@klinking/colander 2.0.2 → 3.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 (56) hide show
  1. package/dist/formats/date.cjs +1 -1
  2. package/dist/formats/date.d.cts +2 -2
  3. package/dist/formats/date.d.mts +2 -2
  4. package/dist/formats/date.mjs +1 -1
  5. package/dist/formats/object.cjs +1 -1
  6. package/dist/formats/object.d.cts +2 -2
  7. package/dist/formats/object.d.mts +2 -2
  8. package/dist/formats/object.mjs +1 -1
  9. package/dist/formats/plain-date-time.cjs +1 -1
  10. package/dist/formats/plain-date-time.d.cts +2 -2
  11. package/dist/formats/plain-date-time.d.mts +2 -2
  12. package/dist/formats/plain-date-time.mjs +1 -1
  13. package/dist/formats/plain-date.cjs +1 -1
  14. package/dist/formats/plain-date.d.cts +2 -2
  15. package/dist/formats/plain-date.d.mts +2 -2
  16. package/dist/formats/plain-date.mjs +1 -1
  17. package/dist/formats/plain-month-day.cjs +1 -1
  18. package/dist/formats/plain-month-day.d.cts +2 -2
  19. package/dist/formats/plain-month-day.d.mts +2 -2
  20. package/dist/formats/plain-month-day.mjs +1 -1
  21. package/dist/formats/plain-year-month.cjs +1 -1
  22. package/dist/formats/plain-year-month.d.cts +2 -2
  23. package/dist/formats/plain-year-month.d.mts +2 -2
  24. package/dist/formats/plain-year-month.mjs +1 -1
  25. package/dist/formats/zoned-date-time.cjs +1 -1
  26. package/dist/formats/zoned-date-time.d.cts +2 -2
  27. package/dist/formats/zoned-date-time.d.mts +2 -2
  28. package/dist/formats/zoned-date-time.mjs +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.mjs +1 -1
  33. package/dist/{weeks-navigation-Xve4O55H.mjs → weeks-navigation-Bg0nZLgh.mjs} +43 -41
  34. package/dist/{weeks-navigation-epiyL4IP.cjs → weeks-navigation-CJzhxbgj.cjs} +43 -41
  35. package/dist/{weeks-view-context-BZeWx9N8.d.cts → weeks-view-context-CNAq2Hiu.d.cts} +77 -15
  36. package/dist/{weeks-view-context-MVe1b-BS.d.mts → weeks-view-context-CsP3PBiu.d.mts} +77 -15
  37. package/package.json +92 -26
  38. package/src/formats/date.ts +4 -1
  39. package/src/formats/object.ts +4 -1
  40. package/src/formats/plain-date-time.ts +4 -1
  41. package/src/formats/plain-date.ts +4 -1
  42. package/src/formats/plain-month-day.ts +4 -1
  43. package/src/formats/plain-year-month.ts +4 -1
  44. package/src/formats/zoned-date-time.ts +4 -1
  45. package/src/grid.tsx +1 -1
  46. package/src/index.ts +4 -1
  47. package/src/month-view-types.ts +11 -6
  48. package/src/month-view.test.tsx +44 -2
  49. package/src/month-view.tsx +6 -6
  50. package/src/navigation.tsx +13 -1
  51. package/src/{overflow.test.ts → out-of-range.test.ts} +16 -12
  52. package/src/{overflow.ts → out-of-range.ts} +56 -10
  53. package/src/weeks-navigation.tsx +8 -7
  54. package/src/weeks-view-state.ts +33 -26
  55. package/src/weeks-view-types.ts +15 -4
  56. package/src/weeks-view.tsx +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klinking/colander",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "homepage": "https://github.com/klink-ing/colander#readme",
5
5
  "bugs": "https://github.com/klink-ing/colander/issues",
6
6
  "license": "MIT",
@@ -17,47 +17,113 @@
17
17
  "sideEffects": false,
18
18
  "main": "./dist/index.cjs",
19
19
  "module": "./dist/index.mjs",
