@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.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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-
|
|
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";
|
|
2
2
|
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
|
-
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
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 { buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, minutesIntoDay, nextDateRange, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useMonthGrid, 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, 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";
|
|
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";
|
|
9
9
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
10
10
|
//#region src/components/YearView.tsx
|
|
11
11
|
const FALLBACK_COLUMNS = 3;
|
|
12
|
-
function YearViewInner({ date, events, weekStartsOn, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
12
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
13
13
|
const theme = useCalendarTheme();
|
|
14
14
|
const slot = createSlots({
|
|
15
15
|
classNames,
|
|
@@ -22,19 +22,20 @@ function YearViewInner({ date, events, weekStartsOn, locale, activeDate, minMont
|
|
|
22
22
|
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
23
23
|
};
|
|
24
24
|
const months = useMemo(() => getYearMonths(date), [date]);
|
|
25
|
-
const weekdayLabels = useMemo(() => getWeekDays$1(date, weekStartsOn).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
|
|
25
|
+
const weekdayLabels = useMemo(() => filterHiddenDays(getWeekDays$1(date, weekStartsOn), hiddenDays).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
|
|
26
26
|
date,
|
|
27
27
|
weekStartsOn,
|
|
28
|
-
locale
|
|
28
|
+
locale,
|
|
29
|
+
hiddenDays
|
|
29
30
|
]);
|
|
30
|
-
const eventDays = useMemo(() => new Set(events && events.length > 0 ? groupEventsByDay(events).keys() : []), [events]);
|
|
31
|
+
const eventDays = useMemo(() => new Set(events && events.length > 0 ? groupEventsByDay(events.filter((e) => !isBackgroundEvent$1(e))).keys() : []), [events]);
|
|
31
32
|
return /* @__PURE__ */ jsx(ScrollView, {
|
|
32
33
|
onLayout: handleLayout,
|
|
33
34
|
showsVerticalScrollIndicator: true,
|
|
34
35
|
children: /* @__PURE__ */ jsx(View, {
|
|
35
36
|
...slot("grid", { base: styles$5.grid }),
|
|
36
37
|
children: months.map((month) => {
|
|
37
|
-
const weeks = buildMonthWeeks$1(month, weekStartsOn);
|
|
38
|
+
const weeks = buildMonthWeeks$1(month, weekStartsOn, { hiddenDays });
|
|
38
39
|
const title = format(month, "MMMM", { locale });
|
|
39
40
|
const monthLabel = format(month, "MMMM yyyy", { locale });
|
|
40
41
|
const titleText = /* @__PURE__ */ jsx(Text, {
|
|
@@ -184,7 +185,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
184
185
|
}), [classNames, styleOverrides]);
|
|
185
186
|
const RenderEventComponent = renderEvent;
|
|
186
187
|
const rows = useMemo(() => {
|
|
187
|
-
const sorted =
|
|
188
|
+
const sorted = events.filter((event) => !isBackgroundEvent$1(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
188
189
|
const out = [];
|
|
189
190
|
let currentDay = null;
|
|
190
191
|
sorted.forEach((event, index) => {
|
|
@@ -351,7 +352,7 @@ function DefaultEvent({ event, mode, boxHeight, isAllDay, ampm = false, showTime
|
|
|
351
352
|
],
|
|
352
353
|
onPress,
|
|
353
354
|
onLongPress,
|
|
354
|
-
activeOpacity:
|
|
355
|
+
activeOpacity: 1,
|
|
355
356
|
accessibilityRole: "button",
|
|
356
357
|
accessibilityLabel,
|
|
357
358
|
accessibilityState: { disabled: event.disabled ?? false },
|
|
@@ -481,7 +482,7 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
|
|
|
481
482
|
const theme = useCalendarTheme();
|
|
482
483
|
const slot = useSlots();
|
|
483
484
|
const RenderEventComponent = renderEvent;
|
|
484
|
-
const allDay = events.filter(isAllDayEvent$1);
|
|
485
|
+
const allDay = events.filter((event) => isAllDayEvent$1(event) && !isBackgroundEvent$1(event));
|
|
485
486
|
const perDay = days.map((day) => {
|
|
486
487
|
const start = startOfDay(day);
|
|
487
488
|
const next = addDays(start, 1);
|
|
@@ -559,34 +560,72 @@ const MOVE_ACTIVATE_MS$1 = 500;
|
|
|
559
560
|
const DRAG_ACTIVATE_PX$1 = 8;
|
|
560
561
|
const RESIZE_HANDLE_HEIGHT = 14;
|
|
561
562
|
const DEFAULT_DRAG_STEP_MINUTES = 15;
|
|
562
|
-
const
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
563
|
+
const DRAG_EVENT_Z = 100;
|
|
564
|
+
const EDGE_DWELL_MS = 500;
|
|
565
|
+
const EDGE_ZONE_PX = 36;
|
|
566
|
+
const EdgePagingContext = createContext(null);
|
|
567
|
+
const noop = () => {};
|
|
568
|
+
/**
|
|
569
|
+
* The floating copy of a dragged event, rendered above the pager so a cross-week
|
|
570
|
+
* drag stays visible after its source page pages away. Position, size, and
|
|
571
|
+
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
572
|
+
* finger without a React re-render.
|
|
573
|
+
*/
|
|
574
|
+
function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
575
|
+
const RenderEventComponent = renderEvent;
|
|
576
|
+
const style = useAnimatedStyle(() => ({
|
|
577
|
+
transform: [{ translateX: x.value }, { translateY: y.value }],
|
|
578
|
+
width: w.value,
|
|
579
|
+
height: h.value,
|
|
580
|
+
opacity: visible.value
|
|
581
|
+
}));
|
|
582
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
583
|
+
style: [
|
|
584
|
+
styles$1.eventBox,
|
|
585
|
+
styles$1.dragGhost,
|
|
586
|
+
style
|
|
587
|
+
],
|
|
588
|
+
pointerEvents: "none",
|
|
589
|
+
children: /* @__PURE__ */ jsx(RenderEventComponent, {
|
|
590
|
+
event,
|
|
591
|
+
mode,
|
|
592
|
+
boxHeight: h,
|
|
593
|
+
onPress: noop
|
|
594
|
+
})
|
|
595
|
+
});
|
|
573
596
|
}
|
|
574
|
-
|
|
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 }) {
|
|
575
599
|
const RenderEventComponent = renderEvent;
|
|
576
600
|
const theme = useCalendarTheme();
|
|
577
601
|
const slot = useSlots();
|
|
578
|
-
const
|
|
602
|
+
const edgePaging = useContext(EdgePagingContext);
|
|
603
|
+
const pagerLeftSV = edgePaging?.pagerLeft;
|
|
604
|
+
const pagerTopSV = edgePaging?.pagerTop;
|
|
605
|
+
const pagerWidthSV = edgePaging?.pagerWidth;
|
|
606
|
+
const ghostXSV = edgePaging?.ghostX;
|
|
607
|
+
const ghostYSV = edgePaging?.ghostY;
|
|
608
|
+
const commitLiftedDrop = edgePaging?.commitLiftedDrop;
|
|
609
|
+
const draggable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
|
|
579
610
|
const resizable = draggable && !positioned.continuesAfter;
|
|
580
611
|
const moveOffset = useSharedValue(0);
|
|
581
612
|
const moveOffsetX = useSharedValue(0);
|
|
582
613
|
const resizeDelta = useSharedValue(0);
|
|
614
|
+
const dragZ = useSharedValue(0);
|
|
615
|
+
const edgeDir = useSharedValue(0);
|
|
616
|
+
const lifted = useSharedValue(0);
|
|
617
|
+
const grabX = useSharedValue(0);
|
|
618
|
+
const grabY = useSharedValue(0);
|
|
619
|
+
const liveAbsX = useSharedValue(0);
|
|
620
|
+
const liveAbsY = useSharedValue(0);
|
|
583
621
|
const startHours = positioned.startHours;
|
|
584
622
|
const durationHours = positioned.durationHours;
|
|
585
623
|
const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
|
|
586
624
|
const boxStyle = useAnimatedStyle(() => ({
|
|
587
625
|
top: (startHours - minHour) * cellHeight.value + moveOffset.value,
|
|
588
626
|
height: boxHeight.value,
|
|
589
|
-
transform: [{ translateX: moveOffsetX.value }]
|
|
627
|
+
transform: [{ translateX: moveOffsetX.value }],
|
|
628
|
+
zIndex: dragZ.value
|
|
590
629
|
}), [
|
|
591
630
|
startHours,
|
|
592
631
|
durationHours,
|
|
@@ -635,16 +674,81 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
635
674
|
const notifyDragStart = useCallback(() => {
|
|
636
675
|
latest.current.onDragStart?.(latest.current.event);
|
|
637
676
|
}, []);
|
|
677
|
+
const dwellTimer = useRef(null);
|
|
678
|
+
const disarmEdge = useCallback(() => {
|
|
679
|
+
if (dwellTimer.current) {
|
|
680
|
+
clearTimeout(dwellTimer.current);
|
|
681
|
+
dwellTimer.current = null;
|
|
682
|
+
}
|
|
683
|
+
}, []);
|
|
684
|
+
const releaseEdge = useCallback(() => {
|
|
685
|
+
disarmEdge();
|
|
686
|
+
edgePaging?.lockScroll(false);
|
|
687
|
+
}, [disarmEdge, edgePaging]);
|
|
688
|
+
const armEdge = useCallback((dir) => {
|
|
689
|
+
disarmEdge();
|
|
690
|
+
dwellTimer.current = setTimeout(() => {
|
|
691
|
+
dwellTimer.current = null;
|
|
692
|
+
if (!edgePaging) return;
|
|
693
|
+
edgePaging.lockScroll(true);
|
|
694
|
+
if (!lifted.value) {
|
|
695
|
+
lifted.value = 1;
|
|
696
|
+
edgePaging.ghostW.value = width;
|
|
697
|
+
edgePaging.ghostH.value = boxHeight.value;
|
|
698
|
+
edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
|
|
699
|
+
edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
|
|
700
|
+
edgePaging.ghostVisible.value = 1;
|
|
701
|
+
edgePaging.beginLift(latest.current.event);
|
|
702
|
+
}
|
|
703
|
+
onEdgeAdvance?.(dir);
|
|
704
|
+
}, EDGE_DWELL_MS);
|
|
705
|
+
}, [
|
|
706
|
+
disarmEdge,
|
|
707
|
+
edgePaging,
|
|
708
|
+
lifted,
|
|
709
|
+
width,
|
|
710
|
+
boxHeight,
|
|
711
|
+
liveAbsX,
|
|
712
|
+
liveAbsY,
|
|
713
|
+
grabX,
|
|
714
|
+
grabY,
|
|
715
|
+
onEdgeAdvance
|
|
716
|
+
]);
|
|
638
717
|
const moveGesture = useMemo(() => {
|
|
639
|
-
const pan = Gesture.Pan().enabled(draggable).onStart(() => {
|
|
718
|
+
const pan = Gesture.Pan().enabled(draggable).onStart((event) => {
|
|
719
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
720
|
+
edgeDir.value = 0;
|
|
721
|
+
lifted.value = 0;
|
|
722
|
+
grabX.value = event.x;
|
|
723
|
+
grabY.value = event.y;
|
|
724
|
+
liveAbsX.value = event.absoluteX;
|
|
725
|
+
liveAbsY.value = event.absoluteY;
|
|
640
726
|
runOnJS(notifyDragStart)();
|
|
641
727
|
}).onUpdate((event) => {
|
|
642
|
-
|
|
643
|
-
|
|
728
|
+
liveAbsX.value = event.absoluteX;
|
|
729
|
+
liveAbsY.value = event.absoluteY;
|
|
730
|
+
if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
|
|
731
|
+
ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
|
|
732
|
+
ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
|
|
733
|
+
} else {
|
|
734
|
+
moveOffset.value = event.translationY;
|
|
735
|
+
moveOffsetX.value = event.translationX;
|
|
736
|
+
}
|
|
737
|
+
if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
|
|
738
|
+
const fx = event.absoluteX - pagerLeftSV.value;
|
|
739
|
+
const dir = fx > pagerWidthSV.value - EDGE_ZONE_PX ? 1 : fx < EDGE_ZONE_PX ? -1 : 0;
|
|
740
|
+
if (dir !== edgeDir.value) {
|
|
741
|
+
edgeDir.value = dir;
|
|
742
|
+
if (dir === 0) runOnJS(disarmEdge)();
|
|
743
|
+
else runOnJS(armEdge)(dir);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
644
746
|
}).onEnd((event) => {
|
|
747
|
+
if (lifted.value) return;
|
|
645
748
|
const minuteDelta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
646
749
|
const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
|
|
647
|
-
const
|
|
750
|
+
const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
|
|
751
|
+
const dayDelta = targetDay - dayIndex;
|
|
648
752
|
if (minuteDelta === 0 && dayDelta === 0) {
|
|
649
753
|
moveOffset.value = 0;
|
|
650
754
|
moveOffsetX.value = 0;
|
|
@@ -652,8 +756,17 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
652
756
|
}
|
|
653
757
|
moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
654
758
|
moveOffsetX.value = dayDelta * dayWidth;
|
|
655
|
-
const totalDelta = minuteDelta +
|
|
759
|
+
const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
656
760
|
runOnJS(commitDrag)(totalDelta, totalDelta);
|
|
761
|
+
}).onFinalize(() => {
|
|
762
|
+
dragZ.value = 0;
|
|
763
|
+
if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
|
|
764
|
+
runOnJS(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
|
|
765
|
+
moveOffset.value = 0;
|
|
766
|
+
moveOffsetX.value = 0;
|
|
767
|
+
lifted.value = 0;
|
|
768
|
+
}
|
|
769
|
+
runOnJS(releaseEdge)();
|
|
657
770
|
});
|
|
658
771
|
return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
|
|
659
772
|
}, [
|
|
@@ -662,13 +775,32 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
662
775
|
cellHeight,
|
|
663
776
|
moveOffset,
|
|
664
777
|
moveOffsetX,
|
|
778
|
+
dragZ,
|
|
779
|
+
edgeDir,
|
|
780
|
+
lifted,
|
|
781
|
+
grabX,
|
|
782
|
+
grabY,
|
|
783
|
+
liveAbsX,
|
|
784
|
+
liveAbsY,
|
|
785
|
+
pagerLeftSV,
|
|
786
|
+
pagerTopSV,
|
|
787
|
+
pagerWidthSV,
|
|
788
|
+
ghostXSV,
|
|
789
|
+
ghostYSV,
|
|
790
|
+
commitLiftedDrop,
|
|
665
791
|
dayWidth,
|
|
666
792
|
dayIndex,
|
|
667
793
|
dayCount,
|
|
794
|
+
dayOrdinals,
|
|
668
795
|
commitDrag,
|
|
669
|
-
notifyDragStart
|
|
796
|
+
notifyDragStart,
|
|
797
|
+
onEdgeAdvance,
|
|
798
|
+
armEdge,
|
|
799
|
+
disarmEdge,
|
|
800
|
+
releaseEdge
|
|
670
801
|
]);
|
|
671
802
|
const resizeGesture = useMemo(() => Gesture.Pan().enabled(resizable).onStart(() => {
|
|
803
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
672
804
|
runOnJS(notifyDragStart)();
|
|
673
805
|
}).onUpdate((event) => {
|
|
674
806
|
resizeDelta.value = event.translationY;
|
|
@@ -680,17 +812,21 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
680
812
|
}
|
|
681
813
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
682
814
|
runOnJS(commitDrag)(0, delta);
|
|
815
|
+
}).onFinalize(() => {
|
|
816
|
+
dragZ.value = 0;
|
|
683
817
|
}), [
|
|
684
818
|
resizable,
|
|
685
819
|
snapMinutes,
|
|
686
820
|
cellHeight,
|
|
687
821
|
resizeDelta,
|
|
822
|
+
dragZ,
|
|
688
823
|
commitDrag,
|
|
689
824
|
notifyDragStart
|
|
690
825
|
]);
|
|
691
826
|
const handlePress = () => onPress(positioned.event);
|
|
692
827
|
const handleLongPress = !draggable && onLongPress ? () => onLongPress(positioned.event) : void 0;
|
|
693
828
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
829
|
+
const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
|
|
694
830
|
const accessibilityActions = draggable ? [
|
|
695
831
|
{
|
|
696
832
|
name: "move-later",
|
|
@@ -706,7 +842,15 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
706
842
|
}, {
|
|
707
843
|
name: "shrink",
|
|
708
844
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
709
|
-
}] : []
|
|
845
|
+
}] : [],
|
|
846
|
+
{
|
|
847
|
+
name: "move-next-page",
|
|
848
|
+
label: `Move to next ${pageUnit}`
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "move-previous-page",
|
|
852
|
+
label: `Move to previous ${pageUnit}`
|
|
853
|
+
}
|
|
710
854
|
] : void 0;
|
|
711
855
|
const handleAccessibilityAction = draggable ? (e) => {
|
|
712
856
|
switch (e.nativeEvent.actionName) {
|
|
@@ -722,6 +866,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
722
866
|
case "shrink":
|
|
723
867
|
commitDrag(0, -snapMinutes);
|
|
724
868
|
break;
|
|
869
|
+
case "move-next-page":
|
|
870
|
+
commitDrag(daysPerPage * MINUTES_PER_DAY, daysPerPage * MINUTES_PER_DAY);
|
|
871
|
+
break;
|
|
872
|
+
case "move-previous-page":
|
|
873
|
+
commitDrag(-daysPerPage * MINUTES_PER_DAY, -daysPerPage * MINUTES_PER_DAY);
|
|
874
|
+
break;
|
|
725
875
|
}
|
|
726
876
|
} : void 0;
|
|
727
877
|
const eventSlot = slot("event", {
|
|
@@ -825,7 +975,7 @@ const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) =>
|
|
|
825
975
|
style: [lineSlot.style, animatedStyle]
|
|
826
976
|
});
|
|
827
977
|
};
|
|
828
|
-
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color }) => {
|
|
978
|
+
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", children }) => {
|
|
829
979
|
const slot = useSlots();
|
|
830
980
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
831
981
|
top: (startHour - minHour) * cellHeight.value,
|
|
@@ -835,7 +985,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
835
985
|
endHour,
|
|
836
986
|
minHour
|
|
837
987
|
]);
|
|
838
|
-
const bandSlot = slot(
|
|
988
|
+
const bandSlot = slot(slotName, {
|
|
839
989
|
base: [
|
|
840
990
|
styles$1.shadeBand,
|
|
841
991
|
styles$1.nonInteractive,
|
|
@@ -844,18 +994,25 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
844
994
|
width
|
|
845
995
|
}
|
|
846
996
|
],
|
|
847
|
-
themed: { backgroundColor: color }
|
|
997
|
+
themed: color === void 0 ? void 0 : { backgroundColor: color }
|
|
848
998
|
});
|
|
849
999
|
return /* @__PURE__ */ jsx(Animated.View, {
|
|
850
|
-
testID
|
|
1000
|
+
testID,
|
|
1001
|
+
accessibilityElementsHidden: true,
|
|
1002
|
+
importantForAccessibility: "no-hide-descendants",
|
|
851
1003
|
...bandSlot,
|
|
852
|
-
style: [bandSlot.style, animatedStyle]
|
|
1004
|
+
style: [bandSlot.style, animatedStyle],
|
|
1005
|
+
children
|
|
853
1006
|
});
|
|
854
1007
|
};
|
|
855
|
-
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 }) {
|
|
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 }) {
|
|
856
1009
|
const theme = useCalendarTheme();
|
|
857
1010
|
const slot = useSlots();
|
|
858
1011
|
const scrollRef = useAnimatedRef();
|
|
1012
|
+
const gridTopRef = useRef(0);
|
|
1013
|
+
useEffect(() => {
|
|
1014
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1015
|
+
}, [isActive, onGridTop]);
|
|
859
1016
|
const heightSource = isActive ? cellHeight : committedCellHeight;
|
|
860
1017
|
const isDragging = useSharedValue(false);
|
|
861
1018
|
const isActiveShared = useSharedValue(isActive);
|
|
@@ -891,17 +1048,20 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
891
1048
|
if (isWeb$1 || !active || active === previous) return;
|
|
892
1049
|
scrollTo(scrollRef, 0, scrollY.value, false);
|
|
893
1050
|
});
|
|
894
|
-
const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1051
|
+
const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
895
1052
|
mode,
|
|
896
1053
|
date,
|
|
897
1054
|
weekStartsOn,
|
|
898
1055
|
numberOfDays,
|
|
899
1056
|
isRTL,
|
|
900
|
-
weekEndsOn
|
|
1057
|
+
weekEndsOn,
|
|
1058
|
+
hiddenDays
|
|
901
1059
|
]);
|
|
1060
|
+
const daysPerPage = pageStepDays(mode, date, weekStartsOn, numberOfDays);
|
|
902
1061
|
const dayCount = days.length;
|
|
903
1062
|
const dayWidth = (width - hourColumnWidth) / dayCount;
|
|
904
1063
|
const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
|
|
1064
|
+
const dayOrdinals = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[0])), [days]);
|
|
905
1065
|
const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
|
|
906
1066
|
const cellDateFromTouch = (event) => {
|
|
907
1067
|
const { locationX, locationY } = event.nativeEvent;
|
|
@@ -923,8 +1083,11 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
923
1083
|
if (date) onLongPressCell?.(date);
|
|
924
1084
|
};
|
|
925
1085
|
const hoursRange = useMemo(() => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index), [minHour, maxHour]);
|
|
926
|
-
const now = useNow(showNowIndicator && isActive
|
|
927
|
-
|
|
1086
|
+
const now = useNow$1(showNowIndicator && isActive, {
|
|
1087
|
+
now: nowProp,
|
|
1088
|
+
timeZone: nowTimeZone
|
|
1089
|
+
});
|
|
1090
|
+
const nowDayIndex = days.findIndex((day) => isSameCalendarDay$1(day, now));
|
|
928
1091
|
const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
|
|
929
1092
|
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
930
1093
|
const fullHeightStyle = useAnimatedStyle(() => ({ height: (maxHour - minHour) * heightSource.value }), [
|
|
@@ -1102,6 +1265,10 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1102
1265
|
scrollEnabled: verticalScrollEnabled,
|
|
1103
1266
|
onScroll: scrollHandler,
|
|
1104
1267
|
scrollEventThrottle: 16,
|
|
1268
|
+
onLayout: (event) => {
|
|
1269
|
+
gridTopRef.current = event.nativeEvent.layout.y;
|
|
1270
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1271
|
+
},
|
|
1105
1272
|
contentContainerStyle: { paddingTop: HOUR_LABEL_TOP_INSET },
|
|
1106
1273
|
contentOffset: {
|
|
1107
1274
|
x: 0,
|
|
@@ -1115,7 +1282,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1115
1282
|
children: cellLayer
|
|
1116
1283
|
}) : cellLayer,
|
|
1117
1284
|
days.map((day, dayIndex) => {
|
|
1118
|
-
if (!isWeekend$1(day)) return null;
|
|
1285
|
+
if (!highlightWeekends || !isWeekend$1(day)) return null;
|
|
1119
1286
|
const shadeSlot = slot("weekendShade", {
|
|
1120
1287
|
base: [
|
|
1121
1288
|
styles$1.weekendColumn,
|
|
@@ -1128,6 +1295,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1128
1295
|
themed: { backgroundColor: theme.colors.weekendBackground }
|
|
1129
1296
|
});
|
|
1130
1297
|
return /* @__PURE__ */ jsx(Animated.View, {
|
|
1298
|
+
testID: "weekend-shade",
|
|
1131
1299
|
...shadeSlot,
|
|
1132
1300
|
style: [shadeSlot.style, fullHeightStyle]
|
|
1133
1301
|
}, `weekend-${day.toISOString()}`);
|
|
@@ -1152,8 +1320,28 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1152
1320
|
minHour,
|
|
1153
1321
|
left: dayLeft(dayIndex),
|
|
1154
1322
|
width: dayWidth,
|
|
1155
|
-
color: theme.colors.outsideHoursBackground
|
|
1323
|
+
color: renderBusinessHours ? void 0 : theme.colors.outsideHoursBackground,
|
|
1324
|
+
children: renderBusinessHours?.({
|
|
1325
|
+
date: day,
|
|
1326
|
+
start: band.start,
|
|
1327
|
+
end: band.end
|
|
1328
|
+
})
|
|
1156
1329
|
}, `closed-${day.toISOString()}-${bandIndex}`))) : null,
|
|
1330
|
+
days.flatMap((day, dayIndex) => backgroundBandsForDay$1(events, day).map((b) => ({
|
|
1331
|
+
...b,
|
|
1332
|
+
startHours: Math.max(b.startHours, minHour),
|
|
1333
|
+
endHours: Math.min(b.endHours, maxHour)
|
|
1334
|
+
})).filter((b) => b.endHours > b.startHours).map((b, bandIndex) => /* @__PURE__ */ jsx(ShadeBand, {
|
|
1335
|
+
cellHeight: heightSource,
|
|
1336
|
+
startHour: b.startHours,
|
|
1337
|
+
endHour: b.endHours,
|
|
1338
|
+
minHour,
|
|
1339
|
+
left: dayLeft(dayIndex),
|
|
1340
|
+
width: dayWidth,
|
|
1341
|
+
color: theme.colors.backgroundEvent,
|
|
1342
|
+
slotName: "backgroundEvent",
|
|
1343
|
+
testID: "background-event-shade"
|
|
1344
|
+
}, `bg-${day.toISOString()}-${bandIndex}`))),
|
|
1157
1345
|
days.map((day, dayIndex) => {
|
|
1158
1346
|
const separatorSlot = slot("daySeparator", {
|
|
1159
1347
|
base: [
|
|
@@ -1195,14 +1383,17 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1195
1383
|
dayWidth,
|
|
1196
1384
|
dayIndex,
|
|
1197
1385
|
dayCount: days.length,
|
|
1386
|
+
dayOrdinals,
|
|
1198
1387
|
mode,
|
|
1388
|
+
daysPerPage,
|
|
1199
1389
|
renderEvent,
|
|
1200
1390
|
snapMinutes,
|
|
1201
1391
|
showDragHandle,
|
|
1202
1392
|
onPress: onPressEvent,
|
|
1203
1393
|
onLongPress: onLongPressEvent,
|
|
1204
1394
|
onDragEvent,
|
|
1205
|
-
onDragStart
|
|
1395
|
+
onDragStart,
|
|
1396
|
+
onEdgeAdvance
|
|
1206
1397
|
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
1207
1398
|
})),
|
|
1208
1399
|
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
|
|
@@ -1224,7 +1415,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1224
1415
|
});
|
|
1225
1416
|
}
|
|
1226
1417
|
const TimetablePage = memo(TimetablePageInner);
|
|
1227
|
-
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 }) {
|
|
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 }) {
|
|
1228
1419
|
const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
|
|
1229
1420
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
1230
1421
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -1235,6 +1426,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1235
1426
|
]);
|
|
1236
1427
|
const { width, height } = useWindowDimensions();
|
|
1237
1428
|
const listRef = useRef(null);
|
|
1429
|
+
const pagerRef = useRef(null);
|
|
1238
1430
|
const containerRef = useRef(null);
|
|
1239
1431
|
const suppressCaptureUntilRef = useRef(0);
|
|
1240
1432
|
const [pageHeight, setPageHeight] = useState(height);
|
|
@@ -1244,6 +1436,84 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1244
1436
|
const step = weekAnchored ? 7 : viewDayCount(mode, numberOfDays);
|
|
1245
1437
|
const seedDefaultY = Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR$1 - clampedMinHour) * hourHeight;
|
|
1246
1438
|
const scrollY = useSharedValue(seedDefaultY);
|
|
1439
|
+
const pagerLeft = useSharedValue(0);
|
|
1440
|
+
const pagerTop = useSharedValue(0);
|
|
1441
|
+
const pagerWidth = useSharedValue(width);
|
|
1442
|
+
const [edgePagingLock, setEdgePagingLock] = useState(false);
|
|
1443
|
+
const ghostX = useSharedValue(0);
|
|
1444
|
+
const ghostY = useSharedValue(0);
|
|
1445
|
+
const ghostW = useSharedValue(0);
|
|
1446
|
+
const ghostH = useSharedValue(0);
|
|
1447
|
+
const ghostVisible = useSharedValue(0);
|
|
1448
|
+
const gridTop = useSharedValue(0);
|
|
1449
|
+
const [liftedEvent, setLiftedEvent] = useState(null);
|
|
1450
|
+
const liftedEventRef = useRef(null);
|
|
1451
|
+
const dropRef = useRef({
|
|
1452
|
+
headerDays: [],
|
|
1453
|
+
containerWidth,
|
|
1454
|
+
hourColumnWidth,
|
|
1455
|
+
minHour: clampedMinHour,
|
|
1456
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1457
|
+
onDragEvent,
|
|
1458
|
+
onChangeDate
|
|
1459
|
+
});
|
|
1460
|
+
const beginLift = useCallback((event) => {
|
|
1461
|
+
liftedEventRef.current = event;
|
|
1462
|
+
setLiftedEvent(event);
|
|
1463
|
+
}, []);
|
|
1464
|
+
const clearLift = useCallback(() => {
|
|
1465
|
+
ghostVisible.value = 0;
|
|
1466
|
+
liftedEventRef.current = null;
|
|
1467
|
+
setLiftedEvent(null);
|
|
1468
|
+
setEdgePagingLock(false);
|
|
1469
|
+
}, [ghostVisible]);
|
|
1470
|
+
const commitLiftedDrop = useCallback((ghostLocalX, ghostLocalY) => {
|
|
1471
|
+
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1472
|
+
const ev = liftedEventRef.current;
|
|
1473
|
+
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1474
|
+
clearLift();
|
|
1475
|
+
if (!ev || !onDrag || days.length === 0) return;
|
|
1476
|
+
const dayWidth = (cw - hcw) / days.length;
|
|
1477
|
+
const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
|
|
1478
|
+
const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1479
|
+
const minutes = Math.round(rawMinutes / snap) * snap;
|
|
1480
|
+
const start = new Date(days[col]);
|
|
1481
|
+
start.setHours(0, 0, 0, 0);
|
|
1482
|
+
start.setMinutes(minutes);
|
|
1483
|
+
if (onDrag(ev, start, new Date(start.getTime() + duration)) === false) onDate(ev.start);
|
|
1484
|
+
}, [
|
|
1485
|
+
clearLift,
|
|
1486
|
+
gridTop,
|
|
1487
|
+
scrollY,
|
|
1488
|
+
cellHeight
|
|
1489
|
+
]);
|
|
1490
|
+
const handleGridTop = useCallback((y) => {
|
|
1491
|
+
gridTop.value = y;
|
|
1492
|
+
}, [gridTop]);
|
|
1493
|
+
const edgePaging = useMemo(() => ({
|
|
1494
|
+
pagerLeft,
|
|
1495
|
+
pagerTop,
|
|
1496
|
+
pagerWidth,
|
|
1497
|
+
lockScroll: setEdgePagingLock,
|
|
1498
|
+
ghostX,
|
|
1499
|
+
ghostY,
|
|
1500
|
+
ghostW,
|
|
1501
|
+
ghostH,
|
|
1502
|
+
ghostVisible,
|
|
1503
|
+
beginLift,
|
|
1504
|
+
commitLiftedDrop
|
|
1505
|
+
}), [
|
|
1506
|
+
pagerLeft,
|
|
1507
|
+
pagerTop,
|
|
1508
|
+
pagerWidth,
|
|
1509
|
+
ghostX,
|
|
1510
|
+
ghostY,
|
|
1511
|
+
ghostW,
|
|
1512
|
+
ghostH,
|
|
1513
|
+
ghostVisible,
|
|
1514
|
+
beginLift,
|
|
1515
|
+
commitLiftedDrop
|
|
1516
|
+
]);
|
|
1247
1517
|
const offsetSeedRef = useRef(null);
|
|
1248
1518
|
const captureOffsetSeed = useCallback((y) => {
|
|
1249
1519
|
offsetSeedRef.current = y;
|
|
@@ -1268,7 +1538,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1268
1538
|
])(date);
|
|
1269
1539
|
const viewedIndexRef = useRef(activeIndex);
|
|
1270
1540
|
const pendingScrollIndexRef = useRef(null);
|
|
1271
|
-
const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1541
|
+
const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
1272
1542
|
mode,
|
|
1273
1543
|
pageDates,
|
|
1274
1544
|
activeIndex,
|
|
@@ -1276,8 +1546,18 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1276
1546
|
weekStartsOn,
|
|
1277
1547
|
numberOfDays,
|
|
1278
1548
|
isRTL,
|
|
1279
|
-
weekEndsOn
|
|
1549
|
+
weekEndsOn,
|
|
1550
|
+
hiddenDays
|
|
1280
1551
|
]);
|
|
1552
|
+
dropRef.current = {
|
|
1553
|
+
headerDays,
|
|
1554
|
+
containerWidth,
|
|
1555
|
+
hourColumnWidth,
|
|
1556
|
+
minHour: clampedMinHour,
|
|
1557
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1558
|
+
onDragEvent,
|
|
1559
|
+
onChangeDate
|
|
1560
|
+
};
|
|
1281
1561
|
const handleViewableItemsChanged = useCallback((info) => {
|
|
1282
1562
|
if (isWeb$1) return;
|
|
1283
1563
|
const settled = info.viewableItems.find((token) => token.isViewable);
|
|
@@ -1363,14 +1643,15 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1363
1643
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
1364
1644
|
return () => cancelAnimationFrame(raf);
|
|
1365
1645
|
}, [pageHeight]);
|
|
1366
|
-
|
|
1646
|
+
const goToPage = useCallback((delta) => {
|
|
1367
1647
|
const target = pageDates[activeIndex + delta];
|
|
1368
1648
|
if (target) onChangeDate(target);
|
|
1369
1649
|
}, [
|
|
1370
1650
|
pageDates,
|
|
1371
1651
|
activeIndex,
|
|
1372
1652
|
onChangeDate
|
|
1373
|
-
])
|
|
1653
|
+
]);
|
|
1654
|
+
useWebPagerKeys(swipeEnabled, goToPage);
|
|
1374
1655
|
const reduceMotion = useReducedMotion();
|
|
1375
1656
|
const handlePressCell = useMemo(() => {
|
|
1376
1657
|
if (!onPressCell) return void 0;
|
|
@@ -1399,6 +1680,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1399
1680
|
children: /* @__PURE__ */ jsx(TimetablePage, {
|
|
1400
1681
|
mode,
|
|
1401
1682
|
numberOfDays,
|
|
1683
|
+
hiddenDays,
|
|
1684
|
+
now,
|
|
1685
|
+
nowTimeZone: timeZone,
|
|
1402
1686
|
date: item,
|
|
1403
1687
|
width: containerWidth,
|
|
1404
1688
|
events,
|
|
@@ -1418,11 +1702,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1418
1702
|
timeslots,
|
|
1419
1703
|
isRTL,
|
|
1420
1704
|
showAllDayEventCell,
|
|
1705
|
+
highlightWeekends,
|
|
1421
1706
|
showVerticalScrollIndicator,
|
|
1422
1707
|
verticalScrollEnabled,
|
|
1423
1708
|
hourComponent,
|
|
1424
1709
|
calendarCellStyle,
|
|
1425
1710
|
businessHours,
|
|
1711
|
+
renderBusinessHours,
|
|
1426
1712
|
minHourHeight,
|
|
1427
1713
|
maxHourHeight,
|
|
1428
1714
|
showNowIndicator,
|
|
@@ -1436,11 +1722,14 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1436
1722
|
onDragStart,
|
|
1437
1723
|
onPressCell: handlePressCell,
|
|
1438
1724
|
onLongPressCell,
|
|
1439
|
-
onCreateEvent
|
|
1725
|
+
onCreateEvent,
|
|
1726
|
+
onEdgeAdvance: goToPage,
|
|
1727
|
+
onGridTop: handleGridTop
|
|
1440
1728
|
})
|
|
1441
1729
|
}), [
|
|
1442
1730
|
containerWidth,
|
|
1443
1731
|
pageHeight,
|
|
1732
|
+
handleGridTop,
|
|
1444
1733
|
mode,
|
|
1445
1734
|
numberOfDays,
|
|
1446
1735
|
events,
|
|
@@ -1460,6 +1749,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1460
1749
|
timeslots,
|
|
1461
1750
|
isRTL,
|
|
1462
1751
|
showAllDayEventCell,
|
|
1752
|
+
highlightWeekends,
|
|
1463
1753
|
showVerticalScrollIndicator,
|
|
1464
1754
|
verticalScrollEnabled,
|
|
1465
1755
|
hourComponent,
|
|
@@ -1478,7 +1768,11 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1478
1768
|
onDragStart,
|
|
1479
1769
|
handlePressCell,
|
|
1480
1770
|
onLongPressCell,
|
|
1481
|
-
onCreateEvent
|
|
1771
|
+
onCreateEvent,
|
|
1772
|
+
goToPage,
|
|
1773
|
+
hiddenDays,
|
|
1774
|
+
now,
|
|
1775
|
+
timeZone
|
|
1482
1776
|
]);
|
|
1483
1777
|
const listExtraData = useMemo(() => ({
|
|
1484
1778
|
events,
|
|
@@ -1487,52 +1781,70 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1487
1781
|
return /* @__PURE__ */ jsx(SlotStylesProvider, {
|
|
1488
1782
|
classNames,
|
|
1489
1783
|
styles: styleOverrides,
|
|
1490
|
-
children: /* @__PURE__ */
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
keyExtractor: keyExtractorList,
|
|
1522
|
-
getFixedItemSize,
|
|
1523
|
-
...isWeb$1 ? null : {
|
|
1524
|
-
scrollEnabled: swipeEnabled,
|
|
1525
|
-
pagingEnabled: !freeSwipe,
|
|
1526
|
-
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1784
|
+
children: /* @__PURE__ */ jsx(EdgePagingContext.Provider, {
|
|
1785
|
+
value: edgePaging,
|
|
1786
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
1787
|
+
ref: containerRef,
|
|
1788
|
+
style: styles$1.container,
|
|
1789
|
+
children: [
|
|
1790
|
+
renderHeader ? renderHeader(headerDays) : /* @__PURE__ */ jsx(DefaultHeader, {
|
|
1791
|
+
days: headerDays,
|
|
1792
|
+
mode,
|
|
1793
|
+
width: containerWidth,
|
|
1794
|
+
hourColumnWidth,
|
|
1795
|
+
showWeekNumber,
|
|
1796
|
+
weekNumberPrefix,
|
|
1797
|
+
weekdayFormat,
|
|
1798
|
+
locale,
|
|
1799
|
+
activeDate,
|
|
1800
|
+
onPressDateHeader
|
|
1801
|
+
}),
|
|
1802
|
+
headerComponent,
|
|
1803
|
+
/* @__PURE__ */ jsxs(View, {
|
|
1804
|
+
ref: pagerRef,
|
|
1805
|
+
style: styles$1.pager,
|
|
1806
|
+
onLayout: (event) => {
|
|
1807
|
+
setPageHeight(event.nativeEvent.layout.height);
|
|
1808
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
1809
|
+
setMeasured(true);
|
|
1810
|
+
pagerRef.current?.measureInWindow((x, y, w) => {
|
|
1811
|
+
pagerLeft.value = x;
|
|
1812
|
+
pagerTop.value = y;
|
|
1813
|
+
pagerWidth.value = w;
|
|
1814
|
+
});
|
|
1527
1815
|
},
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1816
|
+
children: [/* @__PURE__ */ jsx(LegendList, {
|
|
1817
|
+
ref: listRef,
|
|
1818
|
+
style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
|
|
1819
|
+
data: pageDates,
|
|
1820
|
+
extraData: listExtraData,
|
|
1821
|
+
horizontal: true,
|
|
1822
|
+
recycleItems: false,
|
|
1823
|
+
keyExtractor: keyExtractorList,
|
|
1824
|
+
getFixedItemSize,
|
|
1825
|
+
...isWeb$1 ? null : {
|
|
1826
|
+
scrollEnabled: swipeEnabled && !edgePagingLock,
|
|
1827
|
+
pagingEnabled: !freeSwipe,
|
|
1828
|
+
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1829
|
+
},
|
|
1830
|
+
initialScrollIndex: activeIndex,
|
|
1831
|
+
showsHorizontalScrollIndicator: false,
|
|
1832
|
+
viewabilityConfig: PAGE_VIEWABILITY,
|
|
1833
|
+
onViewableItemsChanged: handleViewableItemsChanged,
|
|
1834
|
+
renderItem
|
|
1835
|
+
}, measured ? "grid" : "grid-seed"), liftedEvent ? /* @__PURE__ */ jsx(DragGhost, {
|
|
1836
|
+
x: ghostX,
|
|
1837
|
+
y: ghostY,
|
|
1838
|
+
w: ghostW,
|
|
1839
|
+
h: ghostH,
|
|
1840
|
+
visible: ghostVisible,
|
|
1841
|
+
event: liftedEvent,
|
|
1842
|
+
mode,
|
|
1843
|
+
renderEvent: labeledRenderEvent
|
|
1844
|
+
}) : null]
|
|
1845
|
+
})
|
|
1846
|
+
]
|
|
1847
|
+
})
|
|
1536
1848
|
})
|
|
1537
1849
|
});
|
|
1538
1850
|
}
|
|
@@ -1716,6 +2028,11 @@ const styles$1 = StyleSheet.create({
|
|
|
1716
2028
|
overflow: "hidden",
|
|
1717
2029
|
padding: EVENT_GAP
|
|
1718
2030
|
},
|
|
2031
|
+
dragGhost: {
|
|
2032
|
+
top: 0,
|
|
2033
|
+
left: 0,
|
|
2034
|
+
zIndex: 101
|
|
2035
|
+
},
|
|
1719
2036
|
nowIndicator: {
|
|
1720
2037
|
position: "absolute",
|
|
1721
2038
|
height: 2
|
|
@@ -1766,7 +2083,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
1766
2083
|
* }
|
|
1767
2084
|
* ```
|
|
1768
2085
|
*/
|
|
1769
|
-
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 }) {
|
|
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 }) {
|
|
1770
2087
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
1771
2088
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
1772
2089
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -1843,6 +2160,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1843
2160
|
events: displayEvents,
|
|
1844
2161
|
maxVisibleEventCount,
|
|
1845
2162
|
weekStartsOn,
|
|
2163
|
+
hiddenDays,
|
|
1846
2164
|
weekdayFormat,
|
|
1847
2165
|
locale,
|
|
1848
2166
|
sortedMonthView,
|
|
@@ -1871,6 +2189,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1871
2189
|
date,
|
|
1872
2190
|
events: displayEvents,
|
|
1873
2191
|
weekStartsOn,
|
|
2192
|
+
hiddenDays,
|
|
1874
2193
|
locale,
|
|
1875
2194
|
activeDate,
|
|
1876
2195
|
onPressDay,
|
|
@@ -1899,6 +2218,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1899
2218
|
hourHeight,
|
|
1900
2219
|
weekStartsOn,
|
|
1901
2220
|
weekdayFormat,
|
|
2221
|
+
hiddenDays,
|
|
2222
|
+
now,
|
|
2223
|
+
timeZone,
|
|
1902
2224
|
renderEvent: resolvedRenderEvent,
|
|
1903
2225
|
keyExtractor,
|
|
1904
2226
|
scrollOffsetMinutes,
|
|
@@ -1906,8 +2228,10 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1906
2228
|
hideHours,
|
|
1907
2229
|
timeslots,
|
|
1908
2230
|
showAllDayEventCell,
|
|
2231
|
+
highlightWeekends,
|
|
1909
2232
|
calendarCellStyle,
|
|
1910
2233
|
businessHours,
|
|
2234
|
+
renderBusinessHours,
|
|
1911
2235
|
showWeekNumber,
|
|
1912
2236
|
weekNumberPrefix,
|
|
1913
2237
|
hourComponent,
|
|
@@ -1981,41 +2305,60 @@ function DefaultBar({ event, width, height }) {
|
|
|
1981
2305
|
}) : null]
|
|
1982
2306
|
});
|
|
1983
2307
|
}
|
|
1984
|
-
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, theme }) {
|
|
2308
|
+
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, resources, laneIndex, laneSize, dragActive, onDragActiveChange, theme }) {
|
|
1985
2309
|
const moveX = useSharedValue(0);
|
|
2310
|
+
const moveCross = useSharedValue(0);
|
|
1986
2311
|
const resizeW = useSharedValue(0);
|
|
1987
2312
|
const latest = useRef({
|
|
1988
2313
|
event: pe.event,
|
|
1989
|
-
onDragEvent
|
|
2314
|
+
onDragEvent,
|
|
2315
|
+
resources,
|
|
2316
|
+
laneIndex
|
|
1990
2317
|
});
|
|
1991
2318
|
latest.current = {
|
|
1992
2319
|
event: pe.event,
|
|
1993
|
-
onDragEvent
|
|
2320
|
+
onDragEvent,
|
|
2321
|
+
resources,
|
|
2322
|
+
laneIndex
|
|
1994
2323
|
};
|
|
1995
|
-
const
|
|
2324
|
+
const laneCount = resources.length;
|
|
2325
|
+
const draggable = !pe.event.disabled && pe.event.draggable !== false;
|
|
1996
2326
|
useEffect(() => {
|
|
2327
|
+
if (dragActive) return;
|
|
1997
2328
|
moveX.value = 0;
|
|
2329
|
+
moveCross.value = 0;
|
|
1998
2330
|
resizeW.value = 0;
|
|
1999
2331
|
}, [
|
|
2332
|
+
dragActive,
|
|
2000
2333
|
pe.startHours,
|
|
2001
2334
|
pe.durationHours,
|
|
2002
2335
|
moveX,
|
|
2336
|
+
moveCross,
|
|
2003
2337
|
resizeW
|
|
2004
2338
|
]);
|
|
2005
2339
|
const snapBack = useCallback(() => {
|
|
2006
2340
|
moveX.value = 0;
|
|
2341
|
+
moveCross.value = 0;
|
|
2007
2342
|
resizeW.value = 0;
|
|
2008
|
-
}, [
|
|
2009
|
-
|
|
2010
|
-
|
|
2343
|
+
}, [
|
|
2344
|
+
moveX,
|
|
2345
|
+
moveCross,
|
|
2346
|
+
resizeW
|
|
2347
|
+
]);
|
|
2348
|
+
const commit = useCallback((deltaStartMin, deltaEndMin, laneDelta = 0) => {
|
|
2349
|
+
const { event, onDragEvent: handler, resources: lanes, laneIndex: lane } = latest.current;
|
|
2011
2350
|
const next = resolveDraggedBounds(event.start, event.end, deltaStartMin, deltaEndMin, snapMinutes);
|
|
2012
|
-
|
|
2351
|
+
const target = lanes[Math.min(Math.max(lane + laneDelta, 0), lanes.length - 1)];
|
|
2352
|
+
if (!next || !target) {
|
|
2013
2353
|
snapBack();
|
|
2014
2354
|
return;
|
|
2015
2355
|
}
|
|
2016
|
-
if (handler(event, next.start, next.end) === false) snapBack();
|
|
2356
|
+
if (handler(event, next.start, next.end, target) === false) snapBack();
|
|
2017
2357
|
}, [snapMinutes, snapBack]);
|
|
2018
2358
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
2359
|
+
const laneTitle = (lane) => lane && (lane.title || lane.id);
|
|
2360
|
+
const nextLane = laneTitle(resources[laneIndex + 1]);
|
|
2361
|
+
const previousLane = laneTitle(resources[laneIndex - 1]);
|
|
2019
2362
|
const barActions = draggable ? [
|
|
2020
2363
|
{
|
|
2021
2364
|
name: "move-later",
|
|
@@ -2032,7 +2375,15 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
2032
2375
|
{
|
|
2033
2376
|
name: "shrink",
|
|
2034
2377
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
2035
|
-
}
|
|
2378
|
+
},
|
|
2379
|
+
...nextLane ? [{
|
|
2380
|
+
name: "move-next-lane",
|
|
2381
|
+
label: `Move to ${nextLane}`
|
|
2382
|
+
}] : [],
|
|
2383
|
+
...previousLane ? [{
|
|
2384
|
+
name: "move-previous-lane",
|
|
2385
|
+
label: `Move to ${previousLane}`
|
|
2386
|
+
}] : []
|
|
2036
2387
|
] : void 0;
|
|
2037
2388
|
const onBarAction = draggable ? (e) => {
|
|
2038
2389
|
switch (e.nativeEvent.actionName) {
|
|
@@ -2048,36 +2399,61 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
2048
2399
|
case "shrink":
|
|
2049
2400
|
commit(0, -snapMinutes);
|
|
2050
2401
|
break;
|
|
2402
|
+
case "move-next-lane":
|
|
2403
|
+
commit(0, 0, 1);
|
|
2404
|
+
break;
|
|
2405
|
+
case "move-previous-lane":
|
|
2406
|
+
commit(0, 0, -1);
|
|
2407
|
+
break;
|
|
2051
2408
|
}
|
|
2052
2409
|
} : void 0;
|
|
2053
2410
|
const barStyle = useAnimatedStyle(() => vertical ? {
|
|
2054
|
-
transform: [{ translateY: moveX.value }],
|
|
2411
|
+
transform: [{ translateY: moveX.value }, { translateX: moveCross.value }],
|
|
2055
2412
|
height: Math.max(height + resizeW.value, 2)
|
|
2056
2413
|
} : {
|
|
2057
|
-
transform: [{ translateX: moveX.value }],
|
|
2414
|
+
transform: [{ translateX: moveX.value }, { translateY: moveCross.value }],
|
|
2058
2415
|
width: Math.max(width + resizeW.value, 2)
|
|
2059
2416
|
}, [
|
|
2060
2417
|
vertical,
|
|
2061
2418
|
width,
|
|
2062
2419
|
height
|
|
2063
2420
|
]);
|
|
2064
|
-
const
|
|
2421
|
+
const laneId = resources[laneIndex]?.id ?? "";
|
|
2422
|
+
const moveGesture = useMemo(() => Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
|
|
2423
|
+
runOnJS(onDragActiveChange)(laneId);
|
|
2424
|
+
}).onUpdate((e) => {
|
|
2065
2425
|
moveX.value = vertical ? e.translationY : e.translationX;
|
|
2426
|
+
if (laneSize > 0 && laneCount > 1) {
|
|
2427
|
+
const cross = vertical ? e.translationX : e.translationY;
|
|
2428
|
+
moveCross.value = Math.min(Math.max(cross, -laneIndex * laneSize), (laneCount - 1 - laneIndex) * laneSize);
|
|
2429
|
+
}
|
|
2066
2430
|
}).onEnd((e) => {
|
|
2067
2431
|
const delta = snapDeltaMinutes(vertical ? e.translationY : e.translationX, hourSize, snapMinutes);
|
|
2068
|
-
|
|
2432
|
+
const cross = laneSize > 0 ? vertical ? e.translationX : e.translationY : 0;
|
|
2433
|
+
const laneDelta = laneSize > 0 ? Math.min(Math.max(Math.round(cross / laneSize), -laneIndex), laneCount - 1 - laneIndex) : 0;
|
|
2434
|
+
if (delta === 0 && laneDelta === 0) {
|
|
2069
2435
|
moveX.value = 0;
|
|
2436
|
+
moveCross.value = 0;
|
|
2070
2437
|
return;
|
|
2071
2438
|
}
|
|
2072
2439
|
moveX.value = delta / MINUTES_PER_HOUR * hourSize;
|
|
2073
|
-
|
|
2440
|
+
moveCross.value = laneDelta * laneSize;
|
|
2441
|
+
runOnJS(commit)(delta, delta, laneDelta);
|
|
2442
|
+
}).onFinalize(() => {
|
|
2443
|
+
runOnJS(onDragActiveChange)(null);
|
|
2074
2444
|
}), [
|
|
2075
2445
|
draggable,
|
|
2076
2446
|
vertical,
|
|
2077
2447
|
hourSize,
|
|
2078
2448
|
snapMinutes,
|
|
2449
|
+
laneSize,
|
|
2450
|
+
laneCount,
|
|
2451
|
+
laneIndex,
|
|
2452
|
+
laneId,
|
|
2079
2453
|
moveX,
|
|
2080
|
-
|
|
2454
|
+
moveCross,
|
|
2455
|
+
commit,
|
|
2456
|
+
onDragActiveChange
|
|
2081
2457
|
]);
|
|
2082
2458
|
const resizeGesture = useMemo(() => Gesture.Pan().enabled(draggable).onUpdate((e) => {
|
|
2083
2459
|
resizeW.value = vertical ? e.translationY : e.translationX;
|
|
@@ -2263,11 +2639,57 @@ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, s
|
|
|
2263
2639
|
* />
|
|
2264
2640
|
* ```
|
|
2265
2641
|
*/
|
|
2266
|
-
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 }) {
|
|
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 }) {
|
|
2267
2643
|
const theme = useCalendarTheme();
|
|
2644
|
+
const resources = useMemo(() => {
|
|
2645
|
+
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
2646
|
+
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
2647
|
+
const page = Math.min(Math.max(resourcePage, 0), pages - 1);
|
|
2648
|
+
return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
|
|
2649
|
+
}, [
|
|
2650
|
+
allResources,
|
|
2651
|
+
resourcesPerPage,
|
|
2652
|
+
resourcePage
|
|
2653
|
+
]);
|
|
2654
|
+
const [dragLaneId, setDragLaneId] = useState(null);
|
|
2655
|
+
const [vBodyWidth, setVBodyWidth] = useState(0);
|
|
2656
|
+
const vLaneSize = resources.length > 0 && vBodyWidth > GUTTER_WIDTH ? (vBodyWidth - GUTTER_WIDTH) / resources.length : 0;
|
|
2268
2657
|
const Renderer = renderEvent ?? DefaultBar;
|
|
2269
2658
|
const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
|
|
2659
|
+
const now = useNow$1(showNowIndicator, {
|
|
2660
|
+
now: nowProp,
|
|
2661
|
+
timeZone
|
|
2662
|
+
});
|
|
2663
|
+
const nowHours = now.getHours() + now.getMinutes() / 60;
|
|
2664
|
+
const showNow = showNowIndicator && isSameCalendarDay$1(now, date) && nowHours >= startHour && nowHours <= endHour;
|
|
2665
|
+
const nowLine = (vertical, hourSize) => showNow ? /* @__PURE__ */ jsx(View, {
|
|
2666
|
+
pointerEvents: "none",
|
|
2667
|
+
testID: "resource-now-indicator",
|
|
2668
|
+
style: [
|
|
2669
|
+
vertical ? {
|
|
2670
|
+
position: "absolute",
|
|
2671
|
+
left: 0,
|
|
2672
|
+
right: 0,
|
|
2673
|
+
height: 2
|
|
2674
|
+
} : {
|
|
2675
|
+
position: "absolute",
|
|
2676
|
+
top: 0,
|
|
2677
|
+
bottom: 0,
|
|
2678
|
+
width: 2
|
|
2679
|
+
},
|
|
2680
|
+
vertical ? { top: (nowHours - startHour) * hourSize } : { left: (nowHours - startHour) * hourSize },
|
|
2681
|
+
{
|
|
2682
|
+
backgroundColor: theme.colors.nowIndicator,
|
|
2683
|
+
zIndex: 2
|
|
2684
|
+
}
|
|
2685
|
+
]
|
|
2686
|
+
}) : null;
|
|
2270
2687
|
const bandsFor = (resource) => businessHours ? closedHourBands(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
2688
|
+
const backgroundBandsFor = (resource) => backgroundBandsForDay$1(events.filter((event) => resourceId(event) === resource.id), date).map((b) => ({
|
|
2689
|
+
...b,
|
|
2690
|
+
startHours: Math.max(b.startHours, startHour),
|
|
2691
|
+
endHours: Math.min(b.endHours, endHour)
|
|
2692
|
+
})).filter((b) => b.endHours > b.startHours);
|
|
2271
2693
|
const hours = useMemo(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
|
|
2272
2694
|
const trackWidth = (endHour - startHour) * hourWidth;
|
|
2273
2695
|
const byResource = useMemo(() => {
|
|
@@ -2302,6 +2724,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2302
2724
|
showsVerticalScrollIndicator: true,
|
|
2303
2725
|
children: /* @__PURE__ */ jsxs(View, {
|
|
2304
2726
|
style: [styles.vbody, { height: trackHeight }],
|
|
2727
|
+
onLayout: (event) => setVBodyWidth(event.nativeEvent.layout.width),
|
|
2305
2728
|
children: [/* @__PURE__ */ jsx(View, {
|
|
2306
2729
|
style: { width: GUTTER_WIDTH },
|
|
2307
2730
|
children: hours.map((h) => /* @__PURE__ */ jsx(Text, {
|
|
@@ -2312,24 +2735,45 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2312
2735
|
}],
|
|
2313
2736
|
children: formatHour(h, { ampm })
|
|
2314
2737
|
}, h))
|
|
2315
|
-
}), resources.map((resource) => {
|
|
2738
|
+
}), resources.map((resource, laneIndex) => {
|
|
2316
2739
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2317
2740
|
return /* @__PURE__ */ jsxs(View, {
|
|
2318
2741
|
style: [
|
|
2319
2742
|
styles.vcolumn,
|
|
2320
2743
|
{ borderLeftColor: theme.colors.gridLine },
|
|
2321
|
-
theme.containers.resourceRow
|
|
2744
|
+
theme.containers.resourceRow,
|
|
2745
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2322
2746
|
],
|
|
2323
2747
|
children: [
|
|
2324
2748
|
bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
|
|
2325
2749
|
pointerEvents: "none",
|
|
2750
|
+
accessibilityElementsHidden: true,
|
|
2751
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2326
2752
|
testID: "resource-hours-shade",
|
|
2753
|
+
style: [
|
|
2754
|
+
styles.vshadeBand,
|
|
2755
|
+
{
|
|
2756
|
+
top: (b.start - startHour) * hourHeight,
|
|
2757
|
+
height: (b.end - b.start) * hourHeight
|
|
2758
|
+
},
|
|
2759
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2760
|
+
],
|
|
2761
|
+
children: renderBusinessHours?.({
|
|
2762
|
+
date,
|
|
2763
|
+
start: b.start,
|
|
2764
|
+
end: b.end,
|
|
2765
|
+
resource
|
|
2766
|
+
})
|
|
2767
|
+
}, `shade-${b.start}`)),
|
|
2768
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ jsx(View, {
|
|
2769
|
+
pointerEvents: "none",
|
|
2770
|
+
testID: "background-event-shade",
|
|
2327
2771
|
style: [styles.vshadeBand, {
|
|
2328
|
-
top: (b.
|
|
2329
|
-
height: (b.
|
|
2330
|
-
backgroundColor: theme.colors.
|
|
2772
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
2773
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
2774
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2331
2775
|
}]
|
|
2332
|
-
}, `
|
|
2776
|
+
}, `bg-${i}`)),
|
|
2333
2777
|
hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
|
|
2334
2778
|
pointerEvents: "none",
|
|
2335
2779
|
style: [styles.vgridLine, {
|
|
@@ -2337,6 +2781,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2337
2781
|
backgroundColor: theme.colors.gridLine
|
|
2338
2782
|
}]
|
|
2339
2783
|
}, h)),
|
|
2784
|
+
nowLine(true, hourHeight),
|
|
2340
2785
|
cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
|
|
2341
2786
|
resource,
|
|
2342
2787
|
vertical: true,
|
|
@@ -2360,6 +2805,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2360
2805
|
if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
|
|
2361
2806
|
pe,
|
|
2362
2807
|
vertical: true,
|
|
2808
|
+
resources,
|
|
2809
|
+
laneIndex,
|
|
2810
|
+
laneSize: vLaneSize,
|
|
2811
|
+
dragActive: dragLaneId === resource.id,
|
|
2812
|
+
onDragActiveChange: setDragLaneId,
|
|
2363
2813
|
hourSize: hourHeight,
|
|
2364
2814
|
left,
|
|
2365
2815
|
top,
|
|
@@ -2426,7 +2876,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2426
2876
|
children: formatHour(h, { ampm })
|
|
2427
2877
|
}, h))
|
|
2428
2878
|
})]
|
|
2429
|
-
}), resources.map((resource) => {
|
|
2879
|
+
}), resources.map((resource, laneIndex) => {
|
|
2430
2880
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2431
2881
|
return /* @__PURE__ */ jsxs(View, {
|
|
2432
2882
|
style: [
|
|
@@ -2435,7 +2885,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2435
2885
|
height: rowHeight,
|
|
2436
2886
|
borderBottomColor: theme.colors.gridLine
|
|
2437
2887
|
},
|
|
2438
|
-
theme.containers.resourceRow
|
|
2888
|
+
theme.containers.resourceRow,
|
|
2889
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2439
2890
|
],
|
|
2440
2891
|
children: [/* @__PURE__ */ jsx(View, {
|
|
2441
2892
|
style: [
|
|
@@ -2457,13 +2908,33 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2457
2908
|
children: [
|
|
2458
2909
|
bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
|
|
2459
2910
|
pointerEvents: "none",
|
|
2911
|
+
accessibilityElementsHidden: true,
|
|
2912
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2460
2913
|
testID: "resource-hours-shade",
|
|
2914
|
+
style: [
|
|
2915
|
+
styles.hshadeBand,
|
|
2916
|
+
{
|
|
2917
|
+
left: (b.start - startHour) * hourWidth,
|
|
2918
|
+
width: (b.end - b.start) * hourWidth
|
|
2919
|
+
},
|
|
2920
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2921
|
+
],
|
|
2922
|
+
children: renderBusinessHours?.({
|
|
2923
|
+
date,
|
|
2924
|
+
start: b.start,
|
|
2925
|
+
end: b.end,
|
|
2926
|
+
resource
|
|
2927
|
+
})
|
|
2928
|
+
}, `shade-${b.start}`)),
|
|
2929
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ jsx(View, {
|
|
2930
|
+
pointerEvents: "none",
|
|
2931
|
+
testID: "background-event-shade",
|
|
2461
2932
|
style: [styles.hshadeBand, {
|
|
2462
|
-
left: (b.
|
|
2463
|
-
width: (b.
|
|
2464
|
-
backgroundColor: theme.colors.
|
|
2933
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
2934
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
2935
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2465
2936
|
}]
|
|
2466
|
-
}, `
|
|
2937
|
+
}, `bg-${i}`)),
|
|
2467
2938
|
hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
|
|
2468
2939
|
pointerEvents: "none",
|
|
2469
2940
|
style: [styles.gridLine, {
|
|
@@ -2471,6 +2942,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2471
2942
|
backgroundColor: theme.colors.gridLine
|
|
2472
2943
|
}]
|
|
2473
2944
|
}, h)),
|
|
2945
|
+
nowLine(false, hourWidth),
|
|
2474
2946
|
cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
|
|
2475
2947
|
resource,
|
|
2476
2948
|
vertical: false,
|
|
@@ -2492,6 +2964,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2492
2964
|
if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
|
|
2493
2965
|
pe,
|
|
2494
2966
|
vertical: false,
|
|
2967
|
+
resources,
|
|
2968
|
+
laneIndex,
|
|
2969
|
+
laneSize: rowHeight,
|
|
2970
|
+
dragActive: dragLaneId === resource.id,
|
|
2971
|
+
onDragActiveChange: setDragLaneId,
|
|
2495
2972
|
hourSize: hourWidth,
|
|
2496
2973
|
left,
|
|
2497
2974
|
top: pe.column * laneHeight,
|
|
@@ -2601,6 +3078,7 @@ const styles = StyleSheet.create({
|
|
|
2601
3078
|
fontWeight: "600"
|
|
2602
3079
|
},
|
|
2603
3080
|
vbody: { flexDirection: "row" },
|
|
3081
|
+
laneLifted: { zIndex: 10 },
|
|
2604
3082
|
vcolumn: {
|
|
2605
3083
|
flex: 1,
|
|
2606
3084
|
borderLeftWidth: StyleSheet.hairlineWidth
|
|
@@ -2646,4 +3124,4 @@ const styles = StyleSheet.create({
|
|
|
2646
3124
|
}
|
|
2647
3125
|
});
|
|
2648
3126
|
//#endregion
|
|
2649
|
-
export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, YearView, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useMonthGrid, weekdayFormatToken };
|
|
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 };
|