@overdoser/react-toolkit 0.15.0 → 0.17.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 (41) hide show
  1. package/AGENTS.md +2 -0
  2. package/CHANGELOG.md +87 -0
  3. package/components/Chart/AreaChart.d.ts +5 -1
  4. package/components/Chart/AreaChart.js +155 -144
  5. package/components/Chart/BarChart.js +5 -5
  6. package/components/Chart/PieChart.js +2 -5
  7. package/components/Chart/RadarChart.js +2 -5
  8. package/components/Chart/TradingChart.js +258 -257
  9. package/components/Drawer/Drawer.js +69 -70
  10. package/components/Dropdown/Dropdown.js +51 -56
  11. package/components/Modal/Modal.js +42 -47
  12. package/components/Popover/Popover.js +52 -55
  13. package/components/SplitButton/SplitButton.js +50 -55
  14. package/components/inputs/DatePicker/CalendarPanel.d.ts +40 -0
  15. package/components/inputs/DatePicker/CalendarPanel.js +287 -0
  16. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +41 -0
  17. package/components/inputs/DatePicker/DatePicker.d.ts +3 -1
  18. package/components/inputs/DatePicker/DatePicker.js +105 -192
  19. package/components/inputs/DatePicker/DatePicker.module.scss.js +20 -40
  20. package/components/inputs/DateTimePicker/DateTimePicker.d.ts +141 -0
  21. package/components/inputs/DateTimePicker/DateTimePicker.js +232 -0
  22. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +37 -0
  23. package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +48 -0
  24. package/components/inputs/DateTimePicker/DateTimeSegments.js +252 -0
  25. package/components/inputs/DateTimePicker/TimeField.d.ts +18 -0
  26. package/components/inputs/DateTimePicker/TimeField.js +135 -0
  27. package/components/inputs/DateTimePicker/index.d.ts +3 -0
  28. package/components/inputs/DateTimePicker/timeZoneUtils.d.ts +44 -0
  29. package/components/inputs/DateTimePicker/timeZoneUtils.js +102 -0
  30. package/components/inputs/NumberInput/NumberInput.js +79 -81
  31. package/components/inputs/Select/Select.d.ts +5 -0
  32. package/components/inputs/Select/Select.js +340 -285
  33. package/hooks/useEscapeLayer.d.ts +36 -0
  34. package/hooks/useEscapeLayer.js +33 -0
  35. package/index.css +1 -1
  36. package/index.d.ts +2 -0
  37. package/index.js +108 -106
  38. package/index.layered.css +1 -1
  39. package/llms.txt +29 -4
  40. package/manifest.json +127 -1
  41. package/package.json +1 -1
@@ -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()} />