sweetalert2 11.3.1 → 11.3.5

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sweetalert2 v11.3.1
2
+ * sweetalert2 v11.3.5
3
3
  * Released under the MIT License.
4
4
  */
5
5
  (function (global, factory) {
@@ -27,27 +27,28 @@
27
27
  };
28
28
  /**
29
29
  * Capitalize the first letter of a string
30
- * @param str
30
+ * @param {string} str
31
+ * @returns {string}
31
32
  */
32
33
 
33
34
  const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
34
35
  /**
35
- * Convert NodeList to Array
36
- * @param nodeList
36
+ * @param {NodeList | HTMLCollection | NamedNodeMap} nodeList
37
+ * @returns {array}
37
38
  */
38
39
 
39
40
  const toArray = nodeList => Array.prototype.slice.call(nodeList);
40
41
  /**
41
- * Standardise console warnings
42
- * @param message
42
+ * Standardize console warnings
43
+ * @param {string | array} message
43
44
  */
44
45
 
45
46
  const warn = message => {
46
47
  console.warn("".concat(consolePrefix, " ").concat(typeof message === 'object' ? message.join(' ') : message));
47
48
  };
48
49
  /**
49
- * Standardise console errors
50
- * @param message
50
+ * Standardize console errors
51
+ * @param {string} message
51
52
  */
52
53
 
53
54
  const error = message => {
@@ -62,7 +63,7 @@
62
63
  const previousWarnOnceMessages = [];
63
64
  /**
64
65
  * Show a console warning, but only if it hasn't already been shown
65
- * @param message
66
+ * @param {string} message
66
67
  */
67
68
 
68
69
  const warnOnce = message => {
@@ -183,7 +184,7 @@
183
184
  const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
184
185
  /**
185
186
  * Is valid parameter
186
- * @param {String} paramName
187
+ * @param {string} paramName
187
188
  */
188
189
 
189
190
  const isValidParameter = paramName => {
@@ -191,7 +192,7 @@
191
192
  };
192
193
  /**
193
194
  * Is valid parameter for Swal.update() method
194
- * @param {String} paramName
195
+ * @param {string} paramName
195
196
  */
196
197
 
197
198
  const isUpdatableParameter = paramName => {
@@ -199,7 +200,7 @@
199
200
  };
200
201
  /**
201
202
  * Is deprecated parameter
202
- * @param {String} paramName
203
+ * @param {string} paramName
203
204
  */
204
205
 
205
206
  const isDeprecatedParameter = paramName => {
@@ -259,6 +260,12 @@
259
260
  const swalClasses = prefix(['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'default-outline', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error']);
260
261
  const iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
261
262
 
263
+ /**
264
+ * Gets the popup container which contains the backdrop and the popup itself.
265
+ *
266
+ * @returns {HTMLElement | null}
267
+ */
268
+
262
269
  const getContainer = () => document.body.querySelector(".".concat(swalClasses.container));
263
270
  const elementBySelector = selectorString => {
264
271
  const container = getContainer();
@@ -290,12 +297,12 @@
290
297
  const getFocusableElements = () => {
291
298
  const focusableElementsWithTabindex = toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')) // sort according to tabindex
292
299
  .sort((a, b) => {
293
- a = parseInt(a.getAttribute('tabindex'));
294
- b = parseInt(b.getAttribute('tabindex'));
300
+ const tabindexA = parseInt(a.getAttribute('tabindex'));
301
+ const tabindexB = parseInt(b.getAttribute('tabindex'));
295
302
 
296
- if (a > b) {
303
+ if (tabindexA > tabindexB) {
297
304
  return 1;
298
- } else if (a < b) {
305
+ } else if (tabindexA < tabindexB) {
299
306
  return -1;
300
307
  }
301
308
 
@@ -317,8 +324,15 @@
317
324
  const states = {
318
325
  previousBodyPadding: null
319
326
  };
327
+ /**
328
+ * Securely set innerHTML of an element
329
+ * https://github.com/sweetalert2/sweetalert2/issues/1926
330
+ *
331
+ * @param {HTMLElement} elem
332
+ * @param {string} html
333
+ */
334
+
320
335
  const setInnerHtml = (elem, html) => {
321
- // #1926
322
336
  elem.textContent = '';
323
337
 
324
338
  if (html) {
@@ -332,6 +346,12 @@
332
346
  });
333
347
  }
334
348
  };
349
+ /**
350
+ * @param {HTMLElement} elem
351
+ * @param {string} className
352
+ * @returns {boolean}
353
+ */
354
+
335
355
  const hasClass = (elem, className) => {
336
356
  if (!className) {
337
357
  return false;
@@ -367,6 +387,12 @@
367
387
  addClass(elem, params.customClass[className]);
368
388
  }
369
389
  };
390
+ /**
391
+ * @param {HTMLElement} popup
392
+ * @param {string} inputType
393
+ * @returns {HTMLInputElement | null}
394
+ */
395
+
370
396
  const getInput = (popup, inputType) => {
371
397
  if (!inputType) {
372
398
  return null;
@@ -376,21 +402,25 @@
376
402
  case 'select':
377
403
  case 'textarea':
378
404
  case 'file':
379
- return getChildByClass(popup, swalClasses[inputType]);
405
+ return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses[inputType]));
380
406
 
381
407
  case 'checkbox':
382
- return popup.querySelector(".".concat(swalClasses.checkbox, " input"));
408
+ return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.checkbox, " input"));
383
409
 
384
410
  case 'radio':
385
- return popup.querySelector(".".concat(swalClasses.radio, " input:checked")) || popup.querySelector(".".concat(swalClasses.radio, " input:first-child"));
411
+ return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.radio, " input:checked")) || popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.radio, " input:first-child"));
386
412
 
387
413
  case 'range':
388
- return popup.querySelector(".".concat(swalClasses.range, " input"));
414
+ return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.range, " input"));
389
415
 
