@super-calendar/native 2.19.0 → 2.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/{MonthList-DeO-x5VW.js → MonthList-CGgy0Juh.js} +28 -7
- package/dist/{MonthList-BGl1gTDr.mjs → MonthList-CPpsr5Oa.mjs} +28 -7
- package/dist/index.d.mts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +110 -34
- package/dist/index.mjs +110 -34
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +3 -3
- package/src/components/Calendar.tsx +17 -0
- package/src/components/MonthList.tsx +13 -3
- package/src/components/MonthPager.tsx +21 -5
- package/src/components/MonthView.tsx +11 -4
- package/src/components/TimeGrid.tsx +173 -46
- package/src/index.tsx +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as mergeTheme, a as DateRows, c as useWebPagerKeys, d as useSlots, f as CalendarLabelsContext, g as defaultTheme, h as darkTheme, i as MonthPager, l as SlotStylesProvider, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, p as useCalendarLabels, r as DateRowsPager, s as withEventAccessibilityLabel, t as MonthList, u as createSlots, v as useCalendarTheme } from "./MonthList-
|
|
1
|
+
import { _ as mergeTheme, a as DateRows, c as useWebPagerKeys, d as useSlots, f as CalendarLabelsContext, g as defaultTheme, h as darkTheme, i as MonthPager, l as SlotStylesProvider, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, p as useCalendarLabels, r as DateRowsPager, s as withEventAccessibilityLabel, t as MonthList, u as createSlots, v as useCalendarTheme } from "./MonthList-CPpsr5Oa.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
3
|
import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Animated, { runOnJS, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
|
|
@@ -1495,9 +1495,10 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1495
1495
|
}
|
|
1496
1496
|
const AnimatedEventBox = memo(AnimatedEventBoxInner);
|
|
1497
1497
|
const hourRange = (minHour, maxHour) => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index);
|
|
1498
|
-
const HourLabel = ({ hour, width, label, ampm, hourComponent }) => {
|
|
1498
|
+
const HourLabel = ({ hour, width, label, ampm, hourComponent, hidden }) => {
|
|
1499
1499
|
const theme = useCalendarTheme();
|
|
1500
1500
|
const slot = useSlots();
|
|
1501
|
+
if (hidden) return null;
|
|
1501
1502
|
return hourComponent ? /* @__PURE__ */ jsx(View, {
|
|
1502
1503
|
style: { width },
|
|
1503
1504
|
children: hourComponent(hour, ampm)
|
|
@@ -1532,12 +1533,24 @@ const HourLines = memo(function HourLines({ hours, timeslots }) {
|
|
|
1532
1533
|
}, hour))
|
|
1533
1534
|
});
|
|
1534
1535
|
});
|
|
1535
|
-
|
|
1536
|
+
function getNowPosition(time, days, minHour, maxHour) {
|
|
1537
|
+
const hours = getHours(time) + getMinutes(time) / MINUTES_PER_HOUR$1;
|
|
1538
|
+
const dayIndex = days.findIndex((day) => isSameCalendarDay$1(day, time));
|
|
1539
|
+
return dayIndex >= 0 && hours >= minHour && hours <= maxHour ? {
|
|
1540
|
+
time,
|
|
1541
|
+
hours,
|
|
1542
|
+
dayIndex
|
|
1543
|
+
} : null;
|
|
1544
|
+
}
|
|
1545
|
+
const NOW_LABEL_CLEARANCE_HOURS = .25;
|
|
1546
|
+
const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scrollY, showLane, showAllDayLabel, allDayLabel, headerHeight, weekNumber, ampm, hourComponent, renderNowLabel, nowPosition }) => {
|
|
1536
1547
|
const theme = useCalendarTheme();
|
|
1537
1548
|
const slot = useSlots();
|
|
1538
1549
|
const hours = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1550
|
+
const label = nowPosition && renderNowLabel?.(nowPosition.time);
|
|
1551
|
+
const labelHours = label == null || typeof label === "boolean" ? void 0 : nowPosition?.hours;
|
|
1539
1552
|
const laneCellHeightStyle = useAnimatedStyle(() => ({ height: laneHeight.value }));
|
|
1540
|
-
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
|
|
1553
|
+
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: Math.max(0, scrollY.value) }] }));
|
|
1541
1554
|
const rowsStyle = useAnimatedStyle(() => ({
|
|
1542
1555
|
top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
|
|
1543
1556
|
height: (maxHour - minHour) * cellHeight.value
|
|
@@ -1586,9 +1599,9 @@ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scro
|
|
|
1586
1599
|
children: allDayLabel
|
|
1587
1600
|
}) : null
|
|
1588
1601
|
}) : null,
|
|
1589
|
-
/* @__PURE__ */
|
|
1602
|
+
/* @__PURE__ */ jsxs(Animated.View, {
|
|
1590
1603
|
style: [styles$1.gutterRows, rowsStyle],
|
|
1591
|
-
children: hours.map((hour) => /* @__PURE__ */ jsx(View, {
|
|
1604
|
+
children: [hours.map((hour) => /* @__PURE__ */ jsx(View, {
|
|
1592
1605
|
style: styles$1.hourCell,
|
|
1593
1606
|
children: /* @__PURE__ */ jsx(View, {
|
|
1594
1607
|
style: [styles$1.hourRow, styles$1.nonInteractive],
|
|
@@ -1597,10 +1610,21 @@ const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scro
|
|
|
1597
1610
|
width,
|
|
1598
1611
|
label: formatHour(hour, { ampm }),
|
|
1599
1612
|
ampm,
|
|
1600
|
-
hourComponent
|
|
1613
|
+
hourComponent,
|
|
1614
|
+
hidden: labelHours != null && Math.abs(hour - labelHours) < NOW_LABEL_CLEARANCE_HOURS
|
|
1601
1615
|
})
|
|
1602
1616
|
})
|
|
1603
|
-
}, hour))
|
|
1617
|
+
}, hour)), labelHours != null ? /* @__PURE__ */ jsx(View, {
|
|
1618
|
+
style: [
|
|
1619
|
+
styles$1.nowLabel,
|
|
1620
|
+
styles$1.nonInteractive,
|
|
1621
|
+
{
|
|
1622
|
+
width,
|
|
1623
|
+
top: `${(labelHours - minHour) / (maxHour - minHour) * 100}%`
|
|
1624
|
+
}
|
|
1625
|
+
],
|
|
1626
|
+
children: label
|
|
1627
|
+
}) : null]
|
|
1604
1628
|
})
|
|
1605
1629
|
]
|
|
1606
1630
|
});
|
|
@@ -1729,14 +1753,13 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1729
1753
|
if (date) onLongPressCell?.(date);
|
|
1730
1754
|
};
|
|
1731
1755
|
const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1732
|
-
const
|
|
1756
|
+
const tickOnPage = showNowIndicator && isActive && nowProp == null;
|
|
1757
|
+
const pageClock = useNow$1(tickOnPage, {
|
|
1733
1758
|
now: nowProp,
|
|
1734
1759
|
timeZone: nowTimeZone
|
|
1735
1760
|
});
|
|
1736
|
-
const today =
|
|
1737
|
-
const
|
|
1738
|
-
const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
|
|
1739
|
-
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
1761
|
+
const today = tickOnPage ? pageClock : nowInTimeZone$1(nowProp, nowTimeZone);
|
|
1762
|
+
const nowPosition = showNowIndicator ? getNowPosition(today, days, minHour, maxHour) : null;
|
|
1740
1763
|
const fullHeightStyle = useAnimatedStyle(() => ({ height: (maxHour - minHour) * heightSource.value }), [
|
|
1741
1764
|
minHour,
|
|
1742
1765
|
maxHour,
|
|
@@ -1756,7 +1779,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1756
1779
|
height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
|
|
1757
1780
|
borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? StyleSheet.hairlineWidth : 0
|
|
1758
1781
|
}));
|
|
1759
|
-
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
|
|
1782
|
+
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: Math.max(0, scrollY.value) }] }));
|
|
1760
1783
|
const reportLaneLayout = useCallback((event) => {
|
|
1761
1784
|
onLaneLayout(pageIndex, event.nativeEvent.layout.height);
|
|
1762
1785
|
}, [onLaneLayout, pageIndex]);
|
|
@@ -2242,11 +2265,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2242
2265
|
minEventHeight,
|
|
2243
2266
|
eventGap
|
|
2244
2267
|
}) : null,
|
|
2245
|
-
|
|
2268
|
+
nowPosition ? /* @__PURE__ */ jsx(NowIndicator, {
|
|
2246
2269
|
cellHeight: heightSource,
|
|
2247
|
-
nowHours,
|
|
2270
|
+
nowHours: nowPosition.hours,
|
|
2248
2271
|
minHour,
|
|
2249
|
-
left: dayLeft(
|
|
2272
|
+
left: dayLeft(nowPosition.dayIndex),
|
|
2250
2273
|
width: dayWidth,
|
|
2251
2274
|
color: theme.colors.nowIndicator
|
|
2252
2275
|
}) : null,
|
|
@@ -2273,10 +2296,13 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2273
2296
|
});
|
|
2274
2297
|
}
|
|
2275
2298
|
const TimetablePage = memo(TimetablePageInner);
|
|
2276
|
-
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }, ref) {
|
|
2299
|
+
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", labels: labelsProp, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now: nowProp, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onPressDateHeader, onChangeDate, renderHeader, renderNowLabel, contentPaddingBottom = 0, onVerticalScroll, verticalBounces = true, classNames, styles: styleOverrides }, ref) {
|
|
2277
2300
|
const clampedMinHour = Math.max(0, Math.min(minHour, 23));
|
|
2278
2301
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
2279
2302
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
2303
|
+
const hasNowLabel = showNowIndicator && renderNowLabel != null && hourColumnWidth > 0;
|
|
2304
|
+
const labelClock = useNow$1(hasNowLabel, { now: nowProp });
|
|
2305
|
+
const now = nowProp ?? (hasNowLabel ? labelClock : void 0);
|
|
2280
2306
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
2281
2307
|
const todayLabel = labels.today;
|
|
2282
2308
|
const pagedHeader = renderHeader == null;
|
|
@@ -2312,7 +2338,21 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2312
2338
|
const scrollY = useSharedValue(seedDefaultY);
|
|
2313
2339
|
const scrollHandler = useAnimatedScrollHandler({ onScroll: (event) => {
|
|
2314
2340
|
scrollY.value = event.contentOffset.y;
|
|
2315
|
-
|
|
2341
|
+
if (onVerticalScroll) runOnJS(onVerticalScroll)({ nativeEvent: {
|
|
2342
|
+
contentOffset: {
|
|
2343
|
+
x: event.contentOffset.x,
|
|
2344
|
+
y: event.contentOffset.y
|
|
2345
|
+
},
|
|
2346
|
+
contentSize: {
|
|
2347
|
+
width: event.contentSize.width,
|
|
2348
|
+
height: event.contentSize.height
|
|
2349
|
+
},
|
|
2350
|
+
layoutMeasurement: {
|
|
2351
|
+
width: event.layoutMeasurement.width,
|
|
2352
|
+
height: event.layoutMeasurement.height
|
|
2353
|
+
}
|
|
2354
|
+
} });
|
|
2355
|
+
} }, [onVerticalScroll]);
|
|
2316
2356
|
const [mountOffsetY] = useState(seedDefaultY);
|
|
2317
2357
|
const webSeededRef = useRef(!isWeb$1);
|
|
2318
2358
|
const seedWebScroll = useCallback(() => {
|
|
@@ -2496,17 +2536,17 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2496
2536
|
hiddenDays,
|
|
2497
2537
|
weekNumberPrefix
|
|
2498
2538
|
]);
|
|
2499
|
-
const
|
|
2539
|
+
const activePageDate = pageDates[activeIndex] ?? date;
|
|
2540
|
+
const headerDays = useMemo(() => getViewDays$1(mode, activePageDate, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
2500
2541
|
mode,
|
|
2501
|
-
|
|
2502
|
-
activeIndex,
|
|
2503
|
-
date,
|
|
2542
|
+
activePageDate,
|
|
2504
2543
|
weekStartsOn,
|
|
2505
2544
|
numberOfDays,
|
|
2506
2545
|
isRTL,
|
|
2507
2546
|
weekEndsOn,
|
|
2508
2547
|
hiddenDays
|
|
2509
2548
|
]);
|
|
2549
|
+
const gutterNow = hasNowLabel ? getNowPosition(nowInTimeZone$1(now, timeZone), headerDays, clampedMinHour, clampedMaxHour) : null;
|
|
2510
2550
|
dropRef.current = {
|
|
2511
2551
|
headerDays,
|
|
2512
2552
|
columnsWidth,
|
|
@@ -2542,9 +2582,25 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2542
2582
|
animated: false
|
|
2543
2583
|
});
|
|
2544
2584
|
}, [activeIndex]);
|
|
2545
|
-
|
|
2585
|
+
const laidOutWidthRef = useRef(null);
|
|
2586
|
+
useLayoutEffect(() => {
|
|
2546
2587
|
pagerOffset.value = activeIndex * columnsWidth;
|
|
2547
|
-
|
|
2588
|
+
if (!pagerReady) {
|
|
2589
|
+
laidOutWidthRef.current = null;
|
|
2590
|
+
return;
|
|
2591
|
+
}
|
|
2592
|
+
const previous = laidOutWidthRef.current;
|
|
2593
|
+
laidOutWidthRef.current = columnsWidth;
|
|
2594
|
+
if (previous == null || previous === columnsWidth) return;
|
|
2595
|
+
listRef.current?.scrollToIndex({
|
|
2596
|
+
index: activeIndex,
|
|
2597
|
+
animated: false
|
|
2598
|
+
});
|
|
2599
|
+
}, [
|
|
2600
|
+
columnsWidth,
|
|
2601
|
+
pagerOffset,
|
|
2602
|
+
pagerReady
|
|
2603
|
+
]);
|
|
2548
2604
|
useEffect(() => {
|
|
2549
2605
|
if (!isWeb$1) return;
|
|
2550
2606
|
let attempts = 0;
|
|
@@ -2638,8 +2694,12 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2638
2694
|
pageDates,
|
|
2639
2695
|
onChangeDate
|
|
2640
2696
|
]);
|
|
2697
|
+
const pagerDraggingRef = useRef(false);
|
|
2698
|
+
const pagerUserScrollRef = useRef(false);
|
|
2641
2699
|
const handlePagerSettled = useCallback((event) => {
|
|
2642
2700
|
if (columnsWidth <= 0) return;
|
|
2701
|
+
if (!pagerUserScrollRef.current || pagerDraggingRef.current) return;
|
|
2702
|
+
pagerUserScrollRef.current = false;
|
|
2643
2703
|
if (pendingScrollIndexRef.current != null) return;
|
|
2644
2704
|
const index = commitNearestPage(event.nativeEvent.contentOffset.x);
|
|
2645
2705
|
pagerOffset.value = index * columnsWidth;
|
|
@@ -2654,7 +2714,6 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2654
2714
|
commitNearestPage,
|
|
2655
2715
|
pagerOffset
|
|
2656
2716
|
]);
|
|
2657
|
-
const pagerDraggingRef = useRef(false);
|
|
2658
2717
|
const lastPagerScrollRef = useRef({
|
|
2659
2718
|
offsetX: 0,
|
|
2660
2719
|
at: 0
|
|
@@ -2703,6 +2762,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2703
2762
|
}, [armPagerIdleTimer]);
|
|
2704
2763
|
const handlePagerDragStart = useCallback(() => {
|
|
2705
2764
|
pagerDraggingRef.current = true;
|
|
2765
|
+
pagerUserScrollRef.current = true;
|
|
2706
2766
|
}, []);
|
|
2707
2767
|
const handlePagerDragEnd = useCallback(() => {
|
|
2708
2768
|
pagerDraggingRef.current = false;
|
|
@@ -2842,6 +2902,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2842
2902
|
dragStepMinutes,
|
|
2843
2903
|
minHour,
|
|
2844
2904
|
maxHour,
|
|
2905
|
+
headerDays,
|
|
2906
|
+
showNowIndicator,
|
|
2845
2907
|
nowTime,
|
|
2846
2908
|
timeZone
|
|
2847
2909
|
}), [
|
|
@@ -2854,6 +2916,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2854
2916
|
dragStepMinutes,
|
|
2855
2917
|
minHour,
|
|
2856
2918
|
maxHour,
|
|
2919
|
+
headerDays,
|
|
2920
|
+
showNowIndicator,
|
|
2857
2921
|
nowTime,
|
|
2858
2922
|
timeZone
|
|
2859
2923
|
]);
|
|
@@ -2893,6 +2957,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2893
2957
|
x: 0,
|
|
2894
2958
|
y: mountOffsetY
|
|
2895
2959
|
},
|
|
2960
|
+
contentContainerStyle: contentPaddingBottom > 0 ? { paddingBottom: contentPaddingBottom } : void 0,
|
|
2961
|
+
bounces: verticalBounces,
|
|
2962
|
+
overScrollMode: verticalBounces ? void 0 : "never",
|
|
2896
2963
|
children: /* @__PURE__ */ jsxs(Animated.View, {
|
|
2897
2964
|
testID: "time-grid-hours",
|
|
2898
2965
|
style: [styles$1.gridRow, gridHeightStyle],
|
|
@@ -2909,7 +2976,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2909
2976
|
headerHeight: headerOffset,
|
|
2910
2977
|
weekNumber,
|
|
2911
2978
|
ampm,
|
|
2912
|
-
hourComponent
|
|
2979
|
+
hourComponent,
|
|
2980
|
+
renderNowLabel,
|
|
2981
|
+
nowPosition: gutterNow
|
|
2913
2982
|
}) : null, /* @__PURE__ */ jsxs(View, {
|
|
2914
2983
|
ref: pagerRef,
|
|
2915
2984
|
testID: "time-grid-pager",
|
|
@@ -2946,18 +3015,16 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2946
3015
|
disableIntervalMomentum: !freeSwipe,
|
|
2947
3016
|
scrollEventThrottle: 16,
|
|
2948
3017
|
onMomentumScrollEnd: handlePagerSettled,
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
onScrollEndDrag: handlePagerDragEnd
|
|
2953
|
-
} : null
|
|
3018
|
+
onScrollBeginDrag: handlePagerDragStart,
|
|
3019
|
+
onScrollEndDrag: handlePagerDragEnd,
|
|
3020
|
+
...Platform.OS === "android" ? { onScroll: handlePagerScroll } : null
|
|
2954
3021
|
},
|
|
2955
3022
|
initialScrollIndex: activeIndex,
|
|
2956
3023
|
showsHorizontalScrollIndicator: false,
|
|
2957
3024
|
viewabilityConfig: PAGE_VIEWABILITY,
|
|
2958
3025
|
onViewableItemsChanged: handleViewableItemsChanged,
|
|
2959
3026
|
renderItem
|
|
2960
|
-
}
|
|
3027
|
+
}) : null, liftedEvent ? /* @__PURE__ */ jsx(DragGhost, {
|
|
2961
3028
|
x: ghostX,
|
|
2962
3029
|
y: ghostY,
|
|
2963
3030
|
w: ghostW,
|
|
@@ -3151,6 +3218,11 @@ const styles$1 = StyleSheet.create({
|
|
|
3151
3218
|
textAlign: "right",
|
|
3152
3219
|
paddingRight: 6
|
|
3153
3220
|
},
|
|
3221
|
+
nowLabel: {
|
|
3222
|
+
position: "absolute",
|
|
3223
|
+
left: 0,
|
|
3224
|
+
marginTop: -6
|
|
3225
|
+
},
|
|
3154
3226
|
gutterRows: {
|
|
3155
3227
|
position: "absolute",
|
|
3156
3228
|
left: 0,
|
|
@@ -3311,7 +3383,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn, numb
|
|
|
3311
3383
|
* ```
|
|
3312
3384
|
*/
|
|
3313
3385
|
const Calendar = forwardRef(CalendarInner);
|
|
3314
|
-
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, numberOfWeeks = 2, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
|
|
3386
|
+
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, numberOfWeeks = 2, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderNowLabel, timeGridContentPaddingBottom, onTimeGridScroll, timeGridBounces, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
|
|
3315
3387
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
3316
3388
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
3317
3389
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -3588,6 +3660,10 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3588
3660
|
onPressDateHeader,
|
|
3589
3661
|
onChangeDate: handleChangeDate,
|
|
3590
3662
|
renderHeader: renderTimeGridHeader,
|
|
3663
|
+
renderNowLabel,
|
|
3664
|
+
contentPaddingBottom: timeGridContentPaddingBottom,
|
|
3665
|
+
onVerticalScroll: onTimeGridScroll,
|
|
3666
|
+
verticalBounces: timeGridBounces,
|
|
3591
3667
|
classNames,
|
|
3592
3668
|
styles: styleOverrides
|
|
3593
3669
|
})
|
package/dist/picker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_MonthList = require("./MonthList-
|
|
2
|
+
const require_MonthList = require("./MonthList-CGgy0Juh.js");
|
|
3
3
|
let _super_calendar_core = require("@super-calendar/core");
|
|
4
4
|
exports.CalendarThemeProvider = require_MonthList.CalendarThemeProvider;
|
|
5
5
|
exports.DefaultMonthEvent = require_MonthList.DefaultMonthEvent;
|
package/dist/picker.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { _ as mergeTheme, g as defaultTheme, h as darkTheme, i as MonthPager, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, t as MonthList, v as useCalendarTheme } from "./MonthList-
|
|
1
|
+
import { _ as mergeTheme, g as defaultTheme, h as darkTheme, i as MonthPager, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, t as MonthList, v as useCalendarTheme } from "./MonthList-CPpsr5Oa.mjs";
|
|
2
2
|
import { buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
|
|
3
3
|
export { CalendarThemeProvider, DefaultMonthEvent, MonthList, MonthPager, MonthView, 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.20.1",
|
|
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,10 +64,10 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@super-calendar/core": "2.
|
|
67
|
+
"@super-calendar/core": "2.20.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@legendapp/list": ">=3",
|
|
70
|
+
"@legendapp/list": ">=3.7.1",
|
|
71
71
|
"date-fns": ">=3",
|
|
72
72
|
"react": ">=18",
|
|
73
73
|
"react-native": ">=0.74 <2",
|
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
type HourRenderer,
|
|
69
69
|
TimeGrid,
|
|
70
70
|
type TimeGridSlot,
|
|
71
|
+
type VerticalScrollEvent,
|
|
71
72
|
} from "./TimeGrid";
|
|
72
73
|
|
|
73
74
|
/**
|
|
@@ -373,6 +374,14 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
373
374
|
freeSwipe?: boolean;
|
|
374
375
|
/** Custom header above the week/day grid. Receives the visible days. */
|
|
375
376
|
renderTimeGridHeader?: (days: Date[]) => React.ReactNode;
|
|
377
|
+
/** Draw a label in the hour column when the current-time line is visible. */
|
|
378
|
+
renderNowLabel?: (now: Date) => React.ReactNode;
|
|
379
|
+
/** Week/day grid: extra scrollable space below the last hour (e.g. for a floating tab bar). Default 0. */
|
|
380
|
+
timeGridContentPaddingBottom?: number;
|
|
381
|
+
/** Week/day grid: the vertical scroll view's scroll events, on the JS thread. */
|
|
382
|
+
onTimeGridScroll?: (event: VerticalScrollEvent) => void;
|
|
383
|
+
/** Week/day grid: `false` turns off overscroll on the hours (iOS bounce, Android stretch). Default true. */
|
|
384
|
+
timeGridBounces?: boolean;
|
|
376
385
|
/** Replace the weekday-label header above the month grid. Return `null` to hide it. */
|
|
377
386
|
renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
|
|
378
387
|
/**
|
|
@@ -590,6 +599,10 @@ function CalendarInner<T>(
|
|
|
590
599
|
isRTL,
|
|
591
600
|
freeSwipe,
|
|
592
601
|
renderTimeGridHeader,
|
|
602
|
+
renderNowLabel,
|
|
603
|
+
timeGridContentPaddingBottom,
|
|
604
|
+
onTimeGridScroll,
|
|
605
|
+
timeGridBounces,
|
|
593
606
|
renderHeaderForMonthView,
|
|
594
607
|
renderCustomDateForMonth,
|
|
595
608
|
itemSeparatorComponent,
|
|
@@ -974,6 +987,10 @@ function CalendarInner<T>(
|
|
|
974
987
|
onPressDateHeader={onPressDateHeader}
|
|
975
988
|
onChangeDate={handleChangeDate}
|
|
976
989
|
renderHeader={renderTimeGridHeader}
|
|
990
|
+
renderNowLabel={renderNowLabel}
|
|
991
|
+
contentPaddingBottom={timeGridContentPaddingBottom}
|
|
992
|
+
onVerticalScroll={onTimeGridScroll}
|
|
993
|
+
verticalBounces={timeGridBounces}
|
|
977
994
|
classNames={classNames}
|
|
978
995
|
styles={styleOverrides}
|
|
979
996
|
/>
|
|
@@ -224,10 +224,20 @@ function MonthListInner<T>({
|
|
|
224
224
|
// `events` and `activeDate` (renderItem captures them; without this, events
|
|
225
225
|
// that arrive after mount never paint, same bug as the MonthPager had) plus
|
|
226
226
|
// `firstViewableIndex` (the web `inert` cutoff must stay current). Selection
|
|
227
|
-
// needs no entry: it reaches MonthView through context.
|
|
227
|
+
// needs no entry: it reaches MonthView through context. `weekRowHeight` and
|
|
228
|
+
// `monthHeaderHeight` size each month, and LegendList re-resolves
|
|
229
|
+
// `getFixedItemSize` only when `extraData` changes.
|
|
228
230
|
const listExtraData = useMemo(
|
|
229
|
-
() => ({
|
|
230
|
-
|
|
231
|
+
() => ({
|
|
232
|
+
events,
|
|
233
|
+
activeDate,
|
|
234
|
+
firstViewableIndex,
|
|
235
|
+
chipHeight,
|
|
236
|
+
chipGap,
|
|
237
|
+
weekRowHeight,
|
|
238
|
+
monthHeaderHeight,
|
|
239
|
+
}),
|
|
240
|
+
[events, activeDate, firstViewableIndex, chipHeight, chipGap, weekRowHeight, monthHeaderHeight],
|
|
231
241
|
);
|
|
232
242
|
|
|
233
243
|
// A fixed window of months anchored once, aligned to the month start.
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
type ReactElement,
|
|
23
23
|
useCallback,
|
|
24
24
|
useEffect,
|
|
25
|
+
useLayoutEffect,
|
|
25
26
|
useMemo,
|
|
26
27
|
useRef,
|
|
27
28
|
useState,
|
|
@@ -352,6 +353,18 @@ function DateRowsPagerInner<T>({
|
|
|
352
353
|
void listRef.current?.scrollToIndex({ index: activeIndex, animated: false });
|
|
353
354
|
}, [activeIndex]);
|
|
354
355
|
|
|
356
|
+
// A new container width resizes every page (see `listExtraData`), but the
|
|
357
|
+
// native scroll offset stays at the old `index * width`, which now points at a
|
|
358
|
+
// different month or between two. Scroll back to the committed page.
|
|
359
|
+
// Before paint, so the one frame Android shows between the resize and the scroll
|
|
360
|
+
// is blank rather than a wrong month.
|
|
361
|
+
const laidOutWidthRef = useRef(containerWidth);
|
|
362
|
+
useLayoutEffect(() => {
|
|
363
|
+
if (containerWidth === laidOutWidthRef.current) return;
|
|
364
|
+
laidOutWidthRef.current = containerWidth;
|
|
365
|
+
void listRef.current?.scrollToIndex({ index: activeIndex, animated: false });
|
|
366
|
+
}, [containerWidth, activeIndex]);
|
|
367
|
+
|
|
355
368
|
// Web arrow-key paging (swipe is disabled there); the effect above scrolls to
|
|
356
369
|
// the new month once `onChangeDate` updates `date`.
|
|
357
370
|
const goToPage = useCallback(
|
|
@@ -381,9 +394,13 @@ function DateRowsPagerInner<T>({
|
|
|
381
394
|
// grids as renderItem props, not through the selection context below: toggling
|
|
382
395
|
// a "pick dates" mode on must reach the pages already rendered.
|
|
383
396
|
// `now` and `timeZone` move the today highlight on the pages already rendered.
|
|
397
|
+
// `containerWidth` and `pageHeight` resize them: LegendList re-resolves
|
|
398
|
+
// `getFixedItemSize` only when `extraData` changes.
|
|
384
399
|
const nowTime = now?.getTime();
|
|
385
400
|
const monthExtraData = useMemo(
|
|
386
401
|
() => ({
|
|
402
|
+
containerWidth,
|
|
403
|
+
pageHeight,
|
|
387
404
|
events,
|
|
388
405
|
activeDate,
|
|
389
406
|
nowTime,
|
|
@@ -398,6 +415,8 @@ function DateRowsPagerInner<T>({
|
|
|
398
415
|
createGhostStyle: styleOverrides?.createGhost,
|
|
399
416
|
}),
|
|
400
417
|
[
|
|
418
|
+
containerWidth,
|
|
419
|
+
pageHeight,
|
|
401
420
|
events,
|
|
402
421
|
activeDate,
|
|
403
422
|
nowTime,
|
|
@@ -440,7 +459,7 @@ function DateRowsPagerInner<T>({
|
|
|
440
459
|
const getFixedItemSize = useCallback(() => containerWidth, [containerWidth]);
|
|
441
460
|
const renderItem = useCallback(
|
|
442
461
|
({ item }: LegendListRenderItemProps<Date>) => (
|
|
443
|
-
<View style={{ width: containerWidth, height: pageHeight }}>
|
|
462
|
+
<View testID="month-pager-page" style={{ width: containerWidth, height: pageHeight }}>
|
|
444
463
|
<DateRows
|
|
445
464
|
source={sourceFor(item)}
|
|
446
465
|
events={events}
|
|
@@ -574,6 +593,7 @@ function DateRowsPagerInner<T>({
|
|
|
574
593
|
/>
|
|
575
594
|
)}
|
|
576
595
|
<View
|
|
596
|
+
testID="month-pager"
|
|
577
597
|
style={styles.pager}
|
|
578
598
|
onLayout={(event) => {
|
|
579
599
|
setPageHeight(event.nativeEvent.layout.height);
|
|
@@ -581,10 +601,6 @@ function DateRowsPagerInner<T>({
|
|
|
581
601
|
}}
|
|
582
602
|
>
|
|
583
603
|
<LegendList
|
|
584
|
-
// Remount when the measured page height changes so the list adopts the
|
|
585
|
-
// corrected item height. Without this the list can keep the oversized
|
|
586
|
-
// initial (window-height) seed and clip the last week row.
|
|
587
|
-
key={pageHeight}
|
|
588
604
|
ref={listRef}
|
|
589
605
|
style={isWeb ? [styles.pagerList, styles.webNoScroll] : styles.pagerList}
|
|
590
606
|
data={monthDates}
|
|
@@ -858,10 +858,17 @@ function DateRowsInner<T>({
|
|
|
858
858
|
// day, so neither can be a drag's origin or its drop target.
|
|
859
859
|
const hitTest = useCallback(
|
|
860
860
|
(x: number, y: number): { day: Date; event: CalendarEvent<T> | null } | null => {
|
|
861
|
-
|
|
861
|
+
// On the web `onLayout` reaches state a few frames after the grid gets its
|
|
862
|
+
// size, so a press right after the pager resizes a page can land on a grid
|
|
863
|
+
// that was never measured. Its box (the space `gridPoint` maps into) is current.
|
|
864
|
+
let { width, height } = gridSize;
|
|
865
|
+
if ((width <= 0 || height <= 0) && isWeb && gridRef.current instanceof Element) {
|
|
866
|
+
({ width, height } = gridRef.current.getBoundingClientRect());
|
|
867
|
+
}
|
|
862
868
|
if (width <= 0 || height <= 0 || weeks.length === 0) return null;
|
|
863
|
-
|
|
864
|
-
let
|
|
869
|
+
const pitch = rowHeight > 0 ? rowHeight : height / weeks.length;
|
|
870
|
+
let row = Math.min(weeks.length - 1, Math.max(0, Math.floor(y / pitch)));
|
|
871
|
+
let rowTop = row * pitch;
|
|
865
872
|
if (multiWeek) {
|
|
866
873
|
// A styled grid can have padding, space between weeks, or overflowing rows.
|
|
867
874
|
// Web layout notifications can miss a move that does not resize the row.
|
|
@@ -875,7 +882,7 @@ function DateRowsInner<T>({
|
|
|
875
882
|
const borderTop = node
|
|
876
883
|
? node.getBoundingClientRect().top - gridTop
|
|
877
884
|
: weekTops.current[index];
|
|
878
|
-
return borderTop == null ? index *
|
|
885
|
+
return borderTop == null ? index * pitch : borderTop - cellGeometry.weekMarginTop;
|
|
879
886
|
};
|
|
880
887
|
row = weekAtOffset(y, weeks.length, topOf);
|
|
881
888
|
rowTop = topOf(row);
|