@klinking/colander 0.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formats/date.cjs +51 -48
- package/dist/formats/date.d.cts +10 -37
- package/dist/formats/date.d.mts +10 -37
- package/dist/formats/date.mjs +6 -2
- package/dist/formats/object.cjs +51 -48
- package/dist/formats/object.d.cts +10 -37
- package/dist/formats/object.d.mts +10 -37
- package/dist/formats/object.mjs +6 -2
- package/dist/formats/plain-date-time.cjs +51 -48
- package/dist/formats/plain-date-time.d.cts +10 -37
- package/dist/formats/plain-date-time.d.mts +10 -37
- package/dist/formats/plain-date-time.mjs +6 -2
- package/dist/formats/plain-date.cjs +51 -48
- package/dist/formats/plain-date.d.cts +10 -37
- package/dist/formats/plain-date.d.mts +10 -37
- package/dist/formats/plain-date.mjs +6 -2
- package/dist/formats/plain-month-day.cjs +51 -48
- package/dist/formats/plain-month-day.d.cts +10 -37
- package/dist/formats/plain-month-day.d.mts +10 -37
- package/dist/formats/plain-month-day.mjs +6 -2
- package/dist/formats/plain-year-month.cjs +51 -48
- package/dist/formats/plain-year-month.d.cts +10 -37
- package/dist/formats/plain-year-month.d.mts +10 -37
- package/dist/formats/plain-year-month.mjs +6 -2
- package/dist/formats/zoned-date-time.cjs +51 -48
- package/dist/formats/zoned-date-time.d.cts +10 -37
- package/dist/formats/zoned-date-time.d.mts +10 -37
- package/dist/formats/zoned-date-time.mjs +6 -2
- package/dist/index.cjs +47 -48
- package/dist/index.d.cts +11 -2
- package/dist/index.d.mts +11 -2
- package/dist/index.mjs +2 -2
- package/dist/{temporal-polyfill-DU8VfleL.cjs → weeks-navigation-CtbaTTmA.cjs} +329 -567
- package/dist/{temporal-polyfill-DTx0VIX5.mjs → weeks-navigation-D5GjCwNm.mjs} +329 -561
- package/dist/{weeks-view-context-BN6qR-83.d.mts → weeks-view-context-BZeWx9N8.d.cts} +275 -258
- package/dist/{weeks-view-context-aHGgYkpt.d.cts → weeks-view-context-MVe1b-BS.d.mts} +275 -258
- package/package.json +20 -20
- package/src/calendar-context.ts +12 -5
- package/src/calendar-provider.test.tsx +18 -4
- package/src/calendar-provider.tsx +130 -35
- package/src/calendar-types.ts +21 -4
- package/src/compute-weeks-in-window.test.ts +9 -7
- package/src/context.ts +1 -1
- package/src/day-cell.tsx +92 -46
- package/src/drag-handle.tsx +23 -24
- package/src/formats/date.ts +120 -56
- package/src/formats/formats.test.ts +8 -4
- package/src/formats/object.ts +120 -56
- package/src/formats/plain-date-time.ts +120 -56
- package/src/formats/plain-date.ts +120 -56
- package/src/formats/plain-month-day.ts +120 -56
- package/src/formats/plain-year-month.ts +120 -56
- package/src/formats/zoned-date-time.ts +120 -56
- package/src/grid-header.tsx +24 -18
- package/src/grid.event-perf.test.tsx +30 -13
- package/src/grid.perf.test.tsx +97 -33
- package/src/grid.tsx +75 -43
- package/src/index.ts +16 -4
- package/src/keyboard.test.ts +110 -42
- package/src/keyboard.ts +18 -7
- package/src/month-separator.test.tsx +3 -1
- package/src/month-separator.tsx +30 -9
- package/src/month-view-context.ts +8 -3
- package/src/month-view-types.ts +14 -10
- package/src/month-view.test.tsx +687 -68
- package/src/month-view.tsx +176 -71
- package/src/navigation.tsx +77 -47
- package/src/overflow.test.ts +15 -13
- package/src/overflow.ts +10 -2
- package/src/range-preview.tsx +37 -12
- package/src/resolve-first-week.test.ts +14 -10
- package/src/resolve-first-week.ts +6 -2
- package/src/root-selection.ts +185 -101
- package/src/selected-range.tsx +47 -22
- package/src/test-temporal.ts +0 -2
- package/src/types.ts +126 -103
- package/src/utils.bench.ts +30 -6
- package/src/utils.test.ts +203 -55
- package/src/utils.ts +156 -54
- package/src/view-context.ts +4 -1
- package/src/week-number.tsx +5 -8
- package/src/weeks-grid.tsx +45 -19
- package/src/weeks-keyboard.test.ts +6 -7
- package/src/weeks-keyboard.ts +8 -3
- package/src/weeks-navigation.tsx +21 -9
- package/src/weeks-view-context.ts +8 -3
- package/src/weeks-view-state.ts +100 -33
- package/src/weeks-view-types.ts +14 -8
- package/src/weeks-view.test.tsx +127 -19
- package/src/weeks-view.tsx +30 -12
- package/src/temporal-polyfill.test.ts +0 -317
- package/src/temporal-polyfill.ts +0 -566
package/src/month-separator.tsx
CHANGED
|
@@ -37,7 +37,8 @@ export type MonthSeparatorState = {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
/** Context providing MonthSeparator data to child components. */
|
|
40
|
-
export const MonthSeparatorDataContext =
|
|
40
|
+
export const MonthSeparatorDataContext =
|
|
41
|
+
createContext<MonthSeparatorState | null>(null);
|
|
41
42
|
|
|
42
43
|
function useMonthSeparatorData(): MonthSeparatorState {
|
|
43
44
|
const ctx = useContext(MonthSeparatorDataContext);
|
|
@@ -58,7 +59,8 @@ const stateAttributesMapping = {
|
|
|
58
59
|
weeksVisibleAfter: () => null,
|
|
59
60
|
firstDayColumn: (v: number) => ({ "data-first-day-column": String(v) }),
|
|
60
61
|
totalColumns: (v: number) => ({ "data-total-columns": String(v) }),
|
|
61
|
-
firstDayVisible: (v: boolean) =>
|
|
62
|
+
firstDayVisible: (v: boolean) =>
|
|
63
|
+
v ? { "data-first-day-visible": "" } : null,
|
|
62
64
|
fullWeeksVisibleAfter: (v: number) => ({
|
|
63
65
|
"data-full-weeks-visible-after": String(v),
|
|
64
66
|
}),
|
|
@@ -74,7 +76,10 @@ type MonthChildProps = useRender.ComponentProps<"span", MonthSeparatorState> & {
|
|
|
74
76
|
format?: "long" | "short" | "narrow";
|
|
75
77
|
};
|
|
76
78
|
|
|
77
|
-
function MonthSeparatorMonthFn(
|
|
79
|
+
function MonthSeparatorMonthFn(
|
|
80
|
+
props: MonthChildProps,
|
|
81
|
+
ref: React.ForwardedRef<HTMLSpanElement>,
|
|
82
|
+
) {
|
|
78
83
|
const { render, locale = "en-US", format = "long", ...otherProps } = props;
|
|
79
84
|
const data = useMonthSeparatorData();
|
|
80
85
|
|
|
@@ -99,7 +104,10 @@ const MonthSeparatorMonth = forwardRef(MonthSeparatorMonthFn);
|
|
|
99
104
|
|
|
100
105
|
type YearChildProps = useRender.ComponentProps<"span", MonthSeparatorState>;
|
|
101
106
|
|
|
102
|
-
function MonthSeparatorYearFn(
|
|
107
|
+
function MonthSeparatorYearFn(
|
|
108
|
+
props: YearChildProps,
|
|
109
|
+
ref: React.ForwardedRef<HTMLSpanElement>,
|
|
110
|
+
) {
|
|
103
111
|
const { render, ...otherProps } = props;
|
|
104
112
|
const data = useMonthSeparatorData();
|
|
105
113
|
|
|
@@ -117,7 +125,10 @@ const MonthSeparatorYear = forwardRef(MonthSeparatorYearFn);
|
|
|
117
125
|
|
|
118
126
|
// ─── Child: WeekCount ────────────────────────────────────────────────
|
|
119
127
|
|
|
120
|
-
type WeekCountChildProps = useRender.ComponentProps<
|
|
128
|
+
type WeekCountChildProps = useRender.ComponentProps<
|
|
129
|
+
"span",
|
|
130
|
+
MonthSeparatorState
|
|
131
|
+
>;
|
|
121
132
|
|
|
122
133
|
function MonthSeparatorWeekCountFn(
|
|
123
134
|
props: WeekCountChildProps,
|
|
@@ -140,7 +151,10 @@ const MonthSeparatorWeekCount = forwardRef(MonthSeparatorWeekCountFn);
|
|
|
140
151
|
|
|
141
152
|
// ─── MonthSeparatorRow ──────────────────────────────────────────────
|
|
142
153
|
|
|
143
|
-
type MonthSeparatorRowProps = useRender.ComponentProps<
|
|
154
|
+
type MonthSeparatorRowProps = useRender.ComponentProps<
|
|
155
|
+
"tr",
|
|
156
|
+
MonthSeparatorState
|
|
157
|
+
>;
|
|
144
158
|
|
|
145
159
|
function MonthSeparatorRowFn(
|
|
146
160
|
props: MonthSeparatorRowProps,
|
|
@@ -159,7 +173,9 @@ function MonthSeparatorRowFn(
|
|
|
159
173
|
});
|
|
160
174
|
|
|
161
175
|
return (
|
|
162
|
-
<MonthSeparatorDataContext.Provider value={data}>
|
|
176
|
+
<MonthSeparatorDataContext.Provider value={data}>
|
|
177
|
+
{rendered}
|
|
178
|
+
</MonthSeparatorDataContext.Provider>
|
|
163
179
|
);
|
|
164
180
|
}
|
|
165
181
|
|
|
@@ -168,7 +184,10 @@ export const MonthSeparatorRow = forwardRef(MonthSeparatorRowFn);
|
|
|
168
184
|
|
|
169
185
|
// ─── MonthSeparatorCell ─────────────────────────────────────────────
|
|
170
186
|
|
|
171
|
-
type MonthSeparatorCellProps = useRender.ComponentProps<
|
|
187
|
+
type MonthSeparatorCellProps = useRender.ComponentProps<
|
|
188
|
+
"td",
|
|
189
|
+
MonthSeparatorState
|
|
190
|
+
>;
|
|
172
191
|
|
|
173
192
|
function MonthSeparatorCellFn(
|
|
174
193
|
props: MonthSeparatorCellProps,
|
|
@@ -224,7 +243,9 @@ function MonthSeparatorFn(
|
|
|
224
243
|
});
|
|
225
244
|
|
|
226
245
|
return (
|
|
227
|
-
<MonthSeparatorDataContext.Provider value={data}>
|
|
246
|
+
<MonthSeparatorDataContext.Provider value={data}>
|
|
247
|
+
{rendered}
|
|
248
|
+
</MonthSeparatorDataContext.Provider>
|
|
228
249
|
);
|
|
229
250
|
}
|
|
230
251
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
MonthViewStableContextValue,
|
|
4
|
+
MonthViewStateContextValue,
|
|
5
|
+
} from "./month-view-types";
|
|
3
6
|
|
|
4
7
|
/** @internal React context for MonthView stable values (config + callbacks). */
|
|
5
|
-
export const MonthViewStableContext =
|
|
8
|
+
export const MonthViewStableContext =
|
|
9
|
+
createContext<MonthViewStableContextValue | null>(null);
|
|
6
10
|
|
|
7
11
|
/** @internal React context for MonthView volatile state. */
|
|
8
|
-
export const MonthViewStateContext =
|
|
12
|
+
export const MonthViewStateContext =
|
|
13
|
+
createContext<MonthViewStateContextValue | null>(null);
|
|
9
14
|
|
|
10
15
|
/** Returns the MonthView stable context (config + callbacks). */
|
|
11
16
|
export function useMonthViewStable(): MonthViewStableContextValue {
|
package/src/month-view-types.ts
CHANGED
|
@@ -12,40 +12,44 @@ export interface MonthViewRootProps {
|
|
|
12
12
|
* Number of months to display simultaneously (1–12).
|
|
13
13
|
* @default 1
|
|
14
14
|
*/
|
|
15
|
-
numberOfMonths?: number;
|
|
15
|
+
numberOfMonths?: number | undefined;
|
|
16
16
|
/**
|
|
17
17
|
* When `true`, always render 6 week rows per month grid.
|
|
18
18
|
* Prevents layout shifts when navigating between months.
|
|
19
19
|
* @default false
|
|
20
20
|
*/
|
|
21
|
-
fixedWeeks?: boolean;
|
|
21
|
+
fixedWeeks?: boolean | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* Controls how days from adjacent months are displayed.
|
|
24
24
|
* @default "enabled"
|
|
25
25
|
*/
|
|
26
|
-
outsideDays?: OutsideDays;
|
|
26
|
+
outsideDays?: OutsideDays | undefined;
|
|
27
27
|
/**
|
|
28
28
|
* How month navigation behaves at `min`/`max` bounds.
|
|
29
29
|
* - `"unbounded"` — navigation is always allowed.
|
|
30
30
|
* - `"stop"` — navigation buttons disable at the boundary.
|
|
31
31
|
* @default "unbounded"
|
|
32
32
|
*/
|
|
33
|
-
overflowBehavior?: MonthOverflowBehavior;
|
|
33
|
+
overflowBehavior?: MonthOverflowBehavior | undefined;
|
|
34
34
|
/**
|
|
35
35
|
* The controlled visible month. When provided, the component is controlled.
|
|
36
|
+
*
|
|
37
|
+
* Interpreted in the ISO calendar (the year/month are read as ISO values).
|
|
38
|
+
* The `locale` only affects how the month is displayed, so this value
|
|
39
|
+
* round-trips directly with {@link onMonthChange}.
|
|
36
40
|
*/
|
|
37
|
-
month?: Temporal.PlainYearMonth;
|
|
41
|
+
month?: Temporal.PlainYearMonth | undefined;
|
|
38
42
|
/**
|
|
39
|
-
* The initial visible month (uncontrolled).
|
|
43
|
+
* The initial visible month (uncontrolled). Interpreted in the ISO calendar.
|
|
40
44
|
*/
|
|
41
|
-
defaultMonth?: Temporal.PlainYearMonth;
|
|
45
|
+
defaultMonth?: Temporal.PlainYearMonth | undefined;
|
|
42
46
|
/**
|
|
43
47
|
* Called when the visible month changes via navigation or focus movement.
|
|
44
|
-
* Not called on initial mount.
|
|
48
|
+
* Not called on initial mount. The argument is an ISO `PlainYearMonth`.
|
|
45
49
|
*/
|
|
46
|
-
onMonthChange?: (month: Temporal.PlainYearMonth) => void;
|
|
50
|
+
onMonthChange?: ((month: Temporal.PlainYearMonth) => void) | undefined;
|
|
47
51
|
/** React children. */
|
|
48
|
-
children?: React.ReactNode;
|
|
52
|
+
children?: React.ReactNode | undefined;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
// ---------------------------------------------------------------------------
|