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