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,37 +1,27 @@
1
1
  <script setup lang="ts">
2
2
  import { nextTick, computed, provide, ref, useId, useTemplateRef } 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 ULink from "../ui.button-link/ULink.vue";
6
9
  import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
7
10
 
8
- import { getDefault } from "../utils/ui.ts";
9
-
10
11
  import { vClickOutside } from "../directives";
11
12
 
12
13
  import { UDropdownLink } from "./constants.ts";
13
14
  import defaultConfig from "./config.ts";
14
- import useAttrs from "./useAttrs.ts";
15
15
 
16
- import type { UDropdownLinkProps, IconSize } from "./types.ts";
16
+ import type { Props, IconSize, Config } from "./types.ts";
17
17
  import type { Option } from "../ui.dropdown-list/types.ts";
18
18
 
19
19
  defineOptions({ inheritAttrs: false });
20
20
 
21
- const props = withDefaults(defineProps<UDropdownLinkProps>(), {
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ ...getDefaults<Props, Config>(defaultConfig, UDropdownLink),
22
23
  options: () => [],
23
- labelKey: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).labelKey,
24
- color: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).color,
25
- size: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).size,
26
- underlined: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).underlined,
27
- dashed: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).dashed,
28
- noRing: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).noRing,
29
- noIcon: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).noIcon,
30
- yPosition: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).yPosition,
31
- xPosition: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).xPosition,
32
- id: "",
33
- dataTest: "",
34
- config: () => ({}),
24
+ label: "",
35
25
  });
36
26
 
