Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vueform/multiselect

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueform/multiselect - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

src/utils/filterObjectKeys.js

13

CHANGELOG.md

@@ -0,1 +1,14 @@

## v1.3.3
> `2021-03-12`
### 🐞 Bug Fixes
- Selected items' label update when options label change ([#39](https://github.com/vueform/multiselect/issues/39)).
- Horizontal scroll fix ([#31](https://github.com/vueform/multiselect/issues/31)).
### 🎉 Feature
- Added `addTagOn` that can enable `enter` and/or `space` key to create a tag.
- Added `required` prop that renders a HTML5 required attribute on a fake input next to multiselect.
- Added `showOptions` prop that hide options list if somebody wants to have only a free-type tag list.
## v1.3.2

@@ -2,0 +15,0 @@

2

dist/multiselect.global.js

@@ -1,1 +0,1 @@

var VueformMultiselect=function(e,t){"use strict";function l(e){return-1!==[null,void 0,!1].indexOf(e)}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function r(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var l=Object.prototype.toString.call(e).slice(8,-1);"Object"===l&&e.constructor&&(l=e.constructor.name);if("Map"===l||"Set"===l)return Array.from(e);if("Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return u(e,t)}(e)||function(){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 u(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=new Array(t);l<t;l++)n[l]=e[l];return n}function o(e){return String(e).toLowerCase().trim()}function i(t,r,u){var i=e.toRefs(t),c=i.options,s=i.mode,d=i.trackBy,v=i.limit,p=i.hideSelected,f=i.createTag,h=i.label,m=i.appendNewTag,y=i.multipleLabel,b=i.object,w=i.loading,g=i.delay,S=i.resolveOnLoad,k=i.minChars,V=i.filterResults,B=i.clearOnSearch,O=i.clearOnSelect,x=i.valueProp,N=i.canDeselect,M=i.max,P=u.internalValue,q=u.externalValue,D=u.search,T=u.blurSearch,C=u.clearSearch,K=u.update,I=u.blurInput,R=u.pointer,j=e.ref([]),A=e.ref([]),E=e.ref(!1),L=e.computed((function(){var e,t=A.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var l,n=t[e];return a(l={},x.value,e),a(l,d.value,n),a(l,h.value,n),l}))),t=t.map((function(e,t){var l;return"object"===n(e)?e:(a(l={},x.value,t),a(l,d.value,e),a(l,h.value,e),l)})),j.value.length&&(t=t.concat(j.value)),t})),$=e.computed((function(){var e=L.value;return W.value.length&&(e=W.value.concat(e)),D.value&&V.value&&(e=e.filter((function(e){return-1!==o(e[d.value]).indexOf(o(D.value))}))),p.value&&(e=e.filter((function(e){return!re(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),H=e.computed((function(){switch(s.value){case"single":return!l(P.value[x.value]);case"multiple":case"tags":return!l(P.value)&&P.value.length>0}})),F=e.computed((function(){return void 0!==y&&void 0!==y.value?y.value(P.value):P.value&&P.value.length>1?"".concat(P.value.length," options selected"):"1 option selected"})),_=e.computed((function(){return!L.value.length&&!E.value})),U=e.computed((function(){return L.value.length>0&&0==$.value.length})),W=e.computed((function(){var e;return!1!==f.value&&D.value?-1!==ae(D.value)?[]:[(e={},a(e,x.value,D.value),a(e,h.value,D.value),a(e,d.value,D.value),e)]:[]})),z=e.computed((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),G=e.computed((function(){return w.value||E.value})),J=function(e){switch("object"!==n(e)&&(e=ne(e)),s.value){case"single":K(e);break;case"multiple":case"tags":K(P.value.concat(e))}r.emit("select",X(e))},Q=function(e){switch("object"!==n(e)&&(e=ne(e)),s.value){case"single":Z();break;case"tags":case"multiple":K(P.value.filter((function(t){return t[x.value]!=e[x.value]})))}r.emit("deselect",X(e))},X=function(e){return b.value?e:e[x.value]},Y=function(e){Q(e)},Z=function(){K(z.value)},ee=function(e){switch(s.value){case"single":return!l(P.value)&&P.value[x.value]==e[x.value];case"tags":case"multiple":return!l(P.value)&&-1!==P.value.map((function(e){return e[x.value]})).indexOf(e[x.value])}},te=function(e){return!0===e.disabled},le=function(){return!(void 0===M||-1===M.value||!H.value&&M.value>0)&&P.value.length>=M.value},ne=function(e){return L.value[L.value.map((function(e){return String(e[x.value])})).indexOf(String(e))]},ae=function(e){return L.value.map((function(e){return o(e[d.value])})).indexOf(o(e))},re=function(e){return"tags"===s.value&&p.value&&ee(e)},ue=function(e){j.value.push(e)},oe=function(){l(q.value)||(P.value=ce(q.value))},ie=function(e){E.value=!0,c.value(D.value).then((function(t){A.value=t,"function"==typeof e&&e(t),E.value=!1}))},ce=function(e){return l(e)?"single"===s.value?{}:[]:b.value?e:"single"===s.value?ne(e)||{}:e.filter((function(e){return!!ne(e)})).map((function(e){return ne(e)}))};if("single"!==s.value&&!l(q.value)&&!Array.isArray(q.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return c&&"function"==typeof c.value?S.value?ie(oe):1==b.value&&oe():(A.value=c&&c.value?c.value:[],oe()),g.value>-1&&e.watch(D,(function(e){e.length<k.value||(E.value=!0,B.value&&(A.value=[]),setTimeout((function(){e==D.value&&c.value(D.value).then((function(t){e==D.value&&(A.value=t,R.value=$.value.filter((function(e){return!0!==e.disabled}))[0]||null,E.value=!1)}))}),g.value))}),{flush:"sync"}),e.watch(q,(function(e){var t,n,a;if(l(e))P.value=ce(e);else switch(s.value){case"single":(b.value?e[x.value]!=P.value[x.value]:e!=P.value[x.value])&&(P.value=ce(e));break;case"multiple":case"tags":t=b.value?e.map((function(e){return e[x.value]})):e,n=P.value.map((function(e){return e[x.value]})),a=n.slice().sort(),t.length===n.length&&t.slice().sort().every((function(e,t){return e===a[t]}))||(P.value=ce(e))}}),{deep:!0}),e.watch((function(){return t.options}),(function(e){"function"!=typeof t.options&&(A.value=t.options)}),{flush:"sync"}),{filteredOptions:$,hasSelected:H,multipleLabelText:F,extendedOptions:L,noOptions:_,noResults:U,resolving:E,busy:G,select:J,deselect:Q,remove:Y,clear:Z,isSelected:ee,isDisabled:te,isMax:le,getOption:ne,handleOptionClick:function(e){if(!te(e))switch(s.value){case"single":if(ee(e))return void(N.value&&Q(e));J(e),T(),I();break;case"multiple":if(ee(e))return void Q(e);if(le())return;J(e),O.value&&C();break;case"tags":if(ee(e))return void Q(e);if(le())return;void 0===ne(e[x.value])&&f.value&&(r.emit("tag",e[x.value]),m.value&&ue(e),C()),O.value&&C(),J(e)}},handleTagRemove:function(e,t){0===t.button?Y(e):t.preventDefault()},refreshOptions:function(e){ie(e)},resolveOptions:ie}}var c={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1}},setup(t,n){const a=function(t,l){var n=e.toRefs(t),a=n.value,r=n.modelValue,u=n.mode;return{internalValue:e.ref("single"!==u.value?[]:{}),externalValue:void 0!==l.expose?r:a}}(t,n),u=function(t,l,n){var a=e.toRefs(t),r=a.searchable,u=(a.id,e.ref(null)),o=e.computed((function(){return r.value?-1:0}));return{multiselect:u,tabindex:o,focusInput:function(){u.value.querySelector(".multiselect-input").focus()},blurInput:function(){u.value.querySelector(".multiselect-input").blur()}}}(t),o={pointer:e.ref(null)},c=function(t,n,a){var r=e.toRefs(t),u=r.object,o=r.valueProp,i=r.mode,c=a.internalValue,s=function(e){return u.value||l(e)?e:Array.isArray(e)?e.map((function(e){return e[o.value]})):e[o.value]},d=function(e){return l(e)?"single"===i.value?{}:[]:e};return{update:function(e){c.value=d(e);var t=s(e);n.emit("change",t),n.emit("input",t),n.emit("update:modelValue",t)}}}(t,n,{internalValue:a.internalValue}),s=function(t,l,n){var a=e.toRefs(t),r=a.searchable,u=a.mode,o=n.internalValue,i=e.ref(null),c=e.ref(null),s=e.computed((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===u.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"}));return e.watch(i,(function(e){l.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=""},focusSearch:function(){c.value.focus()},blurSearch:function(){r.value&&c.value.blur()}}}(t,n,{internalValue:a.internalValue}),d=function(t,l,n){var a=e.toRefs(t),r=a.maxHeight,u=a.disabled,o=a.searchable,i=n.multiselect,c=n.blurInput,s=n.blurSearch,d=n.focusInput,v=n.focusSearch,p=e.ref(!1),f=e.computed((function(){return"".concat(r.value,"px")}));return{isOpen:p,contentMaxHeight:f,openDropdown:function(){u.value||(p.value=!0,l.emit("open"))},closeDropdown:function(){p.value=!1,l.emit("close")},open:function(){o&&o.value?v():d()},close:function(){o&&o.value?s():c()},handleInputMousedown:function(e){p.value&&!o.value&&(i.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),i.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(t,n,{multiselect:u.multiselect,blurInput:u.blurInput,blurSearch:s.blurSearch,focusInput:u.focusInput,focusSearch:s.focusSearch}),v=i(t,n,{externalValue:a.externalValue,internalValue:a.internalValue,search:s.search,blurSearch:s.blurSearch,clearSearch:s.clearSearch,update:c.update,blurInput:u.blurInput,pointer:o.pointer}),p=function(t,l,n){var a=e.toRefs(t),r=a.id,u=a.valueProp,o=n.filteredOptions,i=n.handleOptionClick,c=n.search,s=n.pointer,d=e.computed((function(){return o.value.filter((function(e){return!0!==e.disabled}))})),v=function(e){s.value=e},p=function(){s.value=d.value[0]||null},f=function(){s.value=null},h=function(){var e=document.getElementById(r.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return e.watch(c,(function(e){p()})),{pointer:s,isPointed:function(e){return!!s.value&&s.value[u.value]==e[u.value]},setPointer:v,setPointerFirst:p,clearPointer:f,selectPointer:function(){s.value&&!0!==s.value.disabled?(i(s.value),f()):f()},forwardPointer:function(){if(null===s.value)v(d.value[0]||null);else{var t=d.value.map((function(e){return e[u.value]})).indexOf(s.value[u.value])+1;d.value.length<=t&&(t=0),v(d.value[t]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===s.value)v(d.value[d.value.length-1]||null);else{var t=d.value.map((function(e){return e[u.value]})).indexOf(s.value[u.value])-1;t<0&&(t=d.value.length-1),v(d.value[t]||null)}e.nextTick((function(){h()}))}}}(t,0,{filteredOptions:v.filteredOptions,handleOptionClick:v.handleOptionClick,search:s.search,pointer:o.pointer}),f=function(t,l,n){var a=e.toRefs(t).mode,u=n.internalValue,o=n.update,i=n.closeDropdown,c=n.clearPointer,s=n.search;return{handleBackspace:function(e){"single"!==a.value&&o(r(u.value).slice(0,-1))},handleEsc:function(e){i(),c(),e.target.blur()},handleSearchBackspace:function(e){""!==s.value&&e.stopPropagation()}}}(t,0,{internalValue:a.internalValue,update:c.update,closeDropdown:d.closeDropdown,clearPointer:p.clearPointer,search:s.search});return{...a,...d,...u,...o,...c,...s,...v,...p,...f}}};const s={class:"multiselect-single-label"},d={class:"multiselect-multiple-label"},v={key:2,class:"multiselect-search"},p={key:3,class:"multiselect-tags"},f={class:"multiselect-tag"},h={class:"multiselect-placeholder"},m={class:"multiselect-spinner"},y={class:"multiselect-no-options"},b={class:"multiselect-no-results"};return c.render=function(e,l,n,a,r,u){return t.openBlock(),t.createBlock("div",{class:["multiselect",[`is-${n.mode}`,{"is-open":e.isOpen,"is-searchable":n.searchable,"is-disabled":n.disabled,"no-caret":!n.caret}]],id:n.id,onKeydown:l[28]||(l[28]=t.withKeys(t.withModifiers((()=>{}),["prevent"]),["enter"])),ref:"multiselect"},[t.createVNode("div",{class:"multiselect-input",tabindex:e.tabindex,onMousedown:l[19]||(l[19]=(...t)=>e.handleInputMousedown&&e.handleInputMousedown(...t)),onFocus:l[20]||(l[20]=(...t)=>e.openDropdown&&e.openDropdown(...t)),onBlur:l[21]||(l[21]=(...t)=>e.closeDropdown&&e.closeDropdown(...t)),onKeyup:[l[22]||(l[22]=t.withKeys(((...t)=>e.handleEsc&&e.handleEsc(...t)),["esc"])),l[23]||(l[23]=t.withKeys(((...t)=>e.selectPointer&&e.selectPointer(...t)),["enter"]))],onKeydown:[l[24]||(l[24]=t.withKeys(t.withModifiers(((...t)=>e.handleBackspace&&e.handleBackspace(...t)),["prevent"]),["delete"])),l[25]||(l[25]=t.withKeys(t.withModifiers(((...t)=>e.backwardPointer&&e.backwardPointer(...t)),["prevent"]),["up"])),l[26]||(l[26]=t.withKeys(t.withModifiers(((...t)=>e.forwardPointer&&e.forwardPointer(...t)),["prevent"]),["down"]))]},[t.createCommentVNode(" Single label "),"single"==n.mode&&e.hasSelected&&!e.search&&e.internalValue?t.renderSlot(e.$slots,"singlelabel",{key:0,value:e.internalValue},(()=>[t.createVNode("div",s,t.toDisplayString(e.internalValue[n.label]),1)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Multiple label "),"multiple"==n.mode&&e.hasSelected&&!e.search?t.renderSlot(e.$slots,"multiplelabel",{key:1,values:e.internalValue},(()=>[t.createVNode("div",d,t.toDisplayString(e.multipleLabelText),1)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Search "),"tags"!==n.mode&&n.searchable&&!n.disabled?(t.openBlock(),t.createBlock("div",v,[t.withDirectives(t.createVNode("input",{"onUpdate:modelValue":l[1]||(l[1]=t=>e.search=t),onFocus:l[2]||(l[2]=t.withModifiers(((...t)=>e.openDropdown&&e.openDropdown(...t)),["stop"])),onBlur:l[3]||(l[3]=t.withModifiers(((...t)=>e.closeDropdown&&e.closeDropdown(...t)),["stop"])),onKeyup:[l[4]||(l[4]=t.withKeys(t.withModifiers(((...t)=>e.handleEsc&&e.handleEsc(...t)),["stop"]),["esc"])),l[5]||(l[5]=t.withKeys(t.withModifiers(((...t)=>e.selectPointer&&e.selectPointer(...t)),["stop"]),["enter"]))],onKeydown:[l[6]||(l[6]=t.withKeys(((...t)=>e.handleSearchBackspace&&e.handleSearchBackspace(...t)),["delete"])),l[7]||(l[7]=t.withKeys(t.withModifiers(((...t)=>e.backwardPointer&&e.backwardPointer(...t)),["stop"]),["up"])),l[8]||(l[8]=t.withKeys(t.withModifiers(((...t)=>e.forwardPointer&&e.forwardPointer(...t)),["stop"]),["down"]))],ref:"input"},null,544),[[t.vModelText,e.search]])])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Tags (with search) "),"tags"==n.mode?(t.openBlock(),t.createBlock("div",p,[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.internalValue,((a,r,u)=>(t.openBlock(),t.createBlock("span",{key:u},[t.renderSlot(e.$slots,"tag",{option:a,handleTagRemove:e.handleTagRemove,disabled:n.disabled},(()=>[t.createVNode("div",f,[t.createTextVNode(t.toDisplayString(a[n.label])+" ",1),n.disabled?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock("i",{key:0,onClick:l[9]||(l[9]=t.withModifiers((()=>{}),["prevent"])),onMousedown:t.withModifiers((t=>e.handleTagRemove(a,t)),["prevent","stop"])},null,40,["onMousedown"]))])]))])))),128)),n.searchable&&!n.disabled?(t.openBlock(),t.createBlock("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[t.withDirectives(t.createVNode("input",{"onUpdate:modelValue":l[10]||(l[10]=t=>e.search=t),onFocus:l[11]||(l[11]=t.withModifiers(((...t)=>e.openDropdown&&e.openDropdown(...t)),["stop"])),onBlur:l[12]||(l[12]=t.withModifiers(((...t)=>e.closeDropdown&&e.closeDropdown(...t)),["stop"])),onKeyup:[l[13]||(l[13]=t.withKeys(t.withModifiers(((...t)=>e.handleEsc&&e.handleEsc(...t)),["stop"]),["esc"])),l[14]||(l[14]=t.withKeys(t.withModifiers(((...t)=>e.selectPointer&&e.selectPointer(...t)),["stop"]),["enter"]))],onKeydown:[l[15]||(l[15]=t.withKeys(((...t)=>e.handleSearchBackspace&&e.handleSearchBackspace(...t)),["delete"])),l[16]||(l[16]=t.withKeys(t.withModifiers(((...t)=>e.backwardPointer&&e.backwardPointer(...t)),["stop"]),["up"])),l[17]||(l[17]=t.withKeys(t.withModifiers(((...t)=>e.forwardPointer&&e.forwardPointer(...t)),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[t.vModelText,e.search]])],4)):t.createCommentVNode("v-if",!0)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Placeholder "),!n.placeholder||e.hasSelected||e.search?t.createCommentVNode("v-if",!0):t.renderSlot(e.$slots,"placeholder",{key:4},(()=>[t.createVNode("div",h,t.toDisplayString(n.placeholder),1)])),t.createVNode(t.Transition,{name:"multiselect-loading"},{default:t.withCtx((()=>[t.withDirectives(t.createVNode("div",m,null,512),[[t.vShow,e.busy]])])),_:1}),"single"!==n.mode&&e.hasSelected&&!n.disabled?(t.openBlock(),t.createBlock("a",{key:5,class:"multiselect-clear",onClick:l[18]||(l[18]=t.withModifiers(((...t)=>e.clear&&e.clear(...t)),["prevent"]))})):t.createCommentVNode("v-if",!0)],40,["tabindex"]),t.createCommentVNode(" Options "),e.resolving&&n.clearOnSearch?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(t.Transition,{key:0,name:"multiselect",onAfterLeave:e.clearSearch},{default:t.withCtx((()=>[t.withDirectives(t.createVNode("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[t.renderSlot(e.$slots,"beforelist"),(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.filteredOptions,((a,r,u)=>(t.openBlock(),t.createBlock("a",{tabindex:-1,href:"",class:["multiselect-option",{"is-pointed":e.isPointed(a),"is-selected":e.isSelected(a),"is-disabled":e.isDisabled(a)}],key:u,onMousedown:l[27]||(l[27]=t.withModifiers((()=>{}),["prevent"])),onMouseenter:t=>e.setPointer(a),onClick:t.withModifiers((t=>e.handleOptionClick(a)),["stop","prevent"])},[t.renderSlot(e.$slots,"option",{option:a,search:e.search},(()=>[t.createVNode("span",null,t.toDisplayString(a[n.label]),1)]))],42,["onMouseenter","onClick"])))),128)),t.withDirectives(t.createVNode("span",null,[t.renderSlot(e.$slots,"nooptions",{},(()=>[t.createVNode("div",y,t.toDisplayString(n.noOptionsText),1)]))],512),[[t.vShow,e.noOptions]]),t.withDirectives(t.createVNode("span",null,[t.renderSlot(e.$slots,"noresults",{},(()=>[t.createVNode("div",b,t.toDisplayString(n.noResultsText),1)]))],512),[[t.vShow,e.noResults]]),t.renderSlot(e.$slots,"afterlist")],4),[[t.vShow,e.isOpen]])])),_:3},8,["onAfterLeave"]))],42,["id"])},c.__file="src/Multiselect.vue",c}(Vue,Vue);
var VueformMultiselect=function(e,t){"use strict";function l(e){return-1!==[null,void 0,!1].indexOf(e)}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function r(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var l=Object.prototype.toString.call(e).slice(8,-1);"Object"===l&&e.constructor&&(l=e.constructor.name);if("Map"===l||"Set"===l)return Array.from(e);if("Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return u(e,t)}(e)||function(){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 u(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=new Array(t);l<t;l++)n[l]=e[l];return n}function o(e){return String(e).toLowerCase().trim()}function i(t,r,u){var i=e.toRefs(t),c=i.options,s=i.mode,d=i.trackBy,v=i.limit,p=i.hideSelected,f=i.createTag,h=i.label,m=i.appendNewTag,y=i.multipleLabel,g=i.object,w=i.loading,b=i.delay,S=i.resolveOnLoad,k=i.minChars,V=i.filterResults,O=i.clearOnSearch,B=i.clearOnSelect,x=i.valueProp,T=i.canDeselect,q=i.max,M=u.internalValue,N=u.externalValue,P=u.currentValue,D=u.search,C=u.blurSearch,K=u.clearSearch,A=u.update,j=u.blurInput,I=u.pointer,R=e.ref([]),E=e.ref([]),L=e.ref(!1),H=e.computed((function(){var e,t=E.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var l,n=t[e];return a(l={},x.value,e),a(l,d.value,n),a(l,h.value,n),l}))),t=t.map((function(e,t){var l;return"object"===n(e)?e:(a(l={},x.value,t),a(l,d.value,e),a(l,h.value,e),l)})),R.value.length&&(t=t.concat(R.value)),t})),$=e.computed((function(){var e=H.value;return z.value.length&&(e=z.value.concat(e)),D.value&&V.value&&(e=e.filter((function(e){return-1!==o(e[d.value]).indexOf(o(D.value))}))),p.value&&(e=e.filter((function(e){return!ue(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),F=e.computed((function(){switch(s.value){case"single":return!l(M.value[x.value]);case"multiple":case"tags":return!l(M.value)&&M.value.length>0}})),_=e.computed((function(){return void 0!==y&&void 0!==y.value?y.value(M.value):M.value&&M.value.length>1?"".concat(M.value.length," options selected"):"1 option selected"})),U=e.computed((function(){return!H.value.length&&!L.value})),W=e.computed((function(){return H.value.length>0&&0==$.value.length})),z=e.computed((function(){var e;return!1!==f.value&&D.value?-1!==re(D.value)?[]:[(e={},a(e,x.value,D.value),a(e,h.value,D.value),a(e,d.value,D.value),e)]:[]})),G=e.computed((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),J=e.computed((function(){return w.value||L.value})),Q=function(e){switch("object"!==n(e)&&(e=ae(e)),s.value){case"single":A(e);break;case"multiple":case"tags":A(M.value.concat(e))}r.emit("select",Y(e))},X=function(e){switch("object"!==n(e)&&(e=ae(e)),s.value){case"single":ee();break;case"tags":case"multiple":A(M.value.filter((function(t){return t[x.value]!=e[x.value]})))}r.emit("deselect",Y(e))},Y=function(e){return g.value?e:e[x.value]},Z=function(e){X(e)},ee=function(){A(G.value)},te=function(e){switch(s.value){case"single":return!l(M.value)&&M.value[x.value]==e[x.value];case"tags":case"multiple":return!l(M.value)&&-1!==M.value.map((function(e){return e[x.value]})).indexOf(e[x.value])}},le=function(e){return!0===e.disabled},ne=function(){return!(void 0===q||-1===q.value||!F.value&&q.value>0)&&M.value.length>=q.value},ae=function(e){return H.value[H.value.map((function(e){return String(e[x.value])})).indexOf(String(e))]},re=function(e){return H.value.map((function(e){return o(e[d.value])})).indexOf(o(e))},ue=function(e){return"tags"===s.value&&p.value&&te(e)},oe=function(e){R.value.push(e)},ie=function(){l(N.value)||(M.value=se(N.value))},ce=function(e){L.value=!0,c.value(D.value).then((function(t){E.value=t,"function"==typeof e&&e(t),L.value=!1}))},se=function(e){return l(e)?"single"===s.value?{}:[]:g.value?e:"single"===s.value?ae(e)||{}:e.filter((function(e){return!!ae(e)})).map((function(e){return ae(e)}))};if("single"!==s.value&&!l(N.value)&&!Array.isArray(N.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return c&&"function"==typeof c.value?S.value?ce(ie):1==g.value&&ie():(E.value=c&&c.value?c.value:[],ie()),b.value>-1&&e.watch(D,(function(e){e.length<k.value||(L.value=!0,O.value&&(E.value=[]),setTimeout((function(){e==D.value&&c.value(D.value).then((function(t){e==D.value&&(E.value=t,I.value=$.value.filter((function(e){return!0!==e.disabled}))[0]||null,L.value=!1)}))}),b.value))}),{flush:"sync"}),e.watch(N,(function(e){var t,n,a;if(l(e))M.value=se(e);else switch(s.value){case"single":(g.value?e[x.value]!=M.value[x.value]:e!=M.value[x.value])&&(M.value=se(e));break;case"multiple":case"tags":t=g.value?e.map((function(e){return e[x.value]})):e,n=M.value.map((function(e){return e[x.value]})),a=n.slice().sort(),t.length===n.length&&t.slice().sort().every((function(e,t){return e===a[t]}))||(M.value=se(e))}}),{deep:!0}),e.watch((function(){return t.options}),(function(e){"function"!=typeof t.options&&(E.value=t.options)}),{flush:"sync"}),e.watch(H,(function(e,t){var l;H.value.length&&P.value&&P.value.length&&("single"===s.value?l=H.value[H.value.map((function(e){return e[x.value]})).indexOf(P.value)]:(l=[],P.value.forEach((function(e){l.push(H.value[H.value.map((function(e){return e[x.value]})).indexOf(e)])}))),g.value?A(l):M.value=l)}),{flush:"sync",deep:!0,immediate:!1}),{filteredOptions:$,hasSelected:F,multipleLabelText:_,extendedOptions:H,noOptions:U,noResults:W,resolving:L,busy:J,select:Q,deselect:X,remove:Z,clear:ee,isSelected:te,isDisabled:le,isMax:ne,getOption:ae,handleOptionClick:function(e){if(!le(e))switch(s.value){case"single":if(te(e))return void(T.value&&X(e));Q(e),C(),j();break;case"multiple":if(te(e))return void X(e);if(ne())return;Q(e),B.value&&K();break;case"tags":if(te(e))return void X(e);if(ne())return;void 0===ae(e[x.value])&&f.value&&(r.emit("tag",e[x.value]),m.value&&oe(e),K()),B.value&&K(),Q(e)}},handleTagRemove:function(e,t){0===t.button?Z(e):t.preventDefault()},refreshOptions:function(e){ce(e)},resolveOptions:ce}}var c={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1},showOptions:{type:Boolean,required:!1,default:!0},addTagOn:{type:Array,required:!1,default:()=>["enter"]},required:{type:Boolean,required:!1,default:!1}},setup(t,n){const a=function(t,l){var n=e.toRefs(t),a=n.value,r=n.modelValue,u=n.mode,o=n.valueProp,i=e.ref("single"!==u.value?[]:{}),c=void 0!==l.expose?r:a,s=e.computed((function(){return Object.keys(i.value).length?"single"!==u.value?i.value.map((function(e){return e[o.value]})):i.value[o.value]:i.value})),d=e.computed((function(){return"single"!==u.value?i.value.map((function(e){return e[o.value]})).join(","):i.value[o.value]}));return{internalValue:i,externalValue:c,currentValue:s,textValue:d}}(t,n),u=function(t,l,n){var a=e.toRefs(t),r=a.searchable,u=(a.id,e.ref(null)),o=e.computed((function(){return r.value?-1:0}));return{multiselect:u,tabindex:o,focusInput:function(){u.value.querySelector(".multiselect-input").focus()},blurInput:function(){u.value.querySelector(".multiselect-input").blur()}}}(t),o={pointer:e.ref(null)},c=function(t,n,a){var r=e.toRefs(t),u=r.object,o=r.valueProp,i=r.mode,c=a.internalValue,s=function(e){return u.value||l(e)?e:Array.isArray(e)?e.map((function(e){return e[o.value]})):e[o.value]},d=function(e){return l(e)?"single"===i.value?{}:[]:e};return{update:function(e){c.value=d(e);var t=s(e);n.emit("change",t),n.emit("input",t),n.emit("update:modelValue",t)}}}(t,n,{internalValue:a.internalValue}),s=function(t,l,n){var a=e.toRefs(t),r=a.searchable,u=a.mode,o=n.internalValue,i=e.ref(null),c=e.ref(null),s=e.computed((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===u.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"}));return e.watch(i,(function(e){l.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=""},focusSearch:function(){c.value.focus()},blurSearch:function(){r.value&&c.value.blur()}}}(t,n,{internalValue:a.internalValue}),d=function(t,l,n){var a=e.toRefs(t),r=a.maxHeight,u=a.disabled,o=a.searchable,i=n.multiselect,c=n.blurInput,s=n.blurSearch,d=n.focusInput,v=n.focusSearch,p=e.ref(!1),f=e.computed((function(){return"".concat(r.value,"px")}));return{isOpen:p,contentMaxHeight:f,openDropdown:function(){u.value||(p.value=!0,l.emit("open"))},closeDropdown:function(){p.value=!1,l.emit("close")},open:function(){o&&o.value?v():d()},close:function(){o&&o.value?s():c()},handleInputMousedown:function(e){p.value&&!o.value&&(i.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),i.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(t,n,{multiselect:u.multiselect,blurInput:u.blurInput,blurSearch:s.blurSearch,focusInput:u.focusInput,focusSearch:s.focusSearch}),v=i(t,n,{externalValue:a.externalValue,internalValue:a.internalValue,currentValue:a.currentValue,search:s.search,blurSearch:s.blurSearch,clearSearch:s.clearSearch,update:c.update,blurInput:u.blurInput,pointer:o.pointer}),p=function(t,l,n){var a=e.toRefs(t),r=a.id,u=a.valueProp,o=n.filteredOptions,i=n.handleOptionClick,c=n.search,s=n.pointer,d=e.computed((function(){return o.value.filter((function(e){return!0!==e.disabled}))})),v=function(e){s.value=e},p=function(){s.value=d.value[0]||null},f=function(){s.value=null},h=function(){var e=document.getElementById(r.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return e.watch(c,(function(e){p()})),{pointer:s,isPointed:function(e){return!!s.value&&s.value[u.value]==e[u.value]},setPointer:v,setPointerFirst:p,clearPointer:f,selectPointer:function(){s.value&&!0!==s.value.disabled?(i(s.value),f()):f()},forwardPointer:function(){if(null===s.value)v(d.value[0]||null);else{var t=d.value.map((function(e){return e[u.value]})).indexOf(s.value[u.value])+1;d.value.length<=t&&(t=0),v(d.value[t]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===s.value)v(d.value[d.value.length-1]||null);else{var t=d.value.map((function(e){return e[u.value]})).indexOf(s.value[u.value])-1;t<0&&(t=d.value.length-1),v(d.value[t]||null)}e.nextTick((function(){h()}))}}}(t,0,{filteredOptions:v.filteredOptions,handleOptionClick:v.handleOptionClick,search:s.search,pointer:o.pointer}),f=function(t,l,n){var a=e.toRefs(t),u=a.mode,o=a.addTagOn,i={enter:13,space:32},c=n.internalValue,s=n.update,d=n.closeDropdown,v=n.clearPointer,p=n.search,f=n.selectPointer;return{handleBackspace:function(e){"single"!==u.value&&s(r(c.value).slice(0,-1))},handleEsc:function(e){d(),v(),e.target.blur()},handleSearchBackspace:function(e){""!==p.value&&e.stopPropagation()},handleAddTag:function(e){-1!==Object.values(function(e,t){var l,n={};for(l in e)e.hasOwnProperty(l)&&-1!==t.indexOf(l)&&(n[l]=e[l]);return n}(i,o.value)).indexOf(e.keyCode)&&f()}}}(t,0,{internalValue:a.internalValue,update:c.update,closeDropdown:d.closeDropdown,clearPointer:p.clearPointer,search:s.search,selectPointer:p.selectPointer});return{...a,...d,...u,...o,...c,...s,...v,...p,...f}}};const s={class:"multiselect-single-label"},d={class:"multiselect-multiple-label"},v={key:2,class:"multiselect-search"},p={key:3,class:"multiselect-tags"},f={class:"multiselect-tag"},h={class:"multiselect-placeholder"},m={class:"multiselect-spinner"},y={class:"multiselect-no-options"},g={class:"multiselect-no-results"};return c.render=function(e,l,n,a,r,u){return t.openBlock(),t.createBlock("div",{class:["multiselect",[`is-${n.mode}`,{"is-open":e.isOpen,"is-searchable":n.searchable,"is-disabled":n.disabled,"no-caret":!n.caret}]],id:n.id,onKeydown:l[31]||(l[31]=t.withKeys(t.withModifiers((()=>{}),["prevent"]),["enter"])),ref:"multiselect"},[t.createVNode("div",{class:"multiselect-input",tabindex:e.tabindex,onMousedown:l[21]||(l[21]=(...t)=>e.handleInputMousedown&&e.handleInputMousedown(...t)),onFocus:l[22]||(l[22]=(...t)=>e.openDropdown&&e.openDropdown(...t)),onBlur:l[23]||(l[23]=(...t)=>e.closeDropdown&&e.closeDropdown(...t)),onKeyup:[l[24]||(l[24]=t.withKeys(((...t)=>e.handleEsc&&e.handleEsc(...t)),["esc"])),l[25]||(l[25]=t.withKeys(((...t)=>e.handleAddTag&&e.handleAddTag(...t)),["enter"])),l[26]||(l[26]=t.withKeys(((...t)=>e.handleAddTag&&e.handleAddTag(...t)),["space"]))],onKeydown:[l[27]||(l[27]=t.withKeys(t.withModifiers(((...t)=>e.handleBackspace&&e.handleBackspace(...t)),["prevent"]),["delete"])),l[28]||(l[28]=t.withKeys(t.withModifiers(((...t)=>e.backwardPointer&&e.backwardPointer(...t)),["prevent"]),["up"])),l[29]||(l[29]=t.withKeys(t.withModifiers(((...t)=>e.forwardPointer&&e.forwardPointer(...t)),["prevent"]),["down"]))]},[t.createCommentVNode(" Single label "),"single"==n.mode&&e.hasSelected&&!e.search&&e.internalValue?t.renderSlot(e.$slots,"singlelabel",{key:0,value:e.internalValue},(()=>[t.createVNode("div",s,t.toDisplayString(e.internalValue[n.label]),1)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Multiple label "),"multiple"==n.mode&&e.hasSelected&&!e.search?t.renderSlot(e.$slots,"multiplelabel",{key:1,values:e.internalValue},(()=>[t.createVNode("div",d,t.toDisplayString(e.multipleLabelText),1)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Search "),"tags"!==n.mode&&n.searchable&&!n.disabled?(t.openBlock(),t.createBlock("div",v,[t.withDirectives(t.createVNode("input",{"onUpdate:modelValue":l[1]||(l[1]=t=>e.search=t),onFocus:l[2]||(l[2]=t.withModifiers(((...t)=>e.openDropdown&&e.openDropdown(...t)),["stop"])),onBlur:l[3]||(l[3]=t.withModifiers(((...t)=>e.closeDropdown&&e.closeDropdown(...t)),["stop"])),onKeyup:[l[4]||(l[4]=t.withKeys(t.withModifiers(((...t)=>e.handleEsc&&e.handleEsc(...t)),["stop"]),["esc"])),l[5]||(l[5]=t.withKeys(t.withModifiers(((...t)=>e.selectPointer&&e.selectPointer(...t)),["stop"]),["enter"])),l[6]||(l[6]=t.withKeys(t.withModifiers(((...t)=>e.selectPointer&&e.selectPointer(...t)),["stop"]),["space"]))],onKeydown:[l[7]||(l[7]=t.withKeys(((...t)=>e.handleSearchBackspace&&e.handleSearchBackspace(...t)),["delete"])),l[8]||(l[8]=t.withKeys(t.withModifiers(((...t)=>e.backwardPointer&&e.backwardPointer(...t)),["stop"]),["up"])),l[9]||(l[9]=t.withKeys(t.withModifiers(((...t)=>e.forwardPointer&&e.forwardPointer(...t)),["stop"]),["down"]))],ref:"input"},null,544),[[t.vModelText,e.search]])])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Tags (with search) "),"tags"==n.mode?(t.openBlock(),t.createBlock("div",p,[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.internalValue,((a,r,u)=>(t.openBlock(),t.createBlock("span",{key:u},[t.renderSlot(e.$slots,"tag",{option:a,handleTagRemove:e.handleTagRemove,disabled:n.disabled},(()=>[t.createVNode("div",f,[t.createTextVNode(t.toDisplayString(a[n.label])+" ",1),n.disabled?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock("i",{key:0,onClick:l[10]||(l[10]=t.withModifiers((()=>{}),["prevent"])),onMousedown:t.withModifiers((t=>e.handleTagRemove(a,t)),["prevent","stop"])},null,40,["onMousedown"]))])]))])))),128)),n.searchable&&!n.disabled?(t.openBlock(),t.createBlock("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[t.withDirectives(t.createVNode("input",{"onUpdate:modelValue":l[11]||(l[11]=t=>e.search=t),onFocus:l[12]||(l[12]=t.withModifiers(((...t)=>e.openDropdown&&e.openDropdown(...t)),["stop"])),onBlur:l[13]||(l[13]=t.withModifiers(((...t)=>e.closeDropdown&&e.closeDropdown(...t)),["stop"])),onKeyup:[l[14]||(l[14]=t.withKeys(t.withModifiers(((...t)=>e.handleEsc&&e.handleEsc(...t)),["stop"]),["esc"])),l[15]||(l[15]=t.withKeys(t.withModifiers(((...t)=>e.handleAddTag&&e.handleAddTag(...t)),["stop"]),["enter"])),l[16]||(l[16]=t.withKeys(t.withModifiers(((...t)=>e.handleAddTag&&e.handleAddTag(...t)),["stop"]),["space"]))],onKeydown:[l[17]||(l[17]=t.withKeys(((...t)=>e.handleSearchBackspace&&e.handleSearchBackspace(...t)),["delete"])),l[18]||(l[18]=t.withKeys(t.withModifiers(((...t)=>e.backwardPointer&&e.backwardPointer(...t)),["stop"]),["up"])),l[19]||(l[19]=t.withKeys(t.withModifiers(((...t)=>e.forwardPointer&&e.forwardPointer(...t)),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[t.vModelText,e.search]])],4)):t.createCommentVNode("v-if",!0)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Placeholder "),!n.placeholder||e.hasSelected||e.search?t.createCommentVNode("v-if",!0):t.renderSlot(e.$slots,"placeholder",{key:4},(()=>[t.createVNode("div",h,t.toDisplayString(n.placeholder),1)])),t.createVNode(t.Transition,{name:"multiselect-loading"},{default:t.withCtx((()=>[t.withDirectives(t.createVNode("div",m,null,512),[[t.vShow,e.busy]])])),_:1}),"single"!==n.mode&&e.hasSelected&&!n.disabled?(t.openBlock(),t.createBlock("a",{key:5,class:"multiselect-clear",onClick:l[20]||(l[20]=t.withModifiers(((...t)=>e.clear&&e.clear(...t)),["prevent"]))})):t.createCommentVNode("v-if",!0)],40,["tabindex"]),t.createCommentVNode(" Options "),e.resolving&&n.clearOnSearch?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(t.Transition,{key:0,name:"multiselect",onAfterLeave:e.clearSearch},{default:t.withCtx((()=>[t.withDirectives(t.createVNode("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[t.renderSlot(e.$slots,"beforelist"),(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.filteredOptions,((a,r,u)=>(t.openBlock(),t.createBlock("span",{tabindex:-1,class:["multiselect-option",{"is-pointed":e.isPointed(a),"is-selected":e.isSelected(a),"is-disabled":e.isDisabled(a)}],key:u,onMousedown:l[30]||(l[30]=t.withModifiers((()=>{}),["prevent"])),onMouseenter:t=>e.setPointer(a),onClick:t.withModifiers((t=>e.handleOptionClick(a)),["stop","prevent"])},[t.renderSlot(e.$slots,"option",{option:a,search:e.search},(()=>[t.createVNode("span",null,t.toDisplayString(a[n.label]),1)]))],42,["onMouseenter","onClick"])))),128)),t.withDirectives(t.createVNode("span",null,[t.renderSlot(e.$slots,"nooptions",{},(()=>[t.createVNode("div",y,t.toDisplayString(n.noOptionsText),1)]))],512),[[t.vShow,e.noOptions]]),t.withDirectives(t.createVNode("span",null,[t.renderSlot(e.$slots,"noresults",{},(()=>[t.createVNode("div",g,t.toDisplayString(n.noResultsText),1)]))],512),[[t.vShow,e.noResults]]),t.renderSlot(e.$slots,"afterlist")],4),[[t.vShow,e.isOpen&&n.showOptions]])])),_:3},8,["onAfterLeave"])),t.createCommentVNode(" Hacky input element to show HTML5 required warning "),n.required?(t.openBlock(),t.createBlock("input",{key:1,class:"multiselect-fake-input",tabindex:"-1",value:e.textValue,required:""},null,8,["value"])):t.createCommentVNode("v-if",!0)],42,["id"])},c.__file="src/Multiselect.vue",c}(Vue,Vue);

@@ -1,1 +0,1 @@

import{toRefs as e,ref as l,computed as t,watch as n,nextTick as a,openBlock as u,createBlock as r,withKeys as o,withModifiers as i,createVNode as c,createCommentVNode as s,renderSlot as d,toDisplayString as v,withDirectives as p,vModelText as f,Fragment as h,renderList as m,createTextVNode as b,Transition as g,withCtx as y,vShow as S}from"vue";function w(e){return-1!==[null,void 0,!1].indexOf(e)}function O(e){return String(e).toLowerCase().trim()}function k(e){return(k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function P(e,l,t){return l in e?Object.defineProperty(e,l,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[l]=t,e}function q(a,u,r){var o=e(a),i=o.options,c=o.mode,s=o.trackBy,d=o.limit,v=o.hideSelected,p=o.createTag,f=o.label,h=o.appendNewTag,m=o.multipleLabel,b=o.object,g=o.loading,y=o.delay,S=o.resolveOnLoad,q=o.minChars,x=o.filterResults,V=o.clearOnSearch,B=o.clearOnSelect,T=o.valueProp,D=o.canDeselect,I=o.max,j=r.internalValue,M=r.externalValue,A=r.search,C=r.blurSearch,E=r.clearSearch,$=r.update,N=r.blurInput,R=r.pointer,H=l([]),L=l([]),K=l(!1),F=t((function(){var e,l=L.value||[];return e=l,"[object Object]"===Object.prototype.toString.call(e)&&(l=Object.keys(l).map((function(e){var t,n=l[e];return P(t={},T.value,e),P(t,s.value,n),P(t,f.value,n),t}))),l=l.map((function(e,l){var t;return"object"===k(e)?e:(P(t={},T.value,l),P(t,s.value,e),P(t,f.value,e),t)})),H.value.length&&(l=l.concat(H.value)),l})),_=t((function(){var e=F.value;return J.value.length&&(e=J.value.concat(e)),A.value&&x.value&&(e=e.filter((function(e){return-1!==O(e[s.value]).indexOf(O(A.value))}))),v.value&&(e=e.filter((function(e){return!ie(e)}))),d.value>0&&(e=e.slice(0,d.value)),e})),U=t((function(){switch(c.value){case"single":return!w(j.value[T.value]);case"multiple":case"tags":return!w(j.value)&&j.value.length>0}})),W=t((function(){return void 0!==m&&void 0!==m.value?m.value(j.value):j.value&&j.value.length>1?"".concat(j.value.length," options selected"):"1 option selected"})),z=t((function(){return!F.value.length&&!K.value})),G=t((function(){return F.value.length>0&&0==_.value.length})),J=t((function(){var e;return!1!==p.value&&A.value?-1!==oe(A.value)?[]:[(e={},P(e,T.value,A.value),P(e,f.value,A.value),P(e,s.value,A.value),e)]:[]})),Q=t((function(){switch(c.value){case"single":return null;case"multiple":case"tags":return[]}})),X=t((function(){return g.value||K.value})),Y=function(e){switch("object"!==k(e)&&(e=re(e)),c.value){case"single":$(e);break;case"multiple":case"tags":$(j.value.concat(e))}u.emit("select",ee(e))},Z=function(e){switch("object"!==k(e)&&(e=re(e)),c.value){case"single":te();break;case"tags":case"multiple":$(j.value.filter((function(l){return l[T.value]!=e[T.value]})))}u.emit("deselect",ee(e))},ee=function(e){return b.value?e:e[T.value]},le=function(e){Z(e)},te=function(){$(Q.value)},ne=function(e){switch(c.value){case"single":return!w(j.value)&&j.value[T.value]==e[T.value];case"tags":case"multiple":return!w(j.value)&&-1!==j.value.map((function(e){return e[T.value]})).indexOf(e[T.value])}},ae=function(e){return!0===e.disabled},ue=function(){return!(void 0===I||-1===I.value||!U.value&&I.value>0)&&j.value.length>=I.value},re=function(e){return F.value[F.value.map((function(e){return String(e[T.value])})).indexOf(String(e))]},oe=function(e){return F.value.map((function(e){return O(e[s.value])})).indexOf(O(e))},ie=function(e){return"tags"===c.value&&v.value&&ne(e)},ce=function(e){H.value.push(e)},se=function(){w(M.value)||(j.value=ve(M.value))},de=function(e){K.value=!0,i.value(A.value).then((function(l){L.value=l,"function"==typeof e&&e(l),K.value=!1}))},ve=function(e){return w(e)?"single"===c.value?{}:[]:b.value?e:"single"===c.value?re(e)||{}:e.filter((function(e){return!!re(e)})).map((function(e){return re(e)}))};if("single"!==c.value&&!w(M.value)&&!Array.isArray(M.value))throw new Error('v-model must be an array when using "'.concat(c.value,'" mode'));return i&&"function"==typeof i.value?S.value?de(se):1==b.value&&se():(L.value=i&&i.value?i.value:[],se()),y.value>-1&&n(A,(function(e){e.length<q.value||(K.value=!0,V.value&&(L.value=[]),setTimeout((function(){e==A.value&&i.value(A.value).then((function(l){e==A.value&&(L.value=l,R.value=_.value.filter((function(e){return!0!==e.disabled}))[0]||null,K.value=!1)}))}),y.value))}),{flush:"sync"}),n(M,(function(e){var l,t,n;if(w(e))j.value=ve(e);else switch(c.value){case"single":(b.value?e[T.value]!=j.value[T.value]:e!=j.value[T.value])&&(j.value=ve(e));break;case"multiple":case"tags":l=b.value?e.map((function(e){return e[T.value]})):e,t=j.value.map((function(e){return e[T.value]})),n=t.slice().sort(),l.length===t.length&&l.slice().sort().every((function(e,l){return e===n[l]}))||(j.value=ve(e))}}),{deep:!0}),n((function(){return a.options}),(function(e){"function"!=typeof a.options&&(L.value=a.options)}),{flush:"sync"}),{filteredOptions:_,hasSelected:U,multipleLabelText:W,extendedOptions:F,noOptions:z,noResults:G,resolving:K,busy:X,select:Y,deselect:Z,remove:le,clear:te,isSelected:ne,isDisabled:ae,isMax:ue,getOption:re,handleOptionClick:function(e){if(!ae(e))switch(c.value){case"single":if(ne(e))return void(D.value&&Z(e));Y(e),C(),N();break;case"multiple":if(ne(e))return void Z(e);if(ue())return;Y(e),B.value&&E();break;case"tags":if(ne(e))return void Z(e);if(ue())return;void 0===re(e[T.value])&&p.value&&(u.emit("tag",e[T.value]),h.value&&ce(e),E()),B.value&&E(),Y(e)}},handleTagRemove:function(e,l){0===l.button?le(e):l.preventDefault()},refreshOptions:function(e){de(e)},resolveOptions:de}}function x(e){return function(e){if(Array.isArray(e))return V(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,l){if(!e)return;if("string"==typeof e)return V(e,l);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return V(e,l)}(e)||function(){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 V(e,l){(null==l||l>e.length)&&(l=e.length);for(var t=0,n=new Array(l);t<l;t++)n[t]=e[t];return n}var B={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1}},setup(u,r){const o=function(t,n){var a=e(t),u=a.value,r=a.modelValue,o=a.mode;return{internalValue:l("single"!==o.value?[]:{}),externalValue:void 0!==n.expose?r:u}}(u,r),i=function(n,a,u){var r=e(n),o=r.searchable,i=(r.id,l(null)),c=t((function(){return o.value?-1:0}));return{multiselect:i,tabindex:c,focusInput:function(){i.value.querySelector(".multiselect-input").focus()},blurInput:function(){i.value.querySelector(".multiselect-input").blur()}}}(u),c={pointer:l(null)},s=function(l,t,n){var a=e(l),u=a.object,r=a.valueProp,o=a.mode,i=n.internalValue,c=function(e){return u.value||w(e)?e:Array.isArray(e)?e.map((function(e){return e[r.value]})):e[r.value]},s=function(e){return w(e)?"single"===o.value?{}:[]:e};return{update:function(e){i.value=s(e);var l=c(e);t.emit("change",l),t.emit("input",l),t.emit("update:modelValue",l)}}}(u,r,{internalValue:o.internalValue}),d=function(a,u,r){var o=e(a),i=o.searchable,c=o.mode,s=r.internalValue,d=l(null),v=l(null),p=t((function(){return d.value?"".concat(d.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return n(d,(function(e){u.emit("search-change",e)})),{search:d,input:v,tagsSearchWidth:p,clearSearch:function(){d.value=""},focusSearch:function(){v.value.focus()},blurSearch:function(){i.value&&v.value.blur()}}}(u,r,{internalValue:o.internalValue}),v=function(n,a,u){var r=e(n),o=r.maxHeight,i=r.disabled,c=r.searchable,s=u.multiselect,d=u.blurInput,v=u.blurSearch,p=u.focusInput,f=u.focusSearch,h=l(!1),m=t((function(){return"".concat(o.value,"px")}));return{isOpen:h,contentMaxHeight:m,openDropdown:function(){i.value||(h.value=!0,a.emit("open"))},closeDropdown:function(){h.value=!1,a.emit("close")},open:function(){c&&c.value?f():p()},close:function(){c&&c.value?v():d()},handleInputMousedown:function(e){h.value&&!c.value&&(s.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),s.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(u,r,{multiselect:i.multiselect,blurInput:i.blurInput,blurSearch:d.blurSearch,focusInput:i.focusInput,focusSearch:d.focusSearch}),p=q(u,r,{externalValue:o.externalValue,internalValue:o.internalValue,search:d.search,blurSearch:d.blurSearch,clearSearch:d.clearSearch,update:s.update,blurInput:i.blurInput,pointer:c.pointer}),f=function(l,u,r){var o=e(l),i=o.id,c=o.valueProp,s=r.filteredOptions,d=r.handleOptionClick,v=r.search,p=r.pointer,f=t((function(){return s.value.filter((function(e){return!0!==e.disabled}))})),h=function(e){p.value=e},m=function(){p.value=f.value[0]||null},b=function(){p.value=null},g=function(){var e=document.getElementById(i.value).querySelector(".is-pointed");if(e){var l=e.parentElement;e.offsetTop+e.offsetHeight>l.clientHeight+l.scrollTop&&(l.scrollTop=e.offsetTop+e.offsetHeight-l.clientHeight),e.offsetTop<l.scrollTop&&(l.scrollTop=e.offsetTop)}};return n(v,(function(e){m()})),{pointer:p,isPointed:function(e){return!!p.value&&p.value[c.value]==e[c.value]},setPointer:h,setPointerFirst:m,clearPointer:b,selectPointer:function(){p.value&&!0!==p.value.disabled?(d(p.value),b()):b()},forwardPointer:function(){if(null===p.value)h(f.value[0]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])+1;f.value.length<=e&&(e=0),h(f.value[e]||null)}a((function(){g()}))},backwardPointer:function(){if(null===p.value)h(f.value[f.value.length-1]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])-1;e<0&&(e=f.value.length-1),h(f.value[e]||null)}a((function(){g()}))}}}(u,0,{filteredOptions:p.filteredOptions,handleOptionClick:p.handleOptionClick,search:d.search,pointer:c.pointer}),h=function(l,t,n){var a=e(l).mode,u=n.internalValue,r=n.update,o=n.closeDropdown,i=n.clearPointer,c=n.search;return{handleBackspace:function(e){"single"!==a.value&&r(x(u.value).slice(0,-1))},handleEsc:function(e){o(),i(),e.target.blur()},handleSearchBackspace:function(e){""!==c.value&&e.stopPropagation()}}}(u,0,{internalValue:o.internalValue,update:s.update,closeDropdown:v.closeDropdown,clearPointer:f.clearPointer,search:d.search});return{...o,...v,...i,...c,...s,...d,...p,...f,...h}}};const T={class:"multiselect-single-label"},D={class:"multiselect-multiple-label"},I={key:2,class:"multiselect-search"},j={key:3,class:"multiselect-tags"},M={class:"multiselect-tag"},A={class:"multiselect-placeholder"},C={class:"multiselect-spinner"},E={class:"multiselect-no-options"},$={class:"multiselect-no-results"};B.render=function(e,l,t,n,a,w){return u(),r("div",{class:["multiselect",[`is-${t.mode}`,{"is-open":e.isOpen,"is-searchable":t.searchable,"is-disabled":t.disabled,"no-caret":!t.caret}]],id:t.id,onKeydown:l[28]||(l[28]=o(i((()=>{}),["prevent"]),["enter"])),ref:"multiselect"},[c("div",{class:"multiselect-input",tabindex:e.tabindex,onMousedown:l[19]||(l[19]=(...l)=>e.handleInputMousedown&&e.handleInputMousedown(...l)),onFocus:l[20]||(l[20]=(...l)=>e.openDropdown&&e.openDropdown(...l)),onBlur:l[21]||(l[21]=(...l)=>e.closeDropdown&&e.closeDropdown(...l)),onKeyup:[l[22]||(l[22]=o(((...l)=>e.handleEsc&&e.handleEsc(...l)),["esc"])),l[23]||(l[23]=o(((...l)=>e.selectPointer&&e.selectPointer(...l)),["enter"]))],onKeydown:[l[24]||(l[24]=o(i(((...l)=>e.handleBackspace&&e.handleBackspace(...l)),["prevent"]),["delete"])),l[25]||(l[25]=o(i(((...l)=>e.backwardPointer&&e.backwardPointer(...l)),["prevent"]),["up"])),l[26]||(l[26]=o(i(((...l)=>e.forwardPointer&&e.forwardPointer(...l)),["prevent"]),["down"]))]},[s(" Single label "),"single"==t.mode&&e.hasSelected&&!e.search&&e.internalValue?d(e.$slots,"singlelabel",{key:0,value:e.internalValue},(()=>[c("div",T,v(e.internalValue[t.label]),1)])):s("v-if",!0),s(" Multiple label "),"multiple"==t.mode&&e.hasSelected&&!e.search?d(e.$slots,"multiplelabel",{key:1,values:e.internalValue},(()=>[c("div",D,v(e.multipleLabelText),1)])):s("v-if",!0),s(" Search "),"tags"!==t.mode&&t.searchable&&!t.disabled?(u(),r("div",I,[p(c("input",{"onUpdate:modelValue":l[1]||(l[1]=l=>e.search=l),onFocus:l[2]||(l[2]=i(((...l)=>e.openDropdown&&e.openDropdown(...l)),["stop"])),onBlur:l[3]||(l[3]=i(((...l)=>e.closeDropdown&&e.closeDropdown(...l)),["stop"])),onKeyup:[l[4]||(l[4]=o(i(((...l)=>e.handleEsc&&e.handleEsc(...l)),["stop"]),["esc"])),l[5]||(l[5]=o(i(((...l)=>e.selectPointer&&e.selectPointer(...l)),["stop"]),["enter"]))],onKeydown:[l[6]||(l[6]=o(((...l)=>e.handleSearchBackspace&&e.handleSearchBackspace(...l)),["delete"])),l[7]||(l[7]=o(i(((...l)=>e.backwardPointer&&e.backwardPointer(...l)),["stop"]),["up"])),l[8]||(l[8]=o(i(((...l)=>e.forwardPointer&&e.forwardPointer(...l)),["stop"]),["down"]))],ref:"input"},null,544),[[f,e.search]])])):s("v-if",!0),s(" Tags (with search) "),"tags"==t.mode?(u(),r("div",j,[(u(!0),r(h,null,m(e.internalValue,((n,a,o)=>(u(),r("span",{key:o},[d(e.$slots,"tag",{option:n,handleTagRemove:e.handleTagRemove,disabled:t.disabled},(()=>[c("div",M,[b(v(n[t.label])+" ",1),t.disabled?s("v-if",!0):(u(),r("i",{key:0,onClick:l[9]||(l[9]=i((()=>{}),["prevent"])),onMousedown:i((l=>e.handleTagRemove(n,l)),["prevent","stop"])},null,40,["onMousedown"]))])]))])))),128)),t.searchable&&!t.disabled?(u(),r("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[p(c("input",{"onUpdate:modelValue":l[10]||(l[10]=l=>e.search=l),onFocus:l[11]||(l[11]=i(((...l)=>e.openDropdown&&e.openDropdown(...l)),["stop"])),onBlur:l[12]||(l[12]=i(((...l)=>e.closeDropdown&&e.closeDropdown(...l)),["stop"])),onKeyup:[l[13]||(l[13]=o(i(((...l)=>e.handleEsc&&e.handleEsc(...l)),["stop"]),["esc"])),l[14]||(l[14]=o(i(((...l)=>e.selectPointer&&e.selectPointer(...l)),["stop"]),["enter"]))],onKeydown:[l[15]||(l[15]=o(((...l)=>e.handleSearchBackspace&&e.handleSearchBackspace(...l)),["delete"])),l[16]||(l[16]=o(i(((...l)=>e.backwardPointer&&e.backwardPointer(...l)),["stop"]),["up"])),l[17]||(l[17]=o(i(((...l)=>e.forwardPointer&&e.forwardPointer(...l)),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[f,e.search]])],4)):s("v-if",!0)])):s("v-if",!0),s(" Placeholder "),!t.placeholder||e.hasSelected||e.search?s("v-if",!0):d(e.$slots,"placeholder",{key:4},(()=>[c("div",A,v(t.placeholder),1)])),c(g,{name:"multiselect-loading"},{default:y((()=>[p(c("div",C,null,512),[[S,e.busy]])])),_:1}),"single"!==t.mode&&e.hasSelected&&!t.disabled?(u(),r("a",{key:5,class:"multiselect-clear",onClick:l[18]||(l[18]=i(((...l)=>e.clear&&e.clear(...l)),["prevent"]))})):s("v-if",!0)],40,["tabindex"]),s(" Options "),e.resolving&&t.clearOnSearch?s("v-if",!0):(u(),r(g,{key:0,name:"multiselect",onAfterLeave:e.clearSearch},{default:y((()=>[p(c("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[d(e.$slots,"beforelist"),(u(!0),r(h,null,m(e.filteredOptions,((n,a,o)=>(u(),r("a",{tabindex:-1,href:"",class:["multiselect-option",{"is-pointed":e.isPointed(n),"is-selected":e.isSelected(n),"is-disabled":e.isDisabled(n)}],key:o,onMousedown:l[27]||(l[27]=i((()=>{}),["prevent"])),onMouseenter:l=>e.setPointer(n),onClick:i((l=>e.handleOptionClick(n)),["stop","prevent"])},[d(e.$slots,"option",{option:n,search:e.search},(()=>[c("span",null,v(n[t.label]),1)]))],42,["onMouseenter","onClick"])))),128)),p(c("span",null,[d(e.$slots,"nooptions",{},(()=>[c("div",E,v(t.noOptionsText),1)]))],512),[[S,e.noOptions]]),p(c("span",null,[d(e.$slots,"noresults",{},(()=>[c("div",$,v(t.noResultsText),1)]))],512),[[S,e.noResults]]),d(e.$slots,"afterlist")],4),[[S,e.isOpen]])])),_:3},8,["onAfterLeave"]))],42,["id"])},B.__file="src/Multiselect.vue";export default B;
import{toRefs as e,ref as l,computed as t,watch as n,nextTick as a,openBlock as u,createBlock as r,withKeys as o,withModifiers as i,createVNode as c,createCommentVNode as s,renderSlot as d,toDisplayString as v,withDirectives as p,vModelText as f,Fragment as h,renderList as m,createTextVNode as b,Transition as g,withCtx as y,vShow as w}from"vue";function S(e){return-1!==[null,void 0,!1].indexOf(e)}function O(e){return String(e).toLowerCase().trim()}function k(e){return(k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function q(e,l,t){return l in e?Object.defineProperty(e,l,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[l]=t,e}function x(a,u,r){var o=e(a),i=o.options,c=o.mode,s=o.trackBy,d=o.limit,v=o.hideSelected,p=o.createTag,f=o.label,h=o.appendNewTag,m=o.multipleLabel,b=o.object,g=o.loading,y=o.delay,w=o.resolveOnLoad,x=o.minChars,P=o.filterResults,T=o.clearOnSearch,V=o.clearOnSelect,B=o.valueProp,A=o.canDeselect,D=o.max,j=r.internalValue,I=r.externalValue,M=r.currentValue,C=r.search,E=r.blurSearch,H=r.clearSearch,$=r.update,L=r.blurInput,N=r.pointer,R=l([]),K=l([]),F=l(!1),_=t((function(){var e,l=K.value||[];return e=l,"[object Object]"===Object.prototype.toString.call(e)&&(l=Object.keys(l).map((function(e){var t,n=l[e];return q(t={},B.value,e),q(t,s.value,n),q(t,f.value,n),t}))),l=l.map((function(e,l){var t;return"object"===k(e)?e:(q(t={},B.value,l),q(t,s.value,e),q(t,f.value,e),t)})),R.value.length&&(l=l.concat(R.value)),l})),U=t((function(){var e=_.value;return Q.value.length&&(e=Q.value.concat(e)),C.value&&P.value&&(e=e.filter((function(e){return-1!==O(e[s.value]).indexOf(O(C.value))}))),v.value&&(e=e.filter((function(e){return!ce(e)}))),d.value>0&&(e=e.slice(0,d.value)),e})),W=t((function(){switch(c.value){case"single":return!S(j.value[B.value]);case"multiple":case"tags":return!S(j.value)&&j.value.length>0}})),z=t((function(){return void 0!==m&&void 0!==m.value?m.value(j.value):j.value&&j.value.length>1?"".concat(j.value.length," options selected"):"1 option selected"})),G=t((function(){return!_.value.length&&!F.value})),J=t((function(){return _.value.length>0&&0==U.value.length})),Q=t((function(){var e;return!1!==p.value&&C.value?-1!==ie(C.value)?[]:[(e={},q(e,B.value,C.value),q(e,f.value,C.value),q(e,s.value,C.value),e)]:[]})),X=t((function(){switch(c.value){case"single":return null;case"multiple":case"tags":return[]}})),Y=t((function(){return g.value||F.value})),Z=function(e){switch("object"!==k(e)&&(e=oe(e)),c.value){case"single":$(e);break;case"multiple":case"tags":$(j.value.concat(e))}u.emit("select",le(e))},ee=function(e){switch("object"!==k(e)&&(e=oe(e)),c.value){case"single":ne();break;case"tags":case"multiple":$(j.value.filter((function(l){return l[B.value]!=e[B.value]})))}u.emit("deselect",le(e))},le=function(e){return b.value?e:e[B.value]},te=function(e){ee(e)},ne=function(){$(X.value)},ae=function(e){switch(c.value){case"single":return!S(j.value)&&j.value[B.value]==e[B.value];case"tags":case"multiple":return!S(j.value)&&-1!==j.value.map((function(e){return e[B.value]})).indexOf(e[B.value])}},ue=function(e){return!0===e.disabled},re=function(){return!(void 0===D||-1===D.value||!W.value&&D.value>0)&&j.value.length>=D.value},oe=function(e){return _.value[_.value.map((function(e){return String(e[B.value])})).indexOf(String(e))]},ie=function(e){return _.value.map((function(e){return O(e[s.value])})).indexOf(O(e))},ce=function(e){return"tags"===c.value&&v.value&&ae(e)},se=function(e){R.value.push(e)},de=function(){S(I.value)||(j.value=pe(I.value))},ve=function(e){F.value=!0,i.value(C.value).then((function(l){K.value=l,"function"==typeof e&&e(l),F.value=!1}))},pe=function(e){return S(e)?"single"===c.value?{}:[]:b.value?e:"single"===c.value?oe(e)||{}:e.filter((function(e){return!!oe(e)})).map((function(e){return oe(e)}))};if("single"!==c.value&&!S(I.value)&&!Array.isArray(I.value))throw new Error('v-model must be an array when using "'.concat(c.value,'" mode'));return i&&"function"==typeof i.value?w.value?ve(de):1==b.value&&de():(K.value=i&&i.value?i.value:[],de()),y.value>-1&&n(C,(function(e){e.length<x.value||(F.value=!0,T.value&&(K.value=[]),setTimeout((function(){e==C.value&&i.value(C.value).then((function(l){e==C.value&&(K.value=l,N.value=U.value.filter((function(e){return!0!==e.disabled}))[0]||null,F.value=!1)}))}),y.value))}),{flush:"sync"}),n(I,(function(e){var l,t,n;if(S(e))j.value=pe(e);else switch(c.value){case"single":(b.value?e[B.value]!=j.value[B.value]:e!=j.value[B.value])&&(j.value=pe(e));break;case"multiple":case"tags":l=b.value?e.map((function(e){return e[B.value]})):e,t=j.value.map((function(e){return e[B.value]})),n=t.slice().sort(),l.length===t.length&&l.slice().sort().every((function(e,l){return e===n[l]}))||(j.value=pe(e))}}),{deep:!0}),n((function(){return a.options}),(function(e){"function"!=typeof a.options&&(K.value=a.options)}),{flush:"sync"}),n(_,(function(e,l){var t;_.value.length&&M.value&&M.value.length&&("single"===c.value?t=_.value[_.value.map((function(e){return e[B.value]})).indexOf(M.value)]:(t=[],M.value.forEach((function(e){t.push(_.value[_.value.map((function(e){return e[B.value]})).indexOf(e)])}))),b.value?$(t):j.value=t)}),{flush:"sync",deep:!0,immediate:!1}),{filteredOptions:U,hasSelected:W,multipleLabelText:z,extendedOptions:_,noOptions:G,noResults:J,resolving:F,busy:Y,select:Z,deselect:ee,remove:te,clear:ne,isSelected:ae,isDisabled:ue,isMax:re,getOption:oe,handleOptionClick:function(e){if(!ue(e))switch(c.value){case"single":if(ae(e))return void(A.value&&ee(e));Z(e),E(),L();break;case"multiple":if(ae(e))return void ee(e);if(re())return;Z(e),V.value&&H();break;case"tags":if(ae(e))return void ee(e);if(re())return;void 0===oe(e[B.value])&&p.value&&(u.emit("tag",e[B.value]),h.value&&se(e),H()),V.value&&H(),Z(e)}},handleTagRemove:function(e,l){0===l.button?te(e):l.preventDefault()},refreshOptions:function(e){ve(e)},resolveOptions:ve}}function P(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,l){if(!e)return;if("string"==typeof e)return T(e,l);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return T(e,l)}(e)||function(){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 T(e,l){(null==l||l>e.length)&&(l=e.length);for(var t=0,n=new Array(l);t<l;t++)n[t]=e[t];return n}var V={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1},showOptions:{type:Boolean,required:!1,default:!0},addTagOn:{type:Array,required:!1,default:()=>["enter"]},required:{type:Boolean,required:!1,default:!1}},setup(u,r){const o=function(n,a){var u=e(n),r=u.value,o=u.modelValue,i=u.mode,c=u.valueProp,s=l("single"!==i.value?[]:{}),d=void 0!==a.expose?o:r,v=t((function(){return Object.keys(s.value).length?"single"!==i.value?s.value.map((function(e){return e[c.value]})):s.value[c.value]:s.value})),p=t((function(){return"single"!==i.value?s.value.map((function(e){return e[c.value]})).join(","):s.value[c.value]}));return{internalValue:s,externalValue:d,currentValue:v,textValue:p}}(u,r),i=function(n,a,u){var r=e(n),o=r.searchable,i=(r.id,l(null)),c=t((function(){return o.value?-1:0}));return{multiselect:i,tabindex:c,focusInput:function(){i.value.querySelector(".multiselect-input").focus()},blurInput:function(){i.value.querySelector(".multiselect-input").blur()}}}(u),c={pointer:l(null)},s=function(l,t,n){var a=e(l),u=a.object,r=a.valueProp,o=a.mode,i=n.internalValue,c=function(e){return u.value||S(e)?e:Array.isArray(e)?e.map((function(e){return e[r.value]})):e[r.value]},s=function(e){return S(e)?"single"===o.value?{}:[]:e};return{update:function(e){i.value=s(e);var l=c(e);t.emit("change",l),t.emit("input",l),t.emit("update:modelValue",l)}}}(u,r,{internalValue:o.internalValue}),d=function(a,u,r){var o=e(a),i=o.searchable,c=o.mode,s=r.internalValue,d=l(null),v=l(null),p=t((function(){return d.value?"".concat(d.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return n(d,(function(e){u.emit("search-change",e)})),{search:d,input:v,tagsSearchWidth:p,clearSearch:function(){d.value=""},focusSearch:function(){v.value.focus()},blurSearch:function(){i.value&&v.value.blur()}}}(u,r,{internalValue:o.internalValue}),v=function(n,a,u){var r=e(n),o=r.maxHeight,i=r.disabled,c=r.searchable,s=u.multiselect,d=u.blurInput,v=u.blurSearch,p=u.focusInput,f=u.focusSearch,h=l(!1),m=t((function(){return"".concat(o.value,"px")}));return{isOpen:h,contentMaxHeight:m,openDropdown:function(){i.value||(h.value=!0,a.emit("open"))},closeDropdown:function(){h.value=!1,a.emit("close")},open:function(){c&&c.value?f():p()},close:function(){c&&c.value?v():d()},handleInputMousedown:function(e){h.value&&!c.value&&(s.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),s.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(u,r,{multiselect:i.multiselect,blurInput:i.blurInput,blurSearch:d.blurSearch,focusInput:i.focusInput,focusSearch:d.focusSearch}),p=x(u,r,{externalValue:o.externalValue,internalValue:o.internalValue,currentValue:o.currentValue,search:d.search,blurSearch:d.blurSearch,clearSearch:d.clearSearch,update:s.update,blurInput:i.blurInput,pointer:c.pointer}),f=function(l,u,r){var o=e(l),i=o.id,c=o.valueProp,s=r.filteredOptions,d=r.handleOptionClick,v=r.search,p=r.pointer,f=t((function(){return s.value.filter((function(e){return!0!==e.disabled}))})),h=function(e){p.value=e},m=function(){p.value=f.value[0]||null},b=function(){p.value=null},g=function(){var e=document.getElementById(i.value).querySelector(".is-pointed");if(e){var l=e.parentElement;e.offsetTop+e.offsetHeight>l.clientHeight+l.scrollTop&&(l.scrollTop=e.offsetTop+e.offsetHeight-l.clientHeight),e.offsetTop<l.scrollTop&&(l.scrollTop=e.offsetTop)}};return n(v,(function(e){m()})),{pointer:p,isPointed:function(e){return!!p.value&&p.value[c.value]==e[c.value]},setPointer:h,setPointerFirst:m,clearPointer:b,selectPointer:function(){p.value&&!0!==p.value.disabled?(d(p.value),b()):b()},forwardPointer:function(){if(null===p.value)h(f.value[0]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])+1;f.value.length<=e&&(e=0),h(f.value[e]||null)}a((function(){g()}))},backwardPointer:function(){if(null===p.value)h(f.value[f.value.length-1]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])-1;e<0&&(e=f.value.length-1),h(f.value[e]||null)}a((function(){g()}))}}}(u,0,{filteredOptions:p.filteredOptions,handleOptionClick:p.handleOptionClick,search:d.search,pointer:c.pointer}),h=function(l,t,n){var a=e(l),u=a.mode,r=a.addTagOn,o={enter:13,space:32},i=n.internalValue,c=n.update,s=n.closeDropdown,d=n.clearPointer,v=n.search,p=n.selectPointer;return{handleBackspace:function(e){"single"!==u.value&&c(P(i.value).slice(0,-1))},handleEsc:function(e){s(),d(),e.target.blur()},handleSearchBackspace:function(e){""!==v.value&&e.stopPropagation()},handleAddTag:function(e){-1!==Object.values(function(e,l){var t,n={};for(t in e)e.hasOwnProperty(t)&&-1!==l.indexOf(t)&&(n[t]=e[t]);return n}(o,r.value)).indexOf(e.keyCode)&&p()}}}(u,0,{internalValue:o.internalValue,update:s.update,closeDropdown:v.closeDropdown,clearPointer:f.clearPointer,search:d.search,selectPointer:f.selectPointer});return{...o,...v,...i,...c,...s,...d,...p,...f,...h}}};const B={class:"multiselect-single-label"},A={class:"multiselect-multiple-label"},D={key:2,class:"multiselect-search"},j={key:3,class:"multiselect-tags"},I={class:"multiselect-tag"},M={class:"multiselect-placeholder"},C={class:"multiselect-spinner"},E={class:"multiselect-no-options"},H={class:"multiselect-no-results"};V.render=function(e,l,t,n,a,S){return u(),r("div",{class:["multiselect",[`is-${t.mode}`,{"is-open":e.isOpen,"is-searchable":t.searchable,"is-disabled":t.disabled,"no-caret":!t.caret}]],id:t.id,onKeydown:l[31]||(l[31]=o(i((()=>{}),["prevent"]),["enter"])),ref:"multiselect"},[c("div",{class:"multiselect-input",tabindex:e.tabindex,onMousedown:l[21]||(l[21]=(...l)=>e.handleInputMousedown&&e.handleInputMousedown(...l)),onFocus:l[22]||(l[22]=(...l)=>e.openDropdown&&e.openDropdown(...l)),onBlur:l[23]||(l[23]=(...l)=>e.closeDropdown&&e.closeDropdown(...l)),onKeyup:[l[24]||(l[24]=o(((...l)=>e.handleEsc&&e.handleEsc(...l)),["esc"])),l[25]||(l[25]=o(((...l)=>e.handleAddTag&&e.handleAddTag(...l)),["enter"])),l[26]||(l[26]=o(((...l)=>e.handleAddTag&&e.handleAddTag(...l)),["space"]))],onKeydown:[l[27]||(l[27]=o(i(((...l)=>e.handleBackspace&&e.handleBackspace(...l)),["prevent"]),["delete"])),l[28]||(l[28]=o(i(((...l)=>e.backwardPointer&&e.backwardPointer(...l)),["prevent"]),["up"])),l[29]||(l[29]=o(i(((...l)=>e.forwardPointer&&e.forwardPointer(...l)),["prevent"]),["down"]))]},[s(" Single label "),"single"==t.mode&&e.hasSelected&&!e.search&&e.internalValue?d(e.$slots,"singlelabel",{key:0,value:e.internalValue},(()=>[c("div",B,v(e.internalValue[t.label]),1)])):s("v-if",!0),s(" Multiple label "),"multiple"==t.mode&&e.hasSelected&&!e.search?d(e.$slots,"multiplelabel",{key:1,values:e.internalValue},(()=>[c("div",A,v(e.multipleLabelText),1)])):s("v-if",!0),s(" Search "),"tags"!==t.mode&&t.searchable&&!t.disabled?(u(),r("div",D,[p(c("input",{"onUpdate:modelValue":l[1]||(l[1]=l=>e.search=l),onFocus:l[2]||(l[2]=i(((...l)=>e.openDropdown&&e.openDropdown(...l)),["stop"])),onBlur:l[3]||(l[3]=i(((...l)=>e.closeDropdown&&e.closeDropdown(...l)),["stop"])),onKeyup:[l[4]||(l[4]=o(i(((...l)=>e.handleEsc&&e.handleEsc(...l)),["stop"]),["esc"])),l[5]||(l[5]=o(i(((...l)=>e.selectPointer&&e.selectPointer(...l)),["stop"]),["enter"])),l[6]||(l[6]=o(i(((...l)=>e.selectPointer&&e.selectPointer(...l)),["stop"]),["space"]))],onKeydown:[l[7]||(l[7]=o(((...l)=>e.handleSearchBackspace&&e.handleSearchBackspace(...l)),["delete"])),l[8]||(l[8]=o(i(((...l)=>e.backwardPointer&&e.backwardPointer(...l)),["stop"]),["up"])),l[9]||(l[9]=o(i(((...l)=>e.forwardPointer&&e.forwardPointer(...l)),["stop"]),["down"]))],ref:"input"},null,544),[[f,e.search]])])):s("v-if",!0),s(" Tags (with search) "),"tags"==t.mode?(u(),r("div",j,[(u(!0),r(h,null,m(e.internalValue,((n,a,o)=>(u(),r("span",{key:o},[d(e.$slots,"tag",{option:n,handleTagRemove:e.handleTagRemove,disabled:t.disabled},(()=>[c("div",I,[b(v(n[t.label])+" ",1),t.disabled?s("v-if",!0):(u(),r("i",{key:0,onClick:l[10]||(l[10]=i((()=>{}),["prevent"])),onMousedown:i((l=>e.handleTagRemove(n,l)),["prevent","stop"])},null,40,["onMousedown"]))])]))])))),128)),t.searchable&&!t.disabled?(u(),r("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[p(c("input",{"onUpdate:modelValue":l[11]||(l[11]=l=>e.search=l),onFocus:l[12]||(l[12]=i(((...l)=>e.openDropdown&&e.openDropdown(...l)),["stop"])),onBlur:l[13]||(l[13]=i(((...l)=>e.closeDropdown&&e.closeDropdown(...l)),["stop"])),onKeyup:[l[14]||(l[14]=o(i(((...l)=>e.handleEsc&&e.handleEsc(...l)),["stop"]),["esc"])),l[15]||(l[15]=o(i(((...l)=>e.handleAddTag&&e.handleAddTag(...l)),["stop"]),["enter"])),l[16]||(l[16]=o(i(((...l)=>e.handleAddTag&&e.handleAddTag(...l)),["stop"]),["space"]))],onKeydown:[l[17]||(l[17]=o(((...l)=>e.handleSearchBackspace&&e.handleSearchBackspace(...l)),["delete"])),l[18]||(l[18]=o(i(((...l)=>e.backwardPointer&&e.backwardPointer(...l)),["stop"]),["up"])),l[19]||(l[19]=o(i(((...l)=>e.forwardPointer&&e.forwardPointer(...l)),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[f,e.search]])],4)):s("v-if",!0)])):s("v-if",!0),s(" Placeholder "),!t.placeholder||e.hasSelected||e.search?s("v-if",!0):d(e.$slots,"placeholder",{key:4},(()=>[c("div",M,v(t.placeholder),1)])),c(g,{name:"multiselect-loading"},{default:y((()=>[p(c("div",C,null,512),[[w,e.busy]])])),_:1}),"single"!==t.mode&&e.hasSelected&&!t.disabled?(u(),r("a",{key:5,class:"multiselect-clear",onClick:l[20]||(l[20]=i(((...l)=>e.clear&&e.clear(...l)),["prevent"]))})):s("v-if",!0)],40,["tabindex"]),s(" Options "),e.resolving&&t.clearOnSearch?s("v-if",!0):(u(),r(g,{key:0,name:"multiselect",onAfterLeave:e.clearSearch},{default:y((()=>[p(c("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[d(e.$slots,"beforelist"),(u(!0),r(h,null,m(e.filteredOptions,((n,a,o)=>(u(),r("span",{tabindex:-1,class:["multiselect-option",{"is-pointed":e.isPointed(n),"is-selected":e.isSelected(n),"is-disabled":e.isDisabled(n)}],key:o,onMousedown:l[30]||(l[30]=i((()=>{}),["prevent"])),onMouseenter:l=>e.setPointer(n),onClick:i((l=>e.handleOptionClick(n)),["stop","prevent"])},[d(e.$slots,"option",{option:n,search:e.search},(()=>[c("span",null,v(n[t.label]),1)]))],42,["onMouseenter","onClick"])))),128)),p(c("span",null,[d(e.$slots,"nooptions",{},(()=>[c("div",E,v(t.noOptionsText),1)]))],512),[[w,e.noOptions]]),p(c("span",null,[d(e.$slots,"noresults",{},(()=>[c("div",H,v(t.noResultsText),1)]))],512),[[w,e.noResults]]),d(e.$slots,"afterlist")],4),[[w,e.isOpen&&t.showOptions]])])),_:3},8,["onAfterLeave"])),s(" Hacky input element to show HTML5 required warning "),t.required?(u(),r("input",{key:1,class:"multiselect-fake-input",tabindex:"-1",value:e.textValue,required:""},null,8,["value"])):s("v-if",!0)],42,["id"])},V.__file="src/Multiselect.vue";export default V;

@@ -1,1 +0,1 @@

var VueformMultiselect=function(e){"use strict";function t(e){return-1!==[null,void 0,!1].indexOf(e)}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){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 u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=new Array(t);n<t;n++)l[n]=e[n];return l}function r(e){return String(e).toLowerCase().trim()}function o(a,u,o){var i=e.toRefs(a),c=i.options,s=i.mode,d=i.trackBy,p=i.limit,v=i.hideSelected,f=i.createTag,h=i.label,m=i.appendNewTag,y=i.multipleLabel,g=i.object,b=i.loading,k=i.delay,w=i.resolveOnLoad,_=i.minChars,S=i.filterResults,O=i.clearOnSearch,x=i.clearOnSelect,C=i.valueProp,P=i.canDeselect,D=i.max,q=o.internalValue,T=o.externalValue,V=o.search,R=o.blurSearch,E=o.clearSearch,B=o.update,A=o.blurInput,I=o.pointer,N=e.ref([]),j=e.ref([]),H=e.ref(!1),U=e.computed((function(){var e,t=j.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,a=t[e];return l(n={},C.value,e),l(n,d.value,a),l(n,h.value,a),n}))),t=t.map((function(e,t){var a;return"object"===n(e)?e:(l(a={},C.value,t),l(a,d.value,e),l(a,h.value,e),a)})),N.value.length&&(t=t.concat(N.value)),t})),M=e.computed((function(){var e=U.value;return X.value.length&&(e=X.value.concat(e)),V.value&&S.value&&(e=e.filter((function(e){return-1!==r(e[d.value]).indexOf(r(V.value))}))),v.value&&(e=e.filter((function(e){return!ue(e)}))),p.value>0&&(e=e.slice(0,p.value)),e})),$=e.computed((function(){switch(s.value){case"single":return!t(q.value[C.value]);case"multiple":case"tags":return!t(q.value)&&q.value.length>0}})),L=e.computed((function(){return void 0!==y&&void 0!==y.value?y.value(q.value):q.value&&q.value.length>1?"".concat(q.value.length," options selected"):"1 option selected"})),F=e.computed((function(){return!U.value.length&&!H.value})),W=e.computed((function(){return U.value.length>0&&0==M.value.length})),X=e.computed((function(){var e;return!1!==f.value&&V.value?-1!==ae(V.value)?[]:[(e={},l(e,C.value,V.value),l(e,h.value,V.value),l(e,d.value,V.value),e)]:[]})),z=e.computed((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),G=e.computed((function(){return b.value||H.value})),J=function(e){switch("object"!==n(e)&&(e=le(e)),s.value){case"single":B(e);break;case"multiple":case"tags":B(q.value.concat(e))}u.emit("select",Q(e))},K=function(e){switch("object"!==n(e)&&(e=le(e)),s.value){case"single":Z();break;case"tags":case"multiple":B(q.value.filter((function(t){return t[C.value]!=e[C.value]})))}u.emit("deselect",Q(e))},Q=function(e){return g.value?e:e[C.value]},Y=function(e){K(e)},Z=function(){B(z.value)},ee=function(e){switch(s.value){case"single":return!t(q.value)&&q.value[C.value]==e[C.value];case"tags":case"multiple":return!t(q.value)&&-1!==q.value.map((function(e){return e[C.value]})).indexOf(e[C.value])}},te=function(e){return!0===e.disabled},ne=function(){return!(void 0===D||-1===D.value||!$.value&&D.value>0)&&q.value.length>=D.value},le=function(e){return U.value[U.value.map((function(e){return String(e[C.value])})).indexOf(String(e))]},ae=function(e){return U.value.map((function(e){return r(e[d.value])})).indexOf(r(e))},ue=function(e){return"tags"===s.value&&v.value&&ee(e)},re=function(e){N.value.push(e)},oe=function(){t(T.value)||(q.value=ce(T.value))},ie=function(e){H.value=!0,c.value(V.value).then((function(t){j.value=t,"function"==typeof e&&e(t),H.value=!1}))},ce=function(e){return t(e)?"single"===s.value?{}:[]:g.value?e:"single"===s.value?le(e)||{}:e.filter((function(e){return!!le(e)})).map((function(e){return le(e)}))};if("single"!==s.value&&!t(T.value)&&!Array.isArray(T.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return c&&"function"==typeof c.value?w.value?ie(oe):1==g.value&&oe():(j.value=c&&c.value?c.value:[],oe()),k.value>-1&&e.watch(V,(function(e){e.length<_.value||(H.value=!0,O.value&&(j.value=[]),setTimeout((function(){e==V.value&&c.value(V.value).then((function(t){e==V.value&&(j.value=t,I.value=M.value.filter((function(e){return!0!==e.disabled}))[0]||null,H.value=!1)}))}),k.value))}),{flush:"sync"}),e.watch(T,(function(e){var n,l,a;if(t(e))q.value=ce(e);else switch(s.value){case"single":(g.value?e[C.value]!=q.value[C.value]:e!=q.value[C.value])&&(q.value=ce(e));break;case"multiple":case"tags":n=g.value?e.map((function(e){return e[C.value]})):e,l=q.value.map((function(e){return e[C.value]})),a=l.slice().sort(),n.length===l.length&&n.slice().sort().every((function(e,t){return e===a[t]}))||(q.value=ce(e))}}),{deep:!0}),e.watch((function(){return a.options}),(function(e){"function"!=typeof a.options&&(j.value=a.options)}),{flush:"sync"}),{filteredOptions:M,hasSelected:$,multipleLabelText:L,extendedOptions:U,noOptions:F,noResults:W,resolving:H,busy:G,select:J,deselect:K,remove:Y,clear:Z,isSelected:ee,isDisabled:te,isMax:ne,getOption:le,handleOptionClick:function(e){if(!te(e))switch(s.value){case"single":if(ee(e))return void(P.value&&K(e));J(e),R(),A();break;case"multiple":if(ee(e))return void K(e);if(ne())return;J(e),x.value&&E();break;case"tags":if(ee(e))return void K(e);if(ne())return;void 0===le(e[C.value])&&f.value&&(u.emit("tag",e[C.value]),m.value&&re(e),E()),x.value&&E(),J(e)}},handleTagRemove:function(e,t){0===t.button?Y(e):t.preventDefault()},refreshOptions:function(e){ie(e)},resolveOptions:ie}}function i(e,t,n,l,a,u,r,o,i,c){"boolean"!=typeof r&&(i=o,o=r,r=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),l&&(d._scopeId=l),u?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(u)},d._ssrRegister=s):t&&(s=r?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),s)if(d.functional){var p=d.render;d.render=function(e,t){return s.call(t),p(e,t)}}else{var v=d.beforeCreate;d.beforeCreate=v?[].concat(v,s):[s]}return n}const c={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1}},setup(n,l){const u=function(t,n){var l=e.toRefs(t),a=l.value,u=l.modelValue,r=l.mode;return{internalValue:e.ref("single"!==r.value?[]:{}),externalValue:void 0!==n.expose?u:a}}(n,l),r=function(t,n,l){var a=e.toRefs(t),u=a.searchable,r=(a.id,e.ref(null)),o=e.computed((function(){return u.value?-1:0}));return{multiselect:r,tabindex:o,focusInput:function(){r.value.querySelector(".multiselect-input").focus()},blurInput:function(){r.value.querySelector(".multiselect-input").blur()}}}(n),i={pointer:e.ref(null)},c=function(n,l,a){var u=e.toRefs(n),r=u.object,o=u.valueProp,i=u.mode,c=a.internalValue,s=function(e){return r.value||t(e)?e:Array.isArray(e)?e.map((function(e){return e[o.value]})):e[o.value]},d=function(e){return t(e)?"single"===i.value?{}:[]:e};return{update:function(e){c.value=d(e);var t=s(e);l.emit("change",t),l.emit("input",t),l.emit("update:modelValue",t)}}}(n,l,{internalValue:u.internalValue}),s=function(t,n,l){var a=e.toRefs(t),u=a.searchable,r=a.mode,o=l.internalValue,i=e.ref(null),c=e.ref(null),s=e.computed((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===r.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"}));return e.watch(i,(function(e){n.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=""},focusSearch:function(){c.value.focus()},blurSearch:function(){u.value&&c.value.blur()}}}(n,l,{internalValue:u.internalValue}),d=function(t,n,l){var a=e.toRefs(t),u=a.maxHeight,r=a.disabled,o=a.searchable,i=l.multiselect,c=l.blurInput,s=l.blurSearch,d=l.focusInput,p=l.focusSearch,v=e.ref(!1),f=e.computed((function(){return"".concat(u.value,"px")}));return{isOpen:v,contentMaxHeight:f,openDropdown:function(){r.value||(v.value=!0,n.emit("open"))},closeDropdown:function(){v.value=!1,n.emit("close")},open:function(){o&&o.value?p():d()},close:function(){o&&o.value?s():c()},handleInputMousedown:function(e){v.value&&!o.value&&(i.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),i.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(n,l,{multiselect:r.multiselect,blurInput:r.blurInput,blurSearch:s.blurSearch,focusInput:r.focusInput,focusSearch:s.focusSearch}),p=o(n,l,{externalValue:u.externalValue,internalValue:u.internalValue,search:s.search,blurSearch:s.blurSearch,clearSearch:s.clearSearch,update:c.update,blurInput:r.blurInput,pointer:i.pointer}),v=function(t,n,l){var a=e.toRefs(t),u=a.id,r=a.valueProp,o=l.filteredOptions,i=l.handleOptionClick,c=l.search,s=l.pointer,d=e.computed((function(){return o.value.filter((function(e){return!0!==e.disabled}))})),p=function(e){s.value=e},v=function(){s.value=d.value[0]||null},f=function(){s.value=null},h=function(){var e=document.getElementById(u.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return e.watch(c,(function(e){v()})),{pointer:s,isPointed:function(e){return!!s.value&&s.value[r.value]==e[r.value]},setPointer:p,setPointerFirst:v,clearPointer:f,selectPointer:function(){s.value&&!0!==s.value.disabled?(i(s.value),f()):f()},forwardPointer:function(){if(null===s.value)p(d.value[0]||null);else{var t=d.value.map((function(e){return e[r.value]})).indexOf(s.value[r.value])+1;d.value.length<=t&&(t=0),p(d.value[t]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===s.value)p(d.value[d.value.length-1]||null);else{var t=d.value.map((function(e){return e[r.value]})).indexOf(s.value[r.value])-1;t<0&&(t=d.value.length-1),p(d.value[t]||null)}e.nextTick((function(){h()}))}}}(n,0,{filteredOptions:p.filteredOptions,handleOptionClick:p.handleOptionClick,search:s.search,pointer:i.pointer}),f=function(t,n,l){var u=e.toRefs(t).mode,r=l.internalValue,o=l.update,i=l.closeDropdown,c=l.clearPointer,s=l.search;return{handleBackspace:function(e){"single"!==u.value&&o(a(r.value).slice(0,-1))},handleEsc:function(e){i(),c(),e.target.blur()},handleSearchBackspace:function(e){""!==s.value&&e.stopPropagation()}}}(n,0,{internalValue:u.internalValue,update:c.update,closeDropdown:d.closeDropdown,clearPointer:v.clearPointer,search:s.search});return{...u,...d,...r,...i,...c,...s,...p,...v,...f}}};var s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{mousedown:e.handleInputMousedown,focus:e.openDropdown,blur:e.closeDropdown,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.selectPointer(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.internalValue?[e._t("singlelabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.internalValue[e.label])+"\n ")])],{value:e.internalValue})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.internalValue})]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.internalValue,(function(t,l,a){return n("span",{key:a},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),n.stopPropagation(),e.handleTagRemove(t,n)}}})])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[n("div",{staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.busy,expression:"busy"}],staticClass:"multiselect-spinner"})]),e._v(" "),"single"!==e.mode&&e.hasSelected&&!e.disabled?n("a",{staticClass:"multiselect-clear",on:{click:function(t){return t.preventDefault(),e.clear(t)}}}):e._e()],2),e._v(" "),e.resolving&&e.clearOnSearch?e._e():n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforelist"),e._v(" "),e._l(e.filteredOptions,(function(t,l,a){return n("a",{key:a,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t),"is-disabled":e.isDisabled(t)},attrs:{tabindex:-1,href:""},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("nooptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noresults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterlist")],2)])],1)};s._withStripped=!0;return i({render:s,staticRenderFns:[]},undefined,c,undefined,false,undefined,!1,void 0,void 0,void 0)}(VueCompositionAPI);
var VueformMultiselect=function(e){"use strict";function t(e){return-1!==[null,void 0,!1].indexOf(e)}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){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 u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function r(e){return String(e).toLowerCase().trim()}function o(l,u,o){var i=e.toRefs(l),c=i.options,s=i.mode,d=i.trackBy,p=i.limit,v=i.hideSelected,f=i.createTag,h=i.label,m=i.appendNewTag,y=i.multipleLabel,g=i.object,b=i.loading,k=i.delay,w=i.resolveOnLoad,_=i.minChars,O=i.filterResults,S=i.clearOnSearch,x=i.clearOnSelect,C=i.valueProp,P=i.canDeselect,q=i.max,D=o.internalValue,T=o.externalValue,V=o.currentValue,B=o.search,E=o.blurSearch,R=o.clearSearch,A=o.update,j=o.blurInput,I=o.pointer,N=e.ref([]),H=e.ref([]),U=e.ref(!1),M=e.computed((function(){var e,t=H.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,l=t[e];return a(n={},C.value,e),a(n,d.value,l),a(n,h.value,l),n}))),t=t.map((function(e,t){var l;return"object"===n(e)?e:(a(l={},C.value,t),a(l,d.value,e),a(l,h.value,e),l)})),N.value.length&&(t=t.concat(N.value)),t})),$=e.computed((function(){var e=M.value;return z.value.length&&(e=z.value.concat(e)),B.value&&O.value&&(e=e.filter((function(e){return-1!==r(e[d.value]).indexOf(r(B.value))}))),v.value&&(e=e.filter((function(e){return!re(e)}))),p.value>0&&(e=e.slice(0,p.value)),e})),L=e.computed((function(){switch(s.value){case"single":return!t(D.value[C.value]);case"multiple":case"tags":return!t(D.value)&&D.value.length>0}})),F=e.computed((function(){return void 0!==y&&void 0!==y.value?y.value(D.value):D.value&&D.value.length>1?"".concat(D.value.length," options selected"):"1 option selected"})),W=e.computed((function(){return!M.value.length&&!U.value})),X=e.computed((function(){return M.value.length>0&&0==$.value.length})),z=e.computed((function(){var e;return!1!==f.value&&B.value?-1!==ue(B.value)?[]:[(e={},a(e,C.value,B.value),a(e,h.value,B.value),a(e,d.value,B.value),e)]:[]})),G=e.computed((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),J=e.computed((function(){return b.value||U.value})),K=function(e){switch("object"!==n(e)&&(e=le(e)),s.value){case"single":A(e);break;case"multiple":case"tags":A(D.value.concat(e))}u.emit("select",Y(e))},Q=function(e){switch("object"!==n(e)&&(e=le(e)),s.value){case"single":ee();break;case"tags":case"multiple":A(D.value.filter((function(t){return t[C.value]!=e[C.value]})))}u.emit("deselect",Y(e))},Y=function(e){return g.value?e:e[C.value]},Z=function(e){Q(e)},ee=function(){A(G.value)},te=function(e){switch(s.value){case"single":return!t(D.value)&&D.value[C.value]==e[C.value];case"tags":case"multiple":return!t(D.value)&&-1!==D.value.map((function(e){return e[C.value]})).indexOf(e[C.value])}},ne=function(e){return!0===e.disabled},ae=function(){return!(void 0===q||-1===q.value||!L.value&&q.value>0)&&D.value.length>=q.value},le=function(e){return M.value[M.value.map((function(e){return String(e[C.value])})).indexOf(String(e))]},ue=function(e){return M.value.map((function(e){return r(e[d.value])})).indexOf(r(e))},re=function(e){return"tags"===s.value&&v.value&&te(e)},oe=function(e){N.value.push(e)},ie=function(){t(T.value)||(D.value=se(T.value))},ce=function(e){U.value=!0,c.value(B.value).then((function(t){H.value=t,"function"==typeof e&&e(t),U.value=!1}))},se=function(e){return t(e)?"single"===s.value?{}:[]:g.value?e:"single"===s.value?le(e)||{}:e.filter((function(e){return!!le(e)})).map((function(e){return le(e)}))};if("single"!==s.value&&!t(T.value)&&!Array.isArray(T.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return c&&"function"==typeof c.value?w.value?ce(ie):1==g.value&&ie():(H.value=c&&c.value?c.value:[],ie()),k.value>-1&&e.watch(B,(function(e){e.length<_.value||(U.value=!0,S.value&&(H.value=[]),setTimeout((function(){e==B.value&&c.value(B.value).then((function(t){e==B.value&&(H.value=t,I.value=$.value.filter((function(e){return!0!==e.disabled}))[0]||null,U.value=!1)}))}),k.value))}),{flush:"sync"}),e.watch(T,(function(e){var n,a,l;if(t(e))D.value=se(e);else switch(s.value){case"single":(g.value?e[C.value]!=D.value[C.value]:e!=D.value[C.value])&&(D.value=se(e));break;case"multiple":case"tags":n=g.value?e.map((function(e){return e[C.value]})):e,a=D.value.map((function(e){return e[C.value]})),l=a.slice().sort(),n.length===a.length&&n.slice().sort().every((function(e,t){return e===l[t]}))||(D.value=se(e))}}),{deep:!0}),e.watch((function(){return l.options}),(function(e){"function"!=typeof l.options&&(H.value=l.options)}),{flush:"sync"}),e.watch(M,(function(e,t){var n;M.value.length&&V.value&&V.value.length&&("single"===s.value?n=M.value[M.value.map((function(e){return e[C.value]})).indexOf(V.value)]:(n=[],V.value.forEach((function(e){n.push(M.value[M.value.map((function(e){return e[C.value]})).indexOf(e)])}))),g.value?A(n):D.value=n)}),{flush:"sync",deep:!0,immediate:!1}),{filteredOptions:$,hasSelected:L,multipleLabelText:F,extendedOptions:M,noOptions:W,noResults:X,resolving:U,busy:J,select:K,deselect:Q,remove:Z,clear:ee,isSelected:te,isDisabled:ne,isMax:ae,getOption:le,handleOptionClick:function(e){if(!ne(e))switch(s.value){case"single":if(te(e))return void(P.value&&Q(e));K(e),E(),j();break;case"multiple":if(te(e))return void Q(e);if(ae())return;K(e),x.value&&R();break;case"tags":if(te(e))return void Q(e);if(ae())return;void 0===le(e[C.value])&&f.value&&(u.emit("tag",e[C.value]),m.value&&oe(e),R()),x.value&&R(),K(e)}},handleTagRemove:function(e,t){0===t.button?Z(e):t.preventDefault()},refreshOptions:function(e){ce(e)},resolveOptions:ce}}function i(e,t,n,a,l,u,r,o,i,c){"boolean"!=typeof r&&(i=o,o=r,r=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,l&&(d.functional=!0)),a&&(d._scopeId=a),u?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(u)},d._ssrRegister=s):t&&(s=r?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),s)if(d.functional){var p=d.render;d.render=function(e,t){return s.call(t),p(e,t)}}else{var v=d.beforeCreate;d.beforeCreate=v?[].concat(v,s):[s]}return n}const c={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1},showOptions:{type:Boolean,required:!1,default:!0},addTagOn:{type:Array,required:!1,default:()=>["enter"]},required:{type:Boolean,required:!1,default:!1}},setup(n,a){const u=function(t,n){var a=e.toRefs(t),l=a.value,u=a.modelValue,r=a.mode,o=a.valueProp,i=e.ref("single"!==r.value?[]:{}),c=void 0!==n.expose?u:l,s=e.computed((function(){return Object.keys(i.value).length?"single"!==r.value?i.value.map((function(e){return e[o.value]})):i.value[o.value]:i.value})),d=e.computed((function(){return"single"!==r.value?i.value.map((function(e){return e[o.value]})).join(","):i.value[o.value]}));return{internalValue:i,externalValue:c,currentValue:s,textValue:d}}(n,a),r=function(t,n,a){var l=e.toRefs(t),u=l.searchable,r=(l.id,e.ref(null)),o=e.computed((function(){return u.value?-1:0}));return{multiselect:r,tabindex:o,focusInput:function(){r.value.querySelector(".multiselect-input").focus()},blurInput:function(){r.value.querySelector(".multiselect-input").blur()}}}(n),i={pointer:e.ref(null)},c=function(n,a,l){var u=e.toRefs(n),r=u.object,o=u.valueProp,i=u.mode,c=l.internalValue,s=function(e){return r.value||t(e)?e:Array.isArray(e)?e.map((function(e){return e[o.value]})):e[o.value]},d=function(e){return t(e)?"single"===i.value?{}:[]:e};return{update:function(e){c.value=d(e);var t=s(e);a.emit("change",t),a.emit("input",t),a.emit("update:modelValue",t)}}}(n,a,{internalValue:u.internalValue}),s=function(t,n,a){var l=e.toRefs(t),u=l.searchable,r=l.mode,o=a.internalValue,i=e.ref(null),c=e.ref(null),s=e.computed((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===r.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"}));return e.watch(i,(function(e){n.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=""},focusSearch:function(){c.value.focus()},blurSearch:function(){u.value&&c.value.blur()}}}(n,a,{internalValue:u.internalValue}),d=function(t,n,a){var l=e.toRefs(t),u=l.maxHeight,r=l.disabled,o=l.searchable,i=a.multiselect,c=a.blurInput,s=a.blurSearch,d=a.focusInput,p=a.focusSearch,v=e.ref(!1),f=e.computed((function(){return"".concat(u.value,"px")}));return{isOpen:v,contentMaxHeight:f,openDropdown:function(){r.value||(v.value=!0,n.emit("open"))},closeDropdown:function(){v.value=!1,n.emit("close")},open:function(){o&&o.value?p():d()},close:function(){o&&o.value?s():c()},handleInputMousedown:function(e){v.value&&!o.value&&(i.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),i.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(n,a,{multiselect:r.multiselect,blurInput:r.blurInput,blurSearch:s.blurSearch,focusInput:r.focusInput,focusSearch:s.focusSearch}),p=o(n,a,{externalValue:u.externalValue,internalValue:u.internalValue,currentValue:u.currentValue,search:s.search,blurSearch:s.blurSearch,clearSearch:s.clearSearch,update:c.update,blurInput:r.blurInput,pointer:i.pointer}),v=function(t,n,a){var l=e.toRefs(t),u=l.id,r=l.valueProp,o=a.filteredOptions,i=a.handleOptionClick,c=a.search,s=a.pointer,d=e.computed((function(){return o.value.filter((function(e){return!0!==e.disabled}))})),p=function(e){s.value=e},v=function(){s.value=d.value[0]||null},f=function(){s.value=null},h=function(){var e=document.getElementById(u.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return e.watch(c,(function(e){v()})),{pointer:s,isPointed:function(e){return!!s.value&&s.value[r.value]==e[r.value]},setPointer:p,setPointerFirst:v,clearPointer:f,selectPointer:function(){s.value&&!0!==s.value.disabled?(i(s.value),f()):f()},forwardPointer:function(){if(null===s.value)p(d.value[0]||null);else{var t=d.value.map((function(e){return e[r.value]})).indexOf(s.value[r.value])+1;d.value.length<=t&&(t=0),p(d.value[t]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===s.value)p(d.value[d.value.length-1]||null);else{var t=d.value.map((function(e){return e[r.value]})).indexOf(s.value[r.value])-1;t<0&&(t=d.value.length-1),p(d.value[t]||null)}e.nextTick((function(){h()}))}}}(n,0,{filteredOptions:p.filteredOptions,handleOptionClick:p.handleOptionClick,search:s.search,pointer:i.pointer}),f=function(t,n,a){var u=e.toRefs(t),r=u.mode,o=u.addTagOn,i={enter:13,space:32},c=a.internalValue,s=a.update,d=a.closeDropdown,p=a.clearPointer,v=a.search,f=a.selectPointer;return{handleBackspace:function(e){"single"!==r.value&&s(l(c.value).slice(0,-1))},handleEsc:function(e){d(),p(),e.target.blur()},handleSearchBackspace:function(e){""!==v.value&&e.stopPropagation()},handleAddTag:function(e){-1!==Object.values(function(e,t){var n,a={};for(n in e)e.hasOwnProperty(n)&&-1!==t.indexOf(n)&&(a[n]=e[n]);return a}(i,o.value)).indexOf(e.keyCode)&&f()}}}(n,0,{internalValue:u.internalValue,update:c.update,closeDropdown:d.closeDropdown,clearPointer:v.clearPointer,search:s.search,selectPointer:v.selectPointer});return{...u,...d,...r,...i,...c,...s,...p,...v,...f}}};var s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{mousedown:e.handleInputMousedown,focus:e.openDropdown,blur:e.closeDropdown,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.handleAddTag(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:e.handleAddTag(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.internalValue?[e._t("singlelabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.internalValue[e.label])+"\n ")])],{value:e.internalValue})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.internalValue})]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.internalValue,(function(t,a,l){return n("span",{key:l},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),n.stopPropagation(),e.handleTagRemove(t,n)}}})])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.handleAddTag(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:(t.stopPropagation(),e.handleAddTag(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[n("div",{staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.busy,expression:"busy"}],staticClass:"multiselect-spinner"})]),e._v(" "),"single"!==e.mode&&e.hasSelected&&!e.disabled?n("a",{staticClass:"multiselect-clear",on:{click:function(t){return t.preventDefault(),e.clear(t)}}}):e._e()],2),e._v(" "),e.resolving&&e.clearOnSearch?e._e():n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen&&e.showOptions,expression:"isOpen && showOptions"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforelist"),e._v(" "),e._l(e.filteredOptions,(function(t,a,l){return n("span",{key:l,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t),"is-disabled":e.isDisabled(t)},attrs:{tabindex:-1},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("nooptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noresults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterlist")],2)]),e._v(" "),e.required?n("input",{staticClass:"multiselect-fake-input",attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e()],1)};s._withStripped=!0;return i({render:s,staticRenderFns:[]},undefined,c,undefined,false,undefined,!1,void 0,void 0,void 0)}(VueCompositionAPI);

