@klinking/colander 3.1.0-alpha.7 → 3.1.0-alpha.8

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 (61) hide show
  1. package/dist/formats/date.cjs +2 -3
  2. package/dist/formats/date.d.cts +10 -14
  3. package/dist/formats/date.d.mts +10 -14
  4. package/dist/formats/date.mjs +2 -3
  5. package/dist/formats/object.cjs +2 -3
  6. package/dist/formats/object.d.cts +10 -14
  7. package/dist/formats/object.d.mts +10 -14
  8. package/dist/formats/object.mjs +2 -3
  9. package/dist/formats/plain-date-time.cjs +2 -3
  10. package/dist/formats/plain-date-time.d.cts +10 -14
  11. package/dist/formats/plain-date-time.d.mts +10 -14
  12. package/dist/formats/plain-date-time.mjs +2 -3
  13. package/dist/formats/plain-date.cjs +2 -3
  14. package/dist/formats/plain-date.d.cts +10 -14
  15. package/dist/formats/plain-date.d.mts +10 -14
  16. package/dist/formats/plain-date.mjs +2 -3
  17. package/dist/formats/plain-month-day.cjs +2 -3
  18. package/dist/formats/plain-month-day.d.cts +10 -14
  19. package/dist/formats/plain-month-day.d.mts +10 -14
  20. package/dist/formats/plain-month-day.mjs +2 -3
  21. package/dist/formats/plain-year-month.cjs +2 -3
  22. package/dist/formats/plain-year-month.d.cts +10 -14
  23. package/dist/formats/plain-year-month.d.mts +10 -14
  24. package/dist/formats/plain-year-month.mjs +2 -3
  25. package/dist/formats/zoned-date-time.cjs +2 -3
  26. package/dist/formats/zoned-date-time.d.cts +10 -14
  27. package/dist/formats/zoned-date-time.d.mts +10 -14
  28. package/dist/formats/zoned-date-time.mjs +2 -3
  29. package/dist/{weeks-view-context-BTojXkys.d.cts → index-BqzrxYgn.d.cts} +89 -106
  30. package/dist/{weeks-view-context-CFXV8orh.d.mts → index-CkhYFmf4.d.mts} +89 -106
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +1 -10
  33. package/dist/index.d.mts +1 -10
  34. package/dist/index.mjs +1 -2
  35. package/dist/{weeks-navigation-BSKwFvdP.mjs → weeks-navigation-BWB5OvqW.mjs} +95 -111
  36. package/dist/{weeks-navigation-CPevz3Xg.cjs → weeks-navigation-CatYJIKb.cjs} +97 -114
  37. package/package.json +17 -18
  38. package/src/calendar-provider.test.tsx +1 -1
  39. package/src/compute-weeks-in-window.test.ts +1 -1
  40. package/src/day-cell-state.test.ts +1 -1
  41. package/src/day-cell.test.tsx +1 -1
  42. package/src/formats/formats.test.ts +1 -1
  43. package/src/grid.event-perf.test.tsx +7 -1
  44. package/src/grid.perf.test.tsx +7 -1
  45. package/src/keyboard.test.ts +1 -1
  46. package/src/month-separator.test.tsx +1 -1
  47. package/src/month-view.bounds.test.tsx +1 -1
  48. package/src/month-view.test.tsx +89 -1
  49. package/src/month-view.tsx +14 -5
  50. package/src/month-window.test.ts +1 -1
  51. package/src/out-of-range.test.ts +1 -1
  52. package/src/range-preview.test.ts +1 -1
  53. package/src/resolve-first-week.test.ts +1 -1
  54. package/src/today.test.tsx +8 -1
  55. package/src/utils.bench.ts +158 -106
  56. package/src/utils.test.ts +1 -1
  57. package/src/view-context.test.tsx +1 -1
  58. package/src/weeks-keyboard.test.ts +1 -1
  59. package/src/weeks-view.bounds.test.tsx +1 -1
  60. package/src/weeks-view.test.tsx +1 -1
  61. package/src/weeks-window.test.ts +1 -1
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import { render, act } from "@testing-library/react";
3
3
  import { useState } from "react";
