@super-calendar/dom 2.14.2 → 2.16.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/README.md +48 -0
- package/dist/index.d.mts +47 -26
- package/dist/index.d.ts +47 -26
- package/dist/index.js +1264 -452
- package/dist/index.mjs +1265 -453
- package/package.json +2 -2
- package/src/Calendar.tsx +13 -0
- package/src/DateRangePicker.tsx +60 -6
- package/src/EventActions.tsx +470 -0
- package/src/InertDiv.ts +7 -0
- package/src/MonthList.tsx +64 -38
- package/src/MonthView.tsx +14 -2
- package/src/ResourceTimeline.tsx +438 -98
- package/src/TimeGrid.tsx +305 -35
- package/src/index.ts +1 -0
package/src/TimeGrid.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type ReactElement,
|
|
18
18
|
type ReactNode,
|
|
19
19
|
type RefAttributes,
|
|
20
|
+
useCallback,
|
|
20
21
|
useEffect,
|
|
21
22
|
useImperativeHandle,
|
|
22
23
|
useMemo,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
type CalendarEvent,
|
|
30
31
|
type CalendarHandle,
|
|
31
32
|
type CalendarMode,
|
|
33
|
+
type CreateGhostArgs,
|
|
32
34
|
cellRangeFromDrag,
|
|
33
35
|
clampMoveStartMinutes,
|
|
34
36
|
resolveDraggedBounds,
|
|
@@ -60,7 +62,16 @@ import {
|
|
|
60
62
|
weekdayFormatToken,
|
|
61
63
|
type WeekStartsOn,
|
|
62
64
|
} from "@super-calendar/core";
|
|
65
|
+
import {
|
|
66
|
+
EventActionsDialog,
|
|
67
|
+
describeEventDates,
|
|
68
|
+
type EventActionsSlot,
|
|
69
|
+
EventActionsMenu,
|
|
70
|
+
type EventEditAction,
|
|
71
|
+
useEventActions,
|
|
72
|
+
} from "./EventActions";
|
|
63
73
|
import { createSlots, dataState, type ResolvedSlot, type SlotStyleProps } from "./slots";
|
|
74
|
+
import { InertDiv } from "./InertDiv";
|
|
64
75
|
import { type DomCalendarTheme, mergeDomTheme } from "./theme";
|
|
65
76
|
import { type EventGrab, waitForHold } from "./touch";
|
|
66
77
|
|
|
@@ -87,7 +98,8 @@ export type TimeGridSlot =
|
|
|
87
98
|
| "event"
|
|
88
99
|
| "eventBox"
|
|
89
100
|
| "nowIndicator"
|
|
90
|
-
| "createGhost"
|
|
101
|
+
| "createGhost"
|
|
102
|
+
| EventActionsSlot;
|
|
91
103
|
|
|
92
104
|
const GUTTER_WIDTH = 56;
|
|
93
105
|
const HOURS_PER_DAY = 24;
|
|
@@ -98,6 +110,21 @@ const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
|
98
110
|
// via `eventGap`.
|
|
99
111
|
const DEFAULT_EVENT_GAP = 1;
|
|
100
112
|
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
|
|
113
|
+
// Floor for the create-by-drag preview, so a press shows a line before it moves.
|
|
114
|
+
const CREATE_PREVIEW_MIN_HEIGHT = 2;
|
|
115
|
+
// Vertical placement of the create preview inside a day column `gridHeight` px
|
|
116
|
+
// tall. Both ends are clamped to the visible hours. The preview is anchored to
|
|
117
|
+
// the nearer column edge, so its minimum height and any custom border
|
|
118
|
+
// grow toward the middle of the grid instead of past its first or last hour.
|
|
119
|
+
function createPreviewPlacement(topPx: number, heightPx: number, gridHeight: number) {
|
|
120
|
+
const start = clamp(topPx, 0, gridHeight);
|
|
121
|
+
const end = clamp(topPx + heightPx, 0, gridHeight);
|
|
122
|
+
const height = Math.min(gridHeight, Math.max(end - start, CREATE_PREVIEW_MIN_HEIGHT));
|
|
123
|
+
const top = Math.min(start, gridHeight - height);
|
|
124
|
+
return top + height / 2 > gridHeight / 2
|
|
125
|
+
? { bottom: gridHeight - top - height, height }
|
|
126
|
+
: { top, height };
|
|
127
|
+
}
|
|
101
128
|
|
|
102
129
|
// Edge auto-advance: how close to the day-columns edge (px) counts as "at the
|
|
103
130
|
// edge", how long to dwell there before paging, and the repeat interval while
|
|
@@ -275,6 +302,16 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
|
|
|
275
302
|
onPressCell?: (date: Date) => void;
|
|
276
303
|
/** Drag empty grid space to create; called with the swept start/end. */
|
|
277
304
|
onCreateEvent?: (start: Date, end: Date) => void;
|
|
305
|
+
/**
|
|
306
|
+
* A component that draws content inside the drag-to-create preview, such as a
|
|
307
|
+
* draft title and the live time range. It receives the snapped `start` and
|
|
308
|
+
* `end` that `onCreateEvent` would get if the pointer were released now, and
|
|
309
|
+
* re-renders as the sweep changes them. The grid keeps positioning, sizing and
|
|
310
|
+
* styling the preview and clips the content to it; the content is
|
|
311
|
+
* non-interactive and hidden from assistive tech. Renders only while a sweep
|
|
312
|
+
* can create, so it needs `onCreateEvent` and does not enable creation itself.
|
|
313
|
+
*/
|
|
314
|
+
renderCreateGhost?: ComponentType<CreateGhostArgs>;
|
|
278
315
|
/** Fires when an event drag begins (e.g. to trigger haptics). */
|
|
279
316
|
onDragStart?: (event: CalendarEvent<T>) => void;
|
|
280
317
|
/**
|
|
@@ -282,6 +319,8 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
|
|
|
282
319
|
* Return `false` to reject the drop (the event snaps back).
|
|
283
320
|
*/
|
|
284
321
|
onDragEvent?: (event: CalendarEvent<T>, start: Date, end: Date) => void | boolean;
|
|
322
|
+
/** Stable, unique event identity for the web editing dialog across data refreshes. */
|
|
323
|
+
getEventId?: (event: CalendarEvent<T>) => string | number;
|
|
285
324
|
/**
|
|
286
325
|
* Page the grid to a new anchor date. Supplying it alongside `onDragEvent`
|
|
287
326
|
* turns on edge auto-advance: dragging an event to the left/right edge and
|
|
@@ -501,8 +540,10 @@ function TimeGridInner<T = unknown>(
|
|
|
501
540
|
onPressDateHeader,
|
|
502
541
|
onPressCell,
|
|
503
542
|
onCreateEvent,
|
|
543
|
+
renderCreateGhost,
|
|
504
544
|
onDragStart,
|
|
505
545
|
onDragEvent,
|
|
546
|
+
getEventId,
|
|
506
547
|
onChangeDate,
|
|
507
548
|
className,
|
|
508
549
|
style,
|
|
@@ -528,6 +569,7 @@ function TimeGridInner<T = unknown>(
|
|
|
528
569
|
const windowHours = windowEnd - windowStart;
|
|
529
570
|
const gutterWidth = hideHours ? 0 : GUTTER_WIDTH;
|
|
530
571
|
const RenderBackground = renderBackgroundEvent;
|
|
572
|
+
const RenderCreateGhost = renderCreateGhost;
|
|
531
573
|
const visibleHours = useMemo(
|
|
532
574
|
() => Array.from({ length: windowHours }, (_, i) => windowStart + i),
|
|
533
575
|
[windowStart, windowHours],
|
|
@@ -570,12 +612,38 @@ function TimeGridInner<T = unknown>(
|
|
|
570
612
|
|
|
571
613
|
// Create-by-drag / tap on empty grid space. Mouse and pen sweep out a new
|
|
572
614
|
// event; on touch the column scrolls instead, so a tap still hits onPressCell.
|
|
615
|
+
// `startPx` stays unsorted: the live range passes it to `cellRangeFromDrag` as
|
|
616
|
+
// the sweep's origin, exactly as the commit does.
|
|
573
617
|
const [createBox, setCreateBox] = useState<{
|
|
574
618
|
dayIndex: number;
|
|
575
|
-
|
|
576
|
-
|
|
619
|
+
dayTime: number;
|
|
620
|
+
startPx: number;
|
|
621
|
+
curPx: number;
|
|
577
622
|
} | null>(null);
|
|
578
|
-
const createOrigin = useRef<{
|
|
623
|
+
const createOrigin = useRef<{
|
|
624
|
+
pointerId: number;
|
|
625
|
+
clientY: number;
|
|
626
|
+
el: HTMLElement;
|
|
627
|
+
dayIndex: number;
|
|
628
|
+
dayTime: number;
|
|
629
|
+
creating: boolean;
|
|
630
|
+
startPx: number;
|
|
631
|
+
} | null>(null);
|
|
632
|
+
const createActive = createBox !== null;
|
|
633
|
+
useEffect(() => {
|
|
634
|
+
if (!createActive) return;
|
|
635
|
+
// Scrolling a column or an ancestor moves it beneath the held pointer.
|
|
636
|
+
const onScroll = () => {
|
|
637
|
+
const origin = createOrigin.current;
|
|
638
|
+
if (!origin) return;
|
|
639
|
+
const curPx = origin.clientY - origin.el.getBoundingClientRect().top;
|
|
640
|
+
setCreateBox((current) =>
|
|
641
|
+
current && current.curPx !== curPx ? { ...current, curPx } : current,
|
|
642
|
+
);
|
|
643
|
+
};
|
|
644
|
+
window.addEventListener("scroll", onScroll, true);
|
|
645
|
+
return () => window.removeEventListener("scroll", onScroll, true);
|
|
646
|
+
}, [createActive]);
|
|
579
647
|
// Touch never sweeps, so a tap presses the cell from its click, which the
|
|
580
648
|
// browser skips when the finger scrolled the grid instead.
|
|
581
649
|
const cellTouchRef = useRef<{ pointerId: number; x: number; y: number } | null>(null);
|
|
@@ -634,6 +702,97 @@ function TimeGridInner<T = unknown>(
|
|
|
634
702
|
overlapsOtherEvents(events, event, start, end) ? false : onDragEvent(event, start, end)
|
|
635
703
|
: onDragEvent;
|
|
636
704
|
|
|
705
|
+
// What a drag may change on an event: `draggable: false` locks it, and
|
|
706
|
+
// `startEditable`/`durationEditable` (per event, falling back to the grid
|
|
707
|
+
// props) split whether it can be moved vs resized.
|
|
708
|
+
const editability = (event: CalendarEvent<T>) => {
|
|
709
|
+
const editable = !!onDragEvent && event.draggable !== false;
|
|
710
|
+
return {
|
|
711
|
+
canMove: editable && (event.startEditable ?? eventStartEditable),
|
|
712
|
+
canResize: editable && (event.durationEditable ?? eventDurationEditable),
|
|
713
|
+
};
|
|
714
|
+
};
|
|
715
|
+
const eventLabel = (event: CalendarEvent<T>) =>
|
|
716
|
+
eventAccessibilityLabel
|
|
717
|
+
? eventAccessibilityLabel(event, { mode, isAllDay: false, ampm })
|
|
718
|
+
: defaultEventAccessibilityLabel({
|
|
719
|
+
title: event.title,
|
|
720
|
+
isAllDay: false,
|
|
721
|
+
start: event.start,
|
|
722
|
+
end: event.end,
|
|
723
|
+
ampm,
|
|
724
|
+
labels,
|
|
725
|
+
});
|
|
726
|
+
const eventDescription = (event: CalendarEvent<T>) =>
|
|
727
|
+
`${describeEventDates(event)}, ${eventLabel(event)}`;
|
|
728
|
+
// The actions dialog's steps, matching the native screen-reader actions: one
|
|
729
|
+
// snap step, or one page of days, through the same commit path as a drop.
|
|
730
|
+
const pageDays = pageStepDays(mode, date, weekStartsOn, numberOfDays);
|
|
731
|
+
const actionDelta = (id: string): [number, number] | null => {
|
|
732
|
+
const page = pageDays * HOURS_PER_DAY * 60;
|
|
733
|
+
switch (id) {
|
|
734
|
+
case "move-later":
|
|
735
|
+
return [snapMinutes, snapMinutes];
|
|
736
|
+
case "move-earlier":
|
|
737
|
+
return [-snapMinutes, -snapMinutes];
|
|
738
|
+
case "extend":
|
|
739
|
+
return [0, snapMinutes];
|
|
740
|
+
case "shorten":
|
|
741
|
+
return [0, -snapMinutes];
|
|
742
|
+
case "move-next-page":
|
|
743
|
+
return [page, page];
|
|
744
|
+
case "move-previous-page":
|
|
745
|
+
return [-page, -page];
|
|
746
|
+
default:
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
const editActions = (event: CalendarEvent<T>): EventEditAction[] => {
|
|
751
|
+
if (isAllDayEvent(event) || isBackgroundEvent(event)) return [];
|
|
752
|
+
const { canMove, canResize } = editability(event);
|
|
753
|
+
const action = (id: string, label: string): EventEditAction => {
|
|
754
|
+
const [startDelta, endDelta] = actionDelta(id) ?? [0, 0];
|
|
755
|
+
const next = resolveDraggedBounds(event.start, event.end, startDelta, endDelta, snapMinutes);
|
|
756
|
+
return { id, label, available: next !== null };
|
|
757
|
+
};
|
|
758
|
+
return [
|
|
759
|
+
...(canMove
|
|
760
|
+
? [
|
|
761
|
+
action("move-later", labels.moveLater(snapMinutes)),
|
|
762
|
+
action("move-earlier", labels.moveEarlier(snapMinutes)),
|
|
763
|
+
]
|
|
764
|
+
: []),
|
|
765
|
+
...(canResize
|
|
766
|
+
? [
|
|
767
|
+
action("extend", labels.extend(snapMinutes)),
|
|
768
|
+
action("shorten", labels.shorten(snapMinutes)),
|
|
769
|
+
]
|
|
770
|
+
: []),
|
|
771
|
+
...(canMove
|
|
772
|
+
? [
|
|
773
|
+
action("move-next-page", labels.moveToNextPage(pageDays, mode)),
|
|
774
|
+
action("move-previous-page", labels.moveToPreviousPage(pageDays, mode)),
|
|
775
|
+
]
|
|
776
|
+
: []),
|
|
777
|
+
];
|
|
778
|
+
};
|
|
779
|
+
const eventActions = useEventActions(
|
|
780
|
+
events,
|
|
781
|
+
editActions,
|
|
782
|
+
(event, id) => {
|
|
783
|
+
const delta = actionDelta(id);
|
|
784
|
+
const next =
|
|
785
|
+
delta && resolveDraggedBounds(event.start, event.end, delta[0], delta[1], snapMinutes);
|
|
786
|
+
if (!next || onDragEventRef.current?.(event, next.start, next.end) === false) return null;
|
|
787
|
+
return (candidate) =>
|
|
788
|
+
candidate !== event &&
|
|
789
|
+
candidate.start.getTime() === next.start.getTime() &&
|
|
790
|
+
candidate.end.getTime() === next.end.getTime() &&
|
|
791
|
+
candidate.title === event.title;
|
|
792
|
+
},
|
|
793
|
+
getEventId,
|
|
794
|
+
);
|
|
795
|
+
|
|
637
796
|
const allDayByDay = useMemo(
|
|
638
797
|
// A multi-day all-day event shows in every column it overlaps (matching the
|
|
639
798
|
// native AllDayLane), not just its start day.
|
|
@@ -1158,8 +1317,17 @@ function TimeGridInner<T = unknown>(
|
|
|
1158
1317
|
} catch {
|
|
1159
1318
|
// Best-effort capture.
|
|
1160
1319
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1320
|
+
const dayTime = days[dayIndex].getTime();
|
|
1321
|
+
createOrigin.current = {
|
|
1322
|
+
pointerId: e.pointerId,
|
|
1323
|
+
clientY: e.clientY,
|
|
1324
|
+
el,
|
|
1325
|
+
dayIndex,
|
|
1326
|
+
dayTime,
|
|
1327
|
+
creating: !!onCreateEvent,
|
|
1328
|
+
startPx,
|
|
1329
|
+
};
|
|
1330
|
+
setCreateBox({ dayIndex, dayTime, startPx, curPx: startPx });
|
|
1163
1331
|
};
|
|
1164
1332
|
const moveCreate = (e: ReactPointerEvent) => {
|
|
1165
1333
|
const touch = cellTouchRef.current;
|
|
@@ -1172,11 +1340,12 @@ function TimeGridInner<T = unknown>(
|
|
|
1172
1340
|
}
|
|
1173
1341
|
const o = createOrigin.current;
|
|
1174
1342
|
if (!o) return;
|
|
1175
|
-
|
|
1343
|
+
o.clientY = e.clientY;
|
|
1176
1344
|
setCreateBox({
|
|
1177
1345
|
dayIndex: o.dayIndex,
|
|
1178
|
-
|
|
1179
|
-
|
|
1346
|
+
dayTime: o.dayTime,
|
|
1347
|
+
startPx: o.startPx,
|
|
1348
|
+
curPx: pxFromTop(o.el, e.clientY),
|
|
1180
1349
|
});
|
|
1181
1350
|
};
|
|
1182
1351
|
const endCreate = (e: ReactPointerEvent) => {
|
|
@@ -1216,11 +1385,75 @@ function TimeGridInner<T = unknown>(
|
|
|
1216
1385
|
};
|
|
1217
1386
|
// A gesture the browser/OS cancels (scroll takeover, etc.) must not commit a
|
|
1218
1387
|
// create — just drop the in-progress state.
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1388
|
+
const clearCreate = useCallback(() => {
|
|
1389
|
+
const previous = createOrigin.current;
|
|
1221
1390
|
createOrigin.current = null;
|
|
1222
1391
|
setCreateBox(null);
|
|
1392
|
+
try {
|
|
1393
|
+
previous?.el.releasePointerCapture?.(previous.pointerId);
|
|
1394
|
+
} catch {
|
|
1395
|
+
// The browser may have already released capture.
|
|
1396
|
+
}
|
|
1397
|
+
}, []);
|
|
1398
|
+
const cancelCreate = () => {
|
|
1399
|
+
cellTouchRef.current = null;
|
|
1400
|
+
clearCreate();
|
|
1401
|
+
};
|
|
1402
|
+
// Without capture the column stops seeing the sweep's moves and release, so
|
|
1403
|
+
// drop it. Leaves `cellTouchRef` alone: touch taps resolve on the later click.
|
|
1404
|
+
const loseCreateCapture = (e: ReactPointerEvent) => {
|
|
1405
|
+
if (createOrigin.current?.pointerId !== e.pointerId) return;
|
|
1406
|
+
clearCreate();
|
|
1223
1407
|
};
|
|
1408
|
+
// Pointer capture does not move keyboard focus to the grid.
|
|
1409
|
+
useEffect(() => {
|
|
1410
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
1411
|
+
if (event.key !== "Escape" || !createOrigin.current) return;
|
|
1412
|
+
event.preventDefault();
|
|
1413
|
+
event.stopPropagation();
|
|
1414
|
+
clearCreate();
|
|
1415
|
+
};
|
|
1416
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1417
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
1418
|
+
}, [clearCreate]);
|
|
1419
|
+
// What `onCreateEvent` would receive if the sweep ended here. The props keep
|
|
1420
|
+
// the same `Date`s while that range holds, so content effects keyed on them
|
|
1421
|
+
// re-run only when it changes.
|
|
1422
|
+
const liveRange =
|
|
1423
|
+
createBox &&
|
|
1424
|
+
RenderCreateGhost &&
|
|
1425
|
+
onCreateEvent &&
|
|
1426
|
+
days[createBox.dayIndex]?.getTime() === createBox.dayTime
|
|
1427
|
+
? cellRangeFromDrag(
|
|
1428
|
+
days[createBox.dayIndex],
|
|
1429
|
+
createBox.startPx,
|
|
1430
|
+
createBox.curPx,
|
|
1431
|
+
hourHeight,
|
|
1432
|
+
windowStart,
|
|
1433
|
+
snapMinutes,
|
|
1434
|
+
)
|
|
1435
|
+
: null;
|
|
1436
|
+
const liveStart = liveRange?.start.getTime();
|
|
1437
|
+
const liveEnd = liveRange?.end.getTime();
|
|
1438
|
+
const createRange = useMemo(
|
|
1439
|
+
() =>
|
|
1440
|
+
liveStart === undefined || liveEnd === undefined
|
|
1441
|
+
? null
|
|
1442
|
+
: { start: new Date(liveStart), end: new Date(liveEnd) },
|
|
1443
|
+
[liveStart, liveEnd],
|
|
1444
|
+
);
|
|
1445
|
+
// Disabling creation or replacing the pressed day invalidates the whole sweep.
|
|
1446
|
+
useEffect(() => {
|
|
1447
|
+
const origin = createOrigin.current;
|
|
1448
|
+
if (
|
|
1449
|
+
origin &&
|
|
1450
|
+
(!origin.el.isConnected ||
|
|
1451
|
+
!cellEnabled ||
|
|
1452
|
+
(origin.creating && !onCreateEvent) ||
|
|
1453
|
+
days[origin.dayIndex]?.getTime() !== origin.dayTime)
|
|
1454
|
+
)
|
|
1455
|
+
clearCreate();
|
|
1456
|
+
});
|
|
1224
1457
|
|
|
1225
1458
|
// Per-day layout and shading are pure functions of days/events/businessHours,
|
|
1226
1459
|
// so memoize them — otherwise every drag pointermove (which calls setDrag)
|
|
@@ -1396,9 +1629,11 @@ function TimeGridInner<T = unknown>(
|
|
|
1396
1629
|
const slotHeight = hourHeight / timeslots;
|
|
1397
1630
|
return `${hourLines}, repeating-linear-gradient(to bottom, transparent 0, transparent ${slotHeight - 1}px, ${theme.gridLine}80 ${slotHeight - 1}px, ${theme.gridLine}80 ${slotHeight}px)`;
|
|
1398
1631
|
}, [hourHeight, timeslots, theme.gridLine]);
|
|
1399
|
-
|
|
1632
|
+
const openActionsEvent = eventActions.openEvent;
|
|
1400
1633
|
return (
|
|
1401
1634
|
<div
|
|
1635
|
+
ref={eventActions.rootRef}
|
|
1636
|
+
tabIndex={-1}
|
|
1402
1637
|
className={className}
|
|
1403
1638
|
style={{
|
|
1404
1639
|
fontFamily: theme.fontFamily,
|
|
@@ -1408,6 +1643,25 @@ function TimeGridInner<T = unknown>(
|
|
|
1408
1643
|
...style,
|
|
1409
1644
|
}}
|
|
1410
1645
|
>
|
|
1646
|
+
<EventActionsMenu
|
|
1647
|
+
events={[
|
|
1648
|
+
...new Set(
|
|
1649
|
+
positionedByDay
|
|
1650
|
+
.flat()
|
|
1651
|
+
.filter(
|
|
1652
|
+
(pe) => pe.startHours < windowEnd && pe.startHours + pe.durationHours > windowStart,
|
|
1653
|
+
)
|
|
1654
|
+
.map((pe) => pe.event),
|
|
1655
|
+
),
|
|
1656
|
+
].filter((event) => editActions(event).length > 0)}
|
|
1657
|
+
label={labels.editEvents}
|
|
1658
|
+
labelFor={(event) => labels.eventActions(event.title ?? "")}
|
|
1659
|
+
descriptionFor={eventDescription}
|
|
1660
|
+
onSelect={eventActions.select}
|
|
1661
|
+
rootRef={eventActions.rootRef}
|
|
1662
|
+
slot={slot}
|
|
1663
|
+
theme={theme}
|
|
1664
|
+
/>
|
|
1411
1665
|
{/* Header */}
|
|
1412
1666
|
<div
|
|
1413
1667
|
{...slot("header", {
|
|
@@ -1665,7 +1919,11 @@ function TimeGridInner<T = unknown>(
|
|
|
1665
1919
|
nowHours <= windowEnd;
|
|
1666
1920
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
1667
1921
|
const bands = bandsByDay[dayIndex];
|
|
1668
|
-
const ghost =
|
|
1922
|
+
const ghost =
|
|
1923
|
+
createBox?.dayIndex === dayIndex && createBox.dayTime === day.getTime()
|
|
1924
|
+
? createBox
|
|
1925
|
+
: null;
|
|
1926
|
+
const ghostRange = ghost ? createRange : null;
|
|
1669
1927
|
// The tail of a move that runs past midnight, previewed at the top of
|
|
1670
1928
|
// this column. The dragged event is looked up from its `drag.key`
|
|
1671
1929
|
// ("<originColumn>:<index>"), so no extra state has to track it.
|
|
@@ -1685,6 +1943,7 @@ function TimeGridInner<T = unknown>(
|
|
|
1685
1943
|
onPointerMove={cellEnabled ? moveCreate : undefined}
|
|
1686
1944
|
onPointerUp={cellEnabled ? endCreate : undefined}
|
|
1687
1945
|
onPointerCancel={cellEnabled ? cancelCreate : undefined}
|
|
1946
|
+
onLostPointerCapture={cellEnabled ? loseCreateCapture : undefined}
|
|
1688
1947
|
onClick={cellEnabled ? (e) => tapCell(e, dayIndex) : undefined}
|
|
1689
1948
|
{...dataState({ "data-today": getIsToday(day), "data-weekend": isWeekend(day) })}
|
|
1690
1949
|
{...slot("dayColumn", {
|
|
@@ -1816,12 +2075,7 @@ function TimeGridInner<T = unknown>(
|
|
|
1816
2075
|
};
|
|
1817
2076
|
// `draggable: false` locks a single event: it keeps its normal
|
|
1818
2077
|
// look and still responds to clicks, it just can't be dragged.
|
|
1819
|
-
|
|
1820
|
-
// the grid props) split whether it can be moved vs resized.
|
|
1821
|
-
const editable = !!onDragEvent && pe.event.draggable !== false;
|
|
1822
|
-
const canMove = editable && (pe.event.startEditable ?? eventStartEditable);
|
|
1823
|
-
const canResize =
|
|
1824
|
-
editable && (pe.event.durationEditable ?? eventDurationEditable);
|
|
2078
|
+
const { canMove, canResize } = editability(pe.event);
|
|
1825
2079
|
return (
|
|
1826
2080
|
<div
|
|
1827
2081
|
key={idx}
|
|
@@ -1830,18 +2084,7 @@ function TimeGridInner<T = unknown>(
|
|
|
1830
2084
|
// faster path between events without removing any from Tab order.
|
|
1831
2085
|
tabIndex={0}
|
|
1832
2086
|
data-event-key={keyboardEventNavigation ? key : undefined}
|
|
1833
|
-
aria-label={
|
|
1834
|
-
eventAccessibilityLabel
|
|
1835
|
-
? eventAccessibilityLabel(pe.event, { mode, isAllDay: false, ampm })
|
|
1836
|
-
: defaultEventAccessibilityLabel({
|
|
1837
|
-
title: pe.event.title,
|
|
1838
|
-
isAllDay: false,
|
|
1839
|
-
start: pe.event.start,
|
|
1840
|
-
end: pe.event.end,
|
|
1841
|
-
ampm,
|
|
1842
|
-
labels,
|
|
1843
|
-
})
|
|
1844
|
-
}
|
|
2087
|
+
aria-label={eventLabel(pe.event)}
|
|
1845
2088
|
onKeyDown={(e) => {
|
|
1846
2089
|
if (e.key === "Enter" || e.key === " ") {
|
|
1847
2090
|
e.preventDefault();
|
|
@@ -2053,15 +2296,23 @@ function TimeGridInner<T = unknown>(
|
|
|
2053
2296
|
</div>
|
|
2054
2297
|
) : null}
|
|
2055
2298
|
{ghost ? (
|
|
2056
|
-
<
|
|
2299
|
+
<InertDiv
|
|
2057
2300
|
aria-hidden
|
|
2301
|
+
// Custom content stays out of the tab order and pointer input.
|
|
2302
|
+
inert={!!ghostRange}
|
|
2058
2303
|
{...slot("createGhost", {
|
|
2059
2304
|
base: {
|
|
2060
2305
|
position: "absolute",
|
|
2061
2306
|
left: eventGap,
|
|
2062
2307
|
right: eventGap,
|
|
2063
|
-
|
|
2064
|
-
|
|
2308
|
+
...createPreviewPlacement(
|
|
2309
|
+
Math.min(ghost.startPx, ghost.curPx),
|
|
2310
|
+
Math.abs(ghost.curPx - ghost.startPx),
|
|
2311
|
+
totalHeight,
|
|
2312
|
+
),
|
|
2313
|
+
// Borders, including custom ones, stay inside the placed box.
|
|
2314
|
+
boxSizing: "border-box",
|
|
2315
|
+
...(ghostRange ? { overflow: "hidden" } : null),
|
|
2065
2316
|
opacity: 0.7,
|
|
2066
2317
|
pointerEvents: "none",
|
|
2067
2318
|
zIndex: 2,
|
|
@@ -2072,7 +2323,11 @@ function TimeGridInner<T = unknown>(
|
|
|
2072
2323
|
borderRadius: 6,
|
|
2073
2324
|
},
|
|
2074
2325
|
})}
|
|
2075
|
-
|
|
2326
|
+
>
|
|
2327
|
+
{ghostRange && RenderCreateGhost ? (
|
|
2328
|
+
<RenderCreateGhost start={ghostRange.start} end={ghostRange.end} />
|
|
2329
|
+
) : null}
|
|
2330
|
+
</InertDiv>
|
|
2076
2331
|
) : null}
|
|
2077
2332
|
</div>
|
|
2078
2333
|
);
|
|
@@ -2124,6 +2379,21 @@ function TimeGridInner<T = unknown>(
|
|
|
2124
2379
|
)}
|
|
2125
2380
|
</div>
|
|
2126
2381
|
) : null}
|
|
2382
|
+
{openActionsEvent ? (
|
|
2383
|
+
<EventActionsDialog
|
|
2384
|
+
dialogRef={eventActions.dialogRef}
|
|
2385
|
+
title={labels.eventActions(openActionsEvent.title ?? "")}
|
|
2386
|
+
description={eventDescription(openActionsEvent)}
|
|
2387
|
+
actions={editActions(openActionsEvent)}
|
|
2388
|
+
closeLabel={labels.close}
|
|
2389
|
+
rejectedLabel={labels.eventChangeRejected}
|
|
2390
|
+
rejections={eventActions.rejections}
|
|
2391
|
+
onAction={eventActions.run}
|
|
2392
|
+
onClose={() => eventActions.close(true)}
|
|
2393
|
+
slot={slot}
|
|
2394
|
+
theme={theme}
|
|
2395
|
+
/>
|
|
2396
|
+
) : null}
|
|
2127
2397
|
</div>
|
|
2128
2398
|
);
|
|
2129
2399
|
}
|