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