@klinking/colander 3.1.0-alpha.7 → 3.1.0-alpha.8
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.
- package/dist/formats/date.cjs +2 -3
- package/dist/formats/date.d.cts +10 -14
- package/dist/formats/date.d.mts +10 -14
- package/dist/formats/date.mjs +2 -3
- package/dist/formats/object.cjs +2 -3
- package/dist/formats/object.d.cts +10 -14
- package/dist/formats/object.d.mts +10 -14
- package/dist/formats/object.mjs +2 -3
- package/dist/formats/plain-date-time.cjs +2 -3
- package/dist/formats/plain-date-time.d.cts +10 -14
- package/dist/formats/plain-date-time.d.mts +10 -14
- package/dist/formats/plain-date-time.mjs +2 -3
- package/dist/formats/plain-date.cjs +2 -3
- package/dist/formats/plain-date.d.cts +10 -14
- package/dist/formats/plain-date.d.mts +10 -14
- package/dist/formats/plain-date.mjs +2 -3
- package/dist/formats/plain-month-day.cjs +2 -3
- package/dist/formats/plain-month-day.d.cts +10 -14
- package/dist/formats/plain-month-day.d.mts +10 -14
- package/dist/formats/plain-month-day.mjs +2 -3
- package/dist/formats/plain-year-month.cjs +2 -3
- package/dist/formats/plain-year-month.d.cts +10 -14
- package/dist/formats/plain-year-month.d.mts +10 -14
- package/dist/formats/plain-year-month.mjs +2 -3
- package/dist/formats/zoned-date-time.cjs +2 -3
- package/dist/formats/zoned-date-time.d.cts +10 -14
- package/dist/formats/zoned-date-time.d.mts +10 -14
- package/dist/formats/zoned-date-time.mjs +2 -3
- package/dist/{weeks-view-context-BTojXkys.d.cts → index-BqzrxYgn.d.cts} +89 -106
- package/dist/{weeks-view-context-CFXV8orh.d.mts → index-CkhYFmf4.d.mts} +89 -106
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -10
- package/dist/index.d.mts +1 -10
- package/dist/index.mjs +1 -2
- package/dist/{weeks-navigation-BSKwFvdP.mjs → weeks-navigation-BWB5OvqW.mjs} +95 -111
- package/dist/{weeks-navigation-CPevz3Xg.cjs → weeks-navigation-CatYJIKb.cjs} +97 -114
- package/package.json +17 -18
- package/src/calendar-provider.test.tsx +1 -1
- package/src/compute-weeks-in-window.test.ts +1 -1
- package/src/day-cell-state.test.ts +1 -1
- package/src/day-cell.test.tsx +1 -1
- package/src/formats/formats.test.ts +1 -1
- package/src/grid.event-perf.test.tsx +7 -1
- package/src/grid.perf.test.tsx +7 -1
- package/src/keyboard.test.ts +1 -1
- package/src/month-separator.test.tsx +1 -1
- package/src/month-view.bounds.test.tsx +1 -1
- package/src/month-view.test.tsx +89 -1
- package/src/month-view.tsx +14 -5
- package/src/month-window.test.ts +1 -1
- package/src/out-of-range.test.ts +1 -1
- package/src/range-preview.test.ts +1 -1
- package/src/resolve-first-week.test.ts +1 -1
- package/src/today.test.tsx +8 -1
- package/src/utils.bench.ts +158 -106
- package/src/utils.test.ts +1 -1
- package/src/view-context.test.tsx +1 -1
- package/src/weeks-keyboard.test.ts +1 -1
- package/src/weeks-view.bounds.test.tsx +1 -1
- package/src/weeks-view.test.tsx +1 -1
- package/src/weeks-window.test.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -15,17 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
22
|
-
//#endregion
|
|
23
22
|
let react = require("react");
|
|
24
23
|
react = __toESM(react, 1);
|
|
25
24
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
26
25
|
let _base_ui_react_merge_props = require("@base-ui/react/merge-props");
|
|
27
26
|
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
28
|
-
|
|
27
|
+
// src/calendar-context.ts
|
|
29
28
|
/** @internal React context carrying stable CalendarProvider values (callbacks, config). */
|
|
30
29
|
const CalendarStableContext = (0, react.createContext)(null);
|
|
31
30
|
/** @internal React context carrying volatile CalendarProvider state. */
|
|
@@ -42,8 +41,7 @@ function useCalendarState() {
|
|
|
42
41
|
if (!ctx) throw new Error("useCalendarState must be used within CalendarProvider");
|
|
43
42
|
return ctx;
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
//#region src/utils.ts
|
|
44
|
+
// src/utils.ts
|
|
47
45
|
/**
|
|
48
46
|
* Resolves a {@link TemporalNamespace} instance.
|
|
49
47
|
*
|
|
@@ -489,8 +487,7 @@ function getISOWeekNumber(date, T) {
|
|
|
489
487
|
const daysDiff = thursday.since(jan4Thursday, { largestUnit: "days" }).days;
|
|
490
488
|
return Math.round(daysDiff / 7) + 1;
|
|
491
489
|
}
|
|
492
|
-
|
|
493
|
-
//#region src/root-selection.ts
|
|
490
|
+
// src/root-selection.ts
|
|
494
491
|
/** Construct a DateRange (workaround for TS generic conditional type widening). */
|
|
495
492
|
function mkRange(start, end) {
|
|
496
493
|
return {
|
|
@@ -855,8 +852,7 @@ function computePreviewRange(hoveredDate, currentRange, rangeMode, preventRangeR
|
|
|
855
852
|
});
|
|
856
853
|
return preview ? mkRange(preview[0], preview[1]) : null;
|
|
857
854
|
}
|
|
858
|
-
|
|
859
|
-
//#region src/calendar-provider.tsx
|
|
855
|
+
// src/calendar-provider.tsx
|
|
860
856
|
/**
|
|
861
857
|
* Provides shared calendar state (selection, config, range preview) to all
|
|
862
858
|
* descendant view components. Does NOT manage focus, navigation, or grid data.
|
|
@@ -974,7 +970,7 @@ function CalendarProvider(props) {
|
|
|
974
970
|
isRange,
|
|
975
971
|
isMultiple
|
|
976
972
|
]);
|
|
977
|
-
const
|
|
973
|
+
const defaultDates = (0, react.useMemo)(() => {
|
|
978
974
|
if (isMultiple) {
|
|
979
975
|
if (multipleDefault) return sortDates(multipleDefault.map(rawToPlain));
|
|
980
976
|
return [];
|
|
@@ -989,7 +985,8 @@ function CalendarProvider(props) {
|
|
|
989
985
|
singleDefault,
|
|
990
986
|
rawToPlain,
|
|
991
987
|
sortDates
|
|
992
|
-
])
|
|
988
|
+
]);
|
|
989
|
+
const [internalDates, setInternalDates] = (0, react.useState)(defaultDates);
|
|
993
990
|
const isControlled = controlledDates !== void 0;
|
|
994
991
|
const committedDates = isControlled ? controlledDates : internalDates;
|
|
995
992
|
const rangeStart = !isMultiple && committedDates.length > 0 ? committedDates[0] ?? void 0 : void 0;
|
|
@@ -1300,8 +1297,7 @@ function CalendarProvider(props) {
|
|
|
1300
1297
|
})
|
|
1301
1298
|
});
|
|
1302
1299
|
}
|
|
1303
|
-
|
|
1304
|
-
//#region src/month-view-context.ts
|
|
1300
|
+
// src/month-view-context.ts
|
|
1305
1301
|
/** @internal React context for MonthView stable values (config + callbacks). */
|
|
1306
1302
|
const MonthViewStableContext = (0, react.createContext)(null);
|
|
1307
1303
|
/** @internal React context for MonthView volatile state. */
|
|
@@ -1318,8 +1314,7 @@ function useMonthViewState() {
|
|
|
1318
1314
|
if (!ctx) throw new Error("useMonthViewState must be used within MonthView.Root");
|
|
1319
1315
|
return ctx;
|
|
1320
1316
|
}
|
|
1321
|
-
|
|
1322
|
-
//#region src/month-view-navigation.ts
|
|
1317
|
+
// src/month-view-navigation.ts
|
|
1323
1318
|
/**
|
|
1324
1319
|
* Owns which month the view shows, in both controlled and uncontrolled mode:
|
|
1325
1320
|
* the month state, the Prev/Next steps, and syncing the window with focus.
|
|
@@ -1438,8 +1433,7 @@ function useMonthNavigation(input) {
|
|
|
1438
1433
|
goPrevMonth: (0, react.useCallback)(() => go("prev"), [go])
|
|
1439
1434
|
};
|
|
1440
1435
|
}
|
|
1441
|
-
|
|
1442
|
-
//#region src/month-window.ts
|
|
1436
|
+
// src/month-window.ts
|
|
1443
1437
|
const monthIndex = (m) => m.year * 12 + (m.month - 1);
|
|
1444
1438
|
/**
|
|
1445
1439
|
* Builds the policy for a MonthView window of `numberOfMonths` months.
|
|
@@ -1489,8 +1483,7 @@ function monthAt(start, offset) {
|
|
|
1489
1483
|
month: index % 12 + 1
|
|
1490
1484
|
};
|
|
1491
1485
|
}
|
|
1492
|
-
|
|
1493
|
-
//#region src/view-context.ts
|
|
1486
|
+
// src/view-context.ts
|
|
1494
1487
|
/** @internal React context for the active view (MonthView or WeeksView). */
|
|
1495
1488
|
const ViewContext = (0, react.createContext)(null);
|
|
1496
1489
|
/** Returns the nearest view context (MonthView or WeeksView). */
|
|
@@ -1515,8 +1508,7 @@ function useViewState() {
|
|
|
1515
1508
|
if (!ctx) throw new Error("useViewState must be used within MonthView or WeeksView");
|
|
1516
1509
|
return ctx;
|
|
1517
1510
|
}
|
|
1518
|
-
|
|
1519
|
-
//#region src/month-view.tsx
|
|
1511
|
+
// src/month-view.tsx
|
|
1520
1512
|
function MonthViewRoot(props) {
|
|
1521
1513
|
const { numberOfMonths: numberOfMonthsProp, fixedWeeks: fixedWeeksProp, outsideDays: outsideDaysProp, outOfRangeBehavior: outOfRangeBehaviorProp, month: monthProp, defaultMonth: defaultMonthProp, onMonthChange, children } = props;
|
|
1522
1514
|
const numberOfMonths = Math.max(1, Math.min(numberOfMonthsProp ?? 1, 12));
|
|
@@ -1527,7 +1519,6 @@ function MonthViewRoot(props) {
|
|
|
1527
1519
|
const calState = useCalendarState();
|
|
1528
1520
|
const T = calStable.temporal;
|
|
1529
1521
|
const { timeZone, today, weekStartDay, isDateDisabled } = calStable;
|
|
1530
|
-
const [focusedDate, setFocusedDate] = (0, react.useState)(() => resolveInitialAnchor(calState.selected, today, timeZone, T));
|
|
1531
1522
|
const [gridHasFocus, setGridHasFocus] = (0, react.useState)(false);
|
|
1532
1523
|
const gridFocusedRef = (0, react.useRef)(false);
|
|
1533
1524
|
const { minValue, maxValue } = calStable;
|
|
@@ -1544,6 +1535,16 @@ function MonthViewRoot(props) {
|
|
|
1544
1535
|
maxValue,
|
|
1545
1536
|
T
|
|
1546
1537
|
]);
|
|
1538
|
+
const [focusedDate, setFocusedDate] = (0, react.useState)(() => {
|
|
1539
|
+
const anchor = resolveInitialAnchor(calState.selected, today, timeZone, T);
|
|
1540
|
+
const opening = monthProp ?? defaultMonthProp;
|
|
1541
|
+
if (!opening || windowPolicy.isVisible(opening, anchor)) return anchor;
|
|
1542
|
+
return T.PlainDate.from({
|
|
1543
|
+
year: opening.year,
|
|
1544
|
+
month: opening.month,
|
|
1545
|
+
day: 1
|
|
1546
|
+
});
|
|
1547
|
+
});
|
|
1547
1548
|
const { currentMonth, viewingYearMonth, goNextMonth, goPrevMonth } = useMonthNavigation({
|
|
1548
1549
|
month: monthProp,
|
|
1549
1550
|
defaultMonth: defaultMonthProp,
|
|
@@ -1732,8 +1733,7 @@ function MonthView(props) {
|
|
|
1732
1733
|
});
|
|
1733
1734
|
}
|
|
1734
1735
|
MonthView.Root = MonthViewRoot;
|
|
1735
|
-
|
|
1736
|
-
//#region src/context.ts
|
|
1736
|
+
// src/context.ts
|
|
1737
1737
|
/** @internal Provides the days and index of the current week row to child components. */
|
|
1738
1738
|
const WeekDataContext = (0, react.createContext)(null);
|
|
1739
1739
|
/** @internal Provides the resolved grid orientation to descendant cells. */
|
|
@@ -1742,8 +1742,7 @@ const GridContext = (0, react.createContext)({ orientation: "horizontal" });
|
|
|
1742
1742
|
const DayCellDataContext = (0, react.createContext)(null);
|
|
1743
1743
|
/** @internal Provides per-grid month data to WeekTemplate and DayCellTemplate. */
|
|
1744
1744
|
const GridMonthContext = (0, react.createContext)(null);
|
|
1745
|
-
|
|
1746
|
-
//#region src/grid-header.tsx
|
|
1745
|
+
// src/grid-header.tsx
|
|
1747
1746
|
function useGridHeaderCellState(index) {
|
|
1748
1747
|
const { locale, temporal: T, weekStartDay } = useCalendarStable();
|
|
1749
1748
|
const { rootState } = useViewState();
|
|
@@ -1835,8 +1834,7 @@ function GridHeaderFn(props, ref) {
|
|
|
1835
1834
|
}
|
|
1836
1835
|
/** Table header section (`<thead>`) wrapping a row of {@link GridHeaderCell}s. */
|
|
1837
1836
|
const GridHeader = (0, react.forwardRef)(GridHeaderFn);
|
|
1838
|
-
|
|
1839
|
-
//#region src/keyboard.ts
|
|
1837
|
+
// src/keyboard.ts
|
|
1840
1838
|
/**
|
|
1841
1839
|
* Computes the target date when jumping by `months` from `focusedDate`.
|
|
1842
1840
|
*
|
|
@@ -1909,8 +1907,7 @@ function computeNextFocusDate(input) {
|
|
|
1909
1907
|
if (nextDate) return clampToBounds(nextDate, focusedDate, minValue, maxValue, T);
|
|
1910
1908
|
return { action: "none" };
|
|
1911
1909
|
}
|
|
1912
|
-
|
|
1913
|
-
//#region src/month-separator.tsx
|
|
1910
|
+
// src/month-separator.tsx
|
|
1914
1911
|
/** Context providing MonthSeparator data to child components. */
|
|
1915
1912
|
const MonthSeparatorDataContext = (0, react.createContext)(null);
|
|
1916
1913
|
function useMonthSeparatorData() {
|
|
@@ -2040,8 +2037,7 @@ function MonthSeparatorFn(props, ref) {
|
|
|
2040
2037
|
* Default children: `<Month /> <Year />`.
|
|
2041
2038
|
*/
|
|
2042
2039
|
const MonthSeparator = (0, react.forwardRef)(MonthSeparatorFn);
|
|
2043
|
-
|
|
2044
|
-
//#region src/weeks-view-context.ts
|
|
2040
|
+
// src/weeks-view-context.ts
|
|
2045
2041
|
/** @internal React context for WeeksView stable values (config + callbacks). */
|
|
2046
2042
|
const WeeksViewStableContext = (0, react.createContext)(null);
|
|
2047
2043
|
/** @internal React context for WeeksView volatile state. */
|
|
@@ -2058,8 +2054,7 @@ function useWeeksViewState() {
|
|
|
2058
2054
|
if (!ctx) throw new Error("useWeeksViewState must be used within WeeksView.Root");
|
|
2059
2055
|
return ctx;
|
|
2060
2056
|
}
|
|
2061
|
-
|
|
2062
|
-
//#region src/weeks-grid.tsx
|
|
2057
|
+
// src/weeks-grid.tsx
|
|
2063
2058
|
/**
|
|
2064
2059
|
* @internal WeeksGrid — renders continuous week rows for WeeksView.
|
|
2065
2060
|
* Not exported from the public API.
|
|
@@ -2225,8 +2220,7 @@ function WeeksGrid(props) {
|
|
|
2225
2220
|
children: rows
|
|
2226
2221
|
});
|
|
2227
2222
|
}
|
|
2228
|
-
|
|
2229
|
-
//#region src/weeks-keyboard.ts
|
|
2223
|
+
// src/weeks-keyboard.ts
|
|
2230
2224
|
const NONE = {
|
|
2231
2225
|
action: "none",
|
|
2232
2226
|
windowShift: 0,
|
|
@@ -2300,8 +2294,7 @@ function computeWeeksKeyNav(input) {
|
|
|
2300
2294
|
default: return NONE;
|
|
2301
2295
|
}
|
|
2302
2296
|
}
|
|
2303
|
-
|
|
2304
|
-
//#region src/day-cell-state.ts
|
|
2297
|
+
// src/day-cell-state.ts
|
|
2305
2298
|
const NO_RANGE = {
|
|
2306
2299
|
rangeStart: false,
|
|
2307
2300
|
rangeEnd: false,
|
|
@@ -2473,8 +2466,7 @@ function useDayCellDeriver() {
|
|
|
2473
2466
|
}, inputs);
|
|
2474
2467
|
};
|
|
2475
2468
|
}
|
|
2476
|
-
|
|
2477
|
-
//#region src/day-cell.tsx
|
|
2469
|
+
// src/day-cell.tsx
|
|
2478
2470
|
const dayStateAttributesMapping = {
|
|
2479
2471
|
root: () => null,
|
|
2480
2472
|
date: (v) => v ? { "data-date": v.toString() } : null,
|
|
@@ -2506,22 +2498,23 @@ const dayStateAttributesMapping = {
|
|
|
2506
2498
|
function DayCellInstanceFn(props) {
|
|
2507
2499
|
const { render, date, columnIndex, children, _derivedState, ...otherProps } = props;
|
|
2508
2500
|
const state = _derivedState;
|
|
2501
|
+
const defaultProps = state.hidden ? {
|
|
2502
|
+
role: "gridcell",
|
|
2503
|
+
"aria-hidden": true,
|
|
2504
|
+
children: null
|
|
2505
|
+
} : {
|
|
2506
|
+
role: "gridcell",
|
|
2507
|
+
"aria-selected": state.selected || void 0,
|
|
2508
|
+
"aria-disabled": state.disabled || void 0,
|
|
2509
|
+
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButton, { _derivedState })
|
|
2510
|
+
};
|
|
2509
2511
|
const cell = (0, _base_ui_react_use_render.useRender)({
|
|
2510
2512
|
defaultTagName: "td",
|
|
2511
2513
|
render,
|
|
2512
2514
|
ref: [],
|
|
2513
2515
|
state,
|
|
2514
2516
|
stateAttributesMapping: dayStateAttributesMapping,
|
|
2515
|
-
props: (0, _base_ui_react_merge_props.mergeProps)(
|
|
2516
|
-
role: "gridcell",
|
|
2517
|
-
"aria-hidden": true,
|
|
2518
|
-
children: null
|
|
2519
|
-
} : {
|
|
2520
|
-
role: "gridcell",
|
|
2521
|
-
"aria-selected": state.selected || void 0,
|
|
2522
|
-
"aria-disabled": state.disabled || void 0,
|
|
2523
|
-
children: children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayButton, { _derivedState })
|
|
2524
|
-
}, otherProps)
|
|
2517
|
+
props: (0, _base_ui_react_merge_props.mergeProps)(defaultProps, otherProps)
|
|
2525
2518
|
});
|
|
2526
2519
|
const outsideDisabled = state.hidden || state.outsideMonth && state.disabled;
|
|
2527
2520
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DayCellDataContext.Provider, {
|
|
@@ -2546,14 +2539,14 @@ function passThroughPropsEqual(prev, next, handledKeys) {
|
|
|
2546
2539
|
for (const key of prevKeys) if (prev[key] !== next[key]) return false;
|
|
2547
2540
|
return true;
|
|
2548
2541
|
}
|
|
2549
|
-
const DAY_CELL_HANDLED_KEYS = new Set([
|
|
2542
|
+
const DAY_CELL_HANDLED_KEYS = /* @__PURE__ */ new Set([
|
|
2550
2543
|
"render",
|
|
2551
2544
|
"date",
|
|
2552
2545
|
"columnIndex",
|
|
2553
2546
|
"children",
|
|
2554
2547
|
"_derivedState"
|
|
2555
2548
|
]);
|
|
2556
|
-
const DAY_BUTTON_HANDLED_KEYS = new Set([
|
|
2549
|
+
const DAY_BUTTON_HANDLED_KEYS = /* @__PURE__ */ new Set([
|
|
2557
2550
|
"render",
|
|
2558
2551
|
"date",
|
|
2559
2552
|
"children",
|
|
@@ -2682,8 +2675,7 @@ function DayButtonFallbackFn(props, ref) {
|
|
|
2682
2675
|
});
|
|
2683
2676
|
}
|
|
2684
2677
|
const DayButtonFallback = (0, react.forwardRef)(DayButtonFallbackFn);
|
|
2685
|
-
|
|
2686
|
-
//#region src/grid.tsx
|
|
2678
|
+
// src/grid.tsx
|
|
2687
2679
|
function useGridKeyboard() {
|
|
2688
2680
|
const { onSelect, disabled, readOnly, isDateDisabled, minValue, maxValue, temporal: T, weekStartDay } = useCalendarStable();
|
|
2689
2681
|
const { focusedDate, setFocusedDate } = useViewContext();
|
|
@@ -3017,19 +3009,20 @@ function WeekInstance(props) {
|
|
|
3017
3009
|
const { render, ...otherProps } = props;
|
|
3018
3010
|
const weekData = (0, react.useContext)(WeekDataContext);
|
|
3019
3011
|
const { rootState } = useViewState();
|
|
3012
|
+
const state = (0, react.useMemo)(() => ({
|
|
3013
|
+
root: rootState,
|
|
3014
|
+
weekIndex: weekData.weekIndex,
|
|
3015
|
+
gridRowIndex: weekData.gridRowIndex
|
|
3016
|
+
}), [
|
|
3017
|
+
rootState,
|
|
3018
|
+
weekData.weekIndex,
|
|
3019
|
+
weekData.gridRowIndex
|
|
3020
|
+
]);
|
|
3020
3021
|
return (0, _base_ui_react_use_render.useRender)({
|
|
3021
3022
|
defaultTagName: "tr",
|
|
3022
3023
|
render,
|
|
3023
3024
|
ref: [],
|
|
3024
|
-
state
|
|
3025
|
-
root: rootState,
|
|
3026
|
-
weekIndex: weekData.weekIndex,
|
|
3027
|
-
gridRowIndex: weekData.gridRowIndex
|
|
3028
|
-
}), [
|
|
3029
|
-
rootState,
|
|
3030
|
-
weekData.weekIndex,
|
|
3031
|
-
weekData.gridRowIndex
|
|
3032
|
-
]),
|
|
3025
|
+
state,
|
|
3033
3026
|
stateAttributesMapping: weekInstanceStateAttributesMapping,
|
|
3034
3027
|
props: (0, _base_ui_react_merge_props.mergeProps)({}, otherProps)
|
|
3035
3028
|
});
|
|
@@ -3062,8 +3055,7 @@ function WeekTemplate(props) {
|
|
|
3062
3055
|
}, firstDay.toString());
|
|
3063
3056
|
}) });
|
|
3064
3057
|
}
|
|
3065
|
-
|
|
3066
|
-
//#region src/navigation.tsx
|
|
3058
|
+
// src/navigation.tsx
|
|
3067
3059
|
const dateStringStateAttributesMapping = {
|
|
3068
3060
|
root: () => null,
|
|
3069
3061
|
month: () => null,
|
|
@@ -3299,8 +3291,7 @@ function NextMonthButtonFn(props, ref) {
|
|
|
3299
3291
|
* when the next month falls after `max`. Exposes `data-direction="next"`.
|
|
3300
3292
|
*/
|
|
3301
3293
|
const NextMonthButton = (0, react.forwardRef)(NextMonthButtonFn);
|
|
3302
|
-
|
|
3303
|
-
//#region src/selected-range.tsx
|
|
3294
|
+
// src/selected-range.tsx
|
|
3304
3295
|
const rangeOverlayStateAttributesMapping = {
|
|
3305
3296
|
root: () => null,
|
|
3306
3297
|
active: (v) => v ? { "data-active": "" } : null,
|
|
@@ -3420,8 +3411,7 @@ function RangeSelectedInnerFn(props, ref) {
|
|
|
3420
3411
|
});
|
|
3421
3412
|
}
|
|
3422
3413
|
const RangeSelectedInner = (0, react.forwardRef)(RangeSelectedInnerFn);
|
|
3423
|
-
|
|
3424
|
-
//#region src/range-preview.tsx
|
|
3414
|
+
// src/range-preview.tsx
|
|
3425
3415
|
function RangePreviewFn(props, ref) {
|
|
3426
3416
|
const { selectionMode } = useCalendarStable();
|
|
3427
3417
|
if (selectionMode !== "range") return null;
|
|
@@ -3494,8 +3484,7 @@ function RangePreviewInnerFn(props, ref) {
|
|
|
3494
3484
|
});
|
|
3495
3485
|
}
|
|
3496
3486
|
const RangePreviewInner = (0, react.forwardRef)(RangePreviewInnerFn);
|
|
3497
|
-
|
|
3498
|
-
//#region src/drag-handle.tsx
|
|
3487
|
+
// src/drag-handle.tsx
|
|
3499
3488
|
const dragHandleStateAttributesMapping = {
|
|
3500
3489
|
root: () => null,
|
|
3501
3490
|
active: (v) => v ? { "data-active": "" } : null,
|
|
@@ -3514,32 +3503,34 @@ function useDragHandle(edge, { dragging: draggingProp }) {
|
|
|
3514
3503
|
const isActive = readOnly || disabled || outsideDisabled ? false : edge === "start" ? !!(date && rangeStart && T.PlainDate.compare(date, rangeStart) === 0) : !!(date && rangeEnd && T.PlainDate.compare(date, rangeEnd) === 0);
|
|
3515
3504
|
const isDragging = !!draggingProp && isActive;
|
|
3516
3505
|
const handleRef = (0, react.useRef)(null);
|
|
3506
|
+
const state = (0, react.useMemo)(() => ({
|
|
3507
|
+
root: rootState,
|
|
3508
|
+
active: isActive,
|
|
3509
|
+
dragging: isDragging,
|
|
3510
|
+
edge,
|
|
3511
|
+
orientation
|
|
3512
|
+
}), [
|
|
3513
|
+
rootState,
|
|
3514
|
+
isActive,
|
|
3515
|
+
isDragging,
|
|
3516
|
+
edge,
|
|
3517
|
+
orientation
|
|
3518
|
+
]);
|
|
3519
|
+
const defaultProps = {
|
|
3520
|
+
role: "slider",
|
|
3521
|
+
"aria-roledescription": "drag handle",
|
|
3522
|
+
"aria-label": edge === "start" ? "Range start date" : "Range end date",
|
|
3523
|
+
"aria-valuetext": date?.toString(),
|
|
3524
|
+
"aria-grabbed": isActive ? isDragging : void 0,
|
|
3525
|
+
"aria-hidden": isActive ? void 0 : true,
|
|
3526
|
+
onPointerEnter: () => {
|
|
3527
|
+
if (date && !outsideDisabled) setHoveredDate(date);
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3517
3530
|
return {
|
|
3518
|
-
state
|
|
3519
|
-
root: rootState,
|
|
3520
|
-
active: isActive,
|
|
3521
|
-
dragging: isDragging,
|
|
3522
|
-
edge,
|
|
3523
|
-
orientation
|
|
3524
|
-
}), [
|
|
3525
|
-
rootState,
|
|
3526
|
-
isActive,
|
|
3527
|
-
isDragging,
|
|
3528
|
-
edge,
|
|
3529
|
-
orientation
|
|
3530
|
-
]),
|
|
3531
|
+
state,
|
|
3531
3532
|
stateAttributesMapping: dragHandleStateAttributesMapping,
|
|
3532
|
-
defaultProps
|
|
3533
|
-
role: "slider",
|
|
3534
|
-
"aria-roledescription": "drag handle",
|
|
3535
|
-
"aria-label": edge === "start" ? "Range start date" : "Range end date",
|
|
3536
|
-
"aria-valuetext": date?.toString(),
|
|
3537
|
-
"aria-grabbed": isActive ? isDragging : void 0,
|
|
3538
|
-
"aria-hidden": isActive ? void 0 : true,
|
|
3539
|
-
onPointerEnter: () => {
|
|
3540
|
-
if (date && !outsideDisabled) setHoveredDate(date);
|
|
3541
|
-
}
|
|
3542
|
-
},
|
|
3533
|
+
defaultProps,
|
|
3543
3534
|
handleRef
|
|
3544
3535
|
};
|
|
3545
3536
|
}
|
|
@@ -3580,8 +3571,7 @@ function RangeEndDragHandleFn(props, ref) {
|
|
|
3580
3571
|
}
|
|
3581
3572
|
/** Convenience wrapper for {@link RangeDragHandle} with `edge="end"`. */
|
|
3582
3573
|
const RangeEndDragHandle = (0, react.forwardRef)(RangeEndDragHandleFn);
|
|
3583
|
-
|
|
3584
|
-
//#region src/week-number.tsx
|
|
3574
|
+
// src/week-number.tsx
|
|
3585
3575
|
const weekNumberCellStateAttributesMapping = {
|
|
3586
3576
|
root: () => null,
|
|
3587
3577
|
weekNumber: (v) => ({ "data-week-number": String(v) })
|
|
@@ -3646,8 +3636,7 @@ function WeekNumberHeaderFn(props, ref) {
|
|
|
3646
3636
|
* Column header for the week number column. Renders a `<th scope="col">`.
|
|
3647
3637
|
*/
|
|
3648
3638
|
const WeekNumberHeader = (0, react.forwardRef)(WeekNumberHeaderFn);
|
|
3649
|
-
|
|
3650
|
-
//#region src/compute-weeks-in-window.ts
|
|
3639
|
+
// src/compute-weeks-in-window.ts
|
|
3651
3640
|
/**
|
|
3652
3641
|
* Computes an array of week descriptors for a continuous window.
|
|
3653
3642
|
* `firstWeek` is snapped back to the nearest `weekStartDay`.
|
|
@@ -3669,8 +3658,7 @@ function computeWeeksInWindow(firstWeek, weekCount, weekStartDay, _T) {
|
|
|
3669
3658
|
}
|
|
3670
3659
|
return weeks;
|
|
3671
3660
|
}
|
|
3672
|
-
|
|
3673
|
-
//#region src/resolve-first-week.ts
|
|
3661
|
+
// src/resolve-first-week.ts
|
|
3674
3662
|
/** Snaps `date` back to the start of its containing week (determined by `weekStartDay`). */
|
|
3675
3663
|
function snapToWeekStart(date, weekStartDay) {
|
|
3676
3664
|
const offset = (date.dayOfWeek % 7 - weekStartDay + 7) % 7;
|
|
@@ -3761,8 +3749,7 @@ function resolveFirstWeek(currentFirstWeek, weekCount, target, options) {
|
|
|
3761
3749
|
}
|
|
3762
3750
|
}
|
|
3763
3751
|
}
|
|
3764
|
-
|
|
3765
|
-
//#region src/out-of-range.ts
|
|
3752
|
+
// src/out-of-range.ts
|
|
3766
3753
|
/** Returns true if any day in the 7-day span starting at weekStart falls within [min, max]. */
|
|
3767
3754
|
function weekHasValidDay(weekStart, min, max, T) {
|
|
3768
3755
|
const weekEnd = weekStart.add({ days: 6 });
|
|
@@ -3831,8 +3818,7 @@ function applyOutOfRange({ targetFirstWeek, weekCount, behavior, min, max, weekS
|
|
|
3831
3818
|
weekCount
|
|
3832
3819
|
};
|
|
3833
3820
|
}
|
|
3834
|
-
|
|
3835
|
-
//#region src/weeks-window.ts
|
|
3821
|
+
// src/weeks-window.ts
|
|
3836
3822
|
function createWeekWindowPolicy({ weekCount, behavior, min, max, weekStartDay, T }) {
|
|
3837
3823
|
const bounds = {
|
|
3838
3824
|
weekCount,
|
|
@@ -3857,15 +3843,15 @@ function createWeekWindowPolicy({ weekCount, behavior, min, max, weekStartDay, T
|
|
|
3857
3843
|
moveTo,
|
|
3858
3844
|
shift: (current, direction, shiftBy) => {
|
|
3859
3845
|
const by = shiftBy ?? current.weekCount;
|
|
3860
|
-
const
|
|
3846
|
+
const target = current.firstWeek.add({ weeks: direction * by });
|
|
3847
|
+
const next = moveTo(target);
|
|
3861
3848
|
if (next === null) return null;
|
|
3862
3849
|
if ((behavior === "snap" || behavior === "snap-shrink") && isBounded && T.PlainDate.compare(next.firstWeek, current.firstWeek) === 0) return null;
|
|
3863
3850
|
return next;
|
|
3864
3851
|
}
|
|
3865
3852
|
};
|
|
3866
3853
|
}
|
|
3867
|
-
|
|
3868
|
-
//#region src/weeks-view-state.ts
|
|
3854
|
+
// src/weeks-view-state.ts
|
|
3869
3855
|
/**
|
|
3870
3856
|
* Core state management hook for WeeksView.Root.
|
|
3871
3857
|
* Reads calendar-level context and manages weeks-specific state.
|
|
@@ -4199,8 +4185,7 @@ function useWeeksViewRootState(props) {
|
|
|
4199
4185
|
scrollToWeek
|
|
4200
4186
|
};
|
|
4201
4187
|
}
|
|
4202
|
-
|
|
4203
|
-
//#region src/weeks-view.tsx
|
|
4188
|
+
// src/weeks-view.tsx
|
|
4204
4189
|
function WeeksViewRootFn(props, ref) {
|
|
4205
4190
|
const { children } = props;
|
|
4206
4191
|
const { stableCtx, stateCtx, viewCtx, viewStableCtx, viewStateCtx, scrollToWeek } = useWeeksViewRootState(props);
|
|
@@ -4242,8 +4227,7 @@ function WeeksViewFn(props, ref) {
|
|
|
4242
4227
|
}
|
|
4243
4228
|
const WeeksView = (0, react.forwardRef)(WeeksViewFn);
|
|
4244
4229
|
WeeksView.Root = WeeksViewRoot;
|
|
4245
|
-
|
|
4246
|
-
//#region src/weeks-navigation.tsx
|
|
4230
|
+
// src/weeks-navigation.tsx
|
|
4247
4231
|
const weeksNavButtonStateAttributesMapping = {
|
|
4248
4232
|
root: () => null,
|
|
4249
4233
|
direction: (v) => ({ "data-direction": v }),
|
|
@@ -4352,7 +4336,6 @@ function WeekCountFn(props, ref) {
|
|
|
4352
4336
|
* out-of-range modes where the actual count may be less than the `weekCount` prop.
|
|
4353
4337
|
*/
|
|
4354
4338
|
const WeekCount = (0, react.forwardRef)(WeekCountFn);
|
|
4355
|
-
//#endregion
|
|
4356
4339
|
Object.defineProperty(exports, "CalendarProvider", {
|
|
4357
4340
|
enumerable: true,
|
|
4358
4341
|
get: function() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klinking/colander",
|
|
3
|
-
"version": "3.1.0-alpha.
|
|
3
|
+
"version": "3.1.0-alpha.8",
|
|
4
4
|
"homepage": "https://github.com/klink-ing/colander#readme",
|
|
5
5
|
"bugs": "https://github.com/klink-ing/colander/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -127,24 +127,23 @@
|
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"@base-ui/react": "^1.
|
|
130
|
+
"@base-ui/react": "^1.9.0",
|
|
131
131
|
"@js-temporal/polyfill": "^0.5.1",
|
|
132
|
-
"@playwright/test": "^1.
|
|
133
|
-
"@testing-library/dom": "^10.4.
|
|
134
|
-
"@testing-library/react": "^16.3.
|
|
135
|
-
"@types/react": "^19.
|
|
136
|
-
"@types/react-dom": "^19.
|
|
137
|
-
"@vitejs/plugin-react": "^
|
|
138
|
-
"jsdom": "^
|
|
139
|
-
"
|
|
140
|
-
"react": "^19.
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"tsx": "^4.
|
|
144
|
-
"typescript": "^
|
|
145
|
-
"vite": "npm:@voidzero-dev/vite-plus-core
|
|
146
|
-
"vite-plus": "
|
|
147
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
132
|
+
"@playwright/test": "^1.65.2",
|
|
133
|
+
"@testing-library/dom": "^10.4.2",
|
|
134
|
+
"@testing-library/react": "^16.3.3",
|
|
135
|
+
"@types/react": "^19.3.3",
|
|
136
|
+
"@types/react-dom": "^19.3.0",
|
|
137
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
138
|
+
"jsdom": "^31.0.1",
|
|
139
|
+
"react": "^19.3.1",
|
|
140
|
+
"react-dom": "^19.3.1",
|
|
141
|
+
"rollup-plugin-visualizer": "^7.3.0",
|
|
142
|
+
"ts-morph": "^28.0.0",
|
|
143
|
+
"tsx": "^4.23.15",
|
|
144
|
+
"typescript": "^7.0.2",
|
|
145
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
|
|
146
|
+
"vite-plus": "1.8.0"
|
|
148
147
|
},
|
|
149
148
|
"peerDependencies": {
|
|
150
149
|
"@base-ui/react": ">=1.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { render, act, cleanup } from "@testing-library/react";
|
|
3
3
|
import type { ComponentProps } from "react";
|
|
4
|
-
import { describe, it, expect, vi, afterEach } from "
|
|
4
|
+
import { describe, it, expect, vi, afterEach } from "vite-plus/test";
|
|
5
5
|
import { useCalendarStable, useCalendarState } from "./calendar-context";
|
|
6
6
|
import { CalendarProvider } from "./calendar-provider";
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import { describe, expect, it } from "
|
|
2
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
3
3
|
import { computeDayCellState, dayCellStateEqual } from "./day-cell-state";
|
|
4
4
|
import type { DayCellInputs } from "./day-cell-state";
|
|
5
5
|
import type { OutsideDays } from "./types";
|
package/src/day-cell.test.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
2
|
import * as root from "@klinking/colander";
|
|
3
|
-
import { describe, it, expect } from "
|
|
3
|
+
import { describe, it, expect } from "vite-plus/test";
|
|
4
4
|
|
|
5
5
|
const formatModules = import.meta.glob<Record<string, unknown>>(
|
|
6
6
|
["./*.ts", "!./*.test.ts"],
|
|
@@ -2,7 +2,13 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { render, act, fireEvent } from "@testing-library/react";
|
|
3
3
|
import { Profiler, type ProfilerOnRenderCallback } from "react";
|
|
4
4
|
// @vitest-environment jsdom
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
describe,
|
|
7
|
+
it,
|
|
8
|
+
expect,
|
|
9
|
+
beforeAll,
|
|
10
|
+
type TestOptions,
|
|
11
|
+
} from "vite-plus/test";
|
|
6
12
|
|
|
7
13
|
const perfOptions: TestOptions = { retry: 3 };
|
|
8
14
|
import { Grid } from "./grid";
|
package/src/grid.perf.test.tsx
CHANGED
|
@@ -2,7 +2,13 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { render } from "@testing-library/react";
|
|
3
3
|
import { Profiler, type ProfilerOnRenderCallback } from "react";
|
|
4
4
|
// @vitest-environment jsdom
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
describe,
|
|
7
|
+
it,
|
|
8
|
+
expect,
|
|
9
|
+
beforeAll,
|
|
10
|
+
type TestOptions,
|
|
11
|
+
} from "vite-plus/test";
|
|
6
12
|
|
|
7
13
|
const perfOptions: TestOptions = { retry: 3 };
|
|
8
14
|
import { WeekDataContext } from "./context";
|
package/src/keyboard.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect } from "
|
|
1
|
+
import { describe, it, expect } from "vite-plus/test";
|
|
2
2
|
import { computeNextFocusDate, computeMonthJumpTarget } from "./keyboard";
|
|
3
3
|
import type { KeyboardNavInput } from "./keyboard";
|
|
4
4
|
import { temporalVariants } from "./test-temporal";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { act, cleanup, render, screen } from "@testing-library/react";
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from "
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
|
4
4
|
import { MonthView } from "./month-view";
|
|
5
5
|
import type { MonthViewProps } from "./month-view";
|
|
6
6
|
import { useMonthViewStable, useMonthViewState } from "./month-view-context";
|