@super-calendar/dom 2.17.0 → 2.18.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 +42 -2
- package/dist/index.d.mts +58 -16
- package/dist/index.d.ts +58 -16
- package/dist/index.js +398 -144
- package/dist/index.mjs +400 -146
- package/package.json +2 -2
- package/src/Agenda.tsx +18 -2
- package/src/Calendar.tsx +104 -29
- package/src/MonthView.tsx +182 -33
- package/src/TimeGrid.tsx +363 -153
- package/src/YearView.tsx +12 -1
package/dist/index.js
CHANGED
|
@@ -102,8 +102,9 @@ function DefaultAgendaRow({ event, isAllDay, ampm = false, cardProps }) {
|
|
|
102
102
|
* <Agenda events={events} onPressEvent={(e) => console.log(e.title)} />
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverrides, height = 480, renderEvent, eventAccessibilityLabel, onPressEvent, onPressDay, className, style, classNames, styles }) {
|
|
105
|
+
function Agenda({ events, locale, now, timeZone, ampm = false, activeDate, theme: themeOverrides, height = 480, renderEvent, eventAccessibilityLabel, onPressEvent, onPressDay, className, style, classNames, styles }) {
|
|
106
106
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
107
|
+
const today = (0, _super_calendar_core.nowInTimeZone)(now, timeZone);
|
|
107
108
|
const slot = createSlots({
|
|
108
109
|
classNames,
|
|
109
110
|
styles
|
|
@@ -148,7 +149,7 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
148
149
|
},
|
|
149
150
|
renderItem: ({ item }) => {
|
|
150
151
|
if (item.kind === "header") {
|
|
151
|
-
const highlighted = activeDate ? (0, date_fns.isSameDay)(item.date, activeDate) : (0, _super_calendar_core.getIsToday)(item.date);
|
|
152
|
+
const highlighted = activeDate ? (0, date_fns.isSameDay)(item.date, activeDate) : (0, _super_calendar_core.getIsToday)(item.date, today);
|
|
152
153
|
const label = (0, date_fns.format)(item.date, "EEEE, d LLLL", locale ? { locale } : void 0);
|
|
153
154
|
const color = highlighted ? theme.todayBackground : theme.textMuted;
|
|
154
155
|
const headerProps = slot("dayHeader", {
|
|
@@ -238,7 +239,7 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
238
239
|
* highlighted and a dot under days that hold events. It's the view `Calendar`
|
|
239
240
|
* renders for `mode="year"`.
|
|
240
241
|
*/
|
|
241
|
-
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, labels: labelsProp, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, theme: themeOverrides, className, style, classNames, styles }) {
|
|
242
|
+
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, now, timeZone, labels: labelsProp, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, theme: themeOverrides, className, style, classNames, styles }) {
|
|
242
243
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
243
244
|
const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
|
|
244
245
|
const slot = createSlots({
|
|
@@ -289,6 +290,7 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, labels:
|
|
|
289
290
|
window.addEventListener("pointerup", finish);
|
|
290
291
|
return () => window.removeEventListener("pointerup", finish);
|
|
291
292
|
}, [isCreating, onCreateEvent]);
|
|
293
|
+
const today = (0, _super_calendar_core.nowInTimeZone)(now, timeZone);
|
|
292
294
|
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
293
295
|
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
294
296
|
date,
|
|
@@ -385,7 +387,7 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, labels:
|
|
|
385
387
|
"aria-hidden": true,
|
|
386
388
|
style: { aspectRatio: "1" }
|
|
387
389
|
}, day.toISOString());
|
|
388
|
-
const isToday = (0, _super_calendar_core.getIsToday)(day);
|
|
390
|
+
const isToday = (0, _super_calendar_core.getIsToday)(day, today);
|
|
389
391
|
const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : isToday;
|
|
390
392
|
const hasEvents = eventDays.has((0, date_fns.startOfDay)(day).toISOString());
|
|
391
393
|
const state = (0, _super_calendar_core.daySelectionState)(day, {
|
|
@@ -635,6 +637,13 @@ function holdDateDrag(grab, start, move, cancel, release) {
|
|
|
635
637
|
}, release, stop);
|
|
636
638
|
return stop;
|
|
637
639
|
}
|
|
640
|
+
// src/InertDiv.ts
|
|
641
|
+
function InertDiv(props) {
|
|
642
|
+
return (0, react.createElement)("div", {
|
|
643
|
+
...props,
|
|
644
|
+
inert: props.inert ? "inert" : void 0
|
|
645
|
+
});
|
|
646
|
+
}
|
|
638
647
|
// src/MonthView.tsx
|
|
639
648
|
const EMPTY_LAYOUT = {
|
|
640
649
|
segments: [],
|
|
@@ -644,6 +653,8 @@ const CHIP_HEIGHT = 18;
|
|
|
644
653
|
const CHIP_GAP = 2;
|
|
645
654
|
const CELL_PAD = 4;
|
|
646
655
|
const DRAGGED_CHIP_OPACITY = .4;
|
|
656
|
+
const DRAG_SLOP_PX = 4;
|
|
657
|
+
const TOUCH_DRAG_SLOP_PX = 8;
|
|
647
658
|
const isOutsidePeriod = (day) => day.isCurrentMonth === false;
|
|
648
659
|
function dayCellDefault(day, theme, highlightWeekends) {
|
|
649
660
|
return {
|
|
@@ -869,7 +880,7 @@ function MonthView({ date, showAdjacentMonths = true, ...rest }) {
|
|
|
869
880
|
* The day-row grid behind the public row views: week rows of day cells with
|
|
870
881
|
* spanning event bars, overflow, selection, drag, and keyboard handling.
|
|
871
882
|
*/
|
|
872
|
-
function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, chipHeight = CHIP_HEIGHT, chipGap = CHIP_GAP, moreLabel = "{moreCount} More", labels: labelsProp, onPressEvent, onPressMore, selectedRange, selectedDates, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
883
|
+
function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, chipHeight = CHIP_HEIGHT, chipGap = CHIP_GAP, moreLabel = "{moreCount} More", labels: labelsProp, onPressEvent, onPressMore, selectedRange, selectedDates, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, now, timeZone, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, renderCreateGhost: RenderCreateGhost, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
873
884
|
const { date } = source;
|
|
874
885
|
const multiWeek = source.kind === "multiweek";
|
|
875
886
|
const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
|
|
@@ -881,8 +892,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
881
892
|
classNames,
|
|
882
893
|
styles
|
|
883
894
|
});
|
|
884
|
-
const
|
|
895
|
+
const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
|
|
896
|
+
const eventsMode = events !== void 0 || multiWeek || createContentEnabled;
|
|
885
897
|
const dayRoving = !eventsMode || keyboardDayNavigation;
|
|
898
|
+
const todayKey = (0, date_fns.startOfDay)((0, _super_calendar_core.nowInTimeZone)(now, timeZone)).getTime();
|
|
886
899
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
887
900
|
if (eventsByDayProp) return eventsByDayProp;
|
|
888
901
|
const map = (0, _super_calendar_core.groupEventsByDay)((events ?? []).filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
|
|
@@ -930,7 +943,8 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
930
943
|
minDate,
|
|
931
944
|
maxDate,
|
|
932
945
|
isDateDisabled,
|
|
933
|
-
locale
|
|
946
|
+
locale,
|
|
947
|
+
today: new Date(todayKey)
|
|
934
948
|
};
|
|
935
949
|
if (numberOfWeeks === void 0) return {
|
|
936
950
|
...(0, _super_calendar_core.buildMonthGrid)(date, options),
|
|
@@ -958,7 +972,8 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
958
972
|
minDate,
|
|
959
973
|
maxDate,
|
|
960
974
|
isDateDisabled,
|
|
961
|
-
locale
|
|
975
|
+
locale,
|
|
976
|
+
todayKey
|
|
962
977
|
]);
|
|
963
978
|
const weekLayouts = (0, react.useMemo)(() => eventsMode ? weeks.map((week) => (0, _super_calendar_core.layoutMonthWeek)(week.days.map((d) => d.date), collectRowEvents(week, eventsByDay))) : [], [
|
|
964
979
|
eventsMode,
|
|
@@ -1024,54 +1039,75 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1024
1039
|
(focusKey ? gridRef.current.querySelector(`[data-day="${focusKey}"]`) : gridRef.current)?.focus();
|
|
1025
1040
|
}, [multiWeek, focusKey]);
|
|
1026
1041
|
const [drag, setDrag] = (0, react.useState)(null);
|
|
1027
|
-
const dragRef = (0, react.useRef)(
|
|
1028
|
-
|
|
1042
|
+
const dragRef = (0, react.useRef)(null);
|
|
1043
|
+
const applyDrag = (0, react.useCallback)((next) => {
|
|
1044
|
+
dragRef.current = next;
|
|
1045
|
+
setDrag(next);
|
|
1046
|
+
}, []);
|
|
1047
|
+
const createStart = drag?.kind === "create" ? drag.anchor : null;
|
|
1048
|
+
const createEnd = drag?.kind === "create" ? drag.hover : null;
|
|
1049
|
+
const createRange = (0, react.useMemo)(() => createContentEnabled && createStart !== null && createEnd !== null ? (0, _super_calendar_core.monthCreateRange)(new Date(createStart), new Date(createEnd)) : null, [
|
|
1050
|
+
createContentEnabled,
|
|
1051
|
+
createStart,
|
|
1052
|
+
createEnd
|
|
1053
|
+
]);
|
|
1029
1054
|
const movedRef = (0, react.useRef)(false);
|
|
1030
1055
|
const suppressClickRef = (0, react.useRef)(false);
|
|
1031
|
-
const consumeSuppressedClick = () => {
|
|
1032
|
-
if (!suppressClickRef.current) return false;
|
|
1056
|
+
const consumeSuppressedClick = (detail) => {
|
|
1057
|
+
if (detail === 0 || !suppressClickRef.current) return false;
|
|
1033
1058
|
suppressClickRef.current = false;
|
|
1034
1059
|
return true;
|
|
1035
1060
|
};
|
|
1036
1061
|
const canMove = (event) => onDragEvent != null && !event.disabled && event.draggable !== false && (event.startEditable ?? eventStartEditable);
|
|
1062
|
+
const pressOrigin = (0, react.useRef)({
|
|
1063
|
+
x: 0,
|
|
1064
|
+
y: 0,
|
|
1065
|
+
slop: DRAG_SLOP_PX
|
|
1066
|
+
});
|
|
1037
1067
|
const beginPress = () => {
|
|
1038
1068
|
suppressClickRef.current = false;
|
|
1039
1069
|
movedRef.current = false;
|
|
1040
1070
|
};
|
|
1041
|
-
const beginCreate = (day) => {
|
|
1071
|
+
const beginCreate = (day, pointerId, armed) => {
|
|
1042
1072
|
if (!onCreateEvent && !onSelectDrag) return;
|
|
1043
1073
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
1044
|
-
|
|
1074
|
+
applyDrag({
|
|
1045
1075
|
kind: "create",
|
|
1046
1076
|
anchor: t,
|
|
1047
1077
|
hover: t,
|
|
1048
|
-
windowKey
|
|
1078
|
+
windowKey,
|
|
1079
|
+
pointerId,
|
|
1080
|
+
armed
|
|
1049
1081
|
});
|
|
1050
1082
|
};
|
|
1051
|
-
const beginMove = (event, day) => {
|
|
1083
|
+
const beginMove = (event, day, pointerId, armed) => {
|
|
1052
1084
|
if (!canMove(event)) return;
|
|
1053
1085
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
1054
|
-
|
|
1086
|
+
applyDrag({
|
|
1055
1087
|
kind: "move",
|
|
1056
1088
|
event,
|
|
1057
1089
|
from: t,
|
|
1058
1090
|
to: t,
|
|
1059
|
-
windowKey
|
|
1091
|
+
windowKey,
|
|
1092
|
+
pointerId,
|
|
1093
|
+
armed
|
|
1060
1094
|
});
|
|
1061
1095
|
onDragStart?.(event);
|
|
1062
1096
|
};
|
|
1063
|
-
const extendDrag = (day) => {
|
|
1097
|
+
const extendDrag = (day, pointerId) => {
|
|
1064
1098
|
const current = dragRef.current;
|
|
1065
|
-
if (!current) return;
|
|
1099
|
+
if (!current || current.pointerId !== pointerId) return;
|
|
1066
1100
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
1067
1101
|
if (t === (current.kind === "create" ? current.hover : current.to)) return;
|
|
1068
1102
|
movedRef.current = true;
|
|
1069
|
-
|
|
1103
|
+
applyDrag(current.kind === "create" ? {
|
|
1070
1104
|
...current,
|
|
1071
|
-
hover: t
|
|
1105
|
+
hover: t,
|
|
1106
|
+
armed: true
|
|
1072
1107
|
} : {
|
|
1073
1108
|
...current,
|
|
1074
|
-
to: t
|
|
1109
|
+
to: t,
|
|
1110
|
+
armed: true
|
|
1075
1111
|
});
|
|
1076
1112
|
if (current.kind === "create") {
|
|
1077
1113
|
const [lo, hi] = current.anchor <= t ? [current.anchor, t] : [t, current.anchor];
|
|
@@ -1096,12 +1132,17 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1096
1132
|
const pressRow = (event, day, moving) => {
|
|
1097
1133
|
if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
|
|
1098
1134
|
beginPress();
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1135
|
+
pressOrigin.current = {
|
|
1136
|
+
x: event.clientX,
|
|
1137
|
+
y: event.clientY,
|
|
1138
|
+
slop: event.pointerType === "touch" ? TOUCH_DRAG_SLOP_PX : DRAG_SLOP_PX
|
|
1139
|
+
};
|
|
1140
|
+
const start = (armed) => {
|
|
1141
|
+
if (moving) touchHandlers.current.beginMove(moving, day, event.pointerId, armed);
|
|
1142
|
+
else touchHandlers.current.beginCreate(day, event.pointerId, armed);
|
|
1102
1143
|
};
|
|
1103
1144
|
if (!multiWeek || !event.pointerType || event.pointerType === "mouse") {
|
|
1104
|
-
start();
|
|
1145
|
+
start(false);
|
|
1105
1146
|
return;
|
|
1106
1147
|
}
|
|
1107
1148
|
heldOrigin.current = {
|
|
@@ -1114,14 +1155,13 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1114
1155
|
pointerType: event.pointerType,
|
|
1115
1156
|
clientX: event.clientX,
|
|
1116
1157
|
clientY: event.clientY
|
|
1117
|
-
}, start, (x, y) => {
|
|
1158
|
+
}, () => start(true), (x, y) => {
|
|
1118
1159
|
const element = gridRef.current?.ownerDocument.elementFromPoint(x, y)?.closest("[data-day]");
|
|
1119
1160
|
if (!element || !gridRef.current?.contains(element)) return;
|
|
1120
1161
|
const day = touchHandlers.current.dayLookup.get(element.dataset.day ?? "");
|
|
1121
|
-
if (day && !day.isDisabled) touchHandlers.current.extendDrag(day.date);
|
|
1162
|
+
if (day && !day.isDisabled) touchHandlers.current.extendDrag(day.date, event.pointerId);
|
|
1122
1163
|
}, () => {
|
|
1123
|
-
|
|
1124
|
-
setDrag(null);
|
|
1164
|
+
applyDrag(null);
|
|
1125
1165
|
movedRef.current = false;
|
|
1126
1166
|
}, () => {
|
|
1127
1167
|
heldTouch.current = null;
|
|
@@ -1143,13 +1183,18 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1143
1183
|
if (!enabled(origin.day) || !enabled(destination) || (origin.event ? !events?.includes(origin.event) || !canMove(origin.event) : !onCreateEvent && !onSelectDrag)) heldTouch.current?.();
|
|
1144
1184
|
});
|
|
1145
1185
|
const isDragging = drag !== null;
|
|
1186
|
+
const dragArmed = drag?.armed === true;
|
|
1146
1187
|
const dragWired = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
1147
1188
|
(0, react.useEffect)(() => {
|
|
1148
1189
|
if (!isDragging) return;
|
|
1149
|
-
const finish = () => {
|
|
1190
|
+
const finish = (event) => {
|
|
1150
1191
|
const current = dragRef.current;
|
|
1151
|
-
|
|
1152
|
-
|
|
1192
|
+
if (!current || current.pointerId !== event.pointerId) return;
|
|
1193
|
+
applyDrag(null);
|
|
1194
|
+
if (!movedRef.current) {
|
|
1195
|
+
if (current.kind === "move" && current.armed) suppressClickRef.current = true;
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1153
1198
|
if (multiWeek && current.windowKey !== windowKeyRef.current) return;
|
|
1154
1199
|
suppressClickRef.current = true;
|
|
1155
1200
|
if (current.kind === "create") {
|
|
@@ -1162,24 +1207,61 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1162
1207
|
if (eventOverlap === false && (0, _super_calendar_core.overlapsOtherEvents)(events ?? [], current.event, next.start, next.end)) return;
|
|
1163
1208
|
onDragEvent?.(current.event, next.start, next.end);
|
|
1164
1209
|
};
|
|
1210
|
+
const clear = () => {
|
|
1211
|
+
heldTouch.current?.();
|
|
1212
|
+
applyDrag(null);
|
|
1213
|
+
movedRef.current = false;
|
|
1214
|
+
suppressClickRef.current = true;
|
|
1215
|
+
};
|
|
1216
|
+
const cancel = (event) => {
|
|
1217
|
+
if (dragRef.current?.pointerId === event.pointerId) clear();
|
|
1218
|
+
};
|
|
1219
|
+
const arm = (event) => {
|
|
1220
|
+
const current = dragRef.current;
|
|
1221
|
+
if (!current || current.armed || current.pointerId !== event.pointerId) return;
|
|
1222
|
+
const origin = pressOrigin.current;
|
|
1223
|
+
if (Math.hypot(event.clientX - origin.x, event.clientY - origin.y) <= origin.slop) return;
|
|
1224
|
+
applyDrag({
|
|
1225
|
+
...current,
|
|
1226
|
+
armed: true
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
const keyDown = (event) => {
|
|
1230
|
+
if (event.key !== "Escape") return;
|
|
1231
|
+
event.preventDefault();
|
|
1232
|
+
clear();
|
|
1233
|
+
};
|
|
1234
|
+
window.addEventListener("pointermove", arm);
|
|
1165
1235
|
window.addEventListener("pointerup", finish);
|
|
1166
|
-
|
|
1236
|
+
window.addEventListener("pointercancel", cancel);
|
|
1237
|
+
window.addEventListener("keydown", keyDown);
|
|
1238
|
+
return () => {
|
|
1239
|
+
window.removeEventListener("pointermove", arm);
|
|
1240
|
+
window.removeEventListener("pointerup", finish);
|
|
1241
|
+
window.removeEventListener("pointercancel", cancel);
|
|
1242
|
+
window.removeEventListener("keydown", keyDown);
|
|
1243
|
+
};
|
|
1167
1244
|
}, [
|
|
1168
1245
|
isDragging,
|
|
1169
1246
|
multiWeek,
|
|
1170
1247
|
onCreateEvent,
|
|
1171
1248
|
onDragEvent,
|
|
1172
1249
|
eventOverlap,
|
|
1173
|
-
events
|
|
1250
|
+
events,
|
|
1251
|
+
applyDrag
|
|
1174
1252
|
]);
|
|
1175
1253
|
const transientWindow = (0, react.useRef)(windowKey);
|
|
1176
1254
|
(0, react.useEffect)(() => {
|
|
1177
1255
|
if (transientWindow.current === windowKey) return;
|
|
1178
1256
|
transientWindow.current = windowKey;
|
|
1179
1257
|
if (!multiWeek) return;
|
|
1180
|
-
|
|
1258
|
+
applyDrag(null);
|
|
1181
1259
|
setMoreOpenFor(null);
|
|
1182
|
-
}, [
|
|
1260
|
+
}, [
|
|
1261
|
+
multiWeek,
|
|
1262
|
+
windowKey,
|
|
1263
|
+
applyDrag
|
|
1264
|
+
]);
|
|
1183
1265
|
const nextMultiWeekFocus = (key) => {
|
|
1184
1266
|
if (!focusableDays || !focusableKeys || !period) return void 0;
|
|
1185
1267
|
const index = focusableDays.findIndex((d) => (0, date_fns.format)(d, "yyyy-MM-dd") === focusKey);
|
|
@@ -1303,6 +1385,11 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1303
1385
|
continuesAfter: s.continuesAfter || endCol < s.endCol
|
|
1304
1386
|
};
|
|
1305
1387
|
}).filter((b) => b.startCol <= b.endCol);
|
|
1388
|
+
const draftColumns = createRange ? week.days.flatMap((day, index) => !showAdjacentMonths && isOutsidePeriod(day) || day.date < createRange.start || day.date >= createRange.end ? [] : [index]) : [];
|
|
1389
|
+
const draftStart = draftColumns[0];
|
|
1390
|
+
const draftEnd = draftColumns.at(-1);
|
|
1391
|
+
const draftTop = 28 + chipGap + Math.min(visibleLanes, Math.max(0, maxVisibleEventCount - 1)) * (chipHeight + chipGap);
|
|
1392
|
+
const draftHeight = Math.min(chipHeight, Math.max(0, eventRowHeight - draftTop));
|
|
1306
1393
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1307
1394
|
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
1308
1395
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1369,9 +1456,9 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1369
1456
|
onPointerDown: dragWired && !day.isDisabled ? (e) => {
|
|
1370
1457
|
pressRow(e, day.date);
|
|
1371
1458
|
} : void 0,
|
|
1372
|
-
onPointerEnter: dragWired && !day.isDisabled ? () => extendDrag(day.date) : void 0,
|
|
1373
|
-
onClick: day.isDisabled ? void 0 : () => {
|
|
1374
|
-
if (consumeSuppressedClick()) return;
|
|
1459
|
+
onPointerEnter: dragWired && !day.isDisabled ? (event) => extendDrag(day.date, event.pointerId) : void 0,
|
|
1460
|
+
onClick: day.isDisabled ? void 0 : (e) => {
|
|
1461
|
+
if (consumeSuppressedClick(e.detail)) return;
|
|
1375
1462
|
onPressDay?.(day.date);
|
|
1376
1463
|
onPressCell?.((0, date_fns.startOfDay)(day.date));
|
|
1377
1464
|
},
|
|
@@ -1396,7 +1483,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1396
1483
|
}),
|
|
1397
1484
|
barSegs.filter((b) => b.startCol === dayCol).map((b) => {
|
|
1398
1485
|
const span = b.endCol - b.startCol + 1;
|
|
1399
|
-
const isDragged = drag?.kind === "move" && drag.event === b.seg.event;
|
|
1486
|
+
const isDragged = dragArmed && drag?.kind === "move" && drag.event === b.seg.event;
|
|
1400
1487
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1401
1488
|
type: "button",
|
|
1402
1489
|
onPointerDown: canMove(b.seg.event) ? (e) => {
|
|
@@ -1406,7 +1493,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1406
1493
|
} : void 0,
|
|
1407
1494
|
onClick: (e) => {
|
|
1408
1495
|
e.stopPropagation();
|
|
1409
|
-
if (consumeSuppressedClick()) return;
|
|
1496
|
+
if (consumeSuppressedClick(e.detail)) return;
|
|
1410
1497
|
onPressEvent?.(b.seg.event);
|
|
1411
1498
|
},
|
|
1412
1499
|
...barChipButton,
|
|
@@ -1423,7 +1510,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1423
1510
|
width: `calc(${span * 100}% - 4px)`,
|
|
1424
1511
|
top: 28 + chipGap + b.seg.lane * (chipHeight + chipGap),
|
|
1425
1512
|
height: chipHeight,
|
|
1426
|
-
pointerEvents:
|
|
1513
|
+
pointerEvents: dragArmed ? "none" : "auto",
|
|
1427
1514
|
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1428
1515
|
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
1429
1516
|
touchAction: dragWired ? multiWeek ? "pan-y" : "none" : void 0,
|
|
@@ -1450,6 +1537,34 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1450
1537
|
})
|
|
1451
1538
|
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`);
|
|
1452
1539
|
}),
|
|
1540
|
+
RenderCreateGhost && createRange && draftStart === dayCol && draftEnd !== void 0 && draftHeight > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InertDiv, {
|
|
1541
|
+
...slot("createGhost", {
|
|
1542
|
+
base: {
|
|
1543
|
+
position: "absolute",
|
|
1544
|
+
left: 2,
|
|
1545
|
+
width: `calc(${(draftEnd - draftStart + 1) * 100}% - 4px)`,
|
|
1546
|
+
top: draftTop,
|
|
1547
|
+
height: draftHeight,
|
|
1548
|
+
boxSizing: "border-box",
|
|
1549
|
+
pointerEvents: "none",
|
|
1550
|
+
overflow: "hidden",
|
|
1551
|
+
zIndex: 3
|
|
1552
|
+
},
|
|
1553
|
+
themed: {
|
|
1554
|
+
background: theme.rangeBackground,
|
|
1555
|
+
border: `1px solid ${theme.selectedBackground}`,
|
|
1556
|
+
borderRadius: 4,
|
|
1557
|
+
fontSize: 12,
|
|
1558
|
+
color: theme.text
|
|
1559
|
+
}
|
|
1560
|
+
}),
|
|
1561
|
+
inert: true,
|
|
1562
|
+
"aria-hidden": "true",
|
|
1563
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderCreateGhost, {
|
|
1564
|
+
start: createRange.start,
|
|
1565
|
+
end: createRange.end
|
|
1566
|
+
})
|
|
1567
|
+
}) : null,
|
|
1453
1568
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1454
1569
|
...slot("events", { base: {
|
|
1455
1570
|
display: "flex",
|
|
@@ -1977,19 +2092,13 @@ function EventActionsDialog({ dialogRef, title, description, actions, closeLabel
|
|
|
1977
2092
|
})
|
|
1978
2093
|
});
|
|
1979
2094
|
}
|
|
1980
|
-
// src/InertDiv.ts
|
|
1981
|
-
function InertDiv(props) {
|
|
1982
|
-
return (0, react.createElement)("div", {
|
|
1983
|
-
...props,
|
|
1984
|
-
inert: props.inert ? "inert" : void 0
|
|
1985
|
-
});
|
|
1986
|
-
}
|
|
1987
2095
|
// src/TimeGrid.tsx
|
|
1988
2096
|
const GUTTER_WIDTH$1 = 56;
|
|
1989
2097
|
const HOURS_PER_DAY = 24;
|
|
1990
2098
|
const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
1991
2099
|
const DEFAULT_EVENT_GAP = 1;
|
|
1992
2100
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
2101
|
+
const useClientLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
1993
2102
|
const CREATE_PREVIEW_MIN_HEIGHT = 2;
|
|
1994
2103
|
function createPreviewPlacement(topPx, heightPx, gridHeight) {
|
|
1995
2104
|
const start = clamp$1(topPx, 0, gridHeight);
|
|
@@ -2004,6 +2113,11 @@ function createPreviewPlacement(topPx, heightPx, gridHeight) {
|
|
|
2004
2113
|
height
|
|
2005
2114
|
};
|
|
2006
2115
|
}
|
|
2116
|
+
function createRangePlacement(range, day, hourHeight, minHour, gridHeight, minEventHeight) {
|
|
2117
|
+
const at = (time) => ((0, date_fns.differenceInCalendarDays)(time, day) * 24 + time.getHours() + time.getMinutes() / 60 - minHour) * hourHeight;
|
|
2118
|
+
const top = at(range.start);
|
|
2119
|
+
return createPreviewPlacement(top, Math.max(minEventHeight, at(range.end) - top), gridHeight);
|
|
2120
|
+
}
|
|
2007
2121
|
const EDGE_ZONE = 32;
|
|
2008
2122
|
const EDGE_DWELL_MS = 600;
|
|
2009
2123
|
const EDGE_REPEAT_MS = 600;
|
|
@@ -2027,6 +2141,20 @@ function movedSegmentStart(origin, base, startHours) {
|
|
|
2027
2141
|
const dayMinutes = (0, date_fns.differenceInCalendarDays)(base, origin.base) * HOURS_PER_DAY * 60;
|
|
2028
2142
|
return (0, _super_calendar_core.shiftMinutes)(origin.segmentStart, dayMinutes + Math.round((startHours - origin.startHours) * 60));
|
|
2029
2143
|
}
|
|
2144
|
+
function draggedEventBounds(d, origin, event, base, snapMinutes) {
|
|
2145
|
+
if (d.kind === "resize") {
|
|
2146
|
+
const endDelta = Math.round((d.startHours + d.durationHours - origin.startHours - origin.durationHours) * 60);
|
|
2147
|
+
return (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, 0, endDelta, snapMinutes);
|
|
2148
|
+
}
|
|
2149
|
+
const startShift = movedSegmentStart(origin, base, d.kind === "move" ? d.requestedStartHours : d.startHours).getTime() - origin.segmentStart.getTime();
|
|
2150
|
+
const endShift = d.kind === "move" ? startShift : 0;
|
|
2151
|
+
const start = new Date(event.start.getTime() + startShift);
|
|
2152
|
+
const end = new Date(event.end.getTime() + endShift);
|
|
2153
|
+
return end > start || d.kind === "move" && end.getTime() === start.getTime() ? {
|
|
2154
|
+
start,
|
|
2155
|
+
end
|
|
2156
|
+
} : null;
|
|
2157
|
+
}
|
|
2030
2158
|
function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme, boxProps }) {
|
|
2031
2159
|
const timeLabel = (0, _super_calendar_core.eventTimeLabel)({
|
|
2032
2160
|
mode,
|
|
@@ -2128,6 +2256,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2128
2256
|
now: nowProp,
|
|
2129
2257
|
timeZone
|
|
2130
2258
|
});
|
|
2259
|
+
const todayDate = showNowIndicator ? now : (0, _super_calendar_core.nowInTimeZone)(nowProp, timeZone);
|
|
2131
2260
|
const [hourHeight, setHourHeight] = (0, react.useState)(initialHourHeight);
|
|
2132
2261
|
(0, react.useEffect)(() => setHourHeight(initialHourHeight), [initialHourHeight]);
|
|
2133
2262
|
const hourHeightRef = (0, react.useRef)(hourHeight);
|
|
@@ -2142,6 +2271,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2142
2271
|
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
2143
2272
|
const createOrigin = (0, react.useRef)(null);
|
|
2144
2273
|
const createActive = createBox !== null;
|
|
2274
|
+
const detachCreateListeners = (0, react.useRef)(null);
|
|
2275
|
+
const createRelease = (0, react.useRef)(null);
|
|
2145
2276
|
(0, react.useEffect)(() => {
|
|
2146
2277
|
if (!createActive) return;
|
|
2147
2278
|
const onScroll = () => {
|
|
@@ -2207,6 +2338,11 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2207
2338
|
canResize: editable && (event.durationEditable ?? eventDurationEditable)
|
|
2208
2339
|
};
|
|
2209
2340
|
};
|
|
2341
|
+
const hasEditActions = (event) => {
|
|
2342
|
+
if ((0, _super_calendar_core.isAllDayEvent)(event) || (0, _super_calendar_core.isBackgroundEvent)(event)) return false;
|
|
2343
|
+
const { canMove, canResize } = editability(event);
|
|
2344
|
+
return canMove || canResize;
|
|
2345
|
+
};
|
|
2210
2346
|
const eventLabel = (event) => eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
2211
2347
|
mode,
|
|
2212
2348
|
isAllDay: false,
|
|
@@ -2234,7 +2370,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2234
2370
|
}
|
|
2235
2371
|
};
|
|
2236
2372
|
const editActions = (event) => {
|
|
2237
|
-
if ((
|
|
2373
|
+
if (!hasEditActions(event)) return [];
|
|
2238
2374
|
const { canMove, canResize } = editability(event);
|
|
2239
2375
|
const action = (id, label) => {
|
|
2240
2376
|
const [startDelta, endDelta] = actionDelta(id) ?? [0, 0];
|
|
@@ -2256,12 +2392,36 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2256
2392
|
if (!next || onDragEventRef.current?.(event, next.start, next.end) === false) return null;
|
|
2257
2393
|
return (candidate) => candidate !== event && candidate.start.getTime() === next.start.getTime() && candidate.end.getTime() === next.end.getTime() && candidate.title === event.title;
|
|
2258
2394
|
}, getEventId);
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2395
|
+
const allDayLayout = (0, react.useMemo)(() => (0, _super_calendar_core.layoutMonthWeek)(days, events.filter((event) => (0, _super_calendar_core.isAllDayEvent)(event) && !(0, _super_calendar_core.isBackgroundEvent)(event) && days.some((day) => event.start < (0, date_fns.addDays)((0, date_fns.startOfDay)(day), 1) && event.end > (0, date_fns.startOfDay)(day)))), [days, events]);
|
|
2396
|
+
const hasAllDay = allDayLayout.segments.length > 0;
|
|
2397
|
+
const allDayIds = (0, react.useMemo)(() => {
|
|
2398
|
+
const keys = /* @__PURE__ */ new Map();
|
|
2399
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2400
|
+
for (const { event } of allDayLayout.segments) {
|
|
2401
|
+
const id = getEventId?.(event);
|
|
2402
|
+
if (typeof id !== "string" && typeof id !== "number") continue;
|
|
2403
|
+
const key = `${typeof id}:${id}`;
|
|
2404
|
+
const previous = seen.get(key);
|
|
2405
|
+
if (previous) keys.delete(previous);
|
|
2406
|
+
else {
|
|
2407
|
+
seen.set(key, event);
|
|
2408
|
+
keys.set(event, key);
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
return keys;
|
|
2412
|
+
}, [allDayLayout, getEventId]);
|
|
2413
|
+
const allDayKeys = (0, react.useRef)(/* @__PURE__ */ new WeakMap());
|
|
2414
|
+
const nextAllDayKey = (0, react.useRef)(0);
|
|
2415
|
+
const allDayKey = (event) => {
|
|
2416
|
+
const id = allDayIds.get(event);
|
|
2417
|
+
if (id !== void 0) return id;
|
|
2418
|
+
let key = allDayKeys.current.get(event);
|
|
2419
|
+
if (key === void 0) {
|
|
2420
|
+
key = nextAllDayKey.current++;
|
|
2421
|
+
allDayKeys.current.set(event, key);
|
|
2422
|
+
}
|
|
2423
|
+
return `object:${key}`;
|
|
2424
|
+
};
|
|
2265
2425
|
(0, react.useEffect)(() => {
|
|
2266
2426
|
if (scrollRef.current) scrollRef.current.scrollTop = Math.max(0, (scrollOffsetMinutes / 60 - windowStart) * hourHeightRef.current);
|
|
2267
2427
|
}, [scrollOffsetMinutes, windowStart]);
|
|
@@ -2361,6 +2521,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2361
2521
|
document.removeEventListener("pointermove", h.move);
|
|
2362
2522
|
document.removeEventListener("pointerup", h.up);
|
|
2363
2523
|
document.removeEventListener("pointercancel", h.cancel);
|
|
2524
|
+
document.removeEventListener("selectstart", h.preventNative, true);
|
|
2525
|
+
document.removeEventListener("dragstart", h.preventNative, true);
|
|
2364
2526
|
docHandlersRef.current = null;
|
|
2365
2527
|
};
|
|
2366
2528
|
const finishDrag = () => {
|
|
@@ -2468,18 +2630,14 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2468
2630
|
base = day ? (0, date_fns.startOfDay)(day) : null;
|
|
2469
2631
|
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
|
|
2470
2632
|
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex] ?? daysRef.current[0]);
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
const start = new Date(held.event.start.getTime() + startShift);
|
|
2479
|
-
const end = new Date(held.event.end.getTime() + endShift);
|
|
2480
|
-
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
2633
|
+
try {
|
|
2634
|
+
if (base && held && origin) {
|
|
2635
|
+
const next = draggedEventBounds(d, origin, held.event, base, snapMinutes);
|
|
2636
|
+
if (next) onDragEventRef.current?.(held.event, next.start, next.end);
|
|
2637
|
+
}
|
|
2638
|
+
} finally {
|
|
2639
|
+
finishDrag();
|
|
2481
2640
|
}
|
|
2482
|
-
finishDrag();
|
|
2483
2641
|
};
|
|
2484
2642
|
const cancelDrag = () => {
|
|
2485
2643
|
finishDrag();
|
|
@@ -2493,7 +2651,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2493
2651
|
activeGrabRef.current = e;
|
|
2494
2652
|
const boxEl = e.box;
|
|
2495
2653
|
const column = kind === "move" ? boxEl.parentElement : null;
|
|
2496
|
-
const
|
|
2654
|
+
const columnRect = column ? column.getBoundingClientRect() : null;
|
|
2655
|
+
const dayWidth = columnRect ? columnRect.width : 0;
|
|
2497
2656
|
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
2498
2657
|
const originBase = (0, date_fns.startOfDay)(days[dayIndex] ?? days[0]);
|
|
2499
2658
|
const originNextDay = (0, date_fns.addDays)(originBase, 1);
|
|
@@ -2513,9 +2672,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2513
2672
|
draggedRef.current = {
|
|
2514
2673
|
event,
|
|
2515
2674
|
onPress: onPress ?? (() => {}),
|
|
2516
|
-
grabX:
|
|
2675
|
+
grabX: column && columnRect ? e.clientX - columnRect.left - column.clientLeft - eventGap : 0,
|
|
2517
2676
|
grabY: boxRect ? e.clientY - boxRect.top : 0,
|
|
2518
|
-
w:
|
|
2677
|
+
w: column ? Math.max(column.clientWidth - eventGap * 2, 0) : 0,
|
|
2519
2678
|
h: boxRect ? boxRect.height : 0
|
|
2520
2679
|
};
|
|
2521
2680
|
ptr.current = {
|
|
@@ -2551,12 +2710,15 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2551
2710
|
},
|
|
2552
2711
|
cancel: (event) => {
|
|
2553
2712
|
if (event.pointerId === e.pointerId) cancelDrag();
|
|
2554
|
-
}
|
|
2713
|
+
},
|
|
2714
|
+
preventNative: (event) => event.preventDefault()
|
|
2555
2715
|
};
|
|
2556
2716
|
docHandlersRef.current = handlers;
|
|
2557
2717
|
document.addEventListener("pointermove", handlers.move);
|
|
2558
2718
|
document.addEventListener("pointerup", handlers.up);
|
|
2559
2719
|
document.addEventListener("pointercancel", handlers.cancel);
|
|
2720
|
+
document.addEventListener("selectstart", handlers.preventNative, true);
|
|
2721
|
+
document.addEventListener("dragstart", handlers.preventNative, true);
|
|
2560
2722
|
};
|
|
2561
2723
|
const pressEvent = (e, pe, key, kind, dayIndex, onPress) => {
|
|
2562
2724
|
if (!onDragEvent || e.button > 0) return;
|
|
@@ -2590,6 +2752,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2590
2752
|
cancelHoldRef.current?.();
|
|
2591
2753
|
detachDocListeners();
|
|
2592
2754
|
clearEdgeTimer();
|
|
2755
|
+
if (createOrigin.current?.captureLoss !== void 0) clearTimeout(createOrigin.current.captureLoss);
|
|
2756
|
+
createOrigin.current = null;
|
|
2757
|
+
detachCreateListeners.current?.();
|
|
2758
|
+
detachCreateListeners.current = null;
|
|
2593
2759
|
}, []);
|
|
2594
2760
|
(0, react.useEffect)(() => {
|
|
2595
2761
|
cancelHoldRef.current?.();
|
|
@@ -2600,6 +2766,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2600
2766
|
]);
|
|
2601
2767
|
const pxFromTop = (el, clientY) => clientY - el.getBoundingClientRect().top;
|
|
2602
2768
|
const beginCreate = (e, dayIndex) => {
|
|
2769
|
+
if (createOrigin.current || activeGrabRef.current || e.isPrimary === false) return;
|
|
2603
2770
|
cellTouchRef.current = e.pointerType === "touch" && e.target === e.currentTarget ? {
|
|
2604
2771
|
pointerId: e.pointerId,
|
|
2605
2772
|
x: e.clientX,
|
|
@@ -2628,12 +2795,33 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2628
2795
|
startPx,
|
|
2629
2796
|
curPx: startPx
|
|
2630
2797
|
});
|
|
2798
|
+
const document = el.ownerDocument;
|
|
2799
|
+
const release = (event) => createRelease.current?.(event);
|
|
2800
|
+
const cancel = (event) => {
|
|
2801
|
+
if (createOrigin.current?.pointerId === event.pointerId) clearCreate();
|
|
2802
|
+
};
|
|
2803
|
+
const restart = (event) => {
|
|
2804
|
+
if (event.isPrimary && event.pointerType !== "touch" || createOrigin.current?.pointerId === event.pointerId) clearCreate();
|
|
2805
|
+
};
|
|
2806
|
+
const preventSelection = (event) => event.preventDefault();
|
|
2807
|
+
document.addEventListener("pointerup", release, true);
|
|
2808
|
+
document.addEventListener("pointercancel", cancel, true);
|
|
2809
|
+
document.addEventListener("pointerdown", restart, true);
|
|
2810
|
+
document.addEventListener("selectstart", preventSelection, true);
|
|
2811
|
+
document.addEventListener("dragstart", preventSelection, true);
|
|
2812
|
+
detachCreateListeners.current = () => {
|
|
2813
|
+
document.removeEventListener("pointerup", release, true);
|
|
2814
|
+
document.removeEventListener("pointercancel", cancel, true);
|
|
2815
|
+
document.removeEventListener("pointerdown", restart, true);
|
|
2816
|
+
document.removeEventListener("selectstart", preventSelection, true);
|
|
2817
|
+
document.removeEventListener("dragstart", preventSelection, true);
|
|
2818
|
+
};
|
|
2631
2819
|
};
|
|
2632
2820
|
const moveCreate = (e) => {
|
|
2633
2821
|
const touch = cellTouchRef.current;
|
|
2634
2822
|
if (touch && e.pointerId === touch.pointerId && Math.hypot(e.clientX - touch.x, e.clientY - touch.y) > CELL_TOUCH_SLOP_PX) cellTouchRef.current = null;
|
|
2635
2823
|
const o = createOrigin.current;
|
|
2636
|
-
if (!o) return;
|
|
2824
|
+
if (!o || o.pointerId !== e.pointerId) return;
|
|
2637
2825
|
o.clientY = e.clientY;
|
|
2638
2826
|
setCreateBox({
|
|
2639
2827
|
dayIndex: o.dayIndex,
|
|
@@ -2644,10 +2832,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2644
2832
|
};
|
|
2645
2833
|
const endCreate = (e) => {
|
|
2646
2834
|
const o = createOrigin.current;
|
|
2647
|
-
if (!o) return;
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
} catch {}
|
|
2835
|
+
if (!o || o.pointerId !== e.pointerId) return;
|
|
2836
|
+
clearCreate();
|
|
2837
|
+
if (!o.el.isConnected || !cellEnabled || o.creating && !onCreateEvent || days[o.dayIndex]?.getTime() !== o.dayTime) return;
|
|
2651
2838
|
const endPx = pxFromTop(o.el, e.clientY);
|
|
2652
2839
|
const day = days[o.dayIndex];
|
|
2653
2840
|
const moved = Math.abs(endPx - o.startPx) > 4;
|
|
@@ -2659,9 +2846,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2659
2846
|
const at = (0, _super_calendar_core.cellRangeFromDrag)(day, o.startPx, o.startPx, h, windowStart, snapMinutes);
|
|
2660
2847
|
if (at) onPressCell(at.start);
|
|
2661
2848
|
}
|
|
2662
|
-
createOrigin.current = null;
|
|
2663
|
-
setCreateBox(null);
|
|
2664
2849
|
};
|
|
2850
|
+
useClientLayoutEffect(() => {
|
|
2851
|
+
createRelease.current = endCreate;
|
|
2852
|
+
});
|
|
2665
2853
|
const tapCell = (e, dayIndex) => {
|
|
2666
2854
|
const touch = cellTouchRef.current;
|
|
2667
2855
|
cellTouchRef.current = null;
|
|
@@ -2674,18 +2862,26 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2674
2862
|
const clearCreate = (0, react.useCallback)(() => {
|
|
2675
2863
|
const previous = createOrigin.current;
|
|
2676
2864
|
createOrigin.current = null;
|
|
2865
|
+
if (previous?.captureLoss !== void 0) clearTimeout(previous.captureLoss);
|
|
2866
|
+
detachCreateListeners.current?.();
|
|
2867
|
+
detachCreateListeners.current = null;
|
|
2677
2868
|
setCreateBox(null);
|
|
2678
2869
|
try {
|
|
2679
2870
|
previous?.el.releasePointerCapture?.(previous.pointerId);
|
|
2680
2871
|
} catch {}
|
|
2681
2872
|
}, []);
|
|
2682
|
-
const cancelCreate = () => {
|
|
2683
|
-
cellTouchRef.current = null;
|
|
2873
|
+
const cancelCreate = (e) => {
|
|
2874
|
+
if (cellTouchRef.current?.pointerId === e.pointerId) cellTouchRef.current = null;
|
|
2875
|
+
if (createOrigin.current?.pointerId !== e.pointerId) return;
|
|
2684
2876
|
clearCreate();
|
|
2685
2877
|
};
|
|
2686
2878
|
const loseCreateCapture = (e) => {
|
|
2687
|
-
|
|
2688
|
-
|
|
2879
|
+
const origin = createOrigin.current;
|
|
2880
|
+
if (!origin || origin.pointerId !== e.pointerId) return;
|
|
2881
|
+
if (origin.captureLoss !== void 0) clearTimeout(origin.captureLoss);
|
|
2882
|
+
origin.captureLoss = setTimeout(() => {
|
|
2883
|
+
if (createOrigin.current === origin) clearCreate();
|
|
2884
|
+
}, 0);
|
|
2689
2885
|
};
|
|
2690
2886
|
(0, react.useEffect)(() => {
|
|
2691
2887
|
const onKeyDown = (event) => {
|
|
@@ -2697,7 +2893,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2697
2893
|
document.addEventListener("keydown", onKeyDown);
|
|
2698
2894
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
2699
2895
|
}, [clearCreate]);
|
|
2700
|
-
const liveRange = createBox &&
|
|
2896
|
+
const liveRange = createBox && onCreateEvent && days[createBox.dayIndex]?.getTime() === createBox.dayTime ? (0, _super_calendar_core.cellRangeFromDrag)(days[createBox.dayIndex], createBox.startPx, createBox.curPx, hourHeight, windowStart, snapMinutes) : null;
|
|
2701
2897
|
const liveStart = liveRange?.start.getTime();
|
|
2702
2898
|
const liveEnd = liveRange?.end.getTime();
|
|
2703
2899
|
const createRange = (0, react.useMemo)(() => liveStart === void 0 || liveEnd === void 0 ? null : {
|
|
@@ -2712,7 +2908,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2712
2908
|
const moveOrigin = dragOrigin.current;
|
|
2713
2909
|
const heldEvent = draggedRef.current?.event;
|
|
2714
2910
|
const movingEvent = heldEvent && (events.includes(heldEvent) ? heldEvent : events.find((event) => event.start.getTime() === heldEvent.start.getTime() && event.end.getTime() === heldEvent.end.getTime() && event.title === heldEvent.title) ?? heldEvent);
|
|
2715
|
-
const
|
|
2911
|
+
const multiDayHeld = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && !!movingEvent;
|
|
2912
|
+
const multiDayMove = !paged && drag?.kind === "move" && drag.moved && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
|
|
2716
2913
|
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
2717
2914
|
const shift = movedSegmentStart(moveOrigin, (0, date_fns.startOfDay)(target), drag.requestedStartHours).getTime() - moveOrigin.segmentStart.getTime();
|
|
2718
2915
|
return {
|
|
@@ -2722,12 +2919,18 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2722
2919
|
allDay: false
|
|
2723
2920
|
};
|
|
2724
2921
|
})() : null;
|
|
2922
|
+
const liveBounds = !paged && drag?.moved && !multiDayMove && moveOrigin && draggedRef.current ? draggedEventBounds(drag, moveOrigin, draggedRef.current.event, (0, date_fns.startOfDay)(days[moveOrigin.dayIndex + (drag.kind === "move" ? drag.dayDelta : 0)] ?? days[moveOrigin.dayIndex]), snapMinutes) : null;
|
|
2923
|
+
const withLiveBounds = (event) => liveBounds ? {
|
|
2924
|
+
...event,
|
|
2925
|
+
start: liveBounds.start,
|
|
2926
|
+
end: liveBounds.end
|
|
2927
|
+
} : event;
|
|
2725
2928
|
const spillPreviewFor = (dayIndex) => {
|
|
2726
2929
|
if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
|
|
2727
2930
|
const dragged = draggedRef.current?.event;
|
|
2728
2931
|
if (!dragged) return null;
|
|
2729
2932
|
return {
|
|
2730
|
-
event: dragged,
|
|
2933
|
+
event: withLiveBounds(dragged),
|
|
2731
2934
|
mode,
|
|
2732
2935
|
isAllDay: false,
|
|
2733
2936
|
boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
|
|
@@ -2848,7 +3051,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2848
3051
|
},
|
|
2849
3052
|
children: [
|
|
2850
3053
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EventActionsMenu, {
|
|
2851
|
-
events: [...new Set(positionedByDay.flat().filter((pe) => pe.startHours < windowEnd && pe.startHours + pe.durationHours > windowStart).map((pe) => pe.event))].filter(
|
|
3054
|
+
events: [...new Set(positionedByDay.flat().filter((pe) => pe.startHours < windowEnd && pe.startHours + pe.durationHours > windowStart).map((pe) => pe.event))].filter(hasEditActions),
|
|
2852
3055
|
label: labels.editEvents,
|
|
2853
3056
|
labelFor: (event) => labels.eventActions(event.title ?? ""),
|
|
2854
3057
|
descriptionFor: eventDescription,
|
|
@@ -2879,7 +3082,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2879
3082
|
}),
|
|
2880
3083
|
children: showWeekNumber && gutterWidth > 0 && days[0] ? `${weekNumberPrefix}${(0, date_fns.getISOWeek)(days.find((d) => d.getDay() === 4) ?? days[0])}` : null
|
|
2881
3084
|
}), days.map((day) => {
|
|
2882
|
-
const today = (0, _super_calendar_core.getIsToday)(day);
|
|
3085
|
+
const today = (0, _super_calendar_core.getIsToday)(day, todayDate);
|
|
2883
3086
|
const dateLabel = (0, date_fns.format)(day, "EEEE, d MMMM yyyy", dfns);
|
|
2884
3087
|
const headerProps = slot("columnHeader", {
|
|
2885
3088
|
base: {
|
|
@@ -2956,6 +3159,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2956
3159
|
base: {
|
|
2957
3160
|
width: gutterWidth,
|
|
2958
3161
|
flex: "none",
|
|
3162
|
+
boxSizing: "border-box",
|
|
2959
3163
|
minWidth: 0,
|
|
2960
3164
|
overflow: "hidden",
|
|
2961
3165
|
textAlign: "right"
|
|
@@ -2963,34 +3167,41 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2963
3167
|
themed: {
|
|
2964
3168
|
fontSize: 10,
|
|
2965
3169
|
color: theme.textMuted,
|
|
2966
|
-
padding: "4px 6px 0 0"
|
|
3170
|
+
padding: hideHours ? 0 : "4px 6px 0 0"
|
|
2967
3171
|
}
|
|
2968
3172
|
}),
|
|
2969
3173
|
children: showAllDayLabel ? labels.allDay : null
|
|
2970
|
-
}),
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
3174
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3175
|
+
style: {
|
|
3176
|
+
flex: 1,
|
|
3177
|
+
minWidth: 0,
|
|
3178
|
+
display: "grid",
|
|
3179
|
+
gridTemplateColumns: `repeat(${days.length}, minmax(0, 1fr))`,
|
|
3180
|
+
gap: "2px 0",
|
|
3181
|
+
padding: "2px 0"
|
|
3182
|
+
},
|
|
3183
|
+
children: allDayLayout.segments.map((segment) => {
|
|
3184
|
+
const { event, startCol, endCol, lane, continuesBefore, continuesAfter } = segment;
|
|
3185
|
+
const args = {
|
|
3186
|
+
event,
|
|
3187
|
+
mode,
|
|
3188
|
+
isAllDay: true,
|
|
3189
|
+
continuesBefore,
|
|
3190
|
+
continuesAfter,
|
|
3191
|
+
ampm,
|
|
3192
|
+
onPress: () => onPressEvent?.(event)
|
|
3193
|
+
};
|
|
3194
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3195
|
+
...slot("allDayColumn", { base: {
|
|
3196
|
+
gridColumn: `${startCol + 1} / span ${endCol - startCol + 1}`,
|
|
3197
|
+
gridRow: lane + 1,
|
|
3198
|
+
minWidth: 0,
|
|
3199
|
+
borderLeft: "1px solid transparent",
|
|
3200
|
+
padding: "0 1px",
|
|
3201
|
+
display: "flex",
|
|
3202
|
+
flexDirection: "column"
|
|
3203
|
+
} }),
|
|
3204
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2994
3205
|
type: "button",
|
|
2995
3206
|
onClick: () => onPressEvent?.(event),
|
|
2996
3207
|
"aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
@@ -3018,9 +3229,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3018
3229
|
theme,
|
|
3019
3230
|
boxProps: slot("eventBox")
|
|
3020
3231
|
})
|
|
3021
|
-
}
|
|
3022
|
-
})
|
|
3023
|
-
}
|
|
3232
|
+
})
|
|
3233
|
+
}, allDayKey(event));
|
|
3234
|
+
})
|
|
3024
3235
|
})]
|
|
3025
3236
|
}) : null,
|
|
3026
3237
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3069,7 +3280,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3069
3280
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
3070
3281
|
const bands = bandsByDay[dayIndex];
|
|
3071
3282
|
const ghost = createBox?.dayIndex === dayIndex && createBox.dayTime === day.getTime() ? createBox : null;
|
|
3072
|
-
const ghostRange = ghost ? createRange : null;
|
|
3283
|
+
const ghostRange = ghost && RenderCreateGhost ? createRange : null;
|
|
3073
3284
|
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
3074
3285
|
const moveSegment = multiDayMove ? (0, _super_calendar_core.layoutDayEvents)([multiDayMove], day)[0] : void 0;
|
|
3075
3286
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3081,7 +3292,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3081
3292
|
onLostPointerCapture: cellEnabled ? loseCreateCapture : void 0,
|
|
3082
3293
|
onClick: cellEnabled ? (e) => tapCell(e, dayIndex) : void 0,
|
|
3083
3294
|
...dataState({
|
|
3084
|
-
"data-today": (0, _super_calendar_core.getIsToday)(day),
|
|
3295
|
+
"data-today": (0, _super_calendar_core.getIsToday)(day, todayDate),
|
|
3085
3296
|
"data-weekend": (0, _super_calendar_core.isWeekend)(day)
|
|
3086
3297
|
}),
|
|
3087
3298
|
...slot("dayColumn", {
|
|
@@ -3169,7 +3380,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3169
3380
|
}),
|
|
3170
3381
|
positioned.map((pe, idx) => {
|
|
3171
3382
|
const key = `${dayIndex}:${idx}`;
|
|
3172
|
-
const active = !paged && drag?.key === key && (!
|
|
3383
|
+
const active = !paged && drag?.key === key && (!multiDayHeld || pe.event === movingEvent) ? drag : null;
|
|
3173
3384
|
const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
|
|
3174
3385
|
const startHours = active ? active.startHours : pe.startHours;
|
|
3175
3386
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
@@ -3177,9 +3388,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3177
3388
|
const top = (startHours - windowStart) * hourHeight;
|
|
3178
3389
|
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
|
|
3179
3390
|
const widthPct = 100 / pe.columns;
|
|
3391
|
+
const floating = active?.kind === "move" && active.moved;
|
|
3180
3392
|
const onPress = () => onPressEvent?.(pe.event);
|
|
3181
3393
|
const args = {
|
|
3182
|
-
event: pe.event,
|
|
3394
|
+
event: active ? withLiveBounds(pe.event) : pe.event,
|
|
3183
3395
|
mode,
|
|
3184
3396
|
isAllDay: false,
|
|
3185
3397
|
boxHeight,
|
|
@@ -3214,8 +3426,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3214
3426
|
position: "absolute",
|
|
3215
3427
|
top,
|
|
3216
3428
|
height: boxHeight,
|
|
3217
|
-
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
3218
|
-
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
3429
|
+
left: floating ? eventGap : `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
3430
|
+
width: floating ? `calc(100% - ${eventGap * 2}px)` : `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
3219
3431
|
cursor: canMove ? "grab" : "pointer",
|
|
3220
3432
|
touchAction: canMove ? "pan-y" : "auto",
|
|
3221
3433
|
userSelect: canMove ? "none" : void 0,
|
|
@@ -3343,7 +3555,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3343
3555
|
position: "absolute",
|
|
3344
3556
|
left: eventGap,
|
|
3345
3557
|
right: eventGap,
|
|
3346
|
-
...createPreviewPlacement(Math.min(ghost.startPx, ghost.curPx), Math.abs(ghost.curPx - ghost.startPx), totalHeight),
|
|
3558
|
+
...createRange ? createRangePlacement(createRange, day, hourHeight, windowStart, totalHeight, minEventHeight) : createPreviewPlacement(Math.min(ghost.startPx, ghost.curPx), Math.abs(ghost.curPx - ghost.startPx), totalHeight),
|
|
3347
3559
|
boxSizing: "border-box",
|
|
3348
3560
|
...ghostRange ? { overflow: "hidden" } : null,
|
|
3349
3561
|
opacity: .7,
|
|
@@ -3455,12 +3667,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3455
3667
|
const displayEvents = (0, react.useMemo)(() => {
|
|
3456
3668
|
let out = events ?? EMPTY_EVENTS;
|
|
3457
3669
|
if (out.some((e) => e.recurrence)) {
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
start = (0, date_fns.addDays)(start, -1);
|
|
3461
|
-
end = (0, date_fns.addDays)(end, 1);
|
|
3462
|
-
}
|
|
3463
|
-
out = (0, _super_calendar_core.expandRecurringEvents)(out, start, end);
|
|
3670
|
+
const [start, end] = expansionRange(mode, date, weekStartsOn, numberOfDays, numberOfWeeks);
|
|
3671
|
+
out = timeZone ? (0, _super_calendar_core.expandRecurringEvents)(out, (0, _super_calendar_core.fromZonedTime)(start, timeZone), (0, _super_calendar_core.fromZonedTime)(end, timeZone), { timeZone }) : (0, _super_calendar_core.expandRecurringEvents)(out, start, end);
|
|
3464
3672
|
}
|
|
3465
3673
|
if (timeZone) out = (0, _super_calendar_core.eventsInTimeZone)(out, timeZone);
|
|
3466
3674
|
return out;
|
|
@@ -3473,6 +3681,42 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3473
3681
|
numberOfWeeks,
|
|
3474
3682
|
timeZone
|
|
3475
3683
|
]);
|
|
3684
|
+
const timeGridMode = mode !== "month" && mode !== "multiweek";
|
|
3685
|
+
const zoned = (0, react.useMemo)(() => {
|
|
3686
|
+
if (!timeZone) return {
|
|
3687
|
+
onPressEvent,
|
|
3688
|
+
onDragStart,
|
|
3689
|
+
onDragEvent,
|
|
3690
|
+
onPressMore,
|
|
3691
|
+
onPressTime: onPressCell,
|
|
3692
|
+
onCreateTimed: onCreateEvent
|
|
3693
|
+
};
|
|
3694
|
+
const instant = (wallClock) => (0, _super_calendar_core.fromZonedTime)(wallClock, timeZone);
|
|
3695
|
+
return {
|
|
3696
|
+
onPressEvent: onPressEvent && ((event) => onPressEvent((0, _super_calendar_core.zonedEventSource)(event))),
|
|
3697
|
+
onDragStart: onDragStart && ((event) => onDragStart((0, _super_calendar_core.zonedEventSource)(event))),
|
|
3698
|
+
onDragEvent: onDragEvent && ((event, start, end) => {
|
|
3699
|
+
const bounds = (0, _super_calendar_core.zonedDragBounds)(event, start, end, { keepDuration: timeGridMode });
|
|
3700
|
+
if (!bounds) return false;
|
|
3701
|
+
return onDragEvent((0, _super_calendar_core.zonedEventSource)(event), bounds.start, bounds.end);
|
|
3702
|
+
}),
|
|
3703
|
+
onPressMore: onPressMore && ((dayEvents, day) => onPressMore(dayEvents.map(_super_calendar_core.zonedEventSource), day)),
|
|
3704
|
+
onPressTime: onPressCell && ((time) => onPressCell(instant(time))),
|
|
3705
|
+
onCreateTimed: onCreateEvent && ((start, end) => {
|
|
3706
|
+
const range = (0, _super_calendar_core.fromZonedRange)(start, end, timeZone);
|
|
3707
|
+
if (range) onCreateEvent(range.start, range.end);
|
|
3708
|
+
})
|
|
3709
|
+
};
|
|
3710
|
+
}, [
|
|
3711
|
+
timeZone,
|
|
3712
|
+
timeGridMode,
|
|
3713
|
+
onPressEvent,
|
|
3714
|
+
onDragStart,
|
|
3715
|
+
onDragEvent,
|
|
3716
|
+
onPressMore,
|
|
3717
|
+
onPressCell,
|
|
3718
|
+
onCreateEvent
|
|
3719
|
+
]);
|
|
3476
3720
|
const handlePageKeys = (e) => {
|
|
3477
3721
|
if (!onChangeDate) return;
|
|
3478
3722
|
if (e.key === "PageDown") onChangeDate(pageStep(mode, date, 1, weekStartsOn, numberOfDays, numberOfWeeks));
|
|
@@ -3487,6 +3731,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3487
3731
|
weekStartsOn,
|
|
3488
3732
|
hiddenDays,
|
|
3489
3733
|
locale,
|
|
3734
|
+
now,
|
|
3735
|
+
timeZone,
|
|
3490
3736
|
labels,
|
|
3491
3737
|
theme,
|
|
3492
3738
|
className,
|
|
@@ -3509,6 +3755,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3509
3755
|
else if (mode === "schedule") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {
|
|
3510
3756
|
events: displayEvents,
|
|
3511
3757
|
locale,
|
|
3758
|
+
now,
|
|
3759
|
+
timeZone,
|
|
3512
3760
|
ampm,
|
|
3513
3761
|
theme,
|
|
3514
3762
|
height,
|
|
@@ -3519,7 +3767,7 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3519
3767
|
styles,
|
|
3520
3768
|
renderEvent: renderScheduleEvent,
|
|
3521
3769
|
eventAccessibilityLabel,
|
|
3522
|
-
onPressEvent,
|
|
3770
|
+
onPressEvent: zoned.onPressEvent,
|
|
3523
3771
|
onPressDay
|
|
3524
3772
|
});
|
|
3525
3773
|
else if (mode === "month") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthView, {
|
|
@@ -3530,6 +3778,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3530
3778
|
weekdayFormat,
|
|
3531
3779
|
highlightWeekends,
|
|
3532
3780
|
locale,
|
|
3781
|
+
now,
|
|
3782
|
+
timeZone,
|
|
3533
3783
|
labels,
|
|
3534
3784
|
theme,
|
|
3535
3785
|
className,
|
|
@@ -3552,13 +3802,14 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3552
3802
|
onPressDay,
|
|
3553
3803
|
onPressCell,
|
|
3554
3804
|
onCreateEvent,
|
|
3805
|
+
renderCreateGhost,
|
|
3555
3806
|
onSelectDrag,
|
|
3556
|
-
onDragEvent,
|
|
3557
|
-
onDragStart,
|
|
3807
|
+
onDragEvent: zoned.onDragEvent,
|
|
3808
|
+
onDragStart: zoned.onDragStart,
|
|
3558
3809
|
eventStartEditable,
|
|
3559
3810
|
eventOverlap,
|
|
3560
|
-
onPressEvent,
|
|
3561
|
-
onPressMore,
|
|
3811
|
+
onPressEvent: zoned.onPressEvent,
|
|
3812
|
+
onPressMore: zoned.onPressMore,
|
|
3562
3813
|
renderEvent: renderMonthEvent,
|
|
3563
3814
|
eventAccessibilityLabel
|
|
3564
3815
|
});
|
|
@@ -3571,6 +3822,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3571
3822
|
weekdayFormat,
|
|
3572
3823
|
highlightWeekends,
|
|
3573
3824
|
locale,
|
|
3825
|
+
now,
|
|
3826
|
+
timeZone,
|
|
3574
3827
|
labels,
|
|
3575
3828
|
theme,
|
|
3576
3829
|
className,
|
|
@@ -3595,13 +3848,14 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3595
3848
|
onPressDay,
|
|
3596
3849
|
onPressCell,
|
|
3597
3850
|
onCreateEvent,
|
|
3851
|
+
renderCreateGhost,
|
|
3598
3852
|
onSelectDrag,
|
|
3599
|
-
onDragEvent,
|
|
3600
|
-
onDragStart,
|
|
3853
|
+
onDragEvent: zoned.onDragEvent,
|
|
3854
|
+
onDragStart: zoned.onDragStart,
|
|
3601
3855
|
eventStartEditable,
|
|
3602
3856
|
eventOverlap,
|
|
3603
|
-
onPressEvent,
|
|
3604
|
-
onPressMore,
|
|
3857
|
+
onPressEvent: zoned.onPressEvent,
|
|
3858
|
+
onPressMore: zoned.onPressMore,
|
|
3605
3859
|
renderEvent: renderMonthEvent,
|
|
3606
3860
|
eventAccessibilityLabel
|
|
3607
3861
|
});
|
|
@@ -3648,12 +3902,12 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3648
3902
|
dragStepMinutes,
|
|
3649
3903
|
touchDragDelay,
|
|
3650
3904
|
touchDragThreshold,
|
|
3651
|
-
onPressEvent,
|
|
3652
|
-
onPressCell,
|
|
3653
|
-
onCreateEvent,
|
|
3905
|
+
onPressEvent: zoned.onPressEvent,
|
|
3906
|
+
onPressCell: zoned.onPressTime,
|
|
3907
|
+
onCreateEvent: zoned.onCreateTimed,
|
|
3654
3908
|
renderCreateGhost,
|
|
3655
|
-
onDragStart,
|
|
3656
|
-
onDragEvent,
|
|
3909
|
+
onDragStart: zoned.onDragStart,
|
|
3910
|
+
onDragEvent: zoned.onDragEvent,
|
|
3657
3911
|
getEventId,
|
|
3658
3912
|
onChangeDate,
|
|
3659
3913
|
onPressDateHeader,
|