@klinking/colander 3.1.0-alpha.3 → 3.1.0-alpha.5

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.
Files changed (51) hide show
  1. package/dist/formats/date.cjs +1 -1
  2. package/dist/formats/date.d.cts +1 -1
  3. package/dist/formats/date.d.mts +1 -1
  4. package/dist/formats/date.mjs +1 -1
  5. package/dist/formats/object.cjs +1 -1
  6. package/dist/formats/object.d.cts +1 -1
  7. package/dist/formats/object.d.mts +1 -1
  8. package/dist/formats/object.mjs +1 -1
  9. package/dist/formats/plain-date-time.cjs +1 -1
  10. package/dist/formats/plain-date-time.d.cts +1 -1
  11. package/dist/formats/plain-date-time.d.mts +1 -1
  12. package/dist/formats/plain-date-time.mjs +1 -1
  13. package/dist/formats/plain-date.cjs +1 -1
  14. package/dist/formats/plain-date.d.cts +1 -1
  15. package/dist/formats/plain-date.d.mts +1 -1
  16. package/dist/formats/plain-date.mjs +1 -1
  17. package/dist/formats/plain-month-day.cjs +1 -1
  18. package/dist/formats/plain-month-day.d.cts +1 -1
  19. package/dist/formats/plain-month-day.d.mts +1 -1
  20. package/dist/formats/plain-month-day.mjs +1 -1
  21. package/dist/formats/plain-year-month.cjs +1 -1
  22. package/dist/formats/plain-year-month.d.cts +1 -1
  23. package/dist/formats/plain-year-month.d.mts +1 -1
  24. package/dist/formats/plain-year-month.mjs +1 -1
  25. package/dist/formats/zoned-date-time.cjs +1 -1
  26. package/dist/formats/zoned-date-time.d.cts +1 -1
  27. package/dist/formats/zoned-date-time.d.mts +1 -1
  28. package/dist/formats/zoned-date-time.mjs +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +1 -1
  31. package/dist/index.d.mts +1 -1
  32. package/dist/index.mjs +1 -1
  33. package/dist/{weeks-navigation-DEaASUAh.mjs → weeks-navigation-CEV8w_69.mjs} +239 -221
  34. package/dist/{weeks-navigation-DvryOSWF.cjs → weeks-navigation-q3beZn2n.cjs} +239 -221
  35. package/dist/{weeks-view-context-CNAq2Hiu.d.cts → weeks-view-context-BLZZm1fq.d.mts} +33 -2
  36. package/dist/{weeks-view-context-CsP3PBiu.d.mts → weeks-view-context-CkTcdZpj.d.cts} +33 -2
  37. package/package.json +1 -1
  38. package/src/calendar-provider.tsx +6 -0
  39. package/src/calendar-types.ts +2 -0
  40. package/src/day-cell.tsx +8 -1
  41. package/src/month-view-navigation.ts +180 -0
  42. package/src/month-view-types.ts +3 -0
  43. package/src/month-view.bounds.test.tsx +136 -0
  44. package/src/month-view.tsx +41 -217
  45. package/src/month-window.test.ts +207 -0
  46. package/src/month-window.ts +93 -0
  47. package/src/navigation.tsx +15 -74
  48. package/src/today.test.tsx +98 -0
  49. package/src/utils.test.ts +25 -0
  50. package/src/utils.ts +17 -0
  51. package/src/weeks-view-state.ts +8 -15
@@ -1,7 +1,7 @@
1
- import * as _$react from "react";
2
- import React$1 from "react";
3
1
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
2
  import { useRender } from "@base-ui/react/use-render";
3
+ import * as _$react from "react";
4
+ import React$1 from "react";
5
5
 
6
6
  //#region ../node_modules/.pnpm/@js-temporal+polyfill@0.5.1/node_modules/@js-temporal/polyfill/index.d.ts
