@overdoser/react-toolkit 0.20.0 → 0.21.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 (273) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.js +20 -0
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.js +25 -0
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +92 -95
  9. package/components/Alert/Alert.module.js +18 -0
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.js +23 -0
  12. package/components/Badge/Badge.js +16 -38
  13. package/components/Badge/Badge.module.js +17 -0
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.js +10 -0
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.js +25 -0
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.js +35 -0
  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.js +32 -0
  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 +46 -41
  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.js +32 -0
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.js +23 -0
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.js +28 -0
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.js +12 -0
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.js +17 -0
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.js +10 -0
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.js +66 -0
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.js +29 -0
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +12 -10
  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.js +12 -0
  71. package/components/EmptyState/EmptyState.js +58 -55
  72. package/components/EmptyState/EmptyState.module.js +14 -0
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +32 -35
  75. package/components/Form/Form.module.js +16 -0
  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.js +26 -0
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +25 -22
  85. package/components/Kbd/Kbd.module.js +10 -0
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.js +23 -0
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.js +10 -0
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.js +12 -0
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.js +40 -0
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.js +18 -0
  96. package/components/PageHeader/PageHeader.js +78 -72
  97. package/components/PageHeader/PageHeader.module.js +23 -0
  98. package/components/Pagination/Pagination.js +63 -84
  99. package/components/Pagination/Pagination.module.js +13 -0
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.js +12 -0
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +57 -90
  105. package/components/ProgressBar/ProgressBar.module.js +29 -0
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.js +3 -0
  108. package/components/SegmentedControl/SegmentedControl.js +94 -130
  109. package/components/SegmentedControl/SegmentedControl.module.js +21 -0
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.js +15 -0
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.js +12 -0
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.js +31 -0
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.js +14 -0
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.js +42 -0
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.js +18 -0
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.js +28 -0
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.js +29 -0
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.js +31 -0
  134. package/components/Timeline/Timeline.module.js +76 -0
  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 +245 -178
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.js +98 -0
  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.js +29 -0
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.js +37 -0
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  153. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.js +17 -0
  157. package/components/Typography/Typography.js +11 -36
  158. package/components/Typography/Typography.module.js +30 -0
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  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.js +23 -0
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  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.js +20 -0
  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.js +15 -0
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.js +9 -0
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  183. package/components/inputs/Select/Select.js +555 -682
  184. package/components/inputs/Select/Select.module.js +38 -0
  185. package/components/inputs/Slider/Slider.js +97 -128
  186. package/components/inputs/Slider/Slider.module.js +9 -0
  187. package/components/inputs/Switch/Switch.js +11 -8
  188. package/components/inputs/Textarea/Textarea.js +42 -58
  189. package/components/inputs/Textarea/Textarea.module.js +14 -0
  190. package/hooks/useClickOutside.js +17 -14
  191. package/hooks/useDebouncedValue.js +13 -14
  192. package/hooks/useElementSize.js +27 -22
  193. package/hooks/useEscapeLayer.js +28 -29
  194. package/hooks/useFocusTrap.js +27 -38
  195. package/hooks/useKeyboard.js +76 -64
  196. package/hooks/useMediaQuery.js +10 -15
  197. package/hooks/useNow.js +28 -33
  198. package/hooks/usePersistedState.js +98 -94
  199. package/hooks/usePortalPosition.js +25 -19
  200. package/hooks/useResizable.js +106 -104
  201. package/hooks/useTheme.js +28 -23
  202. package/index.css +2 -1
  203. package/index.js +97 -215
  204. package/index.layered.css +2 -3
  205. package/llms.txt +3 -0
  206. package/manifest.json +8 -0
  207. package/package.json +1 -1
  208. package/utils/formatBytes.js +29 -13
  209. package/utils/themeScript.js +6 -8
  210. package/utils/timeAgo.js +59 -32
  211. package/components/Accordion/Accordion.module.scss.js +0 -36
  212. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  213. package/components/Alert/Alert.module.scss.js +0 -33
  214. package/components/Avatar/Avatar.module.scss.js +0 -43
  215. package/components/Badge/Badge.module.scss.js +0 -31
  216. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  217. package/components/Button/Button.module.scss.js +0 -47
  218. package/components/Card/Card.module.scss.js +0 -60
  219. package/components/Chart/Chart.module.scss.js +0 -61
  220. package/components/Chip/Chip.module.scss.js +0 -59
  221. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  222. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  223. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  224. package/components/Divider/Divider.module.scss.js +0 -31
  225. package/components/Draggable/Draggable.module.scss.js +0 -17
  226. package/components/Drawer/Drawer.module.scss.js +0 -119
  227. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  228. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  229. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  230. package/components/Form/Form.module.scss.js +0 -29
  231. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  232. package/components/Kbd/Kbd.module.scss.js +0 -17
  233. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  234. package/components/Link/Link.module.scss.js +0 -16
  235. package/components/List/List.module.scss.js +0 -21
  236. package/components/Loader/Loader.module.scss.js +0 -70
  237. package/components/Modal/Modal.module.scss.js +0 -33
  238. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  239. package/components/Pagination/Pagination.module.scss.js +0 -23
  240. package/components/Popover/Popover.module.scss.js +0 -21
  241. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  242. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  243. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  244. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  245. package/components/Spinner/Spinner.module.scss.js +0 -20
  246. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  247. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  248. package/components/StatCard/StatCard.module.scss.js +0 -72
  249. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  250. package/components/Table/Table.module.scss.js +0 -81
  251. package/components/Tabs/Tabs.module.scss.js +0 -53
  252. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  253. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  254. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  255. package/components/Timeline/Timeline.module.scss.js +0 -141
  256. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  257. package/components/Timer/Timer.module.scss.js +0 -55
  258. package/components/Toast/Toast.module.scss.js +0 -62
  259. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  260. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  261. package/components/Typography/Typography.module.scss.js +0 -53
  262. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  263. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  264. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  265. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  266. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  267. package/components/inputs/Input/Input.module.scss.js +0 -27
  268. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  269. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  270. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  271. package/components/inputs/Select/Select.module.scss.js +0 -73
  272. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  273. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -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 { ChartContainer as e } from "./ChartContainer.js";
