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