@super-calendar/dom 2.6.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.js CHANGED
@@ -112,7 +112,7 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
112
112
  });
113
113
  const Renderer = renderEvent;
114
114
  const rows = (0, react.useMemo)(() => {
115
- const sorted = [...events].sort((a, b) => a.start.getTime() - b.start.getTime());
115
+ const sorted = events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
116
116
  const out = [];
117
117
  let currentDay = null;
118
118
  sorted.forEach((event, index) => {
@@ -241,19 +241,20 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
241
241
  * highlighted and a dot under days that hold events. It's the view `Calendar`
242
242
  * renders for `mode="year"`.
243
243
  */
244
- function YearView({ date, events, weekStartsOn = 0, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
244
+ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
245
245
  const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
246
246
  const slot = createSlots({
247
247
  classNames,
248
248
  styles
249
249
  });
250
250
  const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
251
- const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.getWeekDays)(date, weekStartsOn).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
251
+ const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
252
252
  date,
253
253
  weekStartsOn,
254
- locale
254
+ locale,
255
+ hiddenDays
255
256
  ]);
256
- const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events).keys() : []), [events]);
257
+ const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events.filter((e) => !(0, _super_calendar_core.isBackgroundEvent)(e))).keys() : []), [events]);
257
258
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
258
259
  className,
259
260
  style: {
@@ -268,7 +269,7 @@ function YearView({ date, events, weekStartsOn = 0, locale, activeDate, minMonth
268
269
  gridTemplateColumns: `repeat(auto-fill, minmax(${minMonthWidth}px, 1fr))`
269
270
  } }),
270
271
  children: months.map((month) => {
271
- const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn);
272
+ const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn, { hiddenDays });
272
273
  const monthLabel = (0, date_fns.format)(month, "MMMM yyyy", { locale });
273
274
  const titleContent = (0, date_fns.format)(month, "MMMM", { locale });
274
275
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -413,6 +414,10 @@ function YearView({ date, events, weekStartsOn = 0, locale, activeDate, minMonth
413
414
  }
414
415
  //#endregion
415
416
  //#region src/MonthView.tsx
417
+ const EMPTY_LAYOUT = {
418
+ segments: [],
419
+ laneCount: 0
420
+ };
416
421
  const DATE_ROW = 24;
417
422
  const CHIP_HEIGHT = 18;
418
423
  const CHIP_GAP = 2;
@@ -591,6 +596,19 @@ function moreButtonDefault(theme) {
591
596
  }
592
597
  };
593
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
+ }
594
612
  /**
595
613
  * A single static month grid, rendered with plain DOM elements.
596
614
  *
@@ -599,7 +617,7 @@ function moreButtonDefault(theme) {
599
617
  * <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
600
618
  * ```
601
619
  */
