@klinking/colander 3.1.0-alpha.8 → 3.1.0-alpha.9

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 (50) 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-BqzrxYgn.d.cts → index-B5VJ_WF2.d.mts} +2 -8
  30. package/dist/{index-CkhYFmf4.d.mts → index-BMsxaq1s.d.cts} +2 -8
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.cts +1 -1
  33. package/dist/index.d.mts +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/{weeks-navigation-CatYJIKb.cjs → weeks-navigation-CUQApLMk.cjs} +438 -290
  36. package/dist/{weeks-navigation-BWB5OvqW.mjs → weeks-navigation-CWNpF_6M.mjs} +440 -292
  37. package/package.json +5 -1
  38. package/src/calendar-provider.tsx +8 -2
  39. package/src/day-cell-state.ts +0 -70
  40. package/src/day-cell-store.test.tsx +273 -0
  41. package/src/day-cell-store.tsx +204 -0
  42. package/src/day-cell.test.tsx +72 -89
  43. package/src/day-cell.tsx +93 -78
  44. package/src/grid.tsx +17 -15
  45. package/src/month-view.tsx +3 -2
  46. package/src/store.ts +72 -0
  47. package/src/view-context.ts +2 -0
  48. package/src/weeks-grid.tsx +20 -10
  49. package/src/weeks-view-state.ts +1 -1
  50. package/src/weeks-view.tsx +2 -1
@@ -21,6 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
  let react = require("react");
23
23
  react = __toESM(react, 1);
24
+ let use_sync_external_store_shim_with_selector = require("use-sync-external-store/shim/with-selector");
24
25
  let react_jsx_runtime = require("react/jsx-runtime");
25
26
  let _base_ui_react_merge_props = require("@base-ui/react/merge-props");
26
27
  let _base_ui_react_use_render = require("@base-ui/react/use-render");
@@ -852,6 +853,45 @@ function computePreviewRange(hoveredDate, currentRange, rangeMode, preventRangeR
852
853
  });
853
854
  return preview ? mkRange(preview[0], preview[1]) : null;
854
855
  }
856
+ // src/store.ts
857
+ function createStore(initial) {
858
+ let state = initial;
859
+ const listeners = /* @__PURE__ */ new Set();
860
+ return {
861
+ get: () => state,
862
+ set: (next) => {
863
+ if (Object.is(state, next)) return;
864
+ state = next;
865
+ for (const listener of listeners) listener();
866
+ },
867
+ subscribe: (listener) => {
868
+ listeners.add(listener);
869
+ return () => listeners.delete(listener);
870
+ }
871
+ };
872
+ }
873
+ /** `useLayoutEffect` in the browser, `useEffect` on the server (no warning). */
874
+ const useIsoLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
875
+ /**
876
+ * Subscribes to the slice of `store` that `select` picks. The component
877
+ * re-renders only when `isEqual` says the slice changed; otherwise the
878
+ * previously returned slice is handed back, keeping its identity.
879
+ */
880
+ function useStoreSelector(store, select, isEqual) {
881
+ return (0, use_sync_external_store_shim_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.get, store.get, select, isEqual);
882
+ }
883
+ /**
884
+ * Returns a function with a stable identity that always calls the latest
885
+ * `fn`, so contexts holding it don't change when its closure does. Call it
886
+ * from event handlers and effects, not during render.
887
+ */
888
+ function useStableCallback(fn) {
889
+ const latest = (0, react.useRef)(fn);
890
+ (0, react.useInsertionEffect)(() => {
891
+ latest.current = fn;
892
+ });
893
+ return (0, react.useCallback)((...args) => latest.current(...args), []);
894
+ }
855
895
  // src/calendar-provider.tsx
