sweetalert2 11.3.3 → 11.3.7

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +2257 -0
  2. package/README.md +8 -10
  3. package/dist/sweetalert2.all.js +175 -78
  4. package/dist/sweetalert2.all.min.js +1 -1
  5. package/dist/sweetalert2.js +175 -78
  6. package/dist/sweetalert2.min.js +1 -1
  7. package/package.json +12 -8
  8. package/src/SweetAlert.js +12 -11
  9. package/src/buttons-handlers.js +32 -29
  10. package/src/globalState.js +1 -1
  11. package/src/instanceMethods/_destroy.js +2 -2
  12. package/src/instanceMethods/close.js +25 -23
  13. package/src/instanceMethods/enable-disable-elements.js +7 -7
  14. package/src/instanceMethods/getInput.js +1 -1
  15. package/src/instanceMethods/hideLoading.js +2 -5
  16. package/src/instanceMethods/progress-steps.js +1 -1
  17. package/src/instanceMethods/update.js +20 -13
  18. package/src/instanceMethods/validation-message.js +2 -2
  19. package/src/keydown-handler.js +22 -16
  20. package/src/popup-click-handler.js +3 -1
  21. package/src/privateMethods.js +1 -1
  22. package/src/privateProps.js +1 -1
  23. package/src/staticMethods/argsToParams.js +1 -1
  24. package/src/staticMethods/bindClickHandler.js +1 -1
  25. package/src/staticMethods/dom.js +1 -1
  26. package/src/staticMethods/fire.js +2 -2
  27. package/src/staticMethods/mixin.js +2 -2
  28. package/src/staticMethods/showLoading.js +1 -4
  29. package/src/staticMethods.js +1 -5
  30. package/src/utils/DismissReason.js +1 -1
  31. package/src/utils/Timer.js +6 -6
  32. package/src/utils/aria.js +2 -2
  33. package/src/utils/classes.js +1 -7
  34. package/src/utils/defaultInputValidators.js +1 -1
  35. package/src/utils/dom/animationEndEvent.js +2 -3
  36. package/src/utils/dom/domUtils.js +16 -9
  37. package/src/utils/dom/getters.js +11 -11
  38. package/src/utils/dom/init.js +3 -7
  39. package/src/utils/dom/inputUtils.js +26 -19
  40. package/src/utils/dom/parseHtmlToContainer.js +14 -3
  41. package/src/utils/dom/renderers/renderActions.js +3 -3
  42. package/src/utils/dom/renderers/renderContainer.js +3 -3
  43. package/src/utils/dom/renderers/renderContent.js +4 -2
  44. package/src/utils/dom/renderers/renderIcon.js +26 -17
  45. package/src/utils/dom/renderers/renderInput.js +30 -21
  46. package/src/utils/dom/renderers/renderPopup.js +2 -1
  47. package/src/utils/dom/renderers/renderProgressSteps.js +1 -1
  48. package/src/utils/getTemplateParams.js +43 -9
  49. package/src/utils/iosFix.js +33 -10
  50. package/src/utils/isNodeEnv.js +5 -1
  51. package/src/utils/openPopup.js +1 -1
  52. package/src/utils/params.js +2 -2
  53. package/src/utils/setParameters.js +5 -5
  54. package/src/utils/utils.js +14 -11
package/README.md CHANGED
@@ -19,22 +19,20 @@ Sponsors
19
19
 
20
20
  For all questions related to sponsorship please contact me via email limon.monte@protonmail.com
21
21
 