602
- function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onCreateEvent, keyboardDayNavigation = false, className, style, classNames, styles }) {
620
+ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onCreateEvent, keyboardDayNavigation = false, className, style, classNames, styles }) {
603
621
  const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
604
622
  const slot = createSlots({
605
623
  classNames,
@@ -609,14 +627,44 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
609
627
  const dayRoving = !eventsMode || keyboardDayNavigation;
610
628
  const eventsByDay = (0, react.useMemo)(() => {
611
629
  if (eventsByDayProp) return eventsByDayProp;
612
- const map = (0, _super_calendar_core.groupEventsByDay)(events ?? []);
630
+ const map = (0, _super_calendar_core.groupEventsByDay)((events ?? []).filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
613
631
  for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
614
632
  return map;
615
633
  }, [eventsByDayProp, events]);
616
634
  const Chip = renderEvent;
635
+ const [moreOpenFor, setMoreOpenFor] = (0, react.useState)(null);
636
+ const morePopoverRef = (0, react.useRef)(null);
637
+ const moreTriggerRef = (0, react.useRef)(null);
638
+ (0, react.useEffect)(() => {
639
+ if (moreOpenFor) {
640
+ morePopoverRef.current?.querySelector("button")?.focus();
641
+ return;
642
+ }
643
+ moreTriggerRef.current?.focus();
644
+ moreTriggerRef.current = null;
645
+ }, [moreOpenFor]);
646
+ (0, react.useEffect)(() => {
647
+ if (!moreOpenFor) return;
648
+ const onDocPointerDown = (e) => {
649
+ if (!morePopoverRef.current?.contains(e.target)) {
650
+ moreTriggerRef.current = null;
651
+ setMoreOpenFor(null);
652
+ }
653
+ };
654
+ const onKey = (e) => {
655
+ if (e.key === "Escape") setMoreOpenFor(null);
656
+ };
657
+ document.addEventListener("pointerdown", onDocPointerDown);
658
+ document.addEventListener("keydown", onKey);
659
+ return () => {
660
+ document.removeEventListener("pointerdown", onDocPointerDown);
661
+ document.removeEventListener("keydown", onKey);
662
+ };
663
+ }, [moreOpenFor]);
617
664
  const eventRowHeight = 32 + maxVisibleEventCount * 20;
618
665
  const { weeks, weekdays } = (0, react.useMemo)(() => (0, _super_calendar_core.buildMonthGrid)(date, {
619
666
  weekStartsOn,
667
+ hiddenDays,
620
668
  weekdayFormat,
621
669
  selectedRange,
622
670
  selectedDates,
@@ -635,6 +683,11 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
635
683
  isDateDisabled,
636
684
  locale
637
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
+ ]);
638
691
  const initialFocus = (0, react.useMemo)(() => {
639
692
  const inMonth = (d) => !!d && (0, date_fns.isSameMonth)(d, date);
640
693
  if (inMonth(selectedRange?.start)) return (0, date_fns.startOfDay)(selectedRange.start);
@@ -752,153 +805,281 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
752
805
  "aria-label": (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0),
753
806
  onKeyDown: dayRoving ? onKeyDown : void 0,
754
807
  ...slot("grid"),
755
- children: weeks.map((week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
756
- role: "row",
757
- ...slot("week", { base: {
758
- display: "grid",
759
- gridTemplateColumns: "repeat(7, minmax(0, 1fr))"
760
- } }),
761
- children: week.days.map((day) => {
762
- const hidden = !showAdjacentMonths && !day.isCurrentMonth;
763
- const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
764
- if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
765
- role: "gridcell",
766
- "aria-hidden": true,
767
- style: { height: cellHeight }
768
- }, day.id);
769
- const band = rangeBandDefault(day, theme, fillCellOnSelection);
770
- const label = (0, date_fns.format)(day.date, "EEEE, d MMMM yyyy", locale ? { locale } : void 0);
771
- const dayTime = (0, date_fns.startOfDay)(day.date).getTime();
772
- const inCreate = creating != null && dayTime >= Math.min(creating.anchor, creating.hover) && dayTime <= Math.max(creating.anchor, creating.hover);
773
- const dayData = dataState({
774
- "data-today": day.isToday,
775
- "data-selected": day.isSelected,
776
- "data-range": day.isInRange,
777
- "data-weekend": day.isWeekend,
778
- "data-outside": !day.isCurrentMonth,
779
- "data-disabled": day.isDisabled,
780
- "data-creating": inCreate
781
- });
782
- if (eventsMode) {
783
- const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString()) ?? [];
784
- const visible = (0, _super_calendar_core.monthVisibleCount)(dayEvents.length, {
785
- full: maxVisibleEventCount,
786
- withMore: Math.max(maxVisibleEventCount - 1, 1)
787
- });
788
- const shown = dayEvents.slice(0, visible);
789
- const rest = dayEvents.slice(visible);
790
- const overflow = rest.length > 0;
791
- const dayLabel = (0, date_fns.format)(day.date, "d MMMM", locale ? { locale } : void 0);
792
- const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight));
793
- 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", {
794
845
  role: "gridcell",
795
- "data-day": day.id,
796
- ...dayData,
797
- tabIndex: keyboardDayNavigation ? day.id === focusKey ? 0 : -1 : void 0,
798
- "aria-disabled": day.isDisabled || void 0,
799
- "aria-label": label,
800
- ...dayCellProps,
801
- style: onCreateEvent ? {
802
- ...dayCellProps.style,
803
- touchAction: "none"
804
- } : dayCellProps.style,
805
- onPointerDown: onCreateEvent && !day.isDisabled ? (e) => {
806
- if (e.button === 0) beginCreate(day.date);
807
- } : void 0,
808
- onPointerEnter: onCreateEvent ? () => extendCreate(day.date) : void 0,
809
- onClick: day.isDisabled ? void 0 : () => {
810
- if (suppressClickRef.current) {
811
- suppressClickRef.current = false;
812
- return;
813
- }
814
- onPressDay?.(day.date);
815
- },
816
- onKeyDown: keyboardDayNavigation && !day.isDisabled ? (e) => {
817
- if (e.target !== e.currentTarget) return;
818
- if (e.key === "Enter" || e.key === " ") {
819
- e.preventDefault();
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
+ }
820
888
  onPressDay?.(day.date);
821
- }
822
- } : void 0,
823
- children: [
824
- band ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
825
- "data-band": true,
826
- "aria-hidden": true,
827
- ...slot("rangeBand", band)
828
- }) : null,
829
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
830
- ...dayData,
831
- ...slot("dayBadge", compactBadgeDefault(day, theme)),
832
- children: day.label
833
- }),
834
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
835
- ...slot("events", { base: {
836
- display: "flex",
837
- flexDirection: "column",
838
- gap: CHIP_GAP
839
- } }),
840
- children: [shown.map((event) => {
841
- const onPress = () => onPressEvent?.(event);
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;
842
910
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
843
911
  type: "button",
844
912
  onClick: (e) => {
845
913
  e.stopPropagation();
846
- onPress();
914
+ onPressEvent?.(b.seg.event);
847
915
  },
848
- ...slot("chipButton", chipButtonDefault),
849
- title: event.title,
850
- "aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(event, {
916
+ ...barChipButton,
917
+ title: b.seg.event.title,
918
+ "aria-label": eventAccessibilityLabel ? eventAccessibilityLabel(b.seg.event, {
851
919
  mode: "month",
852
- isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
920
+ isAllDay: (0, _super_calendar_core.isAllDayEvent)(b.seg.event),
853
921
  ampm: false
854
- }) : `${event.title}, ${dayLabel}`,
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
932
+ },
855
933
  children: Chip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chip, {
856
- event,
857
- onPress
934
+ event: b.seg.event,
935
+ onPress: () => onPressEvent?.(b.seg.event)
858
936
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
859
- ...slot("chip", chipDefault(theme)),
860
- children: event.title
937
+ ...barChip,
938
+ style: {
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
948
+ },
949
+ children: b.seg.event.title
861
950
  })
862
- }, `${event.start.toISOString()}:${event.title}`);
863
- }), overflow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
864
- type: "button",
865
- onClick: (e) => {
866
- e.stopPropagation();
867
- onPressMore?.(rest, day.date);
868
- },
869
- ...slot("more", moreButtonDefault(theme)),
870
- "aria-label": `${rest.length} more events, ${dayLabel}`,
871
- children: moreLabel.replace("{moreCount}", String(rest.length))
872
- }) : null]
873
- })
874
- ]
875
- }, day.id);
876
- }
877
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
878
- type: "button",
879
- role: "gridcell",
880
- "data-day": day.id,
881
- ...dayData,
882
- tabIndex: day.id === focusKey ? 0 : -1,
883
- "aria-disabled": day.isDisabled || void 0,
884
- "aria-label": label,
885
- "aria-pressed": day.isSelected || day.isInRange,
886
- ...slot("day", dayCellDefault(day, theme)),
887
- onClick: day.isDisabled ? void 0 : () => onPressDay?.(day.date),
888
- onMouseEnter: day.isDisabled ? void 0 : () => setHoveredKey(day.id),
889
- onMouseLeave: () => setHoveredKey((k) => k === day.id ? null : k),
890
- children: [band ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
891
- "data-band": true,
892
- "aria-hidden": true,
893
- ...slot("rangeBand", band)
894
- }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
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", {
965
+ type: "button",
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
+ }
974
+ },
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
+ }
998
+ },
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,
895
1061
  ...dayData,
896
- ...slot("dayBadge", badgeDefault(day, theme, hoveredKey === day.id)),
897
- children: day.label
898
- })]
899
- }, day.id);
900
- })
901
- }, week.id))
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
+ })
902
1083
  })
903
1084
  ]
904
1085
  });
@@ -907,6 +1088,9 @@ function MonthView({ date, weekStartsOn = 0, weekdayFormat = "short", events, ev
907
1088
  //#region src/TimeGrid.tsx
908
1089
  const GUTTER_WIDTH$1 = 56;
909
1090
  const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
1091
+ const EDGE_ZONE = 32;
1092
+ const EDGE_DWELL_MS = 600;
1093
+ const EDGE_REPEAT_MS = 600;
910
1094
  const VISUALLY_HIDDEN = {
911
1095
  position: "absolute",
912
1096
  width: 1,
@@ -989,17 +1173,6 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
989
1173
  }) : null]
990
1174
  });
991
1175
  }
992
- const NOW_TICK_MS = 6e4;
993
- function useNow(enabled) {
994
- const [now, setNow] = (0, react.useState)(() => /* @__PURE__ */ new Date());
995
- (0, react.useEffect)(() => {
996
- if (!enabled) return;
997
- setNow(/* @__PURE__ */ new Date());
998
- const id = setInterval(() => setNow(/* @__PURE__ */ new Date()), NOW_TICK_MS);
999
- return () => clearInterval(id);
1000
- }, [enabled]);
1001
- return now;
1002
- }
1003
1176
  /**
1004
1177
  * A day / week / N-day time grid rendered with plain DOM elements. Events are
1005
1178
  * positioned with the library's pure `layoutDayEvents`, so overlap columns and
@@ -1011,7 +1184,7 @@ function useNow(enabled) {
1011
1184
  * <TimeGrid mode="week" date={new Date()} events={events} />
1012
1185
  * ```
1013
1186
  */