4
4
  // @vitest-environment jsdom
5
- import { describe, it, expect, vi } from "vitest";
5
+ import { describe, it, expect, vi } from "vite-plus/test";
6
6
  import { useCalendarStable } from "./calendar-context";
7
7
  import { Grid } from "./grid";
8
8
  import { MonthView } from "./month-view";
@@ -2092,3 +2092,91 @@ describe("outsideDays", () => {
2092
2092
  });
2093
2093
  });
2094
2094
  });
2095
+
2096
+ describe("opening month", () => {
2097
+ // 2020 dates keep the real today out of every window under test.
2098
+ const ym = (s: string) => Temporal.PlainYearMonth.from(s);
2099
+ const day = (s: string) => Temporal.PlainDate.from(s);
2100
+
2101
+ it.each([
2102
+ {
2103
+ description: "defaultMonth opens on that month, not today's",
2104
+ props: { defaultMonth: ym("2020-03") },
2105
+ keys: [],
2106
+ expected: { months: ["2020-03"], focused: "2020-03-01", monthChanges: 0 },
2107
+ },
2108
+ {
2109
+ description: "defaultMonth opens on that month in range mode",
2110
+ props: { selectionMode: "range", defaultMonth: ym("2020-03") },
2111
+ keys: [],
2112
+ expected: { months: ["2020-03"], focused: "2020-03-01", monthChanges: 0 },
2113
+ },
2114
+ {
2115
+ description: "defaultMonth wins over a defaultValue outside it",
2116
+ props: { defaultMonth: ym("2020-03"), defaultValue: day("2020-05-15") },
2117
+ keys: [],
2118
+ expected: { months: ["2020-03"], focused: "2020-03-01", monthChanges: 0 },
2119
+ },
2120
+ {
2121
+ description: "a defaultValue inside a multi-month window keeps focus",
2122
+ props: {
2123
+ defaultMonth: ym("2020-03"),
2124
+ defaultValue: day("2020-04-15"),
2125
+ numberOfMonths: 2,
2126
+ },
2127
+ keys: [],
2128
+ expected: {
2129
+ months: ["2020-03", "2020-04"],
2130
+ focused: "2020-04-15",
2131
+ monthChanges: 0,
2132
+ },
2133
+ },
2134
+ {
2135
+ description: "the first arrow key after defaultMonth moves within it",
2136
+ props: { defaultMonth: ym("2020-03") },
2137
+ keys: ["ArrowRight"],
2138
+ expected: { months: ["2020-03"], focused: "2020-03-02", monthChanges: 0 },
2139
+ },
2140
+ {
2141
+ description: "the first arrow key in a controlled month moves within it",
2142
+ props: { month: ym("2020-03") },
2143
+ keys: ["ArrowRight"],
2144
+ expected: { months: ["2020-03"], focused: "2020-03-02", monthChanges: 0 },
2145
+ },
2146
+ ])("$description", ({ props, keys, expected }) => {
2147
+ const onMonthChange = vi.fn();
2148
+ let captured: { months: string[]; focused: string } | undefined;
2149
+ const { container } = render(
2150
+ <MonthView
2151
+ {...defaultProps}
2152
+ {...(props as object)}
2153
+ onMonthChange={onMonthChange}
2154
+ >
2155
+ <Grid />
2156
+ <MonthDataCapture
2157
+ onCapture={(d) => {
2158
+ captured = {
2159
+ months: d.allMonths.map((m) =>
2160
+ Temporal.PlainYearMonth.from(m).toString(),
2161
+ ),
2162
+ focused: d.focusedDate,
2163
+ };
2164
+ }}
2165
+ />
2166
+ </MonthView>,
2167
+ );
2168
+ const grid = container.querySelector('[role="grid"]')!;
2169
+ for (const key of keys) {
2170
+ act(() => {
2171
+ grid.dispatchEvent(
2172
+ new KeyboardEvent("keydown", { key, bubbles: true }),
2173
+ );
2174
+ });
2175
+ }
2176
+
2177
+ expect({
2178
+ ...captured,
2179
+ monthChanges: onMonthChange.mock.calls.length,
2180
+ }).toEqual(expected);
2181
+ });
2182
+ });
@@ -58,11 +58,6 @@ function MonthViewRoot(props: MonthViewRootProps) {
58
58
  const T = calStable.temporal;
59
59
  const { timeZone, today, weekStartDay, isDateDisabled } = calStable;
60
60
 
61
- // --- Focus state ---
62
- const [focusedDate, setFocusedDate] = useState<Temporal.PlainDate>(() =>
63
- resolveInitialAnchor(calState.selected, today, timeZone, T),
64
- );
65
-
66
61
  const [gridHasFocus, setGridHasFocus] = useState(false);
67
62
  const gridFocusedRef = useRef(false);
68
63
 
@@ -80,6 +75,20 @@ function MonthViewRoot(props: MonthViewRootProps) {
80
75
  [numberOfMonths, outOfRangeBehavior, minValue, maxValue, T],
81
76
  );
82
77
 
78
+ // --- Focus state ---
79
+ // Focus starts inside the window the view opens on. Arrow keys move from
80
+ // the focused date, so focus outside the window would pull the view to it.
81
+ const [focusedDate, setFocusedDate] = useState<Temporal.PlainDate>(() => {
82
+ const anchor = resolveInitialAnchor(calState.selected, today, timeZone, T);
83
+ const opening = monthProp ?? defaultMonthProp;
84
+ if (!opening || windowPolicy.isVisible(opening, anchor)) return anchor;
85
+ return T.PlainDate.from({
86
+ year: opening.year,
87
+ month: opening.month,
88
+ day: 1,
89
+ });
90
+ });
91
+
83
92
  const initialAnchor = useCallback(
84
93
  () => resolveInitialAnchor(calState.selected, today, timeZone, T),
85
94
  [calState.selected, today, timeZone, T],
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, expect, it } from "vitest";
2
+ import { describe, expect, it } from "vite-plus/test";
3
3
  import { createMonthWindowPolicy } from "./month-window";
4
4
  import type { MonthWindowPolicyInput } from "./month-window";
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, it, expect } from "vitest";
2
+ import { describe, it, expect } from "vite-plus/test";
3
3
  import { applyOutOfRange, type OutOfRangeBehavior } from "./out-of-range";
