@klinking/colander 0.0.0 → 2.0.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.
Files changed (92) hide show
  1. package/dist/formats/date.cjs +51 -48
  2. package/dist/formats/date.d.cts +10 -37
  3. package/dist/formats/date.d.mts +10 -37
  4. package/dist/formats/date.mjs +6 -2
  5. package/dist/formats/object.cjs +51 -48
  6. package/dist/formats/object.d.cts +10 -37
  7. package/dist/formats/object.d.mts +10 -37
  8. package/dist/formats/object.mjs +6 -2
  9. package/dist/formats/plain-date-time.cjs +51 -48
  10. package/dist/formats/plain-date-time.d.cts +10 -37
  11. package/dist/formats/plain-date-time.d.mts +10 -37
  12. package/dist/formats/plain-date-time.mjs +6 -2
  13. package/dist/formats/plain-date.cjs +51 -48
  14. package/dist/formats/plain-date.d.cts +10 -37
  15. package/dist/formats/plain-date.d.mts +10 -37
  16. package/dist/formats/plain-date.mjs +6 -2
  17. package/dist/formats/plain-month-day.cjs +51 -48
  18. package/dist/formats/plain-month-day.d.cts +10 -37
  19. package/dist/formats/plain-month-day.d.mts +10 -37
  20. package/dist/formats/plain-month-day.mjs +6 -2
  21. package/dist/formats/plain-year-month.cjs +51 -48
  22. package/dist/formats/plain-year-month.d.cts +10 -37
  23. package/dist/formats/plain-year-month.d.mts +10 -37
  24. package/dist/formats/plain-year-month.mjs +6 -2
  25. package/dist/formats/zoned-date-time.cjs +51 -48
  26. package/dist/formats/zoned-date-time.d.cts +10 -37
  27. package/dist/formats/zoned-date-time.d.mts +10 -37
  28. package/dist/formats/zoned-date-time.mjs +6 -2
  29. package/dist/index.cjs +47 -48
  30. package/dist/index.d.cts +11 -2
  31. package/dist/index.d.mts +11 -2
  32. package/dist/index.mjs +2 -2
  33. package/dist/{temporal-polyfill-DU8VfleL.cjs → weeks-navigation-CtbaTTmA.cjs} +329 -567
  34. package/dist/{temporal-polyfill-DTx0VIX5.mjs → weeks-navigation-D5GjCwNm.mjs} +329 -561
  35. package/dist/{weeks-view-context-BN6qR-83.d.mts → weeks-view-context-BZeWx9N8.d.cts} +275 -258
  36. package/dist/{weeks-view-context-aHGgYkpt.d.cts → weeks-view-context-MVe1b-BS.d.mts} +275 -258
  37. package/package.json +20 -20
  38. package/src/calendar-context.ts +12 -5
  39. package/src/calendar-provider.test.tsx +18 -4
  40. package/src/calendar-provider.tsx +130 -35
  41. package/src/calendar-types.ts +21 -4
  42. package/src/compute-weeks-in-window.test.ts +9 -7
  43. package/src/context.ts +1 -1
  44. package/src/day-cell.tsx +92 -46
  45. package/src/drag-handle.tsx +23 -24
  46. package/src/formats/date.ts +120 -56
  47. package/src/formats/formats.test.ts +8 -4
  48. package/src/formats/object.ts +120 -56
  49. package/src/formats/plain-date-time.ts +120 -56
  50. package/src/formats/plain-date.ts +120 -56
  51. package/src/formats/plain-month-day.ts +120 -56
  52. package/src/formats/plain-year-month.ts +120 -56
  53. package/src/formats/zoned-date-time.ts +120 -56
  54. package/src/grid-header.tsx +24 -18
  55. package/src/grid.event-perf.test.tsx +30 -13
  56. package/src/grid.perf.test.tsx +97 -33
  57. package/src/grid.tsx +75 -43
  58. package/src/index.ts +16 -4
  59. package/src/keyboard.test.ts +110 -42
  60. package/src/keyboard.ts +18 -7
  61. package/src/month-separator.test.tsx +3 -1
  62. package/src/month-separator.tsx +30 -9
  63. package/src/month-view-context.ts +8 -3
  64. package/src/month-view-types.ts +14 -10
  65. package/src/month-view.test.tsx +687 -68
  66. package/src/month-view.tsx +176 -71
  67. package/src/navigation.tsx +77 -47
  68. package/src/overflow.test.ts +15 -13
  69. package/src/overflow.ts +10 -2
  70. package/src/range-preview.tsx +37 -12
  71. package/src/resolve-first-week.test.ts +14 -10
  72. package/src/resolve-first-week.ts +6 -2
  73. package/src/root-selection.ts +185 -101
  74. package/src/selected-range.tsx +47 -22
  75. package/src/test-temporal.ts +0 -2
  76. package/src/types.ts +126 -103
  77. package/src/utils.bench.ts +30 -6
  78. package/src/utils.test.ts +203 -55
  79. package/src/utils.ts +156 -54
  80. package/src/view-context.ts +4 -1
  81. package/src/week-number.tsx +5 -8
  82. package/src/weeks-grid.tsx +45 -19
  83. package/src/weeks-keyboard.test.ts +6 -7
  84. package/src/weeks-keyboard.ts +8 -3
  85. package/src/weeks-navigation.tsx +21 -9
  86. package/src/weeks-view-context.ts +8 -3
  87. package/src/weeks-view-state.ts +100 -33
  88. package/src/weeks-view-types.ts +14 -8
  89. package/src/weeks-view.test.tsx +127 -19
  90. package/src/weeks-view.tsx +30 -12
  91. package/src/temporal-polyfill.test.ts +0 -317
  92. package/src/temporal-polyfill.ts +0 -566
