@overdoser/react-toolkit 0.7.0 → 0.8.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/CHANGELOG.md +32 -0
- package/components/ActionButton/ActionButton.js +211 -0
- package/components/ActionButton/ActionButton.module.scss.js +47 -0
- package/components/ActionButton/CopyButton.js +66 -0
- package/components/Alert/Alert.js +82 -0
- package/components/Alert/Alert.module.scss.js +25 -0
- package/components/Avatar/Avatar.js +57 -0
- package/components/Avatar/Avatar.module.scss.js +43 -0
- package/components/Badge/Badge.js +38 -0
- package/components/Badge/Badge.module.scss.js +31 -0
- package/components/Breadcrumbs/Breadcrumbs.js +49 -0
- package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
- package/components/Button/Button.js +57 -0
- package/components/Button/Button.module.scss.js +47 -0
- package/components/Chart/AreaChart.js +244 -0
- package/components/Chart/Axis.js +45 -0
- package/components/Chart/BarChart.js +353 -0
- package/components/Chart/Chart.module.scss.js +61 -0
- package/components/Chart/ChartContainer.js +41 -0
- package/components/Chart/ChartLegend.js +31 -0
- package/components/Chart/ChartTooltip.js +42 -0
- package/components/Chart/LineChart.js +236 -0
- package/components/Chart/PieChart.js +248 -0
- package/components/Chart/RadarChart.js +221 -0
- package/components/Chart/Sparkline.js +69 -0
- package/components/Chart/TradingChart.js +732 -0
- package/components/Chart/scales.js +39 -0
- package/components/Chart/trading/indicators.js +68 -0
- package/components/Chart/trading/period.js +71 -0
- package/components/Chart/useChartDimensions.js +23 -0
- package/components/Divider/Divider.js +36 -0
- package/components/Divider/Divider.module.scss.js +31 -0
- package/components/Draggable/Draggable.js +155 -0
- package/components/Draggable/Draggable.module.scss.js +17 -0
- package/components/Drawer/Drawer.js +126 -0
- package/components/Drawer/Drawer.module.scss.js +117 -0
- package/components/Dropdown/Dropdown.js +142 -0
- package/components/Dropdown/Dropdown.module.scss.js +35 -0
- package/components/Dropdown/DropdownItem.js +31 -0
- package/components/Dropzone/Dropzone.js +107 -0
- package/components/Dropzone/Dropzone.module.scss.js +21 -0
- package/components/Form/Form.js +36 -0
- package/components/Form/Form.module.scss.js +29 -0
- package/components/Form/FormField.js +76 -0
- package/components/Form/FormRow.js +9 -0
- package/components/Form/formFieldDefaults.js +5 -0
- package/components/Link/Link.js +59 -0
- package/components/Link/Link.module.scss.js +16 -0
- package/components/List/List.js +46 -0
- package/components/List/List.module.scss.js +21 -0
- package/components/Modal/Modal.js +109 -0
- package/components/Modal/Modal.module.scss.js +31 -0
- package/components/Pagination/Pagination.js +84 -0
- package/components/Pagination/Pagination.module.scss.js +23 -0
- package/components/Pagination/paginationRange.js +24 -0
- package/components/Popover/Popover.js +138 -0
- package/components/Popover/Popover.module.scss.js +21 -0
- package/components/Skeleton/Skeleton.js +50 -0
- package/components/Skeleton/Skeleton.module.scss.js +25 -0
- package/components/Spinner/Spinner.js +25 -0
- package/components/Spinner/Spinner.module.scss.js +20 -0
- package/components/Table/Table.js +284 -0
- package/components/Table/Table.module.scss.js +59 -0
- package/components/Table/useTableSort.js +44 -0
- package/components/Tabs/Tabs.js +163 -0
- package/components/Tabs/Tabs.module.scss.js +53 -0
- package/components/Timer/Timer.js +159 -0
- package/components/Timer/Timer.module.scss.js +55 -0
- package/components/Toast/Toast.js +133 -0
- package/components/Toast/Toast.module.scss.js +62 -0
- package/components/Toast/toastStore.js +62 -0
- package/components/ToggleIconButton/ToggleIconButton.js +58 -0
- package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
- package/components/Tooltip/Tooltip.js +86 -0
- package/components/Tooltip/Tooltip.module.scss.js +30 -0
- package/components/Typography/Typography.js +37 -0
- package/components/Typography/Typography.module.scss.js +53 -0
- package/components/inputs/Checkbox/Checkbox.js +50 -0
- package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
- package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
- package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
- package/components/inputs/DatePicker/DatePicker.js +229 -0
- package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
- package/components/inputs/DatePicker/dateUtils.js +41 -0
- package/components/inputs/Input/Input.js +50 -0
- package/components/inputs/Input/Input.module.scss.js +25 -0
- package/components/inputs/NumberInput/NumberInput.js +134 -0
- package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
- package/components/inputs/Radio/Radio.js +68 -0
- package/components/inputs/Radio/Radio.module.scss.js +13 -0
- package/components/inputs/Select/Select.js +520 -0
- package/components/inputs/Select/Select.module.scss.js +69 -0
- package/components/inputs/Slider/Slider.js +128 -0
- package/components/inputs/Slider/Slider.module.scss.js +15 -0
- package/components/inputs/Textarea/Textarea.js +58 -0
- package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
- package/hooks/useClickOutside.js +15 -0
- package/hooks/useFocusTrap.js +39 -0
- package/hooks/useKeyboard.js +19 -0
- package/hooks/usePortalPosition.js +20 -0
- package/index.css +1 -1
- package/index.js +119 -7000
- package/index.layered.css +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { jsx as r, jsxs as Tt, Fragment as Gt } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as $t, useState as It, useRef as Ft } from "react";
|
|
3
|
+
import x from "clsx";
|
|
4
|
+
import { ChartContainer as qt } from "./ChartContainer.js";
|
|
5
|
+
import { ChartLegend as Ht } from "./ChartLegend.js";
|
|
6
|
+
import { ChartTooltip as Jt } from "./ChartTooltip.js";
|
|
7
|
+
import { extent as Kt, niceTicks as Qt, bandScale as dt, linearScale as Zt } from "./scales.js";
|
|
8
|
+
import i from "./Chart.module.scss.js";
|
|
9
|
+
const Wt = [
|
|
10
|
+
"var(--crk-chart-1)",
|
|
11
|
+
"var(--crk-chart-2)",
|
|
12
|
+
"var(--crk-chart-3)",
|
|
13
|
+
"var(--crk-chart-4)",
|
|
14
|
+
"var(--crk-chart-5)"
|
|
15
|
+
], Pt = { top: 12, right: 16, bottom: 28, left: 48 }, te = { top: 12, right: 16, bottom: 28, left: 72 };
|
|
16
|
+
function ee(t, c = 8) {
|
|
17
|
+
if (t.length <= c) return t;
|
|
18
|
+
const e = Math.ceil(t.length / c);
|
|
19
|
+
return t.filter((s, a) => a % e === 0);
|
|
20
|
+
}
|
|
21
|
+
function ue({
|
|
22
|
+
data: t,
|
|
23
|
+
xKey: c,
|
|
24
|
+
config: e,
|
|
25
|
+
orientation: s = "vertical",
|
|
26
|
+
stacked: a = !1,
|
|
27
|
+
aspectRatio: u = 16 / 9,
|
|
28
|
+
height: p,
|
|
29
|
+
groupPadding: v = 0.2,
|
|
30
|
+
barPadding: f = 0.1,
|
|
31
|
+
barRadius: y = 4,
|
|
32
|
+
showGrid: j = !0,
|
|
33
|
+
showLegend: tt = !0,
|
|
34
|
+
showTooltip: wt = !0,
|
|
35
|
+
showValues: kt = !1,
|
|
36
|
+
valuePosition: et = "outside",
|
|
37
|
+
renderLabel: mt,
|
|
38
|
+
colorBy: _t = "series",
|
|
39
|
+
colors: nt = Wt,
|
|
40
|
+
negativeColor: O,
|
|
41
|
+
activeIndex: U,
|
|
42
|
+
onBarClick: ot,
|
|
43
|
+
yTickCount: zt = 5,
|
|
44
|
+
yFormat: ht,
|
|
45
|
+
xFormat: xt,
|
|
46
|
+
valueFormat: rt,
|
|
47
|
+
renderTooltip: ut,
|
|
48
|
+
margin: Et,
|
|
49
|
+
emptyMessage: Xt = "No data",
|
|
50
|
+
className: pt,
|
|
51
|
+
style: ft,
|
|
52
|
+
classes: l
|
|
53
|
+
}) {
|
|
54
|
+
const d = s === "horizontal", T = { ...d ? te : Pt, ...Et }, $ = $t(() => Object.keys(e), [e]), _ = a && $.length > 1, [gt, yt] = It(null), z = Ft(null);
|
|
55
|
+
if (t.length === 0)
|
|
56
|
+
return /* @__PURE__ */ r("div", { ref: z, className: x(i.root, l?.root, pt), style: ft, children: /* @__PURE__ */ r("div", { className: i.canvas, style: { height: p ?? 240 }, children: /* @__PURE__ */ r("div", { className: i.empty, children: Xt }) }) });
|
|
57
|
+
const it = t.map((b) => String(b[c])), N = U ?? gt, bt = $t(() => {
|
|
58
|
+
if (_) {
|
|
59
|
+
let L = 0, h = 0;
|
|
60
|
+
for (const g of t) {
|
|
61
|
+
let E = 0, X = 0;
|
|
62
|
+
for (const At of $) {
|
|
63
|
+
const A = g[At];
|
|
64
|
+
typeof A == "number" && (A >= 0 ? E += A : X += A);
|
|
65
|
+
}
|
|
66
|
+
E > L && (L = E), X < h && (h = X);
|
|
67
|
+
}
|
|
68
|
+
return [h, L];
|
|
69
|
+
}
|
|
70
|
+
const b = [];
|
|
71
|
+
for (const L of t)
|
|
72
|
+
for (const h of $) {
|
|
73
|
+
const g = L[h];
|
|
74
|
+
typeof g == "number" && b.push(g);
|
|
75
|
+
}
|
|
76
|
+
const [B, m] = Kt(b);
|
|
77
|
+
return [Math.min(0, B), Math.max(0, m)];
|
|
78
|
+
}, [t, $, _]), V = Qt(bt[0], bt[1], zt), Lt = V[0], Mt = V[V.length - 1], vt = (b, B) => _t === "index" ? nt[B % nt.length] : e[b]?.color ?? nt[0], Yt = wt && N !== null && t[N] ? /* @__PURE__ */ r(
|
|
79
|
+
Jt,
|
|
80
|
+
{
|
|
81
|
+
row: t[N],
|
|
82
|
+
x: oe(t, c, T, N, z, d, v),
|
|
83
|
+
y: d ? re(t, c, T, N, z, v) : 16,
|
|
84
|
+
containerWidth: z.current?.getBoundingClientRect().width ?? 0,
|
|
85
|
+
config: e,
|
|
86
|
+
render: ut ? () => ut(t[N]) : void 0,
|
|
87
|
+
valueFormat: rt,
|
|
88
|
+
titleKey: c,
|
|
89
|
+
resolveColor: (b) => {
|
|
90
|
+
const B = t[N][b], m = vt(b, N);
|
|
91
|
+
return typeof B != "number" ? m : O !== void 0 && B < 0 ? O : m;
|
|
92
|
+
},
|
|
93
|
+
classes: l
|
|
94
|
+
}
|
|
95
|
+
) : null;
|
|
96
|
+
return /* @__PURE__ */ r(
|
|
97
|
+
qt,
|
|
98
|
+
{
|
|
99
|
+
ref: z,
|
|
100
|
+
aspectRatio: u,
|
|
101
|
+
height: p,
|
|
102
|
+
className: pt,
|
|
103
|
+
style: ft,
|
|
104
|
+
classes: l,
|
|
105
|
+
legend: tt ? /* @__PURE__ */ r(Ht, { config: e, classes: l }) : void 0,
|
|
106
|
+
overlay: Yt,
|
|
107
|
+
children: ({ width: b, height: B }) => {
|
|
108
|
+
const m = T.left, L = b - T.right, h = T.top, g = B - T.bottom, E = Math.max(0, L - m), X = Math.max(0, g - h), A = dt(it, d ? [h, g] : [m, L], v), st = A.bandWidth(), G = Zt([Lt, Mt], d ? [m, L] : [g, h]), I = G(0), Dt = _ ? 1 : Math.max(1, $.length), ct = st / Dt, F = ct * (1 - f), Nt = V.map((n) => ({
|
|
109
|
+
value: n,
|
|
110
|
+
pos: G(n)
|
|
111
|
+
})), jt = ee(it);
|
|
112
|
+
return /* @__PURE__ */ Tt(Gt, { children: [
|
|
113
|
+
j && /* @__PURE__ */ r("g", { className: x(i.axis, l?.axis), children: Nt.map(
|
|
114
|
+
({ value: n, pos: o }) => d ? /* @__PURE__ */ r(
|
|
115
|
+
"line",
|
|
116
|
+
{
|
|
117
|
+
className: x(i.gridLine, l?.grid),
|
|
118
|
+
x1: o,
|
|
119
|
+
x2: o,
|
|
120
|
+
y1: h,
|
|
121
|
+
y2: g
|
|
122
|
+
},
|
|
123
|
+
`g-${n}`
|
|
124
|
+
) : /* @__PURE__ */ r(
|
|
125
|
+
"line",
|
|
126
|
+
{
|
|
127
|
+
className: x(i.gridLine, l?.grid),
|
|
128
|
+
x1: m,
|
|
129
|
+
x2: L,
|
|
130
|
+
y1: o,
|
|
131
|
+
y2: o
|
|
132
|
+
},
|
|
133
|
+
`g-${n}`
|
|
134
|
+
)
|
|
135
|
+
) }),
|
|
136
|
+
/* @__PURE__ */ r("g", { className: x(i.axis, l?.axis), children: Nt.map(({ value: n, pos: o }) => {
|
|
137
|
+
const C = ht ? ht(n) : String(n);
|
|
138
|
+
return d ? /* @__PURE__ */ r(
|
|
139
|
+
"text",
|
|
140
|
+
{
|
|
141
|
+
className: x(i.axisLabel, l?.axisLabel),
|
|
142
|
+
x: o,
|
|
143
|
+
y: g + 16,
|
|
144
|
+
textAnchor: "middle",
|
|
145
|
+
children: C
|
|
146
|
+
},
|
|
147
|
+
`vt-${n}`
|
|
148
|
+
) : /* @__PURE__ */ r(
|
|
149
|
+
"text",
|
|
150
|
+
{
|
|
151
|
+
className: x(i.axisLabel, l?.axisLabel),
|
|
152
|
+
x: m - 8,
|
|
153
|
+
y: o,
|
|
154
|
+
textAnchor: "end",
|
|
155
|
+
dominantBaseline: "middle",
|
|
156
|
+
children: C
|
|
157
|
+
},
|
|
158
|
+
`vt-${n}`
|
|
159
|
+
);
|
|
160
|
+
}) }),
|
|
161
|
+
/* @__PURE__ */ r("g", { className: x(i.axis, l?.axis), children: jt.map((n) => {
|
|
162
|
+
const o = A(n), C = xt ? xt(n) : n;
|
|
163
|
+
return d ? /* @__PURE__ */ r(
|
|
164
|
+
"text",
|
|
165
|
+
{
|
|
166
|
+
className: x(i.axisLabel, l?.axisLabel),
|
|
167
|
+
x: m - 8,
|
|
168
|
+
y: o,
|
|
169
|
+
textAnchor: "end",
|
|
170
|
+
dominantBaseline: "middle",
|
|
171
|
+
children: C
|
|
172
|
+
},
|
|
173
|
+
`c-${n}`
|
|
174
|
+
) : /* @__PURE__ */ r(
|
|
175
|
+
"text",
|
|
176
|
+
{
|
|
177
|
+
className: x(i.axisLabel, l?.axisLabel),
|
|
178
|
+
x: o,
|
|
179
|
+
y: g + 16,
|
|
180
|
+
textAnchor: "middle",
|
|
181
|
+
children: C
|
|
182
|
+
},
|
|
183
|
+
`c-${n}`
|
|
184
|
+
);
|
|
185
|
+
}) }),
|
|
186
|
+
t.map((n, o) => {
|
|
187
|
+
const q = A(it[o]) - st / 2;
|
|
188
|
+
let w = 0, Y = 0;
|
|
189
|
+
return /* @__PURE__ */ r("g", { className: x(i.series, l?.series), children: $.map((R, Ot) => {
|
|
190
|
+
const Bt = n[R];
|
|
191
|
+
if (typeof Bt != "number") return null;
|
|
192
|
+
const M = Bt, Ut = vt(R, o), Vt = O !== void 0 && M < 0 ? O : Ut, Ct = U !== void 0 ? U === o : gt === o, St = U !== void 0 && !Ct;
|
|
193
|
+
let H, k;
|
|
194
|
+
_ ? M >= 0 ? (H = w, k = w + M, w = k) : (H = Y, k = Y + M, Y = k) : (H = 0, k = M);
|
|
195
|
+
const J = G(H), K = G(k), Rt = _ ? (st - F) / 2 : Ot * ct + (ct - F) / 2;
|
|
196
|
+
let Q = 0, Z = 0, W = 0, P = 0;
|
|
197
|
+
if (d) {
|
|
198
|
+
const D = Math.min(J, K), lt = Math.max(J, K);
|
|
199
|
+
Q = D, W = lt - D, Z = q + Rt, P = F;
|
|
200
|
+
} else {
|
|
201
|
+
const D = Math.min(J, K), lt = Math.max(J, K);
|
|
202
|
+
Q = q + Rt, W = F, Z = D, P = lt - D;
|
|
203
|
+
}
|
|
204
|
+
const at = mt ? mt({ row: n, value: M, seriesKey: R, index: o }) : kt ? rt ? rt(M) : String(M) : null, S = ne({
|
|
205
|
+
isHorizontal: d,
|
|
206
|
+
valuePosition: et,
|
|
207
|
+
x: Q,
|
|
208
|
+
y: Z,
|
|
209
|
+
rectW: W,
|
|
210
|
+
rectH: P,
|
|
211
|
+
value: M
|
|
212
|
+
});
|
|
213
|
+
return /* @__PURE__ */ Tt("g", { children: [
|
|
214
|
+
/* @__PURE__ */ r(
|
|
215
|
+
"rect",
|
|
216
|
+
{
|
|
217
|
+
className: x(
|
|
218
|
+
i.bar,
|
|
219
|
+
Ct && i.activeBar,
|
|
220
|
+
l?.point
|
|
221
|
+
),
|
|
222
|
+
x: Q,
|
|
223
|
+
y: Z,
|
|
224
|
+
width: Math.max(0, W),
|
|
225
|
+
height: Math.max(0, P),
|
|
226
|
+
rx: y,
|
|
227
|
+
ry: y,
|
|
228
|
+
fill: Vt,
|
|
229
|
+
opacity: St ? 0.35 : 1,
|
|
230
|
+
onClick: ot ? () => ot({ row: n, value: M, seriesKey: R, index: o }) : void 0,
|
|
231
|
+
style: ot ? { cursor: "pointer" } : void 0
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
at != null && /* @__PURE__ */ r(
|
|
235
|
+
"text",
|
|
236
|
+
{
|
|
237
|
+
className: x(
|
|
238
|
+
i.axisLabel,
|
|
239
|
+
(et === "inside" || et === "inside-start") && i.barLabelInside
|
|
240
|
+
),
|
|
241
|
+
x: S.x,
|
|
242
|
+
y: S.y,
|
|
243
|
+
textAnchor: S.textAnchor,
|
|
244
|
+
dominantBaseline: S.dominantBaseline,
|
|
245
|
+
transform: S.rotate ? `rotate(${S.rotate} ${S.x} ${S.y})` : void 0,
|
|
246
|
+
opacity: St ? 0.5 : 1,
|
|
247
|
+
children: at
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
] }, R);
|
|
251
|
+
}) }, `group-${o}`);
|
|
252
|
+
}),
|
|
253
|
+
Lt < 0 && Mt > 0 && /* @__PURE__ */ r(
|
|
254
|
+
"line",
|
|
255
|
+
{
|
|
256
|
+
className: x(i.gridLine),
|
|
257
|
+
x1: d ? I : m,
|
|
258
|
+
x2: d ? I : L,
|
|
259
|
+
y1: d ? h : I,
|
|
260
|
+
y2: d ? g : I,
|
|
261
|
+
opacity: 0.9
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ r(
|
|
265
|
+
"rect",
|
|
266
|
+
{
|
|
267
|
+
className: i.interactionLayer,
|
|
268
|
+
x: m,
|
|
269
|
+
y: h,
|
|
270
|
+
width: E,
|
|
271
|
+
height: X,
|
|
272
|
+
onMouseMove: (n) => {
|
|
273
|
+
const o = n.currentTarget.getBoundingClientRect(), C = n.clientX - o.left + m, q = n.clientY - o.top + h, w = A.step(), Y = d ? q - h : C - m, R = Math.max(
|
|
274
|
+
0,
|
|
275
|
+
Math.min(t.length - 1, Math.round((Y - w / 2) / w))
|
|
276
|
+
);
|
|
277
|
+
yt(R);
|
|
278
|
+
},
|
|
279
|
+
onMouseLeave: () => yt(null)
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
] });
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function ne({
|
|
288
|
+
isHorizontal: t,
|
|
289
|
+
valuePosition: c,
|
|
290
|
+
x: e,
|
|
291
|
+
y: s,
|
|
292
|
+
rectW: a,
|
|
293
|
+
rectH: u,
|
|
294
|
+
value: p
|
|
295
|
+
}) {
|
|
296
|
+
if (t) {
|
|
297
|
+
if (c === "inside-start")
|
|
298
|
+
return p >= 0 ? { x: e + 6, y: s + u / 2, textAnchor: "start", dominantBaseline: "middle" } : { x: e + a - 6, y: s + u / 2, textAnchor: "end", dominantBaseline: "middle" };
|
|
299
|
+
const y = c === "inside";
|
|
300
|
+
return p >= 0 ? {
|
|
301
|
+
x: y ? e + a - 6 : e + a + 6,
|
|
302
|
+
y: s + u / 2,
|
|
303
|
+
textAnchor: y ? "end" : "start",
|
|
304
|
+
dominantBaseline: "middle"
|
|
305
|
+
} : {
|
|
306
|
+
x: y ? e + 6 : e - 6,
|
|
307
|
+
y: s + u / 2,
|
|
308
|
+
textAnchor: y ? "start" : "end",
|
|
309
|
+
dominantBaseline: "middle"
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
if (c === "inside-start")
|
|
313
|
+
return p >= 0 ? {
|
|
314
|
+
x: e + a / 2,
|
|
315
|
+
y: s + u - 6,
|
|
316
|
+
textAnchor: "start",
|
|
317
|
+
dominantBaseline: "middle",
|
|
318
|
+
rotate: -90
|
|
319
|
+
} : {
|
|
320
|
+
x: e + a / 2,
|
|
321
|
+
y: s + 6,
|
|
322
|
+
textAnchor: "start",
|
|
323
|
+
dominantBaseline: "middle",
|
|
324
|
+
rotate: 90
|
|
325
|
+
};
|
|
326
|
+
const f = c === "inside";
|
|
327
|
+
return p >= 0 ? {
|
|
328
|
+
x: e + a / 2,
|
|
329
|
+
y: f ? s + 12 : s - 6,
|
|
330
|
+
textAnchor: "middle",
|
|
331
|
+
dominantBaseline: f ? "middle" : "auto"
|
|
332
|
+
} : {
|
|
333
|
+
x: e + a / 2,
|
|
334
|
+
y: f ? s + u - 6 : s + u + 12,
|
|
335
|
+
textAnchor: "middle",
|
|
336
|
+
dominantBaseline: f ? "auto" : "middle"
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function oe(t, c, e, s, a, u, p) {
|
|
340
|
+
const v = a.current;
|
|
341
|
+
if (!v) return 0;
|
|
342
|
+
const f = v.getBoundingClientRect(), y = t.map((tt) => String(tt[c]));
|
|
343
|
+
return u ? f.width / 2 : dt(y, [e.left, f.width - e.right], p)(y[s]);
|
|
344
|
+
}
|
|
345
|
+
function re(t, c, e, s, a, u) {
|
|
346
|
+
const p = a.current;
|
|
347
|
+
if (!p) return 16;
|
|
348
|
+
const v = p.getBoundingClientRect(), f = t.map((j) => String(j[c]));
|
|
349
|
+
return dt(f, [e.top, v.height - e.bottom], u)(f[s]);
|
|
350
|
+
}
|
|
351
|
+
export {
|
|
352
|
+
ue as BarChart
|
|
353
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const t = "crk-root-uMSq0", e = "crk-canvas-zhFr0", o = "crk-svg-waPLB", c = "crk-gridLine-K2Gx9", n = "crk-axis-Zum8-", a = "crk-axisLabel-Ilv3u", r = "crk-cursorLine-iNHim", i = "crk-linePath-E4eYA", l = "crk-areaPath-ZwMc6", s = "crk-point-DTAoa", k = "crk-bar-9sYbq", d = "crk-barLabelInside-dlQh5", p = "crk-activeBar-FJhPJ", g = "crk-interactionLayer-dHNAG", L = "crk-legend-JL6YI", b = "crk-legendItem-rcdvO", w = "crk-legendSwatch-eJBsF", h = "crk-legendIcon-6gzcO", v = "crk-legendLabel-C-eu3", u = "crk-tooltip-m55-N", I = "crk-tooltipTitle-0EfoX", m = "crk-tooltipRows-MC0wM", P = "crk-tooltipRow-ZQomr", x = "crk-tooltipLabel-s4OKX", y = "crk-tooltipValue-iwj1s", R = "crk-empty-aa4vk", B = "crk-sparkline-3-eRc", H = "crk-tradingHeader-Pb9wS", S = {
|
|
2
|
+
root: t,
|
|
3
|
+
canvas: e,
|
|
4
|
+
svg: o,
|
|
5
|
+
gridLine: c,
|
|
6
|
+
axis: n,
|
|
7
|
+
axisLabel: a,
|
|
8
|
+
cursorLine: r,
|
|
9
|
+
linePath: i,
|
|
10
|
+
areaPath: l,
|
|
11
|
+
point: s,
|
|
12
|
+
bar: k,
|
|
13
|
+
barLabelInside: d,
|
|
14
|
+
activeBar: p,
|
|
15
|
+
interactionLayer: g,
|
|
16
|
+
legend: L,
|
|
17
|
+
legendItem: b,
|
|
18
|
+
legendSwatch: w,
|
|
19
|
+
legendIcon: h,
|
|
20
|
+
legendLabel: v,
|
|
21
|
+
tooltip: u,
|
|
22
|
+
tooltipTitle: I,
|
|
23
|
+
tooltipRows: m,
|
|
24
|
+
tooltipRow: P,
|
|
25
|
+
tooltipLabel: x,
|
|
26
|
+
tooltipValue: y,
|
|
27
|
+
empty: R,
|
|
28
|
+
sparkline: B,
|
|
29
|
+
tradingHeader: H
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
p as activeBar,
|
|
33
|
+
l as areaPath,
|
|
34
|
+
n as axis,
|
|
35
|
+
a as axisLabel,
|
|
36
|
+
k as bar,
|
|
37
|
+
d as barLabelInside,
|
|
38
|
+
e as canvas,
|
|
39
|
+
r as cursorLine,
|
|
40
|
+
S as default,
|
|
41
|
+
R as empty,
|
|
42
|
+
c as gridLine,
|
|
43
|
+
g as interactionLayer,
|
|
44
|
+
L as legend,
|
|
45
|
+
h as legendIcon,
|
|
46
|
+
b as legendItem,
|
|
47
|
+
v as legendLabel,
|
|
48
|
+
w as legendSwatch,
|
|
49
|
+
i as linePath,
|
|
50
|
+
s as point,
|
|
51
|
+
t as root,
|
|
52
|
+
B as sparkline,
|
|
53
|
+
o as svg,
|
|
54
|
+
u as tooltip,
|
|
55
|
+
x as tooltipLabel,
|
|
56
|
+
P as tooltipRow,
|
|
57
|
+
m as tooltipRows,
|
|
58
|
+
I as tooltipTitle,
|
|
59
|
+
y as tooltipValue,
|
|
60
|
+
H as tradingHeader
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs as s, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as u, useRef as x, useImperativeHandle as w } from "react";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import { useChartDimensions as C } from "./useChartDimensions.js";
|
|
5
|
+
import o from "./Chart.module.scss.js";
|
|
6
|
+
const N = u(
|
|
7
|
+
({ aspectRatio: a = 16 / 9, height: h, className: d, style: m, classes: i, legend: l, overlay: c, children: v }, f) => {
|
|
8
|
+
const t = x(null);
|
|
9
|
+
w(f, () => t.current);
|
|
10
|
+
const { width: g } = C(t), e = Math.max(0, g), r = h ?? Math.round(e / a);
|
|
11
|
+
return /* @__PURE__ */ s(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
ref: t,
|
|
15
|
+
className: n(o.root, i?.root, d),
|
|
16
|
+
style: m,
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ s("div", { className: o.canvas, style: { height: r || void 0 }, children: [
|
|
19
|
+
e > 0 && r > 0 && /* @__PURE__ */ p(
|
|
20
|
+
"svg",
|
|
21
|
+
{
|
|
22
|
+
className: n(o.svg, i?.svg),
|
|
23
|
+
width: e,
|
|
24
|
+
height: r,
|
|
25
|
+
viewBox: `0 0 ${e} ${r}`,
|
|
26
|
+
role: "img",
|
|
27
|
+
children: v({ width: e, height: r })
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
c
|
|
31
|
+
] }),
|
|
32
|
+
l
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
N.displayName = "ChartContainer";
|
|
39
|
+
export {
|
|
40
|
+
N as ChartContainer
|
|
41
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as n, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import a from "clsx";
|
|
3
|
+
import l from "./Chart.module.scss.js";
|
|
4
|
+
function h({ config: r, order: o, classes: s }) {
|
|
5
|
+
const c = o ?? Object.keys(r);
|
|
6
|
+
return /* @__PURE__ */ n("div", { className: a(l.legend, s?.legend), role: "list", children: c.map((t) => {
|
|
7
|
+
const e = r[t];
|
|
8
|
+
return e ? /* @__PURE__ */ d("div", { className: a(l.legendItem, s?.legendItem), role: "listitem", children: [
|
|
9
|
+
e.icon ? /* @__PURE__ */ n(
|
|
10
|
+
"span",
|
|
11
|
+
{
|
|
12
|
+
className: l.legendIcon,
|
|
13
|
+
style: { color: e.color },
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: e.icon
|
|
16
|
+
}
|
|
17
|
+
) : /* @__PURE__ */ n(
|
|
18
|
+
"span",
|
|
19
|
+
{
|
|
20
|
+
className: l.legendSwatch,
|
|
21
|
+
style: { background: e.color },
|
|
22
|
+
"aria-hidden": "true"
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
/* @__PURE__ */ n("span", { className: l.legendLabel, children: e.label })
|
|
26
|
+
] }, t) : null;
|
|
27
|
+
}) });
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
h as ChartLegend
|
|
31
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as l, jsxs as p, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import x from "clsx";
|
|
3
|
+
import t from "./Chart.module.scss.js";
|
|
4
|
+
function F({
|
|
5
|
+
row: o,
|
|
6
|
+
x: s,
|
|
7
|
+
y: d,
|
|
8
|
+
containerWidth: m,
|
|
9
|
+
config: h,
|
|
10
|
+
render: c,
|
|
11
|
+
valueFormat: u = String,
|
|
12
|
+
titleKey: n,
|
|
13
|
+
resolveColor: f,
|
|
14
|
+
classes: N
|
|
15
|
+
}) {
|
|
16
|
+
if (!o) return null;
|
|
17
|
+
const a = 180, g = s + a + 16 > m ? s - a - 12 : s + 12, v = Math.max(8, d - 16);
|
|
18
|
+
return /* @__PURE__ */ l(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: x(t.tooltip, N?.tooltip),
|
|
22
|
+
style: { left: g, top: v, width: a },
|
|
23
|
+
role: "tooltip",
|
|
24
|
+
children: c ? c(o) : /* @__PURE__ */ p(j, { children: [
|
|
25
|
+
n && o[n] !== void 0 && /* @__PURE__ */ l("div", { className: t.tooltipTitle, children: String(o[n]) }),
|
|
26
|
+
/* @__PURE__ */ l("div", { className: t.tooltipRows, children: Object.entries(h).map(([e, r]) => {
|
|
27
|
+
const i = o[e];
|
|
28
|
+
if (i == null) return null;
|
|
29
|
+
const b = typeof i == "number" ? u(i) : String(i), S = f?.(e) ?? r.color;
|
|
30
|
+
return /* @__PURE__ */ p("div", { className: t.tooltipRow, children: [
|
|
31
|
+
/* @__PURE__ */ l("span", { className: t.legendSwatch, style: { background: S }, "aria-hidden": "true" }),
|
|
32
|
+
/* @__PURE__ */ l("span", { className: t.tooltipLabel, children: r.label }),
|
|
33
|
+
/* @__PURE__ */ l("span", { className: t.tooltipValue, children: b })
|
|
34
|
+
] }, e);
|
|
35
|
+
}) })
|
|
36
|
+
] })
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
F as ChartTooltip
|
|
42
|
+
};
|