856
896
  /**
857
897
  * Provides shared calendar state (selection, config, range preview) to all
@@ -1145,7 +1185,7 @@ function CalendarProvider(props) {
1145
1185
  isMultiple,
1146
1186
  isControlled
1147
1187
  ]);
1148
- const onSelect = (0, react.useCallback)((date) => {
1188
+ const onSelectLatest = (0, react.useCallback)((date) => {
1149
1189
  const result = computeSelectionUpdate({
1150
1190
  date,
1151
1191
  readOnly,
@@ -1189,7 +1229,7 @@ function CalendarProvider(props) {
1189
1229
  currentRangeFormatted,
1190
1230
  currentMultipleFormatted
1191
1231
  ]);
1192
- const setRange = (0, react.useCallback)((start, end) => {
1232
+ const setRangeLatest = (0, react.useCallback)((start, end) => {
1193
1233
  const result = computeSetRangeUpdate({
1194
1234
  start,
1195
1235
  end,
@@ -1215,6 +1255,8 @@ function CalendarProvider(props) {
1215
1255
  resolvedFormat,
1216
1256
  T
1217
1257
  ]);
1258
+ const onSelect = useStableCallback(onSelectLatest);
1259
+ const setRange = useStableCallback(setRangeLatest);
1218
1260
  const nonNullDates = (0, react.useMemo)(() => committedDates.filter((d) => d != null), [committedDates]);
1219
1261
  const stableCtx = (0, react.useMemo)(() => ({
1220
1262
  onSelect,
@@ -1297,6 +1339,292 @@ function CalendarProvider(props) {
1297
1339
  })
1298
1340
  });
1299
1341
  }
1342
+ // src/context.ts
1343
+ /** @internal Provides the days and index of the current week row to child components. */
1344
+ const WeekDataContext = (0, react.createContext)(null);
1345
+ /** @internal Provides the resolved grid orientation to descendant cells. */
1346
+ const GridContext = (0, react.createContext)({ orientation: "horizontal" });
1347
+ /** @internal Provides the date and column index from a `DayCellTemplate` to its child `DayButton`. */
1348
+ const DayCellDataContext = (0, react.createContext)(null);
1349
+ /** @internal Provides per-grid month data to WeekTemplate and DayCellTemplate. */
1350
+ const GridMonthContext = (0, react.createContext)(null);
1351
+ // src/day-cell-state.ts
1352
+ const NO_RANGE = {
1353
+ rangeStart: false,
1354
+ rangeEnd: false,
1355
+ rangeBoundary: false,
1356
+ inRange: false,
1357
+ rangeIndex: false,
1358
+ rangeLength: false,
1359
+ rangeHasStart: false,
1360
+ rangeHasEnd: false,
1361
+ rangePreviewStart: false,
1362
+ rangePreviewEnd: false,
1363
+ rangePreviewBoundary: false,
1364
+ rangePreviewInRange: false,
1365
+ rangePreviewIndex: false,
1366
+ rangePreviewLength: false,
1367
+ rangePreviewHasStart: false,
1368
+ rangePreviewHasEnd: false
1369
+ };
1370
+ function computeRangeState(date, inputs) {
1371
+ const { T, selectionMode, rangeStart, rangeEnd, previewStart, previewEnd } = inputs;
1372
+ if (selectionMode !== "range") return NO_RANGE;
1373
+ const isRangeStart = rangeStart ? T.PlainDate.compare(date, rangeStart) === 0 : false;
1374
+ const isRangeEnd = rangeEnd ? T.PlainDate.compare(date, rangeEnd) === 0 : false;
1375
+ const inRange = isInRange(date, rangeStart, rangeEnd, T) !== false;
1376
+ const effectiveStart = rangeStart ?? rangeEnd;
1377
+ const effectiveEnd = rangeEnd ?? rangeStart;
1378
+ const isPreviewStart = previewStart ? T.PlainDate.compare(date, previewStart) === 0 : false;
1379
+ const isPreviewEnd = previewEnd ? T.PlainDate.compare(date, previewEnd) === 0 : false;
1380
+ const inPreview = previewStart && previewEnd ? isInRange(date, previewStart, previewEnd, T) !== false : false;
1381
+ return {
1382
+ rangeStart: isRangeStart,
1383
+ rangeEnd: isRangeEnd,
1384
+ rangeBoundary: isRangeStart || isRangeEnd,
1385
+ inRange,
1386
+ rangeIndex: inRange && effectiveStart ? date.since(effectiveStart).days : false,
1387
+ rangeLength: inRange && effectiveStart && effectiveEnd ? effectiveEnd.since(effectiveStart).days + 1 : false,
1388
+ rangeHasStart: inRange && rangeStart !== void 0,
1389
+ rangeHasEnd: inRange && rangeEnd !== void 0,
1390
+ rangePreviewStart: isPreviewStart,
1391
+ rangePreviewEnd: isPreviewEnd,
1392
+ rangePreviewBoundary: isPreviewStart || isPreviewEnd,
1393
+ rangePreviewInRange: inPreview,
1394
+ rangePreviewIndex: inPreview && previewStart ? date.since(previewStart).days : false,
1395
+ rangePreviewLength: inPreview && previewStart && previewEnd ? previewEnd.since(previewStart).days + 1 : false,
1396
+ rangePreviewHasStart: inPreview && previewStart !== void 0,
1397
+ rangePreviewHasEnd: inPreview && previewEnd !== void 0
1398
+ };
1399
+ }
1400
+ /** Derives the state of one day cell. Pure function, no hooks. */
1401
+ function computeDayCellState(date, position, inputs) {
1402
+ const { T, outsideDays } = inputs;
1403
+ const { columnIndex, month } = position;
1404
+ const isCurrentMonth = date.year === month.year && date.month === month.month;
1405
+ const base = {
1406
+ root: inputs.rootState,
1407
+ date,
1408
+ columnIndex,
1409
+ orientation: inputs.orientation
1410
+ };
1411
+ if (!isCurrentMonth && outsideDays === "hidden") return {
1412
+ ...base,
1413
+ ...NO_RANGE,
1414
+ outsideMonth: true,
1415
+ hidden: true,
1416
+ selected: false,
1417
+ today: false,
1418
+ disabled: true,
1419
+ focused: false,
1420
+ isTabTarget: false
1421
+ };
1422
+ const isToday = T.PlainDate.compare(date, inputs.today) === 0;
1423
+ if (!isCurrentMonth && outsideDays !== "enabled") {
1424
+ const suppressRange = outsideDays === "disabled";
1425
+ return {
1426
+ ...base,
1427
+ ...suppressRange ? NO_RANGE : computeRangeState(date, inputs),
1428
+ outsideMonth: true,
1429
+ hidden: false,
1430
+ selected: false,
1431
+ today: isToday,
1432
+ disabled: true,
1433
+ focused: false,
1434
+ isTabTarget: false
1435
+ };
1436
+ }
1437
+ return {
1438
+ ...base,
1439
+ ...computeRangeState(date, inputs),
1440
+ outsideMonth: !isCurrentMonth,
1441
+ hidden: false,
1442
+ selected: inputs.selectionMode !== "range" ? inputs.selectedDates.some((d) => T.PlainDate.compare(d, date) === 0) : false,
1443
+ today: isToday,
1444
+ disabled: inputs.disabled || (inputs.isDateDisabled?.(date) ?? false),
1445
+ focused: T.PlainDate.compare(date, inputs.focusedDate) === 0,
1446
+ isTabTarget: T.PlainDate.compare(date, inputs.tabTargetDate) === 0
1447
+ };
1448
+ }
1449
+ const COMPARED_KEYS = Object.keys({
1450
+ outsideMonth: true,
1451
+ hidden: true,
1452
+ selected: true,
1453
+ today: true,
1454
+ disabled: true,
1455
+ focused: true,
1456
+ rangeStart: true,
1457
+ rangeEnd: true,
1458
+ rangeBoundary: true,
1459
+ inRange: true,
1460
+ rangeIndex: true,
1461
+ rangeLength: true,
1462
+ rangeHasStart: true,
1463
+ rangeHasEnd: true,
1464
+ rangePreviewStart: true,
1465
+ rangePreviewEnd: true,
1466
+ rangePreviewBoundary: true,
1467
+ rangePreviewInRange: true,
1468
+ rangePreviewIndex: true,
1469
+ rangePreviewLength: true,
1470
+ rangePreviewHasStart: true,
1471
+ rangePreviewHasEnd: true,
1472
+ isTabTarget: true
1473
+ });
1474
+ /** Whether two cell states render the same cell. */
1475
+ function dayCellStateEqual(a, b) {
1476
+ for (const key of COMPARED_KEYS) if (a[key] !== b[key]) return false;
1477
+ return true;
1478
+ }
1479
+ // src/view-context.ts
1480
+ /** @internal React context for the active view (MonthView or WeeksView). */
1481
+ const ViewContext = (0, react.createContext)(null);
1482
+ /** Returns the nearest view context (MonthView or WeeksView). */
1483
+ function useViewContext() {
1484
+ const ctx = (0, react.useContext)(ViewContext);
1485
+ if (!ctx) throw new Error("useViewContext must be used within MonthView or WeeksView");
1486
+ return ctx;
1487
+ }
1488
+ /** @internal Context for {@link ViewStableContextValue}. */
1489
+ const ViewStableContext = (0, react.createContext)(null);
1490
+ /** @internal Context for {@link ViewStateContextValue}. */
1491
+ const ViewStateContext = (0, react.createContext)(null);
1492
+ /** Returns the nearest view's stable values. */
1493
+ function useViewStable() {
1494
+ const ctx = (0, react.useContext)(ViewStableContext);
1495
+ if (!ctx) throw new Error("useViewStable must be used within MonthView or WeeksView");
1496
+ return ctx;
1497
+ }
1498
+ /** Returns the nearest view's volatile state. */
1499
+ function useViewState() {
1500
+ const ctx = (0, react.useContext)(ViewStateContext);
1501
+ if (!ctx) throw new Error("useViewState must be used within MonthView or WeeksView");
1502
+ return ctx;
1503
+ }
1504
+ // src/day-cell-store.tsx
1505
+ /** @internal The view's day-cell store. Its identity never changes. */
1506
+ const DayCellStoreContext = (0, react.createContext)(null);
1507
+ /**
1508
+ * Publishes the calendar and view state that day cells derive from. Cells
1509
+ * subscribe per date, so a change re-renders only the cells it affects instead
1510
+ * of every cell under a context.
1511
+ *
1512
+ * The store is seeded on the first render and updated only after a change
1513
+ * commits, never during render: a render React discards (a suspended
1514
+ * transition) must not leak into cells that re-render meanwhile. Cells that
1515
+ * render in the same pass as a change read the previous state first, then
1516
+ * re-render from the layout effect before the browser paints.
1517
+ */
1518
+ function DayCellStoreProvider(props) {
1519
+ const { disabled, isDateDisabled, selectionMode, temporal: T, today, weekStartDay } = useCalendarStable();
1520
+ const { selectedDates, rangeStart, rangeEnd, previewStart, previewEnd } = useCalendarState();
1521
+ const { viewType, focusedDate, tabTargetDate } = useViewContext();
1522
+ const { rootState, currentDateTime } = useViewState();
1523
+ const { outsideDays } = useViewStable();
1524
+ const todayKey = today().toString();
1525
+ const { year, month } = currentDateTime;
1526
+ const snapshot = (0, react.useMemo)(() => ({
1527
+ inputs: {
1528
+ T,
1529
+ today: T.PlainDate.from(todayKey),
1530
+ rootState,
1531
+ selectionMode,
1532
+ selectedDates,
1533
+ rangeStart,
1534
+ rangeEnd,
1535
+ previewStart,
1536
+ previewEnd,
1537
+ disabled,
1538
+ isDateDisabled,
1539
+ focusedDate,
1540
+ tabTargetDate,
1541
+ outsideDays
1542
+ },
1543
+ viewType,
1544
+ viewMonth: {
1545
+ year,
1546
+ month
1547
+ },
1548
+ weekStartDay
1549
+ }), [
1550
+ T,
1551
+ todayKey,
1552
+ rootState,
1553
+ selectionMode,
1554
+ selectedDates,
1555
+ rangeStart,
1556
+ rangeEnd,
1557
+ previewStart,
1558
+ previewEnd,
1559
+ disabled,
1560
+ isDateDisabled,
1561
+ focusedDate,
1562
+ tabTargetDate,
1563
+ outsideDays,
1564
+ viewType,
1565
+ year,
1566
+ month,
1567
+ weekStartDay
1568
+ ]);
1569
+ const [store] = (0, react.useState)(() => createStore(snapshot));
1570
+ useIsoLayoutEffect(() => store.set(snapshot), [store, snapshot]);
1571
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellStoreContext.Provider, {
1572
+ value: store,
1573
+ children: props.children
1574
+ });
1575
+ }
1576
+ /**
1577
+ * Hands `state` to render functions with `root` as a non-enumerable getter
1578
+ * that calls `onReadRoot`. Base UI's data-attribute pass only walks
1579
+ * enumerable keys, so `root` counts as read only when user code reads it.
1580
+ */
1581
+ function withLazyRoot(state, onReadRoot) {
1582
+ const { root, ...rest } = state;
1583
+ return Object.defineProperty(rest, "root", {
1584
+ get() {
1585
+ onReadRoot();
1586
+ return root;
1587
+ },
1588
+ enumerable: false
1589
+ });
1590
+ }
1591
+ /**
1592
+ * Subscribes to one day cell's state. The cell re-renders only when a field
1593
+ * it renders changes; `root` joins that comparison once a render function has
1594
+ * read `state.root`, so cells that never read it ignore focus and selection
1595
+ * changes elsewhere in the grid.
1596
+ */
1597
+ function useDayCellState(date, columnIndex, gridMonth) {
1598
+ const store = (0, react.useContext)(DayCellStoreContext);
1599
+ if (!store) throw new Error("Day cells must be used inside MonthView or WeeksView.");
1600
+ const { orientation } = (0, react.useContext)(GridContext);
1601
+ const readsRoot = (0, react.useRef)(false);
1602
+ const state = useStoreSelector(store, (0, react.useCallback)((s) => {
1603
+ const daysInWeek = date.daysInWeek;
1604
+ return computeDayCellState(date, {
1605
+ columnIndex: columnIndex ?? (date.dayOfWeek % daysInWeek - s.weekStartDay + daysInWeek) % daysInWeek,
1606
+ month: s.viewType === "weeks" ? {
1607
+ year: date.year,
1608
+ month: date.month
1609
+ } : gridMonth ?? s.viewMonth
1610
+ }, {
1611
+ ...s.inputs,
1612
+ orientation
1613
+ });
1614
+ }, [
1615
+ date,
1616
+ columnIndex,
1617
+ gridMonth,
1618
+ orientation
1619
+ ]), (0, react.useCallback)((a, b) => a.date === b.date && a.columnIndex === b.columnIndex && a.orientation === b.orientation && dayCellStateEqual(a, b) && (!readsRoot.current || a.root === b.root), []));
1620
+ return (0, react.useMemo)(() => withLazyRoot(state, () => {
1621
+ readsRoot.current = true;
1622
+ }), [state]);
1623
+ }
1624
+ /** Like {@link useDayCellState}, taking the grid month from the enclosing week. */
1625
+ function useStandaloneDayCellState(date) {
1626
+ return useDayCellState(date, void 0, (0, react.useContext)(WeekDataContext)?.gridMonth);
1627
+ }
1300
1628
  // src/month-view-context.ts
