@actionexec/dashboards 0.5.3 → 0.5.4
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/components/SearchableSelect.d.ts +9 -0
- package/dist/{index-CxUAEQYp.js → index-BXIn44vr.js} +250 -166
- package/dist/index-BXIn44vr.js.map +1 -0
- package/dist/index.js +249 -238
- package/dist/index.js.map +1 -1
- package/dist/internals.d.ts +1 -0
- package/dist/internals.js +19 -18
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- 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 { O as G, Q as z, K as H, B as I, H as W, m as D, v as R, I as X, k as L, p as q, u as Q, s as U, d as J, x as Z, w as B, b as ee } from "./index-BXIn44vr.js";
|
|
4
|
+
import { R as je } from "./index-BXIn44vr.js";
|
|
5
|
+
import { PieChart as te, Pie as ae, Cell as re, Tooltip as P, LineChart as le, Line as ne, AreaChart as ie, Area as se, BarChart as ce, Bar as oe, CartesianGrid as de, XAxis as he, YAxis as ge, Legend as ue } from "recharts";
|
|
6
|
+
const me = 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 G(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), z(
|
|
23
|
-
e(f), !k.current && f.applied && (k.current = !0,
|
|
24
|
-
}).catch((f) =>
|
|
25
|
-
},
|
|
21
|
+
const v = _e(i, s);
|
|
22
|
+
u(!0), z(a, v).then((f) => {
|
|
23
|
+
e(f), !k.current && f.applied && (k.current = !0, c(($) => ({ ...be(f.applied), ...$ }))), g(null);
|
|
24
|
+
}).catch((f) => g(f.message)).finally(() => u(!1));
|
|
25
|
+
}, me), () => {
|
|
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 _e(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 be(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(",") : typeof t == "string" && (r[n] = t);
|
|
71
|
+
return r;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const n =
|
|
73
|
+
function fe({ 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 O(
|
|
90
|
+
const ve = "var(--bg-elevated)";
|
|
91
|
+
function O(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 A(
|
|
99
|
-
const
|
|
100
|
-
return
|
|
98
|
+
function A(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 we({ data: a, palette: r, label: n }) {
|
|
103
|
+
const t = n || String(a.label || ""), e = typeof a.value == "number" ? a.value : null, i = e != null ? A(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 ? A(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: O(g, p, k, 1), fill: "none", stroke: ve, strokeWidth: b, strokeLinecap: "butt" }),
|
|
109
|
+
h > 0 && /* @__PURE__ */ l("path", { d: O(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 E = { fontSize: 10, fill: "var(--text-muted)" },
|
|
124
|
+
const E = { fontSize: 10, fill: "var(--text-muted)" }, ye = "var(--bg-elevated)", Y = {
|
|
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 V(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 Ne(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__ */
|
|
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(de, { strokeDasharray: "3 3", stroke: ye }),
|
|
155
|
+
/* @__PURE__ */ l(he, { dataKey: n, tick: E }),
|
|
156
|
+
/* @__PURE__ */ l(ge, { tick: E }),
|
|
157
|
+
/* @__PURE__ */ l(
|
|
158
158
|
P,
|
|
159
159
|
{
|
|
160
160
|
contentStyle: Y,
|
|
161
|
-
labelStyle:
|
|
162
|
-
labelFormatter:
|
|
161
|
+
labelStyle: K,
|
|
162
|
+
labelFormatter: V,
|
|
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(ue, {}),
|
|
167
167
|
t.map((m, o) => i(m, e[o % e.length], o))
|
|
168
168
|
] });
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const t = String(
|
|
172
|
-
return
|
|
173
|
-
e && /* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
170
|
+
function ke({ 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 } = Ne(m);
|
|
172
|
+
return s.length ? /* @__PURE__ */ _("div", { className: "widget widget-chart", children: [
|
|
173
|
+
e && /* @__PURE__ */ l("h4", { className: "widget-chart__title", children: e }),
|
|
174
|
+
/* @__PURE__ */ l("div", { ref: m, className: "widget-chart__container", children: (() => {
|
|
175
175
|
var w;
|
|
176
176
|
if (o <= 0 || d <= 0) return null;
|
|
177
177
|
if (t === "pie")
|
|
178
|
-
return /* @__PURE__ */ _(
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
|
|
178
|
+
return /* @__PURE__ */ _(te, { width: o, height: d, children: [
|
|
179
|
+
/* @__PURE__ */ l(
|
|
180
|
+
ae,
|
|
181
181
|
{
|
|
182
|
-
data:
|
|
183
|
-
dataKey: ((w =
|
|
182
|
+
data: s,
|
|
183
|
+
dataKey: ((w = c[0]) == null ? void 0 : w.key) || "s0",
|
|
184
184
|
nameKey: i,
|
|
185
185
|
cx: "50%",
|
|
186
186
|
cy: "50%",
|
|
187
187
|
outerRadius: "75%",
|
|
188
|
-
label: ({ name:
|
|
188
|
+
label: ({ name: g, percent: p }) => `${g}: ${(p * 100).toFixed(0)}%`,
|
|
189
189
|
labelLine: !1,
|
|
190
|
-
children:
|
|
190
|
+
children: s.map((g, p) => /* @__PURE__ */ l(re, { fill: r[p % r.length] }, p))
|
|
191
191
|
}
|
|
192
192
|
),
|
|
193
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ l(
|
|
194
194
|
P,
|
|
195
195
|
{
|
|
196
196
|
contentStyle: Y,
|
|
197
|
-
labelStyle:
|
|
198
|
-
labelFormatter:
|
|
197
|
+
labelStyle: K,
|
|
198
|
+
labelFormatter: V
|
|
199
199
|
}
|
|
200
200
|
)
|
|
201
201
|
] });
|
|
202
|
-
const u = { chartData:
|
|
203
|
-
return t === "line" ? /* @__PURE__ */
|
|
204
|
-
|
|
202
|
+
const u = { chartData: s, xKey: i, series: c, palette: r, width: o, height: d };
|
|
203
|
+
return t === "line" ? /* @__PURE__ */ l(x, { ...u, Chart: le, renderSeries: (g, p) => /* @__PURE__ */ l(
|
|
204
|
+
ne,
|
|
205
205
|
{
|
|
206
206
|
type: "monotone",
|
|
207
|
-
dataKey:
|
|
208
|
-
name:
|
|
207
|
+
dataKey: g.key,
|
|
208
|
+
name: g.label,
|
|
209
209
|
stroke: p,
|
|
210
210
|
strokeWidth: 2,
|
|
211
|
-
dot:
|
|
211
|
+
dot: s.length <= 31
|
|
212
212
|
},
|
|
213
|
-
|
|
214
|
-
) }) : t === "area" ? /* @__PURE__ */
|
|
215
|
-
|
|
213
|
+
g.key
|
|
214
|
+
) }) : t === "area" ? /* @__PURE__ */ l(x, { ...u, Chart: ie, renderSeries: (g, p) => /* @__PURE__ */ l(
|
|
215
|
+
se,
|
|
216
216
|
{
|
|
217
217
|
type: "monotone",
|
|
218
|
-
dataKey:
|
|
219
|
-
name:
|
|
218
|
+
dataKey: g.key,
|
|
219
|
+
name: g.label,
|
|
220
220
|
fill: p,
|
|
221
221
|
stroke: p,
|
|
222
222
|
fillOpacity: 0.3
|
|
223
223
|
},
|
|
224
|
-
|
|
225
|
-
) }) : /* @__PURE__ */
|
|
226
|
-
|
|
224
|
+
g.key
|
|
225
|
+
) }) : /* @__PURE__ */ l(x, { ...u, Chart: ce, renderSeries: (g, p) => /* @__PURE__ */ l(
|
|
226
|
+
oe,
|
|
227
227
|
{
|
|
228
|
-
dataKey:
|
|
229
|
-
name:
|
|
228
|
+
dataKey: g.key,
|
|
229
|
+
name: g.label,
|
|
230
230
|
fill: p,
|
|
231
231
|
radius: [3, 3, 0, 0]
|
|
232
232
|
},
|
|
233
|
-
|
|
233
|
+
g.key
|
|
234
234
|
) });
|
|
235
235
|
})() })
|
|
236
|
-
] }) : /* @__PURE__ */
|
|
236
|
+
] }) : /* @__PURE__ */ l("div", { className: "widget widget-chart widget-chart--empty", children: "Sem dados" });
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
const i =
|
|
238
|
+
function $e({ 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(Ce, { value: r, dateBounds: t, onChange: e }) : s === "monthly" ? /* @__PURE__ */ l(Me, { value: r, dateBounds: t, onChange: e }) : s === "weekly" ? /* @__PURE__ */ l(Re, { value: r, dateBounds: t, onChange: e }) : /* @__PURE__ */ l(Se, { value: r, dateBounds: t, onChange: e }) : /* @__PURE__ */ l(
|
|
243
|
+
xe,
|
|
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 Se({ 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
|
+
/* @__PURE__ */ l(
|
|
257
258
|
L,
|
|
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
|
+
/* @__PURE__ */ l(
|
|
270
271
|
L,
|
|
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,101 +282,111 @@ function $e({ value: l, dateBounds: a, onChange: n }) {
|
|
|
281
282
|
)
|
|
282
283
|
] });
|
|
283
284
|
}
|
|
284
|
-
function Ce({ value:
|
|
285
|
-
const [t] =
|
|
286
|
-
const d =
|
|
285
|
+
function Ce({ 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 = I(r), m = (o) => {
|
|
287
|
+
const d = U(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 Me({ 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 = I(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 Re({ 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 = I(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 xe({ 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(",") : [], c = (s) => {
|
|
380
|
+
const m = i.includes(s) ? i.filter((o) => o !== s) : [...i, s];
|
|
381
|
+
e(m.join(","));
|
|
371
382
|
};
|
|
372
|
-
return /* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ l("div", { className: "widget-filter__multi", children: r.map((s) => /* @__PURE__ */ _("label", { className: "widget-filter__multi-option", children: [
|
|
384
|
+
/* @__PURE__ */ l(
|
|
374
385
|
"input",
|
|
375
386
|
{
|
|
376
387
|
type: "checkbox",
|
|
377
|
-
checked:
|
|
378
|
-
onChange: () =>
|
|
388
|
+
checked: i.includes(s),
|
|
389
|
+
onChange: () => c(s)
|
|
379
390
|
}
|
|
380
391
|
),
|
|
381
392
|
s
|
|
@@ -385,11 +396,11 @@ function Re({ value: l, options: a, multi: n, onChange: t }) {
|
|
|
385
396
|
"select",
|
|
386
397
|
{
|
|
387
398
|
className: "widget-filter__select",
|
|
388
|
-
value:
|
|
389
|
-
onChange: (
|
|
399
|
+
value: a,
|
|
400
|
+
onChange: (i) => e(i.target.value),
|
|
390
401
|
children: [
|
|
391
|
-
/* @__PURE__ */
|
|
392
|
-
|
|
402
|
+
/* @__PURE__ */ l("option", { value: "", children: "Todos" }),
|
|
403
|
+
r.map((i) => /* @__PURE__ */ l("option", { value: i, children: i }, i))
|
|
393
404
|
]
|
|
394
405
|
}
|
|
395
406
|
);
|
|
@@ -398,73 +409,73 @@ const Fe = {
|
|
|
398
409
|
currency: "R$",
|
|
399
410
|
percentage: "%"
|
|
400
411
|
};
|
|
401
|
-
function
|
|
402
|
-
const t =
|
|
412
|
+
function Te({ config: a, value: r, onChange: n }) {
|
|
413
|
+
const t = a.label || "Variavel", e = a.locked || !1, i = a.variableFormat || "number", c = Fe[i] || "";
|
|
403
414
|
return /* @__PURE__ */ _("div", { className: `widget-variable ${e ? "widget-variable--locked" : ""}`, children: [
|
|
404
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ l("label", { className: "widget-variable__label", children: t }),
|
|
405
416
|
/* @__PURE__ */ _("div", { className: "widget-variable__input-wrapper", children: [
|
|
406
|
-
/* @__PURE__ */
|
|
417
|
+
/* @__PURE__ */ l(
|
|
407
418
|
"input",
|
|
408
419
|
{
|
|
409
420
|
className: "widget-variable__input",
|
|
410
421
|
type: "number",
|
|
411
|
-
value:
|
|
412
|
-
onChange: (
|
|
422
|
+
value: r,
|
|
423
|
+
onChange: (s) => n(parseFloat(s.target.value) || 0),
|
|
413
424
|
disabled: e,
|
|
414
425
|
step: i === "integer" ? 1 : 0.01
|
|
415
426
|
}
|
|
416
427
|
),
|
|
417
|
-
|
|
428
|
+
c && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: c })
|
|
418
429
|
] }),
|
|
419
|
-
e && /* @__PURE__ */
|
|
430
|
+
e && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
420
431
|
] });
|
|
421
432
|
}
|
|
422
|
-
function
|
|
423
|
-
const t =
|
|
433
|
+
function Ie({ config: a, palette: r, onChange: n }) {
|
|
434
|
+
const t = a.label || "Cores", e = a.locked || !1;
|
|
424
435
|
return /* @__PURE__ */ _("div", { className: `widget-palette ${e ? "widget-palette--locked" : ""}`, children: [
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
/* @__PURE__ */
|
|
427
|
-
e && /* @__PURE__ */
|
|
436
|
+
/* @__PURE__ */ l("label", { className: "widget-palette__label", children: t }),
|
|
437
|
+
/* @__PURE__ */ l(J, { selected: r, onSelect: n, customMode: !0, disabled: e }),
|
|
438
|
+
e && /* @__PURE__ */ l("span", { className: "widget-palette__lock-icon", title: "Bloqueado", children: "🔒" })
|
|
428
439
|
] });
|
|
429
440
|
}
|
|
430
|
-
function
|
|
431
|
-
type:
|
|
432
|
-
computed:
|
|
441
|
+
function Le({
|
|
442
|
+
type: a,
|
|
443
|
+
computed: r,
|
|
433
444
|
palette: n,
|
|
434
445
|
config: t,
|
|
435
446
|
filterValue: e,
|
|
436
447
|
filterOptions: i,
|
|
437
|
-
dateBounds:
|
|
438
|
-
onFilterChange:
|
|
448
|
+
dateBounds: c,
|
|
449
|
+
onFilterChange: s,
|
|
439
450
|
variableValue: m,
|
|
440
451
|
onVariableChange: o,
|
|
441
452
|
onPaletteChange: d
|
|
442
453
|
}) {
|
|
443
|
-
if (
|
|
444
|
-
return /* @__PURE__ */
|
|
445
|
-
const
|
|
446
|
-
switch (
|
|
454
|
+
if (r.error)
|
|
455
|
+
return /* @__PURE__ */ l("div", { className: "widget widget--error", children: /* @__PURE__ */ l("span", { className: "widget__error-text", children: String(r.error) }) });
|
|
456
|
+
const h = Z(n);
|
|
457
|
+
switch (a) {
|
|
447
458
|
case "kpi_card":
|
|
448
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ l(fe, { data: r, label: t == null ? void 0 : t.label });
|
|
449
460
|
case "gauge":
|
|
450
|
-
return /* @__PURE__ */
|
|
461
|
+
return /* @__PURE__ */ l(we, { data: r, palette: h, label: t == null ? void 0 : t.label });
|
|
451
462
|
case "chart":
|
|
452
|
-
return /* @__PURE__ */
|
|
463
|
+
return /* @__PURE__ */ l(ke, { data: r, palette: h, label: t == null ? void 0 : t.label });
|
|
453
464
|
case "filter":
|
|
454
|
-
return t &&
|
|
455
|
-
|
|
465
|
+
return t && s ? /* @__PURE__ */ l(
|
|
466
|
+
$e,
|
|
456
467
|
{
|
|
457
468
|
config: t,
|
|
458
469
|
value: e || "",
|
|
459
470
|
options: i,
|
|
460
|
-
dateBounds:
|
|
461
|
-
onChange:
|
|
471
|
+
dateBounds: c,
|
|
472
|
+
onChange: s
|
|
462
473
|
}
|
|
463
474
|
) : null;
|
|
464
475
|
case "variable": {
|
|
465
476
|
const u = t;
|
|
466
|
-
return u && o ? /* @__PURE__ */
|
|
467
|
-
|
|
477
|
+
return u && o ? /* @__PURE__ */ l(
|
|
478
|
+
Te,
|
|
468
479
|
{
|
|
469
480
|
config: u,
|
|
470
481
|
value: m ?? u.variableValue ?? 0,
|
|
@@ -473,8 +484,8 @@ function Ie({
|
|
|
473
484
|
) : null;
|
|
474
485
|
}
|
|
475
486
|
case "color_palette":
|
|
476
|
-
return t && d ? /* @__PURE__ */
|
|
477
|
-
|
|
487
|
+
return t && d ? /* @__PURE__ */ l(
|
|
488
|
+
Ie,
|
|
478
489
|
{
|
|
479
490
|
config: t,
|
|
480
491
|
palette: n,
|
|
@@ -484,56 +495,56 @@ function Ie({
|
|
|
484
495
|
default:
|
|
485
496
|
return /* @__PURE__ */ _("div", { className: "widget", children: [
|
|
486
497
|
"Widget: ",
|
|
487
|
-
|
|
498
|
+
a
|
|
488
499
|
] });
|
|
489
500
|
}
|
|
490
501
|
}
|
|
491
|
-
const
|
|
492
|
-
function
|
|
493
|
-
token:
|
|
494
|
-
rowHeight:
|
|
495
|
-
gridGap: n =
|
|
502
|
+
const Oe = 2.5, Ae = 0.375;
|
|
503
|
+
function Ye({
|
|
504
|
+
token: a,
|
|
505
|
+
rowHeight: r = Oe,
|
|
506
|
+
gridGap: n = Ae,
|
|
496
507
|
className: t
|
|
497
508
|
}) {
|
|
498
509
|
const {
|
|
499
510
|
layout: e,
|
|
500
511
|
renderData: i,
|
|
501
|
-
loading:
|
|
502
|
-
error:
|
|
512
|
+
loading: c,
|
|
513
|
+
error: s,
|
|
503
514
|
filters: m,
|
|
504
515
|
variables: o,
|
|
505
516
|
palette: d,
|
|
506
|
-
setFilter:
|
|
517
|
+
setFilter: h,
|
|
507
518
|
setVariable: u,
|
|
508
519
|
setPalette: w
|
|
509
|
-
} =
|
|
510
|
-
if (
|
|
511
|
-
return /* @__PURE__ */
|
|
520
|
+
} = pe(a);
|
|
521
|
+
if (s && !e)
|
|
522
|
+
return /* @__PURE__ */ l("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ l("div", { className: "preview-tab__error", children: s }) });
|
|
512
523
|
if (!e)
|
|
513
|
-
return /* @__PURE__ */
|
|
524
|
+
return /* @__PURE__ */ l("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ l("div", { className: "preview-tab__loading", children: "Carregando dashboard..." }) });
|
|
514
525
|
if (e.widgets.length === 0)
|
|
515
|
-
return /* @__PURE__ */
|
|
516
|
-
const
|
|
526
|
+
return /* @__PURE__ */ l("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ l("div", { className: "preview-tab__empty", children: "Este dashboard nao possui widgets." }) });
|
|
527
|
+
const g = (i == null ? void 0 : i.widgets) ?? {}, p = (i == null ? void 0 : i.date_bounds) ?? null, k = {
|
|
517
528
|
display: "grid",
|
|
518
529
|
gridTemplateColumns: `repeat(${e.gridColumns}, 1fr)`,
|
|
519
|
-
gridTemplateRows: `repeat(${e.gridRows}, ${
|
|
530
|
+
gridTemplateRows: `repeat(${e.gridRows}, ${r}rem)`,
|
|
520
531
|
gap: `${n}rem`,
|
|
521
|
-
...
|
|
532
|
+
...B(d)
|
|
522
533
|
};
|
|
523
534
|
return /* @__PURE__ */ _("div", { className: `preview-tab ${t ?? ""}`, children: [
|
|
524
|
-
|
|
525
|
-
i && /* @__PURE__ */
|
|
526
|
-
const
|
|
535
|
+
s && !i && /* @__PURE__ */ l("div", { className: "preview-tab__error", children: s }),
|
|
536
|
+
i && /* @__PURE__ */ l("div", { className: "preview-tab__grid", style: k, children: e.widgets.map((b) => {
|
|
537
|
+
const S = ee.has(b.type), y = g[b.id], C = {
|
|
527
538
|
gridColumn: `${b.grid.x + 1} / span ${b.grid.w}`,
|
|
528
539
|
gridRow: `${b.grid.y + 1} / span ${b.grid.h}`
|
|
529
540
|
}, v = b.type === "variable" ? o[b.id] ?? (y == null ? void 0 : y.value) ?? b.config.variableValue ?? 0 : void 0;
|
|
530
|
-
return /* @__PURE__ */
|
|
541
|
+
return /* @__PURE__ */ l(
|
|
531
542
|
"div",
|
|
532
543
|
{
|
|
533
|
-
className: `preview-tab__widget ${
|
|
534
|
-
style:
|
|
535
|
-
children:
|
|
536
|
-
|
|
544
|
+
className: `preview-tab__widget ${S ? "preview-tab__widget--control" : ""}`,
|
|
545
|
+
style: C,
|
|
546
|
+
children: S || y ? /* @__PURE__ */ l(
|
|
547
|
+
Le,
|
|
537
548
|
{
|
|
538
549
|
type: b.type,
|
|
539
550
|
computed: y || {},
|
|
@@ -542,21 +553,21 @@ function Pe({
|
|
|
542
553
|
filterValue: m[b.id] || "",
|
|
543
554
|
filterOptions: (y == null ? void 0 : y.available_values) || [],
|
|
544
555
|
dateBounds: p,
|
|
545
|
-
onFilterChange: (f) =>
|
|
556
|
+
onFilterChange: (f) => h(b.id, f),
|
|
546
557
|
variableValue: v,
|
|
547
558
|
onVariableChange: (f) => u(b.id, f),
|
|
548
559
|
onPaletteChange: w
|
|
549
560
|
}
|
|
550
|
-
) : /* @__PURE__ */
|
|
561
|
+
) : /* @__PURE__ */ l("div", { className: "preview-tab__widget-loading", children: c ? "Carregando..." : "Sem dados" })
|
|
551
562
|
},
|
|
552
563
|
b.id
|
|
553
564
|
);
|
|
554
565
|
}) }),
|
|
555
|
-
|
|
566
|
+
c && i && /* @__PURE__ */ l("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
|
|
556
567
|
] });
|
|
557
568
|
}
|
|
558
569
|
export {
|
|
559
|
-
|
|
560
|
-
|
|
570
|
+
je as ApiError,
|
|
571
|
+
Ye as Dashboard
|
|
561
572
|
};
|
|
562
573
|
//# sourceMappingURL=index.js.map
|