@overdoser/react-toolkit 0.20.0 → 0.22.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 (212) hide show
  1. package/AGENTS.md +2 -1
  2. package/CHANGELOG.md +41 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.scss.js +19 -35
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.scss.js +24 -46
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +93 -96
  9. package/components/Alert/Alert.module.scss.js +17 -32
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.scss.js +22 -42
  12. package/components/Badge/Badge.js +15 -37
  13. package/components/Badge/Badge.module.scss.js +16 -30
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +9 -16
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.scss.js +24 -46
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.scss.js +34 -59
  21. package/components/Chart/AreaChart.d.ts +1 -1
  22. package/components/Chart/AreaChart.js +248 -249
  23. package/components/Chart/Axis.d.ts +2 -2
  24. package/components/Chart/Axis.js +34 -43
  25. package/components/Chart/BarChart.d.ts +1 -1
  26. package/components/Chart/BarChart.js +307 -348
  27. package/components/Chart/Chart.module.scss.js +31 -60
  28. package/components/Chart/ChartContainer.js +33 -41
  29. package/components/Chart/ChartLegend.d.ts +1 -1
  30. package/components/Chart/ChartLegend.js +31 -30
  31. package/components/Chart/ChartTooltip.d.ts +1 -1
  32. package/components/Chart/ChartTooltip.js +45 -40
  33. package/components/Chart/LineChart.d.ts +1 -1
  34. package/components/Chart/LineChart.js +220 -232
  35. package/components/Chart/PieChart.d.ts +1 -1
  36. package/components/Chart/PieChart.js +224 -240
  37. package/components/Chart/RadarChart.d.ts +1 -1
  38. package/components/Chart/RadarChart.js +166 -215
  39. package/components/Chart/Sparkline.js +73 -68
  40. package/components/Chart/TradingChart.d.ts +1 -1
  41. package/components/Chart/TradingChart.js +804 -701
  42. package/components/Chart/scales.js +28 -35
  43. package/components/Chart/trading/indicators.js +61 -62
  44. package/components/Chart/trading/period.js +46 -68
  45. package/components/Chart/useChartDimensions.js +30 -22
  46. package/components/Chip/Chip.js +98 -141
  47. package/components/Chip/Chip.module.scss.js +31 -58
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.scss.js +22 -42
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.scss.js +27 -48
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +11 -20
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.scss.js +16 -30
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.scss.js +9 -16
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.scss.js +65 -118
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.scss.js +28 -52
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +13 -11
  67. package/components/Dropdown/dropdownContext.js +4 -5
  68. package/components/Dropdown/useContextMenu.js +27 -17
  69. package/components/Dropzone/Dropzone.js +99 -105
  70. package/components/Dropzone/Dropzone.module.scss.js +11 -20
  71. package/components/EmptyState/EmptyState.js +57 -54
  72. package/components/EmptyState/EmptyState.module.scss.js +13 -24
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +31 -34
  75. package/components/Form/Form.module.scss.js +15 -28
  76. package/components/Form/FormField.d.ts +1 -1
  77. package/components/Form/FormField.js +71 -75
  78. package/components/Form/FormRow.d.ts +1 -1
  79. package/components/Form/FormRow.js +11 -8
  80. package/components/Form/formFieldDefaults.js +4 -5
  81. package/components/ImageViewer/ImageViewer.js +312 -201
  82. package/components/ImageViewer/ImageViewer.module.scss.js +25 -46
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +24 -21
  85. package/components/Kbd/Kbd.module.scss.js +9 -16
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.scss.js +22 -42
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.scss.js +9 -15
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.scss.js +11 -20
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.scss.js +39 -69
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.scss.js +17 -32
  96. package/components/PageHeader/PageHeader.js +79 -73
  97. package/components/PageHeader/PageHeader.module.scss.js +22 -42
  98. package/components/Pagination/Pagination.js +62 -83
  99. package/components/Pagination/Pagination.module.scss.js +12 -22
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.scss.js +11 -20
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +56 -89
  105. package/components/ProgressBar/ProgressBar.module.scss.js +28 -50
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.scss.js +3 -7
  108. package/components/SegmentedControl/SegmentedControl.js +93 -129
  109. package/components/SegmentedControl/SegmentedControl.module.scss.js +20 -38
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.scss.js +14 -24
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.scss.js +11 -19
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.scss.js +30 -56
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.scss.js +13 -24
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.scss.js +41 -71
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.scss.js +17 -31
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.scss.js +41 -80
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.scss.js +27 -52
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.scss.js +12 -22
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.scss.js +28 -54
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.scss.js +30 -58
  134. package/components/Timeline/Timeline.module.scss.js +75 -140
  135. package/components/Timeline/TimelineShared.d.ts +7 -7
  136. package/components/Timeline/TimelineShared.js +288 -279
  137. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  138. package/components/Timeline/TraceEventDetails.js +244 -177
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.scss.js +97 -188
  141. package/components/Timeline/historyLayout.js +336 -263
  142. package/components/Timeline/timelineCore.js +208 -183
  143. package/components/Timeline/traceEvent.js +59 -61
  144. package/components/Timeline/traceLayout.js +101 -90
  145. package/components/Timeline/useTimeline.js +76 -79
  146. package/components/Timer/Timer.js +190 -156
  147. package/components/Timer/Timer.module.scss.js +28 -54
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.scss.js +36 -61
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +36 -58
  153. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +14 -26
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.scss.js +16 -29
  157. package/components/Typography/Typography.js +10 -35
  158. package/components/Typography/Typography.module.scss.js +29 -52
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.scss.js +9 -16
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +16 -30
  163. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  164. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  165. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +22 -40
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.scss.js +13 -24
  168. package/components/inputs/DatePicker/dateUtils.js +32 -41
  169. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  170. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +19 -36
  171. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  172. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  173. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  174. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  175. package/components/inputs/Input/Input.js +98 -109
  176. package/components/inputs/Input/Input.module.scss.js +14 -26
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.scss.js +13 -24
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.scss.js +8 -14
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.scss.js +7 -12
  183. package/components/inputs/Select/Select.d.ts +55 -3
  184. package/components/inputs/Select/Select.js +696 -682
  185. package/components/inputs/Select/Select.module.scss.js +49 -72
  186. package/components/inputs/Slider/Slider.js +97 -128
  187. package/components/inputs/Slider/Slider.module.scss.js +8 -14
  188. package/components/inputs/Switch/Switch.js +11 -8
  189. package/components/inputs/Textarea/Textarea.js +42 -58
  190. package/components/inputs/Textarea/Textarea.module.scss.js +13 -24
  191. package/hooks/useClickOutside.js +17 -14
  192. package/hooks/useDebouncedValue.js +13 -14
  193. package/hooks/useElementSize.js +27 -22
  194. package/hooks/useEscapeLayer.js +28 -29
  195. package/hooks/useFocusTrap.js +27 -38
  196. package/hooks/useKeyboard.js +76 -64
  197. package/hooks/useMediaQuery.js +10 -15
  198. package/hooks/useNow.js +28 -33
  199. package/hooks/usePersistedState.js +98 -94
  200. package/hooks/usePortalPosition.d.ts +2 -1
  201. package/hooks/usePortalPosition.js +28 -19
  202. package/hooks/useResizable.js +106 -104
  203. package/hooks/useTheme.js +28 -23
  204. package/index.css +2 -1
  205. package/index.js +96 -214
  206. package/index.layered.css +2 -3
  207. package/llms.txt +28 -4
  208. package/manifest.json +41 -4
  209. package/package.json +1 -1
  210. package/utils/formatBytes.js +29 -13
  211. package/utils/themeScript.js +6 -8
  212. package/utils/timeAgo.js +59 -32
