@volverjs/ui-vue 0.0.8 → 0.0.9-beta.10
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 +4 -4
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +7 -0
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +7 -0
- package/dist/components/VvAction/VvAction.es.js +9 -1
- 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 +14 -6
- 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 +54 -10
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAvatar/VvAvatar.es.js +7 -0
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +7 -0
- package/dist/components/VvBadge/VvBadge.es.js +7 -0
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +7 -0
- package/dist/components/VvButton/VvButton.es.js +11 -2
- 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 +7 -0
- package/dist/components/VvCard/VvCard.es.js +7 -0
- package/dist/components/VvCheckbox/VvCheckbox.es.js +91 -14
- 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 +97 -15
- 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 +164 -94
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +35 -14
- package/dist/components/VvCombobox/index.d.ts +24 -7
- package/dist/components/VvDialog/VvDialog.es.js +67 -27
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +58 -20
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +13 -12
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +1 -7
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +9 -1
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +7 -0
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +7 -0
- package/dist/components/VvInputText/VvInputText.es.js +87 -14
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +4 -4
- package/dist/components/VvNav/VvNav.es.js +10 -2
- 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 +7 -0
- package/dist/components/VvRadio/VvRadio.es.js +91 -14
- 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 +97 -15
- 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 +87 -14
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +4 -4
- package/dist/components/VvTab/VvTab.es.js +10 -2
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +87 -14
- 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 +7 -0
- package/dist/components/common/HintSlot.d.ts +4 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.es.js +958 -431
- 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 +10 -0
- package/dist/directives/index.es.js +7 -0
- package/dist/directives/v-tooltip.es.js +7 -0
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +7 -0
- package/dist/resolvers/unplugin.es.js +3 -0
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +43 -258
- 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/Nav/Nav.settings.d.ts +3 -21
- package/package.json +54 -46
- 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 +30 -0
- package/src/components/VvAlertGroup/index.ts +11 -1
- 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 +9 -4
- package/src/components/VvCombobox/index.ts +24 -0
- package/src/components/VvDialog/VvDialog.vue +36 -17
- package/src/components/VvDialog/index.ts +13 -1
- package/src/components/VvDropdown/VvDropdown.vue +44 -15
- package/src/components/VvDropdown/index.ts +2 -8
- package/src/components/VvInputText/VvInputText.vue +8 -1
- 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 +8 -1
- 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 +21 -0
- package/src/props/index.ts +7 -0
- 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/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
|
@@ -329,25 +329,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
329
329
|
clear: () => void;
|
|
330
330
|
}): any;
|
|
331
331
|
hint?(_: {
|
|
332
|
-
modelValue:
|
|
332
|
+
modelValue: unknown;
|
|
333
333
|
valid: boolean;
|
|
334
334
|
invalid: boolean;
|
|
335
335
|
loading: boolean;
|
|
336
336
|
}): any;
|
|
337
337
|
loading?(_: {
|
|
338
|
-
modelValue:
|
|
338
|
+
modelValue: unknown;
|
|
339
339
|
valid: boolean;
|
|
340
340
|
invalid: boolean;
|
|
341
341
|
loading: boolean;
|
|
342
342
|
}): any;
|
|
343
343
|
valid?(_: {
|
|
344
|
-
modelValue:
|
|
344
|
+
modelValue: unknown;
|
|
345
345
|
valid: boolean;
|
|
346
346
|
invalid: boolean;
|
|
347
347
|
loading: boolean;
|
|
348
348
|
}): any;
|
|
349
349
|
invalid?(_: {
|
|
350
|
-
modelValue:
|
|
350
|
+
modelValue: unknown;
|
|
351
351
|
valid: boolean;
|
|
352
352
|
invalid: boolean;
|
|
353
353
|
loading: boolean;
|
|
@@ -230,6 +230,13 @@ const ActionProps = {
|
|
|
230
230
|
type: String,
|
|
231
231
|
default: ButtonType.button,
|
|
232
232
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
233
|
+
},
|
|
234
|
+
/**
|
|
235
|
+
* Button aria-label
|
|
236
|
+
*/
|
|
237
|
+
ariaLabel: {
|
|
238
|
+
type: String,
|
|
239
|
+
default: void 0
|
|
233
240
|
}
|
|
234
241
|
};
|
|
235
242
|
const VvNavProps = {
|
|
@@ -297,7 +304,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
297
304
|
const hasProps = computed(() => {
|
|
298
305
|
const toReturn = {
|
|
299
306
|
...dropdownAria == null ? void 0 : dropdownAria.value,
|
|
300
|
-
|
|
307
|
+
ariaPressed: pressed.value ? true : void 0,
|
|
308
|
+
ariaLabel: props.ariaLabel,
|
|
301
309
|
role: role == null ? void 0 : role.value
|
|
302
310
|
};
|
|
303
311
|
switch (hasTag.value) {
|
|
@@ -434,7 +442,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
434
442
|
current: unref(activeItem) == navItem.id,
|
|
435
443
|
disabled: navItem.disabled
|
|
436
444
|
}, "vv-nav__item-label"]
|
|
437
|
-
}, toHandlers(navItem.on
|
|
445
|
+
}, toHandlers(navItem.on), {
|
|
438
446
|
onClick: ($event) => onClick(navItem)
|
|
439
447
|
}), {
|
|
440
448
|
default: withCtx(() => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvNav=t(e.vue)}(this,(function(e){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),o=(e=>(e.before="before",e.after="after",e))(o||{}),
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvNav=t(e.vue)}(this,(function(e){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),o=(e=>(e.before="before",e.after="after",e))(o||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{}),n=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(n||{}),l=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(l||{});const a=Symbol.for("volver"),i=Symbol.for("dropdownTrigger"),s=Symbol.for("dropdownAction"),u={to:{type:[String,Object]},href:String,target:{type:String,validator:e=>Object.values(l).includes(e)},rel:{type:String,default:"noopener noreferrer"}},d={disabled:Boolean},c={active:Boolean},v={pressed:Boolean},f={label:[String,Number]},p={modifiers:[String,Array]};o.before,t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const m={...d,...f,...v,...c,...u,type:{type:String,default:r.button,validator:e=>Object.values(r).includes(e)},ariaLabel:{type:String,default:void 0}},b={...p,items:{type:Array,required:!0,default:()=>[]}},k=m;const y=e.defineComponent({name:"VvAction",props:k,emits:["click","mouseover","mouseleave"],setup(t,{expose:o,emit:r}){const l=t,u=e.inject(a),d=e.ref(null);o({$el:d});const{reference:c,bus:v,aria:f,expanded:p}=e.inject(i,{});e.watch((()=>d.value),(e=>{c&&(c.value=e)}));const m=e.computed((()=>l.pressed||(null==p?void 0:p.value))),{role:b}=e.inject(s,{}),k=e.computed((()=>{switch(!0){case l.disabled:return n.button;case void 0!==l.to:return(null==u?void 0:u.nuxt)?n.nuxtLink:n.routerLink;case void 0!==l.href:return n.a;default:return n.button}})),y=e.computed((()=>{const e={...null==f?void 0:f.value,ariaPressed:!!m.value||void 0,ariaLabel:l.ariaLabel,role:null==b?void 0:b.value};switch(k.value){case n.a:return{...e,href:l.href,target:l.target,rel:l.rel};case n.routerLink:case n.nuxtLink:return{...e,to:l.to,target:l.target};default:return{...e,type:l.type,disabled:l.disabled}}})),g=e=>{l.disabled?e.preventDefault():(null==v||v.emit("click",e),r("click",e))},_=e=>{null==v||v.emit("mouseover",e),r("mouseover",e)},B=e=>{null==v||v.emit("mouseleave",e),r("mouseleave",e)};return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(k)),e.mergeProps(e.unref(y),{ref_key:"element",ref:d,class:{active:t.active,pressed:e.unref(m),disabled:t.disabled},onClickPassive:g,onMouseoverPassive:_,onMouseleavePassive:B}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});const g={class:"vv-nav__menu",role:"menu","aria-busy":"true"};return e.defineComponent({__name:"VvNav",props:b,emits:["click"],setup(t,{emit:o}){const r=t,{modifiers:n,items:l}=e.toRefs(r),a=e.ref(null),i=function(t,o,r){return e.computed((()=>{const n={[t]:!0},l="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(n[`${t}--${e}`]=!0)})),r&&Object.keys(r.value).forEach((o=>{n[`${t}--${o}`]=e.unref(r.value[o])})),n}))}("vv-nav",n),s=e.computed((()=>l.value.map(((e,t)=>({...e,id:e.id||`nav-item_${t}`})))));return(t,r)=>(e.openBlock(),e.createElementBlock("nav",{class:e.normalizeClass(e.unref(i))},[e.createElementVNode("ul",g,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),(t=>(e.openBlock(),e.createElementBlock("li",{key:t.id,class:"vv-nav__item",role:"presentation"},[e.createVNode(y,e.mergeProps({disabled:t.disabled,to:t.to,href:t.href,tabindex:0},{class:[{current:e.unref(a)==t.id,disabled:t.disabled},"vv-nav__item-label"]},e.toHandlers(t.on),{onClick:e=>{var r;(r=t).disabled||(o("click",r),a.value=r.id)}}),{default:e.withCtx((()=>[e.createTextVNode(e.toDisplayString(t.title),1)])),_:2},1040,["class","onClick"])])))),128))])],2))}})}));
|
|
@@ -216,6 +216,13 @@ const ModifiersProps = {
|
|
|
216
216
|
type: String,
|
|
217
217
|
default: ButtonType.button,
|
|
218
218
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
219
|
+
},
|
|
220
|
+
/**
|
|
221
|
+
* Button aria-label
|
|
222
|
+
*/
|
|
223
|
+
ariaLabel: {
|
|
224
|
+
type: String,
|
|
225
|
+
default: void 0
|
|
219
226
|
}
|
|
220
227
|
});
|
|
221
228
|
const VvProgressProps = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unref, inject, computed, toRef, toRefs, defineComponent, h, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode,
|
|
1
|
+
import { unref, inject, computed, toRef, toRefs, isRef, defineComponent, h, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, vModelRadio, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps } from "vue";
|
|
2
2
|
import { nanoid } from "nanoid";
|
|
3
3
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
4
4
|
Side2["left"] = "left";
|
|
@@ -36,6 +36,7 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
|
36
36
|
AnchorTarget2["_top"] = "_top";
|
|
37
37
|
return AnchorTarget2;
|
|
38
38
|
})(AnchorTarget || {});
|
|
39
|
+
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
39
40
|
const INJECTION_KEY_RADIO_GROUP = Symbol.for("radioGroup");
|
|
40
41
|
const LinkProps = {
|
|
41
42
|
/**
|
|
@@ -304,6 +305,13 @@ const CheckboxRadioProps = {
|
|
|
304
305
|
type: String,
|
|
305
306
|
default: ButtonType.button,
|
|
306
307
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
308
|
+
},
|
|
309
|
+
/**
|
|
310
|
+
* Button aria-label
|
|
311
|
+
*/
|
|
312
|
+
ariaLabel: {
|
|
313
|
+
type: String,
|
|
314
|
+
default: void 0
|
|
307
315
|
}
|
|
308
316
|
});
|
|
309
317
|
function equals(obj1, obj2, field) {
|
|
@@ -462,19 +470,27 @@ function joinLines(items) {
|
|
|
462
470
|
}
|
|
463
471
|
return items;
|
|
464
472
|
}
|
|
465
|
-
function HintSlotFactory(
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
473
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
474
|
+
const props = computed(() => {
|
|
475
|
+
if (isRef(propsOrRef)) {
|
|
476
|
+
return propsOrRef.value;
|
|
477
|
+
}
|
|
478
|
+
return propsOrRef;
|
|
479
|
+
});
|
|
480
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
481
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
482
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
483
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
470
484
|
const hasLoadingLabelOrSlot = computed(
|
|
471
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
485
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
472
486
|
);
|
|
473
487
|
const hasInvalidLabelOrSlot = computed(
|
|
474
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
488
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
489
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
490
|
+
)
|
|
475
491
|
);
|
|
476
492
|
const hasValidLabelOrSlot = computed(
|
|
477
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
493
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
478
494
|
);
|
|
479
495
|
const hasHintLabelOrSlot = computed(
|
|
480
496
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -483,10 +499,10 @@ function HintSlotFactory(props, slots) {
|
|
|
483
499
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
484
500
|
);
|
|
485
501
|
const hintSlotScope = computed(() => ({
|
|
486
|
-
modelValue: props.modelValue,
|
|
487
|
-
valid: props.valid,
|
|
488
|
-
invalid: props.invalid,
|
|
489
|
-
loading: props.loading
|
|
502
|
+
modelValue: props.value.modelValue,
|
|
503
|
+
valid: props.value.valid,
|
|
504
|
+
invalid: props.value.invalid,
|
|
505
|
+
loading: props.value.loading
|
|
490
506
|
}));
|
|
491
507
|
const HintSlot = defineComponent({
|
|
492
508
|
name: "HintSlot",
|
|
@@ -566,6 +582,62 @@ function HintSlotFactory(props, slots) {
|
|
|
566
582
|
HintSlot
|
|
567
583
|
};
|
|
568
584
|
}
|
|
585
|
+
function useVolver() {
|
|
586
|
+
return inject(INJECTION_KEY_VOLVER);
|
|
587
|
+
}
|
|
588
|
+
function useDefaults(componentName, propsDefinition, props) {
|
|
589
|
+
const volver = useVolver();
|
|
590
|
+
const volverComponentDefaults = computed(() => {
|
|
591
|
+
var _a;
|
|
592
|
+
if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
|
|
593
|
+
return void 0;
|
|
594
|
+
}
|
|
595
|
+
return volver.defaults.value[componentName];
|
|
596
|
+
});
|
|
597
|
+
return computed(() => {
|
|
598
|
+
if (volverComponentDefaults.value === void 0) {
|
|
599
|
+
return props;
|
|
600
|
+
}
|
|
601
|
+
const componentDefaults = volverComponentDefaults.value;
|
|
602
|
+
const simplifiedPropsDefinition = propsDefinition;
|
|
603
|
+
const simplifiedProps = props;
|
|
604
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
605
|
+
const propValue = simplifiedProps[key];
|
|
606
|
+
acc[key] = propValue;
|
|
607
|
+
if (key in componentDefaults) {
|
|
608
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
609
|
+
const typeArray = simplifiedPropsDefinition[key];
|
|
610
|
+
if (typeArray.length) {
|
|
611
|
+
const typeFunction = typeArray[0];
|
|
612
|
+
if (typeFunction === propValue) {
|
|
613
|
+
acc[key] = componentDefaults[key];
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
618
|
+
const typeFunction = simplifiedPropsDefinition[key];
|
|
619
|
+
if (typeFunction() === propValue) {
|
|
620
|
+
acc[key] = componentDefaults[key];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
624
|
+
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
625
|
+
if (typeof defaultValue === "function") {
|
|
626
|
+
defaultValue = defaultValue();
|
|
627
|
+
}
|
|
628
|
+
if (typeof defaultValue === "object") {
|
|
629
|
+
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
630
|
+
acc[key] = componentDefaults[key];
|
|
631
|
+
}
|
|
632
|
+
} else if (defaultValue === propValue) {
|
|
633
|
+
acc[key] = componentDefaults[key];
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return acc;
|
|
638
|
+
}, {});
|
|
639
|
+
});
|
|
640
|
+
}
|
|
569
641
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
570
642
|
function useModifiers(prefix, modifiers, others) {
|
|
571
643
|
return computed(() => {
|
|
@@ -602,6 +674,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
602
674
|
setup(__props, { emit }) {
|
|
603
675
|
const props = __props;
|
|
604
676
|
const slots = useSlots();
|
|
677
|
+
const propsDefaults = useDefaults(
|
|
678
|
+
"VvRadio",
|
|
679
|
+
VvRadioProps,
|
|
680
|
+
props
|
|
681
|
+
);
|
|
605
682
|
const { id, disabled, readonly, modelValue, valid, invalid } = useGroupProps(props, emit);
|
|
606
683
|
const hasId = useUniqueId(id);
|
|
607
684
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
@@ -652,7 +729,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
652
729
|
hasHintLabelOrSlot,
|
|
653
730
|
hasInvalidLabelOrSlot,
|
|
654
731
|
hintSlotScope
|
|
655
|
-
} = HintSlotFactory(
|
|
732
|
+
} = HintSlotFactory(propsDefaults, slots);
|
|
656
733
|
return (_ctx, _cache) => {
|
|
657
734
|
return openBlock(), createElementBlock("label", {
|
|
658
735
|
class: normalizeClass(unref(bemCssClasses)),
|
|
@@ -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).VvRadio=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("
|
|
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).VvRadio=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("radioGroup"),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]}),f={readonly:Boolean},c={modifiers:[String,Array]},p={hintLabel:{type:String,default:""}};a.before;const b={tabindex:{type:[String,Number],default:0}},m={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const g={...{...m,name:{type:String,required:!0}},...b,...r,...u,...p,...s,...f,...c,...v,...d,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]};function h(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=g;function B(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function $(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"],A=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"];return e.defineComponent({name:"VvRadio",props:O,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const n=t,o=e.useSlots(),r=$("VvRadio",O,n),{id:u,disabled:d,readonly:s,modelValue:v,valid:f,invalid:c}=function(l,t){const{id:a}=e.toRefs(l),{group:n,isInGroup:o,getGroupOrLocalRef:r}=L(i),u=r("modelValue",l,t),d=r("valid",l),s=r("invalid",l),v=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==n?void 0:n.value)?void 0:e.readonly.value))})),f=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==n?void 0:n.value)?void 0:e.disabled.value))}));return{id:a,group:n,isInGroup:o,modelValue:u,valid:d,invalid:s,readonly:v,disabled:f}}(n,a),p=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(u),b=e.computed((()=>`${p.value}-hint`)),m=e.computed((()=>y.value?-1:n.tabindex)),g=e.ref(),y=e.computed((()=>d.value||s.value)),S=e.computed((()=>!0===c.value||!0!==f.value&&void 0)),j=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(h(e,t))return!0;return!1}(n.value,v.value):h(n.value,v.value))),R=e.computed((()=>!["string","number","boolean"].includes(typeof n.value)||n.value)),k=e.computed({get:()=>j.value?R.value:null,set(e){Array.isArray(v.value)?v.value=[n.value]:v.value=n.value,a("change",e)}}),{modifiers:x}=e.toRefs(n),N=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-radio",x,e.computed((()=>({valid:f.value,invalid:c.value,disabled:d.value,readonly:s.value})))),{HintSlot:P,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:C,hintSlotScope:w}=function(l,t){const a=e.computed((()=>e.isRef(l)?l.value:l)),n=e.computed((()=>B(a.value.invalidLabel))),o=e.computed((()=>B(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))),f=e.computed((()=>d.value||s.value||u.value||v.value)),c=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:f,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:c,HintSlot:p}}(r,o);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(N)),for:e.unref(p)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(p),ref_key:"input",ref:g,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(k)?k.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(y),value:e.unref(R),tabindex:e.unref(m),"aria-invalid":e.unref(S),"aria-describedby":e.unref(I)?e.unref(b):void 0,"aria-errormessage":e.unref(C)?e.unref(b):void 0},null,8,A),[[e.vModelRadio,e.unref(k)]]),e.renderSlot(l.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(P),{id:e.unref(b),class:"vv-radio__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"3"}:void 0]),1032,["id"])],10,V))}})}));
|
|
@@ -72,25 +72,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
72
72
|
value: any;
|
|
73
73
|
}): any;
|
|
74
74
|
hint?(_: {
|
|
75
|
-
modelValue:
|
|
75
|
+
modelValue: unknown;
|
|
76
76
|
valid: boolean;
|
|
77
77
|
invalid: boolean;
|
|
78
78
|
loading: boolean;
|
|
79
79
|
}): any;
|
|
80
80
|
loading?(_: {
|
|
81
|
-
modelValue:
|
|
81
|
+
modelValue: unknown;
|
|
82
82
|
valid: boolean;
|
|
83
83
|
invalid: boolean;
|
|
84
84
|
loading: boolean;
|
|
85
85
|
}): any;
|
|
86
86
|
valid?(_: {
|
|
87
|
-
modelValue:
|
|
87
|
+
modelValue: unknown;
|
|
88
88
|
valid: boolean;
|
|
89
89
|
invalid: boolean;
|
|
90
90
|
loading: boolean;
|
|
91
91
|
}): any;
|
|
92
92
|
invalid?(_: {
|
|
93
|
-
modelValue:
|
|
93
|
+
modelValue: unknown;
|
|
94
94
|
valid: boolean;
|
|
95
95
|
invalid: boolean;
|
|
96
96
|
loading: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unref, computed, defineComponent, h, inject, toRef, toRefs, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode,
|
|
1
|
+
import { unref, computed, isRef, defineComponent, h, inject, toRef, toRefs, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, vModelRadio, 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";
|
|
@@ -38,6 +38,7 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
|
38
38
|
AnchorTarget2["_top"] = "_top";
|
|
39
39
|
return AnchorTarget2;
|
|
40
40
|
})(AnchorTarget || {});
|
|
41
|
+
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
41
42
|
const INJECTION_KEY_RADIO_GROUP = Symbol.for("radioGroup");
|
|
42
43
|
function equals(obj1, obj2, field) {
|
|
43
44
|
if (field)
|
|
@@ -130,19 +131,27 @@ function joinLines(items) {
|
|
|
130
131
|
}
|
|
131
132
|
return items;
|
|
132
133
|
}
|
|
133
|
-
function HintSlotFactory(
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
135
|
+
const props = computed(() => {
|
|
136
|
+
if (isRef(propsOrRef)) {
|
|
137
|
+
return propsOrRef.value;
|
|
138
|
+
}
|
|
139
|
+
return propsOrRef;
|
|
140
|
+
});
|
|
141
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
142
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
143
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
144
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
138
145
|
const hasLoadingLabelOrSlot = computed(
|
|
139
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
146
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
140
147
|
);
|
|
141
148
|
const hasInvalidLabelOrSlot = computed(
|
|
142
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
149
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
150
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
151
|
+
)
|
|
143
152
|
);
|
|
144
153
|
const hasValidLabelOrSlot = computed(
|
|
145
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
154
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
146
155
|
);
|
|
147
156
|
const hasHintLabelOrSlot = computed(
|
|
148
157
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -151,10 +160,10 @@ function HintSlotFactory(props, slots) {
|
|
|
151
160
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
152
161
|
);
|
|
153
162
|
const hintSlotScope = computed(() => ({
|
|
154
|
-
modelValue: props.modelValue,
|
|
155
|
-
valid: props.valid,
|
|
156
|
-
invalid: props.invalid,
|
|
157
|
-
loading: props.loading
|
|
163
|
+
modelValue: props.value.modelValue,
|
|
164
|
+
valid: props.value.valid,
|
|
165
|
+
invalid: props.value.invalid,
|
|
166
|
+
loading: props.value.loading
|
|
158
167
|
}));
|
|
159
168
|
const HintSlot = defineComponent({
|
|
160
169
|
name: "HintSlot",
|
|
@@ -545,6 +554,13 @@ const CheckboxRadioGroupProps = {
|
|
|
545
554
|
type: String,
|
|
546
555
|
default: ButtonType.button,
|
|
547
556
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
557
|
+
},
|
|
558
|
+
/**
|
|
559
|
+
* Button aria-label
|
|
560
|
+
*/
|
|
561
|
+
ariaLabel: {
|
|
562
|
+
type: String,
|
|
563
|
+
default: void 0
|
|
548
564
|
}
|
|
549
565
|
});
|
|
550
566
|
function useInjectedGroupState(groupKey) {
|
|
@@ -612,6 +628,62 @@ function useGroupProps(props, emit) {
|
|
|
612
628
|
disabled
|
|
613
629
|
};
|
|
614
630
|
}
|
|
631
|
+
function useVolver() {
|
|
632
|
+
return inject(INJECTION_KEY_VOLVER);
|
|
633
|
+
}
|
|
634
|
+
function useDefaults(componentName, propsDefinition, props) {
|
|
635
|
+
const volver = useVolver();
|
|
636
|
+
const volverComponentDefaults = computed(() => {
|
|
637
|
+
var _a;
|
|
638
|
+
if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
|
|
639
|
+
return void 0;
|
|
640
|
+
}
|
|
641
|
+
return volver.defaults.value[componentName];
|
|
642
|
+
});
|
|
643
|
+
return computed(() => {
|
|
644
|
+
if (volverComponentDefaults.value === void 0) {
|
|
645
|
+
return props;
|
|
646
|
+
}
|
|
647
|
+
const componentDefaults = volverComponentDefaults.value;
|
|
648
|
+
const simplifiedPropsDefinition = propsDefinition;
|
|
649
|
+
const simplifiedProps = props;
|
|
650
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
651
|
+
const propValue = simplifiedProps[key];
|
|
652
|
+
acc[key] = propValue;
|
|
653
|
+
if (key in componentDefaults) {
|
|
654
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
655
|
+
const typeArray = simplifiedPropsDefinition[key];
|
|
656
|
+
if (typeArray.length) {
|
|
657
|
+
const typeFunction = typeArray[0];
|
|
658
|
+
if (typeFunction === propValue) {
|
|
659
|
+
acc[key] = componentDefaults[key];
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
664
|
+
const typeFunction = simplifiedPropsDefinition[key];
|
|
665
|
+
if (typeFunction() === propValue) {
|
|
666
|
+
acc[key] = componentDefaults[key];
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
670
|
+
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
671
|
+
if (typeof defaultValue === "function") {
|
|
672
|
+
defaultValue = defaultValue();
|
|
673
|
+
}
|
|
674
|
+
if (typeof defaultValue === "object") {
|
|
675
|
+
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
676
|
+
acc[key] = componentDefaults[key];
|
|
677
|
+
}
|
|
678
|
+
} else if (defaultValue === propValue) {
|
|
679
|
+
acc[key] = componentDefaults[key];
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return acc;
|
|
684
|
+
}, {});
|
|
685
|
+
});
|
|
686
|
+
}
|
|
615
687
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
616
688
|
function useModifiers(prefix, modifiers, others) {
|
|
617
689
|
return computed(() => {
|
|
@@ -648,6 +720,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
648
720
|
setup(__props, { emit }) {
|
|
649
721
|
const props = __props;
|
|
650
722
|
const slots = useSlots();
|
|
723
|
+
const propsDefaults = useDefaults(
|
|
724
|
+
"VvRadio",
|
|
725
|
+
VvRadioProps,
|
|
726
|
+
props
|
|
727
|
+
);
|
|
651
728
|
const { id, disabled, readonly, modelValue, valid, invalid } = useGroupProps(props, emit);
|
|
652
729
|
const hasId = useUniqueId(id);
|
|
653
730
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
@@ -698,7 +775,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
698
775
|
hasHintLabelOrSlot,
|
|
699
776
|
hasInvalidLabelOrSlot,
|
|
700
777
|
hintSlotScope
|
|
701
|
-
} = HintSlotFactory(
|
|
778
|
+
} = HintSlotFactory(propsDefaults, slots);
|
|
702
779
|
return (_ctx, _cache) => {
|
|
703
780
|
return openBlock(), createElementBlock("label", {
|
|
704
781
|
class: normalizeClass(unref(bemCssClasses)),
|
|
@@ -817,6 +894,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
817
894
|
setup(__props, { emit }) {
|
|
818
895
|
const props = __props;
|
|
819
896
|
const slots = useSlots();
|
|
897
|
+
const propsDefaults = useDefaults(
|
|
898
|
+
"VvRadioGroup",
|
|
899
|
+
VvRadioGroupProps,
|
|
900
|
+
props
|
|
901
|
+
);
|
|
820
902
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
821
903
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
822
904
|
useProvideGroupState({
|
|
@@ -847,7 +929,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
847
929
|
value: getOptionValue(option)
|
|
848
930
|
};
|
|
849
931
|
};
|
|
850
|
-
const { HintSlot, hintSlotScope } = HintSlotFactory(
|
|
932
|
+
const { HintSlot, hintSlotScope } = HintSlotFactory(propsDefaults, slots);
|
|
851
933
|
return (_ctx, _cache) => {
|
|
852
934
|
return openBlock(), createElementBlock("fieldset", {
|
|
853
935
|
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).VvRadioGroup=l(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,l,t,o){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),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("radioGroup");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),o=Array.isArray(l);let a,n,i;if(t&&o){if(n=e.length,n!=l.length)return!1;for(a=n;0!=a--;)if(!d(e[a],l[a]))return!1;return!0}if(t!=o)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(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(l,c[a]))return!1;for(a=n;0!=a--;)if(i=c[a],!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 o=e;for(let l=0,a=t.length;l<a;++l){if(null==e)return null;o=o[t[l]]}return o}}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 o=e.computed((()=>v(l.invalidLabel))),a=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||o.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(t.valid||a.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:o,validLabel:a,loadingLabel:n,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:s}),render(){var l,t,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==(t=(l=this.$slots).loading)?void 0:t.call(l))??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: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},g=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},h={modifiers:[String,Array]},S={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]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const k={...{...O,name:{type:String,required:!0}},...B,...f,...p,...S,...b,...y,...h,...g,...m,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},$={...f,...p,...L,...S,...b,...y,...h,...g,...m,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function V(l){const t=e.inject(l,void 0),o=e.computed((()=>{return l=t,!(null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var l,o}));return{group:t,isInGroup:o,getGroupOrLocalRef:function(l,o,a){if(null==t?void 0:t.value){const o=e.unref(t.value)[l];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,l);return e.computed({get:()=>n.value,set(e){a&&a(`update:${l}`,e)}})}}}i.button;const R=k;function x(l,t,o){return e.computed((()=>{const a={[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&&(a[`${l}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((t=>{a[`${l}--${t}`]=e.unref(o.value[t])})),a}))}const A=["for"],P=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],j=e.defineComponent({name:"VvRadio",props:R,emits:["click","update:modelValue","change","blur"],setup(t,{emit:o}){const a=t,n=e.useSlots(),{id:i,disabled:d,readonly:s,modelValue:v,valid:f,invalid:p}=function(l,t){const{id:o}=e.toRefs(l),{group:a,isInGroup:n,getGroupOrLocalRef:i}=V(r),u=i("modelValue",l,t),d=i("valid",l),s=i("invalid",l),v=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),c=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:o,group:a,isInGroup:n,modelValue:u,valid:d,invalid:s,readonly:v,disabled:c}}(a,o),m=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(i),b=e.computed((()=>`${m.value}-hint`)),g=e.computed((()=>h.value?-1:a.tabindex)),y=e.ref(),h=e.computed((()=>d.value||s.value)),S=e.computed((()=>!0===p.value||!0!==f.value&&void 0)),L=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(u(e,t))return!0;return!1}(a.value,v.value):u(a.value,v.value))),B=e.computed((()=>!["string","number","boolean"].includes(typeof a.value)||a.value)),O=e.computed({get:()=>L.value?B.value:null,set(e){Array.isArray(v.value)?v.value=[a.value]:v.value=a.value,o("change",e)}}),{modifiers:k}=e.toRefs(a),$=x("vv-radio",k,e.computed((()=>({valid:f.value,invalid:p.value,disabled:d.value,readonly:s.value})))),{HintSlot:R,hasHintLabelOrSlot:j,hasInvalidLabelOrSlot:C,hintSlotScope:w}=c(a,n);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref($)),for:e.unref(m)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(m),ref_key:"input",ref:y,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(O)?O.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(h),value:e.unref(B),tabindex:e.unref(g),"aria-invalid":e.unref(S),"aria-describedby":e.unref(j)?e.unref(b):void 0,"aria-errormessage":e.unref(C)?e.unref(b):void 0},null,8,P),[[e.vModelRadio,e.unref(O)]]),e.renderSlot(l.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(R),{id:e.unref(b),class:"vv-radio__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"3"}:void 0]),1032,["id"])],10,A))}}),C=$;const w=["textContent"],N={class:"vv-radio-group__wrapper"};return e.defineComponent({name:"VvRadioGroup",props:C,emits:["update:modelValue","change"],setup(l,{emit:a}){const n=l,i=e.useSlots(),u=t.useVModel(n,"modelValue",a),{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:g}=function(l){const{options:t,labelKey:a,valueKey:n,disabledKey:i}=e.toRefs(l);return{options:t,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof a.value?a.value(e):o.get(e,a.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):o.get(e,n.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):o.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(n),y=x("vv-radio-group",m,e.computed((()=>({disabled:d.value,readonly:s.value,horizontal:!v.value,valid:f.value,invalid:p.value})))),{HintSlot:h,hintSlotScope:S}=c(n,i);return(l,t)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,w)):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(j,e.mergeProps({key:t},((e,l)=>({id:`${n.name}_opt${l}`,name:n.name,label:b(e),value:g(e)}))(l,t)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(h),{class:"vv-radio-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).VvRadioGroup=t(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,t,l,o){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),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("radioGroup");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),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(!s(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,v=t instanceof RegExp;if(d!=v)return!1;if(d&&v)return e.toString()==t.toString();const f=Object.keys(e);if(n=f.length,n!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,f[a]))return!1;for(a=n;0!=a--;)if(i=f[a],!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 o=e;for(let t=0,a=l.length;t<a;++t){if(null==e)return null;o=o[l[t]]}return o}}return null}function f(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function c(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>f(o.value.invalidLabel))),n=e.computed((()=>f(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)),p=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:p,HintSlot:m}}const p={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},y=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},S={modifiers:[String,Array]},L={hintLabel:{type:String,default:""}},O={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}},k={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const V={...{...k,name:{type:String,required:!0}},...B,...p,...m,...L,...g,...h,...S,...y,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},$={...p,...m,...O,...L,...g,...h,...S,...y,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function R(t){const l=e.inject(t,void 0),o=e.computed((()=>{return t=l,!(null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var t,o}));return{group:l,isInGroup:o,getGroupOrLocalRef:function(t,o,a){if(null==l?void 0:l.value){const o=e.unref(l.value)[t];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,t);return e.computed({get:()=>n.value,set(e){a&&a(`update:${t}`,e)}})}}}i.button;const j=V;function A(t,l,o){const a=e.inject(r),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 x(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 P=["for"],C=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],N=e.defineComponent({name:"VvRadio",props:j,emits:["click","update:modelValue","change","blur"],setup(l,{emit:o}){const a=l,n=e.useSlots(),i=A("VvRadio",j,a),{id:r,disabled:s,readonly:v,modelValue:f,valid:p,invalid:m}=function(t,l){const{id:o}=e.toRefs(t),{group:a,isInGroup:n,getGroupOrLocalRef:i}=R(u),r=i("modelValue",t,l),d=i("valid",t),s=i("invalid",t),v=e.computed((()=>{var e;return Boolean(t.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),f=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:o,group:a,isInGroup:n,modelValue:r,valid:d,invalid:s,readonly:v,disabled:f}}(a,o),b=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.nanoid()))))(r),g=e.computed((()=>`${b.value}-hint`)),y=e.computed((()=>S.value?-1:a.tabindex)),h=e.ref(),S=e.computed((()=>s.value||v.value)),L=e.computed((()=>!0===m.value||!0!==p.value&&void 0)),O=e.computed((()=>Array.isArray(f.value)?function(e,t){if(null!=e&&t&&t.length)for(const l of t)if(d(e,l))return!0;return!1}(a.value,f.value):d(a.value,f.value))),B=e.computed((()=>!["string","number","boolean"].includes(typeof a.value)||a.value)),k=e.computed({get:()=>O.value?B.value:null,set(e){Array.isArray(f.value)?f.value=[a.value]:f.value=a.value,o("change",e)}}),{modifiers:V}=e.toRefs(a),$=x("vv-radio",V,e.computed((()=>({valid:p.value,invalid:m.value,disabled:s.value,readonly:v.value})))),{HintSlot:N,hasHintLabelOrSlot:w,hasInvalidLabelOrSlot:_,hintSlotScope:z}=c(i,n);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref($)),for:e.unref(b)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(b),ref_key:"input",ref:h,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(k)?k.value=t:null),type:"radio",class:"vv-radio__input",name:t.name,disabled:e.unref(S),value:e.unref(B),tabindex:e.unref(y),"aria-invalid":e.unref(L),"aria-describedby":e.unref(w)?e.unref(g):void 0,"aria-errormessage":e.unref(_)?e.unref(g):void 0},null,8,C),[[e.vModelRadio,e.unref(k)]]),e.renderSlot(t.$slots,"default",{value:e.unref(f)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(N),{id:e.unref(g),class:"vv-radio__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"3"}:void 0]),1032,["id"])],10,P))}}),w=$;const _=["textContent"],z={class:"vv-radio-group__wrapper"};return e.defineComponent({name:"VvRadioGroup",props:w,emits:["update:modelValue","change"],setup(t,{emit:a}){const n=t,i=e.useSlots(),r=A("VvRadioGroup",w,n),d=l.useVModel(n,"modelValue",a),{disabled:s,readonly:v,vertical:f,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:g,getOptionValue:y}=function(t){const{options:l,labelKey:a,valueKey:n,disabledKey:i}=e.toRefs(t);return{options:l,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof a.value?a.value(e):o.get(e,a.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):o.get(e,n.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):o.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(n),h=x("vv-radio-group",b,e.computed((()=>({disabled:s.value,readonly:v.value,horizontal:!f.value,valid:p.value,invalid:m.value})))),{HintSlot:S,hintSlotScope:L}=c(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(h))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,_)):e.createCommentVNode("",!0),e.createElementVNode("div",z,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(N,e.mergeProps({key:l},((e,t)=>({id:`${n.name}_opt${t}`,name:n.name,label:g(e),value:y(e)}))(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(S),{class:"vv-radio-group__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),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;
|