@super-calendar/native 2.8.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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-C-vBotP0.js");
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 = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn, { hiddenDays });
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
- weeks.map((week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
101
- ...slot("week", { base: styles$5.week }),
102
- children: week.map((day) => {
103
- if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: styles$5.day }, day.toISOString());
104
- const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : (0, _super_calendar_core.getIsToday)(day);
105
- const hasEvents = eventDays.has((0, date_fns.startOfDay)(day).toISOString());
106
- const label = `${(0, date_fns.format)(day, "EEEE, d LLLL yyyy", { locale })}${(0, _super_calendar_core.getIsToday)(day) ? ", today" : ""}${hasEvents ? ", has events" : ""}`;
107
- const daySlot = slot("day", {
108
- base: styles$5.day,
109
- themed: isHighlighted ? {
110
- backgroundColor: theme.colors.todayBackground,
111
- borderRadius: theme.todayBadgeRadius
112
- } : void 0
113
- });
114
- const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
115
- ...slot("dayText", { themed: [styles$5.dayText, { color: isHighlighted ? theme.colors.todayText : theme.colors.text }] }),
116
- allowFontScaling: false,
117
- children: day.getDate()
118
- }), hasEvents ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("eventDot", {
119
- base: styles$5.eventDot,
120
- themed: { backgroundColor: isHighlighted ? theme.colors.todayText : theme.colors.todayBackground }
121
- }) }) : null] });
122
- return onPressDay ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
123
- onPress: () => onPressDay(day),
124
- accessibilityRole: "button",
125
- accessibilityLabel: label,
126
- ...daySlot,
127
- children: content
128
- }, day.toISOString()) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
129
- accessible: true,
130
- accessibilityLabel: label,
131
- ...daySlot,
132
- children: content
133
- }, day.toISOString());
134
- })
135
- }, week[0].toISOString()))
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. It's the view `Calendar` renders for
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,
@@ -590,6 +782,49 @@ const EDGE_ZONE_PX = 36;
590
782
  const EdgePagingContext = (0, react.createContext)(null);
591
783
  const noop = () => {};
