vueless 0.0.820 → 0.0.822
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
|
@@ -296,7 +296,7 @@ const { getDataTest } = useUI<Config>(defaultConfig);
|
|
|
296
296
|
v-bind="attrs.bodySelectedDateDividerAttrs.value"
|
|
297
297
|
:config="
|
|
298
298
|
getMergedConfig({
|
|
299
|
-
defaultConfig: attrs.
|
|
299
|
+
defaultConfig: attrs.bodySelectedDateDividerAttrs.value.config,
|
|
300
300
|
globalConfig: dateDividerData.config,
|
|
301
301
|
}) as UDividerConfig
|
|
302
302
|
"
|
|
@@ -2,6 +2,7 @@ import { computed } from "vue";
|
|
|
2
2
|
|
|
3
3
|
import { isSameMonth } from "../ui.form-calendar/utilDate.ts";
|
|
4
4
|
import { formatDate, parseDate } from "../ui.form-calendar/utilCalendar.ts";
|
|
5
|
+
import { getTokenIndexes } from "./utilDateRange.ts";
|
|
5
6
|
|
|
6
7
|
import type { Ref } from "vue";
|
|
7
8
|
import type { IsPeriod, SortedLocale } from "./types.ts";
|
|
@@ -28,6 +29,8 @@ export function useUserFormat(
|
|
|
28
29
|
? parseDate(localValue.value.to, dateFormat, locale.value)
|
|
29
30
|
: null;
|
|
30
31
|
|
|
32
|
+
let fromFormat = userDateFormat;
|
|
33
|
+
|
|
31
34
|
if (isDefaultTitle && from && to) {
|
|
32
35
|
let startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
|
|
33
36
|
const endMonthName = userFormatLocale.value.months.longhand[to.getMonth()];
|
|
@@ -40,8 +43,6 @@ export function useUserFormat(
|
|
|
40
43
|
const isDateToSameMonth = isSameMonth(from, to);
|
|
41
44
|
const isDateToSameYear = from.getFullYear() === to.getFullYear();
|
|
42
45
|
|
|
43
|
-
let fromFormat = userDateFormat;
|
|
44
|
-
|
|
45
46
|
if (isDateToSameMonth && isDateToSameYear) {
|
|
46
47
|
fromFormat = fromFormat.replace(/[YyMmFnU]/g, "");
|
|
47
48
|
}
|
|
@@ -50,6 +51,8 @@ export function useUserFormat(
|
|
|
50
51
|
fromFormat = fromFormat.replace(/[Yy]/g, "");
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
fromFormat = fromFormat.slice(...getTokenIndexes(fromFormat));
|
|
55
|
+
|
|
53
56
|
const fromTitle = from ? formatDate(from, fromFormat, userFormatLocale.value) : "";
|
|
54
57
|
const toTitle = to ? formatDate(to, userDateFormat, userFormatLocale.value) : "";
|
|
55
58
|
|
|
@@ -61,7 +64,9 @@ export function useUserFormat(
|
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
if (isPeriod.value.quarter || isPeriod.value.year) {
|
|
64
|
-
|
|
67
|
+
fromFormat = fromFormat.replace(/[Yy]/g, "");
|
|
68
|
+
|
|
69
|
+
fromFormat = fromFormat.slice(...getTokenIndexes(fromFormat));
|
|
65
70
|
|
|
66
71
|
const fromTitle = from ? formatDate(from, fromFormat, userFormatLocale.value) : "";
|
|
67
72
|
const toTitle = to ? formatDate(to, userDateFormat, userFormatLocale.value) : "";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getEndOfYear,
|
|
12
12
|
getStartOfYear,
|
|
13
13
|
} from "../ui.form-calendar/utilDate.ts";
|
|
14
|
+
import { formats } from "../ui.form-calendar/utilFormatting.ts";
|
|
14
15
|
|
|
15
16
|
export interface DatePeriodRange {
|
|
16
17
|
title: string | number;
|
|
@@ -116,3 +117,34 @@ export function getWeekDateList(date: Date, monthShortLocales: string[] = []) {
|
|
|
116
117
|
|
|
117
118
|
return weeks;
|
|
118
119
|
}
|
|
120
|
+
|
|
121
|
+
export function getTokenIndexes(inputString: string) {
|
|
122
|
+
let firstIndex = -1;
|
|
123
|
+
let lastIndex = 0;
|
|
124
|
+
let isEscaped = false;
|
|
125
|
+
|
|
126
|
+
const tokens = Object.keys(formats);
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < inputString.length; i++) {
|
|
129
|
+
const char = inputString[i];
|
|
130
|
+
|
|
131
|
+
if (char === "\\" && !isEscaped) {
|
|
132
|
+
isEscaped = true;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!isEscaped && tokens.includes(char)) {
|
|
137
|
+
if (firstIndex === -1) {
|
|
138
|
+
firstIndex = i;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
lastIndex = i + 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (isEscaped) {
|
|
145
|
+
isEscaped = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return [firstIndex, lastIndex];
|
|
150
|
+
}
|