@overdoser/react-toolkit 0.14.0 → 0.16.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 (32) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +64 -0
  3. package/components/Button/Button.js +8 -8
  4. package/components/Button/Button.module.scss.js +9 -9
  5. package/components/Dropdown/Dropdown.js +40 -36
  6. package/components/SplitButton/SplitButton.d.ts +88 -0
  7. package/components/SplitButton/SplitButton.js +201 -0
  8. package/components/SplitButton/SplitButton.module.scss.js +57 -0
  9. package/components/SplitButton/index.d.ts +2 -0
  10. package/components/inputs/DatePicker/CalendarPanel.d.ts +40 -0
  11. package/components/inputs/DatePicker/CalendarPanel.js +287 -0
  12. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +41 -0
  13. package/components/inputs/DatePicker/DatePicker.d.ts +3 -1
  14. package/components/inputs/DatePicker/DatePicker.js +93 -186
  15. package/components/inputs/DatePicker/DatePicker.module.scss.js +20 -40
  16. package/components/inputs/DateTimePicker/DateTimePicker.d.ts +141 -0
  17. package/components/inputs/DateTimePicker/DateTimePicker.js +230 -0
  18. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +37 -0
  19. package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +47 -0
  20. package/components/inputs/DateTimePicker/DateTimeSegments.js +252 -0
  21. package/components/inputs/DateTimePicker/TimeField.d.ts +18 -0
  22. package/components/inputs/DateTimePicker/TimeField.js +135 -0
  23. package/components/inputs/DateTimePicker/index.d.ts +3 -0
  24. package/components/inputs/DateTimePicker/timeZoneUtils.d.ts +44 -0
  25. package/components/inputs/DateTimePicker/timeZoneUtils.js +102 -0
  26. package/index.css +1 -1
  27. package/index.d.ts +4 -0
  28. package/index.js +110 -106
  29. package/index.layered.css +1 -1
  30. package/llms.txt +68 -2
  31. package/manifest.json +210 -1
  32. package/package.json +1 -1
