@super-calendar/dom 2.12.1 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Locale } from "date-fns";
2
- import { CSSProperties, ComponentType, ReactElement, ReactNode } from "react";
3
- import { BusinessHours, BusinessHours as BusinessHours$1, BusinessHoursBand, BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarLabels, CalendarLabels as CalendarLabels$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DateSelectionConstraints as DateSelectionConstraints$1, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, ICalendarEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, TimeGridMode as TimeGridMode$1, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
2
+ import { CSSProperties, ComponentType, ReactElement, ReactNode, RefAttributes } from "react";
3
+ import { BusinessHours, BusinessHours as BusinessHours$1, BusinessHoursBand, BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarLabels as CalendarLabels$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DateSelectionConstraints as DateSelectionConstraints$1, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, ICalendarEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, TimeGridMode as TimeGridMode$1, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
4
4
  //#region src/slots.d.ts
5
5
  /**
6
6
  * Per-slot styling overrides. Give a slot a Tailwind/CSS class and/or an inline
@@ -367,7 +367,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
367
367
  weekdayFormat?: WeekdayFormat$1;
368
368
  /** Initial pixels per hour (default 48). */
369
369
  hourHeight?: number;
370
- /** Initial scroll position, in minutes from midnight (default 8:00). */
370
+ /** Vertical scroll, in minutes from midnight (default 8:00). Applied on mount and whenever it changes. */
371
371
  scrollOffsetMinutes?: number;
372
372
  /** Pinch / Ctrl-⌘-scroll to zoom the grid (default true). */
373
373
  zoomable?: boolean;
@@ -507,7 +507,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
507
507
  * <TimeGrid mode="week" date={new Date()} events={events} />
508
508
  * ```
509
509
  */
510
- export declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, minEventHeight, eventGap, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, showAllDayLabel, labels: labelsProp, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
510
+ export declare const TimeGrid: <T = unknown>(props: TimeGridProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
511
511
  //#endregion
512
512
  //#region src/Calendar.d.ts
513
513
  /**
@@ -591,7 +591,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
591
591
  * Default 1; pass 0 to let events fill their column.
592
592
  */
593
593
  eventGap?: number;
594
- /** Initial scroll position, in minutes from midnight. */
594
+ /** Vertical scroll, in minutes from midnight. Applied on mount and whenever it changes. */
595
595
  scrollOffsetMinutes?: number;
596
596
  /** Sub-divisions per hour for the grid lines. */
597
597
  timeslots?: number;
@@ -721,7 +721,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
721
721
  * <Calendar mode="week" date={new Date()} events={events} />
722
722
  * ```
723
723
  */
724
- export declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
724
+ export declare const Calendar: <T = unknown>(props: CalendarProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
725
725
  //#endregion
726
726
  //#region src/MonthList.d.ts
727
727
  /**
@@ -996,4 +996,4 @@ interface ResourceTimelineProps<T = unknown> extends SlotStyleProps<ResourceTime
996
996
  */
997
997
  export declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, className, style, classNames, styles }: ResourceTimelineProps<T>): ReactElement;
998
998
  //#endregion
999
- export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type DatePickerProps, type DatePickerSlot, type DateRange, type DateRangePickerProps, type DateSelectionConstraints, type DaySelectionState, type DomAgendaEvent, type DomAgendaEventArgs, type DomCalendarTheme, type DomMonthEvent, type DomMonthEventArgs, type DomRenderEvent, type DomRenderEventArgs, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, type MonthListProps, type MonthListSlot, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ResourceTimelineSlot, 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, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
999
+ export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type DatePickerProps, type DatePickerSlot, type DateRange, type DateRangePickerProps, type DateSelectionConstraints, type DaySelectionState, type DomAgendaEvent, type DomAgendaEventArgs, type DomCalendarTheme, type DomMonthEvent, type DomMonthEventArgs, type DomRenderEvent, type DomRenderEventArgs, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, type MonthListProps, type MonthListSlot, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ResourceTimelineSlot, 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, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Locale } from "date-fns";
2
- import { CSSProperties, ComponentType, ReactElement, ReactNode } from "react";
3
- import { BusinessHours, BusinessHours as BusinessHours$1, BusinessHoursBand, BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarLabels, CalendarLabels as CalendarLabels$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DateSelectionConstraints as DateSelectionConstraints$1, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, ICalendarEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, TimeGridMode as TimeGridMode$1, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
2
+ import { CSSProperties, ComponentType, ReactElement, ReactNode, RefAttributes } from "react";
3
+ import { BusinessHours, BusinessHours as BusinessHours$1, BusinessHoursBand, BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarLabels as CalendarLabels$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DateSelectionConstraints as DateSelectionConstraints$1, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, ICalendarEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, TimeGridMode as TimeGridMode$1, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
4
4
  //#region src/slots.d.ts
5
5
  /**
6
6
  * Per-slot styling overrides. Give a slot a Tailwind/CSS class and/or an inline
@@ -367,7 +367,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
367
367
  weekdayFormat?: WeekdayFormat$1;
368
368
  /** Initial pixels per hour (default 48). */
369
369
  hourHeight?: number;
370
- /** Initial scroll position, in minutes from midnight (default 8:00). */
370
+ /** Vertical scroll, in minutes from midnight (default 8:00). Applied on mount and whenever it changes. */
371
371
  scrollOffsetMinutes?: number;
372
372
  /** Pinch / Ctrl-⌘-scroll to zoom the grid (default true). */
373
373
  zoomable?: boolean;
@@ -507,7 +507,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
507
507
  * <TimeGrid mode="week" date={new Date()} events={events} />
508
508
  * ```
509
509
  */
510
- export declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, minEventHeight, eventGap, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, showAllDayLabel, labels: labelsProp, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
510
+ export declare const TimeGrid: <T = unknown>(props: TimeGridProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
511
511
  //#endregion
512
512
  //#region src/Calendar.d.ts
513
513
  /**
@@ -591,7 +591,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
591
591
  * Default 1; pass 0 to let events fill their column.
592
592
  */
593
593
  eventGap?: number;
594
- /** Initial scroll position, in minutes from midnight. */
594
+ /** Vertical scroll, in minutes from midnight. Applied on mount and whenever it changes. */
595
595
  scrollOffsetMinutes?: number;
596
596
  /** Sub-divisions per hour for the grid lines. */
597
597
  timeslots?: number;
@@ -721,7 +721,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
721
721
  * <Calendar mode="week" date={new Date()} events={events} />
722
722
  * ```
723
723
  */
724
- export declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
724
+ export declare const Calendar: <T = unknown>(props: CalendarProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
725
725
  //#endregion
726
726
  //#region src/MonthList.d.ts
727
727
  /**
@@ -996,4 +996,4 @@ interface ResourceTimelineProps<T = unknown> extends SlotStyleProps<ResourceTime
996
996
  */
997
997
  export declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, theme: themeOverrides, renderEvent, onPressEvent, onDragEvent, onPressCell, onCreateEvent, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, className, style, classNames, styles }: ResourceTimelineProps<T>): ReactElement;
998
998
  //#endregion
999
- export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type DatePickerProps, type DatePickerSlot, type DateRange, type DateRangePickerProps, type DateSelectionConstraints, type DaySelectionState, type DomAgendaEvent, type DomAgendaEventArgs, type DomCalendarTheme, type DomMonthEvent, type DomMonthEventArgs, type DomRenderEvent, type DomRenderEventArgs, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, type MonthListProps, type MonthListSlot, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ResourceTimelineSlot, 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, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
999
+ export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type DatePickerProps, type DatePickerSlot, type DateRange, type DateRangePickerProps, type DateSelectionConstraints, type DaySelectionState, type DomAgendaEvent, type DomAgendaEventArgs, type DomCalendarTheme, type DomMonthEvent, type DomMonthEventArgs, type DomRenderEvent, type DomRenderEventArgs, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, type MonthListProps, type MonthListSlot, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ResourceTimelineSlot, 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, daySelectionState, defaultCalendarLabels, expandRecurringEvents, getViewDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, layoutMonthWeek, nextDateRange, parseICalendar, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
package/dist/index.js CHANGED
@@ -1398,7 +1398,8 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
1398
1398
  * <TimeGrid mode="week" date={new Date()} events={events} />
1399
1399
  * ```
1400
1400
  */
1401
- function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
1401
+ const TimeGrid = (0, react.forwardRef)(TimeGridInner);
1402
+ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
1402
1403
  const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
1403
1404
  const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
1404
1405
  const slot = createSlots({
@@ -1480,6 +1481,16 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1480
1481
  (0, react.useEffect)(() => {
1481
1482
  if (scrollRef.current) scrollRef.current.scrollTop = Math.max(0, (scrollOffsetMinutes / 60 - windowStart) * hourHeightRef.current);
1482
1483
  }, [scrollOffsetMinutes, windowStart]);
1484
+ (0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, { animated = true } = {}) => {
1485
+ const el = scrollRef.current;
1486
+ if (!el) return;
1487
+ const top = Math.max(0, (minutes / 60 - windowStart) * hourHeightRef.current);
1488
+ if (animated && !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches && typeof el.scrollTo === "function") el.scrollTo({
1489
+ top,
1490
+ behavior: "smooth"
1491
+ });
1492
+ else el.scrollTop = top;
1493
+ } }), [windowStart]);
1483
1494
  (0, react.useEffect)(() => {
1484
1495
  const el = scrollRef.current;
1485
1496
  if (!el || !zoomable) return;
@@ -2486,7 +2497,10 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
2486
2497
  * <Calendar mode="week" date={new Date()} events={events} />
2487
2498
  * ```
2488
2499
  */
2489
- function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
2500
+ const Calendar = (0, react.forwardRef)(CalendarInner);
2501
+ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
2502
+ const timeGridRef = (0, react.useRef)(null);
2503
+ (0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
2490
2504
  const displayEvents = (0, react.useMemo)(() => {
2491
2505
  let out = events ?? EMPTY_EVENTS;
2492
2506
  if (out.some((e) => e.recurrence)) {
@@ -2595,6 +2609,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2595
2609
  eventAccessibilityLabel
2596
2610
  });
2597
2611
  else view = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimeGrid, {
2612
+ ref: timeGridRef,
2598
2613
  date,
2599
2614
  mode,
2600
2615
  events: displayEvents,
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LegendList } from "@legendapp/list/react";
2
2
  import { addDays, addMinutes, addMonths, addYears, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
3
- import { useEffect, useId, useMemo, useRef, useState } from "react";
3
+ import { forwardRef, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
4
4
  import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getViewDays, getViewDays as getViewDays$1, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, layoutMonthWeek as layoutMonthWeek$1, lightColors, monthCreateRange, monthDropBounds, nextDateRange, nextDateRange as nextDateRange$1, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, titleNumberOfLines, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/slots.ts
@@ -1397,7 +1397,8 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
1397
1397
  * <TimeGrid mode="week" date={new Date()} events={events} />
1398
1398
  * ```
1399
1399
  */
1400
- function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
1400
+ const TimeGrid = forwardRef(TimeGridInner);
1401
+ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
1401
1402
  const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
1402
1403
  const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
1403
1404
  const slot = createSlots({
@@ -1479,6 +1480,16 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1479
1480
  useEffect(() => {
1480
1481
  if (scrollRef.current) scrollRef.current.scrollTop = Math.max(0, (scrollOffsetMinutes / 60 - windowStart) * hourHeightRef.current);
1481
1482
  }, [scrollOffsetMinutes, windowStart]);
1483
+ useImperativeHandle(ref, () => ({ scrollToTime: (minutes, { animated = true } = {}) => {
1484
+ const el = scrollRef.current;
1485
+ if (!el) return;
1486
+ const top = Math.max(0, (minutes / 60 - windowStart) * hourHeightRef.current);
1487
+ if (animated && !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches && typeof el.scrollTo === "function") el.scrollTo({
1488
+ top,
1489
+ behavior: "smooth"
1490
+ });
1491
+ else el.scrollTop = top;
1492
+ } }), [windowStart]);
1482
1493
  useEffect(() => {
1483
1494
  const el = scrollRef.current;
1484
1495
  if (!el || !zoomable) return;
@@ -2485,7 +2496,10 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
2485
2496
  * <Calendar mode="week" date={new Date()} events={events} />
2486
2497
  * ```
2487
2498
  */
2488
- function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
2499
+ const Calendar = forwardRef(CalendarInner);
2500
+ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
2501
+ const timeGridRef = useRef(null);
2502
+ useImperativeHandle(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
2489
2503
  const displayEvents = useMemo(() => {
2490
2504
  let out = events ?? EMPTY_EVENTS;
2491
2505
  if (out.some((e) => e.recurrence)) {
@@ -2594,6 +2608,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2594
2608
  eventAccessibilityLabel
2595
2609
  });
2596
2610
  else view = /* @__PURE__ */ jsx(TimeGrid, {
2611
+ ref: timeGridRef,
2597
2612
  date,
2598
2613
  mode,
2599
2614
  events: displayEvents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/dom",
3
- "version": "2.12.1",
3
+ "version": "2.13.0",
4
4
  "description": "Virtualized month / week / day calendar and date picker for react-dom. No React Native, no react-native-web.",
5
5
  "keywords": [
6
6
  "calendar",
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@super-calendar/core": "2.12.1"
51
+ "@super-calendar/core": "2.13.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@legendapp/list": ">=3",
package/src/Calendar.tsx CHANGED
@@ -14,10 +14,15 @@ import {
14
14
  } from "date-fns";
15
15
  import {
16
16
  type CSSProperties,
17
+ type ForwardedRef,
18
+ forwardRef,
17
19
  type KeyboardEvent as ReactKeyboardEvent,
18
20
  type ReactElement,
19
21
  type ReactNode,
22
+ type RefAttributes,
23
+ useImperativeHandle,
20
24
  useMemo,
25
+ useRef,
21
26
  } from "react";
22
27
  import {
23
28
  type CalendarMode,
@@ -33,7 +38,7 @@ import {
33
38
  type WeekdayFormat,
34
39
  type WeekStartsOn,
35
40
  } from "@super-calendar/core";
36
- import type { CalendarLabels } from "@super-calendar/core";
41
+ import type { CalendarHandle, CalendarLabels } from "@super-calendar/core";
37
42
  import { Agenda, type AgendaSlot, type DomAgendaEvent } from "./Agenda";
38
43
  import { YearView, type YearViewSlot } from "./YearView";
39
44
  import { type DomMonthEvent, MonthView, type MonthViewSlot } from "./MonthView";
@@ -127,7 +132,7 @@ export interface CalendarProps<T = unknown>
127
132
  * Default 1; pass 0 to let events fill their column.
128
133
  */
129
134
  eventGap?: number;
130
- /** Initial scroll position, in minutes from midnight. */
135
+ /** Vertical scroll, in minutes from midnight. Applied on mount and whenever it changes. */
131
136
  scrollOffsetMinutes?: number;
132
137
  /** Sub-divisions per hour for the grid lines. */
133
138
  timeslots?: number;
@@ -311,79 +316,94 @@ function pageStep(
311
316
  * <Calendar mode="week" date={new Date()} events={events} />
312
317
  * ```
313
318
  */
314
- export function Calendar<T = unknown>({
315
- mode = "week",
316
- date,
317
- events,
318
- onChangeDate,
319
- weekStartsOn = 0,
320
- hiddenDays,
321
- now,
322
- numberOfDays,
323
- locale,
324
- timeZone,
325
- theme,
326
- height,
327
- className,
328
- style,
329
- onPressEvent,
330
- eventAccessibilityLabel,
331
- // time grid
332
- ampm,
333
- hourHeight,
334
- minEventHeight,
335
- eventGap,
336
- scrollOffsetMinutes,
337
- timeslots,
338
- minHour,
339
- maxHour,
340
- hideHours,
341
- showWeekNumber,
342
- weekNumberPrefix,
343
- businessHours,
344
- renderBusinessHours,
345
- renderBackgroundEvent,
346
- showNowIndicator,
347
- showAllDayEventCell,
348
- showAllDayLabel,
349
- highlightWeekends,
350
- eventStartEditable,
351
- eventDurationEditable,
352
- eventOverlap,
353
- dragStepMinutes,
354
- onPressCell,
355
- onCreateEvent,
356
- onDragStart,
357
- onDragEvent,
358
- onPressDateHeader,
359
- renderTimeEvent,
360
- hourComponent,
361
- keyboardEventNavigation,
362
- // month
363
- maxVisibleEventCount,
364
- moreLabel,
365
- labels,
366
- showAdjacentMonths,
367
- showTitle,
368
- weekdayFormat,
369
- fillCellOnSelection,
370
- selectedRange,
371
- selectedDates,
372
- minDate,
373
- maxDate,
374
- isDateDisabled,
375
- keyboardDayNavigation,
376
- onPressDay,
377
- onSelectDrag,
378
- onPressMonth,
379
- onPressMore,
380
- renderMonthEvent,
381
- // schedule
382
- renderScheduleEvent,
383
- // styling
384
- classNames,
385
- styles,
386
- }: CalendarProps<T>): ReactElement {
319
+ export const Calendar = forwardRef(CalendarInner) as <T = unknown>(
320
+ props: CalendarProps<T> & RefAttributes<CalendarHandle>,
321
+ ) => ReactElement;
322
+
323
+ function CalendarInner<T = unknown>(
324
+ {
325
+ mode = "week",
326
+ date,
327
+ events,
328
+ onChangeDate,
329
+ weekStartsOn = 0,
330
+ hiddenDays,
331
+ now,
332
+ numberOfDays,
333
+ locale,
334
+ timeZone,
335
+ theme,
336
+ height,
337
+ className,
338
+ style,
339
+ onPressEvent,
340
+ eventAccessibilityLabel,
341
+ // time grid
342
+ ampm,
343
+ hourHeight,
344
+ minEventHeight,
345
+ eventGap,
346
+ scrollOffsetMinutes,
347
+ timeslots,
348
+ minHour,
349
+ maxHour,
350
+ hideHours,
351
+ showWeekNumber,
352
+ weekNumberPrefix,
353
+ businessHours,
354
+ renderBusinessHours,
355
+ renderBackgroundEvent,
356
+ showNowIndicator,
357
+ showAllDayEventCell,
358
+ showAllDayLabel,
359
+ highlightWeekends,
360
+ eventStartEditable,
361
+ eventDurationEditable,
362
+ eventOverlap,
363
+ dragStepMinutes,
364
+ onPressCell,
365
+ onCreateEvent,
366
+ onDragStart,
367
+ onDragEvent,
368
+ onPressDateHeader,
369
+ renderTimeEvent,
370
+ hourComponent,
371
+ keyboardEventNavigation,
372
+ // month
373
+ maxVisibleEventCount,
374
+ moreLabel,
375
+ labels,
376
+ showAdjacentMonths,
377
+ showTitle,
378
+ weekdayFormat,
379
+ fillCellOnSelection,
380
+ selectedRange,
381
+ selectedDates,
382
+ minDate,
383
+ maxDate,
384
+ isDateDisabled,
385
+ keyboardDayNavigation,
386
+ onPressDay,
387
+ onSelectDrag,
388
+ onPressMonth,
389
+ onPressMore,
390
+ renderMonthEvent,
391
+ // schedule
392
+ renderScheduleEvent,
393
+ // styling
394
+ classNames,
395
+ styles,
396
+ }: CalendarProps<T>,
397
+ ref: ForwardedRef<CalendarHandle>,
398
+ ): ReactElement {
399
+ const timeGridRef = useRef<CalendarHandle>(null);
400
+ useImperativeHandle(
401
+ ref,
402
+ () => ({
403
+ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options),
404
+ }),
405
+ [],
406
+ );
387
407
  // Materialise recurring events over the range this mode renders, then apply the
388
408
  // display zone. Non-recurring and already-expanded events pass through
389
409
  // untouched, so identity is preserved for the common (no-recurrence) case.
@@ -503,6 +523,7 @@ export function Calendar<T = unknown>({
503
523
  } else {
504
524
  view = (
505
525
  <TimeGrid<T>
526
+ ref={timeGridRef}
506
527
  date={date}
507
528
  mode={mode}
508
529
  events={displayEvents}
package/src/TimeGrid.tsx CHANGED
@@ -10,11 +10,15 @@ import {
10
10
  import {
11
11
  type ComponentType,
12
12
  type CSSProperties,
13
+ type ForwardedRef,
14
+ forwardRef,
13
15
  type KeyboardEvent as ReactKeyboardEvent,
14
16
  type PointerEvent as ReactPointerEvent,
15
17
  type ReactElement,
16
18
  type ReactNode,
19
+ type RefAttributes,
17
20
  useEffect,
21
+ useImperativeHandle,
18
22
  useMemo,
19
23
  useRef,
20
24
  useState,
@@ -23,6 +27,7 @@ import {
23
27
  type BusinessHours,
24
28
  type BusinessHoursBand,
25
29
  type CalendarEvent,
30
+ type CalendarHandle,
26
31
  type CalendarMode,
27
32
  cellRangeFromDrag,
28
33
  clampMoveStartMinutes,
@@ -151,7 +156,7 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
151
156
  weekdayFormat?: WeekdayFormat;
152
157
  /** Initial pixels per hour (default 48). */
153
158
  hourHeight?: number;
154
- /** Initial scroll position, in minutes from midnight (default 8:00). */
159
+ /** Vertical scroll, in minutes from midnight (default 8:00). Applied on mount and whenever it changes. */
155
160
  scrollOffsetMinutes?: number;
156
161
  /** Pinch / Ctrl-⌘-scroll to zoom the grid (default true). */
157
162
  zoomable?: boolean;
@@ -412,61 +417,68 @@ function DefaultDomEvent<T>({
412
417
  * <TimeGrid mode="week" date={new Date()} events={events} />
413
418
  * ```
414
419
  */
415
- export function TimeGrid<T = unknown>({
416
- date,
417
- events = [],
418
- mode = "day",
419
- numberOfDays = 1,
420
- weekStartsOn = 0,
421
- weekdayFormat = "short",
422
- hourHeight: initialHourHeight = 48,
423
- scrollOffsetMinutes = 8 * 60,
424
- zoomable = true,
425
- minHourHeight = 24,
426
- maxHourHeight = 160,
427
- minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
428
- eventGap = DEFAULT_EVENT_GAP,
429
- dragStepMinutes = 15,
430
- ampm = false,
431
- timeslots = 1,
432
- minHour = 0,
433
- maxHour = 24,
434
- hideHours = false,
435
- showWeekNumber = false,
436
- weekNumberPrefix = "W",
437
- hiddenDays,
438
- keyboardEventNavigation = false,
439
- businessHours,
440
- renderBusinessHours,
441
- renderBackgroundEvent,
442
- showNowIndicator = true,
443
- highlightWeekends = true,
444
- eventStartEditable = true,
445
- eventDurationEditable = true,
446
- eventOverlap = true,
447
- now: nowProp,
448
- timeZone,
449
- showAllDayEventCell = true,
450
- showAllDayLabel = false,
451
- labels: labelsProp,
452
- locale,
453
- theme: themeOverrides,
454
- height = 600,
455
- renderEvent,
456
- eventAccessibilityLabel,
457
- hourComponent,
458
- onPressEvent,
459
- onPressDateHeader,
460
- onPressCell,
461
- onCreateEvent,
462
- onDragStart,
463
- onDragEvent,
464
- onChangeDate,
465
- className,
466
- style,
467
- classNames,
468
- styles,
469
- }: TimeGridProps<T>): ReactElement {
420
+ export const TimeGrid = forwardRef(TimeGridInner) as <T = unknown>(
421
+ props: TimeGridProps<T> & RefAttributes<CalendarHandle>,
422
+ ) => ReactElement;
423
+
424
+ function TimeGridInner<T = unknown>(
425
+ {
426
+ date,
427
+ events = [],
428
+ mode = "day",
429
+ numberOfDays = 1,
430
+ weekStartsOn = 0,
431
+ weekdayFormat = "short",
432
+ hourHeight: initialHourHeight = 48,
433
+ scrollOffsetMinutes = 8 * 60,
434
+ zoomable = true,
435
+ minHourHeight = 24,
436
+ maxHourHeight = 160,
437
+ minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
438
+ eventGap = DEFAULT_EVENT_GAP,
439
+ dragStepMinutes = 15,
440
+ ampm = false,
441
+ timeslots = 1,
442
+ minHour = 0,
443
+ maxHour = 24,
444
+ hideHours = false,
445
+ showWeekNumber = false,
446
+ weekNumberPrefix = "W",
447
+ hiddenDays,
448
+ keyboardEventNavigation = false,
449
+ businessHours,
450
+ renderBusinessHours,
451
+ renderBackgroundEvent,
452
+ showNowIndicator = true,
453
+ highlightWeekends = true,
454
+ eventStartEditable = true,
455
+ eventDurationEditable = true,
456
+ eventOverlap = true,
457
+ now: nowProp,
458
+ timeZone,
459
+ showAllDayEventCell = true,
460
+ showAllDayLabel = false,
461
+ labels: labelsProp,
462
+ locale,
463
+ theme: themeOverrides,
464
+ height = 600,
465
+ renderEvent,
466
+ eventAccessibilityLabel,
467
+ hourComponent,
468
+ onPressEvent,
469
+ onPressDateHeader,
470
+ onPressCell,
471
+ onCreateEvent,
472
+ onDragStart,
473
+ onDragEvent,
474
+ onChangeDate,
475
+ className,
476
+ style,
477
+ classNames,
478
+ styles,
479
+ }: TimeGridProps<T>,
480
+ ref: ForwardedRef<CalendarHandle>,
481
+ ): ReactElement {
470
482
  const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
471
483
  const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
472
484
  const slot = createSlots<TimeGridSlot>({ classNames, styles });
@@ -602,6 +614,21 @@ export function TimeGrid<T = unknown>({
602
614
  );
603
615
  }, [scrollOffsetMinutes, windowStart]);
604
616
 
617
+ useImperativeHandle(
618
+ ref,
619
+ () => ({
620
+ scrollToTime: (minutes, { animated = true } = {}) => {
621
+ const el = scrollRef.current;
622
+ if (!el) return;
623
+ const top = Math.max(0, (minutes / 60 - windowStart) * hourHeightRef.current);
624
+ const smooth = animated && !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
625
+ if (smooth && typeof el.scrollTo === "function") el.scrollTo({ top, behavior: "smooth" });
626
+ else el.scrollTop = top;
627
+ },
628
+ }),
629
+ [windowStart],
630
+ );
631
+
605
632
  // Zoom: Ctrl/⌘ + wheel (native listener so we can preventDefault), plus
606
633
  // two-pointer pinch. Both scale hourHeight about the current view.
607
634
  useEffect(() => {
package/src/index.ts CHANGED
@@ -63,6 +63,7 @@ export {
63
63
  type BusinessHours,
64
64
  type BusinessHoursBand,
65
65
  type CalendarEvent,
66
+ type CalendarHandle,
66
67
  type CalendarLabels,
67
68
  defaultCalendarLabels,
68
69
  type CalendarMode,
@@ -82,6 +83,7 @@ export {
82
83
  type WeekStartsOn,
83
84
  type RecurrenceRule,
84
85
  type RecurrenceFrequency,
86
+ type ScrollToTimeOptions,
85
87
  expandRecurringEvents,
86
88
  getViewDays,
87
89
  backgroundBandsForDay,