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