@super-calendar/native 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f a
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, 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, 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
7
  import { Gesture, GestureDetector } from "react-native-gesture-handler";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -733,6 +733,92 @@ const styles$2 = StyleSheet.create({
733
733
  chip: { minHeight: 18 }
734
734
  });
735
735
  //#endregion
736
+ //#region src/components/MultiDayMovePreview.tsx
737
+ const noop$1 = () => {};
738
+ function MultiDayMovePreview(props) {
739
+ const { move, days } = props;
740
+ const dayOffsets = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[move.dayIndex]) * 1440), [days, move]);
741
+ return days.map((day, index) => /* @__PURE__ */ jsx(PreviewDay, {
742
+ ...props,
743
+ dayOffsets,
744
+ index,
745
+ dayStart: startOfDay(day).getTime(),
746
+ dayEnd: addDays(startOfDay(day), 1).getTime()
747
+ }, day.toISOString()));
748
+ }
749
+ function PreviewDay({ move, cellHeight, dayWidth, hourColumnWidth, minHour, mode, renderEvent: RenderEventComponent, minEventHeight, eventGap, dayOffsets, index, dayStart, dayEnd }) {
750
+ const theme = useCalendarTheme();
751
+ const slot = useSlots();
752
+ const { offsetX, offsetY, lifted, dayIndex, event } = move;
753
+ const duration = event.end.getTime() - event.start.getTime();
754
+ const startTimestamp = event.start.getTime();
755
+ const segment = useDerivedValue(() => {
756
+ const columnDelta = dayWidth > 0 ? Math.round(offsetX.value / dayWidth) : 0;
757
+ const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayOffsets.length - 1);
758
+ const minuteDelta = cellHeight.value > 0 ? offsetY.value / cellHeight.value * 60 : 0;
759
+ const start = shiftMinutes(new Date(startTimestamp), dayOffsets[target] + minuteDelta).getTime();
760
+ const end = start + duration;
761
+ const visible = !lifted.value && start < dayEnd && end > dayStart;
762
+ return {
763
+ top: (Math.max(start, dayStart) - dayStart) / 36e5,
764
+ hours: visible ? Math.max((Math.min(end, dayEnd) - Math.max(start, dayStart)) / 36e5, .25) : 0,
765
+ continuesBefore: start < dayStart,
766
+ continuesAfter: end > dayEnd
767
+ };
768
+ }, [
769
+ dayWidth,
770
+ dayIndex,
771
+ dayOffsets,
772
+ startTimestamp,
773
+ duration,
774
+ dayStart,
775
+ dayEnd
776
+ ]);
777
+ const boxHeight = useDerivedValue(() => segment.value.hours > 0 ? Math.max(segment.value.hours * cellHeight.value, minEventHeight) : 0, [minEventHeight]);
778
+ const style = useAnimatedStyle(() => ({
779
+ top: (segment.value.top - minHour) * cellHeight.value,
780
+ height: boxHeight.value,
781
+ opacity: boxHeight.value > 0 ? 1 : 0
782
+ }), [minHour]);
783
+ const [continuation, setContinuation] = useState(() => ({
784
+ continuesBefore: segment.value.continuesBefore,
785
+ continuesAfter: segment.value.continuesAfter
786
+ }));
787
+ useAnimatedReaction(() => ({
788
+ continuesBefore: segment.value.continuesBefore,
789
+ continuesAfter: segment.value.continuesAfter
790
+ }), (next, previous) => {
791
+ if (previous && (next.continuesBefore !== previous.continuesBefore || next.continuesAfter !== previous.continuesAfter)) runOnJS(setContinuation)(next);
792
+ });
793
+ const eventSlot = slot("event", { themed: theme.containers.timeGridEvent });
794
+ return /* @__PURE__ */ jsx(Animated.View, {
795
+ ...eventSlot,
796
+ testID: "multi-day-move-preview",
797
+ pointerEvents: "none",
798
+ accessibilityElementsHidden: true,
799
+ importantForAccessibility: "no-hide-descendants",
800
+ style: [
801
+ {
802
+ position: "absolute",
803
+ overflow: "hidden",
804
+ padding: eventGap,
805
+ left: hourColumnWidth + index * dayWidth,
806
+ width: dayWidth,
807
+ zIndex: 100
808
+ },
809
+ eventSlot.style,
810
+ style
811
+ ],
812
+ children: /* @__PURE__ */ jsx(RenderEventComponent, {
813
+ event,
814
+ mode,
815
+ boxHeight,
816
+ ...continuation,
817
+ onPress: noop$1
818
+ })
819
+ });
820
+ }
821
+ //#endregion
736
822
  //#region src/components/TimeGrid.tsx
