vueless 0.0.579 → 0.0.580

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 (240) hide show
  1. package/composables/useUI.ts +46 -60
  2. package/constants.js +3 -0
  3. package/package.json +1 -1
  4. package/types.ts +39 -48
  5. package/ui.button/UButton.vue +2 -3
  6. package/ui.button/types.ts +2 -2
  7. package/ui.button-link/ULink.vue +23 -24
  8. package/ui.button-link/storybook/stories.ts +2 -2
  9. package/ui.button-link/types.ts +7 -6
  10. package/ui.button-toggle/UToggle.vue +15 -16
  11. package/ui.button-toggle/storybook/stories.ts +2 -2
  12. package/ui.button-toggle/types.ts +6 -4
  13. package/ui.button-toggle-item/UToggleItem.vue +29 -20
  14. package/ui.button-toggle-item/storybook/stories.ts +2 -2
  15. package/ui.button-toggle-item/types.ts +5 -4
  16. package/ui.container-accordion/UAccordion.vue +22 -17
  17. package/ui.container-accordion/storybook/stories.ts +2 -2
  18. package/ui.container-accordion/types.ts +5 -4
  19. package/ui.container-card/UCard.vue +12 -5
  20. package/ui.container-card/storybook/stories.ts +2 -2
  21. package/ui.container-card/types.ts +4 -3
  22. package/ui.container-col/UCol.vue +11 -12
  23. package/ui.container-col/storybook/stories.ts +2 -2
  24. package/ui.container-col/types.ts +5 -3
  25. package/ui.container-divider/UDivider.vue +13 -13
  26. package/ui.container-divider/storybook/stories.ts +2 -2
  27. package/ui.container-divider/types.ts +5 -3
  28. package/ui.container-group/UGroup.vue +10 -8
  29. package/ui.container-group/storybook/stories.ts +2 -2
  30. package/ui.container-group/types.ts +5 -3
  31. package/ui.container-groups/UGroups.vue +10 -7
  32. package/ui.container-groups/storybook/stories.ts +2 -2
  33. package/ui.container-groups/types.ts +5 -3
  34. package/ui.container-modal/UModal.vue +43 -43
  35. package/ui.container-modal/storybook/stories.ts +2 -3
  36. package/ui.container-modal/types.ts +5 -3
  37. package/ui.container-modal-confirm/UModalConfirm.vue +14 -17
  38. package/ui.container-modal-confirm/storybook/stories.ts +8 -6
  39. package/ui.container-modal-confirm/types.ts +5 -3
  40. package/ui.container-page/UPage.vue +32 -31
  41. package/ui.container-page/storybook/stories.ts +2 -2
  42. package/ui.container-page/types.ts +4 -3
  43. package/ui.container-row/URow.vue +10 -13
  44. package/ui.container-row/storybook/stories.ts +2 -2
  45. package/ui.container-row/types.ts +5 -3
  46. package/ui.data-list/UDataList.vue +40 -51
  47. package/ui.data-list/storybook/stories.ts +2 -2
  48. package/ui.data-list/types.ts +4 -4
  49. package/ui.data-table/UTable.vue +61 -60
  50. package/ui.data-table/types.ts +4 -3
  51. package/ui.dropdown-badge/UDropdownBadge.vue +21 -25
  52. package/ui.dropdown-badge/storybook/stories.ts +3 -3
  53. package/ui.dropdown-badge/types.ts +4 -3
  54. package/ui.dropdown-button/UDropdownButton.vue +20 -23
  55. package/ui.dropdown-button/storybook/stories.ts +3 -3
  56. package/ui.dropdown-button/types.ts +4 -3
  57. package/ui.dropdown-link/UDropdownLink.vue +20 -23
  58. package/ui.dropdown-link/storybook/stories.ts +3 -3
  59. package/ui.dropdown-link/types.ts +4 -3
  60. package/ui.dropdown-list/UDropdownList.vue +28 -32
  61. package/ui.dropdown-list/storybook/stories.ts +4 -4
  62. package/ui.dropdown-list/types.ts +4 -4
  63. package/ui.form-calendar/UCalendar.vue +36 -34
  64. package/ui.form-calendar/UCalendarDayView.vue +28 -23
  65. package/ui.form-calendar/UCalendarMonthView.vue +24 -19
  66. package/ui.form-calendar/UCalendarYearView.vue +24 -19
  67. package/ui.form-calendar/config.ts +2 -2
  68. package/ui.form-calendar/storybook/stories.ts +2 -2
  69. package/ui.form-calendar/types.ts +8 -7
  70. package/ui.form-checkbox/UCheckbox.vue +23 -21
  71. package/ui.form-checkbox/storybook/stories.ts +2 -2
  72. package/ui.form-checkbox/types.ts +7 -5
  73. package/ui.form-checkbox-group/UCheckboxGroup.vue +17 -14
  74. package/ui.form-checkbox-group/storybook/stories.ts +2 -2
  75. package/ui.form-checkbox-group/types.ts +6 -6
  76. package/ui.form-checkbox-multi-state/UCheckboxMultiState.vue +33 -14
  77. package/ui.form-checkbox-multi-state/storybook/stories.ts +2 -2
  78. package/ui.form-checkbox-multi-state/types.ts +4 -4
  79. package/ui.form-color-picker/UColorPicker.vue +23 -21
  80. package/ui.form-color-picker/storybook/stories.ts +2 -2
  81. package/ui.form-color-picker/types.ts +5 -5
  82. package/ui.form-date-picker/UDatePicker.vue +42 -27
  83. package/ui.form-date-picker/config.ts +5 -5
  84. package/ui.form-date-picker/types.ts +5 -2
  85. package/ui.form-date-picker-range/UDatePickerRange.vue +80 -53
  86. package/ui.form-date-picker-range/types.ts +7 -4
  87. package/ui.form-input/UInput.vue +32 -28
  88. package/ui.form-input/storybook/stories.ts +2 -2
  89. package/ui.form-input/types.ts +5 -3
  90. package/ui.form-input-file/UInputFile.vue +37 -32
  91. package/ui.form-input-file/storybook/stories.ts +2 -2
  92. package/ui.form-input-file/types.ts +6 -4
  93. package/ui.form-input-money/UInputMoney.vue +13 -18
  94. package/ui.form-input-money/storybook/stories.ts +2 -2
  95. package/ui.form-input-money/types.ts +5 -3
  96. package/ui.form-input-number/UInputNumber.vue +23 -24
  97. package/ui.form-input-number/types.ts +4 -2
  98. package/ui.form-input-rating/UInputRating.vue +24 -19
  99. package/ui.form-input-rating/storybook/stories.ts +2 -2
  100. package/ui.form-input-rating/types.ts +5 -3
  101. package/ui.form-input-search/UInputSearch.vue +22 -20
  102. package/ui.form-input-search/storybook/stories.ts +2 -2
  103. package/ui.form-input-search/types.ts +5 -3
  104. package/ui.form-label/ULabel.vue +19 -11
  105. package/ui.form-label/config.ts +0 -1
  106. package/ui.form-label/storybook/stories.ts +2 -2
  107. package/ui.form-label/types.ts +10 -8
  108. package/ui.form-radio/URadio.vue +22 -12
  109. package/ui.form-radio/storybook/stories.ts +2 -2
  110. package/ui.form-radio/types.ts +5 -5
  111. package/ui.form-radio-group/URadioGroup.vue +16 -12
  112. package/ui.form-radio-group/storybook/stories.ts +2 -2
  113. package/ui.form-radio-group/types.ts +7 -7
  114. package/ui.form-select/USelect.vue +53 -39
  115. package/ui.form-switch/USwitch.vue +30 -23
  116. package/ui.form-switch/storybook/stories.ts +2 -2
  117. package/ui.form-switch/types.ts +5 -3
  118. package/ui.form-textarea/UTextarea.vue +19 -15
  119. package/ui.form-textarea/storybook/stories.ts +2 -2
  120. package/ui.form-textarea/types.ts +5 -3
  121. package/ui.image-avatar/UAvatar.vue +12 -11
  122. package/ui.image-avatar/types.ts +4 -2
  123. package/ui.image-icon/UIcon.vue +31 -18
  124. package/ui.image-icon/storybook/stories.ts +2 -2
  125. package/ui.image-icon/types.ts +12 -5
  126. package/ui.loader/ULoader.vue +11 -9
  127. package/ui.loader/storybook/stories.ts +2 -2
  128. package/ui.loader/types.ts +10 -3
  129. package/ui.loader-overlay/ULoaderOverlay.vue +11 -7
  130. package/ui.loader-overlay/storybook/stories.ts +2 -2
  131. package/ui.loader-overlay/types.ts +4 -3
  132. package/ui.loader-progress/ULoaderProgress.vue +14 -10
  133. package/ui.loader-progress/storybook/stories.ts +2 -2
  134. package/ui.loader-progress/types.ts +4 -3
  135. package/ui.navigation-pagination/UPagination.vue +34 -33
  136. package/ui.navigation-pagination/storybook/stories.ts +2 -2
  137. package/ui.navigation-pagination/types.ts +4 -3
  138. package/ui.navigation-progress/StepperProgress.vue +25 -12
  139. package/ui.navigation-progress/UProgress.vue +12 -12
  140. package/ui.navigation-progress/types.ts +4 -3
  141. package/ui.navigation-tab/UTab.vue +18 -9
  142. package/ui.navigation-tab/storybook/stories.ts +2 -2
  143. package/ui.navigation-tab/types.ts +4 -3
  144. package/ui.navigation-tabs/UTabs.vue +13 -8
  145. package/ui.navigation-tabs/storybook/stories.ts +2 -2
  146. package/ui.navigation-tabs/types.ts +5 -5
  147. package/ui.other-dot/UDot.vue +10 -8
  148. package/ui.other-dot/storybook/stories.ts +2 -2
  149. package/ui.other-dot/types.ts +4 -3
  150. package/ui.text-alert/UAlert.vue +24 -27
  151. package/ui.text-alert/storybook/stories.ts +2 -2
  152. package/ui.text-alert/types.ts +4 -3
  153. package/ui.text-badge/UBadge.vue +25 -13
  154. package/ui.text-badge/storybook/stories.ts +2 -2
  155. package/ui.text-badge/types.ts +4 -3
  156. package/ui.text-block/UText.vue +10 -9
  157. package/ui.text-block/storybook/stories.ts +2 -2
  158. package/ui.text-block/types.ts +4 -3
  159. package/ui.text-empty/UEmpty.vue +22 -19
  160. package/ui.text-empty/storybook/stories.ts +2 -2
  161. package/ui.text-empty/types.ts +4 -3
  162. package/ui.text-file/UFile.vue +23 -20
  163. package/ui.text-file/storybook/stories.ts +2 -2
  164. package/ui.text-file/types.ts +4 -3
  165. package/ui.text-files/UFiles.vue +16 -10
  166. package/ui.text-files/storybook/stories.ts +2 -2
  167. package/ui.text-files/types.ts +4 -3
  168. package/ui.text-header/UHeader.vue +11 -11
  169. package/ui.text-header/storybook/stories.ts +2 -2
  170. package/ui.text-header/types.ts +4 -3
  171. package/ui.text-money/UMoney.vue +20 -27
  172. package/ui.text-money/storybook/stories.ts +2 -2
  173. package/ui.text-money/types.ts +4 -3
  174. package/ui.text-notify/UNotify.vue +58 -41
  175. package/ui.text-notify/config.ts +3 -3
  176. package/ui.text-notify/constants.ts +18 -20
  177. package/ui.text-notify/storybook/stories.ts +2 -2
  178. package/ui.text-notify/types.ts +10 -5
  179. package/ui.text-notify/utilNotify.ts +17 -11
  180. package/utils/helper.ts +5 -5
  181. package/utils/storybook.ts +11 -1
  182. package/utils/ui.ts +19 -9
  183. package/web-types.json +521 -368
  184. package/ui.button-link/useAttrs.ts +0 -20
  185. package/ui.button-toggle/useAttrs.ts +0 -12
  186. package/ui.button-toggle-item/useAttrs.ts +0 -29
  187. package/ui.container-accordion/useAttrs.ts +0 -26
  188. package/ui.container-card/useAttrs.ts +0 -12
  189. package/ui.container-col/useAttrs.ts +0 -12
  190. package/ui.container-divider/useAttrs.ts +0 -17
  191. package/ui.container-group/useAttrs.ts +0 -12
  192. package/ui.container-groups/useAttrs.ts +0 -12
  193. package/ui.container-modal/useAttrs.ts +0 -12
  194. package/ui.container-modal-confirm/useAttrs.ts +0 -12
  195. package/ui.container-page/useAttrs.ts +0 -12
  196. package/ui.container-row/useAttrs.ts +0 -12
  197. package/ui.data-list/useAttrs.ts +0 -12
  198. package/ui.data-table/useAttrs.ts +0 -31
  199. package/ui.dropdown-badge/useAttrs.ts +0 -26
  200. package/ui.dropdown-button/useAttrs.ts +0 -26
  201. package/ui.dropdown-link/useAttrs.ts +0 -26
  202. package/ui.dropdown-list/useAttrs.ts +0 -12
  203. package/ui.form-calendar/useAttrs.ts +0 -12
  204. package/ui.form-checkbox/useAttrs.ts +0 -29
  205. package/ui.form-checkbox-group/useAttrs.ts +0 -12
  206. package/ui.form-checkbox-multi-state/useAttrs.ts +0 -37
  207. package/ui.form-color-picker/useAttrs.ts +0 -15
  208. package/ui.form-date-picker/useAttrs.ts +0 -43
  209. package/ui.form-date-picker-range/useAttrs.ts +0 -53
  210. package/ui.form-input/useAttrs.ts +0 -31
  211. package/ui.form-input-file/useAttrs.ts +0 -21
  212. package/ui.form-input-money/useAttrs.ts +0 -15
  213. package/ui.form-input-number/useAttrs.ts +0 -15
  214. package/ui.form-input-rating/useAttrs.ts +0 -14
  215. package/ui.form-input-search/useAttrs.ts +0 -15
  216. package/ui.form-label/useAttrs.ts +0 -20
  217. package/ui.form-radio/useAttrs.ts +0 -29
  218. package/ui.form-radio-group/useAttrs.ts +0 -12
  219. package/ui.form-select/useAttrs.js +0 -19
  220. package/ui.form-switch/useAttrs.ts +0 -28
  221. package/ui.form-textarea/useAttrs.ts +0 -21
  222. package/ui.image-avatar/useAttrs.ts +0 -12
  223. package/ui.image-icon/useAttrs.ts +0 -12
  224. package/ui.loader/useAttrs.ts +0 -12
  225. package/ui.loader-overlay/useAttrs.ts +0 -12
  226. package/ui.loader-progress/useAttrs.ts +0 -12
  227. package/ui.navigation-pagination/useAttrs.ts +0 -12
  228. package/ui.navigation-progress/useAttrs.ts +0 -17
  229. package/ui.navigation-tab/useAttrs.ts +0 -28
  230. package/ui.navigation-tabs/useAttrs.ts +0 -12
  231. package/ui.other-dot/useAttrs.ts +0 -12
  232. package/ui.text-alert/useAttrs.ts +0 -12
  233. package/ui.text-badge/useAttrs.ts +0 -21
  234. package/ui.text-block/useAttrs.ts +0 -12
  235. package/ui.text-empty/useAttrs.ts +0 -12
  236. package/ui.text-file/useAttrs.ts +0 -12
  237. package/ui.text-files/useAttrs.ts +0 -12
  238. package/ui.text-header/useAttrs.ts +0 -12
  239. package/ui.text-money/useAttrs.ts +0 -12
  240. package/ui.text-notify/useAttrs.ts +0 -12
