@klinking/colander 3.1.0-alpha.6 → 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 (66) 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/{index-DnFCKyyw.d.cts → index-BqzrxYgn.d.cts} +106 -116
  30. package/dist/{index-q3cQKJdA.d.mts → index-CkhYFmf4.d.mts} +106 -116
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +2 -2
  33. package/dist/index.d.mts +2 -2
  34. package/dist/index.mjs +1 -2
  35. package/dist/{weeks-navigation-Dn3UtG76.mjs → weeks-navigation-BWB5OvqW.mjs} +151 -188
  36. package/dist/{weeks-navigation-SuKJZJCM.cjs → weeks-navigation-CatYJIKb.cjs} +153 -191
  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/grid.tsx +1 -1
  46. package/src/keyboard.test.ts +1 -1
  47. package/src/month-separator.test.tsx +1 -1
  48. package/src/month-view.bounds.test.tsx +1 -1
  49. package/src/month-view.test.tsx +89 -1
  50. package/src/month-view.tsx +14 -5
  51. package/src/month-window.test.ts +1 -1
  52. package/src/out-of-range.test.ts +34 -54
  53. package/src/out-of-range.ts +47 -123
  54. package/src/range-preview.test.ts +1 -1
  55. package/src/resolve-first-week.test.ts +1 -1
  56. package/src/today.test.tsx +8 -1
  57. package/src/utils.bench.ts +158 -106
  58. package/src/utils.test.ts +1 -1
  59. package/src/view-context.test.tsx +1 -1
  60. package/src/weeks-keyboard.test.ts +1 -1
  61. package/src/weeks-navigation.tsx +15 -6
  62. package/src/weeks-view-state.ts +21 -12
  63. package/src/weeks-view.bounds.test.tsx +246 -0
  64. package/src/weeks-view.test.tsx +1 -1
  65. package/src/weeks-window.test.ts +110 -22
  66. package/src/weeks-window.ts +57 -19
@@ -12,7 +12,8 @@ import type { TemporalNamespace, WeekStartDay } from "./types";
12
12
  * - `"unbounded"` — Navigation is never restricted by `min`/`max`; any range of
13
13
  * weeks can be viewed. Out-of-range days simply render disabled. (Default.)
14
14
  * - `"stop"` — Navigation halts at the boundary: the Prev/Next button is
15
- * disabled once the next step would show a window containing no in-range day.
15
+ * disabled, and `goNext`/`goPrev`/`scrollToWeek` and keyboard paging do
16
+ * nothing, once the next step would show a window containing no in-range day.
16
17
  * - `"stop-shrink"` — Like `"stop"`, but near the edge the window **shrinks** to
17
18
  * fewer week rows instead of showing rows that are entirely out of range.
18
19
  * - `"snap"` — A jump that would overshoot **snaps** the window so its edge
@@ -20,6 +21,8 @@ import type { TemporalNamespace, WeekStartDay } from "./types";
20
21
  * - `"snap-shrink"` — Snap to the boundary, then **shrink** the window to just
21
22
  * the in-range weeks.
22
23
  *
24
+ * A single bound (`min` only or `max` only) is honored; the missing side is unlimited.
25
+ *
23
26
  * `"snap"` and `"snap-shrink"` are identical **unless the selectable range spans
24
27
  * fewer weeks than `weekCount`** — i.e. the window is taller than the range.
25
28
  * Snapping can only pin *one* edge to a bound; if the range is narrower than the
@@ -63,19 +66,33 @@ export type MonthOutOfRangeBehavior = "unbounded" | "stop";
63
66
  /** Returns true if any day in the 7-day span starting at weekStart falls within [min, max]. */
64
67
  function weekHasValidDay(
65
68
  weekStart: Temporal.PlainDate,
66
- min: Temporal.PlainDate,
67
- max: Temporal.PlainDate,
69
+ min: Temporal.PlainDate | undefined,
70
+ max: Temporal.PlainDate | undefined,
68
71
  T: TemporalNamespace,
69
72
  ): boolean {
70
73
  // Week spans [weekStart, weekStart+6]. Overlaps with [min, max] iff
71
- // weekStart <= max AND weekStart+6 >= min.
74
+ // weekStart <= max AND weekStart+6 >= min. A missing bound is unlimited.
72
75
  const weekEnd = weekStart.add({ days: 6 });
73
76
  return (
74
- T.PlainDate.compare(weekStart, max) <= 0 &&
75
- T.PlainDate.compare(weekEnd, min) >= 0
77
+ (!max || T.PlainDate.compare(weekStart, max) <= 0) &&
78
+ (!min || T.PlainDate.compare(weekEnd, min) >= 0)
76
79
  );
77
80
  }
