@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.js
CHANGED
|
@@ -21,16 +21,180 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_MonthList = require("./MonthList-
|
|
24
|
+
const require_MonthList = require("./MonthList-CJs1vq5T.js");
|
|
25
25
|
let date_fns = require("date-fns");
|
|
26
26
|
let react = require("react");
|
|
27
27
|
let react_native_reanimated = require("react-native-reanimated");
|
|
28
28
|
react_native_reanimated = __toESM(react_native_reanimated);
|
|
29
29
|
let _super_calendar_core = require("@super-calendar/core");
|
|
30
|
-
let _legendapp_list_react_native = require("@legendapp/list/react-native");
|
|
31
30
|
let react_native = require("react-native");
|
|
32
31
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
let _legendapp_list_react_native = require("@legendapp/list/react-native");
|
|
33
33
|
let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
34
|
+
//#region src/components/YearView.tsx
|
|
35
|
+
const FALLBACK_COLUMNS = 3;
|
|
36
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, classNames, styles: styleOverrides }) {
|
|
37
|
+
const theme = require_MonthList.useCalendarTheme();
|
|
38
|
+
const slot = require_MonthList.createSlots({
|
|
39
|
+
classNames,
|
|
40
|
+
styles: styleOverrides
|
|
41
|
+
});
|
|
42
|
+
const [columns, setColumns] = (0, react.useState)(FALLBACK_COLUMNS);
|
|
43
|
+
const handleLayout = (event) => {
|
|
44
|
+
const width = event.nativeEvent.layout.width;
|
|
45
|
+
if (width <= 0) return;
|
|
46
|
+
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
47
|
+
};
|
|
48
|
+
const months = (0, react.useMemo)(() => (0, _super_calendar_core.getYearMonths)(date), [date]);
|
|
49
|
+
const weekdayLabels = (0, react.useMemo)(() => (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays).map((d) => (0, date_fns.format)(d, (0, _super_calendar_core.weekdayFormatToken)("narrow"), { locale })), [
|
|
50
|
+
date,
|
|
51
|
+
weekStartsOn,
|
|
52
|
+
locale,
|
|
53
|
+
hiddenDays
|
|
54
|
+
]);
|
|
55
|
+
const eventDays = (0, react.useMemo)(() => new Set(events && events.length > 0 ? (0, _super_calendar_core.groupEventsByDay)(events.filter((e) => !(0, _super_calendar_core.isBackgroundEvent)(e))).keys() : []), [events]);
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ScrollView, {
|
|
57
|
+
onLayout: handleLayout,
|
|
58
|
+
showsVerticalScrollIndicator: true,
|
|
59
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
60
|
+
...slot("grid", { base: styles$5.grid }),
|
|
61
|
+
children: months.map((month) => {
|
|
62
|
+
const weeks = (0, _super_calendar_core.buildMonthWeeks)(month, weekStartsOn, { hiddenDays });
|
|
63
|
+
const title = (0, date_fns.format)(month, "MMMM", { locale });
|
|
64
|
+
const monthLabel = (0, date_fns.format)(month, "MMMM yyyy", { locale });
|
|
65
|
+
const titleText = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
66
|
+
...slot("monthTitle", {
|
|
67
|
+
base: styles$5.monthTitle,
|
|
68
|
+
themed: [styles$5.monthTitleText, { color: theme.colors.todayBackground }]
|
|
69
|
+
}),
|
|
70
|
+
allowFontScaling: false,
|
|
71
|
+
children: title
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
74
|
+
...slot("month", { base: [styles$5.month, { width: `${100 / columns}%` }] }),
|
|
75
|
+
children: [
|
|
76
|
+
onPressMonth ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
77
|
+
onPress: () => onPressMonth(month),
|
|
78
|
+
accessibilityRole: "button",
|
|
79
|
+
accessibilityLabel: monthLabel,
|
|
80
|
+
children: titleText
|
|
81
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
82
|
+
accessible: true,
|
|
83
|
+
accessibilityRole: "header",
|
|
84
|
+
accessibilityLabel: monthLabel,
|
|
85
|
+
children: titleText
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
88
|
+
...slot("weekdays", { base: styles$5.weekdays }),
|
|
89
|
+
accessibilityElementsHidden: true,
|
|
90
|
+
importantForAccessibility: "no-hide-descendants",
|
|
91
|
+
children: weekdayLabels.map((label, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
92
|
+
...slot("weekday", {
|
|
93
|
+
base: styles$5.weekday,
|
|
94
|
+
themed: [styles$5.weekdayText, { color: theme.colors.textMuted }]
|
|
95
|
+
}),
|
|
96
|
+
allowFontScaling: false,
|
|
97
|
+
children: label
|
|
98
|
+
}, i))
|
|
99
|
+
}),
|
|
100
|
+
weeks.map((week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
101
|
+
...slot("week", { base: styles$5.week }),
|
|
102
|
+
children: week.map((day) => {
|
|
103
|
+
if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: styles$5.day }, day.toISOString());
|
|
104
|
+
const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : (0, _super_calendar_core.getIsToday)(day);
|
|
105
|
+
const hasEvents = eventDays.has((0, date_fns.startOfDay)(day).toISOString());
|
|
106
|
+
const label = `${(0, date_fns.format)(day, "EEEE, d LLLL yyyy", { locale })}${(0, _super_calendar_core.getIsToday)(day) ? ", today" : ""}${hasEvents ? ", has events" : ""}`;
|
|
107
|
+
const daySlot = slot("day", {
|
|
108
|
+
base: styles$5.day,
|
|
109
|
+
themed: isHighlighted ? {
|
|
110
|
+
backgroundColor: theme.colors.todayBackground,
|
|
111
|
+
borderRadius: theme.todayBadgeRadius
|
|
112
|
+
} : void 0
|
|
113
|
+
});
|
|
114
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
115
|
+
...slot("dayText", { themed: [styles$5.dayText, { color: isHighlighted ? theme.colors.todayText : theme.colors.text }] }),
|
|
116
|
+
allowFontScaling: false,
|
|
117
|
+
children: day.getDate()
|
|
118
|
+
}), hasEvents ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("eventDot", {
|
|
119
|
+
base: styles$5.eventDot,
|
|
120
|
+
themed: { backgroundColor: isHighlighted ? theme.colors.todayText : theme.colors.todayBackground }
|
|
121
|
+
}) }) : null] });
|
|
122
|
+
return onPressDay ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
123
|
+
onPress: () => onPressDay(day),
|
|
124
|
+
accessibilityRole: "button",
|
|
125
|
+
accessibilityLabel: label,
|
|
126
|
+
...daySlot,
|
|
127
|
+
children: content
|
|
128
|
+
}, day.toISOString()) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
129
|
+
accessible: true,
|
|
130
|
+
accessibilityLabel: label,
|
|
131
|
+
...daySlot,
|
|
132
|
+
children: content
|
|
133
|
+
}, day.toISOString());
|
|
134
|
+
})
|
|
135
|
+
}, week[0].toISOString()))
|
|
136
|
+
]
|
|
137
|
+
}, month.toISOString());
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A year at a glance: the twelve months as compact mini grids, with today
|
|
144
|
+
* highlighted and a dot under days that hold events. Tap a day or a month
|
|
145
|
+
* title to drill into a denser view. It's the view `Calendar` renders for
|
|
146
|
+
* `mode="year"`.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```tsx
|
|
150
|
+
* import { YearView } from "@super-calendar/native";
|
|
151
|
+
*
|
|
152
|
+
* <YearView
|
|
153
|
+
* date={new Date()}
|
|
154
|
+
* events={events}
|
|
155
|
+
* weekStartsOn={1}
|
|
156
|
+
* onPressDay={(day) => console.log(day)}
|
|
157
|
+
* />
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
const YearView = (0, react.memo)(YearViewInner);
|
|
161
|
+
const styles$5 = react_native.StyleSheet.create({
|
|
162
|
+
grid: {
|
|
163
|
+
flexDirection: "row",
|
|
164
|
+
flexWrap: "wrap"
|
|
165
|
+
},
|
|
166
|
+
month: { padding: 8 },
|
|
167
|
+
monthTitle: { paddingBottom: 4 },
|
|
168
|
+
monthTitleText: {
|
|
169
|
+
fontSize: 13,
|
|
170
|
+
fontWeight: "700"
|
|
171
|
+
},
|
|
172
|
+
weekdays: { flexDirection: "row" },
|
|
173
|
+
weekday: {
|
|
174
|
+
flex: 1,
|
|
175
|
+
textAlign: "center"
|
|
176
|
+
},
|
|
177
|
+
weekdayText: {
|
|
178
|
+
fontSize: 9,
|
|
179
|
+
fontWeight: "600"
|
|
180
|
+
},
|
|
181
|
+
week: { flexDirection: "row" },
|
|
182
|
+
day: {
|
|
183
|
+
flex: 1,
|
|
184
|
+
aspectRatio: 1,
|
|
185
|
+
alignItems: "center",
|
|
186
|
+
justifyContent: "center"
|
|
187
|
+
},
|
|
188
|
+
dayText: { fontSize: 11 },
|
|
189
|
+
eventDot: {
|
|
190
|
+
position: "absolute",
|
|
191
|
+
bottom: 1,
|
|
192
|
+
width: 3,
|
|
193
|
+
height: 3,
|
|
194
|
+
borderRadius: 2
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
//#endregion
|
|
34
198
|
//#region src/components/Agenda.tsx
|
|
35
199
|
/**
|
|
36
200
|
* A vertical, day-grouped list of events (no time grid). Events are sorted by
|
|
@@ -45,7 +209,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
45
209
|
}), [classNames, styleOverrides]);
|
|
46
210
|
const RenderEventComponent = renderEvent;
|
|
47
211
|
const rows = (0, react.useMemo)(() => {
|
|
48
|
-
const sorted =
|
|
212
|
+
const sorted = events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)).sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
49
213
|
const out = [];
|
|
50
214
|
let currentDay = null;
|
|
51
215
|
sorted.forEach((event, index) => {
|
|
@@ -212,7 +376,7 @@ function DefaultEvent({ event, mode, boxHeight, isAllDay, ampm = false, showTime
|
|
|
212
376
|
],
|
|
213
377
|
onPress,
|
|
214
378
|
onLongPress,
|
|
215
|
-
activeOpacity:
|
|
379
|
+
activeOpacity: 1,
|
|
216
380
|
accessibilityRole: "button",
|
|
217
381
|
accessibilityLabel,
|
|
218
382
|
accessibilityState: { disabled: event.disabled ?? false },
|
|
@@ -342,7 +506,7 @@ function AllDayLane({ days, events, mode, hourColumnWidth, dayWidth, renderEvent
|
|
|
342
506
|
const theme = require_MonthList.useCalendarTheme();
|
|
343
507
|
const slot = require_MonthList.useSlots();
|
|
344
508
|
const RenderEventComponent = renderEvent;
|
|
345
|
-
const allDay = events.filter(_super_calendar_core.isAllDayEvent);
|
|
509
|
+
const allDay = events.filter((event) => (0, _super_calendar_core.isAllDayEvent)(event) && !(0, _super_calendar_core.isBackgroundEvent)(event));
|
|
346
510
|
const perDay = days.map((day) => {
|
|
347
511
|
const start = (0, date_fns.startOfDay)(day);
|
|
348
512
|
const next = (0, date_fns.addDays)(start, 1);
|
|
@@ -420,34 +584,72 @@ const MOVE_ACTIVATE_MS$1 = 500;
|
|
|
420
584
|
const DRAG_ACTIVATE_PX$1 = 8;
|
|
421
585
|
const RESIZE_HANDLE_HEIGHT = 14;
|
|
422
586
|
const DEFAULT_DRAG_STEP_MINUTES = 15;
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
587
|
+
const DRAG_EVENT_Z = 100;
|
|
588
|
+
const EDGE_DWELL_MS = 500;
|
|
589
|
+
const EDGE_ZONE_PX = 36;
|
|
590
|
+
const EdgePagingContext = (0, react.createContext)(null);
|
|
591
|
+
const noop = () => {};
|
|
592
|
+
/**
|
|
593
|
+
* The floating copy of a dragged event, rendered above the pager so a cross-week
|
|
594
|
+
* drag stays visible after its source page pages away. Position, size, and
|
|
595
|
+
* visibility are driven on the UI thread by the shared values so it tracks the
|
|
596
|
+
* finger without a React re-render.
|
|
597
|
+
*/
|
|
598
|
+
function DragGhost({ x, y, w, h, visible, event, mode, renderEvent }) {
|
|
599
|
+
const RenderEventComponent = renderEvent;
|
|
600
|
+
const style = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
601
|
+
transform: [{ translateX: x.value }, { translateY: y.value }],
|
|
602
|
+
width: w.value,
|
|
603
|
+
height: h.value,
|
|
604
|
+
opacity: visible.value
|
|
605
|
+
}));
|
|
606
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
607
|
+
style: [
|
|
608
|
+
styles$1.eventBox,
|
|
609
|
+
styles$1.dragGhost,
|
|
610
|
+
style
|
|
611
|
+
],
|
|
612
|
+
pointerEvents: "none",
|
|
613
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
614
|
+
event,
|
|
615
|
+
mode,
|
|
616
|
+
boxHeight: h,
|
|
617
|
+
onPress: noop
|
|
618
|
+
})
|
|
619
|
+
});
|
|
434
620
|
}
|
|
435
|
-
|
|
621
|
+
const HOUR_LABEL_TOP_INSET = 12;
|
|
622
|
+
function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWidth, dayIndex, dayCount, dayOrdinals, mode, daysPerPage, renderEvent, snapMinutes, onPress, onLongPress, onDragEvent, onDragStart, onEdgeAdvance, showDragHandle }) {
|
|
436
623
|
const RenderEventComponent = renderEvent;
|
|
437
624
|
const theme = require_MonthList.useCalendarTheme();
|
|
438
625
|
const slot = require_MonthList.useSlots();
|
|
439
|
-
const
|
|
626
|
+
const edgePaging = (0, react.useContext)(EdgePagingContext);
|
|
627
|
+
const pagerLeftSV = edgePaging?.pagerLeft;
|
|
628
|
+
const pagerTopSV = edgePaging?.pagerTop;
|
|
629
|
+
const pagerWidthSV = edgePaging?.pagerWidth;
|
|
630
|
+
const ghostXSV = edgePaging?.ghostX;
|
|
631
|
+
const ghostYSV = edgePaging?.ghostY;
|
|
632
|
+
const commitLiftedDrop = edgePaging?.commitLiftedDrop;
|
|
633
|
+
const draggable = onDragEvent != null && !positioned.event.disabled && positioned.event.draggable !== false;
|
|
440
634
|
const resizable = draggable && !positioned.continuesAfter;
|
|
441
635
|
const moveOffset = (0, react_native_reanimated.useSharedValue)(0);
|
|
442
636
|
const moveOffsetX = (0, react_native_reanimated.useSharedValue)(0);
|
|
443
637
|
const resizeDelta = (0, react_native_reanimated.useSharedValue)(0);
|
|
638
|
+
const dragZ = (0, react_native_reanimated.useSharedValue)(0);
|
|
639
|
+
const edgeDir = (0, react_native_reanimated.useSharedValue)(0);
|
|
640
|
+
const lifted = (0, react_native_reanimated.useSharedValue)(0);
|
|
641
|
+
const grabX = (0, react_native_reanimated.useSharedValue)(0);
|
|
642
|
+
const grabY = (0, react_native_reanimated.useSharedValue)(0);
|
|
643
|
+
const liveAbsX = (0, react_native_reanimated.useSharedValue)(0);
|
|
644
|
+
const liveAbsY = (0, react_native_reanimated.useSharedValue)(0);
|
|
444
645
|
const startHours = positioned.startHours;
|
|
445
646
|
const durationHours = positioned.durationHours;
|
|
446
647
|
const boxHeight = (0, react_native_reanimated.useDerivedValue)(() => Math.max(durationHours * cellHeight.value + resizeDelta.value, MIN_EVENT_HEIGHT), [durationHours]);
|
|
447
648
|
const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
448
649
|
top: (startHours - minHour) * cellHeight.value + moveOffset.value,
|
|
449
650
|
height: boxHeight.value,
|
|
450
|
-
transform: [{ translateX: moveOffsetX.value }]
|
|
651
|
+
transform: [{ translateX: moveOffsetX.value }],
|
|
652
|
+
zIndex: dragZ.value
|
|
451
653
|
}), [
|
|
452
654
|
startHours,
|
|
453
655
|
durationHours,
|
|
@@ -496,16 +698,81 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
496
698
|
const notifyDragStart = (0, react.useCallback)(() => {
|
|
497
699
|
latest.current.onDragStart?.(latest.current.event);
|
|
498
700
|
}, []);
|
|
701
|
+
const dwellTimer = (0, react.useRef)(null);
|
|
702
|
+
const disarmEdge = (0, react.useCallback)(() => {
|
|
703
|
+
if (dwellTimer.current) {
|
|
704
|
+
clearTimeout(dwellTimer.current);
|
|
705
|
+
dwellTimer.current = null;
|
|
706
|
+
}
|
|
707
|
+
}, []);
|
|
708
|
+
const releaseEdge = (0, react.useCallback)(() => {
|
|
709
|
+
disarmEdge();
|
|
710
|
+
edgePaging?.lockScroll(false);
|
|
711
|
+
}, [disarmEdge, edgePaging]);
|
|
712
|
+
const armEdge = (0, react.useCallback)((dir) => {
|
|
713
|
+
disarmEdge();
|
|
714
|
+
dwellTimer.current = setTimeout(() => {
|
|
715
|
+
dwellTimer.current = null;
|
|
716
|
+
if (!edgePaging) return;
|
|
717
|
+
edgePaging.lockScroll(true);
|
|
718
|
+
if (!lifted.value) {
|
|
719
|
+
lifted.value = 1;
|
|
720
|
+
edgePaging.ghostW.value = width;
|
|
721
|
+
edgePaging.ghostH.value = boxHeight.value;
|
|
722
|
+
edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
|
|
723
|
+
edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
|
|
724
|
+
edgePaging.ghostVisible.value = 1;
|
|
725
|
+
edgePaging.beginLift(latest.current.event);
|
|
726
|
+
}
|
|
727
|
+
onEdgeAdvance?.(dir);
|
|
728
|
+
}, EDGE_DWELL_MS);
|
|
729
|
+
}, [
|
|
730
|
+
disarmEdge,
|
|
731
|
+
edgePaging,
|
|
732
|
+
lifted,
|
|
733
|
+
width,
|
|
734
|
+
boxHeight,
|
|
735
|
+
liveAbsX,
|
|
736
|
+
liveAbsY,
|
|
737
|
+
grabX,
|
|
738
|
+
grabY,
|
|
739
|
+
onEdgeAdvance
|
|
740
|
+
]);
|
|
499
741
|
const moveGesture = (0, react.useMemo)(() => {
|
|
500
|
-
const pan = react_native_gesture_handler.Gesture.Pan().enabled(draggable).onStart(() => {
|
|
742
|
+
const pan = react_native_gesture_handler.Gesture.Pan().enabled(draggable).onStart((event) => {
|
|
743
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
744
|
+
edgeDir.value = 0;
|
|
745
|
+
lifted.value = 0;
|
|
746
|
+
grabX.value = event.x;
|
|
747
|
+
grabY.value = event.y;
|
|
748
|
+
liveAbsX.value = event.absoluteX;
|
|
749
|
+
liveAbsY.value = event.absoluteY;
|
|
501
750
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
502
751
|
}).onUpdate((event) => {
|
|
503
|
-
|
|
504
|
-
|
|
752
|
+
liveAbsX.value = event.absoluteX;
|
|
753
|
+
liveAbsY.value = event.absoluteY;
|
|
754
|
+
if (lifted.value && pagerLeftSV && pagerTopSV && ghostXSV && ghostYSV) {
|
|
755
|
+
ghostXSV.value = event.absoluteX - grabX.value - pagerLeftSV.value;
|
|
756
|
+
ghostYSV.value = event.absoluteY - grabY.value - pagerTopSV.value;
|
|
757
|
+
} else {
|
|
758
|
+
moveOffset.value = event.translationY;
|
|
759
|
+
moveOffsetX.value = event.translationX;
|
|
760
|
+
}
|
|
761
|
+
if (onEdgeAdvance && pagerLeftSV && pagerWidthSV) {
|
|
762
|
+
const fx = event.absoluteX - pagerLeftSV.value;
|
|
763
|
+
const dir = fx > pagerWidthSV.value - EDGE_ZONE_PX ? 1 : fx < EDGE_ZONE_PX ? -1 : 0;
|
|
764
|
+
if (dir !== edgeDir.value) {
|
|
765
|
+
edgeDir.value = dir;
|
|
766
|
+
if (dir === 0) (0, react_native_reanimated.runOnJS)(disarmEdge)();
|
|
767
|
+
else (0, react_native_reanimated.runOnJS)(armEdge)(dir);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
505
770
|
}).onEnd((event) => {
|
|
771
|
+
if (lifted.value) return;
|
|
506
772
|
const minuteDelta = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
|
|
507
773
|
const rawDayDelta = dayWidth > 0 ? Math.round(event.translationX / dayWidth) : 0;
|
|
508
|
-
const
|
|
774
|
+
const targetDay = Math.min(Math.max(dayIndex + rawDayDelta, 0), dayCount - 1);
|
|
775
|
+
const dayDelta = targetDay - dayIndex;
|
|
509
776
|
if (minuteDelta === 0 && dayDelta === 0) {
|
|
510
777
|
moveOffset.value = 0;
|
|
511
778
|
moveOffsetX.value = 0;
|
|
@@ -513,8 +780,17 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
513
780
|
}
|
|
514
781
|
moveOffset.value = minuteDelta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
515
782
|
moveOffsetX.value = dayDelta * dayWidth;
|
|
516
|
-
const totalDelta = minuteDelta +
|
|
783
|
+
const totalDelta = minuteDelta + (dayOrdinals[targetDay] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
517
784
|
(0, react_native_reanimated.runOnJS)(commitDrag)(totalDelta, totalDelta);
|
|
785
|
+
}).onFinalize(() => {
|
|
786
|
+
dragZ.value = 0;
|
|
787
|
+
if (lifted.value && ghostXSV && ghostYSV && commitLiftedDrop) {
|
|
788
|
+
(0, react_native_reanimated.runOnJS)(commitLiftedDrop)(ghostXSV.value, ghostYSV.value);
|
|
789
|
+
moveOffset.value = 0;
|
|
790
|
+
moveOffsetX.value = 0;
|
|
791
|
+
lifted.value = 0;
|
|
792
|
+
}
|
|
793
|
+
(0, react_native_reanimated.runOnJS)(releaseEdge)();
|
|
518
794
|
});
|
|
519
795
|
return isWeb$1 ? pan.activeOffsetX([-8, DRAG_ACTIVATE_PX$1]).activeOffsetY([-8, DRAG_ACTIVATE_PX$1]) : pan.activateAfterLongPress(MOVE_ACTIVATE_MS$1);
|
|
520
796
|
}, [
|
|
@@ -523,13 +799,32 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
523
799
|
cellHeight,
|
|
524
800
|
moveOffset,
|
|
525
801
|
moveOffsetX,
|
|
802
|
+
dragZ,
|
|
803
|
+
edgeDir,
|
|
804
|
+
lifted,
|
|
805
|
+
grabX,
|
|
806
|
+
grabY,
|
|
807
|
+
liveAbsX,
|
|
808
|
+
liveAbsY,
|
|
809
|
+
pagerLeftSV,
|
|
810
|
+
pagerTopSV,
|
|
811
|
+
pagerWidthSV,
|
|
812
|
+
ghostXSV,
|
|
813
|
+
ghostYSV,
|
|
814
|
+
commitLiftedDrop,
|
|
526
815
|
dayWidth,
|
|
527
816
|
dayIndex,
|
|
528
817
|
dayCount,
|
|
818
|
+
dayOrdinals,
|
|
529
819
|
commitDrag,
|
|
530
|
-
notifyDragStart
|
|
820
|
+
notifyDragStart,
|
|
821
|
+
onEdgeAdvance,
|
|
822
|
+
armEdge,
|
|
823
|
+
disarmEdge,
|
|
824
|
+
releaseEdge
|
|
531
825
|
]);
|
|
532
826
|
const resizeGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(resizable).onStart(() => {
|
|
827
|
+
dragZ.value = DRAG_EVENT_Z;
|
|
533
828
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
534
829
|
}).onUpdate((event) => {
|
|
535
830
|
resizeDelta.value = event.translationY;
|
|
@@ -541,17 +836,21 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
541
836
|
}
|
|
542
837
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
543
838
|
(0, react_native_reanimated.runOnJS)(commitDrag)(0, delta);
|
|
839
|
+
}).onFinalize(() => {
|
|
840
|
+
dragZ.value = 0;
|
|
544
841
|
}), [
|
|
545
842
|
resizable,
|
|
546
843
|
snapMinutes,
|
|
547
844
|
cellHeight,
|
|
548
845
|
resizeDelta,
|
|
846
|
+
dragZ,
|
|
549
847
|
commitDrag,
|
|
550
848
|
notifyDragStart
|
|
551
849
|
]);
|
|
552
850
|
const handlePress = () => onPress(positioned.event);
|
|
553
851
|
const handleLongPress = !draggable && onLongPress ? () => onLongPress(positioned.event) : void 0;
|
|
554
852
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
853
|
+
const pageUnit = mode === "week" ? "week" : daysPerPage === 1 ? "day" : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
|
|
555
854
|
const accessibilityActions = draggable ? [
|
|
556
855
|
{
|
|
557
856
|
name: "move-later",
|
|
@@ -567,7 +866,15 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
567
866
|
}, {
|
|
568
867
|
name: "shrink",
|
|
569
868
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
570
|
-
}] : []
|
|
869
|
+
}] : [],
|
|
870
|
+
{
|
|
871
|
+
name: "move-next-page",
|
|
872
|
+
label: `Move to next ${pageUnit}`
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
name: "move-previous-page",
|
|
876
|
+
label: `Move to previous ${pageUnit}`
|
|
877
|
+
}
|
|
571
878
|
] : void 0;
|
|
572
879
|
const handleAccessibilityAction = draggable ? (e) => {
|
|
573
880
|
switch (e.nativeEvent.actionName) {
|
|
@@ -583,6 +890,12 @@ function AnimatedEventBox({ positioned, cellHeight, minHour, left, width, dayWid
|
|
|
583
890
|
case "shrink":
|
|
584
891
|
commitDrag(0, -snapMinutes);
|
|
585
892
|
break;
|
|
893
|
+
case "move-next-page":
|
|
894
|
+
commitDrag(daysPerPage * MINUTES_PER_DAY, daysPerPage * MINUTES_PER_DAY);
|
|
895
|
+
break;
|
|
896
|
+
case "move-previous-page":
|
|
897
|
+
commitDrag(-daysPerPage * MINUTES_PER_DAY, -daysPerPage * MINUTES_PER_DAY);
|
|
898
|
+
break;
|
|
586
899
|
}
|
|
587
900
|
} : void 0;
|
|
588
901
|
const eventSlot = slot("event", {
|
|
@@ -686,7 +999,7 @@ const NowIndicator = ({ cellHeight, nowHours, minHour, left, width, color }) =>
|
|
|
686
999
|
style: [lineSlot.style, animatedStyle]
|
|
687
1000
|
});
|
|
688
1001
|
};
|
|
689
|
-
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color }) => {
|
|
1002
|
+
const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color, slotName = "businessHours", testID = "business-hours-shade", children }) => {
|
|
690
1003
|
const slot = require_MonthList.useSlots();
|
|
691
1004
|
const animatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({
|
|
692
1005
|
top: (startHour - minHour) * cellHeight.value,
|
|
@@ -696,7 +1009,7 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
696
1009
|
endHour,
|
|
697
1010
|
minHour
|
|
698
1011
|
]);
|
|
699
|
-
const bandSlot = slot(
|
|
1012
|
+
const bandSlot = slot(slotName, {
|
|
700
1013
|
base: [
|
|
701
1014
|
styles$1.shadeBand,
|
|
702
1015
|
styles$1.nonInteractive,
|
|
@@ -705,18 +1018,25 @@ const ShadeBand = ({ cellHeight, startHour, endHour, minHour, left, width, color
|
|
|
705
1018
|
width
|
|
706
1019
|
}
|
|
707
1020
|
],
|
|
708
|
-
themed: { backgroundColor: color }
|
|
1021
|
+
themed: color === void 0 ? void 0 : { backgroundColor: color }
|
|
709
1022
|
});
|
|
710
1023
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
711
|
-
testID
|
|
1024
|
+
testID,
|
|
1025
|
+
accessibilityElementsHidden: true,
|
|
1026
|
+
importantForAccessibility: "no-hide-descendants",
|
|
712
1027
|
...bandSlot,
|
|
713
|
-
style: [bandSlot.style, animatedStyle]
|
|
1028
|
+
style: [bandSlot.style, animatedStyle],
|
|
1029
|
+
children
|
|
714
1030
|
});
|
|
715
1031
|
};
|
|
716
|
-
function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent }) {
|
|
1032
|
+
function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowTimeZone, date, events, cellHeight, hourHeight, committedCellHeight, scrollY, isActive, initialScrollY, onSettleOffset, weekStartsOn, weekEndsOn, width, hourColumnWidth, minHour, maxHour, ampm, timeslots, isRTL, showAllDayEventCell, highlightWeekends, showVerticalScrollIndicator, verticalScrollEnabled, hourComponent, calendarCellStyle, minHourHeight, maxHourHeight, showNowIndicator, businessHours, renderBusinessHours, renderEvent, keyExtractor, snapMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onEdgeAdvance, onGridTop }) {
|
|
717
1033
|
const theme = require_MonthList.useCalendarTheme();
|
|
718
1034
|
const slot = require_MonthList.useSlots();
|
|
719
1035
|
const scrollRef = (0, react_native_reanimated.useAnimatedRef)();
|
|
1036
|
+
const gridTopRef = (0, react.useRef)(0);
|
|
1037
|
+
(0, react.useEffect)(() => {
|
|
1038
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1039
|
+
}, [isActive, onGridTop]);
|
|
720
1040
|
const heightSource = isActive ? cellHeight : committedCellHeight;
|
|
721
1041
|
const isDragging = (0, react_native_reanimated.useSharedValue)(false);
|
|
722
1042
|
const isActiveShared = (0, react_native_reanimated.useSharedValue)(isActive);
|
|
@@ -752,17 +1072,20 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
752
1072
|
if (isWeb$1 || !active || active === previous) return;
|
|
753
1073
|
(0, react_native_reanimated.scrollTo)(scrollRef, 0, scrollY.value, false);
|
|
754
1074
|
});
|
|
755
|
-
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1075
|
+
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
756
1076
|
mode,
|
|
757
1077
|
date,
|
|
758
1078
|
weekStartsOn,
|
|
759
1079
|
numberOfDays,
|
|
760
1080
|
isRTL,
|
|
761
|
-
weekEndsOn
|
|
1081
|
+
weekEndsOn,
|
|
1082
|
+
hiddenDays
|
|
762
1083
|
]);
|
|
1084
|
+
const daysPerPage = (0, _super_calendar_core.pageStepDays)(mode, date, weekStartsOn, numberOfDays);
|
|
763
1085
|
const dayCount = days.length;
|
|
764
1086
|
const dayWidth = (width - hourColumnWidth) / dayCount;
|
|
765
1087
|
const dayLeft = (dayIndex) => hourColumnWidth + dayIndex * dayWidth;
|
|
1088
|
+
const dayOrdinals = (0, react.useMemo)(() => days.map((day) => (0, date_fns.differenceInCalendarDays)(day, days[0])), [days]);
|
|
766
1089
|
const dayLayouts = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
|
|
767
1090
|
const cellDateFromTouch = (event) => {
|
|
768
1091
|
const { locationX, locationY } = event.nativeEvent;
|
|
@@ -784,8 +1107,11 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
784
1107
|
if (date) onLongPressCell?.(date);
|
|
785
1108
|
};
|
|
786
1109
|
const hoursRange = (0, react.useMemo)(() => Array.from({ length: maxHour - minHour }, (_, index) => minHour + index), [minHour, maxHour]);
|
|
787
|
-
const now = useNow(showNowIndicator && isActive
|
|
788
|
-
|
|
1110
|
+
const now = (0, _super_calendar_core.useNow)(showNowIndicator && isActive, {
|
|
1111
|
+
now: nowProp,
|
|
1112
|
+
timeZone: nowTimeZone
|
|
1113
|
+
});
|
|
1114
|
+
const nowDayIndex = days.findIndex((day) => (0, _super_calendar_core.isSameCalendarDay)(day, now));
|
|
789
1115
|
const nowHours = ((0, date_fns.getHours)(now) * MINUTES_PER_HOUR$1 + (0, date_fns.getMinutes)(now)) / MINUTES_PER_HOUR$1;
|
|
790
1116
|
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
791
1117
|
const fullHeightStyle = (0, react_native_reanimated.useAnimatedStyle)(() => ({ height: (maxHour - minHour) * heightSource.value }), [
|
|
@@ -963,6 +1289,10 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
963
1289
|
scrollEnabled: verticalScrollEnabled,
|
|
964
1290
|
onScroll: scrollHandler,
|
|
965
1291
|
scrollEventThrottle: 16,
|
|
1292
|
+
onLayout: (event) => {
|
|
1293
|
+
gridTopRef.current = event.nativeEvent.layout.y;
|
|
1294
|
+
if (isActive) onGridTop?.(gridTopRef.current);
|
|
1295
|
+
},
|
|
966
1296
|
contentContainerStyle: { paddingTop: HOUR_LABEL_TOP_INSET },
|
|
967
1297
|
contentOffset: {
|
|
968
1298
|
x: 0,
|
|
@@ -976,7 +1306,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
976
1306
|
children: cellLayer
|
|
977
1307
|
}) : cellLayer,
|
|
978
1308
|
days.map((day, dayIndex) => {
|
|
979
|
-
if (!(0, _super_calendar_core.isWeekend)(day)) return null;
|
|
1309
|
+
if (!highlightWeekends || !(0, _super_calendar_core.isWeekend)(day)) return null;
|
|
980
1310
|
const shadeSlot = slot("weekendShade", {
|
|
981
1311
|
base: [
|
|
982
1312
|
styles$1.weekendColumn,
|
|
@@ -989,6 +1319,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
989
1319
|
themed: { backgroundColor: theme.colors.weekendBackground }
|
|
990
1320
|
});
|
|
991
1321
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
1322
|
+
testID: "weekend-shade",
|
|
992
1323
|
...shadeSlot,
|
|
993
1324
|
style: [shadeSlot.style, fullHeightStyle]
|
|
994
1325
|
}, `weekend-${day.toISOString()}`);
|
|
@@ -1013,8 +1344,28 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1013
1344
|
minHour,
|
|
1014
1345
|
left: dayLeft(dayIndex),
|
|
1015
1346
|
width: dayWidth,
|
|
1016
|
-
color: theme.colors.outsideHoursBackground
|
|
1347
|
+
color: renderBusinessHours ? void 0 : theme.colors.outsideHoursBackground,
|
|
1348
|
+
children: renderBusinessHours?.({
|
|
1349
|
+
date: day,
|
|
1350
|
+
start: band.start,
|
|
1351
|
+
end: band.end
|
|
1352
|
+
})
|
|
1017
1353
|
}, `closed-${day.toISOString()}-${bandIndex}`))) : null,
|
|
1354
|
+
days.flatMap((day, dayIndex) => (0, _super_calendar_core.backgroundBandsForDay)(events, day).map((b) => ({
|
|
1355
|
+
...b,
|
|
1356
|
+
startHours: Math.max(b.startHours, minHour),
|
|
1357
|
+
endHours: Math.min(b.endHours, maxHour)
|
|
1358
|
+
})).filter((b) => b.endHours > b.startHours).map((b, bandIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShadeBand, {
|
|
1359
|
+
cellHeight: heightSource,
|
|
1360
|
+
startHour: b.startHours,
|
|
1361
|
+
endHour: b.endHours,
|
|
1362
|
+
minHour,
|
|
1363
|
+
left: dayLeft(dayIndex),
|
|
1364
|
+
width: dayWidth,
|
|
1365
|
+
color: theme.colors.backgroundEvent,
|
|
1366
|
+
slotName: "backgroundEvent",
|
|
1367
|
+
testID: "background-event-shade"
|
|
1368
|
+
}, `bg-${day.toISOString()}-${bandIndex}`))),
|
|
1018
1369
|
days.map((day, dayIndex) => {
|
|
1019
1370
|
const separatorSlot = slot("daySeparator", {
|
|
1020
1371
|
base: [
|
|
@@ -1056,14 +1407,17 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1056
1407
|
dayWidth,
|
|
1057
1408
|
dayIndex,
|
|
1058
1409
|
dayCount: days.length,
|
|
1410
|
+
dayOrdinals,
|
|
1059
1411
|
mode,
|
|
1412
|
+
daysPerPage,
|
|
1060
1413
|
renderEvent,
|
|
1061
1414
|
snapMinutes,
|
|
1062
1415
|
showDragHandle,
|
|
1063
1416
|
onPress: onPressEvent,
|
|
1064
1417
|
onLongPress: onLongPressEvent,
|
|
1065
1418
|
onDragEvent,
|
|
1066
|
-
onDragStart
|
|
1419
|
+
onDragStart,
|
|
1420
|
+
onEdgeAdvance
|
|
1067
1421
|
}, `${dayIndex}:${keyExtractor(positioned.event, eventIndex)}`);
|
|
1068
1422
|
})),
|
|
1069
1423
|
showNowIndicator && nowDayIndex >= 0 && nowInWindow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NowIndicator, {
|
|
@@ -1085,7 +1439,7 @@ function TimetablePageInner({ mode, numberOfDays, date, events, cellHeight, hour
|
|
|
1085
1439
|
});
|
|
1086
1440
|
}
|
|
1087
1441
|
const TimetablePage = (0, react.memo)(TimetablePageInner);
|
|
1088
|
-
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, calendarCellStyle, businessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
1442
|
+
function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellHeight, hourHeight = 48, weekStartsOn, weekdayFormat = "short", renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes = 0, hourColumnWidth: hourColumnWidthProp = DEFAULT_HOUR_COLUMN_WIDTH, hideHours = false, timeslots = 1, showAllDayEventCell = true, highlightWeekends = true, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber = false, headerComponent, minHour = 0, maxHour = HOURS_PER_DAY, ampm = false, isRTL = false, minHourHeight = DEFAULT_MIN_HOUR_HEIGHT, maxHourHeight = DEFAULT_MAX_HOUR_HEIGHT, showNowIndicator = true, locale, freeSwipe = false, swipeEnabled = true, showVerticalScrollIndicator = true, verticalScrollEnabled = true, weekNumberPrefix = "W", hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell = false, dragStepMinutes = DEFAULT_DRAG_STEP_MINUTES, showDragHandle = true, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }) {
|
|
1089
1443
|
const clampedMinHour = Math.max(0, Math.min(minHour, HOURS_PER_DAY - 1));
|
|
1090
1444
|
const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
|
|
1091
1445
|
const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
|
|
@@ -1096,6 +1450,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1096
1450
|
]);
|
|
1097
1451
|
const { width, height } = (0, react_native.useWindowDimensions)();
|
|
1098
1452
|
const listRef = (0, react.useRef)(null);
|
|
1453
|
+
const pagerRef = (0, react.useRef)(null);
|
|
1099
1454
|
const containerRef = (0, react.useRef)(null);
|
|
1100
1455
|
const suppressCaptureUntilRef = (0, react.useRef)(0);
|
|
1101
1456
|
const [pageHeight, setPageHeight] = (0, react.useState)(height);
|
|
@@ -1105,6 +1460,84 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1105
1460
|
const step = weekAnchored ? 7 : (0, _super_calendar_core.viewDayCount)(mode, numberOfDays);
|
|
1106
1461
|
const seedDefaultY = Math.max(0, scrollOffsetMinutes / MINUTES_PER_HOUR$1 - clampedMinHour) * hourHeight;
|
|
1107
1462
|
const scrollY = (0, react_native_reanimated.useSharedValue)(seedDefaultY);
|
|
1463
|
+
const pagerLeft = (0, react_native_reanimated.useSharedValue)(0);
|
|
1464
|
+
const pagerTop = (0, react_native_reanimated.useSharedValue)(0);
|
|
1465
|
+
const pagerWidth = (0, react_native_reanimated.useSharedValue)(width);
|
|
1466
|
+
const [edgePagingLock, setEdgePagingLock] = (0, react.useState)(false);
|
|
1467
|
+
const ghostX = (0, react_native_reanimated.useSharedValue)(0);
|
|
1468
|
+
const ghostY = (0, react_native_reanimated.useSharedValue)(0);
|
|
1469
|
+
const ghostW = (0, react_native_reanimated.useSharedValue)(0);
|
|
1470
|
+
const ghostH = (0, react_native_reanimated.useSharedValue)(0);
|
|
1471
|
+
const ghostVisible = (0, react_native_reanimated.useSharedValue)(0);
|
|
1472
|
+
const gridTop = (0, react_native_reanimated.useSharedValue)(0);
|
|
1473
|
+
const [liftedEvent, setLiftedEvent] = (0, react.useState)(null);
|
|
1474
|
+
const liftedEventRef = (0, react.useRef)(null);
|
|
1475
|
+
const dropRef = (0, react.useRef)({
|
|
1476
|
+
headerDays: [],
|
|
1477
|
+
containerWidth,
|
|
1478
|
+
hourColumnWidth,
|
|
1479
|
+
minHour: clampedMinHour,
|
|
1480
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1481
|
+
onDragEvent,
|
|
1482
|
+
onChangeDate
|
|
1483
|
+
});
|
|
1484
|
+
const beginLift = (0, react.useCallback)((event) => {
|
|
1485
|
+
liftedEventRef.current = event;
|
|
1486
|
+
setLiftedEvent(event);
|
|
1487
|
+
}, []);
|
|
1488
|
+
const clearLift = (0, react.useCallback)(() => {
|
|
1489
|
+
ghostVisible.value = 0;
|
|
1490
|
+
liftedEventRef.current = null;
|
|
1491
|
+
setLiftedEvent(null);
|
|
1492
|
+
setEdgePagingLock(false);
|
|
1493
|
+
}, [ghostVisible]);
|
|
1494
|
+
const commitLiftedDrop = (0, react.useCallback)((ghostLocalX, ghostLocalY) => {
|
|
1495
|
+
const { headerDays: days, containerWidth: cw, hourColumnWidth: hcw, minHour: min, snapMinutes: snap, onDragEvent: onDrag, onChangeDate: onDate } = dropRef.current;
|
|
1496
|
+
const ev = liftedEventRef.current;
|
|
1497
|
+
const duration = ev ? ev.end.getTime() - ev.start.getTime() : 0;
|
|
1498
|
+
clearLift();
|
|
1499
|
+
if (!ev || !onDrag || days.length === 0) return;
|
|
1500
|
+
const dayWidth = (cw - hcw) / days.length;
|
|
1501
|
+
const col = Math.min(Math.max(Math.floor((ghostLocalX - hcw) / dayWidth), 0), days.length - 1);
|
|
1502
|
+
const rawMinutes = (min + (ghostLocalY - gridTop.value - HOUR_LABEL_TOP_INSET + scrollY.value) / cellHeight.value) * MINUTES_PER_HOUR$1;
|
|
1503
|
+
const minutes = Math.round(rawMinutes / snap) * snap;
|
|
1504
|
+
const start = new Date(days[col]);
|
|
1505
|
+
start.setHours(0, 0, 0, 0);
|
|
1506
|
+
start.setMinutes(minutes);
|
|
1507
|
+
if (onDrag(ev, start, new Date(start.getTime() + duration)) === false) onDate(ev.start);
|
|
1508
|
+
}, [
|
|
1509
|
+
clearLift,
|
|
1510
|
+
gridTop,
|
|
1511
|
+
scrollY,
|
|
1512
|
+
cellHeight
|
|
1513
|
+
]);
|
|
1514
|
+
const handleGridTop = (0, react.useCallback)((y) => {
|
|
1515
|
+
gridTop.value = y;
|
|
1516
|
+
}, [gridTop]);
|
|
1517
|
+
const edgePaging = (0, react.useMemo)(() => ({
|
|
1518
|
+
pagerLeft,
|
|
1519
|
+
pagerTop,
|
|
1520
|
+
pagerWidth,
|
|
1521
|
+
lockScroll: setEdgePagingLock,
|
|
1522
|
+
ghostX,
|
|
1523
|
+
ghostY,
|
|
1524
|
+
ghostW,
|
|
1525
|
+
ghostH,
|
|
1526
|
+
ghostVisible,
|
|
1527
|
+
beginLift,
|
|
1528
|
+
commitLiftedDrop
|
|
1529
|
+
}), [
|
|
1530
|
+
pagerLeft,
|
|
1531
|
+
pagerTop,
|
|
1532
|
+
pagerWidth,
|
|
1533
|
+
ghostX,
|
|
1534
|
+
ghostY,
|
|
1535
|
+
ghostW,
|
|
1536
|
+
ghostH,
|
|
1537
|
+
ghostVisible,
|
|
1538
|
+
beginLift,
|
|
1539
|
+
commitLiftedDrop
|
|
1540
|
+
]);
|
|
1108
1541
|
const offsetSeedRef = (0, react.useRef)(null);
|
|
1109
1542
|
const captureOffsetSeed = (0, react.useCallback)((y) => {
|
|
1110
1543
|
offsetSeedRef.current = y;
|
|
@@ -1129,7 +1562,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1129
1562
|
])(date);
|
|
1130
1563
|
const viewedIndexRef = (0, react.useRef)(activeIndex);
|
|
1131
1564
|
const pendingScrollIndexRef = (0, react.useRef)(null);
|
|
1132
|
-
const headerDays = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn), [
|
|
1565
|
+
const headerDays = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, pageDates[activeIndex] ?? date, weekStartsOn, numberOfDays, isRTL, weekEndsOn, hiddenDays), [
|
|
1133
1566
|
mode,
|
|
1134
1567
|
pageDates,
|
|
1135
1568
|
activeIndex,
|
|
@@ -1137,8 +1570,18 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1137
1570
|
weekStartsOn,
|
|
1138
1571
|
numberOfDays,
|
|
1139
1572
|
isRTL,
|
|
1140
|
-
weekEndsOn
|
|
1573
|
+
weekEndsOn,
|
|
1574
|
+
hiddenDays
|
|
1141
1575
|
]);
|
|
1576
|
+
dropRef.current = {
|
|
1577
|
+
headerDays,
|
|
1578
|
+
containerWidth,
|
|
1579
|
+
hourColumnWidth,
|
|
1580
|
+
minHour: clampedMinHour,
|
|
1581
|
+
snapMinutes: Math.max(1, dragStepMinutes),
|
|
1582
|
+
onDragEvent,
|
|
1583
|
+
onChangeDate
|
|
1584
|
+
};
|
|
1142
1585
|
const handleViewableItemsChanged = (0, react.useCallback)((info) => {
|
|
1143
1586
|
if (isWeb$1) return;
|
|
1144
1587
|
const settled = info.viewableItems.find((token) => token.isViewable);
|
|
@@ -1224,14 +1667,15 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1224
1667
|
const raf = requestAnimationFrame(lockHorizontal);
|
|
1225
1668
|
return () => cancelAnimationFrame(raf);
|
|
1226
1669
|
}, [pageHeight]);
|
|
1227
|
-
|
|
1670
|
+
const goToPage = (0, react.useCallback)((delta) => {
|
|
1228
1671
|
const target = pageDates[activeIndex + delta];
|
|
1229
1672
|
if (target) onChangeDate(target);
|
|
1230
1673
|
}, [
|
|
1231
1674
|
pageDates,
|
|
1232
1675
|
activeIndex,
|
|
1233
1676
|
onChangeDate
|
|
1234
|
-
])
|
|
1677
|
+
]);
|
|
1678
|
+
require_MonthList.useWebPagerKeys(swipeEnabled, goToPage);
|
|
1235
1679
|
const reduceMotion = (0, react_native_reanimated.useReducedMotion)();
|
|
1236
1680
|
const handlePressCell = (0, react.useMemo)(() => {
|
|
1237
1681
|
if (!onPressCell) return void 0;
|
|
@@ -1260,6 +1704,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1260
1704
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimetablePage, {
|
|
1261
1705
|
mode,
|
|
1262
1706
|
numberOfDays,
|
|
1707
|
+
hiddenDays,
|
|
1708
|
+
now,
|
|
1709
|
+
nowTimeZone: timeZone,
|
|
1263
1710
|
date: item,
|
|
1264
1711
|
width: containerWidth,
|
|
1265
1712
|
events,
|
|
@@ -1279,11 +1726,13 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1279
1726
|
timeslots,
|
|
1280
1727
|
isRTL,
|
|
1281
1728
|
showAllDayEventCell,
|
|
1729
|
+
highlightWeekends,
|
|
1282
1730
|
showVerticalScrollIndicator,
|
|
1283
1731
|
verticalScrollEnabled,
|
|
1284
1732
|
hourComponent,
|
|
1285
1733
|
calendarCellStyle,
|
|
1286
1734
|
businessHours,
|
|
1735
|
+
renderBusinessHours,
|
|
1287
1736
|
minHourHeight,
|
|
1288
1737
|
maxHourHeight,
|
|
1289
1738
|
showNowIndicator,
|
|
@@ -1297,11 +1746,14 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1297
1746
|
onDragStart,
|
|
1298
1747
|
onPressCell: handlePressCell,
|
|
1299
1748
|
onLongPressCell,
|
|
1300
|
-
onCreateEvent
|
|
1749
|
+
onCreateEvent,
|
|
1750
|
+
onEdgeAdvance: goToPage,
|
|
1751
|
+
onGridTop: handleGridTop
|
|
1301
1752
|
})
|
|
1302
1753
|
}), [
|
|
1303
1754
|
containerWidth,
|
|
1304
1755
|
pageHeight,
|
|
1756
|
+
handleGridTop,
|
|
1305
1757
|
mode,
|
|
1306
1758
|
numberOfDays,
|
|
1307
1759
|
events,
|
|
@@ -1321,6 +1773,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1321
1773
|
timeslots,
|
|
1322
1774
|
isRTL,
|
|
1323
1775
|
showAllDayEventCell,
|
|
1776
|
+
highlightWeekends,
|
|
1324
1777
|
showVerticalScrollIndicator,
|
|
1325
1778
|
verticalScrollEnabled,
|
|
1326
1779
|
hourComponent,
|
|
@@ -1339,7 +1792,11 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1339
1792
|
onDragStart,
|
|
1340
1793
|
handlePressCell,
|
|
1341
1794
|
onLongPressCell,
|
|
1342
|
-
onCreateEvent
|
|
1795
|
+
onCreateEvent,
|
|
1796
|
+
goToPage,
|
|
1797
|
+
hiddenDays,
|
|
1798
|
+
now,
|
|
1799
|
+
timeZone
|
|
1343
1800
|
]);
|
|
1344
1801
|
const listExtraData = (0, react.useMemo)(() => ({
|
|
1345
1802
|
events,
|
|
@@ -1348,52 +1805,70 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
1348
1805
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MonthList.SlotStylesProvider, {
|
|
1349
1806
|
classNames,
|
|
1350
1807
|
styles: styleOverrides,
|
|
1351
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
keyExtractor: keyExtractorList,
|
|
1383
|
-
getFixedItemSize,
|
|
1384
|
-
...isWeb$1 ? null : {
|
|
1385
|
-
scrollEnabled: swipeEnabled,
|
|
1386
|
-
pagingEnabled: !freeSwipe,
|
|
1387
|
-
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1808
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EdgePagingContext.Provider, {
|
|
1809
|
+
value: edgePaging,
|
|
1810
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
1811
|
+
ref: containerRef,
|
|
1812
|
+
style: styles$1.container,
|
|
1813
|
+
children: [
|
|
1814
|
+
renderHeader ? renderHeader(headerDays) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultHeader, {
|
|
1815
|
+
days: headerDays,
|
|
1816
|
+
mode,
|
|
1817
|
+
width: containerWidth,
|
|
1818
|
+
hourColumnWidth,
|
|
1819
|
+
showWeekNumber,
|
|
1820
|
+
weekNumberPrefix,
|
|
1821
|
+
weekdayFormat,
|
|
1822
|
+
locale,
|
|
1823
|
+
activeDate,
|
|
1824
|
+
onPressDateHeader
|
|
1825
|
+
}),
|
|
1826
|
+
headerComponent,
|
|
1827
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
1828
|
+
ref: pagerRef,
|
|
1829
|
+
style: styles$1.pager,
|
|
1830
|
+
onLayout: (event) => {
|
|
1831
|
+
setPageHeight(event.nativeEvent.layout.height);
|
|
1832
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
1833
|
+
setMeasured(true);
|
|
1834
|
+
pagerRef.current?.measureInWindow((x, y, w) => {
|
|
1835
|
+
pagerLeft.value = x;
|
|
1836
|
+
pagerTop.value = y;
|
|
1837
|
+
pagerWidth.value = w;
|
|
1838
|
+
});
|
|
1388
1839
|
},
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1840
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_legendapp_list_react_native.LegendList, {
|
|
1841
|
+
ref: listRef,
|
|
1842
|
+
style: isWeb$1 ? [styles$1.pagerList, styles$1.webNoScroll] : styles$1.pagerList,
|
|
1843
|
+
data: pageDates,
|
|
1844
|
+
extraData: listExtraData,
|
|
1845
|
+
horizontal: true,
|
|
1846
|
+
recycleItems: false,
|
|
1847
|
+
keyExtractor: keyExtractorList,
|
|
1848
|
+
getFixedItemSize,
|
|
1849
|
+
...isWeb$1 ? null : {
|
|
1850
|
+
scrollEnabled: swipeEnabled && !edgePagingLock,
|
|
1851
|
+
pagingEnabled: !freeSwipe,
|
|
1852
|
+
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1853
|
+
},
|
|
1854
|
+
initialScrollIndex: activeIndex,
|
|
1855
|
+
showsHorizontalScrollIndicator: false,
|
|
1856
|
+
viewabilityConfig: PAGE_VIEWABILITY,
|
|
1857
|
+
onViewableItemsChanged: handleViewableItemsChanged,
|
|
1858
|
+
renderItem
|
|
1859
|
+
}, measured ? "grid" : "grid-seed"), liftedEvent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DragGhost, {
|
|
1860
|
+
x: ghostX,
|
|
1861
|
+
y: ghostY,
|
|
1862
|
+
w: ghostW,
|
|
1863
|
+
h: ghostH,
|
|
1864
|
+
visible: ghostVisible,
|
|
1865
|
+
event: liftedEvent,
|
|
1866
|
+
mode,
|
|
1867
|
+
renderEvent: labeledRenderEvent
|
|
1868
|
+
}) : null]
|
|
1869
|
+
})
|
|
1870
|
+
]
|
|
1871
|
+
})
|
|
1397
1872
|
})
|
|
1398
1873
|
});
|
|
1399
1874
|
}
|
|
@@ -1577,6 +2052,11 @@ const styles$1 = react_native.StyleSheet.create({
|
|
|
1577
2052
|
overflow: "hidden",
|
|
1578
2053
|
padding: EVENT_GAP
|
|
1579
2054
|
},
|
|
2055
|
+
dragGhost: {
|
|
2056
|
+
top: 0,
|
|
2057
|
+
left: 0,
|
|
2058
|
+
zIndex: 101
|
|
2059
|
+
},
|
|
1580
2060
|
nowIndicator: {
|
|
1581
2061
|
position: "absolute",
|
|
1582
2062
|
height: 2
|
|
@@ -1589,11 +2069,13 @@ const styles$1 = react_native.StyleSheet.create({
|
|
|
1589
2069
|
const defaultKeyExtractor = (event) => `${event.start.toISOString()}|${event.end.toISOString()}|${event.title ?? ""}`;
|
|
1590
2070
|
function visibleRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
1591
2071
|
if (mode === "month") return [(0, date_fns.startOfWeek)((0, date_fns.startOfMonth)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfMonth)(date), { weekStartsOn })];
|
|
2072
|
+
if (mode === "year") return [(0, date_fns.startOfWeek)((0, date_fns.startOfYear)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfYear)(date), { weekStartsOn })];
|
|
1592
2073
|
const days = (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, false, weekEndsOn);
|
|
1593
2074
|
return [(0, date_fns.startOfDay)(days[0]), (0, date_fns.endOfDay)(days[days.length - 1])];
|
|
1594
2075
|
}
|
|
1595
2076
|
function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
1596
2077
|
if (mode === "month") return [(0, date_fns.startOfWeek)((0, date_fns.startOfMonth)((0, date_fns.addMonths)(date, -1)), { weekStartsOn }), (0, date_fns.addWeeks)((0, date_fns.endOfWeek)((0, date_fns.endOfMonth)((0, date_fns.addMonths)(date, 1)), { weekStartsOn }), 1)];
|
|
2078
|
+
if (mode === "year") return [(0, date_fns.startOfWeek)((0, date_fns.startOfYear)(date), { weekStartsOn }), (0, date_fns.endOfWeek)((0, date_fns.endOfYear)(date), { weekStartsOn })];
|
|
1597
2079
|
if (mode === "schedule") return [(0, date_fns.startOfDay)(date), (0, date_fns.endOfDay)((0, date_fns.addMonths)(date, 3))];
|
|
1598
2080
|
const days = (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, false, weekEndsOn);
|
|
1599
2081
|
const span = days.length;
|
|
@@ -1625,7 +2107,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
1625
2107
|
* }
|
|
1626
2108
|
* ```
|
|
1627
2109
|
*/
|
|
1628
|
-
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 }) {
|
|
2110
|
+
function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }) {
|
|
1629
2111
|
const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
|
|
1630
2112
|
const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
|
|
1631
2113
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -1702,6 +2184,7 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1702
2184
|
events: displayEvents,
|
|
1703
2185
|
maxVisibleEventCount,
|
|
1704
2186
|
weekStartsOn,
|
|
2187
|
+
hiddenDays,
|
|
1705
2188
|
weekdayFormat,
|
|
1706
2189
|
locale,
|
|
1707
2190
|
sortedMonthView,
|
|
@@ -1726,6 +2209,17 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1726
2209
|
swipeEnabled,
|
|
1727
2210
|
classNames,
|
|
1728
2211
|
styles: styleOverrides
|
|
2212
|
+
}) : mode === "year" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(YearView, {
|
|
2213
|
+
date,
|
|
2214
|
+
events: displayEvents,
|
|
2215
|
+
weekStartsOn,
|
|
2216
|
+
hiddenDays,
|
|
2217
|
+
locale,
|
|
2218
|
+
activeDate,
|
|
2219
|
+
onPressDay,
|
|
2220
|
+
onPressMonth,
|
|
2221
|
+
classNames,
|
|
2222
|
+
styles: styleOverrides
|
|
1729
2223
|
}) : mode === "schedule" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Agenda, {
|
|
1730
2224
|
events: displayEvents,
|
|
1731
2225
|
locale,
|
|
@@ -1748,6 +2242,9 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1748
2242
|
hourHeight,
|
|
1749
2243
|
weekStartsOn,
|
|
1750
2244
|
weekdayFormat,
|
|
2245
|
+
hiddenDays,
|
|
2246
|
+
now,
|
|
2247
|
+
timeZone,
|
|
1751
2248
|
renderEvent: resolvedRenderEvent,
|
|
1752
2249
|
keyExtractor,
|
|
1753
2250
|
scrollOffsetMinutes,
|
|
@@ -1755,8 +2252,10 @@ function Calendar({ events, mode, date, onChangeDate, onChangeDateRange, onPress
|
|
|
1755
2252
|
hideHours,
|
|
1756
2253
|
timeslots,
|
|
1757
2254
|
showAllDayEventCell,
|
|
2255
|
+
highlightWeekends,
|
|
1758
2256
|
calendarCellStyle,
|
|
1759
2257
|
businessHours,
|
|
2258
|
+
renderBusinessHours,
|
|
1760
2259
|
showWeekNumber,
|
|
1761
2260
|
weekNumberPrefix,
|
|
1762
2261
|
hourComponent,
|
|
@@ -1830,41 +2329,60 @@ function DefaultBar({ event, width, height }) {
|
|
|
1830
2329
|
}) : null]
|
|
1831
2330
|
});
|
|
1832
2331
|
}
|
|
1833
|
-
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, theme }) {
|
|
2332
|
+
function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendererSize, snapMinutes, Renderer, onPress, onLongPress, onDragEvent, resources, laneIndex, laneSize, dragActive, onDragActiveChange, theme }) {
|
|
1834
2333
|
const moveX = (0, react_native_reanimated.useSharedValue)(0);
|
|
2334
|
+
const moveCross = (0, react_native_reanimated.useSharedValue)(0);
|
|
1835
2335
|
const resizeW = (0, react_native_reanimated.useSharedValue)(0);
|
|
1836
2336
|
const latest = (0, react.useRef)({
|
|
1837
2337
|
event: pe.event,
|
|
1838
|
-
onDragEvent
|
|
2338
|
+
onDragEvent,
|
|
2339
|
+
resources,
|
|
2340
|
+
laneIndex
|
|
1839
2341
|
});
|
|
1840
2342
|
latest.current = {
|
|
1841
2343
|
event: pe.event,
|
|
1842
|
-
onDragEvent
|
|
2344
|
+
onDragEvent,
|
|
2345
|
+
resources,
|
|
2346
|
+
laneIndex
|
|
1843
2347
|
};
|
|
1844
|
-
const
|
|
2348
|
+
const laneCount = resources.length;
|
|
2349
|
+
const draggable = !pe.event.disabled && pe.event.draggable !== false;
|
|
1845
2350
|
(0, react.useEffect)(() => {
|
|
2351
|
+
if (dragActive) return;
|
|
1846
2352
|
moveX.value = 0;
|
|
2353
|
+
moveCross.value = 0;
|
|
1847
2354
|
resizeW.value = 0;
|
|
1848
2355
|
}, [
|
|
2356
|
+
dragActive,
|
|
1849
2357
|
pe.startHours,
|
|
1850
2358
|
pe.durationHours,
|
|
1851
2359
|
moveX,
|
|
2360
|
+
moveCross,
|
|
1852
2361
|
resizeW
|
|
1853
2362
|
]);
|
|
1854
2363
|
const snapBack = (0, react.useCallback)(() => {
|
|
1855
2364
|
moveX.value = 0;
|
|
2365
|
+
moveCross.value = 0;
|
|
1856
2366
|
resizeW.value = 0;
|
|
1857
|
-
}, [
|
|
1858
|
-
|
|
1859
|
-
|
|
2367
|
+
}, [
|
|
2368
|
+
moveX,
|
|
2369
|
+
moveCross,
|
|
2370
|
+
resizeW
|
|
2371
|
+
]);
|
|
2372
|
+
const commit = (0, react.useCallback)((deltaStartMin, deltaEndMin, laneDelta = 0) => {
|
|
2373
|
+
const { event, onDragEvent: handler, resources: lanes, laneIndex: lane } = latest.current;
|
|
1860
2374
|
const next = (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, deltaStartMin, deltaEndMin, snapMinutes);
|
|
1861
|
-
|
|
2375
|
+
const target = lanes[Math.min(Math.max(lane + laneDelta, 0), lanes.length - 1)];
|
|
2376
|
+
if (!next || !target) {
|
|
1862
2377
|
snapBack();
|
|
1863
2378
|
return;
|
|
1864
2379
|
}
|
|
1865
|
-
if (handler(event, next.start, next.end) === false) snapBack();
|
|
2380
|
+
if (handler(event, next.start, next.end, target) === false) snapBack();
|
|
1866
2381
|
}, [snapMinutes, snapBack]);
|
|
1867
2382
|
const unit = (n) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
2383
|
+
const laneTitle = (lane) => lane && (lane.title || lane.id);
|
|
2384
|
+
const nextLane = laneTitle(resources[laneIndex + 1]);
|
|
2385
|
+
const previousLane = laneTitle(resources[laneIndex - 1]);
|
|
1868
2386
|
const barActions = draggable ? [
|
|
1869
2387
|
{
|
|
1870
2388
|
name: "move-later",
|
|
@@ -1881,7 +2399,15 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
1881
2399
|
{
|
|
1882
2400
|
name: "shrink",
|
|
1883
2401
|
label: `Shorten by ${unit(snapMinutes)}`
|
|
1884
|
-
}
|
|
2402
|
+
},
|
|
2403
|
+
...nextLane ? [{
|
|
2404
|
+
name: "move-next-lane",
|
|
2405
|
+
label: `Move to ${nextLane}`
|
|
2406
|
+
}] : [],
|
|
2407
|
+
...previousLane ? [{
|
|
2408
|
+
name: "move-previous-lane",
|
|
2409
|
+
label: `Move to ${previousLane}`
|
|
2410
|
+
}] : []
|
|
1885
2411
|
] : void 0;
|
|
1886
2412
|
const onBarAction = draggable ? (e) => {
|
|
1887
2413
|
switch (e.nativeEvent.actionName) {
|
|
@@ -1897,36 +2423,61 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
1897
2423
|
case "shrink":
|
|
1898
2424
|
commit(0, -snapMinutes);
|
|
1899
2425
|
break;
|
|
2426
|
+
case "move-next-lane":
|
|
2427
|
+
commit(0, 0, 1);
|
|
2428
|
+
break;
|
|
2429
|
+
case "move-previous-lane":
|
|
2430
|
+
commit(0, 0, -1);
|
|
2431
|
+
break;
|
|
1900
2432
|
}
|
|
1901
2433
|
} : void 0;
|
|
1902
2434
|
const barStyle = (0, react_native_reanimated.useAnimatedStyle)(() => vertical ? {
|
|
1903
|
-
transform: [{ translateY: moveX.value }],
|
|
2435
|
+
transform: [{ translateY: moveX.value }, { translateX: moveCross.value }],
|
|
1904
2436
|
height: Math.max(height + resizeW.value, 2)
|
|
1905
2437
|
} : {
|
|
1906
|
-
transform: [{ translateX: moveX.value }],
|
|
2438
|
+
transform: [{ translateX: moveX.value }, { translateY: moveCross.value }],
|
|
1907
2439
|
width: Math.max(width + resizeW.value, 2)
|
|
1908
2440
|
}, [
|
|
1909
2441
|
vertical,
|
|
1910
2442
|
width,
|
|
1911
2443
|
height
|
|
1912
2444
|
]);
|
|
1913
|
-
const
|
|
2445
|
+
const laneId = resources[laneIndex]?.id ?? "";
|
|
2446
|
+
const moveGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
|
|
2447
|
+
(0, react_native_reanimated.runOnJS)(onDragActiveChange)(laneId);
|
|
2448
|
+
}).onUpdate((e) => {
|
|
1914
2449
|
moveX.value = vertical ? e.translationY : e.translationX;
|
|
2450
|
+
if (laneSize > 0 && laneCount > 1) {
|
|
2451
|
+
const cross = vertical ? e.translationX : e.translationY;
|
|
2452
|
+
moveCross.value = Math.min(Math.max(cross, -laneIndex * laneSize), (laneCount - 1 - laneIndex) * laneSize);
|
|
2453
|
+
}
|
|
1915
2454
|
}).onEnd((e) => {
|
|
1916
2455
|
const delta = (0, _super_calendar_core.snapDeltaMinutes)(vertical ? e.translationY : e.translationX, hourSize, snapMinutes);
|
|
1917
|
-
|
|
2456
|
+
const cross = laneSize > 0 ? vertical ? e.translationX : e.translationY : 0;
|
|
2457
|
+
const laneDelta = laneSize > 0 ? Math.min(Math.max(Math.round(cross / laneSize), -laneIndex), laneCount - 1 - laneIndex) : 0;
|
|
2458
|
+
if (delta === 0 && laneDelta === 0) {
|
|
1918
2459
|
moveX.value = 0;
|
|
2460
|
+
moveCross.value = 0;
|
|
1919
2461
|
return;
|
|
1920
2462
|
}
|
|
1921
2463
|
moveX.value = delta / MINUTES_PER_HOUR * hourSize;
|
|
1922
|
-
|
|
2464
|
+
moveCross.value = laneDelta * laneSize;
|
|
2465
|
+
(0, react_native_reanimated.runOnJS)(commit)(delta, delta, laneDelta);
|
|
2466
|
+
}).onFinalize(() => {
|
|
2467
|
+
(0, react_native_reanimated.runOnJS)(onDragActiveChange)(null);
|
|
1923
2468
|
}), [
|
|
1924
2469
|
draggable,
|
|
1925
2470
|
vertical,
|
|
1926
2471
|
hourSize,
|
|
1927
2472
|
snapMinutes,
|
|
2473
|
+
laneSize,
|
|
2474
|
+
laneCount,
|
|
2475
|
+
laneIndex,
|
|
2476
|
+
laneId,
|
|
1928
2477
|
moveX,
|
|
1929
|
-
|
|
2478
|
+
moveCross,
|
|
2479
|
+
commit,
|
|
2480
|
+
onDragActiveChange
|
|
1930
2481
|
]);
|
|
1931
2482
|
const resizeGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(draggable).onUpdate((e) => {
|
|
1932
2483
|
resizeW.value = vertical ? e.translationY : e.translationX;
|
|
@@ -2112,11 +2663,57 @@ function LaneInteractionLayer({ resource, vertical, hourSize, startHour, date, s
|
|
|
2112
2663
|
* />
|
|
2113
2664
|
* ```
|
|
2114
2665
|
*/
|
|
2115
|
-
function ResourceTimeline({ date, orientation = "horizontal", resources, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, dragStepMinutes = 15 }) {
|
|
2666
|
+
function ResourceTimeline({ date, orientation = "horizontal", resources: allResources, resourcesPerPage, resourcePage = 0, events, resourceId = (event) => event.resourceId, startHour = 0, endHour = 24, hourWidth = 80, hourHeight = 48, rowHeight = 56, labelWidth = 140, ampm = false, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes = 15, showNowIndicator = true, now: nowProp, timeZone }) {
|
|
2116
2667
|
const theme = require_MonthList.useCalendarTheme();
|
|
2668
|
+
const resources = (0, react.useMemo)(() => {
|
|
2669
|
+
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
2670
|
+
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
2671
|
+
const page = Math.min(Math.max(resourcePage, 0), pages - 1);
|
|
2672
|
+
return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
|
|
2673
|
+
}, [
|
|
2674
|
+
allResources,
|
|
2675
|
+
resourcesPerPage,
|
|
2676
|
+
resourcePage
|
|
2677
|
+
]);
|
|
2678
|
+
const [dragLaneId, setDragLaneId] = (0, react.useState)(null);
|
|
2679
|
+
const [vBodyWidth, setVBodyWidth] = (0, react.useState)(0);
|
|
2680
|
+
const vLaneSize = resources.length > 0 && vBodyWidth > GUTTER_WIDTH ? (vBodyWidth - GUTTER_WIDTH) / resources.length : 0;
|
|
2117
2681
|
const Renderer = renderEvent ?? DefaultBar;
|
|
2118
2682
|
const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
|
|
2683
|
+
const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
|
|
2684
|
+
now: nowProp,
|
|
2685
|
+
timeZone
|
|
2686
|
+
});
|
|
2687
|
+
const nowHours = now.getHours() + now.getMinutes() / 60;
|
|
2688
|
+
const showNow = showNowIndicator && (0, _super_calendar_core.isSameCalendarDay)(now, date) && nowHours >= startHour && nowHours <= endHour;
|
|
2689
|
+
const nowLine = (vertical, hourSize) => showNow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2690
|
+
pointerEvents: "none",
|
|
2691
|
+
testID: "resource-now-indicator",
|
|
2692
|
+
style: [
|
|
2693
|
+
vertical ? {
|
|
2694
|
+
position: "absolute",
|
|
2695
|
+
left: 0,
|
|
2696
|
+
right: 0,
|
|
2697
|
+
height: 2
|
|
2698
|
+
} : {
|
|
2699
|
+
position: "absolute",
|
|
2700
|
+
top: 0,
|
|
2701
|
+
bottom: 0,
|
|
2702
|
+
width: 2
|
|
2703
|
+
},
|
|
2704
|
+
vertical ? { top: (nowHours - startHour) * hourSize } : { left: (nowHours - startHour) * hourSize },
|
|
2705
|
+
{
|
|
2706
|
+
backgroundColor: theme.colors.nowIndicator,
|
|
2707
|
+
zIndex: 2
|
|
2708
|
+
}
|
|
2709
|
+
]
|
|
2710
|
+
}) : null;
|
|
2119
2711
|
const bandsFor = (resource) => businessHours ? (0, _super_calendar_core.closedHourBands)(date, (d) => businessHours(d, resource), startHour, endHour) : [];
|
|
2712
|
+
const backgroundBandsFor = (resource) => (0, _super_calendar_core.backgroundBandsForDay)(events.filter((event) => resourceId(event) === resource.id), date).map((b) => ({
|
|
2713
|
+
...b,
|
|
2714
|
+
startHours: Math.max(b.startHours, startHour),
|
|
2715
|
+
endHours: Math.min(b.endHours, endHour)
|
|
2716
|
+
})).filter((b) => b.endHours > b.startHours);
|
|
2120
2717
|
const hours = (0, react.useMemo)(() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i), [startHour, endHour]);
|
|
2121
2718
|
const trackWidth = (endHour - startHour) * hourWidth;
|
|
2122
2719
|
const byResource = (0, react.useMemo)(() => {
|
|
@@ -2151,6 +2748,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2151
2748
|
showsVerticalScrollIndicator: true,
|
|
2152
2749
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2153
2750
|
style: [styles.vbody, { height: trackHeight }],
|
|
2751
|
+
onLayout: (event) => setVBodyWidth(event.nativeEvent.layout.width),
|
|
2154
2752
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2155
2753
|
style: { width: GUTTER_WIDTH },
|
|
2156
2754
|
children: hours.map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
@@ -2161,24 +2759,45 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2161
2759
|
}],
|
|
2162
2760
|
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
2163
2761
|
}, h))
|
|
2164
|
-
}), resources.map((resource) => {
|
|
2762
|
+
}), resources.map((resource, laneIndex) => {
|
|
2165
2763
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2166
2764
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2167
2765
|
style: [
|
|
2168
2766
|
styles.vcolumn,
|
|
2169
2767
|
{ borderLeftColor: theme.colors.gridLine },
|
|
2170
|
-
theme.containers.resourceRow
|
|
2768
|
+
theme.containers.resourceRow,
|
|
2769
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2171
2770
|
],
|
|
2172
2771
|
children: [
|
|
2173
2772
|
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2174
2773
|
pointerEvents: "none",
|
|
2774
|
+
accessibilityElementsHidden: true,
|
|
2775
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2175
2776
|
testID: "resource-hours-shade",
|
|
2777
|
+
style: [
|
|
2778
|
+
styles.vshadeBand,
|
|
2779
|
+
{
|
|
2780
|
+
top: (b.start - startHour) * hourHeight,
|
|
2781
|
+
height: (b.end - b.start) * hourHeight
|
|
2782
|
+
},
|
|
2783
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2784
|
+
],
|
|
2785
|
+
children: renderBusinessHours?.({
|
|
2786
|
+
date,
|
|
2787
|
+
start: b.start,
|
|
2788
|
+
end: b.end,
|
|
2789
|
+
resource
|
|
2790
|
+
})
|
|
2791
|
+
}, `shade-${b.start}`)),
|
|
2792
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2793
|
+
pointerEvents: "none",
|
|
2794
|
+
testID: "background-event-shade",
|
|
2176
2795
|
style: [styles.vshadeBand, {
|
|
2177
|
-
top: (b.
|
|
2178
|
-
height: (b.
|
|
2179
|
-
backgroundColor: theme.colors.
|
|
2796
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
2797
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
2798
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2180
2799
|
}]
|
|
2181
|
-
}, `
|
|
2800
|
+
}, `bg-${i}`)),
|
|
2182
2801
|
hours.slice(1).map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2183
2802
|
pointerEvents: "none",
|
|
2184
2803
|
style: [styles.vgridLine, {
|
|
@@ -2186,6 +2805,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2186
2805
|
backgroundColor: theme.colors.gridLine
|
|
2187
2806
|
}]
|
|
2188
2807
|
}, h)),
|
|
2808
|
+
nowLine(true, hourHeight),
|
|
2189
2809
|
cellEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LaneInteractionLayer, {
|
|
2190
2810
|
resource,
|
|
2191
2811
|
vertical: true,
|
|
@@ -2209,6 +2829,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2209
2829
|
if (onDragEvent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResourceBar, {
|
|
2210
2830
|
pe,
|
|
2211
2831
|
vertical: true,
|
|
2832
|
+
resources,
|
|
2833
|
+
laneIndex,
|
|
2834
|
+
laneSize: vLaneSize,
|
|
2835
|
+
dragActive: dragLaneId === resource.id,
|
|
2836
|
+
onDragActiveChange: setDragLaneId,
|
|
2212
2837
|
hourSize: hourHeight,
|
|
2213
2838
|
left,
|
|
2214
2839
|
top,
|
|
@@ -2275,7 +2900,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2275
2900
|
children: (0, _super_calendar_core.formatHour)(h, { ampm })
|
|
2276
2901
|
}, h))
|
|
2277
2902
|
})]
|
|
2278
|
-
}), resources.map((resource) => {
|
|
2903
|
+
}), resources.map((resource, laneIndex) => {
|
|
2279
2904
|
const positioned = byResource.get(resource.id) ?? [];
|
|
2280
2905
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
2281
2906
|
style: [
|
|
@@ -2284,7 +2909,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2284
2909
|
height: rowHeight,
|
|
2285
2910
|
borderBottomColor: theme.colors.gridLine
|
|
2286
2911
|
},
|
|
2287
|
-
theme.containers.resourceRow
|
|
2912
|
+
theme.containers.resourceRow,
|
|
2913
|
+
dragLaneId === resource.id && styles.laneLifted
|
|
2288
2914
|
],
|
|
2289
2915
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2290
2916
|
style: [
|
|
@@ -2306,13 +2932,33 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2306
2932
|
children: [
|
|
2307
2933
|
bandsFor(resource).map((b) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2308
2934
|
pointerEvents: "none",
|
|
2935
|
+
accessibilityElementsHidden: true,
|
|
2936
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2309
2937
|
testID: "resource-hours-shade",
|
|
2938
|
+
style: [
|
|
2939
|
+
styles.hshadeBand,
|
|
2940
|
+
{
|
|
2941
|
+
left: (b.start - startHour) * hourWidth,
|
|
2942
|
+
width: (b.end - b.start) * hourWidth
|
|
2943
|
+
},
|
|
2944
|
+
renderBusinessHours ? null : { backgroundColor: theme.colors.outsideHoursBackground }
|
|
2945
|
+
],
|
|
2946
|
+
children: renderBusinessHours?.({
|
|
2947
|
+
date,
|
|
2948
|
+
start: b.start,
|
|
2949
|
+
end: b.end,
|
|
2950
|
+
resource
|
|
2951
|
+
})
|
|
2952
|
+
}, `shade-${b.start}`)),
|
|
2953
|
+
backgroundBandsFor(resource).map((b, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2954
|
+
pointerEvents: "none",
|
|
2955
|
+
testID: "background-event-shade",
|
|
2310
2956
|
style: [styles.hshadeBand, {
|
|
2311
|
-
left: (b.
|
|
2312
|
-
width: (b.
|
|
2313
|
-
backgroundColor: theme.colors.
|
|
2957
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
2958
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
2959
|
+
backgroundColor: theme.colors.backgroundEvent
|
|
2314
2960
|
}]
|
|
2315
|
-
}, `
|
|
2961
|
+
}, `bg-${i}`)),
|
|
2316
2962
|
hours.slice(1).map((h) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
2317
2963
|
pointerEvents: "none",
|
|
2318
2964
|
style: [styles.gridLine, {
|
|
@@ -2320,6 +2966,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2320
2966
|
backgroundColor: theme.colors.gridLine
|
|
2321
2967
|
}]
|
|
2322
2968
|
}, h)),
|
|
2969
|
+
nowLine(false, hourWidth),
|
|
2323
2970
|
cellEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LaneInteractionLayer, {
|
|
2324
2971
|
resource,
|
|
2325
2972
|
vertical: false,
|
|
@@ -2341,6 +2988,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources, events,
|
|
|
2341
2988
|
if (onDragEvent) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResourceBar, {
|
|
2342
2989
|
pe,
|
|
2343
2990
|
vertical: false,
|
|
2991
|
+
resources,
|
|
2992
|
+
laneIndex,
|
|
2993
|
+
laneSize: rowHeight,
|
|
2994
|
+
dragActive: dragLaneId === resource.id,
|
|
2995
|
+
onDragActiveChange: setDragLaneId,
|
|
2344
2996
|
hourSize: hourWidth,
|
|
2345
2997
|
left,
|
|
2346
2998
|
top: pe.column * laneHeight,
|
|
@@ -2450,6 +3102,7 @@ const styles = react_native.StyleSheet.create({
|
|
|
2450
3102
|
fontWeight: "600"
|
|
2451
3103
|
},
|
|
2452
3104
|
vbody: { flexDirection: "row" },
|
|
3105
|
+
laneLifted: { zIndex: 10 },
|
|
2453
3106
|
vcolumn: {
|
|
2454
3107
|
flex: 1,
|
|
2455
3108
|
borderLeftWidth: react_native.StyleSheet.hairlineWidth
|
|
@@ -2506,6 +3159,13 @@ exports.MonthPager = require_MonthList.MonthPager;
|
|
|
2506
3159
|
exports.MonthView = require_MonthList.MonthView;
|
|
2507
3160
|
exports.ResourceTimeline = ResourceTimeline;
|
|
2508
3161
|
exports.TimeGrid = TimeGrid;
|
|
3162
|
+
exports.YearView = YearView;
|
|
3163
|
+
Object.defineProperty(exports, "backgroundBandsForDay", {
|
|
3164
|
+
enumerable: true,
|
|
3165
|
+
get: function() {
|
|
3166
|
+
return _super_calendar_core.backgroundBandsForDay;
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
2509
3169
|
Object.defineProperty(exports, "buildMonthGrid", {
|
|
2510
3170
|
enumerable: true,
|
|
2511
3171
|
get: function() {
|
|
@@ -2562,6 +3222,12 @@ Object.defineProperty(exports, "isAllDayEvent", {
|
|
|
2562
3222
|
return _super_calendar_core.isAllDayEvent;
|
|
2563
3223
|
}
|
|
2564
3224
|
});
|
|
3225
|
+
Object.defineProperty(exports, "isBackgroundEvent", {
|
|
3226
|
+
enumerable: true,
|
|
3227
|
+
get: function() {
|
|
3228
|
+
return _super_calendar_core.isBackgroundEvent;
|
|
3229
|
+
}
|
|
3230
|
+
});
|
|
2565
3231
|
Object.defineProperty(exports, "isDateSelectable", {
|
|
2566
3232
|
enumerable: true,
|
|
2567
3233
|
get: function() {
|
|
@@ -2636,12 +3302,24 @@ Object.defineProperty(exports, "useDateRange", {
|
|
|
2636
3302
|
return _super_calendar_core.useDateRange;
|
|
2637
3303
|
}
|
|
2638
3304
|
});
|
|
3305
|
+
Object.defineProperty(exports, "useEventSource", {
|
|
3306
|
+
enumerable: true,
|
|
3307
|
+
get: function() {
|
|
3308
|
+
return _super_calendar_core.useEventSource;
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
2639
3311
|
Object.defineProperty(exports, "useMonthGrid", {
|
|
2640
3312
|
enumerable: true,
|
|
2641
3313
|
get: function() {
|
|
2642
3314
|
return _super_calendar_core.useMonthGrid;
|
|
2643
3315
|
}
|
|
2644
3316
|
});
|
|
3317
|
+
Object.defineProperty(exports, "useNow", {
|
|
3318
|
+
enumerable: true,
|
|
3319
|
+
get: function() {
|
|
3320
|
+
return _super_calendar_core.useNow;
|
|
3321
|
+
}
|
|
3322
|
+
});
|
|
2645
3323
|
Object.defineProperty(exports, "weekdayFormatToken", {
|
|
2646
3324
|
enumerable: true,
|
|
2647
3325
|
get: function() {
|