@vueform/multiselect
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -0,1 +1,12 @@ | ||
## v2.1.1 | ||
> `2021-08-09` | ||
### 🎉 Feature | ||
- Added `closeOnSelect` prop. | ||
### 🐞 Bug Fixes | ||
- Clear search on single option select [#99](https://github.com/vueform/multiselect/issues/99) and [#106](https://github.com/vueform/multiselect/issues/106). | ||
- No blur when tags are being removed. | ||
## v2.1.0 | ||
@@ -6,2 +17,3 @@ | ||
### 🎉 Feature | ||
- **BREAKING**: `dropdown` class now has `dropdownHidden` when it is closed instead of using `v-show` (requires using 2.1.0's `themes/default.css`) | ||
- **BREAKING**: removed `:maxHeight` prop. Use `var(--ms-max-height)` instead. | ||
@@ -8,0 +20,0 @@ - **BREAKING**: tags search layout has changed -> added a wrapper div and an extra span to calculate input width. |
@@ -1,1 +0,1 @@ | ||
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); | ||
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,a,l,n,r){try{var o=e[n](r),i=o.value}catch(e){return void u(e)}o.done?t(i):Promise.resolve(i).then(a,l)}function n(e,t,u){return t in e?Object.defineProperty(e,t,{value:u,enumerable:!0,configurable:!0,writable:!0}):e[t]=u,e}function r(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 o(e){return function(e){if(Array.isArray(e))return i(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 i(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 i(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 i(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 c(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 s(t,l,r){var o=e.toRefs(t),i=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,w=o.max,E=o.strict,V=o.closeOnSelect,N=r.iv,L=r.ev,P=r.search,q=r.clearSearch,T=r.update,x=r.pointer,R=r.blur,j=r.deactivate,I=e.ref([]),M=e.ref([]),$=e.ref(!1),H=e.computed((function(){var e,t=M.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var u,a=t[e];return n(u={},k.value,e),n(u,d.value,a),n(u,m.value,a),u}))),t=t.map((function(e,t){var u;return"object"===a(e)?e:(n(u={},k.value,e),n(u,d.value,e),n(u,m.value,e),u)})),I.value.length&&(t=t.concat(I.value)),t})),K=e.computed((function(){var e=H.value;return G.value.length&&(e=G.value.concat(e)),P.value&&B.value&&(e=e.filter((function(e){return-1!==c(e[d.value],E.value).indexOf(c(P.value,E.value))}))),p.value&&(e=e.filter((function(e){return!oe(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),W=e.computed((function(){switch(s.value){case"single":return!u(N.value[k.value]);case"multiple":case"tags":return!u(N.value)&&N.value.length>0}})),U=e.computed((function(){return void 0!==h&&void 0!==h.value?h.value(N.value):N.value&&N.value.length>1?"".concat(N.value.length," options selected"):"1 option selected"})),_=e.computed((function(){return!H.value.length&&!$.value})),z=e.computed((function(){return H.value.length>0&&0==K.value.length})),G=e.computed((function(){var e;return!1!==f.value&&P.value?-1!==re(P.value)?[]:[(e={},n(e,k.value,P.value),n(e,m.value,P.value),n(e,d.value,P.value),e)]:[]})),J=e.computed((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),Q=e.computed((function(){return b.value||$.value})),X=function(e){switch("object"!==a(e)&&(e=ne(e)),s.value){case"single":T(e);break;case"multiple":case"tags":T(N.value.concat(e))}l.emit("select",Z(e),e)},Y=function(e){switch("object"!==a(e)&&(e=ne(e)),s.value){case"single":te();break;case"tags":case"multiple":T(N.value.filter((function(t){return t[k.value]!=e[k.value]})))}l.emit("deselect",Z(e),e)},Z=function(e){return g.value?e:e[k.value]},ee=function(e){Y(e)},te=function(){l.emit("clear"),T(J.value)},ue=function(e){switch(s.value){case"single":return!u(N.value)&&N.value[k.value]==e[k.value];case"tags":case"multiple":return!u(N.value)&&-1!==N.value.map((function(e){return e[k.value]})).indexOf(e[k.value])}},ae=function(e){return!0===e.disabled},le=function(){return!(void 0===w||-1===w.value||!W.value&&w.value>0)&&N.value.length>=w.value},ne=function(e){return H.value[H.value.map((function(e){return String(e[k.value])})).indexOf(String(e))]},re=function(e){return H.value.map((function(e){return c(e[d.value])})).indexOf(c(e))},oe=function(e){return"tags"===s.value&&p.value&&ue(e)},ie=function(e){I.value.push(e)},ce=function(){u(L.value)||(N.value=de(L.value))},se=function(e){$.value=!0,i.value(P.value).then((function(t){M.value=t,"function"==typeof e&&e(t),$.value=!1}))},de=function(e){return u(e)?"single"===s.value?{}:[]:g.value?e:"single"===s.value?ne(e)||{}:e.filter((function(e){return!!ne(e)})).map((function(e){return ne(e)}))};if("single"!==s.value&&!u(L.value)&&!Array.isArray(L.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return i&&"function"==typeof i.value?C.value?se(ce):1==g.value&&ce():(M.value=i.value,ce()),y.value>-1&&e.watch(P,(function(e){e.length<F.value||($.value=!0,A.value&&(M.value=[]),setTimeout((function(){e==P.value&&i.value(P.value).then((function(t){e==P.value&&(M.value=t,x.value=K.value.filter((function(e){return!0!==e.disabled}))[0]||null,$.value=!1)}))}),y.value))}),{flush:"sync"}),e.watch(L,(function(e){var t,a,l;if(u(e))N.value=de(e);else switch(s.value){case"single":(g.value?e[k.value]!=N.value[k.value]:e!=N.value[k.value])&&(N.value=de(e));break;case"multiple":case"tags":t=g.value?e.map((function(e){return e[k.value]})):e,a=N.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]}))||(N.value=de(e))}}),{deep:!0}),"function"!=typeof t.options&&e.watch(i,(function(e,u){M.value=t.options,Object.keys(N.value).length||ce(),function(){if(W.value)if("single"===s.value){var e=ne(N.value[k.value])[m.value];N.value[m.value]=e,g.value&&(L.value[m.value]=e)}else N.value.forEach((function(e,t){var u=ne(N.value[t][k.value])[m.value];N.value[t][m.value]=u,g.value&&(L.value[t][m.value]=u)}))}()})),{fo:K,filteredOptions:K,hasSelected:W,multipleLabelText:U,eo:H,extendedOptions:H,noOptions:_,noResults:z,resolving:$,busy:Q,select:X,deselect:Y,remove:ee,clear:te,isSelected:ue,isDisabled:ae,isMax:le,getOption:ne,handleOptionClick:function(e){if(!ae(e)){switch(s.value){case"single":if(ue(e))return void(O.value&&Y(e));R(),X(e);break;case"multiple":if(ue(e))return void Y(e);if(le())return;X(e),S.value&&q();break;case"tags":if(ue(e))return void Y(e);if(le())return;void 0===ne(e[k.value])&&f.value&&(l.emit("tag",e[k.value]),D.value&&ie(e),q()),S.value&&q(),X(e)}V.value&&j()}},handleTagRemove:function(e,t){0===t.button?ee(e):t.preventDefault()},refreshOptions:function(e){se(e)},resolveOptions:se}}function d(t,u,a){var n=e.toRefs(t),r=n.searchable,o=n.disabled,i=a.input,c=a.open,s=a.close,d=a.clearSearch,v=e.ref(null),p=e.ref(!1),f=e.computed((function(){return r.value||o.value?-1:0})),m=function(){r.value&&i.value.blur(),v.value.blur()},D=function(){var e,t=(e=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:p.value=!1,setTimeout((function(){p.value||(s(),d())}),1);case 2:case"end":return e.stop()}}),e)})),function(){var t=this,u=arguments;return new Promise((function(a,n){var r=e.apply(t,u);function o(e){l(r,a,n,o,i,"next",e)}function i(e){l(r,a,n,o,i,"throw",e)}o(void 0)}))});return function(){return t.apply(this,arguments)}}();return{multiselect:v,tabindex:f,isActive:p,blur:m,handleFocus:function(){r.value&&!o.value&&i.value.focus()},activate:function(){o.value||(p.value=!0,c())},deactivate:D,handleCaretClick:function(){D(),m()}}}function v(t,u,a){var l=e.toRefs(t),o=l.disabled,i=l.openDirection,c=l.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?r(Object(u),!0).forEach((function(t){n(e,t,u[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(u)):r(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"},l.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 p={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},closeOnSelect:{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)},r=function(t,u,a){var l=e.toRefs(t).disabled,n=e.ref(!1);return{isOpen:n,open:function(){n.value||l.value||(n.value=!0,u.emit("open"))},close:function(){n.value&&(n.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),c=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}),p=d(t,0,{input:i.input,open:r.open,close:r.close,clearSearch:i.clearSearch}),f=s(t,a,{ev:l.ev,iv:l.iv,search:i.search,clearSearch:i.clearSearch,update:c.update,pointer:n.pointer,blur:p.blur,deactivate:p.deactivate}),m=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:f.fo,handleOptionClick:f.handleOptionClick,search:i.search,pointer:n.pointer,multiselect:p.multiselect}),D=function(t,u,a){var l=e.toRefs(t),n=l.mode,r=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(o(p.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===n.value&&-1===r.value.indexOf("enter"))return;F();break;case 27:y();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(),!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===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()}}}}(t,0,{iv:l.iv,update:c.update,search:i.search,setPointer:m.setPointer,selectPointer:m.selectPointer,backwardPointer:m.backwardPointer,forwardPointer:m.forwardPointer,blur:p.blur,fo:f.fo}),h=v(t,0,{isOpen:r.isOpen,isPointed:m.isPointed,isSelected:f.isSelected,isDisabled:f.isDisabled,isActive:p.isActive});return{...l,...r,...p,...n,...c,...i,...f,...m,...D,...h}}};return p.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("span",{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 "),t.createVNode("div",{class:e.classList.dropdown,tabindex:"-1"},[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),t.createCommentVNode(" Hacky input element to show HTML5 required warning "),a.required?(t.openBlock(),t.createBlock("input",{key:8,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:9},["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"])},p.__file="src/Multiselect.vue",p}(Vue,Vue); |
@@ -1,1 +0,1 @@ | ||
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; | ||
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}from"vue";function D(e){return-1!==[null,void 0,!1].indexOf(e)}function h(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 m(e){return(m="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 g(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(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,b=i.appendNewTag,y=i.multipleLabel,F=i.object,C=i.loading,A=i.delay,O=i.resolveOnLoad,S=i.minChars,B=i.filterResults,E=i.clearOnSearch,w=i.clearOnSelect,k=i.valueProp,P=i.canDeselect,L=i.max,q=i.strict,x=i.closeOnSelect,T=r.iv,j=r.ev,R=r.search,I=r.clearSearch,V=r.update,M=r.pointer,$=r.blur,H=r.deactivate,N=u([]),K=u([]),W=u(!1),U=t((function(){var e,u=K.value||[];return e=u,"[object Object]"===Object.prototype.toString.call(e)&&(u=Object.keys(u).map((function(e){var t,a=u[e];return g(t={},k.value,e),g(t,c.value,a),g(t,f.value,a),t}))),u=u.map((function(e,u){var t;return"object"===m(e)?e:(g(t={},k.value,e),g(t,c.value,e),g(t,f.value,e),t)})),N.value.length&&(u=u.concat(N.value)),u})),_=t((function(){var e=U.value;return X.value.length&&(e=X.value.concat(e)),R.value&&B.value&&(e=e.filter((function(e){return-1!==h(e[c.value],q.value).indexOf(h(R.value,q.value))}))),p.value&&(e=e.filter((function(e){return!ce(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),z=t((function(){switch(s.value){case"single":return!D(T.value[k.value]);case"multiple":case"tags":return!D(T.value)&&T.value.length>0}})),G=t((function(){return void 0!==y&&void 0!==y.value?y.value(T.value):T.value&&T.value.length>1?"".concat(T.value.length," options selected"):"1 option selected"})),J=t((function(){return!U.value.length&&!W.value})),Q=t((function(){return U.value.length>0&&0==_.value.length})),X=t((function(){var e;return!1!==d.value&&R.value?-1!==se(R.value)?[]:[(e={},g(e,k.value,R.value),g(e,f.value,R.value),g(e,c.value,R.value),e)]:[]})),Y=t((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),Z=t((function(){return C.value||W.value})),ee=function(e){switch("object"!==m(e)&&(e=oe(e)),s.value){case"single":V(e);break;case"multiple":case"tags":V(T.value.concat(e))}n.emit("select",te(e),e)},ue=function(e){switch("object"!==m(e)&&(e=oe(e)),s.value){case"single":le();break;case"tags":case"multiple":V(T.value.filter((function(u){return u[k.value]!=e[k.value]})))}n.emit("deselect",te(e),e)},te=function(e){return F.value?e:e[k.value]},ae=function(e){ue(e)},le=function(){n.emit("clear"),V(Y.value)},ne=function(e){switch(s.value){case"single":return!D(T.value)&&T.value[k.value]==e[k.value];case"tags":case"multiple":return!D(T.value)&&-1!==T.value.map((function(e){return e[k.value]})).indexOf(e[k.value])}},re=function(e){return!0===e.disabled},ie=function(){return!(void 0===L||-1===L.value||!z.value&&L.value>0)&&T.value.length>=L.value},oe=function(e){return U.value[U.value.map((function(e){return String(e[k.value])})).indexOf(String(e))]},se=function(e){return U.value.map((function(e){return h(e[c.value])})).indexOf(h(e))},ce=function(e){return"tags"===s.value&&p.value&&ne(e)},ve=function(e){N.value.push(e)},pe=function(){D(j.value)||(T.value=fe(j.value))},de=function(e){W.value=!0,o.value(R.value).then((function(u){K.value=u,"function"==typeof e&&e(u),W.value=!1}))},fe=function(e){return D(e)?"single"===s.value?{}:[]:F.value?e:"single"===s.value?oe(e)||{}:e.filter((function(e){return!!oe(e)})).map((function(e){return oe(e)}))};if("single"!==s.value&&!D(j.value)&&!Array.isArray(j.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return o&&"function"==typeof o.value?O.value?de(pe):1==F.value&&pe():(K.value=o.value,pe()),A.value>-1&&a(R,(function(e){e.length<S.value||(W.value=!0,E.value&&(K.value=[]),setTimeout((function(){e==R.value&&o.value(R.value).then((function(u){e==R.value&&(K.value=u,M.value=_.value.filter((function(e){return!0!==e.disabled}))[0]||null,W.value=!1)}))}),A.value))}),{flush:"sync"}),a(j,(function(e){var u,t,a;if(D(e))T.value=fe(e);else switch(s.value){case"single":(F.value?e[k.value]!=T.value[k.value]:e!=T.value[k.value])&&(T.value=fe(e));break;case"multiple":case"tags":u=F.value?e.map((function(e){return e[k.value]})):e,t=T.value.map((function(e){return e[k.value]})),a=t.slice().sort(),u.length===t.length&&u.slice().sort().every((function(e,u){return e===a[u]}))||(T.value=fe(e))}}),{deep:!0}),"function"!=typeof l.options&&a(o,(function(e,u){K.value=l.options,Object.keys(T.value).length||pe(),function(){if(z.value)if("single"===s.value){var e=oe(T.value[k.value])[f.value];T.value[f.value]=e,F.value&&(j.value[f.value]=e)}else T.value.forEach((function(e,u){var t=oe(T.value[u][k.value])[f.value];T.value[u][f.value]=t,F.value&&(j.value[u][f.value]=t)}))}()})),{fo:_,filteredOptions:_,hasSelected:z,multipleLabelText:G,eo:U,extendedOptions:U,noOptions:J,noResults:Q,resolving:W,busy:Z,select:ee,deselect:ue,remove:ae,clear:le,isSelected:ne,isDisabled:re,isMax:ie,getOption:oe,handleOptionClick:function(e){if(!re(e)){switch(s.value){case"single":if(ne(e))return void(P.value&&ue(e));$(),ee(e);break;case"multiple":if(ne(e))return void ue(e);if(ie())return;ee(e),w.value&&I();break;case"tags":if(ne(e))return void ue(e);if(ie())return;void 0===oe(e[k.value])&&d.value&&(n.emit("tag",e[k.value]),b.value&&ve(e),I()),w.value&&I(),ee(e)}x.value&&H()}},handleTagRemove:function(e,u){0===u.button?ae(e):u.preventDefault()},refreshOptions:function(e){de(e)},resolveOptions:de}}function y(e,u,t,a,l,n,r){try{var i=e[n](r),o=i.value}catch(e){return void t(e)}i.done?u(o):Promise.resolve(o).then(a,l)}function F(a,l,n){var r=e(a),i=r.searchable,o=r.disabled,s=n.input,c=n.open,v=n.close,p=n.clearSearch,d=u(null),f=u(!1),D=t((function(){return i.value||o.value?-1:0})),h=function(){i.value&&s.value.blur(),d.value.blur()},m=function(){var e,u=(e=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:f.value=!1,setTimeout((function(){f.value||(v(),p())}),1);case 2:case"end":return e.stop()}}),e)})),function(){var u=this,t=arguments;return new Promise((function(a,l){var n=e.apply(u,t);function r(e){y(n,a,l,r,i,"next",e)}function i(e){y(n,a,l,r,i,"throw",e)}r(void 0)}))});return function(){return u.apply(this,arguments)}}();return{multiselect:d,tabindex:D,isActive:f,blur:h,handleFocus:function(){i.value&&!o.value&&s.value.focus()},activate:function(){o.value||(f.value=!0,c())},deactivate:m,handleCaretClick:function(){m(),h()}}}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},closeOnSelect:{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).disabled,r=u(!1);return{isOpen:r,open:function(){r.value||n.value||(r.value=!0,a.emit("open"))},close:function(){r.value&&(r.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||D(e)?e:Array.isArray(e)?e.map((function(e){return e[r.value]})):e[r.value]},c=function(e){return D(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=F(n,0,{input:c.input,open:s.open,close:s.close,clearSearch:c.clearSearch}),d=b(n,r,{ev:i.ev,iv:i.iv,search:c.search,clearSearch:c.clearSearch,update:v.update,pointer:o.pointer,blur:p.blur,deactivate:p.deactivate}),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}),h=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}),m=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,...h,...m}}};E.render=function(e,u,t,a,l,D){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("span",{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 "),f("div",{class:e.classList.dropdown,tabindex:"-1"},[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),i(" Hacky input element to show HTML5 required warning "),t.required?(n(),r("input",{key:8,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:9},["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 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); | ||
var VueformMultiselect=function(e){"use strict";function t(e){return-1!==[null,void 0,!1].indexOf(e)}function u(e){return(u="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,u,a,n,l,r){try{var i=e[l](r),o=i.value}catch(e){return void u(e)}i.done?t(o):Promise.resolve(o).then(a,n)}function n(e,t,u){return t in e?Object.defineProperty(e,t,{value:u,enumerable:!0,configurable:!0,writable:!0}):e[t]=u,e}function l(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 i(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 i(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 i(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 i(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 o(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 s(a,l,r){var i=e.toRefs(a),s=i.options,c=i.mode,v=i.trackBy,d=i.limit,p=i.hideSelected,f=i.createTag,D=i.label,m=i.appendNewTag,h=i.multipleLabel,g=i.object,b=i.loading,y=i.delay,F=i.resolveOnLoad,C=i.minChars,A=i.filterResults,O=i.clearOnSearch,S=i.clearOnSelect,_=i.valueProp,B=i.canDeselect,E=i.max,w=i.strict,P=i.closeOnSelect,k=r.iv,q=r.ev,x=r.search,T=r.clearSearch,L=r.update,R=r.pointer,j=r.blur,I=r.deactivate,V=e.ref([]),N=e.ref([]),H=e.ref(!1),$=e.computed((function(){var e,t=N.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var u,a=t[e];return n(u={},_.value,e),n(u,v.value,a),n(u,D.value,a),u}))),t=t.map((function(e,t){var a;return"object"===u(e)?e:(n(a={},_.value,e),n(a,v.value,e),n(a,D.value,e),a)})),V.value.length&&(t=t.concat(V.value)),t})),M=e.computed((function(){var e=$.value;return z.value.length&&(e=z.value.concat(e)),x.value&&A.value&&(e=e.filter((function(e){return-1!==o(e[v.value],w.value).indexOf(o(x.value,w.value))}))),p.value&&(e=e.filter((function(e){return!ie(e)}))),d.value>0&&(e=e.slice(0,d.value)),e})),W=e.computed((function(){switch(c.value){case"single":return!t(k.value[_.value]);case"multiple":case"tags":return!t(k.value)&&k.value.length>0}})),U=e.computed((function(){return void 0!==h&&void 0!==h.value?h.value(k.value):k.value&&k.value.length>1?"".concat(k.value.length," options selected"):"1 option selected"})),K=e.computed((function(){return!$.value.length&&!H.value})),X=e.computed((function(){return $.value.length>0&&0==M.value.length})),z=e.computed((function(){var e;return!1!==f.value&&x.value?-1!==re(x.value)?[]:[(e={},n(e,_.value,x.value),n(e,D.value,x.value),n(e,v.value,x.value),e)]:[]})),G=e.computed((function(){switch(c.value){case"single":return null;case"multiple":case"tags":return[]}})),J=e.computed((function(){return b.value||H.value})),Q=function(e){switch("object"!==u(e)&&(e=le(e)),c.value){case"single":L(e);break;case"multiple":case"tags":L(k.value.concat(e))}l.emit("select",Z(e),e)},Y=function(e){switch("object"!==u(e)&&(e=le(e)),c.value){case"single":te();break;case"tags":case"multiple":L(k.value.filter((function(t){return t[_.value]!=e[_.value]})))}l.emit("deselect",Z(e),e)},Z=function(e){return g.value?e:e[_.value]},ee=function(e){Y(e)},te=function(){l.emit("clear"),L(G.value)},ue=function(e){switch(c.value){case"single":return!t(k.value)&&k.value[_.value]==e[_.value];case"tags":case"multiple":return!t(k.value)&&-1!==k.value.map((function(e){return e[_.value]})).indexOf(e[_.value])}},ae=function(e){return!0===e.disabled},ne=function(){return!(void 0===E||-1===E.value||!W.value&&E.value>0)&&k.value.length>=E.value},le=function(e){return $.value[$.value.map((function(e){return String(e[_.value])})).indexOf(String(e))]},re=function(e){return $.value.map((function(e){return o(e[v.value])})).indexOf(o(e))},ie=function(e){return"tags"===c.value&&p.value&&ue(e)},oe=function(e){V.value.push(e)},se=function(){t(q.value)||(k.value=ve(q.value))},ce=function(e){H.value=!0,s.value(x.value).then((function(t){N.value=t,"function"==typeof e&&e(t),H.value=!1}))},ve=function(e){return t(e)?"single"===c.value?{}:[]:g.value?e:"single"===c.value?le(e)||{}:e.filter((function(e){return!!le(e)})).map((function(e){return le(e)}))};if("single"!==c.value&&!t(q.value)&&!Array.isArray(q.value))throw new Error('v-model must be an array when using "'.concat(c.value,'" mode'));return s&&"function"==typeof s.value?F.value?ce(se):1==g.value&&se():(N.value=s.value,se()),y.value>-1&&e.watch(x,(function(e){e.length<C.value||(H.value=!0,O.value&&(N.value=[]),setTimeout((function(){e==x.value&&s.value(x.value).then((function(t){e==x.value&&(N.value=t,R.value=M.value.filter((function(e){return!0!==e.disabled}))[0]||null,H.value=!1)}))}),y.value))}),{flush:"sync"}),e.watch(q,(function(e){var u,a,n;if(t(e))k.value=ve(e);else switch(c.value){case"single":(g.value?e[_.value]!=k.value[_.value]:e!=k.value[_.value])&&(k.value=ve(e));break;case"multiple":case"tags":u=g.value?e.map((function(e){return e[_.value]})):e,a=k.value.map((function(e){return e[_.value]})),n=a.slice().sort(),u.length===a.length&&u.slice().sort().every((function(e,t){return e===n[t]}))||(k.value=ve(e))}}),{deep:!0}),"function"!=typeof a.options&&e.watch(s,(function(e,t){N.value=a.options,Object.keys(k.value).length||se(),function(){if(W.value)if("single"===c.value){var e=le(k.value[_.value])[D.value];k.value[D.value]=e,g.value&&(q.value[D.value]=e)}else k.value.forEach((function(e,t){var u=le(k.value[t][_.value])[D.value];k.value[t][D.value]=u,g.value&&(q.value[t][D.value]=u)}))}()})),{fo:M,filteredOptions:M,hasSelected:W,multipleLabelText:U,eo:$,extendedOptions:$,noOptions:K,noResults:X,resolving:H,busy:J,select:Q,deselect:Y,remove:ee,clear:te,isSelected:ue,isDisabled:ae,isMax:ne,getOption:le,handleOptionClick:function(e){if(!ae(e)){switch(c.value){case"single":if(ue(e))return void(B.value&&Y(e));j(),Q(e);break;case"multiple":if(ue(e))return void Y(e);if(ne())return;Q(e),S.value&&T();break;case"tags":if(ue(e))return void Y(e);if(ne())return;void 0===le(e[_.value])&&f.value&&(l.emit("tag",e[_.value]),m.value&&oe(e),T()),S.value&&T(),Q(e)}P.value&&I()}},handleTagRemove:function(e,t){0===t.button?ee(e):t.preventDefault()},refreshOptions:function(e){ce(e)},resolveOptions:ce}}function c(t,u,n){var l=e.toRefs(t),r=l.searchable,i=l.disabled,o=n.input,s=n.open,c=n.close,v=n.clearSearch,d=e.ref(null),p=e.ref(!1),f=e.computed((function(){return r.value||i.value?-1:0})),D=function(){r.value&&o.value.blur(),d.value.blur()},m=function(){var e,t=(e=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:p.value=!1,setTimeout((function(){p.value||(c(),v())}),1);case 2:case"end":return e.stop()}}),e)})),function(){var t=this,u=arguments;return new Promise((function(n,l){var r=e.apply(t,u);function i(e){a(r,n,l,i,o,"next",e)}function o(e){a(r,n,l,i,o,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}();return{multiselect:d,tabindex:f,isActive:p,blur:D,handleFocus:function(){r.value&&!i.value&&o.value.focus()},activate:function(){i.value||(p.value=!0,s())},deactivate:m,handleCaretClick:function(){m(),D()}}}function v(t,u,a){var r=e.toRefs(t),i=r.disabled,o=r.openDirection,s=r.showOptions,c=a.isOpen,v=a.isPointed,d=a.isSelected,p=a.isDisabled,f=a.isActive,D=function(e){for(var t=1;t<arguments.length;t++){var u=null!=arguments[t]?arguments[t]:{};t%2?l(Object(u),!0).forEach((function(t){n(e,t,u[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(u)):l(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:[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 t=[D.option];return v(e)?t.push(d(e)?D.optionSelectedPointed:D.optionPointed):d(e)?t.push(p(e)?D.optionSelectedDisabled:D.optionSelected):p(e)&&t.push(D.optionDisabled),t},noOptions:D.noOptions,noResults:D.noResults,fakeInput:D.fakeInput}}))}}function d(e,t,u,a,n,l,r,i,o,s){"boolean"!=typeof r&&(o=i,i=r,r=!1);var c,v="function"==typeof u?u.options:u;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__),t&&t.call(this,o(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},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 u}const p={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},closeOnSelect:{type:Boolean,required:!1,default:!0}},setup(u,a){const n=function(t,u){var a=e.toRefs(t),n=a.value,l=a.modelValue,r=a.mode,i=a.valueProp,o=e.ref("single"!==r.value?[]:{}),s=void 0!==u.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}}(u,a),l={pointer:e.ref(null)},i=function(t,u,a){var n=e.toRefs(t).disabled,l=e.ref(!1);return{isOpen:l,open:function(){l.value||n.value||(l.value=!0,u.emit("open"))},close:function(){l.value&&(l.value=!1,u.emit("close"))}}}(u,a),o=function(t,u,a){var n=e.ref(null),l=e.ref(null);return e.watch(n,(function(e){u.emit("search-change",e)})),{search:n,input:l,clearSearch:function(){n.value=""},handleSearchInput:function(e){n.value=e.target.value}}}(0,a),d=function(u,a,n){var l=e.toRefs(u),r=l.object,i=l.valueProp,o=l.mode,s=n.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)}}}(u,a,{iv:n.iv}),p=c(u,0,{input:o.input,open:i.open,close:i.close,clearSearch:o.clearSearch}),f=s(u,a,{ev:n.ev,iv:n.iv,search:o.search,clearSearch:o.clearSearch,update:d.update,pointer:l.pointer,blur:p.blur,deactivate:p.deactivate}),D=function(t,u,a){var n=e.toRefs(t),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 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&&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 t=p.value.map((function(e){return e[l.value]})).indexOf(v.value[l.value])+1;p.value.length<=t&&(t=0),f(p.value[t]||null)}e.nextTick((function(){h()}))},backwardPointer:function(){if(null===v.value)f(p.value[p.value.length-1]||null);else{var t=p.value.map((function(e){return e[l.value]})).indexOf(v.value[l.value])-1;t<0&&(t=p.value.length-1),f(p.value[t]||null)}e.nextTick((function(){h()}))}}}(u,0,{fo:f.fo,handleOptionClick:f.handleOptionClick,search:o.search,pointer:l.pointer,multiselect:p.multiselect}),m=function(t,u,a){var n=e.toRefs(t),l=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"===l.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"===l.value)return;if(c.value&&-1===[null,""].indexOf(D.value))return;if(0===p.value.length)return;f(r(p.value).slice(0,-1));break;case 13:if(e.preventDefault(),"tags"===l.value&&-1===i.value.indexOf("enter"))return;C();break;case 27:y();break;case 32:if("tags"!==l.value&&c.value)return;if("tags"===l.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"!==l.value)return;if(-1===i.value.indexOf(";")||!o.value)return;C(),e.preventDefault();break;case 188:if("tags"!==l.value)return;if(-1===i.value.indexOf(",")||!o.value)return;C(),e.preventDefault()}}}}(u,0,{iv:n.iv,update:d.update,search:o.search,setPointer:D.setPointer,selectPointer:D.selectPointer,backwardPointer:D.backwardPointer,forwardPointer:D.forwardPointer,blur:p.blur,fo:f.fo}),h=v(u,0,{isOpen:i.isOpen,isPointed:D.isPointed,isSelected:f.isSelected,isDisabled:f.isDisabled,isActive:p.isActive});return{...n,...i,...p,...l,...d,...o,...f,...D,...m,...h}}};var f=function(){var e=this,t=e.$createElement,u=e._self._c||t;return u("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?[u("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?[u("div",{class:e.classList.tags},[e._l(e.iv,(function(t,a,n){return e._t("tag",[u("span",{key:n,class:e.classList.tag},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():u("span",{class:e.classList.tagRemove,on:{mousedown:function(u){return u.preventDefault(),e.handleTagRemove(t,u)}}},[u("span",{class:e.classList.tagRemoveIcon})])])],{option:t,handleTagRemove:e.handleTagRemove,disabled:e.disabled})})),e._v(" "),u("div",{class:e.classList.tagsSearchWrapper},[u("span",{class:e.classList.tagsSearchCopy},[e._v(e._s(e.search))]),e._v(" "),e.searchable&&!e.disabled?u("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",[u("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",[u("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",[u("div",{class:e.classList.placeholder},[e._v("\n "+e._s(e.placeholder)+"\n ")])])],e._v(" "),e.busy?e._t("spinner",[u("span",{class:e.classList.spinner})]):e._e(),e._v(" "),e.hasSelected&&!e.disabled&&e.canClear&&!e.busy?e._t("clear",[u("span",{class:e.classList.clear,on:{mousedown:e.clear}},[u("span",{class:e.classList.clearIcon})])],{clear:e.clear}):e._e(),e._v(" "),e.caret?e._t("caret",[u("span",{class:e.classList.caret,on:{click:e.handleCaretClick}})]):e._e(),e._v(" "),u("div",{class:e.classList.dropdown,attrs:{tabindex:"-1"}},[e._t("beforelist",null,{options:e.fo}),e._v(" "),u("ul",{class:e.classList.options},e._l(e.fo,(function(t,a,n){return u("li",{key:n,class:e.classList.option(t),attrs:{"data-pointed":e.isPointed(t)},on:{mouseenter:function(u){return e.setPointer(t)},click:function(u){return e.handleOptionClick(t)}}},[e._t("option",[u("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),0),e._v(" "),e.noOptions?e._t("nooptions",[u("div",{class:e.classList.noOptions,domProps:{innerHTML:e._s(e.noOptionsText)}})]):e._e(),e._v(" "),e.noResults?e._t("noresults",[u("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?u("input",{class:e.classList.fakeInput,attrs:{tabindex:"-1",required:""},domProps:{value:e.textValue}}):e._e(),e._v(" "),e.nativeSupport?["single"==e.mode?u("input",{attrs:{type:"hidden",name:e.name},domProps:{value:void 0!==e.plainValue?e.plainValue:""}}):e._l(e.plainValue,(function(t,a){return u("input",{key:a,attrs:{type:"hidden",name:e.name+"[]"},domProps:{value:t}})}))]:e._e(),e._v(" "),u("div",{class:e.classList.spacer})],2)};f._withStripped=!0;return d({render:f,staticRenderFns:[]},undefined,p,undefined,false,undefined,!1,void 0,void 0,void 0)}(VueCompositionAPI); |
@@ -1,1 +0,1 @@ | ||
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; | ||
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,S=v.minChars,_=v.filterResults,B=v.clearOnSearch,E=v.clearOnSelect,w=v.valueProp,P=v.canDeselect,q=v.max,x=v.strict,L=v.closeOnSelect,k=c.iv,T=c.ev,j=c.search,R=c.clearSearch,I=c.update,V=c.pointer,N=c.blur,H=c.deactivate,$=u([]),M=u([]),W=u(!1),U=t((function(){var e,u=M.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)})),$.value.length&&(u=u.concat($.value)),u})),K=t((function(){var e=U.value;return Q.value.length&&(e=Q.value.concat(e)),j.value&&_.value&&(e=e.filter((function(e){return-1!==r(e[f.value],x.value).indexOf(r(j.value,x.value))}))),m.value&&(e=e.filter((function(e){return!ce(e)}))),D.value>0&&(e=e.slice(0,D.value)),e})),X=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}})),z=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"})),G=t((function(){return!U.value.length&&!W.value})),J=t((function(){return U.value.length>0&&0==K.value.length})),Q=t((function(){var e;return!1!==h.value&&j.value?-1!==se(j.value)?[]:[(e={},o(e,w.value,j.value),o(e,g.value,j.value),o(e,f.value,j.value),e)]:[]})),Y=t((function(){switch(p.value){case"single":return null;case"multiple":case"tags":return[]}})),Z=t((function(){return C.value||W.value})),ee=function(e){switch("object"!==i(e)&&(e=oe(e)),p.value){case"single":I(e);break;case"multiple":case"tags":I(k.value.concat(e))}s.emit("select",te(e),e)},ue=function(e){switch("object"!==i(e)&&(e=oe(e)),p.value){case"single":ne();break;case"tags":case"multiple":I(k.value.filter((function(u){return u[w.value]!=e[w.value]})))}s.emit("deselect",te(e),e)},te=function(e){return F.value?e:e[w.value]},ae=function(e){ue(e)},ne=function(){s.emit("clear"),I(Y.value)},le=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])}},re=function(e){return!0===e.disabled},ie=function(){return!(void 0===q||-1===q.value||!X.value&&q.value>0)&&k.value.length>=q.value},oe=function(e){return U.value[U.value.map((function(e){return String(e[w.value])})).indexOf(String(e))]},se=function(e){return U.value.map((function(e){return r(e[f.value])})).indexOf(r(e))},ce=function(e){return"tags"===p.value&&m.value&&le(e)},ve=function(e){$.value.push(e)},de=function(){l(T.value)||(k.value=fe(T.value))},pe=function(e){W.value=!0,d.value(j.value).then((function(u){M.value=u,"function"==typeof e&&e(u),W.value=!1}))},fe=function(e){return l(e)?"single"===p.value?{}:[]:F.value?e:"single"===p.value?oe(e)||{}:e.filter((function(e){return!!oe(e)})).map((function(e){return oe(e)}))};if("single"!==p.value&&!l(T.value)&&!Array.isArray(T.value))throw new Error('v-model must be an array when using "'.concat(p.value,'" mode'));return d&&"function"==typeof d.value?O.value?pe(de):1==F.value&&de():(M.value=d.value,de()),A.value>-1&&a(j,(function(e){e.length<S.value||(W.value=!0,B.value&&(M.value=[]),setTimeout((function(){e==j.value&&d.value(j.value).then((function(u){e==j.value&&(M.value=u,V.value=K.value.filter((function(e){return!0!==e.disabled}))[0]||null,W.value=!1)}))}),A.value))}),{flush:"sync"}),a(T,(function(e){var u,t,a;if(l(e))k.value=fe(e);else switch(p.value){case"single":(F.value?e[w.value]!=k.value[w.value]:e!=k.value[w.value])&&(k.value=fe(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=fe(e))}}),{deep:!0}),"function"!=typeof n.options&&a(d,(function(e,u){M.value=n.options,Object.keys(k.value).length||de(),function(){if(X.value)if("single"===p.value){var e=oe(k.value[w.value])[g.value];k.value[g.value]=e,F.value&&(T.value[g.value]=e)}else k.value.forEach((function(e,u){var t=oe(k.value[u][w.value])[g.value];k.value[u][g.value]=t,F.value&&(T.value[u][g.value]=t)}))}()})),{fo:K,filteredOptions:K,hasSelected:X,multipleLabelText:z,eo:U,extendedOptions:U,noOptions:G,noResults:J,resolving:W,busy:Z,select:ee,deselect:ue,remove:ae,clear:ne,isSelected:le,isDisabled:re,isMax:ie,getOption:oe,handleOptionClick:function(e){if(!re(e)){switch(p.value){case"single":if(le(e))return void(P.value&&ue(e));N(),ee(e);break;case"multiple":if(le(e))return void ue(e);if(ie())return;ee(e),E.value&&R();break;case"tags":if(le(e))return void ue(e);if(ie())return;void 0===oe(e[w.value])&&h.value&&(s.emit("tag",e[w.value]),b.value&&ve(e),R()),E.value&&R(),ee(e)}L.value&&H()}},handleTagRemove:function(e,u){0===u.button?ae(e):u.preventDefault()},refreshOptions:function(e){pe(e)},resolveOptions:pe}}function c(e,u,t,a,n,l,r){try{var i=e[l](r),o=i.value}catch(e){return void t(e)}i.done?u(o):Promise.resolve(o).then(a,n)}function v(a,n,l){var r=e(a),i=r.searchable,o=r.disabled,s=l.input,v=l.open,d=l.close,p=l.clearSearch,f=u(null),D=u(!1),m=t((function(){return i.value||o.value?-1:0})),h=function(){i.value&&s.value.blur(),f.value.blur()},g=function(){var e,u=(e=regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:D.value=!1,setTimeout((function(){D.value||(d(),p())}),1);case 2:case"end":return e.stop()}}),e)})),function(){var u=this,t=arguments;return new Promise((function(a,n){var l=e.apply(u,t);function r(e){c(l,a,n,r,i,"next",e)}function i(e){c(l,a,n,r,i,"throw",e)}r(void 0)}))});return function(){return u.apply(this,arguments)}}();return{multiselect:f,tabindex:m,isActive:D,blur:h,handleFocus:function(){i.value&&!o.value&&s.value.focus()},activate:function(){o.value||(D.value=!0,v())},deactivate:g,handleCaretClick:function(){g(),h()}}}function d(e){return function(e){if(Array.isArray(e))return p(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 p(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 p(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 p(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 f(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 D(e,u,t){return u in e?Object.defineProperty(e,u,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[u]=t,e}function m(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,d=n.isDisabled,p=n.isActive,m=function(e){for(var u=1;u<arguments.length;u++){var t=null!=arguments[u]?arguments[u]:{};u%2?f(Object(t),!0).forEach((function(u){D(e,u,t[u])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):f(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(p.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(d(e)?m.optionSelectedDisabled:m.optionSelected):d(e)&&u.push(m.optionDisabled),u},noOptions:m.noOptions,noResults:m.noResults,fakeInput:m.fakeInput}}))}}function h(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 g={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},closeOnSelect:{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),c={pointer:u(null)},p=function(t,a,n){var l=e(t).disabled,r=u(!1);return{isOpen:r,open:function(){r.value||l.value||(r.value=!0,a.emit("open"))},close:function(){r.value&&(r.value=!1,a.emit("close"))}}}(r,i),f=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}),h=v(r,0,{input:f.input,open:p.open,close:p.close,clearSearch:f.clearSearch}),g=s(r,i,{ev:o.ev,iv:o.iv,search:f.search,clearSearch:f.clearSearch,update:D.update,pointer:c.pointer,blur:h.blur,deactivate:h.deactivate}),b=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:g.fo,handleOptionClick:g.handleOptionClick,search:f.search,pointer:c.pointer,multiselect:h.multiselect}),y=function(u,t,a){var n=e(u),l=n.mode,r=n.addTagOn,i=n.createTag,o=n.openDirection,s=n.searchable,c=n.showOptions,v=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&&!c.value&&i.value&&s.value&&m(F.value[F.value.map((function(e){return e[v.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(d(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(),!c.value)return;"top"===o.value?b():g();break;case 40:if(e.preventDefault(),!c.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:f.search,setPointer:b.setPointer,selectPointer:b.selectPointer,backwardPointer:b.backwardPointer,forwardPointer:b.forwardPointer,blur:h.blur,fo:g.fo}),F=m(r,0,{isOpen:p.isOpen,isPointed:b.isPointed,isSelected:g.isSelected,isDisabled:g.isDisabled,isActive:h.isActive});return{...o,...p,...h,...c,...D,...f,...g,...b,...y,...F}}};var b=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("span",{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(" "),t("div",{class:e.classList.dropdown,attrs:{tabindex:"-1"}},[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)};b._withStripped=!0;const y=h({render:b,staticRenderFns:[]},undefined,g,undefined,false,undefined,!1,void 0,void 0,void 0);export default y; |
{ | ||
"name": "@vueform/multiselect", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Vue 3 multiselect component with single select, multiselect and tagging options.", |
225
README.md
@@ -165,2 +165,114 @@ <div align="center"> | ||
## Support | ||
Join our [Discord channel](https://discord.gg/WhX2nG6GTQ) or [open an issue](https://github.com/vueform/multiselect/issues). | ||
## Basic props | ||
| Name | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| **mode** | `string` | `single` | Possible values: `single\|multiple\|tags`. | | ||
| **options** | `array\|object\|function` | `[]` | List of options. Can be:<br>- an array (eg. `[1,2,3]`)<br>- an object (eg. `{a:1,b:2,c:3}`)<br>- an array of objects `[{value:1,label:'v1'},{value:2,label:'v2'},{value:3,label:'v3',disabled:true}]`<br>- a function returning a Promise (async function) with `query` input param. The promise should return options as an **object** or as an **array of objects**.<br>When an array of objects is provided it **must** have properties that equal to `:valueProp`'s, `:trackBy`'s and `:label`'s value. | | ||
| **required** | `boolean` | `false` | Whether the HTML5 required attribute should be used for multiselect (using an invisible fake input). | | ||
| **searchable** | `boolean` | `false` | Whether the options should be searchable. | | ||
| **valueProp** | `string` | `'value'` | If you provide an array of objects as options this property should be used as the value of the option. | | ||
| **trackBy** | `string` | `'label'` | The name of the property that should be searched when `searchable` is `true` and an array of objects are provided as `:options`. | | ||
| **label** | `string` | `'label'` | If you provide an array of objects as options the value this property will be displayed as selected option. | | ||
| **placeholder** | `string` | `null` | The text that should be displayed before any option is selected. | | ||
| **multipleLabel** | `function` | | A function that returns the label to be displayed for selected options when using `multiple` mode. It receives `value` as an argument. By default it renders `1 option selected` and `[n] options selected` based on `value` length. | | ||
| **disabled** | `boolean` | `false` | Whether the input should be disabled for the user (API can still be used programmatically). | | ||
| **max** | `number` | `-1` | The maximum number of options that **can be selected** when using `multiple` or `tags` mode. If `-1` the number of options won't be limited. | | ||
| **limit** | `number` | `-1` | The maximum number of options that **should be displayed**. If `-1` the number of options won't be limited. | | ||
| **loading** | `boolean` | `false` | Whether a loading spinner should be shown. | | ||
| **id** | `string` | `'multiselect'` | The `id` of the multiselect container DOM. | | ||
| **caret** | `boolean` | `true` | Whether should display the caret symbol on the right. | | ||
| **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> `tagsSearchWrapper: 'multiselect-tags-search-wrapper',`<br> `tagsSearch: 'multiselect-tags-search',`<br> `tagsSearchCopy: 'multiselect-tags-search-copy',`<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> `dropdownHidden: 'is-hidden',`<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>`}` | | ||
### Advanced Props | ||
| Name | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| **canDeselect** | `boolean` | `true` | Whether a selected option can be deselected when using `single` mode. | | ||
| **canClear** | `boolean` | `true` | Whether option(s) can be cleared. | | ||
| **clearOnSearch** | `boolean` | `false` | Whether the option list should be cleared when a new character is typed before loading new options list, when using async options. | | ||
| **clearOnSelect** | `boolean` | `true` | Whether the option list should be cleared upon selecting an option when using async options. | | ||
| **closeOnSelect** | `boolean` | `true` | Whether the option list should be hidden upon selecting an option. | | ||
| **delay** | `number` | `-1` | The delay in milliseconds that should occur between the last typed character and refreshing an async option list. If `-1` the option list will not refresh when the search query changes. If `0` it will refresh without delay. | | ||
| **filterResults** | `boolean` | `true` | Whether option list should be filtered by search query. This may be set to `false` if you are handling filtering manually when returning async options. | | ||
| **minChars** | `number` | `0` | The minimum number of characters that should be typed to refresh async option list. If `0` it will refresh even when the search field becomes empty. | | ||
| **resolveOnLoad** | `boolean` | `true` | Whether async options should be loaded initially (with an empty query). This should be `true` if you are planning to load non-object value(s) initially while using async options (to fetch matching objects for values). | | ||
| **appendNewTag** | `boolean` | `true` | Whether it should append new tag automatically to option list when using `tags` mode with `createTag`. If set to `false` you need to take care of appending a new tag to the provided `:options` list upon `@tag` event. | | ||
| **createTag** | `boolean` | `false` | Whether it should allow creating new tag based on search query when using `tags` mode. | | ||
| **addTagOn** | `array` | `['enter']` | The list of keys that creates a new tag while typing in the search field when having `createTag` enabled. Possible values: `enter\|space\|;\|,`. | | ||
| **hideSelected** | `boolean` | `true` | Whether selected options should be excluded from the option list when using `multiple` or `tags` mode. | | ||
| **showOptions** | `boolean` | `true` | Whether option list should be displayed. Can be used to create free-typed tags. | | ||
| **object** | `boolean` | `false` | Whether the value should be stored as an object.<br>If **false**:<br>`value: ['js','jsx','ts']`<br>If **true**:<br> `value: [`<br> `{value:'js',label:'Javascript'},`<br> `{value:'jsx',label:'JSX'},`<br> `{value:'ts',label:'Typescript'}`<br>`]` | | ||
| **nativeSupport** | `boolean` | `false` | Whether hidden input fields should be appended to achieve native data handling. | | ||
## API | ||
| Name | Params | Description | | ||
| --- | --- | --- | | ||
| **open** | | Opens the options list and focuses the multiselect. | | ||
| **close** | | Closes the options list and blurs the multiselect. | | ||
| **select** | `value`, `option` | Selects an option based on its value. | | ||
| **deselect** | `value`, `option` | Deselects an option based on its value. | | ||
| **remove** | `value`, `option` | Alias for `deselect`. | | ||
| **clear** | | Deselects all selected options. | | ||
| **refreshOptions** | `callback` | Refreshes async options list. | | ||
To access API use `ref` on `Multiselect` component: | ||
``` html | ||
<Multiselect | ||
v-model="value" | ||
:options="options" | ||
ref="multiselect" | ||
/> | ||
``` | ||
``` js | ||
// eg: | ||
mounted() { | ||
this.$refs.multiselect.open() | ||
} | ||
``` | ||
## Events | ||
| Event | Attributes | Description | | ||
| --- | --- | --- | | ||
| **@change** | `value` | Emitted after the value is changed. | | ||
| **@close** | | Emitted after closing the option list. | | ||
| **@deselect** | `option` | Emitted after an option is deselected or a tag is removed. | | ||
| **@open** | | Emitted after opening the option list. | | ||
| **@search-change** | `query` | Emitted after a character is typed. | | ||
| **@select** | `option` | Emitted after an option or tag is selected. | | ||
| **@tag** | `query` | Emitted after enter is hit when a new tag is being created. | | ||
| **@clear** | | Emitted when the options are cleared. | | ||
## Slots | ||
| Slot | Attributes | Description | | ||
| --- | --- | --- | | ||
| **placeholder** | | Rendered as placeholder when the multiselect does not have value and `placeholder` prop is defined. | | ||
| **afterlist** | | Rendered after the options list. | | ||
| **beforelist** | | Rendered before the options list. | | ||
| **multiplelabel** | `values` | Rendered when using `multiple` mode and options are selected. By default it renders the return value of `multipleLabel` function. | | ||
| **nooptions** | | Rendered when the options list is empty. By default renders `noOptionsText`. | | ||
| **noresults** | | Rendered when there are no search results. By default renders `noResultsText`. | | ||
| **option** | `option, search` | Renders an option in options list. | | ||
| **singlelabel** | `value` | Rendered when using `single` mode and an option is selected. By default it renders the `:label` if the selected option. | | ||
| **tag** | `option, handleTagRemove, disabled` | Renders a tag when using `tags` mode. When `disabled` the remove icon should not be displayed. The `handleTagRemove` prop should be used to trigger the removal of the tag. | | ||
| **caret** | | Renders a small triangle on the right side of the multiselect. | | ||
| **clear** | | Renders a remove icon if the multiselect has any value. | | ||
| **spinner** | | Renders a loader icon when async options are being fetched. | | ||
> Note: we don't use camelCase because they are [normalized back to lowercase](https://github.com/vuejs/vue/issues/9449#issuecomment-461170017) when written in DOM. | ||
## Styling with CSS vars | ||
@@ -291,3 +403,3 @@ | ||
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', | ||
tagsSearch: 'absolute inset-0 border-0 outline-none appearance-none p-0 text-base font-sans box-border w-full', | ||
tagsSearchCopy: 'invisible whitespace-pre-wrap inline-block h-px', | ||
@@ -350,113 +462,2 @@ placeholder: 'flex items-center h-full absolute left-0 top-0 pointer-events-none bg-transparent leading-snug pl-3.5 text-gray-400', | ||
## Support | ||
Join our [Discord channel](https://discord.gg/WhX2nG6GTQ) or [open an issue](https://github.com/vueform/multiselect/issues). | ||
## Basic props | ||
| Name | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| **mode** | `string` | `single` | Possible values: `single\|multiple\|tags`. | | ||
| **options** | `array\|object\|function` | `[]` | List of options. Can be:<br>- an array (eg. `[1,2,3]`)<br>- an object (eg. `{a:1,b:2,c:3}`)<br>- an array of objects `[{value:1,label:'v1'},{value:2,label:'v2'},{value:3,label:'v3',disabled:true}]`<br>- a function returning a Promise (async function) with `query` input param. The promise should return options as an **object** or as an **array of objects**.<br>When an array of objects is provided it **must** have properties that equal to `:valueProp`'s, `:trackBy`'s and `:label`'s value. | | ||
| **required** | `boolean` | `false` | Whether the HTML5 required attribute should be used for multiselect (using an invisible fake input). | | ||
| **searchable** | `boolean` | `false` | Whether the options should be searchable. | | ||
| **valueProp** | `string` | `'value'` | If you provide an array of objects as options this property should be used as the value of the option. | | ||
| **trackBy** | `string` | `'label'` | The name of the property that should be searched when `searchable` is `true` and an array of objects are provided as `:options`. | | ||
| **label** | `string` | `'label'` | If you provide an array of objects as options the value this property will be displayed as selected option. | | ||
| **placeholder** | `string` | `null` | The text that should be displayed before any option is selected. | | ||
| **multipleLabel** | `function` | | A function that returns the label to be displayed for selected options when using `multiple` mode. It receives `value` as an argument. By default it renders `1 option selected` and `[n] options selected` based on `value` length. | | ||
| **disabled** | `boolean` | `false` | Whether the input should be disabled for the user (API can still be used programmatically). | | ||
| **max** | `number` | `-1` | The maximum number of options that **can be selected** when using `multiple` or `tags` mode. If `-1` the number of options won't be limited. | | ||
| **limit** | `number` | `-1` | The maximum number of options that **should be displayed**. If `-1` the number of options won't be limited. | | ||
| **loading** | `boolean` | `false` | Whether a loading spinner should be shown. | | ||
| **id** | `string` | `'multiselect'` | The `id` of the multiselect container DOM. | | ||
| **caret** | `boolean` | `true` | Whether should display the caret symbol on the right. | | ||
| **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>`}` | | ||
### Advanced Props | ||
| Name | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| **canDeselect** | `boolean` | `true` | Whether a selected option can be deselected when using `single` mode. | | ||
| **canClear** | `boolean` | `true` | Whether option(s) can be cleared. | | ||
| **clearOnSearch** | `boolean` | `false` | Whether the option list should be cleared when a new character is typed before loading new options list, when using async options. | | ||
| **clearOnSelect** | `boolean` | `true` | Whether the option list should be cleared upon selecting an option when using async options. | | ||
| **delay** | `number` | `-1` | The delay in milliseconds that should occur between the last typed character and refreshing an async option list. If `-1` the option list will not refresh when the search query changes. If `0` it will refresh without delay. | | ||
| **filterResults** | `boolean` | `true` | Whether option list should be filtered by search query. This may be set to `false` if you are handling filtering manually when returning async options. | | ||
| **minChars** | `number` | `0` | The minimum number of characters that should be typed to refresh async option list. If `0` it will refresh even when the search field becomes empty. | | ||
| **resolveOnLoad** | `boolean` | `true` | Whether async options should be loaded initially (with an empty query). This should be `true` if you are planning to load non-object value(s) initially while using async options (to fetch matching objects for values). | | ||
| **appendNewTag** | `boolean` | `true` | Whether it should append new tag automatically to option list when using `tags` mode with `createTag`. If set to `false` you need to take care of appending a new tag to the provided `:options` list upon `@tag` event. | | ||
| **createTag** | `boolean` | `false` | Whether it should allow creating new tag based on search query when using `tags` mode. | | ||
| **addTagOn** | `array` | `['enter']` | The list of keys that creates a new tag while typing in the search field when having `createTag` enabled. Possible values: `enter\|space\|;\|,`. | | ||
| **hideSelected** | `boolean` | `true` | Whether selected options should be excluded from the option list when using `multiple` or `tags` mode. | | ||
| **showOptions** | `boolean` | `true` | Whether option list should be displayed. Can be used to create free-typed tags. | | ||
| **object** | `boolean` | `false` | Whether the value should be stored as an object.<br>If **false**:<br>`value: ['js','jsx','ts']`<br>If **true**:<br> `value: [`<br> `{value:'js',label:'Javascript'},`<br> `{value:'jsx',label:'JSX'},`<br> `{value:'ts',label:'Typescript'}`<br>`]` | | ||
| **nativeSupport** | `boolean` | `false` | Whether hidden input fields should be appended to achieve native data handling. | | ||
## API | ||
| Name | Params | Description | | ||
| --- | --- | --- | | ||
| **open** | | Opens the options list and focuses the multiselect. | | ||
| **close** | | Closes the options list and blurs the multiselect. | | ||
| **select** | `value`, `option` | Selects an option based on its value. | | ||
| **deselect** | `value`, `option` | Deselects an option based on its value. | | ||
| **remove** | `value`, `option` | Alias for `deselect`. | | ||
| **clear** | | Deselects all selected options. | | ||
| **refreshOptions** | `callback` | Refreshes async options list. | | ||
To access API use `ref` on `Multiselect` component: | ||
``` html | ||
<Multiselect | ||
v-model="value" | ||
:options="options" | ||
ref="multiselect" | ||
/> | ||
``` | ||
``` js | ||
// eg: | ||
mounted() { | ||
this.$refs.multiselect.open() | ||
} | ||
``` | ||
## Events | ||
| Event | Attributes | Description | | ||
| --- | --- | --- | | ||
| **@change** | `value` | Emitted after the value is changed. | | ||
| **@close** | | Emitted after closing the option list. | | ||
| **@deselect** | `option` | Emitted after an option is deselected or a tag is removed. | | ||
| **@open** | | Emitted after opening the option list. | | ||
| **@search-change** | `query` | Emitted after a character is typed. | | ||
| **@select** | `option` | Emitted after an option or tag is selected. | | ||
| **@tag** | `query` | Emitted after enter is hit when a new tag is being created. | | ||
| **@clear** | | Emitted when the options are cleared. | | ||
## Slots | ||
| Slot | Attributes | Description | | ||
| --- | --- | --- | | ||
| **placeholder** | | Rendered as placeholder when the multiselect does not have value and `placeholder` prop is defined. | | ||
| **afterlist** | | Rendered after the options list. | | ||
| **beforelist** | | Rendered before the options list. | | ||
| **multiplelabel** | `values` | Rendered when using `multiple` mode and options are selected. By default it renders the return value of `multipleLabel` function. | | ||
| **nooptions** | | Rendered when the options list is empty. By default renders `noOptionsText`. | | ||
| **noresults** | | Rendered when there are no search results. By default renders `noResultsText`. | | ||
| **option** | `option, search` | Renders an option in options list. | | ||
| **singlelabel** | `value` | Rendered when using `single` mode and an option is selected. By default it renders the `:label` if the selected option. | | ||
| **tag** | `option, handleTagRemove, disabled` | Renders a tag when using `tags` mode. When `disabled` the remove icon should not be displayed. The `handleTagRemove` prop should be used to trigger the removal of the tag. | | ||
| **caret** | | Renders a small triangle on the right side of the multiselect. | | ||
| **clear** | | Renders a remove icon if the multiselect has any value. | | ||
| **spinner** | | Renders a loader icon when async options are being fetched. | | ||
> Note: we don't use camelCase because they are [normalized back to lowercase](https://github.com/vuejs/vue/issues/9449#issuecomment-461170017) when written in DOM. | ||
## Examples | ||
@@ -463,0 +464,0 @@ |
@@ -1,6 +0,6 @@ | ||
import { ref, toRefs, computed } from 'composition-api' | ||
import { ref, toRefs } from 'composition-api' | ||
export default function useDropdown (props, context, dep) | ||
{ | ||
const { maxHeight, disabled } = toRefs(props) | ||
const { disabled } = toRefs(props) | ||
@@ -7,0 +7,0 @@ // ================ DATA ================ |
@@ -12,2 +12,3 @@ import { ref, toRefs, computed } from 'composition-api' | ||
const close = dep.close | ||
const clearSearch = dep.clearSearch | ||
@@ -52,6 +53,11 @@ // ================ DATA ================ | ||
const deactivate = () => { | ||
const deactivate = async () => { | ||
isActive.value = false | ||
close() | ||
setTimeout(() => { | ||
if (!isActive.value) { | ||
close() | ||
clearSearch() | ||
} | ||
}, 1) | ||
} | ||
@@ -58,0 +64,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { ref, toRefs, computed, watch } from 'composition-api' | ||
import { ref, toRefs, computed, watch, nextTick } from 'composition-api' | ||
import normalize from './../utils/normalize' | ||
@@ -13,3 +13,3 @@ import isObject from './../utils/isObject' | ||
minChars, filterResults, clearOnSearch, clearOnSelect, valueProp, | ||
canDeselect, max, strict, | ||
canDeselect, max, strict, closeOnSelect, | ||
} = toRefs(props) | ||
@@ -26,2 +26,3 @@ | ||
const blur = dep.blur | ||
const deactivate = dep.deactivate | ||
@@ -295,2 +296,6 @@ // ================ DATA ================ | ||
} | ||
if (closeOnSelect.value) { | ||
deactivate() | ||
} | ||
} | ||
@@ -297,0 +302,0 @@ |
@@ -42,2 +42,3 @@ import Vue,{ VNode } from 'vue'; | ||
strict?: boolean; | ||
closeOnSelect?: boolean; | ||
@@ -44,0 +45,0 @@ $emit(eventName: 'change', e: {originalEvent: Event, value: any}): this; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
199200
1328
694