@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/index.js CHANGED
@@ -1,264 +1,265 @@
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-CxUAEQYp.js";
4
- import { Q as Ke } from "./index-CxUAEQYp.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);
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 j(l).then((f) => {
11
+ return z(a).then((f) => {
12
12
  v || n(f);
13
13
  }).catch((f) => {
14
- v || h(f.message);
14
+ v || g(f.message);
15
15
  }), () => {
16
16
  v = !0;
17
17
  };
18
- }, [l]), T(() => {
19
- if (a)
18
+ }, [a]), T(() => {
19
+ if (r)
20
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), () => {
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
- }, [l, a, i, c]);
28
+ }, [a, r, i, s]);
29
29
  const b = M((v, f) => {
30
- s(($) => ({ ...$, [v]: f }));
31
- }, []), C = M((v, f) => {
30
+ c(($) => ({ ...$, [v]: f }));
31
+ }, []), S = M((v, f) => {
32
32
  m(($) => ({ ...$, [v]: f }));
33
33
  }, []), y = M((v) => {
34
34
  d(v);
35
- }, []), S = G(
36
- () => o ?? (a == null ? void 0 : a.palette) ?? [],
37
- [o, a]
35
+ }, []), C = j(
36
+ () => o ?? (r == null ? void 0 : r.palette) ?? [],
37
+ [o, r]
38
38
  );
39
39
  return {
40
- layout: a,
40
+ layout: r,
41
41
  renderData: t,
42
- loading: g,
42
+ loading: h,
43
43
  error: w,
44
44
  filters: i,
45
- variables: c,
46
- palette: S,
45
+ variables: s,
46
+ palette: C,
47
47
  setFilter: b,
48
- setVariable: C,
48
+ setVariable: S,
49
49
  setPalette: y
50
50
  };
51
51
  }
52
- function pe(l, a) {
52
+ function be(a, r) {
53
53
  const n = {};
54
- for (const [t, e] of Object.entries(l))
54
+ for (const [t, e] of Object.entries(a))
55
55
  if (e.includes("|")) {
56
- const [i, s] = e.split("|");
57
- i && (n.f_date_start = i), s && (n.f_date_end = s);
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(a))
60
+ for (const [t, e] of Object.entries(r))
61
61
  n[`v_${t}`] = String(e);
62
62
  return n;
63
63
  }
64
- function _e(l) {
65
- const a = {};
66
- for (const [n, t] of Object.entries(l))
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
- a[n] = `${e.start || ""}|${e.end || ""}`;
70
- } else Array.isArray(t) ? a[n] = t.join(",") : typeof t == "string" && (a[n] = t);
71
- return a;
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 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" ? "↓" : "";
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__ */ r("span", { className: "widget-kpi__label", children: n }),
77
- /* @__PURE__ */ r("span", { className: "widget-kpi__value", children: t }),
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
- s,
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__ */ r("span", { className: "widget-kpi__trend-label", children: e.label })
86
+ e.label && /* @__PURE__ */ l("span", { className: "widget-kpi__trend-label", children: e.label })
87
87
  ] })
88
88
  ] });
89
89
  }
