@super-calendar/native 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,15 +1,15 @@
1
- import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-CMzYn9T0.mjs";
1
+ import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-Chx0jP5n.mjs";
2
2
  import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
3
- import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import Animated, { runOnJS, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
5
- import { buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, minutesIntoDay, nextDateRange, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useMonthGrid, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
5
+ import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
6
6
  import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { LegendList } from "@legendapp/list/react-native";
9
9
  import { Gesture, GestureDetector } from "react-native-gesture-handler";
10
10
  //#region src/components/YearView.tsx
11
11
  const FALLBACK_COLUMNS = 3;
12
- function YearViewInner({ date, events, weekStartsOn, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
12
+ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
13
13
  const theme = useCalendarTheme();
14
14
  const slot = createSlots({
15
15
  classNames,
@@ -22,19 +22,20 @@ function YearViewInner({ date, events, weekStartsOn, locale, activeDate, minMont
22
22
  setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
23
23
  };
24
24
  const months = useMemo(() => getYearMonths(date), [date]);
25
- const weekdayLabels = useMemo(() => getWeekDays$1(date, weekStartsOn).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
25
+ const weekdayLabels = useMemo(() => filterHiddenDays(getWeekDays$1(date, weekStartsOn), hiddenDays).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
26
26
  date,
27
27
  weekStartsOn,
28
- locale
28
+ locale,
29
+ hiddenDays
29
30
  ]);
30
- const eventDays = useMemo(() => new Set(events && events.length > 0 ? groupEventsByDay(events).keys() : []), [events]);
31
+ const eventDays = useMemo(() => new Set(events && events.length > 0 ? groupEventsByDay(events.filter((e) => !isBackgroundEvent$1(e))).keys() : []), [events]);
31
32
  return /* @__PURE__ */ jsx(ScrollView, {
32
33
  onLayout: handleLayout,
33
34
  showsVerticalScrollIndicator: true,
34
35
  children: /* @__PURE__ */ jsx(View, {
35
36
  ...slot("grid", { base: styles$5.grid }),
36
37
  children: months.map((month) => {
37
- const weeks = buildMonthWeeks$1(month, weekStartsOn);
38
+ const weeks = buildMonthWeeks$1(month, weekStartsOn, { hiddenDays });
38
39
  const title = format(month, "MMMM", { locale });
39
40
  const monthLabel = format(month, "MMMM yyyy", { locale });
40
41
  const titleText = /* @__PURE__ */ jsx(Text, {
@@ -184,7 +185,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
184
185
  }), [classNames, styleOverrides]);
185
186
  const RenderEventComponent = renderEvent;
186
187
  const rows = useMemo(() => {
187
- const sorted = [...events].sort((a, b) => a.start.getTime() - b.start.getTime());
188
+ const sorted = events.filter((event) => !isBackgroundEvent$1(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
188
189
  const out = [];
189
190
  let currentDay = null;
190
191
  sorted.forEach((event, index) => {
@@ -351,7 +352,7 @@ function DefaultEvent({ event, mode, boxHeight, isAllDay, ampm = false, showTime
351
352
  ],
352
353
  onPress,
353
354
  onLongPress,
354
- activeOpacity: .7,
355
+ activeOpacity: 1,
355
356
  accessibilityRole: "button",
356
357
  accessibilityLabel,
357
358
  accessibilityState: { disabled: event.disabled ?? false },
@@ -481,7 +482,7 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
481
482
  const theme = useCalendarTheme();
482
483
  const slot = useSlots();
483
484
  const RenderEventComponent = renderEvent;
484
- const allDay = events.filter(isAllDayEvent$1);
485
+ const allDay = events.filter((event) => isAllDayEvent$1(event) && !isBackgroundEvent$1(event));
485
486
  const perDay = days.map((day) => {
486
487
  const start = startOfDay(day);
487
488
  const next = addDays(start, 1);
@@ -559,34 +560,76 @@ const MOVE_ACTIVATE_MS$1 = 500;
559
560
  const DRAG_ACTIVATE_PX$1 = 8;
560
561
  const RESIZE_HANDLE_HEIGHT = 14;
561
562
  const DEFAULT_DRAG_STEP_MINUTES = 15;
562
- const HOUR_LABEL_TOP_INSET = 12;
563
- const NOW_TICK_MS = 6e4;
564
- function useNow(enabled) {
565
- const [now, setNow] = useState(() => /* @__PURE__ */ new Date());
566
- useEffect(() => {
567
- if (!enabled) return;
568
- setNow(/* @__PURE__ */ new Date());
569
- const id = setInterval(() => setNow(/* @__PURE__ */ new Date()), NOW_TICK_MS);
570
- return () => clearInterval(id);
571
- }, [enabled]);
572
- return now;
563
+ const DRAG_EVENT_Z = 100;
564
+ const EDGE_DWELL_MS = 500;
565
+ const EDGE_ZONE_PX = 36;
566
+ const EdgePagingContext = createContext(null);
567
+ const noop = () => {};
568
+ /**
569
+ * The floating copy of a dragged event, rendered above the pager so a cross-week
570
+ * drag stays visible after its source page pages away. Position, size, and
571
+ * visibility are driven on the UI thread by the shared values so it tracks the
572
+ * finger without a React re-render.
573
+ */
574
+ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
575
+ const RenderEventComponent = renderEvent;
576
+ const style = useAnimatedStyle(() => ({
577
+ transform: [{ translateX: x.value }, { translateY: y.value }],
578
+ width: w.value,
579
+ height: h.value,
580
+ opacity: visible.value
581
+ }));
582
+ return /* @__PURE__ */ jsx(Animated.View, {
583
+ style: [
584
+ styles$1.eventBox,
585
+ styles$1.dragGhost,
586
+ style
587
+ ],
588
+ pointerEvents: "none",
589
+ children: /* @__PURE__ */ jsx(RenderEventComponent, {
590
+ event,
591
+ mode,
592
+ boxHeight: h,
593
+ onPress: noop
594
+ })
595
+ });
573
596
  }
574
- function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, mode, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, showDragHandle }) {
597
+ const HOUR_LABEL_TOP_INSET = 12;
598
+ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
575
599
  const RenderEventComponent = renderEvent;
576
600
  const theme = useCalendarTheme();
577
601
  const slot = useSlots();
578
- const draggable = onDragEvent != null && !positioned.event.disabled;
579
- const resizable = draggable && !positioned.continuesAfter;
602
+ const edgePaging = useContext(EdgePagingContext);
603
+ const pagerLeftSV = edgePaging?.pagerLeft;
604
+ const pagerTopSV = edgePaging?.pagerTop;
605
+ const pagerWidthSV = edgePaging?.pagerWidth;
606
+ const ghostXSV = edgePaging?.ghostX;
607
+ const ghostYSV = edgePaging?.ghostY;
608
+ const commitLiftedDrop = edgePaging?.commitLiftedDrop;
609
+ const editable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
610
+ const canMove = editable && (positioned.event.startEditable ?? eventStartEditable);
611
+ const canResize = editable && (positioned.event.durationEditable ?? eventDurationEditable);
612
+ const resizable = canResize && !positioned.continuesAfter;
613
+ const resizableFromStart = canResize && !positioned.continuesBefore && !isWeb$1;
580
614
  const moveOffset = useSharedValue(0);
581
615
  const moveOffsetX = useSharedValue(0);
582
616
  const resizeDelta = useSharedValue(0);
617
+ const resizeStartDelta = useSharedValue(0);
618
+ const dragZ = useSharedValue(0);
619
+ const edgeDir = useSharedValue(0);
620
+ const lifted = useSharedValue(0);
621
+ const grabX = useSharedValue(0);
622
+ const grabY = useSharedValue(0);
623
+ const liveAbsX = useSharedValue(0);
624
+ const liveAbsY = useSharedValue(0);
583
625
  const startHours = positioned.startHours;
584
626
  const durationHours = positioned.durationHours;
585
- const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
627
+ const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
586
628
  const boxStyle = useAnimatedStyle(() => ({
587
- top: (startHours - minHour) * cellHeight.value + moveOffset.value,
629
+ top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
588
630
  height: boxHeight.value,
589
- transform: [{ translateX: moveOffsetX.value }]
631
+ transform: [{ translateX: moveOffsetX.value }],
632
+ zIndex: dragZ.value
590
633
  }), [
591
634
  startHours,
592
635
  durationHours,
@@ -596,12 +639,14 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
596
639
  moveOffset.value = 0;
597
640
  moveOffsetX.value = 0;
598
641
  resizeDelta.value = 0;
642
+ resizeStartDelta.value = 0;
599
643
  }, [
600
644
  positioned.startHours,
601
645
  positioned.durationHours,
602
646
  moveOffset,
603
647
  moveOffsetX,
604
- resizeDelta
648
+ resizeDelta,
649
+ resizeStartDelta
605
650
  ]);
606
651
  const latest = useRef({
607
652
  event: positioned.event,
@@ -617,10 +662,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
617
662
  moveOffset.value = 0;
618
663
  moveOffsetX.value = 0;
619
664
  resizeDelta.value = 0;
665
+ resizeStartDelta.value = 0;
620
666
  }, [
621
667
  moveOffset,
622
668
  moveOffsetX,
623
- resizeDelta
669
+ resizeDelta,
670
+ resizeStartDelta
624
671
  ]);
625
672
  const commitDrag = useCallback((deltaStartMin, deltaEndMin) => {
626
673
  const { event, onDragEvent: handler } = latest.current;
@@ -635,16 +682,81 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
635
682
  const notifyDragStart = useCallback(() => {
636
683
  latest.current.onDragStart?.(latest.current.event);
637
684
  }, []);
685
+ const dwellTimer = useRef(null);
686
+ const disarmEdge = useCallback(() => {
687
+ if (dwellTimer.current) {
688
+ clearTimeout(dwellTimer.current);
689
+ dwellTimer.current = null;
690
+ }
691
+ }, []);
692
+ const releaseEdge = useCallback(() => {
693
+ disarmEdge();
694
+ edgePaging?.lockScroll(false);
695
+ }, [disarmEdge, edgePaging]);
696
+ const armEdge = useCallback((dir) => {
697
+ disarmEdge();
698
+ dwellTimer.current = setTimeout(() => {
699
+ dwellTimer.current = null;
700
+ if (!edgePaging) return;
701
+ edgePaging.lockScroll(true);
702
+ if (!lifted.value) {
703
+ lifted.value = 1;
704
+ edgePaging.ghostW.value = width;
705
+ edgePaging.ghostH.value = boxHeight.value;
706
+ edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
707
+ edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
708
+ edgePaging.ghostVisible.value = 1;
709
+ edgePaging.beginLift(latest.current.event);
710
+ }
711
+ onEdgeAdvance?.(dir);
712
+ }, EDGE_DWELL_MS);
713
+ }, [
714
+ disarmEdge,
715
+ edgePaging,
716
+ lifted,
717
+ width,
718
+ boxHeight,
719
+ liveAbsX,
720
+ liveAbsY,
721
+ grabX,
722
+ grabY,
723
+ onEdgeAdvance
724
+ ]);
638
725
  const moveGesture = useMemo(() => {
639
- const pan = Gesture.Pan().enabled(draggable).onStart(() => {
726
+ const pan = Gesture.Pan().enabled(canMove).onStart((event) => {
727
+ dragZ.value = DRAG_EVENT_Z;
728
+ edgeDir.value = 0;
729
+ lifted.value = 0;
730
+ grabX.value = event.x;
731
+ grabY.value = event.y;
732
+ liveAbsX.value = event.absoluteX;
733
+ liveAbsY.value = event.absoluteY;
640
734
  runOnJS(notifyDragStart)();
641
735
  }).onUpdate((event) => {
642
- moveOffset.value = event.translationY;
643
- moveOffsetX.value = event.translationX;
736
+ liveAbsX.value = event.absoluteX;
737
+ liveAbsY.value = event.absoluteY;
738
+ if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
739
+ ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
740
+ ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
741
+ } else {
742
+ moveOffset.value = event.translationY;
743
+ moveOffsetX.value = event.translationX;
744
+ }
745
+ if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
746
+ const fx = event.absoluteX - pagerLeftSV.value;
747
+ const dir = fx > pagerWidthSV.value - EDGE_ZONE_PX ? 1 : fx < EDGE_ZONE_PX ? -1 : 0;
748
+ if (dir !== edgeDir.value) {
749
+ edgeDir.value = dir;
750
+ if (dir === 0) runOnJS(disarmEdge)();
751
+ else runOnJS(armEdge)(dir);
752
+ }
753
+ }
644
754
  }).onEnd((event) => {
755
+ if (lifted.value) return;
645
756
  const minuteDelta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
646
757
  const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
647
- const dayDelta = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1) - dayIndex;
758
+ const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
759
+ const dayDelta = targetDay - dayIndex;
648
760
  if (minuteDelta === 0 && dayDelta === 0) {
649
761
  moveOffset.value = 0;
650
762
  moveOffsetX.value = 0;
@@ -652,23 +764,51 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
652
764
  }
653
765
  moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
654
766
  moveOffsetX.value = dayDelta * dayWidth;
655
- const totalDelta = minuteDelta + dayDelta * MINUTES_PER_DAY;
767
+ const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
656
768
  runOnJS(commitDrag)(totalDelta, totalDelta);
769
+ }).onFinalize(() => {
770
+ dragZ.value = 0;
771
+ if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
772
+ runOnJS(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
773
+ moveOffset.value = 0;
774
+ moveOffsetX.value = 0;
775
+ lifted.value = 0;
776
+ }
777
+ runOnJS(releaseEdge)();
657
778
  });
658
779
  return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
659
780
  }, [
660
- draggable,
781
+ canMove,
661
782
  snapMinutes,
662
783
  cellHeight,
663
784
  moveOffset,
664
785
  moveOffsetX,
786
+ dragZ,
787
+ edgeDir,
788
+ lifted,
789
+ grabX,
790
+ grabY,
791
+ liveAbsX,
792
+ liveAbsY,
793
+ pagerLeftSV,
794
+ pagerTopSV,
795
+ pagerWidthSV,
796
+ ghostXSV,
797
+ ghostYSV,
798
+ commitLiftedDrop,
665
799
  dayWidth,
666
800
  dayIndex,
667
801
  dayCount,
802
+ dayOrdinals,
668
803
  commitDrag,
669
- notifyDragStart
804
+ notifyDragStart,
805
+ onEdgeAdvance,
806
+ armEdge,
807
+ disarmEdge,
808
+ releaseEdge
670
809
  ]);
671
810
  const resizeGesture = useMemo(() => Gesture.Pan().enabled(resizable).onStart(() => {
811
+ dragZ.value = DRAG_EVENT_Z;
672
812
  runOnJS(notifyDragStart)();
673
813
  }).onUpdate((event) => {
674
814
  resizeDelta.value = event.translationY;
@@ -680,35 +820,70 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
680
820
  }
681
821
  resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
682
822
  runOnJS(commitDrag)(0, delta);
823
+ }).onFinalize(() => {
824
+ dragZ.value = 0;
683
825
  }), [
684
826
  resizable,
685
827
  snapMinutes,
686
828
  cellHeight,
687
829
  resizeDelta,
830
+ dragZ,
831
+ commitDrag,
832
+ notifyDragStart
833
+ ]);
834
+ const resizeStartGesture = useMemo(() => Gesture.Pan().enabled(resizableFromStart).onStart(() => {
835
+ dragZ.value = DRAG_EVENT_Z;
836
+ runOnJS(notifyDragStart)();
837
+ }).onUpdate((event) => {
838
+ resizeStartDelta.value = event.translationY;
839
+ }).onEnd((event) => {
840
+ const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
841
+ if (delta === 0) {
842
+ resizeStartDelta.value = 0;
843
+ return;
844
+ }
845
+ resizeStartDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
846
+ runOnJS(commitDrag)(delta, 0);
847
+ }).onFinalize(() => {
848
+ dragZ.value = 0;
849
+ }), [
850
+ resizableFromStart,
851
+ snapMinutes,
852
+ cellHeight,
853
+ resizeStartDelta,
854
+ dragZ,
688
855
  commitDrag,
689
856
  notifyDragStart
690
857
  ]);
691
858
  const handlePress = () => onPress(positioned.event);
692
- const handleLongPress = !draggable && onLongPress ? () => onLongPress(positioned.event) : void 0;
859
+ const handleLongPress = !canMove && onLongPress ? () => onLongPress(positioned.event) : void 0;
693
860
  const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
694
- const accessibilityActions = draggable ? [
695
- {
861
+ const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
862
+ const dragActions = [
863
+ ...canMove ? [{
696
864
  name: "move-later",
697
865
  label: `Move ${unit(snapMinutes)} later`
698
- },
699
- {
866
+ }, {
700
867
  name: "move-earlier",
701
868
  label: `Move ${unit(snapMinutes)} earlier`
702
- },
869
+ }] : [],
703
870
  ...resizable ? [{
704
871
  name: "extend",
705
872
  label: `Extend by ${unit(snapMinutes)}`
706
873
  }, {
707
874
  name: "shrink",
708
875
  label: `Shorten by ${unit(snapMinutes)}`
876
+ }] : [],
877
+ ...canMove ? [{
878
+ name: "move-next-page",
879
+ label: `Move to next ${pageUnit}`
880
+ }, {
881
+ name: "move-previous-page",
882
+ label: `Move to previous ${pageUnit}`
709
883
  }] : []
710
- ] : void 0;
711
- const handleAccessibilityAction = draggable ? (e) => {
884
+ ];
885
+ const accessibilityActions = dragActions.length ? dragActions : void 0;
886
+ const handleAccessibilityAction = accessibilityActions ? (e) => {
712
887
  switch (e.nativeEvent.actionName) {
713
888
  case "move-later":
714
889
  commitDrag(snapMinutes, snapMinutes);
@@ -722,6 +897,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
722
897
  case "shrink":
723
898
  commitDrag(0, -snapMinutes);
724
899
  break;
900
+ case "move-next-page":
901
+ commitDrag(daysPerPage * MINUTES_PER_DAY, daysPerPage * MINUTES_PER_DAY);
902
+ break;
903
+ case "move-previous-page":
904
+ commitDrag(-daysPerPage * MINUTES_PER_DAY, -daysPerPage * MINUTES_PER_DAY);
905
+ break;
725
906
  }
726
907
  } : void 0;
727
908
  const eventSlot = slot("event", {
@@ -734,25 +915,35 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
734
915
  const box = /* @__PURE__ */ jsxs(Animated.View, {
735
916
  ...eventSlot,
736
917
  style: [eventSlot.style, boxStyle],
737
- children: [/* @__PURE__ */ jsx(RenderEventComponent, {
738
- event: positioned.event,
739
- mode,
740
- boxHeight,
741
- continuesBefore: positioned.continuesBefore,
742
- continuesAfter: positioned.continuesAfter,
743
- accessibilityActions,
744
- onAccessibilityAction: handleAccessibilityAction,
745
- onPress: handlePress,
746
- onLongPress: handleLongPress
747
- }), resizable ? /* @__PURE__ */ jsx(GestureDetector, {
748
- gesture: resizeGesture,
749
- children: /* @__PURE__ */ jsx(Animated.View, {
750
- style: styles$1.resizeHandle,
751
- children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
752
- })
753
- }) : null]
918
+ children: [
919
+ /* @__PURE__ */ jsx(RenderEventComponent, {
920
+ event: positioned.event,
921
+ mode,
922
+ boxHeight,
923
+ continuesBefore: positioned.continuesBefore,
924
+ continuesAfter: positioned.continuesAfter,
925
+ accessibilityActions,
926
+ onAccessibilityAction: handleAccessibilityAction,
927
+ onPress: handlePress,
928
+ onLongPress: handleLongPress
929
+ }),
930
+ resizableFromStart ? /* @__PURE__ */ jsx(GestureDetector, {
931
+ gesture: resizeStartGesture,
932
+ children: /* @__PURE__ */ jsx(Animated.View, {
933
+ style: styles$1.resizeHandleTop,
934
+ children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
935
+ })
936
+ }) : null,
937
+ resizable ? /* @__PURE__ */ jsx(GestureDetector, {
938
+ gesture: resizeGesture,
939
+ children: /* @__PURE__ */ jsx(Animated.View, {
940
+ style: styles$1.resizeHandle,
941
+ children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
942
+ })
943
+ }) : null
944
+ ]
754
945
  });
755
- if (!draggable) return box;
946
+ if (!canMove) return box;
756
947
  return /* @__PURE__ */ jsx(GestureDetector, {
757
948
  gesture: moveGesture,
758
949
  children: box
@@ -825,7 +1016,7 @@ const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) =>
825
1016
  style: [lineSlot.style, animatedStyle]
826
1017
  });
827
1018
  };
828
- const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color }) => {
1019
+ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", children }) => {
829
1020
  const slot = useSlots();
830
1021
  const animatedStyle = useAnimatedStyle(() => ({
831
1022
  top: (startHour - minHour) * cellHeight.value,
@@ -835,7 +1026,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
835
1026
  endHour,
836
1027
  minHour
837
1028
  ]);
838
- const bandSlot = slot("businessHours", {
1029
+ const bandSlot = slot(slotName, {
839
1030
  base: [
840
1031
  styles$1.shadeBand,
841
1032
  styles$1.nonInteractive,
@@ -844,18 +1035,25 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
844
1035
  width
845
1036
  }
846
1037
  ],
847
- themed: { backgroundColor: color }
1038
+ themed: color === void 0 ? void 0 : { backgroundColor: color }
848
1039
  });
849
1040
  return /* @__PURE__ */ jsx(Animated.View, {
850
- testID: "business-hours-shade",
1041
+ testID,
1042
+ accessibilityElementsHidden: true,
1043
+ importantForAccessibility: "no-hide-descendants",
851
1044
  ...bandSlot,
852
- style: [bandSlot.style, animatedStyle]
1045
+ style: [bandSlot.style, animatedStyle],
1046
+ children
853
1047
  });
854
1048
  };
855
- function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent }) {
1049
+ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowTimeZone, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, highlightWeekends, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderBusinessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, eventStartEditable, eventDurationEditable, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, onGridTop }) {
856
1050
  const theme = useCalendarTheme();
857
1051
  const slot = useSlots();
858
1052
  const scrollRef = useAnimatedRef();
1053
+ const gridTopRef = useRef(0);
1054
+ useEffect(() => {
1055
+ if (isActive) onGridTop?.(gridTopRef.current);
1056
+ }, [isActive, onGridTop]);
859
1057
  const heightSource = isActive ? cellHeight : committedCellHeight;
860
1058
  const isDragging = useSharedValue(false);
861
1059
  const isActiveShared = useSharedValue(isActive);
@@ -891,17 +1089,20 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
891
1089
  if (isWeb$1 || !active || active === previous) return;
892
1090
  scrollTo(scrollRef, 0, scrollY.value, false);
893
1091
  });
894
- const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
1092
+ const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
895
1093
  mode,
896
1094
  date,
897
1095
  weekStartsOn,
898
1096
  numberOfDays,
899
1097
  isRTL,
900
- weekEndsOn
1098
+ weekEndsOn,
1099
+ hiddenDays
901
1100
  ]);
1101
+ const daysPerPage = pageStepDays(mode, date, weekStartsOn, numberOfDays);
902
1102
  const dayCount = days.length;
903
1103
  const dayWidth = (width - hourColumnWidth) / dayCount;
904
1104
  const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
1105
+ const dayOrdinals = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[0])), [days]);
905
1106
  const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
906
1107
  const cellDateFromTouch = (event) => {
907
1108
  const { locationX, locationY } = event.nativeEvent;
@@ -923,8 +1124,11 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
923
1124
  if (date) onLongPressCell?.(date);
924
1125
  };
925
1126
  const hoursRange = useMemo(() => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index), [minHour, maxHour]);
926
- const now = useNow(showNowIndicator && isActive);
927
- const nowDayIndex = days.findIndex((day) => getIsToday$1(day));
1127
+ const now = useNow$1(showNowIndicator && isActive, {
1128
+ now: nowProp,
1129
+ timeZone: nowTimeZone
1130
+ });
1131
+ const nowDayIndex = days.findIndex((day) => isSameCalendarDay$1(day, now));
928
1132
  const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
929
1133
  const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
930
1134
  const fullHeightStyle = useAnimatedStyle(() => ({ height: (maxHour - minHour) * heightSource.value }), [
@@ -1102,6 +1306,10 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
1102
1306
  scrollEnabled: verticalScrollEnabled,
1103
1307
  onScroll: scrollHandler,
1104
1308
  scrollEventThrottle: 16,
1309
+ onLayout: (event) => {
1310
+ gridTopRef.current = event.nativeEvent.layout.y;
1311
+ if (isActive) onGridTop?.(gridTopRef.current);
1312
+ },
1105
1313
  contentContainerStyle: { paddingTop: HOUR_LABEL_TOP_INSET },
1106
1314
  contentOffset: {
1107
1315
  x: 0,
@@ -1115,7 +1323,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
1115
1323
  children: cellLayer
1116
1324
  }) : cellLayer,
1117
1325
  days.map((day, dayIndex) => {
1118
- if (!isWeekend$1(day)) return null;
1326
+ if (!highlightWeekends || !isWeekend$1(day)) return null;
1119
1327
  const shadeSlot = slot("weekendShade", {
1120
1328
  base: [
1121
1329
  styles$1.weekendColumn,
@@ -1128,6 +1336,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
1128
1336
  themed: { backgroundColor: theme.colors.weekendBackground }
1129
1337
  });
1130
1338
  return /* @__PURE__ */ jsx(Animated.View, {
1339
+ testID: "weekend-shade",
1131
1340
  ...shadeSlot,
1132
1341
  style: [shadeSlot.style, fullHeightStyle]
1133
1342
  }, `weekend-${day.toISOString()}`);
@@ -1152,8 +1361,28 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
1152
1361
  minHour,
1153
1362
  left: dayLeft(dayIndex),
1154
1363
  width: dayWidth,
1155
- color: theme.colors.outsideHoursBackground
1364
+ color: renderBusinessHours ? void 0 : theme.colors.outsideHoursBackground,
1365
+ children: renderBusinessHours?.({
1366
+ date: day,
1367
+ start: band.start,
1368
+ end: band.end
1369
+ })
1156
1370
  }, `closed-${day.toISOString()}-${bandIndex}`))) : null,
1371
+ days.flatMap((day, dayIndex) => backgroundBandsForDay$1(events, day).map((b) => ({
1372
+ ...b,
1373
+ startHours: Math.max(b.startHours, minHour),
1374
+ endHours: Math.min(b.endHours, maxHour)
1375
+ })).filter((b) => b.endHours > b.startHours).map((b, bandIndex) => /* @__PURE__ */ jsx(ShadeBand, {
1376
+ cellHeight: heightSource,
1377
+ startHour: b.startHours,
1378
+ endHour: b.endHours,
1379
+ minHour,
1380
+ left: dayLeft(dayIndex),
1381
+ width: dayWidth,
1382
+ color: theme.colors.backgroundEvent,
1383
+ slotName: "backgroundEvent",
1384
+ testID: "background-event-shade"
1385
+ }, `bg-${day.toISOString()}-${bandIndex}`))),
1157
1386
  days.map((day, dayIndex) => {
1158
1387
  const separatorSlot = slot("daySeparator", {
1159
1388
  base: [
@@ -1195,14 +1424,19 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
1195
1424
  dayWidth,
1196
1425
  dayIndex,
1197
1426
  dayCount: days.length,
1427
+ dayOrdinals,
1198
1428
  mode,
1429
+ daysPerPage,
1199
1430
  renderEvent,
1200
1431
  snapMinutes,
1201
1432
  showDragHandle,
1433
+ eventStartEditable,
1434
+ eventDurationEditable,
1202
1435
  onPress: onPressEvent,
1203
1436
  onLongPress: onLongPressEvent,
1204
1437
  onDragEvent,
1205
- onDragStart
1438
+ onDragStart,
1439
+ onEdgeAdvance
1206
1440
  }, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
1207
1441
  })),
1208
1442
  showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
@@ -1224,7 +1458,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
1224
1458
  });
1225
1459
  }
1226
1460
  const TimetablePage = memo(TimetablePageInner);
1227
- function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, calendarCellStyle, businessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
1461
+ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
1228
1462
  const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
1229
1463
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
1230
1464
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
@@ -1233,8 +1467,17 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1233
1467
  eventAccessibilityLabel,
1234
1468
  ampm
1235
1469
  ]);
1470
+ const onDragEvent = useMemo(() => {
1471
+ if (!onDragEventProp || eventOverlap !== false) return onDragEventProp;
1472
+ return (event, start, end) => overlapsOtherEvents(events, event, start, end) ? false : onDragEventProp(event, start, end);
1473
+ }, [
1474
+ onDragEventProp,
1475
+ eventOverlap,
1476
+ events
1477
+ ]);
1236
1478
  const { width, height } = useWindowDimensions();
1237
1479
  const listRef = useRef(null);
1480
+ const pagerRef = useRef(null);
1238
1481
  const containerRef = useRef(null);
1239
1482
  const suppressCaptureUntilRef = useRef(0);
1240
1483
  const [pageHeight, setPageHeight] = useState(height);
@@ -1244,6 +1487,84 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1244
1487
  const step = weekAnchored ? 7 : viewDayCount(mode, numberOfDays);
1245
1488
  const seedDefaultY = Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR$1 - clampedMinHour) * hourHeight;
1246
1489
  const scrollY = useSharedValue(seedDefaultY);
1490
+ const pagerLeft = useSharedValue(0);
1491
+ const pagerTop = useSharedValue(0);
1492
+ const pagerWidth = useSharedValue(width);
1493
+ const [edgePagingLock, setEdgePagingLock] = useState(false);
1494
+ const ghostX = useSharedValue(0);
1495
+ const ghostY = useSharedValue(0);
1496
+ const ghostW = useSharedValue(0);
1497
+ const ghostH = useSharedValue(0);
1498
+ const ghostVisible = useSharedValue(0);
1499
+ const gridTop = useSharedValue(0);
1500
+ const [liftedEvent, setLiftedEvent] = useState(null);
1501
+ const liftedEventRef = useRef(null);
1502
+ const dropRef = useRef({
1503
+ headerDays: [],
1504
+ containerWidth,
1505
+ hourColumnWidth,
1506
+ minHour: clampedMinHour,
1507
+ snapMinutes: Math.max(1, dragStepMinutes),
1508
+ onDragEvent,
1509
+ onChangeDate
1510
+ });
1511
+ const beginLift = useCallback((event) => {
1512
+ liftedEventRef.current = event;
1513
+ setLiftedEvent(event);
1514
+ }, []);
1515
+ const clearLift = useCallback(() => {
1516
+ ghostVisible.value = 0;
1517
+ liftedEventRef.current = null;
1518
+ setLiftedEvent(null);
1519
+ setEdgePagingLock(false);
1520
+ }, [ghostVisible]);
1521
+ const commitLiftedDrop = useCallback((ghostLocalX, ghostLocalY) => {
1522
+ const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
1523
+ const ev = liftedEventRef.current;
1524
+ const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
1525
+ clearLift();
1526
+ if (!ev || !onDrag || days.length === 0) return;
1527
+ const dayWidth = (cw - hcw) / days.length;
1528
+ const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
1529
+ const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
1530
+ const minutes = Math.round(rawMinutes / snap) * snap;
1531
+ const start = new Date(days[col]);
1532
+ start.setHours(0, 0, 0, 0);
1533
+ start.setMinutes(minutes);
1534
+ if (onDrag(ev, start, new Date(start.getTime() + duration)) === false) onDate(ev.start);
1535
+ }, [
1536
+ clearLift,
1537
+ gridTop,
1538
+ scrollY,
1539
+ cellHeight
1540
+ ]);
1541
+ const handleGridTop = useCallback((y) => {
1542
+ gridTop.value = y;
1543
+ }, [gridTop]);
1544
+ const edgePaging = useMemo(() => ({
1545
+ pagerLeft,
1546
+ pagerTop,
1547
+ pagerWidth,
1548
+ lockScroll: setEdgePagingLock,
1549
+ ghostX,
1550
+ ghostY,
1551
+ ghostW,
1552
+ ghostH,
1553
+ ghostVisible,
1554
+ beginLift,
1555
+ commitLiftedDrop
1556
+ }), [
1557
+ pagerLeft,
1558
+ pagerTop,
1559
+ pagerWidth,
1560
+ ghostX,
1561
+ ghostY,
1562
+ ghostW,
1563
+ ghostH,
1564
+ ghostVisible,
1565
+ beginLift,
1566
+ commitLiftedDrop
1567
+ ]);
1247
1568
  const offsetSeedRef = useRef(null);
1248
1569
  const captureOffsetSeed = useCallback((y) => {
1249
1570
  offsetSeedRef.current = y;
@@ -1268,7 +1589,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1268
1589
  ])(date);
1269
1590
  const viewedIndexRef = useRef(activeIndex);
1270
1591
  const pendingScrollIndexRef = useRef(null);
1271
- const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
1592
+ const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
1272
1593
  mode,
1273
1594
  pageDates,
1274
1595
  activeIndex,
@@ -1276,8 +1597,18 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1276
1597
  weekStartsOn,
1277
1598
  numberOfDays,
1278
1599
  isRTL,
1279
- weekEndsOn
1600
+ weekEndsOn,
1601
+ hiddenDays
1280
1602
  ]);
1603
+ dropRef.current = {
1604
+ headerDays,
1605
+ containerWidth,
1606
+ hourColumnWidth,
1607
+ minHour: clampedMinHour,
1608
+ snapMinutes: Math.max(1, dragStepMinutes),
1609
+ onDragEvent,
1610
+ onChangeDate
1611
+ };
1281
1612
  const handleViewableItemsChanged = useCallback((info) => {
1282
1613
  if (isWeb$1) return;
1283
1614
  const settled = info.viewableItems.find((token) => token.isViewable);
@@ -1363,14 +1694,15 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1363
1694
  const raf = requestAnimationFrame(lockHorizontal);
1364
1695
  return () => cancelAnimationFrame(raf);
1365
1696
  }, [pageHeight]);
1366
- useWebPagerKeys(swipeEnabled, useCallback((delta) => {
1697
+ const goToPage = useCallback((delta) => {
1367
1698
  const target = pageDates[activeIndex + delta];
1368
1699
  if (target) onChangeDate(target);
1369
1700
  }, [
1370
1701
  pageDates,
1371
1702
  activeIndex,
1372
1703
  onChangeDate
1373
- ]));
1704
+ ]);
1705
+ useWebPagerKeys(swipeEnabled, goToPage);
1374
1706
  const reduceMotion = useReducedMotion();
1375
1707
  const handlePressCell = useMemo(() => {
1376
1708
  if (!onPressCell) return void 0;
@@ -1399,6 +1731,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1399
1731
  children: /* @__PURE__ */ jsx(TimetablePage, {
1400
1732
  mode,
1401
1733
  numberOfDays,
1734
+ hiddenDays,
1735
+ now,
1736
+ nowTimeZone: timeZone,
1402
1737
  date: item,
1403
1738
  width: containerWidth,
1404
1739
  events,
@@ -1418,11 +1753,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1418
1753
  timeslots,
1419
1754
  isRTL,
1420
1755
  showAllDayEventCell,
1756
+ highlightWeekends,
1421
1757
  showVerticalScrollIndicator,
1422
1758
  verticalScrollEnabled,
1423
1759
  hourComponent,
1424
1760
  calendarCellStyle,
1425
1761
  businessHours,
1762
+ renderBusinessHours,
1426
1763
  minHourHeight,
1427
1764
  maxHourHeight,
1428
1765
  showNowIndicator,
@@ -1430,17 +1767,22 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1430
1767
  keyExtractor,
1431
1768
  snapMinutes: Math.max(1, dragStepMinutes),
1432
1769
  showDragHandle,
1770
+ eventStartEditable,
1771
+ eventDurationEditable,
1433
1772
  onPressEvent,
1434
1773
  onLongPressEvent,
1435
1774
  onDragEvent,
1436
1775
  onDragStart,
1437
1776
  onPressCell: handlePressCell,
1438
1777
  onLongPressCell,
1439
- onCreateEvent
1778
+ onCreateEvent,
1779
+ onEdgeAdvance: goToPage,
1780
+ onGridTop: handleGridTop
1440
1781
  })
1441
1782
  }), [
1442
1783
  containerWidth,
1443
1784
  pageHeight,
1785
+ handleGridTop,
1444
1786
  mode,
1445
1787
  numberOfDays,
1446
1788
  events,
@@ -1460,6 +1802,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1460
1802
  timeslots,
1461
1803
  isRTL,
1462
1804
  showAllDayEventCell,
1805
+ highlightWeekends,
1463
1806
  showVerticalScrollIndicator,
1464
1807
  verticalScrollEnabled,
1465
1808
  hourComponent,
@@ -1472,13 +1815,19 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1472
1815
  keyExtractor,
1473
1816
  dragStepMinutes,
1474
1817
  showDragHandle,
1818
+ eventStartEditable,
1819
+ eventDurationEditable,
1475
1820
  onPressEvent,
1476
1821
  onLongPressEvent,
1477
1822
  onDragEvent,
1478
1823
  onDragStart,
1479
1824
  handlePressCell,
1480
1825
  onLongPressCell,
1481
- onCreateEvent
1826
+ onCreateEvent,
1827
+ goToPage,
1828
+ hiddenDays,
1829
+ now,
1830
+ timeZone
1482
1831
  ]);
1483
1832
  const listExtraData = useMemo(() => ({
1484
1833
  events,
@@ -1487,52 +1836,70 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1487
1836
  return /* @__PURE__ */ jsx(SlotStylesProvider, {
1488
1837
  classNames,
1489
1838
  styles: styleOverrides,
1490
- children: /* @__PURE__ */ jsxs(View, {
1491
- ref: containerRef,
1492
- style: styles$1.container,
1493
- children: [
1494
- renderHeader ? renderHeader(headerDays) : /* @__PURE__ */ jsx(DefaultHeader, {
1495
- days: headerDays,
1496
- mode,
1497
- width: containerWidth,
1498
- hourColumnWidth,
1499
- showWeekNumber,
1500
- weekNumberPrefix,
1501
- weekdayFormat,
1502
- locale,
1503
- activeDate,
1504
- onPressDateHeader
1505
- }),
1506
- headerComponent,
1507
- /* @__PURE__ */ jsx(View, {
1508
- style: styles$1.pager,
1509
- onLayout: (event) => {
1510
- setPageHeight(event.nativeEvent.layout.height);
1511
- setContainerWidth(event.nativeEvent.layout.width);
1512
- setMeasured(true);
1513
- },
1514
- children: /* @__PURE__ */ jsx(LegendList, {
1515
- ref: listRef,
1516
- style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
1517
- data: pageDates,
1518
- extraData: listExtraData,
1519
- horizontal: true,
1520
- recycleItems: false,
1521
- keyExtractor: keyExtractorList,
1522
- getFixedItemSize,
1523
- ...isWeb$1 ? null : {
1524
- scrollEnabled: swipeEnabled,
1525
- pagingEnabled: !freeSwipe,
1526
- snapToIndices: freeSwipe ? snapToIndices : void 0
1839
+ children: /* @__PURE__ */ jsx(EdgePagingContext.Provider, {
1840
+ value: edgePaging,
1841
+ children: /* @__PURE__ */ jsxs(View, {
1842
+ ref: containerRef,
1843
+ style: styles$1.container,
1844
+ children: [
1845
+ renderHeader ? renderHeader(headerDays) : /* @__PURE__ */ jsx(DefaultHeader, {
1846
+ days: headerDays,
1847
+ mode,
1848
+ width: containerWidth,
1849
+ hourColumnWidth,
1850
+ showWeekNumber,
1851
+ weekNumberPrefix,
1852
+ weekdayFormat,
1853
+ locale,
1854
+ activeDate,
1855
+ onPressDateHeader
1856
+ }),
1857
+ headerComponent,
1858
+ /* @__PURE__ */ jsxs(View, {
1859
+ ref: pagerRef,
1860
+ style: styles$1.pager,
1861
+ onLayout: (event) => {
1862
+ setPageHeight(event.nativeEvent.layout.height);
1863
+ setContainerWidth(event.nativeEvent.layout.width);
1864
+ setMeasured(true);
1865
+ pagerRef.current?.measureInWindow((x, y, w) => {
1866
+ pagerLeft.value = x;
1867
+ pagerTop.value = y;
1868
+ pagerWidth.value = w;
1869
+ });
1527
1870
  },
1528
- initialScrollIndex: activeIndex,
1529
- showsHorizontalScrollIndicator: false,
1530
- viewabilityConfig: PAGE_VIEWABILITY,
1531
- onViewableItemsChanged: handleViewableItemsChanged,
1532
- renderItem
1533
- }, measured ? "grid" : "grid-seed")
1534
- })
1535
- ]
1871
+ children: [/* @__PURE__ */ jsx(LegendList, {
1872
+ ref: listRef,
1873
+ style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
1874
+ data: pageDates,
1875
+ extraData: listExtraData,
1876
+ horizontal: true,
1877
+ recycleItems: false,
1878
+ keyExtractor: keyExtractorList,
1879
+ getFixedItemSize,
1880
+ ...isWeb$1 ? null : {
1881
+ scrollEnabled: swipeEnabled && !edgePagingLock,
1882
+ pagingEnabled: !freeSwipe,
1883
+ snapToIndices: freeSwipe ? snapToIndices : void 0
1884
+ },
1885
+ initialScrollIndex: activeIndex,
1886
+ showsHorizontalScrollIndicator: false,
1887
+ viewabilityConfig: PAGE_VIEWABILITY,
1888
+ onViewableItemsChanged: handleViewableItemsChanged,
1889
+ renderItem
1890
+ }, measured ? "grid" : "grid-seed"), liftedEvent ? /* @__PURE__ */ jsx(DragGhost, {
1891
+ x: ghostX,
1892
+ y: ghostY,
1893
+ w: ghostW,
1894
+ h: ghostH,
1895
+ visible: ghostVisible,
1896
+ event: liftedEvent,
1897
+ mode,
1898
+ renderEvent: labeledRenderEvent
1899
+ }) : null]
1900
+ })
1901
+ ]
1902
+ })
1536
1903
  })
1537
1904
  });
1538
1905
  }
@@ -1705,6 +2072,15 @@ const styles$1 = StyleSheet.create({
1705
2072
  alignItems: "center",
1706
2073
  justifyContent: "center"
1707
2074
  },
2075
+ resizeHandleTop: {
2076
+ position: "absolute",
2077
+ left: 0,
2078
+ right: 0,
2079
+ top: 0,
2080
+ height: RESIZE_HANDLE_HEIGHT,
2081
+ alignItems: "center",
2082
+ justifyContent: "center"
2083
+ },
1708
2084
  resizeGrip: {
1709
2085
  width: 24,
1710
2086
  height: 3,
@@ -1716,6 +2092,11 @@ const styles$1 = StyleSheet.create({
1716
2092
  overflow: "hidden",
1717
2093
  padding: EVENT_GAP
1718
2094
  },
2095
+ dragGhost: {
2096
+ top: 0,
2097
+ left: 0,
2098
+ zIndex: 101
2099
+ },
1719
2100
  nowIndicator: {
1720
2101
  position: "absolute",
1721
2102
  height: 2
@@ -1766,7 +2147,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
1766
2147
  * }
1767
2148
  * ```
1768
2149
  */
1769
- function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
2150
+ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
1770
2151
  const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
1771
2152
  const internalCellHeight = useSharedValue(hourHeight);
1772
2153
  const cellHeight = cellHeightProp ?? internalCellHeight;
@@ -1843,6 +2224,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
1843
2224
  events: displayEvents,
1844
2225
  maxVisibleEventCount,
1845
2226
  weekStartsOn,
2227
+ hiddenDays,
1846
2228
  weekdayFormat,
1847
2229
  locale,
1848
2230
  sortedMonthView,
@@ -1871,6 +2253,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
1871
2253
  date,
1872
2254
  events: displayEvents,
1873
2255
  weekStartsOn,
2256
+ hiddenDays,
1874
2257
  locale,
1875
2258
  activeDate,
1876
2259
  onPressDay,
@@ -1899,6 +2282,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
1899
2282
  hourHeight,
1900
2283
  weekStartsOn,
1901
2284
  weekdayFormat,
2285
+ hiddenDays,
2286
+ now,
2287
+ timeZone,
1902
2288
  renderEvent: resolvedRenderEvent,
1903
2289
  keyExtractor,
1904
2290
  scrollOffsetMinutes,
@@ -1906,8 +2292,13 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
1906
2292
  hideHours,
1907
2293
  timeslots,
1908
2294
  showAllDayEventCell,
2295
+ highlightWeekends,
2296
+ eventStartEditable,
2297
+ eventDurationEditable,
2298
+ eventOverlap,
1909
2299
  calendarCellStyle,
1910
2300
  businessHours,
2301
+ renderBusinessHours,
1911
2302
  showWeekNumber,
1912
2303
  weekNumberPrefix,
1913
2304
  hourComponent,
@@ -1981,41 +2372,60 @@ function DefaultBar({ event, width, height }) {
1981
2372
  }) : null]
1982
2373
  });
1983
2374
  }
1984
- function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, theme }) {
2375
+ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, resources, laneIndex, laneSize, dragActive, onDragActiveChange, theme }) {
1985
2376
  const moveX = useSharedValue(0);
2377
+ const moveCross = useSharedValue(0);
1986
2378
  const resizeW = useSharedValue(0);
1987
2379
  const latest = useRef({
1988
2380
  event: pe.event,
1989
- onDragEvent
2381
+ onDragEvent,
2382
+ resources,
2383
+ laneIndex
1990
2384
  });
1991
2385
  latest.current = {
1992
2386
  event: pe.event,
1993
- onDragEvent
2387
+ onDragEvent,
2388
+ resources,
2389
+ laneIndex
1994
2390
  };
1995
- const draggable = !pe.event.disabled;
2391
+ const laneCount = resources.length;
2392
+ const draggable = !pe.event.disabled && pe.event.draggable !== false;
1996
2393
  useEffect(() => {
2394
+ if (dragActive) return;
1997
2395
  moveX.value = 0;
2396
+ moveCross.value = 0;
1998
2397
  resizeW.value = 0;
1999
2398
  }, [
2399
+ dragActive,
2000
2400
  pe.startHours,
2001
2401
  pe.durationHours,
2002
2402
  moveX,
2403
+ moveCross,
2003
2404
  resizeW
2004
2405
  ]);
2005
2406
  const snapBack = useCallback(() => {
2006
2407
  moveX.value = 0;
2408
+ moveCross.value = 0;
2007
2409
  resizeW.value = 0;
2008
- }, [moveX, resizeW]);
2009
- const commit = useCallback((deltaStartMin, deltaEndMin) => {
2010
- const { event, onDragEvent: handler } = latest.current;
2410
+ }, [
2411
+ moveX,
2412
+ moveCross,
2413
+ resizeW
2414
+ ]);
2415
+ const commit = useCallback((deltaStartMin, deltaEndMin, laneDelta = 0) => {
2416
+ const { event, onDragEvent: handler, resources: lanes, laneIndex: lane } = latest.current;
2011
2417
  const next = resolveDraggedBounds(event.start, event.end, deltaStartMin, deltaEndMin, snapMinutes);
2012
- if (!next) {
2418
+ const target = lanes[Math.min(Math.max(lane + laneDelta, 0), lanes.length - 1)];
2419
+ if (!next || !target) {
2013
2420
  snapBack();
2014
2421
  return;
2015
2422
  }
2016
- if (handler(event, next.start, next.end) === false) snapBack();
2423
+ if (handler(event, next.start, next.end, target) === false) snapBack();
2017
2424
  }, [snapMinutes, snapBack]);
2018
2425
  const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
2426
+ const laneTitle = (lane) => lane && (lane.title || lane.id);
2427
+ const nextLane = laneTitle(resources[laneIndex + 1]);
2428
+ const previousLane = laneTitle(resources[laneIndex - 1]);
2019
2429
  const barActions = draggable ? [
2020
2430
  {
2021
2431
  name: "move-later",
@@ -2032,7 +2442,15 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
2032
2442
  {
2033
2443
  name: "shrink",
2034
2444
  label: `Shorten by ${unit(snapMinutes)}`
2035
- }
2445
+ },
2446
+ ...nextLane ? [{
2447
+ name: "move-next-lane",
2448
+ label: `Move to ${nextLane}`
2449
+ }] : [],
2450
+ ...previousLane ? [{
2451
+ name: "move-previous-lane",
2452
+ label: `Move to ${previousLane}`
2453
+ }] : []
2036
2454
  ] : void 0;
2037
2455
  const onBarAction = draggable ? (e) => {
2038
2456
  switch (e.nativeEvent.actionName) {
@@ -2048,36 +2466,61 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
2048
2466
  case "shrink":
2049
2467
  commit(0, -snapMinutes);
2050
2468
  break;
2469
+ case "move-next-lane":
2470
+ commit(0, 0, 1);
2471
+ break;
2472
+ case "move-previous-lane":
2473
+ commit(0, 0, -1);
2474
+ break;
2051
2475
  }
2052
2476
  } : void 0;
2053
2477
  const barStyle = useAnimatedStyle(() => vertical ? {
2054
- transform: [{ translateY: moveX.value }],
2478
+ transform: [{ translateY: moveX.value }, { translateX: moveCross.value }],
2055
2479
  height: Math.max(height + resizeW.value, 2)
2056
2480
  } : {
2057
- transform: [{ translateX: moveX.value }],
2481
+ transform: [{ translateX: moveX.value }, { translateY: moveCross.value }],
2058
2482
  width: Math.max(width + resizeW.value, 2)
2059
2483
  }, [
2060
2484
  vertical,
2061
2485
  width,
2062
2486
  height
2063
2487
  ]);
2064
- const moveGesture = useMemo(() => Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onUpdate((e) => {
2488
+ const laneId = resources[laneIndex]?.id ?? "";
2489
+ const moveGesture = useMemo(() => Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
2490
+ runOnJS(onDragActiveChange)(laneId);
2491
+ }).onUpdate((e) => {
2065
2492
  moveX.value = vertical ? e.translationY : e.translationX;
2493
+ if (laneSize > 0 && laneCount > 1) {
2494
+ const cross = vertical ? e.translationX : e.translationY;
2495
+ moveCross.value = Math.min(Math.max(cross, -laneIndex * laneSize), (laneCount - 1 - laneIndex) * laneSize);
2496
+ }
2066
2497
  }).onEnd((e) => {
2067
2498
  const delta = snapDeltaMinutes(vertical ? e.translationY : e.translationX, hourSize, snapMinutes);
2068
- if (delta === 0) {
2499
+ const cross = laneSize > 0 ? vertical ? e.translationX : e.translationY : 0;
2500
+ const laneDelta = laneSize > 0 ? Math.min(Math.max(Math.round(cross / laneSize), -laneIndex), laneCount - 1 - laneIndex) : 0;
2501
+ if (delta === 0 && laneDelta === 0) {
2069
2502
  moveX.value = 0;
2503
+ moveCross.value = 0;
2070
2504
  return;
2071
2505
  }
2072
2506
  moveX.value = delta / MINUTES_PER_HOUR * hourSize;
2073
- runOnJS(commit)(delta, delta);
2507
+ moveCross.value = laneDelta * laneSize;
2508
+ runOnJS(commit)(delta, delta, laneDelta);
2509
+ }).onFinalize(() => {
2510
+ runOnJS(onDragActiveChange)(null);
2074
2511
  }), [
2075
2512
  draggable,
2076
2513
  vertical,
2077
2514
  hourSize,
2078
2515
  snapMinutes,
2516
+ laneSize,
2517
+ laneCount,
2518
+ laneIndex,
2519
+ laneId,
2079
2520
  moveX,
2080
- commit
2521
+ moveCross,
2522
+ commit,
2523
+ onDragActiveChange
2081
2524
  ]);
2082
2525
  const resizeGesture = useMemo(() => Gesture.Pan().enabled(draggable).onUpdate((e) => {
2083
2526
  resizeW.value = vertical ? e.translationY : e.translationX;
@@ -2263,11 +2706,57 @@ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, s
2263
2706
  * />
2264
2707
  * ```
2265
2708
  */
2266
- 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, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, dragStepMinutes = 15 }) {
2709
+ 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, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone }) {
2267
2710
  const theme = useCalendarTheme();
2711
+ const resources = useMemo(() => {
2712
+ if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
2713
+ const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
2714
+ const page = Math.min(Math.max(resourcePage, 0), pages - 1);
2715
+ return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
2716
+ }, [
2717
+ allResources,
2718
+ resourcesPerPage,
2719
+ resourcePage
2720
+ ]);
2721
+ const [dragLaneId, setDragLaneId] = useState(null);
2722
+ const [vBodyWidth, setVBodyWidth] = useState(0);
2723
+ const vLaneSize = resources.length > 0 && vBodyWidth > GUTTER_WIDTH ? (vBodyWidth - GUTTER_WIDTH) / resources.length : 0;
2268
2724
  const Renderer = renderEvent ?? DefaultBar;
2269
2725
  const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
2726
+ const now = useNow$1(showNowIndicator, {
2727
+ now: nowProp,
2728
+ timeZone
2729
+ });
2730
+ const nowHours = now.getHours() + now.getMinutes() / 60;
2731
+ const showNow = showNowIndicator && isSameCalendarDay$1(now, date) && nowHours >= startHour && nowHours <= endHour;
2732
+ const nowLine = (vertical, hourSize) => showNow ? /* @__PURE__ */ jsx(View, {
2733
+ pointerEvents: "none",
2734
+ testID: "resource-now-indicator",
2735
+ style: [
2736
+ vertical ? {
2737
+ position: "absolute",
2738
+ left: 0,
2739
+ right: 0,
2740
+ height: 2
2741
+ } : {
2742
+ position: "absolute",
2743
+ top: 0,
2744
+ bottom: 0,
2745
+ width: 2
2746
+ },
2747
+ vertical ? { top: (nowHours - startHour) * hourSize } : { left: (nowHours - startHour) * hourSize },
2748
+ {
2749
+ backgroundColor: theme.colors.nowIndicator,
2750
+ zIndex: 2
2751
+ }
2752
+ ]
2753
+ }) : null;
2270
2754
  const bandsFor = (resource) => businessHours ? closedHourBands(date, (d) => businessHours(d, resource), startHour, endHour) : [];
2755
+ const backgroundBandsFor = (resource) => backgroundBandsForDay$1(events.filter((event) => resourceId(event) === resource.id), date).map((b) => ({
2756
+ ...b,
2757
+ startHours: Math.max(b.startHours, startHour),
2758
+ endHours: Math.min(b.endHours, endHour)
2759
+ })).filter((b) => b.endHours > b.startHours);
2271
2760
  const hours = useMemo(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
2272
2761
  const trackWidth = (endHour - startHour) * hourWidth;
2273
2762
  const byResource = useMemo(() => {
@@ -2289,9 +2778,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2289
2778
  style: styles.vroot,
2290
2779
  children: [/* @__PURE__ */ jsxs(View, {
2291
2780
  style: [styles.header, { borderBottomColor: theme.colors.gridLine }],
2292
- children: [/* @__PURE__ */ jsx(View, { style: { width: GUTTER_WIDTH } }), resources.map((resource) => /* @__PURE__ */ jsx(View, {
2781
+ children: [/* @__PURE__ */ jsx(View, { style: { width: GUTTER_WIDTH } }), resources.map((resource, index) => /* @__PURE__ */ jsx(View, {
2293
2782
  style: [styles.vheaderCell, theme.containers.resourceLabel],
2294
- children: /* @__PURE__ */ jsx(Text, {
2783
+ children: renderResourceHeader ? renderResourceHeader(resource, index) : /* @__PURE__ */ jsx(Text, {
2295
2784
  numberOfLines: 1,
2296
2785
  style: [styles.vheaderText, { color: theme.colors.text }],
2297
2786
  allowFontScaling: false,
@@ -2302,6 +2791,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2302
2791
  showsVerticalScrollIndicator: true,
2303
2792
  children: /* @__PURE__ */ jsxs(View, {
2304
2793
  style: [styles.vbody, { height: trackHeight }],
2794
+ onLayout: (event) => setVBodyWidth(event.nativeEvent.layout.width),
2305
2795
  children: [/* @__PURE__ */ jsx(View, {
2306
2796
  style: { width: GUTTER_WIDTH },
2307
2797
  children: hours.map((h) => /* @__PURE__ */ jsx(Text, {
@@ -2312,24 +2802,45 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2312
2802
  }],
2313
2803
  children: formatHour(h, { ampm })
2314
2804
  }, h))
2315
- }), resources.map((resource) => {
2805
+ }), resources.map((resource, laneIndex) => {
2316
2806
  const positioned = byResource.get(resource.id) ?? [];
2317
2807
  return /* @__PURE__ */ jsxs(View, {
2318
2808
  style: [
2319
2809
  styles.vcolumn,
2320
2810
  { borderLeftColor: theme.colors.gridLine },
2321
- theme.containers.resourceRow
2811
+ theme.containers.resourceRow,
2812
+ dragLaneId === resource.id && styles.laneLifted
2322
2813
  ],
2323
2814
  children: [
2324
2815
  bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
2325
2816
  pointerEvents: "none",
2817
+ accessibilityElementsHidden: true,
2818
+ importantForAccessibility: "no-hide-descendants",
2326
2819
  testID: "resource-hours-shade",
2820
+ style: [
2821
+ styles.vshadeBand,
2822
+ {
2823
+ top: (b.start - startHour) * hourHeight,
2824
+ height: (b.end - b.start) * hourHeight
2825
+ },
2826
+ renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
2827
+ ],
2828
+ children: renderBusinessHours?.({
2829
+ date,
2830
+ start: b.start,
2831
+ end: b.end,
2832
+ resource
2833
+ })
2834
+ }, `shade-${b.start}`)),
2835
+ backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ jsx(View, {
2836
+ pointerEvents: "none",
2837
+ testID: "background-event-shade",
2327
2838
  style: [styles.vshadeBand, {
2328
- top: (b.start - startHour) * hourHeight,
2329
- height: (b.end - b.start) * hourHeight,
2330
- backgroundColor: theme.colors.outsideHoursBackground
2839
+ top: (b.startHours - startHour) * hourHeight,
2840
+ height: (b.endHours - b.startHours) * hourHeight,
2841
+ backgroundColor: theme.colors.backgroundEvent
2331
2842
  }]
2332
- }, `shade-${b.start}`)),
2843
+ }, `bg-${i}`)),
2333
2844
  hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
2334
2845
  pointerEvents: "none",
2335
2846
  style: [styles.vgridLine, {
@@ -2337,6 +2848,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2337
2848
  backgroundColor: theme.colors.gridLine
2338
2849
  }]
2339
2850
  }, h)),
2851
+ nowLine(true, hourHeight),
2340
2852
  cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
2341
2853
  resource,
2342
2854
  vertical: true,
@@ -2360,6 +2872,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2360
2872
  if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
2361
2873
  pe,
2362
2874
  vertical: true,
2875
+ resources,
2876
+ laneIndex,
2877
+ laneSize: vLaneSize,
2878
+ dragActive: dragLaneId === resource.id,
2879
+ onDragActiveChange: setDragLaneId,
2363
2880
  hourSize: hourHeight,
2364
2881
  left,
2365
2882
  top,
@@ -2426,7 +2943,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2426
2943
  children: formatHour(h, { ampm })
2427
2944
  }, h))
2428
2945
  })]
2429
- }), resources.map((resource) => {
2946
+ }), resources.map((resource, laneIndex) => {
2430
2947
  const positioned = byResource.get(resource.id) ?? [];
2431
2948
  return /* @__PURE__ */ jsxs(View, {
2432
2949
  style: [
@@ -2435,7 +2952,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2435
2952
  height: rowHeight,
2436
2953
  borderBottomColor: theme.colors.gridLine
2437
2954
  },
2438
- theme.containers.resourceRow
2955
+ theme.containers.resourceRow,
2956
+ dragLaneId === resource.id && styles.laneLifted
2439
2957
  ],
2440
2958
  children: [/* @__PURE__ */ jsx(View, {
2441
2959
  style: [
@@ -2446,7 +2964,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2446
2964
  },
2447
2965
  theme.containers.resourceLabel
2448
2966
  ],
2449
- children: /* @__PURE__ */ jsx(Text, {
2967
+ children: renderResourceHeader ? renderResourceHeader(resource, laneIndex) : /* @__PURE__ */ jsx(Text, {
2450
2968
  numberOfLines: 1,
2451
2969
  style: { color: theme.colors.text },
2452
2970
  allowFontScaling: false,
@@ -2457,13 +2975,33 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2457
2975
  children: [
2458
2976
  bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
2459
2977
  pointerEvents: "none",
2978
+ accessibilityElementsHidden: true,
2979
+ importantForAccessibility: "no-hide-descendants",
2460
2980
  testID: "resource-hours-shade",
2981
+ style: [
2982
+ styles.hshadeBand,
2983
+ {
2984
+ left: (b.start - startHour) * hourWidth,
2985
+ width: (b.end - b.start) * hourWidth
2986
+ },
2987
+ renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
2988
+ ],
2989
+ children: renderBusinessHours?.({
2990
+ date,
2991
+ start: b.start,
2992
+ end: b.end,
2993
+ resource
2994
+ })
2995
+ }, `shade-${b.start}`)),
2996
+ backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ jsx(View, {
2997
+ pointerEvents: "none",
2998
+ testID: "background-event-shade",
2461
2999
  style: [styles.hshadeBand, {
2462
- left: (b.start - startHour) * hourWidth,
2463
- width: (b.end - b.start) * hourWidth,
2464
- backgroundColor: theme.colors.outsideHoursBackground
3000
+ left: (b.startHours - startHour) * hourWidth,
3001
+ width: (b.endHours - b.startHours) * hourWidth,
3002
+ backgroundColor: theme.colors.backgroundEvent
2465
3003
  }]
2466
- }, `shade-${b.start}`)),
3004
+ }, `bg-${i}`)),
2467
3005
  hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
2468
3006
  pointerEvents: "none",
2469
3007
  style: [styles.gridLine, {
@@ -2471,6 +3009,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2471
3009
  backgroundColor: theme.colors.gridLine
2472
3010
  }]
2473
3011
  }, h)),
3012
+ nowLine(false, hourWidth),
2474
3013
  cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
2475
3014
  resource,
2476
3015
  vertical: false,
@@ -2492,6 +3031,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
2492
3031
  if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
2493
3032
  pe,
2494
3033
  vertical: false,
3034
+ resources,
3035
+ laneIndex,
3036
+ laneSize: rowHeight,
3037
+ dragActive: dragLaneId === resource.id,
3038
+ onDragActiveChange: setDragLaneId,
2495
3039
  hourSize: hourWidth,
2496
3040
  left,
2497
3041
  top: pe.column * laneHeight,
@@ -2601,6 +3145,7 @@ const styles = StyleSheet.create({
2601
3145
  fontWeight: "600"
2602
3146
  },
2603
3147
  vbody: { flexDirection: "row" },
3148
+ laneLifted: { zIndex: 10 },
2604
3149
  vcolumn: {
2605
3150
  flex: 1,
2606
3151
  borderLeftWidth: StyleSheet.hairlineWidth
@@ -2646,4 +3191,4 @@ const styles = StyleSheet.create({
2646
3191
  }
2647
3192
  });
2648
3193
  //#endregion
2649
- export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, YearView, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useMonthGrid, weekdayFormatToken };
3194
+ export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };