@overdoser/react-toolkit 0.16.0 → 0.18.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 CHANGED
@@ -89,7 +89,7 @@ For exhaustive component reference (every prop, every variant, every signature),
89
89
 
90
90
  - **Need an inline status message?** → `<Alert variant="info|success|warning|danger">`. Add `title` for a heading, `onClose` to make it dismissible. For *transient* feedback prefer Toast; use Alert for persistent, in-flow messaging.
91
91
 
92
- - **Need a status pill / count / tag?** → `<Badge>`. For loading states: `<Spinner>` (indeterminate activity, inherits text color) and `<Skeleton>` (content placeholder — `variant="text|circle|rect"`, `lines` for multi-line text).
92
+ - **Need a status pill / count / tag?** → `<Badge>`. For loading states: `<Loader>` (page / container loading — wrap content to overlay it without a height jump, `mode="overlay"` drop-in, or `mode="fullscreen"`; variants `dots|pulse|spinner|grid|morph`), `<Spinner>` (small inline indicator for buttons and text, inherits text color) and `<Skeleton>` (content placeholder — `variant="text|circle|rect"`, `lines` for multi-line text).
93
93
 
94
94
  - **Need a data table?** → `<Table>`.
95
95
  - All data in memory → don't pass `onSort`; pass `pagination` (without `totalRows`) for client-side paging.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,80 @@ 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.18.0]
