@overdoser/react-toolkit 0.19.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 (279) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +47 -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 +41 -16
  123. package/components/Table/Table.js +383 -442
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/index.d.ts +1 -1
  126. package/components/Table/useTableSort.d.ts +1 -1
  127. package/components/Table/useTableSort.js +51 -42
  128. package/components/Tabs/Tabs.js +109 -161
  129. package/components/Tabs/Tabs.module.js +28 -0
  130. package/components/ThemeToggle/ThemeToggle.d.ts +2 -0
  131. package/components/ThemeToggle/ThemeToggle.js +122 -97
  132. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  133. package/components/Timeline/GanttTimeline.js +357 -318
  134. package/components/Timeline/GanttTimeline.module.js +29 -0
  135. package/components/Timeline/HistoryTimeline.js +486 -450
  136. package/components/Timeline/HistoryTimeline.module.js +31 -0
  137. package/components/Timeline/Timeline.module.js +76 -0
  138. package/components/Timeline/TimelineShared.d.ts +7 -7
  139. package/components/Timeline/TimelineShared.js +288 -279
  140. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  141. package/components/Timeline/TraceEventDetails.js +245 -178
  142. package/components/Timeline/TraceTimeline.js +823 -783
  143. package/components/Timeline/TraceTimeline.module.js +98 -0
  144. package/components/Timeline/historyLayout.js +336 -263
  145. package/components/Timeline/timelineCore.js +208 -183
  146. package/components/Timeline/traceEvent.js +59 -61
  147. package/components/Timeline/traceLayout.js +101 -90
  148. package/components/Timeline/useTimeline.js +76 -79
  149. package/components/Timer/Timer.js +190 -156
  150. package/components/Timer/Timer.module.js +29 -0
  151. package/components/Toast/Toast.d.ts +1 -1
  152. package/components/Toast/Toast.js +128 -128
  153. package/components/Toast/Toast.module.js +37 -0
  154. package/components/Toast/toastStore.js +58 -62
  155. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  156. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  157. package/components/Tooltip/Tooltip.d.ts +1 -1
  158. package/components/Tooltip/Tooltip.js +76 -85
  159. package/components/Tooltip/Tooltip.module.js +17 -0
  160. package/components/Typography/Typography.js +11 -36
  161. package/components/Typography/Typography.module.js +30 -0
  162. package/components/inputs/Checkbox/Checkbox.js +27 -51
  163. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  164. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  165. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  166. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  167. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  168. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  169. package/components/inputs/DatePicker/DatePicker.js +115 -142
  170. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  171. package/components/inputs/DatePicker/dateUtils.js +32 -41
  172. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  173. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  174. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  175. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  176. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  177. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  178. package/components/inputs/Input/Input.js +98 -109
  179. package/components/inputs/Input/Input.module.js +15 -0
  180. package/components/inputs/NumberInput/NumberInput.js +112 -132
  181. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  182. package/components/inputs/Radio/Radio.js +50 -73
  183. package/components/inputs/Radio/Radio.module.js +9 -0
  184. package/components/inputs/SearchInput/SearchInput.js +98 -115
  185. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  186. package/components/inputs/Select/Select.js +555 -682
  187. package/components/inputs/Select/Select.module.js +38 -0
  188. package/components/inputs/Slider/Slider.js +97 -128
  189. package/components/inputs/Slider/Slider.module.js +9 -0
  190. package/components/inputs/Switch/Switch.js +11 -8
  191. package/components/inputs/Textarea/Textarea.js +42 -58
  192. package/components/inputs/Textarea/Textarea.module.js +14 -0
  193. package/hooks/useClickOutside.js +17 -14
  194. package/hooks/useDebouncedValue.js +13 -14
  195. package/hooks/useElementSize.js +27 -22
  196. package/hooks/useEscapeLayer.js +28 -29
  197. package/hooks/useFocusTrap.js +27 -38
  198. package/hooks/useKeyboard.js +76 -64
  199. package/hooks/useMediaQuery.js +10 -15
  200. package/hooks/useNow.js +28 -33
  201. package/hooks/usePersistedState.js +98 -91
  202. package/hooks/usePortalPosition.js +25 -19
  203. package/hooks/useResizable.js +106 -104
  204. package/hooks/useTheme.d.ts +2 -2
  205. package/hooks/useTheme.js +28 -25
  206. package/index.css +2 -1
  207. package/index.d.ts +1 -1
  208. package/index.js +97 -215
  209. package/index.layered.css +2 -3
  210. package/llms.txt +9 -6
  211. package/manifest.json +66 -10
  212. package/package.json +1 -1
  213. package/utils/formatBytes.js +29 -13
  214. package/utils/themeScript.d.ts +2 -0
  215. package/utils/themeScript.js +6 -8
  216. package/utils/timeAgo.js +59 -32
  217. package/components/Accordion/Accordion.module.scss.js +0 -36
  218. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  219. package/components/Alert/Alert.module.scss.js +0 -33
  220. package/components/Avatar/Avatar.module.scss.js +0 -43
  221. package/components/Badge/Badge.module.scss.js +0 -31
  222. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  223. package/components/Button/Button.module.scss.js +0 -47
  224. package/components/Card/Card.module.scss.js +0 -60
  225. package/components/Chart/Chart.module.scss.js +0 -61
  226. package/components/Chip/Chip.module.scss.js +0 -59
  227. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  228. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  229. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  230. package/components/Divider/Divider.module.scss.js +0 -31
  231. package/components/Draggable/Draggable.module.scss.js +0 -17
  232. package/components/Drawer/Drawer.module.scss.js +0 -119
  233. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  234. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  235. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  236. package/components/Form/Form.module.scss.js +0 -29
  237. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  238. package/components/Kbd/Kbd.module.scss.js +0 -17
  239. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  240. package/components/Link/Link.module.scss.js +0 -16
  241. package/components/List/List.module.scss.js +0 -21
  242. package/components/Loader/Loader.module.scss.js +0 -70
  243. package/components/Modal/Modal.module.scss.js +0 -33
  244. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  245. package/components/Pagination/Pagination.module.scss.js +0 -23
  246. package/components/Popover/Popover.module.scss.js +0 -21
  247. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  248. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  249. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  250. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  251. package/components/Spinner/Spinner.module.scss.js +0 -20
  252. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  253. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  254. package/components/StatCard/StatCard.module.scss.js +0 -72
  255. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  256. package/components/Table/Table.module.scss.js +0 -81
  257. package/components/Tabs/Tabs.module.scss.js +0 -53
  258. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  259. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  260. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  261. package/components/Timeline/Timeline.module.scss.js +0 -141
  262. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  263. package/components/Timer/Timer.module.scss.js +0 -55
  264. package/components/Toast/Toast.module.scss.js +0 -62
  265. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  266. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  267. package/components/Typography/Typography.module.scss.js +0 -53
  268. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  269. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  270. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  271. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  272. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  273. package/components/inputs/Input/Input.module.scss.js +0 -27
  274. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  275. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  276. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  277. package/components/inputs/Select/Select.module.scss.js +0 -73
  278. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  279. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -1,255 +1,254 @@
