2 lines
25 KiB
JavaScript
2 lines
25 KiB
JavaScript
this.primereact=this.primereact||{},this.primereact.autocomplete=function(e,t,n,i,r,o,l,s,p,a,u,c){"use strict";function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=h(t),f=h(c);function m(){return m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},m.apply(this,arguments)}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function y(e){if(Array.isArray(e))return v(e)}function b(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function g(e,t){if(e){if("string"==typeof e)return v(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(e,t):void 0}}function O(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function I(e,t,n){return t&&C(e.prototype,t),n&&C(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function E(e,t){return E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},E(e,t)}function S(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&E(e,t)}function R(e){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},R(e)}function D(e,t){if(t&&("object"===R(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return w(e)}function x(e){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},x(e)}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?L(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function P(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var H=function(e){S(a,e);var t,n,i=(t=a,n=P(),function(){var e,i=x(t);if(n){var r=x(this).constructor;e=Reflect.construct(i,arguments,r)}else e=i.apply(this,arguments);return D(this,e)});function a(){return k(this,a),i.apply(this,arguments)}return I(a,[{key:"getOptionGroupRenderKey",value:function(e){return r.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"renderGroupChildren",value:function(e,t){var n=this;return this.props.getOptionGroupChildren(e).map((function(e,i){var l=n.props.itemTemplate?r.ObjectUtils.getJSXElement(n.props.itemTemplate,e,i):n.props.field?r.ObjectUtils.resolveFieldData(e,n.props.field):e;return d.default.createElement("li",{key:i+"_item",role:"option","aria-selected":n.props.ariaSelected===e,className:"p-autocomplete-item",onClick:function(t){return n.props.onItemClick(t,e)},"data-group":t,"data-index":i},l,d.default.createElement(o.Ripple,null))}))}},{key:"renderItem",value:function(e,t){var n=this;if(this.props.optionGroupLabel){var i=this.props.optionGroupTemplate?r.ObjectUtils.getJSXElement(this.props.optionGroupTemplate,e,t):this.props.getOptionGroupLabel(e),l=this.renderGroupChildren(e,t),s=t+"_"+this.getOptionGroupRenderKey(e);return d.default.createElement(d.default.Fragment,{key:s},d.default.createElement("li",{className:"p-autocomplete-item-group"},i),l)}var p=this.props.itemTemplate?r.ObjectUtils.getJSXElement(this.props.itemTemplate,e,t):this.props.field?r.ObjectUtils.resolveFieldData(e,this.props.field):e;return d.default.createElement("li",{key:t+"_item",role:"option","aria-selected":this.props.ariaSelected===e,className:"p-autocomplete-item",onClick:function(t){return n.props.onItemClick(t,e)}},p,d.default.createElement(o.Ripple,null))}},{key:"renderItems",value:function(){var e=this;return this.props.suggestions?this.props.suggestions.map((function(t,n){return e.renderItem(t,n)})):null}},{key:"renderContent",value:function(){var e=this;if(this.props.virtualScrollerOptions){var t=M(M({},this.props.virtualScrollerOptions),{style:M(M({},this.props.virtualScrollerOptions.style),{height:this.props.scrollHeight}),items:this.props.suggestions,itemTemplate:function(t,n){return t&&e.renderItem(t,n.index)},contentTemplate:function(t){var n=r.classNames("p-autocomplete-items",t.className);return d.default.createElement("ul",{ref:t.contentRef,className:n,role:"listbox",id:e.props.listId},t.children)}});return d.default.createElement(p.VirtualScroller,m({ref:this.props.virtualScrollerRef},t))}var n=this.renderItems();return d.default.createElement("ul",{className:"p-autocomplete-items",role:"listbox",id:this.props.listId},n)}},{key:"renderElement",value:function(){var e=r.classNames("p-autocomplete-panel p-component",this.props.panelClassName),t=M({maxHeight:this.props.scrollHeight},this.props.panelStyle),n=this.renderContent();return d.default.createElement(l.CSSTransition,{nodeRef:this.props.forwardRef,classNames:"p-connected-overlay",in:this.props.in,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.props.onEnter,onEntering:this.props.onEntering,onEntered:this.props.onEntered,onExit:this.props.onExit,onExited:this.props.onExited},d.default.createElement("div",{ref:this.props.forwardRef,className:e,style:t,onClick:this.props.onClick},n))}},{key:"render",value:function(){var e=this.renderElement();return d.default.createElement(s.Portal,{element:e,appendTo:this.props.appendTo})}}]),a}(t.Component),N=d.default.forwardRef((function(e,t){return d.default.createElement(H,m({forwardRef:t},e))}));function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function G(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=F(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,o=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw o}}}}function F(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(e,t):void 0}}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function K(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var A=function(e){S(p,e);var o,l,s=(o=p,l=K(),function(){var e,t=x(o);if(l){var n=x(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return D(this,e)});function p(e){var n;return k(this,p),(n=s.call(this,e)).state={id:n.props.id,searching:!1,focused:!1,overlayVisible:!1},n.onInputChange=n.onInputChange.bind(w(n)),n.onInputFocus=n.onInputFocus.bind(w(n)),n.onInputBlur=n.onInputBlur.bind(w(n)),n.onInputKeyDown=n.onInputKeyDown.bind(w(n)),n.onDropdownClick=n.onDropdownClick.bind(w(n)),n.onMultiContainerClick=n.onMultiContainerClick.bind(w(n)),n.onMultiInputFocus=n.onMultiInputFocus.bind(w(n)),n.onMultiInputBlur=n.onMultiInputBlur.bind(w(n)),n.selectItem=n.selectItem.bind(w(n)),n.getOptionGroupLabel=n.getOptionGroupLabel.bind(w(n)),n.getOptionGroupChildren=n.getOptionGroupChildren.bind(w(n)),n.onOverlayEnter=n.onOverlayEnter.bind(w(n)),n.onOverlayEntering=n.onOverlayEntering.bind(w(n)),n.onOverlayEntered=n.onOverlayEntered.bind(w(n)),n.onOverlayExit=n.onOverlayExit.bind(w(n)),n.onOverlayExited=n.onOverlayExited.bind(w(n)),n.onPanelClick=n.onPanelClick.bind(w(n)),n.overlayRef=t.createRef(),n.virtualScrollerRef=t.createRef(),n.inputRef=t.createRef(n.props.inputRef),n}return I(p,[{key:"onInputChange",value:function(e){var t=this;this.timeout&&clearTimeout(this.timeout);var n=e.target.value;this.props.multiple||this.updateModel(e,n),0===n.length?(this.hideOverlay(),this.props.onClear&&this.props.onClear(e)):n.length>=this.props.minLength?this.timeout=setTimeout((function(){t.search(e,n,"input")}),this.props.delay):this.hideOverlay()}},{key:"search",value:function(e,t,n){null!=t&&("input"===n&&0===t.trim().length||this.props.completeMethod&&(this.setState({searching:!0}),this.props.completeMethod({originalEvent:e,query:t})))}},{key:"selectItem",value:function(e,t,n){if(this.props.multiple){if(this.inputRef.current.value="",!this.isSelected(t)){var i=this.props.value?[].concat(y(r=this.props.value)||b(r)||g(r)||O(),[t]):[t];this.updateModel(e,i)}}else this.updateInputField(t),this.updateModel(e,t);var r;this.props.onSelect&&this.props.onSelect({originalEvent:e,value:t}),n||(this.inputRef.current.focus(),this.hideOverlay())}},{key:"updateModel",value:function(e,t){this.props.onChange&&this.props.onChange({originalEvent:e,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.state.id,value:t}}),this.ariaSelected=t}},{key:"formatValue",value:function(e){if(e){if(this.props.selectedItemTemplate&&(this.props.multiple?this.isSelected(e):this.findOptionIndex(e)>-1)){var t=r.ObjectUtils.getJSXElement(this.props.selectedItemTemplate,e);return t||e}if(this.props.field){var n=r.ObjectUtils.resolveFieldData(e,this.props.field);return null!=n?n:e}return e}return""}},{key:"updateInputField",value:function(e){var t=this.formatValue(e);this.inputRef.current.value=t}},{key:"showOverlay",value:function(){this.setState({overlayVisible:!0})}},{key:"hideOverlay",value:function(){this.setState({overlayVisible:!1,searching:!1})}},{key:"onOverlayEnter",value:function(){r.ZIndexUtils.set("overlay",this.overlayRef.current,f.default.autoZIndex,f.default.zIndex.overlay),this.alignOverlay()}},{key:"onOverlayEntering",value:function(){this.props.autoHighlight&&this.props.suggestions&&this.props.suggestions.length&&r.DomHandler.addClass(this.overlayRef.current.firstChild.firstChild,"p-highlight")}},{key:"onOverlayEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.props.onShow&&this.props.onShow()}},{key:"onOverlayExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onOverlayExited",value:function(){r.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){r.DomHandler.alignOverlay(this.overlayRef.current,this.props.multiple?this.multiContainer:this.inputRef.current,this.props.appendTo||f.default.appendTo)}},{key:"onPanelClick",value:function(e){u.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"onDropdownClick",value:function(e){this.inputRef.current.focus(),"blank"===this.props.dropdownMode?this.search(e,"","dropdown"):"current"===this.props.dropdownMode&&this.search(e,this.inputRef.current.value,"dropdown"),this.props.onDropdownClick&&this.props.onDropdownClick({originalEvent:e,query:this.inputRef.current.value})}},{key:"removeItem",value:function(e,t){var n=this.props.value[t],i=this.props.value.filter((function(e,n){return t!==n}));this.updateModel(e,i),this.props.onUnselect&&this.props.onUnselect({originalEvent:e,value:n})}},{key:"onInputKeyDown",value:function(e){if(this.state.overlayVisible){var t=r.DomHandler.findSingle(this.overlayRef.current,"li.p-highlight");switch(e.which){case 40:if(t){var n=this.findNextItem(t);n&&(r.DomHandler.addClass(n,"p-highlight"),r.DomHandler.removeClass(t,"p-highlight"),r.DomHandler.scrollInView(this.overlayRef.current,n))}else t=r.DomHandler.findSingle(this.overlayRef.current,"li"),r.DomHandler.hasClass(t,"p-autocomplete-item-group")&&(t=this.findNextItem(t)),t&&r.DomHandler.addClass(t,"p-highlight");e.preventDefault();break;case 38:if(t){var i=this.findPrevItem(t);i&&(r.DomHandler.addClass(i,"p-highlight"),r.DomHandler.removeClass(t,"p-highlight"),r.DomHandler.scrollInView(this.overlayRef.current,i))}e.preventDefault();break;case 13:t&&(this.selectHighlightItem(e,t),this.hideOverlay()),e.preventDefault();break;case 27:this.hideOverlay(),e.preventDefault();break;case 9:t&&this.selectHighlightItem(e,t),this.hideOverlay()}}if(this.props.multiple&&8===e.which)if(this.props.value&&this.props.value.length&&!this.inputRef.current.value){var o=this.props.value[this.props.value.length-1],l=this.props.value.slice(0,-1);this.updateModel(e,l),this.props.onUnselect&&this.props.onUnselect({originalEvent:e,value:o})}}},{key:"selectHighlightItem",value:function(e,t){this.props.optionGroupLabel?this.selectItem(e,this.getOptionGroupChildren(this.props.suggestions[t.dataset.group])[t.dataset.index]):this.selectItem(e,this.props.suggestions[r.DomHandler.index(t)])}},{key:"findNextItem",value:function(e){var t=e.nextElementSibling;return t?r.DomHandler.hasClass(t,"p-autocomplete-item-group")?this.findNextItem(t):t:null}},{key:"findPrevItem",value:function(e){var t=e.previousElementSibling;return t?r.DomHandler.hasClass(t,"p-autocomplete-item-group")?this.findPrevItem(t):t:null}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"forceItemSelection",value:function(e){var t=!1,n=e.target.value.trim();if(this.props.suggestions){var i,o=G(this.props.suggestions);try{for(o.s();!(i=o.n()).done;){var l=i.value,s=this.props.field?r.ObjectUtils.resolveFieldData(l,this.props.field):l;if(s&&n===s.trim()){t=!0,this.selectItem(e,l,!0);break}}}catch(e){o.e(e)}finally{o.f()}}t||(this.inputRef.current.value="",this.updateModel(e,null),this.props.onClear&&this.props.onClear(e))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.forceSelection&&t.forceItemSelection(e),t.props.onBlur&&t.props.onBlur(e)}))}},{key:"onMultiContainerClick",value:function(e){this.inputRef.current.focus(),this.props.onClick&&this.props.onClick(e)}},{key:"onMultiInputFocus",value:function(e){this.onInputFocus(e),r.DomHandler.addClass(this.multiContainer,"p-focus")}},{key:"onMultiInputBlur",value:function(e){this.onInputBlur(e),r.DomHandler.removeClass(this.multiContainer,"p-focus")}},{key:"isSelected",value:function(e){var t=!1;if(this.props.value&&this.props.value.length)for(var n=0;n<this.props.value.length;n++)if(r.ObjectUtils.equals(this.props.value[n],e)){t=!0;break}return t}},{key:"findOptionIndex",value:function(e){var t=-1;if(this.props.suggestions)for(var n=0;n<this.props.suggestions.length;n++)if(r.ObjectUtils.equals(e,this.props.suggestions[n])){t=n;break}return t}},{key:"getOptionGroupLabel",value:function(e){return this.props.optionGroupLabel?r.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel):e}},{key:"getOptionGroupChildren",value:function(e){return r.ObjectUtils.resolveFieldData(e,this.props.optionGroupChildren)}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){3!==t.which&&e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hideOverlay()},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new r.ConnectedOverlayScrollHandler(this.container,(function(){e.state.overlayVisible&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!r.DomHandler.isTouchDevice()&&e.hideOverlay()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)&&!this.isInputClicked(e)}},{key:"isInputClicked",value:function(e){return this.props.multiple?e.target===this.multiContainer||this.multiContainer.contains(e.target):e.target===this.inputRef.current}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef(),this.state.id||this.setState({id:r.UniqueComponentId()}),this.props.autoFocus&&this.inputRef&&this.inputRef.current&&this.inputRef.current.focus(),this.props.tooltip&&this.renderTooltip()}},{key:"componentDidUpdate",value:function(e){e.suggestions!==this.props.suggestions&&this.state.searching&&(this.props.suggestions&&this.props.suggestions.length?this.showOverlay():this.hideOverlay(),this.setState({searching:!1})),this.inputRef&&this.inputRef.current&&!this.props.multiple&&this.updateInputField(this.props.value),e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(U({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip())}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null),this.timeout&&clearTimeout(this.timeout),r.ZIndexUtils.clear(this.overlayRef.current)}},{key:"renderTooltip",value:function(){this.tooltip=a.tip({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderSimpleAutoComplete",value:function(){var e=r.classNames("p-autocomplete-input",this.props.inputClassName,{"p-autocomplete-dd-input":this.props.dropdown});return d.default.createElement(n.InputText,{ref:this.inputRef,id:this.props.inputId,type:this.props.type,name:this.props.name,defaultValue:this.formatValue(this.props.value),role:"searchbox","aria-autocomplete":"list","aria-controls":this.state.id+"_list","aria-labelledby":this.props.ariaLabelledBy,className:e,style:this.props.inputStyle,autoComplete:"off",readOnly:this.props.readOnly,disabled:this.props.disabled,placeholder:this.props.placeholder,size:this.props.size,maxLength:this.props.maxLength,tabIndex:this.props.tabIndex,onBlur:this.onInputBlur,onFocus:this.onInputFocus,onChange:this.onInputChange,onMouseDown:this.props.onMouseDown,onKeyUp:this.props.onKeyUp,onKeyDown:this.onInputKeyDown,onKeyPress:this.props.onKeyPress,onContextMenu:this.props.onContextMenu,onClick:this.props.onClick,onDoubleClick:this.props.onDblClick})}},{key:"renderChips",value:function(){var e=this;return this.props.value&&this.props.value.length?this.props.value.map((function(t,n){return d.default.createElement("li",{key:n+"multi-item",className:"p-autocomplete-token p-highlight"},d.default.createElement("span",{className:"p-autocomplete-token-label"},e.formatValue(t)),!e.props.disabled&&r.IconUtils.getJSXIcon(e.props.removeIcon,{className:"p-autocomplete-token-icon",onClick:function(t){return e.removeItem(t,n)}},{props:e.props}))})):null}},{key:"renderMultiInput",value:function(){return d.default.createElement("li",{className:"p-autocomplete-input-token"},d.default.createElement("input",{ref:this.inputRef,type:this.props.type,disabled:this.props.disabled,placeholder:this.props.placeholder,role:"searchbox","aria-autocomplete":"list","aria-controls":this.state.id+"_list","aria-labelledby":this.props.ariaLabelledBy,autoComplete:"off",tabIndex:this.props.tabIndex,onChange:this.onInputChange,id:this.props.inputId,name:this.props.name,style:this.props.inputStyle,className:this.props.inputClassName,maxLength:this.props.maxLength,onKeyUp:this.props.onKeyUp,onKeyDown:this.onInputKeyDown,onKeyPress:this.props.onKeyPress,onFocus:this.onMultiInputFocus,onBlur:this.onMultiInputBlur}))}},{key:"renderMultipleAutoComplete",value:function(){var e=this,t=r.classNames("p-autocomplete-multiple-container p-component p-inputtext",{"p-disabled":this.props.disabled}),n=this.renderChips(),i=this.renderMultiInput();return d.default.createElement("ul",{ref:function(t){e.multiContainer=t},className:t,onContextMenu:this.props.onContextMenu,onMouseDown:this.props.onMouseDown,onClick:this.onMultiContainerClick,onDoubleClick:this.props.onDblClick},n,i)}},{key:"renderDropdown",value:function(){var e=this;return d.default.createElement(i.Button,{ref:function(t){return e.dropdownButton=t},type:"button",icon:this.props.dropdownIcon,className:"p-autocomplete-dropdown",disabled:this.props.disabled,onClick:this.onDropdownClick})}},{key:"renderLoader",value:function(){return this.state.searching?d.default.createElement("i",{className:"p-autocomplete-loader pi pi-spinner pi-spin"}):null}},{key:"render",value:function(){var e,t,n=this,i=r.classNames("p-autocomplete p-component p-inputwrapper",this.props.className,{"p-autocomplete-dd":this.props.dropdown,"p-autocomplete-multiple":this.props.multiple,"p-inputwrapper-filled":this.props.value,"p-inputwrapper-focus":this.state.focused}),o=this.renderLoader();return e=this.props.multiple?this.renderMultipleAutoComplete():this.renderSimpleAutoComplete(),this.props.dropdown&&(t=this.renderDropdown()),d.default.createElement("span",{ref:function(e){return n.container=e},id:this.state.id,style:this.props.style,className:i,"aria-haspopup":"listbox","aria-expanded":this.state.overlayVisible,"aria-owns":this.state.id+"_list"},e,o,t,d.default.createElement(N,m({ref:this.overlayRef,virtualScrollerRef:this.virtualScrollerRef},this.props,{listId:this.state.id+"_list",onItemClick:this.selectItem,ariaSelected:this.ariaSelected,onClick:this.onPanelClick,getOptionGroupLabel:this.getOptionGroupLabel,getOptionGroupChildren:this.getOptionGroupChildren,in:this.state.overlayVisible,onEnter:this.onOverlayEnter,onEntering:this.onOverlayEntering,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited})))}}]),p}(t.Component);return j(A,"defaultProps",{id:null,inputRef:null,value:null,name:null,type:"text",suggestions:null,field:null,optionGroupLabel:null,optionGroupChildren:null,optionGroupTemplate:null,forceSelection:!1,autoHighlight:!1,virtualScrollerOptions:null,scrollHeight:"200px",dropdown:!1,dropdownMode:"blank",multiple:!1,minLength:1,delay:300,style:null,className:null,inputId:null,inputStyle:null,inputClassName:null,panelClassName:null,panelStyle:null,placeholder:null,readOnly:!1,disabled:!1,maxLength:null,size:null,appendTo:null,tabIndex:null,autoFocus:!1,tooltip:null,tooltipOptions:null,ariaLabelledBy:null,completeMethod:null,itemTemplate:null,selectedItemTemplate:null,transitionOptions:null,dropdownIcon:"pi pi-chevron-down",removeIcon:"pi pi-times-circle",onChange:null,onFocus:null,onBlur:null,onSelect:null,onUnselect:null,onDropdownClick:null,onClick:null,onDblClick:null,onMouseDown:null,onKeyUp:null,onKeyPress:null,onContextMenu:null,onClear:null,onShow:null,onHide:null}),e.AutoComplete=A,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.inputtext,primereact.button,primereact.utils,primereact.ripple,primereact.csstransition,primereact.portal,primereact.virtualscroller,primereact.tooltip,primereact.overlayservice,primereact.api);
|