@super-calendar/dom 2.17.0 → 2.19.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 +435 -150
- package/dist/index.mjs +437 -152
- package/package.json +2 -2
- package/src/Agenda.tsx +20 -3
- package/src/Calendar.tsx +106 -30
- package/src/MonthList.tsx +1 -1
- package/src/MonthView.tsx +243 -46
- package/src/ResourceTimeline.tsx +11 -7
- package/src/TimeGrid.tsx +363 -153
- package/src/YearView.tsx +21 -5
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,7 +637,15 @@ 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
|
|
648
|
+
const pressedEvent = (event) => event.target instanceof Element && event.target.closest("[data-slot=\"chipButton\"]") !== null;
|
|
639
649
|
const EMPTY_LAYOUT = {
|
|
640
650
|
segments: [],
|
|
641
651
|
laneCount: 0
|
|
@@ -644,6 +654,8 @@ const CHIP_HEIGHT = 18;
|
|
|
644
654
|
const CHIP_GAP = 2;
|
|
645
655
|
const CELL_PAD = 4;
|
|
646
656
|
const DRAGGED_CHIP_OPACITY = .4;
|
|
657
|
+
const DRAG_SLOP_PX = 4;
|
|
658
|
+
const TOUCH_DRAG_SLOP_PX = 8;
|
|
647
659
|
const isOutsidePeriod = (day) => day.isCurrentMonth === false;
|
|
648
660
|
function dayCellDefault(day, theme, highlightWeekends) {
|
|
649
661
|
return {
|
|
@@ -869,7 +881,7 @@ function MonthView({ date, showAdjacentMonths = true, ...rest }) {
|
|
|
869
881
|
* The day-row grid behind the public row views: week rows of day cells with
|
|
870
882
|
* spanning event bars, overflow, selection, drag, and keyboard handling.
|
|
871
883
|
*/
|
|
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 }) {
|
|
884
|
+
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
885
|
const { date } = source;
|
|
874
886
|
const multiWeek = source.kind === "multiweek";
|
|
875
887
|
const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
|
|
@@ -881,8 +893,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
881
893
|
classNames,
|
|
882
894
|
styles
|
|
883
895
|
});
|
|
884
|
-
const
|
|
896
|
+
const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
|
|
897
|
+
const eventsMode = events !== void 0 || multiWeek || createContentEnabled;
|
|
885
898
|
const dayRoving = !eventsMode || keyboardDayNavigation;
|
|
899
|
+
const todayKey = (0, date_fns.startOfDay)((0, _super_calendar_core.nowInTimeZone)(now, timeZone)).getTime();
|
|
886
900
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
887
901
|
if (eventsByDayProp) return eventsByDayProp;
|
|
888
902
|
const map = (0, _super_calendar_core.groupEventsByDay)((events ?? []).filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
|
|
@@ -930,7 +944,8 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
930
944
|
minDate,
|
|
931
945
|
maxDate,
|
|
932
946
|
isDateDisabled,
|
|
933
|
-
locale
|
|
947
|
+
locale,
|
|
948
|
+
today: new Date(todayKey)
|
|
934
949
|
};
|
|
935
950
|
if (numberOfWeeks === void 0) return {
|
|
936
951
|
...(0, _super_calendar_core.buildMonthGrid)(date, options),
|
|
@@ -958,7 +973,8 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
958
973
|
minDate,
|
|
959
974
|
maxDate,
|
|
960
975
|
isDateDisabled,
|
|
961
|
-
locale
|
|
976
|
+
locale,
|
|
977
|
+
todayKey
|
|
962
978
|
]);
|
|
963
979
|
const weekLayouts = (0, react.useMemo)(() => eventsMode ? weeks.map((week) => (0, _super_calendar_core.layoutMonthWeek)(week.days.map((d) => d.date), collectRowEvents(week, eventsByDay))) : [], [
|
|
964
980
|
eventsMode,
|
|
@@ -1024,54 +1040,102 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1024
1040
|
(focusKey ? gridRef.current.querySelector(`[data-day="${focusKey}"]`) : gridRef.current)?.focus();
|
|
1025
1041
|
}, [multiWeek, focusKey]);
|
|
1026
1042
|
const [drag, setDrag] = (0, react.useState)(null);
|
|
1027
|
-
const dragRef = (0, react.useRef)(
|
|
1028
|
-
|
|
1043
|
+
const dragRef = (0, react.useRef)(null);
|
|
1044
|
+
const applyDrag = (0, react.useCallback)((next) => {
|
|
1045
|
+
dragRef.current = next;
|
|
1046
|
+
setDrag(next);
|
|
1047
|
+
}, []);
|
|
1048
|
+
const createStart = drag?.kind === "create" ? drag.anchor : null;
|
|
1049
|
+
const createEnd = drag?.kind === "create" ? drag.hover : null;
|
|
1050
|
+
const createRange = (0, react.useMemo)(() => createContentEnabled && createStart !== null && createEnd !== null ? (0, _super_calendar_core.monthCreateRange)(new Date(createStart), new Date(createEnd)) : null, [
|
|
1051
|
+
createContentEnabled,
|
|
1052
|
+
createStart,
|
|
1053
|
+
createEnd
|
|
1054
|
+
]);
|
|
1055
|
+
const visibleLanesFor = (0, react.useCallback)((laneCount) => laneCount > maxVisibleEventCount ? Math.max(maxVisibleEventCount - 1, 1) : laneCount, [maxVisibleEventCount]);
|
|
1056
|
+
const draftEvent = (0, react.useMemo)(() => createRange ? {
|
|
1057
|
+
title: "",
|
|
1058
|
+
start: createRange.start,
|
|
1059
|
+
end: createRange.end,
|
|
1060
|
+
allDay: true
|
|
1061
|
+
} : null, [createRange]);
|
|
1062
|
+
const rowLayouts = (0, react.useMemo)(() => {
|
|
1063
|
+
if (!draftEvent) return weekLayouts;
|
|
1064
|
+
const days = (0, _super_calendar_core.withDraftEventDays)(eventsByDay, draftEvent);
|
|
1065
|
+
return weeks.map((week, index) => {
|
|
1066
|
+
const base = weekLayouts[index] ?? EMPTY_LAYOUT;
|
|
1067
|
+
if (!week.days.some((d) => d.date >= draftEvent.start && d.date < draftEvent.end)) return base;
|
|
1068
|
+
const placed = (0, _super_calendar_core.layoutMonthWeek)(week.days.map((d) => d.date), collectRowEvents(week, days));
|
|
1069
|
+
return (0, _super_calendar_core.keepMonthDraftVisible)(placed, base, draftEvent, {
|
|
1070
|
+
visibleLanes: visibleLanesFor,
|
|
1071
|
+
extraLaneFits: (visibleLanes) => visibleLanes < maxVisibleEventCount
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
}, [
|
|
1075
|
+
draftEvent,
|
|
1076
|
+
weekLayouts,
|
|
1077
|
+
eventsByDay,
|
|
1078
|
+
weeks,
|
|
1079
|
+
visibleLanesFor,
|
|
1080
|
+
maxVisibleEventCount
|
|
1081
|
+
]);
|
|
1029
1082
|
const movedRef = (0, react.useRef)(false);
|
|
1030
1083
|
const suppressClickRef = (0, react.useRef)(false);
|
|
1031
|
-
const consumeSuppressedClick = () => {
|
|
1032
|
-
if (!suppressClickRef.current) return false;
|
|
1084
|
+
const consumeSuppressedClick = (detail) => {
|
|
1085
|
+
if (detail === 0 || !suppressClickRef.current) return false;
|
|
1033
1086
|
suppressClickRef.current = false;
|
|
1034
1087
|
return true;
|
|
1035
1088
|
};
|
|
1036
1089
|
const canMove = (event) => onDragEvent != null && !event.disabled && event.draggable !== false && (event.startEditable ?? eventStartEditable);
|
|
1090
|
+
const pressOrigin = (0, react.useRef)({
|
|
1091
|
+
x: 0,
|
|
1092
|
+
y: 0,
|
|
1093
|
+
slop: DRAG_SLOP_PX
|
|
1094
|
+
});
|
|
1037
1095
|
const beginPress = () => {
|
|
1038
1096
|
suppressClickRef.current = false;
|
|
1039
1097
|
movedRef.current = false;
|
|
1040
1098
|
};
|
|
1041
|
-
const beginCreate = (day) => {
|
|
1099
|
+
const beginCreate = (day, pointerId, armed) => {
|
|
1042
1100
|
if (!onCreateEvent && !onSelectDrag) return;
|
|
1043
1101
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
1044
|
-
|
|
1102
|
+
applyDrag({
|
|
1045
1103
|
kind: "create",
|
|
1046
1104
|
anchor: t,
|
|
1047
1105
|
hover: t,
|
|
1048
|
-
windowKey
|
|
1106
|
+
windowKey,
|
|
1107
|
+
pointerId,
|
|
1108
|
+
armed
|
|
1049
1109
|
});
|
|
1050
1110
|
};
|
|
1051
|
-
const beginMove = (event, day) => {
|
|
1111
|
+
const beginMove = (event, day, pointerId, armed) => {
|
|
1052
1112
|
if (!canMove(event)) return;
|
|
1053
1113
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
1054
|
-
|
|
1114
|
+
applyDrag({
|
|
1055
1115
|
kind: "move",
|
|
1056
1116
|
event,
|
|
1057
1117
|
from: t,
|
|
1058
1118
|
to: t,
|
|
1059
|
-
windowKey
|
|
1119
|
+
windowKey,
|
|
1120
|
+
pointerId,
|
|
1121
|
+
armed
|
|
1060
1122
|
});
|
|
1061
1123
|
onDragStart?.(event);
|
|
1062
1124
|
};
|
|
1063
|
-
const extendDrag = (day) => {
|
|
1125
|
+
const extendDrag = (day, pointerId) => {
|
|
1064
1126
|
const current = dragRef.current;
|
|
1065
|
-
if (!current) return;
|
|
1127
|
+
if (!current || current.pointerId !== pointerId) return;
|
|
1066
1128
|
const t = (0, date_fns.startOfDay)(day).getTime();
|
|
1067
1129
|
if (t === (current.kind === "create" ? current.hover : current.to)) return;
|
|
1068
1130
|
movedRef.current = true;
|
|
1069
|
-
|
|
1131
|
+
applyDrag(current.kind === "create" ? {
|
|
1070
1132
|
...current,
|
|
1071
|
-
hover: t
|
|
1133
|
+
hover: t,
|
|
1134
|
+
armed: true
|
|
1072
1135
|
} : {
|
|
1073
1136
|
...current,
|
|
1074
|
-
to: t
|
|
1137
|
+
to: t,
|
|
1138
|
+
armed: true
|
|
1075
1139
|
});
|
|
1076
1140
|
if (current.kind === "create") {
|
|
1077
1141
|
const [lo, hi] = current.anchor <= t ? [current.anchor, t] : [t, current.anchor];
|
|
@@ -1096,12 +1160,18 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1096
1160
|
const pressRow = (event, day, moving) => {
|
|
1097
1161
|
if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
|
|
1098
1162
|
beginPress();
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1163
|
+
if (!moving && pressedEvent(event.nativeEvent)) return;
|
|
1164
|
+
pressOrigin.current = {
|
|
1165
|
+
x: event.clientX,
|
|
1166
|
+
y: event.clientY,
|
|
1167
|
+
slop: event.pointerType === "touch" ? TOUCH_DRAG_SLOP_PX : DRAG_SLOP_PX
|
|
1168
|
+
};
|
|
1169
|
+
const start = (armed) => {
|
|
1170
|
+
if (moving) touchHandlers.current.beginMove(moving, day, event.pointerId, armed);
|
|
1171
|
+
else touchHandlers.current.beginCreate(day, event.pointerId, armed);
|
|
1102
1172
|
};
|
|
1103
1173
|
if (!multiWeek || !event.pointerType || event.pointerType === "mouse") {
|
|
1104
|
-
start();
|
|
1174
|
+
start(false);
|
|
1105
1175
|
return;
|
|
1106
1176
|
}
|
|
1107
1177
|
heldOrigin.current = {
|
|
@@ -1114,14 +1184,13 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1114
1184
|
pointerType: event.pointerType,
|
|
1115
1185
|
clientX: event.clientX,
|
|
1116
1186
|
clientY: event.clientY
|
|
1117
|
-
}, start, (x, y) => {
|
|
1187
|
+
}, () => start(true), (x, y) => {
|
|
1118
1188
|
const element = gridRef.current?.ownerDocument.elementFromPoint(x, y)?.closest("[data-day]");
|
|
1119
1189
|
if (!element || !gridRef.current?.contains(element)) return;
|
|
1120
1190
|
const day = touchHandlers.current.dayLookup.get(element.dataset.day ?? "");
|
|
1121
|
-
if (day && !day.isDisabled) touchHandlers.current.extendDrag(day.date);
|
|
1191
|
+
if (day && !day.isDisabled) touchHandlers.current.extendDrag(day.date, event.pointerId);
|
|
1122
1192
|
}, () => {
|
|
1123
|
-
|
|
1124
|
-
setDrag(null);
|
|
1193
|
+
applyDrag(null);
|
|
1125
1194
|
movedRef.current = false;
|
|
1126
1195
|
}, () => {
|
|
1127
1196
|
heldTouch.current = null;
|
|
@@ -1143,13 +1212,18 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1143
1212
|
if (!enabled(origin.day) || !enabled(destination) || (origin.event ? !events?.includes(origin.event) || !canMove(origin.event) : !onCreateEvent && !onSelectDrag)) heldTouch.current?.();
|
|
1144
1213
|
});
|
|
1145
1214
|
const isDragging = drag !== null;
|
|
1215
|
+
const dragArmed = drag?.armed === true;
|
|
1146
1216
|
const dragWired = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
1147
1217
|
(0, react.useEffect)(() => {
|
|
1148
1218
|
if (!isDragging) return;
|
|
1149
|
-
const finish = () => {
|
|
1219
|
+
const finish = (event) => {
|
|
1150
1220
|
const current = dragRef.current;
|
|
1151
|
-
|
|
1152
|
-
|
|
1221
|
+
if (!current || current.pointerId !== event.pointerId) return;
|
|
1222
|
+
applyDrag(null);
|
|
1223
|
+
if (!movedRef.current) {
|
|
1224
|
+
if (current.kind === "move" && current.armed) suppressClickRef.current = true;
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1153
1227
|
if (multiWeek && current.windowKey !== windowKeyRef.current) return;
|
|
1154
1228
|
suppressClickRef.current = true;
|
|
1155
1229
|
if (current.kind === "create") {
|
|
@@ -1162,24 +1236,61 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1162
1236
|
if (eventOverlap === false && (0, _super_calendar_core.overlapsOtherEvents)(events ?? [], current.event, next.start, next.end)) return;
|
|
1163
1237
|
onDragEvent?.(current.event, next.start, next.end);
|
|
1164
1238
|
};
|
|
1239
|
+
const clear = () => {
|
|
1240
|
+
heldTouch.current?.();
|
|
1241
|
+
applyDrag(null);
|
|
1242
|
+
movedRef.current = false;
|
|
1243
|
+
suppressClickRef.current = true;
|
|
1244
|
+
};
|
|
1245
|
+
const cancel = (event) => {
|
|
1246
|
+
if (dragRef.current?.pointerId === event.pointerId) clear();
|
|
1247
|
+
};
|
|
1248
|
+
const arm = (event) => {
|
|
1249
|
+
const current = dragRef.current;
|
|
1250
|
+
if (!current || current.armed || current.pointerId !== event.pointerId) return;
|
|
1251
|
+
const origin = pressOrigin.current;
|
|
1252
|
+
if (Math.hypot(event.clientX - origin.x, event.clientY - origin.y) <= origin.slop) return;
|
|
1253
|
+
applyDrag({
|
|
1254
|
+
...current,
|
|
1255
|
+
armed: true
|
|
1256
|
+
});
|
|
1257
|
+
};
|
|
1258
|
+
const keyDown = (event) => {
|
|
1259
|
+
if (event.key !== "Escape") return;
|
|
1260
|
+
event.preventDefault();
|
|
1261
|
+
clear();
|
|
1262
|
+
};
|
|
1263
|
+
window.addEventListener("pointermove", arm);
|
|
1165
1264
|
window.addEventListener("pointerup", finish);
|
|
1166
|
-
|
|
1265
|
+
window.addEventListener("pointercancel", cancel);
|
|
1266
|
+
window.addEventListener("keydown", keyDown);
|
|
1267
|
+
return () => {
|
|
1268
|
+
window.removeEventListener("pointermove", arm);
|
|
1269
|
+
window.removeEventListener("pointerup", finish);
|
|
1270
|
+
window.removeEventListener("pointercancel", cancel);
|
|
1271
|
+
window.removeEventListener("keydown", keyDown);
|
|
1272
|
+
};
|
|
1167
1273
|
}, [
|
|
1168
1274
|
isDragging,
|
|
1169
1275
|
multiWeek,
|
|
1170
1276
|
onCreateEvent,
|
|
1171
1277
|
onDragEvent,
|
|
1172
1278
|
eventOverlap,
|
|
1173
|
-
events
|
|
1279
|
+
events,
|
|
1280
|
+
applyDrag
|
|
1174
1281
|
]);
|
|
1175
1282
|
const transientWindow = (0, react.useRef)(windowKey);
|
|
1176
1283
|
(0, react.useEffect)(() => {
|
|
1177
1284
|
if (transientWindow.current === windowKey) return;
|
|
1178
1285
|
transientWindow.current = windowKey;
|
|
1179
1286
|
if (!multiWeek) return;
|
|
1180
|
-
|
|
1287
|
+
applyDrag(null);
|
|
1181
1288
|
setMoreOpenFor(null);
|
|
1182
|
-
}, [
|
|
1289
|
+
}, [
|
|
1290
|
+
multiWeek,
|
|
1291
|
+
windowKey,
|
|
1292
|
+
applyDrag
|
|
1293
|
+
]);
|
|
1183
1294
|
const nextMultiWeekFocus = (key) => {
|
|
1184
1295
|
if (!focusableDays || !focusableKeys || !period) return void 0;
|
|
1185
1296
|
const index = focusableDays.findIndex((d) => (0, date_fns.format)(d, "yyyy-MM-dd") === focusKey);
|
|
@@ -1279,9 +1390,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1279
1390
|
overflowY: "auto"
|
|
1280
1391
|
} } : void 0),
|
|
1281
1392
|
children: weeks.map((week, weekIndex) => {
|
|
1282
|
-
const rowLayout =
|
|
1283
|
-
const visibleLanes = rowLayout.laneCount
|
|
1393
|
+
const rowLayout = rowLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
1394
|
+
const visibleLanes = visibleLanesFor(rowLayout.laneCount);
|
|
1284
1395
|
const cols = week.days.length;
|
|
1396
|
+
const extraLane = visibleLanes < maxVisibleEventCount ? (0, _super_calendar_core.monthExtraLaneColumns)(rowLayout, visibleLanes, cols) : week.days.map(() => false);
|
|
1285
1397
|
let firstVisCol = 0;
|
|
1286
1398
|
let lastVisCol = cols - 1;
|
|
1287
1399
|
if (eventsMode && !showAdjacentMonths) {
|
|
@@ -1292,7 +1404,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1292
1404
|
lastVisCol = cols - 1 - lastFromEnd;
|
|
1293
1405
|
}
|
|
1294
1406
|
}
|
|
1295
|
-
const barSegs = rowLayout.
|
|
1407
|
+
const barSegs = (0, _super_calendar_core.monthVisibleBars)(rowLayout, visibleLanes, extraLane).filter((s) => s.event !== draftEvent).map((s) => {
|
|
1296
1408
|
const startCol = Math.max(s.startCol, firstVisCol);
|
|
1297
1409
|
const endCol = Math.min(s.endCol, lastVisCol);
|
|
1298
1410
|
return {
|
|
@@ -1303,6 +1415,11 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1303
1415
|
continuesAfter: s.continuesAfter || endCol < s.endCol
|
|
1304
1416
|
};
|
|
1305
1417
|
}).filter((b) => b.startCol <= b.endCol);
|
|
1418
|
+
const draftSegment = rowLayout.segments.find((s) => s.event === draftEvent);
|
|
1419
|
+
const draftStart = draftSegment ? Math.max(draftSegment.startCol, firstVisCol) : -1;
|
|
1420
|
+
const draftEnd = draftSegment ? Math.min(draftSegment.endCol, lastVisCol) : -1;
|
|
1421
|
+
const draftTop = 28 + chipGap + (draftSegment?.lane ?? 0) * (chipHeight + chipGap);
|
|
1422
|
+
const draftHeight = Math.min(chipHeight, Math.max(0, eventRowHeight - draftTop));
|
|
1306
1423
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1307
1424
|
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
1308
1425
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1312,6 +1429,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1312
1429
|
gridTemplateColumns: `repeat(${week.days.length}, minmax(0, 1fr))`
|
|
1313
1430
|
} }),
|
|
1314
1431
|
children: week.days.map((day, dayCol) => {
|
|
1432
|
+
const dayLanes = visibleLanes + (extraLane[dayCol] ? 1 : 0);
|
|
1315
1433
|
const hidden = !showAdjacentMonths && isOutsidePeriod(day);
|
|
1316
1434
|
const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
|
|
1317
1435
|
if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1341,7 +1459,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1341
1459
|
});
|
|
1342
1460
|
if (eventsMode) {
|
|
1343
1461
|
const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString()) ?? [];
|
|
1344
|
-
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >=
|
|
1462
|
+
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= dayLanes && s.event !== draftEvent).map((s) => s.event);
|
|
1345
1463
|
const dayLabel = (0, date_fns.format)(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
1346
1464
|
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget, chipGap));
|
|
1347
1465
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -1369,9 +1487,9 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1369
1487
|
onPointerDown: dragWired && !day.isDisabled ? (e) => {
|
|
1370
1488
|
pressRow(e, day.date);
|
|
1371
1489
|
} : void 0,
|
|
1372
|
-
onPointerEnter: dragWired && !day.isDisabled ? () => extendDrag(day.date) : void 0,
|
|
1373
|
-
onClick: day.isDisabled ? void 0 : () => {
|
|
1374
|
-
if (consumeSuppressedClick()) return;
|
|
1490
|
+
onPointerEnter: dragWired && !day.isDisabled ? (event) => extendDrag(day.date, event.pointerId) : void 0,
|
|
1491
|
+
onClick: day.isDisabled ? void 0 : (e) => {
|
|
1492
|
+
if (consumeSuppressedClick(e.detail)) return;
|
|
1375
1493
|
onPressDay?.(day.date);
|
|
1376
1494
|
onPressCell?.((0, date_fns.startOfDay)(day.date));
|
|
1377
1495
|
},
|
|
@@ -1396,7 +1514,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1396
1514
|
}),
|
|
1397
1515
|
barSegs.filter((b) => b.startCol === dayCol).map((b) => {
|
|
1398
1516
|
const span = b.endCol - b.startCol + 1;
|
|
1399
|
-
const isDragged = drag?.kind === "move" && drag.event === b.seg.event;
|
|
1517
|
+
const isDragged = dragArmed && drag?.kind === "move" && drag.event === b.seg.event;
|
|
1400
1518
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1401
1519
|
type: "button",
|
|
1402
1520
|
onPointerDown: canMove(b.seg.event) ? (e) => {
|
|
@@ -1406,7 +1524,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1406
1524
|
} : void 0,
|
|
1407
1525
|
onClick: (e) => {
|
|
1408
1526
|
e.stopPropagation();
|
|
1409
|
-
if (consumeSuppressedClick()) return;
|
|
1527
|
+
if (consumeSuppressedClick(e.detail)) return;
|
|
1410
1528
|
onPressEvent?.(b.seg.event);
|
|
1411
1529
|
},
|
|
1412
1530
|
...barChipButton,
|
|
@@ -1423,7 +1541,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1423
1541
|
width: `calc(${span * 100}% - 4px)`,
|
|
1424
1542
|
top: 28 + chipGap + b.seg.lane * (chipHeight + chipGap),
|
|
1425
1543
|
height: chipHeight,
|
|
1426
|
-
pointerEvents:
|
|
1544
|
+
pointerEvents: dragArmed ? "none" : "auto",
|
|
1427
1545
|
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1428
1546
|
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
1429
1547
|
touchAction: dragWired ? multiWeek ? "pan-y" : "none" : void 0,
|
|
@@ -1448,8 +1566,36 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1448
1566
|
},
|
|
1449
1567
|
children: b.seg.event.title
|
|
1450
1568
|
})
|
|
1451
|
-
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`);
|
|
1569
|
+
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}:${b.startCol}`);
|
|
1452
1570
|
}),
|
|
1571
|
+
RenderCreateGhost && createRange && draftStart === dayCol && draftEnd >= draftStart && draftHeight > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InertDiv, {
|
|
1572
|
+
...slot("createGhost", {
|
|
1573
|
+
base: {
|
|
1574
|
+
position: "absolute",
|
|
1575
|
+
left: 2,
|
|
1576
|
+
width: `calc(${(draftEnd - draftStart + 1) * 100}% - 4px)`,
|
|
1577
|
+
top: draftTop,
|
|
1578
|
+
height: draftHeight,
|
|
1579
|
+
boxSizing: "border-box",
|
|
1580
|
+
pointerEvents: "none",
|
|
1581
|
+
overflow: "hidden",
|
|
1582
|
+
zIndex: 3
|
|
1583
|
+
},
|
|
1584
|
+
themed: {
|
|
1585
|
+
background: theme.rangeBackground,
|
|
1586
|
+
border: `1px solid ${theme.selectedBackground}`,
|
|
1587
|
+
borderRadius: 4,
|
|
1588
|
+
fontSize: 12,
|
|
1589
|
+
color: theme.text
|
|
1590
|
+
}
|
|
1591
|
+
}),
|
|
1592
|
+
inert: true,
|
|
1593
|
+
"aria-hidden": "true",
|
|
1594
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderCreateGhost, {
|
|
1595
|
+
start: createRange.start,
|
|
1596
|
+
end: createRange.end
|
|
1597
|
+
})
|
|
1598
|
+
}) : null,
|
|
1453
1599
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1454
1600
|
...slot("events", { base: {
|
|
1455
1601
|
display: "flex",
|
|
@@ -1457,7 +1603,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1457
1603
|
gap: chipGap
|
|
1458
1604
|
} }),
|
|
1459
1605
|
children: [
|
|
1460
|
-
Array.from({ length:
|
|
1606
|
+
Array.from({ length: dayLanes }, (_, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1461
1607
|
"aria-hidden": true,
|
|
1462
1608
|
style: { height: chipHeight }
|
|
1463
1609
|
}, `lane-${i}`)),
|
|
@@ -1977,19 +2123,13 @@ function EventActionsDialog({ dialogRef, title, description, actions, closeLabel
|
|
|
1977
2123
|
})
|
|
1978
2124
|
});
|
|
1979
2125
|
}
|
|
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
2126
|
// src/TimeGrid.tsx
|
|
1988
2127
|
const GUTTER_WIDTH$1 = 56;
|
|
1989
2128
|
const HOURS_PER_DAY = 24;
|
|
1990
2129
|
const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
1991
2130
|
const DEFAULT_EVENT_GAP = 1;
|
|
1992
2131
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
2132
|
+
const useClientLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
1993
2133
|
const CREATE_PREVIEW_MIN_HEIGHT = 2;
|
|
1994
2134
|
function createPreviewPlacement(topPx, heightPx, gridHeight) {
|
|
1995
2135
|
const start = clamp$1(topPx, 0, gridHeight);
|
|
@@ -2004,6 +2144,11 @@ function createPreviewPlacement(topPx, heightPx, gridHeight) {
|
|
|
2004
2144
|
height
|
|
2005
2145
|
};
|
|
2006
2146
|
}
|
|
2147
|
+
function createRangePlacement(range, day, hourHeight, minHour, gridHeight, minEventHeight) {
|
|
2148
|
+
const at = (time) => ((0, date_fns.differenceInCalendarDays)(time, day) * 24 + time.getHours() + time.getMinutes() / 60 - minHour) * hourHeight;
|
|
2149
|
+
const top = at(range.start);
|
|
2150
|
+
return createPreviewPlacement(top, Math.max(minEventHeight, at(range.end) - top), gridHeight);
|
|
2151
|
+
}
|
|
2007
2152
|
const EDGE_ZONE = 32;
|
|
2008
2153
|
const EDGE_DWELL_MS = 600;
|
|
2009
2154
|
const EDGE_REPEAT_MS = 600;
|
|
@@ -2027,6 +2172,20 @@ function movedSegmentStart(origin, base, startHours) {
|
|
|
2027
2172
|
const dayMinutes = (0, date_fns.differenceInCalendarDays)(base, origin.base) * HOURS_PER_DAY * 60;
|
|
2028
2173
|
return (0, _super_calendar_core.shiftMinutes)(origin.segmentStart, dayMinutes + Math.round((startHours - origin.startHours) * 60));
|
|
2029
2174
|
}
|
|
2175
|
+
function draggedEventBounds(d, origin, event, base, snapMinutes) {
|
|
2176
|
+
if (d.kind === "resize") {
|
|
2177
|
+
const endDelta = Math.round((d.startHours + d.durationHours - origin.startHours - origin.durationHours) * 60);
|
|
2178
|
+
return (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, 0, endDelta, snapMinutes);
|
|
2179
|
+
}
|
|
2180
|
+
const startShift = movedSegmentStart(origin, base, d.kind === "move" ? d.requestedStartHours : d.startHours).getTime() - origin.segmentStart.getTime();
|
|
2181
|
+
const endShift = d.kind === "move" ? startShift : 0;
|
|
2182
|
+
const start = new Date(event.start.getTime() + startShift);
|
|
2183
|
+
const end = new Date(event.end.getTime() + endShift);
|
|
2184
|
+
return end > start || d.kind === "move" && end.getTime() === start.getTime() ? {
|
|
2185
|
+
start,
|
|
2186
|
+
end
|
|
2187
|
+
} : null;
|
|
2188
|
+
}
|
|
2030
2189
|
function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme, boxProps }) {
|
|
2031
2190
|
const timeLabel = (0, _super_calendar_core.eventTimeLabel)({
|
|
2032
2191
|
mode,
|
|
@@ -2128,6 +2287,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2128
2287
|
now: nowProp,
|
|
2129
2288
|
timeZone
|
|
2130
2289
|
});
|
|
2290
|
+
const todayDate = showNowIndicator ? now : (0, _super_calendar_core.nowInTimeZone)(nowProp, timeZone);
|
|
2131
2291
|
const [hourHeight, setHourHeight] = (0, react.useState)(initialHourHeight);
|
|
2132
2292
|
(0, react.useEffect)(() => setHourHeight(initialHourHeight), [initialHourHeight]);
|
|
2133
2293
|
const hourHeightRef = (0, react.useRef)(hourHeight);
|
|
@@ -2142,6 +2302,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2142
2302
|
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
2143
2303
|
const createOrigin = (0, react.useRef)(null);
|
|
2144
2304
|
const createActive = createBox !== null;
|
|
2305
|
+
const detachCreateListeners = (0, react.useRef)(null);
|
|
2306
|
+
const createRelease = (0, react.useRef)(null);
|
|
2145
2307
|
(0, react.useEffect)(() => {
|
|
2146
2308
|
if (!createActive) return;
|
|
2147
2309
|
const onScroll = () => {
|
|
@@ -2207,6 +2369,11 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2207
2369
|
canResize: editable && (event.durationEditable ?? eventDurationEditable)
|
|
2208
2370
|
};
|
|
2209
2371
|
};
|
|
2372
|
+
const hasEditActions = (event) => {
|
|
2373
|
+
if ((0, _super_calendar_core.isAllDayEvent)(event) || (0, _super_calendar_core.isBackgroundEvent)(event)) return false;
|
|
2374
|
+
const { canMove, canResize } = editability(event);
|
|
2375
|
+
return canMove || canResize;
|
|
2376
|
+
};
|
|
2210
2377
|
const eventLabel = (event) => eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
2211
2378
|
mode,
|
|
2212
2379
|
isAllDay: false,
|
|
@@ -2234,7 +2401,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2234
2401
|
}
|
|
2235
2402
|
};
|
|
2236
2403
|
const editActions = (event) => {
|
|
2237
|
-
if ((
|
|
2404
|
+
if (!hasEditActions(event)) return [];
|
|
2238
2405
|
const { canMove, canResize } = editability(event);
|
|
2239
2406
|
const action = (id, label) => {
|
|
2240
2407
|
const [startDelta, endDelta] = actionDelta(id) ?? [0, 0];
|
|
@@ -2256,12 +2423,36 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2256
2423
|
if (!next || onDragEventRef.current?.(event, next.start, next.end) === false) return null;
|
|
2257
2424
|
return (candidate) => candidate !== event && candidate.start.getTime() === next.start.getTime() && candidate.end.getTime() === next.end.getTime() && candidate.title === event.title;
|
|
2258
2425
|
}, getEventId);
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2426
|
+
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]);
|
|
2427
|
+
const hasAllDay = allDayLayout.segments.length > 0;
|
|
2428
|
+
const allDayIds = (0, react.useMemo)(() => {
|
|
2429
|
+
const keys = /* @__PURE__ */ new Map();
|
|
2430
|
+
const seen = /* @__PURE__ */ new Map();
|
|
2431
|
+
for (const { event } of allDayLayout.segments) {
|
|
2432
|
+
const id = getEventId?.(event);
|
|
2433
|
+
if (typeof id !== "string" && typeof id !== "number") continue;
|
|
2434
|
+
const key = `${typeof id}:${id}`;
|
|
2435
|
+
const previous = seen.get(key);
|
|
2436
|
+
if (previous) keys.delete(previous);
|
|
2437
|
+
else {
|
|
2438
|
+
seen.set(key, event);
|
|
2439
|
+
keys.set(event, key);
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
return keys;
|
|
2443
|
+
}, [allDayLayout, getEventId]);
|
|
2444
|
+
const allDayKeys = (0, react.useRef)(/* @__PURE__ */ new WeakMap());
|
|
2445
|
+
const nextAllDayKey = (0, react.useRef)(0);
|
|
2446
|
+
const allDayKey = (event) => {
|
|
2447
|
+
const id = allDayIds.get(event);
|
|
2448
|
+
if (id !== void 0) return id;
|
|
2449
|
+
let key = allDayKeys.current.get(event);
|
|
2450
|
+
if (key === void 0) {
|
|
2451
|
+
key = nextAllDayKey.current++;
|
|
2452
|
+
allDayKeys.current.set(event, key);
|
|
2453
|
+
}
|
|
2454
|
+
return `object:${key}`;
|
|
2455
|
+
};
|
|
2265
2456
|
(0, react.useEffect)(() => {
|
|
2266
2457
|
if (scrollRef.current) scrollRef.current.scrollTop = Math.max(0, (scrollOffsetMinutes / 60 - windowStart) * hourHeightRef.current);
|
|
2267
2458
|
}, [scrollOffsetMinutes, windowStart]);
|
|
@@ -2361,6 +2552,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2361
2552
|
document.removeEventListener("pointermove", h.move);
|
|
2362
2553
|
document.removeEventListener("pointerup", h.up);
|
|
2363
2554
|
document.removeEventListener("pointercancel", h.cancel);
|
|
2555
|
+
document.removeEventListener("selectstart", h.preventNative, true);
|
|
2556
|
+
document.removeEventListener("dragstart", h.preventNative, true);
|
|
2364
2557
|
docHandlersRef.current = null;
|
|
2365
2558
|
};
|
|
2366
2559
|
const finishDrag = () => {
|
|
@@ -2468,18 +2661,14 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2468
2661
|
base = day ? (0, date_fns.startOfDay)(day) : null;
|
|
2469
2662
|
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
|
|
2470
2663
|
} 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);
|
|
2664
|
+
try {
|
|
2665
|
+
if (base && held && origin) {
|
|
2666
|
+
const next = draggedEventBounds(d, origin, held.event, base, snapMinutes);
|
|
2667
|
+
if (next) onDragEventRef.current?.(held.event, next.start, next.end);
|
|
2668
|
+
}
|
|
2669
|
+
} finally {
|
|
2670
|
+
finishDrag();
|
|
2481
2671
|
}
|
|
2482
|
-
finishDrag();
|
|
2483
2672
|
};
|
|
2484
2673
|
const cancelDrag = () => {
|
|
2485
2674
|
finishDrag();
|
|
@@ -2493,7 +2682,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2493
2682
|
activeGrabRef.current = e;
|
|
2494
2683
|
const boxEl = e.box;
|
|
2495
2684
|
const column = kind === "move" ? boxEl.parentElement : null;
|
|
2496
|
-
const
|
|
2685
|
+
const columnRect = column ? column.getBoundingClientRect() : null;
|
|
2686
|
+
const dayWidth = columnRect ? columnRect.width : 0;
|
|
2497
2687
|
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
2498
2688
|
const originBase = (0, date_fns.startOfDay)(days[dayIndex] ?? days[0]);
|
|
2499
2689
|
const originNextDay = (0, date_fns.addDays)(originBase, 1);
|
|
@@ -2513,9 +2703,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2513
2703
|
draggedRef.current = {
|
|
2514
2704
|
event,
|
|
2515
2705
|
onPress: onPress ?? (() => {}),
|
|
2516
|
-
grabX:
|
|
2706
|
+
grabX: column && columnRect ? e.clientX - columnRect.left - column.clientLeft - eventGap : 0,
|
|
2517
2707
|
grabY: boxRect ? e.clientY - boxRect.top : 0,
|
|
2518
|
-
w:
|
|
2708
|
+
w: column ? Math.max(column.clientWidth - eventGap * 2, 0) : 0,
|
|
2519
2709
|
h: boxRect ? boxRect.height : 0
|
|
2520
2710
|
};
|
|
2521
2711
|
ptr.current = {
|
|
@@ -2551,12 +2741,15 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2551
2741
|
},
|
|
2552
2742
|
cancel: (event) => {
|
|
2553
2743
|
if (event.pointerId === e.pointerId) cancelDrag();
|
|
2554
|
-
}
|
|
2744
|
+
},
|
|
2745
|
+
preventNative: (event) => event.preventDefault()
|
|
2555
2746
|
};
|
|
2556
2747
|
docHandlersRef.current = handlers;
|
|
2557
2748
|
document.addEventListener("pointermove", handlers.move);
|
|
2558
2749
|
document.addEventListener("pointerup", handlers.up);
|
|
2559
2750
|
document.addEventListener("pointercancel", handlers.cancel);
|
|
2751
|
+
document.addEventListener("selectstart", handlers.preventNative, true);
|
|
2752
|
+
document.addEventListener("dragstart", handlers.preventNative, true);
|
|
2560
2753
|
};
|
|
2561
2754
|
const pressEvent = (e, pe, key, kind, dayIndex, onPress) => {
|
|
2562
2755
|
if (!onDragEvent || e.button > 0) return;
|
|
@@ -2590,6 +2783,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2590
2783
|
cancelHoldRef.current?.();
|
|
2591
2784
|
detachDocListeners();
|
|
2592
2785
|
clearEdgeTimer();
|
|
2786
|
+
if (createOrigin.current?.captureLoss !== void 0) clearTimeout(createOrigin.current.captureLoss);
|
|
2787
|
+
createOrigin.current = null;
|
|
2788
|
+
detachCreateListeners.current?.();
|
|
2789
|
+
detachCreateListeners.current = null;
|
|
2593
2790
|
}, []);
|
|
2594
2791
|
(0, react.useEffect)(() => {
|
|
2595
2792
|
cancelHoldRef.current?.();
|
|
@@ -2600,6 +2797,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2600
2797
|
]);
|
|
2601
2798
|
const pxFromTop = (el, clientY) => clientY - el.getBoundingClientRect().top;
|
|
2602
2799
|
const beginCreate = (e, dayIndex) => {
|
|
2800
|
+
if (createOrigin.current || activeGrabRef.current || e.isPrimary === false) return;
|
|
2603
2801
|
cellTouchRef.current = e.pointerType === "touch" && e.target === e.currentTarget ? {
|
|
2604
2802
|
pointerId: e.pointerId,
|
|
2605
2803
|
x: e.clientX,
|
|
@@ -2628,12 +2826,33 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2628
2826
|
startPx,
|
|
2629
2827
|
curPx: startPx
|
|
2630
2828
|
});
|
|
2829
|
+
const document = el.ownerDocument;
|
|
2830
|
+
const release = (event) => createRelease.current?.(event);
|
|
2831
|
+
const cancel = (event) => {
|
|
2832
|
+
if (createOrigin.current?.pointerId === event.pointerId) clearCreate();
|
|
2833
|
+
};
|
|
2834
|
+
const restart = (event) => {
|
|
2835
|
+
if (event.isPrimary && event.pointerType !== "touch" || createOrigin.current?.pointerId === event.pointerId) clearCreate();
|
|
2836
|
+
};
|
|
2837
|
+
const preventSelection = (event) => event.preventDefault();
|
|
2838
|
+
document.addEventListener("pointerup", release, true);
|
|
2839
|
+
document.addEventListener("pointercancel", cancel, true);
|
|
2840
|
+
document.addEventListener("pointerdown", restart, true);
|
|
2841
|
+
document.addEventListener("selectstart", preventSelection, true);
|
|
2842
|
+
document.addEventListener("dragstart", preventSelection, true);
|
|
2843
|
+
detachCreateListeners.current = () => {
|
|
2844
|
+
document.removeEventListener("pointerup", release, true);
|
|
2845
|
+
document.removeEventListener("pointercancel", cancel, true);
|
|
2846
|
+
document.removeEventListener("pointerdown", restart, true);
|
|
2847
|
+
document.removeEventListener("selectstart", preventSelection, true);
|
|
2848
|
+
document.removeEventListener("dragstart", preventSelection, true);
|
|
2849
|
+
};
|
|
2631
2850
|
};
|
|
2632
2851
|
const moveCreate = (e) => {
|
|
2633
2852
|
const touch = cellTouchRef.current;
|
|
2634
2853
|
if (touch && e.pointerId === touch.pointerId && Math.hypot(e.clientX - touch.x, e.clientY - touch.y) > CELL_TOUCH_SLOP_PX) cellTouchRef.current = null;
|
|
2635
2854
|
const o = createOrigin.current;
|
|
2636
|
-
if (!o) return;
|
|
2855
|
+
if (!o || o.pointerId !== e.pointerId) return;
|
|
2637
2856
|
o.clientY = e.clientY;
|
|
2638
2857
|
setCreateBox({
|
|
2639
2858
|
dayIndex: o.dayIndex,
|
|
@@ -2644,10 +2863,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2644
2863
|
};
|
|
2645
2864
|
const endCreate = (e) => {
|
|
2646
2865
|
const o = createOrigin.current;
|
|
2647
|
-
if (!o) return;
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
} catch {}
|
|
2866
|
+
if (!o || o.pointerId !== e.pointerId) return;
|
|
2867
|
+
clearCreate();
|
|
2868
|
+
if (!o.el.isConnected || !cellEnabled || o.creating && !onCreateEvent || days[o.dayIndex]?.getTime() !== o.dayTime) return;
|
|
2651
2869
|
const endPx = pxFromTop(o.el, e.clientY);
|
|
2652
2870
|
const day = days[o.dayIndex];
|
|
2653
2871
|
const moved = Math.abs(endPx - o.startPx) > 4;
|
|
@@ -2659,9 +2877,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2659
2877
|
const at = (0, _super_calendar_core.cellRangeFromDrag)(day, o.startPx, o.startPx, h, windowStart, snapMinutes);
|
|
2660
2878
|
if (at) onPressCell(at.start);
|
|
2661
2879
|
}
|
|
2662
|
-
createOrigin.current = null;
|
|
2663
|
-
setCreateBox(null);
|
|
2664
2880
|
};
|
|
2881
|
+
useClientLayoutEffect(() => {
|
|
2882
|
+
createRelease.current = endCreate;
|
|
2883
|
+
});
|
|
2665
2884
|
const tapCell = (e, dayIndex) => {
|
|
2666
2885
|
const touch = cellTouchRef.current;
|
|
2667
2886
|
cellTouchRef.current = null;
|
|
@@ -2674,18 +2893,26 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2674
2893
|
const clearCreate = (0, react.useCallback)(() => {
|
|
2675
2894
|
const previous = createOrigin.current;
|
|
2676
2895
|
createOrigin.current = null;
|
|
2896
|
+
if (previous?.captureLoss !== void 0) clearTimeout(previous.captureLoss);
|
|
2897
|
+
detachCreateListeners.current?.();
|
|
2898
|
+
detachCreateListeners.current = null;
|
|
2677
2899
|
setCreateBox(null);
|
|
2678
2900
|
try {
|
|
2679
2901
|
previous?.el.releasePointerCapture?.(previous.pointerId);
|
|
2680
2902
|
} catch {}
|
|
2681
2903
|
}, []);
|
|
2682
|
-
const cancelCreate = () => {
|
|
2683
|
-
cellTouchRef.current = null;
|
|
2904
|
+
const cancelCreate = (e) => {
|
|
2905
|
+
if (cellTouchRef.current?.pointerId === e.pointerId) cellTouchRef.current = null;
|
|
2906
|
+
if (createOrigin.current?.pointerId !== e.pointerId) return;
|
|
2684
2907
|
clearCreate();
|
|
2685
2908
|
};
|
|
2686
2909
|
const loseCreateCapture = (e) => {
|
|
2687
|
-
|
|
2688
|
-
|
|
2910
|
+
const origin = createOrigin.current;
|
|
2911
|
+
if (!origin || origin.pointerId !== e.pointerId) return;
|
|
2912
|
+
if (origin.captureLoss !== void 0) clearTimeout(origin.captureLoss);
|
|
2913
|
+
origin.captureLoss = setTimeout(() => {
|
|
2914
|
+
if (createOrigin.current === origin) clearCreate();
|
|
2915
|
+
}, 0);
|
|
2689
2916
|
};
|
|
2690
2917
|
(0, react.useEffect)(() => {
|
|
2691
2918
|
const onKeyDown = (event) => {
|
|
@@ -2697,7 +2924,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2697
2924
|
document.addEventListener("keydown", onKeyDown);
|
|
2698
2925
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
2699
2926
|
}, [clearCreate]);
|
|
2700
|
-
const liveRange = createBox &&
|
|
2927
|
+
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
2928
|
const liveStart = liveRange?.start.getTime();
|
|
2702
2929
|
const liveEnd = liveRange?.end.getTime();
|
|
2703
2930
|
const createRange = (0, react.useMemo)(() => liveStart === void 0 || liveEnd === void 0 ? null : {
|
|
@@ -2712,7 +2939,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2712
2939
|
const moveOrigin = dragOrigin.current;
|
|
2713
2940
|
const heldEvent = draggedRef.current?.event;
|
|
2714
2941
|
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
|
|
2942
|
+
const multiDayHeld = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && !!movingEvent;
|
|
2943
|
+
const multiDayMove = !paged && drag?.kind === "move" && drag.moved && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
|
|
2716
2944
|
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
2717
2945
|
const shift = movedSegmentStart(moveOrigin, (0, date_fns.startOfDay)(target), drag.requestedStartHours).getTime() - moveOrigin.segmentStart.getTime();
|
|
2718
2946
|
return {
|
|
@@ -2722,12 +2950,18 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2722
2950
|
allDay: false
|
|
2723
2951
|
};
|
|
2724
2952
|
})() : null;
|
|
2953
|
+
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;
|
|
2954
|
+
const withLiveBounds = (event) => liveBounds ? {
|
|
2955
|
+
...event,
|
|
2956
|
+
start: liveBounds.start,
|
|
2957
|
+
end: liveBounds.end
|
|
2958
|
+
} : event;
|
|
2725
2959
|
const spillPreviewFor = (dayIndex) => {
|
|
2726
2960
|
if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
|
|
2727
2961
|
const dragged = draggedRef.current?.event;
|
|
2728
2962
|
if (!dragged) return null;
|
|
2729
2963
|
return {
|
|
2730
|
-
event: dragged,
|
|
2964
|
+
event: withLiveBounds(dragged),
|
|
2731
2965
|
mode,
|
|
2732
2966
|
isAllDay: false,
|
|
2733
2967
|
boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
|
|
@@ -2848,7 +3082,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2848
3082
|
},
|
|
2849
3083
|
children: [
|
|
2850
3084
|
/* @__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(
|
|
3085
|
+
events: [...new Set(positionedByDay.flat().filter((pe) => pe.startHours < windowEnd && pe.startHours + pe.durationHours > windowStart).map((pe) => pe.event))].filter(hasEditActions),
|
|
2852
3086
|
label: labels.editEvents,
|
|
2853
3087
|
labelFor: (event) => labels.eventActions(event.title ?? ""),
|
|
2854
3088
|
descriptionFor: eventDescription,
|
|
@@ -2879,7 +3113,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2879
3113
|
}),
|
|
2880
3114
|
children: showWeekNumber && gutterWidth > 0 && days[0] ? `${weekNumberPrefix}${(0, date_fns.getISOWeek)(days.find((d) => d.getDay() === 4) ?? days[0])}` : null
|
|
2881
3115
|
}), days.map((day) => {
|
|
2882
|
-
const today = (0, _super_calendar_core.getIsToday)(day);
|
|
3116
|
+
const today = (0, _super_calendar_core.getIsToday)(day, todayDate);
|
|
2883
3117
|
const dateLabel = (0, date_fns.format)(day, "EEEE, d MMMM yyyy", dfns);
|
|
2884
3118
|
const headerProps = slot("columnHeader", {
|
|
2885
3119
|
base: {
|
|
@@ -2956,6 +3190,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2956
3190
|
base: {
|
|
2957
3191
|
width: gutterWidth,
|
|
2958
3192
|
flex: "none",
|
|
3193
|
+
boxSizing: "border-box",
|
|
2959
3194
|
minWidth: 0,
|
|
2960
3195
|
overflow: "hidden",
|
|
2961
3196
|
textAlign: "right"
|
|
@@ -2963,34 +3198,41 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2963
3198
|
themed: {
|
|
2964
3199
|
fontSize: 10,
|
|
2965
3200
|
color: theme.textMuted,
|
|
2966
|
-
padding: "4px 6px 0 0"
|
|
3201
|
+
padding: hideHours ? 0 : "4px 6px 0 0"
|
|
2967
3202
|
}
|
|
2968
3203
|
}),
|
|
2969
3204
|
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
|
-
|
|
3205
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3206
|
+
style: {
|
|
3207
|
+
flex: 1,
|
|
3208
|
+
minWidth: 0,
|
|
3209
|
+
display: "grid",
|
|
3210
|
+
gridTemplateColumns: `repeat(${days.length}, minmax(0, 1fr))`,
|
|
3211
|
+
gap: "2px 0",
|
|
3212
|
+
padding: "2px 0"
|
|
3213
|
+
},
|
|
3214
|
+
children: allDayLayout.segments.map((segment) => {
|
|
3215
|
+
const { event, startCol, endCol, lane, continuesBefore, continuesAfter } = segment;
|
|
3216
|
+
const args = {
|
|
3217
|
+
event,
|
|
3218
|
+
mode,
|
|
3219
|
+
isAllDay: true,
|
|
3220
|
+
continuesBefore,
|
|
3221
|
+
continuesAfter,
|
|
3222
|
+
ampm,
|
|
3223
|
+
onPress: () => onPressEvent?.(event)
|
|
3224
|
+
};
|
|
3225
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3226
|
+
...slot("allDayColumn", { base: {
|
|
3227
|
+
gridColumn: `${startCol + 1} / span ${endCol - startCol + 1}`,
|
|
3228
|
+
gridRow: lane + 1,
|
|
3229
|
+
minWidth: 0,
|
|
3230
|
+
borderLeft: "1px solid transparent",
|
|
3231
|
+
padding: "0 1px",
|
|
3232
|
+
display: "flex",
|
|
3233
|
+
flexDirection: "column"
|
|
3234
|
+
} }),
|
|
3235
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2994
3236
|
type: "button",
|
|
2995
3237
|
onClick: () => onPressEvent?.(event),
|
|
2996
3238
|
"aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
@@ -3018,9 +3260,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3018
3260
|
theme,
|
|
3019
3261
|
boxProps: slot("eventBox")
|
|
3020
3262
|
})
|
|
3021
|
-
}
|
|
3022
|
-
})
|
|
3023
|
-
}
|
|
3263
|
+
})
|
|
3264
|
+
}, allDayKey(event));
|
|
3265
|
+
})
|
|
3024
3266
|
})]
|
|
3025
3267
|
}) : null,
|
|
3026
3268
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -3069,7 +3311,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3069
3311
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
3070
3312
|
const bands = bandsByDay[dayIndex];
|
|
3071
3313
|
const ghost = createBox?.dayIndex === dayIndex && createBox.dayTime === day.getTime() ? createBox : null;
|
|
3072
|
-
const ghostRange = ghost ? createRange : null;
|
|
3314
|
+
const ghostRange = ghost && RenderCreateGhost ? createRange : null;
|
|
3073
3315
|
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
3074
3316
|
const moveSegment = multiDayMove ? (0, _super_calendar_core.layoutDayEvents)([multiDayMove], day)[0] : void 0;
|
|
3075
3317
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -3081,7 +3323,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3081
3323
|
onLostPointerCapture: cellEnabled ? loseCreateCapture : void 0,
|
|
3082
3324
|
onClick: cellEnabled ? (e) => tapCell(e, dayIndex) : void 0,
|
|
3083
3325
|
...dataState({
|
|
3084
|
-
"data-today": (0, _super_calendar_core.getIsToday)(day),
|
|
3326
|
+
"data-today": (0, _super_calendar_core.getIsToday)(day, todayDate),
|
|
3085
3327
|
"data-weekend": (0, _super_calendar_core.isWeekend)(day)
|
|
3086
3328
|
}),
|
|
3087
3329
|
...slot("dayColumn", {
|
|
@@ -3169,7 +3411,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3169
3411
|
}),
|
|
3170
3412
|
positioned.map((pe, idx) => {
|
|
3171
3413
|
const key = `${dayIndex}:${idx}`;
|
|
3172
|
-
const active = !paged && drag?.key === key && (!
|
|
3414
|
+
const active = !paged && drag?.key === key && (!multiDayHeld || pe.event === movingEvent) ? drag : null;
|
|
3173
3415
|
const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
|
|
3174
3416
|
const startHours = active ? active.startHours : pe.startHours;
|
|
3175
3417
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
@@ -3177,9 +3419,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3177
3419
|
const top = (startHours - windowStart) * hourHeight;
|
|
3178
3420
|
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
|
|
3179
3421
|
const widthPct = 100 / pe.columns;
|
|
3422
|
+
const floating = active?.kind === "move" && active.moved;
|
|
3180
3423
|
const onPress = () => onPressEvent?.(pe.event);
|
|
3181
3424
|
const args = {
|
|
3182
|
-
event: pe.event,
|
|
3425
|
+
event: active ? withLiveBounds(pe.event) : pe.event,
|
|
3183
3426
|
mode,
|
|
3184
3427
|
isAllDay: false,
|
|
3185
3428
|
boxHeight,
|
|
@@ -3214,8 +3457,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3214
3457
|
position: "absolute",
|
|
3215
3458
|
top,
|
|
3216
3459
|
height: boxHeight,
|
|
3217
|
-
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
3218
|
-
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
3460
|
+
left: floating ? eventGap : `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
3461
|
+
width: floating ? `calc(100% - ${eventGap * 2}px)` : `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
3219
3462
|
cursor: canMove ? "grab" : "pointer",
|
|
3220
3463
|
touchAction: canMove ? "pan-y" : "auto",
|
|
3221
3464
|
userSelect: canMove ? "none" : void 0,
|
|
@@ -3343,7 +3586,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3343
3586
|
position: "absolute",
|
|
3344
3587
|
left: eventGap,
|
|
3345
3588
|
right: eventGap,
|
|
3346
|
-
...createPreviewPlacement(Math.min(ghost.startPx, ghost.curPx), Math.abs(ghost.curPx - ghost.startPx), totalHeight),
|
|
3589
|
+
...createRange ? createRangePlacement(createRange, day, hourHeight, windowStart, totalHeight, minEventHeight) : createPreviewPlacement(Math.min(ghost.startPx, ghost.curPx), Math.abs(ghost.curPx - ghost.startPx), totalHeight),
|
|
3347
3590
|
boxSizing: "border-box",
|
|
3348
3591
|
...ghostRange ? { overflow: "hidden" } : null,
|
|
3349
3592
|
opacity: .7,
|
|
@@ -3455,12 +3698,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3455
3698
|
const displayEvents = (0, react.useMemo)(() => {
|
|
3456
3699
|
let out = events ?? EMPTY_EVENTS;
|
|
3457
3700
|
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);
|
|
3701
|
+
const [start, end] = expansionRange(mode, date, weekStartsOn, numberOfDays, numberOfWeeks);
|
|
3702
|
+
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
3703
|
}
|
|
3465
3704
|
if (timeZone) out = (0, _super_calendar_core.eventsInTimeZone)(out, timeZone);
|
|
3466
3705
|
return out;
|
|
@@ -3473,6 +3712,42 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3473
3712
|
numberOfWeeks,
|
|
3474
3713
|
timeZone
|
|
3475
3714
|
]);
|
|
3715
|
+
const timeGridMode = mode !== "month" && mode !== "multiweek";
|
|
3716
|
+
const zoned = (0, react.useMemo)(() => {
|
|
3717
|
+
if (!timeZone) return {
|
|
3718
|
+
onPressEvent,
|
|
3719
|
+
onDragStart,
|
|
3720
|
+
onDragEvent,
|
|
3721
|
+
onPressMore,
|
|
3722
|
+
onPressTime: onPressCell,
|
|
3723
|
+
onCreateTimed: onCreateEvent
|
|
3724
|
+
};
|
|
3725
|
+
const instant = (wallClock) => (0, _super_calendar_core.fromZonedTime)(wallClock, timeZone);
|
|
3726
|
+
return {
|
|
3727
|
+
onPressEvent: onPressEvent && ((event) => onPressEvent((0, _super_calendar_core.zonedEventSource)(event))),
|
|
3728
|
+
onDragStart: onDragStart && ((event) => onDragStart((0, _super_calendar_core.zonedEventSource)(event))),
|
|
3729
|
+
onDragEvent: onDragEvent && ((event, start, end) => {
|
|
3730
|
+
const bounds = (0, _super_calendar_core.zonedDragBounds)(event, start, end, { keepDuration: timeGridMode });
|
|
3731
|
+
if (!bounds) return false;
|
|
3732
|
+
return onDragEvent((0, _super_calendar_core.zonedEventSource)(event), bounds.start, bounds.end);
|
|
3733
|
+
}),
|
|
3734
|
+
onPressMore: onPressMore && ((dayEvents, day) => onPressMore(dayEvents.map(_super_calendar_core.zonedEventSource), day)),
|
|
3735
|
+
onPressTime: onPressCell && ((time) => onPressCell(instant(time))),
|
|
3736
|
+
onCreateTimed: onCreateEvent && ((start, end) => {
|
|
3737
|
+
const range = (0, _super_calendar_core.fromZonedRange)(start, end, timeZone);
|
|
3738
|
+
if (range) onCreateEvent(range.start, range.end);
|
|
3739
|
+
})
|
|
3740
|
+
};
|
|
3741
|
+
}, [
|
|
3742
|
+
timeZone,
|
|
3743
|
+
timeGridMode,
|
|
3744
|
+
onPressEvent,
|
|
3745
|
+
onDragStart,
|
|
3746
|
+
onDragEvent,
|
|
3747
|
+
onPressMore,
|
|
3748
|
+
onPressCell,
|
|
3749
|
+
onCreateEvent
|
|
3750
|
+
]);
|
|
3476
3751
|
const handlePageKeys = (e) => {
|
|
3477
3752
|
if (!onChangeDate) return;
|
|
3478
3753
|
if (e.key === "PageDown") onChangeDate(pageStep(mode, date, 1, weekStartsOn, numberOfDays, numberOfWeeks));
|
|
@@ -3487,6 +3762,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3487
3762
|
weekStartsOn,
|
|
3488
3763
|
hiddenDays,
|
|
3489
3764
|
locale,
|
|
3765
|
+
now,
|
|
3766
|
+
timeZone,
|
|
3490
3767
|
labels,
|
|
3491
3768
|
theme,
|
|
3492
3769
|
className,
|
|
@@ -3509,6 +3786,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3509
3786
|
else if (mode === "schedule") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {
|
|
3510
3787
|
events: displayEvents,
|
|
3511
3788
|
locale,
|
|
3789
|
+
now,
|
|
3790
|
+
timeZone,
|
|
3512
3791
|
ampm,
|
|
3513
3792
|
theme,
|
|
3514
3793
|
height,
|
|
@@ -3519,7 +3798,7 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3519
3798
|
styles,
|
|
3520
3799
|
renderEvent: renderScheduleEvent,
|
|
3521
3800
|
eventAccessibilityLabel,
|
|
3522
|
-
onPressEvent,
|
|
3801
|
+
onPressEvent: zoned.onPressEvent,
|
|
3523
3802
|
onPressDay
|
|
3524
3803
|
});
|
|
3525
3804
|
else if (mode === "month") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthView, {
|
|
@@ -3530,6 +3809,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3530
3809
|
weekdayFormat,
|
|
3531
3810
|
highlightWeekends,
|
|
3532
3811
|
locale,
|
|
3812
|
+
now,
|
|
3813
|
+
timeZone,
|
|
3533
3814
|
labels,
|
|
3534
3815
|
theme,
|
|
3535
3816
|
className,
|
|
@@ -3552,13 +3833,14 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3552
3833
|
onPressDay,
|
|
3553
3834
|
onPressCell,
|
|
3554
3835
|
onCreateEvent,
|
|
3836
|
+
renderCreateGhost,
|
|
3555
3837
|
onSelectDrag,
|
|
3556
|
-
onDragEvent,
|
|
3557
|
-
onDragStart,
|
|
3838
|
+
onDragEvent: zoned.onDragEvent,
|
|
3839
|
+
onDragStart: zoned.onDragStart,
|
|
3558
3840
|
eventStartEditable,
|
|
3559
3841
|
eventOverlap,
|
|
3560
|
-
onPressEvent,
|
|
3561
|
-
onPressMore,
|
|
3842
|
+
onPressEvent: zoned.onPressEvent,
|
|
3843
|
+
onPressMore: zoned.onPressMore,
|
|
3562
3844
|
renderEvent: renderMonthEvent,
|
|
3563
3845
|
eventAccessibilityLabel
|
|
3564
3846
|
});
|
|
@@ -3571,6 +3853,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3571
3853
|
weekdayFormat,
|
|
3572
3854
|
highlightWeekends,
|
|
3573
3855
|
locale,
|
|
3856
|
+
now,
|
|
3857
|
+
timeZone,
|
|
3574
3858
|
labels,
|
|
3575
3859
|
theme,
|
|
3576
3860
|
className,
|
|
@@ -3595,13 +3879,14 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3595
3879
|
onPressDay,
|
|
3596
3880
|
onPressCell,
|
|
3597
3881
|
onCreateEvent,
|
|
3882
|
+
renderCreateGhost,
|
|
3598
3883
|
onSelectDrag,
|
|
3599
|
-
onDragEvent,
|
|
3600
|
-
onDragStart,
|
|
3884
|
+
onDragEvent: zoned.onDragEvent,
|
|
3885
|
+
onDragStart: zoned.onDragStart,
|
|
3601
3886
|
eventStartEditable,
|
|
3602
3887
|
eventOverlap,
|
|
3603
|
-
onPressEvent,
|
|
3604
|
-
onPressMore,
|
|
3888
|
+
onPressEvent: zoned.onPressEvent,
|
|
3889
|
+
onPressMore: zoned.onPressMore,
|
|
3605
3890
|
renderEvent: renderMonthEvent,
|
|
3606
3891
|
eventAccessibilityLabel
|
|
3607
3892
|
});
|
|
@@ -3648,12 +3933,12 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3648
3933
|
dragStepMinutes,
|
|
3649
3934
|
touchDragDelay,
|
|
3650
3935
|
touchDragThreshold,
|
|
3651
|
-
onPressEvent,
|
|
3652
|
-
onPressCell,
|
|
3653
|
-
onCreateEvent,
|
|
3936
|
+
onPressEvent: zoned.onPressEvent,
|
|
3937
|
+
onPressCell: zoned.onPressTime,
|
|
3938
|
+
onCreateEvent: zoned.onCreateTimed,
|
|
3654
3939
|
renderCreateGhost,
|
|
3655
|
-
onDragStart,
|
|
3656
|
-
onDragEvent,
|
|
3940
|
+
onDragStart: zoned.onDragStart,
|
|
3941
|
+
onDragEvent: zoned.onDragEvent,
|
|
3657
3942
|
getEventId,
|
|
3658
3943
|
onChangeDate,
|
|
3659
3944
|
onPressDateHeader,
|