@super-calendar/native 2.19.0 → 2.20.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/README.md CHANGED
@@ -113,6 +113,17 @@ Keep `events` stable during unrelated UI updates. With recurrence or `timeZone`,
113
113
  replacing the array rebuilds displayed events and cancels a held move on web. See
114
114
  [keep event data stable](https://super-calendar.afonsojramos.me/guides/events#keep-event-data-stable).
115
115
 
116
+ ## Vertical scrolling
117
+
118
+ In a day or week grid, set `timeGridContentPaddingBottom` to leave scrollable
119
+ space below the last hour. Set `timeGridBounces={false}` to turn off overscroll.
120
+ Use `onTimeGridScroll` to read `contentOffset`, `contentSize`, and
121
+ `layoutMeasurement` from `event.nativeEvent` on the JavaScript thread.
122
+
123
+ On the standalone `TimeGrid`, the same props are `contentPaddingBottom`,
124
+ `verticalBounces`, and `onVerticalScroll`. Both callbacks receive a
125
+ `VerticalScrollEvent`.
126
+
116
127
  ## Moving events
117
128
 
118
129
  Pass `onDragEvent` and update your event state with the returned `start` and `end`.
@@ -128,6 +139,13 @@ Set an event's `dragHandleColor` to colour its resize grips in `TimeGrid` and
128
139
  `showDragHandle={false}` still hides the time-grid grips.
129
140
  You can toggle it after mounting without replacing the `events` array.
130
141
 
142
+ ## Current-time label
143
+
144
+ Pass `renderNowLabel` to `Calendar` or `TimeGrid` to show a label beside the
145
+ current-time line. The callback receives the time in the calendar's `timeZone`.
146
+ When the line is visible, a custom label replaces hour labels less than
147
+ 15 minutes away. Return `null` to keep the ordinary hour labels.
148
+
131
149
  ## Creating events
132
150
 
133
151
  Pass `onCreateEvent` to long-press and sweep out a new event. To show a draft in
package/dist/index.d.mts CHANGED
@@ -293,6 +293,44 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
293
293
  onChangeDate: (date: Date) => void;
294
294
  /** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
295
295
  renderHeader?: (days: Date[]) => React.ReactNode;
296
+ /**
297
+ * Draw a label in the hour column when the current-time line is visible.
298
+ * A custom label replaces hour labels less than 15 minutes away.
299
+ */
300
+ renderNowLabel?: (now: Date) => React.ReactNode;
301
+ /**
302
+ * Extra scrollable space below the last hour, inside the vertical scroll view,
303
+ * so the end of the day can scroll clear of something floating over the grid
304
+ * (a tab bar, a button). Default 0.
305
+ */
306
+ contentPaddingBottom?: number;
307
+ /**
308
+ * The vertical scroll view's scroll events, on the JS thread. Use it to react
309
+ * to the hours scrolling, such as collapsing a toolbar.
310
+ */
311
+ onVerticalScroll?: (event: VerticalScrollEvent) => void;
312
+ /**
313
+ * Overscroll on the hours: iOS `bounces`, Android `overScrollMode`. Set
314
+ * `false` to stop the grid at its ends. Default true.
315
+ */
316
+ verticalBounces?: boolean;
317
+ };
318
+ /** The scroll event `onVerticalScroll` receives, shaped like React Native's scroll event. */
319
+ type VerticalScrollEvent = {
320
+ nativeEvent: {
321
+ contentOffset: {
322
+ x: number;
323
+ y: number;
324
+ };
325
+ contentSize: {
326
+ width: number;
327
+ height: number;
328
+ };
329
+ layoutMeasurement: {
330
+ width: number;
331
+ height: number;
332
+ };
333
+ };
296
334
  };
297
335
  /**
298
336
  * The timetable view used in day, 3days, week, and custom modes: an
@@ -616,6 +654,14 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
616
654
  freeSwipe?: boolean;
617
655
  /** Custom header above the week/day grid. Receives the visible days. */
618
656
  renderTimeGridHeader?: (days: Date[]) => React.ReactNode;
657
+ /** Draw a label in the hour column when the current-time line is visible. */
658
+ renderNowLabel?: (now: Date) => React.ReactNode;
659
+ /** Week/day grid: extra scrollable space below the last hour (e.g. for a floating tab bar). Default 0. */
660
+ timeGridContentPaddingBottom?: number;
661
+ /** Week/day grid: the vertical scroll view's scroll events, on the JS thread. */
662
+ onTimeGridScroll?: (event: VerticalScrollEvent) => void;
663
+ /** Week/day grid: `false` turns off overscroll on the hours (iOS bounce, Android stretch). Default true. */
664
+ timeGridBounces?: boolean;
619
665
  /** Replace the weekday-label header above the month grid. Return `null` to hide it. */
620
666
  renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
621
667
  /**
@@ -838,4 +884,4 @@ interface ResourceTimelineProps<T = unknown> {
838
884
  * ```
839
885
  */
840
886
  export declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, labels: labelsProp }: ResourceTimelineProps<T>): ReactElement;
841
- export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthDateInfo, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, nowInTimeZone, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken, zonedDragBounds, zonedEventSource };
887
+ export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthDateInfo, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type VerticalScrollEvent, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, nowInTimeZone, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken, zonedDragBounds, zonedEventSource };
package/dist/index.d.ts CHANGED
@@ -293,6 +293,44 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
293
293
  onChangeDate: (date: Date) => void;
294
294
  /** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
295
295
  renderHeader?: (days: Date[]) => React.ReactNode;
296
+ /**
297
+ * Draw a label in the hour column when the current-time line is visible.
298
+ * A custom label replaces hour labels less than 15 minutes away.
299
+ */
300
+ renderNowLabel?: (now: Date) => React.ReactNode;
301
+ /**
302
+ * Extra scrollable space below the last hour, inside the vertical scroll view,
303
+ * so the end of the day can scroll clear of something floating over the grid
304
+ * (a tab bar, a button). Default 0.
305
+ */
306
+ contentPaddingBottom?: number;
307
+ /**
308
+ * The vertical scroll view's scroll events, on the JS thread. Use it to react
309
+ * to the hours scrolling, such as collapsing a toolbar.
310
+ */
311
+ onVerticalScroll?: (event: VerticalScrollEvent) => void;
312
+ /**
313
+ * Overscroll on the hours: iOS `bounces`, Android `overScrollMode`. Set
314
+ * `false` to stop the grid at its ends. Default true.
315
+ */
316
+ verticalBounces?: boolean;
317
+ };
318
+ /** The scroll event `onVerticalScroll` receives, shaped like React Native's scroll event. */
319
+ type VerticalScrollEvent = {
320
+ nativeEvent: {
321
+ contentOffset: {
322
+ x: number;
323
+ y: number;
324
+ };
325
+ contentSize: {
326
+ width: number;
327
+ height: number;
328
+ };
329
+ layoutMeasurement: {
330
+ width: number;
331
+ height: number;
332
+ };
333
+ };
296
334
  };
