@volverjs/ui-vue 0.0.6-beta.5 → 0.0.6-beta.7

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.
Files changed (70) hide show
  1. package/auto-imports.d.ts +9 -0
  2. package/dist/Volver.d.ts +1 -1
  3. package/dist/components/VvAccordion/index.d.ts +1 -1
  4. package/dist/components/VvButton/VvButton.es.js +25 -19
  5. package/dist/components/VvButton/VvButton.umd.js +1 -1
  6. package/dist/components/VvCheckbox/VvCheckbox.es.js +151 -98
  7. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  8. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +37 -1
  9. package/dist/components/VvCheckbox/index.d.ts +6 -1
  10. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +187 -101
  11. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  12. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +36 -0
  13. package/dist/components/VvCheckboxGroup/index.d.ts +5 -0
  14. package/dist/components/VvCombobox/VvCombobox.es.js +236 -140
  15. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  16. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +25 -1
  17. package/dist/components/VvDialog/VvDialog.es.js +25 -19
  18. package/dist/components/VvDialog/VvDialog.umd.js +1 -1
  19. package/dist/components/VvDropdown/VvDropdown.es.js +19 -4
  20. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  21. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +8 -4
  22. package/dist/components/VvDropdown/index.d.ts +1 -1
  23. package/dist/components/VvIcon/VvIcon.es.js +25 -19
  24. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  25. package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
  26. package/dist/components/VvIcon/index.d.ts +2 -2
  27. package/dist/components/VvInputText/VvInputText.es.js +160 -136
  28. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  29. package/dist/components/VvInputText/VvInputText.vue.d.ts +24 -0
  30. package/dist/components/VvRadio/VvRadio.es.js +151 -98
  31. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  32. package/dist/components/VvRadio/VvRadio.vue.d.ts +37 -1
  33. package/dist/components/VvRadio/index.d.ts +6 -1
  34. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +187 -101
  35. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  36. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +36 -0
  37. package/dist/components/VvRadioGroup/index.d.ts +5 -0
  38. package/dist/components/VvSelect/VvSelect.es.js +163 -137
  39. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  40. package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -0
  41. package/dist/components/VvTextarea/VvTextarea.es.js +160 -136
  42. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  43. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +24 -0
  44. package/dist/components/common/HintSlot.d.ts +38 -12
  45. package/dist/components/index.es.js +466 -168
  46. package/dist/components/index.umd.js +1 -1
  47. package/dist/composables/group/useInjectedGroupState.d.ts +1 -1
  48. package/dist/composables/useOptions.d.ts +2 -2
  49. package/dist/directives/index.d.ts +2 -2
  50. package/dist/icons.es.js +3 -3
  51. package/dist/icons.umd.js +1 -1
  52. package/dist/props/index.d.ts +22 -0
  53. package/package.json +33 -33
  54. package/src/assets/icons/detailed.json +1 -1
  55. package/src/assets/icons/normal.json +1 -1
  56. package/src/assets/icons/simple.json +1 -1
  57. package/src/components/VvCheckbox/VvCheckbox.vue +23 -2
  58. package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +15 -2
  59. package/src/components/VvCombobox/VvCombobox.vue +40 -16
  60. package/src/components/VvDropdown/VvDropdown.vue +20 -2
  61. package/src/components/VvIcon/VvIcon.vue +37 -34
  62. package/src/components/VvIcon/index.ts +2 -2
  63. package/src/components/VvInputText/VvInputText.vue +26 -9
  64. package/src/components/VvRadio/VvRadio.vue +23 -2
  65. package/src/components/VvRadioGroup/VvRadioGroup.vue +15 -2
  66. package/src/components/VvSelect/VvSelect.vue +26 -9
  67. package/src/components/VvTextarea/VvTextarea.vue +26 -9
  68. package/src/components/common/HintSlot.ts +129 -170
  69. package/src/composables/useOptions.ts +9 -7
  70. package/src/props/index.ts +2 -0
@@ -1,5 +1,4 @@
1
- import { unref, inject, computed, toRef, toRefs, h, defineComponent, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, isRef, vModelRadio, renderSlot, createTextVNode, toDisplayString, createVNode } from "vue";
2
- import { toReactive } from "@vueuse/core";
1
+ import { unref, inject, computed, toRef, toRefs, defineComponent, h, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, isRef, vModelRadio, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps } from "vue";
3
2
  import { nanoid } from "nanoid";
