@super-calendar/native 2.7.0 → 2.8.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/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-Dn37Ezj0.mjs";
1
+ import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-DjAz4xoi.mjs";
2
2
  import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
3
3
  import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import Animated, { runOnJS, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
5
- import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, minutesIntoDay, nextDateRange, pageStepDays, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
5
+ import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
6
6
  import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { LegendList } from "@legendapp/list/react-native";
@@ -595,7 +595,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
595
595
  });
596
596
  }
597
597
  const HOUR_LABEL_TOP_INSET = 12;
598
- function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle }) {
598
+ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
599
599
  const RenderEventComponent = renderEvent;
600
600
  const theme = useCalendarTheme();
601
601
  const slot = useSlots();
@@ -606,11 +606,15 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
606
606
  const ghostXSV = edgePaging?.ghostX;
607
607
  const ghostYSV = edgePaging?.ghostY;
608
608
  const commitLiftedDrop = edgePaging?.commitLiftedDrop;
609
- const draggable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
610
- const resizable = draggable && !positioned.continuesAfter;
609
+ const editable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
610
+ const canMove = editable && (positioned.event.startEditable ?? eventStartEditable);
611
+ const canResize = editable && (positioned.event.durationEditable ?? eventDurationEditable);
612
+ const resizable = canResize && !positioned.continuesAfter;
613
+ const resizableFromStart = canResize && !positioned.continuesBefore && !isWeb$1;
611
614
  const moveOffset = useSharedValue(0);
612
615
  const moveOffsetX = useSharedValue(0);
613
616
  const resizeDelta = useSharedValue(0);
617
+ const resizeStartDelta = useSharedValue(0);
614
618
  const dragZ = useSharedValue(0);
615
619
  const edgeDir = useSharedValue(0);
616
620
  const lifted = useSharedValue(0);
@@ -620,9 +624,9 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
620
624
  const liveAbsY = useSharedValue(0);
621
625
  const startHours = positioned.startHours;
622
626
  const durationHours = positioned.durationHours;
623
- const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
627
+ const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
624
628
  const boxStyle = useAnimatedStyle(() => ({
625
- top: (startHours - minHour) * cellHeight.value + moveOffset.value,
629
+ top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
626
630
  height: boxHeight.value,
627
631
  transform: [{ translateX: moveOffsetX.value }],
628
632
  zIndex: dragZ.value
@@ -635,12 +639,14 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
635
639
  moveOffset.value = 0;
636
640
  moveOffsetX.value = 0;
637
641
  resizeDelta.value = 0;
642
+ resizeStartDelta.value = 0;
638
643
  }, [
639
644
  positioned.startHours,
640
645
  positioned.durationHours,
641
646
  moveOffset,
642
647
  moveOffsetX,
643
- resizeDelta
648
+ resizeDelta,
649
+ resizeStartDelta
644
650
  ]);
645
651
  const latest = useRef({
646
652
  event: positioned.event,
@@ -656,10 +662,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
656
662
  moveOffset.value = 0;
657
663
  moveOffsetX.value = 0;
658
664
  resizeDelta.value = 0;
665
+ resizeStartDelta.value = 0;
659
666
  }, [
660
667
  moveOffset,
661
668
  moveOffsetX,
662
- resizeDelta
669
+ resizeDelta,
670
+ resizeStartDelta
663
671
  ]);
664
672
  const commitDrag = useCallback((deltaStartMin, deltaEndMin) => {
665
673
  const { event, onDragEvent: handler } = latest.current;
@@ -715,7 +723,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
715
723
  onEdgeAdvance
716
724
  ]);
717
725
  const moveGesture = useMemo(() => {
718
- const pan = Gesture.Pan().enabled(draggable).onStart((event) => {
726
+ const pan = Gesture.Pan().enabled(canMove).onStart((event) => {
719
727
  dragZ.value = DRAG_EVENT_Z;
720
728
  edgeDir.value = 0;
721
729
  lifted.value = 0;
@@ -770,7 +778,7 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
770
778
  });
771
779
  return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
772
780
  }, [
773
- draggable,
781
+ canMove,
774
782
  snapMinutes,
775
783
  cellHeight,
776
784
  moveOffset,
@@ -823,19 +831,42 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
823
831
  commitDrag,
824
832
  notifyDragStart
825
833
  ]);
834
+ const resizeStartGesture = useMemo(() => Gesture.Pan().enabled(resizableFromStart).onStart(() => {
835
+ dragZ.value = DRAG_EVENT_Z;
836
+ runOnJS(notifyDragStart)();
837
+ }).onUpdate((event) => {
838
+ resizeStartDelta.value = event.translationY;
839
+ }).onEnd((event) => {
840
+ const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
841
+ if (delta === 0) {
842
+ resizeStartDelta.value = 0;
843
+ return;
844
+ }
845
+ resizeStartDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
846
+ runOnJS(commitDrag)(delta, 0);
847
+ }).onFinalize(() => {
848
+ dragZ.value = 0;
849
+ }), [
850
+ resizableFromStart,
851
+ snapMinutes,
852
+ cellHeight,
853
+ resizeStartDelta,
854
+ dragZ,
855
+ commitDrag,
856
+ notifyDragStart
857
+ ]);
826
858
  const handlePress = () => onPress(positioned.event);
827
- const handleLongPress = !draggable && onLongPress ? () => onLongPress(positioned.event) : void 0;
859
+ const handleLongPress = !canMove && onLongPress ? () => onLongPress(positioned.event) : void 0;
828
860
  const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
829
861
  const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
830
- const accessibilityActions = draggable ? [
831
- {
862
+ const dragActions = [
863
+ ...canMove ? [{
832
864
  name: "move-later",
833
865
  label: `Move ${unit(snapMinutes)} later`
834
- },
835
- {
866
+ }, {
836
867
  name: "move-earlier",
837
868
  label: `Move ${unit(snapMinutes)} earlier`
838
- },
869
+ }] : [],
839
870
  ...resizable ? [{
840
871
  name: "extend",
841
872
  label: `Extend by ${unit(snapMinutes)}`
@@ -843,16 +874,16 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
843
874
  name: "shrink",
844
875
  label: `Shorten by ${unit(snapMinutes)}`
845
876
  }] : [],
846
- {
877
+ ...canMove ? [{
847
878
  name: "move-next-page",
848
879
  label: `Move to next ${pageUnit}`
849
- },
850
- {
880
+ }, {
851
881
  name: "move-previous-page",
852
882
  label: `Move to previous ${pageUnit}`
853
- }
854
- ] : void 0;
855
- const handleAccessibilityAction = draggable ? (e) => {
883
+ }] : []
884
+ ];
885
+ const accessibilityActions = dragActions.length ? dragActions : void 0;
886
+ const handleAccessibilityAction = accessibilityActions ? (e) => {
856
887
  switch (e.nativeEvent.actionName) {
857
888
  case "move-later":
858
889
  commitDrag(snapMinutes, snapMinutes);
@@ -884,25 +915,35 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
884
915
  const box = /* @__PURE__ */ jsxs(Animated.View, {
885
916
  ...eventSlot,
886
917
  style: [eventSlot.style, boxStyle],
887
- children: [/* @__PURE__ */ jsx(RenderEventComponent, {
888
- event: positioned.event,
889
- mode,
890
- boxHeight,
891
- continuesBefore: positioned.continuesBefore,
892
- continuesAfter: positioned.continuesAfter,
893
- accessibilityActions,
894
- onAccessibilityAction: handleAccessibilityAction,
895
- onPress: handlePress,
896
- onLongPress: handleLongPress
897
- }), resizable ? /* @__PURE__ */ jsx(GestureDetector, {
898
- gesture: resizeGesture,
899
- children: /* @__PURE__ */ jsx(Animated.View, {
900
- style: styles$1.resizeHandle,
901
- children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
902
- })
903
- }) : null]
918
+ children: [
919
+ /* @__PURE__ */ jsx(RenderEventComponent, {
920
+ event: positioned.event,
921
+ mode,
922
+ boxHeight,
923
+ continuesBefore: positioned.continuesBefore,
924
+ continuesAfter: positioned.continuesAfter,
925
+ accessibilityActions,
926
+ onAccessibilityAction: handleAccessibilityAction,
927
+ onPress: handlePress,
928
+ onLongPress: handleLongPress
929
+ }),
930
+ resizableFromStart ? /* @__PURE__ */ jsx(GestureDetector, {
931
+ gesture: resizeStartGesture,
932
+ children: /* @__PURE__ */ jsx(Animated.View, {
933
+ style: styles$1.resizeHandleTop,
934
+ children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
935
+ })
936
+ }) : null,
937
+ resizable ? /* @__PURE__ */ jsx(GestureDetector, {
938
+ gesture: resizeGesture,
939
+ children: /* @__PURE__ */ jsx(Animated.View, {
940
+ style: styles$1.resizeHandle,
941
+ children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
942
+ })
943
+ }) : null
944
+ ]
904
945
  });
905
- if (!draggable) return box;
946
+ if (!canMove) return box;
906
947
  return /* @__PURE__ */ jsx(GestureDetector, {
907
948
  gesture: moveGesture,
908
949
  children: box
@@ -1005,7 +1046,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
1005
1046
  children
1006
1047
  });
1007
1048
  };
1008
- 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, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, onGridTop }) {
1049
+ 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 }) {
1009
1050
  const theme = useCalendarTheme();
1010
1051
  const slot = useSlots();
1011
1052
  const scrollRef = useAnimatedRef();
@@ -1389,6 +1430,8 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1389
1430
  renderEvent,
1390
1431
  snapMinutes,
1391
1432
  showDragHandle,
1433
+ eventStartEditable,
1434
+ eventDurationEditable,
1392
1435
  onPress: onPressEvent,
1393
1436
  onLongPress: onLongPressEvent,
1394
1437
  onDragEvent,
@@ -1415,7 +1458,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
1415
1458
  });
1416
1459
  }
1417
1460
  const TimetablePage = memo(TimetablePageInner);
1418
- 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, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
1461
+ 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 }) {
1419
1462
  const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
1420
1463
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
1421
1464
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
@@ -1424,6 +1467,14 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1424
1467
  eventAccessibilityLabel,
1425
1468
  ampm
1426
1469
  ]);
