@iota-uz/sdk 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-host/identity.d.ts +4 -4
- package/dist/client-host/identity.js +2 -2
- package/dist/lens/{CascadePanel-jtC2EUUS.js → CascadePanel-Sd2OKQx-.js} +15 -15
- package/dist/lens/{ChartDataEquivalent-BFDdHoQn.js → ChartDataEquivalent-DgCAb4Ov.js} +14 -13
- package/dist/lens/ChartPanel-CiAahY9O.js +709 -0
- package/dist/lens/{CoveragePanel-5LWQwFMZ.js → CoveragePanel-DeeKg8gF.js} +10 -10
- package/dist/lens/{GaugePanel-eVYvp3Hk.js → GaugePanel-8rsf_XHS.js} +8 -8
- package/dist/lens/{MapPanel-CzpZKz1Y.js → MapPanel-Bq0mfVCB.js} +14 -14
- package/dist/lens/{MetricFlowPanel-CG2Bj7s6.js → MetricFlowPanel-ZBJqPFpc.js} +2 -2
- package/dist/lens/{MetricHierarchyPanel-Difdcafn.js → MetricHierarchyPanel-DStGwvVU.js} +2 -2
- package/dist/lens/{MetricRelationshipPanel-Cq1dFTeY.js → MetricRelationshipPanel-D6ItmGCS.js} +2 -2
- package/dist/lens/{PrintReport-BiUdo8XG.js → PrintReport-Dr-6xXVr.js} +413 -397
- package/dist/lens/{TablePanel-_6j7epQg.js → TablePanel-CzLP8gG0.js} +1 -1
- package/dist/lens/{adapter-DRShqW45.js → adapter-BwEwcw2W.js} +4960 -4956
- package/dist/lens/adapter-CgoRd_uP.js +6 -0
- package/dist/lens/charts/adapter.d.ts +1 -0
- package/dist/lens/charts/adapter.d.ts.map +1 -1
- package/dist/lens/charts/echarts/options.d.ts.map +1 -1
- package/dist/lens/charts/keys.d.ts +2 -0
- package/dist/lens/charts/keys.d.ts.map +1 -1
- package/dist/lens/contract/schemas.d.ts.map +1 -1
- package/dist/lens/contract/types.d.ts +1 -0
- package/dist/lens/contract/types.d.ts.map +1 -1
- package/dist/lens/{index-CmXDbBaF.js → index-B6anZ5Pr.js} +1 -1
- package/dist/lens/{index-BBtBPnTb.js → index-R9mnOHaj.js} +684 -667
- package/dist/lens/index.js +1 -1
- package/dist/lens/{install-ByIx15ES.js → install-CsNOaFxV.js} +1 -1
- package/dist/lens/{install-DKwCLbtk.js → install-CumkiUJn.js} +1 -1
- package/dist/lens/{install-ByEamXef.js → install-D5OiGDnd.js} +1 -1
- package/dist/lens/{install-DIbrzh5h.js → install-VEXJv-Wi.js} +1 -1
- package/dist/lens/keys-6_gqLhcv.js +78 -0
- package/dist/lens/{metricViews-IoSavtwn.js → metricViews-De-9pff-.js} +1 -1
- package/dist/lens/panels/ChartPanel.d.ts.map +1 -1
- package/dist/lens/panels/data.d.ts +2 -0
- package/dist/lens/panels/data.d.ts.map +1 -1
- package/dist/lens/{prefetch-CrMQhAEy.js → prefetch-C_qYKOTU.js} +2 -2
- package/dist/lens/{prefetchPanels-BbWAAYrz.js → prefetchPanels-CD4C-A5q.js} +1 -1
- package/dist/lens/print/PrintReport.d.ts.map +1 -1
- package/dist/lens/{print-CLo-mTEP.js → print-Iu804kRb.js} +18 -18
- package/dist/lens/{scales-CChHRiVq.js → scales-CWTA0tSQ.js} +53 -53
- package/dist/sdk-identity.cjs +3 -3
- package/dist/sdk-identity.js +3 -3
- package/dist/sdk-identity.json +2 -2
- package/dist/testing/driver.d.ts +19 -0
- package/dist/testing/driver.js +103 -30
- package/dist/testing/fixtures.d.ts +27 -0
- package/dist/testing/fixtures.js +19 -4
- package/dist/testing/index.d.ts +3 -2
- package/dist/testing/index.js +6 -30
- package/dist/testing/lease.d.ts +11 -0
- package/dist/testing/lease.js +44 -0
- package/package.json +1 -1
- package/dist/lens/ChartHost-DTnhnwkn.js +0 -68
- package/dist/lens/ChartPanel-_S4IVYdJ.js +0 -730
- package/dist/lens/keys-DenV5HsJ.js +0 -12
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { jsxs as A, jsx as i, Fragment as Ee } from "react/jsx-runtime";
|
|
2
|
+
import { useState as se, useRef as Pe, useCallback as ke, useEffect as pe, useMemo as R, memo as bt, useLayoutEffect as At, Fragment as Kt } from "react";
|
|
3
|
+
import { r as Rt } from "./adapter-CgoRd_uP.js";
|
|
4
|
+
import { C as Tt, f as Ft } from "./keys-6_gqLhcv.js";
|
|
5
|
+
import { s as Et, o as _e, c as Bt, a as Mt, b as Ht, d as _t, f as $t } from "./scales-CWTA0tSQ.js";
|
|
6
|
+
import { t as Ot, u as Ke, a as pt, x as zt, y as ut, z as mt, n as Ut, A as Vt, B as Dt, C as Pt, D as qt, m as jt, E as Wt, F as Qt, G as ht, h as St, i as xt, g as It, H as Zt, I as Gt, j as Jt, J as Yt, K as Xt, P as eo, W as to, L as M, M as ft, N as oo, O as $e, Q as no, R as ro, S as so, T as ao } from "./index-R9mnOHaj.js";
|
|
7
|
+
import "@iota-uz/sdk/client-host";
|
|
8
|
+
import { c as io, C as co } from "./ChartDataEquivalent-DgCAb4Ov.js";
|
|
9
|
+
const lo = 0.02, go = ao, uo = 4;
|
|
10
|
+
function mo(e) {
|
|
11
|
+
const n = M(), t = M(e.encoding.label ? e.format[e.encoding.label] : void 0), r = M(e.encoding.value ? e.format[e.encoding.value] : void 0), l = M(e.encoding.previous ? e.format[e.encoding.previous] : void 0), c = M(e.encoding.lower ? e.format[e.encoding.lower] : void 0), f = M(e.encoding.q1 ? e.format[e.encoding.q1] : void 0), y = M(e.encoding.median ? e.format[e.encoding.median] : void 0), h = M(e.encoding.q3 ? e.format[e.encoding.q3] : void 0), p = M(e.encoding.upper ? e.format[e.encoding.upper] : void 0), v = M(e.encoding.id ? e.format[e.encoding.id] : void 0), T = M(e.encoding.series ? e.format[e.encoding.series] : void 0), u = M(e.encoding.category ? e.format[e.encoding.category] : void 0), d = M(e.encoding.cut ? e.format[e.encoding.cut] : void 0), C = M(e.encoding.cutLabel ? e.format[e.encoding.cutLabel] : void 0), ae = M(e.encoding.final ? e.format[e.encoding.final] : void 0), U = ft(e.encoding.value ? e.format[e.encoding.value] : void 0), X = ft(e.encoding.median ? e.format[e.encoding.median] : void 0), H = R(() => {
|
|
12
|
+
const E = { label: t, value: r, previous: l, lower: c, q1: f, median: y, q3: h, upper: p, id: v, series: T, category: u, cut: d, cutLabel: C, final: ae }, k = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const L of oo) {
|
|
14
|
+
const ee = e.encoding[L], K = E[L];
|
|
15
|
+
ee && K && k.set(ee, K);
|
|
16
|
+
}
|
|
17
|
+
return (L, ee) => (k.get(L) ?? n)(ee);
|
|
18
|
+
}, [u, d, C, n, ae, v, t, c, y, e.encoding, l, f, h, T, p, r]), ne = R(() => {
|
|
19
|
+
const E = e.encoding.value, k = e.encoding.median;
|
|
20
|
+
return (L, ee) => E && L === E ? U(ee) : k && L === k ? X(ee) : H(L, ee);
|
|
21
|
+
}, [X, H, e.encoding.median, e.encoding.value, U]);
|
|
22
|
+
return R(() => ({ format: H, formatAxis: ne }), [H, ne]);
|
|
23
|
+
}
|
|
24
|
+
function Oe(e, n, t) {
|
|
25
|
+
var y, h;
|
|
26
|
+
const r = n.encoding.id ? e.columns.findIndex((p) => p.name === n.encoding.id) : -1, l = [n.encoding.category, n.encoding.label].find((p) => !!p && e.columns.some((v) => v.name === p)), c = e.columns.findIndex((p) => p.name === l), f = r >= 0 ? (y = e.rows[t]) == null ? void 0 : y[r] : (h = e.rows[t]) == null ? void 0 : h[c];
|
|
27
|
+
return String(typeof f == "string" || typeof f == "number" || typeof f == "bigint" ? f : t);
|
|
28
|
+
}
|
|
29
|
+
function vt(e, n, t) {
|
|
30
|
+
var y;
|
|
31
|
+
if (((y = n.radial) == null ? void 0 : y.mode) === "partition" && n.encoding.series) {
|
|
32
|
+
const h = e.columns.findIndex((p) => p.name === n.encoding.series);
|
|
33
|
+
if (h >= 0) {
|
|
34
|
+
const p = e.rows.findIndex((v, T) => {
|
|
35
|
+
const u = v[h], d = typeof u == "string" || typeof u == "number" || typeof u == "bigint" ? String(u) : "";
|
|
36
|
+
return Rt(d, Oe(e, n, T)) === t;
|
|
37
|
+
});
|
|
38
|
+
if (p >= 0) return p;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const r = e.rows.findIndex((h, p) => Oe(e, n, p) === t);
|
|
42
|
+
if (r >= 0) return r;
|
|
43
|
+
const l = n.encoding.category ?? n.encoding.label, c = e.columns.findIndex((h) => h.name === l), f = e.columns.findIndex((h) => h.name === n.encoding.series);
|
|
44
|
+
return c < 0 ? -1 : e.rows.findIndex((h) => Ft(
|
|
45
|
+
Ae(h[c]),
|
|
46
|
+
f >= 0 ? Ae(h[f]) : ""
|
|
47
|
+
) === t);
|
|
48
|
+
}
|
|
49
|
+
function Nt(e, n) {
|
|
50
|
+
return n.semantics !== "series" || !n.encoding.series ? -1 : e.columns.findIndex((t) => t.name === n.encoding.series);
|
|
51
|
+
}
|
|
52
|
+
function ho(e, n, t) {
|
|
53
|
+
var c;
|
|
54
|
+
const r = Nt(e, n);
|
|
55
|
+
if (r < 0) return Oe(e, n, t);
|
|
56
|
+
const l = (c = e.rows[t]) == null ? void 0 : c[r];
|
|
57
|
+
return String(typeof l == "string" || typeof l == "number" || typeof l == "bigint" ? l : t);
|
|
58
|
+
}
|
|
59
|
+
function le(e) {
|
|
60
|
+
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
61
|
+
if (typeof e == "string" && e.trim() !== "") {
|
|
62
|
+
const n = Number(e);
|
|
63
|
+
if (Number.isFinite(n)) return n;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function Ae(e) {
|
|
67
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? String(e) : "";
|
|
68
|
+
}
|
|
69
|
+
function fo(e, n) {
|
|
70
|
+
const l = (n.kind === "pie" || n.kind === "donut" || n.kind === "radial" ? [n.encoding.label, n.encoding.category] : [n.encoding.category, n.encoding.label]).reduce((c, f) => c >= 0 || !f ? c : e.columns.findIndex((y) => y.name === f), -1);
|
|
71
|
+
return l < 0 ? 0 : new Set(e.rows.map((c) => c[l]).filter((c) => c != null).map(String)).size;
|
|
72
|
+
}
|
|
73
|
+
function vo(e, n) {
|
|
74
|
+
const t = e.columns.findIndex((r) => r.name === n.encoding.series);
|
|
75
|
+
return t < 0 ? 1 : new Set(e.rows.map((r) => r[t]).filter((r) => r != null).map(String)).size;
|
|
76
|
+
}
|
|
77
|
+
const Ct = "__lens_other__", wo = "__lens_topn_group";
|
|
78
|
+
function wt(e, n) {
|
|
79
|
+
var v, T;
|
|
80
|
+
const t = e.columns.findIndex((u) => u.name === wo), r = e.columns.findIndex((u) => u.name === (n.encoding.label ?? n.encoding.category)), l = e.columns.findIndex((u) => u.name === n.encoding.id), c = e.columns.findIndex((u) => u.name === n.encoding.value);
|
|
81
|
+
if (t < 0 || r < 0 || c < 0) return { frame: e, collapsed: !1 };
|
|
82
|
+
const f = e.rows.filter((u) => typeof u[t] == "string" && String(u[t]).trim() !== "");
|
|
83
|
+
if (f.length === 0) return { frame: e, collapsed: !1 };
|
|
84
|
+
const y = e.rows.filter((u) => !f.includes(u)).map((u) => [...u]), h = new Array(e.columns.length).fill(null);
|
|
85
|
+
h[t] = (v = f[0]) == null ? void 0 : v[t], h[r] = (T = f[0]) == null ? void 0 : T[t], l >= 0 && (h[l] = Ct), h[c] = f.reduce((u, d) => u + (le(d[c]) ?? 0), 0), y.push(h);
|
|
86
|
+
const p = e.colors ? [...e.colors.filter((u, d) => !f.includes(e.rows[d])), $e()] : [...y.slice(0, -1).map(() => ""), $e()];
|
|
87
|
+
return { frame: { ...e, rows: y, colors: p }, collapsed: !0 };
|
|
88
|
+
}
|
|
89
|
+
function yt(e, n, t) {
|
|
90
|
+
if (n.kind !== "donut" || e.rows.length < 2) return { frame: e, collapsed: !1 };
|
|
91
|
+
const r = e.columns.findIndex((d) => d.name === (n.encoding.label ?? n.encoding.category)), l = e.columns.findIndex((d) => d.name === n.encoding.id), c = e.columns.findIndex((d) => d.name === n.encoding.value);
|
|
92
|
+
if (r < 0 || c < 0) return { frame: e, collapsed: !1 };
|
|
93
|
+
const f = e.total ?? e.rows.reduce((d, C) => d + (le(C[c]) ?? 0), 0);
|
|
94
|
+
if (!Number.isFinite(f) || f <= 0) return { frame: e, collapsed: !1 };
|
|
95
|
+
const y = e.rows.map((d, C) => ({ index: C, value: le(d[c]) ?? 0 })).filter(({ value: d }) => d / f < lo);
|
|
96
|
+
if (y.length === 0) return { frame: e, collapsed: !1 };
|
|
97
|
+
const h = new Set(y.map(({ index: d }) => d)), p = e.rows.filter((d, C) => !h.has(C)).map((d) => [...d]), v = new Array(e.columns.length).fill(null);
|
|
98
|
+
v[r] = t, l >= 0 && (v[l] = Ct), v[c] = y.reduce((d, C) => d + C.value, 0), p.push(v);
|
|
99
|
+
const T = e.rows.map((d, C) => C).filter((d) => !h.has(d)), u = e.colors ? [...e.colors.filter((d, C) => !h.has(C)), $e()] : [...T.map(() => ""), $e()];
|
|
100
|
+
return { frame: { ...e, rows: p, colors: u }, collapsed: !0 };
|
|
101
|
+
}
|
|
102
|
+
function To({ panel: e, adapter: n }) {
|
|
103
|
+
var Ze, Ge, Je, Ye, Xe, et, tt, ot, nt, rt, st, at, it, ct, lt, dt, gt;
|
|
104
|
+
const t = Ot(e.id), r = Ke(), { document: l, navigation: c } = pt(), { drillInto: f } = zt(), { format: y, formatAxis: h } = mo(e), [p, v] = se(), [T, u] = se(!1), [d, C] = se(0), ae = typeof window > "u" ? { regression: !1 } : ut(new URL(window.location.href), e.id), [U, X] = se(ae.regression), [H, ne] = se(ae.movingAverage), [E, k] = se(() => /* @__PURE__ */ new Set()), [L, ee] = se(() => typeof window > "u" ? /* @__PURE__ */ new Set() : mt(new URL(window.location.href), e.id)), K = L, te = c.panelId === e.id && c.path.length > 0, q = te ? Ut(l, c.path) : e.drillRoot ? l.drill.edges[e.drillRoot] : void 0, Be = q ? q.children.some(({ target: o }) => o) : !!e.drillRoot, re = !!e.drillRoot || !!q, _ = Vt(e), ie = Pe(), ce = ke((o) => {
|
|
105
|
+
if (re || !_.action || !t.data) return;
|
|
106
|
+
const a = vt(t.data, e, o);
|
|
107
|
+
return _.urlForRow(t.data, a >= 0 ? t.data.rows[a] : void 0);
|
|
108
|
+
}, [t.data, re, _, e]), de = ke((o) => {
|
|
109
|
+
var a;
|
|
110
|
+
(a = ie.current) == null || a.call(ie), ie.current = void 0, !(o === null || re) && (ie.current = _.prefetch(ce(o)));
|
|
111
|
+
}, [re, ce, _]);
|
|
112
|
+
pe(() => () => {
|
|
113
|
+
var o;
|
|
114
|
+
return (o = ie.current) == null ? void 0 : o.call(ie);
|
|
115
|
+
}, []);
|
|
116
|
+
const Z = R(() => {
|
|
117
|
+
var o;
|
|
118
|
+
return re || ((o = _.action) == null ? void 0 : o.kind) !== "open_drawer" || !t.data ? [] : t.data.rows.length === 0 || t.data.rows.length > 4 ? [] : [...new Set(t.data.rows.flatMap((a) => {
|
|
119
|
+
const m = _.urlForRow(t.data, a);
|
|
120
|
+
return m ? [m] : [];
|
|
121
|
+
}))];
|
|
122
|
+
}, [t.data, re, _]);
|
|
123
|
+
pe(() => {
|
|
124
|
+
if (Z.length !== 0)
|
|
125
|
+
return _.prefetchIdle(Z);
|
|
126
|
+
}, [Z, _]);
|
|
127
|
+
const I = Dt(), G = ((Ze = _.action) == null ? void 0 : Ze.kind) === "cross_filter" || ((Ge = _.action) == null ? void 0 : Ge.kind) === "cube_drill" ? _.action.filter : void 0, we = R(() => {
|
|
128
|
+
if (!(G != null && G.dimension)) return;
|
|
129
|
+
const o = I.values[Pt], a = Array.isArray(o) ? o : o ? [o] : [], m = `${G.dimension}:`, b = new Set(a.filter((B) => B.startsWith(m)).map((B) => B.slice(m.length)));
|
|
130
|
+
return b.size > 0 ? b : void 0;
|
|
131
|
+
}, [G == null ? void 0 : G.dimension, I.values]), Re = R(() => {
|
|
132
|
+
if (!we || !G || !t.data) return;
|
|
133
|
+
new URL(globalThis.location.href);
|
|
134
|
+
const o = t.data;
|
|
135
|
+
for (let a = 0; a < o.rows.length; a += 1) {
|
|
136
|
+
const m = qt(G.value, {
|
|
137
|
+
fields: jt(o, o.rows[a]),
|
|
138
|
+
variables: {}
|
|
139
|
+
}), b = Ae(m);
|
|
140
|
+
if (b !== "" && we.has(b)) return Oe(o, e, a);
|
|
141
|
+
}
|
|
142
|
+
}, [we, G, t.data, e]), J = e.kind, Te = t.data ? fo(t.data, e) <= 1 && vo(t.data, e) <= 1 : !1, Se = `${c.panelId === e.id ? c.path.join("|") : ""}:${c.perspectiveId ?? ""}`, xe = Pe(Se);
|
|
143
|
+
pe(() => {
|
|
144
|
+
xe.current !== Se && (xe.current = Se, v(void 0));
|
|
145
|
+
}, [Se]);
|
|
146
|
+
const ge = ke((o) => ee(new Set(o)), []);
|
|
147
|
+
pe(() => {
|
|
148
|
+
if (typeof window > "u") return;
|
|
149
|
+
const o = () => ge(mt(new URL(window.location.href), e.id));
|
|
150
|
+
return window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
|
|
151
|
+
}, [e.id, ge]), pe(() => {
|
|
152
|
+
if (typeof window > "u") return;
|
|
153
|
+
const o = new URL(window.location.href), a = Wt(o, e.id, K);
|
|
154
|
+
a.search !== o.search && window.history.replaceState(window.history.state, "", a);
|
|
155
|
+
}, [K, e.id]), pe(() => {
|
|
156
|
+
if (typeof window > "u") return;
|
|
157
|
+
const o = () => {
|
|
158
|
+
const a = ut(new URL(window.location.href), e.id);
|
|
159
|
+
X(a.regression), ne(a.movingAverage);
|
|
160
|
+
};
|
|
161
|
+
return window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
|
|
162
|
+
}, [e.id]), pe(() => {
|
|
163
|
+
if (typeof window > "u") return;
|
|
164
|
+
const o = new URL(window.location.href), a = Qt(o, e.id, { regression: U, movingAverage: H });
|
|
165
|
+
a.search !== o.search && window.history.replaceState(window.history.state, "", a);
|
|
166
|
+
}, [H, e.id, U]);
|
|
167
|
+
const V = R(() => {
|
|
168
|
+
var Q, Ce;
|
|
169
|
+
if (!t.data || K.size === 0) return t.data;
|
|
170
|
+
const o = t.data.rows.map((Le, be) => !K.has(ho(t.data, e, be))), a = t.data.rows.filter((Le, be) => o[be]), m = (Q = t.data.colors) == null ? void 0 : Q.filter((Le, be) => o[be]), b = t.data.columns.findIndex((Le) => Le.name === e.encoding.value), B = ((Ce = e.radial) == null ? void 0 : Ce.mode) === "partition" || b < 0 ? t.data.total : a.reduce((Le, be) => Le + (le(be[b]) ?? 0), 0);
|
|
171
|
+
return { ...t.data, rows: a, total: B, ...m ? { colors: m } : {} };
|
|
172
|
+
}, [t.data, K, e]), F = R(() => V ? (() => {
|
|
173
|
+
const o = wt(V, e);
|
|
174
|
+
return o.collapsed ? o : yt(V, e, r("chart.other", "Other"));
|
|
175
|
+
})() : { frame: V, collapsed: !1 }, [e, r, V]), Fe = F.collapsed && F.frame ? io(F.frame, e, F.frame.rows.length - 1) : void 0, O = T || !F.collapsed ? V : F.frame, s = O ? Et(O, e.encoding, e.valueAxis, (Je = e.presentation) == null ? void 0 : Je.valueSpreadThreshold) : !1, N = R(() => {
|
|
176
|
+
if (!t.data || T) return t.data;
|
|
177
|
+
const o = wt(t.data, e);
|
|
178
|
+
return o.collapsed ? o.frame : yt(t.data, e, r("chart.other", "Other")).frame;
|
|
179
|
+
}, [t.data, e, T, r]), x = R(() => {
|
|
180
|
+
var a;
|
|
181
|
+
if (!t.data || K.size === 0 || !e.encoding.value || ((a = e.radial) == null ? void 0 : a.mode) === "partition") return;
|
|
182
|
+
const o = t.data.columns.findIndex((m) => m.name === e.encoding.value);
|
|
183
|
+
if (!(o < 0))
|
|
184
|
+
return ((V == null ? void 0 : V.rows) ?? []).reduce((m, b) => m + (le(b[o]) ?? 0), 0);
|
|
185
|
+
}, [t.data, K.size, e.encoding.value, (Ye = e.radial) == null ? void 0 : Ye.mode, V]), Y = R(() => {
|
|
186
|
+
var a;
|
|
187
|
+
if (!t.data || !e.encoding.value || ((a = e.radial) == null ? void 0 : a.mode) === "partition") return;
|
|
188
|
+
const o = t.data.columns.findIndex((m) => m.name === e.encoding.value);
|
|
189
|
+
if (!(o < 0))
|
|
190
|
+
return t.data.rows.reduce((m, b) => m + (le(b[o]) ?? 0), 0);
|
|
191
|
+
}, [t.data, e.encoding.value, (Xe = e.radial) == null ? void 0 : Xe.mode]), j = K.size > 0 && ((V == null ? void 0 : V.rows.length) ?? 0) === 0, z = ((tt = ((et = t.data) == null ? void 0 : et.presentation) ?? e.presentation) == null ? void 0 : tt.keepTotalBadge) === !0, W = t.data && (t.data.rows.length > 0 || z) ? t.data.total ?? (z || te || e.kind === "pie" || e.kind === "donut" || e.kind === "radial" ? Y : void 0) ?? e.total : void 0, D = W === void 0 || j && !z ? null : K.size > 0 ? x ?? null : W, $ = ((ot = t.data) == null ? void 0 : ot.presentation) ?? e.presentation, ue = O == null ? void 0 : O.colors, me = ke((o) => {
|
|
192
|
+
const a = new Set(K);
|
|
193
|
+
a.has(o) ? a.delete(o) : a.add(o), ge(a);
|
|
194
|
+
}, [K, ge]), he = R(() => {
|
|
195
|
+
if (q)
|
|
196
|
+
return (o) => {
|
|
197
|
+
var a;
|
|
198
|
+
return !!((a = ht(q, o)) != null && a.target);
|
|
199
|
+
};
|
|
200
|
+
}, [q]), fe = R(() => St(t.data, e), [t.data, e]), ve = R(
|
|
201
|
+
() => xt(l.theme, e, t.data, !te),
|
|
202
|
+
[te, l.theme, t.data, e]
|
|
203
|
+
), g = R(
|
|
204
|
+
() => It(l.theme, e, { colors: ue, positional: !te, labels: fe }),
|
|
205
|
+
[te, l.theme, ue, fe, e]
|
|
206
|
+
), w = R(() => {
|
|
207
|
+
var a;
|
|
208
|
+
const o = new Set(E);
|
|
209
|
+
U || o.add(_e.trend);
|
|
210
|
+
for (const { window: m } of ((a = e.temporal) == null ? void 0 : a.movingAverages) ?? [])
|
|
211
|
+
m !== H && o.add(_e.average(m));
|
|
212
|
+
return o;
|
|
213
|
+
}, [E, H, (nt = e.temporal) == null ? void 0 : nt.movingAverages, U]), S = ke((o) => {
|
|
214
|
+
var m, b;
|
|
215
|
+
if (o === _e.trend) {
|
|
216
|
+
X((B) => !B);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const a = (b = (m = e.temporal) == null ? void 0 : m.movingAverages) == null ? void 0 : b.find(({ window: B }) => _e.average(B) === o);
|
|
220
|
+
if (a) {
|
|
221
|
+
ne((B) => B === a.window ? void 0 : a.window);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
k((B) => {
|
|
225
|
+
const Q = new Set(B);
|
|
226
|
+
return Q.has(o) ? Q.delete(o) : Q.add(o), Q;
|
|
227
|
+
});
|
|
228
|
+
}, [(rt = e.temporal) == null ? void 0 : rt.movingAverages]), oe = (J === "line" || J === "area") && e.temporal && (e.temporal.regression || (st = e.temporal.movingAverages) != null && st.length) ? /* @__PURE__ */ A("div", { className: "lens-temporal-controls", children: [
|
|
229
|
+
e.temporal.regression && /* @__PURE__ */ i(
|
|
230
|
+
"button",
|
|
231
|
+
{
|
|
232
|
+
"aria-pressed": U,
|
|
233
|
+
className: "lens-temporal-toggle",
|
|
234
|
+
onClick: () => X((o) => !o),
|
|
235
|
+
type: "button",
|
|
236
|
+
children: r("chart.regression", "Trend")
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
!!((at = e.temporal.movingAverages) != null && at.length) && /* @__PURE__ */ A(
|
|
240
|
+
"select",
|
|
241
|
+
{
|
|
242
|
+
"aria-label": r("chart.movingAverage", "Moving average"),
|
|
243
|
+
className: "lens-temporal-select",
|
|
244
|
+
onChange: (o) => ne(o.target.value ? Number(o.target.value) : void 0),
|
|
245
|
+
value: H ?? "",
|
|
246
|
+
children: [
|
|
247
|
+
/* @__PURE__ */ i("option", { value: "", children: r("chart.movingAverage", "Moving average") }),
|
|
248
|
+
(it = e.temporal.movingAverages) == null ? void 0 : it.map(({ window: o, label: a }) => /* @__PURE__ */ i("option", { value: o, children: a || `SMA ${o}` }, o))
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
] }) : void 0, P = R(() => ({
|
|
253
|
+
current: r("chart.series.current", "Current period"),
|
|
254
|
+
previous: r("chart.series.previous", "Previous"),
|
|
255
|
+
trend: r("chart.series.trend", "Trend"),
|
|
256
|
+
movingAverage: (o) => r("chart.series.movingAverage", "SMA {window}", { window: String(o) }),
|
|
257
|
+
estimate: r("chart.series.estimate", "Estimate"),
|
|
258
|
+
ytd: r("chart.series.ytd", "YTD"),
|
|
259
|
+
forecast: r("chart.series.forecast", "Forecast"),
|
|
260
|
+
forecastLower: (o) => r("chart.series.forecastLower", "{forecast} lower", { forecast: o }),
|
|
261
|
+
forecastConfidence: (o) => r("chart.series.forecastConfidence", "{forecast} confidence", { forecast: o }),
|
|
262
|
+
boxplot: [
|
|
263
|
+
r("chart.boxplot.min", "Min"),
|
|
264
|
+
r("chart.boxplot.q1", "Q1"),
|
|
265
|
+
r("chart.boxplot.median", "Median"),
|
|
266
|
+
r("chart.boxplot.q3", "Q3"),
|
|
267
|
+
r("chart.boxplot.max", "Max")
|
|
268
|
+
],
|
|
269
|
+
noData: r("panel.empty", "No data"),
|
|
270
|
+
copyValue: r("explore.copyValue", "Copy value"),
|
|
271
|
+
copied: r("explore.copied", "Copied")
|
|
272
|
+
}), [r]), ye = R(() => {
|
|
273
|
+
var o, a;
|
|
274
|
+
return O ? {
|
|
275
|
+
kind: J,
|
|
276
|
+
frame: O,
|
|
277
|
+
encoding: e.encoding,
|
|
278
|
+
format: y,
|
|
279
|
+
formatAxis: h,
|
|
280
|
+
formatTooltip: (m, b, B) => Yt(b, B, e.format[m], l.meta.locale),
|
|
281
|
+
// The plot abbreviates because a label has to fit beside a mark; the
|
|
282
|
+
// tooltip is where a reader who stopped to point gets the whole number, and
|
|
283
|
+
// the clipboard gets the machine value behind it.
|
|
284
|
+
formatExact: (m, b) => {
|
|
285
|
+
var B;
|
|
286
|
+
return Jt(b, e.format[m], ((B = l.meta) == null ? void 0 : B.locale) ?? "en");
|
|
287
|
+
},
|
|
288
|
+
rawValue: (m, b) => Gt(b, e.format[m]),
|
|
289
|
+
categoryFormatDefined: !!(e.encoding.category && e.format[e.encoding.category]),
|
|
290
|
+
locale: (o = l.meta) == null ? void 0 : o.locale,
|
|
291
|
+
shareDecimalSeparator: e.encoding.value ? (a = e.format[e.encoding.value]) == null ? void 0 : a.decimalSeparator : void 0,
|
|
292
|
+
tooltipTotalLabel: r("panel.total", "Total"),
|
|
293
|
+
labels: P,
|
|
294
|
+
theme: l.theme,
|
|
295
|
+
// An explicit pick wins; otherwise the mark the page is currently filtered
|
|
296
|
+
// by carries the same outline, so the source panel states its own selection
|
|
297
|
+
// across a reload or a shared URL, not only in the click that made it.
|
|
298
|
+
selectedKey: p ?? Re,
|
|
299
|
+
presentation: $,
|
|
300
|
+
seriesColor: ve,
|
|
301
|
+
rowColor: g,
|
|
302
|
+
radial: e.radial,
|
|
303
|
+
temporal: e.temporal,
|
|
304
|
+
hiddenOverlays: w,
|
|
305
|
+
valueAxis: e.valueAxis,
|
|
306
|
+
valueUnit: Zt(e.encoding.value ? e.format[e.encoding.value] : void 0),
|
|
307
|
+
expandable: he
|
|
308
|
+
} : void 0;
|
|
309
|
+
}, [P, (ct = l.meta) == null ? void 0 : ct.locale, l.theme, he, y, h, Re, w, J, e.encoding, e.format, e.radial, e.temporal, e.valueAxis, $, O, g, p, ve, r]), ze = R(() => {
|
|
310
|
+
var a, m;
|
|
311
|
+
if (!e.temporal && !e.encoding.previous) return [];
|
|
312
|
+
const o = e.encoding.category ?? e.encoding.label;
|
|
313
|
+
return Bt({
|
|
314
|
+
temporal: e.temporal,
|
|
315
|
+
hasComparison: !!e.encoding.previous,
|
|
316
|
+
labels: P,
|
|
317
|
+
formatValue: (b) => y(e.encoding.value ?? "", b),
|
|
318
|
+
formatCategory: Mt({
|
|
319
|
+
format: (b) => y(o ?? "", b),
|
|
320
|
+
isTime: ((a = t.data) == null ? void 0 : a.columns.some((b) => b.name === o && b.type === "time")) === !0,
|
|
321
|
+
hasDeclaredFormat: !!(o && e.format[o]),
|
|
322
|
+
locale: (m = l.meta) == null ? void 0 : m.locale
|
|
323
|
+
}),
|
|
324
|
+
hidden: w
|
|
325
|
+
});
|
|
326
|
+
}, [P, (lt = l.meta) == null ? void 0 : lt.locale, y, (dt = t.data) == null ? void 0 : dt.columns, w, e.encoding, e.format, e.temporal]), Me = Xt(), Ue = re ? Me ? !!((q == null ? void 0 : q.children.length) ?? e.drillRoot) : Be : !!_.action, qe = J === "histogram" || J === "boxplot" || J === "heatmap", Ve = Te && !qe, De = ke((o, a, m) => {
|
|
327
|
+
const b = F.frame ? F.frame.rows.length - 1 : -1;
|
|
328
|
+
if (F.collapsed && !!(o === Fe || F.frame && vt(F.frame, e, o) === b)) {
|
|
329
|
+
u((Ce) => !Ce);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (!re) {
|
|
333
|
+
const Ce = ce(o);
|
|
334
|
+
_.activate(Ce, void 0, { newTab: m == null ? void 0 : m.newTab });
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (Me) {
|
|
338
|
+
v(o), Me(o, a);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const Q = ht(q, o);
|
|
342
|
+
q && !(Q != null && Q.target) || (v(o), f((Q == null ? void 0 : Q.key) ?? o, e.id));
|
|
343
|
+
}, [F.collapsed, F.frame, Fe, f, re, q, ce, Me, e, _]), je = !Ve && ($ == null ? void 0 : $.legend) === "below" && !!O, Lt = !Ve && ze.length > 0 && !!O, Ie = Ue || F.collapsed, kt = e.encoding.category ?? e.encoding.label, We = (J === "line" || J === "area") && (O == null ? void 0 : O.columns.some((o) => o.name === kt && o.type === "time")) === !0, He = ze.find((o) => o.kind === "incomplete" && o.active), Qe = G ? r("chart.filterHint", "Select to filter the page") : r("chart.drillHint", "Select to explore"), Ne = R(
|
|
344
|
+
() => ye && Ue ? { ...ye, actionHint: Qe } : ye,
|
|
345
|
+
[Qe, ye, Ue]
|
|
346
|
+
);
|
|
347
|
+
return /* @__PURE__ */ i(eo, { allowEmptyContent: !qe, panel: e, frame: t, headerActions: oe, total: D, children: /* @__PURE__ */ A("div", { className: `lens-chart-layout${je ? " lens-chart-layout-legend" : ""}`, children: [
|
|
348
|
+
/* @__PURE__ */ A("div", { className: "lens-chart-area", children: [
|
|
349
|
+
($ == null ? void 0 : $.totalBadge) === "plot" && J !== "donut" && ((gt = e.radial) == null ? void 0 : gt.mode) !== "partition" && D !== null && /* @__PURE__ */ i(po, { panel: e, total: D }),
|
|
350
|
+
(s || He || We || we || T && F.collapsed) && /* @__PURE__ */ A("div", { className: "lens-chart-notes", children: [
|
|
351
|
+
we && /* @__PURE__ */ i("span", { className: "lens-chart-source-note", role: "note", children: r("chart.crossFilterSource", "All categories shown — the filter applies to the other panels") }),
|
|
352
|
+
s && /* @__PURE__ */ A(
|
|
353
|
+
"span",
|
|
354
|
+
{
|
|
355
|
+
className: "lens-chart-log-scale",
|
|
356
|
+
role: "note",
|
|
357
|
+
title: r("chart.logScaleHint", "Values are shown on a logarithmic scale"),
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ i(to, { "aria-hidden": "true" }),
|
|
360
|
+
/* @__PURE__ */ i("span", { children: r("chart.logScale", "Logarithmic scale") })
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
He && /* @__PURE__ */ i("span", { className: "lens-chart-period-note", role: "note", children: [He.detail, He.label].filter(Boolean).join(" · ") }),
|
|
365
|
+
/* @__PURE__ */ A("span", { className: "lens-chart-notes-actions", children: [
|
|
366
|
+
T && F.collapsed && /* @__PURE__ */ i("button", { className: "lens-chart-collapse-other", onClick: () => u(!1), type: "button", children: r("chart.collapseOther", "Collapse Other") }),
|
|
367
|
+
We && /* @__PURE__ */ i("button", { className: "lens-chart-reset-zoom", onClick: () => C((o) => o + 1), type: "button", children: r("chart.resetZoom", "Reset zoom") })
|
|
368
|
+
] })
|
|
369
|
+
] }),
|
|
370
|
+
j ? /* @__PURE__ */ i(yo, { onShowAll: () => ge(/* @__PURE__ */ new Set()) }) : Ne && Ve ? /* @__PURE__ */ i(
|
|
371
|
+
bo,
|
|
372
|
+
{
|
|
373
|
+
actionable: Ie,
|
|
374
|
+
frame: Ne.frame,
|
|
375
|
+
onSelect: Ie ? De : void 0,
|
|
376
|
+
panel: e
|
|
377
|
+
}
|
|
378
|
+
) : Ne && /* @__PURE__ */ A(Ee, { children: [
|
|
379
|
+
/* @__PURE__ */ i(
|
|
380
|
+
co,
|
|
381
|
+
{
|
|
382
|
+
actionable: Ie,
|
|
383
|
+
format: Ne.format,
|
|
384
|
+
frame: Ne.frame,
|
|
385
|
+
label: r("chart.data", "Chart data for {name}", { name: e.title }),
|
|
386
|
+
onHover: de,
|
|
387
|
+
onSelect: De,
|
|
388
|
+
panel: e,
|
|
389
|
+
translate: r
|
|
390
|
+
}
|
|
391
|
+
),
|
|
392
|
+
/* @__PURE__ */ i(
|
|
393
|
+
Tt,
|
|
394
|
+
{
|
|
395
|
+
input: Ne,
|
|
396
|
+
panelId: e.id,
|
|
397
|
+
adapter: n,
|
|
398
|
+
label: r("chart.label", "{name} chart", { name: e.title }),
|
|
399
|
+
drillable: Ie,
|
|
400
|
+
onHover: Ie ? de : void 0,
|
|
401
|
+
onSelect: Ie ? De : void 0,
|
|
402
|
+
resetZoomKey: d
|
|
403
|
+
}
|
|
404
|
+
)
|
|
405
|
+
] }),
|
|
406
|
+
Lt && /* @__PURE__ */ i(xo, { onToggle: S, overlays: ze })
|
|
407
|
+
] }),
|
|
408
|
+
je && N && /* @__PURE__ */ i(
|
|
409
|
+
So,
|
|
410
|
+
{
|
|
411
|
+
frame: N,
|
|
412
|
+
hidden: K,
|
|
413
|
+
onSetHidden: ge,
|
|
414
|
+
onToggle: me,
|
|
415
|
+
panel: e,
|
|
416
|
+
presentation: $,
|
|
417
|
+
total: D ?? void 0
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
] }) });
|
|
421
|
+
}
|
|
422
|
+
function yo({ onShowAll: e }) {
|
|
423
|
+
const n = Ke();
|
|
424
|
+
return /* @__PURE__ */ A("div", { className: "lens-chart-empty", role: "status", children: [
|
|
425
|
+
/* @__PURE__ */ i("span", { className: "lens-chart-empty-note", children: n("chart.allSeriesHidden", "All series are hidden") }),
|
|
426
|
+
/* @__PURE__ */ i("button", { className: "lens-chart-empty-action", onClick: e, type: "button", children: n("chart.showAllSeries", "Show all series") })
|
|
427
|
+
] });
|
|
428
|
+
}
|
|
429
|
+
function bo({ actionable: e, frame: n, onSelect: t, panel: r }) {
|
|
430
|
+
var ne, E;
|
|
431
|
+
const l = Ke(), c = [r.encoding.category, r.encoding.label].find((k) => k !== void 0 && n.columns.some((L) => L.name === k)), f = r.encoding.value, y = n.columns.findIndex((k) => k.name === c), h = n.columns.findIndex((k) => k.name === f), p = M(f ? r.format[f] : void 0), v = h < 0 ? void 0 : n.rows.reduce((k, L) => k + (le(L[h]) ?? 0), 0), T = y < 0 || (ne = n.rows[0]) == null ? void 0 : ne[y], u = Ae(T), d = p(v), C = r.encoding.id ?? c, ae = n.columns.findIndex((k) => k.name === C), U = Ae(ae < 0 || (E = n.rows[0]) == null ? void 0 : E[ae]), X = /* @__PURE__ */ i(Ee, { children: n.rows.length === 0 ? /* @__PURE__ */ i("span", { className: "lens-chart-compact-empty", children: l("panel.empty", "No data") }) : /* @__PURE__ */ A(Ee, { children: [
|
|
432
|
+
u && /* @__PURE__ */ i("span", { className: "lens-chart-compact-label", title: u, children: u }),
|
|
433
|
+
/* @__PURE__ */ i("strong", { className: "lens-chart-compact-value", children: d })
|
|
434
|
+
] }) }), H = n.rows.length === 0 ? l("panel.empty", "No data") : [u, d].filter(Boolean).join(" / ");
|
|
435
|
+
return e && U && n.rows.length > 0 ? /* @__PURE__ */ i(
|
|
436
|
+
"button",
|
|
437
|
+
{
|
|
438
|
+
"aria-label": `${H}. ${l("chart.openMark", "Open {name}", { name: u ?? U })}`,
|
|
439
|
+
className: "lens-chart-compact lens-chart-compact-action",
|
|
440
|
+
onClick: () => t == null ? void 0 : t(U),
|
|
441
|
+
type: "button",
|
|
442
|
+
children: X
|
|
443
|
+
}
|
|
444
|
+
) : /* @__PURE__ */ i("div", { "aria-label": H, className: "lens-chart-compact", role: "img", children: X });
|
|
445
|
+
}
|
|
446
|
+
function po({ panel: e, total: n }) {
|
|
447
|
+
const t = Ke(), r = M(e.encoding.value ? e.format[e.encoding.value] : void 0);
|
|
448
|
+
return /* @__PURE__ */ A("span", { className: "lens-plot-total", children: [
|
|
449
|
+
/* @__PURE__ */ A("span", { className: "lens-panel-total-label", children: [
|
|
450
|
+
t("panel.total", "Total"),
|
|
451
|
+
":"
|
|
452
|
+
] }),
|
|
453
|
+
" ",
|
|
454
|
+
r(n)
|
|
455
|
+
] });
|
|
456
|
+
}
|
|
457
|
+
const So = bt(function({
|
|
458
|
+
panel: n,
|
|
459
|
+
frame: t,
|
|
460
|
+
hidden: r,
|
|
461
|
+
onSetHidden: l,
|
|
462
|
+
onToggle: c,
|
|
463
|
+
total: f,
|
|
464
|
+
presentation: y
|
|
465
|
+
}) {
|
|
466
|
+
var Fe, O;
|
|
467
|
+
const { document: h, navigation: p } = pt(), v = Ke(), [T, u] = se(""), d = Pe(null), [C, ae] = se({ top: !1, bottom: !1 }), [U, X] = se(0), [H, ne] = se(!1), E = Nt(t, n), k = E >= 0 ? n.encoding.series : n.encoding.label ?? n.encoding.category, L = n.encoding.value, ee = M(L ? n.format[L] : void 0), K = t.columns.findIndex((s) => s.name === k), te = t.columns.findIndex((s) => s.name === L), q = M(k ? n.format[k] : void 0), Be = p.panelId === n.id && p.path.length > 0, re = St(t, n), _ = xt(h.theme, n, t, !Be), ie = It(h.theme, n, {
|
|
468
|
+
colors: t.colors,
|
|
469
|
+
positional: !Be,
|
|
470
|
+
labels: re
|
|
471
|
+
}), ce = n.encoding.id ? t.columns.findIndex((s) => s.name === n.encoding.id) : -1, de = n.encoding.series ? t.columns.findIndex((s) => s.name === n.encoding.series) : -1, Z = ((Fe = n.radial) == null ? void 0 : Fe.mode) === "partition", I = R(() => {
|
|
472
|
+
var fe, ve;
|
|
473
|
+
const s = t.rows.map((g, w) => {
|
|
474
|
+
const S = ce >= 0 ? g[ce] : g[K];
|
|
475
|
+
return String(typeof S == "string" || typeof S == "number" || typeof S == "bigint" ? S : w);
|
|
476
|
+
}), N = t.rows.map((g, w) => {
|
|
477
|
+
if (E < 0) return s[w];
|
|
478
|
+
const S = g[E];
|
|
479
|
+
return String(typeof S == "string" || typeof S == "number" || typeof S == "bigint" ? S : w);
|
|
480
|
+
});
|
|
481
|
+
let x = t.rows.map((g, w) => w);
|
|
482
|
+
if (E >= 0 || Z) {
|
|
483
|
+
const g = /* @__PURE__ */ new Set();
|
|
484
|
+
x = [];
|
|
485
|
+
for (let w = 0; w < t.rows.length; w += 1) {
|
|
486
|
+
const S = N[w];
|
|
487
|
+
g.has(S) || (g.add(S), x.push(w));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const Y = x.map((g) => N[g]), j = new Map(x.map((g, w) => [g, w])), z = /* @__PURE__ */ new Map();
|
|
491
|
+
Z && s.forEach((g) => {
|
|
492
|
+
z.has(g) || z.set(g, z.size);
|
|
493
|
+
});
|
|
494
|
+
const W = new Map((((fe = n.radial) == null ? void 0 : fe.rings) ?? []).map((g) => [g.key, g.total])), D = /* @__PURE__ */ new Map();
|
|
495
|
+
for (let g = 0; g < t.rows.length; g += 1) {
|
|
496
|
+
const w = de >= 0 ? (ve = t.rows[g]) == null ? void 0 : ve[de] : void 0, S = Z && typeof w == "string" ? w : "", oe = Z ? W.get(S) ?? f : f, P = Z ? S : String(oe), ye = D.get(P) ?? { denominator: oe, indices: [] };
|
|
497
|
+
ye.indices.push(g), D.set(P, ye);
|
|
498
|
+
}
|
|
499
|
+
const $ = /* @__PURE__ */ new Map();
|
|
500
|
+
for (const { denominator: g, indices: w } of D.values()) {
|
|
501
|
+
const S = w.map((oe) => {
|
|
502
|
+
var P;
|
|
503
|
+
return te >= 0 ? le((P = t.rows[oe]) == null ? void 0 : P[te]) : void 0;
|
|
504
|
+
});
|
|
505
|
+
_t(S, g).forEach((oe, P) => $.set(w[P], oe));
|
|
506
|
+
}
|
|
507
|
+
const ue = /* @__PURE__ */ new Map();
|
|
508
|
+
Z && s.forEach((g) => ue.set(g, (ue.get(g) ?? 0) + 1));
|
|
509
|
+
const me = /* @__PURE__ */ new Map();
|
|
510
|
+
te >= 0 && t.rows.forEach((g, w) => {
|
|
511
|
+
var P;
|
|
512
|
+
const S = le(g[te]);
|
|
513
|
+
if (S === void 0) return;
|
|
514
|
+
const oe = N[w];
|
|
515
|
+
E >= 0 && L && ((P = n.format[L]) == null ? void 0 : P.kind) !== "percent" ? me.set(oe, (me.get(oe) ?? 0) + S) : me.set(oe, S);
|
|
516
|
+
});
|
|
517
|
+
const he = /* @__PURE__ */ new Map();
|
|
518
|
+
return Z && de >= 0 && x.forEach((g) => {
|
|
519
|
+
var S;
|
|
520
|
+
const w = (S = t.rows[g]) == null ? void 0 : S[de];
|
|
521
|
+
typeof w == "string" && he.set(g, w);
|
|
522
|
+
}), { allKeys: Y, categoryOrder: z, entries: x, entryKeys: N, entryPositions: j, ringByIndex: he, rowKeys: s, rowsPerKey: ue, shares: $, valueByKey: me };
|
|
523
|
+
}, [t, ce, K, n.format, (O = n.radial) == null ? void 0 : O.rings, Z, de, E, f, L, te]), G = (s, N, x) => {
|
|
524
|
+
var z;
|
|
525
|
+
if (E >= 0) return _(I.entryKeys[N], x);
|
|
526
|
+
const Y = ce >= 0 ? (z = t.rows[N]) == null ? void 0 : z[ce] : void 0, j = typeof Y == "string" && Y.trim() !== "" ? Y : void 0;
|
|
527
|
+
return ie(s, I.categoryOrder.get(I.rowKeys[N]) ?? N, j);
|
|
528
|
+
}, we = (y == null ? void 0 : y.legendValue) === "percent", Re = (s) => E >= 0 ? "value" : we ? "percent" : Z ? I.rowsPerKey.get(I.rowKeys[s]) === 1 ? "percent" : "none" : "value", J = T.trim().toLocaleLowerCase(), Te = J === "" ? I.entries : I.entries.filter((s) => {
|
|
529
|
+
var x;
|
|
530
|
+
const N = (x = t.rows[s]) == null ? void 0 : x[K];
|
|
531
|
+
return Ae(N).toLocaleLowerCase().includes(J);
|
|
532
|
+
});
|
|
533
|
+
if (At(() => {
|
|
534
|
+
const s = d.current;
|
|
535
|
+
if (!s) return;
|
|
536
|
+
const N = () => {
|
|
537
|
+
const Y = s.scrollTop + s.clientHeight, j = s.scrollHeight > s.clientHeight + 1;
|
|
538
|
+
if (ae({
|
|
539
|
+
top: j && s.scrollTop > 1,
|
|
540
|
+
bottom: j && Y < s.scrollHeight - 1
|
|
541
|
+
}), !j) {
|
|
542
|
+
X(0);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const z = s.querySelectorAll(".lens-chart-legend-item");
|
|
546
|
+
let W = 0;
|
|
547
|
+
for (const D of z) D.offsetTop + D.offsetHeight > Y + 1 && (W += 1);
|
|
548
|
+
X(W);
|
|
549
|
+
};
|
|
550
|
+
N(), s.addEventListener("scroll", N, { passive: !0 });
|
|
551
|
+
const x = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(N);
|
|
552
|
+
return x == null || x.observe(s), () => {
|
|
553
|
+
s.removeEventListener("scroll", N), x == null || x.disconnect();
|
|
554
|
+
};
|
|
555
|
+
}, [H, Te.length]), K < 0) return null;
|
|
556
|
+
const Se = (s) => {
|
|
557
|
+
const N = !r.has(s) && I.allKeys.every((x) => x === s || r.has(x));
|
|
558
|
+
l(N ? /* @__PURE__ */ new Set() : new Set(I.allKeys.filter((x) => x !== s)));
|
|
559
|
+
}, xe = I.allKeys.length > 0 && I.allKeys.every((s) => r.has(s)), ge = I.allKeys.every((s) => !r.has(s)), V = I.allKeys.length > uo, F = I.entries.length >= go;
|
|
560
|
+
return /* @__PURE__ */ A("div", { className: "lens-chart-legend-shell", style: H ? { "--lens-chart-legend-max": "none" } : void 0, children: [
|
|
561
|
+
V && /* @__PURE__ */ A("div", { className: "lens-chart-legend-controls", children: [
|
|
562
|
+
/* @__PURE__ */ i(
|
|
563
|
+
"div",
|
|
564
|
+
{
|
|
565
|
+
"aria-label": v("chart.legendControls", "Legend controls"),
|
|
566
|
+
className: "lens-chart-legend-tools",
|
|
567
|
+
"data-members": F ? "many" : "one",
|
|
568
|
+
role: "group",
|
|
569
|
+
children: F ? /* @__PURE__ */ A(Ee, { children: [
|
|
570
|
+
/* @__PURE__ */ i(
|
|
571
|
+
"button",
|
|
572
|
+
{
|
|
573
|
+
"aria-pressed": xe,
|
|
574
|
+
onClick: () => l(new Set(I.allKeys)),
|
|
575
|
+
type: "button",
|
|
576
|
+
children: v("chart.legendHideAll", "Hide all")
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
/* @__PURE__ */ i(
|
|
580
|
+
"button",
|
|
581
|
+
{
|
|
582
|
+
"aria-pressed": ge,
|
|
583
|
+
onClick: () => l(/* @__PURE__ */ new Set()),
|
|
584
|
+
type: "button",
|
|
585
|
+
children: v("chart.legendShowAll", "Show all")
|
|
586
|
+
}
|
|
587
|
+
),
|
|
588
|
+
/* @__PURE__ */ i(
|
|
589
|
+
"button",
|
|
590
|
+
{
|
|
591
|
+
"aria-label": v("chart.legendInvert", "Invert"),
|
|
592
|
+
className: "lens-chart-legend-invert",
|
|
593
|
+
onClick: () => l(new Set(I.allKeys.filter((s) => !r.has(s)))),
|
|
594
|
+
title: v("chart.legendInvert", "Invert"),
|
|
595
|
+
type: "button",
|
|
596
|
+
children: /* @__PURE__ */ i(no, {})
|
|
597
|
+
}
|
|
598
|
+
)
|
|
599
|
+
] }) : /* @__PURE__ */ i(
|
|
600
|
+
"button",
|
|
601
|
+
{
|
|
602
|
+
onClick: () => l(xe ? /* @__PURE__ */ new Set() : new Set(I.allKeys)),
|
|
603
|
+
type: "button",
|
|
604
|
+
children: xe ? v("chart.legendShowAll", "Show all") : v("chart.legendHideAll", "Hide all")
|
|
605
|
+
}
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
),
|
|
609
|
+
F && /* @__PURE__ */ A("label", { className: "lens-chart-legend-search", children: [
|
|
610
|
+
/* @__PURE__ */ i("span", { className: "lens-sr-only", children: v("chart.legendSearch", "Search legend") }),
|
|
611
|
+
/* @__PURE__ */ i(
|
|
612
|
+
"input",
|
|
613
|
+
{
|
|
614
|
+
className: "lens-facet-search",
|
|
615
|
+
onChange: (s) => u(s.currentTarget.value),
|
|
616
|
+
placeholder: v("chart.legendSearch", "Search legend"),
|
|
617
|
+
type: "search",
|
|
618
|
+
value: T
|
|
619
|
+
}
|
|
620
|
+
)
|
|
621
|
+
] })
|
|
622
|
+
] }),
|
|
623
|
+
/* @__PURE__ */ A(
|
|
624
|
+
"div",
|
|
625
|
+
{
|
|
626
|
+
className: "lens-chart-legend-scroll-frame",
|
|
627
|
+
"data-overflow-bottom": C.bottom || void 0,
|
|
628
|
+
"data-overflow-top": C.top || void 0,
|
|
629
|
+
children: [
|
|
630
|
+
/* @__PURE__ */ i("ul", { "aria-label": v("chart.legendControls", "Legend controls"), className: "lens-chart-legend", "data-testid": `lens-panel-${n.id}-legend`, ref: d, role: "region", tabIndex: C.top || C.bottom ? 0 : void 0, children: Te.map((s, N) => {
|
|
631
|
+
var he, fe, ve, g, w;
|
|
632
|
+
const x = t.rows[s], Y = I.entryPositions.get(s) ?? s, j = x[K], z = j == null ? "" : q(j), W = I.entryKeys[s], D = r.has(W), $ = I.ringByIndex.get(s), ue = N > 0 ? I.ringByIndex.get(Te[N - 1]) : void 0, me = ((ve = (fe = (he = n.radial) == null ? void 0 : he.rings) == null ? void 0 : fe.find((S) => S.key === $)) == null ? void 0 : ve.label) ?? $;
|
|
633
|
+
return /* @__PURE__ */ A(Kt, { children: [
|
|
634
|
+
$ && $ !== ue && /* @__PURE__ */ i("li", { className: "lens-chart-legend-heading", children: me }),
|
|
635
|
+
/* @__PURE__ */ i("li", { className: "lens-chart-legend-item", children: /* @__PURE__ */ A(
|
|
636
|
+
"button",
|
|
637
|
+
{
|
|
638
|
+
"aria-pressed": !D,
|
|
639
|
+
className: `lens-chart-legend-toggle${D ? " lens-chart-legend-hidden" : ""}`,
|
|
640
|
+
"data-testid": `lens-panel-${n.id}-legend-series-${Y}`,
|
|
641
|
+
onClick: () => c(W),
|
|
642
|
+
onDoubleClick: () => Se(W),
|
|
643
|
+
title: v("chart.legendToggleHint", "Click to toggle · double-click to isolate"),
|
|
644
|
+
type: "button",
|
|
645
|
+
children: [
|
|
646
|
+
/* @__PURE__ */ i(
|
|
647
|
+
"span",
|
|
648
|
+
{
|
|
649
|
+
"aria-hidden": "true",
|
|
650
|
+
className: "lens-chart-legend-mark",
|
|
651
|
+
style: { background: G(z, s, Y) }
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
/* @__PURE__ */ i("span", { className: "lens-chart-legend-label", children: z }),
|
|
655
|
+
Re(s) !== "none" && /* @__PURE__ */ i("span", { className: "lens-chart-legend-value", children: Re(s) === "percent" ? $t(I.shares.get(s), (g = h.meta) == null ? void 0 : g.locale, L ? (w = n.format[L]) == null ? void 0 : w.decimalSeparator : void 0) : ee(I.valueByKey.get(W)) }),
|
|
656
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", className: "lens-chart-legend-visibility", children: D ? /* @__PURE__ */ i(ro, {}) : /* @__PURE__ */ i(so, {}) })
|
|
657
|
+
]
|
|
658
|
+
}
|
|
659
|
+
) }, `${W}-${s}`)
|
|
660
|
+
] }, `${W}-${s}`);
|
|
661
|
+
}) }),
|
|
662
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", className: "lens-chart-legend-edge lens-chart-legend-edge-top" }),
|
|
663
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", className: "lens-chart-legend-edge lens-chart-legend-edge-bottom" })
|
|
664
|
+
]
|
|
665
|
+
}
|
|
666
|
+
),
|
|
667
|
+
(U > 0 || H) && /* @__PURE__ */ i("button", { className: "lens-chart-legend-overflow", onClick: () => ne((s) => !s), type: "button", children: H ? v("chart.legendCollapse", "Show fewer") : v("chart.legendMore", "{count} more", { count: String(U) }) })
|
|
668
|
+
] });
|
|
669
|
+
}), xo = bt(function({ overlays: n, onToggle: t }) {
|
|
670
|
+
const r = Ke(), l = r("chart.legendOverlays", "Chart marks");
|
|
671
|
+
return /* @__PURE__ */ A("ul", { "aria-label": l, className: "lens-chart-legend lens-chart-overlay-legend", children: [
|
|
672
|
+
/* @__PURE__ */ i("li", { className: "lens-chart-legend-heading", children: l }),
|
|
673
|
+
n.map((c) => /* @__PURE__ */ i("li", { className: "lens-chart-legend-item", children: /* @__PURE__ */ A(
|
|
674
|
+
"button",
|
|
675
|
+
{
|
|
676
|
+
"aria-pressed": c.active,
|
|
677
|
+
className: `lens-chart-legend-toggle${c.active ? "" : " lens-chart-legend-hidden"}`,
|
|
678
|
+
onClick: () => t(c.id),
|
|
679
|
+
title: r("chart.legendToggleOverlay", "Show or hide this mark"),
|
|
680
|
+
type: "button",
|
|
681
|
+
children: [
|
|
682
|
+
/* @__PURE__ */ i(
|
|
683
|
+
"span",
|
|
684
|
+
{
|
|
685
|
+
"aria-hidden": "true",
|
|
686
|
+
className: "lens-chart-overlay-mark",
|
|
687
|
+
"data-stroke": c.stroke,
|
|
688
|
+
style: { "--lens-overlay-ink": `var(${Ht(c.tone)})` }
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
/* @__PURE__ */ i("span", { className: "lens-chart-legend-label", children: c.label }),
|
|
692
|
+
c.detail && /* @__PURE__ */ A(Ee, { children: [
|
|
693
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", className: "lens-chart-legend-separator", children: "·" }),
|
|
694
|
+
/* @__PURE__ */ i("span", { className: "lens-chart-legend-value", children: c.detail })
|
|
695
|
+
] })
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
) }, c.id))
|
|
699
|
+
] });
|
|
700
|
+
});
|
|
701
|
+
export {
|
|
702
|
+
To as ChartPanel,
|
|
703
|
+
wt as collapseExpandableTopN,
|
|
704
|
+
yt as collapseMinorDonutSlices,
|
|
705
|
+
Ct as donutRemainderKey,
|
|
706
|
+
Oe as legendKey,
|
|
707
|
+
vt as rowIndexForKey,
|
|
708
|
+
wo as topNGroupField
|
|
709
|
+
};
|