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) 29.2 kB
import e from"primevue/button";import t from"primevue/icons/chevrondown";import i from"primevue/icons/spinner";import n from"primevue/icons/timescircle";import o from"primevue/overlayeventbus";import s from"primevue/portal";import l from"primevue/ripple";import{UniqueComponentId as r,ZIndexUtils as a,ObjectUtils as u,DomHandler as c,ConnectedOverlayScrollHandler as d}from"primevue/utils";import p from"primevue/virtualscroller";import h from"primevue/autocomplete/style";import f from"primevue/basecomponent";import{resolveComponent as y,resolveDirective as v,openBlock as m,createElementBlock as b,mergeProps as O,createCommentVNode as g,Fragment as I,renderList as x,renderSlot as S,createElementVNode as w,toDisplayString as k,normalizeClass as L,createBlock as C,resolveDynamicComponent as M,withCtx as V,createVNode as $,Transition as D,createSlots as K,createTextVNode as T,withDirectives as F}from"vue";function E(e){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(e)}function A(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function B(e,t){if(e){if("string"==typeof e)return j(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)?j(e,t):void 0}}function P(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function R(e){if(Array.isArray(e))return j(e)}function j(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:"AutoComplete",extends:{name:"BaseAutoComplete",extends:f,props:{modelValue:null,suggestions:{type:Array,default:null},field:{type:[String,Function],default:null},optionLabel:null,optionDisabled:null,optionGroupLabel:null,optionGroupChildren:null,scrollHeight:{type:String,default:"200px"},dropdown:{type:Boolean,default:!1},dropdownMode:{type:String,default:"blank"},autoHighlight:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},dataKey:{type:String,default:null},minLength:{type:Number,default:1},delay:{type:Number,default:300},appendTo:{type:String,default:"body"},forceSelection:{type:Boolean,default:!1},completeOnFocus:{type:Boolean,default:!1},inputId:{type:String,default:null},inputStyle:{type:Object,default:null},inputClass:{type:[String,Object],default:null},inputProps:{type:null,default:null},panelStyle:{type:Object,default:null},panelClass:{type:[String,Object],default:null},panelProps:{type:null,default:null},dropdownIcon:{type:String,default:void 0},dropdownClass:{type:[String,Object],default:null},loadingIcon:{type:String,default:void 0},removeTokenIcon:{type:String,default:void 0},virtualScrollerOptions:{type:Object,default:null},autoOptionFocus:{type:Boolean,default:!0},selectOnFocus:{type:Boolean,default:!1},searchLocale:{type:String,default:void 0},searchMessage:{type:String,default:null},selectionMessage:{type:String,default:null},emptySelectionMessage:{type:String,default:null},emptySearchMessage:{type:String,default:null},tabindex:{type:Number,default:0},ariaLabel:{type:String,default:null},ariaLabelledby:{type:String,default:null}},style:h,provide:function(){return{$parentInstance:this}}},emits:["update:modelValue","change","focus","blur","item-select","item-unselect","dropdown-click","clear","complete","before-show","before-hide","show","hide"],outsideClickListener:null,resizeListener:null,scrollHandler:null,overlay:null,virtualScroller:null,searchTimeout:null,focusOnHover:!1,dirty:!1,data:function(){return{id:this.$attrs.id,focused:!1,focusedOptionIndex:-1,focusedMultipleOptionIndex:-1,overlayVisible:!1,searching:!1}},watch:{"$attrs.id":function(e){this.id=e||r()},suggestions:function(){this.searching&&(this.show(),this.focusedOptionIndex=this.overlayVisible&&this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,this.searching=!1),this.autoUpdateModel()}},mounted:function(){this.id=this.id||r(),this.autoUpdateModel()},updated:function(){this.overlayVisible&&this.alignOverlay()},beforeUnmount:function(){this.unbindOutsideClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlay&&(a.clear(this.overlay),this.overlay=null)},methods:{getOptionIndex:function(e,t){return this.virtualScrollerDisabled?e:t&&t(e).index},getOptionLabel:function(e){return this.field||this.optionLabel?u.resolveFieldData(e,this.field||this.optionLabel):e},getOptionValue:function(e){return e},getOptionRenderKey:function(e,t){return(this.dataKey?u.resolveFieldData(e,this.dataKey):this.getOptionLabel(e))+"_"+t},getPTOptions:function(e,t,i,n){return this.ptm(n,{context:{selected:this.isSelected(e),focused:this.focusedOptionIndex===this.getOptionIndex(i,t),disabled:this.isOptionDisabled(e)}})},isOptionDisabled:function(e){return!!this.optionDisabled&&u.resolveFieldData(e,this.optionDisabled)},isOptionGroup:function(e){return this.optionGroupLabel&&e.optionGroup&&e.group},getOptionGroupLabel:function(e){return u.resolveFieldData(e,this.optionGroupLabel)},getOptionGroupChildren:function(e){return u.resolveFieldData(e,this.optionGroupChildren)},getAriaPosInset:function(e){var t=this;return(this.optionGroupLabel?e-this.visibleOptions.slice(0,e).filter((function(e){return t.isOptionGroup(e)})).length:e)+1},show:function(e){this.$emit("before-show"),this.dirty=!0,this.overlayVisible=!0,this.focusedOptionIndex=-1!==this.focusedOptionIndex?this.focusedOptionIndex:this.autoOptionFocus?this.findFirstFocusedOptionIndex():-1,e&&c.focus(this.$refs.focusInput)},hide:function(e){var t=this;setTimeout((function(){t.$emit("before-hide"),t.dirty=e,t.overlayVisible=!1,t.focusedOptionIndex=-1,e&&c.focus(t.$refs.focusInput)}),0)},onFocus:function(e){this.disabled||(!this.dirty&&this.completeOnFocus&&this.search(e,e.target.value,"focus"),this.dirty=!0,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.dirty=!1,this.focused=!1,this.focusedOptionIndex=-1,this.$emit("blur",e)},onKeyDown:function(e){if(this.disabled)e.preventDefault();else switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"ArrowLeft":this.onArrowLeftKey(e);break;case"ArrowRight":this.onArrowRightKey(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":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e);break;case"Backspace":this.onBackspaceKey(e)}},onInput:function(e){var t=this;this.searchTimeout&&clearTimeout(this.searchTimeout);var i=e.target.value;this.multiple||this.updateModel(e,i),0===i.length?(this.hide(),this.$emit("clear")):i.length>=this.minLength?(this.focusedOptionIndex=-1,this.searchTimeout=setTimeout((function(){t.search(e,i,"input")}),this.delay)):this.hide()},onChange:function(e){var t=this;if(this.forceSelection){var i=!1;if(this.visibleOptions&&!this.multiple){var n=this.visibleOptions.find((function(e){return t.isOptionMatched(e,t.$refs.focusInput.value||"")}));void 0!==n&&(i=!0,!this.isSelected(n)&&this.onOptionSelect(e,n))}i||(this.$refs.focusInput.value="",this.$emit("clear"),!this.multiple&&this.updateModel(e,null))}},onMultipleContainerFocus:function(){this.disabled||(this.focused=!0)},onMultipleContainerBlur:function(){this.focusedMultipleOptionIndex=-1,this.focused=!1},onMultipleContainerKeyDown:function(e){if(this.disabled)e.preventDefault();else switch(e.code){case"ArrowLeft":this.onArrowLeftKeyOnMultiple(e);break;case"ArrowRight":this.onArrowRightKeyOnMultiple(e);break;case"Backspace":this.onBackspaceKeyOnMultiple(e)}},onContainerClick:function(e){this.disabled||this.searching||this.loading||this.isInputClicked(e)||this.isDropdownClicked(e)||this.overlay&&this.overlay.contains(e.target)||c.focus(this.$refs.focusInput)},onDropdownClick:function(e){var t=void 0;this.overlayVisible?this.hide(!0):(c.focus(this.$refs.focusInput),t=this.$refs.focusInput.value,"blank"===this.dropdownMode?this.search(e,"","dropdown"):"current"===this.dropdownMode&&this.search(e,t,"dropdown")),this.$emit("dropdown-click",{originalEvent:e,query:t})},onOptionSelect:function(e,t){var i,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=this.getOptionValue(t);this.multiple?(this.$refs.focusInput.value="",this.isSelected(t)||this.updateModel(e,[].concat(R(i=this.modelValue||[])||P(i)||B(i)||A(),[o]))):this.updateModel(e,o),this.$emit("item-select",{originalEvent:e,value:t}),n&&this.hide(!0)},onOptionMouseMove:function(e,t){this.focusOnHover&&this.changeFocusedOptionIndex(e,t)},onOverlayClick:function(e){o.emit("overlay-click",{originalEvent:e,target:this.$el})},onOverlayKeyDown:function(e){if("Escape"===e.code)this.onEscapeKey(e)},onArrowDownKey:function(e){if(this.overlayVisible){var t=-1!==this.focusedOptionIndex?this.findNextOptionIndex(this.focusedOptionIndex):this.findFirstFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),e.preventDefault()}},onArrowUpKey:function(e){if(this.overlayVisible)if(e.altKey)-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide(),e.preventDefault();else{var t=-1!==this.focusedOptionIndex?this.findPrevOptionIndex(this.focusedOptionIndex):this.findLastFocusedOptionIndex();this.changeFocusedOptionIndex(e,t),e.preventDefault()}},onArrowLeftKey:function(e){var t=e.currentTarget;this.focusedOptionIndex=-1,this.multiple&&(u.isEmpty(t.value)&&this.hasSelectedOption?(c.focus(this.$refs.multiContainer),this.focusedMultipleOptionIndex=this.modelValue.length):e.stopPropagation())},onArrowRightKey:function(e){this.focusedOptionIndex=-1,this.multiple&&e.stopPropagation()},onHomeKey:function(e){var t=e.currentTarget;t.setSelectionRange(0,e.shiftKey?t.value.length:0),this.focusedOptionIndex=-1,e.preventDefault()},onEndKey:function(e){var t=e.currentTarget,i=t.value.length;t.setSelectionRange(e.shiftKey?0:i,i),this.focusedOptionIndex=-1,e.preventDefault()},onPageUpKey:function(e){this.scrollInView(0),e.preventDefault()},onPageDownKey:function(e){this.scrollInView(this.visibleOptions.length-1),e.preventDefault()},onEnterKey:function(e){this.overlayVisible?(-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.hide()):this.onArrowDownKey(e),e.preventDefault()},onEscapeKey:function(e){this.overlayVisible&&this.hide(!0),e.preventDefault()},onTabKey:function(e){-1!==this.focusedOptionIndex&&this.onOptionSelect(e,this.visibleOptions[this.focusedOptionIndex]),this.overlayVisible&&this.hide()},onBackspaceKey:function(e){if(this.multiple){if(u.isNotEmpty(this.modelValue)&&!this.$refs.focusInput.value){var t=this.modelValue[this.modelValue.length-1],i=this.modelValue.slice(0,-1);this.$emit("update:modelValue",i),this.$emit("item-unselect",{originalEvent:e,value:t})}e.stopPropagation()}},onArrowLeftKeyOnMultiple:function(){this.focusedMultipleOptionIndex=this.focusedMultipleOptionIndex<1?0:this.focusedMultipleOptionIndex-1},onArrowRightKeyOnMultiple:function(){this.focusedMultipleOptionIndex++,this.focusedMultipleOptionIndex>this.modelValue.length-1&&(this.focusedMultipleOptionIndex=-1,c.focus(this.$refs.focusInput))},onBackspaceKeyOnMultiple:function(e){-1!==this.focusedMultipleOptionIndex&&this.removeOption(e,this.focusedMultipleOptionIndex)},onOverlayEnter:function(e){a.set("overlay",e,this.$primevue.config.zIndex.overlay),c.addStyles(e,{position:"absolute",top:"0",left:"0"}),this.alignOverlay()},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){a.clear(e)},alignOverlay:function(){var e=this.multiple?this.$refs.multiContainer:this.$refs.focusInput;"self"===this.appendTo?c.relativePosition(this.overlay,e):(this.overlay.style.minWidth=c.getOuterWidth(e)+"px",c.absolutePosition(this.overlay,e))},bindOutsideClickListener:function(){var e=this;this.outsideClickListener||(this.outsideClickListener=function(t){e.overlayVisible&&e.overlay&&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 d(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&&!c.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.overlay.contains(e.target)&&!this.isInputClicked(e)&&!this.isDropdownClicked(e)},isInputClicked:function(e){return this.multiple?e.target===this.$refs.multiContainer||this.$refs.multiContainer.contains(e.target):e.target===this.$refs.focusInput},isDropdownClicked:function(e){return!!this.$refs.dropdownButton&&(e.target===this.$refs.dropdownButton||this.$refs.dropdownButton.$el.contains(e.target))},isOptionMatched:function(e,t){return this.isValidOption(e)&&this.getOptionLabel(e).toLocaleLowerCase(this.searchLocale)===t.toLocaleLowerCase(this.searchLocale)},isValidOption:function(e){return u.isNotEmpty(e)&&!(this.isOptionDisabled(e)||this.isOptionGroup(e))},isValidSelectedOption:function(e){return this.isValidOption(e)&&this.isSelected(e)},isSelected:function(e){return u.equals(this.modelValue,this.getOptionValue(e),this.equalityKey)},findFirstOptionIndex:function(){var e=this;return this.visibleOptions.findIndex((function(t){return e.isValidOption(t)}))},findLastOptionIndex:function(){var e=this;return u.findLastIndex(this.visibleOptions,(function(t){return e.isValidOption(t)}))},findNextOptionIndex:function(e){var t=this,i=e<this.visibleOptions.length-1?this.visibleOptions.slice(e+1).findIndex((function(e){return t.isValidOption(e)})):-1;return i>-1?i+e+1:e},findPrevOptionIndex:function(e){var t=this,i=e>0?u.findLastIndex(this.visibleOptions.slice(0,e),(function(e){return t.isValidOption(e)})):-1;return i>-1?i:e},findSelectedOptionIndex:function(){var e=this;return this.hasSelectedOption?this.visibleOptions.findIndex((function(t){return e.isValidSelectedOption(t)})):-1},findFirstFocusedOptionIndex:function(){var e=this.findSelectedOptionIndex();return e<0?this.findFirstOptionIndex():e},findLastFocusedOptionIndex:function(){var e=this.findSelectedOptionIndex();return e<0?this.findLastOptionIndex():e},search:function(e,t,i){null!=t&&("input"===i&&0===t.trim().length||(this.searching=!0,this.$emit("complete",{originalEvent:e,query:t})))},removeOption:function(e,t){var i=this,n=this.modelValue[t],o=this.modelValue.filter((function(e,i){return i!==t})).map((function(e){return i.getOptionValue(e)}));this.updateModel(e,o),this.$emit("item-unselect",{originalEvent:e,value:n}),this.dirty=!0,c.focus(this.$refs.focusInput)},changeFocusedOptionIndex:function(e,t){this.focusedOptionIndex!==t&&(this.focusedOptionIndex=t,this.scrollInView(),(this.selectOnFocus||this.autoHighlight)&&this.onOptionSelect(e,this.visibleOptions[t],!1))},scrollInView:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,i=-1!==t?"".concat(this.id,"_").concat(t):this.focusedOptionId,n=c.findSingle(this.list,'li[id="'.concat(i,'"]'));n?n.scrollIntoView&&n.scrollIntoView({block:"nearest",inline:"start"}):this.virtualScrollerDisabled||setTimeout((function(){e.virtualScroller&&e.virtualScroller.scrollToIndex(-1!==t?t:e.focusedOptionIndex)}),0)},autoUpdateModel:function(){(this.selectOnFocus||this.autoHighlight)&&this.autoOptionFocus&&!this.hasSelectedOption&&(this.focusedOptionIndex=this.findFirstFocusedOptionIndex(),this.onOptionSelect(null,this.visibleOptions[this.focusedOptionIndex],!1))},updateModel:function(e,t){this.$emit("update:modelValue",t),this.$emit("change",{originalEvent:e,value:t})},flatOptions:function(e){var t=this;return(e||[]).reduce((function(e,i,n){e.push({optionGroup:i,group:!0,index:n});var o=t.getOptionGroupChildren(i);return o&&o.forEach((function(t){return e.push(t)})),e}),[])},overlayRef:function(e){this.overlay=e},listRef:function(e,t){this.list=e,t&&t(e)},virtualScrollerRef:function(e){this.virtualScroller=e}},computed:{visibleOptions:function(){return this.optionGroupLabel?this.flatOptions(this.suggestions):this.suggestions||[]},inputValue:function(){if(u.isNotEmpty(this.modelValue)){if("object"===E(this.modelValue)){var e=this.getOptionLabel(this.modelValue);return null!=e?e:this.modelValue}return this.modelValue}return""},hasSelectedOption:function(){return u.isNotEmpty(this.modelValue)},equalityKey:function(){return this.dataKey},searchResultMessageText:function(){return u.isNotEmpty(this.visibleOptions)&&this.overlayVisible?this.searchMessageText.replaceAll("{0}",this.visibleOptions.length):this.emptySearchMessageText},searchMessageText:function(){return this.searchMessage||this.$primevue.config.locale.searchMessage||""},emptySearchMessageText:function(){return this.emptySearchMessage||this.$primevue.config.locale.emptySearchMessage||""},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.multiple?this.modelValue.length:"1"):this.emptySelectionMessageText},focusedOptionId:function(){return-1!==this.focusedOptionIndex?"".concat(this.id,"_").concat(this.focusedOptionIndex):null},focusedMultipleOptionId:function(){return-1!==this.focusedMultipleOptionIndex?"".concat(this.id,"_multiple_option_").concat(this.focusedMultipleOptionIndex):null},ariaSetSize:function(){var e=this;return this.visibleOptions.filter((function(t){return!e.isOptionGroup(t)})).length},virtualScrollerDisabled:function(){return!this.virtualScrollerOptions}},components:{Button:e,VirtualScroller:p,Portal:s,ChevronDownIcon:t,SpinnerIcon:i,TimesCircleIcon:n},directives:{ripple:l}};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 H(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 _(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?H(Object(i),!0).forEach((function(t){N(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):H(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function N(e,t,i){var n;return(t="symbol"==G(n=U(t,"string"))?n:String(n))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function U(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)}var q=["id","value","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],W=["aria-activedescendant"],J=["id","aria-label","aria-setsize","aria-posinset"],Q=["id","placeholder","tabindex","disabled","aria-label","aria-labelledby","aria-expanded","aria-controls","aria-activedescendant"],X=["id"],Y=["id"],Z=["id","aria-label","aria-selected","aria-disabled","aria-setsize","aria-posinset","onClick","onMousemove","data-p-highlight","data-p-focus","data-p-disabled"];z.render=function(e,t,i,n,o,s){var l=y("SpinnerIcon"),r=y("Button"),a=y("VirtualScroller"),u=y("Portal"),c=v("ripple");return m(),b("div",O({ref:"container",class:e.cx("root"),style:e.sx("root"),onClick:t[15]||(t[15]=function(){return s.onContainerClick&&s.onContainerClick.apply(s,arguments)})},e.ptm("root"),{"data-pc-name":"autocomplete"}),[e.multiple?g("",!0):(m(),b("input",O({key:0,ref:"focusInput",id:e.inputId,type:"text",class:[e.cx("input"),e.inputClass],style:e.inputStyle,value:s.inputValue,placeholder:e.placeholder,tabindex:e.disabled?-1:e.tabindex,disabled:e.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-expanded":o.overlayVisible,"aria-controls":o.id+"_list","aria-activedescendant":o.focused?s.focusedOptionId:void 0,onFocus:t[0]||(t[0]=function(){return s.onFocus&&s.onFocus.apply(s,arguments)}),onBlur:t[1]||(t[1]=function(){return s.onBlur&&s.onBlur.apply(s,arguments)}),onKeydown:t[2]||(t[2]=function(){return s.onKeyDown&&s.onKeyDown.apply(s,arguments)}),onInput:t[3]||(t[3]=function(){return s.onInput&&s.onInput.apply(s,arguments)}),onChange:t[4]||(t[4]=function(){return s.onChange&&s.onChange.apply(s,arguments)})},_(_({},e.inputProps),e.ptm("input"))),null,16,q)),e.multiple?(m(),b("ul",O({key:1,ref:"multiContainer",class:e.cx("container"),tabindex:"-1",role:"listbox","aria-orientation":"horizontal","aria-activedescendant":o.focused?s.focusedMultipleOptionId:void 0,onFocus:t[10]||(t[10]=function(){return s.onMultipleContainerFocus&&s.onMultipleContainerFocus.apply(s,arguments)}),onBlur:t[11]||(t[11]=function(){return s.onMultipleContainerBlur&&s.onMultipleContainerBlur.apply(s,arguments)}),onKeydown:t[12]||(t[12]=function(){return s.onMultipleContainerKeyDown&&s.onMultipleContainerKeyDown.apply(s,arguments)})},e.ptm("container")),[(m(!0),b(I,null,x(e.modelValue,(function(t,i){return m(),b("li",O({key:i,id:o.id+"_multiple_option_"+i,class:e.cx("token",{i:i}),role:"option","aria-label":s.getOptionLabel(t),"aria-selected":!0,"aria-setsize":e.modelValue.length,"aria-posinset":i+1},e.ptm("token")),[S(e.$slots,"chip",{value:t},(function(){return[w("span",O({class:e.cx("tokenLabel")},e.ptm("tokenLabel")),k(s.getOptionLabel(t)),17)]})),S(e.$slots,"removetokenicon",{class:L(e.cx("removeTokenIcon")),index:i,onClick:function(e){return s.removeOption(e,i)},removeCallback:function(e){return s.removeOption(e,i)}},(function(){return[(m(),C(M(e.removeTokenIcon?"span":"TimesCircleIcon"),O({class:[e.cx("removeTokenIcon"),e.removeTokenIcon],onClick:function(e){return s.removeOption(e,i)},"aria-hidden":"true"},e.ptm("removeTokenIcon")),null,16,["class","onClick"]))]}))],16,J)})),128)),w("li",O({class:e.cx("inputToken"),role:"option"},e.ptm("inputToken")),[w("input",O({ref:"focusInput",id:e.inputId,type:"text",style:e.inputStyle,class:e.inputClass,placeholder:e.placeholder,tabindex:e.disabled?-1:e.tabindex,disabled:e.disabled,autocomplete:"off",role:"combobox","aria-label":e.ariaLabel,"aria-labelledby":e.ariaLabelledby,"aria-haspopup":"listbox","aria-autocomplete":"list","aria-expanded":o.overlayVisible,"aria-controls":o.id+"_list","aria-activedescendant":o.focused?s.focusedOptionId:void 0,onFocus:t[5]||(t[5]=function(){return s.onFocus&&s.onFocus.apply(s,arguments)}),onBlur:t[6]||(t[6]=function(){return s.onBlur&&s.onBlur.apply(s,arguments)}),onKeydown:t[7]||(t[7]=function(){return s.onKeyDown&&s.onKeyDown.apply(s,arguments)}),onInput:t[8]||(t[8]=function(){return s.onInput&&s.onInput.apply(s,arguments)}),onChange:t[9]||(t[9]=function(){return s.onChange&&s.onChange.apply(s,arguments)})},_(_({},e.inputProps),e.ptm("input"))),null,16,Q)],16)],16,W)):g("",!0),o.searching||e.loading?S(e.$slots,"loadingicon",{key:2,class:L(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(m(),b("i",O({key:0,class:["pi-spin",e.cx("loadingIcon"),e.loadingIcon],"aria-hidden":"true"},e.ptm("loadingIcon")),null,16)):(m(),C(l,O({key:1,class:[e.cx("loadingIcon"),e.loadingIcon],spin:"","aria-hidden":"true"},e.ptm("loadingIcon")),null,16,["class"]))]})):g("",!0),e.dropdown?(m(),C(r,{key:3,ref:"dropdownButton",type:"button",tabindex:"-1",class:L([e.cx("dropdownButton"),e.dropdownClass]),disabled:e.disabled,"aria-hidden":"true",onClick:s.onDropdownClick,unstyled:e.unstyled,pt:e.ptm("dropdownButton"),"data-pc-section":"dropdownbutton"},{icon:V((function(){return[S(e.$slots,"dropdownicon",{class:L(e.dropdownIcon)},(function(){return[(m(),C(M(e.dropdownIcon?"span":"ChevronDownIcon"),O({class:e.dropdownIcon},e.ptm("dropdownButton").icon,{"data-pc-section":"dropdownicon"}),null,16,["class"]))]}))]})),_:3},8,["class","disabled","onClick","unstyled","pt"])):g("",!0),w("span",O({role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenSearchResult"),{"data-p-hidden-accessible":!0}),k(s.searchResultMessageText),17),$(u,{appendTo:e.appendTo},{default:V((function(){return[$(D,O({name:"p-connected-overlay",onEnter:s.onOverlayEnter,onAfterEnter:s.onOverlayAfterEnter,onLeave:s.onOverlayLeave,onAfterLeave:s.onOverlayAfterLeave},e.ptm("transition")),{default:V((function(){return[o.overlayVisible?(m(),b("div",O({key:0,ref:s.overlayRef,class:[e.cx("panel"),e.panelClass],style:_(_({},e.panelStyle),{},{"max-height":s.virtualScrollerDisabled?e.scrollHeight:""}),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)})},_(_({},e.panelProps),e.ptm("panel"))),[S(e.$slots,"header",{value:e.modelValue,suggestions:s.visibleOptions}),$(a,O({ref:s.virtualScrollerRef},e.virtualScrollerOptions,{style:{height:e.scrollHeight},items:s.visibleOptions,tabindex:-1,disabled:s.virtualScrollerDisabled,pt:e.ptm("virtualScroller")}),K({content:V((function(t){var i=t.styleClass,n=t.contentRef,l=t.items,r=t.getItemOptions,a=t.contentStyle,u=t.itemSize;return[w("ul",O({ref:function(e){return s.listRef(e,n)},id:o.id+"_list",class:[e.cx("list"),i],style:a,role:"listbox"},e.ptm("list")),[(m(!0),b(I,null,x(l,(function(t,i){return m(),b(I,{key:s.getOptionRenderKey(t,s.getOptionIndex(i,r))},[s.isOptionGroup(t)?(m(),b("li",O({key:0,id:o.id+"_"+s.getOptionIndex(i,r),style:{height:u?u+"px":void 0},class:e.cx("itemGroup"),role:"option"},e.ptm("itemGroup")),[S(e.$slots,"optiongroup",{option:t.optionGroup,item:t.optionGroup,index:s.getOptionIndex(i,r)},(function(){return[T(k(s.getOptionGroupLabel(t.optionGroup)),1)]}))],16,Y)):F((m(),b("li",O({key:1,id:o.id+"_"+s.getOptionIndex(i,r),style:{height:u?u+"px":void 0},class:e.cx("item",{option:t,i: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)},onMousemove:function(e){return s.onOptionMouseMove(e,s.getOptionIndex(i,r))},"data-p-highlight":s.isSelected(t),"data-p-focus":o.focusedOptionIndex===s.getOptionIndex(i,r),"data-p-disabled":s.isOptionDisabled(t)},s.getPTOptions(t,r,i,"item")),[e.$slots.option?S(e.$slots,"option",{key:0,option:t,index:s.getOptionIndex(i,r)},(function(){return[T(k(s.getOptionLabel(t)),1)]})):S(e.$slots,"item",{key:1,item:t,index:s.getOptionIndex(i,r)},(function(){return[T(k(s.getOptionLabel(t)),1)]}))],16,Z)),[[c]])],64)})),128)),!l||l&&0===l.length?(m(),b("li",O({key:0,class:e.cx("emptyMessage"),role:"option"},e.ptm("emptyMessage")),[S(e.$slots,"empty",{},(function(){return[T(k(s.searchResultMessageText),1)]}))],16)):g("",!0)],16,X)]})),_:2},[e.$slots.loader?{name:"loader",fn:V((function(t){return[S(e.$slots,"loader",{options:t.options})]})),key:"0"}:void 0]),1040,["style","items","disabled","pt"]),S(e.$slots,"footer",{value:e.modelValue,suggestions:s.visibleOptions}),w("span",O({role:"status","aria-live":"polite",class:"p-hidden-accessible"},e.ptm("hiddenSelectedMessage"),{"data-p-hidden-accessible":!0}),k(s.selectedMessageText),17)],16)):g("",!0)]})),_:3},16,["onEnter","onAfterEnter","onLeave","onAfterLeave"])]})),_:3},8,["appendTo"])],16)};export{z as default};