@super-calendar/dom 2.9.1 → 2.11.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/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). */
@@ -398,6 +409,15 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
398
409
  * band stays non-interactive and hidden from assistive tech.
399
410
  */
400
411
  renderBusinessHours?: (band: BusinessHoursBand$1) => ReactNode;
412
+ /**
413
+ * A component that draws a `display: "background"` event's band in place of
414
+ * the themed shade. Rendered like `renderEvent`, it receives the event, the
415
+ * mode, `continuesBefore` / `continuesAfter` for a multi-day event, and
416
+ * `onPress`, which fires `onPressEvent`. The band then takes pointer events and
417
+ * is no longer hidden from assistive tech; cell clicks and drag-to-create are
418
+ * unreachable underneath it. Without it the band stays a shaded, inert range.
419
+ */
420
+ renderBackgroundEvent?: DomRenderEvent<T>;
401
421
  /** Show the current-time indicator on today's column (default true). */
402
422
  showNowIndicator?: boolean;
403
423
  /** Fixed "now" instant for the indicator (doesn't tick). Defaults to the device clock. */
@@ -406,6 +426,8 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
406
426
  timeZone?: string;
407
427
  /** Show the all-day lane above the grid (default true). */
408
428
  showAllDayEventCell?: boolean;
429
+ /** Show the "all-day" text beside the lane (default false). */
430
+ showAllDayLabel?: boolean;
409
431
  /** Tint Saturday/Sunday columns with the weekend background (default true). Set
410
432
  * false to treat weekends like any other day. */
411
433
  highlightWeekends?: boolean;
@@ -479,7 +501,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
479
501
  * <TimeGrid mode="week" date={new Date()} events={events} />
480
502
  * ```
481
503
  */
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;
504
+ 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, renderBackgroundEvent, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, showAllDayLabel, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
483
505
  //#endregion
484
506
  //#region src/Calendar.d.ts
485
507
  /**
@@ -552,6 +574,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
552
574
  ampm?: boolean;
553
575
  /** Initial pixels per hour. */
554
576
  hourHeight?: number;
577
+ /**
578
+ * Minimum pixel height of a timed event box, so short events stay legible and
579
+ * clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
580
+ * Default 14; pass 0 to size every box strictly by its duration.
581
+ */
582
+ minEventHeight?: number;
583
+ /**
584
+ * Inset in pixels between a timed event box and its column edges (each side).
585
+ * Default 1; pass 0 to let events fill their column.
586
+ */
587
+ eventGap?: number;
555
588
  /** Initial scroll position, in minutes from midnight. */
556
589
  scrollOffsetMinutes?: number;
557
590
  /** Sub-divisions per hour for the grid lines. */
@@ -575,10 +608,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
575
608
  * band stays non-interactive and hidden from assistive tech.
576
609
  */
577
610
  renderBusinessHours?: (band: BusinessHoursBand$1) => ReactNode;
611
+ /**
612
+ * A component that draws a `display: "background"` event's band in place of
613
+ * the themed shade; see `TimeGrid`'s prop of the same name.
614
+ */
615
+ renderBackgroundEvent?: DomRenderEvent<T>;
578
616
  /** Show the current-time indicator (default true). */
579
617
  showNowIndicator?: boolean;
580
618
  /** Show the all-day lane (default true). */
581
619
  showAllDayEventCell?: boolean;
620
+ /** Show the "all-day" text beside the lane (default false). */
621
+ showAllDayLabel?: boolean;
582
622
  /** Tint weekend columns (default true). Set false to treat weekends normally. */
583
623
  highlightWeekends?: boolean;
584
624
  /** Allow moving events by default (per-event `startEditable` overrides). Default true. */
@@ -673,7 +713,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
673
713
  * <Calendar mode="week" date={new Date()} events={events} />
674
714
  * ```
675
715
  */
676
- 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;
716
+ 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, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, 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;
677
717
  //#endregion
678
718
  //#region src/MonthList.d.ts
679
719
  /**
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). */
@@ -398,6 +409,15 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
398
409
  * band stays non-interactive and hidden from assistive tech.
399
410
  */
400
411
  renderBusinessHours?: (band: BusinessHoursBand$1) => ReactNode;
412
+ /**
413
+ * A component that draws a `display: "background"` event's band in place of
414
+ * the themed shade. Rendered like `renderEvent`, it receives the event, the
415
+ * mode, `continuesBefore` / `continuesAfter` for a multi-day event, and
416
+ * `onPress`, which fires `onPressEvent`. The band then takes pointer events and
417
+ * is no longer hidden from assistive tech; cell clicks and drag-to-create are
418
+ * unreachable underneath it. Without it the band stays a shaded, inert range.
419
+ */
420
+ renderBackgroundEvent?: DomRenderEvent<T>;
401
421
  /** Show the current-time indicator on today's column (default true). */
402
422
  showNowIndicator?: boolean;
403
423
  /** Fixed "now" instant for the indicator (doesn't tick). Defaults to the device clock. */
@@ -406,6 +426,8 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
406
426
  timeZone?: string;
407
427
  /** Show the all-day lane above the grid (default true). */
408
428
  showAllDayEventCell?: boolean;
429
+ /** Show the "all-day" text beside the lane (default false). */
430
+ showAllDayLabel?: boolean;
409
431
  /** Tint Saturday/Sunday columns with the weekend background (default true). Set
410
432
  * false to treat weekends like any other day. */
411
433
  highlightWeekends?: boolean;
@@ -479,7 +501,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
479
501
  * <TimeGrid mode="week" date={new Date()} events={events} />
