sweetalert2 11.3.1 → 11.3.2

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 CHANGED
@@ -32,9 +32,9 @@ For all questions related to sponsorship please contact me via email limon.monte
32
32
  NSFW Sponsors
33
33
  -------------
34
34
 
35
- [<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
- [BestRealDoll](https://www.bestrealdoll.com/collections/us-warehouse) | [SexDollTech](https://www.sexdolltech.com/product-category/us-warehouse/) | [Rose Wives](https://rosewives.com/)
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/)
38
38
 
39
39
  [<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
40
  -|-|-|-|-
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sweetalert2 v11.3.1
2
+ * sweetalert2 v11.3.2
3
3
  * Released under the MIT License.
4
4
  */
5
5
  (function (global, factory) {
@@ -183,7 +183,7 @@
183
183
  const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
184
184
  /**
185
185
  * Is valid parameter
186
- * @param {String} paramName
186
+ * @param {string} paramName
187
187
  */
188
188
 
189
189
  const isValidParameter = paramName => {
@@ -191,7 +191,7 @@
191
191
  };
192
192
  /**
193
193
  * Is valid parameter for Swal.update() method
194
- * @param {String} paramName
194
+ * @param {string} paramName
195
195
  */
196
196
 
197
197
  const isUpdatableParameter = paramName => {
@@ -199,7 +199,7 @@
199
199
  };
200
200
  /**
201
201
  * Is deprecated parameter
202
- * @param {String} paramName
202
+ * @param {string} paramName
203
203
  */
204
204
 
205
205
  const isDeprecatedParameter = paramName => {
@@ -259,6 +259,12 @@
259
259
  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
260
  const iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
261
261
 
262
+ /**
263
+ * Gets the popup container which contains the backdrop and the popup itself.
264
+ *
265
+ * @returns {HTMLElement | null}
266
+ */
267
+
262
268
  const getContainer = () => document.body.querySelector(".".concat(swalClasses.container));
263
269
  const elementBySelector = selectorString => {
264
270
  const container = getContainer();
@@ -317,8 +323,15 @@
317
323
  const states = {
318
324
  previousBodyPadding: null
319
325
  };
326
+ /**
327
+ * Securely set innerHTML of an element
328
+ * https://github.com/sweetalert2/sweetalert2/issues/1926
329
+ *
330
+ * @param {HTMLElement} elem
331
+ * @param {string} html
332
+ */
333
+
320
334
  const setInnerHtml = (elem, html) => {
321
- // #1926
322
335
  elem.textContent = '';
323
336
 
324
337
  if (html) {
@@ -332,6 +345,12 @@
332
345
  });
333
346
  }
334
347
  };
348
+ /**
349
+ * @param {HTMLElement} elem
350
+ * @param {string} className
351
+ * @returns {boolean}
352
+ */
353
+
335
354
  const hasClass = (elem, className) => {
336
355
  if (!className) {
337
356
  return false;
@@ -367,6 +386,12 @@
367
386
  addClass(elem, params.customClass[className]);
368
387
  }
369
388
  };
389
+ /**
390
+ * @param {HTMLElement} popup
391
+ * @param {string} inputType
392
+ * @returns {HTMLInputElement | null}
393
+ */
394
+
370
395
  const getInput = (popup, inputType) => {
371
396
  if (!inputType) {
372
397
  return null;
@@ -376,7 +401,7 @@
376
401
  case 'select':
377
402
  case 'textarea':
378
403
  case 'file':
379
- return getChildByClass(popup, swalClasses[inputType]);
404
+ return popup.querySelector(".".concat(swalClasses[inputType]));
380
405
 
381
406
  case 'checkbox':
382
407
  return popup.querySelector(".".concat(swalClasses.checkbox, " input"));
@@ -388,9 +413,13 @@
388
413
  return popup.querySelector(".".concat(swalClasses.range, " input"));
389
414
 
390
415
  default:
391
- return getChildByClass(popup, swalClasses.input);
416
+ return popup.querySelector(".".concat(swalClasses.input));
392
417
  }
393
418
  };
419
+ /**
420
+ * @param {HTMLInputElement} input
421
+ */
422
+
394
423
  const focusInput = input => {
395
424
  input.focus(); // place cursor at end of text in text input
396
425
 
@@ -401,6 +430,12 @@
401
430
  input.value = val;
402
431
  }
403
432
  };
433
+ /**
434
+ * @param {HTMLElement | HTMLElement[] | null} target
435
+ * @param {string | string[]} classList
436
+ * @param {boolean} condition
437
+ */
438
+
404
439
  const toggleClass = (target, classList, condition) => {
405
440
  if (!target || !classList) {
406
441
  return;
@@ -411,7 +446,7 @@
411
446
  }
412
447
 
413
448
  classList.forEach(className => {
414
- if (target.forEach) {
449
+ if (Array.isArray(target)) {
415
450
  target.forEach(elem => {
416
451
  condition ? elem.classList.add(className) : elem.classList.remove(className);
417
452
  });
@@ -420,19 +455,43 @@
420
455
  }
421
456
  });
422
457
  };
458
+ /**
459
+ * @param {HTMLElement | HTMLElement[] | null} target
460
+ * @param {string | string[]} classList
461
+ */
462
+
423
463
  const addClass = (target, classList) => {
424
464
  toggleClass(target, classList, true);
425
465
  };
466
+ /**
467
+ * @param {HTMLElement | HTMLElement[] | null} target
468
+ * @param {string | string[]} classList
469
+ */
470
+
426
471
  const removeClass = (target, classList) => {
427
472
  toggleClass(target, classList, false);
428
473
  };
474
+ /**
475
+ * @param {HTMLElement} elem
476
+ * @param {string} className
477
+ * @returns {HTMLElement | null}
478
+ */
479
+
429
480
  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];
481
+ const childNodes = toArray(elem.childNodes);
482
+
483
+ for (let i = 0; i < childNodes.length; i++) {
484
+ if (hasClass(childNodes[i], className)) {
485
+ return childNodes[i];
433
486
  }
434
487
  }
435
488
  };
489
+ /**
490
+ * @param {HTMLElement} elem
491
+ * @param {string} property
492
+ * @param {*} value
493
+ */
494
+
436
495
  const applyNumericalStyle = (elem, property, value) => {
437
496
  if (value === "".concat(parseInt(value))) {
438
497
  value = parseInt(value);
@@ -444,10 +503,19 @@
444
503
  elem.style.removeProperty(property);
445
504
  }
446
505
  };
506
+ /**
507
+ * @param {HTMLElement} elem
508
+ * @param {string} display
509
+ */
510
+
447
511
  const show = function (elem) {
448
512
  let display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'flex';
449
513
  elem.style.display = display;
450
514
  };
515
+ /**
516
+ * @param {HTMLElement} elem
517
+ */
518
+
451
519
  const hide = elem => {
452
520
  elem.style.display = 'none';
453
521
  };
@@ -494,7 +562,7 @@
494
562
  timerProgressBar.style.removeProperty('transition');
495
563
  timerProgressBar.style.width = '100%';
496
564
  const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
497
- const timerProgressBarPercent = parseInt(timerProgressBarWidth / timerProgressBarFullWidth * 100);
565
+ const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
498
566
  timerProgressBar.style.removeProperty('transition');
499
567
  timerProgressBar.style.width = "".concat(timerProgressBarPercent, "%");
500
568
  };
@@ -502,6 +570,37 @@
502
570
  // Detect Node env
503
571
  const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
504
572
 
573
+ const RESTORE_FOCUS_TIMEOUT = 100;
574
+
575
+ const globalState = {};
576
+
577
+ const focusPreviousActiveElement = () => {
578
+ if (globalState.previousActiveElement && globalState.previousActiveElement.focus) {
579
+ globalState.previousActiveElement.focus();
580
+ globalState.previousActiveElement = null;
581
+ } else if (document.body) {
582
+ document.body.focus();
583
+ }
584
+ }; // Restore previous active (focused) element
585
+
586
+
587
+ const restoreActiveElement = returnFocus => {
588
+ return new Promise(resolve => {
589
+ if (!returnFocus) {
590
+ return resolve();
591
+ }
592
+
593
+ const x = window.scrollX;
594
+ const y = window.scrollY;
595
+ globalState.restoreFocusTimeout = setTimeout(() => {
596
+ focusPreviousActiveElement();
597
+ resolve();
598
+ }, RESTORE_FOCUS_TIMEOUT); // issues/900
599
+
600
+ window.scrollTo(x, y);
601
+ });
602
+ };
603
+
505
604
  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
605
 
507
606
  const resetOldContainer = () => {
@@ -517,9 +616,7 @@
517
616
  };
518
617
 
519
618
  const resetValidationMessage = () => {
520
- if (Swal.isVisible()) {
521
- Swal.resetValidationMessage();
522
- }
619
+ globalState.currentInstance.resetValidationMessage();
523
620
  };
524
621
 
525
622
  const addInputChangeListeners = () => {
@@ -946,8 +1043,9 @@
946
1043
  };
947
1044
 
948
1045
  renderInputType.checkbox = (checkboxContainer, params) => {
1046
+ /** @type {HTMLInputElement} */
949
1047
  const checkbox = getInput(getPopup(), 'checkbox');
950
- checkbox.value = 1;
1048
+ checkbox.value = '1';
951
1049
  checkbox.id = swalClasses.checkbox;
952
1050
  checkbox.checked = Boolean(params.inputValue);
953
1051
  const label = checkboxContainer.querySelector('span');
@@ -1511,7 +1609,6 @@
1511
1609
  * Set type, text and actions on popup
1512
1610
  *
1513
1611
  * @param params
1514
- * @returns {boolean}
1515
1612
  */
1516
1613
 
1517
1614
 
@@ -1553,7 +1650,7 @@
1553
1650
  if (this.running) {
1554
1651
  this.running = false;
1555
1652
  clearTimeout(this.id);
1556
- this.remaining -= new Date() - this.started;
1653
+ this.remaining -= new Date().getTime() - this.started.getTime();
1557
1654
  }
1558
1655
 
1559
1656
  return this.remaining;
@@ -1613,6 +1710,7 @@
1613
1710
  /* istanbul ignore file */
1614
1711
 
1615
1712
  const iOSfix = () => {
1713
+ // @ts-ignore
1616
1714
  const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
1617
1715
 
1618
1716
  if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
@@ -1694,37 +1792,6 @@
1694
1792
  }
1695
1793
  };
1696
1794
 
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
1795
  const SHOW_CLASS_TIMEOUT = 10;
1729
1796
  /**
1730
1797
  * Open popup, add necessary classes and styles, fix scrollbar
@@ -1826,7 +1893,7 @@
1826
1893
  let popup = getPopup();
1827
1894
 
1828
1895
  if (!popup) {
1829
- Swal.fire();
1896
+ new Swal(); // eslint-disable-line no-new
1830
1897
  }
1831
1898
 
1832
1899
  popup = getPopup();
@@ -2183,13 +2250,22 @@
2183
2250
  domCache.popup.onclick = () => {
2184
2251
  const innerParams = privateProps.innerParams.get(instance);
2185
2252
 
2186
- if (innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton || innerParams.timer || innerParams.input) {
2253
+ if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
2187
2254
  return;
2188
2255
  }
2189
2256
 
2190
2257
  dismissWith(DismissReason.close);
2191
2258
  };
2192
2259
  };
2260
+ /**
2261
+ * @param {*} innerParams
2262
+ * @returns {boolean}
2263
+ */
2264
+
2265
+
2266
+ const isAnyButtonShown = innerParams => {
2267
+ return innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton;
2268
+ };
2193
2269
 
2194
2270
  let ignoreOutsideClick = false;
2195
2271
 
@@ -2372,7 +2448,7 @@
2372
2448
  const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
2373
2449
  const buttonToFocus = document.activeElement[sibling];
2374
2450
 
2375
- if (buttonToFocus) {
2451
+ if (buttonToFocus instanceof HTMLElement) {
2376
2452
  buttonToFocus.focus();
2377
2453
  }
2378
2454
  };
@@ -2619,6 +2695,11 @@
2619
2695
  }
