vueless 0.0.210 → 0.0.211

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 (71) hide show
  1. package/package.json +1 -1
  2. package/ui.container-group/configs/default.config.js +19 -1
  3. package/ui.container-group/index.vue +26 -1
  4. package/ui.container-row/configs/default.config.js +21 -3
  5. package/ui.container-row/index.vue +27 -2
  6. package/ui.data-list/composables/attrs.composable.js +39 -36
  7. package/ui.data-list/configs/default.config.js +6 -4
  8. package/ui.data-list/index.stories.js +2 -4
  9. package/ui.data-list/index.vue +34 -5
  10. package/ui.data-table/composables/attrs.composable.js +180 -245
  11. package/ui.data-table/configs/default.config.js +10 -10
  12. package/ui.data-table/index.vue +52 -12
  13. package/ui.form-checkbox/composables/attrs.composable.js +28 -43
  14. package/ui.form-checkbox/configs/default.config.js +2 -2
  15. package/ui.form-checkbox/index.stories.js +2 -4
  16. package/ui.form-checkbox/index.vue +16 -4
  17. package/ui.form-checkbox-group/composables/attrs.composable.js +24 -9
  18. package/ui.form-checkbox-group/configs/default.config.js +2 -2
  19. package/ui.form-checkbox-group/index.vue +8 -2
  20. package/ui.form-checkbox-multi-state/composables/attrs.composable.js +34 -12
  21. package/ui.form-checkbox-multi-state/configs/default.config.js +1 -1
  22. package/ui.form-checkbox-multi-state/index.vue +8 -2
  23. package/ui.form-input-file/composables/attrs.composable.js +19 -62
  24. package/ui.form-input-file/configs/default.config.js +7 -7
  25. package/ui.form-input-file/index.vue +15 -3
  26. package/ui.form-input-money/composables/attrs.composable.js +23 -4
  27. package/ui.form-input-money/configs/default.config.js +1 -1
  28. package/ui.form-input-money/index.stories.js +2 -4
  29. package/ui.form-input-number/composables/attrs.composable.js +22 -36
  30. package/ui.form-input-number/configs/default.config.js +4 -4
  31. package/ui.form-input-number/index.vue +8 -2
  32. package/ui.form-input-rating/composables/attrs.composable.js +10 -11
  33. package/ui.form-input-rating/index.vue +2 -2
  34. package/ui.form-input-search/composables/attrs.composable.js +26 -11
  35. package/ui.form-input-search/configs/default.config.js +4 -4
  36. package/ui.form-input-search/index.stories.js +2 -4
  37. package/ui.form-input-search/index.vue +21 -4
  38. package/ui.form-label/composables/attrs.composable.js +22 -49
  39. package/ui.form-label/index.vue +9 -2
  40. package/ui.form-radio/composables/attrs.composable.js +29 -22
  41. package/ui.form-radio/configs/default.config.js +1 -1
  42. package/ui.form-radio/index.stories.js +2 -4
  43. package/ui.form-radio/index.vue +8 -2
  44. package/ui.form-radio-group/composables/attrs.composable.js +20 -15
  45. package/ui.form-radio-group/configs/default.config.js +2 -1
  46. package/ui.form-radio-group/index.vue +8 -2
  47. package/ui.form-switch/composables/attrs.composable.js +25 -61
  48. package/ui.form-switch/configs/default.config.js +2 -2
  49. package/ui.form-switch/index.vue +8 -2
  50. package/ui.form-textarea/composables/attrs.composable.js +25 -36
  51. package/ui.form-textarea/configs/default.config.js +1 -1
  52. package/ui.form-textarea/index.stories.js +3 -5
  53. package/ui.form-textarea/index.vue +35 -4
  54. package/ui.navigation-pagination/composables/attrs.composable.js +41 -31
  55. package/ui.navigation-pagination/configs/default.config.js +2 -2
  56. package/ui.navigation-pagination/index.vue +22 -6
  57. package/ui.navigation-progress/components/StepperProgress.vue +1 -1
  58. package/ui.navigation-progress/composables/attrs.composable.js +19 -22
  59. package/ui.navigation-progress/index.vue +14 -1
  60. package/ui.navigation-tab/composables/attrs.composable.js +25 -20
  61. package/ui.navigation-tab/index.vue +1 -1
  62. package/ui.navigation-tabs/composables/attrs.composable.js +19 -13
  63. package/ui.navigation-tabs/configs/default.config.js +1 -1
  64. package/ui.navigation-tabs/index.vue +9 -2
  65. package/ui.text-file/configs/default.config.js +3 -0
  66. package/ui.text-file/index.vue +36 -25
  67. package/ui.text-files/index.vue +8 -0
  68. package/ui.text-header/configs/default.config.js +1 -0
  69. package/ui.text-header/index.stories.js +2 -2
  70. package/ui.text-header/index.vue +16 -12
  71. package/web-types.json +383 -62
