@efds-ui/behavior 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +192 -2
- package/dist/balloon-entry.d.ts +8 -0
- package/dist/balloon-entry.js +1 -0
- package/dist/cep-DWPro2E9.js +154 -0
- package/dist/components/accordion.d.ts +7 -0
- package/dist/components/agenda.d.ts +28 -0
- package/dist/components/alert.d.ts +8 -0
- package/dist/components/avatar.d.ts +15 -0
- package/dist/components/banner.d.ts +10 -0
- package/dist/components/button-busy.d.ts +8 -0
- package/dist/components/cep.d.ts +17 -0
- package/dist/components/combobox.d.ts +13 -0
- package/dist/components/command.d.ts +28 -0
- package/dist/components/conditional.d.ts +19 -0
- package/dist/components/confirm.d.ts +9 -0
- package/dist/components/copy.d.ts +11 -0
- package/dist/components/cropper.d.ts +14 -0
- package/dist/components/datepicker.d.ts +6 -0
- package/dist/components/dialogs.d.ts +35 -0
- package/dist/components/dirty-guard.d.ts +15 -0
- package/dist/components/dropdown.d.ts +9 -0
- package/dist/components/filter-bar.d.ts +24 -0
- package/dist/components/format.d.ts +12 -0
- package/dist/components/gallery.d.ts +11 -0
- package/dist/components/image-shared.d.ts +11 -0
- package/dist/components/image.d.ts +13 -0
- package/dist/components/loader.d.ts +69 -0
- package/dist/components/lookup.d.ts +18 -0
- package/dist/components/mask.d.ts +18 -0
- package/dist/components/modal.d.ts +16 -0
- package/dist/components/notifications.d.ts +16 -0
- package/dist/components/number.d.ts +14 -0
- package/dist/components/otp.d.ts +13 -0
- package/dist/components/page-messages.d.ts +39 -0
- package/dist/components/password.d.ts +11 -0
- package/dist/components/popover.d.ts +11 -0
- package/dist/components/select-readonly.d.ts +8 -0
- package/dist/components/session.d.ts +48 -0
- package/dist/components/sidebar.d.ts +10 -0
- package/dist/components/sortable.d.ts +3 -0
- package/dist/components/status-region.d.ts +1 -0
- package/dist/components/table-export.d.ts +21 -0
- package/dist/components/table-filter.d.ts +9 -0
- package/dist/components/table.d.ts +13 -0
- package/dist/components/tabs.d.ts +8 -0
- package/dist/components/theme-color.d.ts +10 -0
- package/dist/components/timepicker.d.ts +15 -0
- package/dist/components/toast.d.ts +30 -0
- package/dist/components/tooltip.d.ts +13 -0
- package/dist/components/tree.d.ts +12 -0
- package/dist/components/upload.d.ts +10 -0
- package/dist/components/wizard.d.ts +15 -0
- package/dist/config-DFz_FB2q.js +310 -0
- package/dist/core/cep.d.ts +36 -0
- package/dist/core/config.d.ts +303 -0
- package/dist/core/data.d.ts +22 -0
- package/dist/core/date.d.ts +46 -0
- package/dist/core/dom.d.ts +28 -0
- package/dist/core/drag.d.ts +66 -0
- package/dist/core/error-slot.d.ts +14 -0
- package/dist/core/fields.d.ts +53 -0
- package/dist/core/format.d.ts +53 -0
- package/dist/core/mask.d.ts +70 -0
- package/dist/core/position.d.ts +55 -0
- package/dist/core/registry.d.ts +14 -0
- package/dist/core/status.d.ts +10 -0
- package/dist/create-theme-BCnL4ZqE.js +205 -0
- package/dist/cropper-controller-BERlfnDt.js +565 -0
- package/dist/csv-BeXMUO2r.js +19 -0
- package/dist/data-C-IJ0iTV.js +52 -0
- package/dist/eds-behavior-core.js +1 -0
- package/dist/eds-behavior.js +7 -0
- package/dist/export/afm.d.ts +12 -0
- package/dist/export/csv.d.ts +13 -0
- package/dist/export/download.d.ts +4 -0
- package/dist/export/formats/csv.d.ts +6 -0
- package/dist/export/formats/csv.js +8 -0
- package/dist/export/formats/json.d.ts +6 -0
- package/dist/export/formats/json.js +8 -0
- package/dist/export/formats/pdf.d.ts +6 -0
- package/dist/export/formats/pdf.js +8 -0
- package/dist/export/formats/xlsx.d.ts +6 -0
- package/dist/export/formats/xlsx.js +8 -0
- package/dist/export/index.d.ts +16 -0
- package/dist/export/json.d.ts +7 -0
- package/dist/export/model.d.ts +76 -0
- package/dist/export/pdf.d.ts +3 -0
- package/dist/export/types.d.ts +32 -0
- package/dist/export/xlsx.d.ts +23 -0
- package/dist/export/zip.d.ts +9 -0
- package/dist/export-C7NzFSaG.js +20 -0
- package/dist/export-entry.d.ts +10 -0
- package/dist/export-entry.js +8 -0
- package/dist/fields-entry.d.ts +9 -0
- package/dist/fields-entry.js +1 -0
- package/dist/format-DYcDCukc.js +150 -0
- package/dist/format-entry.d.ts +6 -0
- package/dist/format-entry.js +3 -0
- package/dist/iife-boot.d.ts +3 -0
- package/dist/image/canvas.d.ts +49 -0
- package/dist/image/cropper-controller.d.ts +47 -0
- package/dist/image/gallery-logic.d.ts +20 -0
- package/dist/image/math.d.ts +78 -0
- package/dist/image/srcset.d.ts +48 -0
- package/dist/image-entry.d.ts +14 -0
- package/dist/image-entry.js +1 -0
- package/dist/index-core.d.ts +3 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +6147 -0
- package/dist/init-with.d.ts +8 -0
- package/dist/json-DsaGwmbJ.js +13 -0
- package/dist/mask-BIBbLhPB.js +258 -0
- package/dist/mask-entry.d.ts +6 -0
- package/dist/mask-entry.js +1 -0
- package/dist/model-DBuawlqz.js +191 -0
- package/dist/pdf-BevPZal3.js +1143 -0
- package/dist/setup.d.ts +76 -0
- package/dist/theme/create-theme.d.ts +61 -0
- package/dist/theme-entry.d.ts +6 -0
- package/dist/theme-entry.js +1 -0
- package/dist/tooltip-wRy96rs_.js +326 -0
- package/dist/xlsx-6qfA69o5.js +117 -0
- package/package.json +80 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Behavior } from './core/registry';
|
|
2
|
+
import { type BehaviorOptions } from './setup';
|
|
3
|
+
/**
|
|
4
|
+
* Base de `init` (pacote completo e "core"): liga os componentes comuns mais os `extra`.
|
|
5
|
+
* Liga todos os componentes encontrados em `root` (e os que aparecerem depois nele) e o
|
|
6
|
+
* PageLoader. Devolve `destroy()`. Nada fora de `root` é ligado.
|
|
7
|
+
*/
|
|
8
|
+
export declare function initWith(root: ParentNode, options: BehaviorOptions | undefined, extra: readonly Behavior[]): () => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { r as e, s as t } from "./model-DBuawlqz.js";
|
|
2
|
+
// src/export/json.ts
|
|
3
|
+
function n(n) {
|
|
4
|
+
let { columns: r, rows: i } = t(n), a = i.map((t) => {
|
|
5
|
+
let n = {};
|
|
6
|
+
return t.forEach((t, i) => {
|
|
7
|
+
let a = r[i]?.key;
|
|
8
|
+
a !== void 0 && (n[a] = t.kind === "empty" ? null : t.kind === "date" ? e(t) : t.kind === "text" ? t.text : t.value);
|
|
9
|
+
}), n;
|
|
10
|
+
});
|
|
11
|
+
return JSON.stringify(a, null, 2);
|
|
12
|
+
}
|
|
13
|
+
export { n as t };
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
// src/core/mask.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"telefone",
|
|
4
|
+
"cpf",
|
|
5
|
+
"cnpj",
|
|
6
|
+
"cpf-cnpj",
|
|
7
|
+
"cep",
|
|
8
|
+
"moeda",
|
|
9
|
+
"numero",
|
|
10
|
+
"hora",
|
|
11
|
+
"competencia",
|
|
12
|
+
"processo"
|
|
13
|
+
];
|
|
14
|
+
function t(e) {
|
|
15
|
+
let t = [];
|
|
16
|
+
for (let n = 0; n < e.length; n++) {
|
|
17
|
+
let r = e.charAt(n);
|
|
18
|
+
r === "\\" && n + 1 < e.length ? (n += 1, t.push({ literal: e.charAt(n) })) : r === "0" || r === "A" || r === "*" ? t.push({ slot: r }) : t.push({ literal: r });
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
function n(e) {
|
|
23
|
+
let t = e.normalize("NFD").replace(/\p{M}/gu, "");
|
|
24
|
+
return /^[A-Za-z]$/.test(t) ? t.toUpperCase() : "";
|
|
25
|
+
}
|
|
26
|
+
function r(e, t) {
|
|
27
|
+
if (e === "0") return /^[0-9]$/.test(t) ? t : "";
|
|
28
|
+
let r = n(t);
|
|
29
|
+
return e === "A" ? r : r || (/^[0-9]$/.test(t) ? t : "");
|
|
30
|
+
}
|
|
31
|
+
function i(e) {
|
|
32
|
+
let t = [];
|
|
33
|
+
for (let n of e) "slot" in n && t.push(n.slot);
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
function a(e, t, n) {
|
|
37
|
+
let a = (n) => {
|
|
38
|
+
let a = e(t(n)), o = i(a).length, s = "", c = [], l = 0;
|
|
39
|
+
for (let e = 0; e < n.length && s.length < o; e++) {
|
|
40
|
+
let t = n.charAt(e), i = !1;
|
|
41
|
+
for (;;) {
|
|
42
|
+
let e = a[l];
|
|
43
|
+
if (!e || !("literal" in e)) break;
|
|
44
|
+
if (l += 1, e.literal === t) {
|
|
45
|
+
i = !0;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (i) continue;
|
|
50
|
+
let o = a[l];
|
|
51
|
+
if (!o || !("slot" in o)) break;
|
|
52
|
+
let u = r(o.slot, t);
|
|
53
|
+
u && (s += u, c.push(e), l += 1);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
sig: s,
|
|
57
|
+
idx: c
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
maxLength: n,
|
|
62
|
+
anchor: "start",
|
|
63
|
+
extract: a,
|
|
64
|
+
render(n) {
|
|
65
|
+
let r = e(t(n)), i = "", a = "", o = 0, s = !0;
|
|
66
|
+
for (let e of r) if ("literal" in e) a += e.literal;
|
|
67
|
+
else if (o < n.length) i += a + n.charAt(o), a = "", o += 1;
|
|
68
|
+
else {
|
|
69
|
+
s = !1;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
return s ? i + a : i;
|
|
73
|
+
},
|
|
74
|
+
raw: (e) => e,
|
|
75
|
+
caret(e, t, n) {
|
|
76
|
+
if (n <= 0) return 0;
|
|
77
|
+
let { idx: r } = a(e), i = r[Math.min(n, r.length) - 1];
|
|
78
|
+
return i === void 0 ? e.length : i + 1;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
var o = t("(00) 0000-0000"), s = t("(00) 00000-0000"), c = t("000.000.000-00"), l = t("**.***.***/****-00"), u = t("00000-000"), d = t("00:00"), f = t("00/0000"), p = t("0000000-00.0000.0.00.0000"), m = (e) => e.replace(/\D/g, ""), h = (e) => [...e].map((e) => r("*", e)).filter(Boolean).join(""), g = () => ({
|
|
83
|
+
...a((e) => e.length > 10 ? s : o, m, 15),
|
|
84
|
+
fromText(e, t) {
|
|
85
|
+
let n = m(e);
|
|
86
|
+
return !t || n.length < 12 || !n.startsWith("55") ? null : n.slice(2, 13);
|
|
87
|
+
}
|
|
88
|
+
}), _ = (e) => /^\d{0,11}$/.test(e) ? c : l;
|
|
89
|
+
function v(e) {
|
|
90
|
+
let n = t(e), r = i(n);
|
|
91
|
+
return {
|
|
92
|
+
kind: a(() => n, (e) => e, n.length),
|
|
93
|
+
inputMode: r.length > 0 && r.every((e) => e === "0") ? "numeric" : "text"
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
var y = (e) => {
|
|
97
|
+
let t = /^(\d{2}):(\d{2})$/.exec(e);
|
|
98
|
+
return t !== null && Number(t[1]) <= 23 && Number(t[2]) <= 59;
|
|
99
|
+
}, b = (e) => {
|
|
100
|
+
let t = /^(\d{2})\/(\d{4})$/.exec(e);
|
|
101
|
+
return t !== null && Number(t[1]) >= 1 && Number(t[1]) <= 12 && Number(t[2]) >= 1;
|
|
102
|
+
};
|
|
103
|
+
function x(e) {
|
|
104
|
+
let t = 0;
|
|
105
|
+
for (let n of e) t = (t * 10 + Number(n)) % 97;
|
|
106
|
+
return t;
|
|
107
|
+
}
|
|
108
|
+
var S = (e) => {
|
|
109
|
+
let t = /^(\d{7})-(\d{2})\.(\d{4})\.(\d)\.(\d{2})\.(\d{4})$/.exec(e);
|
|
110
|
+
if (!t) return !1;
|
|
111
|
+
let [, n, r, i, a, o, s] = t;
|
|
112
|
+
return x(`${n}${i}${a}${o}${s}${r}`) === 1;
|
|
113
|
+
}, C = 18;
|
|
114
|
+
function w(e, t, n) {
|
|
115
|
+
let r = (e) => e.replace(/^0+/, ""), i = (e) => ({
|
|
116
|
+
neg: e.endsWith("-"),
|
|
117
|
+
digits: e.endsWith("-") ? e.slice(0, -1) : e
|
|
118
|
+
}), a = (t) => {
|
|
119
|
+
let n = r(t).padStart(e + 1, "0");
|
|
120
|
+
return {
|
|
121
|
+
int: n.slice(0, n.length - e),
|
|
122
|
+
frac: n.slice(-e)
|
|
123
|
+
};
|
|
124
|
+
}, o = (e) => e.replace(/\B(?=(\d{3})+(?!\d))/g, "."), s = (e) => n && (e.match(/-/g)?.length ?? 0) % 2 == 1;
|
|
125
|
+
return {
|
|
126
|
+
maxLength: void 0,
|
|
127
|
+
anchor: "end",
|
|
128
|
+
extract(e) {
|
|
129
|
+
let t = "", n = [];
|
|
130
|
+
for (let r = 0; r < e.length && t.length < C; r++) {
|
|
131
|
+
let i = e.charAt(r);
|
|
132
|
+
i >= "0" && i <= "9" && (t += i, n.push(r));
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
sig: s(e) ? `${t}-` : t,
|
|
136
|
+
idx: n
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
render(n) {
|
|
140
|
+
let { neg: r, digits: s } = i(n);
|
|
141
|
+
if (s === "") return r ? "-" : "";
|
|
142
|
+
let { int: c, frac: l } = a(s);
|
|
143
|
+
return `${r ? "-" : ""}${t}${o(c)}${e > 0 ? `,${l}` : ""}`;
|
|
144
|
+
},
|
|
145
|
+
raw(t) {
|
|
146
|
+
let { neg: n, digits: r } = i(t);
|
|
147
|
+
if (r === "") return "";
|
|
148
|
+
let { int: o, frac: s } = a(r), c = /^0*$/.test(o + s);
|
|
149
|
+
return `${n && !c ? "-" : ""}${o}${e > 0 ? `.${s}` : ""}`;
|
|
150
|
+
},
|
|
151
|
+
caret(e, t, n) {
|
|
152
|
+
let r = i(t).digits.length - n, a = e.length;
|
|
153
|
+
for (; r > 0 && a > 0;) --a, /\d/.test(e.charAt(a)) && --r;
|
|
154
|
+
return a;
|
|
155
|
+
},
|
|
156
|
+
afterDelete(e) {
|
|
157
|
+
let { neg: t, digits: n } = i(e);
|
|
158
|
+
return n !== "" && /^0*$/.test(n) ? t ? "-" : "" : e;
|
|
159
|
+
},
|
|
160
|
+
fromText(t) {
|
|
161
|
+
let r = t.replace(/[^\d.,-]/g, "");
|
|
162
|
+
if (!/\d/.test(r)) return null;
|
|
163
|
+
let i = n && r.includes("-"), a = r.replace(/-/g, ""), o, s = "", c = a.lastIndexOf(","), l = a.split(".").length - 1;
|
|
164
|
+
if (c >= 0) o = m(a.slice(0, c)), s = m(a.slice(c + 1));
|
|
165
|
+
else if (l === 1) {
|
|
166
|
+
let [t = "", n = ""] = a.split(".");
|
|
167
|
+
n.length > 0 && n.length <= e && (n.length !== 3 || e === 3) ? (o = t, s = n) : o = m(a);
|
|
168
|
+
} else o = m(a);
|
|
169
|
+
let u = (o + s.padEnd(e, "0").slice(0, e)).slice(0, C);
|
|
170
|
+
return i ? `${u}-` : u;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function T(e) {
|
|
175
|
+
return e === void 0 || !Number.isFinite(e) ? 2 : Math.min(8, Math.max(0, Math.trunc(e)));
|
|
176
|
+
}
|
|
177
|
+
function E(t) {
|
|
178
|
+
return e.includes(t);
|
|
179
|
+
}
|
|
180
|
+
function D(e, t = {}) {
|
|
181
|
+
let n, r = e, i = "numeric", o, s;
|
|
182
|
+
switch (e) {
|
|
183
|
+
case "telefone":
|
|
184
|
+
n = g(), i = "tel", o = "tel";
|
|
185
|
+
break;
|
|
186
|
+
case "cpf":
|
|
187
|
+
n = a(() => c, m, 14);
|
|
188
|
+
break;
|
|
189
|
+
case "cnpj":
|
|
190
|
+
n = a(() => l, h, 18), i = "text";
|
|
191
|
+
break;
|
|
192
|
+
case "cpf-cnpj":
|
|
193
|
+
n = a(_, h, 18), i = "text";
|
|
194
|
+
break;
|
|
195
|
+
case "cep":
|
|
196
|
+
n = a(() => u, m, 9), o = "postal-code";
|
|
197
|
+
break;
|
|
198
|
+
case "hora":
|
|
199
|
+
n = a(() => d, m, 5), s = y;
|
|
200
|
+
break;
|
|
201
|
+
case "competencia":
|
|
202
|
+
n = a(() => f, m, 7), s = b;
|
|
203
|
+
break;
|
|
204
|
+
case "processo":
|
|
205
|
+
n = a(() => p, m, 25), s = S;
|
|
206
|
+
break;
|
|
207
|
+
case "moeda":
|
|
208
|
+
case "numero": {
|
|
209
|
+
let r = T(t.decimals), a = t.negative === !0;
|
|
210
|
+
n = w(r, t.prefix ?? (e === "moeda" ? "R$ " : ""), a), i = a ? "text" : r > 0 ? "decimal" : "numeric";
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
default: {
|
|
214
|
+
let t = v(e);
|
|
215
|
+
n = t.kind, i = t.inputMode, r = "custom";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
let x = (e, t) => {
|
|
219
|
+
let r = n.render(e);
|
|
220
|
+
return {
|
|
221
|
+
value: r,
|
|
222
|
+
raw: n.raw(e),
|
|
223
|
+
caret: n.caret(r, e, t)
|
|
224
|
+
};
|
|
225
|
+
}, C = {
|
|
226
|
+
name: r,
|
|
227
|
+
maxLength: n.maxLength,
|
|
228
|
+
inputMode: i,
|
|
229
|
+
autocomplete: o,
|
|
230
|
+
validate: s ? (e) => e === "" || s(C.format(e)) : void 0,
|
|
231
|
+
format(e) {
|
|
232
|
+
let t = n.fromText?.(e, !0) ?? n.extract(e).sig;
|
|
233
|
+
return n.render(t);
|
|
234
|
+
},
|
|
235
|
+
unmask(e) {
|
|
236
|
+
return n.raw(n.extract(e).sig);
|
|
237
|
+
},
|
|
238
|
+
edit({ text: e, caret: t, prev: r, inputType: i }) {
|
|
239
|
+
let { sig: a, idx: o } = n.extract(e), s = a, c = o.filter((e) => e < t).length, l = i?.startsWith("delete") === !0;
|
|
240
|
+
return l && r !== void 0 && a === n.extract(r).sig && (i === "deleteContentBackward" && c > 0 ? (s = s.slice(0, c - 1) + s.slice(c), --c) : i === "deleteContentForward" && c < o.length && (s = s.slice(0, c) + s.slice(c + 1))), l && n.afterDelete && (s = n.afterDelete(s)), x(s, Math.min(c, s.length));
|
|
241
|
+
},
|
|
242
|
+
paste(e, t, r, i) {
|
|
243
|
+
let a = t <= 0 && r >= e.length, o = n.fromText?.(i, a);
|
|
244
|
+
if (o != null) return x(o, o.length);
|
|
245
|
+
if (n.anchor === "end") return C.edit({
|
|
246
|
+
text: e,
|
|
247
|
+
caret: r
|
|
248
|
+
});
|
|
249
|
+
let s = e.slice(0, t) + i + e.slice(r);
|
|
250
|
+
return C.edit({
|
|
251
|
+
text: s,
|
|
252
|
+
caret: t + i.length
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
return C;
|
|
257
|
+
}
|
|
258
|
+
export { D as n, E as r, e as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entrada `@efds-ui/behavior/mask`: só o núcleo da máscara de entrada (funções puras, sem DOM e
|
|
3
|
+
* sem `init`), para o `@efds-ui/react` usar exatamente a mesma lógica do HTML por atributos.
|
|
4
|
+
*/
|
|
5
|
+
export { createMask, isMaskName, MASK_NAMES } from './core/mask';
|
|
6
|
+
export type { Mask, MaskEditInput, MaskEditResult, MaskInputMode, MaskName, MaskOptions, } from './core/mask';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as MASK_NAMES, n as createMask, r as isMaskName } from "./mask-BIBbLhPB.js";
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { a as e, o as t, r as n, t as r } from "./config-DFz_FB2q.js";
|
|
2
|
+
// src/export/download.ts
|
|
3
|
+
var i = {
|
|
4
|
+
csv: "text/csv;charset=utf-8",
|
|
5
|
+
json: "application/json;charset=utf-8",
|
|
6
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
7
|
+
pdf: "application/pdf"
|
|
8
|
+
};
|
|
9
|
+
function a(e, t, n) {
|
|
10
|
+
let r = new Blob([e], { type: t }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
11
|
+
a.href = i, a.download = n, a.hidden = !0, document.body.append(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(i), 1e3);
|
|
12
|
+
}
|
|
13
|
+
// src/export/model.ts
|
|
14
|
+
var o = [
|
|
15
|
+
"text",
|
|
16
|
+
"number",
|
|
17
|
+
"currency",
|
|
18
|
+
"date",
|
|
19
|
+
"percent"
|
|
20
|
+
];
|
|
21
|
+
function s(e) {
|
|
22
|
+
let t = e.replace(/\s|R\$|€|£|%/g, "");
|
|
23
|
+
return /^[+-]?\d{1,3}(\.\d{3})+(,\d+)?$/.test(t) ? Number(t.replace(/\./g, "").replace(",", ".")) : /^[+-]?\d+,\d+$/.test(t) ? Number(t.replace(",", ".")) : /^[+-]?\d+(\.\d+)?$/.test(t) ? Number(t) : null;
|
|
24
|
+
}
|
|
25
|
+
var c = (e, t) => new Date(Date.UTC(e, t, 0)).getUTCDate();
|
|
26
|
+
function l(e, t, n, r, i, a, o) {
|
|
27
|
+
return t < 1 || t > 12 || n < 1 || n > c(e, t) || r > 23 || i > 59 || a > 59 ? null : {
|
|
28
|
+
kind: "date",
|
|
29
|
+
year: e,
|
|
30
|
+
month: t,
|
|
31
|
+
day: n,
|
|
32
|
+
hour: r,
|
|
33
|
+
minute: i,
|
|
34
|
+
second: a,
|
|
35
|
+
time: o
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function u(e) {
|
|
39
|
+
let t = e.trim(), n = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/.exec(t);
|
|
40
|
+
return n ? l(Number(n[1]), Number(n[2]), Number(n[3]), Number(n[4] ?? 0), Number(n[5] ?? 0), Number(n[6] ?? 0), n[4] !== void 0) : (n = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:[ T](\d{1,2}):(\d{2})(?::(\d{2}))?)?$/.exec(t), n ? l(Number(n[3]), Number(n[2]), Number(n[1]), Number(n[4] ?? 0), Number(n[5] ?? 0), Number(n[6] ?? 0), n[4] !== void 0) : null);
|
|
41
|
+
}
|
|
42
|
+
function d(e) {
|
|
43
|
+
if (Number.isNaN(e.getTime())) return null;
|
|
44
|
+
let t = e.getHours(), n = e.getMinutes(), r = e.getSeconds();
|
|
45
|
+
return l(e.getFullYear(), e.getMonth() + 1, e.getDate(), t, n, r, t + n + r > 0);
|
|
46
|
+
}
|
|
47
|
+
var f = (e) => {
|
|
48
|
+
let t = typeof e == "string" ? e : String(e);
|
|
49
|
+
return t.trim() === "" ? { kind: "empty" } : {
|
|
50
|
+
kind: "text",
|
|
51
|
+
text: t
|
|
52
|
+
};
|
|
53
|
+
}, p = (e) => Number.isFinite(e) ? {
|
|
54
|
+
kind: "number",
|
|
55
|
+
value: e
|
|
56
|
+
} : { kind: "empty" };
|
|
57
|
+
function m(e, t) {
|
|
58
|
+
if (e == null || typeof e == "string" && e.trim() === "") return { kind: "empty" };
|
|
59
|
+
if (typeof e == "boolean") return {
|
|
60
|
+
kind: "bool",
|
|
61
|
+
value: e
|
|
62
|
+
};
|
|
63
|
+
if (e instanceof Date && t !== "number" && t !== "currency" && t !== "percent") return d(e) ?? { kind: "empty" };
|
|
64
|
+
if (t === "text") return f(e);
|
|
65
|
+
if (t === "number" || t === "currency" || t === "percent") {
|
|
66
|
+
if (typeof e == "number") return p(e);
|
|
67
|
+
if (typeof e == "string") {
|
|
68
|
+
let t = s(e);
|
|
69
|
+
return t !== null && Number.isFinite(t) ? {
|
|
70
|
+
kind: "number",
|
|
71
|
+
value: t
|
|
72
|
+
} : f(e);
|
|
73
|
+
}
|
|
74
|
+
return f(e);
|
|
75
|
+
}
|
|
76
|
+
return t === "date" ? typeof e == "number" ? d(new Date(e)) ?? { kind: "empty" } : typeof e == "string" ? u(e) ?? f(e) : f(e) : typeof e == "number" ? p(e) : f(e);
|
|
77
|
+
}
|
|
78
|
+
function h(e) {
|
|
79
|
+
if (!e || !Array.isArray(e.columns) || !Array.isArray(e.rows)) throw TypeError("exportData: informe { columns, rows }.");
|
|
80
|
+
let t = e.rows.map((t) => e.columns.map((e) => m(t?.[e.key], e.type)));
|
|
81
|
+
return {
|
|
82
|
+
columns: e.columns.map((e, n) => {
|
|
83
|
+
let r;
|
|
84
|
+
if (e.type && o.includes(e.type)) r = e.type;
|
|
85
|
+
else {
|
|
86
|
+
let e = t.map((e) => e[n]).find((e) => e && e.kind !== "empty");
|
|
87
|
+
r = e?.kind === "number" ? "number" : e?.kind === "date" ? "date" : "text";
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
key: e.key,
|
|
91
|
+
label: String(e.label ?? e.key),
|
|
92
|
+
type: r
|
|
93
|
+
};
|
|
94
|
+
}),
|
|
95
|
+
rows: t.map((e) => e.map((e) => e ?? { kind: "empty" }))
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
var g = /* @__PURE__ */ new Map();
|
|
99
|
+
function _(t = e()) {
|
|
100
|
+
let n = g.get(t);
|
|
101
|
+
if (n) return n;
|
|
102
|
+
let i;
|
|
103
|
+
try {
|
|
104
|
+
let e = new Intl.NumberFormat(t).formatToParts(1234567.5), n = new Intl.DateTimeFormat(t, {
|
|
105
|
+
day: "2-digit",
|
|
106
|
+
month: "2-digit",
|
|
107
|
+
year: "numeric",
|
|
108
|
+
timeZone: "UTC"
|
|
109
|
+
}).formatToParts(new Date(Date.UTC(2001, 10, 22))), r = [];
|
|
110
|
+
for (let e of n) e.type === "day" ? r.push({ part: "d" }) : e.type === "month" ? r.push({ part: "m" }) : e.type === "year" ? r.push({ part: "y" }) : e.type === "literal" && r.push({ literal: e.value });
|
|
111
|
+
i = {
|
|
112
|
+
decimal: e.find((e) => e.type === "decimal")?.value ?? ",",
|
|
113
|
+
group: e.find((e) => e.type === "group")?.value ?? ".",
|
|
114
|
+
datePattern: r
|
|
115
|
+
};
|
|
116
|
+
} catch {
|
|
117
|
+
return t === "pt-BR" ? {
|
|
118
|
+
decimal: ",",
|
|
119
|
+
group: ".",
|
|
120
|
+
datePattern: [
|
|
121
|
+
{ part: "d" },
|
|
122
|
+
{ literal: "/" },
|
|
123
|
+
{ part: "m" },
|
|
124
|
+
{ literal: "/" },
|
|
125
|
+
{ part: "y" }
|
|
126
|
+
]
|
|
127
|
+
} : _(r);
|
|
128
|
+
}
|
|
129
|
+
return g.set(t, i), i;
|
|
130
|
+
}
|
|
131
|
+
function v(t) {
|
|
132
|
+
if (t) try {
|
|
133
|
+
return Intl.getCanonicalLocales(t)[0] ?? e();
|
|
134
|
+
} catch {}
|
|
135
|
+
return e();
|
|
136
|
+
}
|
|
137
|
+
function y(t, n, r, i, a = e()) {
|
|
138
|
+
let o = _(a), s = Math.abs(t), c = s.toFixed(r);
|
|
139
|
+
c.includes("e") && (c = String(s));
|
|
140
|
+
let l = c.split("."), u = l[0] ?? "0", d = l[1] ?? "";
|
|
141
|
+
for (; d.length > n && d.endsWith("0");) d = d.slice(0, -1);
|
|
142
|
+
return i && (u = u.replace(/\B(?=(\d{3})+(?!\d))/g, o.group)), `${t < 0 && /[1-9]/.test(u + d) ? "-" : ""}${u}${d ? `${o.decimal}${d}` : ""}`;
|
|
143
|
+
}
|
|
144
|
+
var b = (e) => String(e).padStart(2, "0");
|
|
145
|
+
function x(t, n = e()) {
|
|
146
|
+
let r = _(n).datePattern.map((e) => "literal" in e ? e.literal : e.part === "d" ? b(t.day) : e.part === "m" ? b(t.month) : String(t.year).padStart(4, "0")).join("");
|
|
147
|
+
if (!t.time) return r;
|
|
148
|
+
let i = `${b(t.hour)}:${b(t.minute)}`;
|
|
149
|
+
return `${r} ${t.second ? `${i}:${b(t.second)}` : i}`;
|
|
150
|
+
}
|
|
151
|
+
function S(e) {
|
|
152
|
+
let t = `${String(e.year).padStart(4, "0")}-${b(e.month)}-${b(e.day)}`;
|
|
153
|
+
return e.time ? `${t}T${b(e.hour)}:${b(e.minute)}:${b(e.second)}` : t;
|
|
154
|
+
}
|
|
155
|
+
function C(t, n = e()) {
|
|
156
|
+
return x({
|
|
157
|
+
kind: "date",
|
|
158
|
+
year: t.getFullYear(),
|
|
159
|
+
month: t.getMonth() + 1,
|
|
160
|
+
day: t.getDate(),
|
|
161
|
+
hour: t.getHours(),
|
|
162
|
+
minute: t.getMinutes(),
|
|
163
|
+
second: 0,
|
|
164
|
+
time: !0
|
|
165
|
+
}, n);
|
|
166
|
+
}
|
|
167
|
+
function w(n, r, i, a = e()) {
|
|
168
|
+
switch (n.kind) {
|
|
169
|
+
case "empty": return "";
|
|
170
|
+
case "text": return n.text;
|
|
171
|
+
case "bool": {
|
|
172
|
+
let e = t();
|
|
173
|
+
return n.value ? e.exportYes : e.exportNo;
|
|
174
|
+
}
|
|
175
|
+
case "date": return x(n, a);
|
|
176
|
+
case "number": {
|
|
177
|
+
let e = i === "view";
|
|
178
|
+
if (r === "currency") {
|
|
179
|
+
let t = y(n.value, 2, 2, e, a);
|
|
180
|
+
return i === "csv" ? t : t.startsWith("-") ? `-R$ ${t.slice(1)}` : `R$ ${t}`;
|
|
181
|
+
}
|
|
182
|
+
return r === "percent" ? `${y(n.value, 0, 2, e, a)}%` : y(n.value, 0, 6, e, a);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
var T = (e, r = {}) => n(t()[e], r);
|
|
187
|
+
function E(e, n) {
|
|
188
|
+
let r = (e ?? "").replace(/[\u0000-\u001f\\/:*?"<>|]/g, "-").trim();
|
|
189
|
+
return r.toLowerCase().endsWith(`.${n}`) && (r = r.slice(0, -(n.length + 1))), r = r.replace(/^\.+/, "").replace(/[. ]+$/, ""), r === "" && (r = t().exportFilename), `${r}.${n}`;
|
|
190
|
+
}
|
|
191
|
+
export { _ as a, v as c, C as i, i as l, E as n, T as o, S as r, h as s, w as t, a as u };
|