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