@super-calendar/dom 2.7.0 → 2.8.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
@@ -29,8 +29,9 @@ import {
29
29
  groupEventsByDay,
30
30
  isBackgroundEvent,
31
31
  isAllDayEvent,
32
+ layoutMonthWeek,
32
33
  type MonthGridDay,
33
- monthVisibleCount,
34
+ type MonthGridWeek,
34
35
  rangeBandKind,
35
36
  type WeekdayFormat,
36
37
  type WeekStartsOn,
@@ -57,6 +58,9 @@ export type MonthViewSlot =
57
58
  | "more"
58
59
  | "morePopover";
59
60
 
61
+ // Stable empty layout for rows with no events (avoids a fresh object per render).
62
+ const EMPTY_LAYOUT = { segments: [], laneCount: 0 } as const;
63
+
60
64
  // Chip metrics for the events layout (when `events` is provided).
61
65
  const DATE_ROW = 24;
62
66
  const CHIP_HEIGHT = 18;
@@ -99,7 +103,12 @@ export interface MonthViewProps<T = unknown>
99
103
  * announce. Defaults to the event title and day (e.g. "Standup, 15 July").
100
104
  */
101
105
  eventAccessibilityLabel?: EventAccessibilityLabeler<T>;
102
- /** Max chips shown per day before a "+N more" row (default 3). */
106
+ /**
107
+ * Max event lanes (stacked rows) shown per week before the rest of a day's
108
+ * events collapse into a "+N more" row (default 3). Because multi-day events draw
109
+ * as one bar spanning a lane across the week, this caps lanes per row, not chips
110
+ * per day, so a long bar can push a lightly-booked day's own events into "+N more".
111
+ */
103
112
  maxVisibleEventCount?: number;
104
113
  /** Template for the overflow row; `{moreCount}` is replaced (default "{moreCount} More"). */
105
114
  moreLabel?: string;
@@ -360,6 +369,28 @@ interface MonthViewInternalProps<T = unknown> extends MonthViewProps<T> {
360
369
  eventsByDay?: ReadonlyMap<string, CalendarEvent<T>[]>;
361
370
  }
362
371
 
372
+ // The distinct events touching a week row, in the per-day index's sorted order.
373
+ // A multi-day event lives in each covered day's bucket, so dedupe by reference;
374
+ // this scans only the row's days, not every event in the month.
375
+ function collectRowEvents<T>(
376
+ week: MonthGridWeek,
377
+ eventsByDay: ReadonlyMap<string, CalendarEvent<T>[]>,
378
+ ): CalendarEvent<T>[] {
379
+ const seen = new Set<CalendarEvent<T>>();
380
+ const out: CalendarEvent<T>[] = [];
381
+ for (const day of week.days) {
382
+ const list = eventsByDay.get(startOfDay(day.date).toISOString());
383
+ if (!list) continue;
384
+ for (const event of list) {
385
+ if (!seen.has(event)) {
386
+ seen.add(event);
387
+ out.push(event);
388
+ }
389
+ }
390
+ }
391
+ return out;
392
+ }
393
+
363
394
  /**
364
395
  * A single static month grid, rendered with plain DOM elements.
365
396
  *
@@ -488,6 +519,21 @@ export function MonthView<T = unknown>({
488
519
  ],
489
520
  );
490
521
 
522
+ // Lay out each week row's spanning bars once per data change, not per render, so
523
+ // hover / popover / drag-create state changes don't relay out every row.
524
+ const weekLayouts = useMemo(
525
+ () =>
526
+ eventsMode
527
+ ? weeks.map((week) =>
528
+ layoutMonthWeek(
529
+ week.days.map((d) => d.date),
530
+ collectRowEvents(week, eventsByDay),
531
+ ),
532
+ )
533
+ : [],
534
+ [eventsMode, weeks, eventsByDay],
535
+ );
536
+
491
537
  // Roving tabindex: only one day is in the tab order; arrow keys move focus
492
538
  // within the month, so the grid is a single, sensible tab stop.
493
539
  const initialFocus = useMemo(() => {
@@ -610,281 +656,370 @@ export function MonthView<T = unknown>({
610
656
  onKeyDown={dayRoving ? onKeyDown : undefined}
611
657
  {...slot("grid")}
612
658
  >
613
- {weeks.map((week) => (
614
- <div
615
- key={week.id}
616
- role="row"
617
- {...slot("week", {
618
- base: { display: "grid", gridTemplateColumns: "repeat(7, minmax(0, 1fr))" },
619
- })}
620
- >
621
- {week.days.map((day) => {
622
- const hidden = !showAdjacentMonths && !day.isCurrentMonth;
623
- const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
624
- if (hidden) {
625
- return (
626
- <div key={day.id} role="gridcell" aria-hidden style={{ height: cellHeight }} />
659
+ {weeks.map((week, weekIndex) => {
660
+ // Spanning bars for this row (laid out once in `weekLayouts`). A multi-day
661
+ // event is one bar across its columns, stacked into lanes; each bar renders
662
+ // inside its start-column cell (valid grid content that reads with that day)
663
+ // and overflows right across the days it spans. The cells reserve the lane
664
+ // rows so "+more" sits below the bars.
665
+ const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
666
+ // When lanes overflow, keep the last row for "+more" but always show at
667
+ // least one bar, so a day never collapses to only the overflow row.
668
+ const overflowing = rowLayout.laneCount > maxVisibleEventCount;
669
+ const visibleLanes = overflowing
670
+ ? Math.max(maxVisibleEventCount - 1, 1)
671
+ : rowLayout.laneCount;
672
+ // With adjacent months hidden, clamp bars to the current-month columns so
673
+ // none draw over the blank leading/trailing cells.
674
+ const cols = week.days.length;
675
+ let firstVisCol = 0;
676
+ let lastVisCol = cols - 1;
677
+ if (eventsMode && !showAdjacentMonths) {
678
+ const first = week.days.findIndex((d) => d.isCurrentMonth);
679
+ const lastFromEnd = [...week.days].reverse().findIndex((d) => d.isCurrentMonth);
680
+ if (first !== -1) {
681
+ firstVisCol = first;
682
+ lastVisCol = cols - 1 - lastFromEnd;
683
+ }
684
+ }
685
+ const barSegs = rowLayout.segments
686
+ .filter((s) => s.lane < visibleLanes)
687
+ .map((s) => {
688
+ const startCol = Math.max(s.startCol, firstVisCol);
689
+ const endCol = Math.min(s.endCol, lastVisCol);
690
+ return {
691
+ seg: s,
692
+ startCol,
693
+ endCol,
694
+ continuesBefore: s.continuesBefore || startCol > s.startCol,
695
+ continuesAfter: s.continuesAfter || endCol < s.endCol,
696
+ };
697
+ })
698
+ .filter((b) => b.startCol <= b.endCol);
699
+ const barChipButton = slot("chipButton", chipButtonDefault);
700
+ const barChip = slot("chip", chipDefault(theme));
701
+ return (
702
+ <div
703
+ key={week.id}
704
+ role="row"
705
+ {...slot("week", {
706
+ base: { display: "grid", gridTemplateColumns: "repeat(7, minmax(0, 1fr))" },
707
+ })}
708
+ >
709
+ {week.days.map((day, dayCol) => {
710
+ const hidden = !showAdjacentMonths && !day.isCurrentMonth;
711
+ const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
712
+ if (hidden) {
713
+ return (
714
+ <div key={day.id} role="gridcell" aria-hidden style={{ height: cellHeight }} />
715
+ );
716
+ }
717
+ const band = rangeBandDefault(day, theme, fillCellOnSelection);
718
+ const label = format(
719
+ day.date,
720
+ "EEEE, d MMMM yyyy",
721
+ locale ? { locale } : undefined,
627
722
  );
628
- }
629
- const band = rangeBandDefault(day, theme, fillCellOnSelection);
630
- const label = format(day.date, "EEEE, d MMMM yyyy", locale ? { locale } : undefined);
631
- const dayTime = startOfDay(day.date).getTime();
632
- const inCreate =
633
- creating != null &&
634
- dayTime >= Math.min(creating.anchor, creating.hover) &&
635
- dayTime <= Math.max(creating.anchor, creating.hover);
636
- // Present/absent data-* attributes so consumers can style day state
637
- // with CSS/Tailwind variants (e.g. `data-[today]:bg-blue-500`).
638
- const dayData = dataState({
639
- "data-today": day.isToday,
640
- "data-selected": day.isSelected,
641
- "data-range": day.isInRange,
642
- "data-weekend": day.isWeekend,
643
- "data-outside": !day.isCurrentMonth,
644
- "data-disabled": day.isDisabled,
645
- "data-creating": inCreate,
646
- });
647
-
648
- if (eventsMode) {
649
- const dayEvents = eventsByDay.get(startOfDay(day.date).toISOString()) ?? [];
650
- // Core decides how many fit; withMore keeps >=1 chip so an
651
- // overflowing day never shows only the "+N more" row.
652
- const visible = monthVisibleCount(dayEvents.length, {
653
- full: maxVisibleEventCount,
654
- withMore: Math.max(maxVisibleEventCount - 1, 1),
723
+ const dayTime = startOfDay(day.date).getTime();
724
+ const inCreate =
725
+ creating != null &&
726
+ dayTime >= Math.min(creating.anchor, creating.hover) &&
727
+ dayTime <= Math.max(creating.anchor, creating.hover);
728
+ // Present/absent data-* attributes so consumers can style day state
729
+ // with CSS/Tailwind variants (e.g. `data-[today]:bg-blue-500`).
730
+ const dayData = dataState({
731
+ "data-today": day.isToday,
732
+ "data-selected": day.isSelected,
733
+ "data-range": day.isInRange,
734
+ "data-weekend": day.isWeekend,
735
+ "data-outside": !day.isCurrentMonth,
736
+ "data-disabled": day.isDisabled,
737
+ "data-creating": inCreate,
655
738
  });
656
- const shown = dayEvents.slice(0, visible);
657
- const rest = dayEvents.slice(visible);
658
- const overflow = rest.length > 0;
659
- const dayLabel = format(day.date, "d MMMM", locale ? { locale } : undefined);
660
- const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight));
661
- return (
662
- // Events mode: by default the cell is not a tab stop, so keyboard
663
- // focus moves through the event chips (real buttons) only, not
664
- // every empty day. With keyboardDayNavigation the cell joins the
665
- // roving tab order (arrow keys + Enter to open the day). A pointer
666
- // click always drills into the day.
667
- <div
668
- key={day.id}
669
- role="gridcell"
670
- data-day={day.id}
671
- {...dayData}
672
- tabIndex={keyboardDayNavigation ? (day.id === focusKey ? 0 : -1) : undefined}
673
- aria-disabled={day.isDisabled || undefined}
674
- aria-label={label}
675
- {...dayCellProps}
676
- // Drag-to-create disables touch scroll on the cell so a swipe
677
- // sketches a span instead of scrolling the grid.
678
- style={
679
- onCreateEvent
680
- ? { ...dayCellProps.style, touchAction: "none" }
681
- : dayCellProps.style
682
- }
683
- onPointerDown={
684
- onCreateEvent && !day.isDisabled
685
- ? (e) => {
686
- if (e.button === 0) beginCreate(day.date);
687
- }
688
- : undefined
689
- }
690
- onPointerEnter={onCreateEvent ? () => extendCreate(day.date) : undefined}
691
- onClick={
692
- day.isDisabled
693
- ? undefined
694
- : () => {
695
- if (suppressClickRef.current) {
696
- suppressClickRef.current = false;
697
- return;
698
- }
699
- onPressDay?.(day.date);
700
- }
701
- }
702
- onKeyDown={
703
- keyboardDayNavigation && !day.isDisabled
704
- ? (e) => {
705
- // Let Enter/Space on a focused chip activate the chip.
706
- if (e.target !== e.currentTarget) return;
707
- if (e.key === "Enter" || e.key === " ") {
708
- e.preventDefault();
709
- onPressDay?.(day.date);
710
- }
711
- }
712
- : undefined
713
- }
714
- >
715
- {band ? <span data-band aria-hidden {...slot("rangeBand", band)} /> : null}
716
- <span {...dayData} {...slot("dayBadge", compactBadgeDefault(day, theme))}>
717
- {day.label}
718
- </span>
739
+
740
+ if (eventsMode) {
741
+ const dayEvents = eventsByDay.get(startOfDay(day.date).toISOString()) ?? [];
742
+ // Events past the visible lanes (this day's segments in a lane the
743
+ // row doesn't show) collapse into "+N more"; the popover lists the
744
+ // whole day.
745
+ const hiddenEvents = rowLayout.segments
746
+ .filter(
747
+ (s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes,
748
+ )
749
+ .map((s) => s.event);
750
+ const dayLabel = format(day.date, "d MMMM", locale ? { locale } : undefined);
751
+ const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight));
752
+ return (
753
+ // Events mode: by default the cell is not a tab stop, so keyboard
754
+ // focus moves through the event chips (real buttons) only, not
755
+ // every empty day. With keyboardDayNavigation the cell joins the
756
+ // roving tab order (arrow keys + Enter to open the day). A pointer
757
+ // click always drills into the day.
719
758
  <div
720
- {...slot("events", {
721
- base: { display: "flex", flexDirection: "column", gap: CHIP_GAP },
722
- })}
723
- >
724
- {shown.map((event) => {
725
- const onPress = () => onPressEvent?.(event);
726
- return (
727
- <button
728
- key={`${event.start.toISOString()}:${event.title}`}
729
- type="button"
730
- onClick={(e) => {
731
- e.stopPropagation();
732
- onPress();
733
- }}
734
- {...slot("chipButton", chipButtonDefault)}
735
- title={event.title}
736
- aria-label={
737
- eventAccessibilityLabel
738
- ? eventAccessibilityLabel(event, {
739
- mode: "month",
740
- isAllDay: isAllDayEvent(event),
741
- ampm: false,
742
- })
743
- : `${event.title}, ${dayLabel}`
759
+ key={day.id}
760
+ role="gridcell"
761
+ data-day={day.id}
762
+ {...dayData}
763
+ tabIndex={keyboardDayNavigation ? (day.id === focusKey ? 0 : -1) : undefined}
764
+ aria-disabled={day.isDisabled || undefined}
765
+ aria-label={label}
766
+ {...dayCellProps}
767
+ // Drag-to-create disables touch scroll on the cell so a swipe
768
+ // sketches a span instead of scrolling the grid.
769
+ style={
770
+ onCreateEvent
771
+ ? { ...dayCellProps.style, touchAction: "none" }
772
+ : dayCellProps.style
773
+ }
774
+ onPointerDown={
775
+ onCreateEvent && !day.isDisabled
776
+ ? (e) => {
777
+ if (e.button === 0) beginCreate(day.date);
744
778
  }
745
- >
746
- {Chip ? (
747
- <Chip event={event} onPress={onPress} />
748
- ) : (
749
- <span {...slot("chip", chipDefault(theme))}>{event.title}</span>
750
- )}
751
- </button>
752
- );
753
- })}
754
- {overflow ? (
755
- <button
756
- type="button"
757
- // In built-in-popover mode, keep the document
758
- // pointerdown dismiss from firing before this click's
759
- // toggle, so pressing the button again closes it.
760
- onPointerDown={onPressMore ? undefined : (e) => e.stopPropagation()}
761
- onClick={(e) => {
762
- e.stopPropagation();
763
- if (onPressMore) onPressMore(rest, day.date);
764
- else {
765
- moreTriggerRef.current = e.currentTarget;
766
- setMoreOpenFor((open) => (open === day.id ? null : day.id));
779
+ : undefined
780
+ }
781
+ onPointerEnter={onCreateEvent ? () => extendCreate(day.date) : undefined}
782
+ onClick={
783
+ day.isDisabled
784
+ ? undefined
785
+ : () => {
786
+ if (suppressClickRef.current) {
787
+ suppressClickRef.current = false;
788
+ return;
789
+ }
790
+ onPressDay?.(day.date);
767
791
  }
768
- }}
769
- {...slot("more", moreButtonDefault(theme))}
770
- aria-label={`${rest.length} more events, ${dayLabel}`}
771
- aria-expanded={onPressMore ? undefined : moreOpenFor === day.id}
772
- >
773
- {moreLabel.replace("{moreCount}", String(rest.length))}
774
- </button>
775
- ) : null}
776
- {moreOpenFor === day.id ? (
777
- <div
778
- ref={morePopoverRef}
779
- // A non-modal dialog: Tab stays inside and Escape closes,
780
- // but the page behind is not inert (outside clicks work),
781
- // so no aria-modal claim.
782
- role="dialog"
783
- aria-label={dayLabel}
784
- onPointerDown={(e) => e.stopPropagation()}
785
- // Contain Tab inside the dialog; Escape (handled on the
786
- // document) closes it and restores focus to the trigger.
787
- onKeyDown={(e) => {
788
- if (e.key !== "Tab") return;
789
- const buttons =
790
- morePopoverRef.current?.querySelectorAll<HTMLElement>("button");
791
- if (!buttons?.length) return;
792
- const first = buttons[0];
793
- const last = buttons[buttons.length - 1];
794
- if (e.shiftKey && document.activeElement === first) {
795
- e.preventDefault();
796
- last.focus();
797
- } else if (!e.shiftKey && document.activeElement === last) {
798
- e.preventDefault();
799
- first.focus();
792
+ }
793
+ onKeyDown={
794
+ keyboardDayNavigation && !day.isDisabled
795
+ ? (e) => {
796
+ // Let Enter/Space on a focused chip activate the chip.
797
+ if (e.target !== e.currentTarget) return;
798
+ if (e.key === "Enter" || e.key === " ") {
799
+ e.preventDefault();
800
+ onPressDay?.(day.date);
801
+ }
800
802
  }
801
- }}
802
- {...slot("morePopover", {
803
- base: {
804
- position: "absolute",
805
- top: 2,
806
- left: 2,
807
- right: 2,
808
- zIndex: 10,
809
- display: "flex",
810
- flexDirection: "column",
811
- gap: 2,
812
- maxHeight: 240,
813
- overflowY: "auto",
814
- },
815
- themed: {
816
- background: theme.surface,
817
- border: `1px solid ${theme.gridLine}`,
818
- borderRadius: 8,
819
- padding: 6,
820
- boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
821
- },
822
- })}
823
- >
824
- <div style={{ fontSize: 11, fontWeight: 600, color: theme.textMuted }}>
825
- {dayLabel}
826
- </div>
827
- {dayEvents.map((event, i) => (
803
+ : undefined
804
+ }
805
+ >
806
+ {band ? <span data-band aria-hidden {...slot("rangeBand", band)} /> : null}
807
+ <span {...dayData} {...slot("dayBadge", compactBadgeDefault(day, theme))}>
808
+ {day.label}
809
+ </span>
810
+ {/* Spanning bars that start in this column: absolutely placed,
811
+ overflowing right across the days they span. Rendered here
812
+ (not a row overlay) so each bar is valid content of its
813
+ start day's gridcell and reads with that day. Made
814
+ non-interactive mid drag-create so a sweep reaches the
815
+ cells beneath. */}
816
+ {barSegs
817
+ .filter((b) => b.startCol === dayCol)
818
+ .map((b) => {
819
+ const span = b.endCol - b.startCol + 1;
820
+ return (
828
821
  <button
829
- key={i}
822
+ key={`bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`}
830
823
  type="button"
831
- onClick={() => {
832
- setMoreOpenFor(null);
833
- onPressEvent?.(event);
824
+ onClick={(e) => {
825
+ e.stopPropagation();
826
+ onPressEvent?.(b.seg.event);
834
827
  }}
828
+ {...barChipButton}
829
+ title={b.seg.event.title}
830
+ aria-label={
831
+ eventAccessibilityLabel
832
+ ? eventAccessibilityLabel(b.seg.event, {
833
+ mode: "month",
834
+ isAllDay: isAllDayEvent(b.seg.event),
835
+ ampm: false,
836
+ })
837
+ : `${b.seg.event.title}, ${dayLabel}`
838
+ }
835
839
  style={{
836
- display: "block",
837
- width: "100%",
838
- border: "none",
839
- background: "transparent",
840
- padding: 0,
841
- font: "inherit",
842
- textAlign: "left",
843
- cursor: "pointer",
840
+ ...barChipButton.style,
841
+ position: "absolute",
842
+ left: 2,
843
+ width: `calc(${span * 100}% - 4px)`,
844
+ top:
845
+ CELL_PAD +
846
+ DATE_ROW +
847
+ CHIP_GAP +
848
+ b.seg.lane * (CHIP_HEIGHT + CHIP_GAP),
849
+ height: CHIP_HEIGHT,
850
+ pointerEvents: isCreating ? "none" : "auto",
851
+ zIndex: 2,
844
852
  }}
845
853
  >
846
854
  {Chip ? (
847
- <Chip event={event} onPress={() => onPressEvent?.(event)} />
855
+ <Chip
856
+ event={b.seg.event}
857
+ onPress={() => onPressEvent?.(b.seg.event)}
858
+ />
848
859
  ) : (
849
- <span {...slot("chip", chipDefault(theme))}>{event.title}</span>
860
+ <span
861
+ {...barChip}
862
+ style={{
863
+ ...barChip.style,
864
+ ...(b.continuesBefore
865
+ ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 }
866
+ : null),
867
+ ...(b.continuesAfter
868
+ ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 }
869
+ : null),
870
+ }}
871
+ >
872
+ {b.seg.event.title}
873
+ </span>
850
874
  )}
851
875
  </button>
852
- ))}
853
- </div>
854
- ) : null}
876
+ );
877
+ })}
878
+ <div
879
+ {...slot("events", {
880
+ base: { display: "flex", flexDirection: "column", gap: CHIP_GAP },
881
+ })}
882
+ >
883
+ {/* Reserve one row per visible lane so the absolute bars have
884
+ space and "+more" sits below them. */}
885
+ {Array.from({ length: visibleLanes }, (_, i) => (
886
+ <div key={`lane-${i}`} aria-hidden style={{ height: CHIP_HEIGHT }} />
887
+ ))}
888
+ {hiddenEvents.length > 0 ? (
889
+ <button
890
+ type="button"
891
+ // In built-in-popover mode, keep the document
892
+ // pointerdown dismiss from firing before this click's
893
+ // toggle, so pressing the button again closes it.
894
+ onPointerDown={onPressMore ? undefined : (e) => e.stopPropagation()}
895
+ onClick={(e) => {
896
+ e.stopPropagation();
897
+ if (onPressMore) onPressMore(hiddenEvents, day.date);
898
+ else {
899
+ moreTriggerRef.current = e.currentTarget;
900
+ setMoreOpenFor((open) => (open === day.id ? null : day.id));
901
+ }
902
+ }}
903
+ {...slot("more", moreButtonDefault(theme))}
904
+ aria-label={`${hiddenEvents.length} more events, ${dayLabel}`}
905
+ aria-expanded={onPressMore ? undefined : moreOpenFor === day.id}
906
+ >
907
+ {moreLabel.replace("{moreCount}", String(hiddenEvents.length))}
908
+ </button>
909
+ ) : null}
910
+ {moreOpenFor === day.id ? (
911
+ <div
912
+ ref={morePopoverRef}
913
+ // A non-modal dialog: Tab stays inside and Escape closes,
914
+ // but the page behind is not inert (outside clicks work),
915
+ // so no aria-modal claim.
916
+ role="dialog"
917
+ aria-label={dayLabel}
918
+ onPointerDown={(e) => e.stopPropagation()}
919
+ // Contain Tab inside the dialog; Escape (handled on the
920
+ // document) closes it and restores focus to the trigger.
921
+ onKeyDown={(e) => {
922
+ if (e.key !== "Tab") return;
923
+ const buttons =
924
+ morePopoverRef.current?.querySelectorAll<HTMLElement>("button");
925
+ if (!buttons?.length) return;
926
+ const first = buttons[0];
927
+ const last = buttons[buttons.length - 1];
928
+ if (e.shiftKey && document.activeElement === first) {
929
+ e.preventDefault();
930
+ last.focus();
931
+ } else if (!e.shiftKey && document.activeElement === last) {
932
+ e.preventDefault();
933
+ first.focus();
934
+ }
935
+ }}
936
+ {...slot("morePopover", {
937
+ base: {
938
+ position: "absolute",
939
+ top: 2,
940
+ left: 2,
941
+ right: 2,
942
+ zIndex: 10,
943
+ display: "flex",
944
+ flexDirection: "column",
945
+ gap: 2,
946
+ maxHeight: 240,
947
+ overflowY: "auto",
948
+ },
949
+ themed: {
950
+ background: theme.surface,
951
+ border: `1px solid ${theme.gridLine}`,
952
+ borderRadius: 8,
953
+ padding: 6,
954
+ boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
955
+ },
956
+ })}
957
+ >
958
+ <div style={{ fontSize: 11, fontWeight: 600, color: theme.textMuted }}>
959
+ {dayLabel}
960
+ </div>
961
+ {dayEvents.map((event, i) => (
962
+ <button
963
+ key={i}
964
+ type="button"
965
+ onClick={() => {
966
+ setMoreOpenFor(null);
967
+ onPressEvent?.(event);
968
+ }}
969
+ style={{
970
+ display: "block",
971
+ width: "100%",
972
+ border: "none",
973
+ background: "transparent",
974
+ padding: 0,
975
+ font: "inherit",
976
+ textAlign: "left",
977
+ cursor: "pointer",
978
+ }}
979
+ >
980
+ {Chip ? (
981
+ <Chip event={event} onPress={() => onPressEvent?.(event)} />
982
+ ) : (
983
+ <span {...slot("chip", chipDefault(theme))}>{event.title}</span>
984
+ )}
985
+ </button>
986
+ ))}
987
+ </div>
988
+ ) : null}
989
+ </div>
855
990
  </div>
