@actionexec/dashboards 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,603 +0,0 @@
1
- import { jsx as l, jsxs as h } from "react/jsx-runtime";
2
- import C from "react-datepicker";
3
- import { useState as N, useRef as P, useMemo as w, useEffect as $ } from "react";
4
- const k = "https://action-data-api-7mbrztperq-rj.a.run.app", R = "/external/dashboards";
5
- let v = k;
6
- function X(e) {
7
- v = e.replace(/\/$/, "");
8
- }
9
- class F extends Error {
10
- constructor(t, r, a) {
11
- super(t), this.status = r, this.payload = a, this.name = "ApiError";
12
- }
13
- }
14
- async function L(e, t, r) {
15
- const a = new URL(`${v}${R}${e}`);
16
- if (r)
17
- for (const [n, i] of Object.entries(r)) a.searchParams.set(n, i);
18
- const s = await fetch(a.toString(), {
19
- headers: { Authorization: `Bearer ${t}` }
20
- });
21
- if (!s.ok) {
22
- let n;
23
- try {
24
- n = await s.json();
25
- } catch {
26
- }
27
- throw new F(
28
- `Requisicao falhou (${s.status}) em ${e}`,
29
- s.status,
30
- n
31
- );
32
- }
33
- return await s.json();
34
- }
35
- const Z = (e) => L("/layout", e), ee = (e, t) => L("/render", e, t), d = {
36
- series0: 0,
37
- series1: 1,
38
- series2: 2,
39
- series3: 3,
40
- series4: 4,
41
- bgDark: 5,
42
- bgPaper: 6,
43
- bgElevated: 7,
44
- textPrimary: 8,
45
- textMuted: 9,
46
- accent: 10,
47
- success: 11,
48
- error: 12
49
- }, I = 5, E = 13, U = {
50
- series0: "Série 1",
51
- series1: "Série 2",
52
- series2: "Série 3",
53
- series3: "Série 4",
54
- series4: "Série 5",
55
- bgDark: "Fundo Escuro",
56
- bgPaper: "Fundo Cartão",
57
- bgElevated: "Fundo Elevado",
58
- textPrimary: "Texto Primário",
59
- textMuted: "Texto Secundário",
60
- accent: "Destaque",
61
- success: "Sucesso",
62
- error: "Erro"
63
- }, y = {
64
- action: {
65
- label: "Action",
66
- colors: [
67
- "#ff6b00",
68
- "#a3e635",
69
- "#e3f544",
70
- "#65ffd1",
71
- "#ff0404",
72
- "#1a1a1a",
73
- "#262626",
74
- "#333333",
75
- "#f5f5f5",
76
- "#999999",
77
- "#ff6b00",
78
- "#a3e635",
79
- "#ef4444"
80
- ]
81
- },
82
- westCoast: {
83
- label: "West Coast",
84
- colors: [
85
- "#a3b86c",
86
- "#c89b3c",
87
- "#8b6f47",
88
- "#6b8e23",
89
- "#d2691e",
90
- "#1f1a14",
91
- "#2a241b",
92
- "#3a3225",
93
- "#e8dcc4",
94
- "#a89878",
95
- "#c89b3c",
96
- "#a3b86c",
97
- "#c44536"
98
- ]
99
- },
100
- mono: {
101
- label: "Monocromático",
102
- colors: [
103
- "#f8fafc",
104
- "#cbd5e1",
105
- "#94a3b8",
106
- "#64748b",
107
- "#475569",
108
- "#0a0a0a",
109
- "#171717",
110
- "#262626",
111
- "#fafafa",
112
- "#a3a3a3",
113
- "#e5e5e5",
114
- "#cbd5e1",
115
- "#ef4444"
116
- ]
117
- },
118
- ocean: {
119
- label: "Ocean",
120
- colors: [
121
- "#0ea5e9",
122
- "#06b6d4",
123
- "#0891b2",
124
- "#3b82f6",
125
- "#22d3ee",
126
- "#0a1929",
127
- "#0f2740",
128
- "#173554",
129
- "#e0f2fe",
130
- "#7dd3fc",
131
- "#22d3ee",
132
- "#10b981",
133
- "#f43f5e"
134
- ]
135
- },
136
- princess: {
137
- label: "Cute Pink",
138
- colors: [
139
- "#ff79bc",
140
- "#a855f7",
141
- "#f472b6",
142
- "#d946ef",
143
- "#fb7185",
144
- "#fff0f6",
145
- "#ffe4ec",
146
- "#ffffff",
147
- "#ff4099",
148
- "#ffadd5",
149
- "#ec4899",
150
- "#10b981",
151
- "#e11d48"
152
- ]
153
- }
154
- }, M = y.action.colors;
155
- function D(e) {
156
- const t = M;
157
- if (!e || e.length === 0) return [...t];
158
- if (e.length >= E) return e.slice(0, E);
159
- const r = [...e];
160
- for (let a = e.length; a < E; a++) r.push(t[a]);
161
- return r;
162
- }
163
- function Y(e) {
164
- return D(e).slice(0, I);
165
- }
166
- function te(e) {
167
- const t = D(e);
168
- return {
169
- "--bg-dark": t[d.bgDark],
170
- "--bg-paper": t[d.bgPaper],
171
- "--bg-elevated": t[d.bgElevated],
172
- "--text-primary": t[d.textPrimary],
173
- "--text-secondary": t[d.textMuted],
174
- "--text-muted": t[d.textMuted],
175
- "--action-orange": t[d.accent],
176
- "--action-green": t[d.success],
177
- "--color-success": t[d.success],
178
- "--color-error": t[d.error],
179
- "--color-info": t[d.series2],
180
- "--color-warning": t[d.series3]
181
- };
182
- }
183
- const ae = [
184
- "Jan",
185
- "Fev",
186
- "Mar",
187
- "Abr",
188
- "Mai",
189
- "Jun",
190
- "Jul",
191
- "Ago",
192
- "Set",
193
- "Out",
194
- "Nov",
195
- "Dez"
196
- ], re = [
197
- "Janeiro",
198
- "Fevereiro",
199
- "Marco",
200
- "Abril",
201
- "Maio",
202
- "Junho",
203
- "Julho",
204
- "Agosto",
205
- "Setembro",
206
- "Outubro",
207
- "Novembro",
208
- "Dezembro"
209
- ];
210
- function se(e) {
211
- return { start: `${e}-01-01`, end: `${e}-12-31` };
212
- }
213
- function ne(e) {
214
- if (!e) return null;
215
- const t = e.match(/^(\d{4})/);
216
- return t ? { year: parseInt(t[1]) } : null;
217
- }
218
- function oe(e, t) {
219
- const r = new Date(e, t, 0).getDate(), a = (s) => String(s).padStart(2, "0");
220
- return {
221
- start: `${e}-${a(t)}-01`,
222
- end: `${e}-${a(t)}-${a(r)}`
223
- };
224
- }
225
- function x(e) {
226
- const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()));
227
- t.setUTCDate(t.getUTCDate() + 4 - (t.getUTCDay() || 7));
228
- const r = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
229
- return Math.ceil(((t.getTime() - r.getTime()) / 864e5 + 1) / 7);
230
- }
231
- function ce(e, t) {
232
- const r = new Date(e, 0, 4), a = (r.getDay() + 6) % 7, s = new Date(r.getTime() - a * 864e5), n = new Date(s.getTime() + (t - 1) * 7 * 864e5), i = new Date(n.getTime() + 6 * 864e5), f = (g) => String(g).padStart(2, "0"), p = (g) => `${g.getFullYear()}-${f(g.getMonth() + 1)}-${f(g.getDate())}`;
233
- return { start: p(n), end: p(i) };
234
- }
235
- function le(e, t) {
236
- const r = /* @__PURE__ */ new Set(), a = new Date(e, t, 0).getDate();
237
- for (let s = 1; s <= a; s++)
238
- r.add(x(new Date(e, t - 1, s)));
239
- return Array.from(r).sort((s, n) => s - n);
240
- }
241
- function ie(e, t) {
242
- const r = new Date(e, t, 0).getDate(), a = (f) => String(f).padStart(2, "0"), s = [];
243
- let n = 1, i = 1;
244
- for (; n <= r; ) {
245
- const f = n, p = Math.min(n + 6, r), g = `${e}-${a(t)}-${a(f)}`, o = `${e}-${a(t)}-${a(p)}`, u = `${i}° Semana (${a(f)}/${a(t)} - ${a(p)}/${a(t)})`;
246
- s.push({ index: i, startDay: f, endDay: p, start: g, end: o, label: u }), n = p + 1, i++;
247
- }
248
- return s;
249
- }
250
- function ue(e, t, r) {
251
- if (!e) return 1;
252
- const a = (i) => String(i).padStart(2, "0"), s = e.match(new RegExp(`^${t}-${a(r)}-(\\d{2})`));
253
- if (!s) return 1;
254
- const n = parseInt(s[1]);
255
- return Math.ceil(n / 7);
256
- }
257
- function de(e) {
258
- if (!e) return null;
259
- const t = e.match(/^(\d{4})-(\d{2})/);
260
- return t ? { year: parseInt(t[1]), month: parseInt(t[2]) } : null;
261
- }
262
- function fe(e) {
263
- if (!e) return null;
264
- const t = /* @__PURE__ */ new Date(e + "T00:00:00");
265
- return isNaN(t.getTime()) ? null : { year: t.getFullYear(), week: x(t) };
266
- }
267
- function ge(e) {
268
- const t = /* @__PURE__ */ new Date(), r = e != null && e.min ? parseInt(e.min.slice(0, 4)) : t.getFullYear() - 2, a = e != null && e.max ? parseInt(e.max.slice(0, 4)) : t.getFullYear(), s = [];
269
- for (let n = a; n >= r; n--) s.push(n);
270
- return s;
271
- }
272
- function T(e) {
273
- if (!e) return null;
274
- const [t, r, a] = e.split("-").map(Number);
275
- return !t || !r || !a ? null : new Date(t, r - 1, a);
276
- }
277
- function G(e) {
278
- if (!e) return "";
279
- const t = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
280
- return `${t}-${r}-${a}`;
281
- }
282
- function pe({
283
- value: e,
284
- onChange: t,
285
- minIso: r,
286
- maxIso: a,
287
- placeholder: s,
288
- selectsStart: n,
289
- selectsEnd: i,
290
- startIso: f,
291
- endIso: p,
292
- className: g,
293
- disabled: o
294
- }) {
295
- return /* @__PURE__ */ l("div", { className: `ddp-field ${g ?? ""}`, children: /* @__PURE__ */ l(
296
- C,
297
- {
298
- selected: T(e),
299
- onChange: (u) => t(G(u)),
300
- selectsStart: n,
301
- selectsEnd: i,
302
- startDate: T(f) ?? void 0,
303
- endDate: T(p) ?? void 0,
304
- minDate: T(r) ?? void 0,
305
- maxDate: T(a) ?? void 0,
306
- dateFormat: "dd/MM/yyyy",
307
- placeholderText: s ?? "Selecione...",
308
- disabled: o,
309
- portalId: "ddp-portal",
310
- popperPlacement: "bottom-start",
311
- popperModifiers: [
312
- {
313
- name: "flip",
314
- options: { fallbackPlacements: ["bottom-end", "top-start", "top-end"] },
315
- fn: (u) => u
316
- }
317
- ]
318
- }
319
- ) });
320
- }
321
- function me({ options: e, value: t, multi: r, onChange: a, placeholder: s }) {
322
- const [n, i] = N(!1), [f, p] = N(""), g = P(null), o = w(
323
- () => t ? t.split(",").filter(Boolean) : [],
324
- [t]
325
- ), u = w(() => {
326
- const c = f.trim().toLowerCase();
327
- return c ? e.filter((S) => S.toLowerCase().includes(c)) : e;
328
- }, [e, f]);
329
- $(() => {
330
- if (!n) return;
331
- const c = (S) => {
332
- g.current && !g.current.contains(S.target) && i(!1);
333
- };
334
- return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
335
- }, [n]);
336
- const m = (c) => {
337
- a(c), p(""), i(!1);
338
- }, b = (c) => {
339
- const S = o.includes(c) ? o.filter((A) => A !== c) : [...o, c];
340
- a(S.join(","));
341
- }, _ = r ? o.length > 0 : !!t, O = r ? o.length > 0 ? `${o.length} selecionado(s)` : s || "Todos" : t || s || "Todos";
342
- return /* @__PURE__ */ h("div", { ref: g, className: "widget-filter__search", children: [
343
- /* @__PURE__ */ h(
344
- "button",
345
- {
346
- type: "button",
347
- className: "widget-filter__search-trigger",
348
- onClick: () => i((c) => !c),
349
- children: [
350
- /* @__PURE__ */ l("span", { className: `widget-filter__search-value${_ ? "" : " is-placeholder"}`, children: O }),
351
- /* @__PURE__ */ l("span", { className: "widget-filter__search-caret", "aria-hidden": !0, children: "▾" })
352
- ]
353
- }
354
- ),
355
- n && /* @__PURE__ */ h("div", { className: "widget-filter__search-panel", children: [
356
- /* @__PURE__ */ l(
357
- "input",
358
- {
359
- type: "text",
360
- className: "widget-filter__search-input",
361
- autoFocus: !0,
362
- value: f,
363
- placeholder: "Buscar...",
364
- onChange: (c) => p(c.target.value)
365
- }
366
- ),
367
- /* @__PURE__ */ h("div", { className: "widget-filter__search-list", children: [
368
- !r && /* @__PURE__ */ l(
369
- "button",
370
- {
371
- type: "button",
372
- className: `widget-filter__search-option${t ? "" : " is-selected"}`,
373
- onClick: () => m(""),
374
- children: "Todos"
375
- }
376
- ),
377
- u.length === 0 ? /* @__PURE__ */ l("span", { className: "widget-filter__search-empty", children: "Nenhuma opção" }) : u.map(
378
- (c) => r ? /* @__PURE__ */ h("label", { className: "widget-filter__search-option", children: [
379
- /* @__PURE__ */ l(
380
- "input",
381
- {
382
- type: "checkbox",
383
- checked: o.includes(c),
384
- onChange: () => b(c)
385
- }
386
- ),
387
- c
388
- ] }, c) : /* @__PURE__ */ l(
389
- "button",
390
- {
391
- type: "button",
392
- className: `widget-filter__search-option${t === c ? " is-selected" : ""}`,
393
- onClick: () => m(c),
394
- children: c
395
- },
396
- c
397
- )
398
- )
399
- ] })
400
- ] })
401
- ] });
402
- }
403
- const W = [
404
- d.bgDark,
405
- d.bgPaper,
406
- d.bgElevated,
407
- d.accent,
408
- d.success
409
- ];
410
- function j(e) {
411
- if (!e) return !0;
412
- const t = D(e);
413
- return Object.values(y).some(
414
- (r) => JSON.stringify(r.colors) === JSON.stringify(t)
415
- );
416
- }
417
- const J = [
418
- { label: "Series", slots: ["series0", "series1", "series2", "series3", "series4"] },
419
- { label: "Tema", slots: ["bgDark", "bgPaper", "bgElevated", "textPrimary", "textMuted"] },
420
- { label: "Estados", slots: ["accent", "success", "error"] }
421
- ];
422
- function he({
423
- selected: e,
424
- onSelect: t,
425
- customMode: r,
426
- onCustomModeChange: a,
427
- disabled: s
428
- }) {
429
- var g;
430
- const n = r ?? !j(e), i = D(e), f = n || (g = Object.entries(y).find(
431
- ([, o]) => JSON.stringify(o.colors) === JSON.stringify(i)
432
- )) == null ? void 0 : g[0], p = (o, u) => {
433
- const m = [...i];
434
- for (; m.length < E; ) m.push("#000000");
435
- m[o] = u, t(m);
436
- };
437
- return /* @__PURE__ */ h("div", { className: `palette-selector ${s ? "palette-selector--disabled" : ""}`, children: [
438
- a && /* @__PURE__ */ h("label", { className: "config-panel__checkbox", children: [
439
- /* @__PURE__ */ l(
440
- "input",
441
- {
442
- type: "checkbox",
443
- checked: n,
444
- onChange: (o) => a(o.target.checked),
445
- disabled: s
446
- }
447
- ),
448
- "Customizar"
449
- ] }),
450
- n ? /* @__PURE__ */ l("div", { className: "palette-selector__custom", children: J.map((o) => /* @__PURE__ */ h("div", { className: "palette-selector__row", children: [
451
- /* @__PURE__ */ l("span", { className: "palette-selector__row-label", children: o.label }),
452
- /* @__PURE__ */ l("div", { className: "palette-selector__row-slots", children: o.slots.map((u) => {
453
- const m = d[u];
454
- return /* @__PURE__ */ l(
455
- "input",
456
- {
457
- type: "color",
458
- className: "palette-selector__color-input",
459
- value: i[m] || "#000000",
460
- onChange: (b) => p(m, b.target.value),
461
- disabled: s,
462
- title: U[u]
463
- },
464
- u
465
- );
466
- }) })
467
- ] }, o.label)) }) : /* @__PURE__ */ l("div", { className: "palette-selector__options", children: Object.entries(y).map(([o, u]) => {
468
- const m = D(u.colors);
469
- return /* @__PURE__ */ h(
470
- "button",
471
- {
472
- className: `palette-selector__option ${f === o ? "palette-selector__option--active" : ""}`,
473
- onClick: () => t(u.colors),
474
- disabled: s,
475
- children: [
476
- /* @__PURE__ */ l("div", { className: "palette-selector__bar", children: Y(u.colors).map((b, _) => /* @__PURE__ */ l(
477
- "span",
478
- {
479
- className: "palette-selector__swatch",
480
- style: { backgroundColor: b }
481
- },
482
- _
483
- )) }),
484
- /* @__PURE__ */ l("div", { className: "palette-selector__bar palette-selector__bar--theme", children: W.map((b, _) => /* @__PURE__ */ l(
485
- "span",
486
- {
487
- className: "palette-selector__swatch",
488
- style: { backgroundColor: m[b] }
489
- },
490
- _
491
- )) }),
492
- /* @__PURE__ */ l("span", { className: "palette-selector__label", children: u.label })
493
- ]
494
- },
495
- o
496
- );
497
- }) })
498
- ] });
499
- }
500
- const z = M, q = 30, H = 10, be = {
501
- gridColumns: q,
502
- gridRows: H,
503
- widgets: []
504
- }, _e = {
505
- kpi_card: "KPI Card",
506
- gauge: "Gauge",
507
- chart: "Gráfico",
508
- filter: "Filtro",
509
- variable: "Variável",
510
- color_palette: "Paleta de Cores"
511
- }, Se = ["kpi_card", "gauge", "chart"], Te = ["filter", "variable", "color_palette"], De = /* @__PURE__ */ new Set(["filter", "variable", "color_palette"]), Ee = {
512
- sum: "Soma",
513
- avg: "Média",
514
- count: "Contagem",
515
- min: "Mínimo",
516
- max: "Máximo",
517
- count_distinct: "Contagem Distinta"
518
- }, V = {
519
- currency: "Moeda (R$)",
520
- number: "Número",
521
- integer: "Inteiro",
522
- percentage: "Porcentagem",
523
- date: "Data",
524
- text: "Texto"
525
- }, ye = Object.entries(V).filter(([e]) => e !== "date" && e !== "text"), Ne = {
526
- yoy: "vs Ano Anterior",
527
- mom: "vs Mês Anterior",
528
- target: "vs Meta",
529
- none: "Nenhuma"
530
- }, we = {
531
- bar: "Barras",
532
- line: "Linhas",
533
- area: "Área",
534
- pie: "Pizza"
535
- }, ve = {
536
- date_range: "Periodo",
537
- select: "Seleção Única",
538
- multi_select: "Seleção Múltipla"
539
- }, Le = {
540
- kpi_card: { x: 0, y: 0, w: 6, h: 3 },
541
- gauge: { x: 0, y: 0, w: 6, h: 5 },
542
- chart: { x: 0, y: 0, w: 6, h: 6 },
543
- filter: { x: 0, y: 0, w: 4, h: 2 },
544
- variable: { x: 0, y: 0, w: 4, h: 2 },
545
- color_palette: { x: 0, y: 0, w: 4, h: 2 }
546
- }, Me = {
547
- kpi_card: { label: "Novo KPI", aggregation: "sum", format: "number" },
548
- gauge: { label: "Novo Gauge", aggregation: "sum" },
549
- chart: { label: "Novo Grafico", chartType: "bar", xAxis: { column: "", granularity: "day" }, series: [] },
550
- filter: { label: "Novo Filtro", filterType: "select" },
551
- variable: { label: "Nova Variavel", variableValue: 0, variableFormat: "number", locked: !1 },
552
- color_palette: { label: "Paleta de Cores", paletteColors: z, locked: !1 }
553
- };
554
- export {
555
- Ee as A,
556
- ge as B,
557
- we as C,
558
- Se as D,
559
- be as E,
560
- ve as F,
561
- T as G,
562
- de as H,
563
- ue as I,
564
- fe as J,
565
- ne as K,
566
- X as L,
567
- re as M,
568
- ye as N,
569
- Z as O,
570
- y as P,
571
- ee as Q,
572
- F as R,
573
- I as S,
574
- E as T,
575
- _e as W,
576
- Ne as a,
577
- De as b,
578
- Te as c,
579
- he as d,
580
- Me as e,
581
- Le as f,
582
- q as g,
583
- H as h,
584
- z as i,
585
- M as j,
586
- pe as k,
587
- V as l,
588
- ae as m,
589
- d as n,
590
- U as o,
591
- me as p,
592
- G as q,
593
- D as r,
594
- se as s,
595
- x as t,
596
- oe as u,
597
- ie as v,
598
- te as w,
599
- Y as x,
600
- ce as y,
601
- le as z
602
- };
603
- //# sourceMappingURL=index-BXIn44vr.js.map