@volverjs/ui-vue 0.0.9-beta.2 → 0.0.9-beta.21
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/README.md +3 -3
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +15 -7
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +15 -7
- package/dist/components/VvAction/VvAction.es.js +17 -8
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +9 -0
- package/dist/components/VvAction/index.d.ts +4 -0
- package/dist/components/VvAlert/VvAlert.es.js +22 -13
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +6 -6
- package/dist/components/VvAlert/index.d.ts +3 -3
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +22 -13
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +6 -6
- package/dist/components/VvAlertGroup/index.d.ts +2 -2
- package/dist/components/VvAvatar/VvAvatar.es.js +15 -7
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +15 -7
- package/dist/components/VvBadge/VvBadge.es.js +15 -7
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +15 -7
- package/dist/components/VvButton/VvButton.es.js +19 -9
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +9 -0
- package/dist/components/VvButton/index.d.ts +4 -0
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +15 -7
- package/dist/components/VvCard/VvCard.es.js +15 -7
- package/dist/components/VvCheckbox/VvCheckbox.es.js +99 -21
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +105 -22
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +4 -4
- package/dist/components/VvCombobox/VvCombobox.es.js +256 -191
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +329 -101
- package/dist/components/VvCombobox/index.d.ts +123 -37
- package/dist/components/VvDialog/VvDialog.es.js +50 -37
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +32 -18
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +300 -92
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +99 -30
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +17 -8
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +15 -7
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +15 -7
- package/dist/components/VvInputText/VvInputText.es.js +279 -116
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +23 -41
- package/dist/components/VvInputText/index.d.ts +15 -33
- package/dist/components/VvNav/VvNav.es.js +18 -9
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/index.d.ts +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +15 -7
- package/dist/components/VvRadio/VvRadio.es.js +99 -21
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +105 -22
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +4 -4
- package/dist/components/VvSelect/VvSelect.es.js +95 -21
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +5 -5
- package/dist/components/VvTab/VvTab.es.js +18 -9
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +103 -26
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
- package/dist/components/VvTooltip/VvTooltip.es.js +15 -7
- package/dist/components/common/HintSlot.d.ts +4 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.es.js +1212 -626
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +27 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.es.js +81 -0
- package/dist/composables/index.umd.js +1 -0
- package/dist/constants.d.ts +14 -0
- package/dist/directives/index.es.js +15 -7
- package/dist/directives/v-tooltip.es.js +15 -7
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +107 -31
- package/dist/resolvers/unplugin.es.js +3 -0
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +2 -2
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +54 -269
- package/dist/stories/Alert/Alert.settings.d.ts +3 -7
- package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +2 -2
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +6 -0
- package/dist/stories/Button/Button.settings.d.ts +3 -13
- package/dist/stories/Combobox/Combobox.settings.d.ts +117 -19
- package/dist/stories/InputText/InputText.settings.d.ts +31 -9
- package/dist/stories/InputText/InputText.stories.d.ts +0 -1
- package/dist/stories/InputText/InputTextMask.stories.d.ts +12 -0
- package/dist/stories/Nav/Nav.settings.d.ts +3 -21
- package/package.json +75 -66
- 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/VvAction/VvAction.vue +2 -1
- package/src/components/VvAlert/VvAlert.vue +5 -1
- package/src/components/VvAlert/index.ts +3 -3
- package/src/components/VvAlertGroup/VvAlertGroup.vue +2 -0
- package/src/components/VvButton/VvButton.vue +1 -0
- package/src/components/VvCheckbox/VvCheckbox.vue +8 -1
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +8 -1
- package/src/components/VvCombobox/VvCombobox.vue +43 -23
- package/src/components/VvCombobox/index.ts +24 -0
- package/src/components/VvDialog/VvDialog.vue +22 -19
- package/src/components/VvDropdown/VvDropdown.vue +24 -18
- package/src/components/VvInputText/VvInputText.vue +177 -55
- package/src/components/VvInputText/index.ts +32 -34
- package/src/components/VvNav/VvNav.vue +1 -1
- package/src/components/VvNav/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +8 -1
- package/src/components/VvRadioGroup/VvRadioGroup.vue +8 -1
- package/src/components/VvSelect/VvSelect.vue +8 -1
- package/src/components/VvTextarea/VvTextarea.vue +16 -6
- package/src/components/common/HintSlot.ts +26 -13
- package/src/components/index.ts +5 -0
- package/src/composables/alert/useAlert.ts +103 -0
- package/src/composables/index.ts +1 -0
- package/src/constants.ts +26 -0
- package/src/props/index.ts +14 -11
- package/src/resolvers/unplugin.ts +3 -0
- package/src/stories/Alert/Alert.settings.ts +3 -1
- package/src/stories/AlertGroup/AlertGroup.test.ts +13 -0
- package/src/stories/AlertGroup/AlertGroupSlots.stories.ts +3 -3
- package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +118 -0
- package/src/stories/Button/Button.settings.ts +5 -3
- package/src/stories/Combobox/Combobox.settings.ts +119 -2
- package/src/stories/Combobox/Combobox.test.ts +1 -1
- package/src/stories/InputText/InputText.settings.ts +36 -15
- package/src/stories/InputText/InputText.stories.ts +4 -12
- package/src/stories/InputText/InputText.test.ts +31 -15
- package/src/stories/InputText/InputTextMask.stories.ts +122 -0
- package/src/stories/Nav/Nav.settings.ts +3 -1
- package/src/stories/Tab/Tab.stories.ts +3 -3
- package/src/stories/Textarea/TextareaLength.stories.ts +1 -1
- package/src/types/alert.d.ts +20 -0
- /package/dist/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue.d.ts +0 -0
- /package/dist/components/{VvNavSeparator → VvNav}/VvNavSeparator.d.ts +0 -0
- /package/src/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue +0 -0
- /package/src/components/{VvNavSeparator → VvNav}/VvNavSeparator.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckbox=l(e.vue,e.nanoid)}(this,(function(e,l){"use strict";var
|
|
1
|
+
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckbox=l(e.vue,e.nanoid)}(this,(function(e,l){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),n=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(n||{});const o=Symbol.for("volver"),i=Symbol.for("checkGroup"),r={valid:Boolean,validLabel:[String,Array]},u={invalid:Boolean,invalidLabel:[String,Array]},d={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},s={disabled:Boolean},v=(Boolean,Boolean,{label:[String,Number]}),c={readonly:Boolean},f={modifiers:[String,Array]},p={hintLabel:{type:String,default:""}};a.before;const b={tabindex:{type:[String,Number],default:0}},h={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const m={...{...h,name:{type:String,required:!0}},...b,...r,...u,...p,...s,...c,...f,...v,...d,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]};function g(e,l,t){return t?S(e,t)===S(l,t):y(e,l)}function y(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 n,o,i;if(t&&a){if(o=e.length,o!=l.length)return!1;for(n=o;0!=n--;)if(!y(e[n],l[n]))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 d=e instanceof RegExp,s=l instanceof RegExp;if(d!=s)return!1;if(d&&s)return e.toString()==l.toString();const v=Object.keys(e);if(o=v.length,o!==Object.keys(l).length)return!1;for(n=o;0!=n--;)if(!Object.prototype.hasOwnProperty.call(l,v[n]))return!1;for(n=o;0!=n--;)if(i=v[n],!y(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,n=t.length;l<n;++l){if(null==e)return null;a=a[t[l]]}return a}}return null}function L(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,n){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 o=e.toRef(a,l);return e.computed({get:()=>o.value,set(e){n&&n(`update:${l}`,e)}})}}}n.button;const O={...m,...f,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function k(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function B(l,t,a){const n=e.inject(o),i=e.computed((()=>{var e;if(n&&(null==(e=n.defaults.value)?void 0:e[l]))return n.defaults.value[l]}));return e.computed((()=>{if(void 0===i.value)return a;const e=i.value,l=t,n=a;return Object.keys(l).reduce(((t,a)=>{const o=n[a];if(t[a]=o,a in e){if(Array.isArray(l[a])){const n=l[a];if(n.length){n[0]===o&&(t[a]=e[a])}}if("function"==typeof l[a]){(0,l[a])()===o&&(t[a]=e[a])}if("object"==typeof l[a]){let n=l[a].default;"function"==typeof n&&(n=n()),"object"==typeof n?JSON.stringify(n)===JSON.stringify(o)&&(t[a]=e[a]):n===o&&(t[a]=e[a])}}return t}),{})}))}const V=["for"],x=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"];return e.defineComponent({name:"VvCheckbox",props:O,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const n=t,o=e.useSlots(),r=B("VvCheckbox",O,n),{id:u,disabled:d,readonly:s,valid:v,invalid:c,propsSwitch:f,modelValue:p,indeterminate:b,isInGroup:h}=function(l,t){const{group:a,isInGroup:n,getGroupOrLocalRef:o}=L(i),{id:r,switch:u,indeterminate:d}=e.toRefs(l),s=o("modelValue",l,t),v=o("valid",l),c=o("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:n,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(n,a),m=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(u),y=e.computed((()=>`${m.value}-hint`)),S=e.computed((()=>j.value?-1:n.tabindex)),A=e.ref(),$=e.computed((()=>void 0!==n.uncheckedValue&&!h.value)),j=e.computed((()=>d.value||s.value)),w=e.computed((()=>!0===c.value||!0!==v.value&&void 0)),R=e.computed((()=>$.value?p.value===n.value:Array.isArray(p.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(g(e,t))return!0;return!1}(n.value,p.value):g(n.value,p.value))),C=e.computed((()=>!!b.value||!(R.value||!$.value||n.uncheckedValue===p.value))),N=e.computed((()=>{if(!$.value)return!["string","number","boolean"].includes(typeof n.value)||n.value})),I=e.computed({get:()=>R.value,set(e){if($.value)p.value=e?n.value:n.uncheckedValue;else if(Array.isArray(p.value)||h.value){const l=new Set(Array.isArray(p.value)?p.value:void 0!==p.value?[p.value]:[]);e?l.add(n.value):l.delete(n.value),p.value=[...l]}else p.value=e?n.value:void 0;a("change",e)}}),{modifiers:P}=e.toRefs(n),E=function(l,t,a){return e.computed((()=>{const n={[l]:!0},o="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return o&&Array.isArray(o)&&o.forEach((e=>{e&&(n[`${l}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{n[`${l}--${t}`]=e.unref(a.value[t])})),n}))}("vv-checkbox",P,e.computed((()=>({switch:f.value,valid:v.value,invalid:c.value,disabled:d.value,readonly:s.value,indeterminate:b.value}))));e.watchEffect((()=>{$.value&&Array.isArray(p.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>C.value),(e=>{A.value.indeterminate=!!e})),e.onMounted((()=>{C.value&&(A.value.indeterminate=!0)}));const{HintSlot:G,hasHintLabelOrSlot:H,hasInvalidLabelOrSlot:T,hintSlotScope:_}=function(l,t){const a=e.computed((()=>e.isRef(l)?l.value:l)),n=e.computed((()=>k(a.value.invalidLabel))),o=e.computed((()=>k(a.value.validLabel))),i=e.computed((()=>a.value.loadingLabel)),r=e.computed((()=>a.value.hintLabel)),u=e.computed((()=>Boolean(a.value.loading&&(t.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(a.value.invalid&&(t.invalid||n.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(a.value.valid&&(t.valid||o.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(t.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}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:n,validLabel:o,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var l,t,a,n,o,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==(n=(a=this.$slots).invalid)?void 0:n.call(a))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(o=this.$slots).valid)?void 0:i.call(o))??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:p}}(r,o);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(E)),for:e.unref(m)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(m),ref_key:"input",ref:A,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(I)?I.value=l:null),type:"checkbox",class:"vv-checkbox__input",name:l.name,disabled:e.unref(j),value:e.unref(N),tabindex:e.unref(S),"aria-invalid":e.unref(w),"aria-describedby":e.unref(H)?e.unref(y):void 0,"aria-errormessage":e.unref(T)?e.unref(y):void 0},null,8,x),[[e.vModelCheckbox,e.unref(I)]]),e.renderSlot(l.$slots,"default",{value:e.unref(p)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(G),{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(_))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(_))))])),key:"3"}:void 0]),1032,["id"])],10,V))}})}));
|
|
@@ -80,25 +80,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
80
80
|
value: any;
|
|
81
81
|
}): any;
|
|
82
82
|
hint?(_: {
|
|
83
|
-
modelValue:
|
|
83
|
+
modelValue: unknown;
|
|
84
84
|
valid: boolean;
|
|
85
85
|
invalid: boolean;
|
|
86
86
|
loading: boolean;
|
|
87
87
|
}): any;
|
|
88
88
|
loading?(_: {
|
|
89
|
-
modelValue:
|
|
89
|
+
modelValue: unknown;
|
|
90
90
|
valid: boolean;
|
|
91
91
|
invalid: boolean;
|
|
92
92
|
loading: boolean;
|
|
93
93
|
}): any;
|
|
94
94
|
valid?(_: {
|
|
95
|
-
modelValue:
|
|
95
|
+
modelValue: unknown;
|
|
96
96
|
valid: boolean;
|
|
97
97
|
invalid: boolean;
|
|
98
98
|
loading: boolean;
|
|
99
99
|
}): any;
|
|
100
100
|
invalid?(_: {
|
|
101
|
-
modelValue:
|
|
101
|
+
modelValue: unknown;
|
|
102
102
|
valid: boolean;
|
|
103
103
|
invalid: boolean;
|
|
104
104
|
loading: boolean;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { unref, computed, defineComponent, h, inject, toRef, toRefs, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode,
|
|
1
|
+
import { unref, computed, isRef, defineComponent, h, inject, toRef, toRefs, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, 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
4
|
import { get } from "ts-dot-prop";
|
|
5
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
6
|
+
Strategy2["absolute"] = "absolute";
|
|
7
|
+
Strategy2["fixed"] = "fixed";
|
|
8
|
+
return Strategy2;
|
|
9
|
+
})(Strategy || {});
|
|
5
10
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
6
11
|
Side2["left"] = "left";
|
|
7
12
|
Side2["right"] = "right";
|
|
@@ -38,6 +43,7 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
|
38
43
|
AnchorTarget2["_top"] = "_top";
|
|
39
44
|
return AnchorTarget2;
|
|
40
45
|
})(AnchorTarget || {});
|
|
46
|
+
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
41
47
|
const INJECTION_KEY_CHECK_GROUP = Symbol.for("checkGroup");
|
|
42
48
|
function equals(obj1, obj2, field) {
|
|
43
49
|
if (field)
|
|
@@ -130,19 +136,27 @@ function joinLines(items) {
|
|
|
130
136
|
}
|
|
131
137
|
return items;
|
|
132
138
|
}
|
|
133
|
-
function HintSlotFactory(
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
140
|
+
const props = computed(() => {
|
|
141
|
+
if (isRef(propsOrRef)) {
|
|
142
|
+
return propsOrRef.value;
|
|
143
|
+
}
|
|
144
|
+
return propsOrRef;
|
|
145
|
+
});
|
|
146
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
147
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
148
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
149
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
138
150
|
const hasLoadingLabelOrSlot = computed(
|
|
139
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
151
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
140
152
|
);
|
|
141
153
|
const hasInvalidLabelOrSlot = computed(
|
|
142
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
154
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
155
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
156
|
+
)
|
|
143
157
|
);
|
|
144
158
|
const hasValidLabelOrSlot = computed(
|
|
145
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
159
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
146
160
|
);
|
|
147
161
|
const hasHintLabelOrSlot = computed(
|
|
148
162
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -151,10 +165,10 @@ function HintSlotFactory(props, slots) {
|
|
|
151
165
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
152
166
|
);
|
|
153
167
|
const hintSlotScope = computed(() => ({
|
|
154
|
-
modelValue: props.modelValue,
|
|
155
|
-
valid: props.valid,
|
|
156
|
-
invalid: props.invalid,
|
|
157
|
-
loading: props.loading
|
|
168
|
+
modelValue: props.value.modelValue,
|
|
169
|
+
valid: props.value.valid,
|
|
170
|
+
invalid: props.value.invalid,
|
|
171
|
+
loading: props.value.loading
|
|
158
172
|
}));
|
|
159
173
|
const HintSlot = defineComponent({
|
|
160
174
|
name: "HintSlot",
|
|
@@ -390,19 +404,15 @@ const IdProps = {
|
|
|
390
404
|
placement: {
|
|
391
405
|
type: String,
|
|
392
406
|
default: Side.bottom,
|
|
393
|
-
validator: (value) =>
|
|
394
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
395
|
-
}
|
|
407
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
396
408
|
},
|
|
397
409
|
/**
|
|
398
410
|
* Dropdown strategy
|
|
399
411
|
*/
|
|
400
412
|
strategy: {
|
|
401
413
|
type: String,
|
|
402
|
-
default:
|
|
403
|
-
validator: (value) =>
|
|
404
|
-
return ["fixed", "absolute"].includes(value);
|
|
405
|
-
}
|
|
414
|
+
default: void 0,
|
|
415
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
406
416
|
},
|
|
407
417
|
/**
|
|
408
418
|
* Dropdown show / hide transition name
|
|
@@ -545,6 +555,13 @@ const CheckboxRadioGroupProps = {
|
|
|
545
555
|
type: String,
|
|
546
556
|
default: ButtonType.button,
|
|
547
557
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
558
|
+
},
|
|
559
|
+
/**
|
|
560
|
+
* Button aria-label
|
|
561
|
+
*/
|
|
562
|
+
ariaLabel: {
|
|
563
|
+
type: String,
|
|
564
|
+
default: void 0
|
|
548
565
|
}
|
|
549
566
|
});
|
|
550
567
|
function useInjectedGroupState(groupKey) {
|
|
@@ -629,6 +646,62 @@ function useGroupProps(props, emit) {
|
|
|
629
646
|
disabled
|
|
630
647
|
};
|
|
631
648
|
}
|
|
649
|
+
function useVolver() {
|
|
650
|
+
return inject(INJECTION_KEY_VOLVER);
|
|
651
|
+
}
|
|
652
|
+
function useDefaults(componentName, propsDefinition, props) {
|
|
653
|
+
const volver = useVolver();
|
|
654
|
+
const volverComponentDefaults = computed(() => {
|
|
655
|
+
var _a;
|
|
656
|
+
if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
|
|
657
|
+
return void 0;
|
|
658
|
+
}
|
|
659
|
+
return volver.defaults.value[componentName];
|
|
660
|
+
});
|
|
661
|
+
return computed(() => {
|
|
662
|
+
if (volverComponentDefaults.value === void 0) {
|
|
663
|
+
return props;
|
|
664
|
+
}
|
|
665
|
+
const componentDefaults = volverComponentDefaults.value;
|
|
666
|
+
const simplifiedPropsDefinition = propsDefinition;
|
|
667
|
+
const simplifiedProps = props;
|
|
668
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
669
|
+
const propValue = simplifiedProps[key];
|
|
670
|
+
acc[key] = propValue;
|
|
671
|
+
if (key in componentDefaults) {
|
|
672
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
673
|
+
const typeArray = simplifiedPropsDefinition[key];
|
|
674
|
+
if (typeArray.length) {
|
|
675
|
+
const typeFunction = typeArray[0];
|
|
676
|
+
if (typeFunction === propValue) {
|
|
677
|
+
acc[key] = componentDefaults[key];
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
682
|
+
const typeFunction = simplifiedPropsDefinition[key];
|
|
683
|
+
if (typeFunction() === propValue) {
|
|
684
|
+
acc[key] = componentDefaults[key];
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
688
|
+
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
689
|
+
if (typeof defaultValue === "function") {
|
|
690
|
+
defaultValue = defaultValue();
|
|
691
|
+
}
|
|
692
|
+
if (typeof defaultValue === "object") {
|
|
693
|
+
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
694
|
+
acc[key] = componentDefaults[key];
|
|
695
|
+
}
|
|
696
|
+
} else if (defaultValue === propValue) {
|
|
697
|
+
acc[key] = componentDefaults[key];
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return acc;
|
|
702
|
+
}, {});
|
|
703
|
+
});
|
|
704
|
+
}
|
|
632
705
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
633
706
|
function useModifiers(prefix, modifiers, others) {
|
|
634
707
|
return computed(() => {
|
|
@@ -665,6 +738,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
665
738
|
setup(__props, { emit }) {
|
|
666
739
|
const props = __props;
|
|
667
740
|
const slots = useSlots();
|
|
741
|
+
const propsDefaults = useDefaults(
|
|
742
|
+
"VvCheckbox",
|
|
743
|
+
VvCheckboxProps,
|
|
744
|
+
props
|
|
745
|
+
);
|
|
668
746
|
const {
|
|
669
747
|
id,
|
|
670
748
|
disabled,
|
|
@@ -777,7 +855,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
777
855
|
hasHintLabelOrSlot,
|
|
778
856
|
hasInvalidLabelOrSlot,
|
|
779
857
|
hintSlotScope
|
|
780
|
-
} = HintSlotFactory(
|
|
858
|
+
} = HintSlotFactory(propsDefaults, slots);
|
|
781
859
|
return (_ctx, _cache) => {
|
|
782
860
|
return openBlock(), createElementBlock("label", {
|
|
783
861
|
class: normalizeClass(unref(bemCssClasses)),
|
|
@@ -896,6 +974,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
896
974
|
setup(__props, { emit }) {
|
|
897
975
|
const props = __props;
|
|
898
976
|
const slots = useSlots();
|
|
977
|
+
const propsDefaults = useDefaults(
|
|
978
|
+
"VvCheckboxGroup",
|
|
979
|
+
VvCheckboxGroupProps,
|
|
980
|
+
props
|
|
981
|
+
);
|
|
899
982
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
900
983
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
901
984
|
useProvideGroupState({
|
|
@@ -926,7 +1009,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
926
1009
|
value: getOptionValue(option)
|
|
927
1010
|
};
|
|
928
1011
|
};
|
|
929
|
-
const { HintSlot, hintSlotScope } = HintSlotFactory(
|
|
1012
|
+
const { HintSlot, hintSlotScope } = HintSlotFactory(propsDefaults, slots);
|
|
930
1013
|
return (_ctx, _cache) => {
|
|
931
1014
|
return openBlock(), createElementBlock("fieldset", {
|
|
932
1015
|
class: normalizeClass(unref(bemCssClasses))
|
|
@@ -1 +1 @@
|
|
|
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))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("nanoid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core","ts-dot-prop"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=t(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,t,l,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("volver"),u=Symbol.for("checkGroup");function d(e,t,l){return l?v(e,l)===v(t,l):s(e,t)}function s(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(!s(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,v=t instanceof RegExp;if(d!=v)return!1;if(d&&v)return e.toString()==t.toString();const c=Object.keys(e);if(n=c.length,n!==Object.keys(t).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(t,c[o]))return!1;for(o=n;0!=o--;)if(i=c[o],!s(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function v(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{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 null}function c(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function f(t,l){const a=e.computed((()=>e.isRef(t)?t.value:t)),o=e.computed((()=>c(a.value.invalidLabel))),n=e.computed((()=>c(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))),f=e.computed((()=>d.value||s.value||u.value||v.value)),p=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:f,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:p,HintSlot:m}}const p={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},h={disabled:Boolean},g=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},S={modifiers:[String,Array]},k={hintLabel:{type:String,default:""}},L={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 B={tabindex:{type:[String,Number],default:0}},O={id:[String,Number]};o.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const V={...{...O,name:{type:String,required:!0}},...B,...p,...m,...k,...h,...y,...S,...g,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},x={...p,...m,...L,...k,...h,...y,...S,...g,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function $(t){const l=e.inject(t,void 0),a=e.computed((()=>{return t=l,!(null==(a=e.unref(t))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length);var t,a}));return{group:l,isInGroup:a,getGroupOrLocalRef:function(t,a,o){if(null==l?void 0:l.value){const a=e.unref(l.value)[t];return e.computed({get:()=>null==a?void 0:a.value,set(e){a.value=e}})}const n=e.toRef(a,t);return e.computed({get:()=>n.value,set(e){o&&o(`update:${t}`,e)}})}}}i.button;const A={...V,...S,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function C(t,l,a){const o=e.inject(r),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 j(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 w=["for"],R=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],P=e.defineComponent({name:"VvCheckbox",props:A,emits:["click","update:modelValue","change","blur"],setup(l,{emit:a}){const o=l,n=e.useSlots(),i=C("VvCheckbox",A,o),{id:r,disabled:s,readonly:v,valid:c,invalid:p,propsSwitch:m,modelValue:b,indeterminate:h,isInGroup:g}=function(t,l){const{group:a,isInGroup:o,getGroupOrLocalRef:n}=$(u),{id:i,switch:r,indeterminate:d}=e.toRefs(t),s=n("modelValue",t,l),v=n("valid",t),c=n("invalid",t),f=e.computed((()=>{var e;return Boolean(t.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),p=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:i,propsSwitch:r,indeterminate:d,group:a,isInGroup:o,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(o,a),y=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.nanoid()))))(r),S=e.computed((()=>`${y.value}-hint`)),k=e.computed((()=>O.value?-1:o.tabindex)),L=e.ref(),B=e.computed((()=>void 0!==o.uncheckedValue&&!g.value)),O=e.computed((()=>s.value||v.value)),V=e.computed((()=>!0===p.value||!0!==c.value&&void 0)),x=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(d(e,l))return!0;return!1}(o.value,b.value):d(o.value,b.value))),P=e.computed((()=>!!h.value||!(x.value||!B.value||o.uncheckedValue===b.value))),N=e.computed((()=>{if(!B.value)return!["string","number","boolean"].includes(typeof o.value)||o.value})),E=e.computed({get:()=>x.value,set(e){if(B.value)b.value=e?o.value:o.uncheckedValue;else if(Array.isArray(b.value)||g.value){const t=new Set(Array.isArray(b.value)?b.value:void 0!==b.value?[b.value]:[]);e?t.add(o.value):t.delete(o.value),b.value=[...t]}else b.value=e?o.value:void 0;a("change",e)}}),{modifiers:_}=e.toRefs(o),z=j("vv-checkbox",_,e.computed((()=>({switch:m.value,valid:c.value,invalid:p.value,disabled:s.value,readonly:v.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((()=>P.value),(e=>{L.value.indeterminate=!!e})),e.onMounted((()=>{P.value&&(L.value.indeterminate=!0)}));const{HintSlot:G,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:D,hintSlotScope:H}=f(i,n);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(z)),for:e.unref(y)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(y),ref_key:"input",ref:L,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(E)?E.value=t:null),type:"checkbox",class:"vv-checkbox__input",name:t.name,disabled:e.unref(O),value:e.unref(N),tabindex:e.unref(k),"aria-invalid":e.unref(V),"aria-describedby":e.unref(I)?e.unref(S):void 0,"aria-errormessage":e.unref(D)?e.unref(S):void 0},null,8,R),[[e.vModelCheckbox,e.unref(E)]]),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,w))}}),N=x;const E=["textContent"],_={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:N,emits:["update:modelValue","change"],setup(t,{emit:o}){const n=t,i=e.useSlots(),r=C("VvCheckboxGroup",N,n),d=l.useVModel(n,"modelValue",o),{disabled:s,readonly:v,vertical:c,valid:p,invalid:m,modifiers:b}=e.toRefs(n);!function(t){if(Object.keys(t).some((l=>"key"!==l&&!e.isRef(t[l]))))throw Error("One or more groupState props aren't ref.");e.provide(t.key,e.computed((()=>t)))}({key:u,modelValue:d,disabled:s,readonly:v,valid:p,invalid:m});const{getOptionLabel:h,getOptionValue:g}=function(t){const{options:l,labelKey:o,valueKey:n,disabledKey:i}=e.toRefs(t);return{options:l,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),y=j("vv-checkbox-group",b,e.computed((()=>({disabled:s.value,readonly:v.value,horizontal:!c.value,valid:p.value,invalid:m.value})))),{HintSlot:S,hintSlotScope:k}=f(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,E)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(P,e.mergeProps({key:l},((e,t)=>({id:`${n.name}_opt${t}`,name:n.name,label:h(e),value:g(e)}))(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(S),{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(k))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
@@ -97,25 +97,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
97
97
|
}, {}>, {
|
|
98
98
|
default?(_: {}): any;
|
|
99
99
|
hint?(_: {
|
|
100
|
-
modelValue:
|
|
100
|
+
modelValue: unknown;
|
|
101
101
|
valid: boolean;
|
|
102
102
|
invalid: boolean;
|
|
103
103
|
loading: boolean;
|
|
104
104
|
}): any;
|
|
105
105
|
loading?(_: {
|
|
106
|
-
modelValue:
|
|
106
|
+
modelValue: unknown;
|
|
107
107
|
valid: boolean;
|
|
108
108
|
invalid: boolean;
|
|
109
109
|
loading: boolean;
|
|
110
110
|
}): any;
|
|
111
111
|
valid?(_: {
|
|
112
|
-
modelValue:
|
|
112
|
+
modelValue: unknown;
|
|
113
113
|
valid: boolean;
|
|
114
114
|
invalid: boolean;
|
|
115
115
|
loading: boolean;
|
|
116
116
|
}): any;
|
|
117
117
|
invalid?(_: {
|
|
118
|
-
modelValue:
|
|
118
|
+
modelValue: unknown;
|
|
119
119
|
valid: boolean;
|
|
120
120
|
invalid: boolean;
|
|
121
121
|
loading: boolean;
|