737
823
  const isWeb$1 = Platform.OS === "web";
738
824
  const MINUTES_PER_HOUR$1 = 60;
@@ -745,8 +831,8 @@ const DEFAULT_HOUR_HEIGHT = 48;
745
831
  const DEFAULT_MIN_HOUR_HEIGHT = 32;
746
832
  const DEFAULT_MAX_HOUR_HEIGHT = 160;
747
833
  const DEFAULT_HOUR_COLUMN_WIDTH = 56;
748
- const MIN_EVENT_HEIGHT = 32;
749
- const EVENT_GAP = 2;
834
+ const DEFAULT_MIN_EVENT_HEIGHT = 32;
835
+ const DEFAULT_EVENT_GAP = 2;
750
836
  const DRAG_ACTIVATE_MS = 300;
751
837
  const MOVE_ACTIVATE_MS$1 = 500;
752
838
  const DRAG_ACTIVATE_PX$1 = 8;
@@ -763,7 +849,7 @@ const noop = () => {};
763
849
  * while a drag is actually spilling (see `spillHeight`), so an idle grid pays
764
850
  * nothing for it; its geometry is driven on the UI thread from there.
765
851
  */
766
- function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, slotProps }) {
852
+ function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, eventGap, slotProps }) {
767
853
  const RenderEventComponent = renderEvent;
768
854
  const style = useAnimatedStyle(() => ({
769
855
  height: spillHeight.value,
@@ -785,7 +871,8 @@ function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, day
785
871
  {
786
872
  left: dayLeftPx,
787
873
  width: dayWidth,
788
- top: 0
874
+ top: 0,
875
+ padding: eventGap
789
876
  },
790
877
  slotProps.style,
791
878
  style
@@ -806,7 +893,7 @@ function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, day
806
893
  * visibility are driven on the UI thread by the shared values so it tracks the
807
894
  * finger without a React re-render.
808
895
  */
809
- function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
896
+ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent, eventGap }) {
810
897
  const RenderEventComponent = renderEvent;
811
898
  const style = useAnimatedStyle(() => ({
812
899
  transform: [{ translateX: x.value }, { translateY: y.value }],
@@ -818,6 +905,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
818
905
  style: [
819
906
  styles$1.eventBox,
820
907
  styles$1.dragGhost,
908
+ { padding: eventGap },
821
909
  style
822
910
  ],
823
911
  pointerEvents: "none",
@@ -830,7 +918,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
830
918
  });
831
919
  }
832
920
  const HOUR_LABEL_TOP_INSET = 12;
833
- 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 }) {
921
+ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview, cellHeight, minHour, maxHour, left, width, dayLeftPx, nextDayDirection, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, minEventHeight, eventGap, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
834
922
  const RenderEventComponent = renderEvent;
835
923
  const theme = useCalendarTheme();
836
924
  const slot = useSlots();
@@ -861,16 +949,22 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
861
949
  const startHours = positioned.startHours;
862
950
  const durationHours = positioned.durationHours;
863
951
  const ownsStart = !positioned.continuesBefore;
952
+ const multiDay = positioned.continuesBefore || positioned.continuesAfter;
953
+ const hiddenForMove = positioned.event === movingEvent;
864
954
  const dragStartSV = useDerivedValue(() => ({
865
955
  minutes: startHours * MINUTES_PER_HOUR$1,
866
956
  ownsStart
867
957
  }), [startHours, ownsStart]);
868
- const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
958
+ const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, minEventHeight), [durationHours, minEventHeight]);
869
959
  const visibleBoxHeight = useDerivedValue(() => {
870
960
  const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
871
961
  const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
872
- return Math.max(Math.min(boxHeight.value, dayEnd - top), MIN_EVENT_HEIGHT);
873
- }, [startHours, minHour]);
962
+ return Math.max(Math.min(boxHeight.value, dayEnd - top), minEventHeight);
963
+ }, [
964
+ startHours,
965
+ minHour,
966
+ minEventHeight
967
+ ]);
874
968
  const boxStyle = useAnimatedStyle(() => {
875
969
  return {
876
970
  top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
@@ -880,7 +974,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
880
974
  };
881
975
  }, [startHours, minHour]);
