ilibras-widget 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/README.md +1 -0
- package/dist/ilibras-widget.cjs +233 -60
- package/dist/ilibras-widget.js +233 -60
- package/dist/ilibras-widget.mjs +233 -60
- package/index.d.ts +9 -0
- package/package.json +1 -1
package/dist/ilibras-widget.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* iLibras Widget v1.
|
|
2
|
+
* iLibras Widget v1.6.0
|
|
3
3
|
* https://github.com/Dimendes-Solucoes/Ilibras_widget
|
|
4
4
|
* Licença MIT
|
|
5
5
|
*
|
|
@@ -27,22 +27,22 @@ var CSS = `/**
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/* Posicionamento */
|
|
30
|
-
#ilibras-widget-container
|
|
30
|
+
#ilibras-widget-container.ilibras-widget-bottom-right {
|
|
31
31
|
bottom: 30px;
|
|
32
32
|
right: 30px;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
#ilibras-widget-container
|
|
35
|
+
#ilibras-widget-container.ilibras-widget-bottom-left {
|
|
36
36
|
bottom: 30px;
|
|
37
37
|
left: 30px;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
#ilibras-widget-container
|
|
40
|
+
#ilibras-widget-container.ilibras-widget-top-right {
|
|
41
41
|
top: 30px;
|
|
42
42
|
right: 30px;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
#ilibras-widget-container
|
|
45
|
+
#ilibras-widget-container.ilibras-widget-top-left {
|
|
46
46
|
top: 30px;
|
|
47
47
|
left: 30px;
|
|
48
48
|
}
|
|
@@ -75,7 +75,7 @@ var CSS = `/**
|
|
|
75
75
|
height: 64px;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.ilibras-widget-button:hover,
|
|
78
|
+
#ilibras-widget-container .ilibras-widget-button:hover,
|
|
79
79
|
#ilibras-widget-container .ilibras-widget-button:active {
|
|
80
80
|
transform: none;
|
|
81
81
|
box-shadow: none;
|
|
@@ -105,7 +105,8 @@ var CSS = `/**
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
@keyframes ilibras-pulse {
|
|
108
|
-
0%,
|
|
108
|
+
0%,
|
|
109
|
+
100% {
|
|
109
110
|
transform: scale(1);
|
|
110
111
|
}
|
|
111
112
|
50% {
|
|
@@ -138,23 +139,23 @@ var CSS = `/**
|
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
/* Posicionamento do modal baseado na posição do botão */
|
|
141
|
-
.ilibras-widget-bottom-right .ilibras-widget-modal,
|
|
142
|
-
#ilibras-widget-container
|
|
142
|
+
#ilibras-widget-container.ilibras-widget-bottom-right .ilibras-widget-modal,
|
|
143
|
+
#ilibras-widget-container.ilibras-widget-bottom-left .ilibras-widget-modal {
|
|
143
144
|
bottom: 105px;
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
.ilibras-widget-top-right .ilibras-widget-modal,
|
|
147
|
-
#ilibras-widget-container
|
|
147
|
+
#ilibras-widget-container.ilibras-widget-top-right .ilibras-widget-modal,
|
|
148
|
+
#ilibras-widget-container.ilibras-widget-top-left .ilibras-widget-modal {
|
|
148
149
|
top: 105px;
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
.ilibras-widget-bottom-right .ilibras-widget-modal,
|
|
152
|
-
#ilibras-widget-container
|
|
152
|
+
#ilibras-widget-container.ilibras-widget-bottom-right .ilibras-widget-modal,
|
|
153
|
+
#ilibras-widget-container.ilibras-widget-top-right .ilibras-widget-modal {
|
|
153
154
|
right: 0;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
.ilibras-widget-bottom-left .ilibras-widget-modal,
|
|
157
|
-
#ilibras-widget-container
|
|
157
|
+
#ilibras-widget-container.ilibras-widget-bottom-left .ilibras-widget-modal,
|
|
158
|
+
#ilibras-widget-container.ilibras-widget-top-left .ilibras-widget-modal {
|
|
158
159
|
left: 0;
|
|
159
160
|
}
|
|
160
161
|
|
|
@@ -248,7 +249,7 @@ var CSS = `/**
|
|
|
248
249
|
padding-left: 4px;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
|
-
.ilibras-widget-form-group input[type="text"],
|
|
252
|
+
#ilibras-widget-container .ilibras-widget-form-group input[type="text"],
|
|
252
253
|
#ilibras-widget-container .ilibras-widget-form-group input[type="tel"] {
|
|
253
254
|
background: #ffffff;
|
|
254
255
|
border: 1px solid rgba(20,30,45,0.06);
|
|
@@ -257,7 +258,7 @@ var CSS = `/**
|
|
|
257
258
|
border-radius: 8px;
|
|
258
259
|
}
|
|
259
260
|
|
|
260
|
-
.ilibras-widget-form-group input[type="text"]:focus,
|
|
261
|
+
#ilibras-widget-container .ilibras-widget-form-group input[type="text"]:focus,
|
|
261
262
|
#ilibras-widget-container .ilibras-widget-form-group input[type="tel"]:focus {
|
|
262
263
|
background: white;
|
|
263
264
|
border-color: #357ABD;
|
|
@@ -265,7 +266,7 @@ var CSS = `/**
|
|
|
265
266
|
outline: none;
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
.ilibras-widget-form-group input[type="text"]::placeholder,
|
|
269
|
+
#ilibras-widget-container .ilibras-widget-form-group input[type="text"]::placeholder,
|
|
269
270
|
#ilibras-widget-container .ilibras-widget-form-group input[type="tel"]::placeholder {
|
|
270
271
|
color: #6c757d;
|
|
271
272
|
}
|
|
@@ -358,6 +359,42 @@ var CSS = `/**
|
|
|
358
359
|
text-align: center;
|
|
359
360
|
}
|
|
360
361
|
|
|
362
|
+
/* Aviso de saída para o iLibras: toma o lugar do formulário até a pessoa
|
|
363
|
+
confirmar ou voltar. O atributo hidden precisa de regra própria nos dois —
|
|
364
|
+
o display: flex de cada um venceria o atributo, e os dois apareceriam
|
|
365
|
+
juntos. (Sem crase nos comentários deste arquivo: ele é embutido num
|
|
366
|
+
template literal do JS, e uma crase aqui muda a forma do build inteiro.) */
|
|
367
|
+
#ilibras-widget-container .ilibras-widget-form[hidden],
|
|
368
|
+
#ilibras-widget-container .ilibras-widget-confirmacao[hidden] {
|
|
369
|
+
display: none !important;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
#ilibras-widget-container .ilibras-widget-confirmacao {
|
|
373
|
+
display: flex;
|
|
374
|
+
flex-direction: column;
|
|
375
|
+
gap: 12px;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
#ilibras-widget-container .ilibras-widget-confirmacao-titulo {
|
|
379
|
+
margin: 0;
|
|
380
|
+
font-size: 17px;
|
|
381
|
+
font-weight: 600;
|
|
382
|
+
line-height: 1.35;
|
|
383
|
+
color: #073657;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
#ilibras-widget-container .ilibras-widget-confirmacao-texto {
|
|
387
|
+
margin: 0 0 6px;
|
|
388
|
+
font-size: 14px;
|
|
389
|
+
line-height: 1.5;
|
|
390
|
+
color: #495057;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/* "Voltar" tem o visual do botão de agendar, sem a margem que o cola à dica. */
|
|
394
|
+
#ilibras-widget-container .ilibras-widget-confirmacao .ilibras-widget-agendar {
|
|
395
|
+
margin-top: 0;
|
|
396
|
+
}
|
|
397
|
+
|
|
361
398
|
/* Responsividade */
|
|
362
399
|
@media (max-width: 480px) {
|
|
363
400
|
#ilibras-widget-container .ilibras-widget-modal {
|
|
@@ -365,15 +402,15 @@ var CSS = `/**
|
|
|
365
402
|
max-width: 100%;
|
|
366
403
|
}
|
|
367
404
|
|
|
368
|
-
.ilibras-widget-bottom-right,
|
|
369
|
-
#ilibras-widget-container
|
|
405
|
+
#ilibras-widget-container.ilibras-widget-bottom-right,
|
|
406
|
+
#ilibras-widget-container.ilibras-widget-bottom-left {
|
|
370
407
|
bottom: 20px;
|
|
371
408
|
left: 20px !important;
|
|
372
409
|
right: 20px !important;
|
|
373
410
|
}
|
|
374
411
|
|
|
375
|
-
.ilibras-widget-top-right,
|
|
376
|
-
#ilibras-widget-container
|
|
412
|
+
#ilibras-widget-container.ilibras-widget-top-right,
|
|
413
|
+
#ilibras-widget-container.ilibras-widget-top-left {
|
|
377
414
|
top: 20px;
|
|
378
415
|
left: 20px !important;
|
|
379
416
|
right: 20px !important;
|
|
@@ -407,8 +444,8 @@ var CSS = `/**
|
|
|
407
444
|
}
|
|
408
445
|
}
|
|
409
446
|
|
|
410
|
-
.ilibras-widget-button:focus-visible,
|
|
411
|
-
.ilibras-widget-close:focus-visible,
|
|
447
|
+
#ilibras-widget-container .ilibras-widget-button:focus-visible,
|
|
448
|
+
#ilibras-widget-container .ilibras-widget-close:focus-visible,
|
|
412
449
|
#ilibras-widget-container .ilibras-widget-submit:focus-visible {
|
|
413
450
|
outline: 3px solid rgba(53,122,189,0.18);
|
|
414
451
|
outline-offset: 3px;
|
|
@@ -433,8 +470,8 @@ var CSS = `/**
|
|
|
433
470
|
/* Estados de erro: ver o bloco de acessibilidade no fim do arquivo. */
|
|
434
471
|
|
|
435
472
|
/* Accessibilidade */
|
|
436
|
-
.ilibras-widget-button:focus-visible,
|
|
437
|
-
.ilibras-widget-close:focus-visible,
|
|
473
|
+
#ilibras-widget-container .ilibras-widget-button:focus-visible,
|
|
474
|
+
#ilibras-widget-container .ilibras-widget-close:focus-visible,
|
|
438
475
|
#ilibras-widget-container .ilibras-widget-submit:focus-visible {
|
|
439
476
|
outline: 3px solid #4A90E2;
|
|
440
477
|
outline-offset: 2px;
|
|
@@ -459,14 +496,14 @@ var CSS = `/**
|
|
|
459
496
|
color: #b0b0b0;
|
|
460
497
|
}
|
|
461
498
|
|
|
462
|
-
.ilibras-widget-form-group input[type="text"],
|
|
499
|
+
#ilibras-widget-container .ilibras-widget-form-group input[type="text"],
|
|
463
500
|
#ilibras-widget-container .ilibras-widget-form-group input[type="tel"] {
|
|
464
501
|
background: #363636;
|
|
465
502
|
border-color: #4a4a4a;
|
|
466
503
|
color: #e0e0e0;
|
|
467
504
|
}
|
|
468
505
|
|
|
469
|
-
.ilibras-widget-form-group input[type="text"]::placeholder,
|
|
506
|
+
#ilibras-widget-container .ilibras-widget-form-group input[type="text"]::placeholder,
|
|
470
507
|
#ilibras-widget-container .ilibras-widget-form-group input[type="tel"]::placeholder {
|
|
471
508
|
color: #6c6c6c;
|
|
472
509
|
}
|
|
@@ -606,20 +643,22 @@ var CSS = `/**
|
|
|
606
643
|
font-weight: 600;
|
|
607
644
|
}
|
|
608
645
|
|
|
646
|
+
/* Fora do formulário desde a v1.6.0, então a distância vem daqui e não do gap. */
|
|
609
647
|
#ilibras-widget-container .ilibras-widget-status {
|
|
610
648
|
font-size: 13px;
|
|
611
649
|
color: #495057;
|
|
612
|
-
margin: 0;
|
|
650
|
+
margin: 14px 0 0;
|
|
613
651
|
min-height: 1em;
|
|
614
652
|
}
|
|
615
653
|
|
|
616
654
|
/* Foco visível em tudo que recebe foco, inclusive campos — o :focus original
|
|
617
655
|
trocava a sombra, que some em alto contraste. */
|
|
618
|
-
.ilibras-widget-button:focus-visible,
|
|
619
|
-
.ilibras-widget-close:focus-visible,
|
|
620
|
-
.ilibras-widget-submit:focus-visible,
|
|
621
|
-
.ilibras-widget-
|
|
622
|
-
.ilibras-widget-
|
|
656
|
+
#ilibras-widget-container .ilibras-widget-button:focus-visible,
|
|
657
|
+
#ilibras-widget-container .ilibras-widget-close:focus-visible,
|
|
658
|
+
#ilibras-widget-container .ilibras-widget-submit:focus-visible,
|
|
659
|
+
#ilibras-widget-container .ilibras-widget-agendar:focus-visible,
|
|
660
|
+
#ilibras-widget-container .ilibras-widget-form-group input:focus-visible,
|
|
661
|
+
#ilibras-widget-container .ilibras-widget-checkbox-label input:focus-visible,
|
|
623
662
|
#ilibras-widget-container .ilibras-widget-fallback a:focus-visible {
|
|
624
663
|
outline: 3px solid #1f4f7a;
|
|
625
664
|
outline-offset: 2px;
|
|
@@ -628,16 +667,17 @@ var CSS = `/**
|
|
|
628
667
|
/* Windows em alto contraste remove cor de fundo e borda sutil: sem isto o
|
|
629
668
|
campo e o botão ficam sem contorno. */
|
|
630
669
|
@media (forced-colors: active) {
|
|
631
|
-
.ilibras-widget-modal,
|
|
632
|
-
.ilibras-widget-form-group input,
|
|
633
|
-
.ilibras-widget-submit,
|
|
670
|
+
#ilibras-widget-container .ilibras-widget-modal,
|
|
671
|
+
#ilibras-widget-container .ilibras-widget-form-group input,
|
|
672
|
+
#ilibras-widget-container .ilibras-widget-submit,
|
|
634
673
|
#ilibras-widget-container .ilibras-widget-aviso {
|
|
635
674
|
border: 1px solid CanvasText;
|
|
636
675
|
}
|
|
637
676
|
|
|
638
|
-
.ilibras-widget-button:focus-visible,
|
|
639
|
-
.ilibras-widget-close:focus-visible,
|
|
640
|
-
.ilibras-widget-submit:focus-visible,
|
|
677
|
+
#ilibras-widget-container .ilibras-widget-button:focus-visible,
|
|
678
|
+
#ilibras-widget-container .ilibras-widget-close:focus-visible,
|
|
679
|
+
#ilibras-widget-container .ilibras-widget-submit:focus-visible,
|
|
680
|
+
#ilibras-widget-container .ilibras-widget-agendar:focus-visible,
|
|
641
681
|
#ilibras-widget-container .ilibras-widget-form-group input:focus-visible {
|
|
642
682
|
outline: 3px solid Highlight;
|
|
643
683
|
}
|
|
@@ -647,23 +687,23 @@ var CSS = `/**
|
|
|
647
687
|
das pessoas com sensibilidade vestibular, isso causa mal-estar. */
|
|
648
688
|
@media (prefers-reduced-motion: reduce) {
|
|
649
689
|
#ilibras-widget-container,
|
|
650
|
-
.ilibras-widget-modal,
|
|
651
|
-
.ilibras-widget-submit,
|
|
652
|
-
.ilibras-widget-close,
|
|
690
|
+
#ilibras-widget-container .ilibras-widget-modal,
|
|
691
|
+
#ilibras-widget-container .ilibras-widget-submit,
|
|
692
|
+
#ilibras-widget-container .ilibras-widget-close,
|
|
653
693
|
#ilibras-widget-container .ilibras-widget-badge {
|
|
654
694
|
animation: none !important;
|
|
655
695
|
transition: none !important;
|
|
656
696
|
}
|
|
657
697
|
|
|
658
|
-
.ilibras-widget-submit:hover,
|
|
698
|
+
#ilibras-widget-container .ilibras-widget-submit:hover,
|
|
659
699
|
#ilibras-widget-container .ilibras-widget-close:hover {
|
|
660
700
|
transform: none;
|
|
661
701
|
}
|
|
662
702
|
}
|
|
663
703
|
|
|
664
704
|
@media (prefers-color-scheme: dark) {
|
|
665
|
-
.ilibras-widget-legenda,
|
|
666
|
-
.ilibras-widget-dica,
|
|
705
|
+
#ilibras-widget-container .ilibras-widget-legenda,
|
|
706
|
+
#ilibras-widget-container .ilibras-widget-dica,
|
|
667
707
|
#ilibras-widget-container .ilibras-widget-status {
|
|
668
708
|
color: #c9c9c9;
|
|
669
709
|
}
|
|
@@ -691,10 +731,15 @@ var CSS = `/**
|
|
|
691
731
|
color: #9ecbff;
|
|
692
732
|
}
|
|
693
733
|
|
|
694
|
-
#ilibras-widget-container .ilibras-widget-title
|
|
734
|
+
#ilibras-widget-container .ilibras-widget-title,
|
|
735
|
+
#ilibras-widget-container .ilibras-widget-confirmacao-titulo {
|
|
695
736
|
color: #e6f0f8;
|
|
696
737
|
}
|
|
697
738
|
|
|
739
|
+
#ilibras-widget-container .ilibras-widget-confirmacao-texto {
|
|
740
|
+
color: #c9c9c9;
|
|
741
|
+
}
|
|
742
|
+
|
|
698
743
|
#ilibras-widget-container .ilibras-widget-header {
|
|
699
744
|
background: #1e1e1e;
|
|
700
745
|
border-left-color: #333;
|
|
@@ -722,6 +767,10 @@ var defaultConfig = {
|
|
|
722
767
|
// uma agenda que ninguém cobre é pior do que não ter o botão.
|
|
723
768
|
agendamento: true,
|
|
724
769
|
scheduleButtonText: "Agendar uma conversa",
|
|
770
|
+
// Avisa que a pessoa vai sair do site para o iLibras e espera a confirmação
|
|
771
|
+
// antes de criar o atendimento. Sair do site em que se estava, para uma aba
|
|
772
|
+
// nova, sem saber antes, desorienta — sobretudo quem usa leitor de tela.
|
|
773
|
+
confirmarRedirecionamento: true,
|
|
725
774
|
token: "",
|
|
726
775
|
zIndex: 9999,
|
|
727
776
|
apiUrl: "https://sistema.ilibras.com.br/api/public/widget/cadastrar",
|
|
@@ -752,6 +801,7 @@ var ILibrasWidget = class {
|
|
|
752
801
|
this.enviando = false;
|
|
753
802
|
this.abertoEm = null;
|
|
754
803
|
this.focoAnterior = null;
|
|
804
|
+
this.modoPendente = null;
|
|
755
805
|
this.init();
|
|
756
806
|
}
|
|
757
807
|
init() {
|
|
@@ -854,10 +904,30 @@ var ILibrasWidget = class {
|
|
|
854
904
|
<span class="ilibras-widget-dica ilibras-widget-dica-agendar" id="ilibras-widget-agendar-dica">
|
|
855
905
|
Escolha data e horário em vez de esperar na fila.
|
|
856
906
|
</span>` : ""}
|
|
857
|
-
|
|
858
|
-
<!-- Estado do envio, anunciado sem roubar o foco de quem digita. -->
|
|
859
|
-
<p class="ilibras-widget-status" id="ilibras-widget-status" role="status" aria-live="polite"></p>
|
|
860
907
|
</form>
|
|
908
|
+
|
|
909
|
+
<!-- Aviso de saída do site. Ocupa o lugar do formulário em vez de
|
|
910
|
+
abrir uma janela por cima: o diálogo já é modal, e um segundo
|
|
911
|
+
diálogo empilhado confunde quem navega por leitor de tela. -->
|
|
912
|
+
<div id="ilibras-widget-confirmacao" class="ilibras-widget-confirmacao" role="alertdialog"
|
|
913
|
+
aria-labelledby="ilibras-widget-confirmacao-titulo"
|
|
914
|
+
aria-describedby="ilibras-widget-confirmacao-texto" hidden>
|
|
915
|
+
<h3 class="ilibras-widget-confirmacao-titulo" id="ilibras-widget-confirmacao-titulo">
|
|
916
|
+
Você será redirecionado para o iLibras
|
|
917
|
+
</h3>
|
|
918
|
+
<p class="ilibras-widget-confirmacao-texto" id="ilibras-widget-confirmacao-texto"></p>
|
|
919
|
+
<button type="button" id="ilibras-widget-confirmar" class="ilibras-widget-submit">
|
|
920
|
+
Continuar para o iLibras
|
|
921
|
+
</button>
|
|
922
|
+
<button type="button" id="ilibras-widget-voltar" class="ilibras-widget-agendar">
|
|
923
|
+
Voltar
|
|
924
|
+
</button>
|
|
925
|
+
</div>
|
|
926
|
+
|
|
927
|
+
<!-- Estado do envio, anunciado sem roubar o foco de quem digita. Fica
|
|
928
|
+
fora do formulário: escondido junto com ele durante o aviso de
|
|
929
|
+
saída, o leitor de tela deixaria de anunciar o que acontece. -->
|
|
930
|
+
<p class="ilibras-widget-status" id="ilibras-widget-status" role="status" aria-live="polite"></p>
|
|
861
931
|
</div>
|
|
862
932
|
</div>
|
|
863
933
|
`;
|
|
@@ -870,6 +940,10 @@ var ILibrasWidget = class {
|
|
|
870
940
|
this.agendar = container.querySelector("#ilibras-widget-agendar");
|
|
871
941
|
this.aviso = container.querySelector("#ilibras-widget-aviso");
|
|
872
942
|
this.status = container.querySelector("#ilibras-widget-status");
|
|
943
|
+
this.confirmacao = container.querySelector("#ilibras-widget-confirmacao");
|
|
944
|
+
this.confirmacaoTexto = container.querySelector("#ilibras-widget-confirmacao-texto");
|
|
945
|
+
this.confirmar = container.querySelector("#ilibras-widget-confirmar");
|
|
946
|
+
this.voltar = container.querySelector("#ilibras-widget-voltar");
|
|
873
947
|
}
|
|
874
948
|
escapar(texto) {
|
|
875
949
|
const div = document.createElement("div");
|
|
@@ -882,6 +956,10 @@ var ILibrasWidget = class {
|
|
|
882
956
|
this.modal.addEventListener("keydown", (e) => {
|
|
883
957
|
if (e.key === "Escape") {
|
|
884
958
|
e.stopPropagation();
|
|
959
|
+
if (!this.confirmacao.hidden) {
|
|
960
|
+
if (!this.enviando) this.cancelarConfirmacao();
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
885
963
|
this.closeWidget();
|
|
886
964
|
return;
|
|
887
965
|
}
|
|
@@ -897,6 +975,8 @@ var ILibrasWidget = class {
|
|
|
897
975
|
if (this.agendar) {
|
|
898
976
|
this.agendar.addEventListener("click", (e) => this.handleSubmit(e, "agendamento"));
|
|
899
977
|
}
|
|
978
|
+
this.confirmar.addEventListener("click", () => this.confirmarRedirecionamento());
|
|
979
|
+
this.voltar.addEventListener("click", () => this.cancelarConfirmacao());
|
|
900
980
|
}
|
|
901
981
|
prenderFoco(evento) {
|
|
902
982
|
const focaveis = Array.from(this.modal.querySelectorAll(FOCAVEIS)).filter((el) => el.offsetParent !== null || el === document.activeElement);
|
|
@@ -926,6 +1006,7 @@ var ILibrasWidget = class {
|
|
|
926
1006
|
this.container.querySelector("#ilibras-name").focus();
|
|
927
1007
|
}
|
|
928
1008
|
closeWidget() {
|
|
1009
|
+
this.mostrarFormulario();
|
|
929
1010
|
this.modal.classList.remove("ilibras-widget-modal-open");
|
|
930
1011
|
this.botao.classList.remove("ilibras-widget-button-open");
|
|
931
1012
|
this.botao.setAttribute("aria-expanded", "false");
|
|
@@ -1093,6 +1174,85 @@ var ILibrasWidget = class {
|
|
|
1093
1174
|
invalido.focus();
|
|
1094
1175
|
return;
|
|
1095
1176
|
}
|
|
1177
|
+
if (this.config.confirmarRedirecionamento) {
|
|
1178
|
+
this.pedirConfirmacao(modo);
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
await this.criarAtendimento(modo);
|
|
1182
|
+
}
|
|
1183
|
+
// ─── Aviso de saída ─────────────────────────────────────────────────────
|
|
1184
|
+
/**
|
|
1185
|
+
* Troca o formulário pelo aviso de que a pessoa vai para o iLibras. Nada é
|
|
1186
|
+
* enviado ainda: o atendimento só nasce no "Continuar".
|
|
1187
|
+
*/
|
|
1188
|
+
pedirConfirmacao(modo) {
|
|
1189
|
+
this.modoPendente = modo;
|
|
1190
|
+
this.confirmacaoTexto.textContent = modo === "agendamento" ? "O agendamento é feito no site do iLibras, que abre em uma nova aba. Lá você escolhe o dia e o horário da conversa." : "O atendimento em Libras acontece no site do iLibras, que abre em uma nova aba. Lá você entra na fila e aguarda um intérprete.";
|
|
1191
|
+
this.confirmar.textContent = "Continuar para o iLibras";
|
|
1192
|
+
this.form.hidden = true;
|
|
1193
|
+
this.confirmacao.hidden = false;
|
|
1194
|
+
this.anunciar("");
|
|
1195
|
+
this.confirmar.focus();
|
|
1196
|
+
}
|
|
1197
|
+
/** "Voltar": o formulário reaparece como estava, com o nome digitado. */
|
|
1198
|
+
cancelarConfirmacao() {
|
|
1199
|
+
if (this.enviando) return;
|
|
1200
|
+
const modo = this.modoPendente;
|
|
1201
|
+
this.mostrarFormulario();
|
|
1202
|
+
const origem = modo === "agendamento" && this.agendar ? this.agendar : this.submit;
|
|
1203
|
+
origem.focus();
|
|
1204
|
+
}
|
|
1205
|
+
mostrarFormulario() {
|
|
1206
|
+
this.modoPendente = null;
|
|
1207
|
+
this.confirmacao.hidden = true;
|
|
1208
|
+
this.form.hidden = false;
|
|
1209
|
+
}
|
|
1210
|
+
async confirmarRedirecionamento() {
|
|
1211
|
+
if (this.enviando || !this.modoPendente) return;
|
|
1212
|
+
const aba = this.reservarAba();
|
|
1213
|
+
await this.criarAtendimento(this.modoPendente, aba);
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Abre uma aba em branco para receber o iLibras assim que o atendimento
|
|
1217
|
+
* existir. Devolve null quando o navegador barra — aí vale o caminho antigo.
|
|
1218
|
+
*/
|
|
1219
|
+
reservarAba() {
|
|
1220
|
+
let aba = null;
|
|
1221
|
+
try {
|
|
1222
|
+
aba = window.open("", "_blank");
|
|
1223
|
+
} catch (e) {
|
|
1224
|
+
aba = null;
|
|
1225
|
+
}
|
|
1226
|
+
if (!aba) return null;
|
|
1227
|
+
aba.opener = null;
|
|
1228
|
+
try {
|
|
1229
|
+
const doc = aba.document;
|
|
1230
|
+
doc.title = "Abrindo o iLibras…";
|
|
1231
|
+
doc.documentElement.lang = "pt-BR";
|
|
1232
|
+
doc.body.style.cssText = "font:16px/1.5 system-ui,-apple-system,Segoe UI,sans-serif;padding:32px;color:#073657";
|
|
1233
|
+
doc.body.textContent = "Abrindo o iLibras…";
|
|
1234
|
+
} catch (e) {
|
|
1235
|
+
}
|
|
1236
|
+
return aba;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Leva a pessoa ao endereço devolvido pelo iLibras: na aba reservada quando
|
|
1240
|
+
* ela existe, numa aba nova quando não, e na atual como último recurso.
|
|
1241
|
+
*/
|
|
1242
|
+
irPara(destino, abaReservada) {
|
|
1243
|
+
if (abaReservada && !abaReservada.closed) {
|
|
1244
|
+
abaReservada.location.href = destino;
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
const aba = window.open(destino, "_blank");
|
|
1248
|
+
if (aba) {
|
|
1249
|
+
aba.opener = null;
|
|
1250
|
+
} else {
|
|
1251
|
+
window.location.assign(destino);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
// ─── Criação do atendimento ─────────────────────────────────────────────
|
|
1255
|
+
async criarAtendimento(modo, abaReservada = null) {
|
|
1096
1256
|
const v = this.valores();
|
|
1097
1257
|
const corpo = new FormData();
|
|
1098
1258
|
corpo.append("nome", v.nome);
|
|
@@ -1105,15 +1265,17 @@ var ILibrasWidget = class {
|
|
|
1105
1265
|
const destino = resultado.link_fila || resultado.link || resultado.url || resultado.redirect;
|
|
1106
1266
|
if (!destino) throw new FalhaDeServico("resposta_inesperada");
|
|
1107
1267
|
this.anunciar(modo === "agendamento" ? "Cadastro feito. Abrindo o calendário para escolher data e horário." : "Atendimento criado. Abrindo a sala de atendimento.");
|
|
1108
|
-
|
|
1109
|
-
if (aba) {
|
|
1110
|
-
aba.opener = null;
|
|
1111
|
-
} else {
|
|
1112
|
-
window.location.assign(destino);
|
|
1113
|
-
}
|
|
1268
|
+
this.irPara(destino, abaReservada);
|
|
1114
1269
|
this.form.reset();
|
|
1115
1270
|
this.closeWidget();
|
|
1116
1271
|
} catch (erro) {
|
|
1272
|
+
if (abaReservada && !abaReservada.closed) {
|
|
1273
|
+
try {
|
|
1274
|
+
abaReservada.close();
|
|
1275
|
+
} catch (e) {
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
this.mostrarFormulario();
|
|
1117
1279
|
this.tratarFalha(erro);
|
|
1118
1280
|
} finally {
|
|
1119
1281
|
this.travarEnvio(false, modo);
|
|
@@ -1121,14 +1283,25 @@ var ILibrasWidget = class {
|
|
|
1121
1283
|
}
|
|
1122
1284
|
travarEnvio(travado, modo = "fila") {
|
|
1123
1285
|
this.enviando = travado;
|
|
1124
|
-
for (const botao of [this.submit, this.agendar]) {
|
|
1286
|
+
for (const botao of [this.submit, this.agendar, this.confirmar, this.voltar]) {
|
|
1125
1287
|
if (botao) botao.disabled = travado;
|
|
1126
1288
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1289
|
+
let ativo;
|
|
1290
|
+
let rotulo;
|
|
1291
|
+
if (!this.confirmacao.hidden) {
|
|
1292
|
+
ativo = this.confirmar;
|
|
1293
|
+
rotulo = "Continuar para o iLibras";
|
|
1294
|
+
} else {
|
|
1295
|
+
const usouAgendar = modo === "agendamento" && this.agendar;
|
|
1296
|
+
ativo = usouAgendar ? this.agendar : this.submit;
|
|
1297
|
+
rotulo = usouAgendar ? this.config.scheduleButtonText : this.config.buttonText;
|
|
1298
|
+
}
|
|
1130
1299
|
ativo.setAttribute("aria-busy", travado ? "true" : "false");
|
|
1131
1300
|
ativo.textContent = travado ? "Enviando..." : rotulo;
|
|
1301
|
+
if (!travado) {
|
|
1302
|
+
this.confirmar.setAttribute("aria-busy", "false");
|
|
1303
|
+
this.confirmar.textContent = "Continuar para o iLibras";
|
|
1304
|
+
}
|
|
1132
1305
|
if (travado) this.anunciar("Enviando seus dados. Aguarde.");
|
|
1133
1306
|
}
|
|
1134
1307
|
/**
|
package/index.d.ts
CHANGED
|
@@ -42,6 +42,15 @@ export interface ILibrasConfig {
|
|
|
42
42
|
/** Texto do botão de agendamento. Padrão: `'Agendar uma conversa'`. */
|
|
43
43
|
scheduleButtonText?: string;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Avisa que a pessoa vai para o site do iLibras, numa aba nova, e espera a
|
|
47
|
+
* confirmação antes de criar o atendimento. Padrão: `true`.
|
|
48
|
+
*
|
|
49
|
+
* Com `false`, o widget volta ao comportamento anterior à v1.6.0: cria o
|
|
50
|
+
* atendimento e abre o iLibras direto do botão.
|
|
51
|
+
*/
|
|
52
|
+
confirmarRedirecionamento?: boolean;
|
|
53
|
+
|
|
45
54
|
/** Empilhamento. Padrão: `9999`. */
|
|
46
55
|
zIndex?: number;
|
|
47
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ilibras-widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|