297
335
  /**
298
336
  * The timetable view used in day, 3days, week, and custom modes: an
@@ -616,6 +654,14 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
616
654
  freeSwipe?: boolean;
617
655
  /** Custom header above the week/day grid. Receives the visible days. */
618
656
  renderTimeGridHeader?: (days: Date[]) => React.ReactNode;
657
+ /** Draw a label in the hour column when the current-time line is visible. */
658
+ renderNowLabel?: (now: Date) => React.ReactNode;
659
+ /** Week/day grid: extra scrollable space below the last hour (e.g. for a floating tab bar). Default 0. */
660
+ timeGridContentPaddingBottom?: number;
661
+ /** Week/day grid: the vertical scroll view's scroll events, on the JS thread. */
662
+ onTimeGridScroll?: (event: VerticalScrollEvent) => void;
663
+ /** Week/day grid: `false` turns off overscroll on the hours (iOS bounce, Android stretch). Default true. */
664
+ timeGridBounces?: boolean;
619
665
  /** Replace the weekday-label header above the month grid. Return `null` to hide it. */
620
666
  renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
621
667
  /**
@@ -838,4 +884,4 @@ interface ResourceTimelineProps<T = unknown> {
838
884
  * ```
839
885
  */
840
886
  export declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, labels: labelsProp }: ResourceTimelineProps<T>): ReactElement;
841
- export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthDateInfo, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, nowInTimeZone, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken, zonedDragBounds, zonedEventSource };
887
+ export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthDateInfo, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type VerticalScrollEvent, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, nowInTimeZone, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken, zonedDragBounds, zonedEventSource };
package/dist/index.js CHANGED
@@ -1518,9 +1518,10 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
1518
1518
  }
1519
1519
  const AnimatedEventBox = (0, react.memo)(AnimatedEventBoxInner);
1520
1520
  const hourRange = (minHour, maxHour) => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index);
1521
- const HourLabel = ({ hour, width, label, ampm, hourComponent }) => {
1521
+ const HourLabel = ({ hour, width, label, ampm, hourComponent, hidden }) => {
1522
1522
  const theme = require_MonthList.useCalendarTheme();
1523
1523
  const slot = require_MonthList.useSlots();
1524
+ if (hidden) return null;
1524
1525
  return hourComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
1525
1526
  style: { width },
1526
1527
  children: hourComponent(hour, ampm)
@@ -1555,12 +1556,24 @@ const HourLines = (0, react.memo)(function HourLines({ hours, timeslots }) {
1555
1556
  }, hour))
1556
1557
  });
1557
1558
  });
1558
- const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scrollY, showLane, showAllDayLabel, allDayLabel, headerHeight, weekNumber, ampm, hourComponent }) => {
1559
+ function getNowPosition(time, days, minHour, maxHour) {
1560
+ const hours = (0, date_fns.getHours)(time) + (0, date_fns.getMinutes)(time) / MINUTES_PER_HOUR$1;
1561
+ const dayIndex = days.findIndex((day) => (0, _super_calendar_core.isSameCalendarDay)(day, time));
1562
+ return dayIndex >= 0 && hours >= minHour && hours <= maxHour ? {
1563
+ time,
1564
+ hours,
1565
+ dayIndex
1566
+ } : null;
1567
+ }
1568
+ const NOW_LABEL_CLEARANCE_HOURS = .25;
1569
+ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scrollY, showLane, showAllDayLabel, allDayLabel, headerHeight, weekNumber, ampm, hourComponent, renderNowLabel, nowPosition }) => {
1559
1570
  const theme = require_MonthList.useCalendarTheme();
1560
1571
  const slot = require_MonthList.useSlots();
1561
1572
  const hours = (0, react.useMemo)(() => hourRange(minHour, maxHour), [minHour, maxHour]);
1573
+ const label = nowPosition && renderNowLabel?.(nowPosition.time);
1574
+ const labelHours = label == null || typeof label === "boolean" ? void 0 : nowPosition?.hours;
1562
1575
  const laneCellHeightStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ height: laneHeight.value }));
1563
- const pinStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ transform: [{ translateY: scrollY.value }] }));
1576
+ const pinStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ transform: [{ translateY: Math.max(0, scrollY.value) }] }));
1564
1577
  const rowsStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
1565
1578
  top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
1566
1579
  height: (maxHour - minHour) * cellHeight.value
@@ -1609,9 +1622,9 @@ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scro
1609
1622
  children: allDayLabel
1610
1623
  }) : null
1611
1624
  }) : null,
1612
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
1625
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native_reanimated.default.View, {
1613
1626
  style: [styles$1.gutterRows, rowsStyle],
1614
- children: hours.map((hour) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
1627
+ children: [hours.map((hour) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
1615
1628
  style: styles$1.hourCell,
1616
1629
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
1617
1630
  style: [styles$1.hourRow, styles$1.nonInteractive],
@@ -1620,10 +1633,21 @@ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scro
1620
1633
  width,
1621
1634
  label: (0, _super_calendar_core.formatHour)(hour, { ampm }),
1622
1635
  ampm,
1623
- hourComponent
1636
+ hourComponent,
1637
+ hidden: labelHours != null && Math.abs(hour - labelHours) < NOW_LABEL_CLEARANCE_HOURS
1624
1638
  })
1625
1639
  })
1626
- }, hour))
1640
+ }, hour)), labelHours != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
1641
+ style: [
1642
+ styles$1.nowLabel,
1643
+ styles$1.nonInteractive,
1644
+ {
1645
+ width,
1646
+ top: `${(labelHours - minHour) / (maxHour - minHour) * 100}%`
1647
+ }
1648
+ ],
1649
+ children: label
1650
+ }) : null]
1627
1651
  })
1628
1652
  ]
1629
1653
  });
@@ -1752,14 +1776,13 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1752
1776
  if (date) onLongPressCell?.(date);
1753
1777
  };
1754
1778
  const hoursRange = (0, react.useMemo)(() => hourRange(minHour, maxHour), [minHour, maxHour]);
