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
@@ -4,47 +4,36 @@ 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 { textarea, textareaWrapper } = config.value;
10
-
11
- const cvaTextarea = cva({
12
- base: textarea.base,
13
- variants: textarea.variants,
14
- compoundVariants: textarea.compoundVariants,
15
- });
16
-
17
- const cvaTextareaWrapper = cva({
18
- base: textareaWrapper.base,
19
- variants: textareaWrapper.variants,
20
- compoundVariants: textareaWrapper.compoundVariants,
21
- });
22
-
23
- const textareaWrapperClasses = computed(() =>
24
- cvaTextareaWrapper({
25
- error: Boolean(props.error),
26
- size: props.size,
27
- readonly: props.readonly,
28
- disabled: props.disabled,
29
- labelAlign: props.labelAlign,
30
- label: Boolean(props.label),
31
- }),
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
32
11
  );
12
+ const attrs = {};
33
13
 
34
- const textareaClasses = computed(() => cvaTextarea({ size: props.size }));
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
35
16
 
36
- const leftSlotAttrs = getAttrs("leftSlot");
37
- const rightSlotAttrs = getAttrs("rightSlot");
38
- const labelAttrs = getAttrs("label", { isComponent: true });
39
- const textareaWrapperAttrs = getAttrs("textareaWrapper", { classes: textareaWrapperClasses });
40
- const textareaAttrs = getAttrs("textarea", { classes: textareaClasses });
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
19
+
20
+ if (value.variants || value.compoundVariants) {
21
+ return cva(value)({
22
+ ...props,
23
+ error: Boolean(props.error),
24
+ label: Boolean(props.label),
25
+ });
26
+ }
27
+
28
+ return "";
29
+ });
30
+
31
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
32
+ }
41
33
 
42
34
  return {
43
- textareaAttrs,
44
- labelAttrs,
45
- textareaWrapperAttrs,
46
- leftSlotAttrs,
47
- rightSlotAttrs,
35
+ ...attrs,
36
+ config,
48
37
  hasSlotContent,
49
38
  };
50
39
  }
