@mantine-vue/schedule 2.1.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 +21 -0
- package/cjs/index.cjs +4198 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/index.mjs +4106 -0
- package/esm/index.mjs.map +1 -0
- package/lib/component-props.d.ts +265 -0
- package/lib/components/CurrentTimeIndicator/CurrentTimeIndicator.d.ts +114 -0
- package/lib/components/CurrentTimeIndicator/index.d.ts +1 -0
- package/lib/components/DayView/DayView.d.ts +212 -0
- package/lib/components/DayView/get-day-view-events/get-day-positioned-events.d.ts +15 -0
- package/lib/components/DayView/get-day-view-events/get-day-view-events.d.ts +15 -0
- package/lib/components/DayView/index.d.ts +3 -0
- package/lib/components/DragContext/DragContext.d.ts +11 -0
- package/lib/components/DragContext/index.d.ts +1 -0
- package/lib/components/MobileMonthView/MobileMonthView.d.ts +171 -0
- package/lib/components/MobileMonthView/get-mobile-month-view-events.d.ts +8 -0
- package/lib/components/MobileMonthView/index.d.ts +1 -0
- package/lib/components/MonthView/MonthView.d.ts +174 -0
- package/lib/components/MonthView/get-month-view-events/add-event-to-day-groups.d.ts +14 -0
- package/lib/components/MonthView/get-month-view-events/calculate-event-position-in-week.d.ts +18 -0
- package/lib/components/MonthView/get-month-view-events/find-available-row.d.ts +10 -0
- package/lib/components/MonthView/get-month-view-events/get-month-positioned-events.d.ts +31 -0
- package/lib/components/MonthView/get-month-view-events/get-month-view-events.d.ts +16 -0
- package/lib/components/MonthView/get-month-view-events/get-weeks-in-range.d.ts +13 -0
- package/lib/components/MonthView/get-renderable-month-event-segments.d.ts +16 -0
- package/lib/components/MonthView/index.d.ts +4 -0
- package/lib/components/MoreEvents/MoreEvents.d.ts +65 -0
- package/lib/components/MoreEvents/index.d.ts +1 -0
- package/lib/components/Schedule/Schedule.d.ts +134 -0
- package/lib/components/Schedule/index.d.ts +1 -0
- package/lib/components/ScheduleEvent/ScheduleEvent.d.ts +88 -0
- package/lib/components/ScheduleEvent/index.d.ts +1 -0
- package/lib/components/ScheduleHeader/HeaderControl/index.d.ts +2 -0
- package/lib/components/ScheduleHeader/MonthYearSelect/index.d.ts +2 -0
- package/lib/components/ScheduleHeader/ScheduleHeader.d.ts +364 -0
- package/lib/components/ScheduleHeader/ScheduleHeaderBase.d.ts +72 -0
- package/lib/components/ScheduleHeader/ViewSelect/index.d.ts +2 -0
- package/lib/components/ScheduleHeader/index.d.ts +2 -0
- package/lib/components/WeekView/WeekView.d.ts +294 -0
- package/lib/components/WeekView/get-week-label/get-week-label.d.ts +13 -0
- package/lib/components/WeekView/get-week-view-events/assign-event-rows.d.ts +2 -0
- package/lib/components/WeekView/get-week-view-events/calculate-all-day-event-offset.d.ts +11 -0
- package/lib/components/WeekView/get-week-view-events/calculate-all-day-event-width.d.ts +12 -0
- package/lib/components/WeekView/get-week-view-events/calculate-event-days.d.ts +9 -0
- package/lib/components/WeekView/get-week-view-events/calculate-regular-event-overlaps.d.ts +2 -0
- package/lib/components/WeekView/get-week-view-events/filter-week-view-events.d.ts +14 -0
- package/lib/components/WeekView/get-week-view-events/find-available-column.d.ts +9 -0
- package/lib/components/WeekView/get-week-view-events/get-event-end-date.d.ts +3 -0
- package/lib/components/WeekView/get-week-view-events/get-hanging-status.d.ts +9 -0
- package/lib/components/WeekView/get-week-view-events/get-week-positioned-events.d.ts +26 -0
- package/lib/components/WeekView/get-week-view-events/get-week-view-events.d.ts +7 -0
- package/lib/components/WeekView/index.d.ts +4 -0
- package/lib/components/YearView/YearView.d.ts +151 -0
- package/lib/components/YearView/get-year-view-events/get-year-view-events.d.ts +8 -0
- package/lib/components/YearView/index.d.ts +1 -0
- package/lib/components/keyboard-navigation.d.ts +7 -0
- package/lib/components/shared.d.ts +161 -0
- package/lib/components/use-slot-drag-select.d.ts +28 -0
- package/lib/hooks/use-event-resize.d.ts +31 -0
- package/lib/index.d.mts +15 -0
- package/lib/index.d.ts +15 -0
- package/lib/labels.d.ts +25 -0
- package/lib/test-utils.d.ts +7 -0
- package/lib/types.d.ts +141 -0
- package/lib/utils/calculate-drop-time/calculate-drop-time.d.ts +22 -0
- package/lib/utils/calculate-month-drop-date/calculate-month-drop-date.d.ts +14 -0
- package/lib/utils/clamp-interval-minutes/clamp-interval-minutes.d.ts +2 -0
- package/lib/utils/expand-recurring-events/expand-recurring-events.d.ts +10 -0
- package/lib/utils/format-date/format-date.d.ts +8 -0
- package/lib/utils/get-business-hours-mod/get-business-hours-mod.d.ts +26 -0
- package/lib/utils/get-current-time-position/get-current-time-position.d.ts +10 -0
- package/lib/utils/get-day-position/get-day-position.d.ts +17 -0
- package/lib/utils/get-day-time-intervals/get-day-time-intervals.d.ts +19 -0
- package/lib/utils/get-end-of-week/get-end-of-week.d.ts +3 -0
- package/lib/utils/get-month-days/get-month-days.d.ts +8 -0
- package/lib/utils/get-month-range/get-month-range.d.ts +13 -0
- package/lib/utils/get-months-by-quarter/get-months-by-quarter.d.ts +2 -0
- package/lib/utils/get-months-list/get-months-list.d.ts +11 -0
- package/lib/utils/get-start-of-week/get-start-of-week.d.ts +7 -0
- package/lib/utils/get-visible-events/get-visible-events.d.ts +9 -0
- package/lib/utils/get-week-days/get-week-days.d.ts +13 -0
- package/lib/utils/get-week-number/get-week-number.d.ts +2 -0
- package/lib/utils/get-weekdays-names/get-weekdays-names.d.ts +9 -0
- package/lib/utils/get-years-list/get-years-list.d.ts +6 -0
- package/lib/utils/index.d.ts +41 -0
- package/lib/utils/is-after-min-date/is-after-min-date.d.ts +2 -0
- package/lib/utils/is-all-day-event/is-all-day-event.d.ts +7 -0
- package/lib/utils/is-before-max-date/is-before-max-date.d.ts +2 -0
- package/lib/utils/is-event-in-time-range/is-event-in-time-range.d.ts +8 -0
- package/lib/utils/is-events-overlap/is-events-overlap.d.ts +3 -0
- package/lib/utils/is-in-time-range/is-in-time-range.d.ts +9 -0
- package/lib/utils/is-multiday-event/is-multiday-event.d.ts +2 -0
- package/lib/utils/is-same-month/is-same-month.d.ts +2 -0
- package/lib/utils/is-within-week/is-within-week.d.ts +8 -0
- package/lib/utils/next-week/next-week.d.ts +2 -0
- package/lib/utils/parse-time-string/parse-time-string.d.ts +6 -0
- package/lib/utils/previous-week/previous-week.d.ts +2 -0
- package/lib/utils/sort-events/sort-events.d.ts +3 -0
- package/lib/utils/to-date-string/to-date-string.d.ts +2 -0
- package/lib/utils/to-time-string/to-time-string.d.ts +2 -0
- package/lib/utils/validate-event/validate-event.d.ts +2 -0
- package/package.json +53 -0
- package/styles.css +2087 -0
- package/styles.layer.css +2089 -0
package/cjs/index.cjs
ADDED
|
@@ -0,0 +1,4198 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let dayjs = require("dayjs");
|
|
25
|
+
dayjs = __toESM(dayjs);
|
|
26
|
+
let dayjs_plugin_isoWeek_js = require("dayjs/plugin/isoWeek.js");
|
|
27
|
+
dayjs_plugin_isoWeek_js = __toESM(dayjs_plugin_isoWeek_js);
|
|
28
|
+
let rrule = require("rrule");
|
|
29
|
+
rrule = __toESM(rrule);
|
|
30
|
+
let vue = require("vue");
|
|
31
|
+
let _mantine_vue_core = require("@mantine-vue/core");
|
|
32
|
+
//#region src/labels.ts
|
|
33
|
+
var DEFAULT_SCHEDULE_LABELS = {
|
|
34
|
+
today: "Today",
|
|
35
|
+
next: "Next",
|
|
36
|
+
previous: "Previous",
|
|
37
|
+
more: "More",
|
|
38
|
+
day: "Day",
|
|
39
|
+
week: "Week",
|
|
40
|
+
month: "Month",
|
|
41
|
+
year: "Year",
|
|
42
|
+
allDay: "All day",
|
|
43
|
+
weekday: "Weekday",
|
|
44
|
+
timeSlot: "Time slot",
|
|
45
|
+
selectMonth: "Select month",
|
|
46
|
+
selectYear: "Select year",
|
|
47
|
+
switchToDayView: "Switch to day view",
|
|
48
|
+
switchToWeekView: "Switch to week view",
|
|
49
|
+
switchToMonthView: "Switch to month view",
|
|
50
|
+
switchToYearView: "Switch to year view",
|
|
51
|
+
viewSelectLabel: "Calendar view",
|
|
52
|
+
noEvents: "No events",
|
|
53
|
+
moreLabel: (hiddenEventsCount) => `+${hiddenEventsCount} more`
|
|
54
|
+
};
|
|
55
|
+
function getLabel(key, override) {
|
|
56
|
+
if (override) return {
|
|
57
|
+
...DEFAULT_SCHEDULE_LABELS,
|
|
58
|
+
...override
|
|
59
|
+
}[key];
|
|
60
|
+
return DEFAULT_SCHEDULE_LABELS[key];
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/utils/format-date/format-date.ts
|
|
64
|
+
function formatDate({ locale, date, format }) {
|
|
65
|
+
if (typeof format === "function") return format((0, dayjs.default)(date).format("YYYY-MM-DD HH:mm:ss"));
|
|
66
|
+
return (0, dayjs.default)(date).locale(locale).format(format);
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/utils/get-weekdays-names/get-weekdays-names.ts
|
|
70
|
+
function getWeekdaysNames({ locale, format = "dd", firstDayOfWeek = 1 }) {
|
|
71
|
+
const baseDate = (0, dayjs.default)().day(firstDayOfWeek);
|
|
72
|
+
const labels = [];
|
|
73
|
+
for (let i = 0; i < 7; i += 1) labels.push(formatDate({
|
|
74
|
+
locale,
|
|
75
|
+
date: baseDate.add(i, "days"),
|
|
76
|
+
format
|
|
77
|
+
}));
|
|
78
|
+
return labels;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/utils/get-start-of-week/get-start-of-week.ts
|
|
82
|
+
function getStartOfWeek({ date, firstDayOfWeek = 1 }) {
|
|
83
|
+
let value = (0, dayjs.default)(date);
|
|
84
|
+
while (value.day() !== firstDayOfWeek) value = value.subtract(1, "day");
|
|
85
|
+
return value.format("YYYY-MM-DD");
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/utils/get-end-of-week/get-end-of-week.ts
|
|
89
|
+
function getEndOfWeek(date, firstDayOfWeek = 1) {
|
|
90
|
+
let value = (0, dayjs.default)(date);
|
|
91
|
+
if (!value.isValid()) return value;
|
|
92
|
+
const lastDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1;
|
|
93
|
+
while (value.day() !== lastDayOfWeek) value = value.add(1, "day");
|
|
94
|
+
return value.format("YYYY-MM-DD");
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/utils/get-week-number/get-week-number.ts
|
|
98
|
+
dayjs.default.extend(dayjs_plugin_isoWeek_js.default);
|
|
99
|
+
function getWeekNumber(week) {
|
|
100
|
+
if (Array.isArray(week)) return (0, dayjs.default)(week.find((date) => (0, dayjs.default)(date).day() === 1)).isoWeek();
|
|
101
|
+
return (0, dayjs.default)(week).isoWeek();
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/utils/get-month-days/get-month-days.ts
|
|
105
|
+
function getMonthDays({ month, firstDayOfWeek = 1, consistentWeeks }) {
|
|
106
|
+
const start = (0, dayjs.default)((0, dayjs.default)(month).subtract((0, dayjs.default)(month).date() - 1, "day").format("YYYY-MM-DD"));
|
|
107
|
+
const startOfMonth = start.format("YYYY-MM-DD");
|
|
108
|
+
const endDate = getEndOfWeek(start.add(+start.daysInMonth() - 1, "day").format("YYYY-MM-DD"), firstDayOfWeek);
|
|
109
|
+
const weeks = [];
|
|
110
|
+
let date = (0, dayjs.default)(getStartOfWeek({
|
|
111
|
+
date: startOfMonth,
|
|
112
|
+
firstDayOfWeek
|
|
113
|
+
}));
|
|
114
|
+
while ((0, dayjs.default)(date).isBefore(endDate, "day")) {
|
|
115
|
+
const days = [];
|
|
116
|
+
for (let i = 0; i < 7; i += 1) {
|
|
117
|
+
days.push(date.format("YYYY-MM-DD 00:00:00"));
|
|
118
|
+
date = date.add(1, "day");
|
|
119
|
+
}
|
|
120
|
+
weeks.push(days);
|
|
121
|
+
}
|
|
122
|
+
if (consistentWeeks && weeks.length < 6) {
|
|
123
|
+
const lastWeek = weeks[weeks.length - 1];
|
|
124
|
+
const lastDay = lastWeek[lastWeek.length - 1];
|
|
125
|
+
let nextDay = (0, dayjs.default)(lastDay).add(1, "day");
|
|
126
|
+
while (weeks.length < 6) {
|
|
127
|
+
const days = [];
|
|
128
|
+
for (let i = 0; i < 7; i += 1) {
|
|
129
|
+
days.push(nextDay.format("YYYY-MM-DD 00:00:00"));
|
|
130
|
+
nextDay = nextDay.add(1, "day");
|
|
131
|
+
}
|
|
132
|
+
weeks.push(days);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return weeks;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/utils/is-after-min-date/is-after-min-date.ts
|
|
139
|
+
function isAfterMinDate(date, minDate) {
|
|
140
|
+
return minDate ? (0, dayjs.default)(date).isAfter((0, dayjs.default)(minDate).subtract(1, "day"), "day") : true;
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/utils/is-before-max-date/is-before-max-date.ts
|
|
144
|
+
function isBeforeMaxDate(date, maxDate) {
|
|
145
|
+
return maxDate ? (0, dayjs.default)(date).isBefore((0, dayjs.default)(maxDate).add(1, "day"), "day") : true;
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/utils/is-same-month/is-same-month.ts
|
|
149
|
+
function isSameMonth(date, comparison) {
|
|
150
|
+
return (0, dayjs.default)(date).format("YYYY-MM") === (0, dayjs.default)(comparison).format("YYYY-MM");
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/utils/get-months-by-quarter/get-months-by-quarter.ts
|
|
154
|
+
function getMonthsByQuarter(year) {
|
|
155
|
+
const startOfYear = (0, dayjs.default)(year).startOf("year").toDate();
|
|
156
|
+
const results = [
|
|
157
|
+
[],
|
|
158
|
+
[],
|
|
159
|
+
[],
|
|
160
|
+
[]
|
|
161
|
+
];
|
|
162
|
+
let currentMonthIndex = 0;
|
|
163
|
+
for (let i = 0; i < 4; i += 1) for (let j = 0; j < 3; j += 1) {
|
|
164
|
+
results[i].push((0, dayjs.default)(startOfYear).add(currentMonthIndex, "months").format("YYYY-MM-DD"));
|
|
165
|
+
currentMonthIndex += 1;
|
|
166
|
+
}
|
|
167
|
+
return results;
|
|
168
|
+
}
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/utils/clamp-interval-minutes/clamp-interval-minutes.ts
|
|
171
|
+
/** Clamp interval minutes to valid values (1-60) and ensure it divides evenly into 60 */
|
|
172
|
+
function clampIntervalMinutes(intervalMinutes) {
|
|
173
|
+
let clamped = Math.round(Math.max(1, Math.min(60, intervalMinutes)));
|
|
174
|
+
clamped = 60 % clamped === 0 ? clamped : 60;
|
|
175
|
+
return clamped;
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/utils/parse-time-string/parse-time-string.ts
|
|
179
|
+
function parseTimeString(time) {
|
|
180
|
+
const [hours, minutes, seconds] = time.split(":").map(Number);
|
|
181
|
+
return {
|
|
182
|
+
hours,
|
|
183
|
+
minutes,
|
|
184
|
+
seconds: seconds || 0
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/utils/to-time-string/to-time-string.ts
|
|
189
|
+
function toTimeString({ hours, minutes, seconds }) {
|
|
190
|
+
return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/utils/get-day-time-intervals/get-day-time-intervals.ts
|
|
194
|
+
function getDayTimeIntervals({ startTime, endTime, intervalMinutes: _intervalMinutes = 60 }) {
|
|
195
|
+
const intervalMinutes = clampIntervalMinutes(_intervalMinutes);
|
|
196
|
+
const start = parseTimeString(startTime);
|
|
197
|
+
const end = endTime ? parseTimeString(endTime) : {
|
|
198
|
+
hours: 23,
|
|
199
|
+
minutes: 59,
|
|
200
|
+
seconds: 59
|
|
201
|
+
};
|
|
202
|
+
const startSeconds = start.hours * 3600 + start.minutes * 60 + start.seconds;
|
|
203
|
+
const endSeconds = end.hours * 3600 + end.minutes * 60 + end.seconds;
|
|
204
|
+
const intervalSeconds = intervalMinutes * 60;
|
|
205
|
+
const intervals = [];
|
|
206
|
+
let currentSeconds = startSeconds;
|
|
207
|
+
while (currentSeconds < endSeconds) {
|
|
208
|
+
const intervalStartSeconds = currentSeconds;
|
|
209
|
+
let intervalEndSeconds = currentSeconds + intervalSeconds;
|
|
210
|
+
if (intervalEndSeconds > endSeconds) intervalEndSeconds = endSeconds;
|
|
211
|
+
const startHours = Math.floor(intervalStartSeconds / 3600);
|
|
212
|
+
const startMinutes = Math.floor(intervalStartSeconds % 3600 / 60);
|
|
213
|
+
const startSecs = intervalStartSeconds % 60;
|
|
214
|
+
const endHours = Math.floor(intervalEndSeconds / 3600);
|
|
215
|
+
const endMinutes = Math.floor(intervalEndSeconds % 3600 / 60);
|
|
216
|
+
const endSecs = intervalEndSeconds % 60;
|
|
217
|
+
const durationSeconds = intervalEndSeconds - intervalStartSeconds;
|
|
218
|
+
const isHourStart = startMinutes === 0 && startSecs === 0;
|
|
219
|
+
intervals.push({
|
|
220
|
+
startTime: toTimeString({
|
|
221
|
+
hours: startHours,
|
|
222
|
+
minutes: startMinutes,
|
|
223
|
+
seconds: startSecs
|
|
224
|
+
}),
|
|
225
|
+
endTime: toTimeString({
|
|
226
|
+
hours: endHours,
|
|
227
|
+
minutes: endMinutes,
|
|
228
|
+
seconds: endSecs
|
|
229
|
+
}),
|
|
230
|
+
duration: durationSeconds,
|
|
231
|
+
isHourStart
|
|
232
|
+
});
|
|
233
|
+
currentSeconds = intervalEndSeconds;
|
|
234
|
+
}
|
|
235
|
+
return intervals;
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
//#region src/utils/to-date-string/to-date-string.ts
|
|
239
|
+
function toDateString(date) {
|
|
240
|
+
return (0, dayjs.default)(date).format("YYYY-MM-DD 00:00:00");
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/utils/get-week-days/get-week-days.ts
|
|
244
|
+
/** Returns a list of days in a given week */
|
|
245
|
+
function getWeekDays({ week, weekendDays, withWeekendDays = true, firstDayOfWeek = 1 }) {
|
|
246
|
+
const days = [];
|
|
247
|
+
let current = (0, dayjs.default)(getStartOfWeek({
|
|
248
|
+
date: week,
|
|
249
|
+
firstDayOfWeek
|
|
250
|
+
}));
|
|
251
|
+
for (let i = 0; i < 7; i += 1) {
|
|
252
|
+
const dayOfWeek = current.day();
|
|
253
|
+
if (!(weekendDays && weekendDays.includes(dayOfWeek)) || withWeekendDays) days.push(toDateString(current));
|
|
254
|
+
current = current.add(1, "day");
|
|
255
|
+
}
|
|
256
|
+
return days;
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/utils/get-months-list/get-months-list.ts
|
|
260
|
+
function getMonthsList({ locale, format }) {
|
|
261
|
+
const months = [];
|
|
262
|
+
const date = (0, dayjs.default)().locale(locale).startOf("year");
|
|
263
|
+
for (let i = 0; i < 12; i++) months.push({
|
|
264
|
+
month: i,
|
|
265
|
+
name: formatDate({
|
|
266
|
+
date: date.add(i, "month"),
|
|
267
|
+
format,
|
|
268
|
+
locale
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
return months;
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/utils/get-years-list/get-years-list.ts
|
|
275
|
+
function getYearsList({ startYear, endYear }) {
|
|
276
|
+
const years = [];
|
|
277
|
+
for (let year = startYear; year <= endYear; year++) years.push(year);
|
|
278
|
+
return years;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/utils/next-week/next-week.ts
|
|
282
|
+
function nextWeek(date, firstDayOfWeek) {
|
|
283
|
+
const start = getStartOfWeek({
|
|
284
|
+
date,
|
|
285
|
+
firstDayOfWeek
|
|
286
|
+
});
|
|
287
|
+
return toDateString((0, dayjs.default)(start).set("date", (0, dayjs.default)(start).date() + 7));
|
|
288
|
+
}
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/utils/previous-week/previous-week.ts
|
|
291
|
+
function previousWeek(date, firstDayOfWeek) {
|
|
292
|
+
const start = getStartOfWeek({
|
|
293
|
+
date,
|
|
294
|
+
firstDayOfWeek
|
|
295
|
+
});
|
|
296
|
+
return toDateString((0, dayjs.default)(start).set("date", (0, dayjs.default)(start).date() - 7));
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/utils/get-current-time-position/get-current-time-position.ts
|
|
300
|
+
function getCurrentTimePosition(input) {
|
|
301
|
+
const now = (0, dayjs.default)(input?.now);
|
|
302
|
+
if (!input?.startTime || !input?.endTime) {
|
|
303
|
+
const startOf = now.startOf("date");
|
|
304
|
+
return now.diff(startOf, "minute") / 1440 * 100;
|
|
305
|
+
}
|
|
306
|
+
const [startHour, startMinute, startSecond = 0] = input.startTime.split(":").map(Number);
|
|
307
|
+
const [endHour, endMinute, endSecond = 0] = input.endTime.split(":").map(Number);
|
|
308
|
+
const startOfDay = now.startOf("date");
|
|
309
|
+
const startDateTime = startOfDay.hour(startHour).minute(startMinute).second(startSecond);
|
|
310
|
+
const literalSeconds = startOfDay.hour(endHour).minute(endMinute).second(endSecond).diff(startDateTime, "second");
|
|
311
|
+
const intervalSeconds = input.intervalMinutes !== void 0 ? clampIntervalMinutes(input.intervalMinutes) * 60 : void 0;
|
|
312
|
+
const totalSeconds = intervalSeconds ? Math.ceil(literalSeconds / intervalSeconds) * intervalSeconds : literalSeconds;
|
|
313
|
+
return now.diff(startDateTime, "second") / totalSeconds * 100;
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/utils/is-in-time-range/is-in-time-range.ts
|
|
317
|
+
/** Returns true if the given date's time is within the specified time range */
|
|
318
|
+
function isInTimeRange({ date, startTime = "00:00:00", endTime = "23:59:59" }) {
|
|
319
|
+
const targetDate = (0, dayjs.default)(date);
|
|
320
|
+
const parsedStartTime = parseTimeString(startTime);
|
|
321
|
+
const parsedEndTime = parseTimeString(endTime);
|
|
322
|
+
const startDateTime = targetDate.hour(parsedStartTime.hours).minute(parsedStartTime.minutes).second(parsedStartTime.seconds);
|
|
323
|
+
const endDateTime = targetDate.hour(parsedEndTime.hours).minute(parsedEndTime.minutes).second(parsedEndTime.seconds);
|
|
324
|
+
return targetDate.isAfter(startDateTime) && targetDate.isBefore(endDateTime);
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/utils/is-all-day-event/is-all-day-event.ts
|
|
328
|
+
function isAllDayEvent({ event, date }) {
|
|
329
|
+
const dayStart = (0, dayjs.default)(date).startOf("day");
|
|
330
|
+
const nextDayStart = dayStart.add(1, "day");
|
|
331
|
+
const sameDayEnd = nextDayStart.subtract(1, "second");
|
|
332
|
+
const startTime = (0, dayjs.default)(event.start);
|
|
333
|
+
const endTime = (0, dayjs.default)(event.end);
|
|
334
|
+
return startTime.isSame(dayStart) && (endTime.isSame(nextDayStart) || endTime.isSame(sameDayEnd));
|
|
335
|
+
}
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/utils/validate-event/validate-event.ts
|
|
338
|
+
function validateEvent(eventData) {
|
|
339
|
+
if (!(0, dayjs.default)(eventData.start).isValid()) throw new Error(`[@mantine/schedule] Invalid start date for event id: ${eventData.id}`);
|
|
340
|
+
if (!(0, dayjs.default)(eventData.end).isValid()) throw new Error(`[@mantine/schedule] Invalid end date for event id: ${eventData.id}`);
|
|
341
|
+
if ((0, dayjs.default)(eventData.end).isBefore((0, dayjs.default)(eventData.start))) throw new Error(`[@mantine/schedule] Event end date is before start date for event id: ${eventData.id}`);
|
|
342
|
+
return eventData;
|
|
343
|
+
}
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/utils/sort-events/sort-events.ts
|
|
346
|
+
/** Sorts events by start time, then by duration (longer first) */
|
|
347
|
+
function sortEvents(events) {
|
|
348
|
+
return [...events].sort((a, b) => {
|
|
349
|
+
const startDiff = (0, dayjs.default)(a.start).diff((0, dayjs.default)(b.start));
|
|
350
|
+
if (startDiff !== 0) return startDiff;
|
|
351
|
+
return (0, dayjs.default)(b.end).diff((0, dayjs.default)(b.start)) - (0, dayjs.default)(a.end).diff((0, dayjs.default)(a.start));
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/utils/is-events-overlap/is-events-overlap.ts
|
|
356
|
+
/** Returns true if two events overlap in time */
|
|
357
|
+
function isEventsOverlap(event1, event2) {
|
|
358
|
+
const start1 = (0, dayjs.default)(event1.start).valueOf();
|
|
359
|
+
const end1 = (0, dayjs.default)(event1.end).valueOf();
|
|
360
|
+
const start2 = (0, dayjs.default)(event2.start).valueOf();
|
|
361
|
+
return start1 < (0, dayjs.default)(event2.end).valueOf() && start2 < end1;
|
|
362
|
+
}
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/utils/get-visible-events/get-visible-events.ts
|
|
365
|
+
function getVisibleEvents({ maxEvents, totalEvents }) {
|
|
366
|
+
if (totalEvents <= maxEvents) return {
|
|
367
|
+
visibleEventsCount: totalEvents,
|
|
368
|
+
hiddenEventsCount: 0
|
|
369
|
+
};
|
|
370
|
+
return {
|
|
371
|
+
visibleEventsCount: maxEvents - 1,
|
|
372
|
+
hiddenEventsCount: totalEvents - (maxEvents - 1)
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/utils/is-multiday-event/is-multiday-event.ts
|
|
377
|
+
function isMultidayEvent(event) {
|
|
378
|
+
const startDate = (0, dayjs.default)(event.start).startOf("day");
|
|
379
|
+
const rawEnd = (0, dayjs.default)(event.end);
|
|
380
|
+
return (rawEnd.hour() === 0 && rawEnd.minute() === 0 && rawEnd.second() === 0 ? rawEnd.startOf("day").subtract(1, "day") : rawEnd.startOf("day")).isAfter(startDate);
|
|
381
|
+
}
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region src/utils/is-event-in-time-range/is-event-in-time-range.ts
|
|
384
|
+
function spansFullDay(event) {
|
|
385
|
+
const start = (0, dayjs.default)(event.start);
|
|
386
|
+
const end = (0, dayjs.default)(event.end);
|
|
387
|
+
if (!start.isSame(start.startOf("day"))) return false;
|
|
388
|
+
const nextDayStart = start.startOf("day").add(1, "day");
|
|
389
|
+
return end.isSame(nextDayStart) || end.isSame(nextDayStart.subtract(1, "second"));
|
|
390
|
+
}
|
|
391
|
+
function isEventInTimeRange({ event, startTime, endTime }) {
|
|
392
|
+
if (isMultidayEvent(event) || spansFullDay(event)) return true;
|
|
393
|
+
if (!startTime || !endTime) return true;
|
|
394
|
+
const [startHour, startMinute] = startTime.split(":").map(Number);
|
|
395
|
+
const [endHour, endMinute] = endTime.split(":").map(Number);
|
|
396
|
+
const timeWindowStartMinutes = startHour * 60 + startMinute;
|
|
397
|
+
const timeWindowEndMinutes = endHour * 60 + endMinute;
|
|
398
|
+
const eventStart = (0, dayjs.default)(event.start);
|
|
399
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
400
|
+
const eventStartMinutes = eventStart.hour() * 60 + eventStart.minute();
|
|
401
|
+
return !(eventEnd.hour() * 60 + eventEnd.minute() <= timeWindowStartMinutes || eventStartMinutes >= timeWindowEndMinutes);
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/utils/is-within-week/is-within-week.ts
|
|
405
|
+
function isWithinWeek({ event, targetWeek, firstDayOfWeek }) {
|
|
406
|
+
const startOfWeek = (0, dayjs.default)(getStartOfWeek({
|
|
407
|
+
date: targetWeek,
|
|
408
|
+
firstDayOfWeek
|
|
409
|
+
}));
|
|
410
|
+
const endOfWeek = startOfWeek.add(7, "day");
|
|
411
|
+
return (0, dayjs.default)(event.start).isBefore(endOfWeek) && (0, dayjs.default)(event.end).isAfter(startOfWeek);
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/utils/get-month-range/get-month-range.ts
|
|
415
|
+
/** Returns start and end dates as displayed in MonthView */
|
|
416
|
+
function getMonthRange({ month, withOutsideDays, consistentWeeks, firstDayOfWeek }) {
|
|
417
|
+
if (!withOutsideDays) return {
|
|
418
|
+
start: toDateString((0, dayjs.default)(month).startOf("month")),
|
|
419
|
+
end: toDateString((0, dayjs.default)(month).endOf("month"))
|
|
420
|
+
};
|
|
421
|
+
const days = getMonthDays({
|
|
422
|
+
month,
|
|
423
|
+
firstDayOfWeek,
|
|
424
|
+
consistentWeeks
|
|
425
|
+
});
|
|
426
|
+
return {
|
|
427
|
+
start: days[0][0],
|
|
428
|
+
end: days[days.length - 1][6]
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/utils/get-day-position/get-day-position.ts
|
|
433
|
+
/** Calculates day position within given start and end time boundaries. Returns top and height in percentages. */
|
|
434
|
+
function getDayPosition({ event, startTime = "00:00:00", endTime = "23:59:59", intervalMinutes = 60 }) {
|
|
435
|
+
const eventStart = (0, dayjs.default)(event.start);
|
|
436
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
437
|
+
const parsedStartTime = parseTimeString(startTime);
|
|
438
|
+
const parsedEndTime = parseTimeString(endTime);
|
|
439
|
+
const startOfDay = eventStart.startOf("date");
|
|
440
|
+
const boundaryStart = startOfDay.hour(parsedStartTime.hours).minute(parsedStartTime.minutes).second(parsedStartTime.seconds);
|
|
441
|
+
const literalEnd = startOfDay.hour(parsedEndTime.hours).minute(parsedEndTime.minutes).second(parsedEndTime.seconds);
|
|
442
|
+
const intervalSeconds = clampIntervalMinutes(intervalMinutes) * 60;
|
|
443
|
+
const literalRangeSeconds = literalEnd.diff(boundaryStart, "second");
|
|
444
|
+
const totalSeconds = Math.ceil(literalRangeSeconds / intervalSeconds) * intervalSeconds;
|
|
445
|
+
const eventStartSeconds = (eventStart.isBefore(boundaryStart) ? boundaryStart : eventStart).diff(boundaryStart, "second");
|
|
446
|
+
const eventEndSeconds = (eventEnd.isAfter(literalEnd) ? literalEnd : eventEnd).diff(boundaryStart, "second");
|
|
447
|
+
const startPercent = eventStartSeconds / totalSeconds * 100;
|
|
448
|
+
return {
|
|
449
|
+
top: startPercent,
|
|
450
|
+
height: eventEndSeconds / totalSeconds * 100 - startPercent
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/utils/calculate-drop-time/calculate-drop-time.ts
|
|
455
|
+
function calculateDropTime({ draggedEvent, targetDate, targetSlotTime, mouseYOffset = 0, slotHeight = 64, intervalMinutes = 15 }) {
|
|
456
|
+
const eventDuration = (0, dayjs.default)(draggedEvent.end).diff((0, dayjs.default)(draggedEvent.start), "millisecond");
|
|
457
|
+
const parsedTime = parseTimeString(targetSlotTime);
|
|
458
|
+
const baseTargetTime = (0, dayjs.default)(targetDate).startOf("day").hour(parsedTime.hours).minute(parsedTime.minutes).second(0);
|
|
459
|
+
let finalTargetTime = baseTargetTime;
|
|
460
|
+
if (mouseYOffset > 0 && slotHeight > 0) {
|
|
461
|
+
const offsetRatio = mouseYOffset / slotHeight;
|
|
462
|
+
const offsetMinutes = Math.round(offsetRatio * intervalMinutes);
|
|
463
|
+
finalTargetTime = baseTargetTime.add(offsetMinutes, "minute");
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
start: finalTargetTime.toDate(),
|
|
467
|
+
end: finalTargetTime.add(eventDuration, "millisecond").toDate()
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/utils/calculate-month-drop-date/calculate-month-drop-date.ts
|
|
472
|
+
function calculateMonthDropDate({ draggedEvent, targetDay }) {
|
|
473
|
+
const eventDuration = (0, dayjs.default)(draggedEvent.end).diff((0, dayjs.default)(draggedEvent.start), "millisecond");
|
|
474
|
+
const originalStartTime = (0, dayjs.default)(draggedEvent.start);
|
|
475
|
+
const newStart = (0, dayjs.default)(targetDay).startOf("day").hour(originalStartTime.hour()).minute(originalStartTime.minute()).second(originalStartTime.second()).millisecond(originalStartTime.millisecond());
|
|
476
|
+
const newEnd = newStart.add(eventDuration, "millisecond");
|
|
477
|
+
return {
|
|
478
|
+
start: newStart.toDate(),
|
|
479
|
+
end: newEnd.toDate()
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
483
|
+
//#region src/utils/get-business-hours-mod/get-business-hours-mod.ts
|
|
484
|
+
function isBusinessHoursRange(value) {
|
|
485
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "string";
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Determines if a given time is within business hours and returns modifier object
|
|
489
|
+
* @param time - Time string in HH:mm:ss format
|
|
490
|
+
* @param businessHours - Tuple of [start, end] times in HH:mm:ss format, or per-day record keyed by day of the week
|
|
491
|
+
* @param highlightBusinessHours - Whether to highlight business hours
|
|
492
|
+
* @param dayOfWeek - Day of the week (0 – Sunday, 6 – Saturday), used to resolve per-day business hours
|
|
493
|
+
* @returns Modifier object for styling business/non-business hours
|
|
494
|
+
*/
|
|
495
|
+
function getBusinessHoursMod({ time, businessHours, highlightBusinessHours, dayOfWeek }) {
|
|
496
|
+
if (!highlightBusinessHours || !businessHours) return {
|
|
497
|
+
"business-hours": false,
|
|
498
|
+
"non-business-hours": false
|
|
499
|
+
};
|
|
500
|
+
let range;
|
|
501
|
+
if (isBusinessHoursRange(businessHours)) range = businessHours;
|
|
502
|
+
else {
|
|
503
|
+
if (dayOfWeek === void 0) return {
|
|
504
|
+
"business-hours": false,
|
|
505
|
+
"non-business-hours": false
|
|
506
|
+
};
|
|
507
|
+
range = businessHours[dayOfWeek] ?? null;
|
|
508
|
+
}
|
|
509
|
+
if (!range) return {
|
|
510
|
+
"business-hours": false,
|
|
511
|
+
"non-business-hours": true
|
|
512
|
+
};
|
|
513
|
+
const [start, end] = range;
|
|
514
|
+
const isInBusinessHours = time >= start && time < end;
|
|
515
|
+
return {
|
|
516
|
+
"business-hours": isInBusinessHours,
|
|
517
|
+
"non-business-hours": !isInBusinessHours
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/utils/expand-recurring-events/expand-recurring-events.ts
|
|
522
|
+
function resolveRRule(ns) {
|
|
523
|
+
return (ns.default ?? ns).RRule;
|
|
524
|
+
}
|
|
525
|
+
var RRule = resolveRRule(rrule);
|
|
526
|
+
function getRecurrenceKey(recurringEventId, recurrenceId) {
|
|
527
|
+
return `${recurringEventId}::${recurrenceId}`;
|
|
528
|
+
}
|
|
529
|
+
function overlapsRange(eventStart, eventEnd, rangeStart, rangeEnd) {
|
|
530
|
+
return (eventEnd.isAfter(rangeStart) || eventEnd.isSame(rangeStart)) && (eventStart.isBefore(rangeEnd) || eventStart.isSame(rangeEnd));
|
|
531
|
+
}
|
|
532
|
+
function getExdateSet(recurrence) {
|
|
533
|
+
if (!recurrence?.exdate) return /* @__PURE__ */ new Set();
|
|
534
|
+
const values = recurrence.exdate.map((value) => (0, dayjs.default)(value)).filter((value) => value.isValid()).map((value) => value.format("YYYY-MM-DD HH:mm:ss"));
|
|
535
|
+
return new Set(values);
|
|
536
|
+
}
|
|
537
|
+
function getRRuleString(rule) {
|
|
538
|
+
const normalized = rule.trim();
|
|
539
|
+
if (!normalized.includes("\n")) return normalized.startsWith("RRULE:") ? normalized.replace(/^RRULE:/, "") : normalized;
|
|
540
|
+
const rruleLine = normalized.split("\n").map((line) => line.trim()).find((line) => line.startsWith("RRULE:"));
|
|
541
|
+
return rruleLine ? rruleLine.replace(/^RRULE:/, "") : normalized;
|
|
542
|
+
}
|
|
543
|
+
function getOccurrenceStartsInRange(event, rangeStart, rangeEnd, expansionLimit, durationMs) {
|
|
544
|
+
const dtstart = (0, dayjs.default)(event.recurrence?.dtstart || event.start);
|
|
545
|
+
if (!dtstart.isValid() || !event.recurrence) return [];
|
|
546
|
+
try {
|
|
547
|
+
const options = RRule.parseString(getRRuleString(event.recurrence.rrule));
|
|
548
|
+
options.dtstart = dtstart.toDate();
|
|
549
|
+
const rule = new RRule(options);
|
|
550
|
+
const searchStart = rangeStart.subtract(Math.max(0, durationMs), "millisecond").toDate();
|
|
551
|
+
return rule.between(searchStart, rangeEnd.toDate(), true).slice(0, expansionLimit).map((value) => (0, dayjs.default)(value));
|
|
552
|
+
} catch {
|
|
553
|
+
return [];
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function isEventInRange(event, rangeStart, rangeEnd) {
|
|
557
|
+
const start = (0, dayjs.default)(event.start);
|
|
558
|
+
const end = (0, dayjs.default)(event.end);
|
|
559
|
+
if (!start.isValid() || !end.isValid()) return false;
|
|
560
|
+
return overlapsRange(start, end, rangeStart, rangeEnd);
|
|
561
|
+
}
|
|
562
|
+
function createGeneratedInstance(event, occurrenceStart, durationMs) {
|
|
563
|
+
const occurrenceEnd = occurrenceStart.add(durationMs, "millisecond");
|
|
564
|
+
const recurrenceId = occurrenceStart.format("YYYY-MM-DD HH:mm:ss");
|
|
565
|
+
const { recurrence: _recurrence, ...eventWithoutRecurrence } = event;
|
|
566
|
+
return {
|
|
567
|
+
...eventWithoutRecurrence,
|
|
568
|
+
id: `${event.id}::${recurrenceId}`,
|
|
569
|
+
start: occurrenceStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
570
|
+
end: occurrenceEnd.format("YYYY-MM-DD HH:mm:ss"),
|
|
571
|
+
recurringEventId: event.id,
|
|
572
|
+
recurrenceId,
|
|
573
|
+
recurringInstance: {
|
|
574
|
+
isRecurringInstance: true,
|
|
575
|
+
recurringEventId: event.id,
|
|
576
|
+
recurrenceId,
|
|
577
|
+
originalStart: occurrenceStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
578
|
+
originalEnd: occurrenceEnd.format("YYYY-MM-DD HH:mm:ss")
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
var DEFAULT_EXPANSION_LIMIT = 2e3;
|
|
583
|
+
function expandRecurringEvents({ events, rangeStart, rangeEnd, expansionLimit = DEFAULT_EXPANSION_LIMIT }) {
|
|
584
|
+
if (!events || events.length === 0) return [];
|
|
585
|
+
const start = (0, dayjs.default)(rangeStart);
|
|
586
|
+
const end = (0, dayjs.default)(rangeEnd);
|
|
587
|
+
if (!start.isValid() || !end.isValid()) return [];
|
|
588
|
+
const regularEvents = [];
|
|
589
|
+
const recurringEvents = [];
|
|
590
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
591
|
+
for (const event of events) {
|
|
592
|
+
if (event.recurringEventId && event.recurrenceId) {
|
|
593
|
+
overrides.set(getRecurrenceKey(event.recurringEventId, event.recurrenceId), event);
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
if (event.recurrence?.rrule) {
|
|
597
|
+
recurringEvents.push(event);
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
regularEvents.push(event);
|
|
601
|
+
}
|
|
602
|
+
const output = [];
|
|
603
|
+
const consumedOverrideIds = /* @__PURE__ */ new Set();
|
|
604
|
+
for (const event of regularEvents) if (isEventInRange(event, start, end)) output.push(validateEvent(event));
|
|
605
|
+
for (const event of recurringEvents) {
|
|
606
|
+
const eventStart = (0, dayjs.default)(event.recurrence?.dtstart || event.start);
|
|
607
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
608
|
+
if (!eventStart.isValid() || !eventEnd.isValid()) continue;
|
|
609
|
+
const durationMs = eventEnd.diff((0, dayjs.default)(event.start), "millisecond");
|
|
610
|
+
if (durationMs < 0) continue;
|
|
611
|
+
const exdate = getExdateSet(event.recurrence);
|
|
612
|
+
const starts = getOccurrenceStartsInRange(event, start, end, expansionLimit, durationMs);
|
|
613
|
+
for (const occurrenceStart of starts) {
|
|
614
|
+
const recurrenceId = occurrenceStart.format("YYYY-MM-DD HH:mm:ss");
|
|
615
|
+
if (exdate.has(recurrenceId)) continue;
|
|
616
|
+
const overrideKey = getRecurrenceKey(event.id, recurrenceId);
|
|
617
|
+
const override = overrides.get(overrideKey);
|
|
618
|
+
if (override) {
|
|
619
|
+
if (isEventInRange(override, start, end)) {
|
|
620
|
+
output.push(validateEvent(override));
|
|
621
|
+
consumedOverrideIds.add(override.id);
|
|
622
|
+
}
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
const generated = createGeneratedInstance(event, occurrenceStart, durationMs);
|
|
626
|
+
if (overlapsRange((0, dayjs.default)(generated.start), (0, dayjs.default)(generated.end), start, end)) output.push(validateEvent(generated));
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
for (const override of overrides.values()) {
|
|
630
|
+
if (consumedOverrideIds.has(override.id)) continue;
|
|
631
|
+
if (isEventInRange(override, start, end)) output.push(validateEvent(override));
|
|
632
|
+
}
|
|
633
|
+
return output;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/hooks/use-event-resize.ts
|
|
637
|
+
function useEventResize(input) {
|
|
638
|
+
const resizeState = (0, vue.ref)(null);
|
|
639
|
+
let justResized = false;
|
|
640
|
+
let savedUserSelect = null;
|
|
641
|
+
const clampAndSnap = (minutes, state) => {
|
|
642
|
+
const snapped = Math.round(minutes / state.intervalMinutes) * state.intervalMinutes;
|
|
643
|
+
return Math.max(0, Math.min(state.literalRange, snapped));
|
|
644
|
+
};
|
|
645
|
+
const snapPercent = (percent, state) => {
|
|
646
|
+
return clampAndSnap(percent / 100 * state.totalMinutes, state) / state.totalMinutes * 100;
|
|
647
|
+
};
|
|
648
|
+
const percentToDateTime = (percent, eventDate, state) => {
|
|
649
|
+
const minutes = percent / 100 * state.totalMinutes;
|
|
650
|
+
const totalMinutes = state.startMinutes + clampAndSnap(minutes, state);
|
|
651
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
652
|
+
const mins = totalMinutes % 60;
|
|
653
|
+
return `${eventDate} ${String(hours).padStart(2, "0")}:${String(mins).padStart(2, "0")}:00`;
|
|
654
|
+
};
|
|
655
|
+
const handlePointerMove = (event) => {
|
|
656
|
+
const state = resizeState.value;
|
|
657
|
+
if (!state) return;
|
|
658
|
+
const containerRect = state.container.getBoundingClientRect();
|
|
659
|
+
if (containerRect.height === 0) return;
|
|
660
|
+
const relativeY = event.clientY - containerRect.top;
|
|
661
|
+
const snappedPercent = snapPercent(Math.max(0, Math.min(100, relativeY / containerRect.height * 100)), state);
|
|
662
|
+
let currentTop = state.originalTop;
|
|
663
|
+
let currentHeight = state.originalHeight;
|
|
664
|
+
if (state.edge === "bottom") currentHeight = Math.max(state.minHeightPercent, snappedPercent - state.originalTop);
|
|
665
|
+
else {
|
|
666
|
+
const originalBottom = state.originalTop + state.originalHeight;
|
|
667
|
+
currentTop = Math.min(snappedPercent, originalBottom - state.minHeightPercent);
|
|
668
|
+
currentHeight = originalBottom - currentTop;
|
|
669
|
+
}
|
|
670
|
+
resizeState.value = {
|
|
671
|
+
...state,
|
|
672
|
+
currentTop,
|
|
673
|
+
currentHeight
|
|
674
|
+
};
|
|
675
|
+
};
|
|
676
|
+
const removeDocumentListeners = () => {
|
|
677
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
678
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
679
|
+
if (savedUserSelect !== null) {
|
|
680
|
+
document.body.style.userSelect = savedUserSelect;
|
|
681
|
+
savedUserSelect = null;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
const handlePointerUp = () => {
|
|
685
|
+
const state = resizeState.value;
|
|
686
|
+
if (state && (state.currentTop !== state.originalTop || state.currentHeight !== state.originalHeight)) {
|
|
687
|
+
const newStart = state.edge === "top" ? percentToDateTime(state.currentTop, state.eventDate, state) : state.originalStart;
|
|
688
|
+
const newEnd = state.edge === "bottom" ? percentToDateTime(state.currentTop + state.currentHeight, state.eventDate, state) : state.originalEnd;
|
|
689
|
+
input.onEventResize()?.({
|
|
690
|
+
eventId: state.eventId,
|
|
691
|
+
newStart,
|
|
692
|
+
newEnd,
|
|
693
|
+
event: state.event
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
resizeState.value = null;
|
|
697
|
+
removeDocumentListeners();
|
|
698
|
+
justResized = true;
|
|
699
|
+
requestAnimationFrame(() => {
|
|
700
|
+
justResized = false;
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
const handleResizeStart = ({ event, edge, container, originalTop, originalHeight, eventDate, pointerEvent }) => {
|
|
704
|
+
if (!input.enabled() || input.mode() === "static") return;
|
|
705
|
+
pointerEvent.preventDefault();
|
|
706
|
+
pointerEvent.stopPropagation();
|
|
707
|
+
const parsedStartTime = parseTimeString(input.startTime());
|
|
708
|
+
const parsedEndTime = parseTimeString(input.endTime());
|
|
709
|
+
const startMinutes = parsedStartTime.hours * 60 + parsedStartTime.minutes;
|
|
710
|
+
const endMinutes = parsedEndTime.hours * 60 + parsedEndTime.minutes;
|
|
711
|
+
const intervalMinutes = clampIntervalMinutes(input.intervalMinutes());
|
|
712
|
+
const literalRange = endMinutes - startMinutes;
|
|
713
|
+
const totalMinutes = Math.ceil(literalRange / intervalMinutes) * intervalMinutes;
|
|
714
|
+
resizeState.value = {
|
|
715
|
+
eventId: event.id,
|
|
716
|
+
event,
|
|
717
|
+
edge,
|
|
718
|
+
container,
|
|
719
|
+
originalTop,
|
|
720
|
+
originalHeight,
|
|
721
|
+
currentTop: originalTop,
|
|
722
|
+
currentHeight: originalHeight,
|
|
723
|
+
eventDate,
|
|
724
|
+
originalStart: (0, dayjs.default)(event.start).format("YYYY-MM-DD HH:mm:ss"),
|
|
725
|
+
originalEnd: (0, dayjs.default)(event.end).format("YYYY-MM-DD HH:mm:ss"),
|
|
726
|
+
startMinutes,
|
|
727
|
+
literalRange,
|
|
728
|
+
totalMinutes,
|
|
729
|
+
intervalMinutes,
|
|
730
|
+
minHeightPercent: intervalMinutes / totalMinutes * 100
|
|
731
|
+
};
|
|
732
|
+
savedUserSelect = document.body.style.userSelect;
|
|
733
|
+
document.body.style.userSelect = "none";
|
|
734
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
735
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
736
|
+
};
|
|
737
|
+
const getResizePosition = (eventId) => {
|
|
738
|
+
const state = resizeState.value;
|
|
739
|
+
return state?.eventId === eventId ? {
|
|
740
|
+
top: state.currentTop,
|
|
741
|
+
height: state.currentHeight
|
|
742
|
+
} : null;
|
|
743
|
+
};
|
|
744
|
+
const isResizableEvent = (event) => input.enabled() && input.mode() !== "static" && event.display !== "background" && (input.canResizeEvent()?.(event) ?? true);
|
|
745
|
+
(0, vue.onBeforeUnmount)(removeDocumentListeners);
|
|
746
|
+
return {
|
|
747
|
+
handleResizeStart,
|
|
748
|
+
getResizePosition,
|
|
749
|
+
isResizableEvent,
|
|
750
|
+
wasResizing: () => justResized
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
var CurrentTimeIndicator_module_default = {
|
|
754
|
+
currentTimeIndicator: "_currentTimeIndicator_v2g54_1",
|
|
755
|
+
currentTimeIndicatorLine: "_currentTimeIndicatorLine_v2g54_23",
|
|
756
|
+
currentTimeIndicatorThumb: "_currentTimeIndicatorThumb_v2g54_32",
|
|
757
|
+
currentTimeIndicatorTimeBubble: "_currentTimeIndicatorTimeBubble_v2g54_43"
|
|
758
|
+
};
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/components/CurrentTimeIndicator/CurrentTimeIndicator.ts
|
|
761
|
+
var CurrentTimeIndicator = (0, vue.defineComponent)({
|
|
762
|
+
name: "CurrentTimeIndicator",
|
|
763
|
+
inheritAttrs: false,
|
|
764
|
+
props: {
|
|
765
|
+
color: {
|
|
766
|
+
type: String,
|
|
767
|
+
default: "red"
|
|
768
|
+
},
|
|
769
|
+
startOffset: {
|
|
770
|
+
type: String,
|
|
771
|
+
default: "0px"
|
|
772
|
+
},
|
|
773
|
+
endOffset: {
|
|
774
|
+
type: String,
|
|
775
|
+
default: "0px"
|
|
776
|
+
},
|
|
777
|
+
topOffset: {
|
|
778
|
+
type: String,
|
|
779
|
+
default: "0px"
|
|
780
|
+
},
|
|
781
|
+
timeBubbleStartOffset: {
|
|
782
|
+
type: String,
|
|
783
|
+
default: "0px"
|
|
784
|
+
},
|
|
785
|
+
withTimeBubble: {
|
|
786
|
+
type: Boolean,
|
|
787
|
+
default: true
|
|
788
|
+
},
|
|
789
|
+
withThumb: {
|
|
790
|
+
type: Boolean,
|
|
791
|
+
default: true
|
|
792
|
+
},
|
|
793
|
+
currentTimeFormat: {
|
|
794
|
+
type: [String, Function],
|
|
795
|
+
default: "HH:mm"
|
|
796
|
+
},
|
|
797
|
+
locale: String,
|
|
798
|
+
startTime: {
|
|
799
|
+
type: String,
|
|
800
|
+
default: "00:00:00"
|
|
801
|
+
},
|
|
802
|
+
endTime: {
|
|
803
|
+
type: String,
|
|
804
|
+
default: "23:59:59"
|
|
805
|
+
},
|
|
806
|
+
intervalMinutes: {
|
|
807
|
+
type: Number,
|
|
808
|
+
default: 60
|
|
809
|
+
},
|
|
810
|
+
getCurrentTime: Function
|
|
811
|
+
},
|
|
812
|
+
setup(props, { attrs }) {
|
|
813
|
+
const theme = (0, _mantine_vue_core.useSafeMantineTheme)();
|
|
814
|
+
const tick = (0, vue.ref)(0);
|
|
815
|
+
let timer;
|
|
816
|
+
(0, vue.onMounted)(() => {
|
|
817
|
+
timer = setInterval(() => tick.value++, 3e4);
|
|
818
|
+
});
|
|
819
|
+
(0, vue.onBeforeUnmount)(() => clearInterval(timer));
|
|
820
|
+
return () => {
|
|
821
|
+
tick.value;
|
|
822
|
+
const now = props.getCurrentTime?.() || (0, dayjs.default)();
|
|
823
|
+
if (!isInTimeRange({
|
|
824
|
+
date: now,
|
|
825
|
+
startTime: props.startTime,
|
|
826
|
+
endTime: props.endTime
|
|
827
|
+
})) return null;
|
|
828
|
+
const top = getCurrentTimePosition({
|
|
829
|
+
now,
|
|
830
|
+
startTime: props.startTime,
|
|
831
|
+
endTime: props.endTime,
|
|
832
|
+
intervalMinutes: props.intervalMinutes
|
|
833
|
+
});
|
|
834
|
+
const color = (0, _mantine_vue_core.getThemeColor)(props.color, theme.value);
|
|
835
|
+
const formattedTime = props.withTimeBubble ? formatDate({
|
|
836
|
+
date: now,
|
|
837
|
+
locale: props.locale || "en",
|
|
838
|
+
format: props.currentTimeFormat
|
|
839
|
+
}) : "";
|
|
840
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
841
|
+
...attrs,
|
|
842
|
+
class: [CurrentTimeIndicator_module_default.currentTimeIndicator, attrs.class],
|
|
843
|
+
style: [{
|
|
844
|
+
"--indicator-color": color,
|
|
845
|
+
"--start-offset": props.startOffset,
|
|
846
|
+
"--end-offset": props.endOffset,
|
|
847
|
+
"--top-offset": `calc(${top}% + ${props.topOffset})`,
|
|
848
|
+
"--time-bubble-start-offset": props.timeBubbleStartOffset,
|
|
849
|
+
"--time-bubble-width": formattedTime.toString().toLowerCase().includes("m") ? "64px" : "46px"
|
|
850
|
+
}, attrs.style]
|
|
851
|
+
}, () => [
|
|
852
|
+
props.withTimeBubble ? (0, vue.h)("div", { class: CurrentTimeIndicator_module_default.currentTimeIndicatorTimeBubble }, formattedTime) : null,
|
|
853
|
+
props.withThumb ? (0, vue.h)("div", { class: CurrentTimeIndicator_module_default.currentTimeIndicatorThumb }) : null,
|
|
854
|
+
(0, vue.h)("div", { class: CurrentTimeIndicator_module_default.currentTimeIndicatorLine })
|
|
855
|
+
]);
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
var ScheduleEvent_module_default = {
|
|
860
|
+
event: "_event_bnqc2_1",
|
|
861
|
+
eventInner: "_eventInner_bnqc2_14",
|
|
862
|
+
eventResizeHandle: "_eventResizeHandle_bnqc2_177"
|
|
863
|
+
};
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/components/ScheduleEvent/ScheduleEvent.ts
|
|
866
|
+
function resolveRadius$1(radius) {
|
|
867
|
+
if (radius == null) return void 0;
|
|
868
|
+
if (typeof radius === "number") return `${radius}px`;
|
|
869
|
+
return [
|
|
870
|
+
"xs",
|
|
871
|
+
"sm",
|
|
872
|
+
"md",
|
|
873
|
+
"lg",
|
|
874
|
+
"xl"
|
|
875
|
+
].includes(radius) ? `var(--mantine-radius-${radius})` : radius;
|
|
876
|
+
}
|
|
877
|
+
var ScheduleEvent = (0, vue.defineComponent)({
|
|
878
|
+
name: "ScheduleEvent",
|
|
879
|
+
inheritAttrs: false,
|
|
880
|
+
slots: Object,
|
|
881
|
+
props: {
|
|
882
|
+
event: {
|
|
883
|
+
type: Object,
|
|
884
|
+
required: true
|
|
885
|
+
},
|
|
886
|
+
radius: {
|
|
887
|
+
type: [String, Number],
|
|
888
|
+
default: "sm"
|
|
889
|
+
},
|
|
890
|
+
nowrap: Boolean,
|
|
891
|
+
autoSize: Boolean,
|
|
892
|
+
size: {
|
|
893
|
+
type: String,
|
|
894
|
+
default: "sm"
|
|
895
|
+
},
|
|
896
|
+
renderEventBody: Function,
|
|
897
|
+
renderEvent: Function,
|
|
898
|
+
hanging: String,
|
|
899
|
+
draggable: Boolean,
|
|
900
|
+
onEventDragStart: Function,
|
|
901
|
+
onEventDragEnd: Function,
|
|
902
|
+
isDragging: Boolean,
|
|
903
|
+
mode: {
|
|
904
|
+
type: String,
|
|
905
|
+
default: "default"
|
|
906
|
+
},
|
|
907
|
+
withResize: Boolean,
|
|
908
|
+
onResizeStart: Function,
|
|
909
|
+
isResizing: Boolean
|
|
910
|
+
},
|
|
911
|
+
setup(props, { attrs, slots }) {
|
|
912
|
+
const theme = (0, _mantine_vue_core.useSafeMantineTheme)();
|
|
913
|
+
const isNativeDragging = (0, vue.ref)(false);
|
|
914
|
+
return () => {
|
|
915
|
+
const colors = theme.value.variantColorResolver({
|
|
916
|
+
color: props.event.color || theme.value.primaryColor,
|
|
917
|
+
theme: theme.value,
|
|
918
|
+
variant: props.event.variant || "light",
|
|
919
|
+
autoContrast: true
|
|
920
|
+
});
|
|
921
|
+
const body = props.renderEventBody?.(props.event) || slots.eventBody?.({ event: props.event }) || slots.default?.() || props.event.title;
|
|
922
|
+
const showResizeHandles = props.withResize && props.mode !== "static";
|
|
923
|
+
const rootProps = {
|
|
924
|
+
...attrs,
|
|
925
|
+
class: [ScheduleEvent_module_default.event, attrs.class],
|
|
926
|
+
style: [{
|
|
927
|
+
"--event-color": colors.color,
|
|
928
|
+
"--event-bg": colors.background,
|
|
929
|
+
"--event-hover": colors.hover,
|
|
930
|
+
"--event-radius": resolveRadius$1(props.radius)
|
|
931
|
+
}, attrs.style],
|
|
932
|
+
"data-event-id": props.event.id,
|
|
933
|
+
title: props.event.title,
|
|
934
|
+
size: props.size,
|
|
935
|
+
mod: {
|
|
936
|
+
autoSize: props.autoSize,
|
|
937
|
+
hanging: props.hanging,
|
|
938
|
+
draggable: props.draggable,
|
|
939
|
+
dragging: props.isDragging || isNativeDragging.value,
|
|
940
|
+
static: props.mode === "static",
|
|
941
|
+
resizing: props.isResizing,
|
|
942
|
+
resizable: showResizeHandles
|
|
943
|
+
},
|
|
944
|
+
draggable: props.draggable && props.mode !== "static",
|
|
945
|
+
tabindex: props.mode === "static" ? -1 : 0,
|
|
946
|
+
onDragstart: (event) => {
|
|
947
|
+
if (!props.draggable || props.mode === "static") {
|
|
948
|
+
event.preventDefault();
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
if (event.dataTransfer) {
|
|
952
|
+
event.dataTransfer.effectAllowed = "move";
|
|
953
|
+
event.dataTransfer.setData("application/json", JSON.stringify({ eventId: props.event.id }));
|
|
954
|
+
}
|
|
955
|
+
isNativeDragging.value = true;
|
|
956
|
+
props.onEventDragStart?.(props.event);
|
|
957
|
+
},
|
|
958
|
+
onDragend: props.mode === "static" ? void 0 : () => {
|
|
959
|
+
isNativeDragging.value = false;
|
|
960
|
+
props.onEventDragEnd?.();
|
|
961
|
+
},
|
|
962
|
+
onClick: props.mode === "static" ? void 0 : attrs.onClick
|
|
963
|
+
};
|
|
964
|
+
const children = [
|
|
965
|
+
showResizeHandles ? (0, vue.h)(_mantine_vue_core.Box, {
|
|
966
|
+
class: ScheduleEvent_module_default.eventResizeHandle,
|
|
967
|
+
mod: { edge: "top" },
|
|
968
|
+
onPointerdown: (event) => props.onResizeStart?.("top", event)
|
|
969
|
+
}) : null,
|
|
970
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
971
|
+
class: ScheduleEvent_module_default.eventInner,
|
|
972
|
+
mod: {
|
|
973
|
+
nowrap: props.nowrap,
|
|
974
|
+
size: props.size,
|
|
975
|
+
autoSize: props.autoSize,
|
|
976
|
+
hanging: props.hanging
|
|
977
|
+
}
|
|
978
|
+
}, () => body),
|
|
979
|
+
showResizeHandles ? (0, vue.h)(_mantine_vue_core.Box, {
|
|
980
|
+
class: ScheduleEvent_module_default.eventResizeHandle,
|
|
981
|
+
mod: { edge: "bottom" },
|
|
982
|
+
onPointerdown: (event) => props.onResizeStart?.("bottom", event)
|
|
983
|
+
}) : null
|
|
984
|
+
];
|
|
985
|
+
const renderProps = {
|
|
986
|
+
...rootProps,
|
|
987
|
+
children
|
|
988
|
+
};
|
|
989
|
+
return props.renderEvent?.(props.event, renderProps) || slots.event?.({
|
|
990
|
+
...renderProps,
|
|
991
|
+
event: props.event
|
|
992
|
+
}) || (0, vue.h)(_mantine_vue_core.UnstyledButton, rootProps, () => children);
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
//#endregion
|
|
997
|
+
//#region src/components/shared.ts
|
|
998
|
+
var baseViewProps = {
|
|
999
|
+
date: {
|
|
1000
|
+
type: [String, Date],
|
|
1001
|
+
required: true
|
|
1002
|
+
},
|
|
1003
|
+
onDateChange: Function,
|
|
1004
|
+
events: Array,
|
|
1005
|
+
locale: String,
|
|
1006
|
+
radius: [String, Number],
|
|
1007
|
+
labels: Object,
|
|
1008
|
+
mode: {
|
|
1009
|
+
type: String,
|
|
1010
|
+
default: "default"
|
|
1011
|
+
},
|
|
1012
|
+
withHeader: {
|
|
1013
|
+
type: Boolean,
|
|
1014
|
+
default: true
|
|
1015
|
+
},
|
|
1016
|
+
onViewChange: Function,
|
|
1017
|
+
previousControlProps: Object,
|
|
1018
|
+
nextControlProps: Object,
|
|
1019
|
+
todayControlProps: Object,
|
|
1020
|
+
viewSelectProps: Object,
|
|
1021
|
+
renderEventBody: Function,
|
|
1022
|
+
renderEvent: Function,
|
|
1023
|
+
onEventClick: Function,
|
|
1024
|
+
recurrenceExpansionLimit: {
|
|
1025
|
+
type: Number,
|
|
1026
|
+
default: 2e3
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
var timeViewProps = {
|
|
1030
|
+
...baseViewProps,
|
|
1031
|
+
startTime: {
|
|
1032
|
+
type: String,
|
|
1033
|
+
default: "00:00:00"
|
|
1034
|
+
},
|
|
1035
|
+
endTime: {
|
|
1036
|
+
type: String,
|
|
1037
|
+
default: "23:59:59"
|
|
1038
|
+
},
|
|
1039
|
+
intervalMinutes: {
|
|
1040
|
+
type: Number,
|
|
1041
|
+
default: 60
|
|
1042
|
+
},
|
|
1043
|
+
slotLabelFormat: {
|
|
1044
|
+
type: [String, Function],
|
|
1045
|
+
default: "HH:mm"
|
|
1046
|
+
},
|
|
1047
|
+
withCurrentTimeIndicator: {
|
|
1048
|
+
type: Boolean,
|
|
1049
|
+
default: void 0
|
|
1050
|
+
},
|
|
1051
|
+
withCurrentTimeBubble: {
|
|
1052
|
+
type: Boolean,
|
|
1053
|
+
default: true
|
|
1054
|
+
},
|
|
1055
|
+
getCurrentTime: Function,
|
|
1056
|
+
slotHeight: {
|
|
1057
|
+
type: [String, Number],
|
|
1058
|
+
default: 64
|
|
1059
|
+
},
|
|
1060
|
+
highlightBusinessHours: Boolean,
|
|
1061
|
+
businessHours: [Array, Object],
|
|
1062
|
+
withEventsDragAndDrop: Boolean,
|
|
1063
|
+
onEventDrop: Function,
|
|
1064
|
+
canDragEvent: Function,
|
|
1065
|
+
onEventDragStart: Function,
|
|
1066
|
+
onEventDragEnd: Function,
|
|
1067
|
+
onTimeSlotClick: Function,
|
|
1068
|
+
onAllDaySlotClick: Function,
|
|
1069
|
+
withDragSlotSelect: Boolean,
|
|
1070
|
+
onSlotDragEnd: Function,
|
|
1071
|
+
startScrollTime: String,
|
|
1072
|
+
onExternalEventDrop: Function,
|
|
1073
|
+
withEventResize: Boolean,
|
|
1074
|
+
onEventResize: Function,
|
|
1075
|
+
canResizeEvent: Function
|
|
1076
|
+
};
|
|
1077
|
+
function resolveScheduleRadius(radius) {
|
|
1078
|
+
if (radius === void 0) return void 0;
|
|
1079
|
+
if (typeof radius === "number") return `${radius}px`;
|
|
1080
|
+
return [
|
|
1081
|
+
"xs",
|
|
1082
|
+
"sm",
|
|
1083
|
+
"md",
|
|
1084
|
+
"lg",
|
|
1085
|
+
"xl"
|
|
1086
|
+
].includes(radius) ? `var(--mantine-radius-${radius})` : radius;
|
|
1087
|
+
}
|
|
1088
|
+
function getExpandedEvents(events, rangeStart, rangeEnd, expansionLimit) {
|
|
1089
|
+
return expandRecurringEvents({
|
|
1090
|
+
events,
|
|
1091
|
+
rangeStart,
|
|
1092
|
+
rangeEnd,
|
|
1093
|
+
expansionLimit
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Build the slots object forwarded to a child component, omitting undefined entries.
|
|
1098
|
+
* Returns a `Record<string, unknown>` (possibly empty) so it satisfies Vue's `RawSlots`
|
|
1099
|
+
* type when passed as the third argument to `h()`.
|
|
1100
|
+
*/
|
|
1101
|
+
function forwardEventSlots(slots) {
|
|
1102
|
+
const forwarded = {};
|
|
1103
|
+
if (slots?.eventBody) forwarded.eventBody = slots.eventBody;
|
|
1104
|
+
if (slots?.event) forwarded.event = slots.event;
|
|
1105
|
+
return forwarded;
|
|
1106
|
+
}
|
|
1107
|
+
function eventNode(event, props, extra = {}, slots) {
|
|
1108
|
+
const draggable = props.mode !== "static" && props.withEventsDragAndDrop === true && (props.canDragEvent?.(event) ?? true);
|
|
1109
|
+
return (0, vue.h)(ScheduleEvent, {
|
|
1110
|
+
event,
|
|
1111
|
+
mode: props.mode ?? "default",
|
|
1112
|
+
renderEvent: props.renderEvent,
|
|
1113
|
+
renderEventBody: props.renderEventBody,
|
|
1114
|
+
draggable,
|
|
1115
|
+
onEventDragStart: props.onEventDragStart,
|
|
1116
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
1117
|
+
onClick: (nativeEvent) => props.onEventClick?.(event, nativeEvent),
|
|
1118
|
+
...extra
|
|
1119
|
+
}, forwardEventSlots(slots));
|
|
1120
|
+
}
|
|
1121
|
+
function getDropEvent(events, transfer) {
|
|
1122
|
+
const raw = transfer?.getData("application/json");
|
|
1123
|
+
if (!raw) return void 0;
|
|
1124
|
+
try {
|
|
1125
|
+
const data = JSON.parse(raw);
|
|
1126
|
+
if (typeof data !== "object" || data === null || !("eventId" in data)) return void 0;
|
|
1127
|
+
const eventId = data.eventId;
|
|
1128
|
+
if (typeof eventId !== "string" && typeof eventId !== "number") return void 0;
|
|
1129
|
+
return events?.find((event) => String(event.id) === String(eventId));
|
|
1130
|
+
} catch {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
function getTimeSlotDropTarget({ nativeEvent, container, intervals, date }) {
|
|
1135
|
+
const targetSlot = (nativeEvent.target instanceof Element ? nativeEvent.target : null)?.closest("[data-time-slot-index]");
|
|
1136
|
+
let slotIndex = targetSlot && container.contains(targetSlot) ? Number(targetSlot.dataset.timeSlotIndex) : NaN;
|
|
1137
|
+
if (!Number.isInteger(slotIndex)) {
|
|
1138
|
+
const slots = container.querySelectorAll("[data-time-slot-index]");
|
|
1139
|
+
slotIndex = Array.from(slots).findIndex((slot) => {
|
|
1140
|
+
const rect = slot.getBoundingClientRect();
|
|
1141
|
+
return nativeEvent.clientY >= rect.top && nativeEvent.clientY <= rect.bottom;
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
const interval = intervals[slotIndex];
|
|
1145
|
+
return interval ? {
|
|
1146
|
+
slotIndex,
|
|
1147
|
+
target: `${date} ${interval.startTime}`
|
|
1148
|
+
} : void 0;
|
|
1149
|
+
}
|
|
1150
|
+
function moveEventTo(event, newStart) {
|
|
1151
|
+
const start = (0, dayjs.default)(event.start);
|
|
1152
|
+
const duration = (0, dayjs.default)(event.end).diff(start, "second");
|
|
1153
|
+
const nextStart = (0, dayjs.default)(newStart);
|
|
1154
|
+
return {
|
|
1155
|
+
eventId: event.id,
|
|
1156
|
+
newStart: nextStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
1157
|
+
newEnd: nextStart.add(duration, "second").format("YYYY-MM-DD HH:mm:ss"),
|
|
1158
|
+
event
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
function moveEventToAllDay(event, date) {
|
|
1162
|
+
const dayStart = (0, dayjs.default)(date).startOf("day");
|
|
1163
|
+
const spanDays = Math.max(1, (0, dayjs.default)(event.end).startOf("day").diff((0, dayjs.default)(event.start).startOf("day"), "day"));
|
|
1164
|
+
return {
|
|
1165
|
+
eventId: event.id,
|
|
1166
|
+
newStart: dayStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
1167
|
+
newEnd: dayStart.add(spanDays, "day").format("YYYY-MM-DD HH:mm:ss"),
|
|
1168
|
+
event
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
var MoreEvents_module_default = {
|
|
1172
|
+
moreEventsButton: "_moreEventsButton_1irmu_1",
|
|
1173
|
+
moreEventsDropdown: "_moreEventsDropdown_1irmu_22",
|
|
1174
|
+
moreEventsList: "_moreEventsList_1irmu_26"
|
|
1175
|
+
};
|
|
1176
|
+
//#endregion
|
|
1177
|
+
//#region src/components/MoreEvents/MoreEvents.ts
|
|
1178
|
+
var MoreEvents = (0, vue.defineComponent)({
|
|
1179
|
+
name: "MoreEvents",
|
|
1180
|
+
inheritAttrs: false,
|
|
1181
|
+
slots: Object,
|
|
1182
|
+
props: {
|
|
1183
|
+
events: {
|
|
1184
|
+
type: Array,
|
|
1185
|
+
required: true
|
|
1186
|
+
},
|
|
1187
|
+
moreEventsCount: {
|
|
1188
|
+
type: Number,
|
|
1189
|
+
required: true
|
|
1190
|
+
},
|
|
1191
|
+
radius: [String, Number],
|
|
1192
|
+
modalTitle: String,
|
|
1193
|
+
dropdownType: {
|
|
1194
|
+
type: String,
|
|
1195
|
+
default: "popover"
|
|
1196
|
+
},
|
|
1197
|
+
popoverProps: Object,
|
|
1198
|
+
modalProps: Object,
|
|
1199
|
+
onDropdownClose: Function,
|
|
1200
|
+
renderEventBody: Function,
|
|
1201
|
+
renderEvent: Function,
|
|
1202
|
+
labels: Object,
|
|
1203
|
+
mode: {
|
|
1204
|
+
type: String,
|
|
1205
|
+
default: "default"
|
|
1206
|
+
},
|
|
1207
|
+
onEventClick: Function
|
|
1208
|
+
},
|
|
1209
|
+
setup(props, { attrs, slots }) {
|
|
1210
|
+
const opened = (0, vue.ref)(false);
|
|
1211
|
+
const close = () => {
|
|
1212
|
+
opened.value = false;
|
|
1213
|
+
props.onDropdownClose?.();
|
|
1214
|
+
};
|
|
1215
|
+
return () => {
|
|
1216
|
+
const eventsList = (0, vue.h)(_mantine_vue_core.Box, { class: MoreEvents_module_default.moreEventsList }, () => props.events.map((event) => (0, vue.h)(ScheduleEvent, {
|
|
1217
|
+
key: event.id,
|
|
1218
|
+
event,
|
|
1219
|
+
radius: props.radius ?? "sm",
|
|
1220
|
+
size: "md",
|
|
1221
|
+
mode: props.mode,
|
|
1222
|
+
renderEvent: props.renderEvent,
|
|
1223
|
+
renderEventBody: props.renderEventBody,
|
|
1224
|
+
onClick: (nativeEvent) => props.onEventClick?.(event, nativeEvent)
|
|
1225
|
+
}, forwardEventSlots(slots))));
|
|
1226
|
+
return [props.dropdownType === "modal" ? (0, vue.h)(_mantine_vue_core.Modal, {
|
|
1227
|
+
...props.modalProps,
|
|
1228
|
+
opened: opened.value,
|
|
1229
|
+
onClose: close,
|
|
1230
|
+
radius: props.radius,
|
|
1231
|
+
title: props.modalTitle
|
|
1232
|
+
}, () => eventsList) : null, (0, vue.h)(_mantine_vue_core.Popover, {
|
|
1233
|
+
position: "bottom-start",
|
|
1234
|
+
width: 260,
|
|
1235
|
+
opened: opened.value,
|
|
1236
|
+
trapFocus: true,
|
|
1237
|
+
returnFocus: false,
|
|
1238
|
+
disabled: props.dropdownType === "modal",
|
|
1239
|
+
radius: props.radius,
|
|
1240
|
+
transitionProps: {
|
|
1241
|
+
transition: "pop",
|
|
1242
|
+
duration: 120
|
|
1243
|
+
},
|
|
1244
|
+
offset: -46,
|
|
1245
|
+
...props.popoverProps,
|
|
1246
|
+
onChange: (value) => {
|
|
1247
|
+
if (!value) close();
|
|
1248
|
+
}
|
|
1249
|
+
}, () => [(0, vue.h)(_mantine_vue_core.Popover.Target, null, () => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
1250
|
+
...attrs,
|
|
1251
|
+
class: [MoreEvents_module_default.moreEventsButton, attrs.class],
|
|
1252
|
+
mod: { static: props.mode === "static" },
|
|
1253
|
+
"aria-expanded": opened.value,
|
|
1254
|
+
onClick: () => {
|
|
1255
|
+
opened.value = !opened.value;
|
|
1256
|
+
}
|
|
1257
|
+
}, () => getLabel("moreLabel", props.labels)(props.moreEventsCount))), (0, vue.h)(_mantine_vue_core.Popover.Dropdown, { class: MoreEvents_module_default.moreEventsDropdown }, () => eventsList)])];
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
//#endregion
|
|
1262
|
+
//#region src/components/use-slot-drag-select.ts
|
|
1263
|
+
/**
|
|
1264
|
+
* Composable that provides unified slot drag-selection for Day, Week and Month views.
|
|
1265
|
+
* tracks a selected range as the pointer
|
|
1266
|
+
* moves across elements carrying `data-drag-slot-index` / `data-drag-slot-group`.
|
|
1267
|
+
*/
|
|
1268
|
+
function useSlotDragSelect(input) {
|
|
1269
|
+
const selectedRange = (0, vue.ref)(null);
|
|
1270
|
+
let drag = null;
|
|
1271
|
+
let savedUserSelect = "";
|
|
1272
|
+
const handlePointerMove = (event) => {
|
|
1273
|
+
if (!drag) return;
|
|
1274
|
+
const elements = document.elementsFromPoint(event.clientX, event.clientY);
|
|
1275
|
+
for (const el of elements) {
|
|
1276
|
+
const element = el;
|
|
1277
|
+
const indexAttr = element.getAttribute?.("data-drag-slot-index");
|
|
1278
|
+
const groupAttr = element.getAttribute?.("data-drag-slot-group");
|
|
1279
|
+
if (indexAttr != null && groupAttr != null) {
|
|
1280
|
+
if (groupAttr === drag.group) {
|
|
1281
|
+
const newIndex = Number(indexAttr);
|
|
1282
|
+
if (!Number.isNaN(newIndex) && newIndex !== drag.currentIndex) {
|
|
1283
|
+
drag.currentIndex = newIndex;
|
|
1284
|
+
selectedRange.value = {
|
|
1285
|
+
group: groupAttr,
|
|
1286
|
+
start: Math.min(drag.startIndex, newIndex),
|
|
1287
|
+
end: Math.max(drag.startIndex, newIndex)
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
const handlePointerUp = () => {
|
|
1296
|
+
if (drag) {
|
|
1297
|
+
const { startIndex, currentIndex, group } = drag;
|
|
1298
|
+
if (startIndex !== currentIndex) input.onDragEnd?.()?.(Math.min(startIndex, currentIndex), Math.max(startIndex, currentIndex), group);
|
|
1299
|
+
}
|
|
1300
|
+
drag = null;
|
|
1301
|
+
selectedRange.value = null;
|
|
1302
|
+
};
|
|
1303
|
+
const removeListeners = () => {
|
|
1304
|
+
document.body.style.userSelect = savedUserSelect;
|
|
1305
|
+
document.removeEventListener("pointermove", handlePointerMove);
|
|
1306
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
1307
|
+
};
|
|
1308
|
+
(0, vue.watch)(() => selectedRange.value !== null, (isDragging) => {
|
|
1309
|
+
if (isDragging) {
|
|
1310
|
+
savedUserSelect = document.body.style.userSelect;
|
|
1311
|
+
document.body.style.userSelect = "none";
|
|
1312
|
+
document.addEventListener("pointermove", handlePointerMove);
|
|
1313
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
1314
|
+
} else removeListeners();
|
|
1315
|
+
});
|
|
1316
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
1317
|
+
if (selectedRange.value !== null) removeListeners();
|
|
1318
|
+
});
|
|
1319
|
+
const handleSlotPointerDown = (_event, index, group) => {
|
|
1320
|
+
if (!input.enabled()) return;
|
|
1321
|
+
drag = {
|
|
1322
|
+
group,
|
|
1323
|
+
startIndex: index,
|
|
1324
|
+
currentIndex: index
|
|
1325
|
+
};
|
|
1326
|
+
selectedRange.value = {
|
|
1327
|
+
group,
|
|
1328
|
+
start: index,
|
|
1329
|
+
end: index
|
|
1330
|
+
};
|
|
1331
|
+
};
|
|
1332
|
+
const isSlotSelected = (index, group) => {
|
|
1333
|
+
const range = selectedRange.value;
|
|
1334
|
+
if (!range || range.group !== group) return false;
|
|
1335
|
+
return index >= range.start && index <= range.end;
|
|
1336
|
+
};
|
|
1337
|
+
const isDragging = () => selectedRange.value !== null;
|
|
1338
|
+
return {
|
|
1339
|
+
handleSlotPointerDown,
|
|
1340
|
+
isSlotSelected,
|
|
1341
|
+
isDragging
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
var ScheduleHeader_module_default = {
|
|
1345
|
+
header: "_header_1dfmx_1",
|
|
1346
|
+
navigationGroup: "_navigationGroup_1dfmx_11",
|
|
1347
|
+
todayControl: "_todayControl_1dfmx_25",
|
|
1348
|
+
viewSelect: "_viewSelect_1dfmx_31",
|
|
1349
|
+
compactViewSelect: "_compactViewSelect_1dfmx_37"
|
|
1350
|
+
};
|
|
1351
|
+
var HeaderControl_module_default = { headerControl: "_headerControl_6ykw9_1" };
|
|
1352
|
+
var ViewSelect_module_default = { viewSelect: "_viewSelect_1xfvc_1" };
|
|
1353
|
+
var MonthYearSelect_module_default = {
|
|
1354
|
+
monthYearSelectTarget: "_monthYearSelectTarget_2hd16_1",
|
|
1355
|
+
monthYearSelectList: "_monthYearSelectList_2hd16_10",
|
|
1356
|
+
monthYearSelectDropdown: "_monthYearSelectDropdown_2hd16_14",
|
|
1357
|
+
monthYearSelectLabel: "_monthYearSelectLabel_2hd16_24",
|
|
1358
|
+
monthYearSelectControl: "_monthYearSelectControl_2hd16_31"
|
|
1359
|
+
};
|
|
1360
|
+
//#endregion
|
|
1361
|
+
//#region src/components/ScheduleHeader/ScheduleHeader.ts
|
|
1362
|
+
var labelsKey = Symbol("schedule-header-labels");
|
|
1363
|
+
var commonControlProps = {
|
|
1364
|
+
active: Boolean,
|
|
1365
|
+
square: Boolean,
|
|
1366
|
+
radius: [String, Number],
|
|
1367
|
+
interactive: {
|
|
1368
|
+
type: Boolean,
|
|
1369
|
+
default: true
|
|
1370
|
+
},
|
|
1371
|
+
labels: Object
|
|
1372
|
+
};
|
|
1373
|
+
function resolveRadius(radius) {
|
|
1374
|
+
if (radius == null) return void 0;
|
|
1375
|
+
if (typeof radius === "number") return `${radius}px`;
|
|
1376
|
+
return [
|
|
1377
|
+
"xs",
|
|
1378
|
+
"sm",
|
|
1379
|
+
"md",
|
|
1380
|
+
"lg",
|
|
1381
|
+
"xl"
|
|
1382
|
+
].includes(radius) ? `var(--mantine-radius-${radius})` : radius;
|
|
1383
|
+
}
|
|
1384
|
+
var HeaderControl = (0, vue.defineComponent)({
|
|
1385
|
+
name: "HeaderControl",
|
|
1386
|
+
inheritAttrs: false,
|
|
1387
|
+
props: commonControlProps,
|
|
1388
|
+
setup(props, { attrs, slots }) {
|
|
1389
|
+
return () => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
1390
|
+
...attrs,
|
|
1391
|
+
class: [HeaderControl_module_default.headerControl, attrs.class],
|
|
1392
|
+
style: [props.radius == null ? void 0 : { "--control-radius": resolveRadius(props.radius) }, attrs.style],
|
|
1393
|
+
tabindex: props.interactive ? attrs.tabindex : -1,
|
|
1394
|
+
mod: {
|
|
1395
|
+
active: props.active,
|
|
1396
|
+
square: props.square,
|
|
1397
|
+
interactive: props.interactive
|
|
1398
|
+
}
|
|
1399
|
+
}, () => slots.default?.());
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
function directionalControl(name, type) {
|
|
1403
|
+
return (0, vue.defineComponent)({
|
|
1404
|
+
name,
|
|
1405
|
+
inheritAttrs: false,
|
|
1406
|
+
props: commonControlProps,
|
|
1407
|
+
setup(props, { attrs }) {
|
|
1408
|
+
const inherited = (0, vue.inject)(labelsKey, void 0);
|
|
1409
|
+
const { dir } = (0, _mantine_vue_core.useDirection)();
|
|
1410
|
+
return () => (0, vue.h)(HeaderControl, {
|
|
1411
|
+
...attrs,
|
|
1412
|
+
...props,
|
|
1413
|
+
square: true,
|
|
1414
|
+
"data-type": type,
|
|
1415
|
+
"aria-label": getLabel(type, props.labels || inherited)
|
|
1416
|
+
}, () => (0, vue.h)(_mantine_vue_core.AccordionChevron, { style: { transform: `rotate(${type === "next" ? dir.value === "rtl" ? 90 : -90 : dir.value === "rtl" ? -90 : 90}deg)` } }));
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
var ScheduleHeaderNext = directionalControl("ScheduleHeaderNext", "next");
|
|
1421
|
+
var ScheduleHeaderPrevious = directionalControl("ScheduleHeaderPrevious", "previous");
|
|
1422
|
+
var ScheduleHeaderToday = (0, vue.defineComponent)({
|
|
1423
|
+
name: "ScheduleHeaderToday",
|
|
1424
|
+
inheritAttrs: false,
|
|
1425
|
+
props: commonControlProps,
|
|
1426
|
+
setup(props, { attrs }) {
|
|
1427
|
+
const inherited = (0, vue.inject)(labelsKey, void 0);
|
|
1428
|
+
return () => (0, vue.h)(HeaderControl, {
|
|
1429
|
+
...attrs,
|
|
1430
|
+
...props,
|
|
1431
|
+
"data-type": "today",
|
|
1432
|
+
"aria-label": getLabel("today", props.labels || inherited)
|
|
1433
|
+
}, () => getLabel("today", props.labels || inherited));
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
var ViewSelect = (0, vue.defineComponent)({
|
|
1437
|
+
name: "ViewSelect",
|
|
1438
|
+
inheritAttrs: false,
|
|
1439
|
+
props: {
|
|
1440
|
+
views: {
|
|
1441
|
+
type: Array,
|
|
1442
|
+
default: () => [
|
|
1443
|
+
"day",
|
|
1444
|
+
"week",
|
|
1445
|
+
"month",
|
|
1446
|
+
"year"
|
|
1447
|
+
]
|
|
1448
|
+
},
|
|
1449
|
+
value: String,
|
|
1450
|
+
onChange: Function,
|
|
1451
|
+
radius: [String, Number],
|
|
1452
|
+
labels: Object
|
|
1453
|
+
},
|
|
1454
|
+
setup(props, { attrs }) {
|
|
1455
|
+
const inherited = (0, vue.inject)(labelsKey, void 0);
|
|
1456
|
+
const switchLabels = {
|
|
1457
|
+
day: "switchToDayView",
|
|
1458
|
+
week: "switchToWeekView",
|
|
1459
|
+
month: "switchToMonthView",
|
|
1460
|
+
year: "switchToYearView"
|
|
1461
|
+
};
|
|
1462
|
+
const onKeydown = (event, index) => {
|
|
1463
|
+
const controls = event.currentTarget.parentElement?.querySelectorAll("[role=\"tab\"]");
|
|
1464
|
+
if (!controls?.length) return;
|
|
1465
|
+
let next = index;
|
|
1466
|
+
if (event.key === "ArrowRight") next = (index + 1) % controls.length;
|
|
1467
|
+
else if (event.key === "ArrowLeft") next = (index - 1 + controls.length) % controls.length;
|
|
1468
|
+
else if (event.key === "Home") next = 0;
|
|
1469
|
+
else if (event.key === "End") next = controls.length - 1;
|
|
1470
|
+
else return;
|
|
1471
|
+
event.preventDefault();
|
|
1472
|
+
controls[next]?.focus();
|
|
1473
|
+
};
|
|
1474
|
+
return () => {
|
|
1475
|
+
const labels = props.labels || inherited;
|
|
1476
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
1477
|
+
...attrs,
|
|
1478
|
+
class: [ViewSelect_module_default.viewSelect, attrs.class],
|
|
1479
|
+
role: "tablist",
|
|
1480
|
+
"aria-label": getLabel("viewSelectLabel", labels)
|
|
1481
|
+
}, () => props.views.map((view, index) => (0, vue.h)(HeaderControl, {
|
|
1482
|
+
active: view === props.value,
|
|
1483
|
+
radius: props.radius,
|
|
1484
|
+
role: "tab",
|
|
1485
|
+
"data-type": view,
|
|
1486
|
+
"aria-selected": view === props.value,
|
|
1487
|
+
"aria-label": getLabel(switchLabels[view], labels),
|
|
1488
|
+
tabindex: view === props.value ? 0 : -1,
|
|
1489
|
+
onClick: () => props.onChange?.(view),
|
|
1490
|
+
onKeydown: (event) => onKeydown(event, index)
|
|
1491
|
+
}, () => getLabel(view, labels))));
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
var MonthYearSelect = (0, vue.defineComponent)({
|
|
1496
|
+
name: "MonthYearSelect",
|
|
1497
|
+
inheritAttrs: false,
|
|
1498
|
+
props: {
|
|
1499
|
+
locale: String,
|
|
1500
|
+
startYear: Number,
|
|
1501
|
+
endYear: Number,
|
|
1502
|
+
yearValue: Number,
|
|
1503
|
+
monthValue: Number,
|
|
1504
|
+
onYearChange: Function,
|
|
1505
|
+
onMonthChange: Function,
|
|
1506
|
+
monthsListFormat: [String, Function],
|
|
1507
|
+
labelFormat: [String, Function],
|
|
1508
|
+
radius: [String, Number],
|
|
1509
|
+
getYearControlProps: Function,
|
|
1510
|
+
getMonthControlProps: Function,
|
|
1511
|
+
withMonths: {
|
|
1512
|
+
type: Boolean,
|
|
1513
|
+
default: true
|
|
1514
|
+
},
|
|
1515
|
+
labels: Object
|
|
1516
|
+
},
|
|
1517
|
+
setup(props, { attrs }) {
|
|
1518
|
+
const inherited = (0, vue.inject)(labelsKey, void 0);
|
|
1519
|
+
const opened = (0, vue.ref)(false);
|
|
1520
|
+
const today = /* @__PURE__ */ new Date();
|
|
1521
|
+
return () => {
|
|
1522
|
+
const labels = props.labels || inherited;
|
|
1523
|
+
const startYear = props.startYear ?? today.getFullYear() - 5;
|
|
1524
|
+
const endYear = props.endYear ?? today.getFullYear() + 5;
|
|
1525
|
+
const selected = new Date(props.yearValue ?? today.getFullYear(), props.monthValue ?? today.getMonth(), 1);
|
|
1526
|
+
const hasActiveYear = props.yearValue !== void 0 && props.yearValue >= startYear && props.yearValue <= endYear;
|
|
1527
|
+
const months = props.withMonths ? getMonthsList({
|
|
1528
|
+
locale: props.locale || "en",
|
|
1529
|
+
format: props.monthsListFormat || "MMMM"
|
|
1530
|
+
}).map((month) => {
|
|
1531
|
+
const extra = props.getMonthControlProps?.(month.month) || {};
|
|
1532
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
1533
|
+
...extra,
|
|
1534
|
+
class: [MonthYearSelect_module_default.monthYearSelectControl, extra.class],
|
|
1535
|
+
mod: {
|
|
1536
|
+
type: "month",
|
|
1537
|
+
active: month.month === props.monthValue
|
|
1538
|
+
},
|
|
1539
|
+
tabindex: month.month === props.monthValue ? 0 : -1,
|
|
1540
|
+
"aria-label": `${getLabel("selectMonth", labels)} ${month.name}`,
|
|
1541
|
+
onKeydown: (0, _mantine_vue_core.createScopedKeydownHandler)({
|
|
1542
|
+
siblingSelector: "[data-type=\"month\"]:not(:disabled)",
|
|
1543
|
+
parentSelector: "[data-list]",
|
|
1544
|
+
activateOnFocus: false,
|
|
1545
|
+
loop: true,
|
|
1546
|
+
orientation: "vertical",
|
|
1547
|
+
onKeydown: extra.onKeydown
|
|
1548
|
+
}),
|
|
1549
|
+
onClick: () => {
|
|
1550
|
+
props.onMonthChange?.(month.month);
|
|
1551
|
+
}
|
|
1552
|
+
}, () => month.name);
|
|
1553
|
+
}) : [];
|
|
1554
|
+
const years = getYearsList({
|
|
1555
|
+
startYear,
|
|
1556
|
+
endYear
|
|
1557
|
+
}).map((year, index) => {
|
|
1558
|
+
const extra = props.getYearControlProps?.(year) || {};
|
|
1559
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
1560
|
+
...extra,
|
|
1561
|
+
class: [MonthYearSelect_module_default.monthYearSelectControl, extra.class],
|
|
1562
|
+
mod: {
|
|
1563
|
+
type: "year",
|
|
1564
|
+
active: year === props.yearValue
|
|
1565
|
+
},
|
|
1566
|
+
tabindex: hasActiveYear ? year === props.yearValue ? 0 : -1 : index === 0 ? 0 : -1,
|
|
1567
|
+
"aria-label": `${getLabel("selectYear", labels)} ${year}`,
|
|
1568
|
+
onKeydown: (0, _mantine_vue_core.createScopedKeydownHandler)({
|
|
1569
|
+
siblingSelector: "[data-type=\"year\"]:not(:disabled)",
|
|
1570
|
+
parentSelector: "[data-list]",
|
|
1571
|
+
activateOnFocus: false,
|
|
1572
|
+
loop: true,
|
|
1573
|
+
orientation: "vertical",
|
|
1574
|
+
onKeydown: extra.onKeydown
|
|
1575
|
+
}),
|
|
1576
|
+
onClick: () => {
|
|
1577
|
+
props.onYearChange?.(year);
|
|
1578
|
+
if (!props.withMonths) opened.value = false;
|
|
1579
|
+
}
|
|
1580
|
+
}, () => String(year));
|
|
1581
|
+
});
|
|
1582
|
+
return (0, vue.h)(_mantine_vue_core.Popover, {
|
|
1583
|
+
position: "bottom-start",
|
|
1584
|
+
trapFocus: true,
|
|
1585
|
+
transitionProps: {
|
|
1586
|
+
transition: "pop",
|
|
1587
|
+
duration: 120
|
|
1588
|
+
},
|
|
1589
|
+
radius: props.radius || "var(--schedule-radius, var(--mantine-radius-default))",
|
|
1590
|
+
shadow: "md",
|
|
1591
|
+
offset: 3,
|
|
1592
|
+
width: props.withMonths ? void 0 : "target",
|
|
1593
|
+
opened: opened.value,
|
|
1594
|
+
onChange: (value) => {
|
|
1595
|
+
opened.value = value;
|
|
1596
|
+
}
|
|
1597
|
+
}, () => [(0, vue.h)(_mantine_vue_core.Popover.Target, null, () => (0, vue.h)(HeaderControl, {
|
|
1598
|
+
...attrs,
|
|
1599
|
+
class: [MonthYearSelect_module_default.monthYearSelectTarget, attrs.class],
|
|
1600
|
+
radius: props.radius,
|
|
1601
|
+
"data-with-months": props.withMonths || void 0,
|
|
1602
|
+
onClick: () => {
|
|
1603
|
+
opened.value = !opened.value;
|
|
1604
|
+
}
|
|
1605
|
+
}, () => formatDate({
|
|
1606
|
+
date: selected,
|
|
1607
|
+
locale: props.locale || "en",
|
|
1608
|
+
format: props.labelFormat || (props.withMonths ? "MMMM YYYY" : "YYYY")
|
|
1609
|
+
}))), (0, vue.h)(_mantine_vue_core.Popover.Dropdown, {
|
|
1610
|
+
class: MonthYearSelect_module_default.monthYearSelectDropdown,
|
|
1611
|
+
"data-with-months": props.withMonths || void 0
|
|
1612
|
+
}, () => [props.withMonths ? (0, vue.h)(_mantine_vue_core.Box, {
|
|
1613
|
+
class: MonthYearSelect_module_default.monthYearSelectList,
|
|
1614
|
+
"data-list": true
|
|
1615
|
+
}, () => [(0, vue.h)(_mantine_vue_core.Box, { class: MonthYearSelect_module_default.monthYearSelectLabel }, () => getLabel("month", labels)), ...months]) : null, (0, vue.h)(_mantine_vue_core.Box, {
|
|
1616
|
+
class: MonthYearSelect_module_default.monthYearSelectList,
|
|
1617
|
+
"data-list": true
|
|
1618
|
+
}, () => [props.withMonths ? (0, vue.h)(_mantine_vue_core.Box, { class: MonthYearSelect_module_default.monthYearSelectLabel }, () => getLabel("year", labels)) : null, ...years])])]);
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
var ScheduleHeaderBaseComponent = (0, vue.defineComponent)({
|
|
1623
|
+
name: "ScheduleHeader",
|
|
1624
|
+
inheritAttrs: false,
|
|
1625
|
+
props: { labels: Object },
|
|
1626
|
+
setup(props, { attrs, slots }) {
|
|
1627
|
+
(0, vue.provide)(labelsKey, props.labels);
|
|
1628
|
+
return () => (0, vue.h)(_mantine_vue_core.Box, {
|
|
1629
|
+
...attrs,
|
|
1630
|
+
class: [ScheduleHeader_module_default.header, attrs.class]
|
|
1631
|
+
}, () => slots.default?.());
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
var ScheduleHeader = Object.assign(ScheduleHeaderBaseComponent, {
|
|
1635
|
+
Control: HeaderControl,
|
|
1636
|
+
Next: ScheduleHeaderNext,
|
|
1637
|
+
Previous: ScheduleHeaderPrevious,
|
|
1638
|
+
Today: ScheduleHeaderToday,
|
|
1639
|
+
ViewSelect,
|
|
1640
|
+
MonthYearSelect
|
|
1641
|
+
});
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region src/components/ScheduleHeader/ScheduleHeaderBase.ts
|
|
1644
|
+
var ScheduleHeaderBase = (0, vue.defineComponent)({
|
|
1645
|
+
name: "ScheduleHeaderBase",
|
|
1646
|
+
props: {
|
|
1647
|
+
view: {
|
|
1648
|
+
type: String,
|
|
1649
|
+
required: true
|
|
1650
|
+
},
|
|
1651
|
+
navigationHandlers: {
|
|
1652
|
+
type: Object,
|
|
1653
|
+
required: true
|
|
1654
|
+
},
|
|
1655
|
+
control: {
|
|
1656
|
+
type: Object,
|
|
1657
|
+
required: true
|
|
1658
|
+
},
|
|
1659
|
+
labels: Object,
|
|
1660
|
+
onDateChange: Function,
|
|
1661
|
+
onViewChange: Function,
|
|
1662
|
+
previousControlProps: Object,
|
|
1663
|
+
nextControlProps: Object,
|
|
1664
|
+
todayControlProps: Object,
|
|
1665
|
+
viewSelectProps: Object
|
|
1666
|
+
},
|
|
1667
|
+
setup(props) {
|
|
1668
|
+
return () => {
|
|
1669
|
+
const views = props.viewSelectProps?.views || [
|
|
1670
|
+
"day",
|
|
1671
|
+
"week",
|
|
1672
|
+
"month",
|
|
1673
|
+
"year"
|
|
1674
|
+
];
|
|
1675
|
+
return (0, vue.h)(ScheduleHeader, { labels: props.labels }, () => [
|
|
1676
|
+
(0, vue.h)(_mantine_vue_core.Box, { class: ScheduleHeader_module_default.navigationGroup }, () => [
|
|
1677
|
+
(0, vue.h)(ScheduleHeader.Previous, {
|
|
1678
|
+
...props.previousControlProps,
|
|
1679
|
+
onClick: () => props.onDateChange?.(props.navigationHandlers.previous())
|
|
1680
|
+
}),
|
|
1681
|
+
props.control.monthYearSelect ? (0, vue.h)(ScheduleHeader.MonthYearSelect, {
|
|
1682
|
+
...props.control.monthYearSelect,
|
|
1683
|
+
labels: props.labels
|
|
1684
|
+
}) : (0, vue.h)(ScheduleHeader.Control, { interactive: false }, () => props.control.title),
|
|
1685
|
+
(0, vue.h)(ScheduleHeader.Next, {
|
|
1686
|
+
...props.nextControlProps,
|
|
1687
|
+
onClick: () => props.onDateChange?.(props.navigationHandlers.next())
|
|
1688
|
+
})
|
|
1689
|
+
]),
|
|
1690
|
+
(0, vue.h)(_mantine_vue_core.Box, { class: ScheduleHeader_module_default.todayControl }, () => [(0, vue.h)(ScheduleHeader.Today, {
|
|
1691
|
+
...props.todayControlProps,
|
|
1692
|
+
onClick: () => props.onDateChange?.(props.navigationHandlers.today())
|
|
1693
|
+
})]),
|
|
1694
|
+
(0, vue.h)(_mantine_vue_core.NativeSelect, {
|
|
1695
|
+
class: ScheduleHeader_module_default.compactViewSelect,
|
|
1696
|
+
value: props.view,
|
|
1697
|
+
size: "sm",
|
|
1698
|
+
data: views.map((view) => ({
|
|
1699
|
+
value: view,
|
|
1700
|
+
label: getLabel(view, props.labels)
|
|
1701
|
+
})),
|
|
1702
|
+
"aria-label": getLabel("viewSelectLabel", props.labels),
|
|
1703
|
+
onChange: (event) => props.onViewChange?.(event.currentTarget.value)
|
|
1704
|
+
}),
|
|
1705
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
1706
|
+
class: ScheduleHeader_module_default.viewSelect,
|
|
1707
|
+
style: { marginInlineStart: "auto" }
|
|
1708
|
+
}, () => [(0, vue.h)(ScheduleHeader.ViewSelect, {
|
|
1709
|
+
...props.viewSelectProps,
|
|
1710
|
+
value: props.view,
|
|
1711
|
+
labels: props.labels,
|
|
1712
|
+
onChange: props.onViewChange
|
|
1713
|
+
})])
|
|
1714
|
+
]);
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
function createHeaderNavigation(date, unit) {
|
|
1719
|
+
return {
|
|
1720
|
+
previous: () => toDateString((0, dayjs.default)(date).subtract(1, unit)),
|
|
1721
|
+
next: () => toDateString((0, dayjs.default)(date).add(1, unit)),
|
|
1722
|
+
today: () => toDateString((0, dayjs.default)())
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
//#endregion
|
|
1726
|
+
//#region src/components/DayView/get-day-view-events/get-day-positioned-events.ts
|
|
1727
|
+
function columnHasConflict$1({ columns, columnIndex, event, allDay, date }) {
|
|
1728
|
+
if (!columns[columnIndex]) return false;
|
|
1729
|
+
return columns[columnIndex].some((e) => {
|
|
1730
|
+
const eAllDay = isAllDayEvent({
|
|
1731
|
+
event: e,
|
|
1732
|
+
date
|
|
1733
|
+
});
|
|
1734
|
+
const hasTimeConflict = isEventsOverlap(e, event);
|
|
1735
|
+
if (allDay || eAllDay) return false;
|
|
1736
|
+
return hasTimeConflict;
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
function getDayPositionedEvents({ events, startTime, endTime, intervalMinutes, date }) {
|
|
1740
|
+
const columns = [];
|
|
1741
|
+
const positioned = [];
|
|
1742
|
+
const sorted = sortEvents(events);
|
|
1743
|
+
for (const event of sorted) {
|
|
1744
|
+
const allDay = isAllDayEvent({
|
|
1745
|
+
event,
|
|
1746
|
+
date
|
|
1747
|
+
});
|
|
1748
|
+
let column = 0;
|
|
1749
|
+
while (columnHasConflict$1({
|
|
1750
|
+
columns,
|
|
1751
|
+
columnIndex: column,
|
|
1752
|
+
event,
|
|
1753
|
+
allDay,
|
|
1754
|
+
date
|
|
1755
|
+
})) column++;
|
|
1756
|
+
if (!columns[column]) columns[column] = [];
|
|
1757
|
+
columns[column].push(event);
|
|
1758
|
+
const verticalPosition = allDay ? {
|
|
1759
|
+
top: 0,
|
|
1760
|
+
height: 100
|
|
1761
|
+
} : getDayPosition({
|
|
1762
|
+
event,
|
|
1763
|
+
startTime,
|
|
1764
|
+
endTime,
|
|
1765
|
+
intervalMinutes
|
|
1766
|
+
});
|
|
1767
|
+
positioned.push({
|
|
1768
|
+
...event,
|
|
1769
|
+
position: {
|
|
1770
|
+
...verticalPosition,
|
|
1771
|
+
allDay,
|
|
1772
|
+
column,
|
|
1773
|
+
width: 0,
|
|
1774
|
+
offset: 0,
|
|
1775
|
+
overlaps: 0
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
for (const positionedEvent of positioned) {
|
|
1780
|
+
const { allDay, column } = positionedEvent.position;
|
|
1781
|
+
if (allDay) {
|
|
1782
|
+
positionedEvent.position.overlaps = 1;
|
|
1783
|
+
positionedEvent.position.width = 100;
|
|
1784
|
+
positionedEvent.position.offset = 0;
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
const directlyOverlapping = [];
|
|
1788
|
+
for (const otherEvent of positioned) {
|
|
1789
|
+
if (otherEvent === positionedEvent || otherEvent.position.allDay) continue;
|
|
1790
|
+
if (isEventsOverlap(otherEvent, positionedEvent)) directlyOverlapping.push(otherEvent);
|
|
1791
|
+
}
|
|
1792
|
+
let maxColumn = column;
|
|
1793
|
+
for (const overlappingEvent of directlyOverlapping) {
|
|
1794
|
+
maxColumn = Math.max(maxColumn, overlappingEvent.position.column);
|
|
1795
|
+
for (const otherEvent of positioned) {
|
|
1796
|
+
if (otherEvent === overlappingEvent || otherEvent.position.allDay) continue;
|
|
1797
|
+
if (isEventsOverlap(otherEvent, overlappingEvent)) maxColumn = Math.max(maxColumn, otherEvent.position.column);
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
const totalColumns = maxColumn + 1;
|
|
1801
|
+
let nextOccupiedColumn = totalColumns;
|
|
1802
|
+
for (const other of directlyOverlapping) if (other.position.column > column && other.position.column < nextOccupiedColumn) nextOccupiedColumn = other.position.column;
|
|
1803
|
+
const columnsSpanned = nextOccupiedColumn - column;
|
|
1804
|
+
positionedEvent.position.overlaps = totalColumns;
|
|
1805
|
+
positionedEvent.position.width = columnsSpanned / totalColumns * 100;
|
|
1806
|
+
positionedEvent.position.offset = column * 100 / totalColumns;
|
|
1807
|
+
}
|
|
1808
|
+
return positioned;
|
|
1809
|
+
}
|
|
1810
|
+
//#endregion
|
|
1811
|
+
//#region src/components/DayView/get-day-view-events/get-day-view-events.ts
|
|
1812
|
+
function getDayViewEvents({ events, date, startTime, endTime, intervalMinutes }) {
|
|
1813
|
+
if (events === void 0) return {
|
|
1814
|
+
allDayEvents: [],
|
|
1815
|
+
regularEvents: [],
|
|
1816
|
+
backgroundTimedEvents: [],
|
|
1817
|
+
backgroundAllDayEvents: []
|
|
1818
|
+
};
|
|
1819
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1820
|
+
const filteredEvents = [];
|
|
1821
|
+
const backgroundFiltered = [];
|
|
1822
|
+
const dayStart = (0, dayjs.default)(date).startOf("day");
|
|
1823
|
+
const dayEnd = (0, dayjs.default)(date).endOf("day");
|
|
1824
|
+
for (const event of events) {
|
|
1825
|
+
const eventStart = (0, dayjs.default)(event.start);
|
|
1826
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
1827
|
+
const isOnDay = eventStart.isSame(dayStart, "day");
|
|
1828
|
+
const spansIntoDay = !isOnDay && event.display === "background" && eventStart.isBefore(dayEnd) && eventEnd.isAfter(dayStart);
|
|
1829
|
+
if (isOnDay || spansIntoDay) {
|
|
1830
|
+
if (isOnDay && !isEventInTimeRange({
|
|
1831
|
+
event,
|
|
1832
|
+
startTime,
|
|
1833
|
+
endTime
|
|
1834
|
+
})) continue;
|
|
1835
|
+
const validated = validateEvent(event);
|
|
1836
|
+
if (!ids.has(event.id)) ids.add(event.id);
|
|
1837
|
+
else throw new Error(`[@mantine/schedule] DayView: Duplicated event ids found: ${event.id}`);
|
|
1838
|
+
if (event.display === "background") backgroundFiltered.push(validated);
|
|
1839
|
+
else filteredEvents.push(validated);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
const positionedEvents = getDayPositionedEvents({
|
|
1843
|
+
events: filteredEvents,
|
|
1844
|
+
startTime,
|
|
1845
|
+
endTime,
|
|
1846
|
+
intervalMinutes,
|
|
1847
|
+
date
|
|
1848
|
+
});
|
|
1849
|
+
const allDayEvents = [];
|
|
1850
|
+
const regularEvents = [];
|
|
1851
|
+
for (const event of positionedEvents) if (event.position.allDay) allDayEvents.push(event);
|
|
1852
|
+
else regularEvents.push(event);
|
|
1853
|
+
const backgroundTimedEvents = [];
|
|
1854
|
+
const backgroundAllDayEvents = [];
|
|
1855
|
+
for (const event of backgroundFiltered) {
|
|
1856
|
+
const eventStart = (0, dayjs.default)(event.start);
|
|
1857
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
1858
|
+
const clippedStart = eventStart.isBefore(dayStart) ? dayStart : eventStart;
|
|
1859
|
+
const clippedEnd = eventEnd.isAfter(dayEnd) ? dayEnd : eventEnd;
|
|
1860
|
+
const clippedEvent = {
|
|
1861
|
+
...event,
|
|
1862
|
+
start: clippedStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
1863
|
+
end: clippedEnd.format("YYYY-MM-DD HH:mm:ss")
|
|
1864
|
+
};
|
|
1865
|
+
if (isAllDayEvent({
|
|
1866
|
+
event: clippedEvent,
|
|
1867
|
+
date
|
|
1868
|
+
})) backgroundAllDayEvents.push({
|
|
1869
|
+
...event,
|
|
1870
|
+
position: {
|
|
1871
|
+
top: 0,
|
|
1872
|
+
height: 100,
|
|
1873
|
+
allDay: true,
|
|
1874
|
+
width: 100,
|
|
1875
|
+
offset: 0,
|
|
1876
|
+
column: 0,
|
|
1877
|
+
overlaps: 1
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
else {
|
|
1881
|
+
const { top, height } = getDayPosition({
|
|
1882
|
+
event: clippedEvent,
|
|
1883
|
+
startTime,
|
|
1884
|
+
endTime,
|
|
1885
|
+
intervalMinutes
|
|
1886
|
+
});
|
|
1887
|
+
if (height <= 0) continue;
|
|
1888
|
+
backgroundTimedEvents.push({
|
|
1889
|
+
...event,
|
|
1890
|
+
position: {
|
|
1891
|
+
top,
|
|
1892
|
+
height,
|
|
1893
|
+
allDay: false,
|
|
1894
|
+
width: 100,
|
|
1895
|
+
offset: 0,
|
|
1896
|
+
column: 0,
|
|
1897
|
+
overlaps: 1
|
|
1898
|
+
}
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
return {
|
|
1903
|
+
allDayEvents,
|
|
1904
|
+
regularEvents,
|
|
1905
|
+
backgroundTimedEvents,
|
|
1906
|
+
backgroundAllDayEvents
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
var DayView_module_default = {
|
|
1910
|
+
dayView: "_dayView_wgb7d_1",
|
|
1911
|
+
dayViewHeader: "_dayViewHeader_wgb7d_22",
|
|
1912
|
+
dayViewScrollArea: "_dayViewScrollArea_wgb7d_32",
|
|
1913
|
+
dayViewInner: "_dayViewInner_wgb7d_42",
|
|
1914
|
+
dayViewTimeSlots: "_dayViewTimeSlots_wgb7d_46",
|
|
1915
|
+
dayViewSlot: "_dayViewSlot_wgb7d_49",
|
|
1916
|
+
dayViewSlotLabels: "_dayViewSlotLabels_wgb7d_54",
|
|
1917
|
+
dayViewSlotLabel: "_dayViewSlotLabel_wgb7d_54",
|
|
1918
|
+
dayViewSlots: "_dayViewSlots_wgb7d_84",
|
|
1919
|
+
dayViewBackgroundEvent: "_dayViewBackgroundEvent_wgb7d_188",
|
|
1920
|
+
dayViewAllDay: "_dayViewAllDay_wgb7d_201",
|
|
1921
|
+
dayViewAllDayEvents: "_dayViewAllDayEvents_wgb7d_206"
|
|
1922
|
+
};
|
|
1923
|
+
//#endregion
|
|
1924
|
+
//#region src/components/DayView/DayView.ts
|
|
1925
|
+
var DayView = (0, vue.defineComponent)({
|
|
1926
|
+
name: "DayView",
|
|
1927
|
+
inheritAttrs: false,
|
|
1928
|
+
slots: Object,
|
|
1929
|
+
props: {
|
|
1930
|
+
...timeViewProps,
|
|
1931
|
+
intervalMinutes: {
|
|
1932
|
+
type: Number,
|
|
1933
|
+
default: 15
|
|
1934
|
+
},
|
|
1935
|
+
headerFormat: {
|
|
1936
|
+
type: [String, Function],
|
|
1937
|
+
default: "MMMM D, YYYY"
|
|
1938
|
+
},
|
|
1939
|
+
withAllDaySlot: {
|
|
1940
|
+
type: Boolean,
|
|
1941
|
+
default: true
|
|
1942
|
+
},
|
|
1943
|
+
allDaySlotHeight: {
|
|
1944
|
+
type: [String, Number],
|
|
1945
|
+
default: 44
|
|
1946
|
+
},
|
|
1947
|
+
maxAllDayEvents: {
|
|
1948
|
+
type: Number,
|
|
1949
|
+
default: 3
|
|
1950
|
+
},
|
|
1951
|
+
moreEventsProps: Object
|
|
1952
|
+
},
|
|
1953
|
+
setup(props, { attrs, slots }) {
|
|
1954
|
+
const timeSlotsContainer = (0, vue.ref)(null);
|
|
1955
|
+
const dropTargetSlotIndex = (0, vue.ref)(null);
|
|
1956
|
+
const eventResize = useEventResize({
|
|
1957
|
+
enabled: () => props.withEventResize,
|
|
1958
|
+
mode: () => props.mode,
|
|
1959
|
+
startTime: () => props.startTime,
|
|
1960
|
+
endTime: () => props.endTime,
|
|
1961
|
+
intervalMinutes: () => props.intervalMinutes,
|
|
1962
|
+
onEventResize: () => props.onEventResize,
|
|
1963
|
+
canResizeEvent: () => props.canResizeEvent
|
|
1964
|
+
});
|
|
1965
|
+
const slotTimes = (0, vue.ref)([]);
|
|
1966
|
+
const dayGroupRef = (0, vue.ref)("");
|
|
1967
|
+
const slotDragSelect = useSlotDragSelect({
|
|
1968
|
+
enabled: () => props.withDragSlotSelect && props.mode !== "static",
|
|
1969
|
+
onDragEnd: () => props.onSlotDragEnd ? (startIndex, endIndex) => {
|
|
1970
|
+
const startSlot = slotTimes.value[startIndex];
|
|
1971
|
+
const endSlot = slotTimes.value[endIndex];
|
|
1972
|
+
if (startSlot && endSlot) props.onSlotDragEnd?.(`${dayGroupRef.value} ${startSlot.startTime}`, `${dayGroupRef.value} ${endSlot.endTime}`);
|
|
1973
|
+
} : void 0
|
|
1974
|
+
});
|
|
1975
|
+
return () => {
|
|
1976
|
+
const date = toDateString(props.date);
|
|
1977
|
+
const datePart = (0, dayjs.default)(date).format("YYYY-MM-DD");
|
|
1978
|
+
const now = (0, dayjs.default)(props.getCurrentTime?.() ?? (0, dayjs.default)());
|
|
1979
|
+
const showCurrentTimeIndicator = props.withCurrentTimeIndicator ?? (0, dayjs.default)(date).isSame(now, "day");
|
|
1980
|
+
const expanded = getExpandedEvents(props.events, (0, dayjs.default)(date).startOf("day").format("YYYY-MM-DD HH:mm:ss"), (0, dayjs.default)(date).endOf("day").format("YYYY-MM-DD HH:mm:ss"), props.recurrenceExpansionLimit);
|
|
1981
|
+
const { allDayEvents, regularEvents, backgroundTimedEvents, backgroundAllDayEvents } = getDayViewEvents({
|
|
1982
|
+
events: expanded,
|
|
1983
|
+
date,
|
|
1984
|
+
startTime: props.startTime,
|
|
1985
|
+
endTime: props.endTime,
|
|
1986
|
+
intervalMinutes: props.intervalMinutes
|
|
1987
|
+
});
|
|
1988
|
+
const intervals = getDayTimeIntervals({
|
|
1989
|
+
startTime: props.startTime,
|
|
1990
|
+
endTime: props.endTime,
|
|
1991
|
+
intervalMinutes: props.intervalMinutes
|
|
1992
|
+
});
|
|
1993
|
+
dayGroupRef.value = datePart;
|
|
1994
|
+
slotTimes.value = intervals.map((slot) => ({
|
|
1995
|
+
startTime: slot.startTime,
|
|
1996
|
+
endTime: slot.endTime
|
|
1997
|
+
}));
|
|
1998
|
+
const withSlotSelect = props.withDragSlotSelect && props.mode !== "static";
|
|
1999
|
+
const withDragHandlers = props.mode !== "static" && (props.withEventsDragAndDrop || Boolean(props.onExternalEventDrop));
|
|
2000
|
+
const { visibleEventsCount, hiddenEventsCount } = getVisibleEvents({
|
|
2001
|
+
maxEvents: props.maxAllDayEvents,
|
|
2002
|
+
totalEvents: allDayEvents.length
|
|
2003
|
+
});
|
|
2004
|
+
const emitDrop = (nativeEvent, target) => {
|
|
2005
|
+
nativeEvent.preventDefault();
|
|
2006
|
+
const event = getDropEvent(expanded, nativeEvent.dataTransfer);
|
|
2007
|
+
if (event) props.onEventDrop?.(moveEventTo(event, target));
|
|
2008
|
+
else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.(nativeEvent.dataTransfer, target);
|
|
2009
|
+
};
|
|
2010
|
+
const emitAllDayDrop = (nativeEvent) => {
|
|
2011
|
+
nativeEvent.preventDefault();
|
|
2012
|
+
const event = getDropEvent(expanded, nativeEvent.dataTransfer);
|
|
2013
|
+
if (event) props.onEventDrop?.(moveEventToAllDay(event, datePart));
|
|
2014
|
+
else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.(nativeEvent.dataTransfer, `${datePart} 00:00:00`);
|
|
2015
|
+
};
|
|
2016
|
+
const rootStyle = {
|
|
2017
|
+
"--day-view-radius": resolveScheduleRadius(props.radius),
|
|
2018
|
+
"--day-view-slot-height": typeof props.slotHeight === "number" ? `${props.slotHeight}px` : props.slotHeight,
|
|
2019
|
+
"--day-view-all-day-slot-height": typeof props.allDaySlotHeight === "number" ? `${props.allDaySlotHeight}px` : props.allDaySlotHeight
|
|
2020
|
+
};
|
|
2021
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
2022
|
+
...attrs,
|
|
2023
|
+
class: [DayView_module_default.dayView, attrs.class],
|
|
2024
|
+
style: [rootStyle, attrs.style],
|
|
2025
|
+
mod: {
|
|
2026
|
+
static: props.mode === "static",
|
|
2027
|
+
"slot-dragging": slotDragSelect.isDragging()
|
|
2028
|
+
}
|
|
2029
|
+
}, () => [props.withHeader ? (0, vue.h)(ScheduleHeaderBase, {
|
|
2030
|
+
view: "day",
|
|
2031
|
+
labels: props.labels,
|
|
2032
|
+
onDateChange: props.onDateChange,
|
|
2033
|
+
onViewChange: props.onViewChange,
|
|
2034
|
+
navigationHandlers: createHeaderNavigation(date, "day"),
|
|
2035
|
+
previousControlProps: props.previousControlProps,
|
|
2036
|
+
nextControlProps: props.nextControlProps,
|
|
2037
|
+
todayControlProps: props.todayControlProps,
|
|
2038
|
+
viewSelectProps: props.viewSelectProps,
|
|
2039
|
+
control: { title: formatDate({
|
|
2040
|
+
date,
|
|
2041
|
+
locale: props.locale || "en",
|
|
2042
|
+
format: props.headerFormat
|
|
2043
|
+
}) }
|
|
2044
|
+
}) : null, (0, vue.h)(_mantine_vue_core.ScrollArea.Autosize, {
|
|
2045
|
+
class: DayView_module_default.dayViewScrollArea,
|
|
2046
|
+
scrollbarSize: 4
|
|
2047
|
+
}, () => [(0, vue.h)(_mantine_vue_core.Box, { class: DayView_module_default.dayViewInner }, () => [(0, vue.h)("div", { class: DayView_module_default.dayViewSlotLabels }, [props.withAllDaySlot ? (0, vue.h)(_mantine_vue_core.Box, {
|
|
2048
|
+
class: DayView_module_default.dayViewSlotLabel,
|
|
2049
|
+
mod: { "all-day": true }
|
|
2050
|
+
}, () => getLabelSafe("allDay", props.labels)) : null, ...intervals.filter((slot) => slot.isHourStart).map((slot) => (0, vue.h)(_mantine_vue_core.Box, { class: DayView_module_default.dayViewSlotLabel }, () => formatDate({
|
|
2051
|
+
date: `${datePart} ${slot.startTime}`,
|
|
2052
|
+
locale: props.locale || "en",
|
|
2053
|
+
format: props.slotLabelFormat
|
|
2054
|
+
})))]), (0, vue.h)("div", { class: DayView_module_default.dayViewSlots }, [props.withAllDaySlot ? (0, vue.h)("div", { class: DayView_module_default.dayViewAllDay }, [
|
|
2055
|
+
...backgroundAllDayEvents.map((event) => (0, vue.h)("div", {
|
|
2056
|
+
class: DayView_module_default.dayViewBackgroundEvent,
|
|
2057
|
+
key: event.id
|
|
2058
|
+
})),
|
|
2059
|
+
(0, vue.h)("div", { class: DayView_module_default.dayViewAllDayEvents }, [...allDayEvents.slice(0, visibleEventsCount).map((event) => eventNode(event, props, {
|
|
2060
|
+
key: event.id,
|
|
2061
|
+
nowrap: true
|
|
2062
|
+
}, slots)), hiddenEventsCount > 0 ? (0, vue.h)(MoreEvents, {
|
|
2063
|
+
events: allDayEvents,
|
|
2064
|
+
moreEventsCount: hiddenEventsCount,
|
|
2065
|
+
labels: props.labels,
|
|
2066
|
+
mode: props.mode,
|
|
2067
|
+
renderEvent: props.renderEvent,
|
|
2068
|
+
renderEventBody: props.renderEventBody,
|
|
2069
|
+
onEventClick: props.onEventClick,
|
|
2070
|
+
...props.moreEventsProps
|
|
2071
|
+
}, forwardEventSlots(slots)) : null]),
|
|
2072
|
+
(0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2073
|
+
class: DayView_module_default.dayViewSlot,
|
|
2074
|
+
mod: {
|
|
2075
|
+
"all-day": true,
|
|
2076
|
+
static: props.mode === "static"
|
|
2077
|
+
},
|
|
2078
|
+
tabindex: props.mode === "static" ? -1 : 0,
|
|
2079
|
+
"aria-label": `${getLabelSafe("timeSlot", props.labels)} ${getLabelSafe("allDay", props.labels)}`,
|
|
2080
|
+
onClick: props.mode === "static" ? void 0 : (event) => props.onAllDaySlotClick?.(date, event),
|
|
2081
|
+
onDragover: (event) => event.preventDefault(),
|
|
2082
|
+
onDrop: (event) => emitAllDayDrop(event)
|
|
2083
|
+
})
|
|
2084
|
+
]) : null, (0, vue.h)("div", {
|
|
2085
|
+
ref: timeSlotsContainer,
|
|
2086
|
+
class: DayView_module_default.dayViewTimeSlots,
|
|
2087
|
+
onDragover: withDragHandlers ? (event) => {
|
|
2088
|
+
event.preventDefault();
|
|
2089
|
+
if (!timeSlotsContainer.value) return;
|
|
2090
|
+
dropTargetSlotIndex.value = getTimeSlotDropTarget({
|
|
2091
|
+
nativeEvent: event,
|
|
2092
|
+
container: timeSlotsContainer.value,
|
|
2093
|
+
intervals,
|
|
2094
|
+
date: datePart
|
|
2095
|
+
})?.slotIndex ?? null;
|
|
2096
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = event.dataTransfer.types.includes("application/json") ? "move" : "copy";
|
|
2097
|
+
} : void 0,
|
|
2098
|
+
onDragleave: withDragHandlers ? (event) => {
|
|
2099
|
+
if (!(event.relatedTarget instanceof Node) || !timeSlotsContainer.value?.contains(event.relatedTarget)) dropTargetSlotIndex.value = null;
|
|
2100
|
+
} : void 0,
|
|
2101
|
+
onDrop: withDragHandlers ? (event) => {
|
|
2102
|
+
if (!timeSlotsContainer.value) return;
|
|
2103
|
+
const target = getTimeSlotDropTarget({
|
|
2104
|
+
nativeEvent: event,
|
|
2105
|
+
container: timeSlotsContainer.value,
|
|
2106
|
+
intervals,
|
|
2107
|
+
date: datePart
|
|
2108
|
+
});
|
|
2109
|
+
dropTargetSlotIndex.value = null;
|
|
2110
|
+
if (target) emitDrop(event, target.target);
|
|
2111
|
+
} : void 0
|
|
2112
|
+
}, [
|
|
2113
|
+
...backgroundTimedEvents.map((event) => (0, vue.h)("div", {
|
|
2114
|
+
key: event.id,
|
|
2115
|
+
class: DayView_module_default.dayViewBackgroundEvent,
|
|
2116
|
+
style: {
|
|
2117
|
+
top: `${event.position.top}%`,
|
|
2118
|
+
height: `${event.position.height}%`
|
|
2119
|
+
}
|
|
2120
|
+
})),
|
|
2121
|
+
...regularEvents.map((event) => {
|
|
2122
|
+
const resizePosition = eventResize.getResizePosition(event.id);
|
|
2123
|
+
const isResizable = eventResize.isResizableEvent(event);
|
|
2124
|
+
return eventNode(event, props, {
|
|
2125
|
+
key: event.id,
|
|
2126
|
+
autoSize: true,
|
|
2127
|
+
style: {
|
|
2128
|
+
position: "absolute",
|
|
2129
|
+
top: `${resizePosition?.top ?? event.position.top}%`,
|
|
2130
|
+
height: `${resizePosition?.height ?? event.position.height}%`,
|
|
2131
|
+
width: `${event.position.width}%`,
|
|
2132
|
+
insetInlineStart: `${event.position.offset}%`
|
|
2133
|
+
},
|
|
2134
|
+
withResize: isResizable,
|
|
2135
|
+
isResizing: resizePosition !== null,
|
|
2136
|
+
onClick: props.onEventClick ? (nativeEvent) => {
|
|
2137
|
+
if (!eventResize.wasResizing()) props.onEventClick?.(event, nativeEvent);
|
|
2138
|
+
} : void 0,
|
|
2139
|
+
onResizeStart: (edge, pointerEvent) => {
|
|
2140
|
+
if (!timeSlotsContainer.value) return;
|
|
2141
|
+
eventResize.handleResizeStart({
|
|
2142
|
+
event,
|
|
2143
|
+
edge,
|
|
2144
|
+
container: timeSlotsContainer.value,
|
|
2145
|
+
originalTop: event.position.top,
|
|
2146
|
+
originalHeight: event.position.height,
|
|
2147
|
+
eventDate: datePart,
|
|
2148
|
+
pointerEvent
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
}, slots);
|
|
2152
|
+
}),
|
|
2153
|
+
showCurrentTimeIndicator ? (0, vue.h)(CurrentTimeIndicator, {
|
|
2154
|
+
startOffset: "calc(var(--day-view-slot-labels-width) * -1)",
|
|
2155
|
+
endOffset: "0rem",
|
|
2156
|
+
topOffset: "0rem",
|
|
2157
|
+
timeBubbleStartOffset: "calc(var(--day-view-slot-labels-width) * -1 + 30px)",
|
|
2158
|
+
currentTimeFormat: props.slotLabelFormat,
|
|
2159
|
+
startTime: props.startTime,
|
|
2160
|
+
endTime: props.endTime,
|
|
2161
|
+
intervalMinutes: props.intervalMinutes,
|
|
2162
|
+
withTimeBubble: props.withCurrentTimeBubble,
|
|
2163
|
+
withThumb: !props.withCurrentTimeBubble,
|
|
2164
|
+
getCurrentTime: props.getCurrentTime,
|
|
2165
|
+
locale: props.locale
|
|
2166
|
+
}) : null,
|
|
2167
|
+
...intervals.map((slot, index) => {
|
|
2168
|
+
const start = (0, dayjs.default)(`${datePart} ${slot.startTime}`);
|
|
2169
|
+
const end = start.add(props.intervalMinutes, "minute");
|
|
2170
|
+
const mod = props.highlightBusinessHours ? getBusinessHoursMod({
|
|
2171
|
+
time: start.format("HH:mm:ss"),
|
|
2172
|
+
businessHours: props.businessHours || ["09:00:00", "17:00:00"],
|
|
2173
|
+
highlightBusinessHours: true,
|
|
2174
|
+
dayOfWeek: start.day()
|
|
2175
|
+
}) : {
|
|
2176
|
+
"business-hours": false,
|
|
2177
|
+
"non-business-hours": false
|
|
2178
|
+
};
|
|
2179
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2180
|
+
class: DayView_module_default.dayViewSlot,
|
|
2181
|
+
"data-time-slot-index": index,
|
|
2182
|
+
"data-drag-slot-index": withSlotSelect ? index : void 0,
|
|
2183
|
+
"data-drag-slot-group": withSlotSelect ? datePart : void 0,
|
|
2184
|
+
style: { "--slot-size": String(props.intervalMinutes / 60) },
|
|
2185
|
+
mod: {
|
|
2186
|
+
first: index === 0,
|
|
2187
|
+
"hour-start": slot.isHourStart,
|
|
2188
|
+
static: props.mode === "static",
|
|
2189
|
+
"drop-target": dropTargetSlotIndex.value === index,
|
|
2190
|
+
"drag-selected": slotDragSelect.isSlotSelected(index, datePart),
|
|
2191
|
+
"business-hours": mod["business-hours"],
|
|
2192
|
+
"non-business-hours": mod["non-business-hours"]
|
|
2193
|
+
},
|
|
2194
|
+
tabindex: props.mode === "static" ? -1 : index === 0 ? 0 : -1,
|
|
2195
|
+
onKeydown: props.mode === "static" ? void 0 : (event) => {
|
|
2196
|
+
const nextIndex = event.key === "ArrowDown" ? index + 1 : event.key === "ArrowUp" ? index - 1 : -1;
|
|
2197
|
+
if (nextIndex < 0 || nextIndex >= intervals.length) return;
|
|
2198
|
+
event.preventDefault();
|
|
2199
|
+
timeSlotsContainer.value?.querySelector(`[data-time-slot-index="${nextIndex}"]`)?.focus();
|
|
2200
|
+
},
|
|
2201
|
+
"aria-label": `${getLabelSafe("timeSlot", props.labels)} ${slot.startTime} - ${slot.endTime}`,
|
|
2202
|
+
onClick: (nativeEvent) => props.onTimeSlotClick?.({
|
|
2203
|
+
slotStart: start.format("YYYY-MM-DD HH:mm:ss"),
|
|
2204
|
+
slotEnd: end.format("YYYY-MM-DD HH:mm:ss"),
|
|
2205
|
+
nativeEvent
|
|
2206
|
+
}),
|
|
2207
|
+
onPointerdown: withSlotSelect ? (nativeEvent) => slotDragSelect.handleSlotPointerDown(nativeEvent, index, datePart) : void 0,
|
|
2208
|
+
onDragover: (event) => event.preventDefault()
|
|
2209
|
+
});
|
|
2210
|
+
})
|
|
2211
|
+
])])])])]);
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
});
|
|
2215
|
+
function getLabelSafe(key, labels) {
|
|
2216
|
+
return labels?.[key] || {
|
|
2217
|
+
allDay: "All day",
|
|
2218
|
+
timeSlot: "Time slot"
|
|
2219
|
+
}[key];
|
|
2220
|
+
}
|
|
2221
|
+
//#endregion
|
|
2222
|
+
//#region src/components/MobileMonthView/get-mobile-month-view-events.ts
|
|
2223
|
+
function groupEventByDate$1(event, groupedEvents) {
|
|
2224
|
+
if (isMultidayEvent(event)) {
|
|
2225
|
+
const startDate = (0, dayjs.default)(event.start).startOf("day");
|
|
2226
|
+
const endDate = (0, dayjs.default)(event.end).startOf("day");
|
|
2227
|
+
for (let date = startDate; date.isBefore(endDate) || date.isSame(endDate); date = date.add(1, "day")) {
|
|
2228
|
+
const dateKey = date.format("YYYY-MM-DD");
|
|
2229
|
+
if (!groupedEvents[dateKey]) groupedEvents[dateKey] = [];
|
|
2230
|
+
groupedEvents[dateKey].push(event);
|
|
2231
|
+
}
|
|
2232
|
+
return;
|
|
2233
|
+
}
|
|
2234
|
+
const eventDate = (0, dayjs.default)(event.start).format("YYYY-MM-DD");
|
|
2235
|
+
if (!groupedEvents[eventDate]) groupedEvents[eventDate] = [];
|
|
2236
|
+
groupedEvents[eventDate].push(event);
|
|
2237
|
+
}
|
|
2238
|
+
function getMobileMonthViewEvents({ date, events }) {
|
|
2239
|
+
const groupedEvents = {};
|
|
2240
|
+
if (events === void 0) return groupedEvents;
|
|
2241
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2242
|
+
for (const event of events) {
|
|
2243
|
+
if (event.display === "background") continue;
|
|
2244
|
+
if ((0, dayjs.default)(event.start).isSame((0, dayjs.default)(date), "month")) {
|
|
2245
|
+
groupEventByDate$1(validateEvent(event), groupedEvents);
|
|
2246
|
+
if (!ids.has(event.id)) ids.add(event.id);
|
|
2247
|
+
else throw new Error(`[@mantine/schedule] MobileMonthView: Duplicated event ids found: ${event.id}`);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
return groupedEvents;
|
|
2251
|
+
}
|
|
2252
|
+
var MobileMonthView_module_default = {
|
|
2253
|
+
mobileMonthView: "_mobileMonthView_vgzwg_1",
|
|
2254
|
+
mobileMonthViewHeader: "_mobileMonthViewHeader_vgzwg_24",
|
|
2255
|
+
mobileMonthViewHeaderBackButton: "_mobileMonthViewHeaderBackButton_vgzwg_32",
|
|
2256
|
+
mobileMonthViewHeaderLabel: "_mobileMonthViewHeaderLabel_vgzwg_47",
|
|
2257
|
+
mobileMonthViewCalendar: "_mobileMonthViewCalendar_vgzwg_53",
|
|
2258
|
+
mobileMonthViewWeekdays: "_mobileMonthViewWeekdays_vgzwg_61",
|
|
2259
|
+
mobileMonthViewWeekdaysCorner: "_mobileMonthViewWeekdaysCorner_vgzwg_66",
|
|
2260
|
+
mobileMonthViewWeekday: "_mobileMonthViewWeekday_vgzwg_61",
|
|
2261
|
+
mobileMonthViewWeek: "_mobileMonthViewWeek_vgzwg_61",
|
|
2262
|
+
mobileMonthViewWeekNumber: "_mobileMonthViewWeekNumber_vgzwg_89",
|
|
2263
|
+
mobileMonthViewDay: "_mobileMonthViewDay_vgzwg_119",
|
|
2264
|
+
mobileMonthViewDayIndicators: "_mobileMonthViewDayIndicators_vgzwg_208",
|
|
2265
|
+
mobileMonthViewDayIndicator: "_mobileMonthViewDayIndicator_vgzwg_208",
|
|
2266
|
+
mobileMonthViewEventsList: "_mobileMonthViewEventsList_vgzwg_224",
|
|
2267
|
+
mobileMonthViewEventsHeader: "_mobileMonthViewEventsHeader_vgzwg_232",
|
|
2268
|
+
mobileMonthViewEvent: "_mobileMonthViewEvent_vgzwg_224",
|
|
2269
|
+
mobileMonthViewEventBody: "_mobileMonthViewEventBody_vgzwg_259",
|
|
2270
|
+
mobileMonthViewEventColor: "_mobileMonthViewEventColor_vgzwg_265",
|
|
2271
|
+
mobileMonthViewEventTime: "_mobileMonthViewEventTime_vgzwg_271",
|
|
2272
|
+
mobileMonthViewNoEvents: "_mobileMonthViewNoEvents_vgzwg_277"
|
|
2273
|
+
};
|
|
2274
|
+
//#endregion
|
|
2275
|
+
//#region src/components/MobileMonthView/MobileMonthView.ts
|
|
2276
|
+
var MobileMonthView = (0, vue.defineComponent)({
|
|
2277
|
+
name: "MobileMonthView",
|
|
2278
|
+
inheritAttrs: false,
|
|
2279
|
+
slots: Object,
|
|
2280
|
+
props: {
|
|
2281
|
+
...baseViewProps,
|
|
2282
|
+
selectedDate: [
|
|
2283
|
+
String,
|
|
2284
|
+
Date,
|
|
2285
|
+
null
|
|
2286
|
+
],
|
|
2287
|
+
defaultSelectedDate: [
|
|
2288
|
+
String,
|
|
2289
|
+
Date,
|
|
2290
|
+
null
|
|
2291
|
+
],
|
|
2292
|
+
onSelectedDateChange: Function,
|
|
2293
|
+
withWeekNumbers: Boolean,
|
|
2294
|
+
withWeekDays: {
|
|
2295
|
+
type: Boolean,
|
|
2296
|
+
default: true
|
|
2297
|
+
},
|
|
2298
|
+
firstDayOfWeek: {
|
|
2299
|
+
type: Number,
|
|
2300
|
+
default: 1
|
|
2301
|
+
},
|
|
2302
|
+
weekdayFormat: {
|
|
2303
|
+
type: [String, Function],
|
|
2304
|
+
default: "dd"
|
|
2305
|
+
},
|
|
2306
|
+
weekendDays: {
|
|
2307
|
+
type: Array,
|
|
2308
|
+
default: () => [0, 6]
|
|
2309
|
+
},
|
|
2310
|
+
getWeekNumberProps: Function,
|
|
2311
|
+
getDayProps: Function,
|
|
2312
|
+
onDayClick: Function,
|
|
2313
|
+
onWeekNumberClick: Function,
|
|
2314
|
+
consistentWeeks: {
|
|
2315
|
+
type: Boolean,
|
|
2316
|
+
default: true
|
|
2317
|
+
},
|
|
2318
|
+
highlightToday: {
|
|
2319
|
+
type: Boolean,
|
|
2320
|
+
default: true
|
|
2321
|
+
},
|
|
2322
|
+
withOutsideDays: Boolean,
|
|
2323
|
+
eventsHeaderFormat: {
|
|
2324
|
+
type: [String, Function],
|
|
2325
|
+
default: "dddd, MMMM D"
|
|
2326
|
+
},
|
|
2327
|
+
onYearClick: Function,
|
|
2328
|
+
renderHeader: Function
|
|
2329
|
+
},
|
|
2330
|
+
setup(props, { attrs, slots }) {
|
|
2331
|
+
const { dir } = (0, _mantine_vue_core.useDirection)();
|
|
2332
|
+
const theme = (0, _mantine_vue_core.useSafeMantineTheme)();
|
|
2333
|
+
const internalSelected = (0, vue.ref)(props.selectedDate !== void 0 ? props.selectedDate ? (0, dayjs.default)(props.selectedDate).format("YYYY-MM-DD") : null : (0, dayjs.default)(props.defaultSelectedDate ?? (0, dayjs.default)()).format("YYYY-MM-DD"));
|
|
2334
|
+
(0, vue.watch)(() => props.selectedDate, (value) => {
|
|
2335
|
+
if (value !== void 0) internalSelected.value = value ? (0, dayjs.default)(value).format("YYYY-MM-DD") : null;
|
|
2336
|
+
}, { immediate: true });
|
|
2337
|
+
const select = (date) => {
|
|
2338
|
+
internalSelected.value = date;
|
|
2339
|
+
props.onSelectedDateChange?.(date);
|
|
2340
|
+
};
|
|
2341
|
+
return () => {
|
|
2342
|
+
const month = (0, dayjs.default)(props.date).startOf("month");
|
|
2343
|
+
const weeks = getMonthDays({
|
|
2344
|
+
month,
|
|
2345
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
2346
|
+
consistentWeeks: props.consistentWeeks
|
|
2347
|
+
});
|
|
2348
|
+
const eventsByDay = getMobileMonthViewEvents({
|
|
2349
|
+
date: month,
|
|
2350
|
+
events: getExpandedEvents(props.events, weeks[0][0], (0, dayjs.default)(weeks.at(-1).at(-1)).endOf("day").format("YYYY-MM-DD HH:mm:ss"), props.recurrenceExpansionLimit)
|
|
2351
|
+
});
|
|
2352
|
+
const weekdays = getWeekdaysNames({
|
|
2353
|
+
locale: props.locale || "en",
|
|
2354
|
+
format: props.weekdayFormat,
|
|
2355
|
+
firstDayOfWeek: props.firstDayOfWeek
|
|
2356
|
+
});
|
|
2357
|
+
const selectedEvents = internalSelected.value ? eventsByDay[internalSelected.value] || [] : [];
|
|
2358
|
+
const headerDefault = [(0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2359
|
+
class: MobileMonthView_module_default.mobileMonthViewHeaderBackButton,
|
|
2360
|
+
mod: { static: props.mode === "static" },
|
|
2361
|
+
tabindex: props.mode === "static" ? -1 : 0,
|
|
2362
|
+
onClick: props.mode === "static" ? void 0 : props.onYearClick
|
|
2363
|
+
}, () => [(0, vue.h)(_mantine_vue_core.AccordionChevron, {
|
|
2364
|
+
size: 20,
|
|
2365
|
+
style: { transform: `rotate(${dir.value === "rtl" ? -90 : 90}deg)` }
|
|
2366
|
+
}), month.format("YYYY")]), (0, vue.h)(_mantine_vue_core.Text, { class: MobileMonthView_module_default.mobileMonthViewHeaderLabel }, () => formatDate({
|
|
2367
|
+
date: month,
|
|
2368
|
+
locale: props.locale || "en",
|
|
2369
|
+
format: "MMMM YYYY"
|
|
2370
|
+
}))];
|
|
2371
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
2372
|
+
...attrs,
|
|
2373
|
+
class: [MobileMonthView_module_default.mobileMonthView, attrs.class],
|
|
2374
|
+
style: [{ "--mobile-month-view-radius": resolveScheduleRadius(props.radius) }, attrs.style],
|
|
2375
|
+
mod: { "with-week-numbers": props.withWeekNumbers }
|
|
2376
|
+
}, () => [
|
|
2377
|
+
(0, vue.h)("div", { class: MobileMonthView_module_default.mobileMonthViewHeader }, [props.renderHeader?.({
|
|
2378
|
+
mode: props.mode,
|
|
2379
|
+
date: props.date,
|
|
2380
|
+
defaultHeader: headerDefault
|
|
2381
|
+
}) || slots.header?.({
|
|
2382
|
+
mode: props.mode,
|
|
2383
|
+
date: props.date,
|
|
2384
|
+
defaultHeader: headerDefault
|
|
2385
|
+
}) || headerDefault]),
|
|
2386
|
+
(0, vue.h)(_mantine_vue_core.Box, {
|
|
2387
|
+
class: MobileMonthView_module_default.mobileMonthViewCalendar,
|
|
2388
|
+
mod: { "with-weekdays": props.withWeekDays }
|
|
2389
|
+
}, () => [props.withWeekDays ? (0, vue.h)("div", { class: MobileMonthView_module_default.mobileMonthViewWeekdays }, [props.withWeekNumbers ? (0, vue.h)("span", { class: MobileMonthView_module_default.mobileMonthViewWeekdaysCorner }) : null, ...weekdays.map((weekday) => (0, vue.h)("span", { class: MobileMonthView_module_default.mobileMonthViewWeekday }, [weekday]))]) : null, ...weeks.map((week) => (0, vue.h)("div", { class: MobileMonthView_module_default.mobileMonthViewWeek }, [props.withWeekNumbers ? (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2390
|
+
class: MobileMonthView_module_default.mobileMonthViewWeekNumber,
|
|
2391
|
+
mod: { static: props.mode === "static" },
|
|
2392
|
+
tabindex: props.mode === "static" ? -1 : 0,
|
|
2393
|
+
...props.getWeekNumberProps?.((0, dayjs.default)(week[0]).format("YYYY-MM-DD")),
|
|
2394
|
+
onClick: (event) => props.onWeekNumberClick?.((0, dayjs.default)(week[0]).format("YYYY-MM-DD"), event)
|
|
2395
|
+
}, () => String(getWeekNumber(week))) : null, ...week.map((date) => {
|
|
2396
|
+
const value = (0, dayjs.default)(date).format("YYYY-MM-DD");
|
|
2397
|
+
const outside = !(0, dayjs.default)(date).isSame(month, "month");
|
|
2398
|
+
const events = eventsByDay[value] || [];
|
|
2399
|
+
const extra = props.getDayProps?.(value) || {};
|
|
2400
|
+
const shouldRender = !outside || props.withOutsideDays;
|
|
2401
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2402
|
+
...extra,
|
|
2403
|
+
class: [MobileMonthView_module_default.mobileMonthViewDay, extra.class],
|
|
2404
|
+
mod: {
|
|
2405
|
+
outside,
|
|
2406
|
+
weekend: props.weekendDays.includes((0, dayjs.default)(date).day()),
|
|
2407
|
+
today: props.highlightToday && (0, dayjs.default)(date).isSame((0, dayjs.default)(), "day"),
|
|
2408
|
+
selected: internalSelected.value === value,
|
|
2409
|
+
static: props.mode === "static",
|
|
2410
|
+
hidden: !shouldRender
|
|
2411
|
+
},
|
|
2412
|
+
tabindex: props.mode === "static" || !shouldRender ? -1 : 0,
|
|
2413
|
+
"aria-label": formatDate({
|
|
2414
|
+
date,
|
|
2415
|
+
locale: props.locale || "en",
|
|
2416
|
+
format: "MMMM D, YYYY"
|
|
2417
|
+
}),
|
|
2418
|
+
"aria-selected": internalSelected.value === value || void 0,
|
|
2419
|
+
onClick: props.mode === "static" || !shouldRender ? void 0 : (event) => {
|
|
2420
|
+
select(value);
|
|
2421
|
+
props.onDayClick?.(value, event);
|
|
2422
|
+
}
|
|
2423
|
+
}, () => [shouldRender ? String((0, dayjs.default)(date).date()) : null, shouldRender && events.length ? (0, vue.h)("span", { class: MobileMonthView_module_default.mobileMonthViewDayIndicators }, events.slice(0, 3).map((event) => (0, vue.h)("span", {
|
|
2424
|
+
class: MobileMonthView_module_default.mobileMonthViewDayIndicator,
|
|
2425
|
+
style: { background: `var(--mantine-color-${event.color}-6, ${event.color})` }
|
|
2426
|
+
}))) : null]);
|
|
2427
|
+
})]))]),
|
|
2428
|
+
(0, vue.h)(_mantine_vue_core.Box, { class: MobileMonthView_module_default.mobileMonthViewEventsList }, () => [(0, vue.h)(_mantine_vue_core.Text, { class: MobileMonthView_module_default.mobileMonthViewEventsHeader }, () => internalSelected.value ? formatDate({
|
|
2429
|
+
date: internalSelected.value,
|
|
2430
|
+
locale: props.locale || "en",
|
|
2431
|
+
format: props.eventsHeaderFormat
|
|
2432
|
+
}) : ""), selectedEvents.length ? selectedEvents.map((event) => {
|
|
2433
|
+
const startTime = (0, dayjs.default)(event.start).format("HH:mm");
|
|
2434
|
+
const endTime = (0, dayjs.default)(event.end).format("HH:mm");
|
|
2435
|
+
const isAllDay = startTime === "00:00" && endTime === "00:00";
|
|
2436
|
+
const eventChildren = (0, vue.h)(_mantine_vue_core.Box, { class: MobileMonthView_module_default.mobileMonthViewEventBody }, () => [(0, vue.h)("div", {
|
|
2437
|
+
class: MobileMonthView_module_default.mobileMonthViewEventColor,
|
|
2438
|
+
style: { backgroundColor: (0, _mantine_vue_core.getThemeColor)(event.color, theme.value) }
|
|
2439
|
+
}), (0, vue.h)("div", [(0, vue.h)(_mantine_vue_core.Text, { class: MobileMonthView_module_default.mobileMonthViewEventTitle }, () => event.title), (0, vue.h)(_mantine_vue_core.Text, { class: MobileMonthView_module_default.mobileMonthViewEventTime }, () => isAllDay ? "All day" : `${startTime} – ${endTime}`)])]);
|
|
2440
|
+
const rootProps = {
|
|
2441
|
+
type: "button",
|
|
2442
|
+
class: MobileMonthView_module_default.mobileMonthViewEvent,
|
|
2443
|
+
tabindex: props.mode === "static" ? -1 : 0,
|
|
2444
|
+
onClick: props.mode === "static" ? void 0 : (nativeEvent) => props.onEventClick?.(event, nativeEvent)
|
|
2445
|
+
};
|
|
2446
|
+
return props.renderEvent?.(event, {
|
|
2447
|
+
...rootProps,
|
|
2448
|
+
children: eventChildren
|
|
2449
|
+
}) || slots.event?.({
|
|
2450
|
+
...rootProps,
|
|
2451
|
+
children: eventChildren,
|
|
2452
|
+
event
|
|
2453
|
+
}) || (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2454
|
+
...rootProps,
|
|
2455
|
+
key: event.id
|
|
2456
|
+
}, () => eventChildren);
|
|
2457
|
+
}) : (0, vue.h)(_mantine_vue_core.Text, { class: MobileMonthView_module_default.mobileMonthViewNoEvents }, () => props.labels?.noEvents || "No events")])
|
|
2458
|
+
]);
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
//#endregion
|
|
2463
|
+
//#region src/components/keyboard-navigation.ts
|
|
2464
|
+
function handleGridKeydown({ event, index, columns, total, getControl }) {
|
|
2465
|
+
const step = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : event.key === "ArrowDown" ? columns : event.key === "ArrowUp" ? -columns : 0;
|
|
2466
|
+
if (step === 0) return;
|
|
2467
|
+
event.preventDefault();
|
|
2468
|
+
for (let next = index + step; next >= 0 && next < total; next += step) {
|
|
2469
|
+
const control = getControl(next);
|
|
2470
|
+
if (control && !control.disabled && !control.hasAttribute("data-hidden")) {
|
|
2471
|
+
control.focus();
|
|
2472
|
+
return;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
//#endregion
|
|
2477
|
+
//#region src/components/MonthView/get-month-view-events/add-event-to-day-groups.ts
|
|
2478
|
+
function addEventToDayGroups({ positionedEvent, eventStart, eventEnd, groupedByDay, eventsAddedToDay, weekIdx }) {
|
|
2479
|
+
if (weekIdx === 0 || !eventsAddedToDay.has(positionedEvent.id.toString())) {
|
|
2480
|
+
let dayDate = eventStart;
|
|
2481
|
+
while (dayDate.isBefore(eventEnd) || dayDate.isSame(eventEnd, "day")) {
|
|
2482
|
+
const dayDateStr = dayDate.format("YYYY-MM-DD 00:00:00");
|
|
2483
|
+
if (groupedByDay[dayDateStr]) groupedByDay[dayDateStr].push(positionedEvent);
|
|
2484
|
+
dayDate = dayDate.add(1, "day");
|
|
2485
|
+
}
|
|
2486
|
+
eventsAddedToDay.add(positionedEvent.id.toString());
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
//#endregion
|
|
2490
|
+
//#region src/components/MonthView/get-month-view-events/calculate-event-position-in-week.ts
|
|
2491
|
+
function calculateEventPositionInWeek({ eventStart, eventEnd, weekStart, weekEnd, isMultiday }) {
|
|
2492
|
+
let displayStart = eventStart;
|
|
2493
|
+
let displayEnd = eventEnd;
|
|
2494
|
+
const hangingStart = eventStart.isBefore(weekStart);
|
|
2495
|
+
const hangingEnd = eventEnd.isAfter(weekEnd);
|
|
2496
|
+
const hanging = hangingStart && hangingEnd ? "both" : hangingStart ? "start" : hangingEnd ? "end" : "none";
|
|
2497
|
+
if (displayStart.isBefore(weekStart)) displayStart = weekStart;
|
|
2498
|
+
if (displayEnd.isAfter(weekEnd)) displayEnd = weekEnd;
|
|
2499
|
+
const startDayIndex = displayStart.diff(weekStart, "day");
|
|
2500
|
+
const endDayIndex = displayEnd.diff(weekStart, "day");
|
|
2501
|
+
const daysSpanned = Math.max(1, endDayIndex - startDayIndex + (isMultiday ? 1 : 0));
|
|
2502
|
+
return {
|
|
2503
|
+
startDayIndex,
|
|
2504
|
+
daysSpanned,
|
|
2505
|
+
startOffset: startDayIndex / 7 * 100,
|
|
2506
|
+
width: daysSpanned / 7 * 100,
|
|
2507
|
+
hanging
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
//#endregion
|
|
2511
|
+
//#region src/components/MonthView/get-month-view-events/find-available-row.ts
|
|
2512
|
+
function findAvailableRow({ existingEvents, startDayIndex, daysSpanned, weekStart }) {
|
|
2513
|
+
let row = 0;
|
|
2514
|
+
for (const existing of existingEvents) {
|
|
2515
|
+
const existingStart = (0, dayjs.default)(existing.start).startOf("day");
|
|
2516
|
+
const existingDayIndex = (existingStart.isBefore(weekStart) || existingStart.isSame(weekStart, "day") ? weekStart : existingStart).diff(weekStart, "day");
|
|
2517
|
+
if (existingDayIndex + (existing.position?.width || 0) / 100 * 7 > startDayIndex && existingDayIndex < startDayIndex + daysSpanned) row = Math.max(row, (existing.position?.row || 0) + 1);
|
|
2518
|
+
}
|
|
2519
|
+
return row;
|
|
2520
|
+
}
|
|
2521
|
+
//#endregion
|
|
2522
|
+
//#region src/components/MonthView/get-month-view-events/get-weeks-in-range.ts
|
|
2523
|
+
function getWeeksInRange({ rangeStart, rangeEnd, firstDayOfWeek }) {
|
|
2524
|
+
const weeks = [];
|
|
2525
|
+
const groupedByDay = {};
|
|
2526
|
+
let currentDate = (0, dayjs.default)(getStartOfWeek({
|
|
2527
|
+
date: rangeStart.format("YYYY-MM-DD"),
|
|
2528
|
+
firstDayOfWeek
|
|
2529
|
+
}));
|
|
2530
|
+
while (currentDate.isBefore(rangeEnd) || currentDate.isSame(rangeEnd, "day")) {
|
|
2531
|
+
const week = [];
|
|
2532
|
+
for (let i = 0; i < 7; i++) {
|
|
2533
|
+
const dateStr = currentDate.format("YYYY-MM-DD 00:00:00");
|
|
2534
|
+
week.push(dateStr);
|
|
2535
|
+
if (!groupedByDay[dateStr]) groupedByDay[dateStr] = [];
|
|
2536
|
+
currentDate = currentDate.add(1, "day");
|
|
2537
|
+
}
|
|
2538
|
+
weeks.push(week);
|
|
2539
|
+
}
|
|
2540
|
+
return {
|
|
2541
|
+
weeks,
|
|
2542
|
+
groupedByDay
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
//#endregion
|
|
2546
|
+
//#region src/components/MonthView/get-month-view-events/get-month-positioned-events.ts
|
|
2547
|
+
function getMonthPositionedEvents({ date, events, firstDayOfWeek = 1, range }) {
|
|
2548
|
+
const groupedByWeek = {};
|
|
2549
|
+
const backgroundByWeek = {};
|
|
2550
|
+
const eventsAddedToDay = /* @__PURE__ */ new Set();
|
|
2551
|
+
const { weeks, groupedByDay } = getWeeksInRange({
|
|
2552
|
+
rangeStart: range ? (0, dayjs.default)(range.start) : (0, dayjs.default)(date).startOf("month"),
|
|
2553
|
+
rangeEnd: range ? (0, dayjs.default)(range.end) : (0, dayjs.default)(date).startOf("month").endOf("month"),
|
|
2554
|
+
firstDayOfWeek
|
|
2555
|
+
});
|
|
2556
|
+
for (let i = 0; i < weeks.length; i++) {
|
|
2557
|
+
groupedByWeek[i.toString()] = [];
|
|
2558
|
+
backgroundByWeek[i.toString()] = [];
|
|
2559
|
+
}
|
|
2560
|
+
for (const event of events) {
|
|
2561
|
+
const eventStart = (0, dayjs.default)(event.start).startOf("day");
|
|
2562
|
+
const rawEnd = (0, dayjs.default)(event.end);
|
|
2563
|
+
const eventEnd = rawEnd.hour() === 0 && rawEnd.minute() === 0 && rawEnd.second() === 0 ? rawEnd.startOf("day").subtract(1, "day") : rawEnd.startOf("day");
|
|
2564
|
+
const isMultiday = eventEnd.isAfter(eventStart);
|
|
2565
|
+
for (let weekIdx = 0; weekIdx < weeks.length; weekIdx++) {
|
|
2566
|
+
const week = weeks[weekIdx];
|
|
2567
|
+
const weekStart = (0, dayjs.default)(week[0]).startOf("day");
|
|
2568
|
+
const weekEnd = (0, dayjs.default)(week[6]).endOf("day");
|
|
2569
|
+
if ((eventStart.isBefore(weekEnd) || eventStart.isSame(weekEnd, "day")) && (eventEnd.isAfter(weekStart) || eventEnd.isSame(weekStart, "day"))) {
|
|
2570
|
+
const { startDayIndex, daysSpanned, startOffset, width, hanging } = calculateEventPositionInWeek({
|
|
2571
|
+
eventStart,
|
|
2572
|
+
eventEnd,
|
|
2573
|
+
weekStart,
|
|
2574
|
+
weekEnd,
|
|
2575
|
+
isMultiday
|
|
2576
|
+
});
|
|
2577
|
+
if (event.display === "background") {
|
|
2578
|
+
backgroundByWeek[weekIdx.toString()].push({
|
|
2579
|
+
...event,
|
|
2580
|
+
position: {
|
|
2581
|
+
startOffset,
|
|
2582
|
+
width,
|
|
2583
|
+
weekIndex: weekIdx,
|
|
2584
|
+
row: 0,
|
|
2585
|
+
hanging
|
|
2586
|
+
}
|
|
2587
|
+
});
|
|
2588
|
+
continue;
|
|
2589
|
+
}
|
|
2590
|
+
const row = findAvailableRow({
|
|
2591
|
+
existingEvents: groupedByWeek[weekIdx.toString()],
|
|
2592
|
+
startDayIndex,
|
|
2593
|
+
daysSpanned,
|
|
2594
|
+
weekStart
|
|
2595
|
+
});
|
|
2596
|
+
const positionedEvent = {
|
|
2597
|
+
...event,
|
|
2598
|
+
position: {
|
|
2599
|
+
startOffset,
|
|
2600
|
+
width,
|
|
2601
|
+
weekIndex: weekIdx,
|
|
2602
|
+
row,
|
|
2603
|
+
hanging
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
groupedByWeek[weekIdx.toString()].push(positionedEvent);
|
|
2607
|
+
addEventToDayGroups({
|
|
2608
|
+
positionedEvent,
|
|
2609
|
+
eventStart,
|
|
2610
|
+
eventEnd,
|
|
2611
|
+
groupedByDay,
|
|
2612
|
+
eventsAddedToDay,
|
|
2613
|
+
weekIdx
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
return {
|
|
2619
|
+
groupedByWeek,
|
|
2620
|
+
groupedByDay,
|
|
2621
|
+
backgroundByWeek
|
|
2622
|
+
};
|
|
2623
|
+
}
|
|
2624
|
+
//#endregion
|
|
2625
|
+
//#region src/components/MonthView/get-month-view-events/get-month-view-events.ts
|
|
2626
|
+
function getMonthViewEvents({ date, events, firstDayOfWeek = 1, withOutsideDays, consistentWeeks }) {
|
|
2627
|
+
if (events === void 0) return {
|
|
2628
|
+
groupedByDay: {},
|
|
2629
|
+
groupedByWeek: {},
|
|
2630
|
+
backgroundByWeek: {}
|
|
2631
|
+
};
|
|
2632
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2633
|
+
const filteredEvents = [];
|
|
2634
|
+
const range = getMonthRange({
|
|
2635
|
+
month: date,
|
|
2636
|
+
withOutsideDays,
|
|
2637
|
+
consistentWeeks,
|
|
2638
|
+
firstDayOfWeek
|
|
2639
|
+
});
|
|
2640
|
+
for (const event of events) if ((0, dayjs.default)(event.end).isAfter(range.start, "day") || (0, dayjs.default)(event.start).isBefore(range.end, "day")) {
|
|
2641
|
+
filteredEvents.push(validateEvent(event));
|
|
2642
|
+
if (!ids.has(event.id)) ids.add(event.id);
|
|
2643
|
+
else throw new Error(`[@mantine/schedule] MonthView: Duplicated event ids found: ${event.id}`);
|
|
2644
|
+
}
|
|
2645
|
+
return getMonthPositionedEvents({
|
|
2646
|
+
date,
|
|
2647
|
+
events: filteredEvents,
|
|
2648
|
+
firstDayOfWeek,
|
|
2649
|
+
range
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
//#endregion
|
|
2653
|
+
//#region src/components/MonthView/get-renderable-month-event-segments.ts
|
|
2654
|
+
var DAYS_IN_WEEK = 7;
|
|
2655
|
+
var DAY_WIDTH = 100 / DAYS_IN_WEEK;
|
|
2656
|
+
function getEventDayRange(event) {
|
|
2657
|
+
const startDayIndex = Math.max(0, Math.round(event.position.startOffset / DAY_WIDTH));
|
|
2658
|
+
const daysSpanned = Math.max(1, Math.round(event.position.width / DAY_WIDTH));
|
|
2659
|
+
return {
|
|
2660
|
+
startDayIndex,
|
|
2661
|
+
endDayIndex: Math.min(DAYS_IN_WEEK - 1, startDayIndex + daysSpanned - 1)
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
function getFirstAvailableRow(usedRows, maxEventsPerDay) {
|
|
2665
|
+
for (let row = 0; row < maxEventsPerDay; row += 1) if (!usedRows.has(row)) return row;
|
|
2666
|
+
return null;
|
|
2667
|
+
}
|
|
2668
|
+
function getSegmentHanging(originalHanging, touchesStart, touchesEnd) {
|
|
2669
|
+
const hangsFromStart = touchesStart && (originalHanging === "start" || originalHanging === "both");
|
|
2670
|
+
const hangsFromEnd = touchesEnd && (originalHanging === "end" || originalHanging === "both");
|
|
2671
|
+
if (hangsFromStart && hangsFromEnd) return "both";
|
|
2672
|
+
if (hangsFromStart) return "start";
|
|
2673
|
+
if (hangsFromEnd) return "end";
|
|
2674
|
+
return "none";
|
|
2675
|
+
}
|
|
2676
|
+
function getSegmentPosition(event, segment, eventRange) {
|
|
2677
|
+
const touchesStart = segment.startDayIndex === eventRange.startDayIndex;
|
|
2678
|
+
const touchesEnd = segment.endDayIndex === eventRange.endDayIndex;
|
|
2679
|
+
return {
|
|
2680
|
+
...event.position,
|
|
2681
|
+
startOffset: segment.startDayIndex / DAYS_IN_WEEK * 100,
|
|
2682
|
+
width: (segment.endDayIndex - segment.startDayIndex + 1) / DAYS_IN_WEEK * 100,
|
|
2683
|
+
row: segment.row,
|
|
2684
|
+
hanging: getSegmentHanging(event.position.hanging, touchesStart, touchesEnd)
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
function getEventKey(event) {
|
|
2688
|
+
return event.id;
|
|
2689
|
+
}
|
|
2690
|
+
function getRenderableMonthEventSegments({ events, groupedByDay, maxEventsPerDay, week }) {
|
|
2691
|
+
const eventIndexes = /* @__PURE__ */ new Map();
|
|
2692
|
+
const eventRanges = /* @__PURE__ */ new Map();
|
|
2693
|
+
const renderRows = /* @__PURE__ */ new Map();
|
|
2694
|
+
events.forEach((event, index) => {
|
|
2695
|
+
eventIndexes.set(event, index);
|
|
2696
|
+
eventRanges.set(event, getEventDayRange(event));
|
|
2697
|
+
});
|
|
2698
|
+
const setRenderRow = (event, dayIndex, row) => {
|
|
2699
|
+
if (!renderRows.has(event)) renderRows.set(event, /* @__PURE__ */ new Map());
|
|
2700
|
+
renderRows.get(event).set(dayIndex, row);
|
|
2701
|
+
};
|
|
2702
|
+
for (let dayIndex = 0; dayIndex < week.length; dayIndex += 1) {
|
|
2703
|
+
const dayEvents = groupedByDay[week[dayIndex]] || [];
|
|
2704
|
+
const dayEventIds = new Set(dayEvents.map((event) => getEventKey(event)));
|
|
2705
|
+
const dayWeekEvents = events.filter((event) => {
|
|
2706
|
+
const range = eventRanges.get(event);
|
|
2707
|
+
return dayEventIds.has(getEventKey(event)) && dayIndex >= range.startDayIndex && dayIndex <= range.endDayIndex;
|
|
2708
|
+
});
|
|
2709
|
+
if (dayEvents.length > maxEventsPerDay) {
|
|
2710
|
+
dayWeekEvents.forEach((event) => {
|
|
2711
|
+
if (event.position.row < maxEventsPerDay) setRenderRow(event, dayIndex, event.position.row);
|
|
2712
|
+
});
|
|
2713
|
+
continue;
|
|
2714
|
+
}
|
|
2715
|
+
const usedRows = /* @__PURE__ */ new Set();
|
|
2716
|
+
[...dayWeekEvents].sort((a, b) => {
|
|
2717
|
+
const rowDiff = a.position.row - b.position.row;
|
|
2718
|
+
if (rowDiff !== 0) return rowDiff;
|
|
2719
|
+
return eventIndexes.get(a) - eventIndexes.get(b);
|
|
2720
|
+
}).forEach((event) => {
|
|
2721
|
+
let row = event.position.row;
|
|
2722
|
+
if (row >= maxEventsPerDay || usedRows.has(row)) {
|
|
2723
|
+
const availableRow = getFirstAvailableRow(usedRows, maxEventsPerDay);
|
|
2724
|
+
if (availableRow === null) return;
|
|
2725
|
+
row = availableRow;
|
|
2726
|
+
}
|
|
2727
|
+
usedRows.add(row);
|
|
2728
|
+
setRenderRow(event, dayIndex, row);
|
|
2729
|
+
});
|
|
2730
|
+
}
|
|
2731
|
+
return events.flatMap((event) => {
|
|
2732
|
+
const eventRange = eventRanges.get(event);
|
|
2733
|
+
const eventRenderRows = renderRows.get(event);
|
|
2734
|
+
const segments = [];
|
|
2735
|
+
let currentSegment = null;
|
|
2736
|
+
const addSegment = (segment) => {
|
|
2737
|
+
const position = getSegmentPosition(event, segment, eventRange);
|
|
2738
|
+
segments.push({
|
|
2739
|
+
event,
|
|
2740
|
+
position,
|
|
2741
|
+
clipStart: segment.startDayIndex > eventRange.startDayIndex,
|
|
2742
|
+
clipEnd: segment.endDayIndex < eventRange.endDayIndex,
|
|
2743
|
+
key: `${event.id}-${event.position.weekIndex}-${segment.startDayIndex}-${segment.endDayIndex}-${segment.row}`
|
|
2744
|
+
});
|
|
2745
|
+
};
|
|
2746
|
+
for (let dayIndex = eventRange.startDayIndex; dayIndex <= eventRange.endDayIndex; dayIndex += 1) {
|
|
2747
|
+
const row = eventRenderRows?.get(dayIndex);
|
|
2748
|
+
if (row === void 0) {
|
|
2749
|
+
if (currentSegment) {
|
|
2750
|
+
addSegment(currentSegment);
|
|
2751
|
+
currentSegment = null;
|
|
2752
|
+
}
|
|
2753
|
+
continue;
|
|
2754
|
+
}
|
|
2755
|
+
if (currentSegment && currentSegment.row === row) currentSegment.endDayIndex = dayIndex;
|
|
2756
|
+
else {
|
|
2757
|
+
if (currentSegment) addSegment(currentSegment);
|
|
2758
|
+
currentSegment = {
|
|
2759
|
+
startDayIndex: dayIndex,
|
|
2760
|
+
endDayIndex: dayIndex,
|
|
2761
|
+
row
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
if (currentSegment) addSegment(currentSegment);
|
|
2766
|
+
return segments;
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
var MonthView_module_default = {
|
|
2770
|
+
monthView: "_monthView_2aohq_1",
|
|
2771
|
+
monthViewWeekdays: "_monthViewWeekdays_2aohq_21",
|
|
2772
|
+
monthViewWeek: "_monthViewWeek_2aohq_21",
|
|
2773
|
+
monthViewWeekNumber: "_monthViewWeekNumber_2aohq_31",
|
|
2774
|
+
monthViewWeekday: "_monthViewWeekday_2aohq_21",
|
|
2775
|
+
monthViewWeekdaysCorner: "_monthViewWeekdaysCorner_2aohq_107",
|
|
2776
|
+
monthViewDay: "_monthViewDay_2aohq_114",
|
|
2777
|
+
monthViewDayLabel: "_monthViewDayLabel_2aohq_255",
|
|
2778
|
+
monthViewBackgroundEvent: "_monthViewBackgroundEvent_2aohq_271",
|
|
2779
|
+
monthViewEvents: "_monthViewEvents_2aohq_286"
|
|
2780
|
+
};
|
|
2781
|
+
//#endregion
|
|
2782
|
+
//#region src/components/MonthView/MonthView.ts
|
|
2783
|
+
var MonthView = (0, vue.defineComponent)({
|
|
2784
|
+
name: "MonthView",
|
|
2785
|
+
inheritAttrs: false,
|
|
2786
|
+
slots: Object,
|
|
2787
|
+
props: {
|
|
2788
|
+
...baseViewProps,
|
|
2789
|
+
firstDayOfWeek: {
|
|
2790
|
+
type: Number,
|
|
2791
|
+
default: 1
|
|
2792
|
+
},
|
|
2793
|
+
weekdayFormat: {
|
|
2794
|
+
type: [String, Function],
|
|
2795
|
+
default: "ddd"
|
|
2796
|
+
},
|
|
2797
|
+
weekendDays: {
|
|
2798
|
+
type: Array,
|
|
2799
|
+
default: () => [0, 6]
|
|
2800
|
+
},
|
|
2801
|
+
withWeekNumbers: Boolean,
|
|
2802
|
+
withWeekDays: {
|
|
2803
|
+
type: Boolean,
|
|
2804
|
+
default: true
|
|
2805
|
+
},
|
|
2806
|
+
consistentWeeks: {
|
|
2807
|
+
type: Boolean,
|
|
2808
|
+
default: true
|
|
2809
|
+
},
|
|
2810
|
+
highlightToday: {
|
|
2811
|
+
type: Boolean,
|
|
2812
|
+
default: true
|
|
2813
|
+
},
|
|
2814
|
+
withOutsideDays: {
|
|
2815
|
+
type: Boolean,
|
|
2816
|
+
default: true
|
|
2817
|
+
},
|
|
2818
|
+
maxEventsPerDay: {
|
|
2819
|
+
type: Number,
|
|
2820
|
+
default: 2
|
|
2821
|
+
},
|
|
2822
|
+
getDayProps: Function,
|
|
2823
|
+
getWeekNumberProps: Function,
|
|
2824
|
+
onDayClick: Function,
|
|
2825
|
+
onWeekNumberClick: Function,
|
|
2826
|
+
withEventsDragAndDrop: Boolean,
|
|
2827
|
+
onEventDrop: Function,
|
|
2828
|
+
canDragEvent: Function,
|
|
2829
|
+
onEventDragStart: Function,
|
|
2830
|
+
onEventDragEnd: Function,
|
|
2831
|
+
onExternalEventDrop: Function,
|
|
2832
|
+
withDragSlotSelect: Boolean,
|
|
2833
|
+
onSlotDragEnd: Function
|
|
2834
|
+
},
|
|
2835
|
+
setup(props, { attrs, slots }) {
|
|
2836
|
+
const monthGrid = (0, vue.ref)(null);
|
|
2837
|
+
const dropTarget = (0, vue.ref)(null);
|
|
2838
|
+
const monthGroup = "month";
|
|
2839
|
+
const flatDays = (0, vue.ref)([]);
|
|
2840
|
+
const slotDragSelect = useSlotDragSelect({
|
|
2841
|
+
enabled: () => props.withDragSlotSelect && props.mode !== "static",
|
|
2842
|
+
onDragEnd: () => props.onSlotDragEnd ? (startIndex, endIndex) => {
|
|
2843
|
+
const startDay = flatDays.value[startIndex];
|
|
2844
|
+
const endDay = flatDays.value[endIndex];
|
|
2845
|
+
if (startDay && endDay) props.onSlotDragEnd?.((0, dayjs.default)(startDay).startOf("day").format("YYYY-MM-DD HH:mm:ss"), (0, dayjs.default)(endDay).endOf("day").format("YYYY-MM-DD HH:mm:ss"));
|
|
2846
|
+
} : void 0
|
|
2847
|
+
});
|
|
2848
|
+
return () => {
|
|
2849
|
+
const month = (0, dayjs.default)(props.date).startOf("month");
|
|
2850
|
+
const maxEventsPerDay = Math.min(10, Math.max(1, props.maxEventsPerDay));
|
|
2851
|
+
const weeks = getMonthDays({
|
|
2852
|
+
month,
|
|
2853
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
2854
|
+
consistentWeeks: props.consistentWeeks
|
|
2855
|
+
});
|
|
2856
|
+
flatDays.value = weeks.flat().map((date) => toDateString(date));
|
|
2857
|
+
const firstFocusableDayIndex = weeks.flat().findIndex((date) => props.withOutsideDays || (0, dayjs.default)(date).isSame(month, "month"));
|
|
2858
|
+
const withSlotSelect = props.withDragSlotSelect && props.mode !== "static";
|
|
2859
|
+
const rangeStart = weeks[0][0];
|
|
2860
|
+
const rangeEnd = weeks.at(-1).at(-1);
|
|
2861
|
+
const expanded = getExpandedEvents(props.events, rangeStart, (0, dayjs.default)(rangeEnd).endOf("day").format("YYYY-MM-DD HH:mm:ss"), props.recurrenceExpansionLimit);
|
|
2862
|
+
const grouped = getMonthViewEvents({
|
|
2863
|
+
date: month,
|
|
2864
|
+
events: expanded,
|
|
2865
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
2866
|
+
withOutsideDays: props.withOutsideDays,
|
|
2867
|
+
consistentWeeks: props.consistentWeeks
|
|
2868
|
+
});
|
|
2869
|
+
const weekdays = getWeekdaysNames({
|
|
2870
|
+
locale: props.locale || "en",
|
|
2871
|
+
format: props.weekdayFormat,
|
|
2872
|
+
firstDayOfWeek: props.firstDayOfWeek
|
|
2873
|
+
});
|
|
2874
|
+
const withDragHandlers = props.mode !== "static" && (props.withEventsDragAndDrop || Boolean(props.onExternalEventDrop));
|
|
2875
|
+
const dragOver = (nativeEvent, date) => {
|
|
2876
|
+
nativeEvent.preventDefault();
|
|
2877
|
+
dropTarget.value = toDateString(date);
|
|
2878
|
+
if (nativeEvent.dataTransfer) nativeEvent.dataTransfer.dropEffect = nativeEvent.dataTransfer.types.includes("application/json") ? "move" : "copy";
|
|
2879
|
+
};
|
|
2880
|
+
const dragLeave = (nativeEvent) => {
|
|
2881
|
+
if (!(nativeEvent.relatedTarget instanceof Node) || !monthGrid.value?.contains(nativeEvent.relatedTarget)) dropTarget.value = null;
|
|
2882
|
+
};
|
|
2883
|
+
const drop = (nativeEvent, date) => {
|
|
2884
|
+
nativeEvent.preventDefault();
|
|
2885
|
+
dropTarget.value = null;
|
|
2886
|
+
const event = getDropEvent(expanded, nativeEvent.dataTransfer);
|
|
2887
|
+
if (event) {
|
|
2888
|
+
const { start } = calculateMonthDropDate({
|
|
2889
|
+
draggedEvent: event,
|
|
2890
|
+
targetDay: toDateString(date)
|
|
2891
|
+
});
|
|
2892
|
+
props.onEventDrop?.(moveEventTo(event, start));
|
|
2893
|
+
} else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.(nativeEvent.dataTransfer, toDateString(date));
|
|
2894
|
+
};
|
|
2895
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
2896
|
+
...attrs,
|
|
2897
|
+
class: [MonthView_module_default.monthView, attrs.class],
|
|
2898
|
+
style: [{
|
|
2899
|
+
"--month-view-radius": resolveScheduleRadius(props.radius),
|
|
2900
|
+
"--month-view-max-events": String(maxEventsPerDay)
|
|
2901
|
+
}, attrs.style],
|
|
2902
|
+
mod: {
|
|
2903
|
+
"with-week-numbers": props.withWeekNumbers,
|
|
2904
|
+
"with-weekdays": props.withWeekDays,
|
|
2905
|
+
static: props.mode === "static",
|
|
2906
|
+
"slot-dragging": slotDragSelect.isDragging()
|
|
2907
|
+
}
|
|
2908
|
+
}, () => [props.withHeader ? (0, vue.h)(ScheduleHeaderBase, {
|
|
2909
|
+
view: "month",
|
|
2910
|
+
labels: props.labels,
|
|
2911
|
+
onDateChange: props.onDateChange,
|
|
2912
|
+
onViewChange: props.onViewChange,
|
|
2913
|
+
navigationHandlers: createHeaderNavigation(props.date, "month"),
|
|
2914
|
+
previousControlProps: props.previousControlProps,
|
|
2915
|
+
nextControlProps: props.nextControlProps,
|
|
2916
|
+
todayControlProps: props.todayControlProps,
|
|
2917
|
+
viewSelectProps: props.viewSelectProps,
|
|
2918
|
+
control: { monthYearSelect: {
|
|
2919
|
+
locale: props.locale,
|
|
2920
|
+
monthValue: month.month(),
|
|
2921
|
+
yearValue: month.year(),
|
|
2922
|
+
onMonthChange: (value) => props.onDateChange?.(toDateString(month.month(value))),
|
|
2923
|
+
onYearChange: (value) => props.onDateChange?.(toDateString(month.year(value)))
|
|
2924
|
+
} }
|
|
2925
|
+
}) : null, (0, vue.h)(_mantine_vue_core.ScrollArea, {
|
|
2926
|
+
class: MonthView_module_default.monthViewScrollArea,
|
|
2927
|
+
scrollbarSize: 4
|
|
2928
|
+
}, () => (0, vue.h)("div", {
|
|
2929
|
+
ref: monthGrid,
|
|
2930
|
+
class: MonthView_module_default.monthViewInner
|
|
2931
|
+
}, [props.withWeekDays ? (0, vue.h)("div", { class: MonthView_module_default.monthViewWeekdays }, [props.withWeekNumbers ? (0, vue.h)("div", { class: MonthView_module_default.monthViewWeekdaysCorner }) : null, ...weekdays.map((weekday) => (0, vue.h)("div", { class: MonthView_module_default.monthViewWeekday }, [weekday]))]) : null, ...weeks.map((week, weekIndex) => {
|
|
2932
|
+
const segments = getRenderableMonthEventSegments({
|
|
2933
|
+
events: grouped.groupedByWeek[String(weekIndex)] || [],
|
|
2934
|
+
groupedByDay: grouped.groupedByDay,
|
|
2935
|
+
maxEventsPerDay,
|
|
2936
|
+
week
|
|
2937
|
+
});
|
|
2938
|
+
return (0, vue.h)("div", { class: MonthView_module_default.monthViewWeek }, [
|
|
2939
|
+
props.withWeekNumbers ? (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2940
|
+
type: "button",
|
|
2941
|
+
class: MonthView_module_default.monthViewWeekNumber,
|
|
2942
|
+
...props.getWeekNumberProps?.(toDateString(week[0])),
|
|
2943
|
+
onClick: (event) => props.onWeekNumberClick?.(toDateString(week[0]), event)
|
|
2944
|
+
}, () => String(getWeekNumber(week))) : null,
|
|
2945
|
+
...week.map((date, dayIndex) => {
|
|
2946
|
+
const dateKey = (0, dayjs.default)(date).format("YYYY-MM-DD 00:00:00");
|
|
2947
|
+
const dayProps = props.getDayProps?.(toDateString(date)) || {};
|
|
2948
|
+
const events = grouped.groupedByDay[dateKey] || [];
|
|
2949
|
+
const hiddenCount = Math.max(0, events.length - maxEventsPerDay);
|
|
2950
|
+
const outside = !(0, dayjs.default)(date).isSame(month, "month");
|
|
2951
|
+
const gridIndex = weekIndex * 7 + dayIndex;
|
|
2952
|
+
return (0, vue.h)("div", {
|
|
2953
|
+
class: MonthView_module_default.monthViewDay,
|
|
2954
|
+
"data-outside": outside || void 0,
|
|
2955
|
+
"data-weekend": props.weekendDays.includes((0, dayjs.default)(date).day()) || void 0,
|
|
2956
|
+
"data-static": props.mode === "static" || void 0,
|
|
2957
|
+
"data-drop-target": dropTarget.value === toDateString(date) || void 0,
|
|
2958
|
+
"data-drag-selected": slotDragSelect.isSlotSelected(gridIndex, monthGroup) || void 0,
|
|
2959
|
+
"data-drag-slot-index": withSlotSelect ? gridIndex : void 0,
|
|
2960
|
+
"data-drag-slot-group": withSlotSelect ? monthGroup : void 0,
|
|
2961
|
+
onPointerdown: withSlotSelect ? (event) => slotDragSelect.handleSlotPointerDown(event, gridIndex, monthGroup) : void 0,
|
|
2962
|
+
onDragover: withDragHandlers ? (event) => dragOver(event, date) : (event) => event.preventDefault(),
|
|
2963
|
+
onDragleave: withDragHandlers ? dragLeave : void 0,
|
|
2964
|
+
onDrop: (event) => drop(event, date)
|
|
2965
|
+
}, [(0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
2966
|
+
type: "button",
|
|
2967
|
+
...dayProps,
|
|
2968
|
+
class: [MonthView_module_default.monthViewDayLabel, dayProps.class],
|
|
2969
|
+
disabled: props.mode === "static",
|
|
2970
|
+
"data-grid-index": gridIndex,
|
|
2971
|
+
"data-outside": outside || void 0,
|
|
2972
|
+
"data-hidden": outside && !props.withOutsideDays || void 0,
|
|
2973
|
+
"aria-label": formatDate({
|
|
2974
|
+
date,
|
|
2975
|
+
locale: props.locale || "en",
|
|
2976
|
+
format: "MMMM D, YYYY"
|
|
2977
|
+
}),
|
|
2978
|
+
"data-today": props.highlightToday && (0, dayjs.default)(date).isSame((0, dayjs.default)(), "day") || void 0,
|
|
2979
|
+
onClick: (event) => props.onDayClick?.(toDateString(date), event),
|
|
2980
|
+
tabindex: props.mode === "static" ? -1 : gridIndex === firstFocusableDayIndex ? 0 : -1,
|
|
2981
|
+
onKeydown: props.mode === "static" ? void 0 : (event) => {
|
|
2982
|
+
handleGridKeydown({
|
|
2983
|
+
event,
|
|
2984
|
+
index: gridIndex,
|
|
2985
|
+
columns: 7,
|
|
2986
|
+
total: weeks.length * 7,
|
|
2987
|
+
getControl: (index) => monthGrid.value?.querySelector(`[data-grid-index="${index}"]:not([data-hidden])`) ?? null
|
|
2988
|
+
});
|
|
2989
|
+
dayProps.onKeydown?.(event);
|
|
2990
|
+
}
|
|
2991
|
+
}, () => outside && !props.withOutsideDays ? "" : String((0, dayjs.default)(date).date())), hiddenCount > 0 ? (0, vue.h)(MoreEvents, {
|
|
2992
|
+
events,
|
|
2993
|
+
moreEventsCount: hiddenCount,
|
|
2994
|
+
labels: props.labels,
|
|
2995
|
+
renderEvent: props.renderEvent,
|
|
2996
|
+
renderEventBody: props.renderEventBody,
|
|
2997
|
+
onEventClick: props.onEventClick,
|
|
2998
|
+
mode: props.mode
|
|
2999
|
+
}, forwardEventSlots(slots)) : null]);
|
|
3000
|
+
}),
|
|
3001
|
+
(0, vue.h)("div", { class: MonthView_module_default.monthViewEvents }, segments.map((segment) => eventNode(segment.event, props, {
|
|
3002
|
+
key: segment.key,
|
|
3003
|
+
nowrap: true,
|
|
3004
|
+
hanging: segment.position.hanging,
|
|
3005
|
+
"data-clip-start": segment.clipStart || void 0,
|
|
3006
|
+
"data-clip-end": segment.clipEnd || void 0,
|
|
3007
|
+
style: {
|
|
3008
|
+
position: "absolute",
|
|
3009
|
+
insetInlineStart: `${segment.position.startOffset}%`,
|
|
3010
|
+
width: `${segment.position.width}%`,
|
|
3011
|
+
top: `${28 + segment.position.row * 22}px`
|
|
3012
|
+
}
|
|
3013
|
+
}, slots)))
|
|
3014
|
+
]);
|
|
3015
|
+
})]))]);
|
|
3016
|
+
};
|
|
3017
|
+
}
|
|
3018
|
+
});
|
|
3019
|
+
//#endregion
|
|
3020
|
+
//#region src/components/WeekView/get-week-label/get-week-label.ts
|
|
3021
|
+
function getWeekLabel({ weekdays, locale, weekLabelFormat, renderWeekLabel }) {
|
|
3022
|
+
if (renderWeekLabel) return renderWeekLabel({
|
|
3023
|
+
weekStart: (0, dayjs.default)(weekdays[0]).format("YYYY-MM-DD"),
|
|
3024
|
+
weekEnd: (0, dayjs.default)(weekdays[weekdays.length - 1]).format("YYYY-MM-DD")
|
|
3025
|
+
});
|
|
3026
|
+
return `${formatDate({
|
|
3027
|
+
locale,
|
|
3028
|
+
date: weekdays[0],
|
|
3029
|
+
format: weekLabelFormat
|
|
3030
|
+
})} – ${formatDate({
|
|
3031
|
+
locale,
|
|
3032
|
+
date: weekdays[weekdays.length - 1],
|
|
3033
|
+
format: weekLabelFormat
|
|
3034
|
+
})}, ${formatDate({
|
|
3035
|
+
locale,
|
|
3036
|
+
date: weekdays[0],
|
|
3037
|
+
format: "YYYY"
|
|
3038
|
+
})}`;
|
|
3039
|
+
}
|
|
3040
|
+
//#endregion
|
|
3041
|
+
//#region src/components/WeekView/get-week-view-events/filter-week-view-events.ts
|
|
3042
|
+
function filterWeekViewEvents({ date, events, startTime, endTime, firstDayOfWeek = 1 }) {
|
|
3043
|
+
if (events === void 0) return [];
|
|
3044
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3045
|
+
const filteredEvents = [];
|
|
3046
|
+
for (const event of events) if (isWithinWeek({
|
|
3047
|
+
event,
|
|
3048
|
+
targetWeek: date,
|
|
3049
|
+
firstDayOfWeek
|
|
3050
|
+
}) && isEventInTimeRange({
|
|
3051
|
+
event,
|
|
3052
|
+
startTime,
|
|
3053
|
+
endTime
|
|
3054
|
+
})) {
|
|
3055
|
+
filteredEvents.push(validateEvent(event));
|
|
3056
|
+
if (!ids.has(event.id)) ids.add(event.id);
|
|
3057
|
+
else throw new Error(`[@mantine/schedule] WeekView: Duplicated event ids found: ${event.id}`);
|
|
3058
|
+
}
|
|
3059
|
+
return filteredEvents;
|
|
3060
|
+
}
|
|
3061
|
+
//#endregion
|
|
3062
|
+
//#region src/components/WeekView/get-week-view-events/assign-event-rows.ts
|
|
3063
|
+
function assignEventRows(events) {
|
|
3064
|
+
const eventRows = /* @__PURE__ */ new Map();
|
|
3065
|
+
for (const event of events) {
|
|
3066
|
+
let row = 0;
|
|
3067
|
+
while (true) {
|
|
3068
|
+
let hasConflict = false;
|
|
3069
|
+
for (const [otherEvent, otherRow] of eventRows.entries()) if (otherRow === row && isEventsOverlap(event, otherEvent)) {
|
|
3070
|
+
hasConflict = true;
|
|
3071
|
+
break;
|
|
3072
|
+
}
|
|
3073
|
+
if (!hasConflict) break;
|
|
3074
|
+
row++;
|
|
3075
|
+
}
|
|
3076
|
+
eventRows.set(event, row);
|
|
3077
|
+
}
|
|
3078
|
+
return eventRows;
|
|
3079
|
+
}
|
|
3080
|
+
//#endregion
|
|
3081
|
+
//#region src/components/WeekView/get-week-view-events/calculate-all-day-event-offset.ts
|
|
3082
|
+
function calculateAllDayEventOffset({ eventStartDate, weekStartDate, weekDays, visibleDaysCount, hangingStart }) {
|
|
3083
|
+
let displayStartDate = eventStartDate;
|
|
3084
|
+
if (hangingStart) displayStartDate = weekStartDate;
|
|
3085
|
+
if (!weekDays.some((day) => (0, dayjs.default)(day).isSame(displayStartDate, "day"))) displayStartDate = (0, dayjs.default)(weekDays[0]);
|
|
3086
|
+
return (weekDays.filter((day) => (0, dayjs.default)(day).isBefore(displayStartDate) || (0, dayjs.default)(day).isSame(displayStartDate, "day")).length - 1) / visibleDaysCount * 100;
|
|
3087
|
+
}
|
|
3088
|
+
//#endregion
|
|
3089
|
+
//#region src/components/WeekView/get-week-view-events/calculate-all-day-event-width.ts
|
|
3090
|
+
function calculateAllDayEventWidth({ eventStartDate, actualEndDate, weekStartDate, weekEndDate, weekDays, visibleDaysCount }) {
|
|
3091
|
+
let displayStartDate = eventStartDate;
|
|
3092
|
+
if (eventStartDate.isBefore(weekStartDate)) displayStartDate = weekStartDate;
|
|
3093
|
+
let displayEndDate = actualEndDate;
|
|
3094
|
+
if (actualEndDate.isAfter(weekEndDate)) displayEndDate = weekEndDate;
|
|
3095
|
+
return weekDays.filter((day) => ((0, dayjs.default)(day).isAfter(displayStartDate) || (0, dayjs.default)(day).isSame(displayStartDate, "day")) && ((0, dayjs.default)(day).isBefore(displayEndDate) || (0, dayjs.default)(day).isSame(displayEndDate, "day"))).length / visibleDaysCount * 100;
|
|
3096
|
+
}
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region src/components/WeekView/get-week-view-events/calculate-event-days.ts
|
|
3099
|
+
function calculateEventDays({ event, weekDays, actualEndDate }) {
|
|
3100
|
+
const eventStartDate = (0, dayjs.default)(event.start).startOf("day");
|
|
3101
|
+
return weekDays.filter((day) => {
|
|
3102
|
+
const dayDate = (0, dayjs.default)(day).startOf("day");
|
|
3103
|
+
return (dayDate.isAfter(eventStartDate) || dayDate.isSame(eventStartDate)) && (dayDate.isBefore(actualEndDate) || dayDate.isSame(actualEndDate));
|
|
3104
|
+
});
|
|
3105
|
+
}
|
|
3106
|
+
//#endregion
|
|
3107
|
+
//#region src/components/WeekView/get-week-view-events/calculate-regular-event-overlaps.ts
|
|
3108
|
+
function calculateRegularEventOverlaps(events) {
|
|
3109
|
+
for (const event of events) {
|
|
3110
|
+
let maxOverlappingColumn = event.position.column;
|
|
3111
|
+
for (const otherEvent of events) if (isEventsOverlap(event, otherEvent)) maxOverlappingColumn = Math.max(maxOverlappingColumn, otherEvent.position.column);
|
|
3112
|
+
const overlaps = maxOverlappingColumn + 1;
|
|
3113
|
+
event.position.overlaps = overlaps;
|
|
3114
|
+
event.position.width = 100 / overlaps;
|
|
3115
|
+
event.position.offset = event.position.column * 100 / overlaps;
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
//#endregion
|
|
3119
|
+
//#region src/components/WeekView/get-week-view-events/find-available-column.ts
|
|
3120
|
+
function columnHasConflict({ columns, columnIndex, event, allDay, allWeekDays }) {
|
|
3121
|
+
const columnKey = `col-${columnIndex}`;
|
|
3122
|
+
if (!columns.has(columnKey)) return false;
|
|
3123
|
+
return columns.get(columnKey).some((e) => {
|
|
3124
|
+
const eAllDay = allWeekDays.some((day) => isAllDayEvent({
|
|
3125
|
+
event: e,
|
|
3126
|
+
date: day
|
|
3127
|
+
}));
|
|
3128
|
+
const hasTimeConflict = isEventsOverlap(e, event);
|
|
3129
|
+
if (allDay && eAllDay) return hasTimeConflict;
|
|
3130
|
+
if (allDay || eAllDay) return false;
|
|
3131
|
+
return hasTimeConflict;
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
function findAvailableColumn(input) {
|
|
3135
|
+
let column = 0;
|
|
3136
|
+
while (columnHasConflict({
|
|
3137
|
+
...input,
|
|
3138
|
+
columnIndex: column
|
|
3139
|
+
})) column++;
|
|
3140
|
+
return column;
|
|
3141
|
+
}
|
|
3142
|
+
//#endregion
|
|
3143
|
+
//#region src/components/WeekView/get-week-view-events/get-event-end-date.ts
|
|
3144
|
+
function getEventEndDate(event) {
|
|
3145
|
+
const eventEndDate = (0, dayjs.default)(event.end).startOf("day");
|
|
3146
|
+
if ((0, dayjs.default)(event.end).hour() === 0 && (0, dayjs.default)(event.end).minute() === 0) return eventEndDate.subtract(1, "day");
|
|
3147
|
+
return eventEndDate;
|
|
3148
|
+
}
|
|
3149
|
+
//#endregion
|
|
3150
|
+
//#region src/components/WeekView/get-week-view-events/get-hanging-status.ts
|
|
3151
|
+
function getHangingStatus({ eventStartDate, actualEndDate, weekDays }) {
|
|
3152
|
+
const weekStartDate = (0, dayjs.default)(weekDays[0]);
|
|
3153
|
+
const weekEndDate = (0, dayjs.default)(weekDays[weekDays.length - 1]);
|
|
3154
|
+
const hangingStart = eventStartDate.isBefore(weekStartDate);
|
|
3155
|
+
const hangingEnd = actualEndDate.isAfter(weekEndDate);
|
|
3156
|
+
if (hangingStart && hangingEnd) return "both";
|
|
3157
|
+
if (hangingStart) return "start";
|
|
3158
|
+
if (hangingEnd) return "end";
|
|
3159
|
+
return "none";
|
|
3160
|
+
}
|
|
3161
|
+
//#endregion
|
|
3162
|
+
//#region src/components/WeekView/get-week-view-events/get-week-positioned-events.ts
|
|
3163
|
+
function getWeekPositionedEvents({ date, events, startTime, endTime, intervalMinutes, firstDayOfWeek = 1, weekendDays = [0, 6], withWeekendDays = true }) {
|
|
3164
|
+
const weekDays = getWeekDays({
|
|
3165
|
+
week: date,
|
|
3166
|
+
firstDayOfWeek,
|
|
3167
|
+
withWeekendDays,
|
|
3168
|
+
weekendDays
|
|
3169
|
+
});
|
|
3170
|
+
const visibleDaysCount = weekDays.length;
|
|
3171
|
+
const weekStartDate = (0, dayjs.default)(weekDays[0]);
|
|
3172
|
+
const weekEndDate = (0, dayjs.default)(weekDays[weekDays.length - 1]);
|
|
3173
|
+
const grouped = {
|
|
3174
|
+
allDayEvents: [],
|
|
3175
|
+
regularEvents: Object.fromEntries(weekDays.map((day) => [day, []])),
|
|
3176
|
+
backgroundEvents: Object.fromEntries(weekDays.map((day) => [day, []]))
|
|
3177
|
+
};
|
|
3178
|
+
const columns = /* @__PURE__ */ new Map();
|
|
3179
|
+
const allDayColumns = /* @__PURE__ */ new Map();
|
|
3180
|
+
const sorted = sortEvents(events);
|
|
3181
|
+
for (const event of sorted) {
|
|
3182
|
+
if (event.display === "background") {
|
|
3183
|
+
const eventStartDate = (0, dayjs.default)(event.start).startOf("day");
|
|
3184
|
+
const actualEndDate = getEventEndDate(event);
|
|
3185
|
+
const eventWeekDays = calculateEventDays({
|
|
3186
|
+
event,
|
|
3187
|
+
weekDays,
|
|
3188
|
+
actualEndDate
|
|
3189
|
+
});
|
|
3190
|
+
const hanging = getHangingStatus({
|
|
3191
|
+
eventStartDate,
|
|
3192
|
+
actualEndDate,
|
|
3193
|
+
weekDays
|
|
3194
|
+
});
|
|
3195
|
+
for (const day of eventWeekDays) {
|
|
3196
|
+
const visibleDayIndex = weekDays.indexOf(day);
|
|
3197
|
+
if (visibleDayIndex === -1) continue;
|
|
3198
|
+
const dayStart = (0, dayjs.default)(day);
|
|
3199
|
+
const dayEnd = dayStart.endOf("day");
|
|
3200
|
+
const eventStart = (0, dayjs.default)(event.start);
|
|
3201
|
+
const eventEnd = (0, dayjs.default)(event.end);
|
|
3202
|
+
const clippedStart = eventStart.isBefore(dayStart) ? dayStart : eventStart;
|
|
3203
|
+
const clippedEnd = eventEnd.isAfter(dayEnd) ? dayEnd : eventEnd;
|
|
3204
|
+
const clippedEvent = {
|
|
3205
|
+
...event,
|
|
3206
|
+
start: clippedStart.format("YYYY-MM-DD HH:mm:ss"),
|
|
3207
|
+
end: clippedEnd.format("YYYY-MM-DD HH:mm:ss")
|
|
3208
|
+
};
|
|
3209
|
+
const isAllDay = isAllDayEvent({
|
|
3210
|
+
event: clippedEvent,
|
|
3211
|
+
date: day
|
|
3212
|
+
});
|
|
3213
|
+
const verticalPosition = isAllDay ? {
|
|
3214
|
+
top: 0,
|
|
3215
|
+
height: 100
|
|
3216
|
+
} : getDayPosition({
|
|
3217
|
+
event: clippedEvent,
|
|
3218
|
+
startTime,
|
|
3219
|
+
endTime,
|
|
3220
|
+
intervalMinutes
|
|
3221
|
+
});
|
|
3222
|
+
if (!isAllDay && verticalPosition.height <= 0) continue;
|
|
3223
|
+
const dayWeekOffset = visibleDayIndex / visibleDaysCount * 100;
|
|
3224
|
+
grouped.backgroundEvents[day].push({
|
|
3225
|
+
...event,
|
|
3226
|
+
position: {
|
|
3227
|
+
...verticalPosition,
|
|
3228
|
+
allDay: isAllDay,
|
|
3229
|
+
column: 0,
|
|
3230
|
+
width: 100,
|
|
3231
|
+
offset: 0,
|
|
3232
|
+
overlaps: 1,
|
|
3233
|
+
weekOffset: dayWeekOffset,
|
|
3234
|
+
row: 0,
|
|
3235
|
+
hanging
|
|
3236
|
+
}
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
continue;
|
|
3240
|
+
}
|
|
3241
|
+
const eventStartDate = (0, dayjs.default)(event.start).startOf("day");
|
|
3242
|
+
const actualEndDate = getEventEndDate(event);
|
|
3243
|
+
const eventWeekDays = calculateEventDays({
|
|
3244
|
+
event,
|
|
3245
|
+
weekDays,
|
|
3246
|
+
actualEndDate
|
|
3247
|
+
});
|
|
3248
|
+
if (eventWeekDays.length === 0) continue;
|
|
3249
|
+
const isMultiday = actualEndDate.isAfter(eventStartDate);
|
|
3250
|
+
const hanging = getHangingStatus({
|
|
3251
|
+
eventStartDate,
|
|
3252
|
+
actualEndDate,
|
|
3253
|
+
weekDays
|
|
3254
|
+
});
|
|
3255
|
+
const isActuallyAllDay = eventWeekDays.some((day) => isAllDayEvent({
|
|
3256
|
+
event,
|
|
3257
|
+
date: day
|
|
3258
|
+
}));
|
|
3259
|
+
const allDay = isMultiday || isActuallyAllDay;
|
|
3260
|
+
const columnMap = allDay ? allDayColumns : columns;
|
|
3261
|
+
const column = findAvailableColumn({
|
|
3262
|
+
columns: columnMap,
|
|
3263
|
+
event,
|
|
3264
|
+
allDay,
|
|
3265
|
+
allWeekDays: weekDays
|
|
3266
|
+
});
|
|
3267
|
+
const columnKey = `col-${column}`;
|
|
3268
|
+
if (!columnMap.has(columnKey)) columnMap.set(columnKey, []);
|
|
3269
|
+
columnMap.get(columnKey).push(event);
|
|
3270
|
+
const verticalPosition = allDay ? {
|
|
3271
|
+
top: 0,
|
|
3272
|
+
height: 100
|
|
3273
|
+
} : getDayPosition({
|
|
3274
|
+
event,
|
|
3275
|
+
startTime,
|
|
3276
|
+
endTime,
|
|
3277
|
+
intervalMinutes
|
|
3278
|
+
});
|
|
3279
|
+
if (allDay) {
|
|
3280
|
+
const offset = calculateAllDayEventOffset({
|
|
3281
|
+
eventStartDate,
|
|
3282
|
+
weekStartDate,
|
|
3283
|
+
weekDays,
|
|
3284
|
+
visibleDaysCount,
|
|
3285
|
+
hangingStart: hanging === "start" || hanging === "both"
|
|
3286
|
+
});
|
|
3287
|
+
grouped.allDayEvents.push({
|
|
3288
|
+
...event,
|
|
3289
|
+
position: {
|
|
3290
|
+
...verticalPosition,
|
|
3291
|
+
allDay,
|
|
3292
|
+
column,
|
|
3293
|
+
width: 0,
|
|
3294
|
+
offset,
|
|
3295
|
+
overlaps: 0,
|
|
3296
|
+
row: 0,
|
|
3297
|
+
hanging
|
|
3298
|
+
}
|
|
3299
|
+
});
|
|
3300
|
+
} else for (const day of eventWeekDays) {
|
|
3301
|
+
const visibleDayIndex = weekDays.indexOf(day);
|
|
3302
|
+
if (visibleDayIndex === -1) continue;
|
|
3303
|
+
const dayWeekOffset = visibleDayIndex / visibleDaysCount * 100;
|
|
3304
|
+
grouped.regularEvents[day].push({
|
|
3305
|
+
...event,
|
|
3306
|
+
position: {
|
|
3307
|
+
...verticalPosition,
|
|
3308
|
+
allDay,
|
|
3309
|
+
column,
|
|
3310
|
+
width: 0,
|
|
3311
|
+
offset: 0,
|
|
3312
|
+
overlaps: 0,
|
|
3313
|
+
weekOffset: dayWeekOffset,
|
|
3314
|
+
row: 0,
|
|
3315
|
+
hanging
|
|
3316
|
+
}
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
for (const day of weekDays) calculateRegularEventOverlaps(grouped.regularEvents[day]);
|
|
3321
|
+
if (grouped.allDayEvents.length > 0) {
|
|
3322
|
+
const eventRows = assignEventRows(grouped.allDayEvents);
|
|
3323
|
+
const assignedRows = /* @__PURE__ */ new Set();
|
|
3324
|
+
for (const event of grouped.allDayEvents) {
|
|
3325
|
+
const row = eventRows.get(event);
|
|
3326
|
+
event.position.row = row;
|
|
3327
|
+
assignedRows.add(row);
|
|
3328
|
+
}
|
|
3329
|
+
const rowCount = Math.max(...assignedRows) + 1;
|
|
3330
|
+
for (const event of grouped.allDayEvents) {
|
|
3331
|
+
const eventStartDate = (0, dayjs.default)(event.start).startOf("day");
|
|
3332
|
+
const actualEndDate = getEventEndDate(event);
|
|
3333
|
+
event.position.width = calculateAllDayEventWidth({
|
|
3334
|
+
eventStartDate,
|
|
3335
|
+
actualEndDate,
|
|
3336
|
+
weekStartDate,
|
|
3337
|
+
weekEndDate,
|
|
3338
|
+
weekDays,
|
|
3339
|
+
visibleDaysCount
|
|
3340
|
+
});
|
|
3341
|
+
event.position.overlaps = rowCount;
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
return grouped;
|
|
3345
|
+
}
|
|
3346
|
+
//#endregion
|
|
3347
|
+
//#region src/components/WeekView/get-week-view-events/get-week-view-events.ts
|
|
3348
|
+
function getWeekViewEvents(input) {
|
|
3349
|
+
return getWeekPositionedEvents({
|
|
3350
|
+
...input,
|
|
3351
|
+
events: filterWeekViewEvents(input)
|
|
3352
|
+
});
|
|
3353
|
+
}
|
|
3354
|
+
var WeekView_module_default = {
|
|
3355
|
+
weekView: "_weekView_16qgh_1",
|
|
3356
|
+
weekViewRoot: "_weekViewRoot_16qgh_22",
|
|
3357
|
+
weekViewInner: "_weekViewInner_16qgh_30",
|
|
3358
|
+
weekViewScrollArea: "_weekViewScrollArea_16qgh_36",
|
|
3359
|
+
weekViewHeader: "_weekViewHeader_16qgh_42",
|
|
3360
|
+
weekViewCorner: "_weekViewCorner_16qgh_57",
|
|
3361
|
+
weekViewSlotLabels: "_weekViewSlotLabels_16qgh_68",
|
|
3362
|
+
weekViewSlotLabel: "_weekViewSlotLabel_16qgh_68",
|
|
3363
|
+
weekViewDay: "_weekViewDay_16qgh_95",
|
|
3364
|
+
weekViewDayLabel: "_weekViewDayLabel_16qgh_100",
|
|
3365
|
+
weekViewDayNumber: "_weekViewDayNumber_16qgh_138",
|
|
3366
|
+
weekViewDayWeekday: "_weekViewDayWeekday_16qgh_154",
|
|
3367
|
+
weekViewBackgroundEvent: "_weekViewBackgroundEvent_16qgh_160",
|
|
3368
|
+
weekViewDaySlots: "_weekViewDaySlots_16qgh_173",
|
|
3369
|
+
weekViewDaySlot: "_weekViewDaySlot_16qgh_173",
|
|
3370
|
+
weekViewWeekLabel: "_weekViewWeekLabel_16qgh_271",
|
|
3371
|
+
weekViewWeekNumber: "_weekViewWeekNumber_16qgh_277",
|
|
3372
|
+
weekViewAllDaySlots: "_weekViewAllDaySlots_16qgh_283",
|
|
3373
|
+
weekViewAllDaySlotsLabel: "_weekViewAllDaySlotsLabel_16qgh_288",
|
|
3374
|
+
weekViewAllDaySlotsEvents: "_weekViewAllDaySlotsEvents_16qgh_295",
|
|
3375
|
+
weekViewAllDaySlotsList: "_weekViewAllDaySlotsList_16qgh_302"
|
|
3376
|
+
};
|
|
3377
|
+
//#endregion
|
|
3378
|
+
//#region src/components/WeekView/WeekView.ts
|
|
3379
|
+
var WeekView = (0, vue.defineComponent)({
|
|
3380
|
+
name: "WeekView",
|
|
3381
|
+
inheritAttrs: false,
|
|
3382
|
+
slots: Object,
|
|
3383
|
+
props: {
|
|
3384
|
+
...timeViewProps,
|
|
3385
|
+
withCurrentTimeIndicator: {
|
|
3386
|
+
type: Boolean,
|
|
3387
|
+
default: true
|
|
3388
|
+
},
|
|
3389
|
+
forceCurrentTimeIndicator: Boolean,
|
|
3390
|
+
firstDayOfWeek: {
|
|
3391
|
+
type: Number,
|
|
3392
|
+
default: 1
|
|
3393
|
+
},
|
|
3394
|
+
weekdayFormat: {
|
|
3395
|
+
type: [String, Function],
|
|
3396
|
+
default: "ddd"
|
|
3397
|
+
},
|
|
3398
|
+
dayFormat: {
|
|
3399
|
+
type: [String, Function],
|
|
3400
|
+
default: "D"
|
|
3401
|
+
},
|
|
3402
|
+
withWeekNumber: {
|
|
3403
|
+
type: Boolean,
|
|
3404
|
+
default: true
|
|
3405
|
+
},
|
|
3406
|
+
withAllDaySlots: {
|
|
3407
|
+
type: Boolean,
|
|
3408
|
+
default: true
|
|
3409
|
+
},
|
|
3410
|
+
withWeekNumbers: {
|
|
3411
|
+
type: Boolean,
|
|
3412
|
+
default: void 0
|
|
3413
|
+
},
|
|
3414
|
+
withAllDaySlot: {
|
|
3415
|
+
type: Boolean,
|
|
3416
|
+
default: void 0
|
|
3417
|
+
},
|
|
3418
|
+
allDaySlotsHeight: {
|
|
3419
|
+
type: [String, Number],
|
|
3420
|
+
default: 44
|
|
3421
|
+
},
|
|
3422
|
+
maxAllDayEvents: {
|
|
3423
|
+
type: Number,
|
|
3424
|
+
default: 3
|
|
3425
|
+
},
|
|
3426
|
+
weekendDays: {
|
|
3427
|
+
type: Array,
|
|
3428
|
+
default: () => [0, 6]
|
|
3429
|
+
},
|
|
3430
|
+
withWeekendDays: {
|
|
3431
|
+
type: Boolean,
|
|
3432
|
+
default: true
|
|
3433
|
+
},
|
|
3434
|
+
weekLabelFormat: {
|
|
3435
|
+
type: [String, Function],
|
|
3436
|
+
default: "MMM D"
|
|
3437
|
+
},
|
|
3438
|
+
renderWeekLabel: Function
|
|
3439
|
+
},
|
|
3440
|
+
setup(props, { attrs, slots }) {
|
|
3441
|
+
const daySlotsContainers = /* @__PURE__ */ new Map();
|
|
3442
|
+
const dropTarget = (0, vue.ref)(null);
|
|
3443
|
+
const eventResize = useEventResize({
|
|
3444
|
+
enabled: () => props.withEventResize,
|
|
3445
|
+
mode: () => props.mode,
|
|
3446
|
+
startTime: () => props.startTime,
|
|
3447
|
+
endTime: () => props.endTime,
|
|
3448
|
+
intervalMinutes: () => props.intervalMinutes,
|
|
3449
|
+
onEventResize: () => props.onEventResize,
|
|
3450
|
+
canResizeEvent: () => props.canResizeEvent
|
|
3451
|
+
});
|
|
3452
|
+
const slotTimes = (0, vue.ref)([]);
|
|
3453
|
+
const slotDragSelect = useSlotDragSelect({
|
|
3454
|
+
enabled: () => props.withDragSlotSelect && props.mode !== "static",
|
|
3455
|
+
onDragEnd: () => props.onSlotDragEnd ? (startIndex, endIndex, group) => {
|
|
3456
|
+
const slotDate = (0, dayjs.default)(group).format("YYYY-MM-DD");
|
|
3457
|
+
const startSlot = slotTimes.value[startIndex];
|
|
3458
|
+
const endSlot = slotTimes.value[endIndex];
|
|
3459
|
+
if (startSlot && endSlot) props.onSlotDragEnd?.(`${slotDate} ${startSlot.startTime}`, `${slotDate} ${endSlot.endTime}`);
|
|
3460
|
+
} : void 0
|
|
3461
|
+
});
|
|
3462
|
+
return () => {
|
|
3463
|
+
const withWeekNumber = props.withWeekNumbers ?? props.withWeekNumber;
|
|
3464
|
+
const withAllDaySlots = props.withAllDaySlot ?? props.withAllDaySlots;
|
|
3465
|
+
const days = getWeekDays({
|
|
3466
|
+
week: props.date,
|
|
3467
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
3468
|
+
withWeekendDays: props.withWeekendDays,
|
|
3469
|
+
weekendDays: props.weekendDays
|
|
3470
|
+
});
|
|
3471
|
+
const now = (0, dayjs.default)(props.getCurrentTime?.() ?? (0, dayjs.default)());
|
|
3472
|
+
const currentWeekdayIndex = props.withCurrentTimeIndicator ? props.forceCurrentTimeIndicator ? days.findIndex((date) => (0, dayjs.default)(date).day() === now.day()) : days.findIndex((date) => (0, dayjs.default)(date).isSame(now, "day")) : -1;
|
|
3473
|
+
const expanded = getExpandedEvents(props.events, (0, dayjs.default)(days[0]).startOf("day").format("YYYY-MM-DD HH:mm:ss"), (0, dayjs.default)(days.at(-1)).endOf("day").format("YYYY-MM-DD HH:mm:ss"), props.recurrenceExpansionLimit);
|
|
3474
|
+
const grouped = getWeekViewEvents({
|
|
3475
|
+
date: props.date,
|
|
3476
|
+
events: expanded,
|
|
3477
|
+
startTime: props.startTime,
|
|
3478
|
+
endTime: props.endTime,
|
|
3479
|
+
intervalMinutes: props.intervalMinutes,
|
|
3480
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
3481
|
+
weekendDays: props.weekendDays,
|
|
3482
|
+
withWeekendDays: props.withWeekendDays
|
|
3483
|
+
});
|
|
3484
|
+
const intervals = getDayTimeIntervals({
|
|
3485
|
+
startTime: props.startTime,
|
|
3486
|
+
endTime: props.endTime,
|
|
3487
|
+
intervalMinutes: props.intervalMinutes
|
|
3488
|
+
});
|
|
3489
|
+
slotTimes.value = intervals.map((slot) => ({
|
|
3490
|
+
startTime: slot.startTime,
|
|
3491
|
+
endTime: slot.endTime
|
|
3492
|
+
}));
|
|
3493
|
+
const withSlotSelect = props.withDragSlotSelect && props.mode !== "static";
|
|
3494
|
+
const getWeekRoot = (event) => event.currentTarget.closest(`.${WeekView_module_default.weekViewRoot}`);
|
|
3495
|
+
const focusWeekControl = (event, selector) => {
|
|
3496
|
+
const control = getWeekRoot(event)?.querySelector(selector);
|
|
3497
|
+
if (!control || control.disabled) return;
|
|
3498
|
+
event.preventDefault();
|
|
3499
|
+
control.focus();
|
|
3500
|
+
};
|
|
3501
|
+
const withDragHandlers = props.mode !== "static" && (props.withEventsDragAndDrop || Boolean(props.onExternalEventDrop));
|
|
3502
|
+
const emitDrop = (nativeEvent, target) => {
|
|
3503
|
+
nativeEvent.preventDefault();
|
|
3504
|
+
const event = getDropEvent(expanded, nativeEvent.dataTransfer);
|
|
3505
|
+
if (event) props.onEventDrop?.(moveEventTo(event, target));
|
|
3506
|
+
else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.(nativeEvent.dataTransfer, target);
|
|
3507
|
+
};
|
|
3508
|
+
const emitAllDayDrop = (nativeEvent, date) => {
|
|
3509
|
+
nativeEvent.preventDefault();
|
|
3510
|
+
const dayKey = (0, dayjs.default)(date).format("YYYY-MM-DD");
|
|
3511
|
+
const event = getDropEvent(expanded, nativeEvent.dataTransfer);
|
|
3512
|
+
if (event) props.onEventDrop?.(moveEventToAllDay(event, dayKey));
|
|
3513
|
+
else if (nativeEvent.dataTransfer) props.onExternalEventDrop?.(nativeEvent.dataTransfer, `${dayKey} 00:00:00`);
|
|
3514
|
+
};
|
|
3515
|
+
const rootStyle = {
|
|
3516
|
+
"--week-view-radius": resolveScheduleRadius(props.radius),
|
|
3517
|
+
"--week-view-slot-height": typeof props.slotHeight === "number" ? `${props.slotHeight}px` : props.slotHeight,
|
|
3518
|
+
"--week-view-all-day-slots-height": typeof props.allDaySlotsHeight === "number" ? `${props.allDaySlotsHeight}px` : props.allDaySlotsHeight
|
|
3519
|
+
};
|
|
3520
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
3521
|
+
...attrs,
|
|
3522
|
+
class: [WeekView_module_default.weekView, attrs.class],
|
|
3523
|
+
style: [rootStyle, attrs.style],
|
|
3524
|
+
mod: {
|
|
3525
|
+
static: props.mode === "static",
|
|
3526
|
+
"slot-dragging": slotDragSelect.isDragging()
|
|
3527
|
+
}
|
|
3528
|
+
}, () => [props.withHeader ? (0, vue.h)(ScheduleHeaderBase, {
|
|
3529
|
+
view: "week",
|
|
3530
|
+
labels: props.labels,
|
|
3531
|
+
onDateChange: props.onDateChange,
|
|
3532
|
+
onViewChange: props.onViewChange,
|
|
3533
|
+
navigationHandlers: createHeaderNavigation(props.date, "week"),
|
|
3534
|
+
previousControlProps: props.previousControlProps,
|
|
3535
|
+
nextControlProps: props.nextControlProps,
|
|
3536
|
+
todayControlProps: props.todayControlProps,
|
|
3537
|
+
viewSelectProps: props.viewSelectProps,
|
|
3538
|
+
control: { title: getWeekLabel({
|
|
3539
|
+
weekdays: days,
|
|
3540
|
+
locale: props.locale || "en",
|
|
3541
|
+
weekLabelFormat: props.weekLabelFormat,
|
|
3542
|
+
renderWeekLabel: props.renderWeekLabel ?? (slots.weekLabel ? (params) => slots.weekLabel(params) : void 0)
|
|
3543
|
+
}) }
|
|
3544
|
+
}) : null, (0, vue.h)(_mantine_vue_core.Box, {
|
|
3545
|
+
class: WeekView_module_default.weekViewRoot,
|
|
3546
|
+
style: {
|
|
3547
|
+
"--number-of-days": String(days.length),
|
|
3548
|
+
"--indicator-offset-index": currentWeekdayIndex === -1 ? void 0 : String(currentWeekdayIndex + 1)
|
|
3549
|
+
},
|
|
3550
|
+
mod: { "with-weekends": props.withWeekendDays }
|
|
3551
|
+
}, () => [(0, vue.h)(_mantine_vue_core.ScrollArea.Autosize, {
|
|
3552
|
+
class: WeekView_module_default.weekViewScrollArea,
|
|
3553
|
+
scrollbarSize: 4
|
|
3554
|
+
}, () => [
|
|
3555
|
+
(0, vue.h)("div", { class: WeekView_module_default.weekViewHeader }, [(0, vue.h)("div", { class: WeekView_module_default.weekViewCorner }, [withWeekNumber ? (0, vue.h)("div", { class: WeekView_module_default.weekViewWeekLabel }, props.labels?.week || "Week") : null, withWeekNumber ? (0, vue.h)("div", { class: WeekView_module_default.weekViewWeekNumber }, String(getWeekNumber(days))) : null]), ...days.map((date, dayIndex) => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
3556
|
+
type: "button",
|
|
3557
|
+
class: WeekView_module_default.weekViewDayLabel,
|
|
3558
|
+
"data-weekday-index": dayIndex,
|
|
3559
|
+
"data-weekend": props.weekendDays.includes((0, dayjs.default)(date).day()) || void 0,
|
|
3560
|
+
"aria-label": `${getLabel("weekday", props.labels)} ${(0, dayjs.default)(date).format("YYYY-MM-DD")}`,
|
|
3561
|
+
tabindex: props.mode === "static" ? -1 : dayIndex === 0 ? 0 : -1,
|
|
3562
|
+
onKeydown: props.mode === "static" ? void 0 : (event) => {
|
|
3563
|
+
const next = event.key === "ArrowRight" ? dayIndex + 1 : event.key === "ArrowLeft" ? dayIndex - 1 : -1;
|
|
3564
|
+
if (next >= 0 && next < days.length) focusWeekControl(event, `[data-weekday-index="${next}"]`);
|
|
3565
|
+
},
|
|
3566
|
+
onClick: props.mode === "static" ? void 0 : () => {
|
|
3567
|
+
props.onViewChange?.("day");
|
|
3568
|
+
props.onDateChange?.(date);
|
|
3569
|
+
}
|
|
3570
|
+
}, () => [(0, vue.h)("span", { class: WeekView_module_default.weekViewDayWeekday }, formatDate({
|
|
3571
|
+
date,
|
|
3572
|
+
locale: props.locale || "en",
|
|
3573
|
+
format: props.weekdayFormat
|
|
3574
|
+
})), (0, vue.h)("span", {
|
|
3575
|
+
class: WeekView_module_default.weekViewDayNumber,
|
|
3576
|
+
"data-today": (0, dayjs.default)(date).isSame(now, "day") || void 0
|
|
3577
|
+
}, formatDate({
|
|
3578
|
+
date,
|
|
3579
|
+
locale: props.locale || "en",
|
|
3580
|
+
format: props.dayFormat
|
|
3581
|
+
}))]))]),
|
|
3582
|
+
withAllDaySlots ? (0, vue.h)("div", { class: WeekView_module_default.weekViewAllDaySlots }, [(0, vue.h)("div", { class: WeekView_module_default.weekViewAllDaySlotsLabel }, props.labels?.allDay || "All day"), (0, vue.h)("div", { class: WeekView_module_default.weekViewAllDaySlotsList }, [(0, vue.h)("div", { class: WeekView_module_default.weekViewAllDaySlotsEvents }, grouped.allDayEvents.map((event) => eventNode(event, props, {
|
|
3583
|
+
key: event.id,
|
|
3584
|
+
nowrap: true,
|
|
3585
|
+
hanging: event.position.hanging,
|
|
3586
|
+
style: {
|
|
3587
|
+
position: "absolute",
|
|
3588
|
+
insetInlineStart: `${event.position.offset}%`,
|
|
3589
|
+
width: `${event.position.width}%`,
|
|
3590
|
+
top: `${event.position.row * 22}px`
|
|
3591
|
+
}
|
|
3592
|
+
}, slots))), ...days.map((date, dayIndex) => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
3593
|
+
type: "button",
|
|
3594
|
+
class: WeekView_module_default.weekViewDaySlot,
|
|
3595
|
+
disabled: props.mode === "static",
|
|
3596
|
+
"data-all-day-index": dayIndex,
|
|
3597
|
+
"aria-label": `${getLabel("allDay", props.labels)} ${(0, dayjs.default)(date).format("YYYY-MM-DD")}`,
|
|
3598
|
+
tabindex: props.mode === "static" ? -1 : dayIndex === 0 ? 0 : -1,
|
|
3599
|
+
onKeydown: props.mode === "static" ? void 0 : (event) => {
|
|
3600
|
+
if (event.key === "ArrowDown") {
|
|
3601
|
+
focusWeekControl(event, `[data-week-day-index="${dayIndex}"][data-time-slot-index="0"]`);
|
|
3602
|
+
return;
|
|
3603
|
+
}
|
|
3604
|
+
const next = event.key === "ArrowRight" ? dayIndex + 1 : event.key === "ArrowLeft" ? dayIndex - 1 : -1;
|
|
3605
|
+
if (next >= 0 && next < days.length) focusWeekControl(event, `[data-all-day-index="${next}"]`);
|
|
3606
|
+
},
|
|
3607
|
+
onClick: (event) => props.onAllDaySlotClick?.(date, event),
|
|
3608
|
+
onDragover: (event) => event.preventDefault(),
|
|
3609
|
+
onDrop: (event) => emitAllDayDrop(event, date)
|
|
3610
|
+
}))])]) : null,
|
|
3611
|
+
(0, vue.h)(_mantine_vue_core.Box, { class: WeekView_module_default.weekViewInner }, () => [
|
|
3612
|
+
(0, vue.h)("div", { class: WeekView_module_default.weekViewSlotLabels }, intervals.map((slot) => (0, vue.h)("div", { class: WeekView_module_default.weekViewSlotLabel }, formatDate({
|
|
3613
|
+
date: `${(0, dayjs.default)(days[0]).format("YYYY-MM-DD")} ${slot.startTime}`,
|
|
3614
|
+
locale: props.locale || "en",
|
|
3615
|
+
format: props.slotLabelFormat
|
|
3616
|
+
})))),
|
|
3617
|
+
props.withCurrentTimeIndicator && currentWeekdayIndex !== -1 ? (0, vue.h)(CurrentTimeIndicator, {
|
|
3618
|
+
startOffset: "calc(100% - (100% / var(--number-of-days)) * (var(--number-of-days) - var(--indicator-offset-index) + 1) + ((var(--number-of-days) - var(--indicator-offset-index) + 1) * var(--indicator-labels-offset)))",
|
|
3619
|
+
endOffset: "calc((100% / var(--number-of-days)) * (var(--number-of-days) - var(--indicator-offset-index)) - (var(--number-of-days) - var(--indicator-offset-index)) * var(--indicator-labels-offset))",
|
|
3620
|
+
timeBubbleStartOffset: "calc(var(--week-view-slots-label-width) - var(--time-bubble-width))",
|
|
3621
|
+
currentTimeFormat: props.slotLabelFormat,
|
|
3622
|
+
withTimeBubble: props.withCurrentTimeBubble,
|
|
3623
|
+
withThumb: props.withCurrentTimeBubble ? currentWeekdayIndex !== 0 : true,
|
|
3624
|
+
locale: props.locale,
|
|
3625
|
+
startTime: props.startTime,
|
|
3626
|
+
endTime: props.endTime,
|
|
3627
|
+
intervalMinutes: props.intervalMinutes,
|
|
3628
|
+
getCurrentTime: props.getCurrentTime
|
|
3629
|
+
}) : null,
|
|
3630
|
+
...days.map((date, dayIndex) => (0, vue.h)("div", { class: WeekView_module_default.weekViewDay }, [(0, vue.h)("div", {
|
|
3631
|
+
class: WeekView_module_default.weekViewDaySlots,
|
|
3632
|
+
ref: (element) => {
|
|
3633
|
+
if (element instanceof HTMLElement) daySlotsContainers.set(date, element);
|
|
3634
|
+
else daySlotsContainers.delete(date);
|
|
3635
|
+
},
|
|
3636
|
+
onDragover: withDragHandlers ? (event) => {
|
|
3637
|
+
event.preventDefault();
|
|
3638
|
+
const container = daySlotsContainers.get(date);
|
|
3639
|
+
if (!container) return;
|
|
3640
|
+
const target = getTimeSlotDropTarget({
|
|
3641
|
+
nativeEvent: event,
|
|
3642
|
+
container,
|
|
3643
|
+
intervals,
|
|
3644
|
+
date: (0, dayjs.default)(date).format("YYYY-MM-DD")
|
|
3645
|
+
});
|
|
3646
|
+
dropTarget.value = target ? {
|
|
3647
|
+
date,
|
|
3648
|
+
slotIndex: target.slotIndex
|
|
3649
|
+
} : null;
|
|
3650
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = event.dataTransfer.types.includes("application/json") ? "move" : "copy";
|
|
3651
|
+
} : void 0,
|
|
3652
|
+
onDragleave: withDragHandlers ? (event) => {
|
|
3653
|
+
const container = daySlotsContainers.get(date);
|
|
3654
|
+
if (!(event.relatedTarget instanceof Node) || !container?.contains(event.relatedTarget)) dropTarget.value = null;
|
|
3655
|
+
} : void 0,
|
|
3656
|
+
onDrop: withDragHandlers ? (event) => {
|
|
3657
|
+
const container = daySlotsContainers.get(date);
|
|
3658
|
+
if (!container) return;
|
|
3659
|
+
const target = getTimeSlotDropTarget({
|
|
3660
|
+
nativeEvent: event,
|
|
3661
|
+
container,
|
|
3662
|
+
intervals,
|
|
3663
|
+
date: (0, dayjs.default)(date).format("YYYY-MM-DD")
|
|
3664
|
+
});
|
|
3665
|
+
dropTarget.value = null;
|
|
3666
|
+
if (target) emitDrop(event, target.target);
|
|
3667
|
+
} : void 0
|
|
3668
|
+
}, [
|
|
3669
|
+
...intervals.map((slot, slotIndex) => {
|
|
3670
|
+
const datePart = (0, dayjs.default)(date).format("YYYY-MM-DD");
|
|
3671
|
+
const start = (0, dayjs.default)(`${datePart} ${slot.startTime}`);
|
|
3672
|
+
const end = (0, dayjs.default)(`${datePart} ${slot.endTime}`);
|
|
3673
|
+
const mod = getBusinessHoursMod({
|
|
3674
|
+
time: slot.startTime,
|
|
3675
|
+
businessHours: props.businessHours || ["09:00:00", "17:00:00"],
|
|
3676
|
+
highlightBusinessHours: props.highlightBusinessHours,
|
|
3677
|
+
dayOfWeek: start.day()
|
|
3678
|
+
});
|
|
3679
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
3680
|
+
type: "button",
|
|
3681
|
+
class: WeekView_module_default.weekViewDaySlot,
|
|
3682
|
+
"data-week-day-index": dayIndex,
|
|
3683
|
+
"data-time-slot-index": slotIndex,
|
|
3684
|
+
"data-drag-slot-index": withSlotSelect ? slotIndex : void 0,
|
|
3685
|
+
"data-drag-slot-group": withSlotSelect ? datePart : void 0,
|
|
3686
|
+
"data-drop-target": dropTarget.value?.date === date && dropTarget.value.slotIndex === slotIndex || void 0,
|
|
3687
|
+
"data-drag-selected": slotDragSelect.isSlotSelected(slotIndex, datePart) || void 0,
|
|
3688
|
+
disabled: props.mode === "static",
|
|
3689
|
+
"aria-label": `${getLabel("timeSlot", props.labels)} ${datePart} ${slot.startTime} - ${slot.endTime}`,
|
|
3690
|
+
tabindex: props.mode === "static" ? -1 : dayIndex === 0 && slotIndex === 0 ? 0 : -1,
|
|
3691
|
+
onKeydown: props.mode === "static" ? void 0 : (event) => {
|
|
3692
|
+
if (event.key === "ArrowUp" && slotIndex === 0 && withAllDaySlots) {
|
|
3693
|
+
focusWeekControl(event, `[data-all-day-index="${dayIndex}"]`);
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
const nextDay = event.key === "ArrowRight" ? dayIndex + 1 : event.key === "ArrowLeft" ? dayIndex - 1 : dayIndex;
|
|
3697
|
+
const nextSlot = event.key === "ArrowDown" ? slotIndex + 1 : event.key === "ArrowUp" ? slotIndex - 1 : slotIndex;
|
|
3698
|
+
if (nextDay >= 0 && nextDay < days.length && nextSlot >= 0 && nextSlot < intervals.length && (nextDay !== dayIndex || nextSlot !== slotIndex)) focusWeekControl(event, `[data-week-day-index="${nextDay}"][data-time-slot-index="${nextSlot}"]`);
|
|
3699
|
+
},
|
|
3700
|
+
"data-business-hours": mod["business-hours"] || void 0,
|
|
3701
|
+
"data-non-business-hours": mod["non-business-hours"] || void 0,
|
|
3702
|
+
onClick: (nativeEvent) => props.onTimeSlotClick?.({
|
|
3703
|
+
slotStart: start.format("YYYY-MM-DD HH:mm:ss"),
|
|
3704
|
+
slotEnd: end.format("YYYY-MM-DD HH:mm:ss"),
|
|
3705
|
+
nativeEvent
|
|
3706
|
+
}),
|
|
3707
|
+
onPointerdown: withSlotSelect ? (nativeEvent) => slotDragSelect.handleSlotPointerDown(nativeEvent, slotIndex, datePart) : void 0,
|
|
3708
|
+
onDragover: (event) => event.preventDefault()
|
|
3709
|
+
});
|
|
3710
|
+
}),
|
|
3711
|
+
...(grouped.backgroundEvents[date] || []).map((event) => (0, vue.h)("div", {
|
|
3712
|
+
class: WeekView_module_default.weekViewBackgroundEvent,
|
|
3713
|
+
style: {
|
|
3714
|
+
top: `${event.position.top}%`,
|
|
3715
|
+
height: `${event.position.height}%`,
|
|
3716
|
+
width: "100%"
|
|
3717
|
+
}
|
|
3718
|
+
})),
|
|
3719
|
+
...(grouped.regularEvents[date] || []).map((event) => {
|
|
3720
|
+
const resizePosition = eventResize.getResizePosition(event.id);
|
|
3721
|
+
const isResizable = eventResize.isResizableEvent(event);
|
|
3722
|
+
return eventNode(event, props, {
|
|
3723
|
+
key: `${event.id}-${date}`,
|
|
3724
|
+
autoSize: true,
|
|
3725
|
+
style: {
|
|
3726
|
+
position: "absolute",
|
|
3727
|
+
top: `${resizePosition?.top ?? event.position.top}%`,
|
|
3728
|
+
height: `${resizePosition?.height ?? event.position.height}%`,
|
|
3729
|
+
width: `${event.position.width}%`,
|
|
3730
|
+
insetInlineStart: `${event.position.offset}%`
|
|
3731
|
+
},
|
|
3732
|
+
withResize: isResizable,
|
|
3733
|
+
isResizing: resizePosition !== null,
|
|
3734
|
+
onClick: props.onEventClick ? (nativeEvent) => {
|
|
3735
|
+
if (!eventResize.wasResizing()) props.onEventClick?.(event, nativeEvent);
|
|
3736
|
+
} : void 0,
|
|
3737
|
+
onResizeStart: (edge, pointerEvent) => {
|
|
3738
|
+
const container = daySlotsContainers.get(date);
|
|
3739
|
+
if (!container) return;
|
|
3740
|
+
eventResize.handleResizeStart({
|
|
3741
|
+
event,
|
|
3742
|
+
edge,
|
|
3743
|
+
container,
|
|
3744
|
+
originalTop: event.position.top,
|
|
3745
|
+
originalHeight: event.position.height,
|
|
3746
|
+
eventDate: (0, dayjs.default)(date).format("YYYY-MM-DD"),
|
|
3747
|
+
pointerEvent
|
|
3748
|
+
});
|
|
3749
|
+
}
|
|
3750
|
+
}, slots);
|
|
3751
|
+
})
|
|
3752
|
+
])]))
|
|
3753
|
+
])
|
|
3754
|
+
])])]);
|
|
3755
|
+
};
|
|
3756
|
+
}
|
|
3757
|
+
});
|
|
3758
|
+
//#endregion
|
|
3759
|
+
//#region src/components/YearView/get-year-view-events/get-year-view-events.ts
|
|
3760
|
+
function groupEventByDate(event, groupedEvents) {
|
|
3761
|
+
if (isMultidayEvent(event)) {
|
|
3762
|
+
const startDate = (0, dayjs.default)(event.start).startOf("day");
|
|
3763
|
+
const endDate = (0, dayjs.default)(event.end).startOf("day");
|
|
3764
|
+
for (let date = startDate; date.isBefore(endDate) || date.isSame(endDate); date = date.add(1, "day")) {
|
|
3765
|
+
const dateKey = date.format("YYYY-MM-DD");
|
|
3766
|
+
if (!groupedEvents[dateKey]) groupedEvents[dateKey] = [];
|
|
3767
|
+
groupedEvents[dateKey].push(event);
|
|
3768
|
+
}
|
|
3769
|
+
return;
|
|
3770
|
+
}
|
|
3771
|
+
const eventDate = (0, dayjs.default)(event.start).format("YYYY-MM-DD");
|
|
3772
|
+
if (!groupedEvents[eventDate]) groupedEvents[eventDate] = [];
|
|
3773
|
+
groupedEvents[eventDate].push(event);
|
|
3774
|
+
}
|
|
3775
|
+
function getYearViewEvents({ date, events }) {
|
|
3776
|
+
const groupedEvents = {};
|
|
3777
|
+
if (events === void 0) return groupedEvents;
|
|
3778
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3779
|
+
for (const event of events) if ((0, dayjs.default)(event.start).isSame((0, dayjs.default)(date), "year")) {
|
|
3780
|
+
groupEventByDate(validateEvent(event), groupedEvents);
|
|
3781
|
+
if (!ids.has(event.id)) ids.add(event.id);
|
|
3782
|
+
else throw new Error(`[@mantine/schedule] YearView: Duplicated event ids found: ${event.id}`);
|
|
3783
|
+
}
|
|
3784
|
+
return groupedEvents;
|
|
3785
|
+
}
|
|
3786
|
+
var YearView_module_default = {
|
|
3787
|
+
yearView: "_yearView_1y6ar_1",
|
|
3788
|
+
yearViewMonths: "_yearViewMonths_1y6ar_15",
|
|
3789
|
+
yearViewMonth: "_yearViewMonth_1y6ar_15",
|
|
3790
|
+
yearViewWeekdays: "_yearViewWeekdays_1y6ar_92",
|
|
3791
|
+
yearViewWeek: "_yearViewWeek_1y6ar_92",
|
|
3792
|
+
yearViewWeekNumber: "_yearViewWeekNumber_1y6ar_100",
|
|
3793
|
+
yearViewWeekday: "_yearViewWeekday_1y6ar_92",
|
|
3794
|
+
yearViewWeekdaysCorner: "_yearViewWeekdaysCorner_1y6ar_154",
|
|
3795
|
+
yearViewDay: "_yearViewDay_1y6ar_158",
|
|
3796
|
+
yearViewMonthCaption: "_yearViewMonthCaption_1y6ar_217",
|
|
3797
|
+
yearViewDayIndicators: "_yearViewDayIndicators_1y6ar_243",
|
|
3798
|
+
yearViewDayIndicator: "_yearViewDayIndicator_1y6ar_243"
|
|
3799
|
+
};
|
|
3800
|
+
//#endregion
|
|
3801
|
+
//#region src/components/YearView/YearView.ts
|
|
3802
|
+
var YearView = (0, vue.defineComponent)({
|
|
3803
|
+
name: "YearView",
|
|
3804
|
+
inheritAttrs: false,
|
|
3805
|
+
props: {
|
|
3806
|
+
...baseViewProps,
|
|
3807
|
+
firstDayOfWeek: {
|
|
3808
|
+
type: Number,
|
|
3809
|
+
default: 1
|
|
3810
|
+
},
|
|
3811
|
+
weekdayFormat: {
|
|
3812
|
+
type: [String, Function],
|
|
3813
|
+
default: "dd"
|
|
3814
|
+
},
|
|
3815
|
+
weekendDays: {
|
|
3816
|
+
type: Array,
|
|
3817
|
+
default: () => [0, 6]
|
|
3818
|
+
},
|
|
3819
|
+
withWeekNumbers: Boolean,
|
|
3820
|
+
withWeekDays: {
|
|
3821
|
+
type: Boolean,
|
|
3822
|
+
default: true
|
|
3823
|
+
},
|
|
3824
|
+
consistentWeeks: Boolean,
|
|
3825
|
+
highlightToday: {
|
|
3826
|
+
type: Boolean,
|
|
3827
|
+
default: true
|
|
3828
|
+
},
|
|
3829
|
+
withOutsideDays: {
|
|
3830
|
+
type: Boolean,
|
|
3831
|
+
default: true
|
|
3832
|
+
},
|
|
3833
|
+
monthsListFormat: {
|
|
3834
|
+
type: [String, Function],
|
|
3835
|
+
default: "MMMM"
|
|
3836
|
+
},
|
|
3837
|
+
getDayProps: Function,
|
|
3838
|
+
getWeekNumberProps: Function,
|
|
3839
|
+
onDayClick: Function,
|
|
3840
|
+
onMonthClick: Function,
|
|
3841
|
+
onWeekNumberClick: Function
|
|
3842
|
+
},
|
|
3843
|
+
setup(props, { attrs }) {
|
|
3844
|
+
const yearGrid = (0, vue.ref)(null);
|
|
3845
|
+
return () => {
|
|
3846
|
+
const year = (0, dayjs.default)(props.date).startOf("year");
|
|
3847
|
+
const eventsByDay = getYearViewEvents({
|
|
3848
|
+
date: year,
|
|
3849
|
+
events: getExpandedEvents(props.events, year.startOf("year").format("YYYY-MM-DD HH:mm:ss"), year.endOf("year").format("YYYY-MM-DD HH:mm:ss"), props.recurrenceExpansionLimit)
|
|
3850
|
+
});
|
|
3851
|
+
const weekdays = getWeekdaysNames({
|
|
3852
|
+
locale: props.locale || "en",
|
|
3853
|
+
format: props.weekdayFormat,
|
|
3854
|
+
firstDayOfWeek: props.firstDayOfWeek
|
|
3855
|
+
});
|
|
3856
|
+
let totalYearGridCells = 0;
|
|
3857
|
+
const months = Array.from({ length: 12 }, (_, monthIndex) => {
|
|
3858
|
+
const month = year.month(monthIndex);
|
|
3859
|
+
const weeks = getMonthDays({
|
|
3860
|
+
month,
|
|
3861
|
+
firstDayOfWeek: props.firstDayOfWeek,
|
|
3862
|
+
consistentWeeks: props.consistentWeeks
|
|
3863
|
+
});
|
|
3864
|
+
const offset = totalYearGridCells;
|
|
3865
|
+
totalYearGridCells += weeks.length * 7;
|
|
3866
|
+
return {
|
|
3867
|
+
month,
|
|
3868
|
+
monthIndex,
|
|
3869
|
+
weeks,
|
|
3870
|
+
offset
|
|
3871
|
+
};
|
|
3872
|
+
});
|
|
3873
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
3874
|
+
...attrs,
|
|
3875
|
+
class: [YearView_module_default.yearView, attrs.class],
|
|
3876
|
+
style: [{ "--year-view-radius": resolveScheduleRadius(props.radius) }, attrs.style]
|
|
3877
|
+
}, () => [props.withHeader ? (0, vue.h)(ScheduleHeaderBase, {
|
|
3878
|
+
view: "year",
|
|
3879
|
+
labels: props.labels,
|
|
3880
|
+
onDateChange: props.onDateChange,
|
|
3881
|
+
onViewChange: props.onViewChange,
|
|
3882
|
+
navigationHandlers: createHeaderNavigation(props.date, "year"),
|
|
3883
|
+
previousControlProps: props.previousControlProps,
|
|
3884
|
+
nextControlProps: props.nextControlProps,
|
|
3885
|
+
todayControlProps: props.todayControlProps,
|
|
3886
|
+
viewSelectProps: props.viewSelectProps,
|
|
3887
|
+
control: { monthYearSelect: {
|
|
3888
|
+
locale: props.locale,
|
|
3889
|
+
yearValue: year.year(),
|
|
3890
|
+
withMonths: false,
|
|
3891
|
+
labelFormat: "YYYY",
|
|
3892
|
+
onYearChange: (value) => props.onDateChange?.(toDateString(year.year(value)))
|
|
3893
|
+
} }
|
|
3894
|
+
}) : null, (0, vue.h)("div", {
|
|
3895
|
+
ref: yearGrid,
|
|
3896
|
+
class: YearView_module_default.yearViewMonths
|
|
3897
|
+
}, months.map(({ month, weeks, offset }) => {
|
|
3898
|
+
return (0, vue.h)("section", {
|
|
3899
|
+
class: YearView_module_default.yearViewMonth,
|
|
3900
|
+
"data-with-week-numbers": props.withWeekNumbers || void 0
|
|
3901
|
+
}, [
|
|
3902
|
+
(0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
3903
|
+
type: "button",
|
|
3904
|
+
class: YearView_module_default.yearViewMonthCaption,
|
|
3905
|
+
onClick: () => props.onMonthClick?.(toDateString(month))
|
|
3906
|
+
}, () => formatDate({
|
|
3907
|
+
date: month,
|
|
3908
|
+
locale: props.locale || "en",
|
|
3909
|
+
format: props.monthsListFormat
|
|
3910
|
+
})),
|
|
3911
|
+
props.withWeekDays ? (0, vue.h)("div", { class: YearView_module_default.yearViewWeekdays }, [props.withWeekNumbers ? (0, vue.h)("span", { class: YearView_module_default.yearViewWeekdaysCorner }) : null, ...weekdays.map((weekday) => (0, vue.h)("span", { class: YearView_module_default.yearViewWeekday }, [weekday]))]) : null,
|
|
3912
|
+
...weeks.map((week, weekIndex) => (0, vue.h)("div", { class: YearView_module_default.yearViewWeek }, [props.withWeekNumbers ? (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
3913
|
+
type: "button",
|
|
3914
|
+
class: YearView_module_default.yearViewWeekNumber,
|
|
3915
|
+
...props.getWeekNumberProps?.(toDateString(week[0])),
|
|
3916
|
+
onClick: (event) => props.onWeekNumberClick?.(toDateString(week[0]), event)
|
|
3917
|
+
}, () => String(getWeekNumber(week))) : null, ...week.map((date, dayIndex) => {
|
|
3918
|
+
const events = eventsByDay[(0, dayjs.default)(date).format("YYYY-MM-DD")] || [];
|
|
3919
|
+
const outside = !(0, dayjs.default)(date).isSame(month, "month");
|
|
3920
|
+
const gridIndex = offset + weekIndex * 7 + dayIndex;
|
|
3921
|
+
const extra = props.getDayProps?.(toDateString(date)) || {};
|
|
3922
|
+
if (outside && !props.withOutsideDays) return (0, vue.h)("div", {
|
|
3923
|
+
class: YearView_module_default.yearViewDay,
|
|
3924
|
+
"data-day-placeholder": true,
|
|
3925
|
+
key: toDateString(date)
|
|
3926
|
+
});
|
|
3927
|
+
return (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
3928
|
+
type: "button",
|
|
3929
|
+
...extra,
|
|
3930
|
+
class: [YearView_module_default.yearViewDay, extra.class],
|
|
3931
|
+
disabled: props.mode === "static",
|
|
3932
|
+
"data-year-grid-index": gridIndex,
|
|
3933
|
+
"data-outside": outside || void 0,
|
|
3934
|
+
"data-weekend": props.weekendDays.includes((0, dayjs.default)(date).day()) || void 0,
|
|
3935
|
+
"data-today": props.highlightToday && (0, dayjs.default)(date).isSame((0, dayjs.default)(), "day") || void 0,
|
|
3936
|
+
"aria-label": formatDate({
|
|
3937
|
+
date,
|
|
3938
|
+
locale: props.locale || "en",
|
|
3939
|
+
format: "MMMM D, YYYY"
|
|
3940
|
+
}),
|
|
3941
|
+
tabindex: props.mode === "static" || outside ? -1 : (0, dayjs.default)(date).date() === 1 ? 0 : -1,
|
|
3942
|
+
onKeydown: props.mode === "static" ? void 0 : (event) => {
|
|
3943
|
+
handleGridKeydown({
|
|
3944
|
+
event,
|
|
3945
|
+
index: gridIndex,
|
|
3946
|
+
columns: 7,
|
|
3947
|
+
total: totalYearGridCells,
|
|
3948
|
+
getControl: (index) => {
|
|
3949
|
+
const control = yearGrid.value?.querySelector(`[data-year-grid-index="${index}"]`) ?? null;
|
|
3950
|
+
return control?.hasAttribute("data-outside") ? null : control;
|
|
3951
|
+
}
|
|
3952
|
+
});
|
|
3953
|
+
extra.onKeydown?.(event);
|
|
3954
|
+
},
|
|
3955
|
+
onClick: (event) => props.onDayClick?.(toDateString(date), event)
|
|
3956
|
+
}, () => [String((0, dayjs.default)(date).date()), events.length ? (0, vue.h)("span", { class: YearView_module_default.yearViewDayIndicators }, events.slice(0, 3).map((event) => (0, vue.h)("span", {
|
|
3957
|
+
class: YearView_module_default.yearViewDayIndicator,
|
|
3958
|
+
style: { background: `var(--mantine-color-${event.color}-6, ${event.color})` }
|
|
3959
|
+
}))) : null]);
|
|
3960
|
+
})]))
|
|
3961
|
+
]);
|
|
3962
|
+
}))]);
|
|
3963
|
+
};
|
|
3964
|
+
}
|
|
3965
|
+
});
|
|
3966
|
+
var Schedule_module_default = {
|
|
3967
|
+
root: "_root_j1q6m_1",
|
|
3968
|
+
desktopView: "_desktopView_j1q6m_7",
|
|
3969
|
+
mobileView: "_mobileView_j1q6m_16"
|
|
3970
|
+
};
|
|
3971
|
+
//#endregion
|
|
3972
|
+
//#region src/components/Schedule/Schedule.ts
|
|
3973
|
+
var Schedule = (0, vue.defineComponent)({
|
|
3974
|
+
name: "Schedule",
|
|
3975
|
+
inheritAttrs: false,
|
|
3976
|
+
slots: Object,
|
|
3977
|
+
props: {
|
|
3978
|
+
date: [String, Date],
|
|
3979
|
+
defaultDate: [String, Date],
|
|
3980
|
+
onDateChange: Function,
|
|
3981
|
+
view: String,
|
|
3982
|
+
defaultView: {
|
|
3983
|
+
type: String,
|
|
3984
|
+
default: "week"
|
|
3985
|
+
},
|
|
3986
|
+
onViewChange: Function,
|
|
3987
|
+
events: Array,
|
|
3988
|
+
locale: String,
|
|
3989
|
+
radius: [String, Number],
|
|
3990
|
+
labels: Object,
|
|
3991
|
+
renderEventBody: Function,
|
|
3992
|
+
withEventsDragAndDrop: Boolean,
|
|
3993
|
+
onEventDrop: Function,
|
|
3994
|
+
canDragEvent: Function,
|
|
3995
|
+
onEventDragStart: Function,
|
|
3996
|
+
onEventDragEnd: Function,
|
|
3997
|
+
onTimeSlotClick: Function,
|
|
3998
|
+
onAllDaySlotClick: Function,
|
|
3999
|
+
onEventClick: Function,
|
|
4000
|
+
onDayClick: Function,
|
|
4001
|
+
onMonthClick: Function,
|
|
4002
|
+
withDragSlotSelect: Boolean,
|
|
4003
|
+
onSlotDragEnd: Function,
|
|
4004
|
+
mode: {
|
|
4005
|
+
type: String,
|
|
4006
|
+
default: "default"
|
|
4007
|
+
},
|
|
4008
|
+
onExternalEventDrop: Function,
|
|
4009
|
+
withEventResize: Boolean,
|
|
4010
|
+
onEventResize: Function,
|
|
4011
|
+
canResizeEvent: Function,
|
|
4012
|
+
recurrenceExpansionLimit: {
|
|
4013
|
+
type: Number,
|
|
4014
|
+
default: 2e3
|
|
4015
|
+
},
|
|
4016
|
+
layout: {
|
|
4017
|
+
type: String,
|
|
4018
|
+
default: "default"
|
|
4019
|
+
},
|
|
4020
|
+
dayViewProps: Object,
|
|
4021
|
+
weekViewProps: Object,
|
|
4022
|
+
monthViewProps: Object,
|
|
4023
|
+
yearViewProps: Object,
|
|
4024
|
+
mobileMonthViewProps: Object
|
|
4025
|
+
},
|
|
4026
|
+
setup(props, { attrs, slots }) {
|
|
4027
|
+
const currentDate = (0, vue.ref)(toDateString(props.date || props.defaultDate || (0, dayjs.default)()));
|
|
4028
|
+
const currentView = (0, vue.ref)(props.view || props.defaultView);
|
|
4029
|
+
(0, vue.watch)(() => props.date, (value) => {
|
|
4030
|
+
if (value !== void 0) currentDate.value = toDateString(value);
|
|
4031
|
+
});
|
|
4032
|
+
(0, vue.watch)(() => props.view, (value) => {
|
|
4033
|
+
if (value !== void 0) currentView.value = value;
|
|
4034
|
+
});
|
|
4035
|
+
const changeDate = (date) => {
|
|
4036
|
+
if (props.date === void 0) currentDate.value = date;
|
|
4037
|
+
props.onDateChange?.(date);
|
|
4038
|
+
};
|
|
4039
|
+
const changeView = (view) => {
|
|
4040
|
+
if (props.view === void 0) currentView.value = view;
|
|
4041
|
+
props.onViewChange?.(view);
|
|
4042
|
+
};
|
|
4043
|
+
return () => {
|
|
4044
|
+
const shared = {
|
|
4045
|
+
date: currentDate.value,
|
|
4046
|
+
onDateChange: changeDate,
|
|
4047
|
+
onViewChange: changeView,
|
|
4048
|
+
events: props.events,
|
|
4049
|
+
locale: props.locale,
|
|
4050
|
+
radius: props.radius,
|
|
4051
|
+
labels: props.labels,
|
|
4052
|
+
renderEventBody: props.renderEventBody,
|
|
4053
|
+
withEventsDragAndDrop: props.withEventsDragAndDrop,
|
|
4054
|
+
onEventDrop: props.onEventDrop,
|
|
4055
|
+
canDragEvent: props.canDragEvent,
|
|
4056
|
+
onEventDragStart: props.onEventDragStart,
|
|
4057
|
+
onEventDragEnd: props.onEventDragEnd,
|
|
4058
|
+
onTimeSlotClick: props.onTimeSlotClick,
|
|
4059
|
+
onAllDaySlotClick: props.onAllDaySlotClick,
|
|
4060
|
+
onEventClick: props.onEventClick,
|
|
4061
|
+
onDayClick: props.onDayClick,
|
|
4062
|
+
onMonthClick: props.onMonthClick,
|
|
4063
|
+
withDragSlotSelect: props.withDragSlotSelect,
|
|
4064
|
+
onSlotDragEnd: props.onSlotDragEnd,
|
|
4065
|
+
mode: props.mode,
|
|
4066
|
+
onExternalEventDrop: props.onExternalEventDrop,
|
|
4067
|
+
withEventResize: props.withEventResize,
|
|
4068
|
+
onEventResize: props.onEventResize,
|
|
4069
|
+
canResizeEvent: props.canResizeEvent,
|
|
4070
|
+
recurrenceExpansionLimit: props.recurrenceExpansionLimit
|
|
4071
|
+
};
|
|
4072
|
+
const components = {
|
|
4073
|
+
day: [DayView, props.dayViewProps],
|
|
4074
|
+
week: [WeekView, props.weekViewProps],
|
|
4075
|
+
month: [MonthView, props.monthViewProps],
|
|
4076
|
+
year: [YearView, props.yearViewProps]
|
|
4077
|
+
};
|
|
4078
|
+
const viewSlots = {};
|
|
4079
|
+
if (slots.eventBody) viewSlots.eventBody = slots.eventBody;
|
|
4080
|
+
if (slots.event) viewSlots.event = slots.event;
|
|
4081
|
+
if (slots.weekLabel) viewSlots.weekLabel = slots.weekLabel;
|
|
4082
|
+
if (slots.header) viewSlots.header = slots.header;
|
|
4083
|
+
const forwardedSlots = Object.keys(viewSlots).length ? viewSlots : void 0;
|
|
4084
|
+
const [component, viewProps] = components[currentView.value];
|
|
4085
|
+
const desktop = (0, vue.h)(component, {
|
|
4086
|
+
...shared,
|
|
4087
|
+
...viewProps
|
|
4088
|
+
}, forwardedSlots);
|
|
4089
|
+
if (props.layout !== "responsive") return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4090
|
+
...attrs,
|
|
4091
|
+
class: [Schedule_module_default.root, attrs.class],
|
|
4092
|
+
style: attrs.style
|
|
4093
|
+
}, () => [desktop]);
|
|
4094
|
+
const mobile = currentView.value === "year" ? (0, vue.h)(YearView, {
|
|
4095
|
+
...shared,
|
|
4096
|
+
...props.yearViewProps
|
|
4097
|
+
}, forwardedSlots) : (0, vue.h)(MobileMonthView, {
|
|
4098
|
+
...shared,
|
|
4099
|
+
...props.mobileMonthViewProps,
|
|
4100
|
+
onYearClick: () => changeView("year"),
|
|
4101
|
+
onDayClick: (date, event) => {
|
|
4102
|
+
props.onDayClick?.(date, event);
|
|
4103
|
+
props.mobileMonthViewProps?.onDayClick?.(date, event);
|
|
4104
|
+
}
|
|
4105
|
+
}, forwardedSlots);
|
|
4106
|
+
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
4107
|
+
...attrs,
|
|
4108
|
+
mod: { layout: props.layout },
|
|
4109
|
+
class: [Schedule_module_default.root, attrs.class],
|
|
4110
|
+
style: attrs.style
|
|
4111
|
+
}, () => [(0, vue.h)(_mantine_vue_core.Box, { class: Schedule_module_default.desktopView }, () => [desktop]), (0, vue.h)(_mantine_vue_core.Box, { class: Schedule_module_default.mobileView }, () => [mobile])]);
|
|
4112
|
+
};
|
|
4113
|
+
}
|
|
4114
|
+
});
|
|
4115
|
+
//#endregion
|
|
4116
|
+
//#region src/components/DragContext/DragContext.ts
|
|
4117
|
+
var DragContext = Symbol("mantine-schedule-drag-context");
|
|
4118
|
+
function provideDragContext(value) {
|
|
4119
|
+
(0, vue.provide)(DragContext, value);
|
|
4120
|
+
}
|
|
4121
|
+
function useDragContext() {
|
|
4122
|
+
return (0, vue.inject)(DragContext, {
|
|
4123
|
+
draggedEvent: null,
|
|
4124
|
+
dragOverTarget: null,
|
|
4125
|
+
isDragging: false,
|
|
4126
|
+
isSlotDragging: false
|
|
4127
|
+
});
|
|
4128
|
+
}
|
|
4129
|
+
//#endregion
|
|
4130
|
+
exports.CurrentTimeIndicator = CurrentTimeIndicator;
|
|
4131
|
+
exports.DEFAULT_SCHEDULE_LABELS = DEFAULT_SCHEDULE_LABELS;
|
|
4132
|
+
exports.DayView = DayView;
|
|
4133
|
+
exports.DragContext = DragContext;
|
|
4134
|
+
exports.HeaderControl = HeaderControl;
|
|
4135
|
+
exports.MobileMonthView = MobileMonthView;
|
|
4136
|
+
exports.MonthView = MonthView;
|
|
4137
|
+
exports.MonthYearSelect = MonthYearSelect;
|
|
4138
|
+
exports.MoreEvents = MoreEvents;
|
|
4139
|
+
exports.Schedule = Schedule;
|
|
4140
|
+
exports.ScheduleEvent = ScheduleEvent;
|
|
4141
|
+
exports.ScheduleHeader = ScheduleHeader;
|
|
4142
|
+
exports.ScheduleHeaderBase = ScheduleHeaderBase;
|
|
4143
|
+
exports.ScheduleHeaderNext = ScheduleHeaderNext;
|
|
4144
|
+
exports.ScheduleHeaderPrevious = ScheduleHeaderPrevious;
|
|
4145
|
+
exports.ScheduleHeaderToday = ScheduleHeaderToday;
|
|
4146
|
+
exports.ViewSelect = ViewSelect;
|
|
4147
|
+
exports.WeekView = WeekView;
|
|
4148
|
+
exports.YearView = YearView;
|
|
4149
|
+
exports.calculateDropTime = calculateDropTime;
|
|
4150
|
+
exports.calculateMonthDropDate = calculateMonthDropDate;
|
|
4151
|
+
exports.clampIntervalMinutes = clampIntervalMinutes;
|
|
4152
|
+
exports.createHeaderNavigation = createHeaderNavigation;
|
|
4153
|
+
exports.expandRecurringEvents = expandRecurringEvents;
|
|
4154
|
+
exports.formatDate = formatDate;
|
|
4155
|
+
exports.getBusinessHoursMod = getBusinessHoursMod;
|
|
4156
|
+
exports.getCurrentTimePosition = getCurrentTimePosition;
|
|
4157
|
+
exports.getDayPosition = getDayPosition;
|
|
4158
|
+
exports.getDayPositionedEvents = getDayPositionedEvents;
|
|
4159
|
+
exports.getDayTimeIntervals = getDayTimeIntervals;
|
|
4160
|
+
exports.getDayViewEvents = getDayViewEvents;
|
|
4161
|
+
exports.getEndOfWeek = getEndOfWeek;
|
|
4162
|
+
exports.getLabel = getLabel;
|
|
4163
|
+
exports.getMonthDays = getMonthDays;
|
|
4164
|
+
exports.getMonthPositionedEvents = getMonthPositionedEvents;
|
|
4165
|
+
exports.getMonthRange = getMonthRange;
|
|
4166
|
+
exports.getMonthViewEvents = getMonthViewEvents;
|
|
4167
|
+
exports.getMonthsByQuarter = getMonthsByQuarter;
|
|
4168
|
+
exports.getMonthsList = getMonthsList;
|
|
4169
|
+
exports.getRenderableMonthEventSegments = getRenderableMonthEventSegments;
|
|
4170
|
+
exports.getStartOfWeek = getStartOfWeek;
|
|
4171
|
+
exports.getVisibleEvents = getVisibleEvents;
|
|
4172
|
+
exports.getWeekDays = getWeekDays;
|
|
4173
|
+
exports.getWeekLabel = getWeekLabel;
|
|
4174
|
+
exports.getWeekNumber = getWeekNumber;
|
|
4175
|
+
exports.getWeekPositionedEvents = getWeekPositionedEvents;
|
|
4176
|
+
exports.getWeekViewEvents = getWeekViewEvents;
|
|
4177
|
+
exports.getWeekdaysNames = getWeekdaysNames;
|
|
4178
|
+
exports.getYearsList = getYearsList;
|
|
4179
|
+
exports.isAfterMinDate = isAfterMinDate;
|
|
4180
|
+
exports.isAllDayEvent = isAllDayEvent;
|
|
4181
|
+
exports.isBeforeMaxDate = isBeforeMaxDate;
|
|
4182
|
+
exports.isEventInTimeRange = isEventInTimeRange;
|
|
4183
|
+
exports.isEventsOverlap = isEventsOverlap;
|
|
4184
|
+
exports.isInTimeRange = isInTimeRange;
|
|
4185
|
+
exports.isMultidayEvent = isMultidayEvent;
|
|
4186
|
+
exports.isSameMonth = isSameMonth;
|
|
4187
|
+
exports.isWithinWeek = isWithinWeek;
|
|
4188
|
+
exports.nextWeek = nextWeek;
|
|
4189
|
+
exports.parseTimeString = parseTimeString;
|
|
4190
|
+
exports.previousWeek = previousWeek;
|
|
4191
|
+
exports.provideDragContext = provideDragContext;
|
|
4192
|
+
exports.sortEvents = sortEvents;
|
|
4193
|
+
exports.toDateString = toDateString;
|
|
4194
|
+
exports.toTimeString = toTimeString;
|
|
4195
|
+
exports.useDragContext = useDragContext;
|
|
4196
|
+
exports.validateEvent = validateEvent;
|
|
4197
|
+
|
|
4198
|
+
//# sourceMappingURL=index.cjs.map
|