1301
1629
  /** @internal React context for MonthView stable values (config + callbacks). */
1302
1630
  const MonthViewStableContext = (0, react.createContext)(null);
@@ -1483,31 +1811,6 @@ function monthAt(start, offset) {
1483
1811
  month: index % 12 + 1
1484
1812
  };
1485
1813
  }
1486
- // src/view-context.ts
1487
- /** @internal React context for the active view (MonthView or WeeksView). */
1488
- const ViewContext = (0, react.createContext)(null);
1489
- /** Returns the nearest view context (MonthView or WeeksView). */
1490
- function useViewContext() {
1491
- const ctx = (0, react.useContext)(ViewContext);
1492
- if (!ctx) throw new Error("useViewContext must be used within MonthView or WeeksView");
1493
- return ctx;
1494
- }
1495
- /** @internal Context for {@link ViewStableContextValue}. */
1496
- const ViewStableContext = (0, react.createContext)(null);
1497
- /** @internal Context for {@link ViewStateContextValue}. */
1498
- const ViewStateContext = (0, react.createContext)(null);
1499
- /** Returns the nearest view's stable values. */
1500
- function useViewStable() {
1501
- const ctx = (0, react.useContext)(ViewStableContext);
1502
- if (!ctx) throw new Error("useViewStable must be used within MonthView or WeeksView");
1503
- return ctx;
1504
- }
1505
- /** Returns the nearest view's volatile state. */
1506
- function useViewState() {
1507
- const ctx = (0, react.useContext)(ViewStateContext);
1508
- if (!ctx) throw new Error("useViewState must be used within MonthView or WeeksView");
1509
- return ctx;
1510
- }
1511
1814
  // src/month-view.tsx
