vueless 0.0.352 → 0.0.354
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/preset.tailwind.js +12 -12
- package/ui.form-calendar/UCalendarDayView.vue +202 -63
- package/ui.form-calendar/UCalendarMonthView.vue +143 -44
- package/ui.form-calendar/UCalendarYearView.vue +143 -45
- package/ui.form-calendar/config.js +37 -20
- package/ui.form-calendar/useAttrs.js +328 -7
- package/ui.form-calendar/utilDate.js +1 -1
- package/utils/utilUI.js +1 -1
- package/web-types.json +1 -1
package/package.json
CHANGED
package/preset.tailwind.js
CHANGED
|
@@ -56,7 +56,6 @@ const grayColors = getPalette(GRAY_COLOR);
|
|
|
56
56
|
export const vuelessTailwindConfig = {
|
|
57
57
|
darkMode: DARK_MODE_SELECTOR,
|
|
58
58
|
content: [...vuelessContent, ...vuelessContentVue, ...vuelessContentNuxt],
|
|
59
|
-
safelist,
|
|
60
59
|
theme: {
|
|
61
60
|
extend: {
|
|
62
61
|
colors: {
|
|
@@ -94,9 +93,21 @@ export function vuelessPreset() {
|
|
|
94
93
|
return {
|
|
95
94
|
...vuelessTailwindConfig,
|
|
96
95
|
plugins: [forms],
|
|
96
|
+
safelist,
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Convert sting patterns to RegExp.
|
|
102
|
+
* @returns {Array} - TailwindCSS safelist.
|
|
103
|
+
*/
|
|
104
|
+
export function getSafelist() {
|
|
105
|
+
return JSON.parse(process.env.VUELESS_SAFELIST || "[]").map((rule) => ({
|
|
106
|
+
...rule,
|
|
107
|
+
pattern: new RegExp(rule.pattern),
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
|
|
100
111
|
/**
|
|
101
112
|
* Transform CSS variable with RGB numbers into CSS color.
|
|
102
113
|
* @param { String } variableName
|
|
@@ -122,14 +133,3 @@ function getPalette(color) {
|
|
|
122
133
|
|
|
123
134
|
return palette;
|
|
124
135
|
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Convert sting patterns to RegExp.
|
|
128
|
-
* @returns {Array} - TailwindCSS safelist.
|
|
129
|
-
*/
|
|
130
|
-
function getSafelist() {
|
|
131
|
-
return JSON.parse(process.env.VUELESS_SAFELIST || "[]").map((rule) => ({
|
|
132
|
-
...rule,
|
|
133
|
-
pattern: new RegExp(rule.pattern),
|
|
134
|
-
}));
|
|
135
|
-
}
|
|
@@ -4,16 +4,165 @@
|
|
|
4
4
|
<span v-for="weekDay in weekdays" :key="weekDay" v-bind="weekDayAttrs" v-text="weekDay" />
|
|
5
5
|
</div>
|
|
6
6
|
<div v-bind="daysAttrs">
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
<template v-for="day in days" :key="day">
|
|
8
|
+
<UButton
|
|
9
|
+
v-if="getDayState(day).isCurrentDay && !getDayState(day).isCurrentDayInRange"
|
|
10
|
+
tabindex="-1"
|
|
11
|
+
variant="thirdary"
|
|
12
|
+
color="brand"
|
|
13
|
+
no-ring
|
|
14
|
+
square
|
|
15
|
+
v-bind="currentDayAttrs"
|
|
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).isCurrentDayInRange"
|
|
24
|
+
tabindex="-1"
|
|
25
|
+
variant="thirdary"
|
|
26
|
+
color="brand"
|
|
27
|
+
no-ring
|
|
28
|
+
square
|
|
29
|
+
v-bind="currentDayInRangeAttrs"
|
|
30
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
31
|
+
:label="formatDate(day, 'j', locale)"
|
|
32
|
+
@mousedown.prevent.capture
|
|
33
|
+
@click="onClickDay(day)"
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
<UButton
|
|
37
|
+
v-else-if="getDayState(day).isFirstDayInRange"
|
|
38
|
+
tabindex="-1"
|
|
39
|
+
variant="thirdary"
|
|
40
|
+
color="brand"
|
|
41
|
+
no-ring
|
|
42
|
+
square
|
|
43
|
+
filled
|
|
44
|
+
v-bind="firstDayInRangeAttrs"
|
|
45
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
46
|
+
:label="formatDate(day, 'j', locale)"
|
|
47
|
+
@mousedown.prevent.capture
|
|
48
|
+
@click="onClickDay(day)"
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
<UButton
|
|
52
|
+
v-else-if="getDayState(day).isAnotherMonthFirstDayInRange"
|
|
53
|
+
tabindex="-1"
|
|
54
|
+
variant="thirdary"
|
|
55
|
+
color="brand"
|
|
56
|
+
no-ring
|
|
57
|
+
square
|
|
58
|
+
filled
|
|
59
|
+
v-bind="anotherMonthFirstDayInRangeAttrs"
|
|
60
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
61
|
+
:label="formatDate(day, 'j', locale)"
|
|
62
|
+
@mousedown.prevent.capture
|
|
63
|
+
@click="onClickDay(day)"
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<UButton
|
|
67
|
+
v-else-if="getDayState(day).isLastDayInRange"
|
|
68
|
+
tabindex="-1"
|
|
69
|
+
variant="thirdary"
|
|
70
|
+
color="brand"
|
|
71
|
+
no-ring
|
|
72
|
+
square
|
|
73
|
+
filled
|
|
74
|
+
v-bind="lastDayInRangeAttrs"
|
|
75
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
76
|
+
:label="formatDate(day, 'j', locale)"
|
|
77
|
+
@mousedown.prevent.capture
|
|
78
|
+
@click="onClickDay(day)"
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<UButton
|
|
82
|
+
v-else-if="getDayState(day).isAnotherMonthLastDayInRange"
|
|
83
|
+
tabindex="-1"
|
|
84
|
+
variant="thirdary"
|
|
85
|
+
color="brand"
|
|
86
|
+
no-ring
|
|
87
|
+
square
|
|
88
|
+
filled
|
|
89
|
+
v-bind="anotherMonthLastDayInRangeAttrs"
|
|
90
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
91
|
+
:label="formatDate(day, 'j', locale)"
|
|
92
|
+
@mousedown.prevent.capture
|
|
93
|
+
@click="onClickDay(day)"
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<UButton
|
|
97
|
+
v-else-if="getDayState(day).isSelectedDay"
|
|
98
|
+
tabindex="-1"
|
|
99
|
+
variant="primary"
|
|
100
|
+
color="brand"
|
|
101
|
+
no-ring
|
|
102
|
+
square
|
|
103
|
+
v-bind="selectedDayAttrs"
|
|
104
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
105
|
+
:label="formatDate(day, 'j', locale)"
|
|
106
|
+
@mousedown.prevent.capture
|
|
107
|
+
@click="onClickDay(day)"
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
<UButton
|
|
111
|
+
v-else-if="getDayState(day).isActiveDay"
|
|
112
|
+
tabindex="-1"
|
|
113
|
+
variant="thirdary"
|
|
114
|
+
color="brand"
|
|
115
|
+
no-ring
|
|
116
|
+
square
|
|
117
|
+
v-bind="activeDayAttrs"
|
|
118
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
119
|
+
:label="formatDate(day, 'j', locale)"
|
|
120
|
+
@mousedown.prevent.capture
|
|
121
|
+
@click="onClickDay(day)"
|
|
122
|
+
/>
|
|
123
|
+
|
|
124
|
+
<UButton
|
|
125
|
+
v-else-if="getDayState(day).isDayInRange"
|
|
126
|
+
tabindex="-1"
|
|
127
|
+
variant="thirdary"
|
|
128
|
+
color="brand"
|
|
129
|
+
no-ring
|
|
130
|
+
square
|
|
131
|
+
v-bind="dayInRangeAttrs"
|
|
132
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
133
|
+
:label="formatDate(day, 'j', locale)"
|
|
134
|
+
@mousedown.prevent.capture
|
|
135
|
+
@click="onClickDay(day)"
|
|
136
|
+
/>
|
|
137
|
+
|
|
138
|
+
<UButton
|
|
139
|
+
v-else-if="getDayState(day).isAnotherMonthDay"
|
|
140
|
+
tabindex="-1"
|
|
141
|
+
variant="thirdary"
|
|
142
|
+
color="brand"
|
|
143
|
+
no-ring
|
|
144
|
+
square
|
|
145
|
+
v-bind="anotherMonthDayAttrs"
|
|
146
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
147
|
+
:label="formatDate(day, 'j', locale)"
|
|
148
|
+
@mousedown.prevent.capture
|
|
149
|
+
@click="onClickDay(day)"
|
|
150
|
+
/>
|
|
151
|
+
|
|
152
|
+
<UButton
|
|
153
|
+
v-else
|
|
154
|
+
tabindex="-1"
|
|
155
|
+
variant="thirdary"
|
|
156
|
+
color="brand"
|
|
157
|
+
no-ring
|
|
158
|
+
square
|
|
159
|
+
v-bind="dayAttrs"
|
|
160
|
+
:disabled="dateIsOutOfRange(day, minDate, maxDate, locale, dateFormat)"
|
|
161
|
+
:label="formatDate(day, 'j', locale)"
|
|
162
|
+
@mousedown.prevent.capture
|
|
163
|
+
@click="onClickDay(day)"
|
|
164
|
+
/>
|
|
165
|
+
</template>
|
|
17
166
|
</div>
|
|
18
167
|
</div>
|
|
19
168
|
</template>
|
|
@@ -21,7 +170,6 @@
|
|
|
21
170
|
<script setup>
|
|
22
171
|
import { computed } from "vue";
|
|
23
172
|
|
|
24
|
-
import { cx } from "../utils/utilUI.js";
|
|
25
173
|
import { formatDate, dateIsOutOfRange } from "./utilCalendar.js";
|
|
26
174
|
import {
|
|
27
175
|
isToday,
|
|
@@ -35,6 +183,8 @@ import useAttrs from "./useAttrs.js";
|
|
|
35
183
|
|
|
36
184
|
import { DAYS_IN_WEEK, START_WEEK } from "./constants.js";
|
|
37
185
|
|
|
186
|
+
import UButton from "../ui.button/UButton.vue";
|
|
187
|
+
|
|
38
188
|
const props = defineProps({
|
|
39
189
|
selectedDate: {
|
|
40
190
|
type: [Date, null],
|
|
@@ -94,11 +244,17 @@ const {
|
|
|
94
244
|
weekDaysAttrs,
|
|
95
245
|
weekDayAttrs,
|
|
96
246
|
daysAttrs,
|
|
97
|
-
|
|
98
|
-
selectedDayAttrs,
|
|
247
|
+
dayAttrs,
|
|
99
248
|
currentDayAttrs,
|
|
249
|
+
dayInRangeAttrs,
|
|
250
|
+
currentDayInRangeAttrs,
|
|
100
251
|
anotherMonthDayAttrs,
|
|
101
|
-
|
|
252
|
+
firstDayInRangeAttrs,
|
|
253
|
+
anotherMonthFirstDayInRangeAttrs,
|
|
254
|
+
lastDayInRangeAttrs,
|
|
255
|
+
anotherMonthLastDayInRangeAttrs,
|
|
256
|
+
selectedDayAttrs,
|
|
257
|
+
activeDayAttrs,
|
|
102
258
|
} = useAttrs(props);
|
|
103
259
|
|
|
104
260
|
const localSelectedDate = computed(() => {
|
|
@@ -207,7 +363,7 @@ function getDay(date, dayNumber) {
|
|
|
207
363
|
return day;
|
|
208
364
|
}
|
|
209
365
|
|
|
210
|
-
function
|
|
366
|
+
function getDayState(day) {
|
|
211
367
|
const isDayInRange =
|
|
212
368
|
props.range &&
|
|
213
369
|
localSelectedDate.value &&
|
|
@@ -221,59 +377,42 @@ function getDayClasses(day) {
|
|
|
221
377
|
);
|
|
222
378
|
|
|
223
379
|
const isNotSelectedDate =
|
|
224
|
-
(!
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (isSelectedDay(day)) {
|
|
251
|
-
return selectedDayAttrs.value.class;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (isSameDay(props.activeDate, day)) {
|
|
255
|
-
return activeDayAttrs.value.class;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (isAnotherMothDay(day, activeMonthDate.value)) {
|
|
259
|
-
return anotherMonthDayAttrs.value.class;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function isSelectedDay(day) {
|
|
264
|
-
return isSameDay(day, localSelectedDate.value);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function isSelectedToDay(day) {
|
|
268
|
-
return isSameDay(day, props.selectedDateTo);
|
|
380
|
+
(!isSameDay(day, localSelectedDate.value) && !isSameDay(day, props.selectedDateTo)) ||
|
|
381
|
+
props.selectedDate === null;
|
|
382
|
+
|
|
383
|
+
const isCurrentDay = isToday(day) && isNotSelectedDate;
|
|
384
|
+
const isCurrentDayInRange = isCurrentDay && isDayInRange;
|
|
385
|
+
const isAnotherMonthDay = isAnotherMothDay(day, activeMonthDate.value);
|
|
386
|
+
const isFirstDayInRange = props.range && isSameDay(day, localSelectedDate.value);
|
|
387
|
+
const isAnotherMonthFirstDayInRange = isFirstDayInRange && isAnotherMonthDay;
|
|
388
|
+
const isLastDayInRange = props.range && isSameDay(day, props.selectedDateTo);
|
|
389
|
+
const isAnotherMonthLastDayInRange = isLastDayInRange && isLastDayInRange;
|
|
390
|
+
const isSelectedDay = isSameDay(day, localSelectedDate.value);
|
|
391
|
+
const isActiveDay = isSameDay(props.activeDate, day);
|
|
392
|
+
|
|
393
|
+
return {
|
|
394
|
+
isCurrentDay,
|
|
395
|
+
isCurrentDayInRange,
|
|
396
|
+
isFirstDayInRange,
|
|
397
|
+
isAnotherMonthFirstDayInRange,
|
|
398
|
+
isLastDayInRange,
|
|
399
|
+
isAnotherMonthLastDayInRange,
|
|
400
|
+
isDayInRange,
|
|
401
|
+
isSelectedDay,
|
|
402
|
+
isActiveDay,
|
|
403
|
+
isAnotherMonthDay,
|
|
404
|
+
};
|
|
269
405
|
}
|
|
270
406
|
|
|
271
407
|
function onClickDay(day) {
|
|
272
|
-
const
|
|
408
|
+
const isSameDate = isSameDay(day, localSelectedDate.value) && props.selectedDate !== null;
|
|
273
409
|
const isSameDayInRange =
|
|
274
|
-
|
|
410
|
+
isSameDay(day, localSelectedDate.value) &&
|
|
411
|
+
props.selectedDate !== null &&
|
|
412
|
+
props.selectedDateTo &&
|
|
413
|
+
props.range;
|
|
275
414
|
|
|
276
|
-
if (
|
|
415
|
+
if (isSameDate || isSameDayInRange) {
|
|
277
416
|
emit("input", null);
|
|
278
417
|
|
|
279
418
|
return;
|
|
@@ -1,17 +1,116 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="monthViewAttrs">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
<template v-for="month in months" :key="month">
|
|
4
|
+
<UButton
|
|
5
|
+
v-if="getMonthState(month).isCurrentMonth && !getMonthState(month).isCurrentMonthInRange"
|
|
6
|
+
variant="thirdary"
|
|
7
|
+
color="brand"
|
|
8
|
+
no-ring
|
|
9
|
+
v-bind="currentMonthAttrs"
|
|
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="getMonthState(month).isCurrentMonthAndNotSelected"
|
|
18
|
+
variant="primary"
|
|
19
|
+
color="brand"
|
|
20
|
+
no-ring
|
|
21
|
+
v-bind="currentMonthInRangeAttrs"
|
|
22
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
23
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
24
|
+
@click="onClickMonth(month)"
|
|
25
|
+
@mousedown.prevent.capture
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<UButton
|
|
29
|
+
v-else-if="getMonthState(month).isFirstMonthInRange"
|
|
30
|
+
variant="thirdary"
|
|
31
|
+
color="brand"
|
|
32
|
+
no-ring
|
|
33
|
+
filled
|
|
34
|
+
v-bind="firstMonthInRangeAttrs"
|
|
35
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
36
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
37
|
+
@click="onClickMonth(month)"
|
|
38
|
+
@mousedown.prevent.capture
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<UButton
|
|
42
|
+
v-else-if="getMonthState(month).isLastMonthInRange"
|
|
43
|
+
variant="thirdary"
|
|
44
|
+
color="brand"
|
|
45
|
+
no-ring
|
|
46
|
+
filled
|
|
47
|
+
v-bind="lastMonthInRangeAttrs"
|
|
48
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
49
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
50
|
+
@click="onClickMonth(month)"
|
|
51
|
+
@mousedown.prevent.capture
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<UButton
|
|
55
|
+
v-else-if="getMonthState(month).isSingleMonthInRange"
|
|
56
|
+
variant="thirdary"
|
|
57
|
+
color="brand"
|
|
58
|
+
no-ring
|
|
59
|
+
v-bind="singleMonthInRangeAttrs"
|
|
60
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
61
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
62
|
+
@click="onClickMonth(month)"
|
|
63
|
+
@mousedown.prevent.capture
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<UButton
|
|
67
|
+
v-else-if="getMonthState(month).isMonthInRange"
|
|
68
|
+
variant="thirdary"
|
|
69
|
+
color="brand"
|
|
70
|
+
no-ring
|
|
71
|
+
v-bind="monthInRangeAttrs"
|
|
72
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
73
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
74
|
+
@click="onClickMonth(month)"
|
|
75
|
+
@mousedown.prevent.capture
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<UButton
|
|
79
|
+
v-else-if="getMonthState(month).isSelectedMonth"
|
|
80
|
+
variant="thirdary"
|
|
81
|
+
color="brand"
|
|
82
|
+
no-ring
|
|
83
|
+
v-bind="selectedMonthAttrs"
|
|
84
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
85
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
86
|
+
@click="onClickMonth(month)"
|
|
87
|
+
@mousedown.prevent.capture
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<UButton
|
|
91
|
+
v-else-if="getMonthState(month).isActiveMonth"
|
|
92
|
+
variant="thirdary"
|
|
93
|
+
color="brand"
|
|
94
|
+
no-ring
|
|
95
|
+
v-bind="activeMonthAttrs"
|
|
96
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
97
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
98
|
+
@click="onClickMonth(month)"
|
|
99
|
+
@mousedown.prevent.capture
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<UButton
|
|
103
|
+
v-else
|
|
104
|
+
variant="thirdary"
|
|
105
|
+
color="brand"
|
|
106
|
+
no-ring
|
|
107
|
+
v-bind="monthAttrs"
|
|
108
|
+
:disabled="dateIsOutOfRange(month, minDate, maxDate, locale, dateFormat)"
|
|
109
|
+
:label="formatDate(month, 'M', props.locale)"
|
|
110
|
+
@click="onClickMonth(month)"
|
|
111
|
+
@mousedown.prevent.capture
|
|
112
|
+
/>
|
|
113
|
+
</template>
|
|
15
114
|
</div>
|
|
16
115
|
</template>
|
|
17
116
|
|
|
@@ -19,8 +118,7 @@
|
|
|
19
118
|
import { computed } from "vue";
|
|
20
119
|
|
|
21
120
|
import { formatDate, dateIsOutOfRange } from "./utilCalendar.js";
|
|
22
|
-
import { isSameMonth, getDateWithoutTime,
|
|
23
|
-
import { cx } from "../utils/utilUI.js";
|
|
121
|
+
import { isSameMonth, getDateWithoutTime, isCurrentMonth } from "./utilDate.js";
|
|
24
122
|
|
|
25
123
|
import useAttrs from "./useAttrs.js";
|
|
26
124
|
|
|
@@ -82,8 +180,18 @@ const props = defineProps({
|
|
|
82
180
|
|
|
83
181
|
const emit = defineEmits(["input"]);
|
|
84
182
|
|
|
85
|
-
const {
|
|
86
|
-
|
|
183
|
+
const {
|
|
184
|
+
monthViewAttrs,
|
|
185
|
+
monthAttrs,
|
|
186
|
+
currentMonthAttrs,
|
|
187
|
+
currentMonthInRangeAttrs,
|
|
188
|
+
lastMonthInRangeAttrs,
|
|
189
|
+
firstMonthInRangeAttrs,
|
|
190
|
+
singleMonthInRangeAttrs,
|
|
191
|
+
monthInRangeAttrs,
|
|
192
|
+
selectedMonthAttrs,
|
|
193
|
+
activeMonthAttrs,
|
|
194
|
+
} = useAttrs(props);
|
|
87
195
|
|
|
88
196
|
const localSelectedDate = computed(() => {
|
|
89
197
|
return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
|
|
@@ -112,7 +220,7 @@ function getMonth(monthNumber) {
|
|
|
112
220
|
return newDate;
|
|
113
221
|
}
|
|
114
222
|
|
|
115
|
-
function
|
|
223
|
+
function getMonthState(month) {
|
|
116
224
|
const isMonthInRange =
|
|
117
225
|
props.range &&
|
|
118
226
|
localSelectedDate.value &&
|
|
@@ -131,33 +239,24 @@ function getMonthClasses(month) {
|
|
|
131
239
|
const isMoreThenOneMonthRange =
|
|
132
240
|
props.selectedDateTo && isMoreThanOneMonthDiff(props.selectedDate, props.selectedDateTo);
|
|
133
241
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (isSelectedMonth(month)) {
|
|
155
|
-
return selectedMonthAttrs.value.class;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (isSameMonth(props.activeMonth, month) && !props.range) {
|
|
159
|
-
return activeMonthAttrs.value.class;
|
|
160
|
-
}
|
|
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;
|
|
248
|
+
const isActiveMonth = isSameMonth(props.activeMonth, month) && !props.range;
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
isCurrentMonthAndNotSelected,
|
|
252
|
+
isCurrentMonthInRange,
|
|
253
|
+
isLastMonthInRange,
|
|
254
|
+
isFirstMonthInRange,
|
|
255
|
+
isSingleMonthInRange,
|
|
256
|
+
isMonthInRange,
|
|
257
|
+
isSelectedMonth: isSelectedMonth(month),
|
|
258
|
+
isActiveMonth,
|
|
259
|
+
};
|
|
161
260
|
}
|
|
162
261
|
|
|
163
262
|
function isMoreThanOneMonthDiff(date, dateTo) {
|
|
@@ -1,17 +1,116 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="yearViewAttrs">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
<template v-for="year in years" :key="year">
|
|
4
|
+
<UButton
|
|
5
|
+
v-if="getYearState(year).isCurrentYear && !getYearState(year).isCurrentYearInRange"
|
|
6
|
+
variant="thirdary"
|
|
7
|
+
color="brand"
|
|
8
|
+
no-ring
|
|
9
|
+
v-bind="currentYearAttrs"
|
|
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).isCurrentYearInRange"
|
|
18
|
+
variant="thirdary"
|
|
19
|
+
color="brand"
|
|
20
|
+
no-ring
|
|
21
|
+
v-bind="currentYearInRangeAttrs"
|
|
22
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
23
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
24
|
+
@click="onClickYear(year)"
|
|
25
|
+
@mousedown.prevent.capture
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<UButton
|
|
29
|
+
v-else-if="getYearState(year).isFirstYearInRange"
|
|
30
|
+
variant="thirdary"
|
|
31
|
+
color="brand"
|
|
32
|
+
no-ring
|
|
33
|
+
filled
|
|
34
|
+
v-bind="firstYearInRangeAttrs"
|
|
35
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
36
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
37
|
+
@click="onClickYear(year)"
|
|
38
|
+
@mousedown.prevent.capture
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<UButton
|
|
42
|
+
v-else-if="getYearState(year).isLastYearInRange"
|
|
43
|
+
variant="thirdary"
|
|
44
|
+
color="brand"
|
|
45
|
+
no-ring
|
|
46
|
+
filled
|
|
47
|
+
v-bind="lastYearInRangeAttrs"
|
|
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).isSingleYearInRange"
|
|
56
|
+
variant="thirdary"
|
|
57
|
+
color="brand"
|
|
58
|
+
no-ring
|
|
59
|
+
v-bind="singleYearInRangeAttrs"
|
|
60
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
61
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
62
|
+
@click="onClickYear(year)"
|
|
63
|
+
@mousedown.prevent.capture
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<UButton
|
|
67
|
+
v-else-if="getYearState(year).isYearInRange"
|
|
68
|
+
variant="thirdary"
|
|
69
|
+
color="brand"
|
|
70
|
+
no-ring
|
|
71
|
+
v-bind="yearInRangeAttrs"
|
|
72
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
73
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
74
|
+
@click="onClickYear(year)"
|
|
75
|
+
@mousedown.prevent.capture
|
|
76
|
+
/>
|
|
77
|
+
|
|
78
|
+
<UButton
|
|
79
|
+
v-else-if="getYearState(year).isSelectedYear"
|
|
80
|
+
variant="primary"
|
|
81
|
+
color="brand"
|
|
82
|
+
no-ring
|
|
83
|
+
v-bind="selectedYearAttrs"
|
|
84
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
85
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
86
|
+
@click="onClickYear(year)"
|
|
87
|
+
@mousedown.prevent.capture
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
<UButton
|
|
91
|
+
v-else-if="getYearState(year).isActiveYear"
|
|
92
|
+
variant="thirdary"
|
|
93
|
+
color="brand"
|
|
94
|
+
no-ring
|
|
95
|
+
v-bind="activeYearAttrs"
|
|
96
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
97
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
98
|
+
@click="onClickYear(year)"
|
|
99
|
+
@mousedown.prevent.capture
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<UButton
|
|
103
|
+
v-else
|
|
104
|
+
variant="thirdary"
|
|
105
|
+
color="brand"
|
|
106
|
+
no-ring
|
|
107
|
+
v-bind="yearAttrs"
|
|
108
|
+
:disabled="dateIsOutOfRange(year, minDate, maxDate, locale, dateFormat)"
|
|
109
|
+
:label="formatDate(year, 'Y', props.locale)"
|
|
110
|
+
@click="onClickYear(year)"
|
|
111
|
+
@mousedown.prevent.capture
|
|
112
|
+
/>
|
|
113
|
+
</template>
|
|
15
114
|
</div>
|
|
16
115
|
</template>
|
|
17
116
|
|
|
@@ -20,7 +119,6 @@ import { computed } from "vue";
|
|
|
20
119
|
|
|
21
120
|
import { formatDate, getYearsRange, dateIsOutOfRange } from "./utilCalendar.js";
|
|
22
121
|
import { isSameMonth, getDateWithoutTime, isCurrentYear } from "./utilDate.js";
|
|
23
|
-
import { cx } from "../utils/utilUI.js";
|
|
24
122
|
|
|
25
123
|
import useAttrs from "./useAttrs.js";
|
|
26
124
|
|
|
@@ -82,8 +180,18 @@ const props = defineProps({
|
|
|
82
180
|
|
|
83
181
|
const emit = defineEmits(["input"]);
|
|
84
182
|
|
|
85
|
-
const {
|
|
86
|
-
|
|
183
|
+
const {
|
|
184
|
+
yearViewAttrs,
|
|
185
|
+
yearAttrs,
|
|
186
|
+
currentYearAttrs,
|
|
187
|
+
currentYearInRangeAttrs,
|
|
188
|
+
firstYearInRangeAttrs,
|
|
189
|
+
lastYearInRangeAttrs,
|
|
190
|
+
yearInRangeAttrs,
|
|
191
|
+
singleYearInRangeAttrs,
|
|
192
|
+
selectedYearAttrs,
|
|
193
|
+
activeYearAttrs,
|
|
194
|
+
} = useAttrs(props);
|
|
87
195
|
|
|
88
196
|
const localSelectedDate = computed(() => {
|
|
89
197
|
return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
|
|
@@ -116,7 +224,7 @@ function getYear(year) {
|
|
|
116
224
|
return newDate;
|
|
117
225
|
}
|
|
118
226
|
|
|
119
|
-
function
|
|
227
|
+
function getYearState(year) {
|
|
120
228
|
const isYearInRange =
|
|
121
229
|
props.range &&
|
|
122
230
|
localSelectedDate.value &&
|
|
@@ -140,40 +248,30 @@ function getYearClasses(year) {
|
|
|
140
248
|
const isLastYear =
|
|
141
249
|
props.selectedDateTo && year.getFullYear() === props.selectedDateTo.getFullYear();
|
|
142
250
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return props.config.inRangeDate;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (isSelectedMonth(year)) {
|
|
164
|
-
return selectedYearAttrs.value.class;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (isSameMonth(props.activeMonth, year) && !props.range) {
|
|
168
|
-
return activeYearAttrs.value.class;
|
|
169
|
-
}
|
|
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;
|
|
256
|
+
const isActiveYear = isSameMonth(props.activeMonth, year) && !props.range;
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
isCurrentYear: isCurrentDate,
|
|
260
|
+
isCurrentYearInRange,
|
|
261
|
+
isFirstYearInRange,
|
|
262
|
+
isLastYearInRange,
|
|
263
|
+
isYearInRange,
|
|
264
|
+
isSingleYearInRange,
|
|
265
|
+
isSelectedYear: isSelectedMonth(year),
|
|
266
|
+
isActiveYear,
|
|
267
|
+
};
|
|
170
268
|
}
|
|
171
269
|
|
|
172
270
|
function isSelectedMonth(month) {
|
|
173
271
|
return isSameMonth(month, localSelectedDate.value);
|
|
174
272
|
}
|
|
175
273
|
|
|
176
|
-
function
|
|
177
|
-
emit("input",
|
|
274
|
+
function onClickYear(year) {
|
|
275
|
+
emit("input", year);
|
|
178
276
|
}
|
|
179
277
|
</script>
|
|
@@ -15,28 +15,45 @@ export default /*tw*/ {
|
|
|
15
15
|
weekDays: "grid grid-cols-7",
|
|
16
16
|
weekDay: "flex size-8 items-center justify-center text-xs uppercase text-gray-500",
|
|
17
17
|
days: "grid grid-cols-7",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
dateInRange: "bg-brand-100 text-brand-900 hover:!bg-brand-200 rounded-none",
|
|
19
|
+
edgeDateInRange: "",
|
|
20
|
+
firstDateInRange: "rounded-r-none",
|
|
21
|
+
lastDateInRange: "rounded-l-none",
|
|
22
|
+
anotherMonthDate: "text-gray-400",
|
|
23
|
+
activeDate: "bg-brand-100",
|
|
24
|
+
selectedDate: "",
|
|
25
|
+
currentDate: "border-2 border-brand-600",
|
|
26
|
+
day: `{UButton} size-9 w-auto`,
|
|
27
|
+
currentDay: "",
|
|
28
|
+
dayInRange: "",
|
|
29
|
+
currentDayInRange: "",
|
|
30
|
+
anotherMonthDay: "",
|
|
31
|
+
firstDayInRange: "",
|
|
32
|
+
anotherMonthFirstDayInRange: "",
|
|
33
|
+
lastDayInRange: "",
|
|
34
|
+
anotherMonthLastDayInRange: "",
|
|
35
|
+
selectedDay: "",
|
|
36
|
+
activeDay: "",
|
|
30
37
|
monthView: "grid grid-cols-4 items-center justify-center",
|
|
31
|
-
month: "{UButton} mx-auto flex h-12 w-full
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
month: "{UButton} mx-auto flex h-12 w-full",
|
|
39
|
+
currentMonth: "",
|
|
40
|
+
currentMonthInRange: "",
|
|
41
|
+
lastMonthInRange: "",
|
|
42
|
+
firstMonthInRange: "",
|
|
43
|
+
singleMonthInRange: "rounded-dynamic",
|
|
44
|
+
monthInRange: "",
|
|
45
|
+
selectedMonth: "",
|
|
46
|
+
activeMonth: "",
|
|
35
47
|
yearView: "grid grid-cols-4 items-center justify-center",
|
|
36
|
-
year: "{UButton} mx-auto flex h-12 w-full
|
|
37
|
-
currentYear: "
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
year: "{UButton} mx-auto flex h-12 w-full",
|
|
49
|
+
currentYear: "",
|
|
50
|
+
currentYearInRange: "",
|
|
51
|
+
firstYearInRange: "",
|
|
52
|
+
lastYearInRange: "",
|
|
53
|
+
yearInRange: "",
|
|
54
|
+
singleYearInRange: "rounded-dynamic",
|
|
55
|
+
selectedYear: "",
|
|
56
|
+
activeYear: "",
|
|
40
57
|
timepicker: "mt-2 pl-1 pt-3 text-sm flex items-center justify-between gap-2 border-t border-brand-200",
|
|
41
58
|
timepickerLabel: "w-full",
|
|
42
59
|
timepickerInputWrapper: "flex items-center gap-px rounded-dynamic border border-brand-300",
|
|
@@ -12,8 +12,51 @@ export default function useAttrs(props) {
|
|
|
12
12
|
);
|
|
13
13
|
const attrs = {};
|
|
14
14
|
|
|
15
|
+
const buttonVariantKeys = [
|
|
16
|
+
"firstDateInRange",
|
|
17
|
+
"lastDateInRange",
|
|
18
|
+
"anotherMonthDate",
|
|
19
|
+
"activeDate",
|
|
20
|
+
"selectedDate",
|
|
21
|
+
"currentDate",
|
|
22
|
+
"currentDay",
|
|
23
|
+
"currentDayInRange",
|
|
24
|
+
"anotherMonthDay",
|
|
25
|
+
"firstDayInRange",
|
|
26
|
+
"anotherMonthFirstDayInRange",
|
|
27
|
+
"lastDayInRange",
|
|
28
|
+
"anotherMonthLastDayInRange",
|
|
29
|
+
"selectedDay",
|
|
30
|
+
"activeDay",
|
|
31
|
+
"dayInRange",
|
|
32
|
+
"edgeDateInRange",
|
|
33
|
+
"dateInRange",
|
|
34
|
+
"currentMonth",
|
|
35
|
+
"currentMonthInRange",
|
|
36
|
+
"lastMonthInRange",
|
|
37
|
+
"firstMonthInRange",
|
|
38
|
+
"singleMonthInRange",
|
|
39
|
+
"monthInRange",
|
|
40
|
+
"selectedMonth",
|
|
41
|
+
"activeMonth",
|
|
42
|
+
"currentYear",
|
|
43
|
+
"currentYearInRange",
|
|
44
|
+
"firstYearInRange",
|
|
45
|
+
"lastYearInRange",
|
|
46
|
+
"yearInRange",
|
|
47
|
+
"singleYearInRange",
|
|
48
|
+
"selectedYear",
|
|
49
|
+
"activeYear",
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const timepickerInputKeys = [
|
|
53
|
+
"timepickerInputHours",
|
|
54
|
+
"timepickerInputMinutes",
|
|
55
|
+
"timepickerInputSeconds",
|
|
56
|
+
];
|
|
57
|
+
|
|
15
58
|
for (const key in defaultConfig) {
|
|
16
|
-
if (isSystemKey(key)) continue;
|
|
59
|
+
if (isSystemKey(key) || buttonVariantKeys.includes(key)) continue;
|
|
17
60
|
|
|
18
61
|
const classes = computed(() => {
|
|
19
62
|
let value = config.value[key];
|
|
@@ -29,8 +72,7 @@ export default function useAttrs(props) {
|
|
|
29
72
|
|
|
30
73
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
31
74
|
|
|
32
|
-
|
|
33
|
-
if (["timepickerInputHours", "timepickerInputMinutes", "timepickerInputSeconds"].includes(key)) {
|
|
75
|
+
if (timepickerInputKeys.includes(key)) {
|
|
34
76
|
const keyAttrs = attrs[`${key}Attrs`];
|
|
35
77
|
|
|
36
78
|
attrs[`${key}Attrs`] = computed(() => ({
|
|
@@ -38,11 +80,290 @@ export default function useAttrs(props) {
|
|
|
38
80
|
class: cx([config.value.timepickerInput, keyAttrs.value.class]),
|
|
39
81
|
}));
|
|
40
82
|
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const key of buttonVariantKeys) {
|
|
86
|
+
if (key === "dayInRange") {
|
|
87
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
88
|
+
...attrs.dayAttrs.value,
|
|
89
|
+
class: cx([attrs.dayAttrs.value.class, config.value.dateInRange, config.value.dayInRange]),
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (key === "selectedDay") {
|
|
94
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
95
|
+
...attrs.dayAttrs.value,
|
|
96
|
+
class: cx([
|
|
97
|
+
attrs.dayAttrs.value.class,
|
|
98
|
+
config.value.selectedDate,
|
|
99
|
+
config.value.selectedDay,
|
|
100
|
+
]),
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (key === "activeDay") {
|
|
105
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
106
|
+
...attrs.dayAttrs.value,
|
|
107
|
+
class: cx([attrs.dayAttrs.value.class, config.value.activeDate, config.value.activeDay]),
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (key === "anotherMonthDay") {
|
|
112
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
113
|
+
...attrs.dayAttrs.value,
|
|
114
|
+
class: cx([
|
|
115
|
+
attrs.dayAttrs.value.class,
|
|
116
|
+
config.value.anotherMonthDate,
|
|
117
|
+
config.value.anotherMonthDay,
|
|
118
|
+
]),
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (key === "currentDay") {
|
|
123
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
124
|
+
...attrs.dayAttrs.value,
|
|
125
|
+
class: cx([attrs.dayAttrs.value.class, config.value.currentDate, config.value.currentDay]),
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (key === "currentDayInRange") {
|
|
130
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
131
|
+
...attrs.dayAttrs.value,
|
|
132
|
+
class: cx([
|
|
133
|
+
attrs.dayAttrs.value.class,
|
|
134
|
+
config.value.dateInRange,
|
|
135
|
+
config.value.currentDate,
|
|
136
|
+
config.value.currentDayInRange,
|
|
137
|
+
]),
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
41
140
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
141
|
+
if (key === "firstDayInRange") {
|
|
142
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
143
|
+
...attrs.dayAttrs.value,
|
|
144
|
+
class: cx([
|
|
145
|
+
attrs.dayAttrs.value.class,
|
|
146
|
+
config.value.edgeDateInRange,
|
|
147
|
+
config.value.firstDateInRange,
|
|
148
|
+
config.value.firstDayInRange,
|
|
149
|
+
]),
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (key === "lastDayInRange") {
|
|
154
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
155
|
+
...attrs.dayAttrs.value,
|
|
156
|
+
class: cx([
|
|
157
|
+
attrs.dayAttrs.value.class,
|
|
158
|
+
config.value.edgeDateInRange,
|
|
159
|
+
config.value.lastDateInRange,
|
|
160
|
+
config.value.lastDayInRange,
|
|
161
|
+
]),
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (key === "anotherMonthLastDayInRange") {
|
|
166
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
167
|
+
...attrs.dayAttrs.value,
|
|
168
|
+
class: cx([
|
|
169
|
+
attrs.dayAttrs.value.class,
|
|
170
|
+
config.value.anotherMonthDay,
|
|
171
|
+
config.value.edgeDateInRange,
|
|
172
|
+
config.value.lastDateInRange,
|
|
173
|
+
config.value.anotherMonthLastDayInRange,
|
|
174
|
+
]),
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (key === "anotherMonthFirstDayInRange") {
|
|
179
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
180
|
+
...attrs.dayAttrs.value,
|
|
181
|
+
class: cx([
|
|
182
|
+
attrs.dayAttrs.value.class,
|
|
183
|
+
config.value.anotherMonthDay,
|
|
184
|
+
config.value.edgeDateInRange,
|
|
185
|
+
config.value.firstDateInRange,
|
|
186
|
+
config.value.anotherMonthFirstDayInRange,
|
|
187
|
+
]),
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (key === "currentMonth") {
|
|
192
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
193
|
+
...attrs.monthAttrs.value,
|
|
194
|
+
class: cx([
|
|
195
|
+
attrs.monthAttrs.value.class,
|
|
196
|
+
config.value.currentDate,
|
|
197
|
+
config.value.currentMonth,
|
|
198
|
+
]),
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (key === "monthInRange") {
|
|
203
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
204
|
+
...attrs.monthAttrs.value,
|
|
205
|
+
class: cx([
|
|
206
|
+
attrs.monthAttrs.value.class,
|
|
207
|
+
config.value.dateInRange,
|
|
208
|
+
config.value.monthInRange,
|
|
209
|
+
]),
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (key === "singleMonthInRange") {
|
|
214
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
215
|
+
...attrs.monthAttrs.value,
|
|
216
|
+
class: cx([
|
|
217
|
+
attrs.monthAttrs.value.class,
|
|
218
|
+
config.value.dateInRange,
|
|
219
|
+
config.value.singleMonthInRange,
|
|
220
|
+
]),
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (key === "currentMonthInRange") {
|
|
225
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
226
|
+
...attrs.monthAttrs.value,
|
|
227
|
+
class: cx([
|
|
228
|
+
attrs.monthAttrs.value.class,
|
|
229
|
+
config.value.currentDate,
|
|
230
|
+
config.value.dateInRange,
|
|
231
|
+
config.value.currentMonthInRange,
|
|
232
|
+
]),
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (key === "lastMonthInRange") {
|
|
237
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
238
|
+
...attrs.monthAttrs.value,
|
|
239
|
+
class: cx([
|
|
240
|
+
attrs.monthAttrs.value.class,
|
|
241
|
+
config.value.edgeDateInRange,
|
|
242
|
+
config.value.lastDateInRange,
|
|
243
|
+
config.value.lastMonthInRange,
|
|
244
|
+
]),
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (key === "firstMonthInRange") {
|
|
249
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
250
|
+
...attrs.monthAttrs.value,
|
|
251
|
+
class: cx([
|
|
252
|
+
attrs.monthAttrs.value.class,
|
|
253
|
+
config.value.edgeDateInRange,
|
|
254
|
+
config.value.firstDateInRange,
|
|
255
|
+
config.value.firstMonthInRange,
|
|
256
|
+
]),
|
|
257
|
+
}));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (key === "selectedMonth") {
|
|
261
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
262
|
+
...attrs.monthAttrs.value,
|
|
263
|
+
class: cx([
|
|
264
|
+
attrs.monthAttrs.value.class,
|
|
265
|
+
config.value.selectedDate,
|
|
266
|
+
config.value.selectedMonth,
|
|
267
|
+
]),
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (key === "activeMonth") {
|
|
272
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
273
|
+
...attrs.monthAttrs.value,
|
|
274
|
+
class: cx([
|
|
275
|
+
attrs.monthAttrs.value.class,
|
|
276
|
+
config.value.activeDate,
|
|
277
|
+
config.value.activeMonth,
|
|
278
|
+
]),
|
|
279
|
+
}));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (key === "currentYear") {
|
|
283
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
284
|
+
...attrs.yearAttrs.value,
|
|
285
|
+
class: cx([
|
|
286
|
+
attrs.yearAttrs.value.class,
|
|
287
|
+
config.value.currentDate,
|
|
288
|
+
config.value.currentYear,
|
|
289
|
+
]),
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (key === "yearInRange") {
|
|
294
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
295
|
+
...attrs.yearAttrs.value,
|
|
296
|
+
class: cx([
|
|
297
|
+
attrs.yearAttrs.value.class,
|
|
298
|
+
config.value.dateInRange,
|
|
299
|
+
config.value.yearInRange,
|
|
300
|
+
]),
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (key === "singleYearInRange") {
|
|
305
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
306
|
+
...attrs.yearAttrs.value,
|
|
307
|
+
class: cx([
|
|
308
|
+
attrs.yearAttrs.value.class,
|
|
309
|
+
config.value.dateInRange,
|
|
310
|
+
config.value.singleYearInRange,
|
|
311
|
+
]),
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (key === "currentYearInRange") {
|
|
316
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
317
|
+
...attrs.yearAttrs.value,
|
|
318
|
+
class: cx([
|
|
319
|
+
attrs.yearAttrs.value.class,
|
|
320
|
+
config.value.currentDate,
|
|
321
|
+
config.value.dateInRange,
|
|
322
|
+
config.value.currentYearInRange,
|
|
323
|
+
]),
|
|
324
|
+
}));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (key === "lastYearInRange") {
|
|
328
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
329
|
+
...attrs.yearAttrs.value,
|
|
330
|
+
class: cx([
|
|
331
|
+
attrs.yearAttrs.value.class,
|
|
332
|
+
config.value.edgeDateInRange,
|
|
333
|
+
config.value.lastDateInRange,
|
|
334
|
+
config.value.lastYearInRange,
|
|
335
|
+
]),
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (key === "firstYearInRange") {
|
|
340
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
341
|
+
...attrs.yearAttrs.value,
|
|
342
|
+
class: cx([
|
|
343
|
+
attrs.yearAttrs.value.class,
|
|
344
|
+
config.value.edgeDateInRange,
|
|
345
|
+
config.value.firstDateInRange,
|
|
346
|
+
config.value.firstYearInRange,
|
|
347
|
+
]),
|
|
348
|
+
}));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (key === "selectedYear") {
|
|
352
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
353
|
+
...attrs.yearAttrs.value,
|
|
354
|
+
class: cx([
|
|
355
|
+
attrs.yearAttrs.value.class,
|
|
356
|
+
config.value.selectedDate,
|
|
357
|
+
config.value.selectedYear,
|
|
358
|
+
]),
|
|
359
|
+
}));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (key === "activeYear") {
|
|
363
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
364
|
+
...attrs.yearAttrs.value,
|
|
365
|
+
class: cx([attrs.yearAttrs.value.class, config.value.activeDate, config.value.activeYear]),
|
|
366
|
+
}));
|
|
46
367
|
}
|
|
47
368
|
}
|
|
48
369
|
|
package/utils/utilUI.js
CHANGED