882
976
  const spillHeight = useDerivedValue(() => {
883
- if (!moving.value || lifted.value || cellHeight.value <= 0) return 0;
977
+ if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
884
978
  const overflowHours = startHours + moveOffset.value / cellHeight.value + durationHours - HOURS_PER_DAY;
885
979
  if (overflowHours <= 0) return 0;
886
980
  const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
@@ -897,7 +991,8 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
897
991
  dayIndex,
898
992
  dayCount,
899
993
  dayOrdinals,
900
- nextDayDirection
994
+ nextDayDirection,
995
+ multiDay
901
996
  ]);
902
997
  const [previewMounted, setPreviewMounted] = useState(false);
903
998
  useAnimatedReaction(() => spillHeight.value > 0, (spilling, previous) => {
@@ -918,11 +1013,13 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
918
1013
  ]);
919
1014
  const latest = useRef({
920
1015
  event: positioned.event,
1016
+ eventIndex,
921
1017
  onDragEvent,
922
1018
  onDragStart
923
1019
  });
924
1020
  latest.current = {
925
1021
  event: positioned.event,
1022
+ eventIndex,
926
1023
  onDragEvent,
927
1024
  onDragStart
928
1025
  };
@@ -945,11 +1042,41 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
945
1042
  snapBack();
946
1043
  return;
947
1044
  }
948
- if (handler(event, next.start, next.end) === false) snapBack();
949
- }, [snapMinutes, snapBack]);
1045
+ if (handler(event, next.start, next.end) === false) {
1046
+ snapBack();
1047
+ onMovePreview(null);
1048
+ } else if (multiDay && deltaStartMin === deltaEndMin) onMovePreview((move) => move ? {
1049
+ ...move,
1050
+ phase: "dropped"
1051
+ } : null);
1052
+ }, [
1053
+ snapMinutes,
1054
+ snapBack,
1055
+ multiDay,
1056
+ onMovePreview
1057
+ ]);
950
1058
  const notifyDragStart = useCallback(() => {
951
1059
  latest.current.onDragStart?.(latest.current.event);
952
1060
  }, []);
1061
+ const beginMovePreview = useCallback(() => {
1062
+ if (multiDay) onMovePreview({
1063
+ event: latest.current.event,
1064
+ eventIndex: latest.current.eventIndex,
1065
+ phase: "dragging",
1066
+ dayIndex,
1067
+ offsetX: moveOffsetX,
1068
+ offsetY: moveOffset,
1069
+ lifted
1070
+ });
1071
+ }, [
1072
+ multiDay,
1073
+ onMovePreview,
1074
+ dayIndex,
1075
+ moveOffsetX,
1076
+ moveOffset,
1077
+ lifted
1078
+ ]);
1079
+ const endMovePreview = useCallback(() => onMovePreview(null), [onMovePreview]);
953
1080
  const dwellTimer = useRef(null);
