@super-calendar/native 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DefaultMonthEvent-BSvuJUFk.d.ts → DefaultMonthEvent-DCPDsnvq.d.ts} +10 -6
- package/dist/{DefaultMonthEvent-zDj9dHEv.d.mts → DefaultMonthEvent-DMOC5aNL.d.mts} +10 -6
- package/dist/{MonthList-Gu6p64fE.js → MonthList-CJs1vq5T.js} +80 -11
- package/dist/{MonthList-CMzYn9T0.mjs → MonthList-Dn37Ezj0.mjs} +82 -13
- package/dist/index.d.mts +80 -17
- package/dist/index.d.ts +80 -17
- package/dist/index.js +627 -125
- package/dist/index.mjs +606 -128
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Agenda.tsx +5 -2
- package/src/components/AllDayLane.tsx +3 -2
- package/src/components/Calendar.tsx +29 -0
- package/src/components/DefaultEvent.tsx +3 -1
- package/src/components/MonthPager.tsx +12 -3
- package/src/components/MonthView.tsx +95 -8
- package/src/components/ResourceTimeline.tsx +270 -29
- package/src/components/TimeGrid.tsx +656 -97
- package/src/components/YearView.tsx +14 -4
- package/src/index.tsx +10 -1
- package/src/types.ts +1 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentType, ReactElement } from "react";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
1
|
+
import type { ComponentType, ReactElement, ReactNode } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
4
|
type AccessibilityActionEvent,
|
|
5
5
|
type GestureResponderEvent,
|
|
@@ -13,8 +13,13 @@ import {
|
|
|
13
13
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
14
14
|
import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
15
15
|
import {
|
|
16
|
+
backgroundBandsForDay,
|
|
16
17
|
type CalendarEvent,
|
|
17
18
|
cellRangeFromDrag,
|
|
19
|
+
isSameCalendarDay,
|
|
20
|
+
useNow,
|
|
21
|
+
type BusinessHoursBand,
|
|
22
|
+
type BusinessHoursValue,
|
|
18
23
|
closedHourBands,
|
|
19
24
|
eventTimeLabel,
|
|
20
25
|
formatHour,
|
|
@@ -67,6 +72,19 @@ export interface ResourceTimelineProps<T = unknown> {
|
|
|
67
72
|
orientation?: "horizontal" | "vertical";
|
|
68
73
|
/** The resource lanes: rows when horizontal, columns when vertical. */
|
|
69
74
|
resources: Resource[];
|
|
75
|
+
/**
|
|
76
|
+
* Cap the number of lanes shown at once; the rest sit on further pages. Pair
|
|
77
|
+
* with `resourcePage` and your own prev/next controls to page through them
|
|
78
|
+
* (like `date` drives the time axis). Omit to show every lane, sharing the
|
|
79
|
+
* available space.
|
|
80
|
+
*/
|
|
81
|
+
resourcesPerPage?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The 0-based page of lanes to show when `resourcesPerPage` is set (default
|
|
84
|
+
* 0, clamped to the last page). Controlled: update it from your own paging
|
|
85
|
+
* controls.
|
|
86
|
+
*/
|
|
87
|
+
resourcePage?: number;
|
|
70
88
|
/** Events; each is placed in the row named by `resourceId(event)`. */
|
|
71
89
|
events: CalendarEvent<T>[];
|
|
72
90
|
/** Read an event's resource id. Default: `event.resourceId`. */
|
|
@@ -95,11 +113,19 @@ export interface ResourceTimelineProps<T = unknown> {
|
|
|
95
113
|
*/
|
|
96
114
|
onLongPressEvent?: (event: CalendarEvent<T>) => void;
|
|
97
115
|
/**
|
|
98
|
-
* Enables drag-to-move and edge-resize
|
|
99
|
-
*
|
|
100
|
-
* start/end
|
|
116
|
+
* Enables drag-to-move and edge-resize: long-press a bar to move it along the
|
|
117
|
+
* time axis or across lanes, or drag its trailing edge to resize. Called with
|
|
118
|
+
* the proposed new start/end and the lane the bar was dropped in (the original
|
|
119
|
+
* lane when it didn't cross); retarget the event's resource from it. Return
|
|
120
|
+
* `false` to reject the drop (it snaps back). Only visible lanes are drop
|
|
121
|
+
* targets (see `resourcesPerPage`).
|
|
101
122
|
*/
|
|
102
|
-
onDragEvent?: (
|
|
123
|
+
onDragEvent?: (
|
|
124
|
+
event: CalendarEvent<T>,
|
|
125
|
+
start: Date,
|
|
126
|
+
end: Date,
|
|
127
|
+
resource: Resource,
|
|
128
|
+
) => void | boolean;
|
|
103
129
|
/** Tap empty lane space; called with the snapped time and the lane's resource. */
|
|
104
130
|
onPressCell?: (at: Date, resource: Resource) => void;
|
|
105
131
|
/**
|
|
@@ -117,9 +143,22 @@ export interface ResourceTimelineProps<T = unknown> {
|
|
|
117
143
|
* `businessHours` plus the lane's resource, so per-resource opening hours work
|
|
118
144
|
* (return `null` for a fully closed lane). A date-only function is accepted.
|
|
119
145
|
*/
|
|
120
|
-
businessHours?: (date: Date, resource: Resource) =>
|
|
146
|
+
businessHours?: (date: Date, resource: Resource) => BusinessHoursValue;
|
|
147
|
+
/**
|
|
148
|
+
* Render a closed-hours band's content yourself (a label, icon, pattern). The
|
|
149
|
+
* board keeps positioning the band; when set, the themed tint is dropped and
|
|
150
|
+
* your output fills the band instead. Receives the lane's resource. Decorative only: the
|
|
151
|
+
* band stays non-interactive and hidden from assistive tech.
|
|
152
|
+
*/
|
|
153
|
+
renderBusinessHours?: (band: BusinessHoursBand & { resource: Resource }) => ReactNode;
|
|
121
154
|
/** Snap dragged events to this many minutes (default 15). */
|
|
122
155
|
dragStepMinutes?: number;
|
|
156
|
+
/** Show the current-time line when `date` is today (default true). */
|
|
157
|
+
showNowIndicator?: boolean;
|
|
158
|
+
/** Fixed "now" instant for the indicator (doesn't tick). Defaults to the device clock. */
|
|
159
|
+
now?: Date;
|
|
160
|
+
/** Shift the now indicator into this IANA zone (pair with `eventsInTimeZone`). */
|
|
161
|
+
timeZone?: string;
|
|
123
162
|
}
|
|
124
163
|
|
|
125
164
|
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
|
|
@@ -186,7 +225,22 @@ type ResourceBarProps<T> = {
|
|
|
186
225
|
Renderer: ComponentType<ResourceEventArgs<T>>;
|
|
187
226
|
onPress: () => void;
|
|
188
227
|
onLongPress?: () => void;
|
|
189
|
-
onDragEvent: (
|
|
228
|
+
onDragEvent: (
|
|
229
|
+
event: CalendarEvent<T>,
|
|
230
|
+
start: Date,
|
|
231
|
+
end: Date,
|
|
232
|
+
resource: Resource,
|
|
233
|
+
) => void | boolean;
|
|
234
|
+
/** The visible lanes, for cross-lane drops and their screen-reader actions. */
|
|
235
|
+
resources: Resource[];
|
|
236
|
+
/** This bar's lane index within `resources`. */
|
|
237
|
+
laneIndex: number;
|
|
238
|
+
/** Cross-axis pixels per lane; 0 disables cross-lane dragging (unmeasured). */
|
|
239
|
+
laneSize: number;
|
|
240
|
+
/** True while a drag on this bar's lane is live (holds the preview until settle). */
|
|
241
|
+
dragActive: boolean;
|
|
242
|
+
/** Raise this bar's lane above its siblings while a drag is live. */
|
|
243
|
+
onDragActiveChange: (laneId: string | null) => void;
|
|
190
244
|
theme: ReturnType<typeof useCalendarTheme>;
|
|
191
245
|
};
|
|
192
246
|
|
|
@@ -208,28 +262,45 @@ function ResourceBar<T>({
|
|
|
208
262
|
onPress,
|
|
209
263
|
onLongPress,
|
|
210
264
|
onDragEvent,
|
|
265
|
+
resources,
|
|
266
|
+
laneIndex,
|
|
267
|
+
laneSize,
|
|
268
|
+
dragActive,
|
|
269
|
+
onDragActiveChange,
|
|
211
270
|
theme,
|
|
212
271
|
}: ResourceBarProps<T>): ReactElement {
|
|
213
272
|
const moveX = useSharedValue(0);
|
|
273
|
+
const moveCross = useSharedValue(0);
|
|
214
274
|
const resizeW = useSharedValue(0);
|
|
215
|
-
const latest = useRef({ event: pe.event, onDragEvent });
|
|
216
|
-
latest.current = { event: pe.event, onDragEvent };
|
|
217
|
-
const
|
|
275
|
+
const latest = useRef({ event: pe.event, onDragEvent, resources, laneIndex });
|
|
276
|
+
latest.current = { event: pe.event, onDragEvent, resources, laneIndex };
|
|
277
|
+
const laneCount = resources.length;
|
|
278
|
+
// `draggable: false` locks a single bar (keeps taps, blocks move/resize).
|
|
279
|
+
const draggable =
|
|
280
|
+
!(pe.event as { disabled?: boolean }).disabled &&
|
|
281
|
+
(pe.event as { draggable?: boolean }).draggable !== false;
|
|
218
282
|
|
|
219
|
-
// Clear the live preview
|
|
283
|
+
// Clear the live preview when the drag on this lane settles, or when a
|
|
284
|
+
// committed change re-renders the bar. Skip while a drag is active so this
|
|
285
|
+
// never clobbers the in-flight preview; the cross-lane offset is held through
|
|
286
|
+
// the drag (so a relocation stays seamless) and cleared here on settle, which
|
|
287
|
+
// also snaps a bar back when the handler accepts the move without relocating.
|
|
220
288
|
useEffect(() => {
|
|
289
|
+
if (dragActive) return;
|
|
221
290
|
moveX.value = 0;
|
|
291
|
+
moveCross.value = 0;
|
|
222
292
|
resizeW.value = 0;
|
|
223
|
-
}, [pe.startHours, pe.durationHours, moveX, resizeW]);
|
|
293
|
+
}, [dragActive, pe.startHours, pe.durationHours, moveX, moveCross, resizeW]);
|
|
224
294
|
|
|
225
295
|
const snapBack = useCallback(() => {
|
|
226
296
|
moveX.value = 0;
|
|
297
|
+
moveCross.value = 0;
|
|
227
298
|
resizeW.value = 0;
|
|
228
|
-
}, [moveX, resizeW]);
|
|
299
|
+
}, [moveX, moveCross, resizeW]);
|
|
229
300
|
|
|
230
301
|
const commit = useCallback(
|
|
231
|
-
(deltaStartMin: number, deltaEndMin: number) => {
|
|
232
|
-
const { event, onDragEvent: handler } = latest.current;
|
|
302
|
+
(deltaStartMin: number, deltaEndMin: number, laneDelta = 0) => {
|
|
303
|
+
const { event, onDragEvent: handler, resources: lanes, laneIndex: lane } = latest.current;
|
|
233
304
|
const next = resolveDraggedBounds(
|
|
234
305
|
event.start,
|
|
235
306
|
event.end,
|
|
@@ -237,11 +308,12 @@ function ResourceBar<T>({
|
|
|
237
308
|
deltaEndMin,
|
|
238
309
|
snapMinutes,
|
|
239
310
|
);
|
|
240
|
-
|
|
311
|
+
const target = lanes[Math.min(Math.max(lane + laneDelta, 0), lanes.length - 1)];
|
|
312
|
+
if (!next || !target) {
|
|
241
313
|
snapBack();
|
|
242
314
|
return;
|
|
243
315
|
}
|
|
244
|
-
if (handler(event, next.start, next.end) === false) snapBack();
|
|
316
|
+
if (handler(event, next.start, next.end, target) === false) snapBack();
|
|
245
317
|
},
|
|
246
318
|
[snapMinutes, snapBack],
|
|
247
319
|
);
|
|
@@ -251,12 +323,17 @@ function ResourceBar<T>({
|
|
|
251
323
|
// resize grip is a non-focusable visual/gesture affordance, so an `adjustable`
|
|
252
324
|
// role there would never receive focus on a real device).
|
|
253
325
|
const unit = (n: number) => `${n} minute${n === 1 ? "" : "s"}`;
|
|
326
|
+
const laneTitle = (lane?: Resource) => lane && (lane.title || lane.id);
|
|
327
|
+
const nextLane = laneTitle(resources[laneIndex + 1]);
|
|
328
|
+
const previousLane = laneTitle(resources[laneIndex - 1]);
|
|
254
329
|
const barActions = draggable
|
|
255
330
|
? [
|
|
256
331
|
{ name: "move-later", label: `Move ${unit(snapMinutes)} later` },
|
|
257
332
|
{ name: "move-earlier", label: `Move ${unit(snapMinutes)} earlier` },
|
|
258
333
|
{ name: "extend", label: `Extend by ${unit(snapMinutes)}` },
|
|
259
334
|
{ name: "shrink", label: `Shorten by ${unit(snapMinutes)}` },
|
|
335
|
+
...(nextLane ? [{ name: "move-next-lane", label: `Move to ${nextLane}` }] : []),
|
|
336
|
+
...(previousLane ? [{ name: "move-previous-lane", label: `Move to ${previousLane}` }] : []),
|
|
260
337
|
]
|
|
261
338
|
: undefined;
|
|
262
339
|
const onBarAction = draggable
|
|
@@ -274,6 +351,12 @@ function ResourceBar<T>({
|
|
|
274
351
|
case "shrink":
|
|
275
352
|
commit(0, -snapMinutes);
|
|
276
353
|
break;
|
|
354
|
+
case "move-next-lane":
|
|
355
|
+
commit(0, 0, 1);
|
|
356
|
+
break;
|
|
357
|
+
case "move-previous-lane":
|
|
358
|
+
commit(0, 0, -1);
|
|
359
|
+
break;
|
|
277
360
|
}
|
|
278
361
|
}
|
|
279
362
|
: undefined;
|
|
@@ -282,35 +365,74 @@ function ResourceBar<T>({
|
|
|
282
365
|
() =>
|
|
283
366
|
vertical
|
|
284
367
|
? {
|
|
285
|
-
transform: [{ translateY: moveX.value }],
|
|
368
|
+
transform: [{ translateY: moveX.value }, { translateX: moveCross.value }],
|
|
286
369
|
height: Math.max(height + resizeW.value, 2),
|
|
287
370
|
}
|
|
288
371
|
: {
|
|
289
|
-
transform: [{ translateX: moveX.value }],
|
|
372
|
+
transform: [{ translateX: moveX.value }, { translateY: moveCross.value }],
|
|
290
373
|
width: Math.max((width as number) + resizeW.value, 2),
|
|
291
374
|
},
|
|
292
375
|
[vertical, width, height],
|
|
293
376
|
);
|
|
294
377
|
|
|
378
|
+
const laneId = resources[laneIndex]?.id ?? "";
|
|
295
379
|
const moveGesture = useMemo(
|
|
296
380
|
() =>
|
|
297
381
|
Gesture.Pan()
|
|
298
382
|
.enabled(draggable)
|
|
299
383
|
.activateAfterLongPress(MOVE_ACTIVATE_MS)
|
|
384
|
+
.onStart(() => {
|
|
385
|
+
// Lift this bar's lane above its siblings so the preview isn't
|
|
386
|
+
// painted under later lanes (RN zIndex only orders siblings).
|
|
387
|
+
runOnJS(onDragActiveChange)(laneId);
|
|
388
|
+
})
|
|
300
389
|
.onUpdate((e) => {
|
|
301
390
|
moveX.value = vertical ? e.translationY : e.translationX;
|
|
391
|
+
if (laneSize > 0 && laneCount > 1) {
|
|
392
|
+
const cross = vertical ? e.translationX : e.translationY;
|
|
393
|
+
moveCross.value = Math.min(
|
|
394
|
+
Math.max(cross, -laneIndex * laneSize),
|
|
395
|
+
(laneCount - 1 - laneIndex) * laneSize,
|
|
396
|
+
);
|
|
397
|
+
}
|
|
302
398
|
})
|
|
303
399
|
.onEnd((e) => {
|
|
304
400
|
const translation = vertical ? e.translationY : e.translationX;
|
|
305
401
|
const delta = snapDeltaMinutes(translation, hourSize, snapMinutes);
|
|
306
|
-
|
|
402
|
+
const cross = laneSize > 0 ? (vertical ? e.translationX : e.translationY) : 0;
|
|
403
|
+
const laneDelta =
|
|
404
|
+
laneSize > 0
|
|
405
|
+
? Math.min(
|
|
406
|
+
Math.max(Math.round(cross / laneSize), -laneIndex),
|
|
407
|
+
laneCount - 1 - laneIndex,
|
|
408
|
+
)
|
|
409
|
+
: 0;
|
|
410
|
+
if (delta === 0 && laneDelta === 0) {
|
|
307
411
|
moveX.value = 0;
|
|
412
|
+
moveCross.value = 0;
|
|
308
413
|
return;
|
|
309
414
|
}
|
|
310
415
|
moveX.value = (delta / MINUTES_PER_HOUR) * hourSize;
|
|
311
|
-
|
|
416
|
+
moveCross.value = laneDelta * laneSize;
|
|
417
|
+
runOnJS(commit)(delta, delta, laneDelta);
|
|
418
|
+
})
|
|
419
|
+
.onFinalize(() => {
|
|
420
|
+
runOnJS(onDragActiveChange)(null);
|
|
312
421
|
}),
|
|
313
|
-
[
|
|
422
|
+
[
|
|
423
|
+
draggable,
|
|
424
|
+
vertical,
|
|
425
|
+
hourSize,
|
|
426
|
+
snapMinutes,
|
|
427
|
+
laneSize,
|
|
428
|
+
laneCount,
|
|
429
|
+
laneIndex,
|
|
430
|
+
laneId,
|
|
431
|
+
moveX,
|
|
432
|
+
moveCross,
|
|
433
|
+
commit,
|
|
434
|
+
onDragActiveChange,
|
|
435
|
+
],
|
|
314
436
|
);
|
|
315
437
|
|
|
316
438
|
const resizeGesture = useMemo(
|
|
@@ -564,7 +686,9 @@ function LaneInteractionLayer({
|
|
|
564
686
|
export function ResourceTimeline<T = unknown>({
|
|
565
687
|
date,
|
|
566
688
|
orientation = "horizontal",
|
|
567
|
-
resources,
|
|
689
|
+
resources: allResources,
|
|
690
|
+
resourcesPerPage,
|
|
691
|
+
resourcePage = 0,
|
|
568
692
|
events,
|
|
569
693
|
resourceId = (event) => (event as { resourceId?: string }).resourceId,
|
|
570
694
|
startHour = 0,
|
|
@@ -582,16 +706,73 @@ export function ResourceTimeline<T = unknown>({
|
|
|
582
706
|
onLongPressCell,
|
|
583
707
|
onCreateEvent,
|
|
584
708
|
businessHours,
|
|
709
|
+
renderBusinessHours,
|
|
585
710
|
dragStepMinutes = 15,
|
|
711
|
+
showNowIndicator = true,
|
|
712
|
+
now: nowProp,
|
|
713
|
+
timeZone,
|
|
586
714
|
}: ResourceTimelineProps<T>): ReactElement {
|
|
587
715
|
const theme = useCalendarTheme();
|
|
716
|
+
// Window the lanes to the requested page when resourcesPerPage caps them.
|
|
717
|
+
const resources = useMemo(() => {
|
|
718
|
+
if (!resourcesPerPage || resourcesPerPage <= 0) return allResources;
|
|
719
|
+
const pages = Math.max(1, Math.ceil(allResources.length / resourcesPerPage));
|
|
720
|
+
const page = Math.min(Math.max(resourcePage, 0), pages - 1);
|
|
721
|
+
return allResources.slice(page * resourcesPerPage, (page + 1) * resourcesPerPage);
|
|
722
|
+
}, [allResources, resourcesPerPage, resourcePage]);
|
|
723
|
+
// The lane a bar is being dragged in, lifted above its siblings (RN zIndex
|
|
724
|
+
// only orders siblings, so the lane itself must be raised for the cross-lane
|
|
725
|
+
// preview to stay visible).
|
|
726
|
+
const [dragLaneId, setDragLaneId] = useState<string | null>(null);
|
|
727
|
+
// Vertical columns flex, so measure the body to get the per-lane width.
|
|
728
|
+
const [vBodyWidth, setVBodyWidth] = useState(0);
|
|
729
|
+
const vLaneSize =
|
|
730
|
+
resources.length > 0 && vBodyWidth > GUTTER_WIDTH
|
|
731
|
+
? (vBodyWidth - GUTTER_WIDTH) / resources.length
|
|
732
|
+
: 0;
|
|
588
733
|
const Renderer = renderEvent ?? DefaultBar;
|
|
589
734
|
const cellEnabled = !!onPressCell || !!onLongPressCell || !!onCreateEvent;
|
|
735
|
+
// The current-time line, shown only when the board's day is the zone's today.
|
|
736
|
+
const now = useNow(showNowIndicator, { now: nowProp, timeZone });
|
|
737
|
+
const nowHours = now.getHours() + now.getMinutes() / 60;
|
|
738
|
+
const showNow =
|
|
739
|
+
showNowIndicator &&
|
|
740
|
+
isSameCalendarDay(now, date) &&
|
|
741
|
+
nowHours >= startHour &&
|
|
742
|
+
nowHours <= endHour;
|
|
743
|
+
const nowLine = (vertical: boolean, hourSize: number) =>
|
|
744
|
+
showNow ? (
|
|
745
|
+
<View
|
|
746
|
+
pointerEvents="none"
|
|
747
|
+
testID="resource-now-indicator"
|
|
748
|
+
style={[
|
|
749
|
+
vertical
|
|
750
|
+
? { position: "absolute", left: 0, right: 0, height: 2 }
|
|
751
|
+
: { position: "absolute", top: 0, bottom: 0, width: 2 },
|
|
752
|
+
vertical
|
|
753
|
+
? { top: (nowHours - startHour) * hourSize }
|
|
754
|
+
: { left: (nowHours - startHour) * hourSize },
|
|
755
|
+
{ backgroundColor: theme.colors.nowIndicator, zIndex: 2 },
|
|
756
|
+
]}
|
|
757
|
+
/>
|
|
758
|
+
) : null;
|
|
590
759
|
// The closed-hours bands to shade in a lane, resolved per resource.
|
|
591
760
|
const bandsFor = (resource: Resource) =>
|
|
592
761
|
businessHours
|
|
593
762
|
? closedHourBands(date, (d) => businessHours(d, resource), startHour, endHour)
|
|
594
763
|
: [];
|
|
764
|
+
// `display: "background"` events in a lane, clipped to the visible window.
|
|
765
|
+
const backgroundBandsFor = (resource: Resource) =>
|
|
766
|
+
backgroundBandsForDay(
|
|
767
|
+
events.filter((event) => resourceId(event) === resource.id),
|
|
768
|
+
date,
|
|
769
|
+
)
|
|
770
|
+
.map((b) => ({
|
|
771
|
+
...b,
|
|
772
|
+
startHours: Math.max(b.startHours, startHour),
|
|
773
|
+
endHours: Math.min(b.endHours, endHour),
|
|
774
|
+
}))
|
|
775
|
+
.filter((b) => b.endHours > b.startHours);
|
|
595
776
|
|
|
596
777
|
const hours = useMemo(
|
|
597
778
|
() => Array.from({ length: Math.max(0, endHour - startHour) }, (_, i) => startHour + i),
|
|
@@ -631,7 +812,10 @@ export function ResourceTimeline<T = unknown>({
|
|
|
631
812
|
))}
|
|
632
813
|
</View>
|
|
633
814
|
<ScrollView showsVerticalScrollIndicator>
|
|
634
|
-
<View
|
|
815
|
+
<View
|
|
816
|
+
style={[styles.vbody, { height: trackHeight }]}
|
|
817
|
+
onLayout={(event) => setVBodyWidth(event.nativeEvent.layout.width)}
|
|
818
|
+
>
|
|
635
819
|
<View style={{ width: GUTTER_WIDTH }}>
|
|
636
820
|
{hours.map((h) => (
|
|
637
821
|
<Text
|
|
@@ -649,7 +833,7 @@ export function ResourceTimeline<T = unknown>({
|
|
|
649
833
|
</Text>
|
|
650
834
|
))}
|
|
651
835
|
</View>
|
|
652
|
-
{resources.map((resource) => {
|
|
836
|
+
{resources.map((resource, laneIndex) => {
|
|
653
837
|
const positioned = byResource.get(resource.id) ?? [];
|
|
654
838
|
return (
|
|
655
839
|
<View
|
|
@@ -658,6 +842,7 @@ export function ResourceTimeline<T = unknown>({
|
|
|
658
842
|
styles.vcolumn,
|
|
659
843
|
{ borderLeftColor: theme.colors.gridLine },
|
|
660
844
|
theme.containers.resourceRow,
|
|
845
|
+
dragLaneId === resource.id && styles.laneLifted,
|
|
661
846
|
]}
|
|
662
847
|
>
|
|
663
848
|
{/* Closed-hours shade, behind the grid lines and bars. */}
|
|
@@ -665,13 +850,34 @@ export function ResourceTimeline<T = unknown>({
|
|
|
665
850
|
<View
|
|
666
851
|
key={`shade-${b.start}`}
|
|
667
852
|
pointerEvents="none"
|
|
853
|
+
accessibilityElementsHidden
|
|
854
|
+
importantForAccessibility="no-hide-descendants"
|
|
668
855
|
testID="resource-hours-shade"
|
|
669
856
|
style={[
|
|
670
857
|
styles.vshadeBand,
|
|
671
858
|
{
|
|
672
859
|
top: (b.start - startHour) * hourHeight,
|
|
673
860
|
height: (b.end - b.start) * hourHeight,
|
|
674
|
-
|
|
861
|
+
},
|
|
862
|
+
renderBusinessHours
|
|
863
|
+
? null
|
|
864
|
+
: { backgroundColor: theme.colors.outsideHoursBackground },
|
|
865
|
+
]}
|
|
866
|
+
>
|
|
867
|
+
{renderBusinessHours?.({ date, start: b.start, end: b.end, resource })}
|
|
868
|
+
</View>
|
|
869
|
+
))}
|
|
870
|
+
{backgroundBandsFor(resource).map((b, i) => (
|
|
871
|
+
<View
|
|
872
|
+
key={`bg-${i}`}
|
|
873
|
+
pointerEvents="none"
|
|
874
|
+
testID="background-event-shade"
|
|
875
|
+
style={[
|
|
876
|
+
styles.vshadeBand,
|
|
877
|
+
{
|
|
878
|
+
top: (b.startHours - startHour) * hourHeight,
|
|
879
|
+
height: (b.endHours - b.startHours) * hourHeight,
|
|
880
|
+
backgroundColor: theme.colors.backgroundEvent,
|
|
675
881
|
},
|
|
676
882
|
]}
|
|
677
883
|
/>
|
|
@@ -689,6 +895,7 @@ export function ResourceTimeline<T = unknown>({
|
|
|
689
895
|
]}
|
|
690
896
|
/>
|
|
691
897
|
))}
|
|
898
|
+
{nowLine(true, hourHeight)}
|
|
692
899
|
{cellEnabled ? (
|
|
693
900
|
<LaneInteractionLayer
|
|
694
901
|
resource={resource}
|
|
@@ -721,6 +928,11 @@ export function ResourceTimeline<T = unknown>({
|
|
|
721
928
|
key={idx}
|
|
722
929
|
pe={pe}
|
|
723
930
|
vertical
|
|
931
|
+
resources={resources}
|
|
932
|
+
laneIndex={laneIndex}
|
|
933
|
+
laneSize={vLaneSize}
|
|
934
|
+
dragActive={dragLaneId === resource.id}
|
|
935
|
+
onDragActiveChange={setDragLaneId}
|
|
724
936
|
hourSize={hourHeight}
|
|
725
937
|
left={left}
|
|
726
938
|
top={top}
|
|
@@ -785,7 +997,7 @@ export function ResourceTimeline<T = unknown>({
|
|
|
785
997
|
</View>
|
|
786
998
|
|
|
787
999
|
{/* Resource rows */}
|
|
788
|
-
{resources.map((resource) => {
|
|
1000
|
+
{resources.map((resource, laneIndex) => {
|
|
789
1001
|
const positioned = byResource.get(resource.id) ?? [];
|
|
790
1002
|
return (
|
|
791
1003
|
<View
|
|
@@ -794,6 +1006,7 @@ export function ResourceTimeline<T = unknown>({
|
|
|
794
1006
|
styles.row,
|
|
795
1007
|
{ height: rowHeight, borderBottomColor: theme.colors.gridLine },
|
|
796
1008
|
theme.containers.resourceRow,
|
|
1009
|
+
dragLaneId === resource.id && styles.laneLifted,
|
|
797
1010
|
]}
|
|
798
1011
|
>
|
|
799
1012
|
<View
|
|
@@ -817,13 +1030,34 @@ export function ResourceTimeline<T = unknown>({
|
|
|
817
1030
|
<View
|
|
818
1031
|
key={`shade-${b.start}`}
|
|
819
1032
|
pointerEvents="none"
|
|
1033
|
+
accessibilityElementsHidden
|
|
1034
|
+
importantForAccessibility="no-hide-descendants"
|
|
820
1035
|
testID="resource-hours-shade"
|
|
821
1036
|
style={[
|
|
822
1037
|
styles.hshadeBand,
|
|
823
1038
|
{
|
|
824
1039
|
left: (b.start - startHour) * hourWidth,
|
|
825
1040
|
width: (b.end - b.start) * hourWidth,
|
|
826
|
-
|
|
1041
|
+
},
|
|
1042
|
+
renderBusinessHours
|
|
1043
|
+
? null
|
|
1044
|
+
: { backgroundColor: theme.colors.outsideHoursBackground },
|
|
1045
|
+
]}
|
|
1046
|
+
>
|
|
1047
|
+
{renderBusinessHours?.({ date, start: b.start, end: b.end, resource })}
|
|
1048
|
+
</View>
|
|
1049
|
+
))}
|
|
1050
|
+
{backgroundBandsFor(resource).map((b, i) => (
|
|
1051
|
+
<View
|
|
1052
|
+
key={`bg-${i}`}
|
|
1053
|
+
pointerEvents="none"
|
|
1054
|
+
testID="background-event-shade"
|
|
1055
|
+
style={[
|
|
1056
|
+
styles.hshadeBand,
|
|
1057
|
+
{
|
|
1058
|
+
left: (b.startHours - startHour) * hourWidth,
|
|
1059
|
+
width: (b.endHours - b.startHours) * hourWidth,
|
|
1060
|
+
backgroundColor: theme.colors.backgroundEvent,
|
|
827
1061
|
},
|
|
828
1062
|
]}
|
|
829
1063
|
/>
|
|
@@ -839,6 +1073,7 @@ export function ResourceTimeline<T = unknown>({
|
|
|
839
1073
|
]}
|
|
840
1074
|
/>
|
|
841
1075
|
))}
|
|
1076
|
+
{nowLine(false, hourWidth)}
|
|
842
1077
|
{cellEnabled ? (
|
|
843
1078
|
<LaneInteractionLayer
|
|
844
1079
|
resource={resource}
|
|
@@ -868,6 +1103,11 @@ export function ResourceTimeline<T = unknown>({
|
|
|
868
1103
|
key={idx}
|
|
869
1104
|
pe={pe}
|
|
870
1105
|
vertical={false}
|
|
1106
|
+
resources={resources}
|
|
1107
|
+
laneIndex={laneIndex}
|
|
1108
|
+
laneSize={rowHeight}
|
|
1109
|
+
dragActive={dragLaneId === resource.id}
|
|
1110
|
+
onDragActiveChange={setDragLaneId}
|
|
871
1111
|
hourSize={hourWidth}
|
|
872
1112
|
left={left}
|
|
873
1113
|
top={pe.column * laneHeight}
|
|
@@ -958,6 +1198,7 @@ const styles = StyleSheet.create({
|
|
|
958
1198
|
},
|
|
959
1199
|
vheaderText: { fontSize: 13, fontWeight: "600" },
|
|
960
1200
|
vbody: { flexDirection: "row" },
|
|
1201
|
+
laneLifted: { zIndex: 10 },
|
|
961
1202
|
vcolumn: { flex: 1, borderLeftWidth: StyleSheet.hairlineWidth },
|
|
962
1203
|
vhourLabel: { position: "absolute", right: 6, fontSize: 10 },
|
|
963
1204
|
vgridLine: { position: "absolute", left: 0, right: 0, height: StyleSheet.hairlineWidth },
|