vueless 0.0.31 → 0.0.33
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 +1 -1
- package/ui.dropdown-badge/index.vue +5 -3
- package/ui.dropdown-button/index.vue +5 -3
- package/ui.dropdown-link/index.vue +5 -3
- package/ui.form-calendar/components/DayView.vue +12 -3
- package/ui.form-calendar/configs/default.config.js +27 -4
- package/ui.form-calendar/index.vue +20 -2
- package/ui.form-date-picker/composables/attrs.composable.js +35 -1
- package/ui.form-date-picker/configs/default.config.js +80 -0
- package/ui.form-date-picker/index.vue +44 -5
- package/ui.form-date-picker-range/composables/attrs.composable.js +12 -1
- package/ui.form-date-picker-range/configs/default.config.js +29 -3
- package/ui.form-date-picker-range/index.vue +33 -7
- package/web-types.json +1 -1
package/package.json
CHANGED
|
@@ -237,8 +237,10 @@ function onClickOutside(event) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
function onBlurBadge(event) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
if (!event.target.isEqualNode(event.relatedTarget) && event.relatedTarget) {
|
|
242
|
+
hideOptions();
|
|
243
|
+
}
|
|
244
|
+
}, 100);
|
|
243
245
|
}
|
|
244
246
|
</script>
|
|
@@ -276,8 +276,10 @@ function onClickOutside(event) {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
function onBlurButton(event) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
setTimeout(() => {
|
|
280
|
+
if (!event.target.isEqualNode(event.relatedTarget) && event.relatedTarget) {
|
|
281
|
+
hideOptions();
|
|
282
|
+
}
|
|
283
|
+
}, 100);
|
|
282
284
|
}
|
|
283
285
|
</script>
|
|
@@ -264,8 +264,10 @@ function onClickOutside(event) {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
function onBlurLink(event) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
if (!event.target.isEqualNode(event.relatedTarget) && event.relatedTarget) {
|
|
269
|
+
hideOptions();
|
|
270
|
+
}
|
|
271
|
+
}, 100);
|
|
270
272
|
}
|
|
271
273
|
</script>
|
|
@@ -210,16 +210,25 @@ function getDay(date, dayNumber) {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
function getDayClasses(day) {
|
|
213
|
-
|
|
213
|
+
const isNotSelectedDate =
|
|
214
|
+
(!isSelectedDay(day) && !isSelectedToDay(day)) || props.selectedDate === null;
|
|
215
|
+
|
|
216
|
+
if (isToday(day) && isNotSelectedDate) {
|
|
214
217
|
return [currentDayAttrs.value.class];
|
|
215
218
|
}
|
|
216
219
|
|
|
217
220
|
if (props.range && isSelectedDay(day)) {
|
|
218
|
-
return [
|
|
221
|
+
return [
|
|
222
|
+
inRangeFirstDayAttrs.value.class,
|
|
223
|
+
isAnotherMothDay(day, activeMonthDate.value) && anotherMonthDayAttrs.value.class,
|
|
224
|
+
];
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
if (props.range && isSelectedToDay(day)) {
|
|
222
|
-
return [
|
|
228
|
+
return [
|
|
229
|
+
inRangeLastDayAttrs.value.class,
|
|
230
|
+
isAnotherMothDay(day, activeMonthDate.value) && anotherMonthDayAttrs.value.class,
|
|
231
|
+
];
|
|
223
232
|
}
|
|
224
233
|
|
|
225
234
|
if (
|
|
@@ -23,11 +23,11 @@ export default /*tw*/ {
|
|
|
23
23
|
weekDaysWrapper: "grid grid-cols-7",
|
|
24
24
|
weekDay: "flex size-8 items-center justify-center text-xs uppercase text-gray-500",
|
|
25
25
|
daysWrapper: "grid grid-cols-7",
|
|
26
|
-
day: "mx-auto
|
|
26
|
+
day: "mx-auto size-8 rounded-lg text-sm hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
27
27
|
activeDay: "bg-gray-100 hover:bg-gray-100",
|
|
28
|
-
inRangeFirstDay: "rounded-none rounded-l-lg bg-gray-200 text-gray-900",
|
|
29
|
-
inRangeLastDay: "rounded-none rounded-r-lg bg-gray-200 text-gray-900",
|
|
30
|
-
inRangeDay: "bg-gray-100 text-gray-900 hover
|
|
28
|
+
inRangeFirstDay: "rounded-none rounded-l-lg bg-gray-200 text-gray-900 hover:bg-gray-200",
|
|
29
|
+
inRangeLastDay: "rounded-none rounded-r-lg bg-gray-200 text-gray-900 hover:bg-gray-200",
|
|
30
|
+
inRangeDay: "bg-gray-100 text-gray-900 hover:!bg-gray-200 rounded-none",
|
|
31
31
|
selectedDay: "bg-gray-900 text-white hover:bg-gray-900",
|
|
32
32
|
currentDay: "hover:bg-gray-100 border-2 border-gray-900",
|
|
33
33
|
anotherMonthDay: "hover:bg-gray-100 text-gray-400",
|
|
@@ -80,6 +80,15 @@ export default /*tw*/ {
|
|
|
80
80
|
friday: "Friday",
|
|
81
81
|
saturday: "Saturday",
|
|
82
82
|
},
|
|
83
|
+
userFormat: {
|
|
84
|
+
sunday: "Sunday",
|
|
85
|
+
monday: "Monday",
|
|
86
|
+
tuesday: "Tuesday",
|
|
87
|
+
wednesday: "Wednesday",
|
|
88
|
+
thursday: "Thursday",
|
|
89
|
+
friday: "Friday",
|
|
90
|
+
saturday: "Saturday",
|
|
91
|
+
},
|
|
83
92
|
},
|
|
84
93
|
months: {
|
|
85
94
|
shorthand: {
|
|
@@ -110,6 +119,20 @@ export default /*tw*/ {
|
|
|
110
119
|
november: "November",
|
|
111
120
|
december: "December",
|
|
112
121
|
},
|
|
122
|
+
userFormat: {
|
|
123
|
+
january: "January",
|
|
124
|
+
february: "February",
|
|
125
|
+
march: "March",
|
|
126
|
+
april: "April",
|
|
127
|
+
may: "May",
|
|
128
|
+
june: "June",
|
|
129
|
+
july: "July",
|
|
130
|
+
august: "August",
|
|
131
|
+
september: "September",
|
|
132
|
+
october: "October",
|
|
133
|
+
november: "November",
|
|
134
|
+
december: "December",
|
|
135
|
+
},
|
|
113
136
|
},
|
|
114
137
|
timeLabel: "Time",
|
|
115
138
|
okLabel: "Ok",
|
|
@@ -358,6 +358,24 @@ const locale = computed(() => {
|
|
|
358
358
|
return formattedLocale;
|
|
359
359
|
});
|
|
360
360
|
|
|
361
|
+
const userFormatLocale = computed(() => {
|
|
362
|
+
const currentLocale = props.config.i18n || config.value.i18n;
|
|
363
|
+
|
|
364
|
+
const formattedLocale = {
|
|
365
|
+
...currentLocale,
|
|
366
|
+
months: {
|
|
367
|
+
shorthand: getSortedLocale(currentLocale.months.shorthand, LOCALE_TYPE.month),
|
|
368
|
+
longhand: getSortedLocale(currentLocale.months.userFormat, LOCALE_TYPE.month),
|
|
369
|
+
},
|
|
370
|
+
weekdays: {
|
|
371
|
+
shorthand: getSortedLocale(currentLocale.weekdays.shorthand, LOCALE_TYPE.day),
|
|
372
|
+
longhand: getSortedLocale(currentLocale.weekdays.userFormat, LOCALE_TYPE.day),
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
return formattedLocale;
|
|
377
|
+
});
|
|
378
|
+
|
|
361
379
|
const isTimepickerEnabled = computed(() => {
|
|
362
380
|
return props.timepicker && !props.range;
|
|
363
381
|
});
|
|
@@ -448,9 +466,9 @@ const formattedTime = computed(() => {
|
|
|
448
466
|
});
|
|
449
467
|
|
|
450
468
|
const userFormattedDate = computed(() => {
|
|
451
|
-
const date = formatDate(selectedDate.value, props.userFormat,
|
|
469
|
+
const date = formatDate(selectedDate.value, props.userFormat, userFormatLocale.value);
|
|
452
470
|
const dateTo = props.range
|
|
453
|
-
? formatDate(selectedDateTo.value, props.userFormat,
|
|
471
|
+
? formatDate(selectedDateTo.value, props.userFormat, userFormatLocale.value)
|
|
454
472
|
: undefined;
|
|
455
473
|
|
|
456
474
|
if (isTimepickerEnabled.value && selectedDate.value) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import useUI from "../../composable.ui";
|
|
2
2
|
|
|
3
3
|
import defaultConfig from "../configs/default.config";
|
|
4
|
-
import { computed } from "vue";
|
|
4
|
+
import { computed, watchEffect } from "vue";
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props, { isShownCalendar }) {
|
|
7
7
|
const { config, getAttrs } = useUI(defaultConfig, () => props.config);
|
|
@@ -14,6 +14,40 @@ export default function useAttrs(props, { isShownCalendar }) {
|
|
|
14
14
|
return isShownCalendar.value ? inputActiveAttrs.value : inputBlurAttrs.value;
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
// This watcher rewrites default calendar locales with datepicker range locales
|
|
18
|
+
// Watcher will not rewrite custom calendar locales
|
|
19
|
+
watchEffect(() => {
|
|
20
|
+
if (!calendarAttrs.value.config) {
|
|
21
|
+
calendarAttrs.value.config = {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (calendarAttrs.value.config.i18n || !props.config.i18n) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
calendarAttrs.value.config.i18n = {
|
|
29
|
+
...config.value.i18n,
|
|
30
|
+
weekdays: {
|
|
31
|
+
shorthand: { ...config.value.i18n.weekdays.shorthand },
|
|
32
|
+
longhand: { ...config.value.i18n.weekdays.longhand },
|
|
33
|
+
},
|
|
34
|
+
months: {
|
|
35
|
+
shorthand: { ...config.value.i18n.months.shorthand },
|
|
36
|
+
longhand: { ...config.value.i18n.months.longhand },
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (props.config.i18n.weekdays.userFormat) {
|
|
41
|
+
calendarAttrs.value.config.i18n.userFormat = {
|
|
42
|
+
...config.value.i18n.weekdays.userFormat,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (props.config.i18n.months.userFormat) {
|
|
47
|
+
calendarAttrs.value.config.i18n.userFormat = { ...config.value.i18n.months.userFormat };
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
17
51
|
return {
|
|
18
52
|
config,
|
|
19
53
|
calendarAttrs,
|
|
@@ -14,6 +14,86 @@ export default /*tw*/ {
|
|
|
14
14
|
leaveActiveClass: "transition transform ease-in duration-75",
|
|
15
15
|
leaveToClass: "opacity-0 scale-95",
|
|
16
16
|
},
|
|
17
|
+
i18n: {
|
|
18
|
+
today: "Today",
|
|
19
|
+
yesterday: "Yesterday",
|
|
20
|
+
tomorrow: "Tomorrow",
|
|
21
|
+
weekdays: {
|
|
22
|
+
shorthand: {
|
|
23
|
+
sunday: "Sun",
|
|
24
|
+
monday: "Mon",
|
|
25
|
+
tuesday: "Tue",
|
|
26
|
+
wednesday: "Wed",
|
|
27
|
+
thursday: "Thu",
|
|
28
|
+
friday: "Fri",
|
|
29
|
+
saturday: "Sat",
|
|
30
|
+
},
|
|
31
|
+
longhand: {
|
|
32
|
+
sunday: "Sunday",
|
|
33
|
+
monday: "Monday",
|
|
34
|
+
tuesday: "Tuesday",
|
|
35
|
+
wednesday: "Wednesday",
|
|
36
|
+
thursday: "Thursday",
|
|
37
|
+
friday: "Friday",
|
|
38
|
+
saturday: "Saturday",
|
|
39
|
+
},
|
|
40
|
+
userFormat: {
|
|
41
|
+
sunday: "Sunday",
|
|
42
|
+
monday: "Monday",
|
|
43
|
+
tuesday: "Tuesday",
|
|
44
|
+
wednesday: "Wednesday",
|
|
45
|
+
thursday: "Thursday",
|
|
46
|
+
friday: "Friday",
|
|
47
|
+
saturday: "Saturday",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
months: {
|
|
51
|
+
shorthand: {
|
|
52
|
+
january: "Jan",
|
|
53
|
+
february: "Feb",
|
|
54
|
+
march: "Mar",
|
|
55
|
+
april: "Apr",
|
|
56
|
+
may: "May",
|
|
57
|
+
june: "Jun",
|
|
58
|
+
july: "Jul",
|
|
59
|
+
august: "Aug",
|
|
60
|
+
september: "Sep",
|
|
61
|
+
october: "Oct",
|
|
62
|
+
november: "Nov",
|
|
63
|
+
december: "Dec",
|
|
64
|
+
},
|
|
65
|
+
longhand: {
|
|
66
|
+
january: "January",
|
|
67
|
+
february: "February",
|
|
68
|
+
march: "March",
|
|
69
|
+
april: "April",
|
|
70
|
+
may: "May",
|
|
71
|
+
june: "June",
|
|
72
|
+
july: "July",
|
|
73
|
+
august: "August",
|
|
74
|
+
september: "September",
|
|
75
|
+
october: "October",
|
|
76
|
+
november: "November",
|
|
77
|
+
december: "December",
|
|
78
|
+
},
|
|
79
|
+
userFormat: {
|
|
80
|
+
january: "January",
|
|
81
|
+
february: "February",
|
|
82
|
+
march: "March",
|
|
83
|
+
april: "April",
|
|
84
|
+
may: "May",
|
|
85
|
+
june: "June",
|
|
86
|
+
july: "July",
|
|
87
|
+
august: "August",
|
|
88
|
+
september: "September",
|
|
89
|
+
october: "October",
|
|
90
|
+
november: "November",
|
|
91
|
+
december: "December",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
timeLabel: "Time",
|
|
95
|
+
okLabel: "Ok",
|
|
96
|
+
},
|
|
17
97
|
defaultVariants: {
|
|
18
98
|
dateFormat: "Y-m-d",
|
|
19
99
|
userFormat: "F j, Y",
|
|
@@ -60,6 +60,12 @@ import { VIEW } from "../ui.form-calendar/constants";
|
|
|
60
60
|
|
|
61
61
|
import UIService, { getRandomId } from "../service.ui";
|
|
62
62
|
|
|
63
|
+
import {
|
|
64
|
+
addDays,
|
|
65
|
+
isSameDay,
|
|
66
|
+
getDateFromUnixTimestamp,
|
|
67
|
+
} from "../ui.form-calendar/services/date.service";
|
|
68
|
+
|
|
63
69
|
import useAttrs from "./composables/attrs.composable";
|
|
64
70
|
import defaultConfig from "./configs/default.config";
|
|
65
71
|
import { UDatePicker } from "./constants";
|
|
@@ -193,6 +199,8 @@ const props = defineProps({
|
|
|
193
199
|
|
|
194
200
|
const emit = defineEmits(["update:modelValue", "input"]);
|
|
195
201
|
|
|
202
|
+
const STANDARD_USER_FORMAT = "l, j F, Y";
|
|
203
|
+
|
|
196
204
|
const isShownCalendar = ref(false);
|
|
197
205
|
const userFormatDate = ref("");
|
|
198
206
|
const formattedDate = ref("");
|
|
@@ -216,7 +224,7 @@ const { config, inputAttrs, calendarAttrs } = useAttrs(props, { isShownCalendar
|
|
|
216
224
|
function activate() {
|
|
217
225
|
isShownCalendar.value = true;
|
|
218
226
|
|
|
219
|
-
nextTick(() => calendarRef.value
|
|
227
|
+
nextTick(() => calendarRef.value?.wrapperRef?.focus());
|
|
220
228
|
}
|
|
221
229
|
|
|
222
230
|
function deactivate() {
|
|
@@ -226,7 +234,7 @@ function deactivate() {
|
|
|
226
234
|
}
|
|
227
235
|
|
|
228
236
|
function onUserFormatDateChange(value) {
|
|
229
|
-
userFormatDate.value = value || "";
|
|
237
|
+
userFormatDate.value = formatUserDate(value) || "";
|
|
230
238
|
}
|
|
231
239
|
|
|
232
240
|
function onFormattedDateChange(value) {
|
|
@@ -240,14 +248,45 @@ function onSubmit() {
|
|
|
240
248
|
function onBlur(event) {
|
|
241
249
|
const { relatedTarget } = event;
|
|
242
250
|
|
|
243
|
-
if (!calendarRef
|
|
251
|
+
if (!calendarRef?.value?.wrapperRef?.contains(relatedTarget)) deactivate();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function formatUserDate(data) {
|
|
255
|
+
if (props.dateFormat !== STANDARD_USER_FORMAT) return data;
|
|
256
|
+
|
|
257
|
+
const currentLocale = props.config.i18n || config.value.i18n;
|
|
258
|
+
|
|
259
|
+
let prefix = "";
|
|
260
|
+
const formattedDate = data.charAt(0).toUpperCase() + data.toLowerCase().slice(1);
|
|
261
|
+
const formattedDateWithoutDay = formattedDate.split(",").slice(1).join("").trim();
|
|
262
|
+
|
|
263
|
+
const selectedDate = getDateFromUnixTimestamp(localValue.value);
|
|
264
|
+
const today = new Date();
|
|
265
|
+
|
|
266
|
+
const isToday = isSameDay(today, selectedDate);
|
|
267
|
+
const isYesterday = isSameDay(addDays(today, -1), selectedDate);
|
|
268
|
+
const isTomorrow = isSameDay(addDays(today, 1), selectedDate);
|
|
269
|
+
|
|
270
|
+
if (isToday) {
|
|
271
|
+
prefix = currentLocale.today;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (isYesterday) {
|
|
275
|
+
prefix = currentLocale.yesterday;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (isTomorrow) {
|
|
279
|
+
prefix = currentLocale.tomorrow;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return prefix ? `${prefix}, ${formattedDateWithoutDay}` : formattedDate;
|
|
244
283
|
}
|
|
245
284
|
|
|
246
285
|
function onInput() {
|
|
247
286
|
nextTick(() => {
|
|
248
|
-
calendarRef.value
|
|
287
|
+
calendarRef.value?.wrapperRef?.blur();
|
|
249
288
|
emit("input", {
|
|
250
|
-
userFormatDate: userFormatDate.value,
|
|
289
|
+
userFormatDate: formatUserDate(userFormatDate.value),
|
|
251
290
|
value: localValue.value,
|
|
252
291
|
formattedDate: formattedDate.value,
|
|
253
292
|
});
|
|
@@ -25,11 +25,12 @@ export default function useAttrs(props, { isShownMenu }) {
|
|
|
25
25
|
calendarAttrs.value.config = {};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
if (calendarAttrs.value.config.i18n) {
|
|
28
|
+
if (calendarAttrs.value.config.i18n || !props.config.i18n) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
calendarAttrs.value.config.i18n = {
|
|
33
|
+
...config.value.i18n,
|
|
33
34
|
weekdays: {
|
|
34
35
|
shorthand: { ...config.value.i18n.weekdays.shorthand },
|
|
35
36
|
longhand: { ...config.value.i18n.weekdays.longhand },
|
|
@@ -39,6 +40,16 @@ export default function useAttrs(props, { isShownMenu }) {
|
|
|
39
40
|
longhand: { ...config.value.i18n.months.longhand },
|
|
40
41
|
},
|
|
41
42
|
};
|
|
43
|
+
|
|
44
|
+
if (props.config.i18n.weekdays.userFormat) {
|
|
45
|
+
calendarAttrs.value.config.i18n.userFormat = {
|
|
46
|
+
...config.value.i18n.weekdays.userFormat,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (props.config.i18n.months.userFormat) {
|
|
51
|
+
calendarAttrs.value.config.i18n.userFormat = { ...config.value.i18n.months.userFormat };
|
|
52
|
+
}
|
|
42
53
|
});
|
|
43
54
|
|
|
44
55
|
const inputAttrs = computed(() => {
|
|
@@ -77,15 +77,18 @@ export default /*tw*/ {
|
|
|
77
77
|
navigation: "px-0 w-full",
|
|
78
78
|
nextIcon: {
|
|
79
79
|
defaultVariants: {
|
|
80
|
-
variant: "
|
|
80
|
+
variant: "grayscale",
|
|
81
|
+
size: "sm",
|
|
81
82
|
},
|
|
82
83
|
},
|
|
83
84
|
prevIcon: {
|
|
84
85
|
defaultVariants: {
|
|
85
|
-
variant: "
|
|
86
|
+
variant: "grayscale",
|
|
87
|
+
size: "sm",
|
|
86
88
|
},
|
|
87
89
|
},
|
|
88
|
-
day: "font-medium w-full h-10 text-sm",
|
|
90
|
+
day: "font-medium w-full h-10 text-sm mb-0.5",
|
|
91
|
+
currentDay: "text-white bg-gray-900 hover:bg-gray-900 hover:text-white",
|
|
89
92
|
weekDay: "text-sm size-10",
|
|
90
93
|
month: "font-medium",
|
|
91
94
|
selectedMonth: "bg-zinc-100 text-gray-900 hover:text-white",
|
|
@@ -121,6 +124,15 @@ export default /*tw*/ {
|
|
|
121
124
|
friday: "Friday",
|
|
122
125
|
saturday: "Saturday",
|
|
123
126
|
},
|
|
127
|
+
userFormat: {
|
|
128
|
+
sunday: "Sunday",
|
|
129
|
+
monday: "Monday",
|
|
130
|
+
tuesday: "Tuesday",
|
|
131
|
+
wednesday: "Wednesday",
|
|
132
|
+
thursday: "Thursday",
|
|
133
|
+
friday: "Friday",
|
|
134
|
+
saturday: "Saturday",
|
|
135
|
+
},
|
|
124
136
|
},
|
|
125
137
|
months: {
|
|
126
138
|
shorthand: {
|
|
@@ -151,6 +163,20 @@ export default /*tw*/ {
|
|
|
151
163
|
november: "November",
|
|
152
164
|
december: "December",
|
|
153
165
|
},
|
|
166
|
+
userFormat: {
|
|
167
|
+
january: "January",
|
|
168
|
+
february: "February",
|
|
169
|
+
march: "March",
|
|
170
|
+
april: "April",
|
|
171
|
+
may: "May",
|
|
172
|
+
june: "June",
|
|
173
|
+
july: "July",
|
|
174
|
+
august: "August",
|
|
175
|
+
september: "September",
|
|
176
|
+
october: "October",
|
|
177
|
+
november: "November",
|
|
178
|
+
december: "December",
|
|
179
|
+
},
|
|
154
180
|
},
|
|
155
181
|
},
|
|
156
182
|
defaultVariants: {
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
ref="rangeInputStartRef"
|
|
140
140
|
v-model="rangeStart"
|
|
141
141
|
:error="inputRangeStartError"
|
|
142
|
+
size="sm"
|
|
142
143
|
v-bind="rangeInputAttrs"
|
|
143
144
|
:name="rangeInputName"
|
|
144
145
|
@input="onInputRangeInput($event, INPUT_RANGE_TYPE.start)"
|
|
@@ -149,6 +150,7 @@
|
|
|
149
150
|
ref="rangeInputEndRef"
|
|
150
151
|
v-model="rangeEnd"
|
|
151
152
|
:error="inputRangeEndError"
|
|
153
|
+
size="sm"
|
|
152
154
|
v-bind="rangeInputAttrs"
|
|
153
155
|
:name="rangeInputName"
|
|
154
156
|
@input="onInputRangeInput($event, INPUT_RANGE_TYPE.end)"
|
|
@@ -205,6 +207,7 @@ import {
|
|
|
205
207
|
getStartOfWeek,
|
|
206
208
|
getStartOfYear,
|
|
207
209
|
getDatesDifference,
|
|
210
|
+
isSameMonth,
|
|
208
211
|
} from "../ui.form-calendar/services/date.service";
|
|
209
212
|
|
|
210
213
|
import {
|
|
@@ -427,6 +430,24 @@ const locale = computed(() => {
|
|
|
427
430
|
return formattedLocale;
|
|
428
431
|
});
|
|
429
432
|
|
|
433
|
+
const userFormatLocale = computed(() => {
|
|
434
|
+
const currentLocale = props.config.i18n || config.value.i18n;
|
|
435
|
+
|
|
436
|
+
const formattedLocale = {
|
|
437
|
+
...currentLocale,
|
|
438
|
+
months: {
|
|
439
|
+
shorthand: getSortedLocale(currentLocale.months.shorthand, LOCALE_TYPE.month),
|
|
440
|
+
longhand: getSortedLocale(currentLocale.months.userFormat, LOCALE_TYPE.month),
|
|
441
|
+
},
|
|
442
|
+
weekdays: {
|
|
443
|
+
shorthand: getSortedLocale(currentLocale.weekdays.shorthand, LOCALE_TYPE.day),
|
|
444
|
+
longhand: getSortedLocale(currentLocale.weekdays.userFormat, LOCALE_TYPE.day),
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
return formattedLocale;
|
|
449
|
+
});
|
|
450
|
+
|
|
430
451
|
const periods = computed(() => [
|
|
431
452
|
{
|
|
432
453
|
name: PERIOD.week,
|
|
@@ -489,9 +510,9 @@ const userFormatDate = computed(() => {
|
|
|
489
510
|
const to = localValue.value.to !== null ? getDateFromUnixTimestamp(localValue.value.to) : null;
|
|
490
511
|
|
|
491
512
|
if (isDefaultTitle) {
|
|
492
|
-
let startMonthName =
|
|
513
|
+
let startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
|
|
493
514
|
let startYear = from.getFullYear();
|
|
494
|
-
let endMonthName =
|
|
515
|
+
let endMonthName = userFormatLocale.value.months.longhand[to?.getMonth()];
|
|
495
516
|
let endYear = to?.getFullYear();
|
|
496
517
|
|
|
497
518
|
if (startMonthName === endMonthName && endMonthName === endYear) {
|
|
@@ -502,22 +523,24 @@ const userFormatDate = computed(() => {
|
|
|
502
523
|
startYear = "";
|
|
503
524
|
}
|
|
504
525
|
|
|
505
|
-
const fromTitle =
|
|
526
|
+
const fromTitle = isSameMonth(from, to)
|
|
527
|
+
? from.getDate()
|
|
528
|
+
: `${from.getDate()} ${startMonthName} ${startYear}`;
|
|
506
529
|
const toTitle = to ? `${to.getDate()} ${endMonthName} ${endYear}` : "";
|
|
507
530
|
|
|
508
531
|
title = `${fromTitle} – ${toTitle}`;
|
|
509
532
|
}
|
|
510
533
|
|
|
511
534
|
if (isPeriod.value.month) {
|
|
512
|
-
const startMonthName =
|
|
535
|
+
const startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
|
|
513
536
|
const startYear = from.getFullYear();
|
|
514
537
|
|
|
515
538
|
title = `${startMonthName} ${startYear}`;
|
|
516
539
|
}
|
|
517
540
|
|
|
518
541
|
if (isPeriod.value.quarter || isPeriod.value.year) {
|
|
519
|
-
const startMonthName =
|
|
520
|
-
const endMonthName =
|
|
542
|
+
const startMonthName = userFormatLocale.value.months.longhand[from.getMonth()];
|
|
543
|
+
const endMonthName = userFormatLocale.value.months.longhand[to?.getMonth()];
|
|
521
544
|
const endYear = to?.getFullYear();
|
|
522
545
|
|
|
523
546
|
const fromTitle = `${from.getDate()} ${startMonthName}`;
|
|
@@ -745,8 +768,11 @@ function onBlur(event) {
|
|
|
745
768
|
|
|
746
769
|
function onBlurRangeInput(event) {
|
|
747
770
|
const { relatedTarget } = event;
|
|
771
|
+
const isRangeInputFocus = relatedTarget?.name === rangeInputName.value;
|
|
748
772
|
|
|
749
|
-
|
|
773
|
+
if (!isRangeInputFocus) {
|
|
774
|
+
menuRef.value.focus();
|
|
775
|
+
}
|
|
750
776
|
|
|
751
777
|
if (!menuRef.value.contains(relatedTarget) && !isHoverEvent.value) {
|
|
752
778
|
deactivate();
|