@super-calendar/native 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DefaultMonthEvent-BSvuJUFk.d.ts → DefaultMonthEvent-DCPDsnvq.d.ts} +10 -6
- package/dist/{DefaultMonthEvent-zDj9dHEv.d.mts → DefaultMonthEvent-DMOC5aNL.d.mts} +10 -6
- package/dist/{MonthList-Aczb2RSY.js → MonthList-CJs1vq5T.js} +81 -12
- package/dist/{MonthList-zPLklHAY.mjs → MonthList-Dn37Ezj0.mjs} +83 -14
- package/dist/index.d.mts +130 -18
- package/dist/index.d.ts +130 -18
- package/dist/index.js +799 -121
- package/dist/index.mjs +778 -125
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Agenda.tsx +5 -2
- package/src/components/AllDayLane.tsx +3 -2
- package/src/components/Calendar.tsx +61 -2
- package/src/components/DefaultEvent.tsx +3 -1
- package/src/components/MonthPager.tsx +12 -3
- package/src/components/MonthView.tsx +95 -8
- package/src/components/ResourceTimeline.tsx +270 -29
- package/src/components/TimeGrid.tsx +656 -97
- package/src/components/YearView.tsx +286 -0
- package/src/index.tsx +11 -1
- package/src/types.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,176 @@
|
|
|
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-
|
|
2
|
-
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek } from "date-fns";
|
|
3
|
-
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
1
|
+
import { a as withEventAccessibilityLabel, c as createSlots, d as darkTheme, f as defaultTheme, i as MonthView, l as useSlots, m as useCalendarTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as mergeTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarThemeProvider } from "./MonthList-Dn37Ezj0.mjs";
|
|
2
|
+
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
|
+
import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Animated, { runOnJS, scrollTo, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
|
|
5
|
-
import { buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, minutesIntoDay, nextDateRange, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useMonthGrid, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
6
|
-
import { LegendList } from "@legendapp/list/react-native";
|
|
5
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, closedHourBands, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, minutesIntoDay, nextDateRange, pageStepDays, parseICalendar, resolveDraggedBounds, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
7
6
|
import { Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
8
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { LegendList } from "@legendapp/list/react-native";
|
|
9
9
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
10
|
+
//#region src/components/YearView.tsx
|
|
11
|
+
const FALLBACK_COLUMNS = 3;
|
|
12
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
13
|
+
const theme = useCalendarTheme();
|
|
14
|
+
const slot = createSlots({
|
|
15
|
+
classNames,
|
|
16
|
+
styles: styleOverrides
|
|
17
|
+
});
|
|
18
|
+
const [columns, setColumns] = useState(FALLBACK_COLUMNS);
|
|
19
|
+
const handleLayout = (event) => {
|
|
20
|
+
const width = event.nativeEvent.layout.width;
|
|
21
|
+
if (width <= 0) return;
|
|
22
|
+
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
23
|
+
};
|
|
24
|
+
const months = useMemo(() => getYearMonths(date), [date]);
|
|
25
|
+
const weekdayLabels = useMemo(() => filterHiddenDays(getWeekDays$1(date, weekStartsOn), hiddenDays).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
|
|
26
|
+
date,
|
|
27
|
+
weekStartsOn,
|
|
28
|
+
locale,
|
|
29
|
+
hiddenDays
|
|
30
|
+
]);
|
|
31
|
+
const eventDays = useMemo(() => new Set(events && events.length > 0 ? groupEventsByDay(events.filter((e) => !isBackgroundEvent$1(e))).keys() : []), [events]);
|
|
32
|
+
return /* @__PURE__ */ jsx(ScrollView, {
|
|
33
|
+
onLayout: handleLayout,
|
|
34
|
+
showsVerticalScrollIndicator: true,
|
|
35
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
36
|
+
...slot("grid", { base: styles$5.grid }),
|
|
37
|
+
children: months.map((month) => {
|
|
38
|
+
const weeks = buildMonthWeeks$1(month, weekStartsOn, { hiddenDays });
|
|
39
|
+
const title = format(month, "MMMM", { locale });
|
|
40
|
+
const monthLabel = format(month, "MMMM yyyy", { locale });
|
|
41
|
+
const titleText = /* @__PURE__ */ jsx(Text, {
|
|
42
|
+
...slot("monthTitle", {
|
|
43
|
+
base: styles$5.monthTitle,
|
|
44
|
+
themed: [styles$5.monthTitleText, { color: theme.colors.todayBackground }]
|
|
45
|
+
}),
|
|
46
|
+
allowFontScaling: false,
|
|
47
|
+
children: title
|
|
48
|
+
});
|
|
49
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
50
|
+
...slot("month", { base: [styles$5.month, { width: `${100 / columns}%` }] }),
|
|
51
|
+
children: [
|
|
52
|
+
onPressMonth ? /* @__PURE__ */ jsx(Pressable, {
|
|
53
|
+
onPress: () => onPressMonth(month),
|
|
54
|
+
accessibilityRole: "button",
|
|
55
|
+
accessibilityLabel: monthLabel,
|
|
56
|
+
children: titleText
|
|
57
|
+
}) : /* @__PURE__ */ jsx(View, {
|
|
58
|
+
accessible: true,
|
|
59
|
+
accessibilityRole: "header",
|
|
60
|
+
accessibilityLabel: monthLabel,
|
|
61
|
+
children: titleText
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ jsx(View, {
|
|
64
|
+
...slot("weekdays", { base: styles$5.weekdays }),
|
|
65
|
+
accessibilityElementsHidden: true,
|
|
66
|
+
importantForAccessibility: "no-hide-descendants",
|
|
67
|
+
children: weekdayLabels.map((label, i) => /* @__PURE__ */ jsx(Text, {
|
|
68
|
+
...slot("weekday", {
|
|
69
|
+
base: styles$5.weekday,
|
|
70
|
+
themed: [styles$5.weekdayText, { color: theme.colors.textMuted }]
|
|
71
|
+
}),
|
|
72
|
+
allowFontScaling: false,
|
|
73
|
+
children: label
|
|
74
|
+
}, i))
|
|
75
|
+
}),
|
|
76
|
+
weeks.map((week) => /* @__PURE__ */ jsx(View, {
|
|
77
|
+
...slot("week", { base: styles$5.week }),
|
|
78
|
+
children: week.map((day) => {
|
|
79
|
+
if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ jsx(View, { style: styles$5.day }, day.toISOString());
|
|
80
|
+
const isHighlighted = activeDate ? isSameCalendarDay$1(day, activeDate) : getIsToday$1(day);
|
|
81
|
+
const hasEvents = eventDays.has(startOfDay(day).toISOString());
|
|
82
|
+
const label = `${format(day, "EEEE, d LLLL yyyy", { locale })}${getIsToday$1(day) ? ", today" : ""}${hasEvents ? ", has events" : ""}`;
|
|
83
|
+
const daySlot = slot("day", {
|
|
84
|
+
base: styles$5.day,
|
|
85
|
+
themed: isHighlighted ? {
|
|
86
|
+
backgroundColor: theme.colors.todayBackground,
|
|
87
|
+
borderRadius: theme.todayBadgeRadius
|
|
88
|
+
} : void 0
|
|
89
|
+
});
|
|
90
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
|
|
91
|
+
...slot("dayText", { themed: [styles$5.dayText, { color: isHighlighted ? theme.colors.todayText : theme.colors.text }] }),
|
|
92
|
+
allowFontScaling: false,
|
|
93
|
+
children: day.getDate()
|
|
94
|
+
}), hasEvents ? /* @__PURE__ */ jsx(View, { ...slot("eventDot", {
|
|
95
|
+
base: styles$5.eventDot,
|
|
96
|
+
themed: { backgroundColor: isHighlighted ? theme.colors.todayText : theme.colors.todayBackground }
|
|
97
|
+
}) }) : null] });
|
|
98
|
+
return onPressDay ? /* @__PURE__ */ jsx(Pressable, {
|
|
99
|
+
onPress: () => onPressDay(day),
|
|
100
|
+
accessibilityRole: "button",
|
|
101
|
+
accessibilityLabel: label,
|
|
102
|
+
...daySlot,
|
|
103
|
+
children: content
|
|
104
|
+
}, day.toISOString()) : /* @__PURE__ */ jsx(View, {
|
|
105
|
+
accessible: true,
|
|
106
|
+
accessibilityLabel: label,
|
|
107
|
+
...daySlot,
|
|
108
|
+
children: content
|
|
109
|
+
}, day.toISOString());
|
|
110
|
+
})
|
|
111
|
+
}, week[0].toISOString()))
|
|
112
|
+
]
|
|
113
|
+
}, month.toISOString());
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A year at a glance: the twelve months as compact mini grids, with today
|
|
120
|
+
* highlighted and a dot under days that hold events. Tap a day or a month
|
|
121
|
+
* title to drill into a denser view. It's the view `Calendar` renders for
|
|
122
|
+
* `mode="year"`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* import { YearView } from "@super-calendar/native";
|
|
127
|
+
*
|
|
128
|
+
* <YearView
|
|
129
|
+
* date={new Date()}
|
|
130
|
+
* events={events}
|
|
131
|
+
* weekStartsOn={1}
|
|
132
|
+
* onPressDay={(day) => console.log(day)}
|
|
133
|
+
* />
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
const YearView = memo(YearViewInner);
|
|
137
|
+
const styles$5 = StyleSheet.create({
|
|
138
|
+
grid: {
|
|
139
|
+
flexDirection: "row",
|
|
140
|
+
flexWrap: "wrap"
|
|
141
|
+
},
|
|
142
|
+
month: { padding: 8 },
|
|
143
|
+
monthTitle: { paddingBottom: 4 },
|
|
144
|
+
monthTitleText: {
|
|
145
|
+
fontSize: 13,
|
|
146
|
+
fontWeight: "700"
|
|
147
|
+
},
|
|
148
|
+
weekdays: { flexDirection: "row" },
|
|
149
|
+
weekday: {
|
|
150
|
+
flex: 1,
|
|
151
|
+
textAlign: "center"
|
|
152
|
+
},
|
|
153
|
+
weekdayText: {
|
|
154
|
+
fontSize: 9,
|
|
155
|
+
fontWeight: "600"
|
|
156
|
+
},
|
|
157
|
+
week: { flexDirection: "row" },
|
|
158
|
+
day: {
|
|
159
|
+
flex: 1,
|
|
160
|
+
aspectRatio: 1,
|
|
161
|
+
alignItems: "center",
|
|
162
|
+
justifyContent: "center"
|
|
163
|
+
},
|
|
164
|
+
dayText: { fontSize: 11 },
|
|
165
|
+
eventDot: {
|
|
166
|
+
position: "absolute",
|
|
167
|
+
bottom: 1,
|
|
168
|
+
width: 3,
|
|
169
|
+
height: 3,
|
|
170
|
+
borderRadius: 2
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
//#endregion
|
|
10
174
|
//#region src/components/Agenda.tsx
|
|
11
175
|
/**
|
|
12
176
|
* A vertical, day-grouped list of events (no time grid). Events are sorted by
|
|
@@ -21,7 +185,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
21
185
|
}), [classNames, styleOverrides]);
|
|
22
186
|
const RenderEventComponent = renderEvent;
|
|
23
187
|
const rows = useMemo(() => {
|
|
24
|
-
const sorted =
|
|
188
|
+
const sorted = events.filter((event) => !isBackgroundEvent$1(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
25
189
|
const out = [];
|
|
26
190
|
let currentDay = null;
|
|
27
191
|
sorted.forEach((event, index) => {
|
|
@@ -188,7 +352,7 @@ function DefaultEvent({ event, mode, boxHeight, isAllDay, ampm = false, showTime
|
|
|
188
352
|
],
|
|
189
353
|
onPress,
|
|
190
354
|
onLongPress,
|
|
191
|
-
activeOpacity:
|
|
355
|
+
activeOpacity: 1,
|
|
192
356
|
accessibilityRole: "button",
|
|
193
357
|
accessibilityLabel,
|
|
194
358
|
accessibilityState: { disabled: event.disabled ?? false },
|
|
@@ -318,7 +482,7 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
|
|
|
318
482
|
const theme = useCalendarTheme();
|
|
319
483
|
const slot = useSlots();
|
|
320
484
|
const RenderEventComponent = renderEvent;
|
|
321
|
-
const allDay = events.filter(isAllDayEvent$1);
|
|
485
|
+
const allDay = events.filter((event) => isAllDayEvent$1(event) && !isBackgroundEvent$1(event));
|
|
322
486
|
const perDay = days.map((day) => {
|
|
323
487
|
const start = startOfDay(day);
|
|
324
488
|
const next = addDays(start, 1);
|
|
@@ -396,34 +560,72 @@ const MOVE_ACTIVATE_MS$1 = 500;
|
|
|
396
560
|
const DRAG_ACTIVATE_PX$1 = 8;
|
|
397
561
|
const RESIZE_HANDLE_HEIGHT = 14;
|
|
398
562
|
const DEFAULT_DRAG_STEP_MINUTES = 15;
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
563
|
+
const DRAG_EVENT_Z = 100;
|
|
564
|
+
const EDGE_DWELL_MS = 500;
|
|
565
|
+
const EDGE_ZONE_PX = 36;
|
|
566
|
+
const EdgePagingContext = createContext(null);
|
|
567
|
+
const noop = () => {};
|
|
568
|
+
/**
|
|
569
|
+
* The floating copy of a dragged event, rendered above the pager so a cross-week
|
|
570
|
+
* drag stays visible after its source page pages away. Position, size, and
|
|
571
|
+
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
572
|
+
* finger without a React re-render.
|
|
573
|
+
*/
|
|
574
|
+
function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
575
|
+
const RenderEventComponent = renderEvent;
|
|
576
|
+
const style = useAnimatedStyle(() => ({
|
|
577
|
+
transform: [{ translateX: x.value }, { translateY: y.value }],
|
|
578
|
+
width: w.value,
|
|
579
|
+
height: h.value,
|
|
580
|
+
opacity: visible.value
|
|
581
|
+
}));
|
|
582
|
+
return /* @__PURE__ */ jsx(Animated.View, {
|
|
583
|
+
style: [
|
|
584
|
+
styles$1.eventBox,
|
|
585
|
+
styles$1.dragGhost,
|
|
586
|
+
style
|
|
587
|
+
],
|
|
588
|
+
pointerEvents: "none",
|
|
589
|
+
children: /* @__PURE__ */ jsx(RenderEventComponent, {
|
|
590
|
+
event,
|
|
591
|
+
mode,
|
|
592
|
+
boxHeight: h,
|
|
593
|
+
onPress: noop
|
|
594
|
+
})
|
|
595
|
+
});
|
|
410
596
|
}
|
|
411
|
-
|
|
597
|
+
const HOUR_LABEL_TOP_INSET = 12;
|
|
598
|
+
function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle }) {
|
|
412
599
|
const RenderEventComponent = renderEvent;
|
|
413
600
|
const theme = useCalendarTheme();
|
|
414
601
|
const slot = useSlots();
|
|
415
|
-
const
|
|
602
|
+
const edgePaging = useContext(EdgePagingContext);
|
|
603
|
+
const pagerLeftSV = edgePaging?.pagerLeft;
|
|
604
|
+
const pagerTopSV = edgePaging?.pagerTop;
|
|
605
|
+
const pagerWidthSV = edgePaging?.pagerWidth;
|
|
606
|
+
const ghostXSV = edgePaging?.ghostX;
|
|
607
|
+
const ghostYSV = edgePaging?.ghostY;
|
|
608
|
+
const commitLiftedDrop = edgePaging?.commitLiftedDrop;
|
|
609
|
+
const draggable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
|
|
416
610
|
const resizable = draggable && !positioned.continuesAfter;
|
|
417
611
|
const moveOffset = useSharedValue(0);
|
|
418
612
|
const moveOffsetX = useSharedValue(0);
|
|
419
613
|
const resizeDelta = useSharedValue(0);
|
|
614
|
+
const dragZ = useSharedValue(0);
|
|
615
|
+
const edgeDir = useSharedValue(0);
|
|
616
|
+
const lifted = useSharedValue(0);
|
|
617
|
+
const grabX = useSharedValue(0);
|
|
618
|
+
const grabY = useSharedValue(0);
|
|
619
|
+
const liveAbsX = useSharedValue(0);
|
|
620
|
+
const liveAbsY = useSharedValue(0);
|
|
420
621
|
const startHours = positioned.startHours;
|
|
421
622
|
const durationHours = positioned.durationHours;
|
|
422
623
|
const boxHeight = useDerivedValue(() => Math.max(durationHours * cellHeight.value + resizeDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
|
|
423
624
|
const boxStyle = useAnimatedStyle(() => ({
|
|
424
625
|
top: (startHours - minHour) * cellHeight.value + moveOffset.value,
|
|
425
626
|
height: boxHeight.value,
|
|
426
|
-
transform: [{ translateX: moveOffsetX.value }]
|
|
627
|
+
transform: [{ translateX: moveOffsetX.value }],
|
|
628
|
+
zIndex: dragZ.value
|
|
427
629
|
}), [
|
|
428
630
|
startHours,
|
|
429
631
|
durationHours,
|
|
@@ -472,16 +674,81 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
472
674
|
const notifyDragStart = useCallback(() => {
|
|
473
675
|
latest.current.onDragStart?.(latest.current.event);
|
|
474
676
|
}, []);
|
|
677
|
+
const dwellTimer = useRef(null);
|
|
678
|
+
const disarmEdge = useCallback(() => {
|
|
679
|
+
if (dwellTimer.current) {
|
|
680
|
+
clearTimeout(dwellTimer.current);
|
|
681
|
+
dwellTimer.current = null;
|
|
682
|
+
}
|
|
683
|
+
}, []);
|
|
684
|
+
const releaseEdge = useCallback(() => {
|
|
685
|
+
disarmEdge();
|
|
686
|
+
edgePaging?.lockScroll(false);
|
|
687
|
+
}, [disarmEdge, edgePaging]);
|
|
688
|
+
const armEdge = useCallback((dir) => {
|
|
689
|
+
disarmEdge();
|
|
690
|
+
dwellTimer.current = setTimeout(() => {
|
|
691
|
+
dwellTimer.current = null;
|
|
692
|
+
if (!edgePaging) return;
|
|
693
|
+
edgePaging.lockScroll(true);
|
|
694
|
+
if (!lifted.value) {
|
|
695
|
+
lifted.value = 1;
|
|
696
|
+
edgePaging.ghostW.value = width;
|
|
697
|
+
edgePaging.ghostH.value = boxHeight.value;
|
|
698
|
+
edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
|
|
699
|
+
edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
|
|
700
|
+
edgePaging.ghostVisible.value = 1;
|
|
701
|
+
edgePaging.beginLift(latest.current.event);
|
|
702
|
+
}
|
|
703
|
+
onEdgeAdvance?.(dir);
|
|
704
|
+
}, EDGE_DWELL_MS);
|
|
705
|
+
}, [
|
|
706
|
+
disarmEdge,
|
|
707
|
+
edgePaging,
|
|
708
|
+
lifted,
|
|
709
|
+
width,
|
|
710
|
+
boxHeight,
|
|
711
|
+
liveAbsX,
|
|
712
|
+
liveAbsY,
|
|
713
|
+
grabX,
|
|
714
|
+
grabY,
|
|
715
|
+
onEdgeAdvance
|
|
716
|
+
]);
|
|
475
717
|
const moveGesture = useMemo(() => {
|
|
476
|
-
const pan = Gesture.Pan().enabled(draggable).onStart(() => {
|
|
718
|
+
const pan = Gesture.Pan().enabled(draggable).onStart((event) => {
|
|
719
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
720
|
+
edgeDir.value = 0;
|
|
721
|
+
lifted.value = 0;
|
|
722
|
+
grabX.value = event.x;
|
|
723
|
+
grabY.value = event.y;
|
|
724
|
+
liveAbsX.value = event.absoluteX;
|
|
725
|
+
liveAbsY.value = event.absoluteY;
|
|
477
726
|
runOnJS(notifyDragStart)();
|
|
478
727
|
}).onUpdate((event) => {
|
|
479
|
-
|
|
480
|
-
|
|
728
|
+
liveAbsX.value = event.absoluteX;
|
|
729
|
+
liveAbsY.value = event.absoluteY;
|
|
730
|
+
if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
|
|
731
|
+
ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
|
|
732
|
+
ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
|
|
733
|
+
} else {
|
|
734
|
+
moveOffset.value = event.translationY;
|
|
735
|
+
moveOffsetX.value = event.translationX;
|
|
736
|
+
}
|
|
737
|
+
if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
|
|
738
|
+
const fx = event.absoluteX - pagerLeftSV.value;
|
|
739
|
+
const dir = fx > pagerWidthSV.value - EDGE_ZONE_PX ? 1 : fx < EDGE_ZONE_PX ? -1 : 0;
|
|
740
|
+
if (dir !== edgeDir.value) {
|
|
741
|
+
edgeDir.value = dir;
|
|
742
|
+
if (dir === 0) runOnJS(disarmEdge)();
|
|
743
|
+
else runOnJS(armEdge)(dir);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
481
746
|
}).onEnd((event) => {
|
|
747
|
+
if (lifted.value) return;
|
|
482
748
|
const minuteDelta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
483
749
|
const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
|
|
484
|
-
const
|
|
750
|
+
const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
|
|
751
|
+
const dayDelta = targetDay - dayIndex;
|
|
485
752
|
if (minuteDelta === 0 && dayDelta === 0) {
|
|
486
753
|
moveOffset.value = 0;
|
|
487
754
|
moveOffsetX.value = 0;
|
|
@@ -489,8 +756,17 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
489
756
|
}
|
|
490
757
|
moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
491
758
|
moveOffsetX.value = dayDelta * dayWidth;
|
|
492
|
-
const totalDelta = minuteDelta +
|
|
759
|
+
const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
493
760
|
runOnJS(commitDrag)(totalDelta, totalDelta);
|
|
761
|
+
}).onFinalize(() => {
|
|
762
|
+
dragZ.value = 0;
|
|
763
|
+
if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
|
|
764
|
+
runOnJS(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
|
|
765
|
+
moveOffset.value = 0;
|
|
766
|
+
moveOffsetX.value = 0;
|
|
767
|
+
lifted.value = 0;
|
|
768
|
+
}
|
|
769
|
+
runOnJS(releaseEdge)();
|
|
494
770
|
});
|
|
495
771
|
return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
|
|
496
772
|
}, [
|
|
@@ -499,13 +775,32 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
499
775
|
cellHeight,
|
|
500
776
|
moveOffset,
|
|
501
777
|
moveOffsetX,
|
|
778
|
+
dragZ,
|
|
779
|
+
edgeDir,
|
|
780
|
+
lifted,
|
|
781
|
+
grabX,
|
|
782
|
+
grabY,
|
|
783
|
+
liveAbsX,
|
|
784
|
+
liveAbsY,
|
|
785
|
+
pagerLeftSV,
|
|
786
|
+
pagerTopSV,
|
|
787
|
+
pagerWidthSV,
|
|
788
|
+
ghostXSV,
|
|
789
|
+
ghostYSV,
|
|
790
|
+
commitLiftedDrop,
|
|
502
791
|
dayWidth,
|
|
503
792
|
dayIndex,
|
|
504
793
|
dayCount,
|
|
794
|
+
dayOrdinals,
|
|
505
795
|
commitDrag,
|
|
506
|
-
notifyDragStart
|
|
796
|
+
notifyDragStart,
|
|
797
|
+
onEdgeAdvance,
|
|
798
|
+
armEdge,
|
|
799
|
+
disarmEdge,
|
|
800
|
+
releaseEdge
|
|
507
801
|
]);
|
|
508
802
|
const resizeGesture = useMemo(() => Gesture.Pan().enabled(resizable).onStart(() => {
|
|
803
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
509
804
|
runOnJS(notifyDragStart)();
|
|
510
805
|
}).onUpdate((event) => {
|
|
511
806
|
resizeDelta.value = event.translationY;
|
|
@@ -517,17 +812,21 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
517
812
|
}
|
|
518
813
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
519
814
|
runOnJS(commitDrag)(0, delta);
|
|
815
|
+
}).onFinalize(() => {
|
|
816
|
+
dragZ.value = 0;
|
|
520
817
|
}), [
|
|
521
818
|
resizable,
|
|
522
819
|
snapMinutes,
|
|
523
820
|
cellHeight,
|
|
524
821
|
resizeDelta,
|
|
822
|
+
dragZ,
|
|
525
823
|
commitDrag,
|
|
526
824
|
notifyDragStart
|
|
527
825
|
]);
|
|
528
826
|
const handlePress = () => onPress(positioned.event);
|
|
529
827
|
const handleLongPress = !draggable && onLongPress ? () => onLongPress(positioned.event) : void 0;
|
|
530
828
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
829
|
+
const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
|
|
531
830
|
const accessibilityActions = draggable ? [
|
|
532
831
|
{
|
|
533
832
|
name: "move-later",
|
|
@@ -543,7 +842,15 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
543
842
|
}, {
|
|
544
843
|
name: "shrink",
|
|
545
844
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
546
|
-
}] : []
|
|
845
|
+
}] : [],
|
|
846
|
+
{
|
|
847
|
+
name: "move-next-page",
|
|
848
|
+
label: `Move to next ${pageUnit}`
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
name: "move-previous-page",
|
|
852
|
+
label: `Move to previous ${pageUnit}`
|
|
853
|
+
}
|
|
547
854
|
] : void 0;
|
|
548
855
|
const handleAccessibilityAction = draggable ? (e) => {
|
|
549
856
|
switch (e.nativeEvent.actionName) {
|
|
@@ -559,6 +866,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
559
866
|
case "shrink":
|
|
560
867
|
commitDrag(0, -snapMinutes);
|
|
561
868
|
break;
|
|
869
|
+
case "move-next-page":
|
|
870
|
+
commitDrag(daysPerPage * MINUTES_PER_DAY, daysPerPage * MINUTES_PER_DAY);
|
|
871
|
+
break;
|
|
872
|
+
case "move-previous-page":
|
|
873
|
+
commitDrag(-daysPerPage * MINUTES_PER_DAY, -daysPerPage * MINUTES_PER_DAY);
|
|
874
|
+
break;
|
|
562
875
|
}
|
|
563
876
|
} : void 0;
|
|
564
877
|
const eventSlot = slot("event", {
|
|
@@ -662,7 +975,7 @@ const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) =>
|
|
|
662
975
|
style: [lineSlot.style, animatedStyle]
|
|
663
976
|
});
|
|
664
977
|
};
|
|
665
|
-
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color }) => {
|
|
978
|
+
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", children }) => {
|
|
666
979
|
const slot = useSlots();
|
|
667
980
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
668
981
|
top: (startHour - minHour) * cellHeight.value,
|
|
@@ -672,7 +985,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
672
985
|
endHour,
|
|
673
986
|
minHour
|
|
674
987
|
]);
|
|
675
|
-
const bandSlot = slot(
|
|
988
|
+
const bandSlot = slot(slotName, {
|
|
676
989
|
base: [
|
|
677
990
|
styles$1.shadeBand,
|
|
678
991
|
styles$1.nonInteractive,
|
|
@@ -681,18 +994,25 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
681
994
|
width
|
|
682
995
|
}
|
|
683
996
|
],
|
|
684
|
-
themed: { backgroundColor: color }
|
|
997
|
+
themed: color === void 0 ? void 0 : { backgroundColor: color }
|
|
685
998
|
});
|
|
686
999
|
return /* @__PURE__ */ jsx(Animated.View, {
|
|
687
|
-
testID
|
|
1000
|
+
testID,
|
|
1001
|
+
accessibilityElementsHidden: true,
|
|
1002
|
+
importantForAccessibility: "no-hide-descendants",
|
|
688
1003
|
...bandSlot,
|
|
689
|
-
style: [bandSlot.style, animatedStyle]
|
|
1004
|
+
style: [bandSlot.style, animatedStyle],
|
|
1005
|
+
children
|
|
690
1006
|
});
|
|
691
1007
|
};
|
|
692
|
-
function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent }) {
|
|
1008
|
+
function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowTimeZone, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, highlightWeekends, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderBusinessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, onGridTop }) {
|
|
693
1009
|
const theme = useCalendarTheme();
|
|
694
1010
|
const slot = useSlots();
|
|
695
1011
|
const scrollRef = useAnimatedRef();
|
|
1012
|
+
const gridTopRef = useRef(0);
|
|
1013
|
+
useEffect(() => {
|
|
1014
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1015
|
+
}, [isActive, onGridTop]);
|
|
696
1016
|
const heightSource = isActive ? cellHeight : committedCellHeight;
|
|
697
1017
|
const isDragging = useSharedValue(false);
|
|
698
1018
|
const isActiveShared = useSharedValue(isActive);
|
|
@@ -728,17 +1048,20 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
728
1048
|
if (isWeb$1 || !active || active === previous) return;
|
|
729
1049
|
scrollTo(scrollRef, 0, scrollY.value, false);
|
|
730
1050
|
});
|
|
731
|
-
const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1051
|
+
const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
732
1052
|
mode,
|
|
733
1053
|
date,
|
|
734
1054
|
weekStartsOn,
|
|
735
1055
|
numberOfDays,
|
|
736
1056
|
isRTL,
|
|
737
|
-
weekEndsOn
|
|
1057
|
+
weekEndsOn,
|
|
1058
|
+
hiddenDays
|
|
738
1059
|
]);
|
|
1060
|
+
const daysPerPage = pageStepDays(mode, date, weekStartsOn, numberOfDays);
|
|
739
1061
|
const dayCount = days.length;
|
|
740
1062
|
const dayWidth = (width - hourColumnWidth) / dayCount;
|
|
741
1063
|
const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
|
|
1064
|
+
const dayOrdinals = useMemo(() => days.map((day) => differenceInCalendarDays(day, days[0])), [days]);
|
|
742
1065
|
const dayLayouts = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
|
|
743
1066
|
const cellDateFromTouch = (event) => {
|
|
744
1067
|
const { locationX, locationY } = event.nativeEvent;
|
|
@@ -760,8 +1083,11 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
760
1083
|
if (date) onLongPressCell?.(date);
|
|
761
1084
|
};
|
|
762
1085
|
const hoursRange = useMemo(() => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index), [minHour, maxHour]);
|
|
763
|
-
const now = useNow(showNowIndicator && isActive
|
|
764
|
-
|
|
1086
|
+
const now = useNow$1(showNowIndicator && isActive, {
|
|
1087
|
+
now: nowProp,
|
|
1088
|
+
timeZone: nowTimeZone
|
|
1089
|
+
});
|
|
1090
|
+
const nowDayIndex = days.findIndex((day) => isSameCalendarDay$1(day, now));
|
|
765
1091
|
const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
|
|
766
1092
|
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
767
1093
|
const fullHeightStyle = useAnimatedStyle(() => ({ height: (maxHour - minHour) * heightSource.value }), [
|
|
@@ -939,6 +1265,10 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
939
1265
|
scrollEnabled: verticalScrollEnabled,
|
|
940
1266
|
onScroll: scrollHandler,
|
|
941
1267
|
scrollEventThrottle: 16,
|
|
1268
|
+
onLayout: (event) => {
|
|
1269
|
+
gridTopRef.current = event.nativeEvent.layout.y;
|
|
1270
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1271
|
+
},
|
|
942
1272
|
contentContainerStyle: { paddingTop: HOUR_LABEL_TOP_INSET },
|
|
943
1273
|
contentOffset: {
|
|
944
1274
|
x: 0,
|
|
@@ -952,7 +1282,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
952
1282
|
children: cellLayer
|
|
953
1283
|
}) : cellLayer,
|
|
954
1284
|
days.map((day, dayIndex) => {
|
|
955
|
-
if (!isWeekend$1(day)) return null;
|
|
1285
|
+
if (!highlightWeekends || !isWeekend$1(day)) return null;
|
|
956
1286
|
const shadeSlot = slot("weekendShade", {
|
|
957
1287
|
base: [
|
|
958
1288
|
styles$1.weekendColumn,
|
|
@@ -965,6 +1295,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
965
1295
|
themed: { backgroundColor: theme.colors.weekendBackground }
|
|
966
1296
|
});
|
|
967
1297
|
return /* @__PURE__ */ jsx(Animated.View, {
|
|
1298
|
+
testID: "weekend-shade",
|
|
968
1299
|
...shadeSlot,
|
|
969
1300
|
style: [shadeSlot.style, fullHeightStyle]
|
|
970
1301
|
}, `weekend-${day.toISOString()}`);
|
|
@@ -989,8 +1320,28 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
989
1320
|
minHour,
|
|
990
1321
|
left: dayLeft(dayIndex),
|
|
991
1322
|
width: dayWidth,
|
|
992
|
-
color: theme.colors.outsideHoursBackground
|
|
1323
|
+
color: renderBusinessHours ? void 0 : theme.colors.outsideHoursBackground,
|
|
1324
|
+
children: renderBusinessHours?.({
|
|
1325
|
+
date: day,
|
|
1326
|
+
start: band.start,
|
|
1327
|
+
end: band.end
|
|
1328
|
+
})
|
|
993
1329
|
}, `closed-${day.toISOString()}-${bandIndex}`))) : null,
|
|
1330
|
+
days.flatMap((day, dayIndex) => backgroundBandsForDay$1(events, day).map((b) => ({
|
|
1331
|
+
...b,
|
|
1332
|
+
startHours: Math.max(b.startHours, minHour),
|
|
1333
|
+
endHours: Math.min(b.endHours, maxHour)
|
|
1334
|
+
})).filter((b) => b.endHours > b.startHours).map((b, bandIndex) => /* @__PURE__ */ jsx(ShadeBand, {
|
|
1335
|
+
cellHeight: heightSource,
|
|
1336
|
+
startHour: b.startHours,
|
|
1337
|
+
endHour: b.endHours,
|
|
1338
|
+
minHour,
|
|
1339
|
+
left: dayLeft(dayIndex),
|
|
1340
|
+
width: dayWidth,
|
|
1341
|
+
color: theme.colors.backgroundEvent,
|
|
1342
|
+
slotName: "backgroundEvent",
|
|
1343
|
+
testID: "background-event-shade"
|
|
1344
|
+
}, `bg-${day.toISOString()}-${bandIndex}`))),
|
|
994
1345
|
days.map((day, dayIndex) => {
|
|
995
1346
|
const separatorSlot = slot("daySeparator", {
|
|
996
1347
|
base: [
|
|
@@ -1032,14 +1383,17 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1032
1383
|
dayWidth,
|
|
1033
1384
|
dayIndex,
|
|
1034
1385
|
dayCount: days.length,
|
|
1386
|
+
dayOrdinals,
|
|
1035
1387
|
mode,
|
|
1388
|
+
daysPerPage,
|
|
1036
1389
|
renderEvent,
|
|
1037
1390
|
snapMinutes,
|
|
1038
1391
|
showDragHandle,
|
|
1039
1392
|
onPress: onPressEvent,
|
|
1040
1393
|
onLongPress: onLongPressEvent,
|
|
1041
1394
|
onDragEvent,
|
|
1042
|
-
onDragStart
|
|
1395
|
+
onDragStart,
|
|
1396
|
+
onEdgeAdvance
|
|
1043
1397
|
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
1044
1398
|
})),
|
|
1045
1399
|
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ jsx(NowIndicator, {
|
|
@@ -1061,7 +1415,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1061
1415
|
});
|
|
1062
1416
|
}
|
|
1063
1417
|
const TimetablePage = memo(TimetablePageInner);
|
|
1064
|
-
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, calendarCellStyle, businessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
1418
|
+
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
1065
1419
|
const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
|
|
1066
1420
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
1067
1421
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -1072,6 +1426,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1072
1426
|
]);
|
|
1073
1427
|
const { width, height } = useWindowDimensions();
|
|
1074
1428
|
const listRef = useRef(null);
|
|
1429
|
+
const pagerRef = useRef(null);
|
|
1075
1430
|
const containerRef = useRef(null);
|
|
1076
1431
|
const suppressCaptureUntilRef = useRef(0);
|
|
1077
1432
|
const [pageHeight, setPageHeight] = useState(height);
|
|
@@ -1081,6 +1436,84 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1081
1436
|
const step = weekAnchored ? 7 : viewDayCount(mode, numberOfDays);
|
|
1082
1437
|
const seedDefaultY = Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR$1 - clampedMinHour) * hourHeight;
|
|
1083
1438
|
const scrollY = useSharedValue(seedDefaultY);
|
|
1439
|
+
const pagerLeft = useSharedValue(0);
|
|
1440
|
+
const pagerTop = useSharedValue(0);
|
|
1441
|
+
const pagerWidth = useSharedValue(width);
|
|
1442
|
+
const [edgePagingLock, setEdgePagingLock] = useState(false);
|
|
1443
|
+
const ghostX = useSharedValue(0);
|
|
1444
|
+
const ghostY = useSharedValue(0);
|
|
1445
|
+
const ghostW = useSharedValue(0);
|
|
1446
|
+
const ghostH = useSharedValue(0);
|
|
1447
|
+
const ghostVisible = useSharedValue(0);
|
|
1448
|
+
const gridTop = useSharedValue(0);
|
|
1449
|
+
const [liftedEvent, setLiftedEvent] = useState(null);
|
|
1450
|
+
const liftedEventRef = useRef(null);
|
|
1451
|
+
const dropRef = useRef({
|
|
1452
|
+
headerDays: [],
|
|
1453
|
+
containerWidth,
|
|
1454
|
+
hourColumnWidth,
|
|
1455
|
+
minHour: clampedMinHour,
|
|
1456
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1457
|
+
onDragEvent,
|
|
1458
|
+
onChangeDate
|
|
1459
|
+
});
|
|
1460
|
+
const beginLift = useCallback((event) => {
|
|
1461
|
+
liftedEventRef.current = event;
|
|
1462
|
+
setLiftedEvent(event);
|
|
1463
|
+
}, []);
|
|
1464
|
+
const clearLift = useCallback(() => {
|
|
1465
|
+
ghostVisible.value = 0;
|
|
1466
|
+
liftedEventRef.current = null;
|
|
1467
|
+
setLiftedEvent(null);
|
|
1468
|
+
setEdgePagingLock(false);
|
|
1469
|
+
}, [ghostVisible]);
|
|
1470
|
+
const commitLiftedDrop = useCallback((ghostLocalX, ghostLocalY) => {
|
|
1471
|
+
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1472
|
+
const ev = liftedEventRef.current;
|
|
1473
|
+
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1474
|
+
clearLift();
|
|
1475
|
+
if (!ev || !onDrag || days.length === 0) return;
|
|
1476
|
+
const dayWidth = (cw - hcw) / days.length;
|
|
1477
|
+
const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
|
|
1478
|
+
const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1479
|
+
const minutes = Math.round(rawMinutes / snap) * snap;
|
|
1480
|
+
const start = new Date(days[col]);
|
|
1481
|
+
start.setHours(0, 0, 0, 0);
|
|
1482
|
+
start.setMinutes(minutes);
|
|
1483
|
+
if (onDrag(ev, start, new Date(start.getTime() + duration)) === false) onDate(ev.start);
|
|
1484
|
+
}, [
|
|
1485
|
+
clearLift,
|
|
1486
|
+
gridTop,
|
|
1487
|
+
scrollY,
|
|
1488
|
+
cellHeight
|
|
1489
|
+
]);
|
|
1490
|
+
const handleGridTop = useCallback((y) => {
|
|
1491
|
+
gridTop.value = y;
|
|
1492
|
+
}, [gridTop]);
|
|
1493
|
+
const edgePaging = useMemo(() => ({
|
|
1494
|
+
pagerLeft,
|
|
1495
|
+
pagerTop,
|
|
1496
|
+
pagerWidth,
|
|
1497
|
+
lockScroll: setEdgePagingLock,
|
|
1498
|
+
ghostX,
|
|
1499
|
+
ghostY,
|
|
1500
|
+
ghostW,
|
|
1501
|
+
ghostH,
|
|
1502
|
+
ghostVisible,
|
|
1503
|
+
beginLift,
|
|
1504
|
+
commitLiftedDrop
|
|
1505
|
+
}), [
|
|
1506
|
+
pagerLeft,
|
|
1507
|
+
pagerTop,
|
|
1508
|
+
pagerWidth,
|
|
1509
|
+
ghostX,
|
|
1510
|
+
ghostY,
|
|
1511
|
+
ghostW,
|
|
1512
|
+
ghostH,
|
|
1513
|
+
ghostVisible,
|
|
1514
|
+
beginLift,
|
|
1515
|
+
commitLiftedDrop
|
|
1516
|
+
]);
|
|
1084
1517
|
const offsetSeedRef = useRef(null);
|
|
1085
1518
|
const captureOffsetSeed = useCallback((y) => {
|
|
1086
1519
|
offsetSeedRef.current = y;
|
|
@@ -1105,7 +1538,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1105
1538
|
])(date);
|
|
1106
1539
|
const viewedIndexRef = useRef(activeIndex);
|
|
1107
1540
|
const pendingScrollIndexRef = useRef(null);
|
|
1108
|
-
const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1541
|
+
const headerDays = useMemo(() => getViewDays$1(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
1109
1542
|
mode,
|
|
1110
1543
|
pageDates,
|
|
1111
1544
|
activeIndex,
|
|
@@ -1113,8 +1546,18 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1113
1546
|
weekStartsOn,
|
|
1114
1547
|
numberOfDays,
|
|
1115
1548
|
isRTL,
|
|
1116
|
-
weekEndsOn
|
|
1549
|
+
weekEndsOn,
|
|
1550
|
+
hiddenDays
|
|
1117
1551
|
]);
|
|
1552
|
+
dropRef.current = {
|
|
1553
|
+
headerDays,
|
|
1554
|
+
containerWidth,
|
|
1555
|
+
hourColumnWidth,
|
|
1556
|
+
minHour: clampedMinHour,
|
|
1557
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1558
|
+
onDragEvent,
|
|
1559
|
+
onChangeDate
|
|
1560
|
+
};
|
|
1118
1561
|
const handleViewableItemsChanged = useCallback((info) => {
|
|
1119
1562
|
if (isWeb$1) return;
|
|
1120
1563
|
const settled = info.viewableItems.find((token) => token.isViewable);
|
|
@@ -1200,14 +1643,15 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1200
1643
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
1201
1644
|
return () => cancelAnimationFrame(raf);
|
|
1202
1645
|
}, [pageHeight]);
|
|
1203
|
-
|
|
1646
|
+
const goToPage = useCallback((delta) => {
|
|
1204
1647
|
const target = pageDates[activeIndex + delta];
|
|
1205
1648
|
if (target) onChangeDate(target);
|
|
1206
1649
|
}, [
|
|
1207
1650
|
pageDates,
|
|
1208
1651
|
activeIndex,
|
|
1209
1652
|
onChangeDate
|
|
1210
|
-
])
|
|
1653
|
+
]);
|
|
1654
|
+
useWebPagerKeys(swipeEnabled, goToPage);
|
|
1211
1655
|
const reduceMotion = useReducedMotion();
|
|
1212
1656
|
const handlePressCell = useMemo(() => {
|
|
1213
1657
|
if (!onPressCell) return void 0;
|
|
@@ -1236,6 +1680,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1236
1680
|
children: /* @__PURE__ */ jsx(TimetablePage, {
|
|
1237
1681
|
mode,
|
|
1238
1682
|
numberOfDays,
|
|
1683
|
+
hiddenDays,
|
|
1684
|
+
now,
|
|
1685
|
+
nowTimeZone: timeZone,
|
|
1239
1686
|
date: item,
|
|
1240
1687
|
width: containerWidth,
|
|
1241
1688
|
events,
|
|
@@ -1255,11 +1702,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1255
1702
|
timeslots,
|
|
1256
1703
|
isRTL,
|
|
1257
1704
|
showAllDayEventCell,
|
|
1705
|
+
highlightWeekends,
|
|
1258
1706
|
showVerticalScrollIndicator,
|
|
1259
1707
|
verticalScrollEnabled,
|
|
1260
1708
|
hourComponent,
|
|
1261
1709
|
calendarCellStyle,
|
|
1262
1710
|
businessHours,
|
|
1711
|
+
renderBusinessHours,
|
|
1263
1712
|
minHourHeight,
|
|
1264
1713
|
maxHourHeight,
|
|
1265
1714
|
showNowIndicator,
|
|
@@ -1273,11 +1722,14 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1273
1722
|
onDragStart,
|
|
1274
1723
|
onPressCell: handlePressCell,
|
|
1275
1724
|
onLongPressCell,
|
|
1276
|
-
onCreateEvent
|
|
1725
|
+
onCreateEvent,
|
|
1726
|
+
onEdgeAdvance: goToPage,
|
|
1727
|
+
onGridTop: handleGridTop
|
|
1277
1728
|
})
|
|
1278
1729
|
}), [
|
|
1279
1730
|
containerWidth,
|
|
1280
1731
|
pageHeight,
|
|
1732
|
+
handleGridTop,
|
|
1281
1733
|
mode,
|
|
1282
1734
|
numberOfDays,
|
|
1283
1735
|
events,
|
|
@@ -1297,6 +1749,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1297
1749
|
timeslots,
|
|
1298
1750
|
isRTL,
|
|
1299
1751
|
showAllDayEventCell,
|
|
1752
|
+
highlightWeekends,
|
|
1300
1753
|
showVerticalScrollIndicator,
|
|
1301
1754
|
verticalScrollEnabled,
|
|
1302
1755
|
hourComponent,
|
|
@@ -1315,7 +1768,11 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1315
1768
|
onDragStart,
|
|
1316
1769
|
handlePressCell,
|
|
1317
1770
|
onLongPressCell,
|
|
1318
|
-
onCreateEvent
|
|
1771
|
+
onCreateEvent,
|
|
1772
|
+
goToPage,
|
|
1773
|
+
hiddenDays,
|
|
1774
|
+
now,
|
|
1775
|
+
timeZone
|
|
1319
1776
|
]);
|
|
1320
1777
|
const listExtraData = useMemo(() => ({
|
|
1321
1778
|
events,
|
|
@@ -1324,52 +1781,70 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1324
1781
|
return /* @__PURE__ */ jsx(SlotStylesProvider, {
|
|
1325
1782
|
classNames,
|
|
1326
1783
|
styles: styleOverrides,
|
|
1327
|
-
children: /* @__PURE__ */
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
keyExtractor: keyExtractorList,
|
|
1359
|
-
getFixedItemSize,
|
|
1360
|
-
...isWeb$1 ? null : {
|
|
1361
|
-
scrollEnabled: swipeEnabled,
|
|
1362
|
-
pagingEnabled: !freeSwipe,
|
|
1363
|
-
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1784
|
+
children: /* @__PURE__ */ jsx(EdgePagingContext.Provider, {
|
|
1785
|
+
value: edgePaging,
|
|
1786
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
1787
|
+
ref: containerRef,
|
|
1788
|
+
style: styles$1.container,
|
|
1789
|
+
children: [
|
|
1790
|
+
renderHeader ? renderHeader(headerDays) : /* @__PURE__ */ jsx(DefaultHeader, {
|
|
1791
|
+
days: headerDays,
|
|
1792
|
+
mode,
|
|
1793
|
+
width: containerWidth,
|
|
1794
|
+
hourColumnWidth,
|
|
1795
|
+
showWeekNumber,
|
|
1796
|
+
weekNumberPrefix,
|
|
1797
|
+
weekdayFormat,
|
|
1798
|
+
locale,
|
|
1799
|
+
activeDate,
|
|
1800
|
+
onPressDateHeader
|
|
1801
|
+
}),
|
|
1802
|
+
headerComponent,
|
|
1803
|
+
/* @__PURE__ */ jsxs(View, {
|
|
1804
|
+
ref: pagerRef,
|
|
1805
|
+
style: styles$1.pager,
|
|
1806
|
+
onLayout: (event) => {
|
|
1807
|
+
setPageHeight(event.nativeEvent.layout.height);
|
|
1808
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
1809
|
+
setMeasured(true);
|
|
1810
|
+
pagerRef.current?.measureInWindow((x, y, w) => {
|
|
1811
|
+
pagerLeft.value = x;
|
|
1812
|
+
pagerTop.value = y;
|
|
1813
|
+
pagerWidth.value = w;
|
|
1814
|
+
});
|
|
1364
1815
|
},
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1816
|
+
children: [/* @__PURE__ */ jsx(LegendList, {
|
|
1817
|
+
ref: listRef,
|
|
1818
|
+
style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
|
|
1819
|
+
data: pageDates,
|
|
1820
|
+
extraData: listExtraData,
|
|
1821
|
+
horizontal: true,
|
|
1822
|
+
recycleItems: false,
|
|
1823
|
+
keyExtractor: keyExtractorList,
|
|
1824
|
+
getFixedItemSize,
|
|
1825
|
+
...isWeb$1 ? null : {
|
|
1826
|
+
scrollEnabled: swipeEnabled && !edgePagingLock,
|
|
1827
|
+
pagingEnabled: !freeSwipe,
|
|
1828
|
+
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1829
|
+
},
|
|
1830
|
+
initialScrollIndex: activeIndex,
|
|
1831
|
+
showsHorizontalScrollIndicator: false,
|
|
1832
|
+
viewabilityConfig: PAGE_VIEWABILITY,
|
|
1833
|
+
onViewableItemsChanged: handleViewableItemsChanged,
|
|
1834
|
+
renderItem
|
|
1835
|
+
}, measured ? "grid" : "grid-seed"), liftedEvent ? /* @__PURE__ */ jsx(DragGhost, {
|
|
1836
|
+
x: ghostX,
|
|
1837
|
+
y: ghostY,
|
|
1838
|
+
w: ghostW,
|
|
1839
|
+
h: ghostH,
|
|
1840
|
+
visible: ghostVisible,
|
|
1841
|
+
event: liftedEvent,
|
|
1842
|
+
mode,
|
|
1843
|
+
renderEvent: labeledRenderEvent
|
|
1844
|
+
}) : null]
|
|
1845
|
+
})
|
|
1846
|
+
]
|
|
1847
|
+
})
|
|
1373
1848
|
})
|
|
1374
1849
|
});
|
|
1375
1850
|
}
|
|
@@ -1553,6 +2028,11 @@ const styles$1 = StyleSheet.create({
|
|
|
1553
2028
|
overflow: "hidden",
|
|
1554
2029
|
padding: EVENT_GAP
|
|
1555
2030
|
},
|
|
2031
|
+
dragGhost: {
|
|
2032
|
+
top: 0,
|
|
2033
|
+
left: 0,
|
|
2034
|
+
zIndex: 101
|
|
2035
|
+
},
|
|
1556
2036
|
nowIndicator: {
|
|
1557
2037
|
position: "absolute",
|
|
1558
2038
|
height: 2
|
|
@@ -1565,11 +2045,13 @@ const styles$1 = StyleSheet.create({
|
|
|
1565
2045
|
const defaultKeyExtractor = (event) => `${event.start.toISOString()}|${event.end.toISOString()}|${event.title ?? ""}`;
|
|
1566
2046
|
function visibleRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
1567
2047
|
if (mode === "month") return [startOfWeek(startOfMonth(date), { weekStartsOn }), endOfWeek(endOfMonth(date), { weekStartsOn })];
|
|
2048
|
+
if (mode === "year") return [startOfWeek(startOfYear(date), { weekStartsOn }), endOfWeek(endOfYear(date), { weekStartsOn })];
|
|
1568
2049
|
const days = getViewDays$1(mode, date, weekStartsOn, numberOfDays, false, weekEndsOn);
|
|
1569
2050
|
return [startOfDay(days[0]), endOfDay(days[days.length - 1])];
|
|
1570
2051
|
}
|
|
1571
2052
|
function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
1572
2053
|
if (mode === "month") return [startOfWeek(startOfMonth(addMonths(date, -1)), { weekStartsOn }), addWeeks(endOfWeek(endOfMonth(addMonths(date, 1)), { weekStartsOn }), 1)];
|
|
2054
|
+
if (mode === "year") return [startOfWeek(startOfYear(date), { weekStartsOn }), endOfWeek(endOfYear(date), { weekStartsOn })];
|
|
1573
2055
|
if (mode === "schedule") return [startOfDay(date), endOfDay(addMonths(date, 3))];
|
|
1574
2056
|
const days = getViewDays$1(mode, date, weekStartsOn, numberOfDays, false, weekEndsOn);
|
|
1575
2057
|
const span = days.length;
|
|
@@ -1601,7 +2083,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
1601
2083
|
* }
|
|
1602
2084
|
* ```
|
|
1603
2085
|
*/
|
|
1604
|
-
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
2086
|
+
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
1605
2087
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
1606
2088
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
1607
2089
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -1678,6 +2160,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1678
2160
|
events: displayEvents,
|
|
1679
2161
|
maxVisibleEventCount,
|
|
1680
2162
|
weekStartsOn,
|
|
2163
|
+
hiddenDays,
|
|
1681
2164
|
weekdayFormat,
|
|
1682
2165
|
locale,
|
|
1683
2166
|
sortedMonthView,
|
|
@@ -1702,6 +2185,17 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1702
2185
|
swipeEnabled,
|
|
1703
2186
|
classNames,
|
|
1704
2187
|
styles: styleOverrides
|
|
2188
|
+
}) : mode === "year" ? /* @__PURE__ */ jsx(YearView, {
|
|
2189
|
+
date,
|
|
2190
|
+
events: displayEvents,
|
|
2191
|
+
weekStartsOn,
|
|
2192
|
+
hiddenDays,
|
|
2193
|
+
locale,
|
|
2194
|
+
activeDate,
|
|
2195
|
+
onPressDay,
|
|
2196
|
+
onPressMonth,
|
|
2197
|
+
classNames,
|
|
2198
|
+
styles: styleOverrides
|
|
1705
2199
|
}) : mode === "schedule" ? /* @__PURE__ */ jsx(Agenda, {
|
|
1706
2200
|
events: displayEvents,
|
|
1707
2201
|
locale,
|
|
@@ -1724,6 +2218,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1724
2218
|
hourHeight,
|
|
1725
2219
|
weekStartsOn,
|
|
1726
2220
|
weekdayFormat,
|
|
2221
|
+
hiddenDays,
|
|
2222
|
+
now,
|
|
2223
|
+
timeZone,
|
|
1727
2224
|
renderEvent: resolvedRenderEvent,
|
|
1728
2225
|
keyExtractor,
|
|
1729
2226
|
scrollOffsetMinutes,
|
|
@@ -1731,8 +2228,10 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1731
2228
|
hideHours,
|
|
1732
2229
|
timeslots,
|
|
1733
2230
|
showAllDayEventCell,
|
|
2231
|
+
highlightWeekends,
|
|
1734
2232
|
calendarCellStyle,
|
|
1735
2233
|
businessHours,
|
|
2234
|
+
renderBusinessHours,
|
|
1736
2235
|
showWeekNumber,
|
|
1737
2236
|
weekNumberPrefix,
|
|
1738
2237
|
hourComponent,
|
|
@@ -1806,41 +2305,60 @@ function DefaultBar({ event, width, height }) {
|
|
|
1806
2305
|
}) : null]
|
|
1807
2306
|
});
|
|
1808
2307
|
}
|
|
1809
|
-
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, theme }) {
|
|
2308
|
+
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, resources, laneIndex, laneSize, dragActive, onDragActiveChange, theme }) {
|
|
1810
2309
|
const moveX = useSharedValue(0);
|
|
2310
|
+
const moveCross = useSharedValue(0);
|
|
1811
2311
|
const resizeW = useSharedValue(0);
|
|
1812
2312
|
const latest = useRef({
|
|
1813
2313
|
event: pe.event,
|
|
1814
|
-
onDragEvent
|
|
2314
|
+
onDragEvent,
|
|
2315
|
+
resources,
|
|
2316
|
+
laneIndex
|
|
1815
2317
|
});
|
|
1816
2318
|
latest.current = {
|
|
1817
2319
|
event: pe.event,
|
|
1818
|
-
onDragEvent
|
|
2320
|
+
onDragEvent,
|
|
2321
|
+
resources,
|
|
2322
|
+
laneIndex
|
|
1819
2323
|
};
|
|
1820
|
-
const
|
|
2324
|
+
const laneCount = resources.length;
|
|
2325
|
+
const draggable = !pe.event.disabled && pe.event.draggable !== false;
|
|
1821
2326
|
useEffect(() => {
|
|
2327
|
+
if (dragActive) return;
|
|
1822
2328
|
moveX.value = 0;
|
|
2329
|
+
moveCross.value = 0;
|
|
1823
2330
|
resizeW.value = 0;
|
|
1824
2331
|
}, [
|
|
2332
|
+
dragActive,
|
|
1825
2333
|
pe.startHours,
|
|
1826
2334
|
pe.durationHours,
|
|
1827
2335
|
moveX,
|
|
2336
|
+
moveCross,
|
|
1828
2337
|
resizeW
|
|
1829
2338
|
]);
|
|
1830
2339
|
const snapBack = useCallback(() => {
|
|
1831
2340
|
moveX.value = 0;
|
|
2341
|
+
moveCross.value = 0;
|
|
1832
2342
|
resizeW.value = 0;
|
|
1833
|
-
}, [
|
|
1834
|
-
|
|
1835
|
-
|
|
2343
|
+
}, [
|
|
2344
|
+
moveX,
|
|
2345
|
+
moveCross,
|
|
2346
|
+
resizeW
|
|
2347
|
+
]);
|
|
2348
|
+
const commit = useCallback((deltaStartMin, deltaEndMin, laneDelta = 0) => {
|
|
2349
|
+
const { event, onDragEvent: handler, resources: lanes, laneIndex: lane } = latest.current;
|
|
1836
2350
|
const next = resolveDraggedBounds(event.start, event.end, deltaStartMin, deltaEndMin, snapMinutes);
|
|
1837
|
-
|
|
2351
|
+
const target = lanes[Math.min(Math.max(lane + laneDelta, 0), lanes.length - 1)];
|
|
2352
|
+
if (!next || !target) {
|
|
1838
2353
|
snapBack();
|
|
1839
2354
|
return;
|
|
1840
2355
|
}
|
|
1841
|
-
if (handler(event, next.start, next.end) === false) snapBack();
|
|
2356
|
+
if (handler(event, next.start, next.end, target) === false) snapBack();
|
|
1842
2357
|
}, [snapMinutes, snapBack]);
|
|
1843
2358
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
2359
|
+
const laneTitle = (lane) => lane && (lane.title || lane.id);
|
|
2360
|
+
const nextLane = laneTitle(resources[laneIndex + 1]);
|
|
2361
|
+
const previousLane = laneTitle(resources[laneIndex - 1]);
|
|
1844
2362
|
const barActions = draggable ? [
|
|
1845
2363
|
{
|
|
1846
2364
|
name: "move-later",
|
|
@@ -1857,7 +2375,15 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
1857
2375
|
{
|
|
1858
2376
|
name: "shrink",
|
|
1859
2377
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
1860
|
-
}
|
|
2378
|
+
},
|
|
2379
|
+
...nextLane ? [{
|
|
2380
|
+
name: "move-next-lane",
|
|
2381
|
+
label: `Move to ${nextLane}`
|
|
2382
|
+
}] : [],
|
|
2383
|
+
...previousLane ? [{
|
|
2384
|
+
name: "move-previous-lane",
|
|
2385
|
+
label: `Move to ${previousLane}`
|
|
2386
|
+
}] : []
|
|
1861
2387
|
] : void 0;
|
|
1862
2388
|
const onBarAction = draggable ? (e) => {
|
|
1863
2389
|
switch (e.nativeEvent.actionName) {
|
|
@@ -1873,36 +2399,61 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
1873
2399
|
case "shrink":
|
|
1874
2400
|
commit(0, -snapMinutes);
|
|
1875
2401
|
break;
|
|
2402
|
+
case "move-next-lane":
|
|
2403
|
+
commit(0, 0, 1);
|
|
2404
|
+
break;
|
|
2405
|
+
case "move-previous-lane":
|
|
2406
|
+
commit(0, 0, -1);
|
|
2407
|
+
break;
|
|
1876
2408
|
}
|
|
1877
2409
|
} : void 0;
|
|
1878
2410
|
const barStyle = useAnimatedStyle(() => vertical ? {
|
|
1879
|
-
transform: [{ translateY: moveX.value }],
|
|
2411
|
+
transform: [{ translateY: moveX.value }, { translateX: moveCross.value }],
|
|
1880
2412
|
height: Math.max(height + resizeW.value, 2)
|
|
1881
2413
|
} : {
|
|
1882
|
-
transform: [{ translateX: moveX.value }],
|
|
2414
|
+
transform: [{ translateX: moveX.value }, { translateY: moveCross.value }],
|
|
1883
2415
|
width: Math.max(width + resizeW.value, 2)
|
|
1884
2416
|
}, [
|
|
1885
2417
|
vertical,
|
|
1886
2418
|
width,
|
|
1887
2419
|
height
|
|
1888
2420
|
]);
|
|
1889
|
-
const
|
|
2421
|
+
const laneId = resources[laneIndex]?.id ?? "";
|
|
2422
|
+
const moveGesture = useMemo(() => Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
|
|
2423
|
+
runOnJS(onDragActiveChange)(laneId);
|
|
2424
|
+
}).onUpdate((e) => {
|
|
1890
2425
|
moveX.value = vertical ? e.translationY : e.translationX;
|
|
2426
|
+
if (laneSize > 0 && laneCount > 1) {
|
|
2427
|
+
const cross = vertical ? e.translationX : e.translationY;
|
|
2428
|
+
moveCross.value = Math.min(Math.max(cross, -laneIndex * laneSize), (laneCount - 1 - laneIndex) * laneSize);
|
|
2429
|
+
}
|
|
1891
2430
|
}).onEnd((e) => {
|
|
1892
2431
|
const delta = snapDeltaMinutes(vertical ? e.translationY : e.translationX, hourSize, snapMinutes);
|
|
1893
|
-
|
|
2432
|
+
const cross = laneSize > 0 ? vertical ? e.translationX : e.translationY : 0;
|
|
2433
|
+
const laneDelta = laneSize > 0 ? Math.min(Math.max(Math.round(cross / laneSize), -laneIndex), laneCount - 1 - laneIndex) : 0;
|
|
2434
|
+
if (delta === 0 && laneDelta === 0) {
|
|
1894
2435
|
moveX.value = 0;
|
|
2436
|
+
moveCross.value = 0;
|
|
1895
2437
|
return;
|
|
1896
2438
|
}
|
|
1897
2439
|
moveX.value = delta / MINUTES_PER_HOUR * hourSize;
|
|
1898
|
-
|
|
2440
|
+
moveCross.value = laneDelta * laneSize;
|
|
2441
|
+
runOnJS(commit)(delta, delta, laneDelta);
|
|
2442
|
+
}).onFinalize(() => {
|
|
2443
|
+
runOnJS(onDragActiveChange)(null);
|
|
1899
2444
|
}), [
|
|
1900
2445
|
draggable,
|
|
1901
2446
|
vertical,
|
|
1902
2447
|
hourSize,
|
|
1903
2448
|
snapMinutes,
|
|
2449
|
+
laneSize,
|
|
2450
|
+
laneCount,
|
|
2451
|
+
laneIndex,
|
|
2452
|
+
laneId,
|
|
1904
2453
|
moveX,
|
|
1905
|
-
|
|
2454
|
+
moveCross,
|
|
2455
|
+
commit,
|
|
2456
|
+
onDragActiveChange
|
|
1906
2457
|
]);
|
|
1907
2458
|
const resizeGesture = useMemo(() => Gesture.Pan().enabled(draggable).onUpdate((e) => {
|
|
1908
2459
|
resizeW.value = vertical ? e.translationY : e.translationX;
|
|
@@ -2088,11 +2639,57 @@ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, s
|
|
|
2088
2639
|
* />
|
|
2089
2640
|
* ```
|
|
2090
2641
|
*/
|
|
2091
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, dragStepMinutes = 15 }) {
|
|
2642
|
+
function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone }) {
|
|
2092
2643
|
const theme = useCalendarTheme();
|
|
2644
|
+
const resources = useMemo(() => {
|
|
2645
|
+
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
2646
|
+
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
2647
|
+
const page = Math.min(Math.max(resourcePage, 0), pages - 1);
|
|
2648
|
+
return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
|
|
2649
|
+
}, [
|
|
2650
|
+
allResources,
|
|
2651
|
+
resourcesPerPage,
|
|
2652
|
+
resourcePage
|
|
2653
|
+
]);
|
|
2654
|
+
const [dragLaneId, setDragLaneId] = useState(null);
|
|
2655
|
+
const [vBodyWidth, setVBodyWidth] = useState(0);
|
|
2656
|
+
const vLaneSize = resources.length > 0 && vBodyWidth > GUTTER_WIDTH ? (vBodyWidth - GUTTER_WIDTH) / resources.length : 0;
|
|
2093
2657
|
const Renderer = renderEvent ?? DefaultBar;
|
|
2094
2658
|
const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
|
|
2659
|
+
const now = useNow$1(showNowIndicator, {
|
|
2660
|
+
now: nowProp,
|
|
2661
|
+
timeZone
|
|
2662
|
+
});
|
|
2663
|
+
const nowHours = now.getHours() + now.getMinutes() / 60;
|
|
2664
|
+
const showNow = showNowIndicator && isSameCalendarDay$1(now, date) && nowHours >= startHour && nowHours <= endHour;
|
|
2665
|
+
const nowLine = (vertical, hourSize) => showNow ? /* @__PURE__ */ jsx(View, {
|
|
2666
|
+
pointerEvents: "none",
|
|
2667
|
+
testID: "resource-now-indicator",
|
|
2668
|
+
style: [
|
|
2669
|
+
vertical ? {
|
|
2670
|
+
position: "absolute",
|
|
2671
|
+
left: 0,
|
|
2672
|
+
right: 0,
|
|
2673
|
+
height: 2
|
|
2674
|
+
} : {
|
|
2675
|
+
position: "absolute",
|
|
2676
|
+
top: 0,
|
|
2677
|
+
bottom: 0,
|
|
2678
|
+
width: 2
|
|
2679
|
+
},
|
|
2680
|
+
vertical ? { top: (nowHours - startHour) * hourSize } : { left: (nowHours - startHour) * hourSize },
|
|
2681
|
+
{
|
|
2682
|
+
backgroundColor: theme.colors.nowIndicator,
|
|
2683
|
+
zIndex: 2
|
|
2684
|
+
}
|
|
2685
|
+
]
|
|
2686
|
+
}) : null;
|
|
2095
2687
|
const bandsFor = (resource) => businessHours ? closedHourBands(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
2688
|
+
const backgroundBandsFor = (resource) => backgroundBandsForDay$1(events.filter((event) => resourceId(event) === resource.id), date).map((b) => ({
|
|
2689
|
+
...b,
|
|
2690
|
+
startHours: Math.max(b.startHours, startHour),
|
|
2691
|
+
endHours: Math.min(b.endHours, endHour)
|
|
2692
|
+
})).filter((b) => b.endHours > b.startHours);
|
|
2096
2693
|
const hours = useMemo(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
|
|
2097
2694
|
const trackWidth = (endHour - startHour) * hourWidth;
|
|
2098
2695
|
const byResource = useMemo(() => {
|
|
@@ -2127,6 +2724,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2127
2724
|
showsVerticalScrollIndicator: true,
|
|
2128
2725
|
children: /* @__PURE__ */ jsxs(View, {
|
|
2129
2726
|
style: [styles.vbody, { height: trackHeight }],
|
|
2727
|
+
onLayout: (event) => setVBodyWidth(event.nativeEvent.layout.width),
|
|
2130
2728
|
children: [/* @__PURE__ */ jsx(View, {
|
|
2131
2729
|
style: { width: GUTTER_WIDTH },
|
|
2132
2730
|
children: hours.map((h) => /* @__PURE__ */ jsx(Text, {
|
|
@@ -2137,24 +2735,45 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2137
2735
|
}],
|
|
2138
2736
|
children: formatHour(h, { ampm })
|
|
2139
2737
|
}, h))
|
|
2140
|
-
}), resources.map((resource) => {
|
|
2738
|
+
}), resources.map((resource, laneIndex) => {
|
|
2141
2739
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2142
2740
|
return /* @__PURE__ */ jsxs(View, {
|
|
2143
2741
|
style: [
|
|
2144
2742
|
styles.vcolumn,
|
|
2145
2743
|
{ borderLeftColor: theme.colors.gridLine },
|
|
2146
|
-
theme.containers.resourceRow
|
|
2744
|
+
theme.containers.resourceRow,
|
|
2745
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2147
2746
|
],
|
|
2148
2747
|
children: [
|
|
2149
2748
|
bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
|
|
2150
2749
|
pointerEvents: "none",
|
|
2750
|
+
accessibilityElementsHidden: true,
|
|
2751
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2151
2752
|
testID: "resource-hours-shade",
|
|
2753
|
+
style: [
|
|
2754
|
+
styles.vshadeBand,
|
|
2755
|
+
{
|
|
2756
|
+
top: (b.start - startHour) * hourHeight,
|
|
2757
|
+
height: (b.end - b.start) * hourHeight
|
|
2758
|
+
},
|
|
2759
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2760
|
+
],
|
|
2761
|
+
children: renderBusinessHours?.({
|
|
2762
|
+
date,
|
|
2763
|
+
start: b.start,
|
|
2764
|
+
end: b.end,
|
|
2765
|
+
resource
|
|
2766
|
+
})
|
|
2767
|
+
}, `shade-${b.start}`)),
|
|
2768
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ jsx(View, {
|
|
2769
|
+
pointerEvents: "none",
|
|
2770
|
+
testID: "background-event-shade",
|
|
2152
2771
|
style: [styles.vshadeBand, {
|
|
2153
|
-
top: (b.
|
|
2154
|
-
height: (b.
|
|
2155
|
-
backgroundColor: theme.colors.
|
|
2772
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
2773
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
2774
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2156
2775
|
}]
|
|
2157
|
-
}, `
|
|
2776
|
+
}, `bg-${i}`)),
|
|
2158
2777
|
hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
|
|
2159
2778
|
pointerEvents: "none",
|
|
2160
2779
|
style: [styles.vgridLine, {
|
|
@@ -2162,6 +2781,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2162
2781
|
backgroundColor: theme.colors.gridLine
|
|
2163
2782
|
}]
|
|
2164
2783
|
}, h)),
|
|
2784
|
+
nowLine(true, hourHeight),
|
|
2165
2785
|
cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
|
|
2166
2786
|
resource,
|
|
2167
2787
|
vertical: true,
|
|
@@ -2185,6 +2805,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2185
2805
|
if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
|
|
2186
2806
|
pe,
|
|
2187
2807
|
vertical: true,
|
|
2808
|
+
resources,
|
|
2809
|
+
laneIndex,
|
|
2810
|
+
laneSize: vLaneSize,
|
|
2811
|
+
dragActive: dragLaneId === resource.id,
|
|
2812
|
+
onDragActiveChange: setDragLaneId,
|
|
2188
2813
|
hourSize: hourHeight,
|
|
2189
2814
|
left,
|
|
2190
2815
|
top,
|
|
@@ -2251,7 +2876,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2251
2876
|
children: formatHour(h, { ampm })
|
|
2252
2877
|
}, h))
|
|
2253
2878
|
})]
|
|
2254
|
-
}), resources.map((resource) => {
|
|
2879
|
+
}), resources.map((resource, laneIndex) => {
|
|
2255
2880
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2256
2881
|
return /* @__PURE__ */ jsxs(View, {
|
|
2257
2882
|
style: [
|
|
@@ -2260,7 +2885,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2260
2885
|
height: rowHeight,
|
|
2261
2886
|
borderBottomColor: theme.colors.gridLine
|
|
2262
2887
|
},
|
|
2263
|
-
theme.containers.resourceRow
|
|
2888
|
+
theme.containers.resourceRow,
|
|
2889
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2264
2890
|
],
|
|
2265
2891
|
children: [/* @__PURE__ */ jsx(View, {
|
|
2266
2892
|
style: [
|
|
@@ -2282,13 +2908,33 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2282
2908
|
children: [
|
|
2283
2909
|
bandsFor(resource).map((b) => /* @__PURE__ */ jsx(View, {
|
|
2284
2910
|
pointerEvents: "none",
|
|
2911
|
+
accessibilityElementsHidden: true,
|
|
2912
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2285
2913
|
testID: "resource-hours-shade",
|
|
2914
|
+
style: [
|
|
2915
|
+
styles.hshadeBand,
|
|
2916
|
+
{
|
|
2917
|
+
left: (b.start - startHour) * hourWidth,
|
|
2918
|
+
width: (b.end - b.start) * hourWidth
|
|
2919
|
+
},
|
|
2920
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2921
|
+
],
|
|
2922
|
+
children: renderBusinessHours?.({
|
|
2923
|
+
date,
|
|
2924
|
+
start: b.start,
|
|
2925
|
+
end: b.end,
|
|
2926
|
+
resource
|
|
2927
|
+
})
|
|
2928
|
+
}, `shade-${b.start}`)),
|
|
2929
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ jsx(View, {
|
|
2930
|
+
pointerEvents: "none",
|
|
2931
|
+
testID: "background-event-shade",
|
|
2286
2932
|
style: [styles.hshadeBand, {
|
|
2287
|
-
left: (b.
|
|
2288
|
-
width: (b.
|
|
2289
|
-
backgroundColor: theme.colors.
|
|
2933
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
2934
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
2935
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2290
2936
|
}]
|
|
2291
|
-
}, `
|
|
2937
|
+
}, `bg-${i}`)),
|
|
2292
2938
|
hours.slice(1).map((h) => /* @__PURE__ */ jsx(View, {
|
|
2293
2939
|
pointerEvents: "none",
|
|
2294
2940
|
style: [styles.gridLine, {
|
|
@@ -2296,6 +2942,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2296
2942
|
backgroundColor: theme.colors.gridLine
|
|
2297
2943
|
}]
|
|
2298
2944
|
}, h)),
|
|
2945
|
+
nowLine(false, hourWidth),
|
|
2299
2946
|
cellEnabled ? /* @__PURE__ */ jsx(LaneInteractionLayer, {
|
|
2300
2947
|
resource,
|
|
2301
2948
|
vertical: false,
|
|
@@ -2317,6 +2964,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2317
2964
|
if (onDragEvent) return /* @__PURE__ */ jsx(ResourceBar, {
|
|
2318
2965
|
pe,
|
|
2319
2966
|
vertical: false,
|
|
2967
|
+
resources,
|
|
2968
|
+
laneIndex,
|
|
2969
|
+
laneSize: rowHeight,
|
|
2970
|
+
dragActive: dragLaneId === resource.id,
|
|
2971
|
+
onDragActiveChange: setDragLaneId,
|
|
2320
2972
|
hourSize: hourWidth,
|
|
2321
2973
|
left,
|
|
2322
2974
|
top: pe.column * laneHeight,
|
|
@@ -2426,6 +3078,7 @@ const styles = StyleSheet.create({
|
|
|
2426
3078
|
fontWeight: "600"
|
|
2427
3079
|
},
|
|
2428
3080
|
vbody: { flexDirection: "row" },
|
|
3081
|
+
laneLifted: { zIndex: 10 },
|
|
2429
3082
|
vcolumn: {
|
|
2430
3083
|
flex: 1,
|
|
2431
3084
|
borderLeftWidth: StyleSheet.hairlineWidth
|
|
@@ -2471,4 +3124,4 @@ const styles = StyleSheet.create({
|
|
|
2471
3124
|
}
|
|
2472
3125
|
});
|
|
2473
3126
|
//#endregion
|
|
2474
|
-
export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useMonthGrid, weekdayFormatToken };
|
|
3127
|
+
export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|