2 lines
25 KiB
JavaScript
2 lines
25 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/inputtext"),n=require("primereact/button"),r=require("primereact/utils"),i=require("primereact/ripple"),o=require("primereact/csstransition"),l=require("primereact/portal"),s=require("primereact/virtualscroller"),p=require("primereact/tooltip"),a=require("primereact/overlayservice"),u=require("primereact/api");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=c(e),d=c(u);function f(){return f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},f.apply(this,arguments)}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function v(e){if(Array.isArray(e))return m(e)}function y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function b(e,t){if(e){if("string"==typeof e)return m(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)?m(e,t):void 0}}function g(){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 O(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function C(e,t,n){return t&&k(e.prototype,t),n&&k(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function I(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e,t){return w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},w(e,t)}function E(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&&w(e,t)}function S(e){return S="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},S(e)}function D(e,t){if(t&&("object"===S(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return I(e)}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function M(){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 P=function(t){E(u,e.Component);var n,p,a=(n=u,p=M(),function(){var e,t=R(n);if(p){var r=R(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return D(this,e)});function u(){return O(this,u),a.apply(this,arguments)}return C(u,[{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,o){var l=n.props.itemTemplate?r.ObjectUtils.getJSXElement(n.props.itemTemplate,e,o):n.props.field?r.ObjectUtils.resolveFieldData(e,n.props.field):e;return h.default.createElement("li",{key:o+"_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":o},l,h.default.createElement(i.Ripple,null))}))}},{key:"renderItem",value:function(e,t){var n=this;if(this.props.optionGroupLabel){var o=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 h.default.createElement(h.default.Fragment,{key:s},h.default.createElement("li",{className:"p-autocomplete-item-group"},o),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 h.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,h.default.createElement(i.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=L(L({},this.props.virtualScrollerOptions),{style:L(L({},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 h.default.createElement("ul",{ref:t.contentRef,className:n,role:"listbox",id:e.props.listId},t.children)}});return h.default.createElement(s.VirtualScroller,f({ref:this.props.virtualScrollerRef},t))}var n=this.renderItems();return h.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=L({maxHeight:this.props.scrollHeight},this.props.panelStyle),n=this.renderContent();return h.default.createElement(o.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},h.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 h.default.createElement(l.Portal,{element:e,appendTo:this.props.appendTo})}}]),u}(),H=h.default.forwardRef((function(e,t){return h.default.createElement(P,f({forwardRef:t},e))}));function N(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function T(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=G(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 G(e,t){if(e){if("string"==typeof e)return F(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)?F(e,t):void 0}}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function B(){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 K=function(i){E(u,e.Component);var o,l,s=(o=u,l=B(),function(){var e,t=R(o);if(l){var n=R(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return D(this,e)});function u(t){var n;return O(this,u),(n=s.call(this,t)).state={id:n.props.id,searching:!1,focused:!1,overlayVisible:!1},n.onInputChange=n.onInputChange.bind(I(n)),n.onInputFocus=n.onInputFocus.bind(I(n)),n.onInputBlur=n.onInputBlur.bind(I(n)),n.onInputKeyDown=n.onInputKeyDown.bind(I(n)),n.onDropdownClick=n.onDropdownClick.bind(I(n)),n.onMultiContainerClick=n.onMultiContainerClick.bind(I(n)),n.onMultiInputFocus=n.onMultiInputFocus.bind(I(n)),n.onMultiInputBlur=n.onMultiInputBlur.bind(I(n)),n.selectItem=n.selectItem.bind(I(n)),n.getOptionGroupLabel=n.getOptionGroupLabel.bind(I(n)),n.getOptionGroupChildren=n.getOptionGroupChildren.bind(I(n)),n.onOverlayEnter=n.onOverlayEnter.bind(I(n)),n.onOverlayEntering=n.onOverlayEntering.bind(I(n)),n.onOverlayEntered=n.onOverlayEntered.bind(I(n)),n.onOverlayExit=n.onOverlayExit.bind(I(n)),n.onOverlayExited=n.onOverlayExited.bind(I(n)),n.onPanelClick=n.onPanelClick.bind(I(n)),n.overlayRef=e.createRef(),n.virtualScrollerRef=e.createRef(),n.inputRef=e.createRef(n.props.inputRef),n}return C(u,[{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 r=this.props.value?[].concat(v(i=this.props.value)||y(i)||b(i)||g(),[t]):[t];this.updateModel(e,r)}}else this.updateInputField(t),this.updateModel(e,t);var i;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,d.default.autoZIndex,d.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||d.default.appendTo)}},{key:"onPanelClick",value:function(e){a.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],r=this.props.value.filter((function(e,n){return t!==n}));this.updateModel(e,r),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=U(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(T({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=p.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 h.default.createElement(t.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 h.default.createElement("li",{key:n+"multi-item",className:"p-autocomplete-token p-highlight"},h.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 h.default.createElement("li",{className:"p-autocomplete-input-token"},h.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 h.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 h.default.createElement(n.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?h.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()),h.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,h.default.createElement(H,f({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})))}}]),u}();x(K,"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}),exports.AutoComplete=K;
|