@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
@@ -1,75 +1,72 @@
1
- import { jsx as S, jsxs as G } from "react/jsx-runtime";
2
- import { forwardRef as J, useState as E, useRef as B, useId as Q, useCallback as O, useLayoutEffect as U, useEffect as Z, isValidElement as _, cloneElement as ee } from "react";
3
- import y from "clsx";
4
- import R from "./Popover.module.scss.js";
5
- import { useClickOutside as te } from "../../hooks/useClickOutside.js";
6
- import { useKeyboard as oe } from "../../hooks/useKeyboard.js";
7
- function re(...a) {
1
+ import { jsx as y, jsxs as K } from "react/jsx-runtime";
2
+ import { forwardRef as Q, useState as E, useRef as B, useId as U, useCallback as O, useLayoutEffect as Z, useEffect as _, isValidElement as ee, cloneElement as te } from "react";
3
+ import R from "clsx";
4
+ import L from "./Popover.module.scss.js";
5
+ import { useClickOutside as oe } from "../../hooks/useClickOutside.js";
6
+ import { useEscapeLayer as re, EscapeLayerProvider as ne } from "../../hooks/useEscapeLayer.js";
7
+ function ie(...a) {
8
8
  return (h) => {
9
- for (const f of a)
10
- f && (typeof f == "function" ? f(h) : f.current = h);
9
+ for (const l of a)
10
+ l && (typeof l == "function" ? l(h) : l.current = h);
11
11
  };
12
12
  }
13
- const ne = J(
13
+ const se = Q(
14
14
  ({
15
15
  trigger: a,
16
16
  asChild: h = !1,
17
- content: f,
17
+ content: l,
18
18
  position: n = "bottom",
19
19
  autoPosition: m = !0,
20
20
  open: j,
21
21
  onOpenChange: z,
22
22
  classes: g,
23
- className: K,
24
- style: P
25
- }, T) => {
26
- const [V, W] = E(!1), [A, M] = E(n), [D, X] = E(0), [F, Y] = E(0), $ = B(null), u = B(null), v = B(null), k = Q(), C = j !== void 0, o = C ? j : V, w = O(
23
+ className: H,
24
+ style: T
25
+ }, V) => {
26
+ const [W, A] = E(!1), [D, M] = E(n), [F, P] = E(0), [G, X] = E(0), Y = B(null), u = B(null), v = B(null), k = U(), C = j !== void 0, o = C ? j : W, w = O(
27
27
  (t) => {
28
- C || W(t), z?.(t);
28
+ C || A(t), z?.(t);
29
29
  },
30
30
  [C, z]
31
- ), q = O(() => {
31
+ ), $ = O(() => {
32
32
  w(!1), v.current?.focus();
33
- }, [w]), H = O(() => {
33
+ }, [w]), q = O(() => {
34
34
  w(!o);
35
35
  }, [o, w]);
36
- te($, q, o), oe(
37
- {
38
- Escape: () => q()
39
- },
40
- o
41
- ), U(() => {
36
+ oe(Y, $, o);
37
+ const J = re($, o);
38
+ Z(() => {
42
39
  if (!o || !m) {
43
- M(n), X(0), Y(0);
40
+ M(n), P(0), X(0);
44
41
  return;
45
42
  }
46
43
  if (typeof window > "u") return;
47
44
  const t = () => {
48
45
  const b = v.current, x = u.current;
49
46
  if (!b || !x) return;
50
- const s = b.getBoundingClientRect(), i = x.getBoundingClientRect(), N = window.innerWidth, I = window.innerHeight, r = 8;
47
+ const s = b.getBoundingClientRect(), i = x.getBoundingClientRect(), I = window.innerWidth, S = window.innerHeight, r = 8;
51
48
  let c = n;
52
49
  if (n === "bottom" || n === "top") {
53
- const e = s.bottom + r + i.height <= I, p = s.top - r - i.height >= 0;
50
+ const e = s.bottom + r + i.height <= S, p = s.top - r - i.height >= 0;
54
51
  n === "bottom" && !e && p ? c = "top" : n === "top" && !p && e && (c = "bottom");
55
52
  } else {
56
- const e = s.right + r + i.width <= N, p = s.left - r - i.width >= 0;
53
+ const e = s.right + r + i.width <= I, p = s.left - r - i.width >= 0;
57
54
  n === "right" && !e && p ? c = "left" : n === "left" && !p && e && (c = "right");
58
55
  }
59
- let l = 0, d = 0;
56
+ let f = 0, d = 0;
60
57
  if (c === "bottom" || c === "top") {
61
58
  const e = s.left + s.width / 2 - i.width / 2;
62
- e < r ? l = r - e : e + i.width > N - r && (l = N - r - (e + i.width));
59
+ e < r ? f = r - e : e + i.width > I - r && (f = I - r - (e + i.width));
63
60
  } else {
64
61
  const e = s.top + s.height / 2 - i.height / 2;
65
- e < r ? d = r - e : e + i.height > I - r && (d = I - r - (e + i.height));
62
+ e < r ? d = r - e : e + i.height > S - r && (d = S - r - (e + i.height));
66
63
  }
67
- l = Math.round(l), d = Math.round(d), M((e) => e === c ? e : c), X((e) => e === l ? e : l), Y((e) => e === d ? e : d);
64
+ f = Math.round(f), d = Math.round(d), M((e) => e === c ? e : c), P((e) => e === f ? e : f), X((e) => e === d ? e : d);
68
65
  };
69
66
  return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
70
67
  window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
71
68
  };
72
- }, [o, m, n]), Z(() => {
69
+ }, [o, m, n]), _(() => {
73
70
  if (o && u.current) {
74
71
  const t = u.current.querySelector(
75
72
  'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
@@ -77,54 +74,54 @@ const ne = J(
77
74
  t ? t.focus() : u.current.focus();
78
75
  }
79
76
  }, [o]);
80
- let L;
81
- if (h && _(a)) {
77
+ let N;
78
+ if (h && ee(a)) {
82
79
  const t = a, b = t.ref;
83
- L = ee(t, {
84
- ref: re(v, b),
80
+ N = te(t, {
81
+ ref: ie(v, b),
85
82
  onClick: (x) => {
86
- t.props.onClick?.(x), H();
83
+ t.props.onClick?.(x), q();
87
84
  },
88
- className: y(t.props.className, g?.trigger),
85
+ className: R(t.props.className, g?.trigger),
89
86
  "aria-expanded": o,
90
87
  "aria-haspopup": "dialog",
91
88
  "aria-controls": o ? k : void 0
92
89
  });
93
90
  } else
94
- L = /* @__PURE__ */ S(
91
+ N = /* @__PURE__ */ y(
95
92
  "button",
96
93
  {
97
94
  ref: v,
98
95
  type: "button",
99
- className: y(R.trigger, g?.trigger),
100
- onClick: H,
96
+ className: R(L.trigger, g?.trigger),
97
+ onClick: q,
101
98
  "aria-expanded": o,
102
99
  "aria-haspopup": "dialog",
103
100
  "aria-controls": o ? k : void 0,
104
101
  children: a
105
102
  }
106
103
  );
107
- return /* @__PURE__ */ S(
104
+ return /* @__PURE__ */ y(
108
105
  "div",
109
106
  {
110
- ref: T,
111
- className: y(R.root, g?.root, K),
112
- style: P,
113
- children: /* @__PURE__ */ G("div", { ref: $, children: [
114
- L,
115
- o && /* @__PURE__ */ S(
107
+ ref: V,
108
+ className: R(L.root, g?.root, H),
109
+ style: T,
110
+ children: /* @__PURE__ */ K("div", { ref: Y, children: [
111
+ N,
112
+ o && /* @__PURE__ */ y(
116
113
  "div",
117
114
  {
118
115
  ref: u,
119
116
  id: k,
120
117
  role: "dialog",
121
118
  tabIndex: -1,
122
- className: y(R.popover, R[m ? A : n], g?.popover),
119
+ className: R(L.popover, L[m ? D : n], g?.popover),
123
120
  style: m ? {
124
- "--crk-popover-shift-x": `${D}px`,
125
- "--crk-popover-shift-y": `${F}px`
121
+ "--crk-popover-shift-x": `${F}px`,
122
+ "--crk-popover-shift-y": `${G}px`
126
123
  } : void 0,
127
- children: f
124
+ children: /* @__PURE__ */ y(ne, { value: J, children: l })
128
125
  }
129
126
  )
130
127
  ] })
@@ -132,7 +129,7 @@ const ne = J(
132
129
  );
133
130
  }
134
131
  );
135
- ne.displayName = "Popover";
132
+ se.displayName = "Popover";
136
133
  export {
137
- ne as Popover
134
+ se as Popover
138
135
  };
@@ -1,40 +1,40 @@
1
1
  import { jsxs as N, jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as X, useState as Y, useRef as S, useId as Z, useEffect as q, useCallback as F } from "react";
3
- import { createPortal as $ } from "react-dom";
2
+ import { forwardRef as Y, useState as Z, useRef as L, useId as $, useEffect as q, useCallback as F } from "react";
3
+ import { createPortal as ee } from "react-dom";
4
4
  import i from "clsx";
5
5
  import t from "./SplitButton.module.scss.js";
6
6
  import h from "../Button/Button.module.scss.js";
7
- import { useKeyboard as ee } from "../../hooks/useKeyboard.js";
8
- import { usePortalPosition as te } from "../../hooks/usePortalPosition.js";
9
- const ne = X(
7
+ import { useEscapeLayer as te, EscapeLayerProvider as ne } from "../../hooks/useEscapeLayer.js";
8
+ import { usePortalPosition as re } from "../../hooks/usePortalPosition.js";
9
+ const oe = Y(
10
10
  ({
11
11
  actions: g,
12
12
  variant: b = "secondary",
13
- size: O = "md",
14
- disabled: w = !1,
13
+ size: S = "md",
14
+ disabled: O = !1,
15
15
  align: v = "right",
16
- portal: k = !0,
17
- menuLabel: K = "More actions",
18
- maxWidth: y,
19
- className: G,
20
- style: x,
21
- id: I,
22
- onOpen: L,
16
+ portal: y = !0,
17
+ menuLabel: G = "More actions",
18
+ maxWidth: k,
19
+ className: H,
20
+ style: w,
21
+ id: x,
22
+ onOpen: I,
23
23
  onClose: c,
24
24
  classes: s
25
- }, H) => {
26
- const [n, R] = Y(!1), C = S(null), u = S(null), E = S(null), M = Z();
25
+ }, J) => {
26
+ const [n, E] = Z(!1), C = L(null), u = L(null), R = L(null), M = $();
27
27
  q(() => {
28
28
  n && u.current && u.current.querySelector('[role="menuitem"]:not([disabled])')?.focus();
29
29
  }, [n]);
30
30
  const f = F(() => {
31
- R(!1), c?.(), E.current?.focus();
32
- }, [c]), J = F(() => {
33
- R((e) => {
31
+ E(!1), c?.(), R.current?.focus();
32
+ }, [c]), K = F(() => {
33
+ E((e) => {
34
34
  const l = !e;
35
- return l ? L?.() : c?.(), l;
35
+ return l ? I?.() : c?.(), l;
36
36
  });
37
- }, [L, c]);
37
+ }, [I, c]);
38
38
  q(() => {
39
39
  if (!n) return;
40
40
  const e = (l) => {
@@ -42,27 +42,22 @@ const ne = X(
42
42
  C.current?.contains(m) || u.current?.contains(m) || f();
43
43
  };
44
44
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
45
- }, [n, f]), ee(
46
- {
47
- Escape: () => f()
48
- },
49
- n
50
- );
51
- const d = te(C, n && k);
45
+ }, [n, f]);
46
+ const Q = te(f, n), d = re(C, n && y);
52
47
  if (g.length === 0) return null;
53
- const [o, ...z] = g, a = z.length > 0, B = w || o.disabled, P = i(h.root, h[b], h[O]), Q = b === "secondary" ? t.overlapOutline : b === "ghost" ? t.dividerSubtle : t.dividerOnFill, j = i(
54
- P,
48
+ const [o, ...P] = g, a = P.length > 0, z = O || o.disabled, B = i(h.root, h[b], h[S]), T = b === "secondary" ? t.overlapOutline : b === "ghost" ? t.dividerSubtle : t.dividerOnFill, j = i(
49
+ B,
55
50
  t.main,
56
51
  a && t.mainAttached,
57
52
  a && n && t.mainOpen,
58
53
  s?.main
59
- ), p = (e) => y !== void 0 && (typeof e == "string" || typeof e == "number") ? String(e) : void 0, D = /* @__PURE__ */ N("span", { className: t.mainContent, children: [
54
+ ), p = (e) => k !== void 0 && (typeof e == "string" || typeof e == "number") ? String(e) : void 0, D = /* @__PURE__ */ N("span", { className: t.mainContent, children: [
60
55
  /* @__PURE__ */ r("span", { className: t.mainLabel, children: o.label }),
61
56
  a && /* @__PURE__ */ r("span", { className: t.sizer, "aria-hidden": "true", children: g.map((e, l) => /* @__PURE__ */ r("span", { className: t.sizerItem, children: e.label }, l)) })
62
- ] }), T = o.href && !B ? /* @__PURE__ */ r(
57
+ ] }), U = o.href && !z ? /* @__PURE__ */ r(
63
58
  "a",
64
59
  {
65
- id: I,
60
+ id: x,
66
61
  className: j,
67
62
  href: o.href,
68
63
  target: o.target,
@@ -74,22 +69,22 @@ const ne = X(
74
69
  ) : /* @__PURE__ */ r(
75
70
  "button",
76
71
  {
77
- id: I,
72
+ id: x,
78
73
  type: "button",
79
74
  className: j,
80
- disabled: B,
75
+ disabled: z,
81
76
  title: p(o.label),
82
77
  onClick: o.onClick,
83
78
  children: D
84
79
  }
85
- ), U = z.map((e, l) => {
80
+ ), V = P.map((e, l) => {
86
81
  const m = i(
87
82
  t.item,
88
83
  e.disabled && t.itemDisabled,
89
84
  e.danger && t.itemDanger,
90
85
  s?.item
91
- ), _ = (W) => {
92
- e.onClick?.(W), f();
86
+ ), _ = (X) => {
87
+ e.onClick?.(X), f();
93
88
  };
94
89
  return e.href && !e.disabled ? /* @__PURE__ */ r(
95
90
  "a",
@@ -117,51 +112,51 @@ const ne = X(
117
112
  },
118
113
  l
119
114
  );
120
- }), V = { sm: t.menuSm, md: t.menuMd, lg: t.menuLg }[O], A = (e) => /* @__PURE__ */ r(
115
+ }), W = { sm: t.menuSm, md: t.menuMd, lg: t.menuLg }[S], A = (e) => /* @__PURE__ */ r(
121
116
  "div",
122
117
  {
123
118
  ref: u,
124
119
  id: M,
125
120
  className: i(
126
121
  t.menu,
127
- V,
122
+ W,
128
123
  n && t.menuOpen,
129
124
  v === "left" ? t.alignLeft : t.alignRight,
130
125
  s?.menu
131
126
  ),
132
127
  style: e,
133
128
  role: "menu",
134
- children: U
129
+ children: /* @__PURE__ */ r(ne, { value: Q, children: V })
135
130
  }
136
131
  );
137
132
  return /* @__PURE__ */ N(
138
133
  "div",
139
134
  {
140
- ref: H,
141
- className: i(t.root, s?.root, G),
142
- style: y !== void 0 ? { maxWidth: y, ...x } : x,
135
+ ref: J,
136
+ className: i(t.root, s?.root, H),
137
+ style: k !== void 0 ? { maxWidth: k, ...w } : w,
143
138
  children: [
144
139
  /* @__PURE__ */ N("div", { ref: C, className: i(t.group, s?.group), children: [
145
- T,
140
+ U,
146
141
  a && /* @__PURE__ */ r(
147
142
  "button",
148
143
  {
149
- ref: E,
144
+ ref: R,
150
145
  type: "button",
151
146
  className: i(
152
- P,
147
+ B,
153
148
  h.iconOnly,
154
149
  t.toggle,
155
150
  n && t.toggleOpen,
156
- Q,
151
+ T,
157
152
  s?.toggle
158
153
  ),
159
- disabled: w,
160
- onClick: J,
154
+ disabled: O,
155
+ onClick: K,
161
156
  "aria-haspopup": "menu",
162
157
  "aria-expanded": n,
163
158
  "aria-controls": n ? M : void 0,
164
- "aria-label": K,
159
+ "aria-label": G,
165
160
  children: /* @__PURE__ */ r(
166
161
  "svg",
167
162
  {
@@ -174,8 +169,8 @@ const ne = X(
174
169
  }
175
170
  )
176
171
  ] }),
177
- a && !k && A(),
178
- a && k && n && typeof document < "u" && $(
172
+ a && !y && A(),
173
+ a && y && n && typeof document < "u" && ee(
179
174
  A({
180
175
  position: "fixed",
181
176
  top: d.top,
@@ -195,7 +190,7 @@ const ne = X(
195
190
  );
196
191
  }
197
192
  );
198
- ne.displayName = "SplitButton";
193
+ oe.displayName = "SplitButton";
199
194
  export {
200
- ne as SplitButton
195
+ oe as SplitButton
201
196
  };
@@ -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;