1755
- const now = (0, _super_calendar_core.useNow)(showNowIndicator && isActive, {
1779
+ const tickOnPage = showNowIndicator && isActive && nowProp == null;
1780
+ const pageClock = (0, _super_calendar_core.useNow)(tickOnPage, {
1756
1781
  now: nowProp,
1757
1782
  timeZone: nowTimeZone
1758
1783
  });
1759
- const today = showNowIndicator && isActive ? now : (0, _super_calendar_core.nowInTimeZone)(nowProp, nowTimeZone);
1760
- const nowDayIndex = days.findIndex((day) => (0, _super_calendar_core.isSameCalendarDay)(day, now));
1761
- const nowHours = ((0, date_fns.getHours)(now) * MINUTES_PER_HOUR$1 + (0, date_fns.getMinutes)(now)) / MINUTES_PER_HOUR$1;
1762
- const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
1784
+ const today = tickOnPage ? pageClock : (0, _super_calendar_core.nowInTimeZone)(nowProp, nowTimeZone);
1785
+ const nowPosition = showNowIndicator ? getNowPosition(today, days, minHour, maxHour) : null;
1763
1786
  const fullHeightStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ height: (maxHour - minHour) * heightSource.value }), [
1764
1787
  minHour,
1765
1788
  maxHour,
@@ -1779,7 +1802,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1779
1802
  height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
1780
1803
  borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? react_native.StyleSheet.hairlineWidth : 0
1781
1804
  }));
1782
- const pinStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ transform: [{ translateY: scrollY.value }] }));
1805
+ const pinStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ transform: [{ translateY: Math.max(0, scrollY.value) }] }));
1783
1806
  const reportLaneLayout = (0, react.useCallback)((event) => {
1784
1807
  onLaneLayout(pageIndex, event.nativeEvent.layout.height);
1785
1808
  }, [onLaneLayout, pageIndex]);
@@ -2265,11 +2288,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
2265
2288
  minEventHeight,
2266
2289
  eventGap
2267
2290
  }) : null,
2268
- showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NowIndicator, {
2291
+ nowPosition ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NowIndicator, {
2269
2292
  cellHeight: heightSource,
2270
- nowHours,
2293
+ nowHours: nowPosition.hours,
2271
2294
  minHour,
2272
- left: dayLeft(nowDayIndex),
2295
+ left: dayLeft(nowPosition.dayIndex),
2273
2296
  width: dayWidth,
2274
2297
  color: theme.colors.nowIndicator
2275
2298
  }) : null,
@@ -2296,10 +2319,13 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
2296
2319
  });
2297
2320
  }
2298
2321
  const TimetablePage = (0, react.memo)(TimetablePageInner);
2299
- function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, 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, renderCreateGhost, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }, ref) {
2322
+ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now: nowProp, 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, renderCreateGhost, onPressDateHeader, onChangeDate, renderHeader, renderNowLabel, contentPaddingBottom = 0, onVerticalScroll, verticalBounces = true, classNames, styles: styleOverrides }, ref) {
2300
2323
  const clampedMinHour = Math.max(0, Math.min(minHour, 23));
2301
2324
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
2302
2325
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
2326
+ const hasNowLabel = showNowIndicator && renderNowLabel != null && hourColumnWidth > 0;
2327
+ const labelClock = (0, _super_calendar_core.useNow)(hasNowLabel, { now: nowProp });
2328
+ const now = nowProp ?? (hasNowLabel ? labelClock : void 0);
2303
2329
  const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
2304
2330
  const todayLabel = labels.today;
2305
2331
  const pagedHeader = renderHeader == null;
@@ -2335,7 +2361,21 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2335
2361
  const scrollY = (0, react_native_reanimated.useSharedValue)(seedDefaultY);
2336
2362
  const scrollHandler = (0, react_native_reanimated.useAnimatedScrollHandler)({ onScroll: (event) => {
2337
2363
  scrollY.value = event.contentOffset.y;
2338
- } });
2364
+ if (onVerticalScroll) (0, react_native_reanimated.runOnJS)(onVerticalScroll)({ nativeEvent: {
2365
+ contentOffset: {
2366
+ x: event.contentOffset.x,
2367
+ y: event.contentOffset.y
2368
+ },
2369
+ contentSize: {
2370
+ width: event.contentSize.width,
2371
+ height: event.contentSize.height
2372
+ },
2373
+ layoutMeasurement: {
2374
+ width: event.layoutMeasurement.width,
2375
+ height: event.layoutMeasurement.height
2376
+ }
2377
+ } });
2378
+ } }, [onVerticalScroll]);
2339
2379
  const [mountOffsetY] = (0, react.useState)(seedDefaultY);
2340
2380
  const webSeededRef = (0, react.useRef)(!isWeb$1);
2341
2381
  const seedWebScroll = (0, react.useCallback)(() => {
@@ -2519,17 +2559,17 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2519
2559
  hiddenDays,
2520
2560
  weekNumberPrefix
2521
2561
  ]);
2522
- const headerDays = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
2562
+ const activePageDate = pageDates[activeIndex] ?? date;
2563
+ const headerDays = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
2523
2564
  mode,
2524
- pageDates,
2525
- activeIndex,
2526
- date,
2565
+ activePageDate,
2527
2566
  weekStartsOn,
2528
2567
  numberOfDays,
2529
2568
  isRTL,
2530
2569
  weekEndsOn,
2531
2570
  hiddenDays
2532
2571
  ]);
2572
+ const gutterNow = hasNowLabel ? getNowPosition((0, _super_calendar_core.nowInTimeZone)(now, timeZone), headerDays, clampedMinHour, clampedMaxHour) : null;
2533
2573
  dropRef.current = {
2534
2574
  headerDays,
2535
2575
  columnsWidth,
@@ -2865,6 +2905,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2865
2905
  dragStepMinutes,
2866
2906
  minHour,
2867
2907
  maxHour,
2908
+ headerDays,
2909
+ showNowIndicator,
2868
2910
  nowTime,
2869
2911
  timeZone
2870
2912
  }), [
@@ -2877,6 +2919,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2877
2919
  dragStepMinutes,
2878
2920
  minHour,
2879
2921
  maxHour,
2922
+ headerDays,
2923
+ showNowIndicator,
2880
2924
  nowTime,
2881
2925
  timeZone
2882
2926
  ]);
@@ -2916,6 +2960,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2916
2960
  x: 0,
2917
2961
  y: mountOffsetY
2918
2962
  },
2963
+ contentContainerStyle: contentPaddingBottom > 0 ? { paddingBottom: contentPaddingBottom } : void 0,
2964
+ bounces: verticalBounces,
2965
+ overScrollMode: verticalBounces ? void 0 : "never",
2919
2966
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native_reanimated.default.View, {
2920
2967
  testID: "time-grid-hours",
2921
2968
  style: [styles$1.gridRow, gridHeightStyle],
@@ -2932,7 +2979,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2932
2979
  headerHeight: headerOffset,
2933
2980
  weekNumber,
2934
2981
  ampm,
2935
- hourComponent
2982
+ hourComponent,
2983
+ renderNowLabel,
2984
+ nowPosition: gutterNow
2936
2985
  }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
2937
2986
  ref: pagerRef,
2938
2987
  testID: "time-grid-pager",
