@actionexec/dashboards 0.5.5 → 0.7.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/{ColorPaletteSelector-B4ojsspD.js → ColorPaletteSelector-BSAe2YMH.js} +233 -202
- package/dist/ColorPaletteSelector-BSAe2YMH.js.map +1 -0
- package/dist/Dashboard.d.ts +26 -7
- package/dist/hooks/useGridGeometry.d.ts +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +493 -336
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +3 -1
- package/dist/internals.js +45 -35
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +26 -3
- package/dist/utils/grid.d.ts +77 -0
- package/dist/widgets/TableWidget.d.ts +6 -0
- package/package.json +8 -2
- package/dist/ColorPaletteSelector-B4ojsspD.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,119 +1,201 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { PieChart as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const [
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
}).catch((
|
|
14
|
-
|
|
1
|
+
import { jsxs as w, jsx as l, Fragment as ae } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useRef as C, useEffect as O, useCallback as R, useMemo as Q } from "react";
|
|
3
|
+
import { a1 as ne, a2 as le, r as H, v as G, w as V, y as ie, $ as se, V as z, Y as Z, q as J, L as D, Z as ce, l as K, u as oe, K as de, I as ue, e as he, Q as ge, O as me, c as fe, x as pe, z as be, n as _e, G as j, C as we, o as ve } from "./ColorPaletteSelector-BSAe2YMH.js";
|
|
4
|
+
import { a3 as ft } from "./ColorPaletteSelector-BSAe2YMH.js";
|
|
5
|
+
import { PieChart as ye, Pie as Ne, Cell as ke, Tooltip as B, LineChart as Se, Line as $e, AreaChart as Ce, Area as Re, BarChart as xe, Bar as Me, CartesianGrid as Fe, XAxis as Le, YAxis as Te, Legend as Ae } from "recharts";
|
|
6
|
+
const Ie = 300;
|
|
7
|
+
function We(e) {
|
|
8
|
+
const [t, a] = L(null), [n, r] = L(null), [i, c] = L({}), [s, g] = L({}), [o, d] = L(null), [u, h] = L(!0), [N, m] = L(null), _ = C(), y = C(!1);
|
|
9
|
+
O(() => {
|
|
10
|
+
let S = !1;
|
|
11
|
+
return ne(e).then((v) => {
|
|
12
|
+
S || a(v);
|
|
13
|
+
}).catch((v) => {
|
|
14
|
+
S || m(v.message);
|
|
15
15
|
}), () => {
|
|
16
|
-
|
|
16
|
+
S = !0;
|
|
17
17
|
};
|
|
18
|
-
}, [
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}).catch((
|
|
25
|
-
},
|
|
26
|
-
|
|
18
|
+
}, [e]), O(() => {
|
|
19
|
+
if (t)
|
|
20
|
+
return _.current && clearTimeout(_.current), _.current = setTimeout(() => {
|
|
21
|
+
const S = Ee(i, s);
|
|
22
|
+
h(!0), le(e, S).then((v) => {
|
|
23
|
+
r(v), !y.current && v.applied && (y.current = !0, c((f) => ({ ...Oe(v.applied), ...f }))), m(null);
|
|
24
|
+
}).catch((v) => m(v.message)).finally(() => h(!1));
|
|
25
|
+
}, Ie), () => {
|
|
26
|
+
_.current && clearTimeout(_.current);
|
|
27
27
|
};
|
|
28
|
-
}, [
|
|
29
|
-
const
|
|
30
|
-
c((
|
|
31
|
-
}, []),
|
|
32
|
-
|
|
33
|
-
}, []),
|
|
34
|
-
d(
|
|
35
|
-
}, []),
|
|
36
|
-
() => o ?? (
|
|
37
|
-
[o,
|
|
28
|
+
}, [e, t, i, s]);
|
|
29
|
+
const T = R((S, v) => {
|
|
30
|
+
c((f) => ({ ...f, [S]: v }));
|
|
31
|
+
}, []), k = R((S, v) => {
|
|
32
|
+
g((f) => ({ ...f, [S]: v }));
|
|
33
|
+
}, []), E = R((S) => {
|
|
34
|
+
d(S);
|
|
35
|
+
}, []), F = Q(
|
|
36
|
+
() => o ?? (t == null ? void 0 : t.palette) ?? [],
|
|
37
|
+
[o, t]
|
|
38
38
|
);
|
|
39
39
|
return {
|
|
40
|
-
layout:
|
|
41
|
-
renderData:
|
|
42
|
-
loading:
|
|
43
|
-
error:
|
|
40
|
+
layout: t,
|
|
41
|
+
renderData: n,
|
|
42
|
+
loading: u,
|
|
43
|
+
error: N,
|
|
44
44
|
filters: i,
|
|
45
45
|
variables: s,
|
|
46
|
-
palette:
|
|
47
|
-
setFilter:
|
|
48
|
-
setVariable:
|
|
49
|
-
setPalette:
|
|
46
|
+
palette: F,
|
|
47
|
+
setFilter: T,
|
|
48
|
+
setVariable: k,
|
|
49
|
+
setPalette: E
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
for (const [
|
|
55
|
-
if (
|
|
56
|
-
const [i, c] =
|
|
57
|
-
i && (
|
|
52
|
+
function Ee(e, t) {
|
|
53
|
+
const a = {};
|
|
54
|
+
for (const [n, r] of Object.entries(e))
|
|
55
|
+
if (r.includes("|")) {
|
|
56
|
+
const [i, c] = r.split("|");
|
|
57
|
+
i && (a.f_date_start = i), c && (a.f_date_end = c);
|
|
58
58
|
} else
|
|
59
|
-
|
|
60
|
-
for (const [
|
|
61
|
-
|
|
62
|
-
return
|
|
59
|
+
a[`f_${n}`] = r;
|
|
60
|
+
for (const [n, r] of Object.entries(t))
|
|
61
|
+
a[`v_${n}`] = String(r);
|
|
62
|
+
return a;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
for (const [
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
} else Array.isArray(
|
|
71
|
-
return
|
|
64
|
+
function Oe(e) {
|
|
65
|
+
const t = {};
|
|
66
|
+
for (const [a, n] of Object.entries(e))
|
|
67
|
+
if (n && typeof n == "object" && "start" in n) {
|
|
68
|
+
const r = n;
|
|
69
|
+
t[a] = `${r.start || ""}|${r.end || ""}`;
|
|
70
|
+
} else Array.isArray(n) ? t[a] = n.join(H) : typeof n == "string" && (t[a] = n);
|
|
71
|
+
return t;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
const Pe = (e) => {
|
|
74
|
+
var t, a;
|
|
75
|
+
return ((a = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : a.inlineSize) ?? e.target.offsetWidth;
|
|
76
|
+
}, De = (e) => {
|
|
77
|
+
var t, a;
|
|
78
|
+
return ((a = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : a.blockSize) ?? e.target.offsetHeight;
|
|
79
|
+
};
|
|
80
|
+
function Ye(e, t, a) {
|
|
81
|
+
return e === void 0 ? 0 : e === "auto" ? ie(t, a) : Math.max(0, e);
|
|
82
|
+
}
|
|
83
|
+
function He(e) {
|
|
84
|
+
let t = e.parentElement;
|
|
85
|
+
for (; t && t !== document.body && t !== document.documentElement; ) {
|
|
86
|
+
const { overflowY: a } = getComputedStyle(t);
|
|
87
|
+
if (a !== "visible")
|
|
88
|
+
return a === "hidden" || a === "clip" ? t : null;
|
|
89
|
+
t = t.parentElement;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function ze(e) {
|
|
94
|
+
const t = C(e);
|
|
95
|
+
t.current = e;
|
|
96
|
+
const a = C(null), n = C(null), r = C(null), i = C(null), c = C(null), s = C(0), g = C(0), o = C(!1), d = C(!1), u = C(-1), [h, N] = L(!1), m = R((f) => {
|
|
97
|
+
const p = n.current;
|
|
98
|
+
if (d.current || t.current.silenceWarnings || !p) return;
|
|
99
|
+
const $ = He(p);
|
|
100
|
+
!$ || $.clientHeight >= f.gridHeight || (d.current = !0, console.warn(
|
|
101
|
+
`[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(f.gridHeight)}px de altura, mas o ancestral com overflow oculto tem ${$.clientHeight}px. A altura do dashboard varia com a largura — use a prop onGeometryChange para dimensionar o container, ou troque o overflow para auto. Passe silenceWarnings para desligar este aviso.`
|
|
102
|
+
));
|
|
103
|
+
}, []), _ = R(() => {
|
|
104
|
+
var W, A;
|
|
105
|
+
if (!a.current) return;
|
|
106
|
+
const { columns: f, cellAspect: p } = t.current, $ = s.current, I = V($, f), b = {
|
|
107
|
+
containerWidth: $,
|
|
108
|
+
cellWidth: I,
|
|
109
|
+
cellHeight: G(I, p),
|
|
110
|
+
gridHeight: g.current,
|
|
111
|
+
stacked: o.current
|
|
112
|
+
}, x = c.current;
|
|
113
|
+
x && x.containerWidth === b.containerWidth && x.cellWidth === b.cellWidth && x.cellHeight === b.cellHeight && x.gridHeight === b.gridHeight && x.stacked === b.stacked || (c.current = b, (A = (W = t.current).onGeometryChange) == null || A.call(W, b), m(b));
|
|
114
|
+
}, [m]), y = R((f = !1) => {
|
|
115
|
+
const p = a.current;
|
|
116
|
+
if (!p) return;
|
|
117
|
+
const $ = s.current;
|
|
118
|
+
if (!f && $ === u.current) return;
|
|
119
|
+
u.current = $;
|
|
120
|
+
const { columns: I, cellAspect: b, stackBelow: x } = t.current, M = V($, I);
|
|
121
|
+
p.style.setProperty("--dash-cell-h", `${G(M, b)}px`);
|
|
122
|
+
const W = Ye(x, I, b), A = W > 0 && $ > 0 && $ < W;
|
|
123
|
+
A !== o.current && (o.current = A, N(A));
|
|
124
|
+
}, []), T = R(() => {
|
|
125
|
+
i.current !== null && (cancelAnimationFrame(i.current), i.current = null);
|
|
126
|
+
}, []), k = R(() => {
|
|
127
|
+
i.current === null && (i.current = requestAnimationFrame(() => {
|
|
128
|
+
i.current = null, y(), _();
|
|
129
|
+
}));
|
|
130
|
+
}, [y, _]), E = R((f) => {
|
|
131
|
+
for (const p of f)
|
|
132
|
+
p.target === a.current ? s.current = Math.round(Pe(p)) : p.target === n.current && (g.current = De(p));
|
|
133
|
+
k();
|
|
134
|
+
}, [k]), F = R(() => r.current ? r.current : typeof ResizeObserver > "u" ? null : (r.current = new ResizeObserver(E), r.current), [E]), S = R((f) => {
|
|
135
|
+
const p = F();
|
|
136
|
+
a.current && (p == null || p.unobserve(a.current)), a.current = f, f && (p == null || p.observe(f), s.current = Math.round(f.getBoundingClientRect().width), y(!0), k());
|
|
137
|
+
}, [y, F, k]), v = R((f) => {
|
|
138
|
+
const p = F();
|
|
139
|
+
if (n.current && (p == null || p.unobserve(n.current)), n.current = f, !f) {
|
|
140
|
+
g.current = 0;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
p == null || p.observe(f), g.current = f.getBoundingClientRect().height, k();
|
|
144
|
+
}, [F, k]);
|
|
145
|
+
return O(() => {
|
|
146
|
+
const f = F();
|
|
147
|
+
return a.current && (f == null || f.observe(a.current)), n.current && (f == null || f.observe(n.current)), () => {
|
|
148
|
+
var p;
|
|
149
|
+
(p = r.current) == null || p.disconnect(), r.current = null, T();
|
|
150
|
+
};
|
|
151
|
+
}, [F, T]), O(() => {
|
|
152
|
+
a.current && (y(!0), k());
|
|
153
|
+
}, [e.columns, e.cellAspect, e.stackBelow, y, k]), { rootRef: S, gridRef: v, stacked: h };
|
|
154
|
+
}
|
|
155
|
+
function Ge({ data: e, label: t }) {
|
|
156
|
+
const a = t || String(e.label || ""), n = String(e.formatted || "-"), r = e.comparison, i = (r == null ? void 0 : r.trend) === "up" ? "widget-kpi__trend--up" : (r == null ? void 0 : r.trend) === "down" ? "widget-kpi__trend--down" : "", c = (r == null ? void 0 : r.trend) === "up" ? "↑" : (r == null ? void 0 : r.trend) === "down" ? "↓" : "";
|
|
157
|
+
return /* @__PURE__ */ w("div", { className: "widget widget-kpi", children: [
|
|
158
|
+
/* @__PURE__ */ l("span", { className: "widget-kpi__label", children: a }),
|
|
159
|
+
/* @__PURE__ */ l("span", { className: "widget-kpi__value", children: n }),
|
|
160
|
+
r && r.variance_pct != null && /* @__PURE__ */ w("div", { className: `widget-kpi__trend ${i}`, children: [
|
|
161
|
+
/* @__PURE__ */ w("span", { className: "widget-kpi__variance", children: [
|
|
80
162
|
c,
|
|
81
163
|
" ",
|
|
82
|
-
|
|
83
|
-
|
|
164
|
+
r.variance_pct > 0 ? "+" : "",
|
|
165
|
+
r.variance_pct.toFixed(1),
|
|
84
166
|
"%"
|
|
85
167
|
] }),
|
|
86
|
-
|
|
168
|
+
r.label && /* @__PURE__ */ l("span", { className: "widget-kpi__trend-label", children: r.label })
|
|
87
169
|
] })
|
|
88
170
|
] });
|
|
89
171
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
92
|
-
if (
|
|
93
|
-
if (
|
|
94
|
-
return `M ${
|
|
95
|
-
const
|
|
96
|
-
return `M ${
|
|
172
|
+
const Ve = "var(--bg-elevated)";
|
|
173
|
+
function X(e, t, a, n) {
|
|
174
|
+
if (n <= 0) return "";
|
|
175
|
+
if (n >= 1)
|
|
176
|
+
return `M ${e - a} ${t} A ${a} ${a} 0 0 1 ${e} ${t - a} A ${a} ${a} 0 0 1 ${e + a} ${t}`;
|
|
177
|
+
const r = n * Math.PI, i = e - a * Math.cos(r), c = t - a * Math.sin(r);
|
|
178
|
+
return `M ${e - a} ${t} A ${a} ${a} 0 0 1 ${i} ${c}`;
|
|
97
179
|
}
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
return
|
|
180
|
+
function q(e) {
|
|
181
|
+
const t = Math.abs(e);
|
|
182
|
+
return t >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : t >= 1e3 ? `${(e / 1e3).toFixed(1)}K` : e.toLocaleString("pt-BR");
|
|
101
183
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
/* @__PURE__ */ l("span", { className: "widget-gauge__label", children:
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */ l("path", { d:
|
|
109
|
-
|
|
184
|
+
function Ke({ data: e, palette: t, label: a }) {
|
|
185
|
+
const n = a || String(e.label || ""), r = typeof e.value == "number" ? e.value : null, i = r != null ? q(r) : "-", c = String(e.formatted || "-"), s = typeof e.ratio == "number" ? e.ratio : 0, g = e.target_value, o = e.comparison_label, d = s >= 1, u = Math.min(Math.max(s, 0), 1), h = d ? "var(--action-green)" : s >= 0.7 ? t[0] || "var(--color-info)" : s >= 0.4 ? "var(--color-warning)" : "var(--color-error)", N = g != null ? q(g) : "-", m = 50, _ = 50, y = 44, T = 10;
|
|
186
|
+
return /* @__PURE__ */ w("div", { className: "widget widget-gauge", children: [
|
|
187
|
+
/* @__PURE__ */ l("span", { className: "widget-gauge__label", children: n }),
|
|
188
|
+
/* @__PURE__ */ w("div", { className: "widget-gauge__chart", children: [
|
|
189
|
+
/* @__PURE__ */ w("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", children: [
|
|
190
|
+
/* @__PURE__ */ l("path", { d: X(m, _, y, 1), fill: "none", stroke: Ve, strokeWidth: T, strokeLinecap: "butt" }),
|
|
191
|
+
u > 0 && /* @__PURE__ */ l("path", { d: X(m, _, y, u), fill: "none", stroke: h, strokeWidth: T, strokeLinecap: "butt" })
|
|
110
192
|
] }),
|
|
111
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ w("div", { className: "widget-gauge__center", children: [
|
|
112
194
|
/* @__PURE__ */ l("span", { className: "widget-gauge__percent", children: c }),
|
|
113
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ w("span", { className: "widget-gauge__comparison", children: [
|
|
114
196
|
i,
|
|
115
197
|
" / ",
|
|
116
|
-
|
|
198
|
+
N
|
|
117
199
|
] }),
|
|
118
200
|
d && /* @__PURE__ */ l("span", { className: "widget-gauge__badge", children: o || "Meta batida" }),
|
|
119
201
|
!d && o && /* @__PURE__ */ l("span", { className: "widget-gauge__comparison", children: o })
|
|
@@ -121,195 +203,248 @@ function ye({ data: a, palette: r, label: n }) {
|
|
|
121
203
|
] })
|
|
122
204
|
] });
|
|
123
205
|
}
|
|
124
|
-
const
|
|
206
|
+
const U = { fontSize: 10, fill: "var(--text-muted)" }, je = "var(--bg-elevated)", ee = {
|
|
125
207
|
backgroundColor: "var(--bg-elevated)",
|
|
126
208
|
border: "1px solid var(--bg-paper)",
|
|
127
209
|
borderRadius: "6px",
|
|
128
210
|
color: "var(--text-primary)"
|
|
129
|
-
},
|
|
211
|
+
}, te = {
|
|
130
212
|
color: "var(--text-primary)",
|
|
131
213
|
fontWeight: 600
|
|
132
214
|
};
|
|
133
|
-
function
|
|
134
|
-
var
|
|
135
|
-
const
|
|
136
|
-
return typeof
|
|
215
|
+
function re(e, t) {
|
|
216
|
+
var r;
|
|
217
|
+
const a = Array.isArray(t) ? t[0] : void 0, n = (r = a == null ? void 0 : a.payload) == null ? void 0 : r.tooltipLabel;
|
|
218
|
+
return typeof n == "string" && n ? n : String(e ?? "");
|
|
137
219
|
}
|
|
138
|
-
function
|
|
139
|
-
const [
|
|
140
|
-
return
|
|
141
|
-
const
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
220
|
+
function Xe(e) {
|
|
221
|
+
const [t, a] = L({ width: 0, height: 0 });
|
|
222
|
+
return O(() => {
|
|
223
|
+
const n = e.current;
|
|
224
|
+
if (!n) return;
|
|
225
|
+
const r = new ResizeObserver(([i]) => {
|
|
144
226
|
const { width: c, height: s } = i.contentRect;
|
|
145
|
-
|
|
146
|
-
(
|
|
227
|
+
a(
|
|
228
|
+
(g) => g.width !== Math.floor(c) || g.height !== Math.floor(s) ? { width: Math.floor(c), height: Math.floor(s) } : g
|
|
147
229
|
);
|
|
148
230
|
});
|
|
149
|
-
return
|
|
150
|
-
}, [
|
|
231
|
+
return r.observe(n), () => r.disconnect();
|
|
232
|
+
}, [e]), t;
|
|
151
233
|
}
|
|
152
|
-
function
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */ l(
|
|
155
|
-
/* @__PURE__ */ l(
|
|
156
|
-
/* @__PURE__ */ l(
|
|
234
|
+
function Y({ Chart: e, chartData: t, xKey: a, series: n, palette: r, renderSeries: i, width: c, height: s }) {
|
|
235
|
+
return /* @__PURE__ */ w(e, { data: t, width: c, height: s, children: [
|
|
236
|
+
/* @__PURE__ */ l(Fe, { strokeDasharray: "3 3", stroke: je }),
|
|
237
|
+
/* @__PURE__ */ l(Le, { dataKey: a, tick: U }),
|
|
238
|
+
/* @__PURE__ */ l(Te, { tick: U }),
|
|
157
239
|
/* @__PURE__ */ l(
|
|
158
|
-
|
|
240
|
+
B,
|
|
159
241
|
{
|
|
160
|
-
contentStyle:
|
|
161
|
-
labelStyle:
|
|
162
|
-
labelFormatter:
|
|
242
|
+
contentStyle: ee,
|
|
243
|
+
labelStyle: te,
|
|
244
|
+
labelFormatter: re,
|
|
163
245
|
cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
|
|
164
246
|
}
|
|
165
247
|
),
|
|
166
|
-
|
|
167
|
-
|
|
248
|
+
n.length > 1 && /* @__PURE__ */ l(Ae, {}),
|
|
249
|
+
n.map((g, o) => i(g, r[o % r.length], o))
|
|
168
250
|
] });
|
|
169
251
|
}
|
|
170
|
-
function
|
|
171
|
-
const
|
|
172
|
-
var
|
|
252
|
+
function qe({ data: e, palette: t, label: a }) {
|
|
253
|
+
const n = String(e.chartType || "bar"), r = a || String(e.label || ""), i = String(e.xKey || "label"), c = e.series || [], s = e.data || [], g = C(null), { width: o, height: d } = Xe(g), u = () => {
|
|
254
|
+
var N;
|
|
173
255
|
if (o <= 0 || d <= 0) return null;
|
|
174
|
-
if (
|
|
175
|
-
return /* @__PURE__ */
|
|
256
|
+
if (n === "pie")
|
|
257
|
+
return /* @__PURE__ */ w(ye, { width: o, height: d, children: [
|
|
176
258
|
/* @__PURE__ */ l(
|
|
177
|
-
|
|
259
|
+
Ne,
|
|
178
260
|
{
|
|
179
261
|
data: s,
|
|
180
|
-
dataKey: ((
|
|
262
|
+
dataKey: ((N = c[0]) == null ? void 0 : N.key) || "s0",
|
|
181
263
|
nameKey: i,
|
|
182
264
|
cx: "50%",
|
|
183
265
|
cy: "50%",
|
|
184
266
|
outerRadius: "75%",
|
|
185
|
-
label: ({ name:
|
|
267
|
+
label: ({ name: m, percent: _ }) => `${m}: ${(_ * 100).toFixed(0)}%`,
|
|
186
268
|
labelLine: !1,
|
|
187
|
-
children: s.map((
|
|
269
|
+
children: s.map((m, _) => /* @__PURE__ */ l(ke, { fill: t[_ % t.length] }, _))
|
|
188
270
|
}
|
|
189
271
|
),
|
|
190
272
|
/* @__PURE__ */ l(
|
|
191
|
-
|
|
273
|
+
B,
|
|
192
274
|
{
|
|
193
|
-
contentStyle:
|
|
194
|
-
labelStyle:
|
|
195
|
-
labelFormatter:
|
|
275
|
+
contentStyle: ee,
|
|
276
|
+
labelStyle: te,
|
|
277
|
+
labelFormatter: re
|
|
196
278
|
}
|
|
197
279
|
)
|
|
198
280
|
] });
|
|
199
|
-
const
|
|
200
|
-
return
|
|
201
|
-
|
|
281
|
+
const h = { chartData: s, xKey: i, series: c, palette: t, width: o, height: d };
|
|
282
|
+
return n === "line" ? /* @__PURE__ */ l(Y, { ...h, Chart: Se, renderSeries: (m, _) => /* @__PURE__ */ l(
|
|
283
|
+
$e,
|
|
202
284
|
{
|
|
203
285
|
type: "monotone",
|
|
204
|
-
dataKey:
|
|
205
|
-
name:
|
|
206
|
-
stroke:
|
|
286
|
+
dataKey: m.key,
|
|
287
|
+
name: m.label,
|
|
288
|
+
stroke: _,
|
|
207
289
|
strokeWidth: 2,
|
|
208
290
|
dot: s.length <= 31
|
|
209
291
|
},
|
|
210
|
-
|
|
211
|
-
) }) :
|
|
212
|
-
|
|
292
|
+
m.key
|
|
293
|
+
) }) : n === "area" ? /* @__PURE__ */ l(Y, { ...h, Chart: Ce, renderSeries: (m, _) => /* @__PURE__ */ l(
|
|
294
|
+
Re,
|
|
213
295
|
{
|
|
214
296
|
type: "monotone",
|
|
215
|
-
dataKey:
|
|
216
|
-
name:
|
|
217
|
-
fill:
|
|
218
|
-
stroke:
|
|
297
|
+
dataKey: m.key,
|
|
298
|
+
name: m.label,
|
|
299
|
+
fill: _,
|
|
300
|
+
stroke: _,
|
|
219
301
|
fillOpacity: 0.3
|
|
220
302
|
},
|
|
221
|
-
|
|
222
|
-
) }) : /* @__PURE__ */ l(
|
|
223
|
-
|
|
303
|
+
m.key
|
|
304
|
+
) }) : /* @__PURE__ */ l(Y, { ...h, Chart: xe, renderSeries: (m, _) => /* @__PURE__ */ l(
|
|
305
|
+
Me,
|
|
224
306
|
{
|
|
225
|
-
dataKey:
|
|
226
|
-
name:
|
|
227
|
-
fill:
|
|
307
|
+
dataKey: m.key,
|
|
308
|
+
name: m.label,
|
|
309
|
+
fill: _,
|
|
228
310
|
radius: [3, 3, 0, 0]
|
|
229
311
|
},
|
|
230
|
-
|
|
312
|
+
m.key
|
|
231
313
|
) });
|
|
232
314
|
};
|
|
233
|
-
return /* @__PURE__ */
|
|
234
|
-
|
|
235
|
-
/* @__PURE__ */ l("div", { ref:
|
|
315
|
+
return /* @__PURE__ */ w("div", { className: "widget widget-chart", children: [
|
|
316
|
+
r && /* @__PURE__ */ l("h4", { className: "widget-chart__title", children: r }),
|
|
317
|
+
/* @__PURE__ */ l("div", { ref: g, className: "widget-chart__container", children: s.length === 0 ? /* @__PURE__ */ l("div", { className: "widget-chart__empty", children: "Sem dados" }) : u() })
|
|
318
|
+
] });
|
|
319
|
+
}
|
|
320
|
+
function Ue(e, t) {
|
|
321
|
+
if (e == null || e === "") return "-";
|
|
322
|
+
const a = typeof e == "number" ? e : Number(e), n = e !== "" && !Number.isNaN(a);
|
|
323
|
+
switch (t) {
|
|
324
|
+
case "currency":
|
|
325
|
+
return n ? a.toLocaleString("pt-BR", { style: "currency", currency: "BRL" }) : String(e);
|
|
326
|
+
case "integer":
|
|
327
|
+
return n ? Math.round(a).toLocaleString("pt-BR") : String(e);
|
|
328
|
+
case "number":
|
|
329
|
+
return n ? a.toLocaleString("pt-BR", { maximumFractionDigits: 1 }) : String(e);
|
|
330
|
+
case "percentage":
|
|
331
|
+
return n ? `${a > 0 ? "+" : ""}${Math.round(a)}%` : String(e);
|
|
332
|
+
default:
|
|
333
|
+
return String(e);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function Qe({ data: e, label: t }) {
|
|
337
|
+
var o;
|
|
338
|
+
const [a, n] = L(0), r = e.columns || [], i = e.tabs || [], c = i.length > 0, s = c ? ((o = i[Math.min(a, i.length - 1)]) == null ? void 0 : o.rows) || [] : e.rows || [], g = t || String(e.label || "");
|
|
339
|
+
return r.length === 0 ? /* @__PURE__ */ w("div", { className: "widget widget-table", children: [
|
|
340
|
+
g && /* @__PURE__ */ l("span", { className: "widget-table__label", children: g }),
|
|
341
|
+
/* @__PURE__ */ l("span", { className: "widget-table__empty", children: "Configure as colunas da tabela." })
|
|
342
|
+
] }) : /* @__PURE__ */ w("div", { className: "widget widget-table", children: [
|
|
343
|
+
g && /* @__PURE__ */ l("span", { className: "widget-table__label", children: g }),
|
|
344
|
+
c && /* @__PURE__ */ l("div", { className: "widget-table__tabs", role: "tablist", children: i.map((d, u) => /* @__PURE__ */ l(
|
|
345
|
+
"button",
|
|
346
|
+
{
|
|
347
|
+
type: "button",
|
|
348
|
+
role: "tab",
|
|
349
|
+
"aria-selected": u === a,
|
|
350
|
+
className: `widget-table__tab${u === a ? " widget-table__tab--active" : ""}`,
|
|
351
|
+
onClick: () => n(u),
|
|
352
|
+
children: d.label
|
|
353
|
+
},
|
|
354
|
+
u
|
|
355
|
+
)) }),
|
|
356
|
+
/* @__PURE__ */ l("div", { className: "widget-table__scroll", children: /* @__PURE__ */ w("table", { className: "widget-table__table", children: [
|
|
357
|
+
/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: r.map((d) => {
|
|
358
|
+
const u = !!d.format && d.format !== "text";
|
|
359
|
+
return /* @__PURE__ */ l("th", { className: `widget-table__th${u ? " widget-table__th--num" : ""}`, children: d.label || d.key }, d.key);
|
|
360
|
+
}) }) }),
|
|
361
|
+
/* @__PURE__ */ l("tbody", { children: s.length === 0 ? /* @__PURE__ */ l("tr", { children: /* @__PURE__ */ l("td", { className: "widget-table__td widget-table__empty", colSpan: r.length, children: "Sem dados" }) }) : s.map((d, u) => /* @__PURE__ */ l("tr", { children: r.map((h) => {
|
|
362
|
+
const N = d[h.key], m = !!h.format && h.format !== "text";
|
|
363
|
+
let _ = "";
|
|
364
|
+
if (h.format === "percentage") {
|
|
365
|
+
const y = Number(N);
|
|
366
|
+
Number.isNaN(y) || (_ = y > 0 ? " widget-table__td--up" : y < 0 ? " widget-table__td--down" : "");
|
|
367
|
+
}
|
|
368
|
+
return /* @__PURE__ */ l("td", { className: `widget-table__td${m ? " widget-table__td--num" : ""}${_}`, children: Ue(N, h.format) }, h.key);
|
|
369
|
+
}) }, u)) })
|
|
370
|
+
] }) })
|
|
236
371
|
] });
|
|
237
372
|
}
|
|
238
|
-
function
|
|
239
|
-
const i =
|
|
240
|
-
return /* @__PURE__ */
|
|
373
|
+
function Ze({ config: e, value: t, options: a = [], dateBounds: n, onChange: r }) {
|
|
374
|
+
const i = e.filterType || "select", c = e.label || "Filtro", s = e.dateFilterMode || "range";
|
|
375
|
+
return /* @__PURE__ */ w("div", { className: "widget-filter", children: [
|
|
241
376
|
/* @__PURE__ */ l("label", { className: "widget-filter__label", children: c }),
|
|
242
|
-
i === "date_range" ? s === "yearly" ? /* @__PURE__ */ l(
|
|
243
|
-
|
|
377
|
+
i === "date_range" ? s === "yearly" ? /* @__PURE__ */ l(Be, { value: t, dateBounds: n, onChange: r }) : s === "monthly" ? /* @__PURE__ */ l(et, { value: t, dateBounds: n, onChange: r }) : s === "weekly" ? /* @__PURE__ */ l(tt, { value: t, dateBounds: n, onChange: r }) : /* @__PURE__ */ l(Je, { value: t, dateBounds: n, onChange: r }) : /* @__PURE__ */ l(
|
|
378
|
+
rt,
|
|
244
379
|
{
|
|
245
|
-
value:
|
|
246
|
-
options:
|
|
380
|
+
value: t,
|
|
381
|
+
options: a,
|
|
247
382
|
multi: i === "multi_select",
|
|
248
|
-
searchable:
|
|
249
|
-
onChange:
|
|
383
|
+
searchable: e.searchable || !1,
|
|
384
|
+
onChange: r
|
|
250
385
|
}
|
|
251
386
|
)
|
|
252
387
|
] });
|
|
253
388
|
}
|
|
254
|
-
function
|
|
255
|
-
const [
|
|
256
|
-
return /* @__PURE__ */
|
|
389
|
+
function Je({ value: e, dateBounds: t, onChange: a }) {
|
|
390
|
+
const [n, r] = e ? e.split("|") : ["", ""];
|
|
391
|
+
return /* @__PURE__ */ w("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
|
|
257
392
|
/* @__PURE__ */ l(
|
|
258
|
-
|
|
393
|
+
K,
|
|
259
394
|
{
|
|
260
|
-
value:
|
|
261
|
-
minIso:
|
|
262
|
-
maxIso:
|
|
395
|
+
value: n,
|
|
396
|
+
minIso: t == null ? void 0 : t.min,
|
|
397
|
+
maxIso: r || (t == null ? void 0 : t.max),
|
|
263
398
|
selectsStart: !0,
|
|
264
|
-
startIso:
|
|
265
|
-
endIso:
|
|
399
|
+
startIso: n,
|
|
400
|
+
endIso: r,
|
|
266
401
|
placeholder: "Data inicial",
|
|
267
|
-
onChange: (i) =>
|
|
402
|
+
onChange: (i) => a(`${i}|${r}`)
|
|
268
403
|
}
|
|
269
404
|
),
|
|
270
405
|
/* @__PURE__ */ l(
|
|
271
|
-
|
|
406
|
+
K,
|
|
272
407
|
{
|
|
273
|
-
value:
|
|
274
|
-
minIso:
|
|
275
|
-
maxIso:
|
|
408
|
+
value: r,
|
|
409
|
+
minIso: n || (t == null ? void 0 : t.min),
|
|
410
|
+
maxIso: t == null ? void 0 : t.max,
|
|
276
411
|
selectsEnd: !0,
|
|
277
|
-
startIso:
|
|
278
|
-
endIso:
|
|
412
|
+
startIso: n,
|
|
413
|
+
endIso: r,
|
|
279
414
|
placeholder: "Data final",
|
|
280
|
-
onChange: (i) =>
|
|
415
|
+
onChange: (i) => a(`${n}|${i}`)
|
|
281
416
|
}
|
|
282
417
|
)
|
|
283
418
|
] });
|
|
284
419
|
}
|
|
285
|
-
function
|
|
286
|
-
const [
|
|
287
|
-
const d =
|
|
288
|
-
|
|
420
|
+
function Be({ value: e, dateBounds: t, onChange: a }) {
|
|
421
|
+
const [n] = e ? e.split("|") : [""], r = se(n), i = /* @__PURE__ */ new Date(), c = (r == null ? void 0 : r.year) ?? i.getFullYear(), s = z(t), g = (o) => {
|
|
422
|
+
const d = ue(o);
|
|
423
|
+
a(`${d.start}|${d.end}`);
|
|
289
424
|
};
|
|
290
425
|
return /* @__PURE__ */ l("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ l(
|
|
291
426
|
"select",
|
|
292
427
|
{
|
|
293
428
|
className: "widget-filter__select",
|
|
294
429
|
value: c,
|
|
295
|
-
onChange: (o) =>
|
|
430
|
+
onChange: (o) => g(parseInt(o.target.value)),
|
|
296
431
|
children: s.map((o) => /* @__PURE__ */ l("option", { value: o, children: o }, o))
|
|
297
432
|
}
|
|
298
433
|
) });
|
|
299
434
|
}
|
|
300
|
-
function
|
|
301
|
-
const [
|
|
302
|
-
const
|
|
303
|
-
|
|
435
|
+
function et({ value: e, dateBounds: t, onChange: a }) {
|
|
436
|
+
const [n] = e ? e.split("|") : [""], r = Z(n), i = /* @__PURE__ */ new Date(), c = (r == null ? void 0 : r.year) ?? i.getFullYear(), s = (r == null ? void 0 : r.month) ?? i.getMonth() + 1, g = z(t), o = (d, u) => {
|
|
437
|
+
const h = de(d, u);
|
|
438
|
+
a(`${h.start}|${h.end}`);
|
|
304
439
|
};
|
|
305
|
-
return /* @__PURE__ */
|
|
440
|
+
return /* @__PURE__ */ w("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
|
|
306
441
|
/* @__PURE__ */ l(
|
|
307
442
|
"select",
|
|
308
443
|
{
|
|
309
444
|
className: "widget-filter__select",
|
|
310
445
|
value: s,
|
|
311
446
|
onChange: (d) => o(c, parseInt(d.target.value)),
|
|
312
|
-
children:
|
|
447
|
+
children: J.map((d, u) => /* @__PURE__ */ l("option", { value: u + 1, children: d }, u + 1))
|
|
313
448
|
}
|
|
314
449
|
),
|
|
315
450
|
/* @__PURE__ */ l(
|
|
@@ -318,24 +453,24 @@ function Re({ value: a, dateBounds: r, onChange: n }) {
|
|
|
318
453
|
className: "widget-filter__select",
|
|
319
454
|
value: c,
|
|
320
455
|
onChange: (d) => o(parseInt(d.target.value), s),
|
|
321
|
-
children:
|
|
456
|
+
children: g.map((d) => /* @__PURE__ */ l("option", { value: d, children: d }, d))
|
|
322
457
|
}
|
|
323
458
|
)
|
|
324
459
|
] });
|
|
325
460
|
}
|
|
326
|
-
function
|
|
327
|
-
const [
|
|
328
|
-
return /* @__PURE__ */
|
|
461
|
+
function tt({ value: e, dateBounds: t, onChange: a }) {
|
|
462
|
+
const [n] = e ? e.split("|") : [""], r = Z(n), i = /* @__PURE__ */ new Date(), c = (r == null ? void 0 : r.year) ?? i.getFullYear(), s = (r == null ? void 0 : r.month) ?? i.getMonth() + 1, g = z(t), o = D(c, s), d = ce(n, c, s) || 1;
|
|
463
|
+
return /* @__PURE__ */ w("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
|
|
329
464
|
/* @__PURE__ */ l(
|
|
330
465
|
"select",
|
|
331
466
|
{
|
|
332
467
|
className: "widget-filter__select",
|
|
333
468
|
value: c,
|
|
334
|
-
onChange: (
|
|
335
|
-
const
|
|
336
|
-
|
|
469
|
+
onChange: (u) => {
|
|
470
|
+
const h = parseInt(u.target.value), m = D(h, s)[0];
|
|
471
|
+
m && a(`${m.start}|${m.end}`);
|
|
337
472
|
},
|
|
338
|
-
children:
|
|
473
|
+
children: g.map((u) => /* @__PURE__ */ l("option", { value: u, children: u }, u))
|
|
339
474
|
}
|
|
340
475
|
),
|
|
341
476
|
/* @__PURE__ */ l(
|
|
@@ -343,11 +478,11 @@ function xe({ value: a, dateBounds: r, onChange: n }) {
|
|
|
343
478
|
{
|
|
344
479
|
className: "widget-filter__select",
|
|
345
480
|
value: s,
|
|
346
|
-
onChange: (
|
|
347
|
-
const
|
|
348
|
-
|
|
481
|
+
onChange: (u) => {
|
|
482
|
+
const h = parseInt(u.target.value), m = D(c, h)[0];
|
|
483
|
+
m && a(`${m.start}|${m.end}`);
|
|
349
484
|
},
|
|
350
|
-
children:
|
|
485
|
+
children: J.map((u, h) => /* @__PURE__ */ l("option", { value: h + 1, children: u }, h + 1))
|
|
351
486
|
}
|
|
352
487
|
),
|
|
353
488
|
/* @__PURE__ */ l(
|
|
@@ -355,42 +490,42 @@ function xe({ value: a, dateBounds: r, onChange: n }) {
|
|
|
355
490
|
{
|
|
356
491
|
className: "widget-filter__select",
|
|
357
492
|
value: d,
|
|
358
|
-
onChange: (
|
|
359
|
-
const
|
|
360
|
-
|
|
493
|
+
onChange: (u) => {
|
|
494
|
+
const h = o[parseInt(u.target.value) - 1];
|
|
495
|
+
h && a(`${h.start}|${h.end}`);
|
|
361
496
|
},
|
|
362
|
-
children: o.map((
|
|
497
|
+
children: o.map((u) => /* @__PURE__ */ l("option", { value: u.index, children: u.label }, u.index))
|
|
363
498
|
}
|
|
364
499
|
)
|
|
365
500
|
] });
|
|
366
501
|
}
|
|
367
|
-
function
|
|
368
|
-
if (
|
|
502
|
+
function rt({ value: e, options: t, multi: a, searchable: n, onChange: r }) {
|
|
503
|
+
if (n)
|
|
369
504
|
return /* @__PURE__ */ l(
|
|
370
|
-
|
|
505
|
+
oe,
|
|
371
506
|
{
|
|
372
|
-
value:
|
|
373
|
-
options:
|
|
374
|
-
multi:
|
|
375
|
-
onChange:
|
|
507
|
+
value: e,
|
|
508
|
+
options: t,
|
|
509
|
+
multi: a,
|
|
510
|
+
onChange: r
|
|
376
511
|
}
|
|
377
512
|
);
|
|
378
|
-
if (
|
|
379
|
-
const i =
|
|
380
|
-
const
|
|
381
|
-
|
|
513
|
+
if (a) {
|
|
514
|
+
const i = e ? e.split(H) : [], c = (s) => {
|
|
515
|
+
const g = i.includes(s) ? i.filter((o) => o !== s) : [...i, s];
|
|
516
|
+
r(g.join(H));
|
|
382
517
|
};
|
|
383
|
-
return /* @__PURE__ */
|
|
518
|
+
return /* @__PURE__ */ w("div", { className: "widget-filter__multi", children: [
|
|
384
519
|
i.length > 0 && /* @__PURE__ */ l(
|
|
385
520
|
"button",
|
|
386
521
|
{
|
|
387
522
|
type: "button",
|
|
388
523
|
className: "widget-filter__multi-clear",
|
|
389
|
-
onClick: () =>
|
|
524
|
+
onClick: () => r(""),
|
|
390
525
|
children: "Limpar filtro"
|
|
391
526
|
}
|
|
392
527
|
),
|
|
393
|
-
|
|
528
|
+
t.map((s) => /* @__PURE__ */ w("label", { className: "widget-filter__multi-option", children: [
|
|
394
529
|
/* @__PURE__ */ l(
|
|
395
530
|
"input",
|
|
396
531
|
{
|
|
@@ -403,182 +538,204 @@ function Fe({ value: a, options: r, multi: n, searchable: t, onChange: e }) {
|
|
|
403
538
|
] }, s))
|
|
404
539
|
] });
|
|
405
540
|
}
|
|
406
|
-
return /* @__PURE__ */
|
|
541
|
+
return /* @__PURE__ */ w(
|
|
407
542
|
"select",
|
|
408
543
|
{
|
|
409
544
|
className: "widget-filter__select",
|
|
410
|
-
value:
|
|
411
|
-
onChange: (i) =>
|
|
545
|
+
value: e,
|
|
546
|
+
onChange: (i) => r(i.target.value),
|
|
412
547
|
children: [
|
|
413
548
|
/* @__PURE__ */ l("option", { value: "", children: "Todos" }),
|
|
414
|
-
|
|
549
|
+
t.map((i) => /* @__PURE__ */ l("option", { value: i, children: i }, i))
|
|
415
550
|
]
|
|
416
551
|
}
|
|
417
552
|
);
|
|
418
553
|
}
|
|
419
|
-
const
|
|
554
|
+
const at = {
|
|
420
555
|
currency: "R$",
|
|
421
556
|
percentage: "%"
|
|
422
557
|
};
|
|
423
|
-
function
|
|
424
|
-
const
|
|
425
|
-
return /* @__PURE__ */
|
|
426
|
-
/* @__PURE__ */ l("label", { className: "widget-variable__label", children:
|
|
427
|
-
/* @__PURE__ */
|
|
558
|
+
function nt({ config: e, value: t, onChange: a }) {
|
|
559
|
+
const n = e.label || "Variavel", r = e.locked || !1, i = e.variableFormat || "number", c = at[i] || "";
|
|
560
|
+
return /* @__PURE__ */ w("div", { className: `widget-variable ${r ? "widget-variable--locked" : ""}`, children: [
|
|
561
|
+
/* @__PURE__ */ l("label", { className: "widget-variable__label", children: n }),
|
|
562
|
+
/* @__PURE__ */ w("div", { className: "widget-variable__input-wrapper", children: [
|
|
428
563
|
/* @__PURE__ */ l(
|
|
429
564
|
"input",
|
|
430
565
|
{
|
|
431
566
|
className: "widget-variable__input",
|
|
432
567
|
type: "number",
|
|
433
|
-
value:
|
|
434
|
-
onChange: (s) =>
|
|
435
|
-
disabled:
|
|
568
|
+
value: t,
|
|
569
|
+
onChange: (s) => a(parseFloat(s.target.value) || 0),
|
|
570
|
+
disabled: r,
|
|
436
571
|
step: i === "integer" ? 1 : 0.01
|
|
437
572
|
}
|
|
438
573
|
),
|
|
439
574
|
c && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: c })
|
|
440
575
|
] }),
|
|
441
|
-
|
|
576
|
+
r && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
442
577
|
] });
|
|
443
578
|
}
|
|
444
|
-
function
|
|
445
|
-
const
|
|
446
|
-
return /* @__PURE__ */
|
|
447
|
-
/* @__PURE__ */ l("label", { className: "widget-palette__label", children:
|
|
448
|
-
/* @__PURE__ */ l(
|
|
449
|
-
|
|
579
|
+
function lt({ config: e, palette: t, onChange: a }) {
|
|
580
|
+
const n = e.label || "Cores", r = e.locked || !1;
|
|
581
|
+
return /* @__PURE__ */ w("div", { className: `widget-palette ${r ? "widget-palette--locked" : ""}`, children: [
|
|
582
|
+
/* @__PURE__ */ l("label", { className: "widget-palette__label", children: n }),
|
|
583
|
+
/* @__PURE__ */ l(he, { selected: t, onSelect: a, customMode: !0, disabled: r }),
|
|
584
|
+
r && /* @__PURE__ */ l("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
450
585
|
] });
|
|
451
586
|
}
|
|
452
|
-
function
|
|
453
|
-
type:
|
|
454
|
-
computed:
|
|
455
|
-
palette:
|
|
456
|
-
config:
|
|
457
|
-
filterValue:
|
|
587
|
+
function it({
|
|
588
|
+
type: e,
|
|
589
|
+
computed: t,
|
|
590
|
+
palette: a,
|
|
591
|
+
config: n,
|
|
592
|
+
filterValue: r,
|
|
458
593
|
filterOptions: i,
|
|
459
594
|
dateBounds: c,
|
|
460
595
|
onFilterChange: s,
|
|
461
|
-
variableValue:
|
|
596
|
+
variableValue: g,
|
|
462
597
|
onVariableChange: o,
|
|
463
598
|
onPaletteChange: d
|
|
464
599
|
}) {
|
|
465
|
-
if (
|
|
466
|
-
return /* @__PURE__ */ l("div", { className: "widget widget--error", children: /* @__PURE__ */ l("span", { className: "widget__error-text", children: String(
|
|
467
|
-
const
|
|
468
|
-
switch (
|
|
600
|
+
if (t.error)
|
|
601
|
+
return /* @__PURE__ */ l("div", { className: "widget widget--error", children: /* @__PURE__ */ l("span", { className: "widget__error-text", children: String(t.error) }) });
|
|
602
|
+
const u = ge(a);
|
|
603
|
+
switch (e) {
|
|
469
604
|
case "kpi_card":
|
|
470
|
-
return /* @__PURE__ */ l(
|
|
605
|
+
return /* @__PURE__ */ l(Ge, { data: t, label: n == null ? void 0 : n.label });
|
|
471
606
|
case "gauge":
|
|
472
|
-
return /* @__PURE__ */ l(
|
|
607
|
+
return /* @__PURE__ */ l(Ke, { data: t, palette: u, label: n == null ? void 0 : n.label });
|
|
473
608
|
case "chart":
|
|
474
|
-
return /* @__PURE__ */ l(
|
|
609
|
+
return /* @__PURE__ */ l(qe, { data: t, palette: u, label: n == null ? void 0 : n.label });
|
|
610
|
+
case "table":
|
|
611
|
+
return /* @__PURE__ */ l(Qe, { data: t, label: n == null ? void 0 : n.label });
|
|
475
612
|
case "filter":
|
|
476
|
-
return
|
|
477
|
-
|
|
613
|
+
return n && s ? /* @__PURE__ */ l(
|
|
614
|
+
Ze,
|
|
478
615
|
{
|
|
479
|
-
config:
|
|
480
|
-
value:
|
|
616
|
+
config: n,
|
|
617
|
+
value: r || "",
|
|
481
618
|
options: i,
|
|
482
619
|
dateBounds: c,
|
|
483
620
|
onChange: s
|
|
484
621
|
}
|
|
485
622
|
) : null;
|
|
486
623
|
case "variable": {
|
|
487
|
-
const
|
|
488
|
-
return
|
|
489
|
-
|
|
624
|
+
const h = n;
|
|
625
|
+
return h && o ? /* @__PURE__ */ l(
|
|
626
|
+
nt,
|
|
490
627
|
{
|
|
491
|
-
config:
|
|
492
|
-
value:
|
|
628
|
+
config: h,
|
|
629
|
+
value: g ?? h.variableValue ?? 0,
|
|
493
630
|
onChange: o
|
|
494
631
|
}
|
|
495
632
|
) : null;
|
|
496
633
|
}
|
|
497
634
|
case "color_palette":
|
|
498
|
-
return
|
|
499
|
-
|
|
635
|
+
return n && d ? /* @__PURE__ */ l(
|
|
636
|
+
lt,
|
|
500
637
|
{
|
|
501
|
-
config:
|
|
502
|
-
palette:
|
|
638
|
+
config: n,
|
|
639
|
+
palette: a,
|
|
503
640
|
onChange: d
|
|
504
641
|
}
|
|
505
642
|
) : null;
|
|
506
643
|
default:
|
|
507
|
-
return /* @__PURE__ */
|
|
644
|
+
return /* @__PURE__ */ w("div", { className: "widget", children: [
|
|
508
645
|
"Widget: ",
|
|
509
|
-
|
|
646
|
+
e
|
|
510
647
|
] });
|
|
511
648
|
}
|
|
512
649
|
}
|
|
513
|
-
const
|
|
514
|
-
function
|
|
515
|
-
token:
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
650
|
+
const st = (e, t) => e.grid.y - t.grid.y || e.grid.x - t.grid.x;
|
|
651
|
+
function ht({
|
|
652
|
+
token: e,
|
|
653
|
+
cellAspect: t = we,
|
|
654
|
+
stackBelow: a,
|
|
655
|
+
onGeometryChange: n,
|
|
656
|
+
silenceWarnings: r,
|
|
657
|
+
className: i
|
|
519
658
|
}) {
|
|
520
659
|
const {
|
|
521
|
-
layout:
|
|
522
|
-
renderData:
|
|
523
|
-
loading:
|
|
524
|
-
error:
|
|
525
|
-
filters:
|
|
526
|
-
variables:
|
|
527
|
-
palette:
|
|
528
|
-
setFilter:
|
|
529
|
-
setVariable:
|
|
530
|
-
setPalette:
|
|
531
|
-
} =
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
660
|
+
layout: c,
|
|
661
|
+
renderData: s,
|
|
662
|
+
loading: g,
|
|
663
|
+
error: o,
|
|
664
|
+
filters: d,
|
|
665
|
+
variables: u,
|
|
666
|
+
palette: h,
|
|
667
|
+
setFilter: N,
|
|
668
|
+
setVariable: m,
|
|
669
|
+
setPalette: _
|
|
670
|
+
} = We(e), { rootRef: y, gridRef: T, stacked: k } = ze({
|
|
671
|
+
columns: (c == null ? void 0 : c.gridColumns) ?? 0,
|
|
672
|
+
cellAspect: t,
|
|
673
|
+
stackBelow: a,
|
|
674
|
+
onGeometryChange: n,
|
|
675
|
+
silenceWarnings: r
|
|
676
|
+
}), E = Q(() => {
|
|
677
|
+
const f = (c == null ? void 0 : c.widgets) ?? [];
|
|
678
|
+
return k ? [...f].sort(st) : f;
|
|
679
|
+
}, [c == null ? void 0 : c.widgets, k]), F = {
|
|
680
|
+
"--dash-gap": `${j}px`,
|
|
681
|
+
"--dash-pad": `${_e}px`
|
|
682
|
+
}, S = ["preview-tab", i].filter(Boolean).join(" ");
|
|
683
|
+
let v;
|
|
684
|
+
if (o && !c)
|
|
685
|
+
v = /* @__PURE__ */ l("div", { className: "preview-tab__error", children: o });
|
|
686
|
+
else if (!c)
|
|
687
|
+
v = /* @__PURE__ */ l("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
|
|
688
|
+
else if (c.widgets.length === 0)
|
|
689
|
+
v = /* @__PURE__ */ l("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
|
|
690
|
+
else {
|
|
691
|
+
const f = (s == null ? void 0 : s.widgets) ?? {}, p = (s == null ? void 0 : s.date_bounds) ?? null, $ = {
|
|
692
|
+
"--dash-cols": c.gridColumns,
|
|
693
|
+
"--dash-rows": c.gridRows,
|
|
694
|
+
...me(h)
|
|
695
|
+
}, I = ["preview-tab__grid", k && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
|
|
696
|
+
v = /* @__PURE__ */ w(ae, { children: [
|
|
697
|
+
o && !s && /* @__PURE__ */ l("div", { className: "preview-tab__error", children: o }),
|
|
698
|
+
s && /* @__PURE__ */ l("div", { className: I, style: $, ref: T, children: E.map((b) => {
|
|
699
|
+
const x = fe.has(b.type), M = f[b.id], W = k ? {
|
|
700
|
+
gridColumn: 1,
|
|
701
|
+
aspectRatio: `${be(b.grid.w, b.grid.h, t)}`,
|
|
702
|
+
minHeight: `${pe(b.grid.h, ve, j, 0)}px`
|
|
703
|
+
} : {
|
|
704
|
+
gridColumn: `${b.grid.x + 1} / span ${b.grid.w}`,
|
|
705
|
+
gridRow: `${b.grid.y + 1} / span ${b.grid.h}`
|
|
706
|
+
}, A = b.type === "variable" ? u[b.id] ?? (M == null ? void 0 : M.value) ?? b.config.variableValue ?? 0 : void 0;
|
|
707
|
+
return /* @__PURE__ */ l(
|
|
708
|
+
"div",
|
|
709
|
+
{
|
|
710
|
+
className: `preview-tab__widget ${x ? "preview-tab__widget--control" : ""}`,
|
|
711
|
+
style: W,
|
|
712
|
+
children: x || M ? /* @__PURE__ */ l(
|
|
713
|
+
it,
|
|
714
|
+
{
|
|
715
|
+
type: b.type,
|
|
716
|
+
computed: M || {},
|
|
717
|
+
palette: h,
|
|
718
|
+
config: b.config,
|
|
719
|
+
filterValue: d[b.id] || "",
|
|
720
|
+
filterOptions: (M == null ? void 0 : M.available_values) || [],
|
|
721
|
+
dateBounds: p,
|
|
722
|
+
onFilterChange: (P) => N(b.id, P),
|
|
723
|
+
variableValue: A,
|
|
724
|
+
onVariableChange: (P) => m(b.id, P),
|
|
725
|
+
onPaletteChange: _
|
|
726
|
+
}
|
|
727
|
+
) : /* @__PURE__ */ l("div", { className: "preview-tab__widget-loading", children: g ? "Carregando..." : "Sem dados" })
|
|
728
|
+
},
|
|
729
|
+
b.id
|
|
730
|
+
);
|
|
731
|
+
}) }),
|
|
732
|
+
g && s && /* @__PURE__ */ l("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
|
|
733
|
+
] });
|
|
734
|
+
}
|
|
735
|
+
return /* @__PURE__ */ l("div", { className: S, style: F, ref: y, children: v });
|
|
579
736
|
}
|
|
580
737
|
export {
|
|
581
|
-
|
|
582
|
-
|
|
738
|
+
ft as ApiError,
|
|
739
|
+
ht as Dashboard
|
|
583
740
|
};
|
|
584
741
|
//# sourceMappingURL=index.js.map
|