1
- import { jsx as i, jsxs as U, Fragment as dt } from "react/jsx-runtime";
2
- import { useMemo as E, useState as $t, useRef as gt, useId as Mt } from "react";
3
- import X from "clsx";
4
- import { ChartContainer as Lt } from "./ChartContainer.js";
5
- import { ChartLegend as bt } from "./ChartLegend.js";
6
- import { ChartTooltip as vt } from "./ChartTooltip.js";
7
- import { YAxis as Ct, XAxis as Nt } from "./Axis.js";
8
- import { bandScale as et, niceTicks as Tt, linearScale as kt } from "./scales.js";
9
- import x from "./Chart.module.scss.js";
10
- const Rt = { top: 12, right: 16, bottom: 28, left: 48 };
11
- function V(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((e, o) => `${o === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
16
- if (s === "step") {
17
- let e = `M ${t[0].x} ${t[0].y}`;
18
- for (let o = 1; o < t.length; o++)
19
- e += ` L ${t[o].x} ${t[o - 1].y} L ${t[o].x} ${t[o].y}`;
20
- return e;
21
- }
22
- let r = `M ${t[0].x} ${t[0].y}`;
23
- for (let e = 0; e < t.length - 1; e++) {
24
- const o = t[e - 1] ?? t[e], l = t[e], m = t[e + 1], h = t[e + 2] ?? m, y = l.x + (m.x - o.x) / 6, k = l.y + (m.y - o.y) / 6, F = m.x - (h.x - l.x) / 6, R = m.y - (h.y - l.y) / 6;
25
- r += ` C ${y} ${k}, ${F} ${R}, ${m.x} ${m.y}`;
26
- }
27
- return r;
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, linearScale as o, niceTicks as s } from "./scales.js";
6
+ import c from "./Chart.module.js";
7
+ import { useId as l, useMemo as u, useRef as d, useState as f } from "react";
8
+ import p from "clsx";
9
+ import { Fragment as ee, jsx as m, jsxs as h } from "react/jsx-runtime";
10
+ // src/components/Chart/AreaChart.tsx
11
+ var g = {
12
+ top: 12,
13
+ right: 16,
14
+ bottom: 28,
15
+ left: 48
16
+ };
17
+ function _(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 ot(t, s, r) {
30
- if (t.length === 0) return "";
31
- const e = V(t, r);
32
- if (typeof s == "number") {
33
- const h = t[t.length - 1], y = t[0];
34
- return `${e} L ${h.x} ${s} L ${y.x} ${s} Z`;
35
- }
36
- const o = t.map((h, y) => ({ x: h.x, y: s[y] })).reverse(), m = V(o, r).replace(/^M /, "L ");
37
- return `${e} ${m} Z`;
33
+ function v(e, t, n) {
34
+ if (e.length === 0) return "";
35
+ let r = _(e, n);
36
+ if (typeof t == "number") {
37
+ let n = e[e.length - 1], i = e[0];
38
+ return `${r} L ${n.x} ${t} L ${i.x} ${t} Z`;
39
+ }
40
+ return `${r} ${_(e.map((e, n) => ({
41
+ x: e.x,
42
+ y: t[n]
43
+ })).reverse(), n).replace(/^M /, "L ")} Z`;
38
44
  }
39
- function St(t, s = 8) {
40
- if (t.length <= s) return t;
41
- const r = Math.ceil(t.length / s);
42
- return t.filter((e, o) => o % r === 0);
45
+ function y(e, t = 8) {
46
+ if (e.length <= t) return e;
47
+ let n = Math.ceil(e.length / t);
48
+ return e.filter((e, t) => t % n === 0);
43
49
  }
44
- function Zt({
45
- data: t,
46
- xKey: s,
47
- config: r,
48
- aspectRatio: e = 16 / 9,
49
- height: o,
50
- curve: l = "monotone",
51
- stacked: m = !1,
52
- stackOffset: h = "none",
53
- fillGradient: y = !1,
54
- showGrid: k = !0,
55
- showXAxis: F = !0,
56
- showYAxis: R = !0,
57
- showLegend: nt = !0,
58
- showTooltip: rt = !0,
59
- yTickCount: ct = 5,
60
- yFormat: st,
61
- xFormat: lt,
62
- valueFormat: q,
63
- renderTooltip: z,
64
- margin: J,
65
- emptyMessage: it = "No data",
66
- className: K,
67
- style: Q,
68
- classes: p
69
- }) {
70
- const S = E(
71
- () => ({
72
- ...Rt,
73
- ...R ? {} : { left: 16 },
74
- ...J
75
- }),
76
- [J, R]
77
- ), d = E(() => Object.keys(r), [r]), w = m && d.length > 0, M = w && h === "expand", [L, Y] = $t(null), j = gt(null), G = Mt(), at = E(() => {
78
- const u = d.map(() => []), $ = d.map(() => []);
79
- for (let c = 0; c < t.length; c++) {
80
- let a = 0;
81
- if (M) {
82
- for (const f of d) {
83
- const v = t[c][f];
84
- typeof v == "number" && v > 0 && (a += v);
85
- }
86
- a === 0 && (a = 1);
87
- }
88
- let b = 0;
89
- for (let f = 0; f < d.length; f++) {
90
- const v = d[f], W = t[c][v], g = typeof W == "number" ? W : 0;
91
- if (w) {
92
- const C = M ? g / a : g;
93
- $[f][c] = b, b += C, u[f][c] = b;
94
- } else
95
- $[f][c] = 0, u[f][c] = g;
96
- }
97
- }
98
- return { tops: u, bottoms: $ };
99
- }, [t, d, w, M]), { tops: Z, bottoms: H } = at, [ft, mt] = E(() => {
100
- if (M) return [0, 1];
101
- let u = 0, $ = 0;
102
- for (const c of Z)
103
- for (const a of c)
104
- a < u && (u = a), a > $ && ($ = a);
105
- for (const c of H)
106
- for (const a of c)
107
- a < u && (u = a);
108
- return [Math.min(0, u), $];
109
- }, [Z, H, M]);
110
- if (t.length === 0)
111
- return /* @__PURE__ */ i("div", { ref: j, className: X(x.root, p?.root, K), style: Q, children: /* @__PURE__ */ i("div", { className: x.canvas, style: { height: o ?? 240 }, children: /* @__PURE__ */ i("div", { className: x.empty, children: it }) }) });
112
- const D = L !== null ? t[L] : void 0;
113
- return /* @__PURE__ */ i(
114
- Lt,
115
- {
116
- ref: j,
117
- aspectRatio: e,
118
- height: o,
119
- className: K,
120
- style: Q,
121
- classes: p,
122
- legend: nt ? /* @__PURE__ */ i(bt, { config: r, classes: p }) : void 0,
123
- overlay: rt && L !== null && D ? /* @__PURE__ */ i(
124
- vt,
125
- {
126
- row: D,
127
- x: At(t, s, S, L, j),
128
- y: 16,
129
- containerWidth: j.current?.getBoundingClientRect().width ?? 0,
130
- config: r,
131
- render: z ? () => z(D) : void 0,
132
- valueFormat: M ? wt(D, d, q) : q,
133
- titleKey: s,
134
- classes: p
135
- }
136
- ) : null,
137
- children: ({ width: u, height: $ }) => {
138
- const c = S.left, a = u - S.right, b = S.top, f = $ - S.bottom, v = Math.max(0, a - c), W = Math.max(0, f - b), g = t.map((n) => String(n[s])), C = et(g, [c, a], 0), O = M ? [0, 0.25, 0.5, 0.75, 1] : Tt(ft, mt, ct), _ = kt([O[0], O[O.length - 1]], [f, b]), ht = _(0), tt = O.map((n) => ({ value: n, y: _(n) })), ut = St(g).map((n) => ({ label: n, x: C(n) })), xt = M ? (n) => `${Math.round(n * 100)}%` : st;
139
- return /* @__PURE__ */ U(dt, { children: [
140
- y && /* @__PURE__ */ i("defs", { children: d.map((n) => /* @__PURE__ */ U(
141
- "linearGradient",
142
- {
143
- id: `${G}-${n}`,
144
- x1: "0",
145
- y1: "0",
146
- x2: "0",
147
- y2: "1",
148
- children: [
149
- /* @__PURE__ */ i("stop", { offset: "5%", stopColor: r[n].color, stopOpacity: 0.6 }),
150
- /* @__PURE__ */ i("stop", { offset: "95%", stopColor: r[n].color, stopOpacity: 0.05 })
151
- ]
152
- },
153
- n
154
- )) }),
155
- R ? /* @__PURE__ */ i(
156
- Ct,
157
- {
158
- ticks: tt,
159
- x: c,
160
- plotWidth: v,
161
- format: xt,
162
- showGrid: k,
163
- classes: p
164
- }
165
- ) : k && /* @__PURE__ */ i("g", { className: X(x.axis, p?.axis), children: tt.map(({ value: n, y: N }) => /* @__PURE__ */ i(
166
- "line",
167
- {
168
- className: X(x.gridLine, p?.grid),
169
- x1: c,
170
- x2: a,
171
- y1: N,
172
- y2: N
173
- },
174
- `grid-${n}`
175
- )) }),
176
- F && /* @__PURE__ */ i(Nt, { ticks: ut, y: f, format: lt, classes: p }),
177
- d.map((n, N) => {
178
- const A = r[n], T = t.map((B, P) => ({
179
- x: C(g[P]),
180
- y: _(Z[N][P])
181
- })), I = y ? `url(#${G}-${n})` : A.color, yt = y ? 1 : 0.18, pt = w ? ot(T, H[N].map((B) => _(B)), l) : ot(T, ht, l);
182
- return /* @__PURE__ */ U("g", { className: X(x.series, p?.series), children: [
183
- /* @__PURE__ */ i(
184
- "path",
185
- {
186
- className: x.areaPath,
187
- d: pt,
188
- fill: I,
189
- fillOpacity: yt
190
- }
191
- ),
192
- /* @__PURE__ */ i("path", { className: x.linePath, d: V(T, l), stroke: A.color }),
193
- !w && T.map((B, P) => /* @__PURE__ */ i(
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
- `${n}-${P}`
203
- ))
204
- ] }, n);
205
- }),
206
- L !== null && /* @__PURE__ */ i(
207
- "line",
208
- {
209
- className: x.cursorLine,
210
- x1: C(g[L]),
211
- x2: C(g[L]),
212
- y1: b,
213
- y2: f
214
- }
215
- ),
216
- /* @__PURE__ */ i(
217
- "rect",
218
- {
219
- className: x.interactionLayer,
220
- x: c,
221
- y: b,
222
- width: v,
223
- height: W,
224
- onMouseMove: (n) => {
225
- const N = n.currentTarget.getBoundingClientRect(), A = n.clientX - N.left + c, T = C.step(), I = Math.max(0, Math.min(t.length - 1, Math.round((A - c - T / 2) / T)));
226
- Y(I);
227
- },
228
- onMouseLeave: () => Y(null)
229
- }
230
- )
231
- ] });
232
- }
233
- }
234
- );
50
+ function b({ data: b, xKey: C, config: w, aspectRatio: T = 16 / 9, height: E, curve: D = "monotone", stacked: O = !1, stackOffset: k = "none", fillGradient: A = !1, showGrid: j = !0, showXAxis: te = !0, showYAxis: M = !0, showLegend: N = !0, showTooltip: P = !0, yTickCount: ne = 5, yFormat: re, xFormat: F, valueFormat: I, renderTooltip: L, margin: R, emptyMessage: z = "No data", className: B, style: V, classes: H }) {
51
+ let U = u(() => ({
52
+ ...g,
53
+ ...M ? {} : { left: 16 },
54
+ ...R
55
+ }), [R, M]), W = u(() => Object.keys(w), [w]), G = O && W.length > 0, K = G && k === "expand", [q, J] = f(null), Y = d(null), X = l(), { tops: Z, bottoms: Q } = u(() => {
56
+ let e = W.map(() => []), t = W.map(() => []);
57
+ for (let n = 0; n < b.length; n++) {
58
+ let r = 0;
59
+ if (K) {
60
+ for (let e of W) {
61
+ let t = b[n][e];
62
+ typeof t == "number" && t > 0 && (r += t);
63
+ }
64
+ r === 0 && (r = 1);
65
+ }
66
+ let i = 0;
67
+ for (let a = 0; a < W.length; a++) {
68
+ let o = W[a], s = b[n][o], c = typeof s == "number" ? s : 0;
69
+ if (G) {
70
+ let o = K ? c / r : c;
71
+ t[a][n] = i, i += o, e[a][n] = i;
72
+ } else t[a][n] = 0, e[a][n] = c;
73
+ }
74
+ }
75
+ return {
76
+ tops: e,
77
+ bottoms: t
78
+ };
79
+ }, [
80
+ b,
81
+ W,
82
+ G,
83
+ K
84
+ ]), [ie, ae] = u(() => {
85
+ if (K) return [0, 1];
86
+ let e = 0, t = 0;
87
+ for (let n of Z) for (let r of n) r < e && (e = r), r > t && (t = r);
88
+ for (let t of Q) for (let n of t) n < e && (e = n);
89
+ return [Math.min(0, e), t];
90
+ }, [
91
+ Z,
92
+ Q,
93
+ K
94
+ ]);
95
+ if (b.length === 0) return /* @__PURE__ */ m("div", {
96
+ ref: Y,
97
+ className: p(c.root, H?.root, B),
98
+ style: V,
99
+ children: /* @__PURE__ */ m("div", {
100
+ className: c.canvas,
101
+ style: { height: E ?? 240 },
102
+ children: /* @__PURE__ */ m("div", {
103
+ className: c.empty,
104
+ children: z
105
+ })
106
+ })
107
+ });
108
+ let $ = q === null ? void 0 : b[q];
109
+ return /* @__PURE__ */ m(e, {
110
+ ref: Y,
111
+ aspectRatio: T,
112
+ height: E,
113
+ className: B,
114
+ style: V,
115
+ classes: H,
116
+ legend: N ? /* @__PURE__ */ m(t, {
117
+ config: w,
118
+ classes: H
119
+ }) : void 0,
120
+ overlay: P && q !== null && $ ? /* @__PURE__ */ m(n, {
121
+ row: $,
122
+ x: S(b, C, U, q, Y),
123
+ y: 16,
124
+ containerWidth: Y.current?.getBoundingClientRect().width ?? 0,
125
+ config: w,
126
+ render: L ? () => L($) : void 0,
127
+ valueFormat: K ? x($, W, I) : I,
128
+ titleKey: C,
129
+ classes: H
130
+ }) : null,
131
+ children: ({ width: e, height: t }) => {
132
+ let n = U.left, l = e - U.right, u = U.top, d = t - U.bottom, f = Math.max(0, l - n), g = Math.max(0, d - u), x = b.map((e) => String(e[C])), S = a(x, [n, l], 0), T = K ? [
133
+ 0,
134
+ .25,
135
+ .5,
136
+ .75,
137
+ 1
138
+ ] : s(ie, ae, ne), E = o([T[0], T[T.length - 1]], [d, u]), O = E(0), k = T.map((e) => ({
139
+ value: e,
140
+ y: E(e)
141
+ })), N = y(x).map((e) => ({
142
+ label: e,
143
+ x: S(e)
144
+ })), P = K ? (e) => `${Math.round(e * 100)}%` : re;
145
+ return /* @__PURE__ */ h(ee, { children: [
146
+ A && /* @__PURE__ */ m("defs", { children: W.map((e) => /* @__PURE__ */ h("linearGradient", {
147
+ id: `${X}-${e}`,
148
+ x1: "0",
149
+ y1: "0",
150
+ x2: "0",
151
+ y2: "1",
152
+ children: [/* @__PURE__ */ m("stop", {
153
+ offset: "5%",
154
+ stopColor: w[e].color,
155
+ stopOpacity: .6
156
+ }), /* @__PURE__ */ m("stop", {
157
+ offset: "95%",
158
+ stopColor: w[e].color,
159
+ stopOpacity: .05
160
+ })]
161
+ }, e)) }),
162
+ M ? /* @__PURE__ */ m(i, {
163
+ ticks: k,
164
+ x: n,
165
+ plotWidth: f,
166
+ format: P,
167
+ showGrid: j,
168
+ classes: H
169
+ }) : j && /* @__PURE__ */ m("g", {
170
+ className: p(c.axis, H?.axis),
171
+ children: k.map(({ value: e, y: t }) => /* @__PURE__ */ m("line", {
172
+ className: p(c.gridLine, H?.grid),
173
+ x1: n,
174
+ x2: l,
175
+ y1: t,
176
+ y2: t
177
+ }, `grid-${e}`))
178
+ }),
179
+ te && /* @__PURE__ */ m(r, {
180
+ ticks: N,
181
+ y: d,
182
+ format: F,
183
+ classes: H
184
+ }),
185
+ W.map((e, t) => {
186
+ let n = w[e], r = b.map((e, n) => ({
187
+ x: S(x[n]),
188
+ y: E(Z[t][n])
189
+ })), i = A ? `url(#${X}-${e})` : n.color, a = A ? 1 : .18, o = G ? v(r, Q[t].map((e) => E(e)), D) : v(r, O, D);
190
+ return /* @__PURE__ */ h("g", {
191
+ className: p(c.series, H?.series),
192
+ children: [
193
+ /* @__PURE__ */ m("path", {
194
+ className: c.areaPath,
195
+ d: o,
196
+ fill: i,
197
+ fillOpacity: a
198
+ }),
199
+ /* @__PURE__ */ m("path", {
200
+ className: c.linePath,
201
+ d: _(r, D),
202
+ stroke: n.color
203
+ }),
204
+ !G && r.map((t, r) => /* @__PURE__ */ m("circle", {
205
+ className: p(c.point, H?.point),
206
+ cx: t.x,
207
+ cy: t.y,
208
+ r: q === r ? 5 : 3,
209
+ fill: n.color
210
+ }, `${e}-${r}`))
211
+ ]
212
+ }, e);
213
+ }),
214
+ q !== null && /* @__PURE__ */ m("line", {
215
+ className: c.cursorLine,
216
+ x1: S(x[q]),
217
+ x2: S(x[q]),
218
+ y1: u,
219
+ y2: d
220
+ }),
221
+ /* @__PURE__ */ m("rect", {
222
+ className: c.interactionLayer,
223
+ x: n,
224
+ y: u,
225
+ width: f,
226
+ height: g,
227
+ onMouseMove: (e) => {
228
+ let t = e.currentTarget.getBoundingClientRect(), r = e.clientX - t.left + n, i = S.step(), a = Math.max(0, Math.min(b.length - 1, Math.round((r - n - i / 2) / i)));
229
+ J(a);
230
+ },
231
+ onMouseLeave: () => J(null)
232
+ })
233
+ ] });
234
+ }
235
+ });
235
236
  }
