vant 4.8.11 → 4.9.0
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/README.md +7 -5
- package/es/calendar/Calendar.d.ts +16 -10
- package/es/calendar/Calendar.mjs +83 -53
- package/es/calendar/CalendarHeader.d.ts +16 -1
- package/es/calendar/CalendarHeader.mjs +71 -7
- package/es/calendar/CalendarMonth.d.ts +6 -24
- package/es/calendar/CalendarMonth.mjs +6 -4
- package/es/calendar/index.css +1 -1
- package/es/calendar/index.d.ts +11 -7
- package/es/calendar/types.d.ts +4 -0
- package/es/calendar/utils.d.ts +6 -0
- package/es/calendar/utils.mjs +20 -0
- package/es/highlight/Highlight.mjs +7 -0
- package/es/image-preview/ImagePreviewItem.mjs +2 -0
- package/es/index-bar/IndexBar.mjs +10 -2
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/picker-group/PickerGroup.d.ts +13 -0
- package/es/picker-group/PickerGroup.mjs +5 -4
- package/es/picker-group/index.d.ts +9 -0
- package/es/utils/basic.d.ts +1 -1
- package/lib/calendar/Calendar.d.ts +16 -10
- package/lib/calendar/Calendar.js +82 -52
- package/lib/calendar/CalendarHeader.d.ts +16 -1
- package/lib/calendar/CalendarHeader.js +68 -4
- package/lib/calendar/CalendarMonth.d.ts +6 -24
- package/lib/calendar/CalendarMonth.js +6 -4
- package/lib/calendar/index.css +1 -1
- package/lib/calendar/index.d.ts +11 -7
- package/lib/calendar/types.d.ts +4 -0
- package/lib/calendar/utils.d.ts +6 -0
- package/lib/calendar/utils.js +20 -0
- package/lib/highlight/Highlight.js +7 -0
- package/lib/image-preview/ImagePreviewItem.js +2 -0
- package/lib/index-bar/IndexBar.js +10 -2
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/picker-group/PickerGroup.d.ts +13 -0
- package/lib/picker-group/PickerGroup.js +4 -3
- package/lib/picker-group/index.d.ts +9 -0
- package/lib/utils/basic.d.ts +1 -1
- package/lib/vant.cjs.js +193 -66
- package/lib/vant.es.js +193 -66
- package/lib/vant.js +194 -67
- package/lib/vant.min.js +3 -3
- package/lib/web-types.json +1 -1
- package/package.json +15 -15
package/lib/calendar/Calendar.js
CHANGED
@@ -46,6 +46,7 @@ var import_CalendarHeader = __toESM(require("./CalendarHeader"));
|
|
46
46
|
const calendarProps = {
|
47
47
|
show: Boolean,
|
48
48
|
type: (0, import_utils.makeStringProp)("single"),
|
49
|
+
switchMode: (0, import_utils.makeStringProp)("none"),
|
49
50
|
title: String,
|
50
51
|
color: String,
|
51
52
|
round: import_utils.truthProp,
|
@@ -73,16 +74,11 @@ const calendarProps = {
|
|
73
74
|
safeAreaInsetBottom: import_utils.truthProp,
|
74
75
|
minDate: {
|
75
76
|
type: Date,
|
76
|
-
validator: import_utils.isDate
|
77
|
-
default: import_utils2.getToday
|
77
|
+
validator: import_utils.isDate
|
78
78
|
},
|
79
79
|
maxDate: {
|
80
80
|
type: Date,
|
81
|
-
validator: import_utils.isDate
|
82
|
-
default: () => {
|
83
|
-
const now = (0, import_utils2.getToday)();
|
84
|
-
return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
|
85
|
-
}
|
81
|
+
validator: import_utils.isDate
|
86
82
|
},
|
87
83
|
firstDayOfWeek: {
|
88
84
|
type: import_utils.numericProp,
|
@@ -93,25 +89,36 @@ const calendarProps = {
|
|
93
89
|
var stdin_default = (0, import_vue2.defineComponent)({
|
94
90
|
name: import_utils2.name,
|
95
91
|
props: calendarProps,
|
96
|
-
emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate"],
|
92
|
+
emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate", "panelChange"],
|
97
93
|
setup(props, {
|
98
94
|
emit,
|
99
95
|
slots
|
100
96
|
}) {
|
101
|
-
const
|
102
|
-
|
103
|
-
|
97
|
+
const canSwitch = (0, import_vue2.computed)(() => props.switchMode !== "none");
|
98
|
+
const minDate = (0, import_vue2.computed)(() => {
|
99
|
+
if (!props.minDate && !canSwitch.value) {
|
100
|
+
return (0, import_utils2.getToday)();
|
101
|
+
}
|
102
|
+
return props.minDate;
|
103
|
+
});
|
104
|
+
const maxDate = (0, import_vue2.computed)(() => {
|
105
|
+
if (!props.maxDate && !canSwitch.value) {
|
106
|
+
return (0, import_utils2.getMonthByOffset)((0, import_utils2.getToday)(), 6);
|
104
107
|
}
|
105
|
-
|
106
|
-
|
108
|
+
return props.maxDate;
|
109
|
+
});
|
110
|
+
const limitDateRange = (date, min = minDate.value, max = maxDate.value) => {
|
111
|
+
if (min && (0, import_utils2.compareDay)(date, min) === -1) {
|
112
|
+
return min;
|
113
|
+
}
|
114
|
+
if (max && (0, import_utils2.compareDay)(date, max) === 1) {
|
115
|
+
return max;
|
107
116
|
}
|
108
117
|
return date;
|
109
118
|
};
|
110
119
|
const getInitialDate = (defaultDate = props.defaultDate) => {
|
111
120
|
const {
|
112
121
|
type,
|
113
|
-
minDate,
|
114
|
-
maxDate,
|
115
122
|
allowSameDay
|
116
123
|
} = props;
|
117
124
|
if (defaultDate === null) {
|
@@ -122,8 +129,10 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
122
129
|
if (!Array.isArray(defaultDate)) {
|
123
130
|
defaultDate = [];
|
124
131
|
}
|
125
|
-
const
|
126
|
-
const
|
132
|
+
const min = minDate.value;
|
133
|
+
const max = maxDate.value;
|
134
|
+
const start = limitDateRange(defaultDate[0] || now, min, max ? allowSameDay ? max : (0, import_utils2.getPrevDay)(max) : void 0);
|
135
|
+
const end = limitDateRange(defaultDate[1] || (allowSameDay ? now : (0, import_utils2.getNextDay)(now)), min ? allowSameDay ? min : (0, import_utils2.getNextDay)(min) : void 0);
|
127
136
|
return [start, end];
|
128
137
|
}
|
129
138
|
if (type === "multiple") {
|
@@ -137,23 +146,28 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
137
146
|
}
|
138
147
|
return limitDateRange(defaultDate);
|
139
148
|
};
|
149
|
+
const getInitialPanelDate = () => {
|
150
|
+
const date = Array.isArray(currentDate.value) ? currentDate.value[0] : currentDate.value;
|
151
|
+
return date ? date : limitDateRange((0, import_utils2.getToday)());
|
152
|
+
};
|
140
153
|
let bodyHeight;
|
141
154
|
const bodyRef = (0, import_vue2.ref)();
|
142
|
-
const subtitle = (0, import_vue2.ref)({
|
143
|
-
textFn: () => "",
|
144
|
-
date: void 0
|
145
|
-
});
|
146
155
|
const currentDate = (0, import_vue2.ref)(getInitialDate());
|
156
|
+
const currentPanelDate = (0, import_vue2.ref)(getInitialPanelDate());
|
157
|
+
const currentMonthRef = (0, import_vue2.ref)();
|
147
158
|
const [monthRefs, setMonthRefs] = (0, import_use_refs.useRefs)();
|
148
159
|
const dayOffset = (0, import_vue2.computed)(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
|
149
160
|
const months = (0, import_vue2.computed)(() => {
|
150
161
|
const months2 = [];
|
151
|
-
|
162
|
+
if (!minDate.value || !maxDate.value) {
|
163
|
+
return months2;
|
164
|
+
}
|
165
|
+
const cursor = new Date(minDate.value);
|
152
166
|
cursor.setDate(1);
|
153
167
|
do {
|
154
168
|
months2.push(new Date(cursor));
|
155
169
|
cursor.setMonth(cursor.getMonth() + 1);
|
156
|
-
} while ((0, import_utils2.compareMonth)(cursor,
|
170
|
+
} while ((0, import_utils2.compareMonth)(cursor, maxDate.value) !== 1);
|
157
171
|
return months2;
|
158
172
|
});
|
159
173
|
const buttonDisabled = (0, import_vue2.computed)(() => {
|
@@ -203,25 +217,26 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
203
217
|
monthRefs.value[index].setVisible(visible);
|
204
218
|
});
|
205
219
|
if (currentMonth) {
|
206
|
-
|
207
|
-
textFn: currentMonth.getTitle,
|
208
|
-
date: currentMonth.date
|
209
|
-
};
|
220
|
+
currentMonthRef.value = currentMonth;
|
210
221
|
}
|
211
222
|
};
|
212
223
|
const scrollToDate = (targetDate) => {
|
213
|
-
(
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
224
|
+
if (canSwitch.value) {
|
225
|
+
currentPanelDate.value = targetDate;
|
226
|
+
} else {
|
227
|
+
(0, import_use.raf)(() => {
|
228
|
+
months.value.some((month, index) => {
|
229
|
+
if ((0, import_utils2.compareMonth)(month, targetDate) === 0) {
|
230
|
+
if (bodyRef.value) {
|
231
|
+
monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
|
232
|
+
}
|
233
|
+
return true;
|
218
234
|
}
|
219
|
-
return
|
220
|
-
}
|
221
|
-
|
235
|
+
return false;
|
236
|
+
});
|
237
|
+
onScroll();
|
222
238
|
});
|
223
|
-
|
224
|
-
});
|
239
|
+
}
|
225
240
|
};
|
226
241
|
const scrollToCurrentDate = () => {
|
227
242
|
if (props.poppable && !props.show) {
|
@@ -232,7 +247,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
232
247
|
if ((0, import_utils.isDate)(targetDate)) {
|
233
248
|
scrollToDate(targetDate);
|
234
249
|
}
|
235
|
-
} else {
|
250
|
+
} else if (!canSwitch.value) {
|
236
251
|
(0, import_use.raf)(onScroll);
|
237
252
|
}
|
238
253
|
};
|
@@ -240,9 +255,11 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
240
255
|
if (props.poppable && !props.show) {
|
241
256
|
return;
|
242
257
|
}
|
243
|
-
(
|
244
|
-
|
245
|
-
|
258
|
+
if (!canSwitch.value) {
|
259
|
+
(0, import_use.raf)(() => {
|
260
|
+
bodyHeight = Math.floor((0, import_use.useRect)(bodyRef).height);
|
261
|
+
});
|
262
|
+
}
|
246
263
|
scrollToCurrentDate();
|
247
264
|
};
|
248
265
|
const reset = (date = getInitialDate()) => {
|
@@ -264,6 +281,12 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
264
281
|
}
|
265
282
|
return true;
|
266
283
|
};
|
284
|
+
const onPanelChange = (date) => {
|
285
|
+
currentPanelDate.value = date;
|
286
|
+
emit("panelChange", {
|
287
|
+
date
|
288
|
+
});
|
289
|
+
};
|
267
290
|
const onConfirm = () => {
|
268
291
|
var _a;
|
269
292
|
return emit("confirm", (_a = currentDate.value) != null ? _a : (0, import_utils2.cloneDates)(currentDate.value));
|
@@ -355,12 +378,15 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
355
378
|
const renderMonth = (date, index) => {
|
356
379
|
const showMonthTitle = index !== 0 || !props.showSubtitle;
|
357
380
|
return (0, import_vue.createVNode)(import_CalendarMonth.default, (0, import_vue.mergeProps)({
|
358
|
-
"ref": setMonthRefs(index),
|
381
|
+
"ref": canSwitch.value ? currentMonthRef : setMonthRefs(index),
|
359
382
|
"date": date,
|
360
383
|
"currentDate": currentDate.value,
|
361
384
|
"showMonthTitle": showMonthTitle,
|
362
|
-
"firstDayOfWeek": dayOffset.value
|
363
|
-
|
385
|
+
"firstDayOfWeek": dayOffset.value,
|
386
|
+
"lazyRender": canSwitch.value ? false : props.lazyRender,
|
387
|
+
"maxDate": maxDate.value,
|
388
|
+
"minDate": minDate.value
|
389
|
+
}, (0, import_utils.pick)(props, ["type", "color", "showMark", "formatter", "rowHeight", "showSubtitle", "allowSameDay"]), {
|
364
390
|
"onClick": onClickDay,
|
365
391
|
"onClickDisabledDate": (item) => emit("clickDisabledDate", item)
|
366
392
|
}), (0, import_utils.pick)(slots, ["top-info", "bottom-info", "month-title"]));
|
@@ -395,25 +421,29 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
395
421
|
}]
|
396
422
|
}, [renderFooterButton()]);
|
397
423
|
const renderCalendar = () => {
|
398
|
-
|
424
|
+
var _a, _b;
|
399
425
|
return (0, import_vue.createVNode)("div", {
|
400
426
|
"class": (0, import_utils2.bem)()
|
401
427
|
}, [(0, import_vue.createVNode)(import_CalendarHeader.default, {
|
402
|
-
"date":
|
428
|
+
"date": (_a = currentMonthRef.value) == null ? void 0 : _a.date,
|
429
|
+
"maxDate": maxDate.value,
|
430
|
+
"minDate": minDate.value,
|
403
431
|
"title": props.title,
|
404
|
-
"subtitle":
|
432
|
+
"subtitle": (_b = currentMonthRef.value) == null ? void 0 : _b.getTitle(),
|
405
433
|
"showTitle": props.showTitle,
|
406
434
|
"showSubtitle": props.showSubtitle,
|
435
|
+
"switchMode": props.switchMode,
|
407
436
|
"firstDayOfWeek": dayOffset.value,
|
408
|
-
"onClickSubtitle": (event) => emit("clickSubtitle", event)
|
409
|
-
|
437
|
+
"onClickSubtitle": (event) => emit("clickSubtitle", event),
|
438
|
+
"onPanelChange": onPanelChange
|
439
|
+
}, (0, import_utils.pick)(slots, ["title", "subtitle", "prev-month", "prev-year", "next-month", "next-year"])), (0, import_vue.createVNode)("div", {
|
410
440
|
"ref": bodyRef,
|
411
441
|
"class": (0, import_utils2.bem)("body"),
|
412
|
-
"onScroll": onScroll
|
413
|
-
}, [months.value.map(renderMonth)]), renderFooter()]);
|
442
|
+
"onScroll": canSwitch.value ? void 0 : onScroll
|
443
|
+
}, [canSwitch.value ? renderMonth(currentPanelDate.value, 0) : months.value.map(renderMonth)]), renderFooter()]);
|
414
444
|
};
|
415
445
|
(0, import_vue2.watch)(() => props.show, init);
|
416
|
-
(0, import_vue2.watch)(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
|
446
|
+
(0, import_vue2.watch)(() => [props.type, props.minDate, props.maxDate, props.switchMode], () => reset(getInitialDate(currentDate.value)));
|
417
447
|
(0, import_vue2.watch)(() => props.defaultDate, (value = null) => {
|
418
448
|
currentDate.value = value;
|
419
449
|
scrollToCurrentDate();
|
@@ -1,20 +1,35 @@
|
|
1
|
+
import type { CalendarSwitchMode } from './types';
|
1
2
|
declare const _default: import("vue").DefineComponent<{
|
2
3
|
date: DateConstructor;
|
4
|
+
minDate: DateConstructor;
|
5
|
+
maxDate: DateConstructor;
|
3
6
|
title: StringConstructor;
|
4
7
|
subtitle: StringConstructor;
|
5
8
|
showTitle: BooleanConstructor;
|
6
9
|
showSubtitle: BooleanConstructor;
|
7
10
|
firstDayOfWeek: NumberConstructor;
|
8
|
-
|
11
|
+
switchMode: {
|
12
|
+
type: import("vue").PropType<CalendarSwitchMode>;
|
13
|
+
default: CalendarSwitchMode;
|
14
|
+
};
|
15
|
+
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("clickSubtitle" | "panelChange")[], "clickSubtitle" | "panelChange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
9
16
|
date: DateConstructor;
|
17
|
+
minDate: DateConstructor;
|
18
|
+
maxDate: DateConstructor;
|
10
19
|
title: StringConstructor;
|
11
20
|
subtitle: StringConstructor;
|
12
21
|
showTitle: BooleanConstructor;
|
13
22
|
showSubtitle: BooleanConstructor;
|
14
23
|
firstDayOfWeek: NumberConstructor;
|
24
|
+
switchMode: {
|
25
|
+
type: import("vue").PropType<CalendarSwitchMode>;
|
26
|
+
default: CalendarSwitchMode;
|
27
|
+
};
|
15
28
|
}>> & {
|
16
29
|
onClickSubtitle?: ((...args: any[]) => any) | undefined;
|
30
|
+
onPanelChange?: ((...args: any[]) => any) | undefined;
|
17
31
|
}, {
|
32
|
+
switchMode: CalendarSwitchMode;
|
18
33
|
showTitle: boolean;
|
19
34
|
showSubtitle: boolean;
|
20
35
|
}, {}>;
|
@@ -24,22 +24,42 @@ var import_vue = require("vue");
|
|
24
24
|
var import_vue2 = require("vue");
|
25
25
|
var import_utils = require("../utils");
|
26
26
|
var import_utils2 = require("./utils");
|
27
|
+
var import_icon = require("../icon");
|
27
28
|
const [name] = (0, import_utils.createNamespace)("calendar-header");
|
28
29
|
var stdin_default = (0, import_vue2.defineComponent)({
|
29
30
|
name,
|
30
31
|
props: {
|
31
32
|
date: Date,
|
33
|
+
minDate: Date,
|
34
|
+
maxDate: Date,
|
32
35
|
title: String,
|
33
36
|
subtitle: String,
|
34
37
|
showTitle: Boolean,
|
35
38
|
showSubtitle: Boolean,
|
36
|
-
firstDayOfWeek: Number
|
39
|
+
firstDayOfWeek: Number,
|
40
|
+
switchMode: (0, import_utils.makeStringProp)("none")
|
37
41
|
},
|
38
|
-
emits: ["clickSubtitle"],
|
42
|
+
emits: ["clickSubtitle", "panelChange"],
|
39
43
|
setup(props, {
|
40
44
|
slots,
|
41
45
|
emit
|
42
46
|
}) {
|
47
|
+
const prevMonthDisabled = (0, import_vue2.computed)(() => {
|
48
|
+
const prevMonth = (0, import_utils2.getPrevMonth)(props.date);
|
49
|
+
return props.minDate && prevMonth < props.minDate;
|
50
|
+
});
|
51
|
+
const prevYearDisabled = (0, import_vue2.computed)(() => {
|
52
|
+
const prevYear = (0, import_utils2.getPrevYear)(props.date);
|
53
|
+
return props.minDate && prevYear < props.minDate;
|
54
|
+
});
|
55
|
+
const nextMonthDisabled = (0, import_vue2.computed)(() => {
|
56
|
+
const nextMonth = (0, import_utils2.getNextMonth)(props.date);
|
57
|
+
return props.maxDate && nextMonth > props.maxDate;
|
58
|
+
});
|
59
|
+
const nextYearDisabled = (0, import_vue2.computed)(() => {
|
60
|
+
const nextYear = (0, import_utils2.getNextYear)(props.date);
|
61
|
+
return props.maxDate && nextYear > props.maxDate;
|
62
|
+
});
|
43
63
|
const renderTitle = () => {
|
44
64
|
if (props.showTitle) {
|
45
65
|
const text = props.title || (0, import_utils2.t)("title");
|
@@ -50,16 +70,60 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
50
70
|
}
|
51
71
|
};
|
52
72
|
const onClickSubtitle = (event) => emit("clickSubtitle", event);
|
73
|
+
const onPanelChange = (date) => emit("panelChange", date);
|
74
|
+
const renderAction = (isNext) => {
|
75
|
+
const showYearAction = props.switchMode === "year-month";
|
76
|
+
const monthSlot = slots[isNext ? "next-month" : "prev-month"];
|
77
|
+
const yearSlot = slots[isNext ? "next-year" : "prev-year"];
|
78
|
+
const monthDisabled = isNext ? nextMonthDisabled.value : prevMonthDisabled.value;
|
79
|
+
const yearDisabled = isNext ? nextYearDisabled.value : prevYearDisabled.value;
|
80
|
+
const monthIconName = isNext ? "arrow" : "arrow-left";
|
81
|
+
const yearIconName = isNext ? "arrow-double-right" : "arrow-double-left";
|
82
|
+
const onMonthChange = () => onPanelChange((isNext ? import_utils2.getNextMonth : import_utils2.getPrevMonth)(props.date));
|
83
|
+
const onYearChange = () => onPanelChange((isNext ? import_utils2.getNextYear : import_utils2.getPrevYear)(props.date));
|
84
|
+
const MonthAction = (0, import_vue.createVNode)("view", {
|
85
|
+
"class": (0, import_utils2.bem)("header-action", {
|
86
|
+
disabled: monthDisabled
|
87
|
+
}),
|
88
|
+
"onClick": monthDisabled ? void 0 : onMonthChange
|
89
|
+
}, [monthSlot ? monthSlot({
|
90
|
+
disabled: monthDisabled
|
91
|
+
}) : (0, import_vue.createVNode)(import_icon.Icon, {
|
92
|
+
"class": {
|
93
|
+
[import_utils.HAPTICS_FEEDBACK]: !monthDisabled
|
94
|
+
},
|
95
|
+
"name": monthIconName
|
96
|
+
}, null)]);
|
97
|
+
const YearAction = showYearAction && (0, import_vue.createVNode)("view", {
|
98
|
+
"class": (0, import_utils2.bem)("header-action", {
|
99
|
+
disabled: yearDisabled
|
100
|
+
}),
|
101
|
+
"onClick": yearDisabled ? void 0 : onYearChange
|
102
|
+
}, [yearSlot ? yearSlot({
|
103
|
+
disabled: yearDisabled
|
104
|
+
}) : (0, import_vue.createVNode)(import_icon.Icon, {
|
105
|
+
"class": {
|
106
|
+
[import_utils.HAPTICS_FEEDBACK]: !yearDisabled
|
107
|
+
},
|
108
|
+
"name": yearIconName
|
109
|
+
}, null)]);
|
110
|
+
return isNext ? [MonthAction, YearAction] : [YearAction, MonthAction];
|
111
|
+
};
|
53
112
|
const renderSubtitle = () => {
|
54
113
|
if (props.showSubtitle) {
|
55
114
|
const title = slots.subtitle ? slots.subtitle({
|
56
115
|
date: props.date,
|
57
116
|
text: props.subtitle
|
58
117
|
}) : props.subtitle;
|
118
|
+
const canSwitch = props.switchMode !== "none";
|
59
119
|
return (0, import_vue.createVNode)("div", {
|
60
|
-
"class": (0, import_utils2.bem)("header-subtitle"
|
120
|
+
"class": (0, import_utils2.bem)("header-subtitle", {
|
121
|
+
"with-swicth": canSwitch
|
122
|
+
}),
|
61
123
|
"onClick": onClickSubtitle
|
62
|
-
}, [
|
124
|
+
}, [canSwitch ? [renderAction(), (0, import_vue.createVNode)("div", {
|
125
|
+
"class": (0, import_utils2.bem)("header-subtitle-text")
|
126
|
+
}, [title]), renderAction(true)] : title]);
|
63
127
|
}
|
64
128
|
};
|
65
129
|
const renderWeekDays = () => {
|
@@ -7,14 +7,8 @@ declare const calendarMonthProps: {
|
|
7
7
|
};
|
8
8
|
type: PropType<CalendarType>;
|
9
9
|
color: StringConstructor;
|
10
|
-
minDate:
|
11
|
-
|
12
|
-
required: true;
|
13
|
-
};
|
14
|
-
maxDate: {
|
15
|
-
type: DateConstructor;
|
16
|
-
required: true;
|
17
|
-
};
|
10
|
+
minDate: DateConstructor;
|
11
|
+
maxDate: DateConstructor;
|
18
12
|
showMark: BooleanConstructor;
|
19
13
|
rowHeight: (NumberConstructor | StringConstructor)[];
|
20
14
|
formatter: PropType<(item: CalendarDayItem) => CalendarDayItem>;
|
@@ -33,14 +27,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
33
27
|
};
|
34
28
|
type: PropType<CalendarType>;
|
35
29
|
color: StringConstructor;
|
36
|
-
minDate:
|
37
|
-
|
38
|
-
required: true;
|
39
|
-
};
|
40
|
-
maxDate: {
|
41
|
-
type: DateConstructor;
|
42
|
-
required: true;
|
43
|
-
};
|
30
|
+
minDate: DateConstructor;
|
31
|
+
maxDate: DateConstructor;
|
44
32
|
showMark: BooleanConstructor;
|
45
33
|
rowHeight: (NumberConstructor | StringConstructor)[];
|
46
34
|
formatter: PropType<(item: CalendarDayItem) => CalendarDayItem>;
|
@@ -57,14 +45,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
57
45
|
};
|
58
46
|
type: PropType<CalendarType>;
|
59
47
|
color: StringConstructor;
|
60
|
-
minDate:
|
61
|
-
|
62
|
-
required: true;
|
63
|
-
};
|
64
|
-
maxDate: {
|
65
|
-
type: DateConstructor;
|
66
|
-
required: true;
|
67
|
-
};
|
48
|
+
minDate: DateConstructor;
|
49
|
+
maxDate: DateConstructor;
|
68
50
|
showMark: BooleanConstructor;
|
69
51
|
rowHeight: (NumberConstructor | StringConstructor)[];
|
70
52
|
formatter: PropType<(item: CalendarDayItem) => CalendarDayItem>;
|
@@ -44,8 +44,8 @@ const calendarMonthProps = {
|
|
44
44
|
date: (0, import_utils.makeRequiredProp)(Date),
|
45
45
|
type: String,
|
46
46
|
color: String,
|
47
|
-
minDate:
|
48
|
-
maxDate:
|
47
|
+
minDate: Date,
|
48
|
+
maxDate: Date,
|
49
49
|
showMark: Boolean,
|
50
50
|
rowHeight: import_utils.numericProp,
|
51
51
|
formatter: Function,
|
@@ -71,7 +71,9 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
71
71
|
const title = (0, import_vue2.computed)(() => (0, import_utils3.formatMonthTitle)(props.date));
|
72
72
|
const rowHeight = (0, import_vue2.computed)(() => (0, import_utils.addUnit)(props.rowHeight));
|
73
73
|
const offset = (0, import_vue2.computed)(() => {
|
74
|
-
const
|
74
|
+
const date = props.date.getDate();
|
75
|
+
const day = props.date.getDay();
|
76
|
+
const realDay = (day - date % 7 + 8) % 7;
|
75
77
|
if (props.firstDayOfWeek) {
|
76
78
|
return (realDay + 7 - props.firstDayOfWeek) % 7;
|
77
79
|
}
|
@@ -131,7 +133,7 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
131
133
|
maxDate,
|
132
134
|
currentDate
|
133
135
|
} = props;
|
134
|
-
if ((0, import_utils3.compareDay)(day, minDate) < 0 || (0, import_utils3.compareDay)(day, maxDate) > 0) {
|
136
|
+
if (minDate && (0, import_utils3.compareDay)(day, minDate) < 0 || maxDate && (0, import_utils3.compareDay)(day, maxDate) > 0) {
|
135
137
|
return "disabled";
|
136
138
|
}
|
137
139
|
if (currentDate === null) {
|
package/lib/calendar/index.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
:root,:host{--van-calendar-background: var(--van-background-2);--van-calendar-popup-height: 80%;--van-calendar-header-shadow: 0 2px 10px rgba(125, 126, 128, .16);--van-calendar-header-title-height: 44px;--van-calendar-header-title-font-size: var(--van-font-size-lg);--van-calendar-header-subtitle-font-size: var(--van-font-size-md);--van-calendar-weekdays-height: 30px;--van-calendar-weekdays-font-size: var(--van-font-size-sm);--van-calendar-month-title-font-size: var(--van-font-size-md);--van-calendar-month-mark-color: rgba(242, 243, 245, .8);--van-calendar-month-mark-font-size: 160px;--van-calendar-day-height: 64px;--van-calendar-day-font-size: var(--van-font-size-lg);--van-calendar-day-margin-bottom: 4px;--van-calendar-range-edge-color: var(--van-white);--van-calendar-range-edge-background: var(--van-primary-color);--van-calendar-range-middle-color: var(--van-primary-color);--van-calendar-range-middle-background-opacity: .1;--van-calendar-selected-day-size: 54px;--van-calendar-selected-day-color: var(--van-white);--van-calendar-info-font-size: var(--van-font-size-xs);--van-calendar-info-line-height: var(--van-line-height-xs);--van-calendar-selected-day-background: var(--van-primary-color);--van-calendar-day-disabled-color: var(--van-text-color-3);--van-calendar-confirm-button-height: 36px;--van-calendar-confirm-button-margin: 7px 0}.van-theme-dark{--van-calendar-month-mark-color: rgba(100, 101, 102, .2);--van-calendar-day-disabled-color: var(--van-gray-7)}.van-calendar{display:flex;flex-direction:column;height:100%;background:var(--van-calendar-background)}.van-calendar__popup.van-popup--top,.van-calendar__popup.van-popup--bottom{height:var(--van-calendar-popup-height)}.van-calendar__popup.van-popup--left,.van-calendar__popup.van-popup--right{height:100%}.van-calendar__popup .van-popup__close-icon{top:11px}.van-calendar__header{flex-shrink:0;box-shadow:var(--van-calendar-header-shadow)}.van-calendar__month-title,.van-calendar__header-title,.van-calendar__header-subtitle{color:var(--van-text-color);height:var(--van-calendar-header-title-height);font-weight:var(--van-font-bold);line-height:var(--van-calendar-header-title-height);text-align:center}.van-calendar__header-title{font-size:var(--van-calendar-header-title-font-size)}.van-calendar__header-subtitle{font-size:var(--van-calendar-header-subtitle-font-size)}.van-calendar__month-title{font-size:var(--van-calendar-month-title-font-size)}.van-calendar__weekdays{display:flex}.van-calendar__weekday{flex:1;font-size:var(--van-calendar-weekdays-font-size);line-height:var(--van-calendar-weekdays-height);text-align:center}.van-calendar__body{flex:1;overflow:auto;-webkit-overflow-scrolling:touch}.van-calendar__days{position:relative;display:flex;flex-wrap:wrap;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{position:absolute;top:50%;left:50%;z-index:0;color:var(--van-calendar-month-mark-color);font-size:var(--van-calendar-month-mark-font-size);transform:translate(-50%,-50%);pointer-events:none}.van-calendar__day,.van-calendar__selected-day{display:flex;align-items:center;justify-content:center;text-align:center}.van-calendar__day{position:relative;width:14.285%;height:var(--van-calendar-day-height);font-size:var(--van-calendar-day-font-size);margin-bottom:var(--van-calendar-day-margin-bottom);cursor:pointer}.van-calendar__day--end,.van-calendar__day--start,.van-calendar__day--start-end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected{color:var(--van-calendar-range-edge-color);background:var(--van-calendar-range-edge-background)}.van-calendar__day--start{border-radius:var(--van-radius-md) 0 0 var(--van-radius-md)}.van-calendar__day--end{border-radius:0 var(--van-radius-md) var(--van-radius-md) 0}.van-calendar__day--start-end,.van-calendar__day--multiple-selected{border-radius:var(--van-radius-md)}.van-calendar__day--middle{color:var(--van-calendar-range-middle-color)}.van-calendar__day--middle:after{position:absolute;top:0;right:0;bottom:0;left:0;background-color:currentColor;opacity:var(--van-calendar-range-middle-background-opacity);content:""}.van-calendar__day--disabled{color:var(--van-calendar-day-disabled-color);cursor:default}.van-calendar__top-info,.van-calendar__bottom-info{position:absolute;right:0;left:0;font-size:var(--van-calendar-info-font-size);line-height:var(--van-calendar-info-line-height)}@media (max-width: 350px){.van-calendar__top-info,.van-calendar__bottom-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:6px}.van-calendar__selected-day{width:var(--van-calendar-selected-day-size);height:var(--van-calendar-selected-day-size);color:var(--van-calendar-selected-day-color);background:var(--van-calendar-selected-day-background);border-radius:var(--van-radius-md)}.van-calendar__footer{flex-shrink:0;padding-left:var(--van-padding-md);padding-right:var(--van-padding-md)}.van-calendar__confirm{height:var(--van-calendar-confirm-button-height);margin:var(--van-calendar-confirm-button-margin)}
|
1
|
+
:root,:host{--van-calendar-background: var(--van-background-2);--van-calendar-popup-height: 80%;--van-calendar-header-shadow: 0 2px 10px rgba(125, 126, 128, .16);--van-calendar-header-title-height: 44px;--van-calendar-header-title-font-size: var(--van-font-size-lg);--van-calendar-header-subtitle-font-size: var(--van-font-size-md);--van-calendar-header-action-width: 28px;--van-calendar-header-action-color: var(--van-text-color);--van-calendar-header-action-disabled-color: var(--van-text-color-3);--van-calendar-weekdays-height: 30px;--van-calendar-weekdays-font-size: var(--van-font-size-sm);--van-calendar-month-title-font-size: var(--van-font-size-md);--van-calendar-month-mark-color: rgba(242, 243, 245, .8);--van-calendar-month-mark-font-size: 160px;--van-calendar-day-height: 64px;--van-calendar-day-font-size: var(--van-font-size-lg);--van-calendar-day-margin-bottom: 4px;--van-calendar-range-edge-color: var(--van-white);--van-calendar-range-edge-background: var(--van-primary-color);--van-calendar-range-middle-color: var(--van-primary-color);--van-calendar-range-middle-background-opacity: .1;--van-calendar-selected-day-size: 54px;--van-calendar-selected-day-color: var(--van-white);--van-calendar-info-font-size: var(--van-font-size-xs);--van-calendar-info-line-height: var(--van-line-height-xs);--van-calendar-selected-day-background: var(--van-primary-color);--van-calendar-day-disabled-color: var(--van-text-color-3);--van-calendar-confirm-button-height: 36px;--van-calendar-confirm-button-margin: 7px 0}.van-theme-dark{--van-calendar-month-mark-color: rgba(100, 101, 102, .2);--van-calendar-day-disabled-color: var(--van-gray-7)}.van-calendar{display:flex;flex-direction:column;height:100%;background:var(--van-calendar-background)}.van-calendar__popup.van-popup--top,.van-calendar__popup.van-popup--bottom{height:var(--van-calendar-popup-height)}.van-calendar__popup.van-popup--left,.van-calendar__popup.van-popup--right{height:100%}.van-calendar__popup .van-popup__close-icon{top:11px}.van-calendar__header{flex-shrink:0;box-shadow:var(--van-calendar-header-shadow)}.van-calendar__month-title,.van-calendar__header-title,.van-calendar__header-subtitle{color:var(--van-text-color);height:var(--van-calendar-header-title-height);font-weight:var(--van-font-bold);line-height:var(--van-calendar-header-title-height);text-align:center}.van-calendar__header-title{font-size:var(--van-calendar-header-title-font-size)}.van-calendar__header-subtitle{font-size:var(--van-calendar-header-subtitle-font-size)}.van-calendar__header-subtitle--with-swicth{display:flex;align-items:center;padding:0 var(--van-padding-base)}.van-calendar__header-subtitle-text{flex:1}.van-calendar__header-action{display:flex;align-items:center;justify-content:center;min-width:var(--van-calendar-header-action-width);height:100%;color:var(--van-calendar-header-action-color);cursor:pointer}.van-calendar__header-action--disabled{color:var(--van-calendar-header-action-disabled-color);cursor:not-allowed}.van-calendar__month-title{font-size:var(--van-calendar-month-title-font-size)}.van-calendar__weekdays{display:flex}.van-calendar__weekday{flex:1;font-size:var(--van-calendar-weekdays-font-size);line-height:var(--van-calendar-weekdays-height);text-align:center}.van-calendar__body{flex:1;overflow:auto;-webkit-overflow-scrolling:touch}.van-calendar__days{position:relative;display:flex;flex-wrap:wrap;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{position:absolute;top:50%;left:50%;z-index:0;color:var(--van-calendar-month-mark-color);font-size:var(--van-calendar-month-mark-font-size);transform:translate(-50%,-50%);pointer-events:none}.van-calendar__day,.van-calendar__selected-day{display:flex;align-items:center;justify-content:center;text-align:center}.van-calendar__day{position:relative;width:14.285%;height:var(--van-calendar-day-height);font-size:var(--van-calendar-day-font-size);margin-bottom:var(--van-calendar-day-margin-bottom);cursor:pointer}.van-calendar__day--end,.van-calendar__day--start,.van-calendar__day--start-end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected{color:var(--van-calendar-range-edge-color);background:var(--van-calendar-range-edge-background)}.van-calendar__day--start{border-radius:var(--van-radius-md) 0 0 var(--van-radius-md)}.van-calendar__day--end{border-radius:0 var(--van-radius-md) var(--van-radius-md) 0}.van-calendar__day--start-end,.van-calendar__day--multiple-selected{border-radius:var(--van-radius-md)}.van-calendar__day--middle{color:var(--van-calendar-range-middle-color)}.van-calendar__day--middle:after{position:absolute;top:0;right:0;bottom:0;left:0;background-color:currentColor;opacity:var(--van-calendar-range-middle-background-opacity);content:""}.van-calendar__day--disabled{color:var(--van-calendar-day-disabled-color);cursor:default}.van-calendar__top-info,.van-calendar__bottom-info{position:absolute;right:0;left:0;font-size:var(--van-calendar-info-font-size);line-height:var(--van-calendar-info-line-height)}@media (max-width: 350px){.van-calendar__top-info,.van-calendar__bottom-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:6px}.van-calendar__selected-day{width:var(--van-calendar-selected-day-size);height:var(--van-calendar-selected-day-size);color:var(--van-calendar-selected-day-color);background:var(--van-calendar-selected-day-background);border-radius:var(--van-radius-md)}.van-calendar__footer{flex-shrink:0;padding-left:var(--van-padding-md);padding-right:var(--van-padding-md)}.van-calendar__confirm{height:var(--van-calendar-confirm-button-height);margin:var(--van-calendar-confirm-button-margin)}
|
package/lib/calendar/index.d.ts
CHANGED
@@ -4,6 +4,10 @@ export declare const Calendar: import("../utils").WithInstall<import("vue").Defi
|
|
4
4
|
type: import("vue").PropType<import("./types").CalendarType>;
|
5
5
|
default: import("./types").CalendarType;
|
6
6
|
};
|
7
|
+
switchMode: {
|
8
|
+
type: import("vue").PropType<import("./types").CalendarSwitchMode>;
|
9
|
+
default: import("./types").CalendarSwitchMode;
|
10
|
+
};
|
7
11
|
title: StringConstructor;
|
8
12
|
color: StringConstructor;
|
9
13
|
round: {
|
@@ -71,24 +75,26 @@ export declare const Calendar: import("../utils").WithInstall<import("vue").Defi
|
|
71
75
|
minDate: {
|
72
76
|
type: DateConstructor;
|
73
77
|
validator: (val: unknown) => val is Date;
|
74
|
-
default: () => Date;
|
75
78
|
};
|
76
79
|
maxDate: {
|
77
80
|
type: DateConstructor;
|
78
81
|
validator: (val: unknown) => val is Date;
|
79
|
-
default: () => Date;
|
80
82
|
};
|
81
83
|
firstDayOfWeek: {
|
82
84
|
type: (NumberConstructor | StringConstructor)[];
|
83
85
|
default: number;
|
84
86
|
validator: (val: number) => boolean;
|
85
87
|
};
|
86
|
-
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show" | "confirm" | "clickDisabledDate" | "clickSubtitle" | "unselect" | "monthShow" | "overRange")[], "select" | "update:show" | "confirm" | "clickDisabledDate" | "clickSubtitle" | "unselect" | "monthShow" | "overRange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
88
|
+
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("select" | "update:show" | "confirm" | "clickDisabledDate" | "clickSubtitle" | "panelChange" | "unselect" | "monthShow" | "overRange")[], "select" | "update:show" | "confirm" | "clickDisabledDate" | "clickSubtitle" | "panelChange" | "unselect" | "monthShow" | "overRange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
87
89
|
show: BooleanConstructor;
|
88
90
|
type: {
|
89
91
|
type: import("vue").PropType<import("./types").CalendarType>;
|
90
92
|
default: import("./types").CalendarType;
|
91
93
|
};
|
94
|
+
switchMode: {
|
95
|
+
type: import("vue").PropType<import("./types").CalendarSwitchMode>;
|
96
|
+
default: import("./types").CalendarSwitchMode;
|
97
|
+
};
|
92
98
|
title: StringConstructor;
|
93
99
|
color: StringConstructor;
|
94
100
|
round: {
|
@@ -156,12 +162,10 @@ export declare const Calendar: import("../utils").WithInstall<import("vue").Defi
|
|
156
162
|
minDate: {
|
157
163
|
type: DateConstructor;
|
158
164
|
validator: (val: unknown) => val is Date;
|
159
|
-
default: () => Date;
|
160
165
|
};
|
161
166
|
maxDate: {
|
162
167
|
type: DateConstructor;
|
163
168
|
validator: (val: unknown) => val is Date;
|
164
|
-
default: () => Date;
|
165
169
|
};
|
166
170
|
firstDayOfWeek: {
|
167
171
|
type: (NumberConstructor | StringConstructor)[];
|
@@ -174,6 +178,7 @@ export declare const Calendar: import("../utils").WithInstall<import("vue").Defi
|
|
174
178
|
onConfirm?: ((...args: any[]) => any) | undefined;
|
175
179
|
onClickDisabledDate?: ((...args: any[]) => any) | undefined;
|
176
180
|
onClickSubtitle?: ((...args: any[]) => any) | undefined;
|
181
|
+
onPanelChange?: ((...args: any[]) => any) | undefined;
|
177
182
|
onUnselect?: ((...args: any[]) => any) | undefined;
|
178
183
|
onMonthShow?: ((...args: any[]) => any) | undefined;
|
179
184
|
onOverRange?: ((...args: any[]) => any) | undefined;
|
@@ -188,6 +193,7 @@ export declare const Calendar: import("../utils").WithInstall<import("vue").Defi
|
|
188
193
|
closeOnClickOverlay: boolean;
|
189
194
|
closeOnPopstate: boolean;
|
190
195
|
safeAreaInsetTop: boolean;
|
196
|
+
switchMode: import("./types").CalendarSwitchMode;
|
191
197
|
poppable: boolean;
|
192
198
|
maxRange: string | number;
|
193
199
|
showMark: boolean;
|
@@ -196,8 +202,6 @@ export declare const Calendar: import("../utils").WithInstall<import("vue").Defi
|
|
196
202
|
allowSameDay: boolean;
|
197
203
|
showSubtitle: boolean;
|
198
204
|
showRangePrompt: boolean;
|
199
|
-
minDate: Date;
|
200
|
-
maxDate: Date;
|
201
205
|
firstDayOfWeek: string | number;
|
202
206
|
}, {}>>;
|
203
207
|
export default Calendar;
|
package/lib/calendar/types.d.ts
CHANGED
@@ -2,6 +2,7 @@ import type { ComponentPublicInstance, ComputedRef, Ref } from 'vue';
|
|
2
2
|
import type { Numeric } from '../utils';
|
3
3
|
import type { CalendarProps } from './Calendar';
|
4
4
|
import type { CalendarMonthProps } from './CalendarMonth';
|
5
|
+
export type CalendarSwitchMode = 'none' | 'month' | 'year-month';
|
5
6
|
export type CalendarType = 'single' | 'range' | 'multiple';
|
6
7
|
export type CalendarDayType = '' | 'start' | 'start-end' | 'middle' | 'end' | 'selected' | 'multiple-middle' | 'multiple-selected' | 'disabled' | 'placeholder';
|
7
8
|
export type CalendarDayItem = {
|
@@ -33,6 +34,9 @@ export type CalendarThemeVars = {
|
|
33
34
|
calendarHeaderTitleHeight?: string;
|
34
35
|
calendarHeaderTitleFontSize?: string;
|
35
36
|
calendarHeaderSubtitleFontSize?: string;
|
37
|
+
calendarHeaderActionWidth?: string;
|
38
|
+
calendarHeaderActionColor?: string;
|
39
|
+
calendarHeaderActionDisabledColor?: string;
|
36
40
|
calendarWeekdaysHeight?: string;
|
37
41
|
calendarWeekdaysFontSize?: string;
|
38
42
|
calendarMonthTitleFontSize?: string;
|
package/lib/calendar/utils.d.ts
CHANGED
@@ -6,7 +6,13 @@ export declare function compareDay(day1: Date, day2: Date): 0 | 1 | -1;
|
|
6
6
|
export declare const cloneDate: (date: Date) => Date;
|
7
7
|
export declare const cloneDates: (dates: Date | Date[]) => Date | Date[];
|
8
8
|
export declare function getDayByOffset(date: Date, offset: number): Date;
|
9
|
+
export declare function getMonthByOffset(date: Date, offset: number): Date;
|
10
|
+
export declare function getYearByOffset(date: Date, offset: number): Date;
|
9
11
|
export declare const getPrevDay: (date: Date) => Date;
|
10
12
|
export declare const getNextDay: (date: Date) => Date;
|
13
|
+
export declare const getPrevMonth: (date: Date) => Date;
|
14
|
+
export declare const getNextMonth: (date: Date) => Date;
|
15
|
+
export declare const getPrevYear: (date: Date) => Date;
|
16
|
+
export declare const getNextYear: (date: Date) => Date;
|
11
17
|
export declare const getToday: () => Date;
|
12
18
|
export declare function calcDateNum(date: [Date, Date]): number;
|
package/lib/calendar/utils.js
CHANGED
@@ -25,9 +25,15 @@ __export(stdin_exports, {
|
|
25
25
|
compareMonth: () => compareMonth,
|
26
26
|
formatMonthTitle: () => formatMonthTitle,
|
27
27
|
getDayByOffset: () => getDayByOffset,
|
28
|
+
getMonthByOffset: () => getMonthByOffset,
|
28
29
|
getNextDay: () => getNextDay,
|
30
|
+
getNextMonth: () => getNextMonth,
|
31
|
+
getNextYear: () => getNextYear,
|
29
32
|
getPrevDay: () => getPrevDay,
|
33
|
+
getPrevMonth: () => getPrevMonth,
|
34
|
+
getPrevYear: () => getPrevYear,
|
30
35
|
getToday: () => getToday,
|
36
|
+
getYearByOffset: () => getYearByOffset,
|
31
37
|
name: () => name,
|
32
38
|
t: () => t
|
33
39
|
});
|
@@ -61,8 +67,22 @@ function getDayByOffset(date, offset) {
|
|
61
67
|
cloned.setDate(cloned.getDate() + offset);
|
62
68
|
return cloned;
|
63
69
|
}
|
70
|
+
function getMonthByOffset(date, offset) {
|
71
|
+
const cloned = cloneDate(date);
|
72
|
+
cloned.setMonth(cloned.getMonth() + offset);
|
73
|
+
return cloned;
|
74
|
+
}
|
75
|
+
function getYearByOffset(date, offset) {
|
76
|
+
const cloned = cloneDate(date);
|
77
|
+
cloned.setFullYear(cloned.getFullYear() + offset);
|
78
|
+
return cloned;
|
79
|
+
}
|
64
80
|
const getPrevDay = (date) => getDayByOffset(date, -1);
|
65
81
|
const getNextDay = (date) => getDayByOffset(date, 1);
|
82
|
+
const getPrevMonth = (date) => getMonthByOffset(date, -1);
|
83
|
+
const getNextMonth = (date) => getMonthByOffset(date, 1);
|
84
|
+
const getPrevYear = (date) => getYearByOffset(date, -1);
|
85
|
+
const getNextYear = (date) => getYearByOffset(date, 1);
|
66
86
|
const getToday = () => {
|
67
87
|
const today = /* @__PURE__ */ new Date();
|
68
88
|
today.setHours(0, 0, 0, 0);
|