@volverjs/ui-vue 0.0.8-beta.1 → 0.0.8-beta.11
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/auto-imports.d.ts +1 -0
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +4 -3
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +555 -106
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +3 -0
- package/dist/components/VvCombobox/index.d.ts +1 -0
- package/dist/components/VvDropdown/VvDropdown.es.js +56 -28
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +11 -2
- package/dist/components/VvDropdown/index.d.ts +7 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +4 -3
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.es.js +4 -3
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/index.es.js +110 -58
- 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/ComboboxOptions.stories.d.ts +1 -0
- package/package.json +32 -28
- 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 +48 -26
- package/src/components/VvCombobox/index.ts +1 -0
- package/src/components/VvDropdown/VvDropdown.vue +59 -26
- package/src/components/VvDropdown/index.ts +8 -2
- package/src/composables/useOptions.ts +4 -3
- package/src/stories/Combobox/Combobox.settings.ts +22 -1
- package/src/stories/Combobox/Combobox.test.ts +5 -6
- package/src/stories/Combobox/ComboboxOptions.stories.ts +18 -0
- package/src/stories/Select/Select.test.ts +3 -3
- package/src/stories/Tooltip/Tooltip.test.ts +3 -1
package/auto-imports.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ declare global {
|
|
|
104
104
|
const toReactive: typeof import('@vueuse/core')['toReactive']
|
|
105
105
|
const toRef: typeof import('vue')['toRef']
|
|
106
106
|
const toRefs: typeof import('vue')['toRefs']
|
|
107
|
+
const toValue: typeof import('vue')['toValue']
|
|
107
108
|
const triggerRef: typeof import('vue')['triggerRef']
|
|
108
109
|
const tryOnBeforeMount: typeof import('@vueuse/core')['tryOnBeforeMount']
|
|
109
110
|
const tryOnBeforeUnmount: typeof import('@vueuse/core')['tryOnBeforeUnmount']
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { unref, computed, defineComponent, h, inject, toRef, toRefs, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, isRef, vModelCheckbox, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps, provide, createCommentVNode, Fragment, renderList, createBlock, mergeProps } from "vue";
|
|
2
2
|
import { nanoid } from "nanoid";
|
|
3
3
|
import { useVModel } from "@vueuse/core";
|
|
4
|
+
import { get } from "ts-dot-prop";
|
|
4
5
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
5
6
|
Side2["left"] = "left";
|
|
6
7
|
Side2["right"] = "right";
|
|
@@ -857,18 +858,18 @@ function useOptions(props) {
|
|
|
857
858
|
if (typeof option !== "object" && option !== null)
|
|
858
859
|
return option;
|
|
859
860
|
return String(
|
|
860
|
-
typeof labelKey.value === "function" ? labelKey.value(option) : option
|
|
861
|
+
typeof labelKey.value === "function" ? labelKey.value(option) : get(option, labelKey.value)
|
|
861
862
|
);
|
|
862
863
|
};
|
|
863
864
|
const getOptionValue = (option) => {
|
|
864
865
|
if (typeof option !== "object" && option !== null)
|
|
865
866
|
return option;
|
|
866
|
-
return typeof valueKey.value === "function" ? valueKey.value(option) : option
|
|
867
|
+
return typeof valueKey.value === "function" ? valueKey.value(option) : get(option, valueKey.value);
|
|
867
868
|
};
|
|
868
869
|
const getOptionDisabled = (option) => {
|
|
869
870
|
if (typeof option !== "object" && option !== null)
|
|
870
871
|
return false;
|
|
871
|
-
return typeof disabledKey.value === "function" ? disabledKey.value(option) : option
|
|
872
|
+
return typeof disabledKey.value === "function" ? disabledKey.value(option) : get(option, disabledKey.value);
|
|
872
873
|
};
|
|
873
874
|
const getOptionGrouped = (option) => {
|
|
874
875
|
if (typeof option !== "object" && option !== null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=l(e.vue,e.nanoid,e.core)}(this,(function(e,l,t){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),o=(e=>(e.before="before",e.after="after",e))(o||{}),n=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(n||{});const i=Symbol.for("checkGroup");function r(e,l,t){return t?d(e,t)===d(l,t):u(e,l)}function u(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),a=Array.isArray(l);let o,n,i;if(t&&a){if(n=e.length,n!=l.length)return!1;for(o=n;0!=o--;)if(!u(e[o],l[o]))return!1;return!0}if(t!=a)return!1;const r=e instanceof Date,d=l instanceof Date;if(r!=d)return!1;if(r&&d)return e.getTime()==l.getTime();const s=e instanceof RegExp,v=l instanceof RegExp;if(s!=v)return!1;if(s&&v)return e.toString()==l.toString();const c=Object.keys(e);if(n=c.length,n!==Object.keys(l).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(l,c[o]))return!1;for(o=n;0!=o--;)if(i=c[o],!u(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function d(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let a=e;for(let l=0,o=t.length;l<o;++l){if(null==e)return null;a=a[t[l]]}return a}}return null}function s(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function v(l,t){const a=e.computed((()=>s(l.invalidLabel))),o=e.computed((()=>s(l.validLabel))),n=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(t.loading||n.value)))),u=e.computed((()=>!r.value&&Boolean(l.invalid&&(t.invalid||a.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(t.valid||o.value)))),v=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(t.hint||i.value))),c=e.computed((()=>u.value||d.value||r.value||v.value)),f=e.computed((()=>({modelValue:l.modelValue,valid:l.valid,invalid:l.invalid,loading:l.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:a,validLabel:o,loadingLabel:n,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:v}),render(){var l,t,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==(t=(l=this.$slots).loading)?void 0:t.call(l))??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:u,hasHintLabelOrSlot:v,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:f,HintSlot:p}}const c={valid:Boolean,validLabel:[String,Array]},f={invalid:Boolean,invalidLabel:[String,Array]},p={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},m={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},g={modifiers:[String,Array]},y={hintLabel:{type:String,default:""}},S={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};o.before;const k={tabindex:{type:[String,Number],default:0}},L={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const B={...{...L,name:{type:String,required:!0}},...k,...c,...f,...y,...m,...h,...g,...b,...p,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},V={...c,...f,...S,...y,...m,...h,...g,...b,...p,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function O(l){const t=e.inject(l,void 0),a=e.computed((()=>{return l=t,!(null==(a=e.unref(l))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length);var l,a}));return{group:t,isInGroup:a,getGroupOrLocalRef:function(l,a,o){if(null==t?void 0:t.value){const a=e.unref(t.value)[l];return e.computed({get:()=>null==a?void 0:a.value,set(e){a.value=e}})}const n=e.toRef(a,l);return e.computed({get:()=>n.value,set(e){o&&o(`update:${l}`,e)}})}}}n.button;const x={...B,...g,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function $(l,t,a){return e.computed((()=>{const o={[l]:!0},n="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(o[`${l}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{o[`${l}--${t}`]=e.unref(a.value[t])})),o}))}const A=["for"],w=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],C=e.defineComponent({name:"VvCheckbox",props:x,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const o=t,n=e.useSlots(),{id:u,disabled:d,readonly:s,valid:c,invalid:f,propsSwitch:p,modelValue:m,indeterminate:b,isInGroup:h}=function(l,t){const{group:a,isInGroup:o,getGroupOrLocalRef:n}=O(i),{id:r,switch:u,indeterminate:d}=e.toRefs(l),s=n("modelValue",l,t),v=n("valid",l),c=n("invalid",l),f=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),p=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:r,propsSwitch:u,indeterminate:d,group:a,isInGroup:o,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(o,a),g=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(u),y=e.computed((()=>`${g.value}-hint`)),S=e.computed((()=>B.value?-1:o.tabindex)),k=e.ref(),L=e.computed((()=>void 0!==o.uncheckedValue&&!h.value)),B=e.computed((()=>d.value||s.value)),V=e.computed((()=>!0===f.value||!0!==c.value&&void 0)),x=e.computed((()=>L.value?m.value===o.value:Array.isArray(m.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(r(e,t))return!0;return!1}(o.value,m.value):r(o.value,m.value))),C=e.computed((()=>!!b.value||!(x.value||!L.value||o.uncheckedValue===m.value))),R=e.computed((()=>{if(!L.value)return!["string","number","boolean"].includes(typeof o.value)||o.value})),j=e.computed({get:()=>x.value,set(e){if(L.value)m.value=e?o.value:o.uncheckedValue;else if(Array.isArray(m.value)||h.value){const l=new Set(Array.isArray(m.value)?m.value:void 0!==m.value?[m.value]:[]);e?l.add(o.value):l.delete(o.value),m.value=[...l]}else m.value=e?o.value:void 0;a("change",e)}}),{modifiers:P}=e.toRefs(o),N=$("vv-checkbox",P,e.computed((()=>({switch:p.value,valid:c.value,invalid:f.value,disabled:d.value,readonly:s.value,indeterminate:b.value}))));e.watchEffect((()=>{L.value&&Array.isArray(m.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>C.value),(e=>{k.value.indeterminate=!!e})),e.onMounted((()=>{C.value&&(k.value.indeterminate=!0)}));const{HintSlot:E,hasHintLabelOrSlot:_,hasInvalidLabelOrSlot:z,hintSlotScope:G}=v(o,n);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(N)),for:e.unref(g)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(g),ref_key:"input",ref:k,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(j)?j.value=l:null),type:"checkbox",class:"vv-checkbox__input",name:l.name,disabled:e.unref(B),value:e.unref(R),tabindex:e.unref(S),"aria-invalid":e.unref(V),"aria-describedby":e.unref(_)?e.unref(y):void 0,"aria-errormessage":e.unref(z)?e.unref(y):void 0},null,8,w),[[e.vModelCheckbox,e.unref(j)]]),e.renderSlot(l.$slots,"default",{value:e.unref(m)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(E),{id:e.unref(y),class:"vv-checkbox__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"3"}:void 0]),1032,["id"])],10,A))}}),R=V;const j=["textContent"],P={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:R,emits:["update:modelValue","change"],setup(l,{emit:a}){const o=l,n=e.useSlots(),r=t.useVModel(o,"modelValue",a),{disabled:u,readonly:d,vertical:s,valid:c,invalid:f,modifiers:p}=e.toRefs(o);!function(l){if(Object.keys(l).some((t=>"key"!==t&&!e.isRef(l[t]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:i,modelValue:r,disabled:u,readonly:d,valid:c,invalid:f});const{getOptionLabel:m,getOptionValue:b}=function(l){const{options:t,labelKey:a,valueKey:o,disabledKey:n}=e.toRefs(l);return{options:t,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof a.value?a.value(e):e[a.value]),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof o.value?o.value(e):e[o.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof n.value?n.value(e):e[n.value]),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(o),h=$("vv-checkbox-group",p,e.computed((()=>({disabled:u.value,readonly:d.value,horizontal:!s.value,valid:c.value,invalid:f.value})))),{HintSlot:g,hintSlotScope:y}=v(o,n);return(l,t)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(h))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,j)):e.createCommentVNode("",!0),e.createElementVNode("div",P,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,t)=>(e.openBlock(),e.createBlock(C,e.mergeProps({key:t},((e,l)=>({id:`${o.name}_opt${l}`,name:o.name,label:m(e),value:b(e)}))(l,t)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(g),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
1
|
+
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core","ts-dot-prop"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=l(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,l,t,a){"use strict";var o=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(o||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{});const r=Symbol.for("checkGroup");function u(e,l,t){return t?s(e,t)===s(l,t):d(e,l)}function d(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),a=Array.isArray(l);let o,n,i;if(t&&a){if(n=e.length,n!=l.length)return!1;for(o=n;0!=o--;)if(!d(e[o],l[o]))return!1;return!0}if(t!=a)return!1;const r=e instanceof Date,u=l instanceof Date;if(r!=u)return!1;if(r&&u)return e.getTime()==l.getTime();const s=e instanceof RegExp,v=l instanceof RegExp;if(s!=v)return!1;if(s&&v)return e.toString()==l.toString();const c=Object.keys(e);if(n=c.length,n!==Object.keys(l).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(l,c[o]))return!1;for(o=n;0!=o--;)if(i=c[o],!d(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function s(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let a=e;for(let l=0,o=t.length;l<o;++l){if(null==e)return null;a=a[t[l]]}return a}}return null}function v(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function c(l,t){const a=e.computed((()=>v(l.invalidLabel))),o=e.computed((()=>v(l.validLabel))),n=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(t.loading||n.value)))),u=e.computed((()=>!r.value&&Boolean(l.invalid&&(t.invalid||a.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(t.valid||o.value)))),s=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(t.hint||i.value))),c=e.computed((()=>u.value||d.value||r.value||s.value)),f=e.computed((()=>({modelValue:l.modelValue,valid:l.valid,invalid:l.invalid,loading:l.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:a,validLabel:o,loadingLabel:n,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:s}),render(){var l,t,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==(t=(l=this.$slots).loading)?void 0:t.call(l))??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:u,hasHintLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:f,HintSlot:p}}const f={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},m={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},b={disabled:Boolean},h=(Boolean,Boolean,{label:[String,Number]}),g={readonly:Boolean},y={modifiers:[String,Array]},S={hintLabel:{type:String,default:""}},k={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};n.before;const L={tabindex:{type:[String,Number],default:0}},B={id:[String,Number]};o.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const V={...{...B,name:{type:String,required:!0}},...L,...f,...p,...S,...b,...g,...y,...h,...m,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},O={...f,...p,...k,...S,...b,...g,...y,...h,...m,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function x(l){const t=e.inject(l,void 0),a=e.computed((()=>{return l=t,!(null==(a=e.unref(l))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length);var l,a}));return{group:t,isInGroup:a,getGroupOrLocalRef:function(l,a,o){if(null==t?void 0:t.value){const a=e.unref(t.value)[l];return e.computed({get:()=>null==a?void 0:a.value,set(e){a.value=e}})}const n=e.toRef(a,l);return e.computed({get:()=>n.value,set(e){o&&o(`update:${l}`,e)}})}}}i.button;const $={...V,...y,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function A(l,t,a){return e.computed((()=>{const o={[l]:!0},n="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(o[`${l}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{o[`${l}--${t}`]=e.unref(a.value[t])})),o}))}const w=["for"],C=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],P=e.defineComponent({name:"VvCheckbox",props:$,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const o=t,n=e.useSlots(),{id:i,disabled:d,readonly:s,valid:v,invalid:f,propsSwitch:p,modelValue:m,indeterminate:b,isInGroup:h}=function(l,t){const{group:a,isInGroup:o,getGroupOrLocalRef:n}=x(r),{id:i,switch:u,indeterminate:d}=e.toRefs(l),s=n("modelValue",l,t),v=n("valid",l),c=n("invalid",l),f=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),p=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:i,propsSwitch:u,indeterminate:d,group:a,isInGroup:o,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(o,a),g=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(i),y=e.computed((()=>`${g.value}-hint`)),S=e.computed((()=>B.value?-1:o.tabindex)),k=e.ref(),L=e.computed((()=>void 0!==o.uncheckedValue&&!h.value)),B=e.computed((()=>d.value||s.value)),V=e.computed((()=>!0===f.value||!0!==v.value&&void 0)),O=e.computed((()=>L.value?m.value===o.value:Array.isArray(m.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(u(e,t))return!0;return!1}(o.value,m.value):u(o.value,m.value))),$=e.computed((()=>!!b.value||!(O.value||!L.value||o.uncheckedValue===m.value))),P=e.computed((()=>{if(!L.value)return!["string","number","boolean"].includes(typeof o.value)||o.value})),R=e.computed({get:()=>O.value,set(e){if(L.value)m.value=e?o.value:o.uncheckedValue;else if(Array.isArray(m.value)||h.value){const l=new Set(Array.isArray(m.value)?m.value:void 0!==m.value?[m.value]:[]);e?l.add(o.value):l.delete(o.value),m.value=[...l]}else m.value=e?o.value:void 0;a("change",e)}}),{modifiers:j}=e.toRefs(o),N=A("vv-checkbox",j,e.computed((()=>({switch:p.value,valid:v.value,invalid:f.value,disabled:d.value,readonly:s.value,indeterminate:b.value}))));e.watchEffect((()=>{L.value&&Array.isArray(m.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>$.value),(e=>{k.value.indeterminate=!!e})),e.onMounted((()=>{$.value&&(k.value.indeterminate=!0)}));const{HintSlot:E,hasHintLabelOrSlot:_,hasInvalidLabelOrSlot:z,hintSlotScope:G}=c(o,n);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(N)),for:e.unref(g)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(g),ref_key:"input",ref:k,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(R)?R.value=l:null),type:"checkbox",class:"vv-checkbox__input",name:l.name,disabled:e.unref(B),value:e.unref(P),tabindex:e.unref(S),"aria-invalid":e.unref(V),"aria-describedby":e.unref(_)?e.unref(y):void 0,"aria-errormessage":e.unref(z)?e.unref(y):void 0},null,8,C),[[e.vModelCheckbox,e.unref(R)]]),e.renderSlot(l.$slots,"default",{value:e.unref(m)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(E),{id:e.unref(y),class:"vv-checkbox__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"3"}:void 0]),1032,["id"])],10,w))}}),R=O;const j=["textContent"],N={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:R,emits:["update:modelValue","change"],setup(l,{emit:o}){const n=l,i=e.useSlots(),u=t.useVModel(n,"modelValue",o),{disabled:d,readonly:s,vertical:v,valid:f,invalid:p,modifiers:m}=e.toRefs(n);!function(l){if(Object.keys(l).some((t=>"key"!==t&&!e.isRef(l[t]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:r,modelValue:u,disabled:d,readonly:s,valid:f,invalid:p});const{getOptionLabel:b,getOptionValue:h}=function(l){const{options:t,labelKey:o,valueKey:n,disabledKey:i}=e.toRefs(l);return{options:t,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof o.value?o.value(e):a.get(e,o.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):a.get(e,n.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):a.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(n),g=A("vv-checkbox-group",m,e.computed((()=>({disabled:d.value,readonly:s.value,horizontal:!v.value,valid:f.value,invalid:p.value})))),{HintSlot:y,hintSlotScope:S}=c(n,i);return(l,t)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(g))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,j)):e.createCommentVNode("",!0),e.createElementVNode("div",N,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,t)=>(e.openBlock(),e.createBlock(P,e.mergeProps({key:t},((e,l)=>({id:`${n.name}_opt${l}`,name:n.name,label:b(e),value:h(e)}))(l,t)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(y),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"3"}:void 0]),1024)],2))}})}));
|