954
1081
  const disarmEdge = useCallback(() => {
955
1082
  if (dwellTimer.current) {
@@ -1000,6 +1127,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
1000
1127
  grabY.value = event.y;
1001
1128
  liveAbsX.value = event.absoluteX;
1002
1129
  liveAbsY.value = event.absoluteY;
1130
+ runOnJS(beginMovePreview)();
1003
1131
  runOnJS(notifyDragStart)();
1004
1132
  }).onUpdate((event) => {
1005
1133
  liveAbsX.value = event.absoluteX;
@@ -1034,21 +1162,28 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
1034
1162
  if (minuteDelta === 0 && dayDelta === 0) {
1035
1163
  moveOffset.value = 0;
1036
1164
  moveOffsetX.value = 0;
1165
+ runOnJS(endMovePreview)();
1037
1166
  return;
1038
1167
  }
1039
1168
  moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
1040
1169
  moveOffsetX.value = dayDelta * dayWidth;
1041
1170
  const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
1042
1171
  runOnJS(commitDrag)(totalDelta, totalDelta);
1043
- }).onFinalize(() => {
1172
+ }).onFinalize((_event, success) => {
1044
1173
  dragZ.value = 0;
1045
1174
  if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
1046
1175
  runOnJS(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
1047
1176
  moveOffset.value = 0;
1048
1177
  moveOffsetX.value = 0;
1049
1178
  lifted.value = 0;
1179
+ runOnJS(endMovePreview)();
1050
1180
  }
1051
1181
  moving.value = 0;
1182
+ if (multiDay && !success) {
1183
+ moveOffset.value = 0;
1184
+ moveOffsetX.value = 0;
1185
+ runOnJS(endMovePreview)();
1186
+ }
1052
1187
  runOnJS(releaseEdge)();
1053
1188
  });
1054
1189
  return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
@@ -1080,6 +1215,9 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
1080
1215
  dayCount,
1081
1216
  dayOrdinals,
1082
1217
  commitDrag,
1218
+ multiDay,
1219
+ beginMovePreview,
1220
+ endMovePreview,
1083
1221
  notifyDragStart,
1084
1222
  onEdgeAdvance,
1085
1223
  armEdge,
@@ -1187,13 +1325,18 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
1187
1325
  const eventSlot = slot("event", {
1188
1326
  base: [styles$1.eventBox, {
1189
1327
  left,
1190
- width
1328
+ width,
1329
+ padding: eventGap
1191
1330
  }],
1192
1331
  themed: theme.containers.timeGridEvent
1193
1332
  });
1194
1333
  const box = /* @__PURE__ */ jsxs(Animated.View, {
1195
1334
  ...eventSlot,
1196
- style: [eventSlot.style, boxStyle],
1335
+ style: [
1336
+ eventSlot.style,
1337
+ boxStyle,
1338
+ hiddenForMove ? { opacity: 0 } : null
1339
+ ],
1197
1340
  children: [
1198
1341
  /* @__PURE__ */ jsx(RenderEventComponent, {
1199
1342
  event: positioned.event,
@@ -1237,6 +1380,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, maxHour, left, widt
1237
1380
  event: positioned.event,
1238
1381
  mode,
1239
1382
  renderEvent,
1383
+ eventGap,
1240
1384
  slotProps: slot("event", { themed: theme.containers.timeGridEvent })
1241
1385
  }) : null] });
1242
1386
  }
@@ -1337,7 +1481,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
1337
1481
  children
1338
1482
  });
1339
1483
  };
1340
- function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowTimeZone, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, highlightWeekends, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderBusinessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, eventStartEditable, eventDurationEditable, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, onGridTop }) {
1484
+ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowTimeZone, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, highlightWeekends, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderBusinessHours, renderEvent, keyExtractor, snapMinutes, minEventHeight, eventGap, showDragHandle, eventStartEditable, eventDurationEditable, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, onGridTop }) {
1341
1485
  const theme = useCalendarTheme();
1342
1486
  const slot = useSlots();
1343
1487
  const scrollRef = useAnimatedRef();
@@ -1395,6 +1539,11 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1395
1539
  const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
1396
1540
  const dayOrdinals = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[0])), [days]);
1397
1541
  const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
