@super-calendar/native 2.10.0 → 2.11.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 +1 -1
- package/dist/{DefaultMonthEvent--9Jg6w-x.d.ts → DefaultMonthEvent-B9KzVzFa.d.mts} +11 -5
- package/dist/{DefaultMonthEvent-BlnKHaq2.d.mts → DefaultMonthEvent-DlIIWDzr.d.ts} +11 -5
- package/dist/{MonthList-CjKhzOJX.mjs → MonthList-B-UE37ZG.mjs} +166 -139
- package/dist/{MonthList-DNT1LJkk.js → MonthList-sGAZxQZ_.js} +176 -137
- package/dist/index.d.mts +67 -21
- package/dist/index.d.ts +67 -21
- package/dist/index.js +1121 -772
- package/dist/index.mjs +1117 -774
- 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 +3 -3
- package/src/components/Agenda.tsx +5 -1
- package/src/components/AllDayLane.tsx +36 -53
- package/src/components/Calendar.tsx +196 -149
- package/src/components/DefaultEvent.tsx +3 -0
- package/src/components/DefaultMonthEvent.tsx +3 -0
- package/src/components/MonthList.tsx +6 -0
- package/src/components/MonthPager.tsx +6 -0
- package/src/components/MonthView.tsx +195 -172
- package/src/components/MultiDayMovePreview.tsx +1 -3
- package/src/components/ResourceTimeline.tsx +18 -7
- package/src/components/TimeGrid.tsx +1409 -903
- package/src/components/YearView.tsx +22 -5
- package/src/index.tsx +1 -0
- package/src/utils/labels.ts +13 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LegendList,
|
|
3
2
|
type LegendListRef,
|
|
4
3
|
type LegendListRenderItemProps,
|
|
5
4
|
type OnViewableItemsChangedInfo,
|
|
6
5
|
} from "@legendapp/list/react-native";
|
|
6
|
+
import { AnimatedLegendList } from "@legendapp/list/reanimated";
|
|
7
7
|
import {
|
|
8
8
|
addDays,
|
|
9
9
|
differenceInCalendarDays,
|
|
@@ -31,6 +31,9 @@ import {
|
|
|
31
31
|
import {
|
|
32
32
|
type AccessibilityActionEvent,
|
|
33
33
|
type GestureResponderEvent,
|
|
34
|
+
type LayoutChangeEvent,
|
|
35
|
+
type NativeScrollEvent,
|
|
36
|
+
type NativeSyntheticEvent,
|
|
34
37
|
Platform,
|
|
35
38
|
Pressable,
|
|
36
39
|
StyleSheet,
|
|
@@ -40,11 +43,11 @@ import {
|
|
|
40
43
|
useWindowDimensions,
|
|
41
44
|
View,
|
|
42
45
|
type ViewStyle,
|
|
46
|
+
type ScrollViewProps,
|
|
43
47
|
} from "react-native";
|
|
44
48
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
45
49
|
import Animated, {
|
|
46
50
|
runOnJS,
|
|
47
|
-
scrollTo,
|
|
48
51
|
type SharedValue,
|
|
49
52
|
useAnimatedReaction,
|
|
50
53
|
useAnimatedRef,
|
|
@@ -86,7 +89,8 @@ import {
|
|
|
86
89
|
snapDeltaMinutes,
|
|
87
90
|
} from "@super-calendar/core";
|
|
88
91
|
import { formatHour, layoutDayEvents, type PositionedEvent } from "@super-calendar/core";
|
|
89
|
-
import type { EventAccessibilityLabeler } from "@super-calendar/core";
|
|
92
|
+
import type { CalendarLabels, EventAccessibilityLabeler } from "@super-calendar/core";
|
|
93
|
+
import { resolveCalendarLabels } from "@super-calendar/core";
|
|
90
94
|
import { type WeekdayFormat, weekdayFormatToken } from "@super-calendar/core";
|
|
91
95
|
import {
|
|
92
96
|
type ResolvedSlot,
|
|
@@ -97,6 +101,7 @@ import {
|
|
|
97
101
|
import { useWebGridZoom } from "../utils/useWebGridZoom";
|
|
98
102
|
import { useWebPagerKeys } from "../utils/useWebPagerKeys";
|
|
99
103
|
import { withEventAccessibilityLabel } from "../utils/withEventAccessibilityLabel";
|
|
104
|
+
import { CalendarLabelsContext, useCalendarLabels } from "../utils/labels";
|
|
100
105
|
import { AllDayLane } from "./AllDayLane";
|
|
101
106
|
import { type MultiDayMove, MultiDayMovePreview } from "./MultiDayMovePreview";
|
|
102
107
|
|
|
@@ -155,28 +160,31 @@ const DEFAULT_DRAG_STEP_MINUTES = 15;
|
|
|
155
160
|
// moved over a later event would fall behind it).
|
|
156
161
|
const DRAG_EVENT_Z = 100;
|
|
157
162
|
// How long to hold the dragged event past the visible columns before the view
|
|
158
|
-
// pages one period toward that edge
|
|
159
|
-
|
|
163
|
+
// pages one period toward that edge, and the interval between further pages
|
|
164
|
+
// while the finger stays there.
|
|
165
|
+
const EDGE_DWELL_MS = 600;
|
|
166
|
+
const EDGE_REPEAT_MS = 700;
|
|
160
167
|
// How close (px) the dragging finger must get to the pager's left/right edge to
|
|
161
168
|
// count as "past the columns". Detecting by finger position, not by how many
|
|
162
169
|
// columns the drag has crossed, so an event in any column can reach either edge
|
|
163
|
-
// (a column-delta test can't reach the far edge from a near-side column).
|
|
164
|
-
|
|
170
|
+
// (a column-delta test can't reach the far edge from a near-side column). Kept
|
|
171
|
+
// narrow: on a phone the last column is only a few times this wide.
|
|
172
|
+
const EDGE_ZONE_PX = 24;
|
|
165
173
|
|
|
166
174
|
/**
|
|
167
175
|
* Lets a per-event drag worklet, deep inside the pager, drive a cross-week drag:
|
|
168
|
-
* locate the pager's edges,
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* ghost that survives the source page paging away, then commit on release.
|
|
176
|
+
* locate the pager's edges, page the view under the held finger, and hand the
|
|
177
|
+
* event off to a floating ghost that survives the source page paging away, then
|
|
178
|
+
* commit on release.
|
|
172
179
|
*/
|
|
173
180
|
type EdgePaging = {
|
|
174
181
|
// Pager frame in window space, so the worklet can find the edges and place the
|
|
175
182
|
// ghost (its top-left is the window origin the finger coords are relative to).
|
|
183
|
+
// The pager scrolls with the grid, so its top is derived live from the scroll
|
|
184
|
+
// viewport's top and the current offset.
|
|
176
185
|
pagerLeft: SharedValue<number>;
|
|
177
|
-
pagerTop:
|
|
186
|
+
pagerTop: ReturnType<typeof useDerivedValue<number>>;
|
|
178
187
|
pagerWidth: SharedValue<number>;
|
|
179
|
-
lockScroll: (locked: boolean) => void;
|
|
180
188
|
// The floating "held" copy of the dragged event: pager-local top-left, size, and
|
|
181
189
|
// visibility, driven on the UI thread so it tracks the finger across the page.
|
|
182
190
|
ghostX: SharedValue<number>;
|
|
@@ -184,8 +192,8 @@ type EdgePaging = {
|
|
|
184
192
|
ghostW: SharedValue<number>;
|
|
185
193
|
ghostH: SharedValue<number>;
|
|
186
194
|
ghostVisible: SharedValue<number>;
|
|
187
|
-
// Show the ghost for `event`, then drop it at pager-local
|
|
188
|
-
//
|
|
195
|
+
// Show the ghost for `event`, then drop it at its pager-local top-left
|
|
196
|
+
// (clearing the ghost either way).
|
|
189
197
|
beginLift: (event: CalendarEvent<unknown>) => void;
|
|
190
198
|
commitLiftedDrop: (ghostLocalX: number, minuteDelta: number) => void;
|
|
191
199
|
};
|
|
@@ -318,7 +326,14 @@ export type { EventDragHandler, EventDragStartHandler } from "../types";
|
|
|
318
326
|
// Hour labels are nudged up so the number sits centred on its grid line. Pad the
|
|
319
327
|
// scroll content by the same amount so the top-most label is never clipped.
|
|
320
328
|
const HOUR_LABEL_TOP_INSET = 12;
|
|
329
|
+
// Least height the all-day band keeps, so the lane inside stays measurable (see
|
|
330
|
+
// the band's height style).
|
|
331
|
+
const LANE_BAND_FLOOR = 1;
|
|
321
332
|
const HOUR_LABEL_NUDGE = 6;
|
|
333
|
+
// Fixed height of the day-header row. The header pages with the columns (it
|
|
334
|
+
// lives inside each page), so the hour column's corner, the all-day band, and
|
|
335
|
+
// the hours all offset by this without measuring the header per page.
|
|
336
|
+
const DAY_HEADER_HEIGHT = 56;
|
|
322
337
|
|
|
323
338
|
type AnimatedEventBoxProps<T> = {
|
|
324
339
|
positioned: PositionedEvent<T>;
|
|
@@ -368,7 +383,7 @@ type AnimatedEventBoxProps<T> = {
|
|
|
368
383
|
onEdgeAdvance?: (dir: number) => void;
|
|
369
384
|
};
|
|
370
385
|
|
|
371
|
-
function
|
|
386
|
+
function AnimatedEventBoxInner<T>({
|
|
372
387
|
positioned,
|
|
373
388
|
eventIndex,
|
|
374
389
|
movingEvent,
|
|
@@ -401,9 +416,10 @@ function AnimatedEventBox<T>({
|
|
|
401
416
|
}: AnimatedEventBoxProps<T>) {
|
|
402
417
|
const RenderEventComponent = renderEvent;
|
|
403
418
|
const theme = useCalendarTheme();
|
|
419
|
+
const labels = useCalendarLabels();
|
|
404
420
|
const slot = useSlots<TimeGridSlot>();
|
|
405
|
-
// Pager geometry
|
|
406
|
-
//
|
|
421
|
+
// Pager geometry, so a cross-week edge drag can find the edges and page the
|
|
422
|
+
// view live under the finger (see EdgePaging). The two edge
|
|
407
423
|
// shared values are pulled out so the move worklet closes over them directly
|
|
408
424
|
// rather than over the whole context object (which also holds a JS callback).
|
|
409
425
|
const edgePaging = useContext(EdgePagingContext);
|
|
@@ -515,13 +531,16 @@ function AnimatedEventBox<T>({
|
|
|
515
531
|
// already renders. Purely geometric, so a resting box (already clipped to the
|
|
516
532
|
// day by `layoutDayEvents`) is untouched and the height doesn't jump when a
|
|
517
533
|
// drag commits.
|
|
534
|
+
// Hidden while lifted: the floating ghost stands in for the box until the
|
|
535
|
+
// drop commits (and, for a multi-day move, while the preview draws it).
|
|
518
536
|
return {
|
|
519
537
|
top,
|
|
520
538
|
height: visibleBoxHeight.value,
|
|
521
539
|
transform: [{ translateX: moveOffsetX.value }],
|
|
522
540
|
zIndex: dragZ.value,
|
|
541
|
+
opacity: hiddenForMove || lifted.value ? 0 : 1,
|
|
523
542
|
};
|
|
524
|
-
}, [startHours, minHour]);
|
|
543
|
+
}, [startHours, minHour, hiddenForMove]);
|
|
525
544
|
|
|
526
545
|
// Pixel height of the part of a move that runs past midnight, or 0 when nothing
|
|
527
546
|
// spills. Measured against the end of the day, not `maxHour`: a narrowed window
|
|
@@ -592,8 +611,22 @@ function AnimatedEventBox<T>({
|
|
|
592
611
|
|
|
593
612
|
// Keep the latest event/handler in a ref so the gestures stay memoized but
|
|
594
613
|
// never call into a stale closure.
|
|
595
|
-
const latest = useRef({
|
|
596
|
-
|
|
614
|
+
const latest = useRef({
|
|
615
|
+
event: positioned.event,
|
|
616
|
+
eventIndex,
|
|
617
|
+
onDragEvent,
|
|
618
|
+
onDragStart,
|
|
619
|
+
onPress,
|
|
620
|
+
onLongPress,
|
|
621
|
+
});
|
|
622
|
+
latest.current = {
|
|
623
|
+
event: positioned.event,
|
|
624
|
+
eventIndex,
|
|
625
|
+
onDragEvent,
|
|
626
|
+
onDragStart,
|
|
627
|
+
onPress,
|
|
628
|
+
onLongPress,
|
|
629
|
+
};
|
|
597
630
|
|
|
598
631
|
// Snap the box back to where it started (drop rejected or degenerate).
|
|
599
632
|
const snapBack = useCallback(() => {
|
|
@@ -658,9 +691,9 @@ function AnimatedEventBox<T>({
|
|
|
658
691
|
|
|
659
692
|
// Edge auto-advance dwell. Dragging the event past the visible columns and
|
|
660
693
|
// holding there pages the view one period and carries the event onto it: same
|
|
661
|
-
// weekday, keeping whatever time the vertical drag has reached. It
|
|
662
|
-
//
|
|
663
|
-
//
|
|
694
|
+
// weekday, keeping whatever time the vertical drag has reached. It keeps paging
|
|
695
|
+
// while the finger stays at the edge, matching "hold at the edge to move to the
|
|
696
|
+
// next/previous week"; the tested commit path does the move.
|
|
664
697
|
const dwellTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
665
698
|
const disarmEdge = useCallback(() => {
|
|
666
699
|
if (dwellTimer.current) {
|
|
@@ -668,22 +701,14 @@ function AnimatedEventBox<T>({
|
|
|
668
701
|
dwellTimer.current = null;
|
|
669
702
|
}
|
|
670
703
|
}, []);
|
|
671
|
-
// Cancel a pending dwell
|
|
672
|
-
|
|
673
|
-
const releaseEdge = useCallback(() => {
|
|
674
|
-
disarmEdge();
|
|
675
|
-
edgePaging?.lockScroll(false);
|
|
676
|
-
}, [disarmEdge, edgePaging]);
|
|
704
|
+
// Cancel a pending dwell. Runs on every gesture end.
|
|
705
|
+
const releaseEdge = disarmEdge;
|
|
677
706
|
const armEdge = useCallback(
|
|
678
707
|
(dir: number) => {
|
|
679
708
|
disarmEdge();
|
|
680
|
-
|
|
709
|
+
const fire = () => {
|
|
681
710
|
dwellTimer.current = null;
|
|
682
711
|
if (!edgePaging) return;
|
|
683
|
-
// Freeze the pager's own swipe before paging: on native a programmatic
|
|
684
|
-
// scroll is deferred while the touch is tracked, so without this the view
|
|
685
|
-
// wouldn't advance until the finger lifts.
|
|
686
|
-
edgePaging.lockScroll(true);
|
|
687
712
|
// First edge fire: lift the event into the floating ghost. It must NOT
|
|
688
713
|
// commit here — committing relocates the event off this page, which
|
|
689
714
|
// unmounts the dragging box and kills the gesture. Instead the ghost
|
|
@@ -700,7 +725,9 @@ function AnimatedEventBox<T>({
|
|
|
700
725
|
edgePaging.beginLift(latest.current.event as CalendarEvent<unknown>);
|
|
701
726
|
}
|
|
702
727
|
onEdgeAdvance?.(dir);
|
|
703
|
-
|
|
728
|
+
dwellTimer.current = setTimeout(fire, EDGE_REPEAT_MS);
|
|
729
|
+
};
|
|
730
|
+
dwellTimer.current = setTimeout(fire, EDGE_DWELL_MS);
|
|
704
731
|
},
|
|
705
732
|
[
|
|
706
733
|
disarmEdge,
|
|
@@ -875,69 +902,120 @@ function AnimatedEventBox<T>({
|
|
|
875
902
|
releaseEdge,
|
|
876
903
|
]);
|
|
877
904
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
905
|
+
// Stable callbacks that read the event and handlers from the ref, so the
|
|
906
|
+
// resize gestures below keep their identity across renders.
|
|
907
|
+
const handlePress = useCallback(() => {
|
|
908
|
+
const { event, onPress: press } = latest.current;
|
|
909
|
+
press(event);
|
|
910
|
+
}, []);
|
|
911
|
+
// A handle also takes the consumer's long press, unless a long press already
|
|
912
|
+
// grabs the event to move it.
|
|
913
|
+
const canLongPress = !canMove && onLongPress != null;
|
|
914
|
+
const handleLongPressFromHandle = useCallback(() => {
|
|
915
|
+
const { event, onLongPress: press } = latest.current;
|
|
916
|
+
press?.(event);
|
|
917
|
+
}, []);
|
|
918
|
+
|
|
919
|
+
// A plain tap on a resize handle is a press on the event. The two handles cover
|
|
920
|
+
// almost all of a box at the minimum height, so without this a 5- to 30-minute
|
|
921
|
+
// event has next to no tappable surface. A drag from a handle still resizes:
|
|
922
|
+
// the pan wins the race as soon as the finger moves.
|
|
923
|
+
const resizeGesture = useMemo(() => {
|
|
924
|
+
const pan = Gesture.Pan()
|
|
925
|
+
.enabled(resizable)
|
|
926
|
+
.onStart(() => {
|
|
927
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
928
|
+
runOnJS(notifyDragStart)();
|
|
929
|
+
})
|
|
930
|
+
.onUpdate((event) => {
|
|
931
|
+
resizeDelta.value = event.translationY;
|
|
932
|
+
})
|
|
933
|
+
.onEnd((event) => {
|
|
934
|
+
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
935
|
+
if (delta === 0) {
|
|
936
|
+
resizeDelta.value = 0;
|
|
937
|
+
return;
|
|
938
|
+
}
|
|
939
|
+
resizeDelta.value = (delta / MINUTES_PER_HOUR) * cellHeight.value;
|
|
940
|
+
runOnJS(commitDrag)(0, delta);
|
|
941
|
+
})
|
|
942
|
+
.onFinalize(() => {
|
|
943
|
+
dragZ.value = 0;
|
|
944
|
+
});
|
|
945
|
+
const tap = Gesture.Tap()
|
|
946
|
+
.runOnJS(true)
|
|
947
|
+
.onEnd((_event, success) => {
|
|
948
|
+
if (success) handlePress();
|
|
949
|
+
});
|
|
950
|
+
const longPress = Gesture.LongPress()
|
|
951
|
+
.enabled(canLongPress)
|
|
952
|
+
.runOnJS(true)
|
|
953
|
+
.onStart(() => {
|
|
954
|
+
handleLongPressFromHandle();
|
|
955
|
+
});
|
|
956
|
+
return Gesture.Race(pan, tap, longPress);
|
|
957
|
+
}, [
|
|
958
|
+
resizable,
|
|
959
|
+
snapMinutes,
|
|
960
|
+
cellHeight,
|
|
961
|
+
resizeDelta,
|
|
962
|
+
dragZ,
|
|
963
|
+
commitDrag,
|
|
964
|
+
notifyDragStart,
|
|
965
|
+
handlePress,
|
|
966
|
+
canLongPress,
|
|
967
|
+
handleLongPressFromHandle,
|
|
968
|
+
]);
|
|
903
969
|
|
|
904
970
|
// Top-edge resize: dragging the top changes the start (end fixed). Mirrors the
|
|
905
971
|
// bottom resize but commits a start-delta and previews via resizeStartDelta.
|
|
906
|
-
const resizeStartGesture = useMemo(
|
|
907
|
-
()
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
.
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
.
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
.
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
972
|
+
const resizeStartGesture = useMemo(() => {
|
|
973
|
+
const pan = Gesture.Pan()
|
|
974
|
+
.enabled(resizableFromStart)
|
|
975
|
+
.onStart(() => {
|
|
976
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
977
|
+
runOnJS(notifyDragStart)();
|
|
978
|
+
})
|
|
979
|
+
.onUpdate((event) => {
|
|
980
|
+
resizeStartDelta.value = event.translationY;
|
|
981
|
+
})
|
|
982
|
+
.onEnd((event) => {
|
|
983
|
+
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
984
|
+
if (delta === 0) {
|
|
985
|
+
resizeStartDelta.value = 0;
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
resizeStartDelta.value = (delta / MINUTES_PER_HOUR) * cellHeight.value;
|
|
989
|
+
runOnJS(commitDrag)(delta, 0);
|
|
990
|
+
})
|
|
991
|
+
.onFinalize(() => {
|
|
992
|
+
dragZ.value = 0;
|
|
993
|
+
});
|
|
994
|
+
const tap = Gesture.Tap()
|
|
995
|
+
.runOnJS(true)
|
|
996
|
+
.onEnd((_event, success) => {
|
|
997
|
+
if (success) handlePress();
|
|
998
|
+
});
|
|
999
|
+
const longPress = Gesture.LongPress()
|
|
1000
|
+
.enabled(canLongPress)
|
|
1001
|
+
.runOnJS(true)
|
|
1002
|
+
.onStart(() => {
|
|
1003
|
+
handleLongPressFromHandle();
|
|
1004
|
+
});
|
|
1005
|
+
return Gesture.Race(pan, tap, longPress);
|
|
1006
|
+
}, [
|
|
1007
|
+
resizableFromStart,
|
|
1008
|
+
snapMinutes,
|
|
1009
|
+
cellHeight,
|
|
1010
|
+
resizeStartDelta,
|
|
1011
|
+
dragZ,
|
|
1012
|
+
commitDrag,
|
|
1013
|
+
notifyDragStart,
|
|
1014
|
+
handlePress,
|
|
1015
|
+
canLongPress,
|
|
1016
|
+
handleLongPressFromHandle,
|
|
1017
|
+
]);
|
|
939
1018
|
|
|
940
|
-
const handlePress = () => onPress(positioned.event);
|
|
941
1019
|
// When movable, a long press grabs the event to move it, so don't also fire
|
|
942
1020
|
// the consumer's long-press handler.
|
|
943
1021
|
const handleLongPress = !canMove && onLongPress ? () => onLongPress(positioned.event) : undefined;
|
|
@@ -945,31 +1023,23 @@ function AnimatedEventBox<T>({
|
|
|
945
1023
|
// Dragging is gesture-only, so expose the same move/resize commit path as
|
|
946
1024
|
// discrete screen-reader actions (VoiceOver/TalkBack invoke them from the
|
|
947
1025
|
// actions menu). Steps are one `snapMinutes` unit, matching a drag snap.
|
|
948
|
-
const unit = (n: number) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
949
|
-
// Label the whole-page move by what a page means in this mode.
|
|
950
|
-
const pageUnit =
|
|
951
|
-
mode === "week"
|
|
952
|
-
? "week"
|
|
953
|
-
: daysPerPage === 1
|
|
954
|
-
? "day"
|
|
955
|
-
: `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
|
|
956
1026
|
const dragActions = [
|
|
957
1027
|
...(canMove
|
|
958
1028
|
? [
|
|
959
|
-
{ name: "move-later", label:
|
|
960
|
-
{ name: "move-earlier", label:
|
|
1029
|
+
{ name: "move-later", label: labels.moveLater(snapMinutes) },
|
|
1030
|
+
{ name: "move-earlier", label: labels.moveEarlier(snapMinutes) },
|
|
961
1031
|
]
|
|
962
1032
|
: []),
|
|
963
1033
|
...(resizable
|
|
964
1034
|
? [
|
|
965
|
-
{ name: "extend", label:
|
|
966
|
-
{ name: "shrink", label:
|
|
1035
|
+
{ name: "extend", label: labels.extend(snapMinutes) },
|
|
1036
|
+
{ name: "shrink", label: labels.shorten(snapMinutes) },
|
|
967
1037
|
]
|
|
968
1038
|
: []),
|
|
969
1039
|
...(canMove
|
|
970
1040
|
? [
|
|
971
|
-
{ name: "move-next-page", label:
|
|
972
|
-
{ name: "move-previous-page", label:
|
|
1041
|
+
{ name: "move-next-page", label: labels.moveToNextPage(daysPerPage, mode) },
|
|
1042
|
+
{ name: "move-previous-page", label: labels.moveToPreviousPage(daysPerPage, mode) },
|
|
973
1043
|
]
|
|
974
1044
|
: []),
|
|
975
1045
|
];
|
|
@@ -1004,10 +1074,7 @@ function AnimatedEventBox<T>({
|
|
|
1004
1074
|
themed: theme.containers.timeGridEvent,
|
|
1005
1075
|
});
|
|
1006
1076
|
const box = (
|
|
1007
|
-
<Animated.View
|
|
1008
|
-
{...eventSlot}
|
|
1009
|
-
style={[eventSlot.style, boxStyle, hiddenForMove ? { opacity: 0 } : null]}
|
|
1010
|
-
>
|
|
1077
|
+
<Animated.View {...eventSlot} style={[eventSlot.style, boxStyle]}>
|
|
1011
1078
|
<RenderEventComponent
|
|
1012
1079
|
event={positioned.event}
|
|
1013
1080
|
mode={mode}
|
|
@@ -1021,7 +1088,7 @@ function AnimatedEventBox<T>({
|
|
|
1021
1088
|
/>
|
|
1022
1089
|
{resizableFromStart ? (
|
|
1023
1090
|
<GestureDetector gesture={resizeStartGesture}>
|
|
1024
|
-
<Animated.View style={styles.resizeHandleTop}>
|
|
1091
|
+
<Animated.View testID="resize-handle-top" style={styles.resizeHandleTop}>
|
|
1025
1092
|
{showDragHandle ? (
|
|
1026
1093
|
<View style={[styles.resizeGrip, { backgroundColor: theme.colors.eventText }]} />
|
|
1027
1094
|
) : null}
|
|
@@ -1030,7 +1097,7 @@ function AnimatedEventBox<T>({
|
|
|
1030
1097
|
) : null}
|
|
1031
1098
|
{resizable ? (
|
|
1032
1099
|
<GestureDetector gesture={resizeGesture}>
|
|
1033
|
-
<Animated.View style={styles.resizeHandle}>
|
|
1100
|
+
<Animated.View testID="resize-handle" style={styles.resizeHandle}>
|
|
1034
1101
|
{/* The grip is the only visible drag affordance; hiding it keeps the
|
|
1035
1102
|
resize gesture working but removes the indicator. */}
|
|
1036
1103
|
{showDragHandle ? (
|
|
@@ -1070,92 +1137,208 @@ function AnimatedEventBox<T>({
|
|
|
1070
1137
|
);
|
|
1071
1138
|
}
|
|
1072
1139
|
|
|
1140
|
+
// A page re-renders on every drag preview and page change; the boxes only need
|
|
1141
|
+
// to when their own event, geometry, or zoom source changes.
|
|
1142
|
+
const AnimatedEventBox = memo(AnimatedEventBoxInner) as typeof AnimatedEventBoxInner;
|
|
1143
|
+
|
|
1073
1144
|
/** Replace the hour-axis label. Receives the hour (0–23) and the `ampm` flag. */
|
|
1074
1145
|
export type HourRenderer = (hour: number, ampm: boolean) => React.ReactNode;
|
|
1075
1146
|
|
|
1076
|
-
|
|
1147
|
+
// The hours (rows/labels) visible in the window [minHour, maxHour).
|
|
1148
|
+
const hourRange = (minHour: number, maxHour: number) =>
|
|
1149
|
+
Array.from({ length: maxHour - minHour }, (_, index) => minHour + index);
|
|
1150
|
+
|
|
1151
|
+
type HourLabelProps = {
|
|
1077
1152
|
hour: number;
|
|
1078
|
-
|
|
1079
|
-
cellHeight: SharedValue<number>;
|
|
1080
|
-
hourColumnWidth: number;
|
|
1153
|
+
width: number;
|
|
1081
1154
|
label: string;
|
|
1082
1155
|
ampm: boolean;
|
|
1083
1156
|
hourComponent?: HourRenderer;
|
|
1084
1157
|
};
|
|
1085
1158
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
minHour,
|
|
1089
|
-
cellHeight,
|
|
1090
|
-
hourColumnWidth,
|
|
1091
|
-
label,
|
|
1092
|
-
ampm,
|
|
1093
|
-
hourComponent,
|
|
1094
|
-
}: HourRowProps) => {
|
|
1159
|
+
// The hour-axis label: the consumer's `hourComponent`, or the themed text.
|
|
1160
|
+
const HourLabel = ({ hour, width, label, ampm, hourComponent }: HourLabelProps) => {
|
|
1095
1161
|
const theme = useCalendarTheme();
|
|
1096
1162
|
const slot = useSlots<TimeGridSlot>();
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1163
|
+
return hourComponent ? (
|
|
1164
|
+
<View style={{ width }}>{hourComponent(hour, ampm)}</View>
|
|
1165
|
+
) : (
|
|
1166
|
+
<Text
|
|
1167
|
+
{...slot<TextStyle>("hourLabel", {
|
|
1168
|
+
base: [styles.hourLabel, { width }],
|
|
1169
|
+
themed: [theme.text.hourLabel, { color: theme.colors.textMuted }],
|
|
1170
|
+
})}
|
|
1171
|
+
allowFontScaling={false}
|
|
1172
|
+
>
|
|
1173
|
+
{label}
|
|
1174
|
+
</Text>
|
|
1103
1175
|
);
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
type HourLinesProps = {
|
|
1179
|
+
hours: number[];
|
|
1180
|
+
timeslots: number;
|
|
1181
|
+
};
|
|
1104
1182
|
|
|
1183
|
+
// The grid lines of one page: a column of equal hour cells filling the hour
|
|
1184
|
+
// window, each holding its line at the top and its sub-hour dividers inside.
|
|
1185
|
+
// Layout spreads the cells as the window's height animates, so no line needs a
|
|
1186
|
+
// worklet of its own.
|
|
1187
|
+
const HourLines = memo(function HourLines({ hours, timeslots }: HourLinesProps) {
|
|
1188
|
+
const theme = useCalendarTheme();
|
|
1189
|
+
const slot = useSlots<TimeGridSlot>();
|
|
1190
|
+
const hourLineSlot = slot("gridLines", {
|
|
1191
|
+
base: [styles.hourLine, styles.nonInteractive],
|
|
1192
|
+
themed: { backgroundColor: theme.colors.gridLine },
|
|
1193
|
+
});
|
|
1194
|
+
const timeslotLineSlot = slot("gridLines", {
|
|
1195
|
+
base: [styles.timeslotLine, styles.nonInteractive],
|
|
1196
|
+
themed: { backgroundColor: theme.colors.gridLine },
|
|
1197
|
+
});
|
|
1105
1198
|
return (
|
|
1106
|
-
<
|
|
1107
|
-
{
|
|
1108
|
-
<View
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
{label}
|
|
1118
|
-
</Text>
|
|
1119
|
-
)}
|
|
1120
|
-
<View
|
|
1121
|
-
{...slot("gridLines", {
|
|
1122
|
-
base: styles.hourLine,
|
|
1123
|
-
themed: { backgroundColor: theme.colors.gridLine },
|
|
1124
|
-
})}
|
|
1125
|
-
/>
|
|
1126
|
-
</Animated.View>
|
|
1199
|
+
<View style={[styles.fill, styles.nonInteractive]}>
|
|
1200
|
+
{hours.map((hour) => (
|
|
1201
|
+
<View key={hour} style={styles.hourCell}>
|
|
1202
|
+
{Array.from({ length: Math.max(1, timeslots) }, (_, slotIndex) => (
|
|
1203
|
+
<View key={slotIndex} style={styles.hourCell}>
|
|
1204
|
+
<View {...(slotIndex === 0 ? hourLineSlot : timeslotLineSlot)} />
|
|
1205
|
+
</View>
|
|
1206
|
+
))}
|
|
1207
|
+
</View>
|
|
1208
|
+
))}
|
|
1209
|
+
</View>
|
|
1127
1210
|
);
|
|
1128
|
-
};
|
|
1211
|
+
});
|
|
1129
1212
|
|
|
1130
|
-
type
|
|
1131
|
-
|
|
1213
|
+
type HourGutterProps = {
|
|
1214
|
+
width: number;
|
|
1132
1215
|
minHour: number;
|
|
1133
|
-
|
|
1216
|
+
maxHour: number;
|
|
1134
1217
|
cellHeight: SharedValue<number>;
|
|
1135
|
-
|
|
1218
|
+
/** Height of the all-day band shared with the pages (live, follows the swipe). */
|
|
1219
|
+
laneHeight: SharedValue<number>;
|
|
1220
|
+
/** The grid's vertical offset, so the "all-day" cell can hold still at the top. */
|
|
1221
|
+
scrollY: SharedValue<number>;
|
|
1222
|
+
showLane: boolean;
|
|
1223
|
+
/** Draw the "all-day" text in the lane cell. Default off, so an empty lane reads
|
|
1224
|
+
* as neutral space rather than a labelled-but-empty row. */
|
|
1225
|
+
showAllDayLabel: boolean;
|
|
1226
|
+
/** The text drawn when `showAllDayLabel` is on. */
|
|
1227
|
+
allDayLabel: string;
|
|
1228
|
+
/** Height of the day-header corner above the "all-day" cell (0 when the header
|
|
1229
|
+
* isn't paged, i.e. a custom `renderHeader` draws its own fixed header). */
|
|
1230
|
+
headerHeight: number;
|
|
1231
|
+
/** ISO week label for the corner, or null to leave it empty. */
|
|
1232
|
+
weekNumber: string | null;
|
|
1233
|
+
ampm: boolean;
|
|
1234
|
+
hourComponent?: HourRenderer;
|
|
1136
1235
|
};
|
|
1137
1236
|
|
|
1138
|
-
//
|
|
1139
|
-
|
|
1140
|
-
|
|
1237
|
+
// The hour-axis column beside the pager. It is part of the grid's one vertical
|
|
1238
|
+
// scroll content, so it scrolls and zooms with the pages and holds still while
|
|
1239
|
+
// they swipe. Its "all-day" cell rides the scroll offset to stay pinned at the
|
|
1240
|
+
// top beside the pages' all-day bands, and its label rows are spread by layout
|
|
1241
|
+
// over the hour window, like the pages' lines.
|
|
1242
|
+
const HourGutterInner = ({
|
|
1243
|
+
width,
|
|
1141
1244
|
minHour,
|
|
1142
|
-
|
|
1245
|
+
maxHour,
|
|
1143
1246
|
cellHeight,
|
|
1144
|
-
|
|
1145
|
-
|
|
1247
|
+
laneHeight,
|
|
1248
|
+
scrollY,
|
|
1249
|
+
showLane,
|
|
1250
|
+
showAllDayLabel,
|
|
1251
|
+
allDayLabel,
|
|
1252
|
+
headerHeight,
|
|
1253
|
+
weekNumber,
|
|
1254
|
+
ampm,
|
|
1255
|
+
hourComponent,
|
|
1256
|
+
}: HourGutterProps) => {
|
|
1146
1257
|
const theme = useCalendarTheme();
|
|
1147
1258
|
const slot = useSlots<TimeGridSlot>();
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
|
|
1259
|
+
const hours = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1260
|
+
// Height and offset are separate styles: a style that returns a transform is
|
|
1261
|
+
// re-applied every time it runs, so keeping the offset apart means a swipe
|
|
1262
|
+
// (which only moves the band's height) sends nothing to the view.
|
|
1263
|
+
const laneCellHeightStyle = useAnimatedStyle(() => ({ height: laneHeight.value }));
|
|
1264
|
+
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
|
|
1265
|
+
const rowsStyle = useAnimatedStyle(
|
|
1266
|
+
() => ({
|
|
1267
|
+
top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
|
|
1268
|
+
height: (maxHour - minHour) * cellHeight.value,
|
|
1269
|
+
}),
|
|
1270
|
+
[minHour, maxHour, headerHeight],
|
|
1271
|
+
);
|
|
1272
|
+
return (
|
|
1273
|
+
<View testID="hour-gutter" {...slot("hourGutter", { base: [styles.hourGutter, { width }] })}>
|
|
1274
|
+
{headerHeight > 0 ? (
|
|
1275
|
+
<Animated.View
|
|
1276
|
+
style={[
|
|
1277
|
+
styles.gutterCorner,
|
|
1278
|
+
{
|
|
1279
|
+
height: headerHeight,
|
|
1280
|
+
backgroundColor: theme.colors.surface,
|
|
1281
|
+
borderBottomColor: theme.colors.gridLine,
|
|
1282
|
+
},
|
|
1283
|
+
pinStyle,
|
|
1284
|
+
]}
|
|
1285
|
+
>
|
|
1286
|
+
{weekNumber ? (
|
|
1287
|
+
<Text
|
|
1288
|
+
{...slot<TextStyle>("weekNumber", {
|
|
1289
|
+
themed: [theme.text.hourLabel, { color: theme.colors.textMuted }],
|
|
1290
|
+
})}
|
|
1291
|
+
allowFontScaling={false}
|
|
1292
|
+
>
|
|
1293
|
+
{weekNumber}
|
|
1294
|
+
</Text>
|
|
1295
|
+
) : null}
|
|
1296
|
+
</Animated.View>
|
|
1297
|
+
) : null}
|
|
1298
|
+
{showLane ? (
|
|
1299
|
+
<Animated.View
|
|
1300
|
+
style={[
|
|
1301
|
+
styles.laneCell,
|
|
1302
|
+
{ top: headerHeight },
|
|
1303
|
+
{ backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.gridLine },
|
|
1304
|
+
laneCellHeightStyle,
|
|
1305
|
+
pinStyle,
|
|
1306
|
+
]}
|
|
1307
|
+
>
|
|
1308
|
+
{showAllDayLabel ? (
|
|
1309
|
+
<Text
|
|
1310
|
+
{...slot<TextStyle>("allDayLabel", {
|
|
1311
|
+
base: styles.allDayLabel,
|
|
1312
|
+
themed: { color: theme.colors.textMuted },
|
|
1313
|
+
})}
|
|
1314
|
+
allowFontScaling={false}
|
|
1315
|
+
>
|
|
1316
|
+
{allDayLabel}
|
|
1317
|
+
</Text>
|
|
1318
|
+
) : null}
|
|
1319
|
+
</Animated.View>
|
|
1320
|
+
) : null}
|
|
1321
|
+
<Animated.View style={[styles.gutterRows, rowsStyle]}>
|
|
1322
|
+
{hours.map((hour) => (
|
|
1323
|
+
<View key={hour} style={styles.hourCell}>
|
|
1324
|
+
<View style={[styles.hourRow, styles.nonInteractive]}>
|
|
1325
|
+
<HourLabel
|
|
1326
|
+
hour={hour}
|
|
1327
|
+
width={width}
|
|
1328
|
+
label={formatHour(hour, { ampm })}
|
|
1329
|
+
ampm={ampm}
|
|
1330
|
+
hourComponent={hourComponent}
|
|
1331
|
+
/>
|
|
1332
|
+
</View>
|
|
1333
|
+
</View>
|
|
1334
|
+
))}
|
|
1335
|
+
</Animated.View>
|
|
1336
|
+
</View>
|
|
1151
1337
|
);
|
|
1152
|
-
const lineSlot = slot("gridLines", {
|
|
1153
|
-
base: [styles.timeslotLine, styles.nonInteractive, { left: hourColumnWidth }],
|
|
1154
|
-
themed: { backgroundColor: theme.colors.gridLine },
|
|
1155
|
-
});
|
|
1156
|
-
return <Animated.View {...lineSlot} style={[lineSlot.style, animatedStyle]} />;
|
|
1157
1338
|
};
|
|
1158
1339
|
|
|
1340
|
+
const HourGutter = memo(HourGutterInner);
|
|
1341
|
+
|
|
1159
1342
|
type NowIndicatorProps = {
|
|
1160
1343
|
cellHeight: SharedValue<number>;
|
|
1161
1344
|
nowHours: number;
|
|
@@ -1192,6 +1375,8 @@ type ShadeBandProps = {
|
|
|
1192
1375
|
/** Which slot/testID the band belongs to (closed hours vs background events). */
|
|
1193
1376
|
slotName?: "businessHours" | "backgroundEvent";
|
|
1194
1377
|
testID?: string;
|
|
1378
|
+
/** Let touches reach the band's content; the band itself stays transparent to them. */
|
|
1379
|
+
interactive?: boolean;
|
|
1195
1380
|
children?: React.ReactNode;
|
|
1196
1381
|
};
|
|
1197
1382
|
|
|
@@ -1207,6 +1392,7 @@ const ShadeBand = ({
|
|
|
1207
1392
|
color,
|
|
1208
1393
|
slotName = "businessHours",
|
|
1209
1394
|
testID = "business-hours-shade",
|
|
1395
|
+
interactive = false,
|
|
1210
1396
|
children,
|
|
1211
1397
|
}: ShadeBandProps) => {
|
|
1212
1398
|
const slot = useSlots<TimeGridSlot>();
|
|
@@ -1218,15 +1404,20 @@ const ShadeBand = ({
|
|
|
1218
1404
|
[startHour, endHour, minHour],
|
|
1219
1405
|
);
|
|
1220
1406
|
const bandSlot = slot(slotName, {
|
|
1221
|
-
base: [
|
|
1407
|
+
base: [
|
|
1408
|
+
styles.shadeBand,
|
|
1409
|
+
interactive ? styles.passThrough : styles.nonInteractive,
|
|
1410
|
+
{ left, width },
|
|
1411
|
+
],
|
|
1222
1412
|
themed: color === undefined ? undefined : { backgroundColor: color },
|
|
1223
1413
|
});
|
|
1224
1414
|
return (
|
|
1225
1415
|
<Animated.View
|
|
1226
1416
|
testID={testID}
|
|
1227
|
-
// Decorative, like the dom bands' aria-hidden: never
|
|
1228
|
-
|
|
1229
|
-
|
|
1417
|
+
// Decorative unless interactive, like the dom bands' aria-hidden: never
|
|
1418
|
+
// announced or focused. An interactive band exposes its content instead.
|
|
1419
|
+
accessibilityElementsHidden={!interactive}
|
|
1420
|
+
importantForAccessibility={interactive ? "auto" : "no-hide-descendants"}
|
|
1230
1421
|
{...bandSlot}
|
|
1231
1422
|
style={[bandSlot.style, animatedStyle]}
|
|
1232
1423
|
>
|
|
@@ -1235,6 +1426,73 @@ const ShadeBand = ({
|
|
|
1235
1426
|
);
|
|
1236
1427
|
};
|
|
1237
1428
|
|
|
1429
|
+
type BackgroundEventBandProps<T> = {
|
|
1430
|
+
event: CalendarEvent<T>;
|
|
1431
|
+
cellHeight: SharedValue<number>;
|
|
1432
|
+
startHour: number;
|
|
1433
|
+
endHour: number;
|
|
1434
|
+
minHour: number;
|
|
1435
|
+
left: number;
|
|
1436
|
+
width: number;
|
|
1437
|
+
mode: TimeGridMode;
|
|
1438
|
+
continuesBefore: boolean;
|
|
1439
|
+
continuesAfter: boolean;
|
|
1440
|
+
render: RenderEvent<T>;
|
|
1441
|
+
onPress: (event: CalendarEvent<T>) => void;
|
|
1442
|
+
onLongPress?: (event: CalendarEvent<T>) => void;
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
// A background event's band drawn by the consumer's component instead of the
|
|
1446
|
+
// themed shade. The band lets touches reach that content, and the component is
|
|
1447
|
+
// rendered as an element (like `renderEvent`, so it may use hooks) with the
|
|
1448
|
+
// event, the mode, a live boxHeight, the multi-day continuation flags and the
|
|
1449
|
+
// press handlers.
|
|
1450
|
+
function BackgroundEventBand<T>({
|
|
1451
|
+
event,
|
|
1452
|
+
cellHeight,
|
|
1453
|
+
startHour,
|
|
1454
|
+
endHour,
|
|
1455
|
+
minHour,
|
|
1456
|
+
left,
|
|
1457
|
+
width,
|
|
1458
|
+
mode,
|
|
1459
|
+
continuesBefore,
|
|
1460
|
+
continuesAfter,
|
|
1461
|
+
render: Render,
|
|
1462
|
+
onPress,
|
|
1463
|
+
onLongPress,
|
|
1464
|
+
}: BackgroundEventBandProps<T>) {
|
|
1465
|
+
const boxHeight = useDerivedValue(
|
|
1466
|
+
() => (endHour - startHour) * cellHeight.value,
|
|
1467
|
+
[startHour, endHour, cellHeight],
|
|
1468
|
+
);
|
|
1469
|
+
const handlePress = useCallback(() => onPress(event), [onPress, event]);
|
|
1470
|
+
const handleLongPress = useCallback(() => onLongPress?.(event), [onLongPress, event]);
|
|
1471
|
+
return (
|
|
1472
|
+
<ShadeBand
|
|
1473
|
+
cellHeight={cellHeight}
|
|
1474
|
+
startHour={startHour}
|
|
1475
|
+
endHour={endHour}
|
|
1476
|
+
minHour={minHour}
|
|
1477
|
+
left={left}
|
|
1478
|
+
width={width}
|
|
1479
|
+
slotName="backgroundEvent"
|
|
1480
|
+
testID="background-event-shade"
|
|
1481
|
+
interactive
|
|
1482
|
+
>
|
|
1483
|
+
<Render
|
|
1484
|
+
event={event}
|
|
1485
|
+
mode={mode}
|
|
1486
|
+
boxHeight={boxHeight}
|
|
1487
|
+
continuesBefore={continuesBefore}
|
|
1488
|
+
continuesAfter={continuesAfter}
|
|
1489
|
+
onPress={handlePress}
|
|
1490
|
+
onLongPress={onLongPress ? handleLongPress : undefined}
|
|
1491
|
+
/>
|
|
1492
|
+
</ShadeBand>
|
|
1493
|
+
);
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1238
1496
|
type TimetablePageProps<T> = {
|
|
1239
1497
|
mode: TimeGridMode;
|
|
1240
1498
|
numberOfDays: number;
|
|
@@ -1244,38 +1502,25 @@ type TimetablePageProps<T> = {
|
|
|
1244
1502
|
date: Date;
|
|
1245
1503
|
events: CalendarEvent<T>[];
|
|
1246
1504
|
cellHeight: SharedValue<number>;
|
|
1247
|
-
hourHeight: number;
|
|
1248
1505
|
// The zoom committed at the end of the last pinch. Off-screen pages animate off
|
|
1249
1506
|
// this (it changes once per gesture) instead of the live cellHeight (which
|
|
1250
1507
|
// changes every frame), so a pinch only re-runs the visible page's worklets.
|
|
1251
1508
|
committedCellHeight: SharedValue<number>;
|
|
1252
|
-
scrollY: SharedValue<number>;
|
|
1253
1509
|
isActive: boolean;
|
|
1254
|
-
/** Initial vertical scroll position (px): the live shared offset, so a page that
|
|
1255
|
-
* mounts after a scroll appears there rather than snapping from the default. */
|
|
1256
|
-
initialScrollY: number;
|
|
1257
|
-
/** Record the rested vertical offset (px) so later-mounted pages seed from it. */
|
|
1258
|
-
onSettleOffset: (y: number) => void;
|
|
1259
1510
|
weekStartsOn: WeekStartsOn;
|
|
1260
1511
|
weekEndsOn?: WeekStartsOn;
|
|
1261
|
-
/**
|
|
1512
|
+
/** Width of the day columns: the pager's width (the hour column sits beside it). */
|
|
1262
1513
|
width: number;
|
|
1263
|
-
hourColumnWidth: number;
|
|
1264
1514
|
minHour: number;
|
|
1265
1515
|
maxHour: number;
|
|
1266
|
-
ampm: boolean;
|
|
1267
1516
|
timeslots: number;
|
|
1268
1517
|
isRTL: boolean;
|
|
1269
|
-
showAllDayEventCell: boolean;
|
|
1270
1518
|
highlightWeekends: boolean;
|
|
1271
|
-
showVerticalScrollIndicator: boolean;
|
|
1272
|
-
verticalScrollEnabled: boolean;
|
|
1273
|
-
hourComponent?: HourRenderer;
|
|
1274
1519
|
calendarCellStyle?: (date: Date) => StyleProp<ViewStyle>;
|
|
1275
1520
|
businessHours?: BusinessHours;
|
|
1276
1521
|
renderBusinessHours?: (band: BusinessHoursBand) => React.ReactNode;
|
|
1277
|
-
|
|
1278
|
-
|
|
1522
|
+
/** A component that draws a background event's band; see `Calendar`. */
|
|
1523
|
+
renderBackgroundEvent?: RenderEvent<T>;
|
|
1279
1524
|
showNowIndicator: boolean;
|
|
1280
1525
|
renderEvent: RenderEvent<T>;
|
|
1281
1526
|
keyExtractor: EventKeyExtractor<T>;
|
|
@@ -1293,14 +1538,34 @@ type TimetablePageProps<T> = {
|
|
|
1293
1538
|
onLongPressCell?: (date: Date) => void;
|
|
1294
1539
|
onCreateEvent?: (start: Date, end: Date) => void;
|
|
1295
1540
|
onEdgeAdvance?: (dir: number) => void;
|
|
1296
|
-
/**
|
|
1297
|
-
|
|
1298
|
-
|
|
1541
|
+
/** This page's index in the pager: the key its all-day lane height is reported under. */
|
|
1542
|
+
pageIndex: number;
|
|
1543
|
+
/** Height of the all-day band shared by every page (live, follows the swipe). */
|
|
1544
|
+
laneHeight: SharedValue<number>;
|
|
1545
|
+
/** The grid's vertical offset, so the band can hold still at the top while the hours scroll. */
|
|
1546
|
+
scrollY: SharedValue<number>;
|
|
1547
|
+
showAllDayEventCell: boolean;
|
|
1548
|
+
onLaneLayout: (index: number, height: number) => void;
|
|
1549
|
+
/**
|
|
1550
|
+
* Fixed height of the page (and the pager): tall enough for the fully zoomed
|
|
1551
|
+
* hour window and the tallest lane seen, so neither the pager nor its item
|
|
1552
|
+
* containers re-lay out while the band or the zoom animate inside.
|
|
1553
|
+
*/
|
|
1554
|
+
height: number;
|
|
1555
|
+
/** Draw this page's day-header row (pages with the columns). False when a custom
|
|
1556
|
+
* `renderHeader` owns a fixed header above the pager. */
|
|
1557
|
+
pagedHeader: boolean;
|
|
1558
|
+
weekdayFormat?: WeekdayFormat;
|
|
1559
|
+
todayLabel: string;
|
|
1560
|
+
locale?: Locale;
|
|
1561
|
+
activeDate?: Date;
|
|
1562
|
+
onPressDateHeader?: (date: Date) => void;
|
|
1299
1563
|
};
|
|
1300
1564
|
|
|
1301
|
-
//
|
|
1302
|
-
//
|
|
1303
|
-
//
|
|
1565
|
+
// One page of day columns: the tall, non-scrolling content for a single date
|
|
1566
|
+
// range. Pages sit side by side in the horizontal pager, which itself lives in
|
|
1567
|
+
// the grid's one vertical scroll view, so every page and the hour column share
|
|
1568
|
+
// that scroll position and zoom.
|
|
1304
1569
|
function TimetablePageInner<T>({
|
|
1305
1570
|
mode,
|
|
1306
1571
|
numberOfDays,
|
|
@@ -1310,32 +1575,21 @@ function TimetablePageInner<T>({
|
|
|
1310
1575
|
date,
|
|
1311
1576
|
events,
|
|
1312
1577
|
cellHeight,
|
|
1313
|
-
hourHeight,
|
|
1314
1578
|
committedCellHeight,
|
|
1315
|
-
scrollY,
|
|
1316
1579
|
isActive,
|
|
1317
|
-
initialScrollY,
|
|
1318
|
-
onSettleOffset,
|
|
1319
1580
|
weekStartsOn,
|
|
1320
1581
|
weekEndsOn,
|
|
1321
1582
|
width,
|
|
1322
|
-
hourColumnWidth,
|
|
1323
1583
|
minHour,
|
|
1324
1584
|
maxHour,
|
|
1325
|
-
ampm,
|
|
1326
1585
|
timeslots,
|
|
1327
1586
|
isRTL,
|
|
1328
|
-
showAllDayEventCell,
|
|
1329
1587
|
highlightWeekends,
|
|
1330
|
-
showVerticalScrollIndicator,
|
|
1331
|
-
verticalScrollEnabled,
|
|
1332
|
-
hourComponent,
|
|
1333
1588
|
calendarCellStyle,
|
|
1334
|
-
minHourHeight,
|
|
1335
|
-
maxHourHeight,
|
|
1336
1589
|
showNowIndicator,
|
|
1337
1590
|
businessHours,
|
|
1338
1591
|
renderBusinessHours,
|
|
1592
|
+
renderBackgroundEvent,
|
|
1339
1593
|
renderEvent,
|
|
1340
1594
|
keyExtractor,
|
|
1341
1595
|
snapMinutes,
|
|
@@ -1352,102 +1606,26 @@ function TimetablePageInner<T>({
|
|
|
1352
1606
|
onLongPressCell,
|
|
1353
1607
|
onCreateEvent,
|
|
1354
1608
|
onEdgeAdvance,
|
|
1355
|
-
|
|
1609
|
+
pageIndex,
|
|
1610
|
+
laneHeight,
|
|
1611
|
+
scrollY,
|
|
1612
|
+
showAllDayEventCell,
|
|
1613
|
+
onLaneLayout,
|
|
1614
|
+
height,
|
|
1615
|
+
pagedHeader,
|
|
1616
|
+
weekdayFormat,
|
|
1617
|
+
todayLabel,
|
|
1618
|
+
locale,
|
|
1619
|
+
activeDate,
|
|
1620
|
+
onPressDateHeader,
|
|
1356
1621
|
}: TimetablePageProps<T>) {
|
|
1357
1622
|
const theme = useCalendarTheme();
|
|
1358
1623
|
const slot = useSlots<TimeGridSlot>();
|
|
1359
|
-
const scrollRef = useAnimatedRef<Animated.ScrollView>();
|
|
1360
|
-
// The hour grid sits below the all-day lane; capture its top on layout and
|
|
1361
|
-
// report it up while this page is active (the lane height differs per week).
|
|
1362
|
-
const gridTopRef = useRef(0);
|
|
1363
|
-
useEffect(() => {
|
|
1364
|
-
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1365
|
-
}, [isActive, onGridTop]);
|
|
1366
1624
|
|
|
1367
1625
|
// The visible page tracks the live cellHeight (animates every pinch frame);
|
|
1368
1626
|
// off-screen pages track committedCellHeight (settles once per gesture).
|
|
1369
1627
|
const heightSource = isActive ? cellHeight : committedCellHeight;
|
|
1370
1628
|
|
|
1371
|
-
// Keep every page locked to the same vertical scroll position so the prev/next
|
|
1372
|
-
// pages are already aligned before they drag into view — no post-swipe jump.
|
|
1373
|
-
// Only a genuine user drag (and its momentum) updates the shared offset. The
|
|
1374
|
-
// contentOffset seed and the programmatic scrolls that fire during paging also
|
|
1375
|
-
// emit onScroll events; letting those write `scrollY` could broadcast a transient
|
|
1376
|
-
// 0 to every page (the random "snaps to midnight" behaviour), so they're ignored.
|
|
1377
|
-
const isDragging = useSharedValue(false);
|
|
1378
|
-
// Mirror `isActive` to a shared value so the scroll worklet reads the *current*
|
|
1379
|
-
// active state. A plain `isActive` captured in the worklet goes stale, so only the
|
|
1380
|
-
// page active when the handler was first created would record its scrolls — which
|
|
1381
|
-
// is why a position set on a later page was lost and an earlier one came back.
|
|
1382
|
-
const isActiveShared = useSharedValue(isActive);
|
|
1383
|
-
useEffect(() => {
|
|
1384
|
-
isActiveShared.value = isActive;
|
|
1385
|
-
}, [isActive, isActiveShared]);
|
|
1386
|
-
const scrollHandler = useAnimatedScrollHandler({
|
|
1387
|
-
onScroll: (event) => {
|
|
1388
|
-
// Native captures the active page's scroll on a real drag. (Web is handled by
|
|
1389
|
-
// the container-level scroll listener in TimeGridInner, because LegendList
|
|
1390
|
-
// recycles the page containers there and per-page `isActive` can't reliably
|
|
1391
|
-
// tell which DOM node the user is actually scrolling.)
|
|
1392
|
-
if (isActiveShared.value && isDragging.value) {
|
|
1393
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
1394
|
-
scrollY.value = event.contentOffset.y;
|
|
1395
|
-
}
|
|
1396
|
-
},
|
|
1397
|
-
onBeginDrag: () => {
|
|
1398
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
1399
|
-
isDragging.value = true;
|
|
1400
|
-
},
|
|
1401
|
-
onEndDrag: (event) => {
|
|
1402
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
1403
|
-
isDragging.value = false;
|
|
1404
|
-
// Capture the rested position. The mid-drag onScroll above stops at the
|
|
1405
|
-
// finger-lift point; without this, the momentum tail after it is lost and the
|
|
1406
|
-
// saved offset falls short of where the page actually settles.
|
|
1407
|
-
if (!isWeb && isActiveShared.value) {
|
|
1408
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
1409
|
-
scrollY.value = event.contentOffset.y;
|
|
1410
|
-
runOnJS(onSettleOffset)(event.contentOffset.y);
|
|
1411
|
-
}
|
|
1412
|
-
},
|
|
1413
|
-
onMomentumEnd: (event) => {
|
|
1414
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
1415
|
-
isDragging.value = false;
|
|
1416
|
-
if (!isWeb && isActiveShared.value) {
|
|
1417
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
1418
|
-
scrollY.value = event.contentOffset.y;
|
|
1419
|
-
runOnJS(onSettleOffset)(event.contentOffset.y);
|
|
1420
|
-
}
|
|
1421
|
-
},
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
// Keep *inactive* pages aligned to the shared offset as it changes, so they're
|
|
1425
|
-
// already in position before they drag into view. Reads `isActiveShared` (not the
|
|
1426
|
-
// captured `isActive`) so the worklet sees the current state.
|
|
1427
|
-
useAnimatedReaction(
|
|
1428
|
-
() => scrollY.value,
|
|
1429
|
-
(current, previous) => {
|
|
1430
|
-
if (!isActiveShared.value && current !== previous) {
|
|
1431
|
-
scrollTo(scrollRef, 0, current, false);
|
|
1432
|
-
}
|
|
1433
|
-
},
|
|
1434
|
-
);
|
|
1435
|
-
|
|
1436
|
-
// When a page becomes the active one (paged or jumped to), align it to the shared
|
|
1437
|
-
// offset. The reaction above only syncs *inactive* pages, and only when `scrollY`
|
|
1438
|
-
// changes, so a page that paged in after the last change (the third page on from a
|
|
1439
|
-
// drag, say) would keep its seeded default. Uses reanimated's `scrollTo` worklet:
|
|
1440
|
-
// the imperative `scrollRef.current.scrollTo()` does not take effect on a
|
|
1441
|
-
// useAnimatedRef, which is why that page stayed at the default. Native only; web is
|
|
1442
|
-
// handled by the container-level effect in TimeGridInner.
|
|
1443
|
-
useAnimatedReaction(
|
|
1444
|
-
() => isActiveShared.value,
|
|
1445
|
-
(active, previous) => {
|
|
1446
|
-
if (isWeb || !active || active === previous) return;
|
|
1447
|
-
scrollTo(scrollRef, 0, scrollY.value, false);
|
|
1448
|
-
},
|
|
1449
|
-
);
|
|
1450
|
-
|
|
1451
1629
|
const days = useMemo(
|
|
1452
1630
|
() => getViewDays(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays),
|
|
1453
1631
|
[mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays],
|
|
@@ -1460,8 +1638,8 @@ function TimetablePageInner<T>({
|
|
|
1460
1638
|
// gesture worklet would capture the whole `days` array (of `Date`s), which
|
|
1461
1639
|
// react-native-worklets >=0.10 refuses to copy to the UI thread.
|
|
1462
1640
|
const dayCount = days.length;
|
|
1463
|
-
const dayWidth =
|
|
1464
|
-
const dayLeft = (dayIndex: number) =>
|
|
1641
|
+
const dayWidth = width / dayCount;
|
|
1642
|
+
const dayLeft = (dayIndex: number) => dayIndex * dayWidth;
|
|
1465
1643
|
|
|
1466
1644
|
// Calendar-day offset of each column from the first, as plain numbers a drag
|
|
1467
1645
|
// worklet can close over. Identity (0,1,2,…) for contiguous days; with
|
|
@@ -1513,11 +1691,7 @@ function TimetablePageInner<T>({
|
|
|
1513
1691
|
if (date) onLongPressCell?.(date);
|
|
1514
1692
|
};
|
|
1515
1693
|
|
|
1516
|
-
|
|
1517
|
-
const hoursRange = useMemo(
|
|
1518
|
-
() => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index),
|
|
1519
|
-
[minHour, maxHour],
|
|
1520
|
-
);
|
|
1694
|
+
const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1521
1695
|
|
|
1522
1696
|
const now = useNow(showNowIndicator && isActive, { now: nowProp, timeZone: nowTimeZone });
|
|
1523
1697
|
// "Today" follows the (possibly zone-shifted or overridden) now, so the line
|
|
@@ -1530,33 +1704,35 @@ function TimetablePageInner<T>({
|
|
|
1530
1704
|
() => ({ height: (maxHour - minHour) * heightSource.value }),
|
|
1531
1705
|
[minHour, maxHour, heightSource],
|
|
1532
1706
|
);
|
|
1533
|
-
|
|
1534
|
-
//
|
|
1535
|
-
//
|
|
1536
|
-
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1707
|
+
// The page stacks its all-day band, the label inset, then the hours. The band
|
|
1708
|
+
// rides the scroll offset so it holds still at the top of the viewport while
|
|
1709
|
+
// the hours pass beneath it, and it slides with the page during a swipe.
|
|
1710
|
+
const headerOffset = pagedHeader ? DAY_HEADER_HEIGHT : 0;
|
|
1711
|
+
const gridStyle = useAnimatedStyle(
|
|
1712
|
+
() => ({
|
|
1713
|
+
top: headerOffset + laneHeight.value + HOUR_LABEL_TOP_INSET,
|
|
1714
|
+
height: (maxHour - minHour) * heightSource.value,
|
|
1715
|
+
}),
|
|
1716
|
+
[minHour, maxHour, heightSource, headerOffset],
|
|
1717
|
+
);
|
|
1718
|
+
// Split like the hour column's cell: the offset style only runs on a scroll,
|
|
1719
|
+
// the height style only when the band resizes. Both the header and the band
|
|
1720
|
+
// ride the scroll offset, so they hold still at the top while the hours pass.
|
|
1721
|
+
// The band keeps a 1px floor when the lane measures nothing, so the lane inside
|
|
1722
|
+
// is never clipped to nothing: Android stops reporting the layout of a view
|
|
1723
|
+
// clipped away entirely, which would leave all-day events that arrive later
|
|
1724
|
+
// unmeasured. The bottom rule only draws once the band has real height.
|
|
1725
|
+
const laneHeightStyle = useAnimatedStyle(() => ({
|
|
1726
|
+
height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
|
|
1727
|
+
borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? StyleSheet.hairlineWidth : 0,
|
|
1728
|
+
}));
|
|
1729
|
+
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
|
|
1730
|
+
const reportLaneLayout = useCallback(
|
|
1731
|
+
(event: LayoutChangeEvent) => {
|
|
1732
|
+
onLaneLayout(pageIndex, event.nativeEvent.layout.height);
|
|
1733
|
+
},
|
|
1734
|
+
[onLaneLayout, pageIndex],
|
|
1735
|
+
);
|
|
1560
1736
|
|
|
1561
1737
|
// Drag-to-create: sweep out a new event on empty grid. Native long-presses
|
|
1562
1738
|
// first (so a tap/scroll isn't hijacked); web uses a drag threshold like move,
|
|
@@ -1609,7 +1785,7 @@ function TimetablePageInner<T>({
|
|
|
1609
1785
|
const idx = dayCount === 1 ? 0 : Math.floor(event.x / dayWidth);
|
|
1610
1786
|
createDayIndex.value = idx;
|
|
1611
1787
|
createStartY.value = event.y;
|
|
1612
|
-
createLeft.value =
|
|
1788
|
+
createLeft.value = idx * dayWidth;
|
|
1613
1789
|
createWidth.value = dayWidth;
|
|
1614
1790
|
createTop.value = event.y;
|
|
1615
1791
|
createHeight.value = 0;
|
|
@@ -1644,7 +1820,6 @@ function TimetablePageInner<T>({
|
|
|
1644
1820
|
createEnabled,
|
|
1645
1821
|
dayCount,
|
|
1646
1822
|
dayWidth,
|
|
1647
|
-
hourColumnWidth,
|
|
1648
1823
|
heightSource,
|
|
1649
1824
|
snapMinutes,
|
|
1650
1825
|
commitCreate,
|
|
@@ -1711,7 +1886,7 @@ function TimetablePageInner<T>({
|
|
|
1711
1886
|
const cellLayer =
|
|
1712
1887
|
onPressCell || onLongPressCell || createEnabled ? (
|
|
1713
1888
|
<Pressable
|
|
1714
|
-
style={
|
|
1889
|
+
style={styles.cellPressLayer}
|
|
1715
1890
|
onPress={onPressCell ? handleBackgroundPress : undefined}
|
|
1716
1891
|
// When create is on, a long-press starts the create-drag, so don't also
|
|
1717
1892
|
// fire the consumer's long-press handler.
|
|
@@ -1726,247 +1901,266 @@ function TimetablePageInner<T>({
|
|
|
1726
1901
|
) : null;
|
|
1727
1902
|
|
|
1728
1903
|
return (
|
|
1729
|
-
<View
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1904
|
+
<View
|
|
1905
|
+
testID="time-grid-page"
|
|
1906
|
+
style={[styles.page, { width, height }]}
|
|
1907
|
+
// Only the active page is on screen; keep the pre-mounted neighbours out of
|
|
1908
|
+
// the screen-reader traversal so their events and headers aren't announced.
|
|
1909
|
+
accessibilityElementsHidden={!isActive}
|
|
1910
|
+
importantForAccessibility={isActive ? "auto" : "no-hide-descendants"}
|
|
1911
|
+
>
|
|
1912
|
+
{pagedHeader ? (
|
|
1913
|
+
<Animated.View
|
|
1914
|
+
testID="paged-header"
|
|
1915
|
+
style={[
|
|
1916
|
+
styles.pagedHeader,
|
|
1917
|
+
{ backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.gridLine },
|
|
1918
|
+
pinStyle,
|
|
1919
|
+
]}
|
|
1920
|
+
>
|
|
1921
|
+
<DayHeaderRow
|
|
1922
|
+
days={days}
|
|
1923
|
+
mode={mode}
|
|
1924
|
+
dayWidth={dayWidth}
|
|
1925
|
+
weekdayFormat={weekdayFormat}
|
|
1926
|
+
todayLabel={todayLabel}
|
|
1927
|
+
locale={locale}
|
|
1928
|
+
activeDate={activeDate}
|
|
1929
|
+
onPressDateHeader={onPressDateHeader}
|
|
1930
|
+
/>
|
|
1931
|
+
</Animated.View>
|
|
1742
1932
|
) : null}
|
|
1743
|
-
|
|
1744
|
-
<Animated.
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
}
|
|
1756
|
-
contentContainerStyle={{ paddingTop: HOUR_LABEL_TOP_INSET }}
|
|
1757
|
-
contentOffset={{ x: 0, y: initialScrollY }}
|
|
1933
|
+
{showAllDayEventCell ? (
|
|
1934
|
+
<Animated.View
|
|
1935
|
+
testID="all-day-band"
|
|
1936
|
+
style={[
|
|
1937
|
+
styles.laneBand,
|
|
1938
|
+
{
|
|
1939
|
+
top: headerOffset,
|
|
1940
|
+
backgroundColor: theme.colors.surface,
|
|
1941
|
+
borderBottomColor: theme.colors.gridLine,
|
|
1942
|
+
},
|
|
1943
|
+
laneHeightStyle,
|
|
1944
|
+
pinStyle,
|
|
1945
|
+
]}
|
|
1758
1946
|
>
|
|
1759
|
-
<
|
|
1760
|
-
{
|
|
1947
|
+
<AllDayLane
|
|
1948
|
+
days={days}
|
|
1949
|
+
events={events}
|
|
1950
|
+
mode={mode}
|
|
1951
|
+
dayWidth={dayWidth}
|
|
1952
|
+
renderEvent={renderEvent}
|
|
1953
|
+
keyExtractor={keyExtractor}
|
|
1954
|
+
onPressEvent={onPressEvent}
|
|
1955
|
+
onLongPressEvent={onLongPressEvent}
|
|
1956
|
+
onLayout={reportLaneLayout}
|
|
1957
|
+
/>
|
|
1958
|
+
</Animated.View>
|
|
1959
|
+
) : null}
|
|
1960
|
+
<Animated.View style={[styles.grid, gridStyle]}>
|
|
1961
|
+
{/* Behind the events, so empty-space taps/drags create while event
|
|
1761
1962
|
taps still hit their box. */}
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1963
|
+
{cellLayer && backgroundGesture ? (
|
|
1964
|
+
<GestureDetector gesture={backgroundGesture}>{cellLayer}</GestureDetector>
|
|
1965
|
+
) : (
|
|
1966
|
+
cellLayer
|
|
1967
|
+
)}
|
|
1968
|
+
|
|
1969
|
+
{days.map((day, dayIndex) => {
|
|
1970
|
+
if (!highlightWeekends || !isWeekend(day)) return null;
|
|
1971
|
+
const shadeSlot = slot("weekendShade", {
|
|
1972
|
+
base: [
|
|
1973
|
+
styles.weekendColumn,
|
|
1974
|
+
styles.nonInteractive,
|
|
1975
|
+
{ left: dayLeft(dayIndex), width: dayWidth },
|
|
1976
|
+
],
|
|
1977
|
+
themed: { backgroundColor: theme.colors.weekendBackground },
|
|
1978
|
+
});
|
|
1979
|
+
return (
|
|
1980
|
+
<Animated.View
|
|
1981
|
+
key={`weekend-${day.toISOString()}`}
|
|
1982
|
+
testID="weekend-shade"
|
|
1983
|
+
{...shadeSlot}
|
|
1984
|
+
style={[shadeSlot.style, fullHeightStyle]}
|
|
1985
|
+
/>
|
|
1986
|
+
);
|
|
1987
|
+
})}
|
|
1988
|
+
|
|
1989
|
+
{calendarCellStyle
|
|
1990
|
+
? days.map((day, dayIndex) => {
|
|
1991
|
+
const cellStyle = calendarCellStyle(day);
|
|
1992
|
+
return cellStyle ? (
|
|
1779
1993
|
<Animated.View
|
|
1780
|
-
key={`
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1994
|
+
key={`cell-${day.toISOString()}`}
|
|
1995
|
+
style={[
|
|
1996
|
+
styles.weekendColumn,
|
|
1997
|
+
styles.nonInteractive,
|
|
1998
|
+
{ left: dayLeft(dayIndex), width: dayWidth },
|
|
1999
|
+
cellStyle,
|
|
2000
|
+
fullHeightStyle,
|
|
2001
|
+
]}
|
|
2002
|
+
/>
|
|
2003
|
+
) : null;
|
|
2004
|
+
})
|
|
2005
|
+
: null}
|
|
2006
|
+
|
|
2007
|
+
{businessHours
|
|
2008
|
+
? days.flatMap((day, dayIndex) =>
|
|
2009
|
+
closedHourBands(day, businessHours, minHour, maxHour).map((band, bandIndex) => (
|
|
2010
|
+
<ShadeBand
|
|
2011
|
+
key={`closed-${day.toISOString()}-${bandIndex}`}
|
|
2012
|
+
cellHeight={heightSource}
|
|
2013
|
+
startHour={band.start}
|
|
2014
|
+
endHour={band.end}
|
|
2015
|
+
minHour={minHour}
|
|
2016
|
+
left={dayLeft(dayIndex)}
|
|
2017
|
+
width={dayWidth}
|
|
2018
|
+
color={renderBusinessHours ? undefined : theme.colors.outsideHoursBackground}
|
|
2019
|
+
>
|
|
2020
|
+
{renderBusinessHours?.({ date: day, start: band.start, end: band.end })}
|
|
2021
|
+
</ShadeBand>
|
|
2022
|
+
)),
|
|
2023
|
+
)
|
|
2024
|
+
: null}
|
|
2025
|
+
|
|
2026
|
+
{/* Background events: shaded time ranges, or the consumer's own band. */}
|
|
2027
|
+
{days.flatMap((day, dayIndex) => {
|
|
2028
|
+
const dayStart = startOfDay(day);
|
|
2029
|
+
const nextDayStart = addDays(dayStart, 1);
|
|
2030
|
+
return backgroundBandsForDay(events, day)
|
|
2031
|
+
.map((b) => ({
|
|
2032
|
+
...b,
|
|
2033
|
+
startHours: Math.max(b.startHours, minHour),
|
|
2034
|
+
endHours: Math.min(b.endHours, maxHour),
|
|
2035
|
+
}))
|
|
2036
|
+
.filter((b) => b.endHours > b.startHours)
|
|
2037
|
+
.map((b, bandIndex) => {
|
|
2038
|
+
const key = `bg-${day.toISOString()}-${keyExtractor(b.event, bandIndex)}`;
|
|
2039
|
+
return renderBackgroundEvent ? (
|
|
2040
|
+
<BackgroundEventBand
|
|
2041
|
+
key={key}
|
|
2042
|
+
event={b.event}
|
|
2043
|
+
cellHeight={heightSource}
|
|
2044
|
+
startHour={b.startHours}
|
|
2045
|
+
endHour={b.endHours}
|
|
2046
|
+
minHour={minHour}
|
|
2047
|
+
left={dayLeft(dayIndex)}
|
|
2048
|
+
width={dayWidth}
|
|
2049
|
+
mode={mode}
|
|
2050
|
+
continuesBefore={b.event.start < dayStart}
|
|
2051
|
+
continuesAfter={b.event.end > nextDayStart}
|
|
2052
|
+
render={renderBackgroundEvent}
|
|
2053
|
+
onPress={onPressEvent}
|
|
2054
|
+
onLongPress={onLongPressEvent}
|
|
2055
|
+
/>
|
|
2056
|
+
) : (
|
|
2057
|
+
<ShadeBand
|
|
2058
|
+
key={key}
|
|
2059
|
+
cellHeight={heightSource}
|
|
2060
|
+
startHour={b.startHours}
|
|
2061
|
+
endHour={b.endHours}
|
|
2062
|
+
minHour={minHour}
|
|
2063
|
+
left={dayLeft(dayIndex)}
|
|
2064
|
+
width={dayWidth}
|
|
2065
|
+
color={theme.colors.backgroundEvent}
|
|
2066
|
+
slotName="backgroundEvent"
|
|
2067
|
+
testID="background-event-shade"
|
|
1784
2068
|
/>
|
|
1785
2069
|
);
|
|
1786
|
-
})
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
cellHeight={heightSource}
|
|
1812
|
-
startHour={band.start}
|
|
1813
|
-
endHour={band.end}
|
|
1814
|
-
minHour={minHour}
|
|
1815
|
-
left={dayLeft(dayIndex)}
|
|
1816
|
-
width={dayWidth}
|
|
1817
|
-
color={renderBusinessHours ? undefined : theme.colors.outsideHoursBackground}
|
|
1818
|
-
>
|
|
1819
|
-
{renderBusinessHours?.({ date: day, start: band.start, end: band.end })}
|
|
1820
|
-
</ShadeBand>
|
|
1821
|
-
)),
|
|
1822
|
-
)
|
|
1823
|
-
: null}
|
|
1824
|
-
|
|
1825
|
-
{/* Background events: shaded, non-interactive time ranges. */}
|
|
1826
|
-
{days.flatMap((day, dayIndex) =>
|
|
1827
|
-
backgroundBandsForDay(events, day)
|
|
1828
|
-
.map((b) => ({
|
|
1829
|
-
...b,
|
|
1830
|
-
startHours: Math.max(b.startHours, minHour),
|
|
1831
|
-
endHours: Math.min(b.endHours, maxHour),
|
|
1832
|
-
}))
|
|
1833
|
-
.filter((b) => b.endHours > b.startHours)
|
|
1834
|
-
.map((b, bandIndex) => (
|
|
1835
|
-
<ShadeBand
|
|
1836
|
-
key={`bg-${day.toISOString()}-${bandIndex}`}
|
|
1837
|
-
cellHeight={heightSource}
|
|
1838
|
-
startHour={b.startHours}
|
|
1839
|
-
endHour={b.endHours}
|
|
1840
|
-
minHour={minHour}
|
|
1841
|
-
left={dayLeft(dayIndex)}
|
|
1842
|
-
width={dayWidth}
|
|
1843
|
-
color={theme.colors.backgroundEvent}
|
|
1844
|
-
slotName="backgroundEvent"
|
|
1845
|
-
testID="background-event-shade"
|
|
1846
|
-
/>
|
|
1847
|
-
)),
|
|
1848
|
-
)}
|
|
1849
|
-
|
|
1850
|
-
{days.map((day, dayIndex) => {
|
|
1851
|
-
const separatorSlot = slot("daySeparator", {
|
|
1852
|
-
base: [styles.daySeparator, styles.nonInteractive, { left: dayLeft(dayIndex) }],
|
|
1853
|
-
themed: { backgroundColor: theme.colors.gridLine },
|
|
1854
|
-
});
|
|
2070
|
+
});
|
|
2071
|
+
})}
|
|
2072
|
+
|
|
2073
|
+
{days.map((day, dayIndex) => {
|
|
2074
|
+
const separatorSlot = slot("daySeparator", {
|
|
2075
|
+
base: [styles.daySeparator, styles.nonInteractive, { left: dayLeft(dayIndex) }],
|
|
2076
|
+
themed: { backgroundColor: theme.colors.gridLine },
|
|
2077
|
+
});
|
|
2078
|
+
return (
|
|
2079
|
+
<Animated.View
|
|
2080
|
+
key={`separator-${day.toISOString()}`}
|
|
2081
|
+
{...separatorSlot}
|
|
2082
|
+
style={[separatorSlot.style, fullHeightStyle]}
|
|
2083
|
+
/>
|
|
2084
|
+
);
|
|
2085
|
+
})}
|
|
2086
|
+
|
|
2087
|
+
<HourLines hours={hoursRange} timeslots={timeslots} />
|
|
2088
|
+
|
|
2089
|
+
{dayLayouts.flatMap((layout, dayIndex) =>
|
|
2090
|
+
layout
|
|
2091
|
+
// Skip events that fall entirely outside the [minHour, maxHour) window.
|
|
2092
|
+
.filter((p) => p.startHours < maxHour && p.startHours + p.durationHours > minHour)
|
|
2093
|
+
.map((positioned, eventIndex) => {
|
|
2094
|
+
const columnWidth = dayWidth / positioned.columns;
|
|
1855
2095
|
return (
|
|
1856
|
-
<
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
2096
|
+
<AnimatedEventBox
|
|
2097
|
+
// Prefix with the day so a multi-day event's per-day segments
|
|
2098
|
+
// (which share the same event key) stay unique across the
|
|
2099
|
+
// flattened list of all days' boxes.
|
|
2100
|
+
key={`${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`}
|
|
2101
|
+
positioned={positioned}
|
|
2102
|
+
eventIndex={events.indexOf(positioned.event)}
|
|
2103
|
+
movingEvent={movingEvent}
|
|
2104
|
+
onMovePreview={setMultiDayMove}
|
|
2105
|
+
cellHeight={heightSource}
|
|
2106
|
+
minHour={minHour}
|
|
2107
|
+
maxHour={maxHour}
|
|
2108
|
+
left={dayLeft(dayIndex) + positioned.column * columnWidth}
|
|
2109
|
+
width={columnWidth}
|
|
2110
|
+
dayLeftPx={dayLeft(dayIndex)}
|
|
2111
|
+
nextDayDirection={isRTL ? -1 : 1}
|
|
2112
|
+
dayWidth={dayWidth}
|
|
2113
|
+
dayIndex={dayIndex}
|
|
2114
|
+
dayCount={days.length}
|
|
2115
|
+
dayOrdinals={dayOrdinals}
|
|
2116
|
+
mode={mode}
|
|
2117
|
+
daysPerPage={daysPerPage}
|
|
2118
|
+
renderEvent={renderEvent}
|
|
2119
|
+
snapMinutes={snapMinutes}
|
|
2120
|
+
minEventHeight={minEventHeight}
|
|
2121
|
+
eventGap={eventGap}
|
|
2122
|
+
showDragHandle={showDragHandle}
|
|
2123
|
+
eventStartEditable={eventStartEditable}
|
|
2124
|
+
eventDurationEditable={eventDurationEditable}
|
|
2125
|
+
onPress={onPressEvent}
|
|
2126
|
+
onLongPress={onLongPressEvent}
|
|
2127
|
+
onDragEvent={onDragEvent}
|
|
2128
|
+
onDragStart={onDragStart}
|
|
2129
|
+
onEdgeAdvance={onEdgeAdvance}
|
|
1860
2130
|
/>
|
|
1861
2131
|
);
|
|
1862
|
-
})
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
? hoursRange.flatMap((hour) =>
|
|
1879
|
-
Array.from({ length: timeslots - 1 }, (_, i) => (
|
|
1880
|
-
<TimeslotLine
|
|
1881
|
-
key={`slot-${hour}-${i}`}
|
|
1882
|
-
hour={hour}
|
|
1883
|
-
minHour={minHour}
|
|
1884
|
-
fraction={(i + 1) / timeslots}
|
|
1885
|
-
cellHeight={heightSource}
|
|
1886
|
-
hourColumnWidth={hourColumnWidth}
|
|
1887
|
-
/>
|
|
1888
|
-
)),
|
|
1889
|
-
)
|
|
1890
|
-
: null}
|
|
1891
|
-
|
|
1892
|
-
{dayLayouts.flatMap((layout, dayIndex) =>
|
|
1893
|
-
layout
|
|
1894
|
-
// Skip events that fall entirely outside the [minHour, maxHour) window.
|
|
1895
|
-
.filter((p) => p.startHours < maxHour && p.startHours + p.durationHours > minHour)
|
|
1896
|
-
.map((positioned, eventIndex) => {
|
|
1897
|
-
const columnWidth = dayWidth / positioned.columns;
|
|
1898
|
-
return (
|
|
1899
|
-
<AnimatedEventBox
|
|
1900
|
-
// Prefix with the day so a multi-day event's per-day segments
|
|
1901
|
-
// (which share the same event key) stay unique across the
|
|
1902
|
-
// flattened list of all days' boxes.
|
|
1903
|
-
key={`${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`}
|
|
1904
|
-
positioned={positioned}
|
|
1905
|
-
eventIndex={events.indexOf(positioned.event)}
|
|
1906
|
-
movingEvent={movingEvent}
|
|
1907
|
-
onMovePreview={setMultiDayMove}
|
|
1908
|
-
cellHeight={heightSource}
|
|
1909
|
-
minHour={minHour}
|
|
1910
|
-
maxHour={maxHour}
|
|
1911
|
-
left={dayLeft(dayIndex) + positioned.column * columnWidth}
|
|
1912
|
-
width={columnWidth}
|
|
1913
|
-
dayLeftPx={dayLeft(dayIndex)}
|
|
1914
|
-
nextDayDirection={isRTL ? -1 : 1}
|
|
1915
|
-
dayWidth={dayWidth}
|
|
1916
|
-
dayIndex={dayIndex}
|
|
1917
|
-
dayCount={days.length}
|
|
1918
|
-
dayOrdinals={dayOrdinals}
|
|
1919
|
-
mode={mode}
|
|
1920
|
-
daysPerPage={daysPerPage}
|
|
1921
|
-
renderEvent={renderEvent}
|
|
1922
|
-
snapMinutes={snapMinutes}
|
|
1923
|
-
minEventHeight={minEventHeight}
|
|
1924
|
-
eventGap={eventGap}
|
|
1925
|
-
showDragHandle={showDragHandle}
|
|
1926
|
-
eventStartEditable={eventStartEditable}
|
|
1927
|
-
eventDurationEditable={eventDurationEditable}
|
|
1928
|
-
onPress={onPressEvent}
|
|
1929
|
-
onLongPress={onLongPressEvent}
|
|
1930
|
-
onDragEvent={onDragEvent}
|
|
1931
|
-
onDragStart={onDragStart}
|
|
1932
|
-
onEdgeAdvance={onEdgeAdvance}
|
|
1933
|
-
/>
|
|
1934
|
-
);
|
|
1935
|
-
}),
|
|
1936
|
-
)}
|
|
1937
|
-
|
|
1938
|
-
{multiDayMove ? (
|
|
1939
|
-
<MultiDayMovePreview
|
|
1940
|
-
move={multiDayMove}
|
|
1941
|
-
days={days}
|
|
1942
|
-
cellHeight={heightSource}
|
|
1943
|
-
dayWidth={dayWidth}
|
|
1944
|
-
hourColumnWidth={hourColumnWidth}
|
|
1945
|
-
minHour={minHour}
|
|
1946
|
-
mode={mode}
|
|
1947
|
-
renderEvent={renderEvent}
|
|
1948
|
-
minEventHeight={minEventHeight}
|
|
1949
|
-
eventGap={eventGap}
|
|
1950
|
-
/>
|
|
1951
|
-
) : null}
|
|
2132
|
+
}),
|
|
2133
|
+
)}
|
|
2134
|
+
|
|
2135
|
+
{multiDayMove ? (
|
|
2136
|
+
<MultiDayMovePreview
|
|
2137
|
+
move={multiDayMove}
|
|
2138
|
+
days={days}
|
|
2139
|
+
cellHeight={heightSource}
|
|
2140
|
+
dayWidth={dayWidth}
|
|
2141
|
+
minHour={minHour}
|
|
2142
|
+
mode={mode}
|
|
2143
|
+
renderEvent={renderEvent}
|
|
2144
|
+
minEventHeight={minEventHeight}
|
|
2145
|
+
eventGap={eventGap}
|
|
2146
|
+
/>
|
|
2147
|
+
) : null}
|
|
1952
2148
|
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
2149
|
+
{showNowIndicator && nowDayIndex >= 0 && nowInWindow ? (
|
|
2150
|
+
<NowIndicator
|
|
2151
|
+
cellHeight={heightSource}
|
|
2152
|
+
nowHours={nowHours}
|
|
2153
|
+
minHour={minHour}
|
|
2154
|
+
left={dayLeft(nowDayIndex)}
|
|
2155
|
+
width={dayWidth}
|
|
2156
|
+
color={theme.colors.nowIndicator}
|
|
2157
|
+
/>
|
|
2158
|
+
) : null}
|
|
1963
2159
|
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
</Animated.ScrollView>
|
|
1969
|
-
</GestureDetector>
|
|
2160
|
+
{createEnabled ? (
|
|
2161
|
+
<Animated.View {...ghostSlot} style={[ghostSlot.style, createGhostStyle]} />
|
|
2162
|
+
) : null}
|
|
2163
|
+
</Animated.View>
|
|
1970
2164
|
</View>
|
|
1971
2165
|
);
|
|
1972
2166
|
}
|
|
@@ -1978,10 +2172,10 @@ const TimetablePage = memo(TimetablePageInner) as typeof TimetablePageInner;
|
|
|
1978
2172
|
* where the structure matches; `columnHeaderDateText`, `weekendShade` and
|
|
1979
2173
|
* `daySeparator` are native-only (the dom grid styles those through its
|
|
1980
2174
|
* `dayColumn`/`columnHeaderDate` elements). Slots rendered as Reanimated views
|
|
1981
|
-
* (`
|
|
1982
|
-
* `
|
|
1983
|
-
* `
|
|
1984
|
-
*
|
|
2175
|
+
* (`businessHours`, `weekendShade`, `daySeparator`, `event`,
|
|
2176
|
+
* `nowIndicator`, `createGhost`) always honour the `styles` map; their
|
|
2177
|
+
* `className` reaches the element but needs a Tailwind runtime that styles
|
|
2178
|
+
* Animated components.
|
|
1985
2179
|
*/
|
|
1986
2180
|
export type TimeGridSlot =
|
|
1987
2181
|
| "header"
|
|
@@ -1994,6 +2188,7 @@ export type TimeGridSlot =
|
|
|
1994
2188
|
| "allDayLabel"
|
|
1995
2189
|
| "allDayColumn"
|
|
1996
2190
|
| "allDayEvent"
|
|
2191
|
+
| "hourGutter"
|
|
1997
2192
|
| "hourLabel"
|
|
1998
2193
|
| "gridLines"
|
|
1999
2194
|
| "businessHours"
|
|
@@ -2029,6 +2224,8 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
2029
2224
|
weekStartsOn: WeekStartsOn;
|
|
2030
2225
|
/** Column-header weekday label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
|
|
2031
2226
|
weekdayFormat?: WeekdayFormat;
|
|
2227
|
+
/** Translations for the screen-reader words and gutter text; omitted keys use English. */
|
|
2228
|
+
labels?: Partial<CalendarLabels>;
|
|
2032
2229
|
renderEvent: RenderEvent<T>;
|
|
2033
2230
|
/**
|
|
2034
2231
|
* Override the screen-reader label for each event. Receives the event and a
|
|
@@ -2045,6 +2242,11 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
2045
2242
|
timeslots?: number;
|
|
2046
2243
|
/** Show the all-day lane above the grid. Default true. */
|
|
2047
2244
|
showAllDayEventCell?: boolean;
|
|
2245
|
+
/** Pull-to-refresh control, mounted on the grid's vertical scroll view. */
|
|
2246
|
+
refreshControl?: ScrollViewProps["refreshControl"];
|
|
2247
|
+
/** Show the "all-day" text label in the hour column. Default false; the lane
|
|
2248
|
+
* still reserves its row, it just isn't labelled. */
|
|
2249
|
+
showAllDayLabel?: boolean;
|
|
2048
2250
|
/** Tint Saturday/Sunday columns with the weekend background. Default true. Set
|
|
2049
2251
|
* false to treat weekends like any other day. */
|
|
2050
2252
|
highlightWeekends?: boolean;
|
|
@@ -2058,6 +2260,8 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
2058
2260
|
* band stays non-interactive and hidden from assistive tech.
|
|
2059
2261
|
*/
|
|
2060
2262
|
renderBusinessHours?: (band: BusinessHoursBand) => React.ReactNode;
|
|
2263
|
+
/** A component that draws a background event's band; see `Calendar`. */
|
|
2264
|
+
renderBackgroundEvent?: RenderEvent<T>;
|
|
2061
2265
|
/** Show the ISO week number in the header gutter. Default false. */
|
|
2062
2266
|
showWeekNumber?: boolean;
|
|
2063
2267
|
/** Element rendered between the day header and the grid. */
|
|
@@ -2144,6 +2348,7 @@ function TimeGridInner<T>({
|
|
|
2144
2348
|
hourHeight = DEFAULT_HOUR_HEIGHT,
|
|
2145
2349
|
weekStartsOn,
|
|
2146
2350
|
weekdayFormat = "short",
|
|
2351
|
+
labels: labelsProp,
|
|
2147
2352
|
renderEvent,
|
|
2148
2353
|
eventAccessibilityLabel,
|
|
2149
2354
|
keyExtractor,
|
|
@@ -2152,10 +2357,13 @@ function TimeGridInner<T>({
|
|
|
2152
2357
|
hideHours = false,
|
|
2153
2358
|
timeslots = 1,
|
|
2154
2359
|
showAllDayEventCell = true,
|
|
2360
|
+
showAllDayLabel = false,
|
|
2361
|
+
refreshControl,
|
|
2155
2362
|
highlightWeekends = true,
|
|
2156
2363
|
calendarCellStyle,
|
|
2157
2364
|
businessHours,
|
|
2158
2365
|
renderBusinessHours,
|
|
2366
|
+
renderBackgroundEvent,
|
|
2159
2367
|
showWeekNumber = false,
|
|
2160
2368
|
headerComponent,
|
|
2161
2369
|
minHour = 0,
|
|
@@ -2202,6 +2410,13 @@ function TimeGridInner<T>({
|
|
|
2202
2410
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
2203
2411
|
// Collapse the hour gutter to zero when hours are hidden.
|
|
2204
2412
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
2413
|
+
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
2414
|
+
const todayLabel = labels.today;
|
|
2415
|
+
// The built-in day header pages with the columns (rendered inside each page). A
|
|
2416
|
+
// custom `renderHeader` keeps a single fixed header above the pager instead, so
|
|
2417
|
+
// the pages carry no header and nothing offsets by its height.
|
|
2418
|
+
const pagedHeader = renderHeader == null;
|
|
2419
|
+
const headerOffset = pagedHeader ? DAY_HEADER_HEIGHT : 0;
|
|
2205
2420
|
|
|
2206
2421
|
// Inject a consumer's `eventAccessibilityLabel` override into every event once,
|
|
2207
2422
|
// so the timed columns and the all-day lane share it without threading a prop
|
|
@@ -2220,7 +2435,7 @@ function TimeGridInner<T>({
|
|
|
2220
2435
|
overlapsOtherEvents(events, event, start, end) ? false : onDragEventProp(event, start, end);
|
|
2221
2436
|
}, [onDragEventProp, eventOverlap, events]);
|
|
2222
2437
|
|
|
2223
|
-
const { width
|
|
2438
|
+
const { width } = useWindowDimensions();
|
|
2224
2439
|
const listRef = useRef<LegendListRef>(null);
|
|
2225
2440
|
// The pager's own view; measured in the window so an event drag can locate the
|
|
2226
2441
|
// horizontal edges (its screen-space left and width) for cross-week paging.
|
|
@@ -2228,40 +2443,113 @@ function TimeGridInner<T>({
|
|
|
2228
2443
|
// The grid's outer view; on web its ref resolves to the DOM node we attach the
|
|
2229
2444
|
// Ctrl/Cmd + scroll zoom listener to.
|
|
2230
2445
|
const containerRef = useRef<View>(null);
|
|
2231
|
-
//
|
|
2232
|
-
//
|
|
2233
|
-
const
|
|
2234
|
-
//
|
|
2235
|
-
//
|
|
2236
|
-
const
|
|
2446
|
+
// The scroll viewport; measured in the window so a lifted drag can map the
|
|
2447
|
+
// finger into the scrolling content.
|
|
2448
|
+
const viewportRef = useRef<View>(null);
|
|
2449
|
+
// Width the pager last laid out at, so the zoom (which changes its height every
|
|
2450
|
+
// frame) doesn't re-measure it.
|
|
2451
|
+
const pagerLayoutWidthRef = useRef(-1);
|
|
2452
|
+
const scrollRef = useAnimatedRef<Animated.ScrollView>();
|
|
2237
2453
|
// The grid sizes to its container width, not the window, so it fits a
|
|
2238
2454
|
// constrained layout on the web (e.g. a max-width card). On native the grid
|
|
2239
2455
|
// fills the window, so this equals the window width and behaviour is unchanged.
|
|
2240
|
-
// Seeded with the window width
|
|
2456
|
+
// Seeded with the window width so width-derived values exist before the first
|
|
2457
|
+
// layout, then refined on layout.
|
|
2241
2458
|
const [containerWidth, setContainerWidth] = useState(width);
|
|
2242
|
-
//
|
|
2243
|
-
//
|
|
2244
|
-
//
|
|
2245
|
-
|
|
2246
|
-
const
|
|
2459
|
+
// Width of the day columns: the pager's own, once it has laid out (on the web
|
|
2460
|
+
// a classic scrollbar takes width inside the scroll view), else what the hour
|
|
2461
|
+
// column leaves of the container.
|
|
2462
|
+
const [pagerLayoutWidth, setPagerLayoutWidth] = useState<number | null>(null);
|
|
2463
|
+
const columnsWidth = pagerLayoutWidth ?? containerWidth - hourColumnWidth;
|
|
2464
|
+
// The pager mounts only once its container has laid out, so the list's fixed
|
|
2465
|
+
// item size is the measured width rather than the window-based estimate.
|
|
2466
|
+
const pagerReady = pagerLayoutWidth != null && pagerLayoutWidth > 0;
|
|
2467
|
+
// The tallest all-day lane reported so far, so the fixed pager height below
|
|
2468
|
+
// always has room for the band.
|
|
2469
|
+
const [tallestLane, setTallestLane] = useState(0);
|
|
2247
2470
|
// Week-anchored modes page by a full week and align pages to the week start:
|
|
2248
2471
|
// `week`, and `custom` when a `weekEndsOn` defines a partial-week span.
|
|
2249
2472
|
const weekAnchored = mode === "week" || (mode === "custom" && weekEndsOn != null);
|
|
2250
2473
|
// Days advanced per page: a full week when week-anchored, else the column count.
|
|
2251
2474
|
const step = weekAnchored ? 7 : viewDayCount(mode, numberOfDays);
|
|
2252
|
-
//
|
|
2253
|
-
//
|
|
2254
|
-
//
|
|
2475
|
+
// Initial vertical offset (`scrollOffsetMinutes`), from the numeric hourHeight
|
|
2476
|
+
// rather than cellHeight.value (which would warn about reading a shared value
|
|
2477
|
+
// during render).
|
|
2255
2478
|
const seedDefaultY =
|
|
2256
2479
|
Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR - clampedMinHour) * hourHeight;
|
|
2480
|
+
// The live offset of the one scroll view, for the drag worklets: the pager
|
|
2481
|
+
// scrolls with the content, so a finger's window position maps into the grid
|
|
2482
|
+
// through it.
|
|
2257
2483
|
const scrollY = useSharedValue(seedDefaultY);
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2484
|
+
const scrollHandler = useAnimatedScrollHandler({
|
|
2485
|
+
onScroll: (event) => {
|
|
2486
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2487
|
+
scrollY.value = event.contentOffset.y;
|
|
2488
|
+
},
|
|
2489
|
+
});
|
|
2490
|
+
// react-native-web ignores `contentOffset`; apply the initial offset once the
|
|
2491
|
+
// viewport and the content have laid out instead.
|
|
2492
|
+
const webSeededRef = useRef(!isWeb);
|
|
2493
|
+
const seedWebScroll = useCallback(() => {
|
|
2494
|
+
if (webSeededRef.current) return;
|
|
2495
|
+
const node = scrollRef.current;
|
|
2496
|
+
if (!node) return;
|
|
2497
|
+
node.scrollTo({ y: seedDefaultY, animated: false });
|
|
2498
|
+
// Latch only once the view can hold the offset: until both the viewport and
|
|
2499
|
+
// the content have a size, the scroll clamps to 0 and would drop the seed.
|
|
2500
|
+
const dom = node.getScrollableNode() as { scrollHeight: number; clientHeight: number } | null;
|
|
2501
|
+
if (dom && dom.scrollHeight > dom.clientHeight) webSeededRef.current = true;
|
|
2502
|
+
}, [scrollRef, seedDefaultY]);
|
|
2503
|
+
// Height of the all-day band, shared by the hour column and every page. Each
|
|
2504
|
+
// page reports its lane's natural height under its index, and the band follows
|
|
2505
|
+
// the pager's live offset (kept on the UI thread by the list), interpolating
|
|
2506
|
+
// between the outgoing and incoming pages' heights so it resizes on the fly
|
|
2507
|
+
// during a swipe. The list opens on the anchor page. A guard below clamps the
|
|
2508
|
+
// interpolation to the committed page when the offset is more than 1.5 pages
|
|
2509
|
+
// away (a stale mount seed), so a multi-page `freeSwipe` fling holds the band
|
|
2510
|
+
// at the committed height and it snaps to the destination on settle rather than
|
|
2511
|
+
// animating the whole way; single-page paging (the default) interpolates fully.
|
|
2512
|
+
const laneHeights = useSharedValue<Record<number, number>>({});
|
|
2513
|
+
// Mirrored on the JS side: several pages report in one tick, and a read of the
|
|
2514
|
+
// shared value inside that tick still sees the previous batch, so building the
|
|
2515
|
+
// next map from `.value` would keep only the last report.
|
|
2516
|
+
const laneHeightsRef = useRef<Record<number, number>>({});
|
|
2517
|
+
const pagerOffset = useSharedValue(PAGE_WINDOW * columnsWidth);
|
|
2518
|
+
const pagerSharedValues = useMemo(() => ({ scrollOffset: pagerOffset }), [pagerOffset]);
|
|
2519
|
+
// The committed page, for the worklet below: the list only reports its offset
|
|
2520
|
+
// as it scrolls, and seeds it from its own scroll state at mount, which can
|
|
2521
|
+
// still be zero. An offset more than a page and a half from the committed
|
|
2522
|
+
// page is that stale seed, so the band reads as resting on the page.
|
|
2523
|
+
const activeIndexShared = useSharedValue(PAGE_WINDOW);
|
|
2524
|
+
const laneHeight = useDerivedValue(() => {
|
|
2525
|
+
if (!showAllDayEventCell || columnsWidth <= 0) return 0;
|
|
2526
|
+
const heights = laneHeights.value;
|
|
2527
|
+
let progress = pagerOffset.value / columnsWidth;
|
|
2528
|
+
if (Math.abs(progress - activeIndexShared.value) > 1.5) progress = activeIndexShared.value;
|
|
2529
|
+
const from = Math.floor(progress);
|
|
2530
|
+
const fraction = progress - from;
|
|
2531
|
+
const start = heights[from] ?? 0;
|
|
2532
|
+
const end = heights[from + 1] ?? start;
|
|
2533
|
+
return start + (end - start) * fraction;
|
|
2534
|
+
}, [showAllDayEventCell, columnsWidth]);
|
|
2535
|
+
const reportLaneHeight = useCallback(
|
|
2536
|
+
(index: number, height: number) => {
|
|
2537
|
+
setTallestLane((tallest) => (height > tallest ? height : tallest));
|
|
2538
|
+
if (laneHeightsRef.current[index] === height) return;
|
|
2539
|
+
laneHeightsRef.current = { ...laneHeightsRef.current, [index]: height };
|
|
2540
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2541
|
+
laneHeights.value = laneHeightsRef.current;
|
|
2542
|
+
},
|
|
2543
|
+
[laneHeights],
|
|
2544
|
+
);
|
|
2545
|
+
// Window-space frames (refined on layout), shared with the event drag worklets
|
|
2546
|
+
// through EdgePagingContext so a cross-week edge drag can detect the edges and
|
|
2547
|
+
// page the view live under a held finger. The pager's top follows the scroll:
|
|
2548
|
+
// the viewport's top, less the offset.
|
|
2549
|
+
const viewportTop = useSharedValue(0);
|
|
2261
2550
|
const pagerLeft = useSharedValue(0);
|
|
2262
|
-
const pagerTop = useSharedValue(0);
|
|
2263
2551
|
const pagerWidth = useSharedValue(width);
|
|
2264
|
-
const
|
|
2552
|
+
const pagerTop = useDerivedValue(() => viewportTop.value - scrollY.value);
|
|
2265
2553
|
// Floating "held" ghost that carries a dragged event across a page change (see
|
|
2266
2554
|
// EdgePaging): pager-local top-left, size, visibility, and the event to draw.
|
|
2267
2555
|
const ghostX = useSharedValue(0);
|
|
@@ -2269,10 +2557,6 @@ function TimeGridInner<T>({
|
|
|
2269
2557
|
const ghostW = useSharedValue(0);
|
|
2270
2558
|
const ghostH = useSharedValue(0);
|
|
2271
2559
|
const ghostVisible = useSharedValue(0);
|
|
2272
|
-
// Pager-local top of the active page's hour grid (the all-day lane above it
|
|
2273
|
-
// varies in height per week), so a cross-week drop maps the ghost's screen
|
|
2274
|
-
// position to the right time on the page it lands on.
|
|
2275
|
-
const gridTop = useSharedValue(0);
|
|
2276
2560
|
const [liftedEvent, setLiftedEvent] = useState<CalendarEvent<T> | null>(null);
|
|
2277
2561
|
const liftedEventRef = useRef<CalendarEvent<T> | null>(null);
|
|
2278
2562
|
// The drop commit needs the live page's columns and handler; keep them in a ref
|
|
@@ -2281,8 +2565,8 @@ function TimeGridInner<T>({
|
|
|
2281
2565
|
// drag (the gesture must outlive the page change to finish a cross-week drop).
|
|
2282
2566
|
const dropRef = useRef({
|
|
2283
2567
|
headerDays: [] as Date[],
|
|
2284
|
-
|
|
2285
|
-
|
|
2568
|
+
columnsWidth,
|
|
2569
|
+
headerOffset,
|
|
2286
2570
|
minHour: clampedMinHour,
|
|
2287
2571
|
maxHour: clampedMaxHour,
|
|
2288
2572
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
@@ -2298,14 +2582,13 @@ function TimeGridInner<T>({
|
|
|
2298
2582
|
ghostVisible.value = 0;
|
|
2299
2583
|
liftedEventRef.current = null;
|
|
2300
2584
|
setLiftedEvent(null);
|
|
2301
|
-
setEdgePagingLock(false);
|
|
2302
2585
|
}, [ghostVisible]);
|
|
2303
2586
|
const commitLiftedDrop = useCallback(
|
|
2304
2587
|
(ghostLocalX: number, ghostLocalY: number) => {
|
|
2305
2588
|
const {
|
|
2306
2589
|
headerDays: days,
|
|
2307
|
-
|
|
2308
|
-
|
|
2590
|
+
columnsWidth: cw,
|
|
2591
|
+
headerOffset: headerH,
|
|
2309
2592
|
minHour: min,
|
|
2310
2593
|
maxHour: max,
|
|
2311
2594
|
snapMinutes: snap,
|
|
@@ -2317,16 +2600,14 @@ function TimeGridInner<T>({
|
|
|
2317
2600
|
clearLift();
|
|
2318
2601
|
if (!ev || !onDrag || days.length === 0) return;
|
|
2319
2602
|
// Map the ghost's drawn position on the page it landed on back to a cell:
|
|
2320
|
-
// its left edge picks the day column, its top edge picks the time.
|
|
2321
|
-
//
|
|
2322
|
-
//
|
|
2323
|
-
|
|
2324
|
-
const
|
|
2325
|
-
|
|
2326
|
-
days.length - 1,
|
|
2327
|
-
);
|
|
2603
|
+
// its left edge picks the day column, its top edge picks the time. Both are
|
|
2604
|
+
// pager-local, and the pager is the scrolling content itself, so the top
|
|
2605
|
+
// edge only needs the page's all-day band and label inset taken off before
|
|
2606
|
+
// the live row height (pinch) converts it to hours.
|
|
2607
|
+
const dayWidth = cw / days.length;
|
|
2608
|
+
const col = Math.min(Math.max(Math.floor(ghostLocalX / dayWidth), 0), days.length - 1);
|
|
2328
2609
|
const hoursFromMin =
|
|
2329
|
-
(ghostLocalY -
|
|
2610
|
+
(ghostLocalY - headerH - laneHeight.value - HOUR_LABEL_TOP_INSET) / cellHeight.value;
|
|
2330
2611
|
const rawMinutes = (min + hoursFromMin) * MINUTES_PER_HOUR;
|
|
2331
2612
|
// Same rule as an in-page move: the start stays in the day it landed on,
|
|
2332
2613
|
// while the duration is free to carry the end past midnight.
|
|
@@ -2340,21 +2621,13 @@ function TimeGridInner<T>({
|
|
|
2340
2621
|
// reads as a visible snap-back instead of the event seeming to vanish.
|
|
2341
2622
|
if (onDrag(ev, start, end) === false) onDate(ev.start);
|
|
2342
2623
|
},
|
|
2343
|
-
[clearLift,
|
|
2344
|
-
);
|
|
2345
|
-
const handleGridTop = useCallback(
|
|
2346
|
-
(y: number) => {
|
|
2347
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2348
|
-
gridTop.value = y;
|
|
2349
|
-
},
|
|
2350
|
-
[gridTop],
|
|
2624
|
+
[clearLift, cellHeight, laneHeight],
|
|
2351
2625
|
);
|
|
2352
2626
|
const edgePaging = useMemo<EdgePaging>(
|
|
2353
2627
|
() => ({
|
|
2354
2628
|
pagerLeft,
|
|
2355
2629
|
pagerTop,
|
|
2356
2630
|
pagerWidth,
|
|
2357
|
-
lockScroll: setEdgePagingLock,
|
|
2358
2631
|
ghostX,
|
|
2359
2632
|
ghostY,
|
|
2360
2633
|
ghostW,
|
|
@@ -2376,18 +2649,81 @@ function TimeGridInner<T>({
|
|
|
2376
2649
|
commitLiftedDrop,
|
|
2377
2650
|
],
|
|
2378
2651
|
);
|
|
2379
|
-
// Plain mirror of the last settled vertical offset. A page that mounts after a
|
|
2380
|
-
// scroll seeds its contentOffset here instead of the default, so it appears at the
|
|
2381
|
-
// saved time straight away rather than rendering at the default and snapping (the
|
|
2382
|
-
// one-frame flash). Null until the first scroll, when `seedDefaultY` is used.
|
|
2383
|
-
const offsetSeedRef = useRef<number | null>(null);
|
|
2384
|
-
const captureOffsetSeed = useCallback((y: number) => {
|
|
2385
|
-
offsetSeedRef.current = y;
|
|
2386
|
-
}, []);
|
|
2387
2652
|
// Zoom committed at the end of the last pinch; off-screen pages animate off
|
|
2388
2653
|
// this so they don't re-run their worklets every frame while the visible page
|
|
2389
2654
|
// zooms.
|
|
2390
2655
|
const committedCellHeight = useSharedValue(hourHeight);
|
|
2656
|
+
// Outside a pinch, any other writer of `cellHeight` (a consumer-owned shared
|
|
2657
|
+
// value, the web wheel zoom) commits at once, so the hour column and the
|
|
2658
|
+
// off-screen pages never disagree with the visible page.
|
|
2659
|
+
const pinching = useSharedValue(false);
|
|
2660
|
+
useAnimatedReaction(
|
|
2661
|
+
() => cellHeight.value,
|
|
2662
|
+
(value) => {
|
|
2663
|
+
if (!pinching.value) committedCellHeight.value = value;
|
|
2664
|
+
},
|
|
2665
|
+
);
|
|
2666
|
+
|
|
2667
|
+
// Capture the row height when the pinch starts and apply `event.scale`
|
|
2668
|
+
// (relative to that start) rather than multiplying per-frame deltas — deltas
|
|
2669
|
+
// compound float error and the zoom never settles on a clean level.
|
|
2670
|
+
const pinchStartCellHeight = useSharedValue(hourHeight);
|
|
2671
|
+
const zoomGesture = useMemo(() => {
|
|
2672
|
+
const pinch = Gesture.Pinch()
|
|
2673
|
+
.onStart(() => {
|
|
2674
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2675
|
+
pinching.value = true;
|
|
2676
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2677
|
+
pinchStartCellHeight.value = cellHeight.value;
|
|
2678
|
+
})
|
|
2679
|
+
.onUpdate((event) => {
|
|
2680
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2681
|
+
cellHeight.value = Math.min(
|
|
2682
|
+
maxHourHeight,
|
|
2683
|
+
Math.max(minHourHeight, pinchStartCellHeight.value * event.scale),
|
|
2684
|
+
);
|
|
2685
|
+
})
|
|
2686
|
+
// Finalize (not end) so a cancelled pinch still commits and reopens the
|
|
2687
|
+
// reaction above.
|
|
2688
|
+
.onFinalize(() => {
|
|
2689
|
+
// Publish the final zoom to the off-screen pages in one update.
|
|
2690
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2691
|
+
pinching.value = false;
|
|
2692
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2693
|
+
committedCellHeight.value = cellHeight.value;
|
|
2694
|
+
});
|
|
2695
|
+
// Recognise the pinch and the scroll view's native scroll together so the
|
|
2696
|
+
// scroll never cancels an in-progress zoom.
|
|
2697
|
+
return Gesture.Simultaneous(pinch, Gesture.Native());
|
|
2698
|
+
}, [
|
|
2699
|
+
cellHeight,
|
|
2700
|
+
committedCellHeight,
|
|
2701
|
+
pinching,
|
|
2702
|
+
pinchStartCellHeight,
|
|
2703
|
+
minHourHeight,
|
|
2704
|
+
maxHourHeight,
|
|
2705
|
+
]);
|
|
2706
|
+
// The pager and its pages keep one fixed height, big enough for the fully
|
|
2707
|
+
// zoomed hour window plus the tallest lane, so the list and its item
|
|
2708
|
+
// containers (which report every layout to JS) never re-lay out while the
|
|
2709
|
+
// band or the zoom animate. Only the scroll content's own height is live.
|
|
2710
|
+
const pagerHeight =
|
|
2711
|
+
headerOffset +
|
|
2712
|
+
HOUR_LABEL_TOP_INSET +
|
|
2713
|
+
(clampedMaxHour - clampedMinHour) * maxHourHeight +
|
|
2714
|
+
tallestLane;
|
|
2715
|
+
// Height of the scroll content (the hour column and every page): the all-day
|
|
2716
|
+
// band, the label inset, then the hours, live with the pinch and the swipe.
|
|
2717
|
+
const gridHeightStyle = useAnimatedStyle(
|
|
2718
|
+
() => ({
|
|
2719
|
+
height:
|
|
2720
|
+
headerOffset +
|
|
2721
|
+
laneHeight.value +
|
|
2722
|
+
HOUR_LABEL_TOP_INSET +
|
|
2723
|
+
(clampedMaxHour - clampedMinHour) * cellHeight.value,
|
|
2724
|
+
}),
|
|
2725
|
+
[clampedMinHour, clampedMaxHour, headerOffset],
|
|
2726
|
+
);
|
|
2391
2727
|
|
|
2392
2728
|
// Web stand-in for pinch: Ctrl/Cmd + scroll zooms the grid via the same shared
|
|
2393
2729
|
// values the pinch gesture drives.
|
|
@@ -2427,6 +2763,10 @@ function TimeGridInner<T>({
|
|
|
2427
2763
|
// The committed date's page is the centred/active one. `viewedIndexRef` tracks
|
|
2428
2764
|
// where the list actually sits, telling swipe-driven changes from external ones.
|
|
2429
2765
|
const activeIndex = indexOfDate(date);
|
|
2766
|
+
useEffect(() => {
|
|
2767
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2768
|
+
activeIndexShared.value = activeIndex;
|
|
2769
|
+
}, [activeIndex, activeIndexShared]);
|
|
2430
2770
|
const viewedIndexRef = useRef(activeIndex);
|
|
2431
2771
|
// While a programmatic scroll (a "today" button, prev/next, or any date set from
|
|
2432
2772
|
// outside) is settling, this holds its target index. Viewability ticks for the
|
|
@@ -2434,6 +2774,37 @@ function TimeGridInner<T>({
|
|
|
2434
2774
|
// a page in between back as the new date — which made jumps land one page short.
|
|
2435
2775
|
const pendingScrollIndexRef = useRef<number | null>(null);
|
|
2436
2776
|
|
|
2777
|
+
// ISO week label for the hour column's corner (the visible page's Thursday
|
|
2778
|
+
// defines the week). Null unless the header is paged and week numbers are on.
|
|
2779
|
+
const weekNumber = useMemo(() => {
|
|
2780
|
+
if (!pagedHeader || !showWeekNumber || hourColumnWidth === 0) return null;
|
|
2781
|
+
const days = getViewDays(
|
|
2782
|
+
mode,
|
|
2783
|
+
pageDates[activeIndex] ?? date,
|
|
2784
|
+
weekStartsOn,
|
|
2785
|
+
numberOfDays,
|
|
2786
|
+
isRTL,
|
|
2787
|
+
weekEndsOn,
|
|
2788
|
+
hiddenDays,
|
|
2789
|
+
);
|
|
2790
|
+
const thursday = days.find((d) => d.getDay() === 4) ?? days[0];
|
|
2791
|
+
return thursday ? `${weekNumberPrefix}${getISOWeek(thursday)}` : null;
|
|
2792
|
+
}, [
|
|
2793
|
+
pagedHeader,
|
|
2794
|
+
showWeekNumber,
|
|
2795
|
+
hourColumnWidth,
|
|
2796
|
+
mode,
|
|
2797
|
+
pageDates,
|
|
2798
|
+
activeIndex,
|
|
2799
|
+
date,
|
|
2800
|
+
weekStartsOn,
|
|
2801
|
+
numberOfDays,
|
|
2802
|
+
isRTL,
|
|
2803
|
+
weekEndsOn,
|
|
2804
|
+
hiddenDays,
|
|
2805
|
+
weekNumberPrefix,
|
|
2806
|
+
]);
|
|
2807
|
+
|
|
2437
2808
|
// Header days track the active page (page-aligned), so they always match the
|
|
2438
2809
|
// columns below and a swipe never flashes another day's label.
|
|
2439
2810
|
const headerDays = useMemo(
|
|
@@ -2454,8 +2825,8 @@ function TimeGridInner<T>({
|
|
|
2454
2825
|
// identity-stable EdgePaging callbacks (see dropRef).
|
|
2455
2826
|
dropRef.current = {
|
|
2456
2827
|
headerDays,
|
|
2457
|
-
|
|
2458
|
-
|
|
2828
|
+
columnsWidth,
|
|
2829
|
+
headerOffset,
|
|
2459
2830
|
minHour: clampedMinHour,
|
|
2460
2831
|
maxHour: clampedMaxHour,
|
|
2461
2832
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
@@ -2494,73 +2865,35 @@ function TimeGridInner<T>({
|
|
|
2494
2865
|
if (activeIndex === viewedIndexRef.current) return;
|
|
2495
2866
|
viewedIndexRef.current = activeIndex;
|
|
2496
2867
|
pendingScrollIndexRef.current = activeIndex;
|
|
2868
|
+
// Keep the all-day band's interpolation source in step with the jump; the
|
|
2869
|
+
// list reports its offset only as it scrolls, not on a programmatic one.
|
|
2870
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2871
|
+
pagerOffset.value = activeIndex * columnsWidth;
|
|
2497
2872
|
void listRef.current?.scrollToIndex({ index: activeIndex, animated: false });
|
|
2873
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- columnsWidth/pagerOffset are stable per width
|
|
2498
2874
|
}, [activeIndex]);
|
|
2499
2875
|
|
|
2500
|
-
//
|
|
2501
|
-
//
|
|
2502
|
-
// page settles, restore the shared offset directly on the visible page's scroll
|
|
2503
|
-
// node — the one lever that reliably works on the web. Deferred a frame (twice,
|
|
2504
|
-
// for safety) so the paged-in grid has laid out before we scroll it.
|
|
2876
|
+
// The list reports its offset only as it scrolls; seed it whenever the list is
|
|
2877
|
+
// (re)laid out at a new width, where it opens on the active page.
|
|
2505
2878
|
useEffect(() => {
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
const scrollable =
|
|
2514
|
-
(style.overflowY === "scroll" || style.overflowY === "auto") &&
|
|
2515
|
-
el.scrollHeight > el.clientHeight + 20 &&
|
|
2516
|
-
el.clientHeight > 100;
|
|
2517
|
-
if (!scrollable) continue;
|
|
2518
|
-
const rect = el.getBoundingClientRect();
|
|
2519
|
-
if (rect.left > -50 && rect.right <= vw + 50) {
|
|
2520
|
-
el.scrollTop = scrollY.value;
|
|
2521
|
-
break;
|
|
2522
|
-
}
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
// Don't capture the scroll events this transition emits (recycle-reset, restore).
|
|
2526
|
-
suppressCaptureUntilRef.current = Date.now() + 400;
|
|
2527
|
-
let raf2 = 0;
|
|
2528
|
-
const raf1 = requestAnimationFrame(() => {
|
|
2529
|
-
restoreVisiblePage();
|
|
2530
|
-
raf2 = requestAnimationFrame(restoreVisiblePage);
|
|
2531
|
-
});
|
|
2532
|
-
return () => {
|
|
2533
|
-
cancelAnimationFrame(raf1);
|
|
2534
|
-
cancelAnimationFrame(raf2);
|
|
2535
|
-
};
|
|
2536
|
-
// `pageHeight` is included so this also runs once the pager measures its real
|
|
2537
|
-
// height on first open (the mount pass runs before the pages have laid out).
|
|
2538
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- containerRef/scrollY are stable
|
|
2539
|
-
}, [activeIndex, pageHeight]);
|
|
2540
|
-
|
|
2541
|
-
// Web: record the on-screen page's scroll into the shared offset on genuine user
|
|
2542
|
-
// scrolls, so switching pages preserves the position. Programmatic scrolls (the
|
|
2543
|
-
// recycle-reset and the restore above) are skipped via the suppression window, so
|
|
2544
|
-
// they can't clobber it. Scoped to the visible page so off-screen sync is ignored.
|
|
2879
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2880
|
+
pagerOffset.value = activeIndex * columnsWidth;
|
|
2881
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- reseed on width only; scroll events track index changes
|
|
2882
|
+
}, [columnsWidth, pagerOffset]);
|
|
2883
|
+
|
|
2884
|
+
// react-native-web ignores `contentOffset`: retry the seed each frame until the
|
|
2885
|
+
// scroll view can hold it (the viewport's `onLayout` also tries).
|
|
2545
2886
|
useEffect(() => {
|
|
2546
2887
|
if (!isWeb) return;
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
const
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
if (!el || typeof el.scrollTop !== "number" || el.clientHeight <= 100) return;
|
|
2553
|
-
const rect = el.getBoundingClientRect();
|
|
2554
|
-
const vw = (root.ownerDocument?.defaultView ?? globalThis).innerWidth;
|
|
2555
|
-
if (rect.left <= -50 || rect.right > vw + 50) return;
|
|
2556
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2557
|
-
scrollY.value = el.scrollTop;
|
|
2558
|
-
offsetSeedRef.current = el.scrollTop;
|
|
2888
|
+
let attempts = 0;
|
|
2889
|
+
let frame = 0;
|
|
2890
|
+
const attempt = () => {
|
|
2891
|
+
seedWebScroll();
|
|
2892
|
+
if (!webSeededRef.current && attempts++ < 120) frame = requestAnimationFrame(attempt);
|
|
2559
2893
|
};
|
|
2560
|
-
|
|
2561
|
-
return () =>
|
|
2562
|
-
|
|
2563
|
-
}, []);
|
|
2894
|
+
frame = requestAnimationFrame(attempt);
|
|
2895
|
+
return () => cancelAnimationFrame(frame);
|
|
2896
|
+
}, [seedWebScroll]);
|
|
2564
2897
|
|
|
2565
2898
|
// Web: LegendList's horizontal scroll container is `overflow-x: auto`, so a
|
|
2566
2899
|
// trackpad swipe or horizontal wheel would scroll between pages. Paging should be
|
|
@@ -2583,23 +2916,65 @@ function TimeGridInner<T>({
|
|
|
2583
2916
|
};
|
|
2584
2917
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
2585
2918
|
return () => cancelAnimationFrame(raf);
|
|
2919
|
+
// Re-run once the list exists at its real size (it remounts per width).
|
|
2586
2920
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- containerRef is stable
|
|
2587
|
-
}, [
|
|
2921
|
+
}, [columnsWidth]);
|
|
2922
|
+
|
|
2923
|
+
// Honour the OS "reduce motion" setting: the pager's animated transitions
|
|
2924
|
+
// (paging from an edge drag, the snap-back after a cell press) become instant
|
|
2925
|
+
// jumps when it's on.
|
|
2926
|
+
const reduceMotion = useReducedMotion();
|
|
2588
2927
|
|
|
2589
|
-
//
|
|
2590
|
-
// the
|
|
2928
|
+
// Page by `delta` (edge drags, web arrow keys): move the list at once and
|
|
2929
|
+
// report the date, rather than waiting for the reported date to come back
|
|
2930
|
+
// through props. The realign effect then finds the list already there.
|
|
2591
2931
|
const goToPage = useCallback(
|
|
2592
2932
|
(delta: number) => {
|
|
2593
|
-
const
|
|
2594
|
-
|
|
2933
|
+
const index = viewedIndexRef.current + delta;
|
|
2934
|
+
const target = pageDates[index];
|
|
2935
|
+
if (!target) return;
|
|
2936
|
+
viewedIndexRef.current = index;
|
|
2937
|
+
pendingScrollIndexRef.current = index;
|
|
2938
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2939
|
+
pagerOffset.value = index * columnsWidth;
|
|
2940
|
+
void listRef.current?.scrollToIndex({ index, animated: !isWeb && !reduceMotion });
|
|
2941
|
+
onChangeDate(target);
|
|
2595
2942
|
},
|
|
2596
|
-
[pageDates,
|
|
2943
|
+
[pageDates, reduceMotion, onChangeDate, columnsWidth, pagerOffset],
|
|
2597
2944
|
);
|
|
2598
2945
|
useWebPagerKeys(swipeEnabled, goToPage);
|
|
2599
2946
|
|
|
2600
|
-
//
|
|
2601
|
-
//
|
|
2602
|
-
|
|
2947
|
+
// A fast fling can outrun the list's on-demand mounting and leave the pager
|
|
2948
|
+
// blank until something nudges it. When momentum ends, re-anchor the list on
|
|
2949
|
+
// the page the offset landed on: `scrollToIndex` forces it to recompute its
|
|
2950
|
+
// container positions and repaint, which a plain React re-render (from the
|
|
2951
|
+
// date change) does not. The index comes from the settled offset, not the
|
|
2952
|
+
// viewability ref, so it is right regardless of which fires first.
|
|
2953
|
+
const handlePagerSettled = useCallback(
|
|
2954
|
+
(event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
2955
|
+
if (columnsWidth <= 0) return;
|
|
2956
|
+
// Only a user fling can leave the pager blank; a programmatic scroll
|
|
2957
|
+
// (goToPage, realign) sets `pendingScrollIndexRef` and repaints itself, so
|
|
2958
|
+
// skip those to avoid a redundant re-anchor during held edge paging.
|
|
2959
|
+
if (pendingScrollIndexRef.current != null) return;
|
|
2960
|
+
const raw = Math.round(event.nativeEvent.contentOffset.x / columnsWidth);
|
|
2961
|
+
const index = Math.min(Math.max(raw, 0), pageDates.length - 1);
|
|
2962
|
+
// Commit the page the pager snaps to. Viewability only reports a page that
|
|
2963
|
+
// is nearly all on screen, so a fling that rests between pages would
|
|
2964
|
+
// otherwise move the grid without moving the date behind the header.
|
|
2965
|
+
if (index !== viewedIndexRef.current) {
|
|
2966
|
+
viewedIndexRef.current = index;
|
|
2967
|
+
const target = pageDates[index];
|
|
2968
|
+
if (target) onChangeDate(target);
|
|
2969
|
+
}
|
|
2970
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2971
|
+
pagerOffset.value = index * columnsWidth;
|
|
2972
|
+
requestAnimationFrame(() => {
|
|
2973
|
+
void listRef.current?.scrollToIndex({ index, animated: false });
|
|
2974
|
+
});
|
|
2975
|
+
},
|
|
2976
|
+
[columnsWidth, pageDates, onChangeDate, pagerOffset],
|
|
2977
|
+
);
|
|
2603
2978
|
|
|
2604
2979
|
// Optionally snap the pager back to the active page after an empty-cell press
|
|
2605
2980
|
// (so tapping a far-swiped page returns to the committed date).
|
|
@@ -2614,96 +2989,93 @@ function TimeGridInner<T>({
|
|
|
2614
2989
|
|
|
2615
2990
|
const snapToIndices = useMemo(() => pageDates.map((_, index) => index), [pageDates]);
|
|
2616
2991
|
const keyExtractorList = useCallback((item: Date) => item.toISOString(), []);
|
|
2617
|
-
const getFixedItemSize = useCallback(() =>
|
|
2992
|
+
const getFixedItemSize = useCallback(() => columnsWidth, [columnsWidth]);
|
|
2618
2993
|
const renderItem = useCallback(
|
|
2619
2994
|
({ item, index }: LegendListRenderItemProps<Date>) => (
|
|
2620
|
-
<
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
/>
|
|
2674
|
-
</View>
|
|
2995
|
+
<TimetablePage
|
|
2996
|
+
mode={mode}
|
|
2997
|
+
numberOfDays={numberOfDays}
|
|
2998
|
+
hiddenDays={hiddenDays}
|
|
2999
|
+
now={now}
|
|
3000
|
+
nowTimeZone={timeZone}
|
|
3001
|
+
date={item}
|
|
3002
|
+
width={columnsWidth}
|
|
3003
|
+
events={events}
|
|
3004
|
+
cellHeight={cellHeight}
|
|
3005
|
+
committedCellHeight={committedCellHeight}
|
|
3006
|
+
isActive={index === activeIndex}
|
|
3007
|
+
weekStartsOn={weekStartsOn}
|
|
3008
|
+
weekEndsOn={weekEndsOn}
|
|
3009
|
+
minHour={clampedMinHour}
|
|
3010
|
+
maxHour={clampedMaxHour}
|
|
3011
|
+
timeslots={timeslots}
|
|
3012
|
+
isRTL={isRTL}
|
|
3013
|
+
highlightWeekends={highlightWeekends}
|
|
3014
|
+
calendarCellStyle={calendarCellStyle}
|
|
3015
|
+
businessHours={businessHours}
|
|
3016
|
+
renderBusinessHours={renderBusinessHours}
|
|
3017
|
+
renderBackgroundEvent={renderBackgroundEvent}
|
|
3018
|
+
showNowIndicator={showNowIndicator}
|
|
3019
|
+
renderEvent={labeledRenderEvent}
|
|
3020
|
+
keyExtractor={keyExtractor}
|
|
3021
|
+
snapMinutes={Math.max(1, dragStepMinutes)}
|
|
3022
|
+
minEventHeight={minEventHeight}
|
|
3023
|
+
eventGap={eventGap}
|
|
3024
|
+
showDragHandle={showDragHandle}
|
|
3025
|
+
eventStartEditable={eventStartEditable}
|
|
3026
|
+
eventDurationEditable={eventDurationEditable}
|
|
3027
|
+
onPressEvent={onPressEvent}
|
|
3028
|
+
onLongPressEvent={onLongPressEvent}
|
|
3029
|
+
onDragEvent={onDragEvent}
|
|
3030
|
+
onDragStart={onDragStart}
|
|
3031
|
+
onPressCell={handlePressCell}
|
|
3032
|
+
onLongPressCell={onLongPressCell}
|
|
3033
|
+
onCreateEvent={onCreateEvent}
|
|
3034
|
+
onEdgeAdvance={goToPage}
|
|
3035
|
+
pageIndex={index}
|
|
3036
|
+
laneHeight={laneHeight}
|
|
3037
|
+
scrollY={scrollY}
|
|
3038
|
+
showAllDayEventCell={showAllDayEventCell}
|
|
3039
|
+
onLaneLayout={reportLaneHeight}
|
|
3040
|
+
height={pagerHeight}
|
|
3041
|
+
pagedHeader={pagedHeader}
|
|
3042
|
+
weekdayFormat={weekdayFormat}
|
|
3043
|
+
todayLabel={todayLabel}
|
|
3044
|
+
locale={locale}
|
|
3045
|
+
activeDate={activeDate}
|
|
3046
|
+
onPressDateHeader={onPressDateHeader}
|
|
3047
|
+
/>
|
|
2675
3048
|
),
|
|
2676
3049
|
[
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
3050
|
+
columnsWidth,
|
|
3051
|
+
pagerHeight,
|
|
3052
|
+
pagedHeader,
|
|
3053
|
+
weekdayFormat,
|
|
3054
|
+
todayLabel,
|
|
3055
|
+
locale,
|
|
3056
|
+
activeDate,
|
|
3057
|
+
onPressDateHeader,
|
|
3058
|
+
laneHeight,
|
|
3059
|
+
scrollY,
|
|
3060
|
+
showAllDayEventCell,
|
|
3061
|
+
reportLaneHeight,
|
|
2680
3062
|
mode,
|
|
2681
3063
|
numberOfDays,
|
|
2682
3064
|
events,
|
|
2683
3065
|
cellHeight,
|
|
2684
|
-
hourHeight,
|
|
2685
3066
|
committedCellHeight,
|
|
2686
|
-
scrollY,
|
|
2687
3067
|
activeIndex,
|
|
2688
|
-
seedDefaultY,
|
|
2689
|
-
captureOffsetSeed,
|
|
2690
3068
|
weekStartsOn,
|
|
2691
3069
|
weekEndsOn,
|
|
2692
|
-
hourColumnWidth,
|
|
2693
3070
|
clampedMinHour,
|
|
2694
3071
|
clampedMaxHour,
|
|
2695
|
-
ampm,
|
|
2696
3072
|
timeslots,
|
|
2697
3073
|
isRTL,
|
|
2698
|
-
showAllDayEventCell,
|
|
2699
3074
|
highlightWeekends,
|
|
2700
|
-
showVerticalScrollIndicator,
|
|
2701
|
-
verticalScrollEnabled,
|
|
2702
|
-
hourComponent,
|
|
2703
3075
|
calendarCellStyle,
|
|
2704
3076
|
businessHours,
|
|
2705
|
-
|
|
2706
|
-
|
|
3077
|
+
renderBusinessHours,
|
|
3078
|
+
renderBackgroundEvent,
|
|
2707
3079
|
showNowIndicator,
|
|
2708
3080
|
labeledRenderEvent,
|
|
2709
3081
|
keyExtractor,
|
|
@@ -2731,101 +3103,158 @@ function TimeGridInner<T>({
|
|
|
2731
3103
|
// and only re-renders them when `data` or `extraData` changes. Feed both `events`
|
|
2732
3104
|
// (so a moved event repaints in place) and `activeIndex` (so each page's
|
|
2733
3105
|
// `isActive` updates as you swipe). Without `activeIndex`, a page that pages in
|
|
2734
|
-
// never learns it became active
|
|
2735
|
-
|
|
3106
|
+
// never learns it became active, so its zoom source and now line would lag.
|
|
3107
|
+
// `columnsWidth` resizes the mounted pages when the grid is re-measured.
|
|
3108
|
+
const listExtraData = useMemo(
|
|
3109
|
+
() => ({ events, activeIndex, columnsWidth }),
|
|
3110
|
+
[events, activeIndex, columnsWidth],
|
|
3111
|
+
);
|
|
2736
3112
|
|
|
2737
3113
|
return (
|
|
2738
3114
|
<SlotStylesProvider classNames={classNames} styles={styleOverrides}>
|
|
2739
|
-
<
|
|
2740
|
-
<
|
|
2741
|
-
{renderHeader ? (
|
|
2742
|
-
renderHeader(headerDays)
|
|
2743
|
-
) : (
|
|
2744
|
-
<DefaultHeader
|
|
2745
|
-
days={headerDays}
|
|
2746
|
-
mode={mode}
|
|
2747
|
-
width={containerWidth}
|
|
2748
|
-
hourColumnWidth={hourColumnWidth}
|
|
2749
|
-
showWeekNumber={showWeekNumber}
|
|
2750
|
-
weekNumberPrefix={weekNumberPrefix}
|
|
2751
|
-
weekdayFormat={weekdayFormat}
|
|
2752
|
-
locale={locale}
|
|
2753
|
-
activeDate={activeDate}
|
|
2754
|
-
onPressDateHeader={onPressDateHeader}
|
|
2755
|
-
/>
|
|
2756
|
-
)}
|
|
2757
|
-
|
|
2758
|
-
{headerComponent}
|
|
2759
|
-
|
|
3115
|
+
<CalendarLabelsContext.Provider value={labels}>
|
|
3116
|
+
<EdgePagingContext.Provider value={edgePaging}>
|
|
2760
3117
|
<View
|
|
2761
|
-
ref={
|
|
2762
|
-
style={styles.
|
|
2763
|
-
onLayout={(event) =>
|
|
2764
|
-
setPageHeight(event.nativeEvent.layout.height);
|
|
2765
|
-
setContainerWidth(event.nativeEvent.layout.width);
|
|
2766
|
-
setMeasured(true);
|
|
2767
|
-
// Record the pager's window-space frame for the drag worklets' edge
|
|
2768
|
-
// detection and ghost placement (layout gives parent-relative coords,
|
|
2769
|
-
// not window).
|
|
2770
|
-
pagerRef.current?.measureInWindow((x, y, w) => {
|
|
2771
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2772
|
-
pagerLeft.value = x;
|
|
2773
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2774
|
-
pagerTop.value = y;
|
|
2775
|
-
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
2776
|
-
pagerWidth.value = w;
|
|
2777
|
-
});
|
|
2778
|
-
}}
|
|
3118
|
+
ref={containerRef}
|
|
3119
|
+
style={styles.container}
|
|
3120
|
+
onLayout={(event) => setContainerWidth(event.nativeEvent.layout.width)}
|
|
2779
3121
|
>
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
ref={
|
|
2786
|
-
style={
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
3122
|
+
{renderHeader ? renderHeader(headerDays) : null}
|
|
3123
|
+
|
|
3124
|
+
{headerComponent}
|
|
3125
|
+
|
|
3126
|
+
<View
|
|
3127
|
+
ref={viewportRef}
|
|
3128
|
+
style={styles.viewport}
|
|
3129
|
+
onLayout={() => {
|
|
3130
|
+
seedWebScroll();
|
|
3131
|
+
// Window-space top of the scroll viewport, for the drag worklets'
|
|
3132
|
+
// ghost placement (layout gives parent-relative coords, not window).
|
|
3133
|
+
viewportRef.current?.measureInWindow((_x, y) => {
|
|
3134
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
3135
|
+
viewportTop.value = y;
|
|
3136
|
+
});
|
|
3137
|
+
}}
|
|
3138
|
+
>
|
|
3139
|
+
<GestureDetector gesture={zoomGesture}>
|
|
3140
|
+
<Animated.ScrollView
|
|
3141
|
+
ref={scrollRef}
|
|
3142
|
+
showsVerticalScrollIndicator={showVerticalScrollIndicator}
|
|
3143
|
+
scrollEnabled={verticalScrollEnabled}
|
|
3144
|
+
onScroll={scrollHandler}
|
|
3145
|
+
scrollEventThrottle={16}
|
|
3146
|
+
refreshControl={verticalScrollEnabled ? refreshControl : undefined}
|
|
3147
|
+
contentOffset={{ x: 0, y: seedDefaultY }}
|
|
3148
|
+
>
|
|
3149
|
+
<Animated.View testID="time-grid-hours" style={[styles.gridRow, gridHeightStyle]}>
|
|
3150
|
+
{hourColumnWidth > 0 ? (
|
|
3151
|
+
<HourGutter
|
|
3152
|
+
width={hourColumnWidth}
|
|
3153
|
+
minHour={clampedMinHour}
|
|
3154
|
+
maxHour={clampedMaxHour}
|
|
3155
|
+
cellHeight={cellHeight}
|
|
3156
|
+
laneHeight={laneHeight}
|
|
3157
|
+
scrollY={scrollY}
|
|
3158
|
+
showLane={showAllDayEventCell}
|
|
3159
|
+
showAllDayLabel={showAllDayLabel}
|
|
3160
|
+
allDayLabel={labels.allDay}
|
|
3161
|
+
headerHeight={headerOffset}
|
|
3162
|
+
weekNumber={weekNumber}
|
|
3163
|
+
ampm={ampm}
|
|
3164
|
+
hourComponent={hourComponent}
|
|
3165
|
+
/>
|
|
3166
|
+
) : null}
|
|
3167
|
+
<View
|
|
3168
|
+
ref={pagerRef}
|
|
3169
|
+
testID="time-grid-pager"
|
|
3170
|
+
style={[styles.pager, { left: hourColumnWidth, height: pagerHeight }]}
|
|
3171
|
+
onLayout={(event) => {
|
|
3172
|
+
// Window-space frame of the pager for the drag worklets' edge
|
|
3173
|
+
// detection and ghost placement. Only a width change matters
|
|
3174
|
+
// (the grid's or the hour column's); the zoom changes the
|
|
3175
|
+
// height every frame, so those layouts are skipped.
|
|
3176
|
+
const laidOutWidth = event.nativeEvent.layout.width;
|
|
3177
|
+
if (laidOutWidth === pagerLayoutWidthRef.current) return;
|
|
3178
|
+
pagerLayoutWidthRef.current = laidOutWidth;
|
|
3179
|
+
setPagerLayoutWidth(laidOutWidth);
|
|
3180
|
+
pagerRef.current?.measureInWindow((x, _y, measuredWidth) => {
|
|
3181
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
3182
|
+
pagerLeft.value = x;
|
|
3183
|
+
// eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
|
|
3184
|
+
pagerWidth.value = measuredWidth;
|
|
3185
|
+
});
|
|
3186
|
+
}}
|
|
3187
|
+
>
|
|
3188
|
+
{pagerReady ? (
|
|
3189
|
+
<AnimatedLegendList
|
|
3190
|
+
// Mounts once the pager has measured, so the fixed item size is
|
|
3191
|
+
// right from the list's first layout; the key remounts it on a
|
|
3192
|
+
// later width change (a rotation, a re-measured container).
|
|
3193
|
+
key={`grid-${columnsWidth}`}
|
|
3194
|
+
ref={listRef}
|
|
3195
|
+
style={isWeb ? [styles.pagerList, styles.webNoScroll] : styles.pagerList}
|
|
3196
|
+
data={pageDates}
|
|
3197
|
+
extraData={listExtraData}
|
|
3198
|
+
horizontal
|
|
3199
|
+
recycleItems={false}
|
|
3200
|
+
keyExtractor={keyExtractorList}
|
|
3201
|
+
getFixedItemSize={getFixedItemSize}
|
|
3202
|
+
// Mount the next pages either side while idle, not mid-swipe.
|
|
3203
|
+
drawDistance={columnsWidth * 2}
|
|
3204
|
+
// The live horizontal offset, kept on the UI thread, drives the
|
|
3205
|
+
// all-day band's height.
|
|
3206
|
+
sharedValues={pagerSharedValues}
|
|
3207
|
+
// On web LegendList ignores these RN scroll props (it leaks them to the
|
|
3208
|
+
// DOM as unknown attributes), so omit them there and disable horizontal
|
|
3209
|
+
// scroll via `webNoScroll`; paging is driven by the arrow keys instead.
|
|
3210
|
+
// Native: paging makes each swipe hard-stop at the adjacent page, while
|
|
3211
|
+
// `freeSwipe` lets momentum carry across pages and snap to a boundary.
|
|
3212
|
+
{...(isWeb
|
|
3213
|
+
? null
|
|
3214
|
+
: {
|
|
3215
|
+
scrollEnabled: swipeEnabled,
|
|
3216
|
+
pagingEnabled: !freeSwipe,
|
|
3217
|
+
snapToIndices: freeSwipe ? snapToIndices : undefined,
|
|
3218
|
+
// Paging: snap to the adjacent page quickly instead of the
|
|
3219
|
+
// slow platform glide, and stop at that page rather than
|
|
3220
|
+
// drifting, so rapid one-week swipes land crisply instead of
|
|
3221
|
+
// queuing a long chain of drawn-out snaps. `freeSwipe` keeps
|
|
3222
|
+
// its momentum, so it can still fling across several pages.
|
|
3223
|
+
decelerationRate: freeSwipe
|
|
3224
|
+
? ("normal" as const)
|
|
3225
|
+
: ("fast" as const),
|
|
3226
|
+
disableIntervalMomentum: !freeSwipe,
|
|
3227
|
+
scrollEventThrottle: 16,
|
|
3228
|
+
onMomentumScrollEnd: handlePagerSettled,
|
|
3229
|
+
})}
|
|
3230
|
+
initialScrollIndex={activeIndex}
|
|
3231
|
+
showsHorizontalScrollIndicator={false}
|
|
3232
|
+
viewabilityConfig={PAGE_VIEWABILITY}
|
|
3233
|
+
onViewableItemsChanged={handleViewableItemsChanged}
|
|
3234
|
+
renderItem={renderItem}
|
|
3235
|
+
/>
|
|
3236
|
+
) : null}
|
|
3237
|
+
{liftedEvent ? (
|
|
3238
|
+
<DragGhost
|
|
3239
|
+
x={ghostX}
|
|
3240
|
+
y={ghostY}
|
|
3241
|
+
w={ghostW}
|
|
3242
|
+
h={ghostH}
|
|
3243
|
+
visible={ghostVisible}
|
|
3244
|
+
event={liftedEvent}
|
|
3245
|
+
mode={mode}
|
|
3246
|
+
renderEvent={labeledRenderEvent}
|
|
3247
|
+
eventGap={eventGap}
|
|
3248
|
+
/>
|
|
3249
|
+
) : null}
|
|
3250
|
+
</View>
|
|
3251
|
+
</Animated.View>
|
|
3252
|
+
</Animated.ScrollView>
|
|
3253
|
+
</GestureDetector>
|
|
3254
|
+
</View>
|
|
2826
3255
|
</View>
|
|
2827
|
-
</
|
|
2828
|
-
</
|
|
3256
|
+
</EdgePagingContext.Provider>
|
|
3257
|
+
</CalendarLabelsContext.Provider>
|
|
2829
3258
|
</SlotStylesProvider>
|
|
2830
3259
|
);
|
|
2831
3260
|
}
|
|
@@ -2851,58 +3280,32 @@ function TimeGridInner<T>({
|
|
|
2851
3280
|
*/
|
|
2852
3281
|
export const TimeGrid = memo(TimeGridInner) as typeof TimeGridInner;
|
|
2853
3282
|
|
|
2854
|
-
type
|
|
3283
|
+
type DayHeaderRowProps = {
|
|
2855
3284
|
days: Date[];
|
|
2856
3285
|
mode: CalendarMode;
|
|
2857
|
-
|
|
2858
|
-
hourColumnWidth: number;
|
|
2859
|
-
showWeekNumber?: boolean;
|
|
2860
|
-
weekNumberPrefix?: string;
|
|
3286
|
+
dayWidth: number;
|
|
2861
3287
|
weekdayFormat?: WeekdayFormat;
|
|
3288
|
+
todayLabel: string;
|
|
2862
3289
|
locale?: Locale;
|
|
2863
3290
|
activeDate?: Date;
|
|
2864
3291
|
onPressDateHeader?: (date: Date) => void;
|
|
2865
3292
|
};
|
|
2866
3293
|
|
|
2867
|
-
|
|
3294
|
+
// The row of weekday/date columns, rendered once per page so it pages with the
|
|
3295
|
+
// grid. The header slot is the wrapper in the page; this fills it.
|
|
3296
|
+
const DayHeaderRow = ({
|
|
2868
3297
|
days,
|
|
2869
3298
|
mode,
|
|
2870
|
-
|
|
2871
|
-
hourColumnWidth,
|
|
2872
|
-
showWeekNumber,
|
|
2873
|
-
weekNumberPrefix = "W",
|
|
3299
|
+
dayWidth,
|
|
2874
3300
|
weekdayFormat,
|
|
3301
|
+
todayLabel,
|
|
2875
3302
|
locale,
|
|
2876
3303
|
activeDate,
|
|
2877
3304
|
onPressDateHeader,
|
|
2878
|
-
}:
|
|
2879
|
-
const theme = useCalendarTheme();
|
|
3305
|
+
}: DayHeaderRowProps) => {
|
|
2880
3306
|
const slot = useSlots<TimeGridSlot>();
|
|
2881
|
-
// Match the grid below: an hour-column spacer, then one column per day.
|
|
2882
|
-
const dayWidth = (width - hourColumnWidth) / days.length;
|
|
2883
|
-
|
|
2884
3307
|
return (
|
|
2885
|
-
<View
|
|
2886
|
-
{...slot("header", {
|
|
2887
|
-
base: styles.headerRow,
|
|
2888
|
-
themed: { borderBottomColor: theme.colors.gridLine },
|
|
2889
|
-
})}
|
|
2890
|
-
>
|
|
2891
|
-
<View style={[styles.weekNumberGutter, { width: hourColumnWidth }]}>
|
|
2892
|
-
{showWeekNumber && hourColumnWidth > 0 && days[0] ? (
|
|
2893
|
-
<Text
|
|
2894
|
-
{...slot<TextStyle>("weekNumber", {
|
|
2895
|
-
themed: [theme.text.hourLabel, { color: theme.colors.textMuted }],
|
|
2896
|
-
})}
|
|
2897
|
-
allowFontScaling={false}
|
|
2898
|
-
>
|
|
2899
|
-
{/* Reference the visible Thursday: an ISO week is defined by its Thursday,
|
|
2900
|
-
so a Sunday-start week still shows the week number its Mon–Sat body
|
|
2901
|
-
belongs to. */}
|
|
2902
|
-
{`${weekNumberPrefix}${getISOWeek(days.find((d) => d.getDay() === 4) ?? days[0])}`}
|
|
2903
|
-
</Text>
|
|
2904
|
-
) : null}
|
|
2905
|
-
</View>
|
|
3308
|
+
<View {...slot("header", { base: styles.headerRow })}>
|
|
2906
3309
|
{days.map((day) => (
|
|
2907
3310
|
<DayHeader
|
|
2908
3311
|
key={day.toISOString()}
|
|
@@ -2910,6 +3313,7 @@ const DefaultHeader = ({
|
|
|
2910
3313
|
mode={mode}
|
|
2911
3314
|
width={dayWidth}
|
|
2912
3315
|
weekdayFormat={weekdayFormat}
|
|
3316
|
+
todayLabel={todayLabel}
|
|
2913
3317
|
locale={locale}
|
|
2914
3318
|
activeDate={activeDate}
|
|
2915
3319
|
onPressDateHeader={onPressDateHeader}
|
|
@@ -2924,6 +3328,7 @@ type DayHeaderProps = {
|
|
|
2924
3328
|
mode: CalendarMode;
|
|
2925
3329
|
width: number;
|
|
2926
3330
|
weekdayFormat?: WeekdayFormat;
|
|
3331
|
+
todayLabel: string;
|
|
2927
3332
|
locale?: Locale;
|
|
2928
3333
|
activeDate?: Date;
|
|
2929
3334
|
onPressDateHeader?: (date: Date) => void;
|
|
@@ -2933,6 +3338,7 @@ const DayHeader = ({
|
|
|
2933
3338
|
day,
|
|
2934
3339
|
width,
|
|
2935
3340
|
weekdayFormat = "short",
|
|
3341
|
+
todayLabel,
|
|
2936
3342
|
locale,
|
|
2937
3343
|
activeDate,
|
|
2938
3344
|
onPressDateHeader,
|
|
@@ -2946,7 +3352,7 @@ const DayHeader = ({
|
|
|
2946
3352
|
// One accessible name for the whole header (the weekday + number below are
|
|
2947
3353
|
// decorative). `accessible` groups the children so a screen reader announces
|
|
2948
3354
|
// this once, not label-by-label.
|
|
2949
|
-
const accessibilityLabel = `${format(day, "EEEE d MMMM", { locale })}${isToday ?
|
|
3355
|
+
const accessibilityLabel = `${format(day, "EEEE d MMMM", { locale })}${isToday ? `, ${todayLabel}` : ""}`;
|
|
2950
3356
|
const headerSlot = slot("columnHeader", {
|
|
2951
3357
|
base: [styles.dayHeader, { width }],
|
|
2952
3358
|
themed: theme.containers.columnHeader,
|
|
@@ -3014,8 +3420,11 @@ const DayHeader = ({
|
|
|
3014
3420
|
};
|
|
3015
3421
|
|
|
3016
3422
|
const styles = StyleSheet.create({
|
|
3423
|
+
// Beside the hour column, at the fixed pager height (see `pagerHeight`).
|
|
3017
3424
|
pager: {
|
|
3018
|
-
|
|
3425
|
+
position: "absolute",
|
|
3426
|
+
top: 0,
|
|
3427
|
+
right: 0,
|
|
3019
3428
|
},
|
|
3020
3429
|
pagerList: {
|
|
3021
3430
|
flex: 1,
|
|
@@ -3023,17 +3432,63 @@ const styles = StyleSheet.create({
|
|
|
3023
3432
|
container: {
|
|
3024
3433
|
flex: 1,
|
|
3025
3434
|
},
|
|
3435
|
+
viewport: {
|
|
3436
|
+
flex: 1,
|
|
3437
|
+
},
|
|
3438
|
+
// The scroll content: the hour column and the pager sit inside it, absolutely.
|
|
3439
|
+
// Clipped, so the pager's fixed extra height neither draws nor (on the web)
|
|
3440
|
+
// extends the scroll range below the hours.
|
|
3441
|
+
gridRow: {
|
|
3442
|
+
position: "relative",
|
|
3443
|
+
overflow: "hidden",
|
|
3444
|
+
},
|
|
3445
|
+
hourGutter: {
|
|
3446
|
+
position: "absolute",
|
|
3447
|
+
top: 0,
|
|
3448
|
+
left: 0,
|
|
3449
|
+
bottom: 0,
|
|
3450
|
+
},
|
|
3451
|
+
fill: {
|
|
3452
|
+
position: "absolute",
|
|
3453
|
+
top: 0,
|
|
3454
|
+
left: 0,
|
|
3455
|
+
right: 0,
|
|
3456
|
+
bottom: 0,
|
|
3457
|
+
},
|
|
3458
|
+
// One hour (or sub-hour slot) of a flex column spanning the hour window.
|
|
3459
|
+
hourCell: {
|
|
3460
|
+
flex: 1,
|
|
3461
|
+
},
|
|
3462
|
+
// The day-header row fills the pinned header wrapper in a page.
|
|
3026
3463
|
headerRow: {
|
|
3464
|
+
flex: 1,
|
|
3465
|
+
flexDirection: "row",
|
|
3466
|
+
alignItems: "center",
|
|
3467
|
+
},
|
|
3468
|
+
// The pinned day-header row at the top of a page; rides the scroll offset so it
|
|
3469
|
+
// holds still while the hours pass, and slides with the page during a swipe.
|
|
3470
|
+
pagedHeader: {
|
|
3471
|
+
position: "absolute",
|
|
3472
|
+
top: 0,
|
|
3473
|
+
left: 0,
|
|
3474
|
+
right: 0,
|
|
3475
|
+
height: DAY_HEADER_HEIGHT,
|
|
3476
|
+
zIndex: 2,
|
|
3027
3477
|
flexDirection: "row",
|
|
3028
|
-
// Center the weekday/number block vertically; the day header's own symmetric
|
|
3029
|
-
// paddingVertical provides the spacing, matching the dom renderer (no extra
|
|
3030
|
-
// bottom padding that would push the content up).
|
|
3031
3478
|
alignItems: "center",
|
|
3032
3479
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
3033
3480
|
},
|
|
3034
|
-
|
|
3481
|
+
// The hour column's corner above the "all-day" cell, aligned with the header.
|
|
3482
|
+
gutterCorner: {
|
|
3483
|
+
position: "absolute",
|
|
3484
|
+
top: 0,
|
|
3485
|
+
left: 0,
|
|
3486
|
+
right: 0,
|
|
3487
|
+
zIndex: 2,
|
|
3035
3488
|
alignItems: "center",
|
|
3036
3489
|
justifyContent: "flex-end",
|
|
3490
|
+
paddingBottom: 6,
|
|
3491
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
3037
3492
|
},
|
|
3038
3493
|
dayHeader: {
|
|
3039
3494
|
alignItems: "center",
|
|
@@ -3048,14 +3503,53 @@ const styles = StyleSheet.create({
|
|
|
3048
3503
|
justifyContent: "center",
|
|
3049
3504
|
alignItems: "center",
|
|
3050
3505
|
},
|
|
3051
|
-
|
|
3052
|
-
width: "100%",
|
|
3506
|
+
page: {
|
|
3053
3507
|
position: "relative",
|
|
3054
3508
|
},
|
|
3509
|
+
// The hours of one page, below its all-day band and the label inset.
|
|
3510
|
+
grid: {
|
|
3511
|
+
position: "absolute",
|
|
3512
|
+
left: 0,
|
|
3513
|
+
right: 0,
|
|
3514
|
+
},
|
|
3515
|
+
// A page's all-day band: pinned to the top of the viewport by riding the scroll
|
|
3516
|
+
// offset, painted over the hours that pass beneath it. It draws the lane's
|
|
3517
|
+
// bottom rule at its live height, so the rule stays level with the hour
|
|
3518
|
+
// column's cell while a swipe interpolates between two weeks.
|
|
3519
|
+
laneBand: {
|
|
3520
|
+
position: "absolute",
|
|
3521
|
+
top: 0,
|
|
3522
|
+
left: 0,
|
|
3523
|
+
right: 0,
|
|
3524
|
+
overflow: "hidden",
|
|
3525
|
+
zIndex: 2,
|
|
3526
|
+
},
|
|
3527
|
+
// The hour column's "all-day" cell, pinned like the pages' bands.
|
|
3528
|
+
laneCell: {
|
|
3529
|
+
position: "absolute",
|
|
3530
|
+
top: 0,
|
|
3531
|
+
left: 0,
|
|
3532
|
+
right: 0,
|
|
3533
|
+
zIndex: 2,
|
|
3534
|
+
justifyContent: "center",
|
|
3535
|
+
overflow: "hidden",
|
|
3536
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
3537
|
+
},
|
|
3538
|
+
allDayLabel: {
|
|
3539
|
+
fontSize: 10,
|
|
3540
|
+
textAlign: "right",
|
|
3541
|
+
paddingRight: 6,
|
|
3542
|
+
},
|
|
3543
|
+
gutterRows: {
|
|
3544
|
+
position: "absolute",
|
|
3545
|
+
left: 0,
|
|
3546
|
+
right: 0,
|
|
3547
|
+
},
|
|
3055
3548
|
cellPressLayer: {
|
|
3056
3549
|
position: "absolute",
|
|
3057
3550
|
top: 0,
|
|
3058
3551
|
bottom: 0,
|
|
3552
|
+
left: 0,
|
|
3059
3553
|
right: 0,
|
|
3060
3554
|
},
|
|
3061
3555
|
createGhost: {
|
|
@@ -3069,6 +3563,7 @@ const styles = StyleSheet.create({
|
|
|
3069
3563
|
},
|
|
3070
3564
|
shadeBand: {
|
|
3071
3565
|
position: "absolute",
|
|
3566
|
+
overflow: "hidden",
|
|
3072
3567
|
},
|
|
3073
3568
|
daySeparator: {
|
|
3074
3569
|
position: "absolute",
|
|
@@ -3077,6 +3572,7 @@ const styles = StyleSheet.create({
|
|
|
3077
3572
|
},
|
|
3078
3573
|
hourRow: {
|
|
3079
3574
|
position: "absolute",
|
|
3575
|
+
top: 0,
|
|
3080
3576
|
left: 0,
|
|
3081
3577
|
right: 0,
|
|
3082
3578
|
flexDirection: "row",
|
|
@@ -3087,12 +3583,18 @@ const styles = StyleSheet.create({
|
|
|
3087
3583
|
textAlign: "right",
|
|
3088
3584
|
paddingRight: 6,
|
|
3089
3585
|
},
|
|
3586
|
+
// A line sits at the top of its hour or sub-hour cell.
|
|
3090
3587
|
hourLine: {
|
|
3091
|
-
|
|
3588
|
+
position: "absolute",
|
|
3589
|
+
top: 0,
|
|
3590
|
+
left: 0,
|
|
3591
|
+
right: 0,
|
|
3092
3592
|
height: StyleSheet.hairlineWidth,
|
|
3093
3593
|
},
|
|
3094
3594
|
timeslotLine: {
|
|
3095
3595
|
position: "absolute",
|
|
3596
|
+
top: 0,
|
|
3597
|
+
left: 0,
|
|
3096
3598
|
right: 0,
|
|
3097
3599
|
height: StyleSheet.hairlineWidth,
|
|
3098
3600
|
opacity: 0.5,
|
|
@@ -3142,6 +3644,10 @@ const styles = StyleSheet.create({
|
|
|
3142
3644
|
nonInteractive: {
|
|
3143
3645
|
pointerEvents: "none",
|
|
3144
3646
|
},
|
|
3647
|
+
// Touches pass through the view itself but still reach its children.
|
|
3648
|
+
passThrough: {
|
|
3649
|
+
pointerEvents: "box-none",
|
|
3650
|
+
},
|
|
3145
3651
|
// Disable user-driven horizontal scroll on web; programmatic paging still works.
|
|
3146
3652
|
webNoScroll: {
|
|
3147
3653
|
overflow: "hidden",
|