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