1542
+ const [multiDayMove, setMultiDayMove] = useState(null);
1543
+ const movingEvent = multiDayMove ? events.find((event, index) => keyExtractor(event, index) === keyExtractor(multiDayMove.event, multiDayMove.eventIndex)) ?? null : null;
1544
+ useEffect(() => {
1545
+ if (multiDayMove?.phase === "dropped" && (!movingEvent || movingEvent.start.getTime() !== multiDayMove.event.start.getTime() || movingEvent.end.getTime() !== multiDayMove.event.end.getTime())) setMultiDayMove(null);
1546
+ }, [multiDayMove, movingEvent]);
1398
1547
  const cellDateFromTouch = (event) => {
1399
1548
  const { locationX, locationY } = event.nativeEvent;
1400
1549
  const dayIndex = days.length === 1 ? 0 : Math.floor(locationX / dayWidth);
@@ -1563,7 +1712,10 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1563
1712
  opacity: createActive.value
1564
1713
  }));
1565
1714
  const ghostSlot = slot("createGhost", {
1566
- base: [styles$1.createGhost, { pointerEvents: "none" }],
1715
+ base: [styles$1.createGhost, {
1716
+ marginHorizontal: eventGap,
1717
+ pointerEvents: "none"
1718
+ }],
1567
1719
  themed: {
1568
1720
  backgroundColor: theme.colors.eventBackground,
1569
1721
  borderColor: theme.colors.todayBackground
@@ -1708,6 +1860,9 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1708
1860
  const columnWidth = dayWidth / positioned.columns;
1709
1861
  return /* @__PURE__ */ jsx(AnimatedEventBox, {
1710
1862
  positioned,
1863
+ eventIndex: events.indexOf(positioned.event),
1864
+ movingEvent,
1865
+ onMovePreview: setMultiDayMove,
1711
1866
  cellHeight: heightSource,
1712
1867
  minHour,
1713
1868
  maxHour,
@@ -1723,6 +1878,8 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1723
1878
  daysPerPage,
1724
1879
  renderEvent,
1725
1880
  snapMinutes,
1881
+ minEventHeight,
1882
+ eventGap,
1726
1883
  showDragHandle,
1727
1884
  eventStartEditable,
1728
1885
  eventDurationEditable,
@@ -1733,6 +1890,18 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1733
1890
  onEdgeAdvance
1734
1891
  }, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
1735
1892
  })),
1893
+ multiDayMove ? /* @__PURE__ */ jsx(MultiDayMovePreview, {
1894
+ move: multiDayMove,
1895
+ days,
1896
+ cellHeight: heightSource,
1897
+ dayWidth,
1898
+ hourColumnWidth,
1899
+ minHour,
1900
+ mode,
1901
+ renderEvent,
1902
+ minEventHeight,
1903
+ eventGap
1904
+ }) : null,
1736
1905
  showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
1737
1906
  cellHeight: heightSource,
1738
1907
  nowHours,
@@ -1752,7 +1921,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1752
1921
  });
1753
1922
  }
1754
1923
  const TimetablePage = memo(TimetablePageInner);
1755
- function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
1924
+ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
1756
1925
  const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
1757
1926
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
1758
1927
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
@@ -2062,6 +2231,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2062
2231
  renderEvent: labeledRenderEvent,
2063
2232
  keyExtractor,
2064
2233
  snapMinutes: Math.max(1, dragStepMinutes),
2234
+ minEventHeight,
2235
+ eventGap,
2065
2236
  showDragHandle,
2066
2237
  eventStartEditable,
2067
2238
  eventDurationEditable,
@@ -2110,6 +2281,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2110
2281
  labeledRenderEvent,
2111
2282
  keyExtractor,
2112
2283
  dragStepMinutes,
2284
+ minEventHeight,
2285
+ eventGap,
2113
2286
  showDragHandle,
2114
2287
  eventStartEditable,
2115
2288
  eventDurationEditable,
@@ -2191,7 +2364,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
2191
2364
  visible: ghostVisible,
2192
2365
  event: liftedEvent,
2193
2366
  mode,
2194
- renderEvent: labeledRenderEvent
2367
+ renderEvent: labeledRenderEvent,
2368
+ eventGap
2195
2369
  }) : null]
2196
2370
  })
2197
2371
  ]
