vueless 0.0.211 → 0.0.213

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.211",
3
+ "version": "0.0.213",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -37,8 +37,8 @@
37
37
  "@release-it/bumper": "^6.0.1",
38
38
  "@vitejs/plugin-vue": "^5.0.5",
39
39
  "@vue/eslint-config-prettier": "^9.0.0",
40
- "@vueless/plugin-vite": "^0.0.36",
41
- "@vueless/storybook": "^0.0.33",
40
+ "@vueless/plugin-vite": "^0.0.37",
41
+ "@vueless/storybook": "^0.0.34",
42
42
  "@vueless/web-types": "^0.0.13",
43
43
  "autoprefixer": "^10.4.19",
44
44
  "cssnano": "^6.1.2",
@@ -1,112 +1,71 @@
1
1
  import useUI from "../../composable.ui";
2
- import { cva } from "../../service.ui";
2
+ import { cva, cx } from "../../service.ui";
3
3
 
4
4
  import { computed } from "vue";
5
5
 
6
6
  import defaultConfig from "../configs/default.config";
7
7
 
8
8
  export default function useAttrs(props) {
9
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
10
- const { nextPrevWrapper } = config.value;
11
-
12
- const cvaNextPrevWrapper = cva({
13
- base: nextPrevWrapper.base,
14
- variants: nextPrevWrapper.variants,
15
- compoundVariants: nextPrevWrapper.compoundVariants,
16
- });
17
-
18
- const optionClasses = computed(() => cvaNextPrevWrapper({ range: props.range }));
19
-
20
- const wrapperAttrs = getAttrs("wrapper");
21
- const navigationAttrs = getAttrs("navigation");
22
- const navigationSwitchViewButtonAttrs = getAttrs("navigationSwitchViewButton");
23
- const dayViewSwitchLabelAttrs = getAttrs("dayViewSwitchLabel");
24
- const dayViewSwitchLabelMonthAttrs = getAttrs("dayViewSwitchLabelMonth");
25
- const dayViewSwitchLabelIconAttrs = getAttrs("dayViewSwitchLabelIcon");
26
- const nextPrevButtonAttrs = getAttrs("nextPrevButton");
27
- const nextIconAttrs = getAttrs("nextIcon");
28
- const prevIconAttrs = getAttrs("prevIcon");
29
- const dayViewAttrs = getAttrs("dayView");
30
- const weekDaysAttrs = getAttrs("weekDays");
31
- const weekDayAttrs = getAttrs("weekDay");
32
- const daysAttrs = getAttrs("days");
33
- const activeDayAttrs = getAttrs("activeDay");
34
- const selectedDayAttrs = getAttrs("selectedDay");
35
- const currentDayAttrs = getAttrs("currentDay");
36
- const inRangeDayAttrs = getAttrs("inRangeDay");
37
- const inRangeFirstDayAttrs = getAttrs("inRangeFirstDay");
38
- const inRangeLastDayAttrs = getAttrs("inRangeLastDay");
39
- const anotherMonthDayAttrs = getAttrs("anotherMonthDay");
40
- const monthViewAttrs = getAttrs("monthView");
41
- const selectedMonthAttrs = getAttrs("selectedMonth");
42
- const activeMonthAttrs = getAttrs("activeMonth");
43
- const yearViewAttrs = getAttrs("yearView");
44
- const selectedYearAttrs = getAttrs("selectedYear");
45
- const activeYearAttrs = getAttrs("activeYear");
46
- const timepickerAttrs = getAttrs("timepicker");
47
- const timepickerLabelAttrs = getAttrs("timepickerLabel");
48
- const timepickerInput = getAttrs("timepickerInput");
49
- const timepickerInputWrapperAttrs = getAttrs("timepickerInputWrapper");
50
- const timepickerLeftInputAttrs = getAttrs("timepickerLeftInput", {
51
- classes: timepickerInput.value.class,
52
- });
53
- const timepickerRightInputAttrs = getAttrs("timepickerRightInput", {
54
- classes: timepickerInput.value.class,
55
- });
56
- const timepickerSubmitButtonAttrs = getAttrs("timepickerSubmitButton");
57
-
58
- const nextPrevWrapperAttrs = getAttrs("nextPrevWrapper", { classes: optionClasses });
59
-
60
- // TODO: Need to find other solution
61
- const dayAttrs = (classes) => {
62
- return getAttrs("day", { classes }).value;
63
- };
9
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
10
+ const attrs = {};
64
11
 
65
- const monthAttrs = (classes) => {
66
- return getAttrs("month", { classes, isComponent: true }).value;
67
- };
12
+ for (const key in defaultConfig) {
13
+ if (isSystemKey(key)) continue;
68
14
 
69
- const yearAttrs = (classes) => {
70
- return getAttrs("year", { classes, isComponent: true }).value;
71
- };
15
+ const classes = computed(() => {
16
+ const value = config.value[key];
17
+
18
+ if (value.variants || value.compoundVariants) {
19
+ return cva(value)({
20
+ ...props,
21
+ });
22
+ }
23
+
24
+ return "";
25
+ });
26
+
27
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
28
+
29
+ if (key === "timepickerLeftInput") {
30
+ const timepickerLeftInputAttrs = attrs[`${key}Attrs`];
31
+
32
+ attrs[`${key}Attrs`] = computed(() => ({
33
+ ...timepickerLeftInputAttrs.value,
34
+ class: cx([config.value.timepickerInput, timepickerLeftInputAttrs.value.class]),
35
+ }));
36
+ }
37
+
38
+ if (key === "timepickerRightInput") {
39
+ const timepickerRightInputAttrs = attrs[`${key}Attrs`];
40
+
41
+ attrs[`${key}Attrs`] = computed(() => ({
42
+ ...timepickerRightInputAttrs.value,
43
+ class: cx([config.value.timepickerInput, timepickerRightInputAttrs.value.class]),
44
+ }));
45
+ }
46
+
47
+ // TODO: Need to find other solution
48
+ if (key === "day") {
49
+ attrs[`${key}Attrs`] = (classes) => {
50
+ return getAttrs("day", { classes }).value;
51
+ };
52
+ }
53
+
54
+ if (key === "month") {
55
+ attrs[`${key}Attrs`] = (classes) => {
56
+ return getAttrs("month", { classes }).value;
57
+ };
58
+ }
59
+
60
+ if (key === "year") {
61
+ attrs[`${key}Attrs`] = (classes) => {
62
+ return getAttrs("year", { classes }).value;
63
+ };
64
+ }
65
+ }
72
66
 
73
67
  return {
68
+ ...attrs,
74
69
  config,
75
- wrapperAttrs,
76
- navigationAttrs,
77
- navigationSwitchViewButtonAttrs,
78
- dayViewSwitchLabelAttrs,
79
- dayViewSwitchLabelMonthAttrs,
80
- dayViewSwitchLabelIconAttrs,
81
- nextIconAttrs,
82
- nextPrevButtonAttrs,
83
- prevIconAttrs,
84
- dayViewAttrs,
85
- weekDaysAttrs,
86
- weekDayAttrs,
87
- daysAttrs,
88
- activeDayAttrs,
89
- selectedDayAttrs,
90
- currentDayAttrs,
91
- anotherMonthDayAttrs,
92
- dayAttrs,
93
- inRangeDayAttrs,
94
- inRangeFirstDayAttrs,
95
- inRangeLastDayAttrs,
96
- monthViewAttrs,
97
- selectedMonthAttrs,
98
- activeMonthAttrs,
99
- monthAttrs,
100
- yearViewAttrs,
101
- selectedYearAttrs,
102
- activeYearAttrs,
103
- yearAttrs,
104
- timepickerAttrs,
105
- timepickerLabelAttrs,
106
- timepickerInputWrapperAttrs,
107
- timepickerLeftInputAttrs,
108
- timepickerRightInputAttrs,
109
- timepickerSubmitButtonAttrs,
110
- nextPrevWrapperAttrs,
111
70
  };
112
71
  }
