@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/grid.tsx CHANGED
@@ -1,7 +1,14 @@
1
1
  import { mergeProps } from "@base-ui/react/merge-props";
2
2
  import { useRender } from "@base-ui/react/use-render";
3
3
  import type { Temporal } from "@js-temporal/polyfill";
4
- import { useContext, useMemo, useCallback, useEffect, useRef, forwardRef } from "react";
4
+ import {
5
+ useContext,
6
+ useMemo,
7
+ useCallback,
8
+ useEffect,
9
+ useRef,
10
+ forwardRef,
11
+ } from "react";
5
12
  import type { KeyboardEvent } from "react";
6
13
  import { useCalendarStable } from "./calendar-context";
7
14
  import { WeekDataContext, GridContext, GridMonthContext } from "./context";
@@ -15,8 +22,6 @@ import {
15
22
  } from "./month-view-context";
16
23
  import type { StateAttributesMapping } from "./types";
17
24
  import type {
18
- ValueFormat,
19
- RootState,
20
25
  GridState,
21
26
  GridProps,
22
27
  GridBodyState,
@@ -27,7 +32,11 @@ import type {
27
32
  import { useViewContext } from "./view-context";
28
33
  import { WeeksGrid } from "./weeks-grid";
29
34
  import { computeWeeksKeyNav } from "./weeks-keyboard";
30
- import { WeeksViewStateContext, useWeeksViewState, useWeeksViewStable } from "./weeks-view-context";
35
+ import {
36
+ WeeksViewStateContext,
37
+ useWeeksViewState,
38
+ useWeeksViewStable,
39
+ } from "./weeks-view-context";
31
40
  export { GridHeader, GridHeaderCell } from "./grid-header";
32
41
  export { DayCellTemplate, DayButton } from "./day-cell";
33
42
 
@@ -56,7 +65,7 @@ function useGridKeyboard() {
56
65
  maxValue,
57
66
  disabled,
58
67
  readOnly,
59
- isDateDisabled,
68
+ ...(isDateDisabled !== undefined && { isDateDisabled }),
60
69
  T,
61
70
  weekStartDay,
62
71
  });
@@ -111,7 +120,7 @@ function useWeeksGridKeyboard() {
111
120
  maxValue,
112
121
  disabled,
113
122
  readOnly,
114
- isDateDisabled,
123
+ ...(isDateDisabled !== undefined && { isDateDisabled }),
115
124
  scrollBy: weeksStable.scrollBy,
116
125
  T,
117
126
  weekStartDay,
@@ -181,15 +190,18 @@ function GridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElement>) {
181
190
  throw new Error("Grid must be used inside MonthView.Root or WeeksView.Root.");
182
191
  }
183
192
 
184
- export const Grid = forwardRef(GridFn) as <F extends ValueFormat = ValueFormat>(
185
- props: GridProps<F> & React.RefAttributes<HTMLTableElement>,
193
+ export const Grid = forwardRef(GridFn) as (
194
+ props: GridProps & React.RefAttributes<HTMLTableElement>,
186
195
  ) => React.ReactElement | null;
187
196
 
188
197
  // ---------------------------------------------------------------------------
189
198
  // MonthGrid — existing month view rendering (unchanged logic)
190
199
  // ---------------------------------------------------------------------------
191
200
 
192
- function MonthGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElement>) {
201
+ function MonthGridFn(
202
+ props: GridProps,
203
+ ref: React.ForwardedRef<HTMLTableElement>,
204
+ ) {
193
205
  const {
194
206
  render,
195
207
  mode: _mode,
@@ -226,7 +238,8 @@ function MonthGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElement>
226
238
 
227
239
  useEffect(() => {
228
240
  if (autoFocus && gridRef.current) {
229
- const target = gridRef.current.querySelector<HTMLElement>('[tabindex="0"]');
241
+ const target =
242
+ gridRef.current.querySelector<HTMLElement>('[tabindex="0"]');
230
243
  if (target) {
231
244
  target.focus();
232
245
  gridFocusedRef.current = true;
@@ -322,15 +335,18 @@ function MonthGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElement>
322
335
  );
323
336
  }
324
337
 
325
- const MonthGrid = forwardRef(MonthGridFn) as <F extends ValueFormat = ValueFormat>(
326
- props: GridProps<F> & React.RefAttributes<HTMLTableElement>,
338
+ const MonthGrid = forwardRef(MonthGridFn) as (
339
+ props: GridProps & React.RefAttributes<HTMLTableElement>,
327
340
  ) => React.ReactElement | null;
328
341
 
329
342
  // ---------------------------------------------------------------------------
330
343
  // WeeksViewGrid — continuous week rows for WeeksView
331
344
  // ---------------------------------------------------------------------------
332
345
 
333
- function WeeksViewGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElement>) {
346
+ function WeeksViewGridFn(
347
+ props: GridProps,
348
+ ref: React.ForwardedRef<HTMLTableElement>,
349
+ ) {
334
350
  const {
335
351
  render,
336
352
  mode: _mode,
@@ -352,7 +368,8 @@ function WeeksViewGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElem
352
368
 
353
369
  useEffect(() => {
354
370
  if (autoFocus && gridRef.current) {
355
- const target = gridRef.current.querySelector<HTMLElement>('[tabindex="0"]');
371
+ const target =
372
+ gridRef.current.querySelector<HTMLElement>('[tabindex="0"]');
356
373
  if (target) {
357
374
  target.focus();
358
375
  gridFocusedRef.current = true;
@@ -464,9 +481,9 @@ function WeeksViewGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElem
464
481
  allMonths: [],
465
482
  currentDateTime,
466
483
  gridLabelIds,
467
- rootState: {} as RootState,
484
+ rootState: weeksState.rootState,
468
485
  }),
469
- [currentDateTime, gridLabelIds],
486
+ [currentDateTime, gridLabelIds, weeksState.rootState],
470
487
  );
471
488
 
472
489
  return (
@@ -478,8 +495,8 @@ function WeeksViewGridFn(props: GridProps, ref: React.ForwardedRef<HTMLTableElem
478
495
  );
479
496
  }
480
497
 
481
- const WeeksViewGrid = forwardRef(WeeksViewGridFn) as <F extends ValueFormat = ValueFormat>(
482
- props: GridProps<F> & React.RefAttributes<HTMLTableElement>,
498
+ const WeeksViewGrid = forwardRef(WeeksViewGridFn) as (
499
+ props: GridProps & React.RefAttributes<HTMLTableElement>,
483
500
  ) => React.ReactElement | null;
484
501
 
485
502
  const gridBodyStateAttributesMapping = {
@@ -487,7 +504,10 @@ const gridBodyStateAttributesMapping = {
487
504
  } as const satisfies StateAttributesMapping<GridBodyState>;
488
505
 
489
506
  /** Table body wrapping the week rows. Renders a `<tbody>` by default. */
490
- function GridBodyFn(props: GridBodyProps, ref: React.ForwardedRef<HTMLTableSectionElement>) {
507
+ function GridBodyFn(
508
+ props: GridBodyProps,
509
+ ref: React.ForwardedRef<HTMLTableSectionElement>,
510
+ ) {
491
511
  const weeksState = useContext(WeeksViewStateContext);
492
512
 
493
513
  // In WeeksView, delegate to WeeksGrid which handles week iteration
@@ -504,11 +524,14 @@ function GridBodyFn(props: GridBodyProps, ref: React.ForwardedRef<HTMLTableSecti
504
524
  return <MonthGridBody ref={ref} {...props} />;
505
525
  }
506
526
 
507
- export const GridBody = forwardRef(GridBodyFn) as <F extends ValueFormat = ValueFormat>(
508
- props: GridBodyProps<F> & React.RefAttributes<HTMLTableSectionElement>,
527
+ export const GridBody = forwardRef(GridBodyFn) as (
528
+ props: GridBodyProps & React.RefAttributes<HTMLTableSectionElement>,
509
529
  ) => React.ReactElement | null;
510
530
 
511
- function MonthGridBodyFn(props: GridBodyProps, ref: React.ForwardedRef<HTMLTableSectionElement>) {
531
+ function MonthGridBodyFn(
532
+ props: GridBodyProps,
533
+ ref: React.ForwardedRef<HTMLTableSectionElement>,
534
+ ) {
512
535
  const { render, ...otherProps } = props;
513
536
  const { rootState } = useMonthViewState();
514
537
 
@@ -539,8 +562,8 @@ function MonthGridBodyFn(props: GridBodyProps, ref: React.ForwardedRef<HTMLTable
539
562
  });
540
563
  }
541
564
 
542
- const MonthGridBody = forwardRef(MonthGridBodyFn) as <F extends ValueFormat = ValueFormat>(
543
- props: GridBodyProps<F> & React.RefAttributes<HTMLTableSectionElement>,
565
+ const MonthGridBody = forwardRef(MonthGridBodyFn) as (
566
+ props: GridBodyProps & React.RefAttributes<HTMLTableSectionElement>,
544
567
  ) => React.ReactElement | null;
545
568
 
546
569
  const weekInstanceStateAttributesMapping = {
@@ -549,14 +572,14 @@ const weekInstanceStateAttributesMapping = {
549
572
  gridRowIndex: () => null,
550
573
  } as const satisfies StateAttributesMapping<WeekTemplateState>;
551
574
 
552
- function WeekInstance<F extends ValueFormat = ValueFormat>(props: WeekTemplateProps<F>) {
575
+ function WeekInstance(props: WeekTemplateProps) {
553
576
  const { render, ...otherProps } = props;
554
577
  const weekData = useContext(WeekDataContext)!;
555
578
  const { rootState } = useMonthViewState();
556
579
 
557
- const state = useMemo<WeekTemplateState<F>>(
580
+ const state = useMemo<WeekTemplateState>(
558
581
  () => ({
559
- root: rootState as unknown as WeekTemplateState<F>["root"],
582
+ root: rootState,
560
583
  weekIndex: weekData.weekIndex,
561
584
  gridRowIndex: weekData.gridRowIndex,
562
585
  }),
@@ -577,32 +600,41 @@ function WeekInstance<F extends ValueFormat = ValueFormat>(props: WeekTemplatePr
577
600
  * Iterates over the weeks in the current month and renders one `<tr>` per week.
578
601
  * Each instance receives its week's days and index via {@link WeekDataContext}.
579
602
  */
580
- export function WeekTemplate<F extends ValueFormat = ValueFormat>(props: WeekTemplateProps<F>) {
603
+ export function WeekTemplate(props: WeekTemplateProps) {
581
604
  const outerWeekData = useContext(WeekDataContext);
582
605
  const gridMonthCtx = useContext(GridMonthContext);
583
606
  const { weeks: defaultWeeks } = useMonthViewState();
584
607
  const weeks = gridMonthCtx?.weeks ?? defaultWeeks;
585
608
  const gridMonth = useMemo(
586
- () => (gridMonthCtx ? { year: gridMonthCtx.year, month: gridMonthCtx.month } : undefined),
609
+ () =>
610
+ gridMonthCtx
611
+ ? { year: gridMonthCtx.year, month: gridMonthCtx.month }
612
+ : undefined,
587
613
  [gridMonthCtx],
588
614
  );
589
- const Instance = WeekInstance<F>;
615
+ const Instance = WeekInstance;
590
616
 
591
617
  return (
592
618
  <>
593
- {weeks.map((weekDays, i) => (
594
- <WeekDataContext.Provider
595
- key={weekDays[0].toString()}
596
- value={{
597
- days: weekDays,
598
- weekIndex: i,
599
- gridMonth,
600
- gridRowIndex: outerWeekData?.gridRowIndex,
601
- }}
602
- >
603
- <Instance {...props} />
604
- </WeekDataContext.Provider>
605
- ))}
619
+ {weeks.map((weekDays, i) => {
620
+ const firstDay = weekDays[0];
621
+ if (firstDay === undefined) return null;
622
+ return (
623
+ <WeekDataContext.Provider
624
+ key={firstDay.toString()}
625
+ value={{
626
+ days: weekDays,
627
+ weekIndex: i,
628
+ ...(gridMonth !== undefined && { gridMonth }),
629
+ ...(outerWeekData?.gridRowIndex !== undefined && {
630
+ gridRowIndex: outerWeekData.gridRowIndex,
631
+ }),
632
+ }}
633
+ >
634
+ <Instance {...props} />
635
+ </WeekDataContext.Provider>
636
+ );
637
+ })}
606
638
  </>
607
639
  );
608
640
  }
package/src/index.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  export { CalendarProvider } from "./calendar-provider";
2
2
  export { MonthView, MonthViewRoot } from "./month-view";
3
- export { Grid, GridBody, WeekTemplate, DayCellTemplate, DayButton } from "./grid";
3
+ export {
4
+ Grid,
5
+ GridBody,
6
+ WeekTemplate,
7
+ DayCellTemplate,
8
+ DayButton,
9
+ } from "./grid";
4
10
  export { GridHeader, GridHeaderCell } from "./grid-header";
5
11
  export {
6
12
  DateString,
@@ -14,7 +20,11 @@ export { RangePreview } from "./range-preview";
14
20
  export { RangeStartDragHandle, RangeEndDragHandle } from "./drag-handle";
15
21
  export { WeekNumberCell, WeekNumberHeader } from "./week-number";
16
22
  export { WeeksView, WeeksViewRoot } from "./weeks-view";
17
- export { PrevWeeksButton, NextWeeksButton, WeekCount } from "./weeks-navigation";
23
+ export {
24
+ PrevWeeksButton,
25
+ NextWeeksButton,
26
+ WeekCount,
27
+ } from "./weeks-navigation";
18
28
  export {
19
29
  MonthSeparator,
20
30
  MonthSeparatorRow,
@@ -26,7 +36,6 @@ export {
26
36
  export { computePreviewRange } from "./root-selection";
27
37
  export { computeWeeksInWindow } from "./compute-weeks-in-window";
28
38
  export { resolveFirstWeek, resolveFirstWeekSpec } from "./resolve-first-week";
29
- export { Temporal } from "./temporal-polyfill";
30
39
  export { useCalendarStable, useCalendarState } from "./calendar-context";
31
40
  export { useMonthViewStable, useMonthViewState } from "./month-view-context";
32
41
  export { useViewContext } from "./view-context";
@@ -84,7 +93,10 @@ export type {
84
93
  } from "./types";
85
94
 
86
95
  export type { CalendarProviderProps } from "./calendar-types";
87
- export type { CalendarStableContextValue, CalendarStateContextValue } from "./calendar-types";
96
+ export type {
97
+ CalendarStableContextValue,
98
+ CalendarStateContextValue,
99
+ } from "./calendar-types";
88
100
  export type {
89
101
  MonthViewRootProps,
90
102
  MonthViewStableContextValue,
@@ -6,7 +6,9 @@ import { temporalVariants } from "./test-temporal";
6
6
  describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
7
7
  const d = (iso: string) => T.PlainDate.from(iso);
8
8
 
9
- function nav(overrides: Partial<KeyboardNavInput> & { key: string }): KeyboardNavInput {
9
+ function nav(
10
+ overrides: Partial<KeyboardNavInput> & { key: string },
11
+ ): KeyboardNavInput {
10
12
  return {
11
13
  shiftKey: false,
12
14
  focusedDate: d("2026-03-15"),
@@ -114,9 +116,15 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
114
116
  ["2026-03-15", "2027-03-15"],
115
117
  ["2024-02-29", "2025-02-28"],
116
118
  ["2026-12-31", "2027-12-31"],
117
- ] as const)("from %s → %s (day constrained for leap year)", (focused, expected) => {
118
- expectMove(nav({ key: "PageDown", shiftKey: true, focusedDate: d(focused) }), expected);
119
- });
119
+ ] as const)(
120
+ "from %s → %s (day constrained for leap year)",
121
+ (focused, expected) => {
122
+ expectMove(
123
+ nav({ key: "PageDown", shiftKey: true, focusedDate: d(focused) }),
124
+ expected,
125
+ );
126
+ },
127
+ );
120
128
  });
121
129
 
122
130
  describe("Shift+PageUp — previous year", () => {
@@ -124,9 +132,15 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
124
132
  ["2026-03-15", "2025-03-15"],
125
133
  ["2024-02-29", "2023-02-28"],
126
134
  ["2027-01-01", "2026-01-01"],
127
- ] as const)("from %s → %s (day constrained for leap year)", (focused, expected) => {
128
- expectMove(nav({ key: "PageUp", shiftKey: true, focusedDate: d(focused) }), expected);
129
- });
135
+ ] as const)(
136
+ "from %s → %s (day constrained for leap year)",
137
+ (focused, expected) => {
138
+ expectMove(
139
+ nav({ key: "PageUp", shiftKey: true, focusedDate: d(focused) }),
140
+ expected,
141
+ );
142
+ },
143
+ );
130
144
  });
131
145
 
132
146
  describe("Enter and Space — select", () => {
@@ -161,9 +175,12 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
161
175
  });
162
176
 
163
177
  describe("unrecognized keys return none", () => {
164
- it.each(["Tab", "Escape", "a", "Delete", "F1"] as const)("%s returns none", (key) => {
165
- expectNone(nav({ key }));
166
- });
178
+ it.each(["Tab", "Escape", "a", "Delete", "F1"] as const)(
179
+ "%s returns none",
180
+ (key) => {
181
+ expectNone(nav({ key }));
182
+ },
183
+ );
167
184
  });
168
185
 
169
186
  describe("min bound clamping", () => {
@@ -173,16 +190,25 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
173
190
  ["ArrowLeft", "2026-03-10"],
174
191
  ["ArrowUp", "2026-03-10"],
175
192
  ["Home", "2026-03-10"],
176
- ] as const)("%s from %s is none (already at min boundary)", (key, focused) => {
177
- expectNone(nav({ key, focusedDate: d(focused), minValue: min }));
178
- });
193
+ ] as const)(
194
+ "%s from %s is none (already at min boundary)",
195
+ (key, focused) => {
196
+ expectNone(nav({ key, focusedDate: d(focused), minValue: min }));
197
+ },
198
+ );
179
199
 
180
200
  it.each([
181
201
  ["ArrowLeft", "2026-03-11", "2026-03-10"],
182
202
  ["ArrowRight", "2026-03-10", "2026-03-11"],
183
- ] as const)("%s from %s → %s (at or above min)", (key, focused, expected) => {
184
- expectMove(nav({ key, focusedDate: d(focused), minValue: min }), expected);
185
- });
203
+ ] as const)(
204
+ "%s from %s → %s (at or above min)",
205
+ (key, focused, expected) => {
206
+ expectMove(
207
+ nav({ key, focusedDate: d(focused), minValue: min }),
208
+ expected,
209
+ );
210
+ },
211
+ );
186
212
 
187
213
  it("ArrowUp clamps to min when target is below min", () => {
188
214
  expectMove(
@@ -192,7 +218,10 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
192
218
  });
193
219
 
194
220
  it("Home clamps to min when start-of-week is below min", () => {
195
- expectMove(nav({ key: "Home", focusedDate: d("2026-03-12"), minValue: min }), "2026-03-10");
221
+ expectMove(
222
+ nav({ key: "Home", focusedDate: d("2026-03-12"), minValue: min }),
223
+ "2026-03-10",
224
+ );
196
225
  });
197
226
 
198
227
  it("PageUp clamps to min when target month is before min", () => {
@@ -236,16 +265,25 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
236
265
  ["ArrowRight", "2026-03-20"],
237
266
  ["ArrowDown", "2026-03-20"],
238
267
  ["End", "2026-03-20"],
239
- ] as const)("%s from %s is none (already at max boundary)", (key, focused) => {
240
- expectNone(nav({ key, focusedDate: d(focused), maxValue: max }));
241
- });
268
+ ] as const)(
269
+ "%s from %s is none (already at max boundary)",
270
+ (key, focused) => {
271
+ expectNone(nav({ key, focusedDate: d(focused), maxValue: max }));
272
+ },
273
+ );
242
274
 
243
275
  it.each([
244
276
  ["ArrowRight", "2026-03-19", "2026-03-20"],
245
277
  ["ArrowLeft", "2026-03-20", "2026-03-19"],
246
- ] as const)("%s from %s → %s (at or below max)", (key, focused, expected) => {
247
- expectMove(nav({ key, focusedDate: d(focused), maxValue: max }), expected);
248
- });
278
+ ] as const)(
279
+ "%s from %s → %s (at or below max)",
280
+ (key, focused, expected) => {
281
+ expectMove(
282
+ nav({ key, focusedDate: d(focused), maxValue: max }),
283
+ expected,
284
+ );
285
+ },
286
+ );
249
287
 
250
288
  it("ArrowDown clamps to max when target exceeds max", () => {
251
289
  expectMove(
@@ -259,7 +297,10 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
259
297
  });
260
298
 
261
299
  it("End clamps to max when end-of-week exceeds max", () => {
262
- expectMove(nav({ key: "End", focusedDate: d("2026-03-16"), maxValue: max }), "2026-03-20");
300
+ expectMove(
301
+ nav({ key: "End", focusedDate: d("2026-03-16"), maxValue: max }),
302
+ "2026-03-20",
303
+ );
263
304
  });
264
305
 
265
306
  it("PageDown clamps to max when target month exceeds max", () => {
@@ -396,18 +437,25 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
396
437
  });
397
438
 
398
439
  describe("readOnly suppresses select but allows move", () => {
399
- it.each(["Enter", " "] as const)("%s returns none when readOnly", (key) => {
400
- expectNone(nav({ key, readOnly: true }));
401
- });
402
-
403
- it.each(["ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown", "PageUp", "PageDown"] as const)(
404
- "%s still works when readOnly",
440
+ it.each(["Enter", " "] as const)(
441
+ "%s returns none when readOnly",
405
442
  (key) => {
406
- const result = computeNextFocusDate(nav({ key, readOnly: true }));
407
- expect(result.action).toBe("move");
443
+ expectNone(nav({ key, readOnly: true }));
408
444
  },
409
445
  );
410
446
 
447
+ it.each([
448
+ "ArrowRight",
449
+ "ArrowLeft",
450
+ "ArrowUp",
451
+ "ArrowDown",
452
+ "PageUp",
453
+ "PageDown",
454
+ ] as const)("%s still works when readOnly", (key) => {
455
+ const result = computeNextFocusDate(nav({ key, readOnly: true }));
456
+ expect(result.action).toBe("move");
457
+ });
458
+
411
459
  it("Home still works when readOnly (from mid-week)", () => {
412
460
  const result = computeNextFocusDate(
413
461
  nav({ key: "Home", readOnly: true, focusedDate: d("2026-03-18") }),
@@ -429,24 +477,40 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
429
477
  ["2026-03-18", "2026-03-16"],
430
478
  ["2026-03-21", "2026-03-16"],
431
479
  ["2026-03-22", "2026-03-16"],
432
- ] as const)("Home from %s → %s (Monday start of week)", (focused, expected) => {
433
- expectMove(nav({ key: "Home", focusedDate: d(focused), weekStartDay: 1 }), expected);
434
- });
480
+ ] as const)(
481
+ "Home from %s → %s (Monday start of week)",
482
+ (focused, expected) => {
483
+ expectMove(
484
+ nav({ key: "Home", focusedDate: d(focused), weekStartDay: 1 }),
485
+ expected,
486
+ );
487
+ },
488
+ );
435
489
 
436
490
  it("Home from Monday (already at start) → none", () => {
437
- expectNone(nav({ key: "Home", focusedDate: d("2026-03-16"), weekStartDay: 1 }));
491
+ expectNone(
492
+ nav({ key: "Home", focusedDate: d("2026-03-16"), weekStartDay: 1 }),
493
+ );
438
494
  });
439
495
 
440
496
  it.each([
441
497
  ["2026-03-16", "2026-03-22"],
442
498
  ["2026-03-17", "2026-03-22"],
443
499
  ["2026-03-21", "2026-03-22"],
444
- ] as const)("End from %s → %s (Sunday end of week)", (focused, expected) => {
445
- expectMove(nav({ key: "End", focusedDate: d(focused), weekStartDay: 1 }), expected);
446
- });
500
+ ] as const)(
501
+ "End from %s → %s (Sunday end of week)",
502
+ (focused, expected) => {
503
+ expectMove(
504
+ nav({ key: "End", focusedDate: d(focused), weekStartDay: 1 }),
505
+ expected,
506
+ );
507
+ },
508
+ );
447
509
 
448
510
  it("End from Sunday (already at end) → none", () => {
449
- expectNone(nav({ key: "End", focusedDate: d("2026-03-22"), weekStartDay: 1 }));
511
+ expectNone(
512
+ nav({ key: "End", focusedDate: d("2026-03-22"), weekStartDay: 1 }),
513
+ );
450
514
  });
451
515
  });
452
516
 
@@ -459,7 +523,9 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
459
523
  });
460
524
 
461
525
  it("Home from Saturday (already at start) → none", () => {
462
- expectNone(nav({ key: "Home", focusedDate: d("2026-03-14"), weekStartDay: 6 }));
526
+ expectNone(
527
+ nav({ key: "Home", focusedDate: d("2026-03-14"), weekStartDay: 6 }),
528
+ );
463
529
  });
464
530
 
465
531
  it("End from Saturday (2026-03-14) → Friday (2026-03-20)", () => {
@@ -470,7 +536,9 @@ describe.each(temporalVariants)("computeNextFocusDate ($name)", ({ T }) => {
470
536
  });
471
537
 
472
538
  it("End from Friday (already at end) → none", () => {
473
- expectNone(nav({ key: "End", focusedDate: d("2026-03-20"), weekStartDay: 6 }));
539
+ expectNone(
540
+ nav({ key: "End", focusedDate: d("2026-03-20"), weekStartDay: 6 }),
541
+ );
474
542
  });
475
543
  });
476
544
 
package/src/keyboard.ts CHANGED
@@ -58,9 +58,12 @@ function clampToBounds(
58
58
  T: TemporalNamespace,
59
59
  ): KeyboardNavResult {
60
60
  let clamped = target;
61
- if (minValue && T.PlainDate.compare(clamped, minValue) < 0) clamped = minValue;
62
- if (maxValue && T.PlainDate.compare(clamped, maxValue) > 0) clamped = maxValue;
63
- if (T.PlainDate.compare(clamped, focusedDate) === 0) return { action: "none" };
61
+ if (minValue && T.PlainDate.compare(clamped, minValue) < 0)
62
+ clamped = minValue;
63
+ if (maxValue && T.PlainDate.compare(clamped, maxValue) > 0)
64
+ clamped = maxValue;
65
+ if (T.PlainDate.compare(clamped, focusedDate) === 0)
66
+ return { action: "none" };
64
67
  return { action: "move", date: clamped };
65
68
  }
66
69
 
@@ -71,7 +74,9 @@ function clampToBounds(
71
74
  * PageUp/PageDown (±1 month, ±1 year with Shift), and Enter/Space (select).
72
75
  * Results are clamped to `minValue`/`maxValue` bounds.
73
76
  */
74
- export function computeNextFocusDate(input: KeyboardNavInput): KeyboardNavResult {
77
+ export function computeNextFocusDate(
78
+ input: KeyboardNavInput,
79
+ ): KeyboardNavResult {
75
80
  const {
76
81
  key,
77
82
  shiftKey,
@@ -105,18 +110,24 @@ export function computeNextFocusDate(input: KeyboardNavInput): KeyboardNavResult
105
110
  break;
106
111
  case "Home": {
107
112
  const adjustedDow =
108
- ((focusedDate.dayOfWeek % daysInWeek) - weekStartDay + daysInWeek) % daysInWeek;
113
+ ((focusedDate.dayOfWeek % daysInWeek) - weekStartDay + daysInWeek) %
114
+ daysInWeek;
109
115
  nextDate = focusedDate.subtract({ days: adjustedDow });
110
116
  break;
111
117
  }
112
118
  case "End": {
113
119
  const adjustedDow =
114
- ((focusedDate.dayOfWeek % daysInWeek) - weekStartDay + daysInWeek) % daysInWeek;
120
+ ((focusedDate.dayOfWeek % daysInWeek) - weekStartDay + daysInWeek) %
121
+ daysInWeek;
115
122
  nextDate = focusedDate.add({ days: daysInWeek - 1 - adjustedDow });
116
123
  break;
117
124
  }
118
125
  case "PageUp": {
119
- const target = computeMonthJumpTarget(focusedDate, shiftKey ? -12 : -1, T);
126
+ const target = computeMonthJumpTarget(
127
+ focusedDate,
128
+ shiftKey ? -12 : -1,
129
+ T,
130
+ );
120
131
  return clampToBounds(target, focusedDate, minValue, maxValue, T);
121
132
  }
122
133
  case "PageDown": {
@@ -29,7 +29,9 @@ function renderInTable(ui: React.ReactElement, data = mockData) {
29
29
  return render(
30
30
  <table>
31
31
  <tbody>
32
- <MonthSeparatorDataContext.Provider value={data}>{ui}</MonthSeparatorDataContext.Provider>
32
+ <MonthSeparatorDataContext.Provider value={data}>
33
+ {ui}
34
+ </MonthSeparatorDataContext.Provider>
33
35
  </tbody>
34
36
  </table>,
35
37
  );