1014
- function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", keyboardEventNavigation = false, businessHours, showNowIndicator = true, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, className, style, classNames, styles }) {
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 }) {
1015
1188
  const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
1016
1189
  const slot = createSlots({
1017
1190
  classNames,
@@ -1025,7 +1198,10 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1025
1198
  const windowHours = windowEnd - windowStart;
1026
1199
  const gutterWidth = hideHours ? 0 : GUTTER_WIDTH$1;
1027
1200
  const visibleHours = (0, react.useMemo)(() => Array.from({ length: windowHours }, (_, i) => windowStart + i), [windowStart, windowHours]);
1028
- const now = useNow(showNowIndicator);
1201
+ const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
1202
+ now: nowProp,
1203
+ timeZone
1204
+ });
1029
1205
  const [hourHeight, setHourHeight] = (0, react.useState)(initialHourHeight);
1030
1206
  (0, react.useEffect)(() => setHourHeight(initialHourHeight), [initialHourHeight]);
1031
1207
  const hourHeightRef = (0, react.useRef)(hourHeight);
@@ -1040,16 +1216,48 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1040
1216
  const [createBox, setCreateBox] = (0, react.useState)(null);
1041
1217
  const createOrigin = (0, react.useRef)(null);
1042
1218
  const cellEnabled = !!onPressCell || !!onCreateEvent;
1043
- const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays), [
1219
+ const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, false, void 0, hiddenDays), [
1044
1220
  mode,
1045
1221
  date,
1046
1222
  weekStartsOn,
1047
- numberOfDays
1223
+ numberOfDays,
1224
+ hiddenDays
1048
1225
  ]);
