UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

2 lines (1 loc) 37.4 kB
import{FilterService as e}from"primevue/api";import t from"primevue/icons/check";import i from"primevue/icons/chevrondown";import n from"primevue/icons/search";import o from"primevue/icons/spinner";import s from"primevue/icons/times";import l from"primevue/icons/timescircle";import r from"primevue/overlayeventbus";import a from"primevue/portal";import c from"primevue/ripple";import{UniqueComponentId as u,ZIndexUtils as d,ObjectUtils as p,DomHandler as h,ConnectedOverlayScrollHandler as f}from"primevue/utils";import b from"primevue/virtualscroller";import v from"primevue/basecomponent";import y from"primevue/multiselect/style";import{resolveComponent as m,resolveDirective as O,openBlock as g,createElementBlock as x,mergeProps as I,createElementVNode as S,renderSlot as k,Fragment as L,createTextVNode as V,toDisplayString as F,renderList as w,normalizeClass as C,withModifiers as K,createBlock as M,createCommentVNode as T,resolveDynamicComponent as D,createVNode as E,withCtx as $,Transition as P,withDirectives as A,vShow as H,createSlots as R,normalizeProps as j,guardReactiveProps as B}from"vue";function G(e){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G(e)}function N(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function z(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?N(Object(i),!0).forEach((function(t){U(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):N(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function U(e,t,i){var n;return(t="symbol"==G(n=_(t,"string"))?n:String(n))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _(e,t){if("object"!=G(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function q(e){return X(e)||Q(e)||J(e)||W()}function W(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function J(e,t){if(e){if("string"==typeof e)return Y(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Y(e,t):void 0}}function Q(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function X(e){if(Array.isArray(e))return Y(e)}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var Z={name:"MultiSelect",extends:{name:"BaseMultiSelect",extends:v,props:{modelValue:null,options:Array,optionLabel:null,optionValue:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},placeholder:String,disabled:Boolean,inputId:{type:String,default:null},inputProps:{type:null,default:null},panelClass:{type:String,default:null},panelStyle:{type:null,default:null},panelProps:{type:null,default:null},filterInputProps:{type:null,default:null},closeButtonProps:{type:null,default:null},dataKey:null,filter:Boolean,filterPlaceholder:String,filterLocale:String,filterMatchMode:{type:String,default:"contains"},filterFields:{type:Array,default:null},appendTo:{type:String,default:"body"},display:{type:String,default:"comma"},selectedItemsLabel:{type:String,default:"{0} items selected"},maxSelectedLabels:{type:Number,default:null},selectionLimit:{type:Number,default:null},showToggleAll:{type:Boolean,default:!0},loading:{type:Boolean,default:!1},checkboxIcon:{type:String,default:void 0},closeIcon:{type:String,default:void 0},dropdownIcon:{type:String,default:void 0},filterIcon:{type:String,default:void 0},loadingIcon:{type:String,default:void 0},removeTokenIcon:{type:String,default:void 0},selectAll:{type:Boolean,default:null},resetFilterOnHide:{type:Boolean,default:!1},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},autoFilterFocus:{type:Boolean,default:!1},filterMessage:{type:String,default:null},selectionMessage:{type:String,default:null},emptySelectionMessage:{type:String,default:null},emptyFilterMessage:{type:String,default:null},emptyMessage:{type:String,default:null},tabindex:{type:Number,default:0},ariaLabel:{type:String,default:null},ariaLabelledby:{type:String,default:null}},style:y,provide:function(){return{$parentInstance:this}}},emits:["update:modelValue","change","focus","blur","before-show","before-hide","show","hide","filter","selectall-change"],outsideClickListener:null,scrollHandler:null,resizeListener:null,overlay:null,list:null,virtualScroller:null,startRangeIndex:-1,searchTimeout:null,searchValue:"",selectOnFocus:!1,focusOnHover:!1,data:function(){return{id:this.$attrs.id,focused:!1,focusedOptionIndex:-1,headerCheckboxFocused:!1,filterValue:null,overlayVisible:!1}},watch:{"$attrs.id":function(e){this.id=e||u()},options:function(){this.autoUpdateModel()}},mounted:function(){this.id=this.id||u(),this.autoUpdateModel()},beforeUnmount:function(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(d.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex:function(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel:function(e){return this.optionLabel?p.resolveFieldData(e,this.optionLabel):e},getOptionValue:function(e){return this.optionValue?p.resolveFieldData(e,this.optionValue):e},getOptionRenderKey:function(e){return this.dataKey?p.resolveFieldData(e,this.dataKey):this.getOptionLabel(e)},getHeaderCheckboxPTOptions:function(e){return this.ptm(e,{context:{selected:this.allSelected,focused:this.headerCheckboxFocused}})},getCheckboxPTOptions:function(e,t,i,n){return this.ptm(n,{context:{selected:this.isSelected(e),focused:this.focusedOptionIndex===this.getOptionIndex(i,t),disabled:this.isOptionDisabled(e)}})},isOptionDisabled:function(e){return!(!this.maxSelectionLimitReached||this.isSelected(e))||!!this.optionDisabled&&p.resolveFieldData(e,this.optionDisabled)},isOptionGroup:function(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel:function(e){return p.resolveFieldData(e,this.optionGroupLabel)},getOptionGroupChildren:function(e){return p.resolveFieldData(e,this.optionGroupChildren)},getAriaPosInset:function(e){var t=this;return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((function(e){return t.isOptionGroup(e)})).length:e)+1},show:function(e){this.$emit("before-show"),this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&h.focus(this.$refs.focusInput)},hide:function(e){var t=this;setTimeout((function(){t.$emit("before-hide"),t.overlayVisible=!1,t.focusedOptionIndex=-1,t.searchValue="",t.resetFilterOnHide&&(t.filterValue=null),e&&h.focus(t.$refs.focusInput)}),0)},onFocus:function(e){this.disabled||(this.focused=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.overlayVisible&&this.scrollInView(this.focusedOptionIndex),this.$emit("focus",e))},onBlur:function(e){this.focused=!1,this.focusedOptionIndex=-1,this.searchValue="",this.$emit("blur",e)},onKeyDown:function(e){var t=this;if(this.disabled)e.preventDefault();else{var i=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"PageDown":this.onPageDownKey(e);break;case"PageUp":this.onPageUpKey(e);break;case"Enter":case"NumpadEnter":case"Space":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e);break;case"ShiftLeft":case"ShiftRight":this.onShiftKey(e);break;default:if("KeyA"===e.code&&i){var n=this.visibleOptions.filter((function(e){return t.isValidOption(e)})).map((function(e){return t.getOptionValue(e)}));this.updateModel(e,n),e.preventDefault();break}!i&&p.isPrintableCharacter(e.key)&&(!this.overlayVisible&&this.show(),this.searchOptions(e),e.preventDefault())}}},onContainerClick:function(e){this.disabled||this.loading||this.overlay&&this.overlay.contains(e.target)||(this.overlayVisible?this.hide(!0):this.show(!0))},onFirstHiddenFocus:function(e){var t=e.relatedTarget===this.$refs.focusInput?h.getFirstFocusableElement(this.overlay,':not([data-p-hidden-focusable="true"])'):this.$refs.focusInput;h.focus(t)},onLastHiddenFocus:function(e){var t=e.relatedTarget===this.$refs.focusInput?h.getLastFocusableElement(this.overlay,':not([data-p-hidden-focusable="true"])'):this.$refs.focusInput;h.focus(t)},onCloseClick:function(){this.hide(!0)},onHeaderCheckboxFocus:function(){this.headerCheckboxFocused=!0},onHeaderCheckboxBlur:function(){this.headerCheckboxFocused=!1},onOptionSelect:function(e,t){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!this.disabled&&!this.isOptionDisabled(t)){var s=null;s=this.isSelected(t)?this.modelValue.filter((function(e){return!p.equals(e,i.getOptionValue(t),i.equalityKey)})):[].concat(q(this.modelValue||[]),[this.getOptionValue(t)]),this.updateModel(e,s),-1!==n&&(this.focusedOptionIndex=n),o&&h.focus(this.$refs.focusInput)}},onOptionMouseMove:function(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onOptionSelectRange:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;if(-1===i&&(i=this.findNearestSelectedOptionIndex(n,!0)),-1===n&&(n=this.findNearestSelectedOptionIndex(i)),-1!==i&&-1!==n){var o=Math.min(i,n),s=Math.max(i,n),l=this.visibleOptions.slice(o,s+1).filter((function(e){return t.isValidOption(e)})).map((function(e){return t.getOptionValue(e)}));this.updateModel(e,l)}},onFilterChange:function(e){var t=e.target.value;this.filterValue=t,this.focusedOptionIndex=-1,this.$emit("filter",{originalEvent:e,value:t}),!this.virtualScrollerDisabled&&this.virtualScroller.scrollToIndex(0)},onFilterKeyDown:function(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e,!0);break;case"ArrowLeft":case"ArrowRight":this.onArrowLeftKey(e,!0);break;case"Home":this.onHomeKey(e,!0);break;case"End":this.onEndKey(e,!0);break;case"Enter":case"NumpadEnter":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e,!0)}},onFilterBlur:function(){this.focusedOptionIndex=-1},onFilterUpdated:function(){this.overlayVisible&&this.alignOverlay()},onOverlayClick:function(e){r.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown:function(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey:function(e){var t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();e.shiftKey&&this.onOptionSelectRange(e,this.startRangeIndex,t),this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()},onArrowUpKey:function(e){if(e.altKey&&!(arguments.length>1&&void 0!==arguments[1]&&arguments[1]))-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{var t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();e.shiftKey&&this.onOptionSelectRange(e,t,this.startRangeIndex),this.changeFocusedOptionIndex(e,t),!this.overlayVisible&&this.show(),e.preventDefault()}},onArrowLeftKey:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&(this.focusedOptionIndex=-1)},onHomeKey:function(e){var t=e.currentTarget;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){t.setSelectionRange(0,e.shiftKey?t.value.length:0),this.focusedOptionIndex=-1}else{var i=e.metaKey||e.ctrlKey,n=this.findFirstOptionIndex();e.shiftKey&&i&&this.onOptionSelectRange(e,n,this.startRangeIndex),this.changeFocusedOptionIndex(e,n),!this.overlayVisible&&this.show()}e.preventDefault()},onEndKey:function(e){var t=e.currentTarget;if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){var i=t.value.length;t.setSelectionRange(e.shiftKey?0:i,i),this.focusedOptionIndex=-1}else{var n=e.metaKey||e.ctrlKey,o=this.findLastOptionIndex();e.shiftKey&&n&&this.onOptionSelectRange(e,this.startRangeIndex,o),this.changeFocusedOptionIndex(e,o),!this.overlayVisible&&this.show()}e.preventDefault()},onPageUpKey:function(e){this.scrollInView(0),e.preventDefault()},onPageDownKey:function(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey:function(e){this.overlayVisible?-1!==this.focusedOptionIndex&&(e.shiftKey?this.onOptionSelectRange(e,this.focusedOptionIndex):this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex])):this.onArrowDownKey(e),e.preventDefault()},onEscapeKey:function(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey:function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]||(this.overlayVisible&&this.hasFocusableElements()?(h.focus(e.shiftKey?this.$refs.lastHiddenFocusableElementOnOverlay:this.$refs.firstHiddenFocusableElementOnOverlay),e.preventDefault()):(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(this.filter)))},onShiftKey:function(){this.startRangeIndex=this.focusedOptionIndex},onOverlayEnter:function(e){d.set("overlay",e,this.$primevue.config.zIndex.overlay),h.addStyles(e,{position:"absolute",top:"0",left:"0"}),this.alignOverlay(),this.scrollInView(),this.autoFilterFocus&&h.focus(this.$refs.filterInput)},onOverlayAfterEnter:function(){this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.$emit("show")},onOverlayLeave:function(){this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener(),this.$emit("hide"),this.overlay=null},onOverlayAfterLeave:function(e){d.clear(e)},alignOverlay:function(){"self"===this.appendTo?h.relativePosition(this.overlay,this.$el):(this.overlay.style.minWidth=h.getOuterWidth(this.$el)+"px",h.absolutePosition(this.overlay,this.$el))},bindOutsideClickListener:function(){var e=this;this.outsideClickListener||(this.outsideClickListener=function(t){e.overlayVisible&&e.isOutsideClicked(t)&&e.hide()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener:function(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener:function(){var e=this;this.scrollHandler||(this.scrollHandler=new f(this.$refs.container,(function(){e.overlayVisible&&e.hide()}))),this.scrollHandler.bindScrollListener()},unbindScrollListener:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.overlayVisible&&!h.isTouchDevice()&&e.hide()},window.addEventListener("resize",this.resizeListener))},unbindResizeListener:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},isOutsideClicked:function(e){return!(this.$el.isSameNode(e.target)||this.$el.contains(e.target)||this.overlay&&this.overlay.contains(e.target))},getLabelByValue:function(e){var t=this,i=(this.optionGroupLabel?this.flatOptions(this.options):this.options||[]).find((function(i){return!t.isOptionGroup(i)&&p.equals(t.getOptionValue(i),e,t.equalityKey)}));return i?this.getOptionLabel(i):null},getSelectedItemsLabel:function(){var e=/{(.*?)}/,t=this.selectedItemsLabel||this.$primevue.config.locale.selectionMessage;return e.test(t)?t.replace(t.match(e)[0],this.modelValue.length+""):t},onToggleAll:function(e){var t=this;if(null!==this.selectAll)this.$emit("selectall-change",{originalEvent:e,checked:!this.allSelected});else{var i=this.allSelected?[]:this.visibleOptions.filter((function(e){return t.isValidOption(e)})).map((function(e){return t.getOptionValue(e)}));this.updateModel(e,i)}this.headerCheckboxFocused=!0},removeOption:function(e,t){var i=this,n=this.modelValue.filter((function(e){return!p.equals(e,t,i.equalityKey)}));this.updateModel(e,n)},clearFilter:function(){this.filterValue=null},hasFocusableElements:function(){return h.getFocusableElements(this.overlay,':not([data-p-hidden-focusable="true"])').length>0},isOptionMatched:function(e){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.filterLocale).startsWith(this.searchValue.toLocaleLowerCase(this.filterLocale))},isValidOption:function(e){return p.isNotEmpty(e)&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption:function(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected:function(e){var t=this,i=this.getOptionValue(e);return(this.modelValue||[]).some((function(e){return p.equals(e,i,t.equalityKey)}))},findFirstOptionIndex:function(){var e=this;return this.visibleOptions.findIndex((function(t){return e.isValidOption(t)}))},findLastOptionIndex:function(){var e=this;return p.findLastIndex(this.visibleOptions,(function(t){return e.isValidOption(t)}))},findNextOptionIndex:function(e){var t=this,i=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((function(e){return t.isValidOption(e)})):-1;return i>-1?i+e+1:e},findPrevOptionIndex:function(e){var t=this,i=e>0?p.findLastIndex(this.visibleOptions.slice(0,e),(function(e){return t.isValidOption(e)})):-1;return i>-1?i:e},findFirstSelectedOptionIndex:function(){var e=this;return this.hasSelectedOption?this.visibleOptions.findIndex((function(t){return e.isValidSelectedOption(t)})):-1},findLastSelectedOptionIndex:function(){var e=this;return this.hasSelectedOption?p.findLastIndex(this.visibleOptions,(function(t){return e.isValidSelectedOption(t)})):-1},findNextSelectedOptionIndex:function(e){var t=this,i=this.hasSelectedOption&&e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((function(e){return t.isValidSelectedOption(e)})):-1;return i>-1?i+e+1:-1},findPrevSelectedOptionIndex:function(e){var t=this,i=this.hasSelectedOption&&e>0?p.findLastIndex(this.visibleOptions.slice(0,e),(function(e){return t.isValidSelectedOption(e)})):-1;return i>-1?i:-1},findNearestSelectedOptionIndex:function(e){var t=-1;return this.hasSelectedOption&&(t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?-1===(t=this.findPrevSelectedOptionIndex(e))?this.findNextSelectedOptionIndex(e):t:-1===(t=this.findNextSelectedOptionIndex(e))?this.findPrevSelectedOptionIndex(e):t),t>-1?t:e},findFirstFocusedOptionIndex:function(){var e=this.findFirstSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex:function(){var e=this.findLastSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},searchOptions:function(e){var t=this;this.searchValue=(this.searchValue||"")+e.key;var i=-1;-1===(i=-1!==this.focusedOptionIndex?-1===(i=this.visibleOptions.slice(this.focusedOptionIndex).findIndex((function(e){return t.isOptionMatched(e)})))?this.visibleOptions.slice(0,this.focusedOptionIndex).findIndex((function(e){return t.isOptionMatched(e)})):i+this.focusedOptionIndex:this.visibleOptions.findIndex((function(e){return t.isOptionMatched(e)})))&&-1===this.focusedOptionIndex&&(i=this.findFirstFocusedOptionIndex()),-1!==i&&this.changeFocusedOptionIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout((function(){t.searchValue="",t.searchTimeout=null}),500)},changeFocusedOptionIndex:function(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView())},scrollInView:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=-1!==e?"".concat(this.id,"_").concat(e):this.focusedOptionId,i=h.findSingle(this.list,'li[id="'.concat(t,'"]'));i?i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"nearest"}):this.virtualScrollerDisabled||this.virtualScroller&&this.virtualScroller.scrollToIndex(-1!==e?e:this.focusedOptionIndex)},autoUpdateModel:function(){if(this.selectOnFocus&&this.autoOptionFocus&&!this.hasSelectedOption){this.focusedOptionIndex=this.findFirstFocusedOptionIndex();var e=this.getOptionValue(this.visibleOptions[this.focusedOptionIndex]);this.updateModel(null,[e])}},updateModel:function(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions:function(e){var t=this;return(e||[]).reduce((function(e,i,n){e.push({optionGroup:i,group:!0,index:n});var o=t.getOptionGroupChildren(i);return o&&o.forEach((function(t){return e.push(t)})),e}),[])},overlayRef:function(e){this.overlay=e},listRef:function(e,t){this.list=e,t&&t(e)},virtualScrollerRef:function(e){this.virtualScroller=e}},computed:{visibleOptions:function(){var t=this,i=this.optionGroupLabel?this.flatOptions(this.options):this.options||[];if(this.filterValue){var n=e.filter(i,this.searchFields,this.filterValue,this.filterMatchMode,this.filterLocale);if(this.optionGroupLabel){var o=[];return(this.options||[]).forEach((function(e){var i=t.getOptionGroupChildren(e).filter((function(e){return n.includes(e)}));i.length>0&&o.push(z(z({},e),{},U({},"string"==typeof t.optionGroupChildren?t.optionGroupChildren:"items",q(i))))})),this.flatOptions(o)}return n}return i},label:function(){var e;if(this.modelValue&&this.modelValue.length){if(p.isNotEmpty(this.maxSelectedLabels)&&this.modelValue.length>this.maxSelectedLabels)return this.getSelectedItemsLabel();e="";for(var t=0;t<this.modelValue.length;t++)0!==t&&(e+=", "),e+=this.getLabelByValue(this.modelValue[t])}else e=this.placeholder;return e},chipSelectedItems:function(){return p.isNotEmpty(this.maxSelectedLabels)&&this.modelValue&&this.modelValue.length>this.maxSelectedLabels?this.modelValue.slice(0,this.maxSelectedLabels):this.modelValue},allSelected:function(){var e=this;return null!==this.selectAll?this.selectAll:p.isNotEmpty(this.visibleOptions)&&this.visibleOptions.every((function(t){return e.isOptionGroup(t)||e.isOptionDisabled(t)||e.isSelected(t)}))},hasSelectedOption:function(){return p.isNotEmpty(this.modelValue)},equalityKey:function(){return this.optionValue?null:this.dataKey},searchFields:function(){return this.filterFields||[this.optionLabel]},maxSelectionLimitReached:function(){return this.selectionLimit&&this.modelValue&&this.modelValue.length===this.selectionLimit},filterResultMessageText:function(){return p.isNotEmpty(this.visibleOptions)?this.filterMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptyFilterMessageText},filterMessageText:function(){return this.filterMessage||this.$primevue.config.locale.searchMessage||""},emptyFilterMessageText:function(){return this.emptyFilterMessage||this.$primevue.config.locale.emptySearchMessage||this.$primevue.config.locale.emptyFilterMessage||""},emptyMessageText:function(){return this.emptyMessage||this.$primevue.config.locale.emptyMessage||""},selectionMessageText:function(){return this.selectionMessage||this.$primevue.config.locale.selectionMessage||""},emptySelectionMessageText:function(){return this.emptySelectionMessage||this.$primevue.config.locale.emptySelectionMessage||""},selectedMessageText:function(){return this.hasSelectedOption?this.selectionMessageText.replaceAll("{0}",this.modelValue.length):this.emptySelectionMessageText},focusedOptionId:function(){return-1!==this.focusedOptionIndex?"".concat(this.id,"_").concat(this.focusedOptionIndex):null},ariaSetSize:function(){var e=this;return this.visibleOptions.filter((function(t){return!e.isOptionGroup(t)})).length},toggleAllAriaLabel:function(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria[this.allSelected?"selectAll":"unselectAll"]:void 0},closeAriaLabel:function(){return this.$primevue.config.locale.aria?this.$primevue.config.locale.aria.close:void 0},virtualScrollerDisabled:function(){return!this.virtualScrollerOptions}},directives:{ripple:c},components:{VirtualScroller:b,Portal:a,TimesIcon:s,SearchIcon:n,TimesCircleIcon:l,ChevronDownIcon:i,SpinnerIcon:o,CheckIcon:t}};function ee(e){return ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ee(e)}function te(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function ie(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?te(Object(i),!0).forEach((function(t){ne(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):te(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function ne(e,t,i){var n;return(t="symbol"==ee(n=oe(t,"string"))?n:String(n))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function oe(e,t){if("object"!=ee(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=ee(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var se=["id","disabled","placeholder","tabindex","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],le=["onClick"],re=["checked","aria-label"],ae=["value","placeholder","aria-owns","aria-activedescendant"],ce=["aria-label"],ue=["id"],de=["id"],pe=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove","data-p-highlight","data-p-focused","data-p-disabled"];Z.render=function(e,t,i,n,o,s){var l=m("TimesCircleIcon"),r=m("SpinnerIcon"),a=m("VirtualScroller"),c=m("Portal"),u=O("ripple");return g(),x("div",I({ref:"container",class:e.cx("root"),onClick:t[15]||(t[15]=function(){return s.onContainerClick&&s.onContainerClick.apply(s,arguments)})},e.ptm("root"),{"data-pc-name":"multiselect"}),[S("div",I({class:"p-hidden-accessible"},e.ptm("hiddenInputWrapper"),{"data-p-hidden-accessible":!0}),[S("input",I({ref:"focusInput",id:e.inputId,type:"text",readonly:"",disabled:e.disabled,placeholder:e.placeholder,tabindex:e.disabled?-1:e.tabindex,role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-expanded":o.overlayVisible,"aria-controls":o.id+"_list","aria-activedescendant":o.focused?s.focusedOptionId:void 0,onFocus:t[0]||(t[0]=function(){return s.onFocus&&s.onFocus.apply(s,arguments)}),onBlur:t[1]||(t[1]=function(){return s.onBlur&&s.onBlur.apply(s,arguments)}),onKeydown:t[2]||(t[2]=function(){return s.onKeyDown&&s.onKeyDown.apply(s,arguments)})},ie(ie({},e.inputProps),e.ptm("hiddenInput"))),null,16,se)],16),S("div",I({class:e.cx("labelContainer")},e.ptm("labelContainer")),[S("div",I({class:e.cx("label")},e.ptm("label")),[k(e.$slots,"value",{value:e.modelValue,placeholder:e.placeholder},(function(){return["comma"===e.display?(g(),x(L,{key:0},[V(F(s.label||"empty"),1)],64)):"chip"===e.display?(g(),x(L,{key:1},[(g(!0),x(L,null,w(s.chipSelectedItems,(function(t){return g(),x("div",I({key:s.getLabelByValue(t),class:e.cx("token")},e.ptm("token")),[k(e.$slots,"chip",{value:t},(function(){return[S("span",I({class:e.cx("tokenLabel")},e.ptm("tokenLabel")),F(s.getLabelByValue(t)),17)]})),e.disabled?T("",!0):k(e.$slots,"removetokenicon",{key:0,class:C(e.cx("removeTokenIcon")),item:t,onClick:function(e){return s.removeOption(e,t)},removeCallback:function(e){return s.removeOption(e,t)}},(function(){return[e.removeTokenIcon?(g(),x("span",I({key:0,class:[e.cx("removeTokenIcon"),e.removeTokenIcon],onClick:K((function(e){return s.removeOption(e,t)}),["stop"])},e.ptm("removeTokenIcon")),null,16,le)):(g(),M(l,I({key:1,class:e.cx("removeTokenIcon"),onClick:K((function(e){return s.removeOption(e,t)}),["stop"])},e.ptm("removeTokenIcon")),null,16,["class","onClick"]))]}))],16)})),128)),e.modelValue&&0!==e.modelValue.length?T("",!0):(g(),x(L,{key:0},[V(F(e.placeholder||"empty"),1)],64))],64)):T("",!0)]}))],16)],16),S("div",I({class:e.cx("trigger")},e.ptm("trigger")),[e.loading?k(e.$slots,"loadingicon",{key:0,class:C(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(g(),x("span",I({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon],"aria-hidden":"true"},e.ptm("loadingIcon")),null,16)):(g(),M(r,I({key:1,class:e.cx("loadingIcon"),spin:"","aria-hidden":"true"},e.ptm("loadingIcon")),null,16,["class"]))]})):k(e.$slots,"dropdownicon",{key:1,class:C(e.cx("dropdownIcon"))},(function(){return[(g(),M(D(e.dropdownIcon?"span":"ChevronDownIcon"),I({class:[e.cx("dropdownIcon"),e.dropdownIcon],"aria-hidden":"true"},e.ptm("dropdownIcon")),null,16,["class"]))]}))],16),E(c,{appendTo:e.appendTo},{default:$((function(){return[E(P,I({name:"p-connected-overlay",onEnter:s.onOverlayEnter,onAfterEnter:s.onOverlayAfterEnter,onLeave:s.onOverlayLeave,onAfterLeave:s.onOverlayAfterLeave},e.ptm("transition")),{default:$((function(){return[o.overlayVisible?(g(),x("div",I({key:0,ref:s.overlayRef,style:e.panelStyle,class:[e.cx("panel"),e.panelClass],onClick:t[13]||(t[13]=function(){return s.onOverlayClick&&s.onOverlayClick.apply(s,arguments)}),onKeydown:t[14]||(t[14]=function(){return s.onOverlayKeyDown&&s.onOverlayKeyDown.apply(s,arguments)})},ie(ie({},e.panelProps),e.ptm("panel"))),[S("span",I({ref:"firstHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[3]||(t[3]=function(){return s.onFirstHiddenFocus&&s.onFirstHiddenFocus.apply(s,arguments)})},e.ptm("hiddenFirstFocusableEl"),{"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0}),null,16),k(e.$slots,"header",{value:e.modelValue,options:s.visibleOptions}),e.showToggleAll&&null==e.selectionLimit||e.filter?(g(),x("div",I({key:0,class:e.cx("header")},e.ptm("header")),[e.showToggleAll&&null==e.selectionLimit?(g(),x("div",I({key:0,class:e.cx("headerCheckboxContainer"),onClick:t[6]||(t[6]=function(){return s.onToggleAll&&s.onToggleAll.apply(s,arguments)})},e.ptm("headerCheckboxContainer")),[S("div",I({class:"p-hidden-accessible"},e.ptm("hiddenInputWrapper"),{"data-p-hidden-accessible":!0}),[S("input",I({type:"checkbox",readonly:"",checked:s.allSelected,"aria-label":s.toggleAllAriaLabel,onFocus:t[4]||(t[4]=function(){return s.onHeaderCheckboxFocus&&s.onHeaderCheckboxFocus.apply(s,arguments)}),onBlur:t[5]||(t[5]=function(){return s.onHeaderCheckboxBlur&&s.onHeaderCheckboxBlur.apply(s,arguments)})},e.ptm("headerCheckbox")),null,16,re)],16),S("div",I({class:e.cx("headerCheckbox")},s.getHeaderCheckboxPTOptions("headerCheckbox")),[k(e.$slots,"headercheckboxicon",{allSelected:s.allSelected,class:C(e.cx("headerCheckboxIcon"))},(function(){return[A((g(),M(D(e.checkboxIcon?"span":"CheckIcon"),I({class:[e.cx("headerCheckboxIcon"),ne({},e.checkboxIcon,s.allSelected)]},s.getHeaderCheckboxPTOptions("headerCheckboxIcon")),null,16,["class"])),[[H,s.allSelected]])]}))],16)],16)):T("",!0),e.filter?(g(),x("div",I({key:1,class:e.cx("filterContainer")},e.ptm("filterContainer")),[S("input",I({ref:"filterInput",type:"text",value:o.filterValue,onVnodeMounted:t[7]||(t[7]=function(){return s.onFilterUpdated&&s.onFilterUpdated.apply(s,arguments)}),class:e.cx("filterInput"),placeholder:e.filterPlaceholder,role:"searchbox",autocomplete:"off","aria-owns":o.id+"_list","aria-activedescendant":s.focusedOptionId,onKeydown:t[8]||(t[8]=function(){return s.onFilterKeyDown&&s.onFilterKeyDown.apply(s,arguments)}),onBlur:t[9]||(t[9]=function(){return s.onFilterBlur&&s.onFilterBlur.apply(s,arguments)}),onInput:t[10]||(t[10]=function(){return s.onFilterChange&&s.onFilterChange.apply(s,arguments)})},ie(ie({},e.filterInputProps),e.ptm("filterInput"))),null,16,ae),k(e.$slots,"filtericon",{class:C(e.cx("filterIcon"))},(function(){return[(g(),M(D(e.filterIcon?"span":"SearchIcon"),I({class:[e.cx("filterIcon"),e.filterIcon]},e.ptm("filterIcon")),null,16,["class"]))]}))],16)):T("",!0),e.filter?(g(),x("span",I({key:2,role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenFilterResult"),{"data-p-hidden-accessible":!0}),F(s.filterResultMessageText),17)):T("",!0),A((g(),x("button",I({class:e.cx("closeButton"),"aria-label":s.closeAriaLabel,onClick:t[11]||(t[11]=function(){return s.onCloseClick&&s.onCloseClick.apply(s,arguments)}),type:"button"},ie(ie({},e.closeButtonProps),e.ptm("closeButton"))),[k(e.$slots,"closeicon",{class:C(e.cx("closeIcon"))},(function(){return[(g(),M(D(e.closeIcon?"span":"TimesIcon"),I({class:[e.cx("closeIcon"),e.closeIcon]},e.ptm("closeIcon")),null,16,["class"]))]}))],16,ce)),[[u]])],16)):T("",!0),S("div",I({class:e.cx("wrapper"),style:{"max-height":s.virtualScrollerDisabled?e.scrollHeight:""}},e.ptm("wrapper")),[E(a,I({ref:s.virtualScrollerRef},e.virtualScrollerOptions,{items:s.visibleOptions,style:{height:e.scrollHeight},tabindex:-1,disabled:s.virtualScrollerDisabled,pt:e.ptm("virtualScroller")}),R({content:$((function(t){var i=t.styleClass,n=t.contentRef,l=t.items,r=t.getItemOptions,a=t.contentStyle,c=t.itemSize;return[S("ul",I({ref:function(e){return s.listRef(e,n)},id:o.id+"_list",class:[e.cx("list"),i],style:a,role:"listbox","aria-multiselectable":"true"},e.ptm("list")),[(g(!0),x(L,null,w(l,(function(t,i){return g(),x(L,{key:s.getOptionRenderKey(t,s.getOptionIndex(i,r))},[s.isOptionGroup(t)?(g(),x("li",I({key:0,id:o.id+"_"+s.getOptionIndex(i,r),style:{height:c?c+"px":void 0},class:e.cx("itemGroup"),role:"option"},e.ptm("itemGroup")),[k(e.$slots,"optiongroup",{option:t.optionGroup,index:s.getOptionIndex(i,r)},(function(){return[V(F(s.getOptionGroupLabel(t.optionGroup)),1)]}))],16,de)):A((g(),x("li",I({key:1,id:o.id+"_"+s.getOptionIndex(i,r),style:{height:c?c+"px":void 0},class:e.cx("item",{option:t,index:i,getItemOptions:r}),role:"option","aria-label":s.getOptionLabel(t),"aria-selected":s.isSelected(t),"aria-disabled":s.isOptionDisabled(t),"aria-setsize":s.ariaSetSize,"aria-posinset":s.getAriaPosInset(s.getOptionIndex(i,r)),onClick:function(e){return s.onOptionSelect(e,t,s.getOptionIndex(i,r),!0)},onMousemove:function(e){return s.onOptionMouseMove(e,s.getOptionIndex(i,r))}},s.getCheckboxPTOptions(t,r,i,"item"),{"data-p-highlight":s.isSelected(t),"data-p-focused":o.focusedOptionIndex===s.getOptionIndex(i,r),"data-p-disabled":s.isOptionDisabled(t)}),[S("div",I({class:e.cx("checkboxContainer")},e.ptm("checkboxContainer")),[S("div",I({class:e.cx("checkbox",{option:t})},s.getCheckboxPTOptions(t,r,i,"checkbox")),[k(e.$slots,"itemcheckboxicon",{selected:s.isSelected(t),class:C(e.cx("checkboxIcon"))},(function(){return[A((g(),M(D(e.checkboxIcon?"span":"CheckIcon"),I({class:[e.cx("checkboxIcon"),ne({},e.checkboxIcon,s.isSelected(t))]},s.getCheckboxPTOptions(t,r,i,"checkboxIcon")),null,16,["class"])),[[H,s.isSelected(t)]])]}))],16)],16),k(e.$slots,"option",{option:t,index:s.getOptionIndex(i,r)},(function(){return[S("span",j(B(e.ptm("option"))),F(s.getOptionLabel(t)),17)]}))],16,pe)),[[u]])],64)})),128)),o.filterValue&&(!l||l&&0===l.length)?(g(),x("li",I({key:0,class:e.cx("emptyMessage"),role:"option"},e.ptm("emptyMessage")),[k(e.$slots,"emptyfilter",{},(function(){return[V(F(s.emptyFilterMessageText),1)]}))],16)):!e.options||e.options&&0===e.options.length?(g(),x("li",I({key:1,class:e.cx("emptyMessage"),role:"option"},e.ptm("emptyMessage")),[k(e.$slots,"empty",{},(function(){return[V(F(s.emptyMessageText),1)]}))],16)):T("",!0)],16,ue)]})),_:2},[e.$slots.loader?{name:"loader",fn:$((function(t){return[k(e.$slots,"loader",{options:t.options})]})),key:"0"}:void 0]),1040,["items","style","disabled","pt"])],16),k(e.$slots,"footer",{value:e.modelValue,options:s.visibleOptions}),!e.options||e.options&&0===e.options.length?(g(),x("span",I({key:1,role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenEmptyMessage"),{"data-p-hidden-accessible":!0}),F(s.emptyMessageText),17)):T("",!0),S("span",I({role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenSelectedMessage"),{"data-p-hidden-accessible":!0}),F(s.selectedMessageText),17),S("span",I({ref:"lastHiddenFocusableElementOnOverlay",role:"presentation","aria-hidden":"true",class:"p-hidden-accessible p-hidden-focusable",tabindex:0,onFocus:t[12]||(t[12]=function(){return s.onLastHiddenFocus&&s.onLastHiddenFocus.apply(s,arguments)})},e.ptm("hiddenLastFocusableEl"),{"data-p-hidden-accessible":!0,"data-p-hidden-focusable":!0}),null,16)],16)):T("",!0)]})),_:3},16,["onEnter","onAfterEnter","onLeave","onAfterLeave"])]})),_:3},8,["appendTo"])],16)};export{Z as default};