@vueform/multiselect
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -21,2 +21,2 @@ --- | ||
Please use our [JSFiddle template](https://jsfiddle.net/q6Lnpr7a/) to reproduce the bug. Issues without working reproduction might be ignored. | ||
Please use our [JSFiddle template](https://jsfiddle.net/g56vfpe4/) to reproduce the bug. Issues without working reproduction might be ignored. |
@@ -0,1 +1,17 @@ | ||
## v2.1.0 | ||
> `2021-07-26` | ||
### 🎉 Feature | ||
- **BREAKING**: removed `:maxHeight` prop. Use `var(--ms-max-height)` instead. | ||
- **BREAKING**: tags search layout has changed -> added a wrapper div and an extra span to calculate input width. | ||
- Dropddown can be closed on caret click [#88](https://github.com/vueform/multiselect/issues/88). | ||
- Added `:strict` prop to achieve accent-free search [#82](https://github.com/vueform/multiselect/issues/82). | ||
- Removed inline styles, CSP compilance [#84](https://github.com/vueform/multiselect/issues/84). | ||
- Background images are now customizable via `background-color` [#85](https://github.com/vueform/multiselect/issues/85). | ||
### 🐞 Bug Fixes | ||
- Free typed tags fix [#96](https://github.com/vueform/multiselect/issues/96). | ||
- Tabindex becomes `-1` when `:disabled`. | ||
## v2.0.1 | ||
@@ -2,0 +18,0 @@ |
@@ -1,1 +0,1 @@ | ||
var VueformMultiselect=function(e,t){"use strict";function a(e){return-1!==[null,void 0,!1].indexOf(e)}function l(e){return(l="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 n(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function r(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,l)}return a}function o(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 a=Object.prototype.toString.call(e).slice(8,-1);"Object"===a&&e.constructor&&(a=e.constructor.name);if("Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))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 a=0,l=new Array(t);a<t;a++)l[a]=e[a];return l}function i(e){return String(e).toLowerCase().trim()}function c(t,r,o){var u=e.toRefs(t),c=u.options,s=u.mode,v=u.trackBy,d=u.limit,p=u.hideSelected,f=u.createTag,m=u.label,h=u.appendNewTag,g=u.multipleLabel,b=u.object,y=u.loading,S=u.delay,k=u.resolveOnLoad,O=u.minChars,w=u.filterResults,V=u.clearOnSearch,N=u.clearOnSelect,B=u.valueProp,L=u.canDeselect,x=u.max,C=o.iv,T=o.ev,q=o.search,P=o.clearSearch,D=o.update,R=o.pointer,j=o.blur,I=e.ref([]),A=e.ref([]),M=e.ref(!1),H=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 a,l=t[e];return n(a={},B.value,e),n(a,v.value,l),n(a,m.value,l),a}))),t=t.map((function(e,t){var a;return"object"===l(e)?e:(n(a={},B.value,e),n(a,v.value,e),n(a,m.value,e),a)})),I.value.length&&(t=t.concat(I.value)),t})),$=e.computed((function(){var e=H.value;return _.value.length&&(e=_.value.concat(e)),q.value&&w.value&&(e=e.filter((function(e){return-1!==i(e[v.value]).indexOf(i(q.value))}))),p.value&&(e=e.filter((function(e){return!ne(e)}))),d.value>0&&(e=e.slice(0,d.value)),e})),F=e.computed((function(){switch(s.value){case"single":return!a(C.value[B.value]);case"multiple":case"tags":return!a(C.value)&&C.value.length>0}})),E=e.computed((function(){return void 0!==g&&void 0!==g.value?g.value(C.value):C.value&&C.value.length>1?"".concat(C.value.length," options selected"):"1 option selected"})),K=e.computed((function(){return!H.value.length&&!M.value})),W=e.computed((function(){return H.value.length>0&&0==$.value.length})),_=e.computed((function(){var e;return!1!==f.value&&q.value?-1!==le(q.value)?[]:[(e={},n(e,B.value,q.value),n(e,m.value,q.value),n(e,v.value,q.value),e)]:[]})),U=e.computed((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),z=e.computed((function(){return y.value||M.value})),G=function(e){switch("object"!==l(e)&&(e=ae(e)),s.value){case"single":D(e);break;case"multiple":case"tags":D(C.value.concat(e))}r.emit("select",Q(e),e)},J=function(e){switch("object"!==l(e)&&(e=ae(e)),s.value){case"single":Y();break;case"tags":case"multiple":D(C.value.filter((function(t){return t[B.value]!=e[B.value]})))}r.emit("deselect",Q(e),e)},Q=function(e){return b.value?e:e[B.value]},X=function(e){J(e)},Y=function(){r.emit("clear"),D(U.value)},Z=function(e){switch(s.value){case"single":return!a(C.value)&&C.value[B.value]==e[B.value];case"tags":case"multiple":return!a(C.value)&&-1!==C.value.map((function(e){return e[B.value]})).indexOf(e[B.value])}},ee=function(e){return!0===e.disabled},te=function(){return!(void 0===x||-1===x.value||!F.value&&x.value>0)&&C.value.length>=x.value},ae=function(e){return H.value[H.value.map((function(e){return String(e[B.value])})).indexOf(String(e))]},le=function(e){return H.value.map((function(e){return i(e[v.value])})).indexOf(i(e))},ne=function(e){return"tags"===s.value&&p.value&&Z(e)},re=function(e){I.value.push(e)},oe=function(){a(T.value)||(C.value=ie(T.value))},ue=function(e){M.value=!0,c.value(q.value).then((function(t){A.value=t,"function"==typeof e&&e(t),M.value=!1}))},ie=function(e){return a(e)?"single"===s.value?{}:[]:b.value?e:"single"===s.value?ae(e)||{}:e.filter((function(e){return!!ae(e)})).map((function(e){return ae(e)}))};if("single"!==s.value&&!a(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?k.value?ue(oe):1==b.value&&oe():(A.value=c.value,oe()),S.value>-1&&e.watch(q,(function(e){e.length<O.value||(M.value=!0,V.value&&(A.value=[]),setTimeout((function(){e==q.value&&c.value(q.value).then((function(t){e==q.value&&(A.value=t,R.value=$.value.filter((function(e){return!0!==e.disabled}))[0]||null,M.value=!1)}))}),S.value))}),{flush:"sync"}),e.watch(T,(function(e){var t,l,n;if(a(e))C.value=ie(e);else switch(s.value){case"single":(b.value?e[B.value]!=C.value[B.value]:e!=C.value[B.value])&&(C.value=ie(e));break;case"multiple":case"tags":t=b.value?e.map((function(e){return e[B.value]})):e,l=C.value.map((function(e){return e[B.value]})),n=l.slice().sort(),t.length===l.length&&t.slice().sort().every((function(e,t){return e===n[t]}))||(C.value=ie(e))}}),{deep:!0}),"function"!=typeof t.options&&e.watch(c,(function(e,a){A.value=t.options,Object.keys(C.value).length||oe(),function(){if(F.value)if("single"===s.value){var e=ae(C.value[B.value])[m.value];C.value[m.value]=e,b.value&&(T.value[m.value]=e)}else C.value.forEach((function(e,t){var a=ae(C.value[t][B.value])[m.value];C.value[t][m.value]=a,b.value&&(T.value[t][m.value]=a)}))}()})),{fo:$,filteredOptions:$,hasSelected:F,multipleLabelText:E,eo:H,extendedOptions:H,noOptions:K,noResults:W,resolving:M,busy:z,select:G,deselect:J,remove:X,clear:Y,isSelected:Z,isDisabled:ee,isMax:te,getOption:ae,handleOptionClick:function(e){if(!ee(e))switch(s.value){case"single":if(Z(e))return void(L.value&&J(e));j(),G(e);break;case"multiple":if(Z(e))return void J(e);if(te())return;G(e),N.value&&P();break;case"tags":if(Z(e))return void J(e);if(te())return;void 0===ae(e[B.value])&&f.value&&(r.emit("tag",e[B.value]),h.value&&re(e),P()),N.value&&P(),G(e)}},handleTagRemove:function(e,t){0===t.button?X(e):t.preventDefault()},refreshOptions:function(e){ue(e)},resolveOptions:ue}}function s(t,a,l){var o=e.toRefs(t),u=o.disabled,i=o.openDirection,c=l.isOpen,s=l.isPointed,v=l.isSelected,d=l.isDisabled,p=l.isActive,f=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?r(Object(a),!0).forEach((function(t){n(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):r(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearch:"multiselect-tags-search",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},o.classes.value);return{classList:e.computed((function(){return{container:[f.container].concat(u.value?f.containerDisabled:[]).concat(c.value&&"top"===i.value?f.containerOpenTop:[]).concat(c.value&&"top"!==i.value?f.containerOpen:[]).concat(p.value?f.containerActive:[]),spacer:f.spacer,singleLabel:f.singleLabel,multipleLabel:f.multipleLabel,search:f.search,tags:f.tags,tag:[f.tag].concat(u.value?f.tagDisabled:[]),tagRemove:f.tagRemove,tagRemoveIcon:f.tagRemoveIcon,tagsSearch:f.tagsSearch,placeholder:f.placeholder,caret:[f.caret].concat(c.value?f.caretOpen:[]),clear:f.clear,clearIcon:f.clearIcon,spinner:f.spinner,dropdown:[f.dropdown].concat("top"===i.value?f.dropdownTop:[]),options:[f.options].concat("top"===i.value?f.optionsTop:[]),option:function(e){var t=[f.option];return s(e)?t.push(v(e)?f.optionSelectedPointed:f.optionPointed):v(e)?t.push(d(e)?f.optionSelectedDisabled:f.optionSelected):d(e)&&t.push(f.optionDisabled),t},noOptions:f.noOptions,noResults:f.noResults,fakeInput:f.fakeInput}}))}}var v={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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:[String,Number],required:!1,default:"10rem"},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})}},setup(t,l){const n=function(t,a){var l=e.toRefs(t),n=l.value,r=l.modelValue,o=l.mode,u=l.valueProp,i=e.ref("single"!==o.value?[]:{}),c=void 0!==a.expose?r:n,s=e.computed((function(){return"single"===o.value?i.value[u.value]:i.value.map((function(e){return e[u.value]}))})),v=e.computed((function(){return"single"!==o.value?i.value.map((function(e){return e[u.value]})).join(","):i.value[u.value]}));return{iv:i,internalValue:i,ev:c,externalValue:c,textValue:v,plainValue:s}}(t,l),r={pointer:e.ref(null)},u=function(t,a,l){var n=e.toRefs(t),r=n.maxHeight,o=n.disabled,u=e.ref(!1),i=e.computed((function(){return"number"==typeof r.value?"".concat(r.value,"px"):r.value}));return{isOpen:u,contentMaxHeight:i,open:function(){u.value||o.value||(u.value=!0,a.emit("open"))},close:function(){u.value&&(u.value=!1,a.emit("close"))}}}(t,l),i=function(t,l,n){var r=e.toRefs(t),o=r.object,u=r.valueProp,i=r.mode,c=n.iv,s=function(e){return o.value||a(e)?e:Array.isArray(e)?e.map((function(e){return e[u.value]})):e[u.value]},v=function(e){return a(e)?"single"===i.value?{}:[]:e};return{update:function(e){c.value=v(e);var t=s(e);l.emit("change",t),l.emit("input",t),l.emit("update:modelValue",t)}}}(t,l,{iv:n.iv}),v=function(t,a,l){var n=e.toRefs(t).mode,r=l.iv,o=e.ref(null),u=e.ref(null),i=e.computed((function(){return o.value?"".concat(c.value,"px"):"tags"===n.value&&-1===[null,void 0].indexOf(r.value)&&r.value.length?"1ch":"100%"})),c=e.computed((function(){var e=document.createElement("span");e.innerHTML=o.value.replace(/ /g," "),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",document.body.append(e);var t=e.offsetWidth;return e.remove(),t}));return e.watch(o,(function(e){a.emit("search-change",e)})),{search:o,input:u,tagsSearchWidth:i,clearSearch:function(){o.value=""},handleSearchInput:function(e){o.value=e.target.value}}}(t,l,{iv:n.iv}),d=function(t,a,l){var n=e.toRefs(t),r=n.searchable,o=n.disabled,u=l.input,i=l.open,c=l.close,s=e.ref(null),v=e.ref(!1),d=e.computed((function(){return r.value?-1:0}));return{multiselect:s,tabindex:d,isActive:v,blur:function(){r.value&&u.value.blur(),s.value.blur()},handleFocus:function(){r.value&&!o.value&&u.value.focus()},activate:function(){o.value||(v.value=!0,i())},deactivate:function(){v.value=!1,c()}}}(t,0,{input:v.input,open:u.open,close:u.close}),p=c(t,l,{ev:n.ev,iv:n.iv,search:v.search,clearSearch:v.clearSearch,update:i.update,pointer:r.pointer,blur:d.blur}),f=function(t,a,l){var n=e.toRefs(t),r=n.valueProp,o=n.showOptions,u=n.searchable,i=l.fo,c=l.handleOptionClick,s=l.search,v=l.pointer,d=l.multiselect,p=e.computed((function(){return i.value.filter((function(e){return!0!==e.disabled}))})),f=function(e){!o.value||null!==e&&e.disabled||(v.value=e)},m=function(){f(p.value[0]||null)},h=function(){f(null)},g=function(){var e=d.value.querySelector("[data-pointed]");if(e){var t=e.parentElement.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(s,(function(e){u.value&&(e.length?m():h())})),{pointer:v,isPointed:function(e){return!!v.value&&v.value[r.value]==e[r.value]},setPointer:f,setPointerFirst:m,clearPointer:h,selectPointer:function(){v.value&&!0!==v.value.disabled&&c(v.value)},forwardPointer:function(){if(null===v.value)f(p.value[0]||null);else{var t=p.value.map((function(e){return e[r.value]})).indexOf(v.value[r.value])+1;p.value.length<=t&&(t=0),f(p.value[t]||null)}e.nextTick((function(){g()}))},backwardPointer:function(){if(null===v.value)f(p.value[p.value.length-1]||null);else{var t=p.value.map((function(e){return e[r.value]})).indexOf(v.value[r.value])-1;t<0&&(t=p.value.length-1),f(p.value[t]||null)}e.nextTick((function(){g()}))}}}(t,0,{fo:p.fo,handleOptionClick:p.handleOptionClick,search:v.search,pointer:r.pointer,multiselect:d.multiselect}),m=function(t,a,l){var n=e.toRefs(t),r=n.mode,u=n.addTagOn,i=n.createTag,c=n.openDirection,s=n.searchable,v=l.iv,d=l.update,p=l.search,f=l.selectPointer,m=l.backwardPointer,h=l.forwardPointer,g=l.blur;return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===r.value)return;if(s.value&&-1===[null,""].indexOf(p.value))return;if(0===v.value.length)return;d(o(v.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===r.value&&-1===u.value.indexOf("enter"))return;f();break;case 27:g();break;case 32:if("tags"!==r.value&&s.value)return;if("tags"===r.value&&-1===u.value.indexOf("space"))return;e.preventDefault(),f();break;case 38:e.preventDefault(),"top"===c.value?h():m();break;case 40:e.preventDefault(),"top"===c.value?m():h();break;case 186:if("tags"!==r.value)return;if(-1===u.value.indexOf(";")||!i.value)return;f(),e.preventDefault();break;case 188:if("tags"!==r.value)return;if(-1===u.value.indexOf(",")||!i.value)return;f(),e.preventDefault()}}}}(t,0,{iv:n.iv,update:i.update,search:v.search,selectPointer:f.selectPointer,backwardPointer:f.backwardPointer,forwardPointer:f.forwardPointer,blur:d.blur}),h=s(t,0,{isOpen:u.isOpen,isPointed:f.isPointed,isSelected:p.isSelected,isDisabled:p.isDisabled,isActive:d.isActive});return{...n,...u,...d,...r,...i,...v,...p,...f,...m,...h}}};return v.render=function(e,a,l,n,r,o){return t.openBlock(),t.createBlock("div",{ref:"multiselect",tabindex:e.tabindex,class:e.classList.container,id:l.id,onFocusin:a[4]||(a[4]=(...t)=>e.activate&&e.activate(...t)),onFocusout:a[5]||(a[5]=(...t)=>e.deactivate&&e.deactivate(...t)),onKeydown:a[6]||(a[6]=(...t)=>e.handleKeydown&&e.handleKeydown(...t)),onFocus:a[7]||(a[7]=(...t)=>e.handleFocus&&e.handleFocus(...t))},[t.createCommentVNode(" Search "),"tags"!==l.mode&&l.searchable&&!l.disabled?(t.openBlock(),t.createBlock("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.search,onInput:a[1]||(a[1]=(...t)=>e.handleSearchInput&&e.handleSearchInput(...t)),ref:"input"},null,42,["modelValue","value"])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Tags (with search) "),"tags"==l.mode?(t.openBlock(),t.createBlock("div",{key:1,class:e.classList.tags},[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.iv,((a,n,r)=>t.renderSlot(e.$slots,"tag",{option:a,handleTagRemove:e.handleTagRemove,disabled:l.disabled},(()=>[(t.openBlock(),t.createBlock("div",{class:e.classList.tag,key:r},[t.createTextVNode(t.toDisplayString(a[l.label])+" ",1),l.disabled?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock("span",{key:0,class:e.classList.tagRemove,onMousedown:t.withModifiers((t=>e.handleTagRemove(a,t)),["prevent"])},[t.createVNode("span",{class:e.classList.tagRemoveIcon},null,2)],42,["onMousedown"]))],2))])))),256)),l.searchable&&!l.disabled?(t.openBlock(),t.createBlock("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.tagsSearch,style:{width:e.tagsSearchWidth},onInput:a[2]||(a[2]=(...t)=>e.handleSearchInput&&e.handleSearchInput(...t)),ref:"input"},null,46,["modelValue","value"])):t.createCommentVNode("v-if",!0)],2)):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Single label "),"single"==l.mode&&e.hasSelected&&!e.search&&e.iv?t.renderSlot(e.$slots,"singlelabel",{key:2,value:e.iv},(()=>[t.createVNode("div",{class:e.classList.singleLabel},t.toDisplayString(e.iv[l.label]),3)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Multiple label "),"multiple"==l.mode&&e.hasSelected&&!e.search?t.renderSlot(e.$slots,"multiplelabel",{key:3,values:e.iv},(()=>[t.createVNode("div",{class:e.classList.multipleLabel},t.toDisplayString(e.multipleLabelText),3)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Placeholder "),!l.placeholder||e.hasSelected||e.search?t.createCommentVNode("v-if",!0):t.renderSlot(e.$slots,"placeholder",{key:4},(()=>[t.createVNode("div",{class:e.classList.placeholder},t.toDisplayString(l.placeholder),3)])),t.createCommentVNode(" Spinner "),e.busy?t.renderSlot(e.$slots,"spinner",{key:5},(()=>[t.createVNode("span",{class:e.classList.spinner},null,2)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Clear "),e.hasSelected&&!l.disabled&&l.canClear&&!e.busy?t.renderSlot(e.$slots,"clear",{key:6,clear:e.clear},(()=>[t.createVNode("span",{class:e.classList.clear,onMousedown:a[3]||(a[3]=(...t)=>e.clear&&e.clear(...t))},[t.createVNode("span",{class:e.classList.clearIcon},null,2)],34)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Caret "),l.caret?t.renderSlot(e.$slots,"caret",{key:7},(()=>[t.createVNode("span",{class:e.classList.caret},null,2)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Options "),e.resolving&&l.clearOnSearch?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(t.Transition,{key:8,name:"multiselect",onAfterLeave:e.clearSearch},{default:t.withCtx((()=>[t.withDirectives(t.createVNode("div",{class:e.classList.dropdown,style:{maxHeight:e.contentMaxHeight}},[t.renderSlot(e.$slots,"beforelist",{options:e.fo}),t.createVNode("ul",{class:e.classList.options},[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.fo,((a,n,r)=>(t.openBlock(),t.createBlock("li",{class:e.classList.option(a),key:r,"data-pointed":e.isPointed(a),onMouseenter:t=>e.setPointer(a),onClick:t=>e.handleOptionClick(a)},[t.renderSlot(e.$slots,"option",{option:a,search:e.search},(()=>[t.createVNode("span",null,t.toDisplayString(a[l.label]),1)]))],42,["data-pointed","onMouseenter","onClick"])))),128))],2),e.noOptions?t.renderSlot(e.$slots,"nooptions",{key:0},(()=>[t.createVNode("div",{class:e.classList.noOptions,innerHTML:l.noOptionsText},null,10,["innerHTML"])])):t.createCommentVNode("v-if",!0),e.noResults?t.renderSlot(e.$slots,"noresults",{key:1},(()=>[t.createVNode("div",{class:e.classList.noResults,innerHTML:l.noResultsText},null,10,["innerHTML"])])):t.createCommentVNode("v-if",!0),t.renderSlot(e.$slots,"afterlist",{options:e.fo})],6),[[t.vShow,e.isOpen&&l.showOptions]])])),_:3},8,["onAfterLeave"])),t.createCommentVNode(" Hacky input element to show HTML5 required warning "),l.required?(t.openBlock(),t.createBlock("input",{key:9,class:e.classList.fakeInput,tabindex:"-1",value:e.textValue,required:""},null,10,["value"])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Native input support "),l.nativeSupport?(t.openBlock(),t.createBlock(t.Fragment,{key:10},["single"==l.mode?(t.openBlock(),t.createBlock("input",{key:0,type:"hidden",name:l.name,value:void 0!==e.plainValue?e.plainValue:""},null,8,["name","value"])):(t.openBlock(!0),t.createBlock(t.Fragment,{key:1},t.renderList(e.plainValue,((e,a)=>(t.openBlock(),t.createBlock("input",{type:"hidden",name:`${l.name}[]`,value:e,key:a},null,8,["name","value"])))),128))],64)):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Create height for empty input "),t.createVNode("div",{class:e.classList.spacer},null,2)],42,["tabindex","id"])},v.__file="src/Multiselect.vue",v}(Vue,Vue); | ||
var VueformMultiselect=function(e,t){"use strict";function u(e){return-1!==[null,void 0,!1].indexOf(e)}function a(e){return(a="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,u){return t in e?Object.defineProperty(e,t,{value:u,enumerable:!0,configurable:!0,writable:!0}):e[t]=u,e}function n(e,t){var u=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),u.push.apply(u,a)}return u}function r(e){return function(e){if(Array.isArray(e))return o(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 o(e,t);var u=Object.prototype.toString.call(e).slice(8,-1);"Object"===u&&e.constructor&&(u=e.constructor.name);if("Map"===u||"Set"===u)return Array.from(e);if("Arguments"===u||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return o(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 o(e,t){(null==t||t>e.length)&&(t=e.length);for(var u=0,a=new Array(t);u<t;u++)a[u]=e[u];return a}function i(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t?String(e).toLowerCase().trim():String(e).normalize("NFD").replace(/(?:[\^`\xA8\xAF\xB4\xB7\xB8\u02B0-\u034E\u0350-\u0357\u035D-\u0362\u0374\u0375\u037A\u0384\u0385\u0483-\u0487\u0559\u0591-\u05A1\u05A3-\u05BD\u05BF\u05C1\u05C2\u05C4\u064B-\u0652\u0657\u0658\u06DF\u06E0\u06E5\u06E6\u06EA-\u06EC\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F5\u0818\u0819\u08E3-\u08FE\u093C\u094D\u0951-\u0954\u0971\u09BC\u09CD\u0A3C\u0A4D\u0ABC\u0ACD\u0AFD-\u0AFF\u0B3C\u0B4D\u0B55\u0BCD\u0C4D\u0CBC\u0CCD\u0D3B\u0D3C\u0D4D\u0DCA\u0E47-\u0E4C\u0E4E\u0EBA\u0EC8-\u0ECC\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F82-\u0F84\u0F86\u0F87\u0FC6\u1037\u1039\u103A\u1063\u1064\u1069-\u106D\u1087-\u108D\u108F\u109A\u109B\u135D-\u135F\u17C9-\u17D3\u17DD\u1939-\u193B\u1A75-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B34\u1B44\u1B6B-\u1B73\u1BAA\u1BAB\u1C36\u1C37\u1C78-\u1C7D\u1CD0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1D2C-\u1D6A\u1DC4-\u1DCF\u1DF5-\u1DF9\u1DFD-\u1DFF\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2CEF-\u2CF1\u2E2F\u302A-\u302F\u3099-\u309C\u30FC\uA66F\uA67C\uA67D\uA67F\uA69C\uA69D\uA6F0\uA6F1\uA700-\uA721\uA788-\uA78A\uA7F8\uA7F9\uA8C4\uA8E0-\uA8F1\uA92B-\uA92E\uA953\uA9B3\uA9C0\uA9E5\uAA7B-\uAA7D\uAABF-\uAAC2\uAAF6\uAB5B-\uAB5F\uAB69-\uAB6B\uABEC\uABED\uFB1E\uFE20-\uFE2F\uFF3E\uFF40\uFF70\uFF9E\uFF9F\uFFE3]|\uD800\uDEE0|\uD802[\uDEE5\uDEE6]|\uD803[\uDD22-\uDD27\uDF46-\uDF50]|\uD804[\uDCB9\uDCBA\uDD33\uDD34\uDD73\uDDC0\uDDCA-\uDDCC\uDE35\uDE36\uDEE9\uDEEA\uDF3C\uDF4D\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC42\uDC46\uDCC2\uDCC3\uDDBF\uDDC0\uDE3F\uDEB6\uDEB7\uDF2B]|\uD806[\uDC39\uDC3A\uDD3D\uDD3E\uDD43\uDDE0\uDE34\uDE47\uDE99]|\uD807[\uDC3F\uDD42\uDD44\uDD45\uDD97]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF8F-\uDF9F\uDFF0\uDFF1]|\uD834[\uDD67-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD]|\uD838[\uDD30-\uDD36\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD46\uDD48-\uDD4A])/g,"").toLowerCase().trim()}function c(t,n,r){var o=e.toRefs(t),c=o.options,s=o.mode,d=o.trackBy,v=o.limit,p=o.hideSelected,f=o.createTag,m=o.label,D=o.appendNewTag,h=o.multipleLabel,g=o.object,b=o.loading,y=o.delay,C=o.resolveOnLoad,F=o.minChars,B=o.filterResults,A=o.clearOnSearch,S=o.clearOnSelect,k=o.valueProp,O=o.canDeselect,E=o.max,w=o.strict,V=r.iv,N=r.ev,L=r.search,P=r.clearSearch,T=r.update,q=r.pointer,x=r.blur,j=e.ref([]),R=e.ref([]),I=e.ref(!1),M=e.computed((function(){var e,t=R.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var u,a=t[e];return l(u={},k.value,e),l(u,d.value,a),l(u,m.value,a),u}))),t=t.map((function(e,t){var u;return"object"===a(e)?e:(l(u={},k.value,e),l(u,d.value,e),l(u,m.value,e),u)})),j.value.length&&(t=t.concat(j.value)),t})),$=e.computed((function(){var e=M.value;return U.value.length&&(e=U.value.concat(e)),L.value&&B.value&&(e=e.filter((function(e){return-1!==i(e[d.value],w.value).indexOf(i(L.value,w.value))}))),p.value&&(e=e.filter((function(e){return!ne(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),H=e.computed((function(){switch(s.value){case"single":return!u(V.value[k.value]);case"multiple":case"tags":return!u(V.value)&&V.value.length>0}})),K=e.computed((function(){return void 0!==h&&void 0!==h.value?h.value(V.value):V.value&&V.value.length>1?"".concat(V.value.length," options selected"):"1 option selected"})),W=e.computed((function(){return!M.value.length&&!I.value})),_=e.computed((function(){return M.value.length>0&&0==$.value.length})),U=e.computed((function(){var e;return!1!==f.value&&L.value?-1!==le(L.value)?[]:[(e={},l(e,k.value,L.value),l(e,m.value,L.value),l(e,d.value,L.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||I.value})),J=function(e){switch("object"!==a(e)&&(e=ae(e)),s.value){case"single":T(e);break;case"multiple":case"tags":T(V.value.concat(e))}n.emit("select",X(e),e)},Q=function(e){switch("object"!==a(e)&&(e=ae(e)),s.value){case"single":Z();break;case"tags":case"multiple":T(V.value.filter((function(t){return t[k.value]!=e[k.value]})))}n.emit("deselect",X(e),e)},X=function(e){return g.value?e:e[k.value]},Y=function(e){Q(e)},Z=function(){n.emit("clear"),T(z.value)},ee=function(e){switch(s.value){case"single":return!u(V.value)&&V.value[k.value]==e[k.value];case"tags":case"multiple":return!u(V.value)&&-1!==V.value.map((function(e){return e[k.value]})).indexOf(e[k.value])}},te=function(e){return!0===e.disabled},ue=function(){return!(void 0===E||-1===E.value||!H.value&&E.value>0)&&V.value.length>=E.value},ae=function(e){return M.value[M.value.map((function(e){return String(e[k.value])})).indexOf(String(e))]},le=function(e){return M.value.map((function(e){return i(e[d.value])})).indexOf(i(e))},ne=function(e){return"tags"===s.value&&p.value&&ee(e)},re=function(e){j.value.push(e)},oe=function(){u(N.value)||(V.value=ce(N.value))},ie=function(e){I.value=!0,c.value(L.value).then((function(t){R.value=t,"function"==typeof e&&e(t),I.value=!1}))},ce=function(e){return u(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&&!u(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?C.value?ie(oe):1==g.value&&oe():(R.value=c.value,oe()),y.value>-1&&e.watch(L,(function(e){e.length<F.value||(I.value=!0,A.value&&(R.value=[]),setTimeout((function(){e==L.value&&c.value(L.value).then((function(t){e==L.value&&(R.value=t,q.value=$.value.filter((function(e){return!0!==e.disabled}))[0]||null,I.value=!1)}))}),y.value))}),{flush:"sync"}),e.watch(N,(function(e){var t,a,l;if(u(e))V.value=ce(e);else switch(s.value){case"single":(g.value?e[k.value]!=V.value[k.value]:e!=V.value[k.value])&&(V.value=ce(e));break;case"multiple":case"tags":t=g.value?e.map((function(e){return e[k.value]})):e,a=V.value.map((function(e){return e[k.value]})),l=a.slice().sort(),t.length===a.length&&t.slice().sort().every((function(e,t){return e===l[t]}))||(V.value=ce(e))}}),{deep:!0}),"function"!=typeof t.options&&e.watch(c,(function(e,u){R.value=t.options,Object.keys(V.value).length||oe(),function(){if(H.value)if("single"===s.value){var e=ae(V.value[k.value])[m.value];V.value[m.value]=e,g.value&&(N.value[m.value]=e)}else V.value.forEach((function(e,t){var u=ae(V.value[t][k.value])[m.value];V.value[t][m.value]=u,g.value&&(N.value[t][m.value]=u)}))}()})),{fo:$,filteredOptions:$,hasSelected:H,multipleLabelText:K,eo:M,extendedOptions:M,noOptions:W,noResults:_,resolving:I,busy:G,select:J,deselect:Q,remove:Y,clear:Z,isSelected:ee,isDisabled:te,isMax:ue,getOption:ae,handleOptionClick:function(e){if(!te(e))switch(s.value){case"single":if(ee(e))return void(O.value&&Q(e));x(),J(e);break;case"multiple":if(ee(e))return void Q(e);if(ue())return;J(e),S.value&&P();break;case"tags":if(ee(e))return void Q(e);if(ue())return;void 0===ae(e[k.value])&&f.value&&(n.emit("tag",e[k.value]),D.value&&re(e),P()),S.value&&P(),J(e)}},handleTagRemove:function(e,t){0===t.button?Y(e):t.preventDefault()},refreshOptions:function(e){ie(e)},resolveOptions:ie}}function s(t,u,a){var r=e.toRefs(t),o=r.disabled,i=r.openDirection,c=r.showOptions,s=a.isOpen,d=a.isPointed,v=a.isSelected,p=a.isDisabled,f=a.isActive,m=function(e){for(var t=1;t<arguments.length;t++){var u=null!=arguments[t]?arguments[t]:{};t%2?n(Object(u),!0).forEach((function(t){l(e,t,u[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(u)):n(Object(u)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(u,t))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearchWrapper:"multiselect-tags-search-wrapper",tagsSearch:"multiselect-tags-search",tagsSearchCopy:"multiselect-tags-search-copy",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",dropdownHidden:"is-hidden",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},r.classes.value);return{classList:e.computed((function(){return{container:[m.container].concat(o.value?m.containerDisabled:[]).concat(s.value&&"top"===i.value&&c.value?m.containerOpenTop:[]).concat(s.value&&"top"!==i.value&&c.value?m.containerOpen:[]).concat(f.value?m.containerActive:[]),spacer:m.spacer,singleLabel:m.singleLabel,multipleLabel:m.multipleLabel,search:m.search,tags:m.tags,tag:[m.tag].concat(o.value?m.tagDisabled:[]),tagRemove:m.tagRemove,tagRemoveIcon:m.tagRemoveIcon,tagsSearchWrapper:m.tagsSearchWrapper,tagsSearch:m.tagsSearch,tagsSearchCopy:m.tagsSearchCopy,placeholder:m.placeholder,caret:[m.caret].concat(s.value?m.caretOpen:[]),clear:m.clear,clearIcon:m.clearIcon,spinner:m.spinner,dropdown:[m.dropdown].concat("top"===i.value?m.dropdownTop:[]).concat(s.value&&c.value?[]:m.dropdownHidden),options:[m.options].concat("top"===i.value?m.optionsTop:[]),option:function(e){var t=[m.option];return d(e)?t.push(v(e)?m.optionSelectedPointed:m.optionPointed):v(e)?t.push(p(e)?m.optionSelectedDisabled:m.optionSelected):p(e)&&t.push(m.optionDisabled),t},noOptions:m.noOptions,noResults:m.noResults,fakeInput:m.fakeInput}}))}}var d={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})},strict:{type:Boolean,required:!1,default:!0}},setup(t,a){const l=function(t,u){var a=e.toRefs(t),l=a.value,n=a.modelValue,r=a.mode,o=a.valueProp,i=e.ref("single"!==r.value?[]:{}),c=void 0!==u.expose?n:l,s=e.computed((function(){return"single"===r.value?i.value[o.value]:i.value.map((function(e){return e[o.value]}))})),d=e.computed((function(){return"single"!==r.value?i.value.map((function(e){return e[o.value]})).join(","):i.value[o.value]}));return{iv:i,internalValue:i,ev:c,externalValue:c,textValue:d,plainValue:s}}(t,a),n={pointer:e.ref(null)},o=function(t,u,a){var l=e.toRefs(t),n=(l.maxHeight,l.disabled),r=e.ref(!1);return{isOpen:r,open:function(){r.value||n.value||(r.value=!0,u.emit("open"))},close:function(){r.value&&(r.value=!1,u.emit("close"))}}}(t,a),i=function(t,u,a){var l=e.ref(null),n=e.ref(null);return e.watch(l,(function(e){u.emit("search-change",e)})),{search:l,input:n,clearSearch:function(){l.value=""},handleSearchInput:function(e){l.value=e.target.value}}}(0,a),d=function(t,a,l){var n=e.toRefs(t),r=n.object,o=n.valueProp,i=n.mode,c=l.iv,s=function(e){return r.value||u(e)?e:Array.isArray(e)?e.map((function(e){return e[o.value]})):e[o.value]},d=function(e){return u(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)}}}(t,a,{iv:l.iv}),v=function(t,u,a){var l=e.toRefs(t),n=l.searchable,r=l.disabled,o=a.input,i=a.open,c=a.close,s=e.ref(null),d=e.ref(!1),v=e.computed((function(){return n.value||r.value?-1:0})),p=function(){n.value&&o.value.blur(),s.value.blur()},f=function(){d.value=!1,c()};return{multiselect:s,tabindex:v,isActive:d,blur:p,handleFocus:function(){n.value&&!r.value&&o.value.focus()},activate:function(){r.value||(d.value=!0,i())},deactivate:f,handleCaretClick:function(){f(),p()}}}(t,0,{input:i.input,open:o.open,close:o.close}),p=c(t,a,{ev:l.ev,iv:l.iv,search:i.search,clearSearch:i.clearSearch,update:d.update,pointer:n.pointer,blur:v.blur}),f=function(t,u,a){var l=e.toRefs(t),n=l.valueProp,r=l.showOptions,o=l.searchable,i=a.fo,c=a.handleOptionClick,s=a.search,d=a.pointer,v=a.multiselect,p=e.computed((function(){return i.value.filter((function(e){return!0!==e.disabled}))})),f=function(e){void 0===e||null!==e&&e.disabled||(d.value=e)},m=function(){f(p.value[0]||null)},D=function(){f(null)},h=function(){var e=v.value.querySelector("[data-pointed]");if(e){var t=e.parentElement.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(s,(function(e){o.value&&(e.length&&r.value?m():D())})),{pointer:d,isPointed:function(e){return!!d.value&&d.value[n.value]==e[n.value]},setPointer:f,setPointerFirst:m,clearPointer:D,selectPointer:function(){d.value&&!0!==d.value.disabled&&c(d.value)},forwardPointer:function(){if(null===d.value)f(p.value[0]||null);else{var t=p.value.map((function(e){return e[n.value]})).indexOf(d.value[n.value])+1;p.value.length<=t&&(t=0),f(p.value[t]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===d.value)f(p.value[p.value.length-1]||null);else{var t=p.value.map((function(e){return e[n.value]})).indexOf(d.value[n.value])-1;t<0&&(t=p.value.length-1),f(p.value[t]||null)}e.nextTick((function(){h()}))}}}(t,0,{fo:p.fo,handleOptionClick:p.handleOptionClick,search:i.search,pointer:n.pointer,multiselect:v.multiselect}),m=function(t,u,a){var l=e.toRefs(t),n=l.mode,o=l.addTagOn,i=l.createTag,c=l.openDirection,s=l.searchable,d=l.showOptions,v=l.valueProp,p=a.iv,f=a.update,m=a.search,D=a.setPointer,h=a.selectPointer,g=a.backwardPointer,b=a.forwardPointer,y=a.blur,C=a.fo,F=function(){"tags"===n.value&&!d.value&&i.value&&s.value&&D(C.value[C.value.map((function(e){return e[v.value]})).indexOf(m.value)]),h()};return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===n.value)return;if(s.value&&-1===[null,""].indexOf(m.value))return;if(0===p.value.length)return;f(r(p.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===n.value&&-1===o.value.indexOf("enter"))return;F();break;case 27:y();break;case 32:if("tags"!==n.value&&s.value)return;if("tags"===n.value&&-1===o.value.indexOf("space"))return;e.preventDefault(),F();break;case 38:if(e.preventDefault(),!d.value)return;"top"===c.value?b():g();break;case 40:if(e.preventDefault(),!d.value)return;"top"===c.value?g():b();break;case 186:if("tags"!==n.value)return;if(-1===o.value.indexOf(";")||!i.value)return;F(),e.preventDefault();break;case 188:if("tags"!==n.value)return;if(-1===o.value.indexOf(",")||!i.value)return;F(),e.preventDefault()}}}}(t,0,{iv:l.iv,update:d.update,search:i.search,setPointer:f.setPointer,selectPointer:f.selectPointer,backwardPointer:f.backwardPointer,forwardPointer:f.forwardPointer,blur:v.blur,fo:p.fo}),D=s(t,0,{isOpen:o.isOpen,isPointed:f.isPointed,isSelected:p.isSelected,isDisabled:p.isDisabled,isActive:v.isActive});return{...l,...o,...v,...n,...d,...i,...p,...f,...m,...D}}};return d.render=function(e,u,a,l,n,r){return t.openBlock(),t.createBlock("div",{ref:"multiselect",tabindex:e.tabindex,class:e.classList.container,id:a.id,onFocusin:u[5]||(u[5]=(...t)=>e.activate&&e.activate(...t)),onFocusout:u[6]||(u[6]=(...t)=>e.deactivate&&e.deactivate(...t)),onKeydown:u[7]||(u[7]=(...t)=>e.handleKeydown&&e.handleKeydown(...t)),onFocus:u[8]||(u[8]=(...t)=>e.handleFocus&&e.handleFocus(...t))},[t.createCommentVNode(" Search "),"tags"!==a.mode&&a.searchable&&!a.disabled?(t.openBlock(),t.createBlock("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.search,onInput:u[1]||(u[1]=(...t)=>e.handleSearchInput&&e.handleSearchInput(...t)),ref:"input"},null,42,["modelValue","value"])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Tags (with search) "),"tags"==a.mode?(t.openBlock(),t.createBlock("div",{key:1,class:e.classList.tags},[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.iv,((u,l,n)=>t.renderSlot(e.$slots,"tag",{option:u,handleTagRemove:e.handleTagRemove,disabled:a.disabled},(()=>[(t.openBlock(),t.createBlock("div",{class:e.classList.tag,key:n},[t.createTextVNode(t.toDisplayString(u[a.label])+" ",1),a.disabled?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock("span",{key:0,class:e.classList.tagRemove,onMousedown:t.withModifiers((t=>e.handleTagRemove(u,t)),["prevent"])},[t.createVNode("span",{class:e.classList.tagRemoveIcon},null,2)],42,["onMousedown"]))],2))])))),256)),t.createVNode("div",{class:e.classList.tagsSearchWrapper},[t.createCommentVNode(" Used for measuring search width "),t.createVNode("span",{class:e.classList.tagsSearchCopy},t.toDisplayString(e.search),3),t.createCommentVNode(" Actual search input "),a.searchable&&!a.disabled?(t.openBlock(),t.createBlock("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.tagsSearch,onInput:u[2]||(u[2]=(...t)=>e.handleSearchInput&&e.handleSearchInput(...t)),ref:"input"},null,42,["modelValue","value"])):t.createCommentVNode("v-if",!0)],2)],2)):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Single label "),"single"==a.mode&&e.hasSelected&&!e.search&&e.iv?t.renderSlot(e.$slots,"singlelabel",{key:2,value:e.iv},(()=>[t.createVNode("div",{class:e.classList.singleLabel},t.toDisplayString(e.iv[a.label]),3)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Multiple label "),"multiple"==a.mode&&e.hasSelected&&!e.search?t.renderSlot(e.$slots,"multiplelabel",{key:3,values:e.iv},(()=>[t.createVNode("div",{class:e.classList.multipleLabel},t.toDisplayString(e.multipleLabelText),3)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Placeholder "),!a.placeholder||e.hasSelected||e.search?t.createCommentVNode("v-if",!0):t.renderSlot(e.$slots,"placeholder",{key:4},(()=>[t.createVNode("div",{class:e.classList.placeholder},t.toDisplayString(a.placeholder),3)])),t.createCommentVNode(" Spinner "),e.busy?t.renderSlot(e.$slots,"spinner",{key:5},(()=>[t.createVNode("span",{class:e.classList.spinner},null,2)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Clear "),e.hasSelected&&!a.disabled&&a.canClear&&!e.busy?t.renderSlot(e.$slots,"clear",{key:6,clear:e.clear},(()=>[t.createVNode("span",{class:e.classList.clear,onMousedown:u[3]||(u[3]=(...t)=>e.clear&&e.clear(...t))},[t.createVNode("span",{class:e.classList.clearIcon},null,2)],34)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Caret "),a.caret?t.renderSlot(e.$slots,"caret",{key:7},(()=>[t.createVNode("span",{class:e.classList.caret,onClick:u[4]||(u[4]=(...t)=>e.handleCaretClick&&e.handleCaretClick(...t))},null,2)])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Options "),e.resolving&&a.clearOnSearch?t.createCommentVNode("v-if",!0):(t.openBlock(),t.createBlock(t.Transition,{key:8,name:"multiselect",onAfterLeave:e.clearSearch},{default:t.withCtx((()=>[t.createVNode("div",{class:e.classList.dropdown},[t.renderSlot(e.$slots,"beforelist",{options:e.fo}),t.createVNode("ul",{class:e.classList.options},[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(e.fo,((u,l,n)=>(t.openBlock(),t.createBlock("li",{class:e.classList.option(u),key:n,"data-pointed":e.isPointed(u),onMouseenter:t=>e.setPointer(u),onClick:t=>e.handleOptionClick(u)},[t.renderSlot(e.$slots,"option",{option:u,search:e.search},(()=>[t.createVNode("span",null,t.toDisplayString(u[a.label]),1)]))],42,["data-pointed","onMouseenter","onClick"])))),128))],2),e.noOptions?t.renderSlot(e.$slots,"nooptions",{key:0},(()=>[t.createVNode("div",{class:e.classList.noOptions,innerHTML:a.noOptionsText},null,10,["innerHTML"])])):t.createCommentVNode("v-if",!0),e.noResults?t.renderSlot(e.$slots,"noresults",{key:1},(()=>[t.createVNode("div",{class:e.classList.noResults,innerHTML:a.noResultsText},null,10,["innerHTML"])])):t.createCommentVNode("v-if",!0),t.renderSlot(e.$slots,"afterlist",{options:e.fo})],2)])),_:3},8,["onAfterLeave"])),t.createCommentVNode(" Hacky input element to show HTML5 required warning "),a.required?(t.openBlock(),t.createBlock("input",{key:9,class:e.classList.fakeInput,tabindex:"-1",value:e.textValue,required:""},null,10,["value"])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Native input support "),a.nativeSupport?(t.openBlock(),t.createBlock(t.Fragment,{key:10},["single"==a.mode?(t.openBlock(),t.createBlock("input",{key:0,type:"hidden",name:a.name,value:void 0!==e.plainValue?e.plainValue:""},null,8,["name","value"])):(t.openBlock(!0),t.createBlock(t.Fragment,{key:1},t.renderList(e.plainValue,((e,u)=>(t.openBlock(),t.createBlock("input",{type:"hidden",name:`${a.name}[]`,value:e,key:u},null,8,["name","value"])))),128))],64)):t.createCommentVNode("v-if",!0),t.createCommentVNode(" Create height for empty input "),t.createVNode("div",{class:e.classList.spacer},null,2)],42,["tabindex","id"])},d.__file="src/Multiselect.vue",d}(Vue,Vue); |
@@ -1,1 +0,1 @@ | ||
import{toRefs as e,ref as t,computed as l,watch as a,nextTick as n,openBlock as u,createBlock as i,createCommentVNode as r,Fragment as o,renderList as s,renderSlot as c,createTextVNode as v,toDisplayString as p,withModifiers as d,createVNode as f,Transition as m,withCtx as h,withDirectives as b,vShow as g}from"vue";function y(e){return-1!==[null,void 0,!1].indexOf(e)}function O(e){return String(e).toLowerCase().trim()}function S(e){return(S="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 k(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function w(n,u,i){var r=e(n),o=r.options,s=r.mode,c=r.trackBy,v=r.limit,p=r.hideSelected,d=r.createTag,f=r.label,m=r.appendNewTag,h=r.multipleLabel,b=r.object,g=r.loading,w=r.delay,L=r.resolveOnLoad,q=r.minChars,x=r.filterResults,P=r.clearOnSearch,T=r.clearOnSelect,j=r.valueProp,D=r.canDeselect,I=r.max,R=i.iv,A=i.ev,B=i.search,M=i.clearSearch,C=i.update,H=i.pointer,V=i.blur,$=t([]),N=t([]),F=t(!1),E=l((function(){var e,t=N.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var l,a=t[e];return k(l={},j.value,e),k(l,c.value,a),k(l,f.value,a),l}))),t=t.map((function(e,t){var l;return"object"===S(e)?e:(k(l={},j.value,e),k(l,c.value,e),k(l,f.value,e),l)})),$.value.length&&(t=t.concat($.value)),t})),K=l((function(){var e=E.value;return G.value.length&&(e=G.value.concat(e)),B.value&&x.value&&(e=e.filter((function(e){return-1!==O(e[c.value]).indexOf(O(B.value))}))),p.value&&(e=e.filter((function(e){return!re(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),W=l((function(){switch(s.value){case"single":return!y(R.value[j.value]);case"multiple":case"tags":return!y(R.value)&&R.value.length>0}})),_=l((function(){return void 0!==h&&void 0!==h.value?h.value(R.value):R.value&&R.value.length>1?"".concat(R.value.length," options selected"):"1 option selected"})),U=l((function(){return!E.value.length&&!F.value})),z=l((function(){return E.value.length>0&&0==K.value.length})),G=l((function(){var e;return!1!==d.value&&B.value?-1!==ie(B.value)?[]:[(e={},k(e,j.value,B.value),k(e,f.value,B.value),k(e,c.value,B.value),e)]:[]})),J=l((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),Q=l((function(){return g.value||F.value})),X=function(e){switch("object"!==S(e)&&(e=ue(e)),s.value){case"single":C(e);break;case"multiple":case"tags":C(R.value.concat(e))}u.emit("select",Z(e),e)},Y=function(e){switch("object"!==S(e)&&(e=ue(e)),s.value){case"single":te();break;case"tags":case"multiple":C(R.value.filter((function(t){return t[j.value]!=e[j.value]})))}u.emit("deselect",Z(e),e)},Z=function(e){return b.value?e:e[j.value]},ee=function(e){Y(e)},te=function(){u.emit("clear"),C(J.value)},le=function(e){switch(s.value){case"single":return!y(R.value)&&R.value[j.value]==e[j.value];case"tags":case"multiple":return!y(R.value)&&-1!==R.value.map((function(e){return e[j.value]})).indexOf(e[j.value])}},ae=function(e){return!0===e.disabled},ne=function(){return!(void 0===I||-1===I.value||!W.value&&I.value>0)&&R.value.length>=I.value},ue=function(e){return E.value[E.value.map((function(e){return String(e[j.value])})).indexOf(String(e))]},ie=function(e){return E.value.map((function(e){return O(e[c.value])})).indexOf(O(e))},re=function(e){return"tags"===s.value&&p.value&&le(e)},oe=function(e){$.value.push(e)},se=function(){y(A.value)||(R.value=ve(A.value))},ce=function(e){F.value=!0,o.value(B.value).then((function(t){N.value=t,"function"==typeof e&&e(t),F.value=!1}))},ve=function(e){return y(e)?"single"===s.value?{}:[]:b.value?e:"single"===s.value?ue(e)||{}:e.filter((function(e){return!!ue(e)})).map((function(e){return ue(e)}))};if("single"!==s.value&&!y(A.value)&&!Array.isArray(A.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return o&&"function"==typeof o.value?L.value?ce(se):1==b.value&&se():(N.value=o.value,se()),w.value>-1&&a(B,(function(e){e.length<q.value||(F.value=!0,P.value&&(N.value=[]),setTimeout((function(){e==B.value&&o.value(B.value).then((function(t){e==B.value&&(N.value=t,H.value=K.value.filter((function(e){return!0!==e.disabled}))[0]||null,F.value=!1)}))}),w.value))}),{flush:"sync"}),a(A,(function(e){var t,l,a;if(y(e))R.value=ve(e);else switch(s.value){case"single":(b.value?e[j.value]!=R.value[j.value]:e!=R.value[j.value])&&(R.value=ve(e));break;case"multiple":case"tags":t=b.value?e.map((function(e){return e[j.value]})):e,l=R.value.map((function(e){return e[j.value]})),a=l.slice().sort(),t.length===l.length&&t.slice().sort().every((function(e,t){return e===a[t]}))||(R.value=ve(e))}}),{deep:!0}),"function"!=typeof n.options&&a(o,(function(e,t){N.value=n.options,Object.keys(R.value).length||se(),function(){if(W.value)if("single"===s.value){var e=ue(R.value[j.value])[f.value];R.value[f.value]=e,b.value&&(A.value[f.value]=e)}else R.value.forEach((function(e,t){var l=ue(R.value[t][j.value])[f.value];R.value[t][f.value]=l,b.value&&(A.value[t][f.value]=l)}))}()})),{fo:K,filteredOptions:K,hasSelected:W,multipleLabelText:_,eo:E,extendedOptions:E,noOptions:U,noResults:z,resolving:F,busy:Q,select:X,deselect:Y,remove:ee,clear:te,isSelected:le,isDisabled:ae,isMax:ne,getOption:ue,handleOptionClick:function(e){if(!ae(e))switch(s.value){case"single":if(le(e))return void(D.value&&Y(e));V(),X(e);break;case"multiple":if(le(e))return void Y(e);if(ne())return;X(e),T.value&&M();break;case"tags":if(le(e))return void Y(e);if(ne())return;void 0===ue(e[j.value])&&d.value&&(u.emit("tag",e[j.value]),m.value&&oe(e),M()),T.value&&M(),X(e)}},handleTagRemove:function(e,t){0===t.button?ee(e):t.preventDefault()},refreshOptions:function(e){ce(e)},resolveOptions:ce}}function L(e){return function(e){if(Array.isArray(e))return q(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 q(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 q(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 q(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,a=new Array(t);l<t;l++)a[l]=e[l];return a}function x(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),l.push.apply(l,a)}return l}function P(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function T(t,a,n){var u=e(t),i=u.disabled,r=u.openDirection,o=n.isOpen,s=n.isPointed,c=n.isSelected,v=n.isDisabled,p=n.isActive,d=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?x(Object(l),!0).forEach((function(t){P(e,t,l[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):x(Object(l)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearch:"multiselect-tags-search",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},u.classes.value);return{classList:l((function(){return{container:[d.container].concat(i.value?d.containerDisabled:[]).concat(o.value&&"top"===r.value?d.containerOpenTop:[]).concat(o.value&&"top"!==r.value?d.containerOpen:[]).concat(p.value?d.containerActive:[]),spacer:d.spacer,singleLabel:d.singleLabel,multipleLabel:d.multipleLabel,search:d.search,tags:d.tags,tag:[d.tag].concat(i.value?d.tagDisabled:[]),tagRemove:d.tagRemove,tagRemoveIcon:d.tagRemoveIcon,tagsSearch:d.tagsSearch,placeholder:d.placeholder,caret:[d.caret].concat(o.value?d.caretOpen:[]),clear:d.clear,clearIcon:d.clearIcon,spinner:d.spinner,dropdown:[d.dropdown].concat("top"===r.value?d.dropdownTop:[]),options:[d.options].concat("top"===r.value?d.optionsTop:[]),option:function(e){var t=[d.option];return s(e)?t.push(c(e)?d.optionSelectedPointed:d.optionPointed):c(e)?t.push(v(e)?d.optionSelectedDisabled:d.optionSelected):v(e)&&t.push(d.optionDisabled),t},noOptions:d.noOptions,noResults:d.noResults,fakeInput:d.fakeInput}}))}}var j={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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:[String,Number],required:!1,default:"10rem"},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})}},setup(u,i){const r=function(a,n){var u=e(a),i=u.value,r=u.modelValue,o=u.mode,s=u.valueProp,c=t("single"!==o.value?[]:{}),v=void 0!==n.expose?r:i,p=l((function(){return"single"===o.value?c.value[s.value]:c.value.map((function(e){return e[s.value]}))})),d=l((function(){return"single"!==o.value?c.value.map((function(e){return e[s.value]})).join(","):c.value[s.value]}));return{iv:c,internalValue:c,ev:v,externalValue:v,textValue:d,plainValue:p}}(u,i),o={pointer:t(null)},s=function(a,n,u){var i=e(a),r=i.maxHeight,o=i.disabled,s=t(!1),c=l((function(){return"number"==typeof r.value?"".concat(r.value,"px"):r.value}));return{isOpen:s,contentMaxHeight:c,open:function(){s.value||o.value||(s.value=!0,n.emit("open"))},close:function(){s.value&&(s.value=!1,n.emit("close"))}}}(u,i),c=function(t,l,a){var n=e(t),u=n.object,i=n.valueProp,r=n.mode,o=a.iv,s=function(e){return u.value||y(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},c=function(e){return y(e)?"single"===r.value?{}:[]:e};return{update:function(e){o.value=c(e);var t=s(e);l.emit("change",t),l.emit("input",t),l.emit("update:modelValue",t)}}}(u,i,{iv:r.iv}),v=function(n,u,i){var r=e(n).mode,o=i.iv,s=t(null),c=t(null),v=l((function(){return s.value?"".concat(p.value,"px"):"tags"===r.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"})),p=l((function(){var e=document.createElement("span");e.innerHTML=s.value.replace(/ /g," "),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",document.body.append(e);var t=e.offsetWidth;return e.remove(),t}));return a(s,(function(e){u.emit("search-change",e)})),{search:s,input:c,tagsSearchWidth:v,clearSearch:function(){s.value=""},handleSearchInput:function(e){s.value=e.target.value}}}(u,i,{iv:r.iv}),p=function(a,n,u){var i=e(a),r=i.searchable,o=i.disabled,s=u.input,c=u.open,v=u.close,p=t(null),d=t(!1),f=l((function(){return r.value?-1:0}));return{multiselect:p,tabindex:f,isActive:d,blur:function(){r.value&&s.value.blur(),p.value.blur()},handleFocus:function(){r.value&&!o.value&&s.value.focus()},activate:function(){o.value||(d.value=!0,c())},deactivate:function(){d.value=!1,v()}}}(u,0,{input:v.input,open:s.open,close:s.close}),d=w(u,i,{ev:r.ev,iv:r.iv,search:v.search,clearSearch:v.clearSearch,update:c.update,pointer:o.pointer,blur:p.blur}),f=function(t,u,i){var r=e(t),o=r.valueProp,s=r.showOptions,c=r.searchable,v=i.fo,p=i.handleOptionClick,d=i.search,f=i.pointer,m=i.multiselect,h=l((function(){return v.value.filter((function(e){return!0!==e.disabled}))})),b=function(e){!s.value||null!==e&&e.disabled||(f.value=e)},g=function(){b(h.value[0]||null)},y=function(){b(null)},O=function(){var e=m.value.querySelector("[data-pointed]");if(e){var t=e.parentElement.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(d,(function(e){c.value&&(e.length?g():y())})),{pointer:f,isPointed:function(e){return!!f.value&&f.value[o.value]==e[o.value]},setPointer:b,setPointerFirst:g,clearPointer:y,selectPointer:function(){f.value&&!0!==f.value.disabled&&p(f.value)},forwardPointer:function(){if(null===f.value)b(h.value[0]||null);else{var e=h.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])+1;h.value.length<=e&&(e=0),b(h.value[e]||null)}n((function(){O()}))},backwardPointer:function(){if(null===f.value)b(h.value[h.value.length-1]||null);else{var e=h.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])-1;e<0&&(e=h.value.length-1),b(h.value[e]||null)}n((function(){O()}))}}}(u,0,{fo:d.fo,handleOptionClick:d.handleOptionClick,search:v.search,pointer:o.pointer,multiselect:p.multiselect}),m=function(t,l,a){var n=e(t),u=n.mode,i=n.addTagOn,r=n.createTag,o=n.openDirection,s=n.searchable,c=a.iv,v=a.update,p=a.search,d=a.selectPointer,f=a.backwardPointer,m=a.forwardPointer,h=a.blur;return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===u.value)return;if(s.value&&-1===[null,""].indexOf(p.value))return;if(0===c.value.length)return;v(L(c.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===u.value&&-1===i.value.indexOf("enter"))return;d();break;case 27:h();break;case 32:if("tags"!==u.value&&s.value)return;if("tags"===u.value&&-1===i.value.indexOf("space"))return;e.preventDefault(),d();break;case 38:e.preventDefault(),"top"===o.value?m():f();break;case 40:e.preventDefault(),"top"===o.value?f():m();break;case 186:if("tags"!==u.value)return;if(-1===i.value.indexOf(";")||!r.value)return;d(),e.preventDefault();break;case 188:if("tags"!==u.value)return;if(-1===i.value.indexOf(",")||!r.value)return;d(),e.preventDefault()}}}}(u,0,{iv:r.iv,update:c.update,search:v.search,selectPointer:f.selectPointer,backwardPointer:f.backwardPointer,forwardPointer:f.forwardPointer,blur:p.blur}),h=T(u,0,{isOpen:s.isOpen,isPointed:f.isPointed,isSelected:d.isSelected,isDisabled:d.isDisabled,isActive:p.isActive});return{...r,...s,...p,...o,...c,...v,...d,...f,...m,...h}}};j.render=function(e,t,l,a,n,y){return u(),i("div",{ref:"multiselect",tabindex:e.tabindex,class:e.classList.container,id:l.id,onFocusin:t[4]||(t[4]=(...t)=>e.activate&&e.activate(...t)),onFocusout:t[5]||(t[5]=(...t)=>e.deactivate&&e.deactivate(...t)),onKeydown:t[6]||(t[6]=(...t)=>e.handleKeydown&&e.handleKeydown(...t)),onFocus:t[7]||(t[7]=(...t)=>e.handleFocus&&e.handleFocus(...t))},[r(" Search "),"tags"!==l.mode&&l.searchable&&!l.disabled?(u(),i("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.search,onInput:t[1]||(t[1]=(...t)=>e.handleSearchInput&&e.handleSearchInput(...t)),ref:"input"},null,42,["modelValue","value"])):r("v-if",!0),r(" Tags (with search) "),"tags"==l.mode?(u(),i("div",{key:1,class:e.classList.tags},[(u(!0),i(o,null,s(e.iv,((t,a,n)=>c(e.$slots,"tag",{option:t,handleTagRemove:e.handleTagRemove,disabled:l.disabled},(()=>[(u(),i("div",{class:e.classList.tag,key:n},[v(p(t[l.label])+" ",1),l.disabled?r("v-if",!0):(u(),i("span",{key:0,class:e.classList.tagRemove,onMousedown:d((l=>e.handleTagRemove(t,l)),["prevent"])},[f("span",{class:e.classList.tagRemoveIcon},null,2)],42,["onMousedown"]))],2))])))),256)),l.searchable&&!l.disabled?(u(),i("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.tagsSearch,style:{width:e.tagsSearchWidth},onInput:t[2]||(t[2]=(...t)=>e.handleSearchInput&&e.handleSearchInput(...t)),ref:"input"},null,46,["modelValue","value"])):r("v-if",!0)],2)):r("v-if",!0),r(" Single label "),"single"==l.mode&&e.hasSelected&&!e.search&&e.iv?c(e.$slots,"singlelabel",{key:2,value:e.iv},(()=>[f("div",{class:e.classList.singleLabel},p(e.iv[l.label]),3)])):r("v-if",!0),r(" Multiple label "),"multiple"==l.mode&&e.hasSelected&&!e.search?c(e.$slots,"multiplelabel",{key:3,values:e.iv},(()=>[f("div",{class:e.classList.multipleLabel},p(e.multipleLabelText),3)])):r("v-if",!0),r(" Placeholder "),!l.placeholder||e.hasSelected||e.search?r("v-if",!0):c(e.$slots,"placeholder",{key:4},(()=>[f("div",{class:e.classList.placeholder},p(l.placeholder),3)])),r(" Spinner "),e.busy?c(e.$slots,"spinner",{key:5},(()=>[f("span",{class:e.classList.spinner},null,2)])):r("v-if",!0),r(" Clear "),e.hasSelected&&!l.disabled&&l.canClear&&!e.busy?c(e.$slots,"clear",{key:6,clear:e.clear},(()=>[f("span",{class:e.classList.clear,onMousedown:t[3]||(t[3]=(...t)=>e.clear&&e.clear(...t))},[f("span",{class:e.classList.clearIcon},null,2)],34)])):r("v-if",!0),r(" Caret "),l.caret?c(e.$slots,"caret",{key:7},(()=>[f("span",{class:e.classList.caret},null,2)])):r("v-if",!0),r(" Options "),e.resolving&&l.clearOnSearch?r("v-if",!0):(u(),i(m,{key:8,name:"multiselect",onAfterLeave:e.clearSearch},{default:h((()=>[b(f("div",{class:e.classList.dropdown,style:{maxHeight:e.contentMaxHeight}},[c(e.$slots,"beforelist",{options:e.fo}),f("ul",{class:e.classList.options},[(u(!0),i(o,null,s(e.fo,((t,a,n)=>(u(),i("li",{class:e.classList.option(t),key:n,"data-pointed":e.isPointed(t),onMouseenter:l=>e.setPointer(t),onClick:l=>e.handleOptionClick(t)},[c(e.$slots,"option",{option:t,search:e.search},(()=>[f("span",null,p(t[l.label]),1)]))],42,["data-pointed","onMouseenter","onClick"])))),128))],2),e.noOptions?c(e.$slots,"nooptions",{key:0},(()=>[f("div",{class:e.classList.noOptions,innerHTML:l.noOptionsText},null,10,["innerHTML"])])):r("v-if",!0),e.noResults?c(e.$slots,"noresults",{key:1},(()=>[f("div",{class:e.classList.noResults,innerHTML:l.noResultsText},null,10,["innerHTML"])])):r("v-if",!0),c(e.$slots,"afterlist",{options:e.fo})],6),[[g,e.isOpen&&l.showOptions]])])),_:3},8,["onAfterLeave"])),r(" Hacky input element to show HTML5 required warning "),l.required?(u(),i("input",{key:9,class:e.classList.fakeInput,tabindex:"-1",value:e.textValue,required:""},null,10,["value"])):r("v-if",!0),r(" Native input support "),l.nativeSupport?(u(),i(o,{key:10},["single"==l.mode?(u(),i("input",{key:0,type:"hidden",name:l.name,value:void 0!==e.plainValue?e.plainValue:""},null,8,["name","value"])):(u(!0),i(o,{key:1},s(e.plainValue,((e,t)=>(u(),i("input",{type:"hidden",name:`${l.name}[]`,value:e,key:t},null,8,["name","value"])))),128))],64)):r("v-if",!0),r(" Create height for empty input "),f("div",{class:e.classList.spacer},null,2)],42,["tabindex","id"])},j.__file="src/Multiselect.vue";export default j; | ||
import{toRefs as e,ref as u,computed as t,watch as a,nextTick as l,openBlock as n,createBlock as r,createCommentVNode as i,Fragment as o,renderList as s,renderSlot as c,createTextVNode as v,toDisplayString as p,withModifiers as d,createVNode as f,Transition as D,withCtx as h}from"vue";function m(e){return-1!==[null,void 0,!1].indexOf(e)}function g(e){var u=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return u?String(e).toLowerCase().trim():String(e).normalize("NFD").replace(/(?:[\^`\xA8\xAF\xB4\xB7\xB8\u02B0-\u034E\u0350-\u0357\u035D-\u0362\u0374\u0375\u037A\u0384\u0385\u0483-\u0487\u0559\u0591-\u05A1\u05A3-\u05BD\u05BF\u05C1\u05C2\u05C4\u064B-\u0652\u0657\u0658\u06DF\u06E0\u06E5\u06E6\u06EA-\u06EC\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F5\u0818\u0819\u08E3-\u08FE\u093C\u094D\u0951-\u0954\u0971\u09BC\u09CD\u0A3C\u0A4D\u0ABC\u0ACD\u0AFD-\u0AFF\u0B3C\u0B4D\u0B55\u0BCD\u0C4D\u0CBC\u0CCD\u0D3B\u0D3C\u0D4D\u0DCA\u0E47-\u0E4C\u0E4E\u0EBA\u0EC8-\u0ECC\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F82-\u0F84\u0F86\u0F87\u0FC6\u1037\u1039\u103A\u1063\u1064\u1069-\u106D\u1087-\u108D\u108F\u109A\u109B\u135D-\u135F\u17C9-\u17D3\u17DD\u1939-\u193B\u1A75-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B34\u1B44\u1B6B-\u1B73\u1BAA\u1BAB\u1C36\u1C37\u1C78-\u1C7D\u1CD0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1D2C-\u1D6A\u1DC4-\u1DCF\u1DF5-\u1DF9\u1DFD-\u1DFF\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2CEF-\u2CF1\u2E2F\u302A-\u302F\u3099-\u309C\u30FC\uA66F\uA67C\uA67D\uA67F\uA69C\uA69D\uA6F0\uA6F1\uA700-\uA721\uA788-\uA78A\uA7F8\uA7F9\uA8C4\uA8E0-\uA8F1\uA92B-\uA92E\uA953\uA9B3\uA9C0\uA9E5\uAA7B-\uAA7D\uAABF-\uAAC2\uAAF6\uAB5B-\uAB5F\uAB69-\uAB6B\uABEC\uABED\uFB1E\uFE20-\uFE2F\uFF3E\uFF40\uFF70\uFF9E\uFF9F\uFFE3]|\uD800\uDEE0|\uD802[\uDEE5\uDEE6]|\uD803[\uDD22-\uDD27\uDF46-\uDF50]|\uD804[\uDCB9\uDCBA\uDD33\uDD34\uDD73\uDDC0\uDDCA-\uDDCC\uDE35\uDE36\uDEE9\uDEEA\uDF3C\uDF4D\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC42\uDC46\uDCC2\uDCC3\uDDBF\uDDC0\uDE3F\uDEB6\uDEB7\uDF2B]|\uD806[\uDC39\uDC3A\uDD3D\uDD3E\uDD43\uDDE0\uDE34\uDE47\uDE99]|\uD807[\uDC3F\uDD42\uDD44\uDD45\uDD97]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF8F-\uDF9F\uDFF0\uDFF1]|\uD834[\uDD67-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD]|\uD838[\uDD30-\uDD36\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD46\uDD48-\uDD4A])/g,"").toLowerCase().trim()}function b(e){return(b="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 y(e,u,t){return u in e?Object.defineProperty(e,u,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[u]=t,e}function F(l,n,r){var i=e(l),o=i.options,s=i.mode,c=i.trackBy,v=i.limit,p=i.hideSelected,d=i.createTag,f=i.label,D=i.appendNewTag,h=i.multipleLabel,F=i.object,C=i.loading,A=i.delay,O=i.resolveOnLoad,S=i.minChars,B=i.filterResults,E=i.clearOnSearch,k=i.clearOnSelect,w=i.valueProp,L=i.canDeselect,P=i.max,q=i.strict,T=r.iv,x=r.ev,j=r.search,I=r.clearSearch,R=r.update,V=r.pointer,M=r.blur,$=u([]),H=u([]),N=u(!1),K=t((function(){var e,u=H.value||[];return e=u,"[object Object]"===Object.prototype.toString.call(e)&&(u=Object.keys(u).map((function(e){var t,a=u[e];return y(t={},w.value,e),y(t,c.value,a),y(t,f.value,a),t}))),u=u.map((function(e,u){var t;return"object"===b(e)?e:(y(t={},w.value,e),y(t,c.value,e),y(t,f.value,e),t)})),$.value.length&&(u=u.concat($.value)),u})),W=t((function(){var e=K.value;return J.value.length&&(e=J.value.concat(e)),j.value&&B.value&&(e=e.filter((function(e){return-1!==g(e[c.value],q.value).indexOf(g(j.value,q.value))}))),p.value&&(e=e.filter((function(e){return!oe(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),_=t((function(){switch(s.value){case"single":return!m(T.value[w.value]);case"multiple":case"tags":return!m(T.value)&&T.value.length>0}})),U=t((function(){return void 0!==h&&void 0!==h.value?h.value(T.value):T.value&&T.value.length>1?"".concat(T.value.length," options selected"):"1 option selected"})),z=t((function(){return!K.value.length&&!N.value})),G=t((function(){return K.value.length>0&&0==W.value.length})),J=t((function(){var e;return!1!==d.value&&j.value?-1!==ie(j.value)?[]:[(e={},y(e,w.value,j.value),y(e,f.value,j.value),y(e,c.value,j.value),e)]:[]})),Q=t((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),X=t((function(){return C.value||N.value})),Y=function(e){switch("object"!==b(e)&&(e=re(e)),s.value){case"single":R(e);break;case"multiple":case"tags":R(T.value.concat(e))}n.emit("select",ee(e),e)},Z=function(e){switch("object"!==b(e)&&(e=re(e)),s.value){case"single":te();break;case"tags":case"multiple":R(T.value.filter((function(u){return u[w.value]!=e[w.value]})))}n.emit("deselect",ee(e),e)},ee=function(e){return F.value?e:e[w.value]},ue=function(e){Z(e)},te=function(){n.emit("clear"),R(Q.value)},ae=function(e){switch(s.value){case"single":return!m(T.value)&&T.value[w.value]==e[w.value];case"tags":case"multiple":return!m(T.value)&&-1!==T.value.map((function(e){return e[w.value]})).indexOf(e[w.value])}},le=function(e){return!0===e.disabled},ne=function(){return!(void 0===P||-1===P.value||!_.value&&P.value>0)&&T.value.length>=P.value},re=function(e){return K.value[K.value.map((function(e){return String(e[w.value])})).indexOf(String(e))]},ie=function(e){return K.value.map((function(e){return g(e[c.value])})).indexOf(g(e))},oe=function(e){return"tags"===s.value&&p.value&&ae(e)},se=function(e){$.value.push(e)},ce=function(){m(x.value)||(T.value=pe(x.value))},ve=function(e){N.value=!0,o.value(j.value).then((function(u){H.value=u,"function"==typeof e&&e(u),N.value=!1}))},pe=function(e){return m(e)?"single"===s.value?{}:[]:F.value?e:"single"===s.value?re(e)||{}:e.filter((function(e){return!!re(e)})).map((function(e){return re(e)}))};if("single"!==s.value&&!m(x.value)&&!Array.isArray(x.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return o&&"function"==typeof o.value?O.value?ve(ce):1==F.value&&ce():(H.value=o.value,ce()),A.value>-1&&a(j,(function(e){e.length<S.value||(N.value=!0,E.value&&(H.value=[]),setTimeout((function(){e==j.value&&o.value(j.value).then((function(u){e==j.value&&(H.value=u,V.value=W.value.filter((function(e){return!0!==e.disabled}))[0]||null,N.value=!1)}))}),A.value))}),{flush:"sync"}),a(x,(function(e){var u,t,a;if(m(e))T.value=pe(e);else switch(s.value){case"single":(F.value?e[w.value]!=T.value[w.value]:e!=T.value[w.value])&&(T.value=pe(e));break;case"multiple":case"tags":u=F.value?e.map((function(e){return e[w.value]})):e,t=T.value.map((function(e){return e[w.value]})),a=t.slice().sort(),u.length===t.length&&u.slice().sort().every((function(e,u){return e===a[u]}))||(T.value=pe(e))}}),{deep:!0}),"function"!=typeof l.options&&a(o,(function(e,u){H.value=l.options,Object.keys(T.value).length||ce(),function(){if(_.value)if("single"===s.value){var e=re(T.value[w.value])[f.value];T.value[f.value]=e,F.value&&(x.value[f.value]=e)}else T.value.forEach((function(e,u){var t=re(T.value[u][w.value])[f.value];T.value[u][f.value]=t,F.value&&(x.value[u][f.value]=t)}))}()})),{fo:W,filteredOptions:W,hasSelected:_,multipleLabelText:U,eo:K,extendedOptions:K,noOptions:z,noResults:G,resolving:N,busy:X,select:Y,deselect:Z,remove:ue,clear:te,isSelected:ae,isDisabled:le,isMax:ne,getOption:re,handleOptionClick:function(e){if(!le(e))switch(s.value){case"single":if(ae(e))return void(L.value&&Z(e));M(),Y(e);break;case"multiple":if(ae(e))return void Z(e);if(ne())return;Y(e),k.value&&I();break;case"tags":if(ae(e))return void Z(e);if(ne())return;void 0===re(e[w.value])&&d.value&&(n.emit("tag",e[w.value]),D.value&&se(e),I()),k.value&&I(),Y(e)}},handleTagRemove:function(e,u){0===u.button?ue(e):u.preventDefault()},refreshOptions:function(e){ve(e)},resolveOptions:ve}}function C(e){return function(e){if(Array.isArray(e))return A(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,u){if(!e)return;if("string"==typeof e)return A(e,u);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 A(e,u)}(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 A(e,u){(null==u||u>e.length)&&(u=e.length);for(var t=0,a=new Array(u);t<u;t++)a[t]=e[t];return a}function O(e,u){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);u&&(a=a.filter((function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable}))),t.push.apply(t,a)}return t}function S(e,u,t){return u in e?Object.defineProperty(e,u,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[u]=t,e}function B(u,a,l){var n=e(u),r=n.disabled,i=n.openDirection,o=n.showOptions,s=l.isOpen,c=l.isPointed,v=l.isSelected,p=l.isDisabled,d=l.isActive,f=function(e){for(var u=1;u<arguments.length;u++){var t=null!=arguments[u]?arguments[u]:{};u%2?O(Object(t),!0).forEach((function(u){S(e,u,t[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(u){Object.defineProperty(e,u,Object.getOwnPropertyDescriptor(t,u))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearchWrapper:"multiselect-tags-search-wrapper",tagsSearch:"multiselect-tags-search",tagsSearchCopy:"multiselect-tags-search-copy",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",dropdownHidden:"is-hidden",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},n.classes.value);return{classList:t((function(){return{container:[f.container].concat(r.value?f.containerDisabled:[]).concat(s.value&&"top"===i.value&&o.value?f.containerOpenTop:[]).concat(s.value&&"top"!==i.value&&o.value?f.containerOpen:[]).concat(d.value?f.containerActive:[]),spacer:f.spacer,singleLabel:f.singleLabel,multipleLabel:f.multipleLabel,search:f.search,tags:f.tags,tag:[f.tag].concat(r.value?f.tagDisabled:[]),tagRemove:f.tagRemove,tagRemoveIcon:f.tagRemoveIcon,tagsSearchWrapper:f.tagsSearchWrapper,tagsSearch:f.tagsSearch,tagsSearchCopy:f.tagsSearchCopy,placeholder:f.placeholder,caret:[f.caret].concat(s.value?f.caretOpen:[]),clear:f.clear,clearIcon:f.clearIcon,spinner:f.spinner,dropdown:[f.dropdown].concat("top"===i.value?f.dropdownTop:[]).concat(s.value&&o.value?[]:f.dropdownHidden),options:[f.options].concat("top"===i.value?f.optionsTop:[]),option:function(e){var u=[f.option];return c(e)?u.push(v(e)?f.optionSelectedPointed:f.optionPointed):v(e)?u.push(p(e)?f.optionSelectedDisabled:f.optionSelected):p(e)&&u.push(f.optionDisabled),u},noOptions:f.noOptions,noResults:f.noResults,fakeInput:f.fakeInput}}))}}var E={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})},strict:{type:Boolean,required:!1,default:!0}},setup(n,r){const i=function(a,l){var n=e(a),r=n.value,i=n.modelValue,o=n.mode,s=n.valueProp,c=u("single"!==o.value?[]:{}),v=void 0!==l.expose?i:r,p=t((function(){return"single"===o.value?c.value[s.value]:c.value.map((function(e){return e[s.value]}))})),d=t((function(){return"single"!==o.value?c.value.map((function(e){return e[s.value]})).join(","):c.value[s.value]}));return{iv:c,internalValue:c,ev:v,externalValue:v,textValue:d,plainValue:p}}(n,r),o={pointer:u(null)},s=function(t,a,l){var n=e(t),r=(n.maxHeight,n.disabled),i=u(!1);return{isOpen:i,open:function(){i.value||r.value||(i.value=!0,a.emit("open"))},close:function(){i.value&&(i.value=!1,a.emit("close"))}}}(n,r),c=function(e,t,l){var n=u(null),r=u(null);return a(n,(function(e){t.emit("search-change",e)})),{search:n,input:r,clearSearch:function(){n.value=""},handleSearchInput:function(e){n.value=e.target.value}}}(0,r),v=function(u,t,a){var l=e(u),n=l.object,r=l.valueProp,i=l.mode,o=a.iv,s=function(e){return n.value||m(e)?e:Array.isArray(e)?e.map((function(e){return e[r.value]})):e[r.value]},c=function(e){return m(e)?"single"===i.value?{}:[]:e};return{update:function(e){o.value=c(e);var u=s(e);t.emit("change",u),t.emit("input",u),t.emit("update:modelValue",u)}}}(n,r,{iv:i.iv}),p=function(a,l,n){var r=e(a),i=r.searchable,o=r.disabled,s=n.input,c=n.open,v=n.close,p=u(null),d=u(!1),f=t((function(){return i.value||o.value?-1:0})),D=function(){i.value&&s.value.blur(),p.value.blur()},h=function(){d.value=!1,v()};return{multiselect:p,tabindex:f,isActive:d,blur:D,handleFocus:function(){i.value&&!o.value&&s.value.focus()},activate:function(){o.value||(d.value=!0,c())},deactivate:h,handleCaretClick:function(){h(),D()}}}(n,0,{input:c.input,open:s.open,close:s.close}),d=F(n,r,{ev:i.ev,iv:i.iv,search:c.search,clearSearch:c.clearSearch,update:v.update,pointer:o.pointer,blur:p.blur}),f=function(u,n,r){var i=e(u),o=i.valueProp,s=i.showOptions,c=i.searchable,v=r.fo,p=r.handleOptionClick,d=r.search,f=r.pointer,D=r.multiselect,h=t((function(){return v.value.filter((function(e){return!0!==e.disabled}))})),m=function(e){void 0===e||null!==e&&e.disabled||(f.value=e)},g=function(){m(h.value[0]||null)},b=function(){m(null)},y=function(){var e=D.value.querySelector("[data-pointed]");if(e){var u=e.parentElement.parentElement;e.offsetTop+e.offsetHeight>u.clientHeight+u.scrollTop&&(u.scrollTop=e.offsetTop+e.offsetHeight-u.clientHeight),e.offsetTop<u.scrollTop&&(u.scrollTop=e.offsetTop)}};return a(d,(function(e){c.value&&(e.length&&s.value?g():b())})),{pointer:f,isPointed:function(e){return!!f.value&&f.value[o.value]==e[o.value]},setPointer:m,setPointerFirst:g,clearPointer:b,selectPointer:function(){f.value&&!0!==f.value.disabled&&p(f.value)},forwardPointer:function(){if(null===f.value)m(h.value[0]||null);else{var e=h.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])+1;h.value.length<=e&&(e=0),m(h.value[e]||null)}l((function(){y()}))},backwardPointer:function(){if(null===f.value)m(h.value[h.value.length-1]||null);else{var e=h.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])-1;e<0&&(e=h.value.length-1),m(h.value[e]||null)}l((function(){y()}))}}}(n,0,{fo:d.fo,handleOptionClick:d.handleOptionClick,search:c.search,pointer:o.pointer,multiselect:p.multiselect}),D=function(u,t,a){var l=e(u),n=l.mode,r=l.addTagOn,i=l.createTag,o=l.openDirection,s=l.searchable,c=l.showOptions,v=l.valueProp,p=a.iv,d=a.update,f=a.search,D=a.setPointer,h=a.selectPointer,m=a.backwardPointer,g=a.forwardPointer,b=a.blur,y=a.fo,F=function(){"tags"===n.value&&!c.value&&i.value&&s.value&&D(y.value[y.value.map((function(e){return e[v.value]})).indexOf(f.value)]),h()};return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===n.value)return;if(s.value&&-1===[null,""].indexOf(f.value))return;if(0===p.value.length)return;d(C(p.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===n.value&&-1===r.value.indexOf("enter"))return;F();break;case 27:b();break;case 32:if("tags"!==n.value&&s.value)return;if("tags"===n.value&&-1===r.value.indexOf("space"))return;e.preventDefault(),F();break;case 38:if(e.preventDefault(),!c.value)return;"top"===o.value?g():m();break;case 40:if(e.preventDefault(),!c.value)return;"top"===o.value?m():g();break;case 186:if("tags"!==n.value)return;if(-1===r.value.indexOf(";")||!i.value)return;F(),e.preventDefault();break;case 188:if("tags"!==n.value)return;if(-1===r.value.indexOf(",")||!i.value)return;F(),e.preventDefault()}}}}(n,0,{iv:i.iv,update:v.update,search:c.search,setPointer:f.setPointer,selectPointer:f.selectPointer,backwardPointer:f.backwardPointer,forwardPointer:f.forwardPointer,blur:p.blur,fo:d.fo}),h=B(n,0,{isOpen:s.isOpen,isPointed:f.isPointed,isSelected:d.isSelected,isDisabled:d.isDisabled,isActive:p.isActive});return{...i,...s,...p,...o,...v,...c,...d,...f,...D,...h}}};E.render=function(e,u,t,a,l,m){return n(),r("div",{ref:"multiselect",tabindex:e.tabindex,class:e.classList.container,id:t.id,onFocusin:u[5]||(u[5]=(...u)=>e.activate&&e.activate(...u)),onFocusout:u[6]||(u[6]=(...u)=>e.deactivate&&e.deactivate(...u)),onKeydown:u[7]||(u[7]=(...u)=>e.handleKeydown&&e.handleKeydown(...u)),onFocus:u[8]||(u[8]=(...u)=>e.handleFocus&&e.handleFocus(...u))},[i(" Search "),"tags"!==t.mode&&t.searchable&&!t.disabled?(n(),r("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.search,onInput:u[1]||(u[1]=(...u)=>e.handleSearchInput&&e.handleSearchInput(...u)),ref:"input"},null,42,["modelValue","value"])):i("v-if",!0),i(" Tags (with search) "),"tags"==t.mode?(n(),r("div",{key:1,class:e.classList.tags},[(n(!0),r(o,null,s(e.iv,((u,a,l)=>c(e.$slots,"tag",{option:u,handleTagRemove:e.handleTagRemove,disabled:t.disabled},(()=>[(n(),r("div",{class:e.classList.tag,key:l},[v(p(u[t.label])+" ",1),t.disabled?i("v-if",!0):(n(),r("span",{key:0,class:e.classList.tagRemove,onMousedown:d((t=>e.handleTagRemove(u,t)),["prevent"])},[f("span",{class:e.classList.tagRemoveIcon},null,2)],42,["onMousedown"]))],2))])))),256)),f("div",{class:e.classList.tagsSearchWrapper},[i(" Used for measuring search width "),f("span",{class:e.classList.tagsSearchCopy},p(e.search),3),i(" Actual search input "),t.searchable&&!t.disabled?(n(),r("input",{key:0,modelValue:e.search,value:e.search,class:e.classList.tagsSearch,onInput:u[2]||(u[2]=(...u)=>e.handleSearchInput&&e.handleSearchInput(...u)),ref:"input"},null,42,["modelValue","value"])):i("v-if",!0)],2)],2)):i("v-if",!0),i(" Single label "),"single"==t.mode&&e.hasSelected&&!e.search&&e.iv?c(e.$slots,"singlelabel",{key:2,value:e.iv},(()=>[f("div",{class:e.classList.singleLabel},p(e.iv[t.label]),3)])):i("v-if",!0),i(" Multiple label "),"multiple"==t.mode&&e.hasSelected&&!e.search?c(e.$slots,"multiplelabel",{key:3,values:e.iv},(()=>[f("div",{class:e.classList.multipleLabel},p(e.multipleLabelText),3)])):i("v-if",!0),i(" Placeholder "),!t.placeholder||e.hasSelected||e.search?i("v-if",!0):c(e.$slots,"placeholder",{key:4},(()=>[f("div",{class:e.classList.placeholder},p(t.placeholder),3)])),i(" Spinner "),e.busy?c(e.$slots,"spinner",{key:5},(()=>[f("span",{class:e.classList.spinner},null,2)])):i("v-if",!0),i(" Clear "),e.hasSelected&&!t.disabled&&t.canClear&&!e.busy?c(e.$slots,"clear",{key:6,clear:e.clear},(()=>[f("span",{class:e.classList.clear,onMousedown:u[3]||(u[3]=(...u)=>e.clear&&e.clear(...u))},[f("span",{class:e.classList.clearIcon},null,2)],34)])):i("v-if",!0),i(" Caret "),t.caret?c(e.$slots,"caret",{key:7},(()=>[f("span",{class:e.classList.caret,onClick:u[4]||(u[4]=(...u)=>e.handleCaretClick&&e.handleCaretClick(...u))},null,2)])):i("v-if",!0),i(" Options "),e.resolving&&t.clearOnSearch?i("v-if",!0):(n(),r(D,{key:8,name:"multiselect",onAfterLeave:e.clearSearch},{default:h((()=>[f("div",{class:e.classList.dropdown},[c(e.$slots,"beforelist",{options:e.fo}),f("ul",{class:e.classList.options},[(n(!0),r(o,null,s(e.fo,((u,a,l)=>(n(),r("li",{class:e.classList.option(u),key:l,"data-pointed":e.isPointed(u),onMouseenter:t=>e.setPointer(u),onClick:t=>e.handleOptionClick(u)},[c(e.$slots,"option",{option:u,search:e.search},(()=>[f("span",null,p(u[t.label]),1)]))],42,["data-pointed","onMouseenter","onClick"])))),128))],2),e.noOptions?c(e.$slots,"nooptions",{key:0},(()=>[f("div",{class:e.classList.noOptions,innerHTML:t.noOptionsText},null,10,["innerHTML"])])):i("v-if",!0),e.noResults?c(e.$slots,"noresults",{key:1},(()=>[f("div",{class:e.classList.noResults,innerHTML:t.noResultsText},null,10,["innerHTML"])])):i("v-if",!0),c(e.$slots,"afterlist",{options:e.fo})],2)])),_:3},8,["onAfterLeave"])),i(" Hacky input element to show HTML5 required warning "),t.required?(n(),r("input",{key:9,class:e.classList.fakeInput,tabindex:"-1",value:e.textValue,required:""},null,10,["value"])):i("v-if",!0),i(" Native input support "),t.nativeSupport?(n(),r(o,{key:10},["single"==t.mode?(n(),r("input",{key:0,type:"hidden",name:t.name,value:void 0!==e.plainValue?e.plainValue:""},null,8,["name","value"])):(n(!0),r(o,{key:1},s(e.plainValue,((e,u)=>(n(),r("input",{type:"hidden",name:`${t.name}[]`,value:e,key:u},null,8,["name","value"])))),128))],64)):i("v-if",!0),i(" Create height for empty input "),f("div",{class:e.classList.spacer},null,2)],42,["tabindex","id"])},E.__file="src/Multiselect.vue";export default E; |
@@ -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 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,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function u(e){return function(e){if(Array.isArray(e))return r(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 r(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 r(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 r(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 i(e){return String(e).toLowerCase().trim()}function o(l,u,r){var o=e.toRefs(l),s=o.options,c=o.mode,v=o.trackBy,d=o.limit,p=o.hideSelected,f=o.createTag,m=o.label,h=o.appendNewTag,b=o.multipleLabel,g=o.object,y=o.loading,O=o.delay,_=o.resolveOnLoad,S=o.minChars,w=o.filterResults,P=o.clearOnSearch,x=o.clearOnSelect,T=o.valueProp,q=o.canDeselect,L=o.max,k=r.iv,R=r.ev,j=r.search,D=r.clearSearch,C=r.update,A=r.pointer,I=r.blur,B=e.ref([]),V=e.ref([]),E=e.ref(!1),N=e.computed((function(){var e,t=V.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={},T.value,e),a(n,v.value,l),a(n,m.value,l),n}))),t=t.map((function(e,t){var l;return"object"===n(e)?e:(a(l={},T.value,e),a(l,v.value,e),a(l,m.value,e),l)})),B.value.length&&(t=t.concat(B.value)),t})),H=e.computed((function(){var e=N.value;return W.value.length&&(e=W.value.concat(e)),j.value&&w.value&&(e=e.filter((function(e){return-1!==i(e[v.value]).indexOf(i(j.value))}))),p.value&&(e=e.filter((function(e){return!le(e)}))),d.value>0&&(e=e.slice(0,d.value)),e})),M=e.computed((function(){switch(c.value){case"single":return!t(k.value[T.value]);case"multiple":case"tags":return!t(k.value)&&k.value.length>0}})),F=e.computed((function(){return void 0!==b&&void 0!==b.value?b.value(k.value):k.value&&k.value.length>1?"".concat(k.value.length," options selected"):"1 option selected"})),$=e.computed((function(){return!N.value.length&&!E.value})),U=e.computed((function(){return N.value.length>0&&0==H.value.length})),W=e.computed((function(){var e;return!1!==f.value&&j.value?-1!==ae(j.value)?[]:[(e={},a(e,T.value,j.value),a(e,m.value,j.value),a(e,v.value,j.value),e)]:[]})),K=e.computed((function(){switch(c.value){case"single":return null;case"multiple":case"tags":return[]}})),X=e.computed((function(){return y.value||E.value})),z=function(e){switch("object"!==n(e)&&(e=ne(e)),c.value){case"single":C(e);break;case"multiple":case"tags":C(k.value.concat(e))}u.emit("select",J(e),e)},G=function(e){switch("object"!==n(e)&&(e=ne(e)),c.value){case"single":Y();break;case"tags":case"multiple":C(k.value.filter((function(t){return t[T.value]!=e[T.value]})))}u.emit("deselect",J(e),e)},J=function(e){return g.value?e:e[T.value]},Q=function(e){G(e)},Y=function(){u.emit("clear"),C(K.value)},Z=function(e){switch(c.value){case"single":return!t(k.value)&&k.value[T.value]==e[T.value];case"tags":case"multiple":return!t(k.value)&&-1!==k.value.map((function(e){return e[T.value]})).indexOf(e[T.value])}},ee=function(e){return!0===e.disabled},te=function(){return!(void 0===L||-1===L.value||!M.value&&L.value>0)&&k.value.length>=L.value},ne=function(e){return N.value[N.value.map((function(e){return String(e[T.value])})).indexOf(String(e))]},ae=function(e){return N.value.map((function(e){return i(e[v.value])})).indexOf(i(e))},le=function(e){return"tags"===c.value&&p.value&&Z(e)},ue=function(e){B.value.push(e)},re=function(){t(R.value)||(k.value=oe(R.value))},ie=function(e){E.value=!0,s.value(j.value).then((function(t){V.value=t,"function"==typeof e&&e(t),E.value=!1}))},oe=function(e){return t(e)?"single"===c.value?{}:[]:g.value?e:"single"===c.value?ne(e)||{}:e.filter((function(e){return!!ne(e)})).map((function(e){return ne(e)}))};if("single"!==c.value&&!t(R.value)&&!Array.isArray(R.value))throw new Error('v-model must be an array when using "'.concat(c.value,'" mode'));return s&&"function"==typeof s.value?_.value?ie(re):1==g.value&&re():(V.value=s.value,re()),O.value>-1&&e.watch(j,(function(e){e.length<S.value||(E.value=!0,P.value&&(V.value=[]),setTimeout((function(){e==j.value&&s.value(j.value).then((function(t){e==j.value&&(V.value=t,A.value=H.value.filter((function(e){return!0!==e.disabled}))[0]||null,E.value=!1)}))}),O.value))}),{flush:"sync"}),e.watch(R,(function(e){var n,a,l;if(t(e))k.value=oe(e);else switch(c.value){case"single":(g.value?e[T.value]!=k.value[T.value]:e!=k.value[T.value])&&(k.value=oe(e));break;case"multiple":case"tags":n=g.value?e.map((function(e){return e[T.value]})):e,a=k.value.map((function(e){return e[T.value]})),l=a.slice().sort(),n.length===a.length&&n.slice().sort().every((function(e,t){return e===l[t]}))||(k.value=oe(e))}}),{deep:!0}),"function"!=typeof l.options&&e.watch(s,(function(e,t){V.value=l.options,Object.keys(k.value).length||re(),function(){if(M.value)if("single"===c.value){var e=ne(k.value[T.value])[m.value];k.value[m.value]=e,g.value&&(R.value[m.value]=e)}else k.value.forEach((function(e,t){var n=ne(k.value[t][T.value])[m.value];k.value[t][m.value]=n,g.value&&(R.value[t][m.value]=n)}))}()})),{fo:H,filteredOptions:H,hasSelected:M,multipleLabelText:F,eo:N,extendedOptions:N,noOptions:$,noResults:U,resolving:E,busy:X,select:z,deselect:G,remove:Q,clear:Y,isSelected:Z,isDisabled:ee,isMax:te,getOption:ne,handleOptionClick:function(e){if(!ee(e))switch(c.value){case"single":if(Z(e))return void(q.value&&G(e));I(),z(e);break;case"multiple":if(Z(e))return void G(e);if(te())return;z(e),x.value&&D();break;case"tags":if(Z(e))return void G(e);if(te())return;void 0===ne(e[T.value])&&f.value&&(u.emit("tag",e[T.value]),h.value&&ue(e),D()),x.value&&D(),z(e)}},handleTagRemove:function(e,t){0===t.button?Q(e):t.preventDefault()},refreshOptions:function(e){ie(e)},resolveOptions:ie}}function s(t,n,u){var r=e.toRefs(t),i=r.disabled,o=r.openDirection,s=u.isOpen,c=u.isPointed,v=u.isSelected,d=u.isDisabled,p=u.isActive,f=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearch:"multiselect-tags-search",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},r.classes.value);return{classList:e.computed((function(){return{container:[f.container].concat(i.value?f.containerDisabled:[]).concat(s.value&&"top"===o.value?f.containerOpenTop:[]).concat(s.value&&"top"!==o.value?f.containerOpen:[]).concat(p.value?f.containerActive:[]),spacer:f.spacer,singleLabel:f.singleLabel,multipleLabel:f.multipleLabel,search:f.search,tags:f.tags,tag:[f.tag].concat(i.value?f.tagDisabled:[]),tagRemove:f.tagRemove,tagRemoveIcon:f.tagRemoveIcon,tagsSearch:f.tagsSearch,placeholder:f.placeholder,caret:[f.caret].concat(s.value?f.caretOpen:[]),clear:f.clear,clearIcon:f.clearIcon,spinner:f.spinner,dropdown:[f.dropdown].concat("top"===o.value?f.dropdownTop:[]),options:[f.options].concat("top"===o.value?f.optionsTop:[]),option:function(e){var t=[f.option];return c(e)?t.push(v(e)?f.optionSelectedPointed:f.optionPointed):v(e)?t.push(d(e)?f.optionSelectedDisabled:f.optionSelected):d(e)&&t.push(f.optionDisabled),t},noOptions:f.noOptions,noResults:f.noResults,fakeInput:f.fakeInput}}))}}function c(e,t,n,a,l,u,r,i,o,s){"boolean"!=typeof r&&(o=i,i=r,r=!1);var c,v="function"==typeof n?n.options:n;if(e&&e.render&&(v.render=e.render,v.staticRenderFns=e.staticRenderFns,v._compiled=!0,l&&(v.functional=!0)),a&&(v._scopeId=a),u?(c=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)},v._ssrRegister=c):t&&(c=r?function(e){t.call(this,s(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,i(e))}),c)if(v.functional){var d=v.render;v.render=function(e,t){return c.call(t),d(e,t)}}else{var p=v.beforeCreate;v.beforeCreate=p?[].concat(p,c):[c]}return n}const v={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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:[String,Number],required:!1,default:"10rem"},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})}},setup(n,a){const l=function(t,n){var a=e.toRefs(t),l=a.value,u=a.modelValue,r=a.mode,i=a.valueProp,o=e.ref("single"!==r.value?[]:{}),s=void 0!==n.expose?u:l,c=e.computed((function(){return"single"===r.value?o.value[i.value]:o.value.map((function(e){return e[i.value]}))})),v=e.computed((function(){return"single"!==r.value?o.value.map((function(e){return e[i.value]})).join(","):o.value[i.value]}));return{iv:o,internalValue:o,ev:s,externalValue:s,textValue:v,plainValue:c}}(n,a),r={pointer:e.ref(null)},i=function(t,n,a){var l=e.toRefs(t),u=l.maxHeight,r=l.disabled,i=e.ref(!1),o=e.computed((function(){return"number"==typeof u.value?"".concat(u.value,"px"):u.value}));return{isOpen:i,contentMaxHeight:o,open:function(){i.value||r.value||(i.value=!0,n.emit("open"))},close:function(){i.value&&(i.value=!1,n.emit("close"))}}}(n,a),c=function(n,a,l){var u=e.toRefs(n),r=u.object,i=u.valueProp,o=u.mode,s=l.iv,c=function(e){return r.value||t(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},v=function(e){return t(e)?"single"===o.value?{}:[]:e};return{update:function(e){s.value=v(e);var t=c(e);a.emit("change",t),a.emit("input",t),a.emit("update:modelValue",t)}}}(n,a,{iv:l.iv}),v=function(t,n,a){var l=e.toRefs(t).mode,u=a.iv,r=e.ref(null),i=e.ref(null),o=e.computed((function(){return r.value?"".concat(s.value,"px"):"tags"===l.value&&-1===[null,void 0].indexOf(u.value)&&u.value.length?"1ch":"100%"})),s=e.computed((function(){var e=document.createElement("span");e.innerHTML=r.value.replace(/ /g," "),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",document.body.append(e);var t=e.offsetWidth;return e.remove(),t}));return e.watch(r,(function(e){n.emit("search-change",e)})),{search:r,input:i,tagsSearchWidth:o,clearSearch:function(){r.value=""},handleSearchInput:function(e){r.value=e.target.value}}}(n,a,{iv:l.iv}),d=function(t,n,a){var l=e.toRefs(t),u=l.searchable,r=l.disabled,i=a.input,o=a.open,s=a.close,c=e.ref(null),v=e.ref(!1),d=e.computed((function(){return u.value?-1:0}));return{multiselect:c,tabindex:d,isActive:v,blur:function(){u.value&&i.value.blur(),c.value.blur()},handleFocus:function(){u.value&&!r.value&&i.value.focus()},activate:function(){r.value||(v.value=!0,o())},deactivate:function(){v.value=!1,s()}}}(n,0,{input:v.input,open:i.open,close:i.close}),p=o(n,a,{ev:l.ev,iv:l.iv,search:v.search,clearSearch:v.clearSearch,update:c.update,pointer:r.pointer,blur:d.blur}),f=function(t,n,a){var l=e.toRefs(t),u=l.valueProp,r=l.showOptions,i=l.searchable,o=a.fo,s=a.handleOptionClick,c=a.search,v=a.pointer,d=a.multiselect,p=e.computed((function(){return o.value.filter((function(e){return!0!==e.disabled}))})),f=function(e){!r.value||null!==e&&e.disabled||(v.value=e)},m=function(){f(p.value[0]||null)},h=function(){f(null)},b=function(){var e=d.value.querySelector("[data-pointed]");if(e){var t=e.parentElement.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){i.value&&(e.length?m():h())})),{pointer:v,isPointed:function(e){return!!v.value&&v.value[u.value]==e[u.value]},setPointer:f,setPointerFirst:m,clearPointer:h,selectPointer:function(){v.value&&!0!==v.value.disabled&&s(v.value)},forwardPointer:function(){if(null===v.value)f(p.value[0]||null);else{var t=p.value.map((function(e){return e[u.value]})).indexOf(v.value[u.value])+1;p.value.length<=t&&(t=0),f(p.value[t]||null)}e.nextTick((function(){b()}))},backwardPointer:function(){if(null===v.value)f(p.value[p.value.length-1]||null);else{var t=p.value.map((function(e){return e[u.value]})).indexOf(v.value[u.value])-1;t<0&&(t=p.value.length-1),f(p.value[t]||null)}e.nextTick((function(){b()}))}}}(n,0,{fo:p.fo,handleOptionClick:p.handleOptionClick,search:v.search,pointer:r.pointer,multiselect:d.multiselect}),m=function(t,n,a){var l=e.toRefs(t),r=l.mode,i=l.addTagOn,o=l.createTag,s=l.openDirection,c=l.searchable,v=a.iv,d=a.update,p=a.search,f=a.selectPointer,m=a.backwardPointer,h=a.forwardPointer,b=a.blur;return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===r.value)return;if(c.value&&-1===[null,""].indexOf(p.value))return;if(0===v.value.length)return;d(u(v.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===r.value&&-1===i.value.indexOf("enter"))return;f();break;case 27:b();break;case 32:if("tags"!==r.value&&c.value)return;if("tags"===r.value&&-1===i.value.indexOf("space"))return;e.preventDefault(),f();break;case 38:e.preventDefault(),"top"===s.value?h():m();break;case 40:e.preventDefault(),"top"===s.value?m():h();break;case 186:if("tags"!==r.value)return;if(-1===i.value.indexOf(";")||!o.value)return;f(),e.preventDefault();break;case 188:if("tags"!==r.value)return;if(-1===i.value.indexOf(",")||!o.value)return;f(),e.preventDefault()}}}}(n,0,{iv:l.iv,update:c.update,search:v.search,selectPointer:f.selectPointer,backwardPointer:f.backwardPointer,forwardPointer:f.forwardPointer,blur:d.blur}),h=s(n,0,{isOpen:i.isOpen,isPointed:f.isPointed,isSelected:p.isSelected,isDisabled:p.isDisabled,isActive:d.isActive});return{...l,...i,...d,...r,...c,...v,...p,...f,...m,...h}}};var d=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",class:e.classList.container,attrs:{tabindex:e.tabindex,id:e.id},on:{focusin:e.activate,focusout:e.deactivate,keydown:e.handleKeydown,focus:e.handleFocus}},["tags"!==e.mode&&e.searchable&&!e.disabled?[n("input",{ref:"input",class:e.classList.search,attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}})]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{class:e.classList.tags},[e._l(e.iv,(function(t,a,l){return e._t("tag",[n("div",{key:l,class:e.classList.tag},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("span",{class:e.classList.tagRemove,on:{mousedown:function(n){return n.preventDefault(),e.handleTagRemove(t,n)}}},[n("span",{class:e.classList.tagRemoveIcon})])])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})})),e._v(" "),e.searchable&&!e.disabled?n("input",{ref:"input",class:e.classList.tagsSearch,style:{width:e.tagsSearchWidth},attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}}):e._e()],2)]:e._e(),e._v(" "),"single"==e.mode&&e.hasSelected&&!e.search&&e.iv?[e._t("singlelabel",[n("div",{class:e.classList.singleLabel},[e._v("\n "+e._s(e.iv[e.label])+"\n ")])],{value:e.iv})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[n("div",{class:e.classList.multipleLabel},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.iv})]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[n("div",{class:e.classList.placeholder},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),e.busy?e._t("spinner",[n("span",{class:e.classList.spinner})]):e._e(),e._v(" "),e.hasSelected&&!e.disabled&&e.canClear&&!e.busy?e._t("clear",[n("span",{class:e.classList.clear,on:{mousedown:e.clear}},[n("span",{class:e.classList.clearIcon})])],{clear:e.clear}):e._e(),e._v(" "),e.caret?e._t("caret",[n("span",{class:e.classList.caret})]):e._e(),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"}],class:e.classList.dropdown,style:{maxHeight:e.contentMaxHeight}},[e._t("beforelist",null,{options:e.fo}),e._v(" "),n("ul",{class:e.classList.options},e._l(e.fo,(function(t,a,l){return n("li",{key:l,class:e.classList.option(t),attrs:{"data-pointed":e.isPointed(t)},on:{mouseenter:function(n){return e.setPointer(t)},click:function(n){return e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),0),e._v(" "),e.noOptions?e._t("nooptions",[n("div",{class:e.classList.noOptions,domProps:{innerHTML:e._s(e.noOptionsText)}})]):e._e(),e._v(" "),e.noResults?e._t("noresults",[n("div",{class:e.classList.noResults,domProps:{innerHTML:e._s(e.noResultsText)}})]):e._e(),e._v(" "),e._t("afterlist",null,{options:e.fo})],2)]),e._v(" "),e.required?n("input",{class:e.classList.fakeInput,attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e(),e._v(" "),e.nativeSupport?["single"==e.mode?n("input",{attrs:{type:"hidden",name:e.name},domProps:{value:void 0!==e.plainValue?e.plainValue:""}}):e._l(e.plainValue,(function(t,a){return n("input",{key:a,attrs:{type:"hidden",name:e.name+"[]"},domProps:{value:t}})}))]:e._e(),e._v(" "),n("div",{class:e.classList.spacer})],2)};d._withStripped=!0;return c({render:d,staticRenderFns:[]},undefined,v,undefined,false,undefined,!1,void 0,void 0,void 0)}(VueCompositionAPI); | ||
var VueformMultiselect=function(e){"use strict";function u(e){return-1!==[null,void 0,!1].indexOf(e)}function t(e){return(t="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,u,t){return u in e?Object.defineProperty(e,u,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[u]=t,e}function n(e,u){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);u&&(a=a.filter((function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable}))),t.push.apply(t,a)}return t}function l(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,u){if(!e)return;if("string"==typeof e)return r(e,u);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 r(e,u)}(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 r(e,u){(null==u||u>e.length)&&(u=e.length);for(var t=0,a=new Array(u);t<u;t++)a[t]=e[t];return a}function i(e){var u=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return u?String(e).toLowerCase().trim():String(e).normalize("NFD").replace(/(?:[\^`\xA8\xAF\xB4\xB7\xB8\u02B0-\u034E\u0350-\u0357\u035D-\u0362\u0374\u0375\u037A\u0384\u0385\u0483-\u0487\u0559\u0591-\u05A1\u05A3-\u05BD\u05BF\u05C1\u05C2\u05C4\u064B-\u0652\u0657\u0658\u06DF\u06E0\u06E5\u06E6\u06EA-\u06EC\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F5\u0818\u0819\u08E3-\u08FE\u093C\u094D\u0951-\u0954\u0971\u09BC\u09CD\u0A3C\u0A4D\u0ABC\u0ACD\u0AFD-\u0AFF\u0B3C\u0B4D\u0B55\u0BCD\u0C4D\u0CBC\u0CCD\u0D3B\u0D3C\u0D4D\u0DCA\u0E47-\u0E4C\u0E4E\u0EBA\u0EC8-\u0ECC\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F82-\u0F84\u0F86\u0F87\u0FC6\u1037\u1039\u103A\u1063\u1064\u1069-\u106D\u1087-\u108D\u108F\u109A\u109B\u135D-\u135F\u17C9-\u17D3\u17DD\u1939-\u193B\u1A75-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B34\u1B44\u1B6B-\u1B73\u1BAA\u1BAB\u1C36\u1C37\u1C78-\u1C7D\u1CD0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1D2C-\u1D6A\u1DC4-\u1DCF\u1DF5-\u1DF9\u1DFD-\u1DFF\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2CEF-\u2CF1\u2E2F\u302A-\u302F\u3099-\u309C\u30FC\uA66F\uA67C\uA67D\uA67F\uA69C\uA69D\uA6F0\uA6F1\uA700-\uA721\uA788-\uA78A\uA7F8\uA7F9\uA8C4\uA8E0-\uA8F1\uA92B-\uA92E\uA953\uA9B3\uA9C0\uA9E5\uAA7B-\uAA7D\uAABF-\uAAC2\uAAF6\uAB5B-\uAB5F\uAB69-\uAB6B\uABEC\uABED\uFB1E\uFE20-\uFE2F\uFF3E\uFF40\uFF70\uFF9E\uFF9F\uFFE3]|\uD800\uDEE0|\uD802[\uDEE5\uDEE6]|\uD803[\uDD22-\uDD27\uDF46-\uDF50]|\uD804[\uDCB9\uDCBA\uDD33\uDD34\uDD73\uDDC0\uDDCA-\uDDCC\uDE35\uDE36\uDEE9\uDEEA\uDF3C\uDF4D\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC42\uDC46\uDCC2\uDCC3\uDDBF\uDDC0\uDE3F\uDEB6\uDEB7\uDF2B]|\uD806[\uDC39\uDC3A\uDD3D\uDD3E\uDD43\uDDE0\uDE34\uDE47\uDE99]|\uD807[\uDC3F\uDD42\uDD44\uDD45\uDD97]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF8F-\uDF9F\uDFF0\uDFF1]|\uD834[\uDD67-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD]|\uD838[\uDD30-\uDD36\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD46\uDD48-\uDD4A])/g,"").toLowerCase().trim()}function o(n,l,r){var o=e.toRefs(n),s=o.options,c=o.mode,v=o.trackBy,d=o.limit,p=o.hideSelected,f=o.createTag,D=o.label,m=o.appendNewTag,h=o.multipleLabel,g=o.object,b=o.loading,y=o.delay,F=o.resolveOnLoad,C=o.minChars,A=o.filterResults,O=o.clearOnSearch,_=o.clearOnSelect,S=o.valueProp,B=o.canDeselect,E=o.max,w=o.strict,P=r.iv,k=r.ev,q=r.search,L=r.clearSearch,T=r.update,x=r.pointer,R=r.blur,j=e.ref([]),I=e.ref([]),V=e.ref(!1),N=e.computed((function(){var e,u=I.value||[];return e=u,"[object Object]"===Object.prototype.toString.call(e)&&(u=Object.keys(u).map((function(e){var t,n=u[e];return a(t={},S.value,e),a(t,v.value,n),a(t,D.value,n),t}))),u=u.map((function(e,u){var n;return"object"===t(e)?e:(a(n={},S.value,e),a(n,v.value,e),a(n,D.value,e),n)})),j.value.length&&(u=u.concat(j.value)),u})),H=e.computed((function(){var e=N.value;return K.value.length&&(e=K.value.concat(e)),q.value&&A.value&&(e=e.filter((function(e){return-1!==i(e[v.value],w.value).indexOf(i(q.value,w.value))}))),p.value&&(e=e.filter((function(e){return!le(e)}))),d.value>0&&(e=e.slice(0,d.value)),e})),$=e.computed((function(){switch(c.value){case"single":return!u(P.value[S.value]);case"multiple":case"tags":return!u(P.value)&&P.value.length>0}})),M=e.computed((function(){return void 0!==h&&void 0!==h.value?h.value(P.value):P.value&&P.value.length>1?"".concat(P.value.length," options selected"):"1 option selected"})),W=e.computed((function(){return!N.value.length&&!V.value})),U=e.computed((function(){return N.value.length>0&&0==H.value.length})),K=e.computed((function(){var e;return!1!==f.value&&q.value?-1!==ne(q.value)?[]:[(e={},a(e,S.value,q.value),a(e,D.value,q.value),a(e,v.value,q.value),e)]:[]})),X=e.computed((function(){switch(c.value){case"single":return null;case"multiple":case"tags":return[]}})),z=e.computed((function(){return b.value||V.value})),G=function(e){switch("object"!==t(e)&&(e=ae(e)),c.value){case"single":T(e);break;case"multiple":case"tags":T(P.value.concat(e))}l.emit("select",Q(e),e)},J=function(e){switch("object"!==t(e)&&(e=ae(e)),c.value){case"single":Z();break;case"tags":case"multiple":T(P.value.filter((function(u){return u[S.value]!=e[S.value]})))}l.emit("deselect",Q(e),e)},Q=function(e){return g.value?e:e[S.value]},Y=function(e){J(e)},Z=function(){l.emit("clear"),T(X.value)},ee=function(e){switch(c.value){case"single":return!u(P.value)&&P.value[S.value]==e[S.value];case"tags":case"multiple":return!u(P.value)&&-1!==P.value.map((function(e){return e[S.value]})).indexOf(e[S.value])}},ue=function(e){return!0===e.disabled},te=function(){return!(void 0===E||-1===E.value||!$.value&&E.value>0)&&P.value.length>=E.value},ae=function(e){return N.value[N.value.map((function(e){return String(e[S.value])})).indexOf(String(e))]},ne=function(e){return N.value.map((function(e){return i(e[v.value])})).indexOf(i(e))},le=function(e){return"tags"===c.value&&p.value&&ee(e)},re=function(e){j.value.push(e)},ie=function(){u(k.value)||(P.value=se(k.value))},oe=function(e){V.value=!0,s.value(q.value).then((function(u){I.value=u,"function"==typeof e&&e(u),V.value=!1}))},se=function(e){return u(e)?"single"===c.value?{}:[]:g.value?e:"single"===c.value?ae(e)||{}:e.filter((function(e){return!!ae(e)})).map((function(e){return ae(e)}))};if("single"!==c.value&&!u(k.value)&&!Array.isArray(k.value))throw new Error('v-model must be an array when using "'.concat(c.value,'" mode'));return s&&"function"==typeof s.value?F.value?oe(ie):1==g.value&&ie():(I.value=s.value,ie()),y.value>-1&&e.watch(q,(function(e){e.length<C.value||(V.value=!0,O.value&&(I.value=[]),setTimeout((function(){e==q.value&&s.value(q.value).then((function(u){e==q.value&&(I.value=u,x.value=H.value.filter((function(e){return!0!==e.disabled}))[0]||null,V.value=!1)}))}),y.value))}),{flush:"sync"}),e.watch(k,(function(e){var t,a,n;if(u(e))P.value=se(e);else switch(c.value){case"single":(g.value?e[S.value]!=P.value[S.value]:e!=P.value[S.value])&&(P.value=se(e));break;case"multiple":case"tags":t=g.value?e.map((function(e){return e[S.value]})):e,a=P.value.map((function(e){return e[S.value]})),n=a.slice().sort(),t.length===a.length&&t.slice().sort().every((function(e,u){return e===n[u]}))||(P.value=se(e))}}),{deep:!0}),"function"!=typeof n.options&&e.watch(s,(function(e,u){I.value=n.options,Object.keys(P.value).length||ie(),function(){if($.value)if("single"===c.value){var e=ae(P.value[S.value])[D.value];P.value[D.value]=e,g.value&&(k.value[D.value]=e)}else P.value.forEach((function(e,u){var t=ae(P.value[u][S.value])[D.value];P.value[u][D.value]=t,g.value&&(k.value[u][D.value]=t)}))}()})),{fo:H,filteredOptions:H,hasSelected:$,multipleLabelText:M,eo:N,extendedOptions:N,noOptions:W,noResults:U,resolving:V,busy:z,select:G,deselect:J,remove:Y,clear:Z,isSelected:ee,isDisabled:ue,isMax:te,getOption:ae,handleOptionClick:function(e){if(!ue(e))switch(c.value){case"single":if(ee(e))return void(B.value&&J(e));R(),G(e);break;case"multiple":if(ee(e))return void J(e);if(te())return;G(e),_.value&&L();break;case"tags":if(ee(e))return void J(e);if(te())return;void 0===ae(e[S.value])&&f.value&&(l.emit("tag",e[S.value]),m.value&&re(e),L()),_.value&&L(),G(e)}},handleTagRemove:function(e,u){0===u.button?Y(e):u.preventDefault()},refreshOptions:function(e){oe(e)},resolveOptions:oe}}function s(u,t,l){var r=e.toRefs(u),i=r.disabled,o=r.openDirection,s=r.showOptions,c=l.isOpen,v=l.isPointed,d=l.isSelected,p=l.isDisabled,f=l.isActive,D=function(e){for(var u=1;u<arguments.length;u++){var t=null!=arguments[u]?arguments[u]:{};u%2?n(Object(t),!0).forEach((function(u){a(e,u,t[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach((function(u){Object.defineProperty(e,u,Object.getOwnPropertyDescriptor(t,u))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearchWrapper:"multiselect-tags-search-wrapper",tagsSearch:"multiselect-tags-search",tagsSearchCopy:"multiselect-tags-search-copy",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",dropdownHidden:"is-hidden",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},r.classes.value);return{classList:e.computed((function(){return{container:[D.container].concat(i.value?D.containerDisabled:[]).concat(c.value&&"top"===o.value&&s.value?D.containerOpenTop:[]).concat(c.value&&"top"!==o.value&&s.value?D.containerOpen:[]).concat(f.value?D.containerActive:[]),spacer:D.spacer,singleLabel:D.singleLabel,multipleLabel:D.multipleLabel,search:D.search,tags:D.tags,tag:[D.tag].concat(i.value?D.tagDisabled:[]),tagRemove:D.tagRemove,tagRemoveIcon:D.tagRemoveIcon,tagsSearchWrapper:D.tagsSearchWrapper,tagsSearch:D.tagsSearch,tagsSearchCopy:D.tagsSearchCopy,placeholder:D.placeholder,caret:[D.caret].concat(c.value?D.caretOpen:[]),clear:D.clear,clearIcon:D.clearIcon,spinner:D.spinner,dropdown:[D.dropdown].concat("top"===o.value?D.dropdownTop:[]).concat(c.value&&s.value?[]:D.dropdownHidden),options:[D.options].concat("top"===o.value?D.optionsTop:[]),option:function(e){var u=[D.option];return v(e)?u.push(d(e)?D.optionSelectedPointed:D.optionPointed):d(e)?u.push(p(e)?D.optionSelectedDisabled:D.optionSelected):p(e)&&u.push(D.optionDisabled),u},noOptions:D.noOptions,noResults:D.noResults,fakeInput:D.fakeInput}}))}}function c(e,u,t,a,n,l,r,i,o,s){"boolean"!=typeof r&&(o=i,i=r,r=!1);var c,v="function"==typeof t?t.options:t;if(e&&e.render&&(v.render=e.render,v.staticRenderFns=e.staticRenderFns,v._compiled=!0,n&&(v.functional=!0)),a&&(v._scopeId=a),l?(c=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__),u&&u.call(this,o(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},v._ssrRegister=c):u&&(c=r?function(e){u.call(this,s(e,this.$root.$options.shadowRoot))}:function(e){u.call(this,i(e))}),c)if(v.functional){var d=v.render;v.render=function(e,u){return c.call(u),d(e,u)}}else{var p=v.beforeCreate;v.beforeCreate=p?[].concat(p,c):[c]}return t}const v={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})},strict:{type:Boolean,required:!1,default:!0}},setup(t,a){const n=function(u,t){var a=e.toRefs(u),n=a.value,l=a.modelValue,r=a.mode,i=a.valueProp,o=e.ref("single"!==r.value?[]:{}),s=void 0!==t.expose?l:n,c=e.computed((function(){return"single"===r.value?o.value[i.value]:o.value.map((function(e){return e[i.value]}))})),v=e.computed((function(){return"single"!==r.value?o.value.map((function(e){return e[i.value]})).join(","):o.value[i.value]}));return{iv:o,internalValue:o,ev:s,externalValue:s,textValue:v,plainValue:c}}(t,a),r={pointer:e.ref(null)},i=function(u,t,a){var n=e.toRefs(u),l=(n.maxHeight,n.disabled),r=e.ref(!1);return{isOpen:r,open:function(){r.value||l.value||(r.value=!0,t.emit("open"))},close:function(){r.value&&(r.value=!1,t.emit("close"))}}}(t,a),c=function(u,t,a){var n=e.ref(null),l=e.ref(null);return e.watch(n,(function(e){t.emit("search-change",e)})),{search:n,input:l,clearSearch:function(){n.value=""},handleSearchInput:function(e){n.value=e.target.value}}}(0,a),v=function(t,a,n){var l=e.toRefs(t),r=l.object,i=l.valueProp,o=l.mode,s=n.iv,c=function(e){return r.value||u(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},v=function(e){return u(e)?"single"===o.value?{}:[]:e};return{update:function(e){s.value=v(e);var u=c(e);a.emit("change",u),a.emit("input",u),a.emit("update:modelValue",u)}}}(t,a,{iv:n.iv}),d=function(u,t,a){var n=e.toRefs(u),l=n.searchable,r=n.disabled,i=a.input,o=a.open,s=a.close,c=e.ref(null),v=e.ref(!1),d=e.computed((function(){return l.value||r.value?-1:0})),p=function(){l.value&&i.value.blur(),c.value.blur()},f=function(){v.value=!1,s()};return{multiselect:c,tabindex:d,isActive:v,blur:p,handleFocus:function(){l.value&&!r.value&&i.value.focus()},activate:function(){r.value||(v.value=!0,o())},deactivate:f,handleCaretClick:function(){f(),p()}}}(t,0,{input:c.input,open:i.open,close:i.close}),p=o(t,a,{ev:n.ev,iv:n.iv,search:c.search,clearSearch:c.clearSearch,update:v.update,pointer:r.pointer,blur:d.blur}),f=function(u,t,a){var n=e.toRefs(u),l=n.valueProp,r=n.showOptions,i=n.searchable,o=a.fo,s=a.handleOptionClick,c=a.search,v=a.pointer,d=a.multiselect,p=e.computed((function(){return o.value.filter((function(e){return!0!==e.disabled}))})),f=function(e){void 0===e||null!==e&&e.disabled||(v.value=e)},D=function(){f(p.value[0]||null)},m=function(){f(null)},h=function(){var e=d.value.querySelector("[data-pointed]");if(e){var u=e.parentElement.parentElement;e.offsetTop+e.offsetHeight>u.clientHeight+u.scrollTop&&(u.scrollTop=e.offsetTop+e.offsetHeight-u.clientHeight),e.offsetTop<u.scrollTop&&(u.scrollTop=e.offsetTop)}};return e.watch(c,(function(e){i.value&&(e.length&&r.value?D():m())})),{pointer:v,isPointed:function(e){return!!v.value&&v.value[l.value]==e[l.value]},setPointer:f,setPointerFirst:D,clearPointer:m,selectPointer:function(){v.value&&!0!==v.value.disabled&&s(v.value)},forwardPointer:function(){if(null===v.value)f(p.value[0]||null);else{var u=p.value.map((function(e){return e[l.value]})).indexOf(v.value[l.value])+1;p.value.length<=u&&(u=0),f(p.value[u]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===v.value)f(p.value[p.value.length-1]||null);else{var u=p.value.map((function(e){return e[l.value]})).indexOf(v.value[l.value])-1;u<0&&(u=p.value.length-1),f(p.value[u]||null)}e.nextTick((function(){h()}))}}}(t,0,{fo:p.fo,handleOptionClick:p.handleOptionClick,search:c.search,pointer:r.pointer,multiselect:d.multiselect}),D=function(u,t,a){var n=e.toRefs(u),r=n.mode,i=n.addTagOn,o=n.createTag,s=n.openDirection,c=n.searchable,v=n.showOptions,d=n.valueProp,p=a.iv,f=a.update,D=a.search,m=a.setPointer,h=a.selectPointer,g=a.backwardPointer,b=a.forwardPointer,y=a.blur,F=a.fo,C=function(){"tags"===r.value&&!v.value&&o.value&&c.value&&m(F.value[F.value.map((function(e){return e[d.value]})).indexOf(D.value)]),h()};return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===r.value)return;if(c.value&&-1===[null,""].indexOf(D.value))return;if(0===p.value.length)return;f(l(p.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===r.value&&-1===i.value.indexOf("enter"))return;C();break;case 27:y();break;case 32:if("tags"!==r.value&&c.value)return;if("tags"===r.value&&-1===i.value.indexOf("space"))return;e.preventDefault(),C();break;case 38:if(e.preventDefault(),!v.value)return;"top"===s.value?b():g();break;case 40:if(e.preventDefault(),!v.value)return;"top"===s.value?g():b();break;case 186:if("tags"!==r.value)return;if(-1===i.value.indexOf(";")||!o.value)return;C(),e.preventDefault();break;case 188:if("tags"!==r.value)return;if(-1===i.value.indexOf(",")||!o.value)return;C(),e.preventDefault()}}}}(t,0,{iv:n.iv,update:v.update,search:c.search,setPointer:f.setPointer,selectPointer:f.selectPointer,backwardPointer:f.backwardPointer,forwardPointer:f.forwardPointer,blur:d.blur,fo:p.fo}),m=s(t,0,{isOpen:i.isOpen,isPointed:f.isPointed,isSelected:p.isSelected,isDisabled:p.isDisabled,isActive:d.isActive});return{...n,...i,...d,...r,...v,...c,...p,...f,...D,...m}}};var d=function(){var e=this,u=e.$createElement,t=e._self._c||u;return t("div",{ref:"multiselect",class:e.classList.container,attrs:{tabindex:e.tabindex,id:e.id},on:{focusin:e.activate,focusout:e.deactivate,keydown:e.handleKeydown,focus:e.handleFocus}},["tags"!==e.mode&&e.searchable&&!e.disabled?[t("input",{ref:"input",class:e.classList.search,attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}})]:e._e(),e._v(" "),"tags"==e.mode?[t("div",{class:e.classList.tags},[e._l(e.iv,(function(u,a,n){return e._t("tag",[t("div",{key:n,class:e.classList.tag},[e._v("\n "+e._s(u[e.label])+"\n "),e.disabled?e._e():t("span",{class:e.classList.tagRemove,on:{mousedown:function(t){return t.preventDefault(),e.handleTagRemove(u,t)}}},[t("span",{class:e.classList.tagRemoveIcon})])])],{option:u,handleTagRemove:e.handleTagRemove,disabled:e.disabled})})),e._v(" "),t("div",{class:e.classList.tagsSearchWrapper},[t("span",{class:e.classList.tagsSearchCopy},[e._v(e._s(e.search))]),e._v(" "),e.searchable&&!e.disabled?t("input",{ref:"input",class:e.classList.tagsSearch,attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}}):e._e()])],2)]:e._e(),e._v(" "),"single"==e.mode&&e.hasSelected&&!e.search&&e.iv?[e._t("singlelabel",[t("div",{class:e.classList.singleLabel},[e._v("\n "+e._s(e.iv[e.label])+"\n ")])],{value:e.iv})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[t("div",{class:e.classList.multipleLabel},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.iv})]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[t("div",{class:e.classList.placeholder},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),e.busy?e._t("spinner",[t("span",{class:e.classList.spinner})]):e._e(),e._v(" "),e.hasSelected&&!e.disabled&&e.canClear&&!e.busy?e._t("clear",[t("span",{class:e.classList.clear,on:{mousedown:e.clear}},[t("span",{class:e.classList.clearIcon})])],{clear:e.clear}):e._e(),e._v(" "),e.caret?e._t("caret",[t("span",{class:e.classList.caret,on:{click:e.handleCaretClick}})]):e._e(),e._v(" "),e.resolving&&e.clearOnSearch?e._e():t("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[t("div",{class:e.classList.dropdown},[e._t("beforelist",null,{options:e.fo}),e._v(" "),t("ul",{class:e.classList.options},e._l(e.fo,(function(u,a,n){return t("li",{key:n,class:e.classList.option(u),attrs:{"data-pointed":e.isPointed(u)},on:{mouseenter:function(t){return e.setPointer(u)},click:function(t){return e.handleOptionClick(u)}}},[e._t("option",[t("span",[e._v(e._s(u[e.label]))])],{option:u,search:e.search})],2)})),0),e._v(" "),e.noOptions?e._t("nooptions",[t("div",{class:e.classList.noOptions,domProps:{innerHTML:e._s(e.noOptionsText)}})]):e._e(),e._v(" "),e.noResults?e._t("noresults",[t("div",{class:e.classList.noResults,domProps:{innerHTML:e._s(e.noResultsText)}})]):e._e(),e._v(" "),e._t("afterlist",null,{options:e.fo})],2)]),e._v(" "),e.required?t("input",{class:e.classList.fakeInput,attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e(),e._v(" "),e.nativeSupport?["single"==e.mode?t("input",{attrs:{type:"hidden",name:e.name},domProps:{value:void 0!==e.plainValue?e.plainValue:""}}):e._l(e.plainValue,(function(u,a){return t("input",{key:a,attrs:{type:"hidden",name:e.name+"[]"},domProps:{value:u}})}))]:e._e(),e._v(" "),t("div",{class:e.classList.spacer})],2)};d._withStripped=!0;return c({render:d,staticRenderFns:[]},undefined,v,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 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 s(l,s,c){var v=e(l),d=v.options,p=v.mode,f=v.trackBy,m=v.limit,h=v.hideSelected,b=v.createTag,g=v.label,y=v.appendNewTag,O=v.multipleLabel,_=v.object,S=v.loading,w=v.delay,P=v.resolveOnLoad,x=v.minChars,q=v.filterResults,T=v.clearOnSearch,L=v.clearOnSelect,k=v.valueProp,j=v.canDeselect,D=v.max,R=c.iv,C=c.ev,A=c.search,B=c.clearSearch,I=c.update,V=c.pointer,E=c.blur,N=t([]),H=t([]),F=t(!1),M=n((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,a=t[e];return o(n={},k.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={},k.value,e),o(n,f.value,e),o(n,g.value,e),n)})),N.value.length&&(t=t.concat(N.value)),t})),$=n((function(){var e=M.value;return z.value.length&&(e=z.value.concat(e)),A.value&&q.value&&(e=e.filter((function(e){return-1!==r(e[f.value]).indexOf(r(A.value))}))),h.value&&(e=e.filter((function(e){return!ie(e)}))),m.value>0&&(e=e.slice(0,m.value)),e})),U=n((function(){switch(p.value){case"single":return!u(R.value[k.value]);case"multiple":case"tags":return!u(R.value)&&R.value.length>0}})),W=n((function(){return void 0!==O&&void 0!==O.value?O.value(R.value):R.value&&R.value.length>1?"".concat(R.value.length," options selected"):"1 option selected"})),K=n((function(){return!M.value.length&&!F.value})),X=n((function(){return M.value.length>0&&0==$.value.length})),z=n((function(){var e;return!1!==b.value&&A.value?-1!==re(A.value)?[]:[(e={},o(e,k.value,A.value),o(e,g.value,A.value),o(e,f.value,A.value),e)]:[]})),G=n((function(){switch(p.value){case"single":return null;case"multiple":case"tags":return[]}})),J=n((function(){return S.value||F.value})),Q=function(e){switch("object"!==i(e)&&(e=ue(e)),p.value){case"single":I(e);break;case"multiple":case"tags":I(R.value.concat(e))}s.emit("select",Z(e),e)},Y=function(e){switch("object"!==i(e)&&(e=ue(e)),p.value){case"single":te();break;case"tags":case"multiple":I(R.value.filter((function(t){return t[k.value]!=e[k.value]})))}s.emit("deselect",Z(e),e)},Z=function(e){return _.value?e:e[k.value]},ee=function(e){Y(e)},te=function(){s.emit("clear"),I(G.value)},ne=function(e){switch(p.value){case"single":return!u(R.value)&&R.value[k.value]==e[k.value];case"tags":case"multiple":return!u(R.value)&&-1!==R.value.map((function(e){return e[k.value]})).indexOf(e[k.value])}},ae=function(e){return!0===e.disabled},le=function(){return!(void 0===D||-1===D.value||!U.value&&D.value>0)&&R.value.length>=D.value},ue=function(e){return M.value[M.value.map((function(e){return String(e[k.value])})).indexOf(String(e))]},re=function(e){return M.value.map((function(e){return r(e[f.value])})).indexOf(r(e))},ie=function(e){return"tags"===p.value&&h.value&&ne(e)},oe=function(e){N.value.push(e)},se=function(){u(C.value)||(R.value=ve(C.value))},ce=function(e){F.value=!0,d.value(A.value).then((function(t){H.value=t,"function"==typeof e&&e(t),F.value=!1}))},ve=function(e){return u(e)?"single"===p.value?{}:[]:_.value?e:"single"===p.value?ue(e)||{}:e.filter((function(e){return!!ue(e)})).map((function(e){return ue(e)}))};if("single"!==p.value&&!u(C.value)&&!Array.isArray(C.value))throw new Error('v-model must be an array when using "'.concat(p.value,'" mode'));return d&&"function"==typeof d.value?P.value?ce(se):1==_.value&&se():(H.value=d.value,se()),w.value>-1&&a(A,(function(e){e.length<x.value||(F.value=!0,T.value&&(H.value=[]),setTimeout((function(){e==A.value&&d.value(A.value).then((function(t){e==A.value&&(H.value=t,V.value=$.value.filter((function(e){return!0!==e.disabled}))[0]||null,F.value=!1)}))}),w.value))}),{flush:"sync"}),a(C,(function(e){var t,n,a;if(u(e))R.value=ve(e);else switch(p.value){case"single":(_.value?e[k.value]!=R.value[k.value]:e!=R.value[k.value])&&(R.value=ve(e));break;case"multiple":case"tags":t=_.value?e.map((function(e){return e[k.value]})):e,n=R.value.map((function(e){return e[k.value]})),a=n.slice().sort(),t.length===n.length&&t.slice().sort().every((function(e,t){return e===a[t]}))||(R.value=ve(e))}}),{deep:!0}),"function"!=typeof l.options&&a(d,(function(e,t){H.value=l.options,Object.keys(R.value).length||se(),function(){if(U.value)if("single"===p.value){var e=ue(R.value[k.value])[g.value];R.value[g.value]=e,_.value&&(C.value[g.value]=e)}else R.value.forEach((function(e,t){var n=ue(R.value[t][k.value])[g.value];R.value[t][g.value]=n,_.value&&(C.value[t][g.value]=n)}))}()})),{fo:$,filteredOptions:$,hasSelected:U,multipleLabelText:W,eo:M,extendedOptions:M,noOptions:K,noResults:X,resolving:F,busy:J,select:Q,deselect:Y,remove:ee,clear:te,isSelected:ne,isDisabled:ae,isMax:le,getOption:ue,handleOptionClick:function(e){if(!ae(e))switch(p.value){case"single":if(ne(e))return void(j.value&&Y(e));E(),Q(e);break;case"multiple":if(ne(e))return void Y(e);if(le())return;Q(e),L.value&&B();break;case"tags":if(ne(e))return void Y(e);if(le())return;void 0===ue(e[k.value])&&b.value&&(s.emit("tag",e[k.value]),y.value&&oe(e),B()),L.value&&B(),Q(e)}},handleTagRemove:function(e,t){0===t.button?ee(e):t.preventDefault()},refreshOptions:function(e){ce(e)},resolveOptions:ce}}function c(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,t){if(!e)return;if("string"==typeof e)return v(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 v(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 v(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 d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(t,a,l){var u=e(t),r=u.disabled,i=u.openDirection,o=l.isOpen,s=l.isPointed,c=l.isSelected,v=l.isDisabled,f=l.isActive,m=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?d(Object(n),!0).forEach((function(t){p(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearch:"multiselect-tags-search",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},u.classes.value);return{classList:n((function(){return{container:[m.container].concat(r.value?m.containerDisabled:[]).concat(o.value&&"top"===i.value?m.containerOpenTop:[]).concat(o.value&&"top"!==i.value?m.containerOpen:[]).concat(f.value?m.containerActive:[]),spacer:m.spacer,singleLabel:m.singleLabel,multipleLabel:m.multipleLabel,search:m.search,tags:m.tags,tag:[m.tag].concat(r.value?m.tagDisabled:[]),tagRemove:m.tagRemove,tagRemoveIcon:m.tagRemoveIcon,tagsSearch:m.tagsSearch,placeholder:m.placeholder,caret:[m.caret].concat(o.value?m.caretOpen:[]),clear:m.clear,clearIcon:m.clearIcon,spinner:m.spinner,dropdown:[m.dropdown].concat("top"===i.value?m.dropdownTop:[]),options:[m.options].concat("top"===i.value?m.optionsTop:[]),option:function(e){var t=[m.option];return s(e)?t.push(c(e)?m.optionSelectedPointed:m.optionPointed):c(e)?t.push(v(e)?m.optionSelectedDisabled:m.optionSelected):v(e)&&t.push(m.optionDisabled),t},noOptions:m.noOptions,noResults:m.noResults,fakeInput:m.fakeInput}}))}}function m(e,t,n,a,l,u,r,i,o,s){"boolean"!=typeof r&&(o=i,i=r,r=!1);var c,v="function"==typeof n?n.options:n;if(e&&e.render&&(v.render=e.render,v.staticRenderFns=e.staticRenderFns,v._compiled=!0,l&&(v.functional=!0)),a&&(v._scopeId=a),u?(c=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)},v._ssrRegister=c):t&&(c=r?function(e){t.call(this,s(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,i(e))}),c)if(v.functional){var d=v.render;v.render=function(e,t){return c.call(t),d(e,t)}}else{var p=v.beforeCreate;v.beforeCreate=p?[].concat(p,c):[c]}return n}const h={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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:[String,Number],required:!1,default:"10rem"},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})}},setup(r,i){const o=function(a,l){var u=e(a),r=u.value,i=u.modelValue,o=u.mode,s=u.valueProp,c=t("single"!==o.value?[]:{}),v=void 0!==l.expose?i:r,d=n((function(){return"single"===o.value?c.value[s.value]:c.value.map((function(e){return e[s.value]}))})),p=n((function(){return"single"!==o.value?c.value.map((function(e){return e[s.value]})).join(","):c.value[s.value]}));return{iv:c,internalValue:c,ev:v,externalValue:v,textValue:p,plainValue:d}}(r,i),v={pointer:t(null)},d=function(a,l,u){var r=e(a),i=r.maxHeight,o=r.disabled,s=t(!1),c=n((function(){return"number"==typeof i.value?"".concat(i.value,"px"):i.value}));return{isOpen:s,contentMaxHeight:c,open:function(){s.value||o.value||(s.value=!0,l.emit("open"))},close:function(){s.value&&(s.value=!1,l.emit("close"))}}}(r,i),p=function(t,n,a){var l=e(t),r=l.object,i=l.valueProp,o=l.mode,s=a.iv,c=function(e){return r.value||u(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},v=function(e){return u(e)?"single"===o.value?{}:[]:e};return{update:function(e){s.value=v(e);var t=c(e);n.emit("change",t),n.emit("input",t),n.emit("update:modelValue",t)}}}(r,i,{iv:o.iv}),m=function(l,u,r){var i=e(l).mode,o=r.iv,s=t(null),c=t(null),v=n((function(){return s.value?"".concat(d.value,"px"):"tags"===i.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"})),d=n((function(){var e=document.createElement("span");e.innerHTML=s.value.replace(/ /g," "),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",document.body.append(e);var t=e.offsetWidth;return e.remove(),t}));return a(s,(function(e){u.emit("search-change",e)})),{search:s,input:c,tagsSearchWidth:v,clearSearch:function(){s.value=""},handleSearchInput:function(e){s.value=e.target.value}}}(r,i,{iv:o.iv}),h=function(a,l,u){var r=e(a),i=r.searchable,o=r.disabled,s=u.input,c=u.open,v=u.close,d=t(null),p=t(!1),f=n((function(){return i.value?-1:0}));return{multiselect:d,tabindex:f,isActive:p,blur:function(){i.value&&s.value.blur(),d.value.blur()},handleFocus:function(){i.value&&!o.value&&s.value.focus()},activate:function(){o.value||(p.value=!0,c())},deactivate:function(){p.value=!1,v()}}}(r,0,{input:m.input,open:d.open,close:d.close}),b=s(r,i,{ev:o.ev,iv:o.iv,search:m.search,clearSearch:m.clearSearch,update:p.update,pointer:v.pointer,blur:h.blur}),g=function(t,u,r){var i=e(t),o=i.valueProp,s=i.showOptions,c=i.searchable,v=r.fo,d=r.handleOptionClick,p=r.search,f=r.pointer,m=r.multiselect,h=n((function(){return v.value.filter((function(e){return!0!==e.disabled}))})),b=function(e){!s.value||null!==e&&e.disabled||(f.value=e)},g=function(){b(h.value[0]||null)},y=function(){b(null)},O=function(){var e=m.value.querySelector("[data-pointed]");if(e){var t=e.parentElement.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(p,(function(e){c.value&&(e.length?g():y())})),{pointer:f,isPointed:function(e){return!!f.value&&f.value[o.value]==e[o.value]},setPointer:b,setPointerFirst:g,clearPointer:y,selectPointer:function(){f.value&&!0!==f.value.disabled&&d(f.value)},forwardPointer:function(){if(null===f.value)b(h.value[0]||null);else{var e=h.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])+1;h.value.length<=e&&(e=0),b(h.value[e]||null)}l((function(){O()}))},backwardPointer:function(){if(null===f.value)b(h.value[h.value.length-1]||null);else{var e=h.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])-1;e<0&&(e=h.value.length-1),b(h.value[e]||null)}l((function(){O()}))}}}(r,0,{fo:b.fo,handleOptionClick:b.handleOptionClick,search:m.search,pointer:v.pointer,multiselect:h.multiselect}),y=function(t,n,a){var l=e(t),u=l.mode,r=l.addTagOn,i=l.createTag,o=l.openDirection,s=l.searchable,v=a.iv,d=a.update,p=a.search,f=a.selectPointer,m=a.backwardPointer,h=a.forwardPointer,b=a.blur;return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===u.value)return;if(s.value&&-1===[null,""].indexOf(p.value))return;if(0===v.value.length)return;d(c(v.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===u.value&&-1===r.value.indexOf("enter"))return;f();break;case 27:b();break;case 32:if("tags"!==u.value&&s.value)return;if("tags"===u.value&&-1===r.value.indexOf("space"))return;e.preventDefault(),f();break;case 38:e.preventDefault(),"top"===o.value?h():m();break;case 40:e.preventDefault(),"top"===o.value?m():h();break;case 186:if("tags"!==u.value)return;if(-1===r.value.indexOf(";")||!i.value)return;f(),e.preventDefault();break;case 188:if("tags"!==u.value)return;if(-1===r.value.indexOf(",")||!i.value)return;f(),e.preventDefault()}}}}(r,0,{iv:o.iv,update:p.update,search:m.search,selectPointer:g.selectPointer,backwardPointer:g.backwardPointer,forwardPointer:g.forwardPointer,blur:h.blur}),O=f(r,0,{isOpen:d.isOpen,isPointed:g.isPointed,isSelected:b.isSelected,isDisabled:b.isDisabled,isActive:h.isActive});return{...o,...d,...h,...v,...p,...m,...b,...g,...y,...O}}};var b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",class:e.classList.container,attrs:{tabindex:e.tabindex,id:e.id},on:{focusin:e.activate,focusout:e.deactivate,keydown:e.handleKeydown,focus:e.handleFocus}},["tags"!==e.mode&&e.searchable&&!e.disabled?[n("input",{ref:"input",class:e.classList.search,attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}})]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{class:e.classList.tags},[e._l(e.iv,(function(t,a,l){return e._t("tag",[n("div",{key:l,class:e.classList.tag},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("span",{class:e.classList.tagRemove,on:{mousedown:function(n){return n.preventDefault(),e.handleTagRemove(t,n)}}},[n("span",{class:e.classList.tagRemoveIcon})])])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})})),e._v(" "),e.searchable&&!e.disabled?n("input",{ref:"input",class:e.classList.tagsSearch,style:{width:e.tagsSearchWidth},attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}}):e._e()],2)]:e._e(),e._v(" "),"single"==e.mode&&e.hasSelected&&!e.search&&e.iv?[e._t("singlelabel",[n("div",{class:e.classList.singleLabel},[e._v("\n "+e._s(e.iv[e.label])+"\n ")])],{value:e.iv})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[n("div",{class:e.classList.multipleLabel},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.iv})]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[n("div",{class:e.classList.placeholder},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),e.busy?e._t("spinner",[n("span",{class:e.classList.spinner})]):e._e(),e._v(" "),e.hasSelected&&!e.disabled&&e.canClear&&!e.busy?e._t("clear",[n("span",{class:e.classList.clear,on:{mousedown:e.clear}},[n("span",{class:e.classList.clearIcon})])],{clear:e.clear}):e._e(),e._v(" "),e.caret?e._t("caret",[n("span",{class:e.classList.caret})]):e._e(),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"}],class:e.classList.dropdown,style:{maxHeight:e.contentMaxHeight}},[e._t("beforelist",null,{options:e.fo}),e._v(" "),n("ul",{class:e.classList.options},e._l(e.fo,(function(t,a,l){return n("li",{key:l,class:e.classList.option(t),attrs:{"data-pointed":e.isPointed(t)},on:{mouseenter:function(n){return e.setPointer(t)},click:function(n){return e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),0),e._v(" "),e.noOptions?e._t("nooptions",[n("div",{class:e.classList.noOptions,domProps:{innerHTML:e._s(e.noOptionsText)}})]):e._e(),e._v(" "),e.noResults?e._t("noresults",[n("div",{class:e.classList.noResults,domProps:{innerHTML:e._s(e.noResultsText)}})]):e._e(),e._v(" "),e._t("afterlist",null,{options:e.fo})],2)]),e._v(" "),e.required?n("input",{class:e.classList.fakeInput,attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e(),e._v(" "),e.nativeSupport?["single"==e.mode?n("input",{attrs:{type:"hidden",name:e.name},domProps:{value:void 0!==e.plainValue?e.plainValue:""}}):e._l(e.plainValue,(function(t,a){return n("input",{key:a,attrs:{type:"hidden",name:e.name+"[]"},domProps:{value:t}})}))]:e._e(),e._v(" "),n("div",{class:e.classList.spacer})],2)};b._withStripped=!0;const g=m({render:b,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);export default g; | ||
import{toRefs as e,ref as u,computed as t,watch as a,nextTick as n}from"@vue/composition-api";function l(e){return-1!==[null,void 0,!1].indexOf(e)}function r(e){var u=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return u?String(e).toLowerCase().trim():String(e).normalize("NFD").replace(/(?:[\^`\xA8\xAF\xB4\xB7\xB8\u02B0-\u034E\u0350-\u0357\u035D-\u0362\u0374\u0375\u037A\u0384\u0385\u0483-\u0487\u0559\u0591-\u05A1\u05A3-\u05BD\u05BF\u05C1\u05C2\u05C4\u064B-\u0652\u0657\u0658\u06DF\u06E0\u06E5\u06E6\u06EA-\u06EC\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F5\u0818\u0819\u08E3-\u08FE\u093C\u094D\u0951-\u0954\u0971\u09BC\u09CD\u0A3C\u0A4D\u0ABC\u0ACD\u0AFD-\u0AFF\u0B3C\u0B4D\u0B55\u0BCD\u0C4D\u0CBC\u0CCD\u0D3B\u0D3C\u0D4D\u0DCA\u0E47-\u0E4C\u0E4E\u0EBA\u0EC8-\u0ECC\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F82-\u0F84\u0F86\u0F87\u0FC6\u1037\u1039\u103A\u1063\u1064\u1069-\u106D\u1087-\u108D\u108F\u109A\u109B\u135D-\u135F\u17C9-\u17D3\u17DD\u1939-\u193B\u1A75-\u1A7C\u1A7F\u1AB0-\u1ABD\u1B34\u1B44\u1B6B-\u1B73\u1BAA\u1BAB\u1C36\u1C37\u1C78-\u1C7D\u1CD0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1D2C-\u1D6A\u1DC4-\u1DCF\u1DF5-\u1DF9\u1DFD-\u1DFF\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2CEF-\u2CF1\u2E2F\u302A-\u302F\u3099-\u309C\u30FC\uA66F\uA67C\uA67D\uA67F\uA69C\uA69D\uA6F0\uA6F1\uA700-\uA721\uA788-\uA78A\uA7F8\uA7F9\uA8C4\uA8E0-\uA8F1\uA92B-\uA92E\uA953\uA9B3\uA9C0\uA9E5\uAA7B-\uAA7D\uAABF-\uAAC2\uAAF6\uAB5B-\uAB5F\uAB69-\uAB6B\uABEC\uABED\uFB1E\uFE20-\uFE2F\uFF3E\uFF40\uFF70\uFF9E\uFF9F\uFFE3]|\uD800\uDEE0|\uD802[\uDEE5\uDEE6]|\uD803[\uDD22-\uDD27\uDF46-\uDF50]|\uD804[\uDCB9\uDCBA\uDD33\uDD34\uDD73\uDDC0\uDDCA-\uDDCC\uDE35\uDE36\uDEE9\uDEEA\uDF3C\uDF4D\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC42\uDC46\uDCC2\uDCC3\uDDBF\uDDC0\uDE3F\uDEB6\uDEB7\uDF2B]|\uD806[\uDC39\uDC3A\uDD3D\uDD3E\uDD43\uDDE0\uDE34\uDE47\uDE99]|\uD807[\uDC3F\uDD42\uDD44\uDD45\uDD97]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF8F-\uDF9F\uDFF0\uDFF1]|\uD834[\uDD67-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD]|\uD838[\uDD30-\uDD36\uDEEC-\uDEEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD46\uDD48-\uDD4A])/g,"").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,u,t){return u in e?Object.defineProperty(e,u,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[u]=t,e}function s(n,s,c){var v=e(n),d=v.options,p=v.mode,f=v.trackBy,D=v.limit,m=v.hideSelected,h=v.createTag,g=v.label,b=v.appendNewTag,y=v.multipleLabel,F=v.object,C=v.loading,A=v.delay,O=v.resolveOnLoad,_=v.minChars,S=v.filterResults,B=v.clearOnSearch,E=v.clearOnSelect,w=v.valueProp,P=v.canDeselect,q=v.max,L=v.strict,k=c.iv,x=c.ev,T=c.search,j=c.clearSearch,R=c.update,I=c.pointer,V=c.blur,N=u([]),H=u([]),$=u(!1),M=t((function(){var e,u=H.value||[];return e=u,"[object Object]"===Object.prototype.toString.call(e)&&(u=Object.keys(u).map((function(e){var t,a=u[e];return o(t={},w.value,e),o(t,f.value,a),o(t,g.value,a),t}))),u=u.map((function(e,u){var t;return"object"===i(e)?e:(o(t={},w.value,e),o(t,f.value,e),o(t,g.value,e),t)})),N.value.length&&(u=u.concat(N.value)),u})),W=t((function(){var e=M.value;return G.value.length&&(e=G.value.concat(e)),T.value&&S.value&&(e=e.filter((function(e){return-1!==r(e[f.value],L.value).indexOf(r(T.value,L.value))}))),m.value&&(e=e.filter((function(e){return!oe(e)}))),D.value>0&&(e=e.slice(0,D.value)),e})),U=t((function(){switch(p.value){case"single":return!l(k.value[w.value]);case"multiple":case"tags":return!l(k.value)&&k.value.length>0}})),K=t((function(){return void 0!==y&&void 0!==y.value?y.value(k.value):k.value&&k.value.length>1?"".concat(k.value.length," options selected"):"1 option selected"})),X=t((function(){return!M.value.length&&!$.value})),z=t((function(){return M.value.length>0&&0==W.value.length})),G=t((function(){var e;return!1!==h.value&&T.value?-1!==ie(T.value)?[]:[(e={},o(e,w.value,T.value),o(e,g.value,T.value),o(e,f.value,T.value),e)]:[]})),J=t((function(){switch(p.value){case"single":return null;case"multiple":case"tags":return[]}})),Q=t((function(){return C.value||$.value})),Y=function(e){switch("object"!==i(e)&&(e=re(e)),p.value){case"single":R(e);break;case"multiple":case"tags":R(k.value.concat(e))}s.emit("select",ee(e),e)},Z=function(e){switch("object"!==i(e)&&(e=re(e)),p.value){case"single":te();break;case"tags":case"multiple":R(k.value.filter((function(u){return u[w.value]!=e[w.value]})))}s.emit("deselect",ee(e),e)},ee=function(e){return F.value?e:e[w.value]},ue=function(e){Z(e)},te=function(){s.emit("clear"),R(J.value)},ae=function(e){switch(p.value){case"single":return!l(k.value)&&k.value[w.value]==e[w.value];case"tags":case"multiple":return!l(k.value)&&-1!==k.value.map((function(e){return e[w.value]})).indexOf(e[w.value])}},ne=function(e){return!0===e.disabled},le=function(){return!(void 0===q||-1===q.value||!U.value&&q.value>0)&&k.value.length>=q.value},re=function(e){return M.value[M.value.map((function(e){return String(e[w.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&&m.value&&ae(e)},se=function(e){N.value.push(e)},ce=function(){l(x.value)||(k.value=de(x.value))},ve=function(e){$.value=!0,d.value(T.value).then((function(u){H.value=u,"function"==typeof e&&e(u),$.value=!1}))},de=function(e){return l(e)?"single"===p.value?{}:[]:F.value?e:"single"===p.value?re(e)||{}:e.filter((function(e){return!!re(e)})).map((function(e){return re(e)}))};if("single"!==p.value&&!l(x.value)&&!Array.isArray(x.value))throw new Error('v-model must be an array when using "'.concat(p.value,'" mode'));return d&&"function"==typeof d.value?O.value?ve(ce):1==F.value&&ce():(H.value=d.value,ce()),A.value>-1&&a(T,(function(e){e.length<_.value||($.value=!0,B.value&&(H.value=[]),setTimeout((function(){e==T.value&&d.value(T.value).then((function(u){e==T.value&&(H.value=u,I.value=W.value.filter((function(e){return!0!==e.disabled}))[0]||null,$.value=!1)}))}),A.value))}),{flush:"sync"}),a(x,(function(e){var u,t,a;if(l(e))k.value=de(e);else switch(p.value){case"single":(F.value?e[w.value]!=k.value[w.value]:e!=k.value[w.value])&&(k.value=de(e));break;case"multiple":case"tags":u=F.value?e.map((function(e){return e[w.value]})):e,t=k.value.map((function(e){return e[w.value]})),a=t.slice().sort(),u.length===t.length&&u.slice().sort().every((function(e,u){return e===a[u]}))||(k.value=de(e))}}),{deep:!0}),"function"!=typeof n.options&&a(d,(function(e,u){H.value=n.options,Object.keys(k.value).length||ce(),function(){if(U.value)if("single"===p.value){var e=re(k.value[w.value])[g.value];k.value[g.value]=e,F.value&&(x.value[g.value]=e)}else k.value.forEach((function(e,u){var t=re(k.value[u][w.value])[g.value];k.value[u][g.value]=t,F.value&&(x.value[u][g.value]=t)}))}()})),{fo:W,filteredOptions:W,hasSelected:U,multipleLabelText:K,eo:M,extendedOptions:M,noOptions:X,noResults:z,resolving:$,busy:Q,select:Y,deselect:Z,remove:ue,clear:te,isSelected:ae,isDisabled:ne,isMax:le,getOption:re,handleOptionClick:function(e){if(!ne(e))switch(p.value){case"single":if(ae(e))return void(P.value&&Z(e));V(),Y(e);break;case"multiple":if(ae(e))return void Z(e);if(le())return;Y(e),E.value&&j();break;case"tags":if(ae(e))return void Z(e);if(le())return;void 0===re(e[w.value])&&h.value&&(s.emit("tag",e[w.value]),b.value&&se(e),j()),E.value&&j(),Y(e)}},handleTagRemove:function(e,u){0===u.button?ue(e):u.preventDefault()},refreshOptions:function(e){ve(e)},resolveOptions:ve}}function c(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,u){if(!e)return;if("string"==typeof e)return v(e,u);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,u)}(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,u){(null==u||u>e.length)&&(u=e.length);for(var t=0,a=new Array(u);t<u;t++)a[t]=e[t];return a}function d(e,u){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);u&&(a=a.filter((function(u){return Object.getOwnPropertyDescriptor(e,u).enumerable}))),t.push.apply(t,a)}return t}function p(e,u,t){return u in e?Object.defineProperty(e,u,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[u]=t,e}function f(u,a,n){var l=e(u),r=l.disabled,i=l.openDirection,o=l.showOptions,s=n.isOpen,c=n.isPointed,v=n.isSelected,f=n.isDisabled,D=n.isActive,m=function(e){for(var u=1;u<arguments.length;u++){var t=null!=arguments[u]?arguments[u]:{};u%2?d(Object(t),!0).forEach((function(u){p(e,u,t[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach((function(u){Object.defineProperty(e,u,Object.getOwnPropertyDescriptor(t,u))}))}return e}({container:"multiselect",containerDisabled:"is-disabled",containerOpen:"is-open",containerOpenTop:"is-open-top",containerActive:"is-active",singleLabel:"multiselect-single-label",multipleLabel:"multiselect-multiple-label",search:"multiselect-search",tags:"multiselect-tags",tag:"multiselect-tag",tagDisabled:"is-disabled",tagRemove:"multiselect-tag-remove",tagRemoveIcon:"multiselect-tag-remove-icon",tagsSearchWrapper:"multiselect-tags-search-wrapper",tagsSearch:"multiselect-tags-search",tagsSearchCopy:"multiselect-tags-search-copy",placeholder:"multiselect-placeholder",caret:"multiselect-caret",caretOpen:"is-open",clear:"multiselect-clear",clearIcon:"multiselect-clear-icon",spinner:"multiselect-spinner",dropdown:"multiselect-dropdown",dropdownTop:"is-top",dropdownHidden:"is-hidden",options:"multiselect-options",optionsTop:"is-top",option:"multiselect-option",optionPointed:"is-pointed",optionSelected:"is-selected",optionDisabled:"is-disabled",optionSelectedPointed:"is-selected is-pointed",optionSelectedDisabled:"is-selected is-disabled",noOptions:"multiselect-no-options",noResults:"multiselect-no-results",fakeInput:"multiselect-fake-input",spacer:"multiselect-spacer"},l.classes.value);return{classList:t((function(){return{container:[m.container].concat(r.value?m.containerDisabled:[]).concat(s.value&&"top"===i.value&&o.value?m.containerOpenTop:[]).concat(s.value&&"top"!==i.value&&o.value?m.containerOpen:[]).concat(D.value?m.containerActive:[]),spacer:m.spacer,singleLabel:m.singleLabel,multipleLabel:m.multipleLabel,search:m.search,tags:m.tags,tag:[m.tag].concat(r.value?m.tagDisabled:[]),tagRemove:m.tagRemove,tagRemoveIcon:m.tagRemoveIcon,tagsSearchWrapper:m.tagsSearchWrapper,tagsSearch:m.tagsSearch,tagsSearchCopy:m.tagsSearchCopy,placeholder:m.placeholder,caret:[m.caret].concat(s.value?m.caretOpen:[]),clear:m.clear,clearIcon:m.clearIcon,spinner:m.spinner,dropdown:[m.dropdown].concat("top"===i.value?m.dropdownTop:[]).concat(s.value&&o.value?[]:m.dropdownHidden),options:[m.options].concat("top"===i.value?m.optionsTop:[]),option:function(e){var u=[m.option];return c(e)?u.push(v(e)?m.optionSelectedPointed:m.optionPointed):v(e)?u.push(f(e)?m.optionSelectedDisabled:m.optionSelected):f(e)&&u.push(m.optionDisabled),u},noOptions:m.noOptions,noResults:m.noResults,fakeInput:m.fakeInput}}))}}function D(e,u,t,a,n,l,r,i,o,s){"boolean"!=typeof r&&(o=i,i=r,r=!1);var c,v="function"==typeof t?t.options:t;if(e&&e.render&&(v.render=e.render,v.staticRenderFns=e.staticRenderFns,v._compiled=!0,n&&(v.functional=!0)),a&&(v._scopeId=a),l?(c=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__),u&&u.call(this,o(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},v._ssrRegister=c):u&&(c=r?function(e){u.call(this,s(e,this.$root.$options.shadowRoot))}:function(e){u.call(this,i(e))}),c)if(v.functional){var d=v.render;v.render=function(e,u){return c.call(u),d(e,u)}}else{var p=v.beforeCreate;v.beforeCreate=p?[].concat(p,c):[c]}return t}const m={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue","change","clear"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1,default:()=>[]},id:{type:[String,Number],required:!1},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},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},canClear:{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},openDirection:{type:String,required:!1,default:"bottom"},nativeSupport:{type:Boolean,required:!1,default:!1},classes:{type:Object,required:!1,default:()=>({})},strict:{type:Boolean,required:!1,default:!0}},setup(r,i){const o=function(a,n){var l=e(a),r=l.value,i=l.modelValue,o=l.mode,s=l.valueProp,c=u("single"!==o.value?[]:{}),v=void 0!==n.expose?i:r,d=t((function(){return"single"===o.value?c.value[s.value]:c.value.map((function(e){return e[s.value]}))})),p=t((function(){return"single"!==o.value?c.value.map((function(e){return e[s.value]})).join(","):c.value[s.value]}));return{iv:c,internalValue:c,ev:v,externalValue:v,textValue:p,plainValue:d}}(r,i),v={pointer:u(null)},d=function(t,a,n){var l=e(t),r=(l.maxHeight,l.disabled),i=u(!1);return{isOpen:i,open:function(){i.value||r.value||(i.value=!0,a.emit("open"))},close:function(){i.value&&(i.value=!1,a.emit("close"))}}}(r,i),p=function(e,t,n){var l=u(null),r=u(null);return a(l,(function(e){t.emit("search-change",e)})),{search:l,input:r,clearSearch:function(){l.value=""},handleSearchInput:function(e){l.value=e.target.value}}}(0,i),D=function(u,t,a){var n=e(u),r=n.object,i=n.valueProp,o=n.mode,s=a.iv,c=function(e){return r.value||l(e)?e:Array.isArray(e)?e.map((function(e){return e[i.value]})):e[i.value]},v=function(e){return l(e)?"single"===o.value?{}:[]:e};return{update:function(e){s.value=v(e);var u=c(e);t.emit("change",u),t.emit("input",u),t.emit("update:modelValue",u)}}}(r,i,{iv:o.iv}),m=function(a,n,l){var r=e(a),i=r.searchable,o=r.disabled,s=l.input,c=l.open,v=l.close,d=u(null),p=u(!1),f=t((function(){return i.value||o.value?-1:0})),D=function(){i.value&&s.value.blur(),d.value.blur()},m=function(){p.value=!1,v()};return{multiselect:d,tabindex:f,isActive:p,blur:D,handleFocus:function(){i.value&&!o.value&&s.value.focus()},activate:function(){o.value||(p.value=!0,c())},deactivate:m,handleCaretClick:function(){m(),D()}}}(r,0,{input:p.input,open:d.open,close:d.close}),h=s(r,i,{ev:o.ev,iv:o.iv,search:p.search,clearSearch:p.clearSearch,update:D.update,pointer:v.pointer,blur:m.blur}),g=function(u,l,r){var i=e(u),o=i.valueProp,s=i.showOptions,c=i.searchable,v=r.fo,d=r.handleOptionClick,p=r.search,f=r.pointer,D=r.multiselect,m=t((function(){return v.value.filter((function(e){return!0!==e.disabled}))})),h=function(e){void 0===e||null!==e&&e.disabled||(f.value=e)},g=function(){h(m.value[0]||null)},b=function(){h(null)},y=function(){var e=D.value.querySelector("[data-pointed]");if(e){var u=e.parentElement.parentElement;e.offsetTop+e.offsetHeight>u.clientHeight+u.scrollTop&&(u.scrollTop=e.offsetTop+e.offsetHeight-u.clientHeight),e.offsetTop<u.scrollTop&&(u.scrollTop=e.offsetTop)}};return a(p,(function(e){c.value&&(e.length&&s.value?g():b())})),{pointer:f,isPointed:function(e){return!!f.value&&f.value[o.value]==e[o.value]},setPointer:h,setPointerFirst:g,clearPointer:b,selectPointer:function(){f.value&&!0!==f.value.disabled&&d(f.value)},forwardPointer:function(){if(null===f.value)h(m.value[0]||null);else{var e=m.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])+1;m.value.length<=e&&(e=0),h(m.value[e]||null)}n((function(){y()}))},backwardPointer:function(){if(null===f.value)h(m.value[m.value.length-1]||null);else{var e=m.value.map((function(e){return e[o.value]})).indexOf(f.value[o.value])-1;e<0&&(e=m.value.length-1),h(m.value[e]||null)}n((function(){y()}))}}}(r,0,{fo:h.fo,handleOptionClick:h.handleOptionClick,search:p.search,pointer:v.pointer,multiselect:m.multiselect}),b=function(u,t,a){var n=e(u),l=n.mode,r=n.addTagOn,i=n.createTag,o=n.openDirection,s=n.searchable,v=n.showOptions,d=n.valueProp,p=a.iv,f=a.update,D=a.search,m=a.setPointer,h=a.selectPointer,g=a.backwardPointer,b=a.forwardPointer,y=a.blur,F=a.fo,C=function(){"tags"===l.value&&!v.value&&i.value&&s.value&&m(F.value[F.value.map((function(e){return e[d.value]})).indexOf(D.value)]),h()};return{handleKeydown:function(e){switch(e.keyCode){case 8:if("single"===l.value)return;if(s.value&&-1===[null,""].indexOf(D.value))return;if(0===p.value.length)return;f(c(p.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===l.value&&-1===r.value.indexOf("enter"))return;C();break;case 27:y();break;case 32:if("tags"!==l.value&&s.value)return;if("tags"===l.value&&-1===r.value.indexOf("space"))return;e.preventDefault(),C();break;case 38:if(e.preventDefault(),!v.value)return;"top"===o.value?b():g();break;case 40:if(e.preventDefault(),!v.value)return;"top"===o.value?g():b();break;case 186:if("tags"!==l.value)return;if(-1===r.value.indexOf(";")||!i.value)return;C(),e.preventDefault();break;case 188:if("tags"!==l.value)return;if(-1===r.value.indexOf(",")||!i.value)return;C(),e.preventDefault()}}}}(r,0,{iv:o.iv,update:D.update,search:p.search,setPointer:g.setPointer,selectPointer:g.selectPointer,backwardPointer:g.backwardPointer,forwardPointer:g.forwardPointer,blur:m.blur,fo:h.fo}),y=f(r,0,{isOpen:d.isOpen,isPointed:g.isPointed,isSelected:h.isSelected,isDisabled:h.isDisabled,isActive:m.isActive});return{...o,...d,...m,...v,...D,...p,...h,...g,...b,...y}}};var h=function(){var e=this,u=e.$createElement,t=e._self._c||u;return t("div",{ref:"multiselect",class:e.classList.container,attrs:{tabindex:e.tabindex,id:e.id},on:{focusin:e.activate,focusout:e.deactivate,keydown:e.handleKeydown,focus:e.handleFocus}},["tags"!==e.mode&&e.searchable&&!e.disabled?[t("input",{ref:"input",class:e.classList.search,attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}})]:e._e(),e._v(" "),"tags"==e.mode?[t("div",{class:e.classList.tags},[e._l(e.iv,(function(u,a,n){return e._t("tag",[t("div",{key:n,class:e.classList.tag},[e._v("\n "+e._s(u[e.label])+"\n "),e.disabled?e._e():t("span",{class:e.classList.tagRemove,on:{mousedown:function(t){return t.preventDefault(),e.handleTagRemove(u,t)}}},[t("span",{class:e.classList.tagRemoveIcon})])])],{option:u,handleTagRemove:e.handleTagRemove,disabled:e.disabled})})),e._v(" "),t("div",{class:e.classList.tagsSearchWrapper},[t("span",{class:e.classList.tagsSearchCopy},[e._v(e._s(e.search))]),e._v(" "),e.searchable&&!e.disabled?t("input",{ref:"input",class:e.classList.tagsSearch,attrs:{modelValue:e.search},domProps:{value:e.search},on:{input:e.handleSearchInput}}):e._e()])],2)]:e._e(),e._v(" "),"single"==e.mode&&e.hasSelected&&!e.search&&e.iv?[e._t("singlelabel",[t("div",{class:e.classList.singleLabel},[e._v("\n "+e._s(e.iv[e.label])+"\n ")])],{value:e.iv})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multiplelabel",[t("div",{class:e.classList.multipleLabel},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.iv})]:e._e(),e._v(" "),!e.placeholder||e.hasSelected||e.search?e._e():[e._t("placeholder",[t("div",{class:e.classList.placeholder},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),e.busy?e._t("spinner",[t("span",{class:e.classList.spinner})]):e._e(),e._v(" "),e.hasSelected&&!e.disabled&&e.canClear&&!e.busy?e._t("clear",[t("span",{class:e.classList.clear,on:{mousedown:e.clear}},[t("span",{class:e.classList.clearIcon})])],{clear:e.clear}):e._e(),e._v(" "),e.caret?e._t("caret",[t("span",{class:e.classList.caret,on:{click:e.handleCaretClick}})]):e._e(),e._v(" "),e.resolving&&e.clearOnSearch?e._e():t("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[t("div",{class:e.classList.dropdown},[e._t("beforelist",null,{options:e.fo}),e._v(" "),t("ul",{class:e.classList.options},e._l(e.fo,(function(u,a,n){return t("li",{key:n,class:e.classList.option(u),attrs:{"data-pointed":e.isPointed(u)},on:{mouseenter:function(t){return e.setPointer(u)},click:function(t){return e.handleOptionClick(u)}}},[e._t("option",[t("span",[e._v(e._s(u[e.label]))])],{option:u,search:e.search})],2)})),0),e._v(" "),e.noOptions?e._t("nooptions",[t("div",{class:e.classList.noOptions,domProps:{innerHTML:e._s(e.noOptionsText)}})]):e._e(),e._v(" "),e.noResults?e._t("noresults",[t("div",{class:e.classList.noResults,domProps:{innerHTML:e._s(e.noResultsText)}})]):e._e(),e._v(" "),e._t("afterlist",null,{options:e.fo})],2)]),e._v(" "),e.required?t("input",{class:e.classList.fakeInput,attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e(),e._v(" "),e.nativeSupport?["single"==e.mode?t("input",{attrs:{type:"hidden",name:e.name},domProps:{value:void 0!==e.plainValue?e.plainValue:""}}):e._l(e.plainValue,(function(u,a){return t("input",{key:a,attrs:{type:"hidden",name:e.name+"[]"},domProps:{value:u}})}))]:e._e(),e._v(" "),t("div",{class:e.classList.spacer})],2)};h._withStripped=!0;const g=D({render:h,staticRenderFns:[]},undefined,m,undefined,false,undefined,!1,void 0,void 0,void 0);export default g; |
{ | ||
"name": "@vueform/multiselect", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"private": false, | ||
"description": "Vue 3 multiselect component with tagging options & Tailwind support.", | ||
"description": "Vue 3 multiselect component with single select, multiselect and tagging options.", | ||
"license": "MIT", | ||
@@ -37,2 +37,3 @@ "author": "Adam Berecz <adam@vueform.com>", | ||
"@vue/compiler-sfc": "^3.0.4", | ||
"autoprefixer": "^10.3.1", | ||
"babel-core": "^7.0.0-bridge.0", | ||
@@ -42,2 +43,3 @@ "babel-jest": "^26.6.1", | ||
"flush-promises": "^1.0.2", | ||
"fraction.js": "^4.1.1", | ||
"jest": "^26.6.1", | ||
@@ -44,0 +46,0 @@ "jest-environment-jsdom-sixteen": "^1.0.3", |
@@ -25,3 +25,3 @@ <div align="center"> | ||
<h1>Vue 3 Multiselect with Tailwind support</h1> | ||
<h1>Vue 3 Multiselect</h1> | ||
@@ -52,4 +52,4 @@ <a href="https://vueform.com?ref=github" target="_blank"> | ||
* [@vueform/slider](https://github.com/vueform/slider) - Vue 3 slider component with tooltips & Tailwind support. | ||
* [@vueform/toggle](https://github.com/vueform/toggle) - Vue 3 toggle component with custom labels & Tailwind support. | ||
* [@vueform/slider](https://github.com/vueform/slider) - Vue 3 slider component with multihandles, tooltips merging and formatting. | ||
* [@vueform/toggle](https://github.com/vueform/toggle) - Vue 3 toggle component with labels, custom slots and styling options. | ||
@@ -59,3 +59,2 @@ ## Multiselect features | ||
* Vue 2 & 3 support | ||
* Tailwind & utility class support | ||
* No dependencies | ||
@@ -72,3 +71,6 @@ * 100% coverage | ||
* Events | ||
* CSS vars support | ||
* Tailwind & utility class support | ||
* Fully configurable | ||
* CSP compilant | ||
@@ -184,2 +186,8 @@ ## Demo | ||
--ms-placeholder-color: #9CA3AF; | ||
--ms-max-height: 10rem; | ||
--ms-spinner-color: #10B981; | ||
--ms-caret-color: #999999; | ||
--ms-clear-color: #999999; | ||
--ms-clear-color-hover: #000000; | ||
@@ -281,3 +289,3 @@ --ms-tag-font-size: 0.875rem; | ||
search: 'w-full absolute inset-0 outline-none appearance-none box-border border-0 text-base font-sans bg-white rounded pl-3.5', | ||
tags: 'flex-grow flex-shrink flex flex-wrap mt-1 pl-2', | ||
tags: 'flex-grow flex-shrink flex flex-wrap items-center mt-1 pl-2', | ||
tag: 'bg-green-500 text-white text-sm font-semibold py-0.5 pl-2 rounded mr-1 mb-1 flex items-center whitespace-nowrap', | ||
@@ -287,6 +295,8 @@ tagDisabled: 'pr-2 !bg-gray-400 text-white', | ||
tagRemoveIcon: 'bg-multiselect-remove bg-center bg-no-repeat opacity-30 inline-block w-3 h-3 group-hover:opacity-60', | ||
tagsSearch: 'h-full border-0 outline-none appearance-none p-0 text-base font-sans mx-1 mb-1 box-border flex-grow flex-shrink', | ||
tagsSearchWrapper: 'inline-block relative mx-1 mb-1 flex-grow flex-shrink h-full', | ||
tagsSearch: 'border-0 outline-none appearance-none p-0 text-base font-sans box-border absolute inset-0 w-full', | ||
tagsSearchCopy: 'invisible whitespace-pre-wrap inline-block h-px', | ||
placeholder: 'flex items-center h-full absolute left-0 top-0 pointer-events-none bg-transparent leading-snug pl-3.5 text-gray-400', | ||
caret: 'bg-multiselect-caret bg-center bg-no-repeat w-2.5 h-4 py-px box-content mr-3.5 relative z-10 opacity-40 flex-shrink-0 flex-grow-0 transition-transform transform', | ||
caretOpen: 'rotate-180', | ||
caret: 'bg-multiselect-caret bg-center bg-no-repeat w-2.5 h-4 py-px box-content mr-3.5 relative z-10 opacity-40 flex-shrink-0 flex-grow-0 transition-transform transform pointer-events-none', | ||
caretOpen: 'rotate-180 pointer-events-auto', | ||
clear: 'pr-3.5 relative z-10 opacity-40 transition duration-300 flex-shrink-0 flex-grow-0 flex hover:opacity-80', | ||
@@ -297,2 +307,3 @@ clearIcon: 'bg-multiselect-remove bg-center bg-no-repeat w-2.5 h-4 py-px box-content inline-block', | ||
dropdownTop: '-translate-y-full top-px bottom-auto flex-col-reverse rounded-b-none rounded-t', | ||
dropdownHidden: 'hidden', | ||
options: 'flex flex-col p-0 m-0 list-none', | ||
@@ -368,6 +379,6 @@ optionsTop: 'flex-col-reverse', | ||
| **caret** | `boolean` | `true` | Whether should display the caret symbol on the right. | | ||
| **maxHeight** | `string` | `10rem` | The maximum height of options list. | | ||
| **noOptionsText** | `string` | `'The list is empty'` | The text that should be displayed when options list is empty. | | ||
| **noResultsText** | `string` | `'No results found'` | The text that should be displayed when there are no search results. | | ||
| **openDirection** | `string` | `bottom` | Whether the option list should be displayed above or below the multiselect. Possible values: `top\|bottom` | | ||
| **strict** | `boolean` | `true` | Whether should regard accents/diacritics in search. | | ||
| **classes** | `object` | | An object of class names that gets merged with the default values. Default: `{`<br> `container: 'multiselect',`<br> `containerDisabled: 'is-disabled',`<br> `containerOpen: 'is-open',`<br> `containerOpenTop: 'is-open-top',`<br> `containerActive: 'is-active',`<br> `singleLabel: 'multiselect-single-label',`<br> `multipleLabel: 'multiselect-multiple-label',`<br> `search: 'multiselect-search',`<br> `tags: 'multiselect-tags',`<br> `tag: 'multiselect-tag',`<br> `tagDisabled: 'is-disabled',`<br> `tagRemove: 'multiselect-tag-remove',`<br> `tagRemoveIcon: 'multiselect-tag-remove-icon',`<br> `tagsSearch: 'multiselect-tags-search',`<br> `placeholder: 'multiselect-placeholder',`<br> `caret: 'multiselect-caret',`<br> `caretOpen: 'is-open',`<br> `clear: 'multiselect-clear',`<br> `clearIcon: 'multiselect-clear-icon',`<br> `spinner: 'multiselect-spinner',`<br> `dropdown: 'multiselect-dropdown',`<br> `dropdownTop: 'is-top',`<br> `options: 'multiselect-options',`<br> `optionsTop: 'is-top',`<br> `option: 'multiselect-option',`<br> `optionPointed: 'is-pointed',`<br> `optionSelected: 'is-selected',`<br> `optionDisabled: 'is-disabled',`<br> `optionSelectedPointed: 'is-selected is-pointed',`<br> `optionSelectedDisabled: 'is-selected is-disabled',`<br> `noOptions: 'multiselect-no-options',`<br> `noResults: 'multiselect-no-results',`<br> `fakeInput: 'multiselect-fake-input',`<br> `spacer: 'multiselect-spacer'`<br>`}` | | ||
@@ -374,0 +385,0 @@ |
@@ -6,3 +6,3 @@ import { computed, toRefs } from 'composition-api' | ||
const refs = toRefs(props) | ||
const { disabled, openDirection } = refs | ||
const { disabled, openDirection, showOptions } = refs | ||
@@ -31,3 +31,5 @@ // ============ DEPENDENCIES ============ | ||
tagRemoveIcon: 'multiselect-tag-remove-icon', | ||
tagsSearchWrapper: 'multiselect-tags-search-wrapper', | ||
tagsSearch: 'multiselect-tags-search', | ||
tagsSearchCopy: 'multiselect-tags-search-copy', | ||
placeholder: 'multiselect-placeholder', | ||
@@ -41,2 +43,3 @@ caret: 'multiselect-caret', | ||
dropdownTop: 'is-top', | ||
dropdownHidden: 'is-hidden', | ||
options: 'multiselect-options', | ||
@@ -63,4 +66,4 @@ optionsTop: 'is-top', | ||
.concat(disabled.value ? classes.containerDisabled : []) | ||
.concat(isOpen.value && openDirection.value === 'top' ? classes.containerOpenTop : []) | ||
.concat(isOpen.value && openDirection.value !== 'top' ? classes.containerOpen : []) | ||
.concat(isOpen.value && openDirection.value === 'top' && showOptions.value ? classes.containerOpenTop : []) | ||
.concat(isOpen.value && openDirection.value !== 'top' && showOptions.value ? classes.containerOpen : []) | ||
.concat(isActive.value ? classes.containerActive : []), | ||
@@ -76,3 +79,5 @@ spacer: classes.spacer, | ||
tagRemoveIcon: classes.tagRemoveIcon, | ||
tagsSearchWrapper: classes.tagsSearchWrapper, | ||
tagsSearch: classes.tagsSearch, | ||
tagsSearchCopy: classes.tagsSearchCopy, | ||
placeholder: classes.placeholder, | ||
@@ -85,3 +90,4 @@ caret: [classes.caret] | ||
dropdown: [classes.dropdown] | ||
.concat(openDirection.value === 'top' ? classes.dropdownTop : []), | ||
.concat(openDirection.value === 'top' ? classes.dropdownTop : []) | ||
.concat(!isOpen.value || !showOptions.value ? classes.dropdownHidden : []), | ||
options: [classes.options] | ||
@@ -88,0 +94,0 @@ .concat(openDirection.value === 'top' ? classes.optionsTop : []), |
@@ -11,8 +11,2 @@ import { ref, toRefs, computed } from 'composition-api' | ||
// ============== COMPUTED ============== | ||
const contentMaxHeight = computed(() => { | ||
return typeof maxHeight.value === 'number' ? `${maxHeight.value}px` : maxHeight.value | ||
}) | ||
// =============== METHODS ============== | ||
@@ -40,3 +34,2 @@ | ||
isOpen, | ||
contentMaxHeight, | ||
open, | ||
@@ -43,0 +36,0 @@ close, |
@@ -5,3 +5,6 @@ import { toRefs } from 'composition-api' | ||
{ | ||
const { mode, addTagOn, createTag, openDirection, searchable } = toRefs(props) | ||
const { | ||
mode, addTagOn, createTag, openDirection, searchable, | ||
showOptions, valueProp, | ||
} = toRefs(props) | ||
@@ -13,2 +16,3 @@ // ============ DEPENDENCIES ============ | ||
const search = dep.search | ||
const setPointer = dep.setPointer | ||
const selectPointer = dep.selectPointer | ||
@@ -18,5 +22,15 @@ const backwardPointer = dep.backwardPointer | ||
const blur = dep.blur | ||
const fo = dep.fo | ||
// =============== METHODS ============== | ||
// no export | ||
const handleAddTag = () => { | ||
if (mode.value === 'tags' && !showOptions.value && createTag.value && searchable.value) { | ||
setPointer(fo.value[fo.value.map(o => o[valueProp.value]).indexOf(search.value)]) | ||
} | ||
selectPointer() | ||
} | ||
const handleKeydown = (e) => { | ||
@@ -48,4 +62,4 @@ switch (e.keyCode) { | ||
} | ||
selectPointer() | ||
handleAddTag() | ||
break | ||
@@ -69,3 +83,4 @@ | ||
e.preventDefault() | ||
selectPointer() | ||
handleAddTag() | ||
break | ||
@@ -76,2 +91,7 @@ | ||
e.preventDefault() | ||
if (!showOptions.value) { | ||
return | ||
} | ||
openDirection.value === 'top' ? forwardPointer() : backwardPointer() | ||
@@ -83,2 +103,7 @@ break | ||
e.preventDefault() | ||
if (!showOptions.value) { | ||
return | ||
} | ||
openDirection.value === 'top' ? backwardPointer() : forwardPointer() | ||
@@ -97,3 +122,3 @@ break | ||
selectPointer() | ||
handleAddTag() | ||
e.preventDefault() | ||
@@ -112,3 +137,3 @@ break | ||
selectPointer() | ||
handleAddTag() | ||
e.preventDefault() | ||
@@ -115,0 +140,0 @@ break |
@@ -22,3 +22,3 @@ import { ref, toRefs, computed } from 'composition-api' | ||
const tabindex = computed(() => { | ||
return searchable.value ? -1 : 0 | ||
return searchable.value || disabled.value ? -1 : 0 | ||
}) | ||
@@ -58,2 +58,7 @@ | ||
const handleCaretClick = () => { | ||
deactivate() | ||
blur() | ||
} | ||
return { | ||
@@ -67,3 +72,4 @@ multiselect, | ||
deactivate, | ||
handleCaretClick, | ||
} | ||
} |
@@ -13,3 +13,3 @@ import { ref, toRefs, computed, watch } from 'composition-api' | ||
minChars, filterResults, clearOnSearch, clearOnSelect, valueProp, | ||
canDeselect, max | ||
canDeselect, max, strict, | ||
} = toRefs(props) | ||
@@ -77,3 +77,3 @@ | ||
fo = fo.filter((option) => { | ||
return normalize(option[trackBy.value]).indexOf(normalize(search.value)) !== -1 | ||
return normalize(option[trackBy.value], strict.value).indexOf(normalize(search.value, strict.value)) !== -1 | ||
}) | ||
@@ -80,0 +80,0 @@ } |
@@ -29,3 +29,3 @@ import { toRefs, watch, nextTick, computed } from 'composition-api' | ||
const setPointer = (option) => { | ||
if (!showOptions.value || (option !== null && option.disabled)) { | ||
if (option === undefined || (option !== null && option.disabled)) { | ||
return | ||
@@ -115,3 +115,3 @@ } | ||
if (searchable.value) { | ||
if (val.length) { | ||
if (val.length && showOptions.value) { | ||
setPointerFirst() | ||
@@ -118,0 +118,0 @@ } else { |
@@ -5,8 +5,2 @@ import { ref, toRefs, computed, watch } from 'composition-api' | ||
{ | ||
const { mode } = toRefs(props) | ||
// ============ DEPENDENCIES ============ | ||
const iv = dep.iv | ||
// ================ DATA ================ | ||
@@ -18,31 +12,3 @@ | ||
// ============== COMPUTED ============== | ||
const tagsSearchWidth = computed(() => { | ||
// istanbul ignore next | ||
if (search.value) { | ||
return `${textWidth.value}px` | ||
} | ||
if (mode.value !== 'tags' || [null, undefined].indexOf(iv.value) !== -1 || !iv.value.length) { | ||
return '100%' | ||
} | ||
return '1ch' | ||
}) | ||
const textWidth = computed(() => { | ||
const span = document.createElement('span') | ||
span.innerHTML = search.value.replace(/ /g, ' ') | ||
span.style.position = 'absolute' | ||
span.style.left = '-9999px' | ||
span.style.top = '-9999px' | ||
document.body.append(span) | ||
const width = span.offsetWidth | ||
span.remove() | ||
return width | ||
}) | ||
// =============== METHODS ============== | ||
@@ -67,3 +33,2 @@ | ||
input, | ||
tagsSearchWidth, | ||
clearSearch, | ||
@@ -70,0 +35,0 @@ handleSearchInput, |
@@ -41,2 +41,3 @@ import Vue,{ VNode } from 'vue'; | ||
classes?: object; | ||
strict?: boolean; | ||
@@ -43,0 +44,0 @@ $emit(eventName: 'change', e: {originalEvent: Event, value: any}): this; |
@@ -1,3 +0,5 @@ | ||
export default function normalize (str) { | ||
return String(str).toLowerCase().trim() | ||
export default function normalize (str, strict = true) { | ||
return strict | ||
? String(str).toLowerCase().trim() | ||
: String(str).normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase().trim() | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195790
1309
693
31