@super-calendar/native 2.8.2 → 2.9.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 +8 -0
- package/dist/{DefaultMonthEvent-C_T4thzu.d.ts → DefaultMonthEvent--9Jg6w-x.d.ts} +82 -3
- package/dist/{DefaultMonthEvent-Cewbec1K.d.mts → DefaultMonthEvent-BlnKHaq2.d.mts} +82 -3
- package/dist/{MonthList-DjAz4xoi.mjs → MonthList-CjKhzOJX.mjs} +356 -102
- package/dist/{MonthList-C-vBotP0.js → MonthList-DNT1LJkk.js} +355 -101
- package/dist/index.d.mts +91 -37
- package/dist/index.d.ts +91 -37
- package/dist/index.js +536 -64
- package/dist/index.mjs +537 -65
- 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 +85 -16
- package/src/components/MonthPager.tsx +150 -62
- package/src/components/MonthView.tsx +415 -76
- package/src/components/MultiDayMovePreview.tsx +164 -0
- package/src/components/TimeGrid.tsx +327 -37
- package/src/components/YearView.tsx +368 -81
- package/src/types.ts +19 -0
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-
|
|
1
|
+
import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-CjKhzOJX.mjs";
|
|
2
2
|
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
3
|
import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Animated, { runOnJS, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
|
|
5
|
-
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
5
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, monthCreateRange, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
6
6
|
import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
7
|
+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
7
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { LegendList } from "@legendapp/list/react-native";
|
|
9
|
-
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
10
10
|
//#region src/components/YearView.tsx
|
|
11
|
+
const isWeb$2 = Platform.OS === "web";
|
|
12
|
+
const DRAG_HOLD_MS = 400;
|
|
11
13
|
const FALLBACK_COLUMNS = 3;
|
|
12
|
-
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
14
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, classNames, styles: styleOverrides }) {
|
|
13
15
|
const theme = useCalendarTheme();
|
|
14
16
|
const slot = createSlots({
|
|
15
17
|
classNames,
|
|
@@ -22,6 +24,11 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
22
24
|
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
23
25
|
};
|
|
24
26
|
const months = useMemo(() => getYearMonths(date), [date]);
|
|
27
|
+
const monthWeeks = useMemo(() => months.map((month) => buildMonthWeeks$1(month, weekStartsOn, { hiddenDays })), [
|
|
28
|
+
months,
|
|
29
|
+
weekStartsOn,
|
|
30
|
+
hiddenDays
|
|
31
|
+
]);
|
|
25
32
|
const weekdayLabels = useMemo(() => filterHiddenDays(getWeekDays$1(date, weekStartsOn), hiddenDays).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
|
|
26
33
|
date,
|
|
27
34
|
weekStartsOn,
|
|
@@ -29,13 +36,72 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
29
36
|
hiddenDays
|
|
30
37
|
]);
|
|
31
38
|
const eventDays = useMemo(() => new Set(events && events.length > 0 ? groupEventsByDay(events.filter((e) => !isBackgroundEvent$1(e))).keys() : []), [events]);
|
|
39
|
+
const sweepEnabled = onSelectDrag != null || onCreateEvent != null;
|
|
40
|
+
const [sweep, setSweep] = useState(null);
|
|
41
|
+
const sweepRef = useRef(sweep);
|
|
42
|
+
sweepRef.current = sweep;
|
|
43
|
+
const movedRef = useRef(false);
|
|
44
|
+
const suppressPressRef = useRef(false);
|
|
45
|
+
const isSelectable = useCallback((day) => isDateSelectable$1(day, {
|
|
46
|
+
minDate,
|
|
47
|
+
maxDate,
|
|
48
|
+
isDateDisabled
|
|
49
|
+
}), [
|
|
50
|
+
minDate,
|
|
51
|
+
maxDate,
|
|
52
|
+
isDateDisabled
|
|
53
|
+
]);
|
|
54
|
+
const beginSweep = useCallback((day) => {
|
|
55
|
+
const time = startOfDay(day).getTime();
|
|
56
|
+
suppressPressRef.current = false;
|
|
57
|
+
movedRef.current = false;
|
|
58
|
+
setSweep({
|
|
59
|
+
anchor: time,
|
|
60
|
+
hover: time
|
|
61
|
+
});
|
|
62
|
+
}, []);
|
|
63
|
+
const extendSweep = useCallback((day) => {
|
|
64
|
+
const current = sweepRef.current;
|
|
65
|
+
if (!current || !isSelectable(day)) return;
|
|
66
|
+
const time = startOfDay(day).getTime();
|
|
67
|
+
if (time === current.hover) return;
|
|
68
|
+
movedRef.current = true;
|
|
69
|
+
setSweep((c) => c ? {
|
|
70
|
+
...c,
|
|
71
|
+
hover: time
|
|
72
|
+
} : c);
|
|
73
|
+
const [lo, hi] = current.anchor <= time ? [current.anchor, time] : [time, current.anchor];
|
|
74
|
+
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
75
|
+
}, [isSelectable, onSelectDrag]);
|
|
76
|
+
const finishSweep = useCallback(() => {
|
|
77
|
+
const current = sweepRef.current;
|
|
78
|
+
setSweep(null);
|
|
79
|
+
if (!current || !movedRef.current) return;
|
|
80
|
+
if (isWeb$2) suppressPressRef.current = true;
|
|
81
|
+
const range = monthCreateRange(new Date(current.anchor), new Date(current.hover));
|
|
82
|
+
onCreateEvent?.(range.start, range.end);
|
|
83
|
+
}, [onCreateEvent]);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!isWeb$2 || !sweepEnabled) return;
|
|
86
|
+
const target = globalThis;
|
|
87
|
+
target.addEventListener?.("pointerup", finishSweep);
|
|
88
|
+
return () => target.removeEventListener?.("pointerup", finishSweep);
|
|
89
|
+
}, [sweepEnabled, finishSweep]);
|
|
90
|
+
const pressDay = useCallback((day) => {
|
|
91
|
+
if (suppressPressRef.current) {
|
|
92
|
+
suppressPressRef.current = false;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
onPressDay?.(day);
|
|
96
|
+
}, [onPressDay]);
|
|
32
97
|
return /* @__PURE__ */ jsx(ScrollView, {
|
|
33
98
|
onLayout: handleLayout,
|
|
34
99
|
showsVerticalScrollIndicator: true,
|
|
100
|
+
scrollEnabled: isWeb$2 || sweep == null,
|
|
35
101
|
children: /* @__PURE__ */ jsx(View, {
|
|
36
102
|
...slot("grid", { base: styles$5.grid }),
|
|
37
|
-
children: months.map((month) => {
|
|
38
|
-
const weeks =
|
|
103
|
+
children: months.map((month, monthIndex) => {
|
|
104
|
+
const weeks = monthWeeks[monthIndex];
|
|
39
105
|
const title = format(month, "MMMM", { locale });
|
|
40
106
|
const monthLabel = format(month, "MMMM yyyy", { locale });
|
|
41
107
|
const titleText = /* @__PURE__ */ jsx(Text, {
|
|
@@ -73,53 +139,158 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
73
139
|
children: label
|
|
74
140
|
}, i))
|
|
75
141
|
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
142
|
+
/* @__PURE__ */ jsx(MiniMonthGrid, {
|
|
143
|
+
testID: `year-month-grid-${month.getMonth()}`,
|
|
144
|
+
month,
|
|
145
|
+
weeks,
|
|
146
|
+
sweepEnabled: sweepEnabled && !isWeb$2,
|
|
147
|
+
isSelectable,
|
|
148
|
+
onBeginSweep: beginSweep,
|
|
149
|
+
onExtendSweep: extendSweep,
|
|
150
|
+
onFinishSweep: finishSweep,
|
|
151
|
+
children: weeks.map((week) => /* @__PURE__ */ jsx(View, {
|
|
152
|
+
...slot("week", { base: styles$5.week }),
|
|
153
|
+
children: week.map((day) => {
|
|
154
|
+
if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ jsx(View, { style: styles$5.day }, day.toISOString());
|
|
155
|
+
const isToday = getIsToday$1(day);
|
|
156
|
+
const isHighlighted = activeDate ? isSameCalendarDay$1(day, activeDate) : isToday;
|
|
157
|
+
const hasEvents = eventDays.has(startOfDay(day).toISOString());
|
|
158
|
+
const state = daySelectionState$1(day, {
|
|
159
|
+
selectedDates,
|
|
160
|
+
selectedRange
|
|
161
|
+
}, {
|
|
162
|
+
minDate,
|
|
163
|
+
maxDate,
|
|
164
|
+
isDateDisabled
|
|
165
|
+
});
|
|
166
|
+
const dayTime = startOfDay(day).getTime();
|
|
167
|
+
const inSweep = sweep != null && dayTime >= Math.min(sweep.anchor, sweep.hover) && dayTime <= Math.max(sweep.anchor, sweep.hover);
|
|
168
|
+
const label = `${format(day, "EEEE, d LLLL yyyy", { locale })}${isToday ? ", today" : ""}${state.isSelected ? ", selected" : ""}${state.isDisabled ? ", unavailable" : ""}${hasEvents ? ", has events" : ""}`;
|
|
169
|
+
const badge = dayBadgeKind(state, isHighlighted);
|
|
170
|
+
const daySlot = slot("day", { base: styles$5.day });
|
|
171
|
+
const showBand = rangeBandKind(state, true) !== "none";
|
|
172
|
+
const rounding = bandRounding(rangeBandKind(state, false));
|
|
173
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
174
|
+
showBand || inSweep ? /* @__PURE__ */ jsx(View, { ...slot("rangeBand", {
|
|
175
|
+
base: [
|
|
176
|
+
styles$5.rangeBand,
|
|
177
|
+
rounding.start && styles$5.rangeBandStart,
|
|
178
|
+
rounding.end && styles$5.rangeBandEnd
|
|
179
|
+
],
|
|
180
|
+
themed: { backgroundColor: theme.colors.rangeBackground }
|
|
181
|
+
}) }) : null,
|
|
182
|
+
/* @__PURE__ */ jsx(View, {
|
|
183
|
+
...slot("dayBadge", {
|
|
184
|
+
base: styles$5.dayBadge,
|
|
185
|
+
themed: badge === "none" ? void 0 : {
|
|
186
|
+
backgroundColor: badge === "today" ? theme.colors.todayBackground : theme.colors.selectedBackground,
|
|
187
|
+
borderRadius: theme.todayBadgeRadius
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
191
|
+
...slot("dayText", { themed: [styles$5.dayText, { color: state.isDisabled ? theme.colors.textDisabled : badge === "today" ? theme.colors.todayText : badge === "selected" ? theme.colors.selectedText : theme.colors.text }] }),
|
|
192
|
+
allowFontScaling: false,
|
|
193
|
+
children: day.getDate()
|
|
194
|
+
})
|
|
195
|
+
}),
|
|
196
|
+
hasEvents ? /* @__PURE__ */ jsx(View, { ...slot("eventDot", {
|
|
197
|
+
base: styles$5.eventDot,
|
|
198
|
+
themed: { backgroundColor: badge === "none" ? theme.colors.todayBackground : theme.colors.todayText }
|
|
199
|
+
}) }) : null
|
|
200
|
+
] });
|
|
201
|
+
return onPressDay || sweepEnabled ? /* @__PURE__ */ jsx(Pressable, {
|
|
202
|
+
onPress: () => pressDay(day),
|
|
203
|
+
disabled: state.isDisabled,
|
|
204
|
+
accessibilityRole: "button",
|
|
205
|
+
accessibilityLabel: label,
|
|
206
|
+
...isWeb$2 && sweepEnabled ? {
|
|
207
|
+
onPointerDown: () => {
|
|
208
|
+
if (isSelectable(day)) beginSweep(day);
|
|
209
|
+
},
|
|
210
|
+
onPointerEnter: () => extendSweep(day)
|
|
211
|
+
} : null,
|
|
212
|
+
...daySlot,
|
|
213
|
+
children: content
|
|
214
|
+
}, day.toISOString()) : /* @__PURE__ */ jsx(View, {
|
|
215
|
+
accessible: true,
|
|
216
|
+
accessibilityLabel: label,
|
|
217
|
+
...daySlot,
|
|
218
|
+
children: content
|
|
219
|
+
}, day.toISOString());
|
|
220
|
+
})
|
|
221
|
+
}, week[0].toISOString()))
|
|
222
|
+
})
|
|
112
223
|
]
|
|
113
224
|
}, month.toISOString());
|
|
114
225
|
})
|
|
115
226
|
})
|
|
116
227
|
});
|
|
117
228
|
}
|
|
229
|
+
function MiniMonthGrid({ testID, month, weeks, sweepEnabled, isSelectable, onBeginSweep, onExtendSweep, onFinishSweep, children }) {
|
|
230
|
+
const sizeRef = useRef({
|
|
231
|
+
width: 0,
|
|
232
|
+
height: 0
|
|
233
|
+
});
|
|
234
|
+
const onLayout = useCallback((event) => {
|
|
235
|
+
const { width, height } = event.nativeEvent.layout;
|
|
236
|
+
sizeRef.current = {
|
|
237
|
+
width,
|
|
238
|
+
height
|
|
239
|
+
};
|
|
240
|
+
}, []);
|
|
241
|
+
const latest = useRef({
|
|
242
|
+
month,
|
|
243
|
+
weeks,
|
|
244
|
+
isSelectable,
|
|
245
|
+
onBeginSweep,
|
|
246
|
+
onExtendSweep,
|
|
247
|
+
onFinishSweep
|
|
248
|
+
});
|
|
249
|
+
latest.current = {
|
|
250
|
+
month,
|
|
251
|
+
weeks,
|
|
252
|
+
isSelectable,
|
|
253
|
+
onBeginSweep,
|
|
254
|
+
onExtendSweep,
|
|
255
|
+
onFinishSweep
|
|
256
|
+
};
|
|
257
|
+
const dayAt = useCallback((x, y) => {
|
|
258
|
+
const { width, height } = sizeRef.current;
|
|
259
|
+
const { month: current, weeks: rows, isSelectable: selectable } = latest.current;
|
|
260
|
+
if (width <= 0 || height <= 0 || rows.length === 0) return null;
|
|
261
|
+
const row = Math.min(rows.length - 1, Math.max(0, Math.floor(y / (height / rows.length))));
|
|
262
|
+
const cols = rows[row].length;
|
|
263
|
+
const col = Math.min(cols - 1, Math.max(0, Math.floor(x / (width / cols))));
|
|
264
|
+
const day = rows[row][col];
|
|
265
|
+
if (!day) return null;
|
|
266
|
+
if (day.getMonth() !== current.getMonth()) return null;
|
|
267
|
+
return selectable(day) ? day : null;
|
|
268
|
+
}, []);
|
|
269
|
+
const gesture = useMemo(() => {
|
|
270
|
+
if (!sweepEnabled) return void 0;
|
|
271
|
+
return Gesture.Pan().activateAfterLongPress(DRAG_HOLD_MS).runOnJS(true).onStart((event) => {
|
|
272
|
+
const day = dayAt(event.x, event.y);
|
|
273
|
+
if (day) latest.current.onBeginSweep(day);
|
|
274
|
+
}).onUpdate((event) => {
|
|
275
|
+
const day = dayAt(event.x, event.y);
|
|
276
|
+
if (day) latest.current.onExtendSweep(day);
|
|
277
|
+
}).onFinalize(() => latest.current.onFinishSweep());
|
|
278
|
+
}, [sweepEnabled, dayAt]);
|
|
279
|
+
const grid = /* @__PURE__ */ jsx(View, {
|
|
280
|
+
testID,
|
|
281
|
+
onLayout,
|
|
282
|
+
children
|
|
283
|
+
});
|
|
284
|
+
return gesture ? /* @__PURE__ */ jsx(GestureDetector, {
|
|
285
|
+
gesture,
|
|
286
|
+
children: grid
|
|
287
|
+
}) : grid;
|
|
288
|
+
}
|
|
118
289
|
/**
|
|
119
290
|
* A year at a glance: the twelve months as compact mini grids, with today
|
|
120
291
|
* highlighted and a dot under days that hold events. Tap a day or a month
|
|
121
|
-
* title to drill into a denser view
|
|
122
|
-
* `mode="year"`.
|
|
292
|
+
* title to drill into a denser view, or hold and drag to sweep out a date
|
|
293
|
+
* range. It's the view `Calendar` renders for `mode="year"`.
|
|
123
294
|
*
|
|
124
295
|
* @example
|
|
125
296
|
* ```tsx
|
|
@@ -161,7 +332,28 @@ const styles$5 = StyleSheet.create({
|
|
|
161
332
|
alignItems: "center",
|
|
162
333
|
justifyContent: "center"
|
|
163
334
|
},
|
|
335
|
+
dayBadge: {
|
|
336
|
+
width: "100%",
|
|
337
|
+
height: "100%",
|
|
338
|
+
alignItems: "center",
|
|
339
|
+
justifyContent: "center"
|
|
340
|
+
},
|
|
164
341
|
dayText: { fontSize: 11 },
|
|
342
|
+
rangeBand: {
|
|
343
|
+
position: "absolute",
|
|
344
|
+
top: 0,
|
|
345
|
+
bottom: 0,
|
|
346
|
+
left: 0,
|
|
347
|
+
right: 0
|
|
348
|
+
},
|
|
349
|
+
rangeBandStart: {
|
|
350
|
+
borderTopLeftRadius: 999,
|
|
351
|
+
borderBottomLeftRadius: 999
|
|
352
|
+
},
|
|
353
|
+
rangeBandEnd: {
|
|
354
|
+
borderTopRightRadius: 999,
|
|
355
|
+
borderBottomRightRadius: 999
|
|
356
|
+
},
|
|
165
357
|
eventDot: {
|
|
166
358
|
position: "absolute",
|
|
167
359
|
bottom: 1,
|
|
@@ -541,6 +733,93 @@ const styles$2 = StyleSheet.create({
|
|
|
541
733
|
chip: { minHeight: 18 }
|
|
542
734
|
});
|
|
543
735
|
//#endregion
|
|
736
|
+
//#region src/components/MultiDayMovePreview.tsx
|
|
737
|
+
const noop$1 = () => {};
|
|
738
|
+
const MIN_EVENT_HEIGHT$1 = 32;
|
|
739
|
+
function MultiDayMovePreview(props) {
|
|
740
|
+
const { move, days } = props;
|
|
741
|
+
const dayOffsets = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[move.dayIndex]) * 1440), [days, move]);
|
|
742
|
+
return days.map((day, index) => /* @__PURE__ */ jsx(PreviewDay, {
|
|
743
|
+
...props,
|
|
744
|
+
dayOffsets,
|
|
745
|
+
index,
|
|
746
|
+
dayStart: startOfDay(day).getTime(),
|
|
747
|
+
dayEnd: addDays(startOfDay(day), 1).getTime()
|
|
748
|
+
}, day.toISOString()));
|
|
749
|
+
}
|
|
750
|
+
function PreviewDay({ move, cellHeight, dayWidth, hourColumnWidth, minHour, mode, renderEvent: RenderEventComponent, dayOffsets, index, dayStart, dayEnd }) {
|
|
751
|
+
const theme = useCalendarTheme();
|
|
752
|
+
const slot = useSlots();
|
|
753
|
+
const { offsetX, offsetY, lifted, dayIndex, event } = move;
|
|
754
|
+
const duration = event.end.getTime() - event.start.getTime();
|
|
755
|
+
const startTimestamp = event.start.getTime();
|
|
756
|
+
const segment = useDerivedValue(() => {
|
|
757
|
+
const columnDelta = dayWidth > 0 ? Math.round(offsetX.value / dayWidth) : 0;
|
|
758
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayOffsets.length - 1);
|
|
759
|
+
const minuteDelta = cellHeight.value > 0 ? offsetY.value / cellHeight.value * 60 : 0;
|
|
760
|
+
const start = shiftMinutes(new Date(startTimestamp), dayOffsets[target] + minuteDelta).getTime();
|
|
761
|
+
const end = start + duration;
|
|
762
|
+
const visible = !lifted.value && start < dayEnd && end > dayStart;
|
|
763
|
+
return {
|
|
764
|
+
top: (Math.max(start, dayStart) - dayStart) / 36e5,
|
|
765
|
+
hours: visible ? Math.max((Math.min(end, dayEnd) - Math.max(start, dayStart)) / 36e5, .25) : 0,
|
|
766
|
+
continuesBefore: start < dayStart,
|
|
767
|
+
continuesAfter: end > dayEnd
|
|
768
|
+
};
|
|
769
|
+
}, [
|
|
770
|
+
dayWidth,
|
|
771
|
+
dayIndex,
|
|
772
|
+
dayOffsets,
|
|
773
|
+
startTimestamp,
|
|
774
|
+
duration,
|
|
775
|
+
dayStart,
|
|
776
|
+
dayEnd
|
|
777
|
+
]);
|
|
778
|
+
const boxHeight = useDerivedValue(() => segment.value.hours > 0 ? Math.max(segment.value.hours * cellHeight.value, MIN_EVENT_HEIGHT$1) : 0);
|
|
779
|
+
const style = useAnimatedStyle(() => ({
|
|
780
|
+
top: (segment.value.top - minHour) * cellHeight.value,
|
|
781
|
+
height: boxHeight.value,
|
|
782
|
+
opacity: boxHeight.value > 0 ? 1 : 0
|
|
783
|
+
}), [minHour]);
|
|
784
|
+
const [continuation, setContinuation] = useState(() => ({
|
|
785
|
+
continuesBefore: segment.value.continuesBefore,
|
|
786
|
+
continuesAfter: segment.value.continuesAfter
|
|
787
|
+
}));
|
|
788
|
+
useAnimatedReaction(() => ({
|
|
789
|
+
continuesBefore: segment.value.continuesBefore,
|
|
790
|
+
continuesAfter: segment.value.continuesAfter
|
|
791
|
+
}), (next, previous) => {
|
|
792
|
+
if (previous && (next.continuesBefore !== previous.continuesBefore || next.continuesAfter !== previous.continuesAfter)) runOnJS(setContinuation)(next);
|
|
793
|
+
});
|
|
794
|
+
const eventSlot = slot("event", { themed: theme.containers.timeGridEvent });
|
|
795
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
796
|
+
...eventSlot,
|
|
797
|
+
testID: "multi-day-move-preview",
|
|
798
|
+
pointerEvents: "none",
|
|
799
|
+
accessibilityElementsHidden: true,
|
|
800
|
+
importantForAccessibility: "no-hide-descendants",
|
|
801
|
+
style: [
|
|
802
|
+
{
|
|
803
|
+
position: "absolute",
|
|
804
|
+
overflow: "hidden",
|
|
805
|
+
padding: 2,
|
|
806
|
+
left: hourColumnWidth + index * dayWidth,
|
|
807
|
+
width: dayWidth,
|
|
808
|
+
zIndex: 100
|
|
809
|
+
},
|
|
810
|
+
eventSlot.style,
|
|
811
|
+
style
|
|
812
|
+
],
|
|
813
|
+
children: /* @__PURE__ */ jsx(RenderEventComponent, {
|
|
814
|
+
event,
|
|
815
|
+
mode,
|
|
816
|
+
boxHeight,
|
|
817
|
+
...continuation,
|
|
818
|
+
onPress: noop$1
|
|
819
|
+
})
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
//#endregion
|
|
544
823
|
//#region src/components/TimeGrid.tsx
|
|
545
824
|
const isWeb$1 = Platform.OS === "web";
|
|
546
825
|
const MINUTES_PER_HOUR$1 = 60;
|
|
@@ -566,6 +845,49 @@ const EDGE_ZONE_PX = 36;
|
|
|
566
845
|
const EdgePagingContext = createContext(null);
|
|
567
846
|
const noop = () => {};
|
|
568
847
|
/**
|
|
848
|
+
* The tail of a move that runs past midnight, drawn at the top of the next day's
|
|
849
|
+
* column so the drop reads on both days before the finger lifts. Mounted only
|
|
850
|
+
* while a drag is actually spilling (see `spillHeight`), so an idle grid pays
|
|
851
|
+
* nothing for it; its geometry is driven on the UI thread from there.
|
|
852
|
+
*/
|
|
853
|
+
function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, slotProps }) {
|
|
854
|
+
const RenderEventComponent = renderEvent;
|
|
855
|
+
const style = useAnimatedStyle(() => ({
|
|
856
|
+
height: spillHeight.value,
|
|
857
|
+
opacity: spillHeight.value > 0 ? 1 : 0,
|
|
858
|
+
zIndex: spillHeight.value > 0 ? DRAG_EVENT_Z : 0,
|
|
859
|
+
transform: [{ translateX: moveOffsetX.value + nextDayDirection * dayWidth }, { translateY: -minHour * cellHeight.value }]
|
|
860
|
+
}), [
|
|
861
|
+
dayWidth,
|
|
862
|
+
nextDayDirection,
|
|
863
|
+
minHour
|
|
864
|
+
]);
|
|
865
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
866
|
+
...slotProps,
|
|
867
|
+
accessibilityElementsHidden: true,
|
|
868
|
+
importantForAccessibility: "no-hide-descendants",
|
|
869
|
+
style: [
|
|
870
|
+
styles$1.eventBox,
|
|
871
|
+
styles$1.nonInteractive,
|
|
872
|
+
{
|
|
873
|
+
left: dayLeftPx,
|
|
874
|
+
width: dayWidth,
|
|
875
|
+
top: 0
|
|
876
|
+
},
|
|
877
|
+
slotProps.style,
|
|
878
|
+
style
|
|
879
|
+
],
|
|
880
|
+
children: /* @__PURE__ */ jsx(RenderEventComponent, {
|
|
881
|
+
event,
|
|
882
|
+
mode,
|
|
883
|
+
boxHeight: spillHeight,
|
|
884
|
+
continuesBefore: true,
|
|
885
|
+
continuesAfter: false,
|
|
886
|
+
onPress: noop
|
|
887
|
+
})
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
569
891
|
* The floating copy of a dragged event, rendered above the pager so a cross-week
|
|
570
892
|
* drag stays visible after its source page pages away. Position, size, and
|
|
571
893
|
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
@@ -595,7 +917,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
|
595
917
|
});
|
|
596
918
|
}
|
|
597
919
|
const HOUR_LABEL_TOP_INSET = 12;
|
|
598
|
-
function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
|
|
920
|
+
function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview, cellHeight, minHour, maxHour, left, width, dayLeftPx, nextDayDirection, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
|
|
599
921
|
const RenderEventComponent = renderEvent;
|
|
600
922
|
const theme = useCalendarTheme();
|
|
601
923
|
const slot = useSlots();
|
|
@@ -616,6 +938,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
616
938
|
const resizeDelta = useSharedValue(0);
|
|
617
939
|
const resizeStartDelta = useSharedValue(0);
|
|
618
940
|
const dragZ = useSharedValue(0);
|
|
941
|
+
const moving = useSharedValue(0);
|
|
619
942
|
const edgeDir = useSharedValue(0);
|
|
620
943
|
const lifted = useSharedValue(0);
|
|
621
944
|
const grabX = useSharedValue(0);
|
|
@@ -624,17 +947,52 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
624
947
|
const liveAbsY = useSharedValue(0);
|
|
625
948
|
const startHours = positioned.startHours;
|
|
626
949
|
const durationHours = positioned.durationHours;
|
|
950
|
+
const ownsStart = !positioned.continuesBefore;
|
|
951
|
+
const multiDay = positioned.continuesBefore || positioned.continuesAfter;
|
|
952
|
+
const hiddenForMove = positioned.event === movingEvent;
|
|
953
|
+
const dragStartSV = useDerivedValue(() => ({
|
|
954
|
+
minutes: startHours * MINUTES_PER_HOUR$1,
|
|
955
|
+
ownsStart
|
|
956
|
+
}), [startHours, ownsStart]);
|
|
627
957
|
const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
|
|
628
|
-
const
|
|
629
|
-
top
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
958
|
+
const visibleBoxHeight = useDerivedValue(() => {
|
|
959
|
+
const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
960
|
+
const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
|
|
961
|
+
return Math.max(Math.min(boxHeight.value, dayEnd - top), MIN_EVENT_HEIGHT);
|
|
962
|
+
}, [startHours, minHour]);
|
|
963
|
+
const boxStyle = useAnimatedStyle(() => {
|
|
964
|
+
return {
|
|
965
|
+
top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
966
|
+
height: visibleBoxHeight.value,
|
|
967
|
+
transform: [{ translateX: moveOffsetX.value }],
|
|
968
|
+
zIndex: dragZ.value
|
|
969
|
+
};
|
|
970
|
+
}, [startHours, minHour]);
|
|
971
|
+
const spillHeight = useDerivedValue(() => {
|
|
972
|
+
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
973
|
+
const overflowHours = startHours + moveOffset.value / cellHeight.value + durationHours - HOURS_PER_DAY;
|
|
974
|
+
if (overflowHours <= 0) return 0;
|
|
975
|
+
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
976
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
977
|
+
const next = target + nextDayDirection;
|
|
978
|
+
if (next < 0 || next >= dayCount || dayOrdinals[next] - dayOrdinals[target] !== 1) return 0;
|
|
979
|
+
return Math.min(overflowHours, maxHour - minHour) * cellHeight.value;
|
|
980
|
+
}, [
|
|
634
981
|
startHours,
|
|
635
982
|
durationHours,
|
|
636
|
-
minHour
|
|
983
|
+
minHour,
|
|
984
|
+
maxHour,
|
|
985
|
+
dayWidth,
|
|
986
|
+
dayIndex,
|
|
987
|
+
dayCount,
|
|
988
|
+
dayOrdinals,
|
|
989
|
+
nextDayDirection,
|
|
990
|
+
multiDay
|
|
637
991
|
]);
|
|
992
|
+
const [previewMounted, setPreviewMounted] = useState(false);
|
|
993
|
+
useAnimatedReaction(() => spillHeight.value > 0, (spilling, previous) => {
|
|
994
|
+
if (previous !== null && spilling !== previous) runOnJS(setPreviewMounted)(spilling);
|
|
995
|
+
});
|
|
638
996
|
useEffect(() => {
|
|
639
997
|
moveOffset.value = 0;
|
|
640
998
|
moveOffsetX.value = 0;
|
|
@@ -650,11 +1008,13 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
650
1008
|
]);
|
|
651
1009
|
const latest = useRef({
|
|
652
1010
|
event: positioned.event,
|
|
1011
|
+
eventIndex,
|
|
653
1012
|
onDragEvent,
|
|
654
1013
|
onDragStart
|
|
655
1014
|
});
|
|
656
1015
|
latest.current = {
|
|
657
1016
|
event: positioned.event,
|
|
1017
|
+
eventIndex,
|
|
658
1018
|
onDragEvent,
|
|
659
1019
|
onDragStart
|
|
660
1020
|
};
|
|
@@ -677,11 +1037,41 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
677
1037
|
snapBack();
|
|
678
1038
|
return;
|
|
679
1039
|
}
|
|
680
|
-
if (handler(event, next.start, next.end) === false)
|
|
681
|
-
|
|
1040
|
+
if (handler(event, next.start, next.end) === false) {
|
|
1041
|
+
snapBack();
|
|
1042
|
+
onMovePreview(null);
|
|
1043
|
+
} else if (multiDay && deltaStartMin === deltaEndMin) onMovePreview((move) => move ? {
|
|
1044
|
+
...move,
|
|
1045
|
+
phase: "dropped"
|
|
1046
|
+
} : null);
|
|
1047
|
+
}, [
|
|
1048
|
+
snapMinutes,
|
|
1049
|
+
snapBack,
|
|
1050
|
+
multiDay,
|
|
1051
|
+
onMovePreview
|
|
1052
|
+
]);
|
|
682
1053
|
const notifyDragStart = useCallback(() => {
|
|
683
1054
|
latest.current.onDragStart?.(latest.current.event);
|
|
684
1055
|
}, []);
|
|
1056
|
+
const beginMovePreview = useCallback(() => {
|
|
1057
|
+
if (multiDay) onMovePreview({
|
|
1058
|
+
event: latest.current.event,
|
|
1059
|
+
eventIndex: latest.current.eventIndex,
|
|
1060
|
+
phase: "dragging",
|
|
1061
|
+
dayIndex,
|
|
1062
|
+
offsetX: moveOffsetX,
|
|
1063
|
+
offsetY: moveOffset,
|
|
1064
|
+
lifted
|
|
1065
|
+
});
|
|
1066
|
+
}, [
|
|
1067
|
+
multiDay,
|
|
1068
|
+
onMovePreview,
|
|
1069
|
+
dayIndex,
|
|
1070
|
+
moveOffsetX,
|
|
1071
|
+
moveOffset,
|
|
1072
|
+
lifted
|
|
1073
|
+
]);
|
|
1074
|
+
const endMovePreview = useCallback(() => onMovePreview(null), [onMovePreview]);
|
|
685
1075
|
const dwellTimer = useRef(null);
|
|
686
1076
|
const disarmEdge = useCallback(() => {
|
|
687
1077
|
if (dwellTimer.current) {
|
|
@@ -725,12 +1115,14 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
725
1115
|
const moveGesture = useMemo(() => {
|
|
726
1116
|
const pan = Gesture.Pan().enabled(canMove).onStart((event) => {
|
|
727
1117
|
dragZ.value = DRAG_EVENT_Z;
|
|
1118
|
+
moving.value = 1;
|
|
728
1119
|
edgeDir.value = 0;
|
|
729
1120
|
lifted.value = 0;
|
|
730
1121
|
grabX.value = event.x;
|
|
731
1122
|
grabY.value = event.y;
|
|
732
1123
|
liveAbsX.value = event.absoluteX;
|
|
733
1124
|
liveAbsY.value = event.absoluteY;
|
|
1125
|
+
runOnJS(beginMovePreview)();
|
|
734
1126
|
runOnJS(notifyDragStart)();
|
|
735
1127
|
}).onUpdate((event) => {
|
|
736
1128
|
liveAbsX.value = event.absoluteX;
|
|
@@ -738,8 +1130,11 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
738
1130
|
if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
|
|
739
1131
|
ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
|
|
740
1132
|
ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
|
|
741
|
-
} else {
|
|
742
|
-
|
|
1133
|
+
} else if (cellHeight.value > 0) {
|
|
1134
|
+
const { minutes: startMinutes, ownsStart } = dragStartSV.value;
|
|
1135
|
+
const dragged = startMinutes + event.translationY / cellHeight.value * MINUTES_PER_HOUR$1;
|
|
1136
|
+
const held = ownsStart ? clampMoveStartMinutes(dragged, minHour, maxHour, snapMinutes) : dragged;
|
|
1137
|
+
moveOffset.value = (held - startMinutes) / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
743
1138
|
moveOffsetX.value = event.translationX;
|
|
744
1139
|
}
|
|
745
1140
|
if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
|
|
@@ -753,26 +1148,36 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
753
1148
|
}
|
|
754
1149
|
}).onEnd((event) => {
|
|
755
1150
|
if (lifted.value) return;
|
|
756
|
-
const
|
|
1151
|
+
const { minutes: startMinutes, ownsStart } = dragStartSV.value;
|
|
1152
|
+
const snapped = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1153
|
+
const minuteDelta = ownsStart ? clampMoveStartMinutes(startMinutes + snapped, minHour, maxHour, snapMinutes) - startMinutes : snapped;
|
|
757
1154
|
const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
|
|
758
1155
|
const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
|
|
759
1156
|
const dayDelta = targetDay - dayIndex;
|
|
760
1157
|
if (minuteDelta === 0 && dayDelta === 0) {
|
|
761
1158
|
moveOffset.value = 0;
|
|
762
1159
|
moveOffsetX.value = 0;
|
|
1160
|
+
runOnJS(endMovePreview)();
|
|
763
1161
|
return;
|
|
764
1162
|
}
|
|
765
1163
|
moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
766
1164
|
moveOffsetX.value = dayDelta * dayWidth;
|
|
767
1165
|
const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
768
1166
|
runOnJS(commitDrag)(totalDelta, totalDelta);
|
|
769
|
-
}).onFinalize(() => {
|
|
1167
|
+
}).onFinalize((_event, success) => {
|
|
770
1168
|
dragZ.value = 0;
|
|
771
1169
|
if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
|
|
772
1170
|
runOnJS(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
|
|
773
1171
|
moveOffset.value = 0;
|
|
774
1172
|
moveOffsetX.value = 0;
|
|
775
1173
|
lifted.value = 0;
|
|
1174
|
+
runOnJS(endMovePreview)();
|
|
1175
|
+
}
|
|
1176
|
+
moving.value = 0;
|
|
1177
|
+
if (multiDay && !success) {
|
|
1178
|
+
moveOffset.value = 0;
|
|
1179
|
+
moveOffsetX.value = 0;
|
|
1180
|
+
runOnJS(endMovePreview)();
|
|
776
1181
|
}
|
|
777
1182
|
runOnJS(releaseEdge)();
|
|
778
1183
|
});
|
|
@@ -784,6 +1189,10 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
784
1189
|
moveOffset,
|
|
785
1190
|
moveOffsetX,
|
|
786
1191
|
dragZ,
|
|
1192
|
+
moving,
|
|
1193
|
+
dragStartSV,
|
|
1194
|
+
minHour,
|
|
1195
|
+
maxHour,
|
|
787
1196
|
edgeDir,
|
|
788
1197
|
lifted,
|
|
789
1198
|
grabX,
|
|
@@ -801,6 +1210,9 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
801
1210
|
dayCount,
|
|
802
1211
|
dayOrdinals,
|
|
803
1212
|
commitDrag,
|
|
1213
|
+
multiDay,
|
|
1214
|
+
beginMovePreview,
|
|
1215
|
+
endMovePreview,
|
|
804
1216
|
notifyDragStart,
|
|
805
1217
|
onEdgeAdvance,
|
|
806
1218
|
armEdge,
|
|
@@ -914,12 +1326,16 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
914
1326
|
});
|
|
915
1327
|
const box = /* @__PURE__ */ jsxs(Animated.View, {
|
|
916
1328
|
...eventSlot,
|
|
917
|
-
style: [
|
|
1329
|
+
style: [
|
|
1330
|
+
eventSlot.style,
|
|
1331
|
+
boxStyle,
|
|
1332
|
+
hiddenForMove ? { opacity: 0 } : null
|
|
1333
|
+
],
|
|
918
1334
|
children: [
|
|
919
1335
|
/* @__PURE__ */ jsx(RenderEventComponent, {
|
|
920
1336
|
event: positioned.event,
|
|
921
1337
|
mode,
|
|
922
|
-
boxHeight,
|
|
1338
|
+
boxHeight: visibleBoxHeight,
|
|
923
1339
|
continuesBefore: positioned.continuesBefore,
|
|
924
1340
|
continuesAfter: positioned.continuesAfter,
|
|
925
1341
|
accessibilityActions,
|
|
@@ -944,10 +1360,22 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
944
1360
|
]
|
|
945
1361
|
});
|
|
946
1362
|
if (!canMove) return box;
|
|
947
|
-
return /* @__PURE__ */ jsx(GestureDetector, {
|
|
1363
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(GestureDetector, {
|
|
948
1364
|
gesture: moveGesture,
|
|
949
1365
|
children: box
|
|
950
|
-
})
|
|
1366
|
+
}), previewMounted && !positioned.continuesAfter ? /* @__PURE__ */ jsx(MoveSpillPreview, {
|
|
1367
|
+
spillHeight,
|
|
1368
|
+
moveOffsetX,
|
|
1369
|
+
cellHeight,
|
|
1370
|
+
dayLeftPx,
|
|
1371
|
+
dayWidth,
|
|
1372
|
+
nextDayDirection,
|
|
1373
|
+
minHour,
|
|
1374
|
+
event: positioned.event,
|
|
1375
|
+
mode,
|
|
1376
|
+
renderEvent,
|
|
1377
|
+
slotProps: slot("event", { themed: theme.containers.timeGridEvent })
|
|
1378
|
+
}) : null] });
|
|
951
1379
|
}
|
|
952
1380
|
const HourRow = ({ hour, minHour, cellHeight, hourColumnWidth, label, ampm, hourComponent }) => {
|
|
953
1381
|
const theme = useCalendarTheme();
|
|
@@ -1104,6 +1532,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1104
1532
|
const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
|
|
1105
1533
|
const dayOrdinals = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[0])), [days]);
|
|
1106
1534
|
const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
|
|
1535
|
+
const [multiDayMove, setMultiDayMove] = useState(null);
|
|
1536
|
+
const movingEvent = multiDayMove ? events.find((event, index) => keyExtractor(event, index) === keyExtractor(multiDayMove.event, multiDayMove.eventIndex)) ?? null : null;
|
|
1537
|
+
useEffect(() => {
|
|
1538
|
+
if (multiDayMove?.phase === "dropped" && (!movingEvent || movingEvent.start.getTime() !== multiDayMove.event.start.getTime() || movingEvent.end.getTime() !== multiDayMove.event.end.getTime())) setMultiDayMove(null);
|
|
1539
|
+
}, [multiDayMove, movingEvent]);
|
|
1107
1540
|
const cellDateFromTouch = (event) => {
|
|
1108
1541
|
const { locationX, locationY } = event.nativeEvent;
|
|
1109
1542
|
const dayIndex = days.length === 1 ? 0 : Math.floor(locationX / dayWidth);
|
|
@@ -1417,10 +1850,16 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1417
1850
|
const columnWidth = dayWidth / positioned.columns;
|
|
1418
1851
|
return /* @__PURE__ */ jsx(AnimatedEventBox, {
|
|
1419
1852
|
positioned,
|
|
1853
|
+
eventIndex: events.indexOf(positioned.event),
|
|
1854
|
+
movingEvent,
|
|
1855
|
+
onMovePreview: setMultiDayMove,
|
|
1420
1856
|
cellHeight: heightSource,
|
|
1421
1857
|
minHour,
|
|
1858
|
+
maxHour,
|
|
1422
1859
|
left: dayLeft(dayIndex) + positioned.column * columnWidth,
|
|
1423
1860
|
width: columnWidth,
|
|
1861
|
+
dayLeftPx: dayLeft(dayIndex),
|
|
1862
|
+
nextDayDirection: isRTL ? -1 : 1,
|
|
1424
1863
|
dayWidth,
|
|
1425
1864
|
dayIndex,
|
|
1426
1865
|
dayCount: days.length,
|
|
@@ -1439,6 +1878,16 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1439
1878
|
onEdgeAdvance
|
|
1440
1879
|
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
1441
1880
|
})),
|
|
1881
|
+
multiDayMove ? /* @__PURE__ */ jsx(MultiDayMovePreview, {
|
|
1882
|
+
move: multiDayMove,
|
|
1883
|
+
days,
|
|
1884
|
+
cellHeight: heightSource,
|
|
1885
|
+
dayWidth,
|
|
1886
|
+
hourColumnWidth,
|
|
1887
|
+
minHour,
|
|
1888
|
+
mode,
|
|
1889
|
+
renderEvent
|
|
1890
|
+
}) : null,
|
|
1442
1891
|
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
|
|
1443
1892
|
cellHeight: heightSource,
|
|
1444
1893
|
nowHours,
|
|
@@ -1504,6 +1953,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1504
1953
|
containerWidth,
|
|
1505
1954
|
hourColumnWidth,
|
|
1506
1955
|
minHour: clampedMinHour,
|
|
1956
|
+
maxHour: clampedMaxHour,
|
|
1507
1957
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1508
1958
|
onDragEvent,
|
|
1509
1959
|
onChangeDate
|
|
@@ -1519,7 +1969,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1519
1969
|
setEdgePagingLock(false);
|
|
1520
1970
|
}, [ghostVisible]);
|
|
1521
1971
|
const commitLiftedDrop = useCallback((ghostLocalX, ghostLocalY) => {
|
|
1522
|
-
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1972
|
+
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, maxHour: max, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1523
1973
|
const ev = liftedEventRef.current;
|
|
1524
1974
|
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1525
1975
|
clearLift();
|
|
@@ -1527,7 +1977,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1527
1977
|
const dayWidth = (cw - hcw) / days.length;
|
|
1528
1978
|
const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
|
|
1529
1979
|
const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1530
|
-
const minutes = Math.round(rawMinutes / snap) * snap;
|
|
1980
|
+
const minutes = clampMoveStartMinutes(Math.round(rawMinutes / snap) * snap, min, max, snap);
|
|
1531
1981
|
const start = new Date(days[col]);
|
|
1532
1982
|
start.setHours(0, 0, 0, 0);
|
|
1533
1983
|
start.setMinutes(minutes);
|
|
@@ -1605,6 +2055,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1605
2055
|
containerWidth,
|
|
1606
2056
|
hourColumnWidth,
|
|
1607
2057
|
minHour: clampedMinHour,
|
|
2058
|
+
maxHour: clampedMaxHour,
|
|
1608
2059
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1609
2060
|
onDragEvent,
|
|
1610
2061
|
onChangeDate
|
|
@@ -2147,7 +2598,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
2147
2598
|
* }
|
|
2148
2599
|
* ```
|
|
2149
2600
|
*/
|
|
2150
|
-
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
2601
|
+
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
2151
2602
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
2152
2603
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
2153
2604
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -2234,6 +2685,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2234
2685
|
disableMonthEventCellPress,
|
|
2235
2686
|
isRTL,
|
|
2236
2687
|
showSixWeeks,
|
|
2688
|
+
showTitle,
|
|
2237
2689
|
activeDate,
|
|
2238
2690
|
renderHeaderForMonthView,
|
|
2239
2691
|
renderCustomDateForMonth,
|
|
@@ -2242,9 +2694,22 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2242
2694
|
keyExtractor,
|
|
2243
2695
|
onPressDay,
|
|
2244
2696
|
onLongPressDay,
|
|
2697
|
+
onPressCell,
|
|
2245
2698
|
onPressEvent: handlePressEvent,
|
|
2246
2699
|
onLongPressEvent: handleLongPressEvent,
|
|
2247
2700
|
onPressMore,
|
|
2701
|
+
onCreateEvent,
|
|
2702
|
+
onSelectDrag,
|
|
2703
|
+
onDragEvent,
|
|
2704
|
+
onDragStart,
|
|
2705
|
+
eventStartEditable,
|
|
2706
|
+
eventOverlap,
|
|
2707
|
+
selectedDates,
|
|
2708
|
+
selectedRange,
|
|
2709
|
+
fillCellOnSelection,
|
|
2710
|
+
minDate,
|
|
2711
|
+
maxDate,
|
|
2712
|
+
isDateDisabled,
|
|
2248
2713
|
onChangeDate: handleChangeDate,
|
|
2249
2714
|
freeSwipe,
|
|
2250
2715
|
swipeEnabled,
|
|
@@ -2257,8 +2722,15 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2257
2722
|
hiddenDays,
|
|
2258
2723
|
locale,
|
|
2259
2724
|
activeDate,
|
|
2725
|
+
selectedDates,
|
|
2726
|
+
selectedRange,
|
|
2727
|
+
minDate,
|
|
2728
|
+
maxDate,
|
|
2729
|
+
isDateDisabled,
|
|
2260
2730
|
onPressDay,
|
|
2261
2731
|
onPressMonth,
|
|
2732
|
+
onSelectDrag,
|
|
2733
|
+
onCreateEvent,
|
|
2262
2734
|
classNames,
|
|
2263
2735
|
styles: styleOverrides
|
|
2264
2736
|
}) : mode === "schedule" ? /* @__PURE__ */ jsx(Agenda, {
|