primevue 3.16.1 → 3.16.2
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/autocomplete/AutoComplete.d.ts +2 -2
- package/autocomplete/AutoComplete.vue +2 -2
- package/autocomplete/autocomplete.cjs.js +2 -2
- package/autocomplete/autocomplete.cjs.min.js +1 -1
- package/autocomplete/autocomplete.esm.js +2 -2
- package/autocomplete/autocomplete.esm.min.js +1 -1
- package/autocomplete/autocomplete.js +2 -2
- package/autocomplete/autocomplete.min.js +1 -1
- package/calendar/Calendar.vue +2 -2
- package/calendar/calendar.cjs.js +2 -2
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +2 -2
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +2 -2
- package/calendar/calendar.min.js +1 -1
- package/cascadeselect/CascadeSelect.vue +2 -2
- package/cascadeselect/cascadeselect.cjs.js +2 -2
- package/cascadeselect/cascadeselect.cjs.min.js +1 -1
- package/cascadeselect/cascadeselect.esm.js +2 -2
- package/cascadeselect/cascadeselect.esm.min.js +1 -1
- package/cascadeselect/cascadeselect.js +2 -2
- package/cascadeselect/cascadeselect.min.js +1 -1
- package/core/core.js +31 -9
- package/core/core.min.js +4 -4
- package/datatable/DataTable.vue +2 -2
- package/datatable/datatable.cjs.js +2 -2
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +2 -2
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +2 -2
- package/datatable/datatable.min.js +1 -1
- package/dropdown/Dropdown.vue +2 -2
- package/dropdown/dropdown.cjs.js +2 -2
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +2 -2
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +2 -2
- package/dropdown/dropdown.min.js +1 -1
- package/inputnumber/InputNumber.d.ts +1 -1
- package/inputnumber/InputNumber.vue +1 -1
- package/inputnumber/inputnumber.cjs.js +2 -1
- package/inputnumber/inputnumber.cjs.min.js +1 -1
- package/inputnumber/inputnumber.esm.js +2 -1
- package/inputnumber/inputnumber.esm.min.js +1 -1
- package/inputnumber/inputnumber.js +2 -1
- package/inputnumber/inputnumber.min.js +1 -1
- package/listbox/Listbox.vue +4 -4
- package/listbox/listbox.cjs.js +4 -4
- package/listbox/listbox.cjs.min.js +1 -1
- package/listbox/listbox.esm.js +4 -4
- package/listbox/listbox.esm.min.js +1 -1
- package/listbox/listbox.js +4 -4
- package/listbox/listbox.min.js +1 -1
- package/multiselect/MultiSelect.vue +4 -4
- package/multiselect/multiselect.cjs.js +4 -4
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +4 -4
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +4 -4
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/OverlayPanel.vue +1 -1
- package/overlaypanel/overlaypanel.cjs.js +1 -1
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +1 -1
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +1 -1
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +1 -1
- package/resources/primevue.css +0 -0
- package/resources/primevue.min.css +0 -0
- package/tooltip/tooltip.cjs.js +8 -6
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +9 -7
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +8 -6
- package/tooltip/tooltip.min.js +1 -1
- package/utils/utils.cjs.js +19 -0
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +19 -0
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +19 -0
- package/utils/utils.min.js +1 -1
- package/web-types.json +1 -1
package/dropdown/Dropdown.vue
CHANGED
|
@@ -678,14 +678,14 @@ export default {
|
|
|
678
678
|
return this.visibleOptions.findIndex(option => this.isValidOption(option));
|
|
679
679
|
},
|
|
680
680
|
findLastOptionIndex() {
|
|
681
|
-
return this.visibleOptions
|
|
681
|
+
return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option));
|
|
682
682
|
},
|
|
683
683
|
findNextOptionIndex(index) {
|
|
684
684
|
const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1;
|
|
685
685
|
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
686
686
|
},
|
|
687
687
|
findPrevOptionIndex(index) {
|
|
688
|
-
const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index)
|
|
688
|
+
const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1;
|
|
689
689
|
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
690
690
|
},
|
|
691
691
|
findSelectedOptionIndex() {
|
package/dropdown/dropdown.cjs.js
CHANGED
|
@@ -607,14 +607,14 @@ var script = {
|
|
|
607
607
|
return this.visibleOptions.findIndex(option => this.isValidOption(option));
|
|
608
608
|
},
|
|
609
609
|
findLastOptionIndex() {
|
|
610
|
-
return
|
|
610
|
+
return utils.ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option));
|
|
611
611
|
},
|
|
612
612
|
findNextOptionIndex(index) {
|
|
613
613
|
const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1;
|
|
614
614
|
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
615
615
|
},
|
|
616
616
|
findPrevOptionIndex(index) {
|
|
617
|
-
const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index)
|
|
617
|
+
const matchedOptionIndex = index > 0 ? utils.ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1;
|
|
618
618
|
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
619
619
|
},
|
|
620
620
|
findSelectedOptionIndex() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/utils"),t=require("primevue/overlayeventbus"),i=require("primevue/api"),n=require("primevue/ripple"),s=require("primevue/virtualscroller"),o=require("primevue/portal"),l=require("vue");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(t),d=r(n),p=r(s),c=r(o),h={name:"Dropdown",emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:String,disabled:Boolean,dataKey:null,showClear:Boolean,inputId:String,inputStyle:null,inputClass:null,inputProps:null,panelStyle:null,panelClass:null,panelProps:null,filterInputProps:null,clearIconProps:null,appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:"pi pi-spinner pi-spin"},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},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},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,selectOnFocus:!1,focusOnHover:!1,data:()=>({id:e.UniqueComponentId(),focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}),watch:{modelValue(){this.isModelValueChanged=!0},options(){this.autoUpdateModel()}},mounted(){this.id=this.$attrs.id||this.id,this.autoUpdateModel()},updated(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(e.ZIndexUtils.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel(t){return this.optionLabel?e.ObjectUtils.resolveFieldData(t,this.optionLabel):t},getOptionValue(t){return this.optionValue?e.ObjectUtils.resolveFieldData(t,this.optionValue):t},getOptionRenderKey(t,i){return(this.dataKey?e.ObjectUtils.resolveFieldData(t,this.dataKey):this.getOptionLabel(t))+"_"+i},isOptionDisabled(t){return!!this.optionDisabled&&e.ObjectUtils.resolveFieldData(t,this.optionDisabled)},isOptionGroup(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupLabel)},getOptionGroupChildren(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupChildren)},getAriaPosInset(e){return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((e=>this.isOptionGroup(e))).length:e)+1},show(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&this.$refs.focusInput.focus()},hide(e){const t=()=>{this.$emit("before-hide"),this.overlayVisible=!1,this.focusedOptionIndex=-1,this.searchValue="",e&&this.$refs.focusInput.focus()};setTimeout((()=>{t()}),0)},onFocus(e){this.focused=!0,this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown(t){switch(t.code){case"ArrowDown":this.onArrowDownKey(t);break;case"ArrowUp":this.onArrowUpKey(t,this.editable);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(t,this.editable);break;case"Home":this.onHomeKey(t,this.editable);break;case"End":this.onEndKey(t,this.editable);break;case"PageDown":this.onPageDownKey(t);break;case"PageUp":this.onPageUpKey(t);break;case"Space":this.onSpaceKey(t,this.editable);break;case"Enter":this.onEnterKey(t);break;case"Escape":this.onEscapeKey(t);break;case"Tab":this.onTabKey(t);break;case"Backspace":this.onBackspaceKey(t,this.editable);break;case"ShiftLeft":case"ShiftRight":break;default:e.ObjectUtils.isPrintableCharacter(t.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(t,t.key))}},onEditableInput(e){const t=e.target.value;this.searchValue="";!this.searchOptions(e,t)&&(this.focusedOptionIndex=-1),this.$emit("update:modelValue",t)},onContainerClick(t){this.disabled||this.loading||e.DomHandler.hasClass(t.target,"p-dropdown-clear-icon")||"INPUT"===t.target.tagName||this.overlay&&this.overlay.contains(t.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick(e){this.updateModel(e,null)},onFirstHiddenFocus(t){if(t.relatedTarget===this.$refs.focusInput){const t=e.DomHandler.getFirstFocusableElement(this.overlay,":not(.p-hidden-focusable)");t&&t.focus()}else this.$refs.focusInput.focus()},onLastHiddenFocus(){this.$refs.firstHiddenFocusableElementOnOverlay.focus()},onOptionSelect(e,t){const i=this.getOptionValue(t);this.updateModel(e,i),this.hide(!0)},onOptionMouseMove(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onFilterChange(e){const t=e.target.value;this.filterValue=t,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:t}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur(){this.focusedOptionIndex=-1},onFilterUpdated(){this.overlayVisible&&this.alignOverlay()},onOverlayClick(e){a.default.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey(e){const t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey(e,t=!1){if(e.altKey&&!t)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{const t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey(e,t=!1){t&&(this.focusedOptionIndex=-1)},onHomeKey(e,t=!1){t?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey(e,t=!1){if(t){const 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(e){this.scrollInView(0),e.preventDefault()},onPageDownKey(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey(e,t=!1){!t&&this.onEnterKey(e)},onEscapeKey(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey(e,t=!1){t||(this.overlayVisible&&this.hasFocusableElements()?(this.$refs.firstHiddenFocusableElementOnOverlay.focus(),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey(e,t=!1){t&&!this.overlayVisible&&this.show()},onOverlayEnter(t){e.ZIndexUtils.set("overlay",t,this.$primevue.config.zIndex.overlay),this.alignOverlay(),this.scrollInView()},onOverlayAfterEnter(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave(t){e.ZIndexUtils.clear(t)},alignOverlay(){"self"===this.appendTo?e.DomHandler.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=e.DomHandler.getOuterWidth(this.$el)+"px",e.DomHandler.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.overlay&&!this.$el.contains(e.target)&&!this.overlay.contains(e.target)&&this.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new e.ConnectedOverlayScrollHandler(this.$refs.container,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!e.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},hasFocusableElements(){return e.DomHandler.getFocusableElements(this.overlay,":not(.p-hidden-focusable)").length>0},isOptionMatched(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption(e){return e&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected(t){return e.ObjectUtils.equals(this.modelValue,this.getOptionValue(t),this.equalityKey)},findFirstOptionIndex(){return this.visibleOptions.findIndex((e=>this.isValidOption(e)))},findLastOptionIndex(){return this.visibleOptions.findLastIndex((e=>this.isValidOption(e)))},findNextOptionIndex(e){const t=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((e=>this.isValidOption(e))):-1;return t>-1?t+e+1:e},findPrevOptionIndex(e){const t=e>0?this.visibleOptions.slice(0,e).findLastIndex((e=>this.isValidOption(e))):-1;return t>-1?t:e},findSelectedOptionIndex(){return this.hasSelectedOption?this.visibleOptions.findIndex((e=>this.isValidSelectedOption(e))):-1},findFirstFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,n=!1;return-1!==this.focusedOptionIndex?(i=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))),i=-1===i?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))):i+this.focusedOptionIndex):i=this.visibleOptions.findIndex((e=>this.isOptionMatched(e))),-1!==i&&(n=!0),-1===i&&-1===this.focusedOptionIndex&&(i=this.findFirstFocusedOptionIndex()),-1!==i&&this.changeFocusedOptionIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),n},changeFocusedOptionIndex(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView(),this.selectOnFocus&&this.updateModel(e,this.getOptionValue(this.visibleOptions[t])))},scrollInView(t=-1){const i=-1!==t?`${this.id}_${t}`:this.focusedOptionId,n=e.DomHandler.findSingle(this.list,`li[id="${i}"]`);n?n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((()=>{this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==t?t:this.focusedOptionIndex)}),0)},autoUpdateModel(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();const e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,e)}},updateModel(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions(e){return(e||[]).reduce(((e,t,i)=>{e.push({optionGroup:t,group:!0,index:i});const n=this.getOptionGroupChildren(t);return n&&n.forEach((t=>e.push(t))),e}),[])},overlayRef(e){this.overlay=e},listRef(e,t){this.list=e,t&&t(e)},virtualScrollerRef(e){this.virtualScroller=e}},computed:{containerClass(){return["p-dropdown p-component p-inputwrapper",{"p-disabled":this.disabled,"p-dropdown-clearable":this.showClear&&!this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue,"p-inputwrapper-focus":this.focused||this.overlayVisible,"p-overlay-open":this.overlayVisible}]},inputStyleClass(){return["p-dropdown-label p-inputtext",this.inputClass,{"p-placeholder":!this.editable&&this.label===this.placeholder,"p-dropdown-label-empty":!(this.editable||this.$slots.value||"p-emptylabel"!==this.label&&0!==this.label.length)}]},panelStyleClass(){return["p-dropdown-panel p-component",this.panelClass,{"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},dropdownIconClass(){return["p-dropdown-trigger-icon",this.loading?this.loadingIcon:"pi pi-chevron-down"]},visibleOptions(){const e=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];return this.filterValue?i.FilterService.filter(e,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale):e},hasSelectedOption(){return e.ObjectUtils.isNotEmpty(this.modelValue)},label(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey(){return this.optionValue?null:this.dataKey},searchFields(){return this.filterFields||[this.optionLabel]},filterResultMessageText(){return e.ObjectUtils.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId(){return-1!==this.focusedOptionIndex?`${this.id}_${this.focusedOptionIndex}`:null},ariaSetSize(){return this.visibleOptions.filter((e=>!this.isOptionGroup(e))).length},virtualScrollerDisabled(){return!this.virtualScrollerOptions}},directives:{ripple:d.default},components:{VirtualScroller:p.default,Portal:c.default}};const u=["id"],f=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],b=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],y={class:"p-dropdown-trigger"},v={key:0,class:"p-dropdown-header"},m={class:"p-dropdown-filter-container"},O=["value","placeholder","aria-owns","aria-activedescendant"],g=l.createElementVNode("span",{class:"p-dropdown-filter-icon pi pi-search"},null,-1),x={role:"status","aria-live":"polite",class:"p-hidden-accessible"},w=["id"],I=["id"],S=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove"],V={key:0,class:"p-dropdown-empty-message",role:"option"},k={key:1,class:"p-dropdown-empty-message",role:"option"},F={key:0,role:"status","aria-live":"polite",class:"p-hidden-accessible"},L={role:"status","aria-live":"polite",class:"p-hidden-accessible"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-dropdown {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.p-dropdown-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-dropdown-trigger {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n.p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n}\n.p-dropdown-label-empty {\n overflow: hidden;\n opacity: 0;\n}\ninput.p-dropdown-label {\n cursor: default;\n}\n.p-dropdown .p-dropdown-panel {\n min-width: 100%;\n}\n.p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-dropdown-items-wrapper {\n overflow: auto;\n}\n.p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n}\n.p-dropdown-item-group {\n cursor: auto;\n}\n.p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n.p-dropdown-filter {\n width: 100%;\n}\n.p-dropdown-filter-container {\n position: relative;\n}\n.p-dropdown-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-fluid .p-dropdown {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n}\n"),h.render=function(e,t,i,n,s,o){const r=l.resolveComponent("VirtualScroller"),a=l.resolveComponent("Portal"),d=l.resolveDirective("ripple");return l.openBlock(),l.createElementBlock("div",{ref:"container",id:s.id,class:l.normalizeClass(o.containerClass),onClick:t[16]||(t[16]=(...e)=>o.onContainerClick&&o.onContainerClick(...e))},[i.editable?(l.openBlock(),l.createElementBlock("input",l.mergeProps({key:0,ref:"focusInput",id:i.inputId,type:"text",style:i.inputStyle,class:o.inputStyleClass,value:o.editableInputValue,placeholder:i.placeholder,tabindex:i.disabled?-1:i.tabindex,disabled:i.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,onFocus:t[0]||(t[0]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onInput:t[3]||(t[3]=(...e)=>o.onEditableInput&&o.onEditableInput(...e))},i.inputProps),null,16,f)):(l.openBlock(),l.createElementBlock("span",l.mergeProps({key:1,ref:"focusInput",id:i.inputId,style:i.inputStyle,class:o.inputStyleClass,tabindex:i.disabled?-1:i.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===o.label?void 0:o.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,"aria-disabled":i.disabled,onFocus:t[4]||(t[4]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[5]||(t[5]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[6]||(t[6]=(...e)=>o.onKeyDown&&o.onKeyDown(...e))},i.inputProps),[l.renderSlot(e.$slots,"value",{value:i.modelValue,placeholder:i.placeholder},(()=>[l.createTextVNode(l.toDisplayString("p-emptylabel"===o.label?" ":o.label||"empty"),1)]))],16,b)),i.showClear&&null!=i.modelValue?(l.openBlock(),l.createElementBlock("i",l.mergeProps({key:2,class:"p-dropdown-clear-icon pi pi-times",onClick:t[7]||(t[7]=(...e)=>o.onClearClick&&o.onClearClick(...e))},i.clearIconProps),null,16)):l.createCommentVNode("",!0),l.createElementVNode("div",y,[l.renderSlot(e.$slots,"indicator",{},(()=>[l.createElementVNode("span",{class:l.normalizeClass(o.dropdownIconClass),"aria-hidden":"true"},null,2)]))]),l.createVNode(a,{appendTo:i.appendTo},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onOverlayEnter,onAfterEnter:o.onOverlayAfterEnter,onLeave:o.onOverlayLeave,onAfterLeave:o.onOverlayAfterLeave},{default:l.withCtx((()=>[s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,ref:o.overlayRef,style:i.panelStyle,class:o.panelStyleClass,onClick:t[14]||(t[14]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e)),onKeydown:t[15]||(t[15]=(...e)=>o.onOverlayKeyDown&&o.onOverlayKeyDown(...e))},i.panelProps),[l.createElementVNode("span",{ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[8]||(t[8]=(...e)=>o.onFirstHiddenFocus&&o.onFirstHiddenFocus(...e))},null,544),l.renderSlot(e.$slots,"header",{value:i.modelValue,options:o.visibleOptions}),i.filter?(l.openBlock(),l.createElementBlock("div",v,[l.createElementVNode("div",m,[l.createElementVNode("input",l.mergeProps({type:"text",ref:"filterInput",value:s.filterValue,onVnodeUpdated:t[9]||(t[9]=(...e)=>o.onFilterUpdated&&o.onFilterUpdated(...e)),class:"p-dropdown-filter p-inputtext p-component",placeholder:i.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":s.id+"_list","aria-activedescendant":o.focusedOptionId,onKeydown:t[10]||(t[10]=(...e)=>o.onFilterKeyDown&&o.onFilterKeyDown(...e)),onBlur:t[11]||(t[11]=(...e)=>o.onFilterBlur&&o.onFilterBlur(...e)),onInput:t[12]||(t[12]=(...e)=>o.onFilterChange&&o.onFilterChange(...e))},i.filterInputProps),null,16,O),g]),l.createElementVNode("span",x,l.toDisplayString(o.filterResultMessageText),1)])):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"p-dropdown-items-wrapper",style:l.normalizeStyle({"max-height":o.virtualScrollerDisabled?i.scrollHeight:""})},[l.createVNode(r,l.mergeProps({ref:o.virtualScrollerRef},i.virtualScrollerOptions,{items:o.visibleOptions,style:{height:i.scrollHeight},tabindex:-1,disabled:o.virtualScrollerDisabled}),l.createSlots({content:l.withCtx((({styleClass:t,contentRef:n,items:r,getItemOptions:a,contentStyle:p,itemSize:c})=>[l.createElementVNode("ul",{ref:e=>o.listRef(e,n),id:s.id+"_list",class:l.normalizeClass(["p-dropdown-items",t]),style:l.normalizeStyle(p),role:"listbox"},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(r,((t,i)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.getOptionRenderKey(t,o.getOptionIndex(i,a))},[o.isOptionGroup(t)?(l.openBlock(),l.createElementBlock("li",{key:0,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:"p-dropdown-item-group",role:"option"},[l.renderSlot(e.$slots,"optiongroup",{option:t.optionGroup,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionGroupLabel(t.optionGroup)),1)]))],12,I)):l.withDirectives((l.openBlock(),l.createElementBlock("li",{key:1,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:l.normalizeClass(["p-dropdown-item",{"p-highlight":o.isSelected(t),"p-focus":s.focusedOptionIndex===o.getOptionIndex(i,a),"p-disabled":o.isOptionDisabled(t)}]),role:"option","aria-label":o.getOptionLabel(t),"aria-selected":o.isSelected(t),"aria-disabled":o.isOptionDisabled(t),"aria-setsize":o.ariaSetSize,"aria-posinset":o.getAriaPosInset(o.getOptionIndex(i,a)),onClick:e=>o.onOptionSelect(e,t),onMousemove:e=>o.onOptionMouseMove(e,o.getOptionIndex(i,a))},[l.renderSlot(e.$slots,"option",{option:t,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionLabel(t)),1)]))],46,S)),[[d]])],64)))),128)),s.filterValue&&(!r||r&&0===r.length)?(l.openBlock(),l.createElementBlock("li",V,[l.renderSlot(e.$slots,"emptyfilter",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyFilterMessageText),1)]))])):!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("li",k,[l.renderSlot(e.$slots,"empty",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyMessageText),1)]))])):l.createCommentVNode("",!0)],14,w),!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("span",F,l.toDisplayString(o.emptyMessageText),1)):l.createCommentVNode("",!0),l.createElementVNode("span",L,l.toDisplayString(o.selectedMessageText),1)])),_:2},[e.$slots.loader?{name:"loader",fn:l.withCtx((({options:t})=>[l.renderSlot(e.$slots,"loader",{options:t})]))}:void 0]),1040,["items","style","disabled"])],4),l.renderSlot(e.$slots,"footer",{value:i.modelValue,options:o.visibleOptions}),l.createElementVNode("span",{ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[13]||(t[13]=(...e)=>o.onLastHiddenFocus&&o.onLastHiddenFocus(...e))},null,544)],16)):l.createCommentVNode("",!0)])),_:3},8,["onEnter","onAfterEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo"])],10,u)},module.exports=h;
|
|
1
|
+
"use strict";var e=require("primevue/utils"),t=require("primevue/overlayeventbus"),i=require("primevue/api"),n=require("primevue/ripple"),s=require("primevue/virtualscroller"),o=require("primevue/portal"),l=require("vue");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(t),d=r(n),p=r(s),c=r(o),h={name:"Dropdown",emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:String,disabled:Boolean,dataKey:null,showClear:Boolean,inputId:String,inputStyle:null,inputClass:null,inputProps:null,panelStyle:null,panelClass:null,panelProps:null,filterInputProps:null,clearIconProps:null,appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:"pi pi-spinner pi-spin"},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},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},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,selectOnFocus:!1,focusOnHover:!1,data:()=>({id:e.UniqueComponentId(),focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}),watch:{modelValue(){this.isModelValueChanged=!0},options(){this.autoUpdateModel()}},mounted(){this.id=this.$attrs.id||this.id,this.autoUpdateModel()},updated(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(e.ZIndexUtils.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel(t){return this.optionLabel?e.ObjectUtils.resolveFieldData(t,this.optionLabel):t},getOptionValue(t){return this.optionValue?e.ObjectUtils.resolveFieldData(t,this.optionValue):t},getOptionRenderKey(t,i){return(this.dataKey?e.ObjectUtils.resolveFieldData(t,this.dataKey):this.getOptionLabel(t))+"_"+i},isOptionDisabled(t){return!!this.optionDisabled&&e.ObjectUtils.resolveFieldData(t,this.optionDisabled)},isOptionGroup(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupLabel)},getOptionGroupChildren(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupChildren)},getAriaPosInset(e){return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((e=>this.isOptionGroup(e))).length:e)+1},show(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&this.$refs.focusInput.focus()},hide(e){const t=()=>{this.$emit("before-hide"),this.overlayVisible=!1,this.focusedOptionIndex=-1,this.searchValue="",e&&this.$refs.focusInput.focus()};setTimeout((()=>{t()}),0)},onFocus(e){this.focused=!0,this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown(t){switch(t.code){case"ArrowDown":this.onArrowDownKey(t);break;case"ArrowUp":this.onArrowUpKey(t,this.editable);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(t,this.editable);break;case"Home":this.onHomeKey(t,this.editable);break;case"End":this.onEndKey(t,this.editable);break;case"PageDown":this.onPageDownKey(t);break;case"PageUp":this.onPageUpKey(t);break;case"Space":this.onSpaceKey(t,this.editable);break;case"Enter":this.onEnterKey(t);break;case"Escape":this.onEscapeKey(t);break;case"Tab":this.onTabKey(t);break;case"Backspace":this.onBackspaceKey(t,this.editable);break;case"ShiftLeft":case"ShiftRight":break;default:e.ObjectUtils.isPrintableCharacter(t.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(t,t.key))}},onEditableInput(e){const t=e.target.value;this.searchValue="";!this.searchOptions(e,t)&&(this.focusedOptionIndex=-1),this.$emit("update:modelValue",t)},onContainerClick(t){this.disabled||this.loading||e.DomHandler.hasClass(t.target,"p-dropdown-clear-icon")||"INPUT"===t.target.tagName||this.overlay&&this.overlay.contains(t.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick(e){this.updateModel(e,null)},onFirstHiddenFocus(t){if(t.relatedTarget===this.$refs.focusInput){const t=e.DomHandler.getFirstFocusableElement(this.overlay,":not(.p-hidden-focusable)");t&&t.focus()}else this.$refs.focusInput.focus()},onLastHiddenFocus(){this.$refs.firstHiddenFocusableElementOnOverlay.focus()},onOptionSelect(e,t){const i=this.getOptionValue(t);this.updateModel(e,i),this.hide(!0)},onOptionMouseMove(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onFilterChange(e){const t=e.target.value;this.filterValue=t,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:t}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur(){this.focusedOptionIndex=-1},onFilterUpdated(){this.overlayVisible&&this.alignOverlay()},onOverlayClick(e){a.default.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey(e){const t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey(e,t=!1){if(e.altKey&&!t)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{const t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey(e,t=!1){t&&(this.focusedOptionIndex=-1)},onHomeKey(e,t=!1){t?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey(e,t=!1){if(t){const 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(e){this.scrollInView(0),e.preventDefault()},onPageDownKey(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey(e,t=!1){!t&&this.onEnterKey(e)},onEscapeKey(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey(e,t=!1){t||(this.overlayVisible&&this.hasFocusableElements()?(this.$refs.firstHiddenFocusableElementOnOverlay.focus(),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey(e,t=!1){t&&!this.overlayVisible&&this.show()},onOverlayEnter(t){e.ZIndexUtils.set("overlay",t,this.$primevue.config.zIndex.overlay),this.alignOverlay(),this.scrollInView()},onOverlayAfterEnter(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave(t){e.ZIndexUtils.clear(t)},alignOverlay(){"self"===this.appendTo?e.DomHandler.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=e.DomHandler.getOuterWidth(this.$el)+"px",e.DomHandler.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.overlay&&!this.$el.contains(e.target)&&!this.overlay.contains(e.target)&&this.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new e.ConnectedOverlayScrollHandler(this.$refs.container,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!e.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},hasFocusableElements(){return e.DomHandler.getFocusableElements(this.overlay,":not(.p-hidden-focusable)").length>0},isOptionMatched(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption(e){return e&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected(t){return e.ObjectUtils.equals(this.modelValue,this.getOptionValue(t),this.equalityKey)},findFirstOptionIndex(){return this.visibleOptions.findIndex((e=>this.isValidOption(e)))},findLastOptionIndex(){return e.ObjectUtils.findLastIndex(this.visibleOptions,(e=>this.isValidOption(e)))},findNextOptionIndex(e){const t=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((e=>this.isValidOption(e))):-1;return t>-1?t+e+1:e},findPrevOptionIndex(t){const i=t>0?e.ObjectUtils.findLastIndex(this.visibleOptions.slice(0,t),(e=>this.isValidOption(e))):-1;return i>-1?i:t},findSelectedOptionIndex(){return this.hasSelectedOption?this.visibleOptions.findIndex((e=>this.isValidSelectedOption(e))):-1},findFirstFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,n=!1;return-1!==this.focusedOptionIndex?(i=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))),i=-1===i?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))):i+this.focusedOptionIndex):i=this.visibleOptions.findIndex((e=>this.isOptionMatched(e))),-1!==i&&(n=!0),-1===i&&-1===this.focusedOptionIndex&&(i=this.findFirstFocusedOptionIndex()),-1!==i&&this.changeFocusedOptionIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),n},changeFocusedOptionIndex(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView(),this.selectOnFocus&&this.updateModel(e,this.getOptionValue(this.visibleOptions[t])))},scrollInView(t=-1){const i=-1!==t?`${this.id}_${t}`:this.focusedOptionId,n=e.DomHandler.findSingle(this.list,`li[id="${i}"]`);n?n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((()=>{this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==t?t:this.focusedOptionIndex)}),0)},autoUpdateModel(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();const e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,e)}},updateModel(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions(e){return(e||[]).reduce(((e,t,i)=>{e.push({optionGroup:t,group:!0,index:i});const n=this.getOptionGroupChildren(t);return n&&n.forEach((t=>e.push(t))),e}),[])},overlayRef(e){this.overlay=e},listRef(e,t){this.list=e,t&&t(e)},virtualScrollerRef(e){this.virtualScroller=e}},computed:{containerClass(){return["p-dropdown p-component p-inputwrapper",{"p-disabled":this.disabled,"p-dropdown-clearable":this.showClear&&!this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue,"p-inputwrapper-focus":this.focused||this.overlayVisible,"p-overlay-open":this.overlayVisible}]},inputStyleClass(){return["p-dropdown-label p-inputtext",this.inputClass,{"p-placeholder":!this.editable&&this.label===this.placeholder,"p-dropdown-label-empty":!(this.editable||this.$slots.value||"p-emptylabel"!==this.label&&0!==this.label.length)}]},panelStyleClass(){return["p-dropdown-panel p-component",this.panelClass,{"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},dropdownIconClass(){return["p-dropdown-trigger-icon",this.loading?this.loadingIcon:"pi pi-chevron-down"]},visibleOptions(){const e=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];return this.filterValue?i.FilterService.filter(e,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale):e},hasSelectedOption(){return e.ObjectUtils.isNotEmpty(this.modelValue)},label(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey(){return this.optionValue?null:this.dataKey},searchFields(){return this.filterFields||[this.optionLabel]},filterResultMessageText(){return e.ObjectUtils.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId(){return-1!==this.focusedOptionIndex?`${this.id}_${this.focusedOptionIndex}`:null},ariaSetSize(){return this.visibleOptions.filter((e=>!this.isOptionGroup(e))).length},virtualScrollerDisabled(){return!this.virtualScrollerOptions}},directives:{ripple:d.default},components:{VirtualScroller:p.default,Portal:c.default}};const u=["id"],f=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],b=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],y={class:"p-dropdown-trigger"},v={key:0,class:"p-dropdown-header"},m={class:"p-dropdown-filter-container"},O=["value","placeholder","aria-owns","aria-activedescendant"],g=l.createElementVNode("span",{class:"p-dropdown-filter-icon pi pi-search"},null,-1),x={role:"status","aria-live":"polite",class:"p-hidden-accessible"},w=["id"],I=["id"],S=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove"],V={key:0,class:"p-dropdown-empty-message",role:"option"},k={key:1,class:"p-dropdown-empty-message",role:"option"},F={key:0,role:"status","aria-live":"polite",class:"p-hidden-accessible"},L={role:"status","aria-live":"polite",class:"p-hidden-accessible"};!function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-dropdown {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.p-dropdown-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-dropdown-trigger {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n.p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n}\n.p-dropdown-label-empty {\n overflow: hidden;\n opacity: 0;\n}\ninput.p-dropdown-label {\n cursor: default;\n}\n.p-dropdown .p-dropdown-panel {\n min-width: 100%;\n}\n.p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-dropdown-items-wrapper {\n overflow: auto;\n}\n.p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n}\n.p-dropdown-item-group {\n cursor: auto;\n}\n.p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n.p-dropdown-filter {\n width: 100%;\n}\n.p-dropdown-filter-container {\n position: relative;\n}\n.p-dropdown-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-fluid .p-dropdown {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n}\n"),h.render=function(e,t,i,n,s,o){const r=l.resolveComponent("VirtualScroller"),a=l.resolveComponent("Portal"),d=l.resolveDirective("ripple");return l.openBlock(),l.createElementBlock("div",{ref:"container",id:s.id,class:l.normalizeClass(o.containerClass),onClick:t[16]||(t[16]=(...e)=>o.onContainerClick&&o.onContainerClick(...e))},[i.editable?(l.openBlock(),l.createElementBlock("input",l.mergeProps({key:0,ref:"focusInput",id:i.inputId,type:"text",style:i.inputStyle,class:o.inputStyleClass,value:o.editableInputValue,placeholder:i.placeholder,tabindex:i.disabled?-1:i.tabindex,disabled:i.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,onFocus:t[0]||(t[0]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onInput:t[3]||(t[3]=(...e)=>o.onEditableInput&&o.onEditableInput(...e))},i.inputProps),null,16,f)):(l.openBlock(),l.createElementBlock("span",l.mergeProps({key:1,ref:"focusInput",id:i.inputId,style:i.inputStyle,class:o.inputStyleClass,tabindex:i.disabled?-1:i.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===o.label?void 0:o.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,"aria-disabled":i.disabled,onFocus:t[4]||(t[4]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[5]||(t[5]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[6]||(t[6]=(...e)=>o.onKeyDown&&o.onKeyDown(...e))},i.inputProps),[l.renderSlot(e.$slots,"value",{value:i.modelValue,placeholder:i.placeholder},(()=>[l.createTextVNode(l.toDisplayString("p-emptylabel"===o.label?" ":o.label||"empty"),1)]))],16,b)),i.showClear&&null!=i.modelValue?(l.openBlock(),l.createElementBlock("i",l.mergeProps({key:2,class:"p-dropdown-clear-icon pi pi-times",onClick:t[7]||(t[7]=(...e)=>o.onClearClick&&o.onClearClick(...e))},i.clearIconProps),null,16)):l.createCommentVNode("",!0),l.createElementVNode("div",y,[l.renderSlot(e.$slots,"indicator",{},(()=>[l.createElementVNode("span",{class:l.normalizeClass(o.dropdownIconClass),"aria-hidden":"true"},null,2)]))]),l.createVNode(a,{appendTo:i.appendTo},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onOverlayEnter,onAfterEnter:o.onOverlayAfterEnter,onLeave:o.onOverlayLeave,onAfterLeave:o.onOverlayAfterLeave},{default:l.withCtx((()=>[s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,ref:o.overlayRef,style:i.panelStyle,class:o.panelStyleClass,onClick:t[14]||(t[14]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e)),onKeydown:t[15]||(t[15]=(...e)=>o.onOverlayKeyDown&&o.onOverlayKeyDown(...e))},i.panelProps),[l.createElementVNode("span",{ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[8]||(t[8]=(...e)=>o.onFirstHiddenFocus&&o.onFirstHiddenFocus(...e))},null,544),l.renderSlot(e.$slots,"header",{value:i.modelValue,options:o.visibleOptions}),i.filter?(l.openBlock(),l.createElementBlock("div",v,[l.createElementVNode("div",m,[l.createElementVNode("input",l.mergeProps({type:"text",ref:"filterInput",value:s.filterValue,onVnodeUpdated:t[9]||(t[9]=(...e)=>o.onFilterUpdated&&o.onFilterUpdated(...e)),class:"p-dropdown-filter p-inputtext p-component",placeholder:i.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":s.id+"_list","aria-activedescendant":o.focusedOptionId,onKeydown:t[10]||(t[10]=(...e)=>o.onFilterKeyDown&&o.onFilterKeyDown(...e)),onBlur:t[11]||(t[11]=(...e)=>o.onFilterBlur&&o.onFilterBlur(...e)),onInput:t[12]||(t[12]=(...e)=>o.onFilterChange&&o.onFilterChange(...e))},i.filterInputProps),null,16,O),g]),l.createElementVNode("span",x,l.toDisplayString(o.filterResultMessageText),1)])):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"p-dropdown-items-wrapper",style:l.normalizeStyle({"max-height":o.virtualScrollerDisabled?i.scrollHeight:""})},[l.createVNode(r,l.mergeProps({ref:o.virtualScrollerRef},i.virtualScrollerOptions,{items:o.visibleOptions,style:{height:i.scrollHeight},tabindex:-1,disabled:o.virtualScrollerDisabled}),l.createSlots({content:l.withCtx((({styleClass:t,contentRef:n,items:r,getItemOptions:a,contentStyle:p,itemSize:c})=>[l.createElementVNode("ul",{ref:e=>o.listRef(e,n),id:s.id+"_list",class:l.normalizeClass(["p-dropdown-items",t]),style:l.normalizeStyle(p),role:"listbox"},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(r,((t,i)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.getOptionRenderKey(t,o.getOptionIndex(i,a))},[o.isOptionGroup(t)?(l.openBlock(),l.createElementBlock("li",{key:0,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:"p-dropdown-item-group",role:"option"},[l.renderSlot(e.$slots,"optiongroup",{option:t.optionGroup,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionGroupLabel(t.optionGroup)),1)]))],12,I)):l.withDirectives((l.openBlock(),l.createElementBlock("li",{key:1,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:l.normalizeClass(["p-dropdown-item",{"p-highlight":o.isSelected(t),"p-focus":s.focusedOptionIndex===o.getOptionIndex(i,a),"p-disabled":o.isOptionDisabled(t)}]),role:"option","aria-label":o.getOptionLabel(t),"aria-selected":o.isSelected(t),"aria-disabled":o.isOptionDisabled(t),"aria-setsize":o.ariaSetSize,"aria-posinset":o.getAriaPosInset(o.getOptionIndex(i,a)),onClick:e=>o.onOptionSelect(e,t),onMousemove:e=>o.onOptionMouseMove(e,o.getOptionIndex(i,a))},[l.renderSlot(e.$slots,"option",{option:t,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionLabel(t)),1)]))],46,S)),[[d]])],64)))),128)),s.filterValue&&(!r||r&&0===r.length)?(l.openBlock(),l.createElementBlock("li",V,[l.renderSlot(e.$slots,"emptyfilter",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyFilterMessageText),1)]))])):!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("li",k,[l.renderSlot(e.$slots,"empty",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyMessageText),1)]))])):l.createCommentVNode("",!0)],14,w),!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("span",F,l.toDisplayString(o.emptyMessageText),1)):l.createCommentVNode("",!0),l.createElementVNode("span",L,l.toDisplayString(o.selectedMessageText),1)])),_:2},[e.$slots.loader?{name:"loader",fn:l.withCtx((({options:t})=>[l.renderSlot(e.$slots,"loader",{options:t})]))}:void 0]),1040,["items","style","disabled"])],4),l.renderSlot(e.$slots,"footer",{value:i.modelValue,options:o.visibleOptions}),l.createElementVNode("span",{ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[13]||(t[13]=(...e)=>o.onLastHiddenFocus&&o.onLastHiddenFocus(...e))},null,544)],16)):l.createCommentVNode("",!0)])),_:3},8,["onEnter","onAfterEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo"])],10,u)},module.exports=h;
|
package/dropdown/dropdown.esm.js
CHANGED
|
@@ -598,14 +598,14 @@ var script = {
|
|
|
598
598
|
return this.visibleOptions.findIndex(option => this.isValidOption(option));
|
|
599
599
|
},
|
|
600
600
|
findLastOptionIndex() {
|
|
601
|
-
return this.visibleOptions
|
|
601
|
+
return ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option));
|
|
602
602
|
},
|
|
603
603
|
findNextOptionIndex(index) {
|
|
604
604
|
const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1;
|
|
605
605
|
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
606
606
|
},
|
|
607
607
|
findPrevOptionIndex(index) {
|
|
608
|
-
const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index)
|
|
608
|
+
const matchedOptionIndex = index > 0 ? ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1;
|
|
609
609
|
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
610
610
|
},
|
|
611
611
|
findSelectedOptionIndex() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UniqueComponentId as e,ZIndexUtils as i,ObjectUtils as t,DomHandler as s,ConnectedOverlayScrollHandler as n}from"primevue/utils";import o from"primevue/overlayeventbus";import{FilterService as l}from"primevue/api";import a from"primevue/ripple";import r from"primevue/virtualscroller";import d from"primevue/portal";import{resolveComponent as p,resolveDirective as h,openBlock as u,createElementBlock as c,normalizeClass as f,mergeProps as b,renderSlot as y,createTextVNode as v,toDisplayString as O,createCommentVNode as g,createElementVNode as m,createVNode as x,withCtx as w,Transition as I,normalizeStyle as S,createSlots as V,Fragment as L,renderList as F,withDirectives as k}from"vue";var C={name:"Dropdown",emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:String,disabled:Boolean,dataKey:null,showClear:Boolean,inputId:String,inputStyle:null,inputClass:null,inputProps:null,panelStyle:null,panelClass:null,panelProps:null,filterInputProps:null,clearIconProps:null,appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:"pi pi-spinner pi-spin"},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},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},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,selectOnFocus:!1,focusOnHover:!1,data:()=>({id:e(),focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}),watch:{modelValue(){this.isModelValueChanged=!0},options(){this.autoUpdateModel()}},mounted(){this.id=this.$attrs.id||this.id,this.autoUpdateModel()},updated(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(i.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex(e,i){return this.virtualScrollerDisabled?e:i&&i(e).index},getOptionLabel(e){return this.optionLabel?t.resolveFieldData(e,this.optionLabel):e},getOptionValue(e){return this.optionValue?t.resolveFieldData(e,this.optionValue):e},getOptionRenderKey(e,i){return(this.dataKey?t.resolveFieldData(e,this.dataKey):this.getOptionLabel(e))+"_"+i},isOptionDisabled(e){return!!this.optionDisabled&&t.resolveFieldData(e,this.optionDisabled)},isOptionGroup(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel(e){return t.resolveFieldData(e,this.optionGroupLabel)},getOptionGroupChildren(e){return t.resolveFieldData(e,this.optionGroupChildren)},getAriaPosInset(e){return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((e=>this.isOptionGroup(e))).length:e)+1},show(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&this.$refs.focusInput.focus()},hide(e){const i=()=>{this.$emit("before-hide"),this.overlayVisible=!1,this.focusedOptionIndex=-1,this.searchValue="",e&&this.$refs.focusInput.focus()};setTimeout((()=>{i()}),0)},onFocus(e){this.focused=!0,this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown(e){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"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":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.isPrintableCharacter(e.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(e,e.key))}},onEditableInput(e){const i=e.target.value;this.searchValue="";!this.searchOptions(e,i)&&(this.focusedOptionIndex=-1),this.$emit("update:modelValue",i)},onContainerClick(e){this.disabled||this.loading||s.hasClass(e.target,"p-dropdown-clear-icon")||"INPUT"===e.target.tagName||this.overlay&&this.overlay.contains(e.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick(e){this.updateModel(e,null)},onFirstHiddenFocus(e){if(e.relatedTarget===this.$refs.focusInput){const e=s.getFirstFocusableElement(this.overlay,":not(.p-hidden-focusable)");e&&e.focus()}else this.$refs.focusInput.focus()},onLastHiddenFocus(){this.$refs.firstHiddenFocusableElementOnOverlay.focus()},onOptionSelect(e,i){const t=this.getOptionValue(i);this.updateModel(e,t),this.hide(!0)},onOptionMouseMove(e,i){this.focusOnHover&&this.changeFocusedOptionIndex(e,i)},onFilterChange(e){const i=e.target.value;this.filterValue=i,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:i}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur(){this.focusedOptionIndex=-1},onFilterUpdated(){this.overlayVisible&&this.alignOverlay()},onOverlayClick(e){o.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey(e){const i=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,i),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey(e,i=!1){if(e.altKey&&!i)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{const i=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,i),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey(e,i=!1){i&&(this.focusedOptionIndex=-1)},onHomeKey(e,i=!1){i?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey(e,i=!1){if(i){const i=e.currentTarget,t=i.value.length;i.setSelectionRange(t,t),this.focusedOptionIndex=-1}else this.changeFocusedOptionIndex(e,this.findLastOptionIndex()),!this.overlayVisible&&this.show();e.preventDefault()},onPageUpKey(e){this.scrollInView(0),e.preventDefault()},onPageDownKey(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey(e,i=!1){!i&&this.onEnterKey(e)},onEscapeKey(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey(e,i=!1){i||(this.overlayVisible&&this.hasFocusableElements()?(this.$refs.firstHiddenFocusableElementOnOverlay.focus(),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey(e,i=!1){i&&!this.overlayVisible&&this.show()},onOverlayEnter(e){i.set("overlay",e,this.$primevue.config.zIndex.overlay),this.alignOverlay(),this.scrollInView()},onOverlayAfterEnter(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave(e){i.clear(e)},alignOverlay(){"self"===this.appendTo?s.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=s.getOuterWidth(this.$el)+"px",s.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.overlay&&!this.$el.contains(e.target)&&!this.overlay.contains(e.target)&&this.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new n(this.$refs.container,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!s.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},hasFocusableElements(){return s.getFocusableElements(this.overlay,":not(.p-hidden-focusable)").length>0},isOptionMatched(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption(e){return e&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected(e){return t.equals(this.modelValue,this.getOptionValue(e),this.equalityKey)},findFirstOptionIndex(){return this.visibleOptions.findIndex((e=>this.isValidOption(e)))},findLastOptionIndex(){return this.visibleOptions.findLastIndex((e=>this.isValidOption(e)))},findNextOptionIndex(e){const i=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((e=>this.isValidOption(e))):-1;return i>-1?i+e+1:e},findPrevOptionIndex(e){const i=e>0?this.visibleOptions.slice(0,e).findLastIndex((e=>this.isValidOption(e))):-1;return i>-1?i:e},findSelectedOptionIndex(){return this.hasSelectedOption?this.visibleOptions.findIndex((e=>this.isValidSelectedOption(e))):-1},findFirstFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions(e,i){this.searchValue=(this.searchValue||"")+i;let t=-1,s=!1;return-1!==this.focusedOptionIndex?(t=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))),t=-1===t?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))):t+this.focusedOptionIndex):t=this.visibleOptions.findIndex((e=>this.isOptionMatched(e))),-1!==t&&(s=!0),-1===t&&-1===this.focusedOptionIndex&&(t=this.findFirstFocusedOptionIndex()),-1!==t&&this.changeFocusedOptionIndex(e,t),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),s},changeFocusedOptionIndex(e,i){this.focusedOptionIndex!==i&&(this.focusedOptionIndex=i,this.scrollInView(),this.selectOnFocus&&this.updateModel(e,this.getOptionValue(this.visibleOptions[i])))},scrollInView(e=-1){const i=-1!==e?`${this.id}_${e}`:this.focusedOptionId,t=s.findSingle(this.list,`li[id="${i}"]`);t?t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((()=>{this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==e?e:this.focusedOptionIndex)}),0)},autoUpdateModel(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();const e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,e)}},updateModel(e,i){this.$emit("update:modelValue",i),this.$emit("change",{originalEvent:e,value:i})},flatOptions(e){return(e||[]).reduce(((e,i,t)=>{e.push({optionGroup:i,group:!0,index:t});const s=this.getOptionGroupChildren(i);return s&&s.forEach((i=>e.push(i))),e}),[])},overlayRef(e){this.overlay=e},listRef(e,i){this.list=e,i&&i(e)},virtualScrollerRef(e){this.virtualScroller=e}},computed:{containerClass(){return["p-dropdown p-component p-inputwrapper",{"p-disabled":this.disabled,"p-dropdown-clearable":this.showClear&&!this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue,"p-inputwrapper-focus":this.focused||this.overlayVisible,"p-overlay-open":this.overlayVisible}]},inputStyleClass(){return["p-dropdown-label p-inputtext",this.inputClass,{"p-placeholder":!this.editable&&this.label===this.placeholder,"p-dropdown-label-empty":!(this.editable||this.$slots.value||"p-emptylabel"!==this.label&&0!==this.label.length)}]},panelStyleClass(){return["p-dropdown-panel p-component",this.panelClass,{"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},dropdownIconClass(){return["p-dropdown-trigger-icon",this.loading?this.loadingIcon:"pi pi-chevron-down"]},visibleOptions(){const e=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];return this.filterValue?l.filter(e,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale):e},hasSelectedOption(){return t.isNotEmpty(this.modelValue)},label(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey(){return this.optionValue?null:this.dataKey},searchFields(){return this.filterFields||[this.optionLabel]},filterResultMessageText(){return t.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId(){return-1!==this.focusedOptionIndex?`${this.id}_${this.focusedOptionIndex}`:null},ariaSetSize(){return this.visibleOptions.filter((e=>!this.isOptionGroup(e))).length},virtualScrollerDisabled(){return!this.virtualScrollerOptions}},directives:{ripple:a},components:{VirtualScroller:r,Portal:d}};const K=["id"],M=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],D=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],E={class:"p-dropdown-trigger"},$={key:0,class:"p-dropdown-header"},T={class:"p-dropdown-filter-container"},A=["value","placeholder","aria-owns","aria-activedescendant"],H=m("span",{class:"p-dropdown-filter-icon pi pi-search"},null,-1),P={role:"status","aria-live":"polite",class:"p-hidden-accessible"},B=["id"],z=["id"],R=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove"],G={key:0,class:"p-dropdown-empty-message",role:"option"},U={key:1,class:"p-dropdown-empty-message",role:"option"},_={key:0,role:"status","aria-live":"polite",class:"p-hidden-accessible"},N={role:"status","aria-live":"polite",class:"p-hidden-accessible"};!function(e,i){void 0===i&&(i={});var t=i.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===t&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-dropdown {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.p-dropdown-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-dropdown-trigger {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n.p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n}\n.p-dropdown-label-empty {\n overflow: hidden;\n opacity: 0;\n}\ninput.p-dropdown-label {\n cursor: default;\n}\n.p-dropdown .p-dropdown-panel {\n min-width: 100%;\n}\n.p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-dropdown-items-wrapper {\n overflow: auto;\n}\n.p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n}\n.p-dropdown-item-group {\n cursor: auto;\n}\n.p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n.p-dropdown-filter {\n width: 100%;\n}\n.p-dropdown-filter-container {\n position: relative;\n}\n.p-dropdown-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-fluid .p-dropdown {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n}\n"),C.render=function(e,i,t,s,n,o){const l=p("VirtualScroller"),a=p("Portal"),r=h("ripple");return u(),c("div",{ref:"container",id:n.id,class:f(o.containerClass),onClick:i[16]||(i[16]=(...e)=>o.onContainerClick&&o.onContainerClick(...e))},[t.editable?(u(),c("input",b({key:0,ref:"focusInput",id:t.inputId,type:"text",style:t.inputStyle,class:o.inputStyleClass,value:o.editableInputValue,placeholder:t.placeholder,tabindex:t.disabled?-1:t.tabindex,disabled:t.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":n.overlayVisible,"aria-controls":n.id+"_list","aria-activedescendant":n.focused?o.focusedOptionId:void 0,onFocus:i[0]||(i[0]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:i[1]||(i[1]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:i[2]||(i[2]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onInput:i[3]||(i[3]=(...e)=>o.onEditableInput&&o.onEditableInput(...e))},t.inputProps),null,16,M)):(u(),c("span",b({key:1,ref:"focusInput",id:t.inputId,style:t.inputStyle,class:o.inputStyleClass,tabindex:t.disabled?-1:t.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===o.label?void 0:o.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":n.overlayVisible,"aria-controls":n.id+"_list","aria-activedescendant":n.focused?o.focusedOptionId:void 0,"aria-disabled":t.disabled,onFocus:i[4]||(i[4]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:i[5]||(i[5]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:i[6]||(i[6]=(...e)=>o.onKeyDown&&o.onKeyDown(...e))},t.inputProps),[y(e.$slots,"value",{value:t.modelValue,placeholder:t.placeholder},(()=>[v(O("p-emptylabel"===o.label?" ":o.label||"empty"),1)]))],16,D)),t.showClear&&null!=t.modelValue?(u(),c("i",b({key:2,class:"p-dropdown-clear-icon pi pi-times",onClick:i[7]||(i[7]=(...e)=>o.onClearClick&&o.onClearClick(...e))},t.clearIconProps),null,16)):g("",!0),m("div",E,[y(e.$slots,"indicator",{},(()=>[m("span",{class:f(o.dropdownIconClass),"aria-hidden":"true"},null,2)]))]),x(a,{appendTo:t.appendTo},{default:w((()=>[x(I,{name:"p-connected-overlay",onEnter:o.onOverlayEnter,onAfterEnter:o.onOverlayAfterEnter,onLeave:o.onOverlayLeave,onAfterLeave:o.onOverlayAfterLeave},{default:w((()=>[n.overlayVisible?(u(),c("div",b({key:0,ref:o.overlayRef,style:t.panelStyle,class:o.panelStyleClass,onClick:i[14]||(i[14]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e)),onKeydown:i[15]||(i[15]=(...e)=>o.onOverlayKeyDown&&o.onOverlayKeyDown(...e))},t.panelProps),[m("span",{ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:i[8]||(i[8]=(...e)=>o.onFirstHiddenFocus&&o.onFirstHiddenFocus(...e))},null,544),y(e.$slots,"header",{value:t.modelValue,options:o.visibleOptions}),t.filter?(u(),c("div",$,[m("div",T,[m("input",b({type:"text",ref:"filterInput",value:n.filterValue,onVnodeUpdated:i[9]||(i[9]=(...e)=>o.onFilterUpdated&&o.onFilterUpdated(...e)),class:"p-dropdown-filter p-inputtext p-component",placeholder:t.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":n.id+"_list","aria-activedescendant":o.focusedOptionId,onKeydown:i[10]||(i[10]=(...e)=>o.onFilterKeyDown&&o.onFilterKeyDown(...e)),onBlur:i[11]||(i[11]=(...e)=>o.onFilterBlur&&o.onFilterBlur(...e)),onInput:i[12]||(i[12]=(...e)=>o.onFilterChange&&o.onFilterChange(...e))},t.filterInputProps),null,16,A),H]),m("span",P,O(o.filterResultMessageText),1)])):g("",!0),m("div",{class:"p-dropdown-items-wrapper",style:S({"max-height":o.virtualScrollerDisabled?t.scrollHeight:""})},[x(l,b({ref:o.virtualScrollerRef},t.virtualScrollerOptions,{items:o.visibleOptions,style:{height:t.scrollHeight},tabindex:-1,disabled:o.virtualScrollerDisabled}),V({content:w((({styleClass:i,contentRef:s,items:l,getItemOptions:a,contentStyle:d,itemSize:p})=>[m("ul",{ref:e=>o.listRef(e,s),id:n.id+"_list",class:f(["p-dropdown-items",i]),style:S(d),role:"listbox"},[(u(!0),c(L,null,F(l,((i,t)=>(u(),c(L,{key:o.getOptionRenderKey(i,o.getOptionIndex(t,a))},[o.isOptionGroup(i)?(u(),c("li",{key:0,id:n.id+"_"+o.getOptionIndex(t,a),style:S({height:p?p+"px":void 0}),class:"p-dropdown-item-group",role:"option"},[y(e.$slots,"optiongroup",{option:i.optionGroup,index:o.getOptionIndex(t,a)},(()=>[v(O(o.getOptionGroupLabel(i.optionGroup)),1)]))],12,z)):k((u(),c("li",{key:1,id:n.id+"_"+o.getOptionIndex(t,a),style:S({height:p?p+"px":void 0}),class:f(["p-dropdown-item",{"p-highlight":o.isSelected(i),"p-focus":n.focusedOptionIndex===o.getOptionIndex(t,a),"p-disabled":o.isOptionDisabled(i)}]),role:"option","aria-label":o.getOptionLabel(i),"aria-selected":o.isSelected(i),"aria-disabled":o.isOptionDisabled(i),"aria-setsize":o.ariaSetSize,"aria-posinset":o.getAriaPosInset(o.getOptionIndex(t,a)),onClick:e=>o.onOptionSelect(e,i),onMousemove:e=>o.onOptionMouseMove(e,o.getOptionIndex(t,a))},[y(e.$slots,"option",{option:i,index:o.getOptionIndex(t,a)},(()=>[v(O(o.getOptionLabel(i)),1)]))],46,R)),[[r]])],64)))),128)),n.filterValue&&(!l||l&&0===l.length)?(u(),c("li",G,[y(e.$slots,"emptyfilter",{},(()=>[v(O(o.emptyFilterMessageText),1)]))])):!t.options||t.options&&0===t.options.length?(u(),c("li",U,[y(e.$slots,"empty",{},(()=>[v(O(o.emptyMessageText),1)]))])):g("",!0)],14,B),!t.options||t.options&&0===t.options.length?(u(),c("span",_,O(o.emptyMessageText),1)):g("",!0),m("span",N,O(o.selectedMessageText),1)])),_:2},[e.$slots.loader?{name:"loader",fn:w((({options:i})=>[y(e.$slots,"loader",{options:i})]))}:void 0]),1040,["items","style","disabled"])],4),y(e.$slots,"footer",{value:t.modelValue,options:o.visibleOptions}),m("span",{ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:i[13]||(i[13]=(...e)=>o.onLastHiddenFocus&&o.onLastHiddenFocus(...e))},null,544)],16)):g("",!0)])),_:3},8,["onEnter","onAfterEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo"])],10,K)};export{C as default};
|
|
1
|
+
import{UniqueComponentId as e,ZIndexUtils as i,ObjectUtils as t,DomHandler as s,ConnectedOverlayScrollHandler as n}from"primevue/utils";import o from"primevue/overlayeventbus";import{FilterService as l}from"primevue/api";import a from"primevue/ripple";import r from"primevue/virtualscroller";import d from"primevue/portal";import{resolveComponent as p,resolveDirective as h,openBlock as u,createElementBlock as c,normalizeClass as f,mergeProps as b,renderSlot as y,createTextVNode as v,toDisplayString as O,createCommentVNode as g,createElementVNode as m,createVNode as x,withCtx as w,Transition as I,normalizeStyle as S,createSlots as V,Fragment as L,renderList as F,withDirectives as k}from"vue";var C={name:"Dropdown",emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:String,disabled:Boolean,dataKey:null,showClear:Boolean,inputId:String,inputStyle:null,inputClass:null,inputProps:null,panelStyle:null,panelClass:null,panelProps:null,filterInputProps:null,clearIconProps:null,appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:"pi pi-spinner pi-spin"},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},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},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,selectOnFocus:!1,focusOnHover:!1,data:()=>({id:e(),focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}),watch:{modelValue(){this.isModelValueChanged=!0},options(){this.autoUpdateModel()}},mounted(){this.id=this.$attrs.id||this.id,this.autoUpdateModel()},updated(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(i.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex(e,i){return this.virtualScrollerDisabled?e:i&&i(e).index},getOptionLabel(e){return this.optionLabel?t.resolveFieldData(e,this.optionLabel):e},getOptionValue(e){return this.optionValue?t.resolveFieldData(e,this.optionValue):e},getOptionRenderKey(e,i){return(this.dataKey?t.resolveFieldData(e,this.dataKey):this.getOptionLabel(e))+"_"+i},isOptionDisabled(e){return!!this.optionDisabled&&t.resolveFieldData(e,this.optionDisabled)},isOptionGroup(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel(e){return t.resolveFieldData(e,this.optionGroupLabel)},getOptionGroupChildren(e){return t.resolveFieldData(e,this.optionGroupChildren)},getAriaPosInset(e){return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((e=>this.isOptionGroup(e))).length:e)+1},show(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&this.$refs.focusInput.focus()},hide(e){const i=()=>{this.$emit("before-hide"),this.overlayVisible=!1,this.focusedOptionIndex=-1,this.searchValue="",e&&this.$refs.focusInput.focus()};setTimeout((()=>{i()}),0)},onFocus(e){this.focused=!0,this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown(e){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"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":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.isPrintableCharacter(e.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(e,e.key))}},onEditableInput(e){const i=e.target.value;this.searchValue="";!this.searchOptions(e,i)&&(this.focusedOptionIndex=-1),this.$emit("update:modelValue",i)},onContainerClick(e){this.disabled||this.loading||s.hasClass(e.target,"p-dropdown-clear-icon")||"INPUT"===e.target.tagName||this.overlay&&this.overlay.contains(e.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick(e){this.updateModel(e,null)},onFirstHiddenFocus(e){if(e.relatedTarget===this.$refs.focusInput){const e=s.getFirstFocusableElement(this.overlay,":not(.p-hidden-focusable)");e&&e.focus()}else this.$refs.focusInput.focus()},onLastHiddenFocus(){this.$refs.firstHiddenFocusableElementOnOverlay.focus()},onOptionSelect(e,i){const t=this.getOptionValue(i);this.updateModel(e,t),this.hide(!0)},onOptionMouseMove(e,i){this.focusOnHover&&this.changeFocusedOptionIndex(e,i)},onFilterChange(e){const i=e.target.value;this.filterValue=i,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:i}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur(){this.focusedOptionIndex=-1},onFilterUpdated(){this.overlayVisible&&this.alignOverlay()},onOverlayClick(e){o.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey(e){const i=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,i),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey(e,i=!1){if(e.altKey&&!i)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{const i=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,i),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey(e,i=!1){i&&(this.focusedOptionIndex=-1)},onHomeKey(e,i=!1){i?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey(e,i=!1){if(i){const i=e.currentTarget,t=i.value.length;i.setSelectionRange(t,t),this.focusedOptionIndex=-1}else this.changeFocusedOptionIndex(e,this.findLastOptionIndex()),!this.overlayVisible&&this.show();e.preventDefault()},onPageUpKey(e){this.scrollInView(0),e.preventDefault()},onPageDownKey(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey(e,i=!1){!i&&this.onEnterKey(e)},onEscapeKey(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey(e,i=!1){i||(this.overlayVisible&&this.hasFocusableElements()?(this.$refs.firstHiddenFocusableElementOnOverlay.focus(),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey(e,i=!1){i&&!this.overlayVisible&&this.show()},onOverlayEnter(e){i.set("overlay",e,this.$primevue.config.zIndex.overlay),this.alignOverlay(),this.scrollInView()},onOverlayAfterEnter(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave(e){i.clear(e)},alignOverlay(){"self"===this.appendTo?s.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=s.getOuterWidth(this.$el)+"px",s.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.overlay&&!this.$el.contains(e.target)&&!this.overlay.contains(e.target)&&this.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new n(this.$refs.container,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!s.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},hasFocusableElements(){return s.getFocusableElements(this.overlay,":not(.p-hidden-focusable)").length>0},isOptionMatched(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption(e){return e&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected(e){return t.equals(this.modelValue,this.getOptionValue(e),this.equalityKey)},findFirstOptionIndex(){return this.visibleOptions.findIndex((e=>this.isValidOption(e)))},findLastOptionIndex(){return t.findLastIndex(this.visibleOptions,(e=>this.isValidOption(e)))},findNextOptionIndex(e){const i=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((e=>this.isValidOption(e))):-1;return i>-1?i+e+1:e},findPrevOptionIndex(e){const i=e>0?t.findLastIndex(this.visibleOptions.slice(0,e),(e=>this.isValidOption(e))):-1;return i>-1?i:e},findSelectedOptionIndex(){return this.hasSelectedOption?this.visibleOptions.findIndex((e=>this.isValidSelectedOption(e))):-1},findFirstFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions(e,i){this.searchValue=(this.searchValue||"")+i;let t=-1,s=!1;return-1!==this.focusedOptionIndex?(t=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))),t=-1===t?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))):t+this.focusedOptionIndex):t=this.visibleOptions.findIndex((e=>this.isOptionMatched(e))),-1!==t&&(s=!0),-1===t&&-1===this.focusedOptionIndex&&(t=this.findFirstFocusedOptionIndex()),-1!==t&&this.changeFocusedOptionIndex(e,t),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),s},changeFocusedOptionIndex(e,i){this.focusedOptionIndex!==i&&(this.focusedOptionIndex=i,this.scrollInView(),this.selectOnFocus&&this.updateModel(e,this.getOptionValue(this.visibleOptions[i])))},scrollInView(e=-1){const i=-1!==e?`${this.id}_${e}`:this.focusedOptionId,t=s.findSingle(this.list,`li[id="${i}"]`);t?t.scrollIntoView&&t.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((()=>{this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==e?e:this.focusedOptionIndex)}),0)},autoUpdateModel(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();const e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,e)}},updateModel(e,i){this.$emit("update:modelValue",i),this.$emit("change",{originalEvent:e,value:i})},flatOptions(e){return(e||[]).reduce(((e,i,t)=>{e.push({optionGroup:i,group:!0,index:t});const s=this.getOptionGroupChildren(i);return s&&s.forEach((i=>e.push(i))),e}),[])},overlayRef(e){this.overlay=e},listRef(e,i){this.list=e,i&&i(e)},virtualScrollerRef(e){this.virtualScroller=e}},computed:{containerClass(){return["p-dropdown p-component p-inputwrapper",{"p-disabled":this.disabled,"p-dropdown-clearable":this.showClear&&!this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue,"p-inputwrapper-focus":this.focused||this.overlayVisible,"p-overlay-open":this.overlayVisible}]},inputStyleClass(){return["p-dropdown-label p-inputtext",this.inputClass,{"p-placeholder":!this.editable&&this.label===this.placeholder,"p-dropdown-label-empty":!(this.editable||this.$slots.value||"p-emptylabel"!==this.label&&0!==this.label.length)}]},panelStyleClass(){return["p-dropdown-panel p-component",this.panelClass,{"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},dropdownIconClass(){return["p-dropdown-trigger-icon",this.loading?this.loadingIcon:"pi pi-chevron-down"]},visibleOptions(){const e=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];return this.filterValue?l.filter(e,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale):e},hasSelectedOption(){return t.isNotEmpty(this.modelValue)},label(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey(){return this.optionValue?null:this.dataKey},searchFields(){return this.filterFields||[this.optionLabel]},filterResultMessageText(){return t.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId(){return-1!==this.focusedOptionIndex?`${this.id}_${this.focusedOptionIndex}`:null},ariaSetSize(){return this.visibleOptions.filter((e=>!this.isOptionGroup(e))).length},virtualScrollerDisabled(){return!this.virtualScrollerOptions}},directives:{ripple:a},components:{VirtualScroller:r,Portal:d}};const K=["id"],M=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],D=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],E={class:"p-dropdown-trigger"},$={key:0,class:"p-dropdown-header"},T={class:"p-dropdown-filter-container"},A=["value","placeholder","aria-owns","aria-activedescendant"],H=m("span",{class:"p-dropdown-filter-icon pi pi-search"},null,-1),P={role:"status","aria-live":"polite",class:"p-hidden-accessible"},B=["id"],z=["id"],R=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove"],G={key:0,class:"p-dropdown-empty-message",role:"option"},U={key:1,class:"p-dropdown-empty-message",role:"option"},_={key:0,role:"status","aria-live":"polite",class:"p-hidden-accessible"},N={role:"status","aria-live":"polite",class:"p-hidden-accessible"};!function(e,i){void 0===i&&(i={});var t=i.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===t&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}("\n.p-dropdown {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.p-dropdown-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-dropdown-trigger {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n.p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n}\n.p-dropdown-label-empty {\n overflow: hidden;\n opacity: 0;\n}\ninput.p-dropdown-label {\n cursor: default;\n}\n.p-dropdown .p-dropdown-panel {\n min-width: 100%;\n}\n.p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-dropdown-items-wrapper {\n overflow: auto;\n}\n.p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n}\n.p-dropdown-item-group {\n cursor: auto;\n}\n.p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n.p-dropdown-filter {\n width: 100%;\n}\n.p-dropdown-filter-container {\n position: relative;\n}\n.p-dropdown-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-fluid .p-dropdown {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n}\n"),C.render=function(e,i,t,s,n,o){const l=p("VirtualScroller"),a=p("Portal"),r=h("ripple");return u(),c("div",{ref:"container",id:n.id,class:f(o.containerClass),onClick:i[16]||(i[16]=(...e)=>o.onContainerClick&&o.onContainerClick(...e))},[t.editable?(u(),c("input",b({key:0,ref:"focusInput",id:t.inputId,type:"text",style:t.inputStyle,class:o.inputStyleClass,value:o.editableInputValue,placeholder:t.placeholder,tabindex:t.disabled?-1:t.tabindex,disabled:t.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":n.overlayVisible,"aria-controls":n.id+"_list","aria-activedescendant":n.focused?o.focusedOptionId:void 0,onFocus:i[0]||(i[0]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:i[1]||(i[1]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:i[2]||(i[2]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onInput:i[3]||(i[3]=(...e)=>o.onEditableInput&&o.onEditableInput(...e))},t.inputProps),null,16,M)):(u(),c("span",b({key:1,ref:"focusInput",id:t.inputId,style:t.inputStyle,class:o.inputStyleClass,tabindex:t.disabled?-1:t.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===o.label?void 0:o.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":n.overlayVisible,"aria-controls":n.id+"_list","aria-activedescendant":n.focused?o.focusedOptionId:void 0,"aria-disabled":t.disabled,onFocus:i[4]||(i[4]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:i[5]||(i[5]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:i[6]||(i[6]=(...e)=>o.onKeyDown&&o.onKeyDown(...e))},t.inputProps),[y(e.$slots,"value",{value:t.modelValue,placeholder:t.placeholder},(()=>[v(O("p-emptylabel"===o.label?" ":o.label||"empty"),1)]))],16,D)),t.showClear&&null!=t.modelValue?(u(),c("i",b({key:2,class:"p-dropdown-clear-icon pi pi-times",onClick:i[7]||(i[7]=(...e)=>o.onClearClick&&o.onClearClick(...e))},t.clearIconProps),null,16)):g("",!0),m("div",E,[y(e.$slots,"indicator",{},(()=>[m("span",{class:f(o.dropdownIconClass),"aria-hidden":"true"},null,2)]))]),x(a,{appendTo:t.appendTo},{default:w((()=>[x(I,{name:"p-connected-overlay",onEnter:o.onOverlayEnter,onAfterEnter:o.onOverlayAfterEnter,onLeave:o.onOverlayLeave,onAfterLeave:o.onOverlayAfterLeave},{default:w((()=>[n.overlayVisible?(u(),c("div",b({key:0,ref:o.overlayRef,style:t.panelStyle,class:o.panelStyleClass,onClick:i[14]||(i[14]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e)),onKeydown:i[15]||(i[15]=(...e)=>o.onOverlayKeyDown&&o.onOverlayKeyDown(...e))},t.panelProps),[m("span",{ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:i[8]||(i[8]=(...e)=>o.onFirstHiddenFocus&&o.onFirstHiddenFocus(...e))},null,544),y(e.$slots,"header",{value:t.modelValue,options:o.visibleOptions}),t.filter?(u(),c("div",$,[m("div",T,[m("input",b({type:"text",ref:"filterInput",value:n.filterValue,onVnodeUpdated:i[9]||(i[9]=(...e)=>o.onFilterUpdated&&o.onFilterUpdated(...e)),class:"p-dropdown-filter p-inputtext p-component",placeholder:t.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":n.id+"_list","aria-activedescendant":o.focusedOptionId,onKeydown:i[10]||(i[10]=(...e)=>o.onFilterKeyDown&&o.onFilterKeyDown(...e)),onBlur:i[11]||(i[11]=(...e)=>o.onFilterBlur&&o.onFilterBlur(...e)),onInput:i[12]||(i[12]=(...e)=>o.onFilterChange&&o.onFilterChange(...e))},t.filterInputProps),null,16,A),H]),m("span",P,O(o.filterResultMessageText),1)])):g("",!0),m("div",{class:"p-dropdown-items-wrapper",style:S({"max-height":o.virtualScrollerDisabled?t.scrollHeight:""})},[x(l,b({ref:o.virtualScrollerRef},t.virtualScrollerOptions,{items:o.visibleOptions,style:{height:t.scrollHeight},tabindex:-1,disabled:o.virtualScrollerDisabled}),V({content:w((({styleClass:i,contentRef:s,items:l,getItemOptions:a,contentStyle:d,itemSize:p})=>[m("ul",{ref:e=>o.listRef(e,s),id:n.id+"_list",class:f(["p-dropdown-items",i]),style:S(d),role:"listbox"},[(u(!0),c(L,null,F(l,((i,t)=>(u(),c(L,{key:o.getOptionRenderKey(i,o.getOptionIndex(t,a))},[o.isOptionGroup(i)?(u(),c("li",{key:0,id:n.id+"_"+o.getOptionIndex(t,a),style:S({height:p?p+"px":void 0}),class:"p-dropdown-item-group",role:"option"},[y(e.$slots,"optiongroup",{option:i.optionGroup,index:o.getOptionIndex(t,a)},(()=>[v(O(o.getOptionGroupLabel(i.optionGroup)),1)]))],12,z)):k((u(),c("li",{key:1,id:n.id+"_"+o.getOptionIndex(t,a),style:S({height:p?p+"px":void 0}),class:f(["p-dropdown-item",{"p-highlight":o.isSelected(i),"p-focus":n.focusedOptionIndex===o.getOptionIndex(t,a),"p-disabled":o.isOptionDisabled(i)}]),role:"option","aria-label":o.getOptionLabel(i),"aria-selected":o.isSelected(i),"aria-disabled":o.isOptionDisabled(i),"aria-setsize":o.ariaSetSize,"aria-posinset":o.getAriaPosInset(o.getOptionIndex(t,a)),onClick:e=>o.onOptionSelect(e,i),onMousemove:e=>o.onOptionMouseMove(e,o.getOptionIndex(t,a))},[y(e.$slots,"option",{option:i,index:o.getOptionIndex(t,a)},(()=>[v(O(o.getOptionLabel(i)),1)]))],46,R)),[[r]])],64)))),128)),n.filterValue&&(!l||l&&0===l.length)?(u(),c("li",G,[y(e.$slots,"emptyfilter",{},(()=>[v(O(o.emptyFilterMessageText),1)]))])):!t.options||t.options&&0===t.options.length?(u(),c("li",U,[y(e.$slots,"empty",{},(()=>[v(O(o.emptyMessageText),1)]))])):g("",!0)],14,B),!t.options||t.options&&0===t.options.length?(u(),c("span",_,O(o.emptyMessageText),1)):g("",!0),m("span",N,O(o.selectedMessageText),1)])),_:2},[e.$slots.loader?{name:"loader",fn:w((({options:i})=>[y(e.$slots,"loader",{options:i})]))}:void 0]),1040,["items","style","disabled"])],4),y(e.$slots,"footer",{value:t.modelValue,options:o.visibleOptions}),m("span",{ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:i[13]||(i[13]=(...e)=>o.onLastHiddenFocus&&o.onLastHiddenFocus(...e))},null,544)],16)):g("",!0)])),_:3},8,["onEnter","onAfterEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo"])],10,K)};export{C as default};
|
package/dropdown/dropdown.js
CHANGED
|
@@ -601,14 +601,14 @@ this.primevue.dropdown = (function (utils, OverlayEventBus, api, Ripple, Virtual
|
|
|
601
601
|
return this.visibleOptions.findIndex(option => this.isValidOption(option));
|
|
602
602
|
},
|
|
603
603
|
findLastOptionIndex() {
|
|
604
|
-
return
|
|
604
|
+
return utils.ObjectUtils.findLastIndex(this.visibleOptions, option => this.isValidOption(option));
|
|
605
605
|
},
|
|
606
606
|
findNextOptionIndex(index) {
|
|
607
607
|
const matchedOptionIndex = index < (this.visibleOptions.length - 1) ? this.visibleOptions.slice(index + 1).findIndex(option => this.isValidOption(option)) : -1;
|
|
608
608
|
return matchedOptionIndex > -1 ? matchedOptionIndex + index + 1 : index;
|
|
609
609
|
},
|
|
610
610
|
findPrevOptionIndex(index) {
|
|
611
|
-
const matchedOptionIndex = index > 0 ? this.visibleOptions.slice(0, index)
|
|
611
|
+
const matchedOptionIndex = index > 0 ? utils.ObjectUtils.findLastIndex(this.visibleOptions.slice(0, index), option => this.isValidOption(option)) : -1;
|
|
612
612
|
return matchedOptionIndex > -1 ? matchedOptionIndex : index;
|
|
613
613
|
},
|
|
614
614
|
findSelectedOptionIndex() {
|
package/dropdown/dropdown.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.dropdown=function(e,t,i,n,s,o,l){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(t),d=r(n),p=r(s),c=r(o),h={name:"Dropdown",emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:String,disabled:Boolean,dataKey:null,showClear:Boolean,inputId:String,inputStyle:null,inputClass:null,inputProps:null,panelStyle:null,panelClass:null,panelProps:null,filterInputProps:null,clearIconProps:null,appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:"pi pi-spinner pi-spin"},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},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},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,selectOnFocus:!1,focusOnHover:!1,data:()=>({id:e.UniqueComponentId(),focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}),watch:{modelValue(){this.isModelValueChanged=!0},options(){this.autoUpdateModel()}},mounted(){this.id=this.$attrs.id||this.id,this.autoUpdateModel()},updated(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(e.ZIndexUtils.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel(t){return this.optionLabel?e.ObjectUtils.resolveFieldData(t,this.optionLabel):t},getOptionValue(t){return this.optionValue?e.ObjectUtils.resolveFieldData(t,this.optionValue):t},getOptionRenderKey(t,i){return(this.dataKey?e.ObjectUtils.resolveFieldData(t,this.dataKey):this.getOptionLabel(t))+"_"+i},isOptionDisabled(t){return!!this.optionDisabled&&e.ObjectUtils.resolveFieldData(t,this.optionDisabled)},isOptionGroup(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupLabel)},getOptionGroupChildren(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupChildren)},getAriaPosInset(e){return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((e=>this.isOptionGroup(e))).length:e)+1},show(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&this.$refs.focusInput.focus()},hide(e){const t=()=>{this.$emit("before-hide"),this.overlayVisible=!1,this.focusedOptionIndex=-1,this.searchValue="",e&&this.$refs.focusInput.focus()};setTimeout((()=>{t()}),0)},onFocus(e){this.focused=!0,this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown(t){switch(t.code){case"ArrowDown":this.onArrowDownKey(t);break;case"ArrowUp":this.onArrowUpKey(t,this.editable);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(t,this.editable);break;case"Home":this.onHomeKey(t,this.editable);break;case"End":this.onEndKey(t,this.editable);break;case"PageDown":this.onPageDownKey(t);break;case"PageUp":this.onPageUpKey(t);break;case"Space":this.onSpaceKey(t,this.editable);break;case"Enter":this.onEnterKey(t);break;case"Escape":this.onEscapeKey(t);break;case"Tab":this.onTabKey(t);break;case"Backspace":this.onBackspaceKey(t,this.editable);break;case"ShiftLeft":case"ShiftRight":break;default:e.ObjectUtils.isPrintableCharacter(t.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(t,t.key))}},onEditableInput(e){const t=e.target.value;this.searchValue="";!this.searchOptions(e,t)&&(this.focusedOptionIndex=-1),this.$emit("update:modelValue",t)},onContainerClick(t){this.disabled||this.loading||e.DomHandler.hasClass(t.target,"p-dropdown-clear-icon")||"INPUT"===t.target.tagName||this.overlay&&this.overlay.contains(t.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick(e){this.updateModel(e,null)},onFirstHiddenFocus(t){if(t.relatedTarget===this.$refs.focusInput){const t=e.DomHandler.getFirstFocusableElement(this.overlay,":not(.p-hidden-focusable)");t&&t.focus()}else this.$refs.focusInput.focus()},onLastHiddenFocus(){this.$refs.firstHiddenFocusableElementOnOverlay.focus()},onOptionSelect(e,t){const i=this.getOptionValue(t);this.updateModel(e,i),this.hide(!0)},onOptionMouseMove(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onFilterChange(e){const t=e.target.value;this.filterValue=t,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:t}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur(){this.focusedOptionIndex=-1},onFilterUpdated(){this.overlayVisible&&this.alignOverlay()},onOverlayClick(e){a.default.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey(e){const t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey(e,t=!1){if(e.altKey&&!t)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{const t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey(e,t=!1){t&&(this.focusedOptionIndex=-1)},onHomeKey(e,t=!1){t?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey(e,t=!1){if(t){const 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(e){this.scrollInView(0),e.preventDefault()},onPageDownKey(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey(e,t=!1){!t&&this.onEnterKey(e)},onEscapeKey(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey(e,t=!1){t||(this.overlayVisible&&this.hasFocusableElements()?(this.$refs.firstHiddenFocusableElementOnOverlay.focus(),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey(e,t=!1){t&&!this.overlayVisible&&this.show()},onOverlayEnter(t){e.ZIndexUtils.set("overlay",t,this.$primevue.config.zIndex.overlay),this.alignOverlay(),this.scrollInView()},onOverlayAfterEnter(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave(t){e.ZIndexUtils.clear(t)},alignOverlay(){"self"===this.appendTo?e.DomHandler.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=e.DomHandler.getOuterWidth(this.$el)+"px",e.DomHandler.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.overlay&&!this.$el.contains(e.target)&&!this.overlay.contains(e.target)&&this.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new e.ConnectedOverlayScrollHandler(this.$refs.container,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!e.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},hasFocusableElements(){return e.DomHandler.getFocusableElements(this.overlay,":not(.p-hidden-focusable)").length>0},isOptionMatched(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption(e){return e&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected(t){return e.ObjectUtils.equals(this.modelValue,this.getOptionValue(t),this.equalityKey)},findFirstOptionIndex(){return this.visibleOptions.findIndex((e=>this.isValidOption(e)))},findLastOptionIndex(){return this.visibleOptions.findLastIndex((e=>this.isValidOption(e)))},findNextOptionIndex(e){const t=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((e=>this.isValidOption(e))):-1;return t>-1?t+e+1:e},findPrevOptionIndex(e){const t=e>0?this.visibleOptions.slice(0,e).findLastIndex((e=>this.isValidOption(e))):-1;return t>-1?t:e},findSelectedOptionIndex(){return this.hasSelectedOption?this.visibleOptions.findIndex((e=>this.isValidSelectedOption(e))):-1},findFirstFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,n=!1;return-1!==this.focusedOptionIndex?(i=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))),i=-1===i?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))):i+this.focusedOptionIndex):i=this.visibleOptions.findIndex((e=>this.isOptionMatched(e))),-1!==i&&(n=!0),-1===i&&-1===this.focusedOptionIndex&&(i=this.findFirstFocusedOptionIndex()),-1!==i&&this.changeFocusedOptionIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),n},changeFocusedOptionIndex(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView(),this.selectOnFocus&&this.updateModel(e,this.getOptionValue(this.visibleOptions[t])))},scrollInView(t=-1){const i=-1!==t?`${this.id}_${t}`:this.focusedOptionId,n=e.DomHandler.findSingle(this.list,`li[id="${i}"]`);n?n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((()=>{this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==t?t:this.focusedOptionIndex)}),0)},autoUpdateModel(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();const e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,e)}},updateModel(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions(e){return(e||[]).reduce(((e,t,i)=>{e.push({optionGroup:t,group:!0,index:i});const n=this.getOptionGroupChildren(t);return n&&n.forEach((t=>e.push(t))),e}),[])},overlayRef(e){this.overlay=e},listRef(e,t){this.list=e,t&&t(e)},virtualScrollerRef(e){this.virtualScroller=e}},computed:{containerClass(){return["p-dropdown p-component p-inputwrapper",{"p-disabled":this.disabled,"p-dropdown-clearable":this.showClear&&!this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue,"p-inputwrapper-focus":this.focused||this.overlayVisible,"p-overlay-open":this.overlayVisible}]},inputStyleClass(){return["p-dropdown-label p-inputtext",this.inputClass,{"p-placeholder":!this.editable&&this.label===this.placeholder,"p-dropdown-label-empty":!(this.editable||this.$slots.value||"p-emptylabel"!==this.label&&0!==this.label.length)}]},panelStyleClass(){return["p-dropdown-panel p-component",this.panelClass,{"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},dropdownIconClass(){return["p-dropdown-trigger-icon",this.loading?this.loadingIcon:"pi pi-chevron-down"]},visibleOptions(){const e=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];return this.filterValue?i.FilterService.filter(e,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale):e},hasSelectedOption(){return e.ObjectUtils.isNotEmpty(this.modelValue)},label(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey(){return this.optionValue?null:this.dataKey},searchFields(){return this.filterFields||[this.optionLabel]},filterResultMessageText(){return e.ObjectUtils.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId(){return-1!==this.focusedOptionIndex?`${this.id}_${this.focusedOptionIndex}`:null},ariaSetSize(){return this.visibleOptions.filter((e=>!this.isOptionGroup(e))).length},virtualScrollerDisabled(){return!this.virtualScrollerOptions}},directives:{ripple:d.default},components:{VirtualScroller:p.default,Portal:c.default}};const u=["id"],f=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],b=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],y={class:"p-dropdown-trigger"},v={key:0,class:"p-dropdown-header"},m={class:"p-dropdown-filter-container"},O=["value","placeholder","aria-owns","aria-activedescendant"],g=l.createElementVNode("span",{class:"p-dropdown-filter-icon pi pi-search"},null,-1),x={role:"status","aria-live":"polite",class:"p-hidden-accessible"},w=["id"],I=["id"],S=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove"],V={key:0,class:"p-dropdown-empty-message",role:"option"},k={key:1,class:"p-dropdown-empty-message",role:"option"},F={key:0,role:"status","aria-live":"polite",class:"p-hidden-accessible"},L={role:"status","aria-live":"polite",class:"p-hidden-accessible"};return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-dropdown {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.p-dropdown-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-dropdown-trigger {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n.p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n}\n.p-dropdown-label-empty {\n overflow: hidden;\n opacity: 0;\n}\ninput.p-dropdown-label {\n cursor: default;\n}\n.p-dropdown .p-dropdown-panel {\n min-width: 100%;\n}\n.p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-dropdown-items-wrapper {\n overflow: auto;\n}\n.p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n}\n.p-dropdown-item-group {\n cursor: auto;\n}\n.p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n.p-dropdown-filter {\n width: 100%;\n}\n.p-dropdown-filter-container {\n position: relative;\n}\n.p-dropdown-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-fluid .p-dropdown {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n}\n"),h.render=function(e,t,i,n,s,o){const r=l.resolveComponent("VirtualScroller"),a=l.resolveComponent("Portal"),d=l.resolveDirective("ripple");return l.openBlock(),l.createElementBlock("div",{ref:"container",id:s.id,class:l.normalizeClass(o.containerClass),onClick:t[16]||(t[16]=(...e)=>o.onContainerClick&&o.onContainerClick(...e))},[i.editable?(l.openBlock(),l.createElementBlock("input",l.mergeProps({key:0,ref:"focusInput",id:i.inputId,type:"text",style:i.inputStyle,class:o.inputStyleClass,value:o.editableInputValue,placeholder:i.placeholder,tabindex:i.disabled?-1:i.tabindex,disabled:i.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,onFocus:t[0]||(t[0]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onInput:t[3]||(t[3]=(...e)=>o.onEditableInput&&o.onEditableInput(...e))},i.inputProps),null,16,f)):(l.openBlock(),l.createElementBlock("span",l.mergeProps({key:1,ref:"focusInput",id:i.inputId,style:i.inputStyle,class:o.inputStyleClass,tabindex:i.disabled?-1:i.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===o.label?void 0:o.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,"aria-disabled":i.disabled,onFocus:t[4]||(t[4]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[5]||(t[5]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[6]||(t[6]=(...e)=>o.onKeyDown&&o.onKeyDown(...e))},i.inputProps),[l.renderSlot(e.$slots,"value",{value:i.modelValue,placeholder:i.placeholder},(()=>[l.createTextVNode(l.toDisplayString("p-emptylabel"===o.label?" ":o.label||"empty"),1)]))],16,b)),i.showClear&&null!=i.modelValue?(l.openBlock(),l.createElementBlock("i",l.mergeProps({key:2,class:"p-dropdown-clear-icon pi pi-times",onClick:t[7]||(t[7]=(...e)=>o.onClearClick&&o.onClearClick(...e))},i.clearIconProps),null,16)):l.createCommentVNode("",!0),l.createElementVNode("div",y,[l.renderSlot(e.$slots,"indicator",{},(()=>[l.createElementVNode("span",{class:l.normalizeClass(o.dropdownIconClass),"aria-hidden":"true"},null,2)]))]),l.createVNode(a,{appendTo:i.appendTo},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onOverlayEnter,onAfterEnter:o.onOverlayAfterEnter,onLeave:o.onOverlayLeave,onAfterLeave:o.onOverlayAfterLeave},{default:l.withCtx((()=>[s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,ref:o.overlayRef,style:i.panelStyle,class:o.panelStyleClass,onClick:t[14]||(t[14]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e)),onKeydown:t[15]||(t[15]=(...e)=>o.onOverlayKeyDown&&o.onOverlayKeyDown(...e))},i.panelProps),[l.createElementVNode("span",{ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[8]||(t[8]=(...e)=>o.onFirstHiddenFocus&&o.onFirstHiddenFocus(...e))},null,544),l.renderSlot(e.$slots,"header",{value:i.modelValue,options:o.visibleOptions}),i.filter?(l.openBlock(),l.createElementBlock("div",v,[l.createElementVNode("div",m,[l.createElementVNode("input",l.mergeProps({type:"text",ref:"filterInput",value:s.filterValue,onVnodeUpdated:t[9]||(t[9]=(...e)=>o.onFilterUpdated&&o.onFilterUpdated(...e)),class:"p-dropdown-filter p-inputtext p-component",placeholder:i.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":s.id+"_list","aria-activedescendant":o.focusedOptionId,onKeydown:t[10]||(t[10]=(...e)=>o.onFilterKeyDown&&o.onFilterKeyDown(...e)),onBlur:t[11]||(t[11]=(...e)=>o.onFilterBlur&&o.onFilterBlur(...e)),onInput:t[12]||(t[12]=(...e)=>o.onFilterChange&&o.onFilterChange(...e))},i.filterInputProps),null,16,O),g]),l.createElementVNode("span",x,l.toDisplayString(o.filterResultMessageText),1)])):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"p-dropdown-items-wrapper",style:l.normalizeStyle({"max-height":o.virtualScrollerDisabled?i.scrollHeight:""})},[l.createVNode(r,l.mergeProps({ref:o.virtualScrollerRef},i.virtualScrollerOptions,{items:o.visibleOptions,style:{height:i.scrollHeight},tabindex:-1,disabled:o.virtualScrollerDisabled}),l.createSlots({content:l.withCtx((({styleClass:t,contentRef:n,items:r,getItemOptions:a,contentStyle:p,itemSize:c})=>[l.createElementVNode("ul",{ref:e=>o.listRef(e,n),id:s.id+"_list",class:l.normalizeClass(["p-dropdown-items",t]),style:l.normalizeStyle(p),role:"listbox"},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(r,((t,i)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.getOptionRenderKey(t,o.getOptionIndex(i,a))},[o.isOptionGroup(t)?(l.openBlock(),l.createElementBlock("li",{key:0,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:"p-dropdown-item-group",role:"option"},[l.renderSlot(e.$slots,"optiongroup",{option:t.optionGroup,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionGroupLabel(t.optionGroup)),1)]))],12,I)):l.withDirectives((l.openBlock(),l.createElementBlock("li",{key:1,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:l.normalizeClass(["p-dropdown-item",{"p-highlight":o.isSelected(t),"p-focus":s.focusedOptionIndex===o.getOptionIndex(i,a),"p-disabled":o.isOptionDisabled(t)}]),role:"option","aria-label":o.getOptionLabel(t),"aria-selected":o.isSelected(t),"aria-disabled":o.isOptionDisabled(t),"aria-setsize":o.ariaSetSize,"aria-posinset":o.getAriaPosInset(o.getOptionIndex(i,a)),onClick:e=>o.onOptionSelect(e,t),onMousemove:e=>o.onOptionMouseMove(e,o.getOptionIndex(i,a))},[l.renderSlot(e.$slots,"option",{option:t,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionLabel(t)),1)]))],46,S)),[[d]])],64)))),128)),s.filterValue&&(!r||r&&0===r.length)?(l.openBlock(),l.createElementBlock("li",V,[l.renderSlot(e.$slots,"emptyfilter",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyFilterMessageText),1)]))])):!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("li",k,[l.renderSlot(e.$slots,"empty",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyMessageText),1)]))])):l.createCommentVNode("",!0)],14,w),!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("span",F,l.toDisplayString(o.emptyMessageText),1)):l.createCommentVNode("",!0),l.createElementVNode("span",L,l.toDisplayString(o.selectedMessageText),1)])),_:2},[e.$slots.loader?{name:"loader",fn:l.withCtx((({options:t})=>[l.renderSlot(e.$slots,"loader",{options:t})]))}:void 0]),1040,["items","style","disabled"])],4),l.renderSlot(e.$slots,"footer",{value:i.modelValue,options:o.visibleOptions}),l.createElementVNode("span",{ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[13]||(t[13]=(...e)=>o.onLastHiddenFocus&&o.onLastHiddenFocus(...e))},null,544)],16)):l.createCommentVNode("",!0)])),_:3},8,["onEnter","onAfterEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo"])],10,u)},h}(primevue.utils,primevue.overlayeventbus,primevue.api,primevue.ripple,primevue.virtualscroller,primevue.portal,Vue);
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.dropdown=function(e,t,i,n,s,o,l){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(t),d=r(n),p=r(s),c=r(o),h={name:"Dropdown",emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter"],props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},editable:Boolean,placeholder:String,disabled:Boolean,dataKey:null,showClear:Boolean,inputId:String,inputStyle:null,inputClass:null,inputProps:null,panelStyle:null,panelClass:null,panelProps:null,filterInputProps:null,clearIconProps:null,appendTo:{type:String,default:"body"},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:"pi pi-spinner pi-spin"},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},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},"aria-label":{type:String,default:null},"aria-labelledby":{type:String,default:null}},outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,searchTimeout:null,searchValue:null,isModelValueChanged:!1,selectOnFocus:!1,focusOnHover:!1,data:()=>({id:e.UniqueComponentId(),focused:!1,focusedOptionIndex:-1,filterValue:null,overlayVisible:!1}),watch:{modelValue(){this.isModelValueChanged=!0},options(){this.autoUpdateModel()}},mounted(){this.id=this.$attrs.id||this.id,this.autoUpdateModel()},updated(){this.overlayVisible&&this.isModelValueChanged&&this.scrollInView(this.findSelectedOptionIndex()),this.isModelValueChanged=!1},beforeUnmount(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(e.ZIndexUtils.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel(t){return this.optionLabel?e.ObjectUtils.resolveFieldData(t,this.optionLabel):t},getOptionValue(t){return this.optionValue?e.ObjectUtils.resolveFieldData(t,this.optionValue):t},getOptionRenderKey(t,i){return(this.dataKey?e.ObjectUtils.resolveFieldData(t,this.dataKey):this.getOptionLabel(t))+"_"+i},isOptionDisabled(t){return!!this.optionDisabled&&e.ObjectUtils.resolveFieldData(t,this.optionDisabled)},isOptionGroup(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupLabel)},getOptionGroupChildren(t){return e.ObjectUtils.resolveFieldData(t,this.optionGroupChildren)},getAriaPosInset(e){return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((e=>this.isOptionGroup(e))).length:e)+1},show(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&this.$refs.focusInput.focus()},hide(e){const t=()=>{this.$emit("before-hide"),this.overlayVisible=!1,this.focusedOptionIndex=-1,this.searchValue="",e&&this.$refs.focusInput.focus()};setTimeout((()=>{t()}),0)},onFocus(e){this.focused=!0,this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown(t){switch(t.code){case"ArrowDown":this.onArrowDownKey(t);break;case"ArrowUp":this.onArrowUpKey(t,this.editable);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(t,this.editable);break;case"Home":this.onHomeKey(t,this.editable);break;case"End":this.onEndKey(t,this.editable);break;case"PageDown":this.onPageDownKey(t);break;case"PageUp":this.onPageUpKey(t);break;case"Space":this.onSpaceKey(t,this.editable);break;case"Enter":this.onEnterKey(t);break;case"Escape":this.onEscapeKey(t);break;case"Tab":this.onTabKey(t);break;case"Backspace":this.onBackspaceKey(t,this.editable);break;case"ShiftLeft":case"ShiftRight":break;default:e.ObjectUtils.isPrintableCharacter(t.key)&&(!this.overlayVisible&&this.show(),!this.editable&&this.searchOptions(t,t.key))}},onEditableInput(e){const t=e.target.value;this.searchValue="";!this.searchOptions(e,t)&&(this.focusedOptionIndex=-1),this.$emit("update:modelValue",t)},onContainerClick(t){this.disabled||this.loading||e.DomHandler.hasClass(t.target,"p-dropdown-clear-icon")||"INPUT"===t.target.tagName||this.overlay&&this.overlay.contains(t.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onClearClick(e){this.updateModel(e,null)},onFirstHiddenFocus(t){if(t.relatedTarget===this.$refs.focusInput){const t=e.DomHandler.getFirstFocusableElement(this.overlay,":not(.p-hidden-focusable)");t&&t.focus()}else this.$refs.focusInput.focus()},onLastHiddenFocus(){this.$refs.firstHiddenFocusableElementOnOverlay.focus()},onOptionSelect(e,t){const i=this.getOptionValue(t);this.updateModel(e,i),this.hide(!0)},onOptionMouseMove(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onFilterChange(e){const t=e.target.value;this.filterValue=t,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:t}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur(){this.focusedOptionIndex=-1},onFilterUpdated(){this.overlayVisible&&this.alignOverlay()},onOverlayClick(e){a.default.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey(e){const t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey(e,t=!1){if(e.altKey&&!t)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{const t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey(e,t=!1){t&&(this.focusedOptionIndex=-1)},onHomeKey(e,t=!1){t?(e.currentTarget.setSelectionRange(0,0),this.focusedOptionIndex=-1):(this.changeFocusedOptionIndex(e,this.findFirstOptionIndex()),!this.overlayVisible&&this.show()),e.preventDefault()},onEndKey(e,t=!1){if(t){const 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(e){this.scrollInView(0),e.preventDefault()},onPageDownKey(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onSpaceKey(e,t=!1){!t&&this.onEnterKey(e)},onEscapeKey(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey(e,t=!1){t||(this.overlayVisible&&this.hasFocusableElements()?(this.$refs.firstHiddenFocusableElementOnOverlay.focus(),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onBackspaceKey(e,t=!1){t&&!this.overlayVisible&&this.show()},onOverlayEnter(t){e.ZIndexUtils.set("overlay",t,this.$primevue.config.zIndex.overlay),this.alignOverlay(),this.scrollInView()},onOverlayAfterEnter(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave(t){e.ZIndexUtils.clear(t)},alignOverlay(){"self"===this.appendTo?e.DomHandler.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=e.DomHandler.getOuterWidth(this.$el)+"px",e.DomHandler.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{this.overlayVisible&&this.overlay&&!this.$el.contains(e.target)&&!this.overlay.contains(e.target)&&this.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener(){this.scrollHandler||(this.scrollHandler=new e.ConnectedOverlayScrollHandler(this.$refs.container,(()=>{this.overlayVisible&&this.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener(){this.resizeListener||(this.resizeListener=()=>{this.overlayVisible&&!e.DomHandler.isTouchDevice()&&this.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},hasFocusableElements(){return e.DomHandler.getFocusableElements(this.overlay,":not(.p-hidden-focusable)").length>0},isOptionMatched(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption(e){return e&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected(t){return e.ObjectUtils.equals(this.modelValue,this.getOptionValue(t),this.equalityKey)},findFirstOptionIndex(){return this.visibleOptions.findIndex((e=>this.isValidOption(e)))},findLastOptionIndex(){return e.ObjectUtils.findLastIndex(this.visibleOptions,(e=>this.isValidOption(e)))},findNextOptionIndex(e){const t=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((e=>this.isValidOption(e))):-1;return t>-1?t+e+1:e},findPrevOptionIndex(t){const i=t>0?e.ObjectUtils.findLastIndex(this.visibleOptions.slice(0,t),(e=>this.isValidOption(e))):-1;return i>-1?i:t},findSelectedOptionIndex(){return this.hasSelectedOption?this.visibleOptions.findIndex((e=>this.isValidSelectedOption(e))):-1},findFirstFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex(){const e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,n=!1;return-1!==this.focusedOptionIndex?(i=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))),i=-1===i?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((e=>this.isOptionMatched(e))):i+this.focusedOptionIndex):i=this.visibleOptions.findIndex((e=>this.isOptionMatched(e))),-1!==i&&(n=!0),-1===i&&-1===this.focusedOptionIndex&&(i=this.findFirstFocusedOptionIndex()),-1!==i&&this.changeFocusedOptionIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((()=>{this.searchValue="",this.searchTimeout=null}),500),n},changeFocusedOptionIndex(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView(),this.selectOnFocus&&this.updateModel(e,this.getOptionValue(this.visibleOptions[t])))},scrollInView(t=-1){const i=-1!==t?`${this.id}_${t}`:this.focusedOptionId,n=e.DomHandler.findSingle(this.list,`li[id="${i}"]`);n?n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((()=>{this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==t?t:this.focusedOptionIndex)}),0)},autoUpdateModel(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();const e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,e)}},updateModel(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions(e){return(e||[]).reduce(((e,t,i)=>{e.push({optionGroup:t,group:!0,index:i});const n=this.getOptionGroupChildren(t);return n&&n.forEach((t=>e.push(t))),e}),[])},overlayRef(e){this.overlay=e},listRef(e,t){this.list=e,t&&t(e)},virtualScrollerRef(e){this.virtualScroller=e}},computed:{containerClass(){return["p-dropdown p-component p-inputwrapper",{"p-disabled":this.disabled,"p-dropdown-clearable":this.showClear&&!this.disabled,"p-focus":this.focused,"p-inputwrapper-filled":this.modelValue,"p-inputwrapper-focus":this.focused||this.overlayVisible,"p-overlay-open":this.overlayVisible}]},inputStyleClass(){return["p-dropdown-label p-inputtext",this.inputClass,{"p-placeholder":!this.editable&&this.label===this.placeholder,"p-dropdown-label-empty":!(this.editable||this.$slots.value||"p-emptylabel"!==this.label&&0!==this.label.length)}]},panelStyleClass(){return["p-dropdown-panel p-component",this.panelClass,{"p-input-filled":"filled"===this.$primevue.config.inputStyle,"p-ripple-disabled":!1===this.$primevue.config.ripple}]},dropdownIconClass(){return["p-dropdown-trigger-icon",this.loading?this.loadingIcon:"pi pi-chevron-down"]},visibleOptions(){const e=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];return this.filterValue?i.FilterService.filter(e,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale):e},hasSelectedOption(){return e.ObjectUtils.isNotEmpty(this.modelValue)},label(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.placeholder||"p-emptylabel"},editableInputValue(){const e=this.findSelectedOptionIndex();return-1!==e?this.getOptionLabel(this.visibleOptions[e]):this.modelValue||""},equalityKey(){return this.optionValue?null:this.dataKey},searchFields(){return this.filterFields||[this.optionLabel]},filterResultMessageText(){return e.ObjectUtils.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}","1"):this.emptySelectionMessageText},focusedOptionId(){return-1!==this.focusedOptionIndex?`${this.id}_${this.focusedOptionIndex}`:null},ariaSetSize(){return this.visibleOptions.filter((e=>!this.isOptionGroup(e))).length},virtualScrollerDisabled(){return!this.virtualScrollerOptions}},directives:{ripple:d.default},components:{VirtualScroller:p.default,Portal:c.default}};const u=["id"],f=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],b=["id","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant","aria-disabled"],y={class:"p-dropdown-trigger"},v={key:0,class:"p-dropdown-header"},m={class:"p-dropdown-filter-container"},O=["value","placeholder","aria-owns","aria-activedescendant"],g=l.createElementVNode("span",{class:"p-dropdown-filter-icon pi pi-search"},null,-1),x={role:"status","aria-live":"polite",class:"p-hidden-accessible"},w=["id"],I=["id"],S=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove"],V={key:0,class:"p-dropdown-empty-message",role:"option"},k={key:1,class:"p-dropdown-empty-message",role:"option"},F={key:0,role:"status","aria-live":"polite",class:"p-hidden-accessible"},L={role:"status","aria-live":"polite",class:"p-hidden-accessible"};return function(e,t){void 0===t&&(t={});var i=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&n.firstChild?n.insertBefore(s,n.firstChild):n.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}("\n.p-dropdown {\n display: -webkit-inline-box;\n display: -ms-inline-flexbox;\n display: inline-flex;\n cursor: pointer;\n position: relative;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n.p-dropdown-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-dropdown-trigger {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n}\n.p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n}\n.p-dropdown-label-empty {\n overflow: hidden;\n opacity: 0;\n}\ninput.p-dropdown-label {\n cursor: default;\n}\n.p-dropdown .p-dropdown-panel {\n min-width: 100%;\n}\n.p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n}\n.p-dropdown-items-wrapper {\n overflow: auto;\n}\n.p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n}\n.p-dropdown-item-group {\n cursor: auto;\n}\n.p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n.p-dropdown-filter {\n width: 100%;\n}\n.p-dropdown-filter-container {\n position: relative;\n}\n.p-dropdown-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n}\n.p-fluid .p-dropdown {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n}\n.p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n}\n"),h.render=function(e,t,i,n,s,o){const r=l.resolveComponent("VirtualScroller"),a=l.resolveComponent("Portal"),d=l.resolveDirective("ripple");return l.openBlock(),l.createElementBlock("div",{ref:"container",id:s.id,class:l.normalizeClass(o.containerClass),onClick:t[16]||(t[16]=(...e)=>o.onContainerClick&&o.onContainerClick(...e))},[i.editable?(l.openBlock(),l.createElementBlock("input",l.mergeProps({key:0,ref:"focusInput",id:i.inputId,type:"text",style:i.inputStyle,class:o.inputStyleClass,value:o.editableInputValue,placeholder:i.placeholder,tabindex:i.disabled?-1:i.tabindex,disabled:i.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,onFocus:t[0]||(t[0]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[1]||(t[1]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[2]||(t[2]=(...e)=>o.onKeyDown&&o.onKeyDown(...e)),onInput:t[3]||(t[3]=(...e)=>o.onEditableInput&&o.onEditableInput(...e))},i.inputProps),null,16,f)):(l.openBlock(),l.createElementBlock("span",l.mergeProps({key:1,ref:"focusInput",id:i.inputId,style:i.inputStyle,class:o.inputStyleClass,tabindex:i.disabled?-1:i.tabindex,role:"combobox","aria-label":e.ariaLabel||("p-emptylabel"===o.label?void 0:o.label),"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":s.overlayVisible,"aria-controls":s.id+"_list","aria-activedescendant":s.focused?o.focusedOptionId:void 0,"aria-disabled":i.disabled,onFocus:t[4]||(t[4]=(...e)=>o.onFocus&&o.onFocus(...e)),onBlur:t[5]||(t[5]=(...e)=>o.onBlur&&o.onBlur(...e)),onKeydown:t[6]||(t[6]=(...e)=>o.onKeyDown&&o.onKeyDown(...e))},i.inputProps),[l.renderSlot(e.$slots,"value",{value:i.modelValue,placeholder:i.placeholder},(()=>[l.createTextVNode(l.toDisplayString("p-emptylabel"===o.label?" ":o.label||"empty"),1)]))],16,b)),i.showClear&&null!=i.modelValue?(l.openBlock(),l.createElementBlock("i",l.mergeProps({key:2,class:"p-dropdown-clear-icon pi pi-times",onClick:t[7]||(t[7]=(...e)=>o.onClearClick&&o.onClearClick(...e))},i.clearIconProps),null,16)):l.createCommentVNode("",!0),l.createElementVNode("div",y,[l.renderSlot(e.$slots,"indicator",{},(()=>[l.createElementVNode("span",{class:l.normalizeClass(o.dropdownIconClass),"aria-hidden":"true"},null,2)]))]),l.createVNode(a,{appendTo:i.appendTo},{default:l.withCtx((()=>[l.createVNode(l.Transition,{name:"p-connected-overlay",onEnter:o.onOverlayEnter,onAfterEnter:o.onOverlayAfterEnter,onLeave:o.onOverlayLeave,onAfterLeave:o.onOverlayAfterLeave},{default:l.withCtx((()=>[s.overlayVisible?(l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,ref:o.overlayRef,style:i.panelStyle,class:o.panelStyleClass,onClick:t[14]||(t[14]=(...e)=>o.onOverlayClick&&o.onOverlayClick(...e)),onKeydown:t[15]||(t[15]=(...e)=>o.onOverlayKeyDown&&o.onOverlayKeyDown(...e))},i.panelProps),[l.createElementVNode("span",{ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[8]||(t[8]=(...e)=>o.onFirstHiddenFocus&&o.onFirstHiddenFocus(...e))},null,544),l.renderSlot(e.$slots,"header",{value:i.modelValue,options:o.visibleOptions}),i.filter?(l.openBlock(),l.createElementBlock("div",v,[l.createElementVNode("div",m,[l.createElementVNode("input",l.mergeProps({type:"text",ref:"filterInput",value:s.filterValue,onVnodeUpdated:t[9]||(t[9]=(...e)=>o.onFilterUpdated&&o.onFilterUpdated(...e)),class:"p-dropdown-filter p-inputtext p-component",placeholder:i.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":s.id+"_list","aria-activedescendant":o.focusedOptionId,onKeydown:t[10]||(t[10]=(...e)=>o.onFilterKeyDown&&o.onFilterKeyDown(...e)),onBlur:t[11]||(t[11]=(...e)=>o.onFilterBlur&&o.onFilterBlur(...e)),onInput:t[12]||(t[12]=(...e)=>o.onFilterChange&&o.onFilterChange(...e))},i.filterInputProps),null,16,O),g]),l.createElementVNode("span",x,l.toDisplayString(o.filterResultMessageText),1)])):l.createCommentVNode("",!0),l.createElementVNode("div",{class:"p-dropdown-items-wrapper",style:l.normalizeStyle({"max-height":o.virtualScrollerDisabled?i.scrollHeight:""})},[l.createVNode(r,l.mergeProps({ref:o.virtualScrollerRef},i.virtualScrollerOptions,{items:o.visibleOptions,style:{height:i.scrollHeight},tabindex:-1,disabled:o.virtualScrollerDisabled}),l.createSlots({content:l.withCtx((({styleClass:t,contentRef:n,items:r,getItemOptions:a,contentStyle:p,itemSize:c})=>[l.createElementVNode("ul",{ref:e=>o.listRef(e,n),id:s.id+"_list",class:l.normalizeClass(["p-dropdown-items",t]),style:l.normalizeStyle(p),role:"listbox"},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(r,((t,i)=>(l.openBlock(),l.createElementBlock(l.Fragment,{key:o.getOptionRenderKey(t,o.getOptionIndex(i,a))},[o.isOptionGroup(t)?(l.openBlock(),l.createElementBlock("li",{key:0,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:"p-dropdown-item-group",role:"option"},[l.renderSlot(e.$slots,"optiongroup",{option:t.optionGroup,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionGroupLabel(t.optionGroup)),1)]))],12,I)):l.withDirectives((l.openBlock(),l.createElementBlock("li",{key:1,id:s.id+"_"+o.getOptionIndex(i,a),style:l.normalizeStyle({height:c?c+"px":void 0}),class:l.normalizeClass(["p-dropdown-item",{"p-highlight":o.isSelected(t),"p-focus":s.focusedOptionIndex===o.getOptionIndex(i,a),"p-disabled":o.isOptionDisabled(t)}]),role:"option","aria-label":o.getOptionLabel(t),"aria-selected":o.isSelected(t),"aria-disabled":o.isOptionDisabled(t),"aria-setsize":o.ariaSetSize,"aria-posinset":o.getAriaPosInset(o.getOptionIndex(i,a)),onClick:e=>o.onOptionSelect(e,t),onMousemove:e=>o.onOptionMouseMove(e,o.getOptionIndex(i,a))},[l.renderSlot(e.$slots,"option",{option:t,index:o.getOptionIndex(i,a)},(()=>[l.createTextVNode(l.toDisplayString(o.getOptionLabel(t)),1)]))],46,S)),[[d]])],64)))),128)),s.filterValue&&(!r||r&&0===r.length)?(l.openBlock(),l.createElementBlock("li",V,[l.renderSlot(e.$slots,"emptyfilter",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyFilterMessageText),1)]))])):!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("li",k,[l.renderSlot(e.$slots,"empty",{},(()=>[l.createTextVNode(l.toDisplayString(o.emptyMessageText),1)]))])):l.createCommentVNode("",!0)],14,w),!i.options||i.options&&0===i.options.length?(l.openBlock(),l.createElementBlock("span",F,l.toDisplayString(o.emptyMessageText),1)):l.createCommentVNode("",!0),l.createElementVNode("span",L,l.toDisplayString(o.selectedMessageText),1)])),_:2},[e.$slots.loader?{name:"loader",fn:l.withCtx((({options:t})=>[l.renderSlot(e.$slots,"loader",{options:t})]))}:void 0]),1040,["items","style","disabled"])],4),l.renderSlot(e.$slots,"footer",{value:i.modelValue,options:o.visibleOptions}),l.createElementVNode("span",{ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[13]||(t[13]=(...e)=>o.onLastHiddenFocus&&o.onLastHiddenFocus(...e))},null,544)],16)):l.createCommentVNode("",!0)])),_:3},8,["onEnter","onAfterEnter","onLeave","onAfterLeave"])])),_:3},8,["appendTo"])],10,u)},h}(primevue.utils,primevue.overlayeventbus,primevue.api,primevue.ripple,primevue.virtualscroller,primevue.portal,Vue);
|
|
@@ -144,7 +144,7 @@ export interface InputNumberProps {
|
|
|
144
144
|
/**
|
|
145
145
|
* Placeholder text for the input.
|
|
146
146
|
*/
|
|
147
|
-
placeholder?:
|
|
147
|
+
placeholder?: string | undefined;
|
|
148
148
|
/**
|
|
149
149
|
* Identifier of the focus input to match a label defined for the chips.
|
|
150
150
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<span :class="containerClass">
|
|
3
|
-
<INInputText ref="input" class="p-inputnumber-input" role="spinbutton" :id="inputId" :class="inputClass" :style="inputStyle" :value="formattedValue" :aria-valuemin="min" :aria-valuemax="max" :aria-valuenow="modelValue" :readonly="readonly" :placeholder="placeholder" :aria-labelledby="ariaLabelledby" :aria-label="ariaLabel"
|
|
3
|
+
<INInputText ref="input" class="p-inputnumber-input" role="spinbutton" :id="inputId" :class="inputClass" :style="inputStyle" :value="formattedValue" :aria-valuemin="min" :aria-valuemax="max" :aria-valuenow="modelValue" :disabled="disabled" :readonly="readonly" :placeholder="placeholder" :aria-labelledby="ariaLabelledby" :aria-label="ariaLabel"
|
|
4
4
|
@input="onUserInput" @keydown="onInputKeyDown" @keypress="onInputKeyPress" @paste="onPaste" @click="onInputClick" @focus="onInputFocus" @blur="onInputBlur" v-bind="inputProps"/>
|
|
5
5
|
<span class="p-inputnumber-button-group" v-if="showButtons && buttonLayout === 'stacked'">
|
|
6
6
|
<INButton :class="upButtonClass" :icon="incrementButtonIcon" v-on="upButtonListeners" :disabled="disabled" :tabindex="-1" aria-hidden="true" v-bind="incrementButtonProps" />
|
|
@@ -1047,6 +1047,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1047
1047
|
"aria-valuemin": $props.min,
|
|
1048
1048
|
"aria-valuemax": $props.max,
|
|
1049
1049
|
"aria-valuenow": $props.modelValue,
|
|
1050
|
+
disabled: $props.disabled,
|
|
1050
1051
|
readonly: $props.readonly,
|
|
1051
1052
|
placeholder: $props.placeholder,
|
|
1052
1053
|
"aria-labelledby": _ctx.ariaLabelledby,
|
|
@@ -1058,7 +1059,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1058
1059
|
onClick: $options.onInputClick,
|
|
1059
1060
|
onFocus: $options.onInputFocus,
|
|
1060
1061
|
onBlur: $options.onInputBlur
|
|
1061
|
-
}, $props.inputProps), null, 16, ["id", "class", "style", "value", "aria-valuemin", "aria-valuemax", "aria-valuenow", "readonly", "placeholder", "aria-labelledby", "aria-label", "onInput", "onKeydown", "onKeypress", "onPaste", "onClick", "onFocus", "onBlur"]),
|
|
1062
|
+
}, $props.inputProps), null, 16, ["id", "class", "style", "value", "aria-valuemin", "aria-valuemax", "aria-valuenow", "disabled", "readonly", "placeholder", "aria-labelledby", "aria-label", "onInput", "onKeydown", "onKeypress", "onPaste", "onClick", "onFocus", "onBlur"]),
|
|
1062
1063
|
($props.showButtons && $props.buttonLayout === 'stacked')
|
|
1063
1064
|
? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, [
|
|
1064
1065
|
vue.createVNode(_component_INButton, vue.mergeProps({
|