@super-calendar/dom 2.9.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,6 +52,13 @@ export function MyCalendar() {
52
52
 
53
53
  For a custom picker, pair the headless hooks (`useDateRange`, `useMonthGrid`) with `MonthList` and `TimeGrid`, all re-exported from this package.
54
54
 
55
+ ## Moving events
56
+
57
+ Pass `onDragEvent` and update your event state with the returned `start` and `end`.
58
+ On the time grid, dragging any segment of a multi-day event previews the whole
59
+ range moving together and preserves its duration. Drag a resize grip to change
60
+ only the start or end. See the [dragging guide](https://super-calendar.afonsojramos.me/guides/dragging).
61
+
55
62
  ## Styling
56
63
 
57
64
  Out of the box the calendar is fully styled from the theme, no stylesheet required. To restyle a specific part with **Tailwind** or your own CSS, every element is a named slot: pass `classNames` (or `styles`) per slot, and use `data-*` state variants like `data-[today]:`.
package/dist/index.d.mts CHANGED
@@ -371,6 +371,17 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
371
371
  minHourHeight?: number;
372
372
  /** Upper bound for pixels per hour when zooming. */
373
373
  maxHourHeight?: number;
374
+ /**
375
+ * Minimum pixel height of a timed event box, so short events stay legible and
376
+ * clickable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
377
+ * 14; pass 0 to size every box strictly by its duration.
378
+ */
379
+ minEventHeight?: number;
380
+ /**
381
+ * Inset in pixels between a timed event box and its column edges (each side).
382
+ * Default 1; pass 0 to let events fill their column.
383
+ */
384
+ eventGap?: number;
374
385
  /** Snap dragged events to this many minutes (default 15). */
375
386
  dragStepMinutes?: number;
376
387
  /** Render event time ranges in 12-hour AM/PM (default false, 24h). */
@@ -479,7 +490,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
479
490
  * <TimeGrid mode="week" date={new Date()} events={events} />
480
491
  * ```
481
492
  */
482
- declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
493
+ declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, minEventHeight, eventGap, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
483
494
  //#endregion
484
495
  //#region src/Calendar.d.ts
485
496
  /**
@@ -495,7 +506,13 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
495
506
  * a day-grouped agenda list, and the others a time grid.
496
507
  */
497
508
  mode?: CalendarMode$1;
498
- /** Controlled anchor date. Change it (e.g. from your own header) to navigate. */
509
+ /**
510
+ * Controlled anchor date, read in the device's local time zone; change it
511
+ * (e.g. from your own header) to navigate. Construct it as a local date
512
+ * (`new Date(2026, 7, 24)`), not a UTC instant:
513
+ * `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
514
+ * and anchors the previous week.
515
+ */
499
516
  date: Date;
500
517
  /**
501
518
  * Fires with the next/previous period's date when the user pages the focused
@@ -546,6 +563,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
546
563
  ampm?: boolean;
547
564
  /** Initial pixels per hour. */
548
565
  hourHeight?: number;
566
+ /**
567
+ * Minimum pixel height of a timed event box, so short events stay legible and
568
+ * clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
569
+ * Default 14; pass 0 to size every box strictly by its duration.
570
+ */
571
+ minEventHeight?: number;
572
+ /**
573
+ * Inset in pixels between a timed event box and its column edges (each side).
574
+ * Default 1; pass 0 to let events fill their column.
575
+ */
576
+ eventGap?: number;
549
577
  /** Initial scroll position, in minutes from midnight. */
550
578
  scrollOffsetMinutes?: number;
551
579
  /** Sub-divisions per hour for the grid lines. */
@@ -667,7 +695,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
667
695
  * <Calendar mode="week" date={new Date()} events={events} />
668
696
  * ```
669
697
  */
670
- declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
698
+ declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
671
699
  //#endregion
672
700
  //#region src/MonthList.d.ts
673
701
  /**
package/dist/index.d.ts CHANGED
@@ -371,6 +371,17 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
371
371
  minHourHeight?: number;
372
372
  /** Upper bound for pixels per hour when zooming. */
373
373
  maxHourHeight?: number;
374
+ /**
375
+ * Minimum pixel height of a timed event box, so short events stay legible and
376
+ * clickable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
377
+ * 14; pass 0 to size every box strictly by its duration.
378
+ */
379
+ minEventHeight?: number;
380
+ /**
381
+ * Inset in pixels between a timed event box and its column edges (each side).
382
+ * Default 1; pass 0 to let events fill their column.
383
+ */
384
+ eventGap?: number;
374
385
  /** Snap dragged events to this many minutes (default 15). */
375
386
  dragStepMinutes?: number;
376
387
  /** Render event time ranges in 12-hour AM/PM (default false, 24h). */
@@ -479,7 +490,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
479
490
  * <TimeGrid mode="week" date={new Date()} events={events} />
480
491
  * ```
481
492
  */
482
- declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
493
+ declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, minEventHeight, eventGap, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
483
494
  //#endregion
484
495
  //#region src/Calendar.d.ts
485
496
  /**
@@ -495,7 +506,13 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
495
506
  * a day-grouped agenda list, and the others a time grid.
496
507
  */
497
508
  mode?: CalendarMode$1;
498
- /** Controlled anchor date. Change it (e.g. from your own header) to navigate. */
509
+ /**
510
+ * Controlled anchor date, read in the device's local time zone; change it
511
+ * (e.g. from your own header) to navigate. Construct it as a local date
512
+ * (`new Date(2026, 7, 24)`), not a UTC instant:
513
+ * `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
514
+ * and anchors the previous week.
515
+ */
499
516
  date: Date;
500
517
  /**
501
518
  * Fires with the next/previous period's date when the user pages the focused
@@ -546,6 +563,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
546
563
  ampm?: boolean;
547
564
  /** Initial pixels per hour. */
548
565
  hourHeight?: number;
566
+ /**
567
+ * Minimum pixel height of a timed event box, so short events stay legible and
568
+ * clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
569
+ * Default 14; pass 0 to size every box strictly by its duration.
570
+ */
571
+ minEventHeight?: number;
572
+ /**
573
+ * Inset in pixels between a timed event box and its column edges (each side).
574
+ * Default 1; pass 0 to let events fill their column.
575
+ */
576
+ eventGap?: number;
549
577
  /** Initial scroll position, in minutes from midnight. */
550
578
  scrollOffsetMinutes?: number;
551
579
  /** Sub-divisions per hour for the grid lines. */
@@ -667,7 +695,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
667
695
  * <Calendar mode="week" date={new Date()} events={events} />
668
696
  * ```
669
697
  */
670
- declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
698
+ declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
671
699
  //#endregion
672
700
  //#region src/MonthList.d.ts
673
701
  /**
package/dist/index.js CHANGED
@@ -1279,6 +1279,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
1279
1279
  //#region src/TimeGrid.tsx
1280
1280
  const GUTTER_WIDTH$1 = 56;
1281
1281
  const HOURS_PER_DAY = 24;
1282
+ const DEFAULT_MIN_EVENT_HEIGHT = 14;
1283
+ const DEFAULT_EVENT_GAP = 1;
1282
1284
  const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
1283
1285
  const EDGE_ZONE = 32;
1284
1286
  const EDGE_DWELL_MS = 600;
@@ -1376,7 +1378,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
1376
1378
  * <TimeGrid mode="week" date={new Date()} events={events} />
1377
1379
  * ```
1378
1380
  */
1379
- function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
1381
+ function TimeGrid({ 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, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
1380
1382
  const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
1381
1383
  const slot = createSlots({
1382
1384
  classNames,
@@ -1624,7 +1626,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1624
1626
  const segmentStart = (0, date_fns.addMinutes)(base, Math.round(d.startHours * 60));
1625
1627
  const segmentEnd = (0, date_fns.addMinutes)(base, Math.round((d.startHours + d.durationHours) * 60));
1626
1628
  const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
1627
- const endShift = d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
1629
+ const endShift = d.kind === "move" ? startShift : d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
1628
1630
  const start = new Date(held.event.start.getTime() + startShift);
1629
1631
  const end = new Date(held.event.end.getTime() + endShift);
1630
1632
  if (end > start) onDragEventRef.current?.(held.event, start, end);
@@ -1756,6 +1758,19 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1756
1758
  setCreateBox(null);
1757
1759
  };
1758
1760
  const positionedByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.layoutDayEvents)(events, day)), [days, events]);
1761
+ const moveOrigin = dragOrigin.current;
1762
+ const heldEvent = draggedRef.current?.event;
1763
+ 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);
1764
+ const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
1765
+ const target = days[moveOrigin.dayIndex + drag.dayDelta];
1766
+ const shift = (0, date_fns.addMinutes)((0, date_fns.startOfDay)(target), Math.round(drag.startHours * 60)).getTime() - moveOrigin.segmentStart.getTime();
1767
+ return {
1768
+ ...movingEvent,
1769
+ start: new Date(movingEvent.start.getTime() + shift),
1770
+ end: new Date(movingEvent.end.getTime() + shift),
1771
+ allDay: false
1772
+ };
1773
+ })() : null;
1759
1774
  const spillPreviewFor = (dayIndex) => {
1760
1775
  if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
1761
1776
  const dragged = draggedRef.current?.event;
@@ -1764,7 +1779,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1764
1779
  event: dragged,
1765
1780
  mode,
1766
1781
  isAllDay: false,
1767
- boxHeight: Math.max(drag.spillHours * hourHeight, 14),
1782
+ boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
1768
1783
  continuesBefore: true,
1769
1784
  continuesAfter: false,
1770
1785
  ampm,
@@ -2078,7 +2093,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2078
2093
  const nowTop = (nowHours - windowStart) * hourHeight;
2079
2094
  const bands = bandsByDay[dayIndex];
2080
2095
  const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
2081
- const spill = spillPreviewFor(dayIndex);
2096
+ const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
2097
+ const moveSegment = multiDayMove ? (0, _super_calendar_core.layoutDayEvents)([multiDayMove], day)[0] : void 0;
2082
2098
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2083
2099
  "data-date": day.toISOString(),
2084
2100
  onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
@@ -2150,12 +2166,13 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2150
2166
  }),