480
502
  * ```
481
503
  */
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;
504
+ 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, renderBackgroundEvent, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, showAllDayLabel, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
483
505
  //#endregion
484
506
  //#region src/Calendar.d.ts
485
507
  /**
@@ -552,6 +574,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
552
574
  ampm?: boolean;
553
575
  /** Initial pixels per hour. */
554
576
  hourHeight?: number;
577
+ /**
578
+ * Minimum pixel height of a timed event box, so short events stay legible and
579
+ * clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
580
+ * Default 14; pass 0 to size every box strictly by its duration.
581
+ */
582
+ minEventHeight?: number;
583
+ /**
584
+ * Inset in pixels between a timed event box and its column edges (each side).
585
+ * Default 1; pass 0 to let events fill their column.
586
+ */
587
+ eventGap?: number;
555
588
  /** Initial scroll position, in minutes from midnight. */
556
589
  scrollOffsetMinutes?: number;
557
590
  /** Sub-divisions per hour for the grid lines. */
@@ -575,10 +608,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
575
608
  * band stays non-interactive and hidden from assistive tech.
576
609
  */
577
610
  renderBusinessHours?: (band: BusinessHoursBand$1) => ReactNode;
611
+ /**
612
+ * A component that draws a `display: "background"` event's band in place of
613
+ * the themed shade; see `TimeGrid`'s prop of the same name.
614
+ */
615
+ renderBackgroundEvent?: DomRenderEvent<T>;
578
616
  /** Show the current-time indicator (default true). */
579
617
  showNowIndicator?: boolean;
580
618
  /** Show the all-day lane (default true). */
581
619
  showAllDayEventCell?: boolean;
620
+ /** Show the "all-day" text beside the lane (default false). */
621
+ showAllDayLabel?: boolean;
582
622
  /** Tint weekend columns (default true). Set false to treat weekends normally. */
583
623
  highlightWeekends?: boolean;
584
624
  /** Allow moving events by default (per-event `startEditable` overrides). Default true. */
@@ -673,7 +713,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
673
713
  * <Calendar mode="week" date={new Date()} events={events} />
674
714
  * ```
675
715
  */
676
- 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;
716
+ 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, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, 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;
677
717
  //#endregion
678
718
  //#region src/MonthList.d.ts
679
719
  /**
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, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, 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,
@@ -1390,6 +1392,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1390
1392
  const windowEnd = Math.max(windowStart + 1, Math.min(maxHour, 24));
1391
1393
  const windowHours = windowEnd - windowStart;
1392
1394
  const gutterWidth = hideHours ? 0 : GUTTER_WIDTH$1;
1395
+ const RenderBackground = renderBackgroundEvent;
1393
1396
  const visibleHours = (0, react.useMemo)(() => Array.from({ length: windowHours }, (_, i) => windowStart + i), [windowStart, windowHours]);
1394
1397
  const now = (0, _super_calendar_core.useNow)(showNowIndicator, {
1395
1398
  now: nowProp,
@@ -1777,7 +1780,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1777
1780
  event: dragged,
1778
1781
  mode,
1779
1782
  isAllDay: false,
1780
- boxHeight: Math.max(drag.spillHours * hourHeight, 14),
1783
+ boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
1781
1784
  continuesBefore: true,
1782
1785
  continuesAfter: false,
1783
1786
  ampm,
@@ -1850,11 +1853,22 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1850
1853
  windowStart,
1851
1854
  windowEnd
1852
1855
  ]);
1853
- const backgroundByDay = (0, react.useMemo)(() => days.map((day) => (0, _super_calendar_core.backgroundBandsForDay)(events, day).map((b) => ({
1854
- ...b,
1855
- startHours: Math.max(b.startHours, windowStart),
1856
- endHours: Math.min(b.endHours, windowEnd)
1857
- })).filter((b) => b.endHours > b.startHours)), [
1856
+ const backgroundByDay = (0, react.useMemo)(() => days.map((day) => {
1857
+ const seen = /* @__PURE__ */ new Map();
1858
+ return (0, _super_calendar_core.backgroundBandsForDay)(events, day).map((b) => ({
1859
+ ...b,
1860
+ startHours: Math.max(b.startHours, windowStart),
1861
+ endHours: Math.min(b.endHours, windowEnd)
1862
+ })).filter((b) => b.endHours > b.startHours).map((b) => {
1863
+ const base = `bg-${b.event.start.toISOString()}-${b.event.end.toISOString()}`;
1864
+ const nth = (seen.get(base) ?? 0) + 1;
1865
+ seen.set(base, nth);
1866
+ return {
1867
+ ...b,
1868
+ key: nth === 1 ? base : `${base}-${nth}`
1869
+ };
1870
+ });
1871
+ }), [
1858
1872
  days,
1859
1873
  events,
1860
1874
  windowStart,
@@ -1989,7 +2003,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1989
2003
  padding: "4px 6px 0 0"
1990
2004
  }
1991
2005
  }),
1992
- children: "all-day"
2006
+ children: showAllDayLabel ? "all-day" : null
1993
2007
  }), allDayByDay.map((list, i) => {
1994
2008
  const dayStart = (0, date_fns.startOfDay)(days[i]);
1995
2009
  const dayEnd = (0, date_fns.addDays)(dayStart, 1);
@@ -2134,22 +2148,46 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2134
2148
  end: b.end
2135
2149
  })
2136
2150
  }, b.start)),
