@overdoser/react-toolkit 0.6.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 (116) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +82 -0
  3. package/components/ActionButton/ActionButton.d.ts +105 -0
  4. package/components/ActionButton/ActionButton.js +211 -0
  5. package/components/ActionButton/ActionButton.module.scss.js +47 -0
  6. package/components/ActionButton/CopyButton.d.ts +31 -0
  7. package/components/ActionButton/CopyButton.js +66 -0
  8. package/components/ActionButton/index.d.ts +4 -0
  9. package/components/Alert/Alert.js +82 -0
  10. package/components/Alert/Alert.module.scss.js +25 -0
  11. package/components/Avatar/Avatar.js +57 -0
  12. package/components/Avatar/Avatar.module.scss.js +43 -0
  13. package/components/Badge/Badge.js +38 -0
  14. package/components/Badge/Badge.module.scss.js +31 -0
  15. package/components/Breadcrumbs/Breadcrumbs.js +49 -0
  16. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
  17. package/components/Button/Button.js +57 -0
  18. package/components/Button/Button.module.scss.js +47 -0
  19. package/components/Chart/AreaChart.js +244 -0
  20. package/components/Chart/Axis.js +45 -0
  21. package/components/Chart/BarChart.js +353 -0
  22. package/components/Chart/Chart.module.scss.js +61 -0
  23. package/components/Chart/ChartContainer.js +41 -0
  24. package/components/Chart/ChartLegend.js +31 -0
  25. package/components/Chart/ChartTooltip.js +42 -0
  26. package/components/Chart/LineChart.js +236 -0
  27. package/components/Chart/PieChart.js +248 -0
  28. package/components/Chart/RadarChart.js +221 -0
  29. package/components/Chart/Sparkline.js +69 -0
  30. package/components/Chart/TradingChart.js +732 -0
  31. package/components/Chart/scales.js +39 -0
  32. package/components/Chart/trading/indicators.js +68 -0
  33. package/components/Chart/trading/period.js +71 -0
  34. package/components/Chart/useChartDimensions.js +23 -0
  35. package/components/Divider/Divider.js +36 -0
  36. package/components/Divider/Divider.module.scss.js +31 -0
  37. package/components/Draggable/Draggable.js +155 -0
  38. package/components/Draggable/Draggable.module.scss.js +17 -0
  39. package/components/Drawer/Drawer.js +126 -0
  40. package/components/Drawer/Drawer.module.scss.js +117 -0
  41. package/components/Dropdown/Dropdown.js +142 -0
  42. package/components/Dropdown/Dropdown.module.scss.js +35 -0
  43. package/components/Dropdown/DropdownItem.js +31 -0
  44. package/components/Dropzone/Dropzone.js +107 -0
  45. package/components/Dropzone/Dropzone.module.scss.js +21 -0
  46. package/components/Form/Form.js +36 -0
  47. package/components/Form/Form.module.scss.js +29 -0
  48. package/components/Form/FormField.js +76 -0
  49. package/components/Form/FormRow.js +9 -0
  50. package/components/Form/formFieldDefaults.js +5 -0
  51. package/components/Link/Link.js +59 -0
  52. package/components/Link/Link.module.scss.js +16 -0
  53. package/components/List/List.js +46 -0
  54. package/components/List/List.module.scss.js +21 -0
  55. package/components/Modal/Modal.js +109 -0
  56. package/components/Modal/Modal.module.scss.js +31 -0
  57. package/components/Pagination/Pagination.js +84 -0
  58. package/components/Pagination/Pagination.module.scss.js +23 -0
  59. package/components/Pagination/paginationRange.js +24 -0
  60. package/components/Popover/Popover.js +138 -0
  61. package/components/Popover/Popover.module.scss.js +21 -0
  62. package/components/Skeleton/Skeleton.js +50 -0
  63. package/components/Skeleton/Skeleton.module.scss.js +25 -0
  64. package/components/Spinner/Spinner.js +25 -0
  65. package/components/Spinner/Spinner.module.scss.js +20 -0
  66. package/components/Table/Table.d.ts +61 -6
  67. package/components/Table/Table.js +284 -0
  68. package/components/Table/Table.module.scss.js +59 -0
  69. package/components/Table/useTableSort.d.ts +7 -5
  70. package/components/Table/useTableSort.js +44 -0
  71. package/components/Tabs/Tabs.js +163 -0
  72. package/components/Tabs/Tabs.module.scss.js +53 -0
  73. package/components/Timer/Timer.js +159 -0
  74. package/components/Timer/Timer.module.scss.js +55 -0
  75. package/components/Toast/Toast.js +133 -0
  76. package/components/Toast/Toast.module.scss.js +62 -0
  77. package/components/Toast/toastStore.js +62 -0
  78. package/components/ToggleIconButton/ToggleIconButton.d.ts +62 -0
  79. package/components/ToggleIconButton/ToggleIconButton.js +58 -0
  80. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
  81. package/components/ToggleIconButton/index.d.ts +2 -0
  82. package/components/Tooltip/Tooltip.js +86 -0
  83. package/components/Tooltip/Tooltip.module.scss.js +30 -0
  84. package/components/Typography/Typography.js +37 -0
  85. package/components/Typography/Typography.module.scss.js +53 -0
  86. package/components/inputs/Checkbox/Checkbox.js +50 -0
  87. package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
  88. package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
  89. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
  90. package/components/inputs/DatePicker/DatePicker.js +229 -0
  91. package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
  92. package/components/inputs/DatePicker/dateUtils.js +41 -0
  93. package/components/inputs/Input/Input.js +50 -0
  94. package/components/inputs/Input/Input.module.scss.js +25 -0
  95. package/components/inputs/NumberInput/NumberInput.js +134 -0
  96. package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
  97. package/components/inputs/Radio/Radio.js +68 -0
  98. package/components/inputs/Radio/Radio.module.scss.js +13 -0
  99. package/components/inputs/Select/Select.js +520 -0
  100. package/components/inputs/Select/Select.module.scss.js +69 -0
  101. package/components/inputs/Slider/Slider.js +128 -0
  102. package/components/inputs/Slider/Slider.module.scss.js +15 -0
  103. package/components/inputs/Textarea/Textarea.js +58 -0
  104. package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
  105. package/hooks/useClickOutside.js +15 -0
  106. package/hooks/useFocusTrap.js +39 -0
  107. package/hooks/useKeyboard.js +19 -0
  108. package/hooks/usePortalPosition.js +20 -0
  109. package/index.css +1 -1
  110. package/index.d.ts +4 -0
  111. package/index.js +119 -6575
  112. package/index.layered.css +1 -1
  113. package/llms.txt +123 -5
  114. package/manifest.json +230 -2
  115. package/package.json +3 -2
  116. package/recipes/comparison-table.tsx +123 -0
