sweetalert2 11.4.13 → 11.4.16
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 +8 -8
- package/dist/sweetalert2.all.js +447 -60
- package/dist/sweetalert2.all.min.js +1 -1
- package/dist/sweetalert2.js +447 -60
- 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/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 +20 -0
- package/src/utils/dom/renderers/renderImage.js +4 -0
- package/src/utils/dom/renderers/renderInput.js +0 -2
- package/src/utils/dom/renderers/renderPopup.js +8 -0
- package/src/utils/dom/renderers/renderProgressSteps.js +28 -16
- package/src/utils/dom/renderers/renderTitle.js +4 -0
- package/src/utils/utils.js +1 -1
- package/sweetalert2.d.ts +4 -1
package/dist/sweetalert2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sweetalert2 v11.4.
|
|
2
|
+
* sweetalert2 v11.4.16
|
|
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
|
|
|
@@ -268,33 +268,110 @@
|
|
|
268
268
|
*/
|
|
269
269
|
|
|
270
270
|
const getContainer = () => document.body.querySelector(".".concat(swalClasses.container));
|
|
271
|
+
/**
|
|
272
|
+
* @param {string} selectorString
|
|
273
|
+
* @returns {HTMLElement | null}
|
|
274
|
+
*/
|
|
275
|
+
|
|
271
276
|
const elementBySelector = selectorString => {
|
|
272
277
|
const container = getContainer();
|
|
273
278
|
return container ? container.querySelector(selectorString) : null;
|
|
274
279
|
};
|
|
280
|
+
/**
|
|
281
|
+
* @param {string} className
|
|
282
|
+
* @returns {HTMLElement | null}
|
|
283
|
+
*/
|
|
275
284
|
|
|
276
285
|
const elementByClass = className => {
|
|
277
286
|
return elementBySelector(".".concat(className));
|
|
278
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* @returns {HTMLElement | null}
|
|
290
|
+
*/
|
|
291
|
+
|
|
279
292
|
|
|
280
293
|
const getPopup = () => elementByClass(swalClasses.popup);
|
|
294
|
+
/**
|
|
295
|
+
* @returns {HTMLElement | null}
|
|
296
|
+
*/
|
|
297
|
+
|
|
281
298
|
const getIcon = () => elementByClass(swalClasses.icon);
|
|
299
|
+
/**
|
|
300
|
+
* @returns {HTMLElement | null}
|
|
301
|
+
*/
|
|
302
|
+
|
|
282
303
|
const getTitle = () => elementByClass(swalClasses.title);
|
|
304
|
+
/**
|
|
305
|
+
* @returns {HTMLElement | null}
|
|
306
|
+
*/
|
|
307
|
+
|
|
283
308
|
const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
|
|
309
|
+
/**
|
|
310
|
+
* @returns {HTMLElement | null}
|
|
311
|
+
*/
|
|
312
|
+
|
|
284
313
|
const getImage = () => elementByClass(swalClasses.image);
|
|
314
|
+
/**
|
|
315
|
+
* @returns {HTMLElement | null}
|
|
316
|
+
*/
|
|
317
|
+
|
|
285
318
|
const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
|
|
319
|
+
/**
|
|
320
|
+
* @returns {HTMLElement | null}
|
|
321
|
+
*/
|
|
322
|
+
|
|
286
323
|
const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
|
|
324
|
+
/**
|
|
325
|
+
* @returns {HTMLElement | null}
|
|
326
|
+
*/
|
|
327
|
+
|
|
287
328
|
const getConfirmButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.confirm));
|
|
329
|
+
/**
|
|
330
|
+
* @returns {HTMLElement | null}
|
|
331
|
+
*/
|
|
332
|
+
|
|
288
333
|
const getDenyButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.deny));
|
|
334
|
+
/**
|
|
335
|
+
* @returns {HTMLElement | null}
|
|
336
|
+
*/
|
|
337
|
+
|
|
289
338
|
const getInputLabel = () => elementByClass(swalClasses['input-label']);
|
|
339
|
+
/**
|
|
340
|
+
* @returns {HTMLElement | null}
|
|
341
|
+
*/
|
|
342
|
+
|
|
290
343
|
const getLoader = () => elementBySelector(".".concat(swalClasses.loader));
|
|
344
|
+
/**
|
|
345
|
+
* @returns {HTMLElement | null}
|
|
346
|
+
*/
|
|
347
|
+
|
|
291
348
|
const getCancelButton = () => elementBySelector(".".concat(swalClasses.actions, " .").concat(swalClasses.cancel));
|
|
349
|
+
/**
|
|
350
|
+
* @returns {HTMLElement | null}
|
|
351
|
+
*/
|
|
352
|
+
|
|
292
353
|
const getActions = () => elementByClass(swalClasses.actions);
|
|
354
|
+
/**
|
|
355
|
+
* @returns {HTMLElement | null}
|
|
356
|
+
*/
|
|
357
|
+
|
|
293
358
|
const getFooter = () => elementByClass(swalClasses.footer);
|
|
359
|
+
/**
|
|
360
|
+
* @returns {HTMLElement | null}
|
|
361
|
+
*/
|
|
362
|
+
|
|
294
363
|
const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
|
|
364
|
+
/**
|
|
365
|
+
* @returns {HTMLElement | null}
|
|
366
|
+
*/
|
|
367
|
+
|
|
295
368
|
const getCloseButton = () => elementByClass(swalClasses.close); // https://github.com/jkup/focusable/blob/master/index.js
|
|
296
369
|
|
|
297
370
|
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";
|
|
371
|
+
/**
|
|
372
|
+
* @returns {HTMLElement[]}
|
|
373
|
+
*/
|
|
374
|
+
|
|
298
375
|
const getFocusableElements = () => {
|
|
299
376
|
const focusableElementsWithTabindex = toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')) // sort according to tabindex
|
|
300
377
|
.sort((a, b) => {
|
|
@@ -312,12 +389,24 @@
|
|
|
312
389
|
const otherFocusableElements = toArray(getPopup().querySelectorAll(focusable)).filter(el => el.getAttribute('tabindex') !== '-1');
|
|
313
390
|
return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter(el => isVisible(el));
|
|
314
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* @returns {boolean}
|
|
394
|
+
*/
|
|
395
|
+
|
|
315
396
|
const isModal = () => {
|
|
316
397
|
return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
|
|
317
398
|
};
|
|
399
|
+
/**
|
|
400
|
+
* @returns {boolean}
|
|
401
|
+
*/
|
|
402
|
+
|
|
318
403
|
const isToast = () => {
|
|
319
404
|
return getPopup() && hasClass(getPopup(), swalClasses.toast);
|
|
320
405
|
};
|
|
406
|
+
/**
|
|
407
|
+
* @returns {boolean}
|
|
408
|
+
*/
|
|
409
|
+
|
|
321
410
|
const isLoading = () => {
|
|
322
411
|
return getPopup().hasAttribute('data-loading');
|
|
323
412
|
};
|
|
@@ -368,6 +457,10 @@
|
|
|
368
457
|
|
|
369
458
|
return true;
|
|
370
459
|
};
|
|
460
|
+
/**
|
|
461
|
+
* @param {HTMLElement} elem
|
|
462
|
+
* @param {SweetAlertOptions} params
|
|
463
|
+
*/
|
|
371
464
|
|
|
372
465
|
const removeCustomClasses = (elem, params) => {
|
|
373
466
|
toArray(elem.classList).forEach(className => {
|
|
@@ -376,6 +469,12 @@
|
|
|
376
469
|
}
|
|
377
470
|
});
|
|
378
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* @param {HTMLElement} elem
|
|
474
|
+
* @param {SweetAlertOptions} params
|
|
475
|
+
* @param {string} className
|
|
476
|
+
*/
|
|
477
|
+
|
|
379
478
|
|
|
380
479
|
const applyCustomClass = (elem, params, className) => {
|
|
381
480
|
removeCustomClasses(elem, params);
|
|
@@ -523,20 +622,55 @@
|
|
|
523
622
|
const hide = elem => {
|
|
524
623
|
elem.style.display = 'none';
|
|
525
624
|
};
|
|
625
|
+
/**
|
|
626
|
+
* @param {HTMLElement} parent
|
|
627
|
+
* @param {string} selector
|
|
628
|
+
* @param {string} property
|
|
629
|
+
* @param {string} value
|
|
630
|
+
*/
|
|
631
|
+
|
|
526
632
|
const setStyle = (parent, selector, property, value) => {
|
|
633
|
+
/** @type {HTMLElement} */
|
|
527
634
|
const el = parent.querySelector(selector);
|
|
528
635
|
|
|
529
636
|
if (el) {
|
|
530
637
|
el.style[property] = value;
|
|
531
638
|
}
|
|
532
639
|
};
|
|
533
|
-
|
|
640
|
+
/**
|
|
641
|
+
* @param {HTMLElement} elem
|
|
642
|
+
* @param {any} condition
|
|
643
|
+
* @param {string} display
|
|
644
|
+
*/
|
|
645
|
+
|
|
646
|
+
const toggle = function (elem, condition) {
|
|
647
|
+
let display = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'flex';
|
|
534
648
|
condition ? show(elem, display) : hide(elem);
|
|
535
|
-
};
|
|
649
|
+
};
|
|
650
|
+
/**
|
|
651
|
+
* borrowed from jquery $(elem).is(':visible') implementation
|
|
652
|
+
*
|
|
653
|
+
* @param {HTMLElement} elem
|
|
654
|
+
* @returns {boolean}
|
|
655
|
+
*/
|
|
536
656
|
|
|
537
657
|
const isVisible = elem => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
|
|
658
|
+
/**
|
|
659
|
+
* @returns {boolean}
|
|
660
|
+
*/
|
|
661
|
+
|
|
538
662
|
const allButtonsAreHidden = () => !isVisible(getConfirmButton()) && !isVisible(getDenyButton()) && !isVisible(getCancelButton());
|
|
539
|
-
|
|
663
|
+
/**
|
|
664
|
+
* @returns {boolean}
|
|
665
|
+
*/
|
|
666
|
+
|
|
667
|
+
const isScrollable = elem => !!(elem.scrollHeight > elem.clientHeight);
|
|
668
|
+
/**
|
|
669
|
+
* borrowed from https://stackoverflow.com/a/46352119
|
|
670
|
+
*
|
|
671
|
+
* @param {HTMLElement} elem
|
|
672
|
+
* @returns {boolean}
|
|
673
|
+
*/
|
|
540
674
|
|
|
541
675
|
const hasCssAnimation = elem => {
|
|
542
676
|
const style = window.getComputedStyle(elem);
|
|
@@ -544,6 +678,11 @@
|
|
|
544
678
|
const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
|
|
545
679
|
return animDuration > 0 || transDuration > 0;
|
|
546
680
|
};
|
|
681
|
+
/**
|
|
682
|
+
* @param {number} timer
|
|
683
|
+
* @param {boolean} reset
|
|
684
|
+
*/
|
|
685
|
+
|
|
547
686
|
const animateTimerProgressBar = function (timer) {
|
|
548
687
|
let reset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
549
688
|
const timerProgressBar = getTimerProgressBar();
|
|
@@ -580,16 +719,24 @@
|
|
|
580
719
|
|
|
581
720
|
const RESTORE_FOCUS_TIMEOUT = 100;
|
|
582
721
|
|
|
722
|
+
/** @type {GlobalState} */
|
|
723
|
+
|
|
583
724
|
const globalState = {};
|
|
584
725
|
|
|
585
726
|
const focusPreviousActiveElement = () => {
|
|
586
|
-
if (globalState.previousActiveElement
|
|
727
|
+
if (globalState.previousActiveElement instanceof HTMLElement) {
|
|
587
728
|
globalState.previousActiveElement.focus();
|
|
588
729
|
globalState.previousActiveElement = null;
|
|
589
730
|
} else if (document.body) {
|
|
590
731
|
document.body.focus();
|
|
591
732
|
}
|
|
592
|
-
};
|
|
733
|
+
};
|
|
734
|
+
/**
|
|
735
|
+
* Restore previous active (focused) element
|
|
736
|
+
*
|
|
737
|
+
* @param {boolean} returnFocus
|
|
738
|
+
* @returns {Promise}
|
|
739
|
+
*/
|
|
593
740
|
|
|
594
741
|
|
|
595
742
|
const restoreActiveElement = returnFocus => {
|
|
@@ -610,6 +757,9 @@
|
|
|
610
757
|
};
|
|
611
758
|
|
|
612
759
|
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, '');
|
|
760
|
+
/**
|
|
761
|
+
* @returns {boolean}
|
|
762
|
+
*/
|
|
613
763
|
|
|
614
764
|
const resetOldContainer = () => {
|
|
615
765
|
const oldContainer = getContainer();
|
|
@@ -631,9 +781,15 @@
|
|
|
631
781
|
const popup = getPopup();
|
|
632
782
|
const input = getDirectChildByClass(popup, swalClasses.input);
|
|
633
783
|
const file = getDirectChildByClass(popup, swalClasses.file);
|
|
784
|
+
/** @type {HTMLInputElement} */
|
|
785
|
+
|
|
634
786
|
const range = popup.querySelector(".".concat(swalClasses.range, " input"));
|
|
787
|
+
/** @type {HTMLOutputElement} */
|
|
788
|
+
|
|
635
789
|
const rangeOutput = popup.querySelector(".".concat(swalClasses.range, " output"));
|
|
636
790
|
const select = getDirectChildByClass(popup, swalClasses.select);
|
|
791
|
+
/** @type {HTMLInputElement} */
|
|
792
|
+
|
|
637
793
|
const checkbox = popup.querySelector(".".concat(swalClasses.checkbox, " input"));
|
|
638
794
|
const textarea = getDirectChildByClass(popup, swalClasses.textarea);
|
|
639
795
|
input.oninput = resetValidationMessage;
|
|
@@ -649,11 +805,20 @@
|
|
|
649
805
|
|
|
650
806
|
range.onchange = () => {
|
|
651
807
|
resetValidationMessage();
|
|
652
|
-
|
|
808
|
+
rangeOutput.value = range.value;
|
|
653
809
|
};
|
|
654
810
|
};
|
|
811
|
+
/**
|
|
812
|
+
* @param {string | HTMLElement} target
|
|
813
|
+
* @returns {HTMLElement}
|
|
814
|
+
*/
|
|
815
|
+
|
|
655
816
|
|
|
656
817
|
const getTarget = target => typeof target === 'string' ? document.querySelector(target) : target;
|
|
818
|
+
/**
|
|
819
|
+
* @param {SweetAlertOptions} params
|
|
820
|
+
*/
|
|
821
|
+
|
|
657
822
|
|
|
658
823
|
const setupAccessibility = params => {
|
|
659
824
|
const popup = getPopup();
|
|
@@ -664,14 +829,20 @@
|
|
|
664
829
|
popup.setAttribute('aria-modal', 'true');
|
|
665
830
|
}
|
|
666
831
|
};
|
|
832
|
+
/**
|
|
833
|
+
* @param {HTMLElement} targetElement
|
|
834
|
+
*/
|
|
835
|
+
|
|
667
836
|
|
|
668
837
|
const setupRTL = targetElement => {
|
|
669
838
|
if (window.getComputedStyle(targetElement).direction === 'rtl') {
|
|
670
839
|
addClass(getContainer(), swalClasses.rtl);
|
|
671
840
|
}
|
|
672
841
|
};
|
|
673
|
-
|
|
842
|
+
/**
|
|
674
843
|
* Add modal + backdrop + no-war message for Russians to DOM
|
|
844
|
+
*
|
|
845
|
+
* @param {SweetAlertOptions} params
|
|
675
846
|
*/
|
|
676
847
|
|
|
677
848
|
|
|
@@ -700,6 +871,10 @@
|
|
|
700
871
|
addInputChangeListeners();
|
|
701
872
|
noWarMessageForRussians(container, params);
|
|
702
873
|
};
|
|
874
|
+
/**
|
|
875
|
+
* @param {HTMLElement} container
|
|
876
|
+
* @param {SweetAlertOptions} params
|
|
877
|
+
*/
|
|
703
878
|
|
|
704
879
|
const noWarMessageForRussians = (container, params) => {
|
|
705
880
|
if (params.toast) {
|
|
@@ -730,6 +905,12 @@
|
|
|
730
905
|
}, {
|
|
731
906
|
text: 'ФИНСКИЙ ДРУГ РОССИИ <br> говорит ПО-РУССКИ о спецоперации',
|
|
732
907
|
youtubeId: 'hkCYb6edUrQ'
|
|
908
|
+
}, {
|
|
909
|
+
text: 'ЮРИЙ ПОДОЛЯКА честно <br> о генералах РУССКОЙ АРМИИ',
|
|
910
|
+
youtubeId: 'w4-_8BJKfpk'
|
|
911
|
+
}, {
|
|
912
|
+
text: 'Полковник ФСБ СТРЕЛКОВ <br> об успехах РОССИИ в спецоперации',
|
|
913
|
+
youtubeId: 'saK5UTKroDA'
|
|
733
914
|
}]); // The message will only be shown to Russian users visiting Russian sites
|
|
734
915
|
|
|
735
916
|
if (navigator.language === 'ru' && location.host.match(/\.(ru|su|xn--p1ai)$/)) {
|
|
@@ -772,6 +953,11 @@
|
|
|
772
953
|
setInnerHtml(target, param.toString());
|
|
773
954
|
}
|
|
774
955
|
};
|
|
956
|
+
/**
|
|
957
|
+
* @param {HTMLElement} target
|
|
958
|
+
* @param {HTMLElement} elem
|
|
959
|
+
*/
|
|
960
|
+
|
|
775
961
|
|
|
776
962
|
const handleJqueryElem = (target, elem) => {
|
|
777
963
|
target.textContent = '';
|
|
@@ -785,6 +971,10 @@
|
|
|
785
971
|
}
|
|
786
972
|
};
|
|
787
973
|
|
|
974
|
+
/**
|
|
975
|
+
* @returns {'webkitAnimationEnd' | 'animationend' | false}
|
|
976
|
+
*/
|
|
977
|
+
|
|
788
978
|
const animationEndEvent = (() => {
|
|
789
979
|
// Prevent run in Node env
|
|
790
980
|
|
|
@@ -810,7 +1000,12 @@
|
|
|
810
1000
|
return false;
|
|
811
1001
|
})();
|
|
812
1002
|
|
|
813
|
-
|
|
1003
|
+
/**
|
|
1004
|
+
* Measure scrollbar width for padding body during modal show/hide
|
|
1005
|
+
* https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
|
|
1006
|
+
*
|
|
1007
|
+
* @returns {number}
|
|
1008
|
+
*/
|
|
814
1009
|
|
|
815
1010
|
const measureScrollbar = () => {
|
|
816
1011
|
const scrollDiv = document.createElement('div');
|
|
@@ -821,6 +1016,11 @@
|
|
|
821
1016
|
return scrollbarWidth;
|
|
822
1017
|
};
|
|
823
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* @param {SweetAlert2} instance
|
|
1021
|
+
* @param {SweetAlertOptions} params
|
|
1022
|
+
*/
|
|
1023
|
+
|
|
824
1024
|
const renderActions = (instance, params) => {
|
|
825
1025
|
const actions = getActions();
|
|
826
1026
|
const loader = getLoader(); // Actions (buttons) wrapper
|
|
@@ -839,6 +1039,11 @@
|
|
|
839
1039
|
setInnerHtml(loader, params.loaderHtml);
|
|
840
1040
|
applyCustomClass(loader, params, 'loader');
|
|
841
1041
|
};
|
|
1042
|
+
/**
|
|
1043
|
+
* @param {HTMLElement} actions
|
|
1044
|
+
* @param {HTMLElement} loader
|
|
1045
|
+
* @param {SweetAlertOptions} params
|
|
1046
|
+
*/
|
|
842
1047
|
|
|
843
1048
|
function renderButtons(actions, loader, params) {
|
|
844
1049
|
const confirmButton = getConfirmButton();
|
|
@@ -861,6 +1066,13 @@
|
|
|
861
1066
|
}
|
|
862
1067
|
}
|
|
863
1068
|
}
|
|
1069
|
+
/**
|
|
1070
|
+
* @param {HTMLElement} confirmButton
|
|
1071
|
+
* @param {HTMLElement} denyButton
|
|
1072
|
+
* @param {HTMLElement} cancelButton
|
|
1073
|
+
* @param {SweetAlertOptions} params
|
|
1074
|
+
*/
|
|
1075
|
+
|
|
864
1076
|
|
|
865
1077
|
function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
|
|
866
1078
|
if (!params.buttonsStyling) {
|
|
@@ -884,6 +1096,12 @@
|
|
|
884
1096
|
addClass(cancelButton, swalClasses['default-outline']);
|
|
885
1097
|
}
|
|
886
1098
|
}
|
|
1099
|
+
/**
|
|
1100
|
+
* @param {HTMLElement} button
|
|
1101
|
+
* @param {'confirm' | 'deny' | 'cancel'} buttonType
|
|
1102
|
+
* @param {SweetAlertOptions} params
|
|
1103
|
+
*/
|
|
1104
|
+
|
|
887
1105
|
|
|
888
1106
|
function renderButton(button, buttonType, params) {
|
|
889
1107
|
toggle(button, params["show".concat(capitalizeFirstLetter(buttonType), "Button")], 'inline-block');
|
|
@@ -897,6 +1115,29 @@
|
|
|
897
1115
|
addClass(button, params["".concat(buttonType, "ButtonClass")]);
|
|
898
1116
|
}
|
|
899
1117
|
|
|
1118
|
+
/**
|
|
1119
|
+
* @param {SweetAlert2} instance
|
|
1120
|
+
* @param {SweetAlertOptions} params
|
|
1121
|
+
*/
|
|
1122
|
+
|
|
1123
|
+
const renderContainer = (instance, params) => {
|
|
1124
|
+
const container = getContainer();
|
|
1125
|
+
|
|
1126
|
+
if (!container) {
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
handleBackdropParam(container, params.backdrop);
|
|
1131
|
+
handlePositionParam(container, params.position);
|
|
1132
|
+
handleGrowParam(container, params.grow); // Custom class
|
|
1133
|
+
|
|
1134
|
+
applyCustomClass(container, params, 'container');
|
|
1135
|
+
};
|
|
1136
|
+
/**
|
|
1137
|
+
* @param {HTMLElement} container
|
|
1138
|
+
* @param {SweetAlertOptions['backdrop']} backdrop
|
|
1139
|
+
*/
|
|
1140
|
+
|
|
900
1141
|
function handleBackdropParam(container, backdrop) {
|
|
901
1142
|
if (typeof backdrop === 'string') {
|
|
902
1143
|
container.style.background = backdrop;
|
|
@@ -904,6 +1145,11 @@
|
|
|
904
1145
|
addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
|
|
905
1146
|
}
|
|
906
1147
|
}
|
|
1148
|
+
/**
|
|
1149
|
+
* @param {HTMLElement} container
|
|
1150
|
+
* @param {SweetAlertOptions['position']} position
|
|
1151
|
+
*/
|
|
1152
|
+
|
|
907
1153
|
|
|
908
1154
|
function handlePositionParam(container, position) {
|
|
909
1155
|
if (position in swalClasses) {
|
|
@@ -913,6 +1159,11 @@
|
|
|
913
1159
|
addClass(container, swalClasses.center);
|
|
914
1160
|
}
|
|
915
1161
|
}
|
|
1162
|
+
/**
|
|
1163
|
+
* @param {HTMLElement} container
|
|
1164
|
+
* @param {SweetAlertOptions['grow']} grow
|
|
1165
|
+
*/
|
|
1166
|
+
|
|
916
1167
|
|
|
917
1168
|
function handleGrowParam(container, grow) {
|
|
918
1169
|
if (grow && typeof grow === 'string') {
|
|
@@ -924,20 +1175,6 @@
|
|
|
924
1175
|
}
|
|
925
1176
|
}
|
|
926
1177
|
|
|
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
1178
|
/**
|
|
942
1179
|
* This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
|
|
943
1180
|
* For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
|
|
@@ -1242,6 +1479,11 @@
|
|
|
1242
1479
|
return textarea;
|
|
1243
1480
|
};
|
|
1244
1481
|
|
|
1482
|
+
/**
|
|
1483
|
+
* @param {SweetAlert2} instance
|
|
1484
|
+
* @param {SweetAlertOptions} params
|
|
1485
|
+
*/
|
|
1486
|
+
|
|
1245
1487
|
const renderContent = (instance, params) => {
|
|
1246
1488
|
const htmlContainer = getHtmlContainer();
|
|
1247
1489
|
applyCustomClass(htmlContainer, params, 'htmlContainer'); // Content as HTML
|
|
@@ -1261,6 +1503,11 @@
|
|
|
1261
1503
|
renderInput(instance, params);
|
|
1262
1504
|
};
|
|
1263
1505
|
|
|
1506
|
+
/**
|
|
1507
|
+
* @param {SweetAlert2} instance
|
|
1508
|
+
* @param {SweetAlertOptions} params
|
|
1509
|
+
*/
|
|
1510
|
+
|
|
1264
1511
|
const renderFooter = (instance, params) => {
|
|
1265
1512
|
const footer = getFooter();
|
|
1266
1513
|
toggle(footer, params.footer);
|
|
@@ -1273,6 +1520,11 @@
|
|
|
1273
1520
|
applyCustomClass(footer, params, 'footer');
|
|
1274
1521
|
};
|
|
1275
1522
|
|
|
1523
|
+
/**
|
|
1524
|
+
* @param {SweetAlert2} instance
|
|
1525
|
+
* @param {SweetAlertOptions} params
|
|
1526
|
+
*/
|
|
1527
|
+
|
|
1276
1528
|
const renderCloseButton = (instance, params) => {
|
|
1277
1529
|
const closeButton = getCloseButton();
|
|
1278
1530
|
setInnerHtml(closeButton, params.closeButtonHtml); // Custom class
|
|
@@ -1282,6 +1534,11 @@
|
|
|
1282
1534
|
closeButton.setAttribute('aria-label', params.closeButtonAriaLabel);
|
|
1283
1535
|
};
|
|
1284
1536
|
|
|
1537
|
+
/**
|
|
1538
|
+
* @param {SweetAlert2} instance
|
|
1539
|
+
* @param {SweetAlertOptions} params
|
|
1540
|
+
*/
|
|
1541
|
+
|
|
1285
1542
|
const renderIcon = (instance, params) => {
|
|
1286
1543
|
const innerParams = privateProps.innerParams.get(instance);
|
|
1287
1544
|
const icon = getIcon(); // if the given icon already rendered, apply the styling without re-rendering the icon
|
|
@@ -1309,6 +1566,10 @@
|
|
|
1309
1566
|
|
|
1310
1567
|
addClass(icon, params.showClass.icon);
|
|
1311
1568
|
};
|
|
1569
|
+
/**
|
|
1570
|
+
* @param {HTMLElement} icon
|
|
1571
|
+
* @param {SweetAlertOptions} params
|
|
1572
|
+
*/
|
|
1312
1573
|
|
|
1313
1574
|
const applyStyles = (icon, params) => {
|
|
1314
1575
|
for (const iconType in iconTypes) {
|
|
@@ -1330,6 +1591,8 @@
|
|
|
1330
1591
|
const adjustSuccessIconBackgroundColor = () => {
|
|
1331
1592
|
const popup = getPopup();
|
|
1332
1593
|
const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
|
|
1594
|
+
/** @type {NodeListOf<HTMLElement>} */
|
|
1595
|
+
|
|
1333
1596
|
const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
|
|
1334
1597
|
|
|
1335
1598
|
for (let i = 0; i < successIconParts.length; i++) {
|
|
@@ -1339,6 +1602,10 @@
|
|
|
1339
1602
|
|
|
1340
1603
|
const successIconHtml = "\n <div class=\"swal2-success-circular-line-left\"></div>\n <span class=\"swal2-success-line-tip\"></span> <span class=\"swal2-success-line-long\"></span>\n <div class=\"swal2-success-ring\"></div> <div class=\"swal2-success-fix\"></div>\n <div class=\"swal2-success-circular-line-right\"></div>\n";
|
|
1341
1604
|
const errorIconHtml = "\n <span class=\"swal2-x-mark\">\n <span class=\"swal2-x-mark-line-left\"></span>\n <span class=\"swal2-x-mark-line-right\"></span>\n </span>\n";
|
|
1605
|
+
/**
|
|
1606
|
+
* @param {HTMLElement} icon
|
|
1607
|
+
* @param {SweetAlertOptions} params
|
|
1608
|
+
*/
|
|
1342
1609
|
|
|
1343
1610
|
const setContent = (icon, params) => {
|
|
1344
1611
|
icon.textContent = '';
|
|
@@ -1358,6 +1625,11 @@
|
|
|
1358
1625
|
setInnerHtml(icon, iconContent(defaultIconHtml[params.icon]));
|
|
1359
1626
|
}
|
|
1360
1627
|
};
|
|
1628
|
+
/**
|
|
1629
|
+
* @param {HTMLElement} icon
|
|
1630
|
+
* @param {SweetAlertOptions} params
|
|
1631
|
+
*/
|
|
1632
|
+
|
|
1361
1633
|
|
|
1362
1634
|
const setColor = (icon, params) => {
|
|
1363
1635
|
if (!params.iconColor) {
|
|
@@ -1373,9 +1645,18 @@
|
|
|
1373
1645
|
|
|
1374
1646
|
setStyle(icon, '.swal2-success-ring', 'borderColor', params.iconColor);
|
|
1375
1647
|
};
|
|
1648
|
+
/**
|
|
1649
|
+
* @param {string} content
|
|
1650
|
+
*/
|
|
1651
|
+
|
|
1376
1652
|
|
|
1377
1653
|
const iconContent = content => "<div class=\"".concat(swalClasses['icon-content'], "\">").concat(content, "</div>");
|
|
1378
1654
|
|
|
1655
|
+
/**
|
|
1656
|
+
* @param {SweetAlert2} instance
|
|
1657
|
+
* @param {SweetAlertOptions} params
|
|
1658
|
+
*/
|
|
1659
|
+
|
|
1379
1660
|
const renderImage = (instance, params) => {
|
|
1380
1661
|
const image = getImage();
|
|
1381
1662
|
|
|
@@ -1395,23 +1676,10 @@
|
|
|
1395
1676
|
applyCustomClass(image, params, 'image');
|
|
1396
1677
|
};
|
|
1397
1678
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
return stepEl;
|
|
1403
|
-
};
|
|
1404
|
-
|
|
1405
|
-
const createLineElement = params => {
|
|
1406
|
-
const lineEl = document.createElement('li');
|
|
1407
|
-
addClass(lineEl, swalClasses['progress-step-line']);
|
|
1408
|
-
|
|
1409
|
-
if (params.progressStepsDistance) {
|
|
1410
|
-
lineEl.style.width = params.progressStepsDistance;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
return lineEl;
|
|
1414
|
-
};
|
|
1679
|
+
/**
|
|
1680
|
+
* @param {SweetAlert2} instance
|
|
1681
|
+
* @param {SweetAlertOptions} params
|
|
1682
|
+
*/
|
|
1415
1683
|
|
|
1416
1684
|
const renderProgressSteps = (instance, params) => {
|
|
1417
1685
|
const progressStepsContainer = getProgressSteps();
|
|
@@ -1441,6 +1709,38 @@
|
|
|
1441
1709
|
}
|
|
1442
1710
|
});
|
|
1443
1711
|
};
|
|
1712
|
+
/**
|
|
1713
|
+
* @param {string} step
|
|
1714
|
+
* @returns {HTMLLIElement}
|
|
1715
|
+
*/
|
|
1716
|
+
|
|
1717
|
+
const createStepElement = step => {
|
|
1718
|
+
const stepEl = document.createElement('li');
|
|
1719
|
+
addClass(stepEl, swalClasses['progress-step']);
|
|
1720
|
+
setInnerHtml(stepEl, step);
|
|
1721
|
+
return stepEl;
|
|
1722
|
+
};
|
|
1723
|
+
/**
|
|
1724
|
+
* @param {SweetAlertOptions} params
|
|
1725
|
+
* @returns {HTMLLIElement}
|
|
1726
|
+
*/
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
const createLineElement = params => {
|
|
1730
|
+
const lineEl = document.createElement('li');
|
|
1731
|
+
addClass(lineEl, swalClasses['progress-step-line']);
|
|
1732
|
+
|
|
1733
|
+
if (params.progressStepsDistance) {
|
|
1734
|
+
applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
return lineEl;
|
|
1738
|
+
};
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
* @param {SweetAlert2} instance
|
|
1742
|
+
* @param {SweetAlertOptions} params
|
|
1743
|
+
*/
|
|
1444
1744
|
|
|
1445
1745
|
const renderTitle = (instance, params) => {
|
|
1446
1746
|
const title = getTitle();
|
|
@@ -1458,6 +1758,11 @@
|
|
|
1458
1758
|
applyCustomClass(title, params, 'title');
|
|
1459
1759
|
};
|
|
1460
1760
|
|
|
1761
|
+
/**
|
|
1762
|
+
* @param {SweetAlert2} instance
|
|
1763
|
+
* @param {SweetAlertOptions} params
|
|
1764
|
+
*/
|
|
1765
|
+
|
|
1461
1766
|
const renderPopup = (instance, params) => {
|
|
1462
1767
|
const container = getContainer();
|
|
1463
1768
|
const popup = getPopup(); // Width
|
|
@@ -1487,6 +1792,10 @@
|
|
|
1487
1792
|
|
|
1488
1793
|
addClasses(popup, params);
|
|
1489
1794
|
};
|
|
1795
|
+
/**
|
|
1796
|
+
* @param {HTMLElement} popup
|
|
1797
|
+
* @param {SweetAlertOptions} params
|
|
1798
|
+
*/
|
|
1490
1799
|
|
|
1491
1800
|
const addClasses = (popup, params) => {
|
|
1492
1801
|
// Default Class + showClass when updating Swal.update({})
|
|
@@ -1512,6 +1821,11 @@
|
|
|
1512
1821
|
}
|
|
1513
1822
|
};
|
|
1514
1823
|
|
|
1824
|
+
/**
|
|
1825
|
+
* @param {SweetAlert2} instance
|
|
1826
|
+
* @param {SweetAlertOptions} params
|
|
1827
|
+
*/
|
|
1828
|
+
|
|
1515
1829
|
const render = (instance, params) => {
|
|
1516
1830
|
renderPopup(instance, params);
|
|
1517
1831
|
renderContainer(instance, params);
|
|
@@ -2130,8 +2444,8 @@
|
|
|
2130
2444
|
}
|
|
2131
2445
|
|
|
2132
2446
|
show(loader);
|
|
2133
|
-
popup.setAttribute('data-loading', true);
|
|
2134
|
-
popup.setAttribute('aria-busy', true);
|
|
2447
|
+
popup.setAttribute('data-loading', 'true');
|
|
2448
|
+
popup.setAttribute('aria-busy', 'true');
|
|
2135
2449
|
popup.focus();
|
|
2136
2450
|
};
|
|
2137
2451
|
|
|
@@ -2421,6 +2735,10 @@
|
|
|
2421
2735
|
|
|
2422
2736
|
const clickCancel = () => getCancelButton() && getCancelButton().click();
|
|
2423
2737
|
|
|
2738
|
+
/**
|
|
2739
|
+
* @param {GlobalState} globalState
|
|
2740
|
+
*/
|
|
2741
|
+
|
|
2424
2742
|
const removeKeydownHandler = globalState => {
|
|
2425
2743
|
if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
|
|
2426
2744
|
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
|
|
@@ -2429,6 +2747,13 @@
|
|
|
2429
2747
|
globalState.keydownHandlerAdded = false;
|
|
2430
2748
|
}
|
|
2431
2749
|
};
|
|
2750
|
+
/**
|
|
2751
|
+
* @param {SweetAlert2} instance
|
|
2752
|
+
* @param {GlobalState} globalState
|
|
2753
|
+
* @param {SweetAlertOptions} innerParams
|
|
2754
|
+
* @param {*} dismissWith
|
|
2755
|
+
*/
|
|
2756
|
+
|
|
2432
2757
|
const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
|
|
2433
2758
|
removeKeydownHandler(globalState);
|
|
2434
2759
|
|
|
@@ -2442,7 +2767,12 @@
|
|
|
2442
2767
|
});
|
|
2443
2768
|
globalState.keydownHandlerAdded = true;
|
|
2444
2769
|
}
|
|
2445
|
-
};
|
|
2770
|
+
};
|
|
2771
|
+
/**
|
|
2772
|
+
* @param {SweetAlertOptions} innerParams
|
|
2773
|
+
* @param {number} index
|
|
2774
|
+
* @param {number} increment
|
|
2775
|
+
*/
|
|
2446
2776
|
|
|
2447
2777
|
const setFocus = (innerParams, index, increment) => {
|
|
2448
2778
|
const focusableElements = getFocusableElements(); // search for visible elements and select the next possible match
|
|
@@ -2464,6 +2794,11 @@
|
|
|
2464
2794
|
};
|
|
2465
2795
|
const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
|
|
2466
2796
|
const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
|
|
2797
|
+
/**
|
|
2798
|
+
* @param {SweetAlert2} instance
|
|
2799
|
+
* @param {KeyboardEvent} e
|
|
2800
|
+
* @param {function} dismissWith
|
|
2801
|
+
*/
|
|
2467
2802
|
|
|
2468
2803
|
const keydownHandler = (instance, e, dismissWith) => {
|
|
2469
2804
|
const innerParams = privateProps.innerParams.get(instance);
|
|
@@ -2498,6 +2833,12 @@
|
|
|
2498
2833
|
handleEsc(e, innerParams, dismissWith);
|
|
2499
2834
|
}
|
|
2500
2835
|
};
|
|
2836
|
+
/**
|
|
2837
|
+
* @param {SweetAlert2} instance
|
|
2838
|
+
* @param {KeyboardEvent} e
|
|
2839
|
+
* @param {SweetAlertOptions} innerParams
|
|
2840
|
+
*/
|
|
2841
|
+
|
|
2501
2842
|
|
|
2502
2843
|
const handleEnter = (instance, e, innerParams) => {
|
|
2503
2844
|
// https://github.com/sweetalert2/sweetalert2/issues/2386
|
|
@@ -2505,7 +2846,7 @@
|
|
|
2505
2846
|
return;
|
|
2506
2847
|
}
|
|
2507
2848
|
|
|
2508
|
-
if (e.target && instance.getInput() && e.target.outerHTML === instance.getInput().outerHTML) {
|
|
2849
|
+
if (e.target && instance.getInput() && e.target instanceof HTMLElement && e.target.outerHTML === instance.getInput().outerHTML) {
|
|
2509
2850
|
if (['textarea', 'file'].includes(innerParams.input)) {
|
|
2510
2851
|
return; // do not submit
|
|
2511
2852
|
}
|
|
@@ -2514,6 +2855,11 @@
|
|
|
2514
2855
|
e.preventDefault();
|
|
2515
2856
|
}
|
|
2516
2857
|
};
|
|
2858
|
+
/**
|
|
2859
|
+
* @param {KeyboardEvent} e
|
|
2860
|
+
* @param {SweetAlertOptions} innerParams
|
|
2861
|
+
*/
|
|
2862
|
+
|
|
2517
2863
|
|
|
2518
2864
|
const handleTab = (e, innerParams) => {
|
|
2519
2865
|
const targetElement = e.target;
|
|
@@ -2538,13 +2884,17 @@
|
|
|
2538
2884
|
e.stopPropagation();
|
|
2539
2885
|
e.preventDefault();
|
|
2540
2886
|
};
|
|
2887
|
+
/**
|
|
2888
|
+
* @param {string} key
|
|
2889
|
+
*/
|
|
2890
|
+
|
|
2541
2891
|
|
|
2542
2892
|
const handleArrows = key => {
|
|
2543
2893
|
const confirmButton = getConfirmButton();
|
|
2544
2894
|
const denyButton = getDenyButton();
|
|
2545
2895
|
const cancelButton = getCancelButton();
|
|
2546
2896
|
|
|
2547
|
-
if (![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
|
|
2897
|
+
if (document.activeElement instanceof HTMLElement && ![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
|
|
2548
2898
|
return;
|
|
2549
2899
|
}
|
|
2550
2900
|
|
|
@@ -2558,7 +2908,7 @@
|
|
|
2558
2908
|
return;
|
|
2559
2909
|
}
|
|
2560
2910
|
|
|
2561
|
-
if (
|
|
2911
|
+
if (buttonToFocus instanceof HTMLButtonElement && isVisible(buttonToFocus)) {
|
|
2562
2912
|
break;
|
|
2563
2913
|
}
|
|
2564
2914
|
}
|
|
@@ -2567,6 +2917,12 @@
|
|
|
2567
2917
|
buttonToFocus.focus();
|
|
2568
2918
|
}
|
|
2569
2919
|
};
|
|
2920
|
+
/**
|
|
2921
|
+
* @param {KeyboardEvent} e
|
|
2922
|
+
* @param {SweetAlertOptions} innerParams
|
|
2923
|
+
* @param {function} dismissWith
|
|
2924
|
+
*/
|
|
2925
|
+
|
|
2570
2926
|
|
|
2571
2927
|
const handleEsc = (e, innerParams, dismissWith) => {
|
|
2572
2928
|
if (callIfFunction(innerParams.allowEscapeKey)) {
|
|
@@ -2856,12 +3212,6 @@
|
|
|
2856
3212
|
if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
|
|
2857
3213
|
globalState.swalCloseEventFinishedCallback();
|
|
2858
3214
|
delete globalState.swalCloseEventFinishedCallback;
|
|
2859
|
-
} // Check if there is a swal disposal defer timer
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
if (globalState.deferDisposalTimer) {
|
|
2863
|
-
clearTimeout(globalState.deferDisposalTimer);
|
|
2864
|
-
delete globalState.deferDisposalTimer;
|
|
2865
3215
|
}
|
|
2866
3216
|
|
|
2867
3217
|
if (typeof innerParams.didDestroy === 'function') {
|
|
@@ -2870,9 +3220,13 @@
|
|
|
2870
3220
|
|
|
2871
3221
|
disposeSwal(this);
|
|
2872
3222
|
}
|
|
3223
|
+
/**
|
|
3224
|
+
* @param {SweetAlert2} instance
|
|
3225
|
+
*/
|
|
2873
3226
|
|
|
2874
3227
|
const disposeSwal = instance => {
|
|
2875
3228
|
disposeWeakMaps(instance); // Unset this.params so GC will dispose it (#1569)
|
|
3229
|
+
// @ts-ignore
|
|
2876
3230
|
|
|
2877
3231
|
delete instance.params; // Unset globalState props so GC will dispose globalState (#1569)
|
|
2878
3232
|
|
|
@@ -2881,9 +3235,14 @@
|
|
|
2881
3235
|
|
|
2882
3236
|
delete globalState.currentInstance;
|
|
2883
3237
|
};
|
|
3238
|
+
/**
|
|
3239
|
+
* @param {SweetAlert2} instance
|
|
3240
|
+
*/
|
|
3241
|
+
|
|
2884
3242
|
|
|
2885
3243
|
const disposeWeakMaps = instance => {
|
|
2886
3244
|
// If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
|
|
3245
|
+
// @ts-ignore
|
|
2887
3246
|
if (instance.isAwaitingPromise()) {
|
|
2888
3247
|
unsetWeakMaps(privateProps, instance);
|
|
2889
3248
|
privateProps.awaitingPromise.set(instance, true);
|
|
@@ -2892,6 +3251,11 @@
|
|
|
2892
3251
|
unsetWeakMaps(privateProps, instance);
|
|
2893
3252
|
}
|
|
2894
3253
|
};
|
|
3254
|
+
/**
|
|
3255
|
+
* @param {object} obj
|
|
3256
|
+
* @param {SweetAlert2} instance
|
|
3257
|
+
*/
|
|
3258
|
+
|
|
2895
3259
|
|
|
2896
3260
|
const unsetWeakMaps = (obj, instance) => {
|
|
2897
3261
|
for (const i in obj) {
|
|
@@ -3355,7 +3719,7 @@
|
|
|
3355
3719
|
}
|
|
3356
3720
|
}); // @ts-ignore
|
|
3357
3721
|
|
|
3358
|
-
const promise =
|
|
3722
|
+
const promise = currentInstance._main(currentInstance.params);
|
|
3359
3723
|
|
|
3360
3724
|
privateProps.promise.set(this, promise);
|
|
3361
3725
|
}
|
|
@@ -3365,6 +3729,7 @@
|
|
|
3365
3729
|
showWarningsForParams(Object.assign({}, mixinParams, userParams));
|
|
3366
3730
|
|
|
3367
3731
|
if (globalState.currentInstance) {
|
|
3732
|
+
// @ts-ignore
|
|
3368
3733
|
globalState.currentInstance._destroy();
|
|
3369
3734
|
|
|
3370
3735
|
if (isModal()) {
|
|
@@ -3372,7 +3737,7 @@
|
|
|
3372
3737
|
}
|
|
3373
3738
|
}
|
|
3374
3739
|
|
|
3375
|
-
globalState.currentInstance =
|
|
3740
|
+
globalState.currentInstance = currentInstance;
|
|
3376
3741
|
const innerParams = prepareParams(userParams, mixinParams);
|
|
3377
3742
|
setParameters(innerParams);
|
|
3378
3743
|
Object.freeze(innerParams); // clear the previous timer
|
|
@@ -3384,10 +3749,10 @@
|
|
|
3384
3749
|
|
|
3385
3750
|
|
|
3386
3751
|
clearTimeout(globalState.restoreFocusTimeout);
|
|
3387
|
-
const domCache = populateDomCache(
|
|
3388
|
-
render(
|
|
3389
|
-
privateProps.innerParams.set(
|
|
3390
|
-
return swalPromise(
|
|
3752
|
+
const domCache = populateDomCache(currentInstance);
|
|
3753
|
+
render(currentInstance, innerParams);
|
|
3754
|
+
privateProps.innerParams.set(currentInstance, innerParams);
|
|
3755
|
+
return swalPromise(currentInstance, domCache, innerParams);
|
|
3391
3756
|
} // `catch` cannot be the name of a module export, so we define our thenable methods here instead
|
|
3392
3757
|
|
|
3393
3758
|
|
|
@@ -3445,6 +3810,11 @@
|
|
|
3445
3810
|
params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
|
|
3446
3811
|
return params;
|
|
3447
3812
|
};
|
|
3813
|
+
/**
|
|
3814
|
+
* @param {SweetAlert2} instance
|
|
3815
|
+
* @returns {DomCache}
|
|
3816
|
+
*/
|
|
3817
|
+
|
|
3448
3818
|
|
|
3449
3819
|
const populateDomCache = instance => {
|
|
3450
3820
|
const domCache = {
|
|
@@ -3462,6 +3832,12 @@
|
|
|
3462
3832
|
privateProps.domCache.set(instance, domCache);
|
|
3463
3833
|
return domCache;
|
|
3464
3834
|
};
|
|
3835
|
+
/**
|
|
3836
|
+
* @param {GlobalState} globalState
|
|
3837
|
+
* @param {SweetAlertOptions} innerParams
|
|
3838
|
+
* @param {function} dismissWith
|
|
3839
|
+
*/
|
|
3840
|
+
|
|
3465
3841
|
|
|
3466
3842
|
const setupTimer = (globalState$$1, innerParams, dismissWith) => {
|
|
3467
3843
|
const timerProgressBar = getTimerProgressBar();
|
|
@@ -3485,6 +3861,11 @@
|
|
|
3485
3861
|
}
|
|
3486
3862
|
}
|
|
3487
3863
|
};
|
|
3864
|
+
/**
|
|
3865
|
+
* @param {DomCache} domCache
|
|
3866
|
+
* @param {SweetAlertOptions} innerParams
|
|
3867
|
+
*/
|
|
3868
|
+
|
|
3488
3869
|
|
|
3489
3870
|
const initFocus = (domCache, innerParams) => {
|
|
3490
3871
|
if (innerParams.toast) {
|
|
@@ -3499,6 +3880,12 @@
|
|
|
3499
3880
|
setFocus(innerParams, -1, 1);
|
|
3500
3881
|
}
|
|
3501
3882
|
};
|
|
3883
|
+
/**
|
|
3884
|
+
* @param {DomCache} domCache
|
|
3885
|
+
* @param {SweetAlertOptions} innerParams
|
|
3886
|
+
* @returns {boolean}
|
|
3887
|
+
*/
|
|
3888
|
+
|
|
3502
3889
|
|
|
3503
3890
|
const focusButton = (domCache, innerParams) => {
|
|
3504
3891
|
if (innerParams.focusDeny && isVisible(domCache.denyButton)) {
|
|
@@ -3538,7 +3925,7 @@
|
|
|
3538
3925
|
};
|
|
3539
3926
|
});
|
|
3540
3927
|
SweetAlert.DismissReason = DismissReason;
|
|
3541
|
-
SweetAlert.version = '11.4.
|
|
3928
|
+
SweetAlert.version = '11.4.16';
|
|
3542
3929
|
|
|
3543
3930
|
const Swal = SweetAlert; // @ts-ignore
|
|
3544
3931
|
|