@vueform/multiselect
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,1 +0,1 @@ | ||
function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function t(t){for(var l=1;l<arguments.length;l++){var r=null!=arguments[l]?arguments[l]:{};l%2?e(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}import{toRefs as l,computed as r,ref as u,watch as a,nextTick as o,openBlock as i,createBlock as c,withKeys as s,withModifiers as p,createVNode as f,renderSlot as d,toDisplayString as v,createCommentVNode as b,Fragment as h,renderList as m,createTextVNode as y,withDirectives as g,vModelText as O,vShow as S,Transition as w,withCtx as P}from"vue";function j(e){return String(e).toLowerCase().trim()}function k(e){return function(e){if(Array.isArray(e))return x(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 x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return x(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 x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=new Array(t);n<t;n++)l[n]=e[n];return l}function 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 q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B(e,t,n){var a=l(e),o=a.options,i=a.mode,c=a.trackBy,s=a.limit,p=a.hideSelectedTag,f=a.createTag,d=a.label,v=a.appendNewTag,b=a.multipleLabel,h=a.object,m=n.value,y=n.search,g=n.blurSearch,O=n.clearSearch,S=n.update,w=n.blurInput,P=u([]),x=r((function(){var e,t=void 0===o||void 0===o.value?[]:o.value;return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,l=t[e];return q(n={value:e},c.value,l),q(n,d.value,l),n}))),t=t.map((function(e,t){var n;return"object"===T(e)?e:(q(n={value:t},c.value,e),q(n,d.value,e),n)})),P.value.length&&(t=t.concat(P.value)),t})),B=r((function(){var e=x.value;return M.value.length&&(e=M.value.concat(e)),y.value&&(e=e.filter((function(e){return-1!==j(e[c.value]).indexOf(j(y.value))}))),p.value&&(e=e.filter((function(e){return!_(e)}))),s.value>0&&(e=e.slice(0,s.value)),e})),A=r((function(){return $.value||0===m.value.length||h.value?m.value:"single"==i.value?D(m.value):m.value.map((function(e){return D(e)}))})),E=r((function(){switch(i.value){case"single":return!$.value;case"multiple":case"tags":return!$.value&&m.value.length>0}})),I=r((function(){return void 0!==b&&void 0!==b.value?b.value(m.value):m.value&&m.value.length>1?"".concat(m.value.length," options selected"):"1 option selected"})),C=r((function(){return!x.value.length})),L=r((function(){return x.value.length>0&&0==B.value.length})),M=r((function(){var e;return!1!==f.value&&y.value?-1!==U(y.value)?[]:[(e={},q(e,d.value,y.value),q(e,c.value,y.value),q(e,"value",y.value),e)]:[]})),V=r((function(){switch(i.value){case"single":return null;case"multiple":case"tags":return[]}})),$=r((function(){return-1!==[null,void 0,!1].indexOf(m.value)})),H=function(e){switch("object"!==T(e)&&(e=D(e)),i.value){case"single":S(N(e));break;case"multiple":case"tags":S(k(m.value||[]).concat(N(e)))}t.emit("select",N(e))},K=function(e){switch("object"!==T(e)&&(e=D(e)),i.value){case"single":F();break;case"tags":case"multiple":S(m.value.filter((function(t){return h.value&&t.value!=e.value||!h.value&&t!=e.value})))}t.emit("deselect",N(e))},N=function(e){return h.value?e:e.value},F=function(e){S(V.value)},R=function(e){switch(i.value){case"single":return!$.value&&A.value.value==e.value;case"tags":case"multiple":return!$.value&&-1!==A.value.map((function(e){return e.value})).indexOf(e.value)}},D=function(e){return x.value[x.value.map((function(e){return e.value})).indexOf(e)]},U=function(e){return x.value.map((function(e){return j(e[c.value])})).indexOf(j(e))},_=function(e){return"tags"===i.value&&p.value&&R(e)},W=function(e){P.value.push(e)};return{filteredOptions:B,hasSelected:E,multipleLabelText:I,extendedOptions:x,noOptions:C,noResults:L,valueObject:A,select:H,deselect:K,remove:function(e){K(e)},clear:F,isSelected:R,getOption:D,handleOptionClick:function(e){switch(i.value){case"single":if(R(e))return void K(e);F(),H(e),g(),w();break;case"multiple":if(R(e))return void K(e);H(e),O();break;case"tags":if(R(e))return void K(e);void 0===D(e.value)&&f.value&&(t.emit("tag",e.value),v.value&&W(e),O()),H(e)}}}}function A(e){return function(e){if(Array.isArray(e))return E(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 E(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return E(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 E(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=new Array(t);n<t;n++)l[n]=e[n];return l}var I={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var i=function(e,t){return{update:function(e){t.emit("input",e),t.emit("update:modelValue",e)}}}(0,n),c=function(e,t){var n=l(e),u=n.value,a=n.modelValue;return{externalValue:r((function(){return void 0===u?a.value:u.value}))}}(e),s=function(e,t,n){var o=l(e),i=o.searchable,c=o.mode,s=n.value,p=u(null),f=u(null),d=r((function(){return p.value?"".concat(p.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return a(p,(function(e){t.emit("search-change",e)})),{search:p,input:f,tagsSearchWidth:d,clearSearch:function(){p.value=null},blurSearch:function(){i.value&&f.value.blur()},handleTagsSearchBackspace:function(e){null!==p.value&&e.stopPropagation(),""===p.value&&(p.value=null)}}}(e,n,{value:c.externalValue}),p=function(e,t,n){var a=l(e),o=a.maxHeight,i=a.disabled,c=u(!1),s=r((function(){return"".concat(o.value,"px")}));return{isOpen:c,contentMaxHeight:s,open:function(){i.value||(c.value=!0,t.emit("open"))},close:function(){c.value=!1,t.emit("close")}}}(e,n),f=function(e,t,n){var a=l(e),o=a.searchable,i=a.id;return{multiselect:u(null),tabindex:r((function(){return o.value?-1:0})),blurInput:function(){document.getElementById(i.value).querySelector(".multiselect-input").blur()}}}(e),d=B(e,n,{value:c.externalValue,search:s.search,blurSearch:s.blurSearch,clearSearch:s.clearSearch,update:i.update,blurInput:f.blurInput}),v=function(e,t,n){var r=l(e).id,i=n.filteredOptions,c=n.handleOptionClick,s=n.search,p=u(null),f=function(e){p.value=e},d=function(){p.value=i.value[0]||null},v=function(){p.value=null},b=function(){var e=document.getElementById(r.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return a(s,(function(e){d()})),{pointer:p,isPointed:function(e){return!!p.value&&p.value.value==e.value},setPointer:f,setPointerFirst:d,clearPointer:v,selectPointer:function(){p.value&&(c(p.value),v())},forwardPointer:function(e){if(null===p.value)f(i.value[0]);else{var t=i.value.map((function(e){return e.value})).indexOf(p.value.value)+1;i.value.length<=t&&(t=0),f(i.value[t])}o((function(){b()}))},backwardPointer:function(){if(null===p.value)f(i.value[i.value.length-1]);else{var e=i.value.map((function(e){return e.value})).indexOf(p.value.value)-1;e<0&&(e=i.value.length-1),f(i.value[e])}o((function(){b()}))}}}(e,0,{filteredOptions:d.filteredOptions,handleOptionClick:d.handleOptionClick,search:s.search}),b=function(e,t,n){var l=n.value,r=n.update,u=n.close,a=n.clearPointer;return{handleBackspace:function(e){r(A(l.value).slice(0,-1))},handleEsc:function(e){u(),a(),e.target.blur()}}}(0,0,{value:c.externalValue,update:i.update,close:p.close,clearPointer:v.clearPointer});return t(t(t(t(t(t(t(t({},i),s),p),f),d),v),b),c)}},C={class:"multiselect-single-label"},L={class:"multiselect-multiple-label"},M={key:2,class:"multiselect-tags"},V={class:"multiselect-tag"},$={key:3,class:"multiselect-search"},H={class:"multiselect-spinner"},K={class:"multiselect-no-options"},N={class:"multiselect-no-results"};I.render=function(e,t,n,l,r,u){return i(),c("div",{class:["multiselect",["is-".concat(n.mode),{"is-open":e.isOpen,"is-searchable":n.searchable,"is-disabled":n.disabled,"no-caret":!n.caret}]],id:n.id,onKeydown:t[26]||(t[26]=s(p((function(){}),["prevent"]),["enter"])),ref:"multiselect"},[f("div",{class:"multiselect-input",tabindex:e.tabindex,onFocus:t[18]||(t[18]=function(){return e.open&&e.open.apply(e,arguments)}),onBlur:t[19]||(t[19]=function(){return e.close&&e.close.apply(e,arguments)}),onKeyup:[t[20]||(t[20]=s((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["esc"])),t[21]||(t[21]=s((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["enter"]))],onKeydown:[t[22]||(t[22]=s(p((function(){return e.handleBackspace&&e.handleBackspace.apply(e,arguments)}),["prevent"]),["delete"])),t[23]||(t[23]=s(p((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["prevent"]),["up"])),t[24]||(t[24]=s(p((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["prevent"]),["down"]))]},["single"==n.mode&&e.hasSelected&&!e.search&&e.valueObject?d(e.$slots,"singleLabel",{key:0,value:e.valueObject},(function(){return[f("div",C,v(e.valueObject[n.label]),1)]})):b("v-if",!0),"multiple"==n.mode&&e.hasSelected&&!e.search?d(e.$slots,"multipleLabel",{key:1,values:e.valueObject},(function(){return[f("div",L,v(e.multipleLabelText),1)]})):b("v-if",!0),"tags"==n.mode?(i(),c("div",M,[(i(!0),c(h,null,m(e.valueObject,(function(l,r,u){return i(),c("span",{key:u},[d(e.$slots,"tag",{option:l,remove:e.remove,disabled:n.disabled},(function(){return[f("div",V,[y(v(l[n.label])+" ",1),n.disabled?b("v-if",!0):(i(),c("i",{key:0,onClick:t[1]||(t[1]=p((function(){}),["prevent"])),onMousedown:p((function(t){return e.remove(l)}),["prevent"])},null,40,["onMousedown"]))])]}))])})),128)),n.searchable&&!n.disabled?(i(),c("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[g(f("input",{"onUpdate:modelValue":t[2]||(t[2]=function(t){return e.search=t}),onFocus:t[3]||(t[3]=p((function(){return e.open&&e.open.apply(e,arguments)}),["stop"])),onBlur:t[4]||(t[4]=p((function(){return e.close&&e.close.apply(e,arguments)}),["stop"])),onKeyup:[t[5]||(t[5]=s(p((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["stop"]),["esc"])),t[6]||(t[6]=s(p((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["stop"]),["enter"]))],onKeydown:[t[7]||(t[7]=s((function(){return e.handleTagsSearchBackspace&&e.handleTagsSearchBackspace.apply(e,arguments)}),["delete"])),t[8]||(t[8]=s(p((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["stop"]),["up"])),t[9]||(t[9]=s(p((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[O,e.search]])],4)):b("v-if",!0)])):b("v-if",!0),"tags"!==n.mode&&n.searchable&&!n.disabled?(i(),c("div",$,[g(f("input",{"onUpdate:modelValue":t[10]||(t[10]=function(t){return e.search=t}),onFocus:t[11]||(t[11]=p((function(){return e.open&&e.open.apply(e,arguments)}),["stop"])),onBlur:t[12]||(t[12]=p((function(){return e.close&&e.close.apply(e,arguments)}),["stop"])),onKeyup:[t[13]||(t[13]=s(p((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["stop"]),["esc"])),t[14]||(t[14]=s(p((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["stop"]),["enter"]))],onKeydown:[t[15]||(t[15]=s(p((function(){}),["stop"]),["delete"])),t[16]||(t[16]=s(p((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["stop"]),["up"])),t[17]||(t[17]=s(p((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["stop"]),["down"]))],ref:"input"},null,544),[[O,e.search]])])):b("v-if",!0),g(f("div",{class:"multiselect-placeholder"},v(n.placeholder),513),[[S,n.placeholder&&!e.hasSelected&&!e.search]]),f(w,{name:"multiselect-loading"},{default:P((function(){return[g(f("div",H,null,512),[[S,n.loading]])]})),_:1})],40,["tabindex"]),f(w,{name:"multiselect",onAfterLeave:e.clearSearch},{default:P((function(){return[g(f("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[d(e.$slots,"beforeList"),(i(!0),c(h,null,m(e.filteredOptions,(function(l,r,u){return i(),c("a",{href:"",class:["multiselect-option",{"is-pointed":e.isPointed(l),"is-selected":e.isSelected(l)}],key:u,onMousedown:t[25]||(t[25]=p((function(){}),["prevent"])),onMouseenter:function(t){return e.setPointer(l)},onClick:p((function(t){return e.handleOptionClick(l)}),["stop","prevent"])},[d(e.$slots,"option",{option:l,search:e.search},(function(){return[f("span",null,v(l[n.label]),1)]}))],42,["onMouseenter","onClick"])})),128)),g(f("span",null,[d(e.$slots,"noOptions",{},(function(){return[f("div",K,v(n.noOptionsText),1)]}))],512),[[S,e.noOptions]]),g(f("span",null,[d(e.$slots,"noResults",{},(function(){return[f("div",N,v(n.noResultsText),1)]}))],512),[[S,e.noResults]]),d(e.$slots,"afterList")],4),[[S,e.isOpen]])]})),_:3},8,["onAfterLeave"])],42,["id"])},I.__file="src/Multiselect.vue";export default I; | ||
function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,l)}return n}function t(t){for(var l=1;l<arguments.length;l++){var r=null!=arguments[l]?arguments[l]:{};l%2?e(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}import{toRefs as l,ref as r,computed as a,watch as u,nextTick as i,openBlock as o,createBlock as c,withKeys as s,withModifiers as p,createVNode as f,createCommentVNode as d,renderSlot as v,toDisplayString as h,withDirectives as m,vModelText as y,Fragment as b,renderList as g,createTextVNode as O,vShow as w,Transition as S,withCtx as P}from"vue";function k(e){return String(e).toLowerCase().trim()}function x(e,t,n,l,r,a,u){try{var i=e[a](u),o=i.value}catch(e){return void n(e)}i.done?t(o):Promise.resolve(o).then(l,r)}function q(e){return function(){var t=this,n=arguments;return new Promise((function(l,r){var a=e.apply(t,n);function u(e){x(a,l,r,u,i,"next",e)}function i(e){x(a,l,r,u,i,"throw",e)}u(void 0)}))}}function j(e){return(j="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 V(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B(e,t,n){var i,o=l(e),c=o.options,s=o.mode,p=o.trackBy,f=o.limit,d=o.hideSelectedTag,v=o.createTag,h=o.label,m=o.appendNewTag,y=o.multipleLabel,b=o.object,g=o.loading,O=o.delay,w=o.resolveOnLoad,S=o.minChars,P=o.filterResults,x=o.clearOnSearch,B=o.clearOnSelect,T=n.internalValue,A=n.externalValue,E=n.search,L=n.blurSearch,C=n.clearSearch,M=n.update,R=n.blurInput,H=r([]),I=r([]),N=r(!1),$=a((function(){var e,t=I.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,l=t[e];return V(n={value:e},p.value,l),V(n,h.value,l),n}))),t=t.map((function(e,t){var n;return"object"===j(e)?e:(V(n={value:t},p.value,e),V(n,h.value,e),n)})),H.value.length&&(t=t.concat(H.value)),t})),K=a((function(){var e=$.value;return W.value.length&&(e=W.value.concat(e)),E.value&&P.value&&(e=e.filter((function(e){return-1!==k(e[p.value]).indexOf(k(E.value))}))),d.value&&(e=e.filter((function(e){return!le(e)}))),f.value>0&&(e=e.slice(0,f.value)),e})),F=a((function(){switch(s.value){case"single":return!G.value;case"multiple":case"tags":return!G.value&&T.value.length>0}})),D=a((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"})),_=a((function(){return!$.value.length})),U=a((function(){return $.value.length>0&&0==K.value.length})),W=a((function(){var e;return!1!==v.value&&E.value?-1!==ne(E.value)?[]:[(e={},V(e,h.value,E.value),V(e,p.value,E.value),V(e,"value",E.value),e)]:[]})),z=a((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),G=a((function(){return-1!==[null,void 0,!1].indexOf(T.value)})),J=a((function(){return g.value||N.value})),Q=function(e){switch("object"!==j(e)&&(e=te(e)),s.value){case"single":M(e);break;case"multiple":case"tags":M((T.value||[]).concat(e))}t.emit("select",Y(e))},X=function(e){switch("object"!==j(e)&&(e=te(e)),s.value){case"single":Z();break;case"tags":case"multiple":M(T.value.filter((function(t){return t.value!=e.value})))}t.emit("deselect",Y(e))},Y=function(e){return b.value?e:e.value},Z=function(e){M(z.value)},ee=function(e){switch(s.value){case"single":return!G.value&&T.value.value==e.value;case"tags":case"multiple":return!G.value&&-1!==T.value.map((function(e){return e.value})).indexOf(e.value)}},te=function(e){return $.value[$.value.map((function(e){return e.value})).indexOf(e)]},ne=function(e){return $.value.map((function(e){return k(e[p.value])})).indexOf(k(e))},le=function(e){return"tags"===s.value&&d.value&&ee(e)},re=function(e){H.value.push(e)},ae=function(){var e=q(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return N.value=!0,e.next=3,c.value(E.value);case 3:I.value=e.sent,N.value=!1;case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();if("single"!==s.value&&-1===[null,void 0,!1].indexOf(A.value)&&!Array.isArray(A.value))throw new Error('v-model must be an array when using "'.concat(s.value,'" mode'));return c&&"function"==typeof c.value?w.value&&ae():I.value=c&&c.value?c.value:[],-1===[null,!1,void 0].indexOf(A.value)&&(T.value=(i=A.value,b.value?i:Array.isArray(i)?i.map((function(e){return te(e)})):te(i))),O.value>-1&&u(E,(function(e){e.length<S.value||(x.value&&(I.value=[]),setTimeout(q(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e==E.value){t.next=2;break}return t.abrupt("return");case 2:return N.value=!0,t.next=5,c.value(E.value);case 5:n=t.sent,e==E.value&&(I.value=n),N.value=!1;case 8:case"end":return t.stop()}}),t)}))),O.value))}),{flush:"sync"}),{filteredOptions:K,hasSelected:F,multipleLabelText:D,extendedOptions:$,noOptions:_,noResults:U,busy:J,select:Q,deselect:X,remove:function(e){X(e)},clear:Z,isSelected:ee,getOption:te,handleOptionClick:function(e){switch(s.value){case"single":if(ee(e))return void X(e);Z(),Q(e),L(),R();break;case"multiple":if(ee(e))return void X(e);Q(e),B.value&&C();break;case"tags":if(ee(e))return void X(e);void 0===te(e.value)&&v.value&&(t.emit("tag",e.value),m.value&&re(e),C()),B.value&&C(),Q(e)}}}}function T(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,t){if(!e)return;if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(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 A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=new Array(t);n<t;n++)l[n]=e[n];return l}var E={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var o,c,s,p,f,d=function(e,t){var n=l(e),u=n.value,i=n.modelValue,o=n.mode;return{internalValue:r("single"!==o.value?[]:null),externalValue:a((function(){return void 0!==t.expose?i.value:u.value}))}}(e,n),v=function(e,t,n){var r=l(e).object,a=n.internalValue,u=function(e){return r.value||-1!==[null,!1,void 0].indexOf(e)?e:Array.isArray(e)?e.map((function(e){return e.value})):e.value};return{update:function(e){a.value=e,t.emit("input",u(e)),t.emit("update:modelValue",u(e))}}}(e,n,{internalValue:d.internalValue}),h=function(e,t,n){var i=l(e),o=i.searchable,c=i.mode,s=n.internalValue,p=r(null),f=r(null),d=a((function(){return p.value?"".concat(p.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return u(p,(function(e){t.emit("search-change",e)})),{search:p,input:f,tagsSearchWidth:d,clearSearch:function(){p.value=""},blurSearch:function(){o.value&&f.value.blur()},handleSearchBackspace:function(e){""!==p.value&&e.stopPropagation()}}}(e,n,{internalValue:d.internalValue}),m=function(e,t,n){var u=l(e),i=u.maxHeight,o=u.disabled,c=r(!1),s=a((function(){return"".concat(i.value,"px")}));return{isOpen:c,contentMaxHeight:s,open:function(){o.value||(c.value=!0,t.emit("open"))},close:function(){c.value=!1,t.emit("close")}}}(e,n),y=function(e,t,n){var u=l(e),i=u.searchable,o=u.id;return{multiselect:r(null),tabindex:a((function(){return i.value?-1:0})),blurInput:function(){document.getElementById(o.value).querySelector(".multiselect-input").blur()}}}(e),b=B(e,n,{externalValue:d.externalValue,internalValue:d.internalValue,search:h.search,blurSearch:h.blurSearch,clearSearch:h.clearSearch,update:v.update,blurInput:y.blurInput}),g=function(e,t,n){var a=l(e).id,o=n.filteredOptions,c=n.handleOptionClick,s=n.search,p=r(null),f=function(e){p.value=e},d=function(){p.value=o.value[0]||null},v=function(){p.value=null},h=function(){var e=document.getElementById(a.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return u(s,(function(e){d()})),{pointer:p,isPointed:function(e){return!!p.value&&p.value.value==e.value},setPointer:f,setPointerFirst:d,clearPointer:v,selectPointer:function(){p.value&&(c(p.value),v())},forwardPointer:function(e){if(null===p.value)f(o.value[0]);else{var t=o.value.map((function(e){return e.value})).indexOf(p.value.value)+1;o.value.length<=t&&(t=0),f(o.value[t])}i((function(){h()}))},backwardPointer:function(){if(null===p.value)f(o.value[o.value.length-1]);else{var e=o.value.map((function(e){return e.value})).indexOf(p.value.value)-1;e<0&&(e=o.value.length-1),f(o.value[e])}i((function(){h()}))}}}(e,0,{filteredOptions:b.filteredOptions,handleOptionClick:b.handleOptionClick,search:h.search}),O=(o={internalValue:d.internalValue,update:v.update,close:m.close,clearPointer:g.clearPointer},c=o.internalValue,s=o.update,p=o.close,f=o.clearPointer,{handleBackspace:function(e){s(T(c.value).slice(0,-1))},handleEsc:function(e){p(),f(),e.target.blur()}});return t(t(t(t(t(t(t(t({},d),v),h),m),y),b),g),O)}},L={class:"multiselect-single-label"},C={class:"multiselect-multiple-label"},M={key:2,class:"multiselect-search"},R={key:3,class:"multiselect-tags"},H={class:"multiselect-tag"},I={class:"multiselect-spinner"},N={class:"multiselect-no-options"},$={class:"multiselect-no-results"};E.render=function(e,t,n,l,r,a){return o(),c("div",{class:["multiselect",["is-".concat(n.mode),{"is-open":e.isOpen,"is-searchable":n.searchable,"is-disabled":n.disabled,"no-caret":!n.caret}]],id:n.id,onKeydown:t[26]||(t[26]=s(p((function(){}),["prevent"]),["enter"])),ref:"multiselect"},[f("div",{class:"multiselect-input",tabindex:e.tabindex,onFocus:t[18]||(t[18]=function(){return e.open&&e.open.apply(e,arguments)}),onBlur:t[19]||(t[19]=function(){return e.close&&e.close.apply(e,arguments)}),onKeyup:[t[20]||(t[20]=s((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["esc"])),t[21]||(t[21]=s((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["enter"]))],onKeydown:[t[22]||(t[22]=s(p((function(){return e.handleBackspace&&e.handleBackspace.apply(e,arguments)}),["prevent"]),["delete"])),t[23]||(t[23]=s(p((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["prevent"]),["up"])),t[24]||(t[24]=s(p((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["prevent"]),["down"]))]},[d(" Single label "),"single"==n.mode&&e.hasSelected&&!e.search&&e.internalValue?v(e.$slots,"singleLabel",{key:0,value:e.internalValue},(function(){return[f("div",L,h(e.internalValue[n.label]),1)]})):d("v-if",!0),d(" Multiple label "),"multiple"==n.mode&&e.hasSelected&&!e.search?v(e.$slots,"multipleLabel",{key:1,values:e.internalValue},(function(){return[f("div",C,h(e.multipleLabelText),1)]})):d("v-if",!0),d(" Search "),"tags"!==n.mode&&n.searchable&&!n.disabled?(o(),c("div",M,[m(f("input",{"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.search=t}),onFocus:t[2]||(t[2]=p((function(){return e.open&&e.open.apply(e,arguments)}),["stop"])),onBlur:t[3]||(t[3]=p((function(){return e.close&&e.close.apply(e,arguments)}),["stop"])),onKeyup:[t[4]||(t[4]=s(p((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["stop"]),["esc"])),t[5]||(t[5]=s(p((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["stop"]),["enter"]))],onKeydown:[t[6]||(t[6]=s((function(){return e.handleSearchBackspace&&e.handleSearchBackspace.apply(e,arguments)}),["delete"])),t[7]||(t[7]=s(p((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["stop"]),["up"])),t[8]||(t[8]=s(p((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["stop"]),["down"]))],ref:"input"},null,544),[[y,e.search]])])):d("v-if",!0),d(" Tags (with search) "),"tags"==n.mode?(o(),c("div",R,[(o(!0),c(b,null,g(e.internalValue,(function(l,r,a){return o(),c("span",{key:a},[v(e.$slots,"tag",{option:l,remove:e.remove,disabled:n.disabled},(function(){return[f("div",H,[O(h(l[n.label])+" ",1),n.disabled?d("v-if",!0):(o(),c("i",{key:0,onClick:t[9]||(t[9]=p((function(){}),["prevent"])),onMousedown:p((function(t){return e.remove(l)}),["prevent"])},null,40,["onMousedown"]))])]}))])})),128)),n.searchable&&!n.disabled?(o(),c("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[m(f("input",{"onUpdate:modelValue":t[10]||(t[10]=function(t){return e.search=t}),onFocus:t[11]||(t[11]=p((function(){return e.open&&e.open.apply(e,arguments)}),["stop"])),onBlur:t[12]||(t[12]=p((function(){return e.close&&e.close.apply(e,arguments)}),["stop"])),onKeyup:[t[13]||(t[13]=s(p((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["stop"]),["esc"])),t[14]||(t[14]=s(p((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["stop"]),["enter"]))],onKeydown:[t[15]||(t[15]=s((function(){return e.handleSearchBackspace&&e.handleSearchBackspace.apply(e,arguments)}),["delete"])),t[16]||(t[16]=s(p((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["stop"]),["up"])),t[17]||(t[17]=s(p((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[y,e.search]])],4)):d("v-if",!0)])):d("v-if",!0),d(" Placeholder "),m(f("div",{class:"multiselect-placeholder"},h(n.placeholder),513),[[w,n.placeholder&&!e.hasSelected&&!e.search]]),f(S,{name:"multiselect-loading"},{default:P((function(){return[m(f("div",I,null,512),[[w,e.busy]])]})),_:1})],40,["tabindex"]),d(" Options "),f(S,{name:"multiselect",onAfterLeave:e.clearSearch},{default:P((function(){return[m(f("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[v(e.$slots,"beforeList"),(o(!0),c(b,null,g(e.filteredOptions,(function(l,r,a){return o(),c("a",{href:"",class:["multiselect-option",{"is-pointed":e.isPointed(l),"is-selected":e.isSelected(l)}],key:a,onMousedown:t[25]||(t[25]=p((function(){}),["prevent"])),onMouseenter:function(t){return e.setPointer(l)},onClick:p((function(t){return e.handleOptionClick(l)}),["stop","prevent"])},[v(e.$slots,"option",{option:l,search:e.search},(function(){return[f("span",null,h(l[n.label]),1)]}))],42,["onMouseenter","onClick"])})),128)),m(f("span",null,[v(e.$slots,"noOptions",{},(function(){return[f("div",N,h(n.noOptionsText),1)]}))],512),[[w,e.noOptions]]),m(f("span",null,[v(e.$slots,"noResults",{},(function(){return[f("div",$,h(n.noResultsText),1)]}))],512),[[w,e.noResults]]),v(e.$slots,"afterList")],4),[[w,e.isOpen]])]})),_:3},8,["onAfterLeave"])],42,["id"])},E.__file="src/Multiselect.vue";export default E; |
@@ -1,789 +0,1 @@ | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define("VueFormMultiselect", ["exports", "composition-api", "vue"], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require("composition-api"), require("vue")); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports, global.Vue, global.Vue); | ||
global.VueFormMultiselect = mod.exports; | ||
} | ||
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _compositionApi, _vue) { | ||
"use strict"; | ||
Object.defineProperty(_exports, "__esModule", { | ||
value: true | ||
}); | ||
_exports.default = void 0; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function e(e, t) { | ||
var n = Object.keys(e); | ||
if (Object.getOwnPropertySymbols) { | ||
var l = Object.getOwnPropertySymbols(e); | ||
t && (l = l.filter(function (t) { | ||
return Object.getOwnPropertyDescriptor(e, t).enumerable; | ||
})), n.push.apply(n, l); | ||
} | ||
return n; | ||
} | ||
function t(t) { | ||
for (var l = 1; l < arguments.length; l++) { | ||
var r = null != arguments[l] ? arguments[l] : {}; | ||
l % 2 ? e(Object(r), !0).forEach(function (e) { | ||
n(t, e, r[e]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : e(Object(r)).forEach(function (e) { | ||
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e)); | ||
}); | ||
} | ||
return t; | ||
} | ||
function n(e, t, n) { | ||
return t in e ? Object.defineProperty(e, t, { | ||
value: n, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : e[t] = n, e; | ||
} | ||
function j(e) { | ||
return String(e).toLowerCase().trim(); | ||
} | ||
function k(e) { | ||
return function (e) { | ||
if (Array.isArray(e)) return x(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 x(e, t); | ||
var n = Object.prototype.toString.call(e).slice(8, -1); | ||
"Object" === n && e.constructor && (n = e.constructor.name); | ||
if ("Map" === n || "Set" === n) return Array.from(e); | ||
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return x(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 x(e, t) { | ||
(null == t || t > e.length) && (t = e.length); | ||
for (var n = 0, l = new Array(t); n < t; n++) { | ||
l[n] = e[n]; | ||
} | ||
return l; | ||
} | ||
function 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 q(e, t, n) { | ||
return t in e ? Object.defineProperty(e, t, { | ||
value: n, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}) : e[t] = n, e; | ||
} | ||
function B(e, t, n) { | ||
var a = (0, _compositionApi.toRefs)(e), | ||
o = a.options, | ||
i = a.mode, | ||
c = a.trackBy, | ||
s = a.limit, | ||
p = a.hideSelectedTag, | ||
f = a.createTag, | ||
d = a.label, | ||
v = a.appendNewTag, | ||
m = a.multipleLabel, | ||
b = a.object, | ||
h = n.value, | ||
y = n.search, | ||
g = n.blurSearch, | ||
O = n.clearSearch, | ||
S = n.update, | ||
w = n.blurInput, | ||
P = (0, _compositionApi.ref)([]), | ||
x = (0, _compositionApi.computed)(function () { | ||
var e, | ||
t = void 0 === o || void 0 === o.value ? [] : o.value; | ||
return e = t, "[object Object]" === Object.prototype.toString.call(e) && (t = Object.keys(t).map(function (e) { | ||
var n, | ||
l = t[e]; | ||
return q(n = { | ||
value: e | ||
}, c.value, l), q(n, d.value, l), n; | ||
})), t = t.map(function (e, t) { | ||
var n; | ||
return "object" === T(e) ? e : (q(n = { | ||
value: t | ||
}, c.value, e), q(n, d.value, e), n); | ||
}), P.value.length && (t = t.concat(P.value)), t; | ||
}), | ||
B = (0, _compositionApi.computed)(function () { | ||
var e = x.value; | ||
return M.value.length && (e = M.value.concat(e)), y.value && (e = e.filter(function (e) { | ||
return -1 !== j(e[c.value]).indexOf(j(y.value)); | ||
})), p.value && (e = e.filter(function (e) { | ||
return !_(e); | ||
})), s.value > 0 && (e = e.slice(0, s.value)), e; | ||
}), | ||
A = (0, _compositionApi.computed)(function () { | ||
return $.value || 0 === h.value.length || b.value ? h.value : "single" == i.value ? D(h.value) : h.value.map(function (e) { | ||
return D(e); | ||
}); | ||
}), | ||
E = (0, _compositionApi.computed)(function () { | ||
switch (i.value) { | ||
case "single": | ||
return !$.value; | ||
case "multiple": | ||
case "tags": | ||
return !$.value && h.value.length > 0; | ||
} | ||
}), | ||
I = (0, _compositionApi.computed)(function () { | ||
return void 0 !== m && void 0 !== m.value ? m.value(h.value) : h.value && h.value.length > 1 ? "".concat(h.value.length, " options selected") : "1 option selected"; | ||
}), | ||
C = (0, _compositionApi.computed)(function () { | ||
return !x.value.length; | ||
}), | ||
L = (0, _compositionApi.computed)(function () { | ||
return x.value.length > 0 && 0 == B.value.length; | ||
}), | ||
M = (0, _compositionApi.computed)(function () { | ||
var e; | ||
return !1 !== f.value && y.value ? -1 !== U(y.value) ? [] : [(e = {}, q(e, d.value, y.value), q(e, c.value, y.value), q(e, "value", y.value), e)] : []; | ||
}), | ||
V = (0, _compositionApi.computed)(function () { | ||
switch (i.value) { | ||
case "single": | ||
return null; | ||
case "multiple": | ||
case "tags": | ||
return []; | ||
} | ||
}), | ||
$ = (0, _compositionApi.computed)(function () { | ||
return -1 !== [null, void 0, !1].indexOf(h.value); | ||
}), | ||
H = function H(e) { | ||
switch ("object" !== T(e) && (e = D(e)), i.value) { | ||
case "single": | ||
S(N(e)); | ||
break; | ||
case "multiple": | ||
case "tags": | ||
S(k(h.value || []).concat(N(e))); | ||
} | ||
t.emit("select", N(e)); | ||
}, | ||
K = function K(e) { | ||
switch ("object" !== T(e) && (e = D(e)), i.value) { | ||
case "single": | ||
F(); | ||
break; | ||
case "tags": | ||
case "multiple": | ||
S(h.value.filter(function (t) { | ||
return b.value && t.value != e.value || !b.value && t != e.value; | ||
})); | ||
} | ||
t.emit("deselect", N(e)); | ||
}, | ||
N = function N(e) { | ||
return b.value ? e : e.value; | ||
}, | ||
F = function F(e) { | ||
S(V.value); | ||
}, | ||
R = function R(e) { | ||
switch (i.value) { | ||
case "single": | ||
return !$.value && A.value.value == e.value; | ||
case "tags": | ||
case "multiple": | ||
return !$.value && -1 !== A.value.map(function (e) { | ||
return e.value; | ||
}).indexOf(e.value); | ||
} | ||
}, | ||
D = function D(e) { | ||
return x.value[x.value.map(function (e) { | ||
return e.value; | ||
}).indexOf(e)]; | ||
}, | ||
U = function U(e) { | ||
return x.value.map(function (e) { | ||
return j(e[c.value]); | ||
}).indexOf(j(e)); | ||
}, | ||
_ = function _(e) { | ||
return "tags" === i.value && p.value && R(e); | ||
}, | ||
W = function W(e) { | ||
P.value.push(e); | ||
}; | ||
return { | ||
filteredOptions: B, | ||
hasSelected: E, | ||
multipleLabelText: I, | ||
extendedOptions: x, | ||
noOptions: C, | ||
noResults: L, | ||
valueObject: A, | ||
select: H, | ||
deselect: K, | ||
remove: function remove(e) { | ||
K(e); | ||
}, | ||
clear: F, | ||
isSelected: R, | ||
getOption: D, | ||
handleOptionClick: function handleOptionClick(e) { | ||
switch (i.value) { | ||
case "single": | ||
if (R(e)) return void K(e); | ||
F(), H(e), g(), w(); | ||
break; | ||
case "multiple": | ||
if (R(e)) return void K(e); | ||
H(e), O(); | ||
break; | ||
case "tags": | ||
if (R(e)) return void K(e); | ||
void 0 === D(e.value) && f.value && (t.emit("tag", e.value), v.value && W(e), O()), H(e); | ||
} | ||
} | ||
}; | ||
} | ||
function A(e) { | ||
return function (e) { | ||
if (Array.isArray(e)) return E(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 E(e, t); | ||
var n = Object.prototype.toString.call(e).slice(8, -1); | ||
"Object" === n && e.constructor && (n = e.constructor.name); | ||
if ("Map" === n || "Set" === n) return Array.from(e); | ||
if ("Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return E(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 E(e, t) { | ||
(null == t || t > e.length) && (t = e.length); | ||
for (var n = 0, l = new Array(t); n < t; n++) { | ||
l[n] = e[n]; | ||
} | ||
return l; | ||
} | ||
var I = { | ||
name: "Multiselect", | ||
emits: ["open", "close", "select", "deselect", "input", "search-change", "tag", "update:modelValue"], | ||
props: { | ||
value: { | ||
required: !1 | ||
}, | ||
modelValue: { | ||
required: !1 | ||
}, | ||
options: { | ||
type: [Array, Object], | ||
required: !1 | ||
}, | ||
id: { | ||
type: [String, Number], | ||
required: !1, | ||
default: "multiselect" | ||
}, | ||
name: { | ||
type: [String, Number], | ||
required: !1, | ||
default: "multiselect" | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
required: !1, | ||
default: !1 | ||
}, | ||
label: { | ||
type: String, | ||
required: !1, | ||
default: "label" | ||
}, | ||
trackBy: { | ||
type: String, | ||
required: !1, | ||
default: "label" | ||
}, | ||
placeholder: { | ||
type: String, | ||
required: !1, | ||
default: null | ||
}, | ||
mode: { | ||
type: String, | ||
required: !1, | ||
default: "single" | ||
}, | ||
searchable: { | ||
type: Boolean, | ||
required: !1, | ||
default: !1 | ||
}, | ||
limit: { | ||
type: Number, | ||
required: !1, | ||
default: -1 | ||
}, | ||
maxHeight: { | ||
type: Number, | ||
required: !1, | ||
default: 160 | ||
}, | ||
hideSelectedTag: { | ||
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 | ||
} | ||
}, | ||
setup: function setup(e, n) { | ||
var i = function (e, t) { | ||
return { | ||
update: function update(e) { | ||
t.emit("input", e), t.emit("update:modelValue", e); | ||
} | ||
}; | ||
}(0, n), | ||
c = function (e, t) { | ||
var n = (0, _compositionApi.toRefs)(e), | ||
u = n.value, | ||
a = n.modelValue; | ||
return { | ||
externalValue: (0, _compositionApi.computed)(function () { | ||
return void 0 === u ? a.value : u.value; | ||
}) | ||
}; | ||
}(e), | ||
s = function (e, t, n) { | ||
var o = (0, _compositionApi.toRefs)(e), | ||
i = o.searchable, | ||
c = o.mode, | ||
s = n.value, | ||
p = (0, _compositionApi.ref)(null), | ||
f = (0, _compositionApi.ref)(null), | ||
d = (0, _compositionApi.computed)(function () { | ||
return p.value ? "".concat(p.value.length, "ch") : "tags" === c.value && -1 === [null, void 0].indexOf(s.value) && s.value.length ? "1ch" : "100%"; | ||
}); | ||
return (0, _compositionApi.watch)(p, function (e) { | ||
t.emit("search-change", e); | ||
}), { | ||
search: p, | ||
input: f, | ||
tagsSearchWidth: d, | ||
clearSearch: function clearSearch() { | ||
p.value = null; | ||
}, | ||
blurSearch: function blurSearch() { | ||
i.value && f.value.blur(); | ||
}, | ||
handleTagsSearchBackspace: function handleTagsSearchBackspace(e) { | ||
null !== p.value && e.stopPropagation(), "" === p.value && (p.value = null); | ||
} | ||
}; | ||
}(e, n, { | ||
value: c.externalValue | ||
}), | ||
p = function (e, t, n) { | ||
var a = (0, _compositionApi.toRefs)(e), | ||
o = a.maxHeight, | ||
i = a.disabled, | ||
c = (0, _compositionApi.ref)(!1), | ||
s = (0, _compositionApi.computed)(function () { | ||
return "".concat(o.value, "px"); | ||
}); | ||
return { | ||
isOpen: c, | ||
contentMaxHeight: s, | ||
open: function open() { | ||
i.value || (c.value = !0, t.emit("open")); | ||
}, | ||
close: function close() { | ||
c.value = !1, t.emit("close"); | ||
} | ||
}; | ||
}(e, n), | ||
f = function (e, t, n) { | ||
var a = (0, _compositionApi.toRefs)(e), | ||
o = a.searchable, | ||
i = a.id; | ||
return { | ||
multiselect: (0, _compositionApi.ref)(null), | ||
tabindex: (0, _compositionApi.computed)(function () { | ||
return o.value ? -1 : 0; | ||
}), | ||
blurInput: function blurInput() { | ||
document.getElementById(i.value).querySelector(".multiselect-input").blur(); | ||
} | ||
}; | ||
}(e), | ||
d = B(e, n, { | ||
value: c.externalValue, | ||
search: s.search, | ||
blurSearch: s.blurSearch, | ||
clearSearch: s.clearSearch, | ||
update: i.update, | ||
blurInput: f.blurInput | ||
}), | ||
v = function (e, t, n) { | ||
var r = (0, _compositionApi.toRefs)(e).id, | ||
i = n.filteredOptions, | ||
c = n.handleOptionClick, | ||
s = n.search, | ||
p = (0, _compositionApi.ref)(null), | ||
f = function f(e) { | ||
p.value = e; | ||
}, | ||
d = function d() { | ||
p.value = i.value[0] || null; | ||
}, | ||
v = function v() { | ||
p.value = null; | ||
}, | ||
m = function m() { | ||
var e = document.getElementById(r.value).querySelector(".is-pointed"); | ||
if (e) { | ||
var t = e.parentElement; | ||
e.offsetTop + e.offsetHeight > t.clientHeight + t.scrollTop && (t.scrollTop = e.offsetTop + e.offsetHeight - t.clientHeight), e.offsetTop < t.scrollTop && (t.scrollTop = e.offsetTop); | ||
} | ||
}; | ||
return (0, _compositionApi.watch)(s, function (e) { | ||
d(); | ||
}), { | ||
pointer: p, | ||
isPointed: function isPointed(e) { | ||
return !!p.value && p.value.value == e.value; | ||
}, | ||
setPointer: f, | ||
setPointerFirst: d, | ||
clearPointer: v, | ||
selectPointer: function selectPointer() { | ||
p.value && (c(p.value), v()); | ||
}, | ||
forwardPointer: function forwardPointer(e) { | ||
if (null === p.value) f(i.value[0]);else { | ||
var t = i.value.map(function (e) { | ||
return e.value; | ||
}).indexOf(p.value.value) + 1; | ||
i.value.length <= t && (t = 0), f(i.value[t]); | ||
} | ||
(0, _compositionApi.nextTick)(function () { | ||
m(); | ||
}); | ||
}, | ||
backwardPointer: function backwardPointer() { | ||
if (null === p.value) f(i.value[i.value.length - 1]);else { | ||
var e = i.value.map(function (e) { | ||
return e.value; | ||
}).indexOf(p.value.value) - 1; | ||
e < 0 && (e = i.value.length - 1), f(i.value[e]); | ||
} | ||
(0, _compositionApi.nextTick)(function () { | ||
m(); | ||
}); | ||
} | ||
}; | ||
}(e, 0, { | ||
filteredOptions: d.filteredOptions, | ||
handleOptionClick: d.handleOptionClick, | ||
search: s.search | ||
}), | ||
m = function (e, t, n) { | ||
var l = n.value, | ||
r = n.update, | ||
u = n.close, | ||
a = n.clearPointer; | ||
return { | ||
handleBackspace: function handleBackspace(e) { | ||
r(A(l.value).slice(0, -1)); | ||
}, | ||
handleEsc: function handleEsc(e) { | ||
u(), a(), e.target.blur(); | ||
} | ||
}; | ||
}(0, 0, { | ||
value: c.externalValue, | ||
update: i.update, | ||
close: p.close, | ||
clearPointer: v.clearPointer | ||
}); | ||
return t(t(t(t(t(t(t(t({}, i), s), p), f), d), v), m), c); | ||
} | ||
}, | ||
C = { | ||
class: "multiselect-single-label" | ||
}, | ||
L = { | ||
class: "multiselect-multiple-label" | ||
}, | ||
M = { | ||
key: 2, | ||
class: "multiselect-tags" | ||
}, | ||
V = { | ||
class: "multiselect-tag" | ||
}, | ||
$ = { | ||
key: 3, | ||
class: "multiselect-search" | ||
}, | ||
H = { | ||
class: "multiselect-spinner" | ||
}, | ||
K = { | ||
class: "multiselect-no-options" | ||
}, | ||
N = { | ||
class: "multiselect-no-results" | ||
}; | ||
I.render = function (e, t, n, l, r, u) { | ||
return (0, _vue.openBlock)(), (0, _vue.createBlock)("div", { | ||
class: ["multiselect", ["is-".concat(n.mode), { | ||
"is-open": e.isOpen, | ||
"is-searchable": n.searchable, | ||
"is-disabled": n.disabled, | ||
"no-caret": !n.caret | ||
}]], | ||
id: n.id, | ||
onKeydown: t[26] || (t[26] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () {}, ["prevent"]), ["enter"])), | ||
ref: "multiselect" | ||
}, [(0, _vue.createVNode)("div", { | ||
class: "multiselect-input", | ||
tabindex: e.tabindex, | ||
onFocus: t[18] || (t[18] = function () { | ||
return e.open && e.open.apply(e, arguments); | ||
}), | ||
onBlur: t[19] || (t[19] = function () { | ||
return e.close && e.close.apply(e, arguments); | ||
}), | ||
onKeyup: [t[20] || (t[20] = (0, _vue.withKeys)(function () { | ||
return e.handleEsc && e.handleEsc.apply(e, arguments); | ||
}, ["esc"])), t[21] || (t[21] = (0, _vue.withKeys)(function () { | ||
return e.selectPointer && e.selectPointer.apply(e, arguments); | ||
}, ["enter"]))], | ||
onKeydown: [t[22] || (t[22] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.handleBackspace && e.handleBackspace.apply(e, arguments); | ||
}, ["prevent"]), ["delete"])), t[23] || (t[23] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.backwardPointer && e.backwardPointer.apply(e, arguments); | ||
}, ["prevent"]), ["up"])), t[24] || (t[24] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.forwardPointer && e.forwardPointer.apply(e, arguments); | ||
}, ["prevent"]), ["down"]))] | ||
}, ["single" == n.mode && e.hasSelected && !e.search && e.valueObject ? (0, _vue.renderSlot)(e.$slots, "singleLabel", { | ||
key: 0, | ||
value: e.valueObject | ||
}, function () { | ||
return [(0, _vue.createVNode)("div", C, (0, _vue.toDisplayString)(e.valueObject[n.label]), 1)]; | ||
}) : (0, _vue.createCommentVNode)("v-if", !0), "multiple" == n.mode && e.hasSelected && !e.search ? (0, _vue.renderSlot)(e.$slots, "multipleLabel", { | ||
key: 1, | ||
values: e.valueObject | ||
}, function () { | ||
return [(0, _vue.createVNode)("div", L, (0, _vue.toDisplayString)(e.multipleLabelText), 1)]; | ||
}) : (0, _vue.createCommentVNode)("v-if", !0), "tags" == n.mode ? ((0, _vue.openBlock)(), (0, _vue.createBlock)("div", M, [((0, _vue.openBlock)(!0), (0, _vue.createBlock)(_vue.Fragment, null, (0, _vue.renderList)(e.valueObject, function (l, r, u) { | ||
return (0, _vue.openBlock)(), (0, _vue.createBlock)("span", { | ||
key: u | ||
}, [(0, _vue.renderSlot)(e.$slots, "tag", { | ||
option: l, | ||
remove: e.remove, | ||
disabled: n.disabled | ||
}, function () { | ||
return [(0, _vue.createVNode)("div", V, [(0, _vue.createTextVNode)((0, _vue.toDisplayString)(l[n.label]) + " ", 1), n.disabled ? (0, _vue.createCommentVNode)("v-if", !0) : ((0, _vue.openBlock)(), (0, _vue.createBlock)("i", { | ||
key: 0, | ||
onClick: t[1] || (t[1] = (0, _vue.withModifiers)(function () {}, ["prevent"])), | ||
onMousedown: (0, _vue.withModifiers)(function (t) { | ||
return e.remove(l); | ||
}, ["prevent"]) | ||
}, null, 40, ["onMousedown"]))])]; | ||
})]); | ||
}), 128)), n.searchable && !n.disabled ? ((0, _vue.openBlock)(), (0, _vue.createBlock)("div", { | ||
key: 0, | ||
class: "multiselect-search", | ||
style: { | ||
width: e.tagsSearchWidth | ||
} | ||
}, [(0, _vue.withDirectives)((0, _vue.createVNode)("input", { | ||
"onUpdate:modelValue": t[2] || (t[2] = function (t) { | ||
return e.search = t; | ||
}), | ||
onFocus: t[3] || (t[3] = (0, _vue.withModifiers)(function () { | ||
return e.open && e.open.apply(e, arguments); | ||
}, ["stop"])), | ||
onBlur: t[4] || (t[4] = (0, _vue.withModifiers)(function () { | ||
return e.close && e.close.apply(e, arguments); | ||
}, ["stop"])), | ||
onKeyup: [t[5] || (t[5] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.handleEsc && e.handleEsc.apply(e, arguments); | ||
}, ["stop"]), ["esc"])), t[6] || (t[6] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.selectPointer && e.selectPointer.apply(e, arguments); | ||
}, ["stop"]), ["enter"]))], | ||
onKeydown: [t[7] || (t[7] = (0, _vue.withKeys)(function () { | ||
return e.handleTagsSearchBackspace && e.handleTagsSearchBackspace.apply(e, arguments); | ||
}, ["delete"])), t[8] || (t[8] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.backwardPointer && e.backwardPointer.apply(e, arguments); | ||
}, ["stop"]), ["up"])), t[9] || (t[9] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.forwardPointer && e.forwardPointer.apply(e, arguments); | ||
}, ["stop"]), ["down"]))], | ||
style: { | ||
width: e.tagsSearchWidth | ||
}, | ||
ref: "input" | ||
}, null, 36), [[_vue.vModelText, e.search]])], 4)) : (0, _vue.createCommentVNode)("v-if", !0)])) : (0, _vue.createCommentVNode)("v-if", !0), "tags" !== n.mode && n.searchable && !n.disabled ? ((0, _vue.openBlock)(), (0, _vue.createBlock)("div", $, [(0, _vue.withDirectives)((0, _vue.createVNode)("input", { | ||
"onUpdate:modelValue": t[10] || (t[10] = function (t) { | ||
return e.search = t; | ||
}), | ||
onFocus: t[11] || (t[11] = (0, _vue.withModifiers)(function () { | ||
return e.open && e.open.apply(e, arguments); | ||
}, ["stop"])), | ||
onBlur: t[12] || (t[12] = (0, _vue.withModifiers)(function () { | ||
return e.close && e.close.apply(e, arguments); | ||
}, ["stop"])), | ||
onKeyup: [t[13] || (t[13] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.handleEsc && e.handleEsc.apply(e, arguments); | ||
}, ["stop"]), ["esc"])), t[14] || (t[14] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.selectPointer && e.selectPointer.apply(e, arguments); | ||
}, ["stop"]), ["enter"]))], | ||
onKeydown: [t[15] || (t[15] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () {}, ["stop"]), ["delete"])), t[16] || (t[16] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.backwardPointer && e.backwardPointer.apply(e, arguments); | ||
}, ["stop"]), ["up"])), t[17] || (t[17] = (0, _vue.withKeys)((0, _vue.withModifiers)(function () { | ||
return e.forwardPointer && e.forwardPointer.apply(e, arguments); | ||
}, ["stop"]), ["down"]))], | ||
ref: "input" | ||
}, null, 544), [[_vue.vModelText, e.search]])])) : (0, _vue.createCommentVNode)("v-if", !0), (0, _vue.withDirectives)((0, _vue.createVNode)("div", { | ||
class: "multiselect-placeholder" | ||
}, (0, _vue.toDisplayString)(n.placeholder), 513), [[_vue.vShow, n.placeholder && !e.hasSelected && !e.search]]), (0, _vue.createVNode)(_vue.Transition, { | ||
name: "multiselect-loading" | ||
}, { | ||
default: (0, _vue.withCtx)(function () { | ||
return [(0, _vue.withDirectives)((0, _vue.createVNode)("div", H, null, 512), [[_vue.vShow, n.loading]])]; | ||
}), | ||
_: 1 | ||
})], 40, ["tabindex"]), (0, _vue.createVNode)(_vue.Transition, { | ||
name: "multiselect", | ||
onAfterLeave: e.clearSearch | ||
}, { | ||
default: (0, _vue.withCtx)(function () { | ||
return [(0, _vue.withDirectives)((0, _vue.createVNode)("div", { | ||
class: "multiselect-options", | ||
style: { | ||
maxHeight: e.contentMaxHeight | ||
} | ||
}, [(0, _vue.renderSlot)(e.$slots, "beforeList"), ((0, _vue.openBlock)(!0), (0, _vue.createBlock)(_vue.Fragment, null, (0, _vue.renderList)(e.filteredOptions, function (l, r, u) { | ||
return (0, _vue.openBlock)(), (0, _vue.createBlock)("a", { | ||
href: "", | ||
class: ["multiselect-option", { | ||
"is-pointed": e.isPointed(l), | ||
"is-selected": e.isSelected(l) | ||
}], | ||
key: u, | ||
onMousedown: t[25] || (t[25] = (0, _vue.withModifiers)(function () {}, ["prevent"])), | ||
onMouseenter: function onMouseenter(t) { | ||
return e.setPointer(l); | ||
}, | ||
onClick: (0, _vue.withModifiers)(function (t) { | ||
return e.handleOptionClick(l); | ||
}, ["stop", "prevent"]) | ||
}, [(0, _vue.renderSlot)(e.$slots, "option", { | ||
option: l, | ||
search: e.search | ||
}, function () { | ||
return [(0, _vue.createVNode)("span", null, (0, _vue.toDisplayString)(l[n.label]), 1)]; | ||
})], 42, ["onMouseenter", "onClick"]); | ||
}), 128)), (0, _vue.withDirectives)((0, _vue.createVNode)("span", null, [(0, _vue.renderSlot)(e.$slots, "noOptions", {}, function () { | ||
return [(0, _vue.createVNode)("div", K, (0, _vue.toDisplayString)(n.noOptionsText), 1)]; | ||
})], 512), [[_vue.vShow, e.noOptions]]), (0, _vue.withDirectives)((0, _vue.createVNode)("span", null, [(0, _vue.renderSlot)(e.$slots, "noResults", {}, function () { | ||
return [(0, _vue.createVNode)("div", N, (0, _vue.toDisplayString)(n.noResultsText), 1)]; | ||
})], 512), [[_vue.vShow, e.noResults]]), (0, _vue.renderSlot)(e.$slots, "afterList")], 4), [[_vue.vShow, e.isOpen]])]; | ||
}), | ||
_: 3 | ||
}, 8, ["onAfterLeave"])], 42, ["id"]); | ||
}, I.__file = "src/Multiselect.vue"; | ||
var _default = I; | ||
_exports.default = _default; | ||
}); | ||
!function(e,t){if("function"==typeof define&&define.amd)define("VueFormMultiselect",["exports","composition-api","vue"],t);else if("undefined"!=typeof exports)t(exports,require("composition-api"),require("vue"));else{var n={exports:{}};t(n.exports,e.Vue,e.Vue),e.VueFormMultiselect=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e,t,n){function r(e){return(r="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){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){return String(e).toLowerCase().trim()}function i(e,t,n,r,l,a,u){try{var o=e[a](u),i=o.value}catch(e){return void n(e)}o.done?t(i):Promise.resolve(i).then(r,l)}function c(e){return function(){var t=this,n=arguments;return new Promise((function(r,l){var a=e.apply(t,n);function u(e){i(a,r,l,u,o,"next",e)}function o(e){i(a,r,l,u,o,"throw",e)}u(void 0)}))}}function s(e){return(s="function"==typeof Symbol&&"symbol"==r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,n,r){var l,a=(0,t.toRefs)(e),u=a.options,i=a.mode,f=a.trackBy,p=a.limit,v=a.hideSelectedTag,h=a.createTag,m=a.label,y=a.appendNewTag,b=a.multipleLabel,g=a.object,w=a.loading,S=a.delay,O=a.resolveOnLoad,k=a.minChars,V=a.filterResults,x=a.clearOnSearch,B=a.clearOnSelect,P=r.internalValue,N=r.externalValue,M=r.search,T=r.blurSearch,q=r.clearSearch,j=r.update,C=r.blurInput,K=(0,t.ref)([]),D=(0,t.ref)([]),R=(0,t.ref)(!1),A=(0,t.computed)((function(){var e,t=D.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,r=t[e];return d(n={value:e},f.value,r),d(n,m.value,r),n}))),t=t.map((function(e,t){var n;return"object"===s(e)?e:(d(n={value:t},f.value,e),d(n,m.value,e),n)})),K.value.length&&(t=t.concat(K.value)),t})),L=(0,t.computed)((function(){var e=A.value;return $.value.length&&(e=$.value.concat(e)),M.value&&V.value&&(e=e.filter((function(e){return-1!==o(e[f.value]).indexOf(o(M.value))}))),v.value&&(e=e.filter((function(e){return!ee(e)}))),p.value>0&&(e=e.slice(0,p.value)),e})),E=(0,t.computed)((function(){switch(i.value){case"single":return!U.value;case"multiple":case"tags":return!U.value&&P.value.length>0}})),F=(0,t.computed)((function(){return void 0!==b&&void 0!==b.value?b.value(P.value):P.value&&P.value.length>1?"".concat(P.value.length," options selected"):"1 option selected"})),H=(0,t.computed)((function(){return!A.value.length})),I=(0,t.computed)((function(){return A.value.length>0&&0==L.value.length})),$=(0,t.computed)((function(){var e;return!1!==h.value&&M.value?-1!==Z(M.value)?[]:[(e={},d(e,m.value,M.value),d(e,f.value,M.value),d(e,"value",M.value),e)]:[]})),_=(0,t.computed)((function(){switch(i.value){case"single":return null;case"multiple":case"tags":return[]}})),U=(0,t.computed)((function(){return-1!==[null,void 0,!1].indexOf(P.value)})),W=(0,t.computed)((function(){return w.value||R.value})),z=function(e){switch("object"!==s(e)&&(e=Y(e)),i.value){case"single":j(e);break;case"multiple":case"tags":j((P.value||[]).concat(e))}n.emit("select",J(e))},G=function(e){switch("object"!==s(e)&&(e=Y(e)),i.value){case"single":Q();break;case"tags":case"multiple":j(P.value.filter((function(t){return t.value!=e.value})))}n.emit("deselect",J(e))},J=function(e){return g.value?e:e.value},Q=function(e){j(_.value)},X=function(e){switch(i.value){case"single":return!U.value&&P.value.value==e.value;case"tags":case"multiple":return!U.value&&-1!==P.value.map((function(e){return e.value})).indexOf(e.value)}},Y=function(e){return A.value[A.value.map((function(e){return e.value})).indexOf(e)]},Z=function(e){return A.value.map((function(e){return o(e[f.value])})).indexOf(o(e))},ee=function(e){return"tags"===i.value&&v.value&&X(e)},te=function(){var e=c(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return R.value=!0,e.next=3,u.value(M.value);case 3:D.value=e.sent,R.value=!1;case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();if("single"!==i.value&&-1===[null,void 0,!1].indexOf(N.value)&&!Array.isArray(N.value))throw new Error('v-model must be an array when using "'.concat(i.value,'" mode'));return u&&"function"==typeof u.value?O.value&&te():D.value=u&&u.value?u.value:[],-1===[null,!1,void 0].indexOf(N.value)&&(P.value=(l=N.value,g.value?l:Array.isArray(l)?l.map((function(e){return Y(e)})):Y(l))),S.value>-1&&(0,t.watch)(M,(function(e){e.length<k.value||(x.value&&(D.value=[]),setTimeout(c(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e==M.value){t.next=2;break}return t.abrupt("return");case 2:return R.value=!0,t.next=5,u.value(M.value);case 5:n=t.sent,e==M.value&&(D.value=n),R.value=!1;case 8:case"end":return t.stop()}}),t)}))),S.value))}),{flush:"sync"}),{filteredOptions:L,hasSelected:E,multipleLabelText:F,extendedOptions:A,noOptions:H,noResults:I,busy:W,select:z,deselect:G,remove:function(e){G(e)},clear:Q,isSelected:X,getOption:Y,handleOptionClick:function(e){switch(i.value){case"single":if(X(e))return void G(e);Q(),z(e),T(),C();break;case"multiple":if(X(e))return void G(e);z(e),B.value&&q();break;case"tags":if(X(e))return void G(e);void 0===Y(e.value)&&h.value&&(n.emit("tag",e.value),y.value&&function(e){K.value.push(e)}(e),q()),B.value&&q(),z(e)}}}}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var v={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var r,l,u,o,i,c=function(e,n){var r=(0,t.toRefs)(e),l=r.value,a=r.modelValue,u=r.mode;return{internalValue:(0,t.ref)("single"!==u.value?[]:null),externalValue:(0,t.computed)((function(){return void 0!==n.expose?a.value:l.value}))}}(e,n),s=function(e,n,r){var l=(0,t.toRefs)(e).object,a=r.internalValue,u=function(e){return l.value||-1!==[null,!1,void 0].indexOf(e)?e:Array.isArray(e)?e.map((function(e){return e.value})):e.value};return{update:function(e){a.value=e,n.emit("input",u(e)),n.emit("update:modelValue",u(e))}}}(e,n,{internalValue:c.internalValue}),d=function(e,n,r){var l=(0,t.toRefs)(e),a=l.searchable,u=l.mode,o=r.internalValue,i=(0,t.ref)(null),c=(0,t.ref)(null),s=(0,t.computed)((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===u.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"}));return(0,t.watch)(i,(function(e){n.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=""},blurSearch:function(){a.value&&c.value.blur()},handleSearchBackspace:function(e){""!==i.value&&e.stopPropagation()}}}(e,n,{internalValue:c.internalValue}),v=function(e,n,r){var l=(0,t.toRefs)(e),a=l.maxHeight,u=l.disabled,o=(0,t.ref)(!1),i=(0,t.computed)((function(){return"".concat(a.value,"px")}));return{isOpen:o,contentMaxHeight:i,open:function(){u.value||(o.value=!0,n.emit("open"))},close:function(){o.value=!1,n.emit("close")}}}(e,n),h=function(e,n,r){var l=(0,t.toRefs)(e),a=l.searchable,u=l.id;return{multiselect:(0,t.ref)(null),tabindex:(0,t.computed)((function(){return a.value?-1:0})),blurInput:function(){document.getElementById(u.value).querySelector(".multiselect-input").blur()}}}(e),m=f(e,n,{externalValue:c.externalValue,internalValue:c.internalValue,search:d.search,blurSearch:d.blurSearch,clearSearch:d.clearSearch,update:s.update,blurInput:h.blurInput}),y=function(e,n,r){var l=(0,t.toRefs)(e).id,a=r.filteredOptions,u=r.handleOptionClick,o=r.search,i=(0,t.ref)(null),c=function(e){i.value=e},s=function(){i.value=a.value[0]||null},d=function(){i.value=null},f=function(){var e=document.getElementById(l.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return(0,t.watch)(o,(function(e){s()})),{pointer:i,isPointed:function(e){return!!i.value&&i.value.value==e.value},setPointer:c,setPointerFirst:s,clearPointer:d,selectPointer:function(){i.value&&(u(i.value),d())},forwardPointer:function(e){if(null===i.value)c(a.value[0]);else{var n=a.value.map((function(e){return e.value})).indexOf(i.value.value)+1;a.value.length<=n&&(n=0),c(a.value[n])}(0,t.nextTick)((function(){f()}))},backwardPointer:function(){if(null===i.value)c(a.value[a.value.length-1]);else{var e=a.value.map((function(e){return e.value})).indexOf(i.value.value)-1;e<0&&(e=a.value.length-1),c(a.value[e])}(0,t.nextTick)((function(){f()}))}}}(e,0,{filteredOptions:m.filteredOptions,handleOptionClick:m.handleOptionClick,search:d.search}),b=(r={internalValue:c.internalValue,update:s.update,close:v.close,clearPointer:y.clearPointer},l=r.internalValue,u=r.update,o=r.close,i=r.clearPointer,{handleBackspace:function(e){u(function(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,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}(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.")}()}(l.value).slice(0,-1))},handleEsc:function(e){o(),i(),e.target.blur()}});return a(a(a(a(a(a(a(a({},c),s),d),v),h),m),y),b)}},h={class:"multiselect-single-label"},m={class:"multiselect-multiple-label"},y={key:2,class:"multiselect-search"},b={key:3,class:"multiselect-tags"},g={class:"multiselect-tag"},w={class:"multiselect-spinner"},S={class:"multiselect-no-options"},O={class:"multiselect-no-results"};v.render=function(e,t,r,l,a,u){return(0,n.openBlock)(),(0,n.createBlock)("div",{class:["multiselect",["is-".concat(r.mode),{"is-open":e.isOpen,"is-searchable":r.searchable,"is-disabled":r.disabled,"no-caret":!r.caret}]],id:r.id,onKeydown:t[26]||(t[26]=(0,n.withKeys)((0,n.withModifiers)((function(){}),["prevent"]),["enter"])),ref:"multiselect"},[(0,n.createVNode)("div",{class:"multiselect-input",tabindex:e.tabindex,onFocus:t[18]||(t[18]=function(){return e.open&&e.open.apply(e,arguments)}),onBlur:t[19]||(t[19]=function(){return e.close&&e.close.apply(e,arguments)}),onKeyup:[t[20]||(t[20]=(0,n.withKeys)((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["esc"])),t[21]||(t[21]=(0,n.withKeys)((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["enter"]))],onKeydown:[t[22]||(t[22]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.handleBackspace&&e.handleBackspace.apply(e,arguments)}),["prevent"]),["delete"])),t[23]||(t[23]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["prevent"]),["up"])),t[24]||(t[24]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["prevent"]),["down"]))]},[(0,n.createCommentVNode)(" Single label "),"single"==r.mode&&e.hasSelected&&!e.search&&e.internalValue?(0,n.renderSlot)(e.$slots,"singleLabel",{key:0,value:e.internalValue},(function(){return[(0,n.createVNode)("div",h,(0,n.toDisplayString)(e.internalValue[r.label]),1)]})):(0,n.createCommentVNode)("v-if",!0),(0,n.createCommentVNode)(" Multiple label "),"multiple"==r.mode&&e.hasSelected&&!e.search?(0,n.renderSlot)(e.$slots,"multipleLabel",{key:1,values:e.internalValue},(function(){return[(0,n.createVNode)("div",m,(0,n.toDisplayString)(e.multipleLabelText),1)]})):(0,n.createCommentVNode)("v-if",!0),(0,n.createCommentVNode)(" Search "),"tags"!==r.mode&&r.searchable&&!r.disabled?((0,n.openBlock)(),(0,n.createBlock)("div",y,[(0,n.withDirectives)((0,n.createVNode)("input",{"onUpdate:modelValue":t[1]||(t[1]=function(t){return e.search=t}),onFocus:t[2]||(t[2]=(0,n.withModifiers)((function(){return e.open&&e.open.apply(e,arguments)}),["stop"])),onBlur:t[3]||(t[3]=(0,n.withModifiers)((function(){return e.close&&e.close.apply(e,arguments)}),["stop"])),onKeyup:[t[4]||(t[4]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["stop"]),["esc"])),t[5]||(t[5]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["stop"]),["enter"]))],onKeydown:[t[6]||(t[6]=(0,n.withKeys)((function(){return e.handleSearchBackspace&&e.handleSearchBackspace.apply(e,arguments)}),["delete"])),t[7]||(t[7]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["stop"]),["up"])),t[8]||(t[8]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["stop"]),["down"]))],ref:"input"},null,544),[[n.vModelText,e.search]])])):(0,n.createCommentVNode)("v-if",!0),(0,n.createCommentVNode)(" Tags (with search) "),"tags"==r.mode?((0,n.openBlock)(),(0,n.createBlock)("div",b,[((0,n.openBlock)(!0),(0,n.createBlock)(n.Fragment,null,(0,n.renderList)(e.internalValue,(function(l,a,u){return(0,n.openBlock)(),(0,n.createBlock)("span",{key:u},[(0,n.renderSlot)(e.$slots,"tag",{option:l,remove:e.remove,disabled:r.disabled},(function(){return[(0,n.createVNode)("div",g,[(0,n.createTextVNode)((0,n.toDisplayString)(l[r.label])+" ",1),r.disabled?(0,n.createCommentVNode)("v-if",!0):((0,n.openBlock)(),(0,n.createBlock)("i",{key:0,onClick:t[9]||(t[9]=(0,n.withModifiers)((function(){}),["prevent"])),onMousedown:(0,n.withModifiers)((function(t){return e.remove(l)}),["prevent"])},null,40,["onMousedown"]))])]}))])})),128)),r.searchable&&!r.disabled?((0,n.openBlock)(),(0,n.createBlock)("div",{key:0,class:"multiselect-search",style:{width:e.tagsSearchWidth}},[(0,n.withDirectives)((0,n.createVNode)("input",{"onUpdate:modelValue":t[10]||(t[10]=function(t){return e.search=t}),onFocus:t[11]||(t[11]=(0,n.withModifiers)((function(){return e.open&&e.open.apply(e,arguments)}),["stop"])),onBlur:t[12]||(t[12]=(0,n.withModifiers)((function(){return e.close&&e.close.apply(e,arguments)}),["stop"])),onKeyup:[t[13]||(t[13]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.handleEsc&&e.handleEsc.apply(e,arguments)}),["stop"]),["esc"])),t[14]||(t[14]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.selectPointer&&e.selectPointer.apply(e,arguments)}),["stop"]),["enter"]))],onKeydown:[t[15]||(t[15]=(0,n.withKeys)((function(){return e.handleSearchBackspace&&e.handleSearchBackspace.apply(e,arguments)}),["delete"])),t[16]||(t[16]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.backwardPointer&&e.backwardPointer.apply(e,arguments)}),["stop"]),["up"])),t[17]||(t[17]=(0,n.withKeys)((0,n.withModifiers)((function(){return e.forwardPointer&&e.forwardPointer.apply(e,arguments)}),["stop"]),["down"]))],style:{width:e.tagsSearchWidth},ref:"input"},null,36),[[n.vModelText,e.search]])],4)):(0,n.createCommentVNode)("v-if",!0)])):(0,n.createCommentVNode)("v-if",!0),(0,n.createCommentVNode)(" Placeholder "),(0,n.withDirectives)((0,n.createVNode)("div",{class:"multiselect-placeholder"},(0,n.toDisplayString)(r.placeholder),513),[[n.vShow,r.placeholder&&!e.hasSelected&&!e.search]]),(0,n.createVNode)(n.Transition,{name:"multiselect-loading"},{default:(0,n.withCtx)((function(){return[(0,n.withDirectives)((0,n.createVNode)("div",w,null,512),[[n.vShow,e.busy]])]})),_:1})],40,["tabindex"]),(0,n.createCommentVNode)(" Options "),(0,n.createVNode)(n.Transition,{name:"multiselect",onAfterLeave:e.clearSearch},{default:(0,n.withCtx)((function(){return[(0,n.withDirectives)((0,n.createVNode)("div",{class:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[(0,n.renderSlot)(e.$slots,"beforeList"),((0,n.openBlock)(!0),(0,n.createBlock)(n.Fragment,null,(0,n.renderList)(e.filteredOptions,(function(l,a,u){return(0,n.openBlock)(),(0,n.createBlock)("a",{href:"",class:["multiselect-option",{"is-pointed":e.isPointed(l),"is-selected":e.isSelected(l)}],key:u,onMousedown:t[25]||(t[25]=(0,n.withModifiers)((function(){}),["prevent"])),onMouseenter:function(t){return e.setPointer(l)},onClick:(0,n.withModifiers)((function(t){return e.handleOptionClick(l)}),["stop","prevent"])},[(0,n.renderSlot)(e.$slots,"option",{option:l,search:e.search},(function(){return[(0,n.createVNode)("span",null,(0,n.toDisplayString)(l[r.label]),1)]}))],42,["onMouseenter","onClick"])})),128)),(0,n.withDirectives)((0,n.createVNode)("span",null,[(0,n.renderSlot)(e.$slots,"noOptions",{},(function(){return[(0,n.createVNode)("div",S,(0,n.toDisplayString)(r.noOptionsText),1)]}))],512),[[n.vShow,e.noOptions]]),(0,n.withDirectives)((0,n.createVNode)("span",null,[(0,n.renderSlot)(e.$slots,"noResults",{},(function(){return[(0,n.createVNode)("div",O,(0,n.toDisplayString)(r.noResultsText),1)]}))],512),[[n.vShow,e.noResults]]),(0,n.renderSlot)(e.$slots,"afterList")],4),[[n.vShow,e.isOpen]])]})),_:3},8,["onAfterLeave"])],42,["id"])},v.__file="src/Multiselect.vue";var k=v;e.default=k})); |
@@ -1,1 +0,1 @@ | ||
function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?e(Object(a),!0).forEach((function(e){n(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):e(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}import{toRefs as r,computed as a,ref as l,watch as u,nextTick as o}from"@vue/composition-api";function i(e){return String(e).toLowerCase().trim()}function c(e){return function(e){if(Array.isArray(e))return s(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 s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(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 s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e,t,n){var u=r(e),o=u.options,s=u.mode,f=u.trackBy,v=u.limit,y=u.hideSelectedTag,m=u.createTag,h=u.label,b=u.appendNewTag,g=u.multipleLabel,k=u.object,O=n.value,_=n.search,w=n.blurSearch,S=n.clearSearch,x=n.update,P=n.blurInput,C=l([]),j=a((function(){var e,t=void 0===o||void 0===o.value?[]:o.value;return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,r=t[e];return p(n={value:e},f.value,r),p(n,h.value,r),n}))),t=t.map((function(e,t){var n;return"object"===d(e)?e:(p(n={value:t},f.value,e),p(n,h.value,e),n)})),C.value.length&&(t=t.concat(C.value)),t})),T=a((function(){var e=j.value;return N.value.length&&(e=N.value.concat(e)),_.value&&(e=e.filter((function(e){return-1!==i(e[f.value]).indexOf(i(_.value))}))),y.value&&(e=e.filter((function(e){return!W(e)}))),v.value>0&&(e=e.slice(0,v.value)),e})),E=a((function(){return R.value||0===O.value.length||k.value?O.value:"single"==s.value?F(O.value):O.value.map((function(e){return F(e)}))})),q=a((function(){switch(s.value){case"single":return!R.value;case"multiple":case"tags":return!R.value&&O.value.length>0}})),D=a((function(){return void 0!==g&&void 0!==g.value?g.value(O.value):O.value&&O.value.length>1?"".concat(O.value.length," options selected"):"1 option selected"})),A=a((function(){return!j.value.length})),B=a((function(){return j.value.length>0&&0==T.value.length})),N=a((function(){var e;return!1!==m.value&&_.value?-1!==M(_.value)?[]:[(e={},p(e,h.value,_.value),p(e,f.value,_.value),p(e,"value",_.value),e)]:[]})),I=a((function(){switch(s.value){case"single":return null;case"multiple":case"tags":return[]}})),R=a((function(){return-1!==[null,void 0,!1].indexOf(O.value)})),U=function(e){switch("object"!==d(e)&&(e=F(e)),s.value){case"single":x(H(e));break;case"multiple":case"tags":x(c(O.value||[]).concat(H(e)))}t.emit("select",H(e))},V=function(e){switch("object"!==d(e)&&(e=F(e)),s.value){case"single":L();break;case"tags":case"multiple":x(O.value.filter((function(t){return k.value&&t.value!=e.value||!k.value&&t!=e.value})))}t.emit("deselect",H(e))},H=function(e){return k.value?e:e.value},L=function(e){x(I.value)},$=function(e){switch(s.value){case"single":return!R.value&&E.value.value==e.value;case"tags":case"multiple":return!R.value&&-1!==E.value.map((function(e){return e.value})).indexOf(e.value)}},F=function(e){return j.value[j.value.map((function(e){return e.value})).indexOf(e)]},M=function(e){return j.value.map((function(e){return i(e[f.value])})).indexOf(i(e))},W=function(e){return"tags"===s.value&&y.value&&$(e)},X=function(e){C.value.push(e)};return{filteredOptions:T,hasSelected:q,multipleLabelText:D,extendedOptions:j,noOptions:A,noResults:B,valueObject:E,select:U,deselect:V,remove:function(e){V(e)},clear:L,isSelected:$,getOption:F,handleOptionClick:function(e){switch(s.value){case"single":if($(e))return void V(e);L(),U(e),w(),P();break;case"multiple":if($(e))return void V(e);U(e),S();break;case"tags":if($(e))return void V(e);void 0===F(e.value)&&m.value&&(t.emit("tag",e.value),b.value&&X(e),S()),U(e)}}}}function v(e){return function(e){if(Array.isArray(e))return y(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 y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(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 y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,u,o,i,c){"boolean"!=typeof u&&(i=o,o=u,u=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),r&&(d._scopeId=r),l?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},d._ssrRegister=s):t&&(s=u?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),s)if(d.functional){var p=d.render;d.render=function(e,t){return s.call(t),p(e,t)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,s):[s]}return n}var h={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var i=function(e,t){return{update:function(e){t.emit("input",e),t.emit("update:modelValue",e)}}}(0,n),c=function(e,t){var n=r(e),l=n.value,u=n.modelValue;return{externalValue:a((function(){return void 0===l?u.value:l.value}))}}(e),s=function(e,t,n){var o=r(e),i=o.searchable,c=o.mode,s=n.value,d=l(null),p=l(null),f=a((function(){return d.value?"".concat(d.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return u(d,(function(e){t.emit("search-change",e)})),{search:d,input:p,tagsSearchWidth:f,clearSearch:function(){d.value=null},blurSearch:function(){i.value&&p.value.blur()},handleTagsSearchBackspace:function(e){null!==d.value&&e.stopPropagation(),""===d.value&&(d.value=null)}}}(e,n,{value:c.externalValue}),d=function(e,t,n){var u=r(e),o=u.maxHeight,i=u.disabled,c=l(!1),s=a((function(){return"".concat(o.value,"px")}));return{isOpen:c,contentMaxHeight:s,open:function(){i.value||(c.value=!0,t.emit("open"))},close:function(){c.value=!1,t.emit("close")}}}(e,n),p=function(e,t,n){var u=r(e),o=u.searchable,i=u.id;return{multiselect:l(null),tabindex:a((function(){return o.value?-1:0})),blurInput:function(){document.getElementById(i.value).querySelector(".multiselect-input").blur()}}}(e),y=f(e,n,{value:c.externalValue,search:s.search,blurSearch:s.blurSearch,clearSearch:s.clearSearch,update:i.update,blurInput:p.blurInput}),m=function(e,t,n){var a=r(e).id,i=n.filteredOptions,c=n.handleOptionClick,s=n.search,d=l(null),p=function(e){d.value=e},f=function(){d.value=i.value[0]||null},v=function(){d.value=null},y=function(){var e=document.getElementById(a.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return u(s,(function(e){f()})),{pointer:d,isPointed:function(e){return!!d.value&&d.value.value==e.value},setPointer:p,setPointerFirst:f,clearPointer:v,selectPointer:function(){d.value&&(c(d.value),v())},forwardPointer:function(e){if(null===d.value)p(i.value[0]);else{var t=i.value.map((function(e){return e.value})).indexOf(d.value.value)+1;i.value.length<=t&&(t=0),p(i.value[t])}o((function(){y()}))},backwardPointer:function(){if(null===d.value)p(i.value[i.value.length-1]);else{var e=i.value.map((function(e){return e.value})).indexOf(d.value.value)-1;e<0&&(e=i.value.length-1),p(i.value[e])}o((function(){y()}))}}}(e,0,{filteredOptions:y.filteredOptions,handleOptionClick:y.handleOptionClick,search:s.search}),h=function(e,t,n){var r=n.value,a=n.update,l=n.close,u=n.clearPointer;return{handleBackspace:function(e){a(v(r.value).slice(0,-1))},handleEsc:function(e){l(),u(),e.target.blur()}}}(0,0,{value:c.externalValue,update:i.update,close:d.close,clearPointer:m.clearPointer});return t(t(t(t(t(t(t(t({},i),s),d),p),y),m),h),c)}},b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{focus:e.open,blur:e.close,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.selectPointer(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.valueObject?[e._t("singleLabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.valueObject[e.label])+"\n ")])],{value:e.valueObject})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multipleLabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.valueObject})]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.valueObject,(function(t,r,a){return n("span",{key:a},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),e.remove(t)}}})])],{option:t,remove:e.remove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleTagsSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"]))return null;t.stopPropagation()},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:e.placeholder&&!e.hasSelected&&!e.search,expression:"placeholder && !hasSelected && !search"}],staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")]),e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.loading,expression:"loading"}],staticClass:"multiselect-spinner"})])],2),e._v(" "),n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforeList"),e._v(" "),e._l(e.filteredOptions,(function(t,r,a){return n("a",{key:a,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t)},attrs:{href:""},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("noOptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noResults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterList")],2)])],1)};b._withStripped=!0;var g=m({render:b,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);export default g; | ||
function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?e(Object(a),!0).forEach((function(e){n(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):e(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}import{toRefs as r,ref as a,computed as l,watch as u,nextTick as i}from"@vue/composition-api";function o(e){return String(e).toLowerCase().trim()}function c(e,t,n,r,a,l,u){try{var i=e[l](u),o=i.value}catch(e){return void n(e)}i.done?t(o):Promise.resolve(o).then(r,a)}function s(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var l=e.apply(t,n);function u(e){c(l,r,a,u,i,"next",e)}function i(e){c(l,r,a,u,i,"throw",e)}u(void 0)}))}}function d(e){return(d="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 v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t,n){var i,c=r(e),p=c.options,f=c.mode,y=c.trackBy,m=c.limit,h=c.hideSelectedTag,b=c.createTag,g=c.label,k=c.appendNewTag,O=c.multipleLabel,w=c.object,_=c.loading,x=c.delay,S=c.resolveOnLoad,P=c.minChars,C=c.filterResults,q=c.clearOnSearch,j=c.clearOnSelect,V=n.internalValue,T=n.externalValue,E=n.search,B=n.blurSearch,D=n.clearSearch,A=n.update,R=n.blurInput,N=a([]),L=a([]),I=a(!1),H=l((function(){var e,t=L.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,r=t[e];return v(n={value:e},y.value,r),v(n,g.value,r),n}))),t=t.map((function(e,t){var n;return"object"===d(e)?e:(v(n={value:t},y.value,e),v(n,g.value,e),n)})),N.value.length&&(t=t.concat(N.value)),t})),U=l((function(){var e=H.value;return X.value.length&&(e=X.value.concat(e)),E.value&&C.value&&(e=e.filter((function(e){return-1!==o(e[y.value]).indexOf(o(E.value))}))),h.value&&(e=e.filter((function(e){return!re(e)}))),m.value>0&&(e=e.slice(0,m.value)),e})),$=l((function(){switch(f.value){case"single":return!G.value;case"multiple":case"tags":return!G.value&&V.value.length>0}})),F=l((function(){return void 0!==O&&void 0!==O.value?O.value(V.value):V.value&&V.value.length>1?"".concat(V.value.length," options selected"):"1 option selected"})),M=l((function(){return!H.value.length})),W=l((function(){return H.value.length>0&&0==U.value.length})),X=l((function(){var e;return!1!==b.value&&E.value?-1!==ne(E.value)?[]:[(e={},v(e,g.value,E.value),v(e,y.value,E.value),v(e,"value",E.value),e)]:[]})),z=l((function(){switch(f.value){case"single":return null;case"multiple":case"tags":return[]}})),G=l((function(){return-1!==[null,void 0,!1].indexOf(V.value)})),J=l((function(){return _.value||I.value})),K=function(e){switch("object"!==d(e)&&(e=te(e)),f.value){case"single":A(e);break;case"multiple":case"tags":A((V.value||[]).concat(e))}t.emit("select",Y(e))},Q=function(e){switch("object"!==d(e)&&(e=te(e)),f.value){case"single":Z();break;case"tags":case"multiple":A(V.value.filter((function(t){return t.value!=e.value})))}t.emit("deselect",Y(e))},Y=function(e){return w.value?e:e.value},Z=function(e){A(z.value)},ee=function(e){switch(f.value){case"single":return!G.value&&V.value.value==e.value;case"tags":case"multiple":return!G.value&&-1!==V.value.map((function(e){return e.value})).indexOf(e.value)}},te=function(e){return H.value[H.value.map((function(e){return e.value})).indexOf(e)]},ne=function(e){return H.value.map((function(e){return o(e[y.value])})).indexOf(o(e))},re=function(e){return"tags"===f.value&&h.value&&ee(e)},ae=function(e){N.value.push(e)},le=function(){var e=s(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return I.value=!0,e.next=3,p.value(E.value);case 3:L.value=e.sent,I.value=!1;case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();if("single"!==f.value&&-1===[null,void 0,!1].indexOf(T.value)&&!Array.isArray(T.value))throw new Error('v-model must be an array when using "'.concat(f.value,'" mode'));return p&&"function"==typeof p.value?S.value&&le():L.value=p&&p.value?p.value:[],-1===[null,!1,void 0].indexOf(T.value)&&(V.value=(i=T.value,w.value?i:Array.isArray(i)?i.map((function(e){return te(e)})):te(i))),x.value>-1&&u(E,(function(e){e.length<P.value||(q.value&&(L.value=[]),setTimeout(s(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e==E.value){t.next=2;break}return t.abrupt("return");case 2:return I.value=!0,t.next=5,p.value(E.value);case 5:n=t.sent,e==E.value&&(L.value=n),I.value=!1;case 8:case"end":return t.stop()}}),t)}))),x.value))}),{flush:"sync"}),{filteredOptions:U,hasSelected:$,multipleLabelText:F,extendedOptions:H,noOptions:M,noResults:W,busy:J,select:K,deselect:Q,remove:function(e){Q(e)},clear:Z,isSelected:ee,getOption:te,handleOptionClick:function(e){switch(f.value){case"single":if(ee(e))return void Q(e);Z(),K(e),B(),R();break;case"multiple":if(ee(e))return void Q(e);K(e),j.value&&D();break;case"tags":if(ee(e))return void Q(e);void 0===te(e.value)&&b.value&&(t.emit("tag",e.value),k.value&&ae(e),D()),j.value&&D(),K(e)}}}}function f(e){return function(e){if(Array.isArray(e))return y(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 y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(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 y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,u,i,o,c){"boolean"!=typeof u&&(o=i,i=u,u=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),r&&(d._scopeId=r),l?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,o(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},d._ssrRegister=s):t&&(s=u?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,i(e))}),s)if(d.functional){var v=d.render;d.render=function(e,t){return s.call(t),v(e,t)}}else{var p=d.beforeCreate;d.beforeCreate=p?[].concat(p,s):[s]}return n}var h={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var o,c,s,d,v,y=function(e,t){var n=r(e),u=n.value,i=n.modelValue,o=n.mode;return{internalValue:a("single"!==o.value?[]:null),externalValue:l((function(){return void 0!==t.expose?i.value:u.value}))}}(e,n),m=function(e,t,n){var a=r(e).object,l=n.internalValue,u=function(e){return a.value||-1!==[null,!1,void 0].indexOf(e)?e:Array.isArray(e)?e.map((function(e){return e.value})):e.value};return{update:function(e){l.value=e,t.emit("input",u(e)),t.emit("update:modelValue",u(e))}}}(e,n,{internalValue:y.internalValue}),h=function(e,t,n){var i=r(e),o=i.searchable,c=i.mode,s=n.internalValue,d=a(null),v=a(null),p=l((function(){return d.value?"".concat(d.value.length,"ch"):"tags"===c.value&&-1===[null,void 0].indexOf(s.value)&&s.value.length?"1ch":"100%"}));return u(d,(function(e){t.emit("search-change",e)})),{search:d,input:v,tagsSearchWidth:p,clearSearch:function(){d.value=""},blurSearch:function(){o.value&&v.value.blur()},handleSearchBackspace:function(e){""!==d.value&&e.stopPropagation()}}}(e,n,{internalValue:y.internalValue}),b=function(e,t,n){var u=r(e),i=u.maxHeight,o=u.disabled,c=a(!1),s=l((function(){return"".concat(i.value,"px")}));return{isOpen:c,contentMaxHeight:s,open:function(){o.value||(c.value=!0,t.emit("open"))},close:function(){c.value=!1,t.emit("close")}}}(e,n),g=function(e,t,n){var u=r(e),i=u.searchable,o=u.id;return{multiselect:a(null),tabindex:l((function(){return i.value?-1:0})),blurInput:function(){document.getElementById(o.value).querySelector(".multiselect-input").blur()}}}(e),k=p(e,n,{externalValue:y.externalValue,internalValue:y.internalValue,search:h.search,blurSearch:h.blurSearch,clearSearch:h.clearSearch,update:m.update,blurInput:g.blurInput}),O=function(e,t,n){var l=r(e).id,o=n.filteredOptions,c=n.handleOptionClick,s=n.search,d=a(null),v=function(e){d.value=e},p=function(){d.value=o.value[0]||null},f=function(){d.value=null},y=function(){var e=document.getElementById(l.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return u(s,(function(e){p()})),{pointer:d,isPointed:function(e){return!!d.value&&d.value.value==e.value},setPointer:v,setPointerFirst:p,clearPointer:f,selectPointer:function(){d.value&&(c(d.value),f())},forwardPointer:function(e){if(null===d.value)v(o.value[0]);else{var t=o.value.map((function(e){return e.value})).indexOf(d.value.value)+1;o.value.length<=t&&(t=0),v(o.value[t])}i((function(){y()}))},backwardPointer:function(){if(null===d.value)v(o.value[o.value.length-1]);else{var e=o.value.map((function(e){return e.value})).indexOf(d.value.value)-1;e<0&&(e=o.value.length-1),v(o.value[e])}i((function(){y()}))}}}(e,0,{filteredOptions:k.filteredOptions,handleOptionClick:k.handleOptionClick,search:h.search}),w=(o={internalValue:y.internalValue,update:m.update,close:b.close,clearPointer:O.clearPointer},c=o.internalValue,s=o.update,d=o.close,v=o.clearPointer,{handleBackspace:function(e){s(f(c.value).slice(0,-1))},handleEsc:function(e){d(),v(),e.target.blur()}});return t(t(t(t(t(t(t(t({},y),m),h),b),g),k),O),w)}},b=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{focus:e.open,blur:e.close,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.selectPointer(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.internalValue?[e._t("singleLabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.internalValue[e.label])+"\n ")])],{value:e.internalValue})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multipleLabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.internalValue})]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.internalValue,(function(t,r,a){return n("span",{key:a},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),e.remove(t)}}})])],{option:t,remove:e.remove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:e.placeholder&&!e.hasSelected&&!e.search,expression:"placeholder && !hasSelected && !search"}],staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")]),e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.busy,expression:"busy"}],staticClass:"multiselect-spinner"})])],2),e._v(" "),n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforeList"),e._v(" "),e._l(e.filteredOptions,(function(t,r,a){return n("a",{key:a,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t)},attrs:{href:""},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("noOptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noResults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterList")],2)])],1)};b._withStripped=!0;var g=m({render:b,staticRenderFns:[]},undefined,h,undefined,false,undefined,!1,void 0,void 0,void 0);export default g; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("function"==typeof define&&define.amd)define("VueFormMultiselect",["exports","composition-api"],t);else if("undefined"!=typeof exports)t(exports,require("composition-api"));else{var n={exports:{}};t(n.exports,e.VueCompositionAPI),e.VueFormMultiselect=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){return String(e).toLowerCase().trim()}function u(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){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(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 n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e){return(c="function"==typeof Symbol&&"symbol"==n(Symbol.iterator)?function(e){return n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)})(e)}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,n,r){var a=(0,t.toRefs)(e),l=a.options,i=a.mode,d=a.trackBy,p=a.limit,f=a.hideSelectedTag,v=a.createTag,y=a.label,m=a.appendNewTag,h=a.multipleLabel,b=a.object,g=r.value,k=r.search,O=r.blurSearch,_=r.clearSearch,w=r.update,S=r.blurInput,x=(0,t.ref)([]),P=(0,t.computed)((function(){var e,t=void 0===l||void 0===l.value?[]:l.value;return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,r=t[e];return s(n={value:e},d.value,r),s(n,y.value,r),n}))),t=t.map((function(e,t){var n;return"object"===c(e)?e:(s(n={value:t},d.value,e),s(n,y.value,e),n)})),x.value.length&&(t=t.concat(x.value)),t})),C=(0,t.computed)((function(){var e=P.value;return A.value.length&&(e=A.value.concat(e)),k.value&&(e=e.filter((function(e){return-1!==o(e[d.value]).indexOf(o(k.value))}))),f.value&&(e=e.filter((function(e){return!M(e)}))),p.value>0&&(e=e.slice(0,p.value)),e})),j=(0,t.computed)((function(){return R.value||0===g.value.length||b.value?g.value:"single"==i.value?L(g.value):g.value.map((function(e){return L(e)}))})),T=(0,t.computed)((function(){switch(i.value){case"single":return!R.value;case"multiple":case"tags":return!R.value&&g.value.length>0}})),E=(0,t.computed)((function(){return void 0!==h&&void 0!==h.value?h.value(g.value):g.value&&g.value.length>1?"".concat(g.value.length," options selected"):"1 option selected"})),q=(0,t.computed)((function(){return!P.value.length})),D=(0,t.computed)((function(){return P.value.length>0&&0==C.value.length})),A=(0,t.computed)((function(){var e;return!1!==v.value&&k.value?-1!==$(k.value)?[]:[(e={},s(e,y.value,k.value),s(e,d.value,k.value),s(e,"value",k.value),e)]:[]})),B=(0,t.computed)((function(){switch(i.value){case"single":return null;case"multiple":case"tags":return[]}})),R=(0,t.computed)((function(){return-1!==[null,void 0,!1].indexOf(g.value)})),N=function(e){switch("object"!==c(e)&&(e=L(e)),i.value){case"single":w(V(e));break;case"multiple":case"tags":w(u(g.value||[]).concat(V(e)))}n.emit("select",V(e))},I=function(e){switch("object"!==c(e)&&(e=L(e)),i.value){case"single":U();break;case"tags":case"multiple":w(g.value.filter((function(t){return b.value&&t.value!=e.value||!b.value&&t!=e.value})))}n.emit("deselect",V(e))},V=function(e){return b.value?e:e.value},U=function(e){w(B.value)},H=function(e){switch(i.value){case"single":return!R.value&&j.value.value==e.value;case"tags":case"multiple":return!R.value&&-1!==j.value.map((function(e){return e.value})).indexOf(e.value)}},L=function(e){return P.value[P.value.map((function(e){return e.value})).indexOf(e)]},$=function(e){return P.value.map((function(e){return o(e[d.value])})).indexOf(o(e))},M=function(e){return"tags"===i.value&&f.value&&H(e)};return{filteredOptions:C,hasSelected:T,multipleLabelText:E,extendedOptions:P,noOptions:q,noResults:D,valueObject:j,select:N,deselect:I,remove:function(e){I(e)},clear:U,isSelected:H,getOption:L,handleOptionClick:function(e){switch(i.value){case"single":if(H(e))return void I(e);U(),N(e),O(),S();break;case"multiple":if(H(e))return void I(e);N(e),_();break;case"tags":if(H(e))return void I(e);void 0===L(e.value)&&v.value&&(n.emit("tag",e.value),m.value&&function(e){x.value.push(e)}(e),_()),N(e)}}}}function p(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}(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 f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var v={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var r=function(e,t){return{update:function(e){t.emit("input",e),t.emit("update:modelValue",e)}}}(0,n),l=function(e,n){var r=(0,t.toRefs)(e),a=r.value,l=r.modelValue;return{externalValue:(0,t.computed)((function(){return void 0===a?l.value:a.value}))}}(e),o=function(e,n,r){var a=(0,t.toRefs)(e),l=a.searchable,o=a.mode,u=r.value,i=(0,t.ref)(null),c=(0,t.ref)(null),s=(0,t.computed)((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===o.value&&-1===[null,void 0].indexOf(u.value)&&u.value.length?"1ch":"100%"}));return(0,t.watch)(i,(function(e){n.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=null},blurSearch:function(){l.value&&c.value.blur()},handleTagsSearchBackspace:function(e){null!==i.value&&e.stopPropagation(),""===i.value&&(i.value=null)}}}(e,n,{value:l.externalValue}),u=function(e,n,r){var a=(0,t.toRefs)(e),l=a.maxHeight,o=a.disabled,u=(0,t.ref)(!1),i=(0,t.computed)((function(){return"".concat(l.value,"px")}));return{isOpen:u,contentMaxHeight:i,open:function(){o.value||(u.value=!0,n.emit("open"))},close:function(){u.value=!1,n.emit("close")}}}(e,n),i=function(e,n,r){var a=(0,t.toRefs)(e),l=a.searchable,o=a.id;return{multiselect:(0,t.ref)(null),tabindex:(0,t.computed)((function(){return l.value?-1:0})),blurInput:function(){document.getElementById(o.value).querySelector(".multiselect-input").blur()}}}(e),c=d(e,n,{value:l.externalValue,search:o.search,blurSearch:o.blurSearch,clearSearch:o.clearSearch,update:r.update,blurInput:i.blurInput}),s=function(e,n,r){var a=(0,t.toRefs)(e).id,l=r.filteredOptions,o=r.handleOptionClick,u=r.search,i=(0,t.ref)(null),c=function(e){i.value=e},s=function(){i.value=l.value[0]||null},d=function(){i.value=null},p=function(){var e=document.getElementById(a.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return(0,t.watch)(u,(function(e){s()})),{pointer:i,isPointed:function(e){return!!i.value&&i.value.value==e.value},setPointer:c,setPointerFirst:s,clearPointer:d,selectPointer:function(){i.value&&(o(i.value),d())},forwardPointer:function(e){if(null===i.value)c(l.value[0]);else{var n=l.value.map((function(e){return e.value})).indexOf(i.value.value)+1;l.value.length<=n&&(n=0),c(l.value[n])}(0,t.nextTick)((function(){p()}))},backwardPointer:function(){if(null===i.value)c(l.value[l.value.length-1]);else{var e=l.value.map((function(e){return e.value})).indexOf(i.value.value)-1;e<0&&(e=l.value.length-1),c(l.value[e])}(0,t.nextTick)((function(){p()}))}}}(e,0,{filteredOptions:c.filteredOptions,handleOptionClick:c.handleOptionClick,search:o.search}),f=function(e,t,n){var r=n.value,a=n.update,l=n.close,o=n.clearPointer;return{handleBackspace:function(e){a(p(r.value).slice(0,-1))},handleEsc:function(e){l(),o(),e.target.blur()}}}(0,0,{value:l.externalValue,update:r.update,close:u.close,clearPointer:s.clearPointer});return a(a(a(a(a(a(a(a({},r),o),u),i),c),s),f),l)}},y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{focus:e.open,blur:e.close,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.selectPointer(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.valueObject?[e._t("singleLabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.valueObject[e.label])+"\n ")])],{value:e.valueObject})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multipleLabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.valueObject})]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.valueObject,(function(t,r,a){return n("span",{key:a},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),e.remove(t)}}})])],{option:t,remove:e.remove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleTagsSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"]))return null;t.stopPropagation()},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:e.placeholder&&!e.hasSelected&&!e.search,expression:"placeholder && !hasSelected && !search"}],staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")]),e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.loading,expression:"loading"}],staticClass:"multiselect-spinner"})])],2),e._v(" "),n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforeList"),e._v(" "),e._l(e.filteredOptions,(function(t,r,a){return n("a",{key:a,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t)},attrs:{href:""},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("noOptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noResults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterList")],2)])],1)};y._withStripped=!0;var m=function(e,t,n,r,a,l,o,u,i,c){"boolean"!=typeof o&&(i=u,u=o,o=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),r&&(d._scopeId=r),l?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},d._ssrRegister=s):t&&(s=o?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,u(e))}),s)if(d.functional){var p=d.render;d.render=function(e,t){return s.call(t),p(e,t)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,s):[s]}return n}({render:y,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0);e.default=m})); | ||
!function(e,t){if("function"==typeof define&&define.amd)define("VueFormMultiselect",["exports","composition-api"],t);else if("undefined"!=typeof exports)t(exports,require("composition-api"));else{var n={exports:{}};t(n.exports,e.VueCompositionAPI),e.VueFormMultiselect=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return String(e).toLowerCase().trim()}function o(e,t,n,r,a,l,u){try{var o=e[l](u),i=o.value}catch(e){return void n(e)}o.done?t(i):Promise.resolve(i).then(r,a)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var l=e.apply(t,n);function u(e){o(l,r,a,u,i,"next",e)}function i(e){o(l,r,a,u,i,"throw",e)}u(void 0)}))}}function c(e){return(c="function"==typeof Symbol&&"symbol"==n(Symbol.iterator)?function(e){return n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":n(e)})(e)}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,n,r){var a,l=(0,t.toRefs)(e),o=l.options,d=l.mode,f=l.trackBy,p=l.limit,v=l.hideSelectedTag,y=l.createTag,m=l.label,h=l.appendNewTag,b=l.multipleLabel,g=l.object,k=l.loading,O=l.delay,w=l.resolveOnLoad,_=l.minChars,x=l.filterResults,S=l.clearOnSearch,P=l.clearOnSelect,C=r.internalValue,q=r.externalValue,T=r.search,V=r.blurSearch,j=r.clearSearch,E=r.update,R=r.blurInput,B=(0,t.ref)([]),D=(0,t.ref)([]),A=(0,t.ref)(!1),N=(0,t.computed)((function(){var e,t=D.value||[];return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(t=Object.keys(t).map((function(e){var n,r=t[e];return s(n={value:e},f.value,r),s(n,m.value,r),n}))),t=t.map((function(e,t){var n;return"object"===c(e)?e:(s(n={value:t},f.value,e),s(n,m.value,e),n)})),B.value.length&&(t=t.concat(B.value)),t})),I=(0,t.computed)((function(){var e=N.value;return $.value.length&&(e=$.value.concat(e)),T.value&&x.value&&(e=e.filter((function(e){return-1!==u(e[f.value]).indexOf(u(T.value))}))),v.value&&(e=e.filter((function(e){return!ee(e)}))),p.value>0&&(e=e.slice(0,p.value)),e})),L=(0,t.computed)((function(){switch(d.value){case"single":return!W.value;case"multiple":case"tags":return!W.value&&C.value.length>0}})),H=(0,t.computed)((function(){return void 0!==b&&void 0!==b.value?b.value(C.value):C.value&&C.value.length>1?"".concat(C.value.length," options selected"):"1 option selected"})),U=(0,t.computed)((function(){return!N.value.length})),F=(0,t.computed)((function(){return N.value.length>0&&0==I.value.length})),$=(0,t.computed)((function(){var e;return!1!==y.value&&T.value?-1!==Z(T.value)?[]:[(e={},s(e,m.value,T.value),s(e,f.value,T.value),s(e,"value",T.value),e)]:[]})),M=(0,t.computed)((function(){switch(d.value){case"single":return null;case"multiple":case"tags":return[]}})),W=(0,t.computed)((function(){return-1!==[null,void 0,!1].indexOf(C.value)})),X=(0,t.computed)((function(){return k.value||A.value})),z=function(e){switch("object"!==c(e)&&(e=Y(e)),d.value){case"single":E(e);break;case"multiple":case"tags":E((C.value||[]).concat(e))}n.emit("select",J(e))},G=function(e){switch("object"!==c(e)&&(e=Y(e)),d.value){case"single":K();break;case"tags":case"multiple":E(C.value.filter((function(t){return t.value!=e.value})))}n.emit("deselect",J(e))},J=function(e){return g.value?e:e.value},K=function(e){E(M.value)},Q=function(e){switch(d.value){case"single":return!W.value&&C.value.value==e.value;case"tags":case"multiple":return!W.value&&-1!==C.value.map((function(e){return e.value})).indexOf(e.value)}},Y=function(e){return N.value[N.value.map((function(e){return e.value})).indexOf(e)]},Z=function(e){return N.value.map((function(e){return u(e[f.value])})).indexOf(u(e))},ee=function(e){return"tags"===d.value&&v.value&&Q(e)},te=function(){var e=i(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return A.value=!0,e.next=3,o.value(T.value);case 3:D.value=e.sent,A.value=!1;case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();if("single"!==d.value&&-1===[null,void 0,!1].indexOf(q.value)&&!Array.isArray(q.value))throw new Error('v-model must be an array when using "'.concat(d.value,'" mode'));return o&&"function"==typeof o.value?w.value&&te():D.value=o&&o.value?o.value:[],-1===[null,!1,void 0].indexOf(q.value)&&(C.value=(a=q.value,g.value?a:Array.isArray(a)?a.map((function(e){return Y(e)})):Y(a))),O.value>-1&&(0,t.watch)(T,(function(e){e.length<_.value||(S.value&&(D.value=[]),setTimeout(i(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e==T.value){t.next=2;break}return t.abrupt("return");case 2:return A.value=!0,t.next=5,o.value(T.value);case 5:n=t.sent,e==T.value&&(D.value=n),A.value=!1;case 8:case"end":return t.stop()}}),t)}))),O.value))}),{flush:"sync"}),{filteredOptions:I,hasSelected:L,multipleLabelText:H,extendedOptions:N,noOptions:U,noResults:F,busy:X,select:z,deselect:G,remove:function(e){G(e)},clear:K,isSelected:Q,getOption:Y,handleOptionClick:function(e){switch(d.value){case"single":if(Q(e))return void G(e);K(),z(e),V(),R();break;case"multiple":if(Q(e))return void G(e);z(e),P.value&&j();break;case"tags":if(Q(e))return void G(e);void 0===Y(e.value)&&y.value&&(n.emit("tag",e.value),h.value&&function(e){B.value.push(e)}(e),j()),P.value&&j(),z(e)}}}}function f(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,t){if(e){if("string"==typeof e)return p(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}(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,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var v={name:"Multiselect",emits:["open","close","select","deselect","input","search-change","tag","update:modelValue"],props:{value:{required:!1},modelValue:{required:!1},options:{type:[Array,Object,Function],required:!1},id:{type:[String,Number],required:!1,default:"multiselect"},name:{type:[String,Number],required:!1,default:"multiselect"},disabled:{type:Boolean,required:!1,default:!1},label:{type:String,required:!1,default:"label"},trackBy:{type:String,required:!1,default:"label"},placeholder:{type:String,required:!1,default:null},mode:{type:String,required:!1,default:"single"},searchable:{type:Boolean,required:!1,default:!1},limit:{type:Number,required:!1,default:-1},maxHeight:{type:Number,required:!1,default:160},hideSelectedTag:{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}},setup:function(e,n){var r,l,u,o,i,c=function(e,n){var r=(0,t.toRefs)(e),a=r.value,l=r.modelValue,u=r.mode;return{internalValue:(0,t.ref)("single"!==u.value?[]:null),externalValue:(0,t.computed)((function(){return void 0!==n.expose?l.value:a.value}))}}(e,n),s=function(e,n,r){var a=(0,t.toRefs)(e).object,l=r.internalValue,u=function(e){return a.value||-1!==[null,!1,void 0].indexOf(e)?e:Array.isArray(e)?e.map((function(e){return e.value})):e.value};return{update:function(e){l.value=e,n.emit("input",u(e)),n.emit("update:modelValue",u(e))}}}(e,n,{internalValue:c.internalValue}),p=function(e,n,r){var a=(0,t.toRefs)(e),l=a.searchable,u=a.mode,o=r.internalValue,i=(0,t.ref)(null),c=(0,t.ref)(null),s=(0,t.computed)((function(){return i.value?"".concat(i.value.length,"ch"):"tags"===u.value&&-1===[null,void 0].indexOf(o.value)&&o.value.length?"1ch":"100%"}));return(0,t.watch)(i,(function(e){n.emit("search-change",e)})),{search:i,input:c,tagsSearchWidth:s,clearSearch:function(){i.value=""},blurSearch:function(){l.value&&c.value.blur()},handleSearchBackspace:function(e){""!==i.value&&e.stopPropagation()}}}(e,n,{internalValue:c.internalValue}),v=function(e,n,r){var a=(0,t.toRefs)(e),l=a.maxHeight,u=a.disabled,o=(0,t.ref)(!1),i=(0,t.computed)((function(){return"".concat(l.value,"px")}));return{isOpen:o,contentMaxHeight:i,open:function(){u.value||(o.value=!0,n.emit("open"))},close:function(){o.value=!1,n.emit("close")}}}(e,n),y=function(e,n,r){var a=(0,t.toRefs)(e),l=a.searchable,u=a.id;return{multiselect:(0,t.ref)(null),tabindex:(0,t.computed)((function(){return l.value?-1:0})),blurInput:function(){document.getElementById(u.value).querySelector(".multiselect-input").blur()}}}(e),m=d(e,n,{externalValue:c.externalValue,internalValue:c.internalValue,search:p.search,blurSearch:p.blurSearch,clearSearch:p.clearSearch,update:s.update,blurInput:y.blurInput}),h=function(e,n,r){var a=(0,t.toRefs)(e).id,l=r.filteredOptions,u=r.handleOptionClick,o=r.search,i=(0,t.ref)(null),c=function(e){i.value=e},s=function(){i.value=l.value[0]||null},d=function(){i.value=null},f=function(){var e=document.getElementById(a.value).querySelector(".is-pointed");if(e){var t=e.parentElement;e.offsetTop+e.offsetHeight>t.clientHeight+t.scrollTop&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight),e.offsetTop<t.scrollTop&&(t.scrollTop=e.offsetTop)}};return(0,t.watch)(o,(function(e){s()})),{pointer:i,isPointed:function(e){return!!i.value&&i.value.value==e.value},setPointer:c,setPointerFirst:s,clearPointer:d,selectPointer:function(){i.value&&(u(i.value),d())},forwardPointer:function(e){if(null===i.value)c(l.value[0]);else{var n=l.value.map((function(e){return e.value})).indexOf(i.value.value)+1;l.value.length<=n&&(n=0),c(l.value[n])}(0,t.nextTick)((function(){f()}))},backwardPointer:function(){if(null===i.value)c(l.value[l.value.length-1]);else{var e=l.value.map((function(e){return e.value})).indexOf(i.value.value)-1;e<0&&(e=l.value.length-1),c(l.value[e])}(0,t.nextTick)((function(){f()}))}}}(e,0,{filteredOptions:m.filteredOptions,handleOptionClick:m.handleOptionClick,search:p.search}),b=(r={internalValue:c.internalValue,update:s.update,close:v.close,clearPointer:h.clearPointer},l=r.internalValue,u=r.update,o=r.close,i=r.clearPointer,{handleBackspace:function(e){u(f(l.value).slice(0,-1))},handleEsc:function(e){o(),i(),e.target.blur()}});return a(a(a(a(a(a(a(a({},c),s),p),v),y),m),h),b)}},y=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"multiselect",staticClass:"multiselect",class:["is-"+e.mode,{"is-open":e.isOpen,"is-searchable":e.searchable,"is-disabled":e.disabled,"no-caret":!e.caret}],attrs:{id:e.id},on:{keydown:function(t){if(!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter"))return null;t.preventDefault()}}},[n("div",{staticClass:"multiselect-input",attrs:{tabindex:e.tabindex},on:{focus:e.open,blur:e.close,keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:e.handleEsc(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.selectPointer(t)}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:(t.preventDefault(),e.handleBackspace(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.preventDefault(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.preventDefault(),e.forwardPointer(t))}]}},["single"==e.mode&&e.hasSelected&&!e.search&&e.internalValue?[e._t("singleLabel",[n("div",{staticClass:"multiselect-single-label"},[e._v("\n "+e._s(e.internalValue[e.label])+"\n ")])],{value:e.internalValue})]:e._e(),e._v(" "),"multiple"==e.mode&&e.hasSelected&&!e.search?[e._t("multipleLabel",[n("div",{staticClass:"multiselect-multiple-label"},[e._v("\n "+e._s(e.multipleLabelText)+"\n ")])],{values:e.internalValue})]:e._e(),e._v(" "),"tags"!==e.mode&&e.searchable&&!e.disabled?[n("div",{staticClass:"multiselect-search"},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})])]:e._e(),e._v(" "),"tags"==e.mode?[n("div",{staticClass:"multiselect-tags"},[e._l(e.internalValue,(function(t,r,a){return n("span",{key:a},[e._t("tag",[n("div",{staticClass:"multiselect-tag"},[e._v("\n "+e._s(t[e.label])+"\n "),e.disabled?e._e():n("i",{on:{click:function(e){e.preventDefault()},mousedown:function(n){return n.preventDefault(),e.remove(t)}}})])],{option:t,remove:e.remove,disabled:e.disabled})],2)})),e._v(" "),e.searchable&&!e.disabled?n("div",{staticClass:"multiselect-search",style:{width:e.tagsSearchWidth}},[n("input",{directives:[{name:"model",rawName:"v-model",value:e.search,expression:"search"}],ref:"input",style:{width:e.tagsSearchWidth},domProps:{value:e.search},on:{focus:function(t){return t.stopPropagation(),e.open(t)},blur:function(t){return t.stopPropagation(),e.close(t)},keyup:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),e.handleEsc(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:(t.stopPropagation(),e.selectPointer(t))}],keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.handleSearchBackspace(t)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"up",38,t.key,["Up","ArrowUp"])?null:(t.stopPropagation(),e.backwardPointer(t))},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"down",40,t.key,["Down","ArrowDown"])?null:(t.stopPropagation(),e.forwardPointer(t))}],input:function(t){t.target.composing||(e.search=t.target.value)}}})]):e._e()],2)]:e._e(),e._v(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:e.placeholder&&!e.hasSelected&&!e.search,expression:"placeholder && !hasSelected && !search"}],staticClass:"multiselect-placeholder"},[e._v("\n "+e._s(e.placeholder)+"\n ")]),e._v(" "),n("transition",{attrs:{name:"multiselect-loading"}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.busy,expression:"busy"}],staticClass:"multiselect-spinner"})])],2),e._v(" "),n("transition",{attrs:{name:"multiselect"},on:{"after-leave":e.clearSearch}},[n("div",{directives:[{name:"show",rawName:"v-show",value:e.isOpen,expression:"isOpen"}],staticClass:"multiselect-options",style:{maxHeight:e.contentMaxHeight}},[e._t("beforeList"),e._v(" "),e._l(e.filteredOptions,(function(t,r,a){return n("a",{key:a,staticClass:"multiselect-option",class:{"is-pointed":e.isPointed(t),"is-selected":e.isSelected(t)},attrs:{href:""},on:{mousedown:function(e){e.preventDefault()},mouseenter:function(n){return e.setPointer(t)},click:function(n){return n.stopPropagation(),n.preventDefault(),e.handleOptionClick(t)}}},[e._t("option",[n("span",[e._v(e._s(t[e.label]))])],{option:t,search:e.search})],2)})),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noOptions,expression:"noOptions"}]},[e._t("noOptions",[n("div",{staticClass:"multiselect-no-options"},[e._v(e._s(e.noOptionsText))])])],2),e._v(" "),n("span",{directives:[{name:"show",rawName:"v-show",value:e.noResults,expression:"noResults"}]},[e._t("noResults",[n("div",{staticClass:"multiselect-no-results"},[e._v(e._s(e.noResultsText))])])],2),e._v(" "),e._t("afterList")],2)])],1)};y._withStripped=!0;var m=function(e,t,n,r,a,l,u,o,i,c){"boolean"!=typeof u&&(i=o,o=u,u=!1);var s,d="function"==typeof n?n.options:n;if(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),r&&(d._scopeId=r),l?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,i(e)),e&&e._registeredComponents&&e._registeredComponents.add(l)},d._ssrRegister=s):t&&(s=u?function(e){t.call(this,c(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),s)if(d.functional){var f=d.render;d.render=function(e,t){return s.call(t),f(e,t)}}else{var p=d.beforeCreate;d.beforeCreate=p?[].concat(p,s):[s]}return n}({render:y,staticRenderFns:[]},void 0,v,void 0,!1,void 0,!1,void 0,void 0,void 0);e.default=m})); |
{ | ||
"name": "@vueform/multiselect", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"private": false, | ||
@@ -39,2 +39,3 @@ "description": "Vue 3 multiselect component with single select, multiselect and tagging options.", | ||
"babel-plugin-rename-umd-globals": "^1.0.0", | ||
"flush-promises": "^1.0.2", | ||
"jest": "^26.6.1", | ||
@@ -41,0 +42,0 @@ "jest-environment-jsdom-sixteen": "^1.0.3", |
@@ -13,3 +13,3 @@ <div align="center"> | ||
<a href="https://discord.com/channels/787237947635793940" target="_blank"> | ||
<a href="https://discord.gg/vYAyYmqJ" target="_blank"> | ||
<img alt="Discord" src="https://img.shields.io/discord/787237947635793940"> | ||
@@ -20,6 +20,11 @@ </a> | ||
<h1>Vue 3 multiselect by @vueform</h1> | ||
<h1>Vue 3 multiselect by <a href="https://vueform.com?r=github" target="_blank">Vueform</a></h1> | ||
<a href="https://vueform.com" target="_blank"> | ||
<img align="center" src="https://github.com/vueform/multiselect/raw/main//assets/logo.svg" width="120"> | ||
</a> | ||
<br> | ||
<br> | ||
<a href="https://www.npmjs.com/package/@vueform/multiselect" target="_blank"> | ||
<img align="center" src="https://github.com/vueform/multiselect/raw/main/assets/screenshot.jpg"> | ||
<img align="center" src="https://github.com/vueform/multiselect/raw/main//assets/screenshot.png"> | ||
</a> | ||
@@ -29,4 +34,8 @@ | ||
## Features | ||
## About Vueform | ||
[Vueform](https://vueform.com) is form library for Vue 2 & 3 with 30+ elements, file uploads, element nesting, 50+ validators, conditions, form steps and many more including reactive configuration, API access and ESM modules. Check out our [live demos](https://vueform.com#demo) or see [all the features](https://vueform.com#features) and [sign up for beta](https://vueform.com#beta) to get early access. | ||
## Multiselect features | ||
* Vue 2 & 3 support | ||
@@ -40,2 +49,3 @@ * No dependencies | ||
* Tags | ||
* Async options | ||
* Search & filtering | ||
@@ -101,4 +111,8 @@ * Custom slots | ||
| caret | `boolean` | `true` | Whether should display a caret (small triangle on the right). | | ||
| clearOnSearch | `boolean` | `false` | Whether the option list should be cleared upon a new typed character when using async options. | | ||
| clearOnSelect | `boolean` | `true` | Whether the option list should be cleared upon selecting an option when using async options. | | ||
| createTag | `boolean` | `false` | Whether should allow creating new tag based on search query when using `tags` mode. | | ||
| delay | `number` | `-1` | The delay 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. The number refers to `milliseconds`. | | ||
| disabled | `boolean` | `false` | Whether the input should be disabled. | | ||
| filterResults | `boolean` | `true` | Whether option list should be filtered by search query. This may be set to `false` if you are handling filtering when returning async options. | | ||
| hideSelectedTag | `boolean` | `true` | Whether selected tags should be excluded from the list when using `tags` mode. | | ||
@@ -110,2 +124,3 @@ | id | `string` | `'multiselect'` | The `id` of the multiselect container DOM. | | ||
| maxHeight | `number` | `160` | The maximum height of options list. | | ||
| 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. | | ||
| mode | `string` | `single` | Possible values: `single\|multiple\|tags`. | | ||
@@ -117,4 +132,5 @@ | modelValue | `string\|number\|array` | `null` | The variable that should store the select value when using **Vue 3**. If `v-model` is used it does not need to be set. | | ||
| object | `boolean` | `false` | Whether the value should be stored as an object. If set to `false` while using an array of objects as `:options` the `value` property will be used as value. If set to `true` without using an array of objects as `:options` an object that contains `value` property along with `:trackBy`'s and `:label`'s value will be set as value. | | ||
| options | `array\|object` | `[]` | 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'}]`.<br>When an array of objects is provided it **must** have a `value` property as well as properties that equal to `:trackBy`'s and `:label`'s value (both configurable and default to `label`). | | ||
| 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'}]`<br>- a sync or async function with `query` input param that returns options as an **object** or as an **array of objects**.<br>When an array of objects is provided it **must** have a `value` property as well as properties that equal to `:trackBy`'s and `:label`'s value (both configurable and default to `label`). | | ||
| placeholder | `string` | `null` | The text that should be displayed before an options are selected. | | ||
| 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 initially while using async options. | | ||
| searchable | `boolean` | `false` | Whether the options should be searchable. | | ||
@@ -121,0 +137,0 @@ | 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`. | |
@@ -1,10 +0,41 @@ | ||
export default function useData (props, context) | ||
import { toRefs } from 'composition-api' | ||
export default function useData (props, context, dependencies) | ||
{ | ||
const { object } = toRefs(props) | ||
// ============ DEPENDENCIES ============ | ||
const internalValue = dependencies.internalValue | ||
// =============== METHODS ============== | ||
const update = (val) => { | ||
context.emit('input', val) | ||
context.emit('update:modelValue', val) | ||
// Setting object(s) as internal value | ||
internalValue.value = val | ||
// Setting object(s) or plain value as external | ||
// value based on `option` setting | ||
context.emit('input', makeExternal(val)) | ||
context.emit('update:modelValue', makeExternal(val)) | ||
} | ||
// no export | ||
const makeExternal = (val) => { | ||
// If external value should be object | ||
// no transformation is required | ||
if (object.value) { | ||
return val | ||
} | ||
// No need to transform if empty value | ||
if ([null, false, undefined].indexOf(val) !== -1) { | ||
return val | ||
} | ||
// If external should be plain transform | ||
// value object to plain values | ||
return !Array.isArray(val) ? val.value : val.map(v => v.value) | ||
} | ||
return { | ||
@@ -11,0 +42,0 @@ update, |
@@ -6,3 +6,3 @@ | ||
const value = dependencies.value | ||
const internalValue = dependencies.internalValue | ||
const update = dependencies.update | ||
@@ -15,3 +15,3 @@ const close = dependencies.close | ||
const handleBackspace = (e) => { | ||
update([...value.value].slice(0,-1)) | ||
update([...internalValue.value].slice(0,-1)) | ||
} | ||
@@ -18,0 +18,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { ref, toRefs, computed } from 'composition-api' | ||
import { ref, toRefs, computed, watch } from 'composition-api' | ||
import normalize from './../utils/normalize' | ||
@@ -7,7 +7,10 @@ import isObject from './../utils/isObject' | ||
{ | ||
const { options, mode, trackBy, limit, hideSelectedTag, createTag, label, appendNewTag, multipleLabel, object } = toRefs(props) | ||
const { options, mode, trackBy, limit, hideSelectedTag, createTag, label, | ||
appendNewTag, multipleLabel, object, loading, delay, resolveOnLoad, | ||
minChars, filterResults, clearOnSearch, clearOnSelect } = toRefs(props) | ||
// ============ DEPENDENCIES ============ | ||
const value = dependencies.value | ||
const internalValue = dependencies.internalValue | ||
const externalValue = dependencies.externalValue | ||
const search = dependencies.search | ||
@@ -24,2 +27,8 @@ const blurSearch = dependencies.blurSearch | ||
// no export | ||
const resolvedOptions = ref([]) | ||
// no export | ||
const resolving = ref(false) | ||
// ============== COMPUTED ============== | ||
@@ -29,3 +38,3 @@ | ||
const extendedOptions = computed(() => { | ||
let extendedOptions = options === undefined || options.value === undefined ? [] : options.value | ||
let extendedOptions = resolvedOptions.value || [] | ||
@@ -60,3 +69,3 @@ // Transforming an object to an array of objects | ||
if (search.value) { | ||
if (search.value && filterResults.value) { | ||
filteredOptions = filteredOptions.filter((option) => { | ||
@@ -78,12 +87,2 @@ return normalize(option[trackBy.value]).indexOf(normalize(search.value)) !== -1 | ||
const valueObject = computed(() => { | ||
if (isValueNull.value || value.value.length === 0 || object.value) { | ||
return value.value | ||
} | ||
return mode.value == 'single' | ||
? getOption(value.value) | ||
: value.value.map((val) => getOption(val)) | ||
}) | ||
const hasSelected = computed(() => { | ||
@@ -96,3 +95,3 @@ switch (mode.value) { | ||
case 'tags': | ||
return !isValueNull.value && value.value.length > 0 | ||
return !isValueNull.value && internalValue.value.length > 0 | ||
} | ||
@@ -103,4 +102,4 @@ }) | ||
return multipleLabel !== undefined && multipleLabel.value !== undefined | ||
? multipleLabel.value(value.value) | ||
: (value.value && value.value.length > 1 ? `${value.value.length} options selected` : `1 option selected`) | ||
? multipleLabel.value(internalValue.value) | ||
: (internalValue.value && internalValue.value.length > 1 ? `${internalValue.value.length} options selected` : `1 option selected`) | ||
}) | ||
@@ -143,5 +142,9 @@ | ||
const isValueNull = computed(() => { | ||
return [null, undefined, false].indexOf(value.value) !== -1 | ||
return [null, undefined, false].indexOf(internalValue.value) !== -1 | ||
}) | ||
const busy = computed(() => { | ||
return loading.value || resolving.value | ||
}) | ||
// =============== METHODS ============== | ||
@@ -156,3 +159,3 @@ | ||
case 'single': | ||
update(finalValue(option)) | ||
update(option) | ||
break | ||
@@ -162,3 +165,3 @@ | ||
case 'tags': | ||
update([...(value.value || [])].concat(finalValue(option))) | ||
update((internalValue.value || []).concat(option)) | ||
break | ||
@@ -182,3 +185,3 @@ } | ||
case 'multiple': | ||
update(value.value.filter((val) => (object.value && val.value != option.value) || (!object.value && val != option.value))) | ||
update(internalValue.value.filter((val) => val.value != option.value)) | ||
break | ||
@@ -206,7 +209,7 @@ } | ||
case 'single': | ||
return !isValueNull.value && valueObject.value.value == option.value | ||
return !isValueNull.value && internalValue.value.value == option.value | ||
case 'tags': | ||
case 'multiple': | ||
return !isValueNull.value && valueObject.value.map(o => o.value).indexOf(option.value) !== -1 | ||
return !isValueNull.value && internalValue.value.map(o => o.value).indexOf(option.value) !== -1 | ||
} | ||
@@ -236,3 +239,6 @@ } | ||
select(option) | ||
clearSearch() | ||
if (clearOnSelect.value) { | ||
clearSearch() | ||
} | ||
break | ||
@@ -256,2 +262,6 @@ | ||
if (clearOnSelect.value) { | ||
clearSearch() | ||
} | ||
select(option) | ||
@@ -281,2 +291,69 @@ break | ||
// no export | ||
const resolveOptions = async () => { | ||
resolving.value = true | ||
resolvedOptions.value = await options.value(search.value) | ||
resolving.value = false | ||
} | ||
// no export | ||
const makeInternal = (val) => { | ||
if (object.value) { | ||
return val | ||
} | ||
// If external should be plain transform | ||
// value object to plain values | ||
return !Array.isArray(val) ? getOption(val) : val.map(v => getOption(v)) | ||
} | ||
// ================ HOOKS =============== | ||
if (mode.value !== 'single' && [null, undefined, false].indexOf(externalValue.value) === -1 && !Array.isArray(externalValue.value)) { | ||
throw new Error(`v-model must be an array when using "${mode.value}" mode`) | ||
} | ||
if (options && typeof options.value == 'function') { | ||
if (resolveOnLoad.value) { | ||
resolveOptions() | ||
} | ||
} | ||
else { | ||
resolvedOptions.value = options && options.value ? options.value : [] | ||
} | ||
if ([null, false, undefined].indexOf(externalValue.value) === -1) { | ||
internalValue.value = makeInternal(externalValue.value) | ||
} | ||
// ============== WATCHERS ============== | ||
if (delay.value > -1) { | ||
watch(search, (query) => { | ||
if (query.length < minChars.value) { | ||
return | ||
} | ||
if (clearOnSearch.value) { | ||
resolvedOptions.value = [] | ||
} | ||
setTimeout(async () => { | ||
if (query != search.value) { | ||
return | ||
} | ||
resolving.value = true | ||
let newOptions = await options.value(search.value) | ||
if (query == search.value) { | ||
resolvedOptions.value = newOptions | ||
} | ||
resolving.value = false | ||
}, delay.value) | ||
}, { flush: 'sync' }) | ||
} | ||
return { | ||
@@ -289,3 +366,3 @@ filteredOptions, | ||
noResults, | ||
valueObject, | ||
busy, | ||
select, | ||
@@ -292,0 +369,0 @@ deselect, |
@@ -9,3 +9,3 @@ import { ref, toRefs, computed, watch } from 'composition-api' | ||
const value = dependencies.value | ||
const internalValue = dependencies.internalValue | ||
@@ -25,3 +25,3 @@ // ================ DATA ================ | ||
if (mode.value !== 'tags' || [null, undefined].indexOf(value.value) !== -1 || !value.value.length) { | ||
if (mode.value !== 'tags' || [null, undefined].indexOf(internalValue.value) !== -1 || !internalValue.value.length) { | ||
return '100%' | ||
@@ -37,3 +37,3 @@ } | ||
const clearSearch = () => { | ||
search.value = null | ||
search.value = '' | ||
} | ||
@@ -49,10 +49,6 @@ | ||
const handleTagsSearchBackspace = (e) => { | ||
if (search.value !== null) { | ||
const handleSearchBackspace = (e) => { | ||
if (search.value !== '') { | ||
e.stopPropagation() | ||
} | ||
if (search.value === '') { | ||
search.value = null | ||
} | ||
} | ||
@@ -72,4 +68,4 @@ | ||
blurSearch, | ||
handleTagsSearchBackspace, | ||
handleSearchBackspace, | ||
} | ||
} |
@@ -1,7 +0,11 @@ | ||
import { computed, toRefs } from 'composition-api' | ||
import { computed, toRefs, ref } from 'composition-api' | ||
export default function useValue (props, context) | ||
{ | ||
const { value, modelValue } = toRefs(props) | ||
const { value, modelValue, mode } = toRefs(props) | ||
// ================ DATA ================ | ||
const internalValue = ref(mode.value !== 'single' ? [] : null) | ||
// ============== COMPUTED ============== | ||
@@ -11,8 +15,9 @@ | ||
const externalValue = computed(() => { | ||
return value === undefined ? modelValue.value : value.value | ||
return context.expose !== undefined ? modelValue.value : value.value | ||
}) | ||
return { | ||
internalValue, | ||
externalValue, | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
126823
21
406
30
822