sweetalert2 11.26.1 → 11.26.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sweetalert2 v11.26.1
2
+ * sweetalert2 v11.26.2
3
3
  * Released under the MIT License.
4
4
  */
5
5
  function _assertClassBrand(e, t, n) {
@@ -141,25 +141,25 @@ const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
141
141
  * If `arg` is a function, call it (with no arguments or context) and return the result.
142
142
  * Otherwise, just pass the value through
143
143
  *
144
- * @param {Function | any} arg
145
- * @returns {any}
144
+ * @param {(() => *) | *} arg
145
+ * @returns {*}
146
146
  */
147
147
  const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
148
148
 
149
149
  /**
150
- * @param {any} arg
150
+ * @param {*} arg
151
151
  * @returns {boolean}
152
152
  */
153
153
  const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
154
154
 
155
155
  /**
156
- * @param {any} arg
157
- * @returns {Promise<any>}
156
+ * @param {*} arg
157
+ * @returns {Promise<*>}
158
158
  */
159
159
  const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
160
160
 
161
161
  /**
162
- * @param {any} arg
162
+ * @param {*} arg
163
163
  * @returns {boolean}
164
164
  */
165
165
  const isPromise = arg => arg && Promise.resolve(arg) === arg;
@@ -537,13 +537,13 @@ const getDirectChildByClass = (elem, className) => {
537
537
  /**
538
538
  * @param {HTMLElement} elem
539
539
  * @param {string} property
540
- * @param {*} value
540
+ * @param {string | number | null | undefined} value
541
541
  */
542
542
  const applyNumericalStyle = (elem, property, value) => {
543
- if (value === `${parseInt(value)}`) {
543
+ if (value === `${parseInt(`${value}`)}`) {
544
544
  value = parseInt(value);
545
545
  }
546
- if (value || parseInt(value) === 0) {
546
+ if (value || parseInt(`${value}`) === 0) {
547
547
  elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : value);
548
548
  } else {
549
549
  elem.style.removeProperty(property);
@@ -603,7 +603,7 @@ const setStyle = (parent, selector, property, value) => {
603
603
 
604
604
  /**
605
605
  * @param {HTMLElement} elem
606
- * @param {any} condition
606
+ * @param {boolean | string | null | undefined} condition
607
607
  * @param {string} display
608
608
  */
609
609
  const toggle = (elem, condition, display = 'flex') => {
@@ -858,7 +858,7 @@ const parseHtmlToContainer = (param, target) => {
858
858
  };
859
859
 
860
860
  /**
861
- * @param {any} param
861
+ * @param {object} param
862
862
  * @param {HTMLElement} target
863
863
  */
864
864
  const handleObject = (param, target) => {
@@ -875,7 +875,7 @@ const handleObject = (param, target) => {
875
875
 
876
876
  /**
877
877
  * @param {HTMLElement} target
878
- * @param {any} elem
878
+ * @param {object} elem
879
879
  */
880
880
  const handleJqueryElem = (target, elem) => {
881
881
  target.textContent = '';
@@ -1426,7 +1426,7 @@ const renderFooter = (instance, params) => {
1426
1426
  return;
1427
1427
  }
1428
1428
  showWhenInnerHtmlPresent(footer);
1429
- toggle(footer, params.footer, 'block');
1429
+ toggle(footer, Boolean(params.footer), 'block');
1430
1430
  if (params.footer) {
1431
1431
  parseHtmlToContainer(params.footer, footer);
1432
1432
  }
@@ -1843,7 +1843,7 @@ const renderTitle = (instance, params) => {
1843
1843
  return;
1844
1844
  }
1845
1845
  showWhenInnerHtmlPresent(title);
1846
- toggle(title, params.title || params.titleText, 'block');
1846
+ toggle(title, Boolean(params.title || params.titleText), 'block');
1847
1847
  if (params.title) {
1848
1848
  parseHtmlToContainer(params.title, title);
1849
1849
  }
@@ -1908,8 +1908,6 @@ const clickCancel = () => {
1908
1908
  return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
1909
1909
  };
1910
1910
 
1911
- /** @typedef {'cancel' | 'backdrop' | 'close' | 'esc' | 'timer'} DismissReason */
1912
-
1913
1911
  /** @type {Record<DismissReason, DismissReason>} */
1914
1912
  const DismissReason = Object.freeze({
1915
1913
  cancel: 'cancel',
@@ -1934,7 +1932,7 @@ const removeKeydownHandler = globalState => {
1934
1932
  /**
1935
1933
  * @param {GlobalState} globalState
1936
1934
  * @param {SweetAlertOptions} innerParams
1937
- * @param {*} dismissWith
1935
+ * @param {(dismiss: DismissReason) => void} dismissWith
1938
1936
  */
1939
1937
  const addKeydownHandler = (globalState, innerParams, dismissWith) => {
1940
1938
  removeKeydownHandler(globalState);
@@ -1985,7 +1983,7 @@ const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
1985
1983
  /**
1986
1984
  * @param {SweetAlertOptions} innerParams
1987
1985
  * @param {KeyboardEvent} event
1988
- * @param {Function} dismissWith
1986
+ * @param {(dismiss: DismissReason) => void} dismissWith
1989
1987
  */
1990
1988
  const keydownHandler = (innerParams, event, dismissWith) => {
1991
1989
  if (!innerParams) {
@@ -2108,7 +2106,7 @@ const handleArrows = key => {
2108
2106
  /**
2109
2107
  * @param {KeyboardEvent} event
2110
2108
  * @param {SweetAlertOptions} innerParams
2111
- * @param {Function} dismissWith
2109
+ * @param {(dismiss: DismissReason) => void} dismissWith
2112
2110
  */
2113
2111
  const handleEsc = (event, innerParams, dismissWith) => {
2114
2112
  event.preventDefault();
@@ -2239,7 +2237,7 @@ const shouldPreventTouchMove = event => {
2239
2237
  /**
2240
2238
  * https://github.com/sweetalert2/sweetalert2/issues/1786
2241
2239
  *
2242
- * @param {*} event
2240
+ * @param {object} event
2243
2241
  * @returns {boolean}
2244
2242
  */
2245
2243
  const isStylus = event => {
@@ -2312,7 +2310,7 @@ const undoReplaceScrollbarWithPadding = () => {
2312
2310
  * @param {SweetAlert} instance
2313
2311
  * @param {HTMLElement} container
2314
2312
  * @param {boolean} returnFocus
2315
- * @param {Function} didClose
2313
+ * @param {() => void} didClose
2316
2314
  */
2317
2315
  function removePopupAndResetState(instance, container, returnFocus, didClose) {
2318
2316
  if (isToast()) {
@@ -2349,7 +2347,7 @@ function removeBodyClasses() {
2349
2347
  /**
2350
2348
  * Instance method to close sweetAlert
2351
2349
  *
2352
- * @param {any} resolveValue
2350
+ * @param {SweetAlertResult | undefined} resolveValue
2353
2351
  */
2354
2352
  function close(resolveValue) {
2355
2353
  resolveValue = prepareResolveValue(resolveValue);
@@ -2385,7 +2383,7 @@ const triggerClosePopup = instance => {
2385
2383
  };
2386
2384
 
2387
2385
  /**
2388
- * @param {any} error
2386
+ * @param {Error | string} error
2389
2387
  */
2390
2388
  function rejectPromise(error) {
2391
2389
  const rejectPromise = privateMethods.swalPromiseReject.get(this);
@@ -2410,7 +2408,7 @@ const handleAwaitingPromise = instance => {
2410
2408
  };
2411
2409
 
2412
2410
  /**
2413
- * @param {any} resolveValue
2411
+ * @param {SweetAlertResult | undefined} resolveValue
2414
2412
  * @returns {SweetAlertResult}
2415
2413
  */
2416
2414
  const prepareResolveValue = resolveValue => {
@@ -2456,7 +2454,7 @@ const handlePopupAnimation = (instance, popup, innerParams) => {
2456
2454
  * @param {HTMLElement} popup
2457
2455
  * @param {HTMLElement} container
2458
2456
  * @param {boolean} returnFocus
2459
- * @param {Function} didClose
2457
+ * @param {() => void} didClose
2460
2458
  */
2461
2459
  const animatePopup = (instance, popup, container, returnFocus, didClose) => {
2462
2460
  globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
@@ -2478,7 +2476,7 @@ const animatePopup = (instance, popup, container, returnFocus, didClose) => {
2478
2476
 
2479
2477
  /**
2480
2478
  * @param {SweetAlert} instance
2481
- * @param {Function} didClose
2479
+ * @param {() => void} didClose
2482
2480
  */
2483
2481
  const triggerDidCloseAndDispose = (instance, didClose) => {
2484
2482
  setTimeout(() => {
@@ -2606,7 +2604,7 @@ const handleInputOptions = (instance, params) => {
2606
2604
  return;
2607
2605
  }
2608
2606
  /**
2609
- * @param {Record<string, any>} inputOptions
2607
+ * @param {*} inputOptions
2610
2608
  */
2611
2609
  const processInputOptions = inputOptions => {
2612
2610
  if (params.input === 'select') {
@@ -2733,7 +2731,7 @@ function populateRadioOptions(popup, inputOptions, params) {
2733
2731
  /**
2734
2732
  * Converts `inputOptions` into an array of `[value, label]`s
2735
2733
  *
2736
- * @param {Record<string, any>} inputOptions
2734
+ * @param {*} inputOptions
2737
2735
  * @typedef {string[]} InputOptionFlattened
2738
2736
  * @returns {InputOptionFlattened[]}
2739
2737
  */
@@ -2799,7 +2797,7 @@ const handleDenyButtonClick = instance => {
2799
2797
 
2800
2798
  /**
2801
2799
  * @param {SweetAlert} instance
2802
- * @param {Function} dismissWith
2800
+ * @param {(dismiss: DismissReason) => void} dismissWith
2803
2801
  */
2804
2802
  const handleCancelButtonClick = (instance, dismissWith) => {
2805
2803
  instance.disableButtons();
@@ -2854,7 +2852,7 @@ const handleInputValidator = (instance, inputValue, type) => {
2854
2852
 
2855
2853
  /**
2856
2854
  * @param {SweetAlert} instance
2857
- * @param {any} value
2855
+ * @param {*} value
2858
2856
  */
2859
2857
  const deny = (instance, value) => {
2860
2858
  const innerParams = privateProps.innerParams.get(instance || undefined);
@@ -2869,14 +2867,14 @@ const deny = (instance, value) => {
2869
2867
  instance.hideLoading();
2870
2868
  handleAwaitingPromise(instance);
2871
2869
  } else {
2872
- instance.close({
2870
+ instance.close(/** @type SweetAlertResult */{
2873
2871
  isDenied: true,
2874
2872
  value: typeof preDenyValue === 'undefined' ? value : preDenyValue
2875
2873
  });
2876
2874
  }
2877
2875
  }).catch(error => rejectWith(instance || undefined, error));
2878
2876
  } else {
2879
- instance.close({
2877
+ instance.close(/** @type SweetAlertResult */{
2880
2878
  isDenied: true,
2881
2879
  value
2882
2880
  });
@@ -2885,10 +2883,10 @@ const deny = (instance, value) => {
2885
2883
 
2886
2884
  /**
2887
2885
  * @param {SweetAlert} instance
2888
- * @param {any} value
2886
+ * @param {*} value
2889
2887
  */
2890
2888
  const succeedWith = (instance, value) => {
2891
- instance.close({
2889
+ instance.close(/** @type SweetAlertResult */{
2892
2890
  isConfirmed: true,
2893
2891
  value
2894
2892
  });
@@ -2906,7 +2904,7 @@ const rejectWith = (instance, error) => {
2906
2904
  /**
2907
2905
  *
2908
2906
  * @param {SweetAlert} instance
2909
- * @param {any} value
2907
+ * @param {*} value
2910
2908
  */
2911
2909
  const confirm = (instance, value) => {
2912
2910
  const innerParams = privateProps.innerParams.get(instance || undefined);
@@ -3412,7 +3410,7 @@ var instanceMethods = /*#__PURE__*/Object.freeze({
3412
3410
  /**
3413
3411
  * @param {SweetAlertOptions} innerParams
3414
3412
  * @param {DomCache} domCache
3415
- * @param {Function} dismissWith
3413
+ * @param {(dismiss: DismissReason) => void} dismissWith
3416
3414
  */
3417
3415
  const handlePopupClick = (innerParams, domCache, dismissWith) => {
3418
3416
  if (innerParams.toast) {
@@ -3431,7 +3429,7 @@ const handlePopupClick = (innerParams, domCache, dismissWith) => {
3431
3429
  /**
3432
3430
  * @param {SweetAlertOptions} innerParams
3433
3431
  * @param {DomCache} domCache
3434
- * @param {Function} dismissWith
3432
+ * @param {(dismiss: DismissReason) => void} dismissWith
3435
3433
  */
3436
3434
  const handleToastClick = (innerParams, domCache, dismissWith) => {
3437
3435
  // Closing toast by internal click
@@ -3490,7 +3488,7 @@ const handleContainerMousedown = domCache => {
3490
3488
  /**
3491
3489
  * @param {SweetAlertOptions} innerParams
3492
3490
  * @param {DomCache} domCache
3493
- * @param {Function} dismissWith
3491
+ * @param {(dismiss: DismissReason) => void} dismissWith
3494
3492
  */
3495
3493
  const handleModalClick = (innerParams, domCache, dismissWith) => {
3496
3494
  domCache.container.onclick = e => {
@@ -3839,7 +3837,7 @@ var staticMethods = /*#__PURE__*/Object.freeze({
3839
3837
 
3840
3838
  class Timer {
3841
3839
  /**
3842
- * @param {Function} callback
3840
+ * @param {() => void} callback
3843
3841
  * @param {number} delay
3844
3842
  */
3845
3843
  constructor(callback, delay) {
@@ -3928,10 +3926,10 @@ const getTemplateParams = params => {
3928
3926
 
3929
3927
  /**
3930
3928
  * @param {DocumentFragment} templateContent
3931
- * @returns {Record<string, any>}
3929
+ * @returns {Record<string, string | boolean | number>}
3932
3930
  */
3933
3931
  const getSwalParams = templateContent => {
3934
- /** @type {Record<string, any>} */
3932
+ /** @type {Record<string, string | boolean | number>} */
3935
3933
  const result = {};
3936
3934
  /** @type {HTMLElement[]} */
3937
3935
  const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
@@ -3955,10 +3953,10 @@ const getSwalParams = templateContent => {
3955
3953
 
3956
3954
  /**
3957
3955
  * @param {DocumentFragment} templateContent
3958
- * @returns {Record<string, any>}
3956
+ * @returns {Record<string, () => void>}
3959
3957
  */
3960
3958
  const getSwalFunctionParams = templateContent => {
3961
- /** @type {Record<string, any>} */
3959
+ /** @type {Record<string, () => void>} */
3962
3960
  const result = {};
3963
3961
  /** @type {HTMLElement[]} */
3964
3962
  const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
@@ -3975,10 +3973,10 @@ const getSwalFunctionParams = templateContent => {
3975
3973
 
3976
3974
  /**
3977
3975
  * @param {DocumentFragment} templateContent
3978
- * @returns {Record<string, any>}
3976
+ * @returns {Record<string, string | boolean>}
3979
3977
  */
3980
3978
  const getSwalButtons = templateContent => {
3981
- /** @type {Record<string, any>} */
3979
+ /** @type {Record<string, string | boolean>} */
3982
3980
  const result = {};
3983
3981
  /** @type {HTMLElement[]} */
3984
3982
  const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
@@ -4028,7 +4026,7 @@ const getSwalImage = templateContent => {
4028
4026
 
4029
4027
  /**
4030
4028
  * @param {DocumentFragment} templateContent
4031
- * @returns {Record<string, any>}
4029
+ * @returns {object}
4032
4030
  */
4033
4031
  const getSwalIcon = templateContent => {
4034
4032
  const result = {};
@@ -4049,10 +4047,10 @@ const getSwalIcon = templateContent => {
4049
4047
 
4050
4048
  /**
4051
4049
  * @param {DocumentFragment} templateContent
4052
- * @returns {Record<string, any>}
4050
+ * @returns {object}
4053
4051
  */
4054
4052
  const getSwalInput = templateContent => {
4055
- /** @type {Record<string, any>} */
4053
+ /** @type {object} */
4056
4054
  const result = {};
4057
4055
  /** @type {HTMLElement | null} */
4058
4056
  const input = templateContent.querySelector('swal-input');
@@ -4089,10 +4087,10 @@ const getSwalInput = templateContent => {
4089
4087
  /**
4090
4088
  * @param {DocumentFragment} templateContent
4091
4089
  * @param {string[]} paramNames
4092
- * @returns {Record<string, any>}
4090
+ * @returns {Record<string, string>}
4093
4091
  */
4094
4092
  const getSwalStringParams = (templateContent, paramNames) => {
4095
- /** @type {Record<string, any>} */
4093
+ /** @type {Record<string, string>} */
4096
4094
  const result = {};
4097
4095
  for (const i in paramNames) {
4098
4096
  const paramName = paramNames[i];
@@ -4313,7 +4311,7 @@ let currentInstance;
4313
4311
  var _promise = /*#__PURE__*/new WeakMap();
4314
4312
  class SweetAlert {
4315
4313
  /**
4316
- * @param {...any} args
4314
+ * @param {...(SweetAlertOptions | string)} args
4317
4315
  * @this {SweetAlert}
4318
4316
  */
4319
4317
  constructor(...args) {
@@ -4397,7 +4395,9 @@ const swalPromise = (instance, domCache, innerParams) => {
4397
4395
  const dismissWith = dismiss => {
4398
4396
  instance.close({
4399
4397
  isDismissed: true,
4400
- dismiss
4398
+ dismiss,
4399
+ isConfirmed: false,
4400
+ isDenied: false
4401
4401
  });
4402
4402
  };
4403
4403
  privateMethods.swalPromiseResolve.set(instance, resolve);
@@ -4471,7 +4471,7 @@ const populateDomCache = instance => {
4471
4471
  /**
4472
4472
  * @param {GlobalState} globalState
4473
4473
  * @param {SweetAlertOptions} innerParams
4474
- * @param {Function} dismissWith
4474
+ * @param {(dismiss: DismissReason) => void} dismissWith
4475
4475
  */
4476
4476
  const setupTimer = (globalState, innerParams, dismissWith) => {
4477
4477
  const timerProgressBar = getTimerProgressBar();
@@ -4591,8 +4591,8 @@ Object.assign(SweetAlert, staticMethods);
4591
4591
  // Proxy to instance methods to constructor, for now, for backwards compatibility
4592
4592
  Object.keys(instanceMethods).forEach(key => {
4593
4593
  /**
4594
- * @param {...any} args
4595
- * @returns {any | undefined}
4594
+ * @param {...(SweetAlertOptions | string | undefined)} args
4595
+ * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
4596
4596
  */
4597
4597
  SweetAlert[key] = function (...args) {
4598
4598
  if (currentInstance && currentInstance[key]) {
@@ -4602,7 +4602,7 @@ Object.keys(instanceMethods).forEach(key => {
4602
4602
  };
4603
4603
  });
4604
4604
  SweetAlert.DismissReason = DismissReason;
4605
- SweetAlert.version = '11.26.1';
4605
+ SweetAlert.version = '11.26.2';
4606
4606
 
4607
4607
  const Swal = SweetAlert;
4608
4608
  // @ts-ignore