1226
+ const edgeAdvanceEnabled = !!onChangeDate && !!onDragEvent;
1227
+ const columnsRef = (0, react.useRef)(null);
1228
+ const edgeTimer = (0, react.useRef)(null);
1229
+ const edgeSide = (0, react.useRef)(0);
1230
+ const ptr = (0, react.useRef)({
1231
+ x: 0,
1232
+ y: 0
1233
+ });
1234
+ const pagedRef = (0, react.useRef)(false);
1235
+ const [paged, setPaged] = (0, react.useState)(false);
1236
+ const draggedRef = (0, react.useRef)(null);
1237
+ const ghostRef = (0, react.useRef)(null);
1238
+ const docHandlersRef = (0, react.useRef)(null);
1239
+ const daysRef = (0, react.useRef)(days);
1240
+ daysRef.current = days;
1241
+ const pageDepsRef = (0, react.useRef)({
1242
+ date,
1243
+ mode,
1244
+ weekStartsOn,
1245
+ numberOfDays
1246
+ });
1247
+ pageDepsRef.current = {
1248
+ date,
1249
+ mode,
1250
+ weekStartsOn,
1251
+ numberOfDays
1252
+ };
1253
+ const onChangeDateRef = (0, react.useRef)(onChangeDate);
1254
+ onChangeDateRef.current = onChangeDate;
1255
+ const onDragEventRef = (0, react.useRef)(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;
1049
1257
  const allDayByDay = (0, react.useMemo)(() => days.map((day) => {
1050
1258
  const dayStart = (0, date_fns.startOfDay)(day);
1051
1259
  const dayEnd = (0, date_fns.addDays)(dayStart, 1);
1052
- return events.filter((e) => (0, _super_calendar_core.isAllDayEvent)(e) && e.start < dayEnd && e.end > dayStart);
1260
+ return events.filter((e) => (0, _super_calendar_core.isAllDayEvent)(e) && !(0, _super_calendar_core.isBackgroundEvent)(e) && e.start < dayEnd && e.end > dayStart);
1053
1261
  }), [days, events]);
1054
1262
  const hasAllDay = allDayByDay.some((list) => list.length > 0);
1055
1263
  (0, react.useEffect)(() => {
@@ -1098,47 +1306,59 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1098
1306
  };
1099
1307
  const Renderer = renderEvent;
1100
1308
  const totalHeight = windowHours * hourHeight;
1101
- const beginDrag = (e, event, key, kind, startHours, durationHours, dayIndex) => {
1102
- if (!onDragEvent) return;
1103
- e.stopPropagation();
1104
- try {
1105
- e.target.setPointerCapture?.(e.pointerId);
1106
- } catch {}
1107
- const column = kind === "move" ? e.currentTarget.parentElement : null;
1108
- const dayWidth = column ? column.getBoundingClientRect().width : 0;
1109
- dragOrigin.current = {
1110
- pointerX: e.clientX,
1111
- pointerY: e.clientY,
1112
- startHours,
1113
- durationHours,
1114
- dayIndex,
1115
- dayWidth
1116
- };
1117
- applyDrag({
1118
- key,
1119
- kind,
1120
- startHours,
1121
- durationHours,
1122
- dayDelta: 0,
1123
- dayOffsetPx: 0,
1124
- moved: false
1125
- });
1126
- onDragStart?.(event);
1309
+ const dayAt = (x, y) => {
1310
+ if (typeof document === "undefined" || typeof document.elementFromPoint !== "function") return null;
1311
+ const iso = (document.elementFromPoint(x, y)?.closest?.("[data-date]"))?.getAttribute("data-date");
1312
+ return iso ? new Date(iso) : null;
1127
1313
  };
1128
- const cancelDrag = () => {
1129
- applyDrag(null);
1314
+ const clearEdgeTimer = () => {
1315
+ if (edgeTimer.current) {
1316
+ clearTimeout(edgeTimer.current);
1317
+ edgeTimer.current = null;
1318
+ }
1319
+ };
1320
+ const fireEdge = () => {
1321
+ const side = edgeSide.current;
1322
+ if (side === 0) return;
1323
+ const p = pageDepsRef.current;
1324
+ const step = (0, _super_calendar_core.pageStepDays)(p.mode, p.date, p.weekStartsOn, p.numberOfDays);
1325
+ onChangeDateRef.current?.((0, date_fns.addDays)(p.date, side * step));
1326
+ pagedRef.current = true;
1327
+ setPaged(true);
1328
+ edgeTimer.current = setTimeout(fireEdge, EDGE_REPEAT_MS);
1329
+ };
1330
+ const detachDocListeners = () => {
1331
+ const h = docHandlersRef.current;
1332
+ if (!h) return;
1333
+ document.removeEventListener("pointermove", h.move);
1334
+ document.removeEventListener("pointerup", h.up);
1335
+ document.removeEventListener("pointercancel", h.cancel);
1336
+ docHandlersRef.current = null;
1337
+ };
1338
+ const finishDrag = () => {
1339
+ detachDocListeners();
1340
+ clearEdgeTimer();
1341
+ edgeSide.current = 0;
1342
+ pagedRef.current = false;
1343
+ setPaged(false);
1344
+ draggedRef.current = null;
1130
1345
  dragOrigin.current = null;
1346
+ applyDrag(null);
1131
1347
  };
1132
1348
  const moveDrag = (e) => {
1133
1349
  const d = dragRef.current;
1134
1350
  if (!d || !dragOrigin.current) return;
1351
+ ptr.current = {
1352
+ x: e.clientX,
1353
+ y: e.clientY
1354
+ };
1135
1355
  const dHours = (e.clientY - dragOrigin.current.pointerY) / hourHeightRef.current;
1136
1356
  const snap = (v) => Math.round(v / snapHours) * snapHours;
1137
1357
  if (d.kind === "move") {
1138
1358
  const startHours = clamp$1(snap(dragOrigin.current.startHours + dHours), windowStart, Math.max(windowStart, windowEnd - d.durationHours));
1139
1359
  const o = dragOrigin.current;
1140
1360
  const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
1141
- const dayDelta = clamp$1(o.dayIndex + rawDayDelta, 0, days.length - 1) - o.dayIndex;
1361
+ const dayDelta = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1) - o.dayIndex;
1142
1362
  applyDrag({
1143
1363
  ...d,
1144
1364
  startHours,
@@ -1146,33 +1366,128 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1146
1366
  dayOffsetPx: dayDelta * o.dayWidth,
1147
1367
  moved: true
1148
1368
  });
1149
- } else {
1369
+ const g = ghostRef.current;
1370
+ const held = draggedRef.current;
1371
+ if (g && held) g.style.transform = `translate(${e.clientX - held.grabX}px, ${e.clientY - held.grabY}px)`;
1372
+ if (edgeAdvanceEnabled) {
1373
+ const rect = columnsRef.current?.getBoundingClientRect();
1374
+ if (rect && rect.right > rect.left) {
1375
+ const left = rect.left + gutterWidth;
1376
+ const side = e.clientX <= left + EDGE_ZONE ? -1 : e.clientX >= rect.right - EDGE_ZONE ? 1 : 0;
1377
+ if (side !== edgeSide.current) {
1378
+ clearEdgeTimer();
1379
+ edgeSide.current = side;
1380
+ if (side !== 0) edgeTimer.current = setTimeout(fireEdge, EDGE_DWELL_MS);
1381
+ }
1382
+ }
1383
+ }
1384
+ } else if (d.kind === "resize") {
1150
1385
  const durationHours = clamp$1(snap(dragOrigin.current.durationHours + dHours), snapHours, Math.max(snapHours, windowEnd - d.startHours));
1151
1386
  applyDrag({
1152
1387
  ...d,
1153
1388
  durationHours,
1154
1389
  moved: true
1155
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
+ });
1156
1401
  }
1157
1402
  };
1158
- const endDrag = (e, day, event, onPress) => {
1403
+ const endDrag = (e) => {
1159
1404
  const d = dragRef.current;
1160
1405
  if (!d) return;
1161
1406
  try {
1162
- e.target.releasePointerCapture?.(e.pointerId);
1407
+ e.target?.releasePointerCapture?.(e.pointerId);
1163
1408
  } catch {}
1409
+ const held = draggedRef.current;
1164
1410
  if (!d.moved) {
1165
- applyDrag(null);
1166
- onPress();
1411
+ finishDrag();
1412
+ held?.onPress();
1167
1413
  return;
1168
1414
  }
1169
- const base = (0, date_fns.startOfDay)((0, date_fns.addDays)(day, d.dayDelta));
1170
- const start = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
1171
- const end = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
1172
- onDragEvent?.(event, start, end);
1173
- applyDrag(null);
1174
- dragOrigin.current = null;
1415
+ const originIndex = dragOrigin.current?.dayIndex ?? 0;
1416
+ let base = null;
1417
+ if (d.kind === "move") if (pagedRef.current) {
1418
+ const day = dayAt(e.clientX, e.clientY);
1419
+ base = day ? (0, date_fns.startOfDay)(day) : null;
1420
+ } else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
1421
+ else base = (0, date_fns.startOfDay)(daysRef.current[originIndex] ?? daysRef.current[0]);
1422
+ if (base && held) {
1423
+ const start = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
1424
+ const end = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
1425
+ onDragEventRef.current?.(held.event, start, end);
1426
+ }
1427
+ finishDrag();
1428
+ };
1429
+ const cancelDrag = () => {
1430
+ finishDrag();
1431
+ };
1432
+ const beginDrag = (e, event, key, kind, startHours, durationHours, dayIndex, onPress) => {
1433
+ if (!onDragEvent) return;
1434
+ e.stopPropagation();
1435
+ try {
1436
+ e.target.setPointerCapture?.(e.pointerId);
1437
+ } catch {}
1438
+ const boxEl = e.currentTarget;
1439
+ const column = kind === "move" ? boxEl.parentElement : null;
1440
+ const dayWidth = column ? column.getBoundingClientRect().width : 0;
1441
+ const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
1442
+ dragOrigin.current = {
1443
+ pointerX: e.clientX,
1444
+ pointerY: e.clientY,
1445
+ startHours,
1446
+ durationHours,
1447
+ dayIndex,
1448
+ dayWidth
1449
+ };
1450
+ draggedRef.current = {
1451
+ event,
1452
+ onPress: onPress ?? (() => {}),
1453
+ grabX: boxRect ? e.clientX - boxRect.left : 0,
1454
+ grabY: boxRect ? e.clientY - boxRect.top : 0,
1455
+ w: boxRect ? boxRect.width : 0,
1456
+ h: boxRect ? boxRect.height : 0
1457
+ };
1458
+ ptr.current = {
1459
+ x: e.clientX,
1460
+ y: e.clientY
1461
+ };
1462
+ edgeSide.current = 0;
1463
+ pagedRef.current = false;
1464
+ setPaged(false);
1465
+ clearEdgeTimer();
1466
+ applyDrag({
1467
+ key,
1468
+ kind,
1469
+ startHours,
1470
+ durationHours,
1471
+ dayDelta: 0,
1472
+ dayOffsetPx: 0,
1473
+ moved: false
1474
+ });
1475
+ onDragStart?.(event);
1476
+ detachDocListeners();
1477
+ const handlers = {
1478
+ move: moveDrag,
1479
+ up: endDrag,
1480
+ cancel: cancelDrag
1481
+ };
1482
+ docHandlersRef.current = handlers;
1483
+ document.addEventListener("pointermove", handlers.move);
1484
+ document.addEventListener("pointerup", handlers.up);
1485
+ document.addEventListener("pointercancel", handlers.cancel);
1175
1486
  };
1487
+ (0, react.useEffect)(() => () => {
1488
+ detachDocListeners();
1489
+ clearEdgeTimer();
1490
+ }, []);
1176
1491
  const pxFromTop = (el, clientY) => clientY - el.getBoundingClientRect().top;
1177
1492
  const beginCreate = (e, dayIndex) => {
1178
1493
  if (!cellEnabled || e.pointerType === "touch") return;
@@ -1294,6 +1609,16 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1294
1609
  windowStart,
1295
1610
  windowEnd
1296
1611
  ]);
1612
+ const backgroundByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.backgroundBandsForDay)(events, day).map((b) => ({
1613
+ ...b,
1614
+ startHours: Math.max(b.startHours, windowStart),
1615
+ endHours: Math.min(b.endHours, windowEnd)
1616
+ })).filter((b) => b.endHours > b.startHours)), [
1617
+ days,
1618
+ events,
1619
+ windowStart,
1620
+ windowEnd
1621
+ ]);
1297
1622
  const gridLines = (0, react.useMemo)(() => {
1298
1623
  const hourLines = `repeating-linear-gradient(to bottom, transparent 0, transparent ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight}px)`;
1299
1624
  if (timeslots <= 1) return hourLines;
@@ -1492,6 +1817,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1492
1817
  touchAction: zoomable ? "pan-y" : "auto"
1493
1818
  },
1494
1819
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1820
+ ref: columnsRef,
1495
1821
  style: {
1496
1822
  display: "flex",
1497
1823
  height: totalHeight,
@@ -1525,6 +1851,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1525
1851
  const bands = bandsByDay[dayIndex];
1526
1852
  const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
1527
1853
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1854
+ "data-date": day.toISOString(),
1528
1855
  onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
1529
1856
  onPointerMove: cellEnabled ? moveCreate : void 0,
1530
1857
  onPointerUp: cellEnabled ? endCreate : void 0,
@@ -1540,7 +1867,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1540
1867
  },
1541
1868
  themed: {
1542
1869
  borderLeft: `1px solid ${theme.gridLine}`,
1543
- ...(0, _super_calendar_core.isWeekend)(day) ? { background: theme.weekendBackground } : null
1870
+ ...highlightWeekends && (0, _super_calendar_core.isWeekend)(day) ? { background: theme.weekendBackground } : null
1544
1871
  }
1545
1872
  }),