2
+ import { ChartLegend as t } from "./ChartLegend.js";
3
+ import { ChartTooltip as n } from "./ChartTooltip.js";
4
+ import { XAxis as r, YAxis as i } from "./Axis.js";
5
+ import { bandScale as a, extent as o, linearScale as s, niceTicks as c } from "./scales.js";
6
+ import l from "./Chart.module.js";
7
+ import { useMemo as u, useRef as d, useState as f } from "react";
8
+ import p from "clsx";
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: ee = !0, dotColorKey: D, renderDot: O, showValues: k = !1, valuePosition: A = "top", renderLabel: j, activeIndex: M, onPointClick: N, showGrid: P = !0, showLegend: F = !0, showTooltip: I = !0, yTickCount: L = 5, yFormat: R, xFormat: z, valueFormat: B, renderTooltip: V, margin: H, emptyMessage: U = "No data", className: W, style: G, classes: K }) {
39
+ let q = {
40
+ ..._,
41
+ ...H
42
+ }, J = u(() => Object.keys(C), [C]), [Y, X] = f(null), Z = d(null), Q = M ?? Y, $ = (e, t) => {
43
+ if (D) {
44
+ let e = b[t]?.[D];
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: p(l.root, K?.root, W),
52
+ style: G,
53
+ children: /* @__PURE__ */ h("div", {
54
+ className: l.canvas,
55
+ style: { height: T ?? 240 },
56
+ children: /* @__PURE__ */ h("div", {
57
+ className: l.empty,
58
+ children: U
59
+ })
60
+ })
61
+ });
62
+ let te = I && Q !== null ? /* @__PURE__ */ h(n, {
63
+ row: b[Q],
64
+ x: x(b, S, q, Q, Z),
65
+ y: 16,
66
+ containerWidth: Z.current?.getBoundingClientRect().width ?? 0,
67
+ config: C,
68
+ render: V ? () => V(b[Q]) : void 0,
69
+ valueFormat: B,
70
+ titleKey: S,
71
+ resolveColor: D ? (e) => $(e, Q) : void 0,
72
+ classes: K
73
+ }) : null;
74
+ return /* @__PURE__ */ h(e, {
75
+ ref: Z,
76
+ aspectRatio: w,
77
+ height: T,
78
+ className: W,
79
+ style: G,
80
+ classes: K,
81
+ legend: F ? /* @__PURE__ */ h(t, {
82
+ config: C,
83
+ classes: K
84
+ }) : void 0,
85
+ overlay: te,
86
+ children: ({ width: e, height: t }) => {
87
+ let n = q.left, u = e - q.right, d = q.top, f = t - q.bottom, _ = Math.max(0, u - n), x = Math.max(0, f - d), w = b.map((e) => String(e[S])), T = a(w, [n, u], 0), D = [];
88
+ for (let e of J) for (let t of b) {
89
+ let n = t[e];
90
+ typeof n == "number" && D.push(n);
91
+ }
92
+ let [F, I] = o(D), V = c(Math.min(0, F), I, L), H = s([V[0], V[V.length - 1]], [f, d]), U = V.map((e) => ({
93
+ value: e,
94
+ y: H(e)
95
+ })), W = y(w).map((e) => ({
96
+ label: e,
97
+ x: T(e)
98
+ }));
99
+ return /* @__PURE__ */ g(m, { children: [
100
+ /* @__PURE__ */ h(i, {
101
+ ticks: U,
102
+ x: n,
103
+ plotWidth: _,
104
+ format: R,
105
+ showGrid: P,
106
+ classes: K
107
+ }),
108
+ /* @__PURE__ */ h(r, {
109
+ ticks: W,
110
+ y: f,
111
+ format: z,
112
+ classes: K
113
+ }),
114
+ J.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: H(i),
120
+ value: i,
121
+ row: t
122
+ };
123
+ });
124
+ return /* @__PURE__ */ g("g", {
125
+ className: p(l.series, K?.series),
126
+ children: [
127
+ /* @__PURE__ */ h("path", {
128
+ className: p(l.linePath),
129
+ d: v(n, E),
130
+ stroke: t.color
131
+ }),
132
+ ee && n.map((t, n) => {
133
+ let r = $(e, n), i = Q === n, a = M !== void 0 && !i, o = N ? () => N({
134
+ row: t.row,
135
+ value: t.value,
136
+ seriesKey: e,
137
+ index: n
138
+ }) : void 0;
139
+ return O ? /* @__PURE__ */ h("g", {
140
+ onClick: o,
141
+ style: o ? { cursor: "pointer" } : void 0,
142
+ opacity: a ? .45 : 1,
143
+ children: O({
144
+ row: t.row,
145
+ value: t.value,
146
+ seriesKey: e,
147
+ index: n,
148
+ x: t.x,
149
+ y: t.y,
150
+ color: r,
151
+ active: i
152
+ })
153
+ }, `${e}-${n}`) : /* @__PURE__ */ h("circle", {
154
+ className: p(l.point, K?.point),
155
+ cx: t.x,
156
+ cy: t.y,
157
+ r: i ? 5 : 3.5,
158
+ fill: r,
159
+ onClick: o,
160
+ style: o ? { cursor: "pointer" } : void 0,
161
+ opacity: a ? .45 : 1
162
+ }, `${e}-${n}`);
163
+ }),
164
+ (k || j) && n.map((t, n) => {
165
+ let r = j ? j({
166
+ row: t.row,
167
+ value: t.value,
168
+ seriesKey: e,
169
+ index: n
170
+ }) : k ? B ? B(t.value) : String(t.value) : null;
171
+ if (r == null) return null;
172
+ let i = A === "top" ? t.y - 10 : t.y + 10 + 4;
173
+ return /* @__PURE__ */ h("text", {
174
+ className: p(l.axisLabel),
175
+ x: t.x,
176
+ y: i,
177
+ textAnchor: "middle",
178
+ dominantBaseline: A === "top" ? "auto" : "middle",
179
+ children: r
180
+ }, `label-${e}-${n}`);
181
+ })
182
+ ]
183
+ }, e);
184
+ }),
185
+ Q !== null && /* @__PURE__ */ h("line", {
186
+ className: l.cursorLine,
187
+ x1: T(w[Q]),
188
+ x2: T(w[Q]),
189
+ y1: d,
190
+ y2: f
191
+ }),
192
+ /* @__PURE__ */ h("rect", {
193
+ className: l.interactionLayer,
194
+ x: n,
195
+ y: d,
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: N ? (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 = J[0], s = b[a][o], c = typeof s == "number" ? s : 0;
205
+ N({
206
+ row: b[a],
207
+ value: c,
208
+ seriesKey: o,
209
+ index: a
210
+ });
211
+ } : void 0,
212
+ style: N ? { 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 o = i.current;
220
+ if (!o) return 0;
221
+ let s = o.getBoundingClientRect().width, c = e.map((e) => String(e[t]));
222
+ return a(c, [n.left, s - n.right], 0)(c[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;