236
- function wt(t, s, r) {
237
- let e = 0;
238
- for (const o of s) {
239
- const l = t[o];
240
- typeof l == "number" && l > 0 && (e += l);
241
- }
242
- return (o) => {
243
- const l = e > 0 ? Math.round(o / e * 100) : 0;
244
- return `${r ? r(o) : o} · ${l}%`;
245
- };
237
+ function x(e, t, n) {
238
+ let r = 0;
239
+ for (let n of t) {
240
+ let t = e[n];
241
+ typeof t == "number" && t > 0 && (r += t);
242
+ }
243
+ return (e) => {
244
+ let t = r > 0 ? Math.round(e / r * 100) : 0;
245
+ return `${n ? n(e) : e} · ${t}%`;
246
+ };
246
247
  }
247
- function At(t, s, r, e, o) {
248
- const l = o.current;
249
- if (!l) return 0;
250
- const m = l.getBoundingClientRect().width, h = t.map((k) => String(k[s]));
251
- return et(h, [r.left, m - r.right], 0)(h[e]);
248
+ function S(e, t, n, r, i) {
249
+ let o = i.current;
250
+ if (!o) return 0;
251
+ let s = o.getBoundingClientRect().width, c = e.map((e) => String(e[t]));
252
+ return a(c, [n.left, s - n.right], 0)(c[r]);
252
253
  }
253
- export {
254
- Zt as AreaChart
255
- };
254
+ export { b as AreaChart };
@@ -14,7 +14,7 @@ export interface YAxisProps {
14
14
  classes?: Partial<ChartClasses>;
15
15
  }
16
16
  /** Y axis with optional horizontal grid lines. */
17
- export declare function YAxis({ ticks, x, plotWidth, format, showGrid, classes }: YAxisProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function YAxis({ ticks, x, plotWidth, format, showGrid, classes }: YAxisProps): import("react").JSX.Element;
18
18
  export interface XAxisProps {
19
19
  /** Pixel positions and labels for the X axis. */
20
20
  ticks: {
@@ -27,4 +27,4 @@ export interface XAxisProps {
27
27
  classes?: Partial<ChartClasses>;
28
28
  }
29
29
  /** X axis labels along the bottom of the plot. */
30
- export declare function XAxis({ ticks, y, format, classes }: XAxisProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function XAxis({ ticks, y, format, classes }: XAxisProps): import("react").JSX.Element;
@@ -1,45 +1,36 @@
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}`)) });
1
+ import e from "./Chart.module.js";
2
+ import t from "clsx";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ // src/components/Chart/Axis.tsx
5
+ function i({ ticks: i, x: a, plotWidth: o, format: s, showGrid: c = !0, classes: l }) {
6
+ return /* @__PURE__ */ n("g", {
7
+ className: t(e.axis, l?.axis),
8
+ children: i.map(({ value: i, y: u }) => /* @__PURE__ */ r("g", { children: [c && /* @__PURE__ */ n("line", {
9
+ className: t(e.gridLine, l?.grid),
10
+ x1: a,
11
+ x2: a + o,
12
+ y1: u,
13
+ y2: u
14
+ }), /* @__PURE__ */ n("text", {
15
+ className: t(e.axisLabel, l?.axisLabel),
16
+ x: a - 8,
17
+ y: u,
18
+ textAnchor: "end",
19
+ dominantBaseline: "middle",
20
+ children: s ? s(i) : i
21
+ })] }, `y-${i}`))
22
+ });
28
23
  }
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
- )) });
24
+ function a({ ticks: r, y: i, format: a, classes: o }) {
25
+ return /* @__PURE__ */ n("g", {
26
+ className: t(e.axis, o?.axis),
27
+ children: r.map(({ label: r, x: s }) => /* @__PURE__ */ n("text", {
28
+ className: t(e.axisLabel, o?.axisLabel),
29
+ x: s,
30
+ y: i + 16,
31
+ textAnchor: "middle",
32
+ children: a ? a(r) : r
33
+ }, `x-${r}-${s}`))
34
+ });
41
35
  }
42
- export {
43
- L as XAxis,
44
- g as YAxis
45
- };
36
+ export { a as XAxis, i as YAxis };
@@ -108,4 +108,4 @@ export interface BarChartProps<T extends Record<string, unknown>> {
108
108
  * }}
109
109
  * />
110
110
  */
111
- export declare function BarChart<T extends Record<string, unknown>>({ data, xKey, config, orientation, stacked, aspectRatio, height, groupPadding, barPadding, barRadius, showGrid, showLegend, showTooltip, showValues, valuePosition, renderLabel, colorBy, colors, negativeColor, activeIndex, onBarClick, yTickCount, yFormat, xFormat, valueFormat, renderTooltip, margin: marginOverride, emptyMessage, className, style, classes, }: BarChartProps<T>): import("react/jsx-runtime").JSX.Element;
111
+ export declare function BarChart<T extends Record<string, unknown>>({ data, xKey, config, orientation, stacked, aspectRatio, height, groupPadding, barPadding, barRadius, showGrid, showLegend, showTooltip, showValues, valuePosition, renderLabel, colorBy, colors, negativeColor, activeIndex, onBarClick, yTickCount, yFormat, xFormat, valueFormat, renderTooltip, margin: marginOverride, emptyMessage, className, style, classes, }: BarChartProps<T>): import("react").JSX.Element;