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