2151
2167
  positioned.map((pe, idx) => {
2152
2168
  const key = `${dayIndex}:${idx}`;
2153
- const active = !paged && drag?.key === key ? drag : null;
2169
+ const active = !paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent) ? drag : null;
2170
+ const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
2154
2171
  const startHours = active ? active.startHours : pe.startHours;
2155
2172
  const durationHours = active ? active.durationHours : pe.durationHours;
2156
2173
  if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
2157
2174
  const top = (startHours - windowStart) * hourHeight;
2158
- const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, 14);
2175
+ const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
2159
2176
  const widthPct = 100 / pe.columns;
2160
2177
  const onPress = () => onPressEvent?.(pe.event);
2161
2178
  const args = {
@@ -2196,17 +2213,18 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2196
2213
  },
2197
2214
  onPointerDown: canMove ? (e) => beginDrag(e, pe, key, "move", dayIndex, onPress) : void 0,
2198
2215
  onClick: canMove ? void 0 : onPress,
2199
- ...dataState({ "data-dragging": !!active }),
2216
+ ...dataState({ "data-dragging": !!active && !hiddenForMove }),
2200
2217
  ...slot("event", { base: {
2201
2218
  position: "absolute",
2202
2219
  top,
2203
2220
  height: boxHeight,
2204
- left: `calc(${pe.column * widthPct}% + 1px)`,
2205
- width: `calc(${widthPct}% - 2px)`,
2221
+ left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
2222
+ width: `calc(${widthPct}% - ${eventGap * 2}px)`,
2206
2223
  cursor: canMove ? "grab" : "pointer",
2207
2224
  touchAction: canMove ? "none" : "auto",
2208
2225
  zIndex: active ? 3 : 1,
2209
2226
  opacity: active ? .85 : 1,
2227
+ visibility: hiddenForMove ? "hidden" : void 0,
2210
2228
  ...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
2211
2229
  } }),
