@overdoser/react-toolkit 0.7.0 → 0.8.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 (104) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/components/ActionButton/ActionButton.js +211 -0
  3. package/components/ActionButton/ActionButton.module.scss.js +47 -0
  4. package/components/ActionButton/CopyButton.js +66 -0
  5. package/components/Alert/Alert.js +82 -0
  6. package/components/Alert/Alert.module.scss.js +25 -0
  7. package/components/Avatar/Avatar.js +57 -0
  8. package/components/Avatar/Avatar.module.scss.js +43 -0
  9. package/components/Badge/Badge.js +38 -0
  10. package/components/Badge/Badge.module.scss.js +31 -0
  11. package/components/Breadcrumbs/Breadcrumbs.js +49 -0
  12. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
  13. package/components/Button/Button.js +57 -0
  14. package/components/Button/Button.module.scss.js +47 -0
  15. package/components/Chart/AreaChart.js +244 -0
  16. package/components/Chart/Axis.js +45 -0
  17. package/components/Chart/BarChart.js +353 -0
  18. package/components/Chart/Chart.module.scss.js +61 -0
  19. package/components/Chart/ChartContainer.js +41 -0
  20. package/components/Chart/ChartLegend.js +31 -0
  21. package/components/Chart/ChartTooltip.js +42 -0
  22. package/components/Chart/LineChart.js +236 -0
  23. package/components/Chart/PieChart.js +248 -0
  24. package/components/Chart/RadarChart.js +221 -0
  25. package/components/Chart/Sparkline.js +69 -0
  26. package/components/Chart/TradingChart.js +732 -0
  27. package/components/Chart/scales.js +39 -0
  28. package/components/Chart/trading/indicators.js +68 -0
  29. package/components/Chart/trading/period.js +71 -0
  30. package/components/Chart/useChartDimensions.js +23 -0
  31. package/components/Divider/Divider.js +36 -0
  32. package/components/Divider/Divider.module.scss.js +31 -0
  33. package/components/Draggable/Draggable.js +155 -0
  34. package/components/Draggable/Draggable.module.scss.js +17 -0
  35. package/components/Drawer/Drawer.js +126 -0
  36. package/components/Drawer/Drawer.module.scss.js +117 -0
  37. package/components/Dropdown/Dropdown.js +142 -0
  38. package/components/Dropdown/Dropdown.module.scss.js +35 -0
  39. package/components/Dropdown/DropdownItem.js +31 -0
  40. package/components/Dropzone/Dropzone.js +107 -0
  41. package/components/Dropzone/Dropzone.module.scss.js +21 -0
  42. package/components/Form/Form.js +36 -0
  43. package/components/Form/Form.module.scss.js +29 -0
  44. package/components/Form/FormField.js +76 -0
  45. package/components/Form/FormRow.js +9 -0
  46. package/components/Form/formFieldDefaults.js +5 -0
  47. package/components/Link/Link.js +59 -0
  48. package/components/Link/Link.module.scss.js +16 -0
  49. package/components/List/List.js +46 -0
  50. package/components/List/List.module.scss.js +21 -0
  51. package/components/Modal/Modal.js +109 -0
  52. package/components/Modal/Modal.module.scss.js +31 -0
  53. package/components/Pagination/Pagination.js +84 -0
  54. package/components/Pagination/Pagination.module.scss.js +23 -0
  55. package/components/Pagination/paginationRange.js +24 -0
  56. package/components/Popover/Popover.js +138 -0
  57. package/components/Popover/Popover.module.scss.js +21 -0
  58. package/components/Skeleton/Skeleton.js +50 -0
  59. package/components/Skeleton/Skeleton.module.scss.js +25 -0
  60. package/components/Spinner/Spinner.js +25 -0
  61. package/components/Spinner/Spinner.module.scss.js +20 -0
  62. package/components/Table/Table.js +284 -0
  63. package/components/Table/Table.module.scss.js +59 -0
  64. package/components/Table/useTableSort.js +44 -0
  65. package/components/Tabs/Tabs.js +163 -0
  66. package/components/Tabs/Tabs.module.scss.js +53 -0
  67. package/components/Timer/Timer.js +159 -0
  68. package/components/Timer/Timer.module.scss.js +55 -0
  69. package/components/Toast/Toast.js +133 -0
  70. package/components/Toast/Toast.module.scss.js +62 -0
  71. package/components/Toast/toastStore.js +62 -0
  72. package/components/ToggleIconButton/ToggleIconButton.js +58 -0
  73. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
  74. package/components/Tooltip/Tooltip.js +86 -0
  75. package/components/Tooltip/Tooltip.module.scss.js +30 -0
  76. package/components/Typography/Typography.js +37 -0
  77. package/components/Typography/Typography.module.scss.js +53 -0
  78. package/components/inputs/Checkbox/Checkbox.js +50 -0
  79. package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
  80. package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
  81. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
  82. package/components/inputs/DatePicker/DatePicker.js +229 -0
  83. package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
  84. package/components/inputs/DatePicker/dateUtils.js +41 -0
  85. package/components/inputs/Input/Input.js +50 -0
  86. package/components/inputs/Input/Input.module.scss.js +25 -0
  87. package/components/inputs/NumberInput/NumberInput.js +134 -0
  88. package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
  89. package/components/inputs/Radio/Radio.js +68 -0
  90. package/components/inputs/Radio/Radio.module.scss.js +13 -0
  91. package/components/inputs/Select/Select.js +520 -0
  92. package/components/inputs/Select/Select.module.scss.js +69 -0
  93. package/components/inputs/Slider/Slider.js +128 -0
  94. package/components/inputs/Slider/Slider.module.scss.js +15 -0
  95. package/components/inputs/Textarea/Textarea.js +58 -0
  96. package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
  97. package/hooks/useClickOutside.js +15 -0
  98. package/hooks/useFocusTrap.js +39 -0
  99. package/hooks/useKeyboard.js +19 -0
  100. package/hooks/usePortalPosition.js +20 -0
  101. package/index.css +1 -1
  102. package/index.js +119 -7000
  103. package/index.layered.css +1 -1
  104. package/package.json +3 -2
