@actionexec/dashboards 0.16.1 → 0.16.2
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/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { M as V, f as
|
|
4
|
-
import { E as
|
|
5
|
-
import { LineChart as
|
|
6
|
-
function
|
|
1
|
+
import { jsxs as b, jsx as r, Fragment as he } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useRef as $, useEffect as W, useCallback as E, useMemo as Y, memo as Ae } from "react";
|
|
3
|
+
import { M as V, f as Fe, a as Te, c as J, b as ee, d as Me, e as fe, i as te, g as z, p as xe, h as q, j as ge, k as _e, l as j, m as Ee, r as Le, D as re, n as Oe, o as Pe, S as pe, C as Ie, q as We, s as be, t as De, u as ze, v as He, G as je, w as ne, x as Ge, y as Ye, z as Ve, A as Ke, B as Ue } from "./ColorPaletteSelector-nBO_fbbj.js";
|
|
4
|
+
import { E as ur } from "./ColorPaletteSelector-nBO_fbbj.js";
|
|
5
|
+
import { LineChart as qe, Line as Be, AreaChart as Xe, Area as Qe, BarChart as ve, Bar as K, CartesianGrid as we, XAxis as ye, YAxis as Ne, Tooltip as U, Legend as Ze, Cell as ae, PieChart as Je, Pie as et } from "recharts";
|
|
6
|
+
function D(e, t = {}) {
|
|
7
7
|
const n = {};
|
|
8
8
|
for (const [a, l] of Object.entries(e))
|
|
9
9
|
if (l.includes("|")) {
|
|
@@ -18,11 +18,11 @@ function W(e, t = {}) {
|
|
|
18
18
|
function H(e) {
|
|
19
19
|
return Object.keys(e).sort().map((t) => `${t}=${e[t]}`).join("&");
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function Se(e, t) {
|
|
22
22
|
const n = Object.keys(e);
|
|
23
23
|
return n.length !== Object.keys(t).length ? !1 : n.every((a) => e[a] === t[a]);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ke(e) {
|
|
26
26
|
const t = {};
|
|
27
27
|
for (const [n, a] of Object.entries(e))
|
|
28
28
|
if (a && typeof a == "object" && "start" in a) {
|
|
@@ -31,46 +31,46 @@ function Ne(e) {
|
|
|
31
31
|
} else Array.isArray(a) ? t[n] = a.join(V) : typeof a == "string" && (t[n] = a);
|
|
32
32
|
return t;
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
const [t, n] =
|
|
37
|
-
|
|
38
|
-
let
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
}).catch((
|
|
42
|
-
|
|
34
|
+
const tt = 300;
|
|
35
|
+
function rt(e) {
|
|
36
|
+
const [t, n] = M(null), [a, l] = M(null), [s, c] = M({}), [i, m] = M({}), [o, h] = M(null), [d, f] = M(!0), [p, v] = M(null), S = $(), k = $(!1), A = $(null), y = $(!1);
|
|
37
|
+
W(() => {
|
|
38
|
+
let _ = !1;
|
|
39
|
+
return k.current = !1, A.current = null, y.current = !1, Fe(e).then((u) => {
|
|
40
|
+
_ || n(u);
|
|
41
|
+
}).catch((u) => {
|
|
42
|
+
_ || v(u.message);
|
|
43
43
|
}), () => {
|
|
44
|
-
|
|
44
|
+
_ = !0;
|
|
45
45
|
};
|
|
46
|
-
}, [e]),
|
|
46
|
+
}, [e]), W(() => {
|
|
47
47
|
if (!t) return;
|
|
48
48
|
if (t.widgets.length === 0) {
|
|
49
|
-
|
|
49
|
+
f(!1);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
52
|
+
const _ = D(s, i), u = H(_);
|
|
53
|
+
if (u === A.current) return;
|
|
54
54
|
S.current && clearTimeout(S.current);
|
|
55
|
-
const
|
|
55
|
+
const R = y.current ? tt : 0;
|
|
56
56
|
return S.current = setTimeout(() => {
|
|
57
|
-
|
|
58
|
-
A.current =
|
|
59
|
-
const
|
|
60
|
-
return
|
|
57
|
+
f(!0), Te(e, _).then((C) => {
|
|
58
|
+
A.current = u, y.current = !0, l(C), !k.current && C.applied && (k.current = !0, c((F) => {
|
|
59
|
+
const g = { ...ke(C.applied), ...F };
|
|
60
|
+
return Se(g, F) ? F : (A.current = H(D(g, i)), g);
|
|
61
61
|
})), v(null);
|
|
62
|
-
}).catch((
|
|
63
|
-
},
|
|
62
|
+
}).catch((C) => v(C.message)).finally(() => f(!1));
|
|
63
|
+
}, R), () => {
|
|
64
64
|
S.current && clearTimeout(S.current);
|
|
65
65
|
};
|
|
66
66
|
}, [e, t, s, i]);
|
|
67
|
-
const
|
|
68
|
-
c((
|
|
69
|
-
}, []),
|
|
70
|
-
|
|
71
|
-
}, []),
|
|
72
|
-
|
|
73
|
-
}, []), x =
|
|
67
|
+
const w = E((_, u) => {
|
|
68
|
+
c((R) => ({ ...R, [_]: u }));
|
|
69
|
+
}, []), N = E((_, u) => {
|
|
70
|
+
m((R) => ({ ...R, [_]: u }));
|
|
71
|
+
}, []), T = E((_) => {
|
|
72
|
+
h(_);
|
|
73
|
+
}, []), x = Y(
|
|
74
74
|
() => o ?? (t == null ? void 0 : t.palette) ?? [],
|
|
75
75
|
[o, t]
|
|
76
76
|
);
|
|
@@ -78,26 +78,26 @@ function Ze(e) {
|
|
|
78
78
|
layout: t,
|
|
79
79
|
renderData: a,
|
|
80
80
|
loading: d,
|
|
81
|
-
error:
|
|
81
|
+
error: p,
|
|
82
82
|
filters: s,
|
|
83
83
|
variables: i,
|
|
84
84
|
palette: x,
|
|
85
|
-
setFilter:
|
|
86
|
-
setVariable:
|
|
87
|
-
setPalette:
|
|
85
|
+
setFilter: w,
|
|
86
|
+
setVariable: N,
|
|
87
|
+
setPalette: T
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const nt = (e) => {
|
|
91
91
|
var t, n;
|
|
92
92
|
return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.inlineSize) ?? e.target.offsetWidth;
|
|
93
|
-
},
|
|
93
|
+
}, at = (e) => {
|
|
94
94
|
var t, n;
|
|
95
95
|
return ((n = (t = e.borderBoxSize) == null ? void 0 : t[0]) == null ? void 0 : n.blockSize) ?? e.target.offsetHeight;
|
|
96
96
|
};
|
|
97
|
-
function
|
|
98
|
-
return e === void 0 ? 0 : e === "auto" ?
|
|
97
|
+
function lt(e, t, n) {
|
|
98
|
+
return e === void 0 ? 0 : e === "auto" ? Me(t, n) : Math.max(0, e);
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function st(e) {
|
|
101
101
|
let t = e.parentElement;
|
|
102
102
|
for (; t && t !== document.body && t !== document.documentElement; ) {
|
|
103
103
|
const { overflowY: n } = getComputedStyle(t);
|
|
@@ -107,94 +107,94 @@ function rt(e) {
|
|
|
107
107
|
}
|
|
108
108
|
return null;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function it(e) {
|
|
111
111
|
const t = $(e);
|
|
112
112
|
t.current = e;
|
|
113
|
-
const n = $(null), a = $(null), l = $(null), s = $(null), c = $(null), i = $(0),
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
!
|
|
118
|
-
`[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(
|
|
113
|
+
const n = $(null), a = $(null), l = $(null), s = $(null), c = $(null), i = $(0), m = $(0), o = $(!1), h = $(!1), d = $(-1), [f, p] = M(!1), v = E((_) => {
|
|
114
|
+
const u = a.current;
|
|
115
|
+
if (h.current || t.current.silenceWarnings || !u) return;
|
|
116
|
+
const R = st(u);
|
|
117
|
+
!R || R.clientHeight >= _.gridHeight || (h.current = !0, console.warn(
|
|
118
|
+
`[@actionexec/dashboards] O dashboard esta sendo cortado: o container precisa de ${Math.ceil(_.gridHeight)}px de altura, mas o ancestral com overflow oculto tem ${R.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.`
|
|
119
119
|
));
|
|
120
120
|
}, []), S = E(() => {
|
|
121
|
-
var
|
|
121
|
+
var L, O;
|
|
122
122
|
if (!n.current) return;
|
|
123
|
-
const { columns:
|
|
124
|
-
containerWidth:
|
|
125
|
-
cellWidth:
|
|
126
|
-
cellHeight:
|
|
127
|
-
gridHeight:
|
|
123
|
+
const { columns: _, cellAspect: u } = t.current, R = i.current, C = ee(R, _), F = {
|
|
124
|
+
containerWidth: R,
|
|
125
|
+
cellWidth: C,
|
|
126
|
+
cellHeight: J(C, u),
|
|
127
|
+
gridHeight: m.current,
|
|
128
128
|
stacked: o.current
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
}, [v]),
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
136
|
-
d.current =
|
|
137
|
-
const { columns:
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
O !== o.current && (o.current = O,
|
|
129
|
+
}, g = c.current;
|
|
130
|
+
g && g.containerWidth === F.containerWidth && g.cellWidth === F.cellWidth && g.cellHeight === F.cellHeight && g.gridHeight === F.gridHeight && g.stacked === F.stacked || (c.current = F, (O = (L = t.current).onGeometryChange) == null || O.call(L, F), v(F));
|
|
131
|
+
}, [v]), k = E((_ = !1) => {
|
|
132
|
+
const u = n.current;
|
|
133
|
+
if (!u) return;
|
|
134
|
+
const R = i.current;
|
|
135
|
+
if (!_ && R === d.current) return;
|
|
136
|
+
d.current = R;
|
|
137
|
+
const { columns: C, cellAspect: F, stackBelow: g } = t.current, I = ee(R, C);
|
|
138
|
+
u.style.setProperty("--dash-cell-h", `${J(I, F)}px`);
|
|
139
|
+
const L = lt(g, C, F), O = L > 0 && R > 0 && R < L;
|
|
140
|
+
O !== o.current && (o.current = O, p(O));
|
|
141
141
|
}, []), A = E(() => {
|
|
142
142
|
s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
|
|
143
|
-
}, []),
|
|
143
|
+
}, []), y = E(() => {
|
|
144
144
|
s.current === null && (s.current = requestAnimationFrame(() => {
|
|
145
|
-
s.current = null,
|
|
145
|
+
s.current = null, k(), S();
|
|
146
146
|
}));
|
|
147
|
-
}, [
|
|
148
|
-
for (const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}, [
|
|
152
|
-
const
|
|
153
|
-
n.current && (
|
|
154
|
-
}, [
|
|
155
|
-
const
|
|
156
|
-
if (a.current && (
|
|
157
|
-
|
|
147
|
+
}, [k, S]), w = E((_) => {
|
|
148
|
+
for (const u of _)
|
|
149
|
+
u.target === n.current ? i.current = Math.round(nt(u)) : u.target === a.current && (m.current = at(u));
|
|
150
|
+
y();
|
|
151
|
+
}, [y]), N = E(() => l.current ? l.current : typeof ResizeObserver > "u" ? null : (l.current = new ResizeObserver(w), l.current), [w]), T = E((_) => {
|
|
152
|
+
const u = N();
|
|
153
|
+
n.current && (u == null || u.unobserve(n.current)), n.current = _, _ && (u == null || u.observe(_), i.current = Math.round(_.getBoundingClientRect().width), k(!0), y());
|
|
154
|
+
}, [k, N, y]), x = E((_) => {
|
|
155
|
+
const u = N();
|
|
156
|
+
if (a.current && (u == null || u.unobserve(a.current)), a.current = _, !_) {
|
|
157
|
+
m.current = 0;
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
|
-
|
|
161
|
-
}, [
|
|
162
|
-
return
|
|
163
|
-
const
|
|
164
|
-
return n.current && (
|
|
165
|
-
var
|
|
166
|
-
(
|
|
160
|
+
u == null || u.observe(_), m.current = _.getBoundingClientRect().height, y();
|
|
161
|
+
}, [N, y]);
|
|
162
|
+
return W(() => {
|
|
163
|
+
const _ = N();
|
|
164
|
+
return n.current && (_ == null || _.observe(n.current)), a.current && (_ == null || _.observe(a.current)), () => {
|
|
165
|
+
var u;
|
|
166
|
+
(u = l.current) == null || u.disconnect(), l.current = null, A();
|
|
167
167
|
};
|
|
168
|
-
}, [
|
|
169
|
-
n.current && (
|
|
170
|
-
}, [e.columns, e.cellAspect, e.stackBelow,
|
|
168
|
+
}, [N, A]), W(() => {
|
|
169
|
+
n.current && (k(!0), y());
|
|
170
|
+
}, [e.columns, e.cellAspect, e.stackBelow, k, y]), { rootRef: T, gridRef: x, stacked: f };
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const ot = {
|
|
173
173
|
empty: "Sem dados",
|
|
174
174
|
error: "Não foi possível carregar",
|
|
175
175
|
loading: "Carregando...",
|
|
176
176
|
unconfigured: "Widget não configurado"
|
|
177
177
|
};
|
|
178
|
-
function
|
|
179
|
-
return /* @__PURE__ */ r("div", { className: `widget__state widget__state--${e}`, role: e === "error" ? "alert" : void 0, children: t ||
|
|
178
|
+
function B({ kind: e, message: t }) {
|
|
179
|
+
return /* @__PURE__ */ r("div", { className: `widget__state widget__state--${e}`, role: e === "error" ? "alert" : void 0, children: t || ot[e] });
|
|
180
180
|
}
|
|
181
|
-
function
|
|
182
|
-
return /* @__PURE__ */
|
|
181
|
+
function P({ name: e, title: t, state: n, stateMessage: a, toolbar: l, children: s }) {
|
|
182
|
+
return /* @__PURE__ */ b("div", { className: `widget widget-${e}`, children: [
|
|
183
183
|
t && /* @__PURE__ */ r("span", { className: "widget__title", children: t }),
|
|
184
184
|
l,
|
|
185
|
-
n ? /* @__PURE__ */ r(
|
|
185
|
+
n ? /* @__PURE__ */ r(B, { kind: n, message: a }) : s
|
|
186
186
|
] });
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
function
|
|
188
|
+
const ct = { up: "↑", down: "↓" };
|
|
189
|
+
function Re(e) {
|
|
190
190
|
return Array.isArray(e) ? e.filter(
|
|
191
191
|
(t) => t && t.status === "ok" && t.formatted && t.formatted !== "-"
|
|
192
192
|
) : [];
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
const n = e.sentiment ?? "neutral", a =
|
|
196
|
-
return /* @__PURE__ */
|
|
197
|
-
/* @__PURE__ */
|
|
194
|
+
function dt({ comparison: e, primary: t }) {
|
|
195
|
+
const n = e.sentiment ?? "neutral", a = ct[e.trend ?? ""] ?? "";
|
|
196
|
+
return /* @__PURE__ */ b("div", { className: `widget-kpi__trend widget-kpi__trend--${n}${t ? "" : " widget-kpi__trend--muted"}`, children: [
|
|
197
|
+
/* @__PURE__ */ b("span", { className: "widget-kpi__variance", children: [
|
|
198
198
|
a,
|
|
199
199
|
" ",
|
|
200
200
|
e.formatted
|
|
@@ -202,159 +202,159 @@ function st({ comparison: e, primary: t }) {
|
|
|
202
202
|
e.label && /* @__PURE__ */ r("span", { className: "widget-kpi__trend-label", children: e.label })
|
|
203
203
|
] });
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
const n = t || String(e.label || ""), a = String(e.formatted || "-"), l =
|
|
207
|
-
return /* @__PURE__ */
|
|
205
|
+
function ut({ data: e, label: t }) {
|
|
206
|
+
const n = t || String(e.label || ""), a = String(e.formatted || "-"), l = Re(e.comparisons);
|
|
207
|
+
return /* @__PURE__ */ b(P, { name: "kpi", title: n, children: [
|
|
208
208
|
/* @__PURE__ */ r("span", { className: "widget-kpi__value", children: a }),
|
|
209
|
-
l.map((s, c) => /* @__PURE__ */ r(
|
|
209
|
+
l.map((s, c) => /* @__PURE__ */ r(dt, { comparison: s, primary: c === 0 }, s.id || c))
|
|
210
210
|
] });
|
|
211
211
|
}
|
|
212
|
-
const
|
|
212
|
+
const mt = "var(--bg-elevated)", ht = [
|
|
213
213
|
[1, "var(--color-success)"],
|
|
214
214
|
[0.7, ""],
|
|
215
215
|
// vazio = cor da serie 1 (destaque do dashboard)
|
|
216
216
|
[0.4, "var(--color-warning)"],
|
|
217
217
|
[0, "var(--color-error)"]
|
|
218
218
|
];
|
|
219
|
-
function
|
|
219
|
+
function le(e, t, n, a) {
|
|
220
220
|
if (a <= 0) return "";
|
|
221
221
|
if (a >= 1)
|
|
222
222
|
return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e} ${t - n} A ${n} ${n} 0 0 1 ${e + n} ${t}`;
|
|
223
223
|
const l = a * Math.PI;
|
|
224
224
|
return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e - n * Math.cos(l)} ${t - n * Math.sin(l)}`;
|
|
225
225
|
}
|
|
226
|
-
function
|
|
227
|
-
const a = n || String(e.label || ""), l = typeof e.ratio == "number" ? e.ratio : 0, s = typeof e.format == "string" ? e.format : void 0, c = String(e.value_formatted ||
|
|
228
|
-
return /* @__PURE__ */ r(
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
/* @__PURE__ */ r("path", { d:
|
|
231
|
-
v > 0 && /* @__PURE__ */ r("path", { d:
|
|
226
|
+
function ft({ data: e, palette: t, label: n }) {
|
|
227
|
+
const a = n || String(e.label || ""), l = typeof e.ratio == "number" ? e.ratio : 0, s = typeof e.format == "string" ? e.format : void 0, c = String(e.value_formatted || fe(e.value, s)), i = String(e.formatted || "-"), m = Re(e.comparisons), [o, ...h] = m, d = String((o == null ? void 0 : o.baseline_formatted) || "-"), f = (o == null ? void 0 : o.label) ?? null, p = l >= 1, v = Math.min(Math.max(l, 0), 1), S = ht.find(([T]) => l >= T), k = (S == null ? void 0 : S[1]) || t[0] || "var(--color-info)", A = 50, y = 50, w = 44, N = 10;
|
|
228
|
+
return /* @__PURE__ */ r(P, { name: "gauge", title: a, children: /* @__PURE__ */ b("div", { className: "widget-gauge__chart", children: [
|
|
229
|
+
/* @__PURE__ */ b("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", role: "img", "aria-label": `${i} da meta`, children: [
|
|
230
|
+
/* @__PURE__ */ r("path", { d: le(A, y, w, 1), fill: "none", stroke: mt, strokeWidth: N, strokeLinecap: "butt" }),
|
|
231
|
+
v > 0 && /* @__PURE__ */ r("path", { d: le(A, y, w, v), fill: "none", stroke: k, strokeWidth: N, strokeLinecap: "butt" })
|
|
232
232
|
] }),
|
|
233
|
-
/* @__PURE__ */
|
|
233
|
+
/* @__PURE__ */ b("div", { className: "widget-gauge__center", children: [
|
|
234
234
|
/* @__PURE__ */ r("span", { className: "widget-gauge__percent", children: i }),
|
|
235
|
-
/* @__PURE__ */
|
|
235
|
+
/* @__PURE__ */ b("span", { className: "widget-gauge__comparison", children: [
|
|
236
236
|
c,
|
|
237
237
|
" / ",
|
|
238
238
|
d
|
|
239
239
|
] }),
|
|
240
|
-
|
|
241
|
-
!
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
p && /* @__PURE__ */ r("span", { className: "widget-gauge__badge", children: f || "Meta batida" }),
|
|
241
|
+
!p && f && /* @__PURE__ */ r("span", { className: "widget-gauge__comparison", children: f }),
|
|
242
|
+
h.map((T, x) => /* @__PURE__ */ b("span", { className: "widget-gauge__comparison", children: [
|
|
243
|
+
T.formatted,
|
|
244
244
|
" ",
|
|
245
|
-
|
|
246
|
-
] },
|
|
245
|
+
T.label
|
|
246
|
+
] }, T.id || x))
|
|
247
247
|
] })
|
|
248
248
|
] }) });
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
const [t, n] =
|
|
252
|
-
return
|
|
250
|
+
function X(e) {
|
|
251
|
+
const [t, n] = M({ width: 0, height: 0 });
|
|
252
|
+
return W(() => {
|
|
253
253
|
const a = e.current;
|
|
254
254
|
if (!a) return;
|
|
255
255
|
const l = new ResizeObserver(([s]) => {
|
|
256
256
|
const { width: c, height: i } = s.contentRect;
|
|
257
257
|
n(
|
|
258
|
-
(
|
|
258
|
+
(m) => m.width !== Math.floor(c) || m.height !== Math.floor(i) ? { width: Math.floor(c), height: Math.floor(i) } : m
|
|
259
259
|
);
|
|
260
260
|
});
|
|
261
261
|
return l.observe(a), () => l.disconnect();
|
|
262
262
|
}, [e]), t;
|
|
263
263
|
}
|
|
264
|
-
const
|
|
264
|
+
const se = { fontSize: 10, fill: "var(--text-muted)" }, gt = "var(--bg-elevated)", _t = {
|
|
265
265
|
backgroundColor: "var(--bg-elevated)",
|
|
266
266
|
border: "1px solid var(--bg-paper)",
|
|
267
267
|
borderRadius: "6px",
|
|
268
268
|
color: "var(--text-primary)"
|
|
269
|
-
},
|
|
269
|
+
}, pt = {
|
|
270
270
|
color: "var(--text-primary)",
|
|
271
271
|
fontWeight: 600
|
|
272
272
|
};
|
|
273
|
-
function
|
|
273
|
+
function bt(e, t) {
|
|
274
274
|
var l;
|
|
275
275
|
const n = Array.isArray(t) ? t[0] : void 0, a = (l = n == null ? void 0 : n.payload) == null ? void 0 : l.tooltipLabel;
|
|
276
276
|
return typeof a == "string" && a ? a : String(e ?? "");
|
|
277
277
|
}
|
|
278
|
-
function
|
|
279
|
-
return /* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */ r(
|
|
281
|
-
/* @__PURE__ */ r(
|
|
282
|
-
/* @__PURE__ */ r(
|
|
278
|
+
function G({ Chart: e, chartData: t, xKey: n, series: a, palette: l, renderSeries: s, width: c, height: i }) {
|
|
279
|
+
return /* @__PURE__ */ b(e, { data: t, width: c, height: i, children: [
|
|
280
|
+
/* @__PURE__ */ r(we, { strokeDasharray: "3 3", stroke: gt }),
|
|
281
|
+
/* @__PURE__ */ r(ye, { dataKey: n, tick: se }),
|
|
282
|
+
/* @__PURE__ */ r(Ne, { tick: se }),
|
|
283
283
|
/* @__PURE__ */ r(
|
|
284
284
|
U,
|
|
285
285
|
{
|
|
286
|
-
contentStyle:
|
|
287
|
-
labelStyle:
|
|
288
|
-
labelFormatter:
|
|
286
|
+
contentStyle: _t,
|
|
287
|
+
labelStyle: pt,
|
|
288
|
+
labelFormatter: bt,
|
|
289
289
|
cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
|
|
290
290
|
}
|
|
291
291
|
),
|
|
292
|
-
a.length > 1 && /* @__PURE__ */ r(
|
|
293
|
-
a.map((
|
|
292
|
+
a.length > 1 && /* @__PURE__ */ r(Ze, {}),
|
|
293
|
+
a.map((m, o) => s(m, l[o % l.length], o))
|
|
294
294
|
] });
|
|
295
295
|
}
|
|
296
|
-
function
|
|
297
|
-
const a = String(e.chartType || "bar"), l = n || String(e.label || ""), s = String(e.xKey || "label"), c = e.series || [], i = e.data || [],
|
|
298
|
-
if (o <= 0 ||
|
|
299
|
-
const
|
|
300
|
-
return a === "line" ? /* @__PURE__ */ r(
|
|
301
|
-
|
|
296
|
+
function vt({ data: e, palette: t, label: n }) {
|
|
297
|
+
const a = String(e.chartType || "bar"), l = n || String(e.label || ""), s = String(e.xKey || "label"), c = e.series || [], i = e.data || [], m = $(null), { width: o, height: h } = X(m), d = () => {
|
|
298
|
+
if (o <= 0 || h <= 0) return null;
|
|
299
|
+
const f = { chartData: i, xKey: s, series: c, palette: t, width: o, height: h };
|
|
300
|
+
return a === "line" ? /* @__PURE__ */ r(G, { ...f, Chart: qe, renderSeries: (p, v) => /* @__PURE__ */ r(
|
|
301
|
+
Be,
|
|
302
302
|
{
|
|
303
303
|
type: "monotone",
|
|
304
|
-
dataKey:
|
|
305
|
-
name:
|
|
304
|
+
dataKey: p.key,
|
|
305
|
+
name: p.label,
|
|
306
306
|
stroke: v,
|
|
307
307
|
strokeWidth: 2,
|
|
308
308
|
dot: i.length <= 31
|
|
309
309
|
},
|
|
310
|
-
|
|
311
|
-
) }) : a === "area" ? /* @__PURE__ */ r(
|
|
312
|
-
|
|
310
|
+
p.key
|
|
311
|
+
) }) : a === "area" ? /* @__PURE__ */ r(G, { ...f, Chart: Xe, renderSeries: (p, v) => /* @__PURE__ */ r(
|
|
312
|
+
Qe,
|
|
313
313
|
{
|
|
314
314
|
type: "monotone",
|
|
315
|
-
dataKey:
|
|
316
|
-
name:
|
|
315
|
+
dataKey: p.key,
|
|
316
|
+
name: p.label,
|
|
317
317
|
fill: v,
|
|
318
318
|
stroke: v,
|
|
319
319
|
fillOpacity: 0.3
|
|
320
320
|
},
|
|
321
|
-
|
|
322
|
-
) }) : /* @__PURE__ */ r(
|
|
321
|
+
p.key
|
|
322
|
+
) }) : /* @__PURE__ */ r(G, { ...f, Chart: ve, renderSeries: (p, v) => /* @__PURE__ */ r(
|
|
323
323
|
K,
|
|
324
324
|
{
|
|
325
|
-
dataKey:
|
|
326
|
-
name:
|
|
325
|
+
dataKey: p.key,
|
|
326
|
+
name: p.label,
|
|
327
327
|
fill: v,
|
|
328
328
|
radius: [3, 3, 0, 0]
|
|
329
329
|
},
|
|
330
|
-
|
|
330
|
+
p.key
|
|
331
331
|
) });
|
|
332
332
|
};
|
|
333
|
-
return /* @__PURE__ */ r(
|
|
333
|
+
return /* @__PURE__ */ r(P, { name: "chart", title: l, children: /* @__PURE__ */ r("div", { ref: m, className: "widget-chart__container", children: i.length === 0 ? /* @__PURE__ */ r(B, { kind: "empty" }) : d() }) });
|
|
334
334
|
}
|
|
335
|
-
const
|
|
336
|
-
function
|
|
335
|
+
const ie = { fontSize: 10, fill: "var(--text-muted)" }, wt = "var(--bg-elevated)", yt = { fill: "var(--bg-paper)", opacity: 0.3 };
|
|
336
|
+
function Nt(e) {
|
|
337
337
|
return e.kind === "anchor" ? "var(--color-accent)" : e.kind === "residual" ? "var(--color-warning)" : e.value < 0 ? "var(--color-error)" : "var(--color-success)";
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function oe({ active: e, payload: t }) {
|
|
340
340
|
var a;
|
|
341
341
|
const n = e ? (a = t == null ? void 0 : t[0]) == null ? void 0 : a.payload : void 0;
|
|
342
|
-
return n ? /* @__PURE__ */
|
|
342
|
+
return n ? /* @__PURE__ */ b("div", { className: "widget-composition__tooltip", children: [
|
|
343
343
|
/* @__PURE__ */ r("span", { className: "widget-composition__tooltip-label", children: n.label }),
|
|
344
344
|
/* @__PURE__ */ r("span", { className: "widget-composition__tooltip-value", children: n.formatted })
|
|
345
345
|
] }) : null;
|
|
346
346
|
}
|
|
347
|
-
function
|
|
348
|
-
const a = n || String(e.label || ""), l = String(e.display || "pie"), s = e.data || [], c = typeof e.format == "string" ? e.format : void 0, i = $(null), { width:
|
|
349
|
-
/* @__PURE__ */ r(
|
|
350
|
-
/* @__PURE__ */ r(
|
|
351
|
-
/* @__PURE__ */ r(
|
|
352
|
-
/* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(
|
|
347
|
+
function St({ data: e, palette: t, label: n }) {
|
|
348
|
+
const a = n || String(e.label || ""), l = String(e.display || "pie"), s = e.data || [], c = typeof e.format == "string" ? e.format : void 0, i = $(null), { width: m, height: o } = X(i), h = () => /* @__PURE__ */ b(ve, { data: s, width: m, height: o, children: [
|
|
349
|
+
/* @__PURE__ */ r(we, { strokeDasharray: "3 3", stroke: wt }),
|
|
350
|
+
/* @__PURE__ */ r(ye, { dataKey: "label", tick: ie, interval: 0 }),
|
|
351
|
+
/* @__PURE__ */ r(Ne, { tick: ie, tickFormatter: (f) => fe(f, c) }),
|
|
352
|
+
/* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(oe, {}), cursor: yt }),
|
|
353
353
|
/* @__PURE__ */ r(K, { dataKey: "base", stackId: "bridge", fill: "none", fillOpacity: 0, isAnimationActive: !1 }),
|
|
354
|
-
/* @__PURE__ */ r(K, { dataKey: "span", stackId: "bridge", radius: [3, 3, 0, 0], children: s.map((
|
|
355
|
-
] }), d = () => /* @__PURE__ */
|
|
354
|
+
/* @__PURE__ */ r(K, { dataKey: "span", stackId: "bridge", radius: [3, 3, 0, 0], children: s.map((f, p) => /* @__PURE__ */ r(ae, { fill: Nt(f) }, p)) })
|
|
355
|
+
] }), d = () => /* @__PURE__ */ b(Je, { width: m, height: o, children: [
|
|
356
356
|
/* @__PURE__ */ r(
|
|
357
|
-
|
|
357
|
+
et,
|
|
358
358
|
{
|
|
359
359
|
data: s,
|
|
360
360
|
dataKey: "value",
|
|
@@ -362,61 +362,61 @@ function vt({ data: e, palette: t, label: n }) {
|
|
|
362
362
|
cx: "50%",
|
|
363
363
|
cy: "50%",
|
|
364
364
|
outerRadius: "75%",
|
|
365
|
-
label: ({ name:
|
|
365
|
+
label: ({ name: f, percent: p }) => `${f}: ${(p * 100).toFixed(0)}%`,
|
|
366
366
|
labelLine: !1,
|
|
367
|
-
children: s.map((
|
|
367
|
+
children: s.map((f, p) => /* @__PURE__ */ r(ae, { fill: t[p % t.length] }, p))
|
|
368
368
|
}
|
|
369
369
|
),
|
|
370
|
-
/* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(
|
|
370
|
+
/* @__PURE__ */ r(U, { content: /* @__PURE__ */ r(oe, {}) })
|
|
371
371
|
] });
|
|
372
|
-
return /* @__PURE__ */ r(
|
|
372
|
+
return /* @__PURE__ */ r(P, { name: "composition", title: a, children: /* @__PURE__ */ r("div", { ref: i, className: "widget-composition__container", children: s.length === 0 || m <= 0 || o <= 0 ? /* @__PURE__ */ r(B, { kind: "empty" }) : l === "bridge" ? h() : d() }) });
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function kt(e, t) {
|
|
375
375
|
if (t !== "percentage") return "";
|
|
376
376
|
const n = Number(e);
|
|
377
377
|
return Number.isNaN(n) || n === 0 ? "" : n > 0 ? " widget-table__td--up" : " widget-table__td--down";
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function Rt(e, t, n, a) {
|
|
380
380
|
const l = (a == null ? void 0 : a.offsetHeight) ?? 0;
|
|
381
381
|
if (e === 0 || t <= 0 || l <= 0) return e;
|
|
382
382
|
const s = Math.floor((t - ((n == null ? void 0 : n.offsetHeight) ?? 0)) / l);
|
|
383
383
|
return Math.max(0, Math.min(e, s));
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
var
|
|
387
|
-
const n = e.columns || [], a = e.rows || [], l = e.overflow === "clip", s = e.indexColumn === !0, c = t || String(e.label || ""), i = $(null),
|
|
385
|
+
function $t({ data: e, label: t }) {
|
|
386
|
+
var f;
|
|
387
|
+
const n = e.columns || [], a = e.rows || [], l = e.overflow === "clip", s = e.indexColumn === !0, c = t || String(e.label || ""), i = $(null), m = $(null), o = $(null), { height: h } = X(i), d = l ? a.slice(0, Rt(
|
|
388
388
|
a.length,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
((
|
|
389
|
+
h,
|
|
390
|
+
m.current,
|
|
391
|
+
((f = o.current) == null ? void 0 : f.firstElementChild) ?? null
|
|
392
392
|
)) : a;
|
|
393
393
|
return n.length === 0 ? /* @__PURE__ */ r(
|
|
394
|
-
|
|
394
|
+
P,
|
|
395
395
|
{
|
|
396
396
|
name: "table",
|
|
397
397
|
title: c,
|
|
398
398
|
state: "unconfigured",
|
|
399
399
|
stateMessage: "Configure as colunas da tabela."
|
|
400
400
|
}
|
|
401
|
-
) : /* @__PURE__ */ r(
|
|
401
|
+
) : /* @__PURE__ */ r(P, { name: "table", title: c, children: /* @__PURE__ */ r(
|
|
402
402
|
"div",
|
|
403
403
|
{
|
|
404
404
|
ref: i,
|
|
405
405
|
className: `widget-table__scroll${l ? " widget-table__scroll--clip" : ""}`,
|
|
406
|
-
children: /* @__PURE__ */
|
|
406
|
+
children: /* @__PURE__ */ b(
|
|
407
407
|
"table",
|
|
408
408
|
{
|
|
409
409
|
className: `widget-table__table${l && d.length < a.length ? "" : " widget-table__table--fill"}`,
|
|
410
410
|
children: [
|
|
411
|
-
/* @__PURE__ */ r("thead", { ref:
|
|
411
|
+
/* @__PURE__ */ r("thead", { ref: m, children: /* @__PURE__ */ b("tr", { children: [
|
|
412
412
|
s && /* @__PURE__ */ r("th", { className: "widget-table__th widget-table__th--index", children: "#" }),
|
|
413
|
-
n.map((
|
|
413
|
+
n.map((p) => /* @__PURE__ */ r(
|
|
414
414
|
"th",
|
|
415
415
|
{
|
|
416
|
-
className: `widget-table__th${
|
|
417
|
-
children:
|
|
416
|
+
className: `widget-table__th${te(p.format) ? " widget-table__th--num" : ""}`,
|
|
417
|
+
children: p.label || p.key
|
|
418
418
|
},
|
|
419
|
-
|
|
419
|
+
p.key
|
|
420
420
|
))
|
|
421
421
|
] }) }),
|
|
422
422
|
/* @__PURE__ */ r("tbody", { ref: o, children: d.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r(
|
|
@@ -426,11 +426,11 @@ function Nt({ data: e, label: t }) {
|
|
|
426
426
|
colSpan: n.length + (s ? 1 : 0),
|
|
427
427
|
children: "Sem dados"
|
|
428
428
|
}
|
|
429
|
-
) }) : d.map((
|
|
429
|
+
) }) : d.map((p, v) => /* @__PURE__ */ b("tr", { children: [
|
|
430
430
|
s && /* @__PURE__ */ r("td", { className: "widget-table__td widget-table__td--index", children: v + 1 }),
|
|
431
431
|
n.map((S) => {
|
|
432
|
-
const
|
|
433
|
-
return /* @__PURE__ */ r("td", { className: `widget-table__td${A}${
|
|
432
|
+
const k = p[S.key], A = te(S.format) ? " widget-table__td--num" : "";
|
|
433
|
+
return /* @__PURE__ */ r("td", { className: `widget-table__td${A}${kt(k, S.format)}`, children: z(k, S.format) }, S.key);
|
|
434
434
|
})
|
|
435
435
|
] }, v)) })
|
|
436
436
|
]
|
|
@@ -439,46 +439,46 @@ function Nt({ data: e, label: t }) {
|
|
|
439
439
|
}
|
|
440
440
|
) });
|
|
441
441
|
}
|
|
442
|
-
function
|
|
443
|
-
return e === "yearly" ? /* @__PURE__ */ r(
|
|
444
|
-
|
|
442
|
+
function $e({ mode: e, value: t, dateBounds: n, rangeUnit: a, onChange: l }) {
|
|
443
|
+
return e === "yearly" ? /* @__PURE__ */ r(Ft, { value: t, dateBounds: n, onChange: l }) : e === "monthly" ? /* @__PURE__ */ r(Tt, { value: t, dateBounds: n, onChange: l }) : e === "weekly" ? /* @__PURE__ */ r(Mt, { value: t, dateBounds: n, onChange: l }) : a && a !== "day" ? /* @__PURE__ */ r(
|
|
444
|
+
Ct,
|
|
445
445
|
{
|
|
446
446
|
value: t,
|
|
447
447
|
dateBounds: n,
|
|
448
448
|
unit: a,
|
|
449
449
|
onChange: l
|
|
450
450
|
}
|
|
451
|
-
) : /* @__PURE__ */ r(
|
|
451
|
+
) : /* @__PURE__ */ r(At, { value: t, dateBounds: n, onChange: l });
|
|
452
452
|
}
|
|
453
|
-
function
|
|
454
|
-
const [l, s] = e ? e.split("|") : ["", ""], c =
|
|
455
|
-
var
|
|
456
|
-
return ((
|
|
457
|
-
},
|
|
458
|
-
const d = c.find((
|
|
453
|
+
function Ct({ value: e, dateBounds: t, unit: n, onChange: a }) {
|
|
454
|
+
const [l, s] = e ? e.split("|") : ["", ""], c = Le(n, t), i = (o) => {
|
|
455
|
+
var h;
|
|
456
|
+
return ((h = c.find((d) => o >= d.start && o <= d.end)) == null ? void 0 : h.key) ?? "";
|
|
457
|
+
}, m = (o, h) => {
|
|
458
|
+
const d = c.find((f) => f.key === h);
|
|
459
459
|
d && a(o === "start" ? `${d.start}|${!s || s < d.end ? d.end : s}` : `${!l || l > d.start ? d.start : l}|${d.end}`);
|
|
460
460
|
};
|
|
461
|
-
return /* @__PURE__ */
|
|
462
|
-
/* @__PURE__ */
|
|
461
|
+
return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--period", children: [
|
|
462
|
+
/* @__PURE__ */ b(
|
|
463
463
|
"select",
|
|
464
464
|
{
|
|
465
465
|
className: "widget-filter__select",
|
|
466
466
|
"aria-label": "Período inicial",
|
|
467
467
|
value: i(l),
|
|
468
|
-
onChange: (o) =>
|
|
468
|
+
onChange: (o) => m("start", o.target.value),
|
|
469
469
|
children: [
|
|
470
470
|
!i(l) && /* @__PURE__ */ r("option", { value: "", children: "De..." }),
|
|
471
471
|
c.map((o) => /* @__PURE__ */ r("option", { value: o.key, children: o.label }, o.key))
|
|
472
472
|
]
|
|
473
473
|
}
|
|
474
474
|
),
|
|
475
|
-
/* @__PURE__ */
|
|
475
|
+
/* @__PURE__ */ b(
|
|
476
476
|
"select",
|
|
477
477
|
{
|
|
478
478
|
className: "widget-filter__select",
|
|
479
479
|
"aria-label": "Período final",
|
|
480
480
|
value: i(s),
|
|
481
|
-
onChange: (o) =>
|
|
481
|
+
onChange: (o) => m("end", o.target.value),
|
|
482
482
|
children: [
|
|
483
483
|
!i(s) && /* @__PURE__ */ r("option", { value: "", children: "Até..." }),
|
|
484
484
|
c.map((o) => /* @__PURE__ */ r("option", { value: o.key, children: o.label }, o.key))
|
|
@@ -487,11 +487,11 @@ function St({ value: e, dateBounds: t, unit: n, onChange: a }) {
|
|
|
487
487
|
)
|
|
488
488
|
] });
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function At({ value: e, dateBounds: t, onChange: n }) {
|
|
491
491
|
const [a, l] = e ? e.split("|") : ["", ""];
|
|
492
|
-
return /* @__PURE__ */
|
|
492
|
+
return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
|
|
493
493
|
/* @__PURE__ */ r(
|
|
494
|
-
|
|
494
|
+
re,
|
|
495
495
|
{
|
|
496
496
|
value: a,
|
|
497
497
|
minIso: t == null ? void 0 : t.min,
|
|
@@ -504,7 +504,7 @@ function kt({ value: e, dateBounds: t, onChange: n }) {
|
|
|
504
504
|
}
|
|
505
505
|
),
|
|
506
506
|
/* @__PURE__ */ r(
|
|
507
|
-
|
|
507
|
+
re,
|
|
508
508
|
{
|
|
509
509
|
value: l,
|
|
510
510
|
minIso: a || (t == null ? void 0 : t.min),
|
|
@@ -518,34 +518,34 @@ function kt({ value: e, dateBounds: t, onChange: n }) {
|
|
|
518
518
|
)
|
|
519
519
|
] });
|
|
520
520
|
}
|
|
521
|
-
function
|
|
522
|
-
const [a] = e ? e.split("|") : [""], l =
|
|
523
|
-
const
|
|
524
|
-
n(`${
|
|
521
|
+
function Ft({ value: e, dateBounds: t, onChange: n }) {
|
|
522
|
+
const [a] = e ? e.split("|") : [""], l = xe(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = q(t), m = (o) => {
|
|
523
|
+
const h = Pe(o);
|
|
524
|
+
n(`${h.start}|${h.end}`);
|
|
525
525
|
};
|
|
526
526
|
return /* @__PURE__ */ r("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ r(
|
|
527
527
|
"select",
|
|
528
528
|
{
|
|
529
529
|
className: "widget-filter__select",
|
|
530
530
|
value: c,
|
|
531
|
-
onChange: (o) =>
|
|
531
|
+
onChange: (o) => m(parseInt(o.target.value)),
|
|
532
532
|
children: i.map((o) => /* @__PURE__ */ r("option", { value: o, children: o }, o))
|
|
533
533
|
}
|
|
534
534
|
) });
|
|
535
535
|
}
|
|
536
|
-
function
|
|
537
|
-
const [a] = e ? e.split("|") : [""], l =
|
|
538
|
-
const
|
|
539
|
-
n(`${
|
|
536
|
+
function Tt({ value: e, dateBounds: t, onChange: n }) {
|
|
537
|
+
const [a] = e ? e.split("|") : [""], l = ge(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = (l == null ? void 0 : l.month) ?? s.getMonth() + 1, m = q(t), o = (h, d) => {
|
|
538
|
+
const f = Oe(h, d);
|
|
539
|
+
n(`${f.start}|${f.end}`);
|
|
540
540
|
};
|
|
541
|
-
return /* @__PURE__ */
|
|
541
|
+
return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
|
|
542
542
|
/* @__PURE__ */ r(
|
|
543
543
|
"select",
|
|
544
544
|
{
|
|
545
545
|
className: "widget-filter__select",
|
|
546
546
|
value: i,
|
|
547
|
-
onChange: (
|
|
548
|
-
children:
|
|
547
|
+
onChange: (h) => o(c, parseInt(h.target.value)),
|
|
548
|
+
children: _e.map((h, d) => /* @__PURE__ */ r("option", { value: d + 1, children: h }, d + 1))
|
|
549
549
|
}
|
|
550
550
|
),
|
|
551
551
|
/* @__PURE__ */ r(
|
|
@@ -553,25 +553,25 @@ function $t({ value: e, dateBounds: t, onChange: n }) {
|
|
|
553
553
|
{
|
|
554
554
|
className: "widget-filter__select",
|
|
555
555
|
value: c,
|
|
556
|
-
onChange: (
|
|
557
|
-
children:
|
|
556
|
+
onChange: (h) => o(parseInt(h.target.value), i),
|
|
557
|
+
children: m.map((h) => /* @__PURE__ */ r("option", { value: h, children: h }, h))
|
|
558
558
|
}
|
|
559
559
|
)
|
|
560
560
|
] });
|
|
561
561
|
}
|
|
562
|
-
function
|
|
563
|
-
const [a] = e ? e.split("|") : [""], l =
|
|
564
|
-
return /* @__PURE__ */
|
|
562
|
+
function Mt({ value: e, dateBounds: t, onChange: n }) {
|
|
563
|
+
const [a] = e ? e.split("|") : [""], l = ge(a), s = /* @__PURE__ */ new Date(), c = (l == null ? void 0 : l.year) ?? s.getFullYear(), i = (l == null ? void 0 : l.month) ?? s.getMonth() + 1, m = q(t), o = j(c, i), h = Ee(a, c, i) || 1;
|
|
564
|
+
return /* @__PURE__ */ b("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
|
|
565
565
|
/* @__PURE__ */ r(
|
|
566
566
|
"select",
|
|
567
567
|
{
|
|
568
568
|
className: "widget-filter__select",
|
|
569
569
|
value: c,
|
|
570
570
|
onChange: (d) => {
|
|
571
|
-
const
|
|
571
|
+
const f = parseInt(d.target.value), v = j(f, i)[0];
|
|
572
572
|
v && n(`${v.start}|${v.end}`);
|
|
573
573
|
},
|
|
574
|
-
children:
|
|
574
|
+
children: m.map((d) => /* @__PURE__ */ r("option", { value: d, children: d }, d))
|
|
575
575
|
}
|
|
576
576
|
),
|
|
577
577
|
/* @__PURE__ */ r(
|
|
@@ -580,32 +580,32 @@ function Ct({ value: e, dateBounds: t, onChange: n }) {
|
|
|
580
580
|
className: "widget-filter__select",
|
|
581
581
|
value: i,
|
|
582
582
|
onChange: (d) => {
|
|
583
|
-
const
|
|
583
|
+
const f = parseInt(d.target.value), v = j(c, f)[0];
|
|
584
584
|
v && n(`${v.start}|${v.end}`);
|
|
585
585
|
},
|
|
586
|
-
children:
|
|
586
|
+
children: _e.map((d, f) => /* @__PURE__ */ r("option", { value: f + 1, children: d }, f + 1))
|
|
587
587
|
}
|
|
588
588
|
),
|
|
589
589
|
/* @__PURE__ */ r(
|
|
590
590
|
"select",
|
|
591
591
|
{
|
|
592
592
|
className: "widget-filter__select",
|
|
593
|
-
value:
|
|
593
|
+
value: h,
|
|
594
594
|
onChange: (d) => {
|
|
595
|
-
const
|
|
596
|
-
|
|
595
|
+
const f = o[parseInt(d.target.value) - 1];
|
|
596
|
+
f && n(`${f.start}|${f.end}`);
|
|
597
597
|
},
|
|
598
598
|
children: o.map((d) => /* @__PURE__ */ r("option", { value: d.index, children: d.label }, d.index))
|
|
599
599
|
}
|
|
600
600
|
)
|
|
601
601
|
] });
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function xt({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }) {
|
|
604
604
|
const s = e.filterType || "select", c = e.label || "Filtro", i = e.dateFilterMode || "range";
|
|
605
|
-
return /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ b("div", { className: "widget-filter", children: [
|
|
606
606
|
/* @__PURE__ */ r("label", { className: "widget-filter__label", children: c }),
|
|
607
607
|
s === "date_range" ? /* @__PURE__ */ r(
|
|
608
|
-
|
|
608
|
+
$e,
|
|
609
609
|
{
|
|
610
610
|
mode: i,
|
|
611
611
|
value: t,
|
|
@@ -613,7 +613,7 @@ function At({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }
|
|
|
613
613
|
onChange: l
|
|
614
614
|
}
|
|
615
615
|
) : /* @__PURE__ */ r(
|
|
616
|
-
|
|
616
|
+
Et,
|
|
617
617
|
{
|
|
618
618
|
value: t,
|
|
619
619
|
options: n,
|
|
@@ -624,10 +624,10 @@ function At({ config: e, value: t, options: n = [], dateBounds: a, onChange: l }
|
|
|
624
624
|
)
|
|
625
625
|
] });
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function Et({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
|
|
628
628
|
if (a)
|
|
629
629
|
return /* @__PURE__ */ r(
|
|
630
|
-
|
|
630
|
+
pe,
|
|
631
631
|
{
|
|
632
632
|
value: e,
|
|
633
633
|
options: t,
|
|
@@ -637,10 +637,10 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
|
|
|
637
637
|
);
|
|
638
638
|
if (n) {
|
|
639
639
|
const s = e ? e.split(V) : [], c = (i) => {
|
|
640
|
-
const
|
|
641
|
-
l(
|
|
640
|
+
const m = s.includes(i) ? s.filter((o) => o !== i) : [...s, i];
|
|
641
|
+
l(m.join(V));
|
|
642
642
|
};
|
|
643
|
-
return /* @__PURE__ */
|
|
643
|
+
return /* @__PURE__ */ b("div", { className: "widget-filter__multi", children: [
|
|
644
644
|
s.length > 0 && /* @__PURE__ */ r(
|
|
645
645
|
"button",
|
|
646
646
|
{
|
|
@@ -650,7 +650,7 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
|
|
|
650
650
|
children: "Limpar filtro"
|
|
651
651
|
}
|
|
652
652
|
),
|
|
653
|
-
t.map((i) => /* @__PURE__ */
|
|
653
|
+
t.map((i) => /* @__PURE__ */ b("label", { className: "widget-filter__multi-option", children: [
|
|
654
654
|
/* @__PURE__ */ r(
|
|
655
655
|
"input",
|
|
656
656
|
{
|
|
@@ -663,7 +663,7 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
|
|
|
663
663
|
] }, i))
|
|
664
664
|
] });
|
|
665
665
|
}
|
|
666
|
-
return /* @__PURE__ */
|
|
666
|
+
return /* @__PURE__ */ b(
|
|
667
667
|
"select",
|
|
668
668
|
{
|
|
669
669
|
className: "widget-filter__select",
|
|
@@ -676,15 +676,15 @@ function xt({ value: e, options: t, multi: n, searchable: a, onChange: l }) {
|
|
|
676
676
|
}
|
|
677
677
|
);
|
|
678
678
|
}
|
|
679
|
-
const
|
|
679
|
+
const Lt = {
|
|
680
680
|
currency: "R$",
|
|
681
681
|
percentage: "%"
|
|
682
682
|
};
|
|
683
|
-
function
|
|
684
|
-
const a = e.label || "Variavel", l = e.locked || !1, s = e.variableFormat || "number", c =
|
|
685
|
-
return /* @__PURE__ */
|
|
683
|
+
function Ot({ config: e, value: t, onChange: n }) {
|
|
684
|
+
const a = e.label || "Variavel", l = e.locked || !1, s = e.variableFormat || "number", c = Lt[s] || "";
|
|
685
|
+
return /* @__PURE__ */ b("div", { className: `widget-variable ${l ? "widget-variable--locked" : ""}`, children: [
|
|
686
686
|
/* @__PURE__ */ r("label", { className: "widget-variable__label", children: a }),
|
|
687
|
-
/* @__PURE__ */
|
|
687
|
+
/* @__PURE__ */ b("div", { className: "widget-variable__input-wrapper", children: [
|
|
688
688
|
/* @__PURE__ */ r(
|
|
689
689
|
"input",
|
|
690
690
|
{
|
|
@@ -701,18 +701,18 @@ function Mt({ config: e, value: t, onChange: n }) {
|
|
|
701
701
|
l && /* @__PURE__ */ r("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
702
702
|
] });
|
|
703
703
|
}
|
|
704
|
-
function
|
|
704
|
+
function Pt({ config: e, palette: t, onChange: n }) {
|
|
705
705
|
const a = e.label || "Cores", l = e.locked || !1;
|
|
706
|
-
return /* @__PURE__ */
|
|
706
|
+
return /* @__PURE__ */ b("div", { className: `widget-palette ${l ? "widget-palette--locked" : ""}`, children: [
|
|
707
707
|
/* @__PURE__ */ r("label", { className: "widget-palette__label", children: a }),
|
|
708
|
-
/* @__PURE__ */ r(
|
|
708
|
+
/* @__PURE__ */ r(Ie, { selected: t, onSelect: n, customMode: !0, disabled: l }),
|
|
709
709
|
l && /* @__PURE__ */ r("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
710
710
|
] });
|
|
711
711
|
}
|
|
712
|
-
const
|
|
712
|
+
const It = {
|
|
713
713
|
failed_to_compute: "Não foi possível calcular este widget"
|
|
714
714
|
};
|
|
715
|
-
function
|
|
715
|
+
function Wt({
|
|
716
716
|
type: e,
|
|
717
717
|
computed: t,
|
|
718
718
|
palette: n,
|
|
@@ -721,35 +721,35 @@ function Lt({
|
|
|
721
721
|
filterOptions: s,
|
|
722
722
|
dateBounds: c,
|
|
723
723
|
onFilterChange: i,
|
|
724
|
-
variableValue:
|
|
724
|
+
variableValue: m,
|
|
725
725
|
onVariableChange: o,
|
|
726
|
-
onPaletteChange:
|
|
726
|
+
onPaletteChange: h
|
|
727
727
|
}) {
|
|
728
728
|
if (t.error)
|
|
729
729
|
return /* @__PURE__ */ r(
|
|
730
|
-
|
|
730
|
+
P,
|
|
731
731
|
{
|
|
732
732
|
name: e.replace("_", "-"),
|
|
733
733
|
title: a == null ? void 0 : a.label,
|
|
734
734
|
state: "error",
|
|
735
|
-
stateMessage:
|
|
735
|
+
stateMessage: It[String(t.error)]
|
|
736
736
|
}
|
|
737
737
|
);
|
|
738
|
-
const d =
|
|
738
|
+
const d = We(n);
|
|
739
739
|
switch (e) {
|
|
740
740
|
case "kpi_card":
|
|
741
|
-
return /* @__PURE__ */ r(
|
|
741
|
+
return /* @__PURE__ */ r(ut, { data: t, label: a == null ? void 0 : a.label });
|
|
742
742
|
case "gauge":
|
|
743
|
-
return /* @__PURE__ */ r(
|
|
743
|
+
return /* @__PURE__ */ r(ft, { data: t, palette: d, label: a == null ? void 0 : a.label });
|
|
744
744
|
case "chart":
|
|
745
|
-
return /* @__PURE__ */ r(gt, { data: t, palette: d, label: a == null ? void 0 : a.label });
|
|
746
|
-
case "composition":
|
|
747
745
|
return /* @__PURE__ */ r(vt, { data: t, palette: d, label: a == null ? void 0 : a.label });
|
|
746
|
+
case "composition":
|
|
747
|
+
return /* @__PURE__ */ r(St, { data: t, palette: d, label: a == null ? void 0 : a.label });
|
|
748
748
|
case "table":
|
|
749
|
-
return /* @__PURE__ */ r(
|
|
749
|
+
return /* @__PURE__ */ r($t, { data: t, label: a == null ? void 0 : a.label });
|
|
750
750
|
case "filter":
|
|
751
751
|
return a && i ? /* @__PURE__ */ r(
|
|
752
|
-
|
|
752
|
+
xt,
|
|
753
753
|
{
|
|
754
754
|
config: a,
|
|
755
755
|
value: l || "",
|
|
@@ -759,33 +759,33 @@ function Lt({
|
|
|
759
759
|
}
|
|
760
760
|
) : null;
|
|
761
761
|
case "variable": {
|
|
762
|
-
const
|
|
763
|
-
return
|
|
764
|
-
|
|
762
|
+
const f = a;
|
|
763
|
+
return f && o ? /* @__PURE__ */ r(
|
|
764
|
+
Ot,
|
|
765
765
|
{
|
|
766
|
-
config:
|
|
767
|
-
value:
|
|
766
|
+
config: f,
|
|
767
|
+
value: m ?? f.variableValue ?? 0,
|
|
768
768
|
onChange: o
|
|
769
769
|
}
|
|
770
770
|
) : null;
|
|
771
771
|
}
|
|
772
772
|
case "color_palette":
|
|
773
|
-
return a &&
|
|
774
|
-
|
|
773
|
+
return a && h ? /* @__PURE__ */ r(
|
|
774
|
+
Pt,
|
|
775
775
|
{
|
|
776
776
|
config: a,
|
|
777
777
|
palette: n,
|
|
778
|
-
onChange:
|
|
778
|
+
onChange: h
|
|
779
779
|
}
|
|
780
780
|
) : null;
|
|
781
781
|
default:
|
|
782
|
-
return /* @__PURE__ */ r(
|
|
782
|
+
return /* @__PURE__ */ r(P, { name: "unknown", state: "unconfigured" });
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
const
|
|
786
|
-
function
|
|
785
|
+
const Dt = Ae(Wt), zt = (e, t) => e.grid.y - t.grid.y || e.grid.x - t.grid.x, Ht = {}, ce = [];
|
|
786
|
+
function ir({
|
|
787
787
|
token: e,
|
|
788
|
-
cellAspect: t =
|
|
788
|
+
cellAspect: t = Ge,
|
|
789
789
|
stackBelow: n,
|
|
790
790
|
onGeometryChange: a,
|
|
791
791
|
silenceWarnings: l,
|
|
@@ -794,134 +794,143 @@ function tr({
|
|
|
794
794
|
const {
|
|
795
795
|
layout: c,
|
|
796
796
|
renderData: i,
|
|
797
|
-
loading:
|
|
797
|
+
loading: m,
|
|
798
798
|
error: o,
|
|
799
|
-
filters:
|
|
799
|
+
filters: h,
|
|
800
800
|
variables: d,
|
|
801
|
-
palette:
|
|
802
|
-
setFilter:
|
|
801
|
+
palette: f,
|
|
802
|
+
setFilter: p,
|
|
803
803
|
setVariable: v,
|
|
804
804
|
setPalette: S
|
|
805
|
-
} =
|
|
805
|
+
} = rt(e), { rootRef: k, gridRef: A, stacked: y } = it({
|
|
806
806
|
columns: (c == null ? void 0 : c.gridColumns) ?? 0,
|
|
807
807
|
cellAspect: t,
|
|
808
808
|
stackBelow: n,
|
|
809
809
|
onGeometryChange: a,
|
|
810
810
|
silenceWarnings: l
|
|
811
|
-
}),
|
|
812
|
-
const
|
|
813
|
-
return
|
|
814
|
-
}, [c == null ? void 0 : c.widgets,
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
811
|
+
}), w = Y(() => {
|
|
812
|
+
const u = (c == null ? void 0 : c.widgets) ?? [];
|
|
813
|
+
return y ? [...u].sort(zt) : u;
|
|
814
|
+
}, [c == null ? void 0 : c.widgets, y]), N = Y(() => {
|
|
815
|
+
const u = {};
|
|
816
|
+
for (const R of w)
|
|
817
|
+
u[R.id] = {
|
|
818
|
+
onFilter: (C) => p(R.id, C),
|
|
819
|
+
onVariable: (C) => v(R.id, C)
|
|
820
|
+
};
|
|
821
|
+
return u;
|
|
822
|
+
}, [w, p, v]), T = {
|
|
823
|
+
"--dash-gap": `${ne}px`,
|
|
824
|
+
"--dash-pad": `${je}px`
|
|
825
|
+
}, x = ["preview-tab", s].filter(Boolean).join(" ");
|
|
826
|
+
let _;
|
|
819
827
|
if (o && !c)
|
|
820
|
-
|
|
828
|
+
_ = /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o });
|
|
821
829
|
else if (!c)
|
|
822
|
-
|
|
830
|
+
_ = /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." });
|
|
823
831
|
else if (c.widgets.length === 0)
|
|
824
|
-
|
|
832
|
+
_ = /* @__PURE__ */ r("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." });
|
|
825
833
|
else {
|
|
826
|
-
const
|
|
834
|
+
const u = (i == null ? void 0 : i.widgets) ?? {}, R = (i == null ? void 0 : i.date_bounds) ?? null, C = {
|
|
827
835
|
"--dash-cols": c.gridColumns,
|
|
828
836
|
"--dash-rows": c.gridRows,
|
|
829
|
-
...
|
|
830
|
-
},
|
|
831
|
-
|
|
837
|
+
...be(f)
|
|
838
|
+
}, F = ["preview-tab__grid", y && "preview-tab__grid--stacked"].filter(Boolean).join(" ");
|
|
839
|
+
_ = /* @__PURE__ */ b(he, { children: [
|
|
832
840
|
o && !i && /* @__PURE__ */ r("div", { className: "preview-tab__error", children: o }),
|
|
833
|
-
i && /* @__PURE__ */ r("div", { className:
|
|
834
|
-
|
|
841
|
+
i && /* @__PURE__ */ r("div", { className: F, style: C, ref: A, children: w.map((g) => {
|
|
842
|
+
var Q, Z;
|
|
843
|
+
const I = De.has(g.type), L = u[g.id], O = y ? {
|
|
835
844
|
gridColumn: 1,
|
|
836
|
-
aspectRatio: `${
|
|
837
|
-
minHeight: `${
|
|
845
|
+
aspectRatio: `${He(g.grid.w, g.grid.h, t)}`,
|
|
846
|
+
minHeight: `${ze(g.grid.h, Ye, ne, 0)}px`
|
|
838
847
|
} : {
|
|
839
|
-
gridColumn: `${
|
|
840
|
-
gridRow: `${
|
|
841
|
-
},
|
|
848
|
+
gridColumn: `${g.grid.x + 1} / span ${g.grid.w}`,
|
|
849
|
+
gridRow: `${g.grid.y + 1} / span ${g.grid.h}`
|
|
850
|
+
}, Ce = g.type === "variable" ? d[g.id] ?? (L == null ? void 0 : L.value) ?? g.config.variableValue ?? 0 : void 0;
|
|
842
851
|
return /* @__PURE__ */ r(
|
|
843
852
|
"div",
|
|
844
853
|
{
|
|
845
|
-
className: `preview-tab__widget ${
|
|
846
|
-
style:
|
|
847
|
-
children:
|
|
848
|
-
|
|
854
|
+
className: `preview-tab__widget ${I ? "preview-tab__widget--control" : ""}`,
|
|
855
|
+
style: O,
|
|
856
|
+
children: I || L ? /* @__PURE__ */ r(
|
|
857
|
+
Dt,
|
|
849
858
|
{
|
|
850
|
-
type:
|
|
851
|
-
computed: L ||
|
|
852
|
-
palette:
|
|
853
|
-
config:
|
|
854
|
-
filterValue:
|
|
859
|
+
type: g.type,
|
|
860
|
+
computed: L || Ht,
|
|
861
|
+
palette: f,
|
|
862
|
+
config: g.config,
|
|
863
|
+
filterValue: h[g.id] || "",
|
|
855
864
|
filterOptions: (
|
|
856
865
|
// Estruturais: vem do /layout (cacheavel), nao do /render —
|
|
857
866
|
// recalcula-los a cada render custaria um DISTINCT por filtro.
|
|
858
|
-
|
|
867
|
+
g.type === "filter" ? g.config.availableValues ?? ce : ce
|
|
859
868
|
),
|
|
860
|
-
dateBounds:
|
|
861
|
-
onFilterChange: (
|
|
862
|
-
variableValue:
|
|
863
|
-
onVariableChange: (
|
|
869
|
+
dateBounds: R,
|
|
870
|
+
onFilterChange: (Q = N[g.id]) == null ? void 0 : Q.onFilter,
|
|
871
|
+
variableValue: Ce,
|
|
872
|
+
onVariableChange: (Z = N[g.id]) == null ? void 0 : Z.onVariable,
|
|
864
873
|
onPaletteChange: S
|
|
865
874
|
}
|
|
866
|
-
) : /* @__PURE__ */ r("div", { className: "preview-tab__widget-loading", children:
|
|
875
|
+
) : /* @__PURE__ */ r("div", { className: "preview-tab__widget-loading", children: m ? "Carregando..." : "Sem dados" })
|
|
867
876
|
},
|
|
868
|
-
|
|
877
|
+
g.id
|
|
869
878
|
);
|
|
870
879
|
}) }),
|
|
871
|
-
|
|
880
|
+
m && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
|
|
872
881
|
] });
|
|
873
882
|
}
|
|
874
|
-
return /* @__PURE__ */ r("div", { className:
|
|
883
|
+
return /* @__PURE__ */ r("div", { className: x, style: T, ref: k, children: _ });
|
|
875
884
|
}
|
|
876
|
-
function
|
|
885
|
+
function jt(e, t) {
|
|
877
886
|
const n = URL.createObjectURL(e), a = document.createElement("a");
|
|
878
887
|
a.href = n, a.download = t, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
|
|
879
888
|
}
|
|
880
|
-
const
|
|
881
|
-
function
|
|
889
|
+
const Gt = 768, Yt = 879;
|
|
890
|
+
function Vt(e) {
|
|
882
891
|
return Array.from(e.normalize("NFD")).filter((t) => {
|
|
883
892
|
const n = t.codePointAt(0) ?? 0;
|
|
884
|
-
return n <
|
|
893
|
+
return n < Gt || n > Yt;
|
|
885
894
|
}).join("");
|
|
886
895
|
}
|
|
887
|
-
function
|
|
888
|
-
return `${
|
|
896
|
+
function Kt(e, t) {
|
|
897
|
+
return `${Vt(e).replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase() || "documento"}.${t}`;
|
|
889
898
|
}
|
|
890
|
-
const
|
|
891
|
-
function
|
|
892
|
-
const [t, n] =
|
|
893
|
-
|
|
894
|
-
let
|
|
895
|
-
return v.current = !1, S.current = null,
|
|
896
|
-
|
|
897
|
-
}).catch((
|
|
898
|
-
|
|
899
|
+
const Ut = 300;
|
|
900
|
+
function qt(e) {
|
|
901
|
+
const [t, n] = M(null), [a, l] = M(null), [s, c] = M({}), [i, m] = M(!0), [o, h] = M(null), [d, f] = M(!1), p = $(), v = $(!1), S = $(null), k = $(!1);
|
|
902
|
+
W(() => {
|
|
903
|
+
let w = !1;
|
|
904
|
+
return v.current = !1, S.current = null, k.current = !1, Ve(e).then((N) => {
|
|
905
|
+
w || n(N);
|
|
906
|
+
}).catch((N) => {
|
|
907
|
+
w || h(N.message);
|
|
899
908
|
}), () => {
|
|
900
|
-
|
|
909
|
+
w = !0;
|
|
901
910
|
};
|
|
902
|
-
}, [e]),
|
|
911
|
+
}, [e]), W(() => {
|
|
903
912
|
if (!t) return;
|
|
904
|
-
const
|
|
905
|
-
if (
|
|
906
|
-
|
|
907
|
-
const
|
|
908
|
-
return
|
|
909
|
-
|
|
910
|
-
S.current =
|
|
911
|
-
const
|
|
912
|
-
return
|
|
913
|
-
})),
|
|
914
|
-
}).catch((x) =>
|
|
915
|
-
},
|
|
916
|
-
|
|
913
|
+
const w = D(s), N = H(w);
|
|
914
|
+
if (N === S.current) return;
|
|
915
|
+
p.current && clearTimeout(p.current);
|
|
916
|
+
const T = k.current ? Ut : 0;
|
|
917
|
+
return p.current = setTimeout(() => {
|
|
918
|
+
m(!0), Ke(e, w).then((x) => {
|
|
919
|
+
S.current = N, k.current = !0, l(x), !v.current && x.applied && (v.current = !0, c((_) => {
|
|
920
|
+
const u = { ...ke(x.applied), ..._ };
|
|
921
|
+
return Se(u, _) ? _ : (S.current = H(D(u)), u);
|
|
922
|
+
})), h(null);
|
|
923
|
+
}).catch((x) => h(x.message)).finally(() => m(!1));
|
|
924
|
+
}, T), () => {
|
|
925
|
+
p.current && clearTimeout(p.current);
|
|
917
926
|
};
|
|
918
927
|
}, [e, t, s]);
|
|
919
|
-
const A = E((
|
|
920
|
-
c((
|
|
921
|
-
}, []),
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
}).catch((
|
|
928
|
+
const A = E((w, N) => {
|
|
929
|
+
c((T) => ({ ...T, [w]: N }));
|
|
930
|
+
}, []), y = E(() => {
|
|
931
|
+
f(!0), Ue(e, D(s)).then((w) => {
|
|
932
|
+
jt(w, Kt((t == null ? void 0 : t.name) ?? "demonstrativo", "pdf")), h(null);
|
|
933
|
+
}).catch((w) => h(w.message)).finally(() => f(!1));
|
|
925
934
|
}, [e, s, t == null ? void 0 : t.name]);
|
|
926
935
|
return {
|
|
927
936
|
layout: t,
|
|
@@ -930,22 +939,22 @@ function jt(e) {
|
|
|
930
939
|
error: o,
|
|
931
940
|
filters: s,
|
|
932
941
|
setFilter: A,
|
|
933
|
-
downloadPdf:
|
|
942
|
+
downloadPdf: y,
|
|
934
943
|
downloading: d
|
|
935
944
|
};
|
|
936
945
|
}
|
|
937
|
-
const
|
|
938
|
-
function
|
|
939
|
-
return { paddingLeft: `${
|
|
946
|
+
const Bt = 8, Xt = 14;
|
|
947
|
+
function de(e) {
|
|
948
|
+
return { paddingLeft: `${Bt + e * Xt}px` };
|
|
940
949
|
}
|
|
941
|
-
function
|
|
950
|
+
function Qt(e) {
|
|
942
951
|
const t = {};
|
|
943
952
|
return e != null && e.accent && (t["--stmt-accent"] = e.accent), e != null && e.positive && (t["--stmt-positive"] = e.positive), e != null && e.negative && (t["--stmt-negative"] = e.negative), t;
|
|
944
953
|
}
|
|
945
|
-
function
|
|
954
|
+
function ue(e) {
|
|
946
955
|
return e == null || e === 0 ? "stmt__number" : `stmt__number stmt__number--${e > 0 ? "pos" : "neg"}`;
|
|
947
956
|
}
|
|
948
|
-
const
|
|
957
|
+
const Zt = {
|
|
949
958
|
day: "day",
|
|
950
959
|
week: "week",
|
|
951
960
|
month: "month",
|
|
@@ -953,13 +962,13 @@ const Kt = {
|
|
|
953
962
|
year: "year",
|
|
954
963
|
total: "month"
|
|
955
964
|
};
|
|
956
|
-
function
|
|
965
|
+
function Jt({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onChange: s }) {
|
|
957
966
|
if (e.type === "date_range") {
|
|
958
967
|
const c = e.dateFilterMode ?? "range";
|
|
959
|
-
return /* @__PURE__ */
|
|
968
|
+
return /* @__PURE__ */ b("div", { className: `stmt__filter stmt__filter--date stmt__filter--${c}`, children: [
|
|
960
969
|
/* @__PURE__ */ r("span", { className: "stmt__filter-label", children: e.label }),
|
|
961
970
|
/* @__PURE__ */ r(
|
|
962
|
-
|
|
971
|
+
$e,
|
|
963
972
|
{
|
|
964
973
|
mode: c,
|
|
965
974
|
value: t,
|
|
@@ -970,10 +979,10 @@ function Ut({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onCh
|
|
|
970
979
|
)
|
|
971
980
|
] });
|
|
972
981
|
}
|
|
973
|
-
return /* @__PURE__ */
|
|
982
|
+
return /* @__PURE__ */ b("div", { className: "stmt__filter", children: [
|
|
974
983
|
/* @__PURE__ */ r("span", { className: "stmt__filter-label", children: e.label }),
|
|
975
984
|
/* @__PURE__ */ r(
|
|
976
|
-
|
|
985
|
+
pe,
|
|
977
986
|
{
|
|
978
987
|
value: t,
|
|
979
988
|
options: n,
|
|
@@ -983,7 +992,7 @@ function Ut({ definition: e, value: t, options: n, bounds: a, rangeUnit: l, onCh
|
|
|
983
992
|
)
|
|
984
993
|
] });
|
|
985
994
|
}
|
|
986
|
-
const
|
|
995
|
+
const er = 13, me = {
|
|
987
996
|
day: ["dia", "dias"],
|
|
988
997
|
week: ["semana", "semanas"],
|
|
989
998
|
month: ["mês", "meses"],
|
|
@@ -991,11 +1000,11 @@ const qt = 13, ce = {
|
|
|
991
1000
|
year: ["ano", "anos"],
|
|
992
1001
|
total: ["período", "períodos"]
|
|
993
1002
|
};
|
|
994
|
-
function
|
|
995
|
-
const [n, a] =
|
|
1003
|
+
function tr(e, t) {
|
|
1004
|
+
const [n, a] = me[t] ?? me.total;
|
|
996
1005
|
return `Variação sobre ${e} ${e === 1 ? n : a} atrás`;
|
|
997
1006
|
}
|
|
998
|
-
function
|
|
1007
|
+
function rr({
|
|
999
1008
|
line: e,
|
|
1000
1009
|
columnCount: t,
|
|
1001
1010
|
showTotal: n,
|
|
@@ -1006,8 +1015,8 @@ function Bt({
|
|
|
1006
1015
|
if (e.type === "separator")
|
|
1007
1016
|
return /* @__PURE__ */ r("tr", { className: "stmt__row stmt__row--separator", children: /* @__PURE__ */ r("td", { colSpan: t }) });
|
|
1008
1017
|
if (e.type === "header" && e.formatted.length === 0)
|
|
1009
|
-
return /* @__PURE__ */
|
|
1010
|
-
/* @__PURE__ */ r("th", { scope: "row", style:
|
|
1018
|
+
return /* @__PURE__ */ b("tr", { className: "stmt__row stmt__row--header", children: [
|
|
1019
|
+
/* @__PURE__ */ r("th", { scope: "row", style: de(e.style.indent), children: e.label }),
|
|
1011
1020
|
/* @__PURE__ */ r("td", { colSpan: t - 1 })
|
|
1012
1021
|
] });
|
|
1013
1022
|
const c = [
|
|
@@ -1015,14 +1024,14 @@ function Bt({
|
|
|
1015
1024
|
`stmt__row--${e.type}`,
|
|
1016
1025
|
e.style.bold && "stmt__row--bold"
|
|
1017
1026
|
].filter(Boolean).join(" ");
|
|
1018
|
-
return /* @__PURE__ */
|
|
1019
|
-
/* @__PURE__ */ r("th", { scope: "row", style:
|
|
1020
|
-
e.formatted.map((i,
|
|
1027
|
+
return /* @__PURE__ */ b("tr", { className: c, children: [
|
|
1028
|
+
/* @__PURE__ */ r("th", { scope: "row", style: de(e.style.indent), children: e.label }),
|
|
1029
|
+
e.formatted.map((i, m) => {
|
|
1021
1030
|
var d;
|
|
1022
|
-
const o = e.horizontalAnalysis[
|
|
1023
|
-
return /* @__PURE__ */
|
|
1024
|
-
/* @__PURE__ */ r("span", { className:
|
|
1025
|
-
a && e.verticalAnalysis[
|
|
1031
|
+
const o = e.horizontalAnalysis[m], h = (d = e.comparison) == null ? void 0 : d[m];
|
|
1032
|
+
return /* @__PURE__ */ b("td", { className: "stmt__value", children: [
|
|
1033
|
+
/* @__PURE__ */ r("span", { className: ue(e.values[m]), children: i }),
|
|
1034
|
+
a && e.verticalAnalysis[m] != null && /* @__PURE__ */ r("span", { className: "stmt__aux", title: "Análise vertical", children: z(e.verticalAnalysis[m], "percentage") }),
|
|
1026
1035
|
l && o != null && /* @__PURE__ */ r(
|
|
1027
1036
|
"span",
|
|
1028
1037
|
{
|
|
@@ -1031,59 +1040,59 @@ function Bt({
|
|
|
1031
1040
|
children: z(o, "percentage")
|
|
1032
1041
|
}
|
|
1033
1042
|
),
|
|
1034
|
-
s &&
|
|
1043
|
+
s && h != null && /* @__PURE__ */ b(
|
|
1035
1044
|
"span",
|
|
1036
1045
|
{
|
|
1037
|
-
className: `stmt__aux stmt__aux--${
|
|
1046
|
+
className: `stmt__aux stmt__aux--${h < 0 ? "down" : "up"}`,
|
|
1038
1047
|
title: s,
|
|
1039
1048
|
children: [
|
|
1040
1049
|
"vs ",
|
|
1041
|
-
z(
|
|
1050
|
+
z(h, "percentage")
|
|
1042
1051
|
]
|
|
1043
1052
|
}
|
|
1044
1053
|
)
|
|
1045
|
-
] },
|
|
1054
|
+
] }, m);
|
|
1046
1055
|
}),
|
|
1047
|
-
n && /* @__PURE__ */ r("td", { className: "stmt__value stmt__value--total", children: /* @__PURE__ */ r("span", { className:
|
|
1056
|
+
n && /* @__PURE__ */ r("td", { className: "stmt__value stmt__value--total", children: /* @__PURE__ */ r("span", { className: ue(e.total), children: e.totalFormatted ?? "-" }) })
|
|
1048
1057
|
] });
|
|
1049
1058
|
}
|
|
1050
|
-
function
|
|
1059
|
+
function or({ token: e, palette: t, showDownload: n = !0, className: a }) {
|
|
1051
1060
|
const {
|
|
1052
1061
|
layout: l,
|
|
1053
1062
|
renderData: s,
|
|
1054
1063
|
loading: c,
|
|
1055
1064
|
error: i,
|
|
1056
|
-
filters:
|
|
1065
|
+
filters: m,
|
|
1057
1066
|
setFilter: o,
|
|
1058
|
-
downloadPdf:
|
|
1067
|
+
downloadPdf: h,
|
|
1059
1068
|
downloading: d
|
|
1060
|
-
} =
|
|
1061
|
-
...
|
|
1062
|
-
...
|
|
1069
|
+
} = qt(e), [f, p] = M(!1), v = ["stmt", a].filter(Boolean).join(" "), S = {
|
|
1070
|
+
...be(t),
|
|
1071
|
+
...Qt(l == null ? void 0 : l.colors)
|
|
1063
1072
|
};
|
|
1064
|
-
let
|
|
1073
|
+
let k;
|
|
1065
1074
|
if (i && !l)
|
|
1066
|
-
|
|
1075
|
+
k = /* @__PURE__ */ r("div", { className: "stmt__error", children: i });
|
|
1067
1076
|
else if (!l)
|
|
1068
|
-
|
|
1077
|
+
k = /* @__PURE__ */ r("div", { className: "stmt__state", children: "Carregando demonstrativo..." });
|
|
1069
1078
|
else {
|
|
1070
|
-
const A = (s == null ? void 0 : s.dateBounds) ?? l.dateBounds,
|
|
1071
|
-
|
|
1072
|
-
/* @__PURE__ */
|
|
1073
|
-
l.filters.map((
|
|
1074
|
-
|
|
1079
|
+
const A = (s == null ? void 0 : s.dateBounds) ?? l.dateBounds, y = l.periods.showTotal, w = (s == null ? void 0 : s.columns) ?? [], N = (s == null ? void 0 : s.lines) ?? [], T = 1 + w.length + (y ? 1 : 0), x = N.some((g) => g.verticalAnalysis.length > 0), _ = N.some((g) => g.horizontalAnalysis.length > 0), u = l.periods.comparisonOffset, R = u ? tr(u, l.periods.granularity) : void 0, C = er - (y ? 1 : 0), F = Math.max(0, w.length - C);
|
|
1080
|
+
k = /* @__PURE__ */ b(he, { children: [
|
|
1081
|
+
/* @__PURE__ */ b("div", { className: "stmt__toolbar", children: [
|
|
1082
|
+
l.filters.map((g) => /* @__PURE__ */ r(
|
|
1083
|
+
Jt,
|
|
1075
1084
|
{
|
|
1076
|
-
definition:
|
|
1077
|
-
value:
|
|
1078
|
-
options: l.filterOptions[
|
|
1085
|
+
definition: g,
|
|
1086
|
+
value: m[g.id] ?? "",
|
|
1087
|
+
options: l.filterOptions[g.id] ?? [],
|
|
1079
1088
|
bounds: A,
|
|
1080
|
-
rangeUnit:
|
|
1081
|
-
onChange: (
|
|
1089
|
+
rangeUnit: Zt[l.periods.granularity] ?? "day",
|
|
1090
|
+
onChange: (I) => o(g.id, I)
|
|
1082
1091
|
},
|
|
1083
|
-
|
|
1092
|
+
g.id
|
|
1084
1093
|
)),
|
|
1085
|
-
/* @__PURE__ */
|
|
1086
|
-
/* @__PURE__ */
|
|
1094
|
+
/* @__PURE__ */ b("div", { className: "stmt__toolbar-end", children: [
|
|
1095
|
+
/* @__PURE__ */ b("span", { className: "stmt__bounds", children: [
|
|
1087
1096
|
"Base: ",
|
|
1088
1097
|
A.min,
|
|
1089
1098
|
" a ",
|
|
@@ -1095,11 +1104,11 @@ function rr({ token: e, palette: t, showDownload: n = !0, className: a }) {
|
|
|
1095
1104
|
type: "button",
|
|
1096
1105
|
className: "stmt__download",
|
|
1097
1106
|
onClick: () => {
|
|
1098
|
-
if (
|
|
1099
|
-
|
|
1107
|
+
if (F > 0 && !f) {
|
|
1108
|
+
p(!0);
|
|
1100
1109
|
return;
|
|
1101
1110
|
}
|
|
1102
|
-
|
|
1111
|
+
p(!1), h();
|
|
1103
1112
|
},
|
|
1104
1113
|
disabled: d || !s,
|
|
1105
1114
|
title: "Baixar o documento em PDF",
|
|
@@ -1109,49 +1118,49 @@ function rr({ token: e, palette: t, showDownload: n = !0, className: a }) {
|
|
|
1109
1118
|
] })
|
|
1110
1119
|
] }),
|
|
1111
1120
|
i && /* @__PURE__ */ r("div", { className: "stmt__error", children: i }),
|
|
1112
|
-
|
|
1121
|
+
f && F > 0 && /* @__PURE__ */ b("div", { className: "stmt__warning", children: [
|
|
1113
1122
|
"O PDF cabe ",
|
|
1114
|
-
|
|
1123
|
+
C,
|
|
1115
1124
|
" períodos e este documento tem ",
|
|
1116
|
-
|
|
1125
|
+
w.length,
|
|
1117
1126
|
": o arquivo sairá com os ",
|
|
1118
|
-
|
|
1127
|
+
C,
|
|
1119
1128
|
" mais recentes",
|
|
1120
|
-
|
|
1129
|
+
y && ", e a coluna de total seguirá cobrindo a janela inteira",
|
|
1121
1130
|
'. Clique em "Baixar PDF" de novo para gerar assim, ou reduza o período.'
|
|
1122
1131
|
] }),
|
|
1123
|
-
(s == null ? void 0 : s.truncated) && /* @__PURE__ */
|
|
1132
|
+
(s == null ? void 0 : s.truncated) && /* @__PURE__ */ b("div", { className: "stmt__warning", children: [
|
|
1124
1133
|
"A janela pedida excede o limite de colunas: o documento mostra as primeiras ",
|
|
1125
|
-
|
|
1134
|
+
w.length,
|
|
1126
1135
|
". Escolha um período menor ou uma coluna mais larga."
|
|
1127
1136
|
] }),
|
|
1128
|
-
s ?
|
|
1129
|
-
/* @__PURE__ */ r("thead", { children: /* @__PURE__ */
|
|
1137
|
+
s ? w.length === 0 ? /* @__PURE__ */ r("div", { className: "stmt__state", children: "Nenhum período na janela selecionada." }) : N.length === 0 ? /* @__PURE__ */ r("div", { className: "stmt__state", children: "Este demonstrativo não possui linhas." }) : /* @__PURE__ */ r("div", { className: "stmt__scroll", children: /* @__PURE__ */ b("table", { className: "stmt__table", children: [
|
|
1138
|
+
/* @__PURE__ */ r("thead", { children: /* @__PURE__ */ b("tr", { children: [
|
|
1130
1139
|
/* @__PURE__ */ r("th", { className: "stmt__corner", scope: "col", children: s.name }),
|
|
1131
|
-
|
|
1132
|
-
|
|
1140
|
+
w.map((g) => /* @__PURE__ */ r("th", { scope: "col", title: `${g.start} a ${g.end}`, children: g.label }, g.key)),
|
|
1141
|
+
y && /* @__PURE__ */ r("th", { scope: "col", className: "stmt__total-head", children: l.periods.totalLabel })
|
|
1133
1142
|
] }) }),
|
|
1134
|
-
/* @__PURE__ */ r("tbody", { children:
|
|
1135
|
-
|
|
1143
|
+
/* @__PURE__ */ r("tbody", { children: N.map((g) => /* @__PURE__ */ r(
|
|
1144
|
+
rr,
|
|
1136
1145
|
{
|
|
1137
|
-
line:
|
|
1138
|
-
columnCount:
|
|
1139
|
-
showTotal:
|
|
1146
|
+
line: g,
|
|
1147
|
+
columnCount: T,
|
|
1148
|
+
showTotal: y,
|
|
1140
1149
|
showVertical: x,
|
|
1141
|
-
showHorizontal:
|
|
1142
|
-
comparisonLabel:
|
|
1150
|
+
showHorizontal: _,
|
|
1151
|
+
comparisonLabel: R
|
|
1143
1152
|
},
|
|
1144
|
-
|
|
1153
|
+
g.id
|
|
1145
1154
|
)) })
|
|
1146
1155
|
] }) }) : /* @__PURE__ */ r("div", { className: "stmt__state", children: "Calculando..." }),
|
|
1147
1156
|
c && s && /* @__PURE__ */ r("div", { className: "stmt__recalculating", children: "Atualizando..." })
|
|
1148
1157
|
] });
|
|
1149
1158
|
}
|
|
1150
|
-
return /* @__PURE__ */ r("div", { className: v, style: S, children:
|
|
1159
|
+
return /* @__PURE__ */ r("div", { className: v, style: S, children: k });
|
|
1151
1160
|
}
|
|
1152
1161
|
export {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1162
|
+
ur as ApiError,
|
|
1163
|
+
ir as Dashboard,
|
|
1164
|
+
or as Statement
|
|
1156
1165
|
};
|
|
1157
1166
|
//# sourceMappingURL=index.js.map
|