@super-calendar/native 2.12.0 → 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 +113 -11
- package/dist/index.mjs +115 -13
- 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 +206 -81
- package/src/index.tsx +2 -0
- package/src/types.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
6
|
+
import { PixelRatio, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
7
7
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { LegendList } from "@legendapp/list/react-native";
|
|
@@ -821,6 +821,8 @@ const HOURS_PER_DAY = 24;
|
|
|
821
821
|
const MINUTES_PER_DAY = 1440;
|
|
822
822
|
const PAGE_WINDOW = 180;
|
|
823
823
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
824
|
+
const PAGER_IDLE_MS = 150;
|
|
825
|
+
const PAGER_HELD_DRAG_MS = 1e3;
|
|
824
826
|
/** Default height in pixels of one hour row on the time grid. */
|
|
825
827
|
const DEFAULT_HOUR_HEIGHT = 48;
|
|
826
828
|
const DEFAULT_MIN_HOUR_HEIGHT = 32;
|
|
@@ -2041,7 +2043,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2041
2043
|
});
|
|
2042
2044
|
}
|
|
2043
2045
|
const TimetablePage = memo(TimetablePageInner);
|
|
2044
|
-
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) {
|
|
2045
2047
|
const clampedMinHour = Math.max(0, Math.min(minHour, 23));
|
|
2046
2048
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
2047
2049
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -2081,6 +2083,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2081
2083
|
const scrollHandler = useAnimatedScrollHandler({ onScroll: (event) => {
|
|
2082
2084
|
scrollY.value = event.contentOffset.y;
|
|
2083
2085
|
} });
|
|
2086
|
+
const [mountOffsetY] = useState(seedDefaultY);
|
|
2084
2087
|
const webSeededRef = useRef(!isWeb$1);
|
|
2085
2088
|
const seedWebScroll = useCallback(() => {
|
|
2086
2089
|
if (webSeededRef.current) return;
|
|
@@ -2322,6 +2325,35 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2322
2325
|
frame = requestAnimationFrame(attempt);
|
|
2323
2326
|
return () => cancelAnimationFrame(frame);
|
|
2324
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
|
+
]);
|
|
2325
2357
|
useEffect(() => {
|
|
2326
2358
|
if (!isWeb$1) return;
|
|
2327
2359
|
const root = containerRef.current;
|
|
@@ -2340,6 +2372,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2340
2372
|
return () => cancelAnimationFrame(raf);
|
|
2341
2373
|
}, [columnsWidth]);
|
|
2342
2374
|
const reduceMotion = useReducedMotion();
|
|
2375
|
+
useImperativeHandle(ref, () => ({ scrollToTime: (minutes, { animated = true } = {}) => scrollToMinutes(minutes, animated && !reduceMotion) }), [scrollToMinutes, reduceMotion]);
|
|
2343
2376
|
const goToPage = useCallback((delta) => {
|
|
2344
2377
|
const index = viewedIndexRef.current + delta;
|
|
2345
2378
|
const target = pageDates[index];
|
|
@@ -2360,16 +2393,24 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2360
2393
|
pagerOffset
|
|
2361
2394
|
]);
|
|
2362
2395
|
useWebPagerKeys(swipeEnabled, goToPage);
|
|
2363
|
-
const
|
|
2364
|
-
|
|
2365
|
-
if (pendingScrollIndexRef.current != null) return;
|
|
2366
|
-
const raw = Math.round(event.nativeEvent.contentOffset.x / columnsWidth);
|
|
2396
|
+
const commitNearestPage = useCallback((offsetX) => {
|
|
2397
|
+
const raw = Math.round(offsetX / columnsWidth);
|
|
2367
2398
|
const index = Math.min(Math.max(raw, 0), pageDates.length - 1);
|
|
2368
2399
|
if (index !== viewedIndexRef.current) {
|
|
2369
2400
|
viewedIndexRef.current = index;
|
|
2370
2401
|
const target = pageDates[index];
|
|
2371
2402
|
if (target) onChangeDate(target);
|
|
2372
2403
|
}
|
|
2404
|
+
return index;
|
|
2405
|
+
}, [
|
|
2406
|
+
columnsWidth,
|
|
2407
|
+
pageDates,
|
|
2408
|
+
onChangeDate
|
|
2409
|
+
]);
|
|
2410
|
+
const handlePagerSettled = useCallback((event) => {
|
|
2411
|
+
if (columnsWidth <= 0) return;
|
|
2412
|
+
if (pendingScrollIndexRef.current != null) return;
|
|
2413
|
+
const index = commitNearestPage(event.nativeEvent.contentOffset.x);
|
|
2373
2414
|
pagerOffset.value = index * columnsWidth;
|
|
2374
2415
|
requestAnimationFrame(() => {
|
|
2375
2416
|
listRef.current?.scrollToIndex({
|
|
@@ -2379,10 +2420,62 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2379
2420
|
});
|
|
2380
2421
|
}, [
|
|
2381
2422
|
columnsWidth,
|
|
2382
|
-
|
|
2383
|
-
onChangeDate,
|
|
2423
|
+
commitNearestPage,
|
|
2384
2424
|
pagerOffset
|
|
2385
2425
|
]);
|
|
2426
|
+
const pagerDraggingRef = useRef(false);
|
|
2427
|
+
const lastPagerScrollRef = useRef({
|
|
2428
|
+
offsetX: 0,
|
|
2429
|
+
at: 0
|
|
2430
|
+
});
|
|
2431
|
+
const pagerIdleTimerRef = useRef(null);
|
|
2432
|
+
useEffect(() => () => {
|
|
2433
|
+
if (pagerIdleTimerRef.current) clearTimeout(pagerIdleTimerRef.current);
|
|
2434
|
+
}, []);
|
|
2435
|
+
const realignRestingPager = useCallback((offsetX) => {
|
|
2436
|
+
pagerDraggingRef.current = false;
|
|
2437
|
+
if (columnsWidth <= 0) return;
|
|
2438
|
+
const pages = offsetX / columnsWidth;
|
|
2439
|
+
if (Math.abs(pages - Math.round(pages)) * columnsWidth * PixelRatio.get() < .5) return;
|
|
2440
|
+
const index = pendingScrollIndexRef.current ?? commitNearestPage(offsetX);
|
|
2441
|
+
pagerOffset.value = index * columnsWidth;
|
|
2442
|
+
listRef.current?.scrollToIndex({
|
|
2443
|
+
index,
|
|
2444
|
+
animated: !reduceMotion
|
|
2445
|
+
});
|
|
2446
|
+
}, [
|
|
2447
|
+
columnsWidth,
|
|
2448
|
+
commitNearestPage,
|
|
2449
|
+
pagerOffset,
|
|
2450
|
+
reduceMotion
|
|
2451
|
+
]);
|
|
2452
|
+
const realignRestingPagerRef = useRef(realignRestingPager);
|
|
2453
|
+
realignRestingPagerRef.current = realignRestingPager;
|
|
2454
|
+
const armPagerIdleTimer = useCallback((delay) => {
|
|
2455
|
+
pagerIdleTimerRef.current = setTimeout(() => {
|
|
2456
|
+
const wait = pagerDraggingRef.current ? PAGER_HELD_DRAG_MS : PAGER_IDLE_MS;
|
|
2457
|
+
const remaining = lastPagerScrollRef.current.at + wait - Date.now();
|
|
2458
|
+
if (remaining > 0) {
|
|
2459
|
+
armPagerIdleTimer(remaining);
|
|
2460
|
+
return;
|
|
2461
|
+
}
|
|
2462
|
+
pagerIdleTimerRef.current = null;
|
|
2463
|
+
realignRestingPagerRef.current(lastPagerScrollRef.current.offsetX);
|
|
2464
|
+
}, delay);
|
|
2465
|
+
}, []);
|
|
2466
|
+
const handlePagerScroll = useCallback((event) => {
|
|
2467
|
+
lastPagerScrollRef.current = {
|
|
2468
|
+
offsetX: event.nativeEvent.contentOffset.x,
|
|
2469
|
+
at: Date.now()
|
|
2470
|
+
};
|
|
2471
|
+
if (!pagerIdleTimerRef.current) armPagerIdleTimer(PAGER_IDLE_MS);
|
|
2472
|
+
}, [armPagerIdleTimer]);
|
|
2473
|
+
const handlePagerDragStart = useCallback(() => {
|
|
2474
|
+
pagerDraggingRef.current = true;
|
|
2475
|
+
}, []);
|
|
2476
|
+
const handlePagerDragEnd = useCallback(() => {
|
|
2477
|
+
pagerDraggingRef.current = false;
|
|
2478
|
+
}, []);
|
|
2386
2479
|
const handlePressCell = useMemo(() => {
|
|
2387
2480
|
if (!onPressCell) return void 0;
|
|
2388
2481
|
if (!resetPageOnPressCell) return onPressCell;
|
|
@@ -2548,7 +2641,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2548
2641
|
refreshControl: verticalScrollEnabled ? refreshControl : void 0,
|
|
2549
2642
|
contentOffset: {
|
|
2550
2643
|
x: 0,
|
|
2551
|
-
y:
|
|
2644
|
+
y: mountOffsetY
|
|
2552
2645
|
},
|
|
2553
2646
|
children: /* @__PURE__ */ jsxs(Animated.View, {
|
|
2554
2647
|
testID: "time-grid-hours",
|
|
@@ -2602,7 +2695,12 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2602
2695
|
decelerationRate: freeSwipe ? "normal" : "fast",
|
|
2603
2696
|
disableIntervalMomentum: !freeSwipe,
|
|
2604
2697
|
scrollEventThrottle: 16,
|
|
2605
|
-
onMomentumScrollEnd: handlePagerSettled
|
|
2698
|
+
onMomentumScrollEnd: handlePagerSettled,
|
|
2699
|
+
...Platform.OS === "android" ? {
|
|
2700
|
+
onScroll: handlePagerScroll,
|
|
2701
|
+
onScrollBeginDrag: handlePagerDragStart,
|
|
2702
|
+
onScrollEndDrag: handlePagerDragEnd
|
|
2703
|
+
} : null
|
|
2606
2704
|
},
|
|
2607
2705
|
initialScrollIndex: activeIndex,
|
|
2608
2706
|
showsHorizontalScrollIndicator: false,
|
|
@@ -2650,7 +2748,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2650
2748
|
* />
|
|
2651
2749
|
* ```
|
|
2652
2750
|
*/
|
|
2653
|
-
const TimeGrid = memo(TimeGridInner);
|
|
2751
|
+
const TimeGrid = memo(forwardRef(TimeGridInner));
|
|
2654
2752
|
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
2655
2753
|
const slot = useSlots();
|
|
2656
2754
|
return /* @__PURE__ */ jsx(View, {
|
|
@@ -2944,10 +3042,13 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
2944
3042
|
* }
|
|
2945
3043
|
* ```
|
|
2946
3044
|
*/
|
|
2947
|
-
|
|
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) {
|
|
2948
3047
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
2949
3048
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
2950
3049
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
3050
|
+
const timeGridRef = useRef(null);
|
|
3051
|
+
useImperativeHandle(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
2951
3052
|
const displayEvents = useMemo(() => {
|
|
2952
3053
|
let out = events;
|
|
2953
3054
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -3099,6 +3200,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
3099
3200
|
classNames,
|
|
3100
3201
|
styles: styleOverrides
|
|
3101
3202
|
}) : /* @__PURE__ */ jsx(TimeGrid, {
|
|
3203
|
+
ref: timeGridRef,
|
|
3102
3204
|
mode,
|
|
3103
3205
|
numberOfDays,
|
|
3104
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}
|