1546
1873
  children: [
@@ -1556,9 +1883,30 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1556
1883
  pointerEvents: "none",
1557
1884
  zIndex: 0
1558
1885
  },
1559
- themed: { background: theme.outsideHoursBackground }
1886
+ themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
1887
+ }),
1888
+ children: renderBusinessHours?.({
1889
+ date: day,
1890
+ start: b.start,
1891
+ end: b.end
1560
1892
  })
1561
1893
  }, b.start)),
1894
+ backgroundByDay[dayIndex].map((b, bandIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1895
+ "aria-hidden": true,
1896
+ title: b.event.title,
1897
+ ...slot("backgroundEvent", {
1898
+ base: {
1899
+ position: "absolute",
1900
+ left: 0,
1901
+ right: 0,
1902
+ top: (b.startHours - windowStart) * hourHeight,
1903
+ height: (b.endHours - b.startHours) * hourHeight,
1904
+ pointerEvents: "none",
1905
+ zIndex: 0
1906
+ },
1907
+ themed: { background: theme.backgroundEvent }
1908
+ })
1909
+ }, `bg-${bandIndex}`)),
1562
1910
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1563
1911
  "aria-hidden": true,
1564
1912
  ...slot("gridLines", {
@@ -1573,7 +1921,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1573
1921
  }),
1574
1922
  positioned.map((pe, idx) => {
1575
1923
  const key = `${dayIndex}:${idx}`;
1576
- const active = drag?.key === key ? drag : null;
1924
+ const active = !paged && drag?.key === key ? drag : null;
1577
1925
  const startHours = active ? active.startHours : pe.startHours;
1578
1926
  const durationHours = active ? active.durationHours : pe.durationHours;
1579
1927
  if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
@@ -1591,7 +1939,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1591
1939
  ampm,
1592
1940
  onPress
1593
1941
  };
1594
- const draggable = !!onDragEvent;
1942
+ const editable = !!onDragEvent && pe.event.draggable !== false;
1943
+ const canMove = editable && (pe.event.startEditable ?? eventStartEditable);
1944
+ const canResize = editable && (pe.event.durationEditable ?? eventDurationEditable);
1595
1945
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1596
1946
  role: "button",
1597
1947
  tabIndex: 0,
@@ -1615,11 +1965,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1615
1965
  }
1616
1966
  if (keyboardEventNavigation) onEventKeyDown(key, e);
1617
1967
  },
1618
- onPointerDown: draggable ? (e) => beginDrag(e, pe.event, key, "move", pe.startHours, pe.durationHours, dayIndex) : void 0,
1619
- onPointerMove: draggable ? moveDrag : void 0,
1620
- onPointerUp: draggable ? (e) => endDrag(e, day, pe.event, onPress) : void 0,
1621
- onPointerCancel: draggable ? cancelDrag : void 0,
1622
- onClick: draggable ? void 0 : onPress,
1968
+ onPointerDown: canMove ? (e) => beginDrag(e, pe.event, key, "move", pe.startHours, pe.durationHours, dayIndex, onPress) : void 0,
1969
+ onClick: canMove ? void 0 : onPress,
1623
1970
  ...dataState({ "data-dragging": !!active }),
1624
1971
  ...slot("event", { base: {
1625
1972
  position: "absolute",
@@ -1627,31 +1974,49 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1627
1974
  height: boxHeight,
1628
1975
  left: `calc(${pe.column * widthPct}% + 1px)`,
1629
1976
  width: `calc(${widthPct}% - 2px)`,
1630
- cursor: draggable ? "grab" : "pointer",
1631
- touchAction: draggable ? "none" : "auto",
1977
+ cursor: canMove ? "grab" : "pointer",
1978
+ touchAction: canMove ? "none" : "auto",
1632
1979
  zIndex: active ? 3 : 1,
1633
1980
  opacity: active ? .85 : 1,
1634
1981
  ...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
1635
1982
  } }),
1636
- children: [Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
1637
- ...args,
1638
- theme,
1639
- boxProps: slot("eventBox")
1640
- }), draggable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1641
- onPointerDown: (e) => {
1642
- e.stopPropagation();
1643
- beginDrag(e, pe.event, key, "resize", pe.startHours, pe.durationHours, dayIndex);
1644
- },
1645
- style: {
1646
- position: "absolute",
1647
- left: 0,
1648
- right: 0,
1649
- bottom: 0,
1650
- height: 8,
1651
- cursor: "ns-resize",
1652
- touchAction: "none"
1653
- }
1654
- }) : null]
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
+ ]
1655
2020
  }, idx);
1656
2021
  }),
1657
2022
  showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -1701,7 +2066,39 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1701
2066
  }, day.toISOString());
1702
2067
  })]
1703
2068
  })
1704
- })
2069
+ }),
2070
+ paged && draggedRef.current ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2071
+ ref: ghostRef,
2072
+ "aria-hidden": true,
2073
+ style: {
2074
+ position: "fixed",
2075
+ left: 0,
2076
+ top: 0,
2077
+ width: draggedRef.current.w,
2078
+ height: draggedRef.current.h,
2079
+ transform: `translate(${ptr.current.x - draggedRef.current.grabX}px, ${ptr.current.y - draggedRef.current.grabY}px)`,
2080
+ pointerEvents: "none",
2081
+ zIndex: 1e3,
2082
+ opacity: .85
2083
+ },
2084
+ children: Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, {
2085
+ event: draggedRef.current.event,
2086
+ mode,
2087
+ isAllDay: false,
2088
+ boxHeight: draggedRef.current.h,
2089
+ ampm,
2090
+ onPress: () => {}
2091
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
2092
+ event: draggedRef.current.event,
2093
+ mode,
2094
+ isAllDay: false,
2095
+ boxHeight: draggedRef.current.h,
2096
+ ampm,
2097
+ onPress: () => {},
2098
+ theme,
2099
+ boxProps: slot("eventBox")
2100
+ })
2101
+ }) : null
1705
2102
  ]