1512
1815
  function MonthViewRoot(props) {
1513
1816
  const { numberOfMonths: numberOfMonthsProp, fixedWeeks: fixedWeeksProp, outsideDays: outsideDaysProp, outOfRangeBehavior: outOfRangeBehaviorProp, month: monthProp, defaultMonth: defaultMonthProp, onMonthChange, children } = props;
@@ -1693,7 +1996,8 @@ function MonthViewRoot(props) {
1693
1996
  ]);
1694
1997
  const viewStableCtx = (0, react.useMemo)(() => ({
1695
1998
  gridFocusedRef,
1696
- outsideDays
1999
+ outsideDays,
2000
+ setFocusedDate
1697
2001
  }), [outsideDays]);
1698
2002
  const viewStateCtx = (0, react.useMemo)(() => ({
1699
2003
  currentDateTime,
@@ -1709,7 +2013,7 @@ function MonthViewRoot(props) {
1709
2013
  value: viewStateCtx,
1710
2014
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewContext.Provider, {
1711
2015
  value: viewCtx,
1712
- children
2016
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellStoreProvider, { children })
1713
2017
  })
1714
2018
  })
1715
2019
  })
@@ -1733,15 +2037,6 @@ function MonthView(props) {
1733
2037
  });
1734
2038
  }
1735
2039
  MonthView.Root = MonthViewRoot;
1736
- // src/context.ts
1737
- /** @internal Provides the days and index of the current week row to child components. */
1738
- const WeekDataContext = (0, react.createContext)(null);
1739
- /** @internal Provides the resolved grid orientation to descendant cells. */
1740
- const GridContext = (0, react.createContext)({ orientation: "horizontal" });
1741
- /** @internal Provides the date and column index from a `DayCellTemplate` to its child `DayButton`. */
1742
- const DayCellDataContext = (0, react.createContext)(null);
1743
- /** @internal Provides per-grid month data to WeekTemplate and DayCellTemplate. */
1744
- const GridMonthContext = (0, react.createContext)(null);
1745
2040
  // src/grid-header.tsx
1746
2041
  function useGridHeaderCellState(index) {
1747
2042
  const { locale, temporal: T, weekStartDay } = useCalendarStable();
@@ -2188,28 +2483,35 @@ function WeeksGrid(props) {
2188
2483
  }
2189
2484
  return map;
2190
2485
  }, [monthBoundaries]);
