@overdoser/react-toolkit 0.7.0 → 0.8.1

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 +114 -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,128 @@
1
+ import { jsx as P, jsxs as Z } from "react/jsx-runtime";
2
+ import { forwardRef as _, useState as $, useRef as j, useCallback as u, useEffect as V } from "react";
3
+ import k from "clsx";
4
+ import v from "./Slider.module.scss.js";
5
+ const T = (f) => Array.isArray(f) ? f : null, tt = _(
6
+ ({
7
+ value: f,
8
+ defaultValue: I,
9
+ onChange: A,
10
+ onChangeEnd: E,
11
+ min: n = 0,
12
+ max: a = 100,
13
+ step: l = 1,
14
+ disabled: s = !1,
15
+ formatValue: L,
16
+ classes: y,
17
+ className: K,
18
+ style: x,
19
+ "aria-label": z,
20
+ "aria-labelledby": B
21
+ }, C) => {
22
+ const m = f !== void 0, F = f ?? I ?? 0, [H, q] = $(F), c = m ? f : H, N = j(null), d = j(0), [R, b] = $(!1), S = u((t) => Math.min(a, Math.max(n, t)), [n, a]), U = u(
23
+ (t) => S(Math.round((t - n) / l) * l + n),
24
+ [S, n, l]
25
+ ), h = u((t) => (t - n) / (a - n) * 100, [n, a]), D = u(
26
+ (t, e = !1) => {
27
+ m || q(t), A?.(t), e && E?.(t);
28
+ },
29
+ [m, A, E]
30
+ ), w = u(
31
+ (t, e, r = !1) => {
32
+ const o = U(e), M = T(c);
33
+ if (M) {
34
+ const i = [M[0], M[1]];
35
+ i[t] = o, t === 0 ? i[0] = Math.min(i[0], i[1]) : i[1] = Math.max(i[1], i[0]), D(i, r);
36
+ } else
37
+ D(o, r);
38
+ },
39
+ [c, U, D]
40
+ ), g = u(
41
+ (t) => {
42
+ const e = N.current;
43
+ if (!e) return n;
44
+ const r = e.getBoundingClientRect(), o = r.width > 0 ? (t - r.left) / r.width : 0;
45
+ return n + o * (a - n);
46
+ },
47
+ [n, a]
48
+ ), G = u(
49
+ (t) => {
50
+ const e = T(c);
51
+ return e ? Math.abs(t - e[0]) <= Math.abs(t - e[1]) ? 0 : 1 : 0;
52
+ },
53
+ [c]
54
+ );
55
+ V(() => {
56
+ if (!R) return;
57
+ const t = (r) => {
58
+ w(d.current, g(r.clientX));
59
+ }, e = (r) => {
60
+ b(!1), w(d.current, g(r.clientX), !0);
61
+ };
62
+ return window.addEventListener("pointermove", t), window.addEventListener("pointerup", e), () => {
63
+ window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", e);
64
+ };
65
+ }, [R, w, g]);
66
+ const J = (t) => {
67
+ if (s) return;
68
+ const e = g(t.clientX);
69
+ d.current = G(e), b(!0), w(d.current, e);
70
+ }, O = (t) => (e) => {
71
+ s || (e.stopPropagation(), d.current = t, b(!0));
72
+ }, Q = (t, e) => (r) => {
73
+ if (s) return;
74
+ let o = null;
75
+ r.key === "ArrowRight" || r.key === "ArrowUp" ? o = e + l : r.key === "ArrowLeft" || r.key === "ArrowDown" ? o = e - l : r.key === "Home" ? o = n : r.key === "End" ? o = a : r.key === "PageUp" ? o = e + l * 10 : r.key === "PageDown" && (o = e - l * 10), o !== null && (r.preventDefault(), w(t, o, !0));
76
+ }, p = T(c), W = p ?? [c], X = p ? h(p[0]) : 0, Y = h(p ? p[1] : c);
77
+ return /* @__PURE__ */ P(
78
+ "div",
79
+ {
80
+ ref: C,
81
+ className: k(v.root, s && v.disabled, y?.root, K),
82
+ style: x,
83
+ "data-disabled": s || void 0,
84
+ children: /* @__PURE__ */ Z(
85
+ "div",
86
+ {
87
+ ref: N,
88
+ className: k(v.track, y?.track),
89
+ onPointerDown: J,
90
+ children: [
91
+ /* @__PURE__ */ P(
92
+ "div",
93
+ {
94
+ className: k(v.range, y?.range),
95
+ style: { left: `${X}%`, width: `${Y - X}%` }
96
+ }
97
+ ),
98
+ W.map((t, e) => /* @__PURE__ */ P(
99
+ "div",
100
+ {
101
+ className: k(v.thumb, y?.thumb),
102
+ style: { left: `${h(t)}%` },
103
+ role: "slider",
104
+ tabIndex: s ? -1 : 0,
105
+ "aria-orientation": "horizontal",
106
+ "aria-valuemin": n,
107
+ "aria-valuemax": a,
108
+ "aria-valuenow": t,
109
+ "aria-valuetext": L ? L(t) : void 0,
110
+ "aria-label": z,
111
+ "aria-labelledby": B,
112
+ "aria-disabled": s || void 0,
113
+ onPointerDown: O(e),
114
+ onKeyDown: Q(e, t)
115
+ },
116
+ e
117
+ ))
118
+ ]
119
+ }
120
+ )
121
+ }
122
+ );
123
+ }
124
+ );
125
+ tt.displayName = "Slider";
126
+ export {
127
+ tt as Slider
128
+ };
@@ -0,0 +1,15 @@
1
+ const t = "crk-root-fvpfd", r = "crk-track-MP1oP", c = "crk-range-fh4JV", o = "crk-thumb-LKxgd", s = "crk-disabled-n8jtF", a = {
2
+ root: t,
3
+ track: r,
4
+ range: c,
5
+ thumb: o,
6
+ disabled: s
7
+ };
8
+ export {
9
+ a as default,
10
+ s as disabled,
11
+ c as range,
12
+ t as root,
13
+ o as thumb,
14
+ r as track
15
+ };
@@ -0,0 +1,58 @@
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { forwardRef as y, useRef as v, useCallback as c, useEffect as x } from "react";
3
+ import w from "clsx";
4
+ import t from "./Textarea.module.scss.js";
5
+ const C = {
6
+ none: "resizeNone",
7
+ vertical: "resizeVertical",
8
+ horizontal: "resizeHorizontal",
9
+ both: "resizeBoth"
10
+ }, H = y(
11
+ ({
12
+ inputSize: n = "md",
13
+ error: f = !1,
14
+ resize: u = "vertical",
15
+ autoExpand: r = !0,
16
+ className: h,
17
+ style: m,
18
+ onChange: l,
19
+ ...i
20
+ }, o) => {
21
+ const a = v(null), s = c(() => {
22
+ const e = a.current;
23
+ e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
24
+ }, []), z = i.value ?? "";
25
+ x(() => {
26
+ r && s();
27
+ }, [r, s, z]);
28
+ const p = c(
29
+ (e) => {
30
+ r && s(), l?.(e);
31
+ },
32
+ [r, s, l]
33
+ );
34
+ return /* @__PURE__ */ g(
35
+ "textarea",
36
+ {
37
+ ref: (e) => {
38
+ a.current = e, typeof o == "function" ? o(e) : o && (o.current = e);
39
+ },
40
+ className: w(
41
+ t.root,
42
+ t[n],
43
+ f && t.error,
44
+ r ? t.autoExpand : t[C[u]],
45
+ h
46
+ ),
47
+ style: m,
48
+ onChange: p,
49
+ rows: i.rows ?? 1,
50
+ ...i
51
+ }
52
+ );
53
+ }
54
+ );
55
+ H.displayName = "Textarea";
56
+ export {
57
+ H as Textarea
58
+ };
@@ -0,0 +1,25 @@
1
+ const r = "crk-root-IGgdn", o = "crk-sm-N-5I2", e = "crk-md-bbyFl", s = "crk-lg-Pd-Iq", t = "crk-error-fyu3i", c = "crk-resizeNone-SmNT4", n = "crk-resizeVertical-oi8vP", i = "crk-resizeHorizontal-riMLL", z = "crk-resizeBoth-NYSh4", a = "crk-autoExpand-JWone", l = {
2
+ root: r,
3
+ sm: o,
4
+ md: e,
5
+ lg: s,
6
+ error: t,
7
+ resizeNone: c,
8
+ resizeVertical: n,
9
+ resizeHorizontal: i,
10
+ resizeBoth: z,
11
+ autoExpand: a
12
+ };
13
+ export {
14
+ a as autoExpand,
15
+ l as default,
16
+ t as error,
17
+ s as lg,
18
+ e as md,
19
+ z as resizeBoth,
20
+ i as resizeHorizontal,
21
+ c as resizeNone,
22
+ n as resizeVertical,
23
+ r as root,
24
+ o as sm
25
+ };
@@ -0,0 +1,15 @@
1
+ import { useEffect as o } from "react";
2
+ function s(t, e, n = !0) {
3
+ o(() => {
4
+ if (!n) return;
5
+ const r = (u) => {
6
+ !t.current || t.current.contains(u.target) || e();
7
+ };
8
+ return document.addEventListener("mousedown", r), () => {
9
+ document.removeEventListener("mousedown", r);
10
+ };
11
+ }, [t, e, n]);
12
+ }
13
+ export {
14
+ s as useClickOutside
15
+ };
@@ -0,0 +1,39 @@
1
+ import { useRef as i, useCallback as a, useEffect as f } from "react";
2
+ const s = [
3
+ 'input:not([disabled]):not([type="hidden"])',
4
+ "button:not([disabled])",
5
+ "select:not([disabled])",
6
+ "textarea:not([disabled])",
7
+ "a[href]",
8
+ '[tabindex]:not([tabindex="-1"])'
9
+ ].join(", ");
10
+ function m(t, u) {
11
+ const o = i(null), r = a(
12
+ (e) => {
13
+ if (e.key !== "Tab" || !t.current)
14
+ return;
15
+ const n = Array.from(
16
+ t.current.querySelectorAll(s)
17
+ );
18
+ if (n.length === 0) {
19
+ e.preventDefault();
20
+ return;
21
+ }
22
+ const c = n[0], l = n[n.length - 1];
23
+ e.shiftKey ? document.activeElement === c && (e.preventDefault(), l.focus()) : document.activeElement === l && (e.preventDefault(), c.focus());
24
+ },
25
+ [t]
26
+ );
27
+ f(() => {
28
+ if (!u || !t.current)
29
+ return;
30
+ o.current = document.activeElement;
31
+ const e = t.current.querySelectorAll(s);
32
+ return e.length > 0 && e[0].focus(), document.addEventListener("keydown", r), () => {
33
+ document.removeEventListener("keydown", r), o.current instanceof HTMLElement && o.current.focus();
34
+ };
35
+ }, [u, t, r]);
36
+ }
37
+ export {
38
+ m as useFocusTrap
39
+ };
@@ -0,0 +1,19 @@
1
+ import { useCallback as u, useEffect as d } from "react";
2
+ function f(n, o = !0) {
3
+ const e = u(
4
+ (t) => {
5
+ const r = n[t.key];
6
+ r && r(t);
7
+ },
8
+ [n]
9
+ );
10
+ d(() => {
11
+ if (o)
12
+ return document.addEventListener("keydown", e), () => {
13
+ document.removeEventListener("keydown", e);
14
+ };
15
+ }, [o, e]);
16
+ }
17
+ export {
18
+ f as useKeyboard
19
+ };
@@ -0,0 +1,20 @@
1
+ import { useState as d, useLayoutEffect as u } from "react";
2
+ function f(n, o) {
3
+ const [i, s] = d({ top: 0, left: 0, width: 0 });
4
+ return u(() => {
5
+ if (!o) return;
6
+ const e = () => {
7
+ const r = n.current;
8
+ if (!r) return;
9
+ const t = r.getBoundingClientRect();
10
+ s({ top: t.bottom, left: t.left, width: t.width });
11
+ };
12
+ if (e(), !(typeof window > "u"))
13
+ return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
14
+ window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
15
+ };
16
+ }, [o, n]), i;
17
+ }
18
+ export {
19
+ f as usePortalPosition
20
+ };