@super-calendar/dom 2.13.0 → 2.14.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 +26 -0
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +235 -64
- package/dist/index.mjs +237 -66
- package/package.json +2 -2
- package/src/Calendar.tsx +16 -0
- package/src/MonthList.tsx +11 -4
- package/src/MonthView.tsx +26 -16
- package/src/ResourceTimeline.tsx +48 -50
- package/src/TimeGrid.tsx +263 -35
- package/src/touch.ts +61 -0
package/dist/index.js
CHANGED
|
@@ -638,7 +638,7 @@ function badgeDefault(day, theme, hovered) {
|
|
|
638
638
|
}
|
|
639
639
|
};
|
|
640
640
|
}
|
|
641
|
-
function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget) {
|
|
641
|
+
function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget, chipGap) {
|
|
642
642
|
return {
|
|
643
643
|
base: {
|
|
644
644
|
position: "relative",
|
|
@@ -648,7 +648,7 @@ function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget) {
|
|
|
648
648
|
cursor: day.isDisabled ? "default" : "pointer",
|
|
649
649
|
display: "flex",
|
|
650
650
|
flexDirection: "column",
|
|
651
|
-
gap:
|
|
651
|
+
gap: chipGap,
|
|
652
652
|
padding: CELL_PAD,
|
|
653
653
|
boxSizing: "border-box",
|
|
654
654
|
textAlign: "left",
|
|
@@ -694,12 +694,12 @@ const chipButtonDefault = { base: {
|
|
|
694
694
|
textAlign: "left",
|
|
695
695
|
fontFamily: "inherit"
|
|
696
696
|
} };
|
|
697
|
-
function chipDefault(theme) {
|
|
697
|
+
function chipDefault(theme, chipHeight) {
|
|
698
698
|
return {
|
|
699
699
|
base: {
|
|
700
700
|
display: "block",
|
|
701
|
-
height:
|
|
702
|
-
lineHeight: `${
|
|
701
|
+
height: chipHeight,
|
|
702
|
+
lineHeight: `${chipHeight}px`,
|
|
703
703
|
whiteSpace: "nowrap",
|
|
704
704
|
overflow: "hidden",
|
|
705
705
|
textOverflow: "ellipsis"
|
|
@@ -714,7 +714,7 @@ function chipDefault(theme) {
|
|
|
714
714
|
}
|
|
715
715
|
};
|
|
716
716
|
}
|
|
717
|
-
function moreButtonDefault(theme) {
|
|
717
|
+
function moreButtonDefault(theme, chipHeight) {
|
|
718
718
|
return {
|
|
719
719
|
base: {
|
|
720
720
|
position: "relative",
|
|
@@ -723,8 +723,8 @@ function moreButtonDefault(theme) {
|
|
|
723
723
|
background: "transparent",
|
|
724
724
|
cursor: "pointer",
|
|
725
725
|
textAlign: "left",
|
|
726
|
-
height:
|
|
727
|
-
lineHeight: `${
|
|
726
|
+
height: chipHeight,
|
|
727
|
+
lineHeight: `${chipHeight}px`,
|
|
728
728
|
fontFamily: "inherit"
|
|
729
729
|
},
|
|
730
730
|
themed: {
|
|
@@ -756,7 +756,7 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
756
756
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
757
757
|
* ```
|
|
758
758
|
*/
|
|
759
|
-
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", labels: labelsProp, onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
759
|
+
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, chipHeight = CHIP_HEIGHT, chipGap = CHIP_GAP, moreLabel = "{moreCount} More", labels: labelsProp, onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
760
760
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
761
761
|
const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
|
|
762
762
|
const slot = createSlots({
|
|
@@ -801,7 +801,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
801
801
|
document.removeEventListener("keydown", onKey);
|
|
802
802
|
};
|
|
803
803
|
}, [moreOpenFor]);
|
|
804
|
-
const eventRowHeight = 32 + maxVisibleEventCount *
|
|
804
|
+
const eventRowHeight = 32 + maxVisibleEventCount * (chipHeight + chipGap);
|
|
805
805
|
const { weeks, weekdays } = (0, react.useMemo)(() => (0, _super_calendar_core.buildMonthGrid)(date, {
|
|
806
806
|
weekStartsOn,
|
|
807
807
|
hiddenDays,
|
|
@@ -1013,7 +1013,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1013
1013
|
};
|
|
1014
1014
|
}).filter((b) => b.startCol <= b.endCol);
|
|
1015
1015
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1016
|
-
const barChip = slot("chip", chipDefault(theme));
|
|
1016
|
+
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
1017
1017
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1018
1018
|
role: "row",
|
|
1019
1019
|
...slot("week", { base: {
|
|
@@ -1052,7 +1052,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1052
1052
|
const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString()) ?? [];
|
|
1053
1053
|
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event);
|
|
1054
1054
|
const dayLabel = (0, date_fns.format)(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
1055
|
-
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget));
|
|
1055
|
+
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget, chipGap));
|
|
1056
1056
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1057
1057
|
role: "gridcell",
|
|
1058
1058
|
"data-day": day.id,
|
|
@@ -1130,8 +1130,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1130
1130
|
position: "absolute",
|
|
1131
1131
|
left: 2,
|
|
1132
1132
|
width: `calc(${span * 100}% - 4px)`,
|
|
1133
|
-
top:
|
|
1134
|
-
height:
|
|
1133
|
+
top: 28 + chipGap + b.seg.lane * (chipHeight + chipGap),
|
|
1134
|
+
height: chipHeight,
|
|
1135
1135
|
pointerEvents: isDragging ? "none" : "auto",
|
|
1136
1136
|
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1137
1137
|
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
@@ -1162,12 +1162,12 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1162
1162
|
...slot("events", { base: {
|
|
1163
1163
|
display: "flex",
|
|
1164
1164
|
flexDirection: "column",
|
|
1165
|
-
gap:
|
|
1165
|
+
gap: chipGap
|
|
1166
1166
|
} }),
|
|
1167
1167
|
children: [
|
|
1168
1168
|
Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1169
1169
|
"aria-hidden": true,
|
|
1170
|
-
style: { height:
|
|
1170
|
+
style: { height: chipHeight }
|
|
1171
1171
|
}, `lane-${i}`)),
|
|
1172
1172
|
hiddenEvents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1173
1173
|
type: "button",
|
|
@@ -1180,7 +1180,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1180
1180
|
setMoreOpenFor((open) => open === day.id ? null : day.id);
|
|
1181
1181
|
}
|
|
1182
1182
|
},
|
|
1183
|
-
...slot("more", moreButtonDefault(theme)),
|
|
1183
|
+
...slot("more", moreButtonDefault(theme, chipHeight)),
|
|
1184
1184
|
"aria-label": `${labels.moreEvents(hiddenEvents.length)}, ${dayLabel}`,
|
|
1185
1185
|
"aria-expanded": onPressMore ? void 0 : moreOpenFor === day.id,
|
|
1186
1186
|
children: moreLabel.replace("{moreCount}", String(hiddenEvents.length))
|
|
@@ -1252,7 +1252,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1252
1252
|
event,
|
|
1253
1253
|
onPress: () => onPressEvent?.(event)
|
|
1254
1254
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1255
|
-
...slot("chip", chipDefault(theme)),
|
|
1255
|
+
...slot("chip", chipDefault(theme, chipHeight)),
|
|
1256
1256
|
children: event.title
|
|
1257
1257
|
})
|
|
1258
1258
|
}, i))]
|
|
@@ -1296,6 +1296,45 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1296
1296
|
});
|
|
1297
1297
|
}
|
|
1298
1298
|
//#endregion
|
|
1299
|
+
//#region src/touch.ts
|
|
1300
|
+
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
1301
|
+
const detach = () => {
|
|
1302
|
+
clearTimeout(timer);
|
|
1303
|
+
document.removeEventListener("pointermove", move);
|
|
1304
|
+
document.removeEventListener("pointerup", up);
|
|
1305
|
+
document.removeEventListener("pointercancel", cancelPointer);
|
|
1306
|
+
document.removeEventListener("pointerdown", anotherPointer);
|
|
1307
|
+
};
|
|
1308
|
+
const cancel = () => {
|
|
1309
|
+
detach();
|
|
1310
|
+
onCancel();
|
|
1311
|
+
};
|
|
1312
|
+
const move = (event) => {
|
|
1313
|
+
if (event.pointerId === grab.pointerId && Math.hypot(event.clientX - grab.clientX, event.clientY - grab.clientY) > threshold) cancel();
|
|
1314
|
+
};
|
|
1315
|
+
const up = (event) => {
|
|
1316
|
+
if (event.pointerId === grab.pointerId) {
|
|
1317
|
+
detach();
|
|
1318
|
+
onTap();
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
const cancelPointer = (event) => {
|
|
1322
|
+
if (event.pointerId === grab.pointerId) cancel();
|
|
1323
|
+
};
|
|
1324
|
+
const anotherPointer = (event) => {
|
|
1325
|
+
if (event.pointerId !== grab.pointerId) cancel();
|
|
1326
|
+
};
|
|
1327
|
+
const timer = setTimeout(() => {
|
|
1328
|
+
detach();
|
|
1329
|
+
onHold();
|
|
1330
|
+
}, delay);
|
|
1331
|
+
document.addEventListener("pointermove", move);
|
|
1332
|
+
document.addEventListener("pointerup", up);
|
|
1333
|
+
document.addEventListener("pointercancel", cancelPointer);
|
|
1334
|
+
document.addEventListener("pointerdown", anotherPointer);
|
|
1335
|
+
return cancel;
|
|
1336
|
+
}
|
|
1337
|
+
//#endregion
|
|
1299
1338
|
//#region src/TimeGrid.tsx
|
|
1300
1339
|
const GUTTER_WIDTH$1 = 56;
|
|
1301
1340
|
const HOURS_PER_DAY = 24;
|
|
@@ -1305,6 +1344,7 @@ const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
|
1305
1344
|
const EDGE_ZONE = 32;
|
|
1306
1345
|
const EDGE_DWELL_MS = 600;
|
|
1307
1346
|
const EDGE_REPEAT_MS = 600;
|
|
1347
|
+
const CELL_TOUCH_SLOP_PX = 8;
|
|
1308
1348
|
const VISUALLY_HIDDEN = {
|
|
1309
1349
|
position: "absolute",
|
|
1310
1350
|
width: 1,
|
|
@@ -1320,6 +1360,10 @@ const VISUALLY_HIDDEN = {
|
|
|
1320
1360
|
const DOM_TITLE_LINE_HEIGHT = 16;
|
|
1321
1361
|
const DOM_TIME_LINE_HEIGHT = 30;
|
|
1322
1362
|
const DOM_BOX_PADDING_V = 2;
|
|
1363
|
+
function movedSegmentStart(origin, base, startHours) {
|
|
1364
|
+
const dayMinutes = (0, date_fns.differenceInCalendarDays)(base, origin.base) * HOURS_PER_DAY * 60;
|
|
1365
|
+
return (0, _super_calendar_core.shiftMinutes)(origin.segmentStart, dayMinutes + Math.round((startHours - origin.startHours) * 60));
|
|
1366
|
+
}
|
|
1323
1367
|
function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme, boxProps }) {
|
|
1324
1368
|
const timeLabel = (0, _super_calendar_core.eventTimeLabel)({
|
|
1325
1369
|
mode,
|
|
@@ -1399,7 +1443,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
1399
1443
|
* ```
|
|
1400
1444
|
*/
|
|
1401
1445
|
const TimeGrid = (0, react.forwardRef)(TimeGridInner);
|
|
1402
|
-
function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
|
|
1446
|
+
function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, touchDragDelay = 300, touchDragThreshold = 8, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
|
|
1403
1447
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1404
1448
|
const labels = (0, react.useMemo)(() => (0, _super_calendar_core.resolveCalendarLabels)(labelsProp), [labelsProp]);
|
|
1405
1449
|
const slot = createSlots({
|
|
@@ -1433,6 +1477,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1433
1477
|
};
|
|
1434
1478
|
const [createBox, setCreateBox] = (0, react.useState)(null);
|
|
1435
1479
|
const createOrigin = (0, react.useRef)(null);
|
|
1480
|
+
const cellTouchRef = (0, react.useRef)(null);
|
|
1436
1481
|
const cellEnabled = !!onPressCell || !!onCreateEvent;
|
|
1437
1482
|
const days = (0, react.useMemo)(() => (0, _super_calendar_core.getViewDays)(mode, date, weekStartsOn, numberOfDays, false, void 0, hiddenDays), [
|
|
1438
1483
|
mode,
|
|
@@ -1453,6 +1498,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1453
1498
|
const [paged, setPaged] = (0, react.useState)(false);
|
|
1454
1499
|
const draggedRef = (0, react.useRef)(null);
|
|
1455
1500
|
const ghostRef = (0, react.useRef)(null);
|
|
1501
|
+
const touchDragRef = (0, react.useRef)(false);
|
|
1502
|
+
const activeGrabRef = (0, react.useRef)(null);
|
|
1503
|
+
const cancelHoldRef = (0, react.useRef)(null);
|
|
1504
|
+
const tappedRef = (0, react.useRef)(null);
|
|
1456
1505
|
const docHandlersRef = (0, react.useRef)(null);
|
|
1457
1506
|
const daysRef = (0, react.useRef)(days);
|
|
1458
1507
|
daysRef.current = days;
|
|
@@ -1506,6 +1555,22 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1506
1555
|
minHourHeight,
|
|
1507
1556
|
maxHourHeight
|
|
1508
1557
|
]);
|
|
1558
|
+
(0, react.useEffect)(() => {
|
|
1559
|
+
const el = scrollRef.current;
|
|
1560
|
+
if (!el) return;
|
|
1561
|
+
const onTouchMove = (e) => {
|
|
1562
|
+
if (touchDragRef.current && e.cancelable) e.preventDefault();
|
|
1563
|
+
};
|
|
1564
|
+
const onContextMenu = (e) => {
|
|
1565
|
+
if (touchDragRef.current || cancelHoldRef.current) e.preventDefault();
|
|
1566
|
+
};
|
|
1567
|
+
el.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
1568
|
+
el.addEventListener("contextmenu", onContextMenu);
|
|
1569
|
+
return () => {
|
|
1570
|
+
el.removeEventListener("touchmove", onTouchMove);
|
|
1571
|
+
el.removeEventListener("contextmenu", onContextMenu);
|
|
1572
|
+
};
|
|
1573
|
+
}, []);
|
|
1509
1574
|
const pinch = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
1510
1575
|
const pinchBase = (0, react.useRef)(null);
|
|
1511
1576
|
const onBodyPointerDown = (e) => {
|
|
@@ -1569,6 +1634,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1569
1634
|
edgeSide.current = 0;
|
|
1570
1635
|
pagedRef.current = false;
|
|
1571
1636
|
setPaged(false);
|
|
1637
|
+
touchDragRef.current = false;
|
|
1638
|
+
activeGrabRef.current = null;
|
|
1572
1639
|
draggedRef.current = null;
|
|
1573
1640
|
dragOrigin.current = null;
|
|
1574
1641
|
applyDrag(null);
|
|
@@ -1576,6 +1643,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1576
1643
|
const moveDrag = (e) => {
|
|
1577
1644
|
const d = dragRef.current;
|
|
1578
1645
|
if (!d || !dragOrigin.current) return;
|
|
1646
|
+
if (touchDragRef.current && !d.moved && Math.hypot(e.clientX - dragOrigin.current.pointerX, e.clientY - dragOrigin.current.pointerY) <= touchDragThreshold) return;
|
|
1579
1647
|
ptr.current = {
|
|
1580
1648
|
x: e.clientX,
|
|
1581
1649
|
y: e.clientY
|
|
@@ -1584,17 +1652,23 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1584
1652
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
1585
1653
|
if (d.kind === "move") {
|
|
1586
1654
|
const raw = snap(dragOrigin.current.startHours + dHours);
|
|
1587
|
-
const
|
|
1655
|
+
const requestedHours = d.continuesBefore ? raw : (0, _super_calendar_core.clampMoveStartMinutes)(raw * 60, windowStart, windowEnd, snapMinutes) / 60;
|
|
1588
1656
|
const o = dragOrigin.current;
|
|
1589
1657
|
const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
|
|
1590
1658
|
const targetDay = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1);
|
|
1591
1659
|
const dayDelta = targetDay - o.dayIndex;
|
|
1592
|
-
const
|
|
1660
|
+
const dayMinutes = (0, date_fns.differenceInCalendarDays)((0, date_fns.startOfDay)(daysRef.current[targetDay] ?? o.base), o.base) * HOURS_PER_DAY * 60;
|
|
1661
|
+
const moved = (0, _super_calendar_core.movedClockSpan)(o.segmentStart, o.segmentEnd, dayMinutes + Math.round((requestedHours - o.startHours) * 60));
|
|
1662
|
+
const startHours = o.startHours + moved.startHours - dayMinutes / 60;
|
|
1663
|
+
const durationHours = moved.hours;
|
|
1664
|
+
const spillHours = Math.min(Math.max(startHours + durationHours - HOURS_PER_DAY, 0), windowHours);
|
|
1593
1665
|
const nextDay = daysRef.current[targetDay + 1];
|
|
1594
1666
|
const spillDayIndex = spillHours > 0 && nextDay && (0, date_fns.differenceInCalendarDays)(nextDay, daysRef.current[targetDay]) === 1 && !d.continuesAfter ? targetDay + 1 : -1;
|
|
1595
1667
|
applyDrag({
|
|
1596
1668
|
...d,
|
|
1597
1669
|
startHours,
|
|
1670
|
+
requestedStartHours: requestedHours,
|
|
1671
|
+
durationHours,
|
|
1598
1672
|
dayDelta,
|
|
1599
1673
|
dayOffsetPx: dayDelta * o.dayWidth,
|
|
1600
1674
|
spillHours,
|
|
@@ -1604,7 +1678,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1604
1678
|
const g = ghostRef.current;
|
|
1605
1679
|
const held = draggedRef.current;
|
|
1606
1680
|
if (g && held) g.style.transform = `translate(${e.clientX - held.grabX}px, ${e.clientY - held.grabY}px)`;
|
|
1607
|
-
if (edgeAdvanceEnabled) {
|
|
1681
|
+
if (edgeAdvanceEnabled && o.pointerType === "mouse") {
|
|
1608
1682
|
const rect = columnsRef.current?.getBoundingClientRect();
|
|
1609
1683
|
if (rect && rect.right > rect.left) {
|
|
1610
1684
|
const left = rect.left + gutterWidth;
|
|
@@ -1639,12 +1713,15 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1639
1713
|
const d = dragRef.current;
|
|
1640
1714
|
if (!d) return;
|
|
1641
1715
|
try {
|
|
1642
|
-
|
|
1716
|
+
activeGrabRef.current?.box.releasePointerCapture?.(e.pointerId);
|
|
1643
1717
|
} catch {}
|
|
1644
1718
|
const held = draggedRef.current;
|
|
1645
1719
|
if (!d.moved) {
|
|
1720
|
+
const wasTouch = touchDragRef.current;
|
|
1721
|
+
const tapBox = activeGrabRef.current?.box ?? null;
|
|
1646
1722
|
finishDrag();
|
|
1647
|
-
|
|
1723
|
+
if (wasTouch) tappedRef.current = tapBox;
|
|
1724
|
+
else held?.onPress();
|
|
1648
1725
|
return;
|
|
1649
1726
|
}
|
|
1650
1727
|
const origin = dragOrigin.current;
|
|
@@ -1656,11 +1733,13 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1656
1733
|
base = day ? (0, date_fns.startOfDay)(day) : null;
|
|
1657
1734
|
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
|
|
1658
1735
|
} else base = (0, date_fns.startOfDay)(daysRef.current[originIndex] ?? daysRef.current[0]);
|
|
1659
|
-
if (
|
|
1660
|
-
const
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1663
|
-
|
|
1736
|
+
if (held && origin && d.kind === "resize") {
|
|
1737
|
+
const endDelta = Math.round((d.startHours + d.durationHours - origin.startHours - origin.durationHours) * 60);
|
|
1738
|
+
const next = (0, _super_calendar_core.resolveDraggedBounds)(held.event.start, held.event.end, 0, endDelta, snapMinutes);
|
|
1739
|
+
if (next) onDragEventRef.current?.(held.event, next.start, next.end);
|
|
1740
|
+
} else if (base && held && origin) {
|
|
1741
|
+
const startShift = movedSegmentStart(origin, base, d.kind === "move" ? d.requestedStartHours : d.startHours).getTime() - origin.segmentStart.getTime();
|
|
1742
|
+
const endShift = d.kind === "move" ? startShift : 0;
|
|
1664
1743
|
const start = new Date(held.event.start.getTime() + startShift);
|
|
1665
1744
|
const end = new Date(held.event.end.getTime() + endShift);
|
|
1666
1745
|
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
@@ -1671,26 +1750,30 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1671
1750
|
finishDrag();
|
|
1672
1751
|
};
|
|
1673
1752
|
const beginDrag = (e, pe, key, kind, dayIndex, onPress) => {
|
|
1674
|
-
if (!onDragEvent) return;
|
|
1675
1753
|
const { event, startHours, durationHours, continuesBefore, continuesAfter } = pe;
|
|
1676
|
-
e.stopPropagation();
|
|
1677
1754
|
try {
|
|
1678
|
-
e.
|
|
1755
|
+
e.box.setPointerCapture?.(e.pointerId);
|
|
1679
1756
|
} catch {}
|
|
1680
|
-
|
|
1757
|
+
touchDragRef.current = e.pointerType !== "mouse";
|
|
1758
|
+
activeGrabRef.current = e;
|
|
1759
|
+
const boxEl = e.box;
|
|
1681
1760
|
const column = kind === "move" ? boxEl.parentElement : null;
|
|
1682
1761
|
const dayWidth = column ? column.getBoundingClientRect().width : 0;
|
|
1683
1762
|
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
1684
1763
|
const originBase = (0, date_fns.startOfDay)(days[dayIndex] ?? days[0]);
|
|
1764
|
+
const originNextDay = (0, date_fns.addDays)(originBase, 1);
|
|
1765
|
+
const segmentStart = event.start > originBase ? event.start : originBase;
|
|
1685
1766
|
dragOrigin.current = {
|
|
1686
1767
|
pointerX: e.clientX,
|
|
1687
1768
|
pointerY: e.clientY,
|
|
1769
|
+
pointerType: e.pointerType,
|
|
1688
1770
|
startHours,
|
|
1689
1771
|
durationHours,
|
|
1690
1772
|
dayIndex,
|
|
1691
1773
|
dayWidth,
|
|
1692
|
-
segmentStart
|
|
1693
|
-
segmentEnd:
|
|
1774
|
+
segmentStart,
|
|
1775
|
+
segmentEnd: event.end < originNextDay ? event.end : originNextDay,
|
|
1776
|
+
base: originBase
|
|
1694
1777
|
};
|
|
1695
1778
|
draggedRef.current = {
|
|
1696
1779
|
event,
|
|
@@ -1712,6 +1795,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1712
1795
|
key,
|
|
1713
1796
|
kind,
|
|
1714
1797
|
startHours,
|
|
1798
|
+
requestedStartHours: startHours,
|
|
1715
1799
|
durationHours,
|
|
1716
1800
|
continuesBefore,
|
|
1717
1801
|
continuesAfter,
|
|
@@ -1724,21 +1808,68 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1724
1808
|
onDragStart?.(event);
|
|
1725
1809
|
detachDocListeners();
|
|
1726
1810
|
const handlers = {
|
|
1727
|
-
move:
|
|
1728
|
-
|
|
1729
|
-
|
|
1811
|
+
move: (event) => {
|
|
1812
|
+
if (event.pointerId === e.pointerId) moveDrag(event);
|
|
1813
|
+
},
|
|
1814
|
+
up: (event) => {
|
|
1815
|
+
if (event.pointerId === e.pointerId) endDrag(event);
|
|
1816
|
+
},
|
|
1817
|
+
cancel: (event) => {
|
|
1818
|
+
if (event.pointerId === e.pointerId) cancelDrag();
|
|
1819
|
+
}
|
|
1730
1820
|
};
|
|
1731
1821
|
docHandlersRef.current = handlers;
|
|
1732
1822
|
document.addEventListener("pointermove", handlers.move);
|
|
1733
1823
|
document.addEventListener("pointerup", handlers.up);
|
|
1734
1824
|
document.addEventListener("pointercancel", handlers.cancel);
|
|
1735
1825
|
};
|
|
1826
|
+
const pressEvent = (e, pe, key, kind, dayIndex, onPress) => {
|
|
1827
|
+
if (!onDragEvent || e.button > 0) return;
|
|
1828
|
+
e.stopPropagation();
|
|
1829
|
+
const hadPendingHold = cancelHoldRef.current !== null;
|
|
1830
|
+
cancelHoldRef.current?.();
|
|
1831
|
+
tappedRef.current = null;
|
|
1832
|
+
if (hadPendingHold || activeGrabRef.current || e.pointerType !== "mouse" && !e.isPrimary) return;
|
|
1833
|
+
const grab = {
|
|
1834
|
+
box: e.currentTarget,
|
|
1835
|
+
pointerId: e.pointerId,
|
|
1836
|
+
pointerType: e.pointerType,
|
|
1837
|
+
clientX: e.clientX,
|
|
1838
|
+
clientY: e.clientY
|
|
1839
|
+
};
|
|
1840
|
+
if (e.pointerType === "mouse") {
|
|
1841
|
+
beginDrag(grab, pe, key, kind, dayIndex, onPress);
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
cancelHoldRef.current = waitForHold(grab, touchDragDelay, touchDragThreshold, () => {
|
|
1845
|
+
cancelHoldRef.current = null;
|
|
1846
|
+
beginDrag(grab, pe, key, kind, dayIndex, onPress);
|
|
1847
|
+
}, () => {
|
|
1848
|
+
cancelHoldRef.current = null;
|
|
1849
|
+
tappedRef.current = grab.box;
|
|
1850
|
+
}, () => {
|
|
1851
|
+
cancelHoldRef.current = null;
|
|
1852
|
+
});
|
|
1853
|
+
};
|
|
1736
1854
|
(0, react.useEffect)(() => () => {
|
|
1855
|
+
cancelHoldRef.current?.();
|
|
1737
1856
|
detachDocListeners();
|
|
1738
1857
|
clearEdgeTimer();
|
|
1739
1858
|
}, []);
|
|
1859
|
+
(0, react.useEffect)(() => {
|
|
1860
|
+
cancelHoldRef.current?.();
|
|
1861
|
+
}, [
|
|
1862
|
+
date,
|
|
1863
|
+
events,
|
|
1864
|
+
onDragEvent
|
|
1865
|
+
]);
|
|
1740
1866
|
const pxFromTop = (el, clientY) => clientY - el.getBoundingClientRect().top;
|
|
1741
1867
|
const beginCreate = (e, dayIndex) => {
|
|
1868
|
+
cellTouchRef.current = e.pointerType === "touch" && e.target === e.currentTarget ? {
|
|
1869
|
+
pointerId: e.pointerId,
|
|
1870
|
+
x: e.clientX,
|
|
1871
|
+
y: e.clientY
|
|
1872
|
+
} : null;
|
|
1742
1873
|
if (!cellEnabled || e.pointerType === "touch") return;
|
|
1743
1874
|
if (e.target !== e.currentTarget || e.button > 0) return;
|
|
1744
1875
|
const el = e.currentTarget;
|
|
@@ -1758,6 +1889,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1758
1889
|
});
|
|
1759
1890
|
};
|
|
1760
1891
|
const moveCreate = (e) => {
|
|
1892
|
+
const touch = cellTouchRef.current;
|
|
1893
|
+
if (touch && e.pointerId === touch.pointerId && Math.hypot(e.clientX - touch.x, e.clientY - touch.y) > CELL_TOUCH_SLOP_PX) cellTouchRef.current = null;
|
|
1761
1894
|
const o = createOrigin.current;
|
|
1762
1895
|
if (!o) return;
|
|
1763
1896
|
const cur = pxFromTop(o.el, e.clientY);
|
|
@@ -1787,7 +1920,17 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1787
1920
|
createOrigin.current = null;
|
|
1788
1921
|
setCreateBox(null);
|
|
1789
1922
|
};
|
|
1923
|
+
const tapCell = (e, dayIndex) => {
|
|
1924
|
+
const touch = cellTouchRef.current;
|
|
1925
|
+
cellTouchRef.current = null;
|
|
1926
|
+
const day = days[dayIndex];
|
|
1927
|
+
if (!touch || !onPressCell || !day || e.target !== e.currentTarget) return;
|
|
1928
|
+
const px = pxFromTop(e.currentTarget, e.clientY);
|
|
1929
|
+
const at = (0, _super_calendar_core.cellRangeFromDrag)(day, px, px, hourHeightRef.current, windowStart, snapMinutes);
|
|
1930
|
+
if (at) onPressCell(at.start);
|
|
1931
|
+
};
|
|
1790
1932
|
const cancelCreate = () => {
|
|
1933
|
+
cellTouchRef.current = null;
|
|
1791
1934
|
createOrigin.current = null;
|
|
1792
1935
|
setCreateBox(null);
|
|
1793
1936
|
};
|
|
@@ -1797,7 +1940,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1797
1940
|
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);
|
|
1798
1941
|
const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
|
|
1799
1942
|
const target = days[moveOrigin.dayIndex + drag.dayDelta];
|
|
1800
|
-
const shift = (
|
|
1943
|
+
const shift = movedSegmentStart(moveOrigin, (0, date_fns.startOfDay)(target), drag.requestedStartHours).getTime() - moveOrigin.segmentStart.getTime();
|
|
1801
1944
|
return {
|
|
1802
1945
|
...movingEvent,
|
|
1803
1946
|
start: new Date(movingEvent.start.getTime() + shift),
|
|
@@ -2147,6 +2290,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2147
2290
|
onPointerMove: cellEnabled ? moveCreate : void 0,
|
|
2148
2291
|
onPointerUp: cellEnabled ? endCreate : void 0,
|
|
2149
2292
|
onPointerCancel: cellEnabled ? cancelCreate : void 0,
|
|
2293
|
+
onClick: cellEnabled ? (e) => tapCell(e, dayIndex) : void 0,
|
|
2150
2294
|
...dataState({
|
|
2151
2295
|
"data-today": (0, _super_calendar_core.getIsToday)(day),
|
|
2152
2296
|
"data-weekend": (0, _super_calendar_core.isWeekend)(day)
|
|
@@ -2282,8 +2426,13 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2282
2426
|
}
|
|
2283
2427
|
if (keyboardEventNavigation) onEventKeyDown(key, e);
|
|
2284
2428
|
},
|
|
2285
|
-
onPointerDown: canMove ? (e) =>
|
|
2286
|
-
onClick: canMove ?
|
|
2429
|
+
onPointerDown: canMove ? (e) => pressEvent(e, pe, key, "move", dayIndex, onPress) : void 0,
|
|
2430
|
+
onClick: canMove ? (e) => {
|
|
2431
|
+
if (e.detail === 0 || tappedRef.current && e.currentTarget.contains(tappedRef.current)) {
|
|
2432
|
+
tappedRef.current = null;
|
|
2433
|
+
onPress();
|
|
2434
|
+
}
|
|
2435
|
+
} : onPress,
|
|
2287
2436
|
...dataState({ "data-dragging": !!active && !hiddenForMove }),
|
|
2288
2437
|
...slot("event", { base: {
|
|
2289
2438
|
position: "absolute",
|
|
@@ -2292,7 +2441,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2292
2441
|
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
2293
2442
|
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
2294
2443
|
cursor: canMove ? "grab" : "pointer",
|
|
2295
|
-
touchAction: canMove ? "
|
|
2444
|
+
touchAction: canMove ? "pan-y" : "auto",
|
|
2445
|
+
userSelect: canMove ? "none" : void 0,
|
|
2446
|
+
WebkitTouchCallout: canMove ? "none" : void 0,
|
|
2296
2447
|
zIndex: active ? 3 : 1,
|
|
2297
2448
|
opacity: active ? .85 : 1,
|
|
2298
2449
|
visibility: hiddenForMove ? "hidden" : void 0,
|
|
@@ -2306,8 +2457,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2306
2457
|
}),
|
|
2307
2458
|
canResize && !pe.continuesBefore ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2308
2459
|
onPointerDown: (e) => {
|
|
2309
|
-
e
|
|
2310
|
-
beginDrag(e, pe, key, "resize-start", dayIndex, canMove ? onPress : void 0);
|
|
2460
|
+
pressEvent(e, pe, key, "resize-start", dayIndex, canMove ? onPress : void 0);
|
|
2311
2461
|
},
|
|
2312
2462
|
style: {
|
|
2313
2463
|
position: "absolute",
|
|
@@ -2316,13 +2466,12 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2316
2466
|
top: 0,
|
|
2317
2467
|
height: 8,
|
|
2318
2468
|
cursor: "ns-resize",
|
|
2319
|
-
touchAction: "
|
|
2469
|
+
touchAction: "pan-y"
|
|
2320
2470
|
}
|
|
2321
2471
|
}) : null,
|
|
2322
2472
|
canResize && !pe.continuesAfter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2323
2473
|
onPointerDown: (e) => {
|
|
2324
|
-
e
|
|
2325
|
-
beginDrag(e, pe, key, "resize", dayIndex, canMove ? onPress : void 0);
|
|
2474
|
+
pressEvent(e, pe, key, "resize", dayIndex, canMove ? onPress : void 0);
|
|
2326
2475
|
},
|
|
2327
2476
|
style: {
|
|
2328
2477
|
position: "absolute",
|
|
@@ -2331,7 +2480,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2331
2480
|
bottom: 0,
|
|
2332
2481
|
height: 8,
|
|
2333
2482
|
cursor: "ns-resize",
|
|
2334
|
-
touchAction: "
|
|
2483
|
+
touchAction: "pan-y"
|
|
2335
2484
|
}
|
|
2336
2485
|
}) : null
|
|
2337
2486
|
]
|
|
@@ -2498,7 +2647,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2498
2647
|
* ```
|
|
2499
2648
|
*/
|
|
2500
2649
|
const Calendar = (0, react.forwardRef)(CalendarInner);
|
|
2501
|
-
function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
2650
|
+
function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, touchDragDelay, touchDragThreshold, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
2502
2651
|
const timeGridRef = (0, react.useRef)(null);
|
|
2503
2652
|
(0, react.useImperativeHandle)(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
2504
2653
|
const displayEvents = (0, react.useMemo)(() => {
|
|
@@ -2585,6 +2734,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2585
2734
|
classNames,
|
|
2586
2735
|
styles,
|
|
2587
2736
|
maxVisibleEventCount,
|
|
2737
|
+
chipHeight,
|
|
2738
|
+
chipGap,
|
|
2588
2739
|
moreLabel,
|
|
2589
2740
|
showAdjacentMonths,
|
|
2590
2741
|
showTitle,
|
|
@@ -2649,6 +2800,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2649
2800
|
eventDurationEditable,
|
|
2650
2801
|
eventOverlap,
|
|
2651
2802
|
dragStepMinutes,
|
|
2803
|
+
touchDragDelay,
|
|
2804
|
+
touchDragThreshold,
|
|
2652
2805
|
onPressEvent,
|
|
2653
2806
|
onPressCell,
|
|
2654
2807
|
onCreateEvent,
|
|
@@ -2674,7 +2827,7 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2674
2827
|
* Legend List's DOM renderer and the library's headless grid logic. Selection is
|
|
2675
2828
|
* controlled, pass `selectedRange` (or `selectedDates`) and handle `onPressDay`.
|
|
2676
2829
|
*/
|
|
2677
|
-
function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "short", highlightWeekends = true, weekStartsOn = 0, events, renderEvent, eventAccessibilityLabel, maxVisibleEventCount, moreLabel, labels, onPressEvent, onPressMore, selectedRange, selectedDates, fillCellOnSelection = false, locale, theme: themeOverrides, height = 480, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, className, style, classNames, styles }) {
|
|
2830
|
+
function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "short", highlightWeekends = true, weekStartsOn = 0, events, renderEvent, eventAccessibilityLabel, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, onPressEvent, onPressMore, selectedRange, selectedDates, fillCellOnSelection = false, locale, theme: themeOverrides, height = 480, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, className, style, classNames, styles }) {
|
|
2678
2831
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
2679
2832
|
const slot = createSlots({
|
|
2680
2833
|
classNames,
|
|
@@ -2708,11 +2861,15 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2708
2861
|
const extraData = (0, react.useMemo)(() => [
|
|
2709
2862
|
selectedRange,
|
|
2710
2863
|
selectedDates,
|
|
2711
|
-
events
|
|
2864
|
+
events,
|
|
2865
|
+
chipHeight,
|
|
2866
|
+
chipGap
|
|
2712
2867
|
], [
|
|
2713
2868
|
selectedRange,
|
|
2714
2869
|
selectedDates,
|
|
2715
|
-
events
|
|
2870
|
+
events,
|
|
2871
|
+
chipHeight,
|
|
2872
|
+
chipGap
|
|
2716
2873
|
]);
|
|
2717
2874
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2718
2875
|
className,
|
|
@@ -2761,6 +2918,8 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2761
2918
|
renderEvent,
|
|
2762
2919
|
eventAccessibilityLabel,
|
|
2763
2920
|
maxVisibleEventCount,
|
|
2921
|
+
chipHeight,
|
|
2922
|
+
chipGap,
|
|
2764
2923
|
moreLabel,
|
|
2765
2924
|
labels,
|
|
2766
2925
|
onPressEvent,
|
|
@@ -3147,7 +3306,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3147
3306
|
dragRef.current = next;
|
|
3148
3307
|
setDrag(next);
|
|
3149
3308
|
};
|
|
3150
|
-
const beginDrag = (e, key, resourceId, kind,
|
|
3309
|
+
const beginDrag = (e, key, resourceId, kind, pe) => {
|
|
3310
|
+
const { startHours, durationHours } = pe;
|
|
3151
3311
|
if (!onDragEvent) return;
|
|
3152
3312
|
e.stopPropagation();
|
|
3153
3313
|
try {
|
|
@@ -3157,7 +3317,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3157
3317
|
x: vertical ? e.clientY : e.clientX,
|
|
3158
3318
|
cross: vertical ? e.clientX : e.clientY,
|
|
3159
3319
|
startHours,
|
|
3160
|
-
durationHours
|
|
3320
|
+
durationHours,
|
|
3321
|
+
span: pe.continuesBefore || pe.continuesAfter ? null : {
|
|
3322
|
+
start: pe.event.start,
|
|
3323
|
+
end: pe.event.end
|
|
3324
|
+
}
|
|
3161
3325
|
};
|
|
3162
3326
|
applyDrag({
|
|
3163
3327
|
key,
|
|
@@ -3175,11 +3339,17 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3175
3339
|
const dHours = ((vertical ? e.clientY : e.clientX) - origin.current.x) / hourSize;
|
|
3176
3340
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
3177
3341
|
if (d.kind === "move") {
|
|
3178
|
-
const
|
|
3179
|
-
const
|
|
3342
|
+
const o = origin.current;
|
|
3343
|
+
const requestedHours = clamp(snap(o.startHours + dHours), startHour, endHour - o.durationHours);
|
|
3344
|
+
const span = o.span;
|
|
3345
|
+
const moved = span ? (0, _super_calendar_core.movedClockSpan)(span.start, span.end, Math.round((requestedHours - o.startHours) * 60)) : null;
|
|
3346
|
+
const startHours = moved ? o.startHours + moved.startHours : requestedHours;
|
|
3347
|
+
const durationHours = moved ? moved.hours : o.durationHours;
|
|
3348
|
+
const crossPx = (vertical ? e.clientX : e.clientY) - o.cross;
|
|
3180
3349
|
applyDrag({
|
|
3181
3350
|
...d,
|
|
3182
3351
|
startHours,
|
|
3352
|
+
durationHours,
|
|
3183
3353
|
crossPx,
|
|
3184
3354
|
moved: true
|
|
3185
3355
|
});
|
|
@@ -3218,10 +3388,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3218
3388
|
return;
|
|
3219
3389
|
}
|
|
3220
3390
|
const target = d.kind === "move" ? laneAt(e, resource) : resource;
|
|
3221
|
-
const
|
|
3222
|
-
const
|
|
3223
|
-
const
|
|
3224
|
-
|
|
3391
|
+
const o = origin.current;
|
|
3392
|
+
const startDelta = o ? Math.round((d.startHours - o.startHours) * 60) : 0;
|
|
3393
|
+
const endDelta = d.kind === "move" ? startDelta : o ? Math.round((d.durationHours - o.durationHours) * 60) : 0;
|
|
3394
|
+
const next = (0, _super_calendar_core.resolveDraggedBounds)(event.start, event.end, startDelta, endDelta, dragStepMinutes);
|
|
3395
|
+
if (next) onDragEvent?.(event, next.start, next.end, target);
|
|
3225
3396
|
applyDrag(null);
|
|
3226
3397
|
origin.current = null;
|
|
3227
3398
|
};
|
|
@@ -3475,7 +3646,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3475
3646
|
onClick: draggable ? void 0 : onPress,
|
|
3476
3647
|
"aria-label": pe.event.title,
|
|
3477
3648
|
...dataState({ "data-dragging": !!active }),
|
|
3478
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe
|
|
3649
|
+
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : void 0,
|
|
3479
3650
|
onPointerMove: draggable ? moveDrag : void 0,
|
|
3480
3651
|
onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
|
|
3481
3652
|
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
@@ -3505,7 +3676,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3505
3676
|
"aria-hidden": true,
|
|
3506
3677
|
onPointerDown: (e) => {
|
|
3507
3678
|
e.stopPropagation();
|
|
3508
|
-
beginDrag(e, key, resource.id, "resize", pe
|
|
3679
|
+
beginDrag(e, key, resource.id, "resize", pe);
|
|
3509
3680
|
},
|
|
3510
3681
|
style: {
|
|
3511
3682
|
position: "absolute",
|
|
@@ -3695,7 +3866,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3695
3866
|
onClick: draggable ? void 0 : onPress,
|
|
3696
3867
|
"aria-label": pe.event.title,
|
|
3697
3868
|
...dataState({ "data-dragging": !!active }),
|
|
3698
|
-
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe
|
|
3869
|
+
onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : void 0,
|
|
3699
3870
|
onPointerMove: draggable ? moveDrag : void 0,
|
|
3700
3871
|
onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
|
|
3701
3872
|
onPointerCancel: draggable ? cancelDrag : void 0,
|
|
@@ -3725,7 +3896,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
|
|
|
3725
3896
|
"aria-hidden": true,
|
|
3726
3897
|
onPointerDown: (e) => {
|
|
3727
3898
|
e.stopPropagation();
|
|
3728
|
-
beginDrag(e, key, resource.id, "resize", pe
|
|
3899
|
+
beginDrag(e, key, resource.id, "resize", pe);
|
|
3729
3900
|
},
|
|
3730
3901
|
style: {
|
|
3731
3902
|
position: "absolute",
|