22
- [<img src="https://sweetalert2.github.io/images/sponsors/flowcrypt-banner.png">](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=banner)
22
+ [<img src="https://sweetalert2.github.io/images/plus.png" width="80">](SPONSORS.md#sponsors) | [<img src="https://avatars2.githubusercontent.com/u/28631236?s=80&v=4" width="80">](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/vegega.jpeg" width="80">](https://www.vegega.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/phatoil.png" width="80">](https://phatoil.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/celltrackingapps.png" width="80">](https://celltrackingapps.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/mybitcoinslots.png" width="80">](https://www.mybitcoinslots.com/?utm_source=sweetalert2&utm_medium=logo)
23
+ -|-|-|-|-|-
24
+ [Become a sponsor](SPONSORS.md#sponsors) | [FlowCrypt](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [Metal Raised Garden Bed](https://www.vegega.com/) | [Pure Essential Oil](https://phatoil.com/) | [Phone Tracking Apps](https://celltrackingapps.com) | [My Bitcoin slots](https://www.mybitcoinslots.com/?utm_source=sweetalert2&utm_medium=logo)
23
25
 
24
- [<img src="https://sweetalert2.github.io/images/plus.png" width="80">](SPONSORS.md) | [<img src="https://avatars2.githubusercontent.com/u/28631236?s=80&v=4" width="80">](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/celltrackingapps.png" width="80">](https://celltrackingapps.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/mybitcoinslots.png" width="80">](https://www.mybitcoinslots.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/torc-stark.png" width="80">](https://torcstark.com/)
26
+ [<img src="https://sweetalert2.github.io/images/sponsors/torc-stark.png" width="80">](https://torcstark.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/coderubik.png" width="80">](https://coderubik.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/halvinlaina.png" width="80">](https://halvinlaina.fi/) | [<img src="https://avatars0.githubusercontent.com/u/3986989?s=80&v=4" width="80">](https://github.com/tiagostutz) | [<img src="https://sweetalert2.github.io/images/sponsors/sebaebc.png" width="80">](https://github.com/sebaebc)
25
27
  -|-|-|-|-
26
- [Become a sponsor](SPONSORS.md) | [FlowCrypt](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [Phone Tracking Apps](https://celltrackingapps.com) | [My Bitcoin slots](https://www.mybitcoinslots.com/?utm_source=sweetalert2&utm_medium=logo) | [TorcStark](https://torcstark.com/)
27
-
28
- [<img src="https://sweetalert2.github.io/images/sponsors/coderubik.png" width="80">](https://coderubik.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/halvinlaina.png" width="80">](https://halvinlaina.fi/) | [<img src="https://avatars0.githubusercontent.com/u/3986989?s=80&v=4" width="80">](https://github.com/tiagostutz) | [<img src="https://sweetalert2.github.io/images/sponsors/sebaebc.png" width="80">](https://github.com/sebaebc)
29
- -|-|-|-
30
- [Code Rubik](https://coderubik.com/?utm_source=sweetalert2&utm_medium=logo) | [Halvin Laina](https://halvinlaina.fi/) | [Tiago de Oliveira Stutz](https://github.com/tiagostutz) | [SebaEBC](https://github.com/sebaebc)
28
+ [TorcStark](https://torcstark.com/) | [Code Rubik](https://coderubik.com/?utm_source=sweetalert2&utm_medium=logo) | [Halvin Laina](https://halvinlaina.fi/) | [Tiago de Oliveira Stutz](https://github.com/tiagostutz) | [SebaEBC](https://github.com/sebaebc)
31
29
 
32
30
  NSFW Sponsors
33
31
  -------------
34
32
 
35
- [<img src="https://sweetalert2.github.io/images/sponsors/life-likedoll.png" width="80">](https://life-likedoll.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/bestrealdoll.jpeg" width="80">](https://www.bestrealdoll.com/collections/us-warehouse) | [<img src="https://sweetalert2.github.io/images/sponsors/sexdolltech.jpeg" width="80">](https://www.sexdolltech.com/product-category/us-warehouse/) | [<img src="https://sweetalert2.github.io/images/sponsors/rosewives.png" width="80">](https://rosewives.com/)
36
- -|-|-|-
37
- [Life-likeDoll](https://life-likedoll.com/) | [BestRealDoll](https://www.bestrealdoll.com/collections/us-warehouse) | [SexDollTech](https://www.sexdolltech.com/product-category/us-warehouse/) | [Rose Wives](https://rosewives.com/)
33
+ [<img src="https://sweetalert2.github.io/images/plus.png" width="80">](SPONSORS.md#sponsors) | [<img src="https://sweetalert2.github.io/images/sponsors/sensualdolls.png" width="80">](https://www.sensualdolls.com) | [<img src="https://sweetalert2.github.io/images/sponsors/bestrealdoll.jpeg" width="80">](https://www.bestrealdoll.com/collections/us-warehouse) | [<img src="https://sweetalert2.github.io/images/sponsors/sexdolltech.jpeg" width="80">](https://www.sexdolltech.com/product-category/us-warehouse/) | [<img src="https://sweetalert2.github.io/images/sponsors/rosewives.png" width="80">](https://rosewives.com/)
34
+ -|-|-|-|-
35
+ [Become a NSFW sponsor](SPONSORS.md#sponsors) | [Sensual Dolls](https://www.sensualdolls.com) | [BestRealDoll](https://www.bestrealdoll.com/collections/us-warehouse) | [SexDollTech](https://www.sexdolltech.com/product-category/us-warehouse/) | [Rose Wives](https://rosewives.com/)
38
36
 
39
37
  [<img src="https://sweetalert2.github.io/images/sponsors/sexdollsoff.png" width="80">](https://www.sexdollsoff.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/realsexdoll.png" width="80">](https://realsexdoll.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/yourdoll.jpg" width="80">](https://www.yourdoll.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/annies-dollhouse.png" width="80">](https://anniesdollhouse.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/sexdollcenter.png" width="80">](https://sexdollcenter.vip/) |
40
38
  -|-|-|-|-
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sweetalert2 v11.3.3
2
+ * sweetalert2 v11.3.7
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 => {
@@ -296,12 +297,12 @@
296
297
  const getFocusableElements = () => {
297
298
  const focusableElementsWithTabindex = toArray(getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')) // sort according to tabindex
298
299
  .sort((a, b) => {
299
- a = parseInt(a.getAttribute('tabindex'));
300
- b = parseInt(b.getAttribute('tabindex'));
300
+ const tabindexA = parseInt(a.getAttribute('tabindex'));
301
+ const tabindexB = parseInt(b.getAttribute('tabindex'));
301
302
 
302
- if (a > b) {
303
+ if (tabindexA > tabindexB) {
303
304
  return 1;
304
- } else if (a < b) {
305
+ } else if (tabindexA < tabindexB) {
305
306
  return -1;
306
307
  }
307
308
 
@@ -569,7 +570,11 @@
569
570
  timerProgressBar.style.width = "".concat(timerProgressBarPercent, "%");
570
571
  };
571
572
 
572
- // Detect Node env
573
+ /**
574
+ * Detect Node env
575
+ *
576
+ * @returns {boolean}
577
+ */
573
578
  const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
574
579
 
575
580
  const RESTORE_FOCUS_TIMEOUT = 100;
@@ -694,22 +699,34 @@
694
699
  addInputChangeListeners();
695
700
  };
696
701
 
702
+ /**
703
+ * @param {HTMLElement | object | string} param
704
+ * @param {HTMLElement} target
705
+ */
706
+
697
707
  const parseHtmlToContainer = (param, target) => {
698
708
  // DOM element
699
709
  if (param instanceof HTMLElement) {
700
- target.appendChild(param); // Object
701
- } else if (typeof param === 'object') {
702
- handleObject(param, target); // Plain string
703
- } else if (param) {
710
+ target.appendChild(param);
711
+ } // Object
712
+ else if (typeof param === 'object') {
713
+ handleObject(param, target);
714
+ } // Plain string
715
+ else if (param) {
704
716
  setInnerHtml(target, param);
705
717
  }
706
718
  };
719
+ /**
720
+ * @param {object} param
721
+ * @param {HTMLElement} target
722
+ */
707
723
 
708
724
  const handleObject = (param, target) => {
709
725
  // JQuery element(s)
710
726
  if (param.jquery) {
711
- handleJqueryElem(target, param); // For other objects use their string representation
712
- } else {
727
+ handleJqueryElem(target, param);
728
+ } // For other objects use their string representation
729
+ else {
713
730
  setInnerHtml(target, param.toString());
714
731
  }
715
732
  };
@@ -737,8 +754,9 @@
737
754
  const testEl = document.createElement('div');
738
755
  const transEndEventNames = {
739
756
  WebkitAnimation: 'webkitAnimationEnd',
740
- OAnimation: 'oAnimationEnd oanimationend',
741
- animation: 'animationend'
757
+ // Chrome, Safari and Opera
758
+ animation: 'animationend' // Standard syntax
759
+
742
760
  };
743
761
 
744
762
  for (const i in transEndEventNames) {
@@ -1060,12 +1078,12 @@
1060
1078
  setInputPlaceholder(textarea, params);
1061
1079
  setInputLabel(textarea, textarea, params);
1062
1080
 
1063
- const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
1081
+ const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight); // https://github.com/sweetalert2/sweetalert2/issues/2291
1082
+
1064
1083
 
1065
1084
  setTimeout(() => {
1066
- // #2291
1085
+ // https://github.com/sweetalert2/sweetalert2/issues/1699
1067
1086
  if ('MutationObserver' in window) {
1068
- // #1699
1069
1087
  const initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
1070
1088
 
1071
1089
  const textareaResizeHandler = () => {
@@ -1093,11 +1111,13 @@
1093
1111
 
1094
1112
  if (params.html) {
1095
1113
  parseHtmlToContainer(params.html, htmlContainer);
1096
- show(htmlContainer, 'block'); // Content as plain text
1097
- } else if (params.text) {
1114
+ show(htmlContainer, 'block');
1115
+ } // Content as plain text
1116
+ else if (params.text) {
1098
1117
  htmlContainer.textContent = params.text;
1099
- show(htmlContainer, 'block'); // No content
1100
- } else {
1118
+ show(htmlContainer, 'block');
1119
+ } // No content
1120
+ else {
1101
1121
  hide(htmlContainer);
1102
1122
  }
1103
1123
 
@@ -1164,13 +1184,13 @@
1164
1184
 
1165
1185
  setColor(icon, params); // Success icon background color
1166
1186
 
1167
- adjustSuccessIconBackgoundColor(); // Custom class
1187
+ adjustSuccessIconBackgroundColor(); // Custom class
1168
1188
 
1169
1189
  applyCustomClass(icon, params, 'icon');
1170
1190
  }; // Adjust success icon background color to match the popup background color
1171
1191
 
1172
1192
 
1173
- const adjustSuccessIconBackgoundColor = () => {
1193
+ const adjustSuccessIconBackgroundColor = () => {
1174
1194
  const popup = getPopup();
1175
1195
  const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
1176
1196
  const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
@@ -1180,15 +1200,18 @@
1180
1200
  }
1181
1201
  };
1182
1202
 
1203
+ 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";
1204
+ 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";
1205
+
1183
1206
  const setContent = (icon, params) => {
1184
1207
  icon.textContent = '';
1185
1208
 
1186
1209
  if (params.iconHtml) {
1187
1210
  setInnerHtml(icon, iconContent(params.iconHtml));
1188
1211
  } else if (params.icon === 'success') {
1189
- setInnerHtml(icon, "\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 ");
1212
+ setInnerHtml(icon, successIconHtml);
1190
1213
  } else if (params.icon === 'error') {
1191
- setInnerHtml(icon, "\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 ");
1214
+ setInnerHtml(icon, errorIconHtml);
1192
1215
  } else {
1193
1216
  const defaultIconHtml = {
1194
1217
  question: '?',
@@ -1301,9 +1324,9 @@
1301
1324
  const renderPopup = (instance, params) => {
1302
1325
  const container = getContainer();
1303
1326
  const popup = getPopup(); // Width
1327
+ // https://github.com/sweetalert2/sweetalert2/issues/2170
1304
1328
 
1305
1329
  if (params.toast) {
1306
- // #2170
1307
1330
  applyNumericalStyle(container, 'width', params.width);
1308
1331
  popup.style.width = '100%';
1309
1332
  popup.insertBefore(getLoader(), getIcon());
@@ -1414,32 +1437,39 @@
1414
1437
  if (!template) {
1415
1438
  return {};
1416
1439
  }
1440
+ /** @type {DocumentFragment} */
1441
+
1417
1442
 
1418
1443
  const templateContent = template.content;
1419
1444
  showWarningsForElements(templateContent);
1420
1445
  const result = Object.assign(getSwalParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
1421
1446
  return result;
1422
1447
  };
1448
+ /**
1449
+ * @param {DocumentFragment} templateContent
1450
+ */
1423
1451
 
1424
1452
  const getSwalParams = templateContent => {
1425
1453
  const result = {};
1426
1454
  toArray(templateContent.querySelectorAll('swal-param')).forEach(param => {
1427
1455
  showWarningsForAttributes(param, ['name', 'value']);
1428
1456
  const paramName = param.getAttribute('name');
1429
- let value = param.getAttribute('value');
1457
+ const value = param.getAttribute('value');
1430
1458
 
1431
1459
  if (typeof defaultParams[paramName] === 'boolean' && value === 'false') {
1432
- value = false;
1460
+ result[paramName] = false;
1433
1461
  }
1434
1462
 
1435
1463
  if (typeof defaultParams[paramName] === 'object') {
1436
- value = JSON.parse(value);
1464
+ result[paramName] = JSON.parse(value);
1437
1465
  }
1438
-
1439
- result[paramName] = value;
1440
1466
  });
1441
1467
  return result;
1442
1468
  };
1469
+ /**
1470
+ * @param {DocumentFragment} templateContent
1471
+ */
1472
+
1443
1473
 
1444
1474
  const getSwalButtons = templateContent => {
1445
1475
  const result = {};
@@ -1459,9 +1489,15 @@
1459
1489
  });
1460
1490
  return result;
1461
1491
  };
1492
+ /**
1493
+ * @param {DocumentFragment} templateContent
1494
+ */
1495
+
1462
1496
 
1463
1497
  const getSwalImage = templateContent => {
1464
1498
  const result = {};
1499
+ /** @type {HTMLElement} */
1500
+
1465
1501
  const image = templateContent.querySelector('swal-image');
1466
1502
 
1467
1503
  if (image) {
@@ -1486,9 +1522,15 @@
1486
1522
 
1487
1523
  return result;
1488
1524
  };
1525
+ /**
1526
+ * @param {DocumentFragment} templateContent
1527
+ */
1528
+
1489
1529
 
1490
1530
  const getSwalIcon = templateContent => {
1491
1531
  const result = {};
1532
+ /** @type {HTMLElement} */
1533
+
1492
1534
  const icon = templateContent.querySelector('swal-icon');
1493
1535
 
1494
1536
  if (icon) {
@@ -1507,9 +1549,15 @@
1507
1549
 
1508
1550
  return result;
1509
1551
  };
1552
+ /**
1553
+ * @param {DocumentFragment} templateContent
1554
+ */
1555
+
1510
1556
 
1511
1557
  const getSwalInput = templateContent => {
1512
1558
  const result = {};
1559
+ /** @type {HTMLElement} */
1560
+
1513
1561
  const input = templateContent.querySelector('swal-input');
1514
1562
 
1515
1563
  if (input) {
@@ -1543,12 +1591,19 @@
1543
1591
 
1544
1592
  return result;
1545
1593
  };
1594
+ /**
1595
+ * @param {DocumentFragment} templateContent
1596
+ * @param {string[]} paramNames
1597
+ */
1598
+
1546
1599
 
1547
1600
  const getSwalStringParams = (templateContent, paramNames) => {
1548
1601
  const result = {};
1549
1602
 
1550
1603
  for (const i in paramNames) {
1551
1604
  const paramName = paramNames[i];
1605
+ /** @type {HTMLElement} */
1606
+
1552
1607
  const tag = templateContent.querySelector(paramName);
1553
1608
 
1554
1609
  if (tag) {
@@ -1559,10 +1614,14 @@
1559
1614
 
1560
1615
  return result;
1561
1616
  };
1617
+ /**
1618
+ * @param {DocumentFragment} templateContent
1619
+ */
1562
1620
 
1563
- const showWarningsForElements = template => {
1621
+
1622
+ const showWarningsForElements = templateContent => {
1564
1623
  const allowedElements = swalStringParams.concat(['swal-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
1565
- toArray(template.children).forEach(el => {
1624
+ toArray(templateContent.children).forEach(el => {
1566
1625
  const tagName = el.tagName.toLowerCase();
1567
1626
 
1568
1627
  if (allowedElements.indexOf(tagName) === -1) {
@@ -1570,6 +1629,11 @@
1570
1629
  }
1571
1630
  });
1572
1631
  };
1632
+ /**
1633
+ * @param {HTMLElement} el
1634
+ * @param {string[]} allowedAttributes
1635
+ */
1636
+
1573
1637
 
1574
1638
  const showWarningsForAttributes = (el, allowedAttributes) => {
1575
1639
  toArray(el.attributes).forEach(attribute => {
@@ -1712,22 +1776,28 @@
1712
1776
  /* istanbul ignore file */
1713
1777
 
1714
1778
  const iOSfix = () => {
1715
- // @ts-ignore
1716
- const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
1779
+ const iOS = // @ts-ignore
1780
+ /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
1717
1781
 
1718
1782
  if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
1719
1783
  const offset = document.body.scrollTop;
1720
1784
  document.body.style.top = "".concat(offset * -1, "px");
1721
1785
  addClass(document.body, swalClasses.iosfix);
1722
1786
  lockBodyScroll();
1723
- addBottomPaddingForTallPopups(); // #1948
1787
+ addBottomPaddingForTallPopups();
1724
1788
  }
1725
1789
  };
1790
+ /**
1791
+ * https://github.com/sweetalert2/sweetalert2/issues/1948
1792
+ */
1726
1793
 
1727
1794
  const addBottomPaddingForTallPopups = () => {
1728
- const safari = !navigator.userAgent.match(/(CriOS|FxiOS|EdgiOS|YaBrowser|UCBrowser)/i);
1795
+ const ua = navigator.userAgent;
1796
+ const iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
1797
+ const webkit = !!ua.match(/WebKit/i);
1798
+ const iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
1729
1799
 
1730
- if (safari) {
1800
+ if (iOSSafari) {
1731
1801
  const bottomPanelHeight = 44;
1732
1802
 
1733
1803
  if (getPopup().scrollHeight > window.innerHeight - bottomPanelHeight) {
@@ -1735,9 +1805,12 @@
1735
1805
  }
1736
1806
  }
1737
1807
  };
1808
+ /**
1809
+ * https://github.com/sweetalert2/sweetalert2/issues/1246
1810
+ */
1811
+
1738
1812
 
1739
1813
  const lockBodyScroll = () => {
1740
- // #1246
1741
1814
  const container = getContainer();
1742
1815
  let preventTouchMove;
1743
1816
 
@@ -1757,7 +1830,7 @@
1757
1830
  const target = event.target;
1758
1831
  const container = getContainer();
1759
1832
 
1760
- if (isStylys(event) || isZoom(event)) {
1833
+ if (isStylus(event) || isZoom(event)) {
1761
1834
  return false;
1762
1835
  }
1763
1836
 
@@ -1774,14 +1847,26 @@
1774
1847
 
1775
1848
  return false;
1776
1849
  };
1850
+ /**
1851
+ * https://github.com/sweetalert2/sweetalert2/issues/1786
1852
+ *
1853
+ * @param {*} event
1854
+ * @returns {boolean}
1855
+ */
1856
+
1777
1857
 
1778
- const isStylys = event => {
1779
- // #1786
1858
+ const isStylus = event => {
1780
1859
  return event.touches && event.touches.length && event.touches[0].touchType === 'stylus';
1781
1860
  };
1861
+ /**
1862
+ * https://github.com/sweetalert2/sweetalert2/issues/1891
1863
+ *
1864
+ * @param {TouchEvent} event
1865
+ * @returns {boolean}
1866
+ */
1867
+
1782
1868
 
1783
1869
  const isZoom = event => {
1784
- // #1891
1785
1870
  return event.touches && event.touches.length > 1;
1786
1871
  };
1787
1872
 
@@ -1868,7 +1953,7 @@
1868
1953
  };
1869
1954
 
1870
1955
  const addClasses$1 = (container, popup, params) => {
1871
- addClass(container, params.showClass.backdrop); // the workaround with setting/unsetting opacity is needed for #2019 and 2059
1956
+ addClass(container, params.showClass.backdrop); // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
1872
1957
 
1873
1958
  popup.style.setProperty('opacity', '0', 'important');
1874
1959
  show(popup, 'grid');
@@ -2134,6 +2219,11 @@
2134
2219
  /* 'confirm' | 'deny' */
2135
2220
  ) => {
2136
2221
  const innerParams = privateProps.innerParams.get(instance);
2222
+
2223
+ if (!innerParams.input) {
2224
+ return error("The \"input\" parameter is needed to be set when using returnInputValueOn".concat(capitalizeFirstLetter(type)));
2225
+ }
2226
+
2137
2227
  const inputValue = getInputValue(instance, innerParams);
2138
2228
 
2139
2229
  if (innerParams.inputValidator) {
@@ -2176,7 +2266,7 @@
2176
2266
  }
2177
2267
 
2178
2268
  if (innerParams.preDeny) {
2179
- 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
2269
+ 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
2180
2270
 
2181
2271
  const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
2182
2272
  preDenyPromise.then(preDenyValue => {
@@ -2217,7 +2307,7 @@
2217
2307
 
2218
2308
  if (innerParams.preConfirm) {
2219
2309
  instance.resetValidationMessage();
2220
- 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
2310
+ 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
2221
2311
 
2222
2312
  const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
2223
2313
  preConfirmPromise.then(preConfirmValue => {
@@ -2388,19 +2478,22 @@
2388
2478
 
2389
2479
 
2390
2480
  if (e.key === 'Enter') {
2391
- handleEnter(instance, e, innerParams); // TAB
2392
- } else if (e.key === 'Tab') {
2393
- handleTab(e, innerParams); // ARROWS - switch focus between buttons
2394
- } else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)) {
2395
- handleArrows(e.key); // ESC
2396
- } else if (e.key === 'Escape') {
2481
+ handleEnter(instance, e, innerParams);
2482
+ } // TAB
2483
+ else if (e.key === 'Tab') {
2484
+ handleTab(e, innerParams);
2485
+ } // ARROWS - switch focus between buttons
2486
+ else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)) {
2487
+ handleArrows(e.key);
2488
+ } // ESC
2489
+ else if (e.key === 'Escape') {
2397
2490
  handleEsc(e, innerParams, dismissWith);
2398
2491
  }
2399
2492
  };
2400
2493
 
2401
2494
  const handleEnter = (instance, e, innerParams) => {
2402
- // #720 #721
2403
- if (e.isComposing) {
2495
+ // #2386 #720 #721
2496
+ if (!callIfFunction(innerParams.allowEnterKey) || e.isComposing) {
2404
2497
  return;
2405
2498
  }
2406
2499
 
@@ -2424,13 +2517,13 @@
2424
2517
  btnIndex = i;
2425
2518
  break;
2426
2519
  }
2427
- }
2520
+ } // Cycle to the next button
2521
+
2428
2522
 
2429
2523
  if (!e.shiftKey) {
2430
- // Cycle to the next button
2431
2524
  setFocus(innerParams, btnIndex, 1);
2432
- } else {
2433
- // Cycle to the prev button
2525
+ } // Cycle to the prev button
2526
+ else {
2434
2527
  setFocus(innerParams, btnIndex, -1);
2435
2528
  }
2436
2529
 
@@ -2487,7 +2580,7 @@
2487
2580
  };
2488
2581
 
2489
2582
  function fire() {
2490
- const Swal = this;
2583
+ const Swal = this; // eslint-disable-line @typescript-eslint/no-this-alias
2491
2584
 
2492
2585
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2493
2586
  args[_key] = arguments[_key];
@@ -2973,15 +3066,7 @@
2973
3066
  return warn("You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.");
2974
3067
  }
2975
3068
 
2976
- const validUpdatableParams = {}; // assign valid params from `params` to `defaults`
2977
-
2978
- Object.keys(params).forEach(param => {
2979
- if (isUpdatableParameter(param)) {
2980
- validUpdatableParams[param] = params[param];
2981
- } else {
2982
- 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"));
2983
- }
2984
- });
3069
+ const validUpdatableParams = filterValidParams(params);
2985
3070
  const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
2986
3071
  render(this, updatedParams);
2987
3072
  privateProps.innerParams.set(this, updatedParams);
@@ -2994,12 +3079,24 @@
2994
3079
  });
2995
3080
  }
2996
3081
 
3082
+ const filterValidParams = params => {
3083
+ const validUpdatableParams = {};
3084
+ Object.keys(params).forEach(param => {
3085
+ if (isUpdatableParameter(param)) {
3086
+ validUpdatableParams[param] = params[param];
3087
+ } else {
3088
+ 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"));
3089
+ }
3090
+ });
3091
+ return validUpdatableParams;
3092
+ };
3093
+
2997
3094
  function _destroy() {
2998
3095
  const domCache = privateProps.domCache.get(this);
2999
3096
  const innerParams = privateProps.innerParams.get(this);
3000
3097
 
3001
3098
  if (!innerParams) {
3002
- disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining weakmaps #2335
3099
+ disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
3003
3100
 
3004
3101
  return; // This instance has already been destroyed
3005
3102
  } // Check if there is another Swal closing
@@ -3281,7 +3378,7 @@
3281
3378
  };
3282
3379
  });
3283
3380
  SweetAlert.DismissReason = DismissReason;
3284
- SweetAlert.version = '11.3.3';
3381
+ SweetAlert.version = '11.3.7';
3285
3382
 
3286
3383
  const Swal = SweetAlert; // @ts-ignore
3287
3384