@super-calendar/dom 2.16.0 → 2.18.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/src/MonthView.tsx CHANGED
@@ -12,6 +12,8 @@ import {
12
12
  type CSSProperties,
13
13
  type KeyboardEvent as ReactKeyboardEvent,
14
14
  type ReactElement,
15
+ type PointerEvent as ReactPointerEvent,
16
+ useCallback,
15
17
  useEffect,
16
18
  useMemo,
17
19
  useRef,
@@ -20,7 +22,10 @@ import {
20
22
  import {
21
23
  bandRounding,
22
24
  buildMonthGrid,
25
+ buildMultiWeekGrid,
26
+ nowInTimeZone,
23
27
  type CalendarEvent,
28
+ type CreateGhostArgs,
24
29
  compareDayEvents,
25
30
  dayBadgeKind,
26
31
  type DateRange,
@@ -32,8 +37,8 @@ import {
32
37
  layoutMonthWeek,
33
38
  monthCreateRange,
34
39
  monthDropBounds,
35
- type MonthGridDay,
36
- type MonthGridWeek,
40
+ type MonthGridWeekday,
41
+ type MultiWeekGridDay,
37
42
  overlapsOtherEvents,
38
43
  rangeBandKind,
39
44
  type WeekdayFormat,
@@ -44,6 +49,8 @@ import {
44
49
  dayAccessibilityLabel,
45
50
  resolveCalendarLabels,
46
51
  } from "@super-calendar/core";
52
+ import { holdDateDrag } from "./touch";
53
+ import { InertDiv } from "./InertDiv";
47
54
  import { createSlots, dataState, type SlotDefault, type SlotStyleProps } from "./slots";
48
55
  import { type DomCalendarTheme, mergeDomTheme } from "./theme";
49
56
 
@@ -61,6 +68,7 @@ export type MonthViewSlot =
61
68
  | "dayBadge"
62
69
  | "rangeBand"
63
70
  | "events"
71
+ | "createGhost"
64
72
  | "chipButton"
65
73
  | "chip"
66
74
  | "more"
@@ -76,6 +84,18 @@ const CHIP_GAP = 2;
76
84
  const CELL_PAD = 4;
77
85
  // Opacity of an event chip while it is being dragged to another day.
78
86
  const DRAGGED_CHIP_OPACITY = 0.4;
87
+ // How far a press travels before it becomes a drag. Until then the chips stay
88
+ // hit-testable, so a click still reaches the chip it pressed.
89
+ const DRAG_SLOP_PX = 4;
90
+ const TOUCH_DRAG_SLOP_PX = 8;
91
+
92
+ // A day as the shared rows render it. Month days carry `isCurrentMonth`;
93
+ // multi-week days omit it because every one of them is inside the period.
94
+ type RowDay = MultiWeekGridDay & { isCurrentMonth?: boolean };
95
+ type RowWeek = { id: string; days: RowDay[] };
96
+
97
+ // A leading or trailing day of a neighbouring month in the month grid.
98
+ const isOutsidePeriod = (day: RowDay) => day.isCurrentMonth === false;
79
99
 
80
100
  /** Props passed to a custom month event chip renderer. */
81
101
  export interface DomMonthEventArgs<T = unknown> {
@@ -83,6 +103,8 @@ export interface DomMonthEventArgs<T = unknown> {
83
103
  event: CalendarEvent<T>;
84
104
  /** Call to fire the view's `onPressEvent` for this chip. */
85
105
  onPress: () => void;
106
+ /** The current row view. Supplied by the calendar; optional for existing standalone chip callers. */
107
+ mode?: "month" | "multiweek";
86
108
  }
87
109
 
88
110
  /** A component that renders a single month-grid event chip. */
@@ -91,9 +113,18 @@ export type DomMonthEvent<T = unknown> = ComponentType<DomMonthEventArgs<T>>;
91
113
  // An in-progress month drag: either a day span being swept out for a new event,
92
114
  // or an existing event being carried to another day. Days are held as start-of-day
93
115
  // timestamps, so the reducer-ish updates compare cheaply.
94
- type MonthDrag<T> =
116
+ type MonthDrag<T> = (
95
117
  | { kind: "create"; anchor: number; hover: number }
96
- | { kind: "move"; event: CalendarEvent<T>; from: number; to: number };
118
+ | { kind: "move"; event: CalendarEvent<T>; from: number; to: number }
119
+ ) & {
120
+ // The rows the drag began in, so a drag never commits into a different window.
121
+ windowKey: string;
122
+ pointerId: number;
123
+ // Set once the pointer travels past the drag slop (or a touch hold fires).
124
+ // Chips stop taking pointer input only then, so a plain click is not
125
+ // retargeted to the day cell beneath.
126
+ armed: boolean;
127
+ };
97
128
 
98
129
  /** Props for {@link MonthView}. */
99
130
  export interface MonthViewProps<T = unknown>
@@ -158,6 +189,13 @@ export interface MonthViewProps<T = unknown>
158
189
  showWeekdays?: boolean;
159
190
  /** date-fns locale for the title and weekday labels. */
160
191
  locale?: Locale;
192
+ /**
193
+ * The instant whose calendar day is highlighted as today. Defaults to the
194
+ * device clock, and is read in `timeZone` when one is set.
195
+ */
196
+ now?: Date;
197
+ /** Highlight today as it is in this IANA time zone (default: the device's). */
198
+ timeZone?: string;
161
199
  /** Theme overrides; falls back to the default light theme. */
162
200
  theme?: Partial<DomCalendarTheme>;
163
201
  /** Fired when a selectable day is clicked. */
@@ -175,6 +213,12 @@ export interface MonthViewProps<T = unknown>
175
213
  * carry `data-creating` for styling.
176
214
  */
177
215
  onCreateEvent?: (start: Date, end: Date) => void;
216
+ /**
217
+ * Custom content for a drag-to-create preview, once per covered week row.
218
+ * Receives the full all-day range with an exclusive end. Requires onCreateEvent.
219
+ * Content is clipped, noninteractive, and hidden from assistive technology.
220
+ */
221
+ renderCreateGhost?: ComponentType<CreateGhostArgs>;
178
222
  /**
179
223
  * Reports the day span of a create sweep **as it happens**, as the ordered
180
224
  * inclusive `[start, end]` days (both at midnight), so a selection highlight can
@@ -214,7 +258,7 @@ export interface MonthViewProps<T = unknown>
214
258
  // always applied) and `themed` (colour/type/spacing, dropped when a class is set).
215
259
 
216
260
  function dayCellDefault(
217
- day: MonthGridDay,
261
+ day: RowDay,
218
262
  theme: DomCalendarTheme,
219
263
  highlightWeekends: boolean,
220
264
  ): SlotDefault {
@@ -254,7 +298,7 @@ function dayCellDefault(
254
298
  * event chips (and matches the native renderer's month grid).
255
299
  */
256
300
  function rangeBandDefault(
257
- day: MonthGridDay,
301
+ day: RowDay,
258
302
  theme: DomCalendarTheme,
259
303
  fillCell: boolean,
260
304
  eventsMode: boolean,
@@ -294,7 +338,7 @@ function rangeBandDefault(
294
338
  return { base, themed: { background: theme.rangeBackground } };
295
339
  }
296
340
 
297
- function badgeDefault(day: MonthGridDay, theme: DomCalendarTheme, hovered: boolean): SlotDefault {
341
+ function badgeDefault(day: RowDay, theme: DomCalendarTheme, hovered: boolean): SlotDefault {
298
342
  const badge = dayBadgeKind(day, day.isToday);
299
343
  const filled = badge !== "none";
300
344
  const background = filled
@@ -325,7 +369,7 @@ function badgeDefault(day: MonthGridDay, theme: DomCalendarTheme, hovered: boole
325
369
  // --- Calendar (events) layout styles -------------------------------------
326
370
 
327
371
  function eventCellDefault(
328
- day: MonthGridDay,
372
+ day: RowDay,
329
373
  theme: DomCalendarTheme,
330
374
  height: number,
331
375
  highlightWeekends: boolean,
@@ -361,7 +405,7 @@ function eventCellDefault(
361
405
  };
362
406
  }
363
407
 
364
- function compactBadgeDefault(day: MonthGridDay, theme: DomCalendarTheme): SlotDefault {
408
+ function compactBadgeDefault(day: RowDay, theme: DomCalendarTheme): SlotDefault {
365
409
  const badge = dayBadgeKind(day, day.isToday);
366
410
  const filled = badge !== "none";
367
411
  return {
@@ -423,7 +467,11 @@ function chipDefault(theme: DomCalendarTheme, chipHeight: number): SlotDefault {
423
467
  };
424
468
  }
425
469
 
426
- function moreButtonDefault(theme: DomCalendarTheme, chipHeight: number): SlotDefault {
470
+ function moreButtonDefault(
471
+ theme: DomCalendarTheme,
472
+ chipHeight: number,
473
+ multiWeek = false,
474
+ ): SlotDefault {
427
475
  return {
428
476
  base: {
429
477
  position: "relative",
@@ -435,6 +483,7 @@ function moreButtonDefault(theme: DomCalendarTheme, chipHeight: number): SlotDef
435
483
  height: chipHeight,
436
484
  lineHeight: `${chipHeight}px`,
437
485
  fontFamily: "inherit",
486
+ ...(multiWeek ? { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } : {}),
438
487
  },
439
488
  themed: {
440
489
  padding: "0 6px",
@@ -456,7 +505,7 @@ interface MonthViewInternalProps<T = unknown> extends MonthViewProps<T> {
456
505
  // A multi-day event lives in each covered day's bucket, so dedupe by reference;
457
506
  // this scans only the row's days, not every event in the month.
458
507
  function collectRowEvents<T>(
459
- week: MonthGridWeek,
508
+ week: RowWeek,
460
509
  eventsByDay: ReadonlyMap<string, CalendarEvent<T>[]>,
461
510
  ): CalendarEvent<T>[] {
462
511
  const seen = new Set<CalendarEvent<T>>();
@@ -474,6 +523,38 @@ function collectRowEvents<T>(
474
523
  return out;
475
524
  }
476
525
 
526
+ /**
527
+ * Which rows a {@link DateRows} grid shows. Internal to the package: the public
528
+ * views adapt their own props to it.
529
+ */
530
+ export type DateRowsSource =
531
+ | {
532
+ kind: "month";
533
+ /** Any day within the month to render. */
534
+ date: Date;
535
+ showAdjacentMonths: boolean;
536
+ }
537
+ | {
538
+ kind: "multiweek";
539
+ /** Any day within the first week to render. */
540
+ date: Date;
541
+ numberOfWeeks: number;
542
+ };
543
+
544
+ // The localized first and last displayed days, e.g. "Nov 1, 2026 – Nov 14, 2026".
545
+ function rangeTitle(start: Date, endExclusive: Date, locale?: Locale): string {
546
+ const options = locale ? { locale } : undefined;
547
+ return `${format(start, "PP", options)} – ${format(addDays(endExclusive, -1), "PP", options)}`;
548
+ }
549
+
550
+ /** Props for the private {@link DateRows} grid shared by the public row views. */
551
+ export interface DateRowsProps<T = unknown> extends Omit<
552
+ MonthViewInternalProps<T>,
553
+ "date" | "showAdjacentMonths"
554
+ > {
555
+ source: DateRowsSource;
556
+ }
557
+
477
558
  /**
478
559
  * A single static month grid, rendered with plain DOM elements.
479
560
  *
@@ -484,6 +565,18 @@ function collectRowEvents<T>(
484
565
  */
485
566
  export function MonthView<T = unknown>({
486
567
  date,
568
+ showAdjacentMonths = true,
569
+ ...rest
570
+ }: MonthViewInternalProps<T>): ReactElement {
571
+ return <DateRows<T> {...rest} source={{ kind: "month", date, showAdjacentMonths }} />;
572
+ }
573
+
574
+ /**
575
+ * The day-row grid behind the public row views: week rows of day cells with
576
+ * spanning event bars, overflow, selection, drag, and keyboard handling.
577
+ */
578
+ export function DateRows<T = unknown>({
579
+ source,
487
580
  weekStartsOn = 0,
488
581
  hiddenDays,
489
582
  weekdayFormat = "short",
@@ -500,12 +593,13 @@ export function MonthView<T = unknown>({
500
593
  onPressMore,
501
594
  selectedRange,
502
595
  selectedDates,
503
- showAdjacentMonths = true,
504
596
  highlightWeekends = true,
505
597
  fillCellOnSelection = false,
506
598
  showTitle = true,
507
599
  showWeekdays = true,
508
600
  locale,
601
+ now,
602
+ timeZone,
509
603
  theme: themeOverrides,
510
604
  minDate,
511
605
  maxDate,
@@ -513,6 +607,7 @@ export function MonthView<T = unknown>({
513
607
  onPressDay,
514
608
  onPressCell,
515
609
  onCreateEvent,
610
+ renderCreateGhost: RenderCreateGhost,
516
611
  onSelectDrag,
517
612
  onDragEvent,
518
613
  onDragStart,
@@ -523,20 +618,31 @@ export function MonthView<T = unknown>({
523
618
  style,
524
619
  classNames,
525
620
  styles,
526
- }: MonthViewInternalProps<T>): ReactElement {
621
+ }: DateRowsProps<T>): ReactElement {
622
+ const { date } = source;
623
+ const multiWeek = source.kind === "multiweek";
624
+ // Multi-week rows only contain days of the requested period, so nothing is blanked.
625
+ const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
626
+ const numberOfWeeks = source.kind === "multiweek" ? source.numberOfWeeks : undefined;
627
+ // The mode reported to custom renderers and accessibility labels.
628
+ const viewMode: "month" | "multiweek" = multiWeek ? "multiweek" : "month";
527
629
  const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
528
630
  const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
529
631
  const slot = createSlots<MonthViewSlot>({ classNames, styles });
530
632
 
531
633
  // Calendar layout (date in the corner + event chips) is on whenever `events`
532
- // is provided; otherwise the compact picker badge layout is used.
533
- const eventsMode = events !== undefined;
634
+ // is provided; otherwise the compact picker badge layout is used. Multi-week
635
+ // rows always use the calendar layout.
636
+ const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
637
+ const eventsMode = events !== undefined || multiWeek || createContentEnabled;
534
638
  // The day cells form a roving tab stop (arrow keys + Enter) in the picker
535
639
  // always, and in events mode only when the consumer opts in. Otherwise events
536
640
  // mode tabs through the event chips alone.
537
641
  const dayRoving = !eventsMode || keyboardDayNavigation;
538
642
  // Use the list-built index when provided (MonthList), else build it for this
539
643
  // month. Either way lookups use startOfDay(date).toISOString().
644
+ // The day, not the instant, so the grid is rebuilt once a day.
645
+ const todayKey = startOfDay(nowInTimeZone(now, timeZone)).getTime();
540
646
  const eventsByDay = useMemo(() => {
541
647
  // The list (MonthList) sorts before passing its index in; only sort here when
542
648
  // building our own, so each day reads all-day events first, then by start.
@@ -586,23 +692,19 @@ export function MonthView<T = unknown>({
586
692
  }, [moreOpenFor]);
587
693
  // Reserve `maxVisibleEventCount` rows below the date so every cell is uniform;
588
694
  // when a day overflows, the last row becomes the "+N more" affordance.
589
- const eventRowHeight = CELL_PAD * 2 + DATE_ROW + maxVisibleEventCount * (chipHeight + chipGap);
590
- const { weeks, weekdays } = useMemo(
591
- () =>
592
- buildMonthGrid(date, {
593
- weekStartsOn,
594
- hiddenDays,
595
- weekdayFormat,
596
- selectedRange,
597
- selectedDates,
598
- minDate,
599
- maxDate,
600
- isDateDisabled,
601
- locale,
602
- }),
603
- [
604
- date,
695
+ const eventRowHeight =
696
+ CELL_PAD * 2 +
697
+ DATE_ROW +
698
+ (multiWeek ? Math.max(1, maxVisibleEventCount) : maxVisibleEventCount) * (chipHeight + chipGap);
699
+ const { weeks, weekdays, title, period } = useMemo((): {
700
+ weeks: RowWeek[];
701
+ weekdays: MonthGridWeekday[];
702
+ title: string;
703
+ period: { start: Date; endExclusive: Date } | null;
704
+ } => {
705
+ const options = {
605
706
  weekStartsOn,
707
+ hiddenDays,
606
708
  weekdayFormat,
607
709
  selectedRange,
608
710
  selectedDates,
@@ -610,8 +712,36 @@ export function MonthView<T = unknown>({
610
712
  maxDate,
611
713
  isDateDisabled,
612
714
  locale,
613
- ],
614
- );
715
+ today: new Date(todayKey),
716
+ };
717
+ if (numberOfWeeks === undefined) {
718
+ return {
719
+ ...buildMonthGrid(date, options),
720
+ title: format(date, "MMMM yyyy", locale ? { locale } : undefined),
721
+ period: null,
722
+ };
723
+ }
724
+ const grid = buildMultiWeekGrid(date, { ...options, numberOfWeeks });
725
+ return {
726
+ weeks: grid.weeks,
727
+ weekdays: grid.weekdays,
728
+ title: rangeTitle(grid.visibleRange.start, grid.visibleRange.endExclusive, locale),
729
+ period: grid.period,
730
+ };
731
+ }, [
732
+ date,
733
+ numberOfWeeks,
734
+ weekStartsOn,
735
+ hiddenDays,
736
+ weekdayFormat,
737
+ selectedRange,
738
+ selectedDates,
739
+ minDate,
740
+ maxDate,
741
+ isDateDisabled,
742
+ locale,
743
+ todayKey,
744
+ ]);
615
745
 
616
746
  // Lay out each week row's spanning bars once per data change, not per render, so
617
747
  // hover / popover / drag-create state changes don't relay out every row.
@@ -628,39 +758,131 @@ export function MonthView<T = unknown>({
628
758
  [eventsMode, weeks, eventsByDay],
629
759
  );
630
760
 
761
+ // Multi-week rows rove over the rendered, enabled days only (oldest first), so
762
+ // focus skips hidden and disabled days and never leaves the displayed weeks.
763
+ const focusableDays = useMemo(
764
+ () =>
765
+ period
766
+ ? weeks
767
+ .flatMap((week) => week.days)
768
+ .filter((day) => !day.isDisabled)
769
+ .map((day) => startOfDay(day.date))
770
+ .sort((a, b) => a.getTime() - b.getTime())
771
+ : null,
772
+ [period, weeks],
773
+ );
774
+ const focusableKeys = useMemo(
775
+ () => (focusableDays ? new Set(focusableDays.map((d) => format(d, "yyyy-MM-dd"))) : null),
776
+ [focusableDays],
777
+ );
778
+
631
779
  // Roving tabindex: only one day is in the tab order; arrow keys move focus
632
780
  // within the month, so the grid is a single, sensible tab stop.
633
- const initialFocus = useMemo(() => {
781
+ const initialFocus = useMemo((): Date | null => {
782
+ if (focusableDays && focusableKeys) {
783
+ // The selected day, then today, then the first enabled day; none when every
784
+ // displayed day is disabled.
785
+ const rendered = (d?: Date | null): d is Date =>
786
+ !!d && focusableKeys.has(format(d, "yyyy-MM-dd"));
787
+ if (rendered(selectedRange?.start)) return startOfDay(selectedRange.start);
788
+ const picked = selectedDates?.find(rendered);
789
+ if (picked) return startOfDay(picked);
790
+ const today = new Date();
791
+ if (rendered(today)) return startOfDay(today);
792
+ return focusableDays[0] ?? null;
793
+ }
634
794
  const inMonth = (d?: Date | null) => !!d && isSameMonth(d, date);
635
795
  if (inMonth(selectedRange?.start)) return startOfDay(selectedRange!.start);
636
796
  const picked = selectedDates?.find(inMonth);
637
797
  if (picked) return startOfDay(picked);
638
798
  const today = new Date();
639
799
  return isSameMonth(today, date) ? startOfDay(today) : startOfMonth(date);
640
- }, [date, selectedRange, selectedDates]);
800
+ }, [focusableDays, focusableKeys, date, selectedRange, selectedDates]);
641
801
 
642
802
  const [focusedDate, setFocusedDate] = useState(initialFocus);
643
803
  const initialFocusRef = useRef(initialFocus);
644
804
  initialFocusRef.current = initialFocus;
645
- const monthKey = format(date, "yyyy-MM");
646
- const focusedMonth = useRef(monthKey);
805
+ // The displayed window: the month, or the first week and count of multi-week rows.
806
+ const windowKey = period
807
+ ? `${format(period.start, "yyyy-MM-dd")}+${numberOfWeeks}:${weekdays.map((day) => day.date.getDay()).join(",")}`
808
+ : format(date, "yyyy-MM");
809
+ const windowKeyRef = useRef(windowKey);
810
+ windowKeyRef.current = windowKey;
811
+ const focusedWindow = useRef(windowKey);
812
+ const gridRef = useRef<HTMLDivElement>(null);
813
+ const restoreDayFocus = useRef(false);
814
+ if (multiWeek && windowKey !== focusedWindow.current) {
815
+ const active = gridRef.current?.ownerDocument.activeElement;
816
+ // React replaces keyed week rows when paging. Remember whether the removed
817
+ // day owned focus, so repeated PageUp/PageDown stays inside the calendar.
818
+ restoreDayFocus.current =
819
+ !!active?.hasAttribute("data-day") && !!gridRef.current?.contains(active);
820
+ }
647
821
  useEffect(() => {
648
822
  // A parent can focus a day before the initial passive effect runs.
649
- if (monthKey === focusedMonth.current) return;
650
- focusedMonth.current = monthKey;
823
+ if (windowKey === focusedWindow.current) return;
824
+ focusedWindow.current = windowKey;
651
825
  setFocusedDate(initialFocusRef.current);
652
- }, [monthKey]);
826
+ if (restoreDayFocus.current) {
827
+ const active = gridRef.current?.ownerDocument.activeElement;
828
+ if (
829
+ active === gridRef.current?.ownerDocument.body ||
830
+ (active && gridRef.current?.contains(active))
831
+ ) {
832
+ const next = initialFocusRef.current
833
+ ? gridRef.current?.querySelector<HTMLElement>(
834
+ `[data-day="${format(initialFocusRef.current, "yyyy-MM-dd")}"]`,
835
+ )
836
+ : gridRef.current;
837
+ next?.focus();
838
+ }
839
+ }
840
+ restoreDayFocus.current = false;
841
+ }, [windowKey]);
653
842
 
654
843
  const [hoveredKey, setHoveredKey] = useState<string | null>(null);
655
- const gridRef = useRef<HTMLDivElement>(null);
656
- const focusKey = format(focusedDate, "yyyy-MM-dd");
844
+ const storedFocusKey = focusedDate ? format(focusedDate, "yyyy-MM-dd") : null;
845
+ // A multi-week focus target that hidden days or new constraints removed falls
846
+ // back to the initial target, without moving DOM focus.
847
+ const focusKey =
848
+ focusableKeys && (storedFocusKey === null || !focusableKeys.has(storedFocusKey))
849
+ ? initialFocus && format(initialFocus, "yyyy-MM-dd")
850
+ : storedFocusKey;
851
+
852
+ useEffect(() => {
853
+ if (!multiWeek) return;
854
+ const active = gridRef.current?.ownerDocument.activeElement;
855
+ if (!active?.hasAttribute("data-day") || !gridRef.current?.contains(active)) return;
856
+ if (
857
+ active.getAttribute("data-day") === focusKey &&
858
+ active.getAttribute("aria-disabled") !== "true"
859
+ )
860
+ return;
861
+ const next = focusKey
862
+ ? gridRef.current.querySelector<HTMLElement>(`[data-day="${focusKey}"]`)
863
+ : gridRef.current;
864
+ next?.focus();
865
+ }, [multiWeek, focusKey]);
657
866
 
658
867
  // Dragging (events mode): press a day and drag across others to sketch an
659
868
  // all-day span, or press an event chip and drop it on another day. Both are
660
869
  // released on a window pointerup, so letting go anywhere still commits.
661
870
  const [drag, setDrag] = useState<MonthDrag<T> | null>(null);
662
- const dragRef = useRef(drag);
663
- dragRef.current = drag;
871
+ const dragRef = useRef<MonthDrag<T> | null>(null);
872
+ // Release can arrive before React renders the last pointer movement.
873
+ const applyDrag = useCallback((next: MonthDrag<T> | null) => {
874
+ dragRef.current = next;
875
+ setDrag(next);
876
+ }, []);
877
+ const createStart = drag?.kind === "create" ? drag.anchor : null;
878
+ const createEnd = drag?.kind === "create" ? drag.hover : null;
879
+ const createRange = useMemo(
880
+ () =>
881
+ createContentEnabled && createStart !== null && createEnd !== null
882
+ ? monthCreateRange(new Date(createStart), new Date(createEnd))
883
+ : null,
884
+ [createContentEnabled, createStart, createEnd],
885
+ );
664
886
  const movedRef = useRef(false);
665
887
  // Set when a drag commits, so the click the browser fires next is swallowed (it
666
888
  // must not also open the day, or the event the drag landed on). A drag that ends
@@ -668,8 +890,9 @@ export function MonthView<T = unknown>({
668
890
  // common ancestor instead, where no handler consumes the guard — so every press
669
891
  // clears it first, keeping it scoped to the one interaction that set it.
670
892
  const suppressClickRef = useRef(false);
671
- const consumeSuppressedClick = () => {
672
- if (!suppressClickRef.current) return false;
893
+ // Keyboard and assistive-technology clicks have detail 0 and never trail a drag.
894
+ const consumeSuppressedClick = (detail: number) => {
895
+ if (detail === 0 || !suppressClickRef.current) return false;
673
896
  suppressClickRef.current = false;
674
897
  return true;
675
898
  };
@@ -680,30 +903,36 @@ export function MonthView<T = unknown>({
680
903
  !event.disabled &&
681
904
  event.draggable !== false &&
682
905
  (event.startEditable ?? eventStartEditable);
906
+ // Where the current press began and how far it may travel before it drags.
907
+ const pressOrigin = useRef({ x: 0, y: 0, slop: DRAG_SLOP_PX });
683
908
  // A fresh press starts a new interaction, so any guard left over from the
684
909
  // previous one is stale.
685
910
  const beginPress = () => {
686
911
  suppressClickRef.current = false;
687
912
  movedRef.current = false;
688
913
  };
689
- const beginCreate = (day: Date) => {
914
+ const beginCreate = (day: Date, pointerId: number, armed: boolean) => {
690
915
  if (!onCreateEvent && !onSelectDrag) return;
691
916
  const t = startOfDay(day).getTime();
692
- setDrag({ kind: "create", anchor: t, hover: t });
917
+ applyDrag({ kind: "create", anchor: t, hover: t, windowKey, pointerId, armed });
693
918
  };
694
- const beginMove = (event: CalendarEvent<T>, day: Date) => {
919
+ const beginMove = (event: CalendarEvent<T>, day: Date, pointerId: number, armed: boolean) => {
695
920
  if (!canMove(event)) return;
696
921
  const t = startOfDay(day).getTime();
697
- setDrag({ kind: "move", event, from: t, to: t });
922
+ applyDrag({ kind: "move", event, from: t, to: t, windowKey, pointerId, armed });
698
923
  onDragStart?.(event);
699
924
  };
700
- const extendDrag = (day: Date) => {
925
+ const extendDrag = (day: Date, pointerId: number) => {
701
926
  const current = dragRef.current;
702
- if (!current) return;
927
+ if (!current || current.pointerId !== pointerId) return;
703
928
  const t = startOfDay(day).getTime();
704
929
  if (t === (current.kind === "create" ? current.hover : current.to)) return;
705
930
  movedRef.current = true;
706
- setDrag(current.kind === "create" ? { ...current, hover: t } : { ...current, to: t });
931
+ applyDrag(
932
+ current.kind === "create"
933
+ ? { ...current, hover: t, armed: true }
934
+ : { ...current, to: t, armed: true },
935
+ );
707
936
  // A sweep reports its span live, so a selection can track the drag; a move
708
937
  // has nothing to report until it is dropped.
709
938
  if (current.kind === "create") {
@@ -711,16 +940,112 @@ export function MonthView<T = unknown>({
711
940
  onSelectDrag?.(new Date(lo), new Date(hi));
712
941
  }
713
942
  };
943
+ const heldTouch = useRef<(() => void) | null>(null);
944
+ const heldOrigin = useRef<{ day: Date; event?: CalendarEvent<T> } | null>(null);
945
+ const dayLookup = useMemo(
946
+ () => new Map(weeks.flatMap((week) => week.days).map((day) => [day.id, day])),
947
+ [weeks],
948
+ );
949
+ const touchHandlers = useRef({ beginCreate, beginMove, extendDrag, dayLookup });
950
+ touchHandlers.current = { beginCreate, beginMove, extendDrag, dayLookup };
951
+ const pressRow = (
952
+ event: ReactPointerEvent<HTMLElement>,
953
+ day: Date,
954
+ moving?: CalendarEvent<T>,
955
+ ) => {
956
+ if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
957
+ beginPress();
958
+ pressOrigin.current = {
959
+ x: event.clientX,
960
+ y: event.clientY,
961
+ slop: event.pointerType === "touch" ? TOUCH_DRAG_SLOP_PX : DRAG_SLOP_PX,
962
+ };
963
+ const start = (armed: boolean) => {
964
+ if (moving) touchHandlers.current.beginMove(moving, day, event.pointerId, armed);
965
+ else touchHandlers.current.beginCreate(day, event.pointerId, armed);
966
+ };
967
+ if (!multiWeek || !event.pointerType || event.pointerType === "mouse") {
968
+ start(false);
969
+ return;
970
+ }
971
+ heldOrigin.current = { day, event: moving };
972
+ heldTouch.current = holdDateDrag(
973
+ {
974
+ box: event.currentTarget,
975
+ pointerId: event.pointerId,
976
+ pointerType: event.pointerType,
977
+ clientX: event.clientX,
978
+ clientY: event.clientY,
979
+ },
980
+ // The hold itself is the deliberate gesture, so a held drag starts armed.
981
+ () => start(true),
982
+ (x, y) => {
983
+ const element = gridRef.current?.ownerDocument
984
+ .elementFromPoint(x, y)
985
+ ?.closest<HTMLElement>("[data-day]");
986
+ if (!element || !gridRef.current?.contains(element)) return;
987
+ const day = touchHandlers.current.dayLookup.get(element.dataset.day ?? "");
988
+ if (day && !day.isDisabled) touchHandlers.current.extendDrag(day.date, event.pointerId);
989
+ },
990
+ () => {
991
+ applyDrag(null);
992
+ movedRef.current = false;
993
+ },
994
+ () => {
995
+ heldTouch.current = null;
996
+ heldOrigin.current = null;
997
+ },
998
+ );
999
+ };
1000
+ useEffect(
1001
+ () => () => {
1002
+ heldTouch.current?.();
1003
+ },
1004
+ [windowKey],
1005
+ );
1006
+ // Parent selection updates can replace callbacks and equivalent props during
1007
+ // a hold. Cancel only when its origin or current destination becomes invalid.
1008
+ useEffect(() => {
1009
+ const origin = heldOrigin.current;
1010
+ if (!origin) return;
1011
+ const current = dragRef.current;
1012
+ const destination = current
1013
+ ? new Date(current.kind === "create" ? current.hover : current.to)
1014
+ : origin.day;
1015
+ const enabled = (day: Date) => {
1016
+ const cell = dayLookup.get(format(day, "yyyy-MM-dd"));
1017
+ return cell != null && !cell.isDisabled;
1018
+ };
1019
+ if (
1020
+ !enabled(origin.day) ||
1021
+ !enabled(destination) ||
1022
+ (origin.event
1023
+ ? !events?.includes(origin.event) || !canMove(origin.event)
1024
+ : !onCreateEvent && !onSelectDrag)
1025
+ ) {
1026
+ heldTouch.current?.();
1027
+ }
1028
+ });
714
1029
  const isDragging = drag !== null;
1030
+ const dragArmed = drag?.armed === true;
715
1031
  // Whether any month drag is wired up at all, so the cells only take over touch
716
1032
  // scrolling and pointer tracking when one of the handlers can actually fire.
717
1033
  const dragWired = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
718
1034
  useEffect(() => {
719
1035
  if (!isDragging) return;
720
- const finish = () => {
1036
+ const finish = (event: PointerEvent) => {
721
1037
  const current = dragRef.current;
722
- setDrag(null);
723
- if (!current || !movedRef.current) return;
1038
+ if (!current || current.pointerId !== event.pointerId) return;
1039
+ applyDrag(null);
1040
+ if (!movedRef.current) {
1041
+ // An armed move that returns to its day is released over the day cell,
1042
+ // because the chip ignored pointer input mid drag. The click that
1043
+ // follows belongs to the abandoned drag, not to the day.
1044
+ if (current.kind === "move" && current.armed) suppressClickRef.current = true;
1045
+ return;
1046
+ }
1047
+ // Multi-week rows drop a drag whose window was replaced before release.
1048
+ if (multiWeek && current.windowKey !== windowKeyRef.current) return;
724
1049
  suppressClickRef.current = true;
725
1050
  if (current.kind === "create") {
726
1051
  const range = monthCreateRange(new Date(current.anchor), new Date(current.hover));
@@ -739,10 +1064,82 @@ export function MonthView<T = unknown>({
739
1064
  }
740
1065
  onDragEvent?.(current.event, next.start, next.end);
741
1066
  };
1067
+ const clear = () => {
1068
+ heldTouch.current?.();
1069
+ applyDrag(null);
1070
+ movedRef.current = false;
1071
+ suppressClickRef.current = true;
1072
+ };
1073
+ const cancel = (event: PointerEvent) => {
1074
+ if (dragRef.current?.pointerId === event.pointerId) clear();
1075
+ };
1076
+ const arm = (event: PointerEvent) => {
1077
+ const current = dragRef.current;
1078
+ if (!current || current.armed || current.pointerId !== event.pointerId) return;
1079
+ const origin = pressOrigin.current;
1080
+ if (Math.hypot(event.clientX - origin.x, event.clientY - origin.y) <= origin.slop) return;
1081
+ applyDrag({ ...current, armed: true });
1082
+ };
1083
+ const keyDown = (event: KeyboardEvent) => {
1084
+ if (event.key !== "Escape") return;
1085
+ event.preventDefault();
1086
+ clear();
1087
+ };
1088
+ window.addEventListener("pointermove", arm);
742
1089
  window.addEventListener("pointerup", finish);
743
- return () => window.removeEventListener("pointerup", finish);
744
- }, [isDragging, onCreateEvent, onDragEvent, eventOverlap, events]);
1090
+ window.addEventListener("pointercancel", cancel);
1091
+ window.addEventListener("keydown", keyDown);
1092
+ return () => {
1093
+ window.removeEventListener("pointermove", arm);
1094
+ window.removeEventListener("pointerup", finish);
1095
+ window.removeEventListener("pointercancel", cancel);
1096
+ window.removeEventListener("keydown", keyDown);
1097
+ };
1098
+ }, [isDragging, multiWeek, onCreateEvent, onDragEvent, eventOverlap, events, applyDrag]);
1099
+ // Replacing the multi-week window cancels a drag and closes the overflow
1100
+ // popover, so neither acts on days that are no longer shown.
1101
+ const transientWindow = useRef(windowKey);
1102
+ useEffect(() => {
1103
+ if (transientWindow.current === windowKey) return;
1104
+ transientWindow.current = windowKey;
1105
+ if (!multiWeek) return;
1106
+ applyDrag(null);
1107
+ setMoreOpenFor(null);
1108
+ }, [multiWeek, windowKey, applyDrag]);
1109
+ // Multi-week roving: the neighbouring focusable day, the same weekday in the
1110
+ // nearest week that has it enabled, or the first/last focusable day.
1111
+ const nextMultiWeekFocus = (key: string): Date | null | undefined => {
1112
+ if (!focusableDays || !focusableKeys || !period) return undefined;
1113
+ const index = focusableDays.findIndex((d) => format(d, "yyyy-MM-dd") === focusKey);
1114
+ if (index === -1) return null;
1115
+ if (key === "ArrowLeft") return focusableDays[index - 1] ?? null;
1116
+ if (key === "ArrowRight") return focusableDays[index + 1] ?? null;
1117
+ if (key === "Home") return focusableDays[0];
1118
+ if (key === "End") return focusableDays[focusableDays.length - 1];
1119
+ const step = key === "ArrowUp" ? -7 : 7;
1120
+ for (
1121
+ let cursor = addDays(focusableDays[index], step);
1122
+ cursor >= period.start && cursor < period.endExclusive;
1123
+ cursor = addDays(cursor, step)
1124
+ ) {
1125
+ if (focusableKeys.has(format(cursor, "yyyy-MM-dd"))) return cursor;
1126
+ }
1127
+ return null;
1128
+ };
745
1129
  const onKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {
1130
+ if (multiWeek) {
1131
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"].includes(e.key)) {
1132
+ return;
1133
+ }
1134
+ e.preventDefault();
1135
+ const target = nextMultiWeekFocus(e.key);
1136
+ if (!target) return;
1137
+ setFocusedDate(target);
1138
+ const targetKey = format(target, "yyyy-MM-dd");
1139
+ gridRef.current?.querySelector<HTMLElement>(`[data-day="${targetKey}"]`)?.focus();
1140
+ return;
1141
+ }
1142
+ if (!focusedDate) return;
746
1143
  let next: Date | null = null;
747
1144
  if (e.key === "ArrowLeft") next = addDays(focusedDate, -1);
748
1145
  else if (e.key === "ArrowRight") next = addDays(focusedDate, 1);
@@ -761,7 +1158,14 @@ export function MonthView<T = unknown>({
761
1158
  return (
762
1159
  <div
763
1160
  className={className}
764
- style={{ fontFamily: theme.fontFamily, color: theme.text, ...style }}
1161
+ style={{
1162
+ fontFamily: theme.fontFamily,
1163
+ color: theme.text,
1164
+ // Multi-week rows keep their full height; when the view is given less
1165
+ // room, the grid scrolls under the title and weekday header.
1166
+ ...(multiWeek ? { display: "flex", flexDirection: "column", minHeight: 0 } : null),
1167
+ ...style,
1168
+ }}
765
1169
  >
766
1170
  {showTitle ? (
767
1171
  <div
@@ -769,13 +1173,16 @@ export function MonthView<T = unknown>({
769
1173
  themed: { fontSize: 17, fontWeight: 700, padding: "10px 14px 6px" },
770
1174
  })}
771
1175
  >
772
- {format(date, "MMMM yyyy", locale ? { locale } : undefined)}
1176
+ {title}
773
1177
  </div>
774
1178
  ) : null}
775
1179
  {showWeekdays ? (
776
1180
  <div
777
1181
  {...slot("weekdays", {
778
- base: { display: "grid", gridTemplateColumns: "repeat(7, minmax(0, 1fr))" },
1182
+ base: {
1183
+ display: "grid",
1184
+ gridTemplateColumns: `repeat(${weekdays.length}, minmax(0, 1fr))`,
1185
+ },
779
1186
  themed: { borderBottom: `1px solid ${theme.gridLine}`, padding: "6px 0" },
780
1187
  })}
781
1188
  >
@@ -799,11 +1206,15 @@ export function MonthView<T = unknown>({
799
1206
  <div
800
1207
  ref={gridRef}
801
1208
  role="grid"
802
- aria-label={format(date, "MMMM yyyy", locale ? { locale } : undefined)}
1209
+ tabIndex={multiWeek ? -1 : undefined}
1210
+ aria-label={title}
803
1211
  // Arrow-key roving applies whenever the day cells are a tab stop: the
804
1212
  // picker always, events mode only when keyboardDayNavigation is set.
805
1213
  onKeyDown={dayRoving ? onKeyDown : undefined}
806
- {...slot("grid")}
1214
+ {...slot(
1215
+ "grid",
1216
+ multiWeek ? { base: { flex: "1 1 auto", minHeight: 0, overflowY: "auto" } } : undefined,
1217
+ )}
807
1218
  >
808
1219
  {weeks.map((week, weekIndex) => {
809
1220
  // Spanning bars for this row (laid out once in `weekLayouts`). A multi-day
@@ -824,8 +1235,8 @@ export function MonthView<T = unknown>({
824
1235
  let firstVisCol = 0;
825
1236
  let lastVisCol = cols - 1;
826
1237
  if (eventsMode && !showAdjacentMonths) {
827
- const first = week.days.findIndex((d) => d.isCurrentMonth);
828
- const lastFromEnd = [...week.days].reverse().findIndex((d) => d.isCurrentMonth);
1238
+ const first = week.days.findIndex((d) => !isOutsidePeriod(d));
1239
+ const lastFromEnd = [...week.days].reverse().findIndex((d) => !isOutsidePeriod(d));
829
1240
  if (first !== -1) {
830
1241
  firstVisCol = first;
831
1242
  lastVisCol = cols - 1 - lastFromEnd;
@@ -845,6 +1256,23 @@ export function MonthView<T = unknown>({
845
1256
  };
846
1257
  })
847
1258
  .filter((b) => b.startCol <= b.endCol);
1259
+ const draftColumns = createRange
1260
+ ? week.days.flatMap((day, index) =>
1261
+ (!showAdjacentMonths && isOutsidePeriod(day)) ||
1262
+ day.date < createRange.start ||
1263
+ day.date >= createRange.end
1264
+ ? []
1265
+ : [index],
1266
+ )
1267
+ : [];
1268
+ const draftStart = draftColumns[0];
1269
+ const draftEnd = draftColumns.at(-1);
1270
+ const draftTop =
1271
+ CELL_PAD +
1272
+ DATE_ROW +
1273
+ chipGap +
1274
+ Math.min(visibleLanes, Math.max(0, maxVisibleEventCount - 1)) * (chipHeight + chipGap);
1275
+ const draftHeight = Math.min(chipHeight, Math.max(0, eventRowHeight - draftTop));
848
1276
  const barChipButton = slot("chipButton", chipButtonDefault);
849
1277
  const barChip = slot("chip", chipDefault(theme, chipHeight));
850
1278
  return (
@@ -852,11 +1280,14 @@ export function MonthView<T = unknown>({
852
1280
  key={week.id}
853
1281
  role="row"
854
1282
  {...slot("week", {
855
- base: { display: "grid", gridTemplateColumns: "repeat(7, minmax(0, 1fr))" },
1283
+ base: {
1284
+ display: "grid",
1285
+ gridTemplateColumns: `repeat(${week.days.length}, minmax(0, 1fr))`,
1286
+ },
856
1287
  })}
857
1288
  >
858
1289
  {week.days.map((day, dayCol) => {
859
- const hidden = !showAdjacentMonths && !day.isCurrentMonth;
1290
+ const hidden = !showAdjacentMonths && isOutsidePeriod(day);
860
1291
  const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
861
1292
  if (hidden) {
862
1293
  return (
@@ -885,7 +1316,7 @@ export function MonthView<T = unknown>({
885
1316
  "data-selected": day.isSelected,
886
1317
  "data-range": day.isInRange,
887
1318
  "data-weekend": day.isWeekend,
888
- "data-outside": !day.isCurrentMonth,
1319
+ "data-outside": isOutsidePeriod(day),
889
1320
  "data-disabled": day.isDisabled,
890
1321
  "data-creating": inCreate,
891
1322
  "data-drop": isDropTarget,
@@ -943,28 +1374,32 @@ export function MonthView<T = unknown>({
943
1374
  // numbers and chip titles it passes over.
944
1375
  style={
945
1376
  dragWired
946
- ? { ...dayCellProps.style, touchAction: "none", userSelect: "none" }
1377
+ ? {
1378
+ ...dayCellProps.style,
1379
+ touchAction: multiWeek ? "pan-y" : "none",
1380
+ userSelect: "none",
1381
+ }
947
1382
  : dayCellProps.style
948
1383
  }
949
1384
  onPointerDown={
950
1385
  dragWired && !day.isDisabled
951
1386
  ? (e) => {
952
- if (e.button !== 0) return;
953
- beginPress();
954
- beginCreate(day.date);
1387
+ pressRow(e, day.date);
955
1388
  }
956
1389
  : undefined
957
1390
  }
958
1391
  // A disabled day is out of every selection, drag included, so
959
1392
  // a sweep never extends onto it and no drop lands there.
960
1393
  onPointerEnter={
961
- dragWired && !day.isDisabled ? () => extendDrag(day.date) : undefined
1394
+ dragWired && !day.isDisabled
1395
+ ? (event) => extendDrag(day.date, event.pointerId)
1396
+ : undefined
962
1397
  }
963
1398
  onClick={
964
1399
  day.isDisabled
965
1400
  ? undefined
966
- : () => {
967
- if (consumeSuppressedClick()) return;
1401
+ : (e) => {
1402
+ if (consumeSuppressedClick(e.detail)) return;
968
1403
  onPressDay?.(day.date);
969
1404
  onPressCell?.(startOfDay(day.date));
970
1405
  }
@@ -997,7 +1432,8 @@ export function MonthView<T = unknown>({
997
1432
  .filter((b) => b.startCol === dayCol)
998
1433
  .map((b) => {
999
1434
  const span = b.endCol - b.startCol + 1;
1000
- const isDragged = drag?.kind === "move" && drag.event === b.seg.event;
1435
+ const isDragged =
1436
+ dragArmed && drag?.kind === "move" && drag.event === b.seg.event;
1001
1437
  return (
1002
1438
  <button
1003
1439
  key={`bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`}
@@ -1007,14 +1443,13 @@ export function MonthView<T = unknown>({
1007
1443
  ? (e) => {
1008
1444
  if (e.button !== 0) return;
1009
1445
  e.stopPropagation();
1010
- beginPress();
1011
- beginMove(b.seg.event, day.date);
1446
+ pressRow(e, day.date, b.seg.event);
1012
1447
  }
1013
1448
  : undefined
1014
1449
  }
1015
1450
  onClick={(e) => {
1016
1451
  e.stopPropagation();
1017
- if (consumeSuppressedClick()) return;
1452
+ if (consumeSuppressedClick(e.detail)) return;
1018
1453
  onPressEvent?.(b.seg.event);
1019
1454
  }}
1020
1455
  {...barChipButton}
@@ -1022,7 +1457,7 @@ export function MonthView<T = unknown>({
1022
1457
  aria-label={
1023
1458
  eventAccessibilityLabel
1024
1459
  ? eventAccessibilityLabel(b.seg.event, {
1025
- mode: "month",
1460
+ mode: viewMode,
1026
1461
  isAllDay: isAllDayEvent(b.seg.event),
1027
1462
  ampm: false,
1028
1463
  })
@@ -1039,17 +1474,18 @@ export function MonthView<T = unknown>({
1039
1474
  chipGap +
1040
1475
  b.seg.lane * (chipHeight + chipGap),
1041
1476
  height: chipHeight,
1042
- pointerEvents: isDragging ? "none" : "auto",
1477
+ pointerEvents: dragArmed ? "none" : "auto",
1043
1478
  // Fade the bar being carried, so the tinted drop
1044
1479
  // target reads as where it is going.
1045
1480
  opacity: isDragged ? DRAGGED_CHIP_OPACITY : undefined,
1046
1481
  cursor: canMove(b.seg.event) ? "grab" : undefined,
1047
- touchAction: dragWired ? "none" : undefined,
1482
+ touchAction: dragWired ? (multiWeek ? "pan-y" : "none") : undefined,
1048
1483
  zIndex: 2,
1049
1484
  }}
1050
1485
  >
1051
1486
  {Chip ? (
1052
1487
  <Chip
1488
+ mode={viewMode}
1053
1489
  event={b.seg.event}
1054
1490
  onPress={() => onPressEvent?.(b.seg.event)}
1055
1491
  />
@@ -1072,6 +1508,38 @@ export function MonthView<T = unknown>({
1072
1508
  </button>
1073
1509
  );
1074
1510
  })}
1511
+ {RenderCreateGhost &&
1512
+ createRange &&
1513
+ draftStart === dayCol &&
1514
+ draftEnd !== undefined &&
1515
+ draftHeight > 0 ? (
1516
+ <InertDiv
1517
+ {...slot("createGhost", {
1518
+ base: {
1519
+ position: "absolute",
1520
+ left: 2,
1521
+ width: `calc(${(draftEnd - draftStart + 1) * 100}% - 4px)`,
1522
+ top: draftTop,
1523
+ height: draftHeight,
1524
+ boxSizing: "border-box",
1525
+ pointerEvents: "none",
1526
+ overflow: "hidden",
1527
+ zIndex: 3,
1528
+ },
1529
+ themed: {
1530
+ background: theme.rangeBackground,
1531
+ border: `1px solid ${theme.selectedBackground}`,
1532
+ borderRadius: 4,
1533
+ fontSize: 12,
1534
+ color: theme.text,
1535
+ },
1536
+ })}
1537
+ inert
1538
+ aria-hidden="true"
1539
+ >
1540
+ <RenderCreateGhost start={createRange.start} end={createRange.end} />
1541
+ </InertDiv>
1542
+ ) : null}
1075
1543
  <div
1076
1544
  {...slot("events", {
1077
1545
  base: { display: "flex", flexDirection: "column", gap: chipGap },
@@ -1097,7 +1565,7 @@ export function MonthView<T = unknown>({
1097
1565
  setMoreOpenFor((open) => (open === day.id ? null : day.id));
1098
1566
  }
1099
1567
  }}
1100
- {...slot("more", moreButtonDefault(theme, chipHeight))}
1568
+ {...slot("more", moreButtonDefault(theme, chipHeight, multiWeek))}
1101
1569
  aria-label={`${labels.moreEvents(hiddenEvents.length)}, ${dayLabel}`}
1102
1570
  aria-expanded={onPressMore ? undefined : moreOpenFor === day.id}
1103
1571
  >
@@ -1175,7 +1643,11 @@ export function MonthView<T = unknown>({
1175
1643
  }}
1176
1644
  >
1177
1645
  {Chip ? (
1178
- <Chip event={event} onPress={() => onPressEvent?.(event)} />
1646
+ <Chip
1647
+ mode={viewMode}
1648
+ event={event}
1649
+ onPress={() => onPressEvent?.(event)}
1650
+ />
1179
1651
  ) : (
1180
1652
  <span {...slot("chip", chipDefault(theme, chipHeight))}>
1181
1653
  {event.title}