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