@super-calendar/native 2.12.1 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/{DefaultMonthEvent-B9KzVzFa.d.mts → DefaultMonthEvent-BDD7GgL8.d.mts} +17 -5
- package/dist/{DefaultMonthEvent-DlIIWDzr.d.ts → DefaultMonthEvent-ggwYo7Fy.d.ts} +17 -5
- package/dist/{MonthList-sGAZxQZ_.js → MonthList-D4_LBnbU.js} +47 -19
- package/dist/{MonthList-B-UE37ZG.mjs → MonthList-DWCH3GT5.mjs} +47 -19
- package/dist/index.d.mts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +42 -5
- package/dist/index.mjs +43 -6
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Calendar.tsx +134 -97
- package/src/components/MonthList.tsx +12 -2
- package/src/components/MonthPager.tsx +19 -2
- package/src/components/MonthView.tsx +18 -12
- package/src/components/TimeGrid.tsx +115 -70
- package/src/index.tsx +2 -0
- package/src/types.ts +2 -0
|
@@ -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,
|