@super-calendar/native 2.9.0 → 2.10.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.
@@ -0,0 +1,169 @@
1
+ import { addDays, differenceInCalendarDays, startOfDay } from "date-fns";
2
+ import { useMemo, useState } from "react";
3
+ import Animated, {
4
+ runOnJS,
5
+ type SharedValue,
6
+ useAnimatedReaction,
7
+ useAnimatedStyle,
8
+ useDerivedValue,
9
+ } from "react-native-reanimated";
10
+ import { shiftMinutes } from "@super-calendar/core";
11
+ import type { CalendarEvent, CalendarMode, RenderEvent } from "../types";
12
+ import { useCalendarTheme } from "../theme";
13
+ import { useSlots } from "../utils/slots";
14
+ import type { TimeGridSlot } from "./TimeGrid";
15
+
16
+ export type MultiDayMove<T> = {
17
+ event: CalendarEvent<T>;
18
+ eventIndex: number;
19
+ phase: "dragging" | "dropped";
20
+ dayIndex: number;
21
+ offsetX: SharedValue<number>;
22
+ offsetY: SharedValue<number>;
23
+ lifted: SharedValue<number>;
24
+ };
25
+
26
+ type PreviewProps<T> = {
27
+ move: MultiDayMove<T>;
28
+ days: Date[];
29
+ cellHeight: SharedValue<number>;
30
+ dayWidth: number;
31
+ hourColumnWidth: number;
32
+ minHour: number;
33
+ mode: CalendarMode;
34
+ renderEvent: RenderEvent<T>;
35
+ minEventHeight: number;
36
+ eventGap: number;
37
+ };
38
+
39
+ const noop = () => {};
40
+
41
+ // Mount once on grab. Only numbers and shared values cross to the UI thread;
42
+ // moving the pointer does not rerender the page or rebuild its gestures.
43
+ export function MultiDayMovePreview<T>(props: PreviewProps<T>) {
44
+ const { move, days } = props;
45
+ const dayOffsets = useMemo(
46
+ () => days.map((day) => differenceInCalendarDays(day, days[move.dayIndex]) * 1440),
47
+ [days, move],
48
+ );
49
+ return days.map((day, index) => (
50
+ <PreviewDay
51
+ key={day.toISOString()}
52
+ {...props}
53
+ dayOffsets={dayOffsets}
54
+ index={index}
55
+ dayStart={startOfDay(day).getTime()}
56
+ dayEnd={addDays(startOfDay(day), 1).getTime()}
57
+ />
58
+ ));
59
+ }
60
+
61
+ function PreviewDay<T>({
62
+ move,
63
+ cellHeight,
64
+ dayWidth,
65
+ hourColumnWidth,
66
+ minHour,
67
+ mode,
68
+ renderEvent: RenderEventComponent,
69
+ minEventHeight,
70
+ eventGap,
71
+ dayOffsets,
72
+ index,
73
+ dayStart,
74
+ dayEnd,
75
+ }: PreviewProps<T> & {
76
+ dayOffsets: number[];
77
+ index: number;
78
+ dayStart: number;
79
+ dayEnd: number;
80
+ }) {
81
+ const theme = useCalendarTheme();
82
+ const slot = useSlots<TimeGridSlot>();
83
+ const { offsetX, offsetY, lifted, dayIndex, event } = move;
84
+ const duration = event.end.getTime() - event.start.getTime();
85
+ const startTimestamp = event.start.getTime();
86
+ const segment = useDerivedValue(() => {
87
+ const columnDelta = dayWidth > 0 ? Math.round(offsetX.value / dayWidth) : 0;
88
+ const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayOffsets.length - 1);
89
+ const minuteDelta = cellHeight.value > 0 ? (offsetY.value / cellHeight.value) * 60 : 0;
90
+ const start = shiftMinutes(
91
+ new Date(startTimestamp),
92
+ dayOffsets[target] + minuteDelta,
93
+ ).getTime();
94
+ const end = start + duration;
95
+ const visible = !lifted.value && start < dayEnd && end > dayStart;
96
+ return {
97
+ top: (Math.max(start, dayStart) - dayStart) / 3_600_000,
98
+ hours: visible
99
+ ? Math.max((Math.min(end, dayEnd) - Math.max(start, dayStart)) / 3_600_000, 0.25)
100
+ : 0,
101
+ continuesBefore: start < dayStart,
102
+ continuesAfter: end > dayEnd,
103
+ };
104
+ }, [dayWidth, dayIndex, dayOffsets, startTimestamp, duration, dayStart, dayEnd]);
105
+ const boxHeight = useDerivedValue(
106
+ () =>
107
+ segment.value.hours > 0
108
+ ? Math.max(segment.value.hours * cellHeight.value, minEventHeight)
109
+ : 0,
110
+ [minEventHeight],
111
+ );
112
+ const style = useAnimatedStyle(
113
+ () => ({
114
+ top: (segment.value.top - minHour) * cellHeight.value,
115
+ height: boxHeight.value,
116
+ opacity: boxHeight.value > 0 ? 1 : 0,
117
+ }),
118
+ [minHour],
119
+ );
120
+ const [continuation, setContinuation] = useState(() => ({
121
+ continuesBefore: segment.value.continuesBefore,
122
+ continuesAfter: segment.value.continuesAfter,
123
+ }));
124
+ useAnimatedReaction(
125
+ () => ({
126
+ continuesBefore: segment.value.continuesBefore,
127
+ continuesAfter: segment.value.continuesAfter,
128
+ }),
129
+ (next, previous) => {
130
+ if (
131
+ previous &&
132
+ (next.continuesBefore !== previous.continuesBefore ||
133
+ next.continuesAfter !== previous.continuesAfter)
134
+ ) {
135
+ runOnJS(setContinuation)(next);
136
+ }
137
+ },
138
+ );
139
+ const eventSlot = slot("event", { themed: theme.containers.timeGridEvent });
140
+ return (
141
+ <Animated.View
142
+ {...eventSlot}
143
+ testID="multi-day-move-preview"
144
+ pointerEvents="none"
145
+ accessibilityElementsHidden
146
+ importantForAccessibility="no-hide-descendants"
147
+ style={[
148
+ {
149
+ position: "absolute",
150
+ overflow: "hidden",
151
+ padding: eventGap,
152
+ left: hourColumnWidth + index * dayWidth,
153
+ width: dayWidth,
154
+ zIndex: 100,
155
+ },
156
+ eventSlot.style,
157
+ style,
158
+ ]}
159
+ >
160
+ <RenderEventComponent
161
+ event={event}
162
+ mode={mode}
163
+ boxHeight={boxHeight}
164
+ {...continuation}
165
+ onPress={noop}
166
+ />
167
+ </Animated.View>
168
+ );
169
+ }
@@ -17,8 +17,10 @@ import {
17
17
  } from "date-fns";