2137
- backgroundByDay[dayIndex].map((b, bandIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2138
- "aria-hidden": true,
2139
- title: b.event.title,
2140
- ...slot("backgroundEvent", {
2141
- base: {
2142
- position: "absolute",
2143
- left: 0,
2144
- right: 0,
2145
- top: (b.startHours - windowStart) * hourHeight,
2146
- height: (b.endHours - b.startHours) * hourHeight,
2147
- pointerEvents: "none",
2148
- zIndex: 0
2149
- },
2150
- themed: { background: theme.backgroundEvent }
2151
- })
2152
- }, `bg-${bandIndex}`)),
2151
+ backgroundByDay[dayIndex].map((b) => {
2152
+ const { key } = b;
2153
+ const geometry = {
2154
+ position: "absolute",
2155
+ left: 0,
2156
+ right: 0,
2157
+ top: (b.startHours - windowStart) * hourHeight,
2158
+ height: (b.endHours - b.startHours) * hourHeight,
2159
+ zIndex: 0,
2160
+ overflow: "hidden"
2161
+ };
2162
+ if (!RenderBackground) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2163
+ "aria-hidden": true,
2164
+ title: b.event.title,
2165
+ ...slot("backgroundEvent", {
2166
+ base: {
2167
+ ...geometry,
2168
+ pointerEvents: "none"
2169
+ },
2170
+ themed: { background: theme.backgroundEvent }
2171
+ })
2172
+ }, key);
2173
+ const dayStart = (0, date_fns.startOfDay)(days[dayIndex]);
2174
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2175
+ ...slot("backgroundEvent", { base: {
2176
+ ...geometry,
2177
+ pointerEvents: "auto"
2178
+ } }),
2179
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderBackground, {
2180
+ event: b.event,
2181
+ mode,
2182
+ isAllDay: false,
2183
+ boxHeight: geometry.height,
2184
+ continuesBefore: b.event.start < dayStart,
2185
+ continuesAfter: b.event.end > (0, date_fns.addDays)(dayStart, 1),
2186
+ ampm,
2187
+ onPress: () => onPressEvent?.(b.event)
2188
+ })
2189
+ }, key);
2190
+ }),
2153
2191
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2154
2192
  "aria-hidden": true,