package/src/utils.test.ts CHANGED
@@ -3,7 +3,6 @@ import { describe, it, expect } from "vitest";
3
3
  import { temporalVariants } from "./test-temporal";
4
4
  import type { TemporalNamespace } from "./types";
5
5
  import {
6
- calendarForLocale,
7
6
  resolveTemporal,
8
7
  getSystemTimeZone,
9
8
  toZonedDateTime,
@@ -14,6 +13,7 @@ import {
14
13
  sameCalendarDay,
15
14
  getReferenceWeekStart,
16
15
  computeAdjacentMonth,
16
+ shiftWindowToMonth,
17
17
  focusedDateForMonth,
18
18
  resolveFocusTarget,
19
19
  shouldMoveDomFocus,
@@ -31,18 +31,6 @@ const T: TemporalNamespace = {
31
31
  PlainYearMonth: Temporal.PlainYearMonth,
32
32
  };
33
33
 
34
- describe("calendarForLocale", () => {
35
- it("returns 'gregory' for en-US", () => {
36
- expect(calendarForLocale("en-US")).toBe("gregory");
37
- });
38
-
39
- it("returns a calendar string for an empty locale (runtime default)", () => {
40
- const result = calendarForLocale("");
41
- expect(typeof result).toBe("string");
42
- expect(result.length).toBeGreaterThan(0);
43
- });
44
- });
45
-
46
34
  describe("resolveTemporal", () => {
47
35
  it("returns the provided namespace when given", () => {
48
36
  expect(resolveTemporal(T)).toBe(T);
@@ -106,7 +94,11 @@ describe("toZonedDateTime", () => {
106
94
 
107
95
  it("converts PlainYearMonth to ZonedDateTime (day 1)", () => {
108
96
  const pym = Temporal.PlainYearMonth.from({ year: 2026, month: 6 });
109
- const zdt = toZonedDateTime({ format: "PlainYearMonth", value: pym }, tz, T);
97
+ const zdt = toZonedDateTime(
98
+ { format: "PlainYearMonth", value: pym },
99
+ tz,
100
+ T,
101
+ );
110
102
  expect(zdt.year).toBe(2026);
111
103
  expect(zdt.month).toBe(6);
112
104
  expect(zdt.day).toBe(1);
@@ -114,7 +106,11 @@ describe("toZonedDateTime", () => {
114
106
 
115
107
  it("passes through ZonedDateTime unchanged", () => {
116
108
  const orig = Temporal.PlainDate.from("2026-03-15").toZonedDateTime(tz);
117
- const zdt = toZonedDateTime({ format: "ZonedDateTime", value: orig }, tz, T);
109
+ const zdt = toZonedDateTime(
110
+ { format: "ZonedDateTime", value: orig },
111
+ tz,
112
+ T,
113
+ );
118
114
  expect(Temporal.ZonedDateTime.compare(zdt, orig)).toBe(0);
119
115
  });
120
116
 
@@ -157,7 +153,9 @@ describe("toZonedDateTime", () => {
157
153
 
158
154
  describe("fromZonedDateTime", () => {
159
155
  const tz = "America/New_York";
160
- const zdt = Temporal.PlainDateTime.from("2026-03-15T10:30:45").toZonedDateTime(tz);
156
+ const zdt = Temporal.PlainDateTime.from(
157
+ "2026-03-15T10:30:45",
158
+ ).toZonedDateTime(tz);
161
159
 
162
160
  it("extracts PlainDate", () => {
163
161
  const result = fromZonedDateTime(zdt, "PlainDate", T);
@@ -224,7 +222,11 @@ describe("fromZonedDateTime", () => {
224
222
 
225
223
  it("round-trips: toZonedDateTime → fromZonedDateTime preserves PlainDate", () => {
226
224
  const pd = Temporal.PlainDate.from("2026-06-20");
227
- const intermediate = toZonedDateTime({ format: "PlainDate", value: pd }, tz, T);
225
+ const intermediate = toZonedDateTime(
226
+ { format: "PlainDate", value: pd },
227
+ tz,
228
+ T,
229
+ );
228
230
  const result = fromZonedDateTime(intermediate, "PlainDate", T);
229
231
  expect((result.value as Temporal.PlainDate).toString()).toBe("2026-06-20");
230
232
  });
@@ -249,14 +251,18 @@ describe("selectedToZdt", () => {
249
251
 
250
252
  describe("zdtToNativeDate", () => {
251
253
  it("converts a ZonedDateTime to a native Date with the correct epoch", () => {
252
- const zdt = Temporal.PlainDateTime.from("2026-01-01T00:00:00").toZonedDateTime("UTC");
254
+ const zdt = Temporal.PlainDateTime.from(
255
+ "2026-01-01T00:00:00",
256
+ ).toZonedDateTime("UTC");
253
257
  const native = zdtToNativeDate(zdt);
254
258
  expect(native).toBeInstanceOf(Date);
255
259
  expect(native.toISOString()).toBe("2026-01-01T00:00:00.000Z");
256
260
  });
257
261
 
258
262
  it("preserves millisecond precision", () => {
259
- const zdt = Temporal.PlainDateTime.from("2026-06-15T12:30:00").toZonedDateTime("UTC");
263
+ const zdt = Temporal.PlainDateTime.from(
264
+ "2026-06-15T12:30:00",
265
+ ).toZonedDateTime("UTC");
260
266
  const native = zdtToNativeDate(zdt);
261
267
  expect(native.getUTCHours()).toBe(12);
262
268
  expect(native.getUTCMinutes()).toBe(30);
@@ -265,31 +271,41 @@ describe("zdtToNativeDate", () => {
265
271
 
266
272
  describe("sameCalendarDay", () => {
267
273
  it("returns true when year, month, and day match", () => {
268
- const zdt = Temporal.PlainDateTime.from("2026-03-15T10:00:00").toZonedDateTime("UTC");
274
+ const zdt = Temporal.PlainDateTime.from(
275
+ "2026-03-15T10:00:00",
276
+ ).toZonedDateTime("UTC");
269
277
  const pd = Temporal.PlainDate.from("2026-03-15");
270
278
  expect(sameCalendarDay(zdt, pd)).toBe(true);
271
279
  });
272
280
 
273
281
  it("returns true even when times differ", () => {
274
- const zdt = Temporal.PlainDateTime.from("2026-03-15T23:59:59").toZonedDateTime("UTC");
282
+ const zdt = Temporal.PlainDateTime.from(
283
+ "2026-03-15T23:59:59",
284
+ ).toZonedDateTime("UTC");
275
285
  const pd = Temporal.PlainDate.from("2026-03-15");
276
286
  expect(sameCalendarDay(zdt, pd)).toBe(true);
277
287
  });
278
288
 
279
289
  it("returns false when days differ", () => {
280
- const zdt = Temporal.PlainDateTime.from("2026-03-15T10:00:00").toZonedDateTime("UTC");
290
+ const zdt = Temporal.PlainDateTime.from(
291
+ "2026-03-15T10:00:00",
292
+ ).toZonedDateTime("UTC");
281
293
  const pd = Temporal.PlainDate.from("2026-03-16");
282
294
  expect(sameCalendarDay(zdt, pd)).toBe(false);
283
295
  });
284
296
 
285
297
  it("returns false when months differ", () => {
286
- const zdt = Temporal.PlainDateTime.from("2026-03-15T10:00:00").toZonedDateTime("UTC");
298
+ const zdt = Temporal.PlainDateTime.from(
299
+ "2026-03-15T10:00:00",
300
+ ).toZonedDateTime("UTC");
287
301
  const pd = Temporal.PlainDate.from("2026-04-15");
288
302
  expect(sameCalendarDay(zdt, pd)).toBe(false);
289
303
  });
290
304
 
291
305
  it("returns false when years differ", () => {
292
- const zdt = Temporal.PlainDateTime.from("2026-03-15T10:00:00").toZonedDateTime("UTC");
306
+ const zdt = Temporal.PlainDateTime.from(
307
+ "2026-03-15T10:00:00",
308
+ ).toZonedDateTime("UTC");
293
309
  const pd = Temporal.PlainDate.from("2027-03-15");
294
310
  expect(sameCalendarDay(zdt, pd)).toBe(false);
295
311
  });
@@ -324,14 +340,14 @@ describe.each(temporalVariants)("getWeekdayNames ($name)", ({ T }) => {
324
340
 
325
341
  it("starts with Sunday for en-US", () => {
326
342
  const names = getWeekdayNames("en-US", T);
327
- expect(names[0].long).toBe("Sunday");
328
- expect(names[0].short).toBe("Sun");
329
- expect(names[0].narrow).toBe("S");
343
+ expect(names[0]!.long).toBe("Sunday");
344
+ expect(names[0]!.short).toBe("Sun");
345
+ expect(names[0]!.narrow).toBe("S");
330
346
  });
331
347
 
332
348
  it("ends with Saturday for en-US", () => {
333
349
  const names = getWeekdayNames("en-US", T);
334
- expect(names[6].long).toBe("Saturday");
350
+ expect(names[6]!.long).toBe("Saturday");
335
351
  });
336
352
 
337
353
  it("contains all 7 unique long names", () => {
@@ -354,19 +370,19 @@ describe.each(temporalVariants)("getWeekdayNames ($name)", ({ T }) => {
354
370
 
355
371
  it("produces localized names for a non-English locale", () => {
356
372
  const names = getWeekdayNames("de-DE", T);
357
- expect(names[0].long).toBe("Sonntag");
373
+ expect(names[0]!.long).toBe("Sonntag");
358
374
  });
359
375
 
360
376
  it("starts with Monday when weekStartDay=1", () => {
361
377
  const names = getWeekdayNames("en-US", T, 1);
362
- expect(names[0].long).toBe("Monday");
363
- expect(names[6].long).toBe("Sunday");
378
+ expect(names[0]!.long).toBe("Monday");
379
+ expect(names[6]!.long).toBe("Sunday");
364
380
  });
365
381
 
366
382
  it("starts with Saturday when weekStartDay=6", () => {
367
383
  const names = getWeekdayNames("en-US", T, 6);
368
- expect(names[0].long).toBe("Saturday");
369
- expect(names[1].long).toBe("Sunday");
384
+ expect(names[0]!.long).toBe("Saturday");
385
+ expect(names[1]!.long).toBe("Sunday");
370
386
  });
371
387
  });
372
388
 
@@ -409,6 +425,79 @@ describe.each(temporalVariants)("computeAdjacentMonth ($name)", ({ T }) => {
409
425
  });
410
426
  });
411
427
 
428
+ describe("shiftWindowToMonth", () => {
429
+ const march = { year: 2026, month: 3 };
430
+
431
+ it.each<{
432
+ description: string;
433
+ start: { year: number; month: number };
434
+ focused: { year: number; month: number };
435
+ numberOfMonths: number;
436
+ expected: { year: number; month: number };
437
+ }>([
438
+ {
439
+ description: "already visible (single month) returns start unchanged",
440
+ start: march,
441
+ focused: march,
442
+ numberOfMonths: 1,
443
+ expected: { year: 2026, month: 3 },
444
+ },
445
+ {
446
+ description: "already visible second pane returns start unchanged",
447
+ start: march,
448
+ focused: { year: 2026, month: 4 },
449
+ numberOfMonths: 2,
450
+ expected: { year: 2026, month: 3 },
451
+ },
452
+ {
453
+ description: "one past the last pane shifts by one (focused last)",
454
+ start: march,
455
+ focused: { year: 2026, month: 5 },
456
+ numberOfMonths: 2,
457
+ expected: { year: 2026, month: 4 },
458
+ },
459
+ {
460
+ description: "two past the last pane keeps focused as the last pane",
461
+ start: march,
462
+ focused: { year: 2026, month: 6 },
463
+ numberOfMonths: 2,
464
+ expected: { year: 2026, month: 5 },
465
+ },
466
+ {
467
+ description: "before the window makes focused the first pane",
468
+ start: march,
469
+ focused: { year: 2026, month: 2 },
470
+ numberOfMonths: 2,
471
+ expected: { year: 2026, month: 2 },
472
+ },
473
+ {
474
+ description: "single month after window matches the focused month",
475
+ start: march,
476
+ focused: { year: 2026, month: 7 },
477
+ numberOfMonths: 1,
478
+ expected: { year: 2026, month: 7 },
479
+ },
480
+ {
481
+ description: "shift forward across a year boundary",
482
+ start: { year: 2026, month: 12 },
483
+ focused: { year: 2027, month: 2 },
484
+ numberOfMonths: 2,
485
+ expected: { year: 2027, month: 1 },
486
+ },
487
+ {
488
+ description: "shift backward across a year boundary",
489
+ start: { year: 2027, month: 1 },
490
+ focused: { year: 2026, month: 11 },
491
+ numberOfMonths: 2,
492
+ expected: { year: 2026, month: 11 },
493
+ },
494
+ ])("$description", ({ start, focused, numberOfMonths, expected }) => {
495
+ const result = shiftWindowToMonth(start, focused, numberOfMonths);
496
+ expect(result.year).toBe(expected.year);
497
+ expect(result.month).toBe(expected.month);
498
+ });
499
+ });
500
+
412
501
  describe.each(temporalVariants)("focusedDateForMonth ($name)", ({ T }) => {
413
502
  const d = (iso: string) => T.PlainDate.from(iso);
414
503
 
@@ -481,14 +570,14 @@ describe.each(temporalVariants)("getMonthWeeks ($name)", ({ T }) => {
481
570
  it("starts each week on Sunday (dayOfWeek === 7 in ISO)", () => {
482
571
  const weeks = getMonthWeeks(2026, 3, T);
483
572
  for (const week of weeks) {
484
- expect(week[0].dayOfWeek).toBe(7);
573
+ expect(week[0]!.dayOfWeek).toBe(7);
485
574
  }
486
575
  });
487
576
 
488
577
  it("ends each week on Saturday (dayOfWeek === 6 in ISO)", () => {
489
578
  const weeks = getMonthWeeks(2026, 3, T);
490
579
  for (const week of weeks) {
491
- expect(week[6].dayOfWeek).toBe(6);
580
+ expect(week[6]!.dayOfWeek).toBe(6);
492
581
  }
493
582
  });
494
583
 
@@ -509,28 +598,28 @@ describe.each(temporalVariants)("getMonthWeeks ($name)", ({ T }) => {
509
598
  it("Monday-start: starts each week on Monday (dayOfWeek === 1 in ISO)", () => {
510
599
  const weeks = getMonthWeeks(2026, 3, T, { weekStartDay: 1 });
511
600
  for (const week of weeks) {
512
- expect(week[0].dayOfWeek).toBe(1);
601
+ expect(week[0]!.dayOfWeek).toBe(1);
513
602
  }
514
603
  });
515
604
 
516
605
  it("Monday-start: ends each week on Sunday (dayOfWeek === 7 in ISO)", () => {
517
606
  const weeks = getMonthWeeks(2026, 3, T, { weekStartDay: 1 });
518
607
  for (const week of weeks) {
519
- expect(week[6].dayOfWeek).toBe(7);
608
+ expect(week[6]!.dayOfWeek).toBe(7);
520
609
  }
521
610
  });
522
611
 
523
612
  it("Saturday-start: starts each week on Saturday (dayOfWeek === 6 in ISO)", () => {
524
613
  const weeks = getMonthWeeks(2026, 3, T, { weekStartDay: 6 });
525
614
  for (const week of weeks) {
526
- expect(week[0].dayOfWeek).toBe(6);
615
+ expect(week[0]!.dayOfWeek).toBe(6);
527
616
  }
528
617
  });
529
618
 
530
619
  it("Saturday-start: ends each week on Friday (dayOfWeek === 5 in ISO)", () => {
531
620
  const weeks = getMonthWeeks(2026, 3, T, { weekStartDay: 6 });
532
621
  for (const week of weeks) {
533
- expect(week[6].dayOfWeek).toBe(5);
622
+ expect(week[6]!.dayOfWeek).toBe(5);
534
623
  }
535
624
  });
536
625
 
@@ -554,7 +643,7 @@ describe.each(temporalVariants)("getMonthWeeks ($name)", ({ T }) => {
554
643
  });
555
644
  expect(weeks.length).toBe(6);
556
645
  for (const week of weeks) {
557
- expect(week[0].dayOfWeek).toBe(1);
646
+ expect(week[0]!.dayOfWeek).toBe(1);
558
647
  }
559
648
  }
560
649
  });
@@ -568,14 +657,18 @@ describe.each(temporalVariants)("getMonthWeeks ($name)", ({ T }) => {
568
657
  const nextWeeks = getMonthWeeks(next.year, next.month, T);
569
658
  const allNextDays = nextWeeks.flat();
570
659
 
571
- expect(allNextDays.some((dd) => T.PlainDate.compare(dd, newFocused) === 0)).toBe(true);
660
+ expect(
661
+ allNextDays.some((dd) => T.PlainDate.compare(dd, newFocused) === 0),
662
+ ).toBe(true);
572
663
 
573
664
  const prev = computeAdjacentMonth(current, "prev", T);
574
665
  const prevFocused = focusedDateForMonth(focusedDate, prev, prev.firstDay);
575
666
  const prevWeeks = getMonthWeeks(prev.year, prev.month, T);
576
667
  const allPrevDays = prevWeeks.flat();
577
668
 
578
- expect(allPrevDays.some((dd) => T.PlainDate.compare(dd, prevFocused) === 0)).toBe(true);
669
+ expect(
670
+ allPrevDays.some((dd) => T.PlainDate.compare(dd, prevFocused) === 0),
671
+ ).toBe(true);
579
672
  });
580
673
  });
581
674
 
@@ -586,7 +679,14 @@ describe.each(temporalVariants)("resolveFocusTarget ($name)", ({ T }) => {
586
679
  const march = { year: 2026, month: 3 };
587
680
 
588
681
  it("priority 1: returns focusedDate when it is in the grid", () => {
589
- const result = resolveFocusTarget(d("2026-03-15"), undefined, marchWeeks, march, noDisabled, T);
682
+ const result = resolveFocusTarget(
683
+ d("2026-03-15"),
684
+ undefined,
685
+ marchWeeks,
686
+ march,
687
+ noDisabled,
688
+ T,
689
+ );
590
690
  expect(result.toString()).toBe("2026-03-15");
591
691
  });
592
692
 
@@ -656,7 +756,8 @@ describe.each(temporalVariants)("resolveFocusTarget ($name)", ({ T }) => {
656
756
  });
657
757
 
658
758
  it("falls back to first grid day when all current-month days are disabled", () => {
659
- const allDisabled = (dd: Temporal.PlainDate) => dd.year === 2026 && dd.month === 3;
759
+ const allDisabled = (dd: Temporal.PlainDate) =>
760
+ dd.year === 2026 && dd.month === 3;
660
761
  const result = resolveFocusTarget(
661
762
  d("2026-05-01"),
662
763
  undefined,
@@ -665,10 +766,22 @@ describe.each(temporalVariants)("resolveFocusTarget ($name)", ({ T }) => {
665
766
  allDisabled,
666
767
  T,
667
768
  );
668
- const firstGridDay = marchWeeks[0][0];
769
+ const firstGridDay = marchWeeks[0]![0]!;
669
770
  expect(result.toString()).toBe(firstGridDay.toString());
670
771
  });
671
772
 
773
+ it("falls back to focusedDate when the grid is empty", () => {
774
+ const result = resolveFocusTarget(
775
+ d("2026-03-15"),
776
+ undefined,
777
+ [],
778
+ march,
779
+ noDisabled,
780
+ T,
781
+ );
782
+ expect(result.toString()).toBe("2026-03-15");
783
+ });
784
+
672
785
  it("gridHasFocus=false: selectedDate wins over focusedDate when tabbing into grid", () => {
673
786
  const result = resolveFocusTarget(
674
787
  d("2026-03-01"),
@@ -847,7 +960,7 @@ describe.each(temporalVariants)("isInRange ($name)", ({ T }) => {
847
960
  describe.each(temporalVariants)("computeWeekRangeInfo ($name)", ({ T }) => {
848
961
  const d = (iso: string) => T.PlainDate.from(iso);
849
962
  const marchWeeks = getMonthWeeks(2026, 3, T);
850
- const week1 = marchWeeks[1];
963
+ const week1 = marchWeeks[1]!;
851
964
 
852
965
  it("treats undefined rangeStart as single-day range at rangeEnd", () => {
853
966
  const result = computeWeekRangeInfo(week1, undefined, d("2026-03-10"), T);
@@ -868,23 +981,38 @@ describe.each(temporalVariants)("computeWeekRangeInfo ($name)", ({ T }) => {
868
981
  });
869
982
 
870
983
  it("returns inactive when range has no overlap with week", () => {
871
- const result = computeWeekRangeInfo(week1, d("2026-04-01"), d("2026-04-10"), T);
984
+ const result = computeWeekRangeInfo(
985
+ week1,
986
+ d("2026-04-01"),
987
+ d("2026-04-10"),
988
+ T,
989
+ );
872
990
  expect(result.active).toBe(false);
873
991
  });
874
992
 
875
993
  it("range fully within week", () => {
876
- const result = computeWeekRangeInfo(week1, d("2026-03-09"), d("2026-03-12"), T);
994
+ const result = computeWeekRangeInfo(
995
+ week1,
996
+ d("2026-03-09"),
997
+ d("2026-03-12"),
998
+ T,
999
+ );
877
1000
  expect(result.active).toBe(true);
878
1001
  expect(result.extendsBefore).toBe(false);
879
1002
  expect(result.extendsAfter).toBe(false);
880
- const startDay = week1[result.startIndex];
881
- const endDay = week1[result.endIndex];
1003
+ const startDay = week1[result.startIndex]!;
1004
+ const endDay = week1[result.endIndex]!;
882
1005
  expect(startDay.toString()).toBe("2026-03-09");
883
1006
  expect(endDay.toString()).toBe("2026-03-12");
884
1007
  });
885
1008
 
886
1009
  it("range starts before week", () => {
887
- const result = computeWeekRangeInfo(week1, d("2026-03-01"), d("2026-03-12"), T);
1010
+ const result = computeWeekRangeInfo(
1011
+ week1,
1012
+ d("2026-03-01"),
1013
+ d("2026-03-12"),
1014
+ T,
1015
+ );
888
1016
  expect(result.active).toBe(true);
889
1017
  expect(result.extendsBefore).toBe(true);
890
1018
  expect(result.extendsAfter).toBe(false);
@@ -892,7 +1020,12 @@ describe.each(temporalVariants)("computeWeekRangeInfo ($name)", ({ T }) => {
892
1020
  });
893
1021
 
894
1022
  it("range ends after week", () => {
895
- const result = computeWeekRangeInfo(week1, d("2026-03-09"), d("2026-03-25"), T);
1023
+ const result = computeWeekRangeInfo(
1024
+ week1,
1025
+ d("2026-03-09"),
1026
+ d("2026-03-25"),
1027
+ T,
1028
+ );
896
1029
  expect(result.active).toBe(true);
897
1030
  expect(result.extendsBefore).toBe(false);
898
1031
  expect(result.extendsAfter).toBe(true);
@@ -900,7 +1033,12 @@ describe.each(temporalVariants)("computeWeekRangeInfo ($name)", ({ T }) => {
900
1033
  });
901
1034
 
902
1035
  it("range spans entire week", () => {
903
- const result = computeWeekRangeInfo(week1, d("2026-03-01"), d("2026-03-25"), T);
1036
+ const result = computeWeekRangeInfo(
1037
+ week1,
1038
+ d("2026-03-01"),
1039
+ d("2026-03-25"),
1040
+ T,
1041
+ );
904
1042
  expect(result.active).toBe(true);
905
1043
  expect(result.extendsBefore).toBe(true);
906
1044
  expect(result.extendsAfter).toBe(true);
@@ -918,13 +1056,23 @@ describe.each(temporalVariants)("computeWeekRangeInfo ($name)", ({ T }) => {
918
1056
  });
919
1057
 
920
1058
  it("two-day range within week", () => {
921
- const result = computeWeekRangeInfo(week1, d("2026-03-10"), d("2026-03-11"), T);
1059
+ const result = computeWeekRangeInfo(
1060
+ week1,
1061
+ d("2026-03-10"),
1062
+ d("2026-03-11"),
1063
+ T,
1064
+ );
922
1065
  expect(result.active).toBe(true);
923
1066
  expect(result.endIndex - result.startIndex).toBe(1);
924
1067
  });
925
1068
 
926
1069
  it("returns inactive for empty weekDays array", () => {
927
- const result = computeWeekRangeInfo([], d("2026-03-10"), d("2026-03-15"), T);
1070
+ const result = computeWeekRangeInfo(
1071
+ [],
1072
+ d("2026-03-10"),
1073
+ d("2026-03-15"),
1074
+ T,
1075
+ );
928
1076
  expect(result.active).toBe(false);
929
1077
  });
930
1078
  });