@super-calendar/native 2.9.1 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +74 -13
- package/dist/index.d.ts +74 -13
- package/dist/index.js +939 -604
- package/dist/index.mjs +940 -605
- package/package.json +2 -2
- package/src/components/Agenda.tsx +5 -1
- package/src/components/AllDayLane.tsx +36 -53
- package/src/components/Calendar.tsx +54 -4
- package/src/components/MultiDayMovePreview.tsx +12 -9
- package/src/components/TimeGrid.tsx +1416 -887
- package/src/components/YearView.tsx +5 -0
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
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-CjKhzOJX.mjs";
|
|
2
2
|
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
3
|
import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import Animated, { runOnJS,
|
|
4
|
+
import Animated, { runOnJS, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
|
|
5
5
|
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, monthCreateRange, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
6
6
|
import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
7
7
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { LegendList } from "@legendapp/list/react-native";
|
|
10
|
+
import { AnimatedLegendList } from "@legendapp/list/reanimated";
|
|
10
11
|
//#region src/components/YearView.tsx
|
|
11
12
|
const isWeb$2 = Platform.OS === "web";
|
|
12
13
|
const DRAG_HOLD_MS = 400;
|
|
13
14
|
const FALLBACK_COLUMNS = 3;
|
|
14
|
-
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, classNames, styles: styleOverrides }) {
|
|
15
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, refreshControl, classNames, styles: styleOverrides }) {
|
|
15
16
|
const theme = useCalendarTheme();
|
|
16
17
|
const slot = createSlots({
|
|
17
18
|
classNames,
|
|
@@ -98,6 +99,7 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeD
|
|
|
98
99
|
onLayout: handleLayout,
|
|
99
100
|
showsVerticalScrollIndicator: true,
|
|
100
101
|
scrollEnabled: isWeb$2 || sweep == null,
|
|
102
|
+
refreshControl,
|
|
101
103
|
children: /* @__PURE__ */ jsx(View, {
|
|
102
104
|
...slot("grid", { base: styles$5.grid }),
|
|
103
105
|
children: months.map((month, monthIndex) => {
|
|
@@ -369,7 +371,7 @@ const styles$5 = StyleSheet.create({
|
|
|
369
371
|
* start, grouped under a date header per day. The consumer controls which
|
|
370
372
|
* events (and therefore which date range) are shown.
|
|
371
373
|
*/
|
|
372
|
-
function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLongPressEvent, onPressDay, activeDate, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
374
|
+
function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLongPressEvent, onPressDay, activeDate, itemSeparatorComponent, refreshControl, classNames, styles: styleOverrides }) {
|
|
373
375
|
const theme = useCalendarTheme();
|
|
374
376
|
const slot = useMemo(() => createSlots({
|
|
375
377
|
classNames,
|
|
@@ -448,7 +450,8 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
448
450
|
keyExtractor: keyExtractorRow,
|
|
449
451
|
renderItem,
|
|
450
452
|
ItemSeparatorComponent: itemSeparatorComponent ?? void 0,
|
|
451
|
-
recycleItems: false
|
|
453
|
+
recycleItems: false,
|
|
454
|
+
refreshControl
|
|
452
455
|
});
|
|
453
456
|
}
|
|
454
457
|
const styles$4 = StyleSheet.create({
|
|
@@ -665,12 +668,13 @@ function useWebGridZoom(enabled, target, cellHeight, committedCellHeight, minHei
|
|
|
665
668
|
//#endregion
|
|
666
669
|
//#region src/components/AllDayLane.tsx
|
|
667
670
|
/**
|
|
668
|
-
* The all-day lane
|
|
669
|
-
* excluded from the timed columns (see `layoutDayEvents`) and shown
|
|
670
|
-
* stacked under their day(s).
|
|
671
|
-
*
|
|
671
|
+
* The all-day lane of one page, pinned above the scrolling hours. All-day
|
|
672
|
+
* events are excluded from the timed columns (see `layoutDayEvents`) and shown
|
|
673
|
+
* here, stacked under their day(s). Always rendered so every page reports a
|
|
674
|
+
* height, zero when the week has none, which the band above the grid follows
|
|
675
|
+
* live as you swipe; the "all-day" label lives in the hour column.
|
|
672
676
|
*/
|
|
673
|
-
function AllDayLane({ days, events, mode,
|
|
677
|
+
function AllDayLane({ days, events, mode, dayWidth, renderEvent, keyExtractor, onPressEvent, onLongPressEvent, onLayout }) {
|
|
674
678
|
const theme = useCalendarTheme();
|
|
675
679
|
const slot = useSlots();
|
|
676
680
|
const RenderEventComponent = renderEvent;
|
|
@@ -680,23 +684,13 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
|
|
|
680
684
|
const next = addDays(start, 1);
|
|
681
685
|
return allDay.filter((event) => event.start < next && event.end > start);
|
|
682
686
|
});
|
|
683
|
-
|
|
684
|
-
return /* @__PURE__ */ jsxs(View, {
|
|
687
|
+
return /* @__PURE__ */ jsx(View, {
|
|
685
688
|
...slot("allDayLane", {
|
|
686
689
|
base: styles$2.lane,
|
|
687
|
-
themed:
|
|
690
|
+
themed: theme.containers.allDayLane
|
|
688
691
|
}),
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
692
|
-
...slot("allDayLabel", {
|
|
693
|
-
base: styles$2.label,
|
|
694
|
-
themed: { color: theme.colors.textMuted }
|
|
695
|
-
}),
|
|
696
|
-
allowFontScaling: false,
|
|
697
|
-
children: "all-day"
|
|
698
|
-
})
|
|
699
|
-
}), days.map((day, dayIndex) => /* @__PURE__ */ jsx(View, {
|
|
692
|
+
onLayout,
|
|
693
|
+
children: perDay.every((list) => list.length === 0) ? null : days.map((day, dayIndex) => /* @__PURE__ */ jsx(View, {
|
|
700
694
|
...slot("allDayColumn", {
|
|
701
695
|
base: [styles$2.column, { width: dayWidth }],
|
|
702
696
|
themed: theme.containers.allDayColumn
|
|
@@ -711,20 +705,11 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
|
|
|
711
705
|
onLongPress: onLongPressEvent ? () => onLongPressEvent(event) : void 0
|
|
712
706
|
})
|
|
713
707
|
}, keyExtractor(event, index)))
|
|
714
|
-
}, day.toISOString()))
|
|
708
|
+
}, day.toISOString()))
|
|
715
709
|
});
|
|
716
710
|
}
|
|
717
711
|
const styles$2 = StyleSheet.create({
|
|
718
|
-
lane: {
|
|
719
|
-
flexDirection: "row",
|
|
720
|
-
borderBottomWidth: StyleSheet.hairlineWidth
|
|
721
|
-
},
|
|
722
|
-
gutter: { justifyContent: "center" },
|
|
723
|
-
label: {
|
|
724
|
-
fontSize: 10,
|
|
725
|
-
textAlign: "right",
|
|
726
|
-
paddingRight: 6
|
|
727
|
-
},
|
|
712
|
+
lane: { flexDirection: "row" },
|
|
728
713
|
column: {
|
|
729
714
|
paddingVertical: 2,
|
|
730
715
|
paddingHorizontal: 1,
|
|
@@ -735,7 +720,6 @@ const styles$2 = StyleSheet.create({
|
|
|
735
720
|
//#endregion
|
|
736
721
|
//#region src/components/MultiDayMovePreview.tsx
|
|
737
722
|
const noop$1 = () => {};
|
|
738
|
-
const MIN_EVENT_HEIGHT$1 = 32;
|
|
739
723
|
function MultiDayMovePreview(props) {
|
|
740
724
|
const { move, days } = props;
|
|
741
725
|
const dayOffsets = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[move.dayIndex]) * 1440), [days, move]);
|
|
@@ -747,7 +731,7 @@ function MultiDayMovePreview(props) {
|
|
|
747
731
|
dayEnd: addDays(startOfDay(day), 1).getTime()
|
|
748
732
|
}, day.toISOString()));
|
|
749
733
|
}
|
|
750
|
-
function PreviewDay({ move, cellHeight, dayWidth,
|
|
734
|
+
function PreviewDay({ move, cellHeight, dayWidth, minHour, mode, renderEvent: RenderEventComponent, minEventHeight, eventGap, dayOffsets, index, dayStart, dayEnd }) {
|
|
751
735
|
const theme = useCalendarTheme();
|
|
752
736
|
const slot = useSlots();
|
|
753
737
|
const { offsetX, offsetY, lifted, dayIndex, event } = move;
|
|
@@ -775,7 +759,7 @@ function PreviewDay({ move, cellHeight, dayWidth, hourColumnWidth, minHour, mode
|
|
|
775
759
|
dayStart,
|
|
776
760
|
dayEnd
|
|
777
761
|
]);
|
|
778
|
-
const boxHeight = useDerivedValue(() => segment.value.hours > 0 ? Math.max(segment.value.hours * cellHeight.value,
|
|
762
|
+
const boxHeight = useDerivedValue(() => segment.value.hours > 0 ? Math.max(segment.value.hours * cellHeight.value, minEventHeight) : 0, [minEventHeight]);
|
|
779
763
|
const style = useAnimatedStyle(() => ({
|
|
780
764
|
top: (segment.value.top - minHour) * cellHeight.value,
|
|
781
765
|
height: boxHeight.value,
|
|
@@ -802,8 +786,8 @@ function PreviewDay({ move, cellHeight, dayWidth, hourColumnWidth, minHour, mode
|
|
|
802
786
|
{
|
|
803
787
|
position: "absolute",
|
|
804
788
|
overflow: "hidden",
|
|
805
|
-
padding:
|
|
806
|
-
left:
|
|
789
|
+
padding: eventGap,
|
|
790
|
+
left: index * dayWidth,
|
|
807
791
|
width: dayWidth,
|
|
808
792
|
zIndex: 100
|
|
809
793
|
},
|
|
@@ -832,16 +816,17 @@ const DEFAULT_HOUR_HEIGHT = 48;
|
|
|
832
816
|
const DEFAULT_MIN_HOUR_HEIGHT = 32;
|
|
833
817
|
const DEFAULT_MAX_HOUR_HEIGHT = 160;
|
|
834
818
|
const DEFAULT_HOUR_COLUMN_WIDTH = 56;
|
|
835
|
-
const
|
|
836
|
-
const
|
|
819
|
+
const DEFAULT_MIN_EVENT_HEIGHT = 32;
|
|
820
|
+
const DEFAULT_EVENT_GAP = 2;
|
|
837
821
|
const DRAG_ACTIVATE_MS = 300;
|
|
838
822
|
const MOVE_ACTIVATE_MS$1 = 500;
|
|
839
823
|
const DRAG_ACTIVATE_PX$1 = 8;
|
|
840
824
|
const RESIZE_HANDLE_HEIGHT = 14;
|
|
841
825
|
const DEFAULT_DRAG_STEP_MINUTES = 15;
|
|
842
826
|
const DRAG_EVENT_Z = 100;
|
|
843
|
-
const EDGE_DWELL_MS =
|
|
844
|
-
const
|
|
827
|
+
const EDGE_DWELL_MS = 600;
|
|
828
|
+
const EDGE_REPEAT_MS = 700;
|
|
829
|
+
const EDGE_ZONE_PX = 24;
|
|
845
830
|
const EdgePagingContext = createContext(null);
|
|
846
831
|
const noop = () => {};
|
|
847
832
|
/**
|
|
@@ -850,7 +835,7 @@ const noop = () => {};
|
|
|
850
835
|
* while a drag is actually spilling (see `spillHeight`), so an idle grid pays
|
|
851
836
|
* nothing for it; its geometry is driven on the UI thread from there.
|
|
852
837
|
*/
|
|
853
|
-
function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, slotProps }) {
|
|
838
|
+
function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, dayWidth, nextDayDirection, minHour, event, mode, renderEvent, eventGap, slotProps }) {
|
|
854
839
|
const RenderEventComponent = renderEvent;
|
|
855
840
|
const style = useAnimatedStyle(() => ({
|
|
856
841
|
height: spillHeight.value,
|
|
@@ -872,7 +857,8 @@ function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, day
|
|
|
872
857
|
{
|
|
873
858
|
left: dayLeftPx,
|
|
874
859
|
width: dayWidth,
|
|
875
|
-
top: 0
|
|
860
|
+
top: 0,
|
|
861
|
+
padding: eventGap
|
|
876
862
|
},
|
|
877
863
|
slotProps.style,
|
|
878
864
|
style
|
|
@@ -893,7 +879,7 @@ function MoveSpillPreview({ spillHeight, moveOffsetX, cellHeight, dayLeftPx, day
|
|
|
893
879
|
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
894
880
|
* finger without a React re-render.
|
|
895
881
|
*/
|
|
896
|
-
function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
882
|
+
function DragGhost({ x, y, w, h, visible, event, mode, renderEvent, eventGap }) {
|
|
897
883
|
const RenderEventComponent = renderEvent;
|
|
898
884
|
const style = useAnimatedStyle(() => ({
|
|
899
885
|
transform: [{ translateX: x.value }, { translateY: y.value }],
|
|
@@ -905,6 +891,7 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
|
905
891
|
style: [
|
|
906
892
|
styles$1.eventBox,
|
|
907
893
|
styles$1.dragGhost,
|
|
894
|
+
{ padding: eventGap },
|
|
908
895
|
style
|
|
909
896
|
],
|
|
910
897
|
pointerEvents: "none",
|
|
@@ -917,7 +904,9 @@ function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
|
917
904
|
});
|
|
918
905
|
}
|
|
919
906
|
const HOUR_LABEL_TOP_INSET = 12;
|
|
920
|
-
|
|
907
|
+
const LANE_BAND_FLOOR = 1;
|
|
908
|
+
const DAY_HEADER_HEIGHT = 56;
|
|
909
|
+
function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePreview, cellHeight, minHour, maxHour, left, width, dayLeftPx, nextDayDirection, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, minEventHeight, eventGap, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle, eventStartEditable, eventDurationEditable }) {
|
|
921
910
|
const RenderEventComponent = renderEvent;
|
|
922
911
|
const theme = useCalendarTheme();
|
|
923
912
|
const slot = useSlots();
|
|
@@ -954,20 +943,29 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
954
943
|
minutes: startHours * MINUTES_PER_HOUR$1,
|
|
955
944
|
ownsStart
|
|
956
945
|
}), [startHours, ownsStart]);
|
|
957
|
-
const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value,
|
|
946
|
+
const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value - resizeStartDelta.value, minEventHeight), [durationHours, minEventHeight]);
|
|
958
947
|
const visibleBoxHeight = useDerivedValue(() => {
|
|
959
948
|
const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
960
949
|
const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
|
|
961
|
-
return Math.max(Math.min(boxHeight.value, dayEnd - top),
|
|
962
|
-
}, [
|
|
950
|
+
return Math.max(Math.min(boxHeight.value, dayEnd - top), minEventHeight);
|
|
951
|
+
}, [
|
|
952
|
+
startHours,
|
|
953
|
+
minHour,
|
|
954
|
+
minEventHeight
|
|
955
|
+
]);
|
|
963
956
|
const boxStyle = useAnimatedStyle(() => {
|
|
964
957
|
return {
|
|
965
958
|
top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
966
959
|
height: visibleBoxHeight.value,
|
|
967
960
|
transform: [{ translateX: moveOffsetX.value }],
|
|
968
|
-
zIndex: dragZ.value
|
|
961
|
+
zIndex: dragZ.value,
|
|
962
|
+
opacity: hiddenForMove || lifted.value ? 0 : 1
|
|
969
963
|
};
|
|
970
|
-
}, [
|
|
964
|
+
}, [
|
|
965
|
+
startHours,
|
|
966
|
+
minHour,
|
|
967
|
+
hiddenForMove
|
|
968
|
+
]);
|
|
971
969
|
const spillHeight = useDerivedValue(() => {
|
|
972
970
|
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
973
971
|
const overflowHours = startHours + moveOffset.value / cellHeight.value + durationHours - HOURS_PER_DAY;
|
|
@@ -1010,13 +1008,17 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1010
1008
|
event: positioned.event,
|
|
1011
1009
|
eventIndex,
|
|
1012
1010
|
onDragEvent,
|
|
1013
|
-
onDragStart
|
|
1011
|
+
onDragStart,
|
|
1012
|
+
onPress,
|
|
1013
|
+
onLongPress
|
|
1014
1014
|
});
|
|
1015
1015
|
latest.current = {
|
|
1016
1016
|
event: positioned.event,
|
|
1017
1017
|
eventIndex,
|
|
1018
1018
|
onDragEvent,
|
|
1019
|
-
onDragStart
|
|
1019
|
+
onDragStart,
|
|
1020
|
+
onPress,
|
|
1021
|
+
onLongPress
|
|
1020
1022
|
};
|
|
1021
1023
|
const snapBack = useCallback(() => {
|
|
1022
1024
|
moveOffset.value = 0;
|
|
@@ -1079,16 +1081,12 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1079
1081
|
dwellTimer.current = null;
|
|
1080
1082
|
}
|
|
1081
1083
|
}, []);
|
|
1082
|
-
const releaseEdge =
|
|
1083
|
-
disarmEdge();
|
|
1084
|
-
edgePaging?.lockScroll(false);
|
|
1085
|
-
}, [disarmEdge, edgePaging]);
|
|
1084
|
+
const releaseEdge = disarmEdge;
|
|
1086
1085
|
const armEdge = useCallback((dir) => {
|
|
1087
1086
|
disarmEdge();
|
|
1088
|
-
|
|
1087
|
+
const fire = () => {
|
|
1089
1088
|
dwellTimer.current = null;
|
|
1090
1089
|
if (!edgePaging) return;
|
|
1091
|
-
edgePaging.lockScroll(true);
|
|
1092
1090
|
if (!lifted.value) {
|
|
1093
1091
|
lifted.value = 1;
|
|
1094
1092
|
edgePaging.ghostW.value = width;
|
|
@@ -1099,7 +1097,9 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1099
1097
|
edgePaging.beginLift(latest.current.event);
|
|
1100
1098
|
}
|
|
1101
1099
|
onEdgeAdvance?.(dir);
|
|
1102
|
-
|
|
1100
|
+
dwellTimer.current = setTimeout(fire, EDGE_REPEAT_MS);
|
|
1101
|
+
};
|
|
1102
|
+
dwellTimer.current = setTimeout(fire, EDGE_DWELL_MS);
|
|
1103
1103
|
}, [
|
|
1104
1104
|
disarmEdge,
|
|
1105
1105
|
edgePaging,
|
|
@@ -1219,55 +1219,87 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1219
1219
|
disarmEdge,
|
|
1220
1220
|
releaseEdge
|
|
1221
1221
|
]);
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
})
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1222
|
+
const handlePress = useCallback(() => {
|
|
1223
|
+
const { event, onPress: press } = latest.current;
|
|
1224
|
+
press(event);
|
|
1225
|
+
}, []);
|
|
1226
|
+
const canLongPress = !canMove && onLongPress != null;
|
|
1227
|
+
const handleLongPressFromHandle = useCallback(() => {
|
|
1228
|
+
const { event, onLongPress: press } = latest.current;
|
|
1229
|
+
press?.(event);
|
|
1230
|
+
}, []);
|
|
1231
|
+
const resizeGesture = useMemo(() => {
|
|
1232
|
+
const pan = Gesture.Pan().enabled(resizable).onStart(() => {
|
|
1233
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
1234
|
+
runOnJS(notifyDragStart)();
|
|
1235
|
+
}).onUpdate((event) => {
|
|
1236
|
+
resizeDelta.value = event.translationY;
|
|
1237
|
+
}).onEnd((event) => {
|
|
1238
|
+
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1239
|
+
if (delta === 0) {
|
|
1240
|
+
resizeDelta.value = 0;
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1244
|
+
runOnJS(commitDrag)(0, delta);
|
|
1245
|
+
}).onFinalize(() => {
|
|
1246
|
+
dragZ.value = 0;
|
|
1247
|
+
});
|
|
1248
|
+
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1249
|
+
if (success) handlePress();
|
|
1250
|
+
});
|
|
1251
|
+
const longPress = Gesture.LongPress().enabled(canLongPress).runOnJS(true).onStart(() => {
|
|
1252
|
+
handleLongPressFromHandle();
|
|
1253
|
+
});
|
|
1254
|
+
return Gesture.Race(pan, tap, longPress);
|
|
1255
|
+
}, [
|
|
1238
1256
|
resizable,
|
|
1239
1257
|
snapMinutes,
|
|
1240
1258
|
cellHeight,
|
|
1241
1259
|
resizeDelta,
|
|
1242
1260
|
dragZ,
|
|
1243
1261
|
commitDrag,
|
|
1244
|
-
notifyDragStart
|
|
1262
|
+
notifyDragStart,
|
|
1263
|
+
handlePress,
|
|
1264
|
+
canLongPress,
|
|
1265
|
+
handleLongPressFromHandle
|
|
1245
1266
|
]);
|
|
1246
|
-
const resizeStartGesture = useMemo(() =>
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1267
|
+
const resizeStartGesture = useMemo(() => {
|
|
1268
|
+
const pan = Gesture.Pan().enabled(resizableFromStart).onStart(() => {
|
|
1269
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
1270
|
+
runOnJS(notifyDragStart)();
|
|
1271
|
+
}).onUpdate((event) => {
|
|
1272
|
+
resizeStartDelta.value = event.translationY;
|
|
1273
|
+
}).onEnd((event) => {
|
|
1274
|
+
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1275
|
+
if (delta === 0) {
|
|
1276
|
+
resizeStartDelta.value = 0;
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
resizeStartDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1280
|
+
runOnJS(commitDrag)(delta, 0);
|
|
1281
|
+
}).onFinalize(() => {
|
|
1282
|
+
dragZ.value = 0;
|
|
1283
|
+
});
|
|
1284
|
+
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1285
|
+
if (success) handlePress();
|
|
1286
|
+
});
|
|
1287
|
+
const longPress = Gesture.LongPress().enabled(canLongPress).runOnJS(true).onStart(() => {
|
|
1288
|
+
handleLongPressFromHandle();
|
|
1289
|
+
});
|
|
1290
|
+
return Gesture.Race(pan, tap, longPress);
|
|
1291
|
+
}, [
|
|
1262
1292
|
resizableFromStart,
|
|
1263
1293
|
snapMinutes,
|
|
1264
1294
|
cellHeight,
|
|
1265
1295
|
resizeStartDelta,
|
|
1266
1296
|
dragZ,
|
|
1267
1297
|
commitDrag,
|
|
1268
|
-
notifyDragStart
|
|
1298
|
+
notifyDragStart,
|
|
1299
|
+
handlePress,
|
|
1300
|
+
canLongPress,
|
|
1301
|
+
handleLongPressFromHandle
|
|
1269
1302
|
]);
|
|
1270
|
-
const handlePress = () => onPress(positioned.event);
|
|
1271
1303
|
const handleLongPress = !canMove && onLongPress ? () => onLongPress(positioned.event) : void 0;
|
|
1272
1304
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
1273
1305
|
const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
|
|
@@ -1320,17 +1352,14 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1320
1352
|
const eventSlot = slot("event", {
|
|
1321
1353
|
base: [styles$1.eventBox, {
|
|
1322
1354
|
left,
|
|
1323
|
-
width
|
|
1355
|
+
width,
|
|
1356
|
+
padding: eventGap
|
|
1324
1357
|
}],
|
|
1325
1358
|
themed: theme.containers.timeGridEvent
|
|
1326
1359
|
});
|
|
1327
1360
|
const box = /* @__PURE__ */ jsxs(Animated.View, {
|
|
1328
1361
|
...eventSlot,
|
|
1329
|
-
style: [
|
|
1330
|
-
eventSlot.style,
|
|
1331
|
-
boxStyle,
|
|
1332
|
-
hiddenForMove ? { opacity: 0 } : null
|
|
1333
|
-
],
|
|
1362
|
+
style: [eventSlot.style, boxStyle],
|
|
1334
1363
|
children: [
|
|
1335
1364
|
/* @__PURE__ */ jsx(RenderEventComponent, {
|
|
1336
1365
|
event: positioned.event,
|
|
@@ -1346,6 +1375,7 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1346
1375
|
resizableFromStart ? /* @__PURE__ */ jsx(GestureDetector, {
|
|
1347
1376
|
gesture: resizeStartGesture,
|
|
1348
1377
|
children: /* @__PURE__ */ jsx(Animated.View, {
|
|
1378
|
+
testID: "resize-handle-top",
|
|
1349
1379
|
style: styles$1.resizeHandleTop,
|
|
1350
1380
|
children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
|
|
1351
1381
|
})
|
|
@@ -1353,6 +1383,7 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1353
1383
|
resizable ? /* @__PURE__ */ jsx(GestureDetector, {
|
|
1354
1384
|
gesture: resizeGesture,
|
|
1355
1385
|
children: /* @__PURE__ */ jsx(Animated.View, {
|
|
1386
|
+
testID: "resize-handle",
|
|
1356
1387
|
style: styles$1.resizeHandle,
|
|
1357
1388
|
children: showDragHandle ? /* @__PURE__ */ jsx(View, { style: [styles$1.resizeGrip, { backgroundColor: theme.colors.eventText }] }) : null
|
|
1358
1389
|
})
|
|
@@ -1374,56 +1405,123 @@ function AnimatedEventBox({ positioned, eventIndex, movingEvent, onMovePreview,
|
|
|
1374
1405
|
event: positioned.event,
|
|
1375
1406
|
mode,
|
|
1376
1407
|
renderEvent,
|
|
1408
|
+
eventGap,
|
|
1377
1409
|
slotProps: slot("event", { themed: theme.containers.timeGridEvent })
|
|
1378
1410
|
}) : null] });
|
|
1379
1411
|
}
|
|
1380
|
-
const
|
|
1412
|
+
const AnimatedEventBox = memo(AnimatedEventBoxInner);
|
|
1413
|
+
const hourRange = (minHour, maxHour) => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index);
|
|
1414
|
+
const HourLabel = ({ hour, width, label, ampm, hourComponent }) => {
|
|
1381
1415
|
const theme = useCalendarTheme();
|
|
1382
1416
|
const slot = useSlots();
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
}) : /* @__PURE__ */ jsx(Text, {
|
|
1394
|
-
...slot("hourLabel", {
|
|
1395
|
-
base: [styles$1.hourLabel, { width: hourColumnWidth }],
|
|
1396
|
-
themed: [theme.text.hourLabel, { color: theme.colors.textMuted }]
|
|
1397
|
-
}),
|
|
1398
|
-
allowFontScaling: false,
|
|
1399
|
-
children: label
|
|
1400
|
-
}), /* @__PURE__ */ jsx(View, { ...slot("gridLines", {
|
|
1401
|
-
base: styles$1.hourLine,
|
|
1402
|
-
themed: { backgroundColor: theme.colors.gridLine }
|
|
1403
|
-
}) })]
|
|
1417
|
+
return hourComponent ? /* @__PURE__ */ jsx(View, {
|
|
1418
|
+
style: { width },
|
|
1419
|
+
children: hourComponent(hour, ampm)
|
|
1420
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
1421
|
+
...slot("hourLabel", {
|
|
1422
|
+
base: [styles$1.hourLabel, { width }],
|
|
1423
|
+
themed: [theme.text.hourLabel, { color: theme.colors.textMuted }]
|
|
1424
|
+
}),
|
|
1425
|
+
allowFontScaling: false,
|
|
1426
|
+
children: label
|
|
1404
1427
|
});
|
|
1405
1428
|
};
|
|
1406
|
-
const
|
|
1429
|
+
const HourLines = memo(function HourLines({ hours, timeslots }) {
|
|
1407
1430
|
const theme = useCalendarTheme();
|
|
1408
1431
|
const slot = useSlots();
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
minHour,
|
|
1412
|
-
fraction
|
|
1413
|
-
]);
|
|
1414
|
-
const lineSlot = slot("gridLines", {
|
|
1415
|
-
base: [
|
|
1416
|
-
styles$1.timeslotLine,
|
|
1417
|
-
styles$1.nonInteractive,
|
|
1418
|
-
{ left: hourColumnWidth }
|
|
1419
|
-
],
|
|
1432
|
+
const hourLineSlot = slot("gridLines", {
|
|
1433
|
+
base: [styles$1.hourLine, styles$1.nonInteractive],
|
|
1420
1434
|
themed: { backgroundColor: theme.colors.gridLine }
|
|
1421
1435
|
});
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1436
|
+
const timeslotLineSlot = slot("gridLines", {
|
|
1437
|
+
base: [styles$1.timeslotLine, styles$1.nonInteractive],
|
|
1438
|
+
themed: { backgroundColor: theme.colors.gridLine }
|
|
1439
|
+
});
|
|
1440
|
+
return /* @__PURE__ */ jsx(View, {
|
|
1441
|
+
style: [styles$1.fill, styles$1.nonInteractive],
|
|
1442
|
+
children: hours.map((hour) => /* @__PURE__ */ jsx(View, {
|
|
1443
|
+
style: styles$1.hourCell,
|
|
1444
|
+
children: Array.from({ length: Math.max(1, timeslots) }, (_, slotIndex) => /* @__PURE__ */ jsx(View, {
|
|
1445
|
+
style: styles$1.hourCell,
|
|
1446
|
+
children: /* @__PURE__ */ jsx(View, { ...slotIndex === 0 ? hourLineSlot : timeslotLineSlot })
|
|
1447
|
+
}, slotIndex))
|
|
1448
|
+
}, hour))
|
|
1449
|
+
});
|
|
1450
|
+
});
|
|
1451
|
+
const HourGutterInner = ({ width, minHour, maxHour, cellHeight, laneHeight, scrollY, showLane, showAllDayLabel, headerHeight, weekNumber, ampm, hourComponent }) => {
|
|
1452
|
+
const theme = useCalendarTheme();
|
|
1453
|
+
const slot = useSlots();
|
|
1454
|
+
const hours = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1455
|
+
const laneCellHeightStyle = useAnimatedStyle(() => ({ height: laneHeight.value }));
|
|
1456
|
+
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
|
|
1457
|
+
const rowsStyle = useAnimatedStyle(() => ({
|
|
1458
|
+
top: headerHeight + laneHeight.value + HOUR_LABEL_TOP_INSET,
|
|
1459
|
+
height: (maxHour - minHour) * cellHeight.value
|
|
1460
|
+
}), [
|
|
1461
|
+
minHour,
|
|
1462
|
+
maxHour,
|
|
1463
|
+
headerHeight
|
|
1464
|
+
]);
|
|
1465
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
1466
|
+
testID: "hour-gutter",
|
|
1467
|
+
...slot("hourGutter", { base: [styles$1.hourGutter, { width }] }),
|
|
1468
|
+
children: [
|
|
1469
|
+
headerHeight > 0 ? /* @__PURE__ */ jsx(Animated.View, {
|
|
1470
|
+
style: [
|
|
1471
|
+
styles$1.gutterCorner,
|
|
1472
|
+
{
|
|
1473
|
+
height: headerHeight,
|
|
1474
|
+
backgroundColor: theme.colors.surface,
|
|
1475
|
+
borderBottomColor: theme.colors.gridLine
|
|
1476
|
+
},
|
|
1477
|
+
pinStyle
|
|
1478
|
+
],
|
|
1479
|
+
children: weekNumber ? /* @__PURE__ */ jsx(Text, {
|
|
1480
|
+
...slot("weekNumber", { themed: [theme.text.hourLabel, { color: theme.colors.textMuted }] }),
|
|
1481
|
+
allowFontScaling: false,
|
|
1482
|
+
children: weekNumber
|
|
1483
|
+
}) : null
|
|
1484
|
+
}) : null,
|
|
1485
|
+
showLane ? /* @__PURE__ */ jsx(Animated.View, {
|
|
1486
|
+
style: [
|
|
1487
|
+
styles$1.laneCell,
|
|
1488
|
+
{ top: headerHeight },
|
|
1489
|
+
{
|
|
1490
|
+
backgroundColor: theme.colors.surface,
|
|
1491
|
+
borderBottomColor: theme.colors.gridLine
|
|
1492
|
+
},
|
|
1493
|
+
laneCellHeightStyle,
|
|
1494
|
+
pinStyle
|
|
1495
|
+
],
|
|
1496
|
+
children: showAllDayLabel ? /* @__PURE__ */ jsx(Text, {
|
|
1497
|
+
...slot("allDayLabel", {
|
|
1498
|
+
base: styles$1.allDayLabel,
|
|
1499
|
+
themed: { color: theme.colors.textMuted }
|
|
1500
|
+
}),
|
|
1501
|
+
allowFontScaling: false,
|
|
1502
|
+
children: "all-day"
|
|
1503
|
+
}) : null
|
|
1504
|
+
}) : null,
|
|
1505
|
+
/* @__PURE__ */ jsx(Animated.View, {
|
|
1506
|
+
style: [styles$1.gutterRows, rowsStyle],
|
|
1507
|
+
children: hours.map((hour) => /* @__PURE__ */ jsx(View, {
|
|
1508
|
+
style: styles$1.hourCell,
|
|
1509
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
1510
|
+
style: [styles$1.hourRow, styles$1.nonInteractive],
|
|
1511
|
+
children: /* @__PURE__ */ jsx(HourLabel, {
|
|
1512
|
+
hour,
|
|
1513
|
+
width,
|
|
1514
|
+
label: formatHour(hour, { ampm }),
|
|
1515
|
+
ampm,
|
|
1516
|
+
hourComponent
|
|
1517
|
+
})
|
|
1518
|
+
})
|
|
1519
|
+
}, hour))
|
|
1520
|
+
})
|
|
1521
|
+
]
|
|
1425
1522
|
});
|
|
1426
1523
|
};
|
|
1524
|
+
const HourGutter = memo(HourGutterInner);
|
|
1427
1525
|
const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) => {
|
|
1428
1526
|
const theme = useCalendarTheme();
|
|
1429
1527
|
const slot = useSlots();
|
|
@@ -1444,7 +1542,7 @@ const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) =>
|
|
|
1444
1542
|
style: [lineSlot.style, animatedStyle]
|
|
1445
1543
|
});
|
|
1446
1544
|
};
|
|
1447
|
-
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", children }) => {
|
|
1545
|
+
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", interactive = false, children }) => {
|
|
1448
1546
|
const slot = useSlots();
|
|
1449
1547
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
1450
1548
|
top: (startHour - minHour) * cellHeight.value,
|
|
@@ -1457,7 +1555,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
1457
1555
|
const bandSlot = slot(slotName, {
|
|
1458
1556
|
base: [
|
|
1459
1557
|
styles$1.shadeBand,
|
|
1460
|
-
styles$1.nonInteractive,
|
|
1558
|
+
interactive ? styles$1.passThrough : styles$1.nonInteractive,
|
|
1461
1559
|
{
|
|
1462
1560
|
left,
|
|
1463
1561
|
width
|
|
@@ -1467,56 +1565,46 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
1467
1565
|
});
|
|
1468
1566
|
return /* @__PURE__ */ jsx(Animated.View, {
|
|
1469
1567
|
testID,
|
|
1470
|
-
accessibilityElementsHidden:
|
|
1471
|
-
importantForAccessibility: "no-hide-descendants",
|
|
1568
|
+
accessibilityElementsHidden: !interactive,
|
|
1569
|
+
importantForAccessibility: interactive ? "auto" : "no-hide-descendants",
|
|
1472
1570
|
...bandSlot,
|
|
1473
1571
|
style: [bandSlot.style, animatedStyle],
|
|
1474
1572
|
children
|
|
1475
1573
|
});
|
|
1476
1574
|
};
|
|
1477
|
-
function
|
|
1575
|
+
function BackgroundEventBand({ event, cellHeight, startHour, endHour, minHour, left, width, mode, continuesBefore, continuesAfter, render: Render, onPress, onLongPress }) {
|
|
1576
|
+
const boxHeight = useDerivedValue(() => (endHour - startHour) * cellHeight.value, [
|
|
1577
|
+
startHour,
|
|
1578
|
+
endHour,
|
|
1579
|
+
cellHeight
|
|
1580
|
+
]);
|
|
1581
|
+
const handlePress = useCallback(() => onPress(event), [onPress, event]);
|
|
1582
|
+
const handleLongPress = useCallback(() => onLongPress?.(event), [onLongPress, event]);
|
|
1583
|
+
return /* @__PURE__ */ jsx(ShadeBand, {
|
|
1584
|
+
cellHeight,
|
|
1585
|
+
startHour,
|
|
1586
|
+
endHour,
|
|
1587
|
+
minHour,
|
|
1588
|
+
left,
|
|
1589
|
+
width,
|
|
1590
|
+
slotName: "backgroundEvent",
|
|
1591
|
+
testID: "background-event-shade",
|
|
1592
|
+
interactive: true,
|
|
1593
|
+
children: /* @__PURE__ */ jsx(Render, {
|
|
1594
|
+
event,
|
|
1595
|
+
mode,
|
|
1596
|
+
boxHeight,
|
|
1597
|
+
continuesBefore,
|
|
1598
|
+
continuesAfter,
|
|
1599
|
+
onPress: handlePress,
|
|
1600
|
+
onLongPress: onLongPress ? handleLongPress : void 0
|
|
1601
|
+
})
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowTimeZone, date, events, cellHeight, committedCellHeight, isActive, weekStartsOn, weekEndsOn, width, minHour, maxHour, timeslots, isRTL, highlightWeekends, calendarCellStyle, showNowIndicator, businessHours, renderBusinessHours, renderBackgroundEvent, renderEvent, keyExtractor, snapMinutes, minEventHeight, eventGap, showDragHandle, eventStartEditable, eventDurationEditable, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, pageIndex, laneHeight, scrollY, showAllDayEventCell, onLaneLayout, height, pagedHeader, weekdayFormat, locale, activeDate, onPressDateHeader }) {
|
|
1478
1605
|
const theme = useCalendarTheme();
|
|
1479
1606
|
const slot = useSlots();
|
|
1480
|
-
const scrollRef = useAnimatedRef();
|
|
1481
|
-
const gridTopRef = useRef(0);
|
|
1482
|
-
useEffect(() => {
|
|
1483
|
-
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1484
|
-
}, [isActive, onGridTop]);
|
|
1485
1607
|
const heightSource = isActive ? cellHeight : committedCellHeight;
|
|
1486
|
-
const isDragging = useSharedValue(false);
|
|
1487
|
-
const isActiveShared = useSharedValue(isActive);
|
|
1488
|
-
useEffect(() => {
|
|
1489
|
-
isActiveShared.value = isActive;
|
|
1490
|
-
}, [isActive, isActiveShared]);
|
|
1491
|
-
const scrollHandler = useAnimatedScrollHandler({
|
|
1492
|
-
onScroll: (event) => {
|
|
1493
|
-
if (isActiveShared.value && isDragging.value) scrollY.value = event.contentOffset.y;
|
|
1494
|
-
},
|
|
1495
|
-
onBeginDrag: () => {
|
|
1496
|
-
isDragging.value = true;
|
|
1497
|
-
},
|
|
1498
|
-
onEndDrag: (event) => {
|
|
1499
|
-
isDragging.value = false;
|
|
1500
|
-
if (!isWeb$1 && isActiveShared.value) {
|
|
1501
|
-
scrollY.value = event.contentOffset.y;
|
|
1502
|
-
runOnJS(onSettleOffset)(event.contentOffset.y);
|
|
1503
|
-
}
|
|
1504
|
-
},
|
|
1505
|
-
onMomentumEnd: (event) => {
|
|
1506
|
-
isDragging.value = false;
|
|
1507
|
-
if (!isWeb$1 && isActiveShared.value) {
|
|
1508
|
-
scrollY.value = event.contentOffset.y;
|
|
1509
|
-
runOnJS(onSettleOffset)(event.contentOffset.y);
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
});
|
|
1513
|
-
useAnimatedReaction(() => scrollY.value, (current, previous) => {
|
|
1514
|
-
if (!isActiveShared.value && current !== previous) scrollTo(scrollRef, 0, current, false);
|
|
1515
|
-
});
|
|
1516
|
-
useAnimatedReaction(() => isActiveShared.value, (active, previous) => {
|
|
1517
|
-
if (isWeb$1 || !active || active === previous) return;
|
|
1518
|
-
scrollTo(scrollRef, 0, scrollY.value, false);
|
|
1519
|
-
});
|
|
1520
1608
|
const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
1521
1609
|
mode,
|
|
1522
1610
|
date,
|
|
@@ -1528,8 +1616,8 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1528
1616
|
]);
|
|
1529
1617
|
const daysPerPage = pageStepDays(mode, date, weekStartsOn, numberOfDays);
|
|
1530
1618
|
const dayCount = days.length;
|
|
1531
|
-
const dayWidth =
|
|
1532
|
-
const dayLeft = (dayIndex) =>
|
|
1619
|
+
const dayWidth = width / dayCount;
|
|
1620
|
+
const dayLeft = (dayIndex) => dayIndex * dayWidth;
|
|
1533
1621
|
const dayOrdinals = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[0])), [days]);
|
|
1534
1622
|
const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
|
|
1535
1623
|
const [multiDayMove, setMultiDayMove] = useState(null);
|
|
@@ -1556,7 +1644,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1556
1644
|
const date = onLongPressCell && cellDateFromTouch(event);
|
|
1557
1645
|
if (date) onLongPressCell?.(date);
|
|
1558
1646
|
};
|
|
1559
|
-
const hoursRange = useMemo(() =>
|
|
1647
|
+
const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1560
1648
|
const now = useNow$1(showNowIndicator && isActive, {
|
|
1561
1649
|
now: nowProp,
|
|
1562
1650
|
timeZone: nowTimeZone
|
|
@@ -1569,23 +1657,24 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1569
1657
|
maxHour,
|
|
1570
1658
|
heightSource
|
|
1571
1659
|
]);
|
|
1572
|
-
const
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
return Gesture.Simultaneous(pinch, Gesture.Native());
|
|
1582
|
-
}, [
|
|
1583
|
-
cellHeight,
|
|
1584
|
-
committedCellHeight,
|
|
1585
|
-
pinchStartCellHeight,
|
|
1586
|
-
minHourHeight,
|
|
1587
|
-
maxHourHeight
|
|
1660
|
+
const headerOffset = pagedHeader ? DAY_HEADER_HEIGHT : 0;
|
|
1661
|
+
const gridStyle = useAnimatedStyle(() => ({
|
|
1662
|
+
top: headerOffset + laneHeight.value + HOUR_LABEL_TOP_INSET,
|
|
1663
|
+
height: (maxHour - minHour) * heightSource.value
|
|
1664
|
+
}), [
|
|
1665
|
+
minHour,
|
|
1666
|
+
maxHour,
|
|
1667
|
+
heightSource,
|
|
1668
|
+
headerOffset
|
|
1588
1669
|
]);
|
|
1670
|
+
const laneHeightStyle = useAnimatedStyle(() => ({
|
|
1671
|
+
height: Math.max(LANE_BAND_FLOOR, laneHeight.value),
|
|
1672
|
+
borderBottomWidth: laneHeight.value >= LANE_BAND_FLOOR ? StyleSheet.hairlineWidth : 0
|
|
1673
|
+
}));
|
|
1674
|
+
const pinStyle = useAnimatedStyle(() => ({ transform: [{ translateY: scrollY.value }] }));
|
|
1675
|
+
const reportLaneLayout = useCallback((event) => {
|
|
1676
|
+
onLaneLayout(pageIndex, event.nativeEvent.layout.height);
|
|
1677
|
+
}, [onLaneLayout, pageIndex]);
|
|
1589
1678
|
const createEnabled = onCreateEvent != null;
|
|
1590
1679
|
const createActive = useSharedValue(0);
|
|
1591
1680
|
const createTop = useSharedValue(0);
|
|
@@ -1628,7 +1717,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1628
1717
|
const idx = dayCount === 1 ? 0 : Math.floor(event.x / dayWidth);
|
|
1629
1718
|
createDayIndex.value = idx;
|
|
1630
1719
|
createStartY.value = event.y;
|
|
1631
|
-
createLeft.value =
|
|
1720
|
+
createLeft.value = idx * dayWidth;
|
|
1632
1721
|
createWidth.value = dayWidth;
|
|
1633
1722
|
createTop.value = event.y;
|
|
1634
1723
|
createHeight.value = 0;
|
|
@@ -1653,7 +1742,6 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1653
1742
|
createEnabled,
|
|
1654
1743
|
dayCount,
|
|
1655
1744
|
dayWidth,
|
|
1656
|
-
hourColumnWidth,
|
|
1657
1745
|
heightSource,
|
|
1658
1746
|
snapMinutes,
|
|
1659
1747
|
commitCreate,
|
|
@@ -1705,14 +1793,17 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1705
1793
|
opacity: createActive.value
|
|
1706
1794
|
}));
|
|
1707
1795
|
const ghostSlot = slot("createGhost", {
|
|
1708
|
-
base: [styles$1.createGhost, {
|
|
1796
|
+
base: [styles$1.createGhost, {
|
|
1797
|
+
marginHorizontal: eventGap,
|
|
1798
|
+
pointerEvents: "none"
|
|
1799
|
+
}],
|
|
1709
1800
|
themed: {
|
|
1710
1801
|
backgroundColor: theme.colors.eventBackground,
|
|
1711
1802
|
borderColor: theme.colors.todayBackground
|
|
1712
1803
|
}
|
|
1713
1804
|
});
|
|
1714
1805
|
const cellLayer = onPressCell || onLongPressCell || createEnabled ? /* @__PURE__ */ jsx(Pressable, {
|
|
1715
|
-
style:
|
|
1806
|
+
style: styles$1.cellPressLayer,
|
|
1716
1807
|
onPress: onPressCell ? handleBackgroundPress : void 0,
|
|
1717
1808
|
onLongPress: !createEnabled && onLongPressCell ? handleBackgroundLongPress : void 0,
|
|
1718
1809
|
tabIndex: -1,
|
|
@@ -1720,197 +1811,234 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1720
1811
|
accessibilityElementsHidden: true
|
|
1721
1812
|
}) : null;
|
|
1722
1813
|
return /* @__PURE__ */ jsxs(View, {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1814
|
+
testID: "time-grid-page",
|
|
1815
|
+
style: [styles$1.page, {
|
|
1816
|
+
width,
|
|
1817
|
+
height
|
|
1818
|
+
}],
|
|
1819
|
+
accessibilityElementsHidden: !isActive,
|
|
1820
|
+
importantForAccessibility: isActive ? "auto" : "no-hide-descendants",
|
|
1821
|
+
children: [
|
|
1822
|
+
pagedHeader ? /* @__PURE__ */ jsx(Animated.View, {
|
|
1823
|
+
testID: "paged-header",
|
|
1824
|
+
style: [
|
|
1825
|
+
styles$1.pagedHeader,
|
|
1826
|
+
{
|
|
1827
|
+
backgroundColor: theme.colors.surface,
|
|
1828
|
+
borderBottomColor: theme.colors.gridLine
|
|
1829
|
+
},
|
|
1830
|
+
pinStyle
|
|
1831
|
+
],
|
|
1832
|
+
children: /* @__PURE__ */ jsx(DayHeaderRow, {
|
|
1833
|
+
days,
|
|
1834
|
+
mode,
|
|
1835
|
+
dayWidth,
|
|
1836
|
+
weekdayFormat,
|
|
1837
|
+
locale,
|
|
1838
|
+
activeDate,
|
|
1839
|
+
onPressDateHeader
|
|
1840
|
+
})
|
|
1841
|
+
}) : null,
|
|
1842
|
+
showAllDayEventCell ? /* @__PURE__ */ jsx(Animated.View, {
|
|
1843
|
+
testID: "all-day-band",
|
|
1844
|
+
style: [
|
|
1845
|
+
styles$1.laneBand,
|
|
1846
|
+
{
|
|
1847
|
+
top: headerOffset,
|
|
1848
|
+
backgroundColor: theme.colors.surface,
|
|
1849
|
+
borderBottomColor: theme.colors.gridLine
|
|
1850
|
+
},
|
|
1851
|
+
laneHeightStyle,
|
|
1852
|
+
pinStyle
|
|
1853
|
+
],
|
|
1854
|
+
children: /* @__PURE__ */ jsx(AllDayLane, {
|
|
1855
|
+
days,
|
|
1856
|
+
events,
|
|
1857
|
+
mode,
|
|
1858
|
+
dayWidth,
|
|
1859
|
+
renderEvent,
|
|
1860
|
+
keyExtractor,
|
|
1861
|
+
onPressEvent,
|
|
1862
|
+
onLongPressEvent,
|
|
1863
|
+
onLayout: reportLaneLayout
|
|
1864
|
+
})
|
|
1865
|
+
}) : null,
|
|
1866
|
+
/* @__PURE__ */ jsxs(Animated.View, {
|
|
1867
|
+
style: [styles$1.grid, gridStyle],
|
|
1868
|
+
children: [
|
|
1869
|
+
cellLayer && backgroundGesture ? /* @__PURE__ */ jsx(GestureDetector, {
|
|
1870
|
+
gesture: backgroundGesture,
|
|
1871
|
+
children: cellLayer
|
|
1872
|
+
}) : cellLayer,
|
|
1873
|
+
days.map((day, dayIndex) => {
|
|
1874
|
+
if (!highlightWeekends || !isWeekend$1(day)) return null;
|
|
1875
|
+
const shadeSlot = slot("weekendShade", {
|
|
1876
|
+
base: [
|
|
1780
1877
|
styles$1.weekendColumn,
|
|
1781
1878
|
styles$1.nonInteractive,
|
|
1782
1879
|
{
|
|
1783
1880
|
left: dayLeft(dayIndex),
|
|
1784
1881
|
width: dayWidth
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1882
|
+
}
|
|
1883
|
+
],
|
|
1884
|
+
themed: { backgroundColor: theme.colors.weekendBackground }
|
|
1885
|
+
});
|
|
1886
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
1887
|
+
testID: "weekend-shade",
|
|
1888
|
+
...shadeSlot,
|
|
1889
|
+
style: [shadeSlot.style, fullHeightStyle]
|
|
1890
|
+
}, `weekend-${day.toISOString()}`);
|
|
1891
|
+
}),
|
|
1892
|
+
calendarCellStyle ? days.map((day, dayIndex) => {
|
|
1893
|
+
const cellStyle = calendarCellStyle(day);
|
|
1894
|
+
return cellStyle ? /* @__PURE__ */ jsx(Animated.View, { style: [
|
|
1895
|
+
styles$1.weekendColumn,
|
|
1896
|
+
styles$1.nonInteractive,
|
|
1897
|
+
{
|
|
1898
|
+
left: dayLeft(dayIndex),
|
|
1899
|
+
width: dayWidth
|
|
1900
|
+
},
|
|
1901
|
+
cellStyle,
|
|
1902
|
+
fullHeightStyle
|
|
1903
|
+
] }, `cell-${day.toISOString()}`) : null;
|
|
1904
|
+
}) : null,
|
|
1905
|
+
businessHours ? days.flatMap((day, dayIndex) => closedHourBands(day, businessHours, minHour, maxHour).map((band, bandIndex) => /* @__PURE__ */ jsx(ShadeBand, {
|
|
1906
|
+
cellHeight: heightSource,
|
|
1907
|
+
startHour: band.start,
|
|
1908
|
+
endHour: band.end,
|
|
1909
|
+
minHour,
|
|
1910
|
+
left: dayLeft(dayIndex),
|
|
1911
|
+
width: dayWidth,
|
|
1912
|
+
color: renderBusinessHours ? void 0 : theme.colors.outsideHoursBackground,
|
|
1913
|
+
children: renderBusinessHours?.({
|
|
1914
|
+
date: day,
|
|
1915
|
+
start: band.start,
|
|
1916
|
+
end: band.end
|
|
1917
|
+
})
|
|
1918
|
+
}, `closed-${day.toISOString()}-${bandIndex}`))) : null,
|
|
1919
|
+
days.flatMap((day, dayIndex) => {
|
|
1920
|
+
const dayStart = startOfDay(day);
|
|
1921
|
+
const nextDayStart = addDays(dayStart, 1);
|
|
1922
|
+
return backgroundBandsForDay$1(events, day).map((b) => ({
|
|
1805
1923
|
...b,
|
|
1806
1924
|
startHours: Math.max(b.startHours, minHour),
|
|
1807
1925
|
endHours: Math.min(b.endHours, maxHour)
|
|
1808
|
-
})).filter((b) => b.endHours > b.startHours).map((b, bandIndex) =>
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
minHour,
|
|
1813
|
-
left: dayLeft(dayIndex),
|
|
1814
|
-
width: dayWidth,
|
|
1815
|
-
color: theme.colors.backgroundEvent,
|
|
1816
|
-
slotName: "backgroundEvent",
|
|
1817
|
-
testID: "background-event-shade"
|
|
1818
|
-
}, `bg-${day.toISOString()}-${bandIndex}`))),
|
|
1819
|
-
days.map((day, dayIndex) => {
|
|
1820
|
-
const separatorSlot = slot("daySeparator", {
|
|
1821
|
-
base: [
|
|
1822
|
-
styles$1.daySeparator,
|
|
1823
|
-
styles$1.nonInteractive,
|
|
1824
|
-
{ left: dayLeft(dayIndex) }
|
|
1825
|
-
],
|
|
1826
|
-
themed: { backgroundColor: theme.colors.gridLine }
|
|
1827
|
-
});
|
|
1828
|
-
return /* @__PURE__ */ jsx(Animated.View, {
|
|
1829
|
-
...separatorSlot,
|
|
1830
|
-
style: [separatorSlot.style, fullHeightStyle]
|
|
1831
|
-
}, `separator-${day.toISOString()}`);
|
|
1832
|
-
}),
|
|
1833
|
-
hoursRange.map((hour) => /* @__PURE__ */ jsx(HourRow, {
|
|
1834
|
-
hour,
|
|
1835
|
-
minHour,
|
|
1836
|
-
cellHeight: heightSource,
|
|
1837
|
-
hourColumnWidth,
|
|
1838
|
-
label: formatHour(hour, { ampm }),
|
|
1839
|
-
ampm,
|
|
1840
|
-
hourComponent
|
|
1841
|
-
}, hour)),
|
|
1842
|
-
timeslots > 1 ? hoursRange.flatMap((hour) => Array.from({ length: timeslots - 1 }, (_, i) => /* @__PURE__ */ jsx(TimeslotLine, {
|
|
1843
|
-
hour,
|
|
1844
|
-
minHour,
|
|
1845
|
-
fraction: (i + 1) / timeslots,
|
|
1846
|
-
cellHeight: heightSource,
|
|
1847
|
-
hourColumnWidth
|
|
1848
|
-
}, `slot-${hour}-${i}`))) : null,
|
|
1849
|
-
dayLayouts.flatMap((layout, dayIndex) => layout.filter((p) => p.startHours < maxHour && p.startHours + p.durationHours > minHour).map((positioned, eventIndex) => {
|
|
1850
|
-
const columnWidth = dayWidth / positioned.columns;
|
|
1851
|
-
return /* @__PURE__ */ jsx(AnimatedEventBox, {
|
|
1852
|
-
positioned,
|
|
1853
|
-
eventIndex: events.indexOf(positioned.event),
|
|
1854
|
-
movingEvent,
|
|
1855
|
-
onMovePreview: setMultiDayMove,
|
|
1926
|
+
})).filter((b) => b.endHours > b.startHours).map((b, bandIndex) => {
|
|
1927
|
+
const key = `bg-${day.toISOString()}-${keyExtractor(b.event, bandIndex)}`;
|
|
1928
|
+
return renderBackgroundEvent ? /* @__PURE__ */ jsx(BackgroundEventBand, {
|
|
1929
|
+
event: b.event,
|
|
1856
1930
|
cellHeight: heightSource,
|
|
1931
|
+
startHour: b.startHours,
|
|
1932
|
+
endHour: b.endHours,
|
|
1857
1933
|
minHour,
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
width: columnWidth,
|
|
1861
|
-
dayLeftPx: dayLeft(dayIndex),
|
|
1862
|
-
nextDayDirection: isRTL ? -1 : 1,
|
|
1863
|
-
dayWidth,
|
|
1864
|
-
dayIndex,
|
|
1865
|
-
dayCount: days.length,
|
|
1866
|
-
dayOrdinals,
|
|
1934
|
+
left: dayLeft(dayIndex),
|
|
1935
|
+
width: dayWidth,
|
|
1867
1936
|
mode,
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
showDragHandle,
|
|
1872
|
-
eventStartEditable,
|
|
1873
|
-
eventDurationEditable,
|
|
1937
|
+
continuesBefore: b.event.start < dayStart,
|
|
1938
|
+
continuesAfter: b.event.end > nextDayStart,
|
|
1939
|
+
render: renderBackgroundEvent,
|
|
1874
1940
|
onPress: onPressEvent,
|
|
1875
|
-
onLongPress: onLongPressEvent
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1941
|
+
onLongPress: onLongPressEvent
|
|
1942
|
+
}, key) : /* @__PURE__ */ jsx(ShadeBand, {
|
|
1943
|
+
cellHeight: heightSource,
|
|
1944
|
+
startHour: b.startHours,
|
|
1945
|
+
endHour: b.endHours,
|
|
1946
|
+
minHour,
|
|
1947
|
+
left: dayLeft(dayIndex),
|
|
1948
|
+
width: dayWidth,
|
|
1949
|
+
color: theme.colors.backgroundEvent,
|
|
1950
|
+
slotName: "backgroundEvent",
|
|
1951
|
+
testID: "background-event-shade"
|
|
1952
|
+
}, key);
|
|
1953
|
+
});
|
|
1954
|
+
}),
|
|
1955
|
+
days.map((day, dayIndex) => {
|
|
1956
|
+
const separatorSlot = slot("daySeparator", {
|
|
1957
|
+
base: [
|
|
1958
|
+
styles$1.daySeparator,
|
|
1959
|
+
styles$1.nonInteractive,
|
|
1960
|
+
{ left: dayLeft(dayIndex) }
|
|
1961
|
+
],
|
|
1962
|
+
themed: { backgroundColor: theme.colors.gridLine }
|
|
1963
|
+
});
|
|
1964
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
1965
|
+
...separatorSlot,
|
|
1966
|
+
style: [separatorSlot.style, fullHeightStyle]
|
|
1967
|
+
}, `separator-${day.toISOString()}`);
|
|
1968
|
+
}),
|
|
1969
|
+
/* @__PURE__ */ jsx(HourLines, {
|
|
1970
|
+
hours: hoursRange,
|
|
1971
|
+
timeslots
|
|
1972
|
+
}),
|
|
1973
|
+
dayLayouts.flatMap((layout, dayIndex) => layout.filter((p) => p.startHours < maxHour && p.startHours + p.durationHours > minHour).map((positioned, eventIndex) => {
|
|
1974
|
+
const columnWidth = dayWidth / positioned.columns;
|
|
1975
|
+
return /* @__PURE__ */ jsx(AnimatedEventBox, {
|
|
1976
|
+
positioned,
|
|
1977
|
+
eventIndex: events.indexOf(positioned.event),
|
|
1978
|
+
movingEvent,
|
|
1979
|
+
onMovePreview: setMultiDayMove,
|
|
1884
1980
|
cellHeight: heightSource,
|
|
1885
|
-
dayWidth,
|
|
1886
|
-
hourColumnWidth,
|
|
1887
1981
|
minHour,
|
|
1982
|
+
maxHour,
|
|
1983
|
+
left: dayLeft(dayIndex) + positioned.column * columnWidth,
|
|
1984
|
+
width: columnWidth,
|
|
1985
|
+
dayLeftPx: dayLeft(dayIndex),
|
|
1986
|
+
nextDayDirection: isRTL ? -1 : 1,
|
|
1987
|
+
dayWidth,
|
|
1988
|
+
dayIndex,
|
|
1989
|
+
dayCount: days.length,
|
|
1990
|
+
dayOrdinals,
|
|
1888
1991
|
mode,
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1992
|
+
daysPerPage,
|
|
1993
|
+
renderEvent,
|
|
1994
|
+
snapMinutes,
|
|
1995
|
+
minEventHeight,
|
|
1996
|
+
eventGap,
|
|
1997
|
+
showDragHandle,
|
|
1998
|
+
eventStartEditable,
|
|
1999
|
+
eventDurationEditable,
|
|
2000
|
+
onPress: onPressEvent,
|
|
2001
|
+
onLongPress: onLongPressEvent,
|
|
2002
|
+
onDragEvent,
|
|
2003
|
+
onDragStart,
|
|
2004
|
+
onEdgeAdvance
|
|
2005
|
+
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
2006
|
+
})),
|
|
2007
|
+
multiDayMove ? /* @__PURE__ */ jsx(MultiDayMovePreview, {
|
|
2008
|
+
move: multiDayMove,
|
|
2009
|
+
days,
|
|
2010
|
+
cellHeight: heightSource,
|
|
2011
|
+
dayWidth,
|
|
2012
|
+
minHour,
|
|
2013
|
+
mode,
|
|
2014
|
+
renderEvent,
|
|
2015
|
+
minEventHeight,
|
|
2016
|
+
eventGap
|
|
2017
|
+
}) : null,
|
|
2018
|
+
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
|
|
2019
|
+
cellHeight: heightSource,
|
|
2020
|
+
nowHours,
|
|
2021
|
+
minHour,
|
|
2022
|
+
left: dayLeft(nowDayIndex),
|
|
2023
|
+
width: dayWidth,
|
|
2024
|
+
color: theme.colors.nowIndicator
|
|
2025
|
+
}) : null,
|
|
2026
|
+
createEnabled ? /* @__PURE__ */ jsx(Animated.View, {
|
|
2027
|
+
...ghostSlot,
|
|
2028
|
+
style: [ghostSlot.style, createGhostStyle]
|
|
2029
|
+
}) : null
|
|
2030
|
+
]
|
|
1905
2031
|
})
|
|
1906
|
-
|
|
2032
|
+
]
|
|
1907
2033
|
});
|
|
1908
2034
|
}
|
|
1909
2035
|
const TimetablePage = memo(TimetablePageInner);
|
|
1910
|
-
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
2036
|
+
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, showAllDayLabel = false, refreshControl, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
1911
2037
|
const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
|
|
1912
2038
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
1913
2039
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
2040
|
+
const pagedHeader = renderHeader == null;
|
|
2041
|
+
const headerOffset = pagedHeader ? DAY_HEADER_HEIGHT : 0;
|
|
1914
2042
|
const labeledRenderEvent = useMemo(() => withEventAccessibilityLabel(renderEvent, eventAccessibilityLabel, ampm), [
|
|
1915
2043
|
renderEvent,
|
|
1916
2044
|
eventAccessibilityLabel,
|
|
@@ -1924,34 +2052,76 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1924
2052
|
eventOverlap,
|
|
1925
2053
|
events
|
|
1926
2054
|
]);
|
|
1927
|
-
const { width
|
|
2055
|
+
const { width } = useWindowDimensions();
|
|
1928
2056
|
const listRef = useRef(null);
|
|
1929
2057
|
const pagerRef = useRef(null);
|
|
1930
2058
|
const containerRef = useRef(null);
|
|
1931
|
-
const
|
|
1932
|
-
const
|
|
2059
|
+
const viewportRef = useRef(null);
|
|
2060
|
+
const pagerLayoutWidthRef = useRef(-1);
|
|
2061
|
+
const scrollRef = useAnimatedRef();
|
|
1933
2062
|
const [containerWidth, setContainerWidth] = useState(width);
|
|
1934
|
-
const [
|
|
2063
|
+
const [pagerLayoutWidth, setPagerLayoutWidth] = useState(null);
|
|
2064
|
+
const columnsWidth = pagerLayoutWidth ?? containerWidth - hourColumnWidth;
|
|
2065
|
+
const pagerReady = pagerLayoutWidth != null && pagerLayoutWidth > 0;
|
|
2066
|
+
const [tallestLane, setTallestLane] = useState(0);
|
|
1935
2067
|
const weekAnchored = mode === "week" || mode === "custom" && weekEndsOn != null;
|
|
1936
2068
|
const step = weekAnchored ? 7 : viewDayCount(mode, numberOfDays);
|
|
1937
2069
|
const seedDefaultY = Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR$1 - clampedMinHour) * hourHeight;
|
|
1938
2070
|
const scrollY = useSharedValue(seedDefaultY);
|
|
2071
|
+
const scrollHandler = useAnimatedScrollHandler({ onScroll: (event) => {
|
|
2072
|
+
scrollY.value = event.contentOffset.y;
|
|
2073
|
+
} });
|
|
2074
|
+
const webSeededRef = useRef(!isWeb$1);
|
|
2075
|
+
const seedWebScroll = useCallback(() => {
|
|
2076
|
+
if (webSeededRef.current) return;
|
|
2077
|
+
const node = scrollRef.current;
|
|
2078
|
+
if (!node) return;
|
|
2079
|
+
node.scrollTo({
|
|
2080
|
+
y: seedDefaultY,
|
|
2081
|
+
animated: false
|
|
2082
|
+
});
|
|
2083
|
+
const dom = node.getScrollableNode();
|
|
2084
|
+
if (dom && dom.scrollHeight > dom.clientHeight) webSeededRef.current = true;
|
|
2085
|
+
}, [scrollRef, seedDefaultY]);
|
|
2086
|
+
const laneHeights = useSharedValue({});
|
|
2087
|
+
const laneHeightsRef = useRef({});
|
|
2088
|
+
const pagerOffset = useSharedValue(PAGE_WINDOW * columnsWidth);
|
|
2089
|
+
const pagerSharedValues = useMemo(() => ({ scrollOffset: pagerOffset }), [pagerOffset]);
|
|
2090
|
+
const activeIndexShared = useSharedValue(PAGE_WINDOW);
|
|
2091
|
+
const laneHeight = useDerivedValue(() => {
|
|
2092
|
+
if (!showAllDayEventCell || columnsWidth <= 0) return 0;
|
|
2093
|
+
const heights = laneHeights.value;
|
|
2094
|
+
let progress = pagerOffset.value / columnsWidth;
|
|
2095
|
+
if (Math.abs(progress - activeIndexShared.value) > 1.5) progress = activeIndexShared.value;
|
|
2096
|
+
const from = Math.floor(progress);
|
|
2097
|
+
const fraction = progress - from;
|
|
2098
|
+
const start = heights[from] ?? 0;
|
|
2099
|
+
return start + ((heights[from + 1] ?? start) - start) * fraction;
|
|
2100
|
+
}, [showAllDayEventCell, columnsWidth]);
|
|
2101
|
+
const reportLaneHeight = useCallback((index, height) => {
|
|
2102
|
+
setTallestLane((tallest) => height > tallest ? height : tallest);
|
|
2103
|
+
if (laneHeightsRef.current[index] === height) return;
|
|
2104
|
+
laneHeightsRef.current = {
|
|
2105
|
+
...laneHeightsRef.current,
|
|
2106
|
+
[index]: height
|
|
2107
|
+
};
|
|
2108
|
+
laneHeights.value = laneHeightsRef.current;
|
|
2109
|
+
}, [laneHeights]);
|
|
2110
|
+
const viewportTop = useSharedValue(0);
|
|
1939
2111
|
const pagerLeft = useSharedValue(0);
|
|
1940
|
-
const pagerTop = useSharedValue(0);
|
|
1941
2112
|
const pagerWidth = useSharedValue(width);
|
|
1942
|
-
const
|
|
2113
|
+
const pagerTop = useDerivedValue(() => viewportTop.value - scrollY.value);
|
|
1943
2114
|
const ghostX = useSharedValue(0);
|
|
1944
2115
|
const ghostY = useSharedValue(0);
|
|
1945
2116
|
const ghostW = useSharedValue(0);
|
|
1946
2117
|
const ghostH = useSharedValue(0);
|
|
1947
2118
|
const ghostVisible = useSharedValue(0);
|
|
1948
|
-
const gridTop = useSharedValue(0);
|
|
1949
2119
|
const [liftedEvent, setLiftedEvent] = useState(null);
|
|
1950
2120
|
const liftedEventRef = useRef(null);
|
|
1951
2121
|
const dropRef = useRef({
|
|
1952
2122
|
headerDays: [],
|
|
1953
|
-
|
|
1954
|
-
|
|
2123
|
+
columnsWidth,
|
|
2124
|
+
headerOffset,
|
|
1955
2125
|
minHour: clampedMinHour,
|
|
1956
2126
|
maxHour: clampedMaxHour,
|
|
1957
2127
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
@@ -1966,17 +2136,16 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1966
2136
|
ghostVisible.value = 0;
|
|
1967
2137
|
liftedEventRef.current = null;
|
|
1968
2138
|
setLiftedEvent(null);
|
|
1969
|
-
setEdgePagingLock(false);
|
|
1970
2139
|
}, [ghostVisible]);
|
|
1971
2140
|
const commitLiftedDrop = useCallback((ghostLocalX, ghostLocalY) => {
|
|
1972
|
-
const { headerDays: days,
|
|
2141
|
+
const { headerDays: days, columnsWidth: cw, headerOffset: headerH, minHour: min, maxHour: max, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1973
2142
|
const ev = liftedEventRef.current;
|
|
1974
2143
|
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1975
2144
|
clearLift();
|
|
1976
2145
|
if (!ev || !onDrag || days.length === 0) return;
|
|
1977
|
-
const dayWidth =
|
|
1978
|
-
const col = Math.min(Math.max(Math.floor(
|
|
1979
|
-
const rawMinutes = (min + (ghostLocalY -
|
|
2146
|
+
const dayWidth = cw / days.length;
|
|
2147
|
+
const col = Math.min(Math.max(Math.floor(ghostLocalX / dayWidth), 0), days.length - 1);
|
|
2148
|
+
const rawMinutes = (min + (ghostLocalY - headerH - laneHeight.value - HOUR_LABEL_TOP_INSET) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1980
2149
|
const minutes = clampMoveStartMinutes(Math.round(rawMinutes / snap) * snap, min, max, snap);
|
|
1981
2150
|
const start = new Date(days[col]);
|
|
1982
2151
|
start.setHours(0, 0, 0, 0);
|
|
@@ -1984,18 +2153,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1984
2153
|
if (onDrag(ev, start, new Date(start.getTime() + duration)) === false) onDate(ev.start);
|
|
1985
2154
|
}, [
|
|
1986
2155
|
clearLift,
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
cellHeight
|
|
2156
|
+
cellHeight,
|
|
2157
|
+
laneHeight
|
|
1990
2158
|
]);
|
|
1991
|
-
const handleGridTop = useCallback((y) => {
|
|
1992
|
-
gridTop.value = y;
|
|
1993
|
-
}, [gridTop]);
|
|
1994
2159
|
const edgePaging = useMemo(() => ({
|
|
1995
2160
|
pagerLeft,
|
|
1996
2161
|
pagerTop,
|
|
1997
2162
|
pagerWidth,
|
|
1998
|
-
lockScroll: setEdgePagingLock,
|
|
1999
2163
|
ghostX,
|
|
2000
2164
|
ghostY,
|
|
2001
2165
|
ghostW,
|
|
@@ -2015,11 +2179,37 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2015
2179
|
beginLift,
|
|
2016
2180
|
commitLiftedDrop
|
|
2017
2181
|
]);
|
|
2018
|
-
const offsetSeedRef = useRef(null);
|
|
2019
|
-
const captureOffsetSeed = useCallback((y) => {
|
|
2020
|
-
offsetSeedRef.current = y;
|
|
2021
|
-
}, []);
|
|
2022
2182
|
const committedCellHeight = useSharedValue(hourHeight);
|
|
2183
|
+
const pinching = useSharedValue(false);
|
|
2184
|
+
useAnimatedReaction(() => cellHeight.value, (value) => {
|
|
2185
|
+
if (!pinching.value) committedCellHeight.value = value;
|
|
2186
|
+
});
|
|
2187
|
+
const pinchStartCellHeight = useSharedValue(hourHeight);
|
|
2188
|
+
const zoomGesture = useMemo(() => {
|
|
2189
|
+
const pinch = Gesture.Pinch().onStart(() => {
|
|
2190
|
+
pinching.value = true;
|
|
2191
|
+
pinchStartCellHeight.value = cellHeight.value;
|
|
2192
|
+
}).onUpdate((event) => {
|
|
2193
|
+
cellHeight.value = Math.min(maxHourHeight, Math.max(minHourHeight, pinchStartCellHeight.value * event.scale));
|
|
2194
|
+
}).onFinalize(() => {
|
|
2195
|
+
pinching.value = false;
|
|
2196
|
+
committedCellHeight.value = cellHeight.value;
|
|
2197
|
+
});
|
|
2198
|
+
return Gesture.Simultaneous(pinch, Gesture.Native());
|
|
2199
|
+
}, [
|
|
2200
|
+
cellHeight,
|
|
2201
|
+
committedCellHeight,
|
|
2202
|
+
pinching,
|
|
2203
|
+
pinchStartCellHeight,
|
|
2204
|
+
minHourHeight,
|
|
2205
|
+
maxHourHeight
|
|
2206
|
+
]);
|
|
2207
|
+
const pagerHeight = headerOffset + HOUR_LABEL_TOP_INSET + (clampedMaxHour - clampedMinHour) * maxHourHeight + tallestLane;
|
|
2208
|
+
const gridHeightStyle = useAnimatedStyle(() => ({ height: headerOffset + laneHeight.value + HOUR_LABEL_TOP_INSET + (clampedMaxHour - clampedMinHour) * cellHeight.value }), [
|
|
2209
|
+
clampedMinHour,
|
|
2210
|
+
clampedMaxHour,
|
|
2211
|
+
headerOffset
|
|
2212
|
+
]);
|
|
2023
2213
|
useWebGridZoom(isWeb$1, containerRef, cellHeight, committedCellHeight, minHourHeight, maxHourHeight);
|
|
2024
2214
|
const [anchorDate] = useState(date);
|
|
2025
2215
|
const anchor = useMemo(() => weekAnchored ? startOfWeek(anchorDate, { weekStartsOn }) : startOfDay(anchorDate), [
|
|
@@ -2037,8 +2227,31 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2037
2227
|
step,
|
|
2038
2228
|
weekStartsOn
|
|
2039
2229
|
])(date);
|
|
2230
|
+
useEffect(() => {
|
|
2231
|
+
activeIndexShared.value = activeIndex;
|
|
2232
|
+
}, [activeIndex, activeIndexShared]);
|
|
2040
2233
|
const viewedIndexRef = useRef(activeIndex);
|
|
2041
2234
|
const pendingScrollIndexRef = useRef(null);
|
|
2235
|
+
const weekNumber = useMemo(() => {
|
|
2236
|
+
if (!pagedHeader || !showWeekNumber || hourColumnWidth === 0) return null;
|
|
2237
|
+
const days = getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays);
|
|
2238
|
+
const thursday = days.find((d) => d.getDay() === 4) ?? days[0];
|
|
2239
|
+
return thursday ? `${weekNumberPrefix}${getISOWeek(thursday)}` : null;
|
|
2240
|
+
}, [
|
|
2241
|
+
pagedHeader,
|
|
2242
|
+
showWeekNumber,
|
|
2243
|
+
hourColumnWidth,
|
|
2244
|
+
mode,
|
|
2245
|
+
pageDates,
|
|
2246
|
+
activeIndex,
|
|
2247
|
+
date,
|
|
2248
|
+
weekStartsOn,
|
|
2249
|
+
numberOfDays,
|
|
2250
|
+
isRTL,
|
|
2251
|
+
weekEndsOn,
|
|
2252
|
+
hiddenDays,
|
|
2253
|
+
weekNumberPrefix
|
|
2254
|
+
]);
|
|
2042
2255
|
const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
2043
2256
|
mode,
|
|
2044
2257
|
pageDates,
|
|
@@ -2052,8 +2265,8 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2052
2265
|
]);
|
|
2053
2266
|
dropRef.current = {
|
|
2054
2267
|
headerDays,
|
|
2055
|
-
|
|
2056
|
-
|
|
2268
|
+
columnsWidth,
|
|
2269
|
+
headerOffset,
|
|
2057
2270
|
minHour: clampedMinHour,
|
|
2058
2271
|
maxHour: clampedMaxHour,
|
|
2059
2272
|
snapMinutes: Math.max(1, dragStepMinutes),
|
|
@@ -2079,55 +2292,26 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2079
2292
|
if (activeIndex === viewedIndexRef.current) return;
|
|
2080
2293
|
viewedIndexRef.current = activeIndex;
|
|
2081
2294
|
pendingScrollIndexRef.current = activeIndex;
|
|
2295
|
+
pagerOffset.value = activeIndex * columnsWidth;
|
|
2082
2296
|
listRef.current?.scrollToIndex({
|
|
2083
2297
|
index: activeIndex,
|
|
2084
2298
|
animated: false
|
|
2085
2299
|
});
|
|
2086
2300
|
}, [activeIndex]);
|
|
2087
2301
|
useEffect(() => {
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
if (!root) return;
|
|
2091
|
-
const restoreVisiblePage = () => {
|
|
2092
|
-
const vw = (root.ownerDocument?.defaultView ?? globalThis).innerWidth;
|
|
2093
|
-
for (const el of root.querySelectorAll("*")) {
|
|
2094
|
-
const style = getComputedStyle(el);
|
|
2095
|
-
if (!((style.overflowY === "scroll" || style.overflowY === "auto") && el.scrollHeight > el.clientHeight + 20 && el.clientHeight > 100)) continue;
|
|
2096
|
-
const rect = el.getBoundingClientRect();
|
|
2097
|
-
if (rect.left > -50 && rect.right <= vw + 50) {
|
|
2098
|
-
el.scrollTop = scrollY.value;
|
|
2099
|
-
break;
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
};
|
|
2103
|
-
suppressCaptureUntilRef.current = Date.now() + 400;
|
|
2104
|
-
let raf2 = 0;
|
|
2105
|
-
const raf1 = requestAnimationFrame(() => {
|
|
2106
|
-
restoreVisiblePage();
|
|
2107
|
-
raf2 = requestAnimationFrame(restoreVisiblePage);
|
|
2108
|
-
});
|
|
2109
|
-
return () => {
|
|
2110
|
-
cancelAnimationFrame(raf1);
|
|
2111
|
-
cancelAnimationFrame(raf2);
|
|
2112
|
-
};
|
|
2113
|
-
}, [activeIndex, pageHeight]);
|
|
2302
|
+
pagerOffset.value = activeIndex * columnsWidth;
|
|
2303
|
+
}, [columnsWidth, pagerOffset]);
|
|
2114
2304
|
useEffect(() => {
|
|
2115
2305
|
if (!isWeb$1) return;
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
if (!el || typeof el.scrollTop !== "number" || el.clientHeight <= 100) return;
|
|
2122
|
-
const rect = el.getBoundingClientRect();
|
|
2123
|
-
const vw = (root.ownerDocument?.defaultView ?? globalThis).innerWidth;
|
|
2124
|
-
if (rect.left <= -50 || rect.right > vw + 50) return;
|
|
2125
|
-
scrollY.value = el.scrollTop;
|
|
2126
|
-
offsetSeedRef.current = el.scrollTop;
|
|
2306
|
+
let attempts = 0;
|
|
2307
|
+
let frame = 0;
|
|
2308
|
+
const attempt = () => {
|
|
2309
|
+
seedWebScroll();
|
|
2310
|
+
if (!webSeededRef.current && attempts++ < 120) frame = requestAnimationFrame(attempt);
|
|
2127
2311
|
};
|
|
2128
|
-
|
|
2129
|
-
return () =>
|
|
2130
|
-
}, []);
|
|
2312
|
+
frame = requestAnimationFrame(attempt);
|
|
2313
|
+
return () => cancelAnimationFrame(frame);
|
|
2314
|
+
}, [seedWebScroll]);
|
|
2131
2315
|
useEffect(() => {
|
|
2132
2316
|
if (!isWeb$1) return;
|
|
2133
2317
|
const root = containerRef.current;
|
|
@@ -2144,17 +2328,51 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2144
2328
|
};
|
|
2145
2329
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
2146
2330
|
return () => cancelAnimationFrame(raf);
|
|
2147
|
-
}, [
|
|
2331
|
+
}, [columnsWidth]);
|
|
2332
|
+
const reduceMotion = useReducedMotion();
|
|
2148
2333
|
const goToPage = useCallback((delta) => {
|
|
2149
|
-
const
|
|
2150
|
-
|
|
2334
|
+
const index = viewedIndexRef.current + delta;
|
|
2335
|
+
const target = pageDates[index];
|
|
2336
|
+
if (!target) return;
|
|
2337
|
+
viewedIndexRef.current = index;
|
|
2338
|
+
pendingScrollIndexRef.current = index;
|
|
2339
|
+
pagerOffset.value = index * columnsWidth;
|
|
2340
|
+
listRef.current?.scrollToIndex({
|
|
2341
|
+
index,
|
|
2342
|
+
animated: !isWeb$1 && !reduceMotion
|
|
2343
|
+
});
|
|
2344
|
+
onChangeDate(target);
|
|
2151
2345
|
}, [
|
|
2152
2346
|
pageDates,
|
|
2153
|
-
|
|
2154
|
-
onChangeDate
|
|
2347
|
+
reduceMotion,
|
|
2348
|
+
onChangeDate,
|
|
2349
|
+
columnsWidth,
|
|
2350
|
+
pagerOffset
|
|
2155
2351
|
]);
|
|
2156
2352
|
useWebPagerKeys(swipeEnabled, goToPage);
|
|
2157
|
-
const
|
|
2353
|
+
const handlePagerSettled = useCallback((event) => {
|
|
2354
|
+
if (columnsWidth <= 0) return;
|
|
2355
|
+
if (pendingScrollIndexRef.current != null) return;
|
|
2356
|
+
const raw = Math.round(event.nativeEvent.contentOffset.x / columnsWidth);
|
|
2357
|
+
const index = Math.min(Math.max(raw, 0), pageDates.length - 1);
|
|
2358
|
+
if (index !== viewedIndexRef.current) {
|
|
2359
|
+
viewedIndexRef.current = index;
|
|
2360
|
+
const target = pageDates[index];
|
|
2361
|
+
if (target) onChangeDate(target);
|
|
2362
|
+
}
|
|
2363
|
+
pagerOffset.value = index * columnsWidth;
|
|
2364
|
+
requestAnimationFrame(() => {
|
|
2365
|
+
listRef.current?.scrollToIndex({
|
|
2366
|
+
index,
|
|
2367
|
+
animated: false
|
|
2368
|
+
});
|
|
2369
|
+
});
|
|
2370
|
+
}, [
|
|
2371
|
+
columnsWidth,
|
|
2372
|
+
pageDates,
|
|
2373
|
+
onChangeDate,
|
|
2374
|
+
pagerOffset
|
|
2375
|
+
]);
|
|
2158
2376
|
const handlePressCell = useMemo(() => {
|
|
2159
2377
|
if (!onPressCell) return void 0;
|
|
2160
2378
|
if (!resetPageOnPressCell) return onPressCell;
|
|
@@ -2173,98 +2391,93 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2173
2391
|
]);
|
|
2174
2392
|
const snapToIndices = useMemo(() => pageDates.map((_, index) => index), [pageDates]);
|
|
2175
2393
|
const keyExtractorList = useCallback((item) => item.toISOString(), []);
|
|
2176
|
-
const getFixedItemSize = useCallback(() =>
|
|
2177
|
-
const renderItem = useCallback(({ item, index }) => /* @__PURE__ */ jsx(
|
|
2178
|
-
style: {
|
|
2179
|
-
width: containerWidth,
|
|
2180
|
-
height: pageHeight
|
|
2181
|
-
},
|
|
2182
|
-
children: /* @__PURE__ */ jsx(TimetablePage, {
|
|
2183
|
-
mode,
|
|
2184
|
-
numberOfDays,
|
|
2185
|
-
hiddenDays,
|
|
2186
|
-
now,
|
|
2187
|
-
nowTimeZone: timeZone,
|
|
2188
|
-
date: item,
|
|
2189
|
-
width: containerWidth,
|
|
2190
|
-
events,
|
|
2191
|
-
cellHeight,
|
|
2192
|
-
hourHeight,
|
|
2193
|
-
committedCellHeight,
|
|
2194
|
-
scrollY,
|
|
2195
|
-
isActive: index === activeIndex,
|
|
2196
|
-
initialScrollY: offsetSeedRef.current ?? seedDefaultY,
|
|
2197
|
-
onSettleOffset: captureOffsetSeed,
|
|
2198
|
-
weekStartsOn,
|
|
2199
|
-
weekEndsOn,
|
|
2200
|
-
hourColumnWidth,
|
|
2201
|
-
minHour: clampedMinHour,
|
|
2202
|
-
maxHour: clampedMaxHour,
|
|
2203
|
-
ampm,
|
|
2204
|
-
timeslots,
|
|
2205
|
-
isRTL,
|
|
2206
|
-
showAllDayEventCell,
|
|
2207
|
-
highlightWeekends,
|
|
2208
|
-
showVerticalScrollIndicator,
|
|
2209
|
-
verticalScrollEnabled,
|
|
2210
|
-
hourComponent,
|
|
2211
|
-
calendarCellStyle,
|
|
2212
|
-
businessHours,
|
|
2213
|
-
renderBusinessHours,
|
|
2214
|
-
minHourHeight,
|
|
2215
|
-
maxHourHeight,
|
|
2216
|
-
showNowIndicator,
|
|
2217
|
-
renderEvent: labeledRenderEvent,
|
|
2218
|
-
keyExtractor,
|
|
2219
|
-
snapMinutes: Math.max(1, dragStepMinutes),
|
|
2220
|
-
showDragHandle,
|
|
2221
|
-
eventStartEditable,
|
|
2222
|
-
eventDurationEditable,
|
|
2223
|
-
onPressEvent,
|
|
2224
|
-
onLongPressEvent,
|
|
2225
|
-
onDragEvent,
|
|
2226
|
-
onDragStart,
|
|
2227
|
-
onPressCell: handlePressCell,
|
|
2228
|
-
onLongPressCell,
|
|
2229
|
-
onCreateEvent,
|
|
2230
|
-
onEdgeAdvance: goToPage,
|
|
2231
|
-
onGridTop: handleGridTop
|
|
2232
|
-
})
|
|
2233
|
-
}), [
|
|
2234
|
-
containerWidth,
|
|
2235
|
-
pageHeight,
|
|
2236
|
-
handleGridTop,
|
|
2394
|
+
const getFixedItemSize = useCallback(() => columnsWidth, [columnsWidth]);
|
|
2395
|
+
const renderItem = useCallback(({ item, index }) => /* @__PURE__ */ jsx(TimetablePage, {
|
|
2237
2396
|
mode,
|
|
2238
2397
|
numberOfDays,
|
|
2398
|
+
hiddenDays,
|
|
2399
|
+
now,
|
|
2400
|
+
nowTimeZone: timeZone,
|
|
2401
|
+
date: item,
|
|
2402
|
+
width: columnsWidth,
|
|
2239
2403
|
events,
|
|
2240
2404
|
cellHeight,
|
|
2241
|
-
hourHeight,
|
|
2242
2405
|
committedCellHeight,
|
|
2406
|
+
isActive: index === activeIndex,
|
|
2407
|
+
weekStartsOn,
|
|
2408
|
+
weekEndsOn,
|
|
2409
|
+
minHour: clampedMinHour,
|
|
2410
|
+
maxHour: clampedMaxHour,
|
|
2411
|
+
timeslots,
|
|
2412
|
+
isRTL,
|
|
2413
|
+
highlightWeekends,
|
|
2414
|
+
calendarCellStyle,
|
|
2415
|
+
businessHours,
|
|
2416
|
+
renderBusinessHours,
|
|
2417
|
+
renderBackgroundEvent,
|
|
2418
|
+
showNowIndicator,
|
|
2419
|
+
renderEvent: labeledRenderEvent,
|
|
2420
|
+
keyExtractor,
|
|
2421
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
2422
|
+
minEventHeight,
|
|
2423
|
+
eventGap,
|
|
2424
|
+
showDragHandle,
|
|
2425
|
+
eventStartEditable,
|
|
2426
|
+
eventDurationEditable,
|
|
2427
|
+
onPressEvent,
|
|
2428
|
+
onLongPressEvent,
|
|
2429
|
+
onDragEvent,
|
|
2430
|
+
onDragStart,
|
|
2431
|
+
onPressCell: handlePressCell,
|
|
2432
|
+
onLongPressCell,
|
|
2433
|
+
onCreateEvent,
|
|
2434
|
+
onEdgeAdvance: goToPage,
|
|
2435
|
+
pageIndex: index,
|
|
2436
|
+
laneHeight,
|
|
2243
2437
|
scrollY,
|
|
2438
|
+
showAllDayEventCell,
|
|
2439
|
+
onLaneLayout: reportLaneHeight,
|
|
2440
|
+
height: pagerHeight,
|
|
2441
|
+
pagedHeader,
|
|
2442
|
+
weekdayFormat,
|
|
2443
|
+
locale,
|
|
2444
|
+
activeDate,
|
|
2445
|
+
onPressDateHeader
|
|
2446
|
+
}), [
|
|
2447
|
+
columnsWidth,
|
|
2448
|
+
pagerHeight,
|
|
2449
|
+
pagedHeader,
|
|
2450
|
+
weekdayFormat,
|
|
2451
|
+
locale,
|
|
2452
|
+
activeDate,
|
|
2453
|
+
onPressDateHeader,
|
|
2454
|
+
laneHeight,
|
|
2455
|
+
scrollY,
|
|
2456
|
+
showAllDayEventCell,
|
|
2457
|
+
reportLaneHeight,
|
|
2458
|
+
mode,
|
|
2459
|
+
numberOfDays,
|
|
2460
|
+
events,
|
|
2461
|
+
cellHeight,
|
|
2462
|
+
committedCellHeight,
|
|
2244
2463
|
activeIndex,
|
|
2245
|
-
seedDefaultY,
|
|
2246
|
-
captureOffsetSeed,
|
|
2247
2464
|
weekStartsOn,
|
|
2248
2465
|
weekEndsOn,
|
|
2249
|
-
hourColumnWidth,
|
|
2250
2466
|
clampedMinHour,
|
|
2251
2467
|
clampedMaxHour,
|
|
2252
|
-
ampm,
|
|
2253
2468
|
timeslots,
|
|
2254
2469
|
isRTL,
|
|
2255
|
-
showAllDayEventCell,
|
|
2256
2470
|
highlightWeekends,
|
|
2257
|
-
showVerticalScrollIndicator,
|
|
2258
|
-
verticalScrollEnabled,
|
|
2259
|
-
hourComponent,
|
|
2260
2471
|
calendarCellStyle,
|
|
2261
2472
|
businessHours,
|
|
2262
|
-
|
|
2263
|
-
|
|
2473
|
+
renderBusinessHours,
|
|
2474
|
+
renderBackgroundEvent,
|
|
2264
2475
|
showNowIndicator,
|
|
2265
2476
|
labeledRenderEvent,
|
|
2266
2477
|
keyExtractor,
|
|
2267
2478
|
dragStepMinutes,
|
|
2479
|
+
minEventHeight,
|
|
2480
|
+
eventGap,
|
|
2268
2481
|
showDragHandle,
|
|
2269
2482
|
eventStartEditable,
|
|
2270
2483
|
eventDurationEditable,
|
|
@@ -2282,8 +2495,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2282
2495
|
]);
|
|
2283
2496
|
const listExtraData = useMemo(() => ({
|
|
2284
2497
|
events,
|
|
2285
|
-
activeIndex
|
|
2286
|
-
|
|
2498
|
+
activeIndex,
|
|
2499
|
+
columnsWidth
|
|
2500
|
+
}), [
|
|
2501
|
+
events,
|
|
2502
|
+
activeIndex,
|
|
2503
|
+
columnsWidth
|
|
2504
|
+
]);
|
|
2287
2505
|
return /* @__PURE__ */ jsx(SlotStylesProvider, {
|
|
2288
2506
|
classNames,
|
|
2289
2507
|
styles: styleOverrides,
|
|
@@ -2292,62 +2510,105 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2292
2510
|
children: /* @__PURE__ */ jsxs(View, {
|
|
2293
2511
|
ref: containerRef,
|
|
2294
2512
|
style: styles$1.container,
|
|
2513
|
+
onLayout: (event) => setContainerWidth(event.nativeEvent.layout.width),
|
|
2295
2514
|
children: [
|
|
2296
|
-
renderHeader ? renderHeader(headerDays) :
|
|
2297
|
-
days: headerDays,
|
|
2298
|
-
mode,
|
|
2299
|
-
width: containerWidth,
|
|
2300
|
-
hourColumnWidth,
|
|
2301
|
-
showWeekNumber,
|
|
2302
|
-
weekNumberPrefix,
|
|
2303
|
-
weekdayFormat,
|
|
2304
|
-
locale,
|
|
2305
|
-
activeDate,
|
|
2306
|
-
onPressDateHeader
|
|
2307
|
-
}),
|
|
2515
|
+
renderHeader ? renderHeader(headerDays) : null,
|
|
2308
2516
|
headerComponent,
|
|
2309
|
-
/* @__PURE__ */
|
|
2310
|
-
ref:
|
|
2311
|
-
style: styles$1.
|
|
2312
|
-
onLayout: (
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
pagerRef.current?.measureInWindow((x, y, w) => {
|
|
2317
|
-
pagerLeft.value = x;
|
|
2318
|
-
pagerTop.value = y;
|
|
2319
|
-
pagerWidth.value = w;
|
|
2517
|
+
/* @__PURE__ */ jsx(View, {
|
|
2518
|
+
ref: viewportRef,
|
|
2519
|
+
style: styles$1.viewport,
|
|
2520
|
+
onLayout: () => {
|
|
2521
|
+
seedWebScroll();
|
|
2522
|
+
viewportRef.current?.measureInWindow((_x, y) => {
|
|
2523
|
+
viewportTop.value = y;
|
|
2320
2524
|
});
|
|
2321
2525
|
},
|
|
2322
|
-
children:
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2526
|
+
children: /* @__PURE__ */ jsx(GestureDetector, {
|
|
2527
|
+
gesture: zoomGesture,
|
|
2528
|
+
children: /* @__PURE__ */ jsx(Animated.ScrollView, {
|
|
2529
|
+
ref: scrollRef,
|
|
2530
|
+
showsVerticalScrollIndicator: showVerticalScrollIndicator,
|
|
2531
|
+
scrollEnabled: verticalScrollEnabled,
|
|
2532
|
+
onScroll: scrollHandler,
|
|
2533
|
+
scrollEventThrottle: 16,
|
|
2534
|
+
refreshControl: verticalScrollEnabled ? refreshControl : void 0,
|
|
2535
|
+
contentOffset: {
|
|
2536
|
+
x: 0,
|
|
2537
|
+
y: seedDefaultY
|
|
2538
|
+
},
|
|
2539
|
+
children: /* @__PURE__ */ jsxs(Animated.View, {
|
|
2540
|
+
testID: "time-grid-hours",
|
|
2541
|
+
style: [styles$1.gridRow, gridHeightStyle],
|
|
2542
|
+
children: [hourColumnWidth > 0 ? /* @__PURE__ */ jsx(HourGutter, {
|
|
2543
|
+
width: hourColumnWidth,
|
|
2544
|
+
minHour: clampedMinHour,
|
|
2545
|
+
maxHour: clampedMaxHour,
|
|
2546
|
+
cellHeight,
|
|
2547
|
+
laneHeight,
|
|
2548
|
+
scrollY,
|
|
2549
|
+
showLane: showAllDayEventCell,
|
|
2550
|
+
showAllDayLabel,
|
|
2551
|
+
headerHeight: headerOffset,
|
|
2552
|
+
weekNumber,
|
|
2553
|
+
ampm,
|
|
2554
|
+
hourComponent
|
|
2555
|
+
}) : null, /* @__PURE__ */ jsxs(View, {
|
|
2556
|
+
ref: pagerRef,
|
|
2557
|
+
testID: "time-grid-pager",
|
|
2558
|
+
style: [styles$1.pager, {
|
|
2559
|
+
left: hourColumnWidth,
|
|
2560
|
+
height: pagerHeight
|
|
2561
|
+
}],
|
|
2562
|
+
onLayout: (event) => {
|
|
2563
|
+
const laidOutWidth = event.nativeEvent.layout.width;
|
|
2564
|
+
if (laidOutWidth === pagerLayoutWidthRef.current) return;
|
|
2565
|
+
pagerLayoutWidthRef.current = laidOutWidth;
|
|
2566
|
+
setPagerLayoutWidth(laidOutWidth);
|
|
2567
|
+
pagerRef.current?.measureInWindow((x, _y, measuredWidth) => {
|
|
2568
|
+
pagerLeft.value = x;
|
|
2569
|
+
pagerWidth.value = measuredWidth;
|
|
2570
|
+
});
|
|
2571
|
+
},
|
|
2572
|
+
children: [pagerReady ? /* @__PURE__ */ jsx(AnimatedLegendList, {
|
|
2573
|
+
ref: listRef,
|
|
2574
|
+
style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
|
|
2575
|
+
data: pageDates,
|
|
2576
|
+
extraData: listExtraData,
|
|
2577
|
+
horizontal: true,
|
|
2578
|
+
recycleItems: false,
|
|
2579
|
+
keyExtractor: keyExtractorList,
|
|
2580
|
+
getFixedItemSize,
|
|
2581
|
+
drawDistance: columnsWidth * 2,
|
|
2582
|
+
sharedValues: pagerSharedValues,
|
|
2583
|
+
...isWeb$1 ? null : {
|
|
2584
|
+
scrollEnabled: swipeEnabled,
|
|
2585
|
+
pagingEnabled: !freeSwipe,
|
|
2586
|
+
snapToIndices: freeSwipe ? snapToIndices : void 0,
|
|
2587
|
+
decelerationRate: freeSwipe ? "normal" : "fast",
|
|
2588
|
+
disableIntervalMomentum: !freeSwipe,
|
|
2589
|
+
scrollEventThrottle: 16,
|
|
2590
|
+
onMomentumScrollEnd: handlePagerSettled
|
|
2591
|
+
},
|
|
2592
|
+
initialScrollIndex: activeIndex,
|
|
2593
|
+
showsHorizontalScrollIndicator: false,
|
|
2594
|
+
viewabilityConfig: PAGE_VIEWABILITY,
|
|
2595
|
+
onViewableItemsChanged: handleViewableItemsChanged,
|
|
2596
|
+
renderItem
|
|
2597
|
+
}, `grid-${columnsWidth}`) : null, liftedEvent ? /* @__PURE__ */ jsx(DragGhost, {
|
|
2598
|
+
x: ghostX,
|
|
2599
|
+
y: ghostY,
|
|
2600
|
+
w: ghostW,
|
|
2601
|
+
h: ghostH,
|
|
2602
|
+
visible: ghostVisible,
|
|
2603
|
+
event: liftedEvent,
|
|
2604
|
+
mode,
|
|
2605
|
+
renderEvent: labeledRenderEvent,
|
|
2606
|
+
eventGap
|
|
2607
|
+
}) : null]
|
|
2608
|
+
})]
|
|
2609
|
+
})
|
|
2610
|
+
})
|
|
2611
|
+
})
|
|
2351
2612
|
})
|
|
2352
2613
|
]
|
|
2353
2614
|
})
|
|
@@ -2374,23 +2635,10 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2374
2635
|
* ```
|
|
2375
2636
|
*/
|
|
2376
2637
|
const TimeGrid = memo(TimeGridInner);
|
|
2377
|
-
const
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
return /* @__PURE__ */ jsxs(View, {
|
|
2382
|
-
...slot("header", {
|
|
2383
|
-
base: styles$1.headerRow,
|
|
2384
|
-
themed: { borderBottomColor: theme.colors.gridLine }
|
|
2385
|
-
}),
|
|
2386
|
-
children: [/* @__PURE__ */ jsx(View, {
|
|
2387
|
-
style: [styles$1.weekNumberGutter, { width: hourColumnWidth }],
|
|
2388
|
-
children: showWeekNumber && hourColumnWidth > 0 && days[0] ? /* @__PURE__ */ jsx(Text, {
|
|
2389
|
-
...slot("weekNumber", { themed: [theme.text.hourLabel, { color: theme.colors.textMuted }] }),
|
|
2390
|
-
allowFontScaling: false,
|
|
2391
|
-
children: `${weekNumberPrefix}${getISOWeek(days.find((d) => d.getDay() === 4) ?? days[0])}`
|
|
2392
|
-
}) : null
|
|
2393
|
-
}), days.map((day) => /* @__PURE__ */ jsx(DayHeader, {
|
|
2638
|
+
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, locale, activeDate, onPressDateHeader }) => {
|
|
2639
|
+
return /* @__PURE__ */ jsx(View, {
|
|
2640
|
+
...useSlots()("header", { base: styles$1.headerRow }),
|
|
2641
|
+
children: days.map((day) => /* @__PURE__ */ jsx(DayHeader, {
|
|
2394
2642
|
day,
|
|
2395
2643
|
mode,
|
|
2396
2644
|
width: dayWidth,
|
|
@@ -2398,7 +2646,7 @@ const DefaultHeader = ({ days, mode, width, hourColumnWidth, showWeekNumber, wee
|
|
|
2398
2646
|
locale,
|
|
2399
2647
|
activeDate,
|
|
2400
2648
|
onPressDateHeader
|
|
2401
|
-
}, day.toISOString()))
|
|
2649
|
+
}, day.toISOString()))
|
|
2402
2650
|
});
|
|
2403
2651
|
};
|
|
2404
2652
|
const DayHeader = ({ day, width, weekdayFormat = "short", locale, activeDate, onPressDateHeader }) => {
|
|
@@ -2442,17 +2690,58 @@ const DayHeader = ({ day, width, weekdayFormat = "short", locale, activeDate, on
|
|
|
2442
2690
|
});
|
|
2443
2691
|
};
|
|
2444
2692
|
const styles$1 = StyleSheet.create({
|
|
2445
|
-
pager: {
|
|
2693
|
+
pager: {
|
|
2694
|
+
position: "absolute",
|
|
2695
|
+
top: 0,
|
|
2696
|
+
right: 0
|
|
2697
|
+
},
|
|
2446
2698
|
pagerList: { flex: 1 },
|
|
2447
2699
|
container: { flex: 1 },
|
|
2700
|
+
viewport: { flex: 1 },
|
|
2701
|
+
gridRow: {
|
|
2702
|
+
position: "relative",
|
|
2703
|
+
overflow: "hidden"
|
|
2704
|
+
},
|
|
2705
|
+
hourGutter: {
|
|
2706
|
+
position: "absolute",
|
|
2707
|
+
top: 0,
|
|
2708
|
+
left: 0,
|
|
2709
|
+
bottom: 0
|
|
2710
|
+
},
|
|
2711
|
+
fill: {
|
|
2712
|
+
position: "absolute",
|
|
2713
|
+
top: 0,
|
|
2714
|
+
left: 0,
|
|
2715
|
+
right: 0,
|
|
2716
|
+
bottom: 0
|
|
2717
|
+
},
|
|
2718
|
+
hourCell: { flex: 1 },
|
|
2448
2719
|
headerRow: {
|
|
2720
|
+
flex: 1,
|
|
2721
|
+
flexDirection: "row",
|
|
2722
|
+
alignItems: "center"
|
|
2723
|
+
},
|
|
2724
|
+
pagedHeader: {
|
|
2725
|
+
position: "absolute",
|
|
2726
|
+
top: 0,
|
|
2727
|
+
left: 0,
|
|
2728
|
+
right: 0,
|
|
2729
|
+
height: DAY_HEADER_HEIGHT,
|
|
2730
|
+
zIndex: 2,
|
|
2449
2731
|
flexDirection: "row",
|
|
2450
2732
|
alignItems: "center",
|
|
2451
2733
|
borderBottomWidth: StyleSheet.hairlineWidth
|
|
2452
2734
|
},
|
|
2453
|
-
|
|
2735
|
+
gutterCorner: {
|
|
2736
|
+
position: "absolute",
|
|
2737
|
+
top: 0,
|
|
2738
|
+
left: 0,
|
|
2739
|
+
right: 0,
|
|
2740
|
+
zIndex: 2,
|
|
2454
2741
|
alignItems: "center",
|
|
2455
|
-
justifyContent: "flex-end"
|
|
2742
|
+
justifyContent: "flex-end",
|
|
2743
|
+
paddingBottom: 6,
|
|
2744
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
2456
2745
|
},
|
|
2457
2746
|
dayHeader: {
|
|
2458
2747
|
alignItems: "center",
|
|
@@ -2466,27 +2755,60 @@ const styles$1 = StyleSheet.create({
|
|
|
2466
2755
|
justifyContent: "center",
|
|
2467
2756
|
alignItems: "center"
|
|
2468
2757
|
},
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
position: "
|
|
2758
|
+
page: { position: "relative" },
|
|
2759
|
+
grid: {
|
|
2760
|
+
position: "absolute",
|
|
2761
|
+
left: 0,
|
|
2762
|
+
right: 0
|
|
2763
|
+
},
|
|
2764
|
+
laneBand: {
|
|
2765
|
+
position: "absolute",
|
|
2766
|
+
top: 0,
|
|
2767
|
+
left: 0,
|
|
2768
|
+
right: 0,
|
|
2769
|
+
overflow: "hidden",
|
|
2770
|
+
zIndex: 2
|
|
2771
|
+
},
|
|
2772
|
+
laneCell: {
|
|
2773
|
+
position: "absolute",
|
|
2774
|
+
top: 0,
|
|
2775
|
+
left: 0,
|
|
2776
|
+
right: 0,
|
|
2777
|
+
zIndex: 2,
|
|
2778
|
+
justifyContent: "center",
|
|
2779
|
+
overflow: "hidden",
|
|
2780
|
+
borderBottomWidth: StyleSheet.hairlineWidth
|
|
2781
|
+
},
|
|
2782
|
+
allDayLabel: {
|
|
2783
|
+
fontSize: 10,
|
|
2784
|
+
textAlign: "right",
|
|
2785
|
+
paddingRight: 6
|
|
2786
|
+
},
|
|
2787
|
+
gutterRows: {
|
|
2788
|
+
position: "absolute",
|
|
2789
|
+
left: 0,
|
|
2790
|
+
right: 0
|
|
2472
2791
|
},
|
|
2473
2792
|
cellPressLayer: {
|
|
2474
2793
|
position: "absolute",
|
|
2475
2794
|
top: 0,
|
|
2476
2795
|
bottom: 0,
|
|
2796
|
+
left: 0,
|
|
2477
2797
|
right: 0
|
|
2478
2798
|
},
|
|
2479
2799
|
createGhost: {
|
|
2480
2800
|
position: "absolute",
|
|
2481
2801
|
borderRadius: 6,
|
|
2482
|
-
borderWidth: StyleSheet.hairlineWidth
|
|
2483
|
-
marginHorizontal: EVENT_GAP
|
|
2802
|
+
borderWidth: StyleSheet.hairlineWidth
|
|
2484
2803
|
},
|
|
2485
2804
|
weekendColumn: {
|
|
2486
2805
|
position: "absolute",
|
|
2487
2806
|
top: 0
|
|
2488
2807
|
},
|
|
2489
|
-
shadeBand: {
|
|
2808
|
+
shadeBand: {
|
|
2809
|
+
position: "absolute",
|
|
2810
|
+
overflow: "hidden"
|
|
2811
|
+
},
|
|
2490
2812
|
daySeparator: {
|
|
2491
2813
|
position: "absolute",
|
|
2492
2814
|
top: 0,
|
|
@@ -2494,6 +2816,7 @@ const styles$1 = StyleSheet.create({
|
|
|
2494
2816
|
},
|
|
2495
2817
|
hourRow: {
|
|
2496
2818
|
position: "absolute",
|
|
2819
|
+
top: 0,
|
|
2497
2820
|
left: 0,
|
|
2498
2821
|
right: 0,
|
|
2499
2822
|
flexDirection: "row",
|
|
@@ -2505,11 +2828,16 @@ const styles$1 = StyleSheet.create({
|
|
|
2505
2828
|
paddingRight: 6
|
|
2506
2829
|
},
|
|
2507
2830
|
hourLine: {
|
|
2508
|
-
|
|
2831
|
+
position: "absolute",
|
|
2832
|
+
top: 0,
|
|
2833
|
+
left: 0,
|
|
2834
|
+
right: 0,
|
|
2509
2835
|
height: StyleSheet.hairlineWidth
|
|
2510
2836
|
},
|
|
2511
2837
|
timeslotLine: {
|
|
2512
2838
|
position: "absolute",
|
|
2839
|
+
top: 0,
|
|
2840
|
+
left: 0,
|
|
2513
2841
|
right: 0,
|
|
2514
2842
|
height: StyleSheet.hairlineWidth,
|
|
2515
2843
|
opacity: .5
|
|
@@ -2540,8 +2868,7 @@ const styles$1 = StyleSheet.create({
|
|
|
2540
2868
|
},
|
|
2541
2869
|
eventBox: {
|
|
2542
2870
|
position: "absolute",
|
|
2543
|
-
overflow: "hidden"
|
|
2544
|
-
padding: EVENT_GAP
|
|
2871
|
+
overflow: "hidden"
|
|
2545
2872
|
},
|
|
2546
2873
|
dragGhost: {
|
|
2547
2874
|
top: 0,
|
|
@@ -2553,6 +2880,7 @@ const styles$1 = StyleSheet.create({
|
|
|
2553
2880
|
height: 2
|
|
2554
2881
|
},
|
|
2555
2882
|
nonInteractive: { pointerEvents: "none" },
|
|
2883
|
+
passThrough: { pointerEvents: "box-none" },
|
|
2556
2884
|
webNoScroll: { overflow: "hidden" }
|
|
2557
2885
|
});
|
|
2558
2886
|
//#endregion
|
|
@@ -2598,7 +2926,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
2598
2926
|
* }
|
|
2599
2927
|
* ```
|
|
2600
2928
|
*/
|
|
2601
|
-
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
2929
|
+
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
2602
2930
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
2603
2931
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
2604
2932
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -2718,6 +3046,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2718
3046
|
}) : mode === "year" ? /* @__PURE__ */ jsx(YearView, {
|
|
2719
3047
|
date,
|
|
2720
3048
|
events: displayEvents,
|
|
3049
|
+
refreshControl,
|
|
2721
3050
|
weekStartsOn,
|
|
2722
3051
|
hiddenDays,
|
|
2723
3052
|
locale,
|
|
@@ -2743,6 +3072,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2743
3072
|
onPressDay,
|
|
2744
3073
|
activeDate,
|
|
2745
3074
|
itemSeparatorComponent,
|
|
3075
|
+
refreshControl,
|
|
2746
3076
|
classNames,
|
|
2747
3077
|
styles: styleOverrides
|
|
2748
3078
|
}) : /* @__PURE__ */ jsx(TimeGrid, {
|
|
@@ -2765,6 +3095,8 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2765
3095
|
hideHours,
|
|
2766
3096
|
timeslots,
|
|
2767
3097
|
showAllDayEventCell,
|
|
3098
|
+
showAllDayLabel,
|
|
3099
|
+
refreshControl,
|
|
2768
3100
|
highlightWeekends,
|
|
2769
3101
|
eventStartEditable,
|
|
2770
3102
|
eventDurationEditable,
|
|
@@ -2772,6 +3104,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2772
3104
|
calendarCellStyle,
|
|
2773
3105
|
businessHours,
|
|
2774
3106
|
renderBusinessHours,
|
|
3107
|
+
renderBackgroundEvent,
|
|
2775
3108
|
showWeekNumber,
|
|
2776
3109
|
weekNumberPrefix,
|
|
2777
3110
|
hourComponent,
|
|
@@ -2783,6 +3116,8 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
2783
3116
|
ampm,
|
|
2784
3117
|
minHourHeight,
|
|
2785
3118
|
maxHourHeight,
|
|
3119
|
+
minEventHeight,
|
|
3120
|
+
eventGap,
|
|
2786
3121
|
showNowIndicator,
|
|
2787
3122
|
locale,
|
|
2788
3123
|
activeDate,
|