2155
2193
  ...slot("gridLines", {
@@ -2170,7 +2208,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2170
2208
  const durationHours = active ? active.durationHours : pe.durationHours;
2171
2209
  if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
2172
2210
  const top = (startHours - windowStart) * hourHeight;
2173
- const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, 14);
2211
+ const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
2174
2212
  const widthPct = 100 / pe.columns;
2175
2213
  const onPress = () => onPressEvent?.(pe.event);
2176
2214
  const args = {
@@ -2216,8 +2254,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2216
2254
  position: "absolute",
2217
2255
  top,
2218
2256
  height: boxHeight,
2219
- left: `calc(${pe.column * widthPct}% + 1px)`,
2220
- width: `calc(${widthPct}% - 2px)`,
2257
+ left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
2258
+ width: `calc(${widthPct}% - ${eventGap * 2}px)`,
2221
2259
  cursor: canMove ? "grab" : "pointer",
2222
2260
  touchAction: canMove ? "none" : "auto",
2223
2261
  zIndex: active ? 3 : 1,
@@ -2234,7 +2272,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2234
2272
  canResize && !pe.continuesBefore ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2235
2273
  onPointerDown: (e) => {
2236
2274
  e.stopPropagation();
2237
- beginDrag(e, pe, key, "resize-start", dayIndex);
2275
+ beginDrag(e, pe, key, "resize-start", dayIndex, canMove ? onPress : void 0);
2238
2276
  },
2239
2277
  style: {
2240
2278
  position: "absolute",
@@ -2249,7 +2287,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2249
2287
  canResize && !pe.continuesAfter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2250
2288
  onPointerDown: (e) => {
2251
2289
  e.stopPropagation();
2252
- beginDrag(e, pe, key, "resize", dayIndex);
2290
+ beginDrag(e, pe, key, "resize", dayIndex, canMove ? onPress : void 0);
2253
2291
  },
2254
2292
  style: {
2255
2293
  position: "absolute",
@@ -2270,9 +2308,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2270
2308
  ...slot("event", { base: {
2271
2309
  position: "absolute",
2272
2310
  top: (moveSegment.startHours - windowStart) * hourHeight,
2273
- left: 1,
2274
- right: 1,
2275
- height: Math.max(moveSegment.durationHours * hourHeight, 14),
2311
+ left: eventGap,
2312
+ right: eventGap,
2313
+ height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2276
2314
  pointerEvents: "none",
2277
2315
  zIndex: 3,
2278
2316
  opacity: .85
@@ -2282,7 +2320,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2282
2320
  event: moveSegment.event,
2283
2321
  mode,
2284
2322
  isAllDay: false,
2285
- boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
2323
+ boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2286
2324
  continuesBefore: moveSegment.continuesBefore,
2287
2325
  continuesAfter: moveSegment.continuesAfter,
2288
2326
  ampm,
@@ -2301,8 +2339,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2301
2339
  ...slot("event", { base: {
2302
2340
  position: "absolute",
2303
2341
  top: -windowStart * hourHeight,
2304
- left: 1,
2305
- right: 1,
2342
+ left: eventGap,
2343
+ right: eventGap,
2306
2344
  height: spill.boxHeight,
2307
2345
  pointerEvents: "none",
2308
2346
  zIndex: 3,
@@ -2342,8 +2380,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2342
2380
  ...slot("createGhost", {
2343
2381
  base: {
2344
2382
  position: "absolute",
2345
- left: 1,
2346
- right: 1,
2383
+ left: eventGap,
2384
+ right: eventGap,
2347
2385
  top: ghost.topPx,
2348
2386
  height: Math.max(ghost.heightPx, 2),
2349
2387
  opacity: .7,
@@ -2424,7 +2462,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
2424
2462
  * <Calendar mode="week" date={new Date()} events={events} />
2425
2463
  * ```
2426
2464
  */
2427
- 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 }) {
2465
+ 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, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, 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
2466
  const displayEvents = (0, react.useMemo)(() => {
2429
2467
  let out = events ?? EMPTY_EVENTS;
2430
2468
  if (out.some((e) => e.recurrence)) {
@@ -2549,6 +2587,8 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2549
2587
  styles,
2550
2588
  ampm,
2551
2589
  hourHeight,
2590
+ minEventHeight,
2591
+ eventGap,
2552
2592
  scrollOffsetMinutes,
2553
2593
  timeslots,
2554
2594
  minHour,
@@ -2558,8 +2598,10 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2558
2598
  weekNumberPrefix,
2559
2599
  businessHours,
2560
2600
  renderBusinessHours,
2601
+ renderBackgroundEvent,
2561
2602
  showNowIndicator,
2562
2603
  showAllDayEventCell,
2604
+ showAllDayLabel,
2563
2605
  highlightWeekends,
2564
2606
  eventStartEditable,
2565
2607
  eventDurationEditable,
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, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, 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,
@@ -1389,6 +1391,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1389
1391
  const windowEnd = Math.max(windowStart + 1, Math.min(maxHour, 24));
1390
1392
  const windowHours = windowEnd - windowStart;
1391
1393
  const gutterWidth = hideHours ? 0 : GUTTER_WIDTH$1;
1394
+ const RenderBackground = renderBackgroundEvent;
1392
1395
  const visibleHours = useMemo(() => Array.from({ length: windowHours }, (_, i) => windowStart + i), [windowStart, windowHours]);
1393
1396
  const now = useNow$1(showNowIndicator, {
1394
1397
  now: nowProp,
@@ -1776,7 +1779,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1776
1779
  event: dragged,
1777
1780
  mode,
1778
1781
  isAllDay: false,
1779
- boxHeight: Math.max(drag.spillHours * hourHeight, 14),
1782
+ boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
1780
1783
  continuesBefore: true,
1781
1784
  continuesAfter: false,
1782
1785
  ampm,
@@ -1849,11 +1852,22 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1849
1852
  windowStart,
1850
1853
  windowEnd
1851
1854
  ]);
1852
- const backgroundByDay = useMemo(() => days.map((day) => backgroundBandsForDay$1(events, day).map((b) => ({
1853
- ...b,
1854
- startHours: Math.max(b.startHours, windowStart),
1855
- endHours: Math.min(b.endHours, windowEnd)
1856
- })).filter((b) => b.endHours > b.startHours)), [
1855
+ const backgroundByDay = useMemo(() => days.map((day) => {
1856
+ const seen = /* @__PURE__ */ new Map();
1857
+ return backgroundBandsForDay$1(events, day).map((b) => ({
1858
+ ...b,
1859
+ startHours: Math.max(b.startHours, windowStart),
1860
+ endHours: Math.min(b.endHours, windowEnd)
1861
+ })).filter((b) => b.endHours > b.startHours).map((b) => {
1862
+ const base = `bg-${b.event.start.toISOString()}-${b.event.end.toISOString()}`;
1863
+ const nth = (seen.get(base) ?? 0) + 1;
1864
+ seen.set(base, nth);
1865
+ return {
1866
+ ...b,
1867
+ key: nth === 1 ? base : `${base}-${nth}`
1868
+ };
1869
+ });
1870
+ }), [
1857
1871
  days,
1858
1872
  events,
1859
1873
  windowStart,
@@ -1988,7 +2002,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
1988
2002
  padding: "4px 6px 0 0"
1989
2003
  }
1990
2004
  }),
1991
- children: "all-day"
2005
+ children: showAllDayLabel ? "all-day" : null
1992
2006
  }), allDayByDay.map((list, i) => {
1993
2007
  const dayStart = startOfDay(days[i]);
1994
2008
  const dayEnd = addDays(dayStart, 1);
@@ -2133,22 +2147,46 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2133
2147
  end: b.end
2134
2148
  })
2135
2149
  }, b.start)),
2136
- backgroundByDay[dayIndex].map((b, bandIndex) => /* @__PURE__ */ jsx("div", {
2137
- "aria-hidden": true,
2138
- title: b.event.title,
2139
- ...slot("backgroundEvent", {
2140
- base: {
2141
- position: "absolute",
2142
- left: 0,
2143
- right: 0,
2144
- top: (b.startHours - windowStart) * hourHeight,
2145
- height: (b.endHours - b.startHours) * hourHeight,
2146
- pointerEvents: "none",
2147
- zIndex: 0
2148
- },
2149
- themed: { background: theme.backgroundEvent }
2150
- })
2151
- }, `bg-${bandIndex}`)),
2150
+ backgroundByDay[dayIndex].map((b) => {
2151
+ const { key } = b;
2152
+ const geometry = {
2153
+ position: "absolute",
2154
+ left: 0,
2155
+ right: 0,
2156
+ top: (b.startHours - windowStart) * hourHeight,
2157
+ height: (b.endHours - b.startHours) * hourHeight,
2158
+ zIndex: 0,
2159
+ overflow: "hidden"
2160
+ };
2161
+ if (!RenderBackground) return /* @__PURE__ */ jsx("div", {
2162
+ "aria-hidden": true,
2163
+ title: b.event.title,
2164
+ ...slot("backgroundEvent", {
2165
+ base: {
2166
+ ...geometry,
2167
+ pointerEvents: "none"
2168
+ },
2169
+ themed: { background: theme.backgroundEvent }
2170
+ })
2171
+ }, key);
2172
+ const dayStart = startOfDay(days[dayIndex]);
2173
+ return /* @__PURE__ */ jsx("div", {
2174
+ ...slot("backgroundEvent", { base: {
2175
+ ...geometry,
2176
+ pointerEvents: "auto"
2177
+ } }),
2178
+ children: /* @__PURE__ */ jsx(RenderBackground, {
2179
+ event: b.event,
2180
+ mode,
2181
+ isAllDay: false,
2182
+ boxHeight: geometry.height,
2183
+ continuesBefore: b.event.start < dayStart,
2184
+ continuesAfter: b.event.end > addDays(dayStart, 1),
2185
+ ampm,
2186
+ onPress: () => onPressEvent?.(b.event)
2187
+ })
2188
+ }, key);
2189
+ }),
2152
2190
  /* @__PURE__ */ jsx("div", {
2153
2191
  "aria-hidden": true,
2154
2192
  ...slot("gridLines", {
@@ -2169,7 +2207,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2169
2207
  const durationHours = active ? active.durationHours : pe.durationHours;
2170
2208
  if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
2171
2209
  const top = (startHours - windowStart) * hourHeight;
2172
- const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, 14);
2210
+ const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
2173
2211
  const widthPct = 100 / pe.columns;
2174
2212
  const onPress = () => onPressEvent?.(pe.event);
2175
2213
  const args = {
@@ -2215,8 +2253,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2215
2253
  position: "absolute",
2216
2254
  top,
2217
2255
  height: boxHeight,
2218
- left: `calc(${pe.column * widthPct}% + 1px)`,
2219
- width: `calc(${widthPct}% - 2px)`,
2256
+ left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
2257
+ width: `calc(${widthPct}% - ${eventGap * 2}px)`,
2220
2258
  cursor: canMove ? "grab" : "pointer",
2221
2259
  touchAction: canMove ? "none" : "auto",
2222
2260
  zIndex: active ? 3 : 1,
@@ -2233,7 +2271,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2233
2271
  canResize && !pe.continuesBefore ? /* @__PURE__ */ jsx("div", {
2234
2272
  onPointerDown: (e) => {
2235
2273
  e.stopPropagation();
2236
- beginDrag(e, pe, key, "resize-start", dayIndex);
2274
+ beginDrag(e, pe, key, "resize-start", dayIndex, canMove ? onPress : void 0);
2237
2275
  },
2238
2276
  style: {
2239
2277
  position: "absolute",
@@ -2248,7 +2286,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2248
2286
  canResize && !pe.continuesAfter ? /* @__PURE__ */ jsx("div", {
2249
2287
  onPointerDown: (e) => {
2250
2288
  e.stopPropagation();
2251
- beginDrag(e, pe, key, "resize", dayIndex);
2289
+ beginDrag(e, pe, key, "resize", dayIndex, canMove ? onPress : void 0);
2252
2290
  },
2253
2291
  style: {
2254
2292
  position: "absolute",
@@ -2269,9 +2307,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2269
2307
  ...slot("event", { base: {
2270
2308
  position: "absolute",
2271
2309
  top: (moveSegment.startHours - windowStart) * hourHeight,
2272
- left: 1,
2273
- right: 1,
2274
- height: Math.max(moveSegment.durationHours * hourHeight, 14),
2310
+ left: eventGap,
2311
+ right: eventGap,
2312
+ height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2275
2313
  pointerEvents: "none",
2276
2314
  zIndex: 3,
2277
2315
  opacity: .85
@@ -2281,7 +2319,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2281
2319
  event: moveSegment.event,
2282
2320
  mode,
2283
2321
  isAllDay: false,
2284
- boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
2322
+ boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
2285
2323
  continuesBefore: moveSegment.continuesBefore,
2286
2324
  continuesAfter: moveSegment.continuesAfter,
2287
2325
  ampm,
@@ -2300,8 +2338,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2300
2338
  ...slot("event", { base: {
2301
2339
  position: "absolute",
2302
2340
  top: -windowStart * hourHeight,
2303
- left: 1,
2304
- right: 1,
2341
+ left: eventGap,
2342
+ right: eventGap,
2305
2343
  height: spill.boxHeight,
2306
2344
  pointerEvents: "none",
2307
2345
  zIndex: 3,
@@ -2341,8 +2379,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
2341
2379
  ...slot("createGhost", {
2342
2380
  base: {
2343
2381
  position: "absolute",
2344
- left: 1,
2345
- right: 1,
2382
+ left: eventGap,
2383
+ right: eventGap,
2346
2384
  top: ghost.topPx,
2347
2385
  height: Math.max(ghost.heightPx, 2),
2348
2386
  opacity: .7,
@@ -2423,7 +2461,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
2423
2461
  * <Calendar mode="week" date={new Date()} events={events} />
2424
2462
  * ```
2425
2463
  */
2426
- 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 }) {
2464
+ 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, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, 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 }) {
2427
2465
  const displayEvents = useMemo(() => {
2428
2466
  let out = events ?? EMPTY_EVENTS;
2429
2467
  if (out.some((e) => e.recurrence)) {
@@ -2548,6 +2586,8 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2548
2586
  styles,
2549
2587
  ampm,
2550
2588
  hourHeight,
2589
+ minEventHeight,
2590
+ eventGap,
2551
2591
  scrollOffsetMinutes,
2552
2592
  timeslots,
2553
2593
  minHour,
@@ -2557,8 +2597,10 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
2557
2597
  weekNumberPrefix,
2558
2598
  businessHours,
2559
2599
  renderBusinessHours,
2600
+ renderBackgroundEvent,
2560
2601
  showNowIndicator,
2561
2602
  showAllDayEventCell,
2603
+ showAllDayLabel,
2562
2604
  highlightWeekends,
2563
2605
  eventStartEditable,
2564
2606
  eventDurationEditable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/dom",
3
- "version": "2.9.1",
3
+ "version": "2.11.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.1"
51
+ "@super-calendar/core": "2.11.0"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@legendapp/list": ">=3",
package/src/Calendar.tsx CHANGED
@@ -115,6 +115,17 @@ export interface CalendarProps<T = unknown>
115
115
  ampm?: boolean;
116
116
  /** Initial pixels per hour. */
117
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;
118
129
  /** Initial scroll position, in minutes from midnight. */
119
130
  scrollOffsetMinutes?: number;
120
131
  /** Sub-divisions per hour for the grid lines. */
@@ -138,10 +149,17 @@ export interface CalendarProps<T = unknown>
138
149
  * band stays non-interactive and hidden from assistive tech.
139
150
  */
140
151
  renderBusinessHours?: (band: BusinessHoursBand) => ReactNode;
152
+ /**
153
+ * A component that draws a `display: "background"` event's band in place of
154
+ * the themed shade; see `TimeGrid`'s prop of the same name.
155
+ */
156
+ renderBackgroundEvent?: DomRenderEvent<T>;
141
157
  /** Show the current-time indicator (default true). */
142
158
  showNowIndicator?: boolean;
143
159
  /** Show the all-day lane (default true). */
144
160
  showAllDayEventCell?: boolean;
161
+ /** Show the "all-day" text beside the lane (default false). */
162
+ showAllDayLabel?: boolean;
145
163
  /** Tint weekend columns (default true). Set false to treat weekends normally. */
146
164
  highlightWeekends?: boolean;
147
165
  /** Allow moving events by default (per-event `startEditable` overrides). Default true. */
@@ -310,6 +328,8 @@ export function Calendar<T = unknown>({
310
328
  // time grid
311
329
  ampm,
312
330
  hourHeight,
331
+ minEventHeight,
332
+ eventGap,
313
333
  scrollOffsetMinutes,
314
334
  timeslots,
315
335
  minHour,
@@ -319,8 +339,10 @@ export function Calendar<T = unknown>({
319
339
  weekNumberPrefix,
320
340
  businessHours,
321
341
  renderBusinessHours,
342
+ renderBackgroundEvent,
322
343
  showNowIndicator,
323
344
  showAllDayEventCell,
345
+ showAllDayLabel,
324
346
  highlightWeekends,
325
347
  eventStartEditable,
326
348
  eventDurationEditable,
@@ -493,6 +515,8 @@ export function Calendar<T = unknown>({
493
515
  styles={styles}
494
516
  ampm={ampm}
495
517
  hourHeight={hourHeight}
518
+ minEventHeight={minEventHeight}
519
+ eventGap={eventGap}
496
520
  scrollOffsetMinutes={scrollOffsetMinutes}
497
521
  timeslots={timeslots}
498
522
  minHour={minHour}
@@ -502,8 +526,10 @@ export function Calendar<T = unknown>({
502
526
  weekNumberPrefix={weekNumberPrefix}
503
527
  businessHours={businessHours}
504
528
  renderBusinessHours={renderBusinessHours}
529
+ renderBackgroundEvent={renderBackgroundEvent}
505
530
  showNowIndicator={showNowIndicator}
506
531
  showAllDayEventCell={showAllDayEventCell}
532
+ showAllDayLabel={showAllDayLabel}
507
533
  highlightWeekends={highlightWeekends}
508
534
  eventStartEditable={eventStartEditable}
509
535
  eventDurationEditable={eventDurationEditable}
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). */
@@ -178,6 +195,15 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
178
195
  * band stays non-interactive and hidden from assistive tech.
179
196
  */
180
197
  renderBusinessHours?: (band: BusinessHoursBand) => ReactNode;
198
+ /**
199
+ * A component that draws a `display: "background"` event's band in place of
200
+ * the themed shade. Rendered like `renderEvent`, it receives the event, the
201
+ * mode, `continuesBefore` / `continuesAfter` for a multi-day event, and
202
+ * `onPress`, which fires `onPressEvent`. The band then takes pointer events and
203
+ * is no longer hidden from assistive tech; cell clicks and drag-to-create are
204
+ * unreachable underneath it. Without it the band stays a shaded, inert range.
205
+ */
206
+ renderBackgroundEvent?: DomRenderEvent<T>;
181
207
  /** Show the current-time indicator on today's column (default true). */
182
208
  showNowIndicator?: boolean;
183
209
  /** Fixed "now" instant for the indicator (doesn't tick). Defaults to the device clock. */
@@ -186,6 +212,8 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
186
212
  timeZone?: string;
187
213
  /** Show the all-day lane above the grid (default true). */
188
214
  showAllDayEventCell?: boolean;
215
+ /** Show the "all-day" text beside the lane (default false). */
216
+ showAllDayLabel?: boolean;
189
217
  /** Tint Saturday/Sunday columns with the weekend background (default true). Set
190
218
  * false to treat weekends like any other day. */
191
219
  highlightWeekends?: boolean;
@@ -392,6 +420,8 @@ export function TimeGrid<T = unknown>({
392
420
  zoomable = true,
393
421
  minHourHeight = 24,
394
422
  maxHourHeight = 160,
423
+ minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
424
+ eventGap = DEFAULT_EVENT_GAP,
395
425
  dragStepMinutes = 15,
396
426
  ampm = false,
397
427
  timeslots = 1,
@@ -404,6 +434,7 @@ export function TimeGrid<T = unknown>({
404
434
  keyboardEventNavigation = false,
405
435
  businessHours,
406
436
  renderBusinessHours,
437
+ renderBackgroundEvent,
407
438
  showNowIndicator = true,
408
439
  highlightWeekends = true,
409
440
  eventStartEditable = true,
@@ -412,6 +443,7 @@ export function TimeGrid<T = unknown>({
412
443
  now: nowProp,
413
444
  timeZone,
414
445
  showAllDayEventCell = true,
446
+ showAllDayLabel = false,
415
447
  locale,
416
448
  theme: themeOverrides,
417
449
  height = 600,
@@ -445,6 +477,7 @@ export function TimeGrid<T = unknown>({
445
477
  const windowEnd = Math.max(windowStart + 1, Math.min(maxHour, 24));
446
478
  const windowHours = windowEnd - windowStart;
447
479
  const gutterWidth = hideHours ? 0 : GUTTER_WIDTH;
480
+ const RenderBackground = renderBackgroundEvent;
448
481
  const visibleHours = useMemo(
449
482
  () => Array.from({ length: windowHours }, (_, i) => windowStart + i),
450
483
  [windowStart, windowHours],
@@ -998,7 +1031,7 @@ export function TimeGrid<T = unknown>({
998
1031
  event: dragged,
999
1032
  mode,
1000
1033
  isAllDay: false,
1001
- boxHeight: Math.max(drag.spillHours * hourHeight, 14),
1034
+ boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
1002
1035
  continuesBefore: true,
1003
1036
  continuesAfter: false,
1004
1037
  ampm,
@@ -1091,15 +1124,22 @@ export function TimeGrid<T = unknown>({
1091
1124
  // `display: "background"` events, sliced per day and clipped to the window.
1092
1125
  const backgroundByDay = useMemo(
1093
1126
  () =>
1094
- days.map((day) =>
1095
- backgroundBandsForDay(events, day)
1127
+ days.map((day) => {
1128
+ const seen = new Map<string, number>();
1129
+ return backgroundBandsForDay(events, day)
1096
1130
  .map((b) => ({
1097
1131
  ...b,
1098
1132
  startHours: Math.max(b.startHours, windowStart),
1099
1133
  endHours: Math.min(b.endHours, windowEnd),
1100
1134
  }))
1101
- .filter((b) => b.endHours > b.startHours),
1102
- ),
1135
+ .filter((b) => b.endHours > b.startHours)
1136
+ .map((b) => {
1137
+ const base = `bg-${b.event.start.toISOString()}-${b.event.end.toISOString()}`;
1138
+ const nth = (seen.get(base) ?? 0) + 1;
1139
+ seen.set(base, nth);
1140
+ return { ...b, key: nth === 1 ? base : `${base}-${nth}` };
1141
+ });
1142
+ }),
1103
1143
  [days, events, windowStart, windowEnd],
1104
1144
  );
1105
1145
  const gridLines = useMemo(() => {
@@ -1242,7 +1282,7 @@ export function TimeGrid<T = unknown>({
1242
1282
  themed: { fontSize: 10, color: theme.textMuted, padding: "4px 6px 0 0" },
1243
1283
  })}
1244
1284
  >
1245
- all-day
1285
+ {showAllDayLabel ? "all-day" : null}
1246
1286
  </div>
1247
1287
  {allDayByDay.map((list, i) => {
1248
1288
  const dayStart = startOfDay(days[i]);
@@ -1430,26 +1470,50 @@ export function TimeGrid<T = unknown>({
1430
1470
  {renderBusinessHours?.({ date: day, start: b.start, end: b.end })}
1431
1471
  </div>
1432
1472
  ))}
1433
- {/* Background events: shaded, non-interactive time ranges. */}
1434
- {backgroundByDay[dayIndex].map((b, bandIndex) => (
1435
- <div
1436
- key={`bg-${bandIndex}`}
1437
- aria-hidden
1438
- title={b.event.title}
1439
- {...slot("backgroundEvent", {
1440
- base: {
1441
- position: "absolute",
1442
- left: 0,
1443
- right: 0,
1444
- top: (b.startHours - windowStart) * hourHeight,
1445
- height: (b.endHours - b.startHours) * hourHeight,
1446
- pointerEvents: "none",
1447
- zIndex: 0,
1448
- },
1449
- themed: { background: theme.backgroundEvent },
1450
- })}
1451
- />
1452
- ))}
1473
+ {/* Background events: shaded time ranges, or the consumer's own band. */}
1474
+ {backgroundByDay[dayIndex].map((b) => {
1475
+ const { key } = b;
1476
+ const geometry = {
1477
+ position: "absolute" as const,
1478
+ left: 0,
1479
+ right: 0,
1480
+ top: (b.startHours - windowStart) * hourHeight,
1481
+ height: (b.endHours - b.startHours) * hourHeight,
1482
+ zIndex: 0,
1483
+ overflow: "hidden" as const,
1484
+ };
1485
+ if (!RenderBackground) {
1486
+ return (
1487
+ <div
1488
+ key={key}
1489
+ aria-hidden
1490
+ title={b.event.title}
1491
+ {...slot("backgroundEvent", {
1492
+ base: { ...geometry, pointerEvents: "none" },
1493
+ themed: { background: theme.backgroundEvent },
1494
+ })}
1495
+ />
1496
+ );
1497
+ }
1498
+ const dayStart = startOfDay(days[dayIndex]);
1499
+ return (
1500
+ <div
1501
+ key={key}
1502
+ {...slot("backgroundEvent", { base: { ...geometry, pointerEvents: "auto" } })}
1503
+ >
1504
+ <RenderBackground
1505
+ event={b.event}
1506
+ mode={mode}
1507
+ isAllDay={false}
1508
+ boxHeight={geometry.height}
1509
+ continuesBefore={b.event.start < dayStart}
1510
+ continuesAfter={b.event.end > addDays(dayStart, 1)}
1511
+ ampm={ampm}
1512
+ onPress={() => onPressEvent?.(b.event)}
1513
+ />
1514
+ </div>
1515
+ );
1516
+ })}
1453
1517
  {/* Grid lines, painted over the shade so they stay visible. */}
1454
1518
  <div
1455
1519
  aria-hidden
@@ -1484,7 +1548,7 @@ export function TimeGrid<T = unknown>({
1484
1548
  // them to the day, so the height doesn't jump on commit.
1485
1549
  const boxHeight = Math.max(
1486
1550
  Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight,
1487
- 14,
1551
+ minEventHeight,
1488
1552
  );
1489
1553
  const widthPct = 100 / pe.columns;
1490
1554
  const onPress = () => onPressEvent?.(pe.event);
@@ -1552,8 +1616,8 @@ export function TimeGrid<T = unknown>({
1552
1616
  // is the renderer's concern: the built-in one clamps, and a
1553
1617
  // custom renderer should adapt to the `boxHeight` it's given.
1554
1618
  height: boxHeight,
1555
- left: `calc(${pe.column * widthPct}% + 1px)`,
1556
- width: `calc(${widthPct}% - 2px)`,
1619
+ left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
1620
+ width: `calc(${widthPct}% - ${eventGap * 2}px)`,
1557
1621
  cursor: canMove ? "grab" : "pointer",
1558
1622
  touchAction: canMove ? "none" : "auto",
1559
1623
  zIndex: active ? 3 : 1,
@@ -1572,11 +1636,21 @@ export function TimeGrid<T = unknown>({
1572
1636
  ) : (
1573
1637
  <DefaultDomEvent {...args} theme={theme} boxProps={slot("eventBox")} />
1574
1638
  )}
1639
+ {/* A release without movement on a handle presses the event, like
1640
+ the box itself. Only when the box can move: otherwise it carries
1641
+ its own `onClick`, which would press the event a second time. */}
1575
1642
  {canResize && !pe.continuesBefore ? (
1576
1643
  <div
1577
1644
  onPointerDown={(e) => {
1578
1645
  e.stopPropagation();
1579
- beginDrag(e, pe, key, "resize-start", dayIndex);
1646
+ beginDrag(
1647
+ e,
1648
+ pe,
1649
+ key,
1650
+ "resize-start",
1651
+ dayIndex,
1652
+ canMove ? onPress : undefined,
1653
+ );
1580
1654
  }}
1581
1655
  style={{
1582
1656
  position: "absolute",
@@ -1598,7 +1672,14 @@ export function TimeGrid<T = unknown>({
1598
1672
  <div
1599
1673
  onPointerDown={(e) => {
1600
1674
  e.stopPropagation();
1601
- beginDrag(e, pe, key, "resize", dayIndex);
1675
+ beginDrag(
1676
+ e,
1677
+ pe,
1678
+ key,
1679
+ "resize",
1680
+ dayIndex,
1681
+ canMove ? onPress : undefined,
1682
+ );
1602
1683
  }}
1603
1684
  style={{
1604
1685
  position: "absolute",
@@ -1622,9 +1703,9 @@ export function TimeGrid<T = unknown>({
1622
1703
  base: {
1623
1704
  position: "absolute",
1624
1705
  top: (moveSegment.startHours - windowStart) * hourHeight,
1625
- left: 1,
1626
- right: 1,
1627
- height: Math.max(moveSegment.durationHours * hourHeight, 14),
1706
+ left: eventGap,
1707
+ right: eventGap,
1708
+ height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
1628
1709
  pointerEvents: "none",
1629
1710
  zIndex: 3,
1630
1711
  opacity: 0.85,
@@ -1636,7 +1717,7 @@ export function TimeGrid<T = unknown>({
1636
1717
  event: moveSegment.event,
1637
1718
  mode,
1638
1719
  isAllDay: false,
1639
- boxHeight: Math.max(moveSegment.durationHours * hourHeight, 14),
1720
+ boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
1640
1721
  continuesBefore: moveSegment.continuesBefore,
1641
1722
  continuesAfter: moveSegment.continuesAfter,
1642
1723
  ampm,
@@ -1662,8 +1743,8 @@ export function TimeGrid<T = unknown>({
1662
1743
  // the preview is scrolled out of view, exactly like the
1663
1744
  // continuation the drop will commit.
1664
1745
  top: -windowStart * hourHeight,
1665
- left: 1,
1666
- right: 1,
1746
+ left: eventGap,
1747
+ right: eventGap,
1667
1748
  height: spill.boxHeight,
1668
1749
  pointerEvents: "none",
1669
1750
  zIndex: 3,
@@ -1712,8 +1793,8 @@ export function TimeGrid<T = unknown>({
1712
1793
  {...slot("createGhost", {
1713
1794
  base: {
1714
1795
  position: "absolute",
1715
- left: 1,
1716
- right: 1,
1796
+ left: eventGap,
1797
+ right: eventGap,
1717
1798
  top: ghost.topPx,
1718
1799
  height: Math.max(ghost.heightPx, 2),
1719
1800
  opacity: 0.7,