1470
+ const onDragEvent = useMemo(() => {
1471
+ if (!onDragEventProp || eventOverlap !== false) return onDragEventProp;
1472
+ return (event, start, end) => overlapsOtherEvents(events, event, start, end) ? false : onDragEventProp(event, start, end);
1473
+ }, [
1474
+ onDragEventProp,
1475
+ eventOverlap,
1476
+ events
1477
+ ]);
1427
1478
  const { width, height } = useWindowDimensions();
1428
1479
  const listRef = useRef(null);
1429
1480
  const pagerRef = useRef(null);
@@ -1716,6 +1767,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1716
1767
  keyExtractor,
1717
1768
  snapMinutes: Math.max(1, dragStepMinutes),
1718
1769
  showDragHandle,
1770
+ eventStartEditable,
1771
+ eventDurationEditable,
1719
1772
  onPressEvent,
1720
1773
  onLongPressEvent,
1721
1774
  onDragEvent,
@@ -1762,6 +1815,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
1762
1815
  keyExtractor,
1763
1816
  dragStepMinutes,
1764
1817
  showDragHandle,
1818
+ eventStartEditable,
1819
+ eventDurationEditable,
1765
1820
  onPressEvent,
1766
1821
  onLongPressEvent,
1767
1822
  onDragEvent,
