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