primevue
Version:
PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc
2 lines (1 loc) • 32 kB
JavaScript
import{FilterService as e}from"primevue/api";import t from"primevue/icons/chevrondown";import i from"primevue/icons/filter";import n from"primevue/icons/spinner";import o from"primevue/icons/times";import s from"primevue/overlayeventbus";import r from"primevue/portal";import l from"primevue/ripple";import{UniqueComponentId as a,ZIndexUtils as c,ObjectUtils as u,DomHandler as d,ConnectedOverlayScrollHandler as p}from"primevue/utils";import h from"primevue/virtualscroller";import f from"primevue/basecomponent";import b from"primevue/dropdown/style";import{resolveComponent as y,resolveDirective as v,openBlock as O,createElementBlock as m,mergeProps as g,renderSlot as I,createTextVNode as x,toDisplayString as S,normalizeClass as w,createBlock as L,resolveDynamicComponent as F,createCommentVNode as k,createElementVNode as V,createVNode as C,withCtx as D,Transition as M,createSlots as E,Fragment as K,renderList as P,withDirectives as T}from"vue";function $(e){return $="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},$(e)}function A(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function j(e,t){if(e){if("string"==typeof e)return B(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?B(e,t):void 0}}function H(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function G(e){if(Array.isArray(e))return B(e)}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function R(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function z(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?R(Object(i),!0).forEach((function(t){U(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):R(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function U(e,t,i){var n;return(t="symbol"==$(n=N(t,"string"))?n:String(n))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function N(e,t){if("object"!=$(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var _={name:"Dropdown",extends:{name:"BaseDropdown",extends:f,props:{modelValue:null,options:Array,optionLabel:[String,Function],optionValue:[String,Function],optionDisabled:[String,Function],optionGroupLabel:[String,Function],optionGroupChildren:[String,Function],scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:{type:String,default:null},disabled:{type:Boolean,default:!1},dataKey:null,showClear:{type:Boolean,default:!1},inputId:{type:String,default:null},inputClass:{type:[String,Object],default:null},inputStyle:{type:Object,default:null},inputProps:{type:null,default:null},panelClass:{type:[String,Object],default:null},panelStyle:{type:Object,default:null},panelProps:{type:null,default:null},filterInputProps:{type:null,default:null},clearIconProps:{type:null,default:null},appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},clearIcon:{type:String,default:void 0},dropdownIcon:{type:String,default:void 0},filterIcon:{type:String,default:void 0},loadingIcon:{type:String,default:void 0},resetFilterOnHide:{type:Boolean,default:!1},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},autoFilterFocus:{type:Boolean,default:!1},selectOnFocus:{type:Boolean,default:!1},filterMessage:{type:String,default:null},selectionMessage:{type:String,default:null},emptySelectionMessage:{type:String,default:null},emptyFilterMessage:{type:String,default:null},emptyMessage:{type:String,default:null},tabindex:{type:Number,default:0},ariaLabel:{type:String,default:null},ariaLabelledby:{type:String,default:null}},style:b,provide:function(){return{$parentInstance:this}}},emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],outsideClickListener:null,scrollHandler:null,resizeListener:null,labelClickListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,focusOnHover:!1,data:function(){return{id:this.$attrs.id,focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}},watch:{"$attrs.id":function(e){this.id=e||a()},modelValue:function(){this.isModelValueChanged=!0},options:function(){this.autoUpdateModel()}},mounted:function(){this.id=this.id||a(),this.autoUpdateModel(),this.bindLabelClickListener()},updated:function(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount:function(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.unbindLabelClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(c.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex:function(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel:function(e){return this.optionLabel?u.resolveFieldData(e,this.optionLabel):e},getOptionValue:function(e){return this.optionValue?u.resolveFieldData(e,this.optionValue):e},getOptionRenderKey:function(e,t){return(this.dataKey?u.resolveFieldData(e,this.dataKey):this.getOptionLabel(e))+"_"+t},getPTItemOptions:function(e,t,i,n){return this.ptm(n,{context:{selected:this.isSelected(e),focused:this.focusedOptionIndex===this.getOptionIndex(i,t),disabled:this.isOptionDisabled(e)}})},isOptionDisabled:function(e){return!!this.optionDisabled&&u.resolveFieldData(e,this.optionDisabled)},isOptionGroup:function(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel:function(e){return u.resolveFieldData(e,this.optionGroupLabel)},getOptionGroupChildren:function(e){return u.resolveFieldData(e,this.optionGroupChildren)},getAriaPosInset:function(e){var t=this;return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((function(e){return t.isOptionGroup(e)})).length:e)+1},show:function(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&d.focus(this.$refs.focusInput)},hide:function(e){var t=this;setTimeout((function(){t.$emit("before-hide"),t.overlayVisible=!1,t.focusedOptionIndex=-1,t.searchValue="",t.resetFilterOnHide&&(t.filterValue=null),e&&d.focus(t.$refs.focusInput)}),0)},onFocus:function(e){this.disabled||(this.focused=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e))},onBlur:function(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown:function(e){if(this.disabled||d.isAndroid())e.preventDefault();else{var t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e,this.editable);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(e,this.editable);break;case"Delete":this.onDeleteKey(e);case"Home":this.onHomeKey(e,this.editable);break;case"End":this.onEndKey(e,this.editable);break;case"PageDown":this.onPageDownKey(e);break;case"PageUp":this.onPageUpKey(e);break;case"Space":this.onSpaceKey(e,this.editable);break;case"Enter":case"NumpadEnter":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e);break;case"Backspace":this.onBackspaceKey(e,this.editable);break;case"ShiftLeft":case"ShiftRight":break;default:!t&&u.isPrintableCharacter(e.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(e,e.key))}}},onEditableInput:function(e){var t=e.target.value;this.searchValue="",!this.searchOptions(e,t)&&(this.focusedOptionIndex=-1),this.updateModel(e,t),!this.overlayVisible&&u.isNotEmpty(t)&&this.show()},onContainerClick:function(e){this.disabled||this.loading||"INPUT"===e.target.tagName||"clearicon"===e.target.getAttribute("data-pc-section")||e.target.closest('[data-pc-section="clearicon"]')||this.overlay&&this.overlay.contains(e.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick:function(e){this.updateModel(e,null)},onFirstHiddenFocus:function(e){var t=e.relatedTarget===this.$refs.focusInput?d.getFirstFocusableElement(this.overlay,':not([data-p-hidden-focusable="true"])'):this.$refs.focusInput;d.focus(t)},onLastHiddenFocus:function(e){var t=e.relatedTarget===this.$refs.focusInput?d.getLastFocusableElement(this.overlay,':not([data-p-hidden-focusable="true"])'):this.$refs.focusInput;d.focus(t)},onOptionSelect:function(e,t){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.getOptionValue(t);this.updateModel(e,n),i&&this.hide(!0)},onOptionMouseMove:function(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onFilterChange:function(e){var t=e.target.value;this.filterValue=t,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:t}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown:function(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e,!0);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(e,!0);break;case"Home":this.onHomeKey(e,!0);break;case"End":this.onEndKey(e,!0);break;case"Enter":case"NumpadEnter":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur:function(){this.focusedOptionIndex=-1},onFilterUpdated:function(){this.overlayVisible&&this.alignOverlay()},onOverlayClick:function(e){s.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown:function(e){if("Escape"===e.code)this.onEscapeKey(e)},onDeleteKey:function(e){this.showClear&&(this.updateModel(e,null),e.preventDefault())},onArrowDownKey:function(e){var t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey:function(e){if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{var t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&(this.focusedOptionIndex=-1)},onHomeKey:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var t=e.currentTarget,i=t.value.length;t.setSelectionRange(i,i),this.focusedOptionIndex=-1}else this.changeFocusedOptionIndex(e,this.findLastOptionIndex()),!this.overlayVisible&&this.show();e.preventDefault()},onPageUpKey:function(e){this.scrollInView(0),e.preventDefault()},onPageDownKey:function(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey:function(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey:function(e){!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])&&this.onEnterKey(e)},onEscapeKey:function(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(this.overlayVisible&&this.hasFocusableElements()?(d.focus(this.$refs.firstHiddenFocusableElementOnOverlay),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&!this.overlayVisible&&this.show()},onOverlayEnter:function(e){c.set("overlay",e,this.$primevue.config.zIndex.overlay),d.addStyles(e,{position:"absolute",top:"0",left:"0"}),this.alignOverlay(),this.scrollInView(),this.autoFilterFocus&&d.focus(this.$refs.filterInput)},onOverlayAfterEnter:function(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave:function(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave:function(e){c.clear(e)},alignOverlay:function(){"self"===this.appendTo?d.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=d.getOuterWidth(this.$el)+"px",d.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener:function(){var e=this;this.outsideClickListener||(this.outsideClickListener=function(t){e.overlayVisible&&e.overlay&&!e.$el.contains(t.target)&&!e.overlay.contains(t.target)&&e.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener:function(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener:function(){var e=this;this.scrollHandler||(this.scrollHandler=new p(this.$refs.container,(function(){e.overlayVisible&&e.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.overlayVisible&&!d.isTouchDevice()&&e.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},bindLabelClickListener:function(){var e=this;if(!this.editable&&!this.labelClickListener){var t=document.querySelector('label[for="'.concat(this.inputId,'"]'));t&&d.isVisible(t)&&(this.labelClickListener=function(){d.focus(e.$refs.focusInput)},t.addEventListener("click",this.labelClickListener))}},unbindLabelClickListener:function(){if(this.labelClickListener){var e=document.querySelector('label[for="'.concat(this.inputId,'"]'));e&&d.isVisible(e)&&e.removeEventListener("click",this.labelClickListener)}},hasFocusableElements:function(){return d.getFocusableElements(this.overlay,':not([data-p-hidden-focusable="true"])').length>0},isOptionMatched:function(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption:function(e){return u.isNotEmpty(e)&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption:function(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected:function(e){return this.isValidOption(e)&&u.equals(this.modelValue,this.getOptionValue(e),this.equalityKey)},findFirstOptionIndex:function(){var e=this;return this.visibleOptions.findIndex((function(t){return e.isValidOption(t)}))},findLastOptionIndex:function(){var e=this;return u.findLastIndex(this.visibleOptions,(function(t){return e.isValidOption(t)}))},findNextOptionIndex:function(e){var t=this,i=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((function(e){return t.isValidOption(e)})):-1;return i>-1?i+e+1:e},findPrevOptionIndex:function(e){var t=this,i=e>0?u.findLastIndex(this.visibleOptions.slice(0,e),(function(e){return t.isValidOption(e)})):-1;return i>-1?i:e},findSelectedOptionIndex:function(){var e=this;return this.hasSelectedOption?this.visibleOptions.findIndex((function(t){return e.isValidSelectedOption(t)})):-1},findFirstFocusedOptionIndex:function(){var e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex:function(){var e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions:function(e,t){var i=this;this.searchValue=(this.searchValue||"")+t;var n=-1,o=!1;return-1!==(n=-1!==this.focusedOptionIndex?-1===(n=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((function(e){return i.isOptionMatched(e)})))?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((function(e){return i.isOptionMatched(e)})):n+this.focusedOptionIndex:this.visibleOptions.findIndex((function(e){return i.isOptionMatched(e)})))&&(o=!0),-1===n&&-1===this.focusedOptionIndex&&(n=this.findFirstFocusedOptionIndex()),-1!==n&&this.changeFocusedOptionIndex(e,n),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((function(){i.searchValue="",i.searchTimeout=null}),500),o},changeFocusedOptionIndex:function(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView(),this.selectOnFocus&&this.onOptionSelect(e,this.visibleOptions[t],!1))},scrollInView:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,i=-1!==t?"".concat(this.id,"_").concat(t):this.focusedOptionId,n=d.findSingle(this.list,'li[id="'.concat(i,'"]'));n?n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((function(){e.virtualScroller&&e.virtualScroller.scrollToIndex(-1!==t?t:e.focusedOptionIndex)}),0)},autoUpdateModel:function(){this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption&&(this.focusedOptionIndex=this.findFirstFocusedOptionIndex(),this.onOptionSelect(null,this.visibleOptions[this.focusedOptionIndex],!1))},updateModel:function(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions:function(e){var t=this;return(e||[]).reduce((function(e,i,n){e.push({optionGroup:i,group:!0,index:n});var o=t.getOptionGroupChildren(i);return o&&o.forEach((function(t){return e.push(t)})),e}),[])},overlayRef:function(e){this.overlay=e},listRef:function(e,t){this.list=e,t&&t(e)},virtualScrollerRef:function(e){this.virtualScroller=e}},computed:{visibleOptions:function(){var t=this,i=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];if(this.filterValue){var n=e.filter(i,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale);if(this.optionGroupLabel){var o=[];return(this.options||[]).forEach((function(e){var i,s=t.getOptionGroupChildren(e).filter((function(e){return n.includes(e)}));s.length>0&&o.push(z(z({},e),{},U({},"string"==typeof t.optionGroupChildren?t.optionGroupChildren:"items",G(i=s)||H(i)||j(i)||A())))})),this.flatOptions(o)}return n}return i},hasSelectedOption:function(){return u.isNotEmpty(this.modelValue)},label:function(){var e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue:function(){var e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey:function(){return this.optionValue?null:this.dataKey},searchFields:function(){return this.filterFields||[this.optionLabel]},filterResultMessageText:function(){return u.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText:function(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText:function(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText:function(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText:function(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText:function(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText:function(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId:function(){return-1!==this.focusedOptionIndex?"".concat(this.id,"_").concat(this.focusedOptionIndex):null},ariaSetSize:function(){var e=this;return this.visibleOptions.filter((function(t){return!e.isOptionGroup(t)})).length},virtualScrollerDisabled:function(){return!this.virtualScrollerOptions}},directives:{ripple:l},components:{VirtualScroller:h,Portal:r,TimesIcon:o,ChevronDownIcon:t,SpinnerIcon:n,FilterIcon:i}};function q(e){return q="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},q(e)}function W(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function J(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?W(Object(i),!0).forEach((function(t){Q(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):W(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Q(e,t,i){var n;return(t="symbol"==q(n=X(t,"string"))?n:String(n))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function X(e,t){if("object"!=q(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var Y=["id"],Z=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],ee=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],te=["value","placeholder","aria-owns","aria-activedescendant"],ie=["id"],ne=["id"],oe=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove","data-p-highlight","data-p-focused","data-p-disabled"];_.render=function(e,t,i,n,o,s){var r=y("SpinnerIcon"),l=y("VirtualScroller"),a=y("Portal"),c=v("ripple");return O(),m("div",g({ref:"container",id:o.id,class:e.cx("root"),onClick:t[15]||(t[15]=function(){return s.onContainerClick&&s.onContainerClick.apply(s,arguments)})},e.ptm("root"),{"data-pc-name":"dropdown"}),[e.editable?(O(),m("input",g({key:0,ref:"focusInput",id:e.inputId,type:"text",class:[e.cx("input"),e.inputClass],style:e.inputStyle,value:s.editableInputValue,placeholder:e.placeholder,tabindex:e.disabled?-1:e.tabindex,disabled:e.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":o.overlayVisible,"aria-controls":o.id+"_list","aria-activedescendant":o.focused?s.focusedOptionId:void 0,onFocus:t[0]||(t[0]=function(){return s.onFocus&&s.onFocus.apply(s,arguments)}),onBlur:t[1]||(t[1]=function(){return s.onBlur&&s.onBlur.apply(s,arguments)}),onKeydown:t[2]||(t[2]=function(){return s.onKeyDown&&s.onKeyDown.apply(s,arguments)}),onInput:t[3]||(t[3]=function(){return s.onEditableInput&&s.onEditableInput.apply(s,arguments)})},J(J({},e.inputProps),e.ptm("input"))),null,16,Z)):(O(),m("span",g({key:1,ref:"focusInput",id:e.inputId,class:[e.cx("input"),e.inputClass],style:e.inputStyle,tabindex:e.disabled?-1:e.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===s.label?void 0:s.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":o.overlayVisible,"aria-controls":o.id+"_list","aria-activedescendant":o.focused?s.focusedOptionId:void 0,"aria-disabled":e.disabled,onFocus:t[4]||(t[4]=function(){return s.onFocus&&s.onFocus.apply(s,arguments)}),onBlur:t[5]||(t[5]=function(){return s.onBlur&&s.onBlur.apply(s,arguments)}),onKeydown:t[6]||(t[6]=function(){return s.onKeyDown&&s.onKeyDown.apply(s,arguments)})},J(J({},e.inputProps),e.ptm("input"))),[I(e.$slots,"value",{value:e.modelValue,placeholder:e.placeholder},(function(){return[x(S("p-emptylabel"===s.label?" ":s.label||"empty"),1)]}))],16,ee)),e.showClear&&null!=e.modelValue?I(e.$slots,"clearicon",{key:2,class:w(e.cx("clearIcon")),onClick:s.onClearClick,clearCallback:s.onClearClick},(function(){return[(O(),L(F(e.clearIcon?"i":"TimesIcon"),g({ref:"clearIcon",class:[e.cx("clearIcon"),e.clearIcon],onClick:s.onClearClick},J(J({},e.clearIconProps),e.ptm("clearIcon")),{"data-pc-section":"clearicon"}),null,16,["class","onClick"]))]})):k("",!0),V("div",g({class:e.cx("trigger")},e.ptm("trigger")),[e.loading?I(e.$slots,"loadingicon",{key:0,class:w(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(O(),m("span",g({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon],"aria-hidden":"true"},e.ptm("loadingIcon")),null,16)):(O(),L(r,g({key:1,class:e.cx("loadingIcon"),spin:"","aria-hidden":"true"},e.ptm("loadingIcon")),null,16,["class"]))]})):I(e.$slots,"dropdownicon",{key:1,class:w(e.cx("dropdownIcon"))},(function(){return[(O(),L(F(e.dropdownIcon?"span":"ChevronDownIcon"),g({class:[e.cx("dropdownIcon"),e.dropdownIcon],"aria-hidden":"true"},e.ptm("dropdownIcon")),null,16,["class"]))]}))],16),C(a,{appendTo:e.appendTo},{default:D((function(){return[C(M,g({name:"p-connected-overlay",onEnter:s.onOverlayEnter,onAfterEnter:s.onOverlayAfterEnter,onLeave:s.onOverlayLeave,onAfterLeave:s.onOverlayAfterLeave},e.ptm("transition")),{default:D((function(){return[o.overlayVisible?(O(),m("div",g({key:0,ref:s.overlayRef,class:[e.cx("panel"),e.panelClass],style:e.panelStyle,onClick:t[13]||(t[13]=function(){return s.onOverlayClick&&s.onOverlayClick.apply(s,arguments)}),onKeydown:t[14]||(t[14]=function(){return s.onOverlayKeyDown&&s.onOverlayKeyDown.apply(s,arguments)})},J(J({},e.panelProps),e.ptm("panel"))),[V("span",g({ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[7]||(t[7]=function(){return s.onFirstHiddenFocus&&s.onFirstHiddenFocus.apply(s,arguments)})},e.ptm("hiddenFirstFocusableEl"),{"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0}),null,16),I(e.$slots,"header",{value:e.modelValue,options:s.visibleOptions}),e.filter?(O(),m("div",g({key:0,class:e.cx("header")},e.ptm("header")),[V("div",g({class:e.cx("filterContainer")},e.ptm("filterContainer")),[V("input",g({ref:"filterInput",type:"text",value:o.filterValue,onVnodeMounted:t[8]||(t[8]=function(){return s.onFilterUpdated&&s.onFilterUpdated.apply(s,arguments)}),class:e.cx("filterInput"),placeholder:e.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":o.id+"_list","aria-activedescendant":s.focusedOptionId,onKeydown:t[9]||(t[9]=function(){return s.onFilterKeyDown&&s.onFilterKeyDown.apply(s,arguments)}),onBlur:t[10]||(t[10]=function(){return s.onFilterBlur&&s.onFilterBlur.apply(s,arguments)}),onInput:t[11]||(t[11]=function(){return s.onFilterChange&&s.onFilterChange.apply(s,arguments)})},J(J({},e.filterInputProps),e.ptm("filterInput"))),null,16,te),I(e.$slots,"filtericon",{class:w(e.cx("filterIcon"))},(function(){return[(O(),L(F(e.filterIcon?"span":"FilterIcon"),g({class:[e.cx("filterIcon"),e.filterIcon]},e.ptm("filterIcon")),null,16,["class"]))]}))],16),V("span",g({role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenFilterResult"),{"data-p-hidden-accessible":!0}),S(s.filterResultMessageText),17)],16)):k("",!0),V("div",g({class:e.cx("wrapper"),style:{"max-height":s.virtualScrollerDisabled?e.scrollHeight:""}},e.ptm("wrapper")),[C(l,g({ref:s.virtualScrollerRef},e.virtualScrollerOptions,{items:s.visibleOptions,style:{height:e.scrollHeight},tabindex:-1,disabled:s.virtualScrollerDisabled,pt:e.ptm("virtualScroller")}),E({content:D((function(t){var i=t.styleClass,n=t.contentRef,r=t.items,l=t.getItemOptions,a=t.contentStyle,u=t.itemSize;return[V("ul",g({ref:function(e){return s.listRef(e,n)},id:o.id+"_list",class:[e.cx("list"),i],style:a,role:"listbox"},e.ptm("list")),[(O(!0),m(K,null,P(r,(function(t,i){return O(),m(K,{key:s.getOptionRenderKey(t,s.getOptionIndex(i,l))},[s.isOptionGroup(t)?(O(),m("li",g({key:0,id:o.id+"_"+s.getOptionIndex(i,l),style:{height:u?u+"px":void 0},class:e.cx("itemGroup"),role:"option"},e.ptm("itemGroup")),[I(e.$slots,"optiongroup",{option:t.optionGroup,index:s.getOptionIndex(i,l)},(function(){return[x(S(s.getOptionGroupLabel(t.optionGroup)),1)]}))],16,ne)):T((O(),m("li",g({key:1,id:o.id+"_"+s.getOptionIndex(i,l),class:e.cx("item",{option:t,focusedOption:s.getOptionIndex(i,l)}),style:{height:u?u+"px":void 0},role:"option","aria-label":s.getOptionLabel(t),"aria-selected":s.isSelected(t),"aria-disabled":s.isOptionDisabled(t),"aria-setsize":s.ariaSetSize,"aria-posinset":s.getAriaPosInset(s.getOptionIndex(i,l)),onClick:function(e){return s.onOptionSelect(e,t)},onMousemove:function(e){return s.onOptionMouseMove(e,s.getOptionIndex(i,l))},"data-p-highlight":s.isSelected(t),"data-p-focused":o.focusedOptionIndex===s.getOptionIndex(i,l),"data-p-disabled":s.isOptionDisabled(t)},s.getPTItemOptions(t,l,i,"item")),[I(e.$slots,"option",{option:t,index:s.getOptionIndex(i,l)},(function(){return[x(S(s.getOptionLabel(t)),1)]}))],16,oe)),[[c]])],64)})),128)),o.filterValue&&(!r||r&&0===r.length)?(O(),m("li",g({key:0,class:e.cx("emptyMessage"),role:"option"},e.ptm("emptyMessage"),{"data-p-hidden-accessible":!0}),[I(e.$slots,"emptyfilter",{},(function(){return[x(S(s.emptyFilterMessageText),1)]}))],16)):!e.options||e.options&&0===e.options.length?(O(),m("li",g({key:1,class:e.cx("emptyMessage"),role:"option"},e.ptm("emptyMessage"),{"data-p-hidden-accessible":!0}),[I(e.$slots,"empty",{},(function(){return[x(S(s.emptyMessageText),1)]}))],16)):k("",!0)],16,ie)]})),_:2},[e.$slots.loader?{name:"loader",fn:D((function(t){return[I(e.$slots,"loader",{options:t.options})]})),key:"0"}:void 0]),1040,["items","style","disabled","pt"])],16),I(e.$slots,"footer",{value:e.modelValue,options:s.visibleOptions}),!e.options||e.options&&0===e.options.length?(O(),m("span",g({key:1,role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenEmptyMessage"),{"data-p-hidden-accessible":!0}),S(s.emptyMessageText),17)):k("",!0),V("span",g({role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenSelectedMessage"),{"data-p-hidden-accessible":!0}),S(s.selectedMessageText),17),V("span",g({ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[12]||(t[12]=function(){return s.onLastHiddenFocus&&s.onLastHiddenFocus.apply(s,arguments)})},e.ptm("hiddenLastFocusableEl"),{"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0}),null,16)],16)):k("",!0)]})),_:3},16,["onEnter","onAfterEnter","onLeave","onAfterLeave"])]})),_:3},8,["appendTo"])],16,Y)};export{_ as default};