@@ -0,0 +1,17 @@
1
+ const t = "crk-root-stw2c", r = "crk-list-RGYQR", s = "crk-item-ECyrs", c = "crk-link-B1vub", o = "crk-current-ilnF5", n = "crk-separator-KChd-", e = {
2
+ root: t,
3
+ list: r,
4
+ item: s,
5
+ link: c,
6
+ current: o,
7
+ separator: n
8
+ };
9
+ export {
10
+ o as current,
11
+ e as default,
12
+ s as item,
13
+ c as link,
14
+ r as list,
15
+ t as root,
16
+ n as separator
17
+ };
@@ -0,0 +1,57 @@
1
+ import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as y } from "react";
3
+ import r from "clsx";
4
+ import o from "./Button.module.scss.js";
5
+ const b = {
6
+ dots: o.loadingDots,
7
+ shimmer: o.loadingShimmer,
8
+ border: o.loadingBorder
9
+ }, x = y(
10
+ ({
11
+ variant: s = "primary",
12
+ size: e = "md",
13
+ loading: d = !1,
14
+ loadingStyle: i = "dots",
15
+ fullWidth: n = !1,
16
+ iconOnly: l = !1,
17
+ disabled: p,
18
+ classes: t,
19
+ className: f,
20
+ style: c,
21
+ children: h,
22
+ ...N
23
+ }, u) => /* @__PURE__ */ m(
24
+ "button",
25
+ {
26
+ ref: u,
27
+ className: r(
28
+ o.root,
29
+ o[s],
30
+ o[e],
31
+ n && o.fullWidth,
32
+ l && o.iconOnly,
33
+ d && o.loading,
34
+ d && b[i],
35
+ t?.root,
36
+ f
37
+ ),
38
+ style: c,
39
+ disabled: p || d,
40
+ "aria-busy": d || void 0,
41
+ ...N,
42
+ children: [
43
+ /* @__PURE__ */ a("div", { className: r(o.shimmer, t?.shimmer) }),
44
+ /* @__PURE__ */ a("span", { className: r(o.content, t?.content), children: h }),
45
+ /* @__PURE__ */ m("span", { className: r(o.dots, t?.dots), "aria-hidden": "true", children: [
46
+ /* @__PURE__ */ a("span", { className: r(o.dot, t?.dot) }),
47
+ /* @__PURE__ */ a("span", { className: r(o.dot, t?.dot) }),
48
+ /* @__PURE__ */ a("span", { className: r(o.dot, t?.dot) })
49
+ ] })
50
+ ]
51
+ }
52
+ )
53
+ );
54
+ x.displayName = "Button";
55
+ export {
56
+ x as Button
57
+ };
@@ -0,0 +1,47 @@
1
+ const o = "crk-root-8RX49", n = "crk-loading-QfItr", r = "crk-primary-st6yY", c = "crk-secondary-j-3rj", t = "crk-danger-Hxs5n", s = "crk-ghost-kQ0A8", d = "crk-sm-RXFPY", e = "crk-md-nDnOD", i = "crk-lg-qD-Qh", l = "crk-fullWidth-AHpSl", m = "crk-iconOnly-FNrSu", a = "crk-content-PpYVU", k = "crk-shimmer-8iQSU", g = "crk-loadingShimmer-BVvFw", h = "crk-shimmerSweep-uiZ01", p = "crk-dots-U8wss", S = "crk-loadingDots-eKv64", y = "crk-dot-Owuk1", u = "crk-dotBounce-FwdcC", w = "crk-loadingBorder-9ULFw", B = "crk-borderSpin-EJ2gW", D = {
2
+ root: o,
3
+ loading: n,
4
+ primary: r,
5
+ secondary: c,
6
+ danger: t,
7
+ ghost: s,
8
+ sm: d,
9
+ md: e,
10
+ lg: i,
11
+ fullWidth: l,
12
+ iconOnly: m,
13
+ content: a,
14
+ shimmer: k,
15
+ loadingShimmer: g,
16
+ shimmerSweep: h,
17
+ dots: p,
18
+ loadingDots: S,
19
+ dot: y,
20
+ dotBounce: u,
21
+ loadingBorder: w,
22
+ borderSpin: B
23
+ };
24
+ export {
25
+ B as borderSpin,
26
+ a as content,
27
+ t as danger,
28
+ D as default,
29
+ y as dot,
30
+ u as dotBounce,
31
+ p as dots,
32
+ l as fullWidth,
33
+ s as ghost,
34
+ m as iconOnly,
35
+ i as lg,
36
+ n as loading,
37
+ w as loadingBorder,
38
+ S as loadingDots,
39
+ g as loadingShimmer,
40
+ e as md,
41
+ r as primary,
42
+ o as root,
43
+ c as secondary,
44
+ k as shimmer,
45
+ h as shimmerSweep,
46
+ d as sm
47
+ };
@@ -0,0 +1,244 @@
1
+ import { jsx as l, jsxs as I, Fragment as pt } from "react/jsx-runtime";
2
+ import { useMemo as O, useState as $t, useRef as gt, useId as dt } from "react";
3
+ import X from "clsx";
4
+ import { ChartContainer as Mt } from "./ChartContainer.js";
5
+ import { ChartLegend as Lt } from "./ChartLegend.js";
6
+ import { ChartTooltip as vt } from "./ChartTooltip.js";
7
+ import { YAxis as bt, XAxis as Ct } from "./Axis.js";
8
+ import { bandScale as tt, niceTicks as Nt, linearScale as Tt } from "./scales.js";
9
+ import x from "./Chart.module.scss.js";
10
+ const kt = { top: 12, right: 16, bottom: 28, left: 48 };
11
+ function U(t, s) {
12
+ if (t.length === 0) return "";
13
+ if (t.length === 1) return `M ${t[0].x} ${t[0].y}`;
14
+ if (s === "linear")
15
+ return t.map((o, n) => `${n === 0 ? "M" : "L"} ${o.x} ${o.y}`).join(" ");
16
+ if (s === "step") {
17
+ let o = `M ${t[0].x} ${t[0].y}`;
18
+ for (let n = 1; n < t.length; n++)
19
+ o += ` L ${t[n].x} ${t[n - 1].y} L ${t[n].x} ${t[n].y}`;
20
+ return o;
21
+ }
22
+ let c = `M ${t[0].x} ${t[0].y}`;
23
+ for (let o = 0; o < t.length - 1; o++) {
24
+ const n = t[o - 1] ?? t[o], h = t[o], m = t[o + 1], u = t[o + 2] ?? m, y = h.x + (m.x - n.x) / 6, k = h.y + (m.y - n.y) / 6, _ = m.x - (u.x - h.x) / 6, S = m.y - (u.y - h.y) / 6;
25
+ c += ` C ${y} ${k}, ${_} ${S}, ${m.x} ${m.y}`;
26
+ }
27
+ return c;
28
+ }
29
+ function G(t, s, c) {
30
+ if (t.length === 0) return "";
31
+ const o = U(t, c);
32
+ if (typeof s == "number") {
33
+ const u = t[t.length - 1], y = t[0];
34
+ return `${o} L ${u.x} ${s} L ${y.x} ${s} Z`;
35
+ }
36
+ const n = t.map((u, y) => ({ x: u.x, y: s[y] })).reverse(), m = U(n, c).replace(/^M /, "L ");
37
+ return `${o} ${m} Z`;
38
+ }
39
+ function St(t, s = 8) {
40
+ if (t.length <= s) return t;
41
+ const c = Math.ceil(t.length / s);
42
+ return t.filter((o, n) => n % c === 0);
43
+ }
44
+ function _t({
45
+ data: t,
46
+ xKey: s,
47
+ config: c,
48
+ aspectRatio: o = 16 / 9,
49
+ height: n,
50
+ curve: h = "monotone",
51
+ stacked: m = !1,
52
+ stackOffset: u = "none",
53
+ fillGradient: y = !1,
54
+ showGrid: k = !0,
55
+ showXAxis: _ = !0,
56
+ showYAxis: S = !0,
57
+ showLegend: et = !0,
58
+ showTooltip: ot = !0,
59
+ yTickCount: nt = 5,
60
+ yFormat: rt,
61
+ xFormat: ct,
62
+ valueFormat: lt,
63
+ renderTooltip: q,
64
+ margin: z,
65
+ emptyMessage: st = "No data",
66
+ className: J,
67
+ style: K,
68
+ classes: p
69
+ }) {
70
+ const R = O(
71
+ () => ({
72
+ ...kt,
73
+ ...S ? {} : { left: 16 },
74
+ ...z
75
+ }),
76
+ [z, S]
77
+ ), $ = O(() => Object.keys(c), [c]), w = m && $.length > 0, M = w && u === "expand", [L, Q] = $t(null), j = gt(null), V = dt();
78
+ if (t.length === 0)
79
+ return /* @__PURE__ */ l("div", { ref: j, className: X(x.root, p?.root, J), style: K, children: /* @__PURE__ */ l("div", { className: x.canvas, style: { height: n ?? 240 }, children: /* @__PURE__ */ l("div", { className: x.empty, children: st }) }) });
80
+ const it = O(() => {
81
+ const f = $.map(() => []), g = $.map(() => []);
82
+ for (let r = 0; r < t.length; r++) {
83
+ let i = 0;
84
+ if (M) {
85
+ for (const a of $) {
86
+ const b = t[r][a];
87
+ typeof b == "number" && b > 0 && (i += b);
88
+ }
89
+ i === 0 && (i = 1);
90
+ }
91
+ let v = 0;
92
+ for (let a = 0; a < $.length; a++) {
93
+ const b = $[a], D = t[r][b], d = typeof D == "number" ? D : 0;
94
+ if (w) {
95
+ const C = M ? d / i : d;
96
+ g[a][r] = v, v += C, f[a][r] = v;
97
+ } else
98
+ g[a][r] = 0, f[a][r] = d;
99
+ }
100
+ }
101
+ return { tops: f, bottoms: g };
102
+ }, [t, $, w, M]), { tops: E, bottoms: Z } = it, [at, mt] = O(() => {
103
+ if (M) return [0, 1];
104
+ let f = 0, g = 0;
105
+ for (const r of E)
106
+ for (const i of r)
107
+ i < f && (f = i), i > g && (g = i);
108
+ for (const r of Z)
109
+ for (const i of r)
110
+ i < f && (f = i);
111
+ return [Math.min(0, f), g];
112
+ }, [E, Z, M]);
113
+ return /* @__PURE__ */ l(
114
+ Mt,
115
+ {
116
+ ref: j,
117
+ aspectRatio: o,
118
+ height: n,
119
+ className: J,
120
+ style: K,
121
+ classes: p,
122
+ legend: et ? /* @__PURE__ */ l(Lt, { config: c, classes: p }) : void 0,
123
+ overlay: ot && L !== null ? /* @__PURE__ */ l(
124
+ vt,
125
+ {
126
+ row: t[L],
127
+ x: Rt(t, s, R, L, j),
128
+ y: 16,
129
+ containerWidth: j.current?.getBoundingClientRect().width ?? 0,
130
+ config: c,
131
+ render: q ? () => q(t[L]) : void 0,
132
+ valueFormat: M ? (f) => `${Math.round(f * 100)}%` : lt,
133
+ titleKey: s,
134
+ classes: p
135
+ }
136
+ ) : null,
137
+ children: ({ width: f, height: g }) => {
138
+ const r = R.left, i = f - R.right, v = R.top, a = g - R.bottom, b = Math.max(0, i - r), D = Math.max(0, a - v), d = t.map((e) => String(e[s])), C = tt(d, [r, i], 0), W = M ? [0, 0.25, 0.5, 0.75, 1] : Nt(at, mt, nt), F = Tt([W[0], W[W.length - 1]], [a, v]), ft = F(0), Y = W.map((e) => ({ value: e, y: F(e) })), ht = St(d).map((e) => ({ label: e, x: C(e) })), ut = M ? (e) => `${Math.round(e * 100)}%` : rt;
139
+ return /* @__PURE__ */ I(pt, { children: [
140
+ y && /* @__PURE__ */ l("defs", { children: $.map((e) => /* @__PURE__ */ I(
141
+ "linearGradient",
142
+ {
143
+ id: `${V}-${e}`,
144
+ x1: "0",
145
+ y1: "0",
146
+ x2: "0",
147
+ y2: "1",
148
+ children: [
149
+ /* @__PURE__ */ l("stop", { offset: "5%", stopColor: c[e].color, stopOpacity: 0.6 }),
150
+ /* @__PURE__ */ l("stop", { offset: "95%", stopColor: c[e].color, stopOpacity: 0.05 })
151
+ ]
152
+ },
153
+ e
154
+ )) }),
155
+ S ? /* @__PURE__ */ l(
156
+ bt,
157
+ {
158
+ ticks: Y,
159
+ x: r,
160
+ plotWidth: b,
161
+ format: ut,
162
+ showGrid: k,
163
+ classes: p
164
+ }
165
+ ) : k && /* @__PURE__ */ l("g", { className: X(x.axis, p?.axis), children: Y.map(({ value: e, y: N }) => /* @__PURE__ */ l(
166
+ "line",
167
+ {
168
+ className: X(x.gridLine, p?.grid),
169
+ x1: r,
170
+ x2: i,
171
+ y1: N,
172
+ y2: N
173
+ },
174
+ `grid-${e}`
175
+ )) }),
176
+ _ && /* @__PURE__ */ l(Ct, { ticks: ht, y: a, format: ct, classes: p }),
177
+ $.map((e, N) => {
178
+ const A = c[e], T = t.map((B, P) => ({
179
+ x: C(d[P]),
180
+ y: F(E[N][P])
181
+ })), H = y ? `url(#${V}-${e})` : A.color, xt = y ? 1 : 0.18, yt = w ? G(T, Z[N].map((B) => F(B)), h) : G(T, ft, h);
182
+ return /* @__PURE__ */ I("g", { className: X(x.series, p?.series), children: [
183
+ /* @__PURE__ */ l(
184
+ "path",
185
+ {
186
+ className: x.areaPath,
187
+ d: yt,
188
+ fill: H,
189
+ fillOpacity: xt
190
+ }
191
+ ),
192
+ /* @__PURE__ */ l("path", { className: x.linePath, d: U(T, h), stroke: A.color }),
193
+ !w && T.map((B, P) => /* @__PURE__ */ l(
194
+ "circle",
195
+ {
196
+ className: X(x.point, p?.point),
197
+ cx: B.x,
198
+ cy: B.y,
199
+ r: L === P ? 5 : 3,
200
+ fill: A.color
201
+ },
202
+ `${e}-${P}`
203
+ ))
204
+ ] }, e);
205
+ }),
206
+ L !== null && /* @__PURE__ */ l(
207
+ "line",
208
+ {
209
+ className: x.cursorLine,
210
+ x1: C(d[L]),
211
+ x2: C(d[L]),
212
+ y1: v,
213
+ y2: a
214
+ }
215
+ ),
216
+ /* @__PURE__ */ l(
217
+ "rect",
218
+ {
219
+ className: x.interactionLayer,
220
+ x: r,
221
+ y: v,
222
+ width: b,
223
+ height: D,
224
+ onMouseMove: (e) => {
225
+ const N = e.currentTarget.getBoundingClientRect(), A = e.clientX - N.left + r, T = C.step(), H = Math.max(0, Math.min(t.length - 1, Math.round((A - r - T / 2) / T)));
226
+ Q(H);
227
+ },
228
+ onMouseLeave: () => Q(null)
229
+ }
230
+ )
231
+ ] });
232
+ }
233
+ }
234
+ );
235
+ }
236
+ function Rt(t, s, c, o, n) {
237
+ const h = n.current;
238
+ if (!h) return 0;
239
+ const m = h.getBoundingClientRect().width, u = t.map((k) => String(k[s]));
240
+ return tt(u, [c.left, m - c.right], 0)(u[o]);
241
+ }
242
+ export {
243
+ _t as AreaChart
244
+ };
@@ -0,0 +1,45 @@
1
+ import { jsx as x, jsxs as l } from "react/jsx-runtime";
2
+ import s from "clsx";
3
+ import a from "./Chart.module.scss.js";
4
+ function g({ ticks: m, x: e, plotWidth: t, format: n, showGrid: r = !0, classes: i }) {
5
+ return /* @__PURE__ */ x("g", { className: s(a.axis, i?.axis), children: m.map(({ value: d, y: c }) => /* @__PURE__ */ l("g", { children: [
6
+ r && /* @__PURE__ */ x(
7
+ "line",
8
+ {
9
+ className: s(a.gridLine, i?.grid),
10
+ x1: e,
11
+ x2: e + t,
12
+ y1: c,
13
+ y2: c
14
+ }
15
+ ),
16
+ /* @__PURE__ */ x(
17
+ "text",
18
+ {
19
+ className: s(a.axisLabel, i?.axisLabel),
20
+ x: e - 8,
21
+ y: c,
22
+ textAnchor: "end",
23
+ dominantBaseline: "middle",
24
+ children: n ? n(d) : d
25
+ }
26
+ )
27
+ ] }, `y-${d}`)) });
28
+ }
29
+ function L({ ticks: m, y: e, format: t, classes: n }) {
30
+ return /* @__PURE__ */ x("g", { className: s(a.axis, n?.axis), children: m.map(({ label: r, x: i }) => /* @__PURE__ */ x(
31
+ "text",
32
+ {
33
+ className: s(a.axisLabel, n?.axisLabel),
34
+ x: i,
35
+ y: e + 16,
36
+ textAnchor: "middle",
37
+ children: t ? t(r) : r
38
+ },
39
+ `x-${r}-${i}`
40
+ )) });
41
+ }
42
+ export {
43
+ L as XAxis,
44
+ g as YAxis
45
+ };