@@ -1,5 +1,5 @@
1
1
  export default /*tw*/ {
2
- label: "relative w-full",
2
+ label: "{ULabel} relative w-full",
3
3
  leftSlot: "flex items-center justify-center h-full w-11 absolute left-0",
4
4
  rightSlot: "flex items-center justify-center h-full w-11 absolute right-0",
5
5
  textareaWrapper: {
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UTextarea from "../ui.form-textarea";
4
4
  import UIcon from "../ui.image-icon";
@@ -32,9 +32,7 @@ const DefaultTemplate = (args) => ({
32
32
  <UTextarea
33
33
  v-bind="args"
34
34
  >
35
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
36
- <template v-if="args[slot]">{{ args[slot] }}</template>
37
- </template>
35
+ ${allSlotsFragment}
38
36
  </UTextarea>
39
37
  `,
40
38
  });
@@ -140,7 +138,7 @@ slotLeft.args = {
140
138
  };
141
139
 
142
140
  export const slotRight = SlotTemplate.bind({});
143
- slotLeft.args = {
141
+ slotRight.args = {
144
142
  slotTemplate: `
145
143
  <template #right>
146
144
  <UIcon
@@ -17,7 +17,7 @@
17
17
  :for="id"
18
18
  v-bind="leftSlotAttrs"
19
19
  >
20
- <!-- @slot Use it to add some component before text. -->
20
+ <!-- @slot Use it to add something before the text. -->
21
21
  <slot name="left" />
22
22
  </label>
23
23
  <label ref="textareaWrapper" :for="id" v-bind="textareaWrapperAttrs">
@@ -42,7 +42,7 @@
42
42
  />
43
43
  </label>
44
44
  <label v-if="hasSlotContent($slots['right'])" :for="id" v-bind="rightSlotAttrs">
45
- <!-- @slot Use it to add some component after text. -->
45
+ <!-- @slot Use it to add something after the text. -->
46
46
  <slot name="right" />
47
47
  </label>
48
48
  </ULabel>
@@ -56,7 +56,7 @@ import UIService, { getRandomId } from "../service.ui";
56
56
 
57
57
  import { UTextarea } from "./constants";
58
58
  import defaultConfig from "./configs/default.config";
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: "UTextarea", inheritAttrs: false });
@@ -187,7 +187,38 @@ const props = defineProps({
187
187
  },
188
188
  });
189
189
 
190
- const emit = defineEmits(["change", "click", "focus", "blur", "update:modelValue", "mousedown"]);
190
+ const emit = defineEmits([
191
+ /**
192
+ * Triggers when the textarea value changes.
193
+ * @property {string} value
194
+ */
195
+ "update:modelValue",
196
+
197
+ /**
198
+ * Triggers when the textarea value changes.
199
+ */
200
+ "change",
201
+
202
+ /**
203
+ * Triggers when the textarea is clicked.
204
+ */
205
+ "click",
206
+
207
+ /**
208
+ * Triggers when the textarea is focused.
209
+ */
210
+ "focus",
211
+
212
+ /**
213
+ * Triggers when the textarea loses focus.
214
+ */
215
+ "blur",
216
+
217
+ /**
218
+ * Triggers when mouse button is released over the element.
219
+ */
220
+ "mousedown",
221
+ ]);
191
222
 
192
223
  const slots = useSlots();
193
224
 
@@ -1,45 +1,55 @@
1
1
  import useUI from "../../composable.ui";
2
2
 
3
3
  import defaultConfig from "../configs/default.config";
4
- import { cx } from "../../service.ui";
4
+ import { cva, cx } from "../../service.ui";
5
5
  import { computed } from "vue";
6
6
 
7
- export function useAttrs(props) {
8
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
9
+ const attrs = {};
9
10
 
10
- const listAttrs = getAttrs("list");
11
- const itemAttrsRaw = getAttrs("item");
12
- const itemEllipsisAttrs = getAttrs("itemEllipsis");
13
- const ellipsisAttrs = getAttrs("ellipsis");
14
- const navigationButtonAttrs = getAttrs("navigationButton", { isComponent: true });
15
- const navigationButtonTextAttrs = getAttrs("navigationButtonText");
16
- const pageButtonAttrsRaw = getAttrs("pageButton", { isComponent: true });
11
+ for (const key in defaultConfig) {
12
+ if (isSystemKey(key)) continue;
17
13
 
18
- const itemAttrs = computed(() => (page = 0) => {
19
- const itemClass = page && !isFinite(page.number) && ellipsisAttrs;
14
+ const classes = computed(() => {
15
+ const value = config.value[key];
20
16
 
21
- return {
22
- ...itemAttrsRaw.value,
23
- class: cx([itemAttrsRaw.value.class, itemClass]),
24
- };
25
- });
17
+ if (value.variants || value.compoundVariants) {
18
+ return cva(value)({
19
+ ...props,
20
+ });
21
+ }
26
22
 
27
- const pageButtonAttrs = computed(() => (page) => {
28
- const pageButtonActiveClasses = page.isActive && config.value.pageButtonActive;
23
+ return "";
24
+ });
29
25
 
30
- return {
31
- ...pageButtonAttrsRaw.value,
32
- class: cx([pageButtonAttrsRaw.value.class, pageButtonActiveClasses]),
33
- };
34
- });
26
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
27
+
28
+ if (key === "item") {
29
+ attrs.itemAttrs = computed(() => (page = 0) => {
30
+ const itemClass = page && !isFinite(page.number) && getAttrs("ellipsis");
31
+
32
+ return {
33
+ ...getAttrs("item"),
34
+ class: cx([getAttrs("item").value.class, itemClass]),
35
+ };
36
+ });
37
+ }
38
+
39
+ if (key === "pageButton") {
40
+ attrs.pageButtonAttrs = computed(() => (page) => {
41
+ const pageButtonActiveClasses = page.isActive && config.value.pageButtonActive;
42
+
43
+ return {
44
+ ...getAttrs("pageButton"),
45
+ class: cx([getAttrs("pageButton").value.class, pageButtonActiveClasses]),
46
+ };
47
+ });
48
+ }
49
+ }
35
50
 
36
51
  return {
37
- listAttrs,
38
- itemAttrs,
39
- itemEllipsisAttrs,
40
- navigationButtonAttrs,
41
- navigationButtonTextAttrs,
42
- pageButtonAttrs,
43
- ellipsisAttrs,
52
+ ...attrs,
53
+ config,
44
54
  };
45
55
  }
@@ -3,9 +3,9 @@ export default /*tw*/ {
3
3
  item: "h-9 min-w-9 flex items-center justify-center",
4
4
  ellipsis: "hidden md:flex",
5
5
  itemEllipsis: "leading-none",
6
- navigationButton: "size-full rounded font-normal disabled:hover:bg-transparent",
6
+ navigationButton: "{UButton} size-full rounded font-normal disabled:hover:bg-transparent",
7
7
  navigationButtonText: "h-9 min-w-9 leading-none",
8
- pageButton: "size-full rounded font-normal disabled:hover:bg-transparent",
8
+ pageButton: "{UButton} size-full rounded font-normal disabled:hover:bg-transparent",
9
9
  pageButtonActive: `
10
10
  rounded !bg-brand-900/15
11
11
  hover:!text-brand-900 !hover:bg-brand-900/15 disabled:hover:bg-brand-900/15
@@ -9,7 +9,8 @@
9
9
  v-bind="navigationButtonAttrs"
10
10
  @click="goToFirstPage"
11
11
  >
12
- <slot name="first-label">
12
+ <!-- @slot Use it to add something instead of the "first" label. -->
13
+ <slot name="first">
13
14
  <span v-bind="navigationButtonTextAttrs" v-html="firstLabel" />
14
15
  </slot>
15
16
  </UButton>
@@ -23,7 +24,8 @@
23
24
  v-bind="navigationButtonAttrs"
24
25
  @click="goToPrevPage"
25
26
  >
26
- <slot name="prev-label">
27
+ <!-- @slot Use it to add something instead of the "prev" label. -->
28
+ <slot name="prev">
27
29
  <span v-bind="navigationButtonTextAttrs" v-html="prevLabel" />
28
30
  </slot>
29
31
  </UButton>
@@ -54,7 +56,8 @@
54
56
  v-bind="navigationButtonAttrs"
55
57
  @click="goToNextPage"
56
58
  >
57
- <slot name="next-label">
59
+ <!-- @slot Use it to add something instead of the "next" label. -->
60
+ <slot name="next">
58
61
  <span v-bind="navigationButtonTextAttrs" v-html="nextLabel" />
59
62
  </slot>
60
63
  </UButton>
@@ -68,7 +71,8 @@
68
71
  v-bind="navigationButtonAttrs"
69
72
  @click="goToLastPage"
70
73
  >
71
- <slot name="next-label">
74
+ <!-- @slot Use it to add something instead of the "last" label. -->
75
+ <slot name="last">
72
76
  <span v-bind="navigationButtonTextAttrs" v-html="lastLabel" />
73
77
  </slot>
74
78
  </UButton>
@@ -85,7 +89,7 @@ import UIService from "../service.ui";
85
89
 
86
90
  import defaultConfig from "./configs/default.config";
87
91
  import { UPagination, ELLIPSIS_LABEL } from "./constants";
88
- import { useAttrs } from "./composables/attrs.composable";
92
+ import useAttrs from "./composables/attrs.composable";
89
93
 
90
94
  /* Should be a string for correct web-types gen */
91
95
  defineOptions({ name: "UPagination", inheritAttrs: false });
@@ -207,7 +211,19 @@ const props = defineProps({
207
211
  },
208
212
  });
209
213
 
210
- const emit = defineEmits(["change", "update:modelValue"]);
214
+ const emit = defineEmits([
215
+ /**
216
+ * Triggers when current page changes.
217
+ * @property {number} value
218
+ */
219
+ "change",
220
+
221
+ /**
222
+ * Triggers when current page changes.
223
+ * @property {number} value
224
+ */
225
+ "update:modelValue",
226
+ ]);
211
227
 
212
228
  const {
213
229
  listAttrs,
@@ -40,7 +40,7 @@ import { computed } from "vue";
40
40
 
41
41
  import { GRAY_COLORS } from "../../preset.tailwind/constants";
42
42
 
43
- import { useAttrs } from "../composables/attrs.composable";
43
+ import useAttrs from "../composables/attrs.composable";
44
44
 
45
45
  const props = defineProps({
46
46
  progressPercent: {
@@ -4,45 +4,42 @@ import { cva, cx } from "../../service.ui";
4
4
  import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
- export function useAttrs(props) {
7
+ export default function useAttrs(props) {
8
8
  const { config, getAttrs, getColor, setColor, isSystemKey } = useUI(
9
9
  defaultConfig,
10
10
  () => props.config,
11
11
  );
12
+
12
13
  const attrs = {};
13
14
 
14
15
  for (const key in defaultConfig) {
15
16
  if (isSystemKey(key)) continue;
16
17
 
17
- let classes = "";
18
- let value = config.value[key];
19
-
20
- const isVariants = value.variants || value.compoundVariants;
21
- const excludeKeys = ["progress", "indicator", "step"];
18
+ const classes = computed(() => {
19
+ const value = config.value[key];
22
20
 
23
- if (isVariants && !excludeKeys.includes(key)) {
24
- const getCVA = cva(value);
21
+ if (value.variants || value.compoundVariants) {
22
+ return setColor(
23
+ cva(value)({
24
+ ...props,
25
+ color: getColor(props.color),
26
+ }),
27
+ props.color,
28
+ );
29
+ }
25
30
 
26
- classes = computed(() => getCVA({ ...props }));
27
- }
31
+ return "";
32
+ });
28
33
 
29
- if (isVariants && excludeKeys.includes(key)) {
30
- const getCVA = cva(value);
31
-
32
- classes = computed(() =>
33
- setColor(getCVA({ ...props, color: getColor(props.color) }), props.color),
34
- );
35
- }
34
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
36
35
 
37
36
  if (key === "step") {
38
- const stepAttrsRaw = getAttrs("step", { classes });
37
+ const stepAttrs = attrs[`${key}Attrs`];
39
38
 
40
39
  attrs[`${key}Attrs`] = computed(() => (classes) => ({
41
- ...stepAttrsRaw.value,
42
- class: cx([stepAttrsRaw.value.class, classes]),
40
+ ...stepAttrs,
41
+ class: cx([stepAttrs.value.class, classes]),
43
42
  }));
44
- } else {
45
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
46
43
  }
47
44
  }
48
45
 
@@ -2,6 +2,12 @@
2
2
  <div v-bind="wrapperAttrs">
3
3
  <template v-if="isVariant.progress">
4
4
  <div v-if="indicator" v-bind="indicatorAttrs" :style="{ width: progressPercent }">
5
+ <!--
6
+ @slot Use it to add something instead of the progress indicator.
7
+ @binding {number} percent
8
+ @binding {number} value
9
+ @binding {number} max
10
+ -->
5
11
  <slot name="indicator" :percent="progressPercent" :value="value" :max="realMax">
6
12
  {{ progressPercent }}
7
13
  </slot>
@@ -12,6 +18,13 @@
12
18
 
13
19
  <div v-if="isSteps" v-bind="stepAttrs(!value && config.firstStep)">
14
20
  <template v-for="(step, index) in max" :key="index">
21
+ <!--
22
+ @slot Use it to add something instead of the progress step label.
23
+ @binding {string} name
24
+ @binding {number} step
25
+ @binding {number} value
26
+ @binding {number} max
27
+ -->
15
28
  <slot
16
29
  v-if="isActiveStep(index)"
17
30
  :name="`step-${index}`"
@@ -40,7 +53,7 @@
40
53
  import { computed } from "vue";
41
54
 
42
55
  import UIService from "../service.ui";
43
- import { useAttrs } from "./composables/attrs.composable";
56
+ import useAttrs from "./composables/attrs.composable";
44
57
 
45
58
  import defaultConfig from "./configs/default.config";
46
59
  import { UProgress, VARIANT } from "./constants";
@@ -4,27 +4,32 @@ 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, { selected, size }) {
8
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
9
- const { wrapper } = config.value;
10
-
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
16
-
17
- const wrapperClasses = computed(() =>
18
- cvaWrapper({
19
- disabled: props.disabled,
20
- size: size.value,
21
- selected: selected.value,
22
- }),
23
- );
24
-
25
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
7
+ export default function useAttrs(props, { selected, size }) {
8
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
9
+ const attrs = {};
10
+
11
+ for (const key in defaultConfig) {
12
+ if (isSystemKey(key)) continue;
13
+
14
+ const classes = computed(() => {
15
+ const value = config.value[key];
16
+
17
+ if (value.variants || value.compoundVariants) {
18
+ return cva(value)({
19
+ ...props,
20
+ size: size.value,
21
+ selected: selected.value,
22
+ });
23
+ }
24
+
25
+ return "";
26
+ });
27
+
28
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
29
+ }
26
30
 
27
31
  return {
28
- wrapperAttrs,
32
+ ...attrs,
33
+ config,
29
34
  };
30
35
  }
@@ -14,7 +14,7 @@ import UIService from "../service.ui";
14
14
 
15
15
  import { UTab } from "./constants";
16
16
  import defaultConfig from "./configs/default.config";
17
- import { useAttrs } from "./composables/attrs.composable";
17
+ import useAttrs from "./composables/attrs.composable";
18
18
 
19
19
  /* Should be a string for correct web-types gen */
20
20
  defineOptions({ name: "UTab", inheritAttrs: false });
@@ -4,24 +4,30 @@ 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 } = useUI(defaultConfig, () => props.config);
9
- const { wrapper } = config.value;
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
9
+ const attrs = {};
10
10
 
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
11
+ for (const key in defaultConfig) {
12
+ if (isSystemKey(key)) continue;
16
13
 
17
- const wrapperClasses = computed(() => cvaWrapper({ underlined: props.underlined }));
14
+ const classes = computed(() => {
15
+ const value = config.value[key];
18
16
 
19
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
17
+ if (value.variants || value.compoundVariants) {
18
+ return cva(value)({
19
+ ...props,
20
+ });
21
+ }
20
22
 
21
- const tabAttrs = getAttrs("tab", { isComponent: true });
23
+ return "";
24
+ });
25
+
26
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
27
+ }
22
28
 
23
29
  return {
24
- wrapperAttrs,
25
- tabAttrs,
30
+ ...attrs,
31
+ config,
26
32
  };
27
33
  }
@@ -7,7 +7,7 @@ export default /*tw*/ {
7
7
  },
8
8
  },
9
9
  },
10
- tab: "",
10
+ tab: "{UTab}",
11
11
  defaultVariants: {
12
12
  size: "md",
13
13
  underlined: false,
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div :data-cy="dataCy" v-bind="wrapperAttrs">
3
+ <!-- @slot Use it to add the UTab component. -->
3
4
  <slot>
4
5
  <UTab
5
6
  v-for="(item, index) in options"
@@ -23,7 +24,7 @@ import UIService from "../service.ui";
23
24
 
24
25
  import { UTabs } from "./constants";
25
26
  import defaultConfig from "./configs/default.config";
26
- import { useAttrs } from "./composables/attrs.composable";
27
+ import useAttrs from "./composables/attrs.composable";
27
28
 
28
29
  /* Should be a string for correct web-types gen */
29
30
  defineOptions({ name: "UTabs", inheritAttrs: false });
@@ -85,7 +86,13 @@ const props = defineProps({
85
86
  },
86
87
  });
87
88
 
88
- const emit = defineEmits(["update:modelValue"]);
89
+ const emit = defineEmits([
90
+ /**
91
+ * Triggers when the selected tab changes.
92
+ * @property {string} modelValue
93
+ */
94
+ "update:modelValue",
95
+ ]);
89
96
 
90
97
  const selectedItem = computed({
91
98
  get: () => props.modelValue,
@@ -17,4 +17,7 @@ export default /*tw*/ {
17
17
  },
18
18
  },
19
19
  },
20
+ defaultVariants: {
21
+ size: "md",
22
+ },
20
23
  };