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