@super-calendar/native 2.6.0 → 2.7.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/{DefaultMonthEvent-BSvuJUFk.d.ts → DefaultMonthEvent-DCPDsnvq.d.ts} +10 -6
- package/dist/{DefaultMonthEvent-zDj9dHEv.d.mts → DefaultMonthEvent-DMOC5aNL.d.mts} +10 -6
- package/dist/{MonthList-Gu6p64fE.js → MonthList-CJs1vq5T.js} +80 -11
- package/dist/{MonthList-CMzYn9T0.mjs → MonthList-Dn37Ezj0.mjs} +82 -13
- package/dist/index.d.mts +80 -17
- package/dist/index.d.ts +80 -17
- package/dist/index.js +627 -125
- package/dist/index.mjs +606 -128
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Agenda.tsx +5 -2
- package/src/components/AllDayLane.tsx +3 -2
- package/src/components/Calendar.tsx +29 -0
- package/src/components/DefaultEvent.tsx +3 -1
- package/src/components/MonthPager.tsx +12 -3
- package/src/components/MonthView.tsx +95 -8
- package/src/components/ResourceTimeline.tsx +270 -29
- package/src/components/TimeGrid.tsx +656 -97
- package/src/components/YearView.tsx +14 -4
- package/src/index.tsx +10 -1
- package/src/types.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_MonthList = require("./MonthList-
|
|
24
|
+
const require_MonthList = require("./MonthList-CJs1vq5T.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");
|
|
@@ -33,7 +33,7 @@ let _legendapp_list_react_native = require("@legendapp/list/react-native");
|
|
|
33
33
|
let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
34
34
|
//#region src/components/YearView.tsx
|
|
35
35
|
const FALLBACK_COLUMNS = 3;
|
|
36
|
-
function YearViewInner({ date, events, weekStartsOn, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
36
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
37
37
|
const theme = require_MonthList.useCalendarTheme();
|
|
38
38
|
const slot = require_MonthList.createSlots({
|
|
39
39
|
classNames,
|
|
@@ -46,19 +46,20 @@ function YearViewInner({ date, events, weekStartsOn, locale, activeDate, minMont
|
|
|
46
46
|
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
47
47
|
};
|
|
48
48
|
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
49
|
-
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.getWeekDays)(date, weekStartsOn).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
49
|
+
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
50
|
date,
|
|
51
51
|
weekStartsOn,
|
|
52
|
-
locale
|
|
52
|
+
locale,
|
|
53
|
+
hiddenDays
|
|
53
54
|
]);
|
|
54
|
-
const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events).keys() : []), [events]);
|
|
55
|
+
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]);
|
|
55
56
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ScrollView, {
|
|
56
57
|
onLayout: handleLayout,
|
|
57
58
|
showsVerticalScrollIndicator: true,
|
|
58
59
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
59
60
|
...slot("grid", { base: styles$5.grid }),
|
|
60
61
|
children: months.map((month) => {
|
|
61
|
-
const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn);
|
|
62
|
+
const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn, { hiddenDays });
|
|
62
63
|
const title = (0, date_fns.format)(month, "MMMM", { locale });
|
|
63
64
|
const monthLabel = (0, date_fns.format)(month, "MMMM yyyy", { locale });
|
|
64
65
|
const titleText = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
@@ -208,7 +209,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
208
209
|
}), [classNames, styleOverrides]);
|
|
209
210
|
const RenderEventComponent = renderEvent;
|
|
210
211
|
const rows = (0, react.useMemo)(() => {
|
|
211
|
-
const sorted =
|
|
212
|
+
const sorted = events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
212
213
|
const out = [];
|
|
213
214
|
let currentDay = null;
|
|
214
215
|
sorted.forEach((event, index) => {
|
|
@@ -375,7 +376,7 @@ function DefaultEvent({ event, mode, boxHeight, isAllDay, ampm = false, showTime
|
|
|
375
376
|
],
|
|
376
377
|
onPress,
|
|
377
378
|
onLongPress,
|
|
378
|
-
activeOpacity:
|
|
379
|
+
activeOpacity: 1,
|
|
379
380
|
accessibilityRole: "button",
|
|
380
381
|
accessibilityLabel,
|
|
381
382
|
accessibilityState: { disabled: event.disabled ?? false },
|
|
@@ -505,7 +506,7 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
|
|
|
505
506
|
const theme = require_MonthList.useCalendarTheme();
|
|
506
507
|
const slot = require_MonthList.useSlots();
|
|
507
508
|
const RenderEventComponent = renderEvent;
|
|
508
|
-
const allDay = events.filter(_super_calendar_core.isAllDayEvent);
|
|
509
|
+
const allDay = events.filter((event) => (0, _super_calendar_core.isAllDayEvent)(event) && !(0, _super_calendar_core.isBackgroundEvent)(event));
|
|
509
510
|
const perDay = days.map((day) => {
|
|
510
511
|
const start = (0, date_fns.startOfDay)(day);
|
|
511
512
|
const next = (0, date_fns.addDays)(start, 1);
|
|
@@ -583,34 +584,72 @@ const MOVE_ACTIVATE_MS$1 = 500;
|
|
|
583
584
|
const DRAG_ACTIVATE_PX$1 = 8;
|
|
584
585
|
const RESIZE_HANDLE_HEIGHT = 14;
|
|
585
586
|
const DEFAULT_DRAG_STEP_MINUTES = 15;
|
|
586
|
-
const
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
587
|
+
const DRAG_EVENT_Z = 100;
|
|
588
|
+
const EDGE_DWELL_MS = 500;
|
|
589
|
+
const EDGE_ZONE_PX = 36;
|
|
590
|
+
const EdgePagingContext = (0, react.createContext)(null);
|
|
591
|
+
const noop = () => {};
|
|
592
|
+
/**
|
|
593
|
+
* The floating copy of a dragged event, rendered above the pager so a cross-week
|
|
594
|
+
* drag stays visible after its source page pages away. Position, size, and
|
|
595
|
+
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
596
|
+
* finger without a React re-render.
|
|
597
|
+
*/
|
|
598
|
+
function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
599
|
+
const RenderEventComponent = renderEvent;
|
|
600
|
+
const style = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
601
|
+
transform: [{ translateX: x.value }, { translateY: y.value }],
|
|
602
|
+
width: w.value,
|
|
603
|
+
height: h.value,
|
|
604
|
+
opacity: visible.value
|
|
605
|
+
}));
|
|
606
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
607
|
+
style: [
|
|
608
|
+
styles$1.eventBox,
|
|
609
|
+
styles$1.dragGhost,
|
|
610
|
+
style
|
|
611
|
+
],
|
|
612
|
+
pointerEvents: "none",
|
|
613
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
614
|
+
event,
|
|
615
|
+
mode,
|
|
616
|
+
boxHeight: h,
|
|
617
|
+
onPress: noop
|
|
618
|
+
})
|
|
619
|
+
});
|
|
597
620
|
}
|
|
598
|
-
|
|
621
|
+
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 }) {
|
|
599
623
|
const RenderEventComponent = renderEvent;
|
|
600
624
|
const theme = require_MonthList.useCalendarTheme();
|
|
601
625
|
const slot = require_MonthList.useSlots();
|
|
602
|
-
const
|
|
626
|
+
const edgePaging = (0, react.useContext)(EdgePagingContext);
|
|
627
|
+
const pagerLeftSV = edgePaging?.pagerLeft;
|
|
628
|
+
const pagerTopSV = edgePaging?.pagerTop;
|
|
629
|
+
const pagerWidthSV = edgePaging?.pagerWidth;
|
|
630
|
+
const ghostXSV = edgePaging?.ghostX;
|
|
631
|
+
const ghostYSV = edgePaging?.ghostY;
|
|
632
|
+
const commitLiftedDrop = edgePaging?.commitLiftedDrop;
|
|
633
|
+
const draggable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
|
|
603
634
|
const resizable = draggable && !positioned.continuesAfter;
|
|
604
635
|
const moveOffset = (0, react_native_reanimated.useSharedValue)(0);
|
|
605
636
|
const moveOffsetX = (0, react_native_reanimated.useSharedValue)(0);
|
|
606
637
|
const resizeDelta = (0, react_native_reanimated.useSharedValue)(0);
|
|
638
|
+
const dragZ = (0, react_native_reanimated.useSharedValue)(0);
|
|
639
|
+
const edgeDir = (0, react_native_reanimated.useSharedValue)(0);
|
|
640
|
+
const lifted = (0, react_native_reanimated.useSharedValue)(0);
|
|
641
|
+
const grabX = (0, react_native_reanimated.useSharedValue)(0);
|
|
642
|
+
const grabY = (0, react_native_reanimated.useSharedValue)(0);
|
|
643
|
+
const liveAbsX = (0, react_native_reanimated.useSharedValue)(0);
|
|
644
|
+
const liveAbsY = (0, react_native_reanimated.useSharedValue)(0);
|
|
607
645
|
const startHours = positioned.startHours;
|
|
608
646
|
const durationHours = positioned.durationHours;
|
|
609
647
|
const boxHeight = (0, react_native_reanimated.useDerivedValue)(() => Math.max(durationHours * cellHeight.value + resizeDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
|
|
610
648
|
const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
611
649
|
top: (startHours - minHour) * cellHeight.value + moveOffset.value,
|
|
612
650
|
height: boxHeight.value,
|
|
613
|
-
transform: [{ translateX: moveOffsetX.value }]
|
|
651
|
+
transform: [{ translateX: moveOffsetX.value }],
|
|
652
|
+
zIndex: dragZ.value
|
|
614
653
|
}), [
|
|
615
654
|
startHours,
|
|
616
655
|
durationHours,
|
|
@@ -659,16 +698,81 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
659
698
|
const notifyDragStart = (0, react.useCallback)(() => {
|
|
660
699
|
latest.current.onDragStart?.(latest.current.event);
|
|
661
700
|
}, []);
|
|
701
|
+
const dwellTimer = (0, react.useRef)(null);
|
|
702
|
+
const disarmEdge = (0, react.useCallback)(() => {
|
|
703
|
+
if (dwellTimer.current) {
|
|
704
|
+
clearTimeout(dwellTimer.current);
|
|
705
|
+
dwellTimer.current = null;
|
|
706
|
+
}
|
|
707
|
+
}, []);
|
|
708
|
+
const releaseEdge = (0, react.useCallback)(() => {
|
|
709
|
+
disarmEdge();
|
|
710
|
+
edgePaging?.lockScroll(false);
|
|
711
|
+
}, [disarmEdge, edgePaging]);
|
|
712
|
+
const armEdge = (0, react.useCallback)((dir) => {
|
|
713
|
+
disarmEdge();
|
|
714
|
+
dwellTimer.current = setTimeout(() => {
|
|
715
|
+
dwellTimer.current = null;
|
|
716
|
+
if (!edgePaging) return;
|
|
717
|
+
edgePaging.lockScroll(true);
|
|
718
|
+
if (!lifted.value) {
|
|
719
|
+
lifted.value = 1;
|
|
720
|
+
edgePaging.ghostW.value = width;
|
|
721
|
+
edgePaging.ghostH.value = boxHeight.value;
|
|
722
|
+
edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
|
|
723
|
+
edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
|
|
724
|
+
edgePaging.ghostVisible.value = 1;
|
|
725
|
+
edgePaging.beginLift(latest.current.event);
|
|
726
|
+
}
|
|
727
|
+
onEdgeAdvance?.(dir);
|
|
728
|
+
}, EDGE_DWELL_MS);
|
|
729
|
+
}, [
|
|
730
|
+
disarmEdge,
|
|
731
|
+
edgePaging,
|
|
732
|
+
lifted,
|
|
733
|
+
width,
|
|
734
|
+
boxHeight,
|
|
735
|
+
liveAbsX,
|
|
736
|
+
liveAbsY,
|
|
737
|
+
grabX,
|
|
738
|
+
grabY,
|
|
739
|
+
onEdgeAdvance
|
|
740
|
+
]);
|
|
662
741
|
const moveGesture = (0, react.useMemo)(() => {
|
|
663
|
-
const pan = react_native_gesture_handler.Gesture.Pan().enabled(draggable).onStart(() => {
|
|
742
|
+
const pan = react_native_gesture_handler.Gesture.Pan().enabled(draggable).onStart((event) => {
|
|
743
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
744
|
+
edgeDir.value = 0;
|
|
745
|
+
lifted.value = 0;
|
|
746
|
+
grabX.value = event.x;
|
|
747
|
+
grabY.value = event.y;
|
|
748
|
+
liveAbsX.value = event.absoluteX;
|
|
749
|
+
liveAbsY.value = event.absoluteY;
|
|
664
750
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
665
751
|
}).onUpdate((event) => {
|
|
666
|
-
|
|
667
|
-
|
|
752
|
+
liveAbsX.value = event.absoluteX;
|
|
753
|
+
liveAbsY.value = event.absoluteY;
|
|
754
|
+
if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
|
|
755
|
+
ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
|
|
756
|
+
ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
|
|
757
|
+
} else {
|
|
758
|
+
moveOffset.value = event.translationY;
|
|
759
|
+
moveOffsetX.value = event.translationX;
|
|
760
|
+
}
|
|
761
|
+
if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
|
|
762
|
+
const fx = event.absoluteX - pagerLeftSV.value;
|
|
763
|
+
const dir = fx > pagerWidthSV.value - EDGE_ZONE_PX ? 1 : fx < EDGE_ZONE_PX ? -1 : 0;
|
|
764
|
+
if (dir !== edgeDir.value) {
|
|
765
|
+
edgeDir.value = dir;
|
|
766
|
+
if (dir === 0) (0, react_native_reanimated.runOnJS)(disarmEdge)();
|
|
767
|
+
else (0, react_native_reanimated.runOnJS)(armEdge)(dir);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
668
770
|
}).onEnd((event) => {
|
|
771
|
+
if (lifted.value) return;
|
|
669
772
|
const minuteDelta = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
|
|
670
773
|
const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
|
|
671
|
-
const
|
|
774
|
+
const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
|
|
775
|
+
const dayDelta = targetDay - dayIndex;
|
|
672
776
|
if (minuteDelta === 0 && dayDelta === 0) {
|
|
673
777
|
moveOffset.value = 0;
|
|
674
778
|
moveOffsetX.value = 0;
|
|
@@ -676,8 +780,17 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
676
780
|
}
|
|
677
781
|
moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
678
782
|
moveOffsetX.value = dayDelta * dayWidth;
|
|
679
|
-
const totalDelta = minuteDelta +
|
|
783
|
+
const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
680
784
|
(0, react_native_reanimated.runOnJS)(commitDrag)(totalDelta, totalDelta);
|
|
785
|
+
}).onFinalize(() => {
|
|
786
|
+
dragZ.value = 0;
|
|
787
|
+
if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
|
|
788
|
+
(0, react_native_reanimated.runOnJS)(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
|
|
789
|
+
moveOffset.value = 0;
|
|
790
|
+
moveOffsetX.value = 0;
|
|
791
|
+
lifted.value = 0;
|
|
792
|
+
}
|
|
793
|
+
(0, react_native_reanimated.runOnJS)(releaseEdge)();
|
|
681
794
|
});
|
|
682
795
|
return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
|
|
683
796
|
}, [
|
|
@@ -686,13 +799,32 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
686
799
|
cellHeight,
|
|
687
800
|
moveOffset,
|
|
688
801
|
moveOffsetX,
|
|
802
|
+
dragZ,
|
|
803
|
+
edgeDir,
|
|
804
|
+
lifted,
|
|
805
|
+
grabX,
|
|
806
|
+
grabY,
|
|
807
|
+
liveAbsX,
|
|
808
|
+
liveAbsY,
|
|
809
|
+
pagerLeftSV,
|
|
810
|
+
pagerTopSV,
|
|
811
|
+
pagerWidthSV,
|
|
812
|
+
ghostXSV,
|
|
813
|
+
ghostYSV,
|
|
814
|
+
commitLiftedDrop,
|
|
689
815
|
dayWidth,
|
|
690
816
|
dayIndex,
|
|
691
817
|
dayCount,
|
|
818
|
+
dayOrdinals,
|
|
692
819
|
commitDrag,
|
|
693
|
-
notifyDragStart
|
|
820
|
+
notifyDragStart,
|
|
821
|
+
onEdgeAdvance,
|
|
822
|
+
armEdge,
|
|
823
|
+
disarmEdge,
|
|
824
|
+
releaseEdge
|
|
694
825
|
]);
|
|
695
826
|
const resizeGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(resizable).onStart(() => {
|
|
827
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
696
828
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
697
829
|
}).onUpdate((event) => {
|
|
698
830
|
resizeDelta.value = event.translationY;
|
|
@@ -704,17 +836,21 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
704
836
|
}
|
|
705
837
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
706
838
|
(0, react_native_reanimated.runOnJS)(commitDrag)(0, delta);
|
|
839
|
+
}).onFinalize(() => {
|
|
840
|
+
dragZ.value = 0;
|
|
707
841
|
}), [
|
|
708
842
|
resizable,
|
|
709
843
|
snapMinutes,
|
|
710
844
|
cellHeight,
|
|
711
845
|
resizeDelta,
|
|
846
|
+
dragZ,
|
|
712
847
|
commitDrag,
|
|
713
848
|
notifyDragStart
|
|
714
849
|
]);
|
|
715
850
|
const handlePress = () => onPress(positioned.event);
|
|
716
851
|
const handleLongPress = !draggable && onLongPress ? () => onLongPress(positioned.event) : void 0;
|
|
717
852
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
853
|
+
const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
|
|
718
854
|
const accessibilityActions = draggable ? [
|
|
719
855
|
{
|
|
720
856
|
name: "move-later",
|
|
@@ -730,7 +866,15 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
730
866
|
}, {
|
|
731
867
|
name: "shrink",
|
|
732
868
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
733
|
-
}] : []
|
|
869
|
+
}] : [],
|
|
870
|
+
{
|
|
871
|
+
name: "move-next-page",
|
|
872
|
+
label: `Move to next ${pageUnit}`
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
name: "move-previous-page",
|
|
876
|
+
label: `Move to previous ${pageUnit}`
|
|
877
|
+
}
|
|
734
878
|
] : void 0;
|
|
735
879
|
const handleAccessibilityAction = draggable ? (e) => {
|
|
736
880
|
switch (e.nativeEvent.actionName) {
|
|
@@ -746,6 +890,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
746
890
|
case "shrink":
|
|
747
891
|
commitDrag(0, -snapMinutes);
|
|
748
892
|
break;
|
|
893
|
+
case "move-next-page":
|
|
894
|
+
commitDrag(daysPerPage * MINUTES_PER_DAY, daysPerPage * MINUTES_PER_DAY);
|
|
895
|
+
break;
|
|
896
|
+
case "move-previous-page":
|
|
897
|
+
commitDrag(-daysPerPage * MINUTES_PER_DAY, -daysPerPage * MINUTES_PER_DAY);
|
|
898
|
+
break;
|
|
749
899
|
}
|
|
750
900
|
} : void 0;
|
|
751
901
|
const eventSlot = slot("event", {
|
|
@@ -849,7 +999,7 @@ const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) =>
|
|
|
849
999
|
style: [lineSlot.style, animatedStyle]
|
|
850
1000
|
});
|
|
851
1001
|
};
|
|
852
|
-
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color }) => {
|
|
1002
|
+
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", children }) => {
|
|
853
1003
|
const slot = require_MonthList.useSlots();
|
|
854
1004
|
const animatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
855
1005
|
top: (startHour - minHour) * cellHeight.value,
|
|
@@ -859,7 +1009,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
859
1009
|
endHour,
|
|
860
1010
|
minHour
|
|
861
1011
|
]);
|
|
862
|
-
const bandSlot = slot(
|
|
1012
|
+
const bandSlot = slot(slotName, {
|
|
863
1013
|
base: [
|
|
864
1014
|
styles$1.shadeBand,
|
|
865
1015
|
styles$1.nonInteractive,
|
|
@@ -868,18 +1018,25 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
868
1018
|
width
|
|
869
1019
|
}
|
|
870
1020
|
],
|
|
871
|
-
themed: { backgroundColor: color }
|
|
1021
|
+
themed: color === void 0 ? void 0 : { backgroundColor: color }
|
|
872
1022
|
});
|
|
873
1023
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
874
|
-
testID
|
|
1024
|
+
testID,
|
|
1025
|
+
accessibilityElementsHidden: true,
|
|
1026
|
+
importantForAccessibility: "no-hide-descendants",
|
|
875
1027
|
...bandSlot,
|
|
876
|
-
style: [bandSlot.style, animatedStyle]
|
|
1028
|
+
style: [bandSlot.style, animatedStyle],
|
|
1029
|
+
children
|
|
877
1030
|
});
|
|
878
1031
|
};
|
|
879
|
-
function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent }) {
|
|
1032
|
+
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 }) {
|
|
880
1033
|
const theme = require_MonthList.useCalendarTheme();
|
|
881
1034
|
const slot = require_MonthList.useSlots();
|
|
882
1035
|
const scrollRef = (0, react_native_reanimated.useAnimatedRef)();
|
|
1036
|
+
const gridTopRef = (0, react.useRef)(0);
|
|
1037
|
+
(0, react.useEffect)(() => {
|
|
1038
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1039
|
+
}, [isActive, onGridTop]);
|
|
883
1040
|
const heightSource = isActive ? cellHeight : committedCellHeight;
|
|
884
1041
|
const isDragging = (0, react_native_reanimated.useSharedValue)(false);
|
|
885
1042
|
const isActiveShared = (0, react_native_reanimated.useSharedValue)(isActive);
|
|
@@ -915,17 +1072,20 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
915
1072
|
if (isWeb$1 || !active || active === previous) return;
|
|
916
1073
|
(0, react_native_reanimated.scrollTo)(scrollRef, 0, scrollY.value, false);
|
|
917
1074
|
});
|
|
918
|
-
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1075
|
+
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
919
1076
|
mode,
|
|
920
1077
|
date,
|
|
921
1078
|
weekStartsOn,
|
|
922
1079
|
numberOfDays,
|
|
923
1080
|
isRTL,
|
|
924
|
-
weekEndsOn
|
|
1081
|
+
weekEndsOn,
|
|
1082
|
+
hiddenDays
|
|
925
1083
|
]);
|
|
1084
|
+
const daysPerPage = (0, _super_calendar_core.pageStepDays)(mode, date, weekStartsOn, numberOfDays);
|
|
926
1085
|
const dayCount = days.length;
|
|
927
1086
|
const dayWidth = (width - hourColumnWidth) / dayCount;
|
|
928
1087
|
const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
|
|
1088
|
+
const dayOrdinals = (0, react.useMemo)(() => days.map((day) => (0, date_fns.differenceInCalendarDays)(day, days[0])), [days]);
|
|
929
1089
|
const dayLayouts = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
|
|
930
1090
|
const cellDateFromTouch = (event) => {
|
|
931
1091
|
const { locationX, locationY } = event.nativeEvent;
|
|
@@ -947,8 +1107,11 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
947
1107
|
if (date) onLongPressCell?.(date);
|
|
948
1108
|
};
|
|
949
1109
|
const hoursRange = (0, react.useMemo)(() => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index), [minHour, maxHour]);
|
|
950
|
-
const now = useNow(showNowIndicator && isActive
|
|
951
|
-
|
|
1110
|
+
const now = (0, _super_calendar_core.useNow)(showNowIndicator && isActive, {
|
|
1111
|
+
now: nowProp,
|
|
1112
|
+
timeZone: nowTimeZone
|
|
1113
|
+
});
|
|
1114
|
+
const nowDayIndex = days.findIndex((day) => (0, _super_calendar_core.isSameCalendarDay)(day, now));
|
|
952
1115
|
const nowHours = ((0, date_fns.getHours)(now) * MINUTES_PER_HOUR$1 + (0, date_fns.getMinutes)(now)) / MINUTES_PER_HOUR$1;
|
|
953
1116
|
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
954
1117
|
const fullHeightStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ height: (maxHour - minHour) * heightSource.value }), [
|
|
@@ -1126,6 +1289,10 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1126
1289
|
scrollEnabled: verticalScrollEnabled,
|
|
1127
1290
|
onScroll: scrollHandler,
|
|
1128
1291
|
scrollEventThrottle: 16,
|
|
1292
|
+
onLayout: (event) => {
|
|
1293
|
+
gridTopRef.current = event.nativeEvent.layout.y;
|
|
1294
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1295
|
+
},
|
|
1129
1296
|
contentContainerStyle: { paddingTop: HOUR_LABEL_TOP_INSET },
|
|
1130
1297
|
contentOffset: {
|
|
1131
1298
|
x: 0,
|
|
@@ -1139,7 +1306,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1139
1306
|
children: cellLayer
|
|
1140
1307
|
}) : cellLayer,
|
|
1141
1308
|
days.map((day, dayIndex) => {
|
|
1142
|
-
if (!(0, _super_calendar_core.isWeekend)(day)) return null;
|
|
1309
|
+
if (!highlightWeekends || !(0, _super_calendar_core.isWeekend)(day)) return null;
|
|
1143
1310
|
const shadeSlot = slot("weekendShade", {
|
|
1144
1311
|
base: [
|
|
1145
1312
|
styles$1.weekendColumn,
|
|
@@ -1152,6 +1319,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1152
1319
|
themed: { backgroundColor: theme.colors.weekendBackground }
|
|
1153
1320
|
});
|
|
1154
1321
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
1322
|
+
testID: "weekend-shade",
|
|
1155
1323
|
...shadeSlot,
|
|
1156
1324
|
style: [shadeSlot.style, fullHeightStyle]
|
|
1157
1325
|
}, `weekend-${day.toISOString()}`);
|
|
@@ -1176,8 +1344,28 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1176
1344
|
minHour,
|
|
1177
1345
|
left: dayLeft(dayIndex),
|
|
1178
1346
|
width: dayWidth,
|
|
1179
|
-
color: theme.colors.outsideHoursBackground
|
|
1347
|
+
color: renderBusinessHours ? void 0 : theme.colors.outsideHoursBackground,
|
|
1348
|
+
children: renderBusinessHours?.({
|
|
1349
|
+
date: day,
|
|
1350
|
+
start: band.start,
|
|
1351
|
+
end: band.end
|
|
1352
|
+
})
|
|
1180
1353
|
}, `closed-${day.toISOString()}-${bandIndex}`))) : null,
|
|
1354
|
+
days.flatMap((day, dayIndex) => (0, _super_calendar_core.backgroundBandsForDay)(events, day).map((b) => ({
|
|
1355
|
+
...b,
|
|
1356
|
+
startHours: Math.max(b.startHours, minHour),
|
|
1357
|
+
endHours: Math.min(b.endHours, maxHour)
|
|
1358
|
+
})).filter((b) => b.endHours > b.startHours).map((b, bandIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShadeBand, {
|
|
1359
|
+
cellHeight: heightSource,
|
|
1360
|
+
startHour: b.startHours,
|
|
1361
|
+
endHour: b.endHours,
|
|
1362
|
+
minHour,
|
|
1363
|
+
left: dayLeft(dayIndex),
|
|
1364
|
+
width: dayWidth,
|
|
1365
|
+
color: theme.colors.backgroundEvent,
|
|
1366
|
+
slotName: "backgroundEvent",
|
|
1367
|
+
testID: "background-event-shade"
|
|
1368
|
+
}, `bg-${day.toISOString()}-${bandIndex}`))),
|
|
1181
1369
|
days.map((day, dayIndex) => {
|
|
1182
1370
|
const separatorSlot = slot("daySeparator", {
|
|
1183
1371
|
base: [
|
|
@@ -1219,14 +1407,17 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1219
1407
|
dayWidth,
|
|
1220
1408
|
dayIndex,
|
|
1221
1409
|
dayCount: days.length,
|
|
1410
|
+
dayOrdinals,
|
|
1222
1411
|
mode,
|
|
1412
|
+
daysPerPage,
|
|
1223
1413
|
renderEvent,
|
|
1224
1414
|
snapMinutes,
|
|
1225
1415
|
showDragHandle,
|
|
1226
1416
|
onPress: onPressEvent,
|
|
1227
1417
|
onLongPress: onLongPressEvent,
|
|
1228
1418
|
onDragEvent,
|
|
1229
|
-
onDragStart
|
|
1419
|
+
onDragStart,
|
|
1420
|
+
onEdgeAdvance
|
|
1230
1421
|
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
1231
1422
|
})),
|
|
1232
1423
|
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NowIndicator, {
|
|
@@ -1248,7 +1439,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1248
1439
|
});
|
|
1249
1440
|
}
|
|
1250
1441
|
const TimetablePage = (0, react.memo)(TimetablePageInner);
|
|
1251
|
-
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, calendarCellStyle, businessHours, 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", hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
1442
|
+
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 }) {
|
|
1252
1443
|
const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
|
|
1253
1444
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
1254
1445
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -1259,6 +1450,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1259
1450
|
]);
|
|
1260
1451
|
const { width, height } = (0, react_native.useWindowDimensions)();
|
|
1261
1452
|
const listRef = (0, react.useRef)(null);
|
|
1453
|
+
const pagerRef = (0, react.useRef)(null);
|
|
1262
1454
|
const containerRef = (0, react.useRef)(null);
|
|
1263
1455
|
const suppressCaptureUntilRef = (0, react.useRef)(0);
|
|
1264
1456
|
const [pageHeight, setPageHeight] = (0, react.useState)(height);
|
|
@@ -1268,6 +1460,84 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1268
1460
|
const step = weekAnchored ? 7 : (0, _super_calendar_core.viewDayCount)(mode, numberOfDays);
|
|
1269
1461
|
const seedDefaultY = Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR$1 - clampedMinHour) * hourHeight;
|
|
1270
1462
|
const scrollY = (0, react_native_reanimated.useSharedValue)(seedDefaultY);
|
|
1463
|
+
const pagerLeft = (0, react_native_reanimated.useSharedValue)(0);
|
|
1464
|
+
const pagerTop = (0, react_native_reanimated.useSharedValue)(0);
|
|
1465
|
+
const pagerWidth = (0, react_native_reanimated.useSharedValue)(width);
|
|
1466
|
+
const [edgePagingLock, setEdgePagingLock] = (0, react.useState)(false);
|
|
1467
|
+
const ghostX = (0, react_native_reanimated.useSharedValue)(0);
|
|
1468
|
+
const ghostY = (0, react_native_reanimated.useSharedValue)(0);
|
|
1469
|
+
const ghostW = (0, react_native_reanimated.useSharedValue)(0);
|
|
1470
|
+
const ghostH = (0, react_native_reanimated.useSharedValue)(0);
|
|
1471
|
+
const ghostVisible = (0, react_native_reanimated.useSharedValue)(0);
|
|
1472
|
+
const gridTop = (0, react_native_reanimated.useSharedValue)(0);
|
|
1473
|
+
const [liftedEvent, setLiftedEvent] = (0, react.useState)(null);
|
|
1474
|
+
const liftedEventRef = (0, react.useRef)(null);
|
|
1475
|
+
const dropRef = (0, react.useRef)({
|
|
1476
|
+
headerDays: [],
|
|
1477
|
+
containerWidth,
|
|
1478
|
+
hourColumnWidth,
|
|
1479
|
+
minHour: clampedMinHour,
|
|
1480
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1481
|
+
onDragEvent,
|
|
1482
|
+
onChangeDate
|
|
1483
|
+
});
|
|
1484
|
+
const beginLift = (0, react.useCallback)((event) => {
|
|
1485
|
+
liftedEventRef.current = event;
|
|
1486
|
+
setLiftedEvent(event);
|
|
1487
|
+
}, []);
|
|
1488
|
+
const clearLift = (0, react.useCallback)(() => {
|
|
1489
|
+
ghostVisible.value = 0;
|
|
1490
|
+
liftedEventRef.current = null;
|
|
1491
|
+
setLiftedEvent(null);
|
|
1492
|
+
setEdgePagingLock(false);
|
|
1493
|
+
}, [ghostVisible]);
|
|
1494
|
+
const commitLiftedDrop = (0, react.useCallback)((ghostLocalX, ghostLocalY) => {
|
|
1495
|
+
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1496
|
+
const ev = liftedEventRef.current;
|
|
1497
|
+
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1498
|
+
clearLift();
|
|
1499
|
+
if (!ev || !onDrag || days.length === 0) return;
|
|
1500
|
+
const dayWidth = (cw - hcw) / days.length;
|
|
1501
|
+
const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
|
|
1502
|
+
const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1503
|
+
const minutes = Math.round(rawMinutes / snap) * snap;
|
|
1504
|
+
const start = new Date(days[col]);
|
|
1505
|
+
start.setHours(0, 0, 0, 0);
|
|
1506
|
+
start.setMinutes(minutes);
|
|
1507
|
+
if (onDrag(ev, start, new Date(start.getTime() + duration)) === false) onDate(ev.start);
|
|
1508
|
+
}, [
|
|
1509
|
+
clearLift,
|
|
1510
|
+
gridTop,
|
|
1511
|
+
scrollY,
|
|
1512
|
+
cellHeight
|
|
1513
|
+
]);
|
|
1514
|
+
const handleGridTop = (0, react.useCallback)((y) => {
|
|
1515
|
+
gridTop.value = y;
|
|
1516
|
+
}, [gridTop]);
|
|
1517
|
+
const edgePaging = (0, react.useMemo)(() => ({
|
|
1518
|
+
pagerLeft,
|
|
1519
|
+
pagerTop,
|
|
1520
|
+
pagerWidth,
|
|
1521
|
+
lockScroll: setEdgePagingLock,
|
|
1522
|
+
ghostX,
|
|
1523
|
+
ghostY,
|
|
1524
|
+
ghostW,
|
|
1525
|
+
ghostH,
|
|
1526
|
+
ghostVisible,
|
|
1527
|
+
beginLift,
|
|
1528
|
+
commitLiftedDrop
|
|
1529
|
+
}), [
|
|
1530
|
+
pagerLeft,
|
|
1531
|
+
pagerTop,
|
|
1532
|
+
pagerWidth,
|
|
1533
|
+
ghostX,
|
|
1534
|
+
ghostY,
|
|
1535
|
+
ghostW,
|
|
1536
|
+
ghostH,
|
|
1537
|
+
ghostVisible,
|
|
1538
|
+
beginLift,
|
|
1539
|
+
commitLiftedDrop
|
|
1540
|
+
]);
|
|
1271
1541
|
const offsetSeedRef = (0, react.useRef)(null);
|
|
1272
1542
|
const captureOffsetSeed = (0, react.useCallback)((y) => {
|
|
1273
1543
|
offsetSeedRef.current = y;
|
|
@@ -1292,7 +1562,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1292
1562
|
])(date);
|
|
1293
1563
|
const viewedIndexRef = (0, react.useRef)(activeIndex);
|
|
1294
1564
|
const pendingScrollIndexRef = (0, react.useRef)(null);
|
|
1295
|
-
const headerDays = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1565
|
+
const headerDays = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
1296
1566
|
mode,
|
|
1297
1567
|
pageDates,
|
|
1298
1568
|
activeIndex,
|
|
@@ -1300,8 +1570,18 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1300
1570
|
weekStartsOn,
|
|
1301
1571
|
numberOfDays,
|
|
1302
1572
|
isRTL,
|
|
1303
|
-
weekEndsOn
|
|
1573
|
+
weekEndsOn,
|
|
1574
|
+
hiddenDays
|
|
1304
1575
|
]);
|
|
1576
|
+
dropRef.current = {
|
|
1577
|
+
headerDays,
|
|
1578
|
+
containerWidth,
|
|
1579
|
+
hourColumnWidth,
|
|
1580
|
+
minHour: clampedMinHour,
|
|
1581
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1582
|
+
onDragEvent,
|
|
1583
|
+
onChangeDate
|
|
1584
|
+
};
|
|
1305
1585
|
const handleViewableItemsChanged = (0, react.useCallback)((info) => {
|
|
1306
1586
|
if (isWeb$1) return;
|
|
1307
1587
|
const settled = info.viewableItems.find((token) => token.isViewable);
|
|
@@ -1387,14 +1667,15 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1387
1667
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
1388
1668
|
return () => cancelAnimationFrame(raf);
|
|
1389
1669
|
}, [pageHeight]);
|
|
1390
|
-
|
|
1670
|
+
const goToPage = (0, react.useCallback)((delta) => {
|
|
1391
1671
|
const target = pageDates[activeIndex + delta];
|
|
1392
1672
|
if (target) onChangeDate(target);
|
|
1393
1673
|
}, [
|
|
1394
1674
|
pageDates,
|
|
1395
1675
|
activeIndex,
|
|
1396
1676
|
onChangeDate
|
|
1397
|
-
])
|
|
1677
|
+
]);
|
|
1678
|
+
require_MonthList.useWebPagerKeys(swipeEnabled, goToPage);
|
|
1398
1679
|
const reduceMotion = (0, react_native_reanimated.useReducedMotion)();
|
|
1399
1680
|
const handlePressCell = (0, react.useMemo)(() => {
|
|
1400
1681
|
if (!onPressCell) return void 0;
|
|
@@ -1423,6 +1704,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1423
1704
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimetablePage, {
|
|
1424
1705
|
mode,
|
|
1425
1706
|
numberOfDays,
|
|
1707
|
+
hiddenDays,
|
|
1708
|
+
now,
|
|
1709
|
+
nowTimeZone: timeZone,
|
|
1426
1710
|
date: item,
|
|
1427
1711
|
width: containerWidth,
|
|
1428
1712
|
events,
|
|
@@ -1442,11 +1726,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1442
1726
|
timeslots,
|
|
1443
1727
|
isRTL,
|
|
1444
1728
|
showAllDayEventCell,
|
|
1729
|
+
highlightWeekends,
|
|
1445
1730
|
showVerticalScrollIndicator,
|
|
1446
1731
|
verticalScrollEnabled,
|
|
1447
1732
|
hourComponent,
|
|
1448
1733
|
calendarCellStyle,
|
|
1449
1734
|
businessHours,
|
|
1735
|
+
renderBusinessHours,
|
|
1450
1736
|
minHourHeight,
|
|
1451
1737
|
maxHourHeight,
|
|
1452
1738
|
showNowIndicator,
|
|
@@ -1460,11 +1746,14 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1460
1746
|
onDragStart,
|
|
1461
1747
|
onPressCell: handlePressCell,
|
|
1462
1748
|
onLongPressCell,
|
|
1463
|
-
onCreateEvent
|
|
1749
|
+
onCreateEvent,
|
|
1750
|
+
onEdgeAdvance: goToPage,
|
|
1751
|
+
onGridTop: handleGridTop
|
|
1464
1752
|
})
|
|
1465
1753
|
}), [
|
|
1466
1754
|
containerWidth,
|
|
1467
1755
|
pageHeight,
|
|
1756
|
+
handleGridTop,
|
|
1468
1757
|
mode,
|
|
1469
1758
|
numberOfDays,
|
|
1470
1759
|
events,
|
|
@@ -1484,6 +1773,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1484
1773
|
timeslots,
|
|
1485
1774
|
isRTL,
|
|
1486
1775
|
showAllDayEventCell,
|
|
1776
|
+
highlightWeekends,
|
|
1487
1777
|
showVerticalScrollIndicator,
|
|
1488
1778
|
verticalScrollEnabled,
|
|
1489
1779
|
hourComponent,
|
|
@@ -1502,7 +1792,11 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1502
1792
|
onDragStart,
|
|
1503
1793
|
handlePressCell,
|
|
1504
1794
|
onLongPressCell,
|
|
1505
|
-
onCreateEvent
|
|
1795
|
+
onCreateEvent,
|
|
1796
|
+
goToPage,
|
|
1797
|
+
hiddenDays,
|
|
1798
|
+
now,
|
|
1799
|
+
timeZone
|
|
1506
1800
|
]);
|
|
1507
1801
|
const listExtraData = (0, react.useMemo)(() => ({
|
|
1508
1802
|
events,
|
|
@@ -1511,52 +1805,70 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1511
1805
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MonthList.SlotStylesProvider, {
|
|
1512
1806
|
classNames,
|
|
1513
1807
|
styles: styleOverrides,
|
|
1514
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
keyExtractor: keyExtractorList,
|
|
1546
|
-
getFixedItemSize,
|
|
1547
|
-
...isWeb$1 ? null : {
|
|
1548
|
-
scrollEnabled: swipeEnabled,
|
|
1549
|
-
pagingEnabled: !freeSwipe,
|
|
1550
|
-
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1808
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EdgePagingContext.Provider, {
|
|
1809
|
+
value: edgePaging,
|
|
1810
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
1811
|
+
ref: containerRef,
|
|
1812
|
+
style: styles$1.container,
|
|
1813
|
+
children: [
|
|
1814
|
+
renderHeader ? renderHeader(headerDays) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultHeader, {
|
|
1815
|
+
days: headerDays,
|
|
1816
|
+
mode,
|
|
1817
|
+
width: containerWidth,
|
|
1818
|
+
hourColumnWidth,
|
|
1819
|
+
showWeekNumber,
|
|
1820
|
+
weekNumberPrefix,
|
|
1821
|
+
weekdayFormat,
|
|
1822
|
+
locale,
|
|
1823
|
+
activeDate,
|
|
1824
|
+
onPressDateHeader
|
|
1825
|
+
}),
|
|
1826
|
+
headerComponent,
|
|
1827
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
1828
|
+
ref: pagerRef,
|
|
1829
|
+
style: styles$1.pager,
|
|
1830
|
+
onLayout: (event) => {
|
|
1831
|
+
setPageHeight(event.nativeEvent.layout.height);
|
|
1832
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
1833
|
+
setMeasured(true);
|
|
1834
|
+
pagerRef.current?.measureInWindow((x, y, w) => {
|
|
1835
|
+
pagerLeft.value = x;
|
|
1836
|
+
pagerTop.value = y;
|
|
1837
|
+
pagerWidth.value = w;
|
|
1838
|
+
});
|
|
1551
1839
|
},
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1840
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_legendapp_list_react_native.LegendList, {
|
|
1841
|
+
ref: listRef,
|
|
1842
|
+
style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
|
|
1843
|
+
data: pageDates,
|
|
1844
|
+
extraData: listExtraData,
|
|
1845
|
+
horizontal: true,
|
|
1846
|
+
recycleItems: false,
|
|
1847
|
+
keyExtractor: keyExtractorList,
|
|
1848
|
+
getFixedItemSize,
|
|
1849
|
+
...isWeb$1 ? null : {
|
|
1850
|
+
scrollEnabled: swipeEnabled && !edgePagingLock,
|
|
1851
|
+
pagingEnabled: !freeSwipe,
|
|
1852
|
+
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1853
|
+
},
|
|
1854
|
+
initialScrollIndex: activeIndex,
|
|
1855
|
+
showsHorizontalScrollIndicator: false,
|
|
1856
|
+
viewabilityConfig: PAGE_VIEWABILITY,
|
|
1857
|
+
onViewableItemsChanged: handleViewableItemsChanged,
|
|
1858
|
+
renderItem
|
|
1859
|
+
}, measured ? "grid" : "grid-seed"), liftedEvent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DragGhost, {
|
|
1860
|
+
x: ghostX,
|
|
1861
|
+
y: ghostY,
|
|
1862
|
+
w: ghostW,
|
|
1863
|
+
h: ghostH,
|
|
1864
|
+
visible: ghostVisible,
|
|
1865
|
+
event: liftedEvent,
|
|
1866
|
+
mode,
|
|
1867
|
+
renderEvent: labeledRenderEvent
|
|
1868
|
+
}) : null]
|
|
1869
|
+
})
|
|
1870
|
+
]
|
|
1871
|
+
})
|
|
1560
1872
|
})
|
|
1561
1873
|
});
|
|
1562
1874
|
}
|
|
@@ -1740,6 +2052,11 @@ const styles$1 = react_native.StyleSheet.create({
|
|
|
1740
2052
|
overflow: "hidden",
|
|
1741
2053
|
padding: EVENT_GAP
|
|
1742
2054
|
},
|
|
2055
|
+
dragGhost: {
|
|
2056
|
+
top: 0,
|
|
2057
|
+
left: 0,
|
|
2058
|
+
zIndex: 101
|
|
2059
|
+
},
|
|
1743
2060
|
nowIndicator: {
|
|
1744
2061
|
position: "absolute",
|
|
1745
2062
|
height: 2
|
|
@@ -1790,7 +2107,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
1790
2107
|
* }
|
|
1791
2108
|
* ```
|
|
1792
2109
|
*/
|
|
1793
|
-
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, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, 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 }) {
|
|
2110
|
+
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 }) {
|
|
1794
2111
|
const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
|
|
1795
2112
|
const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
|
|
1796
2113
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -1867,6 +2184,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1867
2184
|
events: displayEvents,
|
|
1868
2185
|
maxVisibleEventCount,
|
|
1869
2186
|
weekStartsOn,
|
|
2187
|
+
hiddenDays,
|
|
1870
2188
|
weekdayFormat,
|
|
1871
2189
|
locale,
|
|
1872
2190
|
sortedMonthView,
|
|
@@ -1895,6 +2213,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1895
2213
|
date,
|
|
1896
2214
|
events: displayEvents,
|
|
1897
2215
|
weekStartsOn,
|
|
2216
|
+
hiddenDays,
|
|
1898
2217
|
locale,
|
|
1899
2218
|
activeDate,
|
|
1900
2219
|
onPressDay,
|
|
@@ -1923,6 +2242,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1923
2242
|
hourHeight,
|
|
1924
2243
|
weekStartsOn,
|
|
1925
2244
|
weekdayFormat,
|
|
2245
|
+
hiddenDays,
|
|
2246
|
+
now,
|
|
2247
|
+
timeZone,
|
|
1926
2248
|
renderEvent: resolvedRenderEvent,
|
|
1927
2249
|
keyExtractor,
|
|
1928
2250
|
scrollOffsetMinutes,
|
|
@@ -1930,8 +2252,10 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1930
2252
|
hideHours,
|
|
1931
2253
|
timeslots,
|
|
1932
2254
|
showAllDayEventCell,
|
|
2255
|
+
highlightWeekends,
|
|
1933
2256
|
calendarCellStyle,
|
|
1934
2257
|
businessHours,
|
|
2258
|
+
renderBusinessHours,
|
|
1935
2259
|
showWeekNumber,
|
|
1936
2260
|
weekNumberPrefix,
|
|
1937
2261
|
hourComponent,
|
|
@@ -2005,41 +2329,60 @@ function DefaultBar({ event, width, height }) {
|
|
|
2005
2329
|
}) : null]
|
|
2006
2330
|
});
|
|
2007
2331
|
}
|
|
2008
|
-
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, theme }) {
|
|
2332
|
+
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, resources, laneIndex, laneSize, dragActive, onDragActiveChange, theme }) {
|
|
2009
2333
|
const moveX = (0, react_native_reanimated.useSharedValue)(0);
|
|
2334
|
+
const moveCross = (0, react_native_reanimated.useSharedValue)(0);
|
|
2010
2335
|
const resizeW = (0, react_native_reanimated.useSharedValue)(0);
|
|
2011
2336
|
const latest = (0, react.useRef)({
|
|
2012
2337
|
event: pe.event,
|
|
2013
|
-
onDragEvent
|
|
2338
|
+
onDragEvent,
|
|
2339
|
+
resources,
|
|
2340
|
+
laneIndex
|
|
2014
2341
|
});
|
|
2015
2342
|
latest.current = {
|
|
2016
2343
|
event: pe.event,
|
|
2017
|
-
onDragEvent
|
|
2344
|
+
onDragEvent,
|
|
2345
|
+
resources,
|
|
2346
|
+
laneIndex
|
|
2018
2347
|
};
|
|
2019
|
-
const
|
|
2348
|
+
const laneCount = resources.length;
|
|
2349
|
+
const draggable = !pe.event.disabled && pe.event.draggable !== false;
|
|
2020
2350
|
(0, react.useEffect)(() => {
|
|
2351
|
+
if (dragActive) return;
|
|
2021
2352
|
moveX.value = 0;
|
|
2353
|
+
moveCross.value = 0;
|
|
2022
2354
|
resizeW.value = 0;
|
|
2023
2355
|
}, [
|
|
2356
|
+
dragActive,
|
|
2024
2357
|
pe.startHours,
|
|
2025
2358
|
pe.durationHours,
|
|
2026
2359
|
moveX,
|
|
2360
|
+
moveCross,
|
|
2027
2361
|
resizeW
|
|
2028
2362
|
]);
|
|
2029
2363
|
const snapBack = (0, react.useCallback)(() => {
|
|
2030
2364
|
moveX.value = 0;
|
|
2365
|
+
moveCross.value = 0;
|
|
2031
2366
|
resizeW.value = 0;
|
|
2032
|
-
}, [
|
|
2033
|
-
|
|
2034
|
-
|
|
2367
|
+
}, [
|
|
2368
|
+
moveX,
|
|
2369
|
+
moveCross,
|
|
2370
|
+
resizeW
|
|
2371
|
+
]);
|
|
2372
|
+
const commit = (0, react.useCallback)((deltaStartMin, deltaEndMin, laneDelta = 0) => {
|
|
2373
|
+
const { event, onDragEvent: handler, resources: lanes, laneIndex: lane } = latest.current;
|
|
2035
2374
|
const next = (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, deltaStartMin, deltaEndMin, snapMinutes);
|
|
2036
|
-
|
|
2375
|
+
const target = lanes[Math.min(Math.max(lane + laneDelta, 0), lanes.length - 1)];
|
|
2376
|
+
if (!next || !target) {
|
|
2037
2377
|
snapBack();
|
|
2038
2378
|
return;
|
|
2039
2379
|
}
|
|
2040
|
-
if (handler(event, next.start, next.end) === false) snapBack();
|
|
2380
|
+
if (handler(event, next.start, next.end, target) === false) snapBack();
|
|
2041
2381
|
}, [snapMinutes, snapBack]);
|
|
2042
2382
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
2383
|
+
const laneTitle = (lane) => lane && (lane.title || lane.id);
|
|
2384
|
+
const nextLane = laneTitle(resources[laneIndex + 1]);
|
|
2385
|
+
const previousLane = laneTitle(resources[laneIndex - 1]);
|
|
2043
2386
|
const barActions = draggable ? [
|
|
2044
2387
|
{
|
|
2045
2388
|
name: "move-later",
|
|
@@ -2056,7 +2399,15 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
2056
2399
|
{
|
|
2057
2400
|
name: "shrink",
|
|
2058
2401
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
2059
|
-
}
|
|
2402
|
+
},
|
|
2403
|
+
...nextLane ? [{
|
|
2404
|
+
name: "move-next-lane",
|
|
2405
|
+
label: `Move to ${nextLane}`
|
|
2406
|
+
}] : [],
|
|
2407
|
+
...previousLane ? [{
|
|
2408
|
+
name: "move-previous-lane",
|
|
2409
|
+
label: `Move to ${previousLane}`
|
|
2410
|
+
}] : []
|
|
2060
2411
|
] : void 0;
|
|
2061
2412
|
const onBarAction = draggable ? (e) => {
|
|
2062
2413
|
switch (e.nativeEvent.actionName) {
|
|
@@ -2072,36 +2423,61 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
2072
2423
|
case "shrink":
|
|
2073
2424
|
commit(0, -snapMinutes);
|
|
2074
2425
|
break;
|
|
2426
|
+
case "move-next-lane":
|
|
2427
|
+
commit(0, 0, 1);
|
|
2428
|
+
break;
|
|
2429
|
+
case "move-previous-lane":
|
|
2430
|
+
commit(0, 0, -1);
|
|
2431
|
+
break;
|
|
2075
2432
|
}
|
|
2076
2433
|
} : void 0;
|
|
2077
2434
|
const barStyle = (0, react_native_reanimated.useAnimatedStyle)(() => vertical ? {
|
|
2078
|
-
transform: [{ translateY: moveX.value }],
|
|
2435
|
+
transform: [{ translateY: moveX.value }, { translateX: moveCross.value }],
|
|
2079
2436
|
height: Math.max(height + resizeW.value, 2)
|
|
2080
2437
|
} : {
|
|
2081
|
-
transform: [{ translateX: moveX.value }],
|
|
2438
|
+
transform: [{ translateX: moveX.value }, { translateY: moveCross.value }],
|
|
2082
2439
|
width: Math.max(width + resizeW.value, 2)
|
|
2083
2440
|
}, [
|
|
2084
2441
|
vertical,
|
|
2085
2442
|
width,
|
|
2086
2443
|
height
|
|
2087
2444
|
]);
|
|
2088
|
-
const
|
|
2445
|
+
const laneId = resources[laneIndex]?.id ?? "";
|
|
2446
|
+
const moveGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
|
|
2447
|
+
(0, react_native_reanimated.runOnJS)(onDragActiveChange)(laneId);
|
|
2448
|
+
}).onUpdate((e) => {
|
|
2089
2449
|
moveX.value = vertical ? e.translationY : e.translationX;
|
|
2450
|
+
if (laneSize > 0 && laneCount > 1) {
|
|
2451
|
+
const cross = vertical ? e.translationX : e.translationY;
|
|
2452
|
+
moveCross.value = Math.min(Math.max(cross, -laneIndex * laneSize), (laneCount - 1 - laneIndex) * laneSize);
|
|
2453
|
+
}
|
|
2090
2454
|
}).onEnd((e) => {
|
|
2091
2455
|
const delta = (0, _super_calendar_core.snapDeltaMinutes)(vertical ? e.translationY : e.translationX, hourSize, snapMinutes);
|
|
2092
|
-
|
|
2456
|
+
const cross = laneSize > 0 ? vertical ? e.translationX : e.translationY : 0;
|
|
2457
|
+
const laneDelta = laneSize > 0 ? Math.min(Math.max(Math.round(cross / laneSize), -laneIndex), laneCount - 1 - laneIndex) : 0;
|
|
2458
|
+
if (delta === 0 && laneDelta === 0) {
|
|
2093
2459
|
moveX.value = 0;
|
|
2460
|
+
moveCross.value = 0;
|
|
2094
2461
|
return;
|
|
2095
2462
|
}
|
|
2096
2463
|
moveX.value = delta / MINUTES_PER_HOUR * hourSize;
|
|
2097
|
-
|
|
2464
|
+
moveCross.value = laneDelta * laneSize;
|
|
2465
|
+
(0, react_native_reanimated.runOnJS)(commit)(delta, delta, laneDelta);
|
|
2466
|
+
}).onFinalize(() => {
|
|
2467
|
+
(0, react_native_reanimated.runOnJS)(onDragActiveChange)(null);
|
|
2098
2468
|
}), [
|
|
2099
2469
|
draggable,
|
|
2100
2470
|
vertical,
|
|
2101
2471
|
hourSize,
|
|
2102
2472
|
snapMinutes,
|
|
2473
|
+
laneSize,
|
|
2474
|
+
laneCount,
|
|
2475
|
+
laneIndex,
|
|
2476
|
+
laneId,
|
|
2103
2477
|
moveX,
|
|
2104
|
-
|
|
2478
|
+
moveCross,
|
|
2479
|
+
commit,
|
|
2480
|
+
onDragActiveChange
|
|
2105
2481
|
]);
|
|
2106
2482
|
const resizeGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(draggable).onUpdate((e) => {
|
|
2107
2483
|
resizeW.value = vertical ? e.translationY : e.translationX;
|
|
@@ -2287,11 +2663,57 @@ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, s
|
|
|
2287
2663
|
* />
|
|
2288
2664
|
* ```
|
|
2289
2665
|
*/
|
|
2290
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources, 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, dragStepMinutes = 15 }) {
|
|
2666
|
+
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 }) {
|
|
2291
2667
|
const theme = require_MonthList.useCalendarTheme();
|
|
2668
|
+
const resources = (0, react.useMemo)(() => {
|
|
2669
|
+
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
2670
|
+
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
2671
|
+
const page = Math.min(Math.max(resourcePage, 0), pages - 1);
|
|
2672
|
+
return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
|
|
2673
|
+
}, [
|
|
2674
|
+
allResources,
|
|
2675
|
+
resourcesPerPage,
|
|
2676
|
+
resourcePage
|
|
2677
|
+
]);
|
|
2678
|
+
const [dragLaneId, setDragLaneId] = (0, react.useState)(null);
|
|
2679
|
+
const [vBodyWidth, setVBodyWidth] = (0, react.useState)(0);
|
|
2680
|
+
const vLaneSize = resources.length > 0 && vBodyWidth > GUTTER_WIDTH ? (vBodyWidth - GUTTER_WIDTH) / resources.length : 0;
|
|
2292
2681
|
const Renderer = renderEvent ?? DefaultBar;
|
|
2293
2682
|
const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
|
|
2683
|
+
const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
|
|
2684
|
+
now: nowProp,
|
|
2685
|
+
timeZone
|
|
2686
|
+
});
|
|
2687
|
+
const nowHours = now.getHours() + now.getMinutes() / 60;
|
|
2688
|
+
const showNow = showNowIndicator && (0, _super_calendar_core.isSameCalendarDay)(now, date) && nowHours >= startHour && nowHours <= endHour;
|
|
2689
|
+
const nowLine = (vertical, hourSize) => showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2690
|
+
pointerEvents: "none",
|
|
2691
|
+
testID: "resource-now-indicator",
|
|
2692
|
+
style: [
|
|
2693
|
+
vertical ? {
|
|
2694
|
+
position: "absolute",
|
|
2695
|
+
left: 0,
|
|
2696
|
+
right: 0,
|
|
2697
|
+
height: 2
|
|
2698
|
+
} : {
|
|
2699
|
+
position: "absolute",
|
|
2700
|
+
top: 0,
|
|
2701
|
+
bottom: 0,
|
|
2702
|
+
width: 2
|
|
2703
|
+
},
|
|
2704
|
+
vertical ? { top: (nowHours - startHour) * hourSize } : { left: (nowHours - startHour) * hourSize },
|
|
2705
|
+
{
|
|
2706
|
+
backgroundColor: theme.colors.nowIndicator,
|
|
2707
|
+
zIndex: 2
|
|
2708
|
+
}
|
|
2709
|
+
]
|
|
2710
|
+
}) : null;
|
|
2294
2711
|
const bandsFor = (resource) => businessHours ? (0, _super_calendar_core.closedHourBands)(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
2712
|
+
const backgroundBandsFor = (resource) => (0, _super_calendar_core.backgroundBandsForDay)(events.filter((event) => resourceId(event) === resource.id), date).map((b) => ({
|
|
2713
|
+
...b,
|
|
2714
|
+
startHours: Math.max(b.startHours, startHour),
|
|
2715
|
+
endHours: Math.min(b.endHours, endHour)
|
|
2716
|
+
})).filter((b) => b.endHours > b.startHours);
|
|
2295
2717
|
const hours = (0, react.useMemo)(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
|
|
2296
2718
|
const trackWidth = (endHour - startHour) * hourWidth;
|
|
2297
2719
|
const byResource = (0, react.useMemo)(() => {
|
|
@@ -2326,6 +2748,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2326
2748
|
showsVerticalScrollIndicator: true,
|
|
2327
2749
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2328
2750
|
style: [styles.vbody, { height: trackHeight }],
|
|
2751
|
+
onLayout: (event) => setVBodyWidth(event.nativeEvent.layout.width),
|
|
2329
2752
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2330
2753
|
style: { width: GUTTER_WIDTH },
|
|
2331
2754
|
children: hours.map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
@@ -2336,24 +2759,45 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2336
2759
|
}],
|
|
2337
2760
|
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
2338
2761
|
}, h))
|
|
2339
|
-
}), resources.map((resource) => {
|
|
2762
|
+
}), resources.map((resource, laneIndex) => {
|
|
2340
2763
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2341
2764
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2342
2765
|
style: [
|
|
2343
2766
|
styles.vcolumn,
|
|
2344
2767
|
{ borderLeftColor: theme.colors.gridLine },
|
|
2345
|
-
theme.containers.resourceRow
|
|
2768
|
+
theme.containers.resourceRow,
|
|
2769
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2346
2770
|
],
|
|
2347
2771
|
children: [
|
|
2348
2772
|
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2349
2773
|
pointerEvents: "none",
|
|
2774
|
+
accessibilityElementsHidden: true,
|
|
2775
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2350
2776
|
testID: "resource-hours-shade",
|
|
2777
|
+
style: [
|
|
2778
|
+
styles.vshadeBand,
|
|
2779
|
+
{
|
|
2780
|
+
top: (b.start - startHour) * hourHeight,
|
|
2781
|
+
height: (b.end - b.start) * hourHeight
|
|
2782
|
+
},
|
|
2783
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2784
|
+
],
|
|
2785
|
+
children: renderBusinessHours?.({
|
|
2786
|
+
date,
|
|
2787
|
+
start: b.start,
|
|
2788
|
+
end: b.end,
|
|
2789
|
+
resource
|
|
2790
|
+
})
|
|
2791
|
+
}, `shade-${b.start}`)),
|
|
2792
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2793
|
+
pointerEvents: "none",
|
|
2794
|
+
testID: "background-event-shade",
|
|
2351
2795
|
style: [styles.vshadeBand, {
|
|
2352
|
-
top: (b.
|
|
2353
|
-
height: (b.
|
|
2354
|
-
backgroundColor: theme.colors.
|
|
2796
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
2797
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
2798
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2355
2799
|
}]
|
|
2356
|
-
}, `
|
|
2800
|
+
}, `bg-${i}`)),
|
|
2357
2801
|
hours.slice(1).map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2358
2802
|
pointerEvents: "none",
|
|
2359
2803
|
style: [styles.vgridLine, {
|
|
@@ -2361,6 +2805,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2361
2805
|
backgroundColor: theme.colors.gridLine
|
|
2362
2806
|
}]
|
|
2363
2807
|
}, h)),
|
|
2808
|
+
nowLine(true, hourHeight),
|
|
2364
2809
|
cellEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LaneInteractionLayer, {
|
|
2365
2810
|
resource,
|
|
2366
2811
|
vertical: true,
|
|
@@ -2384,6 +2829,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2384
2829
|
if (onDragEvent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResourceBar, {
|
|
2385
2830
|
pe,
|
|
2386
2831
|
vertical: true,
|
|
2832
|
+
resources,
|
|
2833
|
+
laneIndex,
|
|
2834
|
+
laneSize: vLaneSize,
|
|
2835
|
+
dragActive: dragLaneId === resource.id,
|
|
2836
|
+
onDragActiveChange: setDragLaneId,
|
|
2387
2837
|
hourSize: hourHeight,
|
|
2388
2838
|
left,
|
|
2389
2839
|
top,
|
|
@@ -2450,7 +2900,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2450
2900
|
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
2451
2901
|
}, h))
|
|
2452
2902
|
})]
|
|
2453
|
-
}), resources.map((resource) => {
|
|
2903
|
+
}), resources.map((resource, laneIndex) => {
|
|
2454
2904
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2455
2905
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2456
2906
|
style: [
|
|
@@ -2459,7 +2909,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2459
2909
|
height: rowHeight,
|
|
2460
2910
|
borderBottomColor: theme.colors.gridLine
|
|
2461
2911
|
},
|
|
2462
|
-
theme.containers.resourceRow
|
|
2912
|
+
theme.containers.resourceRow,
|
|
2913
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2463
2914
|
],
|
|
2464
2915
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2465
2916
|
style: [
|
|
@@ -2481,13 +2932,33 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2481
2932
|
children: [
|
|
2482
2933
|
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2483
2934
|
pointerEvents: "none",
|
|
2935
|
+
accessibilityElementsHidden: true,
|
|
2936
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2484
2937
|
testID: "resource-hours-shade",
|
|
2938
|
+
style: [
|
|
2939
|
+
styles.hshadeBand,
|
|
2940
|
+
{
|
|
2941
|
+
left: (b.start - startHour) * hourWidth,
|
|
2942
|
+
width: (b.end - b.start) * hourWidth
|
|
2943
|
+
},
|
|
2944
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2945
|
+
],
|
|
2946
|
+
children: renderBusinessHours?.({
|
|
2947
|
+
date,
|
|
2948
|
+
start: b.start,
|
|
2949
|
+
end: b.end,
|
|
2950
|
+
resource
|
|
2951
|
+
})
|
|
2952
|
+
}, `shade-${b.start}`)),
|
|
2953
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2954
|
+
pointerEvents: "none",
|
|
2955
|
+
testID: "background-event-shade",
|
|
2485
2956
|
style: [styles.hshadeBand, {
|
|
2486
|
-
left: (b.
|
|
2487
|
-
width: (b.
|
|
2488
|
-
backgroundColor: theme.colors.
|
|
2957
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
2958
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
2959
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2489
2960
|
}]
|
|
2490
|
-
}, `
|
|
2961
|
+
}, `bg-${i}`)),
|
|
2491
2962
|
hours.slice(1).map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2492
2963
|
pointerEvents: "none",
|
|
2493
2964
|
style: [styles.gridLine, {
|
|
@@ -2495,6 +2966,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2495
2966
|
backgroundColor: theme.colors.gridLine
|
|
2496
2967
|
}]
|
|
2497
2968
|
}, h)),
|
|
2969
|
+
nowLine(false, hourWidth),
|
|
2498
2970
|
cellEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LaneInteractionLayer, {
|
|
2499
2971
|
resource,
|
|
2500
2972
|
vertical: false,
|
|
@@ -2516,6 +2988,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2516
2988
|
if (onDragEvent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResourceBar, {
|
|
2517
2989
|
pe,
|
|
2518
2990
|
vertical: false,
|
|
2991
|
+
resources,
|
|
2992
|
+
laneIndex,
|
|
2993
|
+
laneSize: rowHeight,
|
|
2994
|
+
dragActive: dragLaneId === resource.id,
|
|
2995
|
+
onDragActiveChange: setDragLaneId,
|
|
2519
2996
|
hourSize: hourWidth,
|
|
2520
2997
|
left,
|
|
2521
2998
|
top: pe.column * laneHeight,
|
|
@@ -2625,6 +3102,7 @@ const styles = react_native.StyleSheet.create({
|
|
|
2625
3102
|
fontWeight: "600"
|
|
2626
3103
|
},
|
|
2627
3104
|
vbody: { flexDirection: "row" },
|
|
3105
|
+
laneLifted: { zIndex: 10 },
|
|
2628
3106
|
vcolumn: {
|
|
2629
3107
|
flex: 1,
|
|
2630
3108
|
borderLeftWidth: react_native.StyleSheet.hairlineWidth
|
|
@@ -2682,6 +3160,12 @@ exports.MonthView = require_MonthList.MonthView;
|
|
|
2682
3160
|
exports.ResourceTimeline = ResourceTimeline;
|
|
2683
3161
|
exports.TimeGrid = TimeGrid;
|
|
2684
3162
|
exports.YearView = YearView;
|
|
3163
|
+
Object.defineProperty(exports, "backgroundBandsForDay", {
|
|
3164
|
+
enumerable: true,
|
|
3165
|
+
get: function() {
|
|
3166
|
+
return _super_calendar_core.backgroundBandsForDay;
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
2685
3169
|
Object.defineProperty(exports, "buildMonthGrid", {
|
|
2686
3170
|
enumerable: true,
|
|
2687
3171
|
get: function() {
|
|
@@ -2738,6 +3222,12 @@ Object.defineProperty(exports, "isAllDayEvent", {
|
|
|
2738
3222
|
return _super_calendar_core.isAllDayEvent;
|
|
2739
3223
|
}
|
|
2740
3224
|
});
|
|
3225
|
+
Object.defineProperty(exports, "isBackgroundEvent", {
|
|
3226
|
+
enumerable: true,
|
|
3227
|
+
get: function() {
|
|
3228
|
+
return _super_calendar_core.isBackgroundEvent;
|
|
3229
|
+
}
|
|
3230
|
+
});
|
|
2741
3231
|
Object.defineProperty(exports, "isDateSelectable", {
|
|
2742
3232
|
enumerable: true,
|
|
2743
3233
|
get: function() {
|
|
@@ -2812,12 +3302,24 @@ Object.defineProperty(exports, "useDateRange", {
|
|
|
2812
3302
|
return _super_calendar_core.useDateRange;
|
|
2813
3303
|
}
|
|
2814
3304
|
});
|
|
3305
|
+
Object.defineProperty(exports, "useEventSource", {
|
|
3306
|
+
enumerable: true,
|
|
3307
|
+
get: function() {
|
|
3308
|
+
return _super_calendar_core.useEventSource;
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
2815
3311
|
Object.defineProperty(exports, "useMonthGrid", {
|
|
2816
3312
|
enumerable: true,
|
|
2817
3313
|
get: function() {
|
|
2818
3314
|
return _super_calendar_core.useMonthGrid;
|
|
2819
3315
|
}
|
|
2820
3316
|
});
|
|
3317
|
+
Object.defineProperty(exports, "useNow", {
|
|
3318
|
+
enumerable: true,
|
|
3319
|
+
get: function() {
|
|
3320
|
+
return _super_calendar_core.useNow;
|
|
3321
|
+
}
|
|
3322
|
+
});
|
|
2821
3323
|
Object.defineProperty(exports, "weekdayFormatToken", {
|
|
2822
3324
|
enumerable: true,
|
|
2823
3325
|
get: function() {
|