@super-calendar/dom 2.14.0 → 2.14.2

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.js CHANGED
@@ -1360,6 +1360,10 @@ const VISUALLY_HIDDEN = {
1360
1360
  const DOM_TITLE_LINE_HEIGHT = 16;
1361
1361
  const DOM_TIME_LINE_HEIGHT = 30;
1362
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
+ }
1363
1367
  function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme, boxProps }) {
1364
1368
  const timeLabel = (0, _super_calendar_core.eventTimeLabel)({
1365
1369
  mode,
@@ -1648,17 +1652,23 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1648
1652
  const snap = (v) => Math.round(v / snapHours) * snapHours;
1649
1653
  if (d.kind === "move") {
1650
1654
  const raw = snap(dragOrigin.current.startHours + dHours);
1651
- const startHours = d.continuesBefore ? raw : (0, _super_calendar_core.clampMoveStartMinutes)(raw * 60, windowStart, windowEnd, snapMinutes) / 60;
1655
+ const requestedHours = d.continuesBefore ? raw : (0, _super_calendar_core.clampMoveStartMinutes)(raw * 60, windowStart, windowEnd, snapMinutes) / 60;
1652
1656
  const o = dragOrigin.current;
1653
1657
  const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
1654
1658
  const targetDay = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1);
1655
1659
  const dayDelta = targetDay - o.dayIndex;
1656
- const spillHours = Math.min(Math.max(startHours + d.durationHours - HOURS_PER_DAY, 0), windowHours);
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);
1657
1665
  const nextDay = daysRef.current[targetDay + 1];
1658
1666
  const spillDayIndex = spillHours > 0 && nextDay && (0, date_fns.differenceInCalendarDays)(nextDay, daysRef.current[targetDay]) === 1 && !d.continuesAfter ? targetDay + 1 : -1;
1659
1667
  applyDrag({
1660
1668
  ...d,
1661
1669
  startHours,
1670
+ requestedStartHours: requestedHours,
1671
+ durationHours,
1662
1672
  dayDelta,
1663
1673
  dayOffsetPx: dayDelta * o.dayWidth,
1664
1674
  spillHours,
@@ -1723,11 +1733,13 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1723
1733
  base = day ? (0, date_fns.startOfDay)(day) : null;
1724
1734
  } else base = (0, date_fns.startOfDay)(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
1725
1735
  } else base = (0, date_fns.startOfDay)(daysRef.current[originIndex] ?? daysRef.current[0]);
1726
- if (base && held && origin) {
1727
- const segmentStart = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
1728
- const segmentEnd = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
1729
- const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
1730
- const endShift = d.kind === "move" ? startShift : d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
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;
1731
1743
  const start = new Date(held.event.start.getTime() + startShift);
1732
1744
  const end = new Date(held.event.end.getTime() + endShift);
1733
1745
  if (end > start) onDragEventRef.current?.(held.event, start, end);
@@ -1749,6 +1761,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1749
1761
  const dayWidth = column ? column.getBoundingClientRect().width : 0;
1750
1762
  const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
1751
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;
1752
1766
  dragOrigin.current = {
1753
1767
  pointerX: e.clientX,
1754
1768
  pointerY: e.clientY,
@@ -1757,8 +1771,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1757
1771
  durationHours,
1758
1772
  dayIndex,
1759
1773
  dayWidth,
1760
- segmentStart: (0, date_fns.addMinutes)(originBase, Math.round(startHours * 60)),
1761
- segmentEnd: (0, date_fns.addMinutes)(originBase, Math.round((startHours + durationHours) * 60))
1774
+ segmentStart,
1775
+ segmentEnd: event.end < originNextDay ? event.end : originNextDay,
1776
+ base: originBase
1762
1777
  };
1763
1778
  draggedRef.current = {
1764
1779
  event,
@@ -1780,6 +1795,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1780
1795
  key,
1781
1796
  kind,
1782
1797
  startHours,
1798
+ requestedStartHours: startHours,
1783
1799
  durationHours,
1784
1800
  continuesBefore,
1785
1801
  continuesAfter,
@@ -1924,7 +1940,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1924
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);
1925
1941
  const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
1926
1942
  const target = days[moveOrigin.dayIndex + drag.dayDelta];
1927
- const shift = (0, date_fns.addMinutes)((0, date_fns.startOfDay)(target), Math.round(drag.startHours * 60)).getTime() - moveOrigin.segmentStart.getTime();
1943
+ const shift = movedSegmentStart(moveOrigin, (0, date_fns.startOfDay)(target), drag.requestedStartHours).getTime() - moveOrigin.segmentStart.getTime();
1928
1944
  return {
1929
1945
  ...movingEvent,
1930
1946
  start: new Date(movingEvent.start.getTime() + shift),
@@ -3290,7 +3306,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3290
3306
  dragRef.current = next;
3291
3307
  setDrag(next);
3292
3308
  };
3293
- const beginDrag = (e, key, resourceId, kind, startHours, durationHours) => {
3309
+ const beginDrag = (e, key, resourceId, kind, pe) => {
3310
+ const { startHours, durationHours } = pe;
3294
3311
  if (!onDragEvent) return;
3295
3312
  e.stopPropagation();
3296
3313
  try {
@@ -3300,7 +3317,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3300
3317
  x: vertical ? e.clientY : e.clientX,
3301
3318
  cross: vertical ? e.clientX : e.clientY,
3302
3319
  startHours,
3303
- durationHours
3320
+ durationHours,
3321
+ span: pe.continuesBefore || pe.continuesAfter ? null : {
3322
+ start: pe.event.start,
3323
+ end: pe.event.end
3324
+ }
3304
3325
  };
3305
3326
  applyDrag({
3306
3327
  key,
@@ -3318,11 +3339,17 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3318
3339
  const dHours = ((vertical ? e.clientY : e.clientX) - origin.current.x) / hourSize;
3319
3340
  const snap = (v) => Math.round(v / snapHours) * snapHours;
3320
3341
  if (d.kind === "move") {
3321
- const startHours = clamp(snap(origin.current.startHours + dHours), startHour, endHour - d.durationHours);
3322
- const crossPx = (vertical ? e.clientX : e.clientY) - origin.current.cross;
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;
3323
3349
  applyDrag({
3324
3350
  ...d,
3325
3351
  startHours,
3352
+ durationHours,
3326
3353
  crossPx,
3327
3354
  moved: true
3328
3355
  });
@@ -3361,10 +3388,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3361
3388
  return;
3362
3389
  }
3363
3390
  const target = d.kind === "move" ? laneAt(e, resource) : resource;
3364
- const base = (0, date_fns.startOfDay)(date);
3365
- const start = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
3366
- const end = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
3367
- onDragEvent?.(event, start, end, target);
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);
3368
3396
  applyDrag(null);
3369
3397
  origin.current = null;
3370
3398
  };
@@ -3618,7 +3646,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3618
3646
  onClick: draggable ? void 0 : onPress,
3619
3647
  "aria-label": pe.event.title,
3620
3648
  ...dataState({ "data-dragging": !!active }),
3621
- onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe.startHours, pe.durationHours) : void 0,
3649
+ onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : void 0,
3622
3650
  onPointerMove: draggable ? moveDrag : void 0,
3623
3651
  onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
3624
3652
  onPointerCancel: draggable ? cancelDrag : void 0,
@@ -3648,7 +3676,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3648
3676
  "aria-hidden": true,
3649
3677
  onPointerDown: (e) => {
3650
3678
  e.stopPropagation();
3651
- beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
3679
+ beginDrag(e, key, resource.id, "resize", pe);
3652
3680
  },
3653
3681
  style: {
3654
3682
  position: "absolute",
@@ -3838,7 +3866,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3838
3866
  onClick: draggable ? void 0 : onPress,
3839
3867
  "aria-label": pe.event.title,
3840
3868
  ...dataState({ "data-dragging": !!active }),
3841
- onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe.startHours, pe.durationHours) : void 0,
3869
+ onPointerDown: draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : void 0,
3842
3870
  onPointerMove: draggable ? moveDrag : void 0,
3843
3871
  onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
3844
3872
  onPointerCancel: draggable ? cancelDrag : void 0,
@@ -3868,7 +3896,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3868
3896
  "aria-hidden": true,
3869
3897
  onPointerDown: (e) => {
3870
3898
  e.stopPropagation();
3871
- beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
3899
+ beginDrag(e, key, resource.id, "resize", pe);
3872
3900
  },
3873
3901
  style: {
3874
3902
  position: "absolute",
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). */
@@ -1359,6 +1359,10 @@ const VISUALLY_HIDDEN = {
1359
1359
  const DOM_TITLE_LINE_HEIGHT = 16;
1360
1360
  const DOM_TIME_LINE_HEIGHT = 30;
1361
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
+ }
1362
1366
  function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme, boxProps }) {
1363
1367
  const timeLabel = eventTimeLabel({
1364
1368
  mode,
@@ -1647,17 +1651,23 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1647
1651
  const snap = (v) => Math.round(v / snapHours) * snapHours;
1648
1652
  if (d.kind === "move") {
1649
1653
  const raw = snap(dragOrigin.current.startHours + dHours);
1650
- 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;
1651
1655
  const o = dragOrigin.current;
1652
1656
  const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
1653
1657
  const targetDay = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1);
1654
1658
  const dayDelta = targetDay - o.dayIndex;
1655
- 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);
1656
1664
  const nextDay = daysRef.current[targetDay + 1];
1657
1665
  const spillDayIndex = spillHours > 0 && nextDay && differenceInCalendarDays(nextDay, daysRef.current[targetDay]) === 1 && !d.continuesAfter ? targetDay + 1 : -1;
1658
1666
  applyDrag({
1659
1667
  ...d,
1660
1668
  startHours,
1669
+ requestedStartHours: requestedHours,
1670
+ durationHours,
1661
1671
  dayDelta,
1662
1672
  dayOffsetPx: dayDelta * o.dayWidth,
1663
1673
  spillHours,
@@ -1722,11 +1732,13 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1722
1732
  base = day ? startOfDay(day) : null;
1723
1733
  } else base = startOfDay(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
1724
1734
  } else base = startOfDay(daysRef.current[originIndex] ?? daysRef.current[0]);
1725
- if (base && held && origin) {
1726
- const segmentStart = addMinutes(base, Math.round(d.startHours * 60));
1727
- const segmentEnd = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
1728
- const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
1729
- 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;
1730
1742
  const start = new Date(held.event.start.getTime() + startShift);
1731
1743
  const end = new Date(held.event.end.getTime() + endShift);
1732
1744
  if (end > start) onDragEventRef.current?.(held.event, start, end);
@@ -1748,6 +1760,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1748
1760
  const dayWidth = column ? column.getBoundingClientRect().width : 0;
1749
1761
  const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
1750
1762
  const originBase = startOfDay(days[dayIndex] ?? days[0]);
1763
+ const originNextDay = addDays(originBase, 1);
1764
+ const segmentStart = event.start > originBase ? event.start : originBase;
1751
1765
  dragOrigin.current = {
1752
1766
  pointerX: e.clientX,
1753
1767
  pointerY: e.clientY,
@@ -1756,8 +1770,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1756
1770
  durationHours,
1757
1771
  dayIndex,
1758
1772
  dayWidth,
1759
- segmentStart: addMinutes(originBase, Math.round(startHours * 60)),
1760
- segmentEnd: addMinutes(originBase, Math.round((startHours + durationHours) * 60))
1773
+ segmentStart,
1774
+ segmentEnd: event.end < originNextDay ? event.end : originNextDay,
1775
+ base: originBase
1761
1776
  };
1762
1777
  draggedRef.current = {
1763
1778
  event,
@@ -1779,6 +1794,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1779
1794
  key,
1780
1795
  kind,
1781
1796
  startHours,
1797
+ requestedStartHours: startHours,
1782
1798
  durationHours,
1783
1799
  continuesBefore,
1784
1800
  continuesAfter,
@@ -1923,7 +1939,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
1923
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);
1924
1940
  const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
1925
1941
  const target = days[moveOrigin.dayIndex + drag.dayDelta];
1926
- 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();
1927
1943
  return {
1928
1944
  ...movingEvent,
1929
1945
  start: new Date(movingEvent.start.getTime() + shift),
@@ -3289,7 +3305,8 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3289
3305
  dragRef.current = next;
3290
3306
  setDrag(next);
3291
3307
  };
3292
- const beginDrag = (e, key, resourceId, kind, startHours, durationHours) => {
3308
+ const beginDrag = (e, key, resourceId, kind, pe) => {
3309
+ const { startHours, durationHours } = pe;
3293
3310
  if (!onDragEvent) return;
3294
3311
  e.stopPropagation();
3295
3312
  try {
@@ -3299,7 +3316,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3299
3316
  x: vertical ? e.clientY : e.clientX,
3300
3317
  cross: vertical ? e.clientX : e.clientY,
3301
3318
  startHours,
3302
- durationHours
3319
+ durationHours,
3320
+ span: pe.continuesBefore || pe.continuesAfter ? null : {
3321
+ start: pe.event.start,
3322
+ end: pe.event.end
3323
+ }
3303
3324
  };
3304
3325
  applyDrag({
3305
3326
  key,
@@ -3317,11 +3338,17 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3317
3338
  const dHours = ((vertical ? e.clientY : e.clientX) - origin.current.x) / hourSize;
3318
3339
  const snap = (v) => Math.round(v / snapHours) * snapHours;
3319
3340
  if (d.kind === "move") {
3320
- const startHours = clamp(snap(origin.current.startHours + dHours), startHour, endHour - d.durationHours);
3321
- 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;
3322
3348
  applyDrag({
3323
3349
  ...d,
3324
3350
  startHours,
3351
+ durationHours,
3325
3352
  crossPx,
3326
3353
  moved: true
3327
3354
  });
@@ -3360,10 +3387,11 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3360
3387
  return;
3361
3388
  }
3362
3389
  const target = d.kind === "move" ? laneAt(e, resource) : resource;
3363
- const base = startOfDay(date);
3364
- const start = addMinutes(base, Math.round(d.startHours * 60));
3365
- const end = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
3366
- 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);
3367
3395
  applyDrag(null);
3368
3396
  origin.current = null;
3369
3397
  };
@@ -3617,7 +3645,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3617
3645
  onClick: draggable ? void 0 : onPress,
3618
3646
  "aria-label": pe.event.title,
3619
3647
  ...dataState({ "data-dragging": !!active }),
3620
- 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,
3621
3649
  onPointerMove: draggable ? moveDrag : void 0,
3622
3650
  onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
3623
3651
  onPointerCancel: draggable ? cancelDrag : void 0,
@@ -3647,7 +3675,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3647
3675
  "aria-hidden": true,
3648
3676
  onPointerDown: (e) => {
3649
3677
  e.stopPropagation();
3650
- beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
3678
+ beginDrag(e, key, resource.id, "resize", pe);
3651
3679
  },
3652
3680
  style: {
3653
3681
  position: "absolute",
@@ -3837,7 +3865,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3837
3865
  onClick: draggable ? void 0 : onPress,
3838
3866
  "aria-label": pe.event.title,
3839
3867
  ...dataState({ "data-dragging": !!active }),
3840
- 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,
3841
3869
  onPointerMove: draggable ? moveDrag : void 0,
3842
3870
  onPointerUp: draggable ? (e) => endDrag(e, pe.event, resource, onPress) : void 0,
3843
3871
  onPointerCancel: draggable ? cancelDrag : void 0,
@@ -3867,7 +3895,7 @@ function ResourceTimeline({ date, orientation = "horizontal", resources: allReso
3867
3895
  "aria-hidden": true,
3868
3896
  onPointerDown: (e) => {
3869
3897
  e.stopPropagation();
3870
- beginDrag(e, key, resource.id, "resize", pe.startHours, pe.durationHours);
3898
+ beginDrag(e, key, resource.id, "resize", pe);
3871
3899
  },
3872
3900
  style: {
3873
3901
  position: "absolute",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/dom",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
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.14.0"
51
+ "@super-calendar/core": "2.14.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@legendapp/list": ">=3",
@@ -1,4 +1,3 @@
1
- import { addMinutes, startOfDay } from "date-fns";
2
1
  import type {
3
2
  ComponentType,
4
3
  CSSProperties,
@@ -19,6 +18,9 @@ import {
19
18
  eventTimeLabel,
20
19
  formatHour,
21
20
  layoutDayEvents,
21
+ movedClockSpan,
22
+ type PositionedEvent,
23
+ resolveDraggedBounds,
22
24
  } from "@super-calendar/core";
23
25
  import { createSlots, dataState, type ResolvedSlot, type SlotStyleProps } from "./slots";
24
26
  import { type DomCalendarTheme, mergeDomTheme } from "./theme";
@@ -340,6 +342,9 @@ export function ResourceTimeline<T = unknown>({
340
342
  cross: number;
341
343
  startHours: number;
342
344
  durationHours: number;
345
+ // The event's own bounds, for previewing a move across a DST change; null
346
+ // for a bar clipped to the day.
347
+ span: { start: Date; end: Date } | null;
343
348
  } | null>(null);
344
349
  const applyDrag = (next: DragState | null) => {
345
350
  dragRef.current = next;
@@ -351,9 +356,9 @@ export function ResourceTimeline<T = unknown>({
351
356
  key: string,
352
357
  resourceId: string,
353
358
  kind: "move" | "resize",
354
- startHours: number,
355
- durationHours: number,
359
+ pe: PositionedEvent<T>,
356
360
  ) => {
361
+ const { startHours, durationHours } = pe;
357
362
  if (!onDragEvent) return;
358
363
  e.stopPropagation();
359
364
  try {
@@ -366,6 +371,10 @@ export function ResourceTimeline<T = unknown>({
366
371
  cross: vertical ? e.clientX : e.clientY,
367
372
  startHours,
368
373
  durationHours,
374
+ span:
375
+ pe.continuesBefore || pe.continuesAfter
376
+ ? null
377
+ : { start: pe.event.start, end: pe.event.end },
369
378
  };
370
379
  applyDrag({ key, resourceId, kind, startHours, durationHours, crossPx: 0, moved: false });
371
380
  };
@@ -375,13 +384,24 @@ export function ResourceTimeline<T = unknown>({
375
384
  const dHours = ((vertical ? e.clientY : e.clientX) - origin.current.x) / hourSize;
376
385
  const snap = (v: number) => Math.round(v / snapHours) * snapHours;
377
386
  if (d.kind === "move") {
378
- const startHours = clamp(
379
- snap(origin.current.startHours + dHours),
387
+ const o = origin.current;
388
+ const requestedHours = clamp(
389
+ snap(o.startHours + dHours),
380
390
  startHour,
381
- endHour - d.durationHours,
391
+ endHour - o.durationHours,
382
392
  );
383
- const crossPx = (vertical ? e.clientX : e.clientY) - origin.current.cross;
384
- applyDrag({ ...d, startHours, crossPx, moved: true });
393
+ // Draw the bar where the drop commits it: a start in the hour a
394
+ // spring-forward change skips moves on past it, and the kept elapsed
395
+ // duration covers a different number of hours once a DST change falls
396
+ // inside it or stops falling inside it.
397
+ const span = o.span;
398
+ const moved = span
399
+ ? movedClockSpan(span.start, span.end, Math.round((requestedHours - o.startHours) * 60))
400
+ : null;
401
+ const startHours = moved ? o.startHours + moved.startHours : requestedHours;
402
+ const durationHours = moved ? moved.hours : o.durationHours;
403
+ const crossPx = (vertical ? e.clientX : e.clientY) - o.cross;
404
+ applyDrag({ ...d, startHours, durationHours, crossPx, moved: true });
385
405
  } else {
386
406
  const durationHours = clamp(
387
407
  snap(origin.current.durationHours + dHours),
@@ -433,10 +453,22 @@ export function ResourceTimeline<T = unknown>({
433
453
  return;
434
454
  }
435
455
  const target = d.kind === "move" ? laneAt(e, resource) : resource;
436
- const base = startOfDay(date);
437
- const start = addMinutes(base, Math.round(d.startHours * 60));
438
- const end = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
439
- onDragEvent?.(event, start, end, target);
456
+ // Shift the event by how far its bar moved, like the native renderer, so a
457
+ // move keeps its elapsed duration across a DST change.
458
+ const o = origin.current;
459
+ const startDelta = o ? Math.round((d.startHours - o.startHours) * 60) : 0;
460
+ // A move shifts both edges alike; its preview duration only redraws the
461
+ // kept elapsed duration.
462
+ const endDelta =
463
+ d.kind === "move" ? startDelta : o ? Math.round((d.durationHours - o.durationHours) * 60) : 0;
464
+ const next = resolveDraggedBounds(
465
+ event.start,
466
+ event.end,
467
+ startDelta,
468
+ endDelta,
469
+ dragStepMinutes,
470
+ );
471
+ if (next) onDragEvent?.(event, next.start, next.end, target);
440
472
  applyDrag(null);
441
473
  origin.current = null;
442
474
  };
@@ -732,17 +764,7 @@ export function ResourceTimeline<T = unknown>({
732
764
  aria-label={pe.event.title}
733
765
  {...dataState({ "data-dragging": !!active })}
734
766
  onPointerDown={
735
- draggable
736
- ? (e) =>
737
- beginDrag(
738
- e,
739
- key,
740
- resource.id,
741
- "move",
742
- pe.startHours,
743
- pe.durationHours,
744
- )
745
- : undefined
767
+ draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : undefined
746
768
  }
747
769
  onPointerMove={draggable ? moveDrag : undefined}
748
770
  onPointerUp={
@@ -783,14 +805,7 @@ export function ResourceTimeline<T = unknown>({
783
805
  aria-hidden
784
806
  onPointerDown={(e) => {
785
807
  e.stopPropagation();
786
- beginDrag(
787
- e,
788
- key,
789
- resource.id,
790
- "resize",
791
- pe.startHours,
792
- pe.durationHours,
793
- );
808
+ beginDrag(e, key, resource.id, "resize", pe);
794
809
  }}
795
810
  style={{
796
811
  position: "absolute",
@@ -983,17 +998,7 @@ export function ResourceTimeline<T = unknown>({
983
998
  aria-label={pe.event.title}
984
999
  {...dataState({ "data-dragging": !!active })}
985
1000
  onPointerDown={
986
- draggable
987
- ? (e) =>
988
- beginDrag(
989
- e,
990
- key,
991
- resource.id,
992
- "move",
993
- pe.startHours,
994
- pe.durationHours,
995
- )
996
- : undefined
1001
+ draggable ? (e) => beginDrag(e, key, resource.id, "move", pe) : undefined
997
1002
  }
998
1003
  onPointerMove={draggable ? moveDrag : undefined}
999
1004
  onPointerUp={
@@ -1032,14 +1037,7 @@ export function ResourceTimeline<T = unknown>({
1032
1037
  aria-hidden
1033
1038
  onPointerDown={(e) => {
1034
1039
  e.stopPropagation();
1035
- beginDrag(
1036
- e,
1037
- key,
1038
- resource.id,
1039
- "resize",
1040
- pe.startHours,
1041
- pe.durationHours,
1042
- );
1040
+ beginDrag(e, key, resource.id, "resize", pe);
1043
1041
  }}
1044
1042
  style={{
1045
1043
  position: "absolute",
package/src/TimeGrid.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  addDays,
3
- addMinutes,
4
3
  differenceInCalendarDays,
5
4
  format,
6
5
  getISOWeek,
@@ -32,6 +31,9 @@ import {
32
31
  type CalendarMode,
33
32
  cellRangeFromDrag,
34
33
  clampMoveStartMinutes,
34
+ resolveDraggedBounds,
35
+ movedClockSpan,
36
+ shiftMinutes,
35
37
  pageStepDays,
36
38
  backgroundBandsForDay,
37
39
  closedHourBands,
@@ -299,6 +301,10 @@ type DragState = {
299
301
  // top edge (changes the start, end fixed).
300
302
  kind: "move" | "resize" | "resize-start";
301
303
  startHours: number;
304
+ // The row a move asked for. `startHours` is where it lands, an hour later when
305
+ // that row is in the hour a spring-forward change skips; the commit re-resolves
306
+ // the request against the day it drops on.
307
+ requestedStartHours: number;
302
308
  durationHours: number;
303
309
  /** Whole day columns the box has been dragged across, clamped to the view. */
304
310
  dayDelta: number;
@@ -320,8 +326,25 @@ type DragState = {
320
326
  // both. The time reserves two lines (it can wrap on a narrow column).
321
327
  const DOM_TITLE_LINE_HEIGHT = 16;
322
328
  const DOM_TIME_LINE_HEIGHT = 30;
329
+
323
330
  const DOM_BOX_PADDING_V = 2;
324
331
 
332
+ // Where a dragged segment's start lands: shifted on the clock by as many minutes
333
+ // as its row moved, plus whole days to `base`, from the instant it started at.
334
+ // Shifting the real instant rather than rebuilding it from rows keeps a start in
335
+ // the hour a fall-back change repeats on its own occurrence.
336
+ function movedSegmentStart(
337
+ origin: { startHours: number; segmentStart: Date; base: Date },
338
+ base: Date,
339
+ startHours: number,
340
+ ): Date {
341
+ const dayMinutes = differenceInCalendarDays(base, origin.base) * HOURS_PER_DAY * 60;
342
+ return shiftMinutes(
343
+ origin.segmentStart,
344
+ dayMinutes + Math.round((startHours - origin.startHours) * 60),
345
+ );
346
+ }
347
+
325
348
  function DefaultDomEvent<T>({
326
349
  event,
327
350
  mode,
@@ -537,6 +560,8 @@ function TimeGridInner<T = unknown>(
537
560
  // (which would truncate everything outside the dragged day).
538
561
  segmentStart: Date;
539
562
  segmentEnd: Date;
563
+ // Midnight of the day the segment was grabbed on.
564
+ base: Date;
540
565
  } | null>(null);
541
566
  const applyDrag = (next: DragState | null) => {
542
567
  dragRef.current = next;
@@ -793,7 +818,7 @@ function TimeGridInner<T = unknown>(
793
818
  // layout clipped the event, not where the event starts, so holding it there
794
819
  // would make the tail of a midnight-spanning event impossible to drag earlier.
795
820
  const raw = snap(dragOrigin.current.startHours + dHours);
796
- const startHours = d.continuesBefore
821
+ const requestedHours = d.continuesBefore
797
822
  ? raw
798
823
  : clampMoveStartMinutes(raw * 60, windowStart, windowEnd, snapMinutes) / 60;
799
824
  // Map the horizontal drag to whole day columns, clamped so the in-view box
@@ -803,12 +828,27 @@ function TimeGridInner<T = unknown>(
803
828
  const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
804
829
  const targetDay = clamp(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1);
805
830
  const dayDelta = targetDay - o.dayIndex;
831
+ // Draw the box where the drop commits it: a start in the hour a
832
+ // spring-forward change skips moves on past it, and the kept elapsed
833
+ // duration covers a different number of rows once a DST change falls
834
+ // inside it or stops falling inside it.
835
+ const dayMinutes =
836
+ differenceInCalendarDays(startOfDay(daysRef.current[targetDay] ?? o.base), o.base) *
837
+ HOURS_PER_DAY *
838
+ 60;
839
+ const moved = movedClockSpan(
840
+ o.segmentStart,
841
+ o.segmentEnd,
842
+ dayMinutes + Math.round((requestedHours - o.startHours) * 60),
843
+ );
844
+ const startHours = o.startHours + moved.startHours - dayMinutes / 60;
845
+ const durationHours = moved.hours;
806
846
  // Preview the part that runs past *midnight* at the top of the next column.
807
847
  // Measured against the end of the day, not `windowEnd`: a narrowed window
808
848
  // (say 8–18) leaves plenty of events hanging below the last visible hour
809
849
  // without them reaching the next day at all.
810
850
  const spillHours = Math.min(
811
- Math.max(startHours + d.durationHours - HOURS_PER_DAY, 0),
851
+ Math.max(startHours + durationHours - HOURS_PER_DAY, 0),
812
852
  windowHours,
813
853
  );
814
854
  const nextDay = daysRef.current[targetDay + 1];
@@ -826,6 +866,8 @@ function TimeGridInner<T = unknown>(
826
866
  applyDrag({
827
867
  ...d,
828
868
  startHours,
869
+ requestedStartHours: requestedHours,
870
+ durationHours,
829
871
  dayDelta,
830
872
  dayOffsetPx: dayDelta * o.dayWidth,
831
873
  spillHours,
@@ -909,20 +951,26 @@ function TimeGridInner<T = unknown>(
909
951
  } else {
910
952
  base = startOfDay(daysRef.current[originIndex] ?? daysRef.current[0]);
911
953
  }
912
- if (base && held && origin) {
954
+ if (held && origin && d.kind === "resize") {
955
+ // Resolve the end like the native renderer, from the edge the layout drew,
956
+ // so it lands at the row the edge was dragged to on either side of a DST
957
+ // change.
958
+ const endDelta = Math.round(
959
+ (d.startHours + d.durationHours - origin.startHours - origin.durationHours) * 60,
960
+ );
961
+ const next = resolveDraggedBounds(held.event.start, held.event.end, 0, endDelta, snapMinutes);
962
+ if (next) onDragEventRef.current?.(held.event, next.start, next.end);
963
+ } else if (base && held && origin) {
913
964
  // Shift the real event by how far its segment moved, so a move that now
914
965
  // spans midnight (and every later drag of the resulting multi-day event)
915
966
  // keeps the parts outside the dragged day instead of clipping to it.
916
- const segmentStart = addMinutes(base, Math.round(d.startHours * 60));
917
- const segmentEnd = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
918
- const startShift =
919
- d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
920
- const endShift =
921
- d.kind === "move"
922
- ? startShift
923
- : d.kind === "resize-start"
924
- ? 0
925
- : segmentEnd.getTime() - origin.segmentEnd.getTime();
967
+ const segmentStart = movedSegmentStart(
968
+ origin,
969
+ base,
970
+ d.kind === "move" ? d.requestedStartHours : d.startHours,
971
+ );
972
+ const startShift = segmentStart.getTime() - origin.segmentStart.getTime();
973
+ const endShift = d.kind === "move" ? startShift : 0;
926
974
  const start = new Date(held.event.start.getTime() + startShift);
927
975
  const end = new Date(held.event.end.getTime() + endShift);
928
976
  if (end > start) onDragEventRef.current?.(held.event, start, end);
@@ -961,6 +1009,8 @@ function TimeGridInner<T = unknown>(
961
1009
  const dayWidth = column ? column.getBoundingClientRect().width : 0;
962
1010
  const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
963
1011
  const originBase = startOfDay(days[dayIndex] ?? days[0]);
1012
+ const originNextDay = addDays(originBase, 1);
1013
+ const segmentStart = event.start > originBase ? event.start : originBase;
964
1014
  dragOrigin.current = {
965
1015
  pointerX: e.clientX,
966
1016
  pointerY: e.clientY,
@@ -969,8 +1019,11 @@ function TimeGridInner<T = unknown>(
969
1019
  durationHours,
970
1020
  dayIndex,
971
1021
  dayWidth,
972
- segmentStart: addMinutes(originBase, Math.round(startHours * 60)),
973
- segmentEnd: addMinutes(originBase, Math.round((startHours + durationHours) * 60)),
1022
+ // The segment's real edges rather than ones rebuilt from its rows: in the
1023
+ // hour a fall-back change repeats, one row maps to two instants.
1024
+ segmentStart,
1025
+ segmentEnd: event.end < originNextDay ? event.end : originNextDay,
1026
+ base: originBase,
974
1027
  };
975
1028
  draggedRef.current = {
976
1029
  event,
@@ -989,6 +1042,7 @@ function TimeGridInner<T = unknown>(
989
1042
  key,
990
1043
  kind,
991
1044
  startHours,
1045
+ requestedStartHours: startHours,
992
1046
  durationHours,
993
1047
  continuesBefore,
994
1048
  continuesAfter,
@@ -1198,7 +1252,11 @@ function TimeGridInner<T = unknown>(
1198
1252
  movingEvent
1199
1253
  ? (() => {
1200
1254
  const target = days[moveOrigin.dayIndex + drag.dayDelta];
1201
- const segmentStart = addMinutes(startOfDay(target), Math.round(drag.startHours * 60));
1255
+ const segmentStart = movedSegmentStart(
1256
+ moveOrigin,
1257
+ startOfDay(target),
1258
+ drag.requestedStartHours,
1259
+ );
1202
1260
  const shift = segmentStart.getTime() - moveOrigin.segmentStart.getTime();
1203
1261
  return {
1204
1262
  ...movingEvent,