@overdoser/react-toolkit 0.21.0 → 0.22.1
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 +1 -0
- package/CHANGELOG.md +35 -0
- package/components/Accordion/Accordion.js +48 -48
- package/components/ActionButton/ActionButton.js +23 -23
- package/components/ActionButton/CopyButton.js +5 -5
- package/components/Alert/Alert.js +13 -13
- package/components/Avatar/Avatar.js +12 -12
- package/components/Badge/Badge.js +6 -6
- package/components/Breadcrumbs/Breadcrumbs.js +15 -15
- package/components/Button/Button.js +14 -14
- package/components/Card/Card.js +26 -26
- package/components/Chart/AreaChart.js +103 -103
- package/components/Chart/Axis.js +7 -7
- package/components/Chart/BarChart.js +62 -62
- package/components/Chart/ChartContainer.js +11 -11
- package/components/Chart/ChartLegend.js +7 -7
- package/components/Chart/ChartTooltip.js +13 -13
- package/components/Chart/LineChart.js +88 -88
- package/components/Chart/PieChart.js +25 -25
- package/components/Chart/RadarChart.js +42 -42
- package/components/Chart/Sparkline.js +11 -11
- package/components/Chart/TradingChart.js +126 -126
- package/components/Chart/trading/period.js +3 -3
- package/components/Chip/Chip.js +24 -24
- package/components/CodeBlock/CodeBlock.js +31 -31
- package/components/CommandPalette/CommandPalette.js +166 -166
- package/components/ConfirmDialog/ConfirmDialog.js +60 -60
- package/components/Divider/Divider.js +10 -10
- package/components/Draggable/Draggable.js +29 -29
- package/components/Drawer/Drawer.js +53 -53
- package/components/Dropdown/Dropdown.js +66 -66
- package/components/Dropdown/DropdownItem.js +13 -13
- package/components/Dropdown/DropdownLabel.js +5 -5
- package/components/Dropdown/DropdownSeparator.js +5 -5
- package/components/Dropzone/Dropzone.js +15 -15
- package/components/EmptyState/EmptyState.js +11 -11
- package/components/Form/Form.js +17 -17
- package/components/Form/FormField.js +21 -21
- package/components/Form/FormRow.js +3 -3
- package/components/ImageViewer/ImageViewer.js +118 -118
- package/components/Kbd/Kbd.js +11 -11
- package/components/KeyValueList/KeyValueList.js +32 -32
- package/components/Link/Link.js +7 -7
- package/components/List/List.js +7 -7
- package/components/Loader/Loader.js +39 -39
- package/components/Modal/Modal.js +48 -48
- package/components/PageHeader/PageHeader.js +18 -18
- package/components/Pagination/Pagination.js +23 -23
- package/components/Popover/Popover.js +25 -25
- package/components/ProgressBar/ProgressBar.js +17 -17
- package/components/RelativeTime/RelativeTime.js +10 -10
- package/components/SegmentedControl/SegmentedControl.js +38 -38
- package/components/Skeleton/Skeleton.js +10 -10
- package/components/Spinner/Spinner.js +7 -7
- package/components/SplitButton/SplitButton.js +63 -63
- package/components/SplitPane/SplitPane.js +50 -50
- package/components/StatCard/StatCard.js +32 -32
- package/components/StatusDot/StatusDot.js +7 -7
- package/components/Table/Table.js +174 -174
- package/components/Tabs/Tabs.js +47 -47
- package/components/ThemeToggle/ThemeToggle.js +31 -31
- package/components/Timeline/GanttTimeline.js +213 -213
- package/components/Timeline/HistoryTimeline.js +306 -306
- package/components/Timeline/TimelineShared.js +103 -103
- package/components/Timeline/TraceEventDetails.js +103 -103
- package/components/Timeline/TraceTimeline.js +546 -546
- package/components/Timeline/historyLayout.js +2 -2
- package/components/Timer/Timer.js +39 -39
- package/components/Toast/Toast.js +59 -59
- package/components/ToggleIconButton/ToggleIconButton.js +9 -9
- package/components/Tooltip/Tooltip.js +16 -16
- package/components/Typography/Typography.js +5 -5
- package/components/inputs/Checkbox/Checkbox.js +11 -11
- package/components/inputs/Checkbox/CheckboxGroup.js +21 -21
- package/components/inputs/DatePicker/CalendarPanel.js +113 -113
- package/components/inputs/DatePicker/DatePicker.js +39 -39
- package/components/inputs/DateTimePicker/DateTimePicker.js +119 -119
- package/components/inputs/DateTimePicker/DateTimeSegments.js +40 -40
- package/components/inputs/DateTimePicker/TimeField.js +34 -34
- package/components/inputs/Input/Input.js +13 -13
- package/components/inputs/NumberInput/NumberInput.js +16 -16
- package/components/inputs/Radio/Radio.js +17 -17
- package/components/inputs/SearchInput/SearchInput.js +25 -25
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +485 -344
- package/components/inputs/Select/{Select.module.js → Select.module.scss.js} +15 -3
- package/components/inputs/Slider/Slider.js +21 -21
- package/components/inputs/Switch/Switch.js +4 -4
- package/components/inputs/Textarea/Textarea.js +8 -8
- package/hooks/usePortalPosition.d.ts +2 -1
- package/hooks/usePortalPosition.js +6 -3
- package/hooks/useResizable.js +1 -1
- package/hooks/useTheme.js +7 -7
- package/index.css +1 -1
- package/index.js +1 -1
- package/index.layered.css +1 -1
- package/llms.txt +25 -4
- package/manifest.json +33 -4
- package/package.json +1 -1
- /package/components/Accordion/{Accordion.module.js → Accordion.module.scss.js} +0 -0
- /package/components/ActionButton/{ActionButton.module.js → ActionButton.module.scss.js} +0 -0
- /package/components/Alert/{Alert.module.js → Alert.module.scss.js} +0 -0
- /package/components/Avatar/{Avatar.module.js → Avatar.module.scss.js} +0 -0
- /package/components/Badge/{Badge.module.js → Badge.module.scss.js} +0 -0
- /package/components/Breadcrumbs/{Breadcrumbs.module.js → Breadcrumbs.module.scss.js} +0 -0
- /package/components/Button/{Button.module.js → Button.module.scss.js} +0 -0
- /package/components/Card/{Card.module.js → Card.module.scss.js} +0 -0
- /package/components/Chart/{Chart.module.js → Chart.module.scss.js} +0 -0
- /package/components/Chip/{Chip.module.js → Chip.module.scss.js} +0 -0
- /package/components/CodeBlock/{CodeBlock.module.js → CodeBlock.module.scss.js} +0 -0
- /package/components/CommandPalette/{CommandPalette.module.js → CommandPalette.module.scss.js} +0 -0
- /package/components/ConfirmDialog/{ConfirmDialog.module.js → ConfirmDialog.module.scss.js} +0 -0
- /package/components/Divider/{Divider.module.js → Divider.module.scss.js} +0 -0
- /package/components/Draggable/{Draggable.module.js → Draggable.module.scss.js} +0 -0
- /package/components/Drawer/{Drawer.module.js → Drawer.module.scss.js} +0 -0
- /package/components/Dropdown/{Dropdown.module.js → Dropdown.module.scss.js} +0 -0
- /package/components/Dropzone/{Dropzone.module.js → Dropzone.module.scss.js} +0 -0
- /package/components/EmptyState/{EmptyState.module.js → EmptyState.module.scss.js} +0 -0
- /package/components/Form/{Form.module.js → Form.module.scss.js} +0 -0
- /package/components/ImageViewer/{ImageViewer.module.js → ImageViewer.module.scss.js} +0 -0
- /package/components/Kbd/{Kbd.module.js → Kbd.module.scss.js} +0 -0
- /package/components/KeyValueList/{KeyValueList.module.js → KeyValueList.module.scss.js} +0 -0
- /package/components/Link/{Link.module.js → Link.module.scss.js} +0 -0
- /package/components/List/{List.module.js → List.module.scss.js} +0 -0
- /package/components/Loader/{Loader.module.js → Loader.module.scss.js} +0 -0
- /package/components/Modal/{Modal.module.js → Modal.module.scss.js} +0 -0
- /package/components/PageHeader/{PageHeader.module.js → PageHeader.module.scss.js} +0 -0
- /package/components/Pagination/{Pagination.module.js → Pagination.module.scss.js} +0 -0
- /package/components/Popover/{Popover.module.js → Popover.module.scss.js} +0 -0
- /package/components/ProgressBar/{ProgressBar.module.js → ProgressBar.module.scss.js} +0 -0
- /package/components/RelativeTime/{RelativeTime.module.js → RelativeTime.module.scss.js} +0 -0
- /package/components/SegmentedControl/{SegmentedControl.module.js → SegmentedControl.module.scss.js} +0 -0
- /package/components/Skeleton/{Skeleton.module.js → Skeleton.module.scss.js} +0 -0
- /package/components/Spinner/{Spinner.module.js → Spinner.module.scss.js} +0 -0
- /package/components/SplitButton/{SplitButton.module.js → SplitButton.module.scss.js} +0 -0
- /package/components/SplitPane/{SplitPane.module.js → SplitPane.module.scss.js} +0 -0
- /package/components/StatCard/{StatCard.module.js → StatCard.module.scss.js} +0 -0
- /package/components/StatusDot/{StatusDot.module.js → StatusDot.module.scss.js} +0 -0
- /package/components/Table/{Table.module.js → Table.module.scss.js} +0 -0
- /package/components/Tabs/{Tabs.module.js → Tabs.module.scss.js} +0 -0
- /package/components/ThemeToggle/{ThemeToggle.module.js → ThemeToggle.module.scss.js} +0 -0
- /package/components/Timeline/{GanttTimeline.module.js → GanttTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{HistoryTimeline.module.js → HistoryTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{Timeline.module.js → Timeline.module.scss.js} +0 -0
- /package/components/Timeline/{TraceTimeline.module.js → TraceTimeline.module.scss.js} +0 -0
- /package/components/Timer/{Timer.module.js → Timer.module.scss.js} +0 -0
- /package/components/Toast/{Toast.module.js → Toast.module.scss.js} +0 -0
- /package/components/ToggleIconButton/{ToggleIconButton.module.js → ToggleIconButton.module.scss.js} +0 -0
- /package/components/Tooltip/{Tooltip.module.js → Tooltip.module.scss.js} +0 -0
- /package/components/Typography/{Typography.module.js → Typography.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{Checkbox.module.js → Checkbox.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{CheckboxGroup.module.js → CheckboxGroup.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{CalendarPanel.module.js → CalendarPanel.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{DatePicker.module.js → DatePicker.module.scss.js} +0 -0
- /package/components/inputs/DateTimePicker/{DateTimePicker.module.js → DateTimePicker.module.scss.js} +0 -0
- /package/components/inputs/Input/{Input.module.js → Input.module.scss.js} +0 -0
- /package/components/inputs/NumberInput/{NumberInput.module.js → NumberInput.module.scss.js} +0 -0
- /package/components/inputs/Radio/{Radio.module.js → Radio.module.scss.js} +0 -0
- /package/components/inputs/SearchInput/{SearchInput.module.js → SearchInput.module.scss.js} +0 -0
- /package/components/inputs/Slider/{Slider.module.js → Slider.module.scss.js} +0 -0
- /package/components/inputs/Textarea/{Textarea.module.js → Textarea.module.scss.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import p from "
|
|
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 { XAxis as s, YAxis as c } from "./Axis.js";
|
|
7
|
+
import { bandScale as l, extent as u, linearScale as d, niceTicks as f } from "./scales.js";
|
|
8
|
+
import p from "./Chart.module.scss.js";
|
|
9
9
|
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
10
10
|
// src/components/Chart/LineChart.tsx
|
|
11
11
|
var _ = {
|
|
@@ -35,164 +35,164 @@ function y(e, t = 8) {
|
|
|
35
35
|
let n = Math.ceil(e.length / t);
|
|
36
36
|
return e.filter((e, t) => t % n === 0);
|
|
37
37
|
}
|
|
38
|
-
function b({ data: b, xKey: S, config: C, aspectRatio: w = 16 / 9, height: T, curve: E = "monotone", showPoints:
|
|
39
|
-
let
|
|
38
|
+
function b({ data: b, xKey: S, config: C, aspectRatio: w = 16 / 9, height: T, curve: E = "monotone", showPoints: D = !0, dotColorKey: O, renderDot: k, showValues: A = !1, valuePosition: j = "top", renderLabel: M, activeIndex: N, onPointClick: P, showGrid: F = !0, showLegend: I = !0, showTooltip: L = !0, yTickCount: R = 5, yFormat: z, xFormat: B, valueFormat: V, renderTooltip: H, margin: U, emptyMessage: W = "No data", className: G, style: K, classes: q }) {
|
|
39
|
+
let J = {
|
|
40
40
|
..._,
|
|
41
|
-
...
|
|
42
|
-
},
|
|
43
|
-
if (
|
|
44
|
-
let e = b[t]?.[
|
|
41
|
+
...U
|
|
42
|
+
}, Y = e(() => Object.keys(C), [C]), [ee, X] = n(null), Z = t(null), Q = N ?? ee, $ = (e, t) => {
|
|
43
|
+
if (O) {
|
|
44
|
+
let e = b[t]?.[O];
|
|
45
45
|
if (typeof e == "string") return e;
|
|
46
46
|
}
|
|
47
47
|
return C[e]?.color ?? "var(--crk-chart-1)";
|
|
48
48
|
};
|
|
49
49
|
if (b.length === 0) return /* @__PURE__ */ h("div", {
|
|
50
50
|
ref: Z,
|
|
51
|
-
className: p
|
|
52
|
-
style:
|
|
51
|
+
className: r(p.root, q?.root, G),
|
|
52
|
+
style: K,
|
|
53
53
|
children: /* @__PURE__ */ h("div", {
|
|
54
|
-
className:
|
|
54
|
+
className: p.canvas,
|
|
55
55
|
style: { height: T ?? 240 },
|
|
56
56
|
children: /* @__PURE__ */ h("div", {
|
|
57
|
-
className:
|
|
58
|
-
children:
|
|
57
|
+
className: p.empty,
|
|
58
|
+
children: W
|
|
59
59
|
})
|
|
60
60
|
})
|
|
61
61
|
});
|
|
62
|
-
let te =
|
|
62
|
+
let te = L && Q !== null ? /* @__PURE__ */ h(o, {
|
|
63
63
|
row: b[Q],
|
|
64
|
-
x: x(b, S,
|
|
64
|
+
x: x(b, S, J, Q, Z),
|
|
65
65
|
y: 16,
|
|
66
66
|
containerWidth: Z.current?.getBoundingClientRect().width ?? 0,
|
|
67
67
|
config: C,
|
|
68
|
-
render:
|
|
69
|
-
valueFormat:
|
|
68
|
+
render: H ? () => H(b[Q]) : void 0,
|
|
69
|
+
valueFormat: V,
|
|
70
70
|
titleKey: S,
|
|
71
|
-
resolveColor:
|
|
72
|
-
classes:
|
|
71
|
+
resolveColor: O ? (e) => $(e, Q) : void 0,
|
|
72
|
+
classes: q
|
|
73
73
|
}) : null;
|
|
74
|
-
return /* @__PURE__ */ h(
|
|
74
|
+
return /* @__PURE__ */ h(i, {
|
|
75
75
|
ref: Z,
|
|
76
76
|
aspectRatio: w,
|
|
77
77
|
height: T,
|
|
78
|
-
className:
|
|
79
|
-
style:
|
|
80
|
-
classes:
|
|
81
|
-
legend:
|
|
78
|
+
className: G,
|
|
79
|
+
style: K,
|
|
80
|
+
classes: q,
|
|
81
|
+
legend: I ? /* @__PURE__ */ h(a, {
|
|
82
82
|
config: C,
|
|
83
|
-
classes:
|
|
83
|
+
classes: q
|
|
84
84
|
}) : void 0,
|
|
85
85
|
overlay: te,
|
|
86
86
|
children: ({ width: e, height: t }) => {
|
|
87
|
-
let n =
|
|
88
|
-
for (let e of
|
|
87
|
+
let n = J.left, i = e - J.right, a = J.top, o = t - J.bottom, _ = Math.max(0, i - n), x = Math.max(0, o - a), w = b.map((e) => String(e[S])), T = l(w, [n, i], 0), O = [];
|
|
88
|
+
for (let e of Y) for (let t of b) {
|
|
89
89
|
let n = t[e];
|
|
90
|
-
typeof n == "number" &&
|
|
90
|
+
typeof n == "number" && O.push(n);
|
|
91
91
|
}
|
|
92
|
-
let [
|
|
92
|
+
let [I, L] = u(O), H = f(Math.min(0, I), L, R), U = d([H[0], H[H.length - 1]], [o, a]), W = H.map((e) => ({
|
|
93
93
|
value: e,
|
|
94
|
-
y:
|
|
95
|
-
})),
|
|
94
|
+
y: U(e)
|
|
95
|
+
})), G = y(w).map((e) => ({
|
|
96
96
|
label: e,
|
|
97
97
|
x: T(e)
|
|
98
98
|
}));
|
|
99
99
|
return /* @__PURE__ */ g(m, { children: [
|
|
100
|
-
/* @__PURE__ */ h(
|
|
101
|
-
ticks:
|
|
100
|
+
/* @__PURE__ */ h(c, {
|
|
101
|
+
ticks: W,
|
|
102
102
|
x: n,
|
|
103
103
|
plotWidth: _,
|
|
104
|
-
format: R,
|
|
105
|
-
showGrid: P,
|
|
106
|
-
classes: K
|
|
107
|
-
}),
|
|
108
|
-
/* @__PURE__ */ h(r, {
|
|
109
|
-
ticks: W,
|
|
110
|
-
y: f,
|
|
111
104
|
format: z,
|
|
112
|
-
|
|
105
|
+
showGrid: F,
|
|
106
|
+
classes: q
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ h(s, {
|
|
109
|
+
ticks: G,
|
|
110
|
+
y: o,
|
|
111
|
+
format: B,
|
|
112
|
+
classes: q
|
|
113
113
|
}),
|
|
114
|
-
|
|
114
|
+
Y.map((e) => {
|
|
115
115
|
let t = C[e], n = b.map((t, n) => {
|
|
116
116
|
let r = t[e], i = typeof r == "number" ? r : 0;
|
|
117
117
|
return {
|
|
118
118
|
x: T(w[n]),
|
|
119
|
-
y:
|
|
119
|
+
y: U(i),
|
|
120
120
|
value: i,
|
|
121
121
|
row: t
|
|
122
122
|
};
|
|
123
123
|
});
|
|
124
124
|
return /* @__PURE__ */ g("g", {
|
|
125
|
-
className: p
|
|
125
|
+
className: r(p.series, q?.series),
|
|
126
126
|
children: [
|
|
127
127
|
/* @__PURE__ */ h("path", {
|
|
128
|
-
className: p
|
|
128
|
+
className: r(p.linePath),
|
|
129
129
|
d: v(n, E),
|
|
130
130
|
stroke: t.color
|
|
131
131
|
}),
|
|
132
|
-
|
|
133
|
-
let
|
|
132
|
+
D && n.map((t, n) => {
|
|
133
|
+
let i = $(e, n), a = Q === n, o = N !== void 0 && !a, s = P ? () => P({
|
|
134
134
|
row: t.row,
|
|
135
135
|
value: t.value,
|
|
136
136
|
seriesKey: e,
|
|
137
137
|
index: n
|
|
138
138
|
}) : void 0;
|
|
139
|
-
return
|
|
140
|
-
onClick:
|
|
141
|
-
style:
|
|
142
|
-
opacity:
|
|
143
|
-
children:
|
|
139
|
+
return k ? /* @__PURE__ */ h("g", {
|
|
140
|
+
onClick: s,
|
|
141
|
+
style: s ? { cursor: "pointer" } : void 0,
|
|
142
|
+
opacity: o ? .45 : 1,
|
|
143
|
+
children: k({
|
|
144
144
|
row: t.row,
|
|
145
145
|
value: t.value,
|
|
146
146
|
seriesKey: e,
|
|
147
147
|
index: n,
|
|
148
148
|
x: t.x,
|
|
149
149
|
y: t.y,
|
|
150
|
-
color:
|
|
151
|
-
active:
|
|
150
|
+
color: i,
|
|
151
|
+
active: a
|
|
152
152
|
})
|
|
153
153
|
}, `${e}-${n}`) : /* @__PURE__ */ h("circle", {
|
|
154
|
-
className: p
|
|
154
|
+
className: r(p.point, q?.point),
|
|
155
155
|
cx: t.x,
|
|
156
156
|
cy: t.y,
|
|
157
|
-
r:
|
|
158
|
-
fill:
|
|
159
|
-
onClick:
|
|
160
|
-
style:
|
|
161
|
-
opacity:
|
|
157
|
+
r: a ? 5 : 3.5,
|
|
158
|
+
fill: i,
|
|
159
|
+
onClick: s,
|
|
160
|
+
style: s ? { cursor: "pointer" } : void 0,
|
|
161
|
+
opacity: o ? .45 : 1
|
|
162
162
|
}, `${e}-${n}`);
|
|
163
163
|
}),
|
|
164
|
-
(
|
|
165
|
-
let
|
|
164
|
+
(A || M) && n.map((t, n) => {
|
|
165
|
+
let i = M ? M({
|
|
166
166
|
row: t.row,
|
|
167
167
|
value: t.value,
|
|
168
168
|
seriesKey: e,
|
|
169
169
|
index: n
|
|
170
|
-
}) :
|
|
171
|
-
if (
|
|
172
|
-
let
|
|
170
|
+
}) : A ? V ? V(t.value) : String(t.value) : null;
|
|
171
|
+
if (i == null) return null;
|
|
172
|
+
let a = j === "top" ? t.y - 10 : t.y + 10 + 4;
|
|
173
173
|
return /* @__PURE__ */ h("text", {
|
|
174
|
-
className: p
|
|
174
|
+
className: r(p.axisLabel),
|
|
175
175
|
x: t.x,
|
|
176
|
-
y:
|
|
176
|
+
y: a,
|
|
177
177
|
textAnchor: "middle",
|
|
178
|
-
dominantBaseline:
|
|
179
|
-
children:
|
|
178
|
+
dominantBaseline: j === "top" ? "auto" : "middle",
|
|
179
|
+
children: i
|
|
180
180
|
}, `label-${e}-${n}`);
|
|
181
181
|
})
|
|
182
182
|
]
|
|
183
183
|
}, e);
|
|
184
184
|
}),
|
|
185
185
|
Q !== null && /* @__PURE__ */ h("line", {
|
|
186
|
-
className:
|
|
186
|
+
className: p.cursorLine,
|
|
187
187
|
x1: T(w[Q]),
|
|
188
188
|
x2: T(w[Q]),
|
|
189
|
-
y1:
|
|
190
|
-
y2:
|
|
189
|
+
y1: a,
|
|
190
|
+
y2: o
|
|
191
191
|
}),
|
|
192
192
|
/* @__PURE__ */ h("rect", {
|
|
193
|
-
className:
|
|
193
|
+
className: p.interactionLayer,
|
|
194
194
|
x: n,
|
|
195
|
-
y:
|
|
195
|
+
y: a,
|
|
196
196
|
width: _,
|
|
197
197
|
height: x,
|
|
198
198
|
onMouseMove: (e) => {
|
|
@@ -200,25 +200,25 @@ function b({ data: b, xKey: S, config: C, aspectRatio: w = 16 / 9, height: T, cu
|
|
|
200
200
|
X(a);
|
|
201
201
|
},
|
|
202
202
|
onMouseLeave: () => X(null),
|
|
203
|
-
onClick:
|
|
204
|
-
let t = e.currentTarget.getBoundingClientRect(), r = e.clientX - t.left + n, i = T.step(), a = Math.max(0, Math.min(b.length - 1, Math.round((r - n - i / 2) / i))), o =
|
|
205
|
-
|
|
203
|
+
onClick: P ? (e) => {
|
|
204
|
+
let t = e.currentTarget.getBoundingClientRect(), r = e.clientX - t.left + n, i = T.step(), a = Math.max(0, Math.min(b.length - 1, Math.round((r - n - i / 2) / i))), o = Y[0], s = b[a][o], c = typeof s == "number" ? s : 0;
|
|
205
|
+
P({
|
|
206
206
|
row: b[a],
|
|
207
207
|
value: c,
|
|
208
208
|
seriesKey: o,
|
|
209
209
|
index: a
|
|
210
210
|
});
|
|
211
211
|
} : void 0,
|
|
212
|
-
style:
|
|
212
|
+
style: P ? { cursor: "pointer" } : void 0
|
|
213
213
|
})
|
|
214
214
|
] });
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
function x(e, t, n, r, i) {
|
|
219
|
-
let
|
|
220
|
-
if (!
|
|
221
|
-
let
|
|
222
|
-
return
|
|
219
|
+
let a = i.current;
|
|
220
|
+
if (!a) return 0;
|
|
221
|
+
let o = a.getBoundingClientRect().width, s = e.map((e) => String(e[t]));
|
|
222
|
+
return l(s, [n.left, o - n.right], 0)(s[r]);
|
|
223
223
|
}
|
|
224
224
|
export { b as LineChart };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import o from "
|
|
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
6
|
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
7
|
// src/components/Chart/PieChart.tsx
|
|
8
8
|
var u = [
|
|
@@ -58,20 +58,20 @@ function p(e, t, n, r, i) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
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] =
|
|
61
|
+
let [V, H] = n(null), U = t(null), W = j ?? V, G = (e) => {
|
|
62
62
|
if (_) {
|
|
63
63
|
let t = m[e]?.[_];
|
|
64
64
|
if (typeof t == "string") return t;
|
|
65
65
|
}
|
|
66
66
|
return v[e % v.length];
|
|
67
|
-
}, K =
|
|
67
|
+
}, K = e(() => {
|
|
68
68
|
let e = 0;
|
|
69
69
|
for (let t of m) {
|
|
70
70
|
let n = t[h];
|
|
71
71
|
typeof n == "number" && n > 0 && (e += n);
|
|
72
72
|
}
|
|
73
73
|
return e;
|
|
74
|
-
}, [m, h]), q =
|
|
74
|
+
}, [m, h]), q = e(() => {
|
|
75
75
|
let e = [], t = 0;
|
|
76
76
|
for (let n = 0; n < m.length; n++) {
|
|
77
77
|
let r = m[n], i = r[h], a = typeof i == "number" && i > 0 ? i : 0;
|
|
@@ -92,21 +92,21 @@ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspec
|
|
|
92
92
|
h,
|
|
93
93
|
K
|
|
94
94
|
]), J = N ? /* @__PURE__ */ c("div", {
|
|
95
|
-
className: o
|
|
95
|
+
className: r(o.legend, B?.legend),
|
|
96
96
|
role: "list",
|
|
97
97
|
children: q.map((e) => /* @__PURE__ */ l("div", {
|
|
98
|
-
className: o
|
|
98
|
+
className: r(o.legendItem, B?.legendItem),
|
|
99
99
|
role: "listitem",
|
|
100
100
|
children: [/* @__PURE__ */ c("span", {
|
|
101
|
-
className:
|
|
101
|
+
className: o.legendSwatch,
|
|
102
102
|
style: { background: G(e.index) },
|
|
103
103
|
"aria-hidden": "true"
|
|
104
104
|
}), /* @__PURE__ */ c("span", {
|
|
105
|
-
className:
|
|
105
|
+
className: o.legendLabel,
|
|
106
106
|
children: String(e.row[g])
|
|
107
107
|
})]
|
|
108
108
|
}, e.index))
|
|
109
|
-
}) : void 0, Y =
|
|
109
|
+
}) : void 0, Y = e(() => {
|
|
110
110
|
let e = {};
|
|
111
111
|
for (let t of q) e[t.index.toString()] = {
|
|
112
112
|
label: String(t.row[g]),
|
|
@@ -116,17 +116,17 @@ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspec
|
|
|
116
116
|
}, [q]);
|
|
117
117
|
return m.length === 0 || K === 0 ? /* @__PURE__ */ c("div", {
|
|
118
118
|
ref: U,
|
|
119
|
-
className: o
|
|
119
|
+
className: r(o.root, B?.root, R),
|
|
120
120
|
style: z,
|
|
121
121
|
children: /* @__PURE__ */ c("div", {
|
|
122
|
-
className:
|
|
122
|
+
className: o.canvas,
|
|
123
123
|
style: { height: b ?? 240 },
|
|
124
124
|
children: /* @__PURE__ */ c("div", {
|
|
125
|
-
className:
|
|
125
|
+
className: o.empty,
|
|
126
126
|
children: L
|
|
127
127
|
})
|
|
128
128
|
})
|
|
129
|
-
}) : /* @__PURE__ */ c(
|
|
129
|
+
}) : /* @__PURE__ */ c(i, {
|
|
130
130
|
ref: U,
|
|
131
131
|
aspectRatio: y,
|
|
132
132
|
height: b,
|
|
@@ -134,7 +134,7 @@ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspec
|
|
|
134
134
|
style: z,
|
|
135
135
|
classes: B,
|
|
136
136
|
legend: J,
|
|
137
|
-
overlay: P && W !== null && m[W] ? /* @__PURE__ */ c(
|
|
137
|
+
overlay: P && W !== null && m[W] ? /* @__PURE__ */ c(a, {
|
|
138
138
|
row: { [W.toString()]: m[W][h] },
|
|
139
139
|
x: U.current ? U.current.getBoundingClientRect().width / 2 : 0,
|
|
140
140
|
y: 16,
|
|
@@ -146,10 +146,10 @@ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspec
|
|
|
146
146
|
classes: B
|
|
147
147
|
}) : null,
|
|
148
148
|
children: ({ width: e, height: t }) => {
|
|
149
|
-
let
|
|
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
150
|
return /* @__PURE__ */ l(s, { children: [
|
|
151
151
|
/* @__PURE__ */ c("g", { children: q.map((e) => {
|
|
152
|
-
let t = T / 2,
|
|
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
153
|
row: e.row,
|
|
154
154
|
value: e.value,
|
|
155
155
|
index: e.index
|
|
@@ -174,13 +174,13 @@ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspec
|
|
|
174
174
|
index: e.index
|
|
175
175
|
}) : E ? `${String(e.row[g])} ${F ? F(e.value) : Math.round(e.fraction * 100) + "%"}` : null;
|
|
176
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(
|
|
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
178
|
if (!a && O) {
|
|
179
|
-
let t = p(
|
|
179
|
+
let t = p(n, i, u, e.start, e.end), r = h === "end" ? 4 : h === "start" ? -4 : 0;
|
|
180
180
|
_ = {
|
|
181
181
|
x1: t.x,
|
|
182
182
|
y1: t.y,
|
|
183
|
-
x2: f.x +
|
|
183
|
+
x2: f.x + r,
|
|
184
184
|
y2: f.y
|
|
185
185
|
};
|
|
186
186
|
}
|
|
@@ -195,14 +195,14 @@ function m({ data: m, valueKey: h, nameKey: g, colorKey: _, colors: v = u, aspec
|
|
|
195
195
|
}), /* @__PURE__ */ c("text", {
|
|
196
196
|
x: f.x,
|
|
197
197
|
y: f.y,
|
|
198
|
-
className: o
|
|
198
|
+
className: r(o.axisLabel, a && o.barLabelInside),
|
|
199
199
|
textAnchor: h,
|
|
200
200
|
dominantBaseline: "middle",
|
|
201
201
|
children: t
|
|
202
202
|
})] }, `label-${e.index}`);
|
|
203
203
|
}),
|
|
204
204
|
A !== void 0 && /* @__PURE__ */ c("foreignObject", {
|
|
205
|
-
x:
|
|
205
|
+
x: n - m,
|
|
206
206
|
y: i - m,
|
|
207
207
|
width: Math.max(0, m * 2),
|
|
208
208
|
height: Math.max(0, m * 2),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import l from "
|
|
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
8
|
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
9
|
// src/components/Chart/RadarChart.tsx
|
|
10
10
|
function p(e, t, n, r) {
|
|
@@ -21,39 +21,39 @@ function m(e, t, n, r) {
|
|
|
21
21
|
}).join(" ");
|
|
22
22
|
}
|
|
23
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] =
|
|
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
25
|
let e = [];
|
|
26
26
|
for (let t of H) for (let n of h) {
|
|
27
27
|
let r = n[t];
|
|
28
28
|
typeof r == "number" && e.push(r);
|
|
29
29
|
}
|
|
30
|
-
let [, t] =
|
|
30
|
+
let [, t] = s(e);
|
|
31
31
|
return Math.max(1, t);
|
|
32
|
-
}, [h, H]), G =
|
|
32
|
+
}, [h, H]), G = e(() => c(0, W, T).filter((e) => e > 0), [W, T]), K = G[G.length - 1] ?? W;
|
|
33
33
|
return h.length === 0 ? /* @__PURE__ */ d("div", {
|
|
34
34
|
ref: V,
|
|
35
|
-
className: l
|
|
35
|
+
className: r(l.root, R?.root, I),
|
|
36
36
|
style: L,
|
|
37
37
|
children: /* @__PURE__ */ d("div", {
|
|
38
|
-
className:
|
|
38
|
+
className: l.canvas,
|
|
39
39
|
style: { height: y ?? 240 },
|
|
40
40
|
children: /* @__PURE__ */ d("div", {
|
|
41
|
-
className:
|
|
41
|
+
className: l.empty,
|
|
42
42
|
children: F
|
|
43
43
|
})
|
|
44
44
|
})
|
|
45
|
-
}) : /* @__PURE__ */ d(
|
|
45
|
+
}) : /* @__PURE__ */ d(i, {
|
|
46
46
|
ref: V,
|
|
47
47
|
aspectRatio: v,
|
|
48
48
|
height: y,
|
|
49
49
|
className: I,
|
|
50
50
|
style: L,
|
|
51
51
|
classes: R,
|
|
52
|
-
legend: N ? /* @__PURE__ */ d(
|
|
52
|
+
legend: N ? /* @__PURE__ */ d(a, {
|
|
53
53
|
config: _,
|
|
54
54
|
classes: R
|
|
55
55
|
}) : void 0,
|
|
56
|
-
overlay: P && z !== null ? /* @__PURE__ */ d(
|
|
56
|
+
overlay: P && z !== null ? /* @__PURE__ */ d(o, {
|
|
57
57
|
row: h[z],
|
|
58
58
|
x: (V.current?.getBoundingClientRect().width ?? 0) / 2,
|
|
59
59
|
y: 16,
|
|
@@ -65,28 +65,28 @@ function h({ data: h, axisKey: g, config: _, aspectRatio: v = 1, height: y, grid
|
|
|
65
65
|
classes: R
|
|
66
66
|
}) : null,
|
|
67
67
|
children: ({ width: e, height: t }) => {
|
|
68
|
-
let n = C ? 32 : 8,
|
|
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
69
|
return /* @__PURE__ */ f(u, { children: [
|
|
70
70
|
x && G.map((e) => {
|
|
71
71
|
let t = s(e);
|
|
72
72
|
return b === "circle" ? /* @__PURE__ */ d("circle", {
|
|
73
|
-
className: l
|
|
74
|
-
cx:
|
|
75
|
-
cy:
|
|
73
|
+
className: r(l.gridLine, R?.grid),
|
|
74
|
+
cx: i,
|
|
75
|
+
cy: a,
|
|
76
76
|
r: t,
|
|
77
77
|
fill: "none"
|
|
78
78
|
}, `ring-${e}`) : /* @__PURE__ */ d("polygon", {
|
|
79
|
-
className: l
|
|
80
|
-
points: m(
|
|
79
|
+
className: r(l.gridLine, R?.grid),
|
|
80
|
+
points: m(i, a, t, U),
|
|
81
81
|
fill: "none"
|
|
82
82
|
}, `ring-${e}`);
|
|
83
83
|
}),
|
|
84
84
|
S && U.map((e, t) => {
|
|
85
|
-
let n = p(
|
|
85
|
+
let n = p(i, a, o, e);
|
|
86
86
|
return /* @__PURE__ */ d("line", {
|
|
87
|
-
className: l
|
|
88
|
-
x1:
|
|
89
|
-
y1:
|
|
87
|
+
className: r(l.gridLine, R?.grid),
|
|
88
|
+
x1: i,
|
|
89
|
+
y1: a,
|
|
90
90
|
x2: n.x,
|
|
91
91
|
y2: n.y
|
|
92
92
|
}, `spoke-${t}`);
|
|
@@ -94,16 +94,16 @@ function h({ data: h, axisKey: g, config: _, aspectRatio: v = 1, height: y, grid
|
|
|
94
94
|
w && G.map((e) => {
|
|
95
95
|
let t = s(e);
|
|
96
96
|
return /* @__PURE__ */ d("text", {
|
|
97
|
-
className: l
|
|
98
|
-
x:
|
|
99
|
-
y:
|
|
97
|
+
className: r(l.axisLabel, R?.axisLabel),
|
|
98
|
+
x: i + 4,
|
|
99
|
+
y: a - t,
|
|
100
100
|
textAnchor: "start",
|
|
101
101
|
dominantBaseline: "middle",
|
|
102
102
|
children: j ? j(e) : e
|
|
103
103
|
}, `raxis-${e}`);
|
|
104
104
|
}),
|
|
105
105
|
C && h.map((e, t) => {
|
|
106
|
-
let n = U[t], s = p(
|
|
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
107
|
if (k) return /* @__PURE__ */ d("g", { children: k({
|
|
108
108
|
row: e,
|
|
109
109
|
index: t,
|
|
@@ -114,7 +114,7 @@ function h({ data: h, axisKey: g, config: _, aspectRatio: v = 1, height: y, grid
|
|
|
114
114
|
}) }, `label-${t}`);
|
|
115
115
|
let u = String(e[g]), f = A ? A(u) : u;
|
|
116
116
|
return /* @__PURE__ */ d("text", {
|
|
117
|
-
className: l
|
|
117
|
+
className: r(l.axisLabel, R?.axisLabel),
|
|
118
118
|
x: s.x,
|
|
119
119
|
y: s.y,
|
|
120
120
|
textAnchor: c,
|
|
@@ -124,11 +124,11 @@ function h({ data: h, axisKey: g, config: _, aspectRatio: v = 1, height: y, grid
|
|
|
124
124
|
}),
|
|
125
125
|
H.map((e) => {
|
|
126
126
|
let t = _[e], n = h.map((t, n) => {
|
|
127
|
-
let
|
|
128
|
-
return p(
|
|
127
|
+
let r = t[e], o = s(typeof r == "number" ? r : 0);
|
|
128
|
+
return p(i, a, o, U[n]);
|
|
129
129
|
}), o = n.map((e) => `${e.x},${e.y}`).join(" ");
|
|
130
130
|
return /* @__PURE__ */ f("g", {
|
|
131
|
-
className: l
|
|
131
|
+
className: r(l.series, R?.series),
|
|
132
132
|
children: [/* @__PURE__ */ d("polygon", {
|
|
133
133
|
points: o,
|
|
134
134
|
fill: t.color,
|
|
@@ -137,25 +137,25 @@ function h({ data: h, axisKey: g, config: _, aspectRatio: v = 1, height: y, grid
|
|
|
137
137
|
strokeWidth: O,
|
|
138
138
|
strokeLinejoin: "round",
|
|
139
139
|
strokeLinecap: "round"
|
|
140
|
-
}), E && n.map((n,
|
|
141
|
-
className: l
|
|
140
|
+
}), E && n.map((n, i) => /* @__PURE__ */ d("circle", {
|
|
141
|
+
className: r(l.point, R?.point),
|
|
142
142
|
cx: n.x,
|
|
143
143
|
cy: n.y,
|
|
144
|
-
r: z ===
|
|
144
|
+
r: z === i ? 5 : 3.5,
|
|
145
145
|
fill: t.color
|
|
146
|
-
}, `${e}-${
|
|
146
|
+
}, `${e}-${i}`))]
|
|
147
147
|
}, e);
|
|
148
148
|
}),
|
|
149
149
|
/* @__PURE__ */ d("rect", {
|
|
150
|
-
className:
|
|
150
|
+
className: l.interactionLayer,
|
|
151
151
|
x: 0,
|
|
152
152
|
y: 0,
|
|
153
153
|
width: e,
|
|
154
154
|
height: t,
|
|
155
155
|
onMouseMove: (e) => {
|
|
156
|
-
let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left -
|
|
157
|
-
if (n === 0 &&
|
|
158
|
-
let o = Math.atan2(
|
|
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
159
|
o < 0 && (o += 360), o >= 360 && (o -= 360);
|
|
160
160
|
let s = 360 / h.length, c = Math.round(o / s) % h.length;
|
|
161
161
|
B(c);
|