7
7
  declare namespace Temporal {
@@ -1505,6 +1505,8 @@ interface CalendarStableContextValue {
1505
1505
  maxValue?: Temporal.PlainDate;
1506
1506
  /** Resolved IANA time zone. */
1507
1507
  timeZone: string;
1508
+ /** Today's date in the resolved {@link timeZone}. Reads the clock on every call. */
1509
+ today: () => Temporal.PlainDate;
1508
1510
  /** Resolved BCP 47 locale. */
1509
1511
  locale: string;
1510
1512
  /** Resolved Temporal namespace. */
@@ -1594,6 +1596,33 @@ type OutOfRangeBehavior = "unbounded" | "stop" | "stop-shrink" | "snap" | "snap-
1594
1596
  */
1595
1597
  type MonthOutOfRangeBehavior = "unbounded" | "stop";
1596
1598
  //#endregion
1599
+ //#region src/month-window.d.ts
1600
+ /** An ISO year + month. */
1601
+ interface MonthRef {
1602
+ year: number;
1603
+ month: number;
1604
+ }
1605
+ /** One step of the visible month window. */
1606
+ interface MonthStep {
1607
+ /** The window's first month after the step. */
1608
+ start: MonthRef;
1609
+ /** The month that enters view (before the window for `prev`, after it for `next`). */
1610
+ entering: MonthRef;
1611
+ /** First day of `start`, the focus target when focus isn't already in `start`. */
1612
+ firstDay: Temporal.PlainDate;
1613
+ /** Whether `stop` forbids the step because `entering` lies beyond `min`/`max`. */
1614
+ blocked: boolean;
1615
+ }
1616
+ /** The one seam for moving the MonthView window. */
1617
+ interface MonthWindowPolicy {
1618
+ /** Steps the window one month towards `direction`. */
1619
+ step(start: MonthRef, direction: "prev" | "next"): MonthStep;
1620
+ /** Whether `target` is inside the window starting at `start`. */
1621
+ isVisible(start: MonthRef, target: MonthRef): boolean;
1622
+ /** The window start that reveals `target` with the smallest shift. */
1623
+ reveal(start: MonthRef, target: MonthRef): MonthRef;
1624
+ }
1625
+ //#endregion
1597
1626
  //#region src/month-view-types.d.ts
1598
1627
  /** Props accepted by `MonthView.Root`. */
1599
1628
  interface MonthViewRootProps {
@@ -1655,6 +1684,8 @@ interface MonthViewStableContextValue {
1655
1684
  outsideDays: OutsideDays;
1656
1685
  /** How month navigation behaves at bounds. */
1657
1686
  outOfRangeBehavior: MonthOutOfRangeBehavior;
1687
+ /** Steps and reveals the visible month window. */
1688
+ windowPolicy: MonthWindowPolicy;
1658
1689
  /** Navigate to the next month(s). */
1659
1690
  goNextMonth: () => void;
1660
1691
  /** Navigate to the previous month(s). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klinking/colander",
3
- "version": "3.1.0-alpha.3",
3
+ "version": "3.1.0-alpha.5",
4
4
  "homepage": "https://github.com/klink-ing/colander#readme",
5
5
  "bugs": "https://github.com/klink-ing/colander/issues",
6
6
  "license": "MIT",
@@ -55,6 +55,10 @@ function CalendarProvider<F extends ValueFormat = "PlainDate">(
55
55
  const locale = localeProp ?? "en-US";
56
56
  const timeZone = timeZoneProp ?? getSystemTimeZone(T);
57
57
  const weekStartDay = weekStartDayProp ?? 0;
58
+ const today = useCallback(
59
+ () => T.Now.zonedDateTimeISO(timeZone).toPlainDate(),
60
+ [T, timeZone],
61
+ );
58
62
  const resolvedFormat = (formatProp ?? "PlainDate") as F;
59
63
  const selectionMode = selectionModeProp ?? "single";
60
64
  const disabled = disabledProp ?? false;
@@ -604,6 +608,7 @@ function CalendarProvider<F extends ValueFormat = "PlainDate">(
604
608
  ...(minValue !== undefined && { minValue }),
605
609
  ...(maxValue !== undefined && { maxValue }),
606
610
  timeZone,
611
+ today,
607
612
  locale,
608
613
  temporal: T,
609
614
  weekStartDay,
@@ -622,6 +627,7 @@ function CalendarProvider<F extends ValueFormat = "PlainDate">(
622
627
  minValue,
623
628
  maxValue,
624
629
  timeZone,
630
+ today,
625
631
  locale,
626
632
  T,
627
633
  weekStartDay,
@@ -188,6 +188,8 @@ export interface CalendarStableContextValue {
188
188
  maxValue?: Temporal.PlainDate;
189
189
  /** Resolved IANA time zone. */
190
190
  timeZone: string;
191
+ /** Today's date in the resolved {@link timeZone}. Reads the clock on every call. */
192
+ today: () => Temporal.PlainDate;
191
193
  /** Resolved BCP 47 locale. */
192
194
  locale: string;
193
195
  /** Resolved Temporal namespace. */
package/src/day-cell.tsx CHANGED
@@ -31,6 +31,7 @@ export function computeDayCellState(
31
31
  rangeStart: TemporalPoly.PlainDate | undefined,
32
32
  rangeEnd: TemporalPoly.PlainDate | undefined,
33
33
  tabTargetDate: TemporalPoly.PlainDate,
34
+ today: TemporalPoly.PlainDate,
34
35
  T: TemporalNamespace,
35
36
  selectionMode: "single" | "range" | "multiple",
36
37
  outsideDays: OutsideDays,
@@ -73,7 +74,6 @@ export function computeDayCellState(
73
74
  };
74
75
  }
75
76
 
76
- const today = T.Now.plainDateISO();
77
77
  const isToday = T.PlainDate.compare(date, today) === 0;
78
78
  const isRange = selectionMode === "range";
79
79
 
@@ -389,8 +389,10 @@ export function DayCellTemplate(props: DayCellTemplateProps) {
389
389
  isDateDisabled,
390
390
  selectionMode,
391
391
  temporal: T,
392
+ today,
392
393
  weekStartDay,
393
394
  } = useCalendarStable();
395
+ const todayDate = today();
394
396
 
395
397
  const { selectedDates, rangeStart, rangeEnd, previewStart, previewEnd } =
396
398
  useCalendarState();
@@ -429,6 +431,7 @@ export function DayCellTemplate(props: DayCellTemplateProps) {
429
431
  rangeStart,
430
432
  rangeEnd,
431
433
  tabTargetDate,
434
+ todayDate,
432
435
  T,
433
436
  selectionMode,
434
437
  outsideDays,
@@ -464,6 +467,7 @@ export function DayCellTemplate(props: DayCellTemplateProps) {
464
467
  rangeStart,
465
468
  rangeEnd,
466
469
  tabTargetDate,
470
+ todayDate,
467
471
  T,
468
472
  selectionMode,
469
473
  outsideDays,
@@ -659,8 +663,10 @@ function DayButtonFallbackFn(
659
663
  isDateDisabled,
660
664
  selectionMode,
661
665
  temporal: T,
666
+ today,
662
667
  weekStartDay,
663
668
  } = useCalendarStable();
669
+ const todayDate = today();
664
670
  const { selectedDates, rangeStart, rangeEnd, previewStart, previewEnd } =
665
671
  useCalendarState();
666
672
  const viewCtx = useViewContext();
@@ -688,6 +694,7 @@ function DayButtonFallbackFn(
688
694
  rangeStart,
689
695
  rangeEnd,
690
696
  tabTargetDate,
697
+ todayDate,
691
698
  T,
692
699
  selectionMode,
693
700
  outsideDays,
@@ -0,0 +1,180 @@
1
+ import type { Temporal } from "@js-temporal/polyfill";
2
+ import type { Dispatch, SetStateAction } from "react";
3
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
+ import type { MonthRef, MonthWindowPolicy } from "./month-window";
5
+ import type { TemporalNamespace } from "./types";
6
+ import { focusedDateForMonth } from "./utils";
7
+
8
+ export interface UseMonthNavigationInput {
9
+ /** Controlled first visible month. */
10
+ month: MonthRef | undefined;
11
+ /** Initial first visible month when uncontrolled. */
12
+ defaultMonth: MonthRef | undefined;
13
+ /** Date the view opens on when neither `month` nor `defaultMonth` is given. */
14
+ initialAnchor: () => Temporal.PlainDate;
15
+ onMonthChange: ((month: Temporal.PlainYearMonth) => void) | undefined;
16
+ policy: MonthWindowPolicy;
17
+ focusedDate: Temporal.PlainDate;
18
+ setFocusedDate: Dispatch<SetStateAction<Temporal.PlainDate>>;
19
+ T: TemporalNamespace;
20
+ }
21
+
22
+ export interface MonthNavigation {
23
+ /** The first visible month. */
24
+ currentMonth: MonthRef;
25
+ /** The first visible month as an ISO `PlainYearMonth`. */
26
+ viewingYearMonth: Temporal.PlainYearMonth;
27
+ goNextMonth: () => void;
28
+ goPrevMonth: () => void;
29
+ }
30
+
31
+ /**
32
+ * Owns which month the view shows, in both controlled and uncontrolled mode:
33
+ * the month state, the Prev/Next steps, and syncing the window with focus.
34
+ *
35
+ * `onMonthChange` fires exactly once per move: from the effect below when
36
+ * uncontrolled, and from the step or the focus-sync effect when controlled.
37
+ */
38
+ export function useMonthNavigation(
39
+ input: UseMonthNavigationInput,
40
+ ): MonthNavigation {
41
+ const {
42
+ month,
43
+ defaultMonth,
44
+ initialAnchor,
45
+ onMonthChange,
46
+ policy,
47
+ focusedDate,
48
+ setFocusedDate,
49
+ T,
50
+ } = input;
51
+
52
+ const isControlled = month !== undefined;
53
+
54
+ const [internalMonth, setInternalMonth] = useState<MonthRef>(() => {
55
+ if (month) return { year: month.year, month: month.month };
56
+ if (defaultMonth)
57
+ return { year: defaultMonth.year, month: defaultMonth.month };
58
+ const anchor = initialAnchor();
59
+ return { year: anchor.year, month: anchor.month };
60
+ });
61
+
62
+ const year = isControlled ? month.year : internalMonth.year;
63
+ const monthNumber = isControlled ? month.month : internalMonth.month;
64
+ const currentMonth = useMemo<MonthRef>(
65
+ () => ({ year, month: monthNumber }),
66
+ [year, monthNumber],
67
+ );
68
+
69
+ // ISO — the locale calendar only affects display, not this value.
70
+ const viewingYearMonth = useMemo(
71
+ () => T.PlainYearMonth.from({ year, month: monthNumber }),
72
+ [year, monthNumber, T],
73
+ );
74
+
75
+ // Always-current ref so callbacks/effects don't re-subscribe on every
76
+ // onMonthChange identity change.
77
+ const onMonthChangeRef = useRef(onMonthChange);
78
+ onMonthChangeRef.current = onMonthChange;
79
+
80
+ // Request the parent move the view to `{year, month}` (controlled mode).
81
+ // Built in ISO — `year`/`month` are ISO numbers, and the locale calendar
82
+ // only affects display (see MonthYearString). Passing `calendar` here would
83
+ // reinterpret the ISO numbers as locale-calendar fields (e.g. Buddhist),
84
+ // shifting the value by centuries.
85
+ const notifyMonth = useCallback(
86
+ (target: MonthRef) => {
87
+ onMonthChangeRef.current?.(T.PlainYearMonth.from(target));
88
+ },
89
+ [T],
90
+ );
91
+
92
+ // Button navigation in controlled mode notifies the parent directly, then
93
+ // moves focus into the target month. This ref holds that focus value so the
94
+ // focus-sync effect skips re-notifying for it. Keyed by the value (not a
95
+ // one-shot flag) so it can't strand and suppress a later keyboard crossing
96
+ // if the button's focus move is a no-op or the parent ignores the change.
97
+ const skipFocusSyncForRef = useRef<Temporal.PlainDate | null>(null);
98
+ const prevFocusedRef = useRef(focusedDate);
99
+
100
+ // Clear a stale skip target whenever the parent actually moves the view.
101
+ useEffect(() => {
102
+ skipFocusSyncForRef.current = null;
103
+ }, [month?.year, month?.month]);
104
+
105
+ // Sync month when the focused date crosses a month boundary. Uncontrolled:
106
+ // shift internal state. Controlled: ask the parent to move the view, but
107
+ // only when focus actually moved out of the visible window (keyboard nav) —
108
+ // never as an echo of an external `month` update or a button click.
109
+ useEffect(() => {
110
+ const prevFocused = prevFocusedRef.current;
111
+ prevFocusedRef.current = focusedDate;
112
+ const target = { year: focusedDate.year, month: focusedDate.month };
113
+ if (isControlled) {
114
+ if (skipFocusSyncForRef.current === focusedDate) {
115
+ skipFocusSyncForRef.current = null;
116
+ return;
117
+ }
118
+ if (prevFocused === focusedDate) return;
119
+ if (policy.isVisible(currentMonth, target)) return;
120
+ // Emit the minimally-shifted first-visible month (what the parent binds
121
+ // to `month`), not the focused month — so a controlled window scrolls by
122
+ // the minimum, matching uncontrolled mode and the nav buttons.
123
+ notifyMonth(policy.reveal(currentMonth, target));
124
+ return;
125
+ }
126
+ setInternalMonth((prev) => {
127
+ const next = policy.reveal(prev, target);
128
+ if (next.year === prev.year && next.month === prev.month) return prev;
129
+ return next;
130
+ });
131
+ }, [focusedDate, isControlled, policy, currentMonth, notifyMonth]);
132
+
133
+ // Fire onMonthChange when uncontrolled navigation moves the view (not on
134
+ // mount). In controlled mode the parent owns `month`, so notification flows
135
+ // from the steps and the focus-sync effect instead; firing here would just
136
+ // echo the parent's own update back to it.
137
+ const mountedRef = useRef(false);
138
+ useEffect(() => {
139
+ if (!mountedRef.current) {
140
+ mountedRef.current = true;
141
+ return;
142
+ }
143
+ if (isControlled) return;
144
+ onMonthChangeRef.current?.(viewingYearMonth);
145
+ }, [viewingYearMonth, isControlled]);
146
+
147
+ const go = useCallback(
148
+ (direction: "prev" | "next") => {
149
+ if (isControlled) {
150
+ const step = policy.step(month, direction);
151
+ if (step.blocked) return;
152
+ // Notify the parent directly; the follow-on focus move is suppressed in
153
+ // the focus-sync effect (keyed on the value) so onMonthChange fires once.
154
+ const nextFocus = focusedDateForMonth(
155
+ focusedDate,
156
+ step.start,
157
+ step.firstDay,
158
+ );
159
+ skipFocusSyncForRef.current = nextFocus;
160
+ notifyMonth(step.start);
161
+ setFocusedDate(nextFocus);
162
+ return;
163
+ }
164
+ setInternalMonth((m) => {
165
+ const step = policy.step(m, direction);
166
+ if (step.blocked) return m;
167
+ setFocusedDate((prev) =>
168
+ focusedDateForMonth(prev, step.start, step.firstDay),
169
+ );
170
+ return step.start;
171
+ });
172
+ },
173
+ [isControlled, month, policy, notifyMonth, focusedDate, setFocusedDate],
174
+ );
175
+
176
+ const goNextMonth = useCallback(() => go("next"), [go]);
177
+ const goPrevMonth = useCallback(() => go("prev"), [go]);
178
+
179
+ return { currentMonth, viewingYearMonth, goNextMonth, goPrevMonth };
180
+ }
@@ -1,4 +1,5 @@
1
1
  import type { Temporal } from "@js-temporal/polyfill";
2
+ import type { MonthWindowPolicy } from "./month-window";
2
3
  import type { MonthOutOfRangeBehavior } from "./out-of-range";
3
4
  import type { MonthData, OutsideDays, RootState } from "./types";
4
5
 
@@ -71,6 +72,8 @@ export interface MonthViewStableContextValue {
71
72
  outsideDays: OutsideDays;
72
73
  /** How month navigation behaves at bounds. */
73
74
  outOfRangeBehavior: MonthOutOfRangeBehavior;
75
+ /** Steps and reveals the visible month window. */
76
+ windowPolicy: MonthWindowPolicy;
74
77
  /** Navigate to the next month(s). */
75
78
  goNextMonth: () => void;
76
79
  /** Navigate to the previous month(s). */
@@ -0,0 +1,136 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { act, cleanup, render, screen } from "@testing-library/react";
3
+ import { afterEach, describe, expect, it, vi } from "vitest";
4
+ import { MonthView } from "./month-view";
5
+ import type { MonthViewProps } from "./month-view";
6
+ import { useMonthViewStable, useMonthViewState } from "./month-view-context";
7
+ import { useViewContext } from "./view-context";
8
+
9
+ const T = Temporal;
10
+
11
+ let go: { next: () => void; prev: () => void };
12
+
13
+ function Probe() {
14
+ const { goNextMonth, goPrevMonth } = useMonthViewStable();
15
+ const { currentMonth } = useMonthViewState();
16
+ const { focusedDate } = useViewContext();
17
+ go = { next: goNextMonth, prev: goPrevMonth };
18
+ return (
19
+ <>
20
+ <span data-testid="month">
21
+ {currentMonth.year}-{String(currentMonth.month).padStart(2, "0")}
22
+ </span>
23
+ <span data-testid="focus">{focusedDate.toString()}</span>
24
+ </>
25
+ );
26
+ }
27
+
28
+ const base = {
29
+ temporal: T,
30
+ timeZone: "UTC",
31
+ defaultValue: T.PlainDate.from("2026-03-15"),
32
+ } as const;
33
+
34
+ const month = () => screen.getByTestId("month").textContent;
35
+ const focus = () => screen.getByTestId("focus").textContent;
36
+
37
+ afterEach(cleanup);
38
+
39
+ describe("MonthView goNextMonth/goPrevMonth honor outOfRangeBehavior", () => {
40
+ it.each([
41
+ {
42
+ description: "stop: goPrevMonth into the min month moves",
43
+ props: {
44
+ min: T.PlainDate.from("2026-02-10"),
45
+ outOfRangeBehavior: "stop",
46
+ },
47
+ call: "prev" as const,
48
+ expected: { month: "2026-02", focus: "2026-02-01" },
49
+ },
50
+ {
51
+ description: "stop: goPrevMonth before the min month does nothing",
52
+ props: {
53
+ min: T.PlainDate.from("2026-03-10"),
54
+ outOfRangeBehavior: "stop",
55
+ },
56
+ call: "prev" as const,
57
+ expected: { month: "2026-03", focus: "2026-03-15" },
58
+ },
59
+ {
60
+ description: "stop: goNextMonth past the max month does nothing",
61
+ props: {
62
+ max: T.PlainDate.from("2026-03-20"),
63
+ outOfRangeBehavior: "stop",
64
+ },
65
+ call: "next" as const,
66
+ expected: { month: "2026-03", focus: "2026-03-15" },
67
+ },
68
+ {
69
+ description: "stop: goNextMonth with only min set still moves",
70
+ props: {
71
+ min: T.PlainDate.from("2026-03-10"),
72
+ outOfRangeBehavior: "stop",
73
+ },
74
+ call: "next" as const,
75
+ expected: { month: "2026-04", focus: "2026-04-01" },
76
+ },
77
+ {
78
+ description: "unbounded: goNextMonth moves past max",
79
+ props: { max: T.PlainDate.from("2026-03-20") },
80
+ call: "next" as const,
81
+ expected: { month: "2026-04", focus: "2026-04-01" },
82
+ },
83
+ ] satisfies {
84
+ description: string;
85
+ props: Partial<MonthViewProps>;
86
+ call: "next" | "prev";
87
+ expected: { month: string; focus: string };
88
+ }[])("uncontrolled, $description", ({ props, call, expected }) => {
89
+ render(
90
+ <MonthView {...base} {...props}>
91
+ <Probe />
92
+ </MonthView>,
93
+ );
94
+
95
+ act(() => go[call]());
96
+
97
+ expect({ month: month(), focus: focus() }).toEqual(expected);
98
+ });
99
+
100
+ it.each([
101
+ {
102
+ description: "stop: blocked step does not notify the parent",
103
+ props: {
104
+ max: T.PlainDate.from("2026-03-20"),
105
+ outOfRangeBehavior: "stop",
106
+ },
107
+ expected: { calls: 0 },
108
+ },
109
+ {
110
+ description: "unbounded: step notifies the parent once",
111
+ props: { max: T.PlainDate.from("2026-03-20") },
112
+ expected: { calls: 1 },
113
+ },
114
+ ] satisfies {
115
+ description: string;
116
+ props: Partial<MonthViewProps>;
117
+ expected: { calls: number };
118
+ }[])("controlled, $description", ({ props, expected }) => {
119
+ const onMonthChange = vi.fn();
120
+ render(
121
+ <MonthView
122
+ {...base}
123
+ {...props}
124
+ month={T.PlainYearMonth.from("2026-03")}
125
+ onMonthChange={onMonthChange}
126
+ >
127
+ <Probe />
128
+ </MonthView>,
129
+ );
130
+
131
+ act(() => go.next());
132
+
133
+ expect({ calls: onMonthChange.mock.calls.length }).toEqual(expected);
134
+ expect(month()).toBe("2026-03");
135
+ });
136
+ });