@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/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 { 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 j(l).then((f) => {
11
+ return G(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 = _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
- }, [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 _e(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 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
- 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(",") : 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 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__ */ 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 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 ${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 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 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 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__ */ 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: 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__ */ 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 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
- }, V = {
129
+ }, K = {
130
130
  color: "var(--text-primary)",
131
131
  fontWeight: 600
132
132
  };
133
- function K(l, a) {
133
+ function V(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 Ne(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(
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: V,
162
- labelFormatter: K,
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__ */ r(he, {}),
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 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: (() => {
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__ */ _(ee, { width: o, height: d, children: [
179
- /* @__PURE__ */ r(
180
- te,
178
+ return /* @__PURE__ */ _(te, { width: o, height: d, children: [
179
+ /* @__PURE__ */ l(
180
+ ae,
181
181
  {
182
- data: c,
183
- dataKey: ((w = s[0]) == null ? void 0 : w.key) || "s0",
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: h, percent: p }) => `${h}: ${(p * 100).toFixed(0)}%`,
188
+ label: ({ name: g, percent: p }) => `${g}: ${(p * 100).toFixed(0)}%`,
189
189
  labelLine: !1,
190
- children: c.map((h, p) => /* @__PURE__ */ r(ae, { fill: a[p % a.length] }, p))
190
+ children: s.map((g, p) => /* @__PURE__ */ l(re, { fill: r[p % r.length] }, p))
191
191
  }
192
192
  ),
193
- /* @__PURE__ */ r(
193
+ /* @__PURE__ */ l(
194
194
  P,
195
195
  {
196
196
  contentStyle: Y,
197
- labelStyle: V,
198
- labelFormatter: K
197
+ labelStyle: K,
198
+ labelFormatter: V
199
199
  }
200
200
  )
201
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,
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: h.key,
208
- name: h.label,
207
+ dataKey: g.key,
208
+ name: g.label,
209
209
  stroke: p,
210
210
  strokeWidth: 2,
211
- dot: c.length <= 31
211
+ dot: s.length <= 31
212
212
  },
213
- h.key
214
- ) }) : t === "area" ? /* @__PURE__ */ r(F, { ...u, Chart: ne, renderSeries: (h, p) => /* @__PURE__ */ r(
215
- ie,
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: h.key,
219
- name: h.label,
218
+ dataKey: g.key,
219
+ name: g.label,
220
220
  fill: p,
221
221
  stroke: p,
222
222
  fillOpacity: 0.3
223
223
  },
224
- h.key
225
- ) }) : /* @__PURE__ */ r(F, { ...u, Chart: se, renderSeries: (h, p) => /* @__PURE__ */ r(
226
- ce,
224
+ g.key
225
+ ) }) : /* @__PURE__ */ l(x, { ...u, Chart: ce, renderSeries: (g, p) => /* @__PURE__ */ l(
226
+ oe,
227
227
  {
228
- dataKey: h.key,
229
- name: h.label,
228
+ dataKey: g.key,
229
+ name: g.label,
230
230
  fill: p,
231
231
  radius: [3, 3, 0, 0]
232
232
  },
233
- h.key
233
+ g.key
234
234
  ) });
235
235
  })() })
236
- ] }) : /* @__PURE__ */ r("div", { className: "widget widget-chart widget-chart--empty", children: "Sem dados" });
236
+ ] }) : /* @__PURE__ */ l("div", { className: "widget widget-chart widget-chart--empty", children: "Sem dados" });
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 $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__ */ 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(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: 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 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__ */ r(
257
+ /* @__PURE__ */ l(
257
258
  L,
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
+ /* @__PURE__ */ l(
270
271
  L,
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,101 +282,111 @@ 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 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__ */ 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 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__ */ 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 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__ */ 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 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 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(",") : [], c = (s) => {
380
+ const m = i.includes(s) ? i.filter((o) => o !== s) : [...i, s];
381
+ e(m.join(","));
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(
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: e.includes(s),
378
- onChange: () => i(s)
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: l,
389
- onChange: (e) => t(e.target.value),
399
+ value: a,
400
+ onChange: (i) => e(i.target.value),
390
401
  children: [
391
- /* @__PURE__ */ r("option", { value: "", children: "Todos" }),
392
- a.map((e) => /* @__PURE__ */ r("option", { value: e, children: e }, e))
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 xe({ config: l, value: a, onChange: n }) {
402
- const t = l.label || "Variavel", e = l.locked || !1, i = l.variableFormat || "number", s = Fe[i] || "";
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__ */ r("label", { className: "widget-variable__label", children: t }),
415
+ /* @__PURE__ */ l("label", { className: "widget-variable__label", children: t }),
405
416
  /* @__PURE__ */ _("div", { className: "widget-variable__input-wrapper", children: [
406
- /* @__PURE__ */ r(
417
+ /* @__PURE__ */ l(
407
418
  "input",
408
419
  {
409
420
  className: "widget-variable__input",
410
421
  type: "number",
411
- value: a,
412
- onChange: (c) => n(parseFloat(c.target.value) || 0),
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
- s && /* @__PURE__ */ r("span", { className: "widget-variable__suffix", children: s })
428
+ c && /* @__PURE__ */ l("span", { className: "widget-variable__suffix", children: c })
418
429
  ] }),
419
- e && /* @__PURE__ */ r("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
430
+ e && /* @__PURE__ */ l("span", { className: "widget-variable__lock-icon", title: "Bloqueado", children: "🔒" })
420
431
  ] });
421
432
  }
422
- function Te({ config: l, palette: a, onChange: n }) {
423
- const t = l.label || "Cores", e = l.locked || !1;
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__ */ 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: "🔒" })
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 Ie({
431
- type: l,
432
- computed: a,
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: s,
438
- onFilterChange: c,
448
+ dateBounds: c,
449
+ onFilterChange: s,
439
450
  variableValue: m,
440
451
  onVariableChange: o,
441
452
  onPaletteChange: d
442
453
  }) {
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) {
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__ */ r(be, { data: a, label: t == null ? void 0 : t.label });
459
+ return /* @__PURE__ */ l(fe, { data: r, label: t == null ? void 0 : t.label });
449
460
  case "gauge":
450
- return /* @__PURE__ */ r(ve, { data: a, palette: g, label: t == null ? void 0 : t.label });
461
+ return /* @__PURE__ */ l(we, { data: r, palette: h, label: t == null ? void 0 : t.label });
451
462
  case "chart":
452
- return /* @__PURE__ */ r(Ne, { data: a, palette: g, label: t == null ? void 0 : t.label });
463
+ return /* @__PURE__ */ l(ke, { data: r, palette: h, label: t == null ? void 0 : t.label });
453
464
  case "filter":
454
- return t && c ? /* @__PURE__ */ r(
455
- ke,
465
+ return t && s ? /* @__PURE__ */ l(
466
+ $e,
456
467
  {
457
468
  config: t,
458
469
  value: e || "",
459
470
  options: i,
460
- dateBounds: s,
461
- onChange: c
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__ */ r(
467
- xe,
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__ */ r(
477
- Te,
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
- l
498
+ a
488
499
  ] });
489
500
  }
490
501
  }
491
- const Le = 2.5, Oe = 0.375;
492
- function Pe({
493
- token: l,
494
- rowHeight: a = Le,
495
- gridGap: n = Oe,
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: s,
502
- error: c,
512
+ loading: c,
513
+ error: s,
503
514
  filters: m,
504
515
  variables: o,
505
516
  palette: d,
506
- setFilter: g,
517
+ setFilter: h,
507
518
  setVariable: u,
508
519
  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 }) });
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__ */ r("div", { className: `preview-tab ${t ?? ""}`, children: /* @__PURE__ */ r("div", { className: "preview-tab__loading", children: "Carregando dashboard..." }) });
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__ */ 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 = {
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}, ${a}rem)`,
530
+ gridTemplateRows: `repeat(${e.gridRows}, ${r}rem)`,
520
531
  gap: `${n}rem`,
521
- ...Z(d)
532
+ ...B(d)
522
533
  };
523
534
  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 = {
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__ */ r(
541
+ return /* @__PURE__ */ l(
531
542
  "div",
532
543
  {
533
- className: `preview-tab__widget ${C ? "preview-tab__widget--control" : ""}`,
534
- style: S,
535
- children: C || y ? /* @__PURE__ */ r(
536
- Ie,
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) => g(b.id, 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__ */ r("div", { className: "preview-tab__widget-loading", children: s ? "Carregando..." : "Sem dados" })
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
- s && i && /* @__PURE__ */ r("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
566
+ c && i && /* @__PURE__ */ l("div", { className: "preview-tab__recalculating", children: "Atualizando..." })
556
567
  ] });
557
568
  }
558
569
  export {
559
- Ke as ApiError,
560
- Pe as Dashboard
570
+ je as ApiError,
571
+ Ye as Dashboard
561
572
  };
562
573
  //# sourceMappingURL=index.js.map