@@ -0,0 +1,57 @@
1
+ const n = "crk-root-WQNOC", e = "crk-group-vpjIZ", t = "crk-main-rC6D1", i = "crk-mainContent-ztmsF", c = "crk-mainLabel-nGrtw", r = "crk-sizer-PLveG", o = "crk-sizerItem-dwWwd", m = "crk-mainAttached-AhE-l", s = "crk-toggle-yVTi-", a = "crk-mainOpen-7hEXl", l = "crk-toggleOpen-56O29", g = "crk-dividerOnFill-HLKeu", k = "crk-dividerSubtle-g-TfH", u = "crk-overlapOutline-yWbkD", d = "crk-chevron-4zed5", O = "crk-chevronOpen-7vOPn", p = "crk-menu-2ijiM", v = "crk-menuOpen-hANn0", h = "crk-menuSm-WBQSi", L = "crk-menuMd-xjRTT", b = "crk-menuLg-rXDWh", D = "crk-alignLeft-aXK9A", z = "crk-alignRight-ANsBn", A = "crk-item-rolo0", S = "crk-itemDisabled-A7T-8", f = "crk-itemDanger-g19Qe", C = {
2
+ root: n,
3
+ group: e,
4
+ main: t,
5
+ mainContent: i,
6
+ mainLabel: c,
7
+ sizer: r,
8
+ sizerItem: o,
9
+ mainAttached: m,
10
+ toggle: s,
11
+ mainOpen: a,
12
+ toggleOpen: l,
13
+ dividerOnFill: g,
14
+ dividerSubtle: k,
15
+ overlapOutline: u,
16
+ chevron: d,
17
+ chevronOpen: O,
18
+ menu: p,
19
+ menuOpen: v,
20
+ menuSm: h,
21
+ menuMd: L,
22
+ menuLg: b,
23
+ alignLeft: D,
24
+ alignRight: z,
25
+ item: A,
26
+ itemDisabled: S,
27
+ itemDanger: f
28
+ };
29
+ export {
30
+ D as alignLeft,
31
+ z as alignRight,
32
+ d as chevron,
33
+ O as chevronOpen,
34
+ C as default,
35
+ g as dividerOnFill,
36
+ k as dividerSubtle,
37
+ e as group,
38
+ A as item,
39
+ f as itemDanger,
40
+ S as itemDisabled,
41
+ t as main,
42
+ m as mainAttached,
43
+ i as mainContent,
44
+ c as mainLabel,
45
+ a as mainOpen,
46
+ p as menu,
47
+ b as menuLg,
48
+ L as menuMd,
49
+ v as menuOpen,
50
+ h as menuSm,
51
+ u as overlapOutline,
52
+ n as root,
53
+ r as sizer,
54
+ o as sizerItem,
55
+ s as toggle,
56
+ l as toggleOpen
57
+ };
@@ -0,0 +1,2 @@
1
+ export { SplitButton } from './SplitButton';
2
+ export type { SplitButtonProps, SplitButtonClasses, SplitButtonAction } from './SplitButton';
@@ -0,0 +1,40 @@
1
+ export interface CalendarPanelClasses {
2
+ header: string;
3
+ nav: string;
4
+ grid: string;
5
+ day: string;
6
+ daySelected: string;
7
+ dayToday: string;
8
+ dayOutside: string;
9
+ }
10
+ export interface CalendarPanelProps {
11
+ /** Month currently shown (any day within it). */
12
+ viewDate: Date;
13
+ /** Day holding roving focus; receives DOM focus on mount and whenever it changes. */
14
+ focusedDate: Date;
15
+ /** Selected day (day granularity, local midnight). */
16
+ selected: Date | null;
17
+ /** The day to mark as "today". */
18
+ today: Date;
19
+ /** Earliest / latest selectable day — gates the month and year pickers. */
20
+ minDay?: Date;
21
+ maxDay?: Date;
22
+ locale?: string;
23
+ weekStartsOn: number;
24
+ isDisabledDay: (date: Date) => boolean;
25
+ onSelect: (date: Date) => void;
26
+ onViewDateChange: (date: Date) => void;
27
+ onFocusedDateChange: (date: Date) => void;
28
+ /** Escape pressed while in the day grid. */
29
+ onEscape: () => void;
30
+ classes?: Partial<CalendarPanelClasses>;
31
+ }
32
+ /**
33
+ * Internal calendar shared by `DatePicker` and `DateTimePicker`. Owns the
34
+ * header (month / year buttons that open a month grid or a scrollable year
35
+ * grid), the weekday row, and the roving-focus keyboard model; the selected /
36
+ * focused / view dates live in the parent. Days are plain local-midnight
37
+ * `Date`s, so a parent that renders another time zone passes wall-clock
38
+ * proxies.
39
+ */
40
+ export declare function CalendarPanel({ viewDate, focusedDate, selected, today, minDay, maxDay, locale, weekStartsOn, isDisabledDay, onSelect, onViewDateChange, onFocusedDateChange, onEscape, classes, }: CalendarPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,287 @@
1
+ import { jsxs as I, Fragment as U, jsx as o } from "react/jsx-runtime";
2
+ import { useRef as $, useState as q, useMemo as b, useEffect as le } from "react";
3
+ import m from "clsx";
4
+ import r from "./CalendarPanel.module.scss.js";
5
+ import { weekdayLabels as de, buildCalendarDays as ce, toISODate as x, isSameMonth as W, isSameDay as C, addMonths as F, startOfMonth as G, addDays as g } from "./dateUtils.js";
6
+ const z = 100, he = 3, me = 4;
7
+ function ve({
8
+ viewDate: l,
9
+ focusedDate: i,
10
+ selected: J,
11
+ today: Q,
12
+ minDay: p,
13
+ maxDay: f,
14
+ locale: d,
15
+ weekStartsOn: y,
16
+ isDisabledDay: S,
17
+ onSelect: V,
18
+ onViewDateChange: L,
19
+ onFocusedDateChange: E,
20
+ onEscape: X,
21
+ classes: u
22
+ }) {
23
+ const H = $(null), T = $(null), [c, N] = q("day"), [s, R] = q(0), h = l.getFullYear(), k = l.getMonth(), Z = b(
24
+ () => new Intl.DateTimeFormat(d, { month: "long", year: "numeric" }).format(l),
25
+ [d, l]
26
+ ), D = b(() => new Intl.DateTimeFormat(d, { month: "long" }).format(l), [d, l]), ee = b(() => new Intl.DateTimeFormat(d, { year: "numeric" }).format(l), [d, l]), te = b(() => {
27
+ const e = new Intl.DateTimeFormat(d, { month: "short" }), t = new Intl.DateTimeFormat(d, { month: "long" });
28
+ return Array.from({ length: 12 }, (a, n) => {
29
+ const A = new Date(2023, n, 1);
30
+ return { short: e.format(A), long: t.format(A) };
31
+ });
32
+ }, [d]), w = b(() => {
33
+ let e = p ? p.getFullYear() : h - z, t = f ? f.getFullYear() : h + z;
34
+ return e = Math.min(e, h), t = Math.max(t, h), Array.from({ length: t - e + 1 }, (a, n) => e + n);
35
+ }, [p, f, h]), ne = b(() => de(d, y), [d, y]), re = b(() => ce(l, y), [l, y]), ae = b(() => new Intl.DateTimeFormat(d, { dateStyle: "full" }), [d]), Y = (e) => {
36
+ const t = new Date(h, e, 1), a = new Date(h, e + 1, 0);
37
+ return !!f && t > f || !!p && a < p;
38
+ }, K = (e) => !!f && new Date(e, 0, 1) > f || !!p && new Date(e, 11, 31) < p;
39
+ le(() => {
40
+ if (c === "day") {
41
+ H.current?.querySelector(`[data-date="${x(i)}"]`)?.focus();
42
+ return;
43
+ }
44
+ const e = T.current, t = e?.querySelector("[data-active]");
45
+ e && t && (e.scrollTop = t.offsetTop - e.clientHeight / 2 + t.offsetHeight / 2, t.focus());
46
+ }, [c, i, s]);
47
+ const oe = (e) => {
48
+ E(e), W(e, l) || L(G(e));
49
+ }, P = (e) => {
50
+ S(e) || V(e);
51
+ }, _ = (e) => {
52
+ if (c === e) {
53
+ N("day");
54
+ return;
55
+ }
56
+ R(e === "month" ? k : w.indexOf(h)), N(e);
57
+ }, M = (e, t) => {
58
+ const a = new Date(e, t + 1, 0).getDate(), n = new Date(e, t, Math.min(i.getDate(), a));
59
+ E(n), L(G(n)), N("day");
60
+ }, ie = (e) => {
61
+ let t = null;
62
+ switch (e.key) {
63
+ case "ArrowLeft":
64
+ t = g(i, -1);
65
+ break;
66
+ case "ArrowRight":
67
+ t = g(i, 1);
68
+ break;
69
+ case "ArrowUp":
70
+ t = g(i, -7);
71
+ break;
72
+ case "ArrowDown":
73
+ t = g(i, 7);
74
+ break;
75
+ case "Home":
76
+ t = g(i, -((i.getDay() - y + 7) % 7));
77
+ break;
78
+ case "End":
79
+ t = g(i, 6 - (i.getDay() - y + 7) % 7);
80
+ break;
81
+ case "PageUp":
82
+ t = F(i, -1);
83
+ break;
84
+ case "PageDown":
85
+ t = F(i, 1);
86
+ break;
87
+ case "Enter":
88
+ case " ":
89
+ e.preventDefault(), P(i);
90
+ return;
91
+ case "Escape":
92
+ e.preventDefault(), X();
93
+ return;
94
+ default:
95
+ return;
96
+ }
97
+ e.preventDefault(), oe(t);
98
+ }, j = (e, t, a) => {
99
+ let n = s;
100
+ switch (e.key) {
101
+ case "ArrowLeft":
102
+ n = s - 1;
103
+ break;
104
+ case "ArrowRight":
105
+ n = s + 1;
106
+ break;
107
+ case "ArrowUp":
108
+ n = s - a;
109
+ break;
110
+ case "ArrowDown":
111
+ n = s + a;
112
+ break;
113
+ case "Home":
114
+ n = 0;
115
+ break;
116
+ case "End":
117
+ n = t - 1;
118
+ break;
119
+ case "Enter":
120
+ case " ":
121
+ e.preventDefault(), c === "month" ? Y(s) || M(h, s) : K(w[s]) || M(w[s], k);
122
+ return;
123
+ case "Escape":
124
+ e.preventDefault(), N("day");
125
+ return;
126
+ default:
127
+ return;
128
+ }
129
+ e.preventDefault(), R(Math.max(0, Math.min(t - 1, n)));
130
+ }, v = c === "year", B = c === "day" ? "month" : "year", O = (e) => L(c === "day" ? F(l, e) : new Date(h + e, k, 1));
131
+ return /* @__PURE__ */ I(U, { children: [
132
+ /* @__PURE__ */ I("div", { className: m(r.header, u?.header), children: [
133
+ /* @__PURE__ */ o(
134
+ "button",
135
+ {
136
+ type: "button",
137
+ className: m(r.nav, v && r.navHidden, u?.nav),
138
+ onClick: () => O(-1),
139
+ "aria-label": `Previous ${B}`,
140
+ "aria-hidden": v || void 0,
141
+ tabIndex: v ? -1 : void 0,
142
+ children: /* @__PURE__ */ o("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ o("path", { d: "M7 2L3 6l4 4" }) })
143
+ }
144
+ ),
145
+ /* @__PURE__ */ I("div", { className: r.title, children: [
146
+ /* @__PURE__ */ o(
147
+ "button",
148
+ {
149
+ type: "button",
150
+ className: r.titleButton,
151
+ "aria-label": "Choose month",
152
+ "aria-expanded": c === "month",
153
+ onClick: () => _("month"),
154
+ children: D
155
+ }
156
+ ),
157
+ /* @__PURE__ */ o(
158
+ "button",
159
+ {
160
+ type: "button",
161
+ className: r.titleButton,
162
+ "aria-label": "Choose year",
163
+ "aria-expanded": c === "year",
164
+ onClick: () => _("year"),
165
+ children: ee
166
+ }
167
+ ),
168
+ /* @__PURE__ */ o("span", { className: r.srOnly, "aria-live": "polite", children: Z })
169
+ ] }),
170
+ /* @__PURE__ */ o(
171
+ "button",
172
+ {
173
+ type: "button",
174
+ className: m(r.nav, v && r.navHidden, u?.nav),
175
+ onClick: () => O(1),
176
+ "aria-label": `Next ${B}`,
177
+ "aria-hidden": v || void 0,
178
+ tabIndex: v ? -1 : void 0,
179
+ children: /* @__PURE__ */ o("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ o("path", { d: "M5 2l4 4-4 4" }) })
180
+ }
181
+ )
182
+ ] }),
183
+ c === "month" && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
184
+ /* @__PURE__ */ o(
185
+ "div",
186
+ {
187
+ ref: T,
188
+ role: "listbox",
189
+ "aria-label": "Month",
190
+ className: m(r.options, r.months),
191
+ onKeyDown: (e) => j(e, 12, he),
192
+ children: te.map((e, t) => {
193
+ const a = Y(t), n = t === k;
194
+ return /* @__PURE__ */ o(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ role: "option",
199
+ "aria-selected": n,
200
+ "aria-disabled": a || void 0,
201
+ "aria-label": e.long,
202
+ tabIndex: t === s ? 0 : -1,
203
+ "data-active": t === s || void 0,
204
+ className: m(r.option, n && r.optionSelected),
205
+ onClick: () => !a && M(h, t),
206
+ children: e.short
207
+ },
208
+ t
209
+ );
210
+ })
211
+ }
212
+ ),
213
+ c === "year" && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
214
+ /* @__PURE__ */ o(
215
+ "div",
216
+ {
217
+ ref: T,
218
+ role: "listbox",
219
+ "aria-label": "Year",
220
+ className: m(r.options, r.years),
221
+ onKeyDown: (e) => j(e, w.length, me),
222
+ children: w.map((e, t) => {
223
+ const a = K(e), n = e === h;
224
+ return /* @__PURE__ */ o(
225
+ "button",
226
+ {
227
+ type: "button",
228
+ role: "option",
229
+ "aria-selected": n,
230
+ "aria-disabled": a || void 0,
231
+ tabIndex: t === s ? 0 : -1,
232
+ "data-active": t === s || void 0,
233
+ className: m(r.option, n && r.optionSelected),
234
+ onClick: () => !a && M(e, k),
235
+ children: e
236
+ },
237
+ e
238
+ );
239
+ })
240
+ }
241
+ ),
242
+ c === "day" && /* @__PURE__ */ I(U, { children: [
243
+ /* @__PURE__ */ o("div", { className: r.weekdays, "aria-hidden": "true", children: ne.map((e, t) => /* @__PURE__ */ o("span", { className: r.weekday, children: e }, t)) }),
244
+ /* @__PURE__ */ o(
245
+ "div",
246
+ {
247
+ ref: H,
248
+ role: "grid",
249
+ className: m(r.grid, u?.grid),
250
+ onKeyDown: ie,
251
+ children: re.map((e) => {
252
+ const t = !W(e, l), a = C(e, J), n = C(e, Q), A = S(e), se = C(e, i);
253
+ return /* @__PURE__ */ o(
254
+ "button",
255
+ {
256
+ type: "button",
257
+ role: "gridcell",
258
+ "data-date": x(e),
259
+ tabIndex: se ? 0 : -1,
260
+ className: m(
261
+ r.day,
262
+ t && r.dayOutside,
263
+ n && r.dayToday,
264
+ a && r.daySelected,
265
+ t && u?.dayOutside,
266
+ n && u?.dayToday,
267
+ a && u?.daySelected,
268
+ u?.day
269
+ ),
270
+ "aria-selected": a,
271
+ "aria-disabled": A || void 0,
272
+ "aria-current": n ? "date" : void 0,
273
+ "aria-label": ae.format(e),
274
+ onClick: () => P(e),
275
+ children: e.getDate()
276
+ },
277
+ x(e)
278
+ );
279
+ })
280
+ }
281
+ )
282
+ ] })
283
+ ] });
284
+ }
285
+ export {
286
+ ve as CalendarPanel
287
+ };
@@ -0,0 +1,41 @@
1
+ const t = "crk-header-T9XMb", e = "crk-nav-iAxYo", o = "crk-weekdays-TV4PD", n = "crk-grid--96pQ", c = "crk-weekday--syM1", d = "crk-day-m-HUr", s = "crk-dayOutside-x2kQk", a = "crk-dayToday-qIjS-", r = "crk-daySelected-iA4S4", y = "crk-title-68NVZ", i = "crk-titleButton-9V2YZ", k = "crk-srOnly-4nytm", l = "crk-navHidden-QhiL0", p = "crk-options-b8L5n", S = "crk-months-b-CoG", h = "crk-years-QGvpU", u = "crk-option-kbY30", v = "crk-optionSelected-as-xo", w = {
2
+ header: t,
3
+ nav: e,
4
+ weekdays: o,
5
+ grid: n,
6
+ weekday: c,
7
+ day: d,
8
+ dayOutside: s,
9
+ dayToday: a,
10
+ daySelected: r,
11
+ title: y,
12
+ titleButton: i,
13
+ srOnly: k,
14
+ navHidden: l,
15
+ options: p,
16
+ months: S,
17
+ years: h,
18
+ option: u,
19
+ optionSelected: v
20
+ };
21
+ export {
22
+ d as day,
23
+ s as dayOutside,
24
+ r as daySelected,
25
+ a as dayToday,
26
+ w as default,
27
+ n as grid,
28
+ t as header,
29
+ S as months,
30
+ e as nav,
31
+ l as navHidden,
32
+ u as option,
33
+ v as optionSelected,
34
+ p as options,
35
+ k as srOnly,
36
+ y as title,
37
+ i as titleButton,
38
+ c as weekday,
39
+ o as weekdays,
40
+ h as years
41
+ };
@@ -50,7 +50,9 @@ export interface DatePickerProps {
50
50
  /**
51
51
  * Date input with a pop-up calendar. Single date selection with full keyboard
52
52
  * support (arrows move days, PageUp/Down change month, Enter selects, Esc
53
- * closes). Binds inside `FormField` (`value: Date | null` / `onChange`).
53
+ * closes); the month and year in the header open a month grid / year list
54
+ * for long jumps. Binds inside `FormField` (`value: Date | null` / `onChange`).
55
+ * Need a time as well? Use `DateTimePicker`.
54
56
  *
55
57
  * @example
56
58
  * <DatePicker value={date} onChange={setDate} min={new Date()} />