2486
+ const rowValues = (0, react.useMemo)(() => weeks.map((week, i) => {
2487
+ const days = weekDaysArrays[i] ?? [];
2488
+ return {
2489
+ weekData: {
2490
+ days,
2491
+ weekIndex: week.weekIndex,
2492
+ gridRowIndex: i + 2
2493
+ },
2494
+ gridMonth: {
2495
+ weeks: [days],
2496
+ year: week.year,
2497
+ month: week.month
2498
+ }
2499
+ };
2500
+ }), [weeks, weekDaysArrays]);
2191
2501
  const rows = [];
2192
2502
  for (const [i, week] of weeks.entries()) {
2193
- const days = weekDaysArrays[i];
2194
- if (days === void 0) continue;
2503
+ if (weekDaysArrays[i] === void 0) continue;
2195
2504
  const separators = boundariesAtIndex.get(i);
2196
2505
  if (separators && separatorTemplate.length > 0) for (const separatorData of separators) rows.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthSeparatorDataContext.Provider, {
2197
2506
  value: separatorData,
2198
2507
  children: separatorTemplate
2199
2508
  }, `sep-${separatorData.year}-${separatorData.month}`));
2200
- const weekGridRow = i + 2;
2509
+ const rowValue = rowValues[i];
2510
+ if (rowValue === void 0) continue;
2201
2511
  rows.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(WeekDataContext.Provider, {
2202
- value: {
2203
- days,
2204
- weekIndex: week.weekIndex,
2205
- gridRowIndex: weekGridRow
2206
- },
2512
+ value: rowValue.weekData,
2207
2513
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GridMonthContext.Provider, {
2208
- value: {
2209
- weeks: [days],
2210
- year: week.year,
2211
- month: week.month
2212
- },
2514
+ value: rowValue.gridMonth,
2213
2515
  children: weekRowChildren
2214
2516
  })
2215
2517
  }, week.startDate.toString()));
@@ -2294,178 +2596,6 @@ function computeWeeksKeyNav(input) {
2294
2596
  default: return NONE;
2295
2597
  }
2296
2598
  }
2297
- // src/day-cell-state.ts
2298
- const NO_RANGE = {
2299
- rangeStart: false,
2300
- rangeEnd: false,
2301
- rangeBoundary: false,
2302
- inRange: false,
2303
- rangeIndex: false,
2304
- rangeLength: false,
2305
- rangeHasStart: false,
2306
- rangeHasEnd: false,
2307
- rangePreviewStart: false,
2308
- rangePreviewEnd: false,
2309
- rangePreviewBoundary: false,
2310
- rangePreviewInRange: false,
2311
- rangePreviewIndex: false,
2312
- rangePreviewLength: false,
2313
- rangePreviewHasStart: false,
2314
- rangePreviewHasEnd: false
2315
- };
2316
- function computeRangeState(date, inputs) {
2317
- const { T, selectionMode, rangeStart, rangeEnd, previewStart, previewEnd } = inputs;
2318
- if (selectionMode !== "range") return NO_RANGE;
2319
- const isRangeStart = rangeStart ? T.PlainDate.compare(date, rangeStart) === 0 : false;
2320
- const isRangeEnd = rangeEnd ? T.PlainDate.compare(date, rangeEnd) === 0 : false;
2321
- const inRange = isInRange(date, rangeStart, rangeEnd, T) !== false;
2322
- const effectiveStart = rangeStart ?? rangeEnd;
2323
- const effectiveEnd = rangeEnd ?? rangeStart;
2324
- const isPreviewStart = previewStart ? T.PlainDate.compare(date, previewStart) === 0 : false;
2325
- const isPreviewEnd = previewEnd ? T.PlainDate.compare(date, previewEnd) === 0 : false;
2326
- const inPreview = previewStart && previewEnd ? isInRange(date, previewStart, previewEnd, T) !== false : false;
2327
- return {
2328
- rangeStart: isRangeStart,
2329
- rangeEnd: isRangeEnd,
2330
- rangeBoundary: isRangeStart || isRangeEnd,
2331
- inRange,
2332
- rangeIndex: inRange && effectiveStart ? date.since(effectiveStart).days : false,
2333
- rangeLength: inRange && effectiveStart && effectiveEnd ? effectiveEnd.since(effectiveStart).days + 1 : false,
2334
- rangeHasStart: inRange && rangeStart !== void 0,
2335
- rangeHasEnd: inRange && rangeEnd !== void 0,
2336
- rangePreviewStart: isPreviewStart,
2337
- rangePreviewEnd: isPreviewEnd,
2338
- rangePreviewBoundary: isPreviewStart || isPreviewEnd,
2339
- rangePreviewInRange: inPreview,
2340
- rangePreviewIndex: inPreview && previewStart ? date.since(previewStart).days : false,
2341
- rangePreviewLength: inPreview && previewStart && previewEnd ? previewEnd.since(previewStart).days + 1 : false,
2342
- rangePreviewHasStart: inPreview && previewStart !== void 0,
2343
- rangePreviewHasEnd: inPreview && previewEnd !== void 0
2344
- };
2345
- }
2346
- /** Derives the state of one day cell. Pure function, no hooks. */
2347
- function computeDayCellState(date, position, inputs) {
2348
- const { T, outsideDays } = inputs;
2349
- const { columnIndex, month } = position;
2350
- const isCurrentMonth = date.year === month.year && date.month === month.month;
2351
- const base = {
2352
- root: inputs.rootState,
2353
- date,
2354
- columnIndex,
2355
- orientation: inputs.orientation
2356
- };
2357
- if (!isCurrentMonth && outsideDays === "hidden") return {
2358
- ...base,
2359
- ...NO_RANGE,
2360
- outsideMonth: true,
2361
- hidden: true,
2362
- selected: false,
2363
- today: false,
2364
- disabled: true,
2365
- focused: false,
2366
- isTabTarget: false
2367
- };
2368
- const isToday = T.PlainDate.compare(date, inputs.today) === 0;
2369
- if (!isCurrentMonth && outsideDays !== "enabled") {
2370
- const suppressRange = outsideDays === "disabled";
2371
- return {
2372
- ...base,
2373
- ...suppressRange ? NO_RANGE : computeRangeState(date, inputs),
2374
- outsideMonth: true,
2375
- hidden: false,
2376
- selected: false,
2377
- today: isToday,
2378
- disabled: true,
2379
- focused: false,
2380
- isTabTarget: false
2381
- };
2382
- }
2383
- return {
2384
- ...base,
2385
- ...computeRangeState(date, inputs),
2386
- outsideMonth: !isCurrentMonth,
2387
- hidden: false,
2388
- selected: inputs.selectionMode !== "range" ? inputs.selectedDates.some((d) => T.PlainDate.compare(d, date) === 0) : false,
2389
- today: isToday,
2390
- disabled: inputs.disabled || (inputs.isDateDisabled?.(date) ?? false),
2391
- focused: T.PlainDate.compare(date, inputs.focusedDate) === 0,
2392
- isTabTarget: T.PlainDate.compare(date, inputs.tabTargetDate) === 0
2393
- };
2394
- }
2395
- const COMPARED_KEYS = Object.keys({
2396
- outsideMonth: true,
2397
- hidden: true,
2398
- selected: true,
2399
- today: true,
2400
- disabled: true,
2401
- focused: true,
2402
- rangeStart: true,
2403
- rangeEnd: true,
2404
- rangeBoundary: true,
2405
- inRange: true,
2406
- rangeIndex: true,
2407
- rangeLength: true,
2408
- rangeHasStart: true,
2409
- rangeHasEnd: true,
2410
- rangePreviewStart: true,
2411
- rangePreviewEnd: true,
2412
- rangePreviewBoundary: true,
2413
- rangePreviewInRange: true,
2414
- rangePreviewIndex: true,
2415
- rangePreviewLength: true,
2416
- rangePreviewHasStart: true,
2417
- rangePreviewHasEnd: true,
2418
- isTabTarget: true
2419
- });
2420
- /** Whether two cell states render the same cell. */
2421
- function dayCellStateEqual(a, b) {
2422
- for (const key of COMPARED_KEYS) if (a[key] !== b[key]) return false;
2423
- return true;
2424
- }
2425
- /**
2426
- * Reads the contexts a day cell depends on and returns a function that derives
2427
- * the state of any cell. `columnIndex` defaults to the date's column in a
2428
- * week starting on the calendar's `weekStartDay`.
2429
- */
2430
- function useDayCellDeriver() {
2431
- const { orientation } = (0, react.useContext)(GridContext);
2432
- const weekData = (0, react.useContext)(WeekDataContext);
2433
- const { disabled, isDateDisabled, selectionMode, temporal: T, today, weekStartDay } = useCalendarStable();
2434
- const { selectedDates, rangeStart, rangeEnd, previewStart, previewEnd } = useCalendarState();
2435
- const viewCtx = useViewContext();
2436
- const { focusedDate, tabTargetDate } = viewCtx;
2437
- const { rootState, currentDateTime } = useViewState();
2438
- const { outsideDays } = useViewStable();
2439
- const inputs = {
2440
- T,
2441
- today: today(),
2442
- orientation,
2443
- rootState,
2444
- selectionMode,
2445
- selectedDates,
2446
- rangeStart,
2447
- rangeEnd,
2448
- previewStart,
2449
- previewEnd,
2450
- disabled,
2451
- isDateDisabled,
2452
- focusedDate,
2453
- tabTargetDate,
2454
- outsideDays
2455
- };
2456
- const isWeeksView = viewCtx.viewType === "weeks";
2457
- const gridMonth = weekData?.gridMonth ?? currentDateTime;
2458
- return (date, columnIndex) => {
2459
- const daysInWeek = date.daysInWeek;
2460
- return computeDayCellState(date, {
2461
- columnIndex: columnIndex ?? (date.dayOfWeek % daysInWeek - weekStartDay + daysInWeek) % daysInWeek,
2462
- month: isWeeksView ? {
2463
- year: date.year,
2464
- month: date.month
2465
- } : gridMonth
2466
- }, inputs);
2467
- };
2468
- }
2469
2599
  // src/day-cell.tsx