18
18
  import {
19
19
  createContext,
20
+ type Dispatch,
20
21
  memo,
21
22
  type ReactElement,
23
+ type SetStateAction,
22
24
  useCallback,
23
25
  useContext,
24
26
  useEffect,
@@ -96,6 +98,7 @@ import { useWebGridZoom } from "../utils/useWebGridZoom";
96
98
  import { useWebPagerKeys } from "../utils/useWebPagerKeys";
97
99
  import { withEventAccessibilityLabel } from "../utils/withEventAccessibilityLabel";
98
100
  import { AllDayLane } from "./AllDayLane";
101
+ import { type MultiDayMove, MultiDayMovePreview } from "./MultiDayMovePreview";
99
102
 
100
103
  // Horizontal swipe paging doesn't translate to web; there we disable it and page
101
104
  // with the arrow keys instead.
@@ -126,11 +129,13 @@ const DEFAULT_MIN_HOUR_HEIGHT = 32;
126
129
  const DEFAULT_MAX_HOUR_HEIGHT = 160;
127
130
  const DEFAULT_HOUR_COLUMN_WIDTH = 56;
128
131
  // Short events would otherwise render only a few pixels tall and clip their
129
- // content; keep them tall enough to stay legible and tappable.
130
- const MIN_EVENT_HEIGHT = 32;
132
+ // content; keep them tall enough to stay legible and tappable. Overridable per
133
+ // grid via `minEventHeight`.
134
+ const DEFAULT_MIN_EVENT_HEIGHT = 32;
131
135
  // Inset each event box within its slot so adjacent boxes (and column edges) get a
132
- // little breathing room instead of butting edge-to-edge.
133
- const EVENT_GAP = 2;
136
+ // little breathing room instead of butting edge-to-edge. Overridable per grid via
137
+ // `eventGap`.
138
+ const DEFAULT_EVENT_GAP = 2;
134
139
  // Hold this long before drag-to-create (sweeping empty grid space) begins on
135
140
  // native, so a normal scroll/tap isn't hijacked.
136
141
  const DRAG_ACTIVATE_MS = 300;
@@ -205,6 +210,7 @@ function MoveSpillPreview<T>({
205
210
  event,
206
211
  mode,
207
212
  renderEvent,
213
+ eventGap,
208
214
  slotProps,
209
215
  }: {
210
216
  spillHeight: SharedValue<number>;
@@ -217,6 +223,7 @@ function MoveSpillPreview<T>({
217
223
  event: CalendarEvent<T>;
218
224
  mode: CalendarMode;
219
225
  renderEvent: RenderEvent<T>;
226
+ eventGap: number;
220
227
  slotProps: ResolvedSlot<ViewStyle>;
221
228
  }): ReactElement {
222
229
  const RenderEventComponent = renderEvent;
@@ -243,7 +250,7 @@ function MoveSpillPreview<T>({
243
250
  style={[
244
251
  styles.eventBox,
245
252
  styles.nonInteractive,
246
- { left: dayLeftPx, width: dayWidth, top: 0 },
253
+ { left: dayLeftPx, width: dayWidth, top: 0, padding: eventGap },
247
254
  slotProps.style,
248
255
  style,
249
256
  ]}
@@ -275,6 +282,7 @@ function DragGhost<T>({
275
282
  event,
276
283
  mode,
277
284
  renderEvent,
285
+ eventGap,
278
286
  }: {
279
287
  x: SharedValue<number>;
280
288
  y: SharedValue<number>;
@@ -284,6 +292,7 @@ function DragGhost<T>({
284
292
  event: CalendarEvent<T>;
285
293
  mode: CalendarMode;
286
294
  renderEvent: RenderEvent<T>;
295
+ eventGap: number;
287
296
  }): ReactElement {
288
297
  const RenderEventComponent = renderEvent;
289
298
  const style = useAnimatedStyle(() => ({
@@ -293,7 +302,10 @@ function DragGhost<T>({
293
302
  opacity: visible.value,
294
303
  }));
295
304
  return (
296
- <Animated.View style={[styles.eventBox, styles.dragGhost, style]} pointerEvents="none">
305
+ <Animated.View
306
+ style={[styles.eventBox, styles.dragGhost, { padding: eventGap }, style]}
307
+ pointerEvents="none"
308
+ >
297
309
  <RenderEventComponent event={event} mode={mode} boxHeight={h} onPress={noop} />
298
310
  </Animated.View>
299
311
  );
@@ -310,6 +322,9 @@ const HOUR_LABEL_NUDGE = 6;
310
322
 
311
323
  type AnimatedEventBoxProps<T> = {
312
324
  positioned: PositionedEvent<T>;
325
+ eventIndex: number;
326
+ movingEvent: CalendarEvent<T> | null;
327
+ onMovePreview: Dispatch<SetStateAction<MultiDayMove<T> | null>>;
313
328
  cellHeight: SharedValue<number>;
314
329
  minHour: number;
315
330
  maxHour: number;
@@ -335,6 +350,10 @@ type AnimatedEventBoxProps<T> = {
335
350
  daysPerPage: number;
336
351
  renderEvent: RenderEvent<T>;
337
352
  snapMinutes: number;
353
+ // Floor for the box's pixel height (and the `boxHeight` handed to renderEvent).
354
+ minEventHeight: number;
355
+ // Inset between the box and its slot, applied as border-box padding.
356
+ eventGap: number;
338
357
  onPress: (event: CalendarEvent<T>) => void;
339
358
  onLongPress?: (event: CalendarEvent<T>) => void;
340
359
  onDragEvent?: EventDragHandler<T>;
@@ -351,6 +370,9 @@ type AnimatedEventBoxProps<T> = {
351
370
 
352
371
  function AnimatedEventBox<T>({
353
372
  positioned,
373
+ eventIndex,
374
+ movingEvent,
375
+ onMovePreview,
354
376
  cellHeight,
355
377
  minHour,
356
378
  maxHour,
@@ -366,6 +388,8 @@ function AnimatedEventBox<T>({
366
388
  daysPerPage,
367
389
  renderEvent,
368
390
  snapMinutes,
391
+ minEventHeight,
392
+ eventGap,
369
393
  onPress,
370
394
  onLongPress,
371
395
  onDragEvent,
@@ -442,6 +466,8 @@ function AnimatedEventBox<T>({
442
466
  const startHours = positioned.startHours;
443
467
  const durationHours = positioned.durationHours;
444
468
  const ownsStart = !positioned.continuesBefore;
469
+ const multiDay = positioned.continuesBefore || positioned.continuesAfter;
470
+ const hiddenForMove = positioned.event === movingEvent;
445
471
  // Where the move gesture clamps from, mirrored into a shared value so it isn't a
446
472
  // gesture dependency. A gesture memoized on a value the dragged event carries
447
473
  // would be rebuilt under the finger, and so torn down mid-drag, the moment a
@@ -464,9 +490,9 @@ function AnimatedEventBox<T>({
464
490
  () =>
465
491
  Math.max(
466
492
  durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value,
467
- MIN_EVENT_HEIGHT,
493
+ minEventHeight,
468
494
  ),
469
- [durationHours],
495
+ [durationHours, minEventHeight],
470
496
  );
471
497
 
472
498
  // The source segment may stop at midnight while the full event continues in
@@ -477,8 +503,8 @@ function AnimatedEventBox<T>({
477
503
  const top =
478
504
  (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
479
505
  const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
480
- return Math.max(Math.min(boxHeight.value, dayEnd - top), MIN_EVENT_HEIGHT);
481
- }, [startHours, minHour]);
506
+ return Math.max(Math.min(boxHeight.value, dayEnd - top), minEventHeight);
507
+ }, [startHours, minHour, minEventHeight]);
482
508
 
483
509
  const boxStyle = useAnimatedStyle(() => {
484
510
  // A top-edge resize pushes the box down and shortens it (start moves later).
@@ -503,7 +529,7 @@ function AnimatedEventBox<T>({
503
529
  // reaching the next day. Bails on the first line for a box that isn't being
504
530
  // moved, which is every box but one.
505
531
  const spillHeight = useDerivedValue(() => {
506
- if (!moving.value || lifted.value || cellHeight.value <= 0) return 0;
532
+ if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
507
533
  const liveStartHours = startHours + moveOffset.value / cellHeight.value;
508
534
  const overflowHours = liveStartHours + durationHours - HOURS_PER_DAY;
509
535
  if (overflowHours <= 0) return 0;
@@ -524,6 +550,7 @@ function AnimatedEventBox<T>({
524
550
  dayCount,
525
551
  dayOrdinals,
526
552
  nextDayDirection,
553
+ multiDay,
527
554
  ]);
528
555
 
529
556
  // Mount the spill preview only while a drag is actually spilling, off the UI
@@ -565,8 +592,8 @@ function AnimatedEventBox<T>({
565
592
 
566
593
  // Keep the latest event/handler in a ref so the gestures stay memoized but
567
594
  // never call into a stale closure.
568
- const latest = useRef({ event: positioned.event, onDragEvent, onDragStart });
569
- latest.current = { event: positioned.event, onDragEvent, onDragStart };
595
+ const latest = useRef({ event: positioned.event, eventIndex, onDragEvent, onDragStart });
596
+ latest.current = { event: positioned.event, eventIndex, onDragEvent, onDragStart };
570
597
 
571
598
  // Snap the box back to where it started (drop rejected or degenerate).
572
599
  const snapBack = useCallback(() => {
@@ -598,9 +625,14 @@ function AnimatedEventBox<T>({
598
625
  }
599
626
  // A handler may return false to reject the drop (e.g. an overlap or an
600
627
  // out-of-bounds slot); snap the box back to its original place.
601
- if (handler(event, next.start, next.end) === false) snapBack();
628
+ if (handler(event, next.start, next.end) === false) {
629
+ snapBack();
630
+ onMovePreview(null);
631
+ } else if (multiDay && deltaStartMin === deltaEndMin) {
632
+ onMovePreview((move) => (move ? { ...move, phase: "dropped" } : null));
633
+ }
602
634
  },
603
- [snapMinutes, snapBack],
635
+ [snapMinutes, snapBack, multiDay, onMovePreview],
604
636
  );
605
637
 
606
638
  // Fired on the JS thread when the gesture grabs the event, so consumers can
@@ -609,6 +641,21 @@ function AnimatedEventBox<T>({
609
641
  latest.current.onDragStart?.(latest.current.event);
610
642
  }, []);
611
643
 
644
+ const beginMovePreview = useCallback(() => {
645
+ if (multiDay) {
646
+ onMovePreview({
647
+ event: latest.current.event,
648
+ eventIndex: latest.current.eventIndex,
649
+ phase: "dragging",
650
+ dayIndex,
651
+ offsetX: moveOffsetX,
652
+ offsetY: moveOffset,
653
+ lifted,
654
+ });
655
+ }
656
+ }, [multiDay, onMovePreview, dayIndex, moveOffsetX, moveOffset, lifted]);
657
+ const endMovePreview = useCallback(() => onMovePreview(null), [onMovePreview]);
658
+
612
659
  // Edge auto-advance dwell. Dragging the event past the visible columns and
613
660
  // holding there pages the view one period and carries the event onto it: same
614
661
  // weekday, keeping whatever time the vertical drag has reached. It fires once
@@ -683,6 +730,7 @@ function AnimatedEventBox<T>({
683
730
  grabY.value = event.y;
684
731
  liveAbsX.value = event.absoluteX;
685
732
  liveAbsY.value = event.absoluteY;
733
+ runOnJS(beginMovePreview)();
686
734
  runOnJS(notifyDragStart)();
687
735
  })
688
736
  .onUpdate((event) => {
@@ -743,6 +791,7 @@ function AnimatedEventBox<T>({
743
791
  if (minuteDelta === 0 && dayDelta === 0) {
744
792
  moveOffset.value = 0;
745
793
  moveOffsetX.value = 0;
794
+ runOnJS(endMovePreview)();
746
795
  return;
747
796
  }
748
797
  // Hold the snapped position so the box doesn't flash back to the
@@ -757,7 +806,7 @@ function AnimatedEventBox<T>({
757
806
  const totalDelta = minuteDelta + calendarDayDelta * MINUTES_PER_DAY;
758
807
  runOnJS(commitDrag)(totalDelta, totalDelta);
759
808
  })
760
- .onFinalize(() => {
809
+ .onFinalize((_event, success) => {
761
810
  dragZ.value = 0;
762
811
  // Commit the cross-week drop here: onFinalize fires on every gesture end,
763
812
  // including the cancel RNGH reports when the source page moves under the
@@ -768,11 +817,17 @@ function AnimatedEventBox<T>({
768
817
  moveOffset.value = 0;
769
818
  moveOffsetX.value = 0;
770
819
  lifted.value = 0;
820
+ runOnJS(endMovePreview)();
771
821
  }
772
822
  // The preview unmounts from the `spillHeight` reaction once the commit
773
823
  // lands and clears `moveOffset`; this is the safety net for a cancel,
774
824
  // where `onEnd` never runs.
775
825
  moving.value = 0;
826
+ if (multiDay && !success) {
827
+ moveOffset.value = 0;
828
+ moveOffsetX.value = 0;
829
+ runOnJS(endMovePreview)();
830
+ }
776
831
  runOnJS(releaseEdge)();
777
832
  });
778
833
  // Native: long-press to pick up. Web: activate past a small drag in either
@@ -810,6 +865,9 @@ function AnimatedEventBox<T>({
810
865
  dayCount,
811
866
  dayOrdinals,
812
867
  commitDrag,
868
+ multiDay,
869
+ beginMovePreview,
870
+ endMovePreview,
813
871
  notifyDragStart,
814
872
  onEdgeAdvance,
815
873
  armEdge,
@@ -942,11 +1000,14 @@ function AnimatedEventBox<T>({
942
1000
  : undefined;
943
1001
 
944
1002
  const eventSlot = slot("event", {
945
- base: [styles.eventBox, { left, width }],
1003
+ base: [styles.eventBox, { left, width, padding: eventGap }],
946
1004
  themed: theme.containers.timeGridEvent,
947
1005
  });
948
1006
  const box = (
949
- <Animated.View {...eventSlot} style={[eventSlot.style, boxStyle]}>
1007
+ <Animated.View
1008
+ {...eventSlot}
1009
+ style={[eventSlot.style, boxStyle, hiddenForMove ? { opacity: 0 } : null]}
1010
+ >
950
1011
  <RenderEventComponent
951
1012
  event={positioned.event}
952
1013
  mode={mode}
@@ -1001,6 +1062,7 @@ function AnimatedEventBox<T>({
1001
1062
  event={positioned.event}
1002
1063
  mode={mode}
1003
1064
  renderEvent={renderEvent}
1065
+ eventGap={eventGap}
1004
1066
  slotProps={slot("event", { themed: theme.containers.timeGridEvent })}
1005
1067
  />
1006
1068
  ) : null}
@@ -1218,6 +1280,8 @@ type TimetablePageProps<T> = {
1218
1280
  renderEvent: RenderEvent<T>;
1219
1281
  keyExtractor: EventKeyExtractor<T>;
1220
1282
  snapMinutes: number;
1283
+ minEventHeight: number;
1284
+ eventGap: number;
1221
1285
  showDragHandle: boolean;
1222
1286
  eventStartEditable: boolean;
1223
1287
  eventDurationEditable: boolean;
@@ -1275,6 +1339,8 @@ function TimetablePageInner<T>({
1275
1339
  renderEvent,
1276
1340
  keyExtractor,
1277
1341
  snapMinutes,
1342
+ minEventHeight,
1343
+ eventGap,
1278
1344
  showDragHandle,
1279
1345
  eventStartEditable,
1280
1346
  eventDurationEditable,
@@ -1407,6 +1473,23 @@ function TimetablePageInner<T>({
1407
1473
  );
1408
1474
 
1409
1475
  const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents(events, day)), [days, events]);
1476
+ const [multiDayMove, setMultiDayMove] = useState<MultiDayMove<T> | null>(null);
1477
+ const movingEvent = multiDayMove
1478
+ ? (events.find(
1479
+ (event, index) =>
1480
+ keyExtractor(event, index) === keyExtractor(multiDayMove.event, multiDayMove.eventIndex),
1481
+ ) ?? null)
1482
+ : null;
1483
+ useEffect(() => {
1484
+ if (
1485
+ multiDayMove?.phase === "dropped" &&
1486
+ (!movingEvent ||
1487
+ movingEvent.start.getTime() !== multiDayMove.event.start.getTime() ||
1488
+ movingEvent.end.getTime() !== multiDayMove.event.end.getTime())
1489
+ ) {
1490
+ setMultiDayMove(null);
1491
+ }
1492
+ }, [multiDayMove, movingEvent]);
1410
1493
 
1411
1494
  // Map a tap on empty grid space back to the date+time it represents. Reads the
1412
1495
  // live row height on the JS thread to convert the touch Y into minutes.
@@ -1616,7 +1699,7 @@ function TimetablePageInner<T>({
1616
1699
  }));
1617
1700
 
1618
1701
  const ghostSlot = slot("createGhost", {
1619
- base: [styles.createGhost, { pointerEvents: "none" }],
1702
+ base: [styles.createGhost, { marginHorizontal: eventGap, pointerEvents: "none" }],
1620
1703
  themed: {
1621
1704
  backgroundColor: theme.colors.eventBackground,
1622
1705
  borderColor: theme.colors.todayBackground,
@@ -1819,6 +1902,9 @@ function TimetablePageInner<T>({
1819
1902
  // flattened list of all days' boxes.
1820
1903
  key={`${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`}
1821
1904
  positioned={positioned}
1905
+ eventIndex={events.indexOf(positioned.event)}
1906
+ movingEvent={movingEvent}
1907
+ onMovePreview={setMultiDayMove}
1822
1908
  cellHeight={heightSource}
1823
1909
  minHour={minHour}
1824
1910
  maxHour={maxHour}
@@ -1834,6 +1920,8 @@ function TimetablePageInner<T>({
1834
1920
  daysPerPage={daysPerPage}
1835
1921
  renderEvent={renderEvent}
1836
1922
  snapMinutes={snapMinutes}
1923
+ minEventHeight={minEventHeight}
1924
+ eventGap={eventGap}
1837
1925
  showDragHandle={showDragHandle}
1838
1926
  eventStartEditable={eventStartEditable}
1839
1927
  eventDurationEditable={eventDurationEditable}
@@ -1847,6 +1935,21 @@ function TimetablePageInner<T>({
1847
1935
  }),
1848
1936
  )}
1849
1937
 
1938
+ {multiDayMove ? (
1939
+ <MultiDayMovePreview
1940
+ move={multiDayMove}
1941
+ days={days}
1942
+ cellHeight={heightSource}
1943
+ dayWidth={dayWidth}
1944
+ hourColumnWidth={hourColumnWidth}
1945
+ minHour={minHour}
1946
+ mode={mode}
1947
+ renderEvent={renderEvent}
1948
+ minEventHeight={minEventHeight}
1949
+ eventGap={eventGap}
1950
+ />
1951
+ ) : null}
1952
+
1850
1953
  {showNowIndicator && nowDayIndex >= 0 && nowInWindow ? (
1851
1954
  <NowIndicator
1852
1955
  cellHeight={heightSource}
@@ -1969,6 +2072,18 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
1969
2072
  isRTL?: boolean;
1970
2073
  minHourHeight?: number;
1971
2074
  maxHourHeight?: number;
2075
+ /**
2076
+ * Minimum pixel height of a timed event box, so short events stay legible and
2077
+ * tappable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
2078
+ * 32; pass 0 to size every box strictly by its duration.
2079
+ */
2080
+ minEventHeight?: number;
2081
+ /**
2082
+ * Inset in pixels between a timed event box and its slot (each side), so
2083
+ * adjacent boxes and column edges get some breathing room. Default 2; pass 0
2084
+ * to let events fill their slot.
2085
+ */
2086
+ eventGap?: number;
1972
2087
  showNowIndicator?: boolean;
1973
2088
  locale?: Locale;
1974
2089
  freeSwipe?: boolean;
@@ -2049,6 +2164,8 @@ function TimeGridInner<T>({
2049
2164
  isRTL = false,
2050
2165
  minHourHeight = DEFAULT_MIN_HOUR_HEIGHT,
2051
2166
  maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT,
2167
+ minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
2168
+ eventGap = DEFAULT_EVENT_GAP,
2052
2169
  showNowIndicator = true,
2053
2170
  locale,
2054
2171
  freeSwipe = false,
@@ -2539,6 +2656,8 @@ function TimeGridInner<T>({
2539
2656
  renderEvent={labeledRenderEvent}
2540
2657
  keyExtractor={keyExtractor}
2541
2658
  snapMinutes={Math.max(1, dragStepMinutes)}
2659
+ minEventHeight={minEventHeight}
2660
+ eventGap={eventGap}
2542
2661
  showDragHandle={showDragHandle}
2543
2662
  eventStartEditable={eventStartEditable}
2544
2663
  eventDurationEditable={eventDurationEditable}
@@ -2589,6 +2708,8 @@ function TimeGridInner<T>({
2589
2708
  labeledRenderEvent,
2590
2709
  keyExtractor,
2591
2710
  dragStepMinutes,
2711
+ minEventHeight,
2712
+ eventGap,
2592
2713
  showDragHandle,
2593
2714
  eventStartEditable,
2594
2715
  eventDurationEditable,
@@ -2699,6 +2820,7 @@ function TimeGridInner<T>({
2699
2820
  event={liftedEvent}
2700
2821
  mode={mode}
2701
2822
  renderEvent={labeledRenderEvent}
2823
+ eventGap={eventGap}
2702
2824
  />
2703
2825
  ) : null}
2704
2826
  </View>
@@ -2940,7 +3062,6 @@ const styles = StyleSheet.create({
2940
3062
  position: "absolute",
2941
3063
  borderRadius: 6,
2942
3064
  borderWidth: StyleSheet.hairlineWidth,
2943
- marginHorizontal: EVENT_GAP,
2944
3065
  },
2945
3066
  weekendColumn: {
2946
3067
  position: "absolute",
@@ -3000,12 +3121,11 @@ const styles = StyleSheet.create({
3000
3121
  borderRadius: 2,
3001
3122
  opacity: 0.4,
3002
3123
  },
3124
+ // The `eventGap` inset is applied inline as border-box padding, so the visible
3125
+ // box (the flex child) sits inside the slot without touching its geometry.
3003
3126
  eventBox: {
3004
3127
  position: "absolute",
3005
3128
  overflow: "hidden",
3006
- // Border-box padding insets the visible box (the flex child) on all sides,
3007
- // giving a small gap without touching the slot geometry above.
3008
- padding: EVENT_GAP,
3009
3129
  },
3010
3130
  // The cross-week drag ghost: pinned to the pager's top-left, moved into place by
3011
3131
  // its transform, and floated above every page so it stays visible across a page.