@overdoser/react-toolkit 0.15.0 → 0.17.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 -0
- package/CHANGELOG.md +87 -0
- package/components/Chart/AreaChart.d.ts +5 -1
- package/components/Chart/AreaChart.js +155 -144
- package/components/Chart/BarChart.js +5 -5
- package/components/Chart/PieChart.js +2 -5
- package/components/Chart/RadarChart.js +2 -5
- package/components/Chart/TradingChart.js +258 -257
- package/components/Drawer/Drawer.js +69 -70
- package/components/Dropdown/Dropdown.js +51 -56
- package/components/Modal/Modal.js +42 -47
- package/components/Popover/Popover.js +52 -55
- package/components/SplitButton/SplitButton.js +50 -55
- package/components/inputs/DatePicker/CalendarPanel.d.ts +40 -0
- package/components/inputs/DatePicker/CalendarPanel.js +287 -0
- package/components/inputs/DatePicker/CalendarPanel.module.scss.js +41 -0
- package/components/inputs/DatePicker/DatePicker.d.ts +3 -1
- package/components/inputs/DatePicker/DatePicker.js +105 -192
- package/components/inputs/DatePicker/DatePicker.module.scss.js +20 -40
- package/components/inputs/DateTimePicker/DateTimePicker.d.ts +141 -0
- package/components/inputs/DateTimePicker/DateTimePicker.js +232 -0
- package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +37 -0
- package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +48 -0
- package/components/inputs/DateTimePicker/DateTimeSegments.js +252 -0
- package/components/inputs/DateTimePicker/TimeField.d.ts +18 -0
- package/components/inputs/DateTimePicker/TimeField.js +135 -0
- package/components/inputs/DateTimePicker/index.d.ts +3 -0
- package/components/inputs/DateTimePicker/timeZoneUtils.d.ts +44 -0
- package/components/inputs/DateTimePicker/timeZoneUtils.js +102 -0
- package/components/inputs/NumberInput/NumberInput.js +79 -81
- package/components/inputs/Select/Select.d.ts +5 -0
- package/components/inputs/Select/Select.js +340 -285
- package/hooks/useEscapeLayer.d.ts +36 -0
- package/hooks/useEscapeLayer.js +33 -0
- package/index.css +1 -1
- package/index.d.ts +2 -0
- package/index.js +108 -106
- package/index.layered.css +1 -1
- package/llms.txt +29 -4
- package/manifest.json +127 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -75,6 +75,8 @@ For exhaustive component reference (every prop, every variant, every signature),
|
|
|
75
75
|
|
|
76
76
|
- **Need a date input?** → `<DatePicker value onChange min max disabledDate />` — pop-up calendar, single date, binds in `FormField` (`value: Date | null`).
|
|
77
77
|
|
|
78
|
+
- **Need a date *and* time?** → `<DateTimePicker value onChange />` — editable segments in the field (click a part, arrows step, digits type) plus a calendar-icon popover with the calendar beside scrollable hour/minute columns (MUI-style); `hourCycle={12|24}`, `showSeconds`, `minuteStep` (default 5). Defaults: `YYYY-MM-DD HH:mm:ss UTC`, 24h, UTC, zone labelled inline after the time. The value is an absolute instant; `timeZone="system"` (or any IANA zone) edits in another wall clock (`… 17:30:00 GMT+03:00`), `fieldFormat="locale"` follows the locale order, `showTimeZone={false}` drops the label. Don't build a time picker from `DatePicker` + `NumberInput`s.
|
|
79
|
+
|
|
78
80
|
- **Need file upload?** → `<Dropzone onFiles accept maxSize multiple />` — drag-drop or click; it emits accepted/rejected files but leaves the file-list UI to you.
|
|
79
81
|
|
|
80
82
|
- **Need a countdown / stopwatch / elapsed display?** → `<Timer mode="countdown|stopwatch" duration={…} variant="digital|ring" label="…" />`. Drive it with `autoStart` + an imperative ref (`start`/`pause`/`reset`/`restart`), or make it display-only with `value`.
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,93 @@ All notable changes to `@overdoser/react-toolkit` are documented here.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.17.0]
|
|
8
|
+
|
|
9
|
+
A correctness pass over charts, inputs and overlays. Mostly fixes, but a few
|
|
10
|
+
of them change behaviour consumers can observe, hence the minor bump.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Escape and overlays** — Escape now closes one layer at a time. Code that
|
|
15
|
+
relied on a single Escape dismissing a menu *and* the `Modal` / `Drawer`
|
|
16
|
+
around it needs a second press.
|
|
17
|
+
- **`AreaChart`** — the `stackOffset="expand"` tooltip reads
|
|
18
|
+
`<value> · <share>%` instead of a bare percentage, and honours `valueFormat`.
|
|
19
|
+
- **`Select`** (searchable / multi) — `onFocus` / `onBlur` are now called (they
|
|
20
|
+
were dropped before), once per visit to the whole widget. While a searchable
|
|
21
|
+
Select is open, `id` lives on its search input rather than the trigger
|
|
22
|
+
button.
|
|
23
|
+
- **`NumberInput`** — a controlled field never shows a number its parent
|
|
24
|
+
rejected, and `readOnly` disables the step buttons.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Charts** — `AreaChart`, `BarChart`, `RadarChart` and `PieChart` crashed with
|
|
29
|
+
"Rendered more hooks than during the previous render" when `data` went from
|
|
30
|
+
empty to populated (the normal async-load path).
|
|
31
|
+
- **`TradingChart`** — after switching `symbol` / `resolution`, panning into
|
|
32
|
+
history requested the previous symbol's bars, and a history response still in
|
|
33
|
+
flight during the switch overwrote the new series. A slow request for the old
|
|
34
|
+
symbol no longer blocks history loading for the new one.
|
|
35
|
+
- **`AreaChart`** — the `stackOffset="expand"` tooltip showed `2000%`-style
|
|
36
|
+
values (raw value × 100) and ignored `valueFormat`. It now shows
|
|
37
|
+
`<value> · <share>%`.
|
|
38
|
+
- **`NumberInput`** — a controlled, focused field kept showing the old number
|
|
39
|
+
while ArrowUp / ArrowDown stepped the value, and stayed stale after blur. A
|
|
40
|
+
controlled field's text now follows `value` for steps and blur-clamps (so a
|
|
41
|
+
parent that rejects them keeps its number on screen), and on blur it reverts
|
|
42
|
+
to `value` if the parent rejected what was typed. `readOnly` now blocks the
|
|
43
|
+
step buttons and arrow keys.
|
|
44
|
+
- **`Select`** (searchable / multi) — `name` and `form` reach the hidden native
|
|
45
|
+
select, so values appear in `FormData` (including `allowCreate` values missing
|
|
46
|
+
from `options`; an unselected searchable Select submits `''` rather than the
|
|
47
|
+
first option). `aria-*`, `data-*`, `title`, `autoFocus`, `tabIndex` reach the
|
|
48
|
+
visible control and `required` maps to `aria-required`; while a searchable
|
|
49
|
+
Select is open its search input carries the same `aria-*` props and takes
|
|
50
|
+
over `id`, so the focused element keeps its name. `onFocus` / `onBlur`
|
|
51
|
+
now fire at widget level, so blur-based `FormField` validation works. Escape
|
|
52
|
+
closes the menu even when the filter matches nothing; typing into a closed
|
|
53
|
+
multi Select no longer loses the first character; Escape on a closed multi
|
|
54
|
+
Select is left for the surrounding overlay.
|
|
55
|
+
- **Overlays** — Escape only reaches the topmost open overlay. Closing a
|
|
56
|
+
`Dropdown`, `Popover`, `SplitButton` menu, `Select` menu or date picker inside
|
|
57
|
+
a `Modal` / `Drawer` no longer closes the Modal too (including from the
|
|
58
|
+
calendar's navigation buttons, and when nested overlays mount already open),
|
|
59
|
+
and a Modal with `closeOnEscape={false}` shields what is beneath it.
|
|
60
|
+
|
|
61
|
+
## [0.16.0]
|
|
62
|
+
|
|
63
|
+
A date + time picker, and month/year jumping in the calendar header.
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
|
|
67
|
+
- **`DateTimePicker`** — date and time in one field, binding in `FormField`
|
|
68
|
+
like `DatePicker` (`value: Date | null`). The field is a row of editable
|
|
69
|
+
segments: click one, Up/Down steps it (wrapping inside the segment),
|
|
70
|
+
Left/Right moves between segments, digits type with auto-advance,
|
|
71
|
+
Backspace clears; on an empty field the first arrow press fills in "now".
|
|
72
|
+
The calendar icon (or Alt+ArrowDown) opens a popover with the `DatePicker`
|
|
73
|
+
calendar beside scrollable hours / minutes / seconds / AM-PM columns;
|
|
74
|
+
picking a day keeps the time and leaves the popover open, every change
|
|
75
|
+
commits immediately. Defaults: `YYYY-MM-DD HH:mm:ss UTC`, 24-hour clock,
|
|
76
|
+
seconds on, zone badge right after the time. Props: `timeZone` (IANA name,
|
|
77
|
+
`'UTC'`, or `'system'` for the local zone — the value is always an absolute
|
|
78
|
+
instant, only the wall clock shown changes), `showTimeZone`,
|
|
79
|
+
`timeZoneStyle` (`GMT+03:00` by default), `fieldFormat: 'iso' | 'locale'`,
|
|
80
|
+
`hourCycle: 12 | 24`, `showSeconds`, `minuteStep`, `doneLabel`, plus
|
|
81
|
+
`min`/`max` as instants (days outside are disabled, boundary-day times
|
|
82
|
+
clamp). Forwards its ref to the root `<div>`. Exports `DateTimePickerProps`,
|
|
83
|
+
`DateTimePickerClasses`, `TimeZoneNameStyle`.
|
|
84
|
+
|
|
85
|
+
### Changed
|
|
86
|
+
|
|
87
|
+
- **`DatePicker`** — the month and year in the calendar header are now
|
|
88
|
+
buttons: month opens a 12-month grid, year opens a scrollable year list
|
|
89
|
+
(keyboard-navigable, gated and clipped by `min`/`max`). Props, value
|
|
90
|
+
semantics, and the `DatePickerClasses` shape are unchanged; the month
|
|
91
|
+
label became a visually-hidden live region so month changes are still
|
|
92
|
+
announced.
|
|
93
|
+
|
|
7
94
|
## [0.15.0]
|
|
8
95
|
|
|
9
96
|
A split button for grouped row actions, and a Dropdown positioning fix.
|
|
@@ -50,7 +50,11 @@ export interface AreaChartProps<T extends Record<string, unknown>> {
|
|
|
50
50
|
yFormat?: (v: number) => string;
|
|
51
51
|
/** Format X axis tick labels. */
|
|
52
52
|
xFormat?: (v: string) => string;
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Format numeric values inside the default tooltip. With
|
|
55
|
+
* `stackOffset="expand"` the tooltip appends each series' share of the row,
|
|
56
|
+
* e.g. `$30 · 25%`.
|
|
57
|
+
*/
|
|
54
58
|
valueFormat?: (v: number) => string;
|
|
55
59
|
/** Custom tooltip body. */
|
|
56
60
|
renderTooltip?: (row: T) => ReactNode;
|
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsx as i, jsxs as U, Fragment as dt } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as E, useState as $t, useRef as gt, useId as Mt } from "react";
|
|
3
3
|
import X from "clsx";
|
|
4
|
-
import { ChartContainer as
|
|
5
|
-
import { ChartLegend as
|
|
4
|
+
import { ChartContainer as Lt } from "./ChartContainer.js";
|
|
5
|
+
import { ChartLegend as bt } from "./ChartLegend.js";
|
|
6
6
|
import { ChartTooltip as vt } from "./ChartTooltip.js";
|
|
7
|
-
import { YAxis as
|
|
8
|
-
import { bandScale as
|
|
7
|
+
import { YAxis as Ct, XAxis as Nt } from "./Axis.js";
|
|
8
|
+
import { bandScale as et, niceTicks as Tt, linearScale as kt } from "./scales.js";
|
|
9
9
|
import x from "./Chart.module.scss.js";
|
|
10
|
-
const
|
|
11
|
-
function
|
|
10
|
+
const Rt = { top: 12, right: 16, bottom: 28, left: 48 };
|
|
11
|
+
function V(t, s) {
|
|
12
12
|
if (t.length === 0) return "";
|
|
13
13
|
if (t.length === 1) return `M ${t[0].x} ${t[0].y}`;
|
|
14
14
|
if (s === "linear")
|
|
15
|
-
return t.map((
|
|
15
|
+
return t.map((e, o) => `${o === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
|
|
16
16
|
if (s === "step") {
|
|
17
|
-
let
|
|
18
|
-
for (let
|
|
19
|
-
|
|
20
|
-
return
|
|
17
|
+
let e = `M ${t[0].x} ${t[0].y}`;
|
|
18
|
+
for (let o = 1; o < t.length; o++)
|
|
19
|
+
e += ` L ${t[o].x} ${t[o - 1].y} L ${t[o].x} ${t[o].y}`;
|
|
20
|
+
return e;
|
|
21
21
|
}
|
|
22
|
-
let
|
|
23
|
-
for (let
|
|
24
|
-
const
|
|
25
|
-
|
|
22
|
+
let r = `M ${t[0].x} ${t[0].y}`;
|
|
23
|
+
for (let e = 0; e < t.length - 1; e++) {
|
|
24
|
+
const o = t[e - 1] ?? t[e], l = t[e], m = t[e + 1], h = t[e + 2] ?? m, y = l.x + (m.x - o.x) / 6, k = l.y + (m.y - o.y) / 6, F = m.x - (h.x - l.x) / 6, R = m.y - (h.y - l.y) / 6;
|
|
25
|
+
r += ` C ${y} ${k}, ${F} ${R}, ${m.x} ${m.y}`;
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return r;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function ot(t, s, r) {
|
|
30
30
|
if (t.length === 0) return "";
|
|
31
|
-
const
|
|
31
|
+
const e = V(t, r);
|
|
32
32
|
if (typeof s == "number") {
|
|
33
|
-
const
|
|
34
|
-
return `${
|
|
33
|
+
const h = t[t.length - 1], y = t[0];
|
|
34
|
+
return `${e} L ${h.x} ${s} L ${y.x} ${s} Z`;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
return `${
|
|
36
|
+
const o = t.map((h, y) => ({ x: h.x, y: s[y] })).reverse(), m = V(o, r).replace(/^M /, "L ");
|
|
37
|
+
return `${e} ${m} Z`;
|
|
38
38
|
}
|
|
39
39
|
function St(t, s = 8) {
|
|
40
40
|
if (t.length <= s) return t;
|
|
41
|
-
const
|
|
42
|
-
return t.filter((
|
|
41
|
+
const r = Math.ceil(t.length / s);
|
|
42
|
+
return t.filter((e, o) => o % r === 0);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function Zt({
|
|
45
45
|
data: t,
|
|
46
46
|
xKey: s,
|
|
47
|
-
config:
|
|
48
|
-
aspectRatio:
|
|
49
|
-
height:
|
|
50
|
-
curve:
|
|
47
|
+
config: r,
|
|
48
|
+
aspectRatio: e = 16 / 9,
|
|
49
|
+
height: o,
|
|
50
|
+
curve: l = "monotone",
|
|
51
51
|
stacked: m = !1,
|
|
52
|
-
stackOffset:
|
|
52
|
+
stackOffset: h = "none",
|
|
53
53
|
fillGradient: y = !1,
|
|
54
54
|
showGrid: k = !0,
|
|
55
|
-
showXAxis:
|
|
56
|
-
showYAxis:
|
|
57
|
-
showLegend:
|
|
58
|
-
showTooltip:
|
|
59
|
-
yTickCount:
|
|
60
|
-
yFormat:
|
|
61
|
-
xFormat:
|
|
62
|
-
valueFormat:
|
|
63
|
-
renderTooltip:
|
|
64
|
-
margin:
|
|
65
|
-
emptyMessage:
|
|
66
|
-
className:
|
|
67
|
-
style:
|
|
55
|
+
showXAxis: F = !0,
|
|
56
|
+
showYAxis: R = !0,
|
|
57
|
+
showLegend: nt = !0,
|
|
58
|
+
showTooltip: rt = !0,
|
|
59
|
+
yTickCount: ct = 5,
|
|
60
|
+
yFormat: st,
|
|
61
|
+
xFormat: lt,
|
|
62
|
+
valueFormat: q,
|
|
63
|
+
renderTooltip: z,
|
|
64
|
+
margin: J,
|
|
65
|
+
emptyMessage: it = "No data",
|
|
66
|
+
className: K,
|
|
67
|
+
style: Q,
|
|
68
68
|
classes: p
|
|
69
69
|
}) {
|
|
70
|
-
const
|
|
70
|
+
const S = E(
|
|
71
71
|
() => ({
|
|
72
|
-
...
|
|
73
|
-
...
|
|
74
|
-
...
|
|
72
|
+
...Rt,
|
|
73
|
+
...R ? {} : { left: 16 },
|
|
74
|
+
...J
|
|
75
75
|
}),
|
|
76
|
-
[
|
|
77
|
-
),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const f = $.map(() => []), g = $.map(() => []);
|
|
82
|
-
for (let r = 0; r < t.length; r++) {
|
|
83
|
-
let i = 0;
|
|
76
|
+
[J, R]
|
|
77
|
+
), d = E(() => Object.keys(r), [r]), w = m && d.length > 0, M = w && h === "expand", [L, Y] = $t(null), j = gt(null), G = Mt(), at = E(() => {
|
|
78
|
+
const u = d.map(() => []), $ = d.map(() => []);
|
|
79
|
+
for (let c = 0; c < t.length; c++) {
|
|
80
|
+
let a = 0;
|
|
84
81
|
if (M) {
|
|
85
|
-
for (const
|
|
86
|
-
const
|
|
87
|
-
typeof
|
|
82
|
+
for (const f of d) {
|
|
83
|
+
const v = t[c][f];
|
|
84
|
+
typeof v == "number" && v > 0 && (a += v);
|
|
88
85
|
}
|
|
89
|
-
|
|
86
|
+
a === 0 && (a = 1);
|
|
90
87
|
}
|
|
91
|
-
let
|
|
92
|
-
for (let
|
|
93
|
-
const
|
|
88
|
+
let b = 0;
|
|
89
|
+
for (let f = 0; f < d.length; f++) {
|
|
90
|
+
const v = d[f], W = t[c][v], g = typeof W == "number" ? W : 0;
|
|
94
91
|
if (w) {
|
|
95
|
-
const C = M ?
|
|
96
|
-
|
|
92
|
+
const C = M ? g / a : g;
|
|
93
|
+
$[f][c] = b, b += C, u[f][c] = b;
|
|
97
94
|
} else
|
|
98
|
-
|
|
95
|
+
$[f][c] = 0, u[f][c] = g;
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
return { tops:
|
|
102
|
-
}, [t,
|
|
98
|
+
return { tops: u, bottoms: $ };
|
|
99
|
+
}, [t, d, w, M]), { tops: Z, bottoms: H } = at, [ft, mt] = E(() => {
|
|
103
100
|
if (M) return [0, 1];
|
|
104
|
-
let
|
|
105
|
-
for (const
|
|
106
|
-
for (const
|
|
107
|
-
|
|
108
|
-
for (const
|
|
109
|
-
for (const
|
|
110
|
-
|
|
111
|
-
return [Math.min(0,
|
|
112
|
-
}, [
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
let u = 0, $ = 0;
|
|
102
|
+
for (const c of Z)
|
|
103
|
+
for (const a of c)
|
|
104
|
+
a < u && (u = a), a > $ && ($ = a);
|
|
105
|
+
for (const c of H)
|
|
106
|
+
for (const a of c)
|
|
107
|
+
a < u && (u = a);
|
|
108
|
+
return [Math.min(0, u), $];
|
|
109
|
+
}, [Z, H, M]);
|
|
110
|
+
if (t.length === 0)
|
|
111
|
+
return /* @__PURE__ */ i("div", { ref: j, className: X(x.root, p?.root, K), style: Q, children: /* @__PURE__ */ i("div", { className: x.canvas, style: { height: o ?? 240 }, children: /* @__PURE__ */ i("div", { className: x.empty, children: it }) }) });
|
|
112
|
+
const D = L !== null ? t[L] : void 0;
|
|
113
|
+
return /* @__PURE__ */ i(
|
|
114
|
+
Lt,
|
|
115
115
|
{
|
|
116
116
|
ref: j,
|
|
117
|
-
aspectRatio:
|
|
118
|
-
height:
|
|
119
|
-
className:
|
|
120
|
-
style:
|
|
117
|
+
aspectRatio: e,
|
|
118
|
+
height: o,
|
|
119
|
+
className: K,
|
|
120
|
+
style: Q,
|
|
121
121
|
classes: p,
|
|
122
|
-
legend:
|
|
123
|
-
overlay:
|
|
122
|
+
legend: nt ? /* @__PURE__ */ i(bt, { config: r, classes: p }) : void 0,
|
|
123
|
+
overlay: rt && L !== null && D ? /* @__PURE__ */ i(
|
|
124
124
|
vt,
|
|
125
125
|
{
|
|
126
|
-
row:
|
|
127
|
-
x:
|
|
126
|
+
row: D,
|
|
127
|
+
x: At(t, s, S, L, j),
|
|
128
128
|
y: 16,
|
|
129
129
|
containerWidth: j.current?.getBoundingClientRect().width ?? 0,
|
|
130
|
-
config:
|
|
131
|
-
render:
|
|
132
|
-
valueFormat: M ? (
|
|
130
|
+
config: r,
|
|
131
|
+
render: z ? () => z(D) : void 0,
|
|
132
|
+
valueFormat: M ? wt(D, d, q) : q,
|
|
133
133
|
titleKey: s,
|
|
134
134
|
classes: p
|
|
135
135
|
}
|
|
136
136
|
) : null,
|
|
137
|
-
children: ({ width:
|
|
138
|
-
const
|
|
139
|
-
return /* @__PURE__ */
|
|
140
|
-
y && /* @__PURE__ */
|
|
137
|
+
children: ({ width: u, height: $ }) => {
|
|
138
|
+
const c = S.left, a = u - S.right, b = S.top, f = $ - S.bottom, v = Math.max(0, a - c), W = Math.max(0, f - b), g = t.map((n) => String(n[s])), C = et(g, [c, a], 0), O = M ? [0, 0.25, 0.5, 0.75, 1] : Tt(ft, mt, ct), _ = kt([O[0], O[O.length - 1]], [f, b]), ht = _(0), tt = O.map((n) => ({ value: n, y: _(n) })), ut = St(g).map((n) => ({ label: n, x: C(n) })), xt = M ? (n) => `${Math.round(n * 100)}%` : st;
|
|
139
|
+
return /* @__PURE__ */ U(dt, { children: [
|
|
140
|
+
y && /* @__PURE__ */ i("defs", { children: d.map((n) => /* @__PURE__ */ U(
|
|
141
141
|
"linearGradient",
|
|
142
142
|
{
|
|
143
|
-
id: `${
|
|
143
|
+
id: `${G}-${n}`,
|
|
144
144
|
x1: "0",
|
|
145
145
|
y1: "0",
|
|
146
146
|
x2: "0",
|
|
147
147
|
y2: "1",
|
|
148
148
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ i("stop", { offset: "5%", stopColor: r[n].color, stopOpacity: 0.6 }),
|
|
150
|
+
/* @__PURE__ */ i("stop", { offset: "95%", stopColor: r[n].color, stopOpacity: 0.05 })
|
|
151
151
|
]
|
|
152
152
|
},
|
|
153
|
-
|
|
153
|
+
n
|
|
154
154
|
)) }),
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
R ? /* @__PURE__ */ i(
|
|
156
|
+
Ct,
|
|
157
157
|
{
|
|
158
|
-
ticks:
|
|
159
|
-
x:
|
|
160
|
-
plotWidth:
|
|
161
|
-
format:
|
|
158
|
+
ticks: tt,
|
|
159
|
+
x: c,
|
|
160
|
+
plotWidth: v,
|
|
161
|
+
format: xt,
|
|
162
162
|
showGrid: k,
|
|
163
163
|
classes: p
|
|
164
164
|
}
|
|
165
|
-
) : k && /* @__PURE__ */
|
|
165
|
+
) : k && /* @__PURE__ */ i("g", { className: X(x.axis, p?.axis), children: tt.map(({ value: n, y: N }) => /* @__PURE__ */ i(
|
|
166
166
|
"line",
|
|
167
167
|
{
|
|
168
168
|
className: X(x.gridLine, p?.grid),
|
|
169
|
-
x1:
|
|
170
|
-
x2:
|
|
169
|
+
x1: c,
|
|
170
|
+
x2: a,
|
|
171
171
|
y1: N,
|
|
172
172
|
y2: N
|
|
173
173
|
},
|
|
174
|
-
`grid-${
|
|
174
|
+
`grid-${n}`
|
|
175
175
|
)) }),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const A =
|
|
179
|
-
x: C(
|
|
180
|
-
y:
|
|
181
|
-
})),
|
|
182
|
-
return /* @__PURE__ */
|
|
183
|
-
/* @__PURE__ */
|
|
176
|
+
F && /* @__PURE__ */ i(Nt, { ticks: ut, y: f, format: lt, classes: p }),
|
|
177
|
+
d.map((n, N) => {
|
|
178
|
+
const A = r[n], T = t.map((B, P) => ({
|
|
179
|
+
x: C(g[P]),
|
|
180
|
+
y: _(Z[N][P])
|
|
181
|
+
})), I = y ? `url(#${G}-${n})` : A.color, yt = y ? 1 : 0.18, pt = w ? ot(T, H[N].map((B) => _(B)), l) : ot(T, ht, l);
|
|
182
|
+
return /* @__PURE__ */ U("g", { className: X(x.series, p?.series), children: [
|
|
183
|
+
/* @__PURE__ */ i(
|
|
184
184
|
"path",
|
|
185
185
|
{
|
|
186
186
|
className: x.areaPath,
|
|
187
|
-
d:
|
|
188
|
-
fill:
|
|
189
|
-
fillOpacity:
|
|
187
|
+
d: pt,
|
|
188
|
+
fill: I,
|
|
189
|
+
fillOpacity: yt
|
|
190
190
|
}
|
|
191
191
|
),
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
!w && T.map((B, P) => /* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ i("path", { className: x.linePath, d: V(T, l), stroke: A.color }),
|
|
193
|
+
!w && T.map((B, P) => /* @__PURE__ */ i(
|
|
194
194
|
"circle",
|
|
195
195
|
{
|
|
196
196
|
className: X(x.point, p?.point),
|
|
@@ -199,33 +199,33 @@ function _t({
|
|
|
199
199
|
r: L === P ? 5 : 3,
|
|
200
200
|
fill: A.color
|
|
201
201
|
},
|
|
202
|
-
`${
|
|
202
|
+
`${n}-${P}`
|
|
203
203
|
))
|
|
204
|
-
] },
|
|
204
|
+
] }, n);
|
|
205
205
|
}),
|
|
206
|
-
L !== null && /* @__PURE__ */
|
|
206
|
+
L !== null && /* @__PURE__ */ i(
|
|
207
207
|
"line",
|
|
208
208
|
{
|
|
209
209
|
className: x.cursorLine,
|
|
210
|
-
x1: C(
|
|
211
|
-
x2: C(
|
|
212
|
-
y1:
|
|
213
|
-
y2:
|
|
210
|
+
x1: C(g[L]),
|
|
211
|
+
x2: C(g[L]),
|
|
212
|
+
y1: b,
|
|
213
|
+
y2: f
|
|
214
214
|
}
|
|
215
215
|
),
|
|
216
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ i(
|
|
217
217
|
"rect",
|
|
218
218
|
{
|
|
219
219
|
className: x.interactionLayer,
|
|
220
|
-
x:
|
|
221
|
-
y:
|
|
222
|
-
width:
|
|
223
|
-
height:
|
|
224
|
-
onMouseMove: (
|
|
225
|
-
const N =
|
|
226
|
-
|
|
220
|
+
x: c,
|
|
221
|
+
y: b,
|
|
222
|
+
width: v,
|
|
223
|
+
height: W,
|
|
224
|
+
onMouseMove: (n) => {
|
|
225
|
+
const N = n.currentTarget.getBoundingClientRect(), A = n.clientX - N.left + c, T = C.step(), I = Math.max(0, Math.min(t.length - 1, Math.round((A - c - T / 2) / T)));
|
|
226
|
+
Y(I);
|
|
227
227
|
},
|
|
228
|
-
onMouseLeave: () =>
|
|
228
|
+
onMouseLeave: () => Y(null)
|
|
229
229
|
}
|
|
230
230
|
)
|
|
231
231
|
] });
|
|
@@ -233,12 +233,23 @@ function _t({
|
|
|
233
233
|
}
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
function wt(t, s, r) {
|
|
237
|
+
let e = 0;
|
|
238
|
+
for (const o of s) {
|
|
239
|
+
const l = t[o];
|
|
240
|
+
typeof l == "number" && l > 0 && (e += l);
|
|
241
|
+
}
|
|
242
|
+
return (o) => {
|
|
243
|
+
const l = e > 0 ? Math.round(o / e * 100) : 0;
|
|
244
|
+
return `${r ? r(o) : o} · ${l}%`;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function At(t, s, r, e, o) {
|
|
248
|
+
const l = o.current;
|
|
249
|
+
if (!l) return 0;
|
|
250
|
+
const m = l.getBoundingClientRect().width, h = t.map((k) => String(k[s]));
|
|
251
|
+
return et(h, [r.left, m - r.right], 0)(h[e]);
|
|
241
252
|
}
|
|
242
253
|
export {
|
|
243
|
-
|
|
254
|
+
Zt as AreaChart
|
|
244
255
|
};
|
|
@@ -51,10 +51,7 @@ function ue({
|
|
|
51
51
|
style: ft,
|
|
52
52
|
classes: l
|
|
53
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(() => {
|
|
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), it = t.map((b) => String(b[c])), N = U ?? gt, bt = $t(() => {
|
|
58
55
|
if (_) {
|
|
59
56
|
let L = 0, h = 0;
|
|
60
57
|
for (const g of t) {
|
|
@@ -75,7 +72,10 @@ function ue({
|
|
|
75
72
|
}
|
|
76
73
|
const [B, m] = Kt(b);
|
|
77
74
|
return [Math.min(0, B), Math.max(0, m)];
|
|
78
|
-
}, [t, $, _])
|
|
75
|
+
}, [t, $, _]);
|
|
76
|
+
if (t.length === 0)
|
|
77
|
+
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 }) }) });
|
|
78
|
+
const 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
79
|
Jt,
|
|
80
80
|
{
|
|
81
81
|
row: t[N],
|
|
@@ -96,10 +96,7 @@ function yt({
|
|
|
96
96
|
typeof s == "number" && s > 0 && (c += s);
|
|
97
97
|
}
|
|
98
98
|
return c;
|
|
99
|
-
}, [t, i])
|
|
100
|
-
if (t.length === 0 || q === 0)
|
|
101
|
-
return /* @__PURE__ */ a("div", { ref: j, className: D(f.root, P?.root, Y), style: K, children: /* @__PURE__ */ a("div", { className: f.canvas, style: { height: d ?? 240 }, children: /* @__PURE__ */ a("div", { className: f.empty, children: it }) }) });
|
|
102
|
-
const N = Q(() => {
|
|
99
|
+
}, [t, i]), N = Q(() => {
|
|
103
100
|
const c = [];
|
|
104
101
|
let r = 0;
|
|
105
102
|
for (let s = 0; s < t.length; s++) {
|
|
@@ -128,7 +125,7 @@ function yt({
|
|
|
128
125
|
};
|
|
129
126
|
return c;
|
|
130
127
|
}, [N]);
|
|
131
|
-
return /* @__PURE__ */ a(
|
|
128
|
+
return t.length === 0 || q === 0 ? /* @__PURE__ */ a("div", { ref: j, className: D(f.root, P?.root, Y), style: K, children: /* @__PURE__ */ a("div", { className: f.canvas, style: { height: d ?? 240 }, children: /* @__PURE__ */ a("div", { className: f.empty, children: it }) }) }) : /* @__PURE__ */ a(
|
|
132
129
|
ht,
|
|
133
130
|
{
|
|
134
131
|
ref: j,
|
|
@@ -42,10 +42,7 @@ function yn({
|
|
|
42
42
|
style: O,
|
|
43
43
|
classes: c
|
|
44
44
|
}) {
|
|
45
|
-
const [$, W] = nn(null), N = tn(null), P = C(() => Object.keys(m), [m])
|
|
46
|
-
if (e.length === 0)
|
|
47
|
-
return /* @__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 }) }) });
|
|
48
|
-
const L = C(
|
|
45
|
+
const [$, W] = nn(null), N = tn(null), P = C(() => Object.keys(m), [m]), L = C(
|
|
49
46
|
() => e.map((d, p) => p / e.length * 360),
|
|
50
47
|
[e]
|
|
51
48
|
), B = C(() => {
|
|
@@ -58,7 +55,7 @@ function yn({
|
|
|
58
55
|
const [, p] = cn(d);
|
|
59
56
|
return Math.max(1, p);
|
|
60
57
|
}, [e, P]), b = C(() => ln(0, B, I).filter((p) => p > 0), [B, I]), V = b[b.length - 1] ?? B;
|
|
61
|
-
return /* @__PURE__ */ o(
|
|
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(
|
|
62
59
|
en,
|
|
63
60
|
{
|
|
64
61
|
ref: N,
|