1706
2103
  });
1707
2104
  }
@@ -1732,7 +2129,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
1732
2129
  * <Calendar mode="week" date={new Date()} events={events} />
1733
2130
  * ```
1734
2131
  */
1735
- function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, showNowIndicator, showAllDayEventCell, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
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 }) {
1736
2133
  const displayEvents = (0, react.useMemo)(() => {
1737
2134
  let out = events ?? EMPTY_EVENTS;
1738
2135
  if (out.some((e) => e.recurrence)) {
@@ -1765,6 +2162,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
1765
2162
  date,
1766
2163
  events: displayEvents,
1767
2164
  weekStartsOn,
2165
+ hiddenDays,
1768
2166
  locale,
1769
2167
  theme,
1770
2168
  className,
@@ -1797,6 +2195,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
1797
2195
  date,
1798
2196
  events: displayEvents,
1799
2197
  weekStartsOn,
2198
+ hiddenDays,
1800
2199
  weekdayFormat,
1801
2200
  locale,
1802
2201
  theme,
@@ -1826,6 +2225,9 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
1826
2225
  mode,
1827
2226
  events: displayEvents,
1828
2227
  weekStartsOn,
2228
+ hiddenDays,
2229
+ now,
2230
+ timeZone,
1829
2231
  weekdayFormat,
1830
2232
  numberOfDays,
1831
2233
  locale,
@@ -1845,14 +2247,20 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
1845
2247
  showWeekNumber,
1846
2248
  weekNumberPrefix,
1847
2249
  businessHours,
2250
+ renderBusinessHours,
1848
2251
  showNowIndicator,
1849
2252
  showAllDayEventCell,
2253
+ highlightWeekends,
2254
+ eventStartEditable,
2255
+ eventDurationEditable,
2256
+ eventOverlap,
1850
2257
  dragStepMinutes,
1851
2258
  onPressEvent,
1852
2259
  onPressCell,
1853
2260
  onCreateEvent,
1854
2261
  onDragStart,
1855
2262
  onDragEvent,
2263
+ onChangeDate,
1856
2264
  onPressDateHeader,
1857
2265
  renderEvent: renderTimeEvent,
1858
2266
  eventAccessibilityLabel,
@@ -1899,7 +2307,7 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
1899
2307
  ]);
1900
2308
  const eventsByDay = (0, react.useMemo)(() => {
1901
2309
  if (!events) return void 0;
1902
- const map = (0, _super_calendar_core.groupEventsByDay)(events);
2310
+ const map = (0, _super_calendar_core.groupEventsByDay)(events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
1903
2311
  for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
1904
2312
  return map;
1905
2313
  }, [events]);
@@ -2287,7 +2695,17 @@ function DefaultBar({ event, height, boxProps, theme }) {
2287
2695
  * />
2288
2696
  * ```
2289
2697
  */
2290
- function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, dragStepMinutes = 15, className, style, classNames, styles }) {
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 }) {
2699
+ const resources = (0, react.useMemo)(() => {
2700
+ if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
2701
+ const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
2702
+ const page = Math.min(Math.max(resourcePage, 0), pages - 1);
2703
+ return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
2704
+ }, [
2705
+ allResources,
2706
+ resourcesPerPage,
2707
+ resourcePage
2708
+ ]);
2291
2709
  const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
2292
2710
  const slot = createSlots({
2293
2711
  classNames,
@@ -2297,6 +2715,35 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2297
2715
  const snapHours = dragStepMinutes / 60;
2298
2716
  const vertical = orientation === "vertical";
2299
2717
  const hourSize = vertical ? hourHeight : hourWidth;
2718
+ const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
2719
+ now: nowProp,
2720
+ timeZone
2721
+ });
2722
+ const nowHours = now.getHours() + now.getMinutes() / 60;
2723
+ const showNow = showNowIndicator && (0, _super_calendar_core.isSameCalendarDay)(now, date) && nowHours >= startHour && nowHours <= endHour;
2724
+ const nowLine = (resourceKey) => showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2725
+ "aria-hidden": true,
2726
+ ...slot("nowIndicator", {
2727
+ base: vertical ? {
2728
+ position: "absolute",
2729
+ left: 0,
2730
+ right: 0,
2731
+ top: (nowHours - startHour) * hourSize,
2732
+ height: 2,
2733
+ pointerEvents: "none",
2734
+ zIndex: 2
2735
+ } : {
2736
+ position: "absolute",
2737
+ top: 0,
2738
+ bottom: 0,
2739
+ left: (nowHours - startHour) * hourSize,
2740
+ width: 2,
2741
+ pointerEvents: "none",
2742
+ zIndex: 2
2743
+ },
2744
+ themed: { background: theme.nowIndicator }
2745
+ })
2746
+ }, `now-${resourceKey}`) : null;
2300
2747
  const [drag, setDrag] = (0, react.useState)(null);
2301
2748
  const dragRef = (0, react.useRef)(null);
2302
2749
  const origin = (0, react.useRef)(null);
@@ -2304,7 +2751,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2304
2751
  dragRef.current = next;
2305
2752
  setDrag(next);
2306
2753
  };
2307
- const beginDrag = (e, key, kind, startHours, durationHours) => {
2754
+ const beginDrag = (e, key, resourceId, kind, startHours, durationHours) => {
2308
2755
  if (!onDragEvent) return;
2309
2756
  e.stopPropagation();
2310
2757
  try {
@@ -2312,14 +2759,17 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2312
2759
  } catch {}
2313
2760
  origin.current = {
2314
2761
  x: vertical ? e.clientY : e.clientX,
2762
+ cross: vertical ? e.clientX : e.clientY,
2315
2763
  startHours,
2316
2764
  durationHours
2317
2765
  };
2318
2766
  applyDrag({
2319
2767
  key,
2768
+ resourceId,
2320
2769
  kind,
2321
2770
  startHours,
2322
2771
  durationHours,
2772
+ crossPx: 0,
2323
2773
  moved: false
2324
2774
  });
2325
2775
  };
@@ -2330,9 +2780,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2330
2780
  const snap = (v) => Math.round(v / snapHours) * snapHours;
2331
2781
  if (d.kind === "move") {
2332
2782
  const startHours = clamp(snap(origin.current.startHours + dHours), startHour, endHour - d.durationHours);
2783
+ const crossPx = (vertical ? e.clientX : e.clientY) - origin.current.cross;
2333
2784
  applyDrag({
2334
2785
  ...d,
2335
2786
  startHours,
2787
+ crossPx,
2336
2788
  moved: true
2337
2789
  });
2338
2790
  } else {
@@ -2344,7 +2796,21 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2344
2796
  });
2345
2797
  }
2346
2798
  };