20
- "types": "./dist/index.d.mts",
20
+ "types": "./dist/index.d.cts",
21
+ "typesVersions": {
22
+ "*": {
23
+ "plain-date": [
24
+ "./dist/formats/plain-date.d.cts"
25
+ ],
26
+ "plain-date-time": [
27
+ "./dist/formats/plain-date-time.d.cts"
28
+ ],
29
+ "plain-month-day": [
30
+ "./dist/formats/plain-month-day.d.cts"
31
+ ],
32
+ "plain-year-month": [
33
+ "./dist/formats/plain-year-month.d.cts"
34
+ ],
35
+ "zoned-date-time": [
36
+ "./dist/formats/zoned-date-time.d.cts"
37
+ ],
38
+ "object": [
39
+ "./dist/formats/object.d.cts"
40
+ ],
41
+ "date": [
42
+ "./dist/formats/date.d.cts"
43
+ ]
44
+ }
45
+ },
21
46
  "exports": {
47
+ "./package.json": "./package.json",
22
48
  ".": {
23
- "types": "./dist/index.d.mts",
24
- "import": "./dist/index.mjs",
25
- "require": "./dist/index.cjs"
49
+ "import": {
50
+ "types": "./dist/index.d.mts",
51
+ "default": "./dist/index.mjs"
52
+ },
53
+ "require": {
54
+ "types": "./dist/index.d.cts",
55
+ "default": "./dist/index.cjs"
56
+ }
26
57
  },
27
58
  "./plain-date": {
28
- "types": "./dist/formats/plain-date.d.mts",
29
- "import": "./dist/formats/plain-date.mjs",
30
- "require": "./dist/formats/plain-date.cjs"
59
+ "import": {
60
+ "types": "./dist/formats/plain-date.d.mts",
61
+ "default": "./dist/formats/plain-date.mjs"
62
+ },
63
+ "require": {
64
+ "types": "./dist/formats/plain-date.d.cts",
65
+ "default": "./dist/formats/plain-date.cjs"
66
+ }
31
67
  },
32
68
  "./plain-date-time": {
33
- "types": "./dist/formats/plain-date-time.d.mts",
34
- "import": "./dist/formats/plain-date-time.mjs",
35
- "require": "./dist/formats/plain-date-time.cjs"
69
+ "import": {
70
+ "types": "./dist/formats/plain-date-time.d.mts",
71
+ "default": "./dist/formats/plain-date-time.mjs"
72
+ },
73
+ "require": {
74
+ "types": "./dist/formats/plain-date-time.d.cts",
75
+ "default": "./dist/formats/plain-date-time.cjs"
76
+ }
36
77
  },
37
78
  "./plain-month-day": {
38
- "types": "./dist/formats/plain-month-day.d.mts",
39
- "import": "./dist/formats/plain-month-day.mjs",
40
- "require": "./dist/formats/plain-month-day.cjs"
79
+ "import": {
80
+ "types": "./dist/formats/plain-month-day.d.mts",
81
+ "default": "./dist/formats/plain-month-day.mjs"
82
+ },
83
+ "require": {
84
+ "types": "./dist/formats/plain-month-day.d.cts",
85
+ "default": "./dist/formats/plain-month-day.cjs"
86
+ }
41
87
  },
42
88
  "./plain-year-month": {
43
- "types": "./dist/formats/plain-year-month.d.mts",
44
- "import": "./dist/formats/plain-year-month.mjs",
45
- "require": "./dist/formats/plain-year-month.cjs"
89
+ "import": {
90
+ "types": "./dist/formats/plain-year-month.d.mts",
91
+ "default": "./dist/formats/plain-year-month.mjs"
92
+ },
93
+ "require": {
94
+ "types": "./dist/formats/plain-year-month.d.cts",
95
+ "default": "./dist/formats/plain-year-month.cjs"
96
+ }
46
97
  },
47
98
  "./zoned-date-time": {
48
- "types": "./dist/formats/zoned-date-time.d.mts",
49
- "import": "./dist/formats/zoned-date-time.mjs",
50
- "require": "./dist/formats/zoned-date-time.cjs"
99
+ "import": {
100
+ "types": "./dist/formats/zoned-date-time.d.mts",
101
+ "default": "./dist/formats/zoned-date-time.mjs"
102
+ },
103
+ "require": {
104
+ "types": "./dist/formats/zoned-date-time.d.cts",
105
+ "default": "./dist/formats/zoned-date-time.cjs"
106
+ }
51
107
  },
52
108
  "./object": {
53
- "types": "./dist/formats/object.d.mts",
54
- "import": "./dist/formats/object.mjs",
55
- "require": "./dist/formats/object.cjs"
109
+ "import": {
110
+ "types": "./dist/formats/object.d.mts",
111
+ "default": "./dist/formats/object.mjs"
112
+ },
113
+ "require": {
114
+ "types": "./dist/formats/object.d.cts",
115
+ "default": "./dist/formats/object.cjs"
116
+ }
56
117
  },
57
118
  "./date": {
58
- "types": "./dist/formats/date.d.mts",
59
- "import": "./dist/formats/date.mjs",
60
- "require": "./dist/formats/date.cjs"
119
+ "import": {
120
+ "types": "./dist/formats/date.d.mts",
121
+ "default": "./dist/formats/date.mjs"
122
+ },
123
+ "require": {
124
+ "types": "./dist/formats/date.d.cts",
125
+ "default": "./dist/formats/date.cjs"
126
+ }
61
127
  }
62
128
  },
