primereact 10.6.3 → 10.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/accordion.cjs.js +14 -16
- package/accordion/accordion.cjs.min.js +1 -1
- package/accordion/accordion.d.ts +4 -0
- package/accordion/accordion.esm.js +14 -16
- package/accordion/accordion.esm.min.js +1 -1
- package/accordion/accordion.js +14 -16
- package/accordion/accordion.min.js +1 -1
- package/api/api.cjs.js +109 -38
- package/api/api.cjs.min.js +1 -1
- package/api/api.d.ts +5 -0
- package/api/api.esm.js +109 -38
- package/api/api.esm.min.js +1 -1
- package/api/api.js +109 -38
- package/api/api.min.js +1 -1
- package/autocomplete/autocomplete.cjs.js +7 -7
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +7 -7
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +7 -7
- package/autocomplete/autocomplete.min.js +1 -1
- package/breadcrumb/breadcrumb.cjs.js +1 -1
- package/breadcrumb/breadcrumb.cjs.min.js +1 -1
- package/breadcrumb/breadcrumb.esm.js +1 -1
- package/breadcrumb/breadcrumb.esm.min.js +1 -1
- package/breadcrumb/breadcrumb.js +1 -1
- package/breadcrumb/breadcrumb.min.js +1 -1
- package/buttongroup/buttongroup.d.ts +1 -6
- package/calendar/calendar.cjs.js +23 -6
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +23 -6
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +23 -6
- package/calendar/calendar.min.js +1 -1
- package/carousel/carousel.cjs.js +6 -2
- package/carousel/carousel.cjs.min.js +1 -1
- package/carousel/carousel.esm.js +7 -3
- package/carousel/carousel.esm.min.js +1 -1
- package/carousel/carousel.js +6 -2
- package/carousel/carousel.min.js +1 -1
- package/checkbox/checkbox.d.ts +6 -1
- package/chips/chips.cjs.js +12 -12
- package/chips/chips.cjs.min.js +1 -1
- package/chips/chips.esm.js +12 -12
- package/chips/chips.esm.min.js +1 -1
- package/chips/chips.js +12 -12
- package/chips/chips.min.js +1 -1
- package/core/core.js +313 -174
- package/core/core.min.js +7 -7
- package/datatable/datatable.cjs.js +17 -6
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.d.ts +27 -27
- package/datatable/datatable.esm.js +17 -6
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +17 -6
- package/datatable/datatable.min.js +1 -1
- package/dialog/dialog.cjs.js +143 -92
- package/dialog/dialog.cjs.min.js +1 -1
- package/dialog/dialog.esm.js +144 -93
- package/dialog/dialog.esm.min.js +1 -1
- package/dialog/dialog.js +144 -93
- package/dialog/dialog.min.js +1 -1
- package/dropdown/dropdown.cjs.js +39 -40
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.d.ts +17 -17
- package/dropdown/dropdown.esm.js +39 -40
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +39 -40
- package/dropdown/dropdown.min.js +1 -1
- package/editor/editor.cjs.js +2 -2
- package/editor/editor.cjs.min.js +1 -1
- package/editor/editor.esm.js +2 -2
- package/editor/editor.esm.min.js +1 -1
- package/editor/editor.js +2 -2
- package/editor/editor.min.js +1 -1
- package/fileupload/fileupload.d.ts +4 -0
- package/floatlabel/floatlabel.d.ts +5 -0
- package/galleria/galleria.cjs.js +9 -3
- package/galleria/galleria.cjs.min.js +1 -1
- package/galleria/galleria.esm.js +10 -4
- package/galleria/galleria.esm.min.js +1 -1
- package/galleria/galleria.js +9 -3
- package/galleria/galleria.min.js +1 -1
- package/inputnumber/inputnumber.cjs.js +11 -1
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +11 -1
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +11 -1
- package/inputnumber/inputnumber.min.js +1 -1
- package/inputotp/inputotp.cjs.js +9 -9
- package/inputotp/inputotp.cjs.min.js +1 -1
- package/inputotp/inputotp.esm.js +9 -9
- package/inputotp/inputotp.esm.min.js +1 -1
- package/inputotp/inputotp.js +9 -9
- package/inputotp/inputotp.min.js +1 -1
- package/inputotp/package.json +1 -1
- package/keyfilter/keyfilter.cjs.js +3 -1
- package/keyfilter/keyfilter.cjs.min.js +1 -1
- package/keyfilter/keyfilter.esm.js +3 -1
- package/keyfilter/keyfilter.esm.min.js +1 -1
- package/keyfilter/keyfilter.js +3 -1
- package/keyfilter/keyfilter.min.js +1 -1
- package/listbox/listbox.cjs.js +2 -6
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +2 -6
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +2 -6
- package/listbox/listbox.min.js +1 -1
- package/megamenu/megamenu.cjs.js +10 -6
- package/megamenu/megamenu.cjs.min.js +1 -1
- package/megamenu/megamenu.esm.js +10 -6
- package/megamenu/megamenu.esm.min.js +1 -1
- package/megamenu/megamenu.js +10 -6
- package/megamenu/megamenu.min.js +1 -1
- package/menu/menu.cjs.js +23 -5
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.d.ts +19 -0
- package/menu/menu.esm.js +23 -5
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +23 -5
- package/menu/menu.min.js +1 -1
- package/messages/messages.cjs.js +1 -1
- package/messages/messages.cjs.min.js +1 -1
- package/messages/messages.esm.js +1 -1
- package/messages/messages.esm.min.js +1 -1
- package/messages/messages.js +1 -1
- package/messages/messages.min.js +1 -1
- package/metergroup/metergroup.cjs.js +33 -12
- package/metergroup/metergroup.cjs.min.js +1 -1
- package/metergroup/metergroup.esm.js +6 -5
- package/metergroup/metergroup.esm.min.js +1 -1
- package/metergroup/metergroup.js +32 -11
- package/metergroup/metergroup.min.js +1 -1
- package/multiselect/multiselect.cjs.js +18 -3
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.d.ts +17 -17
- package/multiselect/multiselect.esm.js +18 -3
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +18 -3
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/overlaypanel.cjs.js +3 -0
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.d.ts +5 -0
- package/overlaypanel/overlaypanel.esm.js +3 -0
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +3 -0
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +1 -1
- package/paginator/paginator.cjs.js +6 -0
- package/paginator/paginator.cjs.min.js +1 -1
- package/paginator/paginator.esm.js +6 -0
- package/paginator/paginator.esm.min.js +1 -1
- package/paginator/paginator.js +6 -0
- package/paginator/paginator.min.js +1 -1
- package/panelmenu/panelmenu.cjs.js +1 -2
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +1 -2
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +1 -2
- package/panelmenu/panelmenu.min.js +1 -1
- package/passthrough/tailwind/index.cjs.js +14 -4
- package/passthrough/tailwind/index.cjs.min.js +1 -1
- package/passthrough/tailwind/index.esm.js +14 -4
- package/passthrough/tailwind/index.esm.min.js +1 -1
- package/passthrough/tailwind/index.js +14 -4
- package/passthrough/tailwind/index.min.js +1 -1
- package/password/password.cjs.js +104 -15
- package/password/password.cjs.min.js +1 -1
- package/password/password.d.ts +10 -10
- package/password/password.esm.js +104 -15
- package/password/password.esm.min.js +1 -1
- package/password/password.js +105 -16
- package/password/password.min.js +1 -1
- package/picklist/picklist.cjs.js +6 -0
- package/picklist/picklist.cjs.min.js +1 -1
- package/picklist/picklist.esm.js +6 -0
- package/picklist/picklist.esm.min.js +1 -1
- package/picklist/picklist.js +6 -0
- package/picklist/picklist.min.js +1 -1
- package/primereact.all.cjs.js +1121 -920
- package/primereact.all.cjs.min.js +1 -1
- package/primereact.all.esm.js +1121 -920
- package/primereact.all.esm.min.js +1 -1
- package/primereact.all.js +1121 -920
- package/primereact.all.min.js +1 -1
- package/ripple/ripple.d.ts +32 -0
- package/splitter/splitter.cjs.js +6 -1
- package/splitter/splitter.cjs.min.js +1 -1
- package/splitter/splitter.esm.js +6 -1
- package/splitter/splitter.esm.min.js +1 -1
- package/splitter/splitter.js +6 -1
- package/splitter/splitter.min.js +1 -1
- package/stepper/stepper.cjs.js +14 -4
- package/stepper/stepper.cjs.min.js +1 -1
- package/stepper/stepper.d.ts +13 -1
- package/stepper/stepper.esm.js +14 -4
- package/stepper/stepper.esm.min.js +1 -1
- package/stepper/stepper.js +14 -4
- package/stepper/stepper.min.js +1 -1
- package/stepperpanel/stepperpanel.cjs.js +0 -5
- package/stepperpanel/stepperpanel.cjs.min.js +1 -1
- package/stepperpanel/stepperpanel.d.ts +1 -1
- package/stepperpanel/stepperpanel.esm.js +0 -5
- package/stepperpanel/stepperpanel.esm.min.js +1 -1
- package/stepperpanel/stepperpanel.js +2 -6
- package/stepperpanel/stepperpanel.min.js +1 -1
- package/tabview/tabview.cjs.js +1 -1
- package/tabview/tabview.cjs.min.js +1 -1
- package/tabview/tabview.d.ts +4 -0
- package/tabview/tabview.esm.js +1 -1
- package/tabview/tabview.esm.min.js +1 -1
- package/tabview/tabview.js +1 -1
- package/tabview/tabview.min.js +1 -1
- package/toast/toast.cjs.js +7 -1
- package/toast/toast.cjs.min.js +1 -1
- package/toast/toast.esm.js +7 -1
- package/toast/toast.esm.min.js +1 -1
- package/toast/toast.js +7 -1
- package/toast/toast.min.js +1 -1
- package/treeselect/treeselect.cjs.js +12 -2
- package/treeselect/treeselect.cjs.min.js +1 -1
- package/treeselect/treeselect.esm.js +12 -2
- package/treeselect/treeselect.esm.min.js +1 -1
- package/treeselect/treeselect.js +12 -2
- package/treeselect/treeselect.min.js +1 -1
- package/treetable/treetable.cjs.js +8 -0
- package/treetable/treetable.cjs.min.js +1 -1
- package/treetable/treetable.esm.js +8 -0
- package/treetable/treetable.esm.min.js +1 -1
- package/treetable/treetable.js +8 -0
- package/treetable/treetable.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.cjs.js +1 -1
- package/tristatecheckbox/tristatecheckbox.cjs.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.esm.js +1 -1
- package/tristatecheckbox/tristatecheckbox.esm.min.js +1 -1
- package/tristatecheckbox/tristatecheckbox.js +1 -1
- package/tristatecheckbox/tristatecheckbox.min.js +1 -1
- package/virtualscroller/virtualscroller.d.ts +3 -3
- package/web-types.json +61 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/api"),n=require("primereact/componentbase"),r=require("primereact/hooks"),o=require("primereact/icons/chevrondown"),l=require("primereact/icons/spinner"),i=require("primereact/icons/times"),a=require("primereact/overlayservice"),c=require("primereact/tooltip"),u=require("primereact/utils"),s=require("primereact/csstransition"),p=require("primereact/icons/search"),d=require("primereact/portal"),f=require("primereact/virtualscroller"),m=require("primereact/ripple"),v=require("primereact/icons/check"),b=require("primereact/iconbase");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var y=h(e),w=g(t);function O(){return O=Object.assign?Object.assign.bind():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},O.apply(this,arguments)}function I(e){return I="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},I(e)}function E(e,t){if("object"!==I(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==I(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function x(e){var t=E(e,"string");return"symbol"===I(t)?t:String(t)}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e){if(Array.isArray(e))return e}function F(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l,i,a=[],c=!0,u=!1;try{if(l=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=l.call(n)).done)&&(a.push(r.value),a.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function j(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 k(e,t){if(e){if("string"==typeof e)return j(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)?j(e,t):void 0}}function N(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(e,t){return D(e)||F(e,t)||k(e,t)||N()}var L=n.ComponentBase.extend({defaultProps:{__TYPE:"Dropdown",__parentMetadata:null,appendTo:null,ariaLabel:null,ariaLabelledBy:null,autoFocus:!1,children:void 0,className:null,clearIcon:null,dataKey:null,disabled:!1,dropdownIcon:null,editable:!1,emptyFilterMessage:null,highlightOnSelect:!0,checkmark:!1,emptyMessage:null,filter:!1,filterBy:null,filterClearIcon:null,filterIcon:null,filterInputAutoFocus:!1,filterLocale:void 0,filterMatchMode:"contains",filterPlaceholder:null,filterTemplate:null,focusInputRef:null,id:null,inputId:null,inputRef:null,invalid:!1,variant:null,itemTemplate:null,loading:!1,loadingIcon:null,maxLength:null,name:null,onBlur:null,onChange:null,onContextMenu:null,onFilter:null,onFocus:null,onHide:null,onMouseDown:null,onShow:null,optionDisabled:null,optionGroupChildren:"items",selectOnFocus:!1,focusOnHover:!0,autoOptionFocus:!1,optionGroupLabel:null,optionGroupTemplate:null,optionLabel:null,optionValue:null,options:null,panelClassName:null,panelFooterTemplate:null,panelStyle:null,placeholder:null,required:!1,resetFilterOnHide:!1,scrollHeight:"200px",showClear:!1,showFilterClear:!1,showOnFocus:!1,style:null,tabIndex:null,tooltip:null,tooltipOptions:null,transitionOptions:null,value:null,valueTemplate:null,virtualScrollerOptions:null},css:{classes:{root:function(e){var t=e.props,n=e.focusedState,r=e.overlayVisibleState,o=e.context;return u.classNames("p-dropdown p-component p-inputwrapper",{"p-disabled":t.disabled,"p-invalid":t.invalid,"p-focus":n,"p-variant-filled":t.variant?"filled"===t.variant:o&&"filled"===o.inputStyle,"p-dropdown-clearable":t.showClear&&!t.disabled,"p-inputwrapper-filled":u.ObjectUtils.isNotEmpty(t.value),"p-inputwrapper-focus":n||r})},input:function(e){var t=e.props,n=e.label;return t.editable?"p-dropdown-label p-inputtext":u.classNames("p-dropdown-label p-inputtext",{"p-placeholder":null===n&&t.placeholder,"p-dropdown-label-empty":null===n&&!t.placeholder})},trigger:"p-dropdown-trigger",emptyMessage:"p-dropdown-empty-message",itemGroup:function(e){var t=e.optionGroupLabel;return u.classNames("p-dropdown-item-group",{"p-dropdown-item-empty":!t||0===t.length})},itemGroupLabel:"p-dropdown-item-group-label",dropdownIcon:"p-dropdown-trigger-icon p-clickable",loadingIcon:"p-dropdown-trigger-icon p-clickable",clearIcon:"p-dropdown-clear-icon p-clickable",filterIcon:"p-dropdown-filter-icon",filterClearIcon:"p-dropdown-filter-clear-icon",filterContainer:function(e){return u.classNames("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!e.clearIcon})},filterInput:function(e){var t=e.props,n=e.context;return u.classNames("p-dropdown-filter p-inputtext p-component",{"p-variant-filled":t.variant?"filled"===t.variant:n&&"filled"===n.inputStyle})},list:function(e){return"p-dropdown-items"},panel:function(e){var t=e.context;return u.classNames("p-dropdown-panel p-component",{"p-input-filled":t&&"filled"===t.inputStyle||"filled"===w.default.inputStyle,"p-ripple-disabled":t&&!1===t.ripple||!1===w.default.ripple})},item:function(e){var t=e.label;return u.classNames("p-dropdown-item",{"p-highlight":e.selected&&e.highlightOnSelect,"p-disabled":e.disabled,"p-focus":e.index===e.focusedOptionIndex,"p-dropdown-item-empty":!t||0===t.length})},itemLabel:"p-dropdown-item-label",checkIcon:"p-dropdown-check-icon",blankIcon:"p-dropdown-blank-icon",wrapper:"p-dropdown-items-wrapper",header:"p-dropdown-header",footer:"p-dropdown-footer",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-dropdown {\n display: inline-flex;\n cursor: pointer;\n position: relative;\n user-select: none;\n }\n \n .p-dropdown-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n .p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n }\n \n .p-dropdown-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n input.p-dropdown-label {\n cursor: default;\n }\n \n .p-dropdown .p-dropdown-panel {\n min-width: 100%;\n }\n \n .p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-dropdown-items-wrapper {\n overflow: auto;\n }\n \n .p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n \n .p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-dropdown-filter {\n width: 100%;\n }\n \n .p-dropdown-filter-container {\n position: relative;\n }\n \n .p-dropdown-clear-icon,\n .p-dropdown-filter-icon,\n .p-dropdown-filter-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-fluid .p-dropdown {\n display: flex;\n }\n \n .p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n }\n}\n",inlineStyles:{wrapper:function(e){return{maxHeight:e.props.scrollHeight||"auto"}},panel:function(e){}}}}),P=y.memo(y.forwardRef((function(e,t){var n=b.IconBase.getPTI(e);return y.createElement("svg",O({ref:t,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),y.createElement("rect",{width:"1",height:"1",fill:"currentColor",fillOpacity:"0"}))})));P.displayName="BlankIcon";var U=y.memo((function(e){var t=r.useMergeProps(),n=e.ptm,o=e.cx,l=e.selected,i=e.disabled,a=e.option,c=e.label,s=e.index,p=e.focusedOptionIndex,d=e.checkmark,f=e.highlightOnSelect,b=function(e){return n(e,{context:{selected:l,disabled:i}})},g=e.template?u.ObjectUtils.getJSXElement(e.template,e.option):e.label,h=t({role:"option",key:e.label,className:u.classNames(a.className,o("item",{selected:l,disabled:i,label:c,index:s,focusedOptionIndex:p,highlightOnSelect:f})),style:e.style,onClick:function(t){return n=t,void(e.onClick&&e.onClick({originalEvent:n,option:a}));var n},onMouseMove:function(t){return null==e?void 0:e.onMouseMove(t,s)},"aria-label":c,"aria-selected":l,"data-p-highlight":l,"data-p-focused":p===s,"data-p-disabled":i},b("item")),w=t({className:o("itemLabel")},b("itemLabel"));return y.createElement("li",h,d&&function(){if(l){var e=t({className:o("checkIcon")},b("checIcon"));return y.createElement(v.CheckIcon,e)}var n=t({className:o("blankIcon")},b("blankIcon"));return y.createElement(P,n)}(),y.createElement("span",w,g),y.createElement(m.Ripple,null))}));function R(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?R(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}U.displayName="DropdownItem";var M=y.memo(y.forwardRef((function(e,n){var o,l,a,c,m,v=r.useMergeProps(),b=e.ptm,g=e.cx,h=e.sx,w=y.useContext(t.PrimeReactContext),I=y.useRef(null),E=!(e.visibleOptions&&e.visibleOptions.length)&&e.hasFilter,x={filter:function(e){return j(e)},reset:function(){return e.resetFilter()}},S=function(t,n){return b(t,T({hostName:e.hostName},n))},D=function(){e.onEnter((function(){if(e.virtualScrollerRef.current){var t=e.getSelectedOptionIndex();-1!==t&&setTimeout((function(){return e.virtualScrollerRef.current.scrollToIndex(t)}),0)}}))},F=function(){e.onEntered((function(){e.filter&&e.filterInputAutoFocus&&u.DomHandler.focus(I.current,!1)}))},j=function(t){e.virtualScrollerRef.current&&e.virtualScrollerRef.current.scrollToIndex(0),e.onFilterInputChange&&e.onFilterInputChange(t)},k=function(){if(e.panelFooterTemplate){var t=u.ObjectUtils.getJSXElement(e.panelFooterTemplate,e,e.onOverlayHide),n=v({className:g("footer")},S("footer"));return y.createElement("div",n,t)}return null},N=function(t,n){var r;e.focusOnHover&&(null==e||null===(r=e.changeFocusedOptionIndex)||void 0===r||r.call(e,t,n))},C=function(t,n){return e.getOptionGroupChildren(t).map((function(t,r){var o=e.getOptionLabel(t),l=r+"_"+e.getOptionRenderKey(t),i=e.isOptionDisabled(t);return y.createElement(U,{key:l,index:r,focusedOptionIndex:e.focusedOptionIndex,label:o,option:t,style:n,template:e.itemTemplate,selected:e.isSelected(t),highlightOnSelect:e.highlightOnSelect,disabled:i,onClick:e.onOptionClick,onMouseMove:N,ptm:b,cx:g,checkmark:e.checkmark})}))},L=function(n,r){var o=u.ObjectUtils.getJSXElement(n,e)||t.localeOption(r?"emptyFilterMessage":"emptyMessage"),l=v({className:g("emptyMessage")},S("emptyMessage"));return y.createElement("li",l,o)},P=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={height:r.props?r.props.itemSize:void 0};if(o=T(T({},o),t.style),e.optionGroupLabel){var l=e.optionGroupLabel,i=e.optionGroupTemplate?u.ObjectUtils.getJSXElement(e.optionGroupTemplate,t,n):e.getOptionGroupLabel(t),a=C(t,o),c=n+"_"+e.getOptionGroupRenderKey(t),s=v({className:g("itemGroup",{optionGroupLabel:l}),style:o,"data-p-highlight":e.selected},S("itemGroup")),p=v({className:g("itemGroupLabel")},S("itemGroupLabel"));return y.createElement(y.Fragment,{key:c},y.createElement("li",s,y.createElement("span",p,i)),a)}var d=e.getOptionLabel(t),f=n+"_"+e.getOptionRenderKey(t),m=e.isOptionDisabled(t);return y.createElement(U,{key:f,label:d,index:n,focusedOptionIndex:e.focusedOptionIndex,option:t,style:o,template:e.itemTemplate,selected:e.isSelected(t),highlightOnSelect:e.highlightOnSelect,disabled:m,onClick:e.onOptionClick,onMouseMove:N,ptm:b,cx:g,checkmark:e.checkmark})},R=function(){if(e.showFilterClear&&e.filterValue){var n=t.localeOption("clear"),r=v({className:g("filterClearIcon"),"aria-label":n,onClick:function(){return e.onFilterClearIconClick((function(){return u.DomHandler.focus(I.current)}))}},S("filterClearIcon"));return u.IconUtils.getJSXIcon(e.filterClearIcon||y.createElement(i.TimesIcon,r),T({},r),{props:e})}return null},M=function(){if(e.filter){var t=R(),n=v({className:g("filterIcon")},S("filterIcon")),r=u.IconUtils.getJSXIcon(e.filterIcon||y.createElement(p.SearchIcon,n),T({},n),{props:e}),o=v({className:g("filterContainer",{clearIcon:t})},S("filterContainer")),l=v({ref:I,type:"text",autoComplete:"off",className:g("filterInput",{context:w}),placeholder:e.filterPlaceholder,onKeyDown:e.onFilterInputKeyDown,onChange:function(e){return j(e)},value:e.filterValue},S("filterInput")),i=y.createElement("div",o,y.createElement("input",l),t,r);if(e.filterTemplate){var a={className:u.classNames("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!t}),element:i,filterOptions:x,filterInputKeyDown:e.onFilterInputKeyDown,filterInputChange:j,filterIconClassName:"p-dropdown-filter-icon",clearIcon:t,props:e};i=u.ObjectUtils.getJSXElement(e.filterTemplate,a)}var c=v({className:g("header")},S("header"));return y.createElement("div",c,i)}return null},H=function(){if(e.virtualScrollerOptions){var t=T(T({},e.virtualScrollerOptions),{style:T(T({},e.virtualScrollerOptions.style),{height:e.scrollHeight}),className:u.classNames("p-dropdown-items-wrapper",e.virtualScrollerOptions.className),items:e.visibleOptions,autoSize:!0,onLazyLoad:function(t){return e.virtualScrollerOptions.onLazyLoad(T(T({},t),{filter:e.filterValue}))},itemTemplate:function(e,t){return e&&P(e,t.index,t)},contentTemplate:function(t){var n=E?L(e.hasFilter?e.emptyFilterMessage:e.emptyMessage):t.children,r=v({ref:t.contentRef,style:t.style,className:u.classNames(t.className,g("list",{virtualScrollerProps:e.virtualScrollerOptions})),role:"listbox"},S("list"));return y.createElement("ul",r,n)}});return y.createElement(f.VirtualScroller,O({ref:e.virtualScrollerRef},t,{pt:b("virtualScroller")}))}var n=u.ObjectUtils.isNotEmpty(e.visibleOptions)?e.visibleOptions.map(P):e.hasFilter?L(e.emptyFilterMessage,!0):L(e.emptyMessage),r=v({className:g("wrapper"),style:h("wrapper")},S("wrapper")),o=v({className:g("list"),role:"listbox"},S("list"));return y.createElement("div",r,y.createElement("ul",o,n))},G=(o=M(),l=H(),a=k(),c=v({className:u.classNames(e.panelClassName,g("panel",{context:w})),style:h("panel"),onClick:e.onClick},S("panel")),m=v({classNames:g("transition"),in:e.in,timeout:{enter:120,exit:100},options:e.transitionOptions,unmountOnExit:!0,onEnter:D,onEntered:F,onExit:e.onExit,onExited:e.onExited},S("transition")),y.createElement(s.CSSTransition,O({nodeRef:n},m),y.createElement("div",O({ref:n},c),e.firstFocusableElement,o,l,a,e.lastFocusableElement)));return y.createElement(d.Portal,{element:G,appendTo:e.appendTo})})));function H(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,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 l,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,l=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw l}}}}function G(e,t){if(e){if("string"==typeof e)return A(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)?A(e,t):void 0}}function A(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 q(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 K(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?q(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}M.displayName="DropdownPanel";var V=y.memo(y.forwardRef((function(e,s){var p=r.useMergeProps(),d=y.useContext(t.PrimeReactContext),f=L.getProps(e,d),m=C(y.useState(""),2),v=m[0],b=m[1],g=C(y.useState(!1),2),h=g[0],E=g[1],x=C(y.useState(-1),2),D=x[0],F=x[1],j=C(y.useState(!1),2),k=j[0],N=j[1],P=y.useRef(!1),U=y.useRef(null),R=y.useRef(null),T=y.useRef(null),G=y.useRef(null),A=y.useRef(f.inputRef),q=y.useRef(f.focusInputRef),V=y.useRef(null),B=y.useRef(null),_=y.useRef(null);y.useRef(null);var J=f.virtualScrollerOptions&&f.virtualScrollerOptions.lazy,X=u.ObjectUtils.isNotEmpty(v),z=f.appendTo||d&&d.appendTo||w.default.appendTo,Z=L.setMetaData(K(K({props:f},f.__parentMetadata),{},{state:{filter:v,focused:h,overlayVisible:k}})),W=Z.ptm,$=Z.cx,Y=Z.sx;n.useHandleStyle(L.css.styles,Z.isUnstyled,{name:"dropdown"});var Q=C(r.useOverlayListener({target:U,overlay:R,listener:function(e,t){t.valid&&("outside"===t.type?!ne(e)&&Ge():Ge())},when:k}),2),ee=Q[0],te=Q[1],ne=function(e){return u.DomHandler.isAttributeEquals(e.target,"data-pc-section","clearicon")||u.DomHandler.isAttributeEquals(e.target.parentElement||e.target,"data-pc-section","filterclearicon")},re=function(e){f.showOnFocus&&!k&&He(),E(!0),f.onFocus&&f.onFocus(e)},oe=function(e){E(!1),f.onBlur&&setTimeout((function(){var t=A.current?A.current.value:void 0;f.onBlur({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:f.name,id:f.id,value:t}})}),200)},le=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Ve(t);Pe({originalEvent:e,option:r}),n&&Ge()},ie=function(e){if(f.disabled||u.DomHandler.isAndroid())e.preventDefault();else{var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":ge(e);break;case"ArrowUp":he(e);break;case"ArrowLeft":case"ArrowRight":ye(e,f.editable);break;case"Home":we(e);break;case"End":Oe(e);break;case"PageDown":Ee(e);break;case"PageUp":Ie(e);break;case"Space":xe(e,f.editable);break;case"NumpadEnter":case"Enter":Se(e);break;case"Escape":De(e);break;case"Tab":Fe(e);break;case"Backspace":je(e,f.editable);break;case"ShiftLeft":case"ShiftRight":break;default:!t&&u.ObjectUtils.isPrintableCharacter(e.key)&&(!k&&!f.editable&&He(),!f.editable&&fe(e,e.key))}P.current=!1}},ae=function(e){var t;return ce(e)&&(null===(t=Ke(e))||void 0===t?void 0:t.toLocaleLowerCase(f.filterLocale).startsWith(_.current.toLocaleLowerCase(f.filterLocale)))},ce=function(e){return u.ObjectUtils.isNotEmpty(e)&&!(_e(e)||Be(e))},ue=function(){return u.ObjectUtils.isNotEmpty(f.value)},se=function(e){return ce(e)&&Me(e)},pe=function(){return ue?et.findIndex((function(e){return se(e)})):-1},de=function(){var e=pe();return e<0?me():e},fe=function(e,t){_.current=(_.current||"")+t;var n=-1,r=!1;return u.ObjectUtils.isNotEmpty(_.current)&&(-1!==(n=-1!==D?-1===(n=et.slice(D).findIndex((function(e){return ae(e)})))?et.slice(0,D).findIndex((function(e){return ae(e)})):n+D:et.findIndex((function(e){return ae(e)})))&&(r=!0),-1===n&&-1===D&&(n=de()),-1!==n&&be(e,n)),B.current&&clearTimeout(B.current),B.current=setTimeout((function(){_.current="",B.current=null}),500),r},me=function(){return et.findIndex((function(e){return ce(e)}))},ve=function(){return u.ObjectUtils.findLastIndex(et,(function(e){return ce(e)}))},be=function(e,t){D!==t&&(F(t),f.selectOnFocus&&le(e,et[t],!1))},ge=function(e){if(k){var t=-1!==D?(r=(n=D)<et.length-1?et.slice(n+1).findIndex((function(e){return ce(e)})):-1)>-1?r+n+1:n:P.current?me():de();be(e,t)}else He(),f.editable&&be(e,pe());var n,r;e.preventDefault()},he=function(e){var t,n,r;if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==D&&le(e,et[D]),state.overlayVisible&&Ge(),e.preventDefault();else{var o=-1!==D?(r=(n=D)>0?u.ObjectUtils.findLastIndex(et.slice(0,n),(function(e){return ce(e)})):-1)>-1?r:n:P.current?ve():(t=pe())<0?ve():t;be(e,o),!k&&He(),e.preventDefault()}},ye=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&F(-1)},we=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?(e.currentTarget.setSelectionRange(0,0),F(-1)):(be(e,me()),!k&&He()),e.preventDefault()},Oe=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var t=e.currentTarget,n=t.value.length;t.setSelectionRange(n,n),F(-1)}else be(e,ve()),!k&&He();e.preventDefault()},Ie=function(e){e.preventDefault()},Ee=function(e){e.preventDefault()},xe=function(e){!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])&&Se(e)},Se=function(e){k?(-1!==D&&le(e,et[D]),Ge()):(F(-1),ge(e)),e.preventDefault()},De=function(e){k&&Ge(),e.preventDefault()},Fe=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(!k||u.DomHandler.getFocusableElements(R.current,':not([data-p-hidden-focusable="true"])').length>0?(-1!==D&&le(e,et[D]),k&&Ge()):(u.DomHandler.focus(T.current),e.preventDefault()))},je=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&!k&&He()},ke=function(e){var t=null;e.target.value&&(t=et.findIndex((function(t){return Ke(t).toLocaleLowerCase().startsWith(e.target.value.toLocaleLowerCase())}))),F(t),f.onChange&&f.onChange({originalEvent:e.originalEvent,value:e.target.value,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:f.name,id:f.id,value:e.target.value}})},Ne=function(e){E(!0),Ge(),f.onFocus&&f.onFocus(e)},Ce=function(e){b(""),f.onFilter&&f.onFilter({filter:""}),e&&e()},Le=function(e){f.onChange&&f.onChange({originalEvent:e,value:void 0,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:f.name,id:f.id,value:void 0}}),f.filter&&Ce(),qe()},Pe=function(e){if(tt!==e.option){qe(e.option),F(-1);var t=Ve(e.option),n=Te(e.option,et);f.onChange&&f.onChange({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:f.name,id:f.id,value:t}}),be(e.originalEvent,n)}},Ue=function(e){if(e=e||et,null!=f.value&&e){if(!f.optionGroupLabel)return Te(f.value,e);for(var t=0;t<e.length;t++){var n=Te(f.value,Je(e[t]));if(-1!==n)return{group:t,option:n}}}return-1},Re=function(){return f.optionValue?null:f.dataKey},Te=function(e,t){var n=Re();return t.findIndex((function(t){return u.ObjectUtils.equals(e,Ve(t),n)}))},Me=function(e){return u.ObjectUtils.equals(f.value,Ve(e),Re())},He=function(){F(-1!==D?D:f.autoOptionFocus?de():f.editable?-1:pe()),N(!0)},Ge=function(){N(!1),P.current=!1},Ae=function(){u.DomHandler.alignOverlay(R.current,A.current.parentElement,f.appendTo||d&&d.appendTo||w.default.appendTo)},qe=function(e){A.current&&(A.current.value=e?Ke(e):f.value||"",q.current&&(q.current.value=A.current.value))},Ke=function(e){return f.optionLabel?u.ObjectUtils.resolveFieldData(e,f.optionLabel):e&&void 0!==e.label?e.label:e},Ve=function(e){return f.optionValue?u.ObjectUtils.resolveFieldData(e,f.optionValue):e&&void 0!==e.value?e.value:e},Be=function(e){return f.optionGroupLabel&&e.optionGroup&&e.group},_e=function(e){return f.optionDisabled?u.ObjectUtils.isFunction(f.optionDisabled)?f.optionDisabled(e):u.ObjectUtils.resolveFieldData(e,f.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled},Je=function(e){return u.ObjectUtils.resolveFieldData(e,f.optionGroupChildren)},Xe=function(){if(f.editable&&A.current){var e=(tt?Ke(tt):null)||f.value||"";A.current.value=e,q.current&&(q.current.value=e)}};y.useImperativeHandle(s,(function(){return{props:f,show:He,hide:Ge,clear:Le,focus:function(){return u.DomHandler.focus(q.current)},getElement:function(){return U.current},getOverlay:function(){return R.current},getInput:function(){return A.current},getFocusInput:function(){return q.current},getVirtualScroller:function(){return V.current}}})),y.useEffect((function(){u.ObjectUtils.combinedRefs(A,f.inputRef),u.ObjectUtils.combinedRefs(q,f.focusInputRef)}),[A,f.inputRef,q,f.focusInputRef]),r.useMountEffect((function(){f.autoFocus&&u.DomHandler.focus(q.current,f.autoFocus),Ae()})),r.useUpdateEffect((function(){var e;k&&f.value&&(e=u.DomHandler.findSingle(R.current,'li[data-p-highlight="true"]'))&&e.scrollIntoView&&e.scrollIntoView({block:"nearest",inline:"nearest"})}),[k,f.value]),r.useUpdateEffect((function(){k&&v&&f.filter&&Ae()}),[k,v,f.filter]),r.useUpdateEffect((function(){!v||f.options&&0!==f.options.length||b(""),Xe(),A.current&&(A.current.selectedIndex=1)})),r.useUnmountEffect((function(){u.ZIndexUtils.clear(R.current)}));var ze,Ze,We,$e,Ye,Qe=function(e){"Enter"!==e.key&&"Space"!==e.code||(Le(e),e.preventDefault())},et=function(){if(X&&!J){var e=v.trim().toLocaleLowerCase(f.filterLocale),n=f.filterBy?f.filterBy.split(","):[f.optionLabel||"label"];if(f.optionGroupLabel){var r,o=[],l=H(f.options);try{for(l.s();!(r=l.n()).done;){var i=r.value,a=t.FilterService.filter(Je(i),n,e,f.filterMatchMode,f.filterLocale);a&&a.length&&o.push(K(K({},i),S({},"".concat(f.optionGroupChildren),a)))}}catch(e){l.e(e)}finally{l.f()}return o}return t.FilterService.filter(f.options,n,e,f.filterMatchMode,f.filterLocale)}return f.options}(),tt=-1!==(ze=Ue(f.options))?f.optionGroupLabel?Je(f.options[ze.group])[ze.option]:f.options[ze]:null,nt=u.ObjectUtils.isNotEmpty(f.tooltip),rt=L.getOtherProps(f),ot=u.ObjectUtils.reduceKeys(rt,u.DomHandler.ARIA_PROPS),lt=function(){var e={value:"",label:f.placeholder};if(tt){var t=Ve(tt);e={value:"object"===I(t)?f.options.findIndex((function(e){return e===t})):t,label:Ke(tt)}}var n=p({className:"p-hidden-accessible p-dropdown-hidden-select"},W("hiddenSelectedMessage")),r=p({ref:A,required:f.required,defaultValue:e.value,name:f.name,tabIndex:-1,"aria-hidden":"true"},W("select")),o=p({value:e.value},W("option"));return y.createElement("div",n,y.createElement("select",r,y.createElement("option",o,e.label)))}(),it=function(){var e=u.ObjectUtils.isNotEmpty(tt)?Ke(tt):null;f.editable&&(e=e||f.value||"");var t=p({className:"p-hidden-accessible"},W("hiddenSelectedMessage")),n=p(K({ref:q,id:f.inputId,defaultValue:e,type:"text",readOnly:!0,"aria-haspopup":"listbox",onFocus:re,onBlur:oe,onKeyDown:ie,disabled:f.disabled,tabIndex:f.disabled?-1:f.tabIndex||0},ot),W("input"));return y.createElement("div",t,y.createElement("input",n))}(),at=function(){var e=u.ObjectUtils.isNotEmpty(tt)?Ke(tt):null;if(f.editable){var t=p(K({ref:A,type:"text",defaultValue:e||f.value||"",className:$("input",{label:e}),disabled:f.disabled,placeholder:f.placeholder,maxLength:f.maxLength,onInput:ke,onFocus:Ne,onKeyDown:ie,onBlur:oe,tabIndex:f.disabled?-1:f.tabIndex||0,"aria-haspopup":"listbox"},ot),W("input"));return y.createElement("input",t)}var n=f.valueTemplate?u.ObjectUtils.getJSXElement(f.valueTemplate,tt,f):e||f.placeholder||"empty",r=p({ref:A,className:$("input",{label:e}),tabIndex:"-1"},W("input"));return y.createElement("span",r,n)}(),ct=f.loading?(Ze=p({className:$("loadingIcon"),"data-pr-overlay-visible":k},W("loadingIcon")),We=u.IconUtils.getJSXIcon(f.loadingIcon||y.createElement(l.SpinnerIcon,{spin:!0}),K({},Ze),{props:f}),$e=f.placeholder||f.ariaLabel,Ye=p({className:$("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":k,"aria-label":$e},W("trigger")),y.createElement("div",Ye,We)):function(){var e=p({className:$("dropdownIcon"),"data-pr-overlay-visible":k},W("dropdownIcon")),t=u.IconUtils.getJSXIcon(f.dropdownIcon||y.createElement(o.ChevronDownIcon,e),K({},e),{props:f}),n=f.placeholder||f.ariaLabel,r=p({className:$("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":k,"aria-label":n},W("trigger"));return y.createElement("div",r,t)}(),ut=function(){if(null!=f.value&&f.showClear&&!f.disabled){var e=p({className:$("clearIcon"),onPointerUp:Le,tabIndex:f.tabIndex||"0",onKeyDown:Qe,"aria-label":t.localeOption("clear")},W("clearIcon"));return u.IconUtils.getJSXIcon(f.clearIcon||y.createElement(i.TimesIcon,e),K({},e),{props:f})}return null}(),st=p({id:f.id,ref:U,className:u.classNames(f.className,$("root",{context:d,focusedState:h,overlayVisibleState:k})),style:f.style,onClick:function(e){return t=e,void(f.disabled||f.loading||(f.onClick&&f.onClick(t),t.defaultPrevented||ne(t)||"INPUT"===t.target.tagName||(R.current&&R.current&&R.current.contains(t.target)||(u.DomHandler.focus(q.current),k?Ge():He()),P.current=!0)));var t},onMouseDown:f.onMouseDown,onContextMenu:f.onContextMenu,onFocus:function(){f.editable&&!k&&!1===P.current&&u.DomHandler.focus(A.current)},"data-p-disabled":f.disabled,"data-p-focus":h},rt,W("root")),pt=p({ref:T,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===q.current?u.DomHandler.getFirstFocusableElement(R.current,':not([data-p-hidden-focusable="true"])'):q.current;u.DomHandler.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},W("hiddenFirstFocusableEl")),dt=p({ref:G,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===q.current?u.DomHandler.getLastFocusableElement(R.current,':not([data-p-hidden-focusable="true"])'):q.current;u.DomHandler.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},W("hiddenLastFocusableEl"));return y.createElement(y.Fragment,null,y.createElement("div",st,it,lt,at,ut,ct,y.createElement(M,O({hostName:"Dropdown",ref:R,visibleOptions:et,virtualScrollerRef:V},f,{appendTo:z,cx:$,filterValue:v,focusedOptionIndex:D,getOptionGroupChildren:Je,getOptionGroupLabel:function(e){return u.ObjectUtils.resolveFieldData(e,f.optionGroupLabel)},getOptionGroupRenderKey:function(e){return u.ObjectUtils.resolveFieldData(e,f.optionGroupLabel)},getOptionLabel:Ke,getOptionRenderKey:function(e){return f.dataKey?u.ObjectUtils.resolveFieldData(e,f.dataKey):Ke(e)},getSelectedOptionIndex:Ue,hasFilter:X,in:k,isOptionDisabled:_e,isSelected:Me,onClick:function(e){a.OverlayService.emit("overlay-click",{originalEvent:e,target:U.current})},onEnter:function(e){u.ZIndexUtils.set("overlay",R.current,d&&d.autoZIndex||w.default.autoZIndex,d&&d.zIndex.overlay||w.default.zIndex.overlay),u.DomHandler.addStyles(R.current,{position:"absolute",top:"0",left:"0"}),Ae(),e&&e()},onEntered:function(e){e&&e(),ee(),f.onShow&&f.onShow()},onExit:function(){te()},onExited:function(){f.filter&&f.resetFilterOnHide&&Ce(),u.ZIndexUtils.clear(R.current),f.onHide&&f.onHide()},onFilterClearIconClick:function(e){Ce(e)},onFilterInputChange:function(e){var t=e.target.value;b(t),f.onFilter&&f.onFilter({originalEvent:e,filter:t})},onFilterInputKeyDown:function(e){switch(e.code){case"ArrowDown":ge(e);break;case"ArrowUp":he(e);break;case"ArrowLeft":case"ArrowRight":ye(e,!0);break;case"Escape":case"Enter":case"NumpadEnter":Se(e),e.preventDefault()}},onOptionClick:function(e){e.option.disabled||(Pe(e),u.DomHandler.focus(q.current)),Ge()},ptm:W,resetFilter:Ce,changeFocusedOptionIndex:be,firstFocusableElement:y.createElement("span",pt),lastFocusableElement:y.createElement("span",dt),sx:Y}))),nt&&y.createElement(c.Tooltip,O({target:U,content:f.tooltip,pt:W("tooltip")},f.tooltipOptions)))})));V.displayName="Dropdown",exports.Dropdown=V;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/api"),n=require("primereact/componentbase"),r=require("primereact/hooks"),o=require("primereact/icons/chevrondown"),l=require("primereact/icons/spinner"),i=require("primereact/icons/times"),a=require("primereact/overlayservice"),u=require("primereact/tooltip"),c=require("primereact/utils"),s=require("primereact/csstransition"),p=require("primereact/icons/search"),d=require("primereact/portal"),f=require("primereact/virtualscroller"),m=require("primereact/ripple"),v=require("primereact/icons/check"),b=require("primereact/iconbase");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var y=h(e),w=g(t);function O(){return O=Object.assign?Object.assign.bind():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},O.apply(this,arguments)}function I(e){return I="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},I(e)}function E(e,t){if("object"!==I(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==I(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function x(e){var t=E(e,"string");return"symbol"===I(t)?t:String(t)}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e){if(Array.isArray(e))return e}function j(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l,i,a=[],u=!0,c=!1;try{if(l=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=l.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}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 N(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 C(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function k(e,t){return D(e)||j(e,t)||N(e,t)||C()}var L=n.ComponentBase.extend({defaultProps:{__TYPE:"Dropdown",__parentMetadata:null,appendTo:null,ariaLabel:null,ariaLabelledBy:null,autoFocus:!1,children:void 0,className:null,clearIcon:null,dataKey:null,disabled:!1,dropdownIcon:null,editable:!1,emptyFilterMessage:null,highlightOnSelect:!0,checkmark:!1,emptyMessage:null,filter:!1,filterBy:null,filterClearIcon:null,filterIcon:null,filterInputAutoFocus:!1,filterLocale:void 0,filterMatchMode:"contains",filterPlaceholder:null,filterTemplate:null,focusInputRef:null,id:null,inputId:null,inputRef:null,invalid:!1,variant:null,itemTemplate:null,loading:!1,loadingIcon:null,maxLength:null,name:null,onBlur:null,onChange:null,onContextMenu:null,onFilter:null,onFocus:null,onHide:null,onMouseDown:null,onShow:null,optionDisabled:null,optionGroupChildren:"items",selectOnFocus:!1,focusOnHover:!0,autoOptionFocus:!1,optionGroupLabel:null,optionGroupTemplate:null,optionLabel:null,optionValue:null,options:null,panelClassName:null,panelFooterTemplate:null,panelStyle:null,placeholder:null,required:!1,resetFilterOnHide:!1,scrollHeight:"200px",showClear:!1,showFilterClear:!1,showOnFocus:!1,style:null,tabIndex:null,tooltip:null,tooltipOptions:null,transitionOptions:null,value:null,valueTemplate:null,virtualScrollerOptions:null},css:{classes:{root:function(e){var t=e.props,n=e.focusedState,r=e.overlayVisibleState,o=e.context;return c.classNames("p-dropdown p-component p-inputwrapper",{"p-disabled":t.disabled,"p-invalid":t.invalid,"p-focus":n,"p-variant-filled":t.variant?"filled"===t.variant:o&&"filled"===o.inputStyle,"p-dropdown-clearable":t.showClear&&!t.disabled,"p-inputwrapper-filled":c.ObjectUtils.isNotEmpty(t.value),"p-inputwrapper-focus":n||r})},input:function(e){var t=e.props,n=e.label;return t.editable?"p-dropdown-label p-inputtext":c.classNames("p-dropdown-label p-inputtext",{"p-placeholder":null===n&&t.placeholder,"p-dropdown-label-empty":null===n&&!t.placeholder})},trigger:"p-dropdown-trigger",emptyMessage:"p-dropdown-empty-message",itemGroup:function(e){var t=e.optionGroupLabel;return c.classNames("p-dropdown-item-group",{"p-dropdown-item-empty":!t||0===t.length})},itemGroupLabel:"p-dropdown-item-group-label",dropdownIcon:"p-dropdown-trigger-icon p-clickable",loadingIcon:"p-dropdown-trigger-icon p-clickable",clearIcon:"p-dropdown-clear-icon p-clickable",filterIcon:"p-dropdown-filter-icon",filterClearIcon:"p-dropdown-filter-clear-icon",filterContainer:function(e){return c.classNames("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!e.clearIcon})},filterInput:function(e){var t=e.props,n=e.context;return c.classNames("p-dropdown-filter p-inputtext p-component",{"p-variant-filled":t.variant?"filled"===t.variant:n&&"filled"===n.inputStyle})},list:function(e){return"p-dropdown-items"},panel:function(e){var t=e.context;return c.classNames("p-dropdown-panel p-component",{"p-input-filled":t&&"filled"===t.inputStyle||"filled"===w.default.inputStyle,"p-ripple-disabled":t&&!1===t.ripple||!1===w.default.ripple})},item:function(e){var t=e.label;return c.classNames("p-dropdown-item",{"p-highlight":e.selected&&e.highlightOnSelect,"p-disabled":e.disabled,"p-focus":e.index===e.focusedOptionIndex,"p-dropdown-item-empty":!t||0===t.length})},itemLabel:"p-dropdown-item-label",checkIcon:"p-dropdown-check-icon",blankIcon:"p-dropdown-blank-icon",wrapper:"p-dropdown-items-wrapper",header:"p-dropdown-header",footer:"p-dropdown-footer",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-dropdown {\n display: inline-flex;\n cursor: pointer;\n position: relative;\n user-select: none;\n }\n \n .p-dropdown-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n .p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n }\n \n .p-dropdown-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n input.p-dropdown-label {\n cursor: default;\n }\n \n .p-dropdown .p-dropdown-panel {\n min-width: 100%;\n }\n \n .p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-dropdown-items-wrapper {\n overflow: auto;\n }\n \n .p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n \n .p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-dropdown-filter {\n width: 100%;\n }\n \n .p-dropdown-filter-container {\n position: relative;\n }\n \n .p-dropdown-clear-icon,\n .p-dropdown-filter-icon,\n .p-dropdown-filter-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-fluid .p-dropdown {\n display: flex;\n }\n \n .p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n }\n}\n",inlineStyles:{wrapper:function(e){return{maxHeight:e.props.scrollHeight||"auto"}},panel:function(e){}}}}),P=y.memo(y.forwardRef((function(e,t){var n=b.IconBase.getPTI(e);return y.createElement("svg",O({ref:t,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),y.createElement("rect",{width:"1",height:"1",fill:"currentColor",fillOpacity:"0"}))})));P.displayName="BlankIcon";var U=y.memo((function(e){var t=r.useMergeProps(),n=e.ptm,o=e.cx,l=e.selected,i=e.disabled,a=e.option,u=e.label,s=e.index,p=e.focusedOptionIndex,d=e.checkmark,f=e.highlightOnSelect,b=function(e){return n(e,{context:{selected:l,disabled:i}})},g=e.template?c.ObjectUtils.getJSXElement(e.template,e.option):e.label,h=t({role:"option",key:e.label,className:c.classNames(a.className,o("item",{selected:l,disabled:i,label:u,index:s,focusedOptionIndex:p,highlightOnSelect:f})),style:e.style,onClick:function(t){return n=t,void(e.onClick&&e.onClick({originalEvent:n,option:a}));var n},onMouseMove:function(t){return null==e?void 0:e.onMouseMove(t,s)},"aria-label":u,"aria-selected":l,"data-p-highlight":l,"data-p-focused":p===s,"data-p-disabled":i},b("item")),w=t({className:o("itemLabel")},b("itemLabel"));return y.createElement("li",h,d&&function(){if(l){var e=t({className:o("checkIcon")},b("checIcon"));return y.createElement(v.CheckIcon,e)}var n=t({className:o("blankIcon")},b("blankIcon"));return y.createElement(P,n)}(),y.createElement("span",w,g),y.createElement(m.Ripple,null))}));function R(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?R(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}U.displayName="DropdownItem";var M=y.memo(y.forwardRef((function(e,n){var o,l,a,u,m,v=r.useMergeProps(),b=e.ptm,g=e.cx,h=e.sx,w=y.useContext(t.PrimeReactContext),I=y.useRef(null),E=!(e.visibleOptions&&e.visibleOptions.length)&&e.hasFilter,x={filter:function(e){return F(e)},reset:function(){return e.resetFilter()}},S=function(t,n){return b(t,T({hostName:e.hostName},n))},D=function(){e.onEnter((function(){if(e.virtualScrollerRef.current){var t=e.getSelectedOptionIndex();-1!==t&&setTimeout((function(){return e.virtualScrollerRef.current.scrollToIndex(t)}),0)}}))},j=function(){e.onEntered((function(){e.filter&&e.filterInputAutoFocus&&c.DomHandler.focus(I.current,!1)}))},F=function(t){e.virtualScrollerRef.current&&e.virtualScrollerRef.current.scrollToIndex(0),e.onFilterInputChange&&e.onFilterInputChange(t)},N=function(){if(e.panelFooterTemplate){var t=c.ObjectUtils.getJSXElement(e.panelFooterTemplate,e,e.onOverlayHide),n=v({className:g("footer")},S("footer"));return y.createElement("div",n,t)}return null},C=function(t,n){var r;e.focusOnHover&&(null==e||null===(r=e.changeFocusedOptionIndex)||void 0===r||r.call(e,t,n))},k=function(n,r){var o=c.ObjectUtils.getJSXElement(n,e)||t.localeOption(r?"emptyFilterMessage":"emptyMessage"),l=v({className:g("emptyMessage")},S("emptyMessage"));return y.createElement("li",l,o)},L=function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={height:r.props?r.props.itemSize:void 0};if(o=T(T({},o),t.style),t.group&&e.optionGroupLabel){var l=e.optionGroupLabel,i=e.optionGroupTemplate?c.ObjectUtils.getJSXElement(e.optionGroupTemplate,t,n):e.getOptionGroupLabel(t),a=n+"_"+e.getOptionGroupRenderKey(t),u=v({className:g("itemGroup",{optionGroupLabel:l}),style:o,"data-p-highlight":e.selected},S("itemGroup")),s=v({className:g("itemGroupLabel")},S("itemGroupLabel"));return y.createElement("li",O({key:a},u),y.createElement("span",s,i))}var p=e.getOptionRenderKey(t)+"_"+n,d=e.getOptionLabel(t),f=e.isOptionDisabled(t);return y.createElement(U,{key:p,label:d,index:n,focusedOptionIndex:e.focusedOptionIndex,option:t,style:o,template:e.itemTemplate,selected:e.isSelected(t),highlightOnSelect:e.highlightOnSelect,disabled:f,onClick:e.onOptionClick,onMouseMove:C,ptm:b,cx:g,checkmark:e.checkmark})},P=function(){if(e.showFilterClear&&e.filterValue){var n=t.localeOption("clear"),r=v({className:g("filterClearIcon"),"aria-label":n,onClick:function(){return e.onFilterClearIconClick((function(){return c.DomHandler.focus(I.current)}))}},S("filterClearIcon"));return c.IconUtils.getJSXIcon(e.filterClearIcon||y.createElement(i.TimesIcon,r),T({},r),{props:e})}return null},R=function(){if(e.filter){var t=P(),n=v({className:g("filterIcon")},S("filterIcon")),r=c.IconUtils.getJSXIcon(e.filterIcon||y.createElement(p.SearchIcon,n),T({},n),{props:e}),o=v({className:g("filterContainer",{clearIcon:t})},S("filterContainer")),l=v({ref:I,type:"text",autoComplete:"off",className:g("filterInput",{context:w}),placeholder:e.filterPlaceholder,onKeyDown:e.onFilterInputKeyDown,onChange:function(e){return F(e)},value:e.filterValue},S("filterInput")),i=y.createElement("div",o,y.createElement("input",l),t,r);if(e.filterTemplate){var a={className:c.classNames("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!t}),element:i,filterOptions:x,filterInputKeyDown:e.onFilterInputKeyDown,filterInputChange:F,filterIconClassName:"p-dropdown-filter-icon",clearIcon:t,props:e};i=c.ObjectUtils.getJSXElement(e.filterTemplate,a)}var u=v({className:g("header")},S("header"));return y.createElement("div",u,i)}return null},M=function(){if(e.virtualScrollerOptions){var t=T(T({},e.virtualScrollerOptions),{style:T(T({},e.virtualScrollerOptions.style),{height:e.scrollHeight}),className:c.classNames("p-dropdown-items-wrapper",e.virtualScrollerOptions.className),items:e.visibleOptions,autoSize:!0,onLazyLoad:function(t){return e.virtualScrollerOptions.onLazyLoad(T(T({},t),{filter:e.filterValue}))},itemTemplate:function(e,t){return e&&L(e,t.index,t)},contentTemplate:function(t){var n=E?k(e.hasFilter?e.emptyFilterMessage:e.emptyMessage):t.children,r=v({ref:t.contentRef,style:t.style,className:c.classNames(t.className,g("list",{virtualScrollerProps:e.virtualScrollerOptions})),role:"listbox"},S("list"));return y.createElement("ul",r,n)}});return y.createElement(f.VirtualScroller,O({ref:e.virtualScrollerRef},t,{pt:b("virtualScroller")}))}var n=c.ObjectUtils.isNotEmpty(e.visibleOptions)?e.visibleOptions.map(L):e.hasFilter?k(e.emptyFilterMessage,!0):k(e.emptyMessage),r=v({className:g("wrapper"),style:h("wrapper")},S("wrapper")),o=v({className:g("list"),role:"listbox"},S("list"));return y.createElement("div",r,y.createElement("ul",o,n))},H=(o=R(),l=M(),a=N(),u=v({className:c.classNames(e.panelClassName,g("panel",{context:w})),style:h("panel"),onClick:e.onClick},S("panel")),m=v({classNames:g("transition"),in:e.in,timeout:{enter:120,exit:100},options:e.transitionOptions,unmountOnExit:!0,onEnter:D,onEntered:j,onExit:e.onExit,onExited:e.onExited},S("transition")),y.createElement(s.CSSTransition,O({nodeRef:n},m),y.createElement("div",O({ref:n},u),e.firstFocusableElement,o,l,a,e.lastFocusableElement)));return y.createElement(d.Portal,{element:H,appendTo:e.appendTo})})));function H(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,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 l,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,l=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw l}}}}function G(e,t){if(e){if("string"==typeof e)return A(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)?A(e,t):void 0}}function A(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 q(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 V(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?q(Object(n),!0).forEach((function(t){S(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}M.displayName="DropdownPanel";var K=y.memo(y.forwardRef((function(e,s){var p=r.useMergeProps(),d=y.useContext(t.PrimeReactContext),f=L.getProps(e,d),m=k(y.useState(""),2),v=m[0],b=m[1],g=k(y.useState(!1),2),h=g[0],E=g[1],x=k(y.useState(-1),2),D=x[0],j=x[1],F=k(y.useState(!1),2),N=F[0],C=F[1],P=y.useRef(!1),U=y.useRef(null),R=y.useRef(null),T=y.useRef(null),G=y.useRef(null),A=y.useRef(f.inputRef),q=y.useRef(f.focusInputRef),K=y.useRef(null),B=y.useRef(null),_=y.useRef(null);y.useRef(null);var J=f.virtualScrollerOptions&&f.virtualScrollerOptions.lazy,X=c.ObjectUtils.isNotEmpty(v),z=f.appendTo||d&&d.appendTo||w.default.appendTo,Z=L.setMetaData(V(V({props:f},f.__parentMetadata),{},{state:{filter:v,focused:h,overlayVisible:N}})),W=Z.ptm,$=Z.cx,Y=Z.sx;n.useHandleStyle(L.css.styles,Z.isUnstyled,{name:"dropdown"});var Q=k(r.useOverlayListener({target:U,overlay:R,listener:function(e,t){t.valid&&("outside"===t.type?!re(e)&&Ae():Ae())},when:N}),2),ee=Q[0],te=Q[1],ne=function(e){return(e||[]).reduce((function(e,t,n){e.push({optionGroup:t,group:!0,index:n,code:t.code,label:t.label});var r=ze(t);return r&&r.forEach((function(t){return e.push(t)})),e}),[])},re=function(e){return c.DomHandler.isAttributeEquals(e.target,"data-pc-section","clearicon")||c.DomHandler.isAttributeEquals(e.target.parentElement||e.target,"data-pc-section","filterclearicon")},oe=function(e){f.showOnFocus&&!N&&Ge(),E(!0),f.onFocus&&f.onFocus(e)},le=function(e){E(!1),f.onBlur&&setTimeout((function(){var t=A.current?A.current.value:void 0;f.onBlur({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:f.name,id:f.id,value:t}})}),200)},ie=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=_e(t);Ue({originalEvent:e,option:r}),n&&Ae()},ae=function(e){if(f.disabled||c.DomHandler.isAndroid())e.preventDefault();else{var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":he(e);break;case"ArrowUp":ye(e);break;case"ArrowLeft":case"ArrowRight":we(e,f.editable);break;case"Home":Oe(e);break;case"End":Ie(e);break;case"PageDown":xe(e);break;case"PageUp":Ee(e);break;case"Space":Se(e,f.editable);break;case"NumpadEnter":case"Enter":De(e);break;case"Escape":je(e);break;case"Tab":Fe(e);break;case"Backspace":Ne(e,f.editable);break;case"ShiftLeft":case"ShiftRight":break;default:!t&&c.ObjectUtils.isPrintableCharacter(e.key)&&(!N&&!f.editable&&Ge(),!f.editable&&me(e,e.key))}P.current=!1}},ue=function(e){var t;return ce(e)&&(null===(t=Be(e))||void 0===t?void 0:t.toLocaleLowerCase(f.filterLocale).startsWith(_.current.toLocaleLowerCase(f.filterLocale)))},ce=function(e){return c.ObjectUtils.isNotEmpty(e)&&!(Xe(e)||Je(e))},se=function(){return c.ObjectUtils.isNotEmpty(f.value)},pe=function(e){return ce(e)&&He(e)},de=function(){return se?nt.findIndex((function(e){return pe(e)})):-1},fe=function(){var e=de();return e<0?ve():e},me=function(e,t){_.current=(_.current||"")+t;var n=-1,r=!1;return c.ObjectUtils.isNotEmpty(_.current)&&(-1!==(n=-1!==D?-1===(n=nt.slice(D).findIndex((function(e){return ue(e)})))?nt.slice(0,D).findIndex((function(e){return ue(e)})):n+D:nt.findIndex((function(e){return ue(e)})))&&(r=!0),-1===n&&-1===D&&(n=fe()),-1!==n&&ge(e,n)),B.current&&clearTimeout(B.current),B.current=setTimeout((function(){_.current="",B.current=null}),500),r},ve=function(){return nt.findIndex((function(e){return ce(e)}))},be=function(){return c.ObjectUtils.findLastIndex(nt,(function(e){return ce(e)}))},ge=function(e,t){D!==t&&(j(t),f.selectOnFocus&&ie(e,nt[t],!1))},he=function(e){if(N){var t=-1!==D?(r=(n=D)<nt.length-1?nt.slice(n+1).findIndex((function(e){return ce(e)})):-1)>-1?r+n+1:n:P.current?ve():fe();ge(e,t)}else Ge(),f.editable&&ge(e,de());var n,r;e.preventDefault()},ye=function(e){var t,n,r;if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==D&&ie(e,nt[D]),state.overlayVisible&&Ae(),e.preventDefault();else{var o=-1!==D?(r=(n=D)>0?c.ObjectUtils.findLastIndex(nt.slice(0,n),(function(e){return ce(e)})):-1)>-1?r:n:P.current?be():(t=de())<0?be():t;ge(e,o),!N&&Ge(),e.preventDefault()}},we=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&j(-1)},Oe=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?(e.currentTarget.setSelectionRange(0,0),j(-1)):(ge(e,ve()),!N&&Ge()),e.preventDefault()},Ie=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var t=e.currentTarget,n=t.value.length;t.setSelectionRange(n,n),j(-1)}else ge(e,be()),!N&&Ge();e.preventDefault()},Ee=function(e){e.preventDefault()},xe=function(e){e.preventDefault()},Se=function(e){!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])&&De(e)},De=function(e){N?(-1!==D&&ie(e,nt[D]),Ae()):(j(-1),he(e)),e.preventDefault()},je=function(e){N&&Ae(),e.preventDefault()},Fe=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(!N||c.DomHandler.getFocusableElements(R.current,':not([data-p-hidden-focusable="true"])').length>0?(-1!==D&&ie(e,nt[D]),N&&Ae()):(c.DomHandler.focus(T.current),e.preventDefault()))},Ne=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&!N&&Ge()},Ce=function(e){var t=null;e.target.value&&(t=nt.findIndex((function(t){return Be(t).toLocaleLowerCase().startsWith(e.target.value.toLocaleLowerCase())}))),j(t),f.onChange&&f.onChange({originalEvent:e.originalEvent,value:e.target.value,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:f.name,id:f.id,value:e.target.value}})},ke=function(e){E(!0),Ae(),f.onFocus&&f.onFocus(e)},Le=function(e){b(""),f.onFilter&&f.onFilter({filter:""}),e&&e()},Pe=function(e){f.onChange&&f.onChange({originalEvent:e,value:void 0,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:f.name,id:f.id,value:void 0}}),f.filter&&Le(),Ke()},Ue=function(e){if(rt!==e.option){Ke(e.option),j(-1);var t=_e(e.option),n=Me(e.option,nt);f.onChange&&f.onChange({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:f.name,id:f.id,value:t}}),ge(e.originalEvent,n)}},Re=function(e){if(e=e||nt,null!=f.value&&e){if(!f.optionGroupLabel)return Me(f.value,e);for(var t=0;t<e.length;t++){var n=Me(f.value,ze(e[t]));if(-1!==n)return{group:t,option:n}}}return-1},Te=function(){return f.optionValue?null:f.dataKey},Me=function(e,t){var n=Te();return t.findIndex((function(t){return c.ObjectUtils.equals(e,_e(t),n)}))},He=function(e){return c.ObjectUtils.equals(f.value,_e(e),Te())},Ge=function(){j(-1!==D?D:f.autoOptionFocus?fe():f.editable?-1:de()),C(!0)},Ae=function(){C(!1),P.current=!1},qe=function(){c.DomHandler.alignOverlay(R.current,A.current.parentElement,f.appendTo||d&&d.appendTo||w.default.appendTo)},Ve=function(){var e=c.DomHandler.findSingle(R.current,'li[data-p-focused="true"]');if(e&&e.scrollIntoView)e.scrollIntoView({block:"nearest",inline:"nearest"});else{var t=c.DomHandler.findSingle(R.current,'li[data-p-highlight="true"]');t&&t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"nearest"})}},Ke=function(e){A.current&&(A.current.value=e?Be(e):f.value||"",q.current&&(q.current.value=A.current.value))},Be=function(e){return f.optionLabel?c.ObjectUtils.resolveFieldData(e,f.optionLabel):e},_e=function(e){return f.optionValue?c.ObjectUtils.resolveFieldData(e,f.optionValue):e},Je=function(e){return f.optionGroupLabel&&e.optionGroup&&e.group},Xe=function(e){return f.optionDisabled?c.ObjectUtils.isFunction(f.optionDisabled)?f.optionDisabled(e):c.ObjectUtils.resolveFieldData(e,f.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled},ze=function(e){return c.ObjectUtils.resolveFieldData(e,f.optionGroupChildren)},Ze=function(){if(f.editable&&A.current){var e=(rt?Be(rt):null)||f.value||"";A.current.value=e,q.current&&(q.current.value=e)}};y.useImperativeHandle(s,(function(){return{props:f,show:Ge,hide:Ae,clear:Pe,focus:function(){return c.DomHandler.focus(q.current)},getElement:function(){return U.current},getOverlay:function(){return R.current},getInput:function(){return A.current},getFocusInput:function(){return q.current},getVirtualScroller:function(){return K.current}}})),y.useEffect((function(){c.ObjectUtils.combinedRefs(A,f.inputRef),c.ObjectUtils.combinedRefs(q,f.focusInputRef)}),[A,f.inputRef,q,f.focusInputRef]),r.useMountEffect((function(){f.autoFocus&&c.DomHandler.focus(q.current,f.autoFocus),qe()})),r.useUpdateEffect((function(){N&&(f.value||D>=0)&&Ve()}),[N,f.value,D]),r.useUpdateEffect((function(){N&&v&&f.filter&&qe()}),[N,v,f.filter]),r.useUpdateEffect((function(){!v||f.options&&0!==f.options.length||b(""),Ze(),A.current&&(A.current.selectedIndex=1)})),r.useUnmountEffect((function(){c.ZIndexUtils.clear(R.current)}));var We,$e,Ye,Qe,et,tt=function(e){"Enter"!==e.key&&"Space"!==e.code||(Pe(e),e.preventDefault())},nt=function(){var e=f.optionGroupLabel?ne(f.options):f.options;if(X&&!J){var n=v.trim().toLocaleLowerCase(f.filterLocale),r=f.filterBy?f.filterBy.split(","):[f.optionLabel||"label"];if(f.optionGroupLabel){var o,l=[],i=H(f.options);try{for(i.s();!(o=i.n()).done;){var a=o.value,u=t.FilterService.filter(ze(a),r,n,f.filterMatchMode,f.filterLocale);u&&u.length&&l.push(V(V({},a),S({},"".concat(f.optionGroupChildren),u)))}}catch(e){i.e(e)}finally{i.f()}return ne(l)}return t.FilterService.filter(e,r,n,f.filterMatchMode,f.filterLocale)}return e}(),rt=-1!==(We=Re(f.options))?f.optionGroupLabel?ze(f.options[We.group])[We.option]:f.options[We]:null,ot=c.ObjectUtils.isNotEmpty(f.tooltip),lt=L.getOtherProps(f),it=c.ObjectUtils.reduceKeys(lt,c.DomHandler.ARIA_PROPS),at=function(){var e={value:"",label:f.placeholder};if(rt){var t=_e(rt);e={value:"object"===I(t)?f.options.findIndex((function(e){return e===t})):t,label:Be(rt)}}var n=p({className:"p-hidden-accessible p-dropdown-hidden-select"},W("hiddenSelectedMessage")),r=p({ref:A,required:f.required,defaultValue:e.value,name:f.name,tabIndex:-1,"aria-hidden":"true"},W("select")),o=p({value:e.value},W("option"));return y.createElement("div",n,y.createElement("select",r,y.createElement("option",o,e.label)))}(),ut=function(){var e=c.ObjectUtils.isNotEmpty(rt)?Be(rt):null;f.editable&&(e=e||f.value||"");var t=p({className:"p-hidden-accessible"},W("hiddenSelectedMessage")),n=p(V({ref:q,id:f.inputId,defaultValue:e,type:"text",readOnly:!0,"aria-haspopup":"listbox",onFocus:oe,onBlur:le,onKeyDown:ae,disabled:f.disabled,tabIndex:f.disabled?-1:f.tabIndex||0},it),W("input"));return y.createElement("div",t,y.createElement("input",n))}(),ct=function(){var e=c.ObjectUtils.isNotEmpty(rt)?Be(rt):null;if(f.editable){var t=p(V({ref:A,type:"text",defaultValue:e||f.value||"",className:$("input",{label:e}),disabled:f.disabled,placeholder:f.placeholder,maxLength:f.maxLength,onInput:Ce,onFocus:ke,onKeyDown:ae,onBlur:le,tabIndex:f.disabled?-1:f.tabIndex||0,"aria-haspopup":"listbox"},it),W("input"));return y.createElement("input",t)}var n=f.valueTemplate?c.ObjectUtils.getJSXElement(f.valueTemplate,rt,f):e||f.placeholder||"empty",r=p({ref:A,className:$("input",{label:e}),tabIndex:"-1"},W("input"));return y.createElement("span",r,n)}(),st=f.loading?($e=p({className:$("loadingIcon"),"data-pr-overlay-visible":N},W("loadingIcon")),Ye=c.IconUtils.getJSXIcon(f.loadingIcon||y.createElement(l.SpinnerIcon,{spin:!0}),V({},$e),{props:f}),Qe=f.placeholder||f.ariaLabel,et=p({className:$("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":N,"aria-label":Qe},W("trigger")),y.createElement("div",et,Ye)):function(){var e=p({className:$("dropdownIcon"),"data-pr-overlay-visible":N},W("dropdownIcon")),t=c.IconUtils.getJSXIcon(f.dropdownIcon||y.createElement(o.ChevronDownIcon,e),V({},e),{props:f}),n=f.placeholder||f.ariaLabel,r=p({className:$("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":N,"aria-label":n},W("trigger"));return y.createElement("div",r,t)}(),pt=function(){if(null!=f.value&&f.showClear&&!f.disabled){var e=p({className:$("clearIcon"),onPointerUp:Pe,tabIndex:f.tabIndex||"0",onKeyDown:tt,"aria-label":t.localeOption("clear")},W("clearIcon"));return c.IconUtils.getJSXIcon(f.clearIcon||y.createElement(i.TimesIcon,e),V({},e),{props:f})}return null}(),dt=p({id:f.id,ref:U,className:c.classNames(f.className,$("root",{context:d,focusedState:h,overlayVisibleState:N})),style:f.style,onClick:function(e){return t=e,void(f.disabled||f.loading||(f.onClick&&f.onClick(t),t.defaultPrevented||re(t)||"INPUT"===t.target.tagName||(R.current&&R.current&&R.current.contains(t.target)||(c.DomHandler.focus(q.current),N?Ae():Ge()),P.current=!0)));var t},onMouseDown:f.onMouseDown,onContextMenu:f.onContextMenu,onFocus:function(){f.editable&&!N&&!1===P.current&&c.DomHandler.focus(A.current)},"data-p-disabled":f.disabled,"data-p-focus":h},lt,W("root")),ft=p({ref:T,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===q.current?c.DomHandler.getFirstFocusableElement(R.current,':not([data-p-hidden-focusable="true"])'):q.current;c.DomHandler.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},W("hiddenFirstFocusableEl")),mt=p({ref:G,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===q.current?c.DomHandler.getLastFocusableElement(R.current,':not([data-p-hidden-focusable="true"])'):q.current;c.DomHandler.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},W("hiddenLastFocusableEl"));return y.createElement(y.Fragment,null,y.createElement("div",dt,ut,at,ct,pt,st,y.createElement(M,O({hostName:"Dropdown",ref:R,visibleOptions:nt,virtualScrollerRef:K},f,{appendTo:z,cx:$,filterValue:v,focusedOptionIndex:D,getOptionGroupChildren:ze,getOptionGroupLabel:function(e){return c.ObjectUtils.resolveFieldData(e,f.optionGroupLabel)},getOptionGroupRenderKey:function(e){return c.ObjectUtils.resolveFieldData(e,f.optionGroupLabel)},getOptionLabel:Be,getOptionRenderKey:function(e){return f.dataKey?c.ObjectUtils.resolveFieldData(e,f.dataKey):Be(e)},getSelectedOptionIndex:Re,hasFilter:X,in:N,isOptionDisabled:Xe,isSelected:He,onClick:function(e){a.OverlayService.emit("overlay-click",{originalEvent:e,target:U.current})},onEnter:function(e){c.ZIndexUtils.set("overlay",R.current,d&&d.autoZIndex||w.default.autoZIndex,d&&d.zIndex.overlay||w.default.zIndex.overlay),c.DomHandler.addStyles(R.current,{position:"absolute",top:"0",left:"0"}),qe(),e&&e()},onEntered:function(e){e&&e(),ee(),f.onShow&&f.onShow()},onExit:function(){te()},onExited:function(){f.filter&&f.resetFilterOnHide&&Le(),c.ZIndexUtils.clear(R.current),f.onHide&&f.onHide()},onFilterClearIconClick:function(e){Le(e)},onFilterInputChange:function(e){var t=e.target.value;b(t),f.onFilter&&f.onFilter({originalEvent:e,filter:t})},onFilterInputKeyDown:function(e){switch(e.code){case"ArrowDown":he(e);break;case"ArrowUp":ye(e);break;case"ArrowLeft":case"ArrowRight":we(e,!0);break;case"Escape":case"Enter":case"NumpadEnter":De(e),e.preventDefault()}},onOptionClick:function(e){e.option.disabled||(Ue(e),c.DomHandler.focus(q.current)),Ae()},ptm:W,resetFilter:Le,changeFocusedOptionIndex:ge,firstFocusableElement:y.createElement("span",ft),lastFocusableElement:y.createElement("span",mt),sx:Y}))),ot&&y.createElement(u.Tooltip,O({target:U,content:f.tooltip,pt:W("tooltip")},f.tooltipOptions)))})));K.displayName="Dropdown",exports.Dropdown=K;
|
package/dropdown/dropdown.d.ts
CHANGED
|
@@ -249,7 +249,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
249
249
|
* When present, it specifies that the component should automatically get focus on load.
|
|
250
250
|
* @defaultValue false
|
|
251
251
|
*/
|
|
252
|
-
autoFocus?: boolean
|
|
252
|
+
autoFocus?: boolean;
|
|
253
253
|
/**
|
|
254
254
|
* Style class of the component.
|
|
255
255
|
*/
|
|
@@ -266,12 +266,12 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
266
266
|
* When present, it specifies that the component should have invalid state style.
|
|
267
267
|
* @defaultValue false
|
|
268
268
|
*/
|
|
269
|
-
invalid?: boolean
|
|
269
|
+
invalid?: boolean;
|
|
270
270
|
/**
|
|
271
271
|
* When present, it specifies that the component should be disabled.
|
|
272
272
|
* @defaultValue false
|
|
273
273
|
*/
|
|
274
|
-
disabled?: boolean
|
|
274
|
+
disabled?: boolean;
|
|
275
275
|
/**
|
|
276
276
|
* Specifies the input variant of the component.
|
|
277
277
|
* @defaultValue outlined
|
|
@@ -285,17 +285,17 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
285
285
|
* When present, custom value instead of predefined options can be entered using the editable input field.
|
|
286
286
|
* @defaultValue false
|
|
287
287
|
*/
|
|
288
|
-
editable?: boolean
|
|
288
|
+
editable?: boolean;
|
|
289
289
|
/**
|
|
290
290
|
* Whether the selected option will be add highlight class.
|
|
291
291
|
* @defaultValue true
|
|
292
292
|
*/
|
|
293
|
-
highlightOnSelect?: boolean
|
|
293
|
+
highlightOnSelect?: boolean;
|
|
294
294
|
/**
|
|
295
295
|
* Whether the selected option will be shown with a check mark.
|
|
296
296
|
* @defaultValue false
|
|
297
297
|
*/
|
|
298
|
-
checkmark?: boolean
|
|
298
|
+
checkmark?: boolean;
|
|
299
299
|
/**
|
|
300
300
|
* Template to display when filtering does not return any results.
|
|
301
301
|
* @defaultValue No available options
|
|
@@ -310,7 +310,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
310
310
|
* When specified, displays an input field to filter the items on keyup.
|
|
311
311
|
* @defaultValue false
|
|
312
312
|
*/
|
|
313
|
-
filter?: boolean
|
|
313
|
+
filter?: boolean;
|
|
314
314
|
/**
|
|
315
315
|
* Icon of the filter to search.
|
|
316
316
|
*/
|
|
@@ -328,7 +328,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
328
328
|
* When the panel is opened, it specifies that the filter input should focus automatically.
|
|
329
329
|
* @defaultValue false
|
|
330
330
|
*/
|
|
331
|
-
filterInputAutoFocus?: boolean
|
|
331
|
+
filterInputAutoFocus?: boolean;
|
|
332
332
|
/**
|
|
333
333
|
* Locale to use in filtering. The default locale is the host environment's current locale.
|
|
334
334
|
*/
|
|
@@ -359,17 +359,17 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
359
359
|
* When enabled, the focused tab is activated.
|
|
360
360
|
* @defaultValue false
|
|
361
361
|
*/
|
|
362
|
-
selectOnFocus?:
|
|
362
|
+
selectOnFocus?: boolean;
|
|
363
363
|
/**
|
|
364
364
|
* When enabled, the focus is placed on the hovered option.
|
|
365
365
|
* @defaultValue true
|
|
366
366
|
*/
|
|
367
|
-
focusOnHover?: boolean
|
|
367
|
+
focusOnHover?: boolean;
|
|
368
368
|
/**
|
|
369
369
|
* Whether to focus on the first visible or selected element.
|
|
370
370
|
* @defaultValue false
|
|
371
371
|
*/
|
|
372
|
-
autoOptionFocus?:
|
|
372
|
+
autoOptionFocus?: boolean;
|
|
373
373
|
/**
|
|
374
374
|
* Identifier of the focusable input.
|
|
375
375
|
*/
|
|
@@ -386,7 +386,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
386
386
|
* Displays a loader to indicate data load is in progress.
|
|
387
387
|
* @defaultValue false
|
|
388
388
|
*/
|
|
389
|
-
loading?: boolean
|
|
389
|
+
loading?: boolean;
|
|
390
390
|
/**
|
|
391
391
|
* The icon to show while indicating data load is in progress.
|
|
392
392
|
*/
|
|
@@ -449,12 +449,12 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
449
449
|
* When present, it specifies that an input field must be filled out before submitting the form.
|
|
450
450
|
* @defaultValue false
|
|
451
451
|
*/
|
|
452
|
-
required?: boolean
|
|
452
|
+
required?: boolean;
|
|
453
453
|
/**
|
|
454
454
|
* Clears the filter value when hiding the dropdown.
|
|
455
455
|
* @defaultValue false
|
|
456
456
|
*/
|
|
457
|
-
resetFilterOnHide?: boolean
|
|
457
|
+
resetFilterOnHide?: boolean;
|
|
458
458
|
/**
|
|
459
459
|
* Height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value.
|
|
460
460
|
* @defaultValue 200px
|
|
@@ -464,17 +464,17 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
|
|
|
464
464
|
* When enabled, a clear icon is displayed to clear the value.
|
|
465
465
|
* @defaultValue false
|
|
466
466
|
*/
|
|
467
|
-
showClear?: boolean
|
|
467
|
+
showClear?: boolean;
|
|
468
468
|
/**
|
|
469
469
|
* When enabled, a clear icon is displayed to clear the filtered value.
|
|
470
470
|
* @defaultValue false
|
|
471
471
|
*/
|
|
472
|
-
showFilterClear?: boolean
|
|
472
|
+
showFilterClear?: boolean;
|
|
473
473
|
/**
|
|
474
474
|
* When enabled, overlay panel will be visible with input focus.
|
|
475
475
|
* @defaultValue false
|
|
476
476
|
*/
|
|
477
|
-
showOnFocus?: boolean
|
|
477
|
+
showOnFocus?: boolean;
|
|
478
478
|
/**
|
|
479
479
|
* Inline style of the element.
|
|
480
480
|
*/
|
package/dropdown/dropdown.esm.js
CHANGED
|
@@ -460,31 +460,6 @@ var DropdownPanel = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(funct
|
|
|
460
460
|
props === null || props === void 0 || (_props$changeFocusedO = props.changeFocusedOptionIndex) === null || _props$changeFocusedO === void 0 || _props$changeFocusedO.call(props, event, index);
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
|
-
var createGroupChildren = function createGroupChildren(optionGroup, style) {
|
|
464
|
-
var groupChildren = props.getOptionGroupChildren(optionGroup);
|
|
465
|
-
return groupChildren.map(function (option, j) {
|
|
466
|
-
var optionLabel = props.getOptionLabel(option);
|
|
467
|
-
var optionKey = j + '_' + props.getOptionRenderKey(option);
|
|
468
|
-
var disabled = props.isOptionDisabled(option);
|
|
469
|
-
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
470
|
-
key: optionKey,
|
|
471
|
-
index: j,
|
|
472
|
-
focusedOptionIndex: props.focusedOptionIndex,
|
|
473
|
-
label: optionLabel,
|
|
474
|
-
option: option,
|
|
475
|
-
style: style,
|
|
476
|
-
template: props.itemTemplate,
|
|
477
|
-
selected: props.isSelected(option),
|
|
478
|
-
highlightOnSelect: props.highlightOnSelect,
|
|
479
|
-
disabled: disabled,
|
|
480
|
-
onClick: props.onOptionClick,
|
|
481
|
-
onMouseMove: changeFocusedItemOnHover,
|
|
482
|
-
ptm: ptm,
|
|
483
|
-
cx: cx,
|
|
484
|
-
checkmark: props.checkmark
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
};
|
|
488
463
|
var createEmptyMessage = function createEmptyMessage(emptyMessage, isFilter) {
|
|
489
464
|
var message = ObjectUtils.getJSXElement(emptyMessage, props) || localeOption(isFilter ? 'emptyFilterMessage' : 'emptyMessage');
|
|
490
465
|
var emptyMessageProps = mergeProps({
|
|
@@ -498,10 +473,9 @@ var DropdownPanel = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(funct
|
|
|
498
473
|
height: scrollerOptions.props ? scrollerOptions.props.itemSize : undefined
|
|
499
474
|
};
|
|
500
475
|
style = _objectSpread$1(_objectSpread$1({}, style), option.style);
|
|
501
|
-
if (props.optionGroupLabel) {
|
|
476
|
+
if (option.group && props.optionGroupLabel) {
|
|
502
477
|
var optionGroupLabel = props.optionGroupLabel;
|
|
503
478
|
var groupContent = props.optionGroupTemplate ? ObjectUtils.getJSXElement(props.optionGroupTemplate, option, index) : props.getOptionGroupLabel(option);
|
|
504
|
-
var groupChildrenContent = createGroupChildren(option, style);
|
|
505
479
|
var key = index + '_' + props.getOptionGroupRenderKey(option);
|
|
506
480
|
var itemGroupProps = mergeProps({
|
|
507
481
|
className: cx('itemGroup', {
|
|
@@ -513,12 +487,12 @@ var DropdownPanel = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(funct
|
|
|
513
487
|
var itemGroupLabelProps = mergeProps({
|
|
514
488
|
className: cx('itemGroupLabel')
|
|
515
489
|
}, getPTOptions('itemGroupLabel'));
|
|
516
|
-
return /*#__PURE__*/React.createElement(
|
|
490
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
|
517
491
|
key: key
|
|
518
|
-
},
|
|
492
|
+
}, itemGroupProps), /*#__PURE__*/React.createElement("span", itemGroupLabelProps, groupContent));
|
|
519
493
|
}
|
|
494
|
+
var optionKey = props.getOptionRenderKey(option) + '_' + index;
|
|
520
495
|
var optionLabel = props.getOptionLabel(option);
|
|
521
|
-
var optionKey = index + '_' + props.getOptionRenderKey(option);
|
|
522
496
|
var disabled = props.isOptionDisabled(option);
|
|
523
497
|
return /*#__PURE__*/React.createElement(DropdownItem, {
|
|
524
498
|
key: optionKey,
|
|
@@ -775,7 +749,24 @@ var Dropdown = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (
|
|
|
775
749
|
_useOverlayListener2 = _slicedToArray(_useOverlayListener, 2),
|
|
776
750
|
bindOverlayListener = _useOverlayListener2[0],
|
|
777
751
|
unbindOverlayListener = _useOverlayListener2[1];
|
|
752
|
+
var flatOptions = function flatOptions(options) {
|
|
753
|
+
return (options || []).reduce(function (result, option, index) {
|
|
754
|
+
result.push({
|
|
755
|
+
optionGroup: option,
|
|
756
|
+
group: true,
|
|
757
|
+
index: index,
|
|
758
|
+
code: option.code,
|
|
759
|
+
label: option.label
|
|
760
|
+
});
|
|
761
|
+
var optionGroupChildren = getOptionGroupChildren(option);
|
|
762
|
+
optionGroupChildren && optionGroupChildren.forEach(function (o) {
|
|
763
|
+
return result.push(o);
|
|
764
|
+
});
|
|
765
|
+
return result;
|
|
766
|
+
}, []);
|
|
767
|
+
};
|
|
778
768
|
var getVisibleOptions = function getVisibleOptions() {
|
|
769
|
+
var options = props.optionGroupLabel ? flatOptions(props.options) : props.options;
|
|
779
770
|
if (hasFilter && !isLazy) {
|
|
780
771
|
var filterValue = filterState.trim().toLocaleLowerCase(props.filterLocale);
|
|
781
772
|
var searchFields = props.filterBy ? props.filterBy.split(',') : [props.optionLabel || 'label'];
|
|
@@ -796,11 +787,11 @@ var Dropdown = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (
|
|
|
796
787
|
} finally {
|
|
797
788
|
_iterator.f();
|
|
798
789
|
}
|
|
799
|
-
return filteredGroups;
|
|
790
|
+
return flatOptions(filteredGroups);
|
|
800
791
|
}
|
|
801
|
-
return FilterService.filter(
|
|
792
|
+
return FilterService.filter(options, searchFields, filterValue, props.filterMatchMode, props.filterLocale);
|
|
802
793
|
}
|
|
803
|
-
return
|
|
794
|
+
return options;
|
|
804
795
|
};
|
|
805
796
|
var onFirstHiddenFocus = function onFirstHiddenFocus(event) {
|
|
806
797
|
var focusableEl = event.relatedTarget === focusInputRef.current ? DomHandler.getFirstFocusableElement(overlayRef.current, ':not([data-p-hidden-focusable="true"])') : focusInputRef.current;
|
|
@@ -1329,12 +1320,20 @@ var Dropdown = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (
|
|
|
1329
1320
|
DomHandler.alignOverlay(overlayRef.current, inputRef.current.parentElement, props.appendTo || context && context.appendTo || PrimeReact.appendTo);
|
|
1330
1321
|
};
|
|
1331
1322
|
var scrollInView = function scrollInView() {
|
|
1332
|
-
var
|
|
1333
|
-
if (
|
|
1334
|
-
|
|
1323
|
+
var focusedItem = DomHandler.findSingle(overlayRef.current, 'li[data-p-focused="true"]');
|
|
1324
|
+
if (focusedItem && focusedItem.scrollIntoView) {
|
|
1325
|
+
focusedItem.scrollIntoView({
|
|
1335
1326
|
block: 'nearest',
|
|
1336
1327
|
inline: 'nearest'
|
|
1337
1328
|
});
|
|
1329
|
+
} else {
|
|
1330
|
+
var highlightItem = DomHandler.findSingle(overlayRef.current, 'li[data-p-highlight="true"]');
|
|
1331
|
+
if (highlightItem && highlightItem.scrollIntoView) {
|
|
1332
|
+
highlightItem.scrollIntoView({
|
|
1333
|
+
block: 'nearest',
|
|
1334
|
+
inline: 'nearest'
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1338
1337
|
}
|
|
1339
1338
|
};
|
|
1340
1339
|
var updateEditableLabel = function updateEditableLabel(option) {
|
|
@@ -1348,10 +1347,10 @@ var Dropdown = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (
|
|
|
1348
1347
|
}
|
|
1349
1348
|
};
|
|
1350
1349
|
var getOptionLabel = function getOptionLabel(option) {
|
|
1351
|
-
return props.optionLabel ? ObjectUtils.resolveFieldData(option, props.optionLabel) : option
|
|
1350
|
+
return props.optionLabel ? ObjectUtils.resolveFieldData(option, props.optionLabel) : option;
|
|
1352
1351
|
};
|
|
1353
1352
|
var getOptionValue = function getOptionValue(option) {
|
|
1354
|
-
return props.optionValue ? ObjectUtils.resolveFieldData(option, props.optionValue) : option
|
|
1353
|
+
return props.optionValue ? ObjectUtils.resolveFieldData(option, props.optionValue) : option;
|
|
1355
1354
|
};
|
|
1356
1355
|
var getOptionRenderKey = function getOptionRenderKey(option) {
|
|
1357
1356
|
return props.dataKey ? ObjectUtils.resolveFieldData(option, props.dataKey) : getOptionLabel(option);
|
|
@@ -1427,10 +1426,10 @@ var Dropdown = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (
|
|
|
1427
1426
|
alignOverlay();
|
|
1428
1427
|
});
|
|
1429
1428
|
useUpdateEffect(function () {
|
|
1430
|
-
if (overlayVisibleState && props.value) {
|
|
1429
|
+
if (overlayVisibleState && (props.value || focusedOptionIndex >= 0)) {
|
|
1431
1430
|
scrollInView();
|
|
1432
1431
|
}
|
|
1433
|
-
}, [overlayVisibleState, props.value]);
|
|
1432
|
+
}, [overlayVisibleState, props.value, focusedOptionIndex]);
|
|
1434
1433
|
useUpdateEffect(function () {
|
|
1435
1434
|
if (overlayVisibleState && filterState && props.filter) {
|
|
1436
1435
|
alignOverlay();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import t,{PrimeReactContext as n,localeOption as r,FilterService as o}from"primereact/api";import{ComponentBase as l,useHandleStyle as i}from"primereact/componentbase";import{useMergeProps as a,useOverlayListener as u,useMountEffect as c,useUpdateEffect as p,useUnmountEffect as s}from"primereact/hooks";import{ChevronDownIcon as d}from"primereact/icons/chevrondown";import{SpinnerIcon as f}from"primereact/icons/spinner";import{TimesIcon as m}from"primereact/icons/times";import{OverlayService as v}from"primereact/overlayservice";import{Tooltip as b}from"primereact/tooltip";import{classNames as g,ObjectUtils as h,DomHandler as y,IconUtils as w,ZIndexUtils as E}from"primereact/utils";import{CSSTransition as O}from"primereact/csstransition";import{SearchIcon as I}from"primereact/icons/search";import{Portal as x}from"primereact/portal";import{VirtualScroller as S}from"primereact/virtualscroller";import{Ripple as F}from"primereact/ripple";import{CheckIcon as k}from"primereact/icons/check";import{IconBase as C}from"primereact/iconbase";function D(){return D=Object.assign?Object.assign.bind():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},D.apply(this,arguments)}function N(e){return N="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},N(e)}function L(e,t){if("object"!==N(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function P(e){var t=L(e,"string");return"symbol"===N(t)?t:String(t)}function R(e,t,n){return(t=P(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e){if(Array.isArray(e))return e}function j(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l,i,a=[],u=!0,c=!1;try{if(l=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=l.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}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 G(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 A(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function K(e,t){return T(e)||j(e,t)||G(e,t)||A()}var V=l.extend({defaultProps:{__TYPE:"Dropdown",__parentMetadata:null,appendTo:null,ariaLabel:null,ariaLabelledBy:null,autoFocus:!1,children:void 0,className:null,clearIcon:null,dataKey:null,disabled:!1,dropdownIcon:null,editable:!1,emptyFilterMessage:null,highlightOnSelect:!0,checkmark:!1,emptyMessage:null,filter:!1,filterBy:null,filterClearIcon:null,filterIcon:null,filterInputAutoFocus:!1,filterLocale:void 0,filterMatchMode:"contains",filterPlaceholder:null,filterTemplate:null,focusInputRef:null,id:null,inputId:null,inputRef:null,invalid:!1,variant:null,itemTemplate:null,loading:!1,loadingIcon:null,maxLength:null,name:null,onBlur:null,onChange:null,onContextMenu:null,onFilter:null,onFocus:null,onHide:null,onMouseDown:null,onShow:null,optionDisabled:null,optionGroupChildren:"items",selectOnFocus:!1,focusOnHover:!0,autoOptionFocus:!1,optionGroupLabel:null,optionGroupTemplate:null,optionLabel:null,optionValue:null,options:null,panelClassName:null,panelFooterTemplate:null,panelStyle:null,placeholder:null,required:!1,resetFilterOnHide:!1,scrollHeight:"200px",showClear:!1,showFilterClear:!1,showOnFocus:!1,style:null,tabIndex:null,tooltip:null,tooltipOptions:null,transitionOptions:null,value:null,valueTemplate:null,virtualScrollerOptions:null},css:{classes:{root:function(e){var t=e.props,n=e.focusedState,r=e.overlayVisibleState,o=e.context;return g("p-dropdown p-component p-inputwrapper",{"p-disabled":t.disabled,"p-invalid":t.invalid,"p-focus":n,"p-variant-filled":t.variant?"filled"===t.variant:o&&"filled"===o.inputStyle,"p-dropdown-clearable":t.showClear&&!t.disabled,"p-inputwrapper-filled":h.isNotEmpty(t.value),"p-inputwrapper-focus":n||r})},input:function(e){var t=e.props,n=e.label;return t.editable?"p-dropdown-label p-inputtext":g("p-dropdown-label p-inputtext",{"p-placeholder":null===n&&t.placeholder,"p-dropdown-label-empty":null===n&&!t.placeholder})},trigger:"p-dropdown-trigger",emptyMessage:"p-dropdown-empty-message",itemGroup:function(e){var t=e.optionGroupLabel;return g("p-dropdown-item-group",{"p-dropdown-item-empty":!t||0===t.length})},itemGroupLabel:"p-dropdown-item-group-label",dropdownIcon:"p-dropdown-trigger-icon p-clickable",loadingIcon:"p-dropdown-trigger-icon p-clickable",clearIcon:"p-dropdown-clear-icon p-clickable",filterIcon:"p-dropdown-filter-icon",filterClearIcon:"p-dropdown-filter-clear-icon",filterContainer:function(e){return g("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!e.clearIcon})},filterInput:function(e){var t=e.props,n=e.context;return g("p-dropdown-filter p-inputtext p-component",{"p-variant-filled":t.variant?"filled"===t.variant:n&&"filled"===n.inputStyle})},list:function(e){return"p-dropdown-items"},panel:function(e){var n=e.context;return g("p-dropdown-panel p-component",{"p-input-filled":n&&"filled"===n.inputStyle||"filled"===t.inputStyle,"p-ripple-disabled":n&&!1===n.ripple||!1===t.ripple})},item:function(e){var t=e.label;return g("p-dropdown-item",{"p-highlight":e.selected&&e.highlightOnSelect,"p-disabled":e.disabled,"p-focus":e.index===e.focusedOptionIndex,"p-dropdown-item-empty":!t||0===t.length})},itemLabel:"p-dropdown-item-label",checkIcon:"p-dropdown-check-icon",blankIcon:"p-dropdown-blank-icon",wrapper:"p-dropdown-items-wrapper",header:"p-dropdown-header",footer:"p-dropdown-footer",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-dropdown {\n display: inline-flex;\n cursor: pointer;\n position: relative;\n user-select: none;\n }\n \n .p-dropdown-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n .p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n }\n \n .p-dropdown-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n input.p-dropdown-label {\n cursor: default;\n }\n \n .p-dropdown .p-dropdown-panel {\n min-width: 100%;\n }\n \n .p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-dropdown-items-wrapper {\n overflow: auto;\n }\n \n .p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n \n .p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-dropdown-filter {\n width: 100%;\n }\n \n .p-dropdown-filter-container {\n position: relative;\n }\n \n .p-dropdown-clear-icon,\n .p-dropdown-filter-icon,\n .p-dropdown-filter-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-fluid .p-dropdown {\n display: flex;\n }\n \n .p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n }\n}\n",inlineStyles:{wrapper:function(e){return{maxHeight:e.props.scrollHeight||"auto"}},panel:function(e){}}}}),H=e.memo(e.forwardRef((function(t,n){var r=C.getPTI(t);return e.createElement("svg",D({ref:n,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r),e.createElement("rect",{width:"1",height:"1",fill:"currentColor",fillOpacity:"0"}))})));H.displayName="BlankIcon";var B=e.memo((function(t){var n=a(),r=t.ptm,o=t.cx,l=t.selected,i=t.disabled,u=t.option,c=t.label,p=t.index,s=t.focusedOptionIndex,d=t.checkmark,f=t.highlightOnSelect,m=function(e){return r(e,{context:{selected:l,disabled:i}})},v=t.template?h.getJSXElement(t.template,t.option):t.label,b=n({role:"option",key:t.label,className:g(u.className,o("item",{selected:l,disabled:i,label:c,index:p,focusedOptionIndex:s,highlightOnSelect:f})),style:t.style,onClick:function(e){return n=e,void(t.onClick&&t.onClick({originalEvent:n,option:u}));var n},onMouseMove:function(e){return null==t?void 0:t.onMouseMove(e,p)},"aria-label":c,"aria-selected":l,"data-p-highlight":l,"data-p-focused":s===p,"data-p-disabled":i},m("item")),y=n({className:o("itemLabel")},m("itemLabel"));return e.createElement("li",b,d&&function(){if(l){var t=n({className:o("checkIcon")},m("checIcon"));return e.createElement(k,t)}var r=n({className:o("blankIcon")},m("blankIcon"));return e.createElement(H,r)}(),e.createElement("span",y,v),e.createElement(F,null))}));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 X(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){R(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}B.displayName="DropdownItem";var _=e.memo(e.forwardRef((function(t,o){var l,i,u,c,p,s=a(),d=t.ptm,f=t.cx,v=t.sx,b=e.useContext(n),E=e.useRef(null),F=!(t.visibleOptions&&t.visibleOptions.length)&&t.hasFilter,k={filter:function(e){return P(e)},reset:function(){return t.resetFilter()}},C=function(e,n){return d(e,X({hostName:t.hostName},n))},N=function(){t.onEnter((function(){if(t.virtualScrollerRef.current){var e=t.getSelectedOptionIndex();-1!==e&&setTimeout((function(){return t.virtualScrollerRef.current.scrollToIndex(e)}),0)}}))},L=function(){t.onEntered((function(){t.filter&&t.filterInputAutoFocus&&y.focus(E.current,!1)}))},P=function(e){t.virtualScrollerRef.current&&t.virtualScrollerRef.current.scrollToIndex(0),t.onFilterInputChange&&t.onFilterInputChange(e)},R=function(){if(t.panelFooterTemplate){var n=h.getJSXElement(t.panelFooterTemplate,t,t.onOverlayHide),r=s({className:f("footer")},C("footer"));return e.createElement("div",r,n)}return null},T=function(e,n){var r;t.focusOnHover&&(null==t||null===(r=t.changeFocusedOptionIndex)||void 0===r||r.call(t,e,n))},j=function(n,r){return t.getOptionGroupChildren(n).map((function(n,o){var l=t.getOptionLabel(n),i=o+"_"+t.getOptionRenderKey(n),a=t.isOptionDisabled(n);return e.createElement(B,{key:i,index:o,focusedOptionIndex:t.focusedOptionIndex,label:l,option:n,style:r,template:t.itemTemplate,selected:t.isSelected(n),highlightOnSelect:t.highlightOnSelect,disabled:a,onClick:t.onOptionClick,onMouseMove:T,ptm:d,cx:f,checkmark:t.checkmark})}))},M=function(n,o){var l=h.getJSXElement(n,t)||r(o?"emptyFilterMessage":"emptyMessage"),i=s({className:f("emptyMessage")},C("emptyMessage"));return e.createElement("li",i,l)},G=function(n,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l={height:o.props?o.props.itemSize:void 0};if(l=X(X({},l),n.style),t.optionGroupLabel){var i=t.optionGroupLabel,a=t.optionGroupTemplate?h.getJSXElement(t.optionGroupTemplate,n,r):t.getOptionGroupLabel(n),u=j(n,l),c=r+"_"+t.getOptionGroupRenderKey(n),p=s({className:f("itemGroup",{optionGroupLabel:i}),style:l,"data-p-highlight":t.selected},C("itemGroup")),m=s({className:f("itemGroupLabel")},C("itemGroupLabel"));return e.createElement(e.Fragment,{key:c},e.createElement("li",p,e.createElement("span",m,a)),u)}var v=t.getOptionLabel(n),b=r+"_"+t.getOptionRenderKey(n),g=t.isOptionDisabled(n);return e.createElement(B,{key:b,label:v,index:r,focusedOptionIndex:t.focusedOptionIndex,option:n,style:l,template:t.itemTemplate,selected:t.isSelected(n),highlightOnSelect:t.highlightOnSelect,disabled:g,onClick:t.onOptionClick,onMouseMove:T,ptm:d,cx:f,checkmark:t.checkmark})},A=function(){if(t.showFilterClear&&t.filterValue){var n=r("clear"),o=s({className:f("filterClearIcon"),"aria-label":n,onClick:function(){return t.onFilterClearIconClick((function(){return y.focus(E.current)}))}},C("filterClearIcon"));return w.getJSXIcon(t.filterClearIcon||e.createElement(m,o),X({},o),{props:t})}return null},K=function(){if(t.filter){var n=A(),r=s({className:f("filterIcon")},C("filterIcon")),o=w.getJSXIcon(t.filterIcon||e.createElement(I,r),X({},r),{props:t}),l=s({className:f("filterContainer",{clearIcon:n})},C("filterContainer")),i=s({ref:E,type:"text",autoComplete:"off",className:f("filterInput",{context:b}),placeholder:t.filterPlaceholder,onKeyDown:t.onFilterInputKeyDown,onChange:function(e){return P(e)},value:t.filterValue},C("filterInput")),a=e.createElement("div",l,e.createElement("input",i),n,o);if(t.filterTemplate){var u={className:g("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!n}),element:a,filterOptions:k,filterInputKeyDown:t.onFilterInputKeyDown,filterInputChange:P,filterIconClassName:"p-dropdown-filter-icon",clearIcon:n,props:t};a=h.getJSXElement(t.filterTemplate,u)}var c=s({className:f("header")},C("header"));return e.createElement("div",c,a)}return null},V=function(){if(t.virtualScrollerOptions){var n=X(X({},t.virtualScrollerOptions),{style:X(X({},t.virtualScrollerOptions.style),{height:t.scrollHeight}),className:g("p-dropdown-items-wrapper",t.virtualScrollerOptions.className),items:t.visibleOptions,autoSize:!0,onLazyLoad:function(e){return t.virtualScrollerOptions.onLazyLoad(X(X({},e),{filter:t.filterValue}))},itemTemplate:function(e,t){return e&&G(e,t.index,t)},contentTemplate:function(n){var r=F?M(t.hasFilter?t.emptyFilterMessage:t.emptyMessage):n.children,o=s({ref:n.contentRef,style:n.style,className:g(n.className,f("list",{virtualScrollerProps:t.virtualScrollerOptions})),role:"listbox"},C("list"));return e.createElement("ul",o,r)}});return e.createElement(S,D({ref:t.virtualScrollerRef},n,{pt:d("virtualScroller")}))}var r=h.isNotEmpty(t.visibleOptions)?t.visibleOptions.map(G):t.hasFilter?M(t.emptyFilterMessage,!0):M(t.emptyMessage),o=s({className:f("wrapper"),style:v("wrapper")},C("wrapper")),l=s({className:f("list"),role:"listbox"},C("list"));return e.createElement("div",o,e.createElement("ul",l,r))},H=(l=K(),i=V(),u=R(),c=s({className:g(t.panelClassName,f("panel",{context:b})),style:v("panel"),onClick:t.onClick},C("panel")),p=s({classNames:f("transition"),in:t.in,timeout:{enter:120,exit:100},options:t.transitionOptions,unmountOnExit:!0,onEnter:N,onEntered:L,onExit:t.onExit,onExited:t.onExited},C("transition")),e.createElement(O,D({nodeRef:o},p),e.createElement("div",D({ref:o},c),t.firstFocusableElement,l,i,u,t.lastFocusableElement)));return e.createElement(x,{element:H,appendTo:t.appendTo})})));function U(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=q(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 l,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,l=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw l}}}}function q(e,t){if(e){if("string"==typeof e)return z(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)?z(e,t):void 0}}function z(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 W(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 Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?W(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}_.displayName="DropdownPanel";var $=e.memo(e.forwardRef((function(l,O){var I=a(),x=e.useContext(n),S=V.getProps(l,x),F=K(e.useState(""),2),k=F[0],C=F[1],L=K(e.useState(!1),2),P=L[0],T=L[1],j=K(e.useState(-1),2),M=j[0],G=j[1],A=K(e.useState(!1),2),H=A[0],B=A[1],J=e.useRef(!1),X=e.useRef(null),q=e.useRef(null),z=e.useRef(null),W=e.useRef(null),$=e.useRef(S.inputRef),Y=e.useRef(S.focusInputRef),Q=e.useRef(null),ee=e.useRef(null),te=e.useRef(null);e.useRef(null);var ne=S.virtualScrollerOptions&&S.virtualScrollerOptions.lazy,re=h.isNotEmpty(k),oe=S.appendTo||x&&x.appendTo||t.appendTo,le=V.setMetaData(Z(Z({props:S},S.__parentMetadata),{},{state:{filter:k,focused:P,overlayVisible:H}})),ie=le.ptm,ae=le.cx,ue=le.sx;i(V.css.styles,le.isUnstyled,{name:"dropdown"});var ce=K(u({target:X,overlay:q,listener:function(e,t){t.valid&&("outside"===t.type?!de(e)&&We():We())},when:H}),2),pe=ce[0],se=ce[1],de=function(e){return y.isAttributeEquals(e.target,"data-pc-section","clearicon")||y.isAttributeEquals(e.target.parentElement||e.target,"data-pc-section","filterclearicon")},fe=function(e){S.showOnFocus&&!H&&ze(),T(!0),S.onFocus&&S.onFocus(e)},me=function(e){T(!1),S.onBlur&&setTimeout((function(){var t=$.current?$.current.value:void 0;S.onBlur({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:S.name,id:S.id,value:t}})}),200)},ve=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=Qe(t);Je({originalEvent:e,option:r}),n&&We()},be=function(e){if(S.disabled||y.isAndroid())e.preventDefault();else{var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":ke(e);break;case"ArrowUp":Ce(e);break;case"ArrowLeft":case"ArrowRight":De(e,S.editable);break;case"Home":Ne(e);break;case"End":Le(e);break;case"PageDown":Re(e);break;case"PageUp":Pe(e);break;case"Space":Te(e,S.editable);break;case"NumpadEnter":case"Enter":je(e);break;case"Escape":Me(e);break;case"Tab":Ge(e);break;case"Backspace":Ae(e,S.editable);break;case"ShiftLeft":case"ShiftRight":break;default:!t&&h.isPrintableCharacter(e.key)&&(!H&&!S.editable&&ze(),!S.editable&&Ie(e,e.key))}J.current=!1}},ge=function(e){var t;return he(e)&&(null===(t=Ye(e))||void 0===t?void 0:t.toLocaleLowerCase(S.filterLocale).startsWith(te.current.toLocaleLowerCase(S.filterLocale)))},he=function(e){return h.isNotEmpty(e)&&!(tt(e)||et(e))},ye=function(){return h.isNotEmpty(S.value)},we=function(e){return he(e)&&qe(e)},Ee=function(){return ye?pt.findIndex((function(e){return we(e)})):-1},Oe=function(){var e=Ee();return e<0?xe():e},Ie=function(e,t){te.current=(te.current||"")+t;var n=-1,r=!1;return h.isNotEmpty(te.current)&&(-1!==(n=-1!==M?-1===(n=pt.slice(M).findIndex((function(e){return ge(e)})))?pt.slice(0,M).findIndex((function(e){return ge(e)})):n+M:pt.findIndex((function(e){return ge(e)})))&&(r=!0),-1===n&&-1===M&&(n=Oe()),-1!==n&&Fe(e,n)),ee.current&&clearTimeout(ee.current),ee.current=setTimeout((function(){te.current="",ee.current=null}),500),r},xe=function(){return pt.findIndex((function(e){return he(e)}))},Se=function(){return h.findLastIndex(pt,(function(e){return he(e)}))},Fe=function(e,t){M!==t&&(G(t),S.selectOnFocus&&ve(e,pt[t],!1))},ke=function(e){if(H){var t=-1!==M?(r=(n=M)<pt.length-1?pt.slice(n+1).findIndex((function(e){return he(e)})):-1)>-1?r+n+1:n:J.current?xe():Oe();Fe(e,t)}else ze(),S.editable&&Fe(e,Ee());var n,r;e.preventDefault()},Ce=function(e){var t,n,r;if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==M&&ve(e,pt[M]),state.overlayVisible&&We(),e.preventDefault();else{var o=-1!==M?(r=(n=M)>0?h.findLastIndex(pt.slice(0,n),(function(e){return he(e)})):-1)>-1?r:n:J.current?Se():(t=Ee())<0?Se():t;Fe(e,o),!H&&ze(),e.preventDefault()}},De=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(-1)},Ne=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?(e.currentTarget.setSelectionRange(0,0),G(-1)):(Fe(e,xe()),!H&&ze()),e.preventDefault()},Le=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var t=e.currentTarget,n=t.value.length;t.setSelectionRange(n,n),G(-1)}else Fe(e,Se()),!H&&ze();e.preventDefault()},Pe=function(e){e.preventDefault()},Re=function(e){e.preventDefault()},Te=function(e){!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])&&je(e)},je=function(e){H?(-1!==M&&ve(e,pt[M]),We()):(G(-1),ke(e)),e.preventDefault()},Me=function(e){H&&We(),e.preventDefault()},Ge=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(!H||y.getFocusableElements(q.current,':not([data-p-hidden-focusable="true"])').length>0?(-1!==M&&ve(e,pt[M]),H&&We()):(y.focus(z.current),e.preventDefault()))},Ae=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&!H&&ze()},Ke=function(e){var t=null;e.target.value&&(t=pt.findIndex((function(t){return Ye(t).toLocaleLowerCase().startsWith(e.target.value.toLocaleLowerCase())}))),G(t),S.onChange&&S.onChange({originalEvent:e.originalEvent,value:e.target.value,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:S.name,id:S.id,value:e.target.value}})},Ve=function(e){T(!0),We(),S.onFocus&&S.onFocus(e)},He=function(e){C(""),S.onFilter&&S.onFilter({filter:""}),e&&e()},Be=function(e){S.onChange&&S.onChange({originalEvent:e,value:void 0,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:S.name,id:S.id,value:void 0}}),S.filter&&He(),$e()},Je=function(e){if(st!==e.option){$e(e.option),G(-1);var t=Qe(e.option),n=Ue(e.option,pt);S.onChange&&S.onChange({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:S.name,id:S.id,value:t}}),Fe(e.originalEvent,n)}},Xe=function(e){if(e=e||pt,null!=S.value&&e){if(!S.optionGroupLabel)return Ue(S.value,e);for(var t=0;t<e.length;t++){var n=Ue(S.value,nt(e[t]));if(-1!==n)return{group:t,option:n}}}return-1},_e=function(){return S.optionValue?null:S.dataKey},Ue=function(e,t){var n=_e();return t.findIndex((function(t){return h.equals(e,Qe(t),n)}))},qe=function(e){return h.equals(S.value,Qe(e),_e())},ze=function(){G(-1!==M?M:S.autoOptionFocus?Oe():S.editable?-1:Ee()),B(!0)},We=function(){B(!1),J.current=!1},Ze=function(){y.alignOverlay(q.current,$.current.parentElement,S.appendTo||x&&x.appendTo||t.appendTo)},$e=function(e){$.current&&($.current.value=e?Ye(e):S.value||"",Y.current&&(Y.current.value=$.current.value))},Ye=function(e){return S.optionLabel?h.resolveFieldData(e,S.optionLabel):e&&void 0!==e.label?e.label:e},Qe=function(e){return S.optionValue?h.resolveFieldData(e,S.optionValue):e&&void 0!==e.value?e.value:e},et=function(e){return S.optionGroupLabel&&e.optionGroup&&e.group},tt=function(e){return S.optionDisabled?h.isFunction(S.optionDisabled)?S.optionDisabled(e):h.resolveFieldData(e,S.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled},nt=function(e){return h.resolveFieldData(e,S.optionGroupChildren)},rt=function(){if(S.editable&&$.current){var e=(st?Ye(st):null)||S.value||"";$.current.value=e,Y.current&&(Y.current.value=e)}};e.useImperativeHandle(O,(function(){return{props:S,show:ze,hide:We,clear:Be,focus:function(){return y.focus(Y.current)},getElement:function(){return X.current},getOverlay:function(){return q.current},getInput:function(){return $.current},getFocusInput:function(){return Y.current},getVirtualScroller:function(){return Q.current}}})),e.useEffect((function(){h.combinedRefs($,S.inputRef),h.combinedRefs(Y,S.focusInputRef)}),[$,S.inputRef,Y,S.focusInputRef]),c((function(){S.autoFocus&&y.focus(Y.current,S.autoFocus),Ze()})),p((function(){var e;H&&S.value&&(e=y.findSingle(q.current,'li[data-p-highlight="true"]'))&&e.scrollIntoView&&e.scrollIntoView({block:"nearest",inline:"nearest"})}),[H,S.value]),p((function(){H&&k&&S.filter&&Ze()}),[H,k,S.filter]),p((function(){!k||S.options&&0!==S.options.length||C(""),rt(),$.current&&($.current.selectedIndex=1)})),s((function(){E.clear(q.current)}));var ot,lt,it,at,ut,ct=function(e){"Enter"!==e.key&&"Space"!==e.code||(Be(e),e.preventDefault())},pt=function(){if(re&&!ne){var e=k.trim().toLocaleLowerCase(S.filterLocale),t=S.filterBy?S.filterBy.split(","):[S.optionLabel||"label"];if(S.optionGroupLabel){var n,r=[],l=U(S.options);try{for(l.s();!(n=l.n()).done;){var i=n.value,a=o.filter(nt(i),t,e,S.filterMatchMode,S.filterLocale);a&&a.length&&r.push(Z(Z({},i),R({},"".concat(S.optionGroupChildren),a)))}}catch(e){l.e(e)}finally{l.f()}return r}return o.filter(S.options,t,e,S.filterMatchMode,S.filterLocale)}return S.options}(),st=-1!==(ot=Xe(S.options))?S.optionGroupLabel?nt(S.options[ot.group])[ot.option]:S.options[ot]:null,dt=h.isNotEmpty(S.tooltip),ft=V.getOtherProps(S),mt=h.reduceKeys(ft,y.ARIA_PROPS),vt=function(){var t={value:"",label:S.placeholder};if(st){var n=Qe(st);t={value:"object"===N(n)?S.options.findIndex((function(e){return e===n})):n,label:Ye(st)}}var r=I({className:"p-hidden-accessible p-dropdown-hidden-select"},ie("hiddenSelectedMessage")),o=I({ref:$,required:S.required,defaultValue:t.value,name:S.name,tabIndex:-1,"aria-hidden":"true"},ie("select")),l=I({value:t.value},ie("option"));return e.createElement("div",r,e.createElement("select",o,e.createElement("option",l,t.label)))}(),bt=function(){var t=h.isNotEmpty(st)?Ye(st):null;S.editable&&(t=t||S.value||"");var n=I({className:"p-hidden-accessible"},ie("hiddenSelectedMessage")),r=I(Z({ref:Y,id:S.inputId,defaultValue:t,type:"text",readOnly:!0,"aria-haspopup":"listbox",onFocus:fe,onBlur:me,onKeyDown:be,disabled:S.disabled,tabIndex:S.disabled?-1:S.tabIndex||0},mt),ie("input"));return e.createElement("div",n,e.createElement("input",r))}(),gt=function(){var t=h.isNotEmpty(st)?Ye(st):null;if(S.editable){var n=I(Z({ref:$,type:"text",defaultValue:t||S.value||"",className:ae("input",{label:t}),disabled:S.disabled,placeholder:S.placeholder,maxLength:S.maxLength,onInput:Ke,onFocus:Ve,onKeyDown:be,onBlur:me,tabIndex:S.disabled?-1:S.tabIndex||0,"aria-haspopup":"listbox"},mt),ie("input"));return e.createElement("input",n)}var r=S.valueTemplate?h.getJSXElement(S.valueTemplate,st,S):t||S.placeholder||"empty",o=I({ref:$,className:ae("input",{label:t}),tabIndex:"-1"},ie("input"));return e.createElement("span",o,r)}(),ht=S.loading?(lt=I({className:ae("loadingIcon"),"data-pr-overlay-visible":H},ie("loadingIcon")),it=w.getJSXIcon(S.loadingIcon||e.createElement(f,{spin:!0}),Z({},lt),{props:S}),at=S.placeholder||S.ariaLabel,ut=I({className:ae("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":H,"aria-label":at},ie("trigger")),e.createElement("div",ut,it)):function(){var t=I({className:ae("dropdownIcon"),"data-pr-overlay-visible":H},ie("dropdownIcon")),n=w.getJSXIcon(S.dropdownIcon||e.createElement(d,t),Z({},t),{props:S}),r=S.placeholder||S.ariaLabel,o=I({className:ae("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":H,"aria-label":r},ie("trigger"));return e.createElement("div",o,n)}(),yt=function(){if(null!=S.value&&S.showClear&&!S.disabled){var t=I({className:ae("clearIcon"),onPointerUp:Be,tabIndex:S.tabIndex||"0",onKeyDown:ct,"aria-label":r("clear")},ie("clearIcon"));return w.getJSXIcon(S.clearIcon||e.createElement(m,t),Z({},t),{props:S})}return null}(),wt=I({id:S.id,ref:X,className:g(S.className,ae("root",{context:x,focusedState:P,overlayVisibleState:H})),style:S.style,onClick:function(e){return t=e,void(S.disabled||S.loading||(S.onClick&&S.onClick(t),t.defaultPrevented||de(t)||"INPUT"===t.target.tagName||(q.current&&q.current&&q.current.contains(t.target)||(y.focus(Y.current),H?We():ze()),J.current=!0)));var t},onMouseDown:S.onMouseDown,onContextMenu:S.onContextMenu,onFocus:function(){S.editable&&!H&&!1===J.current&&y.focus($.current)},"data-p-disabled":S.disabled,"data-p-focus":P},ft,ie("root")),Et=I({ref:z,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===Y.current?y.getFirstFocusableElement(q.current,':not([data-p-hidden-focusable="true"])'):Y.current;y.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},ie("hiddenFirstFocusableEl")),Ot=I({ref:W,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===Y.current?y.getLastFocusableElement(q.current,':not([data-p-hidden-focusable="true"])'):Y.current;y.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},ie("hiddenLastFocusableEl"));return e.createElement(e.Fragment,null,e.createElement("div",wt,bt,vt,gt,yt,ht,e.createElement(_,D({hostName:"Dropdown",ref:q,visibleOptions:pt,virtualScrollerRef:Q},S,{appendTo:oe,cx:ae,filterValue:k,focusedOptionIndex:M,getOptionGroupChildren:nt,getOptionGroupLabel:function(e){return h.resolveFieldData(e,S.optionGroupLabel)},getOptionGroupRenderKey:function(e){return h.resolveFieldData(e,S.optionGroupLabel)},getOptionLabel:Ye,getOptionRenderKey:function(e){return S.dataKey?h.resolveFieldData(e,S.dataKey):Ye(e)},getSelectedOptionIndex:Xe,hasFilter:re,in:H,isOptionDisabled:tt,isSelected:qe,onClick:function(e){v.emit("overlay-click",{originalEvent:e,target:X.current})},onEnter:function(e){E.set("overlay",q.current,x&&x.autoZIndex||t.autoZIndex,x&&x.zIndex.overlay||t.zIndex.overlay),y.addStyles(q.current,{position:"absolute",top:"0",left:"0"}),Ze(),e&&e()},onEntered:function(e){e&&e(),pe(),S.onShow&&S.onShow()},onExit:function(){se()},onExited:function(){S.filter&&S.resetFilterOnHide&&He(),E.clear(q.current),S.onHide&&S.onHide()},onFilterClearIconClick:function(e){He(e)},onFilterInputChange:function(e){var t=e.target.value;C(t),S.onFilter&&S.onFilter({originalEvent:e,filter:t})},onFilterInputKeyDown:function(e){switch(e.code){case"ArrowDown":ke(e);break;case"ArrowUp":Ce(e);break;case"ArrowLeft":case"ArrowRight":De(e,!0);break;case"Escape":case"Enter":case"NumpadEnter":je(e),e.preventDefault()}},onOptionClick:function(e){e.option.disabled||(Je(e),y.focus(Y.current)),We()},ptm:ie,resetFilter:He,changeFocusedOptionIndex:Fe,firstFocusableElement:e.createElement("span",Et),lastFocusableElement:e.createElement("span",Ot),sx:ue}))),dt&&e.createElement(b,D({target:X,content:S.tooltip,pt:ie("tooltip")},S.tooltipOptions)))})));$.displayName="Dropdown";export{$ as Dropdown};
|
|
1
|
+
import*as e from"react";import t,{PrimeReactContext as n,localeOption as r,FilterService as o}from"primereact/api";import{ComponentBase as l,useHandleStyle as i}from"primereact/componentbase";import{useMergeProps as a,useOverlayListener as u,useMountEffect as c,useUpdateEffect as p,useUnmountEffect as s}from"primereact/hooks";import{ChevronDownIcon as d}from"primereact/icons/chevrondown";import{SpinnerIcon as f}from"primereact/icons/spinner";import{TimesIcon as m}from"primereact/icons/times";import{OverlayService as v}from"primereact/overlayservice";import{Tooltip as b}from"primereact/tooltip";import{classNames as g,ObjectUtils as h,DomHandler as y,IconUtils as w,ZIndexUtils as E}from"primereact/utils";import{CSSTransition as I}from"primereact/csstransition";import{SearchIcon as O}from"primereact/icons/search";import{Portal as x}from"primereact/portal";import{VirtualScroller as S}from"primereact/virtualscroller";import{Ripple as F}from"primereact/ripple";import{CheckIcon as k}from"primereact/icons/check";import{IconBase as C}from"primereact/iconbase";function D(){return D=Object.assign?Object.assign.bind():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},D.apply(this,arguments)}function N(e){return N="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},N(e)}function L(e,t){if("object"!==N(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function P(e){var t=L(e,"string");return"symbol"===N(t)?t:String(t)}function R(e,t,n){return(t=P(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function T(e){if(Array.isArray(e))return e}function j(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l,i,a=[],u=!0,c=!1;try{if(l=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=l.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}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 G(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 A(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function K(e,t){return T(e)||j(e,t)||G(e,t)||A()}var V=l.extend({defaultProps:{__TYPE:"Dropdown",__parentMetadata:null,appendTo:null,ariaLabel:null,ariaLabelledBy:null,autoFocus:!1,children:void 0,className:null,clearIcon:null,dataKey:null,disabled:!1,dropdownIcon:null,editable:!1,emptyFilterMessage:null,highlightOnSelect:!0,checkmark:!1,emptyMessage:null,filter:!1,filterBy:null,filterClearIcon:null,filterIcon:null,filterInputAutoFocus:!1,filterLocale:void 0,filterMatchMode:"contains",filterPlaceholder:null,filterTemplate:null,focusInputRef:null,id:null,inputId:null,inputRef:null,invalid:!1,variant:null,itemTemplate:null,loading:!1,loadingIcon:null,maxLength:null,name:null,onBlur:null,onChange:null,onContextMenu:null,onFilter:null,onFocus:null,onHide:null,onMouseDown:null,onShow:null,optionDisabled:null,optionGroupChildren:"items",selectOnFocus:!1,focusOnHover:!0,autoOptionFocus:!1,optionGroupLabel:null,optionGroupTemplate:null,optionLabel:null,optionValue:null,options:null,panelClassName:null,panelFooterTemplate:null,panelStyle:null,placeholder:null,required:!1,resetFilterOnHide:!1,scrollHeight:"200px",showClear:!1,showFilterClear:!1,showOnFocus:!1,style:null,tabIndex:null,tooltip:null,tooltipOptions:null,transitionOptions:null,value:null,valueTemplate:null,virtualScrollerOptions:null},css:{classes:{root:function(e){var t=e.props,n=e.focusedState,r=e.overlayVisibleState,o=e.context;return g("p-dropdown p-component p-inputwrapper",{"p-disabled":t.disabled,"p-invalid":t.invalid,"p-focus":n,"p-variant-filled":t.variant?"filled"===t.variant:o&&"filled"===o.inputStyle,"p-dropdown-clearable":t.showClear&&!t.disabled,"p-inputwrapper-filled":h.isNotEmpty(t.value),"p-inputwrapper-focus":n||r})},input:function(e){var t=e.props,n=e.label;return t.editable?"p-dropdown-label p-inputtext":g("p-dropdown-label p-inputtext",{"p-placeholder":null===n&&t.placeholder,"p-dropdown-label-empty":null===n&&!t.placeholder})},trigger:"p-dropdown-trigger",emptyMessage:"p-dropdown-empty-message",itemGroup:function(e){var t=e.optionGroupLabel;return g("p-dropdown-item-group",{"p-dropdown-item-empty":!t||0===t.length})},itemGroupLabel:"p-dropdown-item-group-label",dropdownIcon:"p-dropdown-trigger-icon p-clickable",loadingIcon:"p-dropdown-trigger-icon p-clickable",clearIcon:"p-dropdown-clear-icon p-clickable",filterIcon:"p-dropdown-filter-icon",filterClearIcon:"p-dropdown-filter-clear-icon",filterContainer:function(e){return g("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!e.clearIcon})},filterInput:function(e){var t=e.props,n=e.context;return g("p-dropdown-filter p-inputtext p-component",{"p-variant-filled":t.variant?"filled"===t.variant:n&&"filled"===n.inputStyle})},list:function(e){return"p-dropdown-items"},panel:function(e){var n=e.context;return g("p-dropdown-panel p-component",{"p-input-filled":n&&"filled"===n.inputStyle||"filled"===t.inputStyle,"p-ripple-disabled":n&&!1===n.ripple||!1===t.ripple})},item:function(e){var t=e.label;return g("p-dropdown-item",{"p-highlight":e.selected&&e.highlightOnSelect,"p-disabled":e.disabled,"p-focus":e.index===e.focusedOptionIndex,"p-dropdown-item-empty":!t||0===t.length})},itemLabel:"p-dropdown-item-label",checkIcon:"p-dropdown-check-icon",blankIcon:"p-dropdown-blank-icon",wrapper:"p-dropdown-items-wrapper",header:"p-dropdown-header",footer:"p-dropdown-footer",transition:"p-connected-overlay"},styles:"\n@layer primereact {\n .p-dropdown {\n display: inline-flex;\n cursor: pointer;\n position: relative;\n user-select: none;\n }\n \n .p-dropdown-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n .p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n }\n \n .p-dropdown-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n input.p-dropdown-label {\n cursor: default;\n }\n \n .p-dropdown .p-dropdown-panel {\n min-width: 100%;\n }\n \n .p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-dropdown-items-wrapper {\n overflow: auto;\n }\n \n .p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n \n .p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-dropdown-filter {\n width: 100%;\n }\n \n .p-dropdown-filter-container {\n position: relative;\n }\n \n .p-dropdown-clear-icon,\n .p-dropdown-filter-icon,\n .p-dropdown-filter-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-fluid .p-dropdown {\n display: flex;\n }\n \n .p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n }\n}\n",inlineStyles:{wrapper:function(e){return{maxHeight:e.props.scrollHeight||"auto"}},panel:function(e){}}}}),H=e.memo(e.forwardRef((function(t,n){var r=C.getPTI(t);return e.createElement("svg",D({ref:n,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},r),e.createElement("rect",{width:"1",height:"1",fill:"currentColor",fillOpacity:"0"}))})));H.displayName="BlankIcon";var B=e.memo((function(t){var n=a(),r=t.ptm,o=t.cx,l=t.selected,i=t.disabled,u=t.option,c=t.label,p=t.index,s=t.focusedOptionIndex,d=t.checkmark,f=t.highlightOnSelect,m=function(e){return r(e,{context:{selected:l,disabled:i}})},v=t.template?h.getJSXElement(t.template,t.option):t.label,b=n({role:"option",key:t.label,className:g(u.className,o("item",{selected:l,disabled:i,label:c,index:p,focusedOptionIndex:s,highlightOnSelect:f})),style:t.style,onClick:function(e){return n=e,void(t.onClick&&t.onClick({originalEvent:n,option:u}));var n},onMouseMove:function(e){return null==t?void 0:t.onMouseMove(e,p)},"aria-label":c,"aria-selected":l,"data-p-highlight":l,"data-p-focused":s===p,"data-p-disabled":i},m("item")),y=n({className:o("itemLabel")},m("itemLabel"));return e.createElement("li",b,d&&function(){if(l){var t=n({className:o("checkIcon")},m("checIcon"));return e.createElement(k,t)}var r=n({className:o("blankIcon")},m("blankIcon"));return e.createElement(H,r)}(),e.createElement("span",y,v),e.createElement(F,null))}));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 X(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){R(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}B.displayName="DropdownItem";var _=e.memo(e.forwardRef((function(t,o){var l,i,u,c,p,s=a(),d=t.ptm,f=t.cx,v=t.sx,b=e.useContext(n),E=e.useRef(null),F=!(t.visibleOptions&&t.visibleOptions.length)&&t.hasFilter,k={filter:function(e){return P(e)},reset:function(){return t.resetFilter()}},C=function(e,n){return d(e,X({hostName:t.hostName},n))},N=function(){t.onEnter((function(){if(t.virtualScrollerRef.current){var e=t.getSelectedOptionIndex();-1!==e&&setTimeout((function(){return t.virtualScrollerRef.current.scrollToIndex(e)}),0)}}))},L=function(){t.onEntered((function(){t.filter&&t.filterInputAutoFocus&&y.focus(E.current,!1)}))},P=function(e){t.virtualScrollerRef.current&&t.virtualScrollerRef.current.scrollToIndex(0),t.onFilterInputChange&&t.onFilterInputChange(e)},R=function(){if(t.panelFooterTemplate){var n=h.getJSXElement(t.panelFooterTemplate,t,t.onOverlayHide),r=s({className:f("footer")},C("footer"));return e.createElement("div",r,n)}return null},T=function(e,n){var r;t.focusOnHover&&(null==t||null===(r=t.changeFocusedOptionIndex)||void 0===r||r.call(t,e,n))},j=function(n,o){var l=h.getJSXElement(n,t)||r(o?"emptyFilterMessage":"emptyMessage"),i=s({className:f("emptyMessage")},C("emptyMessage"));return e.createElement("li",i,l)},M=function(n,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l={height:o.props?o.props.itemSize:void 0};if(l=X(X({},l),n.style),n.group&&t.optionGroupLabel){var i=t.optionGroupLabel,a=t.optionGroupTemplate?h.getJSXElement(t.optionGroupTemplate,n,r):t.getOptionGroupLabel(n),u=r+"_"+t.getOptionGroupRenderKey(n),c=s({className:f("itemGroup",{optionGroupLabel:i}),style:l,"data-p-highlight":t.selected},C("itemGroup")),p=s({className:f("itemGroupLabel")},C("itemGroupLabel"));return e.createElement("li",D({key:u},c),e.createElement("span",p,a))}var m=t.getOptionRenderKey(n)+"_"+r,v=t.getOptionLabel(n),b=t.isOptionDisabled(n);return e.createElement(B,{key:m,label:v,index:r,focusedOptionIndex:t.focusedOptionIndex,option:n,style:l,template:t.itemTemplate,selected:t.isSelected(n),highlightOnSelect:t.highlightOnSelect,disabled:b,onClick:t.onOptionClick,onMouseMove:T,ptm:d,cx:f,checkmark:t.checkmark})},G=function(){if(t.showFilterClear&&t.filterValue){var n=r("clear"),o=s({className:f("filterClearIcon"),"aria-label":n,onClick:function(){return t.onFilterClearIconClick((function(){return y.focus(E.current)}))}},C("filterClearIcon"));return w.getJSXIcon(t.filterClearIcon||e.createElement(m,o),X({},o),{props:t})}return null},A=function(){if(t.filter){var n=G(),r=s({className:f("filterIcon")},C("filterIcon")),o=w.getJSXIcon(t.filterIcon||e.createElement(O,r),X({},r),{props:t}),l=s({className:f("filterContainer",{clearIcon:n})},C("filterContainer")),i=s({ref:E,type:"text",autoComplete:"off",className:f("filterInput",{context:b}),placeholder:t.filterPlaceholder,onKeyDown:t.onFilterInputKeyDown,onChange:function(e){return P(e)},value:t.filterValue},C("filterInput")),a=e.createElement("div",l,e.createElement("input",i),n,o);if(t.filterTemplate){var u={className:g("p-dropdown-filter-container",{"p-dropdown-clearable-filter":!!n}),element:a,filterOptions:k,filterInputKeyDown:t.onFilterInputKeyDown,filterInputChange:P,filterIconClassName:"p-dropdown-filter-icon",clearIcon:n,props:t};a=h.getJSXElement(t.filterTemplate,u)}var c=s({className:f("header")},C("header"));return e.createElement("div",c,a)}return null},K=function(){if(t.virtualScrollerOptions){var n=X(X({},t.virtualScrollerOptions),{style:X(X({},t.virtualScrollerOptions.style),{height:t.scrollHeight}),className:g("p-dropdown-items-wrapper",t.virtualScrollerOptions.className),items:t.visibleOptions,autoSize:!0,onLazyLoad:function(e){return t.virtualScrollerOptions.onLazyLoad(X(X({},e),{filter:t.filterValue}))},itemTemplate:function(e,t){return e&&M(e,t.index,t)},contentTemplate:function(n){var r=F?j(t.hasFilter?t.emptyFilterMessage:t.emptyMessage):n.children,o=s({ref:n.contentRef,style:n.style,className:g(n.className,f("list",{virtualScrollerProps:t.virtualScrollerOptions})),role:"listbox"},C("list"));return e.createElement("ul",o,r)}});return e.createElement(S,D({ref:t.virtualScrollerRef},n,{pt:d("virtualScroller")}))}var r=h.isNotEmpty(t.visibleOptions)?t.visibleOptions.map(M):t.hasFilter?j(t.emptyFilterMessage,!0):j(t.emptyMessage),o=s({className:f("wrapper"),style:v("wrapper")},C("wrapper")),l=s({className:f("list"),role:"listbox"},C("list"));return e.createElement("div",o,e.createElement("ul",l,r))},V=(l=A(),i=K(),u=R(),c=s({className:g(t.panelClassName,f("panel",{context:b})),style:v("panel"),onClick:t.onClick},C("panel")),p=s({classNames:f("transition"),in:t.in,timeout:{enter:120,exit:100},options:t.transitionOptions,unmountOnExit:!0,onEnter:N,onEntered:L,onExit:t.onExit,onExited:t.onExited},C("transition")),e.createElement(I,D({nodeRef:o},p),e.createElement("div",D({ref:o},c),t.firstFocusableElement,l,i,u,t.lastFocusableElement)));return e.createElement(x,{element:V,appendTo:t.appendTo})})));function U(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=q(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 l,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,l=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw l}}}}function q(e,t){if(e){if("string"==typeof e)return z(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)?z(e,t):void 0}}function z(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 W(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 Z(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?W(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}_.displayName="DropdownPanel";var $=e.memo(e.forwardRef((function(l,I){var O=a(),x=e.useContext(n),S=V.getProps(l,x),F=K(e.useState(""),2),k=F[0],C=F[1],L=K(e.useState(!1),2),P=L[0],T=L[1],j=K(e.useState(-1),2),M=j[0],G=j[1],A=K(e.useState(!1),2),H=A[0],B=A[1],J=e.useRef(!1),X=e.useRef(null),q=e.useRef(null),z=e.useRef(null),W=e.useRef(null),$=e.useRef(S.inputRef),Y=e.useRef(S.focusInputRef),Q=e.useRef(null),ee=e.useRef(null),te=e.useRef(null);e.useRef(null);var ne=S.virtualScrollerOptions&&S.virtualScrollerOptions.lazy,re=h.isNotEmpty(k),oe=S.appendTo||x&&x.appendTo||t.appendTo,le=V.setMetaData(Z(Z({props:S},S.__parentMetadata),{},{state:{filter:k,focused:P,overlayVisible:H}})),ie=le.ptm,ae=le.cx,ue=le.sx;i(V.css.styles,le.isUnstyled,{name:"dropdown"});var ce=K(u({target:X,overlay:q,listener:function(e,t){t.valid&&("outside"===t.type?!fe(e)&&Ze():Ze())},when:H}),2),pe=ce[0],se=ce[1],de=function(e){return(e||[]).reduce((function(e,t,n){e.push({optionGroup:t,group:!0,index:n,code:t.code,label:t.label});var r=ot(t);return r&&r.forEach((function(t){return e.push(t)})),e}),[])},fe=function(e){return y.isAttributeEquals(e.target,"data-pc-section","clearicon")||y.isAttributeEquals(e.target.parentElement||e.target,"data-pc-section","filterclearicon")},me=function(e){S.showOnFocus&&!H&&We(),T(!0),S.onFocus&&S.onFocus(e)},ve=function(e){T(!1),S.onBlur&&setTimeout((function(){var t=$.current?$.current.value:void 0;S.onBlur({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:S.name,id:S.id,value:t}})}),200)},be=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=tt(t);Xe({originalEvent:e,option:r}),n&&Ze()},ge=function(e){if(S.disabled||y.isAndroid())e.preventDefault();else{var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":Ce(e);break;case"ArrowUp":De(e);break;case"ArrowLeft":case"ArrowRight":Ne(e,S.editable);break;case"Home":Le(e);break;case"End":Pe(e);break;case"PageDown":Te(e);break;case"PageUp":Re(e);break;case"Space":je(e,S.editable);break;case"NumpadEnter":case"Enter":Me(e);break;case"Escape":Ge(e);break;case"Tab":Ae(e);break;case"Backspace":Ke(e,S.editable);break;case"ShiftLeft":case"ShiftRight":break;default:!t&&h.isPrintableCharacter(e.key)&&(!H&&!S.editable&&We(),!S.editable&&xe(e,e.key))}J.current=!1}},he=function(e){var t;return ye(e)&&(null===(t=et(e))||void 0===t?void 0:t.toLocaleLowerCase(S.filterLocale).startsWith(te.current.toLocaleLowerCase(S.filterLocale)))},ye=function(e){return h.isNotEmpty(e)&&!(rt(e)||nt(e))},we=function(){return h.isNotEmpty(S.value)},Ee=function(e){return ye(e)&&ze(e)},Ie=function(){return we?dt.findIndex((function(e){return Ee(e)})):-1},Oe=function(){var e=Ie();return e<0?Se():e},xe=function(e,t){te.current=(te.current||"")+t;var n=-1,r=!1;return h.isNotEmpty(te.current)&&(-1!==(n=-1!==M?-1===(n=dt.slice(M).findIndex((function(e){return he(e)})))?dt.slice(0,M).findIndex((function(e){return he(e)})):n+M:dt.findIndex((function(e){return he(e)})))&&(r=!0),-1===n&&-1===M&&(n=Oe()),-1!==n&&ke(e,n)),ee.current&&clearTimeout(ee.current),ee.current=setTimeout((function(){te.current="",ee.current=null}),500),r},Se=function(){return dt.findIndex((function(e){return ye(e)}))},Fe=function(){return h.findLastIndex(dt,(function(e){return ye(e)}))},ke=function(e,t){M!==t&&(G(t),S.selectOnFocus&&be(e,dt[t],!1))},Ce=function(e){if(H){var t=-1!==M?(r=(n=M)<dt.length-1?dt.slice(n+1).findIndex((function(e){return ye(e)})):-1)>-1?r+n+1:n:J.current?Se():Oe();ke(e,t)}else We(),S.editable&&ke(e,Ie());var n,r;e.preventDefault()},De=function(e){var t,n,r;if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==M&&be(e,dt[M]),state.overlayVisible&&Ze(),e.preventDefault();else{var o=-1!==M?(r=(n=M)>0?h.findLastIndex(dt.slice(0,n),(function(e){return ye(e)})):-1)>-1?r:n:J.current?Fe():(t=Ie())<0?Fe():t;ke(e,o),!H&&We(),e.preventDefault()}},Ne=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&G(-1)},Le=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?(e.currentTarget.setSelectionRange(0,0),G(-1)):(ke(e,Se()),!H&&We()),e.preventDefault()},Pe=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var t=e.currentTarget,n=t.value.length;t.setSelectionRange(n,n),G(-1)}else ke(e,Fe()),!H&&We();e.preventDefault()},Re=function(e){e.preventDefault()},Te=function(e){e.preventDefault()},je=function(e){!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])&&Me(e)},Me=function(e){H?(-1!==M&&be(e,dt[M]),Ze()):(G(-1),Ce(e)),e.preventDefault()},Ge=function(e){H&&Ze(),e.preventDefault()},Ae=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(!H||y.getFocusableElements(q.current,':not([data-p-hidden-focusable="true"])').length>0?(-1!==M&&be(e,dt[M]),H&&Ze()):(y.focus(z.current),e.preventDefault()))},Ke=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&!H&&We()},Ve=function(e){var t=null;e.target.value&&(t=dt.findIndex((function(t){return et(t).toLocaleLowerCase().startsWith(e.target.value.toLocaleLowerCase())}))),G(t),S.onChange&&S.onChange({originalEvent:e.originalEvent,value:e.target.value,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:S.name,id:S.id,value:e.target.value}})},He=function(e){T(!0),Ze(),S.onFocus&&S.onFocus(e)},Be=function(e){C(""),S.onFilter&&S.onFilter({filter:""}),e&&e()},Je=function(e){S.onChange&&S.onChange({originalEvent:e,value:void 0,stopPropagation:function(){null==e||e.stopPropagation()},preventDefault:function(){null==e||e.preventDefault()},target:{name:S.name,id:S.id,value:void 0}}),S.filter&&Be(),Qe()},Xe=function(e){if(ft!==e.option){Qe(e.option),G(-1);var t=tt(e.option),n=qe(e.option,dt);S.onChange&&S.onChange({originalEvent:e.originalEvent,value:t,stopPropagation:function(){e.originalEvent.stopPropagation()},preventDefault:function(){e.originalEvent.preventDefault()},target:{name:S.name,id:S.id,value:t}}),ke(e.originalEvent,n)}},_e=function(e){if(e=e||dt,null!=S.value&&e){if(!S.optionGroupLabel)return qe(S.value,e);for(var t=0;t<e.length;t++){var n=qe(S.value,ot(e[t]));if(-1!==n)return{group:t,option:n}}}return-1},Ue=function(){return S.optionValue?null:S.dataKey},qe=function(e,t){var n=Ue();return t.findIndex((function(t){return h.equals(e,tt(t),n)}))},ze=function(e){return h.equals(S.value,tt(e),Ue())},We=function(){G(-1!==M?M:S.autoOptionFocus?Oe():S.editable?-1:Ie()),B(!0)},Ze=function(){B(!1),J.current=!1},$e=function(){y.alignOverlay(q.current,$.current.parentElement,S.appendTo||x&&x.appendTo||t.appendTo)},Ye=function(){var e=y.findSingle(q.current,'li[data-p-focused="true"]');if(e&&e.scrollIntoView)e.scrollIntoView({block:"nearest",inline:"nearest"});else{var t=y.findSingle(q.current,'li[data-p-highlight="true"]');t&&t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"nearest"})}},Qe=function(e){$.current&&($.current.value=e?et(e):S.value||"",Y.current&&(Y.current.value=$.current.value))},et=function(e){return S.optionLabel?h.resolveFieldData(e,S.optionLabel):e},tt=function(e){return S.optionValue?h.resolveFieldData(e,S.optionValue):e},nt=function(e){return S.optionGroupLabel&&e.optionGroup&&e.group},rt=function(e){return S.optionDisabled?h.isFunction(S.optionDisabled)?S.optionDisabled(e):h.resolveFieldData(e,S.optionDisabled):!(!e||void 0===e.disabled)&&e.disabled},ot=function(e){return h.resolveFieldData(e,S.optionGroupChildren)},lt=function(){if(S.editable&&$.current){var e=(ft?et(ft):null)||S.value||"";$.current.value=e,Y.current&&(Y.current.value=e)}};e.useImperativeHandle(I,(function(){return{props:S,show:We,hide:Ze,clear:Je,focus:function(){return y.focus(Y.current)},getElement:function(){return X.current},getOverlay:function(){return q.current},getInput:function(){return $.current},getFocusInput:function(){return Y.current},getVirtualScroller:function(){return Q.current}}})),e.useEffect((function(){h.combinedRefs($,S.inputRef),h.combinedRefs(Y,S.focusInputRef)}),[$,S.inputRef,Y,S.focusInputRef]),c((function(){S.autoFocus&&y.focus(Y.current,S.autoFocus),$e()})),p((function(){H&&(S.value||M>=0)&&Ye()}),[H,S.value,M]),p((function(){H&&k&&S.filter&&$e()}),[H,k,S.filter]),p((function(){!k||S.options&&0!==S.options.length||C(""),lt(),$.current&&($.current.selectedIndex=1)})),s((function(){E.clear(q.current)}));var it,at,ut,ct,pt,st=function(e){"Enter"!==e.key&&"Space"!==e.code||(Je(e),e.preventDefault())},dt=function(){var e=S.optionGroupLabel?de(S.options):S.options;if(re&&!ne){var t=k.trim().toLocaleLowerCase(S.filterLocale),n=S.filterBy?S.filterBy.split(","):[S.optionLabel||"label"];if(S.optionGroupLabel){var r,l=[],i=U(S.options);try{for(i.s();!(r=i.n()).done;){var a=r.value,u=o.filter(ot(a),n,t,S.filterMatchMode,S.filterLocale);u&&u.length&&l.push(Z(Z({},a),R({},"".concat(S.optionGroupChildren),u)))}}catch(e){i.e(e)}finally{i.f()}return de(l)}return o.filter(e,n,t,S.filterMatchMode,S.filterLocale)}return e}(),ft=-1!==(it=_e(S.options))?S.optionGroupLabel?ot(S.options[it.group])[it.option]:S.options[it]:null,mt=h.isNotEmpty(S.tooltip),vt=V.getOtherProps(S),bt=h.reduceKeys(vt,y.ARIA_PROPS),gt=function(){var t={value:"",label:S.placeholder};if(ft){var n=tt(ft);t={value:"object"===N(n)?S.options.findIndex((function(e){return e===n})):n,label:et(ft)}}var r=O({className:"p-hidden-accessible p-dropdown-hidden-select"},ie("hiddenSelectedMessage")),o=O({ref:$,required:S.required,defaultValue:t.value,name:S.name,tabIndex:-1,"aria-hidden":"true"},ie("select")),l=O({value:t.value},ie("option"));return e.createElement("div",r,e.createElement("select",o,e.createElement("option",l,t.label)))}(),ht=function(){var t=h.isNotEmpty(ft)?et(ft):null;S.editable&&(t=t||S.value||"");var n=O({className:"p-hidden-accessible"},ie("hiddenSelectedMessage")),r=O(Z({ref:Y,id:S.inputId,defaultValue:t,type:"text",readOnly:!0,"aria-haspopup":"listbox",onFocus:me,onBlur:ve,onKeyDown:ge,disabled:S.disabled,tabIndex:S.disabled?-1:S.tabIndex||0},bt),ie("input"));return e.createElement("div",n,e.createElement("input",r))}(),yt=function(){var t=h.isNotEmpty(ft)?et(ft):null;if(S.editable){var n=O(Z({ref:$,type:"text",defaultValue:t||S.value||"",className:ae("input",{label:t}),disabled:S.disabled,placeholder:S.placeholder,maxLength:S.maxLength,onInput:Ve,onFocus:He,onKeyDown:ge,onBlur:ve,tabIndex:S.disabled?-1:S.tabIndex||0,"aria-haspopup":"listbox"},bt),ie("input"));return e.createElement("input",n)}var r=S.valueTemplate?h.getJSXElement(S.valueTemplate,ft,S):t||S.placeholder||"empty",o=O({ref:$,className:ae("input",{label:t}),tabIndex:"-1"},ie("input"));return e.createElement("span",o,r)}(),wt=S.loading?(at=O({className:ae("loadingIcon"),"data-pr-overlay-visible":H},ie("loadingIcon")),ut=w.getJSXIcon(S.loadingIcon||e.createElement(f,{spin:!0}),Z({},at),{props:S}),ct=S.placeholder||S.ariaLabel,pt=O({className:ae("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":H,"aria-label":ct},ie("trigger")),e.createElement("div",pt,ut)):function(){var t=O({className:ae("dropdownIcon"),"data-pr-overlay-visible":H},ie("dropdownIcon")),n=w.getJSXIcon(S.dropdownIcon||e.createElement(d,t),Z({},t),{props:S}),r=S.placeholder||S.ariaLabel,o=O({className:ae("trigger"),role:"button","aria-haspopup":"listbox","aria-expanded":H,"aria-label":r},ie("trigger"));return e.createElement("div",o,n)}(),Et=function(){if(null!=S.value&&S.showClear&&!S.disabled){var t=O({className:ae("clearIcon"),onPointerUp:Je,tabIndex:S.tabIndex||"0",onKeyDown:st,"aria-label":r("clear")},ie("clearIcon"));return w.getJSXIcon(S.clearIcon||e.createElement(m,t),Z({},t),{props:S})}return null}(),It=O({id:S.id,ref:X,className:g(S.className,ae("root",{context:x,focusedState:P,overlayVisibleState:H})),style:S.style,onClick:function(e){return t=e,void(S.disabled||S.loading||(S.onClick&&S.onClick(t),t.defaultPrevented||fe(t)||"INPUT"===t.target.tagName||(q.current&&q.current&&q.current.contains(t.target)||(y.focus(Y.current),H?Ze():We()),J.current=!0)));var t},onMouseDown:S.onMouseDown,onContextMenu:S.onContextMenu,onFocus:function(){S.editable&&!H&&!1===J.current&&y.focus($.current)},"data-p-disabled":S.disabled,"data-p-focus":P},vt,ie("root")),Ot=O({ref:z,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===Y.current?y.getFirstFocusableElement(q.current,':not([data-p-hidden-focusable="true"])'):Y.current;y.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},ie("hiddenFirstFocusableEl")),xt=O({ref:W,role:"presentation","aria-hidden":"true",className:"p-hidden-accessible p-hidden-focusable",tabIndex:"0",onFocus:function(e){var t=e.relatedTarget===Y.current?y.getLastFocusableElement(q.current,':not([data-p-hidden-focusable="true"])'):Y.current;y.focus(t)},"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0},ie("hiddenLastFocusableEl"));return e.createElement(e.Fragment,null,e.createElement("div",It,ht,gt,yt,Et,wt,e.createElement(_,D({hostName:"Dropdown",ref:q,visibleOptions:dt,virtualScrollerRef:Q},S,{appendTo:oe,cx:ae,filterValue:k,focusedOptionIndex:M,getOptionGroupChildren:ot,getOptionGroupLabel:function(e){return h.resolveFieldData(e,S.optionGroupLabel)},getOptionGroupRenderKey:function(e){return h.resolveFieldData(e,S.optionGroupLabel)},getOptionLabel:et,getOptionRenderKey:function(e){return S.dataKey?h.resolveFieldData(e,S.dataKey):et(e)},getSelectedOptionIndex:_e,hasFilter:re,in:H,isOptionDisabled:rt,isSelected:ze,onClick:function(e){v.emit("overlay-click",{originalEvent:e,target:X.current})},onEnter:function(e){E.set("overlay",q.current,x&&x.autoZIndex||t.autoZIndex,x&&x.zIndex.overlay||t.zIndex.overlay),y.addStyles(q.current,{position:"absolute",top:"0",left:"0"}),$e(),e&&e()},onEntered:function(e){e&&e(),pe(),S.onShow&&S.onShow()},onExit:function(){se()},onExited:function(){S.filter&&S.resetFilterOnHide&&Be(),E.clear(q.current),S.onHide&&S.onHide()},onFilterClearIconClick:function(e){Be(e)},onFilterInputChange:function(e){var t=e.target.value;C(t),S.onFilter&&S.onFilter({originalEvent:e,filter:t})},onFilterInputKeyDown:function(e){switch(e.code){case"ArrowDown":Ce(e);break;case"ArrowUp":De(e);break;case"ArrowLeft":case"ArrowRight":Ne(e,!0);break;case"Escape":case"Enter":case"NumpadEnter":Me(e),e.preventDefault()}},onOptionClick:function(e){e.option.disabled||(Xe(e),y.focus(Y.current)),Ze()},ptm:ie,resetFilter:Be,changeFocusedOptionIndex:ke,firstFocusableElement:e.createElement("span",Ot),lastFocusableElement:e.createElement("span",xt),sx:ue}))),mt&&e.createElement(b,D({target:X,content:S.tooltip,pt:ie("tooltip")},S.tooltipOptions)))})));$.displayName="Dropdown";export{$ as Dropdown};
|