78
81
 
82
+ /** Returns true if any of the `weekCount` weeks starting at firstWeek has a day in [min, max]. */
83
+ export function windowHasValidWeek(
84
+ firstWeek: Temporal.PlainDate,
85
+ weekCount: number,
86
+ min: Temporal.PlainDate | undefined,
87
+ max: Temporal.PlainDate | undefined,
88
+ T: TemporalNamespace,
89
+ ): boolean {
90
+ for (let i = 0; i < weekCount; i++) {
91
+ if (weekHasValidDay(firstWeek.add({ weeks: i }), min, max, T)) return true;
92
+ }
93
+ return false;
94
+ }
95
+
79
96
  /**
80
97
  * Returns the start of the week (per weekStartDay) that contains the given date.
81
98
  * Uses dayOfWeek % 7 → Sun=0…Sat=6 convention.
@@ -83,31 +100,12 @@ function weekHasValidDay(
83
100
  function weekStartContaining(
84
101
  date: Temporal.PlainDate,
85
102
  weekStartDay: WeekStartDay,
86
- _T: TemporalNamespace,
87
103
  ): Temporal.PlainDate {
88
104
  const dow = date.dayOfWeek % 7; // Sun=0…Sat=6
89
105
  const daysFromStart = (dow - weekStartDay + 7) % 7;
90
106
  return date.subtract({ days: daysFromStart });
91
107
  }
92
108
 
93
- /** Find the week start (per weekStartDay) whose 7-day span contains min. */
94
- function findFirstValidWeekStart(
95
- min: Temporal.PlainDate,
96
- weekStartDay: WeekStartDay,
97
- T: TemporalNamespace,
98
- ): Temporal.PlainDate {
99
- return weekStartContaining(min, weekStartDay, T);
100
- }
101
-
102
- /** Find the week start (per weekStartDay) whose 7-day span contains max. */
103
- function findLastValidWeekStart(
104
- max: Temporal.PlainDate,
105
- weekStartDay: WeekStartDay,
106
- T: TemporalNamespace,
107
- ): Temporal.PlainDate {
108
- return weekStartContaining(max, weekStartDay, T);
109
- }
110
-
111
109
  /**
112
110
  * Trim leading and trailing fully-disabled weeks from a window.
113
111
  * Returns new { firstWeek, weekCount }.
@@ -115,8 +113,8 @@ function findLastValidWeekStart(
115
113
  function shrinkWindow(
116
114
  firstWeek: Temporal.PlainDate,
117
115
  weekCount: number,
118
- min: Temporal.PlainDate,
119
- max: Temporal.PlainDate,
116
+ min: Temporal.PlainDate | undefined,
117
+ max: Temporal.PlainDate | undefined,
120
118
  T: TemporalNamespace,
121
119
  ): { firstWeek: Temporal.PlainDate; weekCount: number } {
122
120
  let start = 0;
@@ -174,13 +172,14 @@ export function applyOutOfRange({
174
172
  weekStartDay,
175
173
  T,
176
174
  }: ApplyOutOfRangeInput): { firstWeek: Temporal.PlainDate; weekCount: number } {
177
- // Without bounds, all modes behave as unbounded
178
- if (!min || !max || behavior === "unbounded") {
175
+ // Without bounds, all modes behave as unbounded. A single bound is honored;
176
+ // the missing side is unlimited.
177
+ if ((!min && !max) || behavior === "unbounded") {
179
178
  return { firstWeek: targetFirstWeek, weekCount };
180
179
  }
181
180
 
182
181
  if (behavior === "stop") {
183
- // Caller checks canShift; here just return the target as-is
182
+ // Whether the move is allowed is decided by the caller (see WeekWindowPolicy)
184
183
  return { firstWeek: targetFirstWeek, weekCount };
185
184
  }
186
185
 
@@ -188,100 +187,25 @@ export function applyOutOfRange({
188
187
  return shrinkWindow(targetFirstWeek, weekCount, min, max, T);
189
188
  }
190
189
 
191
- if (behavior === "snap" || behavior === "snap-shrink") {
192
- // Compute the snapped position: window ends at lastValidWeekStart
193
- const lastValid = findLastValidWeekStart(max, weekStartDay, T);
194
-
195
- // The snapped firstWeek positions the window so it ends at lastValid
196
- // i.e. firstWeek = lastValid - (weekCount - 1) * 7
197
- const snappedFirst = lastValid.subtract({ days: (weekCount - 1) * 7 });
198
-
199
- // Determine which firstWeek to use: if target is already within bounds
200
- // (doesn't overshoot max), use the target; otherwise snap.
201
- // "Overshoots max" means the target window extends past the last valid week.
202
- // The last week of the target window is targetFirstWeek + (weekCount-1)*7.
203
- const targetLastWeek = targetFirstWeek.add({ days: (weekCount - 1) * 7 });
204
-
205
- let resolvedFirst: Temporal.PlainDate;
206
- if (T.PlainDate.compare(targetLastWeek, lastValid) <= 0) {
207
- // Target window fits within max — also check if it goes before min
208
- const firstValid = findFirstValidWeekStart(min, weekStartDay, T);
209
- if (T.PlainDate.compare(targetFirstWeek, firstValid) >= 0) {
210
- resolvedFirst = targetFirstWeek;
211
- } else {
212
- // Overshoots min: snap forward so window starts at firstValid
213
- resolvedFirst = firstValid;
214
- }
215
- } else {
216
- // Overshoots max: snap back
217
- resolvedFirst = snappedFirst;
218
- }
219
-
220
- if (behavior === "snap-shrink") {
221
- return shrinkWindow(resolvedFirst, weekCount, min, max, T);
222
- }
223
- return { firstWeek: resolvedFirst, weekCount };
224
- }
225
-
226
- return { firstWeek: targetFirstWeek, weekCount };
227
- }
228
-
229
- export interface CanShiftInput {
230
- currentFirstWeek: Temporal.PlainDate;
231
- weekCount: number;
232
- direction: 1 | -1;
233
- shiftBy?: number;
234
- behavior: OutOfRangeBehavior;
235
- min?: Temporal.PlainDate;
236
- max?: Temporal.PlainDate;
237
- weekStartDay: WeekStartDay;
238
- T: TemporalNamespace;
239
- }
240
-
241
- /**
242
- * Returns whether the navigation button for the given direction should be enabled.
243
- */
244
- export function canShift({
245
- currentFirstWeek,
246
- weekCount,
247
- direction,
248
- shiftBy,
249
- behavior,
250
- min,
251
- max,
252
- weekStartDay,
253
- T,
254
- }: CanShiftInput): boolean {
255
- if (behavior === "unbounded" || !min || !max) {
256
- return true;
190
+ // snap | snap-shrink
191
+ const targetLastWeek = targetFirstWeek.add({ weeks: weekCount - 1 });
192
+ const lastValid = max && weekStartContaining(max, weekStartDay);
193
+ const firstValid = min && weekStartContaining(min, weekStartDay);
194
+
195
+ let resolvedFirst = targetFirstWeek;
196
+ if (lastValid && T.PlainDate.compare(targetLastWeek, lastValid) > 0) {
197
+ // Overshoots max: snap back so the window ends at the last in-range week
198
+ resolvedFirst = lastValid.subtract({ weeks: weekCount - 1 });
199
+ } else if (
200
+ firstValid &&
201
+ T.PlainDate.compare(targetFirstWeek, firstValid) < 0
202
+ ) {
203
+ // Overshoots min: snap forward so the window starts at the first in-range week
204
+ resolvedFirst = firstValid;
257
205
  }
258
206
 
259
- const shift = shiftBy ?? weekCount;
260
- const targetFirstWeek = currentFirstWeek.add({ days: direction * shift * 7 });
261
-
262
- if (behavior === "stop" || behavior === "stop-shrink") {
263
- // Check if any week in the target window has valid days
264
- for (let i = 0; i < weekCount; i++) {
265
- const ws = targetFirstWeek.add({ days: i * 7 });
266
- if (weekHasValidDay(ws, min, max, T)) return true;
267
- }
268
- return false;
207
+ if (behavior === "snap-shrink") {
208
+ return shrinkWindow(resolvedFirst, weekCount, min, max, T);
269
209
  }
270
-
271
- if (behavior === "snap" || behavior === "snap-shrink") {
272
- // Disabled when the current position is already the snapped position
273
- // (i.e. applying the out-of-range behavior to the target produces the same firstWeek)
274
- const applied = applyOutOfRange({
275
- targetFirstWeek,
276
- weekCount,
277
- behavior,
278
- min,
279
- max,
280
- weekStartDay,
281
- T,
282
- });
283
- return T.PlainDate.compare(applied.firstWeek, currentFirstWeek) !== 0;
284
- }
285
-
286
- return true;
210
+ return { firstWeek: resolvedFirst, weekCount };
287
211
  }
@@ -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;