856
- </div>
857
- );
858
- }
991
+ );
992
+ }
859
993
 
860
- return (
861
- <button
862
- key={day.id}
863
- type="button"
864
- role="gridcell"
865
- data-day={day.id}
866
- {...dayData}
867
- tabIndex={day.id === focusKey ? 0 : -1}
868
- aria-disabled={day.isDisabled || undefined}
869
- aria-label={label}
870
- aria-pressed={day.isSelected || day.isInRange}
871
- {...slot("day", dayCellDefault(day, theme))}
872
- onClick={day.isDisabled ? undefined : () => onPressDay?.(day.date)}
873
- onMouseEnter={day.isDisabled ? undefined : () => setHoveredKey(day.id)}
874
- onMouseLeave={() => setHoveredKey((k) => (k === day.id ? null : k))}
875
- >
876
- {band ? <span data-band aria-hidden {...slot("rangeBand", band)} /> : null}
877
- <span
994
+ return (
995
+ <button
996
+ key={day.id}
997
+ type="button"
998
+ role="gridcell"
999
+ data-day={day.id}
878
1000
  {...dayData}
879
- {...slot("dayBadge", badgeDefault(day, theme, hoveredKey === day.id))}
1001
+ tabIndex={day.id === focusKey ? 0 : -1}
1002
+ aria-disabled={day.isDisabled || undefined}
1003
+ aria-label={label}
1004
+ aria-pressed={day.isSelected || day.isInRange}
1005
+ {...slot("day", dayCellDefault(day, theme))}
1006
+ onClick={day.isDisabled ? undefined : () => onPressDay?.(day.date)}
1007
+ onMouseEnter={day.isDisabled ? undefined : () => setHoveredKey(day.id)}
1008
+ onMouseLeave={() => setHoveredKey((k) => (k === day.id ? null : k))}
880
1009
  >
881
- {day.label}
882
- </span>
883
- </button>
884
- );
885
- })}
886
- </div>
887
- ))}
1010
+ {band ? <span data-band aria-hidden {...slot("rangeBand", band)} /> : null}
1011
+ <span
1012
+ {...dayData}
1013
+ {...slot("dayBadge", badgeDefault(day, theme, hoveredKey === day.id))}
1014
+ >
1015
+ {day.label}
1016
+ </span>
1017
+ </button>
1018
+ );
1019
+ })}
1020
+ </div>
1021
+ );
1022
+ })}
888
1023
  </div>
889
1024
  </div>
890
1025
  );