@super-calendar/native 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/{DefaultMonthEvent-B9KzVzFa.d.mts → DefaultMonthEvent-H1IQMTqK.d.ts} +3 -3
- package/dist/{DefaultMonthEvent-DlIIWDzr.d.ts → DefaultMonthEvent-eip3mlq_.d.mts} +3 -3
- package/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +39 -4
- package/dist/index.mjs +40 -5
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Calendar.tsx +126 -97
- package/src/components/TimeGrid.tsx +115 -70
- package/src/index.tsx +2 -0
- package/src/types.ts +2 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
2
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
3
|
-
import { SharedValue } from "react-native-reanimated";
|
|
4
|
-
import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
5
3
|
import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
4
|
+
import { SharedValue } from "react-native-reanimated";
|
|
5
|
+
import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
6
6
|
//#region src/theme.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The full set of colours, text styles and metrics the calendar paints with.
|
|
@@ -557,4 +557,4 @@ declare const MonthList: typeof MonthListInner;
|
|
|
557
557
|
*/
|
|
558
558
|
declare function DefaultMonthEvent<T>({ event, mode, isAllDay, ampm, showTime, ellipsizeTitle, allDayLabel, accessibilityLabel: accessibilityLabelProp, cellStyle, onPress, onLongPress }: RenderEventArgs<T>): ReactElement;
|
|
559
559
|
//#endregion
|
|
560
|
-
export {
|
|
560
|
+
export { WeekStartsOn as A, ICalendarEvent as C, RenderEventArgs as D, RenderEvent as E, darkTheme as F, defaultTheme as I, mergeTheme as L, CalendarTheme as M, CalendarThemeProvider as N, ScrollToTimeOptions as O, PartialCalendarTheme as P, useCalendarTheme as R, EventKeyExtractor as S, RecurrenceRule as T, CalendarMode$1 as _, MonthPager as a, EventDragHandler as b, MonthViewProps as c, SlotDefault as d, SlotStyleProps as f, CalendarHandle$1 as g, CalendarEvent$1 as h, MonthListSlot as i, WeekdayFormat$1 as j, TimeGridMode as k, MonthViewSlot as l, BusinessHoursBand$1 as m, MonthList as n, MonthPagerProps as o, BusinessHours as p, MonthListProps as r, MonthView as s, DefaultMonthEvent as t, ResolvedSlot as u, EventAccessibilityLabelContext as v, RecurrenceFrequency as w, EventDragStartHandler as x, EventAccessibilityLabeler$1 as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
2
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
3
|
-
import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
4
3
|
import { SharedValue } from "react-native-reanimated";
|
|
5
|
-
import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
4
|
+
import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
5
|
+
import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
6
6
|
//#region src/theme.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The full set of colours, text styles and metrics the calendar paints with.
|
|
@@ -557,4 +557,4 @@ declare const MonthList: typeof MonthListInner;
|
|
|
557
557
|
*/
|
|
558
558
|
declare function DefaultMonthEvent<T>({ event, mode, isAllDay, ampm, showTime, ellipsizeTitle, allDayLabel, accessibilityLabel: accessibilityLabelProp, cellStyle, onPress, onLongPress }: RenderEventArgs<T>): ReactElement;
|
|
559
559
|
//#endregion
|
|
560
|
-
export {
|
|
560
|
+
export { WeekStartsOn as A, ICalendarEvent as C, RenderEventArgs as D, RenderEvent as E, darkTheme as F, defaultTheme as I, mergeTheme as L, CalendarTheme as M, CalendarThemeProvider as N, ScrollToTimeOptions as O, PartialCalendarTheme as P, useCalendarTheme as R, EventKeyExtractor as S, RecurrenceRule as T, CalendarMode$1 as _, MonthPager as a, EventDragHandler as b, MonthViewProps as c, SlotDefault as d, SlotStyleProps as f, CalendarHandle$1 as g, CalendarEvent$1 as h, MonthListSlot as i, WeekdayFormat$1 as j, TimeGridMode as k, MonthViewSlot as l, BusinessHoursBand$1 as m, MonthList as n, MonthPagerProps as o, BusinessHours as p, MonthListProps as r, MonthView as s, DefaultMonthEvent as t, ResolvedSlot as u, EventAccessibilityLabelContext as v, RecurrenceFrequency as w, EventDragStartHandler as x, EventAccessibilityLabeler$1 as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, O as ScrollToTimeOptions, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, T as RecurrenceRule, _ as CalendarMode, a as MonthPager, b as EventDragHandler, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarHandle, h as CalendarEvent, i as MonthListSlot, j as WeekdayFormat, k as TimeGridMode, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabelContext, w as RecurrenceFrequency, x as EventDragStartHandler, y as EventAccessibilityLabeler } from "./DefaultMonthEvent-eip3mlq_.mjs";
|
|
2
2
|
import { Locale } from "date-fns";
|
|
3
|
-
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
3
|
+
import { ComponentType, ReactElement, ReactNode, RefAttributes } from "react";
|
|
4
4
|
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
5
|
-
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, CalendarLabels, CalendarLabels as CalendarLabels$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, defaultCalendarLabels, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
5
|
+
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarLabels as CalendarLabels$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, defaultCalendarLabels, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
6
6
|
import { ScrollViewProps, StyleProp, ViewStyle } from "react-native";
|
|
7
7
|
//#region src/components/YearView.d.ts
|
|
8
8
|
/**
|
|
@@ -268,7 +268,6 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
268
268
|
/** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
|
|
269
269
|
renderHeader?: (days: Date[]) => React.ReactNode;
|
|
270
270
|
};
|
|
271
|
-
declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events, cellHeight, hourHeight, weekStartsOn, weekdayFormat, labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes, hourColumnWidth: hourColumnWidthProp, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber, headerComponent, minHour, maxHour, ampm, isRTL, minHourHeight, maxHourHeight, minEventHeight, eventGap, showNowIndicator, locale, freeSwipe, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, weekNumberPrefix, hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell, dragStepMinutes, showDragHandle, eventStartEditable, eventDurationEditable, eventOverlap, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }: TimeGridProps<T>): ReactElement;
|
|
272
271
|
/**
|
|
273
272
|
* The timetable view used in day, 3days, week, and custom modes: an
|
|
274
273
|
* hour-by-hour grid with positioned event boxes, an all-day lane, pinch-to-zoom
|
|
@@ -288,7 +287,7 @@ declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events
|
|
|
288
287
|
* />
|
|
289
288
|
* ```
|
|
290
289
|
*/
|
|
291
|
-
export declare const TimeGrid:
|
|
290
|
+
export declare const TimeGrid: <T>(props: TimeGridProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
|
|
292
291
|
//#endregion
|
|
293
292
|
//#region src/components/Calendar.d.ts
|
|
294
293
|
/**
|
|
@@ -550,7 +549,7 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
550
549
|
ellipsizeTitle?: boolean;
|
|
551
550
|
/** Label the built-in renderer shows for an all-day event in the schedule (and its screen-reader text). Default "All day". */
|
|
552
551
|
allDayLabel?: string;
|
|
553
|
-
/**
|
|
552
|
+
/** Vertical scroll, in minutes from midnight (week/day). Applied on mount and whenever it changes. */
|
|
554
553
|
scrollOffsetMinutes?: number;
|
|
555
554
|
/** Show the current-time line on the week/day grid. Default true. */
|
|
556
555
|
showNowIndicator?: boolean;
|
|
@@ -615,7 +614,7 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
615
614
|
* }
|
|
616
615
|
* ```
|
|
617
616
|
*/
|
|
618
|
-
export declare
|
|
617
|
+
export declare const Calendar: <T>(props: CalendarProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
|
|
619
618
|
//#endregion
|
|
620
619
|
//#region src/components/DefaultEvent.d.ts
|
|
621
620
|
/**
|
|
@@ -776,4 +775,4 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
776
775
|
*/
|
|
777
776
|
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, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, labels: labelsProp }: ResourceTimelineProps<T>): ReactElement;
|
|
778
777
|
//#endregion
|
|
779
|
-
export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, 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 PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, 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, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
|
778
|
+
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 DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, 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 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, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, O as ScrollToTimeOptions, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, T as RecurrenceRule, _ as CalendarMode, a as MonthPager, b as EventDragHandler, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarHandle, h as CalendarEvent, i as MonthListSlot, j as WeekdayFormat, k as TimeGridMode, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabelContext, w as RecurrenceFrequency, x as EventDragStartHandler, y as EventAccessibilityLabeler } from "./DefaultMonthEvent-H1IQMTqK.js";
|
|
2
2
|
import { Locale } from "date-fns";
|
|
3
|
-
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
3
|
+
import { ComponentType, ReactElement, ReactNode, RefAttributes } from "react";
|
|
4
4
|
import { ScrollViewProps, StyleProp, ViewStyle } from "react-native";
|
|
5
5
|
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
6
|
-
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, CalendarLabels, CalendarLabels as CalendarLabels$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, defaultCalendarLabels, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
6
|
+
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarLabels as CalendarLabels$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, defaultCalendarLabels, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
7
7
|
//#region src/components/YearView.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* The styleable parts of {@link YearView}. `dayText` and `eventDot` are the
|
|
@@ -268,7 +268,6 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
268
268
|
/** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
|
|
269
269
|
renderHeader?: (days: Date[]) => React.ReactNode;
|
|
270
270
|
};
|
|
271
|
-
declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events, cellHeight, hourHeight, weekStartsOn, weekdayFormat, labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes, hourColumnWidth: hourColumnWidthProp, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber, headerComponent, minHour, maxHour, ampm, isRTL, minHourHeight, maxHourHeight, minEventHeight, eventGap, showNowIndicator, locale, freeSwipe, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, weekNumberPrefix, hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell, dragStepMinutes, showDragHandle, eventStartEditable, eventDurationEditable, eventOverlap, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }: TimeGridProps<T>): ReactElement;
|
|
272
271
|
/**
|
|
273
272
|
* The timetable view used in day, 3days, week, and custom modes: an
|
|
274
273
|
* hour-by-hour grid with positioned event boxes, an all-day lane, pinch-to-zoom
|
|
@@ -288,7 +287,7 @@ declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events
|
|
|
288
287
|
* />
|
|
289
288
|
* ```
|
|
290
289
|
*/
|
|
291
|
-
export declare const TimeGrid:
|
|
290
|
+
export declare const TimeGrid: <T>(props: TimeGridProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
|
|
292
291
|
//#endregion
|
|
293
292
|
//#region src/components/Calendar.d.ts
|
|
294
293
|
/**
|
|
@@ -550,7 +549,7 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
550
549
|
ellipsizeTitle?: boolean;
|
|
551
550
|
/** Label the built-in renderer shows for an all-day event in the schedule (and its screen-reader text). Default "All day". */
|
|
552
551
|
allDayLabel?: string;
|
|
553
|
-
/**
|
|
552
|
+
/** Vertical scroll, in minutes from midnight (week/day). Applied on mount and whenever it changes. */
|
|
554
553
|
scrollOffsetMinutes?: number;
|
|
555
554
|
/** Show the current-time line on the week/day grid. Default true. */
|
|
556
555
|
showNowIndicator?: boolean;
|
|
@@ -615,7 +614,7 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
615
614
|
* }
|
|
616
615
|
* ```
|
|
617
616
|
*/
|
|
618
|
-
export declare
|
|
617
|
+
export declare const Calendar: <T>(props: CalendarProps<T> & RefAttributes<CalendarHandle$1>) => ReactElement;
|
|
619
618
|
//#endregion
|
|
620
619
|
//#region src/components/DefaultEvent.d.ts
|
|
621
620
|
/**
|
|
@@ -776,4 +775,4 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
776
775
|
*/
|
|
777
776
|
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, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, labels: labelsProp }: ResourceTimelineProps<T>): ReactElement;
|
|
778
777
|
//#endregion
|
|
779
|
-
export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, 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 PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, 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, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
|
778
|
+
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 DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, 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 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, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
package/dist/index.js
CHANGED
|
@@ -2067,7 +2067,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2067
2067
|
});
|
|
2068
2068
|
}
|
|
2069
2069
|
const TimetablePage = (0, react.memo)(TimetablePageInner);
|
|
2070
|
-
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, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
2070
|
+
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, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }, ref) {
|
|
2071
2071
|
const clampedMinHour = Math.max(0, Math.min(minHour, 23));
|
|
2072
2072
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
2073
2073
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -2107,6 +2107,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2107
2107
|
const scrollHandler = (0, react_native_reanimated.useAnimatedScrollHandler)({ onScroll: (event) => {
|
|
2108
2108
|
scrollY.value = event.contentOffset.y;
|
|
2109
2109
|
} });
|
|
2110
|
+
const [mountOffsetY] = (0, react.useState)(seedDefaultY);
|
|
2110
2111
|
const webSeededRef = (0, react.useRef)(!isWeb$1);
|
|
2111
2112
|
const seedWebScroll = (0, react.useCallback)(() => {
|
|
2112
2113
|
if (webSeededRef.current) return;
|
|
@@ -2348,6 +2349,35 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2348
2349
|
frame = requestAnimationFrame(attempt);
|
|
2349
2350
|
return () => cancelAnimationFrame(frame);
|
|
2350
2351
|
}, [seedWebScroll]);
|
|
2352
|
+
const scrollToMinutes = (0, react.useCallback)((minutes, animated) => {
|
|
2353
|
+
webSeededRef.current = true;
|
|
2354
|
+
const y = Math.max(0, minutes / MINUTES_PER_HOUR$1 - clampedMinHour) * cellHeight.value;
|
|
2355
|
+
scrollRef.current?.scrollTo({
|
|
2356
|
+
y,
|
|
2357
|
+
animated
|
|
2358
|
+
});
|
|
2359
|
+
}, [
|
|
2360
|
+
clampedMinHour,
|
|
2361
|
+
cellHeight,
|
|
2362
|
+
scrollRef
|
|
2363
|
+
]);
|
|
2364
|
+
const appliedOffsetRef = (0, react.useRef)({
|
|
2365
|
+
minutes: scrollOffsetMinutes,
|
|
2366
|
+
minHour: clampedMinHour
|
|
2367
|
+
});
|
|
2368
|
+
(0, react.useEffect)(() => {
|
|
2369
|
+
const applied = appliedOffsetRef.current;
|
|
2370
|
+
if (applied.minutes === scrollOffsetMinutes && applied.minHour === clampedMinHour) return;
|
|
2371
|
+
appliedOffsetRef.current = {
|
|
2372
|
+
minutes: scrollOffsetMinutes,
|
|
2373
|
+
minHour: clampedMinHour
|
|
2374
|
+
};
|
|
2375
|
+
scrollToMinutes(scrollOffsetMinutes, false);
|
|
2376
|
+
}, [
|
|
2377
|
+
scrollOffsetMinutes,
|
|
2378
|
+
clampedMinHour,
|
|
2379
|
+
scrollToMinutes
|
|
2380
|
+
]);
|
|
2351
2381
|
(0, react.useEffect)(() => {
|
|
2352
2382
|
if (!isWeb$1) return;
|
|
2353
2383
|
const root = containerRef.current;
|
|
@@ -2366,6 +2396,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2366
2396
|
return () => cancelAnimationFrame(raf);
|
|
2367
2397
|
}, [columnsWidth]);
|
|
2368
2398
|
const reduceMotion = (0, react_native_reanimated.useReducedMotion)();
|
|
2399
|
+
(0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, { animated = true } = {}) => scrollToMinutes(minutes, animated && !reduceMotion) }), [scrollToMinutes, reduceMotion]);
|
|
2369
2400
|
const goToPage = (0, react.useCallback)((delta) => {
|
|
2370
2401
|
const index = viewedIndexRef.current + delta;
|
|
2371
2402
|
const target = pageDates[index];
|
|
@@ -2634,7 +2665,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2634
2665
|
refreshControl: verticalScrollEnabled ? refreshControl : void 0,
|
|
2635
2666
|
contentOffset: {
|
|
2636
2667
|
x: 0,
|
|
2637
|
-
y:
|
|
2668
|
+
y: mountOffsetY
|
|
2638
2669
|
},
|
|
2639
2670
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native_reanimated.default.View, {
|
|
2640
2671
|
testID: "time-grid-hours",
|
|
@@ -2741,7 +2772,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2741
2772
|
* />
|
|
2742
2773
|
* ```
|
|
2743
2774
|
*/
|
|
2744
|
-
const TimeGrid = (0, react.memo)(TimeGridInner);
|
|
2775
|
+
const TimeGrid = (0, react.memo)((0, react.forwardRef)(TimeGridInner));
|
|
2745
2776
|
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
2746
2777
|
const slot = require_MonthList.useSlots();
|
|
2747
2778
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
@@ -3035,10 +3066,13 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
3035
3066
|
* }
|
|
3036
3067
|
* ```
|
|
3037
3068
|
*/
|
|
3038
|
-
|
|
3069
|
+
const Calendar = (0, react.forwardRef)(CalendarInner);
|
|
3070
|
+
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, 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) {
|
|
3039
3071
|
const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
|
|
3040
3072
|
const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
|
|
3041
3073
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
3074
|
+
const timeGridRef = (0, react.useRef)(null);
|
|
3075
|
+
(0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
3042
3076
|
const displayEvents = (0, react.useMemo)(() => {
|
|
3043
3077
|
let out = events;
|
|
3044
3078
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -3190,6 +3224,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
3190
3224
|
classNames,
|
|
3191
3225
|
styles: styleOverrides
|
|
3192
3226
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimeGrid, {
|
|
3227
|
+
ref: timeGridRef,
|
|
3193
3228
|
mode,
|
|
3194
3229
|
numberOfDays,
|
|
3195
3230
|
weekEndsOn,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as withEventAccessibilityLabel, c as createSlots, d as useCalendarLabels, f as CalendarThemeProvider, g as useCalendarTheme, h as mergeTheme, i as MonthView, l as useSlots, m as defaultTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as darkTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarLabelsContext } from "./MonthList-B-UE37ZG.mjs";
|
|
2
2
|
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
|
-
import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Animated, { runOnJS, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
|
|
5
5
|
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, monthCreateRange, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
6
6
|
import { PixelRatio, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
@@ -2043,7 +2043,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2043
2043
|
});
|
|
2044
2044
|
}
|
|
2045
2045
|
const TimetablePage = memo(TimetablePageInner);
|
|
2046
|
-
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, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
2046
|
+
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, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }, ref) {
|
|
2047
2047
|
const clampedMinHour = Math.max(0, Math.min(minHour, 23));
|
|
2048
2048
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
2049
2049
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -2083,6 +2083,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2083
2083
|
const scrollHandler = useAnimatedScrollHandler({ onScroll: (event) => {
|
|
2084
2084
|
scrollY.value = event.contentOffset.y;
|
|
2085
2085
|
} });
|
|
2086
|
+
const [mountOffsetY] = useState(seedDefaultY);
|
|
2086
2087
|
const webSeededRef = useRef(!isWeb$1);
|
|
2087
2088
|
const seedWebScroll = useCallback(() => {
|
|
2088
2089
|
if (webSeededRef.current) return;
|
|
@@ -2324,6 +2325,35 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2324
2325
|
frame = requestAnimationFrame(attempt);
|
|
2325
2326
|
return () => cancelAnimationFrame(frame);
|
|
2326
2327
|
}, [seedWebScroll]);
|
|
2328
|
+
const scrollToMinutes = useCallback((minutes, animated) => {
|
|
2329
|
+
webSeededRef.current = true;
|
|
2330
|
+
const y = Math.max(0, minutes / MINUTES_PER_HOUR$1 - clampedMinHour) * cellHeight.value;
|
|
2331
|
+
scrollRef.current?.scrollTo({
|
|
2332
|
+
y,
|
|
2333
|
+
animated
|
|
2334
|
+
});
|
|
2335
|
+
}, [
|
|
2336
|
+
clampedMinHour,
|
|
2337
|
+
cellHeight,
|
|
2338
|
+
scrollRef
|
|
2339
|
+
]);
|
|
2340
|
+
const appliedOffsetRef = useRef({
|
|
2341
|
+
minutes: scrollOffsetMinutes,
|
|
2342
|
+
minHour: clampedMinHour
|
|
2343
|
+
});
|
|
2344
|
+
useEffect(() => {
|
|
2345
|
+
const applied = appliedOffsetRef.current;
|
|
2346
|
+
if (applied.minutes === scrollOffsetMinutes && applied.minHour === clampedMinHour) return;
|
|
2347
|
+
appliedOffsetRef.current = {
|
|
2348
|
+
minutes: scrollOffsetMinutes,
|
|
2349
|
+
minHour: clampedMinHour
|
|
2350
|
+
};
|
|
2351
|
+
scrollToMinutes(scrollOffsetMinutes, false);
|
|
2352
|
+
}, [
|
|
2353
|
+
scrollOffsetMinutes,
|
|
2354
|
+
clampedMinHour,
|
|
2355
|
+
scrollToMinutes
|
|
2356
|
+
]);
|
|
2327
2357
|
useEffect(() => {
|
|
2328
2358
|
if (!isWeb$1) return;
|
|
2329
2359
|
const root = containerRef.current;
|
|
@@ -2342,6 +2372,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2342
2372
|
return () => cancelAnimationFrame(raf);
|
|
2343
2373
|
}, [columnsWidth]);
|
|
2344
2374
|
const reduceMotion = useReducedMotion();
|
|
2375
|
+
useImperativeHandle(ref, () => ({ scrollToTime: (minutes, { animated = true } = {}) => scrollToMinutes(minutes, animated && !reduceMotion) }), [scrollToMinutes, reduceMotion]);
|
|
2345
2376
|
const goToPage = useCallback((delta) => {
|
|
2346
2377
|
const index = viewedIndexRef.current + delta;
|
|
2347
2378
|
const target = pageDates[index];
|
|
@@ -2610,7 +2641,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2610
2641
|
refreshControl: verticalScrollEnabled ? refreshControl : void 0,
|
|
2611
2642
|
contentOffset: {
|
|
2612
2643
|
x: 0,
|
|
2613
|
-
y:
|
|
2644
|
+
y: mountOffsetY
|
|
2614
2645
|
},
|
|
2615
2646
|
children: /* @__PURE__ */ jsxs(Animated.View, {
|
|
2616
2647
|
testID: "time-grid-hours",
|
|
@@ -2717,7 +2748,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2717
2748
|
* />
|
|
2718
2749
|
* ```
|
|
2719
2750
|
*/
|
|
2720
|
-
const TimeGrid = memo(TimeGridInner);
|
|
2751
|
+
const TimeGrid = memo(forwardRef(TimeGridInner));
|
|
2721
2752
|
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
2722
2753
|
const slot = useSlots();
|
|
2723
2754
|
return /* @__PURE__ */ jsx(View, {
|
|
@@ -3011,10 +3042,13 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
3011
3042
|
* }
|
|
3012
3043
|
* ```
|
|
3013
3044
|
*/
|
|
3014
|
-
|
|
3045
|
+
const Calendar = forwardRef(CalendarInner);
|
|
3046
|
+
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, 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) {
|
|
3015
3047
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
3016
3048
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
3017
3049
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
3050
|
+
const timeGridRef = useRef(null);
|
|
3051
|
+
useImperativeHandle(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
3018
3052
|
const displayEvents = useMemo(() => {
|
|
3019
3053
|
let out = events;
|
|
3020
3054
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -3166,6 +3200,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
3166
3200
|
classNames,
|
|
3167
3201
|
styles: styleOverrides
|
|
3168
3202
|
}) : /* @__PURE__ */ jsx(TimeGrid, {
|
|
3203
|
+
ref: timeGridRef,
|
|
3169
3204
|
mode,
|
|
3170
3205
|
numberOfDays,
|
|
3171
3206
|
weekEndsOn,
|
package/dist/picker.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent } from "./DefaultMonthEvent-eip3mlq_.mjs";
|
|
2
2
|
import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
|
|
3
3
|
export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
|
package/dist/picker.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent } from "./DefaultMonthEvent-H1IQMTqK.js";
|
|
2
2
|
import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
|
|
3
3
|
export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.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.
|
|
67
|
+
"@super-calendar/core": "2.13.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -12,7 +12,16 @@ import {
|
|
|
12
12
|
startOfWeek,
|
|
13
13
|
startOfYear,
|
|
14
14
|
} from "date-fns";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
type ForwardedRef,
|
|
17
|
+
forwardRef,
|
|
18
|
+
type ReactElement,
|
|
19
|
+
type RefAttributes,
|
|
20
|
+
useCallback,
|
|
21
|
+
useImperativeHandle,
|
|
22
|
+
useMemo,
|
|
23
|
+
useRef,
|
|
24
|
+
} from "react";
|
|
16
25
|
import type { ScrollViewProps, StyleProp, ViewStyle } from "react-native";
|
|
17
26
|
import { useSharedValue } from "react-native-reanimated";
|
|
18
27
|
import { CalendarThemeProvider, mergeTheme, type PartialCalendarTheme } from "../theme";
|
|
@@ -34,7 +43,11 @@ import {
|
|
|
34
43
|
type WeekdayFormat,
|
|
35
44
|
getViewDays,
|
|
36
45
|
} from "@super-calendar/core";
|
|
37
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
type CalendarHandle,
|
|
48
|
+
type CalendarLabels,
|
|
49
|
+
resolveCalendarLabels,
|
|
50
|
+
} from "@super-calendar/core";
|
|
38
51
|
import { CalendarLabelsContext } from "../utils/labels";
|
|
39
52
|
import { type SlotStyleProps } from "../utils/slots";
|
|
40
53
|
import { YearView, type YearViewSlot } from "./YearView";
|
|
@@ -311,7 +324,7 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
311
324
|
ellipsizeTitle?: boolean;
|
|
312
325
|
/** Label the built-in renderer shows for an all-day event in the schedule (and its screen-reader text). Default "All day". */
|
|
313
326
|
allDayLabel?: string;
|
|
314
|
-
/**
|
|
327
|
+
/** Vertical scroll, in minutes from midnight (week/day). Applied on mount and whenever it changes. */
|
|
315
328
|
scrollOffsetMinutes?: number;
|
|
316
329
|
/** Show the current-time line on the week/day grid. Default true. */
|
|
317
330
|
showNowIndicator?: boolean;
|
|
@@ -442,103 +455,118 @@ function expansionRange(
|
|
|
442
455
|
* }
|
|
443
456
|
* ```
|
|
444
457
|
*/
|
|
445
|
-
export
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
458
|
+
export const Calendar = forwardRef(CalendarInner) as <T>(
|
|
459
|
+
props: CalendarProps<T> & RefAttributes<CalendarHandle>,
|
|
460
|
+
) => ReactElement;
|
|
461
|
+
|
|
462
|
+
function CalendarInner<T>(
|
|
463
|
+
{
|
|
464
|
+
events,
|
|
465
|
+
mode,
|
|
466
|
+
date,
|
|
467
|
+
onChangeDate,
|
|
468
|
+
onChangeDateRange,
|
|
469
|
+
onPressEvent,
|
|
470
|
+
onLongPressEvent,
|
|
471
|
+
onDragEvent,
|
|
472
|
+
onDragStart,
|
|
473
|
+
dragStepMinutes,
|
|
474
|
+
showDragHandle,
|
|
475
|
+
onPressDay,
|
|
476
|
+
onPressMonth,
|
|
477
|
+
onLongPressDay,
|
|
478
|
+
onPressMore,
|
|
479
|
+
onPressCell,
|
|
480
|
+
resetPageOnPressCell,
|
|
481
|
+
onLongPressCell,
|
|
482
|
+
onCreateEvent,
|
|
483
|
+
onSelectDrag,
|
|
484
|
+
selectedDates,
|
|
485
|
+
selectedRange,
|
|
486
|
+
fillCellOnSelection,
|
|
487
|
+
minDate,
|
|
488
|
+
maxDate,
|
|
489
|
+
isDateDisabled,
|
|
490
|
+
onPressDateHeader,
|
|
491
|
+
maxVisibleEventCount,
|
|
492
|
+
sortedMonthView,
|
|
493
|
+
moreLabel,
|
|
494
|
+
labels,
|
|
495
|
+
showAdjacentMonths,
|
|
496
|
+
disableMonthEventCellPress,
|
|
497
|
+
weekStartsOn = 0,
|
|
498
|
+
hiddenDays,
|
|
499
|
+
now,
|
|
500
|
+
weekdayFormat,
|
|
501
|
+
numberOfDays,
|
|
502
|
+
weekEndsOn,
|
|
503
|
+
renderEvent = DefaultEvent,
|
|
504
|
+
eventAccessibilityLabel,
|
|
505
|
+
eventCellStyle,
|
|
506
|
+
calendarCellStyle,
|
|
507
|
+
businessHours,
|
|
508
|
+
renderBusinessHours,
|
|
509
|
+
renderBackgroundEvent,
|
|
510
|
+
keyExtractor = defaultKeyExtractor as EventKeyExtractor<T>,
|
|
511
|
+
theme,
|
|
512
|
+
cellHeight: cellHeightProp,
|
|
513
|
+
hourHeight = DEFAULT_HOUR_HEIGHT,
|
|
514
|
+
minHourHeight,
|
|
515
|
+
maxHourHeight,
|
|
516
|
+
minEventHeight,
|
|
517
|
+
eventGap,
|
|
518
|
+
hourColumnWidth,
|
|
519
|
+
hideHours,
|
|
520
|
+
timeslots,
|
|
521
|
+
showAllDayEventCell,
|
|
522
|
+
showAllDayLabel,
|
|
523
|
+
refreshControl,
|
|
524
|
+
highlightWeekends,
|
|
525
|
+
eventStartEditable,
|
|
526
|
+
eventDurationEditable,
|
|
527
|
+
eventOverlap,
|
|
528
|
+
showWeekNumber,
|
|
529
|
+
weekNumberPrefix,
|
|
530
|
+
hourComponent,
|
|
531
|
+
showSixWeeks,
|
|
532
|
+
showTitle,
|
|
533
|
+
swipeEnabled,
|
|
534
|
+
showVerticalScrollIndicator,
|
|
535
|
+
verticalScrollEnabled,
|
|
536
|
+
headerComponent,
|
|
537
|
+
minHour,
|
|
538
|
+
maxHour,
|
|
539
|
+
ampm,
|
|
540
|
+
showTime,
|
|
541
|
+
ellipsizeTitle,
|
|
542
|
+
allDayLabel,
|
|
543
|
+
scrollOffsetMinutes,
|
|
544
|
+
showNowIndicator,
|
|
545
|
+
locale,
|
|
546
|
+
timeZone,
|
|
547
|
+
activeDate,
|
|
548
|
+
isRTL,
|
|
549
|
+
freeSwipe,
|
|
550
|
+
renderTimeGridHeader,
|
|
551
|
+
renderHeaderForMonthView,
|
|
552
|
+
renderCustomDateForMonth,
|
|
553
|
+
itemSeparatorComponent,
|
|
554
|
+
classNames,
|
|
555
|
+
styles: styleOverrides,
|
|
556
|
+
}: CalendarProps<T>,
|
|
557
|
+
ref: ForwardedRef<CalendarHandle>,
|
|
558
|
+
): ReactElement {
|
|
539
559
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
540
560
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
541
561
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
562
|
+
const timeGridRef = useRef<CalendarHandle>(null);
|
|
563
|
+
useImperativeHandle(
|
|
564
|
+
ref,
|
|
565
|
+
() => ({
|
|
566
|
+
scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options),
|
|
567
|
+
}),
|
|
568
|
+
[],
|
|
569
|
+
);
|
|
542
570
|
|
|
543
571
|
// Materialise recurring events over the range this mode renders (plus a one-page
|
|
544
572
|
// buffer so occurrences survive the pager's pre-rendered neighbours), then apply
|
|
@@ -727,6 +755,7 @@ export function Calendar<T>({
|
|
|
727
755
|
/>
|
|
728
756
|
) : (
|
|
729
757
|
<TimeGrid
|
|
758
|
+
ref={timeGridRef}
|
|
730
759
|
mode={mode}
|
|
731
760
|
numberOfDays={numberOfDays}
|
|
732
761
|
weekEndsOn={weekEndsOn}
|
|
@@ -18,12 +18,16 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
createContext,
|
|
20
20
|
type Dispatch,
|
|
21
|
+
type ForwardedRef,
|
|
22
|
+
forwardRef,
|
|
21
23
|
memo,
|
|
22
24
|
type ReactElement,
|
|
25
|
+
type RefAttributes,
|
|
23
26
|
type SetStateAction,
|
|
24
27
|
useCallback,
|
|
25
28
|
useContext,
|
|
26
29
|
useEffect,
|
|
30
|
+
useImperativeHandle,
|
|
27
31
|
useMemo,
|
|
28
32
|
useRef,
|
|
29
33
|
useState,
|
|
@@ -90,7 +94,11 @@ import {
|
|
|
90
94
|
snapDeltaMinutes,
|
|
91
95
|
} from "@super-calendar/core";
|
|
92
96
|
import { formatHour, layoutDayEvents, type PositionedEvent } from "@super-calendar/core";
|
|
93
|
-
import type {
|
|
97
|
+
import type {
|
|
98
|
+
CalendarHandle,
|
|
99
|
+
CalendarLabels,
|
|
100
|
+
EventAccessibilityLabeler,
|
|
101
|
+
} from "@super-calendar/core";
|
|
94
102
|
import { resolveCalendarLabels } from "@super-calendar/core";
|
|
95
103
|
import { type WeekdayFormat, weekdayFormatToken } from "@super-calendar/core";
|
|
96
104
|
import {
|
|
@@ -2346,73 +2354,76 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
2346
2354
|
renderHeader?: (days: Date[]) => React.ReactNode;
|
|
2347
2355
|
};
|
|
2348
2356
|
|
|
2349
|
-
function TimeGridInner<T>(
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2357
|
+
function TimeGridInner<T>(
|
|
2358
|
+
{
|
|
2359
|
+
mode,
|
|
2360
|
+
numberOfDays = 1,
|
|
2361
|
+
weekEndsOn,
|
|
2362
|
+
date,
|
|
2363
|
+
events,
|
|
2364
|
+
cellHeight,
|
|
2365
|
+
hourHeight = DEFAULT_HOUR_HEIGHT,
|
|
2366
|
+
weekStartsOn,
|
|
2367
|
+
weekdayFormat = "short",
|
|
2368
|
+
labels: labelsProp,
|
|
2369
|
+
renderEvent,
|
|
2370
|
+
eventAccessibilityLabel,
|
|
2371
|
+
keyExtractor,
|
|
2372
|
+
scrollOffsetMinutes = 0,
|
|
2373
|
+
hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH,
|
|
2374
|
+
hideHours = false,
|
|
2375
|
+
timeslots = 1,
|
|
2376
|
+
showAllDayEventCell = true,
|
|
2377
|
+
showAllDayLabel = false,
|
|
2378
|
+
refreshControl,
|
|
2379
|
+
highlightWeekends = true,
|
|
2380
|
+
calendarCellStyle,
|
|
2381
|
+
businessHours,
|
|
2382
|
+
renderBusinessHours,
|
|
2383
|
+
renderBackgroundEvent,
|
|
2384
|
+
showWeekNumber = false,
|
|
2385
|
+
headerComponent,
|
|
2386
|
+
minHour = 0,
|
|
2387
|
+
maxHour = HOURS_PER_DAY,
|
|
2388
|
+
ampm = false,
|
|
2389
|
+
isRTL = false,
|
|
2390
|
+
minHourHeight = DEFAULT_MIN_HOUR_HEIGHT,
|
|
2391
|
+
maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT,
|
|
2392
|
+
minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
|
|
2393
|
+
eventGap = DEFAULT_EVENT_GAP,
|
|
2394
|
+
showNowIndicator = true,
|
|
2395
|
+
locale,
|
|
2396
|
+
freeSwipe = false,
|
|
2397
|
+
swipeEnabled = true,
|
|
2398
|
+
showVerticalScrollIndicator = true,
|
|
2399
|
+
verticalScrollEnabled = true,
|
|
2400
|
+
weekNumberPrefix = "W",
|
|
2401
|
+
hiddenDays,
|
|
2402
|
+
now,
|
|
2403
|
+
timeZone,
|
|
2404
|
+
hourComponent,
|
|
2405
|
+
activeDate,
|
|
2406
|
+
resetPageOnPressCell = false,
|
|
2407
|
+
dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES,
|
|
2408
|
+
showDragHandle = true,
|
|
2409
|
+
eventStartEditable = true,
|
|
2410
|
+
eventDurationEditable = true,
|
|
2411
|
+
eventOverlap = true,
|
|
2412
|
+
onPressEvent,
|
|
2413
|
+
onLongPressEvent,
|
|
2414
|
+
onDragEvent: onDragEventProp,
|
|
2415
|
+
onDragStart,
|
|
2416
|
+
onPressCell,
|
|
2417
|
+
onLongPressCell,
|
|
2418
|
+
onCreateEvent,
|
|
2419
|
+
onPressDateHeader,
|
|
2420
|
+
onChangeDate,
|
|
2421
|
+
renderHeader,
|
|
2422
|
+
classNames,
|
|
2423
|
+
styles: styleOverrides,
|
|
2424
|
+
}: TimeGridProps<T>,
|
|
2425
|
+
ref: ForwardedRef<CalendarHandle>,
|
|
2426
|
+
): ReactElement {
|
|
2416
2427
|
// Guard against an inverted/out-of-range window so the grid never collapses.
|
|
2417
2428
|
const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
|
|
2418
2429
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
@@ -2495,6 +2506,9 @@ function TimeGridInner<T>({
|
|
|
2495
2506
|
scrollY.value = event.contentOffset.y;
|
|
2496
2507
|
},
|
|
2497
2508
|
});
|
|
2509
|
+
// The scroll view's `contentOffset` holds the mount offset; a later
|
|
2510
|
+
// `scrollOffsetMinutes` is scrolled to by the effect further down.
|
|
2511
|
+
const [mountOffsetY] = useState(seedDefaultY);
|
|
2498
2512
|
// react-native-web ignores `contentOffset`; apply the initial offset once the
|
|
2499
2513
|
// viewport and the content have laid out instead.
|
|
2500
2514
|
const webSeededRef = useRef(!isWeb);
|
|
@@ -2903,6 +2917,26 @@ function TimeGridInner<T>({
|
|
|
2903
2917
|
return () => cancelAnimationFrame(frame);
|
|
2904
2918
|
}, [seedWebScroll]);
|
|
2905
2919
|
|
|
2920
|
+
// Scroll so `minutes` sits at the top of the hours, at the live zoom.
|
|
2921
|
+
const scrollToMinutes = useCallback(
|
|
2922
|
+
(minutes: number, animated: boolean) => {
|
|
2923
|
+
webSeededRef.current = true;
|
|
2924
|
+
const y = Math.max(0, minutes / MINUTES_PER_HOUR - clampedMinHour) * cellHeight.value;
|
|
2925
|
+
scrollRef.current?.scrollTo({ y, animated });
|
|
2926
|
+
},
|
|
2927
|
+
[clampedMinHour, cellHeight, scrollRef],
|
|
2928
|
+
);
|
|
2929
|
+
|
|
2930
|
+
// Scroll to a changed `scrollOffsetMinutes` (or hour window). The mount offset
|
|
2931
|
+
// comes from `contentOffset` and the web seed above.
|
|
2932
|
+
const appliedOffsetRef = useRef({ minutes: scrollOffsetMinutes, minHour: clampedMinHour });
|
|
2933
|
+
useEffect(() => {
|
|
2934
|
+
const applied = appliedOffsetRef.current;
|
|
2935
|
+
if (applied.minutes === scrollOffsetMinutes && applied.minHour === clampedMinHour) return;
|
|
2936
|
+
appliedOffsetRef.current = { minutes: scrollOffsetMinutes, minHour: clampedMinHour };
|
|
2937
|
+
scrollToMinutes(scrollOffsetMinutes, false);
|
|
2938
|
+
}, [scrollOffsetMinutes, clampedMinHour, scrollToMinutes]);
|
|
2939
|
+
|
|
2906
2940
|
// Web: LegendList's horizontal scroll container is `overflow-x: auto`, so a
|
|
2907
2941
|
// trackpad swipe or horizontal wheel would scroll between pages. Paging should be
|
|
2908
2942
|
// arrow-keys/toolbar only, so disable user horizontal scrolling on it (programmatic
|
|
@@ -2933,6 +2967,15 @@ function TimeGridInner<T>({
|
|
|
2933
2967
|
// jumps when it's on.
|
|
2934
2968
|
const reduceMotion = useReducedMotion();
|
|
2935
2969
|
|
|
2970
|
+
useImperativeHandle(
|
|
2971
|
+
ref,
|
|
2972
|
+
() => ({
|
|
2973
|
+
scrollToTime: (minutes, { animated = true } = {}) =>
|
|
2974
|
+
scrollToMinutes(minutes, animated && !reduceMotion),
|
|
2975
|
+
}),
|
|
2976
|
+
[scrollToMinutes, reduceMotion],
|
|
2977
|
+
);
|
|
2978
|
+
|
|
2936
2979
|
// Page by `delta` (edge drags, web arrow keys): move the list at once and
|
|
2937
2980
|
// report the date, rather than waiting for the reported date to come back
|
|
2938
2981
|
// through props. The realign effect then finds the list already there.
|
|
@@ -3217,7 +3260,7 @@ function TimeGridInner<T>({
|
|
|
3217
3260
|
onScroll={scrollHandler}
|
|
3218
3261
|
scrollEventThrottle={16}
|
|
3219
3262
|
refreshControl={verticalScrollEnabled ? refreshControl : undefined}
|
|
3220
|
-
contentOffset={{ x: 0, y:
|
|
3263
|
+
contentOffset={{ x: 0, y: mountOffsetY }}
|
|
3221
3264
|
>
|
|
3222
3265
|
<Animated.View testID="time-grid-hours" style={[styles.gridRow, gridHeightStyle]}>
|
|
3223
3266
|
{hourColumnWidth > 0 ? (
|
|
@@ -3358,7 +3401,9 @@ function TimeGridInner<T>({
|
|
|
3358
3401
|
* />
|
|
3359
3402
|
* ```
|
|
3360
3403
|
*/
|
|
3361
|
-
export const TimeGrid = memo(TimeGridInner) as
|
|
3404
|
+
export const TimeGrid = memo(forwardRef(TimeGridInner)) as <T>(
|
|
3405
|
+
props: TimeGridProps<T> & RefAttributes<CalendarHandle>,
|
|
3406
|
+
) => ReactElement;
|
|
3362
3407
|
|
|
3363
3408
|
type DayHeaderRowProps = {
|
|
3364
3409
|
days: Date[];
|
package/src/index.tsx
CHANGED
|
@@ -57,6 +57,7 @@ export type {
|
|
|
57
57
|
BusinessHours,
|
|
58
58
|
BusinessHoursBand,
|
|
59
59
|
CalendarEvent,
|
|
60
|
+
CalendarHandle,
|
|
60
61
|
CalendarMode,
|
|
61
62
|
EventAccessibilityLabelContext,
|
|
62
63
|
EventAccessibilityLabeler,
|
|
@@ -66,6 +67,7 @@ export type {
|
|
|
66
67
|
RecurrenceRule,
|
|
67
68
|
RenderEvent,
|
|
68
69
|
RenderEventArgs,
|
|
70
|
+
ScrollToTimeOptions,
|
|
69
71
|
TimeGridMode,
|
|
70
72
|
WeekdayFormat,
|
|
71
73
|
WeekStartsOn,
|
package/src/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
BusinessHours,
|
|
15
15
|
BusinessHoursBand,
|
|
16
16
|
CalendarEvent,
|
|
17
|
+
CalendarHandle,
|
|
17
18
|
CalendarMode,
|
|
18
19
|
EventAccessibilityLabelContext,
|
|
19
20
|
EventAccessibilityLabeler,
|
|
@@ -21,6 +22,7 @@ export type {
|
|
|
21
22
|
ICalendarEvent,
|
|
22
23
|
RecurrenceFrequency,
|
|
23
24
|
RecurrenceRule,
|
|
25
|
+
ScrollToTimeOptions,
|
|
24
26
|
TimeGridMode,
|
|
25
27
|
WeekdayFormat,
|
|
26
28
|
WeekStartsOn,
|