@@ -14,10 +14,10 @@ export default /*tw*/ {
14
14
  },
15
15
  },
16
16
  },
17
- nextPrevButton: "",
18
- nextIcon: "",
17
+ nextPrevButton: "{UButton}",
18
+ nextIcon: "{UIcon}",
19
19
  nextIconName: "keyboard_arrow_right",
20
- prevIcon: "",
20
+ prevIcon: "{UIcon}",
21
21
  prevIconName: "keyboard_arrow_left",
22
22
  dayView: "",
23
23
  weekDays: "grid grid-cols-7",
@@ -32,19 +32,19 @@ export default /*tw*/ {
32
32
  currentDay: "hover:bg-brand-100 border-2 border-brand-900",
33
33
  anotherMonthDay: "hover:bg-brand-100 text-brand-400",
34
34
  monthView: "grid grid-cols-4 items-center justify-center",
35
- month: "mx-auto flex h-12 w-full rounded-lg hover:!bg-brand-900 hover:text-white",
35
+ month: "{UButton} mx-auto flex h-12 w-full rounded-lg hover:!bg-brand-900 hover:text-white",
36
36
  selectedMonth: "bg-brand-900 hover:bg-brand-900 text-white",
37
37
  activeMonth: "bg-brand-100",
38
38
  yearView: "grid grid-cols-4 items-center justify-center",
39
- year: "mx-auto flex h-12 w-full rounded-lg hover:!bg-brand-900 hover:text-white",
39
+ year: "{UButton} mx-auto flex h-12 w-full rounded-lg hover:!bg-brand-900 hover:text-white",
40
40
  selectedYear: "bg-brand-900 hover:bg-brand-900 text-white",
41
41
  activeYear: "bg-brand-100",
42
42
  timepicker: "mt-2 pl-1 pt-3 text-sm flex items-center justify-between gap-2 border-t border-brand-200",
43
43
  timepickerLabel: "w-full",
44
44
  timepickerInputWrapper: "flex items-center gap-px rounded-lg border border-brand-300",
45
- timepickerInput: "w-11 border-none px-2.5 py-1.5 text-center text-sm focus:ring-brand-500",
46
- timepickerLeftInput: "rounded-l-lg",
47
- timepickerRightInput: "rounded-r-lg",
45
+ timepickerInput: " w-11 border-none px-2.5 py-1.5 text-center text-sm focus:ring-brand-500",
46
+ timepickerLeftInput: " rounded-l-lg",
47
+ timepickerRightInput: " rounded-r-lg",
48
48
  timepickerSubmitButton: "py-2 focus:ring-0 border-0",
49
49
  i18n: {
50
50
  weekdays: {
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UCalendar from "../ui.form-calendar";
4
4
 
@@ -36,9 +36,7 @@ const DefaultTemplate = (args) => ({
36
36
  },
37
37
  template: `
38
38
  <UCalendar v-bind="args" v-model="value">
39
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
40
- <template v-if="args[slot]">{{ args[slot] }}</template>
41
- </template>
39
+ ${allSlotsFragment}
42
40
  </UCalendar>
43
41
 
44
42
  <div class="mt-4">
@@ -287,12 +287,44 @@ const props = defineProps({
287
287
  });
288
288
 
289
289
  const emit = defineEmits([
290
+ /**
291
+ * Triggers when date value changes.
292
+ * @property {object} newDate
293
+ */
290
294
  "update:modelValue",
295
+
296
+ /**
297
+ * Triggers when calendar view changes.
298
+ * @property {string} view
299
+ */
291
300
  "update:view",
301
+
302
+ /**
303
+ * Triggers when date value changes.
304
+ * @property {object} value
305
+ */
292
306
  "input",
307
+
308
+ /**
309
+ * Triggers when calendar date is selected by clicking "Enter".
310
+ */
293
311
  "submit",
312
+
313
+ /**
314
+ * Triggers when arrow keys are used to change calendar date.
315
+ */
294
316
  "keydown",
317
+
318
+ /**
319
+ * Triggers when the date input value is changed by the user.
320
+ * @property {string} value
321
+ */
295
322
  "userDateChange",
323
+
324
+ /**
325
+ * Triggers when the date format applied to the input changes.
326
+ * @property {string} value
327
+ */
296
328
  "formattedDateChange",
297
329
  ]);
298
330
 
@@ -4,46 +4,37 @@ import { cva } from "../../service.ui";
4
4
 
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
- export function useAttrs(props) {
8
- const { config, getAttrs, setColor, getColor } = useUI(defaultConfig, () => props.config);
9
- const { list, radio } = config.value;
10
-
11
- const cvaList = cva({
12
- base: list.base,
13
- variants: list.variants,
14
- compoundVariants: list.compoundVariants,
15
- });
16
-
17
- const cvaRadio = cva({
18
- base: radio.base,
19
- variants: radio.variants,
20
- compoundVariants: radio.compoundVariants,
21
- });
22
-
23
- const listClasses = computed(() => cvaList({ size: props.size }));
24
- const radioClasses = computed(() =>
25
- setColor(
26
- cvaRadio({
27
- color: getColor(props.color),
28
- }),
29
- props.color,
30
- ),
7
+ export default function useAttrs(props) {
8
+ const { config, getAttrs, setColor, getColor, isSystemKey } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
31
11
  );
12
+ const attrs = {};
32
13
 
33
- const labelAttrs = getAttrs("label");
34
- const listAttrs = getAttrs("list", { classes: listClasses });
35
- const unselectedAttrs = getAttrs("unselected");
36
- const unselectedRadioAttrs = getAttrs("unselectedRadio", { isComponent: true });
37
- const unselectedIconAttrs = getAttrs("unselectedIcon", { isComponent: true });
38
- const radioAttrs = getAttrs("radio", { classes: radioClasses, isComponent: true });
14
+ for (const key in defaultConfig) {
15
+ if (isSystemKey(key)) continue;
16
+
17
+ const classes = computed(() => {
18
+ const value = config.value[key];
19
+
20
+ if (value.variants || value.compoundVariants) {
21
+ return setColor(
22
+ cva(value)({
23
+ ...props,
24
+ color: getColor(props.color),
25
+ }),
26
+ props.color,
27
+ );
28
+ }
29
+
30
+ return "";
31
+ });
32
+
33
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
34
+ }
39
35
 
40
36
  return {
37
+ ...attrs,
41
38
  config,
42
- listAttrs,
43
- labelAttrs,
44
- radioAttrs,
45
- unselectedIconAttrs,
46
- unselectedAttrs,
47
- unselectedRadioAttrs,
48
39
  };
49
40
  }
@@ -13,13 +13,12 @@ export default /*tw*/ {
13
13
  },
14
14
  },
15
15
  radio: {
16
- radio: {
17
- base: "cursor-pointer bg-{color}-500 border-{color}-500 hover:border-{color}-500",
18
- },
16
+ radio: "{URadio} cursor-pointer bg-{color}-500 border-{color}-500 hover:border-{color}-500",
19
17
  },
20
18
  unselected: "relative flex",
21
19
  unselectedRadio: {
22
20
  radio: {
21
+ base: "{URadio}",
23
22
  compoundVariants: [
24
23
  {
25
24
  color: "grayscale",
@@ -28,7 +27,7 @@ export default /*tw*/ {
28
27
  ],
29
28
  },
30
29
  },
31
- unselectedIcon: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
30
+ unselectedIcon: "{UIcon} absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
32
31
  unselectedIconName: "close",
33
32
  defaultVariants: {
34
33
  name: "UColorPicker",
@@ -60,7 +60,7 @@ import UIService, { getRandomId } from "../service.ui";
60
60
 
61
61
  import { UColorPicker } from "./constants";
62
62
  import defaultConfig from "./configs/default.config";
63
- import { useAttrs } from "./composables/attrs.composable";
63
+ import useAttrs from "./composables/attrs.composable";
64
64
 
65
65
  /* Should be a string for correct web-types gen */
66
66
  defineOptions({ name: "UColorPicker", inheritAttrs: false });
@@ -157,7 +157,13 @@ const props = defineProps({
157
157
  },
158
158
  });
159
159
 
160
- const emit = defineEmits(["update:modelValue"]);
160
+ const emit = defineEmits([
161
+ /**
162
+ * Triggers when color value changes.
163
+ * @property {string} value
164
+ */
165
+ "update:modelValue",
166
+ ]);
161
167
 
162
168
  const {
163
169
  config,
@@ -1,80 +1,94 @@
1
1
  import useUI from "../../composable.ui";
2
- import { cva } from "../../service.ui";
2
+ import { cva, cx } from "../../service.ui";
3
3
  import { computed, watchEffect } from "vue";
4
4
 
5
5
  import defaultConfig from "../configs/default.config";
6
6
  import { POSITION } from "../../composable.adjustElementPosition";
7
7
 
8
8
  export default function useAttrs(props, { isShownCalendar, isTop, isRight }) {
9
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
10
- const { calendar } = config.value;
11
-
12
- const openDirectionY = computed(() => (isTop.value ? POSITION.top : POSITION.bottom));
13
- const openDirectionX = computed(() => (isRight.value ? POSITION.right : POSITION.left));
14
-
15
- const cvaCalendarWrapper = cva({
16
- base: calendar.wrapper.base,
17
- variants: calendar.wrapper.variants,
18
- compoundVariants: calendar.wrapper.compoundVariants,
19
- });
20
-
21
- const calendarWrapperClasses = computed(() =>
22
- cvaCalendarWrapper({
23
- openDirectionY: openDirectionY.value,
24
- openDirectionX: openDirectionX.value,
25
- }),
26
- );
27
-
28
- const calendarAttrs = getAttrs("calendar", {
29
- isComponent: true,
30
- classes: calendarWrapperClasses,
31
- });
32
- const inputBlurAttrs = getAttrs("input");
33
- const inputActiveAttrs = getAttrs("inputActive");
34
- const wrapperAttrs = getAttrs("wrapper");
35
-
36
- const inputAttrs = computed(() => {
37
- return isShownCalendar.value ? inputActiveAttrs.value : inputBlurAttrs.value;
38
- });
39
-
40
- // This watcher rewrites default calendar locales with datepicker range locales
41
- // Watcher will not rewrite custom calendar locales
42
- watchEffect(() => {
43
- if (!calendarAttrs.value.config) {
44
- calendarAttrs.value.config = {};
45
- }
9
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
10
+ const attrs = {};
46
11
 
47
- if (calendarAttrs.value.config.i18n || !props.config.i18n) {
48
- return;
49
- }
12
+ for (const key in defaultConfig) {
13
+ if (isSystemKey(key)) continue;
14
+
15
+ const classes = computed(() => {
16
+ const value = config.value[key];
17
+
18
+ if (value.variants || value.compoundVariants) {
19
+ return cva(value)({
20
+ ...props,
21
+ });
22
+ }
23
+
24
+ return "";
25
+ });
26
+
27
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
28
+
29
+ if (key === "input") {
30
+ const inputAttrs = attrs[`${key}Attrs`];
50
31
 
51
- calendarAttrs.value.config.i18n = {
52
- ...config.value.i18n,
53
- weekdays: {
54
- shorthand: { ...config.value.i18n.weekdays.shorthand },
55
- longhand: { ...config.value.i18n.weekdays.longhand },
56
- },
57
- months: {
58
- shorthand: { ...config.value.i18n.months.shorthand },
59
- longhand: { ...config.value.i18n.months.longhand },
60
- },
61
- };
62
-
63
- if (props.config.i18n.weekdays.userFormat) {
64
- calendarAttrs.value.config.i18n.userFormat = {
65
- ...config.value.i18n.weekdays.userFormat,
66
- };
32
+ attrs[`${key}Attrs`] = computed(() => ({
33
+ ...inputAttrs.value,
34
+ class: cx([inputAttrs.value.class, isShownCalendar.value && config.value.inputFocus]),
35
+ }));
67
36
  }
68
37
 
69
- if (props.config.i18n.months.userFormat) {
70
- calendarAttrs.value.config.i18n.userFormat = { ...config.value.i18n.months.userFormat };
38
+ if (key === "calendar") {
39
+ const calendarAttrs = attrs[`${key}Attrs`];
40
+
41
+ attrs[`${key}Attrs`] = computed(() => ({
42
+ ...calendarAttrs.value,
43
+ class: cx([
44
+ cva(config.value.calendar.wrapper)({
45
+ openDirectionY: isTop.value ? POSITION.top : POSITION.bottom,
46
+ openDirectionX: isRight.value ? POSITION.right : POSITION.left,
47
+ }),
48
+ calendarAttrs.value.class,
49
+ ]),
50
+ }));
51
+
52
+ // This watcher rewrites default calendar locales with datepicker range locales
53
+ // Watcher will not rewrite custom calendar locales
54
+ watchEffect(() => {
55
+ if (!attrs[`${key}Attrs`].value.config) {
56
+ attrs[`${key}Attrs`].value.config = {};
57
+ }
58
+
59
+ if (attrs[`${key}Attrs`].value.config.i18n || !props.config.i18n) {
60
+ return;
61
+ }
62
+
63
+ attrs[`${key}Attrs`].value.config.i18n = {
64
+ ...config.value.i18n,
65
+ weekdays: {
66
+ shorthand: { ...config.value.i18n.weekdays.shorthand },
67
+ longhand: { ...config.value.i18n.weekdays.longhand },
68
+ },
69
+ months: {
70
+ shorthand: { ...config.value.i18n.months.shorthand },
71
+ longhand: { ...config.value.i18n.months.longhand },
72
+ },
73
+ };
74
+
75
+ if (props.config.i18n.weekdays.userFormat) {
76
+ attrs[`${key}Attrs`].value.config.i18n.userFormat = {
77
+ ...config.value.i18n.weekdays.userFormat,
78
+ };
79
+ }
80
+
81
+ if (props.config.i18n.months.userFormat) {
82
+ attrs[`${key}Attrs`].value.config.i18n.userFormat = {
83
+ ...config.value.i18n.months.userFormat,
84
+ };
85
+ }
86
+ });
71
87
  }
72
- });
88
+ }
73
89
 
74
90
  return {
91
+ ...attrs,
75
92
  config,
76
- calendarAttrs,
77
- inputAttrs,
78
- wrapperAttrs,
79
93
  };
80
94
  }
@@ -1,14 +1,12 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: "relative",
3
3
  input: "",
4
- inputActive: {
5
- block: {
6
- base: "ring-4 ring-brand-600/[.15] border-brand-500 hover:border-brand-500",
7
- },
4
+ inputFocus: {
5
+ block: "ring-4 ring-brand-600/[.15] border-brand-500 hover:border-brand-500",
8
6
  },
9
7
  calendar: {
10
8
  wrapper: {
11
- base: "absolute z-40 my-2",
9
+ base: "{UCalendar} absolute z-40 my-2",
12
10
  variants: {
13
11
  openDirectionX: {
14
12
  left: "left-0",
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UDatePicker from "../ui.form-date-picker";
4
4
  import UIcon from "../ui.image-icon";
@@ -40,9 +40,7 @@ const DefaultTemplate = (args) => ({
40
40
  },
41
41
  template: `
42
42
  <UDatePicker v-bind="args" v-model="value">
43
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
44
- <template v-if="args[slot]">{{ args[slot] }}</template>
45
- </template>
43
+ ${allSlotsFragment}
46
44
  </UDatePicker>
47
45
 
48
46
  <div class="mt-4">
@@ -15,14 +15,17 @@
15
15
  @focus="activate"
16
16
  >
17
17
  <template #left>
18
+ <!-- @slot Use it add something before the date. -->
18
19
  <slot name="left" />
19
20
  </template>
20
21
 
21
22
  <template #right-icon>
23
+ <!-- @slot Use it add an icon after the date. -->
22
24
  <slot name="right-icon" />
23
25
  </template>
24
26
 
25
27
  <template #right>
28
+ <!-- @slot Use it add something after the date. -->
26
29
  <slot name="right" />
27
30
  </template>
28
31
  </UInput>
@@ -215,7 +218,19 @@ const props = defineProps({
215
218
  },
216
219
  });
217
220
 
218
- const emit = defineEmits(["update:modelValue", "input"]);
221
+ const emit = defineEmits([
222
+ /**
223
+ * Triggers when date picker value changes.
224
+ * @property {string} value
225
+ */
226
+ "update:modelValue",
227
+
228
+ /**
229
+ * Triggers when date picker value changes.
230
+ * @property {object} value
231
+ */
232
+ "input",
233
+ ]);
219
234
 
220
235
  const STANDARD_USER_FORMAT = "l, j F, Y";
221
236
 
@@ -7,124 +7,130 @@ import defaultConfig from "../configs/default.config";
7
7
  import { POSITION } from "../../composable.adjustElementPosition";
8
8
 
9
9
  export default function useAttrs(props, { isShownMenu, isTop, isRight }) {
10
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
11
- const { menu } = config.value;
12
-
13
- const openDirectionY = computed(() => (isTop.value ? POSITION.top : POSITION.bottom));
14
- const openDirectionX = computed(() => (isRight.value ? POSITION.right : POSITION.left));
15
-
16
- const cvaMenu = cva({
17
- base: menu.base,
18
- variants: menu.variants,
19
- compoundVariants: menu.compoundVariants,
20
- });
21
-
22
- const menuClasses = computed(() =>
23
- cvaMenu({ openDirectionY: openDirectionY.value, openDirectionX: openDirectionX.value }),
24
- );
25
-
26
- const wrapperAttrs = getAttrs("wrapper");
27
- const buttonWrapperAttrsRaw = getAttrs("buttonWrapper");
28
- const buttonAttrsRaw = getAttrs("button");
29
- const shiftRangeButtonAttrs = getAttrs("shiftRangeButton");
30
- const calendarAttrs = getAttrs("calendar", { isComponent: true });
31
- const inputBlurAttrs = getAttrs("input", { isComponent: true });
32
- const inputActiveAttrs = getAttrs("inputActive");
33
- const rangeInputAttrs = getAttrs("rangeInput", { isComponent: true });
34
- const rangeInputWrapperAttrs = getAttrs("rangeInputWrapper");
35
- const inputRangeErrorAttrs = getAttrs("inputRangeError");
36
-
37
- // This watcher rewrites default calendar locales with datepicker range locales
38
- // Watcher will not rewrite custom calendar locales
39
- watchEffect(() => {
40
- if (!calendarAttrs.value.config) {
41
- calendarAttrs.value.config = {};
10
+ const { config, getAttrs, isSystemKey } = useUI(defaultConfig, () => props.config);
11
+ const attrs = {};
12
+
13
+ for (const key in defaultConfig) {
14
+ if (isSystemKey(key)) continue;
15
+
16
+ const classes = computed(() => {
17
+ const value = config.value[key];
18
+
19
+ if (value.variants || value.compoundVariants) {
20
+ return cva(value)({
21
+ ...props,
22
+ });
23
+ }
24
+
25
+ return "";
26
+ });
27
+
28
+ attrs[`${key}Attrs`] = getAttrs(key, { classes });
29
+
30
+ if (key === "menu") {
31
+ const menuAttrs = attrs[`${key}Attrs`];
32
+
33
+ attrs[`${key}Attrs`] = computed(() => ({
34
+ ...menuAttrs.value,
35
+ class: cx([
36
+ cva(config.value.menu)({
37
+ openDirectionY: isTop.value ? POSITION.top : POSITION.bottom,
38
+ openDirectionX: isRight.value ? POSITION.right : POSITION.left,
39
+ }),
40
+ menuAttrs.value.class,
41
+ ]),
42
+ }));
42
43
  }
43
44
 
44
- if (calendarAttrs.value.config.i18n || !props.config.i18n) {
45
- return;
45
+ if (key === "input") {
46
+ const inputAttrs = attrs[`${key}Attrs`];
47
+
48
+ attrs[`${key}Attrs`] = computed(() => ({
49
+ ...inputAttrs.value,
50
+ class: cx([inputAttrs.value.class, isShownMenu.value && config.value.inputFocus]),
51
+ }));
46
52
  }
47
53
 
48
- calendarAttrs.value.config.i18n = {
49
- ...config.value.i18n,
50
- weekdays: {
51
- shorthand: { ...config.value.i18n.weekdays.shorthand },
52
- longhand: { ...config.value.i18n.weekdays.longhand },
53
- },
54
- months: {
55
- shorthand: { ...config.value.i18n.months.shorthand },
56
- longhand: { ...config.value.i18n.months.longhand },
57
- },
58
- };
59
-
60
- if (props.config.i18n.weekdays.userFormat) {
61
- calendarAttrs.value.config.i18n.userFormat = {
62
- ...config.value.i18n.weekdays.userFormat,
63
- };
54
+ if (key === "buttonWrapper") {
55
+ const buttonWrapperAttrs = attrs[`${key}Attrs`];
56
+
57
+ attrs[`${key}Attrs`] = computed(() => ({
58
+ ...buttonWrapperAttrs.value,
59
+ class: cx([
60
+ buttonWrapperAttrs.value.class,
61
+ isShownMenu.value && config.value.buttonWrapperActive,
62
+ ]),
63
+ }));
64
64
  }
65
65
 
66
- if (props.config.i18n.months.userFormat) {
67
- calendarAttrs.value.config.i18n.userFormat = { ...config.value.i18n.months.userFormat };
66
+ if (key === "button") {
67
+ const buttonAttrs = attrs[`${key}Attrs`];
68
+
69
+ attrs[`${key}Attrs`] = computed(() => ({
70
+ ...buttonAttrs.value,
71
+ class: cx([buttonAttrs.value.class, isShownMenu.value && config.value.buttonActive]),
72
+ }));
68
73
  }
69
- });
70
-
71
- const inputAttrs = computed(() => {
72
- return isShownMenu.value ? inputActiveAttrs.value : inputBlurAttrs.value;
73
- });
74
-
75
- const menuAttrs = getAttrs("menu", { classes: menuClasses });
76
- const periodsRowAttrs = getAttrs("periodsRow");
77
- const rangeSwitchWrapperAttrs = getAttrs("rangeSwitchWrapper");
78
- const nextIconAttrs = getAttrs("nextIcon");
79
- const prevIconAttrs = getAttrs("prevIcon");
80
- const periodButtonIconAttrs = getAttrs("periodButtonIcon");
81
- const rangeSwitchTitleAttrs = getAttrs("rangeSwitchTitle");
82
-
83
- const periodButtonAttrs = (classes = []) => {
84
- return getAttrs("periodButton", { classes }).value;
85
- };
86
74
 
87
- const periodDateListAttrs = (classes = []) => {
88
- return getAttrs("periodDateList", { classes }).value;
89
- };
75
+ if (key === "periodButton") {
76
+ attrs[`${key}Attrs`] = (classes) => {
77
+ return getAttrs("periodButton", { classes }).value;
78
+ };
79
+ }
90
80
 
91
- const periodDateAttrs = (classes = []) => {
92
- return getAttrs("periodDate", { classes }).value;
93
- };
81
+ if (key === "periodDateList") {
82
+ attrs[`${key}Attrs`] = (classes) => {
83
+ return getAttrs("periodDateList", { classes }).value;
84
+ };
85
+ }
94
86
 
95
- const buttonWrapperAttrs = computed(() => ({
96
- ...buttonWrapperAttrsRaw.value,
97
- class: cx([
98
- buttonWrapperAttrsRaw.value.class,
99
- isShownMenu.value && config.value.buttonWrapperActive,
100
- ]),
101
- }));
87
+ if (key === "periodDate") {
88
+ attrs[`${key}Attrs`] = (classes) => {
89
+ return getAttrs("periodDate", { classes }).value;
90
+ };
91
+ }
102
92
 
103
- const buttonAttrs = computed(() => ({
104
- ...buttonAttrsRaw.value,
105
- class: cx([buttonAttrsRaw.value.class, isShownMenu.value && config.value.buttonActive]),
106
- }));
93
+ if (key === "calendar") {
94
+ // This watcher rewrites default calendar locales with datepicker range locales
95
+ // Watcher will not rewrite custom calendar locales
96
+ watchEffect(() => {
97
+ if (!attrs[`${key}Attrs`].value.config) {
98
+ attrs[`${key}Attrs`].value.config = {};
99
+ }
100
+
101
+ if (attrs[`${key}Attrs`].value.config.i18n || !props.config.i18n) {
102
+ return;
103
+ }
104
+
105
+ attrs[`${key}Attrs`].value.config.i18n = {
106
+ ...config.value.i18n,
107
+ weekdays: {
108
+ shorthand: { ...config.value.i18n.weekdays.shorthand },
109
+ longhand: { ...config.value.i18n.weekdays.longhand },
110
+ },
111
+ months: {
112
+ shorthand: { ...config.value.i18n.months.shorthand },
113
+ longhand: { ...config.value.i18n.months.longhand },
114
+ },
115
+ };
116
+
117
+ if (props.config.i18n.weekdays.userFormat) {
118
+ attrs[`${key}Attrs`].value.config.i18n.userFormat = {
119
+ ...config.value.i18n.weekdays.userFormat,
120
+ };
121
+ }
122
+
123
+ if (props.config.i18n.months.userFormat) {
124
+ attrs[`${key}Attrs`].value.config.i18n.userFormat = {
125
+ ...config.value.i18n.months.userFormat,
126
+ };
127
+ }
128
+ });
129
+ }
130
+ }
107
131
 
108
132
  return {
133
+ ...attrs,
109
134
  config,
110
- wrapperAttrs,
111
- calendarAttrs,
112
- inputAttrs,
113
- menuAttrs,
114
- periodsRowAttrs,
115
- periodButtonAttrs,
116
- periodButtonIconAttrs,
117
- rangeSwitchWrapperAttrs,
118
- nextIconAttrs,
119
- prevIconAttrs,
120
- periodDateAttrs,
121
- periodDateListAttrs,
122
- rangeSwitchTitleAttrs,
123
- buttonWrapperAttrs,
124
- buttonAttrs,
125
- shiftRangeButtonAttrs,
126
- rangeInputAttrs,
127
- rangeInputWrapperAttrs,
128
- inputRangeErrorAttrs,
129
135
  };
130
136
  }
@@ -1,14 +1,14 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: "relative",
3
- input: "",
4
- inputActive: {
3
+ input: "{UInput}",
4
+ inputFocus: {
5
5
  block: "ring-4 ring-brand-700 ring-opacity-20 border-brand-500 hover:border-brand-500",
6
6
  },
7
7
  buttonWrapper: `
8
8
  flex rounded-lg max-md:justify-between
9
9
  focus-within:ring-4 focus-within:ring-brand-700 focus-within:ring-opacity-20
10
10
  `,
11
- button: "shrink-0 grow rounded-none focus:ring-0",
11
+ button: "{UButton} shrink-0 grow rounded-none focus:ring-0",
12
12
  buttonActive: "ring-0",
13
13
  buttonWrapperActive: "ring-4 ring-brand-700 ring-opacity-20",
14
14
  shiftRangeButton: "focus:ring-0 last:rounded-l-none last:rounded-r-lg first:rounded-l-lg first:rounded-r-none",
@@ -34,17 +34,17 @@ export default /*tw*/ {
34
34
  },
35
35
  periodsRow: "mb-1 flex min-w-64 gap-1",
36
36
  periodButton: `
37
- h-[3.125rem] w-full flex flex-col items-center justify-center
37
+ {UButton} h-[3.125rem] w-full flex flex-col items-center justify-center
38
38
  [&_span]:block [&_span]:font-normal [&_span]:text-brand-500
39
39
  `,
40
- periodButtonIcon: "",
40
+ periodButtonIcon: "{UIcon}",
41
41
  periodButtonIconName: "apps",
42
42
  periodButtonActive: "bg-gray-200",
43
43
  rangeSwitchWrapper: "mb-2.5 mt-4 flex items-center justify-between py-2",
44
44
  rangeSwitchTitle: "font-medium text-sm",
45
- nextIcon: "",
45
+ nextIcon: "{UIcon}",
46
46
  nextIconName: "keyboard_arrow_right",
47
- prevIcon: "",
47
+ prevIcon: "{UIcon}",
48
48
  prevIconName: "keyboard_arrow_left",
49
49
  periodDateList: "",
50
50
  periodDateMonthList: "grid grid-cols-3 grid-rows-1 gap-0.5",
@@ -61,7 +61,7 @@ export default /*tw*/ {
61
61
  description: "hidden",
62
62
  },
63
63
  input: {
64
- base: "text-sm border-brand-100 px-4 py-2.5",
64
+ base: "{UInput} text-sm border-brand-100 px-4 py-2.5",
65
65
  variants: {
66
66
  size: {
67
67
  md: "pt-2.5 pb-2.5",
@@ -71,7 +71,7 @@ export default /*tw*/ {
71
71
  },
72
72
  inputRangeError: "text-xs font-normal !leading-none mt-2 text-center text-red-500",
73
73
  calendar: {
74
- wrapper: "p-0 mt-2 w-full border-none shadow-none",
74
+ wrapper: "{UCalendar} p-0 mt-2 w-full border-none shadow-none",
75
75
  navigation: "mb-0 border-none",
76
76
  navigationSwitchViewButton: "rounded-lg px-3",
77
77
  day: "w-full h-10 mb-0.5",
@@ -1,4 +1,4 @@
1
- import { getArgTypes, getSlotNames } from "../service.storybook";
1
+ import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
2
2
 
3
3
  import UDatePickerRange from "../ui.form-date-picker-range";
4
4
  import URow from "../ui.container-row";
@@ -44,9 +44,7 @@ const DefaultTemplate = (args) => ({
44
44
  },
45
45
  template: `
46
46
  <UDatePickerRange v-bind="args" v-model="value">
47
- <template v-for="(slot, index) of slots" :key="index" v-slot:[slot]>
48
- <template v-if="args[slot]">{{ args[slot] }}</template>
49
- </template>
47
+ ${allSlotsFragment}
50
48
  </UDatePickerRange>
51
49
 
52
50
  <div class="mt-4">
@@ -423,7 +423,13 @@ const props = defineProps({
423
423
 
424
424
  const inputRangeFormat = "d.m.Y";
425
425
 
426
- const emit = defineEmits(["update:modelValue"]);
426
+ const emit = defineEmits([
427
+ /**
428
+ * Triggers when date picker range value changes.
429
+ * @property {string} value
430
+ */
431
+ "update:modelValue",
432
+ ]);
427
433
 
428
434
  const isShownMenu = ref(false);
429
435
  const wrapperRef = ref(null);
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.211",
4
+ "version": "0.0.213",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -1077,25 +1077,72 @@
1077
1077
  ],
1078
1078
  "events": [
1079
1079
  {
1080
- "name": "update:modelValue"
1080
+ "name": "update:modelValue",
1081
+ "description": "Triggers when date value changes.",
1082
+ "properties": [
1083
+ {
1084
+ "type": [
1085
+ "object"
1086
+ ],
1087
+ "name": "newDate"
1088
+ }
1089
+ ]
1081
1090
  },
1082
1091
  {
1083
- "name": "update:view"
1092
+ "name": "update:view",
1093
+ "description": "Triggers when calendar view changes.",
1094
+ "properties": [
1095
+ {
1096
+ "type": [
1097
+ "string"
1098
+ ],
1099
+ "name": "view"
1100
+ }
1101
+ ]
1084
1102
  },
1085
1103
  {
1086
- "name": "input"
1104
+ "name": "input",
1105
+ "description": "Triggers when date value changes.",
1106
+ "properties": [
1107
+ {
1108
+ "type": [
1109
+ "object"
1110
+ ],
1111
+ "name": "value"
1112
+ }
1113
+ ]
1087
1114
  },
1088
1115
  {
1089
- "name": "submit"
1116
+ "name": "submit",
1117
+ "description": "Triggers when calendar date is selected by clicking \"Enter\"."
1090
1118
  },
1091
1119
  {
1092
- "name": "keydown"
1120
+ "name": "keydown",
1121
+ "description": "Triggers when arrow keys are used to change calendar date."
1093
1122
  },
1094
1123
  {
1095
- "name": "userDateChange"
1124
+ "name": "userDateChange",
1125
+ "description": "Triggers when the date input value is changed by the user.",
1126
+ "properties": [
1127
+ {
1128
+ "type": [
1129
+ "string"
1130
+ ],
1131
+ "name": "value"
1132
+ }
1133
+ ]
1096
1134
  },
1097
1135
  {
1098
- "name": "formattedDateChange"
1136
+ "name": "formattedDateChange",
1137
+ "description": "Triggers when the date format applied to the input changes.",
1138
+ "properties": [
1139
+ {
1140
+ "type": [
1141
+ "string"
1142
+ ],
1143
+ "name": "value"
1144
+ }
1145
+ ]
1099
1146
  }
1100
1147
  ],
1101
1148
  "source": {
@@ -1720,7 +1767,16 @@
1720
1767
  ],
1721
1768
  "events": [
1722
1769
  {
1723
- "name": "update:modelValue"
1770
+ "name": "update:modelValue",
1771
+ "description": "Triggers when color value changes.",
1772
+ "properties": [
1773
+ {
1774
+ "type": [
1775
+ "string"
1776
+ ],
1777
+ "name": "value"
1778
+ }
1779
+ ]
1724
1780
  }
1725
1781
  ],
1726
1782
  "source": {
@@ -2076,21 +2132,42 @@
2076
2132
  ],
2077
2133
  "events": [
2078
2134
  {
2079
- "name": "update:modelValue"
2135
+ "name": "update:modelValue",
2136
+ "description": "Triggers when date picker value changes.",
2137
+ "properties": [
2138
+ {
2139
+ "type": [
2140
+ "string"
2141
+ ],
2142
+ "name": "value"
2143
+ }
2144
+ ]
2080
2145
  },
2081
2146
  {
2082
- "name": "input"
2147
+ "name": "input",
2148
+ "description": "Triggers when date picker value changes.",
2149
+ "properties": [
2150
+ {
2151
+ "type": [
2152
+ "object"
2153
+ ],
2154
+ "name": "value"
2155
+ }
2156
+ ]
2083
2157
  }
2084
2158
  ],
2085
2159
  "slots": [
2086
2160
  {
2087
- "name": "left"
2161
+ "name": "left",
2162
+ "description": "Use it add something before the date."
2088
2163
  },
2089
2164
  {
2090
- "name": "right-icon"
2165
+ "name": "right-icon",
2166
+ "description": "Use it add an icon after the date."
2091
2167
  },
2092
2168
  {
2093
- "name": "right"
2169
+ "name": "right",
2170
+ "description": "Use it add something after the date."
2094
2171
  }
2095
2172
  ],
2096
2173
  "source": {
@@ -2255,7 +2332,16 @@
2255
2332
  ],
2256
2333
  "events": [
2257
2334
  {
2258
- "name": "update:modelValue"
2335
+ "name": "update:modelValue",
2336
+ "description": "Triggers when date picker range value changes.",
2337
+ "properties": [
2338
+ {
2339
+ "type": [
2340
+ "string"
2341
+ ],
2342
+ "name": "value"
2343
+ }
2344
+ ]
2259
2345
  }
2260
2346
  ],
2261
2347
  "slots": [