2212
2230
  children: [
@@ -2248,14 +2266,45 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2248
2266
  ]
2249
2267
  }, idx);
2250
2268
  }),
2269
+ moveSegment ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2270
+ "aria-hidden": true,
2271
+ ...dataState({ "data-dragging": true }),
2272
+ ...slot("event", { base: {
2273
+ position: "absolute",
2274
+ top: (moveSegment.startHours - windowStart) * hourHeight,
2275
+ left: eventGap,
2276
+ right: eventGap,
2277
+ height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2278
+ pointerEvents: "none",
2279
+ zIndex: 3,
2280
+ opacity: .85
2281
+ } }),
2282
+ children: (() => {
2283
+ const args = {
2284
+ event: moveSegment.event,
2285
+ mode,
2286
+ isAllDay: false,
2287
+ boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2288
+ continuesBefore: moveSegment.continuesBefore,
2289
+ continuesAfter: moveSegment.continuesAfter,
2290
+ ampm,
2291
+ onPress: () => {}
2292
+ };
2293
+ return Renderer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Renderer, { ...args }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultDomEvent, {
2294
+ ...args,
2295
+ theme,
2296
+ boxProps: slot("eventBox")
2297
+ });
2298
+ })()
2299
+ }) : null,
2251
2300
  spill ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2252
2301
  "aria-hidden": true,
2253
2302
  ...dataState({ "data-dragging": true }),