@@ -2324,8 +2498,7 @@ const styles$1 = StyleSheet.create({
2324
2498
  createGhost: {
2325
2499
  position: "absolute",
2326
2500
  borderRadius: 6,
2327
- borderWidth: StyleSheet.hairlineWidth,
2328
- marginHorizontal: EVENT_GAP
2501
+ borderWidth: StyleSheet.hairlineWidth
2329
2502
  },
2330
2503
  weekendColumn: {
2331
2504
  position: "absolute",
@@ -2385,8 +2558,7 @@ const styles$1 = StyleSheet.create({
2385
2558
  },
2386
2559
  eventBox: {
2387
2560
  position: "absolute",
2388
- overflow: "hidden",
2389
- padding: EVENT_GAP
2561
+ overflow: "hidden"
2390
2562
  },
2391
2563
  dragGhost: {
2392
2564
  top: 0,
@@ -2443,7 +2615,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
2443
2615
  * }
2444
2616
  * ```
2445
2617
  */
2446
- 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 }) {
2618
+ 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, minEventHeight, eventGap, 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 }) {
2447
2619
  const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
2448
2620
  const internalCellHeight = useSharedValue(hourHeight);
2449
2621
  const cellHeight = cellHeightProp ?? internalCellHeight;
@@ -2628,6 +2800,8 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
2628
2800
  ampm,
2629
2801
  minHourHeight,
2630
2802
  maxHourHeight,
2803
+ minEventHeight,
2804
+ eventGap,
2631
2805
  showNowIndicator,
2632
2806
  locale,
2633
2807
  activeDate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/native",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "description": "Gesture-driven, virtualized month / week / day calendar and date picker for React Native (and web via react-native-web).",
5
5
  "keywords": [
6
6
  "agenda",
@@ -64,7 +64,7 @@
64
64
  "access": "public"
65
65
  },
66
66
  "dependencies": {
67
- "@super-calendar/core": "2.9.0"
67
+ "@super-calendar/core": "2.10.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@legendapp/list": ">=3",
@@ -60,6 +60,12 @@ export type CalendarSlot = MonthViewSlot | TimeGridSlot | AgendaSlot | YearViewS
60
60
  export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
61
61
  events: CalendarEvent<T>[];
62
62
  mode: CalendarMode;
63
+ /**
64
+ * The controlled anchor date, read in the device's local time zone. Construct
65
+ * it as a local date (`new Date(2026, 7, 24)`), not a UTC instant:
66
+ * `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
67
+ * and anchors the previous week.
68
+ */
63
69
  date: Date;
64
70
  onChangeDate: (date: Date) => void;
65
71
  /** Fired alongside `onChangeDate` with the `[start, end]` of the newly-visible range. */
@@ -211,6 +217,17 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
211
217
  hourHeight?: number;
212
218
  minHourHeight?: number;
213
219
  maxHourHeight?: number;
220
+ /**
221
+ * Minimum pixel height of a timed event box on the week/day grid, so short
222
+ * events stay legible and tappable. Also the floor of the `boxHeight` handed to
223
+ * `renderEvent`. Default 32; pass 0 to size every box strictly by its duration.
224
+ */
225
+ minEventHeight?: number;
226
+ /**
227
+ * Inset in pixels between a timed event box and its slot on the week/day grid
228
+ * (each side). Default 2; pass 0 to let events fill their slot.
229
+ */
230
+ eventGap?: number;
214
231
  hourColumnWidth?: number;
215
232
  /** Hide the left hour-axis column on the week/day grid. Default false. */
216
233
  hideHours?: boolean;
@@ -445,6 +462,8 @@ export function Calendar<T>({
445
462
  hourHeight = DEFAULT_HOUR_HEIGHT,
446
463
  minHourHeight,
447
464
  maxHourHeight,
465
+ minEventHeight,
466
+ eventGap,
448
467
  hourColumnWidth,
449
468
  hideHours,
450
469
  timeslots,
@@ -703,6 +722,8 @@ export function Calendar<T>({
703
722
  ampm={ampm}
704
723
  minHourHeight={minHourHeight}
705
724
  maxHourHeight={maxHourHeight}
725
+ minEventHeight={minEventHeight}
726
+ eventGap={eventGap}
706
727
  showNowIndicator={showNowIndicator}
707
728
  locale={locale}
708
729
  activeDate={activeDate}