2470
2600
  const dayStateAttributesMapping = {
2471
2601
  root: () => null,
@@ -2495,9 +2625,12 @@ const dayStateAttributesMapping = {
2495
2625
  rangePreviewHasStart: (v) => v ? { "data-range-preview-has-start": "" } : null,
2496
2626
  rangePreviewHasEnd: (v) => v ? { "data-range-preview-has-end": "" } : null
2497
2627
  };
2628
+ /** @internal The enclosing day cell's state, read by its `DayButton`. */
2629
+ const DayCellStateContext = (0, react.createContext)(null);
2498
2630
  function DayCellInstanceFn(props) {
2499
- const { render, date, columnIndex, children, _derivedState, ...otherProps } = props;
2500
- const state = _derivedState;
2631
+ const { render, date, columnIndex, gridMonth, children, ...otherProps } = props;
2632
+ const derived = useDayCellState(date, columnIndex, gridMonth);
2633
+ const state = derived;
2501
2634
  const defaultProps = state.hidden ? {
2502
2635
  role: "gridcell",
2503
2636
  "aria-hidden": true,
@@ -2506,7 +2639,7 @@ function DayCellInstanceFn(props) {
2506
2639
  role: "gridcell",
2507
2640
  "aria-selected": state.selected || void 0,
2508
2641
  "aria-disabled": state.disabled || void 0,
2509
- children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButton, { _derivedState })
2642
+ children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButton, {})
2510
2643
  };
2511
2644
  const cell = (0, _base_ui_react_use_render.useRender)({
2512
2645
  defaultTagName: "td",
@@ -2517,13 +2650,21 @@ function DayCellInstanceFn(props) {
2517
2650
  props: (0, _base_ui_react_merge_props.mergeProps)(defaultProps, otherProps)
2518
2651
  });
2519
2652
  const outsideDisabled = state.hidden || state.outsideMonth && state.disabled;
2653
+ const cellData = (0, react.useMemo)(() => ({
2654
+ date,
2655
+ columnIndex,
2656
+ outsideDisabled
2657
+ }), [
2658
+ date,
2659
+ columnIndex,
2660
+ outsideDisabled
2661
+ ]);
2520
2662
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellDataContext.Provider, {
2521
- value: {
2522
- date,
2523
- columnIndex,
2524
- outsideDisabled
2525
- },
2526
- children: cell
2663
+ value: cellData,
2664
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellStateContext.Provider, {
2665
+ value: derived,
2666
+ children: cell
2667
+ })
2527
2668
  });