2254
2303
  ...slot("event", { base: {
2255
2304
  position: "absolute",
2256
2305
  top: -windowStart * hourHeight,
2257
- left: 1,
2258
- right: 1,
2306
+ left: eventGap,
2307
+ right: eventGap,
2259
2308
  height: spill.boxHeight,
2260
2309
  pointerEvents: "none",
2261
2310
  zIndex: 3,
@@ -2295,8 +2344,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2295
2344
  ...slot("createGhost", {
2296
2345
  base: {
2297
2346
  position: "absolute",
2298
- left: 1,
2299
- right: 1,
2347
+ left: eventGap,
2348
+ right: eventGap,
2300
2349
  top: ghost.topPx,
2301
2350
  height: Math.max(ghost.heightPx, 2),
2302
2351
  opacity: .7,
@@ -2377,7 +2426,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
2377
2426
  * <Calendar mode="week" date={new Date()} events={events} />
2378
2427
  * ```
2379
2428
  */
2380
- function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
2429
+ function Calendar({ 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, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
2381
2430
  const displayEvents = (0, react.useMemo)(() => {
2382
2431
  let out = events ?? EMPTY_EVENTS;
2383
2432
  if (out.some((e) => e.recurrence)) {
@@ -2502,6 +2551,8 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2502
2551
  styles,
2503
2552
  ampm,
2504
2553
  hourHeight,
2554
+ minEventHeight,
2555
+ eventGap,
2505
2556
  scrollOffsetMinutes,
2506
2557
  timeslots,
2507
2558
  minHour,
package/dist/index.mjs CHANGED
@@ -1278,6 +1278,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
1278
1278
  //#region src/TimeGrid.tsx
1279
1279
  const GUTTER_WIDTH$1 = 56;
1280
1280
  const HOURS_PER_DAY = 24;
1281
+ const DEFAULT_MIN_EVENT_HEIGHT = 14;
1282
+ const DEFAULT_EVENT_GAP = 1;
1281
1283
  const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
1282
1284
  const EDGE_ZONE = 32;
1283
1285
  const EDGE_DWELL_MS = 600;
@@ -1375,7 +1377,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
1375
1377
  * <TimeGrid mode="week" date={new Date()} events={events} />
1376
1378
  * ```
1377
1379
  */
1378
- function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
1380
+ function TimeGrid({ 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, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
1379
1381
  const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
1380
1382
  const slot = createSlots({
1381
1383
  classNames,
@@ -1623,7 +1625,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1623
1625
  const segmentStart = addMinutes(base, Math.round(d.startHours * 60));
1624
1626
  const segmentEnd = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
1625
1627
  const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
1626
- const endShift = d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
1628
+ const endShift = d.kind === "move" ? startShift : d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
1627
1629
  const start = new Date(held.event.start.getTime() + startShift);
1628
1630
  const end = new Date(held.event.end.getTime() + endShift);
1629
1631
  if (end > start) onDragEventRef.current?.(held.event, start, end);
@@ -1755,6 +1757,19 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1755
1757
  setCreateBox(null);
1756
1758
  };
1757
1759
  const positionedByDay = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
1760
+ const moveOrigin = dragOrigin.current;
1761
+ const heldEvent = draggedRef.current?.event;
1762
+ 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);
1763
+ const multiDayMove = !paged && drag?.kind === "move" && (drag.continuesBefore || drag.continuesAfter) && moveOrigin && movingEvent ? (() => {
1764
+ const target = days[moveOrigin.dayIndex + drag.dayDelta];
1765
+ const shift = addMinutes(startOfDay(target), Math.round(drag.startHours * 60)).getTime() - moveOrigin.segmentStart.getTime();
1766
+ return {
1767
+ ...movingEvent,
1768
+ start: new Date(movingEvent.start.getTime() + shift),
1769
+ end: new Date(movingEvent.end.getTime() + shift),
1770
+ allDay: false
1771
+ };
1772
+ })() : null;
1758
1773
  const spillPreviewFor = (dayIndex) => {
1759
1774
  if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
1760
1775
  const dragged = draggedRef.current?.event;
@@ -1763,7 +1778,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1763
1778
  event: dragged,
1764
1779
  mode,
1765
1780
  isAllDay: false,
1766
- boxHeight: Math.max(drag.spillHours * hourHeight, 14),
1781
+ boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
1767
1782
  continuesBefore: true,
1768
1783
  continuesAfter: false,
1769
1784
  ampm,
@@ -2077,7 +2092,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2077
2092
  const nowTop = (nowHours - windowStart) * hourHeight;
2078
2093
  const bands = bandsByDay[dayIndex];
2079
2094
  const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
2080
- const spill = spillPreviewFor(dayIndex);
2095
+ const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
2096
+ const moveSegment = multiDayMove ? layoutDayEvents$1([multiDayMove], day)[0] : void 0;
2081
2097
  return /* @__PURE__ */ jsxs("div", {
2082
2098
  "data-date": day.toISOString(),
2083
2099
  onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
@@ -2149,12 +2165,13 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2149
2165
  }),
2150
2166
  positioned.map((pe, idx) => {
2151
2167
  const key = `${dayIndex}:${idx}`;
2152
- const active = !paged && drag?.key === key ? drag : null;
2168
+ const active = !paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent) ? drag : null;
2169
+ const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
2153
2170
  const startHours = active ? active.startHours : pe.startHours;
2154
2171
  const durationHours = active ? active.durationHours : pe.durationHours;
2155
2172
  if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
2156
2173
  const top = (startHours - windowStart) * hourHeight;
2157
- const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, 14);
2174
+ const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
2158
2175
  const widthPct = 100 / pe.columns;
2159
2176
  const onPress = () => onPressEvent?.(pe.event);
2160
2177
  const args = {
@@ -2195,17 +2212,18 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2195
2212
  },
2196
2213
  onPointerDown: canMove ? (e) => beginDrag(e, pe, key, "move", dayIndex, onPress) : void 0,
2197
2214
  onClick: canMove ? void 0 : onPress,
2198
- ...dataState({ "data-dragging": !!active }),
2215
+ ...dataState({ "data-dragging": !!active && !hiddenForMove }),
2199
2216
  ...slot("event", { base: {
2200
2217
  position: "absolute",
2201
2218
  top,
2202
2219
  height: boxHeight,
2203
- left: `calc(${pe.column * widthPct}% + 1px)`,
2204
- width: `calc(${widthPct}% - 2px)`,
2220
+ left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
2221
+ width: `calc(${widthPct}% - ${eventGap * 2}px)`,
2205
2222
  cursor: canMove ? "grab" : "pointer",
2206
2223
  touchAction: canMove ? "none" : "auto",
2207
2224
  zIndex: active ? 3 : 1,
2208
2225
  opacity: active ? .85 : 1,
2226
+ visibility: hiddenForMove ? "hidden" : void 0,
2209
2227
  ...active && active.dayOffsetPx !== 0 ? { transform: `translateX(${active.dayOffsetPx}px)` } : null
2210
2228
  } }),
2211
2229
  children: [
@@ -2247,14 +2265,45 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2247
2265
  ]
2248
2266
  }, idx);
2249
2267
  }),
2268
+ moveSegment ? /* @__PURE__ */ jsx("div", {
2269
+ "aria-hidden": true,
2270
+ ...dataState({ "data-dragging": true }),
2271
+ ...slot("event", { base: {
2272
+ position: "absolute",
2273
+ top: (moveSegment.startHours - windowStart) * hourHeight,
2274
+ left: eventGap,
2275
+ right: eventGap,
2276
+ height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2277
+ pointerEvents: "none",
2278
+ zIndex: 3,
2279
+ opacity: .85
2280
+ } }),
2281
+ children: (() => {
2282
+ const args = {
2283
+ event: moveSegment.event,
2284
+ mode,
2285
+ isAllDay: false,
2286
+ boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2287
+ continuesBefore: moveSegment.continuesBefore,
2288
+ continuesAfter: moveSegment.continuesAfter,
2289
+ ampm,
2290
+ onPress: () => {}
2291
+ };
2292
+ return Renderer ? /* @__PURE__ */ jsx(Renderer, { ...args }) : /* @__PURE__ */ jsx(DefaultDomEvent, {
2293
+ ...args,
2294
+ theme,
2295
+ boxProps: slot("eventBox")
2296
+ });
2297
+ })()
2298
+ }) : null,
2250
2299
  spill ? /* @__PURE__ */ jsx("div", {
2251
2300
  "aria-hidden": true,
2252
2301
  ...dataState({ "data-dragging": true }),
2253
2302
  ...slot("event", { base: {
2254
2303
  position: "absolute",
2255
2304
  top: -windowStart * hourHeight,
2256
- left: 1,
2257
- right: 1,
2305
+ left: eventGap,
2306
+ right: eventGap,
2258
2307
  height: spill.boxHeight,
2259
2308
  pointerEvents: "none",
2260
2309
  zIndex: 3,
@@ -2294,8 +2343,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2294
2343
  ...slot("createGhost", {
2295
2344
  base: {
2296
2345
  position: "absolute",
2297
- left: 1,
2298
- right: 1,
2346
+ left: eventGap,
2347
+ right: eventGap,
2299
2348
  top: ghost.topPx,
2300
2349
  height: Math.max(ghost.heightPx, 2),
2301
2350
  opacity: .7,
@@ -2376,7 +2425,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
2376
2425
  * <Calendar mode="week" date={new Date()} events={events} />
2377
2426
  * ```
2378
2427
  */
2379
- function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
2428
+ function Calendar({ 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, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
2380
2429
  const displayEvents = useMemo(() => {
2381
2430
  let out = events ?? EMPTY_EVENTS;
2382
2431
  if (out.some((e) => e.recurrence)) {
@@ -2501,6 +2550,8 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2501
2550
  styles,
2502
2551
  ampm,
2503
2552
  hourHeight,
2553
+ minEventHeight,
2554
+ eventGap,
2504
2555
  scrollOffsetMinutes,
2505
2556
  timeslots,
2506
2557
  minHour,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/dom",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "description": "Virtualized month / week / day calendar and date picker for react-dom. No React Native, no react-native-web.",
5
5
  "keywords": [
6
6
  "calendar",
@@ -48,7 +48,7 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@super-calendar/core": "2.9.0"
51
+ "@super-calendar/core": "2.10.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@legendapp/list": ">=3",
package/src/Calendar.tsx CHANGED
@@ -55,7 +55,13 @@ export interface CalendarProps<T = unknown>
55
55
  * a day-grouped agenda list, and the others a time grid.
56
56
  */
57
57
  mode?: CalendarMode;
58
- /** Controlled anchor date. Change it (e.g. from your own header) to navigate. */
58
+ /**
59
+ * Controlled anchor date, read in the device's local time zone; change it
60
+ * (e.g. from your own header) to navigate. Construct it as a local date
61
+ * (`new Date(2026, 7, 24)`), not a UTC instant:
62
+ * `new Date("2026-08-24T00:00:00Z")` is still Aug 23 on devices west of UTC
63
+ * and anchors the previous week.
64
+ */
59
65
  date: Date;
60
66
  /**
61
67
  * Fires with the next/previous period's date when the user pages the focused
@@ -109,6 +115,17 @@ export interface CalendarProps<T = unknown>
109
115
  ampm?: boolean;
110
116
  /** Initial pixels per hour. */
111
117
  hourHeight?: number;
118
+ /**
119
+ * Minimum pixel height of a timed event box, so short events stay legible and
120
+ * clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
121
+ * Default 14; pass 0 to size every box strictly by its duration.
122
+ */
123
+ minEventHeight?: number;
124
+ /**
125
+ * Inset in pixels between a timed event box and its column edges (each side).
126
+ * Default 1; pass 0 to let events fill their column.
127
+ */
128
+ eventGap?: number;
112
129
  /** Initial scroll position, in minutes from midnight. */
113
130
  scrollOffsetMinutes?: number;
114
131
  /** Sub-divisions per hour for the grid lines. */
@@ -304,6 +321,8 @@ export function Calendar<T = unknown>({
304
321
  // time grid
305
322
  ampm,
306
323
  hourHeight,
324
+ minEventHeight,
325
+ eventGap,
307
326
  scrollOffsetMinutes,
308
327
  timeslots,
309
328
  minHour,
@@ -487,6 +506,8 @@ export function Calendar<T = unknown>({
487
506
  styles={styles}
488
507
  ampm={ampm}
489
508
  hourHeight={hourHeight}
509
+ minEventHeight={minEventHeight}
510
+ eventGap={eventGap}
490
511
  scrollOffsetMinutes={scrollOffsetMinutes}
491
512
  timeslots={timeslots}
492
513
  minHour={minHour}
package/src/TimeGrid.tsx CHANGED
@@ -80,6 +80,12 @@ export type TimeGridSlot =
80
80
 
81
81
  const GUTTER_WIDTH = 56;
82
82
  const HOURS_PER_DAY = 24;
83
+ // Floor for a timed event box's height, so a very short event still shows a
84
+ // sliver of its chip. Overridable per grid via `minEventHeight`.
85
+ const DEFAULT_MIN_EVENT_HEIGHT = 14;
86
+ // Horizontal inset of each event box from its column edges. Overridable per grid
87
+ // via `eventGap`.
88
+ const DEFAULT_EVENT_GAP = 1;
83
89
  const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
84
90
 
85
91
  // Edge auto-advance: how close to the day-columns edge (px) counts as "at the
@@ -151,6 +157,17 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
151
157
  minHourHeight?: number;
152
158
  /** Upper bound for pixels per hour when zooming. */
153
159
  maxHourHeight?: number;
160
+ /**
161
+ * Minimum pixel height of a timed event box, so short events stay legible and
162
+ * clickable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
163
+ * 14; pass 0 to size every box strictly by its duration.
164
+ */
165
+ minEventHeight?: number;
166
+ /**
167
+ * Inset in pixels between a timed event box and its column edges (each side).
168
+ * Default 1; pass 0 to let events fill their column.
169
+ */
170
+ eventGap?: number;
154
171
  /** Snap dragged events to this many minutes (default 15). */
155
172
  dragStepMinutes?: number;
156
173
  /** Render event time ranges in 12-hour AM/PM (default false, 24h). */
@@ -392,6 +409,8 @@ export function TimeGrid<T = unknown>({
392
409
  zoomable = true,
393
410
  minHourHeight = 24,
394
411
  maxHourHeight = 160,
412
+ minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
413
+ eventGap = DEFAULT_EVENT_GAP,
395
414
  dragStepMinutes = 15,
396
415
  ampm = false,
397
416
  timeslots = 1,
@@ -790,7 +809,11 @@ export function TimeGrid<T = unknown>({
790
809
  const startShift =
791
810
  d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
792
811
  const endShift =
793
- d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
812
+ d.kind === "move"
813
+ ? startShift
814
+ : d.kind === "resize-start"
815
+ ? 0
816
+ : segmentEnd.getTime() - origin.segmentEnd.getTime();
794
817
  const start = new Date(held.event.start.getTime() + startShift);
795
818
  const end = new Date(held.event.end.getTime() + endShift);
796
819
  if (end > start) onDragEventRef.current?.(held.event, start, end);
@@ -949,6 +972,39 @@ export function TimeGrid<T = unknown>({
949
972
  [days, events],
950
973
  );
951
974
 
975
+ // Keep the original boxes mounted for pointer capture, but replace every
976
+ // segment of a moving multi-day event with the same shifted range.
977
+ const moveOrigin = dragOrigin.current;
978
+ const heldEvent = draggedRef.current?.event;
979
+ const movingEvent =
980
+ heldEvent &&
981
+ (events.includes(heldEvent)
982
+ ? heldEvent
983
+ : (events.find(
984
+ (event) =>
985
+ event.start.getTime() === heldEvent.start.getTime() &&
986
+ event.end.getTime() === heldEvent.end.getTime() &&
987
+ event.title === heldEvent.title,
988
+ ) ?? heldEvent));
989
+ const multiDayMove =
990
+ !paged &&
991
+ drag?.kind === "move" &&
992
+ (drag.continuesBefore || drag.continuesAfter) &&
993
+ moveOrigin &&
994
+ movingEvent
995
+ ? (() => {
996
+ const target = days[moveOrigin.dayIndex + drag.dayDelta];
997
+ const segmentStart = addMinutes(startOfDay(target), Math.round(drag.startHours * 60));
998
+ const shift = segmentStart.getTime() - moveOrigin.segmentStart.getTime();
999
+ return {
1000
+ ...movingEvent,
1001
+ start: new Date(movingEvent.start.getTime() + shift),
1002
+ end: new Date(movingEvent.end.getTime() + shift),
1003
+ allDay: false,
1004
+ };
1005
+ })()
1006
+ : null;
1007
+
952
1008
  // The tail of an in-progress move that runs past midnight, shown on `dayIndex`
953
1009
  // so the drop is visible on both days at once. `drag` and `draggedRef` are set
954
1010
  // together in `beginDrag` and cleared together in `finishDrag`, so the guard on
@@ -961,7 +1017,7 @@ export function TimeGrid<T = unknown>({
961
1017
  event: dragged,
962
1018
  mode,
963
1019
  isAllDay: false,
964
- boxHeight: Math.max(drag.spillHours * hourHeight, 14),
1020
+ boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
965
1021
  continuesBefore: true,
966
1022
  continuesAfter: false,
967
1023
  ampm,
@@ -1341,7 +1397,10 @@ export function TimeGrid<T = unknown>({
1341
1397
  // The tail of a move that runs past midnight, previewed at the top of
1342
1398
  // this column. The dragged event is looked up from its `drag.key`
1343
1399
  // ("<originColumn>:<index>"), so no extra state has to track it.
1344
- const spill = spillPreviewFor(dayIndex);
1400
+ const spill = multiDayMove ? null : spillPreviewFor(dayIndex);
1401
+ const moveSegment = multiDayMove
1402
+ ? layoutDayEvents<T>([multiDayMove], day)[0]
1403
+ : undefined;
1345
1404
  return (
1346
1405
  <div
1347
1406
  key={day.toISOString()}
@@ -1423,7 +1482,11 @@ export function TimeGrid<T = unknown>({
1423
1482
  // Not while paged: after a page change the origin box is gone and
1424
1483
  // the ghost stands in, so a same-slot event on the new page (e.g. a
1425
1484
  // recurring one) must not also render lifted.
1426
- const active = !paged && drag?.key === key ? drag : null;
1485
+ const active =
1486
+ !paged && drag?.key === key && (!multiDayMove || pe.event === movingEvent)
1487
+ ? drag
1488
+ : null;
1489
+ const hiddenForMove = !!multiDayMove && pe.event === movingEvent;
1427
1490
  const startHours = active ? active.startHours : pe.startHours;
1428
1491
  const durationHours = active ? active.durationHours : pe.durationHours;
1429
1492
  // Drop events that fall entirely outside the visible window; those
@@ -1440,7 +1503,7 @@ export function TimeGrid<T = unknown>({
1440
1503
  // them to the day, so the height doesn't jump on commit.
1441
1504
  const boxHeight = Math.max(
1442
1505
  Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight,
1443
- 14,
1506
+ minEventHeight,
1444
1507
  );
1445
1508
  const widthPct = 100 / pe.columns;
1446
1509
  const onPress = () => onPressEvent?.(pe.event);
@@ -1498,7 +1561,7 @@ export function TimeGrid<T = unknown>({
1498
1561
  : undefined
1499
1562
  }
1500
1563
  onClick={canMove ? undefined : onPress}
1501
- {...dataState({ "data-dragging": !!active })}
1564
+ {...dataState({ "data-dragging": !!active && !hiddenForMove })}
1502
1565
  {...slot("event", {
1503
1566
  base: {
1504
1567
  position: "absolute",
@@ -1508,12 +1571,13 @@ export function TimeGrid<T = unknown>({
1508
1571
  // is the renderer's concern: the built-in one clamps, and a
1509
1572
  // custom renderer should adapt to the `boxHeight` it's given.
1510
1573
  height: boxHeight,
1511
- left: `calc(${pe.column * widthPct}% + 1px)`,
1512
- width: `calc(${widthPct}% - 2px)`,
1574
+ left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
1575
+ width: `calc(${widthPct}% - ${eventGap * 2}px)`,
1513
1576
  cursor: canMove ? "grab" : "pointer",
1514
1577
  touchAction: canMove ? "none" : "auto",
1515
1578
  zIndex: active ? 3 : 1,
1516
1579
  opacity: active ? 0.85 : 1,
1580
+ visibility: hiddenForMove ? "hidden" : undefined,
1517
1581
  // Snap the dragged box over the target day column so the
1518
1582
  // drop location is visible before release.
1519
1583
  ...(active && active.dayOffsetPx !== 0
@@ -1569,6 +1633,42 @@ export function TimeGrid<T = unknown>({
1569
1633
  </div>
1570
1634
  );
1571
1635
  })}
1636
+ {moveSegment ? (
1637
+ <div
1638
+ aria-hidden
1639
+ {...dataState({ "data-dragging": true })}
1640
+ {...slot("event", {
1641
+ base: {
1642
+ position: "absolute",
1643
+ top: (moveSegment.startHours - windowStart) * hourHeight,
1644
+ left: eventGap,
1645
+ right: eventGap,
1646
+ height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
1647
+ pointerEvents: "none",
1648
+ zIndex: 3,
1649
+ opacity: 0.85,
1650
+ },
1651
+ })}
1652
+ >
1653
+ {(() => {
1654
+ const args: DomRenderEventArgs<T> = {
1655
+ event: moveSegment.event,
1656
+ mode,
1657
+ isAllDay: false,
1658
+ boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
1659
+ continuesBefore: moveSegment.continuesBefore,
1660
+ continuesAfter: moveSegment.continuesAfter,
1661
+ ampm,
1662
+ onPress: () => {},
1663
+ };
1664
+ return Renderer ? (
1665
+ <Renderer {...args} />
1666
+ ) : (
1667
+ <DefaultDomEvent {...args} theme={theme} boxProps={slot("eventBox")} />
1668
+ );
1669
+ })()}
1670
+ </div>
1671
+ ) : null}
1572
1672
  {spill ? (
1573
1673
  <div
1574
1674
  aria-hidden
@@ -1581,8 +1681,8 @@ export function TimeGrid<T = unknown>({
1581
1681
  // the preview is scrolled out of view, exactly like the
1582
1682
  // continuation the drop will commit.
1583
1683
  top: -windowStart * hourHeight,
1584
- left: 1,
1585
- right: 1,
1684
+ left: eventGap,
1685
+ right: eventGap,
1586
1686
  height: spill.boxHeight,
1587
1687
  pointerEvents: "none",
1588
1688
  zIndex: 3,
@@ -1631,8 +1731,8 @@ export function TimeGrid<T = unknown>({
1631
1731
  {...slot("createGhost", {
1632
1732
  base: {
1633
1733
  position: "absolute",
1634
- left: 1,
1635
- right: 1,
1734
+ left: eventGap,
1735
+ right: eventGap,
1636
1736
  top: ghost.topPx,
1637
1737
  height: Math.max(ghost.heightPx, 2),
1638
1738
  opacity: 0.7,