@@ -3174,6 +3223,11 @@ const styles$1 = react_native.StyleSheet.create({
3174
3223
  textAlign: "right",
3175
3224
  paddingRight: 6
3176
3225
  },
3226
+ nowLabel: {
3227
+ position: "absolute",
3228
+ left: 0,
3229
+ marginTop: -6
3230
+ },
3177
3231
  gutterRows: {
3178
3232
  position: "absolute",
3179
3233
  left: 0,
@@ -3334,7 +3388,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn, numb
3334
3388
  * ```
3335
3389
  */
3336
3390
  const Calendar = (0, react.forwardRef)(CalendarInner);
3337
- function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, numberOfWeeks = 2, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
3391
+ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, numberOfWeeks = 2, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderNowLabel, timeGridContentPaddingBottom, onTimeGridScroll, timeGridBounces, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
3338
3392
  const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
3339
3393
  const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
3340
3394
  const cellHeight = cellHeightProp ?? internalCellHeight;
@@ -3611,6 +3665,10 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
3611
3665
  onPressDateHeader,
3612
3666
  onChangeDate: handleChangeDate,
3613
3667
  renderHeader: renderTimeGridHeader,
3668
+ renderNowLabel,
3669
+ contentPaddingBottom: timeGridContentPaddingBottom,
3670
+ onVerticalScroll: onTimeGridScroll,
3671
+ verticalBounces: timeGridBounces,
3614
3672
  classNames,
3615
3673
  styles: styleOverrides
3616
3674
  })
package/dist/index.mjs CHANGED
@@ -1495,9 +1495,10 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
1495
1495
  }
1496
1496
  const AnimatedEventBox = memo(AnimatedEventBoxInner);
1497
1497
  const hourRange = (minHour, maxHour) => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index);
1498
- const HourLabel = ({ hour, width, label, ampm, hourComponent }) => {
1498
+ const HourLabel = ({ hour, width, label, ampm, hourComponent, hidden }) => {
1499
1499
  const theme = useCalendarTheme();
1500
1500
  const slot = useSlots();
1501
+ if (hidden) return null;
1501
1502
  return hourComponent ? /* @__PURE__ */ jsx(View, {
1502
1503
  style: { width },
1503
1504
  children: hourComponent(hour, ampm)
@@ -1532,12 +1533,24 @@ const HourLines = memo(function HourLines({ hours, timeslots }) {
1532
1533
  }, hour))
1533
1534
  });
1534
1535
  });
1535
- const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scrollY, showLane, showAllDayLabel, allDayLabel, headerHeight, weekNumber, ampm, hourComponent }) => {
1536
+ function getNowPosition(time, days, minHour, maxHour) {
1537
+ const hours = getHours(time) + getMinutes(time) / MINUTES_PER_HOUR$1;
1538
+ const dayIndex = days.findIndex((day) => isSameCalendarDay$1(day, time));
1539
+ return dayIndex >= 0 && hours >= minHour && hours <= maxHour ? {
1540
+ time,
1541
+ hours,
1542
+ dayIndex
1543
+ } : null;
1544
+ }
1545
+ const NOW_LABEL_CLEARANCE_HOURS = .25;
1546
+ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scrollY, showLane, showAllDayLabel, allDayLabel, headerHeight, weekNumber, ampm, hourComponent, renderNowLabel, nowPosition }) => {
1536
1547
  const theme = useCalendarTheme();
1537
1548
  const slot = useSlots();
1538
1549
  const hours = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
1550
+ const label = nowPosition && renderNowLabel?.(nowPosition.time);
1551
+ const labelHours = label == null || typeof label === "boolean" ? void 0 : nowPosition?.hours;
1539
1552
  const laneCellHeightStyle = useAnimatedStyle(() => ({ height: laneHeight.value }));
1540
- const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
1553
+ const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: Math.max(0, scrollY.value) }] }));
1541
1554
  const rowsStyle = useAnimatedStyle(() => ({
1542
1555
  top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
1543
1556
  height: (maxHour - minHour) * cellHeight.value
@@ -1586,9 +1599,9 @@ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scro
1586
1599
  children: allDayLabel
1587
1600
  }) : null
1588
1601
  }) : null,
1589
- /* @__PURE__ */ jsx(Animated.View, {
1602
+ /* @__PURE__ */ jsxs(Animated.View, {
1590
1603
  style: [styles$1.gutterRows, rowsStyle],
1591
- children: hours.map((hour) => /* @__PURE__ */ jsx(View, {
1604
+ children: [hours.map((hour) => /* @__PURE__ */ jsx(View, {
1592
1605
  style: styles$1.hourCell,
1593
1606
  children: /* @__PURE__ */ jsx(View, {
1594
1607
  style: [styles$1.hourRow, styles$1.nonInteractive],
@@ -1597,10 +1610,21 @@ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scro
1597
1610
  width,
1598
1611
  label: formatHour(hour, { ampm }),
1599
1612
  ampm,
1600
- hourComponent
1613
+ hourComponent,
1614
+ hidden: labelHours != null && Math.abs(hour - labelHours) < NOW_LABEL_CLEARANCE_HOURS
1601
1615
  })
1602
1616
  })
1603
- }, hour))
1617
+ }, hour)), labelHours != null ? /* @__PURE__ */ jsx(View, {
1618
+ style: [
1619
+ styles$1.nowLabel,
1620
+ styles$1.nonInteractive,
1621
+ {
1622
+ width,
1623
+ top: `${(labelHours - minHour) / (maxHour - minHour) * 100}%`
1624
+ }
1625
+ ],
1626
+ children: label
1627
+ }) : null]
1604
1628
  })
1605
1629
  ]
1606
1630
  });
@@ -1729,14 +1753,13 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1729
1753
  if (date) onLongPressCell?.(date);
1730
1754
  };
1731
1755
  const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
1732
- const now = useNow$1(showNowIndicator && isActive, {
1756
+ const tickOnPage = showNowIndicator && isActive && nowProp == null;
1757
+ const pageClock = useNow$1(tickOnPage, {
1733
1758
  now: nowProp,
1734
1759
  timeZone: nowTimeZone
1735
1760
  });
1736
- const today = showNowIndicator && isActive ? now : nowInTimeZone$1(nowProp, nowTimeZone);
1737
- const nowDayIndex = days.findIndex((day) => isSameCalendarDay$1(day, now));
1738
- const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
1739
- const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
1761
+ const today = tickOnPage ? pageClock : nowInTimeZone$1(nowProp, nowTimeZone);
1762
+ const nowPosition = showNowIndicator ? getNowPosition(today, days, minHour, maxHour) : null;
1740
1763
  const fullHeightStyle = useAnimatedStyle(() => ({ height: (maxHour - minHour) * heightSource.value }), [
1741
1764
  minHour,
1742
1765
  maxHour,
@@ -1756,7 +1779,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1756
1779
  height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
1757
1780
  borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? StyleSheet.hairlineWidth : 0
1758
1781
  }));
1759
- const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
1782
+ const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: Math.max(0, scrollY.value) }] }));
1760
1783
  const reportLaneLayout = useCallback((event) => {
1761
1784
  onLaneLayout(pageIndex, event.nativeEvent.layout.height);
1762
1785
  }, [onLaneLayout, pageIndex]);
@@ -2242,11 +2265,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
2242
2265
  minEventHeight,
2243
2266
  eventGap
2244
2267
  }) : null,
2245
- showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
2268
+ nowPosition ? /* @__PURE__ */ jsx(NowIndicator, {
2246
2269
  cellHeight: heightSource,
2247
- nowHours,
2270
+ nowHours: nowPosition.hours,
2248
2271
  minHour,
2249
- left: dayLeft(nowDayIndex),
2272
+ left: dayLeft(nowPosition.dayIndex),
2250
2273
  width: dayWidth,
2251
2274
  color: theme.colors.nowIndicator
2252
2275
  }) : null,
@@ -2273,10 +2296,13 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
2273
2296
  });
2274
2297
  }
2275
2298
  const TimetablePage = memo(TimetablePageInner);
2276
- function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, 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, renderCreateGhost, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }, ref) {
2299
+ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now: nowProp, 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, renderCreateGhost, onPressDateHeader, onChangeDate, renderHeader, renderNowLabel, contentPaddingBottom = 0, onVerticalScroll, verticalBounces = true, classNames, styles: styleOverrides }, ref) {
2277
2300
  const clampedMinHour = Math.max(0, Math.min(minHour, 23));
2278
2301
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
2279
2302
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
2303
+ const hasNowLabel = showNowIndicator && renderNowLabel != null && hourColumnWidth > 0;
2304
+ const labelClock = useNow$1(hasNowLabel, { now: nowProp });
2305
+ const now = nowProp ?? (hasNowLabel ? labelClock : void 0);
2280
2306
  const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
2281
2307
  const todayLabel = labels.today;
2282
2308
  const pagedHeader = renderHeader == null;
@@ -2312,7 +2338,21 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2312
2338
  const scrollY = useSharedValue(seedDefaultY);
2313
2339
  const scrollHandler = useAnimatedScrollHandler({ onScroll: (event) => {
2314
2340
  scrollY.value = event.contentOffset.y;
2315
- } });
2341
+ if (onVerticalScroll) runOnJS(onVerticalScroll)({ nativeEvent: {
2342
+ contentOffset: {
2343
+ x: event.contentOffset.x,
2344
+ y: event.contentOffset.y
2345
+ },
2346
+ contentSize: {
2347
+ width: event.contentSize.width,
2348
+ height: event.contentSize.height
2349
+ },
2350
+ layoutMeasurement: {
2351
+ width: event.layoutMeasurement.width,
2352
+ height: event.layoutMeasurement.height
2353
+ }
2354
+ } });
2355
+ } }, [onVerticalScroll]);
2316
2356
  const [mountOffsetY] = useState(seedDefaultY);
2317
2357
  const webSeededRef = useRef(!isWeb$1);
2318
2358
  const seedWebScroll = useCallback(() => {
@@ -2496,17 +2536,17 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2496
2536
  hiddenDays,
2497
2537
  weekNumberPrefix
2498
2538
  ]);
2499
- const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
2539
+ const activePageDate = pageDates[activeIndex] ?? date;
2540
+ const headerDays = useMemo(() => getViewDays$1(mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
2500
2541
  mode,
2501
- pageDates,
2502
- activeIndex,
2503
- date,
2542
+ activePageDate,
2504
2543
  weekStartsOn,
2505
2544
  numberOfDays,
2506
2545
  isRTL,
2507
2546
  weekEndsOn,
2508
2547
  hiddenDays
2509
2548
  ]);
2549
+ const gutterNow = hasNowLabel ? getNowPosition(nowInTimeZone$1(now, timeZone), headerDays, clampedMinHour, clampedMaxHour) : null;
2510
2550
  dropRef.current = {
2511
2551
  headerDays,
2512
2552
  columnsWidth,
@@ -2842,6 +2882,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2842
2882
  dragStepMinutes,
2843
2883
  minHour,
2844
2884
  maxHour,
2885
+ headerDays,
2886
+ showNowIndicator,
2845
2887
  nowTime,
2846
2888
  timeZone
2847
2889
  }), [
@@ -2854,6 +2896,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2854
2896
  dragStepMinutes,
2855
2897
  minHour,
2856
2898
  maxHour,
2899
+ headerDays,
2900
+ showNowIndicator,
2857
2901
  nowTime,
2858
2902
  timeZone
2859
2903
  ]);
@@ -2893,6 +2937,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2893
2937
  x: 0,
2894
2938
  y: mountOffsetY
2895
2939
  },
2940
+ contentContainerStyle: contentPaddingBottom > 0 ? { paddingBottom: contentPaddingBottom } : void 0,
2941
+ bounces: verticalBounces,
2942
+ overScrollMode: verticalBounces ? void 0 : "never",
2896
2943
  children: /* @__PURE__ */ jsxs(Animated.View, {
2897
2944
  testID: "time-grid-hours",
2898
2945
  style: [styles$1.gridRow, gridHeightStyle],
@@ -2909,7 +2956,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2909
2956
  headerHeight: headerOffset,
2910
2957
  weekNumber,
2911
2958
  ampm,
2912
- hourComponent
2959
+ hourComponent,
2960
+ renderNowLabel,
2961
+ nowPosition: gutterNow
2913
2962
  }) : null, /* @__PURE__ */ jsxs(View, {
2914
2963
  ref: pagerRef,
2915
2964
  testID: "time-grid-pager",
@@ -3151,6 +3200,11 @@ const styles$1 = StyleSheet.create({
3151
3200
  textAlign: "right",
3152
3201
  paddingRight: 6
3153
3202
  },
3203
+ nowLabel: {
3204
+ position: "absolute",
3205
+ left: 0,
3206
+ marginTop: -6
3207
+ },
3154
3208
  gutterRows: {
3155
3209
  position: "absolute",
3156
3210
  left: 0,
@@ -3311,7 +3365,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn, numb
3311
3365
  * ```
3312
3366
  */
3313
3367
  const Calendar = forwardRef(CalendarInner);
3314
- function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, numberOfWeeks = 2, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
3368
+ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, numberOfWeeks = 2, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderNowLabel, timeGridContentPaddingBottom, onTimeGridScroll, timeGridBounces, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
3315
3369
  const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
3316
3370
  const internalCellHeight = useSharedValue(hourHeight);
3317
3371
  const cellHeight = cellHeightProp ?? internalCellHeight;
@@ -3588,6 +3642,10 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
3588
3642
  onPressDateHeader,
3589
3643
  onChangeDate: handleChangeDate,
3590
3644
  renderHeader: renderTimeGridHeader,
3645
+ renderNowLabel,
3646
+ contentPaddingBottom: timeGridContentPaddingBottom,
3647
+ onVerticalScroll: onTimeGridScroll,
3648
+ verticalBounces: timeGridBounces,
3591
3649
  classNames,
3592
3650
  styles: styleOverrides
3593
3651
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/native",
3
- "version": "2.19.0",
3
+ "version": "2.20.0",
4
4
  "description": "Gesture-driven, virtualized month / week / day calendar and date picker for React Native (and web via react-native-web).",
5
5
  "keywords": [
6
6
  "agenda",
@@ -64,7 +64,7 @@
64
64
  "access": "public"
65
65
  },
66
66
  "dependencies": {
67
- "@super-calendar/core": "2.19.0"
67
+ "@super-calendar/core": "2.20.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@legendapp/list": ">=3",
@@ -68,6 +68,7 @@ import {
68
68
  type HourRenderer,
69
69
  TimeGrid,
70
70
  type TimeGridSlot,
71
+ type VerticalScrollEvent,
71
72
  } from "./TimeGrid";
72
73
 
73
74
  /**
@@ -373,6 +374,14 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
373
374
  freeSwipe?: boolean;
374
375
  /** Custom header above the week/day grid. Receives the visible days. */
375
376
  renderTimeGridHeader?: (days: Date[]) => React.ReactNode;
377
+ /** Draw a label in the hour column when the current-time line is visible. */
378
+ renderNowLabel?: (now: Date) => React.ReactNode;
379
+ /** Week/day grid: extra scrollable space below the last hour (e.g. for a floating tab bar). Default 0. */
380
+ timeGridContentPaddingBottom?: number;
381
+ /** Week/day grid: the vertical scroll view's scroll events, on the JS thread. */
382
+ onTimeGridScroll?: (event: VerticalScrollEvent) => void;
383
+ /** Week/day grid: `false` turns off overscroll on the hours (iOS bounce, Android stretch). Default true. */
384
+ timeGridBounces?: boolean;
376
385
  /** Replace the weekday-label header above the month grid. Return `null` to hide it. */
377
386
  renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
378
387
  /**
@@ -590,6 +599,10 @@ function CalendarInner<T>(
590
599
  isRTL,
591
600
  freeSwipe,
592
601
  renderTimeGridHeader,
602
+ renderNowLabel,
603
+ timeGridContentPaddingBottom,
604
+ onTimeGridScroll,
605
+ timeGridBounces,
593
606
  renderHeaderForMonthView,
594
607
  renderCustomDateForMonth,
595
608
  itemSeparatorComponent,
@@ -974,6 +987,10 @@ function CalendarInner<T>(
974
987
  onPressDateHeader={onPressDateHeader}
975
988
  onChangeDate={handleChangeDate}
976
989
  renderHeader={renderTimeGridHeader}
990
+ renderNowLabel={renderNowLabel}
991
+ contentPaddingBottom={timeGridContentPaddingBottom}
992
+ onVerticalScroll={onTimeGridScroll}
993
+ verticalBounces={timeGridBounces}
977
994
  classNames={classNames}
978
995
  styles={styleOverrides}
979
996
  />
@@ -1265,12 +1265,15 @@ type HourLabelProps = {
1265
1265
  label: string;
1266
1266
  ampm: boolean;
1267
1267
  hourComponent?: HourRenderer;
1268
+ /** Leave the label out, because the now label sits on top of it. */
1269
+ hidden?: boolean;
1268
1270
  };
1269
1271
 
1270
1272
  // The hour-axis label: the consumer's `hourComponent`, or the themed text.
1271
- const HourLabel = ({ hour, width, label, ampm, hourComponent }: HourLabelProps) => {
1273
+ const HourLabel = ({ hour, width, label, ampm, hourComponent, hidden }: HourLabelProps) => {
1272
1274
  const theme = useCalendarTheme();
1273
1275
  const slot = useSlots<TimeGridSlot>();
1276
+ if (hidden) return null;
1274
1277
  return hourComponent ? (
1275
1278
  <View style={{ width }}>{hourComponent(hour, ampm)}</View>
1276
1279
  ) : (
@@ -1321,6 +1324,12 @@ const HourLines = memo(function HourLines({ hours, timeslots }: HourLinesProps)
1321
1324
  );
1322
1325
  });
1323
1326
 
1327
+ function getNowPosition(time: Date, days: Date[], minHour: number, maxHour: number) {
1328
+ const hours = getHours(time) + getMinutes(time) / MINUTES_PER_HOUR;
1329
+ const dayIndex = days.findIndex((day) => isSameCalendarDay(day, time));
1330
+ return dayIndex >= 0 && hours >= minHour && hours <= maxHour ? { time, hours, dayIndex } : null;
1331
+ }
1332
+
1324
1333
  type HourGutterProps = {
1325
1334
  width: number;
1326
1335
  minHour: number;
@@ -1343,8 +1352,14 @@ type HourGutterProps = {
1343
1352
  weekNumber: string | null;
1344
1353
  ampm: boolean;
1345
1354
  hourComponent?: HourRenderer;
1355
+ /** Draws the current time in the hour column, level with the now line. */
1356
+ renderNowLabel?: (now: Date) => React.ReactNode;
1357
+ nowPosition: ReturnType<typeof getNowPosition>;
1346
1358
  };
1347
1359
 
1360
+ // How close, in hours, an hour label may sit to the now label before it is left out.
1361
+ const NOW_LABEL_CLEARANCE_HOURS = 0.25;
1362
+
1348
1363
  // The hour-axis column beside the pager. It is part of the grid's one vertical
1349
1364
  // scroll content, so it scrolls and zooms with the pages and holds still while
1350
1365
  // they swipe. Its "all-day" cell rides the scroll offset to stay pinned at the
@@ -1364,15 +1379,24 @@ const HourGutterInner = ({
1364
1379
  weekNumber,
1365
1380
  ampm,
1366
1381
  hourComponent,
1382
+ renderNowLabel,
1383
+ nowPosition,
1367
1384
  }: HourGutterProps) => {
1368
1385
  const theme = useCalendarTheme();
1369
1386
  const slot = useSlots<TimeGridSlot>();
1370
1387
  const hours = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
1388
+ const label = nowPosition && renderNowLabel?.(nowPosition.time);
1389
+ const labelHours = label == null || typeof label === "boolean" ? undefined : nowPosition?.hours;
1371
1390
  // Height and offset are separate styles: a style that returns a transform is
1372
1391
  // re-applied every time it runs, so keeping the offset apart means a swipe
1373
1392
  // (which only moves the band's height) sends nothing to the view.
1374
1393
  const laneCellHeightStyle = useAnimatedStyle(() => ({ height: laneHeight.value }));
1375
- const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
1394
+ // Pinned to the viewport top only for real offsets. During the iOS top bounce the offset goes
1395
+ // negative, which lifted the pinned header and all-day band out of view while the hours slid
1396
+ // down; clamped at 0 they ride down with the hours instead, like a sticky header.
1397
+ const pinStyle = useAnimatedStyle(() => ({
1398
+ transform: [{ translateY: Math.max(0, scrollY.value) }],
1399
+ }));
1376
1400
  const rowsStyle = useAnimatedStyle(
1377
1401
  () => ({
1378
1402
  top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
@@ -1439,10 +1463,25 @@ const HourGutterInner = ({
1439
1463
  label={formatHour(hour, { ampm })}
1440
1464
  ampm={ampm}
1441
1465
  hourComponent={hourComponent}
1466
+ hidden={
1467
+ labelHours != null && Math.abs(hour - labelHours) < NOW_LABEL_CLEARANCE_HOURS
1468
+ }
1442
1469
  />
1443
1470
  </View>
1444
1471
  </View>
1445
1472
  ))}
1473
+ {labelHours != null ? (
1474
+ // A percentage of the rows' height, so it follows the zoom without a worklet.
1475
+ <View
1476
+ style={[
1477
+ styles.nowLabel,
1478
+ styles.nonInteractive,
1479
+ { width, top: `${((labelHours - minHour) / (maxHour - minHour)) * 100}%` },
1480
+ ]}
1481
+ >
1482
+ {label}
1483
+ </View>
1484
+ ) : null}
1446
1485
  </Animated.View>
1447
1486
  </View>
1448
1487
  );
@@ -1806,15 +1845,10 @@ function TimetablePageInner<T>({
1806
1845
 
1807
1846
  const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
1808
1847
 
1809
- const now = useNow(showNowIndicator && isActive, { now: nowProp, timeZone: nowTimeZone });
1810
- // The day the header marks as today: the indicator's clock while it runs, so
1811
- // the two can't disagree.
1812
- const today = showNowIndicator && isActive ? now : nowInTimeZone(nowProp, nowTimeZone);
1813
- // "Today" follows the (possibly zone-shifted or overridden) now, so the line
1814
- // lands in the column the events are displayed in.
1815
- const nowDayIndex = days.findIndex((day) => isSameCalendarDay(day, now));
1816
- const nowHours = (getHours(now) * MINUTES_PER_HOUR + getMinutes(now)) / MINUTES_PER_HOUR;
1817
- const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
1848
+ const tickOnPage = showNowIndicator && isActive && nowProp == null;
1849
+ const pageClock = useNow(tickOnPage, { now: nowProp, timeZone: nowTimeZone });
1850
+ const today = tickOnPage ? pageClock : nowInTimeZone(nowProp, nowTimeZone);
1851
+ const nowPosition = showNowIndicator ? getNowPosition(today, days, minHour, maxHour) : null;
1818
1852
 
1819
1853
  const fullHeightStyle = useAnimatedStyle(
1820
1854
  () => ({ height: (maxHour - minHour) * heightSource.value }),
@@ -1842,7 +1876,12 @@ function TimetablePageInner<T>({
1842
1876
  height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
1843
1877
  borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? StyleSheet.hairlineWidth : 0,
1844
1878
  }));
1845
- const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
1879
+ // Pinned to the viewport top only for real offsets. During the iOS top bounce the offset goes
1880
+ // negative, which lifted the pinned header and all-day band out of view while the hours slid
1881
+ // down; clamped at 0 they ride down with the hours instead, like a sticky header.
1882
+ const pinStyle = useAnimatedStyle(() => ({
1883
+ transform: [{ translateY: Math.max(0, scrollY.value) }],
1884
+ }));
1846
1885
  const reportLaneLayout = useCallback(
1847
1886
  (event: LayoutChangeEvent) => {
1848
1887
  onLaneLayout(pageIndex, event.nativeEvent.layout.height);
@@ -2441,12 +2480,12 @@ function TimetablePageInner<T>({
2441
2480
  />
2442
2481
  ) : null}
2443
2482
 
2444
- {showNowIndicator && nowDayIndex >= 0 && nowInWindow ? (
2483
+ {nowPosition ? (
2445
2484
  <NowIndicator
2446
2485
  cellHeight={heightSource}
2447
- nowHours={nowHours}
2486
+ nowHours={nowPosition.hours}
2448
2487
  minHour={minHour}
2449
- left={dayLeft(nowDayIndex)}
2488
+ left={dayLeft(nowPosition.dayIndex)}
2450
2489
  width={dayWidth}
2451
2490
  color={theme.colors.nowIndicator}
2452
2491
  />
@@ -2662,6 +2701,36 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
2662
2701
  onChangeDate: (date: Date) => void;
2663
2702
  /** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
2664
2703
  renderHeader?: (days: Date[]) => React.ReactNode;
2704
+ /**
2705
+ * Draw a label in the hour column when the current-time line is visible.
2706
+ * A custom label replaces hour labels less than 15 minutes away.
2707
+ */
2708
+ renderNowLabel?: (now: Date) => React.ReactNode;
2709
+ /**
2710
+ * Extra scrollable space below the last hour, inside the vertical scroll view,
2711
+ * so the end of the day can scroll clear of something floating over the grid
2712
+ * (a tab bar, a button). Default 0.
2713
+ */
2714
+ contentPaddingBottom?: number;
2715
+ /**
2716
+ * The vertical scroll view's scroll events, on the JS thread. Use it to react
2717
+ * to the hours scrolling, such as collapsing a toolbar.
2718
+ */
2719
+ onVerticalScroll?: (event: VerticalScrollEvent) => void;
2720
+ /**
2721
+ * Overscroll on the hours: iOS `bounces`, Android `overScrollMode`. Set
2722
+ * `false` to stop the grid at its ends. Default true.
2723
+ */
2724
+ verticalBounces?: boolean;
2725
+ };
2726
+
2727
+ /** The scroll event `onVerticalScroll` receives, shaped like React Native's scroll event. */
2728
+ export type VerticalScrollEvent = {
2729
+ nativeEvent: {
2730
+ contentOffset: { x: number; y: number };
2731
+ contentSize: { width: number; height: number };
2732
+ layoutMeasurement: { width: number; height: number };
2733
+ };
2665
2734
  };
2666
2735
 
2667
2736
  function TimeGridInner<T>(
@@ -2709,7 +2778,7 @@ function TimeGridInner<T>(
2709
2778
  verticalScrollEnabled = true,
2710
2779
  weekNumberPrefix = "W",
2711
2780
  hiddenDays,
2712
- now,
2781
+ now: nowProp,
2713
2782
  timeZone,
2714
2783
  hourComponent,
2715
2784
  activeDate,
@@ -2730,6 +2799,10 @@ function TimeGridInner<T>(
2730
2799
  onPressDateHeader,
2731
2800
  onChangeDate,
2732
2801
  renderHeader,
2802
+ renderNowLabel,
2803
+ contentPaddingBottom = 0,
2804
+ onVerticalScroll,
2805
+ verticalBounces = true,
2733
2806
  classNames,
2734
2807
  styles: styleOverrides,
2735
2808
  }: TimeGridProps<T>,
@@ -2740,6 +2813,10 @@ function TimeGridInner<T>(
2740
2813
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
2741
2814
  // Collapse the hour gutter to zero when hours are hidden.
2742
2815
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
2816
+ // A custom gutter label and its line must tick on the same minute, including after paging.
2817
+ const hasNowLabel = showNowIndicator && renderNowLabel != null && hourColumnWidth > 0;
2818
+ const labelClock = useNow(hasNowLabel, { now: nowProp });
2819
+ const now = nowProp ?? (hasNowLabel ? labelClock : undefined);
2743
2820
  const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
2744
2821
  const todayLabel = labels.today;
2745
2822
  // The built-in day header pages with the columns (rendered inside each page). A
@@ -2811,12 +2888,27 @@ function TimeGridInner<T>(
2811
2888
  // scrolls with the content, so a finger's window position maps into the grid
2812
2889
  // through it.
2813
2890
  const scrollY = useSharedValue(seedDefaultY);
2814
- const scrollHandler = useAnimatedScrollHandler({
2815
- onScroll: (event) => {
2816
- // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
2817
- scrollY.value = event.contentOffset.y;
2891
+ const scrollHandler = useAnimatedScrollHandler(
2892
+ {
2893
+ onScroll: (event) => {
2894
+ // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
2895
+ scrollY.value = event.contentOffset.y;
2896
+ if (onVerticalScroll) {
2897
+ runOnJS(onVerticalScroll)({
2898
+ nativeEvent: {
2899
+ contentOffset: { x: event.contentOffset.x, y: event.contentOffset.y },
2900
+ contentSize: { width: event.contentSize.width, height: event.contentSize.height },
2901
+ layoutMeasurement: {
2902
+ width: event.layoutMeasurement.width,
2903
+ height: event.layoutMeasurement.height,
2904
+ },
2905
+ },
2906
+ });
2907
+ }
2908
+ },
2818
2909
  },
2819
- });
2910
+ [onVerticalScroll],
2911
+ );
2820
2912
  // The scroll view's `contentOffset` holds the mount offset; a later
2821
2913
  // `scrollOffsetMinutes` is scrolled to by the effect further down.
2822
2914
  const [mountOffsetY] = useState(seedDefaultY);
@@ -3154,20 +3246,17 @@ function TimeGridInner<T>(
3154
3246
 
3155
3247
  // Header days track the active page (page-aligned), so they always match the
3156
3248
  // columns below and a swipe never flashes another day's label.
3249
+ const activePageDate = pageDates[activeIndex] ?? date;
3157
3250
  const headerDays = useMemo(
3158
3251
  () =>
3159
- getViewDays(
3160
- mode,
3161
- pageDates[activeIndex] ?? date,
3162
- weekStartsOn,
3163
- numberOfDays,
3164
- isRTL,
3165
- weekEndsOn,
3166
- hiddenDays,
3167
- ),
3168
- [mode, pageDates, activeIndex, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays],
3252
+ getViewDays(mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays),
3253
+ [mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays],
3169
3254
  );
3170
3255
 
3256
+ const gutterNow = hasNowLabel
3257
+ ? getNowPosition(nowInTimeZone(now, timeZone), headerDays, clampedMinHour, clampedMaxHour)
3258
+ : null;
3259
+
3171
3260
  // Keep the cross-week drop's page columns + handler current without changing the
3172
3261
  // identity-stable EdgePaging callbacks (see dropRef).
3173
3262
  dropRef.current = {
@@ -3550,7 +3639,7 @@ function TimeGridInner<T>(
3550
3639
  // `columnsWidth` resizes the mounted pages when the grid is re-measured.
3551
3640
  // `showDragHandle` refreshes grips without requiring an event-data change, and
3552
3641
  // `renderCreateGhost` swaps the preview content of mounted pages.
3553
- // `now` and `timeZone` move the today highlight and the now line.
3642
+ // Refresh mounted pages when the clock, visible days, or indicator setting changes.
3554
3643
  const nowTime = now?.getTime();
3555
3644
  const listExtraData = useMemo(
3556
3645
  () => ({
@@ -3563,6 +3652,8 @@ function TimeGridInner<T>(
3563
3652
  dragStepMinutes,
3564
3653
  minHour,
3565
3654
  maxHour,
3655
+ headerDays,
3656
+ showNowIndicator,
3566
3657
  nowTime,
3567
3658
  timeZone,
3568
3659
  }),
@@ -3576,6 +3667,8 @@ function TimeGridInner<T>(
3576
3667
  dragStepMinutes,
3577
3668
  minHour,
3578
3669
  maxHour,
3670
+ headerDays,
3671
+ showNowIndicator,
3579
3672
  nowTime,
3580
3673
  timeZone,
3581
3674
  ],
@@ -3616,6 +3709,11 @@ function TimeGridInner<T>(
3616
3709
  scrollEventThrottle={16}
3617
3710
  refreshControl={verticalScrollEnabled ? refreshControl : undefined}
3618
3711
  contentOffset={{ x: 0, y: mountOffsetY }}
3712
+ contentContainerStyle={
3713
+ contentPaddingBottom > 0 ? { paddingBottom: contentPaddingBottom } : undefined
3714
+ }
3715
+ bounces={verticalBounces}
3716
+ overScrollMode={verticalBounces ? undefined : "never"}
3619
3717
  >
3620
3718
  <Animated.View testID="time-grid-hours" style={[styles.gridRow, gridHeightStyle]}>
3621
3719
  {hourColumnWidth > 0 ? (
@@ -3633,6 +3731,8 @@ function TimeGridInner<T>(
3633
3731
  weekNumber={weekNumber}
3634
3732
  ampm={ampm}
3635
3733
  hourComponent={hourComponent}
3734
+ renderNowLabel={renderNowLabel}
3735
+ nowPosition={gutterNow}
3636
3736
  />
3637
3737
  ) : null}
3638
3738
  <View
@@ -4025,6 +4125,11 @@ const styles = StyleSheet.create({
4025
4125
  textAlign: "right",
4026
4126
  paddingRight: 6,
4027
4127
  },
4128
+ nowLabel: {
4129
+ position: "absolute",
4130
+ left: 0,
4131
+ marginTop: -HOUR_LABEL_NUDGE,
4132
+ },
4028
4133
  gutterRows: {
4029
4134
  position: "absolute",
4030
4135
  left: 0,
package/src/index.tsx CHANGED
@@ -35,6 +35,7 @@ export {
35
35
  type EventDragHandler,
36
36
  type EventDragStartHandler,
37
37
  type HourRenderer,
38
+ type VerticalScrollEvent,
38
39
  DEFAULT_HOUR_HEIGHT,
39
40
  } from "./components/TimeGrid";
40
41
  export { DefaultEvent } from "./components/DefaultEvent";