@klinking/colander 2.0.3 → 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 +11 -2
  31. package/dist/index.d.mts +11 -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/{index-BWNknC9t.d.mts → weeks-view-context-CNAq2Hiu.d.cts} +77 -22
  36. package/dist/{index-DV_WxL3K.d.cts → weeks-view-context-CsP3PBiu.d.mts} +77 -22
  37. package/package.json +1 -1
  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
@@ -1,7 +1,7 @@
1
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
- import { useRender } from "@base-ui/react/use-render";
3
1
  import * as _$react from "react";
4
2
  import React$1 from "react";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
+ import { useRender } from "@base-ui/react/use-render";
5
5
 
6
6
  //#region ../node_modules/.pnpm/@js-temporal+polyfill@0.5.1/node_modules/@js-temporal/polyfill/index.d.ts
7
7
  declare namespace Temporal {
@@ -1544,16 +1544,55 @@ interface CalendarStateContextValue {
1544
1544
  baseRootState: BaseRootState;
1545
1545
  }
1546
1546
  //#endregion
1547
- //#region src/calendar-provider.d.ts
1547
+ //#region src/out-of-range.d.ts
1548
1548
  /**
1549
- * Provides shared calendar state (selection, config, range preview) to all
1550
- * descendant view components. Does NOT manage focus, navigation, or grid data.
1549
+ * Controls how a {@link WeeksView} window behaves when navigation would move it
1550
+ * past the `min`/`max` bounds.
1551
+ *
1552
+ * `min`/`max` always restrict which **days are selectable**. `outOfRangeBehavior`
1553
+ * is a separate concern: it decides whether the **visible window** may scroll
1554
+ * beyond those bounds, and how the edge is handled.
1555
+ *
1556
+ * - `"unbounded"` — Navigation is never restricted by `min`/`max`; any range of
1557
+ * weeks can be viewed. Out-of-range days simply render disabled. (Default.)
1558
+ * - `"stop"` — Navigation halts at the boundary: the Prev/Next button is
1559
+ * disabled once the next step would show a window containing no in-range day.
1560
+ * - `"stop-shrink"` — Like `"stop"`, but near the edge the window **shrinks** to
1561
+ * fewer week rows instead of showing rows that are entirely out of range.
1562
+ * - `"snap"` — A jump that would overshoot **snaps** the window so its edge
1563
+ * aligns to the last/first in-range week, rather than stopping or overshooting.
1564
+ * - `"snap-shrink"` — Snap to the boundary, then **shrink** the window to just
1565
+ * the in-range weeks.
1566
+ *
1567
+ * `"snap"` and `"snap-shrink"` are identical **unless the selectable range spans
1568
+ * fewer weeks than `weekCount`** — i.e. the window is taller than the range.
1569
+ * Snapping can only pin *one* edge to a bound; if the range is narrower than the
1570
+ * window, the opposite edge still overhangs into out-of-range weeks. `"snap"`
1571
+ * keeps the full `weekCount` (padding the overhang with all-disabled week rows),
1572
+ * while `"snap-shrink"` trims those rows so only the in-range weeks show.
1573
+ *
1574
+ * Example with `weekCount: 6` and a `min`/`max` that span just 2 weeks: `"snap"`
1575
+ * shows 6 rows (4 of them fully disabled), `"snap-shrink"` shows 2 rows. When
1576
+ * the range is ≥ `weekCount` weeks wide, the snapped window already fits, so the
1577
+ * two behave the same.
1551
1578
  */
1552
- declare function CalendarProvider<F extends ValueFormat = "PlainDate">(props: CalendarProviderProps<F>): _$react_jsx_runtime0.JSX.Element;
1553
- //#endregion
1554
- //#region src/overflow.d.ts
1555
- type OverflowBehavior = "unbounded" | "stop" | "stop-shrink" | "snap" | "snap-shrink";
1556
- type MonthOverflowBehavior = "unbounded" | "stop";
1579
+ type OutOfRangeBehavior = "unbounded" | "stop" | "stop-shrink" | "snap" | "snap-shrink";
1580
+ /**
1581
+ * Controls how {@link MonthView} navigation behaves when it would move the
1582
+ * visible month(s) past the `min`/`max` bounds.
1583
+ *
1584
+ * `min`/`max` always restrict which **days are selectable**. This decides
1585
+ * whether you can still **view** months outside them.
1586
+ *
1587
+ * - `"unbounded"` — Prev/Next are never disabled by `min`/`max`; you can page to
1588
+ * any month. Out-of-range days render disabled. (Default.)
1589
+ * - `"stop"` — Prev/Next become disabled once the destination month crosses the
1590
+ * boundary.
1591
+ *
1592
+ * MonthView renders fixed month grids, so the `"…-shrink"`/`"snap…"` modes that
1593
+ * {@link OutOfRangeBehavior} offers for WeeksView's flexible window don't apply.
1594
+ */
1595
+ type MonthOutOfRangeBehavior = "unbounded" | "stop";
1557
1596
  //#endregion
1558
1597
  //#region src/month-view-types.d.ts
1559
1598
  /** Props accepted by `MonthView.Root`. */
@@ -1575,12 +1614,17 @@ interface MonthViewRootProps {
1575
1614
  */
1576
1615
  outsideDays?: OutsideDays | undefined;
1577
1616
  /**
1578
- * How month navigation behaves at `min`/`max` bounds.
1579
- * - `"unbounded"` — navigation is always allowed.
1580
- * - `"stop"` — navigation buttons disable at the boundary.
1617
+ * How month navigation behaves at the `min`/`max` bounds. `min`/`max` always
1618
+ * restrict which **days are selectable**; this controls whether you can still
1619
+ * **view** months outside them. See {@link MonthOutOfRangeBehavior}.
1620
+ *
1621
+ * - `"unbounded"` — Prev/Next are never disabled by `min`/`max`; you can page
1622
+ * to any month, with out-of-range days rendered disabled.
1623
+ * - `"stop"` — Prev/Next disable once the destination month crosses the bound.
1624
+ *
1581
1625
  * @default "unbounded"
1582
1626
  */
1583
- overflowBehavior?: MonthOverflowBehavior | undefined;
1627
+ outOfRangeBehavior?: MonthOutOfRangeBehavior | undefined;
1584
1628
  /**
1585
1629
  * The controlled visible month. When provided, the component is controlled.
1586
1630
  *
@@ -1610,7 +1654,7 @@ interface MonthViewStableContextValue {
1610
1654
  /** How outside-month days are displayed. */
1611
1655
  outsideDays: OutsideDays;
1612
1656
  /** How month navigation behaves at bounds. */
1613
- overflowBehavior: MonthOverflowBehavior;
1657
+ outOfRangeBehavior: MonthOutOfRangeBehavior;
1614
1658
  /** Navigate to the next month(s). */
1615
1659
  goNextMonth: () => void;
1616
1660
  /** Navigate to the previous month(s). */
@@ -1828,10 +1872,21 @@ interface WeeksViewRootProps {
1828
1872
  */
1829
1873
  scrollBy?: "row" | "page" | undefined;
1830
1874
  /**
1831
- * How navigation behaves at `min`/`max` bounds.
1875
+ * How the visible window behaves at the `min`/`max` bounds. `min`/`max`
1876
+ * always restrict which **days are selectable**; this controls whether the
1877
+ * window may scroll beyond them, and how the edge is handled. See
1878
+ * {@link OutOfRangeBehavior}.
1879
+ *
1880
+ * - `"unbounded"` — navigation is never restricted by `min`/`max`.
1881
+ * - `"stop"` — navigation halts once the next step has no in-range day.
1882
+ * - `"stop-shrink"` — like `"stop"`, but the window shrinks at the edge.
1883
+ * - `"snap"` — overshooting jumps snap the window edge to the last/first
1884
+ * in-range week.
1885
+ * - `"snap-shrink"` — snap to the boundary, shrinking if still out of range.
1886
+ *
1832
1887
  * @default "unbounded"
1833
1888
  */
1834
- overflowBehavior?: OverflowBehavior | undefined;
1889
+ outOfRangeBehavior?: OutOfRangeBehavior | undefined;
1835
1890
  /** Called when the visible window changes. */
1836
1891
  onWindowChange?: ((info: WindowInfo) => void) | undefined;
1837
1892
  /** React children. */
@@ -1866,7 +1921,7 @@ interface WeeksViewStableContextValue {
1866
1921
  /** How much to scroll per navigation step. */
1867
1922
  scrollBy: "row" | "page";
1868
1923
  /** How navigation behaves at bounds. */
1869
- overflowBehavior: OverflowBehavior;
1924
+ outOfRangeBehavior: OutOfRangeBehavior;
1870
1925
  /** Navigate to the next week(s). Optionally override the shift amount (in weeks). */
1871
1926
  goNext: (shiftBy?: number) => void;
1872
1927
  /** Navigate to the previous week(s). Optionally override the shift amount (in weeks). */
@@ -1935,19 +1990,19 @@ type WeekCountState = {
1935
1990
  type WeekCountProps = useRender.ComponentProps<"span", WeekCountState>;
1936
1991
  /**
1937
1992
  * Button that navigates to the previous week(s). Automatically disabled when
1938
- * no more weeks are available based on `overflowBehavior` and `min`.
1993
+ * no more weeks are available based on `outOfRangeBehavior` and `min`.
1939
1994
  * Exposes `data-direction="prev"`.
1940
1995
  */
1941
1996
  declare const PrevWeeksButton: React$1.ForwardRefExoticComponent<Omit<PrevWeeksButtonProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
1942
1997
  /**
1943
1998
  * Button that navigates to the next week(s). Automatically disabled when
1944
- * no more weeks are available based on `overflowBehavior` and `max`.
1999
+ * no more weeks are available based on `outOfRangeBehavior` and `max`.
1945
2000
  * Exposes `data-direction="next"`.
1946
2001
  */
1947
2002
  declare const NextWeeksButton: React$1.ForwardRefExoticComponent<Omit<NextWeeksButtonProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
1948
2003
  /**
1949
2004
  * Renders the current visible week count as a number. Useful with shrink
1950
- * overflow modes where the actual count may be less than the `weekCount` prop.
2005
+ * out-of-range modes where the actual count may be less than the `weekCount` prop.
1951
2006
  */
1952
2007
  declare const WeekCount: React$1.ForwardRefExoticComponent<Omit<WeekCountProps, "ref"> & React$1.RefAttributes<HTMLSpanElement>>;
1953
2008
  //#endregion
@@ -2043,4 +2098,4 @@ declare function useWeeksViewStable(): WeeksViewStableContextValue;
2043
2098
  /** Returns the WeeksView state context (volatile grid data). */
2044
2099
  declare function useWeeksViewState(): WeeksViewStateContextValue;
2045
2100
  //#endregion
2046
- export { GridBody as $, TimeStringProps as $t, VisibleMonth as A, GridHeaderCellState as At, resolveFirstWeekSpec as B, OutsideDays as Bt, WeekCountState as C, DayCellTemplateProps as Ct, WeeksViewProps as D, GridBodyProps as Dt, WeeksView as E, DragHandleState as Et, WeekDescriptor as F, MonthData as Ft, RangePreview as G, RangePreviewProps as Gt, WeekNumberHeader as H, PrevMonthButtonProps as Ht, computeWeeksInWindow as I, MonthYearStringProps as It, MonthYearString as J, RangeSelectedState as Jt, RangeSelected as K, RangePreviewState as Kt, FirstWeekSpec as L, MonthYearStringState as Lt, WeeksViewStableContextValue as M, GridHeaderState as Mt, WeeksViewStateContextValue as N, GridProps as Nt, WeeksViewRoot as O, GridBodyState as Ot, WindowInfo as P, GridState as Pt, Grid as Q, TemporalNamespace as Qt, ScrollToWeekSnap as R, NavButtonState as Rt, WeekCountProps as S, DayButtonState as St, WeeksNavButtonState as T, DragHandleOwnProps as Tt, RangeEndDragHandle as U, RangeEndDragHandleProps as Ut, WeekNumberCell as V, PlainDateObject as Vt, RangeStartDragHandle as W, RangeMode as Wt, PrevMonthButton as X, RawValueForFormat as Xt, NextMonthButton as Y, RangeStartDragHandleProps as Yt, TimeString as Z, RootState as Zt, NextWeeksButton as _, DateRange as _t, useMonthViewStable as a, WeekNumberCellState as an, MonthView as at, PrevWeeksButtonProps as b, DateValueObject as bt, useCalendarState as c, WeekStartDay as cn, MonthViewRootProps as ct, MonthSeparatorCell as d, DayCellDataContext as dn, MonthOverflowBehavior as dt, TimeStringState as en, WeekTemplate as et, MonthSeparatorMonth as f, GridContext as fn, OverflowBehavior as ft, MonthSeparatorYear as g, CalendarStateContextValue as gt, MonthSeparatorWeekCount as h, CalendarStableContextValue as ht, useViewContext as i, WeekNumberCellProps as in, GridHeaderCell as it, WeeksViewRootProps as j, GridHeaderProps as jt, WeeksViewRootHandle as k, GridHeaderCellProps as kt, computePreviewRange as l, WeekTemplateProps as ln, MonthViewStableContextValue as lt, MonthSeparatorState as m, CalendarProviderProps as mt, useWeeksViewState as n, ValueForFormat as nn, DayCellTemplate as nt, useMonthViewState as o, WeekNumberHeaderProps as on, MonthViewProps as ot, MonthSeparatorRow as p, WeekDataContext as pn, CalendarProvider as pt, DateString as q, RangeSelectedProps as qt, ViewContextValue as r, ValueFormat as rn, GridHeader as rt, useCalendarStable as s, WeekNumberHeaderState as sn, MonthViewRoot as st, useWeeksViewStable as t, ValueChangeMeta as tn, DayButton as tt, MonthSeparator as u, WeekTemplateState as un, MonthViewStateContextValue as ut, NextWeeksButtonProps as v, DateStringProps as vt, WeeksNavButtonOwnProps as w, DayCellTemplateState as wt, WeekCount as x, DayButtonProps as xt, PrevWeeksButton as y, DateStringState as yt, resolveFirstWeek as z, NextMonthButtonProps as zt };
2101
+ export { GridBody as $, TimeStringState as $t, VisibleMonth as A, GridHeaderProps as At, resolveFirstWeekSpec as B, PlainDateObject as Bt, WeekCountState as C, DayCellTemplateState as Ct, WeeksViewProps as D, GridBodyState as Dt, WeeksView as E, GridBodyProps as Et, WeekDescriptor as F, MonthYearStringProps as Ft, RangePreview as G, RangePreviewState as Gt, WeekNumberHeader as H, RangeEndDragHandleProps as Ht, computeWeeksInWindow as I, MonthYearStringState as It, MonthYearString as J, RangeStartDragHandleProps as Jt, RangeSelected as K, RangeSelectedProps as Kt, FirstWeekSpec as L, NavButtonState as Lt, WeeksViewStableContextValue as M, GridProps as Mt, WeeksViewStateContextValue as N, GridState as Nt, WeeksViewRoot as O, GridHeaderCellProps as Ot, WindowInfo as P, MonthData as Pt, Grid as Q, TimeStringProps as Qt, ScrollToWeekSnap as R, NextMonthButtonProps as Rt, WeekCountProps as S, DayCellTemplateProps as St, WeeksNavButtonState as T, DragHandleState as Tt, RangeEndDragHandle as U, RangeMode as Ut, WeekNumberCell as V, PrevMonthButtonProps as Vt, RangeStartDragHandle as W, RangePreviewProps as Wt, PrevMonthButton as X, RootState as Xt, NextMonthButton as Y, RawValueForFormat as Yt, TimeString as Z, TemporalNamespace as Zt, NextWeeksButton as _, DateStringProps as _t, useMonthViewStable as a, WeekNumberHeaderProps as an, MonthView as at, PrevWeeksButtonProps as b, DayButtonProps as bt, useCalendarState as c, WeekTemplateProps as cn, MonthViewRootProps as ct, MonthSeparatorCell as d, GridContext as dn, MonthOutOfRangeBehavior as dt, ValueChangeMeta as en, WeekTemplate as et, MonthSeparatorMonth as f, WeekDataContext as fn, OutOfRangeBehavior as ft, MonthSeparatorYear as g, DateRange as gt, MonthSeparatorWeekCount as h, CalendarStateContextValue as ht, useViewContext as i, WeekNumberCellState as in, GridHeaderCell as it, WeeksViewRootProps as j, GridHeaderState as jt, WeeksViewRootHandle as k, GridHeaderCellState as kt, computePreviewRange as l, WeekTemplateState as ln, MonthViewStableContextValue as lt, MonthSeparatorState as m, CalendarStableContextValue as mt, useWeeksViewState as n, ValueFormat as nn, DayCellTemplate as nt, useMonthViewState as o, WeekNumberHeaderState as on, MonthViewProps as ot, MonthSeparatorRow as p, CalendarProviderProps as pt, DateString as q, RangeSelectedState as qt, ViewContextValue as r, WeekNumberCellProps as rn, GridHeader as rt, useCalendarStable as s, WeekStartDay as sn, MonthViewRoot as st, useWeeksViewStable as t, ValueForFormat as tn, DayButton as tt, MonthSeparator as u, DayCellDataContext as un, MonthViewStateContextValue as ut, NextWeeksButtonProps as v, DateStringState as vt, WeeksNavButtonOwnProps as w, DragHandleOwnProps as wt, WeekCount as x, DayButtonState as xt, PrevWeeksButton as y, DateValueObject as yt, resolveFirstWeek as z, OutsideDays as zt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klinking/colander",
3
- "version": "2.0.3",
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",
@@ -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,