@klinking/colander 3.1.0-alpha.4 → 3.1.0-alpha.5

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 (44) hide show
  1. package/dist/formats/date.cjs +1 -1
  2. package/dist/formats/date.d.cts +1 -1
  3. package/dist/formats/date.d.mts +1 -1
  4. package/dist/formats/date.mjs +1 -1
  5. package/dist/formats/object.cjs +1 -1
  6. package/dist/formats/object.d.cts +1 -1
  7. package/dist/formats/object.d.mts +1 -1
  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 +1 -1
  11. package/dist/formats/plain-date-time.d.mts +1 -1
  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 +1 -1
  15. package/dist/formats/plain-date.d.mts +1 -1
  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 +1 -1
  19. package/dist/formats/plain-month-day.d.mts +1 -1
  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 +1 -1
  23. package/dist/formats/plain-year-month.d.mts +1 -1
  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 +1 -1
  27. package/dist/formats/zoned-date-time.d.mts +1 -1
  28. package/dist/formats/zoned-date-time.mjs +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +1 -1
  31. package/dist/index.d.mts +1 -1
  32. package/dist/index.mjs +1 -1
  33. package/dist/{weeks-navigation-elCpdfQ3.mjs → weeks-navigation-CEV8w_69.mjs} +210 -196
  34. package/dist/{weeks-navigation-DV538__x.cjs → weeks-navigation-q3beZn2n.cjs} +210 -196
  35. package/dist/{weeks-view-context-CUCy8njs.d.cts → weeks-view-context-BLZZm1fq.d.mts} +31 -2
  36. package/dist/{weeks-view-context-E1NwyNgQ.d.mts → weeks-view-context-CkTcdZpj.d.cts} +31 -2
  37. package/package.json +1 -1
  38. package/src/month-view-navigation.ts +180 -0
  39. package/src/month-view-types.ts +3 -0
  40. package/src/month-view.bounds.test.tsx +136 -0
  41. package/src/month-view.tsx +37 -205
  42. package/src/month-window.test.ts +207 -0
  43. package/src/month-window.ts +93 -0
  44. package/src/navigation.tsx +15 -74
@@ -1330,6 +1330,177 @@ function useMonthViewState() {
1330
1330
  return ctx;
1331
1331
  }
1332
1332
  //#endregion
