@super-calendar/dom 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/index.d.mts +49 -7
- package/dist/index.d.ts +49 -7
- package/dist/index.js +424 -87
- package/dist/index.mjs +420 -90
- package/package.json +2 -2
- package/src/Calendar.tsx +78 -13
- package/src/MonthView.tsx +388 -65
- package/src/MultiWeekView.tsx +54 -0
- package/src/index.ts +7 -0
- package/src/touch.ts +70 -0
package/dist/index.js
CHANGED
|
@@ -542,6 +542,99 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, labels:
|
|
|
542
542
|
})
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
|
+
// src/touch.ts
|
|
546
|
+
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
547
|
+
const detach = () => {
|
|
548
|
+
clearTimeout(timer);
|
|
549
|
+
document.removeEventListener("pointermove", move);
|
|
550
|
+
document.removeEventListener("pointerup", up);
|
|
551
|
+
document.removeEventListener("pointercancel", cancelPointer);
|
|
552
|
+
document.removeEventListener("pointerdown", anotherPointer);
|
|
553
|
+
};
|
|
554
|
+
const cancel = () => {
|
|
555
|
+
detach();
|
|
556
|
+
onCancel();
|
|
557
|
+
};
|
|
558
|
+
const move = (event) => {
|
|
559
|
+
if (event.pointerId === grab.pointerId && Math.hypot(event.clientX - grab.clientX, event.clientY - grab.clientY) > threshold) cancel();
|
|
560
|
+
};
|
|
561
|
+
const up = (event) => {
|
|
562
|
+
if (event.pointerId === grab.pointerId) {
|
|
563
|
+
detach();
|
|
564
|
+
onTap();
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
const cancelPointer = (event) => {
|
|
568
|
+
if (event.pointerId === grab.pointerId) cancel();
|
|
569
|
+
};
|
|
570
|
+
const anotherPointer = (event) => {
|
|
571
|
+
if (event.pointerId !== grab.pointerId) cancel();
|
|
572
|
+
};
|
|
573
|
+
const timer = setTimeout(() => {
|
|
574
|
+
detach();
|
|
575
|
+
onHold();
|
|
576
|
+
}, delay);
|
|
577
|
+
document.addEventListener("pointermove", move);
|
|
578
|
+
document.addEventListener("pointerup", up);
|
|
579
|
+
document.addEventListener("pointercancel", cancelPointer);
|
|
580
|
+
document.addEventListener("pointerdown", anotherPointer);
|
|
581
|
+
return cancel;
|
|
582
|
+
}
|
|
583
|
+
/** A quick swipe scrolls; a held pointer owns a date-row drag until release. */
|
|
584
|
+
function holdDateDrag(grab, start, move, cancel, release) {
|
|
585
|
+
const doc = grab.box.ownerDocument;
|
|
586
|
+
let active = false;
|
|
587
|
+
let finished = false;
|
|
588
|
+
let cancelWait;
|
|
589
|
+
const detach = () => {
|
|
590
|
+
doc.removeEventListener("pointermove", onMove);
|
|
591
|
+
doc.removeEventListener("pointerup", onUp);
|
|
592
|
+
doc.removeEventListener("pointercancel", onCancel);
|
|
593
|
+
doc.removeEventListener("pointerdown", onAnotherPointer);
|
|
594
|
+
doc.removeEventListener("touchmove", onTouchMove);
|
|
595
|
+
doc.removeEventListener("contextmenu", onContextMenu);
|
|
596
|
+
};
|
|
597
|
+
const stop = () => {
|
|
598
|
+
if (finished) return;
|
|
599
|
+
finished = true;
|
|
600
|
+
detach();
|
|
601
|
+
cancelWait?.();
|
|
602
|
+
cancel();
|
|
603
|
+
release();
|
|
604
|
+
};
|
|
605
|
+
const onMove = (event) => {
|
|
606
|
+
if (active && event.pointerId === grab.pointerId) move(event.clientX, event.clientY);
|
|
607
|
+
};
|
|
608
|
+
const onUp = (event) => {
|
|
609
|
+
if (event.pointerId !== grab.pointerId) return;
|
|
610
|
+
finished = true;
|
|
611
|
+
detach();
|
|
612
|
+
release();
|
|
613
|
+
};
|
|
614
|
+
const onCancel = (event) => {
|
|
615
|
+
if (event.pointerId === grab.pointerId) stop();
|
|
616
|
+
};
|
|
617
|
+
const onAnotherPointer = (event) => {
|
|
618
|
+
if (event.pointerId !== grab.pointerId) stop();
|
|
619
|
+
};
|
|
620
|
+
const onTouchMove = (event) => {
|
|
621
|
+
if (active && event.cancelable) event.preventDefault();
|
|
622
|
+
};
|
|
623
|
+
const onContextMenu = (event) => {
|
|
624
|
+
event.preventDefault();
|
|
625
|
+
};
|
|
626
|
+
doc.addEventListener("pointermove", onMove);
|
|
627
|
+
doc.addEventListener("pointerup", onUp);
|
|
628
|
+
doc.addEventListener("pointercancel", onCancel);
|
|
629
|
+
doc.addEventListener("pointerdown", onAnotherPointer);
|
|
630
|
+
doc.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
631
|
+
doc.addEventListener("contextmenu", onContextMenu);
|
|
632
|
+
cancelWait = waitForHold(grab, 400, 8, () => {
|
|
633
|
+
active = true;
|
|
634
|
+
start();
|
|
635
|
+
}, release, stop);
|
|
636
|
+
return stop;
|
|
637
|
+
}
|
|
545
638
|
// src/MonthView.tsx
|
|
546
639
|
const EMPTY_LAYOUT = {
|
|
547
640
|
segments: [],
|
|
@@ -551,6 +644,7 @@ const CHIP_HEIGHT = 18;
|
|
|
551
644
|
const CHIP_GAP = 2;
|
|
552
645
|
const CELL_PAD = 4;
|
|
553
646
|
const DRAGGED_CHIP_OPACITY = .4;
|
|
647
|
+
const isOutsidePeriod = (day) => day.isCurrentMonth === false;
|
|
554
648
|
function dayCellDefault(day, theme, highlightWeekends) {
|
|
555
649
|
return {
|
|
556
650
|
base: {
|
|
@@ -710,7 +804,7 @@ function chipDefault(theme, chipHeight) {
|
|
|
710
804
|
}
|
|
711
805
|
};
|
|
712
806
|
}
|
|
713
|
-
function moreButtonDefault(theme, chipHeight) {
|
|
807
|
+
function moreButtonDefault(theme, chipHeight, multiWeek = false) {
|
|
714
808
|
return {
|
|
715
809
|
base: {
|
|
716
810
|
position: "relative",
|
|
@@ -721,7 +815,12 @@ function moreButtonDefault(theme, chipHeight) {
|
|
|
721
815
|
textAlign: "left",
|
|
722
816
|
height: chipHeight,
|
|
723
817
|
lineHeight: `${chipHeight}px`,
|
|
724
|
-
fontFamily: "inherit"
|
|
818
|
+
fontFamily: "inherit",
|
|
819
|
+
...multiWeek ? {
|
|
820
|
+
whiteSpace: "nowrap",
|
|
821
|
+
overflow: "hidden",
|
|
822
|
+
textOverflow: "ellipsis"
|
|
823
|
+
} : {}
|
|
725
824
|
},
|
|
726
825
|
themed: {
|
|
727
826
|
padding: "0 6px",
|
|
@@ -744,6 +843,10 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
744
843
|
}
|
|
745
844
|
return out;
|
|
746
845
|
}
|
|
846
|
+
function rangeTitle(start, endExclusive, locale) {
|
|
847
|
+
const options = locale ? { locale } : void 0;
|
|
848
|
+
return `${(0, date_fns.format)(start, "PP", options)} – ${(0, date_fns.format)((0, date_fns.addDays)(endExclusive, -1), "PP", options)}`;
|
|
849
|
+
}
|
|
747
850
|
/**
|
|
748
851
|
* A single static month grid, rendered with plain DOM elements.
|
|
749
852
|
*
|
|
@@ -752,14 +855,33 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
752
855
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
753
856
|
* ```
|
|
754
857
|
*/
|
|
755
|
-
function MonthView({ date,
|
|
858
|
+
function MonthView({ date, showAdjacentMonths = true, ...rest }) {
|
|
859
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRows, {
|
|
860
|
+
...rest,
|
|
861
|
+
source: {
|
|
862
|
+
kind: "month",
|
|
863
|
+
date,
|
|
864
|
+
showAdjacentMonths
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* The day-row grid behind the public row views: week rows of day cells with
|
|
870
|
+
* spanning event bars, overflow, selection, drag, and keyboard handling.
|
|
871
|
+
*/
|
|
872
|
+
function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, chipHeight = CHIP_HEIGHT, chipGap = CHIP_GAP, moreLabel = "{moreCount} More", labels: labelsProp, onPressEvent, onPressMore, selectedRange, selectedDates, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
873
|
+
const { date } = source;
|
|
874
|
+
const multiWeek = source.kind === "multiweek";
|
|
875
|
+
const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
|
|
876
|
+
const numberOfWeeks = source.kind === "multiweek" ? source.numberOfWeeks : void 0;
|
|
877
|
+
const viewMode = multiWeek ? "multiweek" : "month";
|
|
756
878
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
757
879
|
const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
|
|
758
880
|
const slot = createSlots({
|
|
759
881
|
classNames,
|
|
760
882
|
styles
|
|
761
883
|
});
|
|
762
|
-
const eventsMode = events !== void 0;
|
|
884
|
+
const eventsMode = events !== void 0 || multiWeek;
|
|
763
885
|
const dayRoving = !eventsMode || keyboardDayNavigation;
|
|
764
886
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
765
887
|
if (eventsByDayProp) return eventsByDayProp;
|
|
@@ -797,20 +919,39 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
797
919
|
document.removeEventListener("keydown", onKey);
|
|
798
920
|
};
|
|
799
921
|
}, [moreOpenFor]);
|
|
800
|
-
const eventRowHeight = 32 + maxVisibleEventCount * (chipHeight + chipGap);
|
|
801
|
-
const { weeks, weekdays } = (0, react.useMemo)(() =>
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
922
|
+
const eventRowHeight = 32 + (multiWeek ? Math.max(1, maxVisibleEventCount) : maxVisibleEventCount) * (chipHeight + chipGap);
|
|
923
|
+
const { weeks, weekdays, title, period } = (0, react.useMemo)(() => {
|
|
924
|
+
const options = {
|
|
925
|
+
weekStartsOn,
|
|
926
|
+
hiddenDays,
|
|
927
|
+
weekdayFormat,
|
|
928
|
+
selectedRange,
|
|
929
|
+
selectedDates,
|
|
930
|
+
minDate,
|
|
931
|
+
maxDate,
|
|
932
|
+
isDateDisabled,
|
|
933
|
+
locale
|
|
934
|
+
};
|
|
935
|
+
if (numberOfWeeks === void 0) return {
|
|
936
|
+
...(0, _super_calendar_core.buildMonthGrid)(date, options),
|
|
937
|
+
title: (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0),
|
|
938
|
+
period: null
|
|
939
|
+
};
|
|
940
|
+
const grid = (0, _super_calendar_core.buildMultiWeekGrid)(date, {
|
|
941
|
+
...options,
|
|
942
|
+
numberOfWeeks
|
|
943
|
+
});
|
|
944
|
+
return {
|
|
945
|
+
weeks: grid.weeks,
|
|
946
|
+
weekdays: grid.weekdays,
|
|
947
|
+
title: rangeTitle(grid.visibleRange.start, grid.visibleRange.endExclusive, locale),
|
|
948
|
+
period: grid.period
|
|
949
|
+
};
|
|
950
|
+
}, [
|
|
812
951
|
date,
|
|
952
|
+
numberOfWeeks,
|
|
813
953
|
weekStartsOn,
|
|
954
|
+
hiddenDays,
|
|
814
955
|
weekdayFormat,
|
|
815
956
|
selectedRange,
|
|
816
957
|
selectedDates,
|
|
@@ -824,7 +965,18 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
824
965
|
weeks,
|
|
825
966
|
eventsByDay
|
|
826
967
|
]);
|
|
968
|
+
const focusableDays = (0, react.useMemo)(() => period ? weeks.flatMap((week) => week.days).filter((day) => !day.isDisabled).map((day) => (0, date_fns.startOfDay)(day.date)).sort((a, b) => a.getTime() - b.getTime()) : null, [period, weeks]);
|
|
969
|
+
const focusableKeys = (0, react.useMemo)(() => focusableDays ? new Set(focusableDays.map((d) => (0, date_fns.format)(d, "yyyy-MM-dd"))) : null, [focusableDays]);
|
|
827
970
|
const initialFocus = (0, react.useMemo)(() => {
|
|
971
|
+
if (focusableDays && focusableKeys) {
|
|
972
|
+
const rendered = (d) => !!d && focusableKeys.has((0, date_fns.format)(d, "yyyy-MM-dd"));
|
|
973
|
+
if (rendered(selectedRange?.start)) return (0, date_fns.startOfDay)(selectedRange.start);
|
|
974
|
+
const picked = selectedDates?.find(rendered);
|
|
975
|
+
if (picked) return (0, date_fns.startOfDay)(picked);
|
|
976
|
+
const today = /* @__PURE__ */ new Date();
|
|
977
|
+
if (rendered(today)) return (0, date_fns.startOfDay)(today);
|
|
978
|
+
return focusableDays[0] ?? null;
|
|
979
|
+
}
|
|
828
980
|
const inMonth = (d) => !!d && (0, date_fns.isSameMonth)(d, date);
|
|
829
981
|
if (inMonth(selectedRange?.start)) return (0, date_fns.startOfDay)(selectedRange.start);
|
|
830
982
|
const picked = selectedDates?.find(inMonth);
|
|
@@ -832,6 +984,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
832
984
|
const today = /* @__PURE__ */ new Date();
|
|
833
985
|
return (0, date_fns.isSameMonth)(today, date) ? (0, date_fns.startOfDay)(today) : (0, date_fns.startOfMonth)(date);
|
|
834
986
|
}, [
|
|
987
|
+
focusableDays,
|
|
988
|
+
focusableKeys,
|
|
835
989
|
date,
|
|
836
990
|
selectedRange,
|
|
837
991
|
selectedDates
|
|
@@ -839,16 +993,36 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
839
993
|
const [focusedDate, setFocusedDate] = (0, react.useState)(initialFocus);
|
|
840
994
|
const initialFocusRef = (0, react.useRef)(initialFocus);
|
|
841
995
|
initialFocusRef.current = initialFocus;
|
|
842
|
-
const
|
|
843
|
-
const
|
|
996
|
+
const windowKey = period ? `${(0, date_fns.format)(period.start, "yyyy-MM-dd")}+${numberOfWeeks}:${weekdays.map((day) => day.date.getDay()).join(",")}` : (0, date_fns.format)(date, "yyyy-MM");
|
|
997
|
+
const windowKeyRef = (0, react.useRef)(windowKey);
|
|
998
|
+
windowKeyRef.current = windowKey;
|
|
999
|
+
const focusedWindow = (0, react.useRef)(windowKey);
|
|
1000
|
+
const gridRef = (0, react.useRef)(null);
|
|
1001
|
+
const restoreDayFocus = (0, react.useRef)(false);
|
|
1002
|
+
if (multiWeek && windowKey !== focusedWindow.current) {
|
|
1003
|
+
const active = gridRef.current?.ownerDocument.activeElement;
|
|
1004
|
+
restoreDayFocus.current = !!active?.hasAttribute("data-day") && !!gridRef.current?.contains(active);
|
|
1005
|
+
}
|
|
844
1006
|
(0, react.useEffect)(() => {
|
|
845
|
-
if (
|
|
846
|
-
|
|
1007
|
+
if (windowKey === focusedWindow.current) return;
|
|
1008
|
+
focusedWindow.current = windowKey;
|
|
847
1009
|
setFocusedDate(initialFocusRef.current);
|
|
848
|
-
|
|
1010
|
+
if (restoreDayFocus.current) {
|
|
1011
|
+
const active = gridRef.current?.ownerDocument.activeElement;
|
|
1012
|
+
if (active === gridRef.current?.ownerDocument.body || active && gridRef.current?.contains(active)) (initialFocusRef.current ? gridRef.current?.querySelector(`[data-day="${(0, date_fns.format)(initialFocusRef.current, "yyyy-MM-dd")}"]`) : gridRef.current)?.focus();
|
|
1013
|
+
}
|
|
1014
|
+
restoreDayFocus.current = false;
|
|
1015
|
+
}, [windowKey]);
|
|
849
1016
|
const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
|
|
850
|
-
const
|
|
851
|
-
const focusKey = (0, date_fns.format)(
|
|
1017
|
+
const storedFocusKey = focusedDate ? (0, date_fns.format)(focusedDate, "yyyy-MM-dd") : null;
|
|
1018
|
+
const focusKey = focusableKeys && (storedFocusKey === null || !focusableKeys.has(storedFocusKey)) ? initialFocus && (0, date_fns.format)(initialFocus, "yyyy-MM-dd") : storedFocusKey;
|
|
1019
|
+
(0, react.useEffect)(() => {
|
|
1020
|
+
if (!multiWeek) return;
|
|
1021
|
+
const active = gridRef.current?.ownerDocument.activeElement;
|
|
1022
|
+
if (!active?.hasAttribute("data-day") || !gridRef.current?.contains(active)) return;
|
|
1023
|
+
if (active.getAttribute("data-day") === focusKey && active.getAttribute("aria-disabled") !== "true") return;
|
|
1024
|
+
(focusKey ? gridRef.current.querySelector(`[data-day="${focusKey}"]`) : gridRef.current)?.focus();
|
|
1025
|
+
}, [multiWeek, focusKey]);
|
|
852
1026
|
const [drag, setDrag] = (0, react.useState)(null);
|
|
853
1027
|
const dragRef = (0, react.useRef)(drag);
|
|
854
1028
|
dragRef.current = drag;
|
|
@@ -870,7 +1044,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
870
1044
|
setDrag({
|
|
871
1045
|
kind: "create",
|
|
872
1046
|
anchor: t,
|
|
873
|
-
hover: t
|
|
1047
|
+
hover: t,
|
|
1048
|
+
windowKey
|
|
874
1049
|
});
|
|
875
1050
|
};
|
|
876
1051
|
const beginMove = (event, day) => {
|
|
@@ -880,7 +1055,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
880
1055
|
kind: "move",
|
|
881
1056
|
event,
|
|
882
1057
|
from: t,
|
|
883
|
-
to: t
|
|
1058
|
+
to: t,
|
|
1059
|
+
windowKey
|
|
884
1060
|
});
|
|
885
1061
|
onDragStart?.(event);
|
|
886
1062
|
};
|
|
@@ -902,6 +1078,70 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
902
1078
|
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
903
1079
|
}
|
|
904
1080
|
};
|
|
1081
|
+
const heldTouch = (0, react.useRef)(null);
|
|
1082
|
+
const heldOrigin = (0, react.useRef)(null);
|
|
1083
|
+
const dayLookup = (0, react.useMemo)(() => new Map(weeks.flatMap((week) => week.days).map((day) => [day.id, day])), [weeks]);
|
|
1084
|
+
const touchHandlers = (0, react.useRef)({
|
|
1085
|
+
beginCreate,
|
|
1086
|
+
beginMove,
|
|
1087
|
+
extendDrag,
|
|
1088
|
+
dayLookup
|
|
1089
|
+
});
|
|
1090
|
+
touchHandlers.current = {
|
|
1091
|
+
beginCreate,
|
|
1092
|
+
beginMove,
|
|
1093
|
+
extendDrag,
|
|
1094
|
+
dayLookup
|
|
1095
|
+
};
|
|
1096
|
+
const pressRow = (event, day, moving) => {
|
|
1097
|
+
if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
|
|
1098
|
+
beginPress();
|
|
1099
|
+
const start = () => {
|
|
1100
|
+
if (moving) touchHandlers.current.beginMove(moving, day);
|
|
1101
|
+
else touchHandlers.current.beginCreate(day);
|
|
1102
|
+
};
|
|
1103
|
+
if (!multiWeek || !event.pointerType || event.pointerType === "mouse") {
|
|
1104
|
+
start();
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
heldOrigin.current = {
|
|
1108
|
+
day,
|
|
1109
|
+
event: moving
|
|
1110
|
+
};
|
|
1111
|
+
heldTouch.current = holdDateDrag({
|
|
1112
|
+
box: event.currentTarget,
|
|
1113
|
+
pointerId: event.pointerId,
|
|
1114
|
+
pointerType: event.pointerType,
|
|
1115
|
+
clientX: event.clientX,
|
|
1116
|
+
clientY: event.clientY
|
|
1117
|
+
}, start, (x, y) => {
|
|
1118
|
+
const element = gridRef.current?.ownerDocument.elementFromPoint(x, y)?.closest("[data-day]");
|
|
1119
|
+
if (!element || !gridRef.current?.contains(element)) return;
|
|
1120
|
+
const day = touchHandlers.current.dayLookup.get(element.dataset.day ?? "");
|
|
1121
|
+
if (day && !day.isDisabled) touchHandlers.current.extendDrag(day.date);
|
|
1122
|
+
}, () => {
|
|
1123
|
+
dragRef.current = null;
|
|
1124
|
+
setDrag(null);
|
|
1125
|
+
movedRef.current = false;
|
|
1126
|
+
}, () => {
|
|
1127
|
+
heldTouch.current = null;
|
|
1128
|
+
heldOrigin.current = null;
|
|
1129
|
+
});
|
|
1130
|
+
};
|
|
1131
|
+
(0, react.useEffect)(() => () => {
|
|
1132
|
+
heldTouch.current?.();
|
|
1133
|
+
}, [windowKey]);
|
|
1134
|
+
(0, react.useEffect)(() => {
|
|
1135
|
+
const origin = heldOrigin.current;
|
|
1136
|
+
if (!origin) return;
|
|
1137
|
+
const current = dragRef.current;
|
|
1138
|
+
const destination = current ? new Date(current.kind === "create" ? current.hover : current.to) : origin.day;
|
|
1139
|
+
const enabled = (day) => {
|
|
1140
|
+
const cell = dayLookup.get((0, date_fns.format)(day, "yyyy-MM-dd"));
|
|
1141
|
+
return cell != null && !cell.isDisabled;
|
|
1142
|
+
};
|
|
1143
|
+
if (!enabled(origin.day) || !enabled(destination) || (origin.event ? !events?.includes(origin.event) || !canMove(origin.event) : !onCreateEvent && !onSelectDrag)) heldTouch.current?.();
|
|
1144
|
+
});
|
|
905
1145
|
const isDragging = drag !== null;
|
|
906
1146
|
const dragWired = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
907
1147
|
(0, react.useEffect)(() => {
|
|
@@ -910,6 +1150,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
910
1150
|
const current = dragRef.current;
|
|
911
1151
|
setDrag(null);
|
|
912
1152
|
if (!current || !movedRef.current) return;
|
|
1153
|
+
if (multiWeek && current.windowKey !== windowKeyRef.current) return;
|
|
913
1154
|
suppressClickRef.current = true;
|
|
914
1155
|
if (current.kind === "create") {
|
|
915
1156
|
const range = (0, _super_calendar_core.monthCreateRange)(new Date(current.anchor), new Date(current.hover));
|
|
@@ -925,12 +1166,51 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
925
1166
|
return () => window.removeEventListener("pointerup", finish);
|
|
926
1167
|
}, [
|
|
927
1168
|
isDragging,
|
|
1169
|
+
multiWeek,
|
|
928
1170
|
onCreateEvent,
|
|
929
1171
|
onDragEvent,
|
|
930
1172
|
eventOverlap,
|
|
931
1173
|
events
|
|
932
1174
|
]);
|
|
1175
|
+
const transientWindow = (0, react.useRef)(windowKey);
|
|
1176
|
+
(0, react.useEffect)(() => {
|
|
1177
|
+
if (transientWindow.current === windowKey) return;
|
|
1178
|
+
transientWindow.current = windowKey;
|
|
1179
|
+
if (!multiWeek) return;
|
|
1180
|
+
setDrag(null);
|
|
1181
|
+
setMoreOpenFor(null);
|
|
1182
|
+
}, [multiWeek, windowKey]);
|
|
1183
|
+
const nextMultiWeekFocus = (key) => {
|
|
1184
|
+
if (!focusableDays || !focusableKeys || !period) return void 0;
|
|
1185
|
+
const index = focusableDays.findIndex((d) => (0, date_fns.format)(d, "yyyy-MM-dd") === focusKey);
|
|
1186
|
+
if (index === -1) return null;
|
|
1187
|
+
if (key === "ArrowLeft") return focusableDays[index - 1] ?? null;
|
|
1188
|
+
if (key === "ArrowRight") return focusableDays[index + 1] ?? null;
|
|
1189
|
+
if (key === "Home") return focusableDays[0];
|
|
1190
|
+
if (key === "End") return focusableDays[focusableDays.length - 1];
|
|
1191
|
+
const step = key === "ArrowUp" ? -7 : 7;
|
|
1192
|
+
for (let cursor = (0, date_fns.addDays)(focusableDays[index], step); cursor >= period.start && cursor < period.endExclusive; cursor = (0, date_fns.addDays)(cursor, step)) if (focusableKeys.has((0, date_fns.format)(cursor, "yyyy-MM-dd"))) return cursor;
|
|
1193
|
+
return null;
|
|
1194
|
+
};
|
|
933
1195
|
const onKeyDown = (e) => {
|
|
1196
|
+
if (multiWeek) {
|
|
1197
|
+
if (![
|
|
1198
|
+
"ArrowLeft",
|
|
1199
|
+
"ArrowRight",
|
|
1200
|
+
"ArrowUp",
|
|
1201
|
+
"ArrowDown",
|
|
1202
|
+
"Home",
|
|
1203
|
+
"End"
|
|
1204
|
+
].includes(e.key)) return;
|
|
1205
|
+
e.preventDefault();
|
|
1206
|
+
const target = nextMultiWeekFocus(e.key);
|
|
1207
|
+
if (!target) return;
|
|
1208
|
+
setFocusedDate(target);
|
|
1209
|
+
const targetKey = (0, date_fns.format)(target, "yyyy-MM-dd");
|
|
1210
|
+
gridRef.current?.querySelector(`[data-day="${targetKey}"]`)?.focus();
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
if (!focusedDate) return;
|
|
934
1214
|
let next = null;
|
|
935
1215
|
if (e.key === "ArrowLeft") next = (0, date_fns.addDays)(focusedDate, -1);
|
|
936
1216
|
else if (e.key === "ArrowRight") next = (0, date_fns.addDays)(focusedDate, 1);
|
|
@@ -950,6 +1230,11 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
950
1230
|
style: {
|
|
951
1231
|
fontFamily: theme.fontFamily,
|
|
952
1232
|
color: theme.text,
|
|
1233
|
+
...multiWeek ? {
|
|
1234
|
+
display: "flex",
|
|
1235
|
+
flexDirection: "column",
|
|
1236
|
+
minHeight: 0
|
|
1237
|
+
} : null,
|
|
953
1238
|
...style
|
|
954
1239
|
},
|
|
955
1240
|
children: [
|
|
@@ -959,13 +1244,13 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
959
1244
|
fontWeight: 700,
|
|
960
1245
|
padding: "10px 14px 6px"
|
|
961
1246
|
} }),
|
|
962
|
-
children:
|
|
1247
|
+
children: title
|
|
963
1248
|
}) : null,
|
|
964
1249
|
showWeekdays ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
965
1250
|
...slot("weekdays", {
|
|
966
1251
|
base: {
|
|
967
1252
|
display: "grid",
|
|
968
|
-
gridTemplateColumns:
|
|
1253
|
+
gridTemplateColumns: `repeat(${weekdays.length}, minmax(0, 1fr))`
|
|
969
1254
|
},
|
|
970
1255
|
themed: {
|
|
971
1256
|
borderBottom: `1px solid ${theme.gridLine}`,
|
|
@@ -985,9 +1270,14 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
985
1270
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
986
1271
|
ref: gridRef,
|
|
987
1272
|
role: "grid",
|
|
988
|
-
|
|
1273
|
+
tabIndex: multiWeek ? -1 : void 0,
|
|
1274
|
+
"aria-label": title,
|
|
989
1275
|
onKeyDown: dayRoving ? onKeyDown : void 0,
|
|
990
|
-
...slot("grid"
|
|
1276
|
+
...slot("grid", multiWeek ? { base: {
|
|
1277
|
+
flex: "1 1 auto",
|
|
1278
|
+
minHeight: 0,
|
|
1279
|
+
overflowY: "auto"
|
|
1280
|
+
} } : void 0),
|
|
991
1281
|
children: weeks.map((week, weekIndex) => {
|
|
992
1282
|
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
993
1283
|
const visibleLanes = rowLayout.laneCount > maxVisibleEventCount ? Math.max(maxVisibleEventCount - 1, 1) : rowLayout.laneCount;
|
|
@@ -995,8 +1285,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
995
1285
|
let firstVisCol = 0;
|
|
996
1286
|
let lastVisCol = cols - 1;
|
|
997
1287
|
if (eventsMode && !showAdjacentMonths) {
|
|
998
|
-
const first = week.days.findIndex((d) => d
|
|
999
|
-
const lastFromEnd = [...week.days].reverse().findIndex((d) => d
|
|
1288
|
+
const first = week.days.findIndex((d) => !isOutsidePeriod(d));
|
|
1289
|
+
const lastFromEnd = [...week.days].reverse().findIndex((d) => !isOutsidePeriod(d));
|
|
1000
1290
|
if (first !== -1) {
|
|
1001
1291
|
firstVisCol = first;
|
|
1002
1292
|
lastVisCol = cols - 1 - lastFromEnd;
|
|
@@ -1019,10 +1309,10 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1019
1309
|
role: "row",
|
|
1020
1310
|
...slot("week", { base: {
|
|
1021
1311
|
display: "grid",
|
|
1022
|
-
gridTemplateColumns:
|
|
1312
|
+
gridTemplateColumns: `repeat(${week.days.length}, minmax(0, 1fr))`
|
|
1023
1313
|
} }),
|
|
1024
1314
|
children: week.days.map((day, dayCol) => {
|
|
1025
|
-
const hidden = !showAdjacentMonths &&
|
|
1315
|
+
const hidden = !showAdjacentMonths && isOutsidePeriod(day);
|
|
1026
1316
|
const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
|
|
1027
1317
|
if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1028
1318
|
role: "gridcell",
|
|
@@ -1044,7 +1334,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1044
1334
|
"data-selected": day.isSelected,
|
|
1045
1335
|
"data-range": day.isInRange,
|
|
1046
1336
|
"data-weekend": day.isWeekend,
|
|
1047
|
-
"data-outside":
|
|
1337
|
+
"data-outside": isOutsidePeriod(day),
|
|
1048
1338
|
"data-disabled": day.isDisabled,
|
|
1049
1339
|
"data-creating": inCreate,
|
|
1050
1340
|
"data-drop": isDropTarget
|
|
@@ -1073,13 +1363,11 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1073
1363
|
...dayCellProps,
|
|
1074
1364
|
style: dragWired ? {
|
|
1075
1365
|
...dayCellProps.style,
|
|
1076
|
-
touchAction: "none",
|
|
1366
|
+
touchAction: multiWeek ? "pan-y" : "none",
|
|
1077
1367
|
userSelect: "none"
|
|
1078
1368
|
} : dayCellProps.style,
|
|
1079
1369
|
onPointerDown: dragWired && !day.isDisabled ? (e) => {
|
|
1080
|
-
|
|
1081
|
-
beginPress();
|
|
1082
|
-
beginCreate(day.date);
|
|
1370
|
+
pressRow(e, day.date);
|
|
1083
1371
|
} : void 0,
|
|
1084
1372
|
onPointerEnter: dragWired && !day.isDisabled ? () => extendDrag(day.date) : void 0,
|
|
1085
1373
|
onClick: day.isDisabled ? void 0 : () => {
|
|
@@ -1114,8 +1402,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1114
1402
|
onPointerDown: canMove(b.seg.event) ? (e) => {
|
|
1115
1403
|
if (e.button !== 0) return;
|
|
1116
1404
|
e.stopPropagation();
|
|
1117
|
-
|
|
1118
|
-
beginMove(b.seg.event, day.date);
|
|
1405
|
+
pressRow(e, day.date, b.seg.event);
|
|
1119
1406
|
} : void 0,
|
|
1120
1407
|
onClick: (e) => {
|
|
1121
1408
|
e.stopPropagation();
|
|
@@ -1125,7 +1412,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1125
1412
|
...barChipButton,
|
|
1126
1413
|
title: b.seg.event.title,
|
|
1127
1414
|
"aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(b.seg.event, {
|
|
1128
|
-
mode:
|
|
1415
|
+
mode: viewMode,
|
|
1129
1416
|
isAllDay: (0, _super_calendar_core.isAllDayEvent)(b.seg.event),
|
|
1130
1417
|
ampm: false
|
|
1131
1418
|
}) : `${b.seg.event.title}, ${dayLabel}`,
|
|
@@ -1139,10 +1426,11 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1139
1426
|
pointerEvents: isDragging ? "none" : "auto",
|
|
1140
1427
|
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1141
1428
|
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
1142
|
-
touchAction: dragWired ? "none" : void 0,
|
|
1429
|
+
touchAction: dragWired ? multiWeek ? "pan-y" : "none" : void 0,
|
|
1143
1430
|
zIndex: 2
|
|
1144
1431
|
},
|
|
1145
1432
|
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
1433
|
+
mode: viewMode,
|
|
1146
1434
|
event: b.seg.event,
|
|
1147
1435
|
onPress: () => onPressEvent?.(b.seg.event)
|
|
1148
1436
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1184,7 +1472,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1184
1472
|
setMoreOpenFor((open) => open === day.id ? null : day.id);
|
|
1185
1473
|
}
|
|
1186
1474
|
},
|
|
1187
|
-
...slot("more", moreButtonDefault(theme, chipHeight)),
|
|
1475
|
+
...slot("more", moreButtonDefault(theme, chipHeight, multiWeek)),
|
|
1188
1476
|
"aria-label": `${labels.moreEvents(hiddenEvents.length)}, ${dayLabel}`,
|
|
1189
1477
|
"aria-expanded": onPressMore ? void 0 : moreOpenFor === day.id,
|
|
1190
1478
|
children: moreLabel.replace("{moreCount}", String(hiddenEvents.length))
|
|
@@ -1253,6 +1541,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1253
1541
|
cursor: "pointer"
|
|
1254
1542
|
},
|
|
1255
1543
|
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
1544
|
+
mode: viewMode,
|
|
1256
1545
|
event,
|
|
1257
1546
|
onPress: () => onPressEvent?.(event)
|
|
1258
1547
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1302,6 +1591,33 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1302
1591
|
]
|
|
1303
1592
|
});
|
|
1304
1593
|
}
|
|
1594
|
+
// src/MultiWeekView.tsx
|
|
1595
|
+
/**
|
|
1596
|
+
* Consecutive full weeks as stacked seven-day rows, with event chips and no hour
|
|
1597
|
+
* slots. It has the month grid's event bars, overflow, selection, and drag
|
|
1598
|
+
* interactions, and the month slots, `renderEvent`, and theme style it. Every
|
|
1599
|
+
* row is kept at full height; when the view is given less room, the rows scroll
|
|
1600
|
+
* under the title and weekday header.
|
|
1601
|
+
*
|
|
1602
|
+
* Standalone, it shows `events` as given; expand recurring events first with
|
|
1603
|
+
* `expandRecurringEvents`, or use `Calendar` with `mode="multiweek"`.
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```tsx
|
|
1607
|
+
* <MultiWeekView date={new Date()} numberOfWeeks={3} events={events} />
|
|
1608
|
+
* ```
|
|
1609
|
+
*/
|
|
1610
|
+
function MultiWeekView({ date, numberOfWeeks = 2, chipHeight = 24, ...rest }) {
|
|
1611
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRows, {
|
|
1612
|
+
...rest,
|
|
1613
|
+
chipHeight,
|
|
1614
|
+
source: {
|
|
1615
|
+
kind: "multiweek",
|
|
1616
|
+
date,
|
|
1617
|
+
numberOfWeeks
|
|
1618
|
+
}
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1305
1621
|
// src/EventActions.tsx
|
|
1306
1622
|
function moveFocus(event, container) {
|
|
1307
1623
|
const buttons = [...container?.querySelectorAll("button") ?? []];
|
|
@@ -1668,44 +1984,6 @@ function InertDiv(props) {
|
|
|
1668
1984
|
inert: props.inert ? "inert" : void 0
|
|
1669
1985
|
});
|
|
1670
1986
|
}
|
|
1671
|
-
// src/touch.ts
|
|
1672
|
-
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
1673
|
-
const detach = () => {
|
|
1674
|
-
clearTimeout(timer);
|
|
1675
|
-
document.removeEventListener("pointermove", move);
|
|
1676
|
-
document.removeEventListener("pointerup", up);
|
|
1677
|
-
document.removeEventListener("pointercancel", cancelPointer);
|
|
1678
|
-
document.removeEventListener("pointerdown", anotherPointer);
|
|
1679
|
-
};
|
|
1680
|
-
const cancel = () => {
|
|
1681
|
-
detach();
|
|
1682
|
-
onCancel();
|
|
1683
|
-
};
|
|
1684
|
-
const move = (event) => {
|
|
1685
|
-
if (event.pointerId === grab.pointerId && Math.hypot(event.clientX - grab.clientX, event.clientY - grab.clientY) > threshold) cancel();
|
|
1686
|
-
};
|
|
1687
|
-
const up = (event) => {
|
|
1688
|
-
if (event.pointerId === grab.pointerId) {
|
|
1689
|
-
detach();
|
|
1690
|
-
onTap();
|
|
1691
|
-
}
|
|
1692
|
-
};
|
|
1693
|
-
const cancelPointer = (event) => {
|
|
1694
|
-
if (event.pointerId === grab.pointerId) cancel();
|
|
1695
|
-
};
|
|
1696
|
-
const anotherPointer = (event) => {
|
|
1697
|
-
if (event.pointerId !== grab.pointerId) cancel();
|
|
1698
|
-
};
|
|
1699
|
-
const timer = setTimeout(() => {
|
|
1700
|
-
detach();
|
|
1701
|
-
onHold();
|
|
1702
|
-
}, delay);
|
|
1703
|
-
document.addEventListener("pointermove", move);
|
|
1704
|
-
document.addEventListener("pointerup", up);
|
|
1705
|
-
document.addEventListener("pointercancel", cancelPointer);
|
|
1706
|
-
document.addEventListener("pointerdown", anotherPointer);
|
|
1707
|
-
return cancel;
|
|
1708
|
-
}
|
|
1709
1987
|
// src/TimeGrid.tsx
|
|
1710
1988
|
const GUTTER_WIDTH$1 = 56;
|
|
1711
1989
|
const HOURS_PER_DAY = 24;
|
|
@@ -3138,16 +3416,24 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
3138
3416
|
}
|
|
3139
3417
|
// src/Calendar.tsx
|
|
3140
3418
|
const EMPTY_EVENTS = [];
|
|
3141
|
-
function expansionRange(mode, date, weekStartsOn, numberOfDays) {
|
|
3419
|
+
function expansionRange(mode, date, weekStartsOn, numberOfDays, numberOfWeeks) {
|
|
3420
|
+
if (mode === "multiweek") {
|
|
3421
|
+
const { period } = (0, _super_calendar_core.buildMultiWeekGrid)(date, {
|
|
3422
|
+
weekStartsOn,
|
|
3423
|
+
numberOfWeeks
|
|
3424
|
+
});
|
|
3425
|
+
return [period.start, (0, date_fns.endOfDay)((0, date_fns.addDays)(period.endExclusive, -1))];
|
|
3426
|
+
}
|
|
3142
3427
|
if (mode === "month") return [(0, date_fns.startOfWeek)((0, date_fns.startOfMonth)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfMonth)(date), { weekStartsOn })];
|
|
3143
3428
|
if (mode === "year") return [(0, date_fns.startOfWeek)((0, date_fns.startOfYear)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfYear)(date), { weekStartsOn })];
|
|
3144
3429
|
if (mode === "schedule") return [(0, date_fns.startOfDay)(date), (0, date_fns.endOfDay)((0, date_fns.addMonths)(date, 3))];
|
|
3145
3430
|
const days = (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays ?? 1);
|
|
3146
3431
|
return [(0, date_fns.startOfDay)(days[0]), (0, date_fns.endOfDay)(days[days.length - 1])];
|
|
3147
3432
|
}
|
|
3148
|
-
function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
3433
|
+
function pageStep(mode, date, direction, weekStartsOn, numberOfDays, numberOfWeeks) {
|
|
3149
3434
|
if (mode === "year") return (0, date_fns.addYears)(date, direction);
|
|
3150
3435
|
if (mode === "month") return (0, date_fns.addMonths)(date, direction);
|
|
3436
|
+
if (mode === "multiweek") return (0, date_fns.addWeeks)(date, direction * numberOfWeeks);
|
|
3151
3437
|
if (mode === "schedule") return (0, date_fns.addDays)(date, direction * 7);
|
|
3152
3438
|
return (0, date_fns.addDays)(date, direction * (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays ?? 1).length);
|
|
3153
3439
|
}
|
|
@@ -3163,13 +3449,13 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
3163
3449
|
* ```
|
|
3164
3450
|
*/
|
|
3165
3451
|
const Calendar = (0, react.forwardRef)(CalendarInner);
|
|
3166
|
-
function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, touchDragDelay, touchDragThreshold, onPressCell, onCreateEvent, renderCreateGhost, onDragStart, onDragEvent, getEventId, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
3452
|
+
function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, numberOfWeeks = 2, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, touchDragDelay, touchDragThreshold, onPressCell, onCreateEvent, renderCreateGhost, onDragStart, onDragEvent, getEventId, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
3167
3453
|
const timeGridRef = (0, react.useRef)(null);
|
|
3168
3454
|
(0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
3169
3455
|
const displayEvents = (0, react.useMemo)(() => {
|
|
3170
3456
|
let out = events ?? EMPTY_EVENTS;
|
|
3171
3457
|
if (out.some((e) => e.recurrence)) {
|
|
3172
|
-
let [start, end] = expansionRange(mode, date, weekStartsOn, numberOfDays);
|
|
3458
|
+
let [start, end] = expansionRange(mode, date, weekStartsOn, numberOfDays, numberOfWeeks);
|
|
3173
3459
|
if (timeZone) {
|
|
3174
3460
|
start = (0, date_fns.addDays)(start, -1);
|
|
3175
3461
|
end = (0, date_fns.addDays)(end, 1);
|
|
@@ -3184,12 +3470,13 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3184
3470
|
date.getTime(),
|
|
3185
3471
|
weekStartsOn,
|
|
3186
3472
|
numberOfDays,
|
|
3473
|
+
numberOfWeeks,
|
|
3187
3474
|
timeZone
|
|
3188
3475
|
]);
|
|
3189
3476
|
const handlePageKeys = (e) => {
|
|
3190
3477
|
if (!onChangeDate) return;
|
|
3191
|
-
if (e.key === "PageDown") onChangeDate(pageStep(mode, date, 1, weekStartsOn, numberOfDays));
|
|
3192
|
-
else if (e.key === "PageUp") onChangeDate(pageStep(mode, date, -1, weekStartsOn, numberOfDays));
|
|
3478
|
+
if (e.key === "PageDown") onChangeDate(pageStep(mode, date, 1, weekStartsOn, numberOfDays, numberOfWeeks));
|
|
3479
|
+
else if (e.key === "PageUp") onChangeDate(pageStep(mode, date, -1, weekStartsOn, numberOfDays, numberOfWeeks));
|
|
3193
3480
|
else return;
|
|
3194
3481
|
e.preventDefault();
|
|
3195
3482
|
};
|
|
@@ -3275,6 +3562,49 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
3275
3562
|
renderEvent: renderMonthEvent,
|
|
3276
3563
|
eventAccessibilityLabel
|
|
3277
3564
|
});
|
|
3565
|
+
else if (mode === "multiweek") view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiWeekView, {
|
|
3566
|
+
date,
|
|
3567
|
+
numberOfWeeks,
|
|
3568
|
+
events: displayEvents,
|
|
3569
|
+
weekStartsOn,
|
|
3570
|
+
hiddenDays,
|
|
3571
|
+
weekdayFormat,
|
|
3572
|
+
highlightWeekends,
|
|
3573
|
+
locale,
|
|
3574
|
+
labels,
|
|
3575
|
+
theme,
|
|
3576
|
+
className,
|
|
3577
|
+
style: height != null ? {
|
|
3578
|
+
height,
|
|
3579
|
+
...style
|
|
3580
|
+
} : style,
|
|
3581
|
+
classNames,
|
|
3582
|
+
styles,
|
|
3583
|
+
maxVisibleEventCount,
|
|
3584
|
+
chipHeight,
|
|
3585
|
+
chipGap,
|
|
3586
|
+
moreLabel,
|
|
3587
|
+
showTitle,
|
|
3588
|
+
fillCellOnSelection,
|
|
3589
|
+
selectedRange,
|
|
3590
|
+
selectedDates,
|
|
3591
|
+
minDate,
|
|
3592
|
+
maxDate,
|
|
3593
|
+
isDateDisabled,
|
|
3594
|
+
keyboardDayNavigation,
|
|
3595
|
+
onPressDay,
|
|
3596
|
+
onPressCell,
|
|
3597
|
+
onCreateEvent,
|
|
3598
|
+
onSelectDrag,
|
|
3599
|
+
onDragEvent,
|
|
3600
|
+
onDragStart,
|
|
3601
|
+
eventStartEditable,
|
|
3602
|
+
eventOverlap,
|
|
3603
|
+
onPressEvent,
|
|
3604
|
+
onPressMore,
|
|
3605
|
+
renderEvent: renderMonthEvent,
|
|
3606
|
+
eventAccessibilityLabel
|
|
3607
|
+
});
|
|
3278
3608
|
else view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimeGrid, {
|
|
3279
3609
|
ref: timeGridRef,
|
|
3280
3610
|
date,
|
|
@@ -4757,6 +5087,7 @@ exports.DatePicker = DatePicker;
|
|
|
4757
5087
|
exports.DateRangePicker = DateRangePicker;
|
|
4758
5088
|
exports.MonthList = MonthList;
|
|
4759
5089
|
exports.MonthView = MonthView;
|
|
5090
|
+
exports.MultiWeekView = MultiWeekView;
|
|
4760
5091
|
exports.ResourceTimeline = ResourceTimeline;
|
|
4761
5092
|
exports.TimeGrid = TimeGrid;
|
|
4762
5093
|
exports.YearView = YearView;
|
|
@@ -4772,6 +5103,12 @@ Object.defineProperty(exports, "buildMonthGrid", {
|
|
|
4772
5103
|
return _super_calendar_core.buildMonthGrid;
|
|
4773
5104
|
}
|
|
4774
5105
|
});
|
|
5106
|
+
Object.defineProperty(exports, "buildMultiWeekGrid", {
|
|
5107
|
+
enumerable: true,
|
|
5108
|
+
get: function() {
|
|
5109
|
+
return _super_calendar_core.buildMultiWeekGrid;
|
|
5110
|
+
}
|
|
5111
|
+
});
|
|
4775
5112
|
exports.darkDomTheme = darkDomTheme;
|
|
4776
5113
|
Object.defineProperty(exports, "daySelectionState", {
|
|
4777
5114
|
enumerable: true,
|