vueless 0.0.384 → 0.0.385
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.form-calendar/UCalendarDayView.vue +61 -29
- package/ui.form-calendar/UCalendarMonthView.vue +95 -50
- package/ui.form-calendar/UCalendarYearView.vue +95 -50
- package/ui.form-calendar/config.js +8 -0
- package/ui.form-calendar/useAttrs.js +62 -0
- package/ui.form-date-picker/config.js +2 -2
- package/ui.form-date-picker-range/config.js +3 -2
- package/web-types.json +1 -1
package/package.json
CHANGED
|
@@ -6,7 +6,21 @@
|
|
|
6
6
|
<div v-bind="daysAttrs">
|
|
7
7
|
<template v-for="day in days" :key="day">
|
|
8
8
|
<UButton
|
|
9
|
-
v-if="getDayState(day).
|
|
9
|
+
v-if="getDayState(day).isSelectedDay && !props.range"
|
|
10
|
+
tabindex="-1"
|
|
11
|
+
variant="primary"
|
|
12
|
+
color="brand"
|
|
13
|
+
no-ring
|
|
14
|
+
square
|
|
15
|
+
v-bind="selectedDayAttrs"
|
|
16
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
17
|
+
:label="formatDate(day, 'j', locale)"
|
|
18
|
+
@mousedown.prevent.capture
|
|
19
|
+
@click="onClickDay(day)"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<UButton
|
|
23
|
+
v-else-if="getDayState(day).isCurrentDay && !getDayState(day).isDayInRange"
|
|
10
24
|
tabindex="-1"
|
|
11
25
|
variant="thirdary"
|
|
12
26
|
color="brand"
|
|
@@ -20,13 +34,14 @@
|
|
|
20
34
|
/>
|
|
21
35
|
|
|
22
36
|
<UButton
|
|
23
|
-
v-else-if="getDayState(day).
|
|
37
|
+
v-else-if="getDayState(day).isCurrentFirstDayInRange"
|
|
24
38
|
tabindex="-1"
|
|
25
39
|
variant="thirdary"
|
|
26
40
|
color="brand"
|
|
27
41
|
no-ring
|
|
28
42
|
square
|
|
29
|
-
|
|
43
|
+
filled
|
|
44
|
+
v-bind="currentFirstDayInRangeAttrs"
|
|
30
45
|
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
31
46
|
:label="formatDate(day, 'j', locale)"
|
|
32
47
|
@mousedown.prevent.capture
|
|
@@ -34,14 +49,14 @@
|
|
|
34
49
|
/>
|
|
35
50
|
|
|
36
51
|
<UButton
|
|
37
|
-
v-else-if="getDayState(day).
|
|
52
|
+
v-else-if="getDayState(day).isCurrentLastDayInRange"
|
|
38
53
|
tabindex="-1"
|
|
39
54
|
variant="thirdary"
|
|
40
55
|
color="brand"
|
|
41
56
|
no-ring
|
|
42
57
|
square
|
|
43
58
|
filled
|
|
44
|
-
v-bind="
|
|
59
|
+
v-bind="currentLastDayInRangeAttrs"
|
|
45
60
|
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
46
61
|
:label="formatDate(day, 'j', locale)"
|
|
47
62
|
@mousedown.prevent.capture
|
|
@@ -49,14 +64,14 @@
|
|
|
49
64
|
/>
|
|
50
65
|
|
|
51
66
|
<UButton
|
|
52
|
-
v-else-if="getDayState(day).
|
|
67
|
+
v-else-if="getDayState(day).isFirstDayInRange"
|
|
53
68
|
tabindex="-1"
|
|
54
69
|
variant="thirdary"
|
|
55
70
|
color="brand"
|
|
56
71
|
no-ring
|
|
57
72
|
square
|
|
58
73
|
filled
|
|
59
|
-
v-bind="
|
|
74
|
+
v-bind="firstDayInRangeAttrs"
|
|
60
75
|
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
61
76
|
:label="formatDate(day, 'j', locale)"
|
|
62
77
|
@mousedown.prevent.capture
|
|
@@ -79,14 +94,14 @@
|
|
|
79
94
|
/>
|
|
80
95
|
|
|
81
96
|
<UButton
|
|
82
|
-
v-else-if="getDayState(day).
|
|
97
|
+
v-else-if="getDayState(day).isAnotherMonthFirstDayInRange"
|
|
83
98
|
tabindex="-1"
|
|
84
99
|
variant="thirdary"
|
|
85
100
|
color="brand"
|
|
86
101
|
no-ring
|
|
87
102
|
square
|
|
88
103
|
filled
|
|
89
|
-
v-bind="
|
|
104
|
+
v-bind="anotherMonthFirstDayInRangeAttrs"
|
|
90
105
|
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
91
106
|
:label="formatDate(day, 'j', locale)"
|
|
92
107
|
@mousedown.prevent.capture
|
|
@@ -94,13 +109,14 @@
|
|
|
94
109
|
/>
|
|
95
110
|
|
|
96
111
|
<UButton
|
|
97
|
-
v-else-if="getDayState(day).
|
|
112
|
+
v-else-if="getDayState(day).isAnotherMonthLastDayInRange"
|
|
98
113
|
tabindex="-1"
|
|
99
|
-
variant="
|
|
114
|
+
variant="thirdary"
|
|
100
115
|
color="brand"
|
|
101
116
|
no-ring
|
|
102
117
|
square
|
|
103
|
-
|
|
118
|
+
filled
|
|
119
|
+
v-bind="anotherMonthLastDayInRangeAttrs"
|
|
104
120
|
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
105
121
|
:label="formatDate(day, 'j', locale)"
|
|
106
122
|
@mousedown.prevent.capture
|
|
@@ -108,13 +124,13 @@
|
|
|
108
124
|
/>
|
|
109
125
|
|
|
110
126
|
<UButton
|
|
111
|
-
v-else-if="getDayState(day).
|
|
127
|
+
v-else-if="getDayState(day).isDayInRange && getDayState(day).isCurrentDay"
|
|
112
128
|
tabindex="-1"
|
|
113
129
|
variant="thirdary"
|
|
114
130
|
color="brand"
|
|
115
131
|
no-ring
|
|
116
132
|
square
|
|
117
|
-
v-bind="
|
|
133
|
+
v-bind="currentDayInRangeAttrs"
|
|
118
134
|
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
119
135
|
:label="formatDate(day, 'j', locale)"
|
|
120
136
|
@mousedown.prevent.capture
|
|
@@ -135,6 +151,20 @@
|
|
|
135
151
|
@click="onClickDay(day)"
|
|
136
152
|
/>
|
|
137
153
|
|
|
154
|
+
<UButton
|
|
155
|
+
v-else-if="getDayState(day).isActiveDay"
|
|
156
|
+
tabindex="-1"
|
|
157
|
+
variant="thirdary"
|
|
158
|
+
color="brand"
|
|
159
|
+
no-ring
|
|
160
|
+
square
|
|
161
|
+
v-bind="activeDayAttrs"
|
|
162
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
163
|
+
:label="formatDate(day, 'j', locale)"
|
|
164
|
+
@mousedown.prevent.capture
|
|
165
|
+
@click="onClickDay(day)"
|
|
166
|
+
/>
|
|
167
|
+
|
|
138
168
|
<UButton
|
|
139
169
|
v-else-if="getDayState(day).isAnotherMonthDay"
|
|
140
170
|
tabindex="-1"
|
|
@@ -150,7 +180,7 @@
|
|
|
150
180
|
/>
|
|
151
181
|
|
|
152
182
|
<UButton
|
|
153
|
-
v-else
|
|
183
|
+
v-else-if="!getDayState(day).isSelectedDay"
|
|
154
184
|
tabindex="-1"
|
|
155
185
|
variant="thirdary"
|
|
156
186
|
color="brand"
|
|
@@ -255,6 +285,8 @@ const {
|
|
|
255
285
|
anotherMonthLastDayInRangeAttrs,
|
|
256
286
|
selectedDayAttrs,
|
|
257
287
|
activeDayAttrs,
|
|
288
|
+
currentLastDayInRangeAttrs,
|
|
289
|
+
currentFirstDayInRangeAttrs,
|
|
258
290
|
} = useAttrs(props);
|
|
259
291
|
|
|
260
292
|
const localSelectedDate = computed(() => {
|
|
@@ -376,31 +408,31 @@ function getDayState(day) {
|
|
|
376
408
|
props.dateFormat,
|
|
377
409
|
);
|
|
378
410
|
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
props.selectedDate === null;
|
|
382
|
-
|
|
383
|
-
const isCurrentDay = isToday(day) && isNotSelectedDate;
|
|
384
|
-
const isCurrentDayInRange = isCurrentDay && isDayInRange;
|
|
411
|
+
const isSelectedDay = isSameDay(day, localSelectedDate.value) && props.selectedDate !== null;
|
|
412
|
+
const isCurrentDay = isToday(day);
|
|
385
413
|
const isAnotherMonthDay = isAnotherMothDay(day, activeMonthDate.value);
|
|
414
|
+
const isCurrentDayInRange = isCurrentDay && isDayInRange;
|
|
386
415
|
const isFirstDayInRange = props.range && isSameDay(day, localSelectedDate.value);
|
|
387
|
-
const isAnotherMonthFirstDayInRange = isFirstDayInRange && isAnotherMonthDay;
|
|
388
416
|
const isLastDayInRange = props.range && isSameDay(day, props.selectedDateTo);
|
|
389
|
-
const
|
|
390
|
-
const
|
|
391
|
-
const
|
|
417
|
+
const isCurrentFirstDayInRange = isFirstDayInRange && isCurrentDay;
|
|
418
|
+
const isCurrentLastDayInRange = isLastDayInRange && isCurrentDay;
|
|
419
|
+
const isAnotherMonthFirstDayInRange = isFirstDayInRange && isAnotherMonthDay;
|
|
420
|
+
const isAnotherMonthLastDayInRange = isLastDayInRange && isAnotherMonthDay;
|
|
421
|
+
const isActiveDay = isSameDay(props.activeDate, day) && !props.range;
|
|
392
422
|
|
|
393
423
|
return {
|
|
424
|
+
isDayInRange,
|
|
425
|
+
isSelectedDay,
|
|
394
426
|
isCurrentDay,
|
|
427
|
+
isAnotherMonthDay,
|
|
395
428
|
isCurrentDayInRange,
|
|
396
429
|
isFirstDayInRange,
|
|
397
|
-
isAnotherMonthFirstDayInRange,
|
|
398
430
|
isLastDayInRange,
|
|
431
|
+
isCurrentFirstDayInRange,
|
|
432
|
+
isCurrentLastDayInRange,
|
|
433
|
+
isAnotherMonthFirstDayInRange,
|
|
399
434
|
isAnotherMonthLastDayInRange,
|
|
400
|
-
isDayInRange,
|
|
401
|
-
isSelectedDay,
|
|
402
435
|
isActiveDay,
|
|
403
|
-
isAnotherMonthDay,
|
|
404
436
|
};
|
|
405
437
|
}
|
|
406
438
|
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="monthViewAttrs">
|
|
3
|
-
<template v-for="month in months" :key="month">
|
|
3
|
+
<template v-for="(month, idx) in months" :key="month">
|
|
4
4
|
<UButton
|
|
5
|
-
v-if="getMonthState(month).
|
|
5
|
+
v-if="getMonthState(month, idx).isSelectedMonth && !props.range"
|
|
6
|
+
variant="primary"
|
|
7
|
+
color="brand"
|
|
8
|
+
no-ring
|
|
9
|
+
v-bind="selectedMonthAttrs"
|
|
10
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
11
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
12
|
+
@click="onClickMonth(month)"
|
|
13
|
+
@mousedown.prevent.capture
|
|
14
|
+
/>
|
|
15
|
+
|
|
16
|
+
<UButton
|
|
17
|
+
v-else-if="
|
|
18
|
+
getMonthState(month, idx).isCurrentMonth && !getMonthState(month, idx).isMonthInRange
|
|
19
|
+
"
|
|
6
20
|
variant="thirdary"
|
|
7
21
|
color="brand"
|
|
8
22
|
no-ring
|
|
@@ -14,11 +28,25 @@
|
|
|
14
28
|
/>
|
|
15
29
|
|
|
16
30
|
<UButton
|
|
17
|
-
v-else-if="getMonthState(month).
|
|
18
|
-
variant="
|
|
31
|
+
v-else-if="getMonthState(month, idx).isCurrentFirstMonthInRange"
|
|
32
|
+
variant="thirdary"
|
|
19
33
|
color="brand"
|
|
20
34
|
no-ring
|
|
21
|
-
|
|
35
|
+
filled
|
|
36
|
+
v-bind="currentFirstMonthInRangeAttrs"
|
|
37
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
38
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
39
|
+
@click="onClickMonth(month)"
|
|
40
|
+
@mousedown.prevent.capture
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<UButton
|
|
44
|
+
v-else-if="getMonthState(month, idx).isCurrentLastMonthInRange"
|
|
45
|
+
variant="thirdary"
|
|
46
|
+
color="brand"
|
|
47
|
+
no-ring
|
|
48
|
+
filled
|
|
49
|
+
v-bind="currentLastMonthInRangeAttrs"
|
|
22
50
|
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
23
51
|
:label="formatDate(month, 'M', props.locale)"
|
|
24
52
|
@click="onClickMonth(month)"
|
|
@@ -26,7 +54,7 @@
|
|
|
26
54
|
/>
|
|
27
55
|
|
|
28
56
|
<UButton
|
|
29
|
-
v-else-if="getMonthState(month).isFirstMonthInRange"
|
|
57
|
+
v-else-if="getMonthState(month, idx).isFirstMonthInRange"
|
|
30
58
|
variant="thirdary"
|
|
31
59
|
color="brand"
|
|
32
60
|
no-ring
|
|
@@ -39,7 +67,7 @@
|
|
|
39
67
|
/>
|
|
40
68
|
|
|
41
69
|
<UButton
|
|
42
|
-
v-else-if="getMonthState(month).isLastMonthInRange"
|
|
70
|
+
v-else-if="getMonthState(month, idx).isLastMonthInRange"
|
|
43
71
|
variant="thirdary"
|
|
44
72
|
color="brand"
|
|
45
73
|
no-ring
|
|
@@ -52,11 +80,26 @@
|
|
|
52
80
|
/>
|
|
53
81
|
|
|
54
82
|
<UButton
|
|
55
|
-
v-else-if="
|
|
56
|
-
|
|
83
|
+
v-else-if="
|
|
84
|
+
getMonthState(month, idx).isCurrentMonthInRange &&
|
|
85
|
+
!getMonthState(month, idx).isMoreThanOneMonthRange
|
|
86
|
+
"
|
|
87
|
+
variant="primary"
|
|
57
88
|
color="brand"
|
|
58
89
|
no-ring
|
|
59
|
-
v-bind="
|
|
90
|
+
v-bind="singleCurrentMonthInRangeAttrs"
|
|
91
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
92
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
93
|
+
@click="onClickMonth(month)"
|
|
94
|
+
@mousedown.prevent.capture
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<UButton
|
|
98
|
+
v-else-if="getMonthState(month, idx).isCurrentMonthInRange"
|
|
99
|
+
variant="primary"
|
|
100
|
+
color="brand"
|
|
101
|
+
no-ring
|
|
102
|
+
v-bind="currentMonthInRangeAttrs"
|
|
60
103
|
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
61
104
|
:label="formatDate(month, 'M', props.locale)"
|
|
62
105
|
@click="onClickMonth(month)"
|
|
@@ -64,11 +107,14 @@
|
|
|
64
107
|
/>
|
|
65
108
|
|
|
66
109
|
<UButton
|
|
67
|
-
v-else-if="
|
|
110
|
+
v-else-if="
|
|
111
|
+
!getMonthState(month, idx).isMoreThanOneMonthRange &&
|
|
112
|
+
getMonthState(month, idx).isMonthInRange
|
|
113
|
+
"
|
|
68
114
|
variant="thirdary"
|
|
69
115
|
color="brand"
|
|
70
116
|
no-ring
|
|
71
|
-
v-bind="
|
|
117
|
+
v-bind="singleMonthInRangeAttrs"
|
|
72
118
|
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
73
119
|
:label="formatDate(month, 'M', props.locale)"
|
|
74
120
|
@click="onClickMonth(month)"
|
|
@@ -76,11 +122,14 @@
|
|
|
76
122
|
/>
|
|
77
123
|
|
|
78
124
|
<UButton
|
|
79
|
-
v-else-if="
|
|
125
|
+
v-else-if="
|
|
126
|
+
getMonthState(month, idx).isMonthInRange &&
|
|
127
|
+
getMonthState(month, idx).isMoreThanOneMonthRange
|
|
128
|
+
"
|
|
80
129
|
variant="thirdary"
|
|
81
130
|
color="brand"
|
|
82
131
|
no-ring
|
|
83
|
-
v-bind="
|
|
132
|
+
v-bind="monthInRangeAttrs"
|
|
84
133
|
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
85
134
|
:label="formatDate(month, 'M', props.locale)"
|
|
86
135
|
@click="onClickMonth(month)"
|
|
@@ -88,7 +137,7 @@
|
|
|
88
137
|
/>
|
|
89
138
|
|
|
90
139
|
<UButton
|
|
91
|
-
v-else-if="getMonthState(month).isActiveMonth"
|
|
140
|
+
v-else-if="getMonthState(month, idx).isActiveMonth"
|
|
92
141
|
variant="thirdary"
|
|
93
142
|
color="brand"
|
|
94
143
|
no-ring
|
|
@@ -191,6 +240,9 @@ const {
|
|
|
191
240
|
monthInRangeAttrs,
|
|
192
241
|
selectedMonthAttrs,
|
|
193
242
|
activeMonthAttrs,
|
|
243
|
+
currentLastMonthInRangeAttrs,
|
|
244
|
+
currentFirstMonthInRangeAttrs,
|
|
245
|
+
singleCurrentMonthInRangeAttrs,
|
|
194
246
|
} = useAttrs(props);
|
|
195
247
|
|
|
196
248
|
const localSelectedDate = computed(() => {
|
|
@@ -220,42 +272,43 @@ function getMonth(monthNumber) {
|
|
|
220
272
|
return newDate;
|
|
221
273
|
}
|
|
222
274
|
|
|
223
|
-
function getMonthState(month) {
|
|
224
|
-
const
|
|
275
|
+
function getMonthState(month, index) {
|
|
276
|
+
const startRangeIndex = months.value.findIndex((month) => {
|
|
277
|
+
return isSameMonth(month, localSelectedDate.value);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const endRangeIndex = months.value.findIndex((month) => {
|
|
281
|
+
return isSameMonth(month, props.selectedDateTo);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const isMonthInRange = index >= startRangeIndex && index <= endRangeIndex;
|
|
285
|
+
const isSelectedMonth =
|
|
286
|
+
isSameMonth(month, localSelectedDate.value) && props.selectedDate !== null;
|
|
287
|
+
const isPresentMonth = isCurrentMonth(month);
|
|
288
|
+
const isMoreThanOneMonthRange =
|
|
225
289
|
props.range &&
|
|
226
|
-
localSelectedDate.value &&
|
|
227
290
|
props.selectedDateTo &&
|
|
228
|
-
|
|
229
|
-
month,
|
|
230
|
-
props.selectedDate,
|
|
231
|
-
props.selectedDateTo,
|
|
232
|
-
props.locale,
|
|
233
|
-
props.dateFormat,
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
const isNotSelectedDate =
|
|
237
|
-
(!isSelectedMonth(month) && !isSelectedMonth(month)) || props.selectedDate === null;
|
|
238
|
-
|
|
239
|
-
const isMoreThenOneMonthRange =
|
|
240
|
-
props.selectedDateTo && isMoreThanOneMonthDiff(props.selectedDate, props.selectedDateTo);
|
|
241
|
-
|
|
242
|
-
const isCurrentMonthAndNotSelected = isCurrentMonth(month) && isNotSelectedDate;
|
|
243
|
-
const isCurrentMonthInRange =
|
|
244
|
-
isMonthInRange && isCurrentMonthAndNotSelected && props.selectedDateTo;
|
|
245
|
-
const isLastMonthInRange = props.range && isSelectedToMonth(month) && isMoreThenOneMonthRange;
|
|
246
|
-
const isFirstMonthInRange = props.range && isSelectedMonth(month) && isMoreThenOneMonthRange;
|
|
247
|
-
const isSingleMonthInRange = props.range && isSelectedMonth(month) && !isMoreThenOneMonthRange;
|
|
291
|
+
isMoreThanOneMonthDiff(props.selectedDate, props.selectedDateTo);
|
|
248
292
|
const isActiveMonth = isSameMonth(props.activeMonth, month) && !props.range;
|
|
293
|
+
const isCurrentMonthInRange = isMonthInRange && isPresentMonth;
|
|
294
|
+
const isLastMonthInRange =
|
|
295
|
+
props.range && isSameMonth(month, props.selectedDateTo) && isMoreThanOneMonthRange;
|
|
296
|
+
const isFirstMonthInRange =
|
|
297
|
+
props.range && isSameMonth(month, localSelectedDate.value) && isMoreThanOneMonthRange;
|
|
298
|
+
const isCurrentFirstMonthInRange = props.range && isFirstMonthInRange && isPresentMonth;
|
|
299
|
+
const isCurrentLastMonthInRange = props.range && isLastMonthInRange && isPresentMonth;
|
|
249
300
|
|
|
250
301
|
return {
|
|
251
|
-
|
|
302
|
+
isSelectedMonth,
|
|
303
|
+
isCurrentMonth: isPresentMonth,
|
|
304
|
+
isMoreThanOneMonthRange,
|
|
305
|
+
isActiveMonth,
|
|
252
306
|
isCurrentMonthInRange,
|
|
253
307
|
isLastMonthInRange,
|
|
254
308
|
isFirstMonthInRange,
|
|
255
|
-
|
|
309
|
+
isCurrentFirstMonthInRange,
|
|
310
|
+
isCurrentLastMonthInRange,
|
|
256
311
|
isMonthInRange,
|
|
257
|
-
isSelectedMonth: isSelectedMonth(month),
|
|
258
|
-
isActiveMonth,
|
|
259
312
|
};
|
|
260
313
|
}
|
|
261
314
|
|
|
@@ -267,14 +320,6 @@ function isMoreThanOneMonthDiff(date, dateTo) {
|
|
|
267
320
|
return yearDiff > 0 || monthDiff > 1 || (monthDiff === 1 && dayDiff > 0);
|
|
268
321
|
}
|
|
269
322
|
|
|
270
|
-
function isSelectedMonth(month) {
|
|
271
|
-
return isSameMonth(month, localSelectedDate.value);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function isSelectedToMonth(month) {
|
|
275
|
-
return isSameMonth(month, props.selectedDateTo);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
323
|
function onClickMonth(month) {
|
|
279
324
|
emit("input", month);
|
|
280
325
|
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="yearViewAttrs">
|
|
3
|
-
<template v-for="year in years" :key="year">
|
|
3
|
+
<template v-for="(year, idx) in years" :key="year">
|
|
4
4
|
<UButton
|
|
5
|
-
v-if="getYearState(year).
|
|
5
|
+
v-if="getYearState(year, idx).isSelectedYear && !props.range"
|
|
6
|
+
variant="primary"
|
|
7
|
+
color="brand"
|
|
8
|
+
no-ring
|
|
9
|
+
v-bind="selectedYearAttrs"
|
|
10
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
11
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
12
|
+
@click="onClickYear(year)"
|
|
13
|
+
@mousedown.prevent.capture
|
|
14
|
+
/>
|
|
15
|
+
|
|
16
|
+
<UButton
|
|
17
|
+
v-else-if="getYearState(year, idx).isCurrentYear && !getYearState(year, idx).isYearInRange"
|
|
6
18
|
variant="thirdary"
|
|
7
19
|
color="brand"
|
|
8
20
|
no-ring
|
|
@@ -14,11 +26,12 @@
|
|
|
14
26
|
/>
|
|
15
27
|
|
|
16
28
|
<UButton
|
|
17
|
-
v-else-if="getYearState(year).
|
|
29
|
+
v-else-if="getYearState(year, idx).isCurrentFirstYearInRange"
|
|
18
30
|
variant="thirdary"
|
|
19
31
|
color="brand"
|
|
20
32
|
no-ring
|
|
21
|
-
|
|
33
|
+
filled
|
|
34
|
+
v-bind="currentFirstYearInRangeAttrs"
|
|
22
35
|
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
23
36
|
:label="formatDate(year, 'Y', props.locale)"
|
|
24
37
|
@click="onClickYear(year)"
|
|
@@ -26,7 +39,20 @@
|
|
|
26
39
|
/>
|
|
27
40
|
|
|
28
41
|
<UButton
|
|
29
|
-
v-else-if="getYearState(year).
|
|
42
|
+
v-else-if="getYearState(year, idx).isCurrentLastYearInRange"
|
|
43
|
+
variant="thirdary"
|
|
44
|
+
color="brand"
|
|
45
|
+
no-ring
|
|
46
|
+
filled
|
|
47
|
+
v-bind="currentLastYearInRangeAttrs"
|
|
48
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
49
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
50
|
+
@click="onClickYear(year)"
|
|
51
|
+
@mousedown.prevent.capture
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<UButton
|
|
55
|
+
v-else-if="getYearState(year, idx).isFirstYearInRange"
|
|
30
56
|
variant="thirdary"
|
|
31
57
|
color="brand"
|
|
32
58
|
no-ring
|
|
@@ -39,7 +65,7 @@
|
|
|
39
65
|
/>
|
|
40
66
|
|
|
41
67
|
<UButton
|
|
42
|
-
v-else-if="getYearState(year).isLastYearInRange"
|
|
68
|
+
v-else-if="getYearState(year, idx).isLastYearInRange"
|
|
43
69
|
variant="thirdary"
|
|
44
70
|
color="brand"
|
|
45
71
|
no-ring
|
|
@@ -52,11 +78,14 @@
|
|
|
52
78
|
/>
|
|
53
79
|
|
|
54
80
|
<UButton
|
|
55
|
-
v-else-if="
|
|
81
|
+
v-else-if="
|
|
82
|
+
getYearState(year, idx).isCurrentYearInRange &&
|
|
83
|
+
!getYearState(year, idx).isMoreThanOneYearRange
|
|
84
|
+
"
|
|
56
85
|
variant="thirdary"
|
|
57
86
|
color="brand"
|
|
58
87
|
no-ring
|
|
59
|
-
v-bind="
|
|
88
|
+
v-bind="singleCurrentYearInRangeAttrs"
|
|
60
89
|
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
61
90
|
:label="formatDate(year, 'Y', props.locale)"
|
|
62
91
|
@click="onClickYear(year)"
|
|
@@ -64,11 +93,25 @@
|
|
|
64
93
|
/>
|
|
65
94
|
|
|
66
95
|
<UButton
|
|
67
|
-
v-else-if="getYearState(year).
|
|
96
|
+
v-else-if="getYearState(year, idx).isCurrentYearInRange"
|
|
68
97
|
variant="thirdary"
|
|
69
98
|
color="brand"
|
|
70
99
|
no-ring
|
|
71
|
-
v-bind="
|
|
100
|
+
v-bind="currentYearInRangeAttrs"
|
|
101
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
102
|
+
:label="formatDate(year, 'Y', props.locale) + 'sd'"
|
|
103
|
+
@click="onClickYear(year)"
|
|
104
|
+
@mousedown.prevent.capture
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<UButton
|
|
108
|
+
v-else-if="
|
|
109
|
+
!getYearState(year, idx).isMoreThanOneYearRange && getYearState(year, idx).isYearInRange
|
|
110
|
+
"
|
|
111
|
+
variant="thirdary"
|
|
112
|
+
color="brand"
|
|
113
|
+
no-ring
|
|
114
|
+
v-bind="singleYearInRangeAttrs"
|
|
72
115
|
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
73
116
|
:label="formatDate(year, 'Y', props.locale)"
|
|
74
117
|
@click="onClickYear(year)"
|
|
@@ -76,11 +119,13 @@
|
|
|
76
119
|
/>
|
|
77
120
|
|
|
78
121
|
<UButton
|
|
79
|
-
v-else-if="
|
|
80
|
-
|
|
122
|
+
v-else-if="
|
|
123
|
+
getYearState(year, idx).isMoreThanOneYearRange && getYearState(year, idx).isYearInRange
|
|
124
|
+
"
|
|
125
|
+
variant="thirdary"
|
|
81
126
|
color="brand"
|
|
82
127
|
no-ring
|
|
83
|
-
v-bind="
|
|
128
|
+
v-bind="yearInRangeAttrs"
|
|
84
129
|
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
85
130
|
:label="formatDate(year, 'Y', props.locale)"
|
|
86
131
|
@click="onClickYear(year)"
|
|
@@ -88,7 +133,7 @@
|
|
|
88
133
|
/>
|
|
89
134
|
|
|
90
135
|
<UButton
|
|
91
|
-
v-else-if="getYearState(year).isActiveYear"
|
|
136
|
+
v-else-if="getYearState(year, idx).isActiveYear"
|
|
92
137
|
variant="thirdary"
|
|
93
138
|
color="brand"
|
|
94
139
|
no-ring
|
|
@@ -191,6 +236,9 @@ const {
|
|
|
191
236
|
singleYearInRangeAttrs,
|
|
192
237
|
selectedYearAttrs,
|
|
193
238
|
activeYearAttrs,
|
|
239
|
+
singleCurrentYearInRangeAttrs,
|
|
240
|
+
currentLastYearInRangeAttrs,
|
|
241
|
+
currentFirstYearInRangeAttrs,
|
|
194
242
|
} = useAttrs(props);
|
|
195
243
|
|
|
196
244
|
const localSelectedDate = computed(() => {
|
|
@@ -224,53 +272,50 @@ function getYear(year) {
|
|
|
224
272
|
return newDate;
|
|
225
273
|
}
|
|
226
274
|
|
|
227
|
-
function getYearState(year) {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
props.selectedDateTo,
|
|
236
|
-
props.locale,
|
|
237
|
-
props.dateFormat,
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
const isNotSelectedDate =
|
|
241
|
-
(!isSelectedMonth(year) && !isSelectedMonth(year)) || props.selectedDate === null;
|
|
275
|
+
function getYearState(year, index) {
|
|
276
|
+
const startRangeIndex = years.value.findIndex((year) => {
|
|
277
|
+
return year.getFullYear() === localSelectedDate.value?.getFullYear();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const endRangeIndex = years.value.findIndex((year) => {
|
|
281
|
+
return year.getFullYear() === props.selectedDateTo?.getFullYear();
|
|
282
|
+
});
|
|
242
283
|
|
|
284
|
+
const isYearInRange = index >= startRangeIndex && index <= endRangeIndex;
|
|
285
|
+
const isSelectedYear = isSameMonth(year, localSelectedDate.value) && props.selectedDate !== null;
|
|
286
|
+
const isPresentYear = isCurrentYear(year);
|
|
243
287
|
const isMoreThanOneYearRange =
|
|
244
|
-
props.selectedDateTo
|
|
245
|
-
props.selectedDateTo.getFullYear() - props.selectedDate.getFullYear() > 1;
|
|
246
|
-
|
|
247
|
-
const isFirstYear = year.getFullYear() === props.selectedDate.getFullYear();
|
|
248
|
-
const isLastYear =
|
|
249
|
-
props.selectedDateTo && year.getFullYear() === props.selectedDateTo.getFullYear();
|
|
250
|
-
|
|
251
|
-
const isCurrentDate = isCurrentYear(year) && isNotSelectedDate;
|
|
252
|
-
const isCurrentYearInRange = isCurrentDate && isYearInRange;
|
|
253
|
-
const isFirstYearInRange = props.range && isFirstYear && isMoreThanOneYearRange;
|
|
254
|
-
const isLastYearInRange = props.range && isLastYear && isMoreThanOneYearRange;
|
|
255
|
-
const isSingleYearInRange = props.range && isFirstYear && !isMoreThanOneYearRange;
|
|
288
|
+
props.selectedDateTo?.getFullYear() - props.selectedDate?.getFullYear() >= 1;
|
|
256
289
|
const isActiveYear = isSameMonth(props.activeMonth, year) && !props.range;
|
|
290
|
+
const isCurrentYearInRange = isYearInRange && isPresentYear;
|
|
291
|
+
|
|
292
|
+
const isLastYearInRange =
|
|
293
|
+
props.range &&
|
|
294
|
+
year.getFullYear() === props.selectedDateTo?.getFullYear() &&
|
|
295
|
+
isMoreThanOneYearRange;
|
|
296
|
+
|
|
297
|
+
const isFirstYearInRange =
|
|
298
|
+
props.range &&
|
|
299
|
+
year.getFullYear() === localSelectedDate.value?.getFullYear() &&
|
|
300
|
+
isMoreThanOneYearRange;
|
|
301
|
+
|
|
302
|
+
const isCurrentFirstYearInRange = props.range && isFirstYearInRange && isPresentYear;
|
|
303
|
+
const isCurrentLastYearInRange = props.range && isLastYearInRange && isPresentYear;
|
|
257
304
|
|
|
258
305
|
return {
|
|
259
|
-
|
|
306
|
+
isSelectedYear,
|
|
307
|
+
isCurrentYear: isPresentYear,
|
|
308
|
+
isMoreThanOneYearRange,
|
|
309
|
+
isActiveYear,
|
|
260
310
|
isCurrentYearInRange,
|
|
261
|
-
isFirstYearInRange,
|
|
262
311
|
isLastYearInRange,
|
|
312
|
+
isFirstYearInRange,
|
|
313
|
+
isCurrentFirstYearInRange,
|
|
314
|
+
isCurrentLastYearInRange,
|
|
263
315
|
isYearInRange,
|
|
264
|
-
isSingleYearInRange,
|
|
265
|
-
isSelectedYear: isSelectedMonth(year),
|
|
266
|
-
isActiveYear,
|
|
267
316
|
};
|
|
268
317
|
}
|
|
269
318
|
|
|
270
|
-
function isSelectedMonth(month) {
|
|
271
|
-
return isSameMonth(month, localSelectedDate.value);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
319
|
function onClickYear(year) {
|
|
275
320
|
emit("input", year);
|
|
276
321
|
}
|
|
@@ -31,6 +31,8 @@ export default /*tw*/ {
|
|
|
31
31
|
firstDayInRange: "",
|
|
32
32
|
anotherMonthFirstDayInRange: "",
|
|
33
33
|
lastDayInRange: "",
|
|
34
|
+
currentLastDayInRange: "",
|
|
35
|
+
currentFirstDayInRange: "",
|
|
34
36
|
anotherMonthLastDayInRange: "",
|
|
35
37
|
selectedDay: "",
|
|
36
38
|
activeDay: "",
|
|
@@ -38,9 +40,12 @@ export default /*tw*/ {
|
|
|
38
40
|
month: "{UButton} mx-auto flex h-12 w-full",
|
|
39
41
|
currentMonth: "",
|
|
40
42
|
currentMonthInRange: "",
|
|
43
|
+
currentLastMonthInRange: "",
|
|
44
|
+
currentFirstMonthInRange: "",
|
|
41
45
|
lastMonthInRange: "",
|
|
42
46
|
firstMonthInRange: "",
|
|
43
47
|
singleMonthInRange: "rounded-dynamic",
|
|
48
|
+
singleCurrentMonthInRange: "rounded-dynamic",
|
|
44
49
|
monthInRange: "",
|
|
45
50
|
selectedMonth: "",
|
|
46
51
|
activeMonth: "",
|
|
@@ -52,6 +57,9 @@ export default /*tw*/ {
|
|
|
52
57
|
lastYearInRange: "",
|
|
53
58
|
yearInRange: "",
|
|
54
59
|
singleYearInRange: "rounded-dynamic",
|
|
60
|
+
singleCurrentYearInRange: "rounded-dynamic",
|
|
61
|
+
currentLastYearInRange: "",
|
|
62
|
+
currentFirstYearInRange: "",
|
|
55
63
|
selectedYear: "",
|
|
56
64
|
activeYear: "",
|
|
57
65
|
timepicker: "mt-2 pl-1 pt-3 text-sm flex items-center justify-between gap-2 border-t border-brand-200",
|
|
@@ -67,6 +67,22 @@ export default function useAttrs(props) {
|
|
|
67
67
|
extendingKeysClasses.currentDate.value,
|
|
68
68
|
]),
|
|
69
69
|
},
|
|
70
|
+
currentFirstDayInRange: {
|
|
71
|
+
base: computed(() => [
|
|
72
|
+
extendingKeysClasses.day.value,
|
|
73
|
+
extendingKeysClasses.edgeDateInRange.value,
|
|
74
|
+
extendingKeysClasses.firstDateInRange.value,
|
|
75
|
+
extendingKeysClasses.currentDate.value,
|
|
76
|
+
]),
|
|
77
|
+
},
|
|
78
|
+
currentLastDayInRange: {
|
|
79
|
+
base: computed(() => [
|
|
80
|
+
extendingKeysClasses.day.value,
|
|
81
|
+
extendingKeysClasses.edgeDateInRange.value,
|
|
82
|
+
extendingKeysClasses.lastDateInRange.value,
|
|
83
|
+
extendingKeysClasses.currentDate.value,
|
|
84
|
+
]),
|
|
85
|
+
},
|
|
70
86
|
firstDayInRange: {
|
|
71
87
|
base: computed(() => [
|
|
72
88
|
extendingKeysClasses.day.value,
|
|
@@ -115,6 +131,29 @@ export default function useAttrs(props) {
|
|
|
115
131
|
extendingKeysClasses.dateInRange.value,
|
|
116
132
|
]),
|
|
117
133
|
},
|
|
134
|
+
singleCurrentMonthInRange: {
|
|
135
|
+
base: computed(() => [
|
|
136
|
+
extendingKeysClasses.year.value,
|
|
137
|
+
extendingKeysClasses.dateInRange.value,
|
|
138
|
+
extendingKeysClasses.currentDate.value,
|
|
139
|
+
]),
|
|
140
|
+
},
|
|
141
|
+
currentFirstYearInRange: {
|
|
142
|
+
base: computed(() => [
|
|
143
|
+
extendingKeysClasses.year.value,
|
|
144
|
+
extendingKeysClasses.edgeDateInRange.value,
|
|
145
|
+
extendingKeysClasses.firstDateInRange.value,
|
|
146
|
+
extendingKeysClasses.currentDate.value,
|
|
147
|
+
]),
|
|
148
|
+
},
|
|
149
|
+
currentLastYearInRange: {
|
|
150
|
+
base: computed(() => [
|
|
151
|
+
extendingKeysClasses.year.value,
|
|
152
|
+
extendingKeysClasses.edgeDateInRange.value,
|
|
153
|
+
extendingKeysClasses.lastDateInRange.value,
|
|
154
|
+
extendingKeysClasses.currentDate.value,
|
|
155
|
+
]),
|
|
156
|
+
},
|
|
118
157
|
currentMonthInRange: {
|
|
119
158
|
base: computed(() => [
|
|
120
159
|
extendingKeysClasses.month.value,
|
|
@@ -129,6 +168,22 @@ export default function useAttrs(props) {
|
|
|
129
168
|
extendingKeysClasses.lastDateInRange.value,
|
|
130
169
|
]),
|
|
131
170
|
},
|
|
171
|
+
currentFirstMonthInRange: {
|
|
172
|
+
base: computed(() => [
|
|
173
|
+
extendingKeysClasses.month.value,
|
|
174
|
+
extendingKeysClasses.edgeDateInRange.value,
|
|
175
|
+
extendingKeysClasses.firstDateInRange.value,
|
|
176
|
+
extendingKeysClasses.currentDate.value,
|
|
177
|
+
]),
|
|
178
|
+
},
|
|
179
|
+
currentLastMonthInRange: {
|
|
180
|
+
base: computed(() => [
|
|
181
|
+
extendingKeysClasses.month.value,
|
|
182
|
+
extendingKeysClasses.edgeDateInRange.value,
|
|
183
|
+
extendingKeysClasses.lastDateInRange.value,
|
|
184
|
+
extendingKeysClasses.currentDate.value,
|
|
185
|
+
]),
|
|
186
|
+
},
|
|
132
187
|
firstMonthInRange: {
|
|
133
188
|
base: computed(() => [
|
|
134
189
|
extendingKeysClasses.month.value,
|
|
@@ -160,6 +215,13 @@ export default function useAttrs(props) {
|
|
|
160
215
|
extendingKeysClasses.dateInRange.value,
|
|
161
216
|
]),
|
|
162
217
|
},
|
|
218
|
+
singleCurrentYearInRange: {
|
|
219
|
+
base: computed(() => [
|
|
220
|
+
extendingKeysClasses.year.value,
|
|
221
|
+
extendingKeysClasses.dateInRange.value,
|
|
222
|
+
extendingKeysClasses.currentDate.value,
|
|
223
|
+
]),
|
|
224
|
+
},
|
|
163
225
|
singleYearInRange: {
|
|
164
226
|
base: computed(() => [
|
|
165
227
|
extendingKeysClasses.year.value,
|
|
@@ -19,11 +19,12 @@ export default /*tw*/ {
|
|
|
19
19
|
`,
|
|
20
20
|
variants: {
|
|
21
21
|
openDirectionX: {
|
|
22
|
-
left: "right-
|
|
23
|
-
right: "left-
|
|
22
|
+
left: "left-0 right-auto",
|
|
23
|
+
right: "right-0 left-auto",
|
|
24
24
|
},
|
|
25
25
|
openDirectionY: {
|
|
26
26
|
top: "bottom-full mt-0",
|
|
27
|
+
bottom: "top-full mb-0",
|
|
27
28
|
},
|
|
28
29
|
},
|
|
29
30
|
compoundVariants: [
|