1333
+ //#region src/month-view-navigation.ts
1334
+ /**
1335
+ * Owns which month the view shows, in both controlled and uncontrolled mode:
1336
+ * the month state, the Prev/Next steps, and syncing the window with focus.
1337
+ *
1338
+ * `onMonthChange` fires exactly once per move: from the effect below when
1339
+ * uncontrolled, and from the step or the focus-sync effect when controlled.
1340
+ */
1341
+ function useMonthNavigation(input) {
1342
+ const { month, defaultMonth, initialAnchor, onMonthChange, policy, focusedDate, setFocusedDate, T } = input;
1343
+ const isControlled = month !== void 0;
1344
+ const [internalMonth, setInternalMonth] = (0, react.useState)(() => {
1345
+ if (month) return {
1346
+ year: month.year,
1347
+ month: month.month
1348
+ };
1349
+ if (defaultMonth) return {
1350
+ year: defaultMonth.year,
1351
+ month: defaultMonth.month
1352
+ };
1353
+ const anchor = initialAnchor();
1354
+ return {
1355
+ year: anchor.year,
1356
+ month: anchor.month
1357
+ };
1358
+ });
1359
+ const year = isControlled ? month.year : internalMonth.year;
1360
+ const monthNumber = isControlled ? month.month : internalMonth.month;
1361
+ const currentMonth = (0, react.useMemo)(() => ({
1362
+ year,
1363
+ month: monthNumber
1364
+ }), [year, monthNumber]);
1365
+ const viewingYearMonth = (0, react.useMemo)(() => T.PlainYearMonth.from({
1366
+ year,
1367
+ month: monthNumber
1368
+ }), [
1369
+ year,
1370
+ monthNumber,
1371
+ T
1372
+ ]);
1373
+ const onMonthChangeRef = (0, react.useRef)(onMonthChange);
1374
+ onMonthChangeRef.current = onMonthChange;
1375
+ const notifyMonth = (0, react.useCallback)((target) => {
1376
+ onMonthChangeRef.current?.(T.PlainYearMonth.from(target));
1377
+ }, [T]);
1378
+ const skipFocusSyncForRef = (0, react.useRef)(null);
1379
+ const prevFocusedRef = (0, react.useRef)(focusedDate);
1380
+ (0, react.useEffect)(() => {
1381
+ skipFocusSyncForRef.current = null;
1382
+ }, [month?.year, month?.month]);
1383
+ (0, react.useEffect)(() => {
1384
+ const prevFocused = prevFocusedRef.current;
1385
+ prevFocusedRef.current = focusedDate;
1386
+ const target = {
1387
+ year: focusedDate.year,
1388
+ month: focusedDate.month
1389
+ };
1390
+ if (isControlled) {
1391
+ if (skipFocusSyncForRef.current === focusedDate) {
1392
+ skipFocusSyncForRef.current = null;
1393
+ return;
1394
+ }
1395
+ if (prevFocused === focusedDate) return;
1396
+ if (policy.isVisible(currentMonth, target)) return;
1397
+ notifyMonth(policy.reveal(currentMonth, target));
1398
+ return;
1399
+ }
1400
+ setInternalMonth((prev) => {
1401
+ const next = policy.reveal(prev, target);
1402
+ if (next.year === prev.year && next.month === prev.month) return prev;
1403
+ return next;
1404
+ });
1405
+ }, [
1406
+ focusedDate,
1407
+ isControlled,
1408
+ policy,
1409
+ currentMonth,
1410
+ notifyMonth
1411
+ ]);
1412
+ const mountedRef = (0, react.useRef)(false);
1413
+ (0, react.useEffect)(() => {
1414
+ if (!mountedRef.current) {
1415
+ mountedRef.current = true;
1416
+ return;
1417
+ }
1418
+ if (isControlled) return;
1419
+ onMonthChangeRef.current?.(viewingYearMonth);
1420
+ }, [viewingYearMonth, isControlled]);
1421
+ const go = (0, react.useCallback)((direction) => {
1422
+ if (isControlled) {
1423
+ const step = policy.step(month, direction);
1424
+ if (step.blocked) return;
1425
+ const nextFocus = focusedDateForMonth(focusedDate, step.start, step.firstDay);
1426
+ skipFocusSyncForRef.current = nextFocus;
1427
+ notifyMonth(step.start);
1428
+ setFocusedDate(nextFocus);
1429
+ return;
1430
+ }
1431
+ setInternalMonth((m) => {
1432
+ const step = policy.step(m, direction);
1433
+ if (step.blocked) return m;
1434
+ setFocusedDate((prev) => focusedDateForMonth(prev, step.start, step.firstDay));
1435
+ return step.start;
1436
+ });
1437
+ }, [
1438
+ isControlled,
1439
+ month,
1440
+ policy,
1441
+ notifyMonth,
1442
+ focusedDate,
1443
+ setFocusedDate
1444
+ ]);
1445
+ return {
1446
+ currentMonth,
1447
+ viewingYearMonth,
1448
+ goNextMonth: (0, react.useCallback)(() => go("next"), [go]),
1449
+ goPrevMonth: (0, react.useCallback)(() => go("prev"), [go])
1450
+ };
1451
+ }
1452
+ //#endregion
1453
+ //#region src/month-window.ts
1454
+ const monthIndex = (m) => m.year * 12 + (m.month - 1);
1455
+ /**
1456
+ * Builds the policy for a MonthView window of `numberOfMonths` months.
1457
+ *
1458
+ * `unbounded` never blocks a step: `min`/`max` only gate which days are
1459
+ * selectable, not which months can be viewed. Any other behavior is `stop`,
1460
+ * which blocks a step whose entering month lies beyond the bound's month.
1461
+ */
1462
+ function createMonthWindowPolicy(input) {
1463
+ const { numberOfMonths, behavior, min, max, T } = input;
1464
+ return {
1465
+ step(start, direction) {
1466
+ const adjacent = computeAdjacentMonth(start, direction, T);
1467
+ const newStart = {
1468
+ year: adjacent.year,
1469
+ month: adjacent.month
1470
+ };
1471
+ const entering = direction === "prev" ? newStart : monthAt(newStart, numberOfMonths - 1);
1472
+ let blocked = false;
1473
+ if (behavior !== "unbounded") {
1474
+ const bound = direction === "prev" ? min : max;
1475
+ if (bound) {
1476
+ const diff = monthIndex(entering) - monthIndex(bound);
1477
+ blocked = direction === "prev" ? diff < 0 : diff > 0;
1478
+ }
1479
+ }
1480
+ return {
1481
+ start: newStart,
1482
+ entering,
1483
+ firstDay: adjacent.firstDay,
1484
+ blocked
1485
+ };
1486
+ },
1487
+ isVisible(start, target) {
1488
+ const offset = monthIndex(target) - monthIndex(start);
1489
+ return offset >= 0 && offset < numberOfMonths;
1490
+ },
1491
+ reveal(start, target) {
1492
+ return shiftWindowToMonth(start, target, numberOfMonths);
1493
+ }
1494
+ };
1495
+ }
1496
+ function monthAt(start, offset) {
1497
+ const index = monthIndex(start) + offset;
1498
+ return {
1499
+ year: Math.floor(index / 12),
1500
+ month: index % 12 + 1
1501
+ };
1502
+ }
1503
+ //#endregion
1333
1504
  //#region src/view-context.ts
