@overdoser/react-toolkit 0.16.0 → 0.18.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/AGENTS.md +1 -1
- package/CHANGELOG.md +74 -0
- package/components/Chart/AreaChart.d.ts +5 -1
- package/components/Chart/AreaChart.js +155 -144
- package/components/Chart/BarChart.js +5 -5
- package/components/Chart/PieChart.js +2 -5
- package/components/Chart/RadarChart.js +2 -5
- package/components/Chart/TradingChart.js +258 -257
- package/components/Drawer/Drawer.js +69 -70
- package/components/Dropdown/Dropdown.js +51 -56
- package/components/Loader/Loader.d.ts +104 -0
- package/components/Loader/Loader.js +186 -0
- package/components/Loader/Loader.module.scss.js +70 -0
- package/components/Loader/index.d.ts +2 -0
- package/components/Modal/Modal.js +42 -47
- package/components/Popover/Popover.js +52 -55
- package/components/SplitButton/SplitButton.js +50 -55
- package/components/inputs/DatePicker/DatePicker.js +82 -76
- package/components/inputs/DateTimePicker/DateTimePicker.js +4 -2
- package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +2 -1
- package/components/inputs/DateTimePicker/DateTimeSegments.js +1 -1
- package/components/inputs/NumberInput/NumberInput.js +79 -81
- package/components/inputs/Select/Select.d.ts +5 -0
- package/components/inputs/Select/Select.js +340 -285
- package/hooks/useEscapeLayer.d.ts +36 -0
- package/hooks/useEscapeLayer.js +33 -0
- package/index.css +1 -1
- package/index.d.ts +2 -0
- package/index.js +74 -72
- package/index.layered.css +1 -1
- package/llms.txt +43 -2
- package/manifest.json +73 -0
- package/package.json +1 -1
|
@@ -1,125 +1,123 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as B, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as q, useState as z, useRef as L, useEffect as G, useCallback as S } from "react";
|
|
3
|
+
import m from "clsx";
|
|
4
|
+
import l from "./NumberInput.module.scss.js";
|
|
5
|
+
const x = (n) => {
|
|
6
6
|
if (n.trim() === "") return null;
|
|
7
|
-
const
|
|
8
|
-
return Number.isNaN(
|
|
9
|
-
},
|
|
7
|
+
const h = Number(n);
|
|
8
|
+
return Number.isNaN(h) ? null : h;
|
|
9
|
+
}, H = q(
|
|
10
10
|
({
|
|
11
11
|
value: n,
|
|
12
|
-
defaultValue:
|
|
13
|
-
onChange:
|
|
14
|
-
min:
|
|
15
|
-
max:
|
|
16
|
-
step:
|
|
17
|
-
precision:
|
|
18
|
-
inputSize:
|
|
19
|
-
error:
|
|
20
|
-
hideControls:
|
|
21
|
-
disabled:
|
|
12
|
+
defaultValue: h,
|
|
13
|
+
onChange: v,
|
|
14
|
+
min: u,
|
|
15
|
+
max: a,
|
|
16
|
+
step: D = 1,
|
|
17
|
+
precision: N,
|
|
18
|
+
inputSize: R = "md",
|
|
19
|
+
error: C = !1,
|
|
20
|
+
hideControls: A = !1,
|
|
21
|
+
disabled: i,
|
|
22
|
+
readOnly: f,
|
|
22
23
|
classes: d,
|
|
23
|
-
className:
|
|
24
|
-
style:
|
|
25
|
-
onKeyDown:
|
|
26
|
-
onBlur:
|
|
27
|
-
...
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
24
|
+
className: F,
|
|
25
|
+
style: K,
|
|
26
|
+
onKeyDown: W,
|
|
27
|
+
onBlur: E,
|
|
28
|
+
...I
|
|
29
|
+
}, P) => {
|
|
30
|
+
const c = n !== void 0, j = (c ? n : h) ?? null, [g, p] = z(j != null ? String(j) : ""), w = L(!1), b = L(!1), r = c ? n ?? null : x(g);
|
|
31
|
+
G(() => {
|
|
32
|
+
c && (!w.current || b.current) && p(n != null ? String(n) : ""), b.current = !1;
|
|
33
|
+
}, [c, n]);
|
|
34
|
+
const M = S(
|
|
34
35
|
(t) => {
|
|
35
36
|
let e = t;
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
e = Math.round(e *
|
|
37
|
+
if (u != null && (e = Math.max(u, e)), a != null && (e = Math.min(a, e)), N != null) {
|
|
38
|
+
const o = 10 ** N;
|
|
39
|
+
e = Math.round(e * o) / o;
|
|
39
40
|
}
|
|
40
41
|
return e;
|
|
41
42
|
},
|
|
42
|
-
[
|
|
43
|
-
),
|
|
43
|
+
[u, a, N]
|
|
44
|
+
), y = S(
|
|
44
45
|
(t) => {
|
|
45
|
-
|
|
46
|
+
c ? b.current = !0 : p(t != null ? String(t) : ""), v?.(t);
|
|
46
47
|
},
|
|
47
|
-
[
|
|
48
|
-
),
|
|
48
|
+
[c, v]
|
|
49
|
+
), k = S(
|
|
49
50
|
(t) => {
|
|
50
|
-
if (
|
|
51
|
-
|
|
51
|
+
if (i || f) return;
|
|
52
|
+
y(M((r ?? u ?? 0) + t * D));
|
|
52
53
|
},
|
|
53
|
-
[
|
|
54
|
-
),
|
|
55
|
-
|
|
54
|
+
[i, f, r, u, D, M, y]
|
|
55
|
+
), T = a != null && r != null && r >= a, U = u != null && r != null && r <= u, V = (t) => {
|
|
56
|
+
W?.(t), !t.defaultPrevented && (t.key === "ArrowUp" ? (t.preventDefault(), k(1)) : t.key === "ArrowDown" && (t.preventDefault(), k(-1)));
|
|
56
57
|
};
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ B(
|
|
58
59
|
"div",
|
|
59
60
|
{
|
|
60
|
-
className:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
className: m(
|
|
62
|
+
l.root,
|
|
63
|
+
l[R],
|
|
64
|
+
C && l.error,
|
|
65
|
+
i && l.disabled,
|
|
65
66
|
d?.root,
|
|
66
|
-
|
|
67
|
+
F
|
|
67
68
|
),
|
|
68
|
-
style:
|
|
69
|
-
"data-disabled":
|
|
69
|
+
style: K,
|
|
70
|
+
"data-disabled": i || void 0,
|
|
70
71
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ s(
|
|
72
73
|
"input",
|
|
73
74
|
{
|
|
74
|
-
ref:
|
|
75
|
+
ref: P,
|
|
75
76
|
type: "text",
|
|
76
77
|
inputMode: "decimal",
|
|
77
|
-
className:
|
|
78
|
-
value:
|
|
79
|
-
disabled:
|
|
80
|
-
|
|
78
|
+
className: m(l.input, d?.input),
|
|
79
|
+
value: g,
|
|
80
|
+
disabled: i,
|
|
81
|
+
readOnly: f,
|
|
82
|
+
"aria-invalid": C || void 0,
|
|
81
83
|
onChange: (t) => {
|
|
82
|
-
|
|
84
|
+
b.current = !1, p(t.target.value), v?.(x(t.target.value));
|
|
83
85
|
},
|
|
84
|
-
onKeyDown:
|
|
86
|
+
onKeyDown: V,
|
|
85
87
|
onFocus: (t) => {
|
|
86
|
-
|
|
88
|
+
w.current = !0, I.onFocus?.(t);
|
|
87
89
|
},
|
|
88
90
|
onBlur: (t) => {
|
|
89
|
-
|
|
90
|
-
const e = g(
|
|
91
|
-
|
|
92
|
-
const c = y(e);
|
|
93
|
-
c !== e ? w(c) : m(String(c));
|
|
94
|
-
}
|
|
95
|
-
F?.(t);
|
|
91
|
+
w.current = !1;
|
|
92
|
+
const e = x(g), o = e != null ? M(e) : null;
|
|
93
|
+
o !== e && y(o), c ? p(r != null ? String(r) : "") : o != null && o === e && p(String(o)), E?.(t);
|
|
96
94
|
},
|
|
97
|
-
...
|
|
95
|
+
...I
|
|
98
96
|
}
|
|
99
97
|
),
|
|
100
|
-
!
|
|
101
|
-
/* @__PURE__ */
|
|
98
|
+
!A && /* @__PURE__ */ B("div", { className: m(l.controls, d?.controls), children: [
|
|
99
|
+
/* @__PURE__ */ s(
|
|
102
100
|
"button",
|
|
103
101
|
{
|
|
104
102
|
type: "button",
|
|
105
103
|
tabIndex: -1,
|
|
106
|
-
className:
|
|
107
|
-
onClick: () =>
|
|
108
|
-
disabled:
|
|
104
|
+
className: m(l.increment, d?.increment),
|
|
105
|
+
onClick: () => k(1),
|
|
106
|
+
disabled: i || f || T,
|
|
109
107
|
"aria-label": "Increment",
|
|
110
|
-
children: /* @__PURE__ */
|
|
108
|
+
children: /* @__PURE__ */ s("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", children: /* @__PURE__ */ s("path", { d: "M1 5l4-4 4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
111
109
|
}
|
|
112
110
|
),
|
|
113
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ s(
|
|
114
112
|
"button",
|
|
115
113
|
{
|
|
116
114
|
type: "button",
|
|
117
115
|
tabIndex: -1,
|
|
118
|
-
className:
|
|
119
|
-
onClick: () =>
|
|
120
|
-
disabled:
|
|
116
|
+
className: m(l.decrement, d?.decrement),
|
|
117
|
+
onClick: () => k(-1),
|
|
118
|
+
disabled: i || f || U,
|
|
121
119
|
"aria-label": "Decrement",
|
|
122
|
-
children: /* @__PURE__ */
|
|
120
|
+
children: /* @__PURE__ */ s("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", children: /* @__PURE__ */ s("path", { d: "M1 1l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
123
121
|
}
|
|
124
122
|
)
|
|
125
123
|
] })
|
|
@@ -128,7 +126,7 @@ const g = (n) => {
|
|
|
128
126
|
);
|
|
129
127
|
}
|
|
130
128
|
);
|
|
131
|
-
|
|
129
|
+
H.displayName = "NumberInput";
|
|
132
130
|
export {
|
|
133
|
-
|
|
131
|
+
H as NumberInput
|
|
134
132
|
};
|
|
@@ -86,6 +86,11 @@ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, 'onCh
|
|
|
86
86
|
* - **Searchable**: set `searchable`. Custom dropdown with text filter.
|
|
87
87
|
* - **Multi**: set `multiple`. Chip-based multi-select with text filter.
|
|
88
88
|
*
|
|
89
|
+
* In the searchable and multi modes `name` / `form` go to a hidden native
|
|
90
|
+
* `<select>` (so the value is submitted with `FormData`), `aria-*` / `data-*`
|
|
91
|
+
* go to the visible control, `required` becomes `aria-required`, and
|
|
92
|
+
* `onFocus` / `onBlur` fire when focus enters / leaves the whole widget.
|
|
93
|
+
*
|
|
89
94
|
* @example Native: <Select options={[{ value: 'a', label: 'A' }]} onValueChange={setValue} />
|
|
90
95
|
* @example Searchable: <Select searchable options={users} value={id} onValueChange={setId} />
|
|
91
96
|
* @example Multi: <Select multiple options={tags} value={selected} onValuesChange={setSelected} />
|