katoikia-app/web-ui/web-react/node_modules/primereact/dropdown/dropdown.min.js

2 lines
31 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.dropdown=function(e,t,n,i,r,o,l,s,a,p){"use strict";function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(t),h=u(s);function d(){return d=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},d.apply(this,arguments)}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(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 y(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function O(e,t){return O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},O(e,t)}function m(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&&O(e,t)}function g(e){return g="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},g(e)}function k(e,t){if(t&&("object"===g(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return b(e)}function C(e){return C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},C(e)}function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(){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 E=function(e){m(l,e);var t,r,o=(t=l,r=w(),function(){var e,n=C(t);if(r){var i=C(this).constructor;e=Reflect.construct(n,arguments,i)}else e=n.apply(this,arguments);return k(this,e)});function l(e){var t;return f(this,l),(t=o.call(this,e)).onClick=t.onClick.bind(b(t)),t}return y(l,[{key:"onClick",value:function(e){this.props.onClick&&this.props.onClick({originalEvent:e,option:this.props.option})}},{key:"render",value:function(){var e=n.classNames("p-dropdown-item",{"p-highlight":this.props.selected,"p-disabled":this.props.disabled,"p-dropdown-item-empty":!this.props.label||0===this.props.label.length},this.props.option.className),t=this.props.template?n.ObjectUtils.getJSXElement(this.props.template,this.props.option):this.props.label;return c.default.createElement("li",{className:e,onClick:this.onClick,"aria-label":this.props.label,key:this.props.label,role:"option","aria-selected":this.props.selected},t,c.default.createElement(i.Ripple,null))}}]),l}(t.Component);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 S(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){I(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 F(){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}}I(E,"defaultProps",{option:null,label:null,template:null,selected:!1,disabled:!1,onClick:null});var R=function(e){m(p,e);var t,i,a=(t=p,i=F(),function(){var e,n=C(t);if(i){var r=C(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return k(this,e)});function p(e){var t;return f(this,p),(t=a.call(this,e)).onEnter=t.onEnter.bind(b(t)),t.onEntered=t.onEntered.bind(b(t)),t.onFilterInputChange=t.onFilterInputChange.bind(b(t)),t}return y(p,[{key:"onEnter",value:function(){var e=this;this.props.onEnter((function(){if(e.virtualScrollerRef){var t=e.props.getSelectedOptionIndex();-1!==t&&e.virtualScrollerRef.scrollToIndex(t)}}))}},{key:"onEntered",value:function(){var e=this;this.props.onEntered((function(){e.props.filter&&e.props.filterInputAutoFocus&&e.filterInput.focus()}))}},{key:"onFilterInputChange",value:function(e){this.virtualScrollerRef&&this.virtualScrollerRef.scrollToIndex(0),this.props.onFilterInputChange&&this.props.onFilterInputChange(e)}},{key:"isEmptyFilter",value:function(){return!(this.props.visibleOptions&&this.props.visibleOptions.length)&&this.props.hasFilter()}},{key:"renderGroupChildren",value:function(e){var t=this;return this.props.getOptionGroupChildren(e).map((function(e,n){var i=t.props.getOptionLabel(e),r=n+"_"+t.props.getOptionRenderKey(e),o=t.props.isOptionDisabled(e);return c.default.createElement(E,{key:r,label:i,option:e,template:t.props.itemTemplate,selected:t.props.isSelected(e),disabled:o,onClick:t.props.onOptionClick})}))}},{key:"renderEmptyMessage",value:function(e,t){var i=n.ObjectUtils.getJSXElement(e,this.props)||s.localeOption(t?"emptyFilterMessage":"emptyMessage");return c.default.createElement("li",{className:"p-dropdown-empty-message"},i)}},{key:"renderItem",value:function(e,t){if(this.props.optionGroupLabel){var i=this.props.optionGroupTemplate?n.ObjectUtils.getJSXElement(this.props.optionGroupTemplate,e,t):this.props.getOptionGroupLabel(e),r=this.renderGroupChildren(e),o=t+"_"+this.props.getOptionGroupRenderKey(e);return c.default.createElement(c.default.Fragment,{key:o},c.default.createElement("li",{className:"p-dropdown-item-group"},i),r)}var l=this.props.getOptionLabel(e),s=t+"_"+this.props.getOptionRenderKey(e),a=this.props.isOptionDisabled(e);return c.default.createElement(E,{key:s,label:l,option:e,template:this.props.itemTemplate,selected:this.props.isSelected(e),disabled:a,onClick:this.props.onOptionClick})}},{key:"renderItems",value:function(){var e=this;return this.props.visibleOptions&&this.props.visibleOptions.length?this.props.visibleOptions.map((function(t,n){return e.renderItem(t,n)})):this.props.hasFilter()?this.renderEmptyMessage(this.props.emptyFilterMessage,!0):this.renderEmptyMessage(this.props.emptyMessage)}},{key:"renderFilterClearIcon",value:function(){var e=this;return this.props.showFilterClear&&this.props.filterValue?c.default.createElement("i",{className:"p-dropdown-filter-clear-icon pi pi-times",onClick:function(){return e.props.onFilterClearIconClick((function(){return e.filterInput.focus()}))}}):null}},{key:"renderFilter",value:function(){var e=this;if(this.props.filter){var t=this.renderFilterClearIcon(),i=n.classNames("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!t});return c.default.createElement("div",{className:"p-dropdown-header"},c.default.createElement("div",{className:i},c.default.createElement("input",{ref:function(t){return e.filterInput=t},type:"text",autoComplete:"off",className:"p-dropdown-filter p-inputtext p-component",placeholder:this.props.filterPlaceholder,onKeyDown:this.props.onFilterInputKeyDown,onChange:this.onFilterInputChange,value:this.props.filterValue}),t,c.default.createElement("i",{className:"p-dropdown-filter-icon pi pi-search"})))}return null}},{key:"renderContent",value:function(){var e=this;if(this.props.virtualScrollerOptions){var t=S(S({},this.props.virtualScrollerOptions),{style:S(S({},this.props.virtualScrollerOptions.style),{height:this.props.scrollHeight}),className:n.classNames("p-dropdown-items-wrapper",this.props.virtualScrollerOptions.className),items:this.props.visibleOptions,onLazyLoad:function(t){return e.props.virtualScrollerOptions.onLazyLoad(S(S({},t),{filter:e.props.filterValue}))},itemTemplate:function(t,n){return t&&e.renderItem(t,n.index)},contentTemplate:function(t){var i=n.classNames("p-dropdown-items",t.className),r=e.isEmptyFilter()?e.renderEmptyMessage():t.children;return c.default.createElement("ul",{ref:t.contentRef,className:i,role:"listbox"},r)}});return c.default.createElement(l.VirtualScroller,d({ref:function(t){return e.virtualScrollerRef=t}},t))}var i=this.renderItems();return c.default.createElement("div",{className:"p-dropdown-items-wrapper",style:{maxHeight:this.props.scrollHeight||"auto"}},c.default.createElement("ul",{className:"p-dropdown-items",role:"listbox"},i))}},{key:"renderElement",value:function(){var e=n.classNames("p-dropdown-panel p-component",this.props.panelClassName),t=this.renderFilter(),i=this.renderContent();return c.default.createElement(r.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.onEnter,onEntering:this.props.onEntering,onEntered:this.onEntered,onExit:this.props.onExit,onExited:this.props.onExited},c.default.createElement("div",{ref:this.props.forwardRef,className:e,style:this.props.panelStyle,onClick:this.props.onClick},t,i))}},{key:"render",value:function(){var e=this.renderElement();return c.default.createElement(o.Portal,{element:e,appendTo:this.props.appendTo})}}]),p}(t.Component),x=c.default.forwardRef((function(e,t){return c.default.createElement(R,d({forwardRef:t},e))}));function D(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 j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){I(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function V(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=P(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 P(e,t){if(e){if("string"==typeof e)return N(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)?N(e,t):void 0}}function N(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 G(){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(e){m(l,e);var i,r,o=(i=l,r=G(),function(){var e,t=C(i);if(r){var n=C(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return k(this,e)});function l(e){var n;return f(this,l),(n=o.call(this,e)).state={filter:"",focused:!1,overlayVisible:!1},n.onClick=n.onClick.bind(b(n)),n.onInputFocus=n.onInputFocus.bind(b(n)),n.onInputBlur=n.onInputBlur.bind(b(n)),n.onInputKeyDown=n.onInputKeyDown.bind(b(n)),n.onEditableInputChange=n.onEditableInputChange.bind(b(n)),n.onEditableInputFocus=n.onEditableInputFocus.bind(b(n)),n.onOptionClick=n.onOptionClick.bind(b(n)),n.onFilterInputChange=n.onFilterInputChange.bind(b(n)),n.onFilterInputKeyDown=n.onFilterInputKeyDown.bind(b(n)),n.onFilterClearIconClick=n.onFilterClearIconClick.bind(b(n)),n.onPanelClick=n.onPanelClick.bind(b(n)),n.onOverlayEnter=n.onOverlayEnter.bind(b(n)),n.onOverlayEntered=n.onOverlayEntered.bind(b(n)),n.onOverlayExit=n.onOverlayExit.bind(b(n)),n.onOverlayExited=n.onOverlayExited.bind(b(n)),n.resetFilter=n.resetFilter.bind(b(n)),n.clear=n.clear.bind(b(n)),n.hasFilter=n.hasFilter.bind(b(n)),n.getOptionLabel=n.getOptionLabel.bind(b(n)),n.getOptionRenderKey=n.getOptionRenderKey.bind(b(n)),n.isOptionDisabled=n.isOptionDisabled.bind(b(n)),n.getOptionGroupChildren=n.getOptionGroupChildren.bind(b(n)),n.getOptionGroupLabel=n.getOptionGroupLabel.bind(b(n)),n.getOptionGroupRenderKey=n.getOptionGroupRenderKey.bind(b(n)),n.getSelectedOptionIndex=n.getSelectedOptionIndex.bind(b(n)),n.isSelected=n.isSelected.bind(b(n)),n.overlayRef=t.createRef(),n.inputRef=t.createRef(n.props.inputRef),n}return y(l,[{key:"onClick",value:function(e){this.props.disabled||n.DomHandler.hasClass(e.target,"p-dropdown-clear-icon")||"INPUT"===e.target.tagName||this.overlayRef.current&&this.overlayRef.current&&this.overlayRef.current.contains(e.target)||(this.focusInput.focus(),this.state.overlayVisible?this.hideOverlay():this.showOverlay())}},{key:"onInputFocus",value:function(e){var t=this;e.persist(),this.props.showOnFocus&&!this.state.overlayVisible&&this.showOverlay(),this.setState({focused:!0},(function(){t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onInputBlur",value:function(e){var t=this;e.persist(),this.setState({focused:!1},(function(){t.props.onBlur&&t.props.onBlur(e)}))}},{key:"onPanelClick",value:function(e){p.OverlayService.emit("overlay-click",{originalEvent:e,target:this.container})}},{key:"onInputKeyDown",value:function(e){switch(e.which){case 40:this.onDownKey(e);break;case 38:this.onUpKey(e);break;case 32:this.state.overlayVisible?this.hideOverlay():this.showOverlay(),e.preventDefault();break;case 13:this.hideOverlay(),e.preventDefault();break;case 27:case 9:this.hideOverlay();break;default:this.search(e)}}},{key:"onFilterInputKeyDown",value:function(e){switch(e.which){case 40:this.onDownKey(e);break;case 38:this.onUpKey(e);break;case 13:case 27:this.hideOverlay(),e.preventDefault()}}},{key:"onUpKey",value:function(e){if(this.getVisibleOptions()){var t=this.findPrevOption(this.getSelectedOptionIndex());t&&this.selectItem({originalEvent:e,option:t})}e.preventDefault()}},{key:"onDownKey",value:function(e){if(this.getVisibleOptions())if(!this.state.overlayVisible&&e.altKey)this.showOverlay();else{var t=this.findNextOption(this.getSelectedOptionIndex());t&&this.selectItem({originalEvent:e,option:t})}e.preventDefault()}},{key:"findNextOption",value:function(e){var t=this.getVisibleOptions();if(this.props.optionGroupLabel){var n=-1===e?0:e.group,i=-1===e?-1:e.option,r=this.findNextOptionInList(this.getOptionGroupChildren(t[n]),i);return r||(n+1!==t.length?this.findNextOption({group:n+1,option:-1}):null)}return this.findNextOptionInList(t,e)}},{key:"findNextOptionInList",value:function(e,t){var n=t+1;if(n===e.length)return null;var i=e[n];return this.isOptionDisabled(i)?this.findNextOptionInList(n):i}},{key:"findPrevOption",value:function(e){if(-1===e)return null;var t=this.getVisibleOptions();if(this.props.optionGroupLabel){var n=e.group,i=e.option,r=this.findPrevOptionInList(this.getOptionGroupChildren(t[n]),i);return r||(n>0?this.findPrevOption({group:n-1,option:this.getOptionGroupChildren(t[n-1]).length}):null)}return this.findPrevOptionInList(t,e)}},{key:"findPrevOptionInList",value:function(e,t){var n=t-1;if(n<0)return null;var i=e[n];return this.isOptionDisabled(i)?this.findPrevOption(n):i}},{key:"search",value:function(e){var t=this;this.searchTimeout&&clearTimeout(this.searchTimeout);var n=e.key;if(this.previousSearchChar=this.currentSearchChar,this.currentSearchChar=n,this.searchValue=this.previousSearchChar===this.currentSearchChar?this.currentSearchChar:this.searchValue?this.searchValue+n:n,this.searchValue){var i=this.getSelectedOptionIndex(),r=this.props.optionGroupLabel?this.searchOptionInGroup(i):this.searchOption(++i);r&&(this.selectItem({originalEvent:e,option:r}),this.selectedOptionUpdated=!0)}this.searchTimeout=setTimeout((function(){t.searchValue=null}),250)}},{key:"searchOption",value:function(e){var t;if(this.searchValue){var n=this.getVisibleOptions();(t=this.searchOptionInRange(e,n.length))||(t=this.searchOptionInRange(0,e))}return t}},{key:"searchOptionInRange",value:function(e,t){for(var n=this.getVisibleOptions(),i=e;i<t;i++){var r=n[i];if(this.matchesSearchValue(r))return r}return null}},{key:"searchOptionInGroup",value:function(e){for(var t=-1===e?{group:0,option:-1}:e,n=this.getVisibleOptions(),i=t.group;i<n.length;i++)for(var r=this.getOptionGroupChildren(n[i]),o=t.group===i?t.option+1:0;o<r.length;o++)if(this.matchesSearchValue(r[o]))return r[o];for(var l=0;l<=t.group;l++)for(var s=this.getOptionGroupChildren(n[l]),a=0;a<(t.group===l?t.option:s.length);a++)if(this.matchesSearchValue(s[a]))return s[a];return null}},{key:"matchesSearchValue",value:function(e){return this.getOptionLabel(e).toLocaleLowerCase(this.props.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.props.filterLocale))}},{key:"onEditableInputChange",value:function(e){this.props.onChange&&this.props.onChange({originalEvent:e.originalEvent,value:e.target.value,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:e.target.value}})}},{key:"onEditableInputFocus",value:function(e){var t=this;e.persist(),this.setState({focused:!0},(function(){t.hideOverlay(),t.props.onFocus&&t.props.onFocus(e)}))}},{key:"onOptionClick",value:function(e){e.option.disabled||(this.selectItem(e),this.focusInput.focus()),this.hideOverlay()}},{key:"onFilterInputChange",value:function(e){var t=this,n=e.target.value;this.setState({filter:n},(function(){t.props.onFilter&&t.props.onFilter({originalEvent:e,filter:n})}))}},{key:"onFilterClearIconClick",value:function(e){this.resetFilter(e)}},{key:"resetFilter",value:function(e){var t=this;this.setState({filter:""},(function(){t.props.onFilter&&t.props.onFilter({filter:""}),e&&e()}))}},{key:"clear",value:function(e){this.props.onChange&&this.props.onChange({originalEvent:e,value:void 0,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:void 0}}),this.updateEditableLabel()}},{key:"selectItem",value:function(e){if(this.getSelectedOption()!==e.option){this.updateEditableLabel(e.option);var t=this.getOptionValue(e.option);this.props.onChange&&this.props.onChange({originalEvent:e.originalEvent,value:t,stopPropagation:function(){},preventDefault:function(){},target:{name:this.props.name,id:this.props.id,value:t}})}}},{key:"getSelectedOption",value:function(){var e=this.getSelectedOptionIndex(),t=this.getVisibleOptions();return-1!==e?this.props.optionGroupLabel?this.getOptionGroupChildren(t[e.group])[e.option]:t[e]:null}},{key:"getSelectedOptionIndex",value:function(){var e=this.getVisibleOptions();if(null!=this.props.value&&e){if(!this.props.optionGroupLabel)return this.findOptionIndexInList(this.props.value,e);for(var t=0;t<e.length;t++){var n=this.findOptionIndexInList(this.props.value,this.getOptionGroupChildren(e[t]));if(-1!==n)return{group:t,option:n}}}return-1}},{key:"findOptionIndexInList",value:function(e,t){for(var i=this.equalityKey(),r=0;r<t.length;r++)if(n.ObjectUtils.equals(e,this.getOptionValue(t[r]),i))return r;return-1}},{key:"isSelected",value:function(e){return n.ObjectUtils.equals(this.props.value,this.getOptionValue(e),this.equalityKey())}},{key:"equalityKey",value:function(){return this.props.optionValue?null:this.props.dataKey}},{key:"showOverlay",value:function(){this.setState({overlayVisible:!0})}},{key:"hideOverlay",value:function(){this.setState({overlayVisible:!1})}},{key:"onOverlayEnter",value:function(e){n.ZIndexUtils.set("overlay",this.overlayRef.current,h.default.autoZIndex,h.default.zIndex.overlay),this.alignOverlay(),e&&e()}},{key:"onOverlayEntered",value:function(e){e&&e(),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(){this.props.filter&&this.props.resetFilterOnHide&&this.resetFilter(),n.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){n.DomHandler.alignOverlay(this.overlayRef.current,this.input.parentElement,this.props.appendTo||h.default.appendTo)}},{key:"scrollInView",value:function(){var e=n.DomHandler.findSingle(this.overlayRef.current,"li.p-highlight");e&&e.scrollIntoView({block:"nearest",inline:"start"})}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){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 n.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&&!n.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.container.isSameNode(e.target)||this.isClearClicked(e)||this.container.contains(e.target)||this.overlayRef&&this.overlayRef.current.contains(e.target))}},{key:"isClearClicked",value:function(e){return n.DomHandler.hasClass(e.target,"p-dropdown-clear-icon")||n.DomHandler.hasClass(e.target,"p-dropdown-filter-clear-icon")}},{key:"updateEditableLabel",value:function(e){this.input&&(this.input.value=e?this.getOptionLabel(e):this.props.value||"")}},{key:"hasFilter",value:function(){return this.state.filter&&this.state.filter.trim().length>0}},{key:"getOptionLabel",value:function(e){return this.props.optionLabel?n.ObjectUtils.resolveFieldData(e,this.props.optionLabel):e&&void 0!==e.label?e.label:e}},{key:"getOptionValue",value:function(e){return this.props.optionValue?n.ObjectUtils.resolveFieldData(e,this.props.optionValue):e&&void 0!==e.value?e.value:e}},{key:"getOptionRenderKey",value:function(e){return this.props.dataKey?n.ObjectUtils.resolveFieldData(e,this.props.dataKey):this.getOptionLabel(e)}},{key:"isOptionDisabled",value:function(e){return this.props.optionDisabled?n.ObjectUtils.isFunction(this.props.optionDisabled)?this.props.optionDisabled(e):n.ObjectUtils.resolveFieldData(e,this.props.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled}},{key:"getOptionGroupRenderKey",value:function(e){return n.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"getOptionGroupLabel",value:function(e){return n.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"getOptionGroupChildren",value:function(e){return n.ObjectUtils.resolveFieldData(e,this.props.optionGroupChildren)}},{key:"checkValidity",value:function(){return!!this.inputRef.current&&this.inputRef.current.checkValidity()}},{key:"isLazy",value:function(){return this.props.virtualScrollerOptions&&this.props.virtualScrollerOptions.lazy}},{key:"getVisibleOptions",value:function(){if(this.hasFilter()&&!this.isLazy()){var e=this.state.filter.trim().toLocaleLowerCase(this.props.filterLocale),t=this.props.filterBy?this.props.filterBy.split(","):[this.props.optionLabel||"label"];if(this.props.optionGroupLabel){var n,i=[],r=V(this.props.options);try{for(r.s();!(n=r.n()).done;){var o=n.value,l=s.FilterService.filter(this.getOptionGroupChildren(o),t,e,this.props.filterMatchMode,this.props.filterLocale);l&&l.length&&i.push(j(j({},o),{items:l}))}}catch(e){r.e(e)}finally{r.f()}return i}return s.FilterService.filter(this.props.options,t,e,this.props.filterMatchMode,this.props.filterLocale)}return this.props.options}},{key:"updateInputField",value:function(){if(this.props.editable&&this.input){var e=this.getSelectedOption(),t=e?this.getOptionLabel(e):null;this.input.value=t||this.props.value||""}}},{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.props.autoFocus&&this.focusInput&&this.focusInput.focus(),this.props.tooltip&&this.renderTooltip(),this.updateInputField(),this.inputRef.current&&(this.inputRef.current.selectedIndex=1)}},{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.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),n.ZIndexUtils.clear(this.overlayRef.current)}},{key:"componentDidUpdate",value:function(e){this.state.overlayVisible&&(this.props.filter&&this.alignOverlay(),e.value!==this.props.value&&this.scrollInView()),e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(j({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),!this.state.filter||this.props.options&&0!==this.props.options.length||this.setState({filter:""}),this.updateInputField(),this.inputRef.current&&(this.inputRef.current.selectedIndex=1)}},{key:"renderHiddenSelect",value:function(e){var t=c.default.createElement("option",{value:""},this.props.placeholder),n=e?c.default.createElement("option",{value:e.value},this.getOptionLabel(e)):null;return c.default.createElement("div",{className:"p-hidden-accessible p-dropdown-hidden-select"},c.default.createElement("select",{ref:this.inputRef,required:this.props.required,name:this.props.name,tabIndex:-1,"aria-hidden":"true"},t,n))}},{key:"renderTooltip",value:function(){this.tooltip=a.tip({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderKeyboardHelper",value:function(){var e=this;return c.default.createElement("div",{className:"p-hidden-accessible"},c.default.createElement("input",{ref:function(t){return e.focusInput=t},id:this.props.inputId,type:"text",readOnly:!0,"aria-haspopup":"listbox",onFocus:this.onInputFocus,onBlur:this.onInputBlur,onKeyDown:this.onInputKeyDown,disabled:this.props.disabled,tabIndex:this.props.tabIndex,"aria-label":this.props.ariaLabel,"aria-labelledby":this.props.ariaLabelledBy}))}},{key:"renderLabel",value:function(e){var t=this,i=n.ObjectUtils.isNotEmpty(e)?this.getOptionLabel(e):null;if(this.props.editable)return c.default.createElement("input",{ref:function(e){return t.input=e},type:"text",defaultValue:i||this.props.value||"",className:"p-dropdown-label p-inputtext",disabled:this.props.disabled,placeholder:this.props.placeholder,maxLength:this.props.maxLength,onInput:this.onEditableInputChange,onFocus:this.onEditableInputFocus,onBlur:this.onInputBlur,"aria-label":this.props.ariaLabel,"aria-labelledby":this.props.ariaLabelledBy,"aria-haspopup":"listbox"});var r=n.classNames("p-dropdown-label p-inputtext",{"p-placeholder":null===i&&this.props.placeholder,"p-dropdown-label-empty":null===i&&!this.props.placeholder}),o=this.props.valueTemplate?n.ObjectUtils.getJSXElement(this.props.valueTemplate,e,this.props):i||this.props.placeholder||"empty";return c.default.createElement("span",{ref:function(e){return t.input=e},className:r},o)}},{key:"renderClearIcon",value:function(){return null!=this.props.value&&this.props.showClear&&!this.props.disabled?c.default.createElement("i",{className:"p-dropdown-clear-icon pi pi-times",onClick:this.clear}):null}},{key:"renderDropdownIcon",value:function(){var e=this,t=n.classNames("p-dropdown-trigger-icon p-clickable",this.props.dropdownIcon);return c.default.createElement("div",{ref:function(t){return e.trigger=t},className:"p-dropdown-trigger",role:"button","aria-haspopup":"listbox","aria-expanded":this.state.overlayVisible},c.default.createElement("span",{className:t}))}},{key:"render",value:function(){var e=this,t=n.classNames("p-dropdown p-component p-inputwrapper",this.props.className,{"p-disabled":this.props.disabled,"p-focus":this.state.focused,"p-dropdown-clearable":this.props.showClear&&!this.props.disabled,"p-inputwrapper-filled":this.props.value,"p-inputwrapper-focus":this.state.focused||this.state.overlayVisible}),i=this.getVisibleOptions(),r=this.getSelectedOption(),o=this.props.appendTo||h.default.appendTo,l=this.renderHiddenSelect(r),s=this.renderKeyboardHelper(),a=this.renderLabel(r),p=this.renderDropdownIcon(),u=this.renderClearIcon();return c.default.createElement("div",{id:this.props.id,ref:function(t){return e.container=t},className:t,style:this.props.style,onClick:this.onClick,onMouseDown:this.props.onMouseDown,onContextMenu:this.props.onContextMenu},s,l,a,u,p,c.default.createElement(x,d({ref:this.overlayRef,visibleOptions:i},this.props,{appendTo:o,onClick:this.onPanelClick,onOptionClick:this.onOptionClick,filterValue:this.state.filter,hasFilter:this.hasFilter,onFilterClearIconClick:this.onFilterClearIconClick,onFilterInputKeyDown:this.onFilterInputKeyDown,onFilterInputChange:this.onFilterInputChange,getOptionLabel:this.getOptionLabel,getOptionRenderKey:this.getOptionRenderKey,isOptionDisabled:this.isOptionDisabled,getOptionGroupChildren:this.getOptionGroupChildren,getOptionGroupLabel:this.getOptionGroupLabel,getOptionGroupRenderKey:this.getOptionGroupRenderKey,isSelected:this.isSelected,getSelectedOptionIndex:this.getSelectedOptionIndex,in:this.state.overlayVisible,onEnter:this.onOverlayEnter,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited})))}}]),l}(t.Component);return I(K,"defaultProps",{id:null,inputRef:null,name:null,value:null,options:null,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,optionGroupTemplate:null,valueTemplate:null,itemTemplate:null,style:null,className:null,virtualScrollerOptions:null,scrollHeight:"200px",filter:!1,filterBy:null,filterMatchMode:"contains",filterPlaceholder:null,filterLocale:void 0,emptyMessage:null,emptyFilterMessage:null,editable:!1,placeholder:null,required:!1,disabled:!1,appendTo:null,tabIndex:null,autoFocus:!1,filterInputAutoFocus:!0,resetFilterOnHide:!1,showFilterClear:!1,panelClassName:null,panelStyle:null,dataKey:null,inputId:null,showClear:!1,maxLength:null,tooltip:null,tooltipOptions:null,ariaLabel:null,ariaLabelledBy:null,transitionOptions:null,dropdownIcon:"pi pi-chevron-down",showOnFocus:!1,onChange:null,onFocus:null,onBlur:null,onMouseDown:null,onContextMenu:null,onShow:null,onHide:null,onFilter:null}),e.Dropdown=K,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple,primereact.csstransition,primereact.portal,primereact.virtualscroller,primereact.api,primereact.tooltip,primereact.overlayservice);