1334
1505
  /** @internal React context for the active view (MonthView or WeeksView). */
1335
1506
  const ViewContext = (0, react.createContext)(null);
@@ -1367,29 +1538,38 @@ function MonthViewRoot(props) {
1367
1538
  const calState = useCalendarState();
1368
1539
  const T = calStable.temporal;
1369
1540
  const { timeZone, today, weekStartDay, isDateDisabled } = calStable;
1370
- const isMonthControlled = monthProp !== void 0;
1371
- const [internalMonth, setInternalMonth] = (0, react.useState)(() => {
1372
- if (monthProp) return {
1373
- year: monthProp.year,
1374
- month: monthProp.month
1375
- };
1376
- if (defaultMonthProp) return {
1377
- year: defaultMonthProp.year,
1378
- month: defaultMonthProp.month
1379
- };
1380
- const anchor = resolveInitialAnchor(calState.selected, today, timeZone, T);
1381
- return {
1382
- year: anchor.year,
1383
- month: anchor.month
1384
- };
1385
- });
1386
- const currentMonth = isMonthControlled ? {
1387
- year: monthProp.year,
1388
- month: monthProp.month
1389
- } : internalMonth;
1390
1541
  const [focusedDate, setFocusedDate] = (0, react.useState)(() => resolveInitialAnchor(calState.selected, today, timeZone, T));
1391
1542
  const [gridHasFocus, setGridHasFocus] = (0, react.useState)(false);
1392
1543
  const gridFocusedRef = (0, react.useRef)(false);
1544
+ const { minValue, maxValue } = calStable;
1545
+ const windowPolicy = (0, react.useMemo)(() => createMonthWindowPolicy({
1546
+ numberOfMonths,
1547
+ behavior: outOfRangeBehavior,
1548
+ min: minValue,
1549
+ max: maxValue,
1550
+ T
1551
+ }), [
1552
+ numberOfMonths,
1553
+ outOfRangeBehavior,
1554
+ minValue,
1555
+ maxValue,
1556
+ T
1557
+ ]);
1558
+ const { currentMonth, viewingYearMonth, goNextMonth, goPrevMonth } = useMonthNavigation({
1559
+ month: monthProp,
1560
+ defaultMonth: defaultMonthProp,
1561
+ initialAnchor: (0, react.useCallback)(() => resolveInitialAnchor(calState.selected, today, timeZone, T), [
1562
+ calState.selected,
1563
+ today,
1564
+ timeZone,
1565
+ T
1566
+ ]),
1567
+ onMonthChange,
1568
+ policy: windowPolicy,
1569
+ focusedDate,
1570
+ setFocusedDate,
1571
+ T
1572
+ });
1393
1573
  const [gridLabelIds, setGridLabelIds] = (0, react.useState)({});
1394
1574
  const setGridLabelId = (0, react.useCallback)((monthIndex, id) => {
1395
1575
  setGridLabelIds((prev) => {
@@ -1406,140 +1586,6 @@ function MonthViewRoot(props) {
1406
1586
  };
1407
1587
  });
1408
1588
  }, []);
1409
- const onMonthChangeRef = (0, react.useRef)(onMonthChange);
1410
- onMonthChangeRef.current = onMonthChange;
1411
- const notifyMonth = (0, react.useCallback)((year, month) => {
1412
- onMonthChangeRef.current?.(T.PlainYearMonth.from({
1413
- year,
1414
- month
1415
- }));
1416
- }, [T]);
1417
- const isMonthVisible = (0, react.useCallback)((targetYear, targetMonth) => {
1418
- for (let i = 0; i < numberOfMonths; i++) {
1419
- const totalMonths = currentMonth.year * 12 + (currentMonth.month - 1) + i;
1420
- const y = Math.floor(totalMonths / 12);
1421
- const m = totalMonths % 12 + 1;
1422
- if (targetYear === y && targetMonth === m) return true;
1423
- }
1424
- return false;
1425
- }, [
1426
- currentMonth.year,
1427
- currentMonth.month,
1428
- numberOfMonths
1429
- ]);
1430
- const navigateToMonth = (0, react.useCallback)((targetYear, targetMonth) => {
1431
- if (isMonthControlled) return;
1432
- setInternalMonth((prev) => {
1433
- const next = shiftWindowToMonth(prev, {
1434
- year: targetYear,
1435
- month: targetMonth
1436
- }, numberOfMonths);
1437
- if (next.year === prev.year && next.month === prev.month) return prev;
1438
- return next;
1439
- });
1440
- }, [isMonthControlled, numberOfMonths]);
1441
- const skipFocusSyncForRef = (0, react.useRef)(null);
1442
- const prevFocusedRef = (0, react.useRef)(focusedDate);
1443
- (0, react.useEffect)(() => {
1444
- skipFocusSyncForRef.current = null;
1445
- }, [monthProp?.year, monthProp?.month]);
1446
- (0, react.useEffect)(() => {
1447
- const prevFocused = prevFocusedRef.current;
1448
- prevFocusedRef.current = focusedDate;
1449
- if (isMonthControlled) {
1450
- if (skipFocusSyncForRef.current === focusedDate) {
1451
- skipFocusSyncForRef.current = null;
1452
- return;
1453
- }
1454
- if (prevFocused === focusedDate) return;
1455
- if (isMonthVisible(focusedDate.year, focusedDate.month)) return;
1456
- const next = shiftWindowToMonth({
1457
- year: currentMonth.year,
1458
- month: currentMonth.month
1459
- }, {
1460
- year: focusedDate.year,
1461
- month: focusedDate.month
1462
- }, numberOfMonths);
1463
- notifyMonth(next.year, next.month);
1464
- return;
1465
- }
1466
- navigateToMonth(focusedDate.year, focusedDate.month);
1467
- }, [
1468
- focusedDate,
1469
- navigateToMonth,
1470
- isMonthControlled,
1471
- isMonthVisible,
1472
- notifyMonth,
1473
- currentMonth.year,
1474
- currentMonth.month,
1475
- numberOfMonths
1476
- ]);
1477
- const goNextMonth = (0, react.useCallback)(() => {
1478
- if (isMonthControlled) {
1479
- const { year, month, firstDay } = computeAdjacentMonth({
1480
- year: monthProp.year,
1481
- month: monthProp.month
1482
- }, "next", T);
1483
- const nextFocus = focusedDateForMonth(focusedDate, {
1484
- year,
1485
- month
1486
- }, firstDay);
1487
- skipFocusSyncForRef.current = nextFocus;
1488
- notifyMonth(year, month);
1489
- setFocusedDate(nextFocus);
1490
- return;
1491
- }
1492
- setInternalMonth((m) => {
1493
- const { year, month, firstDay } = computeAdjacentMonth(m, "next", T);
1494
- setFocusedDate((prev) => focusedDateForMonth(prev, {
1495
- year,
1496
- month
1497
- }, firstDay));
1498
- return {
1499
- year,
1500
- month
1501
- };
1502
- });
1503
- }, [
1504
- T,
1505
- isMonthControlled,
1506
- monthProp,
1507
- notifyMonth,
1508
- focusedDate
1509
- ]);
1510
- const goPrevMonth = (0, react.useCallback)(() => {
1511
- if (isMonthControlled) {
1512
- const { year, month, firstDay } = computeAdjacentMonth({
1513
- year: monthProp.year,
1514
- month: monthProp.month
1515
- }, "prev", T);
1516
- const nextFocus = focusedDateForMonth(focusedDate, {
1517
- year,
1518
- month
1519
- }, firstDay);
1520
- skipFocusSyncForRef.current = nextFocus;
1521
- notifyMonth(year, month);
1522
- setFocusedDate(nextFocus);
1523
- return;
1524
- }
1525
- setInternalMonth((m) => {
1526
- const { year, month, firstDay } = computeAdjacentMonth(m, "prev", T);
1527
- setFocusedDate((prev) => focusedDateForMonth(prev, {
1528
- year,
1529
- month
1530
- }, firstDay));
1531
- return {
1532
- year,
1533
- month
1534
- };
1535
- });
1536
- }, [
1537
- T,
1538
- isMonthControlled,
1539
- monthProp,
1540
- notifyMonth,
1541
- focusedDate
1542
- ]);
1543
1589
  const allMonths = (0, react.useMemo)(() => {
1544
1590
  const opts = {
1545
1591
  weekStartDay,
@@ -1599,19 +1645,6 @@ function MonthViewRoot(props) {
1599
1645
  T,
1600
1646
  gridHasFocus
1601
1647
  ]);
1602
- const viewingYearMonth = (0, react.useMemo)(() => T.PlainYearMonth.from({
1603
- year: currentMonth.year,
1604
- month: currentMonth.month
1605
- }), [currentMonth, T]);
1606
- const mountedRef = (0, react.useRef)(false);
1607
- (0, react.useEffect)(() => {
1608
- if (!mountedRef.current) {
1609
- mountedRef.current = true;
1610
- return;
1611
- }
1612
- if (isMonthControlled) return;
1613
- onMonthChangeRef.current?.(viewingYearMonth);
1614
- }, [viewingYearMonth, isMonthControlled]);
1615
1648
  const rootState = (0, react.useMemo)(() => ({
1616
1649
  ...calState.baseRootState,
1617
1650
  focused: focusedDate,
@@ -1626,6 +1659,7 @@ function MonthViewRoot(props) {
1626
1659
  fixedWeeks,
1627
1660
  outsideDays,
1628
1661
  outOfRangeBehavior,
1662
+ windowPolicy,
1629
1663
  goNextMonth,
1630
1664
  goPrevMonth,
1631
1665
  setGridLabelId,
@@ -1635,6 +1669,7 @@ function MonthViewRoot(props) {
1635
1669
  fixedWeeks,
1636
1670
  outsideDays,
1637
1671
  outOfRangeBehavior,
1672
+ windowPolicy,
1638
1673
  goNextMonth,
1639
1674
  goPrevMonth,
1640
1675
  setGridLabelId
@@ -3194,37 +3229,16 @@ function MonthYearStringFn(props, ref) {
3194
3229
  */
3195
3230
  const MonthYearString = (0, react.forwardRef)(MonthYearStringFn);
3196
3231
  function useNavButton(direction) {
3197
- const { disabled: globalDisabled, minValue, maxValue, temporal: T } = useCalendarStable();
3198
- const monthViewStable = useMonthViewStable();
3199
- const monthViewState = useMonthViewState();
3200
- const { goNextMonth: goToNextMonth, goPrevMonth: goToPrevMonth, numberOfMonths, outOfRangeBehavior } = monthViewStable;
3201
- const { currentMonth: currentDateTime, allMonths, rootState } = monthViewState;
3202
- const refMonth = direction === "next" ? allMonths[numberOfMonths - 1] ?? currentDateTime : currentDateTime;
3203
- const destMonth = direction === "prev" ? refMonth.month === 1 ? 12 : refMonth.month - 1 : refMonth.month === 12 ? 1 : refMonth.month + 1;
3204
- const destYear = direction === "prev" ? refMonth.month === 1 ? refMonth.year - 1 : refMonth.year : refMonth.month === 12 ? refMonth.year + 1 : refMonth.year;
3205
- const boundValue = direction === "prev" ? minValue : maxValue;
3206
- const isDisabled = (0, react.useMemo)(() => {
3207
- if (globalDisabled) return true;
3208
- if (outOfRangeBehavior === "unbounded") return false;
3209
- if (!boundValue) return false;
3210
- if (direction === "prev") return destYear < boundValue.year || destYear === boundValue.year && destMonth < boundValue.month;
3211
- return destYear > boundValue.year || destYear === boundValue.year && destMonth > boundValue.month;
3212
- }, [
3213
- globalDisabled,
3214
- outOfRangeBehavior,
3215
- destYear,
3216
- destMonth,
3217
- boundValue,
3232
+ const { disabled: globalDisabled, temporal: T } = useCalendarStable();
3233
+ const { goNextMonth: goToNextMonth, goPrevMonth: goToPrevMonth, windowPolicy } = useMonthViewStable();
3234
+ const { currentMonth, rootState } = useMonthViewState();
3235
+ const step = (0, react.useMemo)(() => windowPolicy.step(currentMonth, direction), [
3236
+ windowPolicy,
3237
+ currentMonth,
3218
3238
  direction
3219
3239
  ]);
3220
- const target = (0, react.useMemo)(() => T.PlainYearMonth.from({
3221
- year: destYear,
3222
- month: destMonth
3223
- }), [
3224
- destYear,
3225
- destMonth,
3226
- T
3227
- ]);
3240
+ const isDisabled = globalDisabled || step.blocked;
3241
+ const target = (0, react.useMemo)(() => T.PlainYearMonth.from(step.entering), [step.entering, T]);
3228
3242
  return {
3229
3243
  state: (0, react.useMemo)(() => ({
3230
3244
  root: rootState,
@@ -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 {
@@ -1596,6 +1596,33 @@ type OutOfRangeBehavior = "unbounded" | "stop" | "stop-shrink" | "snap" | "snap-
1596
1596
  */
1597
1597
  type MonthOutOfRangeBehavior = "unbounded" | "stop";
1598
1598
  //#endregion
1599
+ //#region src/month-window.d.ts
1600
+ /** An ISO year + month. */
1601
+ interface MonthRef {
1602
+ year: number;
1603
+ month: number;
1604
+ }
1605
+ /** One step of the visible month window. */
1606
+ interface MonthStep {
1607
+ /** The window's first month after the step. */
1608
+ start: MonthRef;
1609
+ /** The month that enters view (before the window for `prev`, after it for `next`). */
1610
+ entering: MonthRef;
1611
+ /** First day of `start`, the focus target when focus isn't already in `start`. */
1612
+ firstDay: Temporal.PlainDate;
1613
+ /** Whether `stop` forbids the step because `entering` lies beyond `min`/`max`. */
1614
+ blocked: boolean;
1615
+ }
1616
+ /** The one seam for moving the MonthView window. */
1617
+ interface MonthWindowPolicy {
1618
+ /** Steps the window one month towards `direction`. */
1619
+ step(start: MonthRef, direction: "prev" | "next"): MonthStep;
1620
+ /** Whether `target` is inside the window starting at `start`. */
1621
+ isVisible(start: MonthRef, target: MonthRef): boolean;
1622
+ /** The window start that reveals `target` with the smallest shift. */
1623
+ reveal(start: MonthRef, target: MonthRef): MonthRef;
1624
+ }
1625
+ //#endregion
1599
1626
  //#region src/month-view-types.d.ts
1600
1627
  /** Props accepted by `MonthView.Root`. */
1601
1628
  interface MonthViewRootProps {
@@ -1657,6 +1684,8 @@ interface MonthViewStableContextValue {
1657
1684
  outsideDays: OutsideDays;
1658
1685
  /** How month navigation behaves at bounds. */
1659
1686
  outOfRangeBehavior: MonthOutOfRangeBehavior;
1687
+ /** Steps and reveals the visible month window. */
1688
+ windowPolicy: MonthWindowPolicy;
1660
1689
  /** Navigate to the next month(s). */
1661
1690
  goNextMonth: () => void;
1662
1691
  /** Navigate to the previous month(s). */
@@ -1,7 +1,7 @@
1
- import * as _$react from "react";
2
- import React$1 from "react";
3
1
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
2
  import { useRender } from "@base-ui/react/use-render";
3
+ import * as _$react from "react";
4
+ import React$1 from "react";
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 {
@@ -1596,6 +1596,33 @@ type OutOfRangeBehavior = "unbounded" | "stop" | "stop-shrink" | "snap" | "snap-
1596
1596
  */
1597
1597
  type MonthOutOfRangeBehavior = "unbounded" | "stop";
1598
1598
  //#endregion
1599
+ //#region src/month-window.d.ts
1600
+ /** An ISO year + month. */
1601
+ interface MonthRef {
1602
+ year: number;
1603
+ month: number;
1604
+ }
1605
+ /** One step of the visible month window. */
1606
+ interface MonthStep {
1607
+ /** The window's first month after the step. */
1608
+ start: MonthRef;
1609
+ /** The month that enters view (before the window for `prev`, after it for `next`). */
1610
+ entering: MonthRef;
1611
+ /** First day of `start`, the focus target when focus isn't already in `start`. */
1612
+ firstDay: Temporal.PlainDate;
1613
+ /** Whether `stop` forbids the step because `entering` lies beyond `min`/`max`. */
1614
+ blocked: boolean;
1615
+ }
1616
+ /** The one seam for moving the MonthView window. */
1617
+ interface MonthWindowPolicy {
1618
+ /** Steps the window one month towards `direction`. */
1619
+ step(start: MonthRef, direction: "prev" | "next"): MonthStep;
1620
+ /** Whether `target` is inside the window starting at `start`. */
1621
+ isVisible(start: MonthRef, target: MonthRef): boolean;
1622
+ /** The window start that reveals `target` with the smallest shift. */
1623
+ reveal(start: MonthRef, target: MonthRef): MonthRef;
1624
+ }
1625
+ //#endregion
1599
1626
  //#region src/month-view-types.d.ts
1600
1627
  /** Props accepted by `MonthView.Root`. */
1601
1628
  interface MonthViewRootProps {
@@ -1657,6 +1684,8 @@ interface MonthViewStableContextValue {
1657
1684
  outsideDays: OutsideDays;
1658
1685
  /** How month navigation behaves at bounds. */
1659
1686
  outOfRangeBehavior: MonthOutOfRangeBehavior;
1687
+ /** Steps and reveals the visible month window. */
1688
+ windowPolicy: MonthWindowPolicy;
1660
1689
  /** Navigate to the next month(s). */
1661
1690
  goNextMonth: () => void;
1662
1691
  /** Navigate to the previous month(s). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klinking/colander",
3
- "version": "3.1.0-alpha.4",
3
+ "version": "3.1.0-alpha.5",
4
4
  "homepage": "https://github.com/klink-ing/colander#readme",
5
5
  "bugs": "https://github.com/klink-ing/colander/issues",
6
6
  "license": "MIT",