592
784
  /**
785
+ * The tail of a move that runs past midnight, drawn at the top of the next day's
786
+ * column so the drop reads on both days before the finger lifts. Mounted only
787
+ * while a drag is actually spilling (see `spillHeight`), so an idle grid pays
788
+ * nothing for it; its geometry is driven on the UI thread from there.
789
+ */
790
+ function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, slotProps }) {
791
+ const RenderEventComponent = renderEvent;
792
+ const style = (0, react_native_reanimated.useAnimatedStyle)(() => ({
793
+ height: spillHeight.value,
794
+ opacity: spillHeight.value > 0 ? 1 : 0,
795
+ zIndex: spillHeight.value > 0 ? DRAG_EVENT_Z : 0,
796
+ transform: [{ translateX: moveOffsetX.value + nextDayDirection * dayWidth }, { translateY: -minHour * cellHeight.value }]
797
+ }), [
798
+ dayWidth,
799
+ nextDayDirection,
800
+ minHour
801
+ ]);
802
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
803
+ ...slotProps,
804
+ accessibilityElementsHidden: true,
805
+ importantForAccessibility: "no-hide-descendants",
806
+ style: [
807
+ styles$1.eventBox,
808
+ styles$1.nonInteractive,
809
+ {
810
+ left: dayLeftPx,
811
+ width: dayWidth,
812
+ top: 0
813
+ },
814
+ slotProps.style,
815
+ style
816
+ ],
817
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
818
+ event,
819
+ mode,
820
+ boxHeight: spillHeight,
821
+ continuesBefore: true,
822
+ continuesAfter: false,
823
+ onPress: noop
824
+ })
825
+ });
826
+ }
827
+ /**
593
828
  * The floating copy of a dragged event, rendered above the pager so a cross-week
594
829
  * drag stays visible after its source page pages away. Position, size, and
595
830
  * visibility are driven on the UI thread by the shared values so it tracks the
@@ -619,7 +854,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
619
854
  });
620
855
  }
621
856
  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 }) {
857
+ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, width, dayLeftPx, nextDayDirection, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
623
858
  const RenderEventComponent = renderEvent;
624
859
  const theme = require_MonthList.useCalendarTheme();
625
860
  const slot = require_MonthList.useSlots();
@@ -640,6 +875,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
640
875
  const resizeDelta = (0, react_native_reanimated.useSharedValue)(0);
641
876
  const resizeStartDelta = (0, react_native_reanimated.useSharedValue)(0);
642
877
  const dragZ = (0, react_native_reanimated.useSharedValue)(0);
878
+ const moving = (0, react_native_reanimated.useSharedValue)(0);
643
879
  const edgeDir = (0, react_native_reanimated.useSharedValue)(0);
644
880
  const lifted = (0, react_native_reanimated.useSharedValue)(0);
645
881
  const grabX = (0, react_native_reanimated.useSharedValue)(0);
@@ -648,17 +884,49 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
648
884
  const liveAbsY = (0, react_native_reanimated.useSharedValue)(0);
649
885
  const startHours = positioned.startHours;
650
886
  const durationHours = positioned.durationHours;
887
+ const ownsStart = !positioned.continuesBefore;
888
+ const dragStartSV = (0, react_native_reanimated.useDerivedValue)(() => ({
889
+ minutes: startHours * MINUTES_PER_HOUR$1,
890
+ ownsStart
891
+ }), [startHours, ownsStart]);
651
892
  const boxHeight = (0, react_native_reanimated.useDerivedValue)(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
652
- const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
653
- top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
654
- height: boxHeight.value,
655
- transform: [{ translateX: moveOffsetX.value }],
656
- zIndex: dragZ.value
657
- }), [
893
+ const visibleBoxHeight = (0, react_native_reanimated.useDerivedValue)(() => {
894
+ const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
895
+ const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
896
+ return Math.max(Math.min(boxHeight.value, dayEnd - top), MIN_EVENT_HEIGHT);
897
+ }, [startHours, minHour]);
898
+ const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => {
899
+ return {
900
+ top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
901
+ height: visibleBoxHeight.value,
902
+ transform: [{ translateX: moveOffsetX.value }],
903
+ zIndex: dragZ.value
904
+ };
905
+ }, [startHours, minHour]);
906
+ const spillHeight = (0, react_native_reanimated.useDerivedValue)(() => {
907
+ if (!moving.value || lifted.value || cellHeight.value <= 0) return 0;
908
+ const overflowHours = startHours + moveOffset.value / cellHeight.value + durationHours - HOURS_PER_DAY;
909
+ if (overflowHours <= 0) return 0;
910
+ const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
911
+ const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
912
+ const next = target + nextDayDirection;
913
+ if (next < 0 || next >= dayCount || dayOrdinals[next] - dayOrdinals[target] !== 1) return 0;
914
+ return Math.min(overflowHours, maxHour - minHour) * cellHeight.value;
915
+ }, [
658
916
  startHours,
659
917
  durationHours,
660
- minHour
918
+ minHour,
919
+ maxHour,
920
+ dayWidth,
921
+ dayIndex,
922
+ dayCount,
923
+ dayOrdinals,
924
+ nextDayDirection
661
925
  ]);
926
+ const [previewMounted, setPreviewMounted] = (0, react.useState)(false);
927
+ (0, react_native_reanimated.useAnimatedReaction)(() => spillHeight.value > 0, (spilling, previous) => {
928
+ if (previous !== null && spilling !== previous) (0, react_native_reanimated.runOnJS)(setPreviewMounted)(spilling);
929
+ });
662
930
  (0, react.useEffect)(() => {
663
931
  moveOffset.value = 0;
664
932
  moveOffsetX.value = 0;
@@ -749,6 +1017,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
749
1017
  const moveGesture = (0, react.useMemo)(() => {
750
1018
  const pan = react_native_gesture_handler.Gesture.Pan().enabled(canMove).onStart((event) => {
751
1019
  dragZ.value = DRAG_EVENT_Z;
1020
+ moving.value = 1;
752
1021
  edgeDir.value = 0;
753
1022
  lifted.value = 0;
754
1023
  grabX.value = event.x;
@@ -762,8 +1031,11 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
762
1031
  if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
763
1032
  ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
764
1033
  ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
765
- } else {
766
- moveOffset.value = event.translationY;
1034
+ } else if (cellHeight.value > 0) {
1035
+ const { minutes: startMinutes, ownsStart } = dragStartSV.value;
1036
+ const dragged = startMinutes + event.translationY / cellHeight.value * MINUTES_PER_HOUR$1;
1037
+ const held = ownsStart ? (0, _super_calendar_core.clampMoveStartMinutes)(dragged, minHour, maxHour, snapMinutes) : dragged;
1038
+ moveOffset.value = (held - startMinutes) / MINUTES_PER_HOUR$1 * cellHeight.value;
767
1039
  moveOffsetX.value = event.translationX;
768
1040
  }
769
1041
  if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
@@ -777,7 +1049,9 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
777
1049
  }
778
1050
  }).onEnd((event) => {
779
1051
  if (lifted.value) return;
780
- const minuteDelta = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
1052
+ const { minutes: startMinutes, ownsStart } = dragStartSV.value;
1053
+ const snapped = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
1054
+ const minuteDelta = ownsStart ? (0, _super_calendar_core.clampMoveStartMinutes)(startMinutes + snapped, minHour, maxHour, snapMinutes) - startMinutes : snapped;
781
1055
  const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
782
1056
  const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
783
1057
  const dayDelta = targetDay - dayIndex;
@@ -798,6 +1072,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
798
1072
  moveOffsetX.value = 0;
799
1073
  lifted.value = 0;
800
1074
  }
1075
+ moving.value = 0;
801
1076
  (0, react_native_reanimated.runOnJS)(releaseEdge)();
802
1077
  });
803
1078
  return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
@@ -808,6 +1083,10 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
808
1083
  moveOffset,
809
1084
  moveOffsetX,
810
1085
  dragZ,
1086
+ moving,
1087
+ dragStartSV,
1088
+ minHour,
1089
+ maxHour,
811
1090
  edgeDir,
812
1091
  lifted,
813
1092
  grabX,
@@ -943,7 +1222,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
943
1222
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
944
1223
  event: positioned.event,
945
1224
  mode,
946
- boxHeight,
1225
+ boxHeight: visibleBoxHeight,
947
1226
  continuesBefore: positioned.continuesBefore,
948
1227
  continuesAfter: positioned.continuesAfter,
949
1228
  accessibilityActions,
@@ -968,10 +1247,22 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
968
1247
  ]
969
1248
  });
970
1249
  if (!canMove) return box;
971
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
1250
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
972
1251
  gesture: moveGesture,
973
1252
  children: box
974
- });
1253
+ }), previewMounted && !positioned.continuesAfter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoveSpillPreview, {
1254
+ spillHeight,
1255
+ moveOffsetX,
1256
+ cellHeight,
1257
+ dayLeftPx,
1258
+ dayWidth,
1259
+ nextDayDirection,
1260
+ minHour,
1261
+ event: positioned.event,
1262
+ mode,
1263
+ renderEvent,
1264
+ slotProps: slot("event", { themed: theme.containers.timeGridEvent })
1265
+ }) : null] });
975
1266
  }
976
1267
  const HourRow = ({ hour, minHour, cellHeight, hourColumnWidth, label, ampm, hourComponent }) => {
977
1268
  const theme = require_MonthList.useCalendarTheme();
@@ -1443,8 +1734,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1443
1734
  positioned,
1444
1735
  cellHeight: heightSource,
1445
1736
  minHour,
1737
+ maxHour,
1446
1738
  left: dayLeft(dayIndex) + positioned.column * columnWidth,
1447
1739
  width: columnWidth,
1740
+ dayLeftPx: dayLeft(dayIndex),
1741
+ nextDayDirection: isRTL ? -1 : 1,
1448
1742
  dayWidth,
1449
1743
  dayIndex,
1450
1744
  dayCount: days.length,
@@ -1528,6 +1822,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1528
1822
  containerWidth,
1529
1823
  hourColumnWidth,
1530
1824
  minHour: clampedMinHour,
1825
+ maxHour: clampedMaxHour,
1531
1826
  snapMinutes: Math.max(1, dragStepMinutes),
1532
1827
  onDragEvent,
1533
1828
  onChangeDate
@@ -1543,7 +1838,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1543
1838
  setEdgePagingLock(false);
1544
1839
  }, [ghostVisible]);
1545
1840
  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;
1841
+ const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, maxHour: max, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
1547
1842
  const ev = liftedEventRef.current;
1548
1843
  const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
1549
1844
  clearLift();
@@ -1551,7 +1846,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1551
1846
  const dayWidth = (cw - hcw) / days.length;
1552
1847
  const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
1553
1848
  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;
1849
+ const minutes = (0, _super_calendar_core.clampMoveStartMinutes)(Math.round(rawMinutes / snap) * snap, min, max, snap);
1555
1850
  const start = new Date(days[col]);
1556
1851
  start.setHours(0, 0, 0, 0);
1557
1852
  start.setMinutes(minutes);
@@ -1629,6 +1924,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1629
1924
  containerWidth,
1630
1925
  hourColumnWidth,
1631
1926
  minHour: clampedMinHour,
1927
+ maxHour: clampedMaxHour,
1632
1928
  snapMinutes: Math.max(1, dragStepMinutes),
1633
1929
  onDragEvent,
1634
1930
  onChangeDate
@@ -2171,7 +2467,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
2171
2467
  * }
2172
2468
  * ```
2173
2469
  */
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 }) {
2470
+ 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
2471
  const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
2176
2472
  const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
2177
2473
  const cellHeight = cellHeightProp ?? internalCellHeight;
@@ -2258,6 +2554,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
2258
2554
  disableMonthEventCellPress,
2259
2555
  isRTL,
2260
2556
  showSixWeeks,
2557
+ showTitle,
2261
2558
  activeDate,
2262
2559
  renderHeaderForMonthView,
2263
2560
  renderCustomDateForMonth,
@@ -2266,9 +2563,22 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
2266
2563
  keyExtractor,
2267
2564
  onPressDay,
2268
2565
  onLongPressDay,
2566
+ onPressCell,
2269
2567
  onPressEvent: handlePressEvent,
2270
2568
  onLongPressEvent: handleLongPressEvent,
2271
2569
  onPressMore,
2570
+ onCreateEvent,
2571
+ onSelectDrag,
2572
+ onDragEvent,
2573
+ onDragStart,
2574
+ eventStartEditable,
2575
+ eventOverlap,
2576
+ selectedDates,
2577
+ selectedRange,
2578
+ fillCellOnSelection,
2579
+ minDate,
2580
+ maxDate,
2581
+ isDateDisabled,
2272
2582
  onChangeDate: handleChangeDate,
2273
2583
  freeSwipe,
2274
2584
  swipeEnabled,
@@ -2281,8 +2591,15 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
2281
2591
  hiddenDays,
2282
2592
  locale,
2283
2593
  activeDate,
2594
+ selectedDates,
2595
+ selectedRange,
2596
+ minDate,
2597
+ maxDate,
2598
+ isDateDisabled,
2284
2599
  onPressDay,
2285
2600
  onPressMonth,
2601
+ onSelectDrag,
2602
+ onCreateEvent,
2286
2603
  classNames,
2287
2604
  styles: styleOverrides
2288
2605
  }) : mode === "schedule" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {