ilibras-widget 1.4.0 → 1.5.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/CHANGELOG.md +35 -0
- package/README.md +14 -26
- package/dist/ilibras-widget.cjs +8 -153
- package/dist/ilibras-widget.js +8 -153
- package/dist/ilibras-widget.mjs +8 -153
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,41 @@ Todas as mudanças notáveis neste projeto serão documentadas neste arquivo.
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [1.5.0] - 2026-09-18
|
|
8
|
+
|
|
9
|
+
### 🙋 O formulário pede só o nome
|
|
10
|
+
|
|
11
|
+
CPF e telefone saíram. Para chamar um intérprete não é preciso identificar a
|
|
12
|
+
pessoa, e cada campo a mais era uma barreira a quem só queria ser atendido — em
|
|
13
|
+
especial um CPF digitado errado, que reprovava o envio inteiro.
|
|
14
|
+
|
|
15
|
+
Sai junto o que existia só para eles: a validação de CPF, a lista de DDDs, as
|
|
16
|
+
máscaras dos dois campos. O widget ficou 4,5 KB menor.
|
|
17
|
+
|
|
18
|
+
O que continua: nome (com sobrenome), a caixa de consentimento, a armadilha
|
|
19
|
+
anti-robô e a marca de tempo de abertura.
|
|
20
|
+
|
|
21
|
+
### 📲 Aviso por SMS mora no iLibras, não aqui
|
|
22
|
+
|
|
23
|
+
Quem agenda um horário e quer ser avisado por SMS informa o celular **na tela
|
|
24
|
+
de agendamento do iLibras**, e o número vale só para aquele atendimento. Era o
|
|
25
|
+
motivo que restava para o widget pedir telefone de todo mundo — inclusive de
|
|
26
|
+
quem nem ia agendar.
|
|
27
|
+
|
|
28
|
+
### 🔁 Compatibilidade
|
|
29
|
+
|
|
30
|
+
A API continua aceitando `cpf` e `telefone`, então **widget antigo instalado em
|
|
31
|
+
site de cliente segue funcionando** sem ser atualizado.
|
|
32
|
+
|
|
33
|
+
Esta é uma versão **minor** de propósito, e não major: quem seguiu o README e
|
|
34
|
+
fixou `@1` recebe a mudança automaticamente, que é o ponto. A API pública do
|
|
35
|
+
pacote (configuração e métodos) não mudou em nada.
|
|
36
|
+
|
|
37
|
+
**Requer o iLibras com CPF e telefone opcionais.** Contra uma versão anterior do
|
|
38
|
+
servidor, o cadastro sem CPF seria recusado com erro de validação.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
7
42
|
## [1.4.0] - 2026-09-16
|
|
8
43
|
|
|
9
44
|
### 📦 O widget virou pacote npm
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
|
|
5
5
|
[](https://developer.mozilla.org/en-US/docs/Web/CSS)
|
|
6
6
|
|
|
7
|
-
Widget
|
|
7
|
+
Widget de acessibilidade em Libras: um botão flutuante que leva a pessoa surda ao atendimento com intérprete — ao vivo ou agendado. Pede só o nome, envia por POST e redireciona para a plataforma. Ideal para sites, sistemas e plataformas web.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -13,9 +13,9 @@ Widget embarcável similar ao WhatsApp para captura de dados (Nome e CPF) com in
|
|
|
13
13
|
- 🚀 **Fácil integração** - Apenas 2 linhas de código
|
|
14
14
|
- 🎨 **Totalmente personalizável** - Cores, posição, textos e mais
|
|
15
15
|
- 📱 **Responsivo** - Funciona perfeitamente em desktop e mobile
|
|
16
|
-
-
|
|
16
|
+
- 🙋 **Pede só o nome** - Nada de CPF ou telefone para ser atendido
|
|
17
|
+
- 📅 **Ao vivo ou agendado** - Entrar na fila agora, ou marcar dia e hora
|
|
17
18
|
- 🔒 **Envio seguro** - Dados enviados via POST para API
|
|
18
|
-
- 🎭 **Máscaras de entrada** - Formatação automática de CPF
|
|
19
19
|
- 🌐 **Universal** - Funciona em qualquer site ou sistema
|
|
20
20
|
- ♿ **Acessível** - Suporte a leitores de tela e navegação por teclado
|
|
21
21
|
- 🌙 **Tema escuro** - Adapta-se automaticamente às preferências do usuário
|
|
@@ -213,18 +213,21 @@ Os dados são enviados como **FormData** (similar a um formulário HTML tradicio
|
|
|
213
213
|
|
|
214
214
|
```
|
|
215
215
|
nome: "João Silva"
|
|
216
|
-
|
|
217
|
-
telefone: "11987654321"
|
|
216
|
+
modo: "fila"
|
|
218
217
|
token: "seu_token_de_autenticacao"
|
|
219
218
|
```
|
|
220
219
|
|
|
221
220
|
| Campo | Descrição | Formato |
|
|
222
221
|
|-------|-----------|------|
|
|
223
222
|
| `nome` | Nome completo do usuário | String |
|
|
224
|
-
| `
|
|
225
|
-
| `telefone` | Telefone sem formatação (apenas números) | String numérica (10-11 dígitos) |
|
|
223
|
+
| `modo` | `fila` (atendimento agora) ou `agendamento` (escolher dia e hora) | String |
|
|
226
224
|
| `token` | Token de autenticação fornecido pela equipe | String |
|
|
227
225
|
|
|
226
|
+
> Até a v1.4.0 o widget também enviava `cpf` e `telefone`. A partir da v1.5.0
|
|
227
|
+
> não envia mais: para chamar um intérprete não é preciso identificar a pessoa,
|
|
228
|
+
> e cada campo a mais era uma barreira a quem só queria ser atendido. A API
|
|
229
|
+
> continua aceitando os dois campos, para os widgets antigos ainda instalados.
|
|
230
|
+
|
|
228
231
|
### Resposta Esperada da API
|
|
229
232
|
|
|
230
233
|
A API deve retornar um JSON com um link de redirecionamento:
|
|
@@ -428,18 +431,6 @@ Todos os dados são enviados via **método POST** (não via URL/GET), garantindo
|
|
|
428
431
|
- Maior segurança no tráfego de informações sensíveis
|
|
429
432
|
- Conformidade com boas práticas de desenvolvimento web
|
|
430
433
|
|
|
431
|
-
### Validação de CPF
|
|
432
|
-
|
|
433
|
-
O widget valida o CPF antes do envio usando o algoritmo de verificação de dígitos. CPFs inválidos são rejeitados automaticamente.
|
|
434
|
-
|
|
435
|
-
```javascript
|
|
436
|
-
// CPFs aceitos: números válidos com 11 dígitos
|
|
437
|
-
// CPFs rejeitados:
|
|
438
|
-
// - Números com menos de 11 dígitos
|
|
439
|
-
// - Sequências repetidas (111.111.111-11)
|
|
440
|
-
// - Dígitos verificadores incorretos
|
|
441
|
-
```
|
|
442
|
-
|
|
443
434
|
### Validação de Nome
|
|
444
435
|
|
|
445
436
|
- Entre 3 e 120 caracteres
|
|
@@ -447,17 +438,14 @@ O widget valida o CPF antes do envio usando o algoritmo de verificação de díg
|
|
|
447
438
|
pontuação de código são rejeitados
|
|
448
439
|
- Exige nome e sobrenome
|
|
449
440
|
|
|
450
|
-
### Validação de Telefone
|
|
451
|
-
|
|
452
|
-
- DDD conferido contra a lista de códigos em uso no país
|
|
453
|
-
- Celular com 9 dígitos precisa começar em 9; fixo com 8 dígitos, entre 2 e 5
|
|
454
|
-
- Sequências repetidas (00000000000) são rejeitadas
|
|
455
|
-
|
|
456
441
|
### Sanitização de Dados
|
|
457
442
|
|
|
458
|
-
- CPF e telefone: apenas dígitos
|
|
459
443
|
- Nome: espaços das pontas removidos e sequências de espaço reduzidas a um
|
|
460
444
|
|
|
445
|
+
> O telefone não é mais pedido aqui. Quem agenda um horário e quer aviso por
|
|
446
|
+
> SMS informa o celular na própria tela de agendamento do iLibras, e ele vale
|
|
447
|
+
> só para aquele atendimento.
|
|
448
|
+
|
|
461
449
|
> **A validação do widget é conveniência, não barreira.** Ela roda no navegador
|
|
462
450
|
> e qualquer pessoa a desliga pelo console. As mesmas regras valem no servidor,
|
|
463
451
|
> e é lá que elas decidem — o widget as repete só para avisar cedo e em
|
package/dist/ilibras-widget.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iLibras Widget v1.
|
|
2
|
+
* iLibras Widget v1.5.0
|
|
3
3
|
* https://github.com/Dimendes-Solucoes/Ilibras_widget
|
|
4
4
|
* Licença MIT
|
|
5
5
|
*
|
|
@@ -766,75 +766,6 @@ var defaultConfig = {
|
|
|
766
766
|
texto: ""
|
|
767
767
|
}
|
|
768
768
|
};
|
|
769
|
-
var DDDS = [
|
|
770
|
-
11,
|
|
771
|
-
12,
|
|
772
|
-
13,
|
|
773
|
-
14,
|
|
774
|
-
15,
|
|
775
|
-
16,
|
|
776
|
-
17,
|
|
777
|
-
18,
|
|
778
|
-
19,
|
|
779
|
-
21,
|
|
780
|
-
22,
|
|
781
|
-
24,
|
|
782
|
-
27,
|
|
783
|
-
28,
|
|
784
|
-
31,
|
|
785
|
-
32,
|
|
786
|
-
33,
|
|
787
|
-
34,
|
|
788
|
-
35,
|
|
789
|
-
37,
|
|
790
|
-
38,
|
|
791
|
-
41,
|
|
792
|
-
42,
|
|
793
|
-
43,
|
|
794
|
-
44,
|
|
795
|
-
45,
|
|
796
|
-
46,
|
|
797
|
-
47,
|
|
798
|
-
48,
|
|
799
|
-
49,
|
|
800
|
-
51,
|
|
801
|
-
53,
|
|
802
|
-
54,
|
|
803
|
-
55,
|
|
804
|
-
61,
|
|
805
|
-
62,
|
|
806
|
-
63,
|
|
807
|
-
64,
|
|
808
|
-
65,
|
|
809
|
-
66,
|
|
810
|
-
67,
|
|
811
|
-
68,
|
|
812
|
-
69,
|
|
813
|
-
71,
|
|
814
|
-
73,
|
|
815
|
-
74,
|
|
816
|
-
75,
|
|
817
|
-
77,
|
|
818
|
-
79,
|
|
819
|
-
81,
|
|
820
|
-
82,
|
|
821
|
-
83,
|
|
822
|
-
84,
|
|
823
|
-
85,
|
|
824
|
-
86,
|
|
825
|
-
87,
|
|
826
|
-
88,
|
|
827
|
-
89,
|
|
828
|
-
91,
|
|
829
|
-
92,
|
|
830
|
-
93,
|
|
831
|
-
94,
|
|
832
|
-
95,
|
|
833
|
-
96,
|
|
834
|
-
97,
|
|
835
|
-
98,
|
|
836
|
-
99
|
|
837
|
-
];
|
|
838
769
|
var FOCAVEIS = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
839
770
|
var ILibrasWidget = class {
|
|
840
771
|
constructor(config = {}) {
|
|
@@ -917,24 +848,6 @@ var ILibrasWidget = class {
|
|
|
917
848
|
<span class="ilibras-widget-erro" id="ilibras-name-erro" hidden></span>
|
|
918
849
|
</div>
|
|
919
850
|
|
|
920
|
-
<div class="ilibras-widget-form-group">
|
|
921
|
-
<label for="ilibras-cpf">CPF <span aria-hidden="true">*</span></label>
|
|
922
|
-
<input type="text" id="ilibras-cpf" name="cpf" placeholder="000.000.000-00"
|
|
923
|
-
required aria-required="true" maxlength="14" autocomplete="off"
|
|
924
|
-
inputmode="numeric" aria-describedby="ilibras-cpf-dica ilibras-cpf-erro" />
|
|
925
|
-
<span class="ilibras-widget-dica" id="ilibras-cpf-dica">Somente números.</span>
|
|
926
|
-
<span class="ilibras-widget-erro" id="ilibras-cpf-erro" hidden></span>
|
|
927
|
-
</div>
|
|
928
|
-
|
|
929
|
-
<div class="ilibras-widget-form-group">
|
|
930
|
-
<label for="ilibras-phone">Telefone <span aria-hidden="true">*</span></label>
|
|
931
|
-
<input type="tel" id="ilibras-phone" name="phone" placeholder="(00) 00000-0000"
|
|
932
|
-
required aria-required="true" maxlength="15" autocomplete="tel"
|
|
933
|
-
inputmode="numeric" aria-describedby="ilibras-phone-dica ilibras-phone-erro" />
|
|
934
|
-
<span class="ilibras-widget-dica" id="ilibras-phone-dica">Com DDD. Ex.: (11) 98765-4321.</span>
|
|
935
|
-
<span class="ilibras-widget-erro" id="ilibras-phone-erro" hidden></span>
|
|
936
|
-
</div>
|
|
937
|
-
|
|
938
851
|
<div class="ilibras-widget-form-group">
|
|
939
852
|
<label for="ilibras-consent" class="ilibras-widget-checkbox-label">
|
|
940
853
|
<input type="checkbox" id="ilibras-consent" name="consent" required aria-required="true"
|
|
@@ -1000,14 +913,11 @@ var ILibrasWidget = class {
|
|
|
1000
913
|
}
|
|
1001
914
|
if (e.key === "Tab") this.prenderFoco(e);
|
|
1002
915
|
});
|
|
1003
|
-
this.
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
input.addEventListener("blur", () => {
|
|
1007
|
-
if (input.value.trim() !== "") this.validarCampo(campo);
|
|
1008
|
-
});
|
|
1009
|
-
input.addEventListener("input", () => this.limparErro(id));
|
|
916
|
+
const nome = this.container.querySelector("#ilibras-name");
|
|
917
|
+
nome.addEventListener("blur", () => {
|
|
918
|
+
if (nome.value.trim() !== "") this.validarCampo("nome");
|
|
1010
919
|
});
|
|
920
|
+
nome.addEventListener("input", () => this.limparErro("name"));
|
|
1011
921
|
this.container.querySelector("#ilibras-consent").addEventListener("change", () => this.limparErro("consent"));
|
|
1012
922
|
this.form.addEventListener("submit", (e) => this.handleSubmit(e, "fila"));
|
|
1013
923
|
if (this.agendar) {
|
|
@@ -1027,28 +937,6 @@ var ILibrasWidget = class {
|
|
|
1027
937
|
primeiro.focus();
|
|
1028
938
|
}
|
|
1029
939
|
}
|
|
1030
|
-
setupInputMasks() {
|
|
1031
|
-
const cpfInput = this.container.querySelector("#ilibras-cpf");
|
|
1032
|
-
const phoneInput = this.container.querySelector("#ilibras-phone");
|
|
1033
|
-
cpfInput.addEventListener("input", (e) => {
|
|
1034
|
-
let value = e.target.value.replace(/\D/g, "").slice(0, 11);
|
|
1035
|
-
value = value.replace(/(\d{3})(\d)/, "$1.$2");
|
|
1036
|
-
value = value.replace(/(\d{3})(\d)/, "$1.$2");
|
|
1037
|
-
value = value.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
1038
|
-
e.target.value = value;
|
|
1039
|
-
});
|
|
1040
|
-
phoneInput.addEventListener("input", (e) => {
|
|
1041
|
-
let value = e.target.value.replace(/\D/g, "").slice(0, 11);
|
|
1042
|
-
if (value.length <= 10) {
|
|
1043
|
-
value = value.replace(/(\d{2})(\d)/, "($1) $2");
|
|
1044
|
-
value = value.replace(/(\d{4})(\d)/, "$1-$2");
|
|
1045
|
-
} else {
|
|
1046
|
-
value = value.replace(/(\d{2})(\d)/, "($1) $2");
|
|
1047
|
-
value = value.replace(/(\d{5})(\d)/, "$1-$2");
|
|
1048
|
-
}
|
|
1049
|
-
e.target.value = value;
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
940
|
toggleWidget() {
|
|
1053
941
|
if (this.isOpen) this.closeWidget();
|
|
1054
942
|
else this.openWidget();
|
|
@@ -1083,8 +971,6 @@ var ILibrasWidget = class {
|
|
|
1083
971
|
valores() {
|
|
1084
972
|
return {
|
|
1085
973
|
nome: this.container.querySelector("#ilibras-name").value.trim().replace(/\s+/g, " "),
|
|
1086
|
-
cpf: this.container.querySelector("#ilibras-cpf").value.replace(/\D/g, ""),
|
|
1087
|
-
telefone: this.container.querySelector("#ilibras-phone").value.replace(/\D/g, ""),
|
|
1088
974
|
consentimento: this.container.querySelector("#ilibras-consent").checked,
|
|
1089
975
|
honeypot: this.container.querySelector("#ilibras-site-url").value
|
|
1090
976
|
};
|
|
@@ -1101,23 +987,6 @@ var ILibrasWidget = class {
|
|
|
1101
987
|
if (palavras.length < 2) return "Informe o nome completo (nome e sobrenome).";
|
|
1102
988
|
return null;
|
|
1103
989
|
}
|
|
1104
|
-
if (campo === "cpf") {
|
|
1105
|
-
if (!v.cpf) return "Informe seu CPF.";
|
|
1106
|
-
if (!this.validateCPF(v.cpf)) return "CPF inválido. Verifique o número digitado.";
|
|
1107
|
-
return null;
|
|
1108
|
-
}
|
|
1109
|
-
if (campo === "telefone") {
|
|
1110
|
-
if (!v.telefone) return "Informe seu telefone com DDD.";
|
|
1111
|
-
if (v.telefone.length < 10 || v.telefone.length > 11) {
|
|
1112
|
-
return "O telefone deve ter DDD e 8 ou 9 dígitos.";
|
|
1113
|
-
}
|
|
1114
|
-
if (!DDDS.includes(parseInt(v.telefone.slice(0, 2), 10))) return "O DDD informado não existe.";
|
|
1115
|
-
const assinante = v.telefone.slice(2);
|
|
1116
|
-
if (/^(\d)\1+$/.test(assinante)) return "O telefone informado é inválido.";
|
|
1117
|
-
const inicioOk = assinante.length === 9 ? assinante[0] === "9" : ["2", "3", "4", "5"].includes(assinante[0]);
|
|
1118
|
-
if (!inicioOk) return "O telefone informado é inválido.";
|
|
1119
|
-
return null;
|
|
1120
|
-
}
|
|
1121
990
|
if (campo === "consent" && !v.consentimento) {
|
|
1122
991
|
return "É preciso aceitar para continuar.";
|
|
1123
992
|
}
|
|
@@ -1125,7 +994,7 @@ var ILibrasWidget = class {
|
|
|
1125
994
|
}
|
|
1126
995
|
validarCampo(campo) {
|
|
1127
996
|
const erro = this.erroDoCampo(campo, this.valores());
|
|
1128
|
-
const id = { nome: "name",
|
|
997
|
+
const id = { nome: "name", consent: "consent" }[campo];
|
|
1129
998
|
if (erro) this.mostrarErro(id, erro);
|
|
1130
999
|
else this.limparErro(id);
|
|
1131
1000
|
return !erro;
|
|
@@ -1136,7 +1005,7 @@ var ILibrasWidget = class {
|
|
|
1136
1005
|
validarTudo() {
|
|
1137
1006
|
const v = this.valores();
|
|
1138
1007
|
let primeiroInvalido = null;
|
|
1139
|
-
for (const [campo, id] of [["nome", "name"], ["
|
|
1008
|
+
for (const [campo, id] of [["nome", "name"], ["consent", "consent"]]) {
|
|
1140
1009
|
const erro = this.erroDoCampo(campo, v);
|
|
1141
1010
|
if (erro) {
|
|
1142
1011
|
this.mostrarErro(id, erro);
|
|
@@ -1170,18 +1039,6 @@ var ILibrasWidget = class {
|
|
|
1170
1039
|
campo.classList.remove("ilibras-widget-invalido");
|
|
1171
1040
|
}
|
|
1172
1041
|
}
|
|
1173
|
-
validateCPF(cpf) {
|
|
1174
|
-
cpf = String(cpf).replace(/\D/g, "");
|
|
1175
|
-
if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) return false;
|
|
1176
|
-
for (let t = 9; t < 11; t++) {
|
|
1177
|
-
let soma = 0;
|
|
1178
|
-
for (let i = 0; i < t; i++) soma += parseInt(cpf[i], 10) * (t + 1 - i);
|
|
1179
|
-
const resto = soma % 11;
|
|
1180
|
-
const digito = resto < 2 ? 0 : 11 - resto;
|
|
1181
|
-
if (parseInt(cpf[t], 10) !== digito) return false;
|
|
1182
|
-
}
|
|
1183
|
-
return true;
|
|
1184
|
-
}
|
|
1185
1042
|
// ─── Avisos ─────────────────────────────────────────────────────────────
|
|
1186
1043
|
mostrarAviso(mensagem, { fallback = false } = {}) {
|
|
1187
1044
|
this.aviso.innerHTML = "";
|
|
@@ -1265,8 +1122,6 @@ var ILibrasWidget = class {
|
|
|
1265
1122
|
const v = this.valores();
|
|
1266
1123
|
const corpo = new FormData();
|
|
1267
1124
|
corpo.append("nome", v.nome);
|
|
1268
|
-
corpo.append("cpf", v.cpf);
|
|
1269
|
-
corpo.append("telefone", v.telefone);
|
|
1270
1125
|
corpo.append("site_url", v.honeypot);
|
|
1271
1126
|
corpo.append("iniciado_em", String(this.abertoEm || Date.now()));
|
|
1272
1127
|
corpo.append("modo", modo);
|
|
@@ -1367,7 +1222,7 @@ var ILibrasWidget = class {
|
|
|
1367
1222
|
tratarFalha(erro) {
|
|
1368
1223
|
const tipo = erro instanceof FalhaDeServico ? erro.tipo : "desconhecido";
|
|
1369
1224
|
if (tipo === "validacao" && erro.detalhe.erros) {
|
|
1370
|
-
const mapa = { nome: "name"
|
|
1225
|
+
const mapa = { nome: "name" };
|
|
1371
1226
|
let primeiro = null;
|
|
1372
1227
|
for (const [campo, mensagens2] of Object.entries(erro.detalhe.erros)) {
|
|
1373
1228
|
const id = mapa[campo];
|
package/dist/ilibras-widget.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iLibras Widget v1.
|
|
2
|
+
* iLibras Widget v1.5.0
|
|
3
3
|
* https://github.com/Dimendes-Solucoes/Ilibras_widget
|
|
4
4
|
* Licença MIT
|
|
5
5
|
*
|
|
@@ -740,75 +740,6 @@
|
|
|
740
740
|
texto: ""
|
|
741
741
|
}
|
|
742
742
|
};
|
|
743
|
-
var DDDS = [
|
|
744
|
-
11,
|
|
745
|
-
12,
|
|
746
|
-
13,
|
|
747
|
-
14,
|
|
748
|
-
15,
|
|
749
|
-
16,
|
|
750
|
-
17,
|
|
751
|
-
18,
|
|
752
|
-
19,
|
|
753
|
-
21,
|
|
754
|
-
22,
|
|
755
|
-
24,
|
|
756
|
-
27,
|
|
757
|
-
28,
|
|
758
|
-
31,
|
|
759
|
-
32,
|
|
760
|
-
33,
|
|
761
|
-
34,
|
|
762
|
-
35,
|
|
763
|
-
37,
|
|
764
|
-
38,
|
|
765
|
-
41,
|
|
766
|
-
42,
|
|
767
|
-
43,
|
|
768
|
-
44,
|
|
769
|
-
45,
|
|
770
|
-
46,
|
|
771
|
-
47,
|
|
772
|
-
48,
|
|
773
|
-
49,
|
|
774
|
-
51,
|
|
775
|
-
53,
|
|
776
|
-
54,
|
|
777
|
-
55,
|
|
778
|
-
61,
|
|
779
|
-
62,
|
|
780
|
-
63,
|
|
781
|
-
64,
|
|
782
|
-
65,
|
|
783
|
-
66,
|
|
784
|
-
67,
|
|
785
|
-
68,
|
|
786
|
-
69,
|
|
787
|
-
71,
|
|
788
|
-
73,
|
|
789
|
-
74,
|
|
790
|
-
75,
|
|
791
|
-
77,
|
|
792
|
-
79,
|
|
793
|
-
81,
|
|
794
|
-
82,
|
|
795
|
-
83,
|
|
796
|
-
84,
|
|
797
|
-
85,
|
|
798
|
-
86,
|
|
799
|
-
87,
|
|
800
|
-
88,
|
|
801
|
-
89,
|
|
802
|
-
91,
|
|
803
|
-
92,
|
|
804
|
-
93,
|
|
805
|
-
94,
|
|
806
|
-
95,
|
|
807
|
-
96,
|
|
808
|
-
97,
|
|
809
|
-
98,
|
|
810
|
-
99
|
|
811
|
-
];
|
|
812
743
|
var FOCAVEIS = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
813
744
|
var ILibrasWidget = class {
|
|
814
745
|
constructor(config = {}) {
|
|
@@ -891,24 +822,6 @@
|
|
|
891
822
|
<span class="ilibras-widget-erro" id="ilibras-name-erro" hidden></span>
|
|
892
823
|
</div>
|
|
893
824
|
|
|
894
|
-
<div class="ilibras-widget-form-group">
|
|
895
|
-
<label for="ilibras-cpf">CPF <span aria-hidden="true">*</span></label>
|
|
896
|
-
<input type="text" id="ilibras-cpf" name="cpf" placeholder="000.000.000-00"
|
|
897
|
-
required aria-required="true" maxlength="14" autocomplete="off"
|
|
898
|
-
inputmode="numeric" aria-describedby="ilibras-cpf-dica ilibras-cpf-erro" />
|
|
899
|
-
<span class="ilibras-widget-dica" id="ilibras-cpf-dica">Somente números.</span>
|
|
900
|
-
<span class="ilibras-widget-erro" id="ilibras-cpf-erro" hidden></span>
|
|
901
|
-
</div>
|
|
902
|
-
|
|
903
|
-
<div class="ilibras-widget-form-group">
|
|
904
|
-
<label for="ilibras-phone">Telefone <span aria-hidden="true">*</span></label>
|
|
905
|
-
<input type="tel" id="ilibras-phone" name="phone" placeholder="(00) 00000-0000"
|
|
906
|
-
required aria-required="true" maxlength="15" autocomplete="tel"
|
|
907
|
-
inputmode="numeric" aria-describedby="ilibras-phone-dica ilibras-phone-erro" />
|
|
908
|
-
<span class="ilibras-widget-dica" id="ilibras-phone-dica">Com DDD. Ex.: (11) 98765-4321.</span>
|
|
909
|
-
<span class="ilibras-widget-erro" id="ilibras-phone-erro" hidden></span>
|
|
910
|
-
</div>
|
|
911
|
-
|
|
912
825
|
<div class="ilibras-widget-form-group">
|
|
913
826
|
<label for="ilibras-consent" class="ilibras-widget-checkbox-label">
|
|
914
827
|
<input type="checkbox" id="ilibras-consent" name="consent" required aria-required="true"
|
|
@@ -974,14 +887,11 @@
|
|
|
974
887
|
}
|
|
975
888
|
if (e.key === "Tab") this.prenderFoco(e);
|
|
976
889
|
});
|
|
977
|
-
this.
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
input.addEventListener("blur", () => {
|
|
981
|
-
if (input.value.trim() !== "") this.validarCampo(campo);
|
|
982
|
-
});
|
|
983
|
-
input.addEventListener("input", () => this.limparErro(id));
|
|
890
|
+
const nome = this.container.querySelector("#ilibras-name");
|
|
891
|
+
nome.addEventListener("blur", () => {
|
|
892
|
+
if (nome.value.trim() !== "") this.validarCampo("nome");
|
|
984
893
|
});
|
|
894
|
+
nome.addEventListener("input", () => this.limparErro("name"));
|
|
985
895
|
this.container.querySelector("#ilibras-consent").addEventListener("change", () => this.limparErro("consent"));
|
|
986
896
|
this.form.addEventListener("submit", (e) => this.handleSubmit(e, "fila"));
|
|
987
897
|
if (this.agendar) {
|
|
@@ -1001,28 +911,6 @@
|
|
|
1001
911
|
primeiro.focus();
|
|
1002
912
|
}
|
|
1003
913
|
}
|
|
1004
|
-
setupInputMasks() {
|
|
1005
|
-
const cpfInput = this.container.querySelector("#ilibras-cpf");
|
|
1006
|
-
const phoneInput = this.container.querySelector("#ilibras-phone");
|
|
1007
|
-
cpfInput.addEventListener("input", (e) => {
|
|
1008
|
-
let value = e.target.value.replace(/\D/g, "").slice(0, 11);
|
|
1009
|
-
value = value.replace(/(\d{3})(\d)/, "$1.$2");
|
|
1010
|
-
value = value.replace(/(\d{3})(\d)/, "$1.$2");
|
|
1011
|
-
value = value.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
1012
|
-
e.target.value = value;
|
|
1013
|
-
});
|
|
1014
|
-
phoneInput.addEventListener("input", (e) => {
|
|
1015
|
-
let value = e.target.value.replace(/\D/g, "").slice(0, 11);
|
|
1016
|
-
if (value.length <= 10) {
|
|
1017
|
-
value = value.replace(/(\d{2})(\d)/, "($1) $2");
|
|
1018
|
-
value = value.replace(/(\d{4})(\d)/, "$1-$2");
|
|
1019
|
-
} else {
|
|
1020
|
-
value = value.replace(/(\d{2})(\d)/, "($1) $2");
|
|
1021
|
-
value = value.replace(/(\d{5})(\d)/, "$1-$2");
|
|
1022
|
-
}
|
|
1023
|
-
e.target.value = value;
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
914
|
toggleWidget() {
|
|
1027
915
|
if (this.isOpen) this.closeWidget();
|
|
1028
916
|
else this.openWidget();
|
|
@@ -1057,8 +945,6 @@
|
|
|
1057
945
|
valores() {
|
|
1058
946
|
return {
|
|
1059
947
|
nome: this.container.querySelector("#ilibras-name").value.trim().replace(/\s+/g, " "),
|
|
1060
|
-
cpf: this.container.querySelector("#ilibras-cpf").value.replace(/\D/g, ""),
|
|
1061
|
-
telefone: this.container.querySelector("#ilibras-phone").value.replace(/\D/g, ""),
|
|
1062
948
|
consentimento: this.container.querySelector("#ilibras-consent").checked,
|
|
1063
949
|
honeypot: this.container.querySelector("#ilibras-site-url").value
|
|
1064
950
|
};
|
|
@@ -1075,23 +961,6 @@
|
|
|
1075
961
|
if (palavras.length < 2) return "Informe o nome completo (nome e sobrenome).";
|
|
1076
962
|
return null;
|
|
1077
963
|
}
|
|
1078
|
-
if (campo === "cpf") {
|
|
1079
|
-
if (!v.cpf) return "Informe seu CPF.";
|
|
1080
|
-
if (!this.validateCPF(v.cpf)) return "CPF inválido. Verifique o número digitado.";
|
|
1081
|
-
return null;
|
|
1082
|
-
}
|
|
1083
|
-
if (campo === "telefone") {
|
|
1084
|
-
if (!v.telefone) return "Informe seu telefone com DDD.";
|
|
1085
|
-
if (v.telefone.length < 10 || v.telefone.length > 11) {
|
|
1086
|
-
return "O telefone deve ter DDD e 8 ou 9 dígitos.";
|
|
1087
|
-
}
|
|
1088
|
-
if (!DDDS.includes(parseInt(v.telefone.slice(0, 2), 10))) return "O DDD informado não existe.";
|
|
1089
|
-
const assinante = v.telefone.slice(2);
|
|
1090
|
-
if (/^(\d)\1+$/.test(assinante)) return "O telefone informado é inválido.";
|
|
1091
|
-
const inicioOk = assinante.length === 9 ? assinante[0] === "9" : ["2", "3", "4", "5"].includes(assinante[0]);
|
|
1092
|
-
if (!inicioOk) return "O telefone informado é inválido.";
|
|
1093
|
-
return null;
|
|
1094
|
-
}
|
|
1095
964
|
if (campo === "consent" && !v.consentimento) {
|
|
1096
965
|
return "É preciso aceitar para continuar.";
|
|
1097
966
|
}
|
|
@@ -1099,7 +968,7 @@
|
|
|
1099
968
|
}
|
|
1100
969
|
validarCampo(campo) {
|
|
1101
970
|
const erro = this.erroDoCampo(campo, this.valores());
|
|
1102
|
-
const id = { nome: "name",
|
|
971
|
+
const id = { nome: "name", consent: "consent" }[campo];
|
|
1103
972
|
if (erro) this.mostrarErro(id, erro);
|
|
1104
973
|
else this.limparErro(id);
|
|
1105
974
|
return !erro;
|
|
@@ -1110,7 +979,7 @@
|
|
|
1110
979
|
validarTudo() {
|
|
1111
980
|
const v = this.valores();
|
|
1112
981
|
let primeiroInvalido = null;
|
|
1113
|
-
for (const [campo, id] of [["nome", "name"], ["
|
|
982
|
+
for (const [campo, id] of [["nome", "name"], ["consent", "consent"]]) {
|
|
1114
983
|
const erro = this.erroDoCampo(campo, v);
|
|
1115
984
|
if (erro) {
|
|
1116
985
|
this.mostrarErro(id, erro);
|
|
@@ -1144,18 +1013,6 @@
|
|
|
1144
1013
|
campo.classList.remove("ilibras-widget-invalido");
|
|
1145
1014
|
}
|
|
1146
1015
|
}
|
|
1147
|
-
validateCPF(cpf) {
|
|
1148
|
-
cpf = String(cpf).replace(/\D/g, "");
|
|
1149
|
-
if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) return false;
|
|
1150
|
-
for (let t = 9; t < 11; t++) {
|
|
1151
|
-
let soma = 0;
|
|
1152
|
-
for (let i = 0; i < t; i++) soma += parseInt(cpf[i], 10) * (t + 1 - i);
|
|
1153
|
-
const resto = soma % 11;
|
|
1154
|
-
const digito = resto < 2 ? 0 : 11 - resto;
|
|
1155
|
-
if (parseInt(cpf[t], 10) !== digito) return false;
|
|
1156
|
-
}
|
|
1157
|
-
return true;
|
|
1158
|
-
}
|
|
1159
1016
|
// ─── Avisos ─────────────────────────────────────────────────────────────
|
|
1160
1017
|
mostrarAviso(mensagem, { fallback = false } = {}) {
|
|
1161
1018
|
this.aviso.innerHTML = "";
|
|
@@ -1239,8 +1096,6 @@
|
|
|
1239
1096
|
const v = this.valores();
|
|
1240
1097
|
const corpo = new FormData();
|
|
1241
1098
|
corpo.append("nome", v.nome);
|
|
1242
|
-
corpo.append("cpf", v.cpf);
|
|
1243
|
-
corpo.append("telefone", v.telefone);
|
|
1244
1099
|
corpo.append("site_url", v.honeypot);
|
|
1245
1100
|
corpo.append("iniciado_em", String(this.abertoEm || Date.now()));
|
|
1246
1101
|
corpo.append("modo", modo);
|
|
@@ -1341,7 +1196,7 @@
|
|
|
1341
1196
|
tratarFalha(erro) {
|
|
1342
1197
|
const tipo = erro instanceof FalhaDeServico ? erro.tipo : "desconhecido";
|
|
1343
1198
|
if (tipo === "validacao" && erro.detalhe.erros) {
|
|
1344
|
-
const mapa = { nome: "name"
|
|
1199
|
+
const mapa = { nome: "name" };
|
|
1345
1200
|
let primeiro = null;
|
|
1346
1201
|
for (const [campo, mensagens2] of Object.entries(erro.detalhe.erros)) {
|
|
1347
1202
|
const id = mapa[campo];
|
package/dist/ilibras-widget.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iLibras Widget v1.
|
|
2
|
+
* iLibras Widget v1.5.0
|
|
3
3
|
* https://github.com/Dimendes-Solucoes/Ilibras_widget
|
|
4
4
|
* Licença MIT
|
|
5
5
|
*
|
|
@@ -740,75 +740,6 @@ var defaultConfig = {
|
|
|
740
740
|
texto: ""
|
|
741
741
|
}
|
|
742
742
|
};
|
|
743
|
-
var DDDS = [
|
|
744
|
-
11,
|
|
745
|
-
12,
|
|
746
|
-
13,
|
|
747
|
-
14,
|
|
748
|
-
15,
|
|
749
|
-
16,
|
|
750
|
-
17,
|
|
751
|
-
18,
|
|
752
|
-
19,
|
|
753
|
-
21,
|
|
754
|
-
22,
|
|
755
|
-
24,
|
|
756
|
-
27,
|
|
757
|
-
28,
|
|
758
|
-
31,
|
|
759
|
-
32,
|
|
760
|
-
33,
|
|
761
|
-
34,
|
|
762
|
-
35,
|
|
763
|
-
37,
|
|
764
|
-
38,
|
|
765
|
-
41,
|
|
766
|
-
42,
|
|
767
|
-
43,
|
|
768
|
-
44,
|
|
769
|
-
45,
|
|
770
|
-
46,
|
|
771
|
-
47,
|
|
772
|
-
48,
|
|
773
|
-
49,
|
|
774
|
-
51,
|
|
775
|
-
53,
|
|
776
|
-
54,
|
|
777
|
-
55,
|
|
778
|
-
61,
|
|
779
|
-
62,
|
|
780
|
-
63,
|
|
781
|
-
64,
|
|
782
|
-
65,
|
|
783
|
-
66,
|
|
784
|
-
67,
|
|
785
|
-
68,
|
|
786
|
-
69,
|
|
787
|
-
71,
|
|
788
|
-
73,
|
|
789
|
-
74,
|
|
790
|
-
75,
|
|
791
|
-
77,
|
|
792
|
-
79,
|
|
793
|
-
81,
|
|
794
|
-
82,
|
|
795
|
-
83,
|
|
796
|
-
84,
|
|
797
|
-
85,
|
|
798
|
-
86,
|
|
799
|
-
87,
|
|
800
|
-
88,
|
|
801
|
-
89,
|
|
802
|
-
91,
|
|
803
|
-
92,
|
|
804
|
-
93,
|
|
805
|
-
94,
|
|
806
|
-
95,
|
|
807
|
-
96,
|
|
808
|
-
97,
|
|
809
|
-
98,
|
|
810
|
-
99
|
|
811
|
-
];
|
|
812
743
|
var FOCAVEIS = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
813
744
|
var ILibrasWidget = class {
|
|
814
745
|
constructor(config = {}) {
|
|
@@ -891,24 +822,6 @@ var ILibrasWidget = class {
|
|
|
891
822
|
<span class="ilibras-widget-erro" id="ilibras-name-erro" hidden></span>
|
|
892
823
|
</div>
|
|
893
824
|
|
|
894
|
-
<div class="ilibras-widget-form-group">
|
|
895
|
-
<label for="ilibras-cpf">CPF <span aria-hidden="true">*</span></label>
|
|
896
|
-
<input type="text" id="ilibras-cpf" name="cpf" placeholder="000.000.000-00"
|
|
897
|
-
required aria-required="true" maxlength="14" autocomplete="off"
|
|
898
|
-
inputmode="numeric" aria-describedby="ilibras-cpf-dica ilibras-cpf-erro" />
|
|
899
|
-
<span class="ilibras-widget-dica" id="ilibras-cpf-dica">Somente números.</span>
|
|
900
|
-
<span class="ilibras-widget-erro" id="ilibras-cpf-erro" hidden></span>
|
|
901
|
-
</div>
|
|
902
|
-
|
|
903
|
-
<div class="ilibras-widget-form-group">
|
|
904
|
-
<label for="ilibras-phone">Telefone <span aria-hidden="true">*</span></label>
|
|
905
|
-
<input type="tel" id="ilibras-phone" name="phone" placeholder="(00) 00000-0000"
|
|
906
|
-
required aria-required="true" maxlength="15" autocomplete="tel"
|
|
907
|
-
inputmode="numeric" aria-describedby="ilibras-phone-dica ilibras-phone-erro" />
|
|
908
|
-
<span class="ilibras-widget-dica" id="ilibras-phone-dica">Com DDD. Ex.: (11) 98765-4321.</span>
|
|
909
|
-
<span class="ilibras-widget-erro" id="ilibras-phone-erro" hidden></span>
|
|
910
|
-
</div>
|
|
911
|
-
|
|
912
825
|
<div class="ilibras-widget-form-group">
|
|
913
826
|
<label for="ilibras-consent" class="ilibras-widget-checkbox-label">
|
|
914
827
|
<input type="checkbox" id="ilibras-consent" name="consent" required aria-required="true"
|
|
@@ -974,14 +887,11 @@ var ILibrasWidget = class {
|
|
|
974
887
|
}
|
|
975
888
|
if (e.key === "Tab") this.prenderFoco(e);
|
|
976
889
|
});
|
|
977
|
-
this.
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
input.addEventListener("blur", () => {
|
|
981
|
-
if (input.value.trim() !== "") this.validarCampo(campo);
|
|
982
|
-
});
|
|
983
|
-
input.addEventListener("input", () => this.limparErro(id));
|
|
890
|
+
const nome = this.container.querySelector("#ilibras-name");
|
|
891
|
+
nome.addEventListener("blur", () => {
|
|
892
|
+
if (nome.value.trim() !== "") this.validarCampo("nome");
|
|
984
893
|
});
|
|
894
|
+
nome.addEventListener("input", () => this.limparErro("name"));
|
|
985
895
|
this.container.querySelector("#ilibras-consent").addEventListener("change", () => this.limparErro("consent"));
|
|
986
896
|
this.form.addEventListener("submit", (e) => this.handleSubmit(e, "fila"));
|
|
987
897
|
if (this.agendar) {
|
|
@@ -1001,28 +911,6 @@ var ILibrasWidget = class {
|
|
|
1001
911
|
primeiro.focus();
|
|
1002
912
|
}
|
|
1003
913
|
}
|
|
1004
|
-
setupInputMasks() {
|
|
1005
|
-
const cpfInput = this.container.querySelector("#ilibras-cpf");
|
|
1006
|
-
const phoneInput = this.container.querySelector("#ilibras-phone");
|
|
1007
|
-
cpfInput.addEventListener("input", (e) => {
|
|
1008
|
-
let value = e.target.value.replace(/\D/g, "").slice(0, 11);
|
|
1009
|
-
value = value.replace(/(\d{3})(\d)/, "$1.$2");
|
|
1010
|
-
value = value.replace(/(\d{3})(\d)/, "$1.$2");
|
|
1011
|
-
value = value.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
1012
|
-
e.target.value = value;
|
|
1013
|
-
});
|
|
1014
|
-
phoneInput.addEventListener("input", (e) => {
|
|
1015
|
-
let value = e.target.value.replace(/\D/g, "").slice(0, 11);
|
|
1016
|
-
if (value.length <= 10) {
|
|
1017
|
-
value = value.replace(/(\d{2})(\d)/, "($1) $2");
|
|
1018
|
-
value = value.replace(/(\d{4})(\d)/, "$1-$2");
|
|
1019
|
-
} else {
|
|
1020
|
-
value = value.replace(/(\d{2})(\d)/, "($1) $2");
|
|
1021
|
-
value = value.replace(/(\d{5})(\d)/, "$1-$2");
|
|
1022
|
-
}
|
|
1023
|
-
e.target.value = value;
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
914
|
toggleWidget() {
|
|
1027
915
|
if (this.isOpen) this.closeWidget();
|
|
1028
916
|
else this.openWidget();
|
|
@@ -1057,8 +945,6 @@ var ILibrasWidget = class {
|
|
|
1057
945
|
valores() {
|
|
1058
946
|
return {
|
|
1059
947
|
nome: this.container.querySelector("#ilibras-name").value.trim().replace(/\s+/g, " "),
|
|
1060
|
-
cpf: this.container.querySelector("#ilibras-cpf").value.replace(/\D/g, ""),
|
|
1061
|
-
telefone: this.container.querySelector("#ilibras-phone").value.replace(/\D/g, ""),
|
|
1062
948
|
consentimento: this.container.querySelector("#ilibras-consent").checked,
|
|
1063
949
|
honeypot: this.container.querySelector("#ilibras-site-url").value
|
|
1064
950
|
};
|
|
@@ -1075,23 +961,6 @@ var ILibrasWidget = class {
|
|
|
1075
961
|
if (palavras.length < 2) return "Informe o nome completo (nome e sobrenome).";
|
|
1076
962
|
return null;
|
|
1077
963
|
}
|
|
1078
|
-
if (campo === "cpf") {
|
|
1079
|
-
if (!v.cpf) return "Informe seu CPF.";
|
|
1080
|
-
if (!this.validateCPF(v.cpf)) return "CPF inválido. Verifique o número digitado.";
|
|
1081
|
-
return null;
|
|
1082
|
-
}
|
|
1083
|
-
if (campo === "telefone") {
|
|
1084
|
-
if (!v.telefone) return "Informe seu telefone com DDD.";
|
|
1085
|
-
if (v.telefone.length < 10 || v.telefone.length > 11) {
|
|
1086
|
-
return "O telefone deve ter DDD e 8 ou 9 dígitos.";
|
|
1087
|
-
}
|
|
1088
|
-
if (!DDDS.includes(parseInt(v.telefone.slice(0, 2), 10))) return "O DDD informado não existe.";
|
|
1089
|
-
const assinante = v.telefone.slice(2);
|
|
1090
|
-
if (/^(\d)\1+$/.test(assinante)) return "O telefone informado é inválido.";
|
|
1091
|
-
const inicioOk = assinante.length === 9 ? assinante[0] === "9" : ["2", "3", "4", "5"].includes(assinante[0]);
|
|
1092
|
-
if (!inicioOk) return "O telefone informado é inválido.";
|
|
1093
|
-
return null;
|
|
1094
|
-
}
|
|
1095
964
|
if (campo === "consent" && !v.consentimento) {
|
|
1096
965
|
return "É preciso aceitar para continuar.";
|
|
1097
966
|
}
|
|
@@ -1099,7 +968,7 @@ var ILibrasWidget = class {
|
|
|
1099
968
|
}
|
|
1100
969
|
validarCampo(campo) {
|
|
1101
970
|
const erro = this.erroDoCampo(campo, this.valores());
|
|
1102
|
-
const id = { nome: "name",
|
|
971
|
+
const id = { nome: "name", consent: "consent" }[campo];
|
|
1103
972
|
if (erro) this.mostrarErro(id, erro);
|
|
1104
973
|
else this.limparErro(id);
|
|
1105
974
|
return !erro;
|
|
@@ -1110,7 +979,7 @@ var ILibrasWidget = class {
|
|
|
1110
979
|
validarTudo() {
|
|
1111
980
|
const v = this.valores();
|
|
1112
981
|
let primeiroInvalido = null;
|
|
1113
|
-
for (const [campo, id] of [["nome", "name"], ["
|
|
982
|
+
for (const [campo, id] of [["nome", "name"], ["consent", "consent"]]) {
|
|
1114
983
|
const erro = this.erroDoCampo(campo, v);
|
|
1115
984
|
if (erro) {
|
|
1116
985
|
this.mostrarErro(id, erro);
|
|
@@ -1144,18 +1013,6 @@ var ILibrasWidget = class {
|
|
|
1144
1013
|
campo.classList.remove("ilibras-widget-invalido");
|
|
1145
1014
|
}
|
|
1146
1015
|
}
|
|
1147
|
-
validateCPF(cpf) {
|
|
1148
|
-
cpf = String(cpf).replace(/\D/g, "");
|
|
1149
|
-
if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) return false;
|
|
1150
|
-
for (let t = 9; t < 11; t++) {
|
|
1151
|
-
let soma = 0;
|
|
1152
|
-
for (let i = 0; i < t; i++) soma += parseInt(cpf[i], 10) * (t + 1 - i);
|
|
1153
|
-
const resto = soma % 11;
|
|
1154
|
-
const digito = resto < 2 ? 0 : 11 - resto;
|
|
1155
|
-
if (parseInt(cpf[t], 10) !== digito) return false;
|
|
1156
|
-
}
|
|
1157
|
-
return true;
|
|
1158
|
-
}
|
|
1159
1016
|
// ─── Avisos ─────────────────────────────────────────────────────────────
|
|
1160
1017
|
mostrarAviso(mensagem, { fallback = false } = {}) {
|
|
1161
1018
|
this.aviso.innerHTML = "";
|
|
@@ -1239,8 +1096,6 @@ var ILibrasWidget = class {
|
|
|
1239
1096
|
const v = this.valores();
|
|
1240
1097
|
const corpo = new FormData();
|
|
1241
1098
|
corpo.append("nome", v.nome);
|
|
1242
|
-
corpo.append("cpf", v.cpf);
|
|
1243
|
-
corpo.append("telefone", v.telefone);
|
|
1244
1099
|
corpo.append("site_url", v.honeypot);
|
|
1245
1100
|
corpo.append("iniciado_em", String(this.abertoEm || Date.now()));
|
|
1246
1101
|
corpo.append("modo", modo);
|
|
@@ -1341,7 +1196,7 @@ var ILibrasWidget = class {
|
|
|
1341
1196
|
tratarFalha(erro) {
|
|
1342
1197
|
const tipo = erro instanceof FalhaDeServico ? erro.tipo : "desconhecido";
|
|
1343
1198
|
if (tipo === "validacao" && erro.detalhe.erros) {
|
|
1344
|
-
const mapa = { nome: "name"
|
|
1199
|
+
const mapa = { nome: "name" };
|
|
1345
1200
|
let primeiro = null;
|
|
1346
1201
|
for (const [campo, mensagens2] of Object.entries(erro.detalhe.erros)) {
|
|
1347
1202
|
const id = mapa[campo];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilibras-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Widget de acessibilidade em Libras: formulário embarcável que leva a pessoa surda ao atendimento com intérprete, ao vivo ou agendado",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/ilibras-widget.cjs",
|