4
3
  var Side = /* @__PURE__ */ ((Side2) => {
5
4
  Side2["left"] = "left";
@@ -85,6 +84,19 @@ const InvalidProps = {
85
84
  */
86
85
  invalidLabel: [String, Array]
87
86
  };
87
+ const LoadingProps = {
88
+ /**
89
+ * Loading status
90
+ */
91
+ loading: Boolean,
92
+ /**
93
+ * Loading label
94
+ */
95
+ loadingLabel: {
96
+ type: String,
97
+ default: "Loading..."
98
+ }
99
+ };
88
100
  const DisabledProps = {
89
101
  /**
90
102
  * Whether the form control is disabled
@@ -268,6 +280,7 @@ const CheckboxRadioProps = {
268
280
  ...ReadonlyProps,
269
281
  ...ModifiersProps,
270
282
  ...LabelProps,
283
+ ...LoadingProps,
271
284
  /**
272
285
  * Input value
273
286
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
@@ -443,111 +456,114 @@ function useGroupProps(props, emit) {
443
456
  disabled
444
457
  };
445
458
  }
446
- function joinLines(errors) {
447
- if (Array.isArray(errors)) {
448
- return errors.filter((e) => isString(e)).join(" ");
459
+ function joinLines(items) {
460
+ if (Array.isArray(items)) {
461
+ return items.filter((item) => isString(item)).join(" ");
449
462
  }
450
- return errors;
463
+ return items;
451
464
  }
452
- function HintSlotFactory(parentProps, parentSlots) {
453
- const {
454
- invalid: invalidSlot,
455
- valid: validSlot,
456
- hint: hintSlot,
457
- loading: loadingSlot
458
- } = parentSlots;
459
- const {
460
- hintLabel,
461
- modelValue,
462
- valid,
463
- validLabel,
464
- invalid,
465
- invalidLabel,
466
- ...otherProps
467
- } = toRefs(parentProps);
468
- const loading = resolveFieldData(otherProps, "loading");
469
- const loadingLabel = resolveFieldData(otherProps, "loadingLabel");
470
- const hasInvalid = computed(() => {
471
- if (!invalid.value) {
472
- return false;
473
- }
474
- if (invalid.value && invalidSlot) {
475
- return true;
476
- }
477
- if ((invalidLabel == null ? void 0 : invalidLabel.value) && Array.isArray(invalidLabel.value) && invalidLabel.value.length > 0) {
478
- return true;
479
- }
480
- if ((invalidLabel == null ? void 0 : invalidLabel.value) && !isEmpty(invalidLabel)) {
481
- return true;
482
- }
483
- return false;
484
- });
485
- const hasHint = computed(
486
- () => !!(hintLabel && hintLabel.value || hintSlot)
465
+ function HintSlotFactory(props, slots) {
466
+ const invalidLabel = computed(() => joinLines(props.invalidLabel));
467
+ const validLabel = computed(() => joinLines(props.validLabel));
468
+ const loadingLabel = computed(() => props.loadingLabel);
469
+ const hintLabel = computed(() => props.hintLabel);
470
+ const hasLoadingLabelOrSlot = computed(
471
+ () => Boolean(props.loading && (slots.loading || loadingLabel.value))
472
+ );
473
+ const hasInvalidLabelOrSlot = computed(
474
+ () => !hasLoadingLabelOrSlot.value && Boolean(props.invalid && (slots.invalid || invalidLabel.value))
487
475
  );
488
- const hasValid = computed(
489
- () => !!(validLabel && validLabel.value || validSlot)
476
+ const hasValidLabelOrSlot = computed(
477
+ () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
490
478
  );
491
- const hasLoading = computed(
492
- () => !!((loading == null ? void 0 : loading.value) && loadingSlot || (loading == null ? void 0 : loading.value) && (loadingLabel == null ? void 0 : loadingLabel.value))
479
+ const hasHintLabelOrSlot = computed(
480
+ () => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
493
481
  );
494
482
  const isVisible = computed(
495
- () => hasHint.value || hasValid.value || hasInvalid.value || hasLoading.value
483
+ () => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
496
484
  );
497
- return {
498
- hasInvalid,
499
- hasHint,
500
- hasValid,
501
- hasLoading,
502
- HintSlot: {
503
- name: "HintSlot",
504
- props: {
505
- params: {
506
- type: Object,
507
- default: () => ({})
485
+ const hintSlotScope = computed(() => ({
486
+ modelValue: props.modelValue,
487
+ valid: props.valid,
488
+ invalid: props.invalid,
489
+ loading: props.loading
490
+ }));
491
+ const HintSlot = defineComponent({
492
+ name: "HintSlot",
493
+ props: {
494
+ tag: {
495
+ type: String,
496
+ default: "small"
497
+ }
498
+ },
499
+ setup() {
500
+ return {
501
+ isVisible,
502
+ invalidLabel,
503
+ validLabel,
504
+ loadingLabel,
505
+ hintLabel,
506
+ hasInvalidLabelOrSlot,
507
+ hasValidLabelOrSlot,
508
+ hasLoadingLabelOrSlot,
509
+ hasHintLabelOrSlot
510
+ };
511
+ },
512
+ render() {
513
+ var _a, _b, _c, _d, _e, _f, _g, _h;
514
+ if (this.isVisible) {
515
+ let role;
516
+ if (this.hasInvalidLabelOrSlot) {
517
+ role = "alert";
508
518
  }
509
- },
510
- setup(props) {
511
- const hintContent = computed(() => {
512
- const slotProps = toReactive({
513
- hintLabel,
514
- modelValue,
515
- valid,
516
- validLabel,
517
- invalid,
518
- invalidLabel,
519
- loading,
520
- loadingLabel,
521
- ...props.params
522
- });
523
- if (invalid == null ? void 0 : invalid.value) {
524
- return (invalidSlot == null ? void 0 : invalidSlot(slotProps)) || joinLines(invalidLabel == null ? void 0 : invalidLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
525
- }
526
- if (valid == null ? void 0 : valid.value)
527
- return (validSlot == null ? void 0 : validSlot(slotProps)) || joinLines(validLabel == null ? void 0 : validLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
528
- if (loading == null ? void 0 : loading.value)
529
- return (loadingSlot == null ? void 0 : loadingSlot(slotProps)) || joinLines(loadingLabel == null ? void 0 : loadingLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
530
- return (hintSlot == null ? void 0 : hintSlot(slotProps)) || joinLines(hintLabel == null ? void 0 : hintLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
531
- });
532
- return {
533
- isVisible,
534
- hasInvalid,
535
- hasValid,
536
- hintContent
537
- };
538
- },
539
- render() {
540
- if (this.isVisible) {
519
+ if (this.hasValidLabelOrSlot) {
520
+ role = "status";
521
+ }
522
+ if (this.hasLoadingLabelOrSlot) {
541
523
  return h(
542
- "small",
524
+ this.tag,
543
525
  {
544
- role: this.hasInvalid ? "alert" : this.hasValid ? "status" : void 0
526
+ role
545
527
  },
546
- this.hintContent
528
+ ((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
547
529
  );
548
530
  }
531
+ if (this.hasInvalidLabelOrSlot) {
532
+ return h(
533
+ this.tag,
534
+ {
535
+ role
536
+ },
537
+ ((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
538
+ );
539
+ }
540
+ if (this.hasValidLabelOrSlot) {
541
+ return h(
542
+ this.tag,
543
+ {
544
+ role
545
+ },
546
+ ((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
547
+ );
548
+ }
549
+ return h(
550
+ this.tag,
551
+ {
552
+ role
553
+ },
554
+ ((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
555
+ );
549
556
  }
557
+ return null;
550
558
  }
559
+ });
560
+ return {
561
+ hasInvalidLabelOrSlot,
562
+ hasHintLabelOrSlot,
563
+ hasValidLabelOrSlot,
564
+ hasLoadingLabelOrSlot,
565
+ hintSlotScope,
566
+ HintSlot
551
567
  };
552
568
  }
553
569
  const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
@@ -575,7 +591,7 @@ function useModifiers(prefix, modifiers, others) {
575
591
  });
576
592
  }
577
593
  const _hoisted_1 = ["for"];
578
- const _hoisted_2 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid"];
594
+ const _hoisted_2 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid", "aria-describedby", "aria-errormessage"];
579
595
  const __default__ = {
580
596
  name: "VvRadio"
581
597
  };
@@ -588,6 +604,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
588
604
  const slots = useSlots();
589
605
  const { id, disabled, readonly, modelValue, valid, invalid } = useGroupProps(props, emit);
590
606
  const hasId = useUniqueId(id);
607
+ const hasHintId = computed(() => `${hasId.value}-hint`);
591
608
  const tabindex = computed(() => isDisabled.value ? -1 : props.tabindex);
592
609
  const input = ref();
593
610
  const isDisabled = computed(() => disabled.value || readonly.value);
@@ -630,7 +647,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
630
647
  readonly: readonly.value
631
648
  }))
632
649
  );
633
- const { HintSlot } = HintSlotFactory(props, slots);
650
+ const {
651
+ HintSlot,
652
+ hasHintLabelOrSlot,
653
+ hasInvalidLabelOrSlot,
654
+ hintSlotScope
655
+ } = HintSlotFactory(props, slots);
634
656
  return (_ctx, _cache) => {
635
657
  return openBlock(), createElementBlock("label", {
636
658
  class: normalizeClass(unref(bemCssClasses)),
@@ -647,7 +669,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
647
669
  disabled: unref(isDisabled),
648
670
  value: unref(hasValue),
649
671
  tabindex: unref(tabindex),
650
- "aria-invalid": unref(isInvalid)
672
+ "aria-invalid": unref(isInvalid),
673
+ "aria-describedby": unref(hasHintLabelOrSlot) ? unref(hasHintId) : void 0,
674
+ "aria-errormessage": unref(hasInvalidLabelOrSlot) ? unref(hasHintId) : void 0
651
675
  }, null, 8, _hoisted_2), [
652
676
  [vModelRadio, unref(localModelValue)]
653
677
  ]),
@@ -655,9 +679,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
655
679
  createTextVNode(toDisplayString(_ctx.label), 1)
656
680
  ]),
657
681
  createVNode(unref(HintSlot), {
658
- class: "vv-radio__hint",
659
- params: { value: unref(modelValue) }
660
- }, null, 8, ["params"])
682
+ id: unref(hasHintId),
683
+ class: "vv-radio__hint"
684
+ }, createSlots({ _: 2 }, [
685
+ _ctx.$slots.hint ? {
686
+ name: "hint",
687
+ fn: withCtx(() => [
688
+ renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
689
+ ]),
690
+ key: "0"
691
+ } : void 0,
692
+ _ctx.$slots.loading ? {
693
+ name: "loading",
694
+ fn: withCtx(() => [
695
+ renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
696
+ ]),
697
+ key: "1"
698
+ } : void 0,
699
+ _ctx.$slots.valid ? {
700
+ name: "valid",
701
+ fn: withCtx(() => [
702
+ renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
703
+ ]),
704
+ key: "2"
705
+ } : void 0,
706
+ _ctx.$slots.invalid ? {
707
+ name: "invalid",
708
+ fn: withCtx(() => [
709
+ renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
710
+ ]),
711
+ key: "3"
712
+ } : void 0
713
+ ]), 1032, ["id"])
661
714
  ], 10, _hoisted_1);
662
715
  };
663
716
  }
@@ -1 +1 @@
1
- !function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadio=l(e.vue,e.core,e.nanoid)}(this,(function(e,l,n){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),t=(e=>(e.before="before",e.after="after",e))(t||{}),o=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(o||{});const u=Symbol.for("radioGroup"),i={valid:Boolean,validLabel:[String,Array]},r={invalid:Boolean,invalidLabel:[String,Array]},d={disabled:Boolean},v=(Boolean,Boolean,{label:[String,Number]}),s={readonly:Boolean},f={modifiers:[String,Array]},c={hintLabel:{type:String,default:""}};t.before;const p={tabindex:{type:[String,Number],default:0}},m={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const b={...{...m,name:{type:String,required:!0}},...p,...i,...r,...c,...d,...s,...f,...v,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]};function g(e,l,n){return n?h(e,n)===h(l,n):y(e,l)}function y(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const n=Array.isArray(e),a=Array.isArray(l);let t,o,u;if(n&&a){if(o=e.length,o!=l.length)return!1;for(t=o;0!=t--;)if(!y(e[t],l[t]))return!1;return!0}if(n!=a)return!1;const i=e instanceof Date,r=l instanceof Date;if(i!=r)return!1;if(i&&r)return e.getTime()==l.getTime();const d=e instanceof RegExp,v=l instanceof RegExp;if(d!=v)return!1;if(d&&v)return e.toString()==l.toString();const s=Object.keys(e);if(o=s.length,o!==Object.keys(l).length)return!1;for(t=o;0!=t--;)if(!Object.prototype.hasOwnProperty.call(l,s[t]))return!1;for(t=o;0!=t--;)if(u=s[t],!y(e[u],l[u]))return!1;return!0}return e!=e&&l!=l}function h(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const n=l.split(".");let a=e;for(let l=0,t=n.length;l<t;++l){if(null==e)return null;a=a[n[l]]}return a}}return null}function S(l){return null==(n=e.unref(l))||""===n||Array.isArray(n)&&0===n.length||!(n instanceof Date)&&"object"==typeof n&&0===Object.keys(n).length;var n}o.button;const B=b;function A(l,n){const{id:a}=e.toRefs(l),{group:t,isInGroup:o,getGroupOrLocalRef:i}=function(l){const n=e.inject(l,void 0),a=e.computed((()=>!S(n)));return{group:n,isInGroup:a,getGroupOrLocalRef:function(l,a,t){if(null==n?void 0:n.value){const a=e.unref(n.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){t&&t(`update:${l}`,e)}})}}}(u),r=i("modelValue",l,n),d=i("valid",l),v=i("invalid",l),s=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==t?void 0:t.value)?void 0:e.readonly.value))})),f=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==t?void 0:t.value)?void 0:e.disabled.value))}));return{id:a,group:t,isInGroup:o,modelValue:r,valid:d,invalid:v,readonly:s,disabled:f}}function V(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const j=["for"],L=["id","name","disabled","value","tabindex","aria-invalid"];return e.defineComponent({name:"VvRadio",props:B,emits:["click","update:modelValue","change","blur"],setup(a,{emit:t}){const o=a,u=e.useSlots(),{id:i,disabled:r,readonly:d,modelValue:v,valid:s,invalid:f}=A(o,t),c=(l=>e.computed((()=>String((null==l?void 0:l.value)||n.nanoid()))))(i),p=e.computed((()=>b.value?-1:o.tabindex)),m=e.ref(),b=e.computed((()=>r.value||d.value)),y=e.computed((()=>!0===f.value||!0!==s.value&&void 0)),B=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const n of l)if(g(e,n))return!0;return!1}(o.value,v.value):g(o.value,v.value))),R=e.computed((()=>!["string","number","boolean"].includes(typeof o.value)||o.value)),O=e.computed({get:()=>B.value?R.value:null,set(e){Array.isArray(v.value)?v.value=[o.value]:v.value=o.value,t("change",e)}}),{modifiers:x}=e.toRefs(o),k=function(l,n,a){return e.computed((()=>{const t={[l]:!0},o="string"==typeof(null==n?void 0:n.value)?n.value.split(" "):null==n?void 0:n.value;return o&&Array.isArray(o)&&o.forEach((e=>{e&&(t[`${l}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((n=>{t[`${l}--${n}`]=e.unref(a.value[n])})),t}))}("vv-radio",x,e.computed((()=>({valid:s.value,invalid:f.value,disabled:r.value,readonly:d.value})))),{HintSlot:N}=function(n,a){const{invalid:t,valid:o,hint:u,loading:i}=a,{hintLabel:r,modelValue:d,valid:v,validLabel:s,invalid:f,invalidLabel:c,...p}=e.toRefs(n),m=h(p,"loading"),b=h(p,"loadingLabel"),g=e.computed((()=>!(!f.value||(!f.value||!t)&&!((null==c?void 0:c.value)&&Array.isArray(c.value)&&c.value.length>0)&&(!(null==c?void 0:c.value)||S(c))))),y=e.computed((()=>!!(r&&r.value||u))),B=e.computed((()=>!!(s&&s.value||o))),A=e.computed((()=>!!((null==m?void 0:m.value)&&i||(null==m?void 0:m.value)&&(null==b?void 0:b.value)))),j=e.computed((()=>y.value||B.value||g.value||A.value));return{hasInvalid:g,hasHint:y,hasValid:B,hasLoading:A,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(n){const a=e.computed((()=>{const e=l.toReactive({hintLabel:r,modelValue:d,valid:v,validLabel:s,invalid:f,invalidLabel:c,loading:m,loadingLabel:b,...n.params});return(null==f?void 0:f.value)?(null==t?void 0:t(e))||V(null==c?void 0:c.value)||(null==r?void 0:r.value):(null==v?void 0:v.value)?(null==o?void 0:o(e))||V(null==s?void 0:s.value)||(null==r?void 0:r.value):(null==m?void 0:m.value)?(null==i?void 0:i(e))||V(null==b?void 0:b.value)||(null==r?void 0:r.value):(null==u?void 0:u(e))||V(null==r?void 0:r.value)||(null==r?void 0:r.value)}));return{isVisible:j,hasInvalid:g,hasValid:B,hintContent:a}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}(o,u);return(l,n)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(k)),for:e.unref(c)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(c),ref_key:"input",ref:m,"onUpdate:modelValue":n[0]||(n[0]=l=>e.isRef(O)?O.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(b),value:e.unref(R),tabindex:e.unref(p),"aria-invalid":e.unref(y)},null,8,L),[[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(N),{class:"vv-radio__hint",params:{value:e.unref(v)}},null,8,["params"])],10,j))}})}));
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("radioGroup"),i={valid:Boolean,validLabel:[String,Array]},r={invalid:Boolean,invalidLabel:[String,Array]},u={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},d={disabled:Boolean},s=(Boolean,Boolean,{label:[String,Number]}),v={readonly:Boolean},f={modifiers:[String,Array]},c={hintLabel:{type:String,default:""}};a.before;const p={tabindex:{type:[String,Number],default:0}},b={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const h={...{...b,name:{type:String,required:!0}},...p,...i,...r,...c,...d,...v,...f,...s,...u,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]};function m(e,l,t){return t?y(e,t)===y(l,t):g(e,l)}function g(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(!g(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],!g(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function y(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 S(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 L=h;function O(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const B=["for"],$=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"];return e.defineComponent({name:"VvRadio",props:L,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const n=t,i=e.useSlots(),{id:r,disabled:u,readonly:d,modelValue:s,valid:v,invalid:f}=function(l,t){const{id:a}=e.toRefs(l),{group:n,isInGroup:i,getGroupOrLocalRef:r}=S(o),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:i,modelValue:u,valid:d,invalid:s,readonly:v,disabled:f}}(n,a),c=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(r),p=e.computed((()=>`${c.value}-hint`)),b=e.computed((()=>g.value?-1:n.tabindex)),h=e.ref(),g=e.computed((()=>u.value||d.value)),y=e.computed((()=>!0===f.value||!0!==v.value&&void 0)),L=e.computed((()=>Array.isArray(s.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(m(e,t))return!0;return!1}(n.value,s.value):m(n.value,s.value))),V=e.computed((()=>!["string","number","boolean"].includes(typeof n.value)||n.value)),A=e.computed({get:()=>L.value?V.value:null,set(e){Array.isArray(s.value)?s.value=[n.value]:s.value=n.value,a("change",e)}}),{modifiers:R}=e.toRefs(n),x=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",R,e.computed((()=>({valid:v.value,invalid:f.value,disabled:u.value,readonly:d.value})))),{HintSlot:j,hasHintLabelOrSlot:k,hasInvalidLabelOrSlot:P,hintSlotScope:I}=function(l,t){const a=e.computed((()=>O(l.invalidLabel))),n=e.computed((()=>O(l.validLabel))),o=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(t.loading||o.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||n.value)))),s=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(t.hint||i.value))),v=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}))),c=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:a,validLabel:n,loadingLabel:o,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:s}),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:u,hasHintLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:f,HintSlot:c}}(n,i);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(x)),for:e.unref(c)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(c),ref_key:"input",ref:h,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(A)?A.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(g),value:e.unref(V),tabindex:e.unref(b),"aria-invalid":e.unref(y),"aria-describedby":e.unref(k)?e.unref(p):void 0,"aria-errormessage":e.unref(P)?e.unref(p):void 0},null,8,$),[[e.vModelRadio,e.unref(A)]]),e.renderSlot(l.$slots,"default",{value:e.unref(s)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(j),{id:e.unref(p),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(I))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(I))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(I))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(I))))])),key:"3"}:void 0]),1032,["id"])],10,B))}})}));
@@ -1,6 +1,11 @@
1
1
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
2
  value: (StringConstructor | BooleanConstructor | NumberConstructor)[];
3
3
  modelValue: (StringConstructor | BooleanConstructor | ObjectConstructor | NumberConstructor)[];
4
+ loading: BooleanConstructor;
5
+ loadingLabel: {
6
+ type: StringConstructor;
7
+ default: string;
8
+ };
4
9
  label: (StringConstructor | NumberConstructor)[];
5
10
  modifiers: globalThis.PropType<string | string[]>;
6
11
  readonly: BooleanConstructor;
@@ -25,6 +30,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
25
30
  }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
26
31
  value: (StringConstructor | BooleanConstructor | NumberConstructor)[];
27
32
  modelValue: (StringConstructor | BooleanConstructor | ObjectConstructor | NumberConstructor)[];
33
+ loading: BooleanConstructor;
34
+ loadingLabel: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
28
38
  label: (StringConstructor | NumberConstructor)[];
29
39
  modifiers: globalThis.PropType<string | string[]>;
30
40
  readonly: BooleanConstructor;
@@ -50,6 +60,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
50
60
  [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
51
61
  }, {
52
62
  disabled: boolean;
63
+ loading: boolean;
64
+ loadingLabel: string;
53
65
  readonly: boolean;
54
66
  hintLabel: string;
55
67
  invalid: boolean;
@@ -57,7 +69,31 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
57
69
  tabindex: string | number;
58
70
  }>, {
59
71
  default: (_: {
60
- value: string | number | boolean | Record<string, any> | undefined;
72
+ value: any;
73
+ }) => any;
74
+ hint: (_: {
75
+ modelValue: any;
76
+ valid: boolean;
77
+ invalid: boolean;
78
+ loading: boolean;
79
+ }) => any;
80
+ loading: (_: {
81
+ modelValue: any;
82
+ valid: boolean;
83
+ invalid: boolean;
84
+ loading: boolean;
85
+ }) => any;
86
+ valid: (_: {
87
+ modelValue: any;
88
+ valid: boolean;
89
+ invalid: boolean;
90
+ loading: boolean;
91
+ }) => any;
92
+ invalid: (_: {
93
+ modelValue: any;
94
+ valid: boolean;
95
+ invalid: boolean;
96
+ loading: boolean;
61
97
  }) => any;
62
98
  }>;
63
99
  export default _default;
@@ -3,6 +3,11 @@ import type { InputGroupState } from '../../types/group';
3
3
  export declare const VvRadioProps: {
4
4
  value: (StringConstructor | BooleanConstructor | NumberConstructor)[];
5
5
  modelValue: (StringConstructor | BooleanConstructor | ObjectConstructor | NumberConstructor)[];
6
+ loading: BooleanConstructor;
7
+ loadingLabel: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ };
6
11
  label: (StringConstructor | NumberConstructor)[];
7
12
  modifiers: globalThis.PropType<string | string[]>;
8
13
  readonly: BooleanConstructor;
@@ -34,7 +39,7 @@ export declare function useGroupProps(props: VvRadioPropsType, emit: (event: (ty
34
39
  id: Ref<string | number | undefined> | undefined;
35
40
  group: Ref<InputGroupState> | undefined;
36
41
  isInGroup: globalThis.ComputedRef<boolean>;
37
- modelValue: import("vue").WritableComputedRef<unknown>;
42
+ modelValue: import("vue").WritableComputedRef<any>;
38
43
  valid: Ref<boolean>;
39
44
  invalid: Ref<boolean>;
40
45
  readonly: globalThis.ComputedRef<boolean>;