@@ -0,0 +1,41 @@
1
+ function f(t) {
2
+ return new Date(t.getFullYear(), t.getMonth(), t.getDate());
3
+ }
4
+ function s(t, e) {
5
+ return !t || !e ? !1 : t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
6
+ }
7
+ function i(t, e) {
8
+ return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth();
9
+ }
10
+ function a(t, e) {
11
+ return new Date(t.getFullYear(), t.getMonth(), t.getDate() + e);
12
+ }
13
+ function D(t, e) {
14
+ return new Date(t.getFullYear(), t.getMonth() + e, 1);
15
+ }
16
+ function l(t) {
17
+ return new Date(t.getFullYear(), t.getMonth(), 1);
18
+ }
19
+ function c(t) {
20
+ const e = (n) => String(n).padStart(2, "0");
21
+ return `${t.getFullYear()}-${e(t.getMonth() + 1)}-${e(t.getDate())}`;
22
+ }
23
+ function h(t, e) {
24
+ const n = l(t), r = (n.getDay() - e + 7) % 7, o = a(n, -r);
25
+ return Array.from({ length: 42 }, (u, g) => a(o, g));
26
+ }
27
+ function M(t, e) {
28
+ const n = new Intl.DateTimeFormat(t, { weekday: "short" }), r = new Date(2023, 0, 1);
29
+ return Array.from({ length: 7 }, (o, u) => n.format(a(r, (e + u) % 7)));
30
+ }
31
+ export {
32
+ a as addDays,
33
+ D as addMonths,
34
+ h as buildCalendarDays,
35
+ s as isSameDay,
36
+ i as isSameMonth,
37
+ f as startOfDay,
38
+ l as startOfMonth,
39
+ c as toISODate,
40
+ M as weekdayLabels
41
+ };
@@ -0,0 +1,50 @@
1
+ import { jsx as n, jsxs as h } from "react/jsx-runtime";
2
+ import { forwardRef as N } from "react";
3
+ import a from "clsx";
4
+ import r from "./Input.module.scss.js";
5
+ const u = N(
6
+ ({
7
+ inputSize: e = "md",
8
+ error: p = !1,
9
+ prefix: o,
10
+ suffix: t,
11
+ classes: m,
12
+ className: d,
13
+ style: l,
14
+ ...i
15
+ }, c) => {
16
+ const s = /* @__PURE__ */ n(
17
+ "input",
18
+ {
19
+ ref: c,
20
+ className: a(
21
+ r.root,
22
+ r[e],
23
+ p && r.error,
24
+ o && r.hasPrefix,
25
+ t && r.hasSuffix,
26
+ m?.root,
27
+ !o && !t && d
28
+ ),
29
+ style: !o && !t ? l : void 0,
30
+ ...i
31
+ }
32
+ );
33
+ return o || t ? /* @__PURE__ */ h(
34
+ "div",
35
+ {
36
+ className: a(r.wrapper, r[e], p && r.error, m?.wrapper, d),
37
+ style: l,
38
+ children: [
39
+ o && /* @__PURE__ */ n("span", { className: a(r.prefix, m?.prefix), children: o }),
40
+ s,
41
+ t && /* @__PURE__ */ n("span", { className: a(r.suffix, m?.suffix), children: t })
42
+ ]
43
+ }
44
+ ) : s;
45
+ }
46
+ );
47
+ u.displayName = "Input";
48
+ export {
49
+ u as Input
50
+ };
@@ -0,0 +1,25 @@
1
+ const r = "crk-root-rSgdy", s = "crk-wrapper-GHy8V", c = "crk-sm-DptM5", f = "crk-md-F4B0G", o = "crk-lg-pBxwX", t = "crk-error-fucxe", e = "crk-prefix-w53Md", x = "crk-suffix-fcNgR", i = "crk-hasPrefix--bqPD", n = "crk-hasSuffix-zO0nX", p = {
2
+ root: r,
3
+ wrapper: s,
4
+ sm: c,
5
+ md: f,
6
+ lg: o,
7
+ error: t,
8
+ prefix: e,
9
+ suffix: x,
10
+ hasPrefix: i,
11
+ hasSuffix: n
12
+ };
13
+ export {
14
+ p as default,
15
+ t as error,
16
+ i as hasPrefix,
17
+ n as hasSuffix,
18
+ o as lg,
19
+ f as md,
20
+ e as prefix,
21
+ r as root,
22
+ c as sm,
23
+ x as suffix,
24
+ s as wrapper
25
+ };
@@ -0,0 +1,134 @@
1
+ import { jsxs as S, jsx as i } from "react/jsx-runtime";
2
+ import { forwardRef as T, useState as U, useRef as V, useEffect as q, useCallback as M } from "react";
3
+ import f from "clsx";
4
+ import r from "./NumberInput.module.scss.js";
5
+ const g = (n) => {
6
+ if (n.trim() === "") return null;
7
+ const p = Number(n);
8
+ return Number.isNaN(p) ? null : p;
9
+ }, z = T(
10
+ ({
11
+ value: n,
12
+ defaultValue: p,
13
+ onChange: b,
14
+ min: o,
15
+ max: s,
16
+ step: x = 1,
17
+ precision: k,
18
+ inputSize: j = "md",
19
+ error: D = !1,
20
+ hideControls: B = !1,
21
+ disabled: l,
22
+ classes: d,
23
+ className: L,
24
+ style: R,
25
+ onKeyDown: A,
26
+ onBlur: F,
27
+ ...C
28
+ }, K) => {
29
+ const u = n !== void 0, I = (u ? n : p) ?? null, [v, m] = U(I != null ? String(I) : ""), N = V(!1), a = u ? n ?? null : g(v);
30
+ q(() => {
31
+ u && !N.current && m(n != null ? String(n) : "");
32
+ }, [u, n]);
33
+ const y = M(
34
+ (t) => {
35
+ let e = t;
36
+ if (o != null && (e = Math.max(o, e)), s != null && (e = Math.min(s, e)), k != null) {
37
+ const c = 10 ** k;
38
+ e = Math.round(e * c) / c;
39
+ }
40
+ return e;
41
+ },
42
+ [o, s, k]
43
+ ), w = M(
44
+ (t) => {
45
+ u || m(t != null ? String(t) : ""), b?.(t);
46
+ },
47
+ [u, b]
48
+ ), h = M(
49
+ (t) => {
50
+ if (l) return;
51
+ w(y((a ?? o ?? 0) + t * x));
52
+ },
53
+ [l, a, o, x, y, w]
54
+ ), W = s != null && a != null && a >= s, E = o != null && a != null && a <= o, P = (t) => {
55
+ A?.(t), !t.defaultPrevented && (t.key === "ArrowUp" ? (t.preventDefault(), h(1)) : t.key === "ArrowDown" && (t.preventDefault(), h(-1)));
56
+ };
57
+ return /* @__PURE__ */ S(
58
+ "div",
59
+ {
60
+ className: f(
61
+ r.root,
62
+ r[j],
63
+ D && r.error,
64
+ l && r.disabled,
65
+ d?.root,
66
+ L
67
+ ),
68
+ style: R,
69
+ "data-disabled": l || void 0,
70
+ children: [
71
+ /* @__PURE__ */ i(
72
+ "input",
73
+ {
74
+ ref: K,
75
+ type: "text",
76
+ inputMode: "decimal",
77
+ className: f(r.input, d?.input),
78
+ value: v,
79
+ disabled: l,
80
+ "aria-invalid": D || void 0,
81
+ onChange: (t) => {
82
+ m(t.target.value), b?.(g(t.target.value));
83
+ },
84
+ onKeyDown: P,
85
+ onFocus: (t) => {
86
+ N.current = !0, C.onFocus?.(t);
87
+ },
88
+ onBlur: (t) => {
89
+ N.current = !1;
90
+ const e = g(v);
91
+ if (e != null) {
92
+ const c = y(e);
93
+ c !== e ? w(c) : m(String(c));
94
+ }
95
+ F?.(t);
96
+ },
97
+ ...C
98
+ }
99
+ ),
100
+ !B && /* @__PURE__ */ S("div", { className: f(r.controls, d?.controls), children: [
101
+ /* @__PURE__ */ i(
102
+ "button",
103
+ {
104
+ type: "button",
105
+ tabIndex: -1,
106
+ className: f(r.increment, d?.increment),
107
+ onClick: () => h(1),
108
+ disabled: l || W,
109
+ "aria-label": "Increment",
110
+ children: /* @__PURE__ */ i("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", children: /* @__PURE__ */ i("path", { d: "M1 5l4-4 4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
111
+ }
112
+ ),
113
+ /* @__PURE__ */ i(
114
+ "button",
115
+ {
116
+ type: "button",
117
+ tabIndex: -1,
118
+ className: f(r.decrement, d?.decrement),
119
+ onClick: () => h(-1),
120
+ disabled: l || E,
121
+ "aria-label": "Decrement",
122
+ children: /* @__PURE__ */ i("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", children: /* @__PURE__ */ i("path", { d: "M1 1l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
123
+ }
124
+ )
125
+ ] })
126
+ ]
127
+ }
128
+ );
129
+ }
130
+ );
131
+ z.displayName = "NumberInput";
132
+ export {
133
+ z as NumberInput
134
+ };
@@ -0,0 +1,25 @@
1
+ const r = "crk-root-aUI4c", c = "crk-sm-t2zR2", t = "crk-input-82UG6", n = "crk-md-v4bFw", o = "crk-lg-mr8pf", e = "crk-controls-0vTT8", s = "crk-increment-nc4uY", m = "crk-decrement-076EO", d = "crk-error-1BkEa", k = "crk-disabled-mk7uC", l = {
2
+ root: r,
3
+ sm: c,
4
+ input: t,
5
+ md: n,
6
+ lg: o,
7
+ controls: e,
8
+ increment: s,
9
+ decrement: m,
10
+ error: d,
11
+ disabled: k
12
+ };
13
+ export {
14
+ e as controls,
15
+ m as decrement,
16
+ l as default,
17
+ k as disabled,
18
+ d as error,
19
+ s as increment,
20
+ t as input,
21
+ o as lg,
22
+ n as md,
23
+ r as root,
24
+ c as sm
25
+ };
@@ -0,0 +1,68 @@
1
+ import { jsxs as f, jsx as t } from "react/jsx-runtime";
2
+ import { forwardRef as g, useContext as y, createContext as R } from "react";
3
+ import l from "clsx";
4
+ import n from "./Radio.module.scss.js";
5
+ const b = R(null), v = ({
6
+ name: o,
7
+ value: e,
8
+ onChange: a,
9
+ className: i,
10
+ style: d,
11
+ children: s,
12
+ id: p,
13
+ "aria-label": c,
14
+ "aria-labelledby": m,
15
+ required: u
16
+ }) => /* @__PURE__ */ t(b.Provider, { value: { name: o, value: e, onChange: a }, children: /* @__PURE__ */ t(
17
+ "div",
18
+ {
19
+ id: p,
20
+ className: l(n.group, i),
21
+ style: d,
22
+ role: "radiogroup",
23
+ tabIndex: -1,
24
+ "aria-label": c,
25
+ "aria-labelledby": m,
26
+ "aria-required": u || void 0,
27
+ children: s
28
+ }
29
+ ) });
30
+ v.displayName = "RadioGroup";
31
+ const G = g(
32
+ ({
33
+ label: o,
34
+ value: e,
35
+ classes: a,
36
+ className: i,
37
+ style: d,
38
+ onChange: s,
39
+ checked: p,
40
+ name: c,
41
+ ...m
42
+ }, u) => {
43
+ const r = y(b), h = r?.name ?? c, x = r ? r.value === e : p, C = (N) => {
44
+ r?.onChange?.(e), s?.(N);
45
+ };
46
+ return /* @__PURE__ */ f("label", { className: l(n.root, a?.root, i), style: d, children: [
47
+ /* @__PURE__ */ t(
48
+ "input",
49
+ {
50
+ ref: u,
51
+ type: "radio",
52
+ className: l(n.input, a?.input),
53
+ name: h,
54
+ value: e,
55
+ checked: x,
56
+ onChange: C,
57
+ ...m
58
+ }
59
+ ),
60
+ o && /* @__PURE__ */ t("span", { className: l(n.label, a?.label), children: o })
61
+ ] });
62
+ }
63
+ );
64
+ G.displayName = "Radio";
65
+ export {
66
+ G as Radio,
67
+ v as RadioGroup
68
+ };
@@ -0,0 +1,13 @@
1
+ const o = "crk-group-NNwCD", t = "crk-root-7fGik", r = "crk-input-43PQW", c = "crk-label-aW30x", l = {
2
+ group: o,
3
+ root: t,
4
+ input: r,
5
+ label: c
6
+ };
7
+ export {
8
+ l as default,
9
+ o as group,
10
+ r as input,
11
+ c as label,
12
+ t as root
13
+ };