@@ -1,1 +0,1 @@

import{toRefs as e,ref as t,computed as n,watch as l,nextTick as a}from"@vue/composition-api";function u(e){return-1!==[null,void 0,!1].indexOf(e)}function r(e){return String(e).toLowerCase().trim()}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(a,c,s){var d=e(a),v=d.options,p=d.mode,f=d.trackBy,h=d.limit,y=d.hideSelected,m=d.createTag,g=d.label,b=d.appendNewTag,k=d.multipleLabel,_=d.object,w=d.loading,S=d.delay,O=d.resolveOnLoad,x=d.minChars,C=d.filterResults,P=d.clearOnSearch,D=d.clearOnSelect,q=d.valueProp,T=d.canDeselect,V=d.max,E=s.internalValue,B=s.externalValue,A=s.search,I=s.blurSearch,N=s.clearSearch,R=s.update,j=s.blurInput,H=s.pointer,U=t([]),$=t([]),L=t(!1),M=n((function(){var e,t=$.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,l=t[e];return o(n={},q.value,e),o(n,f.value,l),o(n,g.value,l),n}))),t=t.map((function(e,t){var n;return"object"===i(e)?e:(o(n={},q.value,t),o(n,f.value,e),o(n,g.value,e),n)})),U.value.length&&(t=t.concat(U.value)),t})),F=n((function(){var e=M.value;return J.value.length&&(e=J.value.concat(e)),A.value&&C.value&&(e=e.filter((function(e){return-1!==r(e[f.value]).indexOf(r(A.value))}))),y.value&&(e=e.filter((function(e){return!oe(e)}))),h.value>0&&(e=e.slice(0,h.value)),e})),W=n((function(){switch(p.value){case"single":return!u(E.value[q.value]);case"multiple":case"tags":return!u(E.value)&&E.value.length>0}})),X=n((function(){return void 0!==k&&void 0!==k.value?k.value(E.value):E.value&&E.value.length>1?"".concat(E.value.length," options selected"):"1 option selected"})),z=n((function(){return!M.value.length&&!L.value})),G=n((function(){return M.value.length>0&&0==F.value.length})),J=n((function(){var e;return!1!==m.value&&A.value?-1!==ie(A.value)?[]:[(e={},o(e,q.value,A.value),o(e,g.value,A.value),o(e,f.value,A.value),e)]:[]})),K=n((function(){switch(p.value){case"single":return null;case"multiple":case"tags":return[]}})),Q=n((function(){return w.value||L.value})),Y=function(e){switch("object"!==i(e)&&(e=re(e)),p.value){case"single":R(e);break;case"multiple":case"tags":R(E.value.concat(e))}c.emit("select",ee(e))},Z=function(e){switch("object"!==i(e)&&(e=re(e)),p.value){case"single":ne();break;case"tags":case"multiple":R(E.value.filter((function(t){return t[q.value]!=e[q.value]})))}c.emit("deselect",ee(e))},ee=function(e){return _.value?e:e[q.value]},te=function(e){Z(e)},ne=function(){R(K.value)},le=function(e){switch(p.value){case"single":return!u(E.value)&&E.value[q.value]==e[q.value];case"tags":case"multiple":return!u(E.value)&&-1!==E.value.map((function(e){return e[q.value]})).indexOf(e[q.value])}},ae=function(e){return!0===e.disabled},ue=function(){return!(void 0===V||-1===V.value||!W.value&&V.value>0)&&E.value.length>=V.value},re=function(e){return M.value[M.value.map((function(e){return String(e[q.value])})).indexOf(String(e))]},ie=function(e){return M.value.map((function(e){return r(e[f.value])})).indexOf(r(e))},oe=function(e){return"tags"===p.value&&y.value&&le(e)},ce=function(e){U.value.push(e)},se=function(){u(B.value)||(E.value=ve(B.value))},de=function(e){L.value=!0,v.value(A.value).then((function(t){$.value=t,"function"==typeof e&&e(t),L.value=!1}))},ve=function(e){return u(e)?"single"===p.value?{}:[]:_.value?e:"single"===p.value?re(e)||{}:e.filter((function(e){return!!re(e)})).map((function(e){return re(e)}))};if("single"!==p.value&&!u(B.value)&&!Array.isArray(B.value))throw new Error('v-model must be an array when using "'.concat(p.value,'" mode'));return v&&"function"==typeof v.value?O.value?de(se):1==_.value&&se():($.value=v&&v.value?v.value:[],se()),S.value>-1&&l(A,(function(e){e.length<x.value||(L.value=!0,P.value&&($.value=[]),setTimeout((function(){e==A.value&&v.value(A.value).then((function(t){e==A.value&&($.value=t,H.value=F.value.filter((function(e){return!0!==e.disabled}))[0]||null,L.value=!1)}))}),S.value))}),{flush:"sync"}),l(B,(function(e){var t,n,l;if(u(e))E.value=ve(e);else switch(p.value){case"single":(_.value?e[q.value]!=E.value[q.value]:e!=E.value[q.value])&&(E.value=ve(e));break;case"multiple":case"tags":t=_.value?e.map((function(e){return e[q.value]})):e,n=E.value.map((function(e){return e[q.value]})),l=n.slice().sort(),t.length===n.length&&t.slice().sort().every((function(e,t){return e===l[t]}))||(E.value=ve(e))}}),{deep:!0}),l((function(){return a.options}),(function(e){"function"!=typeof a.options&&($.value=a.options)}),{flush:"sync"}),{filteredOptions:F,hasSelected:W,multipleLabelText:X,extendedOptions:M,noOptions:z,noResults:G,resolving:L,busy:Q,select:Y,deselect:Z,remove:te,clear:ne,isSelected:le,isDisabled:ae,isMax:ue,getOption:re,handleOptionClick:function(e){if(!ae(e))switch(p.value){case"single":if(le(e))return void(T.value&&Z(e));Y(e),I(),j();break;case"multiple":if(le(e))return void Z(e);if(ue())return;Y(e),D.value&&N();break;case"tags":if(le(e))return void Z(e);if(ue())return;void 0===re(e[q.value])&&m.value&&(c.emit("tag",e[q.value]),b.value&&ce(e),N()),D.value&&N(),Y(e)}},handleTagRemove:function(e,t){0===t.button?te(e):t.preventDefault()},refreshOptions:function(e){de(e)},resolveOptions:de}}function s(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){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 d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=new Array(t);n<t;n++)l[n]=e[n];return l}function v(e,t,n,l,a,u,r,i,o,c){"boolean"!=typeof r&&(o=i,i=r,r=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),l&&(d._scopeId=l),u?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,o(e)),e&&e._registeredComponents&&e._registeredComponents.add(u)},d._ssrRegister=s):t&&(s=r?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,i(e))}),s)if(d.functional){var v=d.render;d.render=function(e,t){return s.call(t),v(e,t)}}else{var p=d.beforeCreate;d.beforeCreate=p?[].concat(p,s):[s]}return n}const p={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1}},setup(r,i){const o=function(n,l){var a=e(n),u=a.value,r=a.modelValue,i=a.mode;return{internalValue:t("single"!==i.value?[]:{}),externalValue:void 0!==l.expose?r:u}}(r,i),d=function(l,a,u){var r=e(l),i=r.searchable,o=(r.id,t(null)),c=n((function(){return i.value?-1:0}));return{multiselect:o,tabindex:c,focusInput:function(){o.value.querySelector(".multiselect-input").focus()},blurInput:function(){o.value.querySelector(".multiselect-input").blur()}}}(r),v={pointer:t(null)},p=function(t,n,l){var a=e(t),r=a.object,i=a.valueProp,o=a.mode,c=l.internalValue,s=function(e){return r.value||u(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},d=function(e){return u(e)?"single"===o.value?{}:[]:e};return{update:function(e){c.value=d(e);var t=s(e);n.emit("change",t),n.emit("input",t),n.emit("update:modelValue",t)}}}(r,i,{internalValue:o.internalValue}),f=function(a,u,r){var i=e(a),o=i.searchable,c=i.mode,s=r.internalValue,d=t(null),v=t(null),p=n((function(){return d.value?"".concat(d.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return l(d,(function(e){u.emit("search-change",e)})),{search:d,input:v,tagsSearchWidth:p,clearSearch:function(){d.value=""},focusSearch:function(){v.value.focus()},blurSearch:function(){o.value&&v.value.blur()}}}(r,i,{internalValue:o.internalValue}),h=function(l,a,u){var r=e(l),i=r.maxHeight,o=r.disabled,c=r.searchable,s=u.multiselect,d=u.blurInput,v=u.blurSearch,p=u.focusInput,f=u.focusSearch,h=t(!1),y=n((function(){return"".concat(i.value,"px")}));return{isOpen:h,contentMaxHeight:y,openDropdown:function(){o.value||(h.value=!0,a.emit("open"))},closeDropdown:function(){h.value=!1,a.emit("close")},open:function(){c&&c.value?f():p()},close:function(){c&&c.value?v():d()},handleInputMousedown:function(e){h.value&&!c.value&&(s.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),s.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(r,i,{multiselect:d.multiselect,blurInput:d.blurInput,blurSearch:f.blurSearch,focusInput:d.focusInput,focusSearch:f.focusSearch}),y=c(r,i,{externalValue:o.externalValue,internalValue:o.internalValue,search:f.search,blurSearch:f.blurSearch,clearSearch:f.clearSearch,update:p.update,blurInput:d.blurInput,pointer:v.pointer}),m=function(t,u,r){var i=e(t),o=i.id,c=i.valueProp,s=r.filteredOptions,d=r.handleOptionClick,v=r.search,p=r.pointer,f=n((function(){return s.value.filter((function(e){return!0!==e.disabled}))})),h=function(e){p.value=e},y=function(){p.value=f.value[0]||null},m=function(){p.value=null},g=function(){var e=document.getElementById(o.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return l(v,(function(e){y()})),{pointer:p,isPointed:function(e){return!!p.value&&p.value[c.value]==e[c.value]},setPointer:h,setPointerFirst:y,clearPointer:m,selectPointer:function(){p.value&&!0!==p.value.disabled?(d(p.value),m()):m()},forwardPointer:function(){if(null===p.value)h(f.value[0]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])+1;f.value.length<=e&&(e=0),h(f.value[e]||null)}a((function(){g()}))},backwardPointer:function(){if(null===p.value)h(f.value[f.value.length-1]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])-1;e<0&&(e=f.value.length-1),h(f.value[e]||null)}a((function(){g()}))}}}(r,0,{filteredOptions:y.filteredOptions,handleOptionClick:y.handleOptionClick,search:f.search,pointer:v.pointer}),g=function(t,n,l){var a=e(t).mode,u=l.internalValue,r=l.update,i=l.closeDropdown,o=l.clearPointer,c=l.search;return{handleBackspace:function(e){"single"!==a.value&&r(s(u.value).slice(0,-1))},handleEsc:function(e){i(),o(),e.target.blur()},handleSearchBackspace:function(e){""!==c.value&&e.stopPropagation()}}}(r,0,{internalValue:o.internalValue,update:p.update,closeDropdown:h.closeDropdown,clearPointer:m.clearPointer,search:f.search});return{...o,...h,...d,...v,...p,...f,...y,...m,...g}}};var f=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{mousedown:e.handleInputMousedown,focus:e.openDropdown,blur:e.closeDropdown,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.selectPointer(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.internalValue?[e._t("singlelabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.internalValue[e.label])+"\n ")])],{value:e.internalValue})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.internalValue})]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.internalValue,(function(t,l,a){return n("span",{key:a},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),n.stopPropagation(),e.handleTagRemove(t,n)}}})])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[n("div",{staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.busy,expression:"busy"}],staticClass:"multiselect-spinner"})]),e._v(" "),"single"!==e.mode&&e.hasSelected&&!e.disabled?n("a",{staticClass:"multiselect-clear",on:{click:function(t){return t.preventDefault(),e.clear(t)}}}):e._e()],2),e._v(" "),e.resolving&&e.clearOnSearch?e._e():n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforelist"),e._v(" "),e._l(e.filteredOptions,(function(t,l,a){return n("a",{key:a,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t),"is-disabled":e.isDisabled(t)},attrs:{tabindex:-1,href:""},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("nooptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noresults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterlist")],2)])],1)};f._withStripped=!0;const h=v({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);export default h;
import{toRefs as e,ref as t,computed as n,watch as a,nextTick as l}from"@vue/composition-api";function u(e){return-1!==[null,void 0,!1].indexOf(e)}function r(e){return String(e).toLowerCase().trim()}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(l,c,s){var d=e(l),v=d.options,p=d.mode,f=d.trackBy,h=d.limit,y=d.hideSelected,m=d.createTag,g=d.label,b=d.appendNewTag,k=d.multipleLabel,_=d.object,w=d.loading,O=d.delay,S=d.resolveOnLoad,x=d.minChars,C=d.filterResults,P=d.clearOnSearch,q=d.clearOnSelect,D=d.valueProp,T=d.canDeselect,V=d.max,B=s.internalValue,E=s.externalValue,A=s.currentValue,j=s.search,I=s.blurSearch,N=s.clearSearch,R=s.update,H=s.blurInput,U=s.pointer,$=t([]),L=t([]),M=t(!1),F=n((function(){var e,t=L.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,a=t[e];return o(n={},D.value,e),o(n,f.value,a),o(n,g.value,a),n}))),t=t.map((function(e,t){var n;return"object"===i(e)?e:(o(n={},D.value,t),o(n,f.value,e),o(n,g.value,e),n)})),$.value.length&&(t=t.concat($.value)),t})),W=n((function(){var e=F.value;return K.value.length&&(e=K.value.concat(e)),j.value&&C.value&&(e=e.filter((function(e){return-1!==r(e[f.value]).indexOf(r(j.value))}))),y.value&&(e=e.filter((function(e){return!ce(e)}))),h.value>0&&(e=e.slice(0,h.value)),e})),X=n((function(){switch(p.value){case"single":return!u(B.value[D.value]);case"multiple":case"tags":return!u(B.value)&&B.value.length>0}})),z=n((function(){return void 0!==k&&void 0!==k.value?k.value(B.value):B.value&&B.value.length>1?"".concat(B.value.length," options selected"):"1 option selected"})),G=n((function(){return!F.value.length&&!M.value})),J=n((function(){return F.value.length>0&&0==W.value.length})),K=n((function(){var e;return!1!==m.value&&j.value?-1!==oe(j.value)?[]:[(e={},o(e,D.value,j.value),o(e,g.value,j.value),o(e,f.value,j.value),e)]:[]})),Q=n((function(){switch(p.value){case"single":return null;case"multiple":case"tags":return[]}})),Y=n((function(){return w.value||M.value})),Z=function(e){switch("object"!==i(e)&&(e=ie(e)),p.value){case"single":R(e);break;case"multiple":case"tags":R(B.value.concat(e))}c.emit("select",te(e))},ee=function(e){switch("object"!==i(e)&&(e=ie(e)),p.value){case"single":ae();break;case"tags":case"multiple":R(B.value.filter((function(t){return t[D.value]!=e[D.value]})))}c.emit("deselect",te(e))},te=function(e){return _.value?e:e[D.value]},ne=function(e){ee(e)},ae=function(){R(Q.value)},le=function(e){switch(p.value){case"single":return!u(B.value)&&B.value[D.value]==e[D.value];case"tags":case"multiple":return!u(B.value)&&-1!==B.value.map((function(e){return e[D.value]})).indexOf(e[D.value])}},ue=function(e){return!0===e.disabled},re=function(){return!(void 0===V||-1===V.value||!X.value&&V.value>0)&&B.value.length>=V.value},ie=function(e){return F.value[F.value.map((function(e){return String(e[D.value])})).indexOf(String(e))]},oe=function(e){return F.value.map((function(e){return r(e[f.value])})).indexOf(r(e))},ce=function(e){return"tags"===p.value&&y.value&&le(e)},se=function(e){$.value.push(e)},de=function(){u(E.value)||(B.value=pe(E.value))},ve=function(e){M.value=!0,v.value(j.value).then((function(t){L.value=t,"function"==typeof e&&e(t),M.value=!1}))},pe=function(e){return u(e)?"single"===p.value?{}:[]:_.value?e:"single"===p.value?ie(e)||{}:e.filter((function(e){return!!ie(e)})).map((function(e){return ie(e)}))};if("single"!==p.value&&!u(E.value)&&!Array.isArray(E.value))throw new Error('v-model must be an array when using "'.concat(p.value,'" mode'));return v&&"function"==typeof v.value?S.value?ve(de):1==_.value&&de():(L.value=v&&v.value?v.value:[],de()),O.value>-1&&a(j,(function(e){e.length<x.value||(M.value=!0,P.value&&(L.value=[]),setTimeout((function(){e==j.value&&v.value(j.value).then((function(t){e==j.value&&(L.value=t,U.value=W.value.filter((function(e){return!0!==e.disabled}))[0]||null,M.value=!1)}))}),O.value))}),{flush:"sync"}),a(E,(function(e){var t,n,a;if(u(e))B.value=pe(e);else switch(p.value){case"single":(_.value?e[D.value]!=B.value[D.value]:e!=B.value[D.value])&&(B.value=pe(e));break;case"multiple":case"tags":t=_.value?e.map((function(e){return e[D.value]})):e,n=B.value.map((function(e){return e[D.value]})),a=n.slice().sort(),t.length===n.length&&t.slice().sort().every((function(e,t){return e===a[t]}))||(B.value=pe(e))}}),{deep:!0}),a((function(){return l.options}),(function(e){"function"!=typeof l.options&&(L.value=l.options)}),{flush:"sync"}),a(F,(function(e,t){var n;F.value.length&&A.value&&A.value.length&&("single"===p.value?n=F.value[F.value.map((function(e){return e[D.value]})).indexOf(A.value)]:(n=[],A.value.forEach((function(e){n.push(F.value[F.value.map((function(e){return e[D.value]})).indexOf(e)])}))),_.value?R(n):B.value=n)}),{flush:"sync",deep:!0,immediate:!1}),{filteredOptions:W,hasSelected:X,multipleLabelText:z,extendedOptions:F,noOptions:G,noResults:J,resolving:M,busy:Y,select:Z,deselect:ee,remove:ne,clear:ae,isSelected:le,isDisabled:ue,isMax:re,getOption:ie,handleOptionClick:function(e){if(!ue(e))switch(p.value){case"single":if(le(e))return void(T.value&&ee(e));Z(e),I(),H();break;case"multiple":if(le(e))return void ee(e);if(re())return;Z(e),q.value&&N();break;case"tags":if(le(e))return void ee(e);if(re())return;void 0===ie(e[D.value])&&m.value&&(c.emit("tag",e[D.value]),b.value&&se(e),N()),q.value&&N(),Z(e)}},handleTagRemove:function(e,t){0===t.button?ne(e):t.preventDefault()},refreshOptions:function(e){ve(e)},resolveOptions:ve}}function s(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e)||function(){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 d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function v(e,t,n,a,l,u,r,i,o,c){"boolean"!=typeof r&&(o=i,i=r,r=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,l&&(d.functional=!0)),a&&(d._scopeId=a),u?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,o(e)),e&&e._registeredComponents&&e._registeredComponents.add(u)},d._ssrRegister=s):t&&(s=r?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,i(e))}),s)if(d.functional){var v=d.render;d.render=function(e,t){return s.call(t),v(e,t)}}else{var p=d.beforeCreate;d.beforeCreate=p?[].concat(p,s):[s]}return n}const p={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},valueProp:{type:String,required:!1,default:"value"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelected:{type:Boolean,required:!1,default:!0},createTag:{type:Boolean,required:!1,default:!1},appendNewTag:{type:Boolean,required:!1,default:!0},caret:{type:Boolean,required:!1,default:!0},loading:{type:Boolean,required:!1,default:!1},noOptionsText:{type:String,required:!1,default:"The list is empty"},noResultsText:{type:String,required:!1,default:"No results found"},multipleLabel:{type:Function,required:!1},object:{type:Boolean,required:!1,default:!1},delay:{type:Number,required:!1,default:-1},minChars:{type:Number,required:!1,default:0},resolveOnLoad:{type:Boolean,required:!1,default:!0},filterResults:{type:Boolean,required:!1,default:!0},clearOnSearch:{type:Boolean,required:!1,default:!1},clearOnSelect:{type:Boolean,required:!1,default:!0},canDeselect:{type:Boolean,required:!1,default:!0},max:{type:Number,required:!1,default:-1},showOptions:{type:Boolean,required:!1,default:!0},addTagOn:{type:Array,required:!1,default:()=>["enter"]},required:{type:Boolean,required:!1,default:!1}},setup(r,i){const o=function(a,l){var u=e(a),r=u.value,i=u.modelValue,o=u.mode,c=u.valueProp,s=t("single"!==o.value?[]:{}),d=void 0!==l.expose?i:r,v=n((function(){return Object.keys(s.value).length?"single"!==o.value?s.value.map((function(e){return e[c.value]})):s.value[c.value]:s.value})),p=n((function(){return"single"!==o.value?s.value.map((function(e){return e[c.value]})).join(","):s.value[c.value]}));return{internalValue:s,externalValue:d,currentValue:v,textValue:p}}(r,i),d=function(a,l,u){var r=e(a),i=r.searchable,o=(r.id,t(null)),c=n((function(){return i.value?-1:0}));return{multiselect:o,tabindex:c,focusInput:function(){o.value.querySelector(".multiselect-input").focus()},blurInput:function(){o.value.querySelector(".multiselect-input").blur()}}}(r),v={pointer:t(null)},p=function(t,n,a){var l=e(t),r=l.object,i=l.valueProp,o=l.mode,c=a.internalValue,s=function(e){return r.value||u(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},d=function(e){return u(e)?"single"===o.value?{}:[]:e};return{update:function(e){c.value=d(e);var t=s(e);n.emit("change",t),n.emit("input",t),n.emit("update:modelValue",t)}}}(r,i,{internalValue:o.internalValue}),f=function(l,u,r){var i=e(l),o=i.searchable,c=i.mode,s=r.internalValue,d=t(null),v=t(null),p=n((function(){return d.value?"".concat(d.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return a(d,(function(e){u.emit("search-change",e)})),{search:d,input:v,tagsSearchWidth:p,clearSearch:function(){d.value=""},focusSearch:function(){v.value.focus()},blurSearch:function(){o.value&&v.value.blur()}}}(r,i,{internalValue:o.internalValue}),h=function(a,l,u){var r=e(a),i=r.maxHeight,o=r.disabled,c=r.searchable,s=u.multiselect,d=u.blurInput,v=u.blurSearch,p=u.focusInput,f=u.focusSearch,h=t(!1),y=n((function(){return"".concat(i.value,"px")}));return{isOpen:h,contentMaxHeight:y,openDropdown:function(){o.value||(h.value=!0,l.emit("open"))},closeDropdown:function(){h.value=!1,l.emit("close")},open:function(){c&&c.value?f():p()},close:function(){c&&c.value?v():d()},handleInputMousedown:function(e){h.value&&!c.value&&(s.value.querySelector(".multiselect-input").dispatchEvent(new Event("blur")),s.value.querySelector(".multiselect-input").blur(),e.preventDefault())}}}(r,i,{multiselect:d.multiselect,blurInput:d.blurInput,blurSearch:f.blurSearch,focusInput:d.focusInput,focusSearch:f.focusSearch}),y=c(r,i,{externalValue:o.externalValue,internalValue:o.internalValue,currentValue:o.currentValue,search:f.search,blurSearch:f.blurSearch,clearSearch:f.clearSearch,update:p.update,blurInput:d.blurInput,pointer:v.pointer}),m=function(t,u,r){var i=e(t),o=i.id,c=i.valueProp,s=r.filteredOptions,d=r.handleOptionClick,v=r.search,p=r.pointer,f=n((function(){return s.value.filter((function(e){return!0!==e.disabled}))})),h=function(e){p.value=e},y=function(){p.value=f.value[0]||null},m=function(){p.value=null},g=function(){var e=document.getElementById(o.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return a(v,(function(e){y()})),{pointer:p,isPointed:function(e){return!!p.value&&p.value[c.value]==e[c.value]},setPointer:h,setPointerFirst:y,clearPointer:m,selectPointer:function(){p.value&&!0!==p.value.disabled?(d(p.value),m()):m()},forwardPointer:function(){if(null===p.value)h(f.value[0]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])+1;f.value.length<=e&&(e=0),h(f.value[e]||null)}l((function(){g()}))},backwardPointer:function(){if(null===p.value)h(f.value[f.value.length-1]||null);else{var e=f.value.map((function(e){return e[c.value]})).indexOf(p.value[c.value])-1;e<0&&(e=f.value.length-1),h(f.value[e]||null)}l((function(){g()}))}}}(r,0,{filteredOptions:y.filteredOptions,handleOptionClick:y.handleOptionClick,search:f.search,pointer:v.pointer}),g=function(t,n,a){var l=e(t),u=l.mode,r=l.addTagOn,i={enter:13,space:32},o=a.internalValue,c=a.update,d=a.closeDropdown,v=a.clearPointer,p=a.search,f=a.selectPointer;return{handleBackspace:function(e){"single"!==u.value&&c(s(o.value).slice(0,-1))},handleEsc:function(e){d(),v(),e.target.blur()},handleSearchBackspace:function(e){""!==p.value&&e.stopPropagation()},handleAddTag:function(e){-1!==Object.values(function(e,t){var n,a={};for(n in e)e.hasOwnProperty(n)&&-1!==t.indexOf(n)&&(a[n]=e[n]);return a}(i,r.value)).indexOf(e.keyCode)&&f()}}}(r,0,{internalValue:o.internalValue,update:p.update,closeDropdown:h.closeDropdown,clearPointer:m.clearPointer,search:f.search,selectPointer:m.selectPointer});return{...o,...h,...d,...v,...p,...f,...y,...m,...g}}};var f=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{mousedown:e.handleInputMousedown,focus:e.openDropdown,blur:e.closeDropdown,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.handleAddTag(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:e.handleAddTag(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.internalValue?[e._t("singlelabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.internalValue[e.label])+"\n ")])],{value:e.internalValue})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.internalValue})]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.internalValue,(function(t,a,l){return n("span",{key:l},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),n.stopPropagation(),e.handleTagRemove(t,n)}}})])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.openDropdown(t)},blur:function(t){return t.stopPropagation(),e.closeDropdown(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.handleAddTag(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"space",32,t.key,[" ","Spacebar"])?null:(t.stopPropagation(),e.handleAddTag(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[n("div",{staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.busy,expression:"busy"}],staticClass:"multiselect-spinner"})]),e._v(" "),"single"!==e.mode&&e.hasSelected&&!e.disabled?n("a",{staticClass:"multiselect-clear",on:{click:function(t){return t.preventDefault(),e.clear(t)}}}):e._e()],2),e._v(" "),e.resolving&&e.clearOnSearch?e._e():n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen&&e.showOptions,expression:"isOpen && showOptions"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforelist"),e._v(" "),e._l(e.filteredOptions,(function(t,a,l){return n("span",{key:l,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t),"is-disabled":e.isDisabled(t)},attrs:{tabindex:-1},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("nooptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noresults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterlist")],2)]),e._v(" "),e.required?n("input",{staticClass:"multiselect-fake-input",attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e()],1)};f._withStripped=!0;const h=v({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0);export default h;
{
"name": "@vueform/multiselect",
"version": "1.3.2",
"version": "1.3.3",
"private": false,

@@ -5,0 +5,0 @@ "description": "Vue 3 multiselect component with single select, multiselect and tagging options.",

<div align="center">
<img alt="CircleCI" src="https://img.shields.io/circleci/build/github/vueform/multiselect">
<a href="https://www.npmjs.com/package/@vueform/multiselect" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/dm/@vueform/multiselect?color=%2353ca2f">
</a>
<a href="https://codecov.io/gh/vueform/multiselect" target="_blank">

@@ -12,6 +15,2 @@ <img src="https://img.shields.io/codecov/c/github/vueform/multiselect"/>

<a href="https://github.com/vueform/multiselect/blob/main/LICENSE.md" target="_blank">
<img alt="GitHub" src="https://img.shields.io/github/license/vueform/multiselect?color=53ca2f">
</a>
<a href="https://discord.gg/WhX2nG6GTQ" target="_blank">

@@ -134,2 +133,3 @@ <img alt="Discord" src="https://img.shields.io/discord/787237947635793940">

| **options** | `array\|object\|function` | `[]` | List of options. Can be:<br>- an array (eg. `[1,2,3]`)<br>- an object (eg. `{a:1,b:2,c:3}`)<br>- an array of objects `[{value:1,label:'v1'},{value:2,label:'v2'},{value:3,label:'v3',disabled:true}]`<br>- a function returning a Promise (async function) with `query` input param. The promise should return options as an **object** or as an **array of objects**.<br>When an array of objects is provided it **must** have properties that equal to `:valueProp`'s, `:trackBy`'s and `:label`'s value. |
| **required** | `boolean` | `false` | Whether the HTML5 required attribute should be used for multiselect (using an invisible fake input). |
| **searchable** | `boolean` | `false` | Whether the options should be searchable. |

@@ -164,3 +164,5 @@ | **valueProp** | `string` | `'value'` | If you provide an array of objects as options this property should be used as the value of the option. |

| **createTag** | `boolean` | `false` | Whether it should allow creating new tag based on search query when using `tags` mode. |
| **addTagOn** | `array` | `['enter']` | The list of keys that trigger tags to be created when using `createTag`. Possible values: `enter|space`. |
| **hideSelected** | `boolean` | `true` | Whether selected options should be excluded from the option list when using `multiple` or `tags` mode. |
| **showOptions** | `boolean` | `true` | Whether option list should be displayed. Can be used to create free-typed tags. |
| **object** | `boolean` | `false` | Whether the value should be stored as an object.<br>If **false**:<br>`value: ['js','jsx','ts']`<br>If **true**:<br> `value: [`<br>&nbsp;&nbsp;`{value:'js',label:'Javascript'},`<br>&nbsp;&nbsp;`{value:'jsx',label:'JSX'},`<br>&nbsp;&nbsp;`{value:'ts',label:'Typescript'}`<br>`]` |

@@ -222,3 +224,3 @@

| **singlelabel** | `value` | Rendered when using `single` mode and an option is selected. By default it renders the `:label` if the selected option. |
| **tag** | `option, remove, disabled` | Renders a tag when using `tags` mode. When `disabled` the remove icon should not be displayed. The `remove` prop should be used to trigger the removal of the tag. |
| **tag** | `option, handleTagRemove, disabled` | Renders a tag when using `tags` mode. When `disabled` the remove icon should not be displayed. The `handleTagRemove` prop should be used to trigger the removal of the tag. |

@@ -225,0 +227,0 @@ > Note: we don't use camelCase because they are [normalized back to lowercase](https://github.com/vuejs/vue/issues/9449#issuecomment-461170017) when written in DOM.

import { toRefs } from 'composition-api'
import filterObjectKeys from './../utils/filterObjectKeys'
export default function useKeyboard (props, context, dependencies)
{
const { mode } = toRefs(props)
const { mode, addTagOn } = toRefs(props)
const KEYCODES = {
enter: 13,
space: 32,
}
// ============ DEPENDENCIES ============

@@ -14,2 +20,3 @@

const search = dependencies.search
const selectPointer = dependencies.selectPointer

@@ -38,2 +45,8 @@ // =============== METHODS ==============

const handleAddTag = (e) => {
if (Object.values(filterObjectKeys(KEYCODES, addTagOn.value)).indexOf(e.keyCode) !== -1) {
selectPointer()
}
}
return {

@@ -43,3 +56,4 @@ handleBackspace,

handleSearchBackspace,
handleAddTag,
}
}

@@ -18,2 +18,3 @@ import { ref, toRefs, computed, watch } from 'composition-api'

const externalValue = dependencies.externalValue
const currentValue = dependencies.currentValue
const search = dependencies.search

@@ -427,2 +428,29 @@ const blurSearch = dependencies.blurSearch

watch(extendedOptions, (n, o) => {
if (!extendedOptions.value.length || !currentValue.value || !currentValue.value.length) {
return
}
let newValue
if (mode.value === 'single') {
newValue = extendedOptions.value[extendedOptions.value.map(v=>v[valueProp.value]).indexOf(currentValue.value)]
} else {
newValue = []
currentValue.value.forEach((val) => {
newValue.push(extendedOptions.value[extendedOptions.value.map(v=>v[valueProp.value]).indexOf(val)])
})
}
// Update both internal and external value if user is using object values
if (object.value) {
update(newValue)
// Only update internal value if external is only valueProp
} else {
internalValue.value = newValue
}
}, { flush: 'sync', deep: true, immediate: false })
return {

@@ -429,0 +457,0 @@ filteredOptions,

import { computed, toRefs, ref } from 'composition-api'
import isNullish from './../utils/isNullish'
export default function useValue (props, context)
{
const { value, modelValue, mode } = toRefs(props)
const { value, modelValue, mode, valueProp } = toRefs(props)

@@ -16,6 +17,20 @@ // ================ DATA ================

const currentValue = computed(() => {
if (!Object.keys(internalValue.value).length) {
return internalValue.value
}
return mode.value !== 'single' ? internalValue.value.map(v=>v[valueProp.value]) : internalValue.value[valueProp.value]
})
const textValue = computed(() => {
return mode.value !== 'single' ? internalValue.value.map(v=>v[valueProp.value]).join(',') : internalValue.value[valueProp.value]
})
return {
internalValue,
externalValue,
currentValue,
textValue,
}
}

@@ -32,4 +32,7 @@ import Vue,{ VNode } from 'vue';

createTag?: boolean;
addTagOn?: string[];
hideSelected?: boolean;
showOptions?: boolean;
object: boolean;
required: boolean;

@@ -36,0 +39,0 @@ $emit(eventName: 'change', e: {originalEvent: Event, value: any}): this;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc