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,47 +1,43 @@
1
1
  <script setup lang="ts" generic="TModelValue extends string | Date">
2
- import { computed, nextTick, ref, useId, useTemplateRef } from "vue";
2
+ import { computed, nextTick, ref, useId, useTemplateRef, watchEffect } from "vue";
3
3
  import { merge } from "lodash-es";
4
4
 
5
+ import useUI from "../composables/useUI.ts";
6
+
5
7
  import UIcon from "../ui.image-icon/UIcon.vue";
6
8
  import UInput from "../ui.form-input/UInput.vue";
7
9
  import UCalendar from "../ui.form-calendar/UCalendar.vue";
8
10
  import { View, LocaleType, ARROW_KEYS, TOKEN_REG_EXP } from "../ui.form-calendar/constants.ts";
9
11
 
10
- import { getDefault } from "../utils/ui.ts";
12
+ import { getDefaults } from "../utils/ui.ts";
11
13
 
12
14
  import { getSortedLocale } from "../ui.form-calendar/utilDate.ts";
13
15
  import { formatDate, parseDate } from "../ui.form-calendar/utilCalendar.ts";
14
16
 
15
- import useAttrs from "./useAttrs.js";
16
17
  import { useLocale } from "../composables/useLocale.ts";
17
- import { useAutoPosition } from "../composables/useAutoPosition.ts";
18
+ import { Direction, useAutoPosition } from "../composables/useAutoPosition.ts";
18
19
 
19
20
  import defaultConfig from "./config.ts";
20
21
  import { UDatePicker } from "./constants.ts";
21
22
 
22
23
  import { vClickOutside } from "../directives";
23
24
 
24
- import type { UDatePickerProps } from "./types.ts";
25
- import type { ComponentExposed } from "../types.ts";
25
+ import type { ComputedRef } from "vue";
26
+ import type { UDatePickerProps, Config, Locale } from "./types.ts";
27
+ import type { ComponentExposed, Transition } from "../types.ts";
28
+ import type { Config as UCalendarConfig } from "../ui.form-calendar/types.ts";
26
29
  import type { DateLocale } from "../ui.form-calendar/utilFormatting.ts";
27
30
 
28
31
  defineOptions({ inheritAttrs: false });
29
32
 
30
33
  type Props = UDatePickerProps<TModelValue>;
31
34
  const props = withDefaults(defineProps<Props>(), {
32
- labelAlign: getDefault<Props>(defaultConfig, UDatePicker).labelAlign,
33
- size: getDefault<Props>(defaultConfig, UDatePicker).size,
34
- openDirectionX: getDefault<Props>(defaultConfig, UDatePicker).openDirectionX,
35
- openDirectionY: getDefault<Props>(defaultConfig, UDatePicker).openDirectionY,
36
- timepicker: getDefault<Props>(defaultConfig, UDatePicker).timepicker,
37
- dateFormat: getDefault<Props>(defaultConfig, UDatePicker).dateFormat,
38
- dateTimeFormat: getDefault<Props>(defaultConfig, UDatePicker).dateTimeFormat,
39
- userDateFormat: getDefault<Props>(defaultConfig, UDatePicker).userDateFormat,
40
- userDateTimeFormat: getDefault<Props>(defaultConfig, UDatePicker).userDateTimeFormat,
41
- rightIcon: getDefault<Props>(defaultConfig, UDatePicker).rightIcon,
42
- disabled: getDefault<Props>(defaultConfig, UDatePicker).disabled,
43
- dataTest: "",
44
- config: () => ({}),
35
+ ...getDefaults<Props, Config>(defaultConfig, UDatePicker),
36
+ modelValue: undefined,
37
+ minDate: undefined,
38
+ maxDate: undefined,
39
+ placeholder: "",
40
+ label: "",
45
41
  });
46
42
 
47
43
  const emit = defineEmits([
@@ -85,7 +81,9 @@ const localValue = computed({
85
81
  set: (value) => emit("update:modelValue", value),
86
82
  });
87
83
 
88
- const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
84
+ const currentLocale: ComputedRef<Locale> = computed(() =>
85
+ merge(defaultConfig.i18n, i18nGlobal, props.config.i18n),
86
+ );
89
87
 
90
88
  const clickOutsideOptions = computed(() => ({ ignore: [datepickerInputRef.value?.inputRef] }));
91
89
 
@@ -108,12 +106,6 @@ const locale = computed(() => {
108
106
 
109
107
  const elementId = props.id || useId();
110
108
 
111
- const { config, datepickerInputAttrs, datepickerInputActiveAttrs, calendarAttrs, wrapperAttrs } =
112
- useAttrs(props, {
113
- isTop,
114
- isRight,
115
- });
116
-
117
109
  function activate() {
118
110
  isShownCalendar.value = true;
119
111
 
@@ -248,6 +240,29 @@ defineExpose({
248
240
  */
249
241
  formattedDate,
250
242
  });
243
+
244
+ /**
245
+ * Get element / nested component attributes for each config token ✨
246
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
247
+ */
248
+ const mutatedProps = computed(() => ({
249
+ openDirectionY: isTop.value ? Direction.Top : Direction.Bottom,
250
+ openDirectionX: isRight.value ? Direction.Right : Direction.Left,
251
+ error: Boolean(props.error),
252
+ description: Boolean(props.description),
253
+ }));
254
+
255
+ const { config, datepickerInputAttrs, datepickerInputActiveAttrs, calendarAttrs, wrapperAttrs } =
256
+ useUI<Config>(defaultConfig, mutatedProps);
257
+
258
+ /* Merging DatePicker's i18n translations into Calendar's i18n translations. */
259
+ watchEffect(() => {
260
+ const calendarConfig = calendarAttrs.value.config as unknown as UCalendarConfig;
261
+
262
+ if (!calendarConfig?.i18n || props.config?.i18n) {
263
+ calendarConfig.i18n = merge(calendarConfig.i18n, config.value.i18n);
264
+ }
265
+ });
251
266
  </script>
252
267
 
253
268
  <template>
@@ -305,7 +320,7 @@ defineExpose({
305
320
  </template>
306
321
  </UInput>
307
322
 
308
- <Transition v-bind="config.calendarTransition">
323
+ <Transition v-bind="config.calendarTransition as Transition">
309
324
  <UCalendar
310
325
  v-show="isShownCalendar"
311
326
  ref="calendar"
@@ -117,18 +117,18 @@ export default /*tw*/ {
117
117
  okLabel: "Ok",
118
118
  },
119
119
  defaults: {
120
+ size: "md",
120
121
  userDateFormat: "r j F, Y",
121
122
  userDateTimeFormat: "r j F, Y - H:i:S",
122
- size: "md",
123
+ dateFormat: undefined,
124
+ dateTimeFormat: undefined,
123
125
  openDirectionX: "auto",
124
126
  openDirectionY: "auto",
125
127
  labelAlign: "topInside",
126
- timepicker: false,
127
- disabled: false,
128
- dateFormat: undefined,
129
- dateTimeFormat: undefined,
130
128
  maxDate: undefined,
131
129
  minDate: undefined,
130
+ timepicker: false,
131
+ disabled: false,
132
132
  /* icons */
133
133
  rightIcon: "calendar_month-fill",
134
134
  },
@@ -1,6 +1,9 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
- export type Config = Partial<typeof defaultConfig>;
3
+ import type { ComponentConfig } from "../types.ts";
4
+
5
+ export type Locale = typeof defaultConfig.i18n;
6
+ export type Config = typeof defaultConfig;
4
7
 
5
8
  export interface UDatePickerProps<TModelValue> {
6
9
  /**
@@ -106,7 +109,7 @@ export interface UDatePickerProps<TModelValue> {
106
109
  /**
107
110
  * Component config object.
108
111
  */
109
- config?: Config;
112
+ config?: ComponentConfig<Config>;
110
113
 
111
114
  /**
112
115
  * Data-test attribute for automated testing.
@@ -1,6 +1,10 @@
1
1
  <script setup lang="ts" generic="TModelValue extends RangeDate">
2
- import { computed, watch, ref, nextTick, provide, useId, useTemplateRef } from "vue";
3
- import { getDefault } from "../utils/ui.ts";
2
+ import { computed, watch, ref, nextTick, provide, useId, useTemplateRef, watchEffect } from "vue";
3
+
4
+ import { merge } from "lodash-es";
5
+
6
+ import useUI from "../composables/useUI.ts";
7
+ import { getDefaults } from "../utils/ui.ts";
4
8
 
5
9
  import UIcon from "../ui.image-icon/UIcon.vue";
6
10
  import UInput from "../ui.form-input/UInput.vue";
@@ -36,8 +40,7 @@ import {
36
40
  type DatePeriodRange,
37
41
  } from "./utilDateRange.ts";
38
42
 
39
- import useAttrs from "./useAttrs.ts";
40
- import { useAutoPosition } from "../composables/useAutoPosition.ts";
43
+ import { Direction, useAutoPosition } from "../composables/useAutoPosition.ts";
41
44
  import { useLocale } from "./useLocale.ts";
42
45
  import { useUserFormat } from "./useUserFormat.ts";
43
46
 
@@ -59,31 +62,22 @@ import type {
59
62
  UDatePickerRangeProps,
60
63
  UDatePickerRangeInputsAttrs,
61
64
  UDatePickerRangePeriodMenuAttrs,
65
+ Config,
62
66
  } from "./types.ts";
63
- import type { RangeDate } from "../ui.form-calendar/types.ts";
67
+ import type { RangeDate, Config as UCalendarConfig } from "../ui.form-calendar/types.ts";
64
68
  import type { ComponentExposed } from "../types.ts";
65
69
 
66
70
  defineOptions({ inheritAttrs: false });
67
71
 
68
72
  type Props = UDatePickerRangeProps<TModelValue>;
69
73
  const props = withDefaults(defineProps<Props>(), {
70
- openDirectionX: getDefault<Props>(defaultConfig, UDatePickerRange).openDirectionX,
71
- openDirectionY: getDefault<Props>(defaultConfig, UDatePickerRange).openDirectionY,
72
- variant: getDefault<Props>(defaultConfig, UDatePickerRange).variant,
73
- dateFormat: getDefault<Props>(defaultConfig, UDatePickerRange).dateFormat,
74
- userDateFormat: getDefault<Props>(defaultConfig, UDatePickerRange).userDateFormat,
75
- size: getDefault<Props>(defaultConfig, UDatePickerRange).size,
76
- rightIcon: getDefault<Props>(defaultConfig, UDatePickerRange).rightIcon,
77
- labelAlign: getDefault<Props>(defaultConfig, UDatePickerRange).labelAlign,
78
- disabled: getDefault<Props>(defaultConfig, UDatePickerRange).disabled,
79
- customRangeButton: () => ({
80
- range: { from: null, to: null },
81
- label: "",
82
- description: "",
83
- }),
84
- id: "",
85
- dataTest: "",
86
- config: () => ({}),
74
+ ...getDefaults<Props, Config>(defaultConfig, UDatePickerRange),
75
+ customRangeButton: () => ({ range: { from: null, to: null } }),
76
+ modelValue: undefined,
77
+ minDate: undefined,
78
+ maxDate: undefined,
79
+ placeholder: "",
80
+ label: "",
87
81
  });
88
82
 
89
83
  const emit = defineEmits([
@@ -219,34 +213,6 @@ const clickOutsideOptions = computed(() => {
219
213
  };
220
214
  });
221
215
 
222
- const {
223
- config,
224
- wrapperAttrs,
225
- calendarAttrs,
226
- datepickerInputAttrs,
227
- menuAttrs,
228
- buttonWrapperAttrs,
229
- buttonAttrs,
230
- shiftRangeButtonAttrs,
231
- rangeInputWrapperAttrs,
232
- rangeInputErrorAttrs,
233
- datepickerActiveInputAttrs,
234
- rangeInputFirstAttrs,
235
- rangeInputLastAttrs,
236
- periodRowAttrs,
237
- periodButtonAttrs,
238
- periodButtonActiveAttrs,
239
- periodDateAttrs,
240
- periodDateCurrentAttrs,
241
- periodDateSelectedAttrs,
242
- periodDateCurrentSelectedAttrs,
243
- periodDateListAttrs,
244
- rangeSwitchButtonAttrs,
245
- rangeSwitchTitleAttrs,
246
- rangeSwitchWrapperAttrs,
247
- customRangeDescriptionAttrs,
248
- } = useAttrs(props, { isShownMenu, isTop, isRight, isPeriod });
249
-
250
216
  const { userFormatDate } = useUserFormat(
251
217
  localValue,
252
218
  userFormatLocale,
@@ -319,7 +285,14 @@ function isDatePeriodOutOfRange(datePeriod: DatePeriodRange) {
319
285
  props.maxDate,
320
286
  locale.value,
321
287
  props.dateFormat,
322
- ) || dateIsOutOfRange(datePeriod.endRange, props.minDate, props.maxDate, props.dateFormat)
288
+ ) ||
289
+ dateIsOutOfRange(
290
+ datePeriod.endRange,
291
+ props.minDate,
292
+ props.maxDate,
293
+ locale.value,
294
+ props.dateFormat,
295
+ )
323
296
  );
324
297
  }
325
298
 
@@ -549,6 +522,60 @@ function onMouseoverCalendar() {
549
522
  function onInputCalendar(value: RangeDate) {
550
523
  calendarInnerValue.value = value;
551
524
  }
525
+
526
+ /**
527
+ * Get element / nested component attributes for each config token ✨
528
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
529
+ */
530
+ const mutatedProps = computed(() => ({
531
+ openDirectionY: isTop.value ? Direction.Top : Direction.Bottom,
532
+ openDirectionX: isRight.value ? Direction.Right : Direction.Left,
533
+ error: Boolean(props.error),
534
+ description: Boolean(props.description),
535
+ /* component state, not a props */
536
+ opened: isShownMenu.value,
537
+ week: isPeriod.value.week,
538
+ month: isPeriod.value.month,
539
+ quarter: isPeriod.value.quarter,
540
+ year: isPeriod.value.year,
541
+ }));
542
+
543
+ const {
544
+ config,
545
+ wrapperAttrs,
546
+ calendarAttrs,
547
+ datepickerInputAttrs,
548
+ menuAttrs,
549
+ buttonWrapperAttrs,
550
+ buttonAttrs,
551
+ shiftRangeButtonAttrs,
552
+ rangeInputWrapperAttrs,
553
+ rangeInputErrorAttrs,
554
+ datepickerActiveInputAttrs,
555
+ rangeInputFirstAttrs,
556
+ rangeInputLastAttrs,
557
+ periodRowAttrs,
558
+ periodButtonAttrs,
559
+ periodButtonActiveAttrs,
560
+ periodDateAttrs,
561
+ periodDateCurrentAttrs,
562
+ periodDateSelectedAttrs,
563
+ periodDateCurrentSelectedAttrs,
564
+ periodDateListAttrs,
565
+ rangeSwitchButtonAttrs,
566
+ rangeSwitchTitleAttrs,
567
+ rangeSwitchWrapperAttrs,
568
+ customRangeDescriptionAttrs,
569
+ } = useUI<Config>(defaultConfig, mutatedProps);
570
+
571
+ /* Merging DatePickerRange's i18n translations into Calendar's i18n translations. */
572
+ watchEffect(() => {
573
+ const calendarConfig = calendarAttrs.value.config as unknown as UCalendarConfig;
574
+
575
+ if (!calendarConfig.i18n || props.config?.i18n) {
576
+ calendarConfig.i18n = merge(calendarConfig.i18n, config.value.i18n);
577
+ }
578
+ });
552
579
  </script>
553
580
 
554
581
  <template>
@@ -607,7 +634,7 @@ function onInputCalendar(value: RangeDate) {
607
634
  :size="size"
608
635
  :disabled="disabled"
609
636
  variant="thirdary"
610
- :left-icon="config.defaults?.prevIcon"
637
+ :left-icon="config.defaults.prevIcon"
611
638
  v-bind="shiftRangeButtonAttrs"
612
639
  @click="onClickShiftRange(ShiftAction.Prev)"
613
640
  />
@@ -634,7 +661,7 @@ function onInputCalendar(value: RangeDate) {
634
661
  :size="size"
635
662
  :disabled="disabled"
636
663
  variant="thirdary"
637
- :left-icon="config.defaults?.nextIcon"
664
+ :left-icon="config.defaults.nextIcon"
638
665
  v-bind="shiftRangeButtonAttrs"
639
666
  @click="onClickShiftRange(ShiftAction.Next)"
640
667
  />
@@ -1,12 +1,12 @@
1
1
  import defaultConfig from "./config.ts";
2
2
  import { ShiftAction } from "./constants.ts";
3
3
 
4
- import type { UnknownObject } from "../types.ts";
5
- import type { DatePeriodRange } from "./utilDateRange.ts";
6
4
  import type { Ref } from "vue";
5
+ import type { UnknownObject, ComponentConfig } from "../types.ts";
6
+ import type { DatePeriodRange } from "./utilDateRange.ts";
7
7
 
8
8
  export type Locale = typeof defaultConfig.i18n;
9
- export type Config = Partial<typeof defaultConfig>;
9
+ export type Config = typeof defaultConfig;
10
10
  export type IsDatePeriodOutOfRange = (datePeriod: DatePeriodRange) => boolean;
11
11
  export type ShiftActions = `${ShiftAction}`;
12
12
 
@@ -19,6 +19,9 @@ export interface SortedLocale extends Omit<Locale, "weekdays" | "months"> {
19
19
  shorthand: string[];
20
20
  longhand: string[];
21
21
  };
22
+ today: string;
23
+ tomorrow: string;
24
+ yesterday: string;
22
25
  }
23
26
 
24
27
  export interface IsPeriod {
@@ -184,7 +187,7 @@ export interface UDatePickerRangeProps<TModelValue> {
184
187
  /**
185
188
  * Component config object.
186
189
  */
187
- config?: Config;
190
+ config?: ComponentConfig<Config>;
188
191
 
189
192
  /**
190
193
  * Data-test attribute for automated testing.
@@ -1,7 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { ref, computed, onMounted, useSlots, useId } from "vue";
3
3
 
4
- import { getDefault } from "../utils/ui.ts";
4
+ import useUI from "../composables/useUI.ts";
5
+ import { getDefaults } from "../utils/ui.ts";
5
6
  import { hasSlotContent } from "../utils/helper.ts";
6
7
  import { useMutationObserver } from "../composables/useMutationObserver.ts";
7
8
 
@@ -10,24 +11,16 @@ import ULabel from "../ui.form-label/ULabel.vue";
10
11
 
11
12
  import defaultConfig from "./config.ts";
12
13
  import { UInput } from "./constants.ts";
13
- import useAttrs from "./useAttrs.ts";
14
14
 
15
- import type { UInputProps, IconSize } from "./types.ts";
15
+ import type { Props, IconSize, Config } from "./types.ts";
16
16
 
17
17
  defineOptions({ inheritAttrs: false });
18
18
 
19
- const props = withDefaults(defineProps<UInputProps>(), {
20
- labelAlign: getDefault<UInputProps>(defaultConfig, UInput).labelAlign,
21
- size: getDefault<UInputProps>(defaultConfig, UInput).size,
22
- validationRule: getDefault<UInputProps>(defaultConfig, UInput).validationRule,
23
- type: getDefault<UInputProps>(defaultConfig, UInput).type,
24
- inputmode: getDefault<UInputProps>(defaultConfig, UInput).inputmode,
25
- readonly: getDefault<UInputProps>(defaultConfig, UInput).readonly,
26
- disabled: getDefault<UInputProps>(defaultConfig, UInput).disabled,
27
- noAutocomplete: getDefault<UInputProps>(defaultConfig, UInput).noAutocomplete,
19
+ const props = withDefaults(defineProps<Props>(), {
20
+ ...getDefaults<Props, Config>(defaultConfig, UInput),
28
21
  modelValue: "",
29
- dataTest: "",
30
- config: () => ({}),
22
+ label: "",
23
+ placeholder: "",
31
24
  });
32
25
 
33
26
  const emit = defineEmits([
@@ -109,18 +102,6 @@ const applyPasswordClasses = computed(() => {
109
102
 
110
103
  const elementId = props.id || useId();
111
104
 
112
- const {
113
- config,
114
- inputAttrs,
115
- wrapperAttrs,
116
- inputLabelAttrs,
117
- passwordIconAttrs,
118
- leftIconWrapperAttrs,
119
- leftIconAttrs,
120
- rightIconAttrs,
121
- rightIconWrapperAttrs,
122
- } = useAttrs(props, { applyPasswordClasses });
123
-
124
105
  const iconSize = computed(() => {
125
106
  const sizes = {
126
107
  sm: "xs",
@@ -137,8 +118,8 @@ const inputType = computed(() => {
137
118
 
138
119
  const passwordIcon = computed(() => {
139
120
  return isShownPassword.value
140
- ? config.value?.defaults?.passwordVisibleIcon || ""
141
- : config.value?.defaults?.passwordHiddenIcon || "";
121
+ ? config.value.defaults.passwordVisibleIcon || ""
122
+ : config.value.defaults.passwordHiddenIcon || "";
142
123
  });
143
124
 
144
125
  onMounted(() => {
@@ -256,6 +237,29 @@ defineExpose({
256
237
  */
257
238
  inputRef,
258
239
  });
240
+
241
+ /**
242
+ * Get element / nested component attributes for each config token ✨
243
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
244
+ */
245
+ const mutatedProps = computed(() => ({
246
+ error: Boolean(props.error),
247
+ label: Boolean(props.label),
248
+ /* component state, not a props */
249
+ typePassword: applyPasswordClasses.value,
250
+ }));
251
+
252
+ const {
253
+ config,
254
+ inputAttrs,
255
+ wrapperAttrs,
256
+ inputLabelAttrs,
257
+ passwordIconAttrs,
258
+ leftIconWrapperAttrs,
259
+ leftIconAttrs,
260
+ rightIconAttrs,
261
+ rightIconWrapperAttrs,
262
+ } = useUI<Config>(defaultConfig, mutatedProps);
259
263
  </script>
260
264
 
261
265
  <template>
@@ -11,9 +11,9 @@ import UButton from "../../ui.button/UButton.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 { UInputProps } from "../types.ts";
14
+ import type { Props } from "../types.ts";
15
15
 
16
- interface UInputArgs extends UInputProps {
16
+ interface UInputArgs extends Props {
17
17
  slotTemplate?: string;
18
18
  enum: "labelAlign" | "size" | "validationRule";
19
19
  }
@@ -1,10 +1,12 @@
1
1
  import defaultConfig from "./config.ts";
2
2
 
3
- export type Config = Partial<typeof defaultConfig>;
3
+ import type { ComponentConfig } from "../types.ts";
4
+
5
+ export type Config = typeof defaultConfig;
4
6
 
5
7
  export type IconSize = "xs" | "sm" | "md";
6
8
 
7
- export interface UInputProps {
9
+ export interface Props {
8
10
  /**
9
11
  * Input value.
10
12
  */
@@ -94,7 +96,7 @@ export interface UInputProps {
94
96
  /**
95
97
  * Component config object.
96
98
  */
97
- config?: Config;
99
+ config?: ComponentConfig<Config>;
98
100
 
99
101
  /**
100
102
  * Data-test attribute for automated testing.
@@ -2,34 +2,30 @@
2
2
  import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch, useId } 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 { hasSlotContent } from "../utils/helper.ts";
8
+ import { getFileMbSize } from "./utilFileForm.ts";
9
+
5
10
  import UText from "../ui.text-block/UText.vue";
6
11
  import ULabel from "../ui.form-label/ULabel.vue";
7
12
  import UButton from "../ui.button/UButton.vue";
8
13
  import UFiles from "../ui.text-files/UFiles.vue";
9
14
 
10
- import { getDefault } from "../utils/ui.ts";
11
- import { hasSlotContent } from "../utils/helper.ts";
12
- import { getFileMbSize } from "./utilFileForm.ts";
13
-
14
- import useAttrs from "./useAttrs.ts";
15
15
  import { useLocale } from "../composables/useLocale.ts";
16
16
 
17
17
  import { UInputFile } from "./constants.ts";
18
18
  import defaultConfig from "./config.ts";
19
19
 
20
- import type { UInputFileProps, ButtonSize } from "./types.ts";
20
+ import type { Props, ButtonSize, Config } from "./types.ts";
21
21
 
22
22
  defineOptions({ inheritAttrs: false });
23
23
 
24
- const props = withDefaults(defineProps<UInputFileProps>(), {
25
- labelAlign: getDefault<UInputFileProps>(defaultConfig, UInputFile).labelAlign,
26
- size: getDefault<UInputFileProps>(defaultConfig, UInputFile).size,
27
- maxFileSize: getDefault<UInputFileProps>(defaultConfig, UInputFile).maxFileSize,
28
- allowedFileTypes: getDefault<UInputFileProps>(defaultConfig, UInputFile).allowedFileTypes,
29
- multiple: getDefault<UInputFileProps>(defaultConfig, UInputFile).multiple,
30
- disabled: getDefault<UInputFileProps>(defaultConfig, UInputFile).disabled,
31
- dataTest: "",
32
- config: () => ({}),
24
+ const props = withDefaults(defineProps<Props>(), {
25
+ ...getDefaults<Props, Config>(defaultConfig, UInputFile),
26
+ modelValue: () => [],
27
+ allowedFileTypes: () => [],
28
+ label: "",
33
29
  });
34
30
 
35
31
  const emit = defineEmits([
@@ -53,21 +49,6 @@ const fileInputRef = ref<HTMLInputElement | null>(null);
53
49
 
54
50
  const elementId = props.id || useId();
55
51
 
56
- const {
57
- config,
58
- inputLabelAttrs,
59
- chooseFileButtonAttrs,
60
- dropzoneAttrs,
61
- descriptionTopAttrs,
62
- descriptionBottomAttrs,
63
- contentAttrs,
64
- clearButtonAttrs,
65
- placeholderAttrs,
66
- inputAttrs,
67
- fileListAttrs,
68
- buttonsAttrs,
69
- } = useAttrs(props);
70
-
71
52
  const i18nGlobal = tm(UInputFile);
72
53
  const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
73
54
 
@@ -265,6 +246,30 @@ function onClickRemoveItem(id: string | number) {
265
246
  currentFiles.value = currentFiles.value.filter((file) => file.name !== id);
266
247
  }
267
248
  }
249
+
250
+ /**
251
+ * Get element / nested component attributes for each config token ✨
252
+ * Applies: `class`, `config`, redefined default `props` and dev `vl-...` attributes.
253
+ */
254
+ const mutatedProps = computed(() => ({
255
+ error: Boolean(props.error),
256
+ label: Boolean(props.label),
257
+ }));
258
+
259
+ const {
260
+ config,
261
+ inputLabelAttrs,
262
+ chooseFileButtonAttrs,
263
+ dropzoneAttrs,
264
+ descriptionTopAttrs,
265
+ descriptionBottomAttrs,
266
+ contentAttrs,
267
+ clearButtonAttrs,
268
+ placeholderAttrs,
269
+ inputAttrs,
270
+ fileListAttrs,
271
+ buttonsAttrs,
272
+ } = useUI<Config>(defaultConfig, mutatedProps);
268
273
  </script>
269
274
 
270
275
  <template>
@@ -311,7 +316,7 @@ function onClickRemoveItem(id: string | number) {
311
316
  tag="label"
312
317
  variant="thirdary"
313
318
  :size="buttonSize"
314
- :right-icon="config.defaults?.chooseFileIcon"
319
+ :right-icon="config.defaults.chooseFileIcon"
315
320
  :label="currentLocale.uploadFile"
316
321
  :disabled="disabled"
317
322
  v-bind="chooseFileButtonAttrs"
@@ -339,7 +344,7 @@ function onClickRemoveItem(id: string | number) {
339
344
  variant="thirdary"
340
345
  :size="buttonSize"
341
346
  :disabled="disabled"
342
- :left-icon="config.defaults?.clearIcon"
347
+ :left-icon="config.defaults.clearIcon"
343
348
  v-bind="clearButtonAttrs"
344
349
  :data-test="`${dataTest}-clear`"
345
350
  @click="onClickResetFiles"
@@ -9,9 +9,9 @@ import UInputFile from "../../ui.form-input-file/UInputFile.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 { UInputFileProps } from "../types.ts";
12
+ import type { Props } from "../types.ts";
13
13
 
14
- interface UInputFileArgs extends UInputFileProps {
14
+ interface UInputFileArgs extends Props {
15
15
  slotTemplate?: string;
16
16
  enum: "labelAlign" | "size";
17
17
  }