@super-calendar/native 2.13.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/{DefaultMonthEvent-H1IQMTqK.d.ts → DefaultMonthEvent-BDD7GgL8.d.mts} +16 -4
- package/dist/{DefaultMonthEvent-eip3mlq_.d.mts → DefaultMonthEvent-ggwYo7Fy.d.ts} +16 -4
- package/dist/{MonthList-sGAZxQZ_.js → MonthList-D4_LBnbU.js} +47 -19
- package/dist/{MonthList-B-UE37ZG.mjs → MonthList-DWCH3GT5.mjs} +47 -19
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +80 -16
- package/dist/index.mjs +81 -17
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Calendar.tsx +8 -0
- package/src/components/MonthList.tsx +23 -4
- package/src/components/MonthPager.tsx +30 -4
- package/src/components/MonthView.tsx +29 -14
- package/src/components/MultiDayMovePreview.tsx +5 -5
- package/src/components/ResourceTimeline.tsx +44 -14
- package/src/components/TimeGrid.tsx +66 -10
- package/src/components/YearView.tsx +2 -2
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { format, type Locale, isSameMonth, startOfDay } from "date-fns";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type ComponentRef,
|
|
4
|
+
memo,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from "react";
|
|
3
12
|
import {
|
|
4
13
|
type DimensionValue,
|
|
5
14
|
type LayoutChangeEvent,
|
|
@@ -72,8 +81,6 @@ const DATE_BADGE_HEIGHT = 24;
|
|
|
72
81
|
const BAND_CENTER_Y = DAY_CELL_PADDING_TOP + DATE_BADGE_HEIGHT / 2;
|
|
73
82
|
const CELL_ROW_GAP = 2;
|
|
74
83
|
const CHIP_PADDING_V = 2;
|
|
75
|
-
// Where the first event row sits below the date badge (padding + badge + gap).
|
|
76
|
-
const BADGE_AREA = DAY_CELL_PADDING_TOP + DATE_BADGE_HEIGHT + CELL_ROW_GAP;
|
|
77
84
|
// Stable empty layout for the events-free picker (avoids a fresh object per render).
|
|
78
85
|
const EMPTY_LAYOUT = { segments: [], laneCount: 0 } as const;
|
|
79
86
|
// Horizontal inset of a chip within its cell (mirrors `styles.monthEvent`).
|
|
@@ -161,6 +168,10 @@ export type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
|
161
168
|
* explicit value when using a custom `renderEvent`.
|
|
162
169
|
*/
|
|
163
170
|
maxVisibleEventCount?: number;
|
|
171
|
+
/** Chip and overflow height in pixels; defaults to the theme title height plus padding. */
|
|
172
|
+
chipHeight?: number;
|
|
173
|
+
/** Vertical gap between chip rows in pixels (default 2). */
|
|
174
|
+
chipGap?: number;
|
|
164
175
|
weekStartsOn: WeekStartsOn;
|
|
165
176
|
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
166
177
|
hiddenDays?: number[];
|
|
@@ -272,6 +283,8 @@ function MonthViewInner<T>({
|
|
|
272
283
|
date,
|
|
273
284
|
events,
|
|
274
285
|
maxVisibleEventCount,
|
|
286
|
+
chipHeight,
|
|
287
|
+
chipGap = CELL_ROW_GAP,
|
|
275
288
|
weekStartsOn,
|
|
276
289
|
hiddenDays,
|
|
277
290
|
weekdayFormat = "short",
|
|
@@ -316,6 +329,7 @@ function MonthViewInner<T>({
|
|
|
316
329
|
styles: styleOverrides,
|
|
317
330
|
}: MonthViewProps<T>): ReactElement {
|
|
318
331
|
const theme = useCalendarTheme();
|
|
332
|
+
const badgeArea = DAY_CELL_PADDING_TOP + DATE_BADGE_HEIGHT + chipGap;
|
|
319
333
|
const slot = createSlots<MonthViewSlot>({ classNames, styles: styleOverrides });
|
|
320
334
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
321
335
|
// Selection comes from context (so cached pages still repaint), but explicit
|
|
@@ -366,9 +380,9 @@ function MonthViewInner<T>({
|
|
|
366
380
|
const chipMetrics = useMemo(() => {
|
|
367
381
|
const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
|
|
368
382
|
const lineHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3));
|
|
369
|
-
const
|
|
370
|
-
return { chipHeight, chipRowHeight:
|
|
371
|
-
}, [theme]);
|
|
383
|
+
const height = chipHeight ?? lineHeight + CHIP_PADDING_V * 2;
|
|
384
|
+
return { chipHeight: height, chipRowHeight: height + chipGap };
|
|
385
|
+
}, [theme, chipHeight, chipGap]);
|
|
372
386
|
|
|
373
387
|
// How many chips fit per cell: a fixed cap when `maxVisibleEventCount` is set,
|
|
374
388
|
// else derived from the measured cell height and the (default) chip metrics.
|
|
@@ -381,10 +395,10 @@ function MonthViewInner<T>({
|
|
|
381
395
|
}
|
|
382
396
|
const rowHeight = gridHeight / weeks.length;
|
|
383
397
|
const moreFontSize = numericStyle(theme.text.more.fontSize, 11);
|
|
384
|
-
const moreRowHeight = Math.ceil(moreFontSize * 1.3) +
|
|
398
|
+
const moreRowHeight = (chipHeight ?? Math.ceil(moreFontSize * 1.3)) + chipGap;
|
|
385
399
|
const available = rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT;
|
|
386
400
|
return monthEventCapacity(available, chipMetrics.chipRowHeight, moreRowHeight);
|
|
387
|
-
}, [maxVisibleEventCount, gridHeight, weeks.length, theme, chipMetrics]);
|
|
401
|
+
}, [maxVisibleEventCount, gridHeight, weeks.length, theme, chipMetrics, chipHeight, chipGap]);
|
|
388
402
|
|
|
389
403
|
// Group events by calendar day once per `events` change (shared with the dom
|
|
390
404
|
// renderer via core's `groupEventsByDay`), rather than scanning the whole list
|
|
@@ -415,7 +429,7 @@ function MonthViewInner<T>({
|
|
|
415
429
|
|
|
416
430
|
// ---- drag to create a day span / reschedule an event ----------------------
|
|
417
431
|
const dragEnabled = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
418
|
-
const gridRef = useRef<View
|
|
432
|
+
const gridRef = useRef<ComponentRef<typeof View>>(null);
|
|
419
433
|
// The live drag drives the preview; the ref is what the gesture and the web
|
|
420
434
|
// pointer listeners read, so neither has to be rebuilt as the hover day moves
|
|
421
435
|
// (rebuilding the gesture mid-drag would cancel it).
|
|
@@ -466,7 +480,7 @@ function MonthViewInner<T>({
|
|
|
466
480
|
if (!isDateSelectable(day, { minDate, maxDate, isDateDisabled })) return null;
|
|
467
481
|
// Which lane row the point lands on, mirroring the bar overlay's geometry.
|
|
468
482
|
const rowLayout = weekLayouts[row] ?? EMPTY_LAYOUT;
|
|
469
|
-
const lane = Math.floor((y - row * rowHeight -
|
|
483
|
+
const lane = Math.floor((y - row * rowHeight - badgeArea) / chipMetrics.chipRowHeight);
|
|
470
484
|
const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
|
|
471
485
|
const segment =
|
|
472
486
|
lane >= 0 && lane < visibleLanes
|
|
@@ -480,6 +494,7 @@ function MonthViewInner<T>({
|
|
|
480
494
|
weekLayouts,
|
|
481
495
|
capacity,
|
|
482
496
|
chipMetrics,
|
|
497
|
+
badgeArea,
|
|
483
498
|
showAdjacentMonths,
|
|
484
499
|
date,
|
|
485
500
|
minDate,
|
|
@@ -623,7 +638,7 @@ function MonthViewInner<T>({
|
|
|
623
638
|
<View
|
|
624
639
|
key={day.toISOString()}
|
|
625
640
|
{...slot("day", {
|
|
626
|
-
base: styles.dayCell,
|
|
641
|
+
base: [styles.dayCell, { gap: chipGap }],
|
|
627
642
|
themed: [
|
|
628
643
|
showGrid && {
|
|
629
644
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
@@ -715,7 +730,7 @@ function MonthViewInner<T>({
|
|
|
715
730
|
// Events mode mirrors the dom renderer: left-aligned cell content with
|
|
716
731
|
// the date badge in the top-right. The picker (no grid) stays centered
|
|
717
732
|
// so the selection range band lines up with the centered badge.
|
|
718
|
-
base: [styles.dayCell, showGrid && styles.dayCellEvents],
|
|
733
|
+
base: [styles.dayCell, { gap: chipGap }, showGrid && styles.dayCellEvents],
|
|
719
734
|
themed: [
|
|
720
735
|
showGrid && {
|
|
721
736
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
@@ -862,7 +877,7 @@ function MonthViewInner<T>({
|
|
|
862
877
|
{hiddenCount > 0 ? (
|
|
863
878
|
<Text
|
|
864
879
|
{...slot<TextStyle>("more", {
|
|
865
|
-
base: styles.moreLabel,
|
|
880
|
+
base: [styles.moreLabel, chipHeight != null && { height: chipHeight }],
|
|
866
881
|
themed: [theme.text.more, { color: theme.colors.textMuted }],
|
|
867
882
|
})}
|
|
868
883
|
onPress={
|
|
@@ -1036,7 +1051,7 @@ function MonthViewInner<T>({
|
|
|
1036
1051
|
position: "absolute",
|
|
1037
1052
|
left: pct((startCol / cols) * 100),
|
|
1038
1053
|
width: pct(((endCol - startCol + 1) / cols) * 100),
|
|
1039
|
-
top:
|
|
1054
|
+
top: badgeArea + seg.lane * chipMetrics.chipRowHeight,
|
|
1040
1055
|
height: chipMetrics.chipHeight,
|
|
1041
1056
|
paddingHorizontal: CHIP_INSET_H,
|
|
1042
1057
|
// Let a sweep in progress reach the cells underneath.
|
|
@@ -7,7 +7,7 @@ import Animated, {
|
|
|
7
7
|
useAnimatedStyle,
|
|
8
8
|
useDerivedValue,
|
|
9
9
|
} from "react-native-reanimated";
|
|
10
|
-
import { shiftMinutes } from "@super-calendar/core";
|
|
10
|
+
import { clockHoursBetween, shiftMinutes, wallClockHours } from "@super-calendar/core";
|
|
11
11
|
import type { CalendarEvent, CalendarMode, RenderEvent } from "../types";
|
|
12
12
|
import { useCalendarTheme } from "../theme";
|
|
13
13
|
import { useSlots } from "../utils/slots";
|
|
@@ -91,11 +91,11 @@ function PreviewDay<T>({
|
|
|
91
91
|
).getTime();
|
|
92
92
|
const end = start + duration;
|
|
93
93
|
const visible = !lifted.value && start < dayEnd && end > dayStart;
|
|
94
|
+
const segStart = new Date(Math.max(start, dayStart));
|
|
95
|
+
const segEnd = new Date(Math.min(end, dayEnd));
|
|
94
96
|
return {
|
|
95
|
-
top: (
|
|
96
|
-
hours: visible
|
|
97
|
-
? Math.max((Math.min(end, dayEnd) - Math.max(start, dayStart)) / 3_600_000, 0.25)
|
|
98
|
-
: 0,
|
|
97
|
+
top: wallClockHours(segStart, new Date(dayStart), new Date(dayEnd)),
|
|
98
|
+
hours: visible ? Math.max(clockHoursBetween(segStart, segEnd), 0.25) : 0,
|
|
99
99
|
continuesBefore: start < dayStart,
|
|
100
100
|
continuesAfter: end > dayEnd,
|
|
101
101
|
};
|
|
@@ -11,7 +11,12 @@ import {
|
|
|
11
11
|
View,
|
|
12
12
|
} from "react-native";
|
|
13
13
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
14
|
-
import Animated, {
|
|
14
|
+
import Animated, {
|
|
15
|
+
runOnJS,
|
|
16
|
+
useAnimatedStyle,
|
|
17
|
+
useDerivedValue,
|
|
18
|
+
useSharedValue,
|
|
19
|
+
} from "react-native-reanimated";
|
|
15
20
|
import {
|
|
16
21
|
backgroundBandsForDay,
|
|
17
22
|
type CalendarEvent,
|
|
@@ -24,6 +29,7 @@ import {
|
|
|
24
29
|
eventTimeLabel,
|
|
25
30
|
formatHour,
|
|
26
31
|
layoutDayEvents,
|
|
32
|
+
movedClockSpan,
|
|
27
33
|
type PositionedEvent,
|
|
28
34
|
resolveDraggedBounds,
|
|
29
35
|
snapDeltaMinutes,
|
|
@@ -38,6 +44,8 @@ const MOVE_ACTIVATE_MS = 250;
|
|
|
38
44
|
// a plain mouse drag creates (mirrors the time grid).
|
|
39
45
|
const DRAG_ACTIVATE_PX = 8;
|
|
40
46
|
const MINUTES_PER_HOUR = 60;
|
|
47
|
+
// `moveExtra` for a bar that isn't moving; shared so the hot path allocates nothing.
|
|
48
|
+
const NO_MOVE_EXTRA = { top: 0, hours: 0 };
|
|
41
49
|
const isWeb = Platform.OS === "web";
|
|
42
50
|
|
|
43
51
|
/** A schedulable lane (room, person, machine) events are grouped under. */
|
|
@@ -376,19 +384,41 @@ function ResourceBar<T>({
|
|
|
376
384
|
}
|
|
377
385
|
: undefined;
|
|
378
386
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
387
|
+
// Where a move in progress lands beyond its plain offset, in hours: a start in
|
|
388
|
+
// the hour a spring-forward change skips moves on past it (`top`), and the kept
|
|
389
|
+
// elapsed duration covers a different number of hours on the axis once a DST
|
|
390
|
+
// change falls inside it or stops falling inside it (`hours`). Timestamps, not
|
|
391
|
+
// `Date`s, so the worklet can capture them; a bar clipped to the day keeps its
|
|
392
|
+
// plain offset.
|
|
393
|
+
const eventStartMs = pe.event.start.getTime();
|
|
394
|
+
const eventEndMs = pe.event.end.getTime();
|
|
395
|
+
const clipped = pe.continuesBefore || pe.continuesAfter;
|
|
396
|
+
const barHours = pe.durationHours;
|
|
397
|
+
const moveExtra = useDerivedValue(() => {
|
|
398
|
+
if (clipped || moveX.value === 0 || hourSize <= 0) return NO_MOVE_EXTRA;
|
|
399
|
+
const minutes = Math.round((moveX.value / hourSize) * MINUTES_PER_HOUR);
|
|
400
|
+
const from = new Date(eventStartMs);
|
|
401
|
+
const to = new Date(eventEndMs);
|
|
402
|
+
const moved = movedClockSpan(from, to, minutes);
|
|
403
|
+
return {
|
|
404
|
+
top: moved.startHours - minutes / MINUTES_PER_HOUR,
|
|
405
|
+
hours: moved.hours - barHours,
|
|
406
|
+
};
|
|
407
|
+
}, [clipped, hourSize, eventStartMs, eventEndMs, barHours]);
|
|
408
|
+
|
|
409
|
+
const barStyle = useAnimatedStyle(() => {
|
|
410
|
+
const shift = moveX.value + moveExtra.value.top * hourSize;
|
|
411
|
+
const grow = resizeW.value + moveExtra.value.hours * hourSize;
|
|
412
|
+
return vertical
|
|
413
|
+
? {
|
|
414
|
+
transform: [{ translateY: shift }, { translateX: moveCross.value }],
|
|
415
|
+
height: Math.max(height + grow, 2),
|
|
416
|
+
}
|
|
417
|
+
: {
|
|
418
|
+
transform: [{ translateX: shift }, { translateY: moveCross.value }],
|
|
419
|
+
width: Math.max((width as number) + grow, 2),
|
|
420
|
+
};
|
|
421
|
+
}, [vertical, width, height, hourSize]);
|
|
392
422
|
|
|
393
423
|
const laneId = resources[laneIndex]?.id ?? "";
|
|
394
424
|
const moveGesture = useMemo(
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
startOfWeek,
|
|
17
17
|
} from "date-fns";
|
|
18
18
|
import {
|
|
19
|
+
type ComponentRef,
|
|
19
20
|
createContext,
|
|
20
21
|
type Dispatch,
|
|
21
22
|
type ForwardedRef,
|
|
@@ -91,6 +92,7 @@ import {
|
|
|
91
92
|
overlapsOtherEvents,
|
|
92
93
|
pageStepDays,
|
|
93
94
|
resolveDraggedBounds,
|
|
95
|
+
movedClockSpan,
|
|
94
96
|
snapDeltaMinutes,
|
|
95
97
|
} from "@super-calendar/core";
|
|
96
98
|
import { formatHour, layoutDayEvents, type PositionedEvent } from "@super-calendar/core";
|
|
@@ -129,6 +131,8 @@ type WebKeyTarget = {
|
|
|
129
131
|
const MINUTES_PER_HOUR = 60;
|
|
130
132
|
const HOURS_PER_DAY = 24;
|
|
131
133
|
const MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY;
|
|
134
|
+
// `moveExtra` for a box that isn't moving; shared so the hot path allocates nothing.
|
|
135
|
+
const NO_MOVE_EXTRA = { top: 0, hours: 0 };
|
|
132
136
|
// Steps rendered either side of the current page. LegendList virtualises, so
|
|
133
137
|
// only a few mount at once; a wide window means the user effectively never runs
|
|
134
138
|
// out of pages to swipe. Items are keyed by date and never recycled.
|
|
@@ -514,6 +518,40 @@ function AnimatedEventBoxInner<T>({
|
|
|
514
518
|
[startHours, ownsStart],
|
|
515
519
|
);
|
|
516
520
|
|
|
521
|
+
// Where a move in progress lands beyond its plain row offset, in hours: a start
|
|
522
|
+
// in the hour a spring-forward change skips moves on past it (`top`), and the
|
|
523
|
+
// kept elapsed duration covers a different number of rows once a DST change
|
|
524
|
+
// falls inside it or stops falling inside it (`hours`). Timestamps, not the
|
|
525
|
+
// event's `Date`s, so the worklet can capture them; a multi-day segment
|
|
526
|
+
// previews through `MultiDayMovePreview` instead.
|
|
527
|
+
const eventStartMs = positioned.event.start.getTime();
|
|
528
|
+
const eventEndMs = positioned.event.end.getTime();
|
|
529
|
+
const moveExtra = useDerivedValue(() => {
|
|
530
|
+
if (multiDay || lifted.value || cellHeight.value <= 0) return NO_MOVE_EXTRA;
|
|
531
|
+
if (moveOffset.value === 0 && moveOffsetX.value === 0) return NO_MOVE_EXTRA;
|
|
532
|
+
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
533
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
534
|
+
const minutes =
|
|
535
|
+
Math.round((moveOffset.value / cellHeight.value) * MINUTES_PER_HOUR) +
|
|
536
|
+
(dayOrdinals[target] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
537
|
+
const from = new Date(eventStartMs);
|
|
538
|
+
const to = new Date(eventEndMs);
|
|
539
|
+
const moved = movedClockSpan(from, to, minutes);
|
|
540
|
+
return {
|
|
541
|
+
top: moved.startHours - minutes / MINUTES_PER_HOUR,
|
|
542
|
+
hours: moved.hours - durationHours,
|
|
543
|
+
};
|
|
544
|
+
}, [
|
|
545
|
+
multiDay,
|
|
546
|
+
dayWidth,
|
|
547
|
+
dayIndex,
|
|
548
|
+
dayCount,
|
|
549
|
+
dayOrdinals,
|
|
550
|
+
eventStartMs,
|
|
551
|
+
eventEndMs,
|
|
552
|
+
durationHours,
|
|
553
|
+
]);
|
|
554
|
+
|
|
517
555
|
// Live pixel height of the box, driven on the UI thread by the shared
|
|
518
556
|
// cellHeight (plus any in-progress resize). Handed to renderEvent so custom
|
|
519
557
|
// renderers can reveal detail progressively as the grid zooms, without
|
|
@@ -521,7 +559,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
521
559
|
const boxHeight = useDerivedValue(
|
|
522
560
|
() =>
|
|
523
561
|
Math.max(
|
|
524
|
-
durationHours
|
|
562
|
+
(durationHours + moveExtra.value.hours) * cellHeight.value +
|
|
563
|
+
resizeDelta.value -
|
|
564
|
+
resizeStartDelta.value,
|
|
525
565
|
minEventHeight,
|
|
526
566
|
),
|
|
527
567
|
[durationHours, minEventHeight],
|
|
@@ -533,7 +573,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
533
573
|
// math and the floating cross-page ghost.
|
|
534
574
|
const visibleBoxHeight = useDerivedValue(() => {
|
|
535
575
|
const top =
|
|
536
|
-
(startHours - minHour) * cellHeight.value +
|
|
576
|
+
(startHours + moveExtra.value.top - minHour) * cellHeight.value +
|
|
577
|
+
moveOffset.value +
|
|
578
|
+
resizeStartDelta.value;
|
|
537
579
|
const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
|
|
538
580
|
return Math.max(Math.min(boxHeight.value, dayEnd - top), minEventHeight);
|
|
539
581
|
}, [startHours, minHour, minEventHeight]);
|
|
@@ -541,7 +583,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
541
583
|
const boxStyle = useAnimatedStyle(() => {
|
|
542
584
|
// A top-edge resize pushes the box down and shortens it (start moves later).
|
|
543
585
|
const top =
|
|
544
|
-
(startHours - minHour) * cellHeight.value +
|
|
586
|
+
(startHours + moveExtra.value.top - minHour) * cellHeight.value +
|
|
587
|
+
moveOffset.value +
|
|
588
|
+
resizeStartDelta.value;
|
|
545
589
|
// Cut the box off at midnight; whatever runs past it shows in the next column
|
|
546
590
|
// instead (see MoveSpillPreview), the way a committed event spanning midnight
|
|
547
591
|
// already renders. Purely geometric, so a resting box (already clipped to the
|
|
@@ -565,8 +609,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
565
609
|
// moved, which is every box but one.
|
|
566
610
|
const spillHeight = useDerivedValue(() => {
|
|
567
611
|
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
568
|
-
const
|
|
569
|
-
const
|
|
612
|
+
const extra = moveExtra.value;
|
|
613
|
+
const liveStartHours = startHours + extra.top + moveOffset.value / cellHeight.value;
|
|
614
|
+
const overflowHours = liveStartHours + durationHours + extra.hours - HOURS_PER_DAY;
|
|
570
615
|
if (overflowHours <= 0) return 0;
|
|
571
616
|
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
572
617
|
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
@@ -2458,13 +2503,13 @@ function TimeGridInner<T>(
|
|
|
2458
2503
|
const listRef = useRef<LegendListRef>(null);
|
|
2459
2504
|
// The pager's own view; measured in the window so an event drag can locate the
|
|
2460
2505
|
// horizontal edges (its screen-space left and width) for cross-week paging.
|
|
2461
|
-
const pagerRef = useRef<View
|
|
2506
|
+
const pagerRef = useRef<ComponentRef<typeof View>>(null);
|
|
2462
2507
|
// The grid's outer view; on web its ref resolves to the DOM node we attach the
|
|
2463
2508
|
// Ctrl/Cmd + scroll zoom listener to.
|
|
2464
|
-
const containerRef = useRef<View
|
|
2509
|
+
const containerRef = useRef<ComponentRef<typeof View>>(null);
|
|
2465
2510
|
// The scroll viewport; measured in the window so a lifted drag can map the
|
|
2466
2511
|
// finger into the scrolling content.
|
|
2467
|
-
const viewportRef = useRef<View
|
|
2512
|
+
const viewportRef = useRef<ComponentRef<typeof View>>(null);
|
|
2468
2513
|
// Width the pager last laid out at, so the zoom (which changes its height every
|
|
2469
2514
|
// frame) doesn't re-measure it.
|
|
2470
2515
|
const pagerLayoutWidthRef = useRef(-1);
|
|
@@ -2519,8 +2564,19 @@ function TimeGridInner<T>(
|
|
|
2519
2564
|
node.scrollTo({ y: seedDefaultY, animated: false });
|
|
2520
2565
|
// Latch only once the view can hold the offset: until both the viewport and
|
|
2521
2566
|
// the content have a size, the scroll clamps to 0 and would drop the seed.
|
|
2522
|
-
|
|
2523
|
-
|
|
2567
|
+
// Native types expose a node handle; react-native-web returns a DOM element.
|
|
2568
|
+
const dom: unknown = node.getScrollableNode();
|
|
2569
|
+
if (
|
|
2570
|
+
dom != null &&
|
|
2571
|
+
typeof dom === "object" &&
|
|
2572
|
+
"scrollHeight" in dom &&
|
|
2573
|
+
typeof dom.scrollHeight === "number" &&
|
|
2574
|
+
"clientHeight" in dom &&
|
|
2575
|
+
typeof dom.clientHeight === "number" &&
|
|
2576
|
+
dom.scrollHeight > dom.clientHeight
|
|
2577
|
+
) {
|
|
2578
|
+
webSeededRef.current = true;
|
|
2579
|
+
}
|
|
2524
2580
|
}, [scrollRef, seedDefaultY]);
|
|
2525
2581
|
// Height of the all-day band, shared by the hour column and every page. Each
|
|
2526
2582
|
// page reports its lane's natural height under its index, and the band follows
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
View,
|
|
12
12
|
type ScrollViewProps,
|
|
13
13
|
} from "react-native";
|
|
14
|
-
import { Gesture, GestureDetector
|
|
14
|
+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
15
15
|
import { useCalendarTheme } from "../theme";
|
|
16
16
|
import type { CalendarEvent, WeekStartsOn } from "../types";
|
|
17
17
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
@@ -522,7 +522,7 @@ function MiniMonthGrid({
|
|
|
522
522
|
if (day.getMonth() !== current.getMonth()) return null;
|
|
523
523
|
return selectable(day) ? day : null;
|
|
524
524
|
}, []);
|
|
525
|
-
const gesture = useMemo
|
|
525
|
+
const gesture = useMemo(() => {
|
|
526
526
|
if (!sweepEnabled) return undefined;
|
|
527
527
|
return Gesture.Pan()
|
|
528
528
|
.activateAfterLongPress(DRAG_HOLD_MS)
|