2347
- const endDrag = (e, event, onPress) => {
2799
+ const laneAt = (e, fallback) => {
2800
+ if (typeof document === "undefined" || typeof document.elementFromPoint !== "function") return fallback;
2801
+ const bar = e.currentTarget;
2802
+ const prev = bar.style.pointerEvents;
2803
+ let hit;
2804
+ bar.style.pointerEvents = "none";
2805
+ try {
2806
+ hit = document.elementFromPoint(e.clientX, e.clientY);
2807
+ } finally {
2808
+ bar.style.pointerEvents = prev;
2809
+ }
2810
+ const id = (hit?.closest?.("[data-resource-id]"))?.getAttribute("data-resource-id");
2811
+ return id && resources.find((r) => r.id === id) || fallback;
2812
+ };
2813
+ const endDrag = (e, event, resource, onPress) => {
2348
2814
  const d = dragRef.current;
2349
2815
  if (!d) return;
2350
2816
  try {
@@ -2355,10 +2821,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2355
2821
  onPress();
2356
2822
  return;
2357
2823
  }
2824
+ const target = d.kind === "move" ? laneAt(e, resource) : resource;
2358
2825
  const base = (0, date_fns.startOfDay)(date);
2359
2826
  const start = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
2360
2827
  const end = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
2361
- onDragEvent?.(event, start, end);
2828
+ onDragEvent?.(event, start, end, target);
2362
2829
  applyDrag(null);
2363
2830
  origin.current = null;
2364
2831
  };
@@ -2429,6 +2896,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2429
2896
  onPointerCancel: cancelCreate
2430
2897
  } : null;
2431
2898
  const bandsFor = (resource) => businessHours ? (0, _super_calendar_core.closedHourBands)(date, (d) => businessHours(d, resource), startHour, endHour) : [];
2899
+ const backgroundBandsFor = (resource) => (0, _super_calendar_core.backgroundBandsForDay)(events.filter((e) => resourceId(e) === resource.id), date).map((b) => ({
2900
+ ...b,
2901
+ startHours: Math.max(b.startHours, startHour),
2902
+ endHours: Math.min(b.endHours, endHour)
2903
+ })).filter((b) => b.endHours > b.startHours);
2432
2904
  const hours = (0, react.useMemo)(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
2433
2905
  const trackWidth = (endHour - startHour) * hourWidth;
2434
2906
  const byResource = (0, react.useMemo)(() => {
@@ -2444,6 +2916,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2444
2916
  resourceId,
2445
2917
  date
2446
2918
  ]);
2919
+ const dragLaneId = drag?.kind === "move" && drag.moved ? drag.resourceId : null;
2447
2920
  if (vertical) {
2448
2921
  const trackHeight = (endHour - startHour) * hourHeight;
2449
2922
  const vGridLines = `repeating-linear-gradient(to bottom, transparent 0, transparent ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight - 1}px, ${theme.gridLine} ${hourHeight}px)`;
@@ -2471,7 +2944,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2471
2944
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { ...slot("corner", { base: {
2472
2945
  width: GUTTER_WIDTH,
2473
2946
  flex: "none"
2474
- } }) }), resources.map((resource) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2947
+ } }) }), resources.map((resource, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2475
2948
  ...slot("resourceLabel", {
2476
2949
  base: {
2477
2950
  flex: 1,
@@ -2489,7 +2962,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2489
2962
  borderLeft: `1px solid ${theme.gridLine}`
2490
2963
  }
2491
2964
  }),
2492
- children: resource.title ?? resource.id
2965
+ children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
2493
2966
  }, resource.id))]
2494
2967
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2495
2968
  style: { display: "flex" },
@@ -2520,11 +2993,16 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2520
2993
  ...slot("row", {
2521
2994
  base: {
2522
2995
  flex: 1,
2523
- minWidth: 0
2996
+ minWidth: 0,
2997
+ ...dragLaneId === resource.id ? {
2998
+ position: "relative",
2999
+ zIndex: 5
3000
+ } : null
2524
3001
  },
2525
3002
  themed: { borderLeft: `1px solid ${theme.gridLine}` }
2526
3003
  }),
2527
3004
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3005
+ "data-resource-id": resource.id,
2528
3006
  ...trackInteractionProps(resource),
2529
3007
  ...slot("track", { base: {
2530
3008
  position: "relative",
@@ -2543,9 +3021,31 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2543
3021
  pointerEvents: "none",
2544
3022
  zIndex: 0
2545
3023
  },
2546
- themed: { background: theme.outsideHoursBackground }
3024
+ themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
3025
+ }),
3026
+ children: renderBusinessHours?.({
3027
+ date,
3028
+ start: b.start,
3029
+ end: b.end,
3030
+ resource
2547
3031
  })
2548
3032
  }, b.start)),
3033
+ backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3034
+ "aria-hidden": true,
3035
+ title: b.event.title,
3036
+ ...slot("backgroundEvent", {
3037
+ base: {
3038
+ position: "absolute",
3039
+ left: 0,
3040
+ right: 0,
3041
+ top: (b.startHours - startHour) * hourHeight,
3042
+ height: (b.endHours - b.startHours) * hourHeight,
3043
+ pointerEvents: "none",
3044
+ zIndex: 0
3045
+ },
3046
+ themed: { background: theme.backgroundEvent }
3047
+ })
3048
+ }, `bg-${i}`)),
2549
3049
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2550
3050
  "aria-hidden": true,
2551
3051
  ...slot("gridLines", {
@@ -2573,15 +3073,15 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2573
3073
  height,
2574
3074
  onPress
2575
3075
  };
2576
- const draggable = !!onDragEvent;
3076
+ const draggable = !!onDragEvent && pe.event.draggable !== false;
2577
3077
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2578
3078
  type: "button",
2579
3079
  onClick: draggable ? void 0 : onPress,
2580
3080
  "aria-label": pe.event.title,
2581
3081
  ...dataState({ "data-dragging": !!active }),
2582
- onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
3082
+ onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe.startHours, pe.durationHours) : void 0,
2583
3083
  onPointerMove: draggable ? moveDrag : void 0,
2584
- onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
3084
+ onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
2585
3085
  onPointerCancel: draggable ? cancelDrag : void 0,
2586
3086
  ...slot("event", { base: {
2587
3087
  position: "absolute",
@@ -2589,6 +3089,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2589
3089
  height,
2590
3090
  left: `${pe.column * lanePct}%`,
2591
3091
  width: `${lanePct}%`,
3092
+ transform: active?.kind === "move" ? `translateX(${active.crossPx}px)` : void 0,
2592
3093
  padding: 1,
2593
3094
  border: "none",
2594
3095
  background: "transparent",
@@ -2608,7 +3109,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2608
3109
  "aria-hidden": true,
2609
3110
  onPointerDown: (e) => {
2610
3111
  e.stopPropagation();
2611
- beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
3112
+ beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
2612
3113
  },
2613
3114
  style: {
2614
3115
  position: "absolute",
@@ -2622,6 +3123,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2622
3123
  }) : null]
2623
3124
  }, idx);
2624
3125
  }),
3126
+ nowLine(resource.id),
2625
3127
  createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2626
3128
  "aria-hidden": true,
2627
3129
  ...slot("createGhost", {
@@ -2689,13 +3191,17 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2689
3191
  children: (0, _super_calendar_core.formatHour)(h, { ampm })
2690
3192
  }, h))
