vueless 0.0.455 → 0.0.456

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.455",
3
+ "version": "0.0.456",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -312,12 +312,6 @@ const emit = defineEmits([
312
312
  * @property {string} value
313
313
  */
314
314
  "userDateChange",
315
-
316
- /**
317
- * Triggers when the date format applied to the input changes.
318
- * @property {string} value
319
- */
320
- "formattedDateChange",
321
315
  ]);
322
316
 
323
317
  const { tm } = useLocale();
@@ -519,10 +513,6 @@ const selectedDateTo = computed(() => {
519
513
  : undefined;
520
514
  });
521
515
 
522
- const formattedDate = computed(() => {
523
- return formatDate(selectedDate.value, actualDateFormat.value, locale.value);
524
- });
525
-
526
516
  const userFormattedDate = computed(() => {
527
517
  const date = formatDate(selectedDate.value, actualUserFormat.value, userFormatLocale.value);
528
518
  const dateTo = props.range
@@ -547,10 +537,6 @@ watch(userFormattedDate, () => {
547
537
  emit("userDateChange", userFormattedDate.value);
548
538
  });
549
539
 
550
- watch(formattedDate, () => {
551
- emit("formattedDateChange", userFormattedDate.value);
552
- });
553
-
554
540
  // This watcher force updates value when range props changed
555
541
  watch(
556
542
  () => props.range,
@@ -573,7 +559,6 @@ const unwatchInit = watch(
573
559
  minutesRef.value.value = String(selectedDate.value.getMinutes()).padStart(2, "0");
574
560
  secondsRef.value.value = String(selectedDate.value.getSeconds()).padStart(2, "0");
575
561
 
576
- emit("formattedDateChange", userFormattedDate.value);
577
562
  emit("userDateChange", userFormattedDate.value);
578
563
 
579
564
  isInit = true;
@@ -6,7 +6,14 @@ export default /*tw*/ {
6
6
  dayView: "",
7
7
  weekDays: "grid grid-cols-7 justify-items-center gap-1",
8
8
  weekDay: "flex size-8 items-center justify-center text-xs uppercase text-gray-500",
9
- days: "grid grid-cols-7 justify-items-center gap-1",
9
+ days: {
10
+ base: "grid grid-cols-7 justify-items-center gap-1",
11
+ variants: {
12
+ range: {
13
+ true: "gap-0 gap-y-0.5",
14
+ },
15
+ },
16
+ },
10
17
  dateInRange: "bg-brand/15 font-semibold !text-brand-900 hover:bg-brand/30 rounded-none",
11
18
  edgeDateInRange: "",
12
19
  firstDateInRange: "rounded-r-none",
@@ -20,9 +27,9 @@ export default /*tw*/ {
20
27
  dayInRange: "",
21
28
  currentDayInRange: "",
22
29
  anotherMonthDay: "",
23
- firstDayInRange: "",
30
+ firstDayInRange: "font-semibold",
24
31
  anotherMonthFirstDayInRange: "",
25
- lastDayInRange: "",
32
+ lastDayInRange: "font-semibold",
26
33
  currentLastDayInRange: "",
27
34
  currentFirstDayInRange: "",
28
35
  anotherMonthLastDayInRange: "",
@@ -65,7 +65,6 @@
65
65
  v-bind="calendarAttrs"
66
66
  @keydown.esc="deactivate"
67
67
  @user-date-change="onUserFormatDateChange"
68
- @formatted-date-change="onFormattedDateChange"
69
68
  @input="onInput"
70
69
  @blur="onBlur"
71
70
  @submit="onSubmit"
@@ -355,10 +354,6 @@ function onUserFormatDateChange(value) {
355
354
  userFormatDate.value = formatUserDate(value) || "";
356
355
  }
357
356
 
358
- function onFormattedDateChange(value) {
359
- formattedDate.value = value || "";
360
- }
361
-
362
357
  function onSubmit() {
363
358
  deactivate();
364
359
  }
@@ -402,7 +397,6 @@ function onInput() {
402
397
  calendarRef.value?.wrapperRef?.blur();
403
398
  emit("input", {
404
399
  value: localValue.value,
405
- formattedDate: formattedDate.value,
406
400
  userFormatDate: formatUserDate(userFormatDate.value),
407
401
  });
408
402
  });
@@ -279,6 +279,14 @@ const props = defineProps({
279
279
  default: getDefault(defaultConfig, UDatePickerRange).dateFormat,
280
280
  },
281
281
 
282
+ /**
283
+ * User-friendly date format (it will be shown in UI).
284
+ */
285
+ userDateFormat: {
286
+ type: String,
287
+ default: getDefault(defaultConfig, UDatePickerRange).userDateFormat,
288
+ },
289
+
282
290
  /**
283
291
  * Datepicker size.
284
292
  * @values sm, md, lg
@@ -498,7 +506,13 @@ const clickOutsideOptions = computed(() => {
498
506
  };
499
507
  });
500
508
 
501
- const { userFormatDate } = useUserFormat(localValue, userFormatLocale, isPeriod, isVariant);
509
+ const { userFormatDate } = useUserFormat(
510
+ localValue,
511
+ userFormatLocale,
512
+ isPeriod,
513
+ locale,
514
+ props.userDateFormat,
515
+ );
502
516
 
503
517
  watch(
504
518
  calendarValue,
@@ -3,7 +3,14 @@ export default /*tw*/ {
3
3
  input: "{UInput}",
4
4
  activeInput: {
5
5
  component: "{UInput}",
6
- wrapper: "ring-dynamic rounded-dynamic ring-offset-dynamic ring-brand-700/15 border-brand-500 hover:border-brand-500",
6
+ wrapper: {
7
+ base: "ring-dynamic rounded-dynamic ring-offset-dynamic ring-brand-700/15 border-brand-500 hover:border-brand-500",
8
+ variants: {
9
+ error: {
10
+ true: "ring-red-500/15",
11
+ },
12
+ },
13
+ },
7
14
  },
8
15
  buttonWrapper: `
9
16
  flex rounded-dynamic max-md:justify-between
@@ -96,7 +103,6 @@ export default /*tw*/ {
96
103
  component: "{UCalendar}",
97
104
  wrapper: "p-0 pt-2 w-full border-none shadow-none rounded-none",
98
105
  navigation: "pb-0 mb-0 border-none",
99
- days: "gap-0 gap-y-0.5",
100
106
  day: "w-full",
101
107
  },
102
108
  i18n: {
@@ -185,6 +191,7 @@ export default /*tw*/ {
185
191
  },
186
192
  },
187
193
  defaults: {
194
+ userDateFormat: "j F Y",
188
195
  size: "md",
189
196
  variant: "button",
190
197
  labelAlign: "topInside",
@@ -1,12 +1,9 @@
1
1
  import { computed } from "vue";
2
2
 
3
- import useBreakpoint from "../composables/useBreakpoint.js";
4
-
5
3
  import { isSameMonth } from "../ui.form-calendar/utilDate.js";
4
+ import { formatDate } from "../ui.form-calendar/utilCalendar.js";
6
5
 
7
- export function useUserFormat(localValue, userFormatLocale, isPeriod, isVariant) {
8
- const { isMobileBreakpoint } = useBreakpoint();
9
-
6
+ export function useUserFormat(localValue, userFormatLocale, isPeriod, locale, userDateFormat) {
10
7
  const userFormatDate = computed(() => {
11
8
  if ((!localValue.value.from && !localValue.value.to) || !localValue.value.from) return "";
12
9
 
@@ -19,7 +16,6 @@ export function useUserFormat(localValue, userFormatLocale, isPeriod, isVariant)
19
16
 
20
17
  if (isDefaultTitle) {
21
18
  let startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
22
- let startYear = from.getFullYear();
23
19
  let endMonthName = userFormatLocale.value.months.longhand[to?.getMonth()];
24
20
  let endYear = to?.getFullYear();
25
21
 
@@ -27,54 +23,34 @@ export function useUserFormat(localValue, userFormatLocale, isPeriod, isVariant)
27
23
  startMonthName = "";
28
24
  }
29
25
 
30
- if (startYear.year === endYear) {
31
- startYear = "";
32
- }
26
+ const isDateToSameMonth = isSameMonth(from, to);
27
+ const isDateToSameYear = from.getFullYear() === to.getFullYear();
33
28
 
34
- const isDatesToSameMonth = isSameMonth(from, to);
35
- const isDatesToSameYear = from.getFullYear() === to.getFullYear();
29
+ let fromFormat = userDateFormat;
36
30
 
37
- let fromTitle = `${from.getDate()} ${startMonthName} ${startYear}`;
38
-
39
- if (isDatesToSameMonth && isDatesToSameYear) {
40
- fromTitle = from.getDate();
31
+ if (isDateToSameMonth && isDateToSameYear) {
32
+ fromFormat = fromFormat.replace(/[YyMmFnU]/g, "");
41
33
  }
42
34
 
43
- if (!isDatesToSameMonth && isDatesToSameYear) {
44
- fromTitle = `${from.getDate()} ${startMonthName}`;
35
+ if (!isDateToSameMonth && isDateToSameYear) {
36
+ fromFormat = fromFormat.replace(/[Yy]/g, "");
45
37
  }
46
38
 
47
- const toTitle = to ? `${to.getDate()} ${endMonthName} ${endYear}` : "";
39
+ const fromTitle = from ? formatDate(from, fromFormat, locale.value) : "";
40
+ const toTitle = to ? formatDate(to, userDateFormat, locale.value) : "";
48
41
 
49
42
  title = `${fromTitle} – ${toTitle}`;
50
43
  }
51
44
 
52
45
  if (isPeriod.value.month) {
53
- const startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
54
- const startYear = from.getFullYear();
55
-
56
- title = `${startMonthName} ${startYear}`;
46
+ title = formatDate(from, "F Y", locale.value);
57
47
  }
58
48
 
59
49
  if (isPeriod.value.quarter || isPeriod.value.year) {
60
- const startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
61
- const endMonthName = userFormatLocale.value.months.longhand[to?.getMonth()];
62
- const endYear = to?.getFullYear();
63
-
64
- const fromTitle = `${from.getDate()} ${startMonthName}`;
65
- const toTitle = to ? `${to.getDate()} ${endMonthName} ${endYear}` : "";
66
-
67
- title = `${fromTitle} – ${toTitle}`;
68
- }
69
-
70
- if (isMobileBreakpoint.value && !isPeriod.value.month && isVariant.value.button) {
71
- const startDay = String(from.getDate()).padStart(2, "0");
72
- const endDay = String(to?.getDate())?.padStart(2, "0");
73
- const startMonth = String(from.getMonth()).padStart(2, "0");
74
- const endMonth = String(to?.getMonth())?.padStart(2, "0");
50
+ const fromFormat = userDateFormat.replace(/[Yy]/g, "");
75
51
 
76
- const fromTitle = `${startDay}.${startMonth}`;
77
- const toTitle = to ? `${endDay}.${endMonth} / ${to.getFullYear()}` : "";
52
+ const fromTitle = from ? formatDate(from, fromFormat, locale.value) : "";
53
+ const toTitle = to ? formatDate(to, userDateFormat, locale.value) : "";
78
54
 
79
55
  title = `${fromTitle} – ${toTitle}`;
80
56
  }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.455",
4
+ "version": "0.0.456",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -1058,18 +1058,6 @@
1058
1058
  "name": "value"
1059
1059
  }
1060
1060
  ]
1061
- },
1062
- {
1063
- "name": "formattedDateChange",
1064
- "description": "Triggers when the date format applied to the input changes.",
1065
- "properties": [
1066
- {
1067
- "type": [
1068
- "string"
1069
- ],
1070
- "name": "value"
1071
- }
1072
- ]
1073
1061
  }
1074
1062
  ],
1075
1063
  "exposes": [
@@ -2683,6 +2671,15 @@
2683
2671
  "type": "string"
2684
2672
  }
2685
2673
  },
2674
+ {
2675
+ "name": "userDateFormat",
2676
+ "description": "User-friendly date format (it will be shown in UI).",
2677
+ "value": {
2678
+ "kind": "expression",
2679
+ "type": "string"
2680
+ },
2681
+ "default": "j F Y"
2682
+ },
2686
2683
  {
2687
2684
  "name": "size",
2688
2685
  "description": "Datepicker size.",