@volverjs/ui-vue 0.0.10-beta.40 → 0.0.10-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +12 -3
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +183 -125
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +6 -0
- package/dist/components/VvCombobox/index.d.ts +54 -22
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +12 -3
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.es.js +79 -46
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +3 -0
- package/dist/components/VvSelect/index.d.ts +14 -0
- package/dist/components/index.es.js +183 -122
- package/dist/components/index.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/stories/Combobox/Combobox.stories.d.ts +1 -0
- package/dist/stories/Combobox/ComboboxMultiple.stories.d.ts +1 -0
- package/dist/stories/Select/Select.stories.d.ts +1 -0
- package/package.json +18 -18
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvCombobox/VvCombobox.vue +105 -97
- package/src/components/VvCombobox/index.ts +19 -2
- package/src/components/VvSelect/VvSelect.vue +66 -46
- package/src/components/VvSelect/index.ts +8 -1
- package/src/composables/useOptions.ts +12 -11
- package/src/stories/Combobox/Combobox.settings.ts +18 -3
- package/src/stories/Combobox/Combobox.stories.ts +8 -0
- package/src/stories/Combobox/Combobox.test.ts +6 -4
- package/src/stories/Combobox/ComboboxMultiple.stories.ts +9 -0
- package/src/stories/Combobox/ComboboxOptions.stories.ts +9 -13
- package/src/stories/Select/Select.stories.ts +8 -0
- package/src/stories/Select/Select.test.ts +5 -3
|
@@ -1006,21 +1006,30 @@ function useOptions(props) {
|
|
|
1006
1006
|
if (typeof option === "string") {
|
|
1007
1007
|
return option;
|
|
1008
1008
|
}
|
|
1009
|
+
if (typeof labelKey.value === "function") {
|
|
1010
|
+
return labelKey.value(option);
|
|
1011
|
+
}
|
|
1009
1012
|
return String(
|
|
1010
|
-
|
|
1013
|
+
labelKey.value ? get(option, labelKey.value) : option
|
|
1011
1014
|
);
|
|
1012
1015
|
};
|
|
1013
1016
|
const getOptionValue = (option) => {
|
|
1014
1017
|
if (typeof option === "string") {
|
|
1015
1018
|
return option;
|
|
1016
1019
|
}
|
|
1017
|
-
|
|
1020
|
+
if (typeof valueKey.value === "function") {
|
|
1021
|
+
return valueKey.value(option);
|
|
1022
|
+
}
|
|
1023
|
+
return valueKey.value ? get(option, valueKey.value) : option;
|
|
1018
1024
|
};
|
|
1019
1025
|
const isOptionDisabled = (option) => {
|
|
1020
1026
|
if (typeof option === "string") {
|
|
1021
1027
|
return false;
|
|
1022
1028
|
}
|
|
1023
|
-
|
|
1029
|
+
if (typeof disabledKey.value === "function") {
|
|
1030
|
+
return disabledKey.value(option);
|
|
1031
|
+
}
|
|
1032
|
+
return disabledKey.value ? get(option, disabledKey.value) : false;
|
|
1024
1033
|
};
|
|
1025
1034
|
const getOptionGrouped = (option) => {
|
|
1026
1035
|
if (typeof option == "string") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("uid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","uid","@vueuse/core","ts-dot-prop"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=t(e.vue,e.uid,e.core,e.tsDotProp)}(this,(function(e,t,l,o){"use strict";var a=(e=>(e.local="local",e.session="session",e))(a||{}),n=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(n||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{});const d=Symbol.for("volver"),s=Symbol.for("checkGroup");function v(e,t,l){return l?f(e,l)===f(t,l):c(e,t)}function c(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const l=Array.isArray(e),o=Array.isArray(t);let a,n,i;if(l&&o){if(n=e.length,n!==t.length)return!1;for(a=n;0!=a--;)if(!c(e[a],t[a]))return!1;return!0}if(l!==o)return!1;const r=e instanceof Date,u=t instanceof Date;if(r!==u)return!1;if(r&&u)return e.getTime()===t.getTime();const d=e instanceof RegExp,s=t instanceof RegExp;if(d!==s)return!1;if(d&&s)return e.toString()===t.toString();const v=Object.keys(e);if(n=v.length,n!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,v[a]))return!1;for(a=n;0!=a--;)if(i=v[a],!c(e[i],t[i]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(t)}function f(e,t){if(e&&Object.keys(e).length&&t){if(t.includes(".")){const l=t.split(".");let o=e;for(let t=0,a=l.length;t<a;++t){if(null==e)return null;o=o[l[t]]}return o}return e[t]}return null}function p(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function m(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>p(o.value.invalidLabel))),n=e.computed((()=>p(o.value.validLabel))),i=e.computed((()=>o.value.loadingLabel)),r=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(l.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(o.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),c=e.computed((()=>d.value||s.value||u.value||v.value)),f=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:a,validLabel:n,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:m}}const b={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},h={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},y={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},g={disabled:{type:Boolean,default:!1}},S=(Boolean,Boolean,Boolean,{label:{type:[String,Number],default:void 0}}),k={readonly:{type:Boolean,default:!1}},L={modifiers:{type:[String,Array],default:void 0}},B={hintLabel:{type:String,default:""}},V={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};i.before;const x={tabindex:{type:[String,Number],default:0}},O={id:[String,Number]};n.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const $={...{...O,name:{type:String,required:!0}},...x,...b,...h,...B,...g,...k,...L,...S,...y,value:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[Object,Number,Boolean,String],default:void 0}},A={...b,...h,...V,...B,...g,...k,...L,...S,...y,modelValue:{type:[String,Array,Boolean,Number,Symbol],default:void 0},name:{type:String,required:!0},vertical:{type:Boolean,default:!1}};r.button,u.button,a.local;const C={...$,...L,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function N(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=function(t){const l=e.inject(t,void 0),o=e.computed((()=>void 0!==l));return{group:l,isInGroup:o,getGroupOrLocalRef:function(t,o,a){const n=null==l?void 0:l[t];if(n)return e.computed({get:()=>n.value,set(e){n.value=e}});const i=e.toRef(o,t);return e.computed({get:()=>i.value,set(e){a&&a(`update:${t}`,e)}})}}}(s),{id:i,switch:r,indeterminate:u}=e.toRefs(t),d=n("modelValue",t,l),v=n("valid",t),c=n("invalid",t),f=e.computed((()=>Boolean(t.readonly||(null==o?void 0:o.readonly.value)))),p=e.computed((()=>Boolean(t.disabled||(null==o?void 0:o.disabled.value))));return{id:i,propsSwitch:r,indeterminate:u,group:o,isInGroup:a,modelValue:d,valid:v,invalid:c,readonly:f,disabled:p}}function w(t,l,o){const a=e.inject(d),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];if(a.length){a[0]===n&&(l[o]=e[o])}}if("function"==typeof t[o]){(0,t[o])()===n&&(l[o]=e[o])}if("object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}function P(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const R=["for"],j=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],_=e.defineComponent({name:"VvCheckbox",props:C,emits:["click","update:modelValue","change","blur"],setup(l,{emit:o}){const a=l,n=o,i=e.useSlots(),r=w("VvCheckbox",C,a),{id:u,disabled:d,readonly:s,valid:c,invalid:f,propsSwitch:p,modelValue:b,indeterminate:h,isInGroup:y}=N(a,n),g=function(l){return e.computed((()=>String((null==l?void 0:l.value)||t.uid())))}(u),S=e.computed((()=>`${g.value}-hint`)),k=e.computed((()=>V.value?-1:a.tabindex)),L=e.ref(),B=e.computed((()=>void 0!==a.uncheckedValue&&!y.value)),V=e.computed((()=>d.value||s.value)),x=e.computed((()=>!0===f.value||!0!==c.value&&void 0)),O=e.computed((()=>B.value?b.value===a.value:Array.isArray(b.value)?function(e,t){if(null!=e&&t&&t.length)for(const l of t)if(v(e,l))return!0;return!1}(a.value,b.value):v(a.value,b.value))),$=e.computed((()=>!!h.value||!(O.value||!B.value||a.uncheckedValue===b.value))),A=e.computed((()=>{if(!B.value)return!["string","number","boolean"].includes(typeof a.value)||a.value})),_=e.computed({get:()=>O.value,set(e){if(B.value)b.value=e?a.value:a.uncheckedValue;else if(Array.isArray(b.value)||y.value){const t=b.value??[],l=new Set(Array.isArray(t)?t:[t]);e?l.add(a.value):l.delete(a.value),b.value=[...l]}else b.value=e?a.value:void 0;n("change",e)}}),{modifiers:z}=e.toRefs(a),E=P("vv-checkbox",z,e.computed((()=>({switch:p.value,valid:c.value,invalid:f.value,disabled:d.value,readonly:s.value,indeterminate:h.value}))));e.watchEffect((()=>{B.value&&Array.isArray(b.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>$.value),(e=>{L.value.indeterminate=!!e})),e.onMounted((()=>{$.value&&(L.value.indeterminate=!0)}));const{HintSlot:G,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:D,hintSlotScope:H}=m(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(E)),for:e.unref(g)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(g),ref_key:"input",ref:L,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(_)?_.value=t:null),type:"checkbox",class:"vv-checkbox__input",name:t.name,disabled:e.unref(V),value:e.unref(A),tabindex:e.unref(k),"aria-invalid":e.unref(x),"aria-describedby":e.unref(I)?e.unref(S):void 0,"aria-errormessage":e.unref(D)?e.unref(S):void 0},null,8,j),[[e.vModelCheckbox,e.unref(_)]]),e.renderSlot(t.$slots,"default",{value:e.unref(b)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(G),{id:e.unref(S),class:"vv-checkbox__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"3"}:void 0]),1032,["id"])],10,R))}}),z=A;const E=["textContent"],G={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:z,emits:["update:modelValue","change"],setup(t,{emit:a}){const n=t,i=a,r=e.useSlots(),u=w("VvCheckboxGroup",z,n),d=l.useVModel(n,"modelValue",i),{disabled:v,readonly:c,vertical:f,valid:p,invalid:b,modifiers:h}=e.toRefs(n);var y,g;y=s,g={modelValue:d,disabled:v,readonly:c,valid:p,invalid:b},e.provide(y,g);const{getOptionLabel:S,getOptionValue:k}=function(t){const{options:l,labelKey:a,valueKey:n,disabledKey:i}=e.toRefs(t);return{options:l,getOptionLabel:e=>"string"==typeof e?e:String("function"==typeof a.value?a.value(e):o.get(e,a.value)),getOptionValue:e=>"string"==typeof e?e:"function"==typeof n.value?n.value(e):o.get(e,n.value),isOptionDisabled:e=>"string"!=typeof e&&("function"==typeof i.value?i.value(e):o.get(e,i.value)),getOptionGrouped:e=>"string"==typeof e?[]:"object"==typeof e&&e&&"options"in e?e.options:[]}}(n),L=P("vv-checkbox-group",h,e.computed((()=>({disabled:v.value,readonly:c.value,horizontal:!f.value,valid:p.value,invalid:b.value}))));const{HintSlot:B,hintSlotScope:V}=m(u,r);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(L))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,E)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",G,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(_,e.mergeProps({key:l,ref_for:!0},function(e,t){return{id:`${n.name}_opt${t}`,name:n.name,label:S(e),value:k(e)}}(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(B),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("uid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","uid","@vueuse/core","ts-dot-prop"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=t(e.vue,e.uid,e.core,e.tsDotProp)}(this,(function(e,t,l,a){"use strict";var o=(e=>(e.local="local",e.session="session",e))(o||{}),n=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(n||{}),i=(e=>(e.before="before",e.after="after",e))(i||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{});const d=Symbol.for("volver"),s=Symbol.for("checkGroup");function v(e,t,l){return l?f(e,l)===f(t,l):c(e,t)}function c(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const l=Array.isArray(e),a=Array.isArray(t);let o,n,i;if(l&&a){if(n=e.length,n!==t.length)return!1;for(o=n;0!=o--;)if(!c(e[o],t[o]))return!1;return!0}if(l!==a)return!1;const r=e instanceof Date,u=t instanceof Date;if(r!==u)return!1;if(r&&u)return e.getTime()===t.getTime();const d=e instanceof RegExp,s=t instanceof RegExp;if(d!==s)return!1;if(d&&s)return e.toString()===t.toString();const v=Object.keys(e);if(n=v.length,n!==Object.keys(t).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(t,v[o]))return!1;for(o=n;0!=o--;)if(i=v[o],!c(e[i],t[i]))return!1;return!0}return Number.isNaN(e)&&Number.isNaN(t)}function f(e,t){if(e&&Object.keys(e).length&&t){if(t.includes(".")){const l=t.split(".");let a=e;for(let t=0,o=l.length;t<o;++t){if(null==e)return null;a=a[l[t]]}return a}return e[t]}return null}function p(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function m(t,l){const a=e.computed((()=>e.isRef(t)?t.value:t)),o=e.computed((()=>p(a.value.invalidLabel))),n=e.computed((()=>p(a.value.validLabel))),i=e.computed((()=>a.value.loadingLabel)),r=e.computed((()=>a.value.hintLabel)),u=e.computed((()=>Boolean(a.value.loading&&(l.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(a.value.invalid&&(l.invalid||o.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(a.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),c=e.computed((()=>d.value||s.value||u.value||v.value)),f=e.computed((()=>({modelValue:a.value.modelValue,valid:a.value.valid,invalid:a.value.invalid,loading:a.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:o,validLabel:n,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var t,l,a,o,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(o=(a=this.$slots).invalid)?void 0:o.call(a))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:m}}const b={valid:{type:Boolean,default:!1},validLabel:{type:[String,Array],default:void 0}},h={invalid:{type:Boolean,default:!1},invalidLabel:{type:[String,Array],default:void 0}},y={loading:{type:Boolean,default:!1},loadingLabel:{type:String,default:"Loading..."}},g={disabled:{type:Boolean,default:!1}},S=(Boolean,Boolean,Boolean,{label:{type:[String,Number],default:void 0}}),k={readonly:{type:Boolean,default:!1}},L={modifiers:{type:[String,Array],default:void 0}},B={hintLabel:{type:String,default:""}},V={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};i.before;const x={tabindex:{type:[String,Number],default:0}},O={id:[String,Number]};n.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const $={...{...O,name:{type:String,required:!0}},...x,...b,...h,...B,...g,...k,...L,...S,...y,value:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[Object,Number,Boolean,String],default:void 0}},A={...b,...h,...V,...B,...g,...k,...L,...S,...y,modelValue:{type:[String,Array,Boolean,Number,Symbol],default:void 0},name:{type:String,required:!0},vertical:{type:Boolean,default:!1}};r.button,u.button,o.local;const C={...$,...L,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function N(t,l){const{group:a,isInGroup:o,getGroupOrLocalRef:n}=function(t){const l=e.inject(t,void 0),a=e.computed((()=>void 0!==l));return{group:l,isInGroup:a,getGroupOrLocalRef:function(t,a,o){const n=null==l?void 0:l[t];if(n)return e.computed({get:()=>n.value,set(e){n.value=e}});const i=e.toRef(a,t);return e.computed({get:()=>i.value,set(e){o&&o(`update:${t}`,e)}})}}}(s),{id:i,switch:r,indeterminate:u}=e.toRefs(t),d=n("modelValue",t,l),v=n("valid",t),c=n("invalid",t),f=e.computed((()=>Boolean(t.readonly||(null==a?void 0:a.readonly.value)))),p=e.computed((()=>Boolean(t.disabled||(null==a?void 0:a.disabled.value))));return{id:i,propsSwitch:r,indeterminate:u,group:a,isInGroup:o,modelValue:d,valid:v,invalid:c,readonly:f,disabled:p}}function w(t,l,a){const o=e.inject(d),n=e.computed((()=>{var e;if(o&&(null==(e=o.defaults.value)?void 0:e[t]))return o.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return a;const e=n.value,t=l,o=a;return Object.keys(t).reduce(((l,a)=>{const n=o[a];if(l[a]=n,a in e){if(Array.isArray(t[a])){const o=t[a];if(o.length){o[0]===n&&(l[a]=e[a])}}if("function"==typeof t[a]){(0,t[a])()===n&&(l[a]=e[a])}if("object"==typeof t[a]){let o=t[a].default;"function"==typeof o&&(o=o()),"object"==typeof o?JSON.stringify(o)===JSON.stringify(n)&&(l[a]=e[a]):o===n&&(l[a]=e[a])}}return l}),{})}))}function P(t,l,a){return e.computed((()=>{const o={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(o[`${t}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((l=>{o[`${t}--${l}`]=e.unref(a.value[l])})),o}))}const R=["for"],j=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],_=e.defineComponent({name:"VvCheckbox",props:C,emits:["click","update:modelValue","change","blur"],setup(l,{emit:a}){const o=l,n=a,i=e.useSlots(),r=w("VvCheckbox",C,o),{id:u,disabled:d,readonly:s,valid:c,invalid:f,propsSwitch:p,modelValue:b,indeterminate:h,isInGroup:y}=N(o,n),g=function(l){return e.computed((()=>String((null==l?void 0:l.value)||t.uid())))}(u),S=e.computed((()=>`${g.value}-hint`)),k=e.computed((()=>V.value?-1:o.tabindex)),L=e.ref(),B=e.computed((()=>void 0!==o.uncheckedValue&&!y.value)),V=e.computed((()=>d.value||s.value)),x=e.computed((()=>!0===f.value||!0!==c.value&&void 0)),O=e.computed((()=>B.value?b.value===o.value:Array.isArray(b.value)?function(e,t){if(null!=e&&t&&t.length)for(const l of t)if(v(e,l))return!0;return!1}(o.value,b.value):v(o.value,b.value))),$=e.computed((()=>!!h.value||!(O.value||!B.value||o.uncheckedValue===b.value))),A=e.computed((()=>{if(!B.value)return!["string","number","boolean"].includes(typeof o.value)||o.value})),_=e.computed({get:()=>O.value,set(e){if(B.value)b.value=e?o.value:o.uncheckedValue;else if(Array.isArray(b.value)||y.value){const t=b.value??[],l=new Set(Array.isArray(t)?t:[t]);e?l.add(o.value):l.delete(o.value),b.value=[...l]}else b.value=e?o.value:void 0;n("change",e)}}),{modifiers:z}=e.toRefs(o),E=P("vv-checkbox",z,e.computed((()=>({switch:p.value,valid:c.value,invalid:f.value,disabled:d.value,readonly:s.value,indeterminate:h.value}))));e.watchEffect((()=>{B.value&&Array.isArray(b.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>$.value),(e=>{L.value.indeterminate=!!e})),e.onMounted((()=>{$.value&&(L.value.indeterminate=!0)}));const{HintSlot:G,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:D,hintSlotScope:H}=m(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(E)),for:e.unref(g)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(g),ref_key:"input",ref:L,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(_)?_.value=t:null),type:"checkbox",class:"vv-checkbox__input",name:t.name,disabled:e.unref(V),value:e.unref(A),tabindex:e.unref(k),"aria-invalid":e.unref(x),"aria-describedby":e.unref(I)?e.unref(S):void 0,"aria-errormessage":e.unref(D)?e.unref(S):void 0},null,8,j),[[e.vModelCheckbox,e.unref(_)]]),e.renderSlot(t.$slots,"default",{value:e.unref(b)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(G),{id:e.unref(S),class:"vv-checkbox__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"3"}:void 0]),1032,["id"])],10,R))}}),z=A;const E=["textContent"],G={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:z,emits:["update:modelValue","change"],setup(t,{emit:o}){const n=t,i=o,r=e.useSlots(),u=w("VvCheckboxGroup",z,n),d=l.useVModel(n,"modelValue",i),{disabled:v,readonly:c,vertical:f,valid:p,invalid:b,modifiers:h}=e.toRefs(n);var y,g;y=s,g={modelValue:d,disabled:v,readonly:c,valid:p,invalid:b},e.provide(y,g);const{getOptionLabel:S,getOptionValue:k}=function(t){const{options:l,labelKey:o,valueKey:n,disabledKey:i}=e.toRefs(t);return{options:l,getOptionLabel:e=>"string"==typeof e?e:"function"==typeof o.value?o.value(e):String(o.value?a.get(e,o.value):e),getOptionValue:e=>"string"==typeof e?e:"function"==typeof n.value?n.value(e):n.value?a.get(e,n.value):e,isOptionDisabled:e=>"string"!=typeof e&&("function"==typeof i.value?i.value(e):!!i.value&&a.get(e,i.value)),getOptionGrouped:e=>"string"==typeof e?[]:"object"==typeof e&&e&&"options"in e?e.options:[]}}(n),L=P("vv-checkbox-group",h,e.computed((()=>({disabled:v.value,readonly:c.value,horizontal:!f.value,valid:p.value,invalid:b.value}))));const{HintSlot:B,hintSlotScope:V}=m(u,r);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(L))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,E)):e.createCommentVNode("v-if",!0),e.createElementVNode("div",G,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(_,e.mergeProps({key:l,ref_for:!0},function(e,t){return{id:`${n.name}_opt${t}`,name:n.name,label:S(e),value:k(e)}}(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(B),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(V))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
@@ -1328,18 +1328,6 @@ function resolveFieldData(data, field) {
|
|
|
1328
1328
|
return null;
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
1331
|
-
function findIndexInList(value, list) {
|
|
1332
|
-
let index = -1;
|
|
1333
|
-
if (list) {
|
|
1334
|
-
for (let i = 0; i < list.length; i++) {
|
|
1335
|
-
if (equals(list[i], value)) {
|
|
1336
|
-
index = i;
|
|
1337
|
-
break;
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
return index;
|
|
1342
|
-
}
|
|
1343
1331
|
function contains(value, list) {
|
|
1344
1332
|
if (value != null && list && list.length) {
|
|
1345
1333
|
for (const val of list) {
|
|
@@ -1350,17 +1338,6 @@ function contains(value, list) {
|
|
|
1350
1338
|
}
|
|
1351
1339
|
return false;
|
|
1352
1340
|
}
|
|
1353
|
-
function isEmpty(value) {
|
|
1354
|
-
return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
|
|
1355
|
-
}
|
|
1356
|
-
function removeFromList(value, list) {
|
|
1357
|
-
const indexElToRemove = findIndexInList(value, list);
|
|
1358
|
-
if (indexElToRemove > -1) {
|
|
1359
|
-
return list.filter((el, elIndex) => elIndex !== indexElToRemove);
|
|
1360
|
-
} else {
|
|
1361
|
-
return list;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
1341
|
function isString(value) {
|
|
1365
1342
|
return typeof value === "string" || value instanceof String;
|
|
1366
1343
|
}
|
|
@@ -1525,6 +1502,13 @@ const VvSelectProps = {
|
|
|
1525
1502
|
type: [String, Number, Boolean, Object, Array],
|
|
1526
1503
|
default: void 0
|
|
1527
1504
|
},
|
|
1505
|
+
/**
|
|
1506
|
+
* Select first option automatically
|
|
1507
|
+
*/
|
|
1508
|
+
autoselectFirst: {
|
|
1509
|
+
type: Boolean,
|
|
1510
|
+
default: false
|
|
1511
|
+
},
|
|
1528
1512
|
/**
|
|
1529
1513
|
* Select placeholder
|
|
1530
1514
|
*/
|
|
@@ -1643,21 +1627,30 @@ function useOptions(props) {
|
|
|
1643
1627
|
if (typeof option === "string") {
|
|
1644
1628
|
return option;
|
|
1645
1629
|
}
|
|
1630
|
+
if (typeof labelKey.value === "function") {
|
|
1631
|
+
return labelKey.value(option);
|
|
1632
|
+
}
|
|
1646
1633
|
return String(
|
|
1647
|
-
|
|
1634
|
+
labelKey.value ? get(option, labelKey.value) : option
|
|
1648
1635
|
);
|
|
1649
1636
|
};
|
|
1650
1637
|
const getOptionValue = (option) => {
|
|
1651
1638
|
if (typeof option === "string") {
|
|
1652
1639
|
return option;
|
|
1653
1640
|
}
|
|
1654
|
-
|
|
1641
|
+
if (typeof valueKey.value === "function") {
|
|
1642
|
+
return valueKey.value(option);
|
|
1643
|
+
}
|
|
1644
|
+
return valueKey.value ? get(option, valueKey.value) : option;
|
|
1655
1645
|
};
|
|
1656
1646
|
const isOptionDisabled = (option) => {
|
|
1657
1647
|
if (typeof option === "string") {
|
|
1658
1648
|
return false;
|
|
1659
1649
|
}
|
|
1660
|
-
|
|
1650
|
+
if (typeof disabledKey.value === "function") {
|
|
1651
|
+
return disabledKey.value(option);
|
|
1652
|
+
}
|
|
1653
|
+
return disabledKey.value ? get(option, disabledKey.value) : false;
|
|
1661
1654
|
};
|
|
1662
1655
|
const getOptionGrouped = (option) => {
|
|
1663
1656
|
if (typeof option == "string") {
|
|
@@ -1709,13 +1702,21 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
1709
1702
|
VvSelectProps2,
|
|
1710
1703
|
props
|
|
1711
1704
|
);
|
|
1712
|
-
const
|
|
1705
|
+
const selectEl = ref();
|
|
1713
1706
|
const {
|
|
1714
1707
|
HintSlot,
|
|
1715
1708
|
hasHintLabelOrSlot,
|
|
1716
1709
|
hasInvalidLabelOrSlot,
|
|
1717
1710
|
hintSlotScope
|
|
1718
1711
|
} = HintSlotFactory(propsDefaults, slots);
|
|
1712
|
+
const { focused } = useComponentFocus(selectEl, emit);
|
|
1713
|
+
function isGroup(option) {
|
|
1714
|
+
var _a;
|
|
1715
|
+
if (typeof option === "string") {
|
|
1716
|
+
return false;
|
|
1717
|
+
}
|
|
1718
|
+
return (_a = option.options) == null ? void 0 : _a.length;
|
|
1719
|
+
}
|
|
1719
1720
|
const {
|
|
1720
1721
|
id,
|
|
1721
1722
|
modifiers,
|
|
@@ -1731,19 +1732,38 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
1731
1732
|
} = toRefs(props);
|
|
1732
1733
|
const hasId = useUniqueId(id);
|
|
1733
1734
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
1734
|
-
const
|
|
1735
|
-
const
|
|
1735
|
+
const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
|
|
1736
|
+
const hasTabindex = computed(() => {
|
|
1737
|
+
return isDisabledOrReadonly.value ? -1 : props.tabindex;
|
|
1738
|
+
});
|
|
1739
|
+
const localModelValue = computed({
|
|
1740
|
+
get: () => {
|
|
1741
|
+
return props.modelValue;
|
|
1742
|
+
},
|
|
1743
|
+
set: (newValue) => {
|
|
1744
|
+
if (Array.isArray(newValue)) {
|
|
1745
|
+
newValue = newValue.filter((item) => item !== void 0);
|
|
1746
|
+
if (newValue.length === 0 && !props.unselectable) {
|
|
1747
|
+
selectEl.value.value = props.modelValue;
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
emit("update:modelValue", newValue);
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
const isDirty = computed(() => {
|
|
1755
|
+
if (Array.isArray(localModelValue.value)) {
|
|
1756
|
+
return localModelValue.value.length > 0;
|
|
1757
|
+
}
|
|
1758
|
+
return localModelValue.value !== void 0 && localModelValue.value !== null;
|
|
1759
|
+
});
|
|
1760
|
+
const isVisible = useElementVisibility(selectEl);
|
|
1736
1761
|
watch(isVisible, (newValue) => {
|
|
1737
1762
|
if (newValue && props.autofocus) {
|
|
1738
1763
|
focused.value = true;
|
|
1739
1764
|
}
|
|
1740
1765
|
});
|
|
1741
1766
|
const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
|
|
1742
|
-
const isDirty = computed(() => !isEmpty(props.modelValue));
|
|
1743
|
-
const isDisabled = computed(() => props.disabled || props.readonly);
|
|
1744
|
-
const hasTabindex = computed(() => {
|
|
1745
|
-
return isDisabled.value ? -1 : props.tabindex;
|
|
1746
|
-
});
|
|
1747
1767
|
const isInvalid = computed(() => {
|
|
1748
1768
|
if (props.invalid === true) {
|
|
1749
1769
|
return true;
|
|
@@ -1770,11 +1790,27 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
1770
1790
|
"multiple": multiple.value
|
|
1771
1791
|
}))
|
|
1772
1792
|
);
|
|
1793
|
+
const {
|
|
1794
|
+
getOptionLabel,
|
|
1795
|
+
getOptionValue,
|
|
1796
|
+
isOptionDisabled,
|
|
1797
|
+
getOptionGrouped
|
|
1798
|
+
} = useOptions(props);
|
|
1799
|
+
watch(
|
|
1800
|
+
() => props.options,
|
|
1801
|
+
(newValue) => {
|
|
1802
|
+
if ((newValue == null ? void 0 : newValue.length) && props.autoselectFirst && !isDirty.value) {
|
|
1803
|
+
const firstOptionValue = getOptionValue(newValue[0]);
|
|
1804
|
+
localModelValue.value = props.multiple ? [firstOptionValue] : firstOptionValue;
|
|
1805
|
+
}
|
|
1806
|
+
},
|
|
1807
|
+
{ immediate: true }
|
|
1808
|
+
);
|
|
1773
1809
|
const hasAttrs = computed(() => {
|
|
1774
1810
|
return {
|
|
1775
1811
|
"name": props.name,
|
|
1776
1812
|
"tabindex": hasTabindex.value,
|
|
1777
|
-
"disabled":
|
|
1813
|
+
"disabled": isDisabledOrReadonly.value,
|
|
1778
1814
|
"required": props.required,
|
|
1779
1815
|
"size": props.size,
|
|
1780
1816
|
"autocomplete": props.autocomplete,
|
|
@@ -1789,30 +1825,6 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
1789
1825
|
invalid: props.invalid,
|
|
1790
1826
|
modelValue: props.modelValue
|
|
1791
1827
|
}));
|
|
1792
|
-
const {
|
|
1793
|
-
getOptionLabel,
|
|
1794
|
-
getOptionValue,
|
|
1795
|
-
isOptionDisabled,
|
|
1796
|
-
getOptionGrouped
|
|
1797
|
-
} = useOptions(props);
|
|
1798
|
-
const localModelValue = computed({
|
|
1799
|
-
get: () => {
|
|
1800
|
-
return props.modelValue;
|
|
1801
|
-
},
|
|
1802
|
-
set: (newValue) => {
|
|
1803
|
-
if (Array.isArray(newValue)) {
|
|
1804
|
-
newValue = newValue.filter((item) => item !== void 0);
|
|
1805
|
-
}
|
|
1806
|
-
emit("update:modelValue", newValue);
|
|
1807
|
-
}
|
|
1808
|
-
});
|
|
1809
|
-
function isGroup(option) {
|
|
1810
|
-
var _a;
|
|
1811
|
-
if (typeof option === "string") {
|
|
1812
|
-
return false;
|
|
1813
|
-
}
|
|
1814
|
-
return (_a = option.options) == null ? void 0 : _a.length;
|
|
1815
|
-
}
|
|
1816
1828
|
return (_ctx, _cache) => {
|
|
1817
1829
|
return openBlock(), createElementBlock(
|
|
1818
1830
|
"div",
|
|
@@ -1838,10 +1850,11 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
1838
1850
|
)) : createCommentVNode("v-if", true),
|
|
1839
1851
|
withDirectives(createElementVNode("select", mergeProps({
|
|
1840
1852
|
id: unref(hasId),
|
|
1841
|
-
ref_key: "
|
|
1842
|
-
ref:
|
|
1853
|
+
ref_key: "selectEl",
|
|
1854
|
+
ref: selectEl
|
|
1855
|
+
}, unref(hasAttrs), {
|
|
1843
1856
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(localModelValue) ? localModelValue.value = $event : null)
|
|
1844
|
-
}
|
|
1857
|
+
}), [
|
|
1845
1858
|
_ctx.placeholder ? (openBlock(), createElementBlock("option", {
|
|
1846
1859
|
key: 0,
|
|
1847
1860
|
value: void 0,
|
|
@@ -2421,7 +2434,6 @@ const VvComboboxProps = {
|
|
|
2421
2434
|
...OptionsProps,
|
|
2422
2435
|
...IconProps,
|
|
2423
2436
|
...FloatingLabelProps,
|
|
2424
|
-
...UnselectableProps,
|
|
2425
2437
|
...DropdownProps,
|
|
2426
2438
|
...LabelProps,
|
|
2427
2439
|
/**
|
|
@@ -2499,10 +2511,22 @@ const VvComboboxProps = {
|
|
|
2499
2511
|
* Manage modelValue as string[] or object[]
|
|
2500
2512
|
*/
|
|
2501
2513
|
multiple: Boolean,
|
|
2514
|
+
/**
|
|
2515
|
+
* The min number of selected values
|
|
2516
|
+
*/
|
|
2517
|
+
minValues: {
|
|
2518
|
+
type: [Number, String],
|
|
2519
|
+
default: 0
|
|
2520
|
+
},
|
|
2502
2521
|
/**
|
|
2503
2522
|
* The max number of selected values
|
|
2504
2523
|
*/
|
|
2505
2524
|
maxValues: [Number, String],
|
|
2525
|
+
/**
|
|
2526
|
+
* If true the input will be unselectable
|
|
2527
|
+
* @deprecated use minValues instead
|
|
2528
|
+
*/
|
|
2529
|
+
unselectable: { type: Boolean, default: true },
|
|
2506
2530
|
/**
|
|
2507
2531
|
* The select label separator visible to the user
|
|
2508
2532
|
*/
|
|
@@ -2543,6 +2567,13 @@ const VvComboboxProps = {
|
|
|
2543
2567
|
type: Boolean,
|
|
2544
2568
|
default: false
|
|
2545
2569
|
},
|
|
2570
|
+
/**
|
|
2571
|
+
* Select first option automatically
|
|
2572
|
+
*/
|
|
2573
|
+
autoselectFirst: {
|
|
2574
|
+
type: Boolean,
|
|
2575
|
+
default: false
|
|
2576
|
+
},
|
|
2546
2577
|
/**
|
|
2547
2578
|
* Keep open dropdown on single select
|
|
2548
2579
|
*/
|
|
@@ -2605,22 +2636,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2605
2636
|
VvComboboxProps2,
|
|
2606
2637
|
props
|
|
2607
2638
|
);
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
}
|
|
2613
|
-
return (_a = option.options) == null ? void 0 : _a.length;
|
|
2614
|
-
}
|
|
2639
|
+
const inputEl = ref(null);
|
|
2640
|
+
const inputSearchEl = ref(null);
|
|
2641
|
+
const wrapperEl = ref(null);
|
|
2642
|
+
const dropdownEl = ref(null);
|
|
2615
2643
|
const {
|
|
2616
2644
|
HintSlot,
|
|
2617
2645
|
hasHintLabelOrSlot,
|
|
2618
2646
|
hasInvalidLabelOrSlot,
|
|
2619
2647
|
hintSlotScope
|
|
2620
2648
|
} = HintSlotFactory(propsDefaults, slots);
|
|
2621
|
-
const inputEl = ref(null);
|
|
2622
|
-
const inputSearchEl = ref(null);
|
|
2623
|
-
const wrapperEl = ref(null);
|
|
2624
2649
|
const { focused } = useComponentFocus(inputEl, emit);
|
|
2625
2650
|
const { focused: focusedWithin } = useFocusWithin(wrapperEl);
|
|
2626
2651
|
watch(focused, (newValue) => {
|
|
@@ -2651,17 +2676,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2651
2676
|
});
|
|
2652
2677
|
const expanded = ref(false);
|
|
2653
2678
|
function toggleExpanded() {
|
|
2654
|
-
if (
|
|
2679
|
+
if (isDisabledOrReadonly.value)
|
|
2655
2680
|
return;
|
|
2656
2681
|
expanded.value = !expanded.value;
|
|
2657
2682
|
}
|
|
2658
2683
|
function expand() {
|
|
2659
|
-
if (
|
|
2684
|
+
if (isDisabledOrReadonly.value || expanded.value)
|
|
2660
2685
|
return;
|
|
2661
2686
|
expanded.value = true;
|
|
2662
2687
|
}
|
|
2663
2688
|
function collapse() {
|
|
2664
|
-
if (
|
|
2689
|
+
if (isDisabledOrReadonly.value || !expanded.value)
|
|
2665
2690
|
return;
|
|
2666
2691
|
expanded.value = false;
|
|
2667
2692
|
}
|
|
@@ -2679,6 +2704,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2679
2704
|
searchText.value = "";
|
|
2680
2705
|
}
|
|
2681
2706
|
}
|
|
2707
|
+
function isGroup(option) {
|
|
2708
|
+
var _a;
|
|
2709
|
+
if (typeof option === "string") {
|
|
2710
|
+
return false;
|
|
2711
|
+
}
|
|
2712
|
+
return (_a = option.options) == null ? void 0 : _a.length;
|
|
2713
|
+
}
|
|
2682
2714
|
const {
|
|
2683
2715
|
id,
|
|
2684
2716
|
icon,
|
|
@@ -2696,14 +2728,53 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2696
2728
|
const hasDropdownId = computed(() => `${hasId.value}-dropdown`);
|
|
2697
2729
|
const hasSearchId = computed(() => `${hasId.value}-search`);
|
|
2698
2730
|
const hasLabelId = computed(() => `${hasId.value}-label`);
|
|
2731
|
+
const isDisabledOrReadonly = computed(() => props.disabled || props.readonly);
|
|
2732
|
+
const hasTabindex = computed(() => {
|
|
2733
|
+
return isDisabledOrReadonly.value ? -1 : props.tabindex;
|
|
2734
|
+
});
|
|
2735
|
+
const localModelValue = computed({
|
|
2736
|
+
get: () => {
|
|
2737
|
+
if (Array.isArray(props.modelValue)) {
|
|
2738
|
+
return new Set(props.modelValue);
|
|
2739
|
+
}
|
|
2740
|
+
return props.modelValue !== void 0 && props.modelValue !== null ? /* @__PURE__ */ new Set([props.modelValue]) : /* @__PURE__ */ new Set();
|
|
2741
|
+
},
|
|
2742
|
+
set: (value) => {
|
|
2743
|
+
emit("update:modelValue", props.multiple ? [...value] : [...value].pop());
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
const sizeOfModelValue = computed(() => localModelValue.value.size);
|
|
2747
|
+
const isDirty = computed(() => sizeOfModelValue.value > 0);
|
|
2748
|
+
const hasMaxValues = computed(() => {
|
|
2749
|
+
if (!props.multiple) {
|
|
2750
|
+
return 1;
|
|
2751
|
+
}
|
|
2752
|
+
if (props.maxValues === void 0) {
|
|
2753
|
+
return Infinity;
|
|
2754
|
+
}
|
|
2755
|
+
return Number(props.maxValues);
|
|
2756
|
+
});
|
|
2757
|
+
const isUnselectable = computed(() => {
|
|
2758
|
+
if (isDisabledOrReadonly.value) {
|
|
2759
|
+
return false;
|
|
2760
|
+
}
|
|
2761
|
+
if (!props.unselectable) {
|
|
2762
|
+
return false;
|
|
2763
|
+
}
|
|
2764
|
+
return sizeOfModelValue.value > Number(props.minValues);
|
|
2765
|
+
});
|
|
2766
|
+
const isSelectable = computed(() => {
|
|
2767
|
+
if (isDisabledOrReadonly.value) {
|
|
2768
|
+
return false;
|
|
2769
|
+
}
|
|
2770
|
+
if (!props.multiple) {
|
|
2771
|
+
return true;
|
|
2772
|
+
}
|
|
2773
|
+
return sizeOfModelValue.value < hasMaxValues.value;
|
|
2774
|
+
});
|
|
2699
2775
|
const localLoading = ref(false);
|
|
2700
2776
|
const isLoading = computed(() => localLoading.value || loading.value);
|
|
2701
|
-
const dropdownEl = ref();
|
|
2702
2777
|
const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition);
|
|
2703
|
-
const isDirty = computed(() => !isEmpty(props.modelValue));
|
|
2704
|
-
const hasTabindex = computed(() => {
|
|
2705
|
-
return disabled.value || readonly.value ? -1 : props.tabindex;
|
|
2706
|
-
});
|
|
2707
2778
|
const bemCssClasses = useModifiers(
|
|
2708
2779
|
"vv-select",
|
|
2709
2780
|
modifiers,
|
|
@@ -2727,6 +2798,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2727
2798
|
getOptionGrouped,
|
|
2728
2799
|
isOptionDisabled
|
|
2729
2800
|
} = useOptions(props);
|
|
2801
|
+
function isOptionDisabledOrNotSelectable(option) {
|
|
2802
|
+
return isOptionDisabled(option) || !isSelectable.value && !isOptionSelected(option);
|
|
2803
|
+
}
|
|
2730
2804
|
const filteredOptions = computedAsync(async () => {
|
|
2731
2805
|
var _a;
|
|
2732
2806
|
if (propsDefaults.value.searchFunction) {
|
|
@@ -2745,10 +2819,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2745
2819
|
});
|
|
2746
2820
|
});
|
|
2747
2821
|
function isOptionSelected(option) {
|
|
2748
|
-
|
|
2749
|
-
return contains(option, props.modelValue) || contains(getOptionValue(option), props.modelValue);
|
|
2750
|
-
}
|
|
2751
|
-
return equals(option, props.modelValue) || equals(getOptionValue(option), props.modelValue);
|
|
2822
|
+
return localModelValue.value.has(getOptionValue(option));
|
|
2752
2823
|
}
|
|
2753
2824
|
const selectedOptions = computed(() => {
|
|
2754
2825
|
const options = props.options.reduce(
|
|
@@ -2771,40 +2842,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2771
2842
|
props.autoOpen ? expand() : toggleExpanded();
|
|
2772
2843
|
}
|
|
2773
2844
|
function onInput(option) {
|
|
2774
|
-
|
|
2775
|
-
if (
|
|
2776
|
-
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
if (props.maxValues !== void 0 && maxValues >= 0 && ((_a = props.modelValue) == null ? void 0 : _a.length) >= maxValues) {
|
|
2784
|
-
if (!contains(value, props.modelValue)) {
|
|
2785
|
-
return;
|
|
2786
|
-
}
|
|
2787
|
-
}
|
|
2788
|
-
toReturn = contains(value, props.modelValue) ? removeFromList(value, props.modelValue) : [...props.modelValue, value];
|
|
2789
|
-
} else {
|
|
2790
|
-
toReturn = [value];
|
|
2791
|
-
}
|
|
2792
|
-
} else {
|
|
2793
|
-
if (!props.keepOpen) {
|
|
2794
|
-
collapse();
|
|
2795
|
-
}
|
|
2796
|
-
if (Array.isArray(props.modelValue)) {
|
|
2797
|
-
if (props.unselectable && props.modelValue.includes(value)) {
|
|
2798
|
-
toReturn = [];
|
|
2799
|
-
} else {
|
|
2800
|
-
toReturn = [value];
|
|
2801
|
-
}
|
|
2802
|
-
} else if (props.unselectable && value === props.modelValue) {
|
|
2803
|
-
toReturn = void 0;
|
|
2804
|
-
}
|
|
2845
|
+
const isSelected = isOptionSelected(option);
|
|
2846
|
+
if (isSelected && isUnselectable.value) {
|
|
2847
|
+
localModelValue.value.delete(getOptionValue(option));
|
|
2848
|
+
} else if (!isSelected && isSelectable.value) {
|
|
2849
|
+
localModelValue.value.add(getOptionValue(option));
|
|
2850
|
+
}
|
|
2851
|
+
localModelValue.value = new Set(localModelValue.value);
|
|
2852
|
+
if (!props.multiple && !props.keepOpen) {
|
|
2853
|
+
collapse();
|
|
2805
2854
|
}
|
|
2806
|
-
emit("update:modelValue", toReturn);
|
|
2807
2855
|
}
|
|
2856
|
+
watch(
|
|
2857
|
+
() => props.options,
|
|
2858
|
+
(newValue) => {
|
|
2859
|
+
if ((newValue == null ? void 0 : newValue.length) && props.autoselectFirst && !isDirty.value) {
|
|
2860
|
+
onInput(newValue[0]);
|
|
2861
|
+
}
|
|
2862
|
+
},
|
|
2863
|
+
{ immediate: true }
|
|
2864
|
+
);
|
|
2808
2865
|
const selectProps = computed(() => ({
|
|
2809
2866
|
id: hasId.value,
|
|
2810
2867
|
name: props.name,
|
|
@@ -2825,7 +2882,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2825
2882
|
icon: propsDefaults.value.icon,
|
|
2826
2883
|
iconPosition: propsDefaults.value.iconPosition,
|
|
2827
2884
|
floating: propsDefaults.value.floating,
|
|
2828
|
-
unselectable:
|
|
2885
|
+
unselectable: isUnselectable.value,
|
|
2886
|
+
autoselectFirst: propsDefaults.value.autoselectFirst,
|
|
2829
2887
|
multiple: propsDefaults.value.multiple,
|
|
2830
2888
|
label: propsDefaults.value.label,
|
|
2831
2889
|
placeholder: propsDefaults.value.placeholder,
|
|
@@ -2946,7 +3004,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2946
3004
|
1
|
|
2947
3005
|
/* TEXT */
|
|
2948
3006
|
),
|
|
2949
|
-
|
|
3007
|
+
unref(isUnselectable) ? (openBlock(), createElementBlock("button", {
|
|
2950
3008
|
key: 0,
|
|
2951
3009
|
"aria-label": unref(propsDefaults).deselectActionLabel,
|
|
2952
3010
|
type: "button",
|
|
@@ -3018,8 +3076,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3018
3076
|
), (item, i) => {
|
|
3019
3077
|
return openBlock(), createBlock(_sfc_main$6, mergeProps({ ref_for: true }, {
|
|
3020
3078
|
selected: isOptionSelected(item),
|
|
3021
|
-
disabled:
|
|
3022
|
-
unselectable:
|
|
3079
|
+
disabled: isOptionDisabledOrNotSelectable(item),
|
|
3080
|
+
unselectable: unref(isUnselectable),
|
|
3023
3081
|
deselectHintLabel: unref(propsDefaults).deselectHintLabel,
|
|
3024
3082
|
selectHintLabel: unref(propsDefaults).selectHintLabel,
|
|
3025
3083
|
selectedHintLabel: unref(propsDefaults).selectedHintLabel
|
|
@@ -3034,7 +3092,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3034
3092
|
option,
|
|
3035
3093
|
selectedOptions: unref(selectedOptions),
|
|
3036
3094
|
selected: isOptionSelected(item),
|
|
3037
|
-
disabled:
|
|
3095
|
+
disabled: isOptionDisabledOrNotSelectable(item)
|
|
3038
3096
|
}), () => [
|
|
3039
3097
|
createTextVNode(
|
|
3040
3098
|
toDisplayString(unref(getOptionLabel)(item)),
|
|
@@ -3058,8 +3116,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3058
3116
|
ref_for: true
|
|
3059
3117
|
}, {
|
|
3060
3118
|
selected: isOptionSelected(option),
|
|
3061
|
-
disabled:
|
|
3062
|
-
unselectable:
|
|
3119
|
+
disabled: isOptionDisabledOrNotSelectable(option),
|
|
3120
|
+
unselectable: unref(isUnselectable),
|
|
3063
3121
|
deselectHintLabel: unref(propsDefaults).deselectHintLabel,
|
|
3064
3122
|
selectHintLabel: unref(propsDefaults).selectHintLabel,
|
|
3065
3123
|
selectedHintLabel: unref(propsDefaults).selectedHintLabel
|
|
@@ -3073,7 +3131,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3073
3131
|
option,
|
|
3074
3132
|
selectedOptions: unref(selectedOptions),
|
|
3075
3133
|
selected: isOptionSelected(option),
|
|
3076
|
-
disabled:
|
|
3134
|
+
disabled: isOptionDisabledOrNotSelectable(option)
|
|
3077
3135
|
}), () => [
|
|
3078
3136
|
createTextVNode(
|
|
3079
3137
|
toDisplayString(unref(getOptionLabel)(option)),
|