63
129
  "devDependencies": {
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
@@ -169,6 +169,9 @@ export type { WeekDescriptor } from "../compute-weeks-in-window";
169
169
 
170
170
  export type { FirstWeekSpec, ScrollToWeekSnap } from "../resolve-first-week";
171
171
 
172
- export type { OverflowBehavior, MonthOverflowBehavior } from "../overflow";
172
+ export type {
173
+ OutOfRangeBehavior,
174
+ MonthOutOfRangeBehavior,
175
+ } from "../out-of-range";
173
176
 
174
177
  export type { MonthSeparatorState } from "../month-separator";
package/src/grid.tsx CHANGED
@@ -460,7 +460,7 @@ function WeeksViewGridFn(
460
460
  numberOfMonths: 1,
461
461
  fixedWeeks: false,
462
462
  outsideDays: "enabled" as const,
463
- overflowBehavior: "unbounded" as const,
463
+ outOfRangeBehavior: "unbounded" as const,
464
464
  goNextMonth: () => {},
465
465
  goPrevMonth: () => {},
466
466
  setGridLabelId: () => {},
package/src/index.ts CHANGED
@@ -124,5 +124,8 @@ export { useWeeksViewStable, useWeeksViewState } from "./weeks-view-context";
124
124
 
125
125
  export type { WeekDescriptor } from "./compute-weeks-in-window";
126
126
  export type { FirstWeekSpec, ScrollToWeekSnap } from "./resolve-first-week";
127
- export type { OverflowBehavior, MonthOverflowBehavior } from "./overflow";
127
+ export type {
128
+ OutOfRangeBehavior,
129
+ MonthOutOfRangeBehavior,
130
+ } from "./out-of-range";
128
131
  export type { MonthSeparatorState } from "./month-separator";
@@ -1,5 +1,5 @@
1
1
  import type { Temporal } from "@js-temporal/polyfill";
2
- import type { MonthOverflowBehavior } from "./overflow";
2
+ import type { MonthOutOfRangeBehavior } from "./out-of-range";
3
3
  import type { MonthData, OutsideDays, RootState } from "./types";
4
4
 
5
5
  // ---------------------------------------------------------------------------
@@ -25,12 +25,17 @@ export interface MonthViewRootProps {
25
25
  */
26
26
  outsideDays?: OutsideDays | undefined;
27
27
  /**
28
- * How month navigation behaves at `min`/`max` bounds.
29
- * - `"unbounded"` — navigation is always allowed.
30
- * - `"stop"` — navigation buttons disable at the boundary.
28
+ * How month navigation behaves at the `min`/`max` bounds. `min`/`max` always
29
+ * restrict which **days are selectable**; this controls whether you can still
30
+ * **view** months outside them. See {@link MonthOutOfRangeBehavior}.
31
+ *
32
+ * - `"unbounded"` — Prev/Next are never disabled by `min`/`max`; you can page
33
+ * to any month, with out-of-range days rendered disabled.
34
+ * - `"stop"` — Prev/Next disable once the destination month crosses the bound.
35
+ *
31
36
  * @default "unbounded"
32
37
  */
33
- overflowBehavior?: MonthOverflowBehavior | undefined;
38
+ outOfRangeBehavior?: MonthOutOfRangeBehavior | undefined;
34
39
  /**
35
40
  * The controlled visible month. When provided, the component is controlled.
36
41
  *
@@ -65,7 +70,7 @@ export interface MonthViewStableContextValue {
65
70
  /** How outside-month days are displayed. */
66
71
  outsideDays: OutsideDays;
67
72
  /** How month navigation behaves at bounds. */
68
- overflowBehavior: MonthOverflowBehavior;
73
+ outOfRangeBehavior: MonthOutOfRangeBehavior;
69
74
  /** Navigate to the next month(s). */
70
75
  goNextMonth: () => void;
71
76
  /** Navigate to the previous month(s). */
@@ -758,7 +758,7 @@ describe("numberOfMonths", () => {
758
758
  unmount();
759
759
  });
760
760
 
761
- it("next button disabled when last visible month reaches max", () => {
761
+ it('outOfRangeBehavior="stop": next button disabled when last visible month reaches max', () => {
762
762
  const maxDate = Temporal.PlainDate.from("2026-05-31");
763
763
  const { container, unmount } = render(
764
764
  <MonthView
@@ -766,6 +766,7 @@ describe("numberOfMonths", () => {
766
766
  defaultValue={march15}
767
767
  numberOfMonths={3}
768
768
  max={maxDate}
769
+ outOfRangeBehavior="stop"
769
770
  >
770
771
  <NextMonthButton data-testid="next" />
771
772
  </MonthView>,
@@ -778,7 +779,7 @@ describe("numberOfMonths", () => {
778
779
  unmount();
779
780
  });
780
781
 
781
- it("prev button disabled when first visible month reaches min", () => {
782
+ it('outOfRangeBehavior="stop": prev button disabled when first visible month reaches min', () => {
782
783
  const minDate = Temporal.PlainDate.from("2026-03-01");
783
784
  const { container, unmount } = render(
784
785
  <MonthView
@@ -786,6 +787,7 @@ describe("numberOfMonths", () => {
786
787
  defaultValue={march15}
787
788
  numberOfMonths={2}
788
789
  min={minDate}
790
+ outOfRangeBehavior="stop"
789
791
  >
790
792
  <PrevMonthButton data-testid="prev" />
791
793
  </MonthView>,
@@ -798,6 +800,46 @@ describe("numberOfMonths", () => {
798
800
  unmount();
799
801
  });
800
802
 
803
+ it('outOfRangeBehavior="unbounded" (default): next button stays enabled past max', () => {
804
+ const maxDate = Temporal.PlainDate.from("2026-05-31");
805
+ const { container, unmount } = render(
806
+ <MonthView
807
+ {...defaultProps}
808
+ defaultValue={march15}
809
+ numberOfMonths={3}
810
+ max={maxDate}
811
+ >
812
+ <NextMonthButton data-testid="next" />
813
+ </MonthView>,
814
+ );
815
+
816
+ // Default is "unbounded": max only restricts selectable days, not which
817
+ // months can be viewed, so the button must NOT disable at the bound.
818
+ const btn = container.querySelector('[data-testid="next"]')!;
819
+ expect(btn.getAttribute("disabled")).toBeNull();
820
+
821
+ unmount();
822
+ });
823
+
824
+ it('outOfRangeBehavior="unbounded" (default): prev button stays enabled past min', () => {
825
+ const minDate = Temporal.PlainDate.from("2026-03-01");
826
+ const { container, unmount } = render(
827
+ <MonthView
828
+ {...defaultProps}
829
+ defaultValue={march15}
830
+ numberOfMonths={2}
831
+ min={minDate}
832
+ >
833
+ <PrevMonthButton data-testid="prev" />
834
+ </MonthView>,
835
+ );
836
+
837
+ const btn = container.querySelector('[data-testid="prev"]')!;
838
+ expect(btn.getAttribute("disabled")).toBeNull();
839
+
840
+ unmount();
841
+ });
842
+
801
843
  it("clicking next shifts view by one month", () => {
802
844
  let captured:
803
845
  | { currentMonth: { year: number; month: number } }
@@ -33,7 +33,7 @@ function MonthViewRoot(props: MonthViewRootProps) {
33
33
  numberOfMonths: numberOfMonthsProp,
34
34
  fixedWeeks: fixedWeeksProp,
35
35
  outsideDays: outsideDaysProp,
36
- overflowBehavior: overflowBehaviorProp,
36
+ outOfRangeBehavior: outOfRangeBehaviorProp,
37
37
  month: monthProp,
38
38
  defaultMonth: defaultMonthProp,
39
39
  onMonthChange,
@@ -43,7 +43,7 @@ function MonthViewRoot(props: MonthViewRootProps) {
43
43
  const numberOfMonths = Math.max(1, Math.min(numberOfMonthsProp ?? 1, 12));
44
44
  const fixedWeeks = fixedWeeksProp ?? false;
45
45
  const outsideDays = outsideDaysProp ?? "enabled";
46
- const overflowBehavior = overflowBehaviorProp ?? "unbounded";
46
+ const outOfRangeBehavior = outOfRangeBehaviorProp ?? "unbounded";
47
47
 
48
48
  // Read calendar-level context
49
49
  const calStable = useCalendarStable();
@@ -383,7 +383,7 @@ function MonthViewRoot(props: MonthViewRootProps) {
383
383
  numberOfMonths,
384
384
  fixedWeeks,
385
385
  outsideDays,
386
- overflowBehavior,
386
+ outOfRangeBehavior,
387
387
  goNextMonth,
388
388
  goPrevMonth,
389
389
  setGridLabelId,
@@ -393,7 +393,7 @@ function MonthViewRoot(props: MonthViewRootProps) {
393
393
  numberOfMonths,
394
394
  fixedWeeks,
395
395
  outsideDays,
396
- overflowBehavior,
396
+ outOfRangeBehavior,
397
397
  goNextMonth,
398
398
  goPrevMonth,
399
399
  setGridLabelId,
@@ -447,7 +447,7 @@ function MonthView<F extends ValueFormat = "PlainDate">(
447
447
  numberOfMonths,
448
448
  fixedWeeks,
449
449
  outsideDays,
450
- overflowBehavior,
450
+ outOfRangeBehavior,
451
451
  month,
452
452
  defaultMonth,
453
453
  onMonthChange,
@@ -461,7 +461,7 @@ function MonthView<F extends ValueFormat = "PlainDate">(
461
461
  numberOfMonths={numberOfMonths}
462
462
  fixedWeeks={fixedWeeks}
463
463
  outsideDays={outsideDays}
464
- overflowBehavior={overflowBehavior}
464
+ outOfRangeBehavior={outOfRangeBehavior}
465
465
  month={month}
466
466
  defaultMonth={defaultMonth}
467
467
  onMonthChange={onMonthChange}
@@ -249,6 +249,7 @@ function useNavButton(direction: "prev" | "next") {
249
249
  goNextMonth: goToNextMonth,
250
250
  goPrevMonth: goToPrevMonth,
251
251
  numberOfMonths,
252
+ outOfRangeBehavior,
252
253
  } = monthViewStable;
253
254
  const {
254
255
  currentMonth: currentDateTime,
@@ -285,6 +286,10 @@ function useNavButton(direction: "prev" | "next") {
285
286
 
286
287
  const isDisabled = useMemo(() => {
287
288
  if (globalDisabled) return true;
289
+ // "unbounded" never disables on min/max — the bounds only gate which days
290
+ // are selectable, not which months can be viewed. "stop" halts navigation
291
+ // once the destination month crosses the boundary.
292
+ if (outOfRangeBehavior === "unbounded") return false;
288
293
  if (!boundValue) return false;
289
294
  if (direction === "prev") {
290
295
  return (
@@ -296,7 +301,14 @@ function useNavButton(direction: "prev" | "next") {
296
301
  destYear > boundValue.year ||
297
302
  (destYear === boundValue.year && destMonth > boundValue.month)
298
303
  );
299
- }, [globalDisabled, destYear, destMonth, boundValue, direction]);
304
+ }, [
305
+ globalDisabled,
306
+ outOfRangeBehavior,
307
+ destYear,
308
+ destMonth,
309
+ boundValue,
310
+ direction,
311
+ ]);
300
312
 
301
313
  // ISO — `destYear`/`destMonth` are ISO numbers; the locale calendar only
302
314
  // affects display, so it must not be injected into this value.
@@ -1,11 +1,15 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { describe, it, expect } from "vitest";
3
- import { applyOverflow, canShift, type OverflowBehavior } from "./overflow";
3
+ import {
4
+ applyOutOfRange,
5
+ canShift,
6
+ type OutOfRangeBehavior,
7
+ } from "./out-of-range";
4
8
 
5
9
  const T = Temporal;
6
10
  const pd = (s: string) => T.PlainDate.from(s);
7
11
 
8
- describe("applyOverflow", () => {
12
+ describe("applyOutOfRange", () => {
9
13
  const min = pd("2025-12-01");
10
14
  const max = pd("2026-01-10");
11
15
 
@@ -14,7 +18,7 @@ describe("applyOverflow", () => {
14
18
  description: "unbounded — no adjustment",
15
19
  targetFirstWeek: pd("2026-02-01"),
16
20
  weekCount: 8,
17
- behavior: "unbounded" as OverflowBehavior,
21
+ behavior: "unbounded" as OutOfRangeBehavior,
18
22
  useMinMax: true,
19
23
  expected: { firstWeek: "2026-02-01", weekCount: 8 },
20
24
  },
@@ -22,7 +26,7 @@ describe("applyOverflow", () => {
22
26
  description: "stop — target has valid weeks, allowed",
23
27
  targetFirstWeek: pd("2025-12-07"),
24
28
  weekCount: 8,
25
- behavior: "stop" as OverflowBehavior,
29
+ behavior: "stop" as OutOfRangeBehavior,
26
30
  useMinMax: true,
27
31
  expected: { firstWeek: "2025-12-07", weekCount: 8 },
28
32
  },
@@ -30,7 +34,7 @@ describe("applyOverflow", () => {
30
34
  description: "snap — pulls back when target overshoots max",
31
35
  targetFirstWeek: pd("2026-01-11"),
32
36
  weekCount: 8,
33
- behavior: "snap" as OverflowBehavior,
37
+ behavior: "snap" as OutOfRangeBehavior,
34
38
  useMinMax: true,
35
39
  expected: {
36
40
  firstWeek: "2025-11-16",
@@ -41,7 +45,7 @@ describe("applyOverflow", () => {
41
45
  description: "snap-shrink — pulls back and trims disabled rows",
42
46
  targetFirstWeek: pd("2026-01-11"),
43
47
  weekCount: 8,
44
- behavior: "snap-shrink" as OverflowBehavior,
48
+ behavior: "snap-shrink" as OutOfRangeBehavior,
45
49
  useMinMax: true,
46
50
  expected: {
47
51
  firstWeek: "2025-11-30",
@@ -52,7 +56,7 @@ describe("applyOverflow", () => {
52
56
  description: "stop-shrink — trims disabled rows",
53
57
  targetFirstWeek: pd("2025-12-07"),
54
58
  weekCount: 8,
55
- behavior: "stop-shrink" as OverflowBehavior,
59
+ behavior: "stop-shrink" as OutOfRangeBehavior,
56
60
  useMinMax: true,
57
61
  expected: {
58
62
  firstWeek: "2025-12-07",
@@ -63,14 +67,14 @@ describe("applyOverflow", () => {
63
67
  description: "no min/max — all modes behave as unbounded",
64
68
  targetFirstWeek: pd("2026-06-01"),
65
69
  weekCount: 8,
66
- behavior: "snap" as OverflowBehavior,
70
+ behavior: "snap" as OutOfRangeBehavior,
67
71
  useMinMax: false,
68
72
  expected: { firstWeek: "2026-06-01", weekCount: 8 },
69
73
  },
70
74
  ])(
71
75
  "$description",
72
76
  ({ targetFirstWeek, weekCount, behavior, useMinMax, expected }) => {
73
- const result = applyOverflow({
77
+ const result = applyOutOfRange({
74
78
  targetFirstWeek,
75
79
  weekCount,
76
80
  behavior,
@@ -91,21 +95,21 @@ describe("canShift", () => {
91
95
  it.each([
92
96
  {
93
97
  description: "unbounded — always true",
94
- behavior: "unbounded" as OverflowBehavior,
98
+ behavior: "unbounded" as OutOfRangeBehavior,
95
99
  currentFirstWeek: pd("2026-06-01"),
96
100
  direction: 1 as const,
97
101
  expected: true,
98
102
  },
99
103
  {
100
104
  description: "stop — false when target has no valid weeks",
101
- behavior: "stop" as OverflowBehavior,
105
+ behavior: "stop" as OutOfRangeBehavior,
102
106
  currentFirstWeek: pd("2025-12-28"),
103
107
  direction: 1 as const,
104
108
  expected: false,
105
109
  },
106
110
  {
107
111
  description: "snap — false when already at clamp position",
108
- behavior: "snap" as OverflowBehavior,
112
+ behavior: "snap" as OutOfRangeBehavior,
109
113
  currentFirstWeek: pd("2025-11-16"),
110
114
  direction: 1 as const,
111
115
  expected: false,