@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,25 @@
1
+ const c = "crk-root-KIhSk", s = "crk-info--J-F1", n = "crk-success-lftZT", o = "crk-warning-uOpos", t = "crk-danger-53-01", e = "crk-icon-RUu7X", r = "crk-content-9Fty2", i = "crk-title-QHuwO", a = "crk-message-Wd9FZ", k = "crk-close-yMuK-", g = {
2
+ root: c,
3
+ info: s,
4
+ success: n,
5
+ warning: o,
6
+ danger: t,
7
+ icon: e,
8
+ content: r,
9
+ title: i,
10
+ message: a,
11
+ close: k
12
+ };
13
+ export {
14
+ k as close,
15
+ r as content,
16
+ t as danger,
17
+ g as default,
18
+ e as icon,
19
+ s as info,
20
+ a as message,
21
+ c as root,
22
+ n as success,
23
+ i as title,
24
+ o as warning
25
+ };
@@ -0,0 +1,57 @@
1
+ import { jsxs as x, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as N, useState as w, useEffect as b } from "react";
3
+ import l from "clsx";
4
+ import r from "./Avatar.module.scss.js";
5
+ function A(e) {
6
+ const t = e.trim().split(/\s+/).filter(Boolean);
7
+ return t.length === 0 ? "" : t.length === 1 ? t[0].slice(0, 2).toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
8
+ }
9
+ const C = N(
10
+ ({ src: e, alt: t, name: i, fallback: c, size: f = "md", shape: m = "circle", status: s, classes: o, className: p, ...u }, d) => {
11
+ const [h, n] = w(!1);
12
+ b(() => n(!1), [e]);
13
+ const g = e && !h, v = i ? A(i) : "";
14
+ return /* @__PURE__ */ x(
15
+ "span",
16
+ {
17
+ ref: d,
18
+ className: l(r.root, r[f], r[m], o?.root, p),
19
+ ...u,
20
+ children: [
21
+ g ? /* @__PURE__ */ a(
22
+ "img",
23
+ {
24
+ className: l(r.image, o?.image),
25
+ src: e,
26
+ alt: t ?? i ?? "",
27
+ onError: () => n(!0)
28
+ }
29
+ ) : /* @__PURE__ */ a(
30
+ "span",
31
+ {
32
+ className: l(r.fallback, o?.fallback),
33
+ role: "img",
34
+ "aria-label": t ?? i ?? "Avatar",
35
+ children: c ?? (v || /* @__PURE__ */ a(U, {}))
36
+ }
37
+ ),
38
+ s && /* @__PURE__ */ a(
39
+ "span",
40
+ {
41
+ className: l(r.status, r[`status_${s}`], o?.status),
42
+ "data-status": s,
43
+ "aria-hidden": "true"
44
+ }
45
+ )
46
+ ]
47
+ }
48
+ );
49
+ }
50
+ );
51
+ C.displayName = "Avatar";
52
+ function U() {
53
+ return /* @__PURE__ */ a("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", width: "60%", height: "60%", children: /* @__PURE__ */ a("path", { d: "M12 12a5 5 0 100-10 5 5 0 000 10zm0 2c-4.4 0-8 2.7-8 6v1h16v-1c0-3.3-3.6-6-8-6z" }) });
54
+ }
55
+ export {
56
+ C as Avatar
57
+ };
@@ -0,0 +1,43 @@
1
+ const s = "crk-root-1YbL5", t = "crk-xs-1SMBv", a = "crk-sm-8TB22", c = "crk-md-zeW0d", n = "crk-lg-MWKN-", o = "crk-xl-KCqIL", u = "crk-circle-nzLby", l = "crk-square-JrlyG", r = "crk-image-HFFlp", e = "crk-fallback-R4J-V", k = "crk-status-e4HnT", i = "crk-status_online-bny3b", y = "crk-status_online-bny3b", f = "crk-status_offline-xxp2c", _ = "crk-status_offline-xxp2c", b = "crk-status_away-coReU", x = "crk-status_away-coReU", m = "crk-status_busy-aOHjE", g = "crk-status_busy-aOHjE", w = {
2
+ root: s,
3
+ xs: t,
4
+ sm: a,
5
+ md: c,
6
+ lg: n,
7
+ xl: o,
8
+ circle: u,
9
+ square: l,
10
+ image: r,
11
+ fallback: e,
12
+ status: k,
13
+ status_online: i,
14
+ statusOnline: y,
15
+ status_offline: f,
16
+ statusOffline: _,
17
+ status_away: b,
18
+ statusAway: x,
19
+ status_busy: m,
20
+ statusBusy: g
21
+ };
22
+ export {
23
+ u as circle,
24
+ w as default,
25
+ e as fallback,
26
+ r as image,
27
+ n as lg,
28
+ c as md,
29
+ s as root,
30
+ a as sm,
31
+ l as square,
32
+ k as status,
33
+ x as statusAway,
34
+ g as statusBusy,
35
+ _ as statusOffline,
36
+ y as statusOnline,
37
+ b as status_away,
38
+ m as status_busy,
39
+ f as status_offline,
40
+ i as status_online,
41
+ o as xl,
42
+ t as xs
43
+ };
@@ -0,0 +1,38 @@
1
+ import { jsxs as l, jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as c } from "react";
3
+ import t from "clsx";
4
+ import r from "./Badge.module.scss.js";
5
+ const x = c(
6
+ ({
7
+ variant: a = "neutral",
8
+ appearance: e = "soft",
9
+ size: s = "md",
10
+ dot: m = !1,
11
+ classes: o,
12
+ className: d,
13
+ children: f,
14
+ ...i
15
+ }, p) => /* @__PURE__ */ l(
16
+ "span",
17
+ {
18
+ ref: p,
19
+ className: t(
20
+ r.root,
21
+ r[a],
22
+ r[e],
23
+ r[s],
24
+ o?.root,
25
+ d
26
+ ),
27
+ ...i,
28
+ children: [
29
+ m && /* @__PURE__ */ n("span", { className: t(r.dot, o?.dot), "aria-hidden": "true" }),
30
+ f
31
+ ]
32
+ }
33
+ )
34
+ );
35
+ x.displayName = "Badge";
36
+ export {
37
+ x as Badge
38
+ };
@@ -0,0 +1,31 @@
1
+ const s = "crk-root-KSuIQ", c = "crk-sm--vFVn", o = "crk-md-zmWkB", n = "crk-lg-vhZlR", r = "crk-neutral-RdrgV", t = "crk-primary-wn6-R", e = "crk-success-DMnu3", k = "crk-warning-4IHkk", l = "crk-danger-nwbtA", a = "crk-soft-D7eFo", d = "crk-solid-OAgyP", i = "crk-outline-2IwcH", u = "crk-dot-KeAKh", g = {
2
+ root: s,
3
+ sm: c,
4
+ md: o,
5
+ lg: n,
6
+ neutral: r,
7
+ primary: t,
8
+ success: e,
9
+ warning: k,
10
+ danger: l,
11
+ soft: a,
12
+ solid: d,
13
+ outline: i,
14
+ dot: u
15
+ };
16
+ export {
17
+ l as danger,
18
+ g as default,
19
+ u as dot,
20
+ n as lg,
21
+ o as md,
22
+ r as neutral,
23
+ i as outline,
24
+ t as primary,
25
+ s as root,
26
+ c as sm,
27
+ a as soft,
28
+ d as solid,
29
+ e as success,
30
+ k as warning
31
+ };
@@ -0,0 +1,49 @@
1
+ import { jsx as e, jsxs as j } from "react/jsx-runtime";
2
+ import { forwardRef as k, Children as v, isValidElement as C } from "react";
3
+ import a from "clsx";
4
+ import t from "./Breadcrumbs.module.scss.js";
5
+ function f({ href: n, current: s = !1, children: i, className: r, ...m }) {
6
+ return /* @__PURE__ */ e("li", { className: r, ...m, children: s || !n ? /* @__PURE__ */ e("span", { "aria-current": s ? "page" : void 0, children: i }) : /* @__PURE__ */ e("a", { href: n, children: i }) });
7
+ }
8
+ f.displayName = "Breadcrumbs.Item";
9
+ const h = k(
10
+ ({ children: n, separator: s = "/", label: i = "Breadcrumb", classes: r, className: m, ...b }, B) => {
11
+ const o = v.toArray(n).filter(C);
12
+ return /* @__PURE__ */ e(
13
+ "nav",
14
+ {
15
+ ref: B,
16
+ "aria-label": i,
17
+ className: a(t.root, r?.root, m),
18
+ ...b,
19
+ children: /* @__PURE__ */ e("ol", { className: a(t.list, r?.list), children: o.map((c, l) => {
20
+ const d = l === o.length - 1, y = c.props ?? {}, { href: p, current: g, children: u, className: x } = y, N = g ?? d;
21
+ return /* @__PURE__ */ j(
22
+ "li",
23
+ {
24
+ className: a(t.item, r?.item, x),
25
+ children: [
26
+ N || !p ? /* @__PURE__ */ e(
27
+ "span",
28
+ {
29
+ className: a(t.current, r?.current),
30
+ "aria-current": N ? "page" : void 0,
31
+ children: u
32
+ }
33
+ ) : /* @__PURE__ */ e("a", { className: a(t.link, r?.link), href: p, children: u }),
34
+ !d && /* @__PURE__ */ e("span", { className: a(t.separator, r?.separator), "aria-hidden": "true", children: s })
35
+ ]
36
+ },
37
+ c.key ?? l
38
+ );
39
+ }) })
40
+ }
41
+ );
42
+ }
43
+ );
44
+ h.displayName = "Breadcrumbs";
45
+ const E = Object.assign(h, { Item: f });
46
+ export {
47
+ f as BreadcrumbItem,
48
+ E as Breadcrumbs
49
+ };
@@ -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
+ };