@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,218 +1,169 @@
1
- import { jsx as o, jsxs as _, Fragment as F } from "react/jsx-runtime";
2
- import { useState as nn, useRef as tn, useMemo as C } from "react";
3
- import h from "clsx";
4
- import { ChartContainer as en } from "./ChartContainer.js";
5
- import { ChartLegend as rn } from "./ChartLegend.js";
6
- import { ChartTooltip as on } from "./ChartTooltip.js";
7
- import { extent as cn, niceTicks as ln } from "./scales.js";
8
- import u from "./Chart.module.scss.js";
9
- function R(e, f, m, M) {
10
- const g = (M - 90) * Math.PI / 180;
11
- return { x: e + m * Math.cos(g), y: f + m * Math.sin(g) };
1
+ import { useMemo as e, useRef as t, useState as n } from "react";
2
+ import r from "clsx";
3
+ import { ChartContainer as i } from "./ChartContainer.js";
4
+ import { ChartLegend as a } from "./ChartLegend.js";
5
+ import { ChartTooltip as o } from "./ChartTooltip.js";
6
+ import { extent as s, niceTicks as c } from "./scales.js";
7
+ import l from "./Chart.module.scss.js";
8
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
+ // src/components/Chart/RadarChart.tsx
10
+ function p(e, t, n, r) {
11
+ let i = (r - 90) * Math.PI / 180;
12
+ return {
13
+ x: e + n * Math.cos(i),
14
+ y: t + n * Math.sin(i)
15
+ };
12
16
  }
13
- function sn(e, f, m, M) {
14
- return M.map((g) => {
15
- const v = R(e, f, m, g);
16
- return `${v.x},${v.y}`;
17
- }).join(" ");
17
+ function m(e, t, n, r) {
18
+ return r.map((r) => {
19
+ let i = p(e, t, n, r);
20
+ return `${i.x},${i.y}`;
21
+ }).join(" ");
18
22
  }
19
- function yn({
20
- data: e,
21
- axisKey: f,
22
- config: m,
23
- aspectRatio: M = 1,
24
- height: g,
25
- gridType: v = "polygon",
26
- showGrid: q = !0,
27
- showRadialLines: z = !0,
28
- showAxisLabels: A = !0,
29
- showRadiusAxis: D = !1,
30
- levels: I = 5,
31
- showPoints: E = !0,
32
- fillOpacity: G = 0.4,
33
- strokeWidth: H = 2,
34
- renderAxisLabel: S,
35
- axisFormat: X,
36
- valueFormat: j,
37
- renderTooltip: Y,
38
- showLegend: J = !0,
39
- showTooltip: Q = !0,
40
- emptyMessage: U = "No data",
41
- className: K,
42
- style: O,
43
- classes: c
44
- }) {
45
- const [$, W] = nn(null), N = tn(null), P = C(() => Object.keys(m), [m]), L = C(
46
- () => e.map((d, p) => p / e.length * 360),
47
- [e]
48
- ), B = C(() => {
49
- const d = [];
50
- for (const T of P)
51
- for (const i of e) {
52
- const l = i[T];
53
- typeof l == "number" && d.push(l);
54
- }
55
- const [, p] = cn(d);
56
- return Math.max(1, p);
57
- }, [e, P]), b = C(() => ln(0, B, I).filter((p) => p > 0), [B, I]), V = b[b.length - 1] ?? B;
58
- return e.length === 0 ? /* @__PURE__ */ o("div", { ref: N, className: h(u.root, c?.root, K), style: O, children: /* @__PURE__ */ o("div", { className: u.canvas, style: { height: g ?? 240 }, children: /* @__PURE__ */ o("div", { className: u.empty, children: U }) }) }) : /* @__PURE__ */ o(
59
- en,
60
- {
61
- ref: N,
62
- aspectRatio: M,
63
- height: g,
64
- className: K,
65
- style: O,
66
- classes: c,
67
- legend: J ? /* @__PURE__ */ o(rn, { config: m, classes: c }) : void 0,
68
- overlay: Q && $ !== null ? /* @__PURE__ */ o(
69
- on,
70
- {
71
- row: e[$],
72
- x: (N.current?.getBoundingClientRect().width ?? 0) / 2,
73
- y: 16,
74
- containerWidth: N.current?.getBoundingClientRect().width ?? 0,
75
- config: m,
76
- render: Y ? () => Y(e[$]) : void 0,
77
- valueFormat: j,
78
- titleKey: f,
79
- classes: c
80
- }
81
- ) : null,
82
- children: ({ width: d, height: p }) => {
83
- const T = A ? 32 : 8, i = d / 2, l = p / 2, w = Math.max(0, Math.min(d, p) / 2 - T), k = (n) => Math.max(0, n) / V * w;
84
- return /* @__PURE__ */ _(F, { children: [
85
- q && b.map((n) => {
86
- const t = k(n);
87
- return v === "circle" ? /* @__PURE__ */ o(
88
- "circle",
89
- {
90
- className: h(u.gridLine, c?.grid),
91
- cx: i,
92
- cy: l,
93
- r: t,
94
- fill: "none"
95
- },
96
- `ring-${n}`
97
- ) : /* @__PURE__ */ o(
98
- "polygon",
99
- {
100
- className: h(u.gridLine, c?.grid),
101
- points: sn(i, l, t, L),
102
- fill: "none"
103
- },
104
- `ring-${n}`
105
- );
106
- }),
107
- z && L.map((n, t) => {
108
- const s = R(i, l, w, n);
109
- return /* @__PURE__ */ o(
110
- "line",
111
- {
112
- className: h(u.gridLine, c?.grid),
113
- x1: i,
114
- y1: l,
115
- x2: s.x,
116
- y2: s.y
117
- },
118
- `spoke-${t}`
119
- );
120
- }),
121
- D && b.map((n) => {
122
- const t = k(n);
123
- return /* @__PURE__ */ o(
124
- "text",
125
- {
126
- className: h(u.axisLabel, c?.axisLabel),
127
- x: i + 4,
128
- y: l - t,
129
- textAnchor: "start",
130
- dominantBaseline: "middle",
131
- children: j ? j(n) : n
132
- },
133
- `raxis-${n}`
134
- );
135
- }),
136
- A && e.map((n, t) => {
137
- const s = L[t], a = R(i, l, w + 14, s), r = a.x < i - 1 ? "end" : a.x > i + 1 ? "start" : "middle";
138
- if (S)
139
- return /* @__PURE__ */ o("g", { children: S({
140
- row: n,
141
- index: t,
142
- angle: s,
143
- x: a.x,
144
- y: a.y,
145
- textAnchor: r
146
- }) }, `label-${t}`);
147
- const x = String(n[f]), y = X ? X(x) : x;
148
- return /* @__PURE__ */ o(
149
- "text",
150
- {
151
- className: h(u.axisLabel, c?.axisLabel),
152
- x: a.x,
153
- y: a.y,
154
- textAnchor: r,
155
- dominantBaseline: "middle",
156
- children: y
157
- },
158
- `label-${t}`
159
- );
160
- }),
161
- P.map((n) => {
162
- const t = m[n], s = e.map((r, x) => {
163
- const y = r[n], Z = k(typeof y == "number" ? y : 0);
164
- return R(i, l, Z, L[x]);
165
- }), a = s.map((r) => `${r.x},${r.y}`).join(" ");
166
- return /* @__PURE__ */ _("g", { className: h(u.series, c?.series), children: [
167
- /* @__PURE__ */ o(
168
- "polygon",
169
- {
170
- points: a,
171
- fill: t.color,
172
- fillOpacity: G,
173
- stroke: t.color,
174
- strokeWidth: H,
175
- strokeLinejoin: "round",
176
- strokeLinecap: "round"
177
- }
178
- ),
179
- E && s.map((r, x) => /* @__PURE__ */ o(
180
- "circle",
181
- {
182
- className: h(u.point, c?.point),
183
- cx: r.x,
184
- cy: r.y,
185
- r: $ === x ? 5 : 3.5,
186
- fill: t.color
187
- },
188
- `${n}-${x}`
189
- ))
190
- ] }, n);
191
- }),
192
- /* @__PURE__ */ o(
193
- "rect",
194
- {
195
- className: u.interactionLayer,
196
- x: 0,
197
- y: 0,
198
- width: d,
199
- height: p,
200
- onMouseMove: (n) => {
201
- const t = n.currentTarget.getBoundingClientRect(), s = n.clientX - t.left - i, a = n.clientY - t.top - l;
202
- if (s === 0 && a === 0) return;
203
- let r = Math.atan2(a, s) * 180 / Math.PI + 90;
204
- r < 0 && (r += 360), r >= 360 && (r -= 360);
205
- const x = 360 / e.length, y = Math.round(r / x) % e.length;
206
- W(y);
207
- },
208
- onMouseLeave: () => W(null)
209
- }
210
- )
211
- ] });
212
- }
213
- }
214
- );
23
+ function h({ data: h, axisKey: g, config: _, aspectRatio: v = 1, height: y, gridType: b = "polygon", showGrid: x = !0, showRadialLines: S = !0, showAxisLabels: C = !0, showRadiusAxis: w = !1, levels: T = 5, showPoints: E = !0, fillOpacity: D = .4, strokeWidth: O = 2, renderAxisLabel: k, axisFormat: A, valueFormat: j, renderTooltip: M, showLegend: N = !0, showTooltip: P = !0, emptyMessage: F = "No data", className: I, style: L, classes: R }) {
24
+ let [z, B] = n(null), V = t(null), H = e(() => Object.keys(_), [_]), U = e(() => h.map((e, t) => t / h.length * 360), [h]), W = e(() => {
25
+ let e = [];
26
+ for (let t of H) for (let n of h) {
27
+ let r = n[t];
28
+ typeof r == "number" && e.push(r);
29
+ }
30
+ let [, t] = s(e);
31
+ return Math.max(1, t);
32
+ }, [h, H]), G = e(() => c(0, W, T).filter((e) => e > 0), [W, T]), K = G[G.length - 1] ?? W;
33
+ return h.length === 0 ? /* @__PURE__ */ d("div", {
34
+ ref: V,
35
+ className: r(l.root, R?.root, I),
36
+ style: L,
37
+ children: /* @__PURE__ */ d("div", {
38
+ className: l.canvas,
39
+ style: { height: y ?? 240 },
40
+ children: /* @__PURE__ */ d("div", {
41
+ className: l.empty,
42
+ children: F
43
+ })
44
+ })
45
+ }) : /* @__PURE__ */ d(i, {
46
+ ref: V,
47
+ aspectRatio: v,
48
+ height: y,
49
+ className: I,
50
+ style: L,
51
+ classes: R,
52
+ legend: N ? /* @__PURE__ */ d(a, {
53
+ config: _,
54
+ classes: R
55
+ }) : void 0,
56
+ overlay: P && z !== null ? /* @__PURE__ */ d(o, {
57
+ row: h[z],
58
+ x: (V.current?.getBoundingClientRect().width ?? 0) / 2,
59
+ y: 16,
60
+ containerWidth: V.current?.getBoundingClientRect().width ?? 0,
61
+ config: _,
62
+ render: M ? () => M(h[z]) : void 0,
63
+ valueFormat: j,
64
+ titleKey: g,
65
+ classes: R
66
+ }) : null,
67
+ children: ({ width: e, height: t }) => {
68
+ let n = C ? 32 : 8, i = e / 2, a = t / 2, o = Math.max(0, Math.min(e, t) / 2 - n), s = (e) => Math.max(0, e) / K * o;
69
+ return /* @__PURE__ */ f(u, { children: [
70
+ x && G.map((e) => {
71
+ let t = s(e);
72
+ return b === "circle" ? /* @__PURE__ */ d("circle", {
73
+ className: r(l.gridLine, R?.grid),
74
+ cx: i,
75
+ cy: a,
76
+ r: t,
77
+ fill: "none"
78
+ }, `ring-${e}`) : /* @__PURE__ */ d("polygon", {
79
+ className: r(l.gridLine, R?.grid),
80
+ points: m(i, a, t, U),
81
+ fill: "none"
82
+ }, `ring-${e}`);
83
+ }),
84
+ S && U.map((e, t) => {
85
+ let n = p(i, a, o, e);
86
+ return /* @__PURE__ */ d("line", {
87
+ className: r(l.gridLine, R?.grid),
88
+ x1: i,
89
+ y1: a,
90
+ x2: n.x,
91
+ y2: n.y
92
+ }, `spoke-${t}`);
93
+ }),
94
+ w && G.map((e) => {
95
+ let t = s(e);
96
+ return /* @__PURE__ */ d("text", {
97
+ className: r(l.axisLabel, R?.axisLabel),
98
+ x: i + 4,
99
+ y: a - t,
100
+ textAnchor: "start",
101
+ dominantBaseline: "middle",
102
+ children: j ? j(e) : e
103
+ }, `raxis-${e}`);
104
+ }),
105
+ C && h.map((e, t) => {
106
+ let n = U[t], s = p(i, a, o + 14, n), c = s.x < i - 1 ? "end" : s.x > i + 1 ? "start" : "middle";
107
+ if (k) return /* @__PURE__ */ d("g", { children: k({
108
+ row: e,
109
+ index: t,
110
+ angle: n,
111
+ x: s.x,
112
+ y: s.y,
113
+ textAnchor: c
114
+ }) }, `label-${t}`);
115
+ let u = String(e[g]), f = A ? A(u) : u;
116
+ return /* @__PURE__ */ d("text", {
117
+ className: r(l.axisLabel, R?.axisLabel),
118
+ x: s.x,
119
+ y: s.y,
120
+ textAnchor: c,
121
+ dominantBaseline: "middle",
122
+ children: f
123
+ }, `label-${t}`);
124
+ }),
125
+ H.map((e) => {
126
+ let t = _[e], n = h.map((t, n) => {
127
+ let r = t[e], o = s(typeof r == "number" ? r : 0);
128
+ return p(i, a, o, U[n]);
129
+ }), o = n.map((e) => `${e.x},${e.y}`).join(" ");
130
+ return /* @__PURE__ */ f("g", {
131
+ className: r(l.series, R?.series),
132
+ children: [/* @__PURE__ */ d("polygon", {
133
+ points: o,
134
+ fill: t.color,
135
+ fillOpacity: D,
136
+ stroke: t.color,
137
+ strokeWidth: O,
138
+ strokeLinejoin: "round",
139
+ strokeLinecap: "round"
140
+ }), E && n.map((n, i) => /* @__PURE__ */ d("circle", {
141
+ className: r(l.point, R?.point),
142
+ cx: n.x,
143
+ cy: n.y,
144
+ r: z === i ? 5 : 3.5,
145
+ fill: t.color
146
+ }, `${e}-${i}`))]
147
+ }, e);
148
+ }),
149
+ /* @__PURE__ */ d("rect", {
150
+ className: l.interactionLayer,
151
+ x: 0,
152
+ y: 0,
153
+ width: e,
154
+ height: t,
155
+ onMouseMove: (e) => {
156
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left - i, r = e.clientY - t.top - a;
157
+ if (n === 0 && r === 0) return;
158
+ let o = Math.atan2(r, n) * 180 / Math.PI + 90;
159
+ o < 0 && (o += 360), o >= 360 && (o -= 360);
160
+ let s = 360 / h.length, c = Math.round(o / s) % h.length;
161
+ B(c);
162
+ },
163
+ onMouseLeave: () => B(null)
164
+ })
165
+ ] });
166
+ }
167
+ });
215
168
  }
216
- export {
217
- yn as RadarChart
218
- };
169
+ export { h as RadarChart };
@@ -1,69 +1,74 @@
1
- import { jsxs as B, jsx as u } from "react/jsx-runtime";
2
- import { forwardRef as C, useMemo as H } from "react";
3
- import R from "clsx";
4
- import { extent as Z, linearScale as j } from "./scales.js";
5
- import d from "./Chart.module.scss.js";
6
- function q(n, o) {
7
- if (n.length === 0) return "";
8
- if (n.length === 1 || o === "linear")
9
- return n.map((e, a) => `${a === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
10
- let t = `M ${n[0].x} ${n[0].y}`;
11
- for (let e = 0; e < n.length - 1; e++) {
12
- const a = n[e - 1] ?? n[e], c = n[e], r = n[e + 1], x = n[e + 2] ?? r, m = c.x + (r.x - a.x) / 6, i = c.y + (r.y - a.y) / 6, y = r.x - (x.x - c.x) / 6, $ = r.y - (x.y - c.y) / 6;
13
- t += ` C ${m} ${i}, ${y} ${$}, ${r.x} ${r.y}`;
14
- }
15
- return t;
1
+ import { forwardRef as e, useMemo as t } from "react";
2
+ import n from "clsx";
3
+ import { extent as r, linearScale as i } from "./scales.js";
4
+ import a from "./Chart.module.scss.js";
5
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
+ // src/components/Chart/Sparkline.tsx
7
+ function c(e, t) {
8
+ if (e.length === 0) return "";
9
+ if (e.length === 1 || t === "linear") return e.map((e, t) => `${t === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
10
+ let n = `M ${e[0].x} ${e[0].y}`;
11
+ for (let t = 0; t < e.length - 1; t++) {
12
+ 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;
13
+ n += ` C ${s} ${c}, ${l} ${u}, ${a.x} ${a.y}`;
14
+ }
15
+ return n;
16
16
  }
17
- const z = C(
18
- ({
19
- data: n,
20
- width: o = 80,
21
- height: t = 24,
22
- color: e = "var(--crk-chart-1)",
23
- strokeWidth: a = 1.5,
24
- curve: c = "monotone",
25
- fill: r = !1,
26
- showLastPoint: x = !1,
27
- "aria-label": m,
28
- className: i,
29
- style: y
30
- }, $) => {
31
- const { line: g, area: M, last: f } = H(() => {
32
- if (n.length === 0) return { line: "", area: "", last: null };
33
- const l = a, k = Math.max(1, o - l * 2), p = Math.max(1, t - l * 2), [h, D] = Z(n), S = j([0, Math.max(1, n.length - 1)], [l, l + k]), b = j([h, D], [l + p, l]), s = n.map((N, V) => ({ x: S(V), y: b(N) })), L = q(s, c), v = r ? `${L} L ${s[s.length - 1].x} ${l + p} L ${s[0].x} ${l + p} Z` : "";
34
- return { line: L, area: v, last: s[s.length - 1] };
35
- }, [n, o, t, a, c, r]);
36
- return /* @__PURE__ */ B(
37
- "svg",
38
- {
39
- ref: $,
40
- className: R(d.sparkline, i),
41
- style: y,
42
- width: o,
43
- height: t,
44
- viewBox: `0 0 ${o} ${t}`,
45
- role: "img",
46
- "aria-label": m,
47
- children: [
48
- r && M && /* @__PURE__ */ u("path", { d: M, fill: e, opacity: 0.18 }),
49
- g && /* @__PURE__ */ u(
50
- "path",
51
- {
52
- d: g,
53
- fill: "none",
54
- stroke: e,
55
- strokeWidth: a,
56
- strokeLinejoin: "round",
57
- strokeLinecap: "round"
58
- }
59
- ),
60
- x && f && /* @__PURE__ */ u("circle", { cx: f.x, cy: f.y, r: a + 1, fill: e })
61
- ]
62
- }
63
- );
64
- }
65
- );
66
- z.displayName = "Sparkline";
67
- export {
68
- z as Sparkline
69
- };
17
+ var l = e(({ data: e, width: l = 80, height: u = 24, color: d = "var(--crk-chart-1)", strokeWidth: f = 1.5, curve: p = "monotone", fill: m = !1, showLastPoint: h = !1, "aria-label": g, className: _, style: v }, y) => {
18
+ let { line: b, area: x, last: S } = t(() => {
19
+ if (e.length === 0) return {
20
+ line: "",
21
+ area: "",
22
+ last: null
23
+ };
24
+ let t = f, n = Math.max(1, l - t * 2), a = Math.max(1, u - t * 2), [o, s] = r(e), d = i([0, Math.max(1, e.length - 1)], [t, t + n]), h = i([o, s], [t + a, t]), g = e.map((e, t) => ({
25
+ x: d(t),
26
+ y: h(e)
27
+ })), _ = c(g, p);
28
+ return {
29
+ line: _,
30
+ area: m ? `${_} L ${g[g.length - 1].x} ${t + a} L ${g[0].x} ${t + a} Z` : "",
31
+ last: g[g.length - 1]
32
+ };
33
+ }, [
34
+ e,
35
+ l,
36
+ u,
37
+ f,
38
+ p,
39
+ m
40
+ ]);
41
+ return /* @__PURE__ */ s("svg", {
42
+ ref: y,
43
+ className: n(a.sparkline, _),
44
+ style: v,
45
+ width: l,
46
+ height: u,
47
+ viewBox: `0 0 ${l} ${u}`,
48
+ role: "img",
49
+ "aria-label": g,
50
+ children: [
51
+ m && x && /* @__PURE__ */ o("path", {
52
+ d: x,
53
+ fill: d,
54
+ opacity: .18
55
+ }),
56
+ b && /* @__PURE__ */ o("path", {
57
+ d: b,
58
+ fill: "none",
59
+ stroke: d,
60
+ strokeWidth: f,
61
+ strokeLinejoin: "round",
62
+ strokeLinecap: "round"
63
+ }),
64
+ h && S && /* @__PURE__ */ o("circle", {
65
+ cx: S.x,
66
+ cy: S.y,
67
+ r: f + 1,
68
+ fill: d
69
+ })
70
+ ]
71
+ });
72
+ });
73
+ l.displayName = "Sparkline";
74
+ export { l as Sparkline };
@@ -107,7 +107,7 @@ export interface TradingChartProps {
107
107
  * ]}
108
108
  * />
109
109
  */
110
- export declare function TradingChart({ datafeed, symbol, resolution, period, seriesType, indicators, precision, initialLookback, height, upColor, downColor, lineColor, timezone, defaultTimezone, onTimezoneChange, showConfigPanel, priceBadgeColorByDirection, priceBadgeShowTime, priceBadgeTimeFormat, onCrosshair, onVisibleRangeChange, className, style, }: TradingChartProps): import("react/jsx-runtime").JSX.Element;
110
+ export declare function TradingChart({ datafeed, symbol, resolution, period, seriesType, indicators, precision, initialLookback, height, upColor, downColor, lineColor, timezone, defaultTimezone, onTimezoneChange, showConfigPanel, priceBadgeColorByDirection, priceBadgeShowTime, priceBadgeTimeFormat, onCrosshair, onVisibleRangeChange, className, style, }: TradingChartProps): import("react").JSX.Element;
111
111
  /**
112
112
  * Full crosshair date/time label with a timezone tag.
113
113
  * Format: `YYYY-MM-DD HH:MM:SS <tz>` — `<tz>` is `+HH:MM` for local,