vueless 0.0.216 → 0.0.217
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
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<script setup>
|
|
18
18
|
import { computed } from "vue";
|
|
19
19
|
import { formatDate, dateIsOutOfRange } from "../services/calendar.service";
|
|
20
|
-
import { isSameMonth, getDateWithoutTime } from "../services/date.service";
|
|
20
|
+
import { isSameMonth, getDateWithoutTime, isCurrentMoth } from "../services/date.service";
|
|
21
21
|
|
|
22
22
|
import useAttrs from "../composables/attrs.composable";
|
|
23
23
|
|
|
@@ -69,7 +69,8 @@ const props = defineProps({
|
|
|
69
69
|
|
|
70
70
|
const emit = defineEmits(["input"]);
|
|
71
71
|
|
|
72
|
-
const { monthViewAttrs, selectedMonthAttrs, activeMonthAttrs, monthAttrs } =
|
|
72
|
+
const { monthViewAttrs, selectedMonthAttrs, activeMonthAttrs, monthAttrs, currentMothAttrs } =
|
|
73
|
+
useAttrs(props);
|
|
73
74
|
|
|
74
75
|
const localSelectedDate = computed(() => {
|
|
75
76
|
return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
|
|
@@ -98,12 +99,19 @@ function getMonth(monthNumber) {
|
|
|
98
99
|
return newDate;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
function getMonthClasses(
|
|
102
|
-
|
|
102
|
+
function getMonthClasses(month) {
|
|
103
|
+
const isNotSelectedDate =
|
|
104
|
+
(!isSelectedMonth(month) && !isSelectedMonth(month)) || props.selectedDate === null;
|
|
105
|
+
|
|
106
|
+
if (isCurrentMoth(month) && isNotSelectedDate) {
|
|
107
|
+
return [currentMothAttrs.value.class];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (isSelectedMonth(month)) {
|
|
103
111
|
return [selectedMonthAttrs.value.class];
|
|
104
112
|
}
|
|
105
113
|
|
|
106
|
-
if (isSameMonth(props.activeMonth,
|
|
114
|
+
if (isSameMonth(props.activeMonth, month)) {
|
|
107
115
|
return [activeMonthAttrs.value.class];
|
|
108
116
|
}
|
|
109
117
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<script setup>
|
|
18
18
|
import { computed } from "vue";
|
|
19
19
|
import { formatDate, getYearsRange, dateIsOutOfRange } from "../services/calendar.service";
|
|
20
|
-
import { isSameMonth, getDateWithoutTime } from "../services/date.service";
|
|
20
|
+
import { isSameMonth, getDateWithoutTime, isCurrentYear } from "../services/date.service";
|
|
21
21
|
|
|
22
22
|
import useAttrs from "../composables/attrs.composable";
|
|
23
23
|
|
|
@@ -69,7 +69,8 @@ const props = defineProps({
|
|
|
69
69
|
|
|
70
70
|
const emit = defineEmits(["input"]);
|
|
71
71
|
|
|
72
|
-
const { yearViewAttrs, selectedYearAttrs, activeYearAttrs, yearAttrs } =
|
|
72
|
+
const { yearViewAttrs, selectedYearAttrs, activeYearAttrs, yearAttrs, currentYearAttrs } =
|
|
73
|
+
useAttrs(props);
|
|
73
74
|
|
|
74
75
|
const localSelectedDate = computed(() => {
|
|
75
76
|
return props.selectedDate === null ? getDateWithoutTime() : props.selectedDate;
|
|
@@ -102,12 +103,19 @@ function getYear(year) {
|
|
|
102
103
|
return newDate;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
function getYearClasses(
|
|
106
|
-
|
|
106
|
+
function getYearClasses(year) {
|
|
107
|
+
const isNotSelectedDate =
|
|
108
|
+
(!isSelectedMonth(year) && !isSelectedMonth(year)) || props.selectedDate === null;
|
|
109
|
+
|
|
110
|
+
if (isCurrentYear(year) && isNotSelectedDate) {
|
|
111
|
+
return [currentYearAttrs.value.class];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (isSelectedMonth(year)) {
|
|
107
115
|
return [selectedYearAttrs.value.class];
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
if (isSameMonth(props.activeMonth,
|
|
118
|
+
if (isSameMonth(props.activeMonth, year)) {
|
|
111
119
|
return [activeYearAttrs.value.class];
|
|
112
120
|
}
|
|
113
121
|
}
|
|
@@ -35,8 +35,10 @@ export default /*tw*/ {
|
|
|
35
35
|
month: "{UButton} mx-auto flex h-12 w-full rounded-lg hover:!bg-brand-900 hover:text-white",
|
|
36
36
|
selectedMonth: "bg-brand-900 hover:bg-brand-900 text-white",
|
|
37
37
|
activeMonth: "bg-brand-100",
|
|
38
|
+
currentMoth: "border-2 border-brand-900",
|
|
38
39
|
yearView: "grid grid-cols-4 items-center justify-center",
|
|
39
40
|
year: "{UButton} mx-auto flex h-12 w-full rounded-lg hover:!bg-brand-900 hover:text-white",
|
|
41
|
+
currentYear: "border-2 border-brand-900",
|
|
40
42
|
selectedYear: "bg-brand-900 hover:bg-brand-900 text-white",
|
|
41
43
|
activeYear: "bg-brand-100",
|
|
42
44
|
timepicker: "mt-2 pl-1 pt-3 text-sm flex items-center justify-between gap-2 border-t border-brand-200",
|
|
@@ -255,6 +255,14 @@ export function isToday(date) {
|
|
|
255
255
|
return isSameDay(date, new Date());
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
export function isCurrentMoth(date) {
|
|
259
|
+
return isSameMonth(date, new Date());
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function isCurrentYear(date) {
|
|
263
|
+
return date.getFullYear() === new Date().getFullYear();
|
|
264
|
+
}
|
|
265
|
+
|
|
258
266
|
export function getLastDayOfMonth(date) {
|
|
259
267
|
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
260
268
|
}
|