@@ -1,236 +1,224 @@
1
- import { jsx as l, jsxs as J, Fragment as xt } from "react/jsx-runtime";
2
- import { useMemo as ft, useState as yt, useRef as dt } from "react";
3
- import S from "clsx";
4
- import { ChartContainer as gt } from "./ChartContainer.js";
5
- import { ChartLegend as vt } from "./ChartLegend.js";
6
- import { ChartTooltip as pt } from "./ChartTooltip.js";
7
- import { YAxis as $t, XAxis as Mt } from "./Axis.js";
8
- import { bandScale as Q, extent as wt, niceTicks as Lt, linearScale as Ct } from "./scales.js";
9
- import g from "./Chart.module.scss.js";
10
- const Nt = { top: 12, right: 16, bottom: 28, left: 48 };
11
- function Rt(t, u) {
12
- if (t.length === 0) return "";
13
- if (t.length === 1) return `M ${t[0].x} ${t[0].y}`;
14
- if (u === "linear")
15
- return t.map((r, o) => `${o === 0 ? "M" : "L"} ${r.x} ${r.y}`).join(" ");
16
- if (u === "step") {
17
- let r = `M ${t[0].x} ${t[0].y}`;
18
- for (let o = 1; o < t.length; o++)
19
- r += ` L ${t[o].x} ${t[o - 1].y} L ${t[o].x} ${t[o].y}`;
20
- return r;
21
- }
22
- let i = `M ${t[0].x} ${t[0].y}`;
23
- for (let r = 0; r < t.length - 1; r++) {
24
- const o = t[r - 1] ?? t[r], f = t[r], h = t[r + 1], y = t[r + 2] ?? h, L = f.x + (h.x - o.x) / 6, $ = f.y + (h.y - o.y) / 6, A = h.x - (y.x - f.x) / 6, C = h.y - (y.y - f.y) / 6;
25
- i += ` C ${L} ${$}, ${A} ${C}, ${h.x} ${h.y}`;
26
- }
27
- return i;
1
+ import { useMemo as e, useRef as t, useState as n } from "react";
2
+ import r from "clsx";
3
+ import { ChartContainer as i } from "./ChartContainer.js";
4
+ import { ChartLegend as a } from "./ChartLegend.js";
5
+ import { ChartTooltip as o } from "./ChartTooltip.js";
6
+ import { XAxis as s, YAxis as c } from "./Axis.js";
7
+ import { bandScale as l, extent as u, linearScale as d, niceTicks as f } from "./scales.js";
8
+ import p from "./Chart.module.scss.js";
9
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
10
+ // src/components/Chart/LineChart.tsx
11
+ var _ = {
12
+ top: 12,
13
+ right: 16,
14
+ bottom: 28,
15
+ left: 48
16
+ };
17
+ function v(e, t) {
18
+ if (e.length === 0) return "";
19
+ if (e.length === 1) return `M ${e[0].x} ${e[0].y}`;
20
+ if (t === "linear") return e.map((e, t) => `${t === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
21
+ if (t === "step") {
22
+ let t = `M ${e[0].x} ${e[0].y}`;
23
+ for (let n = 1; n < e.length; n++) t += ` L ${e[n].x} ${e[n - 1].y} L ${e[n].x} ${e[n].y}`;
24
+ return t;
25
+ }
26
+ let n = `M ${e[0].x} ${e[0].y}`;
27
+ for (let t = 0; t < e.length - 1; t++) {
28
+ let r = e[t - 1] ?? e[t], i = e[t], a = e[t + 1], o = e[t + 2] ?? a, s = i.x + (a.x - r.x) / 6, c = i.y + (a.y - r.y) / 6, l = a.x - (o.x - i.x) / 6, u = a.y - (o.y - i.y) / 6;
29
+ n += ` C ${s} ${c}, ${l} ${u}, ${a.x} ${a.y}`;
30
+ }
31
+ return n;
28
32
  }
29
- function Tt(t, u = 8) {
30
- if (t.length <= u) return t;
31
- const i = Math.ceil(t.length / u);
32
- return t.filter((r, o) => o % i === 0);
33
+ function y(e, t = 8) {
34
+ if (e.length <= t) return e;
35
+ let n = Math.ceil(e.length / t);
36
+ return e.filter((e, t) => t % n === 0);
33
37
  }
34
- function Dt({
35
- data: t,
36
- xKey: u,
37
- config: i,
38
- aspectRatio: r = 16 / 9,
39
- height: o,
40
- curve: f = "monotone",
41
- showPoints: h = !0,
42
- dotColorKey: y,
43
- renderDot: L,
44
- showValues: $ = !1,
45
- valuePosition: A = "top",
46
- renderLabel: C,
47
- activeIndex: D,
48
- onPointClick: N,
49
- showGrid: V = !0,
50
- showLegend: Z = !0,
51
- showTooltip: P = !0,
52
- yTickCount: tt = 5,
53
- yFormat: et,
54
- xFormat: nt,
55
- valueFormat: K,
56
- renderTooltip: E,
57
- margin: rt,
58
- emptyMessage: ot = "No data",
59
- className: F,
60
- style: G,
61
- classes: v
62
- }) {
63
- const R = { ...Nt, ...rt }, H = ft(() => Object.keys(i), [i]), [ct, O] = yt(null), X = dt(null), d = D ?? ct, U = (T, _) => {
64
- if (y) {
65
- const m = t[_]?.[y];
66
- if (typeof m == "string") return m;
67
- }
68
- return i[T]?.color ?? "var(--crk-chart-1)";
69
- };
70
- if (t.length === 0)
71
- return /* @__PURE__ */ l("div", { ref: X, className: S(g.root, v?.root, F), style: G, children: /* @__PURE__ */ l("div", { className: g.canvas, style: { height: o ?? 240 }, children: /* @__PURE__ */ l("div", { className: g.empty, children: ot }) }) });
72
- const it = P && d !== null ? /* @__PURE__ */ l(
73
- pt,
74
- {
75
- row: t[d],
76
- x: bt(t, u, R, d, X),
77
- y: 16,
78
- containerWidth: X.current?.getBoundingClientRect().width ?? 0,
79
- config: i,
80
- render: E ? () => E(t[d]) : void 0,
81
- valueFormat: K,
82
- titleKey: u,
83
- resolveColor: y ? (T) => U(T, d) : void 0,
84
- classes: v
85
- }
86
- ) : null;
87
- return /* @__PURE__ */ l(
88
- gt,
89
- {
90
- ref: X,
91
- aspectRatio: r,
92
- height: o,
93
- className: F,
94
- style: G,
95
- classes: v,
96
- legend: Z ? /* @__PURE__ */ l(vt, { config: i, classes: v }) : void 0,
97
- overlay: it,
98
- children: ({ width: T, height: _ }) => {
99
- const m = R.left, Y = T - R.right, B = R.top, j = _ - R.bottom, q = Math.max(0, Y - m), lt = Math.max(0, j - B), b = t.map((e) => String(e[u])), M = Q(b, [m, Y], 0), z = [];
100
- for (const e of H)
101
- for (const p of t) {
102
- const x = p[e];
103
- typeof x == "number" && z.push(x);
104
- }
105
- const [st, at] = wt(z), ut = Math.min(0, st), W = Lt(ut, at, tt), I = Ct([W[0], W[W.length - 1]], [j, B]), ht = W.map((e) => ({ value: e, y: I(e) })), mt = Tt(b).map((e) => ({ label: e, x: M(e) }));
106
- return /* @__PURE__ */ J(xt, { children: [
107
- /* @__PURE__ */ l(
108
- $t,
109
- {
110
- ticks: ht,
111
- x: m,
112
- plotWidth: q,
113
- format: et,
114
- showGrid: V,
115
- classes: v
116
- }
117
- ),
118
- /* @__PURE__ */ l(Mt, { ticks: mt, y: j, format: nt, classes: v }),
119
- H.map((e) => {
120
- const p = i[e], x = t.map((n, c) => {
121
- const s = n[e], a = typeof s == "number" ? s : 0;
122
- return { x: M(b[c]), y: I(a), value: a, row: n };
123
- });
124
- return /* @__PURE__ */ J("g", { className: S(g.series, v?.series), children: [
125
- /* @__PURE__ */ l(
126
- "path",
127
- {
128
- className: S(g.linePath),
129
- d: Rt(x, f),
130
- stroke: p.color
131
- }
132
- ),
133
- h && x.map((n, c) => {
134
- const s = U(e, c), a = d === c, w = D !== void 0 && !a, k = N ? () => N({ row: n.row, value: n.value, seriesKey: e, index: c }) : void 0;
135
- return L ? /* @__PURE__ */ l(
136
- "g",
137
- {
138
- onClick: k,
139
- style: k ? { cursor: "pointer" } : void 0,
140
- opacity: w ? 0.45 : 1,
141
- children: L({
142
- row: n.row,
143
- value: n.value,
144
- seriesKey: e,
145
- index: c,
146
- x: n.x,
147
- y: n.y,
148
- color: s,
149
- active: a
150
- })
151
- },
152
- `${e}-${c}`
153
- ) : /* @__PURE__ */ l(
154
- "circle",
155
- {
156
- className: S(g.point, v?.point),
157
- cx: n.x,
158
- cy: n.y,
159
- r: a ? 5 : 3.5,
160
- fill: s,
161
- onClick: k,
162
- style: k ? { cursor: "pointer" } : void 0,
163
- opacity: w ? 0.45 : 1
164
- },
165
- `${e}-${c}`
166
- );
167
- }),
168
- ($ || C) && x.map((n, c) => {
169
- const s = C ? C({ row: n.row, value: n.value, seriesKey: e, index: c }) : $ ? K ? K(n.value) : String(n.value) : null;
170
- if (s == null) return null;
171
- const a = 10, w = A === "top" ? n.y - a : n.y + a + 4;
172
- return /* @__PURE__ */ l(
173
- "text",
174
- {
175
- className: S(g.axisLabel),
176
- x: n.x,
177
- y: w,
178
- textAnchor: "middle",
179
- dominantBaseline: A === "top" ? "auto" : "middle",
180
- children: s
181
- },
182
- `label-${e}-${c}`
183
- );
184
- })
185
- ] }, e);
186
- }),
187
- d !== null && /* @__PURE__ */ l(
188
- "line",
189
- {
190
- className: g.cursorLine,
191
- x1: M(b[d]),
192
- x2: M(b[d]),
193
- y1: B,
194
- y2: j
195
- }
196
- ),
197
- /* @__PURE__ */ l(
198
- "rect",
199
- {
200
- className: g.interactionLayer,
201
- x: m,
202
- y: B,
203
- width: q,
204
- height: lt,
205
- onMouseMove: (e) => {
206
- const p = e.currentTarget.getBoundingClientRect(), x = e.clientX - p.left + m, n = M.step(), c = Math.max(
207
- 0,
208
- Math.min(t.length - 1, Math.round((x - m - n / 2) / n))
209
- );
210
- O(c);
211
- },
212
- onMouseLeave: () => O(null),
213
- onClick: N ? (e) => {
214
- const p = e.currentTarget.getBoundingClientRect(), x = e.clientX - p.left + m, n = M.step(), c = Math.max(
215
- 0,
216
- Math.min(t.length - 1, Math.round((x - m - n / 2) / n))
217
- ), s = H[0], a = t[c][s], w = typeof a == "number" ? a : 0;
218
- N({ row: t[c], value: w, seriesKey: s, index: c });
219
- } : void 0,
220
- style: N ? { cursor: "pointer" } : void 0
221
- }
222
- )
223
- ] });
224
- }
225
- }
226
- );
38
+ function b({ data: b, xKey: S, config: C, aspectRatio: w = 16 / 9, height: T, curve: E = "monotone", showPoints: D = !0, dotColorKey: O, renderDot: k, showValues: A = !1, valuePosition: j = "top", renderLabel: M, activeIndex: N, onPointClick: P, showGrid: F = !0, showLegend: I = !0, showTooltip: L = !0, yTickCount: R = 5, yFormat: z, xFormat: B, valueFormat: V, renderTooltip: H, margin: U, emptyMessage: W = "No data", className: G, style: K, classes: q }) {
39
+ let J = {
40
+ ..._,
41
+ ...U
42
+ }, Y = e(() => Object.keys(C), [C]), [ee, X] = n(null), Z = t(null), Q = N ?? ee, $ = (e, t) => {
43
+ if (O) {
44
+ let e = b[t]?.[O];
45
+ if (typeof e == "string") return e;
46
+ }
47
+ return C[e]?.color ?? "var(--crk-chart-1)";
48
+ };
49
+ if (b.length === 0) return /* @__PURE__ */ h("div", {
50
+ ref: Z,
51
+ className: r(p.root, q?.root, G),
52
+ style: K,
53
+ children: /* @__PURE__ */ h("div", {
54
+ className: p.canvas,
55
+ style: { height: T ?? 240 },
56
+ children: /* @__PURE__ */ h("div", {
57
+ className: p.empty,
58
+ children: W
59
+ })
60
+ })
61
+ });
62
+ let te = L && Q !== null ? /* @__PURE__ */ h(o, {
63
+ row: b[Q],
64
+ x: x(b, S, J, Q, Z),
65
+ y: 16,
66
+ containerWidth: Z.current?.getBoundingClientRect().width ?? 0,
67
+ config: C,
68
+ render: H ? () => H(b[Q]) : void 0,
69
+ valueFormat: V,
70
+ titleKey: S,
71
+ resolveColor: O ? (e) => $(e, Q) : void 0,
72
+ classes: q
73
+ }) : null;
74
+ return /* @__PURE__ */ h(i, {
75
+ ref: Z,
76
+ aspectRatio: w,
77
+ height: T,
78
+ className: G,
79
+ style: K,
80
+ classes: q,
81
+ legend: I ? /* @__PURE__ */ h(a, {
82
+ config: C,
83
+ classes: q
84
+ }) : void 0,
85
+ overlay: te,
86
+ children: ({ width: e, height: t }) => {
87
+ let n = J.left, i = e - J.right, a = J.top, o = t - J.bottom, _ = Math.max(0, i - n), x = Math.max(0, o - a), w = b.map((e) => String(e[S])), T = l(w, [n, i], 0), O = [];
88
+ for (let e of Y) for (let t of b) {
89
+ let n = t[e];
90
+ typeof n == "number" && O.push(n);
91
+ }
92
+ let [I, L] = u(O), H = f(Math.min(0, I), L, R), U = d([H[0], H[H.length - 1]], [o, a]), W = H.map((e) => ({
93
+ value: e,
94
+ y: U(e)
95
+ })), G = y(w).map((e) => ({
96
+ label: e,
97
+ x: T(e)
98
+ }));
99
+ return /* @__PURE__ */ g(m, { children: [
100
+ /* @__PURE__ */ h(c, {
101
+ ticks: W,
102
+ x: n,
103
+ plotWidth: _,
104
+ format: z,
105
+ showGrid: F,
106
+ classes: q
107
+ }),
108
+ /* @__PURE__ */ h(s, {
109
+ ticks: G,
110
+ y: o,
111
+ format: B,
112
+ classes: q
113
+ }),
114
+ Y.map((e) => {
115
+ let t = C[e], n = b.map((t, n) => {
116
+ let r = t[e], i = typeof r == "number" ? r : 0;
117
+ return {
118
+ x: T(w[n]),
119
+ y: U(i),
120
+ value: i,
121
+ row: t
122
+ };
123
+ });
124
+ return /* @__PURE__ */ g("g", {
125
+ className: r(p.series, q?.series),
126
+ children: [
127
+ /* @__PURE__ */ h("path", {
128
+ className: r(p.linePath),
129
+ d: v(n, E),
130
+ stroke: t.color
131
+ }),
132
+ D && n.map((t, n) => {
133
+ let i = $(e, n), a = Q === n, o = N !== void 0 && !a, s = P ? () => P({
134
+ row: t.row,
135
+ value: t.value,
136
+ seriesKey: e,
137
+ index: n
138
+ }) : void 0;
139
+ return k ? /* @__PURE__ */ h("g", {
140
+ onClick: s,
141
+ style: s ? { cursor: "pointer" } : void 0,
142
+ opacity: o ? .45 : 1,
143
+ children: k({
144
+ row: t.row,
145
+ value: t.value,
146
+ seriesKey: e,
147
+ index: n,
148
+ x: t.x,
149
+ y: t.y,
150
+ color: i,
151
+ active: a
152
+ })
153
+ }, `${e}-${n}`) : /* @__PURE__ */ h("circle", {
154
+ className: r(p.point, q?.point),
155
+ cx: t.x,
156
+ cy: t.y,
157
+ r: a ? 5 : 3.5,
158
+ fill: i,
159
+ onClick: s,
160
+ style: s ? { cursor: "pointer" } : void 0,
161
+ opacity: o ? .45 : 1
162
+ }, `${e}-${n}`);
163
+ }),
164
+ (A || M) && n.map((t, n) => {
165
+ let i = M ? M({
166
+ row: t.row,
167
+ value: t.value,
168
+ seriesKey: e,
169
+ index: n
170
+ }) : A ? V ? V(t.value) : String(t.value) : null;
171
+ if (i == null) return null;
172
+ let a = j === "top" ? t.y - 10 : t.y + 10 + 4;
173
+ return /* @__PURE__ */ h("text", {
174
+ className: r(p.axisLabel),
175
+ x: t.x,
176
+ y: a,
177
+ textAnchor: "middle",
178
+ dominantBaseline: j === "top" ? "auto" : "middle",
179
+ children: i
180
+ }, `label-${e}-${n}`);
181
+ })
182
+ ]
183
+ }, e);
184
+ }),
185
+ Q !== null && /* @__PURE__ */ h("line", {
186
+ className: p.cursorLine,
187
+ x1: T(w[Q]),
188
+ x2: T(w[Q]),
189
+ y1: a,
190
+ y2: o
191
+ }),
192
+ /* @__PURE__ */ h("rect", {
193
+ className: p.interactionLayer,
194
+ x: n,
195
+ y: a,
196
+ width: _,
197
+ height: x,
198
+ onMouseMove: (e) => {
199
+ let t = e.currentTarget.getBoundingClientRect(), r = e.clientX - t.left + n, i = T.step(), a = Math.max(0, Math.min(b.length - 1, Math.round((r - n - i / 2) / i)));
200
+ X(a);
201
+ },
202
+ onMouseLeave: () => X(null),
203
+ onClick: P ? (e) => {
204
+ let t = e.currentTarget.getBoundingClientRect(), r = e.clientX - t.left + n, i = T.step(), a = Math.max(0, Math.min(b.length - 1, Math.round((r - n - i / 2) / i))), o = Y[0], s = b[a][o], c = typeof s == "number" ? s : 0;
205
+ P({
206
+ row: b[a],
207
+ value: c,
208
+ seriesKey: o,
209
+ index: a
210
+ });
211
+ } : void 0,
212
+ style: P ? { cursor: "pointer" } : void 0
213
+ })
214
+ ] });
215
+ }
216
+ });
227
217
  }
228
- function bt(t, u, i, r, o) {
229
- const f = o.current;
230
- if (!f) return 0;
231
- const h = f.getBoundingClientRect().width, y = t.map(($) => String($[u]));
232
- return Q(y, [i.left, h - i.right], 0)(y[r]);
218
+ function x(e, t, n, r, i) {
219
+ let a = i.current;
220
+ if (!a) return 0;
221
+ let o = a.getBoundingClientRect().width, s = e.map((e) => String(e[t]));
222
+ return l(s, [n.left, o - n.right], 0)(s[r]);
233
223
  }
234
- export {
235
- Dt as LineChart
236
- };
224
+ export { b as LineChart };
@@ -97,4 +97,4 @@ export interface PieChartProps<T extends Record<string, unknown>> {
97
97
  * centerLabel={<strong>475</strong>}
98
98
  * />
99
99
  */
100
- export declare function PieChart<T extends Record<string, unknown>>({ data, valueKey, nameKey, colorKey, colors, aspectRatio, height, innerRadius, outerRadius, strokeWidth, strokeColor, padAngle, showLabels, valuePosition, showLabelLines, renderLabel, centerLabel, activeIndex, onSliceClick, showLegend, showTooltip, valueFormat, renderTooltip, emptyMessage, className, style, classes, }: PieChartProps<T>): import("react/jsx-runtime").JSX.Element;
100
+ export declare function PieChart<T extends Record<string, unknown>>({ data, valueKey, nameKey, colorKey, colors, aspectRatio, height, innerRadius, outerRadius, strokeWidth, strokeColor, padAngle, showLabels, valuePosition, showLabelLines, renderLabel, centerLabel, activeIndex, onSliceClick, showLegend, showTooltip, valueFormat, renderTooltip, emptyMessage, className, style, classes, }: PieChartProps<T>): import("react").JSX.Element;