@@ -1,5 +1,6 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
+ import type { ComponentConfig } from "../types.ts";
3
4
  import type { DateLocale } from "./utilFormatting.ts";
4
5
 
5
6
  export type RangeDate =
@@ -9,13 +10,13 @@ export type RangeDate =
9
10
  export type DateValue = Date | string | RangeDate | null;
10
11
 
11
12
  export type Locale = typeof defaultConfig.i18n;
12
- export type Config = Partial<typeof defaultConfig>;
13
+ export type Config = typeof defaultConfig;
13
14
 
14
15
  export function isRangeDate(value: Date | string | RangeDate | null): value is RangeDate {
15
- return !(value instanceof Date || typeof value === "string") && value !== null;
16
+ return typeof value === "object" && value !== null && "to" in value && "from" in value;
16
17
  }
17
18
 
18
- export interface UCalendarProps<TModelValue> {
19
+ export interface UCalendarProps<TModelValue extends DateValue> {
19
20
  /**
20
21
  * Calendar value (JavaScript Date object or string formatted in given `dateFormat` or object when `range` enabled).
21
22
  */
@@ -74,7 +75,7 @@ export interface UCalendarProps<TModelValue> {
74
75
  /**
75
76
  * Component config object.
76
77
  */
77
- config?: Config;
78
+ config?: ComponentConfig<Config>;
78
79
 
79
80
  /**
80
81
  * Data-test attribute for automated testing.
@@ -88,9 +89,9 @@ export interface UCalendarViewProps {
88
89
  activeDate: Date | null;
89
90
  activeMonth: Date | null;
90
91
  locale: DateLocale;
91
- dateFormat: string | undefined;
92
+ dateFormat?: string;
92
93
  range: boolean;
93
- maxDate: Date | string | undefined;
94
- minDate: Date | string | undefined;
94
+ maxDate?: Date | string;
95
+ minDate?: Date | string;
95
96
  config: Config;
96
97
  }
@@ -2,17 +2,17 @@
2
2
  import { inject, ref, onMounted, computed, watchEffect, toValue, useId } from "vue";
3
3
  import { isEqual } from "lodash-es";
4
4
 
5
+ import useUI from "../composables/useUI.ts";
6
+ import { getDefaults } from "../utils/ui.ts";
7
+
5
8
  import UIcon from "../ui.image-icon/UIcon.vue";
6
9
  import ULabel from "../ui.form-label/ULabel.vue";
7
10
 
8
- import { getDefault } from "../utils/ui.ts";
9
-
10
11
  import defaultConfig from "./config.ts";
11
12
  import { UCheckbox } from "./constants.ts";
12
- import useAttrs from "./useAttrs.ts";
13
13
 
14
14
  import type { UnknownObject } from "../types.ts";
15
- import type { UCheckboxProps, IconSize } from "./types.ts";
15
+ import type { Props, IconSize, Config } from "./types.ts";
16
16
 
17
17
  defineOptions({ inheritAttrs: false });
18
18
 
@@ -25,17 +25,13 @@ const setCheckboxGroupCheckedItems = inject<((value: UnknownObject[]) => void) |
25
25
  const getCheckboxGroupColor = inject("getCheckboxGroupColor", null);
26
26
  const getCheckboxSize = inject("getCheckboxSize", null);
27
27
 
28
- const props = withDefaults(defineProps<UCheckboxProps>(), {
29
- labelAlign: getDefault<UCheckboxProps>(defaultConfig, UCheckbox).labelAlign,
30
- color: getDefault<UCheckboxProps>(defaultConfig, UCheckbox).color,
31
- size: getDefault<UCheckboxProps>(defaultConfig, UCheckbox).size,
32
- disabled: getDefault<UCheckboxProps>(defaultConfig, UCheckbox).disabled,
33
- partial: getDefault<UCheckboxProps>(defaultConfig, UCheckbox).partial,
34
- name: "",
28
+ const props = withDefaults(defineProps<Props>(), {
29
+ ...getDefaults<Props, Config>(defaultConfig, UCheckbox),
30
+ modelValue: false,
35
31
  value: "",
36
32
  trueValue: true,
37
33
  falseValue: false,
38
- dataTest: "",
34
+ label: "",
39
35
  });
40
36
 
41
37
  const emit = defineEmits([
@@ -58,14 +54,6 @@ const checkboxColor = ref(props.color);
58
54
 
59
55
  const elementId = props.id || useId();
60
56
 
61
- const { config, checkboxAttrs, iconWrapperAttrs, checkboxLabelAttrs, checkedIconAttrs } = useAttrs(
62
- props,
63
- {
64
- checkboxColor,
65
- checkboxSize,
66
- },
67
- );
68
-
69
57
  const iconSize = computed(() => {
70
58
  const sizes = {
71
59
  sm: "2xs",
@@ -129,6 +117,20 @@ function onChange() {
129
117
  emit("update:modelValue", newModelValue);
130
118
  emit("input", newModelValue);
131
119
  }
120
+
121
+ /**
122
+ * Get element / nested component attributes for each config token ✨
123
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
124
+ */
125
+ const mutatedProps = computed(() => ({
126
+ color: checkboxColor.value,
127
+ size: checkboxSize.value,
128
+ label: Boolean(props.label),
129
+ error: Boolean(props.error),
130
+ }));
131
+
132
+ const { config, checkboxAttrs, iconWrapperAttrs, checkboxLabelAttrs, checkedIconAttrs } =
133
+ useUI<Config>(defaultConfig, mutatedProps);
132
134
  </script>
133
135
 
134
136
  <template>
@@ -160,7 +162,7 @@ function onChange() {
160
162
  <label v-if="isChecked" v-bind="iconWrapperAttrs" :for="elementId">
161
163
  <UIcon
162
164
  internal
163
- :name="partial ? config?.defaults?.partiallyCheckedIcon : config?.defaults?.checkedIcon"
165
+ :name="partial ? config.defaults.partiallyCheckedIcon : config.defaults.checkedIcon"
164
166
  :size="iconSize"
165
167
  color="white"
166
168
  v-bind="checkedIconAttrs"
@@ -11,9 +11,9 @@ import UBadge from "../../ui.text-badge/UBadge.vue";
11
11
  import UCol from "../../ui.container-col/UCol.vue";
12
12
 
13
13
  import type { Meta, StoryFn } from "@storybook/vue3";
14
- import type { UCheckboxProps } from "../types.ts";
14
+ import type { Props } from "../types.ts";
15
15
 
16
- interface UCheckboxArgs extends UCheckboxProps {
16
+ interface UCheckboxArgs extends Props {
17
17
  slotTemplate?: string;
18
18
  enum: "size";
19
19
  }
@@ -1,19 +1,21 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
- import type { UnknownObject, UnknownArray } from "../types.ts";
3
+ import type { ComponentConfig, UnknownObject, UnknownArray } from "../types.ts";
4
4
 
5
- export type Config = Partial<typeof defaultConfig>;
5
+ export type Config = typeof defaultConfig;
6
6
 
7
7
  export type IconSize = "2xs" | "xs" | "sm";
8
8
 
9
9
  export interface UCheckboxOption {
10
- value?: unknown;
10
+ value?: string | number | boolean | UnknownObject | UnknownArray;
11
+ falseValue?: string | number | boolean | UnknownObject | UnknownArray;
12
+ trueValue?: string | number | boolean | UnknownObject | UnknownArray;
11
13
  label?: string;
12
14
  icon?: string;
13
15
  description?: string;
14
16
  }
15
17
 
16
- export interface UCheckboxProps {
18
+ export interface Props {
17
19
  /**
18
20
  * Checkbox value.
19
21
  */
@@ -107,7 +109,7 @@ export interface UCheckboxProps {
107
109
  /**
108
110
  * Component config object.
109
111
  */
110
- config?: Config;
112
+ config?: ComponentConfig<Config>;
111
113
 
112
114
  /**
113
115
  * Data-test attribute for automated testing.
@@ -2,26 +2,25 @@
2
2
  import { provide, ref, watch } from "vue";
3
3
  import { isEqual } from "lodash-es";
4
4
 
5
- import { getDefault } from "../utils/ui.ts";
5
+ import useUI from "../composables/useUI.ts";
6
+ import { getDefaults } from "../utils/ui.ts";
6
7
 
7
8
  import ULabel from "../ui.form-label/ULabel.vue";
8
9
  import UCheckbox from "../ui.form-checkbox/UCheckbox.vue";
9
10
 
10
11
  import { UCheckboxGroup } from "./constants.ts";
11
12
  import defaultConfig from "./config.ts";
12
- import useAttrs from "./useAttrs.ts";
13
13
 
14
14
  import type { UnknownObject } from "../types.ts";
15
- import type { UCheckboxGroupProps } from "./types.ts";
15
+ import type { Props, Config } from "./types.ts";
16
16
 
17
17
  defineOptions({ inheritAttrs: false });
18
18
 
19
- const props = withDefaults(defineProps<UCheckboxGroupProps>(), {
20
- size: getDefault<UCheckboxGroupProps>(defaultConfig, UCheckboxGroup).size,
21
- color: getDefault<UCheckboxGroupProps>(defaultConfig, UCheckboxGroup).color,
22
- disabled: getDefault<UCheckboxGroupProps>(defaultConfig, UCheckboxGroup).disabled,
23
- name: "",
24
- dataTest: "",
19
+ const props = withDefaults(defineProps<Props>(), {
20
+ ...getDefaults<Props, Config>(defaultConfig, UCheckboxGroup),
21
+ modelValue: () => [],
22
+ options: () => [],
23
+ label: "",
25
24
  });
26
25
 
27
26
  const emit = defineEmits([
@@ -32,9 +31,7 @@ const emit = defineEmits([
32
31
  "update:modelValue",
33
32
  ]);
34
33
 
35
- const checkedItems = ref<UnknownObject[]>([]);
36
-
37
- const { groupLabelAttrs, groupCheckboxAttrs, listAttrs } = useAttrs(props);
34
+ const checkedItems = ref([] as UnknownObject[]);
38
35
 
39
36
  provide<(value: UnknownObject[]) => void>(
40
37
  "setCheckboxGroupCheckedItems",
@@ -52,7 +49,7 @@ watch(
52
49
  () => props?.modelValue?.length,
53
50
  (newValue, oldValue) => {
54
51
  if (!isEqual(newValue, oldValue)) {
55
- checkedItems.value = props.modelValue || [];
52
+ checkedItems.value = props.modelValue;
56
53
  }
57
54
  },
58
55
  { immediate: true },
@@ -61,6 +58,12 @@ watch(
61
58
  function onChangeCheckedItems() {
62
59
  emit("update:modelValue", checkedItems.value);
63
60
  }
61
+
62
+ /**
63
+ * Get element / nested component attributes for each config token ✨
64
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
65
+ */
66
+ const { groupLabelAttrs, groupCheckboxAttrs, listAttrs } = useUI<Config>(defaultConfig);
64
67
  </script>
65
68
 
66
69
  <template>
@@ -79,7 +82,7 @@ function onChangeCheckedItems() {
79
82
  <slot>
80
83
  <UCheckbox
81
84
  v-for="(option, index) in options"
82
- :key="option.id"
85
+ :key="index"
83
86
  :model-value="modelValue"
84
87
  :value="option.value"
85
88
  :true-value="option.trueValue"
@@ -12,10 +12,10 @@ import UCol from "../../ui.container-col/UCol.vue";
12
12
  import URow from "../../ui.container-row/URow.vue";
13
13
 
14
14
  import type { Meta, StoryFn } from "@storybook/vue3";
15
- import type { UCheckboxGroupProps } from "../types.ts";
15
+ import type { Props } from "../types.ts";
16
16
  import type { UnknownObject, UnknownArray } from "../../types.ts";
17
17
 
18
- interface UCheckboxGroupArgs extends UCheckboxGroupProps {
18
+ interface UCheckboxGroupArgs extends Props {
19
19
  slotTemplate?: string;
20
20
  enum: "size" | "color";
21
21
  value?: boolean | string | number | UnknownArray | UnknownObject;
@@ -1,11 +1,11 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
- import type { UnknownObject } from "../types.ts";
4
- import type { UCheckboxProps } from "../ui.form-checkbox/types.ts";
3
+ import type { UnknownObject, ComponentConfig } from "../types.ts";
4
+ import type { UCheckboxOption } from "../ui.form-checkbox/types.ts";
5
5
 
6
- export type Config = Partial<typeof defaultConfig>;
6
+ export type Config = typeof defaultConfig;
7
7
 
8
- export interface UCheckboxGroupProps {
8
+ export interface Props {
9
9
  /**
10
10
  * Checkbox group value.
11
11
  */
@@ -14,7 +14,7 @@ export interface UCheckboxGroupProps {
14
14
  /**
15
15
  * Checkbox group options.
16
16
  */
17
- options?: UCheckboxProps[];
17
+ options?: UCheckboxOption[];
18
18
 
19
19
  /**
20
20
  * Checkbox group label.
@@ -74,7 +74,7 @@ export interface UCheckboxGroupProps {
74
74
  /**
75
75
  * Component config object.
76
76
  */
77
- config?: Config;
77
+ config?: ComponentConfig<Config>;
78
78
 
79
79
  /**
80
80
  * Data-test attribute for automated testing.
@@ -1,24 +1,25 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref, watchEffect } from "vue";
3
+ import { cloneDeep } from "../utils/helper.ts";
4
+
5
+ import useUI from "../composables/useUI.ts";
6
+ import { getDefaults } from "../utils/ui.ts";
3
7
 
4
- import { getDefault } from "../utils/ui.ts";
5
8
  import UCheckbox from "../ui.form-checkbox/UCheckbox.vue";
6
9
 
7
10
  import defaultConfig from "./config.ts";
8
11
  import { UCheckboxMultiState } from "./constants.ts";
9
- import useAttrs from "./useAttrs.ts";
10
12
 
11
- import type { UCheckboxMultiStateProps } from "./types.ts";
12
- import type { UCheckboxOption } from "../ui.form-checkbox/types.ts";
13
+ import type { Props, Config } from "./types.ts";
14
+ import type { UCheckboxOption, Config as UCheckboxConfig } from "../ui.form-checkbox/types.ts";
15
+ import type { ComponentConfig } from "../types.ts";
13
16
 
14
17
  defineOptions({ inheritAttrs: false });
15
18
 
16
- const props = withDefaults(defineProps<UCheckboxMultiStateProps>(), {
17
- size: getDefault<UCheckboxMultiStateProps>(defaultConfig, UCheckboxMultiState).size,
18
- color: getDefault<UCheckboxMultiStateProps>(defaultConfig, UCheckboxMultiState).color,
19
- placement: getDefault<UCheckboxMultiStateProps>(defaultConfig, UCheckboxMultiState).placement,
20
- disabled: getDefault<UCheckboxMultiStateProps>(defaultConfig, UCheckboxMultiState).disabled,
21
- dataTest: "",
19
+ const props = withDefaults(defineProps<Props>(), {
20
+ ...getDefaults<Props, Config>(defaultConfig, UCheckboxMultiState),
21
+ modelValue: false,
22
+ options: () => [],
22
23
  });
23
24
 
24
25
  const emit = defineEmits([
@@ -33,11 +34,9 @@ const index = ref(0);
33
34
  const isChecked = ref(false);
34
35
 
35
36
  const selected = computed<UCheckboxOption>(() => {
36
- return props.options?.[index.value] || { icon: undefined };
37
+ return props.options[index.value] || { icon: undefined };
37
38
  });
38
39
 
39
- const { multiStateCheckboxAttrs } = useAttrs(props, { selected });
40
-
41
40
  watchEffect(setIndex);
42
41
 
43
42
  function setIndex() {
@@ -51,7 +50,7 @@ function setIndex() {
51
50
  }
52
51
 
53
52
  function setChecked() {
54
- setTimeout(() => (isChecked.value = !!props?.options?.[index.value].icon), 0);
53
+ setTimeout(() => (isChecked.value = !!props?.options[index.value].icon), 0);
55
54
  }
56
55
 
57
56
  function onClickCheckbox() {
@@ -62,6 +61,26 @@ function onClickCheckbox() {
62
61
 
63
62
  emit("update:modelValue", selected?.value?.value);
64
63
  }
64
+
65
+ /**
66
+ * Get element / nested component attributes for each config token ✨
67
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
68
+ */
69
+ const { multiStateCheckboxAttrs: checkboxAttrs } = useUI<Config>(defaultConfig);
70
+
71
+ const multiStateCheckboxAttrs = computed(() => {
72
+ const clonedCheckboxAttrs = cloneDeep(checkboxAttrs.value) as {
73
+ config: ComponentConfig<UCheckboxConfig>;
74
+ };
75
+
76
+ if (selected.value.icon) {
77
+ clonedCheckboxAttrs.config.defaults = clonedCheckboxAttrs.config.defaults || {};
78
+
79
+ clonedCheckboxAttrs.config.defaults.checkedIcon = selected.value.icon;
80
+ }
81
+
82
+ return clonedCheckboxAttrs;
83
+ });
65
84
  </script>
66
85
 
67
86
  <template>
@@ -9,9 +9,9 @@ import UCheckboxMultiState from "../../ui.form-checkbox-multi-state/UCheckboxMul
9
9
  import URow from "../../ui.container-row/URow.vue";
10
10
 
11
11
  import type { Meta, StoryFn } from "@storybook/vue3";
12
- import type { UCheckboxMultiStateProps } from "../types.ts";
12
+ import type { Props } from "../types.ts";
13
13
 
14
- interface UCheckboxMultiStateArgs extends UCheckboxMultiStateProps {
14
+ interface UCheckboxMultiStateArgs extends Props {
15
15
  slotTemplate?: string;
16
16
  enum: "size";
17
17
  }
@@ -1,10 +1,10 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
- import type { UnknownObject } from "../types.ts";
3
+ import type { UnknownObject, ComponentConfig } from "../types.ts";
4
4
 
5
- export type Config = Partial<typeof defaultConfig>;
5
+ export type Config = typeof defaultConfig;
6
6
 
7
- export interface UCheckboxMultiStateProps {
7
+ export interface Props {
8
8
  /**
9
9
  * Checkbox value.
10
10
  */
@@ -63,7 +63,7 @@ export interface UCheckboxMultiStateProps {
63
63
  /**
64
64
  * Component config object.
65
65
  */
66
- config?: Config;
66
+ config?: ComponentConfig<Config>;
67
67
 
68
68
  /**
69
69
  * Data-test attribute for automated testing.
@@ -1,26 +1,24 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, useId } from "vue";
3
3
 
4
+ import useUI from "../composables/useUI.ts";
5
+ import { getDefaults } from "../utils/ui.ts";
6
+
4
7
  import UIcon from "../ui.image-icon/UIcon.vue";
5
8
  import URadio from "../ui.form-radio/URadio.vue";
6
9
  import ULabel from "../ui.form-label/ULabel.vue";
7
- import { getDefault } from "../utils/ui.ts";
8
10
 
9
11
  import { UColorPicker } from "./constants.ts";
10
12
  import defaultConfig from "./config.ts";
11
- import useAttrs from "./useAttrs.ts";
12
13
 
13
- import type { UColorPickerProps, IconSize } from "./types.ts";
14
+ import type { Props, IconSize, Config } from "./types.ts";
14
15
 
15
16
  defineOptions({ inheritAttrs: false });
16
17
 
17
- const props = withDefaults(defineProps<UColorPickerProps>(), {
18
- name: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).name,
19
- size: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).size,
20
- colorOptions: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).colorOptions,
21
- disabled: getDefault<UColorPickerProps>(defaultConfig, UColorPicker).disabled,
22
- dataTest: "",
23
- config: () => ({}),
18
+ const props = withDefaults(defineProps<Props>(), {
19
+ ...getDefaults<Props, Config>(defaultConfig, UColorPicker),
20
+ modelValue: "",
21
+ label: "",
24
22
  });
25
23
 
26
24
  const emit = defineEmits([
@@ -33,16 +31,6 @@ const emit = defineEmits([
33
31
 
34
32
  const elementId = props.id || useId();
35
33
 
36
- const {
37
- config,
38
- colorPickerLabelAttrs,
39
- listAttrs,
40
- colorPickerRadioAttrs,
41
- unselectedColorPickerRadioAttrs,
42
- unselectedIconAttrs,
43
- unselectedAttrs,
44
- } = useAttrs(props);
45
-
46
34
  const selectedItem = computed({
47
35
  get: () => props.modelValue,
48
36
  set: (value) => emit("update:modelValue", value),
@@ -63,6 +51,20 @@ const iconSize = computed(() => {
63
51
  function onUpdateValue(value: string) {
64
52
  selectedItem.value = value;
65
53
  }
54
+
55
+ /**
56
+ * Get element / nested component attributes for each config token ✨
57
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
58
+ */
59
+ const {
60
+ config,
61
+ colorPickerLabelAttrs,
62
+ listAttrs,
63
+ colorPickerRadioAttrs,
64
+ unselectedColorPickerRadioAttrs,
65
+ unselectedIconAttrs,
66
+ unselectedAttrs,
67
+ } = useUI<Config>(defaultConfig);
66
68
  </script>
67
69
 
68
70
  <template>
@@ -95,7 +97,7 @@ function onUpdateValue(value: string) {
95
97
  internal
96
98
  :size="iconSize"
97
99
  color="gray"
98
- :name="config.defaults?.unselectedIcon"
100
+ :name="config.defaults.unselectedIcon"
99
101
  v-bind="unselectedIconAttrs"
100
102
  />
101
103
  </label>
@@ -9,9 +9,9 @@ import UColorPicker from "../../ui.form-color-picker/UColorPicker.vue";
9
9
  import UCol from "../../ui.container-col/UCol.vue";
10
10
 
11
11
  import type { Meta, StoryFn } from "@storybook/vue3";
12
- import type { UColorPickerProps } from "../types.ts";
12
+ import type { Props } from "../types.ts";
13
13
 
14
- interface UColorPickerArgs extends UColorPickerProps {
14
+ interface UColorPickerArgs extends Props {
15
15
  slotTemplate?: string;
16
16
  enum: "size";
17
17
  }
@@ -1,12 +1,12 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
- import type { BrandColors } from "../types.ts";
3
+ import type { BrandColors, ComponentConfig } from "../types.ts";
4
4
 
5
- export type Config = Partial<typeof defaultConfig>;
5
+ export type Config = typeof defaultConfig;
6
6
 
7
7
  export type IconSize = "3xs" | "2xs" | "xs" | "sm" | "md";
8
8
 
9
- export interface UColorPickerProps {
9
+ export interface Props {
10
10
  /**
11
11
  * Color picker selected value.
12
12
  */
@@ -40,7 +40,7 @@ export interface UColorPickerProps {
40
40
  /**
41
41
  * Color picker color list.
42
42
  */
43
- colorOptions?: Array<BrandColors>;
43
+ colorOptions?: BrandColors;
44
44
 
45
45
  /**
46
46
  * Set color picker disabled.
@@ -55,7 +55,7 @@ export interface UColorPickerProps {
55
55
  /**
56
56
  * Component config object.
57
57
  */
58
- config?: Config;
58
+ config?: ComponentConfig<Config>;
59
59
 
60
60
  /**
61
61
  * Data-test attribute for automated testing.