390
416
  default:
391
- return getChildByClass(popup, swalClasses.input);
417
+ return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.input));
392
418
  }
393
419
  };
420
+ /**
421
+ * @param {HTMLInputElement} input
422
+ */
423
+
394
424
  const focusInput = input => {
395
425
  input.focus(); // place cursor at end of text in text input
396
426
 
@@ -401,6 +431,12 @@
401
431
  input.value = val;
402
432
  }
403
433
  };
434
+ /**
435
+ * @param {HTMLElement | HTMLElement[] | null} target
436
+ * @param {string | string[]} classList
437
+ * @param {boolean} condition
438
+ */
439
+
404
440
  const toggleClass = (target, classList, condition) => {
405
441
  if (!target || !classList) {
406
442
  return;
@@ -411,7 +447,7 @@
411
447
  }
412
448
 
413
449
  classList.forEach(className => {
414
- if (target.forEach) {
450
+ if (Array.isArray(target)) {
415
451
  target.forEach(elem => {
416
452
  condition ? elem.classList.add(className) : elem.classList.remove(className);
417
453
  });
@@ -420,19 +456,45 @@
420
456
  }
421
457
  });
422
458
  };
459
+ /**
460
+ * @param {HTMLElement | HTMLElement[] | null} target
461
+ * @param {string | string[]} classList
462
+ */
463
+
423
464
  const addClass = (target, classList) => {
424
465
  toggleClass(target, classList, true);
425
466
  };
467
+ /**
468
+ * @param {HTMLElement | HTMLElement[] | null} target
469
+ * @param {string | string[]} classList
470
+ */
471
+
426
472
  const removeClass = (target, classList) => {
427
473
  toggleClass(target, classList, false);
428
474
  };
429
- const getChildByClass = (elem, className) => {
430
- for (let i = 0; i < elem.childNodes.length; i++) {
431
- if (hasClass(elem.childNodes[i], className)) {
432
- return elem.childNodes[i];
475
+ /**
476
+ * Get direct child of an element by class name
477
+ *
478
+ * @param {HTMLElement} elem
479
+ * @param {string} className
480
+ * @returns {HTMLElement | null}
481
+ */
482
+
483
+ const getDirectChildByClass = (elem, className) => {
484
+ const childNodes = toArray(elem.childNodes);
485
+
486
+ for (let i = 0; i < childNodes.length; i++) {
487
+ if (hasClass(childNodes[i], className)) {
488
+ return childNodes[i];
433
489
  }
434
490
  }
435
491
  };
492
+ /**
493
+ * @param {HTMLElement} elem
494
+ * @param {string} property
495
+ * @param {*} value
496
+ */
497
+
436
498
  const applyNumericalStyle = (elem, property, value) => {
437
499
  if (value === "".concat(parseInt(value))) {
438
500
  value = parseInt(value);
@@ -444,10 +506,19 @@
444
506
  elem.style.removeProperty(property);
445
507
  }
446
508
  };
509
+ /**
510
+ * @param {HTMLElement} elem
511
+ * @param {string} display
512
+ */
513
+
447
514
  const show = function (elem) {
448
515
  let display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'flex';
449
516
  elem.style.display = display;
450
517
  };
518
+ /**
519
+ * @param {HTMLElement} elem
520
+ */
521
+
451
522
  const hide = elem => {
452
523
  elem.style.display = 'none';
453
524
  };
@@ -494,7 +565,7 @@
494
565
  timerProgressBar.style.removeProperty('transition');
495
566
  timerProgressBar.style.width = '100%';
496
567
  const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
497
- const timerProgressBarPercent = parseInt(timerProgressBarWidth / timerProgressBarFullWidth * 100);
568
+ const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
498
569
  timerProgressBar.style.removeProperty('transition');
499
570
  timerProgressBar.style.width = "".concat(timerProgressBarPercent, "%");
500
571
  };
@@ -502,6 +573,37 @@
502
573
  // Detect Node env
503
574
  const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
504
575
 
576
+ const RESTORE_FOCUS_TIMEOUT = 100;
577
+
578
+ const globalState = {};
579
+
580
+ const focusPreviousActiveElement = () => {
581
+ if (globalState.previousActiveElement && globalState.previousActiveElement.focus) {
582
+ globalState.previousActiveElement.focus();
583
+ globalState.previousActiveElement = null;
584
+ } else if (document.body) {
585
+ document.body.focus();
586
+ }
587
+ }; // Restore previous active (focused) element
588
+
589
+
590
+ const restoreActiveElement = returnFocus => {
591
+ return new Promise(resolve => {
592
+ if (!returnFocus) {
593
+ return resolve();
594
+ }
595
+
596
+ const x = window.scrollX;
597
+ const y = window.scrollY;
598
+ globalState.restoreFocusTimeout = setTimeout(() => {
599
+ focusPreviousActiveElement();
600
+ resolve();
601
+ }, RESTORE_FOCUS_TIMEOUT); // issues/900
602
+
603
+ window.scrollTo(x, y);
604
+ });
605
+ };
606
+
505
607
  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, '');
506
608
 
507
609
  const resetOldContainer = () => {
@@ -517,20 +619,18 @@
517
619
  };
518
620
 
519
621
  const resetValidationMessage = () => {
520
- if (Swal.isVisible()) {
521
- Swal.resetValidationMessage();
522
- }
622
+ globalState.currentInstance.resetValidationMessage();
523
623
  };
524
624
 
525
625
  const addInputChangeListeners = () => {
526
626
  const popup = getPopup();
527
- const input = getChildByClass(popup, swalClasses.input);
528
- const file = getChildByClass(popup, swalClasses.file);
627
+ const input = getDirectChildByClass(popup, swalClasses.input);
628
+ const file = getDirectChildByClass(popup, swalClasses.file);
529
629
  const range = popup.querySelector(".".concat(swalClasses.range, " input"));
530
630
  const rangeOutput = popup.querySelector(".".concat(swalClasses.range, " output"));
531
- const select = getChildByClass(popup, swalClasses.select);
631
+ const select = getDirectChildByClass(popup, swalClasses.select);
532
632
  const checkbox = popup.querySelector(".".concat(swalClasses.checkbox, " input"));
533
- const textarea = getChildByClass(popup, swalClasses.textarea);
633
+ const textarea = getDirectChildByClass(popup, swalClasses.textarea);
534
634
  input.oninput = resetValidationMessage;
535
635
  file.onchange = resetValidationMessage;
536
636
  select.onchange = resetValidationMessage;
@@ -638,8 +738,9 @@
638
738
  const testEl = document.createElement('div');
639
739
  const transEndEventNames = {
640
740
  WebkitAnimation: 'webkitAnimationEnd',
641
- OAnimation: 'oAnimationEnd oanimationend',
642
- animation: 'animationend'
741
+ // Chrome, Safari and Opera
742
+ animation: 'animationend' // Standard syntax
743
+
643
744
  };
644
745
 
645
746
  for (const i in transEndEventNames) {
@@ -802,7 +903,7 @@
802
903
  const rerender = !innerParams || params.input !== innerParams.input;
803
904
  inputTypes.forEach(inputType => {
804
905
  const inputClass = swalClasses[inputType];
805
- const inputContainer = getChildByClass(popup, inputClass); // set attributes
906
+ const inputContainer = getDirectChildByClass(popup, inputClass); // set attributes
806
907
 
807
908
  setAttributes(inputType, params.inputAttributes); // set class
808
909
 
@@ -890,7 +991,7 @@
890
991
 
891
992
  const getInputContainer = inputType => {
892
993
  const inputClass = swalClasses[inputType] ? swalClasses[inputType] : swalClasses.input;
893
- return getChildByClass(getPopup(), inputClass);
994
+ return getDirectChildByClass(getPopup(), inputClass);
894
995
  };
895
996
 
896
997
  const renderInputType = {};
@@ -946,8 +1047,9 @@
946
1047
  };
947
1048
 
948
1049
  renderInputType.checkbox = (checkboxContainer, params) => {
1050
+ /** @type {HTMLInputElement} */
949
1051
  const checkbox = getInput(getPopup(), 'checkbox');
950
- checkbox.value = 1;
1052
+ checkbox.value = '1';
951
1053
  checkbox.id = swalClasses.checkbox;
952
1054
  checkbox.checked = Boolean(params.inputValue);
953
1055
  const label = checkboxContainer.querySelector('span');
@@ -1064,13 +1166,13 @@
1064
1166
 
1065
1167
  setColor(icon, params); // Success icon background color
1066
1168
 
1067
- adjustSuccessIconBackgoundColor(); // Custom class
1169
+ adjustSuccessIconBackgroundColor(); // Custom class
1068
1170
 
1069
1171
  applyCustomClass(icon, params, 'icon');
1070
1172
  }; // Adjust success icon background color to match the popup background color
1071
1173
 
1072
1174
 
1073
- const adjustSuccessIconBackgoundColor = () => {
1175
+ const adjustSuccessIconBackgroundColor = () => {
1074
1176
  const popup = getPopup();
1075
1177
  const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
1076
1178
  const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
@@ -1326,17 +1428,15 @@
1326
1428
  toArray(templateContent.querySelectorAll('swal-param')).forEach(param => {
1327
1429
  showWarningsForAttributes(param, ['name', 'value']);
1328
1430
  const paramName = param.getAttribute('name');
1329
- let value = param.getAttribute('value');
1431
+ const value = param.getAttribute('value');
1330
1432
 
1331
1433
  if (typeof defaultParams[paramName] === 'boolean' && value === 'false') {
1332
- value = false;
1434
+ result[paramName] = false;
1333
1435
  }
1334
1436
 
1335
1437
  if (typeof defaultParams[paramName] === 'object') {
1336
- value = JSON.parse(value);
1438
+ result[paramName] = JSON.parse(value);
1337
1439
  }
1338
-
1339
- result[paramName] = value;
1340
1440
  });
1341
1441
  return result;
1342
1442
  };
@@ -1470,6 +1570,11 @@
1470
1570
  }
1471
1571
  });
1472
1572
  };
1573
+ /**
1574
+ * @param {HTMLElement} el
1575
+ * @param {string[]} allowedAttributes
1576
+ */
1577
+
1473
1578
 
1474
1579
  const showWarningsForAttributes = (el, allowedAttributes) => {
1475
1580
  toArray(el.attributes).forEach(attribute => {
@@ -1511,7 +1616,6 @@
1511
1616
  * Set type, text and actions on popup
1512
1617
  *
1513
1618
  * @param params
1514
- * @returns {boolean}
1515
1619
  */
1516
1620
 
1517
1621
 
@@ -1553,7 +1657,7 @@
1553
1657
  if (this.running) {
1554
1658
  this.running = false;
1555
1659
  clearTimeout(this.id);
1556
- this.remaining -= new Date() - this.started;
1660
+ this.remaining -= new Date().getTime() - this.started.getTime();
1557
1661
  }
1558
1662
 
1559
1663
  return this.remaining;
@@ -1613,6 +1717,7 @@
1613
1717
  /* istanbul ignore file */
1614
1718
 
1615
1719
  const iOSfix = () => {
1720
+ // @ts-ignore
1616
1721
  const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
1617
1722
 
1618
1723
  if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
@@ -1620,14 +1725,20 @@
1620
1725
  document.body.style.top = "".concat(offset * -1, "px");
1621
1726
  addClass(document.body, swalClasses.iosfix);
1622
1727
  lockBodyScroll();
1623
- addBottomPaddingForTallPopups(); // #1948
1728
+ addBottomPaddingForTallPopups();
1624
1729
  }
1625
1730
  };
1731
+ /**
1732
+ * https://github.com/sweetalert2/sweetalert2/issues/1948
1733
+ */
1626
1734
 
1627
1735
  const addBottomPaddingForTallPopups = () => {
1628
- const safari = !navigator.userAgent.match(/(CriOS|FxiOS|EdgiOS|YaBrowser|UCBrowser)/i);
1736
+ const ua = navigator.userAgent;
1737
+ const iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
1738
+ const webkit = !!ua.match(/WebKit/i);
1739
+ const iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
1629
1740
 
1630
- if (safari) {
1741
+ if (iOSSafari) {
1631
1742
  const bottomPanelHeight = 44;
1632
1743
 
1633
1744
  if (getPopup().scrollHeight > window.innerHeight - bottomPanelHeight) {
@@ -1657,7 +1768,7 @@
1657
1768
  const target = event.target;
1658
1769
  const container = getContainer();
1659
1770
 
1660
- if (isStylys(event) || isZoom(event)) {
1771
+ if (isStylus(event) || isZoom(event)) {
1661
1772
  return false;
1662
1773
  }
1663
1774
 
@@ -1674,9 +1785,15 @@
1674
1785
 
1675
1786
  return false;
1676
1787
  };
1788
+ /**
1789
+ * https://github.com/sweetalert2/sweetalert2/issues/1786
1790
+ *
1791
+ * @param {*} event
1792
+ * @returns {boolean}
1793
+ */
1677
1794
 
1678
- const isStylys = event => {
1679
- // #1786
1795
+
1796
+ const isStylus = event => {
1680
1797
  return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';
1681
1798
  };
1682
1799
 
@@ -1694,37 +1811,6 @@
1694
1811
  }
1695
1812
  };
1696
1813
 
1697
- const RESTORE_FOCUS_TIMEOUT = 100;
1698
-
1699
- const globalState = {};
1700
-
1701
- const focusPreviousActiveElement = () => {
1702
- if (globalState.previousActiveElement && globalState.previousActiveElement.focus) {
1703
- globalState.previousActiveElement.focus();
1704
- globalState.previousActiveElement = null;
1705
- } else if (document.body) {
1706
- document.body.focus();
1707
- }
1708
- }; // Restore previous active (focused) element
1709
-
1710
-
1711
- const restoreActiveElement = returnFocus => {
1712
- return new Promise(resolve => {
1713
- if (!returnFocus) {
1714
- return resolve();
1715
- }
1716
-
1717
- const x = window.scrollX;
1718
- const y = window.scrollY;
1719
- globalState.restoreFocusTimeout = setTimeout(() => {
1720
- focusPreviousActiveElement();
1721
- resolve();
1722
- }, RESTORE_FOCUS_TIMEOUT); // issues/900
1723
-
1724
- window.scrollTo(x, y);
1725
- });
1726
- };
1727
-
1728
1814
  const SHOW_CLASS_TIMEOUT = 10;
1729
1815
  /**
1730
1816
  * Open popup, add necessary classes and styles, fix scrollbar
@@ -1799,7 +1885,7 @@
1799
1885
  };
1800
1886
 
1801
1887
  const addClasses$1 = (container, popup, params) => {
1802
- addClass(container, params.showClass.backdrop); // the workaround with setting/unsetting opacity is needed for #2019 and 2059
1888
+ addClass(container, params.showClass.backdrop); // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
1803
1889
 
1804
1890
  popup.style.setProperty('opacity', '0', 'important');
1805
1891
  show(popup, 'grid');
@@ -1826,7 +1912,7 @@
1826
1912
  let popup = getPopup();
1827
1913
 
1828
1914
  if (!popup) {
1829
- Swal.fire();
1915
+ new Swal(); // eslint-disable-line no-new
1830
1916
  }
1831
1917
 
1832
1918
  popup = getPopup();
@@ -1936,7 +2022,7 @@
1936
2022
 
1937
2023
  const populateInputOptions = {
1938
2024
  select: (popup, inputOptions, params) => {
1939
- const select = getChildByClass(popup, swalClasses.select);
2025
+ const select = getDirectChildByClass(popup, swalClasses.select);
1940
2026
 
1941
2027
  const renderOption = (parent, optionLabel, optionValue) => {
1942
2028
  const option = document.createElement('option');
@@ -1969,7 +2055,7 @@
1969
2055
  select.focus();
1970
2056
  },
1971
2057
  radio: (popup, inputOptions, params) => {
1972
- const radio = getChildByClass(popup, swalClasses.radio);
2058
+ const radio = getDirectChildByClass(popup, swalClasses.radio);
1973
2059
  inputOptions.forEach(inputOption => {
1974
2060
  const radioValue = inputOption[0];
1975
2061
  const radioLabel = inputOption[1];
@@ -2065,6 +2151,11 @@
2065
2151
  /* 'confirm' | 'deny' */
2066
2152
  ) => {
2067
2153
  const innerParams = privateProps.innerParams.get(instance);
2154
+
2155
+ if (!innerParams.input) {
2156
+ return error("The \"input\" parameter is needed to be set when using returnInputValueOn".concat(capitalizeFirstLetter(type)));
2157
+ }
2158
+
2068
2159
  const inputValue = getInputValue(instance, innerParams);
2069
2160
 
2070
2161
  if (innerParams.inputValidator) {
@@ -2107,7 +2198,7 @@
2107
2198
  }
2108
2199
 
2109
2200
  if (innerParams.preDeny) {
2110
- privateProps.awaitingPromise.set(instance || undefined, true); // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesnt get destroyed until the result from this preDeny's promise is received
2201
+ privateProps.awaitingPromise.set(instance || undefined, true); // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
2111
2202
 
2112
2203
  const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
2113
2204
  preDenyPromise.then(preDenyValue => {
@@ -2148,7 +2239,7 @@
2148
2239
 
2149
2240
  if (innerParams.preConfirm) {
2150
2241
  instance.resetValidationMessage();
2151
- privateProps.awaitingPromise.set(instance || undefined, true); // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesnt get destroyed until the result from this preConfirm's promise is received
2242
+ privateProps.awaitingPromise.set(instance || undefined, true); // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
2152
2243
 
2153
2244
  const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
2154
2245
  preConfirmPromise.then(preConfirmValue => {
@@ -2183,13 +2274,22 @@
2183
2274
  domCache.popup.onclick = () => {
2184
2275
  const innerParams = privateProps.innerParams.get(instance);
2185
2276
 
2186
- if (innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton || innerParams.timer || innerParams.input) {
2277
+ if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
2187
2278
  return;
2188
2279
  }
2189
2280
 
2190
2281
  dismissWith(DismissReason.close);
2191
2282
  };
2192
2283
  };
2284
+ /**
2285
+ * @param {*} innerParams
2286
+ * @returns {boolean}
2287
+ */
2288
+
2289
+
2290
+ const isAnyButtonShown = innerParams => {
2291
+ return innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton;
2292
+ };
2193
2293
 
2194
2294
  let ignoreOutsideClick = false;
2195
2295
 
@@ -2372,7 +2472,7 @@
2372
2472
  const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
2373
2473
  const buttonToFocus = document.activeElement[sibling];
2374
2474
 
2375
- if (buttonToFocus) {
2475
+ if (buttonToFocus instanceof HTMLElement) {
2376
2476
  buttonToFocus.focus();
2377
2477
  }
2378
2478
  };
@@ -2619,6 +2719,11 @@
2619
2719
  }
2620
2720
  };
2621
2721
 
2722
+ /**
2723
+ * Gets the input DOM node, this method works with input parameter.
2724
+ * @returns {HTMLElement | null}
2725
+ */
2726
+
2622
2727
  function getInput$1(instance) {
2623
2728
  const innerParams = privateProps.innerParams.get(instance || this);
2624
2729
  const domCache = privateProps.domCache.get(instance || this);
@@ -2893,7 +2998,7 @@
2893
2998
  const validUpdatableParams = {}; // assign valid params from `params` to `defaults`
2894
2999
 
2895
3000
  Object.keys(params).forEach(param => {
2896
- if (Swal.isUpdatableParameter(param)) {
3001
+ if (isUpdatableParameter(param)) {
2897
3002
  validUpdatableParams[param] = params[param];
2898
3003
  } else {
2899
3004
  warn("Invalid parameter to update: \"".concat(param, "\". Updatable params are listed here: https://github.com/sweetalert2/sweetalert2/blob/master/src/utils/params.js\n\nIf you think this parameter should be updatable, request it here: https://github.com/sweetalert2/sweetalert2/issues/new?template=02_feature_request.md"));
@@ -2916,7 +3021,7 @@
2916
3021
  const innerParams = privateProps.innerParams.get(this);
2917
3022
 
2918
3023
  if (!innerParams) {
2919
- disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining weakmaps #2335
3024
+ disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
2920
3025
 
2921
3026
  return; // This instance has already been destroyed
2922
3027
  } // Check if there is another Swal closing
@@ -3000,7 +3105,7 @@
3000
3105
  return;
3001
3106
  }
3002
3107
 
3003
- currentInstance = this;
3108
+ currentInstance = this; // @ts-ignore
3004
3109
 
3005
3110
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3006
3111
  args[_key] = arguments[_key];
@@ -3014,7 +3119,7 @@
3014
3119
  enumerable: true,
3015
3120
  configurable: true
3016
3121
  }
3017
- });
3122
+ }); // @ts-ignore
3018
3123
 
3019
3124
  const promise = this._main(this.params);
3020
3125
 
@@ -3180,7 +3285,7 @@
3180
3285
  };
3181
3286
 
3182
3287
  const blurActiveElement = () => {
3183
- if (document.activeElement && typeof document.activeElement.blur === 'function') {
3288
+ if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
3184
3289
  document.activeElement.blur();
3185
3290
  }
3186
3291
  }; // Assign instance methods from src/instanceMethods/*.js to prototype
@@ -3198,9 +3303,10 @@
3198
3303
  };
3199
3304
  });
3200
3305
  SweetAlert.DismissReason = DismissReason;
3201
- SweetAlert.version = '11.3.1';
3306
+ SweetAlert.version = '11.3.5';
3307
+
3308
+ const Swal = SweetAlert; // @ts-ignore
3202
3309
 
3203
- const Swal = SweetAlert;
3204
3310
  Swal.default = Swal;
3205
3311
 
3206
3312
  return Swal;