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