37
27
  const emit = defineEmits([
@@ -51,11 +41,6 @@ const dropdownListRef = useTemplateRef<UDropdownListRef>("dropdown-list");
51
41
 
52
42
  const elementId = props.id || useId();
53
43
 
54
- const { config, wrapperAttrs, dropdownLinkAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
55
- props,
56
- { isShownOptions },
57
- );
58
-
59
44
  const iconSize = computed(() => {
60
45
  const sizes = {
61
46
  sm: "2xs",
@@ -85,6 +70,18 @@ function onClickList() {
85
70
  function onClickOption(option: Option) {
86
71
  emit("clickOption", option);
87
72
  }
73
+
74
+ /**
75
+ * Get element / nested component attributes for each config token ✨
76
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
77
+ */
78
+ const mutatedProps = computed(() => ({
79
+ /* component state, not a props */
80
+ opened: isShownOptions.value,
81
+ }));
82
+
83
+ const { config, wrapperAttrs, dropdownLinkAttrs, dropdownListAttrs, dropdownIconAttrs } =
84
+ useUI<Config>(defaultConfig, mutatedProps);
88
85
  </script>
89
86
 
90
87
  <template>
@@ -133,7 +130,7 @@ function onClickOption(option: Option) {
133
130
  interactive
134
131
  :color="color"
135
132
  :size="iconSize"
136
- :name="config.defaults?.dropdownIcon"
133
+ :name="config.defaults.dropdownIcon"
137
134
  v-bind="dropdownIconAttrs"
138
135
  :data-test="`${dataTest}-dropdown`"
139
136
  @click="onClickLink"
@@ -10,14 +10,14 @@ import URow from "../../ui.container-row/URow.vue";
10
10
  import UIcon from "../../ui.image-icon/UIcon.vue";
11
11
 
12
12
  import type { Meta, StoryFn } from "@storybook/vue3";
13
- import type { UDropdownLinkProps } from "../types.ts";
13
+ import type { Props } from "../types.ts";
14
14
 
15
- interface DefaultUDropdownLinkArgs extends UDropdownLinkProps {
15
+ interface DefaultUDropdownLinkArgs extends Props {
16
16
  slotTemplate?: string;
17
17
  }
18
18
 
19
19
  interface EnumUDropdownLinkArgs extends DefaultUDropdownLinkArgs {
20
- enum: keyof Pick<UDropdownLinkProps, "size" | "color">;
20
+ enum: keyof Pick<Props, "size" | "color">;
21
21
  }
22
22
 
23
23
  export default {
@@ -1,12 +1,13 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
3
  import type { Option } from "../ui.dropdown-list/types.ts";
4
+ import type { ComponentConfig } from "../types.ts";
4
5
 
5
- export type Config = Partial<typeof defaultConfig>;
6
+ export type Config = typeof defaultConfig;
6
7
 
7
8
  export type IconSize = "sm" | "2xs" | "xs";
8
9
 
9
- export interface UDropdownLinkProps {
10
+ export interface Props {
10
11
  /**
11
12
  * Link label.
12
13
  */
@@ -96,7 +97,7 @@ export interface UDropdownLinkProps {
96
97
  /**
97
98
  * Component config object.
98
99
  */
99
- config?: Config;
100
+ config?: ComponentConfig<Config>;
100
101
 
101
102
  /**
102
103
  * Data-test attribute for automated testing.
@@ -2,20 +2,20 @@
2
2
  import { watch, computed, useId, ref, useTemplateRef, nextTick } from "vue";
3
3
  import { merge } from "lodash-es";
4
4
 
5
+ import useUI from "../composables/useUI.ts";
6
+ import { getDefaults } from "../utils/ui.ts";
7
+ import { isMac } from "../utils/platform.ts";
8
+
5
9
  import UIcon from "../ui.image-icon/UIcon.vue";
6
10
  import UButton from "../ui.button/UButton.vue";
7
11
 
8
- import { getDefault } from "../utils/ui.ts";
9
- import { isMac } from "../utils/platform.ts";
10
-
11
12
  import usePointer from "./usePointer.ts";
12
- import useAttrs from "./useAttrs.ts";
13
13
  import { useLocale } from "../composables/useLocale.ts";
14
14
 
15
15
  import defaultConfig from "./config.ts";
16
16
  import { UDropdownList } from "./constants.ts";
17
17
 
18
- import type { Option, UDropdownListProps } from "./types.ts";
18
+ import type { Option, Props, Config } from "./types.ts";
19
19
  import type { UnknownObject } from "../types.ts";
20
20
 
21
21
  defineOptions({ inheritAttrs: false });
@@ -23,17 +23,9 @@ defineOptions({ inheritAttrs: false });
23
23
  // TODO: Use props and regular modal value
24
24
  const modelValue = defineModel<string | number | UnknownObject>({ default: "" });
25
25
 
26
- const props = withDefaults(defineProps<UDropdownListProps>(), {
26
+ const props = withDefaults(defineProps<Props>(), {
27
+ ...getDefaults<Props, Config>(defaultConfig, UDropdownList),
27
28
  options: () => [],
28
- labelKey: getDefault<UDropdownListProps>(defaultConfig, UDropdownList).labelKey,
29
- valueKey: getDefault<UDropdownListProps>(defaultConfig, UDropdownList).valueKey,
30
- addOption: getDefault<UDropdownListProps>(defaultConfig, UDropdownList).addOption,
31
- size: getDefault<UDropdownListProps>(defaultConfig, UDropdownList).size,
32
- visibleOptions: getDefault<UDropdownListProps>(defaultConfig, UDropdownList).visibleOptions,
33
- disabled: getDefault<UDropdownListProps>(defaultConfig, UDropdownList).disabled,
34
- id: "",
35
- dataTest: "",
36
- config: () => ({}),
37
29
  });
38
30
 
39
31
  const emit = defineEmits([
@@ -59,22 +51,6 @@ const { pointer, pointerDirty, pointerSet, pointerBackward, pointerForward, poin
59
51
 
60
52
  const elementId = props.id || useId();
61
53
 
62
- const {
63
- config,
64
- wrapperAttrs,
65
- listAttrs,
66
- listItemAttrs,
67
- addOptionLabelWrapperAttrs,
68
- addOptionLabelAttrs,
69
- addOptionLabelHotkeyAttrs,
70
- addOptionButtonAttrs,
71
- addOptionIconAttrs,
72
- optionAttrs,
73
- subGroupAttrs,
74
- groupAttrs,
75
- optionContentAttrs,
76
- } = useAttrs(props);
77
-
78
54
  const { tm } = useLocale();
79
55
 
80
56
  const i18nGlobal = tm(UDropdownList);
@@ -239,6 +215,26 @@ defineExpose({
239
215
  */
240
216
  wrapperRef,
241
217
  });
218
+
219
+ /**
220
+ * Get element / nested component attributes for each config token ✨
221
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
222
+ */
223
+ const {
224
+ config,
225
+ wrapperAttrs,
226
+ listAttrs,
227
+ listItemAttrs,
228
+ addOptionLabelWrapperAttrs,
229
+ addOptionLabelAttrs,
230
+ addOptionLabelHotkeyAttrs,
231
+ addOptionButtonAttrs,
232
+ addOptionIconAttrs,
233
+ optionAttrs,
234
+ subGroupAttrs,
235
+ groupAttrs,
236
+ optionContentAttrs,
237
+ } = useUI<Config>(defaultConfig);
242
238
  </script>
243
239
 
244
240
  <template>
@@ -344,7 +340,7 @@ defineExpose({
344
340
  internal
345
341
  color="white"
346
342
  size="xs"
347
- :name="config.defaults?.addOptionIcon"
343
+ :name="config.defaults.addOptionIcon"
348
344
  v-bind="addOptionIconAttrs"
349
345
  />
350
346
  </UButton>
@@ -9,14 +9,14 @@ import UDropdownList from "../../ui.dropdown-list/UDropdownList.vue";
9
9
  import URow from "../../ui.container-row/URow.vue";
10
10
 
11
11
  import type { Meta, StoryFn } from "@storybook/vue3";
12
- import type { UDropdownListProps } from "../types.ts";
12
+ import type { Option, Props } from "../types.ts";
13
13
 
14
- interface DefaultUDropdownListArgs extends UDropdownListProps {
14
+ interface DefaultUDropdownListArgs extends Props {
15
15
  slotTemplate?: string;
16
16
  }
17
17
 
18
18
  interface EnumUDropdownListArgs extends DefaultUDropdownListArgs {
19
- enum: keyof Pick<UDropdownListProps, "size">;
19
+ enum: keyof Pick<Props, "size">;
20
20
  }
21
21
 
22
22
  export default {
@@ -120,7 +120,7 @@ OptionSettings.args = {
120
120
  {
121
121
  label: "option 3",
122
122
  id: "3",
123
- onClick: (option) => alert("onClick option 3 " + JSON.stringify(option)),
123
+ onClick: (option: Option) => alert("onClick option 3 " + JSON.stringify(option)),
124
124
  },
125
125
  ],
126
126
  };
@@ -1,7 +1,7 @@
1
- import type { UnknownObject } from "../types.ts";
2
1
  import defaultConfig from "./config.ts";
2
+ import type { ComponentConfig, UnknownObject } from "../types.ts";
3
3
 
4
- export type Config = Partial<typeof defaultConfig>;
4
+ export type Config = typeof defaultConfig;
5
5
  export type OnClickOption = (option: Omit<Option, "onClick">) => void;
6
6
 
7
7
  export interface BaseOption {
@@ -16,7 +16,7 @@ export interface Option extends BaseOption {
16
16
  [key: string]: string | number | boolean | UnknownObject | OnClickOption | undefined;
17
17
  }
18
18
 
19
- export interface UDropdownListProps {
19
+ export interface Props {
20
20
  /**
21
21
  * List options.
22
22
  */
@@ -60,7 +60,7 @@ export interface UDropdownListProps {
60
60
  /**
61
61
  * Component config object.
62
62
  */
63
- config?: Config;
63
+ config?: ComponentConfig<Config>;
64
64
 
65
65
  /**
66
66
  * Data-test attribute for automated testing.
@@ -2,10 +2,12 @@
2
2
  import { computed, ref, watch, useTemplateRef } from "vue";
3
3
  import { merge } from "lodash-es";
4
4
 
5
- import UButton from "../ui.button/UButton.vue";
6
- import { getDefault } from "../utils/ui.ts";
5
+ import useUI from "../composables/useUI.ts";
6
+ import { getDefaults } from "../utils/ui.ts";
7
7
  import { isRangeDate } from "./types.ts";
8
8
 
9
+ import UButton from "../ui.button/UButton.vue";
10
+
9
11
  import {
10
12
  parseDate,
11
13
  formatDate,
@@ -16,7 +18,6 @@ import {
16
18
 
17
19
  import { getDateWithoutTime, addMonths, addDays, addYears, getSortedLocale } from "./utilDate.ts";
18
20
 
19
- import useAttrs from "./useAttrs.ts";
20
21
  import { useLocale } from "../composables/useLocale.ts";
21
22
 
22
23
  import {
@@ -38,7 +39,7 @@ import {
38
39
 
39
40
  import defaultConfig from "./config.ts";
40
41
 
41
- import type { UCalendarProps, DateValue, RangeDate, Locale } from "./types.ts";
42
+ import type { UCalendarProps, DateValue, RangeDate, Locale, Config } from "./types.ts";
42
43
  import type { ComputedRef, Ref } from "vue";
43
44
  import type { DateLocale } from "./utilFormatting.ts";
44
45
 
@@ -53,21 +54,16 @@ defineOptions({ inheritAttrs: false });
53
54
  type Props = UCalendarProps<TModelValue>;
54
55
  const props = withDefaults(defineProps<Props>(), {
55
56
  view: View.Day,
56
- range: getDefault<Props>(defaultConfig, UCalendar).range,
57
- timepicker: getDefault<Props>(defaultConfig, UCalendar).timepicker,
58
- dateFormat: getDefault<Props>(defaultConfig, UCalendar).dateFormat,
59
- dateTimeFormat: getDefault<Props>(defaultConfig, UCalendar).dateTimeFormat,
60
- userDateFormat: getDefault<Props>(defaultConfig, UCalendar).userDateFormat,
61
- userDateTimeFormat: getDefault<Props>(defaultConfig, UCalendar).userDateTimeFormat,
62
- tabindex: getDefault<Props>(defaultConfig, UCalendar).tabindex,
63
- dataTest: "",
64
- config: () => ({}),
57
+ ...getDefaults<Props, Config>(defaultConfig, UCalendar),
58
+ modelValue: undefined,
59
+ minDate: undefined,
60
+ maxDate: undefined,
65
61
  });
66
62
 
67
63
  const emit = defineEmits([
68
64
  /**
69
65
  * Triggers when date value changes.
70
- * @property {object} newDate
66
+ * @property {object} modelValue
71
67
  */
72
68
  "update:modelValue",
73
69
  /**
@@ -97,21 +93,6 @@ const emit = defineEmits([
97
93
 
98
94
  const { tm } = useLocale();
99
95
 
100
- const {
101
- config,
102
- wrapperAttrs,
103
- navigationAttrs,
104
- viewSwitchButtonAttrs,
105
- nextPrevButtonAttrs,
106
- timepickerAttrs,
107
- timepickerLabelAttrs,
108
- timepickerInputWrapperAttrs,
109
- timepickerInputHoursAttrs,
110
- timepickerInputMinutesAttrs,
111
- timepickerInputSecondsAttrs,
112
- timepickerSubmitButtonAttrs,
113
- } = useAttrs(props);
114
-
115
96
  const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
116
97
  const hoursRef = useTemplateRef<HTMLInputElement>("hours-input");
117
98
  const minutesRef = useTemplateRef<HTMLInputElement>("minutes-input");
@@ -184,12 +165,12 @@ const userFormatLocale = computed(() => {
184
165
  const { months, weekdays } = currentLocale.value;
185
166
 
186
167
  const monthsLonghand =
187
- Boolean(props.config?.i18n?.months?.userFormat) || Boolean(i18nGlobal?.months?.userFormat)
168
+ Boolean(currentLocale.value.months.userFormat) || Boolean(i18nGlobal?.months?.userFormat)
188
169
  ? months.userFormat
189
170
  : months.longhand;
190
171
 
191
172
  const weekdaysLonghand =
192
- Boolean(props.config?.i18n?.weekdays?.userFormat) || Boolean(i18nGlobal?.weekdays?.userFormat)
173
+ Boolean(currentLocale.value.weekdays.userFormat) || Boolean(i18nGlobal?.weekdays?.userFormat)
193
174
  ? weekdays.userFormat
194
175
  : weekdays.longhand;
195
176
 
@@ -211,7 +192,9 @@ const localValue = computed({
211
192
  get: () => {
212
193
  if (props.range) {
213
194
  const isModelValueRangeType =
214
- typeof props.modelValue === "object" && !(props.modelValue instanceof Date);
195
+ props.modelValue &&
196
+ typeof props.modelValue === "object" &&
197
+ !(props.modelValue instanceof Date);
215
198
 
216
199
  const modelValue = isModelValueRangeType
217
200
  ? (props.modelValue as RangeDate)
@@ -656,6 +639,25 @@ defineExpose({
656
639
  */
657
640
  wrapperRef,
658
641
  });
642
+
643
+ /**
644
+ * Get element / nested component attributes for each config token ✨
645
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
646
+ */
647
+ const {
648
+ config,
649
+ wrapperAttrs,
650
+ navigationAttrs,
651
+ viewSwitchButtonAttrs,
652
+ nextPrevButtonAttrs,
653
+ timepickerAttrs,
654
+ timepickerLabelAttrs,
655
+ timepickerInputWrapperAttrs,
656
+ timepickerInputHoursAttrs,
657
+ timepickerInputMinutesAttrs,
658
+ timepickerInputSecondsAttrs,
659
+ timepickerSubmitButtonAttrs,
660
+ } = useUI<Config>(defaultConfig);
659
661
  </script>
660
662
 
661
663
  <template>
@@ -667,7 +669,7 @@ defineExpose({
667
669
  size="sm"
668
670
  color="grayscale"
669
671
  variant="thirdary"
670
- :left-icon="config?.defaults?.prevIcon"
672
+ :left-icon="config.defaults.prevIcon"
671
673
  v-bind="nextPrevButtonAttrs"
672
674
  @mousedown.prevent.capture
673
675
  @click="onClickPrevButton"
@@ -695,7 +697,7 @@ defineExpose({
695
697
  size="sm"
696
698
  color="grayscale"
697
699
  variant="thirdary"
698
- :left-icon="config?.defaults?.nextIcon"
700
+ :left-icon="config.defaults.nextIcon"
699
701
  v-bind="nextPrevButtonAttrs"
700
702
  @mousedown.prevent.capture
701
703
  @click="onClickNextButton"
@@ -1,6 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from "vue";
3
3
 
4
+ import useUI from "../composables/useUI.ts";
5
+
4
6
  import { formatDate, dateIsOutOfRange } from "./utilCalendar.ts";
5
7
  import {
6
8
  isToday,
@@ -10,11 +12,10 @@ import {
10
12
  isAnotherMothDay,
11
13
  } from "./utilDate.ts";
12
14
 
13
- import useAttrs from "./useAttrs.ts";
14
-
15
+ import defaultConfig from "./config.ts";
15
16
  import { DAYS_IN_WEEK, START_WEEK } from "./constants.ts";
16
17
 
17
- import type { UCalendarViewProps, UCalendarProps } from "./types.ts";
18
+ import type { UCalendarViewProps, Config } from "./types.ts";
18
19
 
19
20
  import UButton from "../ui.button/UButton.vue";
20
21
 
@@ -22,26 +23,6 @@ const props = defineProps<UCalendarViewProps>();
22
23
 
23
24
  const emit = defineEmits(["input"]);
24
25
 
25
- const {
26
- dayViewAttrs,
27
- weekDaysAttrs,
28
- weekDayAttrs,
29
- daysAttrs,
30
- dayAttrs,
31
- currentDayAttrs,
32
- dayInRangeAttrs,
33
- currentDayInRangeAttrs,
34
- anotherMonthDayAttrs,
35
- firstDayInRangeAttrs,
36
- anotherMonthFirstDayInRangeAttrs,
37
- lastDayInRangeAttrs,
38
- anotherMonthLastDayInRangeAttrs,
39
- selectedDayAttrs,
40
- activeDayAttrs,
41
- currentLastDayInRangeAttrs,
42
- currentFirstDayInRangeAttrs,
43
- } = useAttrs(props as unknown as UCalendarProps<unknown>);
44
-
45
26
  const localSelectedDate = computed(() => {
46
27
  return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
47
28
  });
@@ -207,6 +188,30 @@ function onClickDay(day: Date) {
207
188
 
208
189
  emit("input", day);
209
190
  }
191
+
192
+ /**
193
+ * Get element / nested component attributes for each config token ✨
194
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
195
+ */
196
+ const {
197
+ dayViewAttrs,
198
+ weekDaysAttrs,
199
+ weekDayAttrs,
200
+ daysAttrs,
201
+ dayAttrs,
202
+ currentDayAttrs,
203
+ dayInRangeAttrs,
204
+ currentDayInRangeAttrs,
205
+ anotherMonthDayAttrs,
206
+ firstDayInRangeAttrs,
207
+ anotherMonthFirstDayInRangeAttrs,
208
+ lastDayInRangeAttrs,
209
+ anotherMonthLastDayInRangeAttrs,
210
+ selectedDayAttrs,
211
+ activeDayAttrs,
212
+ currentLastDayInRangeAttrs,
213
+ currentFirstDayInRangeAttrs,
214
+ } = useUI<Config>(defaultConfig);
210
215
  </script>
211
216
 
212
217
  <template>
@@ -1,14 +1,15 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from "vue";
3
3
 
4
+ import useUI from "../composables/useUI.ts";
5
+
4
6
  import { formatDate, dateIsOutOfRange } from "./utilCalendar.ts";
5
7
  import { isSameMonth, getDateWithoutTime, isCurrentMonth } from "./utilDate.ts";
6
8
 
7
- import useAttrs from "./useAttrs.ts";
8
-
9
+ import defaultConfig from "./config.ts";
9
10
  import { MONTHS_PER_VIEW } from "./constants.ts";
10
11
 
11
- import type { UCalendarViewProps, UCalendarProps } from "./types.ts";
12
+ import type { UCalendarViewProps, Config } from "./types.ts";
12
13
 
13
14
  import UButton from "../ui.button/UButton.vue";
14
15
 
@@ -16,22 +17,6 @@ const props = defineProps<UCalendarViewProps>();
16
17
 
17
18
  const emit = defineEmits(["input"]);
18
19
 
19
- const {
20
- monthViewAttrs,
21
- monthAttrs,
22
- currentMonthAttrs,
23
- currentMonthInRangeAttrs,
24
- lastMonthInRangeAttrs,
25
- firstMonthInRangeAttrs,
26
- singleMonthInRangeAttrs,
27
- monthInRangeAttrs,
28
- selectedMonthAttrs,
29
- activeMonthAttrs,
30
- currentLastMonthInRangeAttrs,
31
- currentFirstMonthInRangeAttrs,
32
- singleCurrentMonthInRangeAttrs,
33
- } = useAttrs(props as unknown as UCalendarProps<unknown>);
34
-
35
20
  const localSelectedDate = computed(() => {
36
21
  return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
37
22
  });
@@ -117,6 +102,26 @@ function isMoreThanOneMonthDiff(date: Date, dateTo: Date) {
117
102
  function onClickMonth(month: Date) {
118
103
  emit("input", month);
119
104
  }
105
+
106
+ /**
107
+ * Get element / nested component attributes for each config token ✨
108
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
109
+ */
110
+ const {
111
+ monthViewAttrs,
112
+ monthAttrs,
113
+ currentMonthAttrs,
114
+ currentMonthInRangeAttrs,
115
+ lastMonthInRangeAttrs,
116
+ firstMonthInRangeAttrs,
117
+ singleMonthInRangeAttrs,
118
+ monthInRangeAttrs,
119
+ selectedMonthAttrs,
120
+ activeMonthAttrs,
121
+ currentLastMonthInRangeAttrs,
122
+ currentFirstMonthInRangeAttrs,
123
+ singleCurrentMonthInRangeAttrs,
124
+ } = useUI<Config>(defaultConfig);
120
125
  </script>
121
126
 
122
127
  <template>
@@ -1,14 +1,15 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from "vue";
3
3
 
4
+ import useUI from "../composables/useUI.ts";
5
+
4
6
  import { formatDate, getYearsRange, dateIsOutOfRange } from "./utilCalendar.ts";
5
7
  import { isSameMonth, getDateWithoutTime, isCurrentYear } from "./utilDate.ts";
6
8
 
7
- import useAttrs from "./useAttrs.ts";
8
-
9
+ import defaultConfig from "./config.ts";
9
10
  import { YEARS_PER_VIEW } from "./constants.ts";
10
11
 
11
- import type { UCalendarProps, UCalendarViewProps } from "./types.ts";
12
+ import type { UCalendarViewProps, Config } from "./types.ts";
12
13
 
13
14
  import UButton from "../ui.button/UButton.vue";
14
15
 
@@ -16,22 +17,6 @@ const props = defineProps<UCalendarViewProps>();
16
17
 
17
18
  const emit = defineEmits(["input"]);
18
19
 
19
- const {
20
- yearViewAttrs,
21
- yearAttrs,
22
- currentYearAttrs,
23
- currentYearInRangeAttrs,
24
- firstYearInRangeAttrs,
25
- lastYearInRangeAttrs,
26
- yearInRangeAttrs,
27
- singleYearInRangeAttrs,
28
- selectedYearAttrs,
29
- activeYearAttrs,
30
- singleCurrentYearInRangeAttrs,
31
- currentLastYearInRangeAttrs,
32
- currentFirstYearInRangeAttrs,
33
- } = useAttrs(props as unknown as UCalendarProps<unknown>);
34
-
35
20
  const localSelectedDate = computed(() => {
36
21
  return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
37
22
  });
@@ -115,6 +100,26 @@ function getYearState(year: Date, index: number) {
115
100
  function onClickYear(year: Date) {
116
101
  emit("input", year);
117
102
  }
103
+
104
+ /**
105
+ * Get element / nested component attributes for each config token ✨
106
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
107
+ */
108
+ const {
109
+ yearViewAttrs,
110
+ yearAttrs,
111
+ currentYearAttrs,
112
+ currentYearInRangeAttrs,
113
+ firstYearInRangeAttrs,
114
+ lastYearInRangeAttrs,
115
+ yearInRangeAttrs,
116
+ singleYearInRangeAttrs,
117
+ selectedYearAttrs,
118
+ activeYearAttrs,
119
+ singleCurrentYearInRangeAttrs,
120
+ currentLastYearInRangeAttrs,
121
+ currentFirstYearInRangeAttrs,
122
+ } = useUI<Config>(defaultConfig);
118
123
  </script>
119
124
 
120
125
  <template>
@@ -152,11 +152,11 @@ export default /*tw*/ {
152
152
  defaults: {
153
153
  userDateFormat: "j F, Y",
154
154
  userDateTimeFormat: "j F, Y - H:i:S",
155
- range: false,
156
- timepicker: false,
157
155
  dateFormat: undefined,
158
156
  dateTimeFormat: undefined,
159
157
  tabindex: 1,
158
+ range: false,
159
+ timepicker: false,
160
160
  /* icons */
161
161
  viewSwitchIcon: "keyboard_arrow_down",
162
162
  nextIcon: "keyboard_arrow_right",
@@ -10,9 +10,9 @@ import UCalendar from "../../ui.form-calendar/UCalendar.vue";
10
10
 
11
11
  import { UCalendar as UCalendarName } from "../constants.ts";
12
12
 
13
- import type { UCalendarProps } from "../types.ts";
13
+ import type { DateValue, UCalendarProps } from "../types.ts";
14
14
 
15
- interface UCalendarArgs extends UCalendarProps<unknown> {
15
+ interface UCalendarArgs extends UCalendarProps<DateValue> {
16
16
  slotTemplate?: string;
17
17
  enum: "size";
18
18
  }