-
Notifications
You must be signed in to change notification settings - Fork 0
/
5762-daaaeefca29aef8f6efd.js
1 lines (1 loc) · 10.4 KB
/
5762-daaaeefca29aef8f6efd.js
1
(self.webpackChunkzent_docs=self.webpackChunkzent_docs||[]).push([[5762],{65762:(e,t,n)=>{"use strict";n.d(t,{Q:()=>f});var o=n(59312),r=n(24246),s=n(27378),i=n(60042),u=n.n(i),a=n(41925),l=n(82285),c=n(33806),p=n(99292),d=n(1348),v=p.ZP.caselessMatchFilterOption,f=function(e){function t(t){var n=e.call(this,t)||this;return n.blurHandlerPrevented=!1,n.refMenuItemList=(0,s.createRef)(),n.onSearchTextChange=function(e){var t=e.target.value,o=n.props.valueFromOptions?n.getSelectedValueFromSearchText(t):t;n.setState({searchText:t,value:o}),n.state.open||n.open(),n.props.onSearch&&n.props.onSearch(t),n.props.onChange&&n.props.onChange(o)},n.onSearchKeyDown=function(e){switch(e.key){case"Escape":case"Tab":n.close();break;case"ArrowDown":e.preventDefault(),n.state.open&&n.moveFocusIndexDown();break;case"ArrowUp":e.preventDefault(),n.state.open&&n.moveFocusIndexUp();break;case"Enter":n.state.open&&n.selectCurrentFocusIndex(e)}},n.onSearchBlur=function(){n.props.valueFromOptions&&setTimeout((function(){if(!n.blurHandlerPrevented){var e=n.state,t=e.searchText,o=e.value,r=n.getSelectedValueFromSearchText(t);r?r!==o&&(n.props.onSelect&&n.props.onSelect(r),n.props.onChange&&n.props.onChange(r)):(n.props.onSelect&&n.props.onSelect(null),n.props.onChange&&n.props.onChange(null))}n.blurHandlerPrevented=!1}),100)},n.getSelectedValueFromSearchText=function(e){var t=null;return n.getTransformedItemConfigsFromProps().some((function(n){return(n.searchContent===e||n.content===e||n.value===e)&&(t=n.value,!0)})),t},n.onSelect=function(e){n.blurHandlerPrevented=!0,n.setState({value:e}),n.props.onSelect&&n.props.onSelect(e),n.props.onChange&&n.props.onChange(e),n.close()},n.getTransformedItemConfigs=(0,a.Z)((function(e,t,n,r,s){return(r||s||[]).map((function(r){if("string"==typeof r||"number"==typeof r)return{value:r,content:r};if("object"==typeof r)return(0,o.pi)((0,o.pi)({},r),{value:r[e],content:r[n]||r[t]||r[e]});throw new Error("AutoComplete unresolvable option!")}))})),n.getDisplayText=function(){var e=n.state.value,t=e||"",o=n.getItemByValue(e);return o&&("string"==typeof o.searchContent?t=o.searchContent:"string"==typeof o.content&&(t=o.content)),t},n.open=function(){var e={open:!0,searchText:n.getDisplayText()||""};n.setState(e)},n.close=function(){n.setState({open:!1})},n.togglePopoverOpen=function(){n.state.open?n.close():n.open()},n.iterateItems=function(e,t){var n=null;return(e||[]).some((function(e){return!(!e||e.value!==t||(n=e,0))})),n},n.getItemByValue=function(e){return n.iterateItems(n.getTransformedItemConfigsFromProps(),e)},n.moveFocusIndexDown=function(){var e=n.refMenuItemList.current;if(e)return e.moveFocusIndexDown()},n.moveFocusIndexUp=function(){var e=n.refMenuItemList.current;if(e)return e.moveFocusIndexUp()},n.selectCurrentFocusIndex=function(e){var t=n.refMenuItemList.current;if(t)return t.selectCurrentFocusIndex(e)},n.state={open:!1,value:t.initialValue||t.value||null,searchText:""},n}return(0,o.ZT)(t,e),t.getDerivedStateFromProps=function(e,t){var n=e.value;return void 0===n||t.value===n?null:{value:e.value}},t.prototype.getTransformedItemConfigsFromProps=function(){var e=this.props,t=e.items,n=e.data,o=e.textField,r=e.valueField,s=e.contentField;return this.getTransformedItemConfigs(r,o,s,t,n)},t.prototype.render=function(){var e=this.props,t=e.width,n=e.placeholder,s=e.className,i=e.popupClassName,a=e.disabled,d=void 0===a?this.context.value:a,v=e.inline,f=this.state,m=f.open,h=f.searchText,I=this.getTransformedItemConfigsFromProps(),x=this.getDisplayText();return(0,r.jsxs)(c.ZP,(0,o.pi)({position:c.ZP.Position.AutoBottomLeft,visible:m,className:u()("zent-auto-complete",i),onVisibleChange:this.togglePopoverOpen,cushion:4},{children:[(0,r.jsx)(c.ZP.Trigger.Click,{children:(0,r.jsx)(l.I,{className:u()("zent-auto-complete",s,{active:m}),value:(m?h:x)||"",placeholder:n,onChange:this.onSearchTextChange,onKeyDown:this.onSearchKeyDown,onBlur:this.onSearchBlur,disabled:d,width:t,inline:v},void 0)},void 0),(0,r.jsx)(c.ZP.Content,{children:(0,r.jsx)(p.ZP,{ref:this.refMenuItemList,items:I,value:this.state.value,searchText:this.state.searchText,onSelect:this.onSelect,filterOption:this.props.filterOption,onRequestClose:this.close},void 0)},void 0)]}),void 0)},t.defaultProps={filterOption:v,valueFromOptions:!1,valueField:"value",contentField:"content",textField:"text",width:160},t.contextType=d.d,t}(s.Component)},99292:(e,t,n)=>{"use strict";n.d(t,{ZP:()=>f});var o=n(59312),r=n(24246),s=n(27378),i=n(41925),u=n(60042),a=n.n(u),l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onClick=function(e){var n=t.props;return c({item:n.item,onRequestClose:n.onRequestClose,event:e})},t.onMouseEnter=function(){var e=t.props;(0,e.focusTo)(e.index,!1)},t.onMouseLeave=function(){t.props.focusTo(null)},t}return(0,o.ZT)(t,e),t.prototype.render=function(){var e=this.props,t=e.item,n=e.hover;if(!t)return null;var s=t.className,i=t.isDivider,u=t.isGroup,l=t.content;if(i)return(0,r.jsx)("div",{className:a()("zent-divider-line",s),"data-zv":"9.12.16"},void 0);if(u)return(0,r.jsx)("li",(0,o.pi)({className:a()("zent-menu-item-group-header",s),"data-zv":"9.12.16"},{children:(0,r.jsx)("span",(0,o.pi)({"data-zv":"9.12.16"},{children:l}),void 0)}),void 0);var c="number"==typeof l||"string"==typeof l?""+l:void 0,p="function"==typeof t.active?t.active(t.value):!!t.active,d=void 0===t.hoverable||!!t.hoverable;return(0,r.jsxs)("li",(0,o.pi)({className:a()("zent-popup-menu-item",{hoverable:d,disabled:t.disabled,active:p,hover:n},s),onClick:this.onClick,onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,"data-zv":"9.12.16"},{children:[t.icon?(0,r.jsx)("i",{className:a()("zent-popup-menu-item-icon"),"data-zv":"9.12.16"},void 0):null,(0,r.jsx)("span",(0,o.pi)({title:c,"data-zv":"9.12.16"},{children:l}),void 0)]}),void 0)},t}(s.Component);function c(e){var t=e.event,n=e.item,o=e.onRequestClose,r=n.disabled,s=n.onClick;r||s&&(s(t),t.defaultPrevented||(t.preventDefault(),t.stopPropagation(),o&&o()))}var p=function(e){function t(t){var n=e.call(this,t)||this;return n.refMenuScrollContainer=(0,s.createRef)(),n.refMenuItemList=(0,s.createRef)(),n.onKeyDown=function(e){switch(e.key){case"Escape":n.close();break;case"ArrowDown":e.preventDefault(),n.state.open&&n.moveFocusIndexDown();break;case"ArrowUp":e.preventDefault(),n.state.open&&n.moveFocusIndexUp();break;case"Enter":n.state.open&&n.selectCurrentFocusIndex(e)}},n.setFocusIndex=function(e,t){void 0===t&&(t=!0),n.setState({focusIdx:null==e?null:n.getItemIdxInItems(e),autoScrollFocusIdx:t?e:null})},n.getItemIdxInItems=function(e){var t=n.props.items,o=e%t.length;return o<0&&(o+=t.length),o},n.getValidItemIdx=function(e,t){void 0===t&&(t=!0);var o=n.props.items;if(!o||!o.length||o.every((function(e){return e.isDivider&&e.isGroup}))||"number"!=typeof e||Number.isNaN(e))return null;var r=n.getItemIdxInItems(e),s=o[r];if(!s||s.isDivider||s.isGroup||s.disabled){var i=r;for(s=o[r=n.getItemIdxInItems(t?r+1:r-1)];!s||(s.isDivider||s.isGroup||s.disabled)&&r!==i;)s=o[r=n.getItemIdxInItems(t?r+1:r-1)]}return r},n.getTopMenu=function(){return n},n.moveFocusIndex=function(e){var t=n.state.focusIdx;null!==t?n.setFocusIndex(n.getValidItemIdx(t+e,e>0)):n.setFocusIndex(n.getValidItemIdx(0))},n.moveFocusIndexDown=function(){n.getTopMenu().moveFocusIndex(1)},n.moveFocusIndexUp=function(){n.getTopMenu().moveFocusIndex(-1)},n.selectCurrentFocusIndex=function(e){var t=n.getTopMenu().state.focusIdx;if(null!==t){var o=n.props,r=o.items,s=o.onRequestClose;c({item:r[t],event:e,onRequestClose:s})}},n.close=function(){n.setState({open:!1})},n.renderItems=function(e){void 0===e&&(e=[]);var t=n.props.onRequestClose,o=n.state.focusIdx;return e.map((function(e,s){return(0,r.jsx)(l,{index:s,item:e,onRequestClose:t,focusTo:n.setFocusIndex,hover:o===s},void 0===e.value?s:e.value)}))},n.state={focusIdx:null},n}return(0,o.ZT)(t,e),t.prototype.componentDidUpdate=function(){this.autoScroll()},t.prototype.autoScroll=function(){var e=(this.props.items||[]).length,t=this.state,n=t.focusIdx,o=t.autoScrollFocusIdx,r=this.refMenuItemList.current,s=this.refMenuScrollContainer.current;if(e&&null!==n&&n===o&&r&&s){var i=r.childNodes[this.state.focusIdx];if(!i)return;var u=i.offsetTop,a=i.offsetHeight,l=s.offsetHeight,c=s.scrollTop;l+c<u+a?s.scrollTop=u+a-l-0:c>u&&(s.scrollTop=u-0)}},t.prototype.render=function(){var e=this.props.items;return(0,r.jsx)("div",(0,o.pi)({ref:this.refMenuScrollContainer,className:"zent-popup-menu",tabIndex:0,onKeyDown:this.onKeyDown,"data-zv":"9.12.16"},{children:e&&e.length?(0,r.jsx)("ul",(0,o.pi)({ref:this.refMenuItemList,"data-zv":"9.12.16"},{children:this.renderItems(e)}),void 0):null}),void 0)},t}(s.Component),d=function(e){return"string"==typeof e||"number"==typeof e};function v(e,t){return!e||(d(t.searchContent)?(""+t.searchContent).toUpperCase().includes(e.toUpperCase()):d(t.content)?(""+t.content).toUpperCase().includes(e.toUpperCase()):!!d(t.value)&&(""+t.value).toUpperCase().includes(e.toUpperCase()))}var f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.refMenuItemList=(0,s.createRef)(),t.wrapWithIdx=function(e,n){return void 0===e&&(e=[]),void 0===n&&(n=[]),e.map((function(e,r){return(0,o.pi)((0,o.pi)({},e),{idx:r,parentIndexes:n,items:e.items?t.wrapWithIdx(e.items,n.concat([r])):void 0})}))},t.wrapWithNullOption=function(e,t){return void 0===e&&(e=[]),[{content:t,value:null,idx:-1,parentIndexes:[]}].concat(e)},t.wrapWithValueCallback=function(e){return void 0===e&&(e=[]),e.map((function(e){return(0,o.pi)((0,o.pi)((0,o.pi)({active:function(e){return e===t.props.value}},e),void 0!==e.value?{onClick:function(n){t.props.onSelect&&t.props.onSelect(e.value,e),e.onClick&&e.onClick(n)}}:{}),{items:t.wrapWithValueCallback(e.items)})}))},t.transformItems=(0,i.Z)((function(e,n,o){var r=t.wrapWithIdx(e);return n&&(r=t.wrapWithNullOption(r,o)),t.wrapWithValueCallback(r)})),t.moveFocusIndexDown=function(){var e=t.refMenuItemList.current;if(e)return e.moveFocusIndexDown()},t.moveFocusIndexUp=function(){var e=t.refMenuItemList.current;if(e)return e.moveFocusIndexUp()},t.selectCurrentFocusIndex=function(e){var n=t.refMenuItemList.current;if(n)return n.selectCurrentFocusIndex(e)},t}return(0,o.ZT)(t,e),t.prototype.render=function(){var e=this.props,t=e.filterOption,n=e.searchText,o=e.items,s=e.nullOption,i=e.nullOptionContent,u=this.transformItems(o,s,i),a=u||[];return"function"==typeof t&&(a=(u||[]).filter((function(e){return t(n,e)}))),(0,r.jsx)(p,{ref:this.refMenuItemList,items:a,onRequestClose:this.props.onRequestClose},void 0)},t.defaultProps={filterOption:v,nullOption:!1},t.caselessMatchFilterOption=v,t}(s.Component)}}]);