@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
package/src/month-view.test.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { render, act } from "@testing-library/react";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
// @vitest-environment jsdom
|
|
5
|
-
import { describe, it, expect, vi } from "
|
|
5
|
+
import { describe, it, expect, vi } from "vite-plus/test";
|
|
6
6
|
import { useCalendarStable } from "./calendar-context";
|
|
7
7
|
import { Grid } from "./grid";
|
|
8
8
|
import { MonthView } from "./month-view";
|
|
@@ -2092,3 +2092,91 @@ describe("outsideDays", () => {
|
|
|
2092
2092
|
});
|
|
2093
2093
|
});
|
|
2094
2094
|
});
|
|
2095
|
+
|
|
2096
|
+
describe("opening month", () => {
|
|
2097
|
+
// 2020 dates keep the real today out of every window under test.
|
|
2098
|
+
const ym = (s: string) => Temporal.PlainYearMonth.from(s);
|
|
2099
|
+
const day = (s: string) => Temporal.PlainDate.from(s);
|
|
2100
|
+
|
|
2101
|
+
it.each([
|
|
2102
|
+
{
|
|
2103
|
+
description: "defaultMonth opens on that month, not today's",
|
|
2104
|
+
props: { defaultMonth: ym("2020-03") },
|
|
2105
|
+
keys: [],
|
|
2106
|
+
expected: { months: ["2020-03"], focused: "2020-03-01", monthChanges: 0 },
|
|
2107
|
+
},
|
|
2108
|
+
{
|
|
2109
|
+
description: "defaultMonth opens on that month in range mode",
|
|
2110
|
+
props: { selectionMode: "range", defaultMonth: ym("2020-03") },
|
|
2111
|
+
keys: [],
|
|
2112
|
+
expected: { months: ["2020-03"], focused: "2020-03-01", monthChanges: 0 },
|
|
2113
|
+
},
|
|
2114
|
+
{
|
|
2115
|
+
description: "defaultMonth wins over a defaultValue outside it",
|
|
2116
|
+
props: { defaultMonth: ym("2020-03"), defaultValue: day("2020-05-15") },
|
|
2117
|
+
keys: [],
|
|
2118
|
+
expected: { months: ["2020-03"], focused: "2020-03-01", monthChanges: 0 },
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
description: "a defaultValue inside a multi-month window keeps focus",
|
|
2122
|
+
props: {
|
|
2123
|
+
defaultMonth: ym("2020-03"),
|
|
2124
|
+
defaultValue: day("2020-04-15"),
|
|
2125
|
+
numberOfMonths: 2,
|
|
2126
|
+
},
|
|
2127
|
+
keys: [],
|
|
2128
|
+
expected: {
|
|
2129
|
+
months: ["2020-03", "2020-04"],
|
|
2130
|
+
focused: "2020-04-15",
|
|
2131
|
+
monthChanges: 0,
|
|
2132
|
+
},
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
description: "the first arrow key after defaultMonth moves within it",
|
|
2136
|
+
props: { defaultMonth: ym("2020-03") },
|
|
2137
|
+
keys: ["ArrowRight"],
|
|
2138
|
+
expected: { months: ["2020-03"], focused: "2020-03-02", monthChanges: 0 },
|
|
2139
|
+
},
|
|
2140
|
+
{
|
|
2141
|
+
description: "the first arrow key in a controlled month moves within it",
|
|
2142
|
+
props: { month: ym("2020-03") },
|
|
2143
|
+
keys: ["ArrowRight"],
|
|
2144
|
+
expected: { months: ["2020-03"], focused: "2020-03-02", monthChanges: 0 },
|
|
2145
|
+
},
|
|
2146
|
+
])("$description", ({ props, keys, expected }) => {
|
|
2147
|
+
const onMonthChange = vi.fn();
|
|
2148
|
+
let captured: { months: string[]; focused: string } | undefined;
|
|
2149
|
+
const { container } = render(
|
|
2150
|
+
<MonthView
|
|
2151
|
+
{...defaultProps}
|
|
2152
|
+
{...(props as object)}
|
|
2153
|
+
onMonthChange={onMonthChange}
|
|
2154
|
+
>
|
|
2155
|
+
<Grid />
|
|
2156
|
+
<MonthDataCapture
|
|
2157
|
+
onCapture={(d) => {
|
|
2158
|
+
captured = {
|
|
2159
|
+
months: d.allMonths.map((m) =>
|
|
2160
|
+
Temporal.PlainYearMonth.from(m).toString(),
|
|
2161
|
+
),
|
|
2162
|
+
focused: d.focusedDate,
|
|
2163
|
+
};
|
|
2164
|
+
}}
|
|
2165
|
+
/>
|
|
2166
|
+
</MonthView>,
|
|
2167
|
+
);
|
|
2168
|
+
const grid = container.querySelector('[role="grid"]')!;
|
|
2169
|
+
for (const key of keys) {
|
|
2170
|
+
act(() => {
|
|
2171
|
+
grid.dispatchEvent(
|
|
2172
|
+
new KeyboardEvent("keydown", { key, bubbles: true }),
|
|
2173
|
+
);
|
|
2174
|
+
});
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
expect({
|
|
2178
|
+
...captured,
|
|
2179
|
+
monthChanges: onMonthChange.mock.calls.length,
|
|
2180
|
+
}).toEqual(expected);
|
|
2181
|
+
});
|
|
2182
|
+
});
|
package/src/month-view.tsx
CHANGED
|
@@ -58,11 +58,6 @@ function MonthViewRoot(props: MonthViewRootProps) {
|
|
|
58
58
|
const T = calStable.temporal;
|
|
59
59
|
const { timeZone, today, weekStartDay, isDateDisabled } = calStable;
|
|
60
60
|
|
|
61
|
-
// --- Focus state ---
|
|
62
|
-
const [focusedDate, setFocusedDate] = useState<Temporal.PlainDate>(() =>
|
|
63
|
-
resolveInitialAnchor(calState.selected, today, timeZone, T),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
61
|
const [gridHasFocus, setGridHasFocus] = useState(false);
|
|
67
62
|
const gridFocusedRef = useRef(false);
|
|
68
63
|
|
|
@@ -80,6 +75,20 @@ function MonthViewRoot(props: MonthViewRootProps) {
|
|
|
80
75
|
[numberOfMonths, outOfRangeBehavior, minValue, maxValue, T],
|
|
81
76
|
);
|
|
82
77
|
|
|
78
|
+
// --- Focus state ---
|
|
79
|
+
// Focus starts inside the window the view opens on. Arrow keys move from
|
|
80
|
+
// the focused date, so focus outside the window would pull the view to it.
|
|
81
|
+
const [focusedDate, setFocusedDate] = useState<Temporal.PlainDate>(() => {
|
|
82
|
+
const anchor = resolveInitialAnchor(calState.selected, today, timeZone, T);
|
|
83
|
+
const opening = monthProp ?? defaultMonthProp;
|
|
84
|
+
if (!opening || windowPolicy.isVisible(opening, anchor)) return anchor;
|
|
85
|
+
return T.PlainDate.from({
|
|
86
|
+
year: opening.year,
|
|
87
|
+
month: opening.month,
|
|
88
|
+
day: 1,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
83
92
|
const initialAnchor = useCallback(
|
|
84
93
|
() => resolveInitialAnchor(calState.selected, today, timeZone, T),
|
|
85
94
|
[calState.selected, today, timeZone, T],
|
package/src/month-window.test.ts
CHANGED
|
@@ -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 { createMonthWindowPolicy } from "./month-window";
|
|
4
4
|
import type { MonthWindowPolicyInput } from "./month-window";
|
|
5
5
|
|
package/src/out-of-range.test.ts
CHANGED
package/src/today.test.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { render, screen, cleanup } from "@testing-library/react";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
describe,
|
|
5
|
+
it,
|
|
6
|
+
expect,
|
|
7
|
+
vi,
|
|
8
|
+
afterEach,
|
|
9
|
+
beforeEach,
|
|
10
|
+
} from "vite-plus/test";
|
|
4
11
|
import {
|
|
5
12
|
Grid,
|
|
6
13
|
GridBody,
|
package/src/utils.bench.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import {
|
|
2
|
+
import { test, describe } from "vite-plus/test";
|
|
3
3
|
import type { TemporalNamespace } from "./types";
|
|
4
4
|
import {
|
|
5
5
|
getMonthWeeks,
|
|
@@ -29,82 +29,112 @@ const rangeEnd = Temporal.PlainDate.from("2026-03-20");
|
|
|
29
29
|
const midWeek = marchWeeks[2]!; // a week in the middle of the range
|
|
30
30
|
|
|
31
31
|
describe("getMonthWeeks", () => {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
test("generate month grid (March 2026)", async ({ bench }) => {
|
|
33
|
+
await bench("generate month grid (March 2026)", () => {
|
|
34
|
+
getMonthWeeks(2026, 3, T);
|
|
35
|
+
}).run();
|
|
34
36
|
});
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
test("generate month grid (February — short month)", async ({ bench }) => {
|
|
39
|
+
await bench("generate month grid (February — short month)", () => {
|
|
40
|
+
getMonthWeeks(2026, 2, T);
|
|
41
|
+
}).run();
|
|
38
42
|
});
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
test("generate month grid (August — 6-week grid)", async ({ bench }) => {
|
|
45
|
+
await bench("generate month grid (August — 6-week grid)", () => {
|
|
46
|
+
getMonthWeeks(2026, 8, T);
|
|
47
|
+
}).run();
|
|
42
48
|
});
|
|
43
49
|
});
|
|
44
50
|
|
|
45
51
|
describe("computeWeekRangeInfo", () => {
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
test("week fully inside range", async ({ bench }) => {
|
|
53
|
+
await bench("week fully inside range", () => {
|
|
54
|
+
computeWeekRangeInfo(midWeek, rangeStart, rangeEnd, T);
|
|
55
|
+
}).run();
|
|
48
56
|
});
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
test("week with no overlap", async ({ bench }) => {
|
|
59
|
+
await bench("week with no overlap", () => {
|
|
60
|
+
const noOverlapWeek = marchWeeks[marchWeeks.length - 1]!;
|
|
61
|
+
computeWeekRangeInfo(
|
|
62
|
+
noOverlapWeek,
|
|
63
|
+
Temporal.PlainDate.from("2026-03-01"),
|
|
64
|
+
Temporal.PlainDate.from("2026-03-04"),
|
|
65
|
+
T,
|
|
66
|
+
);
|
|
67
|
+
}).run();
|
|
58
68
|
});
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
test("no range (undefined bounds)", async ({ bench }) => {
|
|
71
|
+
await bench("no range (undefined bounds)", () => {
|
|
72
|
+
computeWeekRangeInfo(midWeek, undefined, undefined, T);
|
|
73
|
+
}).run();
|
|
62
74
|
});
|
|
63
75
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
test("all 6 weeks of a month", async ({ bench }) => {
|
|
77
|
+
await bench("all 6 weeks of a month", () => {
|
|
78
|
+
for (const week of marchWeeks) {
|
|
79
|
+
computeWeekRangeInfo(week, rangeStart, rangeEnd, T);
|
|
80
|
+
}
|
|
81
|
+
}).run();
|
|
68
82
|
});
|
|
69
83
|
});
|
|
70
84
|
|
|
71
85
|
describe("computeAdjacentMonth", () => {
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
test("next month", async ({ bench }) => {
|
|
87
|
+
await bench("next month", () => {
|
|
88
|
+
computeAdjacentMonth({ year: 2026, month: 3 }, "next", T);
|
|
89
|
+
}).run();
|
|
74
90
|
});
|
|
75
91
|
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
test("prev month", async ({ bench }) => {
|
|
93
|
+
await bench("prev month", () => {
|
|
94
|
+
computeAdjacentMonth({ year: 2026, month: 3 }, "prev", T);
|
|
95
|
+
}).run();
|
|
78
96
|
});
|
|
79
97
|
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
test("year boundary (Dec → Jan)", async ({ bench }) => {
|
|
99
|
+
await bench("year boundary (Dec → Jan)", () => {
|
|
100
|
+
computeAdjacentMonth({ year: 2026, month: 12 }, "next", T);
|
|
101
|
+
}).run();
|
|
82
102
|
});
|
|
83
103
|
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
test("year boundary (Jan → Dec)", async ({ bench }) => {
|
|
105
|
+
await bench("year boundary (Jan → Dec)", () => {
|
|
106
|
+
computeAdjacentMonth({ year: 2026, month: 1 }, "prev", T);
|
|
107
|
+
}).run();
|
|
86
108
|
});
|
|
87
109
|
});
|
|
88
110
|
|
|
89
111
|
describe("isInRange", () => {
|
|
90
112
|
const allDays = marchWeeks.flat();
|
|
91
113
|
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
test("single date check (in range)", async ({ bench }) => {
|
|
115
|
+
await bench("single date check (in range)", () => {
|
|
116
|
+
isInRange(Temporal.PlainDate.from("2026-03-10"), rangeStart, rangeEnd, T);
|
|
117
|
+
}).run();
|
|
94
118
|
});
|
|
95
119
|
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
test("single date check (out of range)", async ({ bench }) => {
|
|
121
|
+
await bench("single date check (out of range)", () => {
|
|
122
|
+
isInRange(Temporal.PlainDate.from("2026-03-25"), rangeStart, rangeEnd, T);
|
|
123
|
+
}).run();
|
|
98
124
|
});
|
|
99
125
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
126
|
+
test("check all 42 grid cells", async ({ bench }) => {
|
|
127
|
+
await bench("check all 42 grid cells", () => {
|
|
128
|
+
for (const day of allDays) {
|
|
129
|
+
isInRange(day, rangeStart, rangeEnd, T);
|
|
130
|
+
}
|
|
131
|
+
}).run();
|
|
104
132
|
});
|
|
105
133
|
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
test("undefined range (early exit)", async ({ bench }) => {
|
|
135
|
+
await bench("undefined range (early exit)", () => {
|
|
136
|
+
isInRange(Temporal.PlainDate.from("2026-03-10"), undefined, undefined, T);
|
|
137
|
+
}).run();
|
|
108
138
|
});
|
|
109
139
|
});
|
|
110
140
|
|
|
@@ -113,49 +143,65 @@ describe("toZonedDateTime / fromZonedDateTime", () => {
|
|
|
113
143
|
const plainDateTime = Temporal.PlainDateTime.from("2026-03-15T10:30:00");
|
|
114
144
|
const nativeDate = new Date(2026, 2, 15, 10, 30, 0);
|
|
115
145
|
|
|
116
|
-
|
|
117
|
-
|
|
146
|
+
test("PlainDate → ZonedDateTime", async ({ bench }) => {
|
|
147
|
+
await bench("PlainDate → ZonedDateTime", () => {
|
|
148
|
+
toZonedDateTime({ format: "PlainDate", value: plainDate }, timeZone, T);
|
|
149
|
+
}).run();
|
|
118
150
|
});
|
|
119
151
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
152
|
+
test("PlainDateTime → ZonedDateTime", async ({ bench }) => {
|
|
153
|
+
await bench("PlainDateTime → ZonedDateTime", () => {
|
|
154
|
+
toZonedDateTime(
|
|
155
|
+
{ format: "PlainDateTime", value: plainDateTime },
|
|
156
|
+
timeZone,
|
|
157
|
+
T,
|
|
158
|
+
);
|
|
159
|
+
}).run();
|
|
126
160
|
});
|
|
127
161
|
|
|
128
|
-
|
|
129
|
-
|
|
162
|
+
test("Date → ZonedDateTime", async ({ bench }) => {
|
|
163
|
+
await bench("Date → ZonedDateTime", () => {
|
|
164
|
+
toZonedDateTime({ format: "Date", value: nativeDate }, timeZone, T);
|
|
165
|
+
}).run();
|
|
130
166
|
});
|
|
131
167
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
168
|
+
test("ZonedDateTime → PlainDate", async ({ bench }) => {
|
|
169
|
+
await bench("ZonedDateTime → PlainDate", () => {
|
|
170
|
+
const zdt = plainDate.toZonedDateTime(timeZone);
|
|
171
|
+
fromZonedDateTime(zdt, "PlainDate", T);
|
|
172
|
+
}).run();
|
|
135
173
|
});
|
|
136
174
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
175
|
+
test("ZonedDateTime → object", async ({ bench }) => {
|
|
176
|
+
await bench("ZonedDateTime → object", () => {
|
|
177
|
+
const zdt = plainDate.toZonedDateTime(timeZone);
|
|
178
|
+
fromZonedDateTime(zdt, "object", T);
|
|
179
|
+
}).run();
|
|
140
180
|
});
|
|
141
181
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
182
|
+
test("round-trip PlainDate → ZDT → PlainDate", async ({ bench }) => {
|
|
183
|
+
await bench("round-trip PlainDate → ZDT → PlainDate", () => {
|
|
184
|
+
const zdt = toZonedDateTime(
|
|
185
|
+
{ format: "PlainDate", value: plainDate },
|
|
186
|
+
timeZone,
|
|
187
|
+
T,
|
|
188
|
+
);
|
|
189
|
+
fromZonedDateTime(zdt, "PlainDate", T);
|
|
190
|
+
}).run();
|
|
149
191
|
});
|
|
150
192
|
});
|
|
151
193
|
|
|
152
194
|
describe("getWeekdayNames", () => {
|
|
153
|
-
|
|
154
|
-
|
|
195
|
+
test("en-US locale (7× toLocaleString)", async ({ bench }) => {
|
|
196
|
+
await bench("en-US locale (7× toLocaleString)", () => {
|
|
197
|
+
getWeekdayNames("en-US", T);
|
|
198
|
+
}).run();
|
|
155
199
|
});
|
|
156
200
|
|
|
157
|
-
|
|
158
|
-
|
|
201
|
+
test("de-DE locale", async ({ bench }) => {
|
|
202
|
+
await bench("de-DE locale", () => {
|
|
203
|
+
getWeekdayNames("de-DE", T);
|
|
204
|
+
}).run();
|
|
159
205
|
});
|
|
160
206
|
});
|
|
161
207
|
|
|
@@ -165,43 +211,49 @@ describe("resolveFocusTarget", () => {
|
|
|
165
211
|
const currentMonth = { year: 2026, month: 3 };
|
|
166
212
|
const noDisabled = () => false;
|
|
167
213
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
214
|
+
test("focused date in grid (fast path)", async ({ bench }) => {
|
|
215
|
+
await bench("focused date in grid (fast path)", () => {
|
|
216
|
+
resolveFocusTarget(
|
|
217
|
+
focusedDate,
|
|
218
|
+
selectedDate,
|
|
219
|
+
marchWeeks,
|
|
220
|
+
currentMonth,
|
|
221
|
+
noDisabled,
|
|
222
|
+
T,
|
|
223
|
+
true,
|
|
224
|
+
);
|
|
225
|
+
}).run();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test("selected date fallback", async ({ bench }) => {
|
|
229
|
+
await bench("selected date fallback", () => {
|
|
230
|
+
// Focus a date outside the grid to force fallback to selectedDate
|
|
231
|
+
const outsideFocus = Temporal.PlainDate.from("2026-05-01");
|
|
232
|
+
resolveFocusTarget(
|
|
233
|
+
outsideFocus,
|
|
234
|
+
selectedDate,
|
|
235
|
+
marchWeeks,
|
|
236
|
+
currentMonth,
|
|
237
|
+
noDisabled,
|
|
238
|
+
T,
|
|
239
|
+
true,
|
|
240
|
+
);
|
|
241
|
+
}).run();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("no match — linear scan to first enabled", async ({ bench }) => {
|
|
245
|
+
await bench("no match — linear scan to first enabled", () => {
|
|
246
|
+
const outsideFocus = Temporal.PlainDate.from("2026-05-01");
|
|
247
|
+
const outsideSelected = Temporal.PlainDate.from("2026-05-15");
|
|
248
|
+
resolveFocusTarget(
|
|
249
|
+
outsideFocus,
|
|
250
|
+
outsideSelected,
|
|
251
|
+
marchWeeks,
|
|
252
|
+
currentMonth,
|
|
253
|
+
noDisabled,
|
|
254
|
+
T,
|
|
255
|
+
true,
|
|
256
|
+
);
|
|
257
|
+
}).run();
|
|
206
258
|
});
|
|
207
259
|
});
|
package/src/utils.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import { describe, it, expect } from "
|
|
2
|
+
import { describe, it, expect } from "vite-plus/test";
|
|
3
3
|
import { temporalVariants } from "./test-temporal";
|
|
4
4
|
import type { TemporalNamespace } from "./types";
|
|
5
5
|
import {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
|
-
import { describe, expect, it } from "
|
|
5
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
6
6
|
import {
|
|
7
7
|
DayButton,
|
|
8
8
|
DayCellTemplate,
|
package/src/weeks-view.test.tsx
CHANGED
package/src/weeks-window.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
-
import { describe, it, expect } from "
|
|
2
|
+
import { describe, it, expect } from "vite-plus/test";
|
|
3
3
|
import type { OutOfRangeBehavior } from "./out-of-range";
|
|
4
4
|
import { createWeekWindowPolicy } from "./weeks-window";
|
|
5
5
|
|