vueless 0.0.383 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.383",
3
+ "version": "0.0.385",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -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).isCurrentDay && !getDayState(day).isCurrentDayInRange"
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).isCurrentDayInRange"
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
- v-bind="currentDayInRangeAttrs"
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).isFirstDayInRange"
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="firstDayInRangeAttrs"
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).isAnotherMonthFirstDayInRange"
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="anotherMonthFirstDayInRangeAttrs"
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).isAnotherMonthLastDayInRange"
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="anotherMonthLastDayInRangeAttrs"
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).isSelectedDay"
112
+ v-else-if="getDayState(day).isAnotherMonthLastDayInRange"
98
113
  tabindex="-1"
99
- variant="primary"
114
+ variant="thirdary"
100
115
  color="brand"
101
116
  no-ring
102
117
  square
103
- v-bind="selectedDayAttrs"
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).isActiveDay"
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="activeDayAttrs"
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 isNotSelectedDate =
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;
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 isAnotherMonthLastDayInRange = isLastDayInRange && isLastDayInRange;
390
- const isSelectedDay = isSameDay(day, localSelectedDate.value);
391
- const isActiveDay = isSameDay(props.activeDate, day);
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).isCurrentMonth && !getMonthState(month).isCurrentMonthInRange"
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).isCurrentMonthAndNotSelected"
18
- variant="primary"
31
+ v-else-if="getMonthState(month, idx).isCurrentFirstMonthInRange"
32
+ variant="thirdary"
19
33
  color="brand"
20
34
  no-ring
21
- v-bind="currentMonthInRangeAttrs"
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="getMonthState(month).isSingleMonthInRange"
56
- variant="thirdary"
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="singleMonthInRangeAttrs"
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="getMonthState(month).isMonthInRange"
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="monthInRangeAttrs"
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="getMonthState(month).isSelectedMonth"
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="selectedMonthAttrs"
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 isMonthInRange =
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
- !dateIsOutOfRange(
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
- isCurrentMonthAndNotSelected,
302
+ isSelectedMonth,
303
+ isCurrentMonth: isPresentMonth,
304
+ isMoreThanOneMonthRange,
305
+ isActiveMonth,
252
306
  isCurrentMonthInRange,
253
307
  isLastMonthInRange,
254
308
  isFirstMonthInRange,
255
- isSingleMonthInRange,
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).isCurrentYear && !getYearState(year).isCurrentYearInRange"
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).isCurrentYearInRange"
29
+ v-else-if="getYearState(year, idx).isCurrentFirstYearInRange"
18
30
  variant="thirdary"
19
31
  color="brand"
20
32
  no-ring
21
- v-bind="currentYearInRangeAttrs"
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).isFirstYearInRange"
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="getYearState(year).isSingleYearInRange"
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="singleYearInRangeAttrs"
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).isYearInRange"
96
+ v-else-if="getYearState(year, idx).isCurrentYearInRange"
68
97
  variant="thirdary"
69
98
  color="brand"
70
99
  no-ring
71
- v-bind="yearInRangeAttrs"
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="getYearState(year).isSelectedYear"
80
- variant="primary"
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="selectedYearAttrs"
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 isYearInRange =
229
- props.range &&
230
- localSelectedDate.value &&
231
- props.selectedDateTo &&
232
- !dateIsOutOfRange(
233
- year,
234
- props.selectedDate,
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
- isCurrentYear: isCurrentDate,
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
  }