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