@@ -2017,6 +2072,15 @@ const styles$1 = StyleSheet.create({
2017
2072
  alignItems: "center",
2018
2073
  justifyContent: "center"
2019
2074
  },
2075
+ resizeHandleTop: {
2076
+ position: "absolute",
2077
+ left: 0,
2078
+ right: 0,
2079
+ top: 0,
2080
+ height: RESIZE_HANDLE_HEIGHT,
2081
+ alignItems: "center",
2082
+ justifyContent: "center"
2083
+ },
2020
2084
  resizeGrip: {
2021
2085
  width: 24,
2022
2086
  height: 3,
@@ -2083,7 +2147,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
2083
2147
  * }
2084
2148
  * ```
2085
2149
  */
2086
- 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, 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 }) {
2150
+ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
2087
2151
  const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
2088
2152
  const internalCellHeight = useSharedValue(hourHeight);
2089
2153
  const cellHeight = cellHeightProp ?? internalCellHeight;
@@ -2166,6 +2230,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
2166
2230
  sortedMonthView,
2167
2231
  moreLabel,
2168
2232
  showAdjacentMonths,
2233
+ highlightWeekends,
2169
2234
  disableMonthEventCellPress,
2170
2235
  isRTL,
2171
2236
  showSixWeeks,
@@ -2229,6 +2294,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
2229
2294
  timeslots,
2230
2295
  showAllDayEventCell,
2231
2296
  highlightWeekends,
2297
+ eventStartEditable,
2298
+ eventDurationEditable,
2299
+ eventOverlap,
2232
2300
  calendarCellStyle,
2233
2301
  businessHours,
2234
2302
  renderBusinessHours,
@@ -2639,7 +2707,7 @@ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, s
2639
2707
  * />
2640
2708
  * ```
2641
2709
  */
2642
- function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone }) {
2710
+ function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone }) {
2643
2711
  const theme = useCalendarTheme();
2644
2712
  const resources = useMemo(() => {
2645
2713
  if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
@@ -2711,9 +2779,9 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
2711
2779
  style: styles.vroot,
2712
2780
  children: [/* @__PURE__ */ jsxs(View, {
2713
2781
  style: [styles.header, { borderBottomColor: theme.colors.gridLine }],
2714
- children: [/* @__PURE__ */ jsx(View, { style: { width: GUTTER_WIDTH } }), resources.map((resource) => /* @__PURE__ */ jsx(View, {
2782
+ children: [/* @__PURE__ */ jsx(View, { style: { width: GUTTER_WIDTH } }), resources.map((resource, index) => /* @__PURE__ */ jsx(View, {
2715
2783
  style: [styles.vheaderCell, theme.containers.resourceLabel],
2716
- children: /* @__PURE__ */ jsx(Text, {
2784
+ children: renderResourceHeader ? renderResourceHeader(resource, index) : /* @__PURE__ */ jsx(Text, {
2717
2785
  numberOfLines: 1,
2718
2786
  style: [styles.vheaderText, { color: theme.colors.text }],
2719
2787
  allowFontScaling: false,
@@ -2897,7 +2965,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
2897
2965
  },
2898
2966
  theme.containers.resourceLabel
2899
2967
  ],
2900
- children: /* @__PURE__ */ jsx(Text, {
2968
+ children: renderResourceHeader ? renderResourceHeader(resource, laneIndex) : /* @__PURE__ */ jsx(Text, {
2901
2969
  numberOfLines: 1,
2902
2970
  style: { color: theme.colors.text },
2903
2971
  allowFontScaling: false,
@@ -3124,4 +3192,4 @@ const styles = StyleSheet.create({
3124
3192
  }
3125
3193
  });
3126
3194
  //#endregion
3127
- export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
3195
+ export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
package/dist/picker.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-DMOC5aNL.mjs";
1
+ import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-VgJarTO_.mjs";
2
2
  import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
3
3
  export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
package/dist/picker.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-DCPDsnvq.js";
1
+ import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-CjwX3Nt1.js";
2
2
  import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
3
3
  export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
package/dist/picker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_MonthList = require("./MonthList-CJs1vq5T.js");
2
+ const require_MonthList = require("./MonthList-C-vBotP0.js");
3
3
  let _super_calendar_core = require("@super-calendar/core");
4
4
  exports.CalendarThemeProvider = require_MonthList.CalendarThemeProvider;
5
5
  exports.DefaultMonthEvent = require_MonthList.DefaultMonthEvent;
package/dist/picker.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { d as darkTheme, f as defaultTheme, i as MonthView, m as useCalendarTheme, n as DefaultMonthEvent, p as mergeTheme, r as MonthPager, t as MonthList, u as CalendarThemeProvider } from "./MonthList-Dn37Ezj0.mjs";
1
+ import { d as darkTheme, f as defaultTheme, i as MonthView, m as useCalendarTheme, n as DefaultMonthEvent, p as mergeTheme, r as MonthPager, t as MonthList, u as CalendarThemeProvider } from "./MonthList-DjAz4xoi.mjs";
2
2
  import { buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
3
3
  export { CalendarThemeProvider, DefaultMonthEvent, MonthList, MonthPager, MonthView, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/native",
3
- "version": "2.7.0",
3
+ "version": "2.8.1",
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.7.0"
67
+ "@super-calendar/core": "2.8.1"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@legendapp/list": ">=3",
@@ -195,6 +195,12 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
195
195
  showAllDayEventCell?: boolean;
196
196
  /** Tint weekend columns (default true). Set false to treat weekends normally. */
197
197
  highlightWeekends?: boolean;
198
+ /** Allow moving events by default (per-event `startEditable` overrides). Default true. */
199
+ eventStartEditable?: boolean;
200
+ /** Allow resizing events by default (per-event `durationEditable` overrides). Default true. */
201
+ eventDurationEditable?: boolean;
202
+ /** Reject drags/resizes that would overlap another event (default true = allowed). */
203
+ eventOverlap?: boolean;
198
204
  /** Show the ISO week number in the week/day header gutter. Default false. */
199
205
  showWeekNumber?: boolean;
200
206
  /** Prefix for the week-number label (e.g. "W"). Default "W". */
@@ -403,6 +409,9 @@ export function Calendar<T>({
403
409
  timeslots,
404
410
  showAllDayEventCell,
405
411
  highlightWeekends,
412
+ eventStartEditable,
413
+ eventDurationEditable,
414
+ eventOverlap,
406
415
  showWeekNumber,
407
416
  weekNumberPrefix,
408
417
  hourComponent,
@@ -544,6 +553,7 @@ export function Calendar<T>({
544
553
  sortedMonthView={sortedMonthView}
545
554
  moreLabel={moreLabel}
546
555
  showAdjacentMonths={showAdjacentMonths}
556
+ highlightWeekends={highlightWeekends}
547
557
  disableMonthEventCellPress={disableMonthEventCellPress}
548
558
  isRTL={isRTL}
549
559
  showSixWeeks={showSixWeeks}
@@ -613,6 +623,9 @@ export function Calendar<T>({
613
623
  timeslots={timeslots}
614
624
  showAllDayEventCell={showAllDayEventCell}
615
625
  highlightWeekends={highlightWeekends}
626
+ eventStartEditable={eventStartEditable}
627
+ eventDurationEditable={eventDurationEditable}
628
+ eventOverlap={eventOverlap}
616
629
  calendarCellStyle={calendarCellStyle}
617
630
  businessHours={businessHours}
618
631
  renderBusinessHours={renderBusinessHours}
@@ -101,6 +101,8 @@ export type MonthListProps<T> = {
101
101
  moreLabel?: string;
102
102
  /** Show dimmed adjacent-month days. Default false (each month shows only its own days). */
103
103
  showAdjacentMonths?: boolean;
104
+ /** Tint weekend day cells with the theme's weekend background. Default true. */
105
+ highlightWeekends?: boolean;
104
106
  disableMonthEventCellPress?: boolean;
105
107
  isRTL?: boolean;
106
108
  activeDate?: Date;
@@ -151,6 +153,7 @@ function MonthListInner<T>({
151
153
  sortedMonthView,
152
154
  moreLabel,
153
155
  showAdjacentMonths = false,
156
+ highlightWeekends = true,
154
157
  disableMonthEventCellPress,
155
158
  isRTL,
156
159
  activeDate,
@@ -463,6 +466,7 @@ function MonthListInner<T>({
463
466
  sortedMonthView={sortedMonthView}
464
467
  moreLabel={moreLabel}
465
468
  showAdjacentMonths={showAdjacentMonths}
469
+ highlightWeekends={highlightWeekends}
466
470
  disableMonthEventCellPress={disableMonthEventCellPress}
467
471
  isRTL={isRTL}
468
472
  activeDate={activeDate}
@@ -53,6 +53,7 @@ export type MonthPagerProps<T> = {
53
53
  sortedMonthView?: boolean;
54
54
  moreLabel?: string;
55
55
  showAdjacentMonths?: boolean;
56
+ highlightWeekends?: boolean;
56
57
  disableMonthEventCellPress?: boolean;
57
58
  isRTL?: boolean;
58
59
  calendarCellStyle?: (date: Date) => StyleProp<ViewStyle>;
@@ -85,6 +86,7 @@ function MonthPagerInner<T>({
85
86
  sortedMonthView,
86
87
  moreLabel,
87
88
  showAdjacentMonths,
89
+ highlightWeekends,
88
90
  disableMonthEventCellPress,
89
91
  isRTL,
90
92
  calendarCellStyle,
@@ -250,6 +252,7 @@ function MonthPagerInner<T>({
250
252
  sortedMonthView={sortedMonthView}
251
253
  moreLabel={moreLabel}
252
254
  showAdjacentMonths={showAdjacentMonths}
255
+ highlightWeekends={highlightWeekends}
253
256
  disableMonthEventCellPress={disableMonthEventCellPress}
254
257
  isRTL={isRTL}
255
258
  showSixWeeks={showSixWeeks}