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

2 lines
31 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/ripple"),i=require("primereact/csstransition"),r=require("primereact/portal"),o=require("primereact/virtualscroller"),l=require("primereact/api"),s=require("primereact/tooltip"),a=require("primereact/overlayservice");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=p(e),c=p(l);function h(){return h=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},h.apply(this,arguments)}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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 v(e,t,n){return t&&f(e.prototype,t),n&&f(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},b(e,t)}function O(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&&b(e,t)}function m(e){return m="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},m(e)}function g(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}function k(e){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},k(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(){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 w=function(i){O(s,e.Component);var r,o,l=(r=s,o=I(),function(){var e,t=k(r);if(o){var n=k(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function s(e){var t;return d(this,s),(t=l.call(this,e)).onClick=t.onClick.bind(y(t)),t}return v(s,[{key:"onClick",value:function(e){this.props.onClick&&this.props.onClick({originalEvent:e,option:this.props.option})}},{key:"render",value:function(){var e=t.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),i=this.props.template?t.ObjectUtils.getJSXElement(this.props.template,this.props.option):this.props.label;return u.default.createElement("li",{className:e,onClick:this.onClick,"aria-label":this.props.label,key:this.props.label,role:"option","aria-selected":this.props.selected},i,u.default.createElement(n.Ripple,null))}}]),s}();function E(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 L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){C(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function S(){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}}C(w,"defaultProps",{option:null,label:null,template:null,selected:!1,disabled:!1,onClick:null});var F=function(n){O(c,e.Component);var s,a,p=(s=c,a=S(),function(){var e,t=k(s);if(a){var n=k(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function c(e){var t;return d(this,c),(t=p.call(this,e)).onEnter=t.onEnter.bind(y(t)),t.onEntered=t.onEntered.bind(y(t)),t.onFilterInputChange=t.onFilterInputChange.bind(y(t)),t}return v(c,[{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 u.default.createElement(w,{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,n){var i=t.ObjectUtils.getJSXElement(e,this.props)||l.localeOption(n?"emptyFilterMessage":"emptyMessage");return u.default.createElement("li",{className:"p-dropdown-empty-message"},i)}},{key:"renderItem",value:function(e,n){if(this.props.optionGroupLabel){var i=this.props.optionGroupTemplate?t.ObjectUtils.getJSXElement(this.props.optionGroupTemplate,e,n):this.props.getOptionGroupLabel(e),r=this.renderGroupChildren(e),o=n+"_"+this.props.getOptionGroupRenderKey(e);return u.default.createElement(u.default.Fragment,{key:o},u.default.createElement("li",{className:"p-dropdown-item-group"},i),r)}var l=this.props.getOptionLabel(e),s=n+"_"+this.props.getOptionRenderKey(e),a=this.props.isOptionDisabled(e);return u.default.createElement(w,{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?u.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 n=this.renderFilterClearIcon(),i=t.classNames("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!n});return u.default.createElement("div",{className:"p-dropdown-header"},u.default.createElement("div",{className:i},u.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}),n,u.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 n=L(L({},this.props.virtualScrollerOptions),{style:L(L({},this.props.virtualScrollerOptions.style),{height:this.props.scrollHeight}),className:t.classNames("p-dropdown-items-wrapper",this.props.virtualScrollerOptions.className),items:this.props.visibleOptions,onLazyLoad:function(t){return e.props.virtualScrollerOptions.onLazyLoad(L(L({},t),{filter:e.props.filterValue}))},itemTemplate:function(t,n){return t&&e.renderItem(t,n.index)},contentTemplate:function(n){var i=t.classNames("p-dropdown-items",n.className),r=e.isEmptyFilter()?e.renderEmptyMessage():n.children;return u.default.createElement("ul",{ref:n.contentRef,className:i,role:"listbox"},r)}});return u.default.createElement(o.VirtualScroller,h({ref:function(t){return e.virtualScrollerRef=t}},n))}var i=this.renderItems();return u.default.createElement("div",{className:"p-dropdown-items-wrapper",style:{maxHeight:this.props.scrollHeight||"auto"}},u.default.createElement("ul",{className:"p-dropdown-items",role:"listbox"},i))}},{key:"renderElement",value:function(){var e=t.classNames("p-dropdown-panel p-component",this.props.panelClassName),n=this.renderFilter(),r=this.renderContent();return u.default.createElement(i.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},u.default.createElement("div",{ref:this.props.forwardRef,className:e,style:this.props.panelStyle,onClick:this.props.onClick},n,r))}},{key:"render",value:function(){var e=this.renderElement();return u.default.createElement(r.Portal,{element:e,appendTo:this.props.appendTo})}}]),c}(),R=u.default.forwardRef((function(e,t){return u.default.createElement(F,h({forwardRef:t},e))}));function x(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 D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(Object(n),!0).forEach((function(t){C(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=V(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 V(e,t){if(e){if("string"==typeof e)return P(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)?P(e,t):void 0}}function P(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 N(){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 G=function(n){O(p,e.Component);var i,r,o=(i=p,r=N(),function(){var e,t=k(i);if(r){var n=k(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return g(this,e)});function p(t){var n;return d(this,p),(n=o.call(this,t)).state={filter:"",focused:!1,overlayVisible:!1},n.onClick=n.onClick.bind(y(n)),n.onInputFocus=n.onInputFocus.bind(y(n)),n.onInputBlur=n.onInputBlur.bind(y(n)),n.onInputKeyDown=n.onInputKeyDown.bind(y(n)),n.onEditableInputChange=n.onEditableInputChange.bind(y(n)),n.onEditableInputFocus=n.onEditableInputFocus.bind(y(n)),n.onOptionClick=n.onOptionClick.bind(y(n)),n.onFilterInputChange=n.onFilterInputChange.bind(y(n)),n.onFilterInputKeyDown=n.onFilterInputKeyDown.bind(y(n)),n.onFilterClearIconClick=n.onFilterClearIconClick.bind(y(n)),n.onPanelClick=n.onPanelClick.bind(y(n)),n.onOverlayEnter=n.onOverlayEnter.bind(y(n)),n.onOverlayEntered=n.onOverlayEntered.bind(y(n)),n.onOverlayExit=n.onOverlayExit.bind(y(n)),n.onOverlayExited=n.onOverlayExited.bind(y(n)),n.resetFilter=n.resetFilter.bind(y(n)),n.clear=n.clear.bind(y(n)),n.hasFilter=n.hasFilter.bind(y(n)),n.getOptionLabel=n.getOptionLabel.bind(y(n)),n.getOptionRenderKey=n.getOptionRenderKey.bind(y(n)),n.isOptionDisabled=n.isOptionDisabled.bind(y(n)),n.getOptionGroupChildren=n.getOptionGroupChildren.bind(y(n)),n.getOptionGroupLabel=n.getOptionGroupLabel.bind(y(n)),n.getOptionGroupRenderKey=n.getOptionGroupRenderKey.bind(y(n)),n.getSelectedOptionIndex=n.getSelectedOptionIndex.bind(y(n)),n.isSelected=n.isSelected.bind(y(n)),n.overlayRef=e.createRef(),n.inputRef=e.createRef(n.props.inputRef),n}return v(p,[{key:"onClick",value:function(e){this.props.disabled||t.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){a.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,n){for(var i=this.equalityKey(),r=0;r<n.length;r++)if(t.ObjectUtils.equals(e,this.getOptionValue(n[r]),i))return r;return-1}},{key:"isSelected",value:function(e){return t.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){t.ZIndexUtils.set("overlay",this.overlayRef.current,c.default.autoZIndex,c.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(),t.ZIndexUtils.clear(this.overlayRef.current),this.props.onHide&&this.props.onHide()}},{key:"alignOverlay",value:function(){t.DomHandler.alignOverlay(this.overlayRef.current,this.input.parentElement,this.props.appendTo||c.default.appendTo)}},{key:"scrollInView",value:function(){var e=t.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 t.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&&!t.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 t.DomHandler.hasClass(e.target,"p-dropdown-clear-icon")||t.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?t.ObjectUtils.resolveFieldData(e,this.props.optionLabel):e&&void 0!==e.label?e.label:e}},{key:"getOptionValue",value:function(e){return this.props.optionValue?t.ObjectUtils.resolveFieldData(e,this.props.optionValue):e&&void 0!==e.value?e.value:e}},{key:"getOptionRenderKey",value:function(e){return this.props.dataKey?t.ObjectUtils.resolveFieldData(e,this.props.dataKey):this.getOptionLabel(e)}},{key:"isOptionDisabled",value:function(e){return this.props.optionDisabled?t.ObjectUtils.isFunction(this.props.optionDisabled)?this.props.optionDisabled(e):t.ObjectUtils.resolveFieldData(e,this.props.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled}},{key:"getOptionGroupRenderKey",value:function(e){return t.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"getOptionGroupLabel",value:function(e){return t.ObjectUtils.resolveFieldData(e,this.props.optionGroupLabel)}},{key:"getOptionGroupChildren",value:function(e){return t.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=j(this.props.options);try{for(r.s();!(n=r.n()).done;){var o=n.value,s=l.FilterService.filter(this.getOptionGroupChildren(o),t,e,this.props.filterMatchMode,this.props.filterLocale);s&&s.length&&i.push(D(D({},o),{items:s}))}}catch(e){r.e(e)}finally{r.f()}return i}return l.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),t.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(D({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=u.default.createElement("option",{value:""},this.props.placeholder),n=e?u.default.createElement("option",{value:e.value},this.getOptionLabel(e)):null;return u.default.createElement("div",{className:"p-hidden-accessible p-dropdown-hidden-select"},u.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=s.tip({target:this.container,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"renderKeyboardHelper",value:function(){var e=this;return u.default.createElement("div",{className:"p-hidden-accessible"},u.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 n=this,i=t.ObjectUtils.isNotEmpty(e)?this.getOptionLabel(e):null;if(this.props.editable)return u.default.createElement("input",{ref:function(e){return n.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=t.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?t.ObjectUtils.getJSXElement(this.props.valueTemplate,e,this.props):i||this.props.placeholder||"empty";return u.default.createElement("span",{ref:function(e){return n.input=e},className:r},o)}},{key:"renderClearIcon",value:function(){return null!=this.props.value&&this.props.showClear&&!this.props.disabled?u.default.createElement("i",{className:"p-dropdown-clear-icon pi pi-times",onClick:this.clear}):null}},{key:"renderDropdownIcon",value:function(){var e=this,n=t.classNames("p-dropdown-trigger-icon p-clickable",this.props.dropdownIcon);return u.default.createElement("div",{ref:function(t){return e.trigger=t},className:"p-dropdown-trigger",role:"button","aria-haspopup":"listbox","aria-expanded":this.state.overlayVisible},u.default.createElement("span",{className:n}))}},{key:"render",value:function(){var e=this,n=t.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||c.default.appendTo,l=this.renderHiddenSelect(r),s=this.renderKeyboardHelper(),a=this.renderLabel(r),p=this.renderDropdownIcon(),d=this.renderClearIcon();return u.default.createElement("div",{id:this.props.id,ref:function(t){return e.container=t},className:n,style:this.props.style,onClick:this.onClick,onMouseDown:this.props.onMouseDown,onContextMenu:this.props.onContextMenu},s,l,a,d,p,u.default.createElement(R,h({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})))}}]),p}();C(G,"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}),exports.Dropdown=G;