@super-calendar/dom 2.6.0 → 2.7.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/dist/index.d.mts +84 -15
- package/dist/index.d.ts +84 -15
- package/dist/index.js +571 -118
- package/dist/index.mjs +549 -120
- package/package.json +2 -2
- package/src/Agenda.tsx +5 -2
- package/src/Calendar.tsx +30 -0
- package/src/MonthList.tsx +3 -1
- package/src/MonthView.tsx +135 -3
- package/src/ResourceTimeline.tsx +269 -20
- package/src/TimeGrid.tsx +364 -80
- package/src/YearView.tsx +14 -4
- package/src/index.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -112,7 +112,7 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
112
112
|
});
|
|
113
113
|
const Renderer = renderEvent;
|
|
114
114
|
const rows = (0, react.useMemo)(() => {
|
|
115
|
-
const sorted =
|
|
115
|
+
const sorted = events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
116
116
|
const out = [];
|
|
117
117
|
let currentDay = null;
|
|
118
118
|
sorted.forEach((event, index) => {
|
|
@@ -241,19 +241,20 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
241
241
|
* highlighted and a dot under days that hold events. It's the view `Calendar`
|
|
242
242
|
* renders for `mode="year"`.
|
|
243
243
|
*/
|
|
244
|
-
function YearView({ date, events, weekStartsOn = 0, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
|
|
244
|
+
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
|
|
245
245
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
246
246
|
const slot = createSlots({
|
|
247
247
|
classNames,
|
|
248
248
|
styles
|
|
249
249
|
});
|
|
250
250
|
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
251
|
-
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.getWeekDays)(date, weekStartsOn).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
251
|
+
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 })), [
|
|
252
252
|
date,
|
|
253
253
|
weekStartsOn,
|
|
254
|
-
locale
|
|
254
|
+
locale,
|
|
255
|
+
hiddenDays
|
|
255
256
|
]);
|
|
256
|
-
const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events).keys() : []), [events]);
|
|
257
|
+
const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events.filter((e) => !(0, _super_calendar_core.isBackgroundEvent)(e))).keys() : []), [events]);
|
|
257
258
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
258
259
|
className,
|
|
259
260
|
style: {
|
|
@@ -268,7 +269,7 @@ function YearView({ date, events, weekStartsOn = 0, locale, activeDate, minMonth
|
|
|
268
269
|
gridTemplateColumns: `repeat(auto-fill, minmax(${minMonthWidth}px, 1fr))`
|
|
269
270
|
} }),
|
|
270
271
|
children: months.map((month) => {
|
|
271
|
-
const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn);
|
|
272
|
+
const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn, { hiddenDays });
|
|
272
273
|
const monthLabel = (0, date_fns.format)(month, "MMMM yyyy", { locale });
|
|
273
274
|
const titleContent = (0, date_fns.format)(month, "MMMM", { locale });
|
|
274
275
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -599,7 +600,7 @@ function moreButtonDefault(theme) {
|
|
|
599
600
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
600
601
|
* ```
|
|
601
602
|
*/
|
|
602
|
-
function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onCreateEvent, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
603
|
+
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onCreateEvent, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
603
604
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
604
605
|
const slot = createSlots({
|
|
605
606
|
classNames,
|
|
@@ -609,14 +610,44 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
|
|
|
609
610
|
const dayRoving = !eventsMode || keyboardDayNavigation;
|
|
610
611
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
611
612
|
if (eventsByDayProp) return eventsByDayProp;
|
|
612
|
-
const map = (0, _super_calendar_core.groupEventsByDay)(events ?? []);
|
|
613
|
+
const map = (0, _super_calendar_core.groupEventsByDay)((events ?? []).filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
|
|
613
614
|
for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
|
|
614
615
|
return map;
|
|
615
616
|
}, [eventsByDayProp, events]);
|
|
616
617
|
const Chip = renderEvent;
|
|
618
|
+
const [moreOpenFor, setMoreOpenFor] = (0, react.useState)(null);
|
|
619
|
+
const morePopoverRef = (0, react.useRef)(null);
|
|
620
|
+
const moreTriggerRef = (0, react.useRef)(null);
|
|
621
|
+
(0, react.useEffect)(() => {
|
|
622
|
+
if (moreOpenFor) {
|
|
623
|
+
morePopoverRef.current?.querySelector("button")?.focus();
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
moreTriggerRef.current?.focus();
|
|
627
|
+
moreTriggerRef.current = null;
|
|
628
|
+
}, [moreOpenFor]);
|
|
629
|
+
(0, react.useEffect)(() => {
|
|
630
|
+
if (!moreOpenFor) return;
|
|
631
|
+
const onDocPointerDown = (e) => {
|
|
632
|
+
if (!morePopoverRef.current?.contains(e.target)) {
|
|
633
|
+
moreTriggerRef.current = null;
|
|
634
|
+
setMoreOpenFor(null);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
const onKey = (e) => {
|
|
638
|
+
if (e.key === "Escape") setMoreOpenFor(null);
|
|
639
|
+
};
|
|
640
|
+
document.addEventListener("pointerdown", onDocPointerDown);
|
|
641
|
+
document.addEventListener("keydown", onKey);
|
|
642
|
+
return () => {
|
|
643
|
+
document.removeEventListener("pointerdown", onDocPointerDown);
|
|
644
|
+
document.removeEventListener("keydown", onKey);
|
|
645
|
+
};
|
|
646
|
+
}, [moreOpenFor]);
|
|
617
647
|
const eventRowHeight = 32 + maxVisibleEventCount * 20;
|
|
618
648
|
const { weeks, weekdays } = (0, react.useMemo)(() => (0, _super_calendar_core.buildMonthGrid)(date, {
|
|
619
649
|
weekStartsOn,
|
|
650
|
+
hiddenDays,
|
|
620
651
|
weekdayFormat,
|
|
621
652
|
selectedRange,
|
|
622
653
|
selectedDates,
|
|
@@ -837,39 +868,120 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
|
|
|
837
868
|
flexDirection: "column",
|
|
838
869
|
gap: CHIP_GAP
|
|
839
870
|
} }),
|
|
840
|
-
children: [
|
|
841
|
-
|
|
842
|
-
|
|
871
|
+
children: [
|
|
872
|
+
shown.map((event) => {
|
|
873
|
+
const onPress = () => onPressEvent?.(event);
|
|
874
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
875
|
+
type: "button",
|
|
876
|
+
onClick: (e) => {
|
|
877
|
+
e.stopPropagation();
|
|
878
|
+
onPress();
|
|
879
|
+
},
|
|
880
|
+
...slot("chipButton", chipButtonDefault),
|
|
881
|
+
title: event.title,
|
|
882
|
+
"aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
883
|
+
mode: "month",
|
|
884
|
+
isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
|
|
885
|
+
ampm: false
|
|
886
|
+
}) : `${event.title}, ${dayLabel}`,
|
|
887
|
+
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
888
|
+
event,
|
|
889
|
+
onPress
|
|
890
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
891
|
+
...slot("chip", chipDefault(theme)),
|
|
892
|
+
children: event.title
|
|
893
|
+
})
|
|
894
|
+
}, `${event.start.toISOString()}:${event.title}`);
|
|
895
|
+
}),
|
|
896
|
+
overflow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
843
897
|
type: "button",
|
|
898
|
+
onPointerDown: onPressMore ? void 0 : (e) => e.stopPropagation(),
|
|
844
899
|
onClick: (e) => {
|
|
845
900
|
e.stopPropagation();
|
|
846
|
-
|
|
901
|
+
if (onPressMore) onPressMore(rest, day.date);
|
|
902
|
+
else {
|
|
903
|
+
moreTriggerRef.current = e.currentTarget;
|
|
904
|
+
setMoreOpenFor((open) => open === day.id ? null : day.id);
|
|
905
|
+
}
|
|
847
906
|
},
|
|
848
|
-
...slot("
|
|
849
|
-
|
|
850
|
-
"aria-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
907
|
+
...slot("more", moreButtonDefault(theme)),
|
|
908
|
+
"aria-label": `${rest.length} more events, ${dayLabel}`,
|
|
909
|
+
"aria-expanded": onPressMore ? void 0 : moreOpenFor === day.id,
|
|
910
|
+
children: moreLabel.replace("{moreCount}", String(rest.length))
|
|
911
|
+
}) : null,
|
|
912
|
+
moreOpenFor === day.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
913
|
+
ref: morePopoverRef,
|
|
914
|
+
role: "dialog",
|
|
915
|
+
"aria-label": dayLabel,
|
|
916
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
917
|
+
onKeyDown: (e) => {
|
|
918
|
+
if (e.key !== "Tab") return;
|
|
919
|
+
const buttons = morePopoverRef.current?.querySelectorAll("button");
|
|
920
|
+
if (!buttons?.length) return;
|
|
921
|
+
const first = buttons[0];
|
|
922
|
+
const last = buttons[buttons.length - 1];
|
|
923
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
924
|
+
e.preventDefault();
|
|
925
|
+
last.focus();
|
|
926
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
927
|
+
e.preventDefault();
|
|
928
|
+
first.focus();
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
...slot("morePopover", {
|
|
932
|
+
base: {
|
|
933
|
+
position: "absolute",
|
|
934
|
+
top: 2,
|
|
935
|
+
left: 2,
|
|
936
|
+
right: 2,
|
|
937
|
+
zIndex: 10,
|
|
938
|
+
display: "flex",
|
|
939
|
+
flexDirection: "column",
|
|
940
|
+
gap: 2,
|
|
941
|
+
maxHeight: 240,
|
|
942
|
+
overflowY: "auto"
|
|
943
|
+
},
|
|
944
|
+
themed: {
|
|
945
|
+
background: theme.surface,
|
|
946
|
+
border: `1px solid ${theme.gridLine}`,
|
|
947
|
+
borderRadius: 8,
|
|
948
|
+
padding: 6,
|
|
949
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.12)"
|
|
950
|
+
}
|
|
951
|
+
}),
|
|
952
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
953
|
+
style: {
|
|
954
|
+
fontSize: 11,
|
|
955
|
+
fontWeight: 600,
|
|
956
|
+
color: theme.textMuted
|
|
957
|
+
},
|
|
958
|
+
children: dayLabel
|
|
959
|
+
}), dayEvents.map((event, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
960
|
+
type: "button",
|
|
961
|
+
onClick: () => {
|
|
962
|
+
setMoreOpenFor(null);
|
|
963
|
+
onPressEvent?.(event);
|
|
964
|
+
},
|
|
965
|
+
style: {
|
|
966
|
+
display: "block",
|
|
967
|
+
width: "100%",
|
|
968
|
+
border: "none",
|
|
969
|
+
background: "transparent",
|
|
970
|
+
padding: 0,
|
|
971
|
+
font: "inherit",
|
|
972
|
+
textAlign: "left",
|
|
973
|
+
cursor: "pointer"
|
|
974
|
+
},
|
|
975
|
+
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
976
|
+
event,
|
|
977
|
+
onPress: () => onPressEvent?.(event)
|
|
978
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
979
|
+
...slot("chip", chipDefault(theme)),
|
|
980
|
+
children: event.title
|
|
981
|
+
})
|
|
982
|
+
}, i))]
|
|
983
|
+
}) : null
|
|
984
|
+
]
|
|
873
985
|
})
|
|
874
986
|
]
|
|
875
987
|
}, day.id);
|
|
@@ -907,6 +1019,9 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
|
|
|
907
1019
|
//#region src/TimeGrid.tsx
|
|
908
1020
|
const GUTTER_WIDTH$1 = 56;
|
|
909
1021
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
1022
|
+
const EDGE_ZONE = 32;
|
|
1023
|
+
const EDGE_DWELL_MS = 600;
|
|
1024
|
+
const EDGE_REPEAT_MS = 600;
|
|
910
1025
|
const VISUALLY_HIDDEN = {
|
|
911
1026
|
position: "absolute",
|
|
912
1027
|
width: 1,
|
|
@@ -989,17 +1104,6 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
989
1104
|
}) : null]
|
|
990
1105
|
});
|
|
991
1106
|
}
|
|
992
|
-
const NOW_TICK_MS = 6e4;
|
|
993
|
-
function useNow(enabled) {
|
|
994
|
-
const [now, setNow] = (0, react.useState)(() => /* @__PURE__ */ new Date());
|
|
995
|
-
(0, react.useEffect)(() => {
|
|
996
|
-
if (!enabled) return;
|
|
997
|
-
setNow(/* @__PURE__ */ new Date());
|
|
998
|
-
const id = setInterval(() => setNow(/* @__PURE__ */ new Date()), NOW_TICK_MS);
|
|
999
|
-
return () => clearInterval(id);
|
|
1000
|
-
}, [enabled]);
|
|
1001
|
-
return now;
|
|
1002
|
-
}
|
|
1003
1107
|
/**
|
|
1004
1108
|
* A day / week / N-day time grid rendered with plain DOM elements. Events are
|
|
1005
1109
|
* positioned with the library's pure `layoutDayEvents`, so overlap columns and
|
|
@@ -1011,7 +1115,7 @@ function useNow(enabled) {
|
|
|
1011
1115
|
* <TimeGrid mode="week" date={new Date()} events={events} />
|
|
1012
1116
|
* ```
|
|
1013
1117
|
*/
|
|
1014
|
-
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", keyboardEventNavigation = false, businessHours, showNowIndicator = true, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, className, style, classNames, styles }) {
|
|
1118
|
+
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1015
1119
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1016
1120
|
const slot = createSlots({
|
|
1017
1121
|
classNames,
|
|
@@ -1025,7 +1129,10 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1025
1129
|
const windowHours = windowEnd - windowStart;
|
|
1026
1130
|
const gutterWidth = hideHours ? 0 : GUTTER_WIDTH$1;
|
|
1027
1131
|
const visibleHours = (0, react.useMemo)(() => Array.from({ length: windowHours }, (_, i) => windowStart + i), [windowStart, windowHours]);
|
|
1028
|
-
const now = useNow(showNowIndicator
|
|
1132
|
+
const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
|
|
1133
|
+
now: nowProp,
|
|
1134
|
+
timeZone
|
|
1135
|
+
});
|
|
1029
1136
|
const [hourHeight, setHourHeight] = (0, react.useState)(initialHourHeight);
|
|
1030
1137
|
(0, react.useEffect)(() => setHourHeight(initialHourHeight), [initialHourHeight]);
|
|
1031
1138
|
const hourHeightRef = (0, react.useRef)(hourHeight);
|
|
@@ -1040,16 +1147,48 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1040
1147
|
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
1041
1148
|
const createOrigin = (0, react.useRef)(null);
|
|
1042
1149
|
const cellEnabled = !!onPressCell || !!onCreateEvent;
|
|
1043
|
-
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays), [
|
|
1150
|
+
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, false, void 0, hiddenDays), [
|
|
1044
1151
|
mode,
|
|
1045
1152
|
date,
|
|
1046
1153
|
weekStartsOn,
|
|
1047
|
-
numberOfDays
|
|
1154
|
+
numberOfDays,
|
|
1155
|
+
hiddenDays
|
|
1048
1156
|
]);
|
|
1157
|
+
const edgeAdvanceEnabled = !!onChangeDate && !!onDragEvent;
|
|
1158
|
+
const columnsRef = (0, react.useRef)(null);
|
|
1159
|
+
const edgeTimer = (0, react.useRef)(null);
|
|
1160
|
+
const edgeSide = (0, react.useRef)(0);
|
|
1161
|
+
const ptr = (0, react.useRef)({
|
|
1162
|
+
x: 0,
|
|
1163
|
+
y: 0
|
|
1164
|
+
});
|
|
1165
|
+
const pagedRef = (0, react.useRef)(false);
|
|
1166
|
+
const [paged, setPaged] = (0, react.useState)(false);
|
|
1167
|
+
const draggedRef = (0, react.useRef)(null);
|
|
1168
|
+
const ghostRef = (0, react.useRef)(null);
|
|
1169
|
+
const docHandlersRef = (0, react.useRef)(null);
|
|
1170
|
+
const daysRef = (0, react.useRef)(days);
|
|
1171
|
+
daysRef.current = days;
|
|
1172
|
+
const pageDepsRef = (0, react.useRef)({
|
|
1173
|
+
date,
|
|
1174
|
+
mode,
|
|
1175
|
+
weekStartsOn,
|
|
1176
|
+
numberOfDays
|
|
1177
|
+
});
|
|
1178
|
+
pageDepsRef.current = {
|
|
1179
|
+
date,
|
|
1180
|
+
mode,
|
|
1181
|
+
weekStartsOn,
|
|
1182
|
+
numberOfDays
|
|
1183
|
+
};
|
|
1184
|
+
const onChangeDateRef = (0, react.useRef)(onChangeDate);
|
|
1185
|
+
onChangeDateRef.current = onChangeDate;
|
|
1186
|
+
const onDragEventRef = (0, react.useRef)(onDragEvent);
|
|
1187
|
+
onDragEventRef.current = onDragEvent;
|
|
1049
1188
|
const allDayByDay = (0, react.useMemo)(() => days.map((day) => {
|
|
1050
1189
|
const dayStart = (0, date_fns.startOfDay)(day);
|
|
1051
1190
|
const dayEnd = (0, date_fns.addDays)(dayStart, 1);
|
|
1052
|
-
return events.filter((e) => (0, _super_calendar_core.isAllDayEvent)(e) && e.start < dayEnd && e.end > dayStart);
|
|
1191
|
+
return events.filter((e) => (0, _super_calendar_core.isAllDayEvent)(e) && !(0, _super_calendar_core.isBackgroundEvent)(e) && e.start < dayEnd && e.end > dayStart);
|
|
1053
1192
|
}), [days, events]);
|
|
1054
1193
|
const hasAllDay = allDayByDay.some((list) => list.length > 0);
|
|
1055
1194
|
(0, react.useEffect)(() => {
|
|
@@ -1098,47 +1237,59 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1098
1237
|
};
|
|
1099
1238
|
const Renderer = renderEvent;
|
|
1100
1239
|
const totalHeight = windowHours * hourHeight;
|
|
1101
|
-
const
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
e.target.setPointerCapture?.(e.pointerId);
|
|
1106
|
-
} catch {}
|
|
1107
|
-
const column = kind === "move" ? e.currentTarget.parentElement : null;
|
|
1108
|
-
const dayWidth = column ? column.getBoundingClientRect().width : 0;
|
|
1109
|
-
dragOrigin.current = {
|
|
1110
|
-
pointerX: e.clientX,
|
|
1111
|
-
pointerY: e.clientY,
|
|
1112
|
-
startHours,
|
|
1113
|
-
durationHours,
|
|
1114
|
-
dayIndex,
|
|
1115
|
-
dayWidth
|
|
1116
|
-
};
|
|
1117
|
-
applyDrag({
|
|
1118
|
-
key,
|
|
1119
|
-
kind,
|
|
1120
|
-
startHours,
|
|
1121
|
-
durationHours,
|
|
1122
|
-
dayDelta: 0,
|
|
1123
|
-
dayOffsetPx: 0,
|
|
1124
|
-
moved: false
|
|
1125
|
-
});
|
|
1126
|
-
onDragStart?.(event);
|
|
1240
|
+
const dayAt = (x, y) => {
|
|
1241
|
+
if (typeof document === "undefined" || typeof document.elementFromPoint !== "function") return null;
|
|
1242
|
+
const iso = (document.elementFromPoint(x, y)?.closest?.("[data-date]"))?.getAttribute("data-date");
|
|
1243
|
+
return iso ? new Date(iso) : null;
|
|
1127
1244
|
};
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1245
|
+
const clearEdgeTimer = () => {
|
|
1246
|
+
if (edgeTimer.current) {
|
|
1247
|
+
clearTimeout(edgeTimer.current);
|
|
1248
|
+
edgeTimer.current = null;
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
const fireEdge = () => {
|
|
1252
|
+
const side = edgeSide.current;
|
|
1253
|
+
if (side === 0) return;
|
|
1254
|
+
const p = pageDepsRef.current;
|
|
1255
|
+
const step = (0, _super_calendar_core.pageStepDays)(p.mode, p.date, p.weekStartsOn, p.numberOfDays);
|
|
1256
|
+
onChangeDateRef.current?.((0, date_fns.addDays)(p.date, side * step));
|
|
1257
|
+
pagedRef.current = true;
|
|
1258
|
+
setPaged(true);
|
|
1259
|
+
edgeTimer.current = setTimeout(fireEdge, EDGE_REPEAT_MS);
|
|
1260
|
+
};
|
|
1261
|
+
const detachDocListeners = () => {
|
|
1262
|
+
const h = docHandlersRef.current;
|
|
1263
|
+
if (!h) return;
|
|
1264
|
+
document.removeEventListener("pointermove", h.move);
|
|
1265
|
+
document.removeEventListener("pointerup", h.up);
|
|
1266
|
+
document.removeEventListener("pointercancel", h.cancel);
|
|
1267
|
+
docHandlersRef.current = null;
|
|
1268
|
+
};
|
|
1269
|
+
const finishDrag = () => {
|
|
1270
|
+
detachDocListeners();
|
|
1271
|
+
clearEdgeTimer();
|
|
1272
|
+
edgeSide.current = 0;
|
|
1273
|
+
pagedRef.current = false;
|
|
1274
|
+
setPaged(false);
|
|
1275
|
+
draggedRef.current = null;
|
|
1130
1276
|
dragOrigin.current = null;
|
|
1277
|
+
applyDrag(null);
|
|
1131
1278
|
};
|
|
1132
1279
|
const moveDrag = (e) => {
|
|
1133
1280
|
const d = dragRef.current;
|
|
1134
1281
|
if (!d || !dragOrigin.current) return;
|
|
1282
|
+
ptr.current = {
|
|
1283
|
+
x: e.clientX,
|
|
1284
|
+
y: e.clientY
|
|
1285
|
+
};
|
|
1135
1286
|
const dHours = (e.clientY - dragOrigin.current.pointerY) / hourHeightRef.current;
|
|
1136
1287
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
1137
1288
|
if (d.kind === "move") {
|
|
1138
1289
|
const startHours = clamp$1(snap(dragOrigin.current.startHours + dHours), windowStart, Math.max(windowStart, windowEnd - d.durationHours));
|
|
1139
1290
|
const o = dragOrigin.current;
|
|
1140
1291
|
const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
|
|
1141
|
-
const dayDelta = clamp$1(o.dayIndex + rawDayDelta, 0,
|
|
1292
|
+
const dayDelta = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1) - o.dayIndex;
|
|
1142
1293
|
applyDrag({
|
|
1143
1294
|
...d,
|
|
1144
1295
|
startHours,
|
|
@@ -1146,6 +1297,21 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1146
1297
|
dayOffsetPx: dayDelta * o.dayWidth,
|
|
1147
1298
|
moved: true
|
|
1148
1299
|
});
|
|
1300
|
+
const g = ghostRef.current;
|
|
1301
|
+
const held = draggedRef.current;
|
|
1302
|
+
if (g && held) g.style.transform = `translate(${e.clientX - held.grabX}px, ${e.clientY - held.grabY}px)`;
|
|
1303
|
+
if (edgeAdvanceEnabled) {
|
|
1304
|
+
const rect = columnsRef.current?.getBoundingClientRect();
|
|
1305
|
+
if (rect && rect.right > rect.left) {
|
|
1306
|
+
const left = rect.left + gutterWidth;
|
|
1307
|
+
const side = e.clientX <= left + EDGE_ZONE ? -1 : e.clientX >= rect.right - EDGE_ZONE ? 1 : 0;
|
|
1308
|
+
if (side !== edgeSide.current) {
|
|
1309
|
+
clearEdgeTimer();
|
|
1310
|
+
edgeSide.current = side;
|
|
1311
|
+
if (side !== 0) edgeTimer.current = setTimeout(fireEdge, EDGE_DWELL_MS);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1149
1315
|
} else {
|
|
1150
1316
|
const durationHours = clamp$1(snap(dragOrigin.current.durationHours + dHours), snapHours, Math.max(snapHours, windowEnd - d.startHours));
|
|
1151
1317
|
applyDrag({
|
|
@@ -1155,24 +1321,94 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1155
1321
|
});
|
|
1156
1322
|
}
|
|
1157
1323
|
};
|
|
1158
|
-
const endDrag = (e
|
|
1324
|
+
const endDrag = (e) => {
|
|
1159
1325
|
const d = dragRef.current;
|
|
1160
1326
|
if (!d) return;
|
|
1161
1327
|
try {
|
|
1162
|
-
e.target
|
|
1328
|
+
e.target?.releasePointerCapture?.(e.pointerId);
|
|
1163
1329
|
} catch {}
|
|
1330
|
+
const held = draggedRef.current;
|
|
1164
1331
|
if (!d.moved) {
|
|
1165
|
-
|
|
1166
|
-
onPress();
|
|
1332
|
+
finishDrag();
|
|
1333
|
+
held?.onPress();
|
|
1167
1334
|
return;
|
|
1168
1335
|
}
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1336
|
+
const originIndex = dragOrigin.current?.dayIndex ?? 0;
|
|
1337
|
+
let base = null;
|
|
1338
|
+
if (d.kind === "move") if (pagedRef.current) {
|
|
1339
|
+
const day = dayAt(e.clientX, e.clientY);
|
|
1340
|
+
base = day ? (0, date_fns.startOfDay)(day) : null;
|
|
1341
|
+
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
|
|
1342
|
+
else base = (0, date_fns.startOfDay)(daysRef.current[originIndex] ?? daysRef.current[0]);
|
|
1343
|
+
if (base && held) {
|
|
1344
|
+
const start = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
|
|
1345
|
+
const end = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
|
|
1346
|
+
onDragEventRef.current?.(held.event, start, end);
|
|
1347
|
+
}
|
|
1348
|
+
finishDrag();
|
|
1349
|
+
};
|
|
1350
|
+
const cancelDrag = () => {
|
|
1351
|
+
finishDrag();
|
|
1352
|
+
};
|
|
1353
|
+
const beginDrag = (e, event, key, kind, startHours, durationHours, dayIndex, onPress) => {
|
|
1354
|
+
if (!onDragEvent) return;
|
|
1355
|
+
e.stopPropagation();
|
|
1356
|
+
try {
|
|
1357
|
+
e.target.setPointerCapture?.(e.pointerId);
|
|
1358
|
+
} catch {}
|
|
1359
|
+
const boxEl = e.currentTarget;
|
|
1360
|
+
const column = kind === "move" ? boxEl.parentElement : null;
|
|
1361
|
+
const dayWidth = column ? column.getBoundingClientRect().width : 0;
|
|
1362
|
+
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
1363
|
+
dragOrigin.current = {
|
|
1364
|
+
pointerX: e.clientX,
|
|
1365
|
+
pointerY: e.clientY,
|
|
1366
|
+
startHours,
|
|
1367
|
+
durationHours,
|
|
1368
|
+
dayIndex,
|
|
1369
|
+
dayWidth
|
|
1370
|
+
};
|
|
1371
|
+
draggedRef.current = {
|
|
1372
|
+
event,
|
|
1373
|
+
onPress: onPress ?? (() => {}),
|
|
1374
|
+
grabX: boxRect ? e.clientX - boxRect.left : 0,
|
|
1375
|
+
grabY: boxRect ? e.clientY - boxRect.top : 0,
|
|
1376
|
+
w: boxRect ? boxRect.width : 0,
|
|
1377
|
+
h: boxRect ? boxRect.height : 0
|
|
1378
|
+
};
|
|
1379
|
+
ptr.current = {
|
|
1380
|
+
x: e.clientX,
|
|
1381
|
+
y: e.clientY
|
|
1382
|
+
};
|
|
1383
|
+
edgeSide.current = 0;
|
|
1384
|
+
pagedRef.current = false;
|
|
1385
|
+
setPaged(false);
|
|
1386
|
+
clearEdgeTimer();
|
|
1387
|
+
applyDrag({
|
|
1388
|
+
key,
|
|
1389
|
+
kind,
|
|
1390
|
+
startHours,
|
|
1391
|
+
durationHours,
|
|
1392
|
+
dayDelta: 0,
|
|
1393
|
+
dayOffsetPx: 0,
|
|
1394
|
+
moved: false
|
|
1395
|
+
});
|
|
1396
|
+
onDragStart?.(event);
|
|
1397
|
+
detachDocListeners();
|
|
1398
|
+
const handlers = {
|
|
1399
|
+
move: moveDrag,
|
|
1400
|
+
up: endDrag,
|
|
1401
|
+
cancel: cancelDrag
|
|
1402
|
+
};
|
|
1403
|
+
docHandlersRef.current = handlers;
|
|
1404
|
+
document.addEventListener("pointermove", handlers.move);
|
|
1405
|
+
document.addEventListener("pointerup", handlers.up);
|
|
1406
|
+
document.addEventListener("pointercancel", handlers.cancel);
|
|
1175
1407
|
};
|
|
1408
|
+
(0, react.useEffect)(() => () => {
|
|
1409
|
+
detachDocListeners();
|
|
1410
|
+
clearEdgeTimer();
|
|
1411
|
+
}, []);
|
|
1176
1412
|
const pxFromTop = (el, clientY) => clientY - el.getBoundingClientRect().top;
|
|
1177
1413
|
const beginCreate = (e, dayIndex) => {
|
|
1178
1414
|
if (!cellEnabled || e.pointerType === "touch") return;
|
|
@@ -1294,6 +1530,16 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1294
1530
|
windowStart,
|
|
1295
1531
|
windowEnd
|
|
1296
1532
|
]);
|
|
1533
|
+
const backgroundByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.backgroundBandsForDay)(events, day).map((b) => ({
|
|
1534
|
+
...b,
|
|
1535
|
+
startHours: Math.max(b.startHours, windowStart),
|
|
1536
|
+
endHours: Math.min(b.endHours, windowEnd)
|
|
1537
|
+
})).filter((b) => b.endHours > b.startHours)), [
|
|
1538
|
+
days,
|
|
1539
|
+
events,
|
|
1540
|
+
windowStart,
|
|
1541
|
+
windowEnd
|
|
1542
|
+
]);
|
|
1297
1543
|
const gridLines = (0, react.useMemo)(() => {
|
|
1298
1544
|
const hourLines = `repeating-linear-gradient(to bottom, transparent 0, transparent ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight}px)`;
|
|
1299
1545
|
if (timeslots <= 1) return hourLines;
|
|
@@ -1492,6 +1738,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1492
1738
|
touchAction: zoomable ? "pan-y" : "auto"
|
|
1493
1739
|
},
|
|
1494
1740
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1741
|
+
ref: columnsRef,
|
|
1495
1742
|
style: {
|
|
1496
1743
|
display: "flex",
|
|
1497
1744
|
height: totalHeight,
|
|
@@ -1525,6 +1772,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1525
1772
|
const bands = bandsByDay[dayIndex];
|
|
1526
1773
|
const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
|
|
1527
1774
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1775
|
+
"data-date": day.toISOString(),
|
|
1528
1776
|
onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
|
|
1529
1777
|
onPointerMove: cellEnabled ? moveCreate : void 0,
|
|
1530
1778
|
onPointerUp: cellEnabled ? endCreate : void 0,
|
|
@@ -1540,7 +1788,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1540
1788
|
},
|
|
1541
1789
|
themed: {
|
|
1542
1790
|
borderLeft: `1px solid ${theme.gridLine}`,
|
|
1543
|
-
...(0, _super_calendar_core.isWeekend)(day) ? { background: theme.weekendBackground } : null
|
|
1791
|
+
...highlightWeekends && (0, _super_calendar_core.isWeekend)(day) ? { background: theme.weekendBackground } : null
|
|
1544
1792
|
}
|
|
1545
1793
|
}),
|
|
1546
1794
|
children: [
|
|
@@ -1556,9 +1804,30 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1556
1804
|
pointerEvents: "none",
|
|
1557
1805
|
zIndex: 0
|
|
1558
1806
|
},
|
|
1559
|
-
themed: { background: theme.outsideHoursBackground }
|
|
1807
|
+
themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
|
|
1808
|
+
}),
|
|
1809
|
+
children: renderBusinessHours?.({
|
|
1810
|
+
date: day,
|
|
1811
|
+
start: b.start,
|
|
1812
|
+
end: b.end
|
|
1560
1813
|
})
|
|
1561
1814
|
}, b.start)),
|
|
1815
|
+
backgroundByDay[dayIndex].map((b, bandIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1816
|
+
"aria-hidden": true,
|
|
1817
|
+
title: b.event.title,
|
|
1818
|
+
...slot("backgroundEvent", {
|
|
1819
|
+
base: {
|
|
1820
|
+
position: "absolute",
|
|
1821
|
+
left: 0,
|
|
1822
|
+
right: 0,
|
|
1823
|
+
top: (b.startHours - windowStart) * hourHeight,
|
|
1824
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
1825
|
+
pointerEvents: "none",
|
|
1826
|
+
zIndex: 0
|
|
1827
|
+
},
|
|
1828
|
+
themed: { background: theme.backgroundEvent }
|
|
1829
|
+
})
|
|
1830
|
+
}, `bg-${bandIndex}`)),
|
|
1562
1831
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1563
1832
|
"aria-hidden": true,
|
|
1564
1833
|
...slot("gridLines", {
|
|
@@ -1573,7 +1842,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1573
1842
|
}),
|
|
1574
1843
|
positioned.map((pe, idx) => {
|
|
1575
1844
|
const key = `${dayIndex}:${idx}`;
|
|
1576
|
-
const active = drag?.key === key ? drag : null;
|
|
1845
|
+
const active = !paged && drag?.key === key ? drag : null;
|
|
1577
1846
|
const startHours = active ? active.startHours : pe.startHours;
|
|
1578
1847
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
1579
1848
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
@@ -1591,7 +1860,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1591
1860
|
ampm,
|
|
1592
1861
|
onPress
|
|
1593
1862
|
};
|
|
1594
|
-
const draggable = !!onDragEvent;
|
|
1863
|
+
const draggable = !!onDragEvent && pe.event.draggable !== false;
|
|
1595
1864
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1596
1865
|
role: "button",
|
|
1597
1866
|
tabIndex: 0,
|
|
@@ -1615,10 +1884,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1615
1884
|
}
|
|
1616
1885
|
if (keyboardEventNavigation) onEventKeyDown(key, e);
|
|
1617
1886
|
},
|
|
1618
|
-
onPointerDown: draggable ? (e) => beginDrag(e, pe.event, key, "move", pe.startHours, pe.durationHours, dayIndex) : void 0,
|
|
1619
|
-
onPointerMove: draggable ? moveDrag : void 0,
|
|
1620
|
-
onPointerUp: draggable ? (e) => endDrag(e, day, pe.event, onPress) : void 0,
|
|
1621
|
-
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
1887
|
+
onPointerDown: draggable ? (e) => beginDrag(e, pe.event, key, "move", pe.startHours, pe.durationHours, dayIndex, onPress) : void 0,
|
|
1622
1888
|
onClick: draggable ? void 0 : onPress,
|
|
1623
1889
|
...dataState({ "data-dragging": !!active }),
|
|
1624
1890
|
...slot("event", { base: {
|
|
@@ -1701,7 +1967,39 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1701
1967
|
}, day.toISOString());
|
|
1702
1968
|
})]
|
|
1703
1969
|
})
|
|
1704
|
-
})
|
|
1970
|
+
}),
|
|
1971
|
+
paged && draggedRef.current ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1972
|
+
ref: ghostRef,
|
|
1973
|
+
"aria-hidden": true,
|
|
1974
|
+
style: {
|
|
1975
|
+
position: "fixed",
|
|
1976
|
+
left: 0,
|
|
1977
|
+
top: 0,
|
|
1978
|
+
width: draggedRef.current.w,
|
|
1979
|
+
height: draggedRef.current.h,
|
|
1980
|
+
transform: `translate(${ptr.current.x - draggedRef.current.grabX}px, ${ptr.current.y - draggedRef.current.grabY}px)`,
|
|
1981
|
+
pointerEvents: "none",
|
|
1982
|
+
zIndex: 1e3,
|
|
1983
|
+
opacity: .85
|
|
1984
|
+
},
|
|
1985
|
+
children: Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, {
|
|
1986
|
+
event: draggedRef.current.event,
|
|
1987
|
+
mode,
|
|
1988
|
+
isAllDay: false,
|
|
1989
|
+
boxHeight: draggedRef.current.h,
|
|
1990
|
+
ampm,
|
|
1991
|
+
onPress: () => {}
|
|
1992
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
|
|
1993
|
+
event: draggedRef.current.event,
|
|
1994
|
+
mode,
|
|
1995
|
+
isAllDay: false,
|
|
1996
|
+
boxHeight: draggedRef.current.h,
|
|
1997
|
+
ampm,
|
|
1998
|
+
onPress: () => {},
|
|
1999
|
+
theme,
|
|
2000
|
+
boxProps: slot("eventBox")
|
|
2001
|
+
})
|
|
2002
|
+
}) : null
|
|
1705
2003
|
]
|
|
1706
2004
|
});
|
|
1707
2005
|
}
|
|
@@ -1732,7 +2030,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
1732
2030
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
1733
2031
|
* ```
|
|
1734
2032
|
*/
|
|
1735
|
-
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, showNowIndicator, showAllDayEventCell, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2033
|
+
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
1736
2034
|
const displayEvents = (0, react.useMemo)(() => {
|
|
1737
2035
|
let out = events ?? EMPTY_EVENTS;
|
|
1738
2036
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -1765,6 +2063,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
1765
2063
|
date,
|
|
1766
2064
|
events: displayEvents,
|
|
1767
2065
|
weekStartsOn,
|
|
2066
|
+
hiddenDays,
|
|
1768
2067
|
locale,
|
|
1769
2068
|
theme,
|
|
1770
2069
|
className,
|
|
@@ -1797,6 +2096,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
1797
2096
|
date,
|
|
1798
2097
|
events: displayEvents,
|
|
1799
2098
|
weekStartsOn,
|
|
2099
|
+
hiddenDays,
|
|
1800
2100
|
weekdayFormat,
|
|
1801
2101
|
locale,
|
|
1802
2102
|
theme,
|
|
@@ -1826,6 +2126,9 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
1826
2126
|
mode,
|
|
1827
2127
|
events: displayEvents,
|
|
1828
2128
|
weekStartsOn,
|
|
2129
|
+
hiddenDays,
|
|
2130
|
+
now,
|
|
2131
|
+
timeZone,
|
|
1829
2132
|
weekdayFormat,
|
|
1830
2133
|
numberOfDays,
|
|
1831
2134
|
locale,
|
|
@@ -1845,14 +2148,17 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
1845
2148
|
showWeekNumber,
|
|
1846
2149
|
weekNumberPrefix,
|
|
1847
2150
|
businessHours,
|
|
2151
|
+
renderBusinessHours,
|
|
1848
2152
|
showNowIndicator,
|
|
1849
2153
|
showAllDayEventCell,
|
|
2154
|
+
highlightWeekends,
|
|
1850
2155
|
dragStepMinutes,
|
|
1851
2156
|
onPressEvent,
|
|
1852
2157
|
onPressCell,
|
|
1853
2158
|
onCreateEvent,
|
|
1854
2159
|
onDragStart,
|
|
1855
2160
|
onDragEvent,
|
|
2161
|
+
onChangeDate,
|
|
1856
2162
|
onPressDateHeader,
|
|
1857
2163
|
renderEvent: renderTimeEvent,
|
|
1858
2164
|
eventAccessibilityLabel,
|
|
@@ -1899,7 +2205,7 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
1899
2205
|
]);
|
|
1900
2206
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
1901
2207
|
if (!events) return void 0;
|
|
1902
|
-
const map = (0, _super_calendar_core.groupEventsByDay)(events);
|
|
2208
|
+
const map = (0, _super_calendar_core.groupEventsByDay)(events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
|
|
1903
2209
|
for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
|
|
1904
2210
|
return map;
|
|
1905
2211
|
}, [events]);
|
|
@@ -2287,7 +2593,17 @@ function DefaultBar({ event, height, boxProps, theme }) {
|
|
|
2287
2593
|
* />
|
|
2288
2594
|
* ```
|
|
2289
2595
|
*/
|
|
2290
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, dragStepMinutes = 15, className, style, classNames, styles }) {
|
|
2596
|
+
function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone, className, style, classNames, styles }) {
|
|
2597
|
+
const resources = (0, react.useMemo)(() => {
|
|
2598
|
+
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
2599
|
+
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
2600
|
+
const page = Math.min(Math.max(resourcePage, 0), pages - 1);
|
|
2601
|
+
return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
|
|
2602
|
+
}, [
|
|
2603
|
+
allResources,
|
|
2604
|
+
resourcesPerPage,
|
|
2605
|
+
resourcePage
|
|
2606
|
+
]);
|
|
2291
2607
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
2292
2608
|
const slot = createSlots({
|
|
2293
2609
|
classNames,
|
|
@@ -2297,6 +2613,35 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2297
2613
|
const snapHours = dragStepMinutes / 60;
|
|
2298
2614
|
const vertical = orientation === "vertical";
|
|
2299
2615
|
const hourSize = vertical ? hourHeight : hourWidth;
|
|
2616
|
+
const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
|
|
2617
|
+
now: nowProp,
|
|
2618
|
+
timeZone
|
|
2619
|
+
});
|
|
2620
|
+
const nowHours = now.getHours() + now.getMinutes() / 60;
|
|
2621
|
+
const showNow = showNowIndicator && (0, _super_calendar_core.isSameCalendarDay)(now, date) && nowHours >= startHour && nowHours <= endHour;
|
|
2622
|
+
const nowLine = (resourceKey) => showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2623
|
+
"aria-hidden": true,
|
|
2624
|
+
...slot("nowIndicator", {
|
|
2625
|
+
base: vertical ? {
|
|
2626
|
+
position: "absolute",
|
|
2627
|
+
left: 0,
|
|
2628
|
+
right: 0,
|
|
2629
|
+
top: (nowHours - startHour) * hourSize,
|
|
2630
|
+
height: 2,
|
|
2631
|
+
pointerEvents: "none",
|
|
2632
|
+
zIndex: 2
|
|
2633
|
+
} : {
|
|
2634
|
+
position: "absolute",
|
|
2635
|
+
top: 0,
|
|
2636
|
+
bottom: 0,
|
|
2637
|
+
left: (nowHours - startHour) * hourSize,
|
|
2638
|
+
width: 2,
|
|
2639
|
+
pointerEvents: "none",
|
|
2640
|
+
zIndex: 2
|
|
2641
|
+
},
|
|
2642
|
+
themed: { background: theme.nowIndicator }
|
|
2643
|
+
})
|
|
2644
|
+
}, `now-${resourceKey}`) : null;
|
|
2300
2645
|
const [drag, setDrag] = (0, react.useState)(null);
|
|
2301
2646
|
const dragRef = (0, react.useRef)(null);
|
|
2302
2647
|
const origin = (0, react.useRef)(null);
|
|
@@ -2304,7 +2649,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2304
2649
|
dragRef.current = next;
|
|
2305
2650
|
setDrag(next);
|
|
2306
2651
|
};
|
|
2307
|
-
const beginDrag = (e, key, kind, startHours, durationHours) => {
|
|
2652
|
+
const beginDrag = (e, key, resourceId, kind, startHours, durationHours) => {
|
|
2308
2653
|
if (!onDragEvent) return;
|
|
2309
2654
|
e.stopPropagation();
|
|
2310
2655
|
try {
|
|
@@ -2312,14 +2657,17 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2312
2657
|
} catch {}
|
|
2313
2658
|
origin.current = {
|
|
2314
2659
|
x: vertical ? e.clientY : e.clientX,
|
|
2660
|
+
cross: vertical ? e.clientX : e.clientY,
|
|
2315
2661
|
startHours,
|
|
2316
2662
|
durationHours
|
|
2317
2663
|
};
|
|
2318
2664
|
applyDrag({
|
|
2319
2665
|
key,
|
|
2666
|
+
resourceId,
|
|
2320
2667
|
kind,
|
|
2321
2668
|
startHours,
|
|
2322
2669
|
durationHours,
|
|
2670
|
+
crossPx: 0,
|
|
2323
2671
|
moved: false
|
|
2324
2672
|
});
|
|
2325
2673
|
};
|
|
@@ -2330,9 +2678,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2330
2678
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
2331
2679
|
if (d.kind === "move") {
|
|
2332
2680
|
const startHours = clamp(snap(origin.current.startHours + dHours), startHour, endHour - d.durationHours);
|
|
2681
|
+
const crossPx = (vertical ? e.clientX : e.clientY) - origin.current.cross;
|
|
2333
2682
|
applyDrag({
|
|
2334
2683
|
...d,
|
|
2335
2684
|
startHours,
|
|
2685
|
+
crossPx,
|
|
2336
2686
|
moved: true
|
|
2337
2687
|
});
|
|
2338
2688
|
} else {
|
|
@@ -2344,7 +2694,21 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2344
2694
|
});
|
|
2345
2695
|
}
|
|
2346
2696
|
};
|
|
2347
|
-
const
|
|
2697
|
+
const laneAt = (e, fallback) => {
|
|
2698
|
+
if (typeof document === "undefined" || typeof document.elementFromPoint !== "function") return fallback;
|
|
2699
|
+
const bar = e.currentTarget;
|
|
2700
|
+
const prev = bar.style.pointerEvents;
|
|
2701
|
+
let hit;
|
|
2702
|
+
bar.style.pointerEvents = "none";
|
|
2703
|
+
try {
|
|
2704
|
+
hit = document.elementFromPoint(e.clientX, e.clientY);
|
|
2705
|
+
} finally {
|
|
2706
|
+
bar.style.pointerEvents = prev;
|
|
2707
|
+
}
|
|
2708
|
+
const id = (hit?.closest?.("[data-resource-id]"))?.getAttribute("data-resource-id");
|
|
2709
|
+
return id && resources.find((r) => r.id === id) || fallback;
|
|
2710
|
+
};
|
|
2711
|
+
const endDrag = (e, event, resource, onPress) => {
|
|
2348
2712
|
const d = dragRef.current;
|
|
2349
2713
|
if (!d) return;
|
|
2350
2714
|
try {
|
|
@@ -2355,10 +2719,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2355
2719
|
onPress();
|
|
2356
2720
|
return;
|
|
2357
2721
|
}
|
|
2722
|
+
const target = d.kind === "move" ? laneAt(e, resource) : resource;
|
|
2358
2723
|
const base = (0, date_fns.startOfDay)(date);
|
|
2359
2724
|
const start = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
|
|
2360
2725
|
const end = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
|
|
2361
|
-
onDragEvent?.(event, start, end);
|
|
2726
|
+
onDragEvent?.(event, start, end, target);
|
|
2362
2727
|
applyDrag(null);
|
|
2363
2728
|
origin.current = null;
|
|
2364
2729
|
};
|
|
@@ -2429,6 +2794,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2429
2794
|
onPointerCancel: cancelCreate
|
|
2430
2795
|
} : null;
|
|
2431
2796
|
const bandsFor = (resource) => businessHours ? (0, _super_calendar_core.closedHourBands)(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
2797
|
+
const backgroundBandsFor = (resource) => (0, _super_calendar_core.backgroundBandsForDay)(events.filter((e) => resourceId(e) === resource.id), date).map((b) => ({
|
|
2798
|
+
...b,
|
|
2799
|
+
startHours: Math.max(b.startHours, startHour),
|
|
2800
|
+
endHours: Math.min(b.endHours, endHour)
|
|
2801
|
+
})).filter((b) => b.endHours > b.startHours);
|
|
2432
2802
|
const hours = (0, react.useMemo)(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
|
|
2433
2803
|
const trackWidth = (endHour - startHour) * hourWidth;
|
|
2434
2804
|
const byResource = (0, react.useMemo)(() => {
|
|
@@ -2444,6 +2814,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2444
2814
|
resourceId,
|
|
2445
2815
|
date
|
|
2446
2816
|
]);
|
|
2817
|
+
const dragLaneId = drag?.kind === "move" && drag.moved ? drag.resourceId : null;
|
|
2447
2818
|
if (vertical) {
|
|
2448
2819
|
const trackHeight = (endHour - startHour) * hourHeight;
|
|
2449
2820
|
const vGridLines = `repeating-linear-gradient(to bottom, transparent 0, transparent ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight}px)`;
|
|
@@ -2520,11 +2891,16 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2520
2891
|
...slot("row", {
|
|
2521
2892
|
base: {
|
|
2522
2893
|
flex: 1,
|
|
2523
|
-
minWidth: 0
|
|
2894
|
+
minWidth: 0,
|
|
2895
|
+
...dragLaneId === resource.id ? {
|
|
2896
|
+
position: "relative",
|
|
2897
|
+
zIndex: 5
|
|
2898
|
+
} : null
|
|
2524
2899
|
},
|
|
2525
2900
|
themed: { borderLeft: `1px solid ${theme.gridLine}` }
|
|
2526
2901
|
}),
|
|
2527
2902
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2903
|
+
"data-resource-id": resource.id,
|
|
2528
2904
|
...trackInteractionProps(resource),
|
|
2529
2905
|
...slot("track", { base: {
|
|
2530
2906
|
position: "relative",
|
|
@@ -2543,9 +2919,31 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2543
2919
|
pointerEvents: "none",
|
|
2544
2920
|
zIndex: 0
|
|
2545
2921
|
},
|
|
2546
|
-
themed: { background: theme.outsideHoursBackground }
|
|
2922
|
+
themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
|
|
2923
|
+
}),
|
|
2924
|
+
children: renderBusinessHours?.({
|
|
2925
|
+
date,
|
|
2926
|
+
start: b.start,
|
|
2927
|
+
end: b.end,
|
|
2928
|
+
resource
|
|
2547
2929
|
})
|
|
2548
2930
|
}, b.start)),
|
|
2931
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2932
|
+
"aria-hidden": true,
|
|
2933
|
+
title: b.event.title,
|
|
2934
|
+
...slot("backgroundEvent", {
|
|
2935
|
+
base: {
|
|
2936
|
+
position: "absolute",
|
|
2937
|
+
left: 0,
|
|
2938
|
+
right: 0,
|
|
2939
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
2940
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
2941
|
+
pointerEvents: "none",
|
|
2942
|
+
zIndex: 0
|
|
2943
|
+
},
|
|
2944
|
+
themed: { background: theme.backgroundEvent }
|
|
2945
|
+
})
|
|
2946
|
+
}, `bg-${i}`)),
|
|
2549
2947
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2550
2948
|
"aria-hidden": true,
|
|
2551
2949
|
...slot("gridLines", {
|
|
@@ -2573,15 +2971,15 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2573
2971
|
height,
|
|
2574
2972
|
onPress
|
|
2575
2973
|
};
|
|
2576
|
-
const draggable = !!onDragEvent;
|
|
2974
|
+
const draggable = !!onDragEvent && pe.event.draggable !== false;
|
|
2577
2975
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
2578
2976
|
type: "button",
|
|
2579
2977
|
onClick: draggable ? void 0 : onPress,
|
|
2580
2978
|
"aria-label": pe.event.title,
|
|
2581
2979
|
...dataState({ "data-dragging": !!active }),
|
|
2582
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2980
|
+
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2583
2981
|
onPointerMove: draggable ? moveDrag : void 0,
|
|
2584
|
-
onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
|
|
2982
|
+
onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
|
|
2585
2983
|
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
2586
2984
|
...slot("event", { base: {
|
|
2587
2985
|
position: "absolute",
|
|
@@ -2589,6 +2987,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2589
2987
|
height,
|
|
2590
2988
|
left: `${pe.column * lanePct}%`,
|
|
2591
2989
|
width: `${lanePct}%`,
|
|
2990
|
+
transform: active?.kind === "move" ? `translateX(${active.crossPx}px)` : void 0,
|
|
2592
2991
|
padding: 1,
|
|
2593
2992
|
border: "none",
|
|
2594
2993
|
background: "transparent",
|
|
@@ -2608,7 +3007,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2608
3007
|
"aria-hidden": true,
|
|
2609
3008
|
onPointerDown: (e) => {
|
|
2610
3009
|
e.stopPropagation();
|
|
2611
|
-
beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
|
|
3010
|
+
beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
|
|
2612
3011
|
},
|
|
2613
3012
|
style: {
|
|
2614
3013
|
position: "absolute",
|
|
@@ -2622,6 +3021,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2622
3021
|
}) : null]
|
|
2623
3022
|
}, idx);
|
|
2624
3023
|
}),
|
|
3024
|
+
nowLine(resource.id),
|
|
2625
3025
|
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2626
3026
|
"aria-hidden": true,
|
|
2627
3027
|
...slot("createGhost", {
|
|
@@ -2695,7 +3095,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2695
3095
|
...slot("row", {
|
|
2696
3096
|
base: {
|
|
2697
3097
|
display: "flex",
|
|
2698
|
-
height: rowHeight
|
|
3098
|
+
height: rowHeight,
|
|
3099
|
+
...dragLaneId === resource.id ? {
|
|
3100
|
+
position: "relative",
|
|
3101
|
+
zIndex: 5
|
|
3102
|
+
} : null
|
|
2699
3103
|
},
|
|
2700
3104
|
themed: { borderBottom: `1px solid ${theme.gridLine}` }
|
|
2701
3105
|
}),
|
|
@@ -2717,6 +3121,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2717
3121
|
}),
|
|
2718
3122
|
children: resource.title ?? resource.id
|
|
2719
3123
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3124
|
+
"data-resource-id": resource.id,
|
|
2720
3125
|
...trackInteractionProps(resource),
|
|
2721
3126
|
...slot("track", { base: {
|
|
2722
3127
|
position: "relative",
|
|
@@ -2735,9 +3140,31 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2735
3140
|
pointerEvents: "none",
|
|
2736
3141
|
zIndex: 0
|
|
2737
3142
|
},
|
|
2738
|
-
themed: { background: theme.outsideHoursBackground }
|
|
3143
|
+
themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
|
|
3144
|
+
}),
|
|
3145
|
+
children: renderBusinessHours?.({
|
|
3146
|
+
date,
|
|
3147
|
+
start: b.start,
|
|
3148
|
+
end: b.end,
|
|
3149
|
+
resource
|
|
2739
3150
|
})
|
|
2740
3151
|
}, b.start)),
|
|
3152
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3153
|
+
"aria-hidden": true,
|
|
3154
|
+
title: b.event.title,
|
|
3155
|
+
...slot("backgroundEvent", {
|
|
3156
|
+
base: {
|
|
3157
|
+
position: "absolute",
|
|
3158
|
+
top: 0,
|
|
3159
|
+
bottom: 0,
|
|
3160
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
3161
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
3162
|
+
pointerEvents: "none",
|
|
3163
|
+
zIndex: 0
|
|
3164
|
+
},
|
|
3165
|
+
themed: { background: theme.backgroundEvent }
|
|
3166
|
+
})
|
|
3167
|
+
}, `bg-${i}`)),
|
|
2741
3168
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2742
3169
|
"aria-hidden": true,
|
|
2743
3170
|
...slot("gridLines", {
|
|
@@ -2770,9 +3197,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2770
3197
|
onClick: draggable ? void 0 : onPress,
|
|
2771
3198
|
"aria-label": pe.event.title,
|
|
2772
3199
|
...dataState({ "data-dragging": !!active }),
|
|
2773
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
|
|
3200
|
+
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe.startHours, pe.durationHours) : void 0,
|
|
2774
3201
|
onPointerMove: draggable ? moveDrag : void 0,
|
|
2775
|
-
onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
|
|
3202
|
+
onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
|
|
2776
3203
|
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
2777
3204
|
...slot("event", { base: {
|
|
2778
3205
|
position: "absolute",
|
|
@@ -2780,6 +3207,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2780
3207
|
width,
|
|
2781
3208
|
top: pe.column * laneHeight,
|
|
2782
3209
|
height: laneHeight,
|
|
3210
|
+
transform: active?.kind === "move" ? `translateY(${active.crossPx}px)` : void 0,
|
|
2783
3211
|
padding: 1,
|
|
2784
3212
|
border: "none",
|
|
2785
3213
|
background: "transparent",
|
|
@@ -2799,7 +3227,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2799
3227
|
"aria-hidden": true,
|
|
2800
3228
|
onPointerDown: (e) => {
|
|
2801
3229
|
e.stopPropagation();
|
|
2802
|
-
beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
|
|
3230
|
+
beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
|
|
2803
3231
|
},
|
|
2804
3232
|
style: {
|
|
2805
3233
|
position: "absolute",
|
|
@@ -2813,6 +3241,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2813
3241
|
}) : null]
|
|
2814
3242
|
}, idx);
|
|
2815
3243
|
}),
|
|
3244
|
+
nowLine(resource.id),
|
|
2816
3245
|
createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2817
3246
|
"aria-hidden": true,
|
|
2818
3247
|
...slot("createGhost", {
|
|
@@ -2850,6 +3279,12 @@ exports.MonthView = MonthView;
|
|
|
2850
3279
|
exports.ResourceTimeline = ResourceTimeline;
|
|
2851
3280
|
exports.TimeGrid = TimeGrid;
|
|
2852
3281
|
exports.YearView = YearView;
|
|
3282
|
+
Object.defineProperty(exports, "backgroundBandsForDay", {
|
|
3283
|
+
enumerable: true,
|
|
3284
|
+
get: function() {
|
|
3285
|
+
return _super_calendar_core.backgroundBandsForDay;
|
|
3286
|
+
}
|
|
3287
|
+
});
|
|
2853
3288
|
Object.defineProperty(exports, "buildMonthGrid", {
|
|
2854
3289
|
enumerable: true,
|
|
2855
3290
|
get: function() {
|
|
@@ -2882,6 +3317,12 @@ Object.defineProperty(exports, "isAllDayEvent", {
|
|
|
2882
3317
|
return _super_calendar_core.isAllDayEvent;
|
|
2883
3318
|
}
|
|
2884
3319
|
});
|
|
3320
|
+
Object.defineProperty(exports, "isBackgroundEvent", {
|
|
3321
|
+
enumerable: true,
|
|
3322
|
+
get: function() {
|
|
3323
|
+
return _super_calendar_core.isBackgroundEvent;
|
|
3324
|
+
}
|
|
3325
|
+
});
|
|
2885
3326
|
Object.defineProperty(exports, "isDateSelectable", {
|
|
2886
3327
|
enumerable: true,
|
|
2887
3328
|
get: function() {
|
|
@@ -2931,12 +3372,24 @@ Object.defineProperty(exports, "useDateRange", {
|
|
|
2931
3372
|
return _super_calendar_core.useDateRange;
|
|
2932
3373
|
}
|
|
2933
3374
|
});
|
|
3375
|
+
Object.defineProperty(exports, "useEventSource", {
|
|
3376
|
+
enumerable: true,
|
|
3377
|
+
get: function() {
|
|
3378
|
+
return _super_calendar_core.useEventSource;
|
|
3379
|
+
}
|
|
3380
|
+
});
|
|
2934
3381
|
Object.defineProperty(exports, "useMonthGrid", {
|
|
2935
3382
|
enumerable: true,
|
|
2936
3383
|
get: function() {
|
|
2937
3384
|
return _super_calendar_core.useMonthGrid;
|
|
2938
3385
|
}
|
|
2939
3386
|
});
|
|
3387
|
+
Object.defineProperty(exports, "useNow", {
|
|
3388
|
+
enumerable: true,
|
|
3389
|
+
get: function() {
|
|
3390
|
+
return _super_calendar_core.useNow;
|
|
3391
|
+
}
|
|
3392
|
+
});
|
|
2940
3393
|
Object.defineProperty(exports, "weekdayFormatToken", {
|
|
2941
3394
|
enumerable: true,
|
|
2942
3395
|
get: function() {
|