sweetalert2 11.4.14 → 11.4.17
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/README.md +3 -3
- package/dist/sweetalert2.all.js +421 -71
- package/dist/sweetalert2.all.min.js +1 -1
- package/dist/sweetalert2.js +421 -71
- package/dist/sweetalert2.min.js +1 -1
- package/package.json +3 -3
- package/src/SweetAlert.js +27 -7
- package/src/globalState.js +8 -2
- package/src/instanceMethods/_destroy.js +12 -6
- package/src/keydown-handler.js +47 -4
- package/src/staticMethods/showLoading.js +2 -2
- package/src/types.js +35 -0
- package/src/utils/classes.js +4 -0
- package/src/utils/defaultInputValidators.js +10 -0
- package/src/utils/dom/animationEndEvent.js +3 -0
- package/src/utils/dom/domUtils.js +44 -3
- package/src/utils/dom/getters.js +68 -1
- package/src/utils/dom/init.js +32 -2
- package/src/utils/dom/measureScrollbar.js +6 -2
- package/src/utils/dom/parseHtmlToContainer.js +4 -0
- package/src/utils/dom/renderers/render.js +4 -0
- package/src/utils/dom/renderers/renderActions.js +20 -0
- package/src/utils/dom/renderers/renderCloseButton.js +4 -0
- package/src/utils/dom/renderers/renderContainer.js +32 -16
- package/src/utils/dom/renderers/renderContent.js +4 -0
- package/src/utils/dom/renderers/renderFooter.js +4 -0
- package/src/utils/dom/renderers/renderIcon.js +17 -13
- package/src/utils/dom/renderers/renderImage.js +0 -5
- package/src/utils/dom/renderers/renderInput.js +0 -2
- package/src/utils/dom/renderers/renderPopup.js +0 -5
- package/src/utils/dom/renderers/renderProgressSteps.js +0 -5
- package/src/utils/dom/renderers/renderTitle.js +4 -0
- package/src/utils/setParameters.js +7 -1
- package/src/utils/utils.js +1 -1
- package/sweetalert2.d.ts +4 -1
package/dist/sweetalert2.all.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sweetalert2 v11.4.
|
|
2
|
+
* sweetalert2 v11.4.17
|
|
3
3
|
* Released under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
|
|
35
35
|
/**
|
|
36
|
-
* @param {NodeList | HTMLCollection | NamedNodeMap} nodeList
|
|
36
|
+
* @param {NodeList | HTMLCollection | NamedNodeMap | DOMTokenList} nodeList
|
|
37
37
|
* @returns {array}
|
|
38
38
|
*/
|
|
39
39
|
|
|
@@ -249,6 +249,11 @@
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
const swalPrefix = 'swal2-';
|
|
252
|
+
/**
|
|
253
|
+
* @param {string[]} items
|
|
254
|
+
* @returns {object}
|
|
255
|
+
*/
|
|
256
|
+
|
|
252
257
|
const prefix = items => {
|
|
253
258
|
const result = {};
|
|
254
259
|
|
|
@@ -268,33 +273,110 @@
|
|
|
268
273
|
*/
|
|
269
274
|
|
|
270
275
|
const getContainer = () => document.body.querySelector(".".concat(swalClasses.container));
|
|
276
|
+
/**
|
|
277
|
+
* @param {string} selectorString
|
|
278
|
+
* @returns {HTMLElement | null}
|
|
279
|
+
*/
|
|
280
|
+
|
|
271
281
|
const elementBySelector = selectorString => {
|
|
272
282
|
const container = getContainer();
|
|
273
283
|
return container ? container.querySelector(selectorString) : null;
|
|
274
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* @param {string} className
|
|
287
|
+
* @returns {HTMLElement | null}
|
|
288
|
+
*/
|
|
275
289
|
|
|
276
290
|
const elementByClass = className => {
|
|
277
291
|
return elementBySelector(".".concat(className));
|
|
278
292
|
};
|
|
293
|
+
/**
|
|
294
|
+
* @returns {HTMLElement | null}
|
|
295
|
+
*/
|
|
296
|
+
|
|
279
297
|
|
|
280
298
|
const getPopup = () => elementByClass(swalClasses.popup);
|
|
299
|
+
/**
|
|
300
|
+
* @returns {HTMLElement | null}
|
|
301
|
+
*/
|
|
302
|
+
|
|
281
303
|
const getIcon = () => elementByClass(swalClasses.icon);
|
|
304
|
+
/**
|
|
305
|
+
* @returns {HTMLElement | null}
|
|
306
|
+
*/
|
|
307
|
+
|
|
282
308
|
const getTitle = () => elementByClass(swalClasses.title);
|
|
309
|
+
/**
|
|
310
|
+
* @returns {HTMLElement | null}
|
|
311
|
+
*/
|
|
312
|
+
|
|
283
313
|
const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
|
|
314
|
+
/**
|
|
315
|
+
* @returns {HTMLElement | null}
|
|
316
|
+
*/
|
|
317
|
+
|
|
284
318
|
const getImage = () => elementByClass(swalClasses.image);
|
|
319
|
+
/**
|
|
320
|
+
* @returns {HTMLElement | null}
|
|
321
|
+
*/
|
|
322
|
+
|
|
285
323
|
const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
|
|
324
|
+
/**
|
|
325
|
+
* @returns {HTMLElement | null}
|
|
326
|
+
*/
|
|
327
|
+
|
|
286
328
|
const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
|
|
329
|
+
/**
|
|
330
|
+
* @returns {HTMLElement | null}
|
|
331
|
+
*/
|
|
332
|
+
|
|
287
333
|
const getConfirmButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.confirm));
|
|
334
|
+
/**
|
|
335
|
+
* @returns {HTMLElement | null}
|
|
336
|
+
*/
|
|
337
|
+
|
|
288
338
|
const getDenyButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.deny));
|
|
339
|
+
/**
|
|
340
|
+
* @returns {HTMLElement | null}
|
|
341
|
+
*/
|
|
342
|
+
|
|
289
343
|
const getInputLabel = () => elementByClass(swalClasses['input-label']);
|
|
344
|
+
/**
|
|
345
|
+
* @returns {HTMLElement | null}
|
|
346
|
+
*/
|
|
347
|
+
|
|
290
348
|
const getLoader = () => elementBySelector(".".concat(swalClasses.loader));
|
|
349
|
+
/**
|
|
350
|
+
* @returns {HTMLElement | null}
|
|
351
|
+
*/
|
|
352
|
+
|
|
291
353
|
const getCancelButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.cancel));
|
|
354
|
+
/**
|
|
355
|
+
* @returns {HTMLElement | null}
|
|
356
|
+
*/
|
|
357
|
+
|
|
292
358
|
const getActions = () => elementByClass(swalClasses.actions);
|
|
359
|
+
/**
|
|
360
|
+
* @returns {HTMLElement | null}
|
|
361
|
+
*/
|
|
362
|
+
|
|
293
363
|
const getFooter = () => elementByClass(swalClasses.footer);
|
|
364
|
+
/**
|
|
365
|
+
* @returns {HTMLElement | null}
|
|
366
|
+
*/
|
|
367
|
+
|
|
294
368
|
const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
|
|
369
|
+
/**
|
|
370
|
+
* @returns {HTMLElement | null}
|
|
371
|
+
*/
|
|
372
|
+
|
|
295
373
|
const getCloseButton = () => elementByClass(swalClasses.close); // https://github.com/jkup/focusable/blob/master/index.js
|
|
296
374
|
|
|
297
375
|
const focusable = "\n a[href],\n area[href],\n input:not([disabled]),\n select:not([disabled]),\n textarea:not([disabled]),\n button:not([disabled]),\n iframe,\n object,\n embed,\n [tabindex=\"0\"],\n [contenteditable],\n audio[controls],\n video[controls],\n summary\n";
|
|
376
|
+
/**
|
|
377
|
+
* @returns {HTMLElement[]}
|
|
378
|
+
*/
|
|
379
|
+
|
|
298
380
|
const getFocusableElements = () => {
|
|
299
381
|
const focusableElementsWithTabindex = toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')) // sort according to tabindex
|
|
300
382
|
.sort((a, b) => {
|
|
@@ -312,12 +394,24 @@
|
|
|
312
394
|
const otherFocusableElements = toArray(getPopup().querySelectorAll(focusable)).filter(el => el.getAttribute('tabindex') !== '-1');
|
|
313
395
|
return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter(el => isVisible(el));
|
|
314
396
|
};
|
|
397
|
+
/**
|
|
398
|
+
* @returns {boolean}
|
|
399
|
+
*/
|
|
400
|
+
|
|
315
401
|
const isModal = () => {
|
|
316
402
|
return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
|
|
317
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* @returns {boolean}
|
|
406
|
+
*/
|
|
407
|
+
|
|
318
408
|
const isToast = () => {
|
|
319
409
|
return getPopup() && hasClass(getPopup(), swalClasses.toast);
|
|
320
410
|
};
|
|
411
|
+
/**
|
|
412
|
+
* @returns {boolean}
|
|
413
|
+
*/
|
|
414
|
+
|
|
321
415
|
const isLoading = () => {
|
|
322
416
|
return getPopup().hasAttribute('data-loading');
|
|
323
417
|
};
|
|
@@ -368,6 +462,10 @@
|
|
|
368
462
|
|
|
369
463
|
return true;
|
|
370
464
|
};
|
|
465
|
+
/**
|
|
466
|
+
* @param {HTMLElement} elem
|
|
467
|
+
* @param {SweetAlertOptions} params
|
|
468
|
+
*/
|
|
371
469
|
|
|
372
470
|
const removeCustomClasses = (elem, params) => {
|
|
373
471
|
toArray(elem.classList).forEach(className => {
|
|
@@ -376,6 +474,12 @@
|
|
|
376
474
|
}
|
|
377
475
|
});
|
|
378
476
|
};
|
|
477
|
+
/**
|
|
478
|
+
* @param {HTMLElement} elem
|
|
479
|
+
* @param {SweetAlertOptions} params
|
|
480
|
+
* @param {string} className
|
|
481
|
+
*/
|
|
482
|
+
|
|
379
483
|
|
|
380
484
|
const applyCustomClass = (elem, params, className) => {
|
|
381
485
|
removeCustomClasses(elem, params);
|
|
@@ -523,20 +627,55 @@
|
|
|
523
627
|
const hide = elem => {
|
|
524
628
|
elem.style.display = 'none';
|
|
525
629
|
};
|
|
630
|
+
/**
|
|
631
|
+
* @param {HTMLElement} parent
|
|
632
|
+
* @param {string} selector
|
|
633
|
+
* @param {string} property
|
|
634
|
+
* @param {string} value
|
|
635
|
+
*/
|
|
636
|
+
|
|
526
637
|
const setStyle = (parent, selector, property, value) => {
|
|
638
|
+
/** @type {HTMLElement} */
|
|
527
639
|
const el = parent.querySelector(selector);
|
|
528
640
|
|
|
529
641
|
if (el) {
|
|
530
642
|
el.style[property] = value;
|
|
531
643
|
}
|
|
532
644
|
};
|
|
533
|
-
|
|
645
|
+
/**
|
|
646
|
+
* @param {HTMLElement} elem
|
|
647
|
+
* @param {any} condition
|
|
648
|
+
* @param {string} display
|
|
649
|
+
*/
|
|
650
|
+
|
|
651
|
+
const toggle = function (elem, condition) {
|
|
652
|
+
let display = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'flex';
|
|
534
653
|
condition ? show(elem, display) : hide(elem);
|
|
535
|
-
};
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* borrowed from jquery $(elem).is(':visible') implementation
|
|
657
|
+
*
|
|
658
|
+
* @param {HTMLElement} elem
|
|
659
|
+
* @returns {boolean}
|
|
660
|
+
*/
|
|
536
661
|
|
|
537
662
|
const isVisible = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
|
|
663
|
+
/**
|
|
664
|
+
* @returns {boolean}
|
|
665
|
+
*/
|
|
666
|
+
|
|
538
667
|
const allButtonsAreHidden = () => !isVisible(getConfirmButton()) && !isVisible(getDenyButton()) && !isVisible(getCancelButton());
|
|
539
|
-
|
|
668
|
+
/**
|
|
669
|
+
* @returns {boolean}
|
|
670
|
+
*/
|
|
671
|
+
|
|
672
|
+
const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight);
|
|
673
|
+
/**
|
|
674
|
+
* borrowed from https://stackoverflow.com/a/46352119
|
|
675
|
+
*
|
|
676
|
+
* @param {HTMLElement} elem
|
|
677
|
+
* @returns {boolean}
|
|
678
|
+
*/
|
|
540
679
|
|
|
541
680
|
const hasCssAnimation = elem => {
|
|
542
681
|
const style = window.getComputedStyle(elem);
|
|
@@ -544,6 +683,11 @@
|
|
|
544
683
|
const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
|
|
545
684
|
return animDuration > 0 || transDuration > 0;
|
|
546
685
|
};
|
|
686
|
+
/**
|
|
687
|
+
* @param {number} timer
|
|
688
|
+
* @param {boolean} reset
|
|
689
|
+
*/
|
|
690
|
+
|
|
547
691
|
const animateTimerProgressBar = function (timer) {
|
|
548
692
|
let reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
549
693
|
const timerProgressBar = getTimerProgressBar();
|
|
@@ -580,16 +724,24 @@
|
|
|
580
724
|
|
|
581
725
|
const RESTORE_FOCUS_TIMEOUT = 100;
|
|
582
726
|
|
|
727
|
+
/** @type {GlobalState} */
|
|
728
|
+
|
|
583
729
|
const globalState = {};
|
|
584
730
|
|
|
585
731
|
const focusPreviousActiveElement = () => {
|
|
586
|
-
if (globalState.previousActiveElement
|
|
732
|
+
if (globalState.previousActiveElement instanceof HTMLElement) {
|
|
587
733
|
globalState.previousActiveElement.focus();
|
|
588
734
|
globalState.previousActiveElement = null;
|
|
589
735
|
} else if (document.body) {
|
|
590
736
|
document.body.focus();
|
|
591
737
|
}
|
|
592
|
-
};
|
|
738
|
+
};
|
|
739
|
+
/**
|
|
740
|
+
* Restore previous active (focused) element
|
|
741
|
+
*
|
|
742
|
+
* @param {boolean} returnFocus
|
|
743
|
+
* @returns {Promise}
|
|
744
|
+
*/
|
|
593
745
|
|
|
594
746
|
|
|
595
747
|
const restoreActiveElement = returnFocus => {
|
|
@@ -610,6 +762,9 @@
|
|
|
610
762
|
};
|
|
611
763
|
|
|
612
764
|
const sweetHTML = "\n <div aria-labelledby=\"".concat(swalClasses.title, "\" aria-describedby=\"").concat(swalClasses['html-container'], "\" class=\"").concat(swalClasses.popup, "\" tabindex=\"-1\">\n <button type=\"button\" class=\"").concat(swalClasses.close, "\"></button>\n <ul class=\"").concat(swalClasses['progress-steps'], "\"></ul>\n <div class=\"").concat(swalClasses.icon, "\"></div>\n <img class=\"").concat(swalClasses.image, "\" />\n <h2 class=\"").concat(swalClasses.title, "\" id=\"").concat(swalClasses.title, "\"></h2>\n <div class=\"").concat(swalClasses['html-container'], "\" id=\"").concat(swalClasses['html-container'], "\"></div>\n <input class=\"").concat(swalClasses.input, "\" />\n <input type=\"file\" class=\"").concat(swalClasses.file, "\" />\n <div class=\"").concat(swalClasses.range, "\">\n <input type=\"range\" />\n <output></output>\n </div>\n <select class=\"").concat(swalClasses.select, "\"></select>\n <div class=\"").concat(swalClasses.radio, "\"></div>\n <label for=\"").concat(swalClasses.checkbox, "\" class=\"").concat(swalClasses.checkbox, "\">\n <input type=\"checkbox\" />\n <span class=\"").concat(swalClasses.label, "\"></span>\n </label>\n <textarea class=\"").concat(swalClasses.textarea, "\"></textarea>\n <div class=\"").concat(swalClasses['validation-message'], "\" id=\"").concat(swalClasses['validation-message'], "\"></div>\n <div class=\"").concat(swalClasses.actions, "\">\n <div class=\"").concat(swalClasses.loader, "\"></div>\n <button type=\"button\" class=\"").concat(swalClasses.confirm, "\"></button>\n <button type=\"button\" class=\"").concat(swalClasses.deny, "\"></button>\n <button type=\"button\" class=\"").concat(swalClasses.cancel, "\"></button>\n </div>\n <div class=\"").concat(swalClasses.footer, "\"></div>\n <div class=\"").concat(swalClasses['timer-progress-bar-container'], "\">\n <div class=\"").concat(swalClasses['timer-progress-bar'], "\"></div>\n </div>\n </div>\n").replace(/(^|\n)\s*/g, '');
|
|
765
|
+
/**
|
|
766
|
+
* @returns {boolean}
|
|
767
|
+
*/
|
|
613
768
|
|
|
614
769
|
const resetOldContainer = () => {
|
|
615
770
|
const oldContainer = getContainer();
|
|
@@ -631,9 +786,15 @@
|
|
|
631
786
|
const popup = getPopup();
|
|
632
787
|
const input = getDirectChildByClass(popup, swalClasses.input);
|
|
633
788
|
const file = getDirectChildByClass(popup, swalClasses.file);
|
|
789
|
+
/** @type {HTMLInputElement} */
|
|
790
|
+
|
|
634
791
|
const range = popup.querySelector(".".concat(swalClasses.range, " input"));
|
|
792
|
+
/** @type {HTMLOutputElement} */
|
|
793
|
+
|
|
635
794
|
const rangeOutput = popup.querySelector(".".concat(swalClasses.range, " output"));
|
|
636
795
|
const select = getDirectChildByClass(popup, swalClasses.select);
|
|
796
|
+
/** @type {HTMLInputElement} */
|
|
797
|
+
|
|
637
798
|
const checkbox = popup.querySelector(".".concat(swalClasses.checkbox, " input"));
|
|
638
799
|
const textarea = getDirectChildByClass(popup, swalClasses.textarea);
|
|
639
800
|
input.oninput = resetValidationMessage;
|
|
@@ -649,11 +810,20 @@
|
|
|
649
810
|
|
|
650
811
|
range.onchange = () => {
|
|
651
812
|
resetValidationMessage();
|
|
652
|
-
|
|
813
|
+
rangeOutput.value = range.value;
|
|
653
814
|
};
|
|
654
815
|
};
|
|
816
|
+
/**
|
|
817
|
+
* @param {string | HTMLElement} target
|
|
818
|
+
* @returns {HTMLElement}
|
|
819
|
+
*/
|
|
820
|
+
|
|
655
821
|
|
|
656
822
|
const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;
|
|
823
|
+
/**
|
|
824
|
+
* @param {SweetAlertOptions} params
|
|
825
|
+
*/
|
|
826
|
+
|
|
657
827
|
|
|
658
828
|
const setupAccessibility = params => {
|
|
659
829
|
const popup = getPopup();
|
|
@@ -664,14 +834,20 @@
|
|
|
664
834
|
popup.setAttribute('aria-modal', 'true');
|
|
665
835
|
}
|
|
666
836
|
};
|
|
837
|
+
/**
|
|
838
|
+
* @param {HTMLElement} targetElement
|
|
839
|
+
*/
|
|
840
|
+
|
|
667
841
|
|
|
668
842
|
const setupRTL = targetElement => {
|
|
669
843
|
if (window.getComputedStyle(targetElement).direction === 'rtl') {
|
|
670
844
|
addClass(getContainer(), swalClasses.rtl);
|
|
671
845
|
}
|
|
672
846
|
};
|
|
673
|
-
|
|
847
|
+
/**
|
|
674
848
|
* Add modal + backdrop + no-war message for Russians to DOM
|
|
849
|
+
*
|
|
850
|
+
* @param {SweetAlertOptions} params
|
|
675
851
|
*/
|
|
676
852
|
|
|
677
853
|
|
|
@@ -700,6 +876,10 @@
|
|
|
700
876
|
addInputChangeListeners();
|
|
701
877
|
noWarMessageForRussians(container, params);
|
|
702
878
|
};
|
|
879
|
+
/**
|
|
880
|
+
* @param {HTMLElement} container
|
|
881
|
+
* @param {SweetAlertOptions} params
|
|
882
|
+
*/
|
|
703
883
|
|
|
704
884
|
const noWarMessageForRussians = (container, params) => {
|
|
705
885
|
if (params.toast) {
|
|
@@ -730,6 +910,12 @@
|
|
|
730
910
|
}, {
|
|
731
911
|
text: 'ФИНСКИЙ ДРУГ РОССИИ <br> говорит ПО-РУССКИ о спецоперации',
|
|
732
912
|
youtubeId: 'hkCYb6edUrQ'
|
|
913
|
+
}, {
|
|
914
|
+
text: 'ЮРИЙ ПОДОЛЯКА честно <br> о генералах РУССКОЙ АРМИИ',
|
|
915
|
+
youtubeId: 'w4-_8BJKfpk'
|
|
916
|
+
}, {
|
|
917
|
+
text: 'Полковник ФСБ СТРЕЛКОВ <br> об успехах РОССИИ в спецоперации',
|
|
918
|
+
youtubeId: 'saK5UTKroDA'
|
|
733
919
|
}]); // The message will only be shown to Russian users visiting Russian sites
|
|
734
920
|
|
|
735
921
|
if (navigator.language === 'ru' && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
|
|
@@ -772,6 +958,11 @@
|
|
|
772
958
|
setInnerHtml(target, param.toString());
|
|
773
959
|
}
|
|
774
960
|
};
|
|
961
|
+
/**
|
|
962
|
+
* @param {HTMLElement} target
|
|
963
|
+
* @param {HTMLElement} elem
|
|
964
|
+
*/
|
|
965
|
+
|
|
775
966
|
|
|
776
967
|
const handleJqueryElem = (target, elem) => {
|
|
777
968
|
target.textContent = '';
|
|
@@ -785,6 +976,10 @@
|
|
|
785
976
|
}
|
|
786
977
|
};
|
|
787
978
|
|
|
979
|
+
/**
|
|
980
|
+
* @returns {'webkitAnimationEnd' | 'animationend' | false}
|
|
981
|
+
*/
|
|
982
|
+
|
|
788
983
|
const animationEndEvent = (() => {
|
|
789
984
|
// Prevent run in Node env
|
|
790
985
|
|
|
@@ -810,7 +1005,12 @@
|
|
|
810
1005
|
return false;
|
|
811
1006
|
})();
|
|
812
1007
|
|
|
813
|
-
|
|
1008
|
+
/**
|
|
1009
|
+
* Measure scrollbar width for padding body during modal show/hide
|
|
1010
|
+
* https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
|
|
1011
|
+
*
|
|
1012
|
+
* @returns {number}
|
|
1013
|
+
*/
|
|
814
1014
|
|
|
815
1015
|
const measureScrollbar = () => {
|
|
816
1016
|
const scrollDiv = document.createElement('div');
|
|
@@ -821,6 +1021,11 @@
|
|
|
821
1021
|
return scrollbarWidth;
|
|
822
1022
|
};
|
|
823
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
* @param {SweetAlert2} instance
|
|
1026
|
+
* @param {SweetAlertOptions} params
|
|
1027
|
+
*/
|
|
1028
|
+
|
|
824
1029
|
const renderActions = (instance, params) => {
|
|
825
1030
|
const actions = getActions();
|
|
826
1031
|
const loader = getLoader(); // Actions (buttons) wrapper
|
|
@@ -839,6 +1044,11 @@
|
|
|
839
1044
|
setInnerHtml(loader, params.loaderHtml);
|
|
840
1045
|
applyCustomClass(loader, params, 'loader');
|
|
841
1046
|
};
|
|
1047
|
+
/**
|
|
1048
|
+
* @param {HTMLElement} actions
|
|
1049
|
+
* @param {HTMLElement} loader
|
|
1050
|
+
* @param {SweetAlertOptions} params
|
|
1051
|
+
*/
|
|
842
1052
|
|
|
843
1053
|
function renderButtons(actions, loader, params) {
|
|
844
1054
|
const confirmButton = getConfirmButton();
|
|
@@ -861,6 +1071,13 @@
|
|
|
861
1071
|
}
|
|
862
1072
|
}
|
|
863
1073
|
}
|
|
1074
|
+
/**
|
|
1075
|
+
* @param {HTMLElement} confirmButton
|
|
1076
|
+
* @param {HTMLElement} denyButton
|
|
1077
|
+
* @param {HTMLElement} cancelButton
|
|
1078
|
+
* @param {SweetAlertOptions} params
|
|
1079
|
+
*/
|
|
1080
|
+
|
|
864
1081
|
|
|
865
1082
|
function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
|
|
866
1083
|
if (!params.buttonsStyling) {
|
|
@@ -884,6 +1101,12 @@
|
|
|
884
1101
|
addClass(cancelButton, swalClasses['default-outline']);
|
|
885
1102
|
}
|
|
886
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* @param {HTMLElement} button
|
|
1106
|
+
* @param {'confirm' | 'deny' | 'cancel'} buttonType
|
|
1107
|
+
* @param {SweetAlertOptions} params
|
|
1108
|
+
*/
|
|
1109
|
+
|
|
887
1110
|
|
|
888
1111
|
function renderButton(button, buttonType, params) {
|
|
889
1112
|
toggle(button, params["show".concat(capitalizeFirstLetter(buttonType), "Button")], 'inline-block');
|
|
@@ -897,6 +1120,29 @@
|
|
|
897
1120
|
addClass(button, params["".concat(buttonType, "ButtonClass")]);
|
|
898
1121
|
}
|
|
899
1122
|
|
|
1123
|
+
/**
|
|
1124
|
+
* @param {SweetAlert2} instance
|
|
1125
|
+
* @param {SweetAlertOptions} params
|
|
1126
|
+
*/
|
|
1127
|
+
|
|
1128
|
+
const renderContainer = (instance, params) => {
|
|
1129
|
+
const container = getContainer();
|
|
1130
|
+
|
|
1131
|
+
if (!container) {
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
handleBackdropParam(container, params.backdrop);
|
|
1136
|
+
handlePositionParam(container, params.position);
|
|
1137
|
+
handleGrowParam(container, params.grow); // Custom class
|
|
1138
|
+
|
|
1139
|
+
applyCustomClass(container, params, 'container');
|
|
1140
|
+
};
|
|
1141
|
+
/**
|
|
1142
|
+
* @param {HTMLElement} container
|
|
1143
|
+
* @param {SweetAlertOptions['backdrop']} backdrop
|
|
1144
|
+
*/
|
|
1145
|
+
|
|
900
1146
|
function handleBackdropParam(container, backdrop) {
|
|
901
1147
|
if (typeof backdrop === 'string') {
|
|
902
1148
|
container.style.background = backdrop;
|
|
@@ -904,6 +1150,11 @@
|
|
|
904
1150
|
addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
|
|
905
1151
|
}
|
|
906
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* @param {HTMLElement} container
|
|
1155
|
+
* @param {SweetAlertOptions['position']} position
|
|
1156
|
+
*/
|
|
1157
|
+
|
|
907
1158
|
|
|
908
1159
|
function handlePositionParam(container, position) {
|
|
909
1160
|
if (position in swalClasses) {
|
|
@@ -913,6 +1164,11 @@
|
|
|
913
1164
|
addClass(container, swalClasses.center);
|
|
914
1165
|
}
|
|
915
1166
|
}
|
|
1167
|
+
/**
|
|
1168
|
+
* @param {HTMLElement} container
|
|
1169
|
+
* @param {SweetAlertOptions['grow']} grow
|
|
1170
|
+
*/
|
|
1171
|
+
|
|
916
1172
|
|
|
917
1173
|
function handleGrowParam(container, grow) {
|
|
918
1174
|
if (grow && typeof grow === 'string') {
|
|
@@ -924,20 +1180,6 @@
|
|
|
924
1180
|
}
|
|
925
1181
|
}
|
|
926
1182
|
|
|
927
|
-
const renderContainer = (instance, params) => {
|
|
928
|
-
const container = getContainer();
|
|
929
|
-
|
|
930
|
-
if (!container) {
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
handleBackdropParam(container, params.backdrop);
|
|
935
|
-
handlePositionParam(container, params.position);
|
|
936
|
-
handleGrowParam(container, params.grow); // Custom class
|
|
937
|
-
|
|
938
|
-
applyCustomClass(container, params, 'container');
|
|
939
|
-
};
|
|
940
|
-
|
|
941
1183
|
/**
|
|
942
1184
|
* This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
|
|
943
1185
|
* For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
|
|
@@ -1242,6 +1484,11 @@
|
|
|
1242
1484
|
return textarea;
|
|
1243
1485
|
};
|
|
1244
1486
|
|
|
1487
|
+
/**
|
|
1488
|
+
* @param {SweetAlert2} instance
|
|
1489
|
+
* @param {SweetAlertOptions} params
|
|
1490
|
+
*/
|
|
1491
|
+
|
|
1245
1492
|
const renderContent = (instance, params) => {
|
|
1246
1493
|
const htmlContainer = getHtmlContainer();
|
|
1247
1494
|
applyCustomClass(htmlContainer, params, 'htmlContainer'); // Content as HTML
|
|
@@ -1261,6 +1508,11 @@
|
|
|
1261
1508
|
renderInput(instance, params);
|
|
1262
1509
|
};
|
|
1263
1510
|
|
|
1511
|
+
/**
|
|
1512
|
+
* @param {SweetAlert2} instance
|
|
1513
|
+
* @param {SweetAlertOptions} params
|
|
1514
|
+
*/
|
|
1515
|
+
|
|
1264
1516
|
const renderFooter = (instance, params) => {
|
|
1265
1517
|
const footer = getFooter();
|
|
1266
1518
|
toggle(footer, params.footer);
|
|
@@ -1273,6 +1525,11 @@
|
|
|
1273
1525
|
applyCustomClass(footer, params, 'footer');
|
|
1274
1526
|
};
|
|
1275
1527
|
|
|
1528
|
+
/**
|
|
1529
|
+
* @param {SweetAlert2} instance
|
|
1530
|
+
* @param {SweetAlertOptions} params
|
|
1531
|
+
*/
|
|
1532
|
+
|
|
1276
1533
|
const renderCloseButton = (instance, params) => {
|
|
1277
1534
|
const closeButton = getCloseButton();
|
|
1278
1535
|
setInnerHtml(closeButton, params.closeButtonHtml); // Custom class
|
|
@@ -1282,11 +1539,6 @@
|
|
|
1282
1539
|
closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
|
|
1283
1540
|
};
|
|
1284
1541
|
|
|
1285
|
-
/**
|
|
1286
|
-
* @typedef { import('sweetalert2') } SweetAlert2
|
|
1287
|
-
* @typedef { import('sweetalert2').SweetAlertOptions } SweetAlertOptions
|
|
1288
|
-
*/
|
|
1289
|
-
|
|
1290
1542
|
/**
|
|
1291
1543
|
* @param {SweetAlert2} instance
|
|
1292
1544
|
* @param {SweetAlertOptions} params
|
|
@@ -1304,12 +1556,14 @@
|
|
|
1304
1556
|
}
|
|
1305
1557
|
|
|
1306
1558
|
if (!params.icon && !params.iconHtml) {
|
|
1307
|
-
|
|
1559
|
+
hide(icon);
|
|
1560
|
+
return;
|
|
1308
1561
|
}
|
|
1309
1562
|
|
|
1310
1563
|
if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
|
|
1311
1564
|
error("Unknown icon! Expected \"success\", \"error\", \"warning\", \"info\" or \"question\", got \"".concat(params.icon, "\""));
|
|
1312
|
-
|
|
1565
|
+
hide(icon);
|
|
1566
|
+
return;
|
|
1313
1567
|
}
|
|
1314
1568
|
|
|
1315
1569
|
show(icon); // Custom or default content
|
|
@@ -1344,6 +1598,8 @@
|
|
|
1344
1598
|
const adjustSuccessIconBackgroundColor = () => {
|
|
1345
1599
|
const popup = getPopup();
|
|
1346
1600
|
const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
|
|
1601
|
+
/** @type {NodeListOf<HTMLElement>} */
|
|
1602
|
+
|
|
1347
1603
|
const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
|
|
1348
1604
|
|
|
1349
1605
|
for (let i = 0; i < successIconParts.length; i++) {
|
|
@@ -1359,21 +1615,27 @@
|
|
|
1359
1615
|
*/
|
|
1360
1616
|
|
|
1361
1617
|
const setContent = (icon, params) => {
|
|
1362
|
-
|
|
1618
|
+
let oldContent = icon.innerHTML;
|
|
1619
|
+
let newContent;
|
|
1363
1620
|
|
|
1364
1621
|
if (params.iconHtml) {
|
|
1365
|
-
|
|
1622
|
+
newContent = iconContent(params.iconHtml);
|
|
1366
1623
|
} else if (params.icon === 'success') {
|
|
1367
|
-
|
|
1624
|
+
newContent = successIconHtml;
|
|
1625
|
+
oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
|
|
1368
1626
|
} else if (params.icon === 'error') {
|
|
1369
|
-
|
|
1627
|
+
newContent = errorIconHtml;
|
|
1370
1628
|
} else {
|
|
1371
1629
|
const defaultIconHtml = {
|
|
1372
1630
|
question: '?',
|
|
1373
1631
|
warning: '!',
|
|
1374
1632
|
info: 'i'
|
|
1375
1633
|
};
|
|
1376
|
-
|
|
1634
|
+
newContent = iconContent(defaultIconHtml[params.icon]);
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
if (oldContent.trim() !== newContent.trim()) {
|
|
1638
|
+
setInnerHtml(icon, newContent);
|
|
1377
1639
|
}
|
|
1378
1640
|
};
|
|
1379
1641
|
/**
|
|
@@ -1398,16 +1660,12 @@
|
|
|
1398
1660
|
};
|
|
1399
1661
|
/**
|
|
1400
1662
|
* @param {string} content
|
|
1663
|
+
* @returns {string}
|
|
1401
1664
|
*/
|
|
1402
1665
|
|
|
1403
1666
|
|
|
1404
1667
|
const iconContent = content => "<div class=\"".concat(swalClasses['icon-content'], "\">").concat(content, "</div>");
|
|
1405
1668
|
|
|
1406
|
-
/**
|
|
1407
|
-
* @typedef { import('sweetalert2') } SweetAlert2
|
|
1408
|
-
* @typedef { import('sweetalert2').SweetAlertOptions } SweetAlertOptions
|
|
1409
|
-
*/
|
|
1410
|
-
|
|
1411
1669
|
/**
|
|
1412
1670
|
* @param {SweetAlert2} instance
|
|
1413
1671
|
* @param {SweetAlertOptions} params
|
|
@@ -1432,11 +1690,6 @@
|
|
|
1432
1690
|
applyCustomClass(image, params, 'image');
|
|
1433
1691
|
};
|
|
1434
1692
|
|
|
1435
|
-
/**
|
|
1436
|
-
* @typedef { import('sweetalert2') } SweetAlert2
|
|
1437
|
-
* @typedef { import('sweetalert2').SweetAlertOptions } SweetAlertOptions
|
|
1438
|
-
*/
|
|
1439
|
-
|
|
1440
1693
|
/**
|
|
1441
1694
|
* @param {SweetAlert2} instance
|
|
1442
1695
|
* @param {SweetAlertOptions} params
|
|
@@ -1498,6 +1751,11 @@
|
|
|
1498
1751
|
return lineEl;
|
|
1499
1752
|
};
|
|
1500
1753
|
|
|
1754
|
+
/**
|
|
1755
|
+
* @param {SweetAlert2} instance
|
|
1756
|
+
* @param {SweetAlertOptions} params
|
|
1757
|
+
*/
|
|
1758
|
+
|
|
1501
1759
|
const renderTitle = (instance, params) => {
|
|
1502
1760
|
const title = getTitle();
|
|
1503
1761
|
toggle(title, params.title || params.titleText, 'block');
|
|
@@ -1514,11 +1772,6 @@
|
|
|
1514
1772
|
applyCustomClass(title, params, 'title');
|
|
1515
1773
|
};
|
|
1516
1774
|
|
|
1517
|
-
/**
|
|
1518
|
-
* @typedef { import('sweetalert2') } SweetAlert2
|
|
1519
|
-
* @typedef { import('sweetalert2').SweetAlertOptions } SweetAlertOptions
|
|
1520
|
-
*/
|
|
1521
|
-
|
|
1522
1775
|
/**
|
|
1523
1776
|
* @param {SweetAlert2} instance
|
|
1524
1777
|
* @param {SweetAlertOptions} params
|
|
@@ -1582,6 +1835,11 @@
|
|
|
1582
1835
|
}
|
|
1583
1836
|
};
|
|
1584
1837
|
|
|
1838
|
+
/**
|
|
1839
|
+
* @param {SweetAlert2} instance
|
|
1840
|
+
* @param {SweetAlertOptions} params
|
|
1841
|
+
*/
|
|
1842
|
+
|
|
1585
1843
|
const render = (instance, params) => {
|
|
1586
1844
|
renderPopup(instance, params);
|
|
1587
1845
|
renderContainer(instance, params);
|
|
@@ -1851,15 +2109,30 @@
|
|
|
1851
2109
|
};
|
|
1852
2110
|
|
|
1853
2111
|
var defaultInputValidators = {
|
|
2112
|
+
/**
|
|
2113
|
+
* @param {string} string
|
|
2114
|
+
* @param {string} validationMessage
|
|
2115
|
+
* @returns {Promise<void | string>}
|
|
2116
|
+
*/
|
|
1854
2117
|
email: (string, validationMessage) => {
|
|
1855
2118
|
return /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,24}$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
|
|
1856
2119
|
},
|
|
2120
|
+
|
|
2121
|
+
/**
|
|
2122
|
+
* @param {string} string
|
|
2123
|
+
* @param {string} validationMessage
|
|
2124
|
+
* @returns {Promise<void | string>}
|
|
2125
|
+
*/
|
|
1857
2126
|
url: (string, validationMessage) => {
|
|
1858
2127
|
// taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
|
|
1859
2128
|
return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL');
|
|
1860
2129
|
}
|
|
1861
2130
|
};
|
|
1862
2131
|
|
|
2132
|
+
/**
|
|
2133
|
+
* @param {SweetAlertOptions} params
|
|
2134
|
+
*/
|
|
2135
|
+
|
|
1863
2136
|
function setDefaultInputValidators(params) {
|
|
1864
2137
|
// Use default `inputValidator` for supported input types if not provided
|
|
1865
2138
|
if (!params.inputValidator) {
|
|
@@ -1870,6 +2143,10 @@
|
|
|
1870
2143
|
});
|
|
1871
2144
|
}
|
|
1872
2145
|
}
|
|
2146
|
+
/**
|
|
2147
|
+
* @param {SweetAlertOptions} params
|
|
2148
|
+
*/
|
|
2149
|
+
|
|
1873
2150
|
|
|
1874
2151
|
function validateCustomTargetElement(params) {
|
|
1875
2152
|
// Determine if the custom target element is valid
|
|
@@ -1881,7 +2158,7 @@
|
|
|
1881
2158
|
/**
|
|
1882
2159
|
* Set type, text and actions on popup
|
|
1883
2160
|
*
|
|
1884
|
-
* @param params
|
|
2161
|
+
* @param {SweetAlertOptions} params
|
|
1885
2162
|
*/
|
|
1886
2163
|
|
|
1887
2164
|
|
|
@@ -2200,8 +2477,8 @@
|
|
|
2200
2477
|
}
|
|
2201
2478
|
|
|
2202
2479
|
show(loader);
|
|
2203
|
-
popup.setAttribute('data-loading', true);
|
|
2204
|
-
popup.setAttribute('aria-busy', true);
|
|
2480
|
+
popup.setAttribute('data-loading', 'true');
|
|
2481
|
+
popup.setAttribute('aria-busy', 'true');
|
|
2205
2482
|
popup.focus();
|
|
2206
2483
|
};
|
|
2207
2484
|
|
|
@@ -2491,6 +2768,10 @@
|
|
|
2491
2768
|
|
|
2492
2769
|
const clickCancel = () => getCancelButton() && getCancelButton().click();
|
|
2493
2770
|
|
|
2771
|
+
/**
|
|
2772
|
+
* @param {GlobalState} globalState
|
|
2773
|
+
*/
|
|
2774
|
+
|
|
2494
2775
|
const removeKeydownHandler = globalState => {
|
|
2495
2776
|
if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
|
|
2496
2777
|
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
|
|
@@ -2499,6 +2780,13 @@
|
|
|
2499
2780
|
globalState.keydownHandlerAdded = false;
|
|
2500
2781
|
}
|
|
2501
2782
|
};
|
|
2783
|
+
/**
|
|
2784
|
+
* @param {SweetAlert2} instance
|
|
2785
|
+
* @param {GlobalState} globalState
|
|
2786
|
+
* @param {SweetAlertOptions} innerParams
|
|
2787
|
+
* @param {*} dismissWith
|
|
2788
|
+
*/
|
|
2789
|
+
|
|
2502
2790
|
const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
|
|
2503
2791
|
removeKeydownHandler(globalState);
|
|
2504
2792
|
|
|
@@ -2512,7 +2800,12 @@
|
|
|
2512
2800
|
});
|
|
2513
2801
|
globalState.keydownHandlerAdded = true;
|
|
2514
2802
|
}
|
|
2515
|
-
};
|
|
2803
|
+
};
|
|
2804
|
+
/**
|
|
2805
|
+
* @param {SweetAlertOptions} innerParams
|
|
2806
|
+
* @param {number} index
|
|
2807
|
+
* @param {number} increment
|
|
2808
|
+
*/
|
|
2516
2809
|
|
|
2517
2810
|
const setFocus = (innerParams, index, increment) => {
|
|
2518
2811
|
const focusableElements = getFocusableElements(); // search for visible elements and select the next possible match
|
|
@@ -2534,6 +2827,11 @@
|
|
|
2534
2827
|
};
|
|
2535
2828
|
const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
|
|
2536
2829
|
const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
|
|
2830
|
+
/**
|
|
2831
|
+
* @param {SweetAlert2} instance
|
|
2832
|
+
* @param {KeyboardEvent} e
|
|
2833
|
+
* @param {function} dismissWith
|
|
2834
|
+
*/
|
|
2537
2835
|
|
|
2538
2836
|
const keydownHandler = (instance, e, dismissWith) => {
|
|
2539
2837
|
const innerParams = privateProps.innerParams.get(instance);
|
|
@@ -2568,6 +2866,12 @@
|
|
|
2568
2866
|
handleEsc(e, innerParams, dismissWith);
|
|
2569
2867
|
}
|
|
2570
2868
|
};
|
|
2869
|
+
/**
|
|
2870
|
+
* @param {SweetAlert2} instance
|
|
2871
|
+
* @param {KeyboardEvent} e
|
|
2872
|
+
* @param {SweetAlertOptions} innerParams
|
|
2873
|
+
*/
|
|
2874
|
+
|
|
2571
2875
|
|
|
2572
2876
|
const handleEnter = (instance, e, innerParams) => {
|
|
2573
2877
|
// https://github.com/sweetalert2/sweetalert2/issues/2386
|
|
@@ -2575,7 +2879,7 @@
|
|
|
2575
2879
|
return;
|
|
2576
2880
|
}
|
|
2577
2881
|
|
|
2578
|
-
if (e.target && instance.getInput() && e.target.outerHTML === instance.getInput().outerHTML) {
|
|
2882
|
+
if (e.target && instance.getInput() && e.target instanceof HTMLElement && e.target.outerHTML === instance.getInput().outerHTML) {
|
|
2579
2883
|
if (['textarea', 'file'].includes(innerParams.input)) {
|
|
2580
2884
|
return; // do not submit
|
|
2581
2885
|
}
|
|
@@ -2584,6 +2888,11 @@
|
|
|
2584
2888
|
e.preventDefault();
|
|
2585
2889
|
}
|
|
2586
2890
|
};
|
|
2891
|
+
/**
|
|
2892
|
+
* @param {KeyboardEvent} e
|
|
2893
|
+
* @param {SweetAlertOptions} innerParams
|
|
2894
|
+
*/
|
|
2895
|
+
|
|
2587
2896
|
|
|
2588
2897
|
const handleTab = (e, innerParams) => {
|
|
2589
2898
|
const targetElement = e.target;
|
|
@@ -2608,13 +2917,17 @@
|
|
|
2608
2917
|
e.stopPropagation();
|
|
2609
2918
|
e.preventDefault();
|
|
2610
2919
|
};
|
|
2920
|
+
/**
|
|
2921
|
+
* @param {string} key
|
|
2922
|
+
*/
|
|
2923
|
+
|
|
2611
2924
|
|
|
2612
2925
|
const handleArrows = key => {
|
|
2613
2926
|
const confirmButton = getConfirmButton();
|
|
2614
2927
|
const denyButton = getDenyButton();
|
|
2615
2928
|
const cancelButton = getCancelButton();
|
|
2616
2929
|
|
|
2617
|
-
if (![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
|
|
2930
|
+
if (document.activeElement instanceof HTMLElement && ![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
|
|
2618
2931
|
return;
|
|
2619
2932
|
}
|
|
2620
2933
|
|
|
@@ -2628,7 +2941,7 @@
|
|
|
2628
2941
|
return;
|
|
2629
2942
|
}
|
|
2630
2943
|
|
|
2631
|
-
if (
|
|
2944
|
+
if (buttonToFocus instanceof HTMLButtonElement && isVisible(buttonToFocus)) {
|
|
2632
2945
|
break;
|
|
2633
2946
|
}
|
|
2634
2947
|
}
|
|
@@ -2637,6 +2950,12 @@
|
|
|
2637
2950
|
buttonToFocus.focus();
|
|
2638
2951
|
}
|
|
2639
2952
|
};
|
|
2953
|
+
/**
|
|
2954
|
+
* @param {KeyboardEvent} e
|
|
2955
|
+
* @param {SweetAlertOptions} innerParams
|
|
2956
|
+
* @param {function} dismissWith
|
|
2957
|
+
*/
|
|
2958
|
+
|
|
2640
2959
|
|
|
2641
2960
|
const handleEsc = (e, innerParams, dismissWith) => {
|
|
2642
2961
|
if (callIfFunction(innerParams.allowEscapeKey)) {
|
|
@@ -2926,12 +3245,6 @@
|
|
|
2926
3245
|
if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
|
|
2927
3246
|
globalState.swalCloseEventFinishedCallback();
|
|
2928
3247
|
delete globalState.swalCloseEventFinishedCallback;
|
|
2929
|
-
} // Check if there is a swal disposal defer timer
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
if (globalState.deferDisposalTimer) {
|
|
2933
|
-
clearTimeout(globalState.deferDisposalTimer);
|
|
2934
|
-
delete globalState.deferDisposalTimer;
|
|
2935
3248
|
}
|
|
2936
3249
|
|
|
2937
3250
|
if (typeof innerParams.didDestroy === 'function') {
|
|
@@ -2940,9 +3253,13 @@
|
|
|
2940
3253
|
|
|
2941
3254
|
disposeSwal(this);
|
|
2942
3255
|
}
|
|
3256
|
+
/**
|
|
3257
|
+
* @param {SweetAlert2} instance
|
|
3258
|
+
*/
|
|
2943
3259
|
|
|
2944
3260
|
const disposeSwal = instance => {
|
|
2945
3261
|
disposeWeakMaps(instance); // Unset this.params so GC will dispose it (#1569)
|
|
3262
|
+
// @ts-ignore
|
|
2946
3263
|
|
|
2947
3264
|
delete instance.params; // Unset globalState props so GC will dispose globalState (#1569)
|
|
2948
3265
|
|
|
@@ -2951,9 +3268,14 @@
|
|
|
2951
3268
|
|
|
2952
3269
|
delete globalState.currentInstance;
|
|
2953
3270
|
};
|
|
3271
|
+
/**
|
|
3272
|
+
* @param {SweetAlert2} instance
|
|
3273
|
+
*/
|
|
3274
|
+
|
|
2954
3275
|
|
|
2955
3276
|
const disposeWeakMaps = instance => {
|
|
2956
3277
|
// If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
|
|
3278
|
+
// @ts-ignore
|
|
2957
3279
|
if (instance.isAwaitingPromise()) {
|
|
2958
3280
|
unsetWeakMaps(privateProps, instance);
|
|
2959
3281
|
privateProps.awaitingPromise.set(instance, true);
|
|
@@ -2962,6 +3284,11 @@
|
|
|
2962
3284
|
unsetWeakMaps(privateProps, instance);
|
|
2963
3285
|
}
|
|
2964
3286
|
};
|
|
3287
|
+
/**
|
|
3288
|
+
* @param {object} obj
|
|
3289
|
+
* @param {SweetAlert2} instance
|
|
3290
|
+
*/
|
|
3291
|
+
|
|
2965
3292
|
|
|
2966
3293
|
const unsetWeakMaps = (obj, instance) => {
|
|
2967
3294
|
for (const i in obj) {
|
|
@@ -3425,7 +3752,7 @@
|
|
|
3425
3752
|
}
|
|
3426
3753
|
}); // @ts-ignore
|
|
3427
3754
|
|
|
3428
|
-
const promise =
|
|
3755
|
+
const promise = currentInstance._main(currentInstance.params);
|
|
3429
3756
|
|
|
3430
3757
|
privateProps.promise.set(this, promise);
|
|
3431
3758
|
}
|
|
@@ -3435,6 +3762,7 @@
|
|
|
3435
3762
|
showWarningsForParams(Object.assign({}, mixinParams, userParams));
|
|
3436
3763
|
|
|
3437
3764
|
if (globalState.currentInstance) {
|
|
3765
|
+
// @ts-ignore
|
|
3438
3766
|
globalState.currentInstance._destroy();
|
|
3439
3767
|
|
|
3440
3768
|
if (isModal()) {
|
|
@@ -3442,7 +3770,7 @@
|
|
|
3442
3770
|
}
|
|
3443
3771
|
}
|
|
3444
3772
|
|
|
3445
|
-
globalState.currentInstance =
|
|
3773
|
+
globalState.currentInstance = currentInstance;
|
|
3446
3774
|
const innerParams = prepareParams(userParams, mixinParams);
|
|
3447
3775
|
setParameters(innerParams);
|
|
3448
3776
|
Object.freeze(innerParams); // clear the previous timer
|
|
@@ -3454,10 +3782,10 @@
|
|
|
3454
3782
|
|
|
3455
3783
|
|
|
3456
3784
|
clearTimeout(globalState.restoreFocusTimeout);
|
|
3457
|
-
const domCache = populateDomCache(
|
|
3458
|
-
render(
|
|
3459
|
-
privateProps.innerParams.set(
|
|
3460
|
-
return swalPromise(
|
|
3785
|
+
const domCache = populateDomCache(currentInstance);
|
|
3786
|
+
render(currentInstance, innerParams);
|
|
3787
|
+
privateProps.innerParams.set(currentInstance, innerParams);
|
|
3788
|
+
return swalPromise(currentInstance, domCache, innerParams);
|
|
3461
3789
|
} // `catch` cannot be the name of a module export, so we define our thenable methods here instead
|
|
3462
3790
|
|
|
3463
3791
|
|
|
@@ -3515,6 +3843,11 @@
|
|
|
3515
3843
|
params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
|
|
3516
3844
|
return params;
|
|
3517
3845
|
};
|
|
3846
|
+
/**
|
|
3847
|
+
* @param {SweetAlert2} instance
|
|
3848
|
+
* @returns {DomCache}
|
|
3849
|
+
*/
|
|
3850
|
+
|
|
3518
3851
|
|
|
3519
3852
|
const populateDomCache = instance => {
|
|
3520
3853
|
const domCache = {
|
|
@@ -3532,6 +3865,12 @@
|
|
|
3532
3865
|
privateProps.domCache.set(instance, domCache);
|
|
3533
3866
|
return domCache;
|
|
3534
3867
|
};
|
|
3868
|
+
/**
|
|
3869
|
+
* @param {GlobalState} globalState
|
|
3870
|
+
* @param {SweetAlertOptions} innerParams
|
|
3871
|
+
* @param {function} dismissWith
|
|
3872
|
+
*/
|
|
3873
|
+
|
|
3535
3874
|
|
|
3536
3875
|
const setupTimer = (globalState$$1, innerParams, dismissWith) => {
|
|
3537
3876
|
const timerProgressBar = getTimerProgressBar();
|
|
@@ -3555,6 +3894,11 @@
|
|
|
3555
3894
|
}
|
|
3556
3895
|
}
|
|
3557
3896
|
};
|
|
3897
|
+
/**
|
|
3898
|
+
* @param {DomCache} domCache
|
|
3899
|
+
* @param {SweetAlertOptions} innerParams
|
|
3900
|
+
*/
|
|
3901
|
+
|
|
3558
3902
|
|
|
3559
3903
|
const initFocus = (domCache, innerParams) => {
|
|
3560
3904
|
if (innerParams.toast) {
|
|
@@ -3569,6 +3913,12 @@
|
|
|
3569
3913
|
setFocus(innerParams, -1, 1);
|
|
3570
3914
|
}
|
|
3571
3915
|
};
|
|
3916
|
+
/**
|
|
3917
|
+
* @param {DomCache} domCache
|
|
3918
|
+
* @param {SweetAlertOptions} innerParams
|
|
3919
|
+
* @returns {boolean}
|
|
3920
|
+
*/
|
|
3921
|
+
|
|
3572
3922
|
|
|
3573
3923
|
const focusButton = (domCache, innerParams) => {
|
|
3574
3924
|
if (innerParams.focusDeny && isVisible(domCache.denyButton)) {
|
|
@@ -3608,7 +3958,7 @@
|
|
|
3608
3958
|
};
|
|
3609
3959
|
});
|
|
3610
3960
|
SweetAlert.DismissReason = DismissReason;
|
|
3611
|
-
SweetAlert.version = '11.4.
|
|
3961
|
+
SweetAlert.version = '11.4.17';
|
|
3612
3962
|
|
|
3613
3963
|
const Swal = SweetAlert; // @ts-ignore
|
|
3614
3964
|
|