@super-calendar/dom 2.7.0 → 2.8.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 +32 -6
- package/dist/index.d.ts +32 -6
- package/dist/index.js +356 -248
- package/dist/index.mjs +352 -250
- package/package.json +2 -2
- package/src/Calendar.tsx +12 -0
- package/src/MonthView.tsx +392 -257
- package/src/ResourceTimeline.tsx +17 -4
- package/src/TimeGrid.tsx +66 -10
- package/src/index.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -414,6 +414,10 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
414
414
|
}
|
|
415
415
|
//#endregion
|
|
416
416
|
//#region src/MonthView.tsx
|
|
417
|
+
const EMPTY_LAYOUT = {
|
|
418
|
+
segments: [],
|
|
419
|
+
laneCount: 0
|
|
420
|
+
};
|
|
417
421
|
const DATE_ROW = 24;
|
|
418
422
|
const CHIP_HEIGHT = 18;
|
|
419
423
|
const CHIP_GAP = 2;
|
|
@@ -592,6 +596,19 @@ function moreButtonDefault(theme) {
|
|
|
592
596
|
}
|
|
593
597
|
};
|
|
594
598
|
}
|
|
599
|
+
function collectRowEvents(week, eventsByDay) {
|
|
600
|
+
const seen = /* @__PURE__ */ new Set();
|
|
601
|
+
const out = [];
|
|
602
|
+
for (const day of week.days) {
|
|
603
|
+
const list = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString());
|
|
604
|
+
if (!list) continue;
|
|
605
|
+
for (const event of list) if (!seen.has(event)) {
|
|
606
|
+
seen.add(event);
|
|
607
|
+
out.push(event);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return out;
|
|
611
|
+
}
|
|
595
612
|
/**
|
|
596
613
|
* A single static month grid, rendered with plain DOM elements.
|
|
597
614
|
*
|
|
@@ -666,6 +683,11 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
666
683
|
isDateDisabled,
|
|
667
684
|
locale
|
|
668
685
|
]);
|
|
686
|
+
const weekLayouts = (0, react.useMemo)(() => eventsMode ? weeks.map((week) => (0, _super_calendar_core.layoutMonthWeek)(week.days.map((d) => d.date), collectRowEvents(week, eventsByDay))) : [], [
|
|
687
|
+
eventsMode,
|
|
688
|
+
weeks,
|
|
689
|
+
eventsByDay
|
|
690
|
+
]);
|
|
669
691
|
const initialFocus = (0, react.useMemo)(() => {
|
|
670
692
|
const inMonth = (d) => !!d && (0, date_fns.isSameMonth)(d, date);
|
|
671
693
|
if (inMonth(selectedRange?.start)) return (0, date_fns.startOfDay)(selectedRange.start);
|
|
@@ -783,234 +805,281 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
783
805
|
"aria-label": (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0),
|
|
784
806
|
onKeyDown: dayRoving ? onKeyDown : void 0,
|
|
785
807
|
...slot("grid"),
|
|
786
|
-
children: weeks.map((week) =>
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
const
|
|
795
|
-
if (
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
const
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
-
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight));
|
|
824
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
808
|
+
children: weeks.map((week, weekIndex) => {
|
|
809
|
+
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
810
|
+
const visibleLanes = rowLayout.laneCount > maxVisibleEventCount ? Math.max(maxVisibleEventCount - 1, 1) : rowLayout.laneCount;
|
|
811
|
+
const cols = week.days.length;
|
|
812
|
+
let firstVisCol = 0;
|
|
813
|
+
let lastVisCol = cols - 1;
|
|
814
|
+
if (eventsMode && !showAdjacentMonths) {
|
|
815
|
+
const first = week.days.findIndex((d) => d.isCurrentMonth);
|
|
816
|
+
const lastFromEnd = [...week.days].reverse().findIndex((d) => d.isCurrentMonth);
|
|
817
|
+
if (first !== -1) {
|
|
818
|
+
firstVisCol = first;
|
|
819
|
+
lastVisCol = cols - 1 - lastFromEnd;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
const barSegs = rowLayout.segments.filter((s) => s.lane < visibleLanes).map((s) => {
|
|
823
|
+
const startCol = Math.max(s.startCol, firstVisCol);
|
|
824
|
+
const endCol = Math.min(s.endCol, lastVisCol);
|
|
825
|
+
return {
|
|
826
|
+
seg: s,
|
|
827
|
+
startCol,
|
|
828
|
+
endCol,
|
|
829
|
+
continuesBefore: s.continuesBefore || startCol > s.startCol,
|
|
830
|
+
continuesAfter: s.continuesAfter || endCol < s.endCol
|
|
831
|
+
};
|
|
832
|
+
}).filter((b) => b.startCol <= b.endCol);
|
|
833
|
+
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
834
|
+
const barChip = slot("chip", chipDefault(theme));
|
|
835
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
836
|
+
role: "row",
|
|
837
|
+
...slot("week", { base: {
|
|
838
|
+
display: "grid",
|
|
839
|
+
gridTemplateColumns: "repeat(7, minmax(0, 1fr))"
|
|
840
|
+
} }),
|
|
841
|
+
children: week.days.map((day, dayCol) => {
|
|
842
|
+
const hidden = !showAdjacentMonths && !day.isCurrentMonth;
|
|
843
|
+
const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
|
|
844
|
+
if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
825
845
|
role: "gridcell",
|
|
826
|
-
"
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
846
|
+
"aria-hidden": true,
|
|
847
|
+
style: { height: cellHeight }
|
|
848
|
+
}, day.id);
|
|
849
|
+
const band = rangeBandDefault(day, theme, fillCellOnSelection);
|
|
850
|
+
const label = (0, date_fns.format)(day.date, "EEEE, d MMMM yyyy", locale ? { locale } : void 0);
|
|
851
|
+
const dayTime = (0, date_fns.startOfDay)(day.date).getTime();
|
|
852
|
+
const inCreate = creating != null && dayTime >= Math.min(creating.anchor, creating.hover) && dayTime <= Math.max(creating.anchor, creating.hover);
|
|
853
|
+
const dayData = dataState({
|
|
854
|
+
"data-today": day.isToday,
|
|
855
|
+
"data-selected": day.isSelected,
|
|
856
|
+
"data-range": day.isInRange,
|
|
857
|
+
"data-weekend": day.isWeekend,
|
|
858
|
+
"data-outside": !day.isCurrentMonth,
|
|
859
|
+
"data-disabled": day.isDisabled,
|
|
860
|
+
"data-creating": inCreate
|
|
861
|
+
});
|
|
862
|
+
if (eventsMode) {
|
|
863
|
+
const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString()) ?? [];
|
|
864
|
+
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event);
|
|
865
|
+
const dayLabel = (0, date_fns.format)(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
866
|
+
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight));
|
|
867
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
868
|
+
role: "gridcell",
|
|
869
|
+
"data-day": day.id,
|
|
870
|
+
...dayData,
|
|
871
|
+
tabIndex: keyboardDayNavigation ? day.id === focusKey ? 0 : -1 : void 0,
|
|
872
|
+
"aria-disabled": day.isDisabled || void 0,
|
|
873
|
+
"aria-label": label,
|
|
874
|
+
...dayCellProps,
|
|
875
|
+
style: onCreateEvent ? {
|
|
876
|
+
...dayCellProps.style,
|
|
877
|
+
touchAction: "none"
|
|
878
|
+
} : dayCellProps.style,
|
|
879
|
+
onPointerDown: onCreateEvent && !day.isDisabled ? (e) => {
|
|
880
|
+
if (e.button === 0) beginCreate(day.date);
|
|
881
|
+
} : void 0,
|
|
882
|
+
onPointerEnter: onCreateEvent ? () => extendCreate(day.date) : void 0,
|
|
883
|
+
onClick: day.isDisabled ? void 0 : () => {
|
|
884
|
+
if (suppressClickRef.current) {
|
|
885
|
+
suppressClickRef.current = false;
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
851
888
|
onPressDay?.(day.date);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
875
|
-
type: "button",
|
|
876
|
-
onClick: (e) => {
|
|
877
|
-
e.stopPropagation();
|
|
878
|
-
onPress();
|
|
879
|
-
},
|
|
880
|
-
...slot("chipButton", chipButtonDefault),
|
|
881
|
-
title: event.title,
|
|
882
|
-
"aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(event, {
|
|
883
|
-
mode: "month",
|
|
884
|
-
isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
|
|
885
|
-
ampm: false
|
|
886
|
-
}) : `${event.title}, ${dayLabel}`,
|
|
887
|
-
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
888
|
-
event,
|
|
889
|
-
onPress
|
|
890
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
891
|
-
...slot("chip", chipDefault(theme)),
|
|
892
|
-
children: event.title
|
|
893
|
-
})
|
|
894
|
-
}, `${event.start.toISOString()}:${event.title}`);
|
|
895
|
-
}),
|
|
896
|
-
overflow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
889
|
+
},
|
|
890
|
+
onKeyDown: keyboardDayNavigation && !day.isDisabled ? (e) => {
|
|
891
|
+
if (e.target !== e.currentTarget) return;
|
|
892
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
893
|
+
e.preventDefault();
|
|
894
|
+
onPressDay?.(day.date);
|
|
895
|
+
}
|
|
896
|
+
} : void 0,
|
|
897
|
+
children: [
|
|
898
|
+
band ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
899
|
+
"data-band": true,
|
|
900
|
+
"aria-hidden": true,
|
|
901
|
+
...slot("rangeBand", band)
|
|
902
|
+
}) : null,
|
|
903
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
904
|
+
...dayData,
|
|
905
|
+
...slot("dayBadge", compactBadgeDefault(day, theme)),
|
|
906
|
+
children: day.label
|
|
907
|
+
}),
|
|
908
|
+
barSegs.filter((b) => b.startCol === dayCol).map((b) => {
|
|
909
|
+
const span = b.endCol - b.startCol + 1;
|
|
910
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
897
911
|
type: "button",
|
|
898
|
-
onPointerDown: onPressMore ? void 0 : (e) => e.stopPropagation(),
|
|
899
912
|
onClick: (e) => {
|
|
900
913
|
e.stopPropagation();
|
|
901
|
-
|
|
902
|
-
else {
|
|
903
|
-
moreTriggerRef.current = e.currentTarget;
|
|
904
|
-
setMoreOpenFor((open) => open === day.id ? null : day.id);
|
|
905
|
-
}
|
|
914
|
+
onPressEvent?.(b.seg.event);
|
|
906
915
|
},
|
|
907
|
-
...
|
|
908
|
-
|
|
909
|
-
"aria-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
if (e.shiftKey && document.activeElement === first) {
|
|
924
|
-
e.preventDefault();
|
|
925
|
-
last.focus();
|
|
926
|
-
} else if (!e.shiftKey && document.activeElement === last) {
|
|
927
|
-
e.preventDefault();
|
|
928
|
-
first.focus();
|
|
929
|
-
}
|
|
916
|
+
...barChipButton,
|
|
917
|
+
title: b.seg.event.title,
|
|
918
|
+
"aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(b.seg.event, {
|
|
919
|
+
mode: "month",
|
|
920
|
+
isAllDay: (0, _super_calendar_core.isAllDayEvent)(b.seg.event),
|
|
921
|
+
ampm: false
|
|
922
|
+
}) : `${b.seg.event.title}, ${dayLabel}`,
|
|
923
|
+
style: {
|
|
924
|
+
...barChipButton.style,
|
|
925
|
+
position: "absolute",
|
|
926
|
+
left: 2,
|
|
927
|
+
width: `calc(${span * 100}% - 4px)`,
|
|
928
|
+
top: 30 + b.seg.lane * 20,
|
|
929
|
+
height: CHIP_HEIGHT,
|
|
930
|
+
pointerEvents: isCreating ? "none" : "auto",
|
|
931
|
+
zIndex: 2
|
|
930
932
|
},
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
right: 2,
|
|
937
|
-
zIndex: 10,
|
|
938
|
-
display: "flex",
|
|
939
|
-
flexDirection: "column",
|
|
940
|
-
gap: 2,
|
|
941
|
-
maxHeight: 240,
|
|
942
|
-
overflowY: "auto"
|
|
943
|
-
},
|
|
944
|
-
themed: {
|
|
945
|
-
background: theme.surface,
|
|
946
|
-
border: `1px solid ${theme.gridLine}`,
|
|
947
|
-
borderRadius: 8,
|
|
948
|
-
padding: 6,
|
|
949
|
-
boxShadow: "0 4px 16px rgba(0,0,0,0.12)"
|
|
950
|
-
}
|
|
951
|
-
}),
|
|
952
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
933
|
+
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
934
|
+
event: b.seg.event,
|
|
935
|
+
onPress: () => onPressEvent?.(b.seg.event)
|
|
936
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
937
|
+
...barChip,
|
|
953
938
|
style: {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
939
|
+
...barChip.style,
|
|
940
|
+
...b.continuesBefore ? {
|
|
941
|
+
borderTopLeftRadius: 0,
|
|
942
|
+
borderBottomLeftRadius: 0
|
|
943
|
+
} : null,
|
|
944
|
+
...b.continuesAfter ? {
|
|
945
|
+
borderTopRightRadius: 0,
|
|
946
|
+
borderBottomRightRadius: 0
|
|
947
|
+
} : null
|
|
957
948
|
},
|
|
958
|
-
children:
|
|
959
|
-
})
|
|
949
|
+
children: b.seg.event.title
|
|
950
|
+
})
|
|
951
|
+
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`);
|
|
952
|
+
}),
|
|
953
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
954
|
+
...slot("events", { base: {
|
|
955
|
+
display: "flex",
|
|
956
|
+
flexDirection: "column",
|
|
957
|
+
gap: CHIP_GAP
|
|
958
|
+
} }),
|
|
959
|
+
children: [
|
|
960
|
+
Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
961
|
+
"aria-hidden": true,
|
|
962
|
+
style: { height: CHIP_HEIGHT }
|
|
963
|
+
}, `lane-${i}`)),
|
|
964
|
+
hiddenEvents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
960
965
|
type: "button",
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
966
|
+
onPointerDown: onPressMore ? void 0 : (e) => e.stopPropagation(),
|
|
967
|
+
onClick: (e) => {
|
|
968
|
+
e.stopPropagation();
|
|
969
|
+
if (onPressMore) onPressMore(hiddenEvents, day.date);
|
|
970
|
+
else {
|
|
971
|
+
moreTriggerRef.current = e.currentTarget;
|
|
972
|
+
setMoreOpenFor((open) => open === day.id ? null : day.id);
|
|
973
|
+
}
|
|
964
974
|
},
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
975
|
+
...slot("more", moreButtonDefault(theme)),
|
|
976
|
+
"aria-label": `${hiddenEvents.length} more events, ${dayLabel}`,
|
|
977
|
+
"aria-expanded": onPressMore ? void 0 : moreOpenFor === day.id,
|
|
978
|
+
children: moreLabel.replace("{moreCount}", String(hiddenEvents.length))
|
|
979
|
+
}) : null,
|
|
980
|
+
moreOpenFor === day.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
981
|
+
ref: morePopoverRef,
|
|
982
|
+
role: "dialog",
|
|
983
|
+
"aria-label": dayLabel,
|
|
984
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
985
|
+
onKeyDown: (e) => {
|
|
986
|
+
if (e.key !== "Tab") return;
|
|
987
|
+
const buttons = morePopoverRef.current?.querySelectorAll("button");
|
|
988
|
+
if (!buttons?.length) return;
|
|
989
|
+
const first = buttons[0];
|
|
990
|
+
const last = buttons[buttons.length - 1];
|
|
991
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
992
|
+
e.preventDefault();
|
|
993
|
+
last.focus();
|
|
994
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
995
|
+
e.preventDefault();
|
|
996
|
+
first.focus();
|
|
997
|
+
}
|
|
974
998
|
},
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
999
|
+
...slot("morePopover", {
|
|
1000
|
+
base: {
|
|
1001
|
+
position: "absolute",
|
|
1002
|
+
top: 2,
|
|
1003
|
+
left: 2,
|
|
1004
|
+
right: 2,
|
|
1005
|
+
zIndex: 10,
|
|
1006
|
+
display: "flex",
|
|
1007
|
+
flexDirection: "column",
|
|
1008
|
+
gap: 2,
|
|
1009
|
+
maxHeight: 240,
|
|
1010
|
+
overflowY: "auto"
|
|
1011
|
+
},
|
|
1012
|
+
themed: {
|
|
1013
|
+
background: theme.surface,
|
|
1014
|
+
border: `1px solid ${theme.gridLine}`,
|
|
1015
|
+
borderRadius: 8,
|
|
1016
|
+
padding: 6,
|
|
1017
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.12)"
|
|
1018
|
+
}
|
|
1019
|
+
}),
|
|
1020
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1021
|
+
style: {
|
|
1022
|
+
fontSize: 11,
|
|
1023
|
+
fontWeight: 600,
|
|
1024
|
+
color: theme.textMuted
|
|
1025
|
+
},
|
|
1026
|
+
children: dayLabel
|
|
1027
|
+
}), dayEvents.map((event, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1028
|
+
type: "button",
|
|
1029
|
+
onClick: () => {
|
|
1030
|
+
setMoreOpenFor(null);
|
|
1031
|
+
onPressEvent?.(event);
|
|
1032
|
+
},
|
|
1033
|
+
style: {
|
|
1034
|
+
display: "block",
|
|
1035
|
+
width: "100%",
|
|
1036
|
+
border: "none",
|
|
1037
|
+
background: "transparent",
|
|
1038
|
+
padding: 0,
|
|
1039
|
+
font: "inherit",
|
|
1040
|
+
textAlign: "left",
|
|
1041
|
+
cursor: "pointer"
|
|
1042
|
+
},
|
|
1043
|
+
children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
|
|
1044
|
+
event,
|
|
1045
|
+
onPress: () => onPressEvent?.(event)
|
|
1046
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1047
|
+
...slot("chip", chipDefault(theme)),
|
|
1048
|
+
children: event.title
|
|
1049
|
+
})
|
|
1050
|
+
}, i))]
|
|
1051
|
+
}) : null
|
|
1052
|
+
]
|
|
1053
|
+
})
|
|
1054
|
+
]
|
|
1055
|
+
}, day.id);
|
|
1056
|
+
}
|
|
1057
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1058
|
+
type: "button",
|
|
1059
|
+
role: "gridcell",
|
|
1060
|
+
"data-day": day.id,
|
|
1007
1061
|
...dayData,
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1062
|
+
tabIndex: day.id === focusKey ? 0 : -1,
|
|
1063
|
+
"aria-disabled": day.isDisabled || void 0,
|
|
1064
|
+
"aria-label": label,
|
|
1065
|
+
"aria-pressed": day.isSelected || day.isInRange,
|
|
1066
|
+
...slot("day", dayCellDefault(day, theme)),
|
|
1067
|
+
onClick: day.isDisabled ? void 0 : () => onPressDay?.(day.date),
|
|
1068
|
+
onMouseEnter: day.isDisabled ? void 0 : () => setHoveredKey(day.id),
|
|
1069
|
+
onMouseLeave: () => setHoveredKey((k) => k === day.id ? null : k),
|
|
1070
|
+
children: [band ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1071
|
+
"data-band": true,
|
|
1072
|
+
"aria-hidden": true,
|
|
1073
|
+
...slot("rangeBand", band)
|
|
1074
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1075
|
+
...dayData,
|
|
1076
|
+
...slot("dayBadge", badgeDefault(day, theme, hoveredKey === day.id)),
|
|
1077
|
+
children: day.label
|
|
1078
|
+
})]
|
|
1079
|
+
}, day.id);
|
|
1080
|
+
})
|
|
1081
|
+
}, week.id);
|
|
1082
|
+
})
|
|
1014
1083
|
})
|
|
1015
1084
|
]
|
|
1016
1085
|
});
|
|
@@ -1115,7 +1184,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
1115
1184
|
* <TimeGrid mode="week" date={new Date()} events={events} />
|
|
1116
1185
|
* ```
|
|
1117
1186
|
*/
|
|
1118
|
-
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1187
|
+
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, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1119
1188
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1120
1189
|
const slot = createSlots({
|
|
1121
1190
|
classNames,
|
|
@@ -1184,7 +1253,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1184
1253
|
const onChangeDateRef = (0, react.useRef)(onChangeDate);
|
|
1185
1254
|
onChangeDateRef.current = onChangeDate;
|
|
1186
1255
|
const onDragEventRef = (0, react.useRef)(onDragEvent);
|
|
1187
|
-
onDragEventRef.current = onDragEvent;
|
|
1256
|
+
onDragEventRef.current = onDragEvent && eventOverlap === false ? (event, start, end) => (0, _super_calendar_core.overlapsOtherEvents)(events, event, start, end) ? false : onDragEvent(event, start, end) : onDragEvent;
|
|
1188
1257
|
const allDayByDay = (0, react.useMemo)(() => days.map((day) => {
|
|
1189
1258
|
const dayStart = (0, date_fns.startOfDay)(day);
|
|
1190
1259
|
const dayEnd = (0, date_fns.addDays)(dayStart, 1);
|
|
@@ -1312,13 +1381,23 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1312
1381
|
}
|
|
1313
1382
|
}
|
|
1314
1383
|
}
|
|
1315
|
-
} else {
|
|
1384
|
+
} else if (d.kind === "resize") {
|
|
1316
1385
|
const durationHours = clamp$1(snap(dragOrigin.current.durationHours + dHours), snapHours, Math.max(snapHours, windowEnd - d.startHours));
|
|
1317
1386
|
applyDrag({
|
|
1318
1387
|
...d,
|
|
1319
1388
|
durationHours,
|
|
1320
1389
|
moved: true
|
|
1321
1390
|
});
|
|
1391
|
+
} else {
|
|
1392
|
+
const o = dragOrigin.current;
|
|
1393
|
+
const end = o.startHours + o.durationHours;
|
|
1394
|
+
const startHours = clamp$1(snap(o.startHours + dHours), windowStart, end - snapHours);
|
|
1395
|
+
applyDrag({
|
|
1396
|
+
...d,
|
|
1397
|
+
startHours,
|
|
1398
|
+
durationHours: end - startHours,
|
|
1399
|
+
moved: true
|
|
1400
|
+
});
|
|
1322
1401
|
}
|
|
1323
1402
|
};
|
|
1324
1403
|
const endDrag = (e) => {
|
|
@@ -1860,7 +1939,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1860
1939
|
ampm,
|
|
1861
1940
|
onPress
|
|
1862
1941
|
};
|
|
1863
|
-
const
|
|
1942
|
+
const editable = !!onDragEvent && pe.event.draggable !== false;
|
|
1943
|
+
const canMove = editable && (pe.event.startEditable ?? eventStartEditable);
|
|
1944
|
+
const canResize = editable && (pe.event.durationEditable ?? eventDurationEditable);
|
|
1864
1945
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1865
1946
|
role: "button",
|
|
1866
1947
|
tabIndex: 0,
|
|
@@ -1884,8 +1965,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1884
1965
|
}
|
|
1885
1966
|
if (keyboardEventNavigation) onEventKeyDown(key, e);
|
|
1886
1967
|
},
|
|
1887
|
-
onPointerDown:
|
|
1888
|
-
onClick:
|
|
1968
|
+
onPointerDown: canMove ? (e) => beginDrag(e, pe.event, key, "move", pe.startHours, pe.durationHours, dayIndex, onPress) : void 0,
|
|
1969
|
+
onClick: canMove ? void 0 : onPress,
|
|
1889
1970
|
...dataState({ "data-dragging": !!active }),
|
|
1890
1971
|
...slot("event", { base: {
|
|
1891
1972
|
position: "absolute",
|
|
@@ -1893,31 +1974,49 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1893
1974
|
height: boxHeight,
|
|
1894
1975
|
left: `calc(${pe.column * widthPct}% + 1px)`,
|
|
1895
1976
|
width: `calc(${widthPct}% - 2px)`,
|
|
1896
|
-
cursor:
|
|
1897
|
-
touchAction:
|
|
1977
|
+
cursor: canMove ? "grab" : "pointer",
|
|
1978
|
+
touchAction: canMove ? "none" : "auto",
|
|
1898
1979
|
zIndex: active ? 3 : 1,
|
|
1899
1980
|
opacity: active ? .85 : 1,
|
|
1900
1981
|
...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
|
|
1901
1982
|
} }),
|
|
1902
|
-
children: [
|
|
1903
|
-
...args,
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1983
|
+
children: [
|
|
1984
|
+
Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
|
|
1985
|
+
...args,
|
|
1986
|
+
theme,
|
|
1987
|
+
boxProps: slot("eventBox")
|
|
1988
|
+
}),
|
|
1989
|
+
canResize && !pe.continuesBefore ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1990
|
+
onPointerDown: (e) => {
|
|
1991
|
+
e.stopPropagation();
|
|
1992
|
+
beginDrag(e, pe.event, key, "resize-start", pe.startHours, pe.durationHours, dayIndex);
|
|
1993
|
+
},
|
|
1994
|
+
style: {
|
|
1995
|
+
position: "absolute",
|
|
1996
|
+
left: 0,
|
|
1997
|
+
right: 0,
|
|
1998
|
+
top: 0,
|
|
1999
|
+
height: 8,
|
|
2000
|
+
cursor: "ns-resize",
|
|
2001
|
+
touchAction: "none"
|
|
2002
|
+
}
|
|
2003
|
+
}) : null,
|
|
2004
|
+
canResize ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2005
|
+
onPointerDown: (e) => {
|
|
2006
|
+
e.stopPropagation();
|
|
2007
|
+
beginDrag(e, pe.event, key, "resize", pe.startHours, pe.durationHours, dayIndex);
|
|
2008
|
+
},
|
|
2009
|
+
style: {
|
|
2010
|
+
position: "absolute",
|
|
2011
|
+
left: 0,
|
|
2012
|
+
right: 0,
|
|
2013
|
+
bottom: 0,
|
|
2014
|
+
height: 8,
|
|
2015
|
+
cursor: "ns-resize",
|
|
2016
|
+
touchAction: "none"
|
|
2017
|
+
}
|
|
2018
|
+
}) : null
|
|
2019
|
+
]
|
|
1921
2020
|
}, idx);
|
|
1922
2021
|
}),
|
|
1923
2022
|
showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -2030,7 +2129,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2030
2129
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
2031
2130
|
* ```
|
|
2032
2131
|
*/
|
|
2033
|
-
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2132
|
+
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, eventStartEditable, eventDurationEditable, eventOverlap, 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 }) {
|
|
2034
2133
|
const displayEvents = (0, react.useMemo)(() => {
|
|
2035
2134
|
let out = events ?? EMPTY_EVENTS;
|
|
2036
2135
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -2152,6 +2251,9 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2152
2251
|
showNowIndicator,
|
|
2153
2252
|
showAllDayEventCell,
|
|
2154
2253
|
highlightWeekends,
|
|
2254
|
+
eventStartEditable,
|
|
2255
|
+
eventDurationEditable,
|
|
2256
|
+
eventOverlap,
|
|
2155
2257
|
dragStepMinutes,
|
|
2156
2258
|
onPressEvent,
|
|
2157
2259
|
onPressCell,
|
|
@@ -2593,7 +2695,7 @@ function DefaultBar({ event, height, boxProps, theme }) {
|
|
|
2593
2695
|
* />
|
|
2594
2696
|
* ```
|
|
2595
2697
|
*/
|
|
2596
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone, className, style, classNames, styles }) {
|
|
2698
|
+
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, renderResourceHeader, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone, className, style, classNames, styles }) {
|
|
2597
2699
|
const resources = (0, react.useMemo)(() => {
|
|
2598
2700
|
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
2599
2701
|
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
@@ -2842,7 +2944,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
2842
2944
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...slot("corner", { base: {
|
|
2843
2945
|
width: GUTTER_WIDTH,
|
|
2844
2946
|
flex: "none"
|
|
2845
|
-
} }) }), resources.map((resource) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2947
|
+
} }) }), resources.map((resource, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2846
2948
|
...slot("resourceLabel", {
|
|
2847
2949
|
base: {
|
|
2848
2950
|
flex: 1,
|
|
@@ -2860,7 +2962,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
2860
2962
|
borderLeft: `1px solid ${theme.gridLine}`
|
|
2861
2963
|
}
|
|
2862
2964
|
}),
|
|
2863
|
-
children: resource.title ?? resource.id
|
|
2965
|
+
children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
|
|
2864
2966
|
}, resource.id))]
|
|
2865
2967
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2866
2968
|
style: { display: "flex" },
|
|
@@ -3089,7 +3191,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3089
3191
|
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
3090
3192
|
}, h))
|
|
3091
3193
|
})]
|
|
3092
|
-
}), resources.map((resource) => {
|
|
3194
|
+
}), resources.map((resource, index) => {
|
|
3093
3195
|
const positioned = byResource.get(resource.id) ?? [];
|
|
3094
3196
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3095
3197
|
...slot("row", {
|
|
@@ -3119,7 +3221,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3119
3221
|
borderRight: `1px solid ${theme.gridLine}`
|
|
3120
3222
|
}
|
|
3121
3223
|
}),
|
|
3122
|
-
children: resource.title ?? resource.id
|
|
3224
|
+
children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
|
|
3123
3225
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3124
3226
|
"data-resource-id": resource.id,
|
|
3125
3227
|
...trackInteractionProps(resource),
|
|
@@ -3347,6 +3449,12 @@ Object.defineProperty(exports, "layoutDayEvents", {
|
|
|
3347
3449
|
return _super_calendar_core.layoutDayEvents;
|
|
3348
3450
|
}
|
|
3349
3451
|
});
|
|
3452
|
+
Object.defineProperty(exports, "layoutMonthWeek", {
|
|
3453
|
+
enumerable: true,
|
|
3454
|
+
get: function() {
|
|
3455
|
+
return _super_calendar_core.layoutMonthWeek;
|
|
3456
|
+
}
|
|
3457
|
+
});
|
|
3350
3458
|
exports.mergeDomTheme = mergeDomTheme;
|
|
3351
3459
|
Object.defineProperty(exports, "nextDateRange", {
|
|
3352
3460
|
enumerable: true,
|