@actionexec/dashboards 0.4.0 → 0.5.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 +2 -2
- package/dist/Dashboard.d.ts +2 -2
- package/dist/api/fetcher.d.ts +3 -0
- package/dist/{index-BHv7_r-h.js → index-C3jiurhg.js} +129 -94
- package/dist/index-C3jiurhg.js.map +1 -0
- package/dist/index.js +240 -266
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +1 -0
- package/dist/internals.js +14 -13
- package/package.json +1 -1
- package/dist/index-BHv7_r-h.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,106 +1,80 @@
|
|
|
1
|
-
import { jsxs as _, jsx as
|
|
2
|
-
import { useState as N, useRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
async function Y(a, r, n) {
|
|
12
|
-
const t = new URL(`${ue}${ge}${a}`);
|
|
13
|
-
if (n)
|
|
14
|
-
for (const [i, s] of Object.entries(n)) t.searchParams.set(i, s);
|
|
15
|
-
const e = await fetch(t.toString(), {
|
|
16
|
-
headers: { Authorization: `Bearer ${r}` }
|
|
17
|
-
});
|
|
18
|
-
if (!e.ok) {
|
|
19
|
-
let i;
|
|
20
|
-
try {
|
|
21
|
-
i = await e.json();
|
|
22
|
-
} catch {
|
|
23
|
-
}
|
|
24
|
-
throw new pe(
|
|
25
|
-
`Requisicao falhou (${e.status}) em ${a}`,
|
|
26
|
-
e.status,
|
|
27
|
-
i
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return await e.json();
|
|
31
|
-
}
|
|
32
|
-
const me = (a) => Y("/layout", a), _e = (a, r) => Y("/render", a, r), fe = 300;
|
|
33
|
-
function be(a) {
|
|
34
|
-
const [r, n] = N(null), [t, e] = N(null), [i, s] = N({}), [c, p] = N({}), [o, d] = N(null), [h, g] = N(!0), [w, u] = N(null), m = M(), $ = M(!1);
|
|
1
|
+
import { jsxs as _, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as x, useEffect as T, useCallback as M, useMemo as G } from "react";
|
|
3
|
+
import { L as j, O as z, J as H, z as I, G as W, m as D, u as R, H as X, k as L, t as q, r as Q, d as U, w as J, v as Z, b as B } from "./index-C3jiurhg.js";
|
|
4
|
+
import { Q as Ke } from "./index-C3jiurhg.js";
|
|
5
|
+
import { PieChart as ee, Pie as te, Cell as ae, Tooltip as P, LineChart as re, Line as le, AreaChart as ne, Area as ie, BarChart as se, Bar as ce, CartesianGrid as oe, XAxis as de, YAxis as ge, Legend as he } from "recharts";
|
|
6
|
+
const ue = 300;
|
|
7
|
+
function me(l) {
|
|
8
|
+
const [a, n] = N(null), [t, e] = N(null), [i, s] = N({}), [c, m] = N({}), [o, d] = N(null), [g, u] = N(!0), [w, h] = N(null), p = x(), k = x(!1);
|
|
35
9
|
T(() => {
|
|
36
10
|
let v = !1;
|
|
37
|
-
return
|
|
38
|
-
v || n(
|
|
39
|
-
}).catch((
|
|
40
|
-
v ||
|
|
11
|
+
return j(l).then((f) => {
|
|
12
|
+
v || n(f);
|
|
13
|
+
}).catch((f) => {
|
|
14
|
+
v || h(f.message);
|
|
41
15
|
}), () => {
|
|
42
16
|
v = !0;
|
|
43
17
|
};
|
|
44
|
-
}, [
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
47
|
-
const v =
|
|
48
|
-
|
|
49
|
-
e(
|
|
50
|
-
}).catch((
|
|
51
|
-
},
|
|
52
|
-
|
|
18
|
+
}, [l]), T(() => {
|
|
19
|
+
if (a)
|
|
20
|
+
return p.current && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
21
|
+
const v = pe(i, c);
|
|
22
|
+
u(!0), z(l, v).then((f) => {
|
|
23
|
+
e(f), !k.current && f.applied && (k.current = !0, s(($) => ({ ..._e(f.applied), ...$ }))), h(null);
|
|
24
|
+
}).catch((f) => h(f.message)).finally(() => u(!1));
|
|
25
|
+
}, ue), () => {
|
|
26
|
+
p.current && clearTimeout(p.current);
|
|
53
27
|
};
|
|
54
|
-
}, [
|
|
55
|
-
const
|
|
56
|
-
s((
|
|
57
|
-
}, []), C =
|
|
58
|
-
|
|
59
|
-
}, []), y =
|
|
28
|
+
}, [l, a, i, c]);
|
|
29
|
+
const b = M((v, f) => {
|
|
30
|
+
s(($) => ({ ...$, [v]: f }));
|
|
31
|
+
}, []), C = M((v, f) => {
|
|
32
|
+
m(($) => ({ ...$, [v]: f }));
|
|
33
|
+
}, []), y = M((v) => {
|
|
60
34
|
d(v);
|
|
61
35
|
}, []), S = G(
|
|
62
|
-
() => o ?? (
|
|
63
|
-
[o,
|
|
36
|
+
() => o ?? (a == null ? void 0 : a.palette) ?? [],
|
|
37
|
+
[o, a]
|
|
64
38
|
);
|
|
65
39
|
return {
|
|
66
|
-
layout:
|
|
40
|
+
layout: a,
|
|
67
41
|
renderData: t,
|
|
68
|
-
loading:
|
|
42
|
+
loading: g,
|
|
69
43
|
error: w,
|
|
70
44
|
filters: i,
|
|
71
45
|
variables: c,
|
|
72
46
|
palette: S,
|
|
73
|
-
setFilter:
|
|
47
|
+
setFilter: b,
|
|
74
48
|
setVariable: C,
|
|
75
49
|
setPalette: y
|
|
76
50
|
};
|
|
77
51
|
}
|
|
78
|
-
function
|
|
52
|
+
function pe(l, a) {
|
|
79
53
|
const n = {};
|
|
80
|
-
for (const [t, e] of Object.entries(
|
|
54
|
+
for (const [t, e] of Object.entries(l))
|
|
81
55
|
if (e.includes("|")) {
|
|
82
56
|
const [i, s] = e.split("|");
|
|
83
57
|
i && (n.f_date_start = i), s && (n.f_date_end = s);
|
|
84
58
|
} else
|
|
85
59
|
n[`f_${t}`] = e;
|
|
86
|
-
for (const [t, e] of Object.entries(
|
|
60
|
+
for (const [t, e] of Object.entries(a))
|
|
87
61
|
n[`v_${t}`] = String(e);
|
|
88
62
|
return n;
|
|
89
63
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
92
|
-
for (const [n, t] of Object.entries(
|
|
64
|
+
function _e(l) {
|
|
65
|
+
const a = {};
|
|
66
|
+
for (const [n, t] of Object.entries(l))
|
|
93
67
|
if (t && typeof t == "object" && "start" in t) {
|
|
94
68
|
const e = t;
|
|
95
|
-
|
|
96
|
-
} else Array.isArray(t) ?
|
|
97
|
-
return
|
|
69
|
+
a[n] = `${e.start || ""}|${e.end || ""}`;
|
|
70
|
+
} else Array.isArray(t) ? a[n] = t.join(",") : typeof t == "string" && (a[n] = t);
|
|
71
|
+
return a;
|
|
98
72
|
}
|
|
99
|
-
function
|
|
100
|
-
const n =
|
|
73
|
+
function be({ data: l, label: a }) {
|
|
74
|
+
const n = a || String(l.label || ""), t = String(l.formatted || "-"), e = l.comparison, i = (e == null ? void 0 : e.trend) === "up" ? "widget-kpi__trend--up" : (e == null ? void 0 : e.trend) === "down" ? "widget-kpi__trend--down" : "", s = (e == null ? void 0 : e.trend) === "up" ? "↑" : (e == null ? void 0 : e.trend) === "down" ? "↓" : "";
|
|
101
75
|
return /* @__PURE__ */ _("div", { className: "widget widget-kpi", children: [
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ r("span", { className: "widget-kpi__label", children: n }),
|
|
77
|
+
/* @__PURE__ */ r("span", { className: "widget-kpi__value", children: t }),
|
|
104
78
|
e && e.variance_pct != null && /* @__PURE__ */ _("div", { className: `widget-kpi__trend ${i}`, children: [
|
|
105
79
|
/* @__PURE__ */ _("span", { className: "widget-kpi__variance", children: [
|
|
106
80
|
s,
|
|
@@ -109,101 +83,101 @@ function ye({ data: a, label: r }) {
|
|
|
109
83
|
e.variance_pct.toFixed(1),
|
|
110
84
|
"%"
|
|
111
85
|
] }),
|
|
112
|
-
e.label && /* @__PURE__ */
|
|
86
|
+
e.label && /* @__PURE__ */ r("span", { className: "widget-kpi__trend-label", children: e.label })
|
|
113
87
|
] })
|
|
114
88
|
] });
|
|
115
89
|
}
|
|
116
|
-
const
|
|
117
|
-
function
|
|
90
|
+
const fe = "var(--bg-elevated)";
|
|
91
|
+
function O(l, a, n, t) {
|
|
118
92
|
if (t <= 0) return "";
|
|
119
93
|
if (t >= 1)
|
|
120
|
-
return `M ${
|
|
121
|
-
const e = t * Math.PI, i =
|
|
122
|
-
return `M ${
|
|
94
|
+
return `M ${l - n} ${a} A ${n} ${n} 0 0 1 ${l} ${a - n} A ${n} ${n} 0 0 1 ${l + n} ${a}`;
|
|
95
|
+
const e = t * Math.PI, i = l - n * Math.cos(e), s = a - n * Math.sin(e);
|
|
96
|
+
return `M ${l - n} ${a} A ${n} ${n} 0 0 1 ${i} ${s}`;
|
|
123
97
|
}
|
|
124
|
-
function A(
|
|
125
|
-
const
|
|
126
|
-
return
|
|
98
|
+
function A(l) {
|
|
99
|
+
const a = Math.abs(l);
|
|
100
|
+
return a >= 1e6 ? `${(l / 1e6).toFixed(1)}M` : a >= 1e3 ? `${(l / 1e3).toFixed(1)}K` : l.toLocaleString("pt-BR");
|
|
127
101
|
}
|
|
128
|
-
function
|
|
129
|
-
const t = n || String(
|
|
102
|
+
function ve({ data: l, palette: a, label: n }) {
|
|
103
|
+
const t = n || String(l.label || ""), e = typeof l.value == "number" ? l.value : null, i = e != null ? A(e) : "-", s = String(l.formatted || "-"), c = typeof l.ratio == "number" ? l.ratio : 0, m = l.target_value, o = l.comparison_label, d = c >= 1, g = Math.min(Math.max(c, 0), 1), u = d ? "var(--action-green)" : c >= 0.7 ? a[0] || "var(--color-info)" : c >= 0.4 ? "var(--color-warning)" : "var(--color-error)", w = m != null ? A(m) : "-", h = 50, p = 50, k = 44, b = 10;
|
|
130
104
|
return /* @__PURE__ */ _("div", { className: "widget widget-gauge", children: [
|
|
131
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ r("span", { className: "widget-gauge__label", children: t }),
|
|
132
106
|
/* @__PURE__ */ _("div", { className: "widget-gauge__chart", children: [
|
|
133
107
|
/* @__PURE__ */ _("svg", { viewBox: "0 0 100 56", preserveAspectRatio: "xMidYMax meet", children: [
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
|
|
108
|
+
/* @__PURE__ */ r("path", { d: O(h, p, k, 1), fill: "none", stroke: fe, strokeWidth: b, strokeLinecap: "butt" }),
|
|
109
|
+
g > 0 && /* @__PURE__ */ r("path", { d: O(h, p, k, g), fill: "none", stroke: u, strokeWidth: b, strokeLinecap: "butt" })
|
|
136
110
|
] }),
|
|
137
111
|
/* @__PURE__ */ _("div", { className: "widget-gauge__center", children: [
|
|
138
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ r("span", { className: "widget-gauge__percent", children: s }),
|
|
139
113
|
/* @__PURE__ */ _("span", { className: "widget-gauge__comparison", children: [
|
|
140
114
|
i,
|
|
141
115
|
" / ",
|
|
142
116
|
w
|
|
143
117
|
] }),
|
|
144
|
-
d && /* @__PURE__ */
|
|
145
|
-
!d && o && /* @__PURE__ */
|
|
118
|
+
d && /* @__PURE__ */ r("span", { className: "widget-gauge__badge", children: o || "Meta batida" }),
|
|
119
|
+
!d && o && /* @__PURE__ */ r("span", { className: "widget-gauge__comparison", children: o })
|
|
146
120
|
] })
|
|
147
121
|
] })
|
|
148
122
|
] });
|
|
149
123
|
}
|
|
150
|
-
const
|
|
124
|
+
const E = { fontSize: 10, fill: "var(--text-muted)" }, we = "var(--bg-elevated)", Y = {
|
|
151
125
|
backgroundColor: "var(--bg-elevated)",
|
|
152
126
|
border: "1px solid var(--bg-paper)",
|
|
153
127
|
borderRadius: "6px",
|
|
154
128
|
color: "var(--text-primary)"
|
|
155
|
-
},
|
|
129
|
+
}, V = {
|
|
156
130
|
color: "var(--text-primary)",
|
|
157
131
|
fontWeight: 600
|
|
158
132
|
};
|
|
159
|
-
function K(
|
|
133
|
+
function K(l, a) {
|
|
160
134
|
var e;
|
|
161
|
-
const n = Array.isArray(
|
|
162
|
-
return typeof t == "string" && t ? t : String(
|
|
135
|
+
const n = Array.isArray(a) ? a[0] : void 0, t = (e = n == null ? void 0 : n.payload) == null ? void 0 : e.tooltipLabel;
|
|
136
|
+
return typeof t == "string" && t ? t : String(l ?? "");
|
|
163
137
|
}
|
|
164
|
-
function
|
|
165
|
-
const [
|
|
138
|
+
function ye(l) {
|
|
139
|
+
const [a, n] = N({ width: 0, height: 0 });
|
|
166
140
|
return T(() => {
|
|
167
|
-
const t =
|
|
141
|
+
const t = l.current;
|
|
168
142
|
if (!t) return;
|
|
169
143
|
const e = new ResizeObserver(([i]) => {
|
|
170
144
|
const { width: s, height: c } = i.contentRect;
|
|
171
145
|
n(
|
|
172
|
-
(
|
|
146
|
+
(m) => m.width !== Math.floor(s) || m.height !== Math.floor(c) ? { width: Math.floor(s), height: Math.floor(c) } : m
|
|
173
147
|
);
|
|
174
148
|
});
|
|
175
149
|
return e.observe(t), () => e.disconnect();
|
|
176
|
-
}, [
|
|
150
|
+
}, [l]), a;
|
|
177
151
|
}
|
|
178
|
-
function F({ Chart:
|
|
179
|
-
return /* @__PURE__ */ _(
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
/* @__PURE__ */
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
|
|
152
|
+
function F({ Chart: l, chartData: a, xKey: n, series: t, palette: e, renderSeries: i, width: s, height: c }) {
|
|
153
|
+
return /* @__PURE__ */ _(l, { data: a, width: s, height: c, children: [
|
|
154
|
+
/* @__PURE__ */ r(oe, { strokeDasharray: "3 3", stroke: we }),
|
|
155
|
+
/* @__PURE__ */ r(de, { dataKey: n, tick: E }),
|
|
156
|
+
/* @__PURE__ */ r(ge, { tick: E }),
|
|
157
|
+
/* @__PURE__ */ r(
|
|
158
|
+
P,
|
|
185
159
|
{
|
|
186
|
-
contentStyle:
|
|
187
|
-
labelStyle:
|
|
160
|
+
contentStyle: Y,
|
|
161
|
+
labelStyle: V,
|
|
188
162
|
labelFormatter: K,
|
|
189
163
|
cursor: { fill: "var(--bg-paper)", opacity: 0.3 }
|
|
190
164
|
}
|
|
191
165
|
),
|
|
192
|
-
t.length > 1 && /* @__PURE__ */
|
|
193
|
-
t.map((
|
|
166
|
+
t.length > 1 && /* @__PURE__ */ r(he, {}),
|
|
167
|
+
t.map((m, o) => i(m, e[o % e.length], o))
|
|
194
168
|
] });
|
|
195
169
|
}
|
|
196
|
-
function
|
|
197
|
-
const t = String(
|
|
170
|
+
function Ne({ data: l, palette: a, label: n }) {
|
|
171
|
+
const t = String(l.chartType || "bar"), e = n || String(l.label || ""), i = String(l.xKey || "label"), s = l.series || [], c = l.data || [], m = x(null), { width: o, height: d } = ye(m);
|
|
198
172
|
return c.length ? /* @__PURE__ */ _("div", { className: "widget widget-chart", children: [
|
|
199
|
-
e && /* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
173
|
+
e && /* @__PURE__ */ r("h4", { className: "widget-chart__title", children: e }),
|
|
174
|
+
/* @__PURE__ */ r("div", { ref: m, className: "widget-chart__container", children: (() => {
|
|
201
175
|
var w;
|
|
202
176
|
if (o <= 0 || d <= 0) return null;
|
|
203
177
|
if (t === "pie")
|
|
204
|
-
return /* @__PURE__ */ _(
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
|
|
178
|
+
return /* @__PURE__ */ _(ee, { width: o, height: d, children: [
|
|
179
|
+
/* @__PURE__ */ r(
|
|
180
|
+
te,
|
|
207
181
|
{
|
|
208
182
|
data: c,
|
|
209
183
|
dataKey: ((w = s[0]) == null ? void 0 : w.key) || "s0",
|
|
@@ -211,64 +185,64 @@ function Se({ data: a, palette: r, label: n }) {
|
|
|
211
185
|
cx: "50%",
|
|
212
186
|
cy: "50%",
|
|
213
187
|
outerRadius: "75%",
|
|
214
|
-
label: ({ name:
|
|
188
|
+
label: ({ name: h, percent: p }) => `${h}: ${(p * 100).toFixed(0)}%`,
|
|
215
189
|
labelLine: !1,
|
|
216
|
-
children: c.map((
|
|
190
|
+
children: c.map((h, p) => /* @__PURE__ */ r(ae, { fill: a[p % a.length] }, p))
|
|
217
191
|
}
|
|
218
192
|
),
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
|
|
193
|
+
/* @__PURE__ */ r(
|
|
194
|
+
P,
|
|
221
195
|
{
|
|
222
|
-
contentStyle:
|
|
223
|
-
labelStyle:
|
|
196
|
+
contentStyle: Y,
|
|
197
|
+
labelStyle: V,
|
|
224
198
|
labelFormatter: K
|
|
225
199
|
}
|
|
226
200
|
)
|
|
227
201
|
] });
|
|
228
|
-
const
|
|
229
|
-
return t === "line" ? /* @__PURE__ */
|
|
230
|
-
|
|
202
|
+
const u = { chartData: c, xKey: i, series: s, palette: a, width: o, height: d };
|
|
203
|
+
return t === "line" ? /* @__PURE__ */ r(F, { ...u, Chart: re, renderSeries: (h, p) => /* @__PURE__ */ r(
|
|
204
|
+
le,
|
|
231
205
|
{
|
|
232
206
|
type: "monotone",
|
|
233
|
-
dataKey:
|
|
234
|
-
name:
|
|
235
|
-
stroke:
|
|
207
|
+
dataKey: h.key,
|
|
208
|
+
name: h.label,
|
|
209
|
+
stroke: p,
|
|
236
210
|
strokeWidth: 2,
|
|
237
211
|
dot: c.length <= 31
|
|
238
212
|
},
|
|
239
|
-
|
|
240
|
-
) }) : t === "area" ? /* @__PURE__ */
|
|
241
|
-
|
|
213
|
+
h.key
|
|
214
|
+
) }) : t === "area" ? /* @__PURE__ */ r(F, { ...u, Chart: ne, renderSeries: (h, p) => /* @__PURE__ */ r(
|
|
215
|
+
ie,
|
|
242
216
|
{
|
|
243
217
|
type: "monotone",
|
|
244
|
-
dataKey:
|
|
245
|
-
name:
|
|
246
|
-
fill:
|
|
247
|
-
stroke:
|
|
218
|
+
dataKey: h.key,
|
|
219
|
+
name: h.label,
|
|
220
|
+
fill: p,
|
|
221
|
+
stroke: p,
|
|
248
222
|
fillOpacity: 0.3
|
|
249
223
|
},
|
|
250
|
-
|
|
251
|
-
) }) : /* @__PURE__ */
|
|
252
|
-
|
|
224
|
+
h.key
|
|
225
|
+
) }) : /* @__PURE__ */ r(F, { ...u, Chart: se, renderSeries: (h, p) => /* @__PURE__ */ r(
|
|
226
|
+
ce,
|
|
253
227
|
{
|
|
254
|
-
dataKey:
|
|
255
|
-
name:
|
|
256
|
-
fill:
|
|
228
|
+
dataKey: h.key,
|
|
229
|
+
name: h.label,
|
|
230
|
+
fill: p,
|
|
257
231
|
radius: [3, 3, 0, 0]
|
|
258
232
|
},
|
|
259
|
-
|
|
233
|
+
h.key
|
|
260
234
|
) });
|
|
261
235
|
})() })
|
|
262
|
-
] }) : /* @__PURE__ */
|
|
236
|
+
] }) : /* @__PURE__ */ r("div", { className: "widget widget-chart widget-chart--empty", children: "Sem dados" });
|
|
263
237
|
}
|
|
264
|
-
function
|
|
265
|
-
const i =
|
|
238
|
+
function ke({ config: l, value: a, options: n = [], dateBounds: t, onChange: e }) {
|
|
239
|
+
const i = l.filterType || "select", s = l.label || "Filtro", c = l.dateFilterMode || "range";
|
|
266
240
|
return /* @__PURE__ */ _("div", { className: "widget-filter", children: [
|
|
267
|
-
/* @__PURE__ */
|
|
268
|
-
i === "date_range" ? c === "yearly" ? /* @__PURE__ */
|
|
269
|
-
|
|
241
|
+
/* @__PURE__ */ r("label", { className: "widget-filter__label", children: s }),
|
|
242
|
+
i === "date_range" ? c === "yearly" ? /* @__PURE__ */ r(Ce, { value: a, dateBounds: t, onChange: e }) : c === "monthly" ? /* @__PURE__ */ r(Se, { value: a, dateBounds: t, onChange: e }) : c === "weekly" ? /* @__PURE__ */ r(Me, { value: a, dateBounds: t, onChange: e }) : /* @__PURE__ */ r($e, { value: a, dateBounds: t, onChange: e }) : /* @__PURE__ */ r(
|
|
243
|
+
Re,
|
|
270
244
|
{
|
|
271
|
-
value:
|
|
245
|
+
value: a,
|
|
272
246
|
options: n,
|
|
273
247
|
multi: i === "multi_select",
|
|
274
248
|
onChange: e
|
|
@@ -276,15 +250,15 @@ function Re({ config: a, value: r, options: n = [], dateBounds: t, onChange: e }
|
|
|
276
250
|
)
|
|
277
251
|
] });
|
|
278
252
|
}
|
|
279
|
-
function
|
|
280
|
-
const [t, e] =
|
|
253
|
+
function $e({ value: l, dateBounds: a, onChange: n }) {
|
|
254
|
+
const [t, e] = l ? l.split("|") : ["", ""];
|
|
281
255
|
return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--stacked", children: [
|
|
282
|
-
/* @__PURE__ */
|
|
256
|
+
/* @__PURE__ */ r(
|
|
283
257
|
L,
|
|
284
258
|
{
|
|
285
259
|
value: t,
|
|
286
|
-
minIso:
|
|
287
|
-
maxIso: e || (
|
|
260
|
+
minIso: a == null ? void 0 : a.min,
|
|
261
|
+
maxIso: e || (a == null ? void 0 : a.max),
|
|
288
262
|
selectsStart: !0,
|
|
289
263
|
startIso: t,
|
|
290
264
|
endIso: e,
|
|
@@ -292,12 +266,12 @@ function xe({ value: a, dateBounds: r, onChange: n }) {
|
|
|
292
266
|
onChange: (i) => n(`${i}|${e}`)
|
|
293
267
|
}
|
|
294
268
|
),
|
|
295
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ r(
|
|
296
270
|
L,
|
|
297
271
|
{
|
|
298
272
|
value: e,
|
|
299
|
-
minIso: t || (
|
|
300
|
-
maxIso:
|
|
273
|
+
minIso: t || (a == null ? void 0 : a.min),
|
|
274
|
+
maxIso: a == null ? void 0 : a.max,
|
|
301
275
|
selectsEnd: !0,
|
|
302
276
|
startIso: t,
|
|
303
277
|
endIso: e,
|
|
@@ -307,96 +281,96 @@ function xe({ value: a, dateBounds: r, onChange: n }) {
|
|
|
307
281
|
)
|
|
308
282
|
] });
|
|
309
283
|
}
|
|
310
|
-
function
|
|
311
|
-
const [t] =
|
|
312
|
-
const d =
|
|
284
|
+
function Ce({ value: l, dateBounds: a, onChange: n }) {
|
|
285
|
+
const [t] = l ? l.split("|") : [""], e = H(t), i = /* @__PURE__ */ new Date(), s = (e == null ? void 0 : e.year) ?? i.getFullYear(), c = I(a), m = (o) => {
|
|
286
|
+
const d = Q(o);
|
|
313
287
|
n(`${d.start}|${d.end}`);
|
|
314
288
|
};
|
|
315
|
-
return /* @__PURE__ */
|
|
289
|
+
return /* @__PURE__ */ r("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ r(
|
|
316
290
|
"select",
|
|
317
291
|
{
|
|
318
292
|
className: "widget-filter__select",
|
|
319
293
|
value: s,
|
|
320
|
-
onChange: (o) =>
|
|
321
|
-
children: c.map((o) => /* @__PURE__ */
|
|
294
|
+
onChange: (o) => m(parseInt(o.target.value)),
|
|
295
|
+
children: c.map((o) => /* @__PURE__ */ r("option", { value: o, children: o }, o))
|
|
322
296
|
}
|
|
323
297
|
) });
|
|
324
298
|
}
|
|
325
|
-
function
|
|
326
|
-
const [t] =
|
|
327
|
-
const
|
|
328
|
-
n(`${
|
|
299
|
+
function Se({ value: l, dateBounds: a, onChange: n }) {
|
|
300
|
+
const [t] = l ? l.split("|") : [""], e = W(t), i = /* @__PURE__ */ new Date(), s = (e == null ? void 0 : e.year) ?? i.getFullYear(), c = (e == null ? void 0 : e.month) ?? i.getMonth() + 1, m = I(a), o = (d, g) => {
|
|
301
|
+
const u = q(d, g);
|
|
302
|
+
n(`${u.start}|${u.end}`);
|
|
329
303
|
};
|
|
330
304
|
return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--month", children: [
|
|
331
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ r(
|
|
332
306
|
"select",
|
|
333
307
|
{
|
|
334
308
|
className: "widget-filter__select",
|
|
335
309
|
value: c,
|
|
336
310
|
onChange: (d) => o(s, parseInt(d.target.value)),
|
|
337
|
-
children: D.map((d,
|
|
311
|
+
children: D.map((d, g) => /* @__PURE__ */ r("option", { value: g + 1, children: d }, g + 1))
|
|
338
312
|
}
|
|
339
313
|
),
|
|
340
|
-
/* @__PURE__ */
|
|
314
|
+
/* @__PURE__ */ r(
|
|
341
315
|
"select",
|
|
342
316
|
{
|
|
343
317
|
className: "widget-filter__select",
|
|
344
318
|
value: s,
|
|
345
319
|
onChange: (d) => o(parseInt(d.target.value), c),
|
|
346
|
-
children:
|
|
320
|
+
children: m.map((d) => /* @__PURE__ */ r("option", { value: d, children: d }, d))
|
|
347
321
|
}
|
|
348
322
|
)
|
|
349
323
|
] });
|
|
350
324
|
}
|
|
351
|
-
function
|
|
352
|
-
const [t] =
|
|
325
|
+
function Me({ value: l, dateBounds: a, onChange: n }) {
|
|
326
|
+
const [t] = l ? l.split("|") : [""], e = W(t), i = /* @__PURE__ */ new Date(), s = (e == null ? void 0 : e.year) ?? i.getFullYear(), c = (e == null ? void 0 : e.month) ?? i.getMonth() + 1, m = I(a), o = R(s, c), d = X(t, s, c) || 1;
|
|
353
327
|
return /* @__PURE__ */ _("div", { className: "widget-filter__date-range widget-filter__date-range--week", children: [
|
|
354
|
-
/* @__PURE__ */
|
|
328
|
+
/* @__PURE__ */ r(
|
|
355
329
|
"select",
|
|
356
330
|
{
|
|
357
331
|
className: "widget-filter__select",
|
|
358
332
|
value: s,
|
|
359
|
-
onChange: (
|
|
360
|
-
const
|
|
361
|
-
|
|
333
|
+
onChange: (g) => {
|
|
334
|
+
const u = parseInt(g.target.value), h = R(u, c)[0];
|
|
335
|
+
h && n(`${h.start}|${h.end}`);
|
|
362
336
|
},
|
|
363
|
-
children:
|
|
337
|
+
children: m.map((g) => /* @__PURE__ */ r("option", { value: g, children: g }, g))
|
|
364
338
|
}
|
|
365
339
|
),
|
|
366
|
-
/* @__PURE__ */
|
|
340
|
+
/* @__PURE__ */ r(
|
|
367
341
|
"select",
|
|
368
342
|
{
|
|
369
343
|
className: "widget-filter__select",
|
|
370
344
|
value: c,
|
|
371
|
-
onChange: (
|
|
372
|
-
const
|
|
373
|
-
|
|
345
|
+
onChange: (g) => {
|
|
346
|
+
const u = parseInt(g.target.value), h = R(s, u)[0];
|
|
347
|
+
h && n(`${h.start}|${h.end}`);
|
|
374
348
|
},
|
|
375
|
-
children: D.map((
|
|
349
|
+
children: D.map((g, u) => /* @__PURE__ */ r("option", { value: u + 1, children: g }, u + 1))
|
|
376
350
|
}
|
|
377
351
|
),
|
|
378
|
-
/* @__PURE__ */
|
|
352
|
+
/* @__PURE__ */ r(
|
|
379
353
|
"select",
|
|
380
354
|
{
|
|
381
355
|
className: "widget-filter__select",
|
|
382
356
|
value: d,
|
|
383
|
-
onChange: (
|
|
384
|
-
const
|
|
385
|
-
|
|
357
|
+
onChange: (g) => {
|
|
358
|
+
const u = o[parseInt(g.target.value) - 1];
|
|
359
|
+
u && n(`${u.start}|${u.end}`);
|
|
386
360
|
},
|
|
387
|
-
children: o.map((
|
|
361
|
+
children: o.map((g) => /* @__PURE__ */ r("option", { value: g.index, children: g.label }, g.index))
|
|
388
362
|
}
|
|
389
363
|
)
|
|
390
364
|
] });
|
|
391
365
|
}
|
|
392
|
-
function
|
|
366
|
+
function Re({ value: l, options: a, multi: n, onChange: t }) {
|
|
393
367
|
if (n) {
|
|
394
|
-
const e =
|
|
395
|
-
const c = e.includes(s) ? e.filter((
|
|
368
|
+
const e = l ? l.split(",") : [], i = (s) => {
|
|
369
|
+
const c = e.includes(s) ? e.filter((m) => m !== s) : [...e, s];
|
|
396
370
|
t(c.join(","));
|
|
397
371
|
};
|
|
398
|
-
return /* @__PURE__ */
|
|
399
|
-
/* @__PURE__ */
|
|
372
|
+
return /* @__PURE__ */ r("div", { className: "widget-filter__multi", children: a.map((s) => /* @__PURE__ */ _("label", { className: "widget-filter__multi-option", children: [
|
|
373
|
+
/* @__PURE__ */ r(
|
|
400
374
|
"input",
|
|
401
375
|
{
|
|
402
376
|
type: "checkbox",
|
|
@@ -411,74 +385,74 @@ function Ie({ value: a, options: r, multi: n, onChange: t }) {
|
|
|
411
385
|
"select",
|
|
412
386
|
{
|
|
413
387
|
className: "widget-filter__select",
|
|
414
|
-
value:
|
|
388
|
+
value: l,
|
|
415
389
|
onChange: (e) => t(e.target.value),
|
|
416
390
|
children: [
|
|
417
|
-
/* @__PURE__ */
|
|
418
|
-
|
|
391
|
+
/* @__PURE__ */ r("option", { value: "", children: "Todos" }),
|
|
392
|
+
a.map((e) => /* @__PURE__ */ r("option", { value: e, children: e }, e))
|
|
419
393
|
]
|
|
420
394
|
}
|
|
421
395
|
);
|
|
422
396
|
}
|
|
423
|
-
const
|
|
397
|
+
const Fe = {
|
|
424
398
|
currency: "R$",
|
|
425
399
|
percentage: "%"
|
|
426
400
|
};
|
|
427
|
-
function
|
|
428
|
-
const t =
|
|
401
|
+
function xe({ config: l, value: a, onChange: n }) {
|
|
402
|
+
const t = l.label || "Variavel", e = l.locked || !1, i = l.variableFormat || "number", s = Fe[i] || "";
|
|
429
403
|
return /* @__PURE__ */ _("div", { className: `widget-variable ${e ? "widget-variable--locked" : ""}`, children: [
|
|
430
|
-
/* @__PURE__ */
|
|
404
|
+
/* @__PURE__ */ r("label", { className: "widget-variable__label", children: t }),
|
|
431
405
|
/* @__PURE__ */ _("div", { className: "widget-variable__input-wrapper", children: [
|
|
432
|
-
/* @__PURE__ */
|
|
406
|
+
/* @__PURE__ */ r(
|
|
433
407
|
"input",
|
|
434
408
|
{
|
|
435
409
|
className: "widget-variable__input",
|
|
436
410
|
type: "number",
|
|
437
|
-
value:
|
|
411
|
+
value: a,
|
|
438
412
|
onChange: (c) => n(parseFloat(c.target.value) || 0),
|
|
439
413
|
disabled: e,
|
|
440
414
|
step: i === "integer" ? 1 : 0.01
|
|
441
415
|
}
|
|
442
416
|
),
|
|
443
|
-
s && /* @__PURE__ */
|
|
417
|
+
s && /* @__PURE__ */ r("span", { className: "widget-variable__suffix", children: s })
|
|
444
418
|
] }),
|
|
445
|
-
e && /* @__PURE__ */
|
|
419
|
+
e && /* @__PURE__ */ r("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
446
420
|
] });
|
|
447
421
|
}
|
|
448
|
-
function
|
|
449
|
-
const t =
|
|
422
|
+
function Te({ config: l, palette: a, onChange: n }) {
|
|
423
|
+
const t = l.label || "Cores", e = l.locked || !1;
|
|
450
424
|
return /* @__PURE__ */ _("div", { className: `widget-palette ${e ? "widget-palette--locked" : ""}`, children: [
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
e && /* @__PURE__ */
|
|
425
|
+
/* @__PURE__ */ r("label", { className: "widget-palette__label", children: t }),
|
|
426
|
+
/* @__PURE__ */ r(U, { selected: a, onSelect: n, customMode: !0, disabled: e }),
|
|
427
|
+
e && /* @__PURE__ */ r("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
454
428
|
] });
|
|
455
429
|
}
|
|
456
|
-
function
|
|
457
|
-
type:
|
|
458
|
-
computed:
|
|
430
|
+
function Ie({
|
|
431
|
+
type: l,
|
|
432
|
+
computed: a,
|
|
459
433
|
palette: n,
|
|
460
434
|
config: t,
|
|
461
435
|
filterValue: e,
|
|
462
436
|
filterOptions: i,
|
|
463
437
|
dateBounds: s,
|
|
464
438
|
onFilterChange: c,
|
|
465
|
-
variableValue:
|
|
439
|
+
variableValue: m,
|
|
466
440
|
onVariableChange: o,
|
|
467
441
|
onPaletteChange: d
|
|
468
442
|
}) {
|
|
469
|
-
if (
|
|
470
|
-
return /* @__PURE__ */
|
|
471
|
-
const
|
|
472
|
-
switch (
|
|
443
|
+
if (a.error)
|
|
444
|
+
return /* @__PURE__ */ r("div", { className: "widget widget--error", children: /* @__PURE__ */ r("span", { className: "widget__error-text", children: String(a.error) }) });
|
|
445
|
+
const g = J(n);
|
|
446
|
+
switch (l) {
|
|
473
447
|
case "kpi_card":
|
|
474
|
-
return /* @__PURE__ */
|
|
448
|
+
return /* @__PURE__ */ r(be, { data: a, label: t == null ? void 0 : t.label });
|
|
475
449
|
case "gauge":
|
|
476
|
-
return /* @__PURE__ */
|
|
450
|
+
return /* @__PURE__ */ r(ve, { data: a, palette: g, label: t == null ? void 0 : t.label });
|
|
477
451
|
case "chart":
|
|
478
|
-
return /* @__PURE__ */
|
|
452
|
+
return /* @__PURE__ */ r(Ne, { data: a, palette: g, label: t == null ? void 0 : t.label });
|
|
479
453
|
case "filter":
|
|
480
|
-
return t && c ? /* @__PURE__ */
|
|
481
|
-
|
|
454
|
+
return t && c ? /* @__PURE__ */ r(
|
|
455
|
+
ke,
|
|
482
456
|
{
|
|
483
457
|
config: t,
|
|
484
458
|
value: e || "",
|
|
@@ -488,19 +462,19 @@ function Oe({
|
|
|
488
462
|
}
|
|
489
463
|
) : null;
|
|
490
464
|
case "variable": {
|
|
491
|
-
const
|
|
492
|
-
return
|
|
493
|
-
|
|
465
|
+
const u = t;
|
|
466
|
+
return u && o ? /* @__PURE__ */ r(
|
|
467
|
+
xe,
|
|
494
468
|
{
|
|
495
|
-
config:
|
|
496
|
-
value:
|
|
469
|
+
config: u,
|
|
470
|
+
value: m ?? u.variableValue ?? 0,
|
|
497
471
|
onChange: o
|
|
498
472
|
}
|
|
499
473
|
) : null;
|
|
500
474
|
}
|
|
501
475
|
case "color_palette":
|
|
502
|
-
return t && d ? /* @__PURE__ */
|
|
503
|
-
|
|
476
|
+
return t && d ? /* @__PURE__ */ r(
|
|
477
|
+
Te,
|
|
504
478
|
{
|
|
505
479
|
config: t,
|
|
506
480
|
palette: n,
|
|
@@ -510,15 +484,15 @@ function Oe({
|
|
|
510
484
|
default:
|
|
511
485
|
return /* @__PURE__ */ _("div", { className: "widget", children: [
|
|
512
486
|
"Widget: ",
|
|
513
|
-
|
|
487
|
+
l
|
|
514
488
|
] });
|
|
515
489
|
}
|
|
516
490
|
}
|
|
517
|
-
const
|
|
518
|
-
function
|
|
519
|
-
token:
|
|
520
|
-
rowHeight:
|
|
521
|
-
gridGap: n =
|
|
491
|
+
const Le = 2.5, Oe = 0.375;
|
|
492
|
+
function Pe({
|
|
493
|
+
token: l,
|
|
494
|
+
rowHeight: a = Le,
|
|
495
|
+
gridGap: n = Oe,
|
|
522
496
|
className: t
|
|
523
497
|
}) {
|
|
524
498
|
const {
|
|
@@ -526,63 +500,63 @@ function Ke({
|
|
|
526
500
|
renderData: i,
|
|
527
501
|
loading: s,
|
|
528
502
|
error: c,
|
|
529
|
-
filters:
|
|
503
|
+
filters: m,
|
|
530
504
|
variables: o,
|
|
531
505
|
palette: d,
|
|
532
|
-
setFilter:
|
|
533
|
-
setVariable:
|
|
506
|
+
setFilter: g,
|
|
507
|
+
setVariable: u,
|
|
534
508
|
setPalette: w
|
|
535
|
-
} =
|
|
509
|
+
} = me(l);
|
|
536
510
|
if (c && !e)
|
|
537
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ r("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ r("div", { className: "preview-tab__error", children: c }) });
|
|
538
512
|
if (!e)
|
|
539
|
-
return /* @__PURE__ */
|
|
513
|
+
return /* @__PURE__ */ r("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." }) });
|
|
540
514
|
if (e.widgets.length === 0)
|
|
541
|
-
return /* @__PURE__ */
|
|
542
|
-
const
|
|
515
|
+
return /* @__PURE__ */ r("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ r("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." }) });
|
|
516
|
+
const h = (i == null ? void 0 : i.widgets) ?? {}, p = (i == null ? void 0 : i.date_bounds) ?? null, k = {
|
|
543
517
|
display: "grid",
|
|
544
518
|
gridTemplateColumns: `repeat(${e.gridColumns}, 1fr)`,
|
|
545
|
-
gridTemplateRows: `repeat(${e.gridRows}, ${
|
|
546
|
-
gap: `${n}
|
|
547
|
-
...
|
|
519
|
+
gridTemplateRows: `repeat(${e.gridRows}, ${a}rem)`,
|
|
520
|
+
gap: `${n}rem`,
|
|
521
|
+
...Z(d)
|
|
548
522
|
};
|
|
549
523
|
return /* @__PURE__ */ _("div", { className: `preview-tab ${t ?? ""}`, children: [
|
|
550
|
-
c && !i && /* @__PURE__ */
|
|
551
|
-
i && /* @__PURE__ */
|
|
552
|
-
const C =
|
|
553
|
-
gridColumn: `${
|
|
554
|
-
gridRow: `${
|
|
555
|
-
}, v =
|
|
556
|
-
return /* @__PURE__ */
|
|
524
|
+
c && !i && /* @__PURE__ */ r("div", { className: "preview-tab__error", children: c }),
|
|
525
|
+
i && /* @__PURE__ */ r("div", { className: "preview-tab__grid", style: k, children: e.widgets.map((b) => {
|
|
526
|
+
const C = B.has(b.type), y = h[b.id], S = {
|
|
527
|
+
gridColumn: `${b.grid.x + 1} / span ${b.grid.w}`,
|
|
528
|
+
gridRow: `${b.grid.y + 1} / span ${b.grid.h}`
|
|
529
|
+
}, v = b.type === "variable" ? o[b.id] ?? (y == null ? void 0 : y.value) ?? b.config.variableValue ?? 0 : void 0;
|
|
530
|
+
return /* @__PURE__ */ r(
|
|
557
531
|
"div",
|
|
558
532
|
{
|
|
559
533
|
className: `preview-tab__widget ${C ? "preview-tab__widget--control" : ""}`,
|
|
560
534
|
style: S,
|
|
561
|
-
children: C || y ? /* @__PURE__ */
|
|
562
|
-
|
|
535
|
+
children: C || y ? /* @__PURE__ */ r(
|
|
536
|
+
Ie,
|
|
563
537
|
{
|
|
564
|
-
type:
|
|
538
|
+
type: b.type,
|
|
565
539
|
computed: y || {},
|
|
566
540
|
palette: d,
|
|
567
|
-
config:
|
|
568
|
-
filterValue:
|
|
541
|
+
config: b.config,
|
|
542
|
+
filterValue: m[b.id] || "",
|
|
569
543
|
filterOptions: (y == null ? void 0 : y.available_values) || [],
|
|
570
|
-
dateBounds:
|
|
571
|
-
onFilterChange: (
|
|
544
|
+
dateBounds: p,
|
|
545
|
+
onFilterChange: (f) => g(b.id, f),
|
|
572
546
|
variableValue: v,
|
|
573
|
-
onVariableChange: (
|
|
547
|
+
onVariableChange: (f) => u(b.id, f),
|
|
574
548
|
onPaletteChange: w
|
|
575
549
|
}
|
|
576
|
-
) : /* @__PURE__ */
|
|
550
|
+
) : /* @__PURE__ */ r("div", { className: "preview-tab__widget-loading", children: s ? "Carregando..." : "Sem dados" })
|
|
577
551
|
},
|
|
578
|
-
|
|
552
|
+
b.id
|
|
579
553
|
);
|
|
580
554
|
}) }),
|
|
581
|
-
s && i && /* @__PURE__ */
|
|
555
|
+
s && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
|
|
582
556
|
] });
|
|
583
557
|
}
|
|
584
558
|
export {
|
|
585
|
-
|
|
586
|
-
|
|
559
|
+
Ke as ApiError,
|
|
560
|
+
Pe as Dashboard
|
|
587
561
|
};
|
|
588
562
|
//# sourceMappingURL=index.js.map
|