2620
2696
  };
2621
2697
 
2698
+ /**
2699
+ * Gets the input DOM node, this method works with input parameter.
2700
+ * @returns {HTMLElement | null}
2701
+ */
2702
+
2622
2703
  function getInput$1(instance) {
2623
2704
  const innerParams = privateProps.innerParams.get(instance || this);
2624
2705
  const domCache = privateProps.domCache.get(instance || this);
@@ -2893,7 +2974,7 @@
2893
2974
  const validUpdatableParams = {}; // assign valid params from `params` to `defaults`
2894
2975
 
2895
2976
  Object.keys(params).forEach(param => {
2896
- if (Swal.isUpdatableParameter(param)) {
2977
+ if (isUpdatableParameter(param)) {
2897
2978
  validUpdatableParams[param] = params[param];
2898
2979
  } else {
2899
2980
  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"));
@@ -3000,7 +3081,7 @@
3000
3081
  return;
3001
3082
  }
3002
3083
 
3003
- currentInstance = this;
3084
+ currentInstance = this; // @ts-ignore
3004
3085
 
3005
3086
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3006
3087
  args[_key] = arguments[_key];
@@ -3014,7 +3095,7 @@
3014
3095
  enumerable: true,
3015
3096
  configurable: true
3016
3097
  }
3017
- });
3098
+ }); // @ts-ignore
3018
3099
 
3019
3100
  const promise = this._main(this.params);
3020
3101
 
@@ -3180,7 +3261,7 @@
3180
3261
  };
3181
3262
 
3182
3263
  const blurActiveElement = () => {
3183
- if (document.activeElement && typeof document.activeElement.blur === 'function') {
3264
+ if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
3184
3265
  document.activeElement.blur();
3185
3266
  }
3186
3267
  }; // Assign instance methods from src/instanceMethods/*.js to prototype
@@ -3198,9 +3279,10 @@
3198
3279
  };
3199
3280
  });
3200
3281
  SweetAlert.DismissReason = DismissReason;
3201
- SweetAlert.version = '11.3.1';
3282
+ SweetAlert.version = '11.3.2';
3283
+
3284
+ const Swal = SweetAlert; // @ts-ignore
3202
3285
 
3203
- const Swal = SweetAlert;
3204
3286
  Swal.default = Swal;
3205
3287
 
3206
3288
  return Swal;