4
4
 
5
5
  const T = Temporal;
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, expect, it } from "vitest";
2
+ import { describe, expect, it } from "vite-plus/test";
3
3
  import {
4
4
  computePreviewRange,
5
5
  computeRangePreview,
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, it, expect } from "vitest";
2
+ import { describe, it, expect } from "vite-plus/test";
3
3
  import { resolveFirstWeekSpec, resolveFirstWeek } from "./resolve-first-week";
4
4
 
5
5
  const T = Temporal;
@@ -1,6 +1,13 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { render, screen, cleanup } from "@testing-library/react";
3
- import { describe, it, expect, vi, afterEach, beforeEach } from "vitest";
3
+ import {
4
+ describe,
5
+ it,
6
+ expect,
7
+ vi,
8
+ afterEach,
9
+ beforeEach,
10
+ } from "vite-plus/test";
4
11
  import {
5
12
  Grid,
6
13
  GridBody,
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { bench, describe } from "vitest";
2
+ import { test, describe } from "vite-plus/test";
3
3
  import type { TemporalNamespace } from "./types";
4
4
  import {
5
5
  getMonthWeeks,
@@ -29,82 +29,112 @@ const rangeEnd = Temporal.PlainDate.from("2026-03-20");
29
29
  const midWeek = marchWeeks[2]!; // a week in the middle of the range
30
30
 
31
31
  describe("getMonthWeeks", () => {
32
- bench("generate month grid (March 2026)", () => {
33
- getMonthWeeks(2026, 3, T);
32
+ test("generate month grid (March 2026)", async ({ bench }) => {
33
+ await bench("generate month grid (March 2026)", () => {
34
+ getMonthWeeks(2026, 3, T);
35
+ }).run();
34
36
  });
35
37
 
36
- bench("generate month grid (February — short month)", () => {
37
- getMonthWeeks(2026, 2, T);
38
+ test("generate month grid (February — short month)", async ({ bench }) => {
39
+ await bench("generate month grid (February — short month)", () => {
40
+ getMonthWeeks(2026, 2, T);
41
+ }).run();
38
42
  });
39
43
 
40
- bench("generate month grid (August — 6-week grid)", () => {
41
- getMonthWeeks(2026, 8, T);
44
+ test("generate month grid (August — 6-week grid)", async ({ bench }) => {
45
+ await bench("generate month grid (August — 6-week grid)", () => {
46
+ getMonthWeeks(2026, 8, T);
47
+ }).run();
42
48
  });
43
49
  });
44
50
 
45
51
  describe("computeWeekRangeInfo", () => {
46
- bench("week fully inside range", () => {
47
- computeWeekRangeInfo(midWeek, rangeStart, rangeEnd, T);
52
+ test("week fully inside range", async ({ bench }) => {
53
+ await bench("week fully inside range", () => {
54
+ computeWeekRangeInfo(midWeek, rangeStart, rangeEnd, T);
55
+ }).run();
48
56
  });
49
57
 
50
- bench("week with no overlap", () => {
51
- const noOverlapWeek = marchWeeks[marchWeeks.length - 1]!;
52
- computeWeekRangeInfo(
53
- noOverlapWeek,
54
- Temporal.PlainDate.from("2026-03-01"),
55
- Temporal.PlainDate.from("2026-03-04"),
56
- T,
57
- );
58
+ test("week with no overlap", async ({ bench }) => {
59
+ await bench("week with no overlap", () => {
60
+ const noOverlapWeek = marchWeeks[marchWeeks.length - 1]!;
61
+ computeWeekRangeInfo(
62
+ noOverlapWeek,
63
+ Temporal.PlainDate.from("2026-03-01"),
64
+ Temporal.PlainDate.from("2026-03-04"),
65
+ T,
66
+ );
67
+ }).run();
58
68
  });
59
69
 
60
- bench("no range (undefined bounds)", () => {
61
- computeWeekRangeInfo(midWeek, undefined, undefined, T);
70
+ test("no range (undefined bounds)", async ({ bench }) => {
71
+ await bench("no range (undefined bounds)", () => {
72
+ computeWeekRangeInfo(midWeek, undefined, undefined, T);
73
+ }).run();
62
74
  });
63
75
 
64
- bench("all 6 weeks of a month", () => {
65
- for (const week of marchWeeks) {
66
- computeWeekRangeInfo(week, rangeStart, rangeEnd, T);
67
- }
76
+ test("all 6 weeks of a month", async ({ bench }) => {
77
+ await bench("all 6 weeks of a month", () => {
78
+ for (const week of marchWeeks) {
79
+ computeWeekRangeInfo(week, rangeStart, rangeEnd, T);
80
+ }
81
+ }).run();
68
82
  });
69
83
  });
70
84
 
71
85
  describe("computeAdjacentMonth", () => {
72
- bench("next month", () => {
73
- computeAdjacentMonth({ year: 2026, month: 3 }, "next", T);
86
+ test("next month", async ({ bench }) => {
87
+ await bench("next month", () => {
88
+ computeAdjacentMonth({ year: 2026, month: 3 }, "next", T);
89
+ }).run();
74
90
  });
75
91
 
76
- bench("prev month", () => {
77
- computeAdjacentMonth({ year: 2026, month: 3 }, "prev", T);
92
+ test("prev month", async ({ bench }) => {
93
+ await bench("prev month", () => {
94
+ computeAdjacentMonth({ year: 2026, month: 3 }, "prev", T);
95
+ }).run();
78
96
  });
79
97
 
80
- bench("year boundary (Dec → Jan)", () => {
81
- computeAdjacentMonth({ year: 2026, month: 12 }, "next", T);
98
+ test("year boundary (Dec → Jan)", async ({ bench }) => {
99
+ await bench("year boundary (Dec → Jan)", () => {
100
+ computeAdjacentMonth({ year: 2026, month: 12 }, "next", T);
101
+ }).run();
82
102
  });
83
103
 
84
- bench("year boundary (Jan → Dec)", () => {
85
- computeAdjacentMonth({ year: 2026, month: 1 }, "prev", T);
104
+ test("year boundary (Jan → Dec)", async ({ bench }) => {
105
+ await bench("year boundary (Jan → Dec)", () => {
106
+ computeAdjacentMonth({ year: 2026, month: 1 }, "prev", T);
107
+ }).run();
86
108
  });
87
109
  });
88
110
 
89
111
  describe("isInRange", () => {
90
112
  const allDays = marchWeeks.flat();
91
113
 
92
- bench("single date check (in range)", () => {
93
- isInRange(Temporal.PlainDate.from("2026-03-10"), rangeStart, rangeEnd, T);
114
+ test("single date check (in range)", async ({ bench }) => {
115
+ await bench("single date check (in range)", () => {
116
+ isInRange(Temporal.PlainDate.from("2026-03-10"), rangeStart, rangeEnd, T);
117
+ }).run();
94
118
  });
95
119
 
96
- bench("single date check (out of range)", () => {
97
- isInRange(Temporal.PlainDate.from("2026-03-25"), rangeStart, rangeEnd, T);
120
+ test("single date check (out of range)", async ({ bench }) => {
121
+ await bench("single date check (out of range)", () => {
122
+ isInRange(Temporal.PlainDate.from("2026-03-25"), rangeStart, rangeEnd, T);
123
+ }).run();
98
124
  });
99
125
 
100
- bench("check all 42 grid cells", () => {
101
- for (const day of allDays) {
102
- isInRange(day, rangeStart, rangeEnd, T);
103
- }
126
+ test("check all 42 grid cells", async ({ bench }) => {
127
+ await bench("check all 42 grid cells", () => {
128
+ for (const day of allDays) {
129
+ isInRange(day, rangeStart, rangeEnd, T);
130
+ }
131
+ }).run();
104
132
  });
105
133
 
106
- bench("undefined range (early exit)", () => {
107
- isInRange(Temporal.PlainDate.from("2026-03-10"), undefined, undefined, T);
134
+ test("undefined range (early exit)", async ({ bench }) => {
135
+ await bench("undefined range (early exit)", () => {
136
+ isInRange(Temporal.PlainDate.from("2026-03-10"), undefined, undefined, T);
137
+ }).run();
108
138
  });
109
139
  });
110
140
 
@@ -113,49 +143,65 @@ describe("toZonedDateTime / fromZonedDateTime", () => {
113
143
  const plainDateTime = Temporal.PlainDateTime.from("2026-03-15T10:30:00");
114
144
  const nativeDate = new Date(2026, 2, 15, 10, 30, 0);
115
145
 
116
- bench("PlainDate → ZonedDateTime", () => {
117
- toZonedDateTime({ format: "PlainDate", value: plainDate }, timeZone, T);
146
+ test("PlainDate → ZonedDateTime", async ({ bench }) => {
147
+ await bench("PlainDate → ZonedDateTime", () => {
148
+ toZonedDateTime({ format: "PlainDate", value: plainDate }, timeZone, T);
149
+ }).run();
118
150
  });
119
151
 
120
- bench("PlainDateTime → ZonedDateTime", () => {
121
- toZonedDateTime(
122
- { format: "PlainDateTime", value: plainDateTime },
123
- timeZone,
124
- T,
125
- );
152
+ test("PlainDateTime → ZonedDateTime", async ({ bench }) => {
153
+ await bench("PlainDateTime → ZonedDateTime", () => {
154
+ toZonedDateTime(
155
+ { format: "PlainDateTime", value: plainDateTime },
156
+ timeZone,
157
+ T,
158
+ );
159
+ }).run();
126
160
  });
127
161
 
128
- bench("Date → ZonedDateTime", () => {
129
- toZonedDateTime({ format: "Date", value: nativeDate }, timeZone, T);
162
+ test("Date → ZonedDateTime", async ({ bench }) => {
163
+ await bench("Date → ZonedDateTime", () => {
164
+ toZonedDateTime({ format: "Date", value: nativeDate }, timeZone, T);
165
+ }).run();
130
166
  });
131
167
 
132
- bench("ZonedDateTime → PlainDate", () => {
133
- const zdt = plainDate.toZonedDateTime(timeZone);
134
- fromZonedDateTime(zdt, "PlainDate", T);
168
+ test("ZonedDateTime → PlainDate", async ({ bench }) => {
169
+ await bench("ZonedDateTime → PlainDate", () => {
170
+ const zdt = plainDate.toZonedDateTime(timeZone);
171
+ fromZonedDateTime(zdt, "PlainDate", T);
172
+ }).run();
135
173
  });
136
174
 
137
- bench("ZonedDateTime → object", () => {
138
- const zdt = plainDate.toZonedDateTime(timeZone);
139
- fromZonedDateTime(zdt, "object", T);
175
+ test("ZonedDateTime → object", async ({ bench }) => {
176
+ await bench("ZonedDateTime → object", () => {
177
+ const zdt = plainDate.toZonedDateTime(timeZone);
178
+ fromZonedDateTime(zdt, "object", T);
179
+ }).run();
140
180
  });
141
181
 
142
- bench("round-trip PlainDate → ZDT → PlainDate", () => {
143
- const zdt = toZonedDateTime(
144
- { format: "PlainDate", value: plainDate },
145
- timeZone,
146
- T,
147
- );
148
- fromZonedDateTime(zdt, "PlainDate", T);
182
+ test("round-trip PlainDate → ZDT → PlainDate", async ({ bench }) => {
183
+ await bench("round-trip PlainDate → ZDT → PlainDate", () => {
184
+ const zdt = toZonedDateTime(
185
+ { format: "PlainDate", value: plainDate },
186
+ timeZone,
187
+ T,
188
+ );
189
+ fromZonedDateTime(zdt, "PlainDate", T);
190
+ }).run();
149
191
  });
150
192
  });
151
193
 
152
194
  describe("getWeekdayNames", () => {
153
- bench("en-US locale (7× toLocaleString)", () => {
154
- getWeekdayNames("en-US", T);
195
+ test("en-US locale (7× toLocaleString)", async ({ bench }) => {
196
+ await bench("en-US locale (7× toLocaleString)", () => {
197
+ getWeekdayNames("en-US", T);
198
+ }).run();
155
199
  });
156
200
 
157
- bench("de-DE locale", () => {
158
- getWeekdayNames("de-DE", T);
201
+ test("de-DE locale", async ({ bench }) => {
202
+ await bench("de-DE locale", () => {
203
+ getWeekdayNames("de-DE", T);
204
+ }).run();
159
205
  });
160
206
  });
161
207
 
@@ -165,43 +211,49 @@ describe("resolveFocusTarget", () => {
165
211
  const currentMonth = { year: 2026, month: 3 };
166
212
  const noDisabled = () => false;
167
213
 
168
- bench("focused date in grid (fast path)", () => {
169
- resolveFocusTarget(
170
- focusedDate,
171
- selectedDate,
172
- marchWeeks,
173
- currentMonth,
174
- noDisabled,
175
- T,
176
- true,
177
- );
178
- });
179
-
180
- bench("selected date fallback", () => {
181
- // Focus a date outside the grid to force fallback to selectedDate
182
- const outsideFocus = Temporal.PlainDate.from("2026-05-01");
183
- resolveFocusTarget(
184
- outsideFocus,
185
- selectedDate,
186
- marchWeeks,
187
- currentMonth,
188
- noDisabled,
189
- T,
190
- true,
191
- );
192
- });
193
-
194
- bench("no match — linear scan to first enabled", () => {
195
- const outsideFocus = Temporal.PlainDate.from("2026-05-01");
196
- const outsideSelected = Temporal.PlainDate.from("2026-05-15");
197
- resolveFocusTarget(
198
- outsideFocus,
199
- outsideSelected,
200
- marchWeeks,
201
- currentMonth,
202
- noDisabled,
203
- T,
204
- true,
205
- );
214
+ test("focused date in grid (fast path)", async ({ bench }) => {
215
+ await bench("focused date in grid (fast path)", () => {
216
+ resolveFocusTarget(
217
+ focusedDate,
218
+ selectedDate,
219
+ marchWeeks,
220
+ currentMonth,
221
+ noDisabled,
222
+ T,
223
+ true,
224
+ );
225
+ }).run();
226
+ });
227
+
228
+ test("selected date fallback", async ({ bench }) => {
229
+ await bench("selected date fallback", () => {
230
+ // Focus a date outside the grid to force fallback to selectedDate
231
+ const outsideFocus = Temporal.PlainDate.from("2026-05-01");
232
+ resolveFocusTarget(
233
+ outsideFocus,
234
+ selectedDate,
235
+ marchWeeks,
236
+ currentMonth,
237
+ noDisabled,
238
+ T,
239
+ true,
240
+ );
241
+ }).run();
242
+ });
243
+
244
+ test("no match — linear scan to first enabled", async ({ bench }) => {
245
+ await bench("no match — linear scan to first enabled", () => {
246
+ const outsideFocus = Temporal.PlainDate.from("2026-05-01");
247
+ const outsideSelected = Temporal.PlainDate.from("2026-05-15");
248
+ resolveFocusTarget(
249
+ outsideFocus,
250
+ outsideSelected,
251
+ marchWeeks,
252
+ currentMonth,
253
+ noDisabled,
254
+ T,
255
+ true,
256
+ );
257
+ }).run();
206
258
  });
207
259
  });
package/src/utils.test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, it, expect } from "vitest";
2
+ import { describe, it, expect } from "vite-plus/test";
3
3
  import { temporalVariants } from "./test-temporal";
4
4
  import type { TemporalNamespace } from "./types";
5
5
  import {
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { act, fireEvent, render, screen } from "@testing-library/react";
4
4
  import type { ReactNode } from "react";
5
- import { describe, expect, it } from "vitest";
5
+ import { describe, expect, it } from "vite-plus/test";
6
6
  import {
7
7
  DayButton,
8
8
  DayCellTemplate,
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, it, expect } from "vitest";
2
+ import { describe, it, expect } from "vite-plus/test";
3
3
  import { computeWeeksKeyNav, type WeeksKeyNavInput } from "./weeks-keyboard";
4
4
 
5
5
  const T = Temporal;
@@ -7,7 +7,7 @@ import {
7
7
  fireEvent,
8
8
  } from "@testing-library/react";
9
9
  import { createRef } from "react";
10
- import { describe, it, expect, afterEach } from "vitest";
10
+ import { describe, it, expect, afterEach } from "vite-plus/test";
11
11
  import {
12
12
  Grid,
13
13
  GridBody,
@@ -7,7 +7,7 @@ import {
7
7
  fireEvent,
8
8
  within,
9
9
  } from "@testing-library/react";
10
- import { describe, it, expect, vi, afterEach } from "vitest";
10
+ import { describe, it, expect, vi, afterEach } from "vite-plus/test";
11
11
  import {
12
12
  Grid,
13
13
  GridBody,
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import { describe, it, expect } from "vitest";
2
+ import { describe, it, expect } from "vite-plus/test";
3
3
  import type { OutOfRangeBehavior } from "./out-of-range";
4
4
  import { createWeekWindowPolicy } from "./weeks-window";
5
5