@actionexec/dashboards 0.6.0 → 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,450 +1,532 @@
1
- import { jsxs as _, jsx as a } from "react/jsx-runtime";
2
- import { useState as k, useRef as F, useEffect as T, useCallback as R, useMemo as j } from "react";
3
- import { Q as z, R as U, n as L, L as H, G as I, I as D, m as P, w as M, 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-Bsda66uL.js";
4
- import { U as Ue } from "./ColorPaletteSelector-Bsda66uL.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 ge, XAxis as he, YAxis as ue, Legend as me } from "recharts";
6
- const _e = 300;
7
- function be(t) {
8
- const [l, n] = k(null), [r, e] = k(null), [i, c] = k({}), [s, m] = k({}), [g, o] = k(null), [d, h] = k(!0), [w, u] = k(null), b = F(), y = F(!1);
9
- T(() => {
10
- let v = !1;
11
- return z(t).then((f) => {
12
- v || n(f);
13
- }).catch((f) => {
14
- v || u(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
- }, [t]), T(() => {
19
- if (l)
20
- return b.current && clearTimeout(b.current), b.current = setTimeout(() => {
21
- const v = pe(i, s);
22
- h(!0), U(t, v).then((f) => {
23
- e(f), !y.current && f.applied && (y.current = !0, c(($) => ({ ...fe(f.applied), ...$ }))), u(null);
24
- }).catch((f) => u(f.message)).finally(() => h(!1));
25
- }, _e), () => {
26
- b.current && clearTimeout(b.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
- }, [t, l, i, s]);
29
- const p = R((v, f) => {
30
- c(($) => ({ ...$, [v]: f }));
31
- }, []), S = R((v, f) => {
32
- m(($) => ({ ...$, [v]: f }));
33
- }, []), N = R((v) => {
34
- o(v);
35
- }, []), C = j(
36
- () => g ?? (l == null ? void 0 : l.palette) ?? [],
37
- [g, l]
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: l,
41
- renderData: r,
42
- loading: d,
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: p,
48
- setVariable: S,
49
- setPalette: N
46
+ palette: F,
47
+ setFilter: T,
48
+ setVariable: k,
49
+ setPalette: E
50
50
  };
51
51
  }
52
- function pe(t, l) {
53
- const n = {};
54
- for (const [r, e] of Object.entries(t))
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_${r}`] = e;
60
- for (const [r, e] of Object.entries(l))
61
- n[`v_${r}`] = String(e);
62
- return n;
63
- }
64
- function fe(t) {
65
- const l = {};
59
+ a[`f_${n}`] = r;
66
60
  for (const [n, r] of Object.entries(t))
67
- if (r && typeof r == "object" && "start" in r) {
68
- const e = r;
69
- l[n] = `${e.start || ""}|${e.end || ""}`;
70
- } else Array.isArray(r) ? l[n] = r.join(L) : typeof r == "string" && (l[n] = r);
71
- return l;
61
+ a[`v_${n}`] = String(r);
62
+ return a;
63
+ }
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
+ }
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 };
72
154
  }
73
- function we({ data: t, label: l }) {
74
- const n = l || String(t.label || ""), r = String(t.formatted || "-"), e = t.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__ */ a("span", { className: "widget-kpi__label", children: n }),
77
- /* @__PURE__ */ a("span", { className: "widget-kpi__value", children: r }),
78
- e && e.variance_pct != null && /* @__PURE__ */ _("div", { className: `widget-kpi__trend ${i}`, children: [
79
- /* @__PURE__ */ _("span", { className: "widget-kpi__variance", children: [
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__ */ a("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 ve = "var(--bg-elevated)";
91
- function E(t, l, n, r) {
92
- if (r <= 0) return "";
93
- if (r >= 1)
94
- return `M ${t - n} ${l} A ${n} ${n} 0 0 1 ${t} ${l - n} A ${n} ${n} 0 0 1 ${t + n} ${l}`;
95
- const e = r * Math.PI, i = t - n * Math.cos(e), c = l - n * Math.sin(e);
96
- return `M ${t - n} ${l} 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(t) {
99
- const l = Math.abs(t);
100
- return l >= 1e6 ? `${(t / 1e6).toFixed(1)}M` : l >= 1e3 ? `${(t / 1e3).toFixed(1)}K` : t.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: t, palette: l, label: n }) {
103
- const r = n || String(t.label || ""), e = typeof t.value == "number" ? t.value : null, i = e != null ? O(e) : "-", c = String(t.formatted || "-"), s = typeof t.ratio == "number" ? t.ratio : 0, m = t.target_value, g = t.comparison_label, o = s >= 1, d = Math.min(Math.max(s, 0), 1), h = o ? "var(--action-green)" : s >= 0.7 ? l[0] || "var(--color-info)" : s >= 0.4 ? "var(--color-warning)" : "var(--color-error)", w = m != null ? O(m) : "-", u = 50, b = 50, y = 44, p = 10;
104
- return /* @__PURE__ */ _("div", { className: "widget widget-gauge", children: [
105
- /* @__PURE__ */ a("span", { className: "widget-gauge__label", children: r }),
106
- /* @__PURE__ */ _("div", { className: "widget-gauge__chart", children: [
107
- /* @__PURE__ */ _("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", children: [
108
- /* @__PURE__ */ a("path", { d: E(u, b, y, 1), fill: "none", stroke: ve, strokeWidth: p, strokeLinecap: "butt" }),
109
- d > 0 && /* @__PURE__ */ a("path", { d: E(u, b, y, d), fill: "none", stroke: h, strokeWidth: p, 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: [
112
- /* @__PURE__ */ a("span", { className: "widget-gauge__percent", children: c }),
113
- /* @__PURE__ */ _("span", { className: "widget-gauge__comparison", children: [
193
+ /* @__PURE__ */ w("div", { className: "widget-gauge__center", children: [
194
+ /* @__PURE__ */ l("span", { className: "widget-gauge__percent", children: c }),
195
+ /* @__PURE__ */ w("span", { className: "widget-gauge__comparison", children: [
114
196
  i,
115
197
  " / ",
116
- w
198
+ N
117
199
  ] }),
118
- o && /* @__PURE__ */ a("span", { className: "widget-gauge__badge", children: g || "Meta batida" }),
119
- !o && g && /* @__PURE__ */ a("span", { className: "widget-gauge__comparison", children: g })
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 })
120
202
  ] })
121
203
  ] })
122
204
  ] });
123
205
  }
124
- const W = { 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(t, l) {
134
- var e;
135
- const n = Array.isArray(l) ? l[0] : void 0, r = (e = n == null ? void 0 : n.payload) == null ? void 0 : e.tooltipLabel;
136
- return typeof r == "string" && r ? r : String(t ?? "");
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(t) {
139
- const [l, n] = k({ width: 0, height: 0 });
140
- return T(() => {
141
- const r = t.current;
142
- if (!r) 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(r), () => e.disconnect();
150
- }, [t]), l;
231
+ return r.observe(n), () => r.disconnect();
232
+ }, [e]), t;
151
233
  }
152
- function x({ Chart: t, chartData: l, xKey: n, series: r, palette: e, renderSeries: i, width: c, height: s }) {
153
- return /* @__PURE__ */ _(t, { data: l, width: c, height: s, children: [
154
- /* @__PURE__ */ a(ge, { strokeDasharray: "3 3", stroke: Ne }),
155
- /* @__PURE__ */ a(he, { dataKey: n, tick: W }),
156
- /* @__PURE__ */ a(ue, { tick: W }),
157
- /* @__PURE__ */ a(
158
- Y,
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 }),
239
+ /* @__PURE__ */ l(
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
- r.length > 1 && /* @__PURE__ */ a(me, {}),
167
- r.map((m, g) => i(m, e[g % e.length], g))
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: t, palette: l, label: n }) {
171
- const r = String(t.chartType || "bar"), e = n || String(t.label || ""), i = String(t.xKey || "label"), c = t.series || [], s = t.data || [], m = F(null), { width: g, height: o } = ke(m), d = () => {
172
- var w;
173
- if (g <= 0 || o <= 0) return null;
174
- if (r === "pie")
175
- return /* @__PURE__ */ _(ae, { width: g, height: o, children: [
176
- /* @__PURE__ */ a(
177
- re,
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;
255
+ if (o <= 0 || d <= 0) return null;
256
+ if (n === "pie")
257
+ return /* @__PURE__ */ w(ye, { width: o, height: d, children: [
258
+ /* @__PURE__ */ l(
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: u, percent: b }) => `${u}: ${(b * 100).toFixed(0)}%`,
267
+ label: ({ name: m, percent: _ }) => `${m}: ${(_ * 100).toFixed(0)}%`,
186
268
  labelLine: !1,
187
- children: s.map((u, b) => /* @__PURE__ */ a(le, { fill: l[b % l.length] }, b))
269
+ children: s.map((m, _) => /* @__PURE__ */ l(ke, { fill: t[_ % t.length] }, _))
188
270
  }
189
271
  ),
190
- /* @__PURE__ */ a(
191
- Y,
272
+ /* @__PURE__ */ l(
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 h = { chartData: s, xKey: i, series: c, palette: l, width: g, height: o };
200
- return r === "line" ? /* @__PURE__ */ a(x, { ...h, Chart: ne, renderSeries: (u, b) => /* @__PURE__ */ a(
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: u.key,
205
- name: u.label,
206
- stroke: b,
286
+ dataKey: m.key,
287
+ name: m.label,
288
+ stroke: _,
207
289
  strokeWidth: 2,
208
290
  dot: s.length <= 31
209
291
  },
210
- u.key
211
- ) }) : r === "area" ? /* @__PURE__ */ a(x, { ...h, Chart: se, renderSeries: (u, b) => /* @__PURE__ */ a(
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: u.key,
216
- name: u.label,
217
- fill: b,
218
- stroke: b,
297
+ dataKey: m.key,
298
+ name: m.label,
299
+ fill: _,
300
+ stroke: _,
219
301
  fillOpacity: 0.3
220
302
  },
221
- u.key
222
- ) }) : /* @__PURE__ */ a(x, { ...h, Chart: oe, renderSeries: (u, b) => /* @__PURE__ */ a(
223
- de,
303
+ m.key
304
+ ) }) : /* @__PURE__ */ l(Y, { ...h, Chart: xe, renderSeries: (m, _) => /* @__PURE__ */ l(
305
+ Me,
224
306
  {
225
- dataKey: u.key,
226
- name: u.label,
227
- fill: b,
307
+ dataKey: m.key,
308
+ name: m.label,
309
+ fill: _,
228
310
  radius: [3, 3, 0, 0]
229
311
  },
230
- u.key
312
+ m.key
231
313
  ) });
232
314
  };
233
- return /* @__PURE__ */ _("div", { className: "widget widget-chart", children: [
234
- e && /* @__PURE__ */ a("h4", { className: "widget-chart__title", children: e }),
235
- /* @__PURE__ */ a("div", { ref: m, className: "widget-chart__container", children: s.length === 0 ? /* @__PURE__ */ a("div", { className: "widget-chart__empty", children: "Sem dados" }) : d() })
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() })
236
318
  ] });
237
319
  }
238
- function Se(t, l) {
239
- if (t == null || t === "") return "-";
240
- const n = typeof t == "number" ? t : Number(t), r = t !== "" && !Number.isNaN(n);
241
- switch (l) {
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) {
242
324
  case "currency":
243
- return r ? n.toLocaleString("pt-BR", { style: "currency", currency: "BRL" }) : String(t);
325
+ return n ? a.toLocaleString("pt-BR", { style: "currency", currency: "BRL" }) : String(e);
244
326
  case "integer":
245
- return r ? Math.round(n).toLocaleString("pt-BR") : String(t);
327
+ return n ? Math.round(a).toLocaleString("pt-BR") : String(e);
246
328
  case "number":
247
- return r ? n.toLocaleString("pt-BR", { maximumFractionDigits: 1 }) : String(t);
329
+ return n ? a.toLocaleString("pt-BR", { maximumFractionDigits: 1 }) : String(e);
248
330
  case "percentage":
249
- return r ? `${n > 0 ? "+" : ""}${Math.round(n)}%` : String(t);
331
+ return n ? `${a > 0 ? "+" : ""}${Math.round(a)}%` : String(e);
250
332
  default:
251
- return String(t);
333
+ return String(e);
252
334
  }
253
335
  }
254
- function Ce({ data: t, label: l }) {
255
- var g;
256
- const [n, r] = k(0), e = t.columns || [], i = t.tabs || [], c = i.length > 0, s = c ? ((g = i[Math.min(n, i.length - 1)]) == null ? void 0 : g.rows) || [] : t.rows || [], m = l || String(t.label || "");
257
- return e.length === 0 ? /* @__PURE__ */ _("div", { className: "widget widget-table", children: [
258
- m && /* @__PURE__ */ a("span", { className: "widget-table__label", children: m }),
259
- /* @__PURE__ */ a("span", { className: "widget-table__empty", children: "Configure as colunas da tabela." })
260
- ] }) : /* @__PURE__ */ _("div", { className: "widget widget-table", children: [
261
- m && /* @__PURE__ */ a("span", { className: "widget-table__label", children: m }),
262
- c && /* @__PURE__ */ a("div", { className: "widget-table__tabs", role: "tablist", children: i.map((o, d) => /* @__PURE__ */ a(
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(
263
345
  "button",
264
346
  {
265
347
  type: "button",
266
348
  role: "tab",
267
- "aria-selected": d === n,
268
- className: `widget-table__tab${d === n ? " widget-table__tab--active" : ""}`,
269
- onClick: () => r(d),
270
- children: o.label
349
+ "aria-selected": u === a,
350
+ className: `widget-table__tab${u === a ? " widget-table__tab--active" : ""}`,
351
+ onClick: () => n(u),
352
+ children: d.label
271
353
  },
272
- d
354
+ u
273
355
  )) }),
274
- /* @__PURE__ */ a("div", { className: "widget-table__scroll", children: /* @__PURE__ */ _("table", { className: "widget-table__table", children: [
275
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: e.map((o) => {
276
- const d = !!o.format && o.format !== "text";
277
- return /* @__PURE__ */ a("th", { className: `widget-table__th${d ? " widget-table__th--num" : ""}`, children: o.label || o.key }, o.key);
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);
278
360
  }) }) }),
279
- /* @__PURE__ */ a("tbody", { children: s.length === 0 ? /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a("td", { className: "widget-table__td widget-table__empty", colSpan: e.length, children: "Sem dados" }) }) : s.map((o, d) => /* @__PURE__ */ a("tr", { children: e.map((h) => {
280
- const w = o[h.key], u = !!h.format && h.format !== "text";
281
- let b = "";
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 _ = "";
282
364
  if (h.format === "percentage") {
283
- const y = Number(w);
284
- Number.isNaN(y) || (b = y > 0 ? " widget-table__td--up" : y < 0 ? " widget-table__td--down" : "");
365
+ const y = Number(N);
366
+ Number.isNaN(y) || (_ = y > 0 ? " widget-table__td--up" : y < 0 ? " widget-table__td--down" : "");
285
367
  }
286
- return /* @__PURE__ */ a("td", { className: `widget-table__td${u ? " widget-table__td--num" : ""}${b}`, children: Se(w, h.format) }, h.key);
287
- }) }, d)) })
368
+ return /* @__PURE__ */ l("td", { className: `widget-table__td${m ? " widget-table__td--num" : ""}${_}`, children: Ue(N, h.format) }, h.key);
369
+ }) }, u)) })
288
370
  ] }) })
289
371
  ] });
290
372
  }
291
- function Re({ config: t, value: l, options: n = [], dateBounds: r, onChange: e }) {
292
- const i = t.filterType || "select", c = t.label || "Filtro", s = t.dateFilterMode || "range";
293
- return /* @__PURE__ */ _("div", { className: "widget-filter", children: [
294
- /* @__PURE__ */ a("label", { className: "widget-filter__label", children: c }),
295
- i === "date_range" ? s === "yearly" ? /* @__PURE__ */ a(xe, { value: l, dateBounds: r, onChange: e }) : s === "monthly" ? /* @__PURE__ */ a(Fe, { value: l, dateBounds: r, onChange: e }) : s === "weekly" ? /* @__PURE__ */ a(Te, { value: l, dateBounds: r, onChange: e }) : /* @__PURE__ */ a(Me, { value: l, dateBounds: r, onChange: e }) : /* @__PURE__ */ a(
296
- Le,
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: [
376
+ /* @__PURE__ */ l("label", { className: "widget-filter__label", children: c }),
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,
297
379
  {
298
- value: l,
299
- options: n,
380
+ value: t,
381
+ options: a,
300
382
  multi: i === "multi_select",
301
- searchable: t.searchable || !1,
302
- onChange: e
383
+ searchable: e.searchable || !1,
384
+ onChange: r
303
385
  }
304
386
  )
305
387
  ] });
306
388
  }
307
- function Me({ value: t, dateBounds: l, onChange: n }) {
308
- const [r, e] = t ? t.split("|") : ["", ""];
309
- return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
310
- /* @__PURE__ */ a(
311
- A,
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: [
392
+ /* @__PURE__ */ l(
393
+ K,
312
394
  {
313
- value: r,
314
- minIso: l == null ? void 0 : l.min,
315
- maxIso: e || (l == null ? void 0 : l.max),
395
+ value: n,
396
+ minIso: t == null ? void 0 : t.min,
397
+ maxIso: r || (t == null ? void 0 : t.max),
316
398
  selectsStart: !0,
317
- startIso: r,
318
- endIso: e,
399
+ startIso: n,
400
+ endIso: r,
319
401
  placeholder: "Data inicial",
320
- onChange: (i) => n(`${i}|${e}`)
402
+ onChange: (i) => a(`${i}|${r}`)
321
403
  }
322
404
  ),
323
- /* @__PURE__ */ a(
324
- A,
405
+ /* @__PURE__ */ l(
406
+ K,
325
407
  {
326
- value: e,
327
- minIso: r || (l == null ? void 0 : l.min),
328
- maxIso: l == null ? void 0 : l.max,
408
+ value: r,
409
+ minIso: n || (t == null ? void 0 : t.min),
410
+ maxIso: t == null ? void 0 : t.max,
329
411
  selectsEnd: !0,
330
- startIso: r,
331
- endIso: e,
412
+ startIso: n,
413
+ endIso: r,
332
414
  placeholder: "Data final",
333
- onChange: (i) => n(`${r}|${i}`)
415
+ onChange: (i) => a(`${n}|${i}`)
334
416
  }
335
417
  )
336
418
  ] });
337
419
  }
338
- function xe({ value: t, dateBounds: l, onChange: n }) {
339
- const [r] = t ? t.split("|") : [""], e = H(r), i = /* @__PURE__ */ new Date(), c = (e == null ? void 0 : e.year) ?? i.getFullYear(), s = I(l), m = (g) => {
340
- const o = J(g);
341
- n(`${o.start}|${o.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}`);
342
424
  };
343
- return /* @__PURE__ */ a("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ a(
425
+ return /* @__PURE__ */ l("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ l(
344
426
  "select",
345
427
  {
346
428
  className: "widget-filter__select",
347
429
  value: c,
348
- onChange: (g) => m(parseInt(g.target.value)),
349
- children: s.map((g) => /* @__PURE__ */ a("option", { value: g, children: g }, g))
430
+ onChange: (o) => g(parseInt(o.target.value)),
431
+ children: s.map((o) => /* @__PURE__ */ l("option", { value: o, children: o }, o))
350
432
  }
351
433
  ) });
352
434
  }
353
- function Fe({ value: t, dateBounds: l, onChange: n }) {
354
- const [r] = t ? t.split("|") : [""], e = D(r), i = /* @__PURE__ */ new Date(), c = (e == null ? void 0 : e.year) ?? i.getFullYear(), s = (e == null ? void 0 : e.month) ?? i.getMonth() + 1, m = I(l), g = (o, d) => {
355
- const h = Q(o, d);
356
- n(`${h.start}|${h.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}`);
357
439
  };
358
- return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
359
- /* @__PURE__ */ a(
440
+ return /* @__PURE__ */ w("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
441
+ /* @__PURE__ */ l(
360
442
  "select",
361
443
  {
362
444
  className: "widget-filter__select",
363
445
  value: s,
364
- onChange: (o) => g(c, parseInt(o.target.value)),
365
- children: P.map((o, d) => /* @__PURE__ */ a("option", { value: d + 1, children: o }, d + 1))
446
+ onChange: (d) => o(c, parseInt(d.target.value)),
447
+ children: J.map((d, u) => /* @__PURE__ */ l("option", { value: u + 1, children: d }, u + 1))
366
448
  }
367
449
  ),
368
- /* @__PURE__ */ a(
450
+ /* @__PURE__ */ l(
369
451
  "select",
370
452
  {
371
453
  className: "widget-filter__select",
372
454
  value: c,
373
- onChange: (o) => g(parseInt(o.target.value), s),
374
- children: m.map((o) => /* @__PURE__ */ a("option", { value: o, children: o }, o))
455
+ onChange: (d) => o(parseInt(d.target.value), s),
456
+ children: g.map((d) => /* @__PURE__ */ l("option", { value: d, children: d }, d))
375
457
  }
376
458
  )
377
459
  ] });
378
460
  }
379
- function Te({ value: t, dateBounds: l, onChange: n }) {
380
- const [r] = t ? t.split("|") : [""], e = D(r), i = /* @__PURE__ */ new Date(), c = (e == null ? void 0 : e.year) ?? i.getFullYear(), s = (e == null ? void 0 : e.month) ?? i.getMonth() + 1, m = I(l), g = M(c, s), o = X(r, c, s) || 1;
381
- return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
382
- /* @__PURE__ */ a(
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: [
464
+ /* @__PURE__ */ l(
383
465
  "select",
384
466
  {
385
467
  className: "widget-filter__select",
386
468
  value: c,
387
- onChange: (d) => {
388
- const h = parseInt(d.target.value), u = M(h, s)[0];
389
- u && n(`${u.start}|${u.end}`);
469
+ onChange: (u) => {
470
+ const h = parseInt(u.target.value), m = D(h, s)[0];
471
+ m && a(`${m.start}|${m.end}`);
390
472
  },
391
- children: m.map((d) => /* @__PURE__ */ a("option", { value: d, children: d }, d))
473
+ children: g.map((u) => /* @__PURE__ */ l("option", { value: u, children: u }, u))
392
474
  }
393
475
  ),
394
- /* @__PURE__ */ a(
476
+ /* @__PURE__ */ l(
395
477
  "select",
396
478
  {
397
479
  className: "widget-filter__select",
398
480
  value: s,
399
- onChange: (d) => {
400
- const h = parseInt(d.target.value), u = M(c, h)[0];
401
- u && n(`${u.start}|${u.end}`);
481
+ onChange: (u) => {
482
+ const h = parseInt(u.target.value), m = D(c, h)[0];
483
+ m && a(`${m.start}|${m.end}`);
402
484
  },
403
- children: P.map((d, h) => /* @__PURE__ */ a("option", { value: h + 1, children: d }, h + 1))
485
+ children: J.map((u, h) => /* @__PURE__ */ l("option", { value: h + 1, children: u }, h + 1))
404
486
  }
405
487
  ),
406
- /* @__PURE__ */ a(
488
+ /* @__PURE__ */ l(
407
489
  "select",
408
490
  {
409
491
  className: "widget-filter__select",
410
- value: o,
411
- onChange: (d) => {
412
- const h = g[parseInt(d.target.value) - 1];
413
- h && n(`${h.start}|${h.end}`);
492
+ value: d,
493
+ onChange: (u) => {
494
+ const h = o[parseInt(u.target.value) - 1];
495
+ h && a(`${h.start}|${h.end}`);
414
496
  },
415
- children: g.map((d) => /* @__PURE__ */ a("option", { value: d.index, children: d.label }, d.index))
497
+ children: o.map((u) => /* @__PURE__ */ l("option", { value: u.index, children: u.label }, u.index))
416
498
  }
417
499
  )
418
500
  ] });
419
501
  }
420
- function Le({ value: t, options: l, multi: n, searchable: r, onChange: e }) {
421
- if (r)
422
- return /* @__PURE__ */ a(
423
- q,
502
+ function rt({ value: e, options: t, multi: a, searchable: n, onChange: r }) {
503
+ if (n)
504
+ return /* @__PURE__ */ l(
505
+ oe,
424
506
  {
425
- value: t,
426
- options: l,
427
- multi: n,
428
- onChange: e
507
+ value: e,
508
+ options: t,
509
+ multi: a,
510
+ onChange: r
429
511
  }
430
512
  );
431
- if (n) {
432
- const i = t ? t.split(L) : [], c = (s) => {
433
- const m = i.includes(s) ? i.filter((g) => g !== s) : [...i, s];
434
- e(m.join(L));
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));
435
517
  };
436
- return /* @__PURE__ */ _("div", { className: "widget-filter__multi", children: [
437
- i.length > 0 && /* @__PURE__ */ a(
518
+ return /* @__PURE__ */ w("div", { className: "widget-filter__multi", children: [
519
+ i.length > 0 && /* @__PURE__ */ l(
438
520
  "button",
439
521
  {
440
522
  type: "button",
441
523
  className: "widget-filter__multi-clear",
442
- onClick: () => e(""),
524
+ onClick: () => r(""),
443
525
  children: "Limpar filtro"
444
526
  }
445
527
  ),
446
- l.map((s) => /* @__PURE__ */ _("label", { className: "widget-filter__multi-option", children: [
447
- /* @__PURE__ */ a(
528
+ t.map((s) => /* @__PURE__ */ w("label", { className: "widget-filter__multi-option", children: [
529
+ /* @__PURE__ */ l(
448
530
  "input",
449
531
  {
450
532
  type: "checkbox",
@@ -456,184 +538,204 @@ function Le({ value: t, options: l, multi: n, searchable: r, onChange: e }) {
456
538
  ] }, s))
457
539
  ] });
458
540
  }
459
- return /* @__PURE__ */ _(
541
+ return /* @__PURE__ */ w(
460
542
  "select",
461
543
  {
462
544
  className: "widget-filter__select",
463
- value: t,
464
- onChange: (i) => e(i.target.value),
545
+ value: e,
546
+ onChange: (i) => r(i.target.value),
465
547
  children: [
466
- /* @__PURE__ */ a("option", { value: "", children: "Todos" }),
467
- l.map((i) => /* @__PURE__ */ a("option", { value: i, children: i }, i))
548
+ /* @__PURE__ */ l("option", { value: "", children: "Todos" }),
549
+ t.map((i) => /* @__PURE__ */ l("option", { value: i, children: i }, i))
468
550
  ]
469
551
  }
470
552
  );
471
553
  }
472
- const Ie = {
554
+ const at = {
473
555
  currency: "R$",
474
556
  percentage: "%"
475
557
  };
476
- function Ae({ config: t, value: l, onChange: n }) {
477
- const r = t.label || "Variavel", e = t.locked || !1, i = t.variableFormat || "number", c = Ie[i] || "";
478
- return /* @__PURE__ */ _("div", { className: `widget-variable ${e ? "widget-variable--locked" : ""}`, children: [
479
- /* @__PURE__ */ a("label", { className: "widget-variable__label", children: r }),
480
- /* @__PURE__ */ _("div", { className: "widget-variable__input-wrapper", children: [
481
- /* @__PURE__ */ a(
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: [
563
+ /* @__PURE__ */ l(
482
564
  "input",
483
565
  {
484
566
  className: "widget-variable__input",
485
567
  type: "number",
486
- value: l,
487
- onChange: (s) => n(parseFloat(s.target.value) || 0),
488
- disabled: e,
568
+ value: t,
569
+ onChange: (s) => a(parseFloat(s.target.value) || 0),
570
+ disabled: r,
489
571
  step: i === "integer" ? 1 : 0.01
490
572
  }
491
573
  ),
492
- c && /* @__PURE__ */ a("span", { className: "widget-variable__suffix", children: c })
574
+ c && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: c })
493
575
  ] }),
494
- e && /* @__PURE__ */ a("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
576
+ r && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
495
577
  ] });
496
578
  }
497
- function Ee({ config: t, palette: l, onChange: n }) {
498
- const r = t.label || "Cores", e = t.locked || !1;
499
- return /* @__PURE__ */ _("div", { className: `widget-palette ${e ? "widget-palette--locked" : ""}`, children: [
500
- /* @__PURE__ */ a("label", { className: "widget-palette__label", children: r }),
501
- /* @__PURE__ */ a(Z, { selected: l, onSelect: n, customMode: !0, disabled: e }),
502
- e && /* @__PURE__ */ a("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: "🔒" })
503
585
  ] });
504
586
  }
505
- function Oe({
506
- type: t,
507
- computed: l,
508
- palette: n,
509
- config: r,
510
- filterValue: e,
587
+ function it({
588
+ type: e,
589
+ computed: t,
590
+ palette: a,
591
+ config: n,
592
+ filterValue: r,
511
593
  filterOptions: i,
512
594
  dateBounds: c,
513
595
  onFilterChange: s,
514
- variableValue: m,
515
- onVariableChange: g,
516
- onPaletteChange: o
596
+ variableValue: g,
597
+ onVariableChange: o,
598
+ onPaletteChange: d
517
599
  }) {
518
- if (l.error)
519
- return /* @__PURE__ */ a("div", { className: "widget widget--error", children: /* @__PURE__ */ a("span", { className: "widget__error-text", children: String(l.error) }) });
520
- const d = B(n);
521
- switch (t) {
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) {
522
604
  case "kpi_card":
523
- return /* @__PURE__ */ a(we, { data: l, label: r == null ? void 0 : r.label });
605
+ return /* @__PURE__ */ l(Ge, { data: t, label: n == null ? void 0 : n.label });
524
606
  case "gauge":
525
- return /* @__PURE__ */ a(ye, { data: l, palette: d, label: r == null ? void 0 : r.label });
607
+ return /* @__PURE__ */ l(Ke, { data: t, palette: u, label: n == null ? void 0 : n.label });
526
608
  case "chart":
527
- return /* @__PURE__ */ a($e, { data: l, palette: d, label: r == null ? void 0 : r.label });
609
+ return /* @__PURE__ */ l(qe, { data: t, palette: u, label: n == null ? void 0 : n.label });
528
610
  case "table":
529
- return /* @__PURE__ */ a(Ce, { data: l, label: r == null ? void 0 : r.label });
611
+ return /* @__PURE__ */ l(Qe, { data: t, label: n == null ? void 0 : n.label });
530
612
  case "filter":
531
- return r && s ? /* @__PURE__ */ a(
532
- Re,
613
+ return n && s ? /* @__PURE__ */ l(
614
+ Ze,
533
615
  {
534
- config: r,
535
- value: e || "",
616
+ config: n,
617
+ value: r || "",
536
618
  options: i,
537
619
  dateBounds: c,
538
620
  onChange: s
539
621
  }
540
622
  ) : null;
541
623
  case "variable": {
542
- const h = r;
543
- return h && g ? /* @__PURE__ */ a(
544
- Ae,
624
+ const h = n;
625
+ return h && o ? /* @__PURE__ */ l(
626
+ nt,
545
627
  {
546
628
  config: h,
547
- value: m ?? h.variableValue ?? 0,
548
- onChange: g
629
+ value: g ?? h.variableValue ?? 0,
630
+ onChange: o
549
631
  }
550
632
  ) : null;
551
633
  }
552
634
  case "color_palette":
553
- return r && o ? /* @__PURE__ */ a(
554
- Ee,
635
+ return n && d ? /* @__PURE__ */ l(
636
+ lt,
555
637
  {
556
- config: r,
557
- palette: n,
558
- onChange: o
638
+ config: n,
639
+ palette: a,
640
+ onChange: d
559
641
  }
560
642
  ) : null;
561
643
  default:
562
- return /* @__PURE__ */ _("div", { className: "widget", children: [
644
+ return /* @__PURE__ */ w("div", { className: "widget", children: [
563
645
  "Widget: ",
564
- t
646
+ e
565
647
  ] });
566
648
  }
567
649
  }
568
- const We = 2.5, De = 0.375;
569
- function Ge({
570
- token: t,
571
- rowHeight: l = We,
572
- gridGap: n = De,
573
- className: r
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
574
658
  }) {
575
659
  const {
576
- layout: e,
577
- renderData: i,
578
- loading: c,
579
- error: s,
580
- filters: m,
581
- variables: g,
582
- palette: o,
583
- setFilter: d,
584
- setVariable: h,
585
- setPalette: w
586
- } = be(t);
587
- if (s && !e)
588
- return /* @__PURE__ */ a("div", { className: `preview-tab ${r ?? ""}`, children: /* @__PURE__ */ a("div", { className: "preview-tab__error", children: s }) });
589
- if (!e)
590
- return /* @__PURE__ */ a("div", { className: `preview-tab ${r ?? ""}`, children: /* @__PURE__ */ a("div", { className: "preview-tab__loading", children: "Carregando dashboard..." }) });
591
- if (e.widgets.length === 0)
592
- return /* @__PURE__ */ a("div", { className: `preview-tab ${r ?? ""}`, children: /* @__PURE__ */ a("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." }) });
593
- const u = (i == null ? void 0 : i.widgets) ?? {}, b = (i == null ? void 0 : i.date_bounds) ?? null, y = {
594
- display: "grid",
595
- gridTemplateColumns: `repeat(${e.gridColumns}, 1fr)`,
596
- gridTemplateRows: `repeat(${e.gridRows}, ${l}rem)`,
597
- gap: `${n}rem`,
598
- ...ee(o)
599
- };
600
- return /* @__PURE__ */ _("div", { className: `preview-tab ${r ?? ""}`, children: [
601
- s && !i && /* @__PURE__ */ a("div", { className: "preview-tab__error", children: s }),
602
- i && /* @__PURE__ */ a("div", { className: "preview-tab__grid", style: y, children: e.widgets.map((p) => {
603
- const S = te.has(p.type), N = u[p.id], C = {
604
- gridColumn: `${p.grid.x + 1} / span ${p.grid.w}`,
605
- gridRow: `${p.grid.y + 1} / span ${p.grid.h}`
606
- }, v = p.type === "variable" ? g[p.id] ?? (N == null ? void 0 : N.value) ?? p.config.variableValue ?? 0 : void 0;
607
- return /* @__PURE__ */ a(
608
- "div",
609
- {
610
- className: `preview-tab__widget ${S ? "preview-tab__widget--control" : ""}`,
611
- style: C,
612
- children: S || N ? /* @__PURE__ */ a(
613
- Oe,
614
- {
615
- type: p.type,
616
- computed: N || {},
617
- palette: o,
618
- config: p.config,
619
- filterValue: m[p.id] || "",
620
- filterOptions: (N == null ? void 0 : N.available_values) || [],
621
- dateBounds: b,
622
- onFilterChange: (f) => d(p.id, f),
623
- variableValue: v,
624
- onVariableChange: (f) => h(p.id, f),
625
- onPaletteChange: w
626
- }
627
- ) : /* @__PURE__ */ a("div", { className: "preview-tab__widget-loading", children: c ? "Carregando..." : "Sem dados" })
628
- },
629
- p.id
630
- );
631
- }) }),
632
- c && i && /* @__PURE__ */ a("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
633
- ] });
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 });
634
736
  }
635
737
  export {
636
- Ue as ApiError,
637
- Ge as Dashboard
738
+ ft as ApiError,
739
+ ht as Dashboard
638
740
  };
639
741
  //# sourceMappingURL=index.js.map