@thibezer/ui-components-kit 2.24.1 → 2.24.2
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/CHANGELOG.md +61 -1
- package/dist/botao.cjs +12 -1
- package/dist/botao.js +162 -3
- package/dist/camadas.cjs +311 -1
- package/dist/camadas.js +3244 -148
- package/dist/campo-texto.cjs +16 -1
- package/dist/campo-texto.js +308 -7
- package/dist/canvas.cjs +22 -22
- package/dist/canvas.js +230 -233
- package/dist/card.cjs +20 -1
- package/dist/card.js +145 -2
- package/dist/components/ui-canvas-prancha/index.d.ts +1 -1
- package/dist/components/ui-canvas-prancha/prancha-teclado.d.ts +18 -0
- package/dist/components/ui-canvas-prancha/ui-canvas-prancha-base.d.ts +4 -0
- package/dist/components/ui-editor-prancha/editor-modos.d.ts +10 -0
- package/dist/components/ui-editor-prancha/editor-tipos.d.ts +4 -0
- package/dist/components/ui-editor-prancha/index.d.ts +1 -0
- package/dist/components/ui-editor-prancha/ui-editor-prancha.d.ts +39 -6
- package/dist/core.cjs +1 -1
- package/dist/core.js +44 -55
- package/dist/{cores-utils-BrdynxRd.js → cores-utils-DMyqWvZh.js} +2 -2
- package/dist/cores.cjs +32 -1
- package/dist/cores.js +300 -13
- package/dist/custom-elements.json +1712 -1205
- package/dist/data.cjs +28 -1
- package/dist/data.js +286 -99
- package/dist/{feature_caixa-2Sxv3tGa.js → feature_caixa-BVc5LenS.js} +42 -42
- package/dist/{feature_desenho-BVHivWIB.js → feature_desenho-CC8Mp5Gp.js} +2 -2
- package/dist/feedback.cjs +52 -1
- package/dist/feedback.js +655 -25
- package/dist/forms.cjs +66 -1
- package/dist/forms.js +1216 -39
- package/dist/{geometria-px-DUs5FgLE.js → geometria-px-DHMPUsxC.js} +47 -47
- package/dist/index.cjs +67 -1
- package/dist/index.js +1476 -274
- package/dist/kit-base-CGqj9aiD.cjs +2 -0
- package/dist/kit-base-_THn4w3u.js +1079 -0
- package/dist/mapa.cjs +5 -5
- package/dist/mapa.js +16 -17
- package/dist/modal.cjs +18 -1
- package/dist/modal.js +235 -29
- package/dist/motor.js +49 -49
- package/dist/prancha-nucleo.cjs +3 -1
- package/dist/prancha-nucleo.js +3120 -277
- package/dist/prancha.cjs +38 -1
- package/dist/prancha.js +3233 -228
- package/dist/register.cjs +1 -1
- package/dist/register.js +3 -20
- package/dist/seletor-mapa-base.cjs +13 -13
- package/dist/seletor-mapa-base.js +3 -5
- package/dist/tabela.cjs +142 -1
- package/dist/tabela.js +3773 -92
- package/dist/tipos-elementos.d.ts +5 -1
- package/dist/tipos-vue.d.ts +4 -1
- package/dist/tools.cjs +16 -1
- package/dist/tools.js +1564 -26
- package/dist/ui-seletor-cor-BGw8SBPm.cjs +83 -0
- package/dist/{ui-seletor-cor-Cd8jkzXG.js → ui-seletor-cor-B_twSm-V.js} +8 -9
- package/dist/utils-ClVgqVyJ.cjs +1 -0
- package/dist/utils-DrHoxxmf.js +83 -0
- package/package.json +43 -2
- package/dist/acessibilidade-CSzX-DkG.cjs +0 -1
- package/dist/acessibilidade-CUlSXc2X.js +0 -38
- package/dist/altura-controle-ukMRPckR.cjs +0 -1
- package/dist/altura-controle-vxQiXG4q.js +0 -62
- package/dist/alvo-digitavel-CzCvNVQ3.js +0 -23
- package/dist/alvo-digitavel-DbH0hYFf.cjs +0 -1
- package/dist/degrade-CIxvOTUv.cjs +0 -1
- package/dist/degrade-gDa5sW__.js +0 -119
- package/dist/feature_caixa-CnYPKVFS.cjs +0 -1
- package/dist/feature_caixa-DCs9ZeSk.js +0 -1038
- package/dist/feature_historico-BAIYk1Me.cjs +0 -3
- package/dist/feature_historico-C4h9y5fu.js +0 -3039
- package/dist/form-atalhos-7JTYvumA.cjs +0 -1
- package/dist/form-atalhos-DDTlpgaB.js +0 -203
- package/dist/form-erros-CwPz7Jr4.cjs +0 -1
- package/dist/form-erros-DT5HklfD.js +0 -184
- package/dist/form-submissao-C-SPRKgT.js +0 -61
- package/dist/form-submissao-DxKO5MHI.cjs +0 -1
- package/dist/form-validacao-BlQFxUVj.js +0 -104
- package/dist/form-validacao-DIeyQVH5.cjs +0 -1
- package/dist/geometria-px-DKrWq_XY.js +0 -639
- package/dist/leaflet-CEPcxGWV.cjs +0 -1
- package/dist/leaflet-DOq10gfg.js +0 -84
- package/dist/leaflet-loader-94z5VsdY.cjs +0 -2
- package/dist/leaflet-loader-Cjcdgj5R.js +0 -21
- package/dist/listener-bag-D5omxZ9h.cjs +0 -1
- package/dist/listener-bag-DQgv7OON.js +0 -34
- package/dist/motor-By2te6PZ.js +0 -1400
- package/dist/motor-CkMxd378.cjs +0 -1
- package/dist/opcoes-CupvWVIm.js +0 -24
- package/dist/opcoes-vdAUY5OI.cjs +0 -1
- package/dist/parts-CaoQiCfI.js +0 -7
- package/dist/parts-vQa2873h.cjs +0 -1
- package/dist/prancha-paleta-BZ-9QDgh.js +0 -5276
- package/dist/prancha-paleta-Bb24vP71.cjs +0 -17
- package/dist/ssr-safe-5cWfJP-s.js +0 -10
- package/dist/ssr-safe-CiHD1adl.cjs +0 -1
- package/dist/svg-seguro-ChVJ2L2z.js +0 -74
- package/dist/svg-seguro-J2RM1Ssf.cjs +0 -1
- package/dist/ui-badge-DE58YSBY.cjs +0 -28
- package/dist/ui-badge-KgmI3jOD.js +0 -201
- package/dist/ui-botao-Dz8YvmiA.cjs +0 -12
- package/dist/ui-botao-zLkcMMyP.js +0 -168
- package/dist/ui-bus-CUd99VJi.js +0 -177
- package/dist/ui-bus-XqBLlTYQ.cjs +0 -1
- package/dist/ui-camadas-DoHPnbQm.js +0 -3133
- package/dist/ui-camadas-Vx7wYD4D.cjs +0 -311
- package/dist/ui-campo-texto-Dliyt9qr.cjs +0 -16
- package/dist/ui-campo-texto-btevggO3.js +0 -379
- package/dist/ui-card-7IEYbCN0.js +0 -150
- package/dist/ui-card-Bx8EyzYY.cjs +0 -20
- package/dist/ui-card-C-EJoKnm.js +0 -150
- package/dist/ui-card-DFnRp9bl.js +0 -146
- package/dist/ui-card-DrWVJQKw.cjs +0 -20
- package/dist/ui-card-DsIjHMmG.cjs +0 -20
- package/dist/ui-controle-cores-B1w_Yl69.cjs +0 -32
- package/dist/ui-controle-cores-BRjMvmMn.js +0 -291
- package/dist/ui-controle-cores-BcH9k2Fa.js +0 -292
- package/dist/ui-controle-cores-CvSTP6gJ.cjs +0 -32
- package/dist/ui-editor-prancha-CIngI6yI.js +0 -2886
- package/dist/ui-editor-prancha-DorSe6sC.cjs +0 -31
- package/dist/ui-linha-2kY7TNUJ.cjs +0 -38
- package/dist/ui-linha-B4mBRm1x.cjs +0 -61
- package/dist/ui-linha-DTEIIww4.js +0 -1167
- package/dist/ui-linha-KFF86FW5.js +0 -752
- package/dist/ui-modal-BrXzVZ65.js +0 -216
- package/dist/ui-modal-lARKzEVZ.cjs +0 -18
- package/dist/ui-paleta-ferramentas-Bu6JaT0s.js +0 -1245
- package/dist/ui-paleta-ferramentas-D3Jhwt26.cjs +0 -21
- package/dist/ui-paleta-ferramentas-DebHYiwd.js +0 -1615
- package/dist/ui-paleta-ferramentas-Dgejtluh.js +0 -1423
- package/dist/ui-paleta-ferramentas-hzyo8wBt.cjs +0 -22
- package/dist/ui-paleta-ferramentas-jWuICjW8.cjs +0 -22
- package/dist/ui-seletor-cor-0RLjcME6.cjs +0 -83
- package/dist/ui-seletor-cor-CMuuW-Ym.cjs +0 -83
- package/dist/ui-seletor-cor-DFIQ1sin.js +0 -405
- package/dist/ui-skeleton-BLEV6h3k.js +0 -653
- package/dist/ui-skeleton-B_XTaGrX.cjs +0 -52
- package/dist/ui-switch-BXIDwC-Y.cjs +0 -66
- package/dist/ui-switch-Ctxk-jKS.js +0 -1212
- package/dist/ui-tabela-CXxqbwXv.cjs +0 -7
- package/dist/ui-tabela-Cd0vOwnT.js +0 -1459
- package/dist/ui-tabela-propriedades-C5cIF5ES.js +0 -3779
- package/dist/ui-tabela-propriedades-CJyo568n.js +0 -3517
- package/dist/ui-tabela-propriedades-D96Djx-q.cjs +0 -136
- package/dist/ui-tabela-propriedades-Wa34hfIr.cjs +0 -142
- package/dist/ui-tabela-propriedades-ahQhQauu.js +0 -2329
- package/dist/ui-tabela-propriedades-w9JWhjHy.cjs +0 -142
- package/dist/zero-js-triggers-CJT988bR.js +0 -83
- package/dist/zero-js-triggers-CgM9IIQB.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const v=require("./listener-bag-D5omxZ9h.cjs"),y="input, select, textarea, ui-campo-texto, ui-input, ui-area-texto, ui-textarea, ui-lista-flutuante, ui-select, ui-checkbox, ui-radio, ui-switch, ui-toggle",w='input[type="file"], input[type="hidden"], input[type="submit"], input[type="button"], input[type="reset"]',R=new Set(["ui-checkbox","ui-radio","ui-switch","ui-toggle"]);function S(t){const e=t.tagName.toLowerCase();if(R.has(e))return!0;if(e!=="input")return!1;const r=(t.getAttribute("type")||"").toLowerCase();return r==="checkbox"||r==="radio"}function g(t,e=y){if(!t||typeof t.querySelectorAll!="function")return[];try{return Array.from(t.querySelectorAll(e)).filter(r=>!r.matches(w))}catch{return[]}}function L(t,e){return t.getAttribute("name")||t.id||`#${e}`}function d(t){try{const e=t;if(S(t))return e.checked===!0?"1":"0";const r=e.value;return r==null?"":typeof r=="string"?r:String(r)}catch{return""}}function b(t,e){try{const r=t;S(t)?r.checked=e==="1"||e==="true":r.value=e}catch{}}function O(t,e,r){return g(t,r).find(i=>i.getAttribute("name")===e||i.id===e)??null}const k=["input","change","ui-input","ui-change","ui-selecionar","ui-campos-preenchidos"];function C(t,e,r){const a=g(t,e).map((n,o)=>[L(n,o),d(n)]);let i=null;if(r)try{i=r()??null}catch{i=null}try{return JSON.stringify([a,i])}catch{return JSON.stringify([a,null])}}function D(t,e={}){const r=e.seletor??y,a=new v.ListenerBag;let i=C(t,r,e.estadoExterno),n=!1;const o=()=>{var u;const l=C(t,r,e.estadoExterno)!==i;if(l!==n){n=l;try{(u=e.aoMudar)==null||u.call(e,n)}catch(s){console.error("[form-rascunho] aoMudar lançou exceção:",s)}}return n};return k.forEach(l=>a.add(t,l,o)),{get sujo(){return n},avaliar:o,marcarLimpo(){i=C(t,r,e.estadoExterno),o()},destruir(){a.cleanup()}}}const V=new Set(["__proto__","constructor","prototype"]),M=t=>t==null?"":typeof t=="boolean"?t?"1":"0":String(t);function P(t,e,r={}){const a=r.somenteVazios!==!1,i=r.vazioSe??((c,f)=>f.trim()===""),n=r.seletor??y,o=[],l=[],u=[],s=[],m=[];let h=!1;const E=()=>{t&&typeof t.dispatchEvent=="function"&&typeof CustomEvent<"u"&&t.dispatchEvent(new CustomEvent("ui-campos-preenchidos",{bubbles:!0,detail:{aplicados:[...o]}}))},x=(c,f,p)=>{s.push({campo:f,valor:d(f)}),b(f,p),o.includes(c)||o.push(c)};if(e&&typeof e=="object")for(const c of Object.keys(e)){if(V.has(c))continue;const f=O(t,c,n);if(!f){u.push(c);continue}const p=M(e[c]);if(p==="")continue;const _=d(f);p!==_&&(!a||i(c,_)?x(c,f,p):(l.push(c),m.push({chave:c,campo:f,valor:p})))}return o.length>0&&E(),{aplicados:o,conflitos:l,semAlvo:u,substituirConflitos(){h||m.length===0||(m.splice(0).forEach(({chave:c,campo:f,valor:p})=>x(c,f,p)),E())},desfazer(){if(!h){h=!0;for(let c=s.length-1;c>=0;c--)b(s[c].campo,s[c].valor);s.length=0,E()}}}}const T="Valor inválido.";function A(t,e){e?(t.setAttribute("erro",""),t.setAttribute("mensagem-erro",e)):(t.removeAttribute("erro"),t.removeAttribute("mensagem-erro"))}function j(t,e,r={}){var i,n,o;const a=[];if(!t||!e||typeof e!="object")return{valido:!0,erros:a};for(const l of Object.keys(e)){const u=e[l],s=O(t,l);if(!s||typeof u!="function")continue;if((i=r.ignorar)!=null&&i.call(r,s)){A(s,null);continue}let m;try{m=u(d(s),s)}catch(h){console.error(`[form-erros] regra do campo "${l}" lançou exceção:`,h),m=T}A(s,m||null),m&&a.push({chave:l,mensagem:m,campo:s})}if(a.length>0){const l=g(t);if(a.sort((u,s)=>l.indexOf(u.campo)-l.indexOf(s.campo)),r.focarPrimeiro!==!1){const u=a[0].campo;try{(n=u.focus)==null||n.call(u),(o=u.scrollIntoView)==null||o.call(u,{block:"center",behavior:"smooth"})}catch{}}}return{valido:a.length===0,erros:a}}function K(t){g(t).forEach(e=>A(e,null))}function N(t,e=y){const r=new v.ListenerBag,a=i=>{const n=i.target;if(!(n instanceof Element))return;const o=n.closest(e);o&&(o.hasAttribute("erro")||o.hasAttribute("mensagem-erro"))&&A(o,null)};return["input","change","ui-input","ui-change","ui-selecionar"].forEach(i=>r.add(t,i,a)),()=>r.cleanup()}function B(t,e){const r=new v.ListenerBag,a=n=>{try{n()}catch(o){console.error("[form-atalhos] ação do atalho lançou exceção:",o)}},i=n=>{if(n.isComposing)return;const o=n.ctrlKey||n.metaKey;if(e.salvar&&o&&!n.altKey&&!n.shiftKey&&n.key.toLowerCase()==="s"){n.preventDefault(),a(e.salvar);return}e.cancelar&&n.key==="Escape"&&!n.defaultPrevented&&!o&&!n.altKey&&!n.shiftKey&&(n.preventDefault(),a(e.cancelar))};return r.add(t,"keydown",i),()=>r.cleanup()}exports.SELETOR_CAMPOS_PADRAO=y;exports.chaveDoCampo=L;exports.criarRascunhoFormulario=D;exports.definirValorCampo=b;exports.ehCampoMarcavel=S;exports.lerValorCampo=d;exports.ligarAtalhosFormulario=B;exports.limparErros=K;exports.listarCampos=g;exports.localizarCampo=O;exports.observarLimpezaDeErros=N;exports.preencherCampos=P;exports.validarCampos=j;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { L as S } from "./listener-bag-DQgv7OON.js";
|
|
2
|
-
const g = "input, select, textarea, ui-campo-texto, ui-input, ui-area-texto, ui-textarea, ui-lista-flutuante, ui-select, ui-checkbox, ui-radio, ui-switch, ui-toggle", w = 'input[type="file"], input[type="hidden"], input[type="submit"], input[type="button"], input[type="reset"]', k = /* @__PURE__ */ new Set(["ui-checkbox", "ui-radio", "ui-switch", "ui-toggle"]);
|
|
3
|
-
function O(t) {
|
|
4
|
-
const e = t.tagName.toLowerCase();
|
|
5
|
-
if (k.has(e)) return !0;
|
|
6
|
-
if (e !== "input") return !1;
|
|
7
|
-
const n = (t.getAttribute("type") || "").toLowerCase();
|
|
8
|
-
return n === "checkbox" || n === "radio";
|
|
9
|
-
}
|
|
10
|
-
function A(t, e = g) {
|
|
11
|
-
if (!t || typeof t.querySelectorAll != "function") return [];
|
|
12
|
-
try {
|
|
13
|
-
return Array.from(t.querySelectorAll(e)).filter((n) => !n.matches(w));
|
|
14
|
-
} catch {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function L(t, e) {
|
|
19
|
-
return t.getAttribute("name") || t.id || `#${e}`;
|
|
20
|
-
}
|
|
21
|
-
function d(t) {
|
|
22
|
-
try {
|
|
23
|
-
const e = t;
|
|
24
|
-
if (O(t)) return e.checked === !0 ? "1" : "0";
|
|
25
|
-
const n = e.value;
|
|
26
|
-
return n == null ? "" : typeof n == "string" ? n : String(n);
|
|
27
|
-
} catch {
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function x(t, e) {
|
|
32
|
-
try {
|
|
33
|
-
const n = t;
|
|
34
|
-
O(t) ? n.checked = e === "1" || e === "true" : n.value = e;
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function _(t, e, n) {
|
|
39
|
-
return A(t, n).find((i) => i.getAttribute("name") === e || i.id === e) ?? null;
|
|
40
|
-
}
|
|
41
|
-
const R = ["input", "change", "ui-input", "ui-change", "ui-selecionar", "ui-campos-preenchidos"];
|
|
42
|
-
function b(t, e, n) {
|
|
43
|
-
const a = A(t, e).map((r, o) => [L(r, o), d(r)]);
|
|
44
|
-
let i = null;
|
|
45
|
-
if (n)
|
|
46
|
-
try {
|
|
47
|
-
i = n() ?? null;
|
|
48
|
-
} catch {
|
|
49
|
-
i = null;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
return JSON.stringify([a, i]);
|
|
53
|
-
} catch {
|
|
54
|
-
return JSON.stringify([a, null]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function K(t, e = {}) {
|
|
58
|
-
const n = e.seletor ?? g, a = new S();
|
|
59
|
-
let i = b(t, n, e.estadoExterno), r = !1;
|
|
60
|
-
const o = () => {
|
|
61
|
-
var u;
|
|
62
|
-
const l = b(t, n, e.estadoExterno) !== i;
|
|
63
|
-
if (l !== r) {
|
|
64
|
-
r = l;
|
|
65
|
-
try {
|
|
66
|
-
(u = e.aoMudar) == null || u.call(e, r);
|
|
67
|
-
} catch (s) {
|
|
68
|
-
console.error("[form-rascunho] aoMudar lançou exceção:", s);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return r;
|
|
72
|
-
};
|
|
73
|
-
return R.forEach((l) => a.add(t, l, o)), {
|
|
74
|
-
get sujo() {
|
|
75
|
-
return r;
|
|
76
|
-
},
|
|
77
|
-
avaliar: o,
|
|
78
|
-
marcarLimpo() {
|
|
79
|
-
i = b(t, n, e.estadoExterno), o();
|
|
80
|
-
},
|
|
81
|
-
destruir() {
|
|
82
|
-
a.cleanup();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const V = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]), D = (t) => t == null ? "" : typeof t == "boolean" ? t ? "1" : "0" : String(t);
|
|
87
|
-
function N(t, e, n = {}) {
|
|
88
|
-
const a = n.somenteVazios !== !1, i = n.vazioSe ?? ((c, f) => f.trim() === ""), r = n.seletor ?? g, o = [], l = [], u = [], s = [], h = [];
|
|
89
|
-
let m = !1;
|
|
90
|
-
const E = () => {
|
|
91
|
-
t && typeof t.dispatchEvent == "function" && typeof CustomEvent < "u" && t.dispatchEvent(new CustomEvent("ui-campos-preenchidos", { bubbles: !0, detail: { aplicados: [...o] } }));
|
|
92
|
-
}, v = (c, f, p) => {
|
|
93
|
-
s.push({ campo: f, valor: d(f) }), x(f, p), o.includes(c) || o.push(c);
|
|
94
|
-
};
|
|
95
|
-
if (e && typeof e == "object")
|
|
96
|
-
for (const c of Object.keys(e)) {
|
|
97
|
-
if (V.has(c)) continue;
|
|
98
|
-
const f = _(t, c, r);
|
|
99
|
-
if (!f) {
|
|
100
|
-
u.push(c);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const p = D(e[c]);
|
|
104
|
-
if (p === "") continue;
|
|
105
|
-
const C = d(f);
|
|
106
|
-
p !== C && (!a || i(c, C) ? v(c, f, p) : (l.push(c), h.push({ chave: c, campo: f, valor: p })));
|
|
107
|
-
}
|
|
108
|
-
return o.length > 0 && E(), {
|
|
109
|
-
aplicados: o,
|
|
110
|
-
conflitos: l,
|
|
111
|
-
semAlvo: u,
|
|
112
|
-
substituirConflitos() {
|
|
113
|
-
m || h.length === 0 || (h.splice(0).forEach(({ chave: c, campo: f, valor: p }) => v(c, f, p)), E());
|
|
114
|
-
},
|
|
115
|
-
desfazer() {
|
|
116
|
-
if (!m) {
|
|
117
|
-
m = !0;
|
|
118
|
-
for (let c = s.length - 1; c >= 0; c--) x(s[c].campo, s[c].valor);
|
|
119
|
-
s.length = 0, E();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const M = "Valor inválido.";
|
|
125
|
-
function y(t, e) {
|
|
126
|
-
e ? (t.setAttribute("erro", ""), t.setAttribute("mensagem-erro", e)) : (t.removeAttribute("erro"), t.removeAttribute("mensagem-erro"));
|
|
127
|
-
}
|
|
128
|
-
function T(t, e, n = {}) {
|
|
129
|
-
var i, r, o;
|
|
130
|
-
const a = [];
|
|
131
|
-
if (!t || !e || typeof e != "object") return { valido: !0, erros: a };
|
|
132
|
-
for (const l of Object.keys(e)) {
|
|
133
|
-
const u = e[l], s = _(t, l);
|
|
134
|
-
if (!s || typeof u != "function") continue;
|
|
135
|
-
if ((i = n.ignorar) != null && i.call(n, s)) {
|
|
136
|
-
y(s, null);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
let h;
|
|
140
|
-
try {
|
|
141
|
-
h = u(d(s), s);
|
|
142
|
-
} catch (m) {
|
|
143
|
-
console.error(`[form-erros] regra do campo "${l}" lançou exceção:`, m), h = M;
|
|
144
|
-
}
|
|
145
|
-
y(s, h || null), h && a.push({ chave: l, mensagem: h, campo: s });
|
|
146
|
-
}
|
|
147
|
-
if (a.length > 0) {
|
|
148
|
-
const l = A(t);
|
|
149
|
-
if (a.sort((u, s) => l.indexOf(u.campo) - l.indexOf(s.campo)), n.focarPrimeiro !== !1) {
|
|
150
|
-
const u = a[0].campo;
|
|
151
|
-
try {
|
|
152
|
-
(r = u.focus) == null || r.call(u), (o = u.scrollIntoView) == null || o.call(u, { block: "center", behavior: "smooth" });
|
|
153
|
-
} catch {
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return { valido: a.length === 0, erros: a };
|
|
158
|
-
}
|
|
159
|
-
function G(t) {
|
|
160
|
-
A(t).forEach((e) => y(e, null));
|
|
161
|
-
}
|
|
162
|
-
function P(t, e = g) {
|
|
163
|
-
const n = new S(), a = (i) => {
|
|
164
|
-
const r = i.target;
|
|
165
|
-
if (!(r instanceof Element)) return;
|
|
166
|
-
const o = r.closest(e);
|
|
167
|
-
o && (o.hasAttribute("erro") || o.hasAttribute("mensagem-erro")) && y(o, null);
|
|
168
|
-
};
|
|
169
|
-
return ["input", "change", "ui-input", "ui-change", "ui-selecionar"].forEach((i) => n.add(t, i, a)), () => n.cleanup();
|
|
170
|
-
}
|
|
171
|
-
function I(t, e) {
|
|
172
|
-
const n = new S(), a = (r) => {
|
|
173
|
-
try {
|
|
174
|
-
r();
|
|
175
|
-
} catch (o) {
|
|
176
|
-
console.error("[form-atalhos] ação do atalho lançou exceção:", o);
|
|
177
|
-
}
|
|
178
|
-
}, i = (r) => {
|
|
179
|
-
if (r.isComposing) return;
|
|
180
|
-
const o = r.ctrlKey || r.metaKey;
|
|
181
|
-
if (e.salvar && o && !r.altKey && !r.shiftKey && r.key.toLowerCase() === "s") {
|
|
182
|
-
r.preventDefault(), a(e.salvar);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
e.cancelar && r.key === "Escape" && !r.defaultPrevented && !o && !r.altKey && !r.shiftKey && (r.preventDefault(), a(e.cancelar));
|
|
186
|
-
};
|
|
187
|
-
return n.add(t, "keydown", i), () => n.cleanup();
|
|
188
|
-
}
|
|
189
|
-
export {
|
|
190
|
-
g as S,
|
|
191
|
-
K as a,
|
|
192
|
-
I as b,
|
|
193
|
-
L as c,
|
|
194
|
-
x as d,
|
|
195
|
-
O as e,
|
|
196
|
-
G as f,
|
|
197
|
-
A as g,
|
|
198
|
-
_ as h,
|
|
199
|
-
d as l,
|
|
200
|
-
P as o,
|
|
201
|
-
N as p,
|
|
202
|
-
T as v
|
|
203
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const x=require("./listener-bag-D5omxZ9h.cjs"),g="input, select, textarea, ui-campo-texto, ui-input, ui-area-texto, ui-textarea, ui-lista-flutuante, ui-select, ui-checkbox, ui-radio, ui-switch, ui-toggle",L='input[type="file"], input[type="hidden"], input[type="submit"], input[type="button"], input[type="reset"]',V=new Set(["ui-checkbox","ui-radio","ui-switch","ui-toggle"]);function C(t){const e=t.tagName.toLowerCase();if(V.has(e))return!0;if(e!=="input")return!1;const n=(t.getAttribute("type")||"").toLowerCase();return n==="checkbox"||n==="radio"}function A(t,e=g){if(!t||typeof t.querySelectorAll!="function")return[];try{return Array.from(t.querySelectorAll(e)).filter(n=>!n.matches(L))}catch{return[]}}function R(t,e){return t.getAttribute("name")||t.id||`#${e}`}function d(t){try{const e=t;if(C(t))return e.checked===!0?"1":"0";const n=e.value;return n==null?"":typeof n=="string"?n:String(n)}catch{return""}}function b(t,e){try{const n=t;C(t)?n.checked=e==="1"||e==="true":n.value=e}catch{}}function S(t,e,n){return A(t,n).find(a=>a.getAttribute("name")===e||a.id===e)??null}const w=["input","change","ui-input","ui-change","ui-selecionar","ui-campos-preenchidos"];function v(t,e,n){const i=A(t,e).map((s,r)=>[R(s,r),d(s)]);let a=null;if(n)try{a=n()??null}catch{a=null}try{return JSON.stringify([i,a])}catch{return JSON.stringify([i,null])}}function D(t,e={}){const n=e.seletor??g,i=new x.ListenerBag;let a=v(t,n,e.estadoExterno),s=!1;const r=()=>{var c;const l=v(t,n,e.estadoExterno)!==a;if(l!==s){s=l;try{(c=e.aoMudar)==null||c.call(e,s)}catch(u){console.error("[form-rascunho] aoMudar lançou exceção:",u)}}return s};return w.forEach(l=>i.add(t,l,r)),{get sujo(){return s},avaliar:r,marcarLimpo(){a=v(t,n,e.estadoExterno),r()},destruir(){i.cleanup()}}}const M=new Set(["__proto__","constructor","prototype"]),k=t=>t==null?"":typeof t=="boolean"?t?"1":"0":String(t);function j(t,e,n={}){const i=n.somenteVazios!==!1,a=n.vazioSe??((o,f)=>f.trim()===""),s=n.seletor??g,r=[],l=[],c=[],u=[],p=[];let h=!1;const y=()=>{t&&typeof t.dispatchEvent=="function"&&typeof CustomEvent<"u"&&t.dispatchEvent(new CustomEvent("ui-campos-preenchidos",{bubbles:!0,detail:{aplicados:[...r]}}))},O=(o,f,m)=>{u.push({campo:f,valor:d(f)}),b(f,m),r.includes(o)||r.push(o)};if(e&&typeof e=="object")for(const o of Object.keys(e)){if(M.has(o))continue;const f=S(t,o,s);if(!f){c.push(o);continue}const m=k(e[o]);if(m==="")continue;const _=d(f);m!==_&&(!i||a(o,_)?O(o,f,m):(l.push(o),p.push({chave:o,campo:f,valor:m})))}return r.length>0&&y(),{aplicados:r,conflitos:l,semAlvo:c,substituirConflitos(){h||p.length===0||(p.splice(0).forEach(({chave:o,campo:f,valor:m})=>O(o,f,m)),y())},desfazer(){if(!h){h=!0;for(let o=u.length-1;o>=0;o--)b(u[o].campo,u[o].valor);u.length=0,y()}}}}const N="Valor inválido.";function E(t,e){e?(t.setAttribute("erro",""),t.setAttribute("mensagem-erro",e)):(t.removeAttribute("erro"),t.removeAttribute("mensagem-erro"))}function P(t,e,n={}){var a,s,r;const i=[];if(!t||!e||typeof e!="object")return{valido:!0,erros:i};for(const l of Object.keys(e)){const c=e[l],u=S(t,l);if(!u||typeof c!="function")continue;if((a=n.ignorar)!=null&&a.call(n,u)){E(u,null);continue}let p;try{p=c(d(u),u)}catch(h){console.error(`[form-erros] regra do campo "${l}" lançou exceção:`,h),p=N}E(u,p||null),p&&i.push({chave:l,mensagem:p,campo:u})}if(i.length>0){const l=A(t);if(i.sort((c,u)=>l.indexOf(c.campo)-l.indexOf(u.campo)),n.focarPrimeiro!==!1){const c=i[0].campo;try{(s=c.focus)==null||s.call(c),(r=c.scrollIntoView)==null||r.call(c,{block:"center",behavior:"smooth"})}catch{}}}return{valido:i.length===0,erros:i}}function T(t){A(t).forEach(e=>E(e,null))}function G(t,e=g){const n=new x.ListenerBag,i=a=>{const s=a.target;if(!(s instanceof Element))return;const r=s.closest(e);r&&(r.hasAttribute("erro")||r.hasAttribute("mensagem-erro"))&&E(r,null)};return["input","change","ui-input","ui-change","ui-selecionar"].forEach(a=>n.add(t,a,i)),()=>n.cleanup()}exports.SELETOR_CAMPOS_PADRAO=g;exports.chaveDoCampo=R;exports.criarRascunhoFormulario=D;exports.definirValorCampo=b;exports.ehCampoMarcavel=C;exports.lerValorCampo=d;exports.limparErros=T;exports.listarCampos=A;exports.localizarCampo=S;exports.observarLimpezaDeErros=G;exports.preencherCampos=j;exports.validarCampos=P;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { L as O } from "./listener-bag-DQgv7OON.js";
|
|
2
|
-
const y = "input, select, textarea, ui-campo-texto, ui-input, ui-area-texto, ui-textarea, ui-lista-flutuante, ui-select, ui-checkbox, ui-radio, ui-switch, ui-toggle", w = 'input[type="file"], input[type="hidden"], input[type="submit"], input[type="button"], input[type="reset"]', L = /* @__PURE__ */ new Set(["ui-checkbox", "ui-radio", "ui-switch", "ui-toggle"]);
|
|
3
|
-
function x(t) {
|
|
4
|
-
const e = t.tagName.toLowerCase();
|
|
5
|
-
if (L.has(e)) return !0;
|
|
6
|
-
if (e !== "input") return !1;
|
|
7
|
-
const n = (t.getAttribute("type") || "").toLowerCase();
|
|
8
|
-
return n === "checkbox" || n === "radio";
|
|
9
|
-
}
|
|
10
|
-
function A(t, e = y) {
|
|
11
|
-
if (!t || typeof t.querySelectorAll != "function") return [];
|
|
12
|
-
try {
|
|
13
|
-
return Array.from(t.querySelectorAll(e)).filter((n) => !n.matches(w));
|
|
14
|
-
} catch {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function R(t, e) {
|
|
19
|
-
return t.getAttribute("name") || t.id || `#${e}`;
|
|
20
|
-
}
|
|
21
|
-
function d(t) {
|
|
22
|
-
try {
|
|
23
|
-
const e = t;
|
|
24
|
-
if (x(t)) return e.checked === !0 ? "1" : "0";
|
|
25
|
-
const n = e.value;
|
|
26
|
-
return n == null ? "" : typeof n == "string" ? n : String(n);
|
|
27
|
-
} catch {
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function C(t, e) {
|
|
32
|
-
try {
|
|
33
|
-
const n = t;
|
|
34
|
-
x(t) ? n.checked = e === "1" || e === "true" : n.value = e;
|
|
35
|
-
} catch {
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function _(t, e, n) {
|
|
39
|
-
return A(t, n).find((u) => u.getAttribute("name") === e || u.id === e) ?? null;
|
|
40
|
-
}
|
|
41
|
-
const V = ["input", "change", "ui-input", "ui-change", "ui-selecionar", "ui-campos-preenchidos"];
|
|
42
|
-
function E(t, e, n) {
|
|
43
|
-
const i = A(t, e).map((s, o) => [R(s, o), d(s)]);
|
|
44
|
-
let u = null;
|
|
45
|
-
if (n)
|
|
46
|
-
try {
|
|
47
|
-
u = n() ?? null;
|
|
48
|
-
} catch {
|
|
49
|
-
u = null;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
return JSON.stringify([i, u]);
|
|
53
|
-
} catch {
|
|
54
|
-
return JSON.stringify([i, null]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function N(t, e = {}) {
|
|
58
|
-
const n = e.seletor ?? y, i = new O();
|
|
59
|
-
let u = E(t, n, e.estadoExterno), s = !1;
|
|
60
|
-
const o = () => {
|
|
61
|
-
var c;
|
|
62
|
-
const l = E(t, n, e.estadoExterno) !== u;
|
|
63
|
-
if (l !== s) {
|
|
64
|
-
s = l;
|
|
65
|
-
try {
|
|
66
|
-
(c = e.aoMudar) == null || c.call(e, s);
|
|
67
|
-
} catch (a) {
|
|
68
|
-
console.error("[form-rascunho] aoMudar lançou exceção:", a);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return s;
|
|
72
|
-
};
|
|
73
|
-
return V.forEach((l) => i.add(t, l, o)), {
|
|
74
|
-
get sujo() {
|
|
75
|
-
return s;
|
|
76
|
-
},
|
|
77
|
-
avaliar: o,
|
|
78
|
-
marcarLimpo() {
|
|
79
|
-
u = E(t, n, e.estadoExterno), o();
|
|
80
|
-
},
|
|
81
|
-
destruir() {
|
|
82
|
-
i.cleanup();
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const k = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]), M = (t) => t == null ? "" : typeof t == "boolean" ? t ? "1" : "0" : String(t);
|
|
87
|
-
function G(t, e, n = {}) {
|
|
88
|
-
const i = n.somenteVazios !== !1, u = n.vazioSe ?? ((r, f) => f.trim() === ""), s = n.seletor ?? y, o = [], l = [], c = [], a = [], p = [];
|
|
89
|
-
let m = !1;
|
|
90
|
-
const b = () => {
|
|
91
|
-
t && typeof t.dispatchEvent == "function" && typeof CustomEvent < "u" && t.dispatchEvent(new CustomEvent("ui-campos-preenchidos", { bubbles: !0, detail: { aplicados: [...o] } }));
|
|
92
|
-
}, v = (r, f, h) => {
|
|
93
|
-
a.push({ campo: f, valor: d(f) }), C(f, h), o.includes(r) || o.push(r);
|
|
94
|
-
};
|
|
95
|
-
if (e && typeof e == "object")
|
|
96
|
-
for (const r of Object.keys(e)) {
|
|
97
|
-
if (k.has(r)) continue;
|
|
98
|
-
const f = _(t, r, s);
|
|
99
|
-
if (!f) {
|
|
100
|
-
c.push(r);
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const h = M(e[r]);
|
|
104
|
-
if (h === "") continue;
|
|
105
|
-
const S = d(f);
|
|
106
|
-
h !== S && (!i || u(r, S) ? v(r, f, h) : (l.push(r), p.push({ chave: r, campo: f, valor: h })));
|
|
107
|
-
}
|
|
108
|
-
return o.length > 0 && b(), {
|
|
109
|
-
aplicados: o,
|
|
110
|
-
conflitos: l,
|
|
111
|
-
semAlvo: c,
|
|
112
|
-
substituirConflitos() {
|
|
113
|
-
m || p.length === 0 || (p.splice(0).forEach(({ chave: r, campo: f, valor: h }) => v(r, f, h)), b());
|
|
114
|
-
},
|
|
115
|
-
desfazer() {
|
|
116
|
-
if (!m) {
|
|
117
|
-
m = !0;
|
|
118
|
-
for (let r = a.length - 1; r >= 0; r--) C(a[r].campo, a[r].valor);
|
|
119
|
-
a.length = 0, b();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
const j = "Valor inválido.";
|
|
125
|
-
function g(t, e) {
|
|
126
|
-
e ? (t.setAttribute("erro", ""), t.setAttribute("mensagem-erro", e)) : (t.removeAttribute("erro"), t.removeAttribute("mensagem-erro"));
|
|
127
|
-
}
|
|
128
|
-
function T(t, e, n = {}) {
|
|
129
|
-
var u, s, o;
|
|
130
|
-
const i = [];
|
|
131
|
-
if (!t || !e || typeof e != "object") return { valido: !0, erros: i };
|
|
132
|
-
for (const l of Object.keys(e)) {
|
|
133
|
-
const c = e[l], a = _(t, l);
|
|
134
|
-
if (!a || typeof c != "function") continue;
|
|
135
|
-
if ((u = n.ignorar) != null && u.call(n, a)) {
|
|
136
|
-
g(a, null);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
let p;
|
|
140
|
-
try {
|
|
141
|
-
p = c(d(a), a);
|
|
142
|
-
} catch (m) {
|
|
143
|
-
console.error(`[form-erros] regra do campo "${l}" lançou exceção:`, m), p = j;
|
|
144
|
-
}
|
|
145
|
-
g(a, p || null), p && i.push({ chave: l, mensagem: p, campo: a });
|
|
146
|
-
}
|
|
147
|
-
if (i.length > 0) {
|
|
148
|
-
const l = A(t);
|
|
149
|
-
if (i.sort((c, a) => l.indexOf(c.campo) - l.indexOf(a.campo)), n.focarPrimeiro !== !1) {
|
|
150
|
-
const c = i[0].campo;
|
|
151
|
-
try {
|
|
152
|
-
(s = c.focus) == null || s.call(c), (o = c.scrollIntoView) == null || o.call(c, { block: "center", behavior: "smooth" });
|
|
153
|
-
} catch {
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return { valido: i.length === 0, erros: i };
|
|
158
|
-
}
|
|
159
|
-
function I(t) {
|
|
160
|
-
A(t).forEach((e) => g(e, null));
|
|
161
|
-
}
|
|
162
|
-
function P(t, e = y) {
|
|
163
|
-
const n = new O(), i = (u) => {
|
|
164
|
-
const s = u.target;
|
|
165
|
-
if (!(s instanceof Element)) return;
|
|
166
|
-
const o = s.closest(e);
|
|
167
|
-
o && (o.hasAttribute("erro") || o.hasAttribute("mensagem-erro")) && g(o, null);
|
|
168
|
-
};
|
|
169
|
-
return ["input", "change", "ui-input", "ui-change", "ui-selecionar"].forEach((u) => n.add(t, u, i)), () => n.cleanup();
|
|
170
|
-
}
|
|
171
|
-
export {
|
|
172
|
-
y as S,
|
|
173
|
-
N as a,
|
|
174
|
-
I as b,
|
|
175
|
-
R as c,
|
|
176
|
-
C as d,
|
|
177
|
-
x as e,
|
|
178
|
-
A as f,
|
|
179
|
-
_ as g,
|
|
180
|
-
d as l,
|
|
181
|
-
P as o,
|
|
182
|
-
G as p,
|
|
183
|
-
T as v
|
|
184
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const a = [
|
|
2
|
-
"button:not([type])",
|
|
3
|
-
'button[type="submit"]',
|
|
4
|
-
'input[type="submit"]',
|
|
5
|
-
'input[type="image"]',
|
|
6
|
-
'ui-botao[type="submit"]',
|
|
7
|
-
"ui-botao[tipo-submit]",
|
|
8
|
-
'ui-botao-primario[type="submit"]',
|
|
9
|
-
"ui-botao-primario[tipo-submit]"
|
|
10
|
-
].join(", "), s = [
|
|
11
|
-
"input:not([type])",
|
|
12
|
-
...["text", "search", "url", "tel", "email", "password", "date", "month", "week", "time", "datetime-local", "number"].map((t) => `input[type="${t}"]`),
|
|
13
|
-
"ui-campo-texto",
|
|
14
|
-
"ui-input"
|
|
15
|
-
].join(", ");
|
|
16
|
-
function r(t, e) {
|
|
17
|
-
const u = Array.from(t.querySelectorAll(e)).filter((o) => {
|
|
18
|
-
const n = o.getAttribute("form");
|
|
19
|
-
return !n || n === t.id;
|
|
20
|
-
});
|
|
21
|
-
if (!t.id) return u;
|
|
22
|
-
const i = Array.from(
|
|
23
|
-
t.getRootNode().querySelectorAll(`[form="${CSS.escape(t.id)}"]`)
|
|
24
|
-
).filter((o) => !t.contains(o) && o.matches(e));
|
|
25
|
-
return [...u, ...i].sort(
|
|
26
|
-
(o, n) => o.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
function m(t) {
|
|
30
|
-
if (t.hasAttribute("disabled")) return !0;
|
|
31
|
-
try {
|
|
32
|
-
return t.matches(":disabled");
|
|
33
|
-
} catch {
|
|
34
|
-
return !1;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function c(t, e, u) {
|
|
38
|
-
if (!e) {
|
|
39
|
-
t.requestSubmit();
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const i = document.createElement("button");
|
|
43
|
-
i.type = "submit", i.name = e, i.value = u ?? "", i.hidden = !0, t.append(i);
|
|
44
|
-
try {
|
|
45
|
-
t.requestSubmit(i);
|
|
46
|
-
} finally {
|
|
47
|
-
i.remove();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function b(t) {
|
|
51
|
-
const e = r(t, a)[0];
|
|
52
|
-
if (e) {
|
|
53
|
-
m(e) || e.click();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
r(t, s).length === 1 && t.requestSubmit();
|
|
57
|
-
}
|
|
58
|
-
export {
|
|
59
|
-
b as a,
|
|
60
|
-
c as s
|
|
61
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const a=["button:not([type])",'button[type="submit"]','input[type="submit"]','input[type="image"]','ui-botao[type="submit"]',"ui-botao[tipo-submit]",'ui-botao-primario[type="submit"]',"ui-botao-primario[tipo-submit]"].join(", "),s=["input:not([type])",...["text","search","url","tel","email","password","date","month","week","time","datetime-local","number"].map(t=>`input[type="${t}"]`),"ui-campo-texto","ui-input"].join(", ");function n(t,e){const o=Array.from(t.querySelectorAll(e)).filter(u=>{const r=u.getAttribute("form");return!r||r===t.id});if(!t.id)return o;const i=Array.from(t.getRootNode().querySelectorAll(`[form="${CSS.escape(t.id)}"]`)).filter(u=>!t.contains(u)&&u.matches(e));return[...o,...i].sort((u,r)=>u.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}function m(t){if(t.hasAttribute("disabled"))return!0;try{return t.matches(":disabled")}catch{return!1}}function c(t,e,o){if(!e){t.requestSubmit();return}const i=document.createElement("button");i.type="submit",i.name=e,i.value=o??"",i.hidden=!0,t.append(i);try{t.requestSubmit(i)}finally{i.remove()}}function b(t){const e=n(t,a)[0];if(e){m(e)||e.click();return}n(t,s).length===1&&t.requestSubmit()}exports.submeterFormulario=c;exports.submeterImplicitamente=b;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
function d(e) {
|
|
2
|
-
if (e.disabled)
|
|
3
|
-
return { valido: !0, flags: {}, mensagem: "" };
|
|
4
|
-
if (e.customError && e.customError.trim() !== "")
|
|
5
|
-
return {
|
|
6
|
-
valido: !1,
|
|
7
|
-
flags: { customError: !0 },
|
|
8
|
-
mensagem: e.customError
|
|
9
|
-
};
|
|
10
|
-
const { val: a, rawVal: n, badInput: s, required: u, tipo: l = "text", mensagemValidacao: t } = e;
|
|
11
|
-
if (s || l === "number" && n && isNaN(Number(n)))
|
|
12
|
-
return {
|
|
13
|
-
valido: !1,
|
|
14
|
-
flags: { badInput: !0 },
|
|
15
|
-
mensagem: t || "Insira um número válido."
|
|
16
|
-
};
|
|
17
|
-
if (u && a.trim() === "")
|
|
18
|
-
return {
|
|
19
|
-
valido: !1,
|
|
20
|
-
flags: { valueMissing: !0 },
|
|
21
|
-
mensagem: t || "Preencha este campo."
|
|
22
|
-
};
|
|
23
|
-
if (a === "")
|
|
24
|
-
return { valido: !0, flags: {}, mensagem: "" };
|
|
25
|
-
if (e.minlength !== null && e.minlength !== void 0 && !isNaN(e.minlength) && a.length < e.minlength)
|
|
26
|
-
return {
|
|
27
|
-
valido: !1,
|
|
28
|
-
flags: { tooShort: !0 },
|
|
29
|
-
mensagem: t || `Use pelo menos ${e.minlength} caracteres (atualmente você está usando ${a.length}).`
|
|
30
|
-
};
|
|
31
|
-
if (e.maxlength !== null && e.maxlength !== void 0 && !isNaN(e.maxlength) && a.length > e.maxlength)
|
|
32
|
-
return {
|
|
33
|
-
valido: !1,
|
|
34
|
-
flags: { tooLong: !0 },
|
|
35
|
-
mensagem: t || `Reduza o texto para no máximo ${e.maxlength} caracteres (atualmente você está usando ${a.length}).`
|
|
36
|
-
};
|
|
37
|
-
if (e.pattern)
|
|
38
|
-
try {
|
|
39
|
-
if (!new RegExp(`^(?:${e.pattern})$`).test(a))
|
|
40
|
-
return {
|
|
41
|
-
valido: !1,
|
|
42
|
-
flags: { patternMismatch: !0 },
|
|
43
|
-
mensagem: t || "O valor não corresponde ao padrão solicitado."
|
|
44
|
-
};
|
|
45
|
-
} catch {
|
|
46
|
-
}
|
|
47
|
-
if (l === "email" && !/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/.test(a))
|
|
48
|
-
return {
|
|
49
|
-
valido: !1,
|
|
50
|
-
flags: { typeMismatch: !0 },
|
|
51
|
-
mensagem: t || "Insira um endereço de e-mail válido."
|
|
52
|
-
};
|
|
53
|
-
if (l === "url")
|
|
54
|
-
try {
|
|
55
|
-
new URL(a);
|
|
56
|
-
} catch {
|
|
57
|
-
return {
|
|
58
|
-
valido: !1,
|
|
59
|
-
flags: { typeMismatch: !0 },
|
|
60
|
-
mensagem: t || "Insira uma URL válida."
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (l === "number") {
|
|
64
|
-
const i = Number(a);
|
|
65
|
-
if (isNaN(i))
|
|
66
|
-
return {
|
|
67
|
-
valido: !1,
|
|
68
|
-
flags: { badInput: !0 },
|
|
69
|
-
mensagem: t || "Insira um número válido."
|
|
70
|
-
};
|
|
71
|
-
if (e.min !== null && e.min !== void 0 && !isNaN(e.min) && i < e.min)
|
|
72
|
-
return {
|
|
73
|
-
valido: !1,
|
|
74
|
-
flags: { rangeUnderflow: !0 },
|
|
75
|
-
mensagem: t || `O valor deve ser maior ou igual a ${e.min}.`
|
|
76
|
-
};
|
|
77
|
-
if (e.max !== null && e.max !== void 0 && !isNaN(e.max) && i > e.max)
|
|
78
|
-
return {
|
|
79
|
-
valido: !1,
|
|
80
|
-
flags: { rangeOverflow: !0 },
|
|
81
|
-
mensagem: t || `O valor deve ser menor ou igual a ${e.max}.`
|
|
82
|
-
};
|
|
83
|
-
if (e.step && e.step !== "any") {
|
|
84
|
-
const m = parseFloat(e.step);
|
|
85
|
-
if (!isNaN(m) && m > 0) {
|
|
86
|
-
const f = e.min !== null && e.min !== void 0 && !isNaN(e.min) ? e.min : 0, o = Math.abs((i - f) % m);
|
|
87
|
-
if (o > 1e-6 && Math.abs(o - m) > 1e-6)
|
|
88
|
-
return {
|
|
89
|
-
valido: !1,
|
|
90
|
-
flags: { stepMismatch: !0 },
|
|
91
|
-
mensagem: t || "Insira um valor válido de acordo com o intervalo."
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return { valido: !0, flags: {}, mensagem: "" };
|
|
97
|
-
}
|
|
98
|
-
function r(e, a, n) {
|
|
99
|
-
!e || typeof e.setValidity != "function" || (a.valido ? e.setValidity({}) : e.setValidity(a.flags, a.mensagem || "Valor inválido.", n));
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
r as a,
|
|
103
|
-
d as v
|
|
104
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function d(e){if(e.disabled)return{valido:!0,flags:{},mensagem:""};if(e.customError&&e.customError.trim()!=="")return{valido:!1,flags:{customError:!0},mensagem:e.customError};const{val:a,rawVal:n,badInput:s,required:u,tipo:l="text",mensagemValidacao:t}=e;if(s||l==="number"&&n&&isNaN(Number(n)))return{valido:!1,flags:{badInput:!0},mensagem:t||"Insira um número válido."};if(u&&a.trim()==="")return{valido:!1,flags:{valueMissing:!0},mensagem:t||"Preencha este campo."};if(a==="")return{valido:!0,flags:{},mensagem:""};if(e.minlength!==null&&e.minlength!==void 0&&!isNaN(e.minlength)&&a.length<e.minlength)return{valido:!1,flags:{tooShort:!0},mensagem:t||`Use pelo menos ${e.minlength} caracteres (atualmente você está usando ${a.length}).`};if(e.maxlength!==null&&e.maxlength!==void 0&&!isNaN(e.maxlength)&&a.length>e.maxlength)return{valido:!1,flags:{tooLong:!0},mensagem:t||`Reduza o texto para no máximo ${e.maxlength} caracteres (atualmente você está usando ${a.length}).`};if(e.pattern)try{if(!new RegExp(`^(?:${e.pattern})$`).test(a))return{valido:!1,flags:{patternMismatch:!0},mensagem:t||"O valor não corresponde ao padrão solicitado."}}catch{}if(l==="email"&&!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/.test(a))return{valido:!1,flags:{typeMismatch:!0},mensagem:t||"Insira um endereço de e-mail válido."};if(l==="url")try{new URL(a)}catch{return{valido:!1,flags:{typeMismatch:!0},mensagem:t||"Insira uma URL válida."}}if(l==="number"){const i=Number(a);if(isNaN(i))return{valido:!1,flags:{badInput:!0},mensagem:t||"Insira um número válido."};if(e.min!==null&&e.min!==void 0&&!isNaN(e.min)&&i<e.min)return{valido:!1,flags:{rangeUnderflow:!0},mensagem:t||`O valor deve ser maior ou igual a ${e.min}.`};if(e.max!==null&&e.max!==void 0&&!isNaN(e.max)&&i>e.max)return{valido:!1,flags:{rangeOverflow:!0},mensagem:t||`O valor deve ser menor ou igual a ${e.max}.`};if(e.step&&e.step!=="any"){const m=parseFloat(e.step);if(!isNaN(m)&&m>0){const f=e.min!==null&&e.min!==void 0&&!isNaN(e.min)?e.min:0,o=Math.abs((i-f)%m);if(o>1e-6&&Math.abs(o-m)>1e-6)return{valido:!1,flags:{stepMismatch:!0},mensagem:t||"Insira um valor válido de acordo com o intervalo."}}}}return{valido:!0,flags:{},mensagem:""}}function r(e,a,n){!e||typeof e.setValidity!="function"||(a.valido?e.setValidity({}):e.setValidity(a.flags,a.mensagem||"Valor inválido.",n))}exports.aplicarValidadeInternals=r;exports.validarRestricoesCampoTexto=d;
|