@antify/ui 3.3.1 → 3.3.2
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.
|
@@ -24,10 +24,20 @@ const props = withDefaults(defineProps<{
|
|
|
24
24
|
showWeekend?: boolean;
|
|
25
25
|
showTodayButton?: boolean;
|
|
26
26
|
skeleton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* To highlight specific days with a custom color e.g. legal holidays
|
|
29
|
+
* date have the following format: yyyy-mm-dd
|
|
30
|
+
*/
|
|
31
|
+
specialDays?: {
|
|
32
|
+
name: string | null;
|
|
33
|
+
date: string;
|
|
34
|
+
color: string;
|
|
35
|
+
}[];
|
|
27
36
|
}>(), {
|
|
28
37
|
showWeekend: false,
|
|
29
38
|
showTodayButton: true,
|
|
30
39
|
skeleton: false,
|
|
40
|
+
specialDays: () => [],
|
|
31
41
|
});
|
|
32
42
|
defineEmits([
|
|
33
43
|
'select',
|
|
@@ -68,6 +78,8 @@ const matrix = computed(() => {
|
|
|
68
78
|
isCurrentMonth,
|
|
69
79
|
isWeekend: weekdayIndex === 5 || weekdayIndex === 6,
|
|
70
80
|
isToday: date === format(Date.now(), 'yyyy-MM-dd') && isCurrentMonth,
|
|
81
|
+
isSpecialDay: !!props.specialDays.find(specialDay => specialDay.date === date),
|
|
82
|
+
specialDayColor: props.specialDays.find(specialDay => specialDay.date === date)?.color,
|
|
71
83
|
};
|
|
72
84
|
|
|
73
85
|
currentDate = addDays(currentDate, 1);
|
|
@@ -102,6 +114,12 @@ const weekDays = computed(() => {
|
|
|
102
114
|
];
|
|
103
115
|
});
|
|
104
116
|
|
|
117
|
+
const getColorNumber = (color: string) => {
|
|
118
|
+
const match = color.match(/(\d+)/);
|
|
119
|
+
|
|
120
|
+
return match ? parseInt(match[0], 10) : null;
|
|
121
|
+
};
|
|
122
|
+
|
|
105
123
|
watch(() => props.modelValue, (val) => {
|
|
106
124
|
const date = new Date(val);
|
|
107
125
|
currentMonthIndex.value = date.getMonth();
|
|
@@ -156,7 +174,15 @@ watch(() => props.modelValue, (val) => {
|
|
|
156
174
|
'text-for-white-bg-font': day.isCurrentMonth,
|
|
157
175
|
'outline outline-primary-500': day.isToday,
|
|
158
176
|
'hover:bg-base-200 hover:text-base-200-font': day.date !== format(modelValue, 'yyyy-MM-dd'),
|
|
159
|
-
'bg-primary-500 text-primary-500-font hover:bg-primary-300 hover:text-primary-300-font': day.date === format(modelValue, 'yyyy-MM-dd'),
|
|
177
|
+
'!bg-primary-500 !text-primary-500-font hover:bg-primary-300 hover:text-primary-300-font': day.date === format(modelValue, 'yyyy-MM-dd'),
|
|
178
|
+
}"
|
|
179
|
+
:style="{
|
|
180
|
+
backgroundColor: day.isSpecialDay ? `var(--color-${day.specialDayColor})` : 'none',
|
|
181
|
+
color: day.isSpecialDay
|
|
182
|
+
? getColorNumber(day.specialDayColor) < 500
|
|
183
|
+
? 'var(--color-for-white-bg-font)'
|
|
184
|
+
: '#fff'
|
|
185
|
+
: 'none'
|
|
160
186
|
}"
|
|
161
187
|
@click="() => $emit('update:modelValue', new Date(day.date).getTime())"
|
|
162
188
|
>
|
|
@@ -7,6 +7,7 @@ module.exports = exports.Docs = void 0;
|
|
|
7
7
|
var _AntDatePicker = _interopRequireDefault(require("../AntDatePicker.vue"));
|
|
8
8
|
var _AntDateSwitcher = _interopRequireDefault(require("../AntDateSwitcher.vue"));
|
|
9
9
|
var _vue = require("vue");
|
|
10
|
+
var _dateFns = require("date-fns");
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
const meta = {
|
|
12
13
|
title: "Components/Date Picker",
|
|
@@ -53,5 +54,11 @@ const Docs = exports.Docs = {
|
|
|
53
54
|
</div>
|
|
54
55
|
</div>`
|
|
55
56
|
}),
|
|
56
|
-
args: {
|
|
57
|
+
args: {
|
|
58
|
+
specialDays: [{
|
|
59
|
+
name: "Special Day",
|
|
60
|
+
date: (0, _dateFns.format)((0, _dateFns.addDays)(/* @__PURE__ */new Date(), 1), "yyyy-MM-dd"),
|
|
61
|
+
color: "success-300"
|
|
62
|
+
}]
|
|
63
|
+
}
|
|
57
64
|
};
|
|
@@ -3,6 +3,10 @@ import AntDateSwitcher from "../AntDateSwitcher.vue";
|
|
|
3
3
|
import {
|
|
4
4
|
ref
|
|
5
5
|
} from "vue";
|
|
6
|
+
import {
|
|
7
|
+
addDays,
|
|
8
|
+
format
|
|
9
|
+
} from "date-fns";
|
|
6
10
|
const meta = {
|
|
7
11
|
title: "Components/Date Picker",
|
|
8
12
|
component: AntCalendar,
|
|
@@ -48,5 +52,13 @@ export const Docs = {
|
|
|
48
52
|
</div>
|
|
49
53
|
</div>`
|
|
50
54
|
}),
|
|
51
|
-
args: {
|
|
55
|
+
args: {
|
|
56
|
+
specialDays: [
|
|
57
|
+
{
|
|
58
|
+
name: "Special Day",
|
|
59
|
+
date: format(addDays(/* @__PURE__ */ new Date(), 1), "yyyy-MM-dd"),
|
|
60
|
+
color: "success-300"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
52
64
|
};
|