@@ -56,7 +56,7 @@ import UIService from "../service.ui";
56
56
 
57
57
  import defaultConfig from "./configs/default.config";
58
58
  import { UInputNumber } from "./constants";
59
- import { useAttrs } from "./composables/attrs.composable";
59
+ import useAttrs from "./composables/attrs.composable";
60
60
 
61
61
  /* Should be a string for correct web-types gen */
62
62
  defineOptions({ name: "UInputNumber", inheritAttrs: false });
@@ -128,7 +128,13 @@ const props = defineProps({
128
128
  },
129
129
  });
130
130
 
131
- const emit = defineEmits(["update:modelValue"]);
131
+ const emit = defineEmits([
132
+ /**
133
+ * Triggers when the input value changes.
134
+ * @property {number} modelValue
135
+ */
136
+ "update:modelValue",
137
+ ]);
132
138
 
133
139
  const {
134
140
  config,
@@ -3,7 +3,7 @@ import useUI from "../../composable.ui";
3
3
  import { cva } from "../../service.ui";
4
4
  import defaultConfig from "../configs/default.config";
5
5
 
6
- export function useAttrs(props) {
6
+ export default function useAttrs(props) {
7
7
  const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
8
8
  defaultConfig,
9
9
  () => props.config,
@@ -13,18 +13,17 @@ export function useAttrs(props) {
13
13
  for (const key in defaultConfig) {
14
14
  if (isSystemKey(key)) continue;
15
15
 
16
- let classes = "";
17
- let value = config.value[key];
16
+ const classes = computed(() => {
17
+ const value = config.value[key];
18
18
 
19
- if (value.variants || value.compoundVariants) {
20
- const getCVA = cva(value);
21
-
22
- classes = computed(() =>
23
- getCVA({
19
+ if (value.variants || value.compoundVariants) {
20
+ return cva(value)({
24
21
  ...props,
25
- }),
26
- );
27
- }
22
+ });
23
+ }
24
+
25
+ return "";
26
+ });
28
27
 
29
28
  attrs[`${key}Attrs`] = getAttrs(key, { classes });
30
29
  }
@@ -58,7 +58,7 @@ import UIService from "../service.ui";
58
58
 
59
59
  import { UInputRating } from "./constants";
60
60
  import defaultConfig from "./configs/default.config";
61
- import { useAttrs } from "./composables/attrs.composable";
61
+ import useAttrs from "./composables/attrs.composable";
62
62
 
63
63
  /* Should be a string for correct web-types gen */
64
64
  defineOptions({ name: "UInputRating", inheritAttrs: false });
@@ -165,7 +165,7 @@ const props = defineProps({
165
165
 
166
166
  const emit = defineEmits([
167
167
  /**
168
- * Triggers when the rating is changes.
168
+ * Triggers when the rating value changes.
169
169
  * @property {number} modelValue
170
170
  */
171
171
  "update:modelValue",
@@ -1,21 +1,36 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../../composable.ui";
2
-
3
+ import { cva } from "../../service.ui";
3
4
  import defaultConfig from "../configs/default.config";
4
5
 
5
- export function useAttrs(props) {
6
- const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
6
+ export default function useAttrs(props) {
7
+ const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
8
+ defaultConfig,
9
+ () => props.config,
10
+ );
11
+ const attrs = {};
12
+
13
+ for (const key in defaultConfig) {
14
+ if (isSystemKey(key)) continue;
15
+
16
+ const classes = computed(() => {
17
+ const value = config.value[key];
18
+
19
+ if (value.variants || value.compoundVariants) {
20
+ return cva(value)({
21
+ ...props,
22
+ });
23
+ }
24
+
25
+ return "";
26
+ });
7
27
 
8
- const inputAttrs = getAttrs("input", { isComponent: true });
9
- const searchIconAttrs = getAttrs("searchIcon", { isComponent: true });
10
- const closeIconAttrs = getAttrs("closeIcon", { isComponent: true });
11
- const buttonAttrs = getAttrs("button", { isComponent: true });
28
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
29
+ }
12
30
 
13
31
  return {
32
+ ...attrs,
14
33
  config,
15
- inputAttrs,
16
- searchIconAttrs,
17
- closeIconAttrs,
18
- buttonAttrs,
19
34
  hasSlotContent,
20
35
  };
21
36
  }
@@ -1,16 +1,16 @@
1
1
  export default /*tw*/ {
2
2
  input: {
3
3
  wrapper: "relative flex items-center justify-between w-full rounded-lg bg-gray-900 bg-opacity-5",
4
- input: "w-full",
4
+ input: "{UInput} w-full",
5
5
  label: "w-full",
6
6
  rightSlot: "pr-0",
7
7
  leftSlot: "pl-0",
8
8
  },
9
- closeIcon: "flex h-full items-center mr-2",
9
+ closeIcon: "{UIcon} flex h-full items-center mr-2",
10
10
  closeIconName: "close",
11
- searchIcon: "mr-3",
11
+ searchIcon: "{UIcon} mr-3",
12
12
  searchIconName: "search",
13
- button: "rounded-l-none ml-1 !ring-0 outline outline-1 outline-gray-900",
13
+ button: "{UButton} rounded-l-none ml-1 !ring-0 outline outline-1 outline-gray-900",
14
14
  defaultVariants: {
15
15
  size: "md",
16
16
  labelAlign: "topInside",
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UInputSearch from "../ui.form-input-search";
4
4
  import UButton from "../ui.button";
@@ -28,9 +28,7 @@ const DefaultTemplate = (args) => ({
28
28
  },
29
29
  template: `
30
30
  <UInputSearch v-bind="args">
31
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
32
- <template v-if="args[slot]">{{ args[slot] }}</template>
33
- </template>
31
+ ${allSlotsFragment}
34
32
  </UInputSearch>
35
33
  `,
36
34
  });
@@ -16,12 +16,12 @@
16
16
  @keyup.enter="onClickSearch"
17
17
  >
18
18
  <template #left>
19
- <!-- @slot Use it to add something before text. -->
19
+ <!-- @slot Use it to add something before the text. -->
20
20
  <slot name="left" />
21
21
  </template>
22
22
 
23
23
  <template #right>
24
- <!-- @slot Use it to add something before text. -->
24
+ <!-- @slot Use it to add something after the text. -->
25
25
  <slot name="right" />
26
26
 
27
27
  <template v-if="!hasSlotContent($slots['right'])">
@@ -70,7 +70,7 @@ import UIService, { getRandomId } from "../service.ui";
70
70
 
71
71
  import { UInputSearch } from "./constants";
72
72
  import defaultConfig from "./configs/default.config";
73
- import { useAttrs } from "./composables/attrs.composable";
73
+ import useAttrs from "./composables/attrs.composable";
74
74
 
75
75
  /* Should be a string for correct web-types gen */
76
76
  defineOptions({ name: "UInputSearch" });
@@ -176,7 +176,24 @@ const props = defineProps({
176
176
  },
177
177
  });
178
178
 
179
- const emit = defineEmits(["update:modelValue", "clear", "search"]);
179
+ const emit = defineEmits([
180
+ /**
181
+ * Triggers when the input value changes.
182
+ * @property {string} value
183
+ */
184
+ "update:modelValue",
185
+
186
+ /**
187
+ * Triggers when the input value is cleared.
188
+ */
189
+ "clear",
190
+
191
+ /**
192
+ * Triggers when the search button is clicked.
193
+ * @property {string} value
194
+ */
195
+ "search",
196
+ ]);
180
197
 
181
198
  const localValue = ref("");
182
199
 
@@ -4,62 +4,35 @@ import { cva } from "../../service.ui";
4
4
  import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
- export function useAttrs(props) {
8
- const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
9
- const { wrapper, label, description } = config.value;
10
-
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
16
-
17
- const cvaLabel = cva({
18
- base: label.base,
19
- variants: label.variants,
20
- compoundVariants: label.compoundVariants,
21
- });
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
11
+ );
12
+ const attrs = {};
22
13
 
23
- const cvaDescription = cva({
24
- base: description.base,
25
- variants: description.variants,
26
- compoundVariants: description.compoundVariants,
27
- });
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
28
16
 
29
- const wrapperClasses = computed(() =>
30
- cvaWrapper({
31
- size: props.size,
32
- align: props.align,
33
- }),
34
- );
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
35
19
 
36
- const labelClasses = computed(() =>
37
- cvaLabel({
38
- size: props.size,
39
- error: Boolean(props.error),
40
- disabled: props.disabled,
41
- align: props.align,
42
- }),
43
- );
20
+ if (value.variants || value.compoundVariants) {
21
+ return cva(value)({
22
+ ...props,
23
+ error: Boolean(props.error),
24
+ });
25
+ }
44
26
 
45
- const descriptionClasses = computed(() =>
46
- cvaDescription({
47
- size: props.size,
48
- error: Boolean(props.error),
49
- align: props.align,
50
- }),
51
- );
27
+ return "";
28
+ });
52
29
 
53
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
54
- const labelAttrs = getAttrs("label", { classes: labelClasses });
55
- const labelWrapperAttrs = getAttrs("labelWrapper");
56
- const descriptionAttrs = getAttrs("description", { classes: descriptionClasses });
30
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
31
+ }
57
32
 
58
33
  return {
59
- wrapperAttrs,
60
- labelWrapperAttrs,
61
- labelAttrs,
62
- descriptionAttrs,
34
+ ...attrs,
35
+ config,
63
36
  hasSlotContent,
64
37
  };
65
38
  }
@@ -25,6 +25,7 @@
25
25
  v-text="description"
26
26
  />
27
27
 
28
+ <!-- @slot Use it to add something to the label's footer -->
28
29
  <slot name="footer" />
29
30
  </div>
30
31
  </div>
@@ -50,6 +51,7 @@
50
51
  v-text="description"
51
52
  />
52
53
 
54
+ <!-- @slot Use it to add something to the label's footer -->
53
55
  <slot name="footer" />
54
56
  </div>
55
57
  </template>
@@ -61,12 +63,17 @@ import UIService from "../service.ui";
61
63
 
62
64
  import defaultConfig from "./configs/default.config";
63
65
  import { ULabel, PLACEMENT } from "./constants";
64
- import { useAttrs } from "./composables/attrs.composable";
66
+ import useAttrs from "./composables/attrs.composable";
65
67
 
66
68
  /* Should be a string for correct web-types gen */
67
69
  defineOptions({ name: "ULabel", inheritAttrs: false });
68
70
 
69
- const emit = defineEmits(["click", "mousedown"]);
71
+ const emit = defineEmits([
72
+ /**
73
+ * Triggers when the label is clicked.
74
+ */
75
+ "click",
76
+ ]);
70
77
 
71
78
  const props = defineProps({
72
79
  /**
@@ -4,31 +4,38 @@ import { cva } from "../../service.ui";
4
4
 
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
- export function useAttrs(props, { radioColor, radioSize }) {
8
- const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
- const { radio } = config.value;
10
-
11
- const cvaRadio = cva({
12
- base: radio.base,
13
- variants: radio.variants,
14
- compoundVariants: radio.compoundVariants,
15
- });
16
-
17
- const radioClasses = computed(() =>
18
- setColor(
19
- cvaRadio({
20
- color: getColor(radioColor.value),
21
- size: radioSize.value,
22
- }),
23
- radioColor.value,
24
- ),
7
+ export default function useAttrs(props, { radioColor, radioSize }) {
8
+ const { config, getAttrs, getColor, setColor, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
25
11
  );
12
+ const attrs = {};
26
13
 
27
- const labelAttrs = getAttrs("label", { isComponent: true });
28
- const radioAttrs = getAttrs("radio", { classes: radioClasses });
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
16
+
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
19
+
20
+ if (value.variants || value.compoundVariants) {
21
+ return setColor(
22
+ cva(value)({
23
+ ...props,
24
+ color: getColor(radioColor.value),
25
+ size: radioSize.value,
26
+ }),
27
+ radioColor.value,
28
+ );
29
+ }
30
+
31
+ return "";
32
+ });
33
+
34
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
35
+ }
29
36
 
30
37
  return {
31
- radioAttrs,
32
- labelAttrs,
38
+ ...attrs,
39
+ config,
33
40
  };
34
41
  }
@@ -1,7 +1,7 @@
1
1
  export default /*tw*/ {
2
2
  label: {
3
3
  wrapper: "inline-flex",
4
- label: "cursor-pointer",
4
+ label: "{ULabel} cursor-pointer",
5
5
  },
6
6
  radio: {
7
7
  base: `
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import URadio from "../ui.form-radio";
4
4
  import UBadge from "../ui.text-badge";
@@ -30,9 +30,7 @@ const DefaultTemplate = (args) => ({
30
30
  },
31
31
  template: `
32
32
  <URadio v-bind="args">
33
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
34
- <template v-if="args[slot]">{{ args[slot] }}</template>
35
- </template>
33
+ ${allSlotsFragment}
36
34
  </URadio>
37
35
  `,
38
36
  });
@@ -36,7 +36,7 @@ import ULabel from "../ui.form-label";
36
36
  import UIService, { getRandomId } from "../service.ui";
37
37
 
38
38
  import defaultConfig from "./configs/default.config";
39
- import { useAttrs } from "./composables/attrs.composable";
39
+ import useAttrs from "./composables/attrs.composable";
40
40
  import { URadio } from "./constants";
41
41
 
42
42
  /* Should be a string for correct web-types gen */
@@ -158,7 +158,13 @@ const props = defineProps({
158
158
  },
159
159
  });
160
160
 
161
- const emit = defineEmits(["update:modelValue"]);
161
+ const emit = defineEmits([
162
+ /**
163
+ * Triggers when the value attribute changes.
164
+ * @property {string} value
165
+ */
166
+ "update:modelValue",
167
+ ]);
162
168
 
163
169
  const localValue = ref("");
164
170
  const radioName = ref(null);
@@ -5,25 +5,30 @@ import useUI from "../../composable.ui";
5
5
 
6
6
  import defaultConfig from "../configs/default.config";
7
7
 
8
- export function useAttrs(props) {
9
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
10
- const { list } = config.value;
8
+ export default function useAttrs(props) {
9
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
10
+ const attrs = {};
11
11
 
12
- const cvaList = cva({
13
- base: list.base,
14
- variants: list.variants,
15
- compoundVariants: list.compoundVariants,
16
- });
12
+ for (const key in defaultConfig) {
13
+ if (isSystemKey(key)) continue;
17
14
 
18
- const listClasses = computed(() => cvaList({ size: props.size }));
15
+ const classes = computed(() => {
16
+ const value = config.value[key];
19
17
 
20
- const labelAttrs = getAttrs("label", { isComponent: true });
21
- const listAttrs = getAttrs("list", { classes: listClasses });
22
- const radioAttrs = getAttrs("radio", { isComponent: true });
18
+ if (value.variants || value.compoundVariants) {
19
+ return cva(value)({
20
+ ...props,
21
+ });
22
+ }
23
+
24
+ return "";
25
+ });
26
+
27
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
28
+ }
23
29
 
24
30
  return {
25
- labelAttrs,
26
- listAttrs,
27
- radioAttrs,
31
+ ...attrs,
32
+ config,
28
33
  };
29
34
  }
@@ -1,5 +1,6 @@
1
1
  export default /*tw*/ {
2
- label: "",
2
+ label: "{ULabel}",
3
+ radio: "{URadio}",
3
4
  list: {
4
5
  base: "flex flex-col",
5
6
  variants: {
@@ -36,7 +36,7 @@ import UIService from "../service.ui";
36
36
 
37
37
  import defaultConfig from "./configs/default.config";
38
38
  import { URadioGroup } from "./constants";
39
- import { useAttrs } from "./composables/attrs.composable";
39
+ import useAttrs from "./composables/attrs.composable";
40
40
 
41
41
  /* Should be a string for correct web-types gen */
42
42
  defineOptions({ name: "URadioGroup", inheritAttrs: false });
@@ -133,7 +133,13 @@ const props = defineProps({
133
133
  },
134
134
  });
135
135
 
136
- const emit = defineEmits(["update:modelValue"]);
136
+ const emit = defineEmits([
137
+ /**
138
+ * Triggers when the value attribute changes.
139
+ * @property {string} value
140
+ */
141
+ "update:modelValue",
142
+ ]);
137
143
 
138
144
  const { labelAttrs, listAttrs, radioAttrs } = useAttrs(props);
139
145
 
@@ -4,74 +4,38 @@ import { cva } from "../../service.ui";
4
4
  import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
- export function useAttrs(props, { checked }) {
8
- const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
- const { wrapper, circle, toggleLabel } = config.value;
10
-
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
16
-
17
- const cvaCircle = cva({
18
- base: circle.base,
19
- variants: circle.variants,
20
- compoundVariants: circle.compoundVariants,
21
- });
7
+ export default function useAttrs(props, { checked }) {
8
+ const { config, getAttrs, getColor, setColor, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
11
+ );
12
+ const attrs = {};
22
13
 
23
- const cvaToggleLabel = cva({
24
- base: toggleLabel.base,
25
- variants: toggleLabel.variants,
26
- compoundVariants: toggleLabel.compoundVariants,
27
- });
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
28
16
 
29
- const wrapperClasses = computed(() =>
30
- setColor(
31
- cvaWrapper({
32
- size: props.size,
33
- color: getColor(props.color),
34
- disabled: props.disabled,
35
- checked: Boolean(checked.value),
36
- toggleLabel: props.toggleLabel,
37
- }),
38
- props.color,
39
- ),
40
- );
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
41
19
 
42
- const circleClasses = computed(() =>
43
- cvaCircle({
44
- size: props.size,
45
- checked: Boolean(checked.value),
46
- }),
47
- );
20
+ if (value.variants || value.compoundVariants) {
21
+ return setColor(
22
+ cva(value)({
23
+ ...props,
24
+ color: getColor(props.color),
25
+ checked: Boolean(checked.value),
26
+ }),
27
+ props.color,
28
+ );
29
+ }
48
30
 
49
- const toggleLabelClasses = computed(() =>
50
- setColor(
51
- cvaToggleLabel({
52
- size: props.size,
53
- color: getColor(props.color),
54
- toggleLabel: props.toggleLabel,
55
- checked: Boolean(checked.value),
56
- }),
57
- props.color,
58
- ),
59
- );
31
+ return "";
32
+ });
60
33
 
61
- const labelAttrs = getAttrs("label", { isComponent: true });
62
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
63
- const inputAttrs = getAttrs("input");
64
- const circleAttrs = getAttrs("circle", { classes: circleClasses });
65
- const iconAttrs = getAttrs("icon", { isComponent: true });
66
- const toggleLabelAttrs = getAttrs("toggleLabel", { classes: toggleLabelClasses });
34
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
35
+ }
67
36
 
68
37
  return {
38
+ ...attrs,
69
39
  config,
70
- iconAttrs,
71
- labelAttrs,
72
- wrapperAttrs,
73
- circleAttrs,
74
- toggleLabelAttrs,
75
- inputAttrs,
76
40
  };
77
41
  }
@@ -1,5 +1,5 @@
1
1
  export default /*tw*/ {
2
- label: "flex items-start",
2
+ label: "{ULabel} flex items-start",
3
3
  wrapper: {
4
4
  base: `
5
5
  transition duration-300
@@ -42,7 +42,7 @@ export default /*tw*/ {
42
42
  { checked: true, size: "lg", class: "ml-[calc(100%-1.5rem)]" },
43
43
  ],
44
44
  },
45
- icon: "",
45
+ icon: "{UIcon}",
46
46
  selectedIconName: "check",
47
47
  unselectedIconName: "close",
48
48
  toggleLabel: {
@@ -47,7 +47,7 @@ import UIService, { getRandomId } from "../service.ui";
47
47
 
48
48
  import { USwitch } from "./constants";
49
49
  import defaultConfig from "./configs/default.config";
50
- import { useAttrs } from "./composables/attrs.composable";
50
+ import useAttrs from "./composables/attrs.composable";
51
51
  import { useLocale } from "../composable.locale";
52
52
 
53
53
  /* Should be a string for correct web-types gen */
@@ -154,7 +154,13 @@ const props = defineProps({
154
154
  },
155
155
  });
156
156
 
157
- const emit = defineEmits(["update:modelValue"]);
157
+ const emit = defineEmits([
158
+ /**
159
+ * Triggers when switch value changes.
160
+ * @property {Boolean} value
161
+ */
162
+ "update:modelValue",
163
+ ]);
158
164
 
159
165
  const { tm } = useLocale();
160
166