@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,245 +1,229 @@
1
- import { jsx as a, jsxs as J, Fragment as at } from "react/jsx-runtime";
2
- import { useState as lt, useRef as dt, useMemo as Q } from "react";
3
- import D from "clsx";
4
- import { ChartContainer as ht } from "./ChartContainer.js";
5
- import { ChartTooltip as $t } from "./ChartTooltip.js";
6
- import f from "./Chart.module.scss.js";
7
- const ft = [
8
- "var(--crk-chart-1)",
9
- "var(--crk-chart-2)",
10
- "var(--crk-chart-3)",
11
- "var(--crk-chart-4)",
12
- "var(--crk-chart-5)"
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 { ChartTooltip as a } from "./ChartTooltip.js";
5
+ import o from "./Chart.module.scss.js";
6
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
7
+ // src/components/Chart/PieChart.tsx
8
+ var u = [
9
+ "var(--crk-chart-1)",
10
+ "var(--crk-chart-2)",
11
+ "var(--crk-chart-3)",
12
+ "var(--crk-chart-4)",
13
+ "var(--crk-chart-5)"
13
14
  ];
14
- function O(t, i) {
15
- if (typeof t == "number") return t;
16
- const n = /^([\d.]+)%$/.exec(t);
17
- return n ? parseFloat(n[1]) / 100 * i : parseFloat(t) || 0;
15
+ function d(e, t) {
16
+ if (typeof e == "number") return e;
17
+ let n = /^([\d.]+)%$/.exec(e);
18
+ return n ? parseFloat(n[1]) / 100 * t : parseFloat(e) || 0;
18
19
  }
19
- function mt(t, i, n, e, m, M) {
20
- if (Math.abs(M - m) >= 360 - 1e-6)
21
- return e > 0 ? [
22
- `M ${t + n} ${i}`,
23
- `A ${n} ${n} 0 1 1 ${t - n} ${i}`,
24
- `A ${n} ${n} 0 1 1 ${t + n} ${i}`,
25
- `M ${t + e} ${i}`,
26
- `A ${e} ${e} 0 1 0 ${t - e} ${i}`,
27
- `A ${e} ${e} 0 1 0 ${t + e} ${i}`,
28
- "Z"
29
- ].join(" ") : [
30
- `M ${t + n} ${i}`,
31
- `A ${n} ${n} 0 1 1 ${t - n} ${i}`,
32
- `A ${n} ${n} 0 1 1 ${t + n} ${i}`,
33
- "Z"
34
- ].join(" ");
35
- const d = (m - 90) * Math.PI / 180, p = (M - 90) * Math.PI / 180, b = M - m > 180 ? 1 : 0, k = t + n * Math.cos(d), E = i + n * Math.sin(d), L = t + n * Math.cos(p), A = i + n * Math.sin(p);
36
- if (e > 0) {
37
- const H = t + e * Math.cos(p), U = i + e * Math.sin(p), C = t + e * Math.cos(d), Z = i + e * Math.sin(d);
38
- return [
39
- `M ${k} ${E}`,
40
- `A ${n} ${n} 0 ${b} 1 ${L} ${A}`,
41
- `L ${H} ${U}`,
42
- `A ${e} ${e} 0 ${b} 0 ${C} ${Z}`,
43
- "Z"
44
- ].join(" ");
45
- }
46
- return [
47
- `M ${t} ${i}`,
48
- `L ${k} ${E}`,
49
- `A ${n} ${n} 0 ${b} 1 ${L} ${A}`,
50
- "Z"
51
- ].join(" ");
20
+ function f(e, t, n, r, i, a) {
21
+ if (Math.abs(a - i) >= 360 - 1e-6) return r > 0 ? [
22
+ `M ${e + n} ${t}`,
23
+ `A ${n} ${n} 0 1 1 ${e - n} ${t}`,
24
+ `A ${n} ${n} 0 1 1 ${e + n} ${t}`,
25
+ `M ${e + r} ${t}`,
26
+ `A ${r} ${r} 0 1 0 ${e - r} ${t}`,
27
+ `A ${r} ${r} 0 1 0 ${e + r} ${t}`,
28
+ "Z"
29
+ ].join(" ") : [
30
+ `M ${e + n} ${t}`,
31
+ `A ${n} ${n} 0 1 1 ${e - n} ${t}`,
32
+ `A ${n} ${n} 0 1 1 ${e + n} ${t}`,
33
+ "Z"
34
+ ].join(" ");
35
+ let o = (i - 90) * Math.PI / 180, s = (a - 90) * Math.PI / 180, c = +(a - i > 180), l = e + n * Math.cos(o), u = t + n * Math.sin(o), d = e + n * Math.cos(s), f = t + n * Math.sin(s);
36
+ if (r > 0) {
37
+ let i = e + r * Math.cos(s), a = t + r * Math.sin(s), p = e + r * Math.cos(o), m = t + r * Math.sin(o);
38
+ return [
39
+ `M ${l} ${u}`,
40
+ `A ${n} ${n} 0 ${c} 1 ${d} ${f}`,
41
+ `L ${i} ${a}`,
42
+ `A ${r} ${r} 0 ${c} 0 ${p} ${m}`,
43
+ "Z"
44
+ ].join(" ");
45
+ }
46
+ return [
47
+ `M ${e} ${t}`,
48
+ `L ${l} ${u}`,
49
+ `A ${n} ${n} 0 ${c} 1 ${d} ${f}`,
50
+ "Z"
51
+ ].join(" ");
52
52
  }
53
- function tt(t, i, n, e, m) {
54
- const d = ((e + m) / 2 - 90) * Math.PI / 180;
55
- return { x: t + n * Math.cos(d), y: i + n * Math.sin(d) };
53
+ function p(e, t, n, r, i) {
54
+ let a = ((r + i) / 2 - 90) * Math.PI / 180;
55
+ return {
56
+ x: e + n * Math.cos(a),
57
+ y: t + n * Math.sin(a)
58
+ };
56
59
  }
57
- function yt({
58
- data: t,
59
- valueKey: i,
60
- nameKey: n,
61
- colorKey: e,
62
- colors: m = ft,
63
- aspectRatio: M = 1,
64
- height: d,
65
- innerRadius: p = 0,
66
- outerRadius: b = "90%",
67
- strokeWidth: k = 2,
68
- strokeColor: E = "var(--crk-color-bg)",
69
- padAngle: L = 0,
70
- showLabels: A = !1,
71
- valuePosition: H = "outside",
72
- showLabelLines: U = !0,
73
- renderLabel: C,
74
- centerLabel: Z,
75
- activeIndex: W,
76
- onSliceClick: V,
77
- showLegend: nt = !0,
78
- showTooltip: ot = !0,
79
- valueFormat: _,
80
- renderTooltip: X,
81
- emptyMessage: it = "No data",
82
- className: Y,
83
- style: K,
84
- classes: P
85
- }) {
86
- const [et, I] = lt(null), j = dt(null), u = W ?? et, B = (c) => {
87
- if (e) {
88
- const r = t[c]?.[e];
89
- if (typeof r == "string") return r;
90
- }
91
- return m[c % m.length];
92
- }, q = Q(() => {
93
- let c = 0;
94
- for (const r of t) {
95
- const s = r[i];
96
- typeof s == "number" && s > 0 && (c += s);
97
- }
98
- return c;
99
- }, [t, i]), N = Q(() => {
100
- const c = [];
101
- let r = 0;
102
- for (let s = 0; s < t.length; s++) {
103
- const g = t[s], v = g[i], l = typeof v == "number" && v > 0 ? v : 0;
104
- if (l === 0) continue;
105
- const h = l / q, F = h * 360;
106
- c.push({ index: s, row: g, value: l, start: r, end: r + F, fraction: h }), r += F;
107
- }
108
- return c;
109
- }, [t, i, q]), ct = nt ? /* @__PURE__ */ a("div", { className: D(f.legend, P?.legend), role: "list", children: N.map((c) => /* @__PURE__ */ J("div", { className: D(f.legendItem, P?.legendItem), role: "listitem", children: [
110
- /* @__PURE__ */ a(
111
- "span",
112
- {
113
- className: f.legendSwatch,
114
- style: { background: B(c.index) },
115
- "aria-hidden": "true"
116
- }
117
- ),
118
- /* @__PURE__ */ a("span", { className: f.legendLabel, children: String(c.row[n]) })
119
- ] }, c.index)) }) : void 0, rt = Q(() => {
120
- const c = {};
121
- for (const r of N)
122
- c[r.index.toString()] = {
123
- label: String(r.row[n]),
124
- color: B(r.index)
125
- };
126
- return c;
127
- }, [N]);
128
- return t.length === 0 || q === 0 ? /* @__PURE__ */ a("div", { ref: j, className: D(f.root, P?.root, Y), style: K, children: /* @__PURE__ */ a("div", { className: f.canvas, style: { height: d ?? 240 }, children: /* @__PURE__ */ a("div", { className: f.empty, children: it }) }) }) : /* @__PURE__ */ a(
129
- ht,
130
- {
131
- ref: j,
132
- aspectRatio: M,
133
- height: d,
134
- className: Y,
135
- style: K,
136
- classes: P,
137
- legend: ct,
138
- overlay: ot && u !== null && t[u] ? /* @__PURE__ */ a(
139
- $t,
140
- {
141
- row: { [u.toString()]: t[u][i] },
142
- x: j.current ? j.current.getBoundingClientRect().width / 2 : 0,
143
- y: 16,
144
- containerWidth: j.current?.getBoundingClientRect().width ?? 0,
145
- config: { [u.toString()]: rt[u.toString()] },
146
- render: X ? () => X(t[u]) : void 0,
147
- valueFormat: _,
148
- titleKey: void 0,
149
- classes: P
150
- }
151
- ) : null,
152
- children: ({ width: c, height: r }) => {
153
- const s = c / 2, g = r / 2, v = Math.min(c, r) / 2 - 4, l = O(b, v), h = Math.min(l - 1, O(p, v)), F = Math.max(4, l * 0.06);
154
- return /* @__PURE__ */ J(at, { children: [
155
- /* @__PURE__ */ a("g", { children: N.map((o) => {
156
- const y = L / 2, w = Math.min(o.end, o.start + y), z = Math.max(o.start, o.end - y), G = B(o.index), $ = u === o.index, R = W !== void 0 && !$, x = $ && W !== void 0 ? l + F : l, T = mt(s, g, x, h, w, z), S = V ? () => V({ row: o.row, value: o.value, index: o.index }) : void 0;
157
- return /* @__PURE__ */ a(
158
- "path",
159
- {
160
- d: T,
161
- fill: G,
162
- stroke: k > 0 ? E : "none",
163
- strokeWidth: k,
164
- opacity: R ? 0.45 : 1,
165
- onMouseEnter: () => I(o.index),
166
- onMouseLeave: () => I(null),
167
- onClick: S,
168
- style: S ? { cursor: "pointer" } : void 0
169
- },
170
- o.index
171
- );
172
- }) }),
173
- (A || C) && N.map((o) => {
174
- const y = C ? C({ row: o.row, value: o.value, fraction: o.fraction, index: o.index }) : A ? `${String(o.row[n])} ${_ ? _(o.value) : Math.round(o.fraction * 100) + "%"}` : null;
175
- if (y == null) return null;
176
- const w = H === "inside", z = Math.max(16, l * 0.12), G = w ? (l + h) / 2 : l + z, $ = tt(s, g, G, o.start, o.end), R = w ? "middle" : $.x < s - 1 ? "end" : $.x > s + 1 ? "start" : "middle";
177
- let x = null;
178
- if (!w && U) {
179
- const T = tt(s, g, l, o.start, o.end), S = 4, st = R === "end" ? S : R === "start" ? -S : 0;
180
- x = { x1: T.x, y1: T.y, x2: $.x + st, y2: $.y };
181
- }
182
- return /* @__PURE__ */ J("g", { children: [
183
- x && /* @__PURE__ */ a(
184
- "line",
185
- {
186
- x1: x.x1,
187
- y1: x.y1,
188
- x2: x.x2,
189
- y2: x.y2,
190
- stroke: B(o.index),
191
- strokeWidth: 1,
192
- opacity: 0.7
193
- }
194
- ),
195
- /* @__PURE__ */ a(
196
- "text",
197
- {
198
- x: $.x,
199
- y: $.y,
200
- className: D(
201
- f.axisLabel,
202
- w && f.barLabelInside
203
- ),
204
- textAnchor: R,
205
- dominantBaseline: "middle",
206
- children: y
207
- }
208
- )
209
- ] }, `label-${o.index}`);
210
- }),
211
- Z !== void 0 && /* @__PURE__ */ a(
212
- "foreignObject",
213
- {
214
- x: s - h,
215
- y: g - h,
216
- width: Math.max(0, h * 2),
217
- height: Math.max(0, h * 2),
218
- style: { pointerEvents: "none" },
219
- children: /* @__PURE__ */ a(
220
- "div",
221
- {
222
- style: {
223
- width: "100%",
224
- height: "100%",
225
- display: "flex",
226
- flexDirection: "column",
227
- alignItems: "center",
228
- justifyContent: "center",
229
- textAlign: "center",
230
- color: "var(--crk-color-text)",
231
- fontFamily: "var(--crk-font-family)"
232
- },
233
- children: Z
234
- }
235
- )
236
- }
237
- )
238
- ] });
239
- }
240
- }
241
- );
60
+ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspectRatio: y = 1, height: b, innerRadius: x = 0, outerRadius: S = "90%", strokeWidth: C = 2, strokeColor: w = "var(--crk-color-bg)", padAngle: T = 0, showLabels: E = !1, valuePosition: D = "outside", showLabelLines: O = !0, renderLabel: k, centerLabel: A, activeIndex: j, onSliceClick: M, showLegend: N = !0, showTooltip: P = !0, valueFormat: F, renderTooltip: I, emptyMessage: L = "No data", className: R, style: z, classes: B }) {
61
+ let [V, H] = n(null), U = t(null), W = j ?? V, G = (e) => {
62
+ if (_) {
63
+ let t = m[e]?.[_];
64
+ if (typeof t == "string") return t;
65
+ }
66
+ return v[e % v.length];
67
+ }, K = e(() => {
68
+ let e = 0;
69
+ for (let t of m) {
70
+ let n = t[h];
71
+ typeof n == "number" && n > 0 && (e += n);
72
+ }
73
+ return e;
74
+ }, [m, h]), q = e(() => {
75
+ let e = [], t = 0;
76
+ for (let n = 0; n < m.length; n++) {
77
+ let r = m[n], i = r[h], a = typeof i == "number" && i > 0 ? i : 0;
78
+ if (a === 0) continue;
79
+ let o = a / K, s = o * 360;
80
+ e.push({
81
+ index: n,
82
+ row: r,
83
+ value: a,
84
+ start: t,
85
+ end: t + s,
86
+ fraction: o
87
+ }), t += s;
88
+ }
89
+ return e;
90
+ }, [
91
+ m,
92
+ h,
93
+ K
94
+ ]), J = N ? /* @__PURE__ */ c("div", {
95
+ className: r(o.legend, B?.legend),
96
+ role: "list",
97
+ children: q.map((e) => /* @__PURE__ */ l("div", {
98
+ className: r(o.legendItem, B?.legendItem),
99
+ role: "listitem",
100
+ children: [/* @__PURE__ */ c("span", {
101
+ className: o.legendSwatch,
102
+ style: { background: G(e.index) },
103
+ "aria-hidden": "true"
104
+ }), /* @__PURE__ */ c("span", {
105
+ className: o.legendLabel,
106
+ children: String(e.row[g])
107
+ })]
108
+ }, e.index))
109
+ }) : void 0, Y = e(() => {
110
+ let e = {};
111
+ for (let t of q) e[t.index.toString()] = {
112
+ label: String(t.row[g]),
113
+ color: G(t.index)
114
+ };
115
+ return e;
116
+ }, [q]);
117
+ return m.length === 0 || K === 0 ? /* @__PURE__ */ c("div", {
118
+ ref: U,
119
+ className: r(o.root, B?.root, R),
120
+ style: z,
121
+ children: /* @__PURE__ */ c("div", {
122
+ className: o.canvas,
123
+ style: { height: b ?? 240 },
124
+ children: /* @__PURE__ */ c("div", {
125
+ className: o.empty,
126
+ children: L
127
+ })
128
+ })
129
+ }) : /* @__PURE__ */ c(i, {
130
+ ref: U,
131
+ aspectRatio: y,
132
+ height: b,
133
+ className: R,
134
+ style: z,
135
+ classes: B,
136
+ legend: J,
137
+ overlay: P && W !== null && m[W] ? /* @__PURE__ */ c(a, {
138
+ row: { [W.toString()]: m[W][h] },
139
+ x: U.current ? U.current.getBoundingClientRect().width / 2 : 0,
140
+ y: 16,
141
+ containerWidth: U.current?.getBoundingClientRect().width ?? 0,
142
+ config: { [W.toString()]: Y[W.toString()] },
143
+ render: I ? () => I(m[W]) : void 0,
144
+ valueFormat: F,
145
+ titleKey: void 0,
146
+ classes: B
147
+ }) : null,
148
+ children: ({ width: e, height: t }) => {
149
+ let n = e / 2, i = t / 2, a = Math.min(e, t) / 2 - 4, u = d(S, a), m = Math.min(u - 1, d(x, a)), h = Math.max(4, u * .06);
150
+ return /* @__PURE__ */ l(s, { children: [
151
+ /* @__PURE__ */ c("g", { children: q.map((e) => {
152
+ let t = T / 2, r = Math.min(e.end, e.start + t), a = Math.max(e.start, e.end - t), o = G(e.index), s = W === e.index, l = j !== void 0 && !s, d = s && j !== void 0 ? u + h : u, p = f(n, i, d, m, r, a), g = M ? () => M({
153
+ row: e.row,
154
+ value: e.value,
155
+ index: e.index
156
+ }) : void 0;
157
+ return /* @__PURE__ */ c("path", {
158
+ d: p,
159
+ fill: o,
160
+ stroke: C > 0 ? w : "none",
161
+ strokeWidth: C,
162
+ opacity: l ? .45 : 1,
163
+ onMouseEnter: () => H(e.index),
164
+ onMouseLeave: () => H(null),
165
+ onClick: g,
166
+ style: g ? { cursor: "pointer" } : void 0
167
+ }, e.index);
168
+ }) }),
169
+ (E || k) && q.map((e) => {
170
+ let t = k ? k({
171
+ row: e.row,
172
+ value: e.value,
173
+ fraction: e.fraction,
174
+ index: e.index
175
+ }) : E ? `${String(e.row[g])} ${F ? F(e.value) : Math.round(e.fraction * 100) + "%"}` : null;
176
+ if (t == null) return null;
177
+ let a = D === "inside", s = Math.max(16, u * .12), d = a ? (u + m) / 2 : u + s, f = p(n, i, d, e.start, e.end), h = a ? "middle" : f.x < n - 1 ? "end" : f.x > n + 1 ? "start" : "middle", _ = null;
178
+ if (!a && O) {
179
+ let t = p(n, i, u, e.start, e.end), r = h === "end" ? 4 : h === "start" ? -4 : 0;
180
+ _ = {
181
+ x1: t.x,
182
+ y1: t.y,
183
+ x2: f.x + r,
184
+ y2: f.y
185
+ };
186
+ }
187
+ return /* @__PURE__ */ l("g", { children: [_ && /* @__PURE__ */ c("line", {
188
+ x1: _.x1,
189
+ y1: _.y1,
190
+ x2: _.x2,
191
+ y2: _.y2,
192
+ stroke: G(e.index),
193
+ strokeWidth: 1,
194
+ opacity: .7
195
+ }), /* @__PURE__ */ c("text", {
196
+ x: f.x,
197
+ y: f.y,
198
+ className: r(o.axisLabel, a && o.barLabelInside),
199
+ textAnchor: h,
200
+ dominantBaseline: "middle",
201
+ children: t
202
+ })] }, `label-${e.index}`);
203
+ }),
204
+ A !== void 0 && /* @__PURE__ */ c("foreignObject", {
205
+ x: n - m,
206
+ y: i - m,
207
+ width: Math.max(0, m * 2),
208
+ height: Math.max(0, m * 2),
209
+ style: { pointerEvents: "none" },
210
+ children: /* @__PURE__ */ c("div", {
211
+ style: {
212
+ width: "100%",
213
+ height: "100%",
214
+ display: "flex",
215
+ flexDirection: "column",
216
+ alignItems: "center",
217
+ justifyContent: "center",
218
+ textAlign: "center",
219
+ color: "var(--crk-color-text)",
220
+ fontFamily: "var(--crk-font-family)"
221
+ },
222
+ children: A
223
+ })
224
+ })
225
+ ] });
226
+ }
227
+ });
242
228
  }
243
- export {
244
- yt as PieChart
245
- };
229
+ export { m as PieChart };
@@ -83,4 +83,4 @@ export interface RadarChartProps<T extends Record<string, unknown>> {
83
83
  * }}
84
84
  * />
85
85
  */
86
- export declare function RadarChart<T extends Record<string, unknown>>({ data, axisKey, config, aspectRatio, height, gridType, showGrid, showRadialLines, showAxisLabels, showRadiusAxis, levels, showPoints, fillOpacity, strokeWidth, renderAxisLabel, axisFormat, valueFormat, renderTooltip, showLegend, showTooltip, emptyMessage, className, style, classes, }: RadarChartProps<T>): import("react/jsx-runtime").JSX.Element;
86
+ export declare function RadarChart<T extends Record<string, unknown>>({ data, axisKey, config, aspectRatio, height, gridType, showGrid, showRadialLines, showAxisLabels, showRadiusAxis, levels, showPoints, fillOpacity, strokeWidth, renderAxisLabel, axisFormat, valueFormat, renderTooltip, showLegend, showTooltip, emptyMessage, className, style, classes, }: RadarChartProps<T>): import("react").JSX.Element;