8
+
9
+ A loader for pages and containers.
10
+
11
+ ### Added
12
+
13
+ - **`Loader`** — loading indicator for pages and containers, in five variants:
14
+ `dots` (the `Button` loading bounce at scale), `pulse` (the same dots
15
+ swelling and fading in place), `spinner`, `grid` (3×3 cells
16
+ in a diagonal wave) and `morph` (a gradient shape that morphs and turns).
17
+ Needs no CSS on the surrounding elements: wrap content
18
+ (`<Loader loading={busy}>…</Loader>`) and it overlays it while the content
19
+ keeps its height; drop `mode="overlay"` into any container and it covers it,
20
+ positioning a static parent itself; `mode="fullscreen"` covers the viewport;
21
+ with no children and no mode it is a centered block. Over a container taller
22
+ than the screen the indicator stays centred in the visible part. `delay` avoids flashing
23
+ on fast responses, `backdrop` is `dim` / `blur` / `none`, covered content is
24
+ `inert` unless `interactive`, and size, color, speed and the dot geometry are
25
+ CSS variables (`--crk-loader-*`). Honors `prefers-reduced-motion`.
26
+
27
+ ## [0.17.0]
28
+
29
+ A correctness pass over charts, inputs and overlays. Mostly fixes, but a few
30
+ of them change behaviour consumers can observe, hence the minor bump.
31
+
32
+ ### Changed
33
+
34
+ - **Escape and overlays** — Escape now closes one layer at a time. Code that
35
+ relied on a single Escape dismissing a menu *and* the `Modal` / `Drawer`
36
+ around it needs a second press.
37
+ - **`AreaChart`** — the `stackOffset="expand"` tooltip reads
38
+ `<value> · <share>%` instead of a bare percentage, and honours `valueFormat`.
39
+ - **`Select`** (searchable / multi) — `onFocus` / `onBlur` are now called (they
40
+ were dropped before), once per visit to the whole widget. While a searchable
41
+ Select is open, `id` lives on its search input rather than the trigger
42
+ button.
43
+ - **`NumberInput`** — a controlled field never shows a number its parent
44
+ rejected, and `readOnly` disables the step buttons.
45
+
46
+ ### Fixed
47
+
48
+ - **Charts** — `AreaChart`, `BarChart`, `RadarChart` and `PieChart` crashed with
49
+ "Rendered more hooks than during the previous render" when `data` went from
50
+ empty to populated (the normal async-load path).
51
+ - **`TradingChart`** — after switching `symbol` / `resolution`, panning into
52
+ history requested the previous symbol's bars, and a history response still in
53
+ flight during the switch overwrote the new series. A slow request for the old
54
+ symbol no longer blocks history loading for the new one.
55
+ - **`AreaChart`** — the `stackOffset="expand"` tooltip showed `2000%`-style
56
+ values (raw value × 100) and ignored `valueFormat`. It now shows
57
+ `<value> · <share>%`.
58
+ - **`NumberInput`** — a controlled, focused field kept showing the old number
59
+ while ArrowUp / ArrowDown stepped the value, and stayed stale after blur. A
60
+ controlled field's text now follows `value` for steps and blur-clamps (so a
61
+ parent that rejects them keeps its number on screen), and on blur it reverts
62
+ to `value` if the parent rejected what was typed. `readOnly` now blocks the
63
+ step buttons and arrow keys.
64
+ - **`Select`** (searchable / multi) — `name` and `form` reach the hidden native
65
+ select, so values appear in `FormData` (including `allowCreate` values missing
66
+ from `options`; an unselected searchable Select submits `''` rather than the
67
+ first option). `aria-*`, `data-*`, `title`, `autoFocus`, `tabIndex` reach the
68
+ visible control and `required` maps to `aria-required`; while a searchable
69
+ Select is open its search input carries the same `aria-*` props and takes
70
+ over `id`, so the focused element keeps its name. `onFocus` / `onBlur`
71
+ now fire at widget level, so blur-based `FormField` validation works. Escape
72
+ closes the menu even when the filter matches nothing; typing into a closed
73
+ multi Select no longer loses the first character; Escape on a closed multi
74
+ Select is left for the surrounding overlay.
75
+ - **Overlays** — Escape only reaches the topmost open overlay. Closing a
76
+ `Dropdown`, `Popover`, `SplitButton` menu, `Select` menu or date picker inside
77
+ a `Modal` / `Drawer` no longer closes the Modal too (including from the
78
+ calendar's navigation buttons, and when nested overlays mount already open),
79
+ and a Modal with `closeOnEscape={false}` shields what is beneath it.
80
+
7
81
  ## [0.16.0]
8
82
 
9
83
  A date + time picker, and month/year jumping in the calendar header.
@@ -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
- /** Format numeric values inside the default tooltip. */
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 l, jsxs as I, Fragment as pt } from "react/jsx-runtime";
2
- import { useMemo as O, useState as $t, useRef as gt, useId as dt } from "react";
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 Mt } from "./ChartContainer.js";
5
- import { ChartLegend as Lt } from "./ChartLegend.js";
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 bt, XAxis as Ct } from "./Axis.js";
8
- import { bandScale as tt, niceTicks as Nt, linearScale as Tt } from "./scales.js";
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 kt = { top: 12, right: 16, bottom: 28, left: 48 };
11
- function U(t, s) {
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((o, n) => `${n === 0 ? "M" : "L"} ${o.x} ${o.y}`).join(" ");
15
+ return t.map((e, o) => `${o === 0 ? "M" : "L"} ${e.x} ${e.y}`).join(" ");
16
16
  if (s === "step") {
17
- let o = `M ${t[0].x} ${t[0].y}`;
18
- for (let n = 1; n < t.length; n++)
19
- o += ` L ${t[n].x} ${t[n - 1].y} L ${t[n].x} ${t[n].y}`;
20
- return o;
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 c = `M ${t[0].x} ${t[0].y}`;
23
- for (let o = 0; o < t.length - 1; o++) {
24
- const n = t[o - 1] ?? t[o], h = t[o], m = t[o + 1], u = t[o + 2] ?? m, y = h.x + (m.x - n.x) / 6, k = h.y + (m.y - n.y) / 6, _ = m.x - (u.x - h.x) / 6, S = m.y - (u.y - h.y) / 6;
25
- c += ` C ${y} ${k}, ${_} ${S}, ${m.x} ${m.y}`;
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 c;
27
+ return r;
28
28
  }
29
- function G(t, s, c) {
29
+ function ot(t, s, r) {
30
30
  if (t.length === 0) return "";
31
- const o = U(t, c);
31
+ const e = V(t, r);
32
32
  if (typeof s == "number") {
33
- const u = t[t.length - 1], y = t[0];
34
- return `${o} L ${u.x} ${s} L ${y.x} ${s} Z`;
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 n = t.map((u, y) => ({ x: u.x, y: s[y] })).reverse(), m = U(n, c).replace(/^M /, "L ");
37
- return `${o} ${m} Z`;
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 c = Math.ceil(t.length / s);
42
- return t.filter((o, n) => n % c === 0);
41
+ const r = Math.ceil(t.length / s);
42
+ return t.filter((e, o) => o % r === 0);
43
43
  }
44
- function _t({
44
+ function Zt({
45
45
  data: t,
46
46
  xKey: s,
47
- config: c,
48
- aspectRatio: o = 16 / 9,
49
- height: n,
50
- curve: h = "monotone",
47
+ config: r,
48
+ aspectRatio: e = 16 / 9,
49
+ height: o,
50
+ curve: l = "monotone",
51
51
  stacked: m = !1,
52
- stackOffset: u = "none",
52
+ stackOffset: h = "none",
53
53
  fillGradient: y = !1,
54
54
  showGrid: k = !0,
55
- showXAxis: _ = !0,
56
- showYAxis: S = !0,
57
- showLegend: et = !0,
58
- showTooltip: ot = !0,
59
- yTickCount: nt = 5,
60
- yFormat: rt,
61
- xFormat: ct,
62
- valueFormat: lt,
63
- renderTooltip: q,
64
- margin: z,
65
- emptyMessage: st = "No data",
66
- className: J,
67
- style: K,
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 R = O(
70
+ const S = E(
71
71
  () => ({
72
- ...kt,
73
- ...S ? {} : { left: 16 },
74
- ...z
72
+ ...Rt,
73
+ ...R ? {} : { left: 16 },
74
+ ...J
75
75
  }),
76
- [z, S]
77
- ), $ = O(() => Object.keys(c), [c]), w = m && $.length > 0, M = w && u === "expand", [L, Q] = $t(null), j = gt(null), V = dt();
78
- if (t.length === 0)
79
- return /* @__PURE__ */ l("div", { ref: j, className: X(x.root, p?.root, J), style: K, children: /* @__PURE__ */ l("div", { className: x.canvas, style: { height: n ?? 240 }, children: /* @__PURE__ */ l("div", { className: x.empty, children: st }) }) });
80
- const it = O(() => {
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 a of $) {
86
- const b = t[r][a];
87
- typeof b == "number" && b > 0 && (i += b);
82
+ for (const f of d) {
83
+ const v = t[c][f];
84
+ typeof v == "number" && v > 0 && (a += v);
88
85
  }
89
- i === 0 && (i = 1);
86
+ a === 0 && (a = 1);
90
87
  }
91
- let v = 0;
92
- for (let a = 0; a < $.length; a++) {
93
- const b = $[a], D = t[r][b], d = typeof D == "number" ? D : 0;
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 ? d / i : d;
96
- g[a][r] = v, v += C, f[a][r] = v;
92
+ const C = M ? g / a : g;
93
+ $[f][c] = b, b += C, u[f][c] = b;
97
94
  } else
98
- g[a][r] = 0, f[a][r] = d;
95
+ $[f][c] = 0, u[f][c] = g;
99
96
  }
100
97
  }
101
- return { tops: f, bottoms: g };
102
- }, [t, $, w, M]), { tops: E, bottoms: Z } = it, [at, mt] = O(() => {
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 f = 0, g = 0;
105
- for (const r of E)
106
- for (const i of r)
107
- i < f && (f = i), i > g && (g = i);
108
- for (const r of Z)
109
- for (const i of r)
110
- i < f && (f = i);
111
- return [Math.min(0, f), g];
112
- }, [E, Z, M]);
113
- return /* @__PURE__ */ l(
114
- Mt,
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: o,
118
- height: n,
119
- className: J,
120
- style: K,
117
+ aspectRatio: e,
118
+ height: o,
119
+ className: K,
120
+ style: Q,
121
121
  classes: p,
122
- legend: et ? /* @__PURE__ */ l(Lt, { config: c, classes: p }) : void 0,
123
- overlay: ot && L !== null ? /* @__PURE__ */ l(
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: t[L],
127
- x: Rt(t, s, R, L, j),
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: c,
131
- render: q ? () => q(t[L]) : void 0,
132
- valueFormat: M ? (f) => `${Math.round(f * 100)}%` : lt,
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: f, height: g }) => {
138
- const r = R.left, i = f - R.right, v = R.top, a = g - R.bottom, b = Math.max(0, i - r), D = Math.max(0, a - v), d = t.map((e) => String(e[s])), C = tt(d, [r, i], 0), W = M ? [0, 0.25, 0.5, 0.75, 1] : Nt(at, mt, nt), F = Tt([W[0], W[W.length - 1]], [a, v]), ft = F(0), Y = W.map((e) => ({ value: e, y: F(e) })), ht = St(d).map((e) => ({ label: e, x: C(e) })), ut = M ? (e) => `${Math.round(e * 100)}%` : rt;
139
- return /* @__PURE__ */ I(pt, { children: [
140
- y && /* @__PURE__ */ l("defs", { children: $.map((e) => /* @__PURE__ */ I(
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: `${V}-${e}`,
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__ */ l("stop", { offset: "5%", stopColor: c[e].color, stopOpacity: 0.6 }),
150
- /* @__PURE__ */ l("stop", { offset: "95%", stopColor: c[e].color, stopOpacity: 0.05 })
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
- e
153
+ n
154
154
  )) }),
155
- S ? /* @__PURE__ */ l(
156
- bt,
155
+ R ? /* @__PURE__ */ i(
156
+ Ct,
157
157
  {
158
- ticks: Y,
159
- x: r,
160
- plotWidth: b,
161
- format: ut,
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__ */ l("g", { className: X(x.axis, p?.axis), children: Y.map(({ value: e, y: N }) => /* @__PURE__ */ l(
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: r,
170
- x2: i,
169
+ x1: c,
170
+ x2: a,
171
171
  y1: N,
172
172
  y2: N
173
173
  },
174
- `grid-${e}`
174
+ `grid-${n}`
175
175
  )) }),
176
- _ && /* @__PURE__ */ l(Ct, { ticks: ht, y: a, format: ct, classes: p }),
177
- $.map((e, N) => {
178
- const A = c[e], T = t.map((B, P) => ({
179
- x: C(d[P]),
180
- y: F(E[N][P])
181
- })), H = y ? `url(#${V}-${e})` : A.color, xt = y ? 1 : 0.18, yt = w ? G(T, Z[N].map((B) => F(B)), h) : G(T, ft, h);
182
- return /* @__PURE__ */ I("g", { className: X(x.series, p?.series), children: [
183
- /* @__PURE__ */ l(
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: yt,
188
- fill: H,
189
- fillOpacity: xt
187
+ d: pt,
188
+ fill: I,
189
+ fillOpacity: yt
190
190
  }
191
191
  ),
192
- /* @__PURE__ */ l("path", { className: x.linePath, d: U(T, h), stroke: A.color }),
193
- !w && T.map((B, P) => /* @__PURE__ */ l(
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
- `${e}-${P}`
202
+ `${n}-${P}`
203
203
  ))
204
- ] }, e);
204
+ ] }, n);
205
205
  }),
206
- L !== null && /* @__PURE__ */ l(
206
+ L !== null && /* @__PURE__ */ i(
207
207
  "line",
208
208
  {
209
209
  className: x.cursorLine,
210
- x1: C(d[L]),
211
- x2: C(d[L]),
212
- y1: v,
213
- y2: a
210
+ x1: C(g[L]),
211
+ x2: C(g[L]),
212
+ y1: b,
213
+ y2: f
214
214
  }
215
215
  ),
216
- /* @__PURE__ */ l(
216
+ /* @__PURE__ */ i(
217
217
  "rect",
218
218
  {
219
219
  className: x.interactionLayer,
220
- x: r,
221
- y: v,
222
- width: b,
223
- height: D,
224
- onMouseMove: (e) => {
225
- const N = e.currentTarget.getBoundingClientRect(), A = e.clientX - N.left + r, T = C.step(), H = Math.max(0, Math.min(t.length - 1, Math.round((A - r - T / 2) / T)));
226
- Q(H);
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: () => Q(null)
228
+ onMouseLeave: () => Y(null)
229
229
  }
230
230
  )
231
231
  ] });
@@ -233,12 +233,23 @@ function _t({
233
233
  }
234
234
  );
235
235
  }
236
- function Rt(t, s, c, o, n) {
237
- const h = n.current;
238
- if (!h) return 0;
239
- const m = h.getBoundingClientRect().width, u = t.map((k) => String(k[s]));
240
- return tt(u, [c.left, m - c.right], 0)(u[o]);
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
- _t as AreaChart
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, $, _]), 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(
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,