2528
2669
  }
2529
2670
  /**
@@ -2543,20 +2684,31 @@ const DAY_CELL_HANDLED_KEYS = /* @__PURE__ */ new Set([
2543
2684
  "render",
2544
2685
  "date",
2545
2686
  "columnIndex",
2546
- "children",
2547
- "_derivedState"
2687
+ "gridMonth",
2688
+ "children"
2548
2689
  ]);
2549
2690
  const DAY_BUTTON_HANDLED_KEYS = /* @__PURE__ */ new Set([
2550
2691
  "render",
2551
2692
  "date",
2552
2693
  "children",
2553
- "_derivedState"
2694
+ "_state"
2554
2695
  ]);
2696
+ /**
2697
+ * Whether a day cell can skip a parent re-render. Its own state comes from
2698
+ * the store, so only props are compared here.
2699
+ */
2555
2700
  function dayCellInstancePropsAreEqual(prev, next) {
2556
- if (prev.date !== next.date || prev.render !== next.render || prev.columnIndex !== next.columnIndex) return false;
2557
- return dayCellStateEqual(prev._derivedState, next._derivedState) && passThroughPropsEqual(prev, next, DAY_CELL_HANDLED_KEYS);
2701
+ return prev.date === next.date && prev.render === next.render && prev.columnIndex === next.columnIndex && prev.gridMonth === next.gridMonth && passThroughPropsEqual(prev, next, DAY_CELL_HANDLED_KEYS);
2558
2702
  }
2559
2703
  const DayCellInstance = (0, react.memo)(DayCellInstanceFn, dayCellInstancePropsAreEqual);
2704
+ /** The cells of a whole month, for a `DayCellTemplate` outside any week row. */
2705
+ function MonthDayCells(props) {
2706
+ const days = (0, react.useContext)(MonthViewStateContext)?.weeks.flat() ?? [];
2707
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: days.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellInstance, {
2708
+ ...props,
2709
+ date: day
2710
+ }, day.toString())) });
2711
+ }
2560
2712
  /**
2561
2713
  * Renders one `<td role="gridcell">` per day. Exposes data-attributes for
2562
2714
  * `selected`, `today`, `disabled`, `outside-month`, `focused`,
@@ -2568,36 +2720,32 @@ const DayCellInstance = (0, react.memo)(DayCellInstanceFn, dayCellInstancePropsA
2568
2720
  function DayCellTemplate(props) {
2569
2721
  const { date: dateProp, ...restProps } = props;
2570
2722
  const weekData = (0, react.useContext)(WeekDataContext);
2571
- const monthState = (0, react.useContext)(MonthViewStateContext);
2572
- const derive = useDayCellDeriver();
2573
2723
  if (dateProp) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellInstance, {
2574
2724
  ...restProps,
2575
2725
  date: dateProp,
2576
- _derivedState: derive(dateProp)
2726
+ gridMonth: weekData?.gridMonth
2577
2727
  });
2578
- const days = weekData ? weekData.days : monthState?.weeks.flat() ?? [];
2579
- const perWeek = weekData != null;
2580
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: days.map((day, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellInstance, {
2728
+ if (!weekData) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthDayCells, { ...restProps });
2729
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: weekData.days.map((day, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellInstance, {
2581
2730
  ...restProps,
2582
2731
  date: day,
2583
- columnIndex: perWeek ? i : void 0,
2584
- _derivedState: derive(day, perWeek ? i : void 0)
2732
+ columnIndex: i,
2733
+ gridMonth: weekData.gridMonth
2585
2734
  }, day.toString())) });
2586
2735
  }
2587
2736
  function DayButtonInnerFn(props, ref) {
2588
- const { render, date, _derivedState, ...otherProps } = props;
2737
+ const { render, date, _state, ...otherProps } = props;
2589
2738
  const { onSelect, locale, readOnly, setHoveredDate } = useCalendarStable();
2590
- const { setFocusedDate } = useViewContext();
2591
- const { gridFocusedRef } = useViewStable();
2739
+ const { gridFocusedRef, setFocusedDate } = useViewStable();
2592
2740
  const internalRef = (0, react.useRef)(null);
2593
- const isHidden = _derivedState?.hidden ?? false;
2594
- const isFocused = _derivedState?.focused ?? false;
2595
- const isTabTarget = _derivedState?.isTabTarget ?? false;
2596
- const isDisabled = _derivedState?.disabled ?? false;
2741
+ const isHidden = _state.hidden;
2742
+ const isFocused = _state.focused;
2743
+ const isTabTarget = _state.isTabTarget;
2744
+ const isDisabled = _state.disabled;
2597
2745
  (0, react.useEffect)(() => {
2598
2746
  if (shouldMoveDomFocus(isFocused, gridFocusedRef.current) && internalRef.current) internalRef.current.focus();
2599
2747
  }, [isFocused, gridFocusedRef]);
2600
- const state = _derivedState;
2748
+ const state = _state;
2601
2749
  const defaultProps = isHidden ? {} : {
2602
2750
  type: "button",
2603
2751
  tabIndex: isTabTarget ? 0 : -1,
@@ -2629,12 +2777,7 @@ function DayButtonInnerFn(props, ref) {
2629
2777
  });
2630
2778
  }
2631
2779
  function dayButtonInnerPropsAreEqual(prev, next) {
2632
- if (prev.date !== next.date || prev.render !== next.render) return false;
2633
- if (!passThroughPropsEqual(prev, next, DAY_BUTTON_HANDLED_KEYS)) return false;
2634
- const a = prev._derivedState;
2635
- const b = next._derivedState;
2636
- if (!a || !b) return a === b;
2637
- return dayCellStateEqual(a, b);
2780
+ return prev.date === next.date && prev.render === next.render && prev._state === next._state && passThroughPropsEqual(prev, next, DAY_BUTTON_HANDLED_KEYS);
2638
2781
  }
2639
2782
  const DayButtonInner = (0, react.memo)((0, react.forwardRef)(DayButtonInnerFn), dayButtonInnerPropsAreEqual);
2640
2783
  /**
@@ -2644,37 +2787,36 @@ const DayButtonInner = (0, react.memo)((0, react.forwardRef)(DayButtonInnerFn),
2644
2787
  * Must be used inside a {@link DayCellTemplate} or given an explicit `date` prop.
2645
2788
  */