90
- const fe = "var(--bg-elevated)";
91
- function O(l, a, n, t) {
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 ${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}`;
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(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");
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 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;
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__ */ r("span", { className: "widget-gauge__label", children: t }),
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__ */ 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" })
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__ */ r("span", { className: "widget-gauge__percent", children: s }),
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__ */ r("span", { className: "widget-gauge__badge", children: o || "Meta batida" }),
119
- !d && o && /* @__PURE__ */ r("span", { className: "widget-gauge__comparison", children: o })
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)" }, we = "var(--bg-elevated)", Y = {
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
- }, V = {
129
+ }, K = {
130
130
  color: "var(--text-primary)",
131
131
  fontWeight: 600
132
132
  };
133
- function K(l, a) {
133
+ function G(a, r) {
134
134
  var e;
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 ?? "");
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 ye(l) {
139
- const [a, n] = N({ width: 0, height: 0 });
138
+ function ke(a) {
139
+ const [r, n] = N({ width: 0, height: 0 });
140
140
  return T(() => {
141
- const t = l.current;
141
+ const t = a.current;
142
142
  if (!t) return;
143
143
  const e = new ResizeObserver(([i]) => {
144
- const { width: s, height: c } = i.contentRect;
144
+ const { width: c, height: s } = i.contentRect;
145
145
  n(
146
- (m) => m.width !== Math.floor(s) || m.height !== Math.floor(c) ? { width: Math.floor(s), height: Math.floor(c) } : m
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
- }, [l]), a;
150
+ }, [a]), r;
151
151
  }
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,
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: Y,
161
- labelStyle: V,
162
- labelFormatter: K,
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__ */ r(he, {}),
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 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);
172
- return c.length ? /* @__PURE__ */ _("div", { className: "widget widget-chart", children: [
173
- e && /* @__PURE__ */ r("h4", { className: "widget-chart__title", children: e }),
174
- /* @__PURE__ */ r("div", { ref: m, className: "widget-chart__container", children: (() => {
175
- var w;
176
- if (o <= 0 || d <= 0) return null;
177
- if (t === "pie")
178
- return /* @__PURE__ */ _(ee, { width: o, height: d, children: [
179
- /* @__PURE__ */ r(
180
- te,
181
- {
182
- data: c,
183
- dataKey: ((w = s[0]) == null ? void 0 : w.key) || "s0",
184
- nameKey: i,
185
- cx: "50%",
186
- cy: "50%",
187
- outerRadius: "75%",
188
- label: ({ name: h, percent: p }) => `${h}: ${(p * 100).toFixed(0)}%`,
189
- labelLine: !1,
190
- children: c.map((h, p) => /* @__PURE__ */ r(ae, { fill: a[p % a.length] }, p))
191
- }
192
- ),
193
- /* @__PURE__ */ r(
194
- P,
195
- {
196
- contentStyle: Y,
197
- labelStyle: V,
198
- labelFormatter: K
199
- }
200
- )
201
- ] });
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,
205
- {
206
- type: "monotone",
207
- dataKey: h.key,
208
- name: h.label,
209
- stroke: p,
210
- strokeWidth: 2,
211
- dot: c.length <= 31
212
- },
213
- h.key
214
- ) }) : t === "area" ? /* @__PURE__ */ r(F, { ...u, Chart: ne, renderSeries: (h, p) => /* @__PURE__ */ r(
215
- ie,
216
- {
217
- type: "monotone",
218
- dataKey: h.key,
219
- name: h.label,
220
- fill: p,
221
- stroke: p,
222
- fillOpacity: 0.3
223
- },
224
- h.key
225
- ) }) : /* @__PURE__ */ r(F, { ...u, Chart: se, renderSeries: (h, p) => /* @__PURE__ */ r(
226
- ce,
227
- {
228
- dataKey: h.key,
229
- name: h.label,
230
- fill: p,
231
- radius: [3, 3, 0, 0]
232
- },
233
- h.key
234
- ) });
235
- })() })
236
- ] }) : /* @__PURE__ */ r("div", { className: "widget widget-chart widget-chart--empty", children: "Sem dados" });
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 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";
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__ */ 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,
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: a,
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 $e({ value: l, dateBounds: a, onChange: n }) {
254
- const [t, e] = l ? l.split("|") : ["", ""];
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__ */ r(
257
- L,
257
+ /* @__PURE__ */ l(
258
+ A,
258
259
  {
259
260
  value: t,
260
- minIso: a == null ? void 0 : a.min,
261
- maxIso: e || (a == null ? void 0 : a.max),
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__ */ r(
270
- L,
270
+ /* @__PURE__ */ l(
271
+ A,
271
272
  {
272
273
  value: e,
273
- minIso: t || (a == null ? void 0 : a.min),
274
- maxIso: a == null ? void 0 : a.max,
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 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);
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__ */ r("div", { className: "widget-filter__date-range widget-filter__date-range--year", children: /* @__PURE__ */ r(
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: s,
294
+ value: c,
294
295
  onChange: (o) => m(parseInt(o.target.value)),
295
- children: c.map((o) => /* @__PURE__ */ r("option", { value: o, children: o }, o))
296
+ children: s.map((o) => /* @__PURE__ */ l("option", { value: o, children: o }, o))
296
297
  }
297
298
  ) });
298
299
  }
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);
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__ */ r(
306
+ /* @__PURE__ */ l(
306
307
  "select",
307
308
  {
308
309
  className: "widget-filter__select",
309
- value: c,
310
- onChange: (d) => o(s, parseInt(d.target.value)),
311
- children: D.map((d, g) => /* @__PURE__ */ r("option", { value: g + 1, children: d }, g + 1))
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__ */ r(
315
+ /* @__PURE__ */ l(
315
316
  "select",
316
317
  {
317
318
  className: "widget-filter__select",
318
- value: s,
319
- onChange: (d) => o(parseInt(d.target.value), c),
320
- children: m.map((d) => /* @__PURE__ */ r("option", { value: d, children: d }, d))
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 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;
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__ */ r(
329
+ /* @__PURE__ */ l(
329
330
  "select",
330
331
  {
331
332
  className: "widget-filter__select",
332
- value: s,
333
- onChange: (g) => {
334
- const u = parseInt(g.target.value), h = R(u, c)[0];
335
- h && n(`${h.start}|${h.end}`);
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((g) => /* @__PURE__ */ r("option", { value: g, children: g }, g))
338
+ children: m.map((h) => /* @__PURE__ */ l("option", { value: h, children: h }, h))
338
339
  }
339
340
  ),
340
- /* @__PURE__ */ r(
341
+ /* @__PURE__ */ l(
341
342
  "select",
342
343
  {
343
344
  className: "widget-filter__select",
344
- value: c,
345
- onChange: (g) => {
346
- const u = parseInt(g.target.value), h = R(s, u)[0];
347
- h && n(`${h.start}|${h.end}`);
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((g, u) => /* @__PURE__ */ r("option", { value: u + 1, children: g }, u + 1))
350
+ children: D.map((h, u) => /* @__PURE__ */ l("option", { value: u + 1, children: h }, u + 1))
350
351
  }
351
352
  ),
352
- /* @__PURE__ */ r(
353
+ /* @__PURE__ */ l(
353
354
  "select",
354
355
  {
355
356
  className: "widget-filter__select",
356
357
  value: d,
357
- onChange: (g) => {
358
- const u = o[parseInt(g.target.value) - 1];
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((g) => /* @__PURE__ */ r("option", { value: g.index, children: g.label }, g.index))
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 Re({ value: l, options: a, multi: n, onChange: t }) {
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 e = l ? l.split(",") : [], i = (s) => {
369
- const c = e.includes(s) ? e.filter((m) => m !== s) : [...e, s];
370
- t(c.join(","));
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__ */ r("div", { className: "widget-filter__multi", children: a.map((s) => /* @__PURE__ */ _("label", { className: "widget-filter__multi-option", children: [
373
- /* @__PURE__ */ r(
374
- "input",
383
+ return /* @__PURE__ */ _("div", { className: "widget-filter__multi", children: [
384
+ i.length > 0 && /* @__PURE__ */ l(
385
+ "button",
375
386
  {
376
- type: "checkbox",
377
- checked: e.includes(s),
378
- onChange: () => i(s)
387
+ type: "button",
388
+ className: "widget-filter__multi-clear",
389
+ onClick: () => e(""),
390
+ children: "Limpar filtro"
379
391
  }
380
392
  ),
381
- s
382
- ] }, s)) });
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: l,
389
- onChange: (e) => t(e.target.value),
410
+ value: a,
411
+ onChange: (i) => e(i.target.value),
390
412
  children: [
391
- /* @__PURE__ */ r("option", { value: "", children: "Todos" }),
392
- a.map((e) => /* @__PURE__ */ r("option", { value: e, children: e }, e))
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 Fe = {
419
+ const Te = {
398
420
  currency: "R$",
399
421
  percentage: "%"
400
422
  };
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] || "";
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__ */ r("label", { className: "widget-variable__label", children: t }),
426
+ /* @__PURE__ */ l("label", { className: "widget-variable__label", children: t }),
405
427
  /* @__PURE__ */ _("div", { className: "widget-variable__input-wrapper", children: [
406
- /* @__PURE__ */ r(
428
+ /* @__PURE__ */ l(
407
429
  "input",
408
430
  {
409
431
  className: "widget-variable__input",
410
432
  type: "number",
411
- value: a,
412
- onChange: (c) => n(parseFloat(c.target.value) || 0),
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
- s && /* @__PURE__ */ r("span", { className: "widget-variable__suffix", children: s })
439
+ c && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: c })
418
440
  ] }),
419
- e && /* @__PURE__ */ r("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
441
+ e && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
420
442
  ] });
421
443
  }
422
- function Te({ config: l, palette: a, onChange: n }) {
423
- const t = l.label || "Cores", e = l.locked || !1;
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__ */ 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: "🔒" })
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 Ie({
431
- type: l,
432
- computed: a,
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: s,
438
- onFilterChange: c,
459
+ dateBounds: c,
460
+ onFilterChange: s,
439
461
  variableValue: m,
440
462
  onVariableChange: o,
441
463
  onPaletteChange: d
442
464
  }) {
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) {
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__ */ r(be, { data: a, label: t == null ? void 0 : t.label });
470
+ return /* @__PURE__ */ l(ve, { data: r, label: t == null ? void 0 : t.label });
449
471
  case "gauge":
450
- return /* @__PURE__ */ r(ve, { data: a, palette: g, label: t == null ? void 0 : t.label });
472
+ return /* @__PURE__ */ l(ye, { data: r, palette: h, label: t == null ? void 0 : t.label });
451
473
  case "chart":
452
- return /* @__PURE__ */ r(Ne, { data: a, palette: g, label: t == null ? void 0 : t.label });
474
+ return /* @__PURE__ */ l($e, { data: r, palette: h, label: t == null ? void 0 : t.label });
453
475
  case "filter":
454
- return t && c ? /* @__PURE__ */ r(
455
- ke,
476
+ return t && s ? /* @__PURE__ */ l(
477
+ Se,
456
478
  {
457
479
  config: t,
458
480
  value: e || "",
459
481
  options: i,
460
- dateBounds: s,
461
- onChange: c
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__ */ r(
467
- xe,
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__ */ r(
477
- Te,
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
- l
509
+ a
488
510
  ] });
489
511
  }
490
512
  }
491
- const Le = 2.5, Oe = 0.375;
492
- function Pe({
493
- token: l,
494
- rowHeight: a = Le,
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: s,
502
- error: c,
523
+ loading: c,
524
+ error: s,
503
525
  filters: m,
504
526
  variables: o,
505
527
  palette: d,
506
- setFilter: g,
528
+ setFilter: h,
507
529
  setVariable: u,
508
530
  setPalette: w
509
- } = me(l);
510
- if (c && !e)
511
- return /* @__PURE__ */ r("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ r("div", { className: "preview-tab__error", children: c }) });
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__ */ r("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." }) });
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__ */ 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 = {
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}, ${a}rem)`,
541
+ gridTemplateRows: `repeat(${e.gridRows}, ${r}rem)`,
520
542
  gap: `${n}rem`,
521
- ...Z(d)
543
+ ...ee(d)
522
544
  };
523
545
  return /* @__PURE__ */ _("div", { className: `preview-tab ${t ?? ""}`, children: [
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 = {
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__ */ r(
552
+ return /* @__PURE__ */ l(
531
553
  "div",
532
554
  {
533
- className: `preview-tab__widget ${C ? "preview-tab__widget--control" : ""}`,
534
- style: S,
535
- children: C || y ? /* @__PURE__ */ r(
536
- Ie,
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) => g(b.id, 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__ */ r("div", { className: "preview-tab__widget-loading", children: s ? "Carregando..." : "Sem dados" })
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
- s && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
577
+ c && i && /* @__PURE__ */ l("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
556
578
  ] });
557
579
  }
558
580
  export {
559
- Ke as ApiError,
560
- Pe as Dashboard
581
+ je as ApiError,
582
+ Ve as Dashboard
561
583
  };
562
584
  //# sourceMappingURL=index.js.map