@dcs-tech/ui 0.10.0 → 0.11.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 +362 -0
- package/README.md +3 -2
- package/THIRD_PARTY_NOTICES.md +23 -0
- package/dist/ChartImageMenu-sB2QNQzd.js +9673 -0
- package/dist/ChartView-BstZkP1g.js +1942 -0
- package/dist/{SummaryChart-i6fOdrDM.js → SummaryChart-B5ibDNOZ.js} +11 -10
- package/dist/{SummaryImage-CCt5ozD9.js → SummaryImage-CRP7X2Nl.js} +2 -2
- package/dist/SummarySeeAll-CtYRGV4G.js +101 -0
- package/dist/assets/fileTask.worker-D97s2vRV.js +1 -0
- package/dist/{columnValue-74XDBcVF.js → columnValue-BOn9NC8X.js} +86 -79
- package/dist/exportContext-CMzuzRjc.js +274 -0
- package/dist/{exportEngine-BmDly7iw.js → exportEngine-CYDN8Ty-.js} +167 -137
- package/dist/file-worker.js +1 -1
- package/dist/{fileActions-CFNO14Aj.js → fileActions-DkPEWE-t.js} +1 -1
- package/dist/{geometry-DG134nYI.js → geometry-CFS5If1N.js} +769 -466
- package/dist/index.js +21095 -12669
- package/dist/{labels-BPItSeRU.js → labels-mukFhYkc.js} +124 -1
- package/dist/{runFileTask-BIZTFnZP.js → runFileTask-DI_39TjR.js} +17 -0
- package/dist/scrollArea-B52kugL1.js +291 -0
- package/dist/style.css +1 -1
- package/dist/{summaryChartData-BiQYJbYZ.js → summaryChartData-D15kw64n.js} +6 -5
- package/dist/types/components/Charts/BarList.d.ts +4 -3
- package/dist/types/components/Charts/CalendarHeatmap.d.ts +4 -2
- package/dist/types/components/Charts/Chart.d.ts +3 -2
- package/dist/types/components/Charts/ChartView.d.ts +3 -2
- package/dist/types/components/Charts/ColumnChart.d.ts +4 -3
- package/dist/types/components/Charts/Donut.d.ts +3 -2
- package/dist/types/components/Charts/Funnel.d.ts +3 -2
- package/dist/types/components/Charts/Gauge.d.ts +3 -2
- package/dist/types/components/Charts/LineChart.d.ts +4 -3
- package/dist/types/components/Charts/NumberTrend.d.ts +4 -3
- package/dist/types/components/Charts/Progress.d.ts +3 -2
- package/dist/types/components/Charts/StackedBar.d.ts +3 -2
- package/dist/types/components/Charts/Treemap.d.ts +3 -2
- package/dist/types/components/Charts/chartData.d.ts +6 -0
- package/dist/types/components/Charts/chartImage.d.ts +2 -0
- package/dist/types/components/Charts/geometry.d.ts +3 -0
- package/dist/types/components/Charts/index.d.ts +2 -0
- package/dist/types/components/Charts/palette.d.ts +1 -0
- package/dist/types/components/Charts/parts.d.ts +14 -0
- package/dist/types/components/Charts/useChartMotion.d.ts +8 -0
- package/dist/types/components/DataTable/DataTable.d.ts +3 -1
- package/dist/types/components/DataTable/DisplayPopover.d.ts +1 -0
- package/dist/types/components/DataTable/HeaderMenu.d.ts +1 -0
- package/dist/types/components/DataTable/TableColumnModal.d.ts +4 -1
- package/dist/types/components/DataTable/TableToolbar.d.ts +20 -1
- package/dist/types/components/DataTable/TableView.d.ts +18 -2
- package/dist/types/components/DataTable/cards/CardView.d.ts +25 -5
- package/dist/types/components/DataTable/cards/rowParts.d.ts +1 -0
- package/dist/types/components/DataTable/cellSelection/CellRangeBar.d.ts +16 -0
- package/dist/types/components/DataTable/cellSelection/cellRangeStore.d.ts +18 -0
- package/dist/types/components/DataTable/cellSelection/paintRanges.d.ts +2 -0
- package/dist/types/components/DataTable/cellSelection/useCellSelection.d.ts +63 -0
- package/dist/types/components/DataTable/data/listDelta.d.ts +27 -0
- package/dist/types/components/DataTable/data/rowLineage.d.ts +3 -0
- package/dist/types/components/DataTable/data/rowModels.d.ts +9 -0
- package/dist/types/components/DataTable/data/rowTransaction.d.ts +9 -0
- package/dist/types/components/DataTable/data/useServerData.d.ts +3 -1
- package/dist/types/components/DataTable/export/exportCells.d.ts +5 -2
- package/dist/types/components/DataTable/export/exportEngine.d.ts +7 -2
- package/dist/types/components/DataTable/export/useTableExport.d.ts +17 -1
- package/dist/types/components/DataTable/filters/filterRowModel.d.ts +1 -0
- package/dist/types/components/DataTable/grouping/groupModel.d.ts +11 -0
- package/dist/types/components/DataTable/index.d.ts +1 -1
- package/dist/types/components/DataTable/keyboard/ShortcutsDialog.d.ts +4 -1
- package/dist/types/components/DataTable/keyboard/useGridKeyboard.d.ts +8 -0
- package/dist/types/components/DataTable/labels.d.ts +128 -0
- package/dist/types/components/DataTable/layout/LayoutSwitcher.d.ts +10 -2
- package/dist/types/components/DataTable/layout/useFitWidths.d.ts +7 -0
- package/dist/types/components/DataTable/menu/RowMenu.d.ts +1 -0
- package/dist/types/components/DataTable/menu/buildRowMenu.d.ts +6 -3
- package/dist/types/components/DataTable/motion/RowChangeNotice.d.ts +19 -0
- package/dist/types/components/DataTable/motion/rowChanges.d.ts +25 -0
- package/dist/types/components/DataTable/motion/useNoticeInsets.d.ts +2 -0
- package/dist/types/components/DataTable/motion/useRowChangeNotices.d.ts +35 -0
- package/dist/types/components/DataTable/motion/useRowMotion.d.ts +29 -3
- package/dist/types/components/DataTable/persistence/reconcile.d.ts +4 -0
- package/dist/types/components/DataTable/persistence/useColumnPersistence.d.ts +5 -1
- package/dist/types/components/DataTable/pivot/PivotPanel.d.ts +11 -0
- package/dist/types/components/DataTable/pivot/PivotView.d.ts +22 -0
- package/dist/types/components/DataTable/pivot/pivotModel.d.ts +54 -0
- package/dist/types/components/DataTable/pivot/usePivot.d.ts +44 -0
- package/dist/types/components/DataTable/rows/PressRow.d.ts +1 -0
- package/dist/types/components/DataTable/rows/RowLead.d.ts +23 -0
- package/dist/types/components/DataTable/rows/rowPress.d.ts +2 -0
- package/dist/types/components/DataTable/rows/usePinnedRows.d.ts +34 -0
- package/dist/types/components/DataTable/rows/useRowDrag.d.ts +44 -0
- package/dist/types/components/DataTable/split/SplitView.d.ts +4 -2
- package/dist/types/components/DataTable/summary/SummaryChart.d.ts +2 -1
- package/dist/types/components/DataTable/summary/TableSummary.d.ts +2 -1
- package/dist/types/components/DataTable/summary/summaryModel.d.ts +28 -6
- package/dist/types/components/DataTable/summary/useTableSummary.d.ts +3 -0
- package/dist/types/components/DataTable/toolbar/ToolbarMore.d.ts +14 -0
- package/dist/types/components/DataTable/toolbar/useToolbarFit.d.ts +10 -0
- package/dist/types/components/DataTable/tree/TreeChips.d.ts +5 -0
- package/dist/types/components/DataTable/tree/treeExport.d.ts +54 -0
- package/dist/types/components/DataTable/tree/treeMove.d.ts +1 -0
- package/dist/types/components/DataTable/tree/useTreeChildren.d.ts +15 -0
- package/dist/types/components/DataTable/tree/useTreeData.d.ts +60 -0
- package/dist/types/components/DataTable/types.d.ts +272 -4
- package/dist/types/components/DataTable/useDataChangeTracker.d.ts +11 -4
- package/dist/types/components/DataTable/useTable.d.ts +13 -1
- package/dist/types/components/DataTable/virtual/useVirtualLines.d.ts +1 -0
- package/dist/types/components/EventCalendar/EventCalendar.d.ts +46 -0
- package/dist/types/components/EventCalendar/eventParts.d.ts +10 -0
- package/dist/types/components/EventCalendar/index.d.ts +3 -0
- package/dist/types/components/EventCalendar/useCalendarEdit.d.ts +40 -0
- package/dist/types/components/Icon/Icon.d.ts +36 -0
- package/dist/types/components/Icon/Icon.storyData.d.ts +6 -0
- package/dist/types/components/Icon/IconContext.d.ts +7 -0
- package/dist/types/components/Icon/icons.d.ts +223 -0
- package/dist/types/components/Icon/index.d.ts +7 -0
- package/dist/types/components/Icon/useIconDone.d.ts +5 -0
- package/dist/types/components/Popover/Popover.d.ts +1 -0
- package/dist/types/components/Popover/floatingPosition.d.ts +22 -2
- package/dist/types/components/ReorderList/ReorderList.d.ts +2 -1
- package/dist/types/components/Scroll/ui.d.ts +1 -0
- package/dist/types/components/SlidingHighlight/index.d.ts +2 -0
- package/dist/types/components/SlidingHighlight/useSlidingHighlight.d.ts +20 -0
- package/dist/types/components/Suggest/SuggestionList.d.ts +1 -0
- package/dist/types/components/UIProvider/UILabelsContext.d.ts +34 -0
- package/dist/types/components/UIProvider/UIProvider.d.ts +2 -0
- package/dist/types/core/hooks/index.d.ts +1 -1
- package/dist/types/core/hooks/usePresence.d.ts +1 -0
- package/dist/types/core/icons/actions.icons.d.ts +37 -0
- package/dist/types/core/icons/commerce.icons.d.ts +16 -0
- package/dist/types/core/icons/communication.icons.d.ts +10 -0
- package/dist/types/core/icons/delivery.icons.d.ts +13 -0
- package/dist/types/core/icons/devices.icons.d.ts +16 -0
- package/dist/types/core/icons/files.icons.d.ts +13 -0
- package/dist/types/core/icons/general.icons.d.ts +24 -0
- package/dist/types/core/icons/index.d.ts +14 -0
- package/dist/types/core/icons/media.icons.d.ts +11 -0
- package/dist/types/core/icons/navigation.icons.d.ts +25 -0
- package/dist/types/core/icons/people.icons.d.ts +13 -0
- package/dist/types/core/icons/registry.d.ts +2 -0
- package/dist/types/core/icons/state.icons.d.ts +14 -0
- package/dist/types/core/icons/status.icons.d.ts +10 -0
- package/dist/types/core/icons/table.icons.d.ts +22 -0
- package/dist/types/core/icons/text.icons.d.ts +13 -0
- package/dist/types/core/logic/cellRange.logic.d.ts +66 -0
- package/dist/types/core/logic/cellTouch.logic.d.ts +16 -0
- package/dist/types/core/logic/columnGroups.logic.d.ts +31 -0
- package/dist/types/core/logic/dropdownSide.logic.d.ts +19 -0
- package/dist/types/core/logic/eventCalendar.logic.d.ts +225 -0
- package/dist/types/core/logic/fitColumns.logic.d.ts +7 -0
- package/dist/types/core/logic/icon.logic.d.ts +24 -0
- package/dist/types/core/logic/index.d.ts +16 -0
- package/dist/types/core/logic/pivot.logic.d.ts +100 -0
- package/dist/types/core/logic/rowActions.logic.d.ts +7 -0
- package/dist/types/core/logic/rowDrag.logic.d.ts +36 -0
- package/dist/types/core/logic/rowPinning.logic.d.ts +12 -0
- package/dist/types/core/logic/slidingHighlight.logic.d.ts +20 -0
- package/dist/types/core/logic/toolbarOverflow.logic.d.ts +21 -0
- package/dist/types/core/logic/treeData.logic.d.ts +44 -0
- package/dist/types/core/logic/treeDrag.logic.d.ts +63 -0
- package/dist/types/core/logic/tween.logic.d.ts +33 -0
- package/dist/types/core/logic/visualViewport.logic.d.ts +13 -0
- package/dist/types/core/types/eventCalendar.types.d.ts +18 -0
- package/dist/types/core/types/fileEngine.types.d.ts +6 -0
- package/dist/types/core/types/icon.types.d.ts +109 -0
- package/dist/types/core/types/index.d.ts +2 -0
- package/dist/types/index.d.ts +7 -0
- package/package.json +4 -4
- package/dist/ChartImageMenu-3OfqNFyt.js +0 -1510
- package/dist/ChartView-n4G5_2ro.js +0 -1707
- package/dist/SummarySeeAll-BY8knsRe.js +0 -101
- package/dist/assets/fileTask.worker--Q3rI3Bn.js +0 -1
- package/dist/exportContext-C52ZuHd8.js +0 -166
- package/dist/scrollArea-D84Cwm4o.js +0 -310
|
@@ -0,0 +1,1942 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { $ as e, $n as t, B as n, C as r, Ct as i, D as a, E as o, F as s, Hn as c, In as l, J as u, Jn as d, K as f, M as p, N as m, O as h, P as g, Q as _, Qn as v, Rn as y, St as b, T as x, V as S, X as C, Xn as w, Y as T, Yn as E, Z as ee, Zn as D, _ as O, b as k, c as A, d as j, er as M, et as N, f as P, ft as F, g as I, gt as L, h as R, i as z, j as te, k as ne, l as B, m as V, nr as re, o as ie, p as H, q as U, qn as W, r as ae, s as oe, t as G, tr as se, tt as ce, u as le, ut as K, v as ue, w as de, x as fe, y as q, z as pe } from "./geometry-CFS5If1N.js";
|
|
3
|
+
import { useCallback as me, useEffect as J, useLayoutEffect as Y, useMemo as he, useReducer as ge, useRef as X, useState as _e, useSyncExternalStore as ve } from "react";
|
|
4
|
+
import { Fragment as ye, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as be } from "react-dom";
|
|
6
|
+
// src/core/logic/uiScale.logic.ts
|
|
7
|
+
function xe(e) {
|
|
8
|
+
let t = parseFloat(e ?? "");
|
|
9
|
+
return Number.isFinite(t) && t > 0 ? t : 1;
|
|
10
|
+
}
|
|
11
|
+
// src/components/Charts/useUiScale.ts
|
|
12
|
+
function Se() {
|
|
13
|
+
let [e, t] = _e(null), [n, r] = _e(1);
|
|
14
|
+
return Y(() => {
|
|
15
|
+
e && r(xe(getComputedStyle(e).getPropertyValue("--ui-scale")));
|
|
16
|
+
}), Y(() => {
|
|
17
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
18
|
+
let t = new ResizeObserver(() => r(xe(getComputedStyle(e).getPropertyValue("--ui-scale"))));
|
|
19
|
+
return t.observe(e), () => t.disconnect();
|
|
20
|
+
}, [e]), [me((e) => t(e), []), n];
|
|
21
|
+
}
|
|
22
|
+
// src/components/Charts/pointer.ts
|
|
23
|
+
function Ce(e, t, n) {
|
|
24
|
+
return n <= 0 || t <= 0 ? null : Math.max(0, Math.min(n - 1, Math.floor(e / t * n)));
|
|
25
|
+
}
|
|
26
|
+
function we(e, t) {
|
|
27
|
+
let n = null, r = Infinity;
|
|
28
|
+
return t.forEach((t, i) => {
|
|
29
|
+
let a = e < t.start ? t.start - e : e > t.end ? e - t.end : 0;
|
|
30
|
+
a < r && (n = i, r = a);
|
|
31
|
+
}), n;
|
|
32
|
+
}
|
|
33
|
+
function Te(e, t, n) {
|
|
34
|
+
let r = null, i = Infinity;
|
|
35
|
+
return n.forEach((n, a) => {
|
|
36
|
+
if (!n) return;
|
|
37
|
+
let o = e < n.left ? n.left - e : e > n.left + n.width ? e - n.left - n.width : 0, s = t < n.top ? n.top - t : t > n.top + n.height ? t - n.top - n.height : 0, c = o * o + s * s;
|
|
38
|
+
c < i && (r = a, i = c);
|
|
39
|
+
}), r;
|
|
40
|
+
}
|
|
41
|
+
function Ee(e, t) {
|
|
42
|
+
let n = Math.atan2(e, -t);
|
|
43
|
+
return n < 0 ? n + 2 * Math.PI : n;
|
|
44
|
+
}
|
|
45
|
+
var De = -1;
|
|
46
|
+
function Oe(e, t, n, r, i) {
|
|
47
|
+
let a = Math.hypot(e, t);
|
|
48
|
+
if (a > n || !i.length) return null;
|
|
49
|
+
if (a < r) return -1;
|
|
50
|
+
let o = Ee(e, t), s = 2 * Math.PI, c = (e, t) => ((t - e) % s + s) % s, l = 0, u = Infinity;
|
|
51
|
+
return i.forEach((e, t) => {
|
|
52
|
+
if (o >= e.a0 && o <= e.a1) {
|
|
53
|
+
l = t, u = -1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (u < 0) return;
|
|
57
|
+
let n = Math.min(c(o, e.a0), c(e.a1, o));
|
|
58
|
+
n < u && (l = t, u = n);
|
|
59
|
+
}), l;
|
|
60
|
+
}
|
|
61
|
+
var ke = {
|
|
62
|
+
x: 12,
|
|
63
|
+
y: 4
|
|
64
|
+
};
|
|
65
|
+
function Ae(e, t, n, r = ke, i = 8) {
|
|
66
|
+
let a = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n)), o = e.x + r.x, s = "right";
|
|
67
|
+
o + t.width > n.width - i && (o = e.x - r.x - t.width, s = "left");
|
|
68
|
+
let c = e.y + r.y, l = "below";
|
|
69
|
+
return c + t.height > n.height - i && (c = e.y - r.y - t.height, l = "above"), {
|
|
70
|
+
left: a(o, i, n.width - t.width - i),
|
|
71
|
+
top: a(c, i, n.height - t.height - i),
|
|
72
|
+
x: s,
|
|
73
|
+
y: l
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// src/components/Charts/ChartTooltip.tsx
|
|
77
|
+
var je = null, Me = 8, Ne = () => ({
|
|
78
|
+
width: document.documentElement.clientWidth || window.innerWidth,
|
|
79
|
+
height: document.documentElement.clientHeight || window.innerHeight
|
|
80
|
+
});
|
|
81
|
+
function Pe(e) {
|
|
82
|
+
let t = X(e);
|
|
83
|
+
t.current = e;
|
|
84
|
+
let [n] = _e(() => ({})), r = X(null), i = X(null), a = y(), [o, s] = _e(null), l = X(null), u = X(null), [d, f] = _e(null), p = !!e.onPick, m = (e) => e >= 0 && e < t.current.count && (t.current.focusable?.(e) ?? !0), h = me((e) => {
|
|
85
|
+
r.current = e;
|
|
86
|
+
}, []), g = me(() => {
|
|
87
|
+
l.current = null, s(null);
|
|
88
|
+
}, []), _ = me((e, t) => {
|
|
89
|
+
je && je.id !== n && je.clear(), je = {
|
|
90
|
+
id: n,
|
|
91
|
+
clear: g
|
|
92
|
+
}, s((n) => n && n.index === e && n.via === t ? n : {
|
|
93
|
+
index: e,
|
|
94
|
+
via: t
|
|
95
|
+
});
|
|
96
|
+
}, [n, g]);
|
|
97
|
+
J(() => () => {
|
|
98
|
+
je?.id === n && (je = null);
|
|
99
|
+
}, [n]);
|
|
100
|
+
let v = me(() => {
|
|
101
|
+
let e = i.current, n = r.current;
|
|
102
|
+
if (!e || !n || !o) return;
|
|
103
|
+
let a = {
|
|
104
|
+
width: e.offsetWidth,
|
|
105
|
+
height: e.offsetHeight
|
|
106
|
+
}, s;
|
|
107
|
+
if (l.current) s = Ae(l.current, a, Ne());
|
|
108
|
+
else {
|
|
109
|
+
let e = t.current.anchor?.(o.index, n) ?? Fe(n, o.index) ?? n.getBoundingClientRect();
|
|
110
|
+
s = c({
|
|
111
|
+
anchor: e,
|
|
112
|
+
tooltip: a,
|
|
113
|
+
viewport: Ne(),
|
|
114
|
+
placement: "top",
|
|
115
|
+
offset: 8,
|
|
116
|
+
margin: 8
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
let u = e.parentElement?.getBoundingClientRect() ?? {
|
|
120
|
+
left: 0,
|
|
121
|
+
top: 0
|
|
122
|
+
};
|
|
123
|
+
e.style.transform = `translate(${Math.round(s.left - u.left)}px, ${Math.round(s.top - u.top)}px)`, e.style.visibility = "visible";
|
|
124
|
+
}, [o]);
|
|
125
|
+
Y(v), J(() => {
|
|
126
|
+
if (o?.via !== "touch") return;
|
|
127
|
+
let e = (e) => {
|
|
128
|
+
r.current?.contains(e.target) || g();
|
|
129
|
+
};
|
|
130
|
+
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
131
|
+
}, [o?.via, g]);
|
|
132
|
+
let b = (e, n) => {
|
|
133
|
+
let i = r.current;
|
|
134
|
+
if (!i) return null;
|
|
135
|
+
let a = i.getBoundingClientRect();
|
|
136
|
+
return t.current.pick(e - a.left, n - a.top, a, i);
|
|
137
|
+
}, x = (e) => {
|
|
138
|
+
l.current = {
|
|
139
|
+
x: e.clientX,
|
|
140
|
+
y: e.clientY
|
|
141
|
+
};
|
|
142
|
+
let t = b(e.clientX, e.clientY);
|
|
143
|
+
if (t === null) return g();
|
|
144
|
+
_(t, e.pointerType === "touch" ? "touch" : "pointer"), v();
|
|
145
|
+
}, S = [
|
|
146
|
+
d,
|
|
147
|
+
o?.index ?? null,
|
|
148
|
+
e.start ?? null
|
|
149
|
+
].find((e) => e !== null && m(e)) ?? null;
|
|
150
|
+
for (let t = 0; t < e.count && S === null; t++) m(t) && (S = t);
|
|
151
|
+
let C = (e) => {
|
|
152
|
+
let t = e instanceof Element && e !== r.current ? e.closest("[data-hit]") : null;
|
|
153
|
+
return t && r.current?.contains(t) ? Number(t.getAttribute("data-hit")) : null;
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
active: o?.index ?? null,
|
|
157
|
+
pickable: p,
|
|
158
|
+
item: (e, t = {}) => p && m(e) ? {
|
|
159
|
+
"data-hit": e,
|
|
160
|
+
role: "button",
|
|
161
|
+
tabIndex: e === S ? 0 : -1,
|
|
162
|
+
"aria-pressed": t.disabled ? void 0 : !!t.pressed,
|
|
163
|
+
"aria-disabled": t.disabled ? !0 : void 0
|
|
164
|
+
} : { "data-hit": e },
|
|
165
|
+
plotProps: {
|
|
166
|
+
ref: h,
|
|
167
|
+
tabIndex: p ? void 0 : 0,
|
|
168
|
+
"data-chart-plot": "",
|
|
169
|
+
onPointerDown: (e) => {
|
|
170
|
+
e.pointerType === "touch" && (u.current = {
|
|
171
|
+
x: e.clientX,
|
|
172
|
+
y: e.clientY,
|
|
173
|
+
moved: !1
|
|
174
|
+
}, x(e));
|
|
175
|
+
},
|
|
176
|
+
onPointerMove: (e) => {
|
|
177
|
+
if (e.pointerType === "touch") {
|
|
178
|
+
if (!u.current) return;
|
|
179
|
+
Math.hypot(e.clientX - u.current.x, e.clientY - u.current.y) > Me && (u.current.moved = !0);
|
|
180
|
+
}
|
|
181
|
+
x(e);
|
|
182
|
+
},
|
|
183
|
+
onPointerUp: () => {
|
|
184
|
+
u.current && setTimeout(() => u.current = null, 0);
|
|
185
|
+
},
|
|
186
|
+
onPointerLeave: (e) => {
|
|
187
|
+
e.pointerType !== "touch" && g();
|
|
188
|
+
},
|
|
189
|
+
onClick: (e) => {
|
|
190
|
+
if (u.current?.moved) return;
|
|
191
|
+
let n = b(e.clientX, e.clientY);
|
|
192
|
+
n !== null && n >= 0 && t.current.onPick?.(n);
|
|
193
|
+
},
|
|
194
|
+
onKeyDown: (e) => {
|
|
195
|
+
let n = t.current, i = C(e.target);
|
|
196
|
+
if (n.onPick && i !== null && !m(i)) return;
|
|
197
|
+
let a = i ?? (o && o.index >= 0 ? o.index : null);
|
|
198
|
+
if ((e.key === "Enter" || e.key === " ") && a !== null && n.onPick) {
|
|
199
|
+
e.preventDefault(), n.onPick(a);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (e.key === "Escape") return o && e.stopPropagation(), g();
|
|
203
|
+
let s = o && o.index >= 0 ? o.index : n.start ?? null, c = N(e.key, s, n.count, n.keys, n.onPick ? m : void 0);
|
|
204
|
+
c !== null && (e.preventDefault(), l.current = null, _(c, "key"), n.onPick && r.current?.querySelector(`[data-hit="${c}"]`)?.focus());
|
|
205
|
+
},
|
|
206
|
+
onFocus: (e) => {
|
|
207
|
+
let t = C(e.target);
|
|
208
|
+
p && t !== null && (f(t), o?.index !== t && (l.current = null, _(t, "key")));
|
|
209
|
+
},
|
|
210
|
+
onBlur: (e) => {
|
|
211
|
+
e.relatedTarget instanceof Node && r.current?.contains(e.relatedTarget) || o?.via === "key" && g();
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
tooltip: (e) => {
|
|
215
|
+
if (!o || e == null || !a) return null;
|
|
216
|
+
let t = r.current?.closest("[data-theme]")?.getAttribute("data-theme") ?? void 0;
|
|
217
|
+
return be(/* @__PURE__ */ Z("div", {
|
|
218
|
+
className: "chart-tooltip-layer",
|
|
219
|
+
"data-theme": t,
|
|
220
|
+
children: /* @__PURE__ */ Z("div", {
|
|
221
|
+
ref: i,
|
|
222
|
+
className: "chart-root chart-tooltip",
|
|
223
|
+
role: "presentation",
|
|
224
|
+
"aria-hidden": !0,
|
|
225
|
+
style: { visibility: "hidden" },
|
|
226
|
+
children: e
|
|
227
|
+
})
|
|
228
|
+
}), a);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function Fe(e, t) {
|
|
233
|
+
let n = e.querySelector(`[data-hit="${t}"]`);
|
|
234
|
+
return n ? n.getBoundingClientRect() : null;
|
|
235
|
+
}
|
|
236
|
+
function Ie(e) {
|
|
237
|
+
let t = e.getBoundingClientRect(), n = [];
|
|
238
|
+
return e.querySelectorAll("[data-hit]").forEach((e) => {
|
|
239
|
+
let r = e.getBoundingClientRect();
|
|
240
|
+
n[Number(e.dataset.hit)] = {
|
|
241
|
+
left: r.left - t.left,
|
|
242
|
+
top: r.top - t.top,
|
|
243
|
+
width: r.width,
|
|
244
|
+
height: r.height
|
|
245
|
+
};
|
|
246
|
+
}), n;
|
|
247
|
+
}
|
|
248
|
+
function $({ title: e, rows: t = [], note: n }) {
|
|
249
|
+
return /* @__PURE__ */ Q(ye, { children: [
|
|
250
|
+
e != null && e !== "" && /* @__PURE__ */ Z("p", {
|
|
251
|
+
className: "chart-tooltip-title",
|
|
252
|
+
children: e
|
|
253
|
+
}),
|
|
254
|
+
t.map((e) => /* @__PURE__ */ Q("p", {
|
|
255
|
+
className: "chart-tooltip-series",
|
|
256
|
+
children: [
|
|
257
|
+
e.color && /* @__PURE__ */ Z("span", {
|
|
258
|
+
className: "chart-swatch chart-swatch--small",
|
|
259
|
+
style: { background: e.color }
|
|
260
|
+
}),
|
|
261
|
+
/* @__PURE__ */ Z("span", {
|
|
262
|
+
className: "chart-tooltip-label",
|
|
263
|
+
children: e.label
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ Z("strong", {
|
|
266
|
+
className: "chart-tooltip-value",
|
|
267
|
+
children: e.value
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
}, e.key)),
|
|
271
|
+
n != null && n !== "" && /* @__PURE__ */ Z("p", {
|
|
272
|
+
className: "chart-tooltip-note",
|
|
273
|
+
children: n
|
|
274
|
+
})
|
|
275
|
+
] });
|
|
276
|
+
}
|
|
277
|
+
// src/components/Charts/useChartMotion.ts
|
|
278
|
+
var Le = W.long, Re = "(prefers-reduced-motion: reduce)", ze = () => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia(Re) : null;
|
|
279
|
+
function Be(e) {
|
|
280
|
+
let t = ze();
|
|
281
|
+
return t?.addEventListener?.("change", e), () => t?.removeEventListener?.("change", e);
|
|
282
|
+
}
|
|
283
|
+
function Ve() {
|
|
284
|
+
return ve(Be, () => !!ze()?.matches, () => !1);
|
|
285
|
+
}
|
|
286
|
+
var He = () => typeof performance < "u" ? performance.now() : Date.now();
|
|
287
|
+
function Ue(e, { animate: n = !0, animationDuration: r = Le } = {}, i) {
|
|
288
|
+
let a = Ve(), o = n && !a && r > 0, [, s] = ge((e) => e + 1, 0), c = X(null);
|
|
289
|
+
c.current === null && (c.current = {
|
|
290
|
+
settled: e,
|
|
291
|
+
tween: null,
|
|
292
|
+
raf: 0
|
|
293
|
+
});
|
|
294
|
+
let l = c.current, u = He();
|
|
295
|
+
t(l.settled, e) || (l.tween = o ? v(l.tween, l.settled, e, u, r, void 0, i) : null, l.settled = e), o || (l.tween = null);
|
|
296
|
+
let d = l.tween ? M(l.tween, u) : e;
|
|
297
|
+
return J(() => {
|
|
298
|
+
if (!l.tween || l.raf || typeof requestAnimationFrame > "u") return;
|
|
299
|
+
let e = () => {
|
|
300
|
+
if (l.raf = 0, !l.tween) return;
|
|
301
|
+
let t = se(l.tween, He());
|
|
302
|
+
t && (l.tween = null), s(), t || (l.raf = requestAnimationFrame(e));
|
|
303
|
+
};
|
|
304
|
+
l.raf = requestAnimationFrame(e);
|
|
305
|
+
}), J(() => () => {
|
|
306
|
+
l.raf && cancelAnimationFrame(l.raf), l.raf = 0;
|
|
307
|
+
}, [l]), d;
|
|
308
|
+
}
|
|
309
|
+
// src/components/Charts/BarList.tsx
|
|
310
|
+
var We = (e, t) => `v:${q(e)}\u0000${t.key}`, Ge = (e) => `p:${q(e)}`;
|
|
311
|
+
function Ke({ href: e, className: t, title: n, children: r }) {
|
|
312
|
+
return /* @__PURE__ */ Z("a", {
|
|
313
|
+
href: e,
|
|
314
|
+
className: t,
|
|
315
|
+
title: n,
|
|
316
|
+
children: r
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
var qe = (e) => e < 1 ? { "--chart-bars-gap-share": e } : void 0;
|
|
320
|
+
function Je({ d: e, series: t, share: n, presence: r, gap: i, nf: a }) {
|
|
321
|
+
return /* @__PURE__ */ Q("div", {
|
|
322
|
+
className: "chart-bars-item chart-bars-item--moving",
|
|
323
|
+
style: {
|
|
324
|
+
...qe(i),
|
|
325
|
+
opacity: r
|
|
326
|
+
},
|
|
327
|
+
"aria-hidden": !0,
|
|
328
|
+
children: [
|
|
329
|
+
/* @__PURE__ */ Z("span", {
|
|
330
|
+
className: "chart-bars-label",
|
|
331
|
+
children: e.label
|
|
332
|
+
}),
|
|
333
|
+
/* @__PURE__ */ Z("span", {
|
|
334
|
+
className: "chart-bars-bar",
|
|
335
|
+
children: t.map((r) => {
|
|
336
|
+
let i = n(e, r);
|
|
337
|
+
return i > 0 ? /* @__PURE__ */ Z("span", {
|
|
338
|
+
className: "chart-bars-segment",
|
|
339
|
+
style: {
|
|
340
|
+
width: `${i * 100}%`,
|
|
341
|
+
background: K(t.length === 1 && e.slot ? e.slot : r.slot)
|
|
342
|
+
}
|
|
343
|
+
}, r.key) : null;
|
|
344
|
+
})
|
|
345
|
+
}),
|
|
346
|
+
/* @__PURE__ */ Z("span", {
|
|
347
|
+
className: "chart-bars-value",
|
|
348
|
+
children: a(k(e, t))
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function Ye({ data: e, series: t, ariaLabel: n, title: r, linkAs: i = Ke, compact: a = !1, onSelect: o, selected: c = null, animate: l, animationDuration: d, ...f }) {
|
|
354
|
+
let { nf: p, L: m } = ce(f), h = (t) => !!o && !e[t]?.href && e[t]?.selectable !== !1, g = Pe({
|
|
355
|
+
count: e.length,
|
|
356
|
+
pick: (e, t, n, r) => we(t, Ie(r).map((e) => e ? {
|
|
357
|
+
start: e.top,
|
|
358
|
+
end: e.top + e.height
|
|
359
|
+
} : {
|
|
360
|
+
start: Infinity,
|
|
361
|
+
end: Infinity
|
|
362
|
+
})),
|
|
363
|
+
keys: {
|
|
364
|
+
ArrowLeft: 0,
|
|
365
|
+
ArrowRight: 0
|
|
366
|
+
},
|
|
367
|
+
start: c === null ? null : e.findIndex((e) => q(e) === c),
|
|
368
|
+
onPick: o ? (t) => h(t) && o(e[t]) : void 0,
|
|
369
|
+
focusable: (t) => !e[t]?.href
|
|
370
|
+
}), v = e.map((e) => k(e, t)), y = le(v), b = {};
|
|
371
|
+
for (let n of e) {
|
|
372
|
+
b[Ge(n)] = 1;
|
|
373
|
+
for (let e of t) b[We(n, e)] = Math.max(0, n.values[e.key] ?? 0) / y;
|
|
374
|
+
}
|
|
375
|
+
let x = Ue(b, {
|
|
376
|
+
animate: l,
|
|
377
|
+
animationDuration: d
|
|
378
|
+
}), S = (e, t) => x[We(e, t)] ?? 0, T = X(e), E = re(e, T.current, q, (e) => (x[`p:${e}`] ?? 0) > 0);
|
|
379
|
+
if (J(() => {
|
|
380
|
+
T.current = E;
|
|
381
|
+
}), v.every((e) => e === 0)) return /* @__PURE__ */ Z(C, {
|
|
382
|
+
title: r,
|
|
383
|
+
children: /* @__PURE__ */ Z(U, {
|
|
384
|
+
ariaLabel: n,
|
|
385
|
+
text: m.empty,
|
|
386
|
+
compact: a
|
|
387
|
+
})
|
|
388
|
+
});
|
|
389
|
+
let D = v.reduce((e, t) => e + t, 0), O = g.active, A = O === null ? c : q(e[O]), j = O === null ? null : e[O], M = (e, t) => `${e.fullLabel ?? e.label}: ${p(v[t])}`, N = new Map(e.map((e, t) => [q(e), t])), P = E.map((e) => x[Ge(e)] ?? 0), F = w(P), I = P.some((e) => e < 1) ? P.map((e) => e < 1 ? `minmax(0, ${e}fr)` : "auto").join(" ") : void 0;
|
|
390
|
+
return /* @__PURE__ */ Q(C, {
|
|
391
|
+
title: r,
|
|
392
|
+
children: [
|
|
393
|
+
/* @__PURE__ */ Z("div", {
|
|
394
|
+
className: ee(`chart-bars chart-plot chart-plot--rows${o ? " chart-plot--pick" : ""}`, a),
|
|
395
|
+
role: o ? "group" : "img",
|
|
396
|
+
"aria-label": !o && j ? M(j, O) : n,
|
|
397
|
+
style: I ? { gridTemplateRows: I } : void 0,
|
|
398
|
+
...g.plotProps,
|
|
399
|
+
children: E.map((e, n) => {
|
|
400
|
+
let r = q(e), a = N.get(r) ?? -1;
|
|
401
|
+
if (a < 0) return /* @__PURE__ */ Z(Je, {
|
|
402
|
+
d: e,
|
|
403
|
+
series: t,
|
|
404
|
+
share: S,
|
|
405
|
+
presence: P[n],
|
|
406
|
+
gap: F[n],
|
|
407
|
+
nf: p
|
|
408
|
+
}, r);
|
|
409
|
+
let o = e.fullLabel ?? e.label, s = g.pickable && !e.href;
|
|
410
|
+
return /* @__PURE__ */ Q("div", {
|
|
411
|
+
...g.item(a, {
|
|
412
|
+
pressed: c === r,
|
|
413
|
+
disabled: !h(a)
|
|
414
|
+
}),
|
|
415
|
+
"aria-label": s ? `${e.label}: ${p(v[a])}` : void 0,
|
|
416
|
+
"aria-description": s && o !== e.label ? o : void 0,
|
|
417
|
+
className: `chart-bars-item${a === O ? " chart-bars-item--active" : ""}${c === r ? " chart-bars-item--on" : ""}${P[n] < 1 ? " chart-bars-item--moving" : ""}`,
|
|
418
|
+
style: {
|
|
419
|
+
...qe(F[n]),
|
|
420
|
+
opacity: P[n] < 1 ? P[n] : void 0
|
|
421
|
+
},
|
|
422
|
+
children: [
|
|
423
|
+
e.href ? /* @__PURE__ */ Z(i, {
|
|
424
|
+
href: e.href,
|
|
425
|
+
className: "chart-bars-label chart-bars-link",
|
|
426
|
+
title: o,
|
|
427
|
+
children: e.label
|
|
428
|
+
}) : /* @__PURE__ */ Z("span", {
|
|
429
|
+
className: "chart-bars-label",
|
|
430
|
+
title: o,
|
|
431
|
+
children: e.label
|
|
432
|
+
}),
|
|
433
|
+
" ",
|
|
434
|
+
/* @__PURE__ */ Z("span", {
|
|
435
|
+
className: `chart-bars-bar${A !== null && A !== r ? " chart-faded" : ""}`,
|
|
436
|
+
"aria-hidden": !0,
|
|
437
|
+
children: t.map((n, r) => {
|
|
438
|
+
let i = S(e, n);
|
|
439
|
+
if (!(i > 0)) return null;
|
|
440
|
+
let a = t.slice(r + 1).every((t) => !(S(e, t) > 0));
|
|
441
|
+
return /* @__PURE__ */ Z("span", {
|
|
442
|
+
className: `chart-bars-segment${a ? " chart-bars-segment--end" : ""}`,
|
|
443
|
+
style: {
|
|
444
|
+
width: `${i * 100}%`,
|
|
445
|
+
background: K(t.length === 1 && e.slot ? e.slot : n.slot)
|
|
446
|
+
}
|
|
447
|
+
}, n.key);
|
|
448
|
+
})
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ Z("span", {
|
|
451
|
+
className: "chart-bars-value",
|
|
452
|
+
children: p(v[a])
|
|
453
|
+
})
|
|
454
|
+
]
|
|
455
|
+
}, r);
|
|
456
|
+
})
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ Z(u, { text: j ? M(j, O) : "" }),
|
|
459
|
+
g.tooltip(j && /* @__PURE__ */ Z($, {
|
|
460
|
+
title: j.fullLabel ?? j.label,
|
|
461
|
+
rows: t.map((e) => ({
|
|
462
|
+
key: e.key,
|
|
463
|
+
color: K(t.length === 1 && j.slot ? j.slot : e.slot),
|
|
464
|
+
label: e.label,
|
|
465
|
+
value: p(j.values[e.key] ?? 0)
|
|
466
|
+
})),
|
|
467
|
+
note: m.shareOf(_(s(v[O], D)), p(D))
|
|
468
|
+
}))
|
|
469
|
+
]
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
// src/components/Charts/useBoxSize.ts
|
|
473
|
+
function Xe() {
|
|
474
|
+
let [e, t] = _e(null), [n, r] = _e({
|
|
475
|
+
width: 0,
|
|
476
|
+
height: 0
|
|
477
|
+
});
|
|
478
|
+
return Y(() => {
|
|
479
|
+
if (!e) return;
|
|
480
|
+
let t = () => {
|
|
481
|
+
let t = e.getBoundingClientRect();
|
|
482
|
+
r((e) => e.width === Math.round(t.width) && e.height === Math.round(t.height) ? e : {
|
|
483
|
+
width: Math.round(t.width),
|
|
484
|
+
height: Math.round(t.height)
|
|
485
|
+
});
|
|
486
|
+
};
|
|
487
|
+
if (t(), typeof ResizeObserver > "u") return;
|
|
488
|
+
let n = new ResizeObserver(t);
|
|
489
|
+
return n.observe(e), () => n.disconnect();
|
|
490
|
+
}, [e]), [me((e) => t(e), []), n];
|
|
491
|
+
}
|
|
492
|
+
function Ze() {
|
|
493
|
+
let [e, t] = Xe();
|
|
494
|
+
return [e, t.width];
|
|
495
|
+
}
|
|
496
|
+
// src/components/Charts/CalendarHeatmap.tsx
|
|
497
|
+
function Qe(e) {
|
|
498
|
+
let t = Math.floor(e), n = e - t;
|
|
499
|
+
return n < .005 ? F(t) : n > .995 ? F(t + 1) : `color-mix(in oklab, ${F(t)}, ${F(t + 1)} ${Math.round(n * 100)}%)`;
|
|
500
|
+
}
|
|
501
|
+
function $e(e) {
|
|
502
|
+
let t = (t) => {
|
|
503
|
+
try {
|
|
504
|
+
return new Intl.DateTimeFormat(e, {
|
|
505
|
+
...t,
|
|
506
|
+
timeZone: "UTC"
|
|
507
|
+
});
|
|
508
|
+
} catch {
|
|
509
|
+
return new Intl.DateTimeFormat(void 0, {
|
|
510
|
+
...t,
|
|
511
|
+
timeZone: "UTC"
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
return {
|
|
516
|
+
day: t({ dateStyle: "medium" }),
|
|
517
|
+
month: t({ month: "short" }),
|
|
518
|
+
weekday: t({ weekday: "short" })
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
var et = (e) => Array.from({ length: 7 }, (t, n) => $e(e).weekday.format(Date.UTC(2024, 0, 1 + n)));
|
|
522
|
+
function tt({ days: e, ariaLabel: t, title: n, onSelect: r, selected: i = null, compact: a = !1, animate: o, animationDuration: s, ...c }) {
|
|
523
|
+
let { nf: d, L: f } = ce(c), p = l().locale, m = c.locale ?? p, h = he(() => $e(m), [m]), g = he(() => et(m), [m]), _ = he(() => P(e), [e]), v = Ue(he(() => {
|
|
524
|
+
let e = {};
|
|
525
|
+
for (let t of _.cells) e[t.day] = t.level;
|
|
526
|
+
return e;
|
|
527
|
+
}, [_]), {
|
|
528
|
+
animate: o,
|
|
529
|
+
animationDuration: s
|
|
530
|
+
}), [y, b] = Ze(), [x, S] = Se(), w = j(b, _.weeks, a ? G.compactMax : G.max, S), T = w.cell + w.gap, E = w.weekdays ? R(S) : 0, D = i === null ? -1 : _.cells.findIndex((e) => e.day === i), O = Pe({
|
|
531
|
+
count: _.cells.length,
|
|
532
|
+
pick: (e, t) => Te(e, t, _.cells.map((e) => ({
|
|
533
|
+
left: E + e.week * T,
|
|
534
|
+
top: e.weekday * T,
|
|
535
|
+
width: w.cell,
|
|
536
|
+
height: w.cell
|
|
537
|
+
}))),
|
|
538
|
+
keys: {
|
|
539
|
+
ArrowLeft: -7,
|
|
540
|
+
ArrowRight: 7,
|
|
541
|
+
ArrowUp: -1,
|
|
542
|
+
ArrowDown: 1
|
|
543
|
+
},
|
|
544
|
+
start: D >= 0 ? D : null,
|
|
545
|
+
onPick: r ? (e) => r({
|
|
546
|
+
day: _.cells[e].day,
|
|
547
|
+
count: _.cells[e].count
|
|
548
|
+
}) : void 0
|
|
549
|
+
});
|
|
550
|
+
if (!_.cells.length || _.total === 0) return /* @__PURE__ */ Z(C, {
|
|
551
|
+
title: n,
|
|
552
|
+
children: /* @__PURE__ */ Z(U, {
|
|
553
|
+
ariaLabel: t,
|
|
554
|
+
text: f.empty,
|
|
555
|
+
compact: a
|
|
556
|
+
})
|
|
557
|
+
});
|
|
558
|
+
let k = (e) => `${h.day.format(fe(e.day))}: ${d(e.count)}`, A = O.active, M = A === null ? null : _.cells[A] ?? null, N = `${w.weekdays ? `${E}px ` : ""}repeat(${_.weeks}, ${w.cell}px)`, I = w.weekdays ? 2 : 1;
|
|
559
|
+
return /* @__PURE__ */ Z(C, {
|
|
560
|
+
title: n,
|
|
561
|
+
children: /* @__PURE__ */ Q("div", {
|
|
562
|
+
ref: y,
|
|
563
|
+
className: ee("chart-calendar", a),
|
|
564
|
+
role: "group",
|
|
565
|
+
"aria-label": `${t}: ${f.total} ${d(_.total)}`,
|
|
566
|
+
children: [
|
|
567
|
+
/* @__PURE__ */ Z("div", {
|
|
568
|
+
ref: x,
|
|
569
|
+
className: "chart-calendar-months",
|
|
570
|
+
style: {
|
|
571
|
+
gridTemplateColumns: N,
|
|
572
|
+
columnGap: w.gap
|
|
573
|
+
},
|
|
574
|
+
"aria-hidden": !0,
|
|
575
|
+
children: H(_.months, T, S).map((e) => /* @__PURE__ */ Z("span", {
|
|
576
|
+
style: {
|
|
577
|
+
gridRow: 1,
|
|
578
|
+
gridColumn: `${e.week + I} / span ${Math.max(1, Math.ceil(V(S) / T))}`
|
|
579
|
+
},
|
|
580
|
+
children: h.month.format(fe(`${e.month}-01`))
|
|
581
|
+
}, e.month))
|
|
582
|
+
}),
|
|
583
|
+
/* @__PURE__ */ Q("div", {
|
|
584
|
+
className: `chart-calendar-grid chart-plot${r ? " chart-plot--pick" : ""}`,
|
|
585
|
+
style: {
|
|
586
|
+
gridTemplateColumns: N,
|
|
587
|
+
gridTemplateRows: `repeat(7, ${w.cell}px)`,
|
|
588
|
+
gap: w.gap
|
|
589
|
+
},
|
|
590
|
+
role: r ? void 0 : "img",
|
|
591
|
+
"aria-label": r ? void 0 : M ? k(M) : t,
|
|
592
|
+
...O.plotProps,
|
|
593
|
+
children: [w.weekdays && g.map((e, t) => /* @__PURE__ */ Z("span", {
|
|
594
|
+
className: "chart-calendar-weekday",
|
|
595
|
+
style: {
|
|
596
|
+
gridRow: t + 1,
|
|
597
|
+
gridColumn: 1
|
|
598
|
+
},
|
|
599
|
+
"aria-hidden": !0,
|
|
600
|
+
children: t % 2 == 0 ? e : ""
|
|
601
|
+
}, e)), _.cells.map((e, t) => /* @__PURE__ */ Z("span", {
|
|
602
|
+
...O.item(t, { pressed: t === D }),
|
|
603
|
+
"aria-label": O.pickable ? k(e) : void 0,
|
|
604
|
+
className: `chart-calendar-day${t === D ? " chart-calendar-day--on" : ""}${t === A ? " chart-calendar-day--active" : ""}${D >= 0 && t !== D ? " chart-calendar-day--faded" : ""}`,
|
|
605
|
+
style: {
|
|
606
|
+
gridRow: e.weekday + 1,
|
|
607
|
+
gridColumn: e.week + I,
|
|
608
|
+
background: Qe(v[e.day] ?? e.level),
|
|
609
|
+
borderRadius: w.cell < 8 ? 1 : 2
|
|
610
|
+
},
|
|
611
|
+
"data-level": e.level,
|
|
612
|
+
"aria-hidden": !O.pickable || void 0
|
|
613
|
+
}, e.day))]
|
|
614
|
+
}),
|
|
615
|
+
/* @__PURE__ */ Q("div", {
|
|
616
|
+
className: "chart-calendar-legend",
|
|
617
|
+
"aria-hidden": !0,
|
|
618
|
+
children: [
|
|
619
|
+
/* @__PURE__ */ Z("span", { children: f.less }),
|
|
620
|
+
Array.from({ length: 5 }, (e, t) => /* @__PURE__ */ Z("span", {
|
|
621
|
+
className: "chart-calendar-swatch",
|
|
622
|
+
style: { background: F(t) }
|
|
623
|
+
}, t)),
|
|
624
|
+
/* @__PURE__ */ Z("span", { children: f.more })
|
|
625
|
+
]
|
|
626
|
+
}),
|
|
627
|
+
/* @__PURE__ */ Z(u, { text: M ? k(M) : "" }),
|
|
628
|
+
O.tooltip(M && /* @__PURE__ */ Z($, {
|
|
629
|
+
title: h.day.format(fe(M.day)),
|
|
630
|
+
rows: [{
|
|
631
|
+
key: "n",
|
|
632
|
+
color: F(Math.max(1, M.level)),
|
|
633
|
+
label: t,
|
|
634
|
+
value: d(M.count)
|
|
635
|
+
}]
|
|
636
|
+
}))
|
|
637
|
+
]
|
|
638
|
+
})
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
// src/components/Charts/Legend.tsx
|
|
642
|
+
function nt({ series: e, labels: t }) {
|
|
643
|
+
let { L: n } = ce({ labels: t });
|
|
644
|
+
return e.length < 2 ? null : /* @__PURE__ */ Z("ul", {
|
|
645
|
+
className: ee("chart-legend"),
|
|
646
|
+
"aria-label": n.legend,
|
|
647
|
+
children: e.map((e) => /* @__PURE__ */ Q("li", {
|
|
648
|
+
className: "chart-legend-item",
|
|
649
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
650
|
+
className: "chart-swatch",
|
|
651
|
+
style: { background: K(e.slot) },
|
|
652
|
+
"aria-hidden": !0
|
|
653
|
+
}), e.label]
|
|
654
|
+
}, e.key))
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
// src/components/Charts/ColumnChart.tsx
|
|
658
|
+
var rt = 6, it = 2, at = 6, ot = 44, st = (e, t) => `v:${q(e)}\u0000${t.key}`, ct = (e) => `p:${q(e)}`;
|
|
659
|
+
function lt({ data: e, series: t, ariaLabel: n, title: r, height: i, compact: a = !1, mode: o = "stacked", legend: s = !1, onSelect: c, selected: l = null, animate: p, animationDuration: m, ...g }) {
|
|
660
|
+
let { nf: _, L: v } = ce(g), [y, b] = Ze(), [x, S] = Se(), D = e.length, A = (t) => !!c && e[t]?.selectable !== !1, j = Pe({
|
|
661
|
+
count: D,
|
|
662
|
+
pick: (e, t, n) => Ce(e, n.width, D),
|
|
663
|
+
anchor: (e, t) => {
|
|
664
|
+
let n = t.getBoundingClientRect();
|
|
665
|
+
return {
|
|
666
|
+
left: n.left + n.width * e / D,
|
|
667
|
+
top: n.top,
|
|
668
|
+
width: n.width / D,
|
|
669
|
+
height: n.height
|
|
670
|
+
};
|
|
671
|
+
},
|
|
672
|
+
keys: {
|
|
673
|
+
ArrowUp: 0,
|
|
674
|
+
ArrowDown: 0
|
|
675
|
+
},
|
|
676
|
+
start: l === null ? null : e.findIndex((e) => q(e) === l),
|
|
677
|
+
onPick: c ? (t) => A(t) && c(e[t]) : void 0
|
|
678
|
+
}), M = e.map((e) => k(e, t)), N = o === "grouped" && t.length > 1, { max: P, ticks: F } = O(ue(e, t, N ? "grouped" : "stacked")), I = { scale: P };
|
|
679
|
+
if (!a) for (let e of F) I[`t:${e}`] = 1;
|
|
680
|
+
for (let n of e) {
|
|
681
|
+
I[ct(n)] = 1;
|
|
682
|
+
for (let e of t) I[st(n, e)] = Math.max(0, n.values[e.key] ?? 0);
|
|
683
|
+
}
|
|
684
|
+
let L = Ue(I, {
|
|
685
|
+
animate: p,
|
|
686
|
+
animationDuration: m
|
|
687
|
+
}), R = L.scale ?? P, z = (e, t) => (L[st(e, t)] ?? 0) / R, te = X(e), ne = re(e, te.current, q, (e) => (L[`p:${e}`] ?? 0) > 0);
|
|
688
|
+
if (J(() => {
|
|
689
|
+
te.current = ne;
|
|
690
|
+
}), M.every((e) => e === 0)) return /* @__PURE__ */ Z(C, {
|
|
691
|
+
title: r,
|
|
692
|
+
children: /* @__PURE__ */ Z(U, {
|
|
693
|
+
ariaLabel: n,
|
|
694
|
+
text: v.empty,
|
|
695
|
+
compact: a
|
|
696
|
+
})
|
|
697
|
+
});
|
|
698
|
+
let V = (i ?? (a ? 96 : 220)) * S, ie = N ? h(t.length, 100, rt) : [], H = j.active, W = (H === null ? null : q(e[H])) ?? l, ae = b && b / Math.max(1, D) < at ? 0 : it, oe = new Map(e.map((e, t) => [q(e), t])), G = ne.map((e) => L[ct(e)] ?? 0), se = E(G), le = w(G), de = (e) => ({
|
|
699
|
+
flexGrow: se[e].size,
|
|
700
|
+
marginLeft: le[e] * ae || void 0
|
|
701
|
+
}), fe = d(L, "t:"), pe = new Set(B(D, Math.max(2, Math.min(12, Math.floor((b || 600) / (ot * S)))))), me = (e, n) => `${e.fullLabel ?? e.label}: ${t.length > 1 ? t.map((t) => `${t.label} ${_(e.values[t.key] ?? 0)}`).join(", ") : _(M[n])}`, Y = H === null ? null : e[H];
|
|
702
|
+
return /* @__PURE__ */ Z(C, {
|
|
703
|
+
title: r,
|
|
704
|
+
children: /* @__PURE__ */ Q("div", {
|
|
705
|
+
ref: y,
|
|
706
|
+
className: ee(`chart-columns${N ? " chart-columns--grouped" : ""}`, a),
|
|
707
|
+
role: "group",
|
|
708
|
+
"aria-label": n,
|
|
709
|
+
children: [
|
|
710
|
+
/* @__PURE__ */ Q("div", {
|
|
711
|
+
className: "chart-columns-plot",
|
|
712
|
+
style: { height: V },
|
|
713
|
+
children: [!a && /* @__PURE__ */ Z(f, {
|
|
714
|
+
ticks: fe,
|
|
715
|
+
max: R,
|
|
716
|
+
plot: V,
|
|
717
|
+
nf: _
|
|
718
|
+
}), /* @__PURE__ */ Q("div", {
|
|
719
|
+
className: `chart-columns-area chart-plot chart-plot--x${c ? " chart-plot--pick" : ""}`,
|
|
720
|
+
role: c ? void 0 : "img",
|
|
721
|
+
"aria-label": c ? void 0 : Y ? me(Y, H) : n,
|
|
722
|
+
...j.plotProps,
|
|
723
|
+
children: [!a && /* @__PURE__ */ Z(T, {
|
|
724
|
+
ticks: fe,
|
|
725
|
+
max: R
|
|
726
|
+
}), /* @__PURE__ */ Z("div", {
|
|
727
|
+
className: "chart-columns-bars",
|
|
728
|
+
"aria-hidden": !j.pickable || void 0,
|
|
729
|
+
children: ne.map((e, n) => {
|
|
730
|
+
let r = q(e), i = oe.get(r) ?? -1, a = W !== null && W !== r ? " chart-faded" : "";
|
|
731
|
+
return /* @__PURE__ */ Z("div", {
|
|
732
|
+
...i >= 0 ? j.item(i, {
|
|
733
|
+
pressed: l === r,
|
|
734
|
+
disabled: !A(i)
|
|
735
|
+
}) : { "aria-hidden": !0 },
|
|
736
|
+
"aria-label": j.pickable && i >= 0 ? me(e, i) : void 0,
|
|
737
|
+
className: `chart-column${i >= 0 && i === H ? " chart-column--active" : ""}${l === r ? " chart-column--on" : ""}`,
|
|
738
|
+
style: de(n),
|
|
739
|
+
children: N ? /* @__PURE__ */ Z("span", {
|
|
740
|
+
className: `chart-column-group${a}`,
|
|
741
|
+
children: t.map((t, n) => /* @__PURE__ */ Z("span", {
|
|
742
|
+
className: "chart-column-segment chart-column-segment--top chart-column-bar",
|
|
743
|
+
style: {
|
|
744
|
+
left: `${ie[n].x}%`,
|
|
745
|
+
width: `${ie[n].width}%`,
|
|
746
|
+
height: `${z(e, t) * V}px`,
|
|
747
|
+
background: K(t.slot)
|
|
748
|
+
}
|
|
749
|
+
}, t.key))
|
|
750
|
+
}) : /* @__PURE__ */ Z("span", {
|
|
751
|
+
className: `chart-column-stack${a}`,
|
|
752
|
+
children: t.map((n, r) => {
|
|
753
|
+
let i = z(e, n);
|
|
754
|
+
if (!(i > 0)) return null;
|
|
755
|
+
let a = t.slice(r + 1).every((t) => !(z(e, t) > 0));
|
|
756
|
+
return /* @__PURE__ */ Z("span", {
|
|
757
|
+
className: `chart-column-segment${a ? " chart-column-segment--top" : ""}`,
|
|
758
|
+
style: {
|
|
759
|
+
height: `${i * V}px`,
|
|
760
|
+
background: K(n.slot)
|
|
761
|
+
}
|
|
762
|
+
}, n.key);
|
|
763
|
+
})
|
|
764
|
+
})
|
|
765
|
+
}, r);
|
|
766
|
+
})
|
|
767
|
+
})]
|
|
768
|
+
})]
|
|
769
|
+
}),
|
|
770
|
+
/* @__PURE__ */ Z("div", {
|
|
771
|
+
ref: x,
|
|
772
|
+
className: `chart-axis-x${a ? " chart-axis-x--compact" : ""}`,
|
|
773
|
+
"aria-hidden": !0,
|
|
774
|
+
children: ne.map((e, t) => {
|
|
775
|
+
let n = q(e), r = oe.get(n) ?? -1;
|
|
776
|
+
return /* @__PURE__ */ Z("span", {
|
|
777
|
+
className: l !== null && l !== n ? "chart-faded" : void 0,
|
|
778
|
+
style: {
|
|
779
|
+
...de(t),
|
|
780
|
+
opacity: G[t] < 1 ? G[t] : void 0
|
|
781
|
+
},
|
|
782
|
+
children: r >= 0 && pe.has(r) ? e.label : ""
|
|
783
|
+
}, n);
|
|
784
|
+
})
|
|
785
|
+
}),
|
|
786
|
+
s && /* @__PURE__ */ Z("div", {
|
|
787
|
+
className: "chart-columns-legend",
|
|
788
|
+
children: /* @__PURE__ */ Z(nt, {
|
|
789
|
+
series: t,
|
|
790
|
+
labels: g.labels
|
|
791
|
+
})
|
|
792
|
+
}),
|
|
793
|
+
/* @__PURE__ */ Z(u, { text: Y ? me(Y, H) : "" }),
|
|
794
|
+
j.tooltip(Y && /* @__PURE__ */ Z($, {
|
|
795
|
+
title: Y.fullLabel ?? Y.label,
|
|
796
|
+
rows: t.map((e) => ({
|
|
797
|
+
key: e.key,
|
|
798
|
+
color: K(e.slot),
|
|
799
|
+
label: e.label,
|
|
800
|
+
value: _(Y.values[e.key] ?? 0)
|
|
801
|
+
})),
|
|
802
|
+
note: t.length > 1 ? `${v.total}: ${_(M[H])}` : void 0
|
|
803
|
+
}))
|
|
804
|
+
]
|
|
805
|
+
})
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
// src/components/Charts/useLegendFit.ts
|
|
809
|
+
function ut(e, t) {
|
|
810
|
+
let [n, r] = _e(null), [i, a] = _e(e), [o, s] = _e(e);
|
|
811
|
+
return Y(() => {
|
|
812
|
+
if (!t || !n) {
|
|
813
|
+
a(e), s(e);
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
let r = 0, i = () => {
|
|
817
|
+
let t = n.clientHeight, r = Array.from(n.children).filter((e) => !e.hasAttribute("data-legend-more")), i = e;
|
|
818
|
+
if (t && r.length >= e) {
|
|
819
|
+
let a = n.getBoundingClientRect().top, o = r.filter((e) => e.getBoundingClientRect().bottom - a <= t + .5).length;
|
|
820
|
+
i = o >= e ? e : Math.max(0, o - 1);
|
|
821
|
+
}
|
|
822
|
+
a(i), s(i);
|
|
823
|
+
}, o = () => {
|
|
824
|
+
cancelAnimationFrame(r), a(e), r = requestAnimationFrame(i);
|
|
825
|
+
};
|
|
826
|
+
if (o(), typeof ResizeObserver > "u") return () => cancelAnimationFrame(r);
|
|
827
|
+
let c = n.parentElement ?? n, l = c.clientWidth, u = new ResizeObserver(() => {
|
|
828
|
+
c.clientWidth !== l && (l = c.clientWidth, o());
|
|
829
|
+
});
|
|
830
|
+
return u.observe(c), () => {
|
|
831
|
+
cancelAnimationFrame(r), u.disconnect();
|
|
832
|
+
};
|
|
833
|
+
}, [
|
|
834
|
+
n,
|
|
835
|
+
e,
|
|
836
|
+
t
|
|
837
|
+
]), [
|
|
838
|
+
me((e) => r(e), []),
|
|
839
|
+
t ? i : e,
|
|
840
|
+
t ? o : e
|
|
841
|
+
];
|
|
842
|
+
}
|
|
843
|
+
// src/components/Charts/Donut.tsx
|
|
844
|
+
var dt = 2.5;
|
|
845
|
+
function ft({ slices: e, ariaLabel: t, title: n, size: r, compact: i = !1, variant: a = "donut", onLegendCut: o, legend: c = !0, onSelect: l, selected: d = null, animate: f, animationDuration: m, ...h }) {
|
|
846
|
+
let { nf: v, L: y } = ce(h), [C, w] = _e(null), [T, E, D] = ut(e.length, i);
|
|
847
|
+
J(() => o?.(e.length - D), [
|
|
848
|
+
o,
|
|
849
|
+
e.length,
|
|
850
|
+
D
|
|
851
|
+
]);
|
|
852
|
+
let [O, k] = Se(), A = (r ?? (i ? 112 : 168)) * k, j = e.reduce((e, t) => e + t.value, 0), M = x(e), N = a === "pie", P = N ? p(e).map((e) => ({
|
|
853
|
+
slice: e.slice,
|
|
854
|
+
a0: e.a0,
|
|
855
|
+
a1: e.a1
|
|
856
|
+
})) : de(e).map((e) => ({
|
|
857
|
+
slice: e.slice,
|
|
858
|
+
a0: e.start / ae * 2 * Math.PI,
|
|
859
|
+
a1: (e.start + e.length) / ae * 2 * Math.PI
|
|
860
|
+
})), F = (t) => !!l && e[t].value > 0 && e[t].selectable !== !1, I = Pe({
|
|
861
|
+
count: e.length,
|
|
862
|
+
pick: (t, n, r) => {
|
|
863
|
+
let i = r.width / 100, a = 48 * i, o = N ? 0 : 32 * i, s = Oe(t - r.width / 2, n - r.height / 2, a, o, P);
|
|
864
|
+
return s === null || s === -1 ? s : e.indexOf(P[s].slice);
|
|
865
|
+
},
|
|
866
|
+
anchor: (t, n) => {
|
|
867
|
+
let r = n.getBoundingClientRect(), i = P.find((n) => n.slice === e[t]), a = i ? g(r.left + r.width / 2, r.top + r.height / 2, r.width / 100 * (N ? 36 : 40), (i.a0 + i.a1) / 2) : {
|
|
868
|
+
x: r.left + r.width / 2,
|
|
869
|
+
y: r.top + r.height / 2
|
|
870
|
+
};
|
|
871
|
+
return {
|
|
872
|
+
left: a.x - 1,
|
|
873
|
+
top: a.y - 1,
|
|
874
|
+
width: 2,
|
|
875
|
+
height: 2
|
|
876
|
+
};
|
|
877
|
+
},
|
|
878
|
+
start: d === null ? null : e.findIndex((e) => e.key === d),
|
|
879
|
+
onPick: l ? (t) => F(t) && l(e[t]) : void 0,
|
|
880
|
+
focusable: (t) => e[t].value > 0
|
|
881
|
+
}), L = {};
|
|
882
|
+
for (let t of e) L[t.key] = t.value;
|
|
883
|
+
let R = Ue(L, {
|
|
884
|
+
animate: f,
|
|
885
|
+
animationDuration: m
|
|
886
|
+
}), z = X(e), te = re(e, z.current, (e) => e.key, (e) => (R[e] ?? 0) > 0).map((e) => ({
|
|
887
|
+
...e,
|
|
888
|
+
value: R[e.key] ?? 0
|
|
889
|
+
}));
|
|
890
|
+
J(() => {
|
|
891
|
+
z.current = te;
|
|
892
|
+
});
|
|
893
|
+
let ne = x(te), B = (t) => {
|
|
894
|
+
let n = e.findIndex((e) => e.key === t.key);
|
|
895
|
+
return n < 0 ? { "aria-hidden": !0 } : {
|
|
896
|
+
...I.item(n, {
|
|
897
|
+
pressed: d === t.key,
|
|
898
|
+
disabled: !F(n)
|
|
899
|
+
}),
|
|
900
|
+
"aria-label": I.pickable ? ie(e[n]) : void 0
|
|
901
|
+
};
|
|
902
|
+
}, V = (e) => s(Math.max(0, e), M), ie = (e) => `${e.label} ${v(e.value)} (${_(V(e.value))})`, H = I.active === -1, U = I.active !== null && I.active >= 0 ? e[I.active] : void 0, W = U?.key ?? C ?? d, oe = e.find((e) => e.key === W) ?? e[0], G = (e) => W !== null && W !== e ? .55 : 1, se = N ? p(ne > 0 ? te : e) : [];
|
|
903
|
+
return /* @__PURE__ */ Q("figure", {
|
|
904
|
+
ref: O,
|
|
905
|
+
className: ee(N ? "chart-donut chart-pie" : "chart-donut", i),
|
|
906
|
+
"aria-label": t,
|
|
907
|
+
children: [
|
|
908
|
+
n && /* @__PURE__ */ Z("figcaption", {
|
|
909
|
+
className: "chart-donut-title",
|
|
910
|
+
children: n
|
|
911
|
+
}),
|
|
912
|
+
/* @__PURE__ */ Q("div", {
|
|
913
|
+
className: `chart-donut-ring chart-plot${l ? " chart-plot--pick" : ""}`,
|
|
914
|
+
style: {
|
|
915
|
+
width: A,
|
|
916
|
+
height: A
|
|
917
|
+
},
|
|
918
|
+
role: l ? void 0 : "img",
|
|
919
|
+
"aria-label": l ? void 0 : U ? ie(U) : `${t}: ${e.map(ie).join(", ")}`,
|
|
920
|
+
...I.plotProps,
|
|
921
|
+
children: [/* @__PURE__ */ Z("svg", {
|
|
922
|
+
viewBox: "0 0 100 100",
|
|
923
|
+
width: A,
|
|
924
|
+
height: A,
|
|
925
|
+
className: "chart-donut-svg",
|
|
926
|
+
overflow: "visible",
|
|
927
|
+
"aria-hidden": !I.pickable || void 0,
|
|
928
|
+
children: N ? M === 0 ? /* @__PURE__ */ Z("circle", {
|
|
929
|
+
cx: "50",
|
|
930
|
+
cy: "50",
|
|
931
|
+
r: 48,
|
|
932
|
+
fill: K("rest"),
|
|
933
|
+
opacity: .5,
|
|
934
|
+
"aria-hidden": !0
|
|
935
|
+
}) : se.map((t) => {
|
|
936
|
+
let n = t.slice, r = e.find((e) => e.key === n.key), i = r ? V(r.value) : 0, a = W === n.key && se.length > 1 ? g(0, 0, dt, (t.a0 + t.a1) / 2) : null;
|
|
937
|
+
return /* @__PURE__ */ Q("g", {
|
|
938
|
+
transform: a ? `translate(${a.x} ${a.y})` : void 0,
|
|
939
|
+
opacity: G(n.key),
|
|
940
|
+
className: "chart-pie-slice-group",
|
|
941
|
+
children: [/* @__PURE__ */ Z("path", {
|
|
942
|
+
...B(n),
|
|
943
|
+
d: S(50, 50, 48, t.a0, t.a1),
|
|
944
|
+
fill: K(n.slot),
|
|
945
|
+
stroke: "var(--chart-surface)",
|
|
946
|
+
strokeWidth: +(se.length > 1),
|
|
947
|
+
strokeLinejoin: "round",
|
|
948
|
+
className: "chart-donut-slice chart-pie-slice"
|
|
949
|
+
}), t.label && i >= 8 && /* @__PURE__ */ Z("text", {
|
|
950
|
+
x: t.label.x,
|
|
951
|
+
y: t.label.y,
|
|
952
|
+
className: "chart-pie-share",
|
|
953
|
+
fill: b(n.slot),
|
|
954
|
+
textAnchor: "middle",
|
|
955
|
+
dominantBaseline: "central",
|
|
956
|
+
"aria-hidden": !0,
|
|
957
|
+
children: _(i)
|
|
958
|
+
})]
|
|
959
|
+
}, n.key);
|
|
960
|
+
}) : /* @__PURE__ */ Z("g", {
|
|
961
|
+
transform: "rotate(-90 50 50)",
|
|
962
|
+
children: M === 0 ? /* @__PURE__ */ Z("circle", {
|
|
963
|
+
cx: "50",
|
|
964
|
+
cy: "50",
|
|
965
|
+
r: 40,
|
|
966
|
+
fill: "none",
|
|
967
|
+
stroke: K("rest"),
|
|
968
|
+
strokeWidth: 16,
|
|
969
|
+
opacity: .5,
|
|
970
|
+
"aria-hidden": !0
|
|
971
|
+
}) : de(ne > 0 ? te : e).map(({ slice: e, start: t, length: n }) => /* @__PURE__ */ Z("circle", {
|
|
972
|
+
...B(e),
|
|
973
|
+
cx: "50",
|
|
974
|
+
cy: "50",
|
|
975
|
+
r: 40,
|
|
976
|
+
fill: "none",
|
|
977
|
+
stroke: K(e.slot),
|
|
978
|
+
strokeWidth: W === e.key ? 18 : 16,
|
|
979
|
+
strokeDasharray: `${n} ${ae}`,
|
|
980
|
+
strokeDashoffset: -t,
|
|
981
|
+
className: "chart-donut-slice",
|
|
982
|
+
opacity: H ? 1 : G(e.key)
|
|
983
|
+
}, e.key))
|
|
984
|
+
})
|
|
985
|
+
}), N ? M === 0 && /* @__PURE__ */ Z("div", {
|
|
986
|
+
className: "chart-donut-centre",
|
|
987
|
+
"aria-hidden": !0,
|
|
988
|
+
children: /* @__PURE__ */ Z("span", {
|
|
989
|
+
className: "chart-donut-empty",
|
|
990
|
+
children: y.empty
|
|
991
|
+
})
|
|
992
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
993
|
+
className: "chart-donut-centre",
|
|
994
|
+
"aria-hidden": !0,
|
|
995
|
+
children: M > 0 && H ? /* @__PURE__ */ Q(ye, { children: [/* @__PURE__ */ Z("span", {
|
|
996
|
+
className: "chart-donut-share",
|
|
997
|
+
children: v(j)
|
|
998
|
+
}), /* @__PURE__ */ Z("span", {
|
|
999
|
+
className: "chart-donut-share-label",
|
|
1000
|
+
children: y.total.toLowerCase()
|
|
1001
|
+
})] }) : M > 0 && oe ? /* @__PURE__ */ Q(ye, { children: [/* @__PURE__ */ Z("span", {
|
|
1002
|
+
className: "chart-donut-share",
|
|
1003
|
+
children: _(V(oe.value))
|
|
1004
|
+
}), /* @__PURE__ */ Z("span", {
|
|
1005
|
+
className: "chart-donut-share-label",
|
|
1006
|
+
children: oe.label.toLowerCase()
|
|
1007
|
+
})] }) : /* @__PURE__ */ Z("span", {
|
|
1008
|
+
className: "chart-donut-empty",
|
|
1009
|
+
children: y.empty
|
|
1010
|
+
})
|
|
1011
|
+
})]
|
|
1012
|
+
}),
|
|
1013
|
+
c && /* @__PURE__ */ Q("ul", {
|
|
1014
|
+
ref: T,
|
|
1015
|
+
className: "chart-donut-legend",
|
|
1016
|
+
"aria-label": y.legend,
|
|
1017
|
+
children: [e.slice(0, E).map((e, t) => /* @__PURE__ */ Q("li", {
|
|
1018
|
+
className: `chart-donut-legend-item${F(t) ? " chart-donut-legend-item--hit" : ""}${d === e.key ? " chart-donut-legend-item--on" : ""}${d !== null && d !== e.key ? " chart-faded" : ""}`,
|
|
1019
|
+
onMouseEnter: () => w(e.key),
|
|
1020
|
+
onMouseLeave: () => w(null),
|
|
1021
|
+
onClick: F(t) ? () => l(e) : void 0,
|
|
1022
|
+
children: [
|
|
1023
|
+
/* @__PURE__ */ Z("span", {
|
|
1024
|
+
className: "chart-swatch",
|
|
1025
|
+
style: { background: K(e.slot) },
|
|
1026
|
+
"aria-hidden": !0
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ Z("span", {
|
|
1029
|
+
className: "chart-donut-legend-label",
|
|
1030
|
+
children: e.label
|
|
1031
|
+
}),
|
|
1032
|
+
/* @__PURE__ */ Q("span", {
|
|
1033
|
+
className: "chart-donut-legend-value",
|
|
1034
|
+
children: [
|
|
1035
|
+
v(e.value),
|
|
1036
|
+
" · ",
|
|
1037
|
+
_(V(e.value))
|
|
1038
|
+
]
|
|
1039
|
+
})
|
|
1040
|
+
]
|
|
1041
|
+
}, e.key)), E < e.length && /* @__PURE__ */ Z("li", {
|
|
1042
|
+
className: "chart-donut-legend-more",
|
|
1043
|
+
"data-legend-more": "",
|
|
1044
|
+
children: y.moreValues(v(e.length - E))
|
|
1045
|
+
})]
|
|
1046
|
+
}),
|
|
1047
|
+
/* @__PURE__ */ Z(u, { text: U ? ie(U) : H ? `${y.total} ${v(j)}` : "" }),
|
|
1048
|
+
I.tooltip(H ? /* @__PURE__ */ Z($, {
|
|
1049
|
+
title: t,
|
|
1050
|
+
rows: e.map((e) => ({
|
|
1051
|
+
key: e.key,
|
|
1052
|
+
color: K(e.slot),
|
|
1053
|
+
label: e.label,
|
|
1054
|
+
value: v(e.value)
|
|
1055
|
+
})),
|
|
1056
|
+
note: `${y.total}: ${v(j)}`
|
|
1057
|
+
}) : U && /* @__PURE__ */ Z($, {
|
|
1058
|
+
rows: [{
|
|
1059
|
+
key: U.key,
|
|
1060
|
+
color: K(U.slot),
|
|
1061
|
+
label: U.label,
|
|
1062
|
+
value: v(U.value)
|
|
1063
|
+
}],
|
|
1064
|
+
note: y.shareOf(_(V(U.value)), v(j))
|
|
1065
|
+
}))
|
|
1066
|
+
]
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
// src/components/Charts/Funnel.tsx
|
|
1070
|
+
function pt({ steps: t, ariaLabel: n, title: r, compact: i = !1, showChange: a = !0, onSelect: s, selected: c = null, animate: l, animationDuration: d, ...f }) {
|
|
1071
|
+
let { nf: p, L: m } = ce(f), h = (e) => !!s && t[e].selectable !== !1, g = Pe({
|
|
1072
|
+
count: t.length,
|
|
1073
|
+
pick: (e, t, n, r) => we(t, Ie(r).map((e) => e ? {
|
|
1074
|
+
start: e.top,
|
|
1075
|
+
end: e.top + e.height
|
|
1076
|
+
} : {
|
|
1077
|
+
start: Infinity,
|
|
1078
|
+
end: Infinity
|
|
1079
|
+
})),
|
|
1080
|
+
keys: {
|
|
1081
|
+
ArrowLeft: 0,
|
|
1082
|
+
ArrowRight: 0
|
|
1083
|
+
},
|
|
1084
|
+
start: c === null ? null : t.findIndex((e) => e.key === c),
|
|
1085
|
+
onPick: s ? (e) => h(e) && s(t[e]) : void 0
|
|
1086
|
+
}), v = o(t).map((e) => a ? e : {
|
|
1087
|
+
...e,
|
|
1088
|
+
drop: null
|
|
1089
|
+
}), y = {};
|
|
1090
|
+
for (let e of v) y[e.step.key] = e.width;
|
|
1091
|
+
let x = Ue(y, {
|
|
1092
|
+
animate: l,
|
|
1093
|
+
animationDuration: d
|
|
1094
|
+
});
|
|
1095
|
+
if (!t.some((e) => e.value > 0)) return /* @__PURE__ */ Z(C, {
|
|
1096
|
+
title: r,
|
|
1097
|
+
children: /* @__PURE__ */ Z(U, {
|
|
1098
|
+
ariaLabel: n,
|
|
1099
|
+
text: m.empty,
|
|
1100
|
+
compact: i
|
|
1101
|
+
})
|
|
1102
|
+
});
|
|
1103
|
+
let S = g.active === null ? null : v[g.active] ?? null, w = S?.step.key ?? c, T = (t) => `${t.step.label}: ${p(t.step.value)}${t.drop === null ? "" : `, ${m.funnelDrop} ${e(t.drop)}`}`, E = s ? "ol" : "div", D = s ? "li" : "div";
|
|
1104
|
+
return /* @__PURE__ */ Q(C, {
|
|
1105
|
+
title: r,
|
|
1106
|
+
children: [
|
|
1107
|
+
/* @__PURE__ */ Z(E, {
|
|
1108
|
+
className: ee(`chart-funnel${a ? "" : " chart-funnel--no-change"} chart-plot chart-plot--rows${s ? " chart-plot--pick" : ""}`, i),
|
|
1109
|
+
role: s ? void 0 : "img",
|
|
1110
|
+
"aria-label": !s && S ? T(S) : n,
|
|
1111
|
+
...g.plotProps,
|
|
1112
|
+
children: v.map(({ step: t, width: n, drop: r }, i) => /* @__PURE__ */ Z(D, {
|
|
1113
|
+
"data-hit": g.pickable ? void 0 : i,
|
|
1114
|
+
className: `chart-funnel-item${i === g.active ? " chart-funnel-item--active" : ""}`,
|
|
1115
|
+
"aria-hidden": !g.pickable || void 0,
|
|
1116
|
+
children: /* @__PURE__ */ Q("span", {
|
|
1117
|
+
...g.pickable ? g.item(i, {
|
|
1118
|
+
pressed: c === t.key,
|
|
1119
|
+
disabled: !h(i)
|
|
1120
|
+
}) : {},
|
|
1121
|
+
"aria-label": g.pickable ? `${t.label}: ${p(t.value)}${r === null ? "" : `, ${e(r)}`}` : void 0,
|
|
1122
|
+
"aria-description": g.pickable && r !== null ? m.funnelDrop : void 0,
|
|
1123
|
+
className: `chart-funnel-row${w !== null && w !== t.key ? " chart-faded" : ""}`,
|
|
1124
|
+
children: [
|
|
1125
|
+
/* @__PURE__ */ Z("span", {
|
|
1126
|
+
className: "chart-funnel-label",
|
|
1127
|
+
title: t.label,
|
|
1128
|
+
children: t.label
|
|
1129
|
+
}),
|
|
1130
|
+
" ",
|
|
1131
|
+
/* @__PURE__ */ Q("span", {
|
|
1132
|
+
className: "chart-funnel-track",
|
|
1133
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
1134
|
+
className: "chart-funnel-bar",
|
|
1135
|
+
style: {
|
|
1136
|
+
width: `${(x[t.key] ?? n) * 100}%`,
|
|
1137
|
+
background: K(t.slot),
|
|
1138
|
+
color: b(t.slot)
|
|
1139
|
+
},
|
|
1140
|
+
children: n >= .18 ? p(t.value) : ""
|
|
1141
|
+
}), n < .18 && /* @__PURE__ */ Z("span", {
|
|
1142
|
+
className: "chart-funnel-outside",
|
|
1143
|
+
children: p(t.value)
|
|
1144
|
+
})]
|
|
1145
|
+
}),
|
|
1146
|
+
" ",
|
|
1147
|
+
a && /* @__PURE__ */ Z("span", {
|
|
1148
|
+
className: "chart-funnel-drop",
|
|
1149
|
+
"data-change": r === null ? void 0 : r > 0 ? "drop" : r < 0 ? "rise" : "flat",
|
|
1150
|
+
children: r === null ? "" : e(r)
|
|
1151
|
+
})
|
|
1152
|
+
]
|
|
1153
|
+
})
|
|
1154
|
+
}, t.key))
|
|
1155
|
+
}),
|
|
1156
|
+
/* @__PURE__ */ Z(u, { text: S ? T(S) : "" }),
|
|
1157
|
+
g.tooltip(S && /* @__PURE__ */ Z($, {
|
|
1158
|
+
rows: [{
|
|
1159
|
+
key: S.step.key,
|
|
1160
|
+
color: K(S.step.slot),
|
|
1161
|
+
label: S.step.label,
|
|
1162
|
+
value: p(S.step.value)
|
|
1163
|
+
}],
|
|
1164
|
+
note: [a && g.active > 0 ? `${m.funnelOfFirst}: ${_(S.ofFirst)}` : "", S.drop === null ? "" : `${m.funnelDrop}: ${e(S.drop)}`].filter(Boolean).join(" · ") || void 0
|
|
1165
|
+
}))
|
|
1166
|
+
]
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
// src/components/Charts/Gauge.tsx
|
|
1170
|
+
function mt({ value: e, total: t, ariaLabel: n, label: r, variant: i = "half", color: o = 1, size: c, compact: l = !1, animate: d, animationDuration: f, ...p }) {
|
|
1171
|
+
let { nf: m, L: h } = ce(p), g = z[i], v = s(e, t), { a0: y, a1: b } = a(i, v), x = Ue({ p: v }, {
|
|
1172
|
+
animate: d,
|
|
1173
|
+
animationDuration: f
|
|
1174
|
+
}).p ?? v, { end: S } = a(i, x), [C, w] = Se(), T = (c ?? (i === "half" ? l ? 120 : 168 : l ? 88 : 128)) * w, E = Pe({
|
|
1175
|
+
count: 1,
|
|
1176
|
+
pick: (e, t, n) => {
|
|
1177
|
+
let r = n.width / g.width;
|
|
1178
|
+
return Oe(e - g.cx * r, t - g.cy * r, (g.r + 6) * r, 0, [{
|
|
1179
|
+
a0: y,
|
|
1180
|
+
a1: b
|
|
1181
|
+
}]) === null ? null : 0;
|
|
1182
|
+
}
|
|
1183
|
+
}), D = h.ofTotal(m(e), m(t)), O = K(L(o, v));
|
|
1184
|
+
return /* @__PURE__ */ Q("div", {
|
|
1185
|
+
ref: C,
|
|
1186
|
+
className: ee(`chart-gauge chart-gauge--${i}`, l),
|
|
1187
|
+
role: "meter",
|
|
1188
|
+
"aria-label": n,
|
|
1189
|
+
"aria-valuemin": 0,
|
|
1190
|
+
"aria-valuemax": 100,
|
|
1191
|
+
"aria-valuenow": Math.round(v * 10) / 10,
|
|
1192
|
+
"aria-valuetext": `${D} (${_(v)})`,
|
|
1193
|
+
children: [
|
|
1194
|
+
/* @__PURE__ */ Q("div", {
|
|
1195
|
+
className: "chart-gauge-dial chart-plot",
|
|
1196
|
+
style: { width: T },
|
|
1197
|
+
...E.plotProps,
|
|
1198
|
+
children: [/* @__PURE__ */ Q("svg", {
|
|
1199
|
+
viewBox: `0 0 ${g.width} ${g.height}`,
|
|
1200
|
+
width: T,
|
|
1201
|
+
height: T * g.height / g.width,
|
|
1202
|
+
"aria-hidden": !0,
|
|
1203
|
+
children: [/* @__PURE__ */ Z("path", {
|
|
1204
|
+
d: oe(g.cx, g.cy, g.r, y, b),
|
|
1205
|
+
className: "chart-gauge-track",
|
|
1206
|
+
fill: "none",
|
|
1207
|
+
strokeWidth: 12,
|
|
1208
|
+
strokeLinecap: "round"
|
|
1209
|
+
}), x > 0 && /* @__PURE__ */ Z("path", {
|
|
1210
|
+
d: oe(g.cx, g.cy, g.r, y, Math.max(S, y + .01)),
|
|
1211
|
+
className: "chart-gauge-value",
|
|
1212
|
+
fill: "none",
|
|
1213
|
+
stroke: O,
|
|
1214
|
+
strokeWidth: 12,
|
|
1215
|
+
strokeLinecap: "round"
|
|
1216
|
+
})]
|
|
1217
|
+
}), /* @__PURE__ */ Z("span", {
|
|
1218
|
+
className: "chart-gauge-share",
|
|
1219
|
+
"aria-hidden": !0,
|
|
1220
|
+
children: _(v)
|
|
1221
|
+
})]
|
|
1222
|
+
}),
|
|
1223
|
+
r !== void 0 && /* @__PURE__ */ Z("span", {
|
|
1224
|
+
className: "chart-gauge-label",
|
|
1225
|
+
children: r
|
|
1226
|
+
}),
|
|
1227
|
+
/* @__PURE__ */ Z("span", {
|
|
1228
|
+
className: "chart-gauge-of",
|
|
1229
|
+
"aria-hidden": !0,
|
|
1230
|
+
children: D
|
|
1231
|
+
}),
|
|
1232
|
+
/* @__PURE__ */ Z(u, { text: E.active === null ? "" : `${D} (${_(v)})` }),
|
|
1233
|
+
E.tooltip(E.active !== null && /* @__PURE__ */ Z($, {
|
|
1234
|
+
title: r ?? n,
|
|
1235
|
+
rows: [{
|
|
1236
|
+
key: "v",
|
|
1237
|
+
color: O,
|
|
1238
|
+
label: D,
|
|
1239
|
+
value: _(v)
|
|
1240
|
+
}]
|
|
1241
|
+
}))
|
|
1242
|
+
]
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
// src/components/Charts/LineChart.tsx
|
|
1246
|
+
var ht = 64, gt = (e, t) => `v:${e.key}\u0000${q(t)}`, _t = (e) => `p:${q(e)}`;
|
|
1247
|
+
function vt({ data: e, series: t, ariaLabel: n, title: r, area: i = !1, height: a, compact: o = !1, onSelect: s, selected: c = null, animate: l, animationDuration: p, ...h }) {
|
|
1248
|
+
let { nf: g, L: _ } = ce(h), [v, y] = Ze(), [b, x] = Se(), S = e.length, w = c === null ? -1 : e.findIndex((e) => q(e) === c), E = Pe({
|
|
1249
|
+
count: S,
|
|
1250
|
+
pick: (e, t, n) => te(e, n.width, S),
|
|
1251
|
+
anchor: (e, t) => {
|
|
1252
|
+
let n = t.getBoundingClientRect();
|
|
1253
|
+
return {
|
|
1254
|
+
left: n.left + m(e, S, 100) / 100 * n.width - 1,
|
|
1255
|
+
top: n.top,
|
|
1256
|
+
width: 2,
|
|
1257
|
+
height: n.height
|
|
1258
|
+
};
|
|
1259
|
+
},
|
|
1260
|
+
keys: {
|
|
1261
|
+
ArrowUp: 0,
|
|
1262
|
+
ArrowDown: 0
|
|
1263
|
+
},
|
|
1264
|
+
start: w >= 0 ? w : null,
|
|
1265
|
+
onPick: s ? (t) => e[t].selectable !== !1 && s(e[t]) : void 0
|
|
1266
|
+
}), j = e.flatMap((e) => t.map((t) => e.values[t.key] ?? 0)), { max: M, ticks: N } = O(j), P = { scale: M };
|
|
1267
|
+
if (!o) for (let e of N) P[`t:${e}`] = 1;
|
|
1268
|
+
for (let n of e) {
|
|
1269
|
+
P[_t(n)] = 1;
|
|
1270
|
+
for (let e of t) P[gt(e, n)] = Math.max(0, n.values[e.key] ?? 0);
|
|
1271
|
+
}
|
|
1272
|
+
let F = Ue(P, {
|
|
1273
|
+
animate: l,
|
|
1274
|
+
animationDuration: p
|
|
1275
|
+
}), I = F.scale ?? M, L = X(e), R = re(e, L.current, q, (e) => (F[`p:${e}`] ?? 0) > 0);
|
|
1276
|
+
if (J(() => {
|
|
1277
|
+
L.current = R;
|
|
1278
|
+
}), !j.some((e) => e > 0)) return /* @__PURE__ */ Z(C, {
|
|
1279
|
+
title: r,
|
|
1280
|
+
children: /* @__PURE__ */ Z(U, {
|
|
1281
|
+
ariaLabel: n,
|
|
1282
|
+
text: _.empty,
|
|
1283
|
+
compact: o
|
|
1284
|
+
})
|
|
1285
|
+
});
|
|
1286
|
+
let z = (a ?? (o ? 96 : 220)) * x, V = R.map((e) => F[_t(e)] ?? 0), ie = D(V).map((e) => e * 100), H = new Map(R.map((e, t) => [q(e), t])), W = (t) => ie[H.get(q(e[t]))], ae = t.map((e) => ({
|
|
1287
|
+
s: e,
|
|
1288
|
+
points: R.map((t, n) => ({
|
|
1289
|
+
x: ie[n],
|
|
1290
|
+
y: 100 - Math.max(0, F[gt(e, t)] ?? 0) / (I || 1) * 100
|
|
1291
|
+
}))
|
|
1292
|
+
})), oe = d(F, "t:"), G = E.active, se = (e) => `${e.fullLabel ?? e.label}: ${t.map((n) => t.length > 1 ? `${n.label} ${g(e.values[n.key] ?? 0)}` : g(e.values[n.key] ?? 0)).join(", ")}`, le = G === null ? null : e[G] ?? null, ue = B(S, Math.max(2, Math.min(o ? 4 : 6, Math.floor((y || 400) / (ht * x))))), de = (e) => `${W(e)}%`;
|
|
1293
|
+
return /* @__PURE__ */ Z(C, {
|
|
1294
|
+
title: r,
|
|
1295
|
+
children: /* @__PURE__ */ Q("div", {
|
|
1296
|
+
ref: v,
|
|
1297
|
+
className: ee(`chart-line${i ? " chart-line--area" : ""}`, o),
|
|
1298
|
+
role: "group",
|
|
1299
|
+
"aria-label": n,
|
|
1300
|
+
children: [
|
|
1301
|
+
/* @__PURE__ */ Q("div", {
|
|
1302
|
+
className: "chart-columns-plot",
|
|
1303
|
+
style: { height: z },
|
|
1304
|
+
children: [!o && /* @__PURE__ */ Z(f, {
|
|
1305
|
+
ticks: oe,
|
|
1306
|
+
max: I,
|
|
1307
|
+
plot: z,
|
|
1308
|
+
nf: g
|
|
1309
|
+
}), /* @__PURE__ */ Q("div", {
|
|
1310
|
+
className: `chart-line-area chart-plot chart-plot--x${s ? " chart-plot--pick" : ""}`,
|
|
1311
|
+
role: s ? void 0 : "img",
|
|
1312
|
+
"aria-label": s ? void 0 : le ? se(le) : n,
|
|
1313
|
+
...E.plotProps,
|
|
1314
|
+
children: [
|
|
1315
|
+
E.pickable && e.map((e, t) => /* @__PURE__ */ Z("span", {
|
|
1316
|
+
...E.item(t, {
|
|
1317
|
+
pressed: t === w,
|
|
1318
|
+
disabled: e.selectable === !1
|
|
1319
|
+
}),
|
|
1320
|
+
"aria-label": se(e),
|
|
1321
|
+
className: "chart-line-slot",
|
|
1322
|
+
style: { left: de(t) }
|
|
1323
|
+
}, q(e))),
|
|
1324
|
+
!o && /* @__PURE__ */ Z(T, {
|
|
1325
|
+
ticks: oe,
|
|
1326
|
+
max: I
|
|
1327
|
+
}),
|
|
1328
|
+
/* @__PURE__ */ Q("svg", {
|
|
1329
|
+
className: "chart-line-svg",
|
|
1330
|
+
viewBox: "0 0 100 100",
|
|
1331
|
+
preserveAspectRatio: "none",
|
|
1332
|
+
width: "100%",
|
|
1333
|
+
height: "100%",
|
|
1334
|
+
"aria-hidden": !0,
|
|
1335
|
+
children: [
|
|
1336
|
+
i && ae.map(({ s: e, points: t }) => /* @__PURE__ */ Z("path", {
|
|
1337
|
+
d: A(t, 100),
|
|
1338
|
+
fill: K(e.slot),
|
|
1339
|
+
className: "chart-line-fill"
|
|
1340
|
+
}, `a-${e.key}`)),
|
|
1341
|
+
ae.map(({ s: e, points: t }) => /* @__PURE__ */ Z("path", {
|
|
1342
|
+
d: ne(t),
|
|
1343
|
+
fill: "none",
|
|
1344
|
+
stroke: K(e.slot),
|
|
1345
|
+
className: "chart-line-path",
|
|
1346
|
+
vectorEffect: "non-scaling-stroke"
|
|
1347
|
+
}, e.key)),
|
|
1348
|
+
w >= 0 && /* @__PURE__ */ Z("line", {
|
|
1349
|
+
className: "chart-line-selected",
|
|
1350
|
+
x1: W(w),
|
|
1351
|
+
x2: W(w),
|
|
1352
|
+
y1: 0,
|
|
1353
|
+
y2: 100,
|
|
1354
|
+
vectorEffect: "non-scaling-stroke"
|
|
1355
|
+
}),
|
|
1356
|
+
G !== null && /* @__PURE__ */ Z("line", {
|
|
1357
|
+
className: "chart-line-crosshair",
|
|
1358
|
+
x1: W(G),
|
|
1359
|
+
x2: W(G),
|
|
1360
|
+
y1: 0,
|
|
1361
|
+
y2: 100,
|
|
1362
|
+
vectorEffect: "non-scaling-stroke"
|
|
1363
|
+
})
|
|
1364
|
+
]
|
|
1365
|
+
}),
|
|
1366
|
+
[G, w >= 0 ? w : null].map((t, n) => t === null || n === 1 && t === G ? null : ae.map(({ s: r, points: i }) => /* @__PURE__ */ Z("span", {
|
|
1367
|
+
className: "chart-line-dot",
|
|
1368
|
+
style: {
|
|
1369
|
+
left: de(t),
|
|
1370
|
+
top: `${i[H.get(q(e[t]))].y}%`,
|
|
1371
|
+
background: K(r.slot)
|
|
1372
|
+
},
|
|
1373
|
+
"aria-hidden": !0
|
|
1374
|
+
}, `${n}-${r.key}`)))
|
|
1375
|
+
]
|
|
1376
|
+
})]
|
|
1377
|
+
}),
|
|
1378
|
+
/* @__PURE__ */ Z("div", {
|
|
1379
|
+
ref: b,
|
|
1380
|
+
className: `chart-line-axis-x${o ? " chart-line-axis-x--compact" : ""}`,
|
|
1381
|
+
"aria-hidden": !0,
|
|
1382
|
+
children: ue.map((t) => {
|
|
1383
|
+
let n = V[H.get(q(e[t]))];
|
|
1384
|
+
return /* @__PURE__ */ Z("span", {
|
|
1385
|
+
style: {
|
|
1386
|
+
left: de(t),
|
|
1387
|
+
opacity: n < 1 ? n : void 0
|
|
1388
|
+
},
|
|
1389
|
+
className: t === 0 ? "chart-line-axis-first" : t === S - 1 ? "chart-line-axis-last" : void 0,
|
|
1390
|
+
children: e[t].label
|
|
1391
|
+
}, q(e[t]));
|
|
1392
|
+
})
|
|
1393
|
+
}),
|
|
1394
|
+
/* @__PURE__ */ Z(u, { text: le ? se(le) : "" }),
|
|
1395
|
+
E.tooltip(le && /* @__PURE__ */ Z($, {
|
|
1396
|
+
title: le.fullLabel ?? le.label,
|
|
1397
|
+
rows: t.map((e) => ({
|
|
1398
|
+
key: e.key,
|
|
1399
|
+
color: K(e.slot),
|
|
1400
|
+
label: e.label,
|
|
1401
|
+
value: g(le.values[e.key] ?? 0)
|
|
1402
|
+
})),
|
|
1403
|
+
note: t.length > 1 ? `${_.total}: ${g(k(le, t))}` : void 0
|
|
1404
|
+
}))
|
|
1405
|
+
]
|
|
1406
|
+
})
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
// src/components/Charts/NumberTrend.tsx
|
|
1410
|
+
var yt = (e) => e.key ?? e.label;
|
|
1411
|
+
function bt({ value: e, ariaLabel: t, title: a, points: o = [], current: s, previous: c, good: l = "up", slot: d = 1, compact: f = !1, animate: p, animationDuration: h, ...g }) {
|
|
1412
|
+
let { nf: v, L: y } = ce(g), b = Pe({
|
|
1413
|
+
count: o.length,
|
|
1414
|
+
pick: (e, t, n) => te(e, n.width, o.length),
|
|
1415
|
+
anchor: (e, t) => {
|
|
1416
|
+
let n = t.getBoundingClientRect();
|
|
1417
|
+
return {
|
|
1418
|
+
left: n.left + m(e, o.length, 100) / 100 * n.width - 1,
|
|
1419
|
+
top: n.top,
|
|
1420
|
+
width: 2,
|
|
1421
|
+
height: n.height
|
|
1422
|
+
};
|
|
1423
|
+
},
|
|
1424
|
+
keys: {
|
|
1425
|
+
ArrowUp: 0,
|
|
1426
|
+
ArrowDown: 0
|
|
1427
|
+
}
|
|
1428
|
+
}), x = s ?? o.reduce((e, t) => e + t.value, 0), S = c === void 0 ? null : n(x, c), C = S ? r(S.direction, l) : "neutral", w = S ? S.direction === "up" ? "▲" : S.direction === "down" ? "▼" : "=" : "", T = S ? S.percent === null ? y.deltaNew : _(Math.abs(S.percent)) : "", E = S ? `${S.direction === "up" ? y.deltaUp : S.direction === "down" ? y.deltaDown : y.deltaSame}${S.direction === "same" ? "" : ` ${T}`} ${y.vsPrevious}` : "", O = Math.min(...o.map((e) => e.value)), k = Math.max(...o.map((e) => e.value)), j = {};
|
|
1429
|
+
for (let e of o) j[`p:${yt(e)}`] = 1, j[`y:${yt(e)}`] = k === O ? .5 : (e.value - O) / (k - O);
|
|
1430
|
+
let M = Ue(j, {
|
|
1431
|
+
animate: p,
|
|
1432
|
+
animationDuration: h
|
|
1433
|
+
}), N = X(o), P = re(o, N.current, yt, (e) => (M[`p:${e}`] ?? 0) > 0);
|
|
1434
|
+
J(() => {
|
|
1435
|
+
N.current = P;
|
|
1436
|
+
});
|
|
1437
|
+
let F = D(P.map((e) => M[`p:${yt(e)}`] ?? 0)), I = P.map((e, t) => ({
|
|
1438
|
+
x: F[t] * 100,
|
|
1439
|
+
y: 100 - (M[`y:${yt(e)}`] ?? 0) * 100
|
|
1440
|
+
})), L = new Map(P.map((e, t) => [yt(e), t])), R = o.map((e) => I[L.get(yt(e))]), z = b.active, B = z === null ? null : o[z] ?? null;
|
|
1441
|
+
return /* @__PURE__ */ Q("div", {
|
|
1442
|
+
className: ee("chart-number", f),
|
|
1443
|
+
role: "group",
|
|
1444
|
+
"aria-label": `${t}: ${v(e)}${E ? `, ${E}` : ""}`,
|
|
1445
|
+
children: [
|
|
1446
|
+
a != null && a !== "" && /* @__PURE__ */ Z("div", {
|
|
1447
|
+
className: "chart-title",
|
|
1448
|
+
children: a
|
|
1449
|
+
}),
|
|
1450
|
+
/* @__PURE__ */ Q("div", {
|
|
1451
|
+
className: "chart-number-line",
|
|
1452
|
+
"aria-hidden": !0,
|
|
1453
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
1454
|
+
className: "chart-number-value",
|
|
1455
|
+
children: v(e)
|
|
1456
|
+
}), S && /* @__PURE__ */ Q("span", {
|
|
1457
|
+
className: "chart-number-delta",
|
|
1458
|
+
"data-tone": C,
|
|
1459
|
+
style: { color: i(C) },
|
|
1460
|
+
children: [
|
|
1461
|
+
w,
|
|
1462
|
+
" ",
|
|
1463
|
+
S.direction === "same" ? _(0) : T
|
|
1464
|
+
]
|
|
1465
|
+
})]
|
|
1466
|
+
}),
|
|
1467
|
+
R.length > 1 && /* @__PURE__ */ Q("div", {
|
|
1468
|
+
className: "chart-number-spark chart-plot chart-plot--x",
|
|
1469
|
+
role: "img",
|
|
1470
|
+
"aria-label": B ? `${B.label}: ${v(B.value)}` : t,
|
|
1471
|
+
...b.plotProps,
|
|
1472
|
+
children: [/* @__PURE__ */ Q("svg", {
|
|
1473
|
+
viewBox: "0 0 100 100",
|
|
1474
|
+
preserveAspectRatio: "none",
|
|
1475
|
+
width: "100%",
|
|
1476
|
+
height: "100%",
|
|
1477
|
+
"aria-hidden": !0,
|
|
1478
|
+
children: [
|
|
1479
|
+
/* @__PURE__ */ Z("path", {
|
|
1480
|
+
d: A(I, 100),
|
|
1481
|
+
fill: K(d),
|
|
1482
|
+
className: "chart-line-fill"
|
|
1483
|
+
}),
|
|
1484
|
+
/* @__PURE__ */ Z("path", {
|
|
1485
|
+
d: ne(I),
|
|
1486
|
+
fill: "none",
|
|
1487
|
+
stroke: K(d),
|
|
1488
|
+
className: "chart-line-path",
|
|
1489
|
+
vectorEffect: "non-scaling-stroke"
|
|
1490
|
+
}),
|
|
1491
|
+
z !== null && R[z] && /* @__PURE__ */ Z("line", {
|
|
1492
|
+
className: "chart-line-crosshair",
|
|
1493
|
+
x1: R[z].x,
|
|
1494
|
+
x2: R[z].x,
|
|
1495
|
+
y1: 0,
|
|
1496
|
+
y2: 100,
|
|
1497
|
+
vectorEffect: "non-scaling-stroke"
|
|
1498
|
+
})
|
|
1499
|
+
]
|
|
1500
|
+
}), z !== null && R[z] && /* @__PURE__ */ Z("span", {
|
|
1501
|
+
className: "chart-line-dot",
|
|
1502
|
+
style: {
|
|
1503
|
+
left: `${R[z].x}%`,
|
|
1504
|
+
top: `${R[z].y}%`,
|
|
1505
|
+
background: K(d)
|
|
1506
|
+
},
|
|
1507
|
+
"aria-hidden": !0
|
|
1508
|
+
})]
|
|
1509
|
+
}),
|
|
1510
|
+
S && /* @__PURE__ */ Z("div", {
|
|
1511
|
+
className: "chart-number-note",
|
|
1512
|
+
"aria-hidden": !0,
|
|
1513
|
+
children: y.vsPrevious
|
|
1514
|
+
}),
|
|
1515
|
+
/* @__PURE__ */ Z(u, { text: B ? `${B.label}: ${v(B.value)}` : "" }),
|
|
1516
|
+
b.tooltip(B && /* @__PURE__ */ Z($, {
|
|
1517
|
+
title: B.label,
|
|
1518
|
+
rows: [{
|
|
1519
|
+
key: "v",
|
|
1520
|
+
color: K(d),
|
|
1521
|
+
label: t,
|
|
1522
|
+
value: v(B.value)
|
|
1523
|
+
}]
|
|
1524
|
+
}))
|
|
1525
|
+
]
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
// src/components/Charts/Progress.tsx
|
|
1529
|
+
function xt({ value: e, total: t, ariaLabel: n, label: r, color: i = 1, compact: a = !1, animate: o, animationDuration: s, ...c }) {
|
|
1530
|
+
let { nf: l, L: d } = ce(c), f = Pe({
|
|
1531
|
+
count: 1,
|
|
1532
|
+
pick: () => 0
|
|
1533
|
+
}), p = t > 0 ? e / t * 100 : 0, m = K(L(i, p)), h = Ue({ p }, {
|
|
1534
|
+
animate: o,
|
|
1535
|
+
animationDuration: s
|
|
1536
|
+
}).p ?? p, g = d.ofTotal(l(e), l(t));
|
|
1537
|
+
return /* @__PURE__ */ Q("div", {
|
|
1538
|
+
className: ee("chart-progress chart-plot", a),
|
|
1539
|
+
role: "progressbar",
|
|
1540
|
+
"aria-label": n,
|
|
1541
|
+
"aria-valuemin": 0,
|
|
1542
|
+
"aria-valuemax": 100,
|
|
1543
|
+
"aria-valuenow": Math.round(p * 10) / 10,
|
|
1544
|
+
"aria-valuetext": `${l(e)} / ${l(t)} (${_(p)})`,
|
|
1545
|
+
...f.plotProps,
|
|
1546
|
+
children: [
|
|
1547
|
+
r !== void 0 && /* @__PURE__ */ Q("div", {
|
|
1548
|
+
className: "chart-progress-head",
|
|
1549
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
1550
|
+
className: "chart-progress-label",
|
|
1551
|
+
children: r
|
|
1552
|
+
}), /* @__PURE__ */ Z("span", {
|
|
1553
|
+
className: "chart-progress-share",
|
|
1554
|
+
children: _(p)
|
|
1555
|
+
})]
|
|
1556
|
+
}),
|
|
1557
|
+
/* @__PURE__ */ Z("div", {
|
|
1558
|
+
className: "chart-progress-track",
|
|
1559
|
+
children: /* @__PURE__ */ Z("div", {
|
|
1560
|
+
className: "chart-progress-fill",
|
|
1561
|
+
style: {
|
|
1562
|
+
width: `${Math.min(100, h)}%`,
|
|
1563
|
+
background: m
|
|
1564
|
+
}
|
|
1565
|
+
})
|
|
1566
|
+
}),
|
|
1567
|
+
/* @__PURE__ */ Z(u, { text: f.active === null ? "" : `${g} (${_(p)})` }),
|
|
1568
|
+
f.tooltip(f.active !== null && /* @__PURE__ */ Z($, {
|
|
1569
|
+
title: r ?? n,
|
|
1570
|
+
rows: [{
|
|
1571
|
+
key: "v",
|
|
1572
|
+
color: m,
|
|
1573
|
+
label: g,
|
|
1574
|
+
value: _(p)
|
|
1575
|
+
}]
|
|
1576
|
+
}))
|
|
1577
|
+
]
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
// src/components/Charts/StackedBar.tsx
|
|
1581
|
+
function St({ slices: e, ariaLabel: t, title: n, compact: r = !1, onLegendCut: i, onSelect: a, selected: o = null, animate: c, animationDuration: l, ...d }) {
|
|
1582
|
+
let { nf: f, L: p } = ce(d), [m, h] = _e(null), [g, v, y] = ut(e.length, r);
|
|
1583
|
+
J(() => i?.(e.length - y), [
|
|
1584
|
+
i,
|
|
1585
|
+
e.length,
|
|
1586
|
+
y
|
|
1587
|
+
]);
|
|
1588
|
+
let b = e.filter((e) => e.value > 0), S = (e) => !!a && e.value > 0 && e.selectable !== !1, w = Pe({
|
|
1589
|
+
count: b.length,
|
|
1590
|
+
pick: (e, t, n, r) => we(e, Ie(r).map((e) => e ? {
|
|
1591
|
+
start: e.left,
|
|
1592
|
+
end: e.left + e.width
|
|
1593
|
+
} : {
|
|
1594
|
+
start: Infinity,
|
|
1595
|
+
end: Infinity
|
|
1596
|
+
})),
|
|
1597
|
+
keys: {
|
|
1598
|
+
ArrowUp: 0,
|
|
1599
|
+
ArrowDown: 0
|
|
1600
|
+
},
|
|
1601
|
+
start: o === null ? null : b.findIndex((e) => e.key === o),
|
|
1602
|
+
onPick: a ? (e) => S(b[e]) && a(b[e]) : void 0
|
|
1603
|
+
}), T = {};
|
|
1604
|
+
for (let e of b) T[e.key] = e.value;
|
|
1605
|
+
let E = Ue(T, {
|
|
1606
|
+
animate: c,
|
|
1607
|
+
animationDuration: l
|
|
1608
|
+
}), D = X(b), O = re(b, D.current, (e) => e.key, (e) => (E[e] ?? 0) > 0);
|
|
1609
|
+
J(() => {
|
|
1610
|
+
D.current = O;
|
|
1611
|
+
});
|
|
1612
|
+
let k = x(e);
|
|
1613
|
+
if (k === 0) return /* @__PURE__ */ Z(C, {
|
|
1614
|
+
title: n,
|
|
1615
|
+
children: /* @__PURE__ */ Z(U, {
|
|
1616
|
+
ariaLabel: t,
|
|
1617
|
+
text: p.empty,
|
|
1618
|
+
compact: r
|
|
1619
|
+
})
|
|
1620
|
+
});
|
|
1621
|
+
let A = (e) => s(Math.max(0, e), k), j = (e) => `${e.label} ${f(e.value)} (${_(A(e.value))})`, M = w.active === null ? null : b[w.active] ?? null, N = M?.key ?? m ?? o, P = (e) => N !== null && N !== e ? " chart-faded" : "";
|
|
1622
|
+
return /* @__PURE__ */ Q("figure", {
|
|
1623
|
+
className: ee("chart-stacked", r),
|
|
1624
|
+
"aria-label": t,
|
|
1625
|
+
children: [
|
|
1626
|
+
n && /* @__PURE__ */ Z("figcaption", {
|
|
1627
|
+
className: "chart-title",
|
|
1628
|
+
children: n
|
|
1629
|
+
}),
|
|
1630
|
+
/* @__PURE__ */ Z("div", {
|
|
1631
|
+
className: `chart-stacked-bar chart-plot chart-plot--x${a ? " chart-plot--pick" : ""}`,
|
|
1632
|
+
role: a ? void 0 : "img",
|
|
1633
|
+
"aria-label": a ? void 0 : M ? j(M) : `${t}: ${e.map(j).join(", ")}`,
|
|
1634
|
+
...w.plotProps,
|
|
1635
|
+
children: O.map((e) => {
|
|
1636
|
+
let t = b.indexOf(e);
|
|
1637
|
+
return t < 0 ? /* @__PURE__ */ Z("span", {
|
|
1638
|
+
"aria-hidden": !0,
|
|
1639
|
+
className: `chart-stacked-segment${P(e.key)}`,
|
|
1640
|
+
style: {
|
|
1641
|
+
flexGrow: E[e.key] ?? 0,
|
|
1642
|
+
background: K(e.slot)
|
|
1643
|
+
}
|
|
1644
|
+
}, e.key) : /* @__PURE__ */ Z("span", {
|
|
1645
|
+
...w.item(t, {
|
|
1646
|
+
pressed: o === e.key,
|
|
1647
|
+
disabled: !S(e)
|
|
1648
|
+
}),
|
|
1649
|
+
"aria-label": w.pickable ? j(e) : void 0,
|
|
1650
|
+
"aria-hidden": !w.pickable || void 0,
|
|
1651
|
+
className: `chart-stacked-segment${P(e.key)}`,
|
|
1652
|
+
style: {
|
|
1653
|
+
flexGrow: E[e.key] ?? e.value,
|
|
1654
|
+
background: K(e.slot)
|
|
1655
|
+
}
|
|
1656
|
+
}, e.key);
|
|
1657
|
+
})
|
|
1658
|
+
}),
|
|
1659
|
+
/* @__PURE__ */ Q("ul", {
|
|
1660
|
+
ref: g,
|
|
1661
|
+
className: "chart-donut-legend chart-stacked-legend",
|
|
1662
|
+
"aria-label": p.legend,
|
|
1663
|
+
children: [e.slice(0, v).map((e) => /* @__PURE__ */ Q("li", {
|
|
1664
|
+
className: `chart-donut-legend-item${S(e) ? " chart-donut-legend-item--hit" : ""}${o === e.key ? " chart-donut-legend-item--on" : ""}${P(e.key)}`,
|
|
1665
|
+
onMouseEnter: () => h(e.key),
|
|
1666
|
+
onMouseLeave: () => h(null),
|
|
1667
|
+
onClick: S(e) ? () => a(e) : void 0,
|
|
1668
|
+
children: [
|
|
1669
|
+
/* @__PURE__ */ Z("span", {
|
|
1670
|
+
className: "chart-swatch",
|
|
1671
|
+
style: { background: K(e.slot) },
|
|
1672
|
+
"aria-hidden": !0
|
|
1673
|
+
}),
|
|
1674
|
+
/* @__PURE__ */ Z("span", {
|
|
1675
|
+
className: "chart-donut-legend-label",
|
|
1676
|
+
children: e.label
|
|
1677
|
+
}),
|
|
1678
|
+
/* @__PURE__ */ Q("span", {
|
|
1679
|
+
className: "chart-donut-legend-value",
|
|
1680
|
+
children: [
|
|
1681
|
+
f(e.value),
|
|
1682
|
+
" · ",
|
|
1683
|
+
_(A(e.value))
|
|
1684
|
+
]
|
|
1685
|
+
})
|
|
1686
|
+
]
|
|
1687
|
+
}, e.key)), v < e.length && /* @__PURE__ */ Z("li", {
|
|
1688
|
+
className: "chart-donut-legend-more",
|
|
1689
|
+
"data-legend-more": "",
|
|
1690
|
+
children: p.moreValues(f(e.length - v))
|
|
1691
|
+
})]
|
|
1692
|
+
}),
|
|
1693
|
+
/* @__PURE__ */ Z(u, { text: M ? j(M) : "" }),
|
|
1694
|
+
w.tooltip(M && /* @__PURE__ */ Z($, {
|
|
1695
|
+
rows: [{
|
|
1696
|
+
key: M.key,
|
|
1697
|
+
color: K(M.slot),
|
|
1698
|
+
label: M.label,
|
|
1699
|
+
value: f(M.value)
|
|
1700
|
+
}],
|
|
1701
|
+
note: p.shareOf(_(A(M.value)), f(k))
|
|
1702
|
+
}))
|
|
1703
|
+
]
|
|
1704
|
+
});
|
|
1705
|
+
}
|
|
1706
|
+
// src/components/Charts/Treemap.tsx
|
|
1707
|
+
var Ct = 400, wt = (e) => e.parent ? `${e.parent.key}\u0000${e.node.key}` : e.node.key, Tt = (e) => e.charCodeAt(0) === 120 || e.charCodeAt(0) === 121;
|
|
1708
|
+
function Et({ nodes: e, ariaLabel: t, title: n, height: r, compact: i = !1, onSelect: a, selected: o = null, animate: c, animationDuration: l, ...d }) {
|
|
1709
|
+
let { nf: f, L: p } = ce(d), [m, h] = Ze(), g = h || Ct, [v, y] = Se(), x = (r ?? (i ? 120 : 220)) * y, S = e.reduce((e, t) => e + Math.max(0, t.value), 0), w = S > 0 ? pe(e, g, x, y) : [], T = w.filter((e) => !e.node.children?.some((e) => e.value > 0)), E = (e) => e.parent ?? e.node, D = (e) => !!a && E(e).selectable !== !1, O = Pe({
|
|
1710
|
+
count: T.length,
|
|
1711
|
+
pick: (e, t, n) => Te(e / n.width * g, t / n.height * x, T.map((e) => ({
|
|
1712
|
+
left: e.rect.x,
|
|
1713
|
+
top: e.rect.y,
|
|
1714
|
+
width: e.rect.w,
|
|
1715
|
+
height: e.rect.h
|
|
1716
|
+
}))),
|
|
1717
|
+
start: o === null ? null : T.findIndex((e) => E(e).key === o),
|
|
1718
|
+
onPick: a ? (e) => D(T[e]) && a(E(T[e])) : void 0
|
|
1719
|
+
}), k = {};
|
|
1720
|
+
for (let e of w) {
|
|
1721
|
+
let t = wt(e);
|
|
1722
|
+
k[`x:${t}`] = (e.rect.x + e.rect.w / 2) / g, k[`y:${t}`] = (e.rect.y + e.rect.h / 2) / x, k[`w:${t}`] = e.rect.w / g, k[`h:${t}`] = e.rect.h / x;
|
|
1723
|
+
}
|
|
1724
|
+
let A = X({
|
|
1725
|
+
width: g,
|
|
1726
|
+
plot: x
|
|
1727
|
+
}), j = A.current.width !== g || A.current.plot !== x, M = Ue(k, {
|
|
1728
|
+
animate: c !== !1 && !j,
|
|
1729
|
+
animationDuration: l
|
|
1730
|
+
}, Tt), N = X(w), P = re(w, N.current, wt, (e) => (M[`w:${e}`] ?? 0) > 0 && (M[`h:${e}`] ?? 0) > 0);
|
|
1731
|
+
J(() => {
|
|
1732
|
+
N.current = P, A.current = {
|
|
1733
|
+
width: g,
|
|
1734
|
+
plot: x
|
|
1735
|
+
};
|
|
1736
|
+
});
|
|
1737
|
+
let F = O.plotProps.ref, L = me((e) => {
|
|
1738
|
+
m(e), F(e);
|
|
1739
|
+
}, [m, F]);
|
|
1740
|
+
if (S <= 0) return /* @__PURE__ */ Z(C, {
|
|
1741
|
+
title: n,
|
|
1742
|
+
children: /* @__PURE__ */ Z(U, {
|
|
1743
|
+
ariaLabel: t,
|
|
1744
|
+
text: p.empty,
|
|
1745
|
+
compact: i
|
|
1746
|
+
})
|
|
1747
|
+
});
|
|
1748
|
+
let R = (e) => `${e.parent ? `${e.parent.label} › ` : ""}${e.node.label} ${f(e.node.value)} (${_(s(e.node.value, S))})`, z = O.active === null ? null : T[O.active] ?? null, te = (e) => {
|
|
1749
|
+
let t = wt(e), n = M[`w:${t}`] ?? 0, r = M[`h:${t}`] ?? 0;
|
|
1750
|
+
return {
|
|
1751
|
+
x: (M[`x:${t}`] ?? 0) - n / 2,
|
|
1752
|
+
y: (M[`y:${t}`] ?? 0) - r / 2,
|
|
1753
|
+
w: n,
|
|
1754
|
+
h: r
|
|
1755
|
+
};
|
|
1756
|
+
}, ne = (e) => ({
|
|
1757
|
+
left: `${e.x * 100}%`,
|
|
1758
|
+
top: `${e.y * 100}%`,
|
|
1759
|
+
width: `${e.w * 100}%`,
|
|
1760
|
+
height: `${e.h * 100}%`
|
|
1761
|
+
}), B = (e) => e.w * g >= ie.w * y && e.h * x >= ie.h * y;
|
|
1762
|
+
return /* @__PURE__ */ Z(C, {
|
|
1763
|
+
title: n,
|
|
1764
|
+
children: /* @__PURE__ */ Q("div", {
|
|
1765
|
+
ref: v,
|
|
1766
|
+
className: ee("chart-treemap", i),
|
|
1767
|
+
role: "group",
|
|
1768
|
+
"aria-label": t,
|
|
1769
|
+
children: [
|
|
1770
|
+
/* @__PURE__ */ Z("div", {
|
|
1771
|
+
className: `chart-treemap-box chart-plot${a ? " chart-plot--pick" : ""}`,
|
|
1772
|
+
style: { height: x },
|
|
1773
|
+
role: a ? void 0 : "img",
|
|
1774
|
+
"aria-label": a ? void 0 : z ? R(z) : `${t}: ${T.map(R).join(", ")}`,
|
|
1775
|
+
...O.plotProps,
|
|
1776
|
+
ref: L,
|
|
1777
|
+
children: P.map((e) => {
|
|
1778
|
+
let t = wt(e), n = te(e);
|
|
1779
|
+
if (!(`w:${t}` in k)) return /* @__PURE__ */ Z("div", {
|
|
1780
|
+
className: `chart-treemap-tile${e.parent ? " chart-treemap-tile--child" : ""}`,
|
|
1781
|
+
style: {
|
|
1782
|
+
...ne(n),
|
|
1783
|
+
background: K(E(e).slot),
|
|
1784
|
+
opacity: e.parent ? I(0) : void 0
|
|
1785
|
+
},
|
|
1786
|
+
"aria-hidden": !0
|
|
1787
|
+
}, t);
|
|
1788
|
+
let r = E(e), i = !!e.node.children?.some((e) => e.value > 0), a = e.parent ? e.parent.children.filter((e) => e.value > 0).indexOf(e.node) : 0, s = o !== null && o !== r.key || z !== null && E(z).key !== r.key, c = T.indexOf(e);
|
|
1789
|
+
return /* @__PURE__ */ Z("div", {
|
|
1790
|
+
...c >= 0 ? O.item(c, {
|
|
1791
|
+
pressed: o === r.key,
|
|
1792
|
+
disabled: !D(e)
|
|
1793
|
+
}) : {},
|
|
1794
|
+
"aria-label": O.pickable && c >= 0 ? R(e) : void 0,
|
|
1795
|
+
className: `chart-treemap-tile${i ? " chart-treemap-tile--group" : ""}${e.parent ? " chart-treemap-tile--child" : ""}${s ? " chart-faded" : ""}${o === r.key ? " chart-treemap-tile--on" : ""}${z === e ? " chart-treemap-tile--active" : ""}`,
|
|
1796
|
+
style: {
|
|
1797
|
+
...ne(n),
|
|
1798
|
+
background: K(r.slot),
|
|
1799
|
+
color: b(r.slot),
|
|
1800
|
+
opacity: e.parent ? I(a) : void 0
|
|
1801
|
+
},
|
|
1802
|
+
"aria-hidden": O.pickable && c >= 0 ? void 0 : !0,
|
|
1803
|
+
children: e.label && B(n) && /* @__PURE__ */ Q("span", {
|
|
1804
|
+
className: "chart-treemap-label",
|
|
1805
|
+
children: [
|
|
1806
|
+
/* @__PURE__ */ Z("span", {
|
|
1807
|
+
className: "chart-treemap-name",
|
|
1808
|
+
children: e.node.label
|
|
1809
|
+
}),
|
|
1810
|
+
" ",
|
|
1811
|
+
!i && /* @__PURE__ */ Z("span", {
|
|
1812
|
+
className: "chart-treemap-count",
|
|
1813
|
+
children: f(e.node.value)
|
|
1814
|
+
})
|
|
1815
|
+
]
|
|
1816
|
+
})
|
|
1817
|
+
}, t);
|
|
1818
|
+
})
|
|
1819
|
+
}),
|
|
1820
|
+
/* @__PURE__ */ Z(u, { text: z ? R(z) : "" }),
|
|
1821
|
+
O.tooltip(z && /* @__PURE__ */ Z($, {
|
|
1822
|
+
title: z.parent ? `${z.parent.label} › ${z.node.label}` : z.node.label,
|
|
1823
|
+
rows: [{
|
|
1824
|
+
key: "n",
|
|
1825
|
+
color: K(E(z).slot),
|
|
1826
|
+
label: t,
|
|
1827
|
+
value: f(z.node.value)
|
|
1828
|
+
}],
|
|
1829
|
+
note: p.shareOf(_(s(z.node.value, S)), f(S))
|
|
1830
|
+
}))
|
|
1831
|
+
]
|
|
1832
|
+
})
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
// src/components/Charts/ChartView.tsx
|
|
1836
|
+
function Dt({ chart: e, ariaLabel: t, compact: n = !1, height: r, size: i, onSelect: a, selected: o = null, linkAs: s, onLegendCut: c, legend: l = !0, animate: u, animationDuration: d, ...f }) {
|
|
1837
|
+
let p = {
|
|
1838
|
+
ariaLabel: t,
|
|
1839
|
+
compact: n,
|
|
1840
|
+
...f,
|
|
1841
|
+
animate: u,
|
|
1842
|
+
animationDuration: d
|
|
1843
|
+
}, m = a ? (e) => a(e.key ?? e.label) : void 0;
|
|
1844
|
+
switch (e.kind) {
|
|
1845
|
+
case "columns": return /* @__PURE__ */ Z(lt, {
|
|
1846
|
+
data: e.data,
|
|
1847
|
+
series: e.series,
|
|
1848
|
+
mode: e.mode,
|
|
1849
|
+
legend: l && e.series.length > 1,
|
|
1850
|
+
height: r,
|
|
1851
|
+
onSelect: m,
|
|
1852
|
+
selected: o,
|
|
1853
|
+
...p
|
|
1854
|
+
});
|
|
1855
|
+
case "line": return /* @__PURE__ */ Z(vt, {
|
|
1856
|
+
data: e.data,
|
|
1857
|
+
series: e.series,
|
|
1858
|
+
area: e.area,
|
|
1859
|
+
height: r,
|
|
1860
|
+
onSelect: m,
|
|
1861
|
+
selected: o,
|
|
1862
|
+
...p
|
|
1863
|
+
});
|
|
1864
|
+
case "bars": return /* @__PURE__ */ Z(Ye, {
|
|
1865
|
+
data: e.data,
|
|
1866
|
+
series: e.series,
|
|
1867
|
+
linkAs: s,
|
|
1868
|
+
onSelect: m,
|
|
1869
|
+
selected: o,
|
|
1870
|
+
...p
|
|
1871
|
+
});
|
|
1872
|
+
case "stacked": return /* @__PURE__ */ Z(St, {
|
|
1873
|
+
slices: e.slices,
|
|
1874
|
+
onLegendCut: c,
|
|
1875
|
+
onSelect: m,
|
|
1876
|
+
selected: o,
|
|
1877
|
+
...p
|
|
1878
|
+
});
|
|
1879
|
+
case "donut":
|
|
1880
|
+
case "pie": return /* @__PURE__ */ Z(ft, {
|
|
1881
|
+
variant: e.kind,
|
|
1882
|
+
slices: e.slices,
|
|
1883
|
+
size: i,
|
|
1884
|
+
legend: l,
|
|
1885
|
+
onLegendCut: c,
|
|
1886
|
+
onSelect: m,
|
|
1887
|
+
selected: o,
|
|
1888
|
+
...p
|
|
1889
|
+
});
|
|
1890
|
+
case "treemap": return /* @__PURE__ */ Z(Et, {
|
|
1891
|
+
nodes: e.nodes,
|
|
1892
|
+
height: r,
|
|
1893
|
+
onSelect: m,
|
|
1894
|
+
selected: o,
|
|
1895
|
+
...p
|
|
1896
|
+
});
|
|
1897
|
+
case "calendar": return /* @__PURE__ */ Z(tt, {
|
|
1898
|
+
days: e.days,
|
|
1899
|
+
onSelect: a ? (e) => a(e.day) : void 0,
|
|
1900
|
+
selected: o,
|
|
1901
|
+
...p
|
|
1902
|
+
});
|
|
1903
|
+
case "funnel": return /* @__PURE__ */ Z(pt, {
|
|
1904
|
+
steps: e.steps,
|
|
1905
|
+
showChange: e.showChange,
|
|
1906
|
+
onSelect: m,
|
|
1907
|
+
selected: o,
|
|
1908
|
+
...p
|
|
1909
|
+
});
|
|
1910
|
+
case "gauge": {
|
|
1911
|
+
let t = e.rows[0];
|
|
1912
|
+
return /* @__PURE__ */ Z(mt, {
|
|
1913
|
+
value: t.value,
|
|
1914
|
+
total: t.total,
|
|
1915
|
+
color: t.color,
|
|
1916
|
+
variant: e.variant,
|
|
1917
|
+
label: n ? void 0 : t.label,
|
|
1918
|
+
...p
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
case "progress": {
|
|
1922
|
+
let t = e.rows[0];
|
|
1923
|
+
return /* @__PURE__ */ Z(xt, {
|
|
1924
|
+
value: t.value,
|
|
1925
|
+
total: t.total,
|
|
1926
|
+
color: t.color,
|
|
1927
|
+
label: n ? void 0 : t.label,
|
|
1928
|
+
...p
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
case "number": return /* @__PURE__ */ Z(bt, {
|
|
1932
|
+
value: e.value,
|
|
1933
|
+
points: e.points,
|
|
1934
|
+
current: e.current,
|
|
1935
|
+
previous: e.previous,
|
|
1936
|
+
good: e.good,
|
|
1937
|
+
slot: e.slot,
|
|
1938
|
+
...p
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
export { Se as A, ke as C, Te as D, Ae as E, Oe as O, De as S, Ce as T, Le as _, bt as a, Ie as b, pt as c, nt as d, tt as f, Ye as g, Ze as h, xt as i, xe as j, we as k, ft as l, Xe as m, Et as n, vt as o, et as p, St as r, mt as s, Dt as t, lt as u, $ as v, Ee as w, Pe as x, Fe as y };
|