2646
2789
  function DayButtonFn(props, ref) {
2647
- const { date: dateProp, _derivedState, ...restProps } = props;
2790
+ const { date: dateProp, ...restProps } = props;
2791
+ const cellState = (0, react.useContext)(DayCellStateContext);
2648
2792
  const cellData = (0, react.useContext)(DayCellDataContext);
2793
+ if (cellState && (!dateProp || dateProp.equals(cellState.date))) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButtonInner, {
2794
+ ...restProps,
2795
+ ref,
2796
+ date: cellState.date,
2797
+ _state: cellState
2798
+ });
2649
2799
  const resolvedDate = dateProp ?? cellData?.date;
2650
- if (resolvedDate) {
2651
- if (_derivedState) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButtonInner, {
2652
- ...restProps,
2653
- ref,
2654
- date: resolvedDate,
2655
- _derivedState
2656
- });
2657
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButtonFallback, {
2658
- ref,
2659
- ...restProps,
2660
- date: resolvedDate
2661
- });
2662
- }
2800
+ if (resolvedDate) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StandaloneDayButton, {
2801
+ ...restProps,
2802
+ ref,
2803
+ date: resolvedDate
2804
+ });
2663
2805
  throw new Error("DayButton must be used inside DayCellTemplate or receive an explicit date prop.");
2664
2806
  }
2665
2807
  const DayButton = (0, react.forwardRef)(DayButtonFn);
2666
- /** Fallback for standalone DayButton usage that needs to read context. */
2667
- function DayButtonFallbackFn(props, ref) {
2808
+ /** A `DayButton` outside any day cell: subscribes to its own date's state. */
2809
+ function StandaloneDayButtonFn(props, ref) {
2668
2810
  const { date, ...restProps } = props;
2669
- const derive = useDayCellDeriver();
2811
+ const state = useStandaloneDayCellState(date);
2670
2812
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButtonInner, {
2671
2813
  ...restProps,
2672
2814
  ref,
2673
2815
  date,
2674
- _derivedState: derive(date)
2816
+ _state: state
2675
2817
  });
2676
2818
  }
2677
- const DayButtonFallback = (0, react.forwardRef)(DayButtonFallbackFn);
2819
+ const StandaloneDayButton = (0, react.forwardRef)(StandaloneDayButtonFn);
2678
2820
  // src/grid.tsx
2679
2821
  function useGridKeyboard() {
2680
2822
  const { onSelect, disabled, readOnly, isDateDisabled, minValue, maxValue, temporal: T, weekStartDay } = useCalendarStable();
@@ -3040,18 +3182,23 @@ function WeekTemplate(props) {
3040
3182
  year: gridMonthCtx.year,
3041
3183
  month: gridMonthCtx.month
3042
3184
  } : void 0, [gridMonthCtx]);
3043
- const Instance = WeekInstance;
3044
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: weeks.map((weekDays, i) => {
3045
- const firstDay = weekDays[0];
3185
+ const gridRowIndex = outerWeekData?.gridRowIndex;
3186
+ const weekValues = (0, react.useMemo)(() => weeks.map((weekDays, i) => ({
3187
+ days: weekDays,
3188
+ weekIndex: i,
3189
+ ...gridMonth !== void 0 && { gridMonth },
3190
+ ...gridRowIndex !== void 0 && { gridRowIndex }
3191
+ })), [
3192
+ weeks,
3193
+ gridMonth,
3194
+ gridRowIndex
3195
+ ]);
3196
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: weekValues.map((value) => {
3197
+ const firstDay = value.days[0];
3046
3198
  if (firstDay === void 0) return null;
3047
3199
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WeekDataContext.Provider, {
3048
- value: {
3049
- days: weekDays,
3050
- weekIndex: i,
3051
- ...gridMonth !== void 0 && { gridMonth },
3052
- ...outerWeekData?.gridRowIndex !== void 0 && { gridRowIndex: outerWeekData.gridRowIndex }
3053
- },
3054
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Instance, { ...props })
3200
+ value,
3201
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WeekInstance, { ...props })
3055
3202
  }, firstDay.toString());
3056
3203
  }) });
3057
3204
  }
@@ -4176,7 +4323,8 @@ function useWeeksViewRootState(props) {
4176
4323
  ]),
4177
4324
  viewStableCtx: (0, react.useMemo)(() => ({
4178
4325
  gridFocusedRef,
4179
- outsideDays: "enabled"
4326
+ outsideDays: "enabled",
4327
+ setFocusedDate
4180
4328
  }), []),
4181
4329
  viewStateCtx: (0, react.useMemo)(() => ({
4182
4330
  currentDateTime,
@@ -4200,7 +4348,7 @@ function WeeksViewRootFn(props, ref) {
4200
4348
  value: viewStateCtx,
4201
4349
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewContext.Provider, {
4202
4350
  value: viewCtx,
4203
- children
4351
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellStoreProvider, { children })
4204
4352
  })
4205
4353
  })
4206
4354
  })