@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.
Files changed (92) hide show
  1. package/dist/formats/date.cjs +51 -48
  2. package/dist/formats/date.d.cts +10 -37
  3. package/dist/formats/date.d.mts +10 -37
  4. package/dist/formats/date.mjs +6 -2
  5. package/dist/formats/object.cjs +51 -48
  6. package/dist/formats/object.d.cts +10 -37
  7. package/dist/formats/object.d.mts +10 -37
  8. package/dist/formats/object.mjs +6 -2
  9. package/dist/formats/plain-date-time.cjs +51 -48
  10. package/dist/formats/plain-date-time.d.cts +10 -37
  11. package/dist/formats/plain-date-time.d.mts +10 -37
  12. package/dist/formats/plain-date-time.mjs +6 -2
  13. package/dist/formats/plain-date.cjs +51 -48
  14. package/dist/formats/plain-date.d.cts +10 -37
  15. package/dist/formats/plain-date.d.mts +10 -37
  16. package/dist/formats/plain-date.mjs +6 -2
  17. package/dist/formats/plain-month-day.cjs +51 -48
  18. package/dist/formats/plain-month-day.d.cts +10 -37
  19. package/dist/formats/plain-month-day.d.mts +10 -37
  20. package/dist/formats/plain-month-day.mjs +6 -2
  21. package/dist/formats/plain-year-month.cjs +51 -48
  22. package/dist/formats/plain-year-month.d.cts +10 -37
  23. package/dist/formats/plain-year-month.d.mts +10 -37
  24. package/dist/formats/plain-year-month.mjs +6 -2
  25. package/dist/formats/zoned-date-time.cjs +51 -48
  26. package/dist/formats/zoned-date-time.d.cts +10 -37
  27. package/dist/formats/zoned-date-time.d.mts +10 -37
  28. package/dist/formats/zoned-date-time.mjs +6 -2
  29. package/dist/index.cjs +47 -48
  30. package/dist/index.d.cts +11 -2
  31. package/dist/index.d.mts +11 -2
  32. package/dist/index.mjs +2 -2
  33. package/dist/{temporal-polyfill-DU8VfleL.cjs → weeks-navigation-CtbaTTmA.cjs} +329 -567
  34. package/dist/{temporal-polyfill-DTx0VIX5.mjs → weeks-navigation-D5GjCwNm.mjs} +329 -561
  35. package/dist/{weeks-view-context-BN6qR-83.d.mts → weeks-view-context-BZeWx9N8.d.cts} +275 -258
  36. package/dist/{weeks-view-context-aHGgYkpt.d.cts → weeks-view-context-MVe1b-BS.d.mts} +275 -258
  37. package/package.json +20 -20
  38. package/src/calendar-context.ts +12 -5
  39. package/src/calendar-provider.test.tsx +18 -4
  40. package/src/calendar-provider.tsx +130 -35
  41. package/src/calendar-types.ts +21 -4
  42. package/src/compute-weeks-in-window.test.ts +9 -7
  43. package/src/context.ts +1 -1
  44. package/src/day-cell.tsx +92 -46
  45. package/src/drag-handle.tsx +23 -24
  46. package/src/formats/date.ts +120 -56
  47. package/src/formats/formats.test.ts +8 -4
  48. package/src/formats/object.ts +120 -56
  49. package/src/formats/plain-date-time.ts +120 -56
  50. package/src/formats/plain-date.ts +120 -56
  51. package/src/formats/plain-month-day.ts +120 -56
  52. package/src/formats/plain-year-month.ts +120 -56
  53. package/src/formats/zoned-date-time.ts +120 -56
  54. package/src/grid-header.tsx +24 -18
  55. package/src/grid.event-perf.test.tsx +30 -13
  56. package/src/grid.perf.test.tsx +97 -33
  57. package/src/grid.tsx +75 -43
  58. package/src/index.ts +16 -4
  59. package/src/keyboard.test.ts +110 -42
  60. package/src/keyboard.ts +18 -7
  61. package/src/month-separator.test.tsx +3 -1
  62. package/src/month-separator.tsx +30 -9
  63. package/src/month-view-context.ts +8 -3
  64. package/src/month-view-types.ts +14 -10
  65. package/src/month-view.test.tsx +687 -68
  66. package/src/month-view.tsx +176 -71
  67. package/src/navigation.tsx +77 -47
  68. package/src/overflow.test.ts +15 -13
  69. package/src/overflow.ts +10 -2
  70. package/src/range-preview.tsx +37 -12
  71. package/src/resolve-first-week.test.ts +14 -10
  72. package/src/resolve-first-week.ts +6 -2
  73. package/src/root-selection.ts +185 -101
  74. package/src/selected-range.tsx +47 -22
  75. package/src/test-temporal.ts +0 -2
  76. package/src/types.ts +126 -103
  77. package/src/utils.bench.ts +30 -6
  78. package/src/utils.test.ts +203 -55
  79. package/src/utils.ts +156 -54
  80. package/src/view-context.ts +4 -1
  81. package/src/week-number.tsx +5 -8
  82. package/src/weeks-grid.tsx +45 -19
  83. package/src/weeks-keyboard.test.ts +6 -7
  84. package/src/weeks-keyboard.ts +8 -3
  85. package/src/weeks-navigation.tsx +21 -9
  86. package/src/weeks-view-context.ts +8 -3
  87. package/src/weeks-view-state.ts +100 -33
  88. package/src/weeks-view-types.ts +14 -8
  89. package/src/weeks-view.test.tsx +127 -19
  90. package/src/weeks-view.tsx +30 -12
  91. package/src/temporal-polyfill.test.ts +0 -317
  92. package/src/temporal-polyfill.ts +0 -566
@@ -37,7 +37,8 @@ export type MonthSeparatorState = {
37
37
  };
38
38
 
39
39
  /** Context providing MonthSeparator data to child components. */
40
- export const MonthSeparatorDataContext = createContext<MonthSeparatorState | null>(null);
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) => (v ? { "data-first-day-visible": "" } : null),
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(props: MonthChildProps, ref: React.ForwardedRef<HTMLSpanElement>) {
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(props: YearChildProps, ref: React.ForwardedRef<HTMLSpanElement>) {
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<"span", MonthSeparatorState>;
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<"tr", MonthSeparatorState>;
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}>{rendered}</MonthSeparatorDataContext.Provider>
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<"td", MonthSeparatorState>;
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}>{rendered}</MonthSeparatorDataContext.Provider>
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 { MonthViewStableContextValue, MonthViewStateContextValue } from "./month-view-types";
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 = createContext<MonthViewStableContextValue | null>(null);
8
+ export const MonthViewStableContext =
9
+ createContext<MonthViewStableContextValue | null>(null);
6
10
 
7
11
  /** @internal React context for MonthView volatile state. */
8
- export const MonthViewStateContext = createContext<MonthViewStateContextValue | null>(null);
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 {
@@ -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
  // ---------------------------------------------------------------------------