@actionexec/dashboards 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/Dashboard.d.ts +20 -0
- package/dist/api/fetcher.d.ts +25 -0
- package/dist/components/ColorPaletteSelector.d.ts +9 -0
- package/dist/components/DashboardDatePicker.d.ts +18 -0
- package/dist/hooks/useDashboardData.d.ts +18 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1082 -0
- package/dist/index.js.map +1 -0
- package/dist/palettes/index.d.ts +32 -0
- package/dist/styles.css +1 -0
- package/dist/types/index.d.ts +201 -0
- package/dist/utils/date.d.ts +41 -0
- package/dist/widgets/ChartWidget.d.ts +7 -0
- package/dist/widgets/ColorPaletteWidget.d.ts +8 -0
- package/dist/widgets/FilterWidget.d.ts +13 -0
- package/dist/widgets/GaugeWidget.d.ts +7 -0
- package/dist/widgets/KPIWidget.d.ts +6 -0
- package/dist/widgets/VariableWidget.d.ts +8 -0
- package/dist/widgets/WidgetRenderer.d.ts +19 -0
- package/package.json +45 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1082 @@
|
|
|
1
|
+
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as T, useRef as O, useEffect as P, useCallback as F, useMemo as G } from "react";
|
|
3
|
+
import { PieChart as Z, Pie as B, Cell as ee, Tooltip as j, LineChart as te, Line as ae, AreaChart as re, Area as ne, BarChart as le, Bar as se, CartesianGrid as ie, XAxis as ce, YAxis as oe, Legend as de } from "recharts";
|
|
4
|
+
import ue from "react-datepicker";
|
|
5
|
+
class ge extends Error {
|
|
6
|
+
constructor(t, n, r) {
|
|
7
|
+
super(t), this.status = n, this.payload = r, this.name = "ApiError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function fe(e) {
|
|
11
|
+
const { apiUrl: t, token: n, fetch: r = globalThis.fetch } = e, a = e.endpointPrefix ?? "/external/dashboards", s = t.replace(/\/$/, "");
|
|
12
|
+
async function i(c, g) {
|
|
13
|
+
const u = new URL(`${s}${a}${c}`);
|
|
14
|
+
if (g)
|
|
15
|
+
for (const [d, f] of Object.entries(g)) u.searchParams.set(d, f);
|
|
16
|
+
const o = await r(u.toString(), {
|
|
17
|
+
headers: { Authorization: `Bearer ${n}` }
|
|
18
|
+
});
|
|
19
|
+
if (!o.ok) {
|
|
20
|
+
let d;
|
|
21
|
+
try {
|
|
22
|
+
d = await o.json();
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
throw new ge(
|
|
26
|
+
`Requisicao falhou (${o.status}) em ${c}`,
|
|
27
|
+
o.status,
|
|
28
|
+
d
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return await o.json();
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
layout: () => i("/layout"),
|
|
35
|
+
render: (c) => i("/render", c)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const he = 300;
|
|
39
|
+
function me(e) {
|
|
40
|
+
const [t, n] = T(null), [r, a] = T(null), [s, i] = T({}), [c, g] = T({}), [u, o] = T(null), [d, f] = T(!0), [v, h] = T(null), p = O(), k = O(!1);
|
|
41
|
+
P(() => {
|
|
42
|
+
let y = !1;
|
|
43
|
+
return e.layout().then((w) => {
|
|
44
|
+
y || n(w);
|
|
45
|
+
}).catch((w) => {
|
|
46
|
+
y || h(w.message);
|
|
47
|
+
}), () => {
|
|
48
|
+
y = !0;
|
|
49
|
+
};
|
|
50
|
+
}, []), P(() => {
|
|
51
|
+
if (t)
|
|
52
|
+
return p.current && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
53
|
+
const y = pe(s, c);
|
|
54
|
+
f(!0), e.render(y).then((w) => {
|
|
55
|
+
a(w), !k.current && w.applied && (k.current = !0, i((N) => ({ ..._e(w.applied), ...N }))), h(null);
|
|
56
|
+
}).catch((w) => h(w.message)).finally(() => f(!1));
|
|
57
|
+
}, he), () => {
|
|
58
|
+
p.current && clearTimeout(p.current);
|
|
59
|
+
};
|
|
60
|
+
}, [t, s, c, e]);
|
|
61
|
+
const $ = F((y, w) => {
|
|
62
|
+
i((N) => ({ ...N, [y]: w }));
|
|
63
|
+
}, []), b = F((y, w) => {
|
|
64
|
+
g((N) => ({ ...N, [y]: w }));
|
|
65
|
+
}, []), E = F((y) => {
|
|
66
|
+
o(y);
|
|
67
|
+
}, []), S = G(
|
|
68
|
+
() => u ?? (t == null ? void 0 : t.palette) ?? [],
|
|
69
|
+
[u, t]
|
|
70
|
+
);
|
|
71
|
+
return {
|
|
72
|
+
layout: t,
|
|
73
|
+
renderData: r,
|
|
74
|
+
loading: d,
|
|
75
|
+
error: v,
|
|
76
|
+
filters: s,
|
|
77
|
+
variables: c,
|
|
78
|
+
palette: S,
|
|
79
|
+
setFilter: $,
|
|
80
|
+
setVariable: b,
|
|
81
|
+
setPalette: E
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function pe(e, t) {
|
|
85
|
+
const n = {};
|
|
86
|
+
for (const [r, a] of Object.entries(e))
|
|
87
|
+
if (a.includes("|")) {
|
|
88
|
+
const [s, i] = a.split("|");
|
|
89
|
+
s && (n.f_date_start = s), i && (n.f_date_end = i);
|
|
90
|
+
} else
|
|
91
|
+
n[`f_${r}`] = a;
|
|
92
|
+
for (const [r, a] of Object.entries(t))
|
|
93
|
+
n[`v_${r}`] = String(a);
|
|
94
|
+
return n;
|
|
95
|
+
}
|
|
96
|
+
function _e(e) {
|
|
97
|
+
const t = {};
|
|
98
|
+
for (const [n, r] of Object.entries(e))
|
|
99
|
+
if (r && typeof r == "object" && "start" in r) {
|
|
100
|
+
const a = r;
|
|
101
|
+
t[n] = `${a.start || ""}|${a.end || ""}`;
|
|
102
|
+
} else Array.isArray(r) ? t[n] = r.join(",") : typeof r == "string" && (t[n] = r);
|
|
103
|
+
return t;
|
|
104
|
+
}
|
|
105
|
+
const _ = {
|
|
106
|
+
series0: 0,
|
|
107
|
+
series1: 1,
|
|
108
|
+
series2: 2,
|
|
109
|
+
series3: 3,
|
|
110
|
+
series4: 4,
|
|
111
|
+
bgDark: 5,
|
|
112
|
+
bgPaper: 6,
|
|
113
|
+
bgElevated: 7,
|
|
114
|
+
textPrimary: 8,
|
|
115
|
+
textMuted: 9,
|
|
116
|
+
accent: 10,
|
|
117
|
+
success: 11,
|
|
118
|
+
error: 12
|
|
119
|
+
}, be = 5, x = 13, ve = {
|
|
120
|
+
series0: "Série 1",
|
|
121
|
+
series1: "Série 2",
|
|
122
|
+
series2: "Série 3",
|
|
123
|
+
series3: "Série 4",
|
|
124
|
+
series4: "Série 5",
|
|
125
|
+
bgDark: "Fundo Escuro",
|
|
126
|
+
bgPaper: "Fundo Cartão",
|
|
127
|
+
bgElevated: "Fundo Elevado",
|
|
128
|
+
textPrimary: "Texto Primário",
|
|
129
|
+
textMuted: "Texto Secundário",
|
|
130
|
+
accent: "Destaque",
|
|
131
|
+
success: "Sucesso",
|
|
132
|
+
error: "Erro"
|
|
133
|
+
}, M = {
|
|
134
|
+
action: {
|
|
135
|
+
label: "Action",
|
|
136
|
+
colors: [
|
|
137
|
+
"#ff6b00",
|
|
138
|
+
"#a3e635",
|
|
139
|
+
"#e3f544",
|
|
140
|
+
"#65ffd1",
|
|
141
|
+
"#ff0404",
|
|
142
|
+
"#1a1a1a",
|
|
143
|
+
"#262626",
|
|
144
|
+
"#333333",
|
|
145
|
+
"#f5f5f5",
|
|
146
|
+
"#999999",
|
|
147
|
+
"#ff6b00",
|
|
148
|
+
"#a3e635",
|
|
149
|
+
"#ef4444"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
westCoast: {
|
|
153
|
+
label: "West Coast",
|
|
154
|
+
colors: [
|
|
155
|
+
"#a3b86c",
|
|
156
|
+
"#c89b3c",
|
|
157
|
+
"#8b6f47",
|
|
158
|
+
"#6b8e23",
|
|
159
|
+
"#d2691e",
|
|
160
|
+
"#1f1a14",
|
|
161
|
+
"#2a241b",
|
|
162
|
+
"#3a3225",
|
|
163
|
+
"#e8dcc4",
|
|
164
|
+
"#a89878",
|
|
165
|
+
"#c89b3c",
|
|
166
|
+
"#a3b86c",
|
|
167
|
+
"#c44536"
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
mono: {
|
|
171
|
+
label: "Monocromático",
|
|
172
|
+
colors: [
|
|
173
|
+
"#f8fafc",
|
|
174
|
+
"#cbd5e1",
|
|
175
|
+
"#94a3b8",
|
|
176
|
+
"#64748b",
|
|
177
|
+
"#475569",
|
|
178
|
+
"#0a0a0a",
|
|
179
|
+
"#171717",
|
|
180
|
+
"#262626",
|
|
181
|
+
"#fafafa",
|
|
182
|
+
"#a3a3a3",
|
|
183
|
+
"#e5e5e5",
|
|
184
|
+
"#cbd5e1",
|
|
185
|
+
"#ef4444"
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
ocean: {
|
|
189
|
+
label: "Ocean",
|
|
190
|
+
colors: [
|
|
191
|
+
"#0ea5e9",
|
|
192
|
+
"#06b6d4",
|
|
193
|
+
"#0891b2",
|
|
194
|
+
"#3b82f6",
|
|
195
|
+
"#22d3ee",
|
|
196
|
+
"#0a1929",
|
|
197
|
+
"#0f2740",
|
|
198
|
+
"#173554",
|
|
199
|
+
"#e0f2fe",
|
|
200
|
+
"#7dd3fc",
|
|
201
|
+
"#22d3ee",
|
|
202
|
+
"#10b981",
|
|
203
|
+
"#f43f5e"
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
princess: {
|
|
207
|
+
label: "Cute Pink",
|
|
208
|
+
colors: [
|
|
209
|
+
"#ff79bc",
|
|
210
|
+
"#a855f7",
|
|
211
|
+
"#f472b6",
|
|
212
|
+
"#d946ef",
|
|
213
|
+
"#fb7185",
|
|
214
|
+
"#fff0f6",
|
|
215
|
+
"#ffe4ec",
|
|
216
|
+
"#ffffff",
|
|
217
|
+
"#ff4099",
|
|
218
|
+
"#ffadd5",
|
|
219
|
+
"#ec4899",
|
|
220
|
+
"#10b981",
|
|
221
|
+
"#e11d48"
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
}, rt = "action", V = M.action.colors;
|
|
225
|
+
function C(e) {
|
|
226
|
+
const t = V;
|
|
227
|
+
if (!e || e.length === 0) return [...t];
|
|
228
|
+
if (e.length >= x) return e.slice(0, x);
|
|
229
|
+
const n = [...e];
|
|
230
|
+
for (let r = e.length; r < x; r++) n.push(t[r]);
|
|
231
|
+
return n;
|
|
232
|
+
}
|
|
233
|
+
function K(e) {
|
|
234
|
+
return C(e).slice(0, be);
|
|
235
|
+
}
|
|
236
|
+
function we(e) {
|
|
237
|
+
const t = C(e);
|
|
238
|
+
return {
|
|
239
|
+
"--bg-dark": t[_.bgDark],
|
|
240
|
+
"--bg-paper": t[_.bgPaper],
|
|
241
|
+
"--bg-elevated": t[_.bgElevated],
|
|
242
|
+
"--text-primary": t[_.textPrimary],
|
|
243
|
+
"--text-secondary": t[_.textMuted],
|
|
244
|
+
"--text-muted": t[_.textMuted],
|
|
245
|
+
"--action-orange": t[_.accent],
|
|
246
|
+
"--action-green": t[_.success],
|
|
247
|
+
"--color-success": t[_.success],
|
|
248
|
+
"--color-error": t[_.error],
|
|
249
|
+
"--color-info": t[_.series2],
|
|
250
|
+
"--color-warning": t[_.series3]
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function ye({ data: e, label: t }) {
|
|
254
|
+
const n = t || String(e.label || ""), r = String(e.formatted || "-"), a = e.comparison, s = (a == null ? void 0 : a.trend) === "up" ? "widget-kpi__trend--up" : (a == null ? void 0 : a.trend) === "down" ? "widget-kpi__trend--down" : "", i = (a == null ? void 0 : a.trend) === "up" ? "↑" : (a == null ? void 0 : a.trend) === "down" ? "↓" : "";
|
|
255
|
+
return /* @__PURE__ */ m("div", { className: "widget widget-kpi", children: [
|
|
256
|
+
/* @__PURE__ */ l("span", { className: "widget-kpi__label", children: n }),
|
|
257
|
+
/* @__PURE__ */ l("span", { className: "widget-kpi__value", children: r }),
|
|
258
|
+
a && a.variance_pct != null && /* @__PURE__ */ m("div", { className: `widget-kpi__trend ${s}`, children: [
|
|
259
|
+
/* @__PURE__ */ m("span", { className: "widget-kpi__variance", children: [
|
|
260
|
+
i,
|
|
261
|
+
" ",
|
|
262
|
+
a.variance_pct > 0 ? "+" : "",
|
|
263
|
+
a.variance_pct.toFixed(1),
|
|
264
|
+
"%"
|
|
265
|
+
] }),
|
|
266
|
+
a.label && /* @__PURE__ */ l("span", { className: "widget-kpi__trend-label", children: a.label })
|
|
267
|
+
] })
|
|
268
|
+
] });
|
|
269
|
+
}
|
|
270
|
+
const Se = "var(--bg-elevated)";
|
|
271
|
+
function R(e, t, n, r) {
|
|
272
|
+
if (r <= 0) return "";
|
|
273
|
+
if (r >= 1)
|
|
274
|
+
return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${e} ${t - n} A ${n} ${n} 0 0 1 ${e + n} ${t}`;
|
|
275
|
+
const a = r * Math.PI, s = e - n * Math.cos(a), i = t - n * Math.sin(a);
|
|
276
|
+
return `M ${e - n} ${t} A ${n} ${n} 0 0 1 ${s} ${i}`;
|
|
277
|
+
}
|
|
278
|
+
function Y(e) {
|
|
279
|
+
const t = Math.abs(e);
|
|
280
|
+
return t >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : t >= 1e3 ? `${(e / 1e3).toFixed(1)}K` : e.toLocaleString("pt-BR");
|
|
281
|
+
}
|
|
282
|
+
function Ne({ data: e, palette: t, label: n }) {
|
|
283
|
+
const r = n || String(e.label || ""), a = typeof e.value == "number" ? e.value : null, s = a != null ? Y(a) : "-", i = String(e.formatted || "-"), c = typeof e.ratio == "number" ? e.ratio : 0, g = e.target_value, u = e.comparison_label, o = c >= 1, d = Math.min(Math.max(c, 0), 1), f = o ? "var(--action-green)" : c >= 0.7 ? t[0] || "var(--color-info)" : c >= 0.4 ? "var(--color-warning)" : "var(--color-error)", v = g != null ? Y(g) : "-", h = 50, p = 50, k = 44, $ = 10;
|
|
284
|
+
return /* @__PURE__ */ m("div", { className: "widget widget-gauge", children: [
|
|
285
|
+
/* @__PURE__ */ l("span", { className: "widget-gauge__label", children: r }),
|
|
286
|
+
/* @__PURE__ */ m("div", { className: "widget-gauge__chart", children: [
|
|
287
|
+
/* @__PURE__ */ m("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", children: [
|
|
288
|
+
/* @__PURE__ */ l("path", { d: R(h, p, k, 1), fill: "none", stroke: Se, strokeWidth: $, strokeLinecap: "butt" }),
|
|
289
|
+
d > 0 && /* @__PURE__ */ l("path", { d: R(h, p, k, d), fill: "none", stroke: f, strokeWidth: $, strokeLinecap: "butt" })
|
|
290
|
+
] }),
|
|
291
|
+
/* @__PURE__ */ m("div", { className: "widget-gauge__center", children: [
|
|
292
|
+
/* @__PURE__ */ l("span", { className: "widget-gauge__percent", children: i }),
|
|
293
|
+
/* @__PURE__ */ m("span", { className: "widget-gauge__comparison", children: [
|
|
294
|
+
s,
|
|
295
|
+
" / ",
|
|
296
|
+
v
|
|
297
|
+
] }),
|
|
298
|
+
o && /* @__PURE__ */ l("span", { className: "widget-gauge__badge", children: u || "Meta batida" }),
|
|
299
|
+
!o && u && /* @__PURE__ */ l("span", { className: "widget-gauge__comparison", children: u })
|
|
300
|
+
] })
|
|
301
|
+
] })
|
|
302
|
+
] });
|
|
303
|
+
}
|
|
304
|
+
const W = { fontSize: 10, fill: "var(--text-muted)" }, Te = "var(--bg-elevated)", z = {
|
|
305
|
+
backgroundColor: "var(--bg-elevated)",
|
|
306
|
+
border: "1px solid var(--bg-paper)",
|
|
307
|
+
borderRadius: "6px",
|
|
308
|
+
color: "var(--text-primary)"
|
|
309
|
+
}, J = {
|
|
310
|
+
color: "var(--text-primary)",
|
|
311
|
+
fontWeight: 600
|
|
312
|
+
};
|
|
313
|
+
function H(e, t) {
|
|
314
|
+
var a;
|
|
315
|
+
const n = Array.isArray(t) ? t[0] : void 0, r = (a = n == null ? void 0 : n.payload) == null ? void 0 : a.tooltipLabel;
|
|
316
|
+
return typeof r == "string" && r ? r : String(e ?? "");
|
|
317
|
+
}
|
|
318
|
+
function ke(e) {
|
|
319
|
+
const [t, n] = T({ width: 0, height: 0 });
|
|
320
|
+
return P(() => {
|
|
321
|
+
const r = e.current;
|
|
322
|
+
if (!r) return;
|
|
323
|
+
const a = new ResizeObserver(([s]) => {
|
|
324
|
+
const { width: i, height: c } = s.contentRect;
|
|
325
|
+
n(
|
|
326
|
+
(g) => g.width !== Math.floor(i) || g.height !== Math.floor(c) ? { width: Math.floor(i), height: Math.floor(c) } : g
|
|
327
|
+
);
|
|
328
|
+
});
|
|
329
|
+
return a.observe(r), () => a.disconnect();
|
|
330
|
+
}, [e]), t;
|
|
331
|
+
}
|
|
332
|
+
function L({ Chart: e, chartData: t, xKey: n, series: r, palette: a, renderSeries: s, width: i, height: c }) {
|
|
333
|
+
return /* @__PURE__ */ m(e, { data: t, width: i, height: c, children: [
|
|
334
|
+
/* @__PURE__ */ l(ie, { strokeDasharray: "3 3", stroke: Te }),
|
|
335
|
+
/* @__PURE__ */ l(ce, { dataKey: n, tick: W }),
|
|
336
|
+
/* @__PURE__ */ l(oe, { tick: W }),
|
|
337
|
+
/* @__PURE__ */ l(
|
|
338
|
+
j,
|
|
339
|
+
{
|
|
340
|
+
contentStyle: z,
|
|
341
|
+
labelStyle: J,
|
|
342
|
+
labelFormatter: H,
|
|
343
|
+
cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
|
|
344
|
+
}
|
|
345
|
+
),
|
|
346
|
+
r.length > 1 && /* @__PURE__ */ l(de, {}),
|
|
347
|
+
r.map((g, u) => s(g, a[u % a.length], u))
|
|
348
|
+
] });
|
|
349
|
+
}
|
|
350
|
+
function $e({ data: e, palette: t, label: n }) {
|
|
351
|
+
const r = String(e.chartType || "bar"), a = n || String(e.label || ""), s = String(e.xKey || "label"), i = e.series || [], c = e.data || [], g = O(null), { width: u, height: o } = ke(g);
|
|
352
|
+
return c.length ? /* @__PURE__ */ m("div", { className: "widget widget-chart", children: [
|
|
353
|
+
a && /* @__PURE__ */ l("h4", { className: "widget-chart__title", children: a }),
|
|
354
|
+
/* @__PURE__ */ l("div", { ref: g, className: "widget-chart__container", children: (() => {
|
|
355
|
+
var v;
|
|
356
|
+
if (u <= 0 || o <= 0) return null;
|
|
357
|
+
if (r === "pie")
|
|
358
|
+
return /* @__PURE__ */ m(Z, { width: u, height: o, children: [
|
|
359
|
+
/* @__PURE__ */ l(
|
|
360
|
+
B,
|
|
361
|
+
{
|
|
362
|
+
data: c,
|
|
363
|
+
dataKey: ((v = i[0]) == null ? void 0 : v.key) || "s0",
|
|
364
|
+
nameKey: s,
|
|
365
|
+
cx: "50%",
|
|
366
|
+
cy: "50%",
|
|
367
|
+
outerRadius: "75%",
|
|
368
|
+
label: ({ name: h, percent: p }) => `${h}: ${(p * 100).toFixed(0)}%`,
|
|
369
|
+
labelLine: !1,
|
|
370
|
+
children: c.map((h, p) => /* @__PURE__ */ l(ee, { fill: t[p % t.length] }, p))
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ l(
|
|
374
|
+
j,
|
|
375
|
+
{
|
|
376
|
+
contentStyle: z,
|
|
377
|
+
labelStyle: J,
|
|
378
|
+
labelFormatter: H
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] });
|
|
382
|
+
const f = { chartData: c, xKey: s, series: i, palette: t, width: u, height: o };
|
|
383
|
+
return r === "line" ? /* @__PURE__ */ l(L, { ...f, Chart: te, renderSeries: (h, p) => /* @__PURE__ */ l(
|
|
384
|
+
ae,
|
|
385
|
+
{
|
|
386
|
+
type: "monotone",
|
|
387
|
+
dataKey: h.key,
|
|
388
|
+
name: h.label,
|
|
389
|
+
stroke: p,
|
|
390
|
+
strokeWidth: 2,
|
|
391
|
+
dot: c.length <= 31
|
|
392
|
+
},
|
|
393
|
+
h.key
|
|
394
|
+
) }) : r === "area" ? /* @__PURE__ */ l(L, { ...f, Chart: re, renderSeries: (h, p) => /* @__PURE__ */ l(
|
|
395
|
+
ne,
|
|
396
|
+
{
|
|
397
|
+
type: "monotone",
|
|
398
|
+
dataKey: h.key,
|
|
399
|
+
name: h.label,
|
|
400
|
+
fill: p,
|
|
401
|
+
stroke: p,
|
|
402
|
+
fillOpacity: 0.3
|
|
403
|
+
},
|
|
404
|
+
h.key
|
|
405
|
+
) }) : /* @__PURE__ */ l(L, { ...f, Chart: le, renderSeries: (h, p) => /* @__PURE__ */ l(
|
|
406
|
+
se,
|
|
407
|
+
{
|
|
408
|
+
dataKey: h.key,
|
|
409
|
+
name: h.label,
|
|
410
|
+
fill: p,
|
|
411
|
+
radius: [3, 3, 0, 0]
|
|
412
|
+
},
|
|
413
|
+
h.key
|
|
414
|
+
) });
|
|
415
|
+
})() })
|
|
416
|
+
] }) : /* @__PURE__ */ l("div", { className: "widget widget-chart widget-chart--empty", children: "Sem dados" });
|
|
417
|
+
}
|
|
418
|
+
const X = [
|
|
419
|
+
"Jan",
|
|
420
|
+
"Fev",
|
|
421
|
+
"Mar",
|
|
422
|
+
"Abr",
|
|
423
|
+
"Mai",
|
|
424
|
+
"Jun",
|
|
425
|
+
"Jul",
|
|
426
|
+
"Ago",
|
|
427
|
+
"Set",
|
|
428
|
+
"Out",
|
|
429
|
+
"Nov",
|
|
430
|
+
"Dez"
|
|
431
|
+
], nt = [
|
|
432
|
+
"Janeiro",
|
|
433
|
+
"Fevereiro",
|
|
434
|
+
"Marco",
|
|
435
|
+
"Abril",
|
|
436
|
+
"Maio",
|
|
437
|
+
"Junho",
|
|
438
|
+
"Julho",
|
|
439
|
+
"Agosto",
|
|
440
|
+
"Setembro",
|
|
441
|
+
"Outubro",
|
|
442
|
+
"Novembro",
|
|
443
|
+
"Dezembro"
|
|
444
|
+
];
|
|
445
|
+
function De(e) {
|
|
446
|
+
return { start: `${e}-01-01`, end: `${e}-12-31` };
|
|
447
|
+
}
|
|
448
|
+
function Ce(e) {
|
|
449
|
+
if (!e) return null;
|
|
450
|
+
const t = e.match(/^(\d{4})/);
|
|
451
|
+
return t ? { year: parseInt(t[1]) } : null;
|
|
452
|
+
}
|
|
453
|
+
function Ee(e, t) {
|
|
454
|
+
const n = new Date(e, t, 0).getDate(), r = (a) => String(a).padStart(2, "0");
|
|
455
|
+
return {
|
|
456
|
+
start: `${e}-${r(t)}-01`,
|
|
457
|
+
end: `${e}-${r(t)}-${r(n)}`
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function q(e) {
|
|
461
|
+
const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
|
|
462
|
+
t.setUTCDate(t.getUTCDate() + 4 - (t.getUTCDay() || 7));
|
|
463
|
+
const n = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
|
|
464
|
+
return Math.ceil(((t.getTime() - n.getTime()) / 864e5 + 1) / 7);
|
|
465
|
+
}
|
|
466
|
+
function lt(e, t) {
|
|
467
|
+
const n = new Date(e, 0, 4), r = (n.getDay() + 6) % 7, a = new Date(n.getTime() - r * 864e5), s = new Date(a.getTime() + (t - 1) * 7 * 864e5), i = new Date(s.getTime() + 6 * 864e5), c = (u) => String(u).padStart(2, "0"), g = (u) => `${u.getFullYear()}-${c(u.getMonth() + 1)}-${c(u.getDate())}`;
|
|
468
|
+
return { start: g(s), end: g(i) };
|
|
469
|
+
}
|
|
470
|
+
function st(e, t) {
|
|
471
|
+
const n = /* @__PURE__ */ new Set(), r = new Date(e, t, 0).getDate();
|
|
472
|
+
for (let a = 1; a <= r; a++)
|
|
473
|
+
n.add(q(new Date(e, t - 1, a)));
|
|
474
|
+
return Array.from(n).sort((a, s) => a - s);
|
|
475
|
+
}
|
|
476
|
+
function A(e, t) {
|
|
477
|
+
const n = new Date(e, t, 0).getDate(), r = (c) => String(c).padStart(2, "0"), a = [];
|
|
478
|
+
let s = 1, i = 1;
|
|
479
|
+
for (; s <= n; ) {
|
|
480
|
+
const c = s, g = Math.min(s + 6, n), u = `${e}-${r(t)}-${r(c)}`, o = `${e}-${r(t)}-${r(g)}`, d = `${i}° Semana (${r(c)}/${r(t)} - ${r(g)}/${r(t)})`;
|
|
481
|
+
a.push({ index: i, startDay: c, endDay: g, start: u, end: o, label: d }), s = g + 1, i++;
|
|
482
|
+
}
|
|
483
|
+
return a;
|
|
484
|
+
}
|
|
485
|
+
function xe(e, t, n) {
|
|
486
|
+
if (!e) return 1;
|
|
487
|
+
const r = (i) => String(i).padStart(2, "0"), a = e.match(new RegExp(`^${t}-${r(n)}-(\\d{2})`));
|
|
488
|
+
if (!a) return 1;
|
|
489
|
+
const s = parseInt(a[1]);
|
|
490
|
+
return Math.ceil(s / 7);
|
|
491
|
+
}
|
|
492
|
+
function Q(e) {
|
|
493
|
+
if (!e) return null;
|
|
494
|
+
const t = e.match(/^(\d{4})-(\d{2})/);
|
|
495
|
+
return t ? { year: parseInt(t[1]), month: parseInt(t[2]) } : null;
|
|
496
|
+
}
|
|
497
|
+
function it(e) {
|
|
498
|
+
if (!e) return null;
|
|
499
|
+
const t = /* @__PURE__ */ new Date(e + "T00:00:00");
|
|
500
|
+
return isNaN(t.getTime()) ? null : { year: t.getFullYear(), week: q(t) };
|
|
501
|
+
}
|
|
502
|
+
function I(e) {
|
|
503
|
+
const t = /* @__PURE__ */ new Date(), n = e != null && e.min ? parseInt(e.min.slice(0, 4)) : t.getFullYear() - 2, r = e != null && e.max ? parseInt(e.max.slice(0, 4)) : t.getFullYear(), a = [];
|
|
504
|
+
for (let s = r; s >= n; s--) a.push(s);
|
|
505
|
+
return a;
|
|
506
|
+
}
|
|
507
|
+
function D(e) {
|
|
508
|
+
if (!e) return null;
|
|
509
|
+
const [t, n, r] = e.split("-").map(Number);
|
|
510
|
+
return !t || !n || !r ? null : new Date(t, n - 1, r);
|
|
511
|
+
}
|
|
512
|
+
function Me(e) {
|
|
513
|
+
if (!e) return "";
|
|
514
|
+
const t = e.getFullYear(), n = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
|
|
515
|
+
return `${t}-${n}-${r}`;
|
|
516
|
+
}
|
|
517
|
+
function U({
|
|
518
|
+
value: e,
|
|
519
|
+
onChange: t,
|
|
520
|
+
minIso: n,
|
|
521
|
+
maxIso: r,
|
|
522
|
+
placeholder: a,
|
|
523
|
+
selectsStart: s,
|
|
524
|
+
selectsEnd: i,
|
|
525
|
+
startIso: c,
|
|
526
|
+
endIso: g,
|
|
527
|
+
className: u,
|
|
528
|
+
disabled: o
|
|
529
|
+
}) {
|
|
530
|
+
return /* @__PURE__ */ l("div", { className: `ddp-field ${u ?? ""}`, children: /* @__PURE__ */ l(
|
|
531
|
+
ue,
|
|
532
|
+
{
|
|
533
|
+
selected: D(e),
|
|
534
|
+
onChange: (d) => t(Me(d)),
|
|
535
|
+
selectsStart: s,
|
|
536
|
+
selectsEnd: i,
|
|
537
|
+
startDate: D(c) ?? void 0,
|
|
538
|
+
endDate: D(g) ?? void 0,
|
|
539
|
+
minDate: D(n) ?? void 0,
|
|
540
|
+
maxDate: D(r) ?? void 0,
|
|
541
|
+
dateFormat: "dd/MM/yyyy",
|
|
542
|
+
placeholderText: a ?? "Selecione...",
|
|
543
|
+
disabled: o,
|
|
544
|
+
portalId: "ddp-portal",
|
|
545
|
+
popperPlacement: "bottom-start",
|
|
546
|
+
popperModifiers: [
|
|
547
|
+
{
|
|
548
|
+
name: "flip",
|
|
549
|
+
options: { fallbackPlacements: ["bottom-end", "top-start", "top-end"] },
|
|
550
|
+
fn: (d) => d
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
) });
|
|
555
|
+
}
|
|
556
|
+
function Fe({ config: e, value: t, options: n = [], dateBounds: r, onChange: a }) {
|
|
557
|
+
const s = e.filterType || "select", i = e.label || "Filtro", c = e.dateFilterMode || "range";
|
|
558
|
+
return /* @__PURE__ */ m("div", { className: "widget-filter", children: [
|
|
559
|
+
/* @__PURE__ */ l("label", { className: "widget-filter__label", children: i }),
|
|
560
|
+
s === "date_range" ? c === "yearly" ? /* @__PURE__ */ l(Ae, { value: t, dateBounds: r, onChange: a }) : c === "monthly" ? /* @__PURE__ */ l(Oe, { value: t, dateBounds: r, onChange: a }) : c === "weekly" ? /* @__PURE__ */ l(Pe, { value: t, dateBounds: r, onChange: a }) : /* @__PURE__ */ l(Le, { value: t, dateBounds: r, onChange: a }) : /* @__PURE__ */ l(
|
|
561
|
+
Ie,
|
|
562
|
+
{
|
|
563
|
+
value: t,
|
|
564
|
+
options: n,
|
|
565
|
+
multi: s === "multi_select",
|
|
566
|
+
onChange: a
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
] });
|
|
570
|
+
}
|
|
571
|
+
function Le({ value: e, dateBounds: t, onChange: n }) {
|
|
572
|
+
const [r, a] = e ? e.split("|") : ["", ""];
|
|
573
|
+
return /* @__PURE__ */ m("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
|
|
574
|
+
/* @__PURE__ */ l(
|
|
575
|
+
U,
|
|
576
|
+
{
|
|
577
|
+
value: r,
|
|
578
|
+
minIso: t == null ? void 0 : t.min,
|
|
579
|
+
maxIso: a || (t == null ? void 0 : t.max),
|
|
580
|
+
selectsStart: !0,
|
|
581
|
+
startIso: r,
|
|
582
|
+
endIso: a,
|
|
583
|
+
placeholder: "Data inicial",
|
|
584
|
+
onChange: (s) => n(`${s}|${a}`)
|
|
585
|
+
}
|
|
586
|
+
),
|
|
587
|
+
/* @__PURE__ */ l(
|
|
588
|
+
U,
|
|
589
|
+
{
|
|
590
|
+
value: a,
|
|
591
|
+
minIso: r || (t == null ? void 0 : t.min),
|
|
592
|
+
maxIso: t == null ? void 0 : t.max,
|
|
593
|
+
selectsEnd: !0,
|
|
594
|
+
startIso: r,
|
|
595
|
+
endIso: a,
|
|
596
|
+
placeholder: "Data final",
|
|
597
|
+
onChange: (s) => n(`${r}|${s}`)
|
|
598
|
+
}
|
|
599
|
+
)
|
|
600
|
+
] });
|
|
601
|
+
}
|
|
602
|
+
function Ae({ value: e, dateBounds: t, onChange: n }) {
|
|
603
|
+
const [r] = e ? e.split("|") : [""], a = Ce(r), s = /* @__PURE__ */ new Date(), i = (a == null ? void 0 : a.year) ?? s.getFullYear(), c = I(t), g = (u) => {
|
|
604
|
+
const o = De(u);
|
|
605
|
+
n(`${o.start}|${o.end}`);
|
|
606
|
+
};
|
|
607
|
+
return /* @__PURE__ */ l("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ l(
|
|
608
|
+
"select",
|
|
609
|
+
{
|
|
610
|
+
className: "widget-filter__select",
|
|
611
|
+
value: i,
|
|
612
|
+
onChange: (u) => g(parseInt(u.target.value)),
|
|
613
|
+
children: c.map((u) => /* @__PURE__ */ l("option", { value: u, children: u }, u))
|
|
614
|
+
}
|
|
615
|
+
) });
|
|
616
|
+
}
|
|
617
|
+
function Oe({ value: e, dateBounds: t, onChange: n }) {
|
|
618
|
+
const [r] = e ? e.split("|") : [""], a = Q(r), s = /* @__PURE__ */ new Date(), i = (a == null ? void 0 : a.year) ?? s.getFullYear(), c = (a == null ? void 0 : a.month) ?? s.getMonth() + 1, g = I(t), u = (o, d) => {
|
|
619
|
+
const f = Ee(o, d);
|
|
620
|
+
n(`${f.start}|${f.end}`);
|
|
621
|
+
};
|
|
622
|
+
return /* @__PURE__ */ m("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
|
|
623
|
+
/* @__PURE__ */ l(
|
|
624
|
+
"select",
|
|
625
|
+
{
|
|
626
|
+
className: "widget-filter__select",
|
|
627
|
+
value: c,
|
|
628
|
+
onChange: (o) => u(i, parseInt(o.target.value)),
|
|
629
|
+
children: X.map((o, d) => /* @__PURE__ */ l("option", { value: d + 1, children: o }, d + 1))
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ l(
|
|
633
|
+
"select",
|
|
634
|
+
{
|
|
635
|
+
className: "widget-filter__select",
|
|
636
|
+
value: i,
|
|
637
|
+
onChange: (o) => u(parseInt(o.target.value), c),
|
|
638
|
+
children: g.map((o) => /* @__PURE__ */ l("option", { value: o, children: o }, o))
|
|
639
|
+
}
|
|
640
|
+
)
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
function Pe({ value: e, dateBounds: t, onChange: n }) {
|
|
644
|
+
const [r] = e ? e.split("|") : [""], a = Q(r), s = /* @__PURE__ */ new Date(), i = (a == null ? void 0 : a.year) ?? s.getFullYear(), c = (a == null ? void 0 : a.month) ?? s.getMonth() + 1, g = I(t), u = A(i, c), o = xe(r, i, c) || 1;
|
|
645
|
+
return /* @__PURE__ */ m("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
|
|
646
|
+
/* @__PURE__ */ l(
|
|
647
|
+
"select",
|
|
648
|
+
{
|
|
649
|
+
className: "widget-filter__select",
|
|
650
|
+
value: i,
|
|
651
|
+
onChange: (d) => {
|
|
652
|
+
const f = parseInt(d.target.value), h = A(f, c)[0];
|
|
653
|
+
h && n(`${h.start}|${h.end}`);
|
|
654
|
+
},
|
|
655
|
+
children: g.map((d) => /* @__PURE__ */ l("option", { value: d, children: d }, d))
|
|
656
|
+
}
|
|
657
|
+
),
|
|
658
|
+
/* @__PURE__ */ l(
|
|
659
|
+
"select",
|
|
660
|
+
{
|
|
661
|
+
className: "widget-filter__select",
|
|
662
|
+
value: c,
|
|
663
|
+
onChange: (d) => {
|
|
664
|
+
const f = parseInt(d.target.value), h = A(i, f)[0];
|
|
665
|
+
h && n(`${h.start}|${h.end}`);
|
|
666
|
+
},
|
|
667
|
+
children: X.map((d, f) => /* @__PURE__ */ l("option", { value: f + 1, children: d }, f + 1))
|
|
668
|
+
}
|
|
669
|
+
),
|
|
670
|
+
/* @__PURE__ */ l(
|
|
671
|
+
"select",
|
|
672
|
+
{
|
|
673
|
+
className: "widget-filter__select",
|
|
674
|
+
value: o,
|
|
675
|
+
onChange: (d) => {
|
|
676
|
+
const f = u[parseInt(d.target.value) - 1];
|
|
677
|
+
f && n(`${f.start}|${f.end}`);
|
|
678
|
+
},
|
|
679
|
+
children: u.map((d) => /* @__PURE__ */ l("option", { value: d.index, children: d.label }, d.index))
|
|
680
|
+
}
|
|
681
|
+
)
|
|
682
|
+
] });
|
|
683
|
+
}
|
|
684
|
+
function Ie({ value: e, options: t, multi: n, onChange: r }) {
|
|
685
|
+
if (n) {
|
|
686
|
+
const a = e ? e.split(",") : [], s = (i) => {
|
|
687
|
+
const c = a.includes(i) ? a.filter((g) => g !== i) : [...a, i];
|
|
688
|
+
r(c.join(","));
|
|
689
|
+
};
|
|
690
|
+
return /* @__PURE__ */ l("div", { className: "widget-filter__multi", children: t.map((i) => /* @__PURE__ */ m("label", { className: "widget-filter__multi-option", children: [
|
|
691
|
+
/* @__PURE__ */ l(
|
|
692
|
+
"input",
|
|
693
|
+
{
|
|
694
|
+
type: "checkbox",
|
|
695
|
+
checked: a.includes(i),
|
|
696
|
+
onChange: () => s(i)
|
|
697
|
+
}
|
|
698
|
+
),
|
|
699
|
+
i
|
|
700
|
+
] }, i)) });
|
|
701
|
+
}
|
|
702
|
+
return /* @__PURE__ */ m(
|
|
703
|
+
"select",
|
|
704
|
+
{
|
|
705
|
+
className: "widget-filter__select",
|
|
706
|
+
value: e,
|
|
707
|
+
onChange: (a) => r(a.target.value),
|
|
708
|
+
children: [
|
|
709
|
+
/* @__PURE__ */ l("option", { value: "", children: "Todos" }),
|
|
710
|
+
t.map((a) => /* @__PURE__ */ l("option", { value: a, children: a }, a))
|
|
711
|
+
]
|
|
712
|
+
}
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
const Re = {
|
|
716
|
+
currency: "R$",
|
|
717
|
+
percentage: "%"
|
|
718
|
+
};
|
|
719
|
+
function Ye({ config: e, value: t, onChange: n }) {
|
|
720
|
+
const r = e.label || "Variavel", a = e.locked || !1, s = e.variableFormat || "number", i = Re[s] || "";
|
|
721
|
+
return /* @__PURE__ */ m("div", { className: `widget-variable ${a ? "widget-variable--locked" : ""}`, children: [
|
|
722
|
+
/* @__PURE__ */ l("label", { className: "widget-variable__label", children: r }),
|
|
723
|
+
/* @__PURE__ */ m("div", { className: "widget-variable__input-wrapper", children: [
|
|
724
|
+
/* @__PURE__ */ l(
|
|
725
|
+
"input",
|
|
726
|
+
{
|
|
727
|
+
className: "widget-variable__input",
|
|
728
|
+
type: "number",
|
|
729
|
+
value: t,
|
|
730
|
+
onChange: (c) => n(parseFloat(c.target.value) || 0),
|
|
731
|
+
disabled: a,
|
|
732
|
+
step: s === "integer" ? 1 : 0.01
|
|
733
|
+
}
|
|
734
|
+
),
|
|
735
|
+
i && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: i })
|
|
736
|
+
] }),
|
|
737
|
+
a && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
738
|
+
] });
|
|
739
|
+
}
|
|
740
|
+
const We = [
|
|
741
|
+
_.bgDark,
|
|
742
|
+
_.bgPaper,
|
|
743
|
+
_.bgElevated,
|
|
744
|
+
_.accent,
|
|
745
|
+
_.success
|
|
746
|
+
];
|
|
747
|
+
function Ue(e) {
|
|
748
|
+
if (!e) return !0;
|
|
749
|
+
const t = C(e);
|
|
750
|
+
return Object.values(M).some(
|
|
751
|
+
(n) => JSON.stringify(n.colors) === JSON.stringify(t)
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
const Ge = [
|
|
755
|
+
{ label: "Series", slots: ["series0", "series1", "series2", "series3", "series4"] },
|
|
756
|
+
{ label: "Tema", slots: ["bgDark", "bgPaper", "bgElevated", "textPrimary", "textMuted"] },
|
|
757
|
+
{ label: "Estados", slots: ["accent", "success", "error"] }
|
|
758
|
+
];
|
|
759
|
+
function je({
|
|
760
|
+
selected: e,
|
|
761
|
+
onSelect: t,
|
|
762
|
+
customMode: n,
|
|
763
|
+
onCustomModeChange: r,
|
|
764
|
+
disabled: a
|
|
765
|
+
}) {
|
|
766
|
+
var u;
|
|
767
|
+
const s = n ?? !Ue(e), i = C(e), c = s || (u = Object.entries(M).find(
|
|
768
|
+
([, o]) => JSON.stringify(o.colors) === JSON.stringify(i)
|
|
769
|
+
)) == null ? void 0 : u[0], g = (o, d) => {
|
|
770
|
+
const f = [...i];
|
|
771
|
+
for (; f.length < x; ) f.push("#000000");
|
|
772
|
+
f[o] = d, t(f);
|
|
773
|
+
};
|
|
774
|
+
return /* @__PURE__ */ m("div", { className: `palette-selector ${a ? "palette-selector--disabled" : ""}`, children: [
|
|
775
|
+
r && /* @__PURE__ */ m("label", { className: "config-panel__checkbox", children: [
|
|
776
|
+
/* @__PURE__ */ l(
|
|
777
|
+
"input",
|
|
778
|
+
{
|
|
779
|
+
type: "checkbox",
|
|
780
|
+
checked: s,
|
|
781
|
+
onChange: (o) => r(o.target.checked),
|
|
782
|
+
disabled: a
|
|
783
|
+
}
|
|
784
|
+
),
|
|
785
|
+
"Customizar"
|
|
786
|
+
] }),
|
|
787
|
+
s ? /* @__PURE__ */ l("div", { className: "palette-selector__custom", children: Ge.map((o) => /* @__PURE__ */ m("div", { className: "palette-selector__row", children: [
|
|
788
|
+
/* @__PURE__ */ l("span", { className: "palette-selector__row-label", children: o.label }),
|
|
789
|
+
/* @__PURE__ */ l("div", { className: "palette-selector__row-slots", children: o.slots.map((d) => {
|
|
790
|
+
const f = _[d];
|
|
791
|
+
return /* @__PURE__ */ l(
|
|
792
|
+
"input",
|
|
793
|
+
{
|
|
794
|
+
type: "color",
|
|
795
|
+
className: "palette-selector__color-input",
|
|
796
|
+
value: i[f] || "#000000",
|
|
797
|
+
onChange: (v) => g(f, v.target.value),
|
|
798
|
+
disabled: a,
|
|
799
|
+
title: ve[d]
|
|
800
|
+
},
|
|
801
|
+
d
|
|
802
|
+
);
|
|
803
|
+
}) })
|
|
804
|
+
] }, o.label)) }) : /* @__PURE__ */ l("div", { className: "palette-selector__options", children: Object.entries(M).map(([o, d]) => {
|
|
805
|
+
const f = C(d.colors);
|
|
806
|
+
return /* @__PURE__ */ m(
|
|
807
|
+
"button",
|
|
808
|
+
{
|
|
809
|
+
className: `palette-selector__option ${c === o ? "palette-selector__option--active" : ""}`,
|
|
810
|
+
onClick: () => t(d.colors),
|
|
811
|
+
disabled: a,
|
|
812
|
+
children: [
|
|
813
|
+
/* @__PURE__ */ l("div", { className: "palette-selector__bar", children: K(d.colors).map((v, h) => /* @__PURE__ */ l(
|
|
814
|
+
"span",
|
|
815
|
+
{
|
|
816
|
+
className: "palette-selector__swatch",
|
|
817
|
+
style: { backgroundColor: v }
|
|
818
|
+
},
|
|
819
|
+
h
|
|
820
|
+
)) }),
|
|
821
|
+
/* @__PURE__ */ l("div", { className: "palette-selector__bar palette-selector__bar--theme", children: We.map((v, h) => /* @__PURE__ */ l(
|
|
822
|
+
"span",
|
|
823
|
+
{
|
|
824
|
+
className: "palette-selector__swatch",
|
|
825
|
+
style: { backgroundColor: f[v] }
|
|
826
|
+
},
|
|
827
|
+
h
|
|
828
|
+
)) }),
|
|
829
|
+
/* @__PURE__ */ l("span", { className: "palette-selector__label", children: d.label })
|
|
830
|
+
]
|
|
831
|
+
},
|
|
832
|
+
o
|
|
833
|
+
);
|
|
834
|
+
}) })
|
|
835
|
+
] });
|
|
836
|
+
}
|
|
837
|
+
function Ve({ config: e, palette: t, onChange: n }) {
|
|
838
|
+
const r = e.label || "Cores", a = e.locked || !1;
|
|
839
|
+
return /* @__PURE__ */ m("div", { className: `widget-palette ${a ? "widget-palette--locked" : ""}`, children: [
|
|
840
|
+
/* @__PURE__ */ l("label", { className: "widget-palette__label", children: r }),
|
|
841
|
+
/* @__PURE__ */ l(je, { selected: t, onSelect: n, customMode: !0, disabled: a }),
|
|
842
|
+
a && /* @__PURE__ */ l("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
843
|
+
] });
|
|
844
|
+
}
|
|
845
|
+
function Ke({
|
|
846
|
+
type: e,
|
|
847
|
+
computed: t,
|
|
848
|
+
palette: n,
|
|
849
|
+
config: r,
|
|
850
|
+
filterValue: a,
|
|
851
|
+
filterOptions: s,
|
|
852
|
+
dateBounds: i,
|
|
853
|
+
onFilterChange: c,
|
|
854
|
+
variableValue: g,
|
|
855
|
+
onVariableChange: u,
|
|
856
|
+
onPaletteChange: o
|
|
857
|
+
}) {
|
|
858
|
+
if (t.error)
|
|
859
|
+
return /* @__PURE__ */ l("div", { className: "widget widget--error", children: /* @__PURE__ */ l("span", { className: "widget__error-text", children: String(t.error) }) });
|
|
860
|
+
const d = K(n);
|
|
861
|
+
switch (e) {
|
|
862
|
+
case "kpi_card":
|
|
863
|
+
return /* @__PURE__ */ l(ye, { data: t, label: r == null ? void 0 : r.label });
|
|
864
|
+
case "gauge":
|
|
865
|
+
return /* @__PURE__ */ l(Ne, { data: t, palette: d, label: r == null ? void 0 : r.label });
|
|
866
|
+
case "chart":
|
|
867
|
+
return /* @__PURE__ */ l($e, { data: t, palette: d, label: r == null ? void 0 : r.label });
|
|
868
|
+
case "filter":
|
|
869
|
+
return r && c ? /* @__PURE__ */ l(
|
|
870
|
+
Fe,
|
|
871
|
+
{
|
|
872
|
+
config: r,
|
|
873
|
+
value: a || "",
|
|
874
|
+
options: s,
|
|
875
|
+
dateBounds: i,
|
|
876
|
+
onChange: c
|
|
877
|
+
}
|
|
878
|
+
) : null;
|
|
879
|
+
case "variable": {
|
|
880
|
+
const f = r;
|
|
881
|
+
return f && u ? /* @__PURE__ */ l(
|
|
882
|
+
Ye,
|
|
883
|
+
{
|
|
884
|
+
config: f,
|
|
885
|
+
value: g ?? f.variableValue ?? 0,
|
|
886
|
+
onChange: u
|
|
887
|
+
}
|
|
888
|
+
) : null;
|
|
889
|
+
}
|
|
890
|
+
case "color_palette":
|
|
891
|
+
return r && o ? /* @__PURE__ */ l(
|
|
892
|
+
Ve,
|
|
893
|
+
{
|
|
894
|
+
config: r,
|
|
895
|
+
palette: n,
|
|
896
|
+
onChange: o
|
|
897
|
+
}
|
|
898
|
+
) : null;
|
|
899
|
+
default:
|
|
900
|
+
return /* @__PURE__ */ m("div", { className: "widget", children: [
|
|
901
|
+
"Widget: ",
|
|
902
|
+
e
|
|
903
|
+
] });
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
const ze = V, Je = 30, He = 10, ct = {
|
|
907
|
+
gridColumns: Je,
|
|
908
|
+
gridRows: He,
|
|
909
|
+
widgets: []
|
|
910
|
+
}, ot = {
|
|
911
|
+
kpi_card: "KPI Card",
|
|
912
|
+
gauge: "Gauge",
|
|
913
|
+
chart: "Gráfico",
|
|
914
|
+
filter: "Filtro",
|
|
915
|
+
variable: "Variável",
|
|
916
|
+
color_palette: "Paleta de Cores"
|
|
917
|
+
}, dt = ["kpi_card", "gauge", "chart"], ut = ["filter", "variable", "color_palette"], Xe = /* @__PURE__ */ new Set(["filter", "variable", "color_palette"]), gt = {
|
|
918
|
+
sum: "Soma",
|
|
919
|
+
avg: "Média",
|
|
920
|
+
count: "Contagem",
|
|
921
|
+
min: "Mínimo",
|
|
922
|
+
max: "Máximo",
|
|
923
|
+
count_distinct: "Contagem Distinta"
|
|
924
|
+
}, qe = {
|
|
925
|
+
currency: "Moeda (R$)",
|
|
926
|
+
number: "Número",
|
|
927
|
+
integer: "Inteiro",
|
|
928
|
+
percentage: "Porcentagem",
|
|
929
|
+
date: "Data",
|
|
930
|
+
text: "Texto"
|
|
931
|
+
}, ft = Object.entries(qe).filter(([e]) => e !== "date" && e !== "text"), ht = {
|
|
932
|
+
yoy: "vs Ano Anterior",
|
|
933
|
+
mom: "vs Mês Anterior",
|
|
934
|
+
target: "vs Meta",
|
|
935
|
+
none: "Nenhuma"
|
|
936
|
+
}, mt = {
|
|
937
|
+
bar: "Barras",
|
|
938
|
+
line: "Linhas",
|
|
939
|
+
area: "Área",
|
|
940
|
+
pie: "Pizza"
|
|
941
|
+
}, pt = {
|
|
942
|
+
date_range: "Periodo",
|
|
943
|
+
select: "Seleção Única",
|
|
944
|
+
multi_select: "Seleção Múltipla"
|
|
945
|
+
}, _t = {
|
|
946
|
+
kpi_card: { x: 0, y: 0, w: 6, h: 3 },
|
|
947
|
+
gauge: { x: 0, y: 0, w: 6, h: 5 },
|
|
948
|
+
chart: { x: 0, y: 0, w: 6, h: 6 },
|
|
949
|
+
filter: { x: 0, y: 0, w: 4, h: 2 },
|
|
950
|
+
variable: { x: 0, y: 0, w: 4, h: 2 },
|
|
951
|
+
color_palette: { x: 0, y: 0, w: 4, h: 2 }
|
|
952
|
+
}, bt = {
|
|
953
|
+
kpi_card: { label: "Novo KPI", aggregation: "sum", format: "number" },
|
|
954
|
+
gauge: { label: "Novo Gauge", aggregation: "sum" },
|
|
955
|
+
chart: { label: "Novo Grafico", chartType: "bar", xAxis: { column: "", granularity: "day" }, series: [] },
|
|
956
|
+
filter: { label: "Novo Filtro", filterType: "select" },
|
|
957
|
+
variable: { label: "Nova Variavel", variableValue: 0, variableFormat: "number", locked: !1 },
|
|
958
|
+
color_palette: { label: "Paleta de Cores", paletteColors: ze, locked: !1 }
|
|
959
|
+
}, Qe = 40, Ze = 6;
|
|
960
|
+
function vt(e) {
|
|
961
|
+
const { rowHeight: t = Qe, gridGap: n = Ze, className: r } = e, a = G(() => "fetcher" in e && e.fetcher ? e.fetcher : fe({ apiUrl: e.apiUrl, token: e.token }), [
|
|
962
|
+
"fetcher" in e ? e.fetcher : null,
|
|
963
|
+
"apiUrl" in e ? e.apiUrl : null,
|
|
964
|
+
"token" in e ? e.token : null
|
|
965
|
+
]), {
|
|
966
|
+
layout: s,
|
|
967
|
+
renderData: i,
|
|
968
|
+
loading: c,
|
|
969
|
+
error: g,
|
|
970
|
+
filters: u,
|
|
971
|
+
variables: o,
|
|
972
|
+
palette: d,
|
|
973
|
+
setFilter: f,
|
|
974
|
+
setVariable: v,
|
|
975
|
+
setPalette: h
|
|
976
|
+
} = me(a);
|
|
977
|
+
if (g && !s)
|
|
978
|
+
return /* @__PURE__ */ l("div", { className: `preview-tab ${r ?? ""}`, children: /* @__PURE__ */ l("div", { className: "preview-tab__error", children: g }) });
|
|
979
|
+
if (!s)
|
|
980
|
+
return /* @__PURE__ */ l("div", { className: `preview-tab ${r ?? ""}`, children: /* @__PURE__ */ l("div", { className: "preview-tab__loading", children: "Carregando dashboard..." }) });
|
|
981
|
+
if (s.widgets.length === 0)
|
|
982
|
+
return /* @__PURE__ */ l("div", { className: `preview-tab ${r ?? ""}`, children: /* @__PURE__ */ l("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." }) });
|
|
983
|
+
const p = (i == null ? void 0 : i.widgets) ?? {}, k = (i == null ? void 0 : i.date_bounds) ?? null, $ = {
|
|
984
|
+
display: "grid",
|
|
985
|
+
gridTemplateColumns: `repeat(${s.gridColumns}, 1fr)`,
|
|
986
|
+
gridTemplateRows: `repeat(${s.gridRows}, ${t}px)`,
|
|
987
|
+
gap: `${n}px`,
|
|
988
|
+
// Aplica CSS vars da paleta no container — widgets descendentes usam var(--bg-*, --text-*, etc)
|
|
989
|
+
...we(d)
|
|
990
|
+
};
|
|
991
|
+
return /* @__PURE__ */ m("div", { className: `preview-tab ${r ?? ""}`, children: [
|
|
992
|
+
g && !i && /* @__PURE__ */ l("div", { className: "preview-tab__error", children: g }),
|
|
993
|
+
i && /* @__PURE__ */ l("div", { className: "preview-tab__grid", style: $, children: s.widgets.map((b) => {
|
|
994
|
+
const E = Xe.has(b.type), S = p[b.id], y = {
|
|
995
|
+
gridColumn: `${b.grid.x + 1} / span ${b.grid.w}`,
|
|
996
|
+
gridRow: `${b.grid.y + 1} / span ${b.grid.h}`
|
|
997
|
+
}, w = b.type === "variable" ? o[b.id] ?? (S == null ? void 0 : S.value) ?? b.config.variableValue ?? 0 : void 0;
|
|
998
|
+
return /* @__PURE__ */ l(
|
|
999
|
+
"div",
|
|
1000
|
+
{
|
|
1001
|
+
className: `preview-tab__widget ${E ? "preview-tab__widget--control" : ""}`,
|
|
1002
|
+
style: y,
|
|
1003
|
+
children: E || S ? /* @__PURE__ */ l(
|
|
1004
|
+
Ke,
|
|
1005
|
+
{
|
|
1006
|
+
type: b.type,
|
|
1007
|
+
computed: S || {},
|
|
1008
|
+
palette: d,
|
|
1009
|
+
config: b.config,
|
|
1010
|
+
filterValue: u[b.id] || "",
|
|
1011
|
+
filterOptions: (S == null ? void 0 : S.available_values) || [],
|
|
1012
|
+
dateBounds: k,
|
|
1013
|
+
onFilterChange: (N) => f(b.id, N),
|
|
1014
|
+
variableValue: w,
|
|
1015
|
+
onVariableChange: (N) => v(b.id, N),
|
|
1016
|
+
onPaletteChange: h
|
|
1017
|
+
}
|
|
1018
|
+
) : /* @__PURE__ */ l("div", { className: "preview-tab__widget-loading", children: c ? "Carregando..." : "Sem dados" })
|
|
1019
|
+
},
|
|
1020
|
+
b.id
|
|
1021
|
+
);
|
|
1022
|
+
}) }),
|
|
1023
|
+
c && i && /* @__PURE__ */ l("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
|
|
1024
|
+
] });
|
|
1025
|
+
}
|
|
1026
|
+
export {
|
|
1027
|
+
gt as AGGREGATION_LABELS,
|
|
1028
|
+
ge as ApiError,
|
|
1029
|
+
mt as CHART_TYPE_LABELS,
|
|
1030
|
+
ht as COMPARISON_LABELS,
|
|
1031
|
+
Xe as CONTROL_WIDGET_SET,
|
|
1032
|
+
ut as CONTROL_WIDGET_TYPES,
|
|
1033
|
+
$e as ChartWidget,
|
|
1034
|
+
je as ColorPaletteSelector,
|
|
1035
|
+
Ve as ColorPaletteWidget,
|
|
1036
|
+
dt as DATA_WIDGET_TYPES,
|
|
1037
|
+
bt as DEFAULT_CONFIG,
|
|
1038
|
+
_t as DEFAULT_GRID,
|
|
1039
|
+
Je as DEFAULT_GRID_COLUMNS,
|
|
1040
|
+
He as DEFAULT_GRID_ROWS,
|
|
1041
|
+
ze as DEFAULT_PALETTE,
|
|
1042
|
+
V as DEFAULT_PALETTE_COLORS,
|
|
1043
|
+
rt as DEFAULT_PALETTE_KEY,
|
|
1044
|
+
vt as Dashboard,
|
|
1045
|
+
U as DashboardDatePicker,
|
|
1046
|
+
ct as EMPTY_LAYOUT,
|
|
1047
|
+
pt as FILTER_TYPE_LABELS,
|
|
1048
|
+
qe as FORMAT_LABELS,
|
|
1049
|
+
Fe as FilterWidget,
|
|
1050
|
+
Ne as GaugeWidget,
|
|
1051
|
+
ye as KPIWidget,
|
|
1052
|
+
nt as MONTH_NAMES_FULL,
|
|
1053
|
+
X as MONTH_NAMES_SHORT,
|
|
1054
|
+
ft as NUMERIC_FORMAT_OPTIONS,
|
|
1055
|
+
M as PALETTES,
|
|
1056
|
+
be as SERIES_COUNT,
|
|
1057
|
+
_ as SLOT_INDEX,
|
|
1058
|
+
ve as SLOT_LABELS,
|
|
1059
|
+
x as TOTAL_SLOTS,
|
|
1060
|
+
Ye as VariableWidget,
|
|
1061
|
+
ot as WIDGET_TYPE_LABELS,
|
|
1062
|
+
Ke as WidgetRenderer,
|
|
1063
|
+
fe as createTokenFetcher,
|
|
1064
|
+
Me as dateToIso,
|
|
1065
|
+
C as ensurePaletteShape,
|
|
1066
|
+
De as getFullYearRange,
|
|
1067
|
+
q as getISOWeek,
|
|
1068
|
+
Ee as getMonthRange,
|
|
1069
|
+
A as getMonthWeeks,
|
|
1070
|
+
we as getPaletteCssVars,
|
|
1071
|
+
K as getSeries,
|
|
1072
|
+
lt as getWeekRange,
|
|
1073
|
+
st as getWeeksInMonth,
|
|
1074
|
+
I as getYearRange,
|
|
1075
|
+
D as isoToDate,
|
|
1076
|
+
Q as parseMonthFromRange,
|
|
1077
|
+
xe as parseMonthWeekFromRange,
|
|
1078
|
+
it as parseWeekFromRange,
|
|
1079
|
+
Ce as parseYearFromRange,
|
|
1080
|
+
me as useDashboardData
|
|
1081
|
+
};
|
|
1082
|
+
//# sourceMappingURL=index.js.map
|