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