2691
3193
  })]
2692
- }), resources.map((resource) => {
3194
+ }), resources.map((resource, index) => {
2693
3195
  const positioned = byResource.get(resource.id) ?? [];
2694
3196
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2695
3197
  ...slot("row", {
2696
3198
  base: {
2697
3199
  display: "flex",
2698
- height: rowHeight
3200
+ height: rowHeight,
3201
+ ...dragLaneId === resource.id ? {
3202
+ position: "relative",
3203
+ zIndex: 5
3204
+ } : null
2699
3205
  },
2700
3206
  themed: { borderBottom: `1px solid ${theme.gridLine}` }
2701
3207
  }),
@@ -2715,8 +3221,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2715
3221
  borderRight: `1px solid ${theme.gridLine}`
2716
3222
  }
2717
3223
  }),
2718
- children: resource.title ?? resource.id
3224
+ children: renderResourceHeader ? renderResourceHeader(resource, index) : resource.title ?? resource.id
2719
3225
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3226
+ "data-resource-id": resource.id,
2720
3227
  ...trackInteractionProps(resource),
2721
3228
  ...slot("track", { base: {
2722
3229
  position: "relative",
@@ -2735,9 +3242,31 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2735
3242
  pointerEvents: "none",
2736
3243
  zIndex: 0
2737
3244
  },
2738
- themed: { background: theme.outsideHoursBackground }
3245
+ themed: renderBusinessHours ? void 0 : { background: theme.outsideHoursBackground }
3246
+ }),
3247
+ children: renderBusinessHours?.({
3248
+ date,
3249
+ start: b.start,
3250
+ end: b.end,
3251
+ resource
2739
3252
  })
2740
3253
  }, b.start)),
3254
+ backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3255
+ "aria-hidden": true,
3256
+ title: b.event.title,
3257
+ ...slot("backgroundEvent", {
3258
+ base: {
3259
+ position: "absolute",
3260
+ top: 0,
3261
+ bottom: 0,
3262
+ left: (b.startHours - startHour) * hourWidth,
3263
+ width: (b.endHours - b.startHours) * hourWidth,
3264
+ pointerEvents: "none",
3265
+ zIndex: 0
3266
+ },
3267
+ themed: { background: theme.backgroundEvent }
3268
+ })
3269
+ }, `bg-${i}`)),
2741
3270
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2742
3271
  "aria-hidden": true,
2743
3272
  ...slot("gridLines", {
@@ -2770,9 +3299,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2770
3299
  onClick: draggable ? void 0 : onPress,
2771
3300
  "aria-label": pe.event.title,
2772
3301
  ...dataState({ "data-dragging": !!active }),
2773
- onPointerDown: draggable ? (e) => beginDrag(e, key, "move", pe.startHours, pe.durationHours) : void 0,
3302
+ onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe.startHours, pe.durationHours) : void 0,
2774
3303
  onPointerMove: draggable ? moveDrag : void 0,
2775
- onPointerUp: draggable ? (e) => endDrag(e, pe.event, onPress) : void 0,
3304
+ onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
2776
3305
  onPointerCancel: draggable ? cancelDrag : void 0,
2777
3306
  ...slot("event", { base: {
2778
3307
  position: "absolute",
@@ -2780,6 +3309,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2780
3309
  width,
2781
3310
  top: pe.column * laneHeight,
2782
3311
  height: laneHeight,
3312
+ transform: active?.kind === "move" ? `translateY(${active.crossPx}px)` : void 0,
2783
3313
  padding: 1,
2784
3314
  border: "none",
2785
3315
  background: "transparent",
@@ -2799,7 +3329,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2799
3329
  "aria-hidden": true,
2800
3330
  onPointerDown: (e) => {
2801
3331
  e.stopPropagation();
2802
- beginDrag(e, key, "resize", pe.startHours, pe.durationHours);
3332
+ beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
2803
3333
  },
2804
3334
  style: {
2805
3335
  position: "absolute",
@@ -2813,6 +3343,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2813
3343
  }) : null]
2814
3344
  }, idx);
2815
3345
  }),
3346
+ nowLine(resource.id),
2816
3347
  createBox?.resourceKey === resource.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2817
3348
  "aria-hidden": true,
2818
3349
  ...slot("createGhost", {
@@ -2850,6 +3381,12 @@ exports.MonthView = MonthView;
2850
3381
  exports.ResourceTimeline = ResourceTimeline;
2851
3382
  exports.TimeGrid = TimeGrid;
2852
3383
  exports.YearView = YearView;
3384
+ Object.defineProperty(exports, "backgroundBandsForDay", {
3385
+ enumerable: true,
3386
+ get: function() {
3387
+ return _super_calendar_core.backgroundBandsForDay;
3388
+ }
3389
+ });
2853
3390
  Object.defineProperty(exports, "buildMonthGrid", {
2854
3391
  enumerable: true,
2855
3392
  get: function() {
@@ -2882,6 +3419,12 @@ Object.defineProperty(exports, "isAllDayEvent", {
2882
3419
  return _super_calendar_core.isAllDayEvent;
2883
3420
  }
2884
3421
  });
3422
+ Object.defineProperty(exports, "isBackgroundEvent", {
3423
+ enumerable: true,
3424
+ get: function() {
3425
+ return _super_calendar_core.isBackgroundEvent;
3426
+ }
3427
+ });
2885
3428
  Object.defineProperty(exports, "isDateSelectable", {
2886
3429
  enumerable: true,
2887
3430
  get: function() {
@@ -2906,6 +3449,12 @@ Object.defineProperty(exports, "layoutDayEvents", {
2906
3449
  return _super_calendar_core.layoutDayEvents;
2907
3450
  }
2908
3451
  });
3452
+ Object.defineProperty(exports, "layoutMonthWeek", {
3453
+ enumerable: true,
3454
+ get: function() {
3455
+ return _super_calendar_core.layoutMonthWeek;
3456
+ }
3457
+ });
2909
3458
  exports.mergeDomTheme = mergeDomTheme;
2910
3459
  Object.defineProperty(exports, "nextDateRange", {
2911
3460
  enumerable: true,
@@ -2931,12 +3480,24 @@ Object.defineProperty(exports, "useDateRange", {
2931
3480
  return _super_calendar_core.useDateRange;
2932
3481
  }
2933
3482
  });
3483
+ Object.defineProperty(exports, "useEventSource", {
3484
+ enumerable: true,
3485
+ get: function() {
3486
+ return _super_calendar_core.useEventSource;
3487
+ }
3488
+ });
2934
3489
  Object.defineProperty(exports, "useMonthGrid", {
2935
3490
  enumerable: true,
2936
3491
  get: function() {
2937
3492
  return _super_calendar_core.useMonthGrid;
2938
3493
  }
2939
3494
  });
3495
+ Object.defineProperty(exports, "useNow", {
3496
+ enumerable: true,
3497
+ get: function() {
3498
+ return _super_calendar_core.useNow;
3499
+ }
3500
+ });
2940
3501
  Object.defineProperty(exports, "weekdayFormatToken", {
2941
3502
  enumerable: true,
2942
3503
  get: function() {