@super-calendar/dom 2.9.0 → 2.9.1
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 +7 -0
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +51 -4
- package/dist/index.mjs +51 -4
- package/package.json +2 -2
- package/src/Calendar.tsx +7 -1
- package/src/TimeGrid.tsx +85 -4
package/README.md
CHANGED
|
@@ -52,6 +52,13 @@ export function MyCalendar() {
|
|
|
52
52
|
|
|
53
53
|
For a custom picker, pair the headless hooks (`useDateRange`, `useMonthGrid`) with `MonthList` and `TimeGrid`, all re-exported from this package.
|
|
54
54
|
|
|
55
|
+
## Moving events
|
|
56
|
+
|
|
57
|
+
Pass `onDragEvent` and update your event state with the returned `start` and `end`.
|
|
58
|
+
On the time grid, dragging any segment of a multi-day event previews the whole
|
|
59
|
+
range moving together and preserves its duration. Drag a resize grip to change
|
|
60
|
+
only the start or end. See the [dragging guide](https://super-calendar.afonsojramos.me/guides/dragging).
|
|
61
|
+
|
|
55
62
|
## Styling
|
|
56
63
|
|
|
57
64
|
Out of the box the calendar is fully styled from the theme, no stylesheet required. To restyle a specific part with **Tailwind** or your own CSS, every element is a named slot: pass `classNames` (or `styles`) per slot, and use `data-*` state variants like `data-[today]:`.
|
package/dist/index.d.mts
CHANGED
|
@@ -495,7 +495,13 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
|
|
|
495
495
|
* a day-grouped agenda list, and the others a time grid.
|
|
496
496
|
*/
|
|
497
497
|
mode?: CalendarMode$1;
|
|
498
|
-
/**
|
|
498
|
+
/**
|
|
499
|
+
* Controlled anchor date, read in the device's local time zone; change it
|
|
500
|
+
* (e.g. from your own header) to navigate. Construct it as a local date
|
|
501
|
+
* (`new Date(2026, 7, 24)`), not a UTC instant:
|
|
502
|
+
* `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
|
|
503
|
+
* and anchors the previous week.
|
|
504
|
+
*/
|
|
499
505
|
date: Date;
|
|
500
506
|
/**
|
|
501
507
|
* Fires with the next/previous period's date when the user pages the focused
|
package/dist/index.d.ts
CHANGED
|
@@ -495,7 +495,13 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
|
|
|
495
495
|
* a day-grouped agenda list, and the others a time grid.
|
|
496
496
|
*/
|
|
497
497
|
mode?: CalendarMode$1;
|
|
498
|
-
/**
|
|
498
|
+
/**
|
|
499
|
+
* Controlled anchor date, read in the device's local time zone; change it
|
|
500
|
+
* (e.g. from your own header) to navigate. Construct it as a local date
|
|
501
|
+
* (`new Date(2026, 7, 24)`), not a UTC instant:
|
|
502
|
+
* `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
|
|
503
|
+
* and anchors the previous week.
|
|
504
|
+
*/
|
|
499
505
|
date: Date;
|
|
500
506
|
/**
|
|
501
507
|
* Fires with the next/previous period's date when the user pages the focused
|
package/dist/index.js
CHANGED
|
@@ -1624,7 +1624,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1624
1624
|
const segmentStart = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
|
|
1625
1625
|
const segmentEnd = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
|
|
1626
1626
|
const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
|
|
1627
|
-
const endShift = d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
1627
|
+
const endShift = d.kind === "move" ? startShift : d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
1628
1628
|
const start = new Date(held.event.start.getTime() + startShift);
|
|
1629
1629
|
const end = new Date(held.event.end.getTime() + endShift);
|
|
1630
1630
|
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
@@ -1756,6 +1756,19 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1756
1756
|
setCreateBox(null);
|
|
1757
1757
|
};
|
|
1758
1758
|
const positionedByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
|
|
1759
|
+
const moveOrigin = dragOrigin.current;
|
|
1760
|
+
const heldEvent = draggedRef.current?.event;
|
|
1761
|
+
const movingEvent = heldEvent && (events.includes(heldEvent) ? heldEvent : events.find((event) => event.start.getTime() === heldEvent.start.getTime() && event.end.getTime() === heldEvent.end.getTime() && event.title === heldEvent.title) ?? heldEvent);
|
|
1762
|
+
const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
|
|
1763
|
+
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
1764
|
+
const shift = (0, date_fns.addMinutes)((0, date_fns.startOfDay)(target), Math.round(drag.startHours * 60)).getTime() - moveOrigin.segmentStart.getTime();
|
|
1765
|
+
return {
|
|
1766
|
+
...movingEvent,
|
|
1767
|
+
start: new Date(movingEvent.start.getTime() + shift),
|
|
1768
|
+
end: new Date(movingEvent.end.getTime() + shift),
|
|
1769
|
+
allDay: false
|
|
1770
|
+
};
|
|
1771
|
+
})() : null;
|
|
1759
1772
|
const spillPreviewFor = (dayIndex) => {
|
|
1760
1773
|
if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
|
|
1761
1774
|
const dragged = draggedRef.current?.event;
|
|
@@ -2078,7 +2091,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2078
2091
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
2079
2092
|
const bands = bandsByDay[dayIndex];
|
|
2080
2093
|
const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
|
|
2081
|
-
const spill = spillPreviewFor(dayIndex);
|
|
2094
|
+
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
2095
|
+
const moveSegment = multiDayMove ? (0, _super_calendar_core.layoutDayEvents)([multiDayMove], day)[0] : void 0;
|
|
2082
2096
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2083
2097
|
"data-date": day.toISOString(),
|
|
2084
2098
|
onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
|
|
@@ -2150,7 +2164,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2150
2164
|
}),
|
|
2151
2165
|
positioned.map((pe, idx) => {
|
|
2152
2166
|
const key = `${dayIndex}:${idx}`;
|
|
2153
|
-
const active = !paged && drag?.key === key ? drag : null;
|
|
2167
|
+
const active = !paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent) ? drag : null;
|
|
2168
|
+
const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
|
|
2154
2169
|
const startHours = active ? active.startHours : pe.startHours;
|
|
2155
2170
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
2156
2171
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
@@ -2196,7 +2211,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2196
2211
|
},
|
|
2197
2212
|
onPointerDown: canMove ? (e) => beginDrag(e, pe, key, "move", dayIndex, onPress) : void 0,
|
|
2198
2213
|
onClick: canMove ? void 0 : onPress,
|
|
2199
|
-
...dataState({ "data-dragging": !!active }),
|
|
2214
|
+
...dataState({ "data-dragging": !!active && !hiddenForMove }),
|
|
2200
2215
|
...slot("event", { base: {
|
|
2201
2216
|
position: "absolute",
|
|
2202
2217
|
top,
|
|
@@ -2207,6 +2222,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2207
2222
|
touchAction: canMove ? "none" : "auto",
|
|
2208
2223
|
zIndex: active ? 3 : 1,
|
|
2209
2224
|
opacity: active ? .85 : 1,
|
|
2225
|
+
visibility: hiddenForMove ? "hidden" : void 0,
|
|
2210
2226
|
...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
|
|
2211
2227
|
} }),
|
|
2212
2228
|
children: [
|
|
@@ -2248,6 +2264,37 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2248
2264
|
]
|
|
2249
2265
|
}, idx);
|
|
2250
2266
|
}),
|
|
2267
|
+
moveSegment ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2268
|
+
"aria-hidden": true,
|
|
2269
|
+
...dataState({ "data-dragging": true }),
|
|
2270
|
+
...slot("event", { base: {
|
|
2271
|
+
position: "absolute",
|
|
2272
|
+
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
2273
|
+
left: 1,
|
|
2274
|
+
right: 1,
|
|
2275
|
+
height: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
2276
|
+
pointerEvents: "none",
|
|
2277
|
+
zIndex: 3,
|
|
2278
|
+
opacity: .85
|
|
2279
|
+
} }),
|
|
2280
|
+
children: (() => {
|
|
2281
|
+
const args = {
|
|
2282
|
+
event: moveSegment.event,
|
|
2283
|
+
mode,
|
|
2284
|
+
isAllDay: false,
|
|
2285
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
2286
|
+
continuesBefore: moveSegment.continuesBefore,
|
|
2287
|
+
continuesAfter: moveSegment.continuesAfter,
|
|
2288
|
+
ampm,
|
|
2289
|
+
onPress: () => {}
|
|
2290
|
+
};
|
|
2291
|
+
return Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
|
|
2292
|
+
...args,
|
|
2293
|
+
theme,
|
|
2294
|
+
boxProps: slot("eventBox")
|
|
2295
|
+
});
|
|
2296
|
+
})()
|
|
2297
|
+
}) : null,
|
|
2251
2298
|
spill ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2252
2299
|
"aria-hidden": true,
|
|
2253
2300
|
...dataState({ "data-dragging": true }),
|
package/dist/index.mjs
CHANGED
|
@@ -1623,7 +1623,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1623
1623
|
const segmentStart = addMinutes(base, Math.round(d.startHours * 60));
|
|
1624
1624
|
const segmentEnd = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
|
|
1625
1625
|
const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
|
|
1626
|
-
const endShift = d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
1626
|
+
const endShift = d.kind === "move" ? startShift : d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
1627
1627
|
const start = new Date(held.event.start.getTime() + startShift);
|
|
1628
1628
|
const end = new Date(held.event.end.getTime() + endShift);
|
|
1629
1629
|
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
@@ -1755,6 +1755,19 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1755
1755
|
setCreateBox(null);
|
|
1756
1756
|
};
|
|
1757
1757
|
const positionedByDay = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
|
|
1758
|
+
const moveOrigin = dragOrigin.current;
|
|
1759
|
+
const heldEvent = draggedRef.current?.event;
|
|
1760
|
+
const movingEvent = heldEvent && (events.includes(heldEvent) ? heldEvent : events.find((event) => event.start.getTime() === heldEvent.start.getTime() && event.end.getTime() === heldEvent.end.getTime() && event.title === heldEvent.title) ?? heldEvent);
|
|
1761
|
+
const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
|
|
1762
|
+
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
1763
|
+
const shift = addMinutes(startOfDay(target), Math.round(drag.startHours * 60)).getTime() - moveOrigin.segmentStart.getTime();
|
|
1764
|
+
return {
|
|
1765
|
+
...movingEvent,
|
|
1766
|
+
start: new Date(movingEvent.start.getTime() + shift),
|
|
1767
|
+
end: new Date(movingEvent.end.getTime() + shift),
|
|
1768
|
+
allDay: false
|
|
1769
|
+
};
|
|
1770
|
+
})() : null;
|
|
1758
1771
|
const spillPreviewFor = (dayIndex) => {
|
|
1759
1772
|
if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
|
|
1760
1773
|
const dragged = draggedRef.current?.event;
|
|
@@ -2077,7 +2090,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2077
2090
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
2078
2091
|
const bands = bandsByDay[dayIndex];
|
|
2079
2092
|
const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
|
|
2080
|
-
const spill = spillPreviewFor(dayIndex);
|
|
2093
|
+
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
2094
|
+
const moveSegment = multiDayMove ? layoutDayEvents$1([multiDayMove], day)[0] : void 0;
|
|
2081
2095
|
return /* @__PURE__ */ jsxs("div", {
|
|
2082
2096
|
"data-date": day.toISOString(),
|
|
2083
2097
|
onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
|
|
@@ -2149,7 +2163,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2149
2163
|
}),
|
|
2150
2164
|
positioned.map((pe, idx) => {
|
|
2151
2165
|
const key = `${dayIndex}:${idx}`;
|
|
2152
|
-
const active = !paged && drag?.key === key ? drag : null;
|
|
2166
|
+
const active = !paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent) ? drag : null;
|
|
2167
|
+
const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
|
|
2153
2168
|
const startHours = active ? active.startHours : pe.startHours;
|
|
2154
2169
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
2155
2170
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
@@ -2195,7 +2210,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2195
2210
|
},
|
|
2196
2211
|
onPointerDown: canMove ? (e) => beginDrag(e, pe, key, "move", dayIndex, onPress) : void 0,
|
|
2197
2212
|
onClick: canMove ? void 0 : onPress,
|
|
2198
|
-
...dataState({ "data-dragging": !!active }),
|
|
2213
|
+
...dataState({ "data-dragging": !!active && !hiddenForMove }),
|
|
2199
2214
|
...slot("event", { base: {
|
|
2200
2215
|
position: "absolute",
|
|
2201
2216
|
top,
|
|
@@ -2206,6 +2221,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2206
2221
|
touchAction: canMove ? "none" : "auto",
|
|
2207
2222
|
zIndex: active ? 3 : 1,
|
|
2208
2223
|
opacity: active ? .85 : 1,
|
|
2224
|
+
visibility: hiddenForMove ? "hidden" : void 0,
|
|
2209
2225
|
...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
|
|
2210
2226
|
} }),
|
|
2211
2227
|
children: [
|
|
@@ -2247,6 +2263,37 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2247
2263
|
]
|
|
2248
2264
|
}, idx);
|
|
2249
2265
|
}),
|
|
2266
|
+
moveSegment ? /* @__PURE__ */ jsx("div", {
|
|
2267
|
+
"aria-hidden": true,
|
|
2268
|
+
...dataState({ "data-dragging": true }),
|
|
2269
|
+
...slot("event", { base: {
|
|
2270
|
+
position: "absolute",
|
|
2271
|
+
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
2272
|
+
left: 1,
|
|
2273
|
+
right: 1,
|
|
2274
|
+
height: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
2275
|
+
pointerEvents: "none",
|
|
2276
|
+
zIndex: 3,
|
|
2277
|
+
opacity: .85
|
|
2278
|
+
} }),
|
|
2279
|
+
children: (() => {
|
|
2280
|
+
const args = {
|
|
2281
|
+
event: moveSegment.event,
|
|
2282
|
+
mode,
|
|
2283
|
+
isAllDay: false,
|
|
2284
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
2285
|
+
continuesBefore: moveSegment.continuesBefore,
|
|
2286
|
+
continuesAfter: moveSegment.continuesAfter,
|
|
2287
|
+
ampm,
|
|
2288
|
+
onPress: () => {}
|
|
2289
|
+
};
|
|
2290
|
+
return Renderer ? /* @__PURE__ */ jsx(Renderer, { ...args }) : /* @__PURE__ */ jsx(DefaultDomEvent, {
|
|
2291
|
+
...args,
|
|
2292
|
+
theme,
|
|
2293
|
+
boxProps: slot("eventBox")
|
|
2294
|
+
});
|
|
2295
|
+
})()
|
|
2296
|
+
}) : null,
|
|
2250
2297
|
spill ? /* @__PURE__ */ jsx("div", {
|
|
2251
2298
|
"aria-hidden": true,
|
|
2252
2299
|
...dataState({ "data-dragging": true }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/dom",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"description": "Virtualized month / week / day calendar and date picker for react-dom. No React Native, no react-native-web.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"calendar",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@super-calendar/core": "2.9.
|
|
51
|
+
"@super-calendar/core": "2.9.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@legendapp/list": ">=3",
|
package/src/Calendar.tsx
CHANGED
|
@@ -55,7 +55,13 @@ export interface CalendarProps<T = unknown>
|
|
|
55
55
|
* a day-grouped agenda list, and the others a time grid.
|
|
56
56
|
*/
|
|
57
57
|
mode?: CalendarMode;
|
|
58
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Controlled anchor date, read in the device's local time zone; change it
|
|
60
|
+
* (e.g. from your own header) to navigate. Construct it as a local date
|
|
61
|
+
* (`new Date(2026, 7, 24)`), not a UTC instant:
|
|
62
|
+
* `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
|
|
63
|
+
* and anchors the previous week.
|
|
64
|
+
*/
|
|
59
65
|
date: Date;
|
|
60
66
|
/**
|
|
61
67
|
* Fires with the next/previous period's date when the user pages the focused
|
package/src/TimeGrid.tsx
CHANGED
|
@@ -790,7 +790,11 @@ export function TimeGrid<T = unknown>({
|
|
|
790
790
|
const startShift =
|
|
791
791
|
d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
|
|
792
792
|
const endShift =
|
|
793
|
-
d.kind === "
|
|
793
|
+
d.kind === "move"
|
|
794
|
+
? startShift
|
|
795
|
+
: d.kind === "resize-start"
|
|
796
|
+
? 0
|
|
797
|
+
: segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
794
798
|
const start = new Date(held.event.start.getTime() + startShift);
|
|
795
799
|
const end = new Date(held.event.end.getTime() + endShift);
|
|
796
800
|
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
@@ -949,6 +953,39 @@ export function TimeGrid<T = unknown>({
|
|
|
949
953
|
[days, events],
|
|
950
954
|
);
|
|
951
955
|
|
|
956
|
+
// Keep the original boxes mounted for pointer capture, but replace every
|
|
957
|
+
// segment of a moving multi-day event with the same shifted range.
|
|
958
|
+
const moveOrigin = dragOrigin.current;
|
|
959
|
+
const heldEvent = draggedRef.current?.event;
|
|
960
|
+
const movingEvent =
|
|
961
|
+
heldEvent &&
|
|
962
|
+
(events.includes(heldEvent)
|
|
963
|
+
? heldEvent
|
|
964
|
+
: (events.find(
|
|
965
|
+
(event) =>
|
|
966
|
+
event.start.getTime() === heldEvent.start.getTime() &&
|
|
967
|
+
event.end.getTime() === heldEvent.end.getTime() &&
|
|
968
|
+
event.title === heldEvent.title,
|
|
969
|
+
) ?? heldEvent));
|
|
970
|
+
const multiDayMove =
|
|
971
|
+
!paged &&
|
|
972
|
+
drag?.kind === "move" &&
|
|
973
|
+
(drag.continuesBefore || drag.continuesAfter) &&
|
|
974
|
+
moveOrigin &&
|
|
975
|
+
movingEvent
|
|
976
|
+
? (() => {
|
|
977
|
+
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
978
|
+
const segmentStart = addMinutes(startOfDay(target), Math.round(drag.startHours * 60));
|
|
979
|
+
const shift = segmentStart.getTime() - moveOrigin.segmentStart.getTime();
|
|
980
|
+
return {
|
|
981
|
+
...movingEvent,
|
|
982
|
+
start: new Date(movingEvent.start.getTime() + shift),
|
|
983
|
+
end: new Date(movingEvent.end.getTime() + shift),
|
|
984
|
+
allDay: false,
|
|
985
|
+
};
|
|
986
|
+
})()
|
|
987
|
+
: null;
|
|
988
|
+
|
|
952
989
|
// The tail of an in-progress move that runs past midnight, shown on `dayIndex`
|
|
953
990
|
// so the drop is visible on both days at once. `drag` and `draggedRef` are set
|
|
954
991
|
// together in `beginDrag` and cleared together in `finishDrag`, so the guard on
|
|
@@ -1341,7 +1378,10 @@ export function TimeGrid<T = unknown>({
|
|
|
1341
1378
|
// The tail of a move that runs past midnight, previewed at the top of
|
|
1342
1379
|
// this column. The dragged event is looked up from its `drag.key`
|
|
1343
1380
|
// ("<originColumn>:<index>"), so no extra state has to track it.
|
|
1344
|
-
const spill = spillPreviewFor(dayIndex);
|
|
1381
|
+
const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
|
|
1382
|
+
const moveSegment = multiDayMove
|
|
1383
|
+
? layoutDayEvents<T>([multiDayMove], day)[0]
|
|
1384
|
+
: undefined;
|
|
1345
1385
|
return (
|
|
1346
1386
|
<div
|
|
1347
1387
|
key={day.toISOString()}
|
|
@@ -1423,7 +1463,11 @@ export function TimeGrid<T = unknown>({
|
|
|
1423
1463
|
// Not while paged: after a page change the origin box is gone and
|
|
1424
1464
|
// the ghost stands in, so a same-slot event on the new page (e.g. a
|
|
1425
1465
|
// recurring one) must not also render lifted.
|
|
1426
|
-
const active =
|
|
1466
|
+
const active =
|
|
1467
|
+
!paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent)
|
|
1468
|
+
? drag
|
|
1469
|
+
: null;
|
|
1470
|
+
const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
|
|
1427
1471
|
const startHours = active ? active.startHours : pe.startHours;
|
|
1428
1472
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
1429
1473
|
// Drop events that fall entirely outside the visible window; those
|
|
@@ -1498,7 +1542,7 @@ export function TimeGrid<T = unknown>({
|
|
|
1498
1542
|
: undefined
|
|
1499
1543
|
}
|
|
1500
1544
|
onClick={canMove ? undefined : onPress}
|
|
1501
|
-
{...dataState({ "data-dragging": !!active })}
|
|
1545
|
+
{...dataState({ "data-dragging": !!active && !hiddenForMove })}
|
|
1502
1546
|
{...slot("event", {
|
|
1503
1547
|
base: {
|
|
1504
1548
|
position: "absolute",
|
|
@@ -1514,6 +1558,7 @@ export function TimeGrid<T = unknown>({
|
|
|
1514
1558
|
touchAction: canMove ? "none" : "auto",
|
|
1515
1559
|
zIndex: active ? 3 : 1,
|
|
1516
1560
|
opacity: active ? 0.85 : 1,
|
|
1561
|
+
visibility: hiddenForMove ? "hidden" : undefined,
|
|
1517
1562
|
// Snap the dragged box over the target day column so the
|
|
1518
1563
|
// drop location is visible before release.
|
|
1519
1564
|
...(active && active.dayOffsetPx !== 0
|
|
@@ -1569,6 +1614,42 @@ export function TimeGrid<T = unknown>({
|
|
|
1569
1614
|
</div>
|
|
1570
1615
|
);
|
|
1571
1616
|
})}
|
|
1617
|
+
{moveSegment ? (
|
|
1618
|
+
<div
|
|
1619
|
+
aria-hidden
|
|
1620
|
+
{...dataState({ "data-dragging": true })}
|
|
1621
|
+
{...slot("event", {
|
|
1622
|
+
base: {
|
|
1623
|
+
position: "absolute",
|
|
1624
|
+
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
1625
|
+
left: 1,
|
|
1626
|
+
right: 1,
|
|
1627
|
+
height: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
1628
|
+
pointerEvents: "none",
|
|
1629
|
+
zIndex: 3,
|
|
1630
|
+
opacity: 0.85,
|
|
1631
|
+
},
|
|
1632
|
+
})}
|
|
1633
|
+
>
|
|
1634
|
+
{(() => {
|
|
1635
|
+
const args: DomRenderEventArgs<T> = {
|
|
1636
|
+
event: moveSegment.event,
|
|
1637
|
+
mode,
|
|
1638
|
+
isAllDay: false,
|
|
1639
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
|
|
1640
|
+
continuesBefore: moveSegment.continuesBefore,
|
|
1641
|
+
continuesAfter: moveSegment.continuesAfter,
|
|
1642
|
+
ampm,
|
|
1643
|
+
onPress: () => {},
|
|
1644
|
+
};
|
|
1645
|
+
return Renderer ? (
|
|
1646
|
+
<Renderer {...args} />
|
|
1647
|
+
) : (
|
|
1648
|
+
<DefaultDomEvent {...args} theme={theme} boxProps={slot("eventBox")} />
|
|
1649
|
+
);
|
|
1650
|
+
})()}
|
|
1651
|
+
</div>
|
|
1652
|
+
) : null}
|
|
1572
1653
|
{spill ? (
|
|
1573
1654
|
<div
|
|
1574
1655
|
aria-hidden
|