@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.js
CHANGED
|
@@ -21,19 +21,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_MonthList = require("./MonthList-
|
|
24
|
+
const require_MonthList = require("./MonthList-DNT1LJkk.js");
|
|
25
25
|
let date_fns = require("date-fns");
|
|
26
26
|
let react = require("react");
|
|
27
27
|
let react_native_reanimated = require("react-native-reanimated");
|
|
28
28
|
react_native_reanimated = __toESM(react_native_reanimated);
|
|
29
29
|
let _super_calendar_core = require("@super-calendar/core");
|
|
30
30
|
let react_native = require("react-native");
|
|
31
|
+
let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
31
32
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
32
33
|
let _legendapp_list_react_native = require("@legendapp/list/react-native");
|
|
33
|
-
let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
34
34
|
//#region src/components/YearView.tsx
|
|
35
|
+
const isWeb$2 = react_native.Platform.OS === "web";
|
|
36
|
+
const DRAG_HOLD_MS = 400;
|
|
35
37
|
const FALLBACK_COLUMNS = 3;
|
|
36
|
-
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
38
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, classNames, styles: styleOverrides }) {
|
|
37
39
|
const theme = require_MonthList.useCalendarTheme();
|
|
38
40
|
const slot = require_MonthList.createSlots({
|
|
39
41
|
classNames,
|
|
@@ -46,6 +48,11 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
46
48
|
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
47
49
|
};
|
|
48
50
|
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
51
|
+
const monthWeeks = (0, react.useMemo)(() => months.map((month) => (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn, { hiddenDays })), [
|
|
52
|
+
months,
|
|
53
|
+
weekStartsOn,
|
|
54
|
+
hiddenDays
|
|
55
|
+
]);
|
|
49
56
|
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
50
57
|
date,
|
|
51
58
|
weekStartsOn,
|
|
@@ -53,13 +60,72 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
53
60
|
hiddenDays
|
|
54
61
|
]);
|
|
55
62
|
const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events.filter((e) => !(0, _super_calendar_core.isBackgroundEvent)(e))).keys() : []), [events]);
|
|
63
|
+
const sweepEnabled = onSelectDrag != null || onCreateEvent != null;
|
|
64
|
+
const [sweep, setSweep] = (0, react.useState)(null);
|
|
65
|
+
const sweepRef = (0, react.useRef)(sweep);
|
|
66
|
+
sweepRef.current = sweep;
|
|
67
|
+
const movedRef = (0, react.useRef)(false);
|
|
68
|
+
const suppressPressRef = (0, react.useRef)(false);
|
|
69
|
+
const isSelectable = (0, react.useCallback)((day) => (0, _super_calendar_core.isDateSelectable)(day, {
|
|
70
|
+
minDate,
|
|
71
|
+
maxDate,
|
|
72
|
+
isDateDisabled
|
|
73
|
+
}), [
|
|
74
|
+
minDate,
|
|
75
|
+
maxDate,
|
|
76
|
+
isDateDisabled
|
|
77
|
+
]);
|
|
78
|
+
const beginSweep = (0, react.useCallback)((day) => {
|
|
79
|
+
const time = (0, date_fns.startOfDay)(day).getTime();
|
|
80
|
+
suppressPressRef.current = false;
|
|
81
|
+
movedRef.current = false;
|
|
82
|
+
setSweep({
|
|
83
|
+
anchor: time,
|
|
84
|
+
hover: time
|
|
85
|
+
});
|
|
86
|
+
}, []);
|
|
87
|
+
const extendSweep = (0, react.useCallback)((day) => {
|
|
88
|
+
const current = sweepRef.current;
|
|
89
|
+
if (!current || !isSelectable(day)) return;
|
|
90
|
+
const time = (0, date_fns.startOfDay)(day).getTime();
|
|
91
|
+
if (time === current.hover) return;
|
|
92
|
+
movedRef.current = true;
|
|
93
|
+
setSweep((c) => c ? {
|
|
94
|
+
...c,
|
|
95
|
+
hover: time
|
|
96
|
+
} : c);
|
|
97
|
+
const [lo, hi] = current.anchor <= time ? [current.anchor, time] : [time, current.anchor];
|
|
98
|
+
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
99
|
+
}, [isSelectable, onSelectDrag]);
|
|
100
|
+
const finishSweep = (0, react.useCallback)(() => {
|
|
101
|
+
const current = sweepRef.current;
|
|
102
|
+
setSweep(null);
|
|
103
|
+
if (!current || !movedRef.current) return;
|
|
104
|
+
if (isWeb$2) suppressPressRef.current = true;
|
|
105
|
+
const range = (0, _super_calendar_core.monthCreateRange)(new Date(current.anchor), new Date(current.hover));
|
|
106
|
+
onCreateEvent?.(range.start, range.end);
|
|
107
|
+
}, [onCreateEvent]);
|
|
108
|
+
(0, react.useEffect)(() => {
|
|
109
|
+
if (!isWeb$2 || !sweepEnabled) return;
|
|
110
|
+
const target = globalThis;
|
|
111
|
+
target.addEventListener?.("pointerup", finishSweep);
|
|
112
|
+
return () => target.removeEventListener?.("pointerup", finishSweep);
|
|
113
|
+
}, [sweepEnabled, finishSweep]);
|
|
114
|
+
const pressDay = (0, react.useCallback)((day) => {
|
|
115
|
+
if (suppressPressRef.current) {
|
|
116
|
+
suppressPressRef.current = false;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
onPressDay?.(day);
|
|
120
|
+
}, [onPressDay]);
|
|
56
121
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ScrollView, {
|
|
57
122
|
onLayout: handleLayout,
|
|
58
123
|
showsVerticalScrollIndicator: true,
|
|
124
|
+
scrollEnabled: isWeb$2 || sweep == null,
|
|
59
125
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
60
126
|
...slot("grid", { base: styles$5.grid }),
|
|
61
|
-
children: months.map((month) => {
|
|
62
|
-
const weeks =
|
|
127
|
+
children: months.map((month, monthIndex) => {
|
|
128
|
+
const weeks = monthWeeks[monthIndex];
|
|
63
129
|
const title = (0, date_fns.format)(month, "MMMM", { locale });
|
|
64
130
|
const monthLabel = (0, date_fns.format)(month, "MMMM yyyy", { locale });
|
|
65
131
|
const titleText = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
@@ -97,53 +163,158 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
97
163
|
children: label
|
|
98
164
|
}, i))
|
|
99
165
|
}),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
166
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MiniMonthGrid, {
|
|
167
|
+
testID: `year-month-grid-${month.getMonth()}`,
|
|
168
|
+
month,
|
|
169
|
+
weeks,
|
|
170
|
+
sweepEnabled: sweepEnabled && !isWeb$2,
|
|
171
|
+
isSelectable,
|
|
172
|
+
onBeginSweep: beginSweep,
|
|
173
|
+
onExtendSweep: extendSweep,
|
|
174
|
+
onFinishSweep: finishSweep,
|
|
175
|
+
children: weeks.map((week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
176
|
+
...slot("week", { base: styles$5.week }),
|
|
177
|
+
children: week.map((day) => {
|
|
178
|
+
if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: styles$5.day }, day.toISOString());
|
|
179
|
+
const isToday = (0, _super_calendar_core.getIsToday)(day);
|
|
180
|
+
const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : isToday;
|
|
181
|
+
const hasEvents = eventDays.has((0, date_fns.startOfDay)(day).toISOString());
|
|
182
|
+
const state = (0, _super_calendar_core.daySelectionState)(day, {
|
|
183
|
+
selectedDates,
|
|
184
|
+
selectedRange
|
|
185
|
+
}, {
|
|
186
|
+
minDate,
|
|
187
|
+
maxDate,
|
|
188
|
+
isDateDisabled
|
|
189
|
+
});
|
|
190
|
+
const dayTime = (0, date_fns.startOfDay)(day).getTime();
|
|
191
|
+
const inSweep = sweep != null && dayTime >= Math.min(sweep.anchor, sweep.hover) && dayTime <= Math.max(sweep.anchor, sweep.hover);
|
|
192
|
+
const label = `${(0, date_fns.format)(day, "EEEE, d LLLL yyyy", { locale })}${isToday ? ", today" : ""}${state.isSelected ? ", selected" : ""}${state.isDisabled ? ", unavailable" : ""}${hasEvents ? ", has events" : ""}`;
|
|
193
|
+
const badge = (0, _super_calendar_core.dayBadgeKind)(state, isHighlighted);
|
|
194
|
+
const daySlot = slot("day", { base: styles$5.day });
|
|
195
|
+
const showBand = (0, _super_calendar_core.rangeBandKind)(state, true) !== "none";
|
|
196
|
+
const rounding = (0, _super_calendar_core.bandRounding)((0, _super_calendar_core.rangeBandKind)(state, false));
|
|
197
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
198
|
+
showBand || inSweep ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("rangeBand", {
|
|
199
|
+
base: [
|
|
200
|
+
styles$5.rangeBand,
|
|
201
|
+
rounding.start && styles$5.rangeBandStart,
|
|
202
|
+
rounding.end && styles$5.rangeBandEnd
|
|
203
|
+
],
|
|
204
|
+
themed: { backgroundColor: theme.colors.rangeBackground }
|
|
205
|
+
}) }) : null,
|
|
206
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
207
|
+
...slot("dayBadge", {
|
|
208
|
+
base: styles$5.dayBadge,
|
|
209
|
+
themed: badge === "none" ? void 0 : {
|
|
210
|
+
backgroundColor: badge === "today" ? theme.colors.todayBackground : theme.colors.selectedBackground,
|
|
211
|
+
borderRadius: theme.todayBadgeRadius
|
|
212
|
+
}
|
|
213
|
+
}),
|
|
214
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
215
|
+
...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 }] }),
|
|
216
|
+
allowFontScaling: false,
|
|
217
|
+
children: day.getDate()
|
|
218
|
+
})
|
|
219
|
+
}),
|
|
220
|
+
hasEvents ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("eventDot", {
|
|
221
|
+
base: styles$5.eventDot,
|
|
222
|
+
themed: { backgroundColor: badge === "none" ? theme.colors.todayBackground : theme.colors.todayText }
|
|
223
|
+
}) }) : null
|
|
224
|
+
] });
|
|
225
|
+
return onPressDay || sweepEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
226
|
+
onPress: () => pressDay(day),
|
|
227
|
+
disabled: state.isDisabled,
|
|
228
|
+
accessibilityRole: "button",
|
|
229
|
+
accessibilityLabel: label,
|
|
230
|
+
...isWeb$2 && sweepEnabled ? {
|
|
231
|
+
onPointerDown: () => {
|
|
232
|
+
if (isSelectable(day)) beginSweep(day);
|
|
233
|
+
},
|
|
234
|
+
onPointerEnter: () => extendSweep(day)
|
|
235
|
+
} : null,
|
|
236
|
+
...daySlot,
|
|
237
|
+
children: content
|
|
238
|
+
}, day.toISOString()) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
239
|
+
accessible: true,
|
|
240
|
+
accessibilityLabel: label,
|
|
241
|
+
...daySlot,
|
|
242
|
+
children: content
|
|
243
|
+
}, day.toISOString());
|
|
244
|
+
})
|
|
245
|
+
}, week[0].toISOString()))
|
|
246
|
+
})
|
|
136
247
|
]
|
|
137
248
|
}, month.toISOString());
|
|
138
249
|
})
|
|
139
250
|
})
|
|
140
251
|
});
|
|
141
252
|
}
|
|
253
|
+
function MiniMonthGrid({ testID, month, weeks, sweepEnabled, isSelectable, onBeginSweep, onExtendSweep, onFinishSweep, children }) {
|
|
254
|
+
const sizeRef = (0, react.useRef)({
|
|
255
|
+
width: 0,
|
|
256
|
+
height: 0
|
|
257
|
+
});
|
|
258
|
+
const onLayout = (0, react.useCallback)((event) => {
|
|
259
|
+
const { width, height } = event.nativeEvent.layout;
|
|
260
|
+
sizeRef.current = {
|
|
261
|
+
width,
|
|
262
|
+
height
|
|
263
|
+
};
|
|
264
|
+
}, []);
|
|
265
|
+
const latest = (0, react.useRef)({
|
|
266
|
+
month,
|
|
267
|
+
weeks,
|
|
268
|
+
isSelectable,
|
|
269
|
+
onBeginSweep,
|
|
270
|
+
onExtendSweep,
|
|
271
|
+
onFinishSweep
|
|
272
|
+
});
|
|
273
|
+
latest.current = {
|
|
274
|
+
month,
|
|
275
|
+
weeks,
|
|
276
|
+
isSelectable,
|
|
277
|
+
onBeginSweep,
|
|
278
|
+
onExtendSweep,
|
|
279
|
+
onFinishSweep
|
|
280
|
+
};
|
|
281
|
+
const dayAt = (0, react.useCallback)((x, y) => {
|
|
282
|
+
const { width, height } = sizeRef.current;
|
|
283
|
+
const { month: current, weeks: rows, isSelectable: selectable } = latest.current;
|
|
284
|
+
if (width <= 0 || height <= 0 || rows.length === 0) return null;
|
|
285
|
+
const row = Math.min(rows.length - 1, Math.max(0, Math.floor(y / (height / rows.length))));
|
|
286
|
+
const cols = rows[row].length;
|
|
287
|
+
const col = Math.min(cols - 1, Math.max(0, Math.floor(x / (width / cols))));
|
|
288
|
+
const day = rows[row][col];
|
|
289
|
+
if (!day) return null;
|
|
290
|
+
if (day.getMonth() !== current.getMonth()) return null;
|
|
291
|
+
return selectable(day) ? day : null;
|
|
292
|
+
}, []);
|
|
293
|
+
const gesture = (0, react.useMemo)(() => {
|
|
294
|
+
if (!sweepEnabled) return void 0;
|
|
295
|
+
return react_native_gesture_handler.Gesture.Pan().activateAfterLongPress(DRAG_HOLD_MS).runOnJS(true).onStart((event) => {
|
|
296
|
+
const day = dayAt(event.x, event.y);
|
|
297
|
+
if (day) latest.current.onBeginSweep(day);
|
|
298
|
+
}).onUpdate((event) => {
|
|
299
|
+
const day = dayAt(event.x, event.y);
|
|
300
|
+
if (day) latest.current.onExtendSweep(day);
|
|
301
|
+
}).onFinalize(() => latest.current.onFinishSweep());
|
|
302
|
+
}, [sweepEnabled, dayAt]);
|
|
303
|
+
const grid = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
304
|
+
testID,
|
|
305
|
+
onLayout,
|
|
306
|
+
children
|
|
307
|
+
});
|
|
308
|
+
return gesture ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
|
|
309
|
+
gesture,
|
|
310
|
+
children: grid
|
|
311
|
+
}) : grid;
|
|
312
|
+
}
|
|
142
313
|
/**
|
|
143
314
|
* A year at a glance: the twelve months as compact mini grids, with today
|
|
144
315
|
* highlighted and a dot under days that hold events. Tap a day or a month
|
|
145
|
-
* title to drill into a denser view
|
|
146
|
-
* `mode="year"`.
|
|
316
|
+
* title to drill into a denser view, or hold and drag to sweep out a date
|
|
317
|
+
* range. It's the view `Calendar` renders for `mode="year"`.
|
|
147
318
|
*
|
|
148
319
|
* @example
|
|
149
320
|
* ```tsx
|
|
@@ -185,7 +356,28 @@ const styles$5 = react_native.StyleSheet.create({
|
|
|
185
356
|
alignItems: "center",
|
|
186
357
|
justifyContent: "center"
|
|
187
358
|
},
|
|
359
|
+
dayBadge: {
|
|
360
|
+
width: "100%",
|
|
361
|
+
height: "100%",
|
|
362
|
+
alignItems: "center",
|
|
363
|
+
justifyContent: "center"
|
|
364
|
+
},
|
|
188
365
|
dayText: { fontSize: 11 },
|
|
366
|
+
rangeBand: {
|
|
367
|
+
position: "absolute",
|
|
368
|
+
top: 0,
|
|
369
|
+
bottom: 0,
|
|
370
|
+
left: 0,
|
|
371
|
+
right: 0
|
|
372
|
+
},
|
|
373
|
+
rangeBandStart: {
|
|
374
|
+
borderTopLeftRadius: 999,
|
|
375
|
+
borderBottomLeftRadius: 999
|
|
376
|
+
},
|
|
377
|
+
rangeBandEnd: {
|
|
378
|
+
borderTopRightRadius: 999,
|
|
379
|
+
borderBottomRightRadius: 999
|
|
380
|
+
},
|
|
189
381
|
eventDot: {
|
|
190
382
|
position: "absolute",
|
|
191
383
|
bottom: 1,
|
|
@@ -565,6 +757,93 @@ const styles$2 = react_native.StyleSheet.create({
|
|
|
565
757
|
chip: { minHeight: 18 }
|
|
566
758
|
});
|
|
567
759
|
//#endregion
|
|
760
|
+
//#region src/components/MultiDayMovePreview.tsx
|
|
761
|
+
const noop$1 = () => {};
|
|
762
|
+
const MIN_EVENT_HEIGHT$1 = 32;
|
|
763
|
+
function MultiDayMovePreview(props) {
|
|
764
|
+
const { move, days } = props;
|
|
765
|
+
const dayOffsets = (0, react.useMemo)(() => days.map((day) => (0, date_fns.differenceInCalendarDays)(day, days[move.dayIndex]) * 1440), [days, move]);
|
|
766
|
+
return days.map((day, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PreviewDay, {
|
|
767
|
+
...props,
|
|
768
|
+
dayOffsets,
|
|
769
|
+
index,
|
|
770
|
+
dayStart: (0, date_fns.startOfDay)(day).getTime(),
|
|
771
|
+
dayEnd: (0, date_fns.addDays)((0, date_fns.startOfDay)(day), 1).getTime()
|
|
772
|
+
}, day.toISOString()));
|
|
773
|
+
}
|
|
774
|
+
function PreviewDay({ move, cellHeight, dayWidth, hourColumnWidth, minHour, mode, renderEvent: RenderEventComponent, dayOffsets, index, dayStart, dayEnd }) {
|
|
775
|
+
const theme = require_MonthList.useCalendarTheme();
|
|
776
|
+
const slot = require_MonthList.useSlots();
|
|
777
|
+
const { offsetX, offsetY, lifted, dayIndex, event } = move;
|
|
778
|
+
const duration = event.end.getTime() - event.start.getTime();
|
|
779
|
+
const startTimestamp = event.start.getTime();
|
|
780
|
+
const segment = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
781
|
+
const columnDelta = dayWidth > 0 ? Math.round(offsetX.value / dayWidth) : 0;
|
|
782
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayOffsets.length - 1);
|
|
783
|
+
const minuteDelta = cellHeight.value > 0 ? offsetY.value / cellHeight.value * 60 : 0;
|
|
784
|
+
const start = (0, _super_calendar_core.shiftMinutes)(new Date(startTimestamp), dayOffsets[target] + minuteDelta).getTime();
|
|
785
|
+
const end = start + duration;
|
|
786
|
+
const visible = !lifted.value && start < dayEnd && end > dayStart;
|
|
787
|
+
return {
|
|
788
|
+
top: (Math.max(start, dayStart) - dayStart) / 36e5,
|
|
789
|
+
hours: visible ? Math.max((Math.min(end, dayEnd) - Math.max(start, dayStart)) / 36e5, .25) : 0,
|
|
790
|
+
continuesBefore: start < dayStart,
|
|
791
|
+
continuesAfter: end > dayEnd
|
|
792
|
+
};
|
|
793
|
+
}, [
|
|
794
|
+
dayWidth,
|
|
795
|
+
dayIndex,
|
|
796
|
+
dayOffsets,
|
|
797
|
+
startTimestamp,
|
|
798
|
+
duration,
|
|
799
|
+
dayStart,
|
|
800
|
+
dayEnd
|
|
801
|
+
]);
|
|
802
|
+
const boxHeight = (0, react_native_reanimated.useDerivedValue)(() => segment.value.hours > 0 ? Math.max(segment.value.hours * cellHeight.value, MIN_EVENT_HEIGHT$1) : 0);
|
|
803
|
+
const style = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
804
|
+
top: (segment.value.top - minHour) * cellHeight.value,
|
|
805
|
+
height: boxHeight.value,
|
|
806
|
+
opacity: boxHeight.value > 0 ? 1 : 0
|
|
807
|
+
}), [minHour]);
|
|
808
|
+
const [continuation, setContinuation] = (0, react.useState)(() => ({
|
|
809
|
+
continuesBefore: segment.value.continuesBefore,
|
|
810
|
+
continuesAfter: segment.value.continuesAfter
|
|
811
|
+
}));
|
|
812
|
+
(0, react_native_reanimated.useAnimatedReaction)(() => ({
|
|
813
|
+
continuesBefore: segment.value.continuesBefore,
|
|
814
|
+
continuesAfter: segment.value.continuesAfter
|
|
815
|
+
}), (next, previous) => {
|
|
816
|
+
if (previous && (next.continuesBefore !== previous.continuesBefore || next.continuesAfter !== previous.continuesAfter)) (0, react_native_reanimated.runOnJS)(setContinuation)(next);
|
|
817
|
+
});
|
|
818
|
+
const eventSlot = slot("event", { themed: theme.containers.timeGridEvent });
|
|
819
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
820
|
+
...eventSlot,
|
|
821
|
+
testID: "multi-day-move-preview",
|
|
822
|
+
pointerEvents: "none",
|
|
823
|
+
accessibilityElementsHidden: true,
|
|
824
|
+
importantForAccessibility: "no-hide-descendants",
|
|
825
|
+
style: [
|
|
826
|
+
{
|
|
827
|
+
position: "absolute",
|
|
828
|
+
overflow: "hidden",
|
|
829
|
+
padding: 2,
|
|
830
|
+
left: hourColumnWidth + index * dayWidth,
|
|
831
|
+
width: dayWidth,
|
|
832
|
+
zIndex: 100
|
|
833
|
+
},
|
|
834
|
+
eventSlot.style,
|
|
835
|
+
style
|
|
836
|
+
],
|
|
837
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
838
|
+
event,
|
|
839
|
+
mode,
|
|
840
|
+
boxHeight,
|
|
841
|
+
...continuation,
|
|
842
|
+
onPress: noop$1
|
|
843
|
+
})
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
//#endregion
|
|
568
847
|
//#region src/components/TimeGrid.tsx
|
|
569
848
|
const isWeb$1 = react_native.Platform.OS === "web";
|
|
570
849
|
const MINUTES_PER_HOUR$1 = 60;
|
|
@@ -590,6 +869,49 @@ const EDGE_ZONE_PX = 36;
|
|
|
590
869
|
const EdgePagingContext = (0, react.createContext)(null);
|
|
591
870
|
const noop = () => {};
|
|
592
871
|
/**
|
|
872
|
+
* The tail of a move that runs past midnight, drawn at the top of the next day's
|
|
873
|
+
* column so the drop reads on both days before the finger lifts. Mounted only
|
|
874
|
+
* while a drag is actually spilling (see `spillHeight`), so an idle grid pays
|
|
875
|
+
* nothing for it; its geometry is driven on the UI thread from there.
|
|
876
|
+
*/
|
|
877
|
+
function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, slotProps }) {
|
|
878
|
+
const RenderEventComponent = renderEvent;
|
|
879
|
+
const style = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
880
|
+
height: spillHeight.value,
|
|
881
|
+
opacity: spillHeight.value > 0 ? 1 : 0,
|
|
882
|
+
zIndex: spillHeight.value > 0 ? DRAG_EVENT_Z : 0,
|
|
883
|
+
transform: [{ translateX: moveOffsetX.value + nextDayDirection * dayWidth }, { translateY: -minHour * cellHeight.value }]
|
|
884
|
+
}), [
|
|
885
|
+
dayWidth,
|
|
886
|
+
nextDayDirection,
|
|
887
|
+
minHour
|
|
888
|
+
]);
|
|
889
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
890
|
+
...slotProps,
|
|
891
|
+
accessibilityElementsHidden: true,
|
|
892
|
+
importantForAccessibility: "no-hide-descendants",
|
|
893
|
+
style: [
|
|
894
|
+
styles$1.eventBox,
|
|
895
|
+
styles$1.nonInteractive,
|
|
896
|
+
{
|
|
897
|
+
left: dayLeftPx,
|
|
898
|
+
width: dayWidth,
|
|
899
|
+
top: 0
|
|
900
|
+
},
|
|
901
|
+
slotProps.style,
|
|
902
|
+
style
|
|
903
|
+
],
|
|
904
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
905
|
+
event,
|
|
906
|
+
mode,
|
|
907
|
+
boxHeight: spillHeight,
|
|
908
|
+
continuesBefore: true,
|
|
909
|
+
continuesAfter: false,
|
|
910
|
+
onPress: noop
|
|
911
|
+
})
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
593
915
|
* The floating copy of a dragged event, rendered above the pager so a cross-week
|
|
594
916
|
* drag stays visible after its source page pages away. Position, size, and
|
|
595
917
|
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
@@ -619,7 +941,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
|
619
941
|
});
|
|
620
942
|
}
|
|
621
943
|
const HOUR_LABEL_TOP_INSET = 12;
|
|
622
|
-
function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
|
|
944
|
+
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 }) {
|
|
623
945
|
const RenderEventComponent = renderEvent;
|
|
624
946
|
const theme = require_MonthList.useCalendarTheme();
|
|
625
947
|
const slot = require_MonthList.useSlots();
|
|
@@ -640,6 +962,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
640
962
|
const resizeDelta = (0, react_native_reanimated.useSharedValue)(0);
|
|
641
963
|
const resizeStartDelta = (0, react_native_reanimated.useSharedValue)(0);
|
|
642
964
|
const dragZ = (0, react_native_reanimated.useSharedValue)(0);
|
|
965
|
+
const moving = (0, react_native_reanimated.useSharedValue)(0);
|
|
643
966
|
const edgeDir = (0, react_native_reanimated.useSharedValue)(0);
|
|
644
967
|
const lifted = (0, react_native_reanimated.useSharedValue)(0);
|
|
645
968
|
const grabX = (0, react_native_reanimated.useSharedValue)(0);
|
|
@@ -648,17 +971,52 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
648
971
|
const liveAbsY = (0, react_native_reanimated.useSharedValue)(0);
|
|
649
972
|
const startHours = positioned.startHours;
|
|
650
973
|
const durationHours = positioned.durationHours;
|
|
974
|
+
const ownsStart = !positioned.continuesBefore;
|
|
975
|
+
const multiDay = positioned.continuesBefore || positioned.continuesAfter;
|
|
976
|
+
const hiddenForMove = positioned.event === movingEvent;
|
|
977
|
+
const dragStartSV = (0, react_native_reanimated.useDerivedValue)(() => ({
|
|
978
|
+
minutes: startHours * MINUTES_PER_HOUR$1,
|
|
979
|
+
ownsStart
|
|
980
|
+
}), [startHours, ownsStart]);
|
|
651
981
|
const boxHeight = (0, react_native_reanimated.useDerivedValue)(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
|
|
652
|
-
const
|
|
653
|
-
top
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
982
|
+
const visibleBoxHeight = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
983
|
+
const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
984
|
+
const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
|
|
985
|
+
return Math.max(Math.min(boxHeight.value, dayEnd - top), MIN_EVENT_HEIGHT);
|
|
986
|
+
}, [startHours, minHour]);
|
|
987
|
+
const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => {
|
|
988
|
+
return {
|
|
989
|
+
top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
990
|
+
height: visibleBoxHeight.value,
|
|
991
|
+
transform: [{ translateX: moveOffsetX.value }],
|
|
992
|
+
zIndex: dragZ.value
|
|
993
|
+
};
|
|
994
|
+
}, [startHours, minHour]);
|
|
995
|
+
const spillHeight = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
996
|
+
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
997
|
+
const overflowHours = startHours + moveOffset.value / cellHeight.value + durationHours - HOURS_PER_DAY;
|
|
998
|
+
if (overflowHours <= 0) return 0;
|
|
999
|
+
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
1000
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
1001
|
+
const next = target + nextDayDirection;
|
|
1002
|
+
if (next < 0 || next >= dayCount || dayOrdinals[next] - dayOrdinals[target] !== 1) return 0;
|
|
1003
|
+
return Math.min(overflowHours, maxHour - minHour) * cellHeight.value;
|
|
1004
|
+
}, [
|
|
658
1005
|
startHours,
|
|
659
1006
|
durationHours,
|
|
660
|
-
minHour
|
|
1007
|
+
minHour,
|
|
1008
|
+
maxHour,
|
|
1009
|
+
dayWidth,
|
|
1010
|
+
dayIndex,
|
|
1011
|
+
dayCount,
|
|
1012
|
+
dayOrdinals,
|
|
1013
|
+
nextDayDirection,
|
|
1014
|
+
multiDay
|
|
661
1015
|
]);
|
|
1016
|
+
const [previewMounted, setPreviewMounted] = (0, react.useState)(false);
|
|
1017
|
+
(0, react_native_reanimated.useAnimatedReaction)(() => spillHeight.value > 0, (spilling, previous) => {
|
|
1018
|
+
if (previous !== null && spilling !== previous) (0, react_native_reanimated.runOnJS)(setPreviewMounted)(spilling);
|
|
1019
|
+
});
|
|
662
1020
|
(0, react.useEffect)(() => {
|
|
663
1021
|
moveOffset.value = 0;
|
|
664
1022
|
moveOffsetX.value = 0;
|
|
@@ -674,11 +1032,13 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
674
1032
|
]);
|
|
675
1033
|
const latest = (0, react.useRef)({
|
|
676
1034
|
event: positioned.event,
|
|
1035
|
+
eventIndex,
|
|
677
1036
|
onDragEvent,
|
|
678
1037
|
onDragStart
|
|
679
1038
|
});
|
|
680
1039
|
latest.current = {
|
|
681
1040
|
event: positioned.event,
|
|
1041
|
+
eventIndex,
|
|
682
1042
|
onDragEvent,
|
|
683
1043
|
onDragStart
|
|
684
1044
|
};
|
|
@@ -701,11 +1061,41 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
701
1061
|
snapBack();
|
|
702
1062
|
return;
|
|
703
1063
|
}
|
|
704
|
-
if (handler(event, next.start, next.end) === false)
|
|
705
|
-
|
|
1064
|
+
if (handler(event, next.start, next.end) === false) {
|
|
1065
|
+
snapBack();
|
|
1066
|
+
onMovePreview(null);
|
|
1067
|
+
} else if (multiDay && deltaStartMin === deltaEndMin) onMovePreview((move) => move ? {
|
|
1068
|
+
...move,
|
|
1069
|
+
phase: "dropped"
|
|
1070
|
+
} : null);
|
|
1071
|
+
}, [
|
|
1072
|
+
snapMinutes,
|
|
1073
|
+
snapBack,
|
|
1074
|
+
multiDay,
|
|
1075
|
+
onMovePreview
|
|
1076
|
+
]);
|
|
706
1077
|
const notifyDragStart = (0, react.useCallback)(() => {
|
|
707
1078
|
latest.current.onDragStart?.(latest.current.event);
|
|
708
1079
|
}, []);
|
|
1080
|
+
const beginMovePreview = (0, react.useCallback)(() => {
|
|
1081
|
+
if (multiDay) onMovePreview({
|
|
1082
|
+
event: latest.current.event,
|
|
1083
|
+
eventIndex: latest.current.eventIndex,
|
|
1084
|
+
phase: "dragging",
|
|
1085
|
+
dayIndex,
|
|
1086
|
+
offsetX: moveOffsetX,
|
|
1087
|
+
offsetY: moveOffset,
|
|
1088
|
+
lifted
|
|
1089
|
+
});
|
|
1090
|
+
}, [
|
|
1091
|
+
multiDay,
|
|
1092
|
+
onMovePreview,
|
|
1093
|
+
dayIndex,
|
|
1094
|
+
moveOffsetX,
|
|
1095
|
+
moveOffset,
|
|
1096
|
+
lifted
|
|
1097
|
+
]);
|
|
1098
|
+
const endMovePreview = (0, react.useCallback)(() => onMovePreview(null), [onMovePreview]);
|
|
709
1099
|
const dwellTimer = (0, react.useRef)(null);
|
|
710
1100
|
const disarmEdge = (0, react.useCallback)(() => {
|
|
711
1101
|
if (dwellTimer.current) {
|
|
@@ -749,12 +1139,14 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
749
1139
|
const moveGesture = (0, react.useMemo)(() => {
|
|
750
1140
|
const pan = react_native_gesture_handler.Gesture.Pan().enabled(canMove).onStart((event) => {
|
|
751
1141
|
dragZ.value = DRAG_EVENT_Z;
|
|
1142
|
+
moving.value = 1;
|
|
752
1143
|
edgeDir.value = 0;
|
|
753
1144
|
lifted.value = 0;
|
|
754
1145
|
grabX.value = event.x;
|
|
755
1146
|
grabY.value = event.y;
|
|
756
1147
|
liveAbsX.value = event.absoluteX;
|
|
757
1148
|
liveAbsY.value = event.absoluteY;
|
|
1149
|
+
(0, react_native_reanimated.runOnJS)(beginMovePreview)();
|
|
758
1150
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
759
1151
|
}).onUpdate((event) => {
|
|
760
1152
|
liveAbsX.value = event.absoluteX;
|
|
@@ -762,8 +1154,11 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
762
1154
|
if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
|
|
763
1155
|
ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
|
|
764
1156
|
ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
|
|
765
|
-
} else {
|
|
766
|
-
|
|
1157
|
+
} else if (cellHeight.value > 0) {
|
|
1158
|
+
const { minutes: startMinutes, ownsStart } = dragStartSV.value;
|
|
1159
|
+
const dragged = startMinutes + event.translationY / cellHeight.value * MINUTES_PER_HOUR$1;
|
|
1160
|
+
const held = ownsStart ? (0, _super_calendar_core.clampMoveStartMinutes)(dragged, minHour, maxHour, snapMinutes) : dragged;
|
|
1161
|
+
moveOffset.value = (held - startMinutes) / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
767
1162
|
moveOffsetX.value = event.translationX;
|
|
768
1163
|
}
|
|
769
1164
|
if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
|
|
@@ -777,26 +1172,36 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
777
1172
|
}
|
|
778
1173
|
}).onEnd((event) => {
|
|
779
1174
|
if (lifted.value) return;
|
|
780
|
-
const
|
|
1175
|
+
const { minutes: startMinutes, ownsStart } = dragStartSV.value;
|
|
1176
|
+
const snapped = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
|
|
1177
|
+
const minuteDelta = ownsStart ? (0, _super_calendar_core.clampMoveStartMinutes)(startMinutes + snapped, minHour, maxHour, snapMinutes) - startMinutes : snapped;
|
|
781
1178
|
const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
|
|
782
1179
|
const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
|
|
783
1180
|
const dayDelta = targetDay - dayIndex;
|
|
784
1181
|
if (minuteDelta === 0 && dayDelta === 0) {
|
|
785
1182
|
moveOffset.value = 0;
|
|
786
1183
|
moveOffsetX.value = 0;
|
|
1184
|
+
(0, react_native_reanimated.runOnJS)(endMovePreview)();
|
|
787
1185
|
return;
|
|
788
1186
|
}
|
|
789
1187
|
moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
790
1188
|
moveOffsetX.value = dayDelta * dayWidth;
|
|
791
1189
|
const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
792
1190
|
(0, react_native_reanimated.runOnJS)(commitDrag)(totalDelta, totalDelta);
|
|
793
|
-
}).onFinalize(() => {
|
|
1191
|
+
}).onFinalize((_event, success) => {
|
|
794
1192
|
dragZ.value = 0;
|
|
795
1193
|
if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
|
|
796
1194
|
(0, react_native_reanimated.runOnJS)(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
|
|
797
1195
|
moveOffset.value = 0;
|
|
798
1196
|
moveOffsetX.value = 0;
|
|
799
1197
|
lifted.value = 0;
|
|
1198
|
+
(0, react_native_reanimated.runOnJS)(endMovePreview)();
|
|
1199
|
+
}
|
|
1200
|
+
moving.value = 0;
|
|
1201
|
+
if (multiDay && !success) {
|
|
1202
|
+
moveOffset.value = 0;
|
|
1203
|
+
moveOffsetX.value = 0;
|
|
1204
|
+
(0, react_native_reanimated.runOnJS)(endMovePreview)();
|
|
800
1205
|
}
|
|
801
1206
|
(0, react_native_reanimated.runOnJS)(releaseEdge)();
|
|
802
1207
|
});
|
|
@@ -808,6 +1213,10 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
808
1213
|
moveOffset,
|
|
809
1214
|
moveOffsetX,
|
|
810
1215
|
dragZ,
|
|
1216
|
+
moving,
|
|
1217
|
+
dragStartSV,
|
|
1218
|
+
minHour,
|
|
1219
|
+
maxHour,
|
|
811
1220
|
edgeDir,
|
|
812
1221
|
lifted,
|
|
813
1222
|
grabX,
|
|
@@ -825,6 +1234,9 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
825
1234
|
dayCount,
|
|
826
1235
|
dayOrdinals,
|
|
827
1236
|
commitDrag,
|
|
1237
|
+
multiDay,
|
|
1238
|
+
beginMovePreview,
|
|
1239
|
+
endMovePreview,
|
|
828
1240
|
notifyDragStart,
|
|
829
1241
|
onEdgeAdvance,
|
|
830
1242
|
armEdge,
|
|
@@ -938,12 +1350,16 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
938
1350
|
});
|
|
939
1351
|
const box = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native_reanimated.default.View, {
|
|
940
1352
|
...eventSlot,
|
|
941
|
-
style: [
|
|
1353
|
+
style: [
|
|
1354
|
+
eventSlot.style,
|
|
1355
|
+
boxStyle,
|
|
1356
|
+
hiddenForMove ? { opacity: 0 } : null
|
|
1357
|
+
],
|
|
942
1358
|
children: [
|
|
943
1359
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
944
1360
|
event: positioned.event,
|
|
945
1361
|
mode,
|
|
946
|
-
boxHeight,
|
|
1362
|
+
boxHeight: visibleBoxHeight,
|
|
947
1363
|
continuesBefore: positioned.continuesBefore,
|
|
948
1364
|
continuesAfter: positioned.continuesAfter,
|
|
949
1365
|
accessibilityActions,
|
|
@@ -968,10 +1384,22 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
968
1384
|
]
|
|
969
1385
|
});
|
|
970
1386
|
if (!canMove) return box;
|
|
971
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
|
|
1387
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
|
|
972
1388
|
gesture: moveGesture,
|
|
973
1389
|
children: box
|
|
974
|
-
})
|
|
1390
|
+
}), previewMounted && !positioned.continuesAfter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoveSpillPreview, {
|
|
1391
|
+
spillHeight,
|
|
1392
|
+
moveOffsetX,
|
|
1393
|
+
cellHeight,
|
|
1394
|
+
dayLeftPx,
|
|
1395
|
+
dayWidth,
|
|
1396
|
+
nextDayDirection,
|
|
1397
|
+
minHour,
|
|
1398
|
+
event: positioned.event,
|
|
1399
|
+
mode,
|
|
1400
|
+
renderEvent,
|
|
1401
|
+
slotProps: slot("event", { themed: theme.containers.timeGridEvent })
|
|
1402
|
+
}) : null] });
|
|
975
1403
|
}
|
|
976
1404
|
const HourRow = ({ hour, minHour, cellHeight, hourColumnWidth, label, ampm, hourComponent }) => {
|
|
977
1405
|
const theme = require_MonthList.useCalendarTheme();
|
|
@@ -1128,6 +1556,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1128
1556
|
const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
|
|
1129
1557
|
const dayOrdinals = (0, react.useMemo)(() => days.map((day) => (0, date_fns.differenceInCalendarDays)(day, days[0])), [days]);
|
|
1130
1558
|
const dayLayouts = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
|
|
1559
|
+
const [multiDayMove, setMultiDayMove] = (0, react.useState)(null);
|
|
1560
|
+
const movingEvent = multiDayMove ? events.find((event, index) => keyExtractor(event, index) === keyExtractor(multiDayMove.event, multiDayMove.eventIndex)) ?? null : null;
|
|
1561
|
+
(0, react.useEffect)(() => {
|
|
1562
|
+
if (multiDayMove?.phase === "dropped" && (!movingEvent || movingEvent.start.getTime() !== multiDayMove.event.start.getTime() || movingEvent.end.getTime() !== multiDayMove.event.end.getTime())) setMultiDayMove(null);
|
|
1563
|
+
}, [multiDayMove, movingEvent]);
|
|
1131
1564
|
const cellDateFromTouch = (event) => {
|
|
1132
1565
|
const { locationX, locationY } = event.nativeEvent;
|
|
1133
1566
|
const dayIndex = days.length === 1 ? 0 : Math.floor(locationX / dayWidth);
|
|
@@ -1441,10 +1874,16 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1441
1874
|
const columnWidth = dayWidth / positioned.columns;
|
|
1442
1875
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnimatedEventBox, {
|
|
1443
1876
|
positioned,
|
|
1877
|
+
eventIndex: events.indexOf(positioned.event),
|
|
1878
|
+
movingEvent,
|
|
1879
|
+
onMovePreview: setMultiDayMove,
|
|
1444
1880
|
cellHeight: heightSource,
|
|
1445
1881
|
minHour,
|
|
1882
|
+
maxHour,
|
|
1446
1883
|
left: dayLeft(dayIndex) + positioned.column * columnWidth,
|
|
1447
1884
|
width: columnWidth,
|
|
1885
|
+
dayLeftPx: dayLeft(dayIndex),
|
|
1886
|
+
nextDayDirection: isRTL ? -1 : 1,
|
|
1448
1887
|
dayWidth,
|
|
1449
1888
|
dayIndex,
|
|
1450
1889
|
dayCount: days.length,
|
|
@@ -1463,6 +1902,16 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1463
1902
|
onEdgeAdvance
|
|
1464
1903
|
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
1465
1904
|
})),
|
|
1905
|
+
multiDayMove ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiDayMovePreview, {
|
|
1906
|
+
move: multiDayMove,
|
|
1907
|
+
days,
|
|
1908
|
+
cellHeight: heightSource,
|
|
1909
|
+
dayWidth,
|
|
1910
|
+
hourColumnWidth,
|
|
1911
|
+
minHour,
|
|
1912
|
+
mode,
|
|
1913
|
+
renderEvent
|
|
1914
|
+
}) : null,
|
|
1466
1915
|
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NowIndicator, {
|
|
1467
1916
|
cellHeight: heightSource,
|
|
1468
1917
|
nowHours,
|
|
@@ -1528,6 +1977,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1528
1977
|
containerWidth,
|
|
1529
1978
|
hourColumnWidth,
|
|
1530
1979
|
minHour: clampedMinHour,
|
|
1980
|
+
maxHour: clampedMaxHour,
|
|
1531
1981
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1532
1982
|
onDragEvent,
|
|
1533
1983
|
onChangeDate
|
|
@@ -1543,7 +1993,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1543
1993
|
setEdgePagingLock(false);
|
|
1544
1994
|
}, [ghostVisible]);
|
|
1545
1995
|
const commitLiftedDrop = (0, react.useCallback)((ghostLocalX, ghostLocalY) => {
|
|
1546
|
-
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1996
|
+
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, maxHour: max, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1547
1997
|
const ev = liftedEventRef.current;
|
|
1548
1998
|
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1549
1999
|
clearLift();
|
|
@@ -1551,7 +2001,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1551
2001
|
const dayWidth = (cw - hcw) / days.length;
|
|
1552
2002
|
const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
|
|
1553
2003
|
const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1554
|
-
const minutes = Math.round(rawMinutes / snap) * snap;
|
|
2004
|
+
const minutes = (0, _super_calendar_core.clampMoveStartMinutes)(Math.round(rawMinutes / snap) * snap, min, max, snap);
|
|
1555
2005
|
const start = new Date(days[col]);
|
|
1556
2006
|
start.setHours(0, 0, 0, 0);
|
|
1557
2007
|
start.setMinutes(minutes);
|
|
@@ -1629,6 +2079,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1629
2079
|
containerWidth,
|
|
1630
2080
|
hourColumnWidth,
|
|
1631
2081
|
minHour: clampedMinHour,
|
|
2082
|
+
maxHour: clampedMaxHour,
|
|
1632
2083
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1633
2084
|
onDragEvent,
|
|
1634
2085
|
onChangeDate
|
|
@@ -2171,7 +2622,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
2171
2622
|
* }
|
|
2172
2623
|
* ```
|
|
2173
2624
|
*/
|
|
2174
|
-
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 }) {
|
|
2625
|
+
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 }) {
|
|
2175
2626
|
const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
|
|
2176
2627
|
const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
|
|
2177
2628
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -2258,6 +2709,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2258
2709
|
disableMonthEventCellPress,
|
|
2259
2710
|
isRTL,
|
|
2260
2711
|
showSixWeeks,
|
|
2712
|
+
showTitle,
|
|
2261
2713
|
activeDate,
|
|
2262
2714
|
renderHeaderForMonthView,
|
|
2263
2715
|
renderCustomDateForMonth,
|
|
@@ -2266,9 +2718,22 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2266
2718
|
keyExtractor,
|
|
2267
2719
|
onPressDay,
|
|
2268
2720
|
onLongPressDay,
|
|
2721
|
+
onPressCell,
|
|
2269
2722
|
onPressEvent: handlePressEvent,
|
|
2270
2723
|
onLongPressEvent: handleLongPressEvent,
|
|
2271
2724
|
onPressMore,
|
|
2725
|
+
onCreateEvent,
|
|
2726
|
+
onSelectDrag,
|
|
2727
|
+
onDragEvent,
|
|
2728
|
+
onDragStart,
|
|
2729
|
+
eventStartEditable,
|
|
2730
|
+
eventOverlap,
|
|
2731
|
+
selectedDates,
|
|
2732
|
+
selectedRange,
|
|
2733
|
+
fillCellOnSelection,
|
|
2734
|
+
minDate,
|
|
2735
|
+
maxDate,
|
|
2736
|
+
isDateDisabled,
|
|
2272
2737
|
onChangeDate: handleChangeDate,
|
|
2273
2738
|
freeSwipe,
|
|
2274
2739
|
swipeEnabled,
|
|
@@ -2281,8 +2746,15 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2281
2746
|
hiddenDays,
|
|
2282
2747
|
locale,
|
|
2283
2748
|
activeDate,
|
|
2749
|
+
selectedDates,
|
|
2750
|
+
selectedRange,
|
|
2751
|
+
minDate,
|
|
2752
|
+
maxDate,
|
|
2753
|
+
isDateDisabled,
|
|
2284
2754
|
onPressDay,
|
|
2285
2755
|
onPressMonth,
|
|
2756
|
+
onSelectDrag,
|
|
2757
|
+
onCreateEvent,
|
|
2286
2758
|
classNames,
|
|
2287
2759
|
styles: styleOverrides
|
|
2288
2760
|
}) : mode === "schedule" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {
|