sweetalert2 11.4.2 → 11.4.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.4.2
2
+ * sweetalert2 v11.4.5
3
3
  * Released under the MIT License.
4
4
  */
5
5
  (function (global, factory) {
@@ -2190,997 +2190,1007 @@
2190
2190
  return inputValue && inputValue.toString() === optionValue.toString();
2191
2191
  };
2192
2192
 
2193
- const handleConfirmButtonClick = instance => {
2194
- const innerParams = privateProps.innerParams.get(instance);
2195
- instance.disableButtons();
2193
+ /**
2194
+ * Hides loader and shows back the button which was hidden by .showLoading()
2195
+ */
2196
2196
 
2197
- if (innerParams.input) {
2198
- handleConfirmOrDenyWithInput(instance, 'confirm');
2199
- } else {
2200
- confirm(instance, true);
2197
+ function hideLoading() {
2198
+ // do nothing if popup is closed
2199
+ const innerParams = privateProps.innerParams.get(this);
2200
+
2201
+ if (!innerParams) {
2202
+ return;
2201
2203
  }
2202
- };
2203
- const handleDenyButtonClick = instance => {
2204
- const innerParams = privateProps.innerParams.get(instance);
2205
- instance.disableButtons();
2206
2204
 
2207
- if (innerParams.returnInputValueOnDeny) {
2208
- handleConfirmOrDenyWithInput(instance, 'deny');
2205
+ const domCache = privateProps.domCache.get(this);
2206
+ hide(domCache.loader);
2207
+
2208
+ if (isToast()) {
2209
+ if (innerParams.icon) {
2210
+ show(getIcon());
2211
+ }
2209
2212
  } else {
2210
- deny(instance, false);
2213
+ showRelatedButton(domCache);
2211
2214
  }
2212
- };
2213
- const handleCancelButtonClick = (instance, dismissWith) => {
2214
- instance.disableButtons();
2215
- dismissWith(DismissReason.cancel);
2216
- };
2217
2215
 
2218
- const handleConfirmOrDenyWithInput = (instance, type
2219
- /* 'confirm' | 'deny' */
2220
- ) => {
2221
- const innerParams = privateProps.innerParams.get(instance);
2216
+ removeClass([domCache.popup, domCache.actions], swalClasses.loading);
2217
+ domCache.popup.removeAttribute('aria-busy');
2218
+ domCache.popup.removeAttribute('data-loading');
2219
+ domCache.confirmButton.disabled = false;
2220
+ domCache.denyButton.disabled = false;
2221
+ domCache.cancelButton.disabled = false;
2222
+ }
2222
2223
 
2223
- if (!innerParams.input) {
2224
- return error("The \"input\" parameter is needed to be set when using returnInputValueOn".concat(capitalizeFirstLetter(type)));
2224
+ const showRelatedButton = domCache => {
2225
+ const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute('data-button-to-replace'));
2226
+
2227
+ if (buttonToReplace.length) {
2228
+ show(buttonToReplace[0], 'inline-block');
2229
+ } else if (allButtonsAreHidden()) {
2230
+ hide(domCache.actions);
2225
2231
  }
2232
+ };
2226
2233
 
2227
- const inputValue = getInputValue(instance, innerParams);
2234
+ /**
2235
+ * Gets the input DOM node, this method works with input parameter.
2236
+ * @returns {HTMLElement | null}
2237
+ */
2228
2238
 
2229
- if (innerParams.inputValidator) {
2230
- handleInputValidator(instance, inputValue, type);
2231
- } else if (!instance.getInput().checkValidity()) {
2232
- instance.enableButtons();
2233
- instance.showValidationMessage(innerParams.validationMessage);
2234
- } else if (type === 'deny') {
2235
- deny(instance, inputValue);
2236
- } else {
2237
- confirm(instance, inputValue);
2239
+ function getInput$1(instance) {
2240
+ const innerParams = privateProps.innerParams.get(instance || this);
2241
+ const domCache = privateProps.domCache.get(instance || this);
2242
+
2243
+ if (!domCache) {
2244
+ return null;
2238
2245
  }
2239
- };
2240
2246
 
2241
- const handleInputValidator = (instance, inputValue, type
2242
- /* 'confirm' | 'deny' */
2243
- ) => {
2244
- const innerParams = privateProps.innerParams.get(instance);
2245
- instance.disableInput();
2246
- const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
2247
- validationPromise.then(validationMessage => {
2248
- instance.enableButtons();
2249
- instance.enableInput();
2247
+ return getInput(domCache.popup, innerParams.input);
2248
+ }
2250
2249
 
2251
- if (validationMessage) {
2252
- instance.showValidationMessage(validationMessage);
2253
- } else if (type === 'deny') {
2254
- deny(instance, inputValue);
2255
- } else {
2256
- confirm(instance, inputValue);
2257
- }
2258
- });
2250
+ /**
2251
+ * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
2252
+ * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
2253
+ * This is the approach that Babel will probably take to implement private methods/fields
2254
+ * https://github.com/tc39/proposal-private-methods
2255
+ * https://github.com/babel/babel/pull/7555
2256
+ * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
2257
+ * then we can use that language feature.
2258
+ */
2259
+ var privateMethods = {
2260
+ swalPromiseResolve: new WeakMap(),
2261
+ swalPromiseReject: new WeakMap()
2259
2262
  };
2260
2263
 
2261
- const deny = (instance, value) => {
2262
- const innerParams = privateProps.innerParams.get(instance || undefined);
2264
+ /*
2265
+ * Instance method to close sweetAlert
2266
+ */
2263
2267
 
2264
- if (innerParams.showLoaderOnDeny) {
2265
- showLoading(getDenyButton());
2268
+ function removePopupAndResetState(instance, container, returnFocus, didClose) {
2269
+ if (isToast()) {
2270
+ triggerDidCloseAndDispose(instance, didClose);
2271
+ } else {
2272
+ restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
2273
+ globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
2274
+ capture: globalState.keydownListenerCapture
2275
+ });
2276
+ globalState.keydownHandlerAdded = false;
2266
2277
  }
2267
2278
 
2268
- if (innerParams.preDeny) {
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
2279
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // workaround for #2088
2280
+ // for some reason removing the container in Safari will scroll the document to bottom
2270
2281
 
2271
- const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
2272
- preDenyPromise.then(preDenyValue => {
2273
- if (preDenyValue === false) {
2274
- instance.hideLoading();
2275
- } else {
2276
- instance.closePopup({
2277
- isDenied: true,
2278
- value: typeof preDenyValue === 'undefined' ? value : preDenyValue
2279
- });
2280
- }
2281
- }).catch(error$$1 => rejectWith(instance || undefined, error$$1));
2282
+ if (isSafari) {
2283
+ container.setAttribute('style', 'display:none !important');
2284
+ container.removeAttribute('class');
2285
+ container.innerHTML = '';
2282
2286
  } else {
2283
- instance.closePopup({
2284
- isDenied: true,
2285
- value
2286
- });
2287
+ container.remove();
2287
2288
  }
2288
- };
2289
2289
 
2290
- const succeedWith = (instance, value) => {
2291
- instance.closePopup({
2292
- isConfirmed: true,
2293
- value
2294
- });
2295
- };
2290
+ if (isModal()) {
2291
+ undoScrollbar();
2292
+ undoIOSfix();
2293
+ unsetAriaHidden();
2294
+ }
2296
2295
 
2297
- const rejectWith = (instance, error$$1) => {
2298
- instance.rejectPromise(error$$1);
2299
- };
2296
+ removeBodyClasses();
2297
+ }
2300
2298
 
2301
- const confirm = (instance, value) => {
2302
- const innerParams = privateProps.innerParams.get(instance || undefined);
2299
+ function removeBodyClasses() {
2300
+ removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
2301
+ }
2303
2302
 
2304
- if (innerParams.showLoaderOnConfirm) {
2305
- showLoading();
2303
+ function close(resolveValue) {
2304
+ resolveValue = prepareResolveValue(resolveValue);
2305
+ const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
2306
+ const didClose = triggerClosePopup(this);
2307
+
2308
+ if (this.isAwaitingPromise()) {
2309
+ // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
2310
+ if (!resolveValue.isDismissed) {
2311
+ handleAwaitingPromise(this);
2312
+ swalPromiseResolve(resolveValue);
2313
+ }
2314
+ } else if (didClose) {
2315
+ // Resolve Swal promise
2316
+ swalPromiseResolve(resolveValue);
2306
2317
  }
2318
+ }
2319
+ function isAwaitingPromise() {
2320
+ return !!privateProps.awaitingPromise.get(this);
2321
+ }
2307
2322
 
2308
- if (innerParams.preConfirm) {
2309
- instance.resetValidationMessage();
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
2323
+ const triggerClosePopup = instance => {
2324
+ const popup = getPopup();
2311
2325
 
2312
- const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
2313
- preConfirmPromise.then(preConfirmValue => {
2314
- if (isVisible(getValidationMessage()) || preConfirmValue === false) {
2315
- instance.hideLoading();
2316
- } else {
2317
- succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
2318
- }
2319
- }).catch(error$$1 => rejectWith(instance || undefined, error$$1));
2320
- } else {
2321
- succeedWith(instance, value);
2326
+ if (!popup) {
2327
+ return false;
2322
2328
  }
2323
- };
2324
2329
 
2325
- const handlePopupClick = (instance, domCache, dismissWith) => {
2326
2330
  const innerParams = privateProps.innerParams.get(instance);
2327
2331
 
2328
- if (innerParams.toast) {
2329
- handleToastClick(instance, domCache, dismissWith);
2330
- } else {
2331
- // Ignore click events that had mousedown on the popup but mouseup on the container
2332
- // This can happen when the user drags a slider
2333
- handleModalMousedown(domCache); // Ignore click events that had mousedown on the container but mouseup on the popup
2334
-
2335
- handleContainerMousedown(domCache);
2336
- handleModalClick(instance, domCache, dismissWith);
2332
+ if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
2333
+ return false;
2337
2334
  }
2335
+
2336
+ removeClass(popup, innerParams.showClass.popup);
2337
+ addClass(popup, innerParams.hideClass.popup);
2338
+ const backdrop = getContainer();
2339
+ removeClass(backdrop, innerParams.showClass.backdrop);
2340
+ addClass(backdrop, innerParams.hideClass.backdrop);
2341
+ handlePopupAnimation(instance, popup, innerParams);
2342
+ return true;
2338
2343
  };
2339
2344
 
2340
- const handleToastClick = (instance, domCache, dismissWith) => {
2341
- // Closing toast by internal click
2342
- domCache.popup.onclick = () => {
2343
- const innerParams = privateProps.innerParams.get(instance);
2345
+ function rejectPromise(error) {
2346
+ const rejectPromise = privateMethods.swalPromiseReject.get(this);
2347
+ handleAwaitingPromise(this);
2344
2348
 
2345
- if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
2346
- return;
2347
- }
2349
+ if (rejectPromise) {
2350
+ // Reject Swal promise
2351
+ rejectPromise(error);
2352
+ }
2353
+ }
2354
+ const handleAwaitingPromise = instance => {
2355
+ if (instance.isAwaitingPromise()) {
2356
+ privateProps.awaitingPromise.delete(instance); // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
2348
2357
 
2349
- dismissWith(DismissReason.close);
2350
- };
2358
+ if (!privateProps.innerParams.get(instance)) {
2359
+ instance._destroy();
2360
+ }
2361
+ }
2351
2362
  };
2352
- /**
2353
- * @param {*} innerParams
2354
- * @returns {boolean}
2355
- */
2356
2363
 
2364
+ const prepareResolveValue = resolveValue => {
2365
+ // When user calls Swal.close()
2366
+ if (typeof resolveValue === 'undefined') {
2367
+ return {
2368
+ isConfirmed: false,
2369
+ isDenied: false,
2370
+ isDismissed: true
2371
+ };
2372
+ }
2357
2373
 
2358
- const isAnyButtonShown = innerParams => {
2359
- return innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton;
2374
+ return Object.assign({
2375
+ isConfirmed: false,
2376
+ isDenied: false,
2377
+ isDismissed: false
2378
+ }, resolveValue);
2360
2379
  };
2361
2380
 
2362
- let ignoreOutsideClick = false;
2381
+ const handlePopupAnimation = (instance, popup, innerParams) => {
2382
+ const container = getContainer(); // If animation is supported, animate
2363
2383
 
2364
- const handleModalMousedown = domCache => {
2365
- domCache.popup.onmousedown = () => {
2366
- domCache.container.onmouseup = function (e) {
2367
- domCache.container.onmouseup = undefined; // We only check if the mouseup target is the container because usually it doesn't
2368
- // have any other direct children aside of the popup
2384
+ const animationIsSupported = animationEndEvent && hasCssAnimation(popup);
2369
2385
 
2370
- if (e.target === domCache.container) {
2371
- ignoreOutsideClick = true;
2372
- }
2373
- };
2374
- };
2386
+ if (typeof innerParams.willClose === 'function') {
2387
+ innerParams.willClose(popup);
2388
+ }
2389
+
2390
+ if (animationIsSupported) {
2391
+ animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
2392
+ } else {
2393
+ // Otherwise, remove immediately
2394
+ removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
2395
+ }
2375
2396
  };
2376
2397
 
2377
- const handleContainerMousedown = domCache => {
2378
- domCache.container.onmousedown = () => {
2379
- domCache.popup.onmouseup = function (e) {
2380
- domCache.popup.onmouseup = undefined; // We also need to check if the mouseup target is a child of the popup
2398
+ const animatePopup = (instance, popup, container, returnFocus, didClose) => {
2399
+ globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
2400
+ popup.addEventListener(animationEndEvent, function (e) {
2401
+ if (e.target === popup) {
2402
+ globalState.swalCloseEventFinishedCallback();
2403
+ delete globalState.swalCloseEventFinishedCallback;
2404
+ }
2405
+ });
2406
+ };
2381
2407
 
2382
- if (e.target === domCache.popup || domCache.popup.contains(e.target)) {
2383
- ignoreOutsideClick = true;
2384
- }
2385
- };
2386
- };
2408
+ const triggerDidCloseAndDispose = (instance, didClose) => {
2409
+ setTimeout(() => {
2410
+ if (typeof didClose === 'function') {
2411
+ didClose.bind(instance.params)();
2412
+ }
2413
+
2414
+ instance._destroy();
2415
+ });
2387
2416
  };
2388
2417
 
2389
- const handleModalClick = (instance, domCache, dismissWith) => {
2390
- domCache.container.onclick = e => {
2391
- const innerParams = privateProps.innerParams.get(instance);
2418
+ function setButtonsDisabled(instance, buttons, disabled) {
2419
+ const domCache = privateProps.domCache.get(instance);
2420
+ buttons.forEach(button => {
2421
+ domCache[button].disabled = disabled;
2422
+ });
2423
+ }
2392
2424
 
2393
- if (ignoreOutsideClick) {
2394
- ignoreOutsideClick = false;
2395
- return;
2396
- }
2425
+ function setInputDisabled(input, disabled) {
2426
+ if (!input) {
2427
+ return false;
2428
+ }
2397
2429
 
2398
- if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
2399
- dismissWith(DismissReason.backdrop);
2430
+ if (input.type === 'radio') {
2431
+ const radiosContainer = input.parentNode.parentNode;
2432
+ const radios = radiosContainer.querySelectorAll('input');
2433
+
2434
+ for (let i = 0; i < radios.length; i++) {
2435
+ radios[i].disabled = disabled;
2400
2436
  }
2401
- };
2402
- };
2437
+ } else {
2438
+ input.disabled = disabled;
2439
+ }
2440
+ }
2403
2441
 
2404
- /*
2405
- * Global function to determine if SweetAlert2 popup is shown
2406
- */
2442
+ function enableButtons() {
2443
+ setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
2444
+ }
2445
+ function disableButtons() {
2446
+ setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
2447
+ }
2448
+ function enableInput() {
2449
+ return setInputDisabled(this.getInput(), false);
2450
+ }
2451
+ function disableInput() {
2452
+ return setInputDisabled(this.getInput(), true);
2453
+ }
2407
2454
 
2408
- const isVisible$1 = () => {
2409
- return isVisible(getPopup());
2410
- };
2411
- /*
2412
- * Global function to click 'Confirm' button
2413
- */
2455
+ function showValidationMessage(error) {
2456
+ const domCache = privateProps.domCache.get(this);
2457
+ const params = privateProps.innerParams.get(this);
2458
+ setInnerHtml(domCache.validationMessage, error);
2459
+ domCache.validationMessage.className = swalClasses['validation-message'];
2414
2460
 
2415
- const clickConfirm = () => getConfirmButton() && getConfirmButton().click();
2416
- /*
2417
- * Global function to click 'Deny' button
2418
- */
2461
+ if (params.customClass && params.customClass.validationMessage) {
2462
+ addClass(domCache.validationMessage, params.customClass.validationMessage);
2463
+ }
2419
2464
 
2420
- const clickDeny = () => getDenyButton() && getDenyButton().click();
2421
- /*
2422
- * Global function to click 'Cancel' button
2423
- */
2465
+ show(domCache.validationMessage);
2466
+ const input = this.getInput();
2424
2467
 
2425
- const clickCancel = () => getCancelButton() && getCancelButton().click();
2468
+ if (input) {
2469
+ input.setAttribute('aria-invalid', true);
2470
+ input.setAttribute('aria-describedby', swalClasses['validation-message']);
2471
+ focusInput(input);
2472
+ addClass(input, swalClasses.inputerror);
2473
+ }
2474
+ } // Hide block with validation message
2426
2475
 
2427
- const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
2428
- if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
2429
- globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
2430
- capture: globalState.keydownListenerCapture
2431
- });
2432
- globalState.keydownHandlerAdded = false;
2476
+ function resetValidationMessage$1() {
2477
+ const domCache = privateProps.domCache.get(this);
2478
+
2479
+ if (domCache.validationMessage) {
2480
+ hide(domCache.validationMessage);
2433
2481
  }
2434
2482
 
2435
- if (!innerParams.toast) {
2436
- globalState.keydownHandler = e => keydownHandler(instance, e, dismissWith);
2483
+ const input = this.getInput();
2437
2484
 
2438
- globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
2439
- globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
2440
- globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
2441
- capture: globalState.keydownListenerCapture
2442
- });
2443
- globalState.keydownHandlerAdded = true;
2485
+ if (input) {
2486
+ input.removeAttribute('aria-invalid');
2487
+ input.removeAttribute('aria-describedby');
2488
+ removeClass(input, swalClasses.inputerror);
2444
2489
  }
2445
- }; // Focus handling
2490
+ }
2446
2491
 
2447
- const setFocus = (innerParams, index, increment) => {
2448
- const focusableElements = getFocusableElements(); // search for visible elements and select the next possible match
2492
+ function getProgressSteps$1() {
2493
+ const domCache = privateProps.domCache.get(this);
2494
+ return domCache.progressSteps;
2495
+ }
2449
2496
 
2450
- if (focusableElements.length) {
2451
- index = index + increment; // rollover to first item
2497
+ /**
2498
+ * Updates popup parameters.
2499
+ */
2452
2500
 
2453
- if (index === focusableElements.length) {
2454
- index = 0; // go to last item
2455
- } else if (index === -1) {
2456
- index = focusableElements.length - 1;
2457
- }
2501
+ function update(params) {
2502
+ const popup = getPopup();
2503
+ const innerParams = privateProps.innerParams.get(this);
2458
2504
 
2459
- return focusableElements[index].focus();
2460
- } // no visible focusable elements, focus the popup
2505
+ if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
2506
+ 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.");
2507
+ }
2461
2508
 
2509
+ const validUpdatableParams = filterValidParams(params);
2510
+ const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
2511
+ render(this, updatedParams);
2512
+ privateProps.innerParams.set(this, updatedParams);
2513
+ Object.defineProperties(this, {
2514
+ params: {
2515
+ value: Object.assign({}, this.params, params),
2516
+ writable: false,
2517
+ enumerable: true
2518
+ }
2519
+ });
2520
+ }
2462
2521
 
2463
- getPopup().focus();
2522
+ const filterValidParams = params => {
2523
+ const validUpdatableParams = {};
2524
+ Object.keys(params).forEach(param => {
2525
+ if (isUpdatableParameter(param)) {
2526
+ validUpdatableParams[param] = params[param];
2527
+ } else {
2528
+ 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"));
2529
+ }
2530
+ });
2531
+ return validUpdatableParams;
2464
2532
  };
2465
- const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
2466
- const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
2467
2533
 
2468
- const keydownHandler = (instance, e, dismissWith) => {
2469
- const innerParams = privateProps.innerParams.get(instance);
2534
+ function _destroy() {
2535
+ const domCache = privateProps.domCache.get(this);
2536
+ const innerParams = privateProps.innerParams.get(this);
2470
2537
 
2471
2538
  if (!innerParams) {
2539
+ disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
2540
+
2472
2541
  return; // This instance has already been destroyed
2473
- }
2542
+ } // Check if there is another Swal closing
2474
2543
 
2475
- if (innerParams.stopKeydownPropagation) {
2476
- e.stopPropagation();
2477
- } // ENTER
2478
2544
 
2545
+ if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
2546
+ globalState.swalCloseEventFinishedCallback();
2547
+ delete globalState.swalCloseEventFinishedCallback;
2548
+ } // Check if there is a swal disposal defer timer
2479
2549
 
2480
- if (e.key === 'Enter') {
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') {
2490
- handleEsc(e, innerParams, dismissWith);
2550
+
2551
+ if (globalState.deferDisposalTimer) {
2552
+ clearTimeout(globalState.deferDisposalTimer);
2553
+ delete globalState.deferDisposalTimer;
2491
2554
  }
2492
- };
2493
2555
 
2494
- const handleEnter = (instance, e, innerParams) => {
2495
- // #2386 #720 #721
2496
- if (!callIfFunction(innerParams.allowEnterKey) || e.isComposing) {
2497
- return;
2556
+ if (typeof innerParams.didDestroy === 'function') {
2557
+ innerParams.didDestroy();
2498
2558
  }
2499
2559
 
2500
- if (e.target && instance.getInput() && e.target.outerHTML === instance.getInput().outerHTML) {
2501
- if (['textarea', 'file'].includes(innerParams.input)) {
2502
- return; // do not submit
2503
- }
2560
+ disposeSwal(this);
2561
+ }
2504
2562
 
2505
- clickConfirm();
2506
- e.preventDefault();
2507
- }
2508
- };
2563
+ const disposeSwal = instance => {
2564
+ disposeWeakMaps(instance); // Unset this.params so GC will dispose it (#1569)
2509
2565
 
2510
- const handleTab = (e, innerParams) => {
2511
- const targetElement = e.target;
2512
- const focusableElements = getFocusableElements();
2513
- let btnIndex = -1;
2566
+ delete instance.params; // Unset globalState props so GC will dispose globalState (#1569)
2514
2567
 
2515
- for (let i = 0; i < focusableElements.length; i++) {
2516
- if (targetElement === focusableElements[i]) {
2517
- btnIndex = i;
2518
- break;
2519
- }
2520
- } // Cycle to the next button
2568
+ delete globalState.keydownHandler;
2569
+ delete globalState.keydownTarget; // Unset currentInstance
2521
2570
 
2571
+ delete globalState.currentInstance;
2572
+ };
2522
2573
 
2523
- if (!e.shiftKey) {
2524
- setFocus(innerParams, btnIndex, 1);
2525
- } // Cycle to the prev button
2526
- else {
2527
- setFocus(innerParams, btnIndex, -1);
2574
+ const disposeWeakMaps = instance => {
2575
+ // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
2576
+ if (instance.isAwaitingPromise()) {
2577
+ unsetWeakMaps(privateProps, instance);
2578
+ privateProps.awaitingPromise.set(instance, true);
2579
+ } else {
2580
+ unsetWeakMaps(privateMethods, instance);
2581
+ unsetWeakMaps(privateProps, instance);
2528
2582
  }
2529
-
2530
- e.stopPropagation();
2531
- e.preventDefault();
2532
2583
  };
2533
2584
 
2534
- const handleArrows = key => {
2535
- const confirmButton = getConfirmButton();
2536
- const denyButton = getDenyButton();
2537
- const cancelButton = getCancelButton();
2538
-
2539
- if (![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
2540
- return;
2585
+ const unsetWeakMaps = (obj, instance) => {
2586
+ for (const i in obj) {
2587
+ obj[i].delete(instance);
2541
2588
  }
2589
+ };
2542
2590
 
2543
- const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
2544
- let buttonToFocus = document.activeElement;
2545
2591
 
2546
- for (let i = 0; i < getActions().children.length; i++) {
2547
- buttonToFocus = buttonToFocus[sibling];
2548
2592
 
2549
- if (!buttonToFocus) {
2550
- return;
2551
- }
2593
+ var instanceMethods = /*#__PURE__*/Object.freeze({
2594
+ hideLoading: hideLoading,
2595
+ disableLoading: hideLoading,
2596
+ getInput: getInput$1,
2597
+ close: close,
2598
+ isAwaitingPromise: isAwaitingPromise,
2599
+ rejectPromise: rejectPromise,
2600
+ handleAwaitingPromise: handleAwaitingPromise,
2601
+ closePopup: close,
2602
+ closeModal: close,
2603
+ closeToast: close,
2604
+ enableButtons: enableButtons,
2605
+ disableButtons: disableButtons,
2606
+ enableInput: enableInput,
2607
+ disableInput: disableInput,
2608
+ showValidationMessage: showValidationMessage,
2609
+ resetValidationMessage: resetValidationMessage$1,
2610
+ getProgressSteps: getProgressSteps$1,
2611
+ update: update,
2612
+ _destroy: _destroy
2613
+ });
2552
2614
 
2553
- if (isVisible(buttonToFocus) && buttonToFocus instanceof HTMLButtonElement) {
2554
- break;
2555
- }
2556
- }
2615
+ const handleConfirmButtonClick = instance => {
2616
+ const innerParams = privateProps.innerParams.get(instance);
2617
+ instance.disableButtons();
2557
2618
 
2558
- if (buttonToFocus instanceof HTMLButtonElement) {
2559
- buttonToFocus.focus();
2619
+ if (innerParams.input) {
2620
+ handleConfirmOrDenyWithInput(instance, 'confirm');
2621
+ } else {
2622
+ confirm(instance, true);
2560
2623
  }
2561
2624
  };
2625
+ const handleDenyButtonClick = instance => {
2626
+ const innerParams = privateProps.innerParams.get(instance);
2627
+ instance.disableButtons();
2562
2628
 
2563
- const handleEsc = (e, innerParams, dismissWith) => {
2564
- if (callIfFunction(innerParams.allowEscapeKey)) {
2565
- e.preventDefault();
2566
- dismissWith(DismissReason.esc);
2629
+ if (innerParams.returnInputValueOnDeny) {
2630
+ handleConfirmOrDenyWithInput(instance, 'deny');
2631
+ } else {
2632
+ deny(instance, false);
2567
2633
  }
2568
2634
  };
2635
+ const handleCancelButtonClick = (instance, dismissWith) => {
2636
+ instance.disableButtons();
2637
+ dismissWith(DismissReason.cancel);
2638
+ };
2569
2639
 
2570
- const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
2640
+ const handleConfirmOrDenyWithInput = (instance, type
2641
+ /* 'confirm' | 'deny' */
2642
+ ) => {
2643
+ const innerParams = privateProps.innerParams.get(instance);
2571
2644
 
2572
- const isElement = elem => elem instanceof Element || isJqueryElement(elem);
2645
+ if (!innerParams.input) {
2646
+ return error("The \"input\" parameter is needed to be set when using returnInputValueOn".concat(capitalizeFirstLetter(type)));
2647
+ }
2573
2648
 
2574
- const argsToParams = args => {
2575
- const params = {};
2649
+ const inputValue = getInputValue(instance, innerParams);
2576
2650
 
2577
- if (typeof args[0] === 'object' && !isElement(args[0])) {
2578
- Object.assign(params, args[0]);
2651
+ if (innerParams.inputValidator) {
2652
+ handleInputValidator(instance, inputValue, type);
2653
+ } else if (!instance.getInput().checkValidity()) {
2654
+ instance.enableButtons();
2655
+ instance.showValidationMessage(innerParams.validationMessage);
2656
+ } else if (type === 'deny') {
2657
+ deny(instance, inputValue);
2579
2658
  } else {
2580
- ['title', 'html', 'icon'].forEach((name, index) => {
2581
- const arg = args[index];
2582
-
2583
- if (typeof arg === 'string' || isElement(arg)) {
2584
- params[name] = arg;
2585
- } else if (arg !== undefined) {
2586
- error("Unexpected type of ".concat(name, "! Expected \"string\" or \"Element\", got ").concat(typeof arg));
2587
- }
2588
- });
2659
+ confirm(instance, inputValue);
2589
2660
  }
2590
-
2591
- return params;
2592
2661
  };
2593
2662
 
2594
- function fire() {
2595
- const Swal = this; // eslint-disable-line @typescript-eslint/no-this-alias
2596
-
2597
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2598
- args[_key] = arguments[_key];
2599
- }
2600
-
2601
- return new Swal(...args);
2602
- }
2663
+ const handleInputValidator = (instance, inputValue, type
2664
+ /* 'confirm' | 'deny' */
2665
+ ) => {
2666
+ const innerParams = privateProps.innerParams.get(instance);
2667
+ instance.disableInput();
2668
+ const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
2669
+ validationPromise.then(validationMessage => {
2670
+ instance.enableButtons();
2671
+ instance.enableInput();
2603
2672
 
2604
- /**
2605
- * Returns an extended version of `Swal` containing `params` as defaults.
2606
- * Useful for reusing Swal configuration.
2607
- *
2608
- * For example:
2609
- *
2610
- * Before:
2611
- * const textPromptOptions = { input: 'text', showCancelButton: true }
2612
- * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
2613
- * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
2614
- *
2615
- * After:
2616
- * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
2617
- * const {value: firstName} = await TextPrompt('What is your first name?')
2618
- * const {value: lastName} = await TextPrompt('What is your last name?')
2619
- *
2620
- * @param mixinParams
2621
- */
2622
- function mixin(mixinParams) {
2623
- class MixinSwal extends this {
2624
- _main(params, priorityMixinParams) {
2625
- return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
2673
+ if (validationMessage) {
2674
+ instance.showValidationMessage(validationMessage);
2675
+ } else if (type === 'deny') {
2676
+ deny(instance, inputValue);
2677
+ } else {
2678
+ confirm(instance, inputValue);
2626
2679
  }
2680
+ });
2681
+ };
2627
2682
 
2628
- }
2629
-
2630
- return MixinSwal;
2631
- }
2683
+ const deny = (instance, value) => {
2684
+ const innerParams = privateProps.innerParams.get(instance || undefined);
2632
2685
 
2633
- /**
2634
- * If `timer` parameter is set, returns number of milliseconds of timer remained.
2635
- * Otherwise, returns undefined.
2636
- */
2686
+ if (innerParams.showLoaderOnDeny) {
2687
+ showLoading(getDenyButton());
2688
+ }
2637
2689
 
2638
- const getTimerLeft = () => {
2639
- return globalState.timeout && globalState.timeout.getTimerLeft();
2640
- };
2641
- /**
2642
- * Stop timer. Returns number of milliseconds of timer remained.
2643
- * If `timer` parameter isn't set, returns undefined.
2644
- */
2690
+ if (innerParams.preDeny) {
2691
+ 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
2645
2692
 
2646
- const stopTimer = () => {
2647
- if (globalState.timeout) {
2648
- stopTimerProgressBar();
2649
- return globalState.timeout.stop();
2693
+ const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
2694
+ preDenyPromise.then(preDenyValue => {
2695
+ if (preDenyValue === false) {
2696
+ instance.hideLoading();
2697
+ handleAwaitingPromise(instance);
2698
+ } else {
2699
+ instance.closePopup({
2700
+ isDenied: true,
2701
+ value: typeof preDenyValue === 'undefined' ? value : preDenyValue
2702
+ });
2703
+ }
2704
+ }).catch(error$$1 => rejectWith(instance || undefined, error$$1));
2705
+ } else {
2706
+ instance.closePopup({
2707
+ isDenied: true,
2708
+ value
2709
+ });
2650
2710
  }
2651
2711
  };
2652
- /**
2653
- * Resume timer. Returns number of milliseconds of timer remained.
2654
- * If `timer` parameter isn't set, returns undefined.
2655
- */
2656
2712
 
2657
- const resumeTimer = () => {
2658
- if (globalState.timeout) {
2659
- const remaining = globalState.timeout.start();
2660
- animateTimerProgressBar(remaining);
2661
- return remaining;
2662
- }
2713
+ const succeedWith = (instance, value) => {
2714
+ instance.closePopup({
2715
+ isConfirmed: true,
2716
+ value
2717
+ });
2663
2718
  };
2664
- /**
2665
- * Resume timer. Returns number of milliseconds of timer remained.
2666
- * If `timer` parameter isn't set, returns undefined.
2667
- */
2668
2719
 
2669
- const toggleTimer = () => {
2670
- const timer = globalState.timeout;
2671
- return timer && (timer.running ? stopTimer() : resumeTimer());
2672
- };
2673
- /**
2674
- * Increase timer. Returns number of milliseconds of an updated timer.
2675
- * If `timer` parameter isn't set, returns undefined.
2676
- */
2677
-
2678
- const increaseTimer = n => {
2679
- if (globalState.timeout) {
2680
- const remaining = globalState.timeout.increase(n);
2681
- animateTimerProgressBar(remaining, true);
2682
- return remaining;
2683
- }
2684
- };
2685
- /**
2686
- * Check if timer is running. Returns true if timer is running
2687
- * or false if timer is paused or stopped.
2688
- * If `timer` parameter isn't set, returns undefined
2689
- */
2690
-
2691
- const isTimerRunning = () => {
2692
- return globalState.timeout && globalState.timeout.isRunning();
2720
+ const rejectWith = (instance, error$$1) => {
2721
+ instance.rejectPromise(error$$1);
2693
2722
  };
2694
2723
 
2695
- let bodyClickListenerAdded = false;
2696
- const clickHandlers = {};
2697
- function bindClickHandler() {
2698
- let attr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'data-swal-template';
2699
- clickHandlers[attr] = this;
2724
+ const confirm = (instance, value) => {
2725
+ const innerParams = privateProps.innerParams.get(instance || undefined);
2700
2726
 
2701
- if (!bodyClickListenerAdded) {
2702
- document.body.addEventListener('click', bodyClickListener);
2703
- bodyClickListenerAdded = true;
2727
+ if (innerParams.showLoaderOnConfirm) {
2728
+ showLoading();
2704
2729
  }
2705
- }
2706
2730
 
2707
- const bodyClickListener = event => {
2708
- for (let el = event.target; el && el !== document; el = el.parentNode) {
2709
- for (const attr in clickHandlers) {
2710
- const template = el.getAttribute(attr);
2731
+ if (innerParams.preConfirm) {
2732
+ instance.resetValidationMessage();
2733
+ 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
2711
2734
 
2712
- if (template) {
2713
- clickHandlers[attr].fire({
2714
- template
2715
- });
2716
- return;
2735
+ const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
2736
+ preConfirmPromise.then(preConfirmValue => {
2737
+ if (isVisible(getValidationMessage()) || preConfirmValue === false) {
2738
+ instance.hideLoading();
2739
+ handleAwaitingPromise(instance);
2740
+ } else {
2741
+ succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
2717
2742
  }
2718
- }
2743
+ }).catch(error$$1 => rejectWith(instance || undefined, error$$1));
2744
+ } else {
2745
+ succeedWith(instance, value);
2719
2746
  }
2720
2747
  };
2721
2748
 
2749
+ const handlePopupClick = (instance, domCache, dismissWith) => {
2750
+ const innerParams = privateProps.innerParams.get(instance);
2751
+
2752
+ if (innerParams.toast) {
2753
+ handleToastClick(instance, domCache, dismissWith);
2754
+ } else {
2755
+ // Ignore click events that had mousedown on the popup but mouseup on the container
2756
+ // This can happen when the user drags a slider
2757
+ handleModalMousedown(domCache); // Ignore click events that had mousedown on the container but mouseup on the popup
2758
+
2759
+ handleContainerMousedown(domCache);
2760
+ handleModalClick(instance, domCache, dismissWith);
2761
+ }
2762
+ };
2722
2763
 
2764
+ const handleToastClick = (instance, domCache, dismissWith) => {
2765
+ // Closing toast by internal click
2766
+ domCache.popup.onclick = () => {
2767
+ const innerParams = privateProps.innerParams.get(instance);
2723
2768
 
2724
- var staticMethods = /*#__PURE__*/Object.freeze({
2725
- isValidParameter: isValidParameter,
2726
- isUpdatableParameter: isUpdatableParameter,
2727
- isDeprecatedParameter: isDeprecatedParameter,
2728
- argsToParams: argsToParams,
2729
- isVisible: isVisible$1,
2730
- clickConfirm: clickConfirm,
2731
- clickDeny: clickDeny,
2732
- clickCancel: clickCancel,
2733
- getContainer: getContainer,
2734
- getPopup: getPopup,
2735
- getTitle: getTitle,
2736
- getHtmlContainer: getHtmlContainer,
2737
- getImage: getImage,
2738
- getIcon: getIcon,
2739
- getInputLabel: getInputLabel,
2740
- getCloseButton: getCloseButton,
2741
- getActions: getActions,
2742
- getConfirmButton: getConfirmButton,
2743
- getDenyButton: getDenyButton,
2744
- getCancelButton: getCancelButton,
2745
- getLoader: getLoader,
2746
- getFooter: getFooter,
2747
- getTimerProgressBar: getTimerProgressBar,
2748
- getFocusableElements: getFocusableElements,
2749
- getValidationMessage: getValidationMessage,
2750
- isLoading: isLoading,
2751
- fire: fire,
2752
- mixin: mixin,
2753
- showLoading: showLoading,
2754
- enableLoading: showLoading,
2755
- getTimerLeft: getTimerLeft,
2756
- stopTimer: stopTimer,
2757
- resumeTimer: resumeTimer,
2758
- toggleTimer: toggleTimer,
2759
- increaseTimer: increaseTimer,
2760
- isTimerRunning: isTimerRunning,
2761
- bindClickHandler: bindClickHandler
2762
- });
2769
+ if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
2770
+ return;
2771
+ }
2763
2772
 
2773
+ dismissWith(DismissReason.close);
2774
+ };
2775
+ };
2764
2776
  /**
2765
- * Hides loader and shows back the button which was hidden by .showLoading()
2777
+ * @param {*} innerParams
2778
+ * @returns {boolean}
2766
2779
  */
2767
2780
 
2768
- function hideLoading() {
2769
- // do nothing if popup is closed
2770
- const innerParams = privateProps.innerParams.get(this);
2771
2781
 
2772
- if (!innerParams) {
2773
- return;
2774
- }
2782
+ const isAnyButtonShown = innerParams => {
2783
+ return innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton;
2784
+ };
2775
2785
 
2776
- const domCache = privateProps.domCache.get(this);
2777
- hide(domCache.loader);
2786
+ let ignoreOutsideClick = false;
2778
2787
 
2779
- if (isToast()) {
2780
- if (innerParams.icon) {
2781
- show(getIcon());
2782
- }
2783
- } else {
2784
- showRelatedButton(domCache);
2785
- }
2788
+ const handleModalMousedown = domCache => {
2789
+ domCache.popup.onmousedown = () => {
2790
+ domCache.container.onmouseup = function (e) {
2791
+ domCache.container.onmouseup = undefined; // We only check if the mouseup target is the container because usually it doesn't
2792
+ // have any other direct children aside of the popup
2786
2793
 
2787
- removeClass([domCache.popup, domCache.actions], swalClasses.loading);
2788
- domCache.popup.removeAttribute('aria-busy');
2789
- domCache.popup.removeAttribute('data-loading');
2790
- domCache.confirmButton.disabled = false;
2791
- domCache.denyButton.disabled = false;
2792
- domCache.cancelButton.disabled = false;
2793
- }
2794
+ if (e.target === domCache.container) {
2795
+ ignoreOutsideClick = true;
2796
+ }
2797
+ };
2798
+ };
2799
+ };
2794
2800
 
2795
- const showRelatedButton = domCache => {
2796
- const buttonToReplace = domCache.popup.getElementsByClassName(domCache.loader.getAttribute('data-button-to-replace'));
2801
+ const handleContainerMousedown = domCache => {
2802
+ domCache.container.onmousedown = () => {
2803
+ domCache.popup.onmouseup = function (e) {
2804
+ domCache.popup.onmouseup = undefined; // We also need to check if the mouseup target is a child of the popup
2797
2805
 
2798
- if (buttonToReplace.length) {
2799
- show(buttonToReplace[0], 'inline-block');
2800
- } else if (allButtonsAreHidden()) {
2801
- hide(domCache.actions);
2802
- }
2806
+ if (e.target === domCache.popup || domCache.popup.contains(e.target)) {
2807
+ ignoreOutsideClick = true;
2808
+ }
2809
+ };
2810
+ };
2803
2811
  };
2804
2812
 
2805
- /**
2806
- * Gets the input DOM node, this method works with input parameter.
2807
- * @returns {HTMLElement | null}
2808
- */
2809
-
2810
- function getInput$1(instance) {
2811
- const innerParams = privateProps.innerParams.get(instance || this);
2812
- const domCache = privateProps.domCache.get(instance || this);
2813
+ const handleModalClick = (instance, domCache, dismissWith) => {
2814
+ domCache.container.onclick = e => {
2815
+ const innerParams = privateProps.innerParams.get(instance);
2813
2816
 
2814
- if (!domCache) {
2815
- return null;
2816
- }
2817
+ if (ignoreOutsideClick) {
2818
+ ignoreOutsideClick = false;
2819
+ return;
2820
+ }
2817
2821
 
2818
- return getInput(domCache.popup, innerParams.input);
2819
- }
2822
+ if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
2823
+ dismissWith(DismissReason.backdrop);
2824
+ }
2825
+ };
2826
+ };
2820
2827
 
2821
- /**
2822
- * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
2823
- * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
2824
- * This is the approach that Babel will probably take to implement private methods/fields
2825
- * https://github.com/tc39/proposal-private-methods
2826
- * https://github.com/babel/babel/pull/7555
2827
- * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
2828
- * then we can use that language feature.
2828
+ /*
2829
+ * Global function to determine if SweetAlert2 popup is shown
2829
2830
  */
2830
- var privateMethods = {
2831
- swalPromiseResolve: new WeakMap(),
2832
- swalPromiseReject: new WeakMap()
2831
+
2832
+ const isVisible$1 = () => {
2833
+ return isVisible(getPopup());
2833
2834
  };
2835
+ /*
2836
+ * Global function to click 'Confirm' button
2837
+ */
2834
2838
 
2839
+ const clickConfirm = () => getConfirmButton() && getConfirmButton().click();
2835
2840
  /*
2836
- * Instance method to close sweetAlert
2841
+ * Global function to click 'Deny' button
2837
2842
  */
2838
2843
 
2839
- function removePopupAndResetState(instance, container, returnFocus, didClose) {
2840
- if (isToast()) {
2841
- triggerDidCloseAndDispose(instance, didClose);
2842
- } else {
2843
- restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
2844
+ const clickDeny = () => getDenyButton() && getDenyButton().click();
2845
+ /*
2846
+ * Global function to click 'Cancel' button
2847
+ */
2848
+
2849
+ const clickCancel = () => getCancelButton() && getCancelButton().click();
2850
+
2851
+ const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
2852
+ if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
2844
2853
  globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
2845
2854
  capture: globalState.keydownListenerCapture
2846
2855
  });
2847
2856
  globalState.keydownHandlerAdded = false;
2848
2857
  }
2849
2858
 
2850
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // workaround for #2088
2851
- // for some reason removing the container in Safari will scroll the document to bottom
2859
+ if (!innerParams.toast) {
2860
+ globalState.keydownHandler = e => keydownHandler(instance, e, dismissWith);
2852
2861
 
2853
- if (isSafari) {
2854
- container.setAttribute('style', 'display:none !important');
2855
- container.removeAttribute('class');
2856
- container.innerHTML = '';
2857
- } else {
2858
- container.remove();
2862
+ globalState.keydownTarget = innerParams.keydownListenerCapture ? window : getPopup();
2863
+ globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
2864
+ globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
2865
+ capture: globalState.keydownListenerCapture
2866
+ });
2867
+ globalState.keydownHandlerAdded = true;
2859
2868
  }
2869
+ }; // Focus handling
2860
2870
 
2861
- if (isModal()) {
2862
- undoScrollbar();
2863
- undoIOSfix();
2864
- unsetAriaHidden();
2865
- }
2866
-
2867
- removeBodyClasses();
2868
- }
2869
-
2870
- function removeBodyClasses() {
2871
- removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
2872
- }
2871
+ const setFocus = (innerParams, index, increment) => {
2872
+ const focusableElements = getFocusableElements(); // search for visible elements and select the next possible match
2873
2873
 
2874
- function close(resolveValue) {
2875
- resolveValue = prepareResolveValue(resolveValue);
2876
- const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
2877
- const didClose = triggerClosePopup(this);
2874
+ if (focusableElements.length) {
2875
+ index = index + increment; // rollover to first item
2878
2876
 
2879
- if (this.isAwaitingPromise()) {
2880
- // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
2881
- if (!resolveValue.isDismissed) {
2882
- handleAwaitingPromise(this);
2883
- swalPromiseResolve(resolveValue);
2877
+ if (index === focusableElements.length) {
2878
+ index = 0; // go to last item
2879
+ } else if (index === -1) {
2880
+ index = focusableElements.length - 1;
2884
2881
  }
2885
- } else if (didClose) {
2886
- // Resolve Swal promise
2887
- swalPromiseResolve(resolveValue);
2888
- }
2889
- }
2890
- function isAwaitingPromise() {
2891
- return !!privateProps.awaitingPromise.get(this);
2892
- }
2893
2882
 
2894
- const triggerClosePopup = instance => {
2895
- const popup = getPopup();
2883
+ return focusableElements[index].focus();
2884
+ } // no visible focusable elements, focus the popup
2896
2885
 
2897
- if (!popup) {
2898
- return false;
2899
- }
2900
2886
 
2901
- const innerParams = privateProps.innerParams.get(instance);
2887
+ getPopup().focus();
2888
+ };
2889
+ const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
2890
+ const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
2902
2891
 
2903
- if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
2904
- return false;
2905
- }
2892
+ const keydownHandler = (instance, e, dismissWith) => {
2893
+ const innerParams = privateProps.innerParams.get(instance);
2906
2894
 
2907
- removeClass(popup, innerParams.showClass.popup);
2908
- addClass(popup, innerParams.hideClass.popup);
2909
- const backdrop = getContainer();
2910
- removeClass(backdrop, innerParams.showClass.backdrop);
2911
- addClass(backdrop, innerParams.hideClass.backdrop);
2912
- handlePopupAnimation(instance, popup, innerParams);
2913
- return true;
2914
- };
2895
+ if (!innerParams) {
2896
+ return; // This instance has already been destroyed
2897
+ } // Ignore keydown during IME composition
2898
+ // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
2899
+ // https://github.com/sweetalert2/sweetalert2/issues/720
2900
+ // https://github.com/sweetalert2/sweetalert2/issues/2406
2915
2901
 
2916
- function rejectPromise(error) {
2917
- const rejectPromise = privateMethods.swalPromiseReject.get(this);
2918
- handleAwaitingPromise(this);
2919
2902
 
2920
- if (rejectPromise) {
2921
- // Reject Swal promise
2922
- rejectPromise(error);
2903
+ if (e.isComposing || e.keyCode === 229) {
2904
+ return;
2923
2905
  }
2924
- }
2925
2906
 
2926
- const handleAwaitingPromise = instance => {
2927
- if (instance.isAwaitingPromise()) {
2928
- privateProps.awaitingPromise.delete(instance); // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
2907
+ if (innerParams.stopKeydownPropagation) {
2908
+ e.stopPropagation();
2909
+ } // ENTER
2929
2910
 
2930
- if (!privateProps.innerParams.get(instance)) {
2931
- instance._destroy();
2932
- }
2911
+
2912
+ if (e.key === 'Enter') {
2913
+ handleEnter(instance, e, innerParams);
2914
+ } // TAB
2915
+ else if (e.key === 'Tab') {
2916
+ handleTab(e, innerParams);
2917
+ } // ARROWS - switch focus between buttons
2918
+ else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)) {
2919
+ handleArrows(e.key);
2920
+ } // ESC
2921
+ else if (e.key === 'Escape') {
2922
+ handleEsc(e, innerParams, dismissWith);
2933
2923
  }
2934
2924
  };
2935
2925
 
2936
- const prepareResolveValue = resolveValue => {
2937
- // When user calls Swal.close()
2938
- if (typeof resolveValue === 'undefined') {
2939
- return {
2940
- isConfirmed: false,
2941
- isDenied: false,
2942
- isDismissed: true
2943
- };
2926
+ const handleEnter = (instance, e, innerParams) => {
2927
+ // https://github.com/sweetalert2/sweetalert2/issues/2386
2928
+ if (!callIfFunction(innerParams.allowEnterKey)) {
2929
+ return;
2944
2930
  }
2945
2931
 
2946
- return Object.assign({
2947
- isConfirmed: false,
2948
- isDenied: false,
2949
- isDismissed: false
2950
- }, resolveValue);
2932
+ if (e.target && instance.getInput() && e.target.outerHTML === instance.getInput().outerHTML) {
2933
+ if (['textarea', 'file'].includes(innerParams.input)) {
2934
+ return; // do not submit
2935
+ }
2936
+
2937
+ clickConfirm();
2938
+ e.preventDefault();
2939
+ }
2951
2940
  };
2952
2941
 
2953
- const handlePopupAnimation = (instance, popup, innerParams) => {
2954
- const container = getContainer(); // If animation is supported, animate
2942
+ const handleTab = (e, innerParams) => {
2943
+ const targetElement = e.target;
2944
+ const focusableElements = getFocusableElements();
2945
+ let btnIndex = -1;
2955
2946
 
2956
- const animationIsSupported = animationEndEvent && hasCssAnimation(popup);
2947
+ for (let i = 0; i < focusableElements.length; i++) {
2948
+ if (targetElement === focusableElements[i]) {
2949
+ btnIndex = i;
2950
+ break;
2951
+ }
2952
+ } // Cycle to the next button
2957
2953
 
2958
- if (typeof innerParams.willClose === 'function') {
2959
- innerParams.willClose(popup);
2960
- }
2961
2954
 
2962
- if (animationIsSupported) {
2963
- animatePopup(instance, popup, container, innerParams.returnFocus, innerParams.didClose);
2964
- } else {
2965
- // Otherwise, remove immediately
2966
- removePopupAndResetState(instance, container, innerParams.returnFocus, innerParams.didClose);
2955
+ if (!e.shiftKey) {
2956
+ setFocus(innerParams, btnIndex, 1);
2957
+ } // Cycle to the prev button
2958
+ else {
2959
+ setFocus(innerParams, btnIndex, -1);
2967
2960
  }
2968
- };
2969
2961
 
2970
- const animatePopup = (instance, popup, container, returnFocus, didClose) => {
2971
- globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
2972
- popup.addEventListener(animationEndEvent, function (e) {
2973
- if (e.target === popup) {
2974
- globalState.swalCloseEventFinishedCallback();
2975
- delete globalState.swalCloseEventFinishedCallback;
2976
- }
2977
- });
2962
+ e.stopPropagation();
2963
+ e.preventDefault();
2978
2964
  };
2979
2965
 
2980
- const triggerDidCloseAndDispose = (instance, didClose) => {
2981
- setTimeout(() => {
2982
- if (typeof didClose === 'function') {
2983
- didClose.bind(instance.params)();
2984
- }
2966
+ const handleArrows = key => {
2967
+ const confirmButton = getConfirmButton();
2968
+ const denyButton = getDenyButton();
2969
+ const cancelButton = getCancelButton();
2985
2970
 
2986
- instance._destroy();
2987
- });
2988
- };
2971
+ if (![confirmButton, denyButton, cancelButton].includes(document.activeElement)) {
2972
+ return;
2973
+ }
2989
2974
 
2990
- function setButtonsDisabled(instance, buttons, disabled) {
2991
- const domCache = privateProps.domCache.get(instance);
2992
- buttons.forEach(button => {
2993
- domCache[button].disabled = disabled;
2994
- });
2995
- }
2975
+ const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
2976
+ let buttonToFocus = document.activeElement;
2996
2977
 
2997
- function setInputDisabled(input, disabled) {
2998
- if (!input) {
2999
- return false;
3000
- }
2978
+ for (let i = 0; i < getActions().children.length; i++) {
2979
+ buttonToFocus = buttonToFocus[sibling];
3001
2980
 
3002
- if (input.type === 'radio') {
3003
- const radiosContainer = input.parentNode.parentNode;
3004
- const radios = radiosContainer.querySelectorAll('input');
2981
+ if (!buttonToFocus) {
2982
+ return;
2983
+ }
3005
2984
 
3006
- for (let i = 0; i < radios.length; i++) {
3007
- radios[i].disabled = disabled;
2985
+ if (isVisible(buttonToFocus) && buttonToFocus instanceof HTMLButtonElement) {
2986
+ break;
3008
2987
  }
3009
- } else {
3010
- input.disabled = disabled;
3011
2988
  }
3012
- }
3013
2989
 
3014
- function enableButtons() {
3015
- setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
3016
- }
3017
- function disableButtons() {
3018
- setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
3019
- }
3020
- function enableInput() {
3021
- return setInputDisabled(this.getInput(), false);
3022
- }
3023
- function disableInput() {
3024
- return setInputDisabled(this.getInput(), true);
3025
- }
3026
-
3027
- function showValidationMessage(error) {
3028
- const domCache = privateProps.domCache.get(this);
3029
- const params = privateProps.innerParams.get(this);
3030
- setInnerHtml(domCache.validationMessage, error);
3031
- domCache.validationMessage.className = swalClasses['validation-message'];
2990
+ if (buttonToFocus instanceof HTMLButtonElement) {
2991
+ buttonToFocus.focus();
2992
+ }
2993
+ };
3032
2994
 
3033
- if (params.customClass && params.customClass.validationMessage) {
3034
- addClass(domCache.validationMessage, params.customClass.validationMessage);
2995
+ const handleEsc = (e, innerParams, dismissWith) => {
2996
+ if (callIfFunction(innerParams.allowEscapeKey)) {
2997
+ e.preventDefault();
2998
+ dismissWith(DismissReason.esc);
3035
2999
  }
3000
+ };
3036
3001
 
3037
- show(domCache.validationMessage);
3038
- const input = this.getInput();
3002
+ const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
3039
3003
 
3040
- if (input) {
3041
- input.setAttribute('aria-invalid', true);
3042
- input.setAttribute('aria-describedby', swalClasses['validation-message']);
3043
- focusInput(input);
3044
- addClass(input, swalClasses.inputerror);
3045
- }
3046
- } // Hide block with validation message
3004
+ const isElement = elem => elem instanceof Element || isJqueryElement(elem);
3047
3005
 
3048
- function resetValidationMessage$1() {
3049
- const domCache = privateProps.domCache.get(this);
3006
+ const argsToParams = args => {
3007
+ const params = {};
3050
3008
 
3051
- if (domCache.validationMessage) {
3052
- hide(domCache.validationMessage);
3009
+ if (typeof args[0] === 'object' && !isElement(args[0])) {
3010
+ Object.assign(params, args[0]);
3011
+ } else {
3012
+ ['title', 'html', 'icon'].forEach((name, index) => {
3013
+ const arg = args[index];
3014
+
3015
+ if (typeof arg === 'string' || isElement(arg)) {
3016
+ params[name] = arg;
3017
+ } else if (arg !== undefined) {
3018
+ error("Unexpected type of ".concat(name, "! Expected \"string\" or \"Element\", got ").concat(typeof arg));
3019
+ }
3020
+ });
3053
3021
  }
3054
3022
 
3055
- const input = this.getInput();
3023
+ return params;
3024
+ };
3056
3025
 
3057
- if (input) {
3058
- input.removeAttribute('aria-invalid');
3059
- input.removeAttribute('aria-describedby');
3060
- removeClass(input, swalClasses.inputerror);
3026
+ function fire() {
3027
+ const Swal = this; // eslint-disable-line @typescript-eslint/no-this-alias
3028
+
3029
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3030
+ args[_key] = arguments[_key];
3061
3031
  }
3062
- }
3063
3032
 
3064
- function getProgressSteps$1() {
3065
- const domCache = privateProps.domCache.get(this);
3066
- return domCache.progressSteps;
3033
+ return new Swal(...args);
3067
3034
  }
3068
3035
 
3069
3036
  /**
3070
- * Updates popup parameters.
3037
+ * Returns an extended version of `Swal` containing `params` as defaults.
3038
+ * Useful for reusing Swal configuration.
3039
+ *
3040
+ * For example:
3041
+ *
3042
+ * Before:
3043
+ * const textPromptOptions = { input: 'text', showCancelButton: true }
3044
+ * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
3045
+ * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
3046
+ *
3047
+ * After:
3048
+ * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
3049
+ * const {value: firstName} = await TextPrompt('What is your first name?')
3050
+ * const {value: lastName} = await TextPrompt('What is your last name?')
3051
+ *
3052
+ * @param mixinParams
3071
3053
  */
3054
+ function mixin(mixinParams) {
3055
+ class MixinSwal extends this {
3056
+ _main(params, priorityMixinParams) {
3057
+ return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
3058
+ }
3072
3059
 
3073
- function update(params) {
3074
- const popup = getPopup();
3075
- const innerParams = privateProps.innerParams.get(this);
3076
-
3077
- if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
3078
- 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.");
3079
3060
  }
3080
3061
 
3081
- const validUpdatableParams = filterValidParams(params);
3082
- const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
3083
- render(this, updatedParams);
3084
- privateProps.innerParams.set(this, updatedParams);
3085
- Object.defineProperties(this, {
3086
- params: {
3087
- value: Object.assign({}, this.params, params),
3088
- writable: false,
3089
- enumerable: true
3090
- }
3091
- });
3062
+ return MixinSwal;
3092
3063
  }
3093
3064
 
3094
- const filterValidParams = params => {
3095
- const validUpdatableParams = {};
3096
- Object.keys(params).forEach(param => {
3097
- if (isUpdatableParameter(param)) {
3098
- validUpdatableParams[param] = params[param];
3099
- } else {
3100
- 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"));
3101
- }
3102
- });
3103
- return validUpdatableParams;
3104
- };
3105
-
3106
- function _destroy() {
3107
- const domCache = privateProps.domCache.get(this);
3108
- const innerParams = privateProps.innerParams.get(this);
3109
-
3110
- if (!innerParams) {
3111
- disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
3112
-
3113
- return; // This instance has already been destroyed
3114
- } // Check if there is another Swal closing
3115
-
3116
-
3117
- if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
3118
- globalState.swalCloseEventFinishedCallback();
3119
- delete globalState.swalCloseEventFinishedCallback;
3120
- } // Check if there is a swal disposal defer timer
3065
+ /**
3066
+ * If `timer` parameter is set, returns number of milliseconds of timer remained.
3067
+ * Otherwise, returns undefined.
3068
+ */
3121
3069
 
3070
+ const getTimerLeft = () => {
3071
+ return globalState.timeout && globalState.timeout.getTimerLeft();
3072
+ };
3073
+ /**
3074
+ * Stop timer. Returns number of milliseconds of timer remained.
3075
+ * If `timer` parameter isn't set, returns undefined.
3076
+ */
3122
3077
 
3123
- if (globalState.deferDisposalTimer) {
3124
- clearTimeout(globalState.deferDisposalTimer);
3125
- delete globalState.deferDisposalTimer;
3078
+ const stopTimer = () => {
3079
+ if (globalState.timeout) {
3080
+ stopTimerProgressBar();
3081
+ return globalState.timeout.stop();
3126
3082
  }
3083
+ };
3084
+ /**
3085
+ * Resume timer. Returns number of milliseconds of timer remained.
3086
+ * If `timer` parameter isn't set, returns undefined.
3087
+ */
3127
3088
 
3128
- if (typeof innerParams.didDestroy === 'function') {
3129
- innerParams.didDestroy();
3089
+ const resumeTimer = () => {
3090
+ if (globalState.timeout) {
3091
+ const remaining = globalState.timeout.start();
3092
+ animateTimerProgressBar(remaining);
3093
+ return remaining;
3130
3094
  }
3095
+ };
3096
+ /**
3097
+ * Resume timer. Returns number of milliseconds of timer remained.
3098
+ * If `timer` parameter isn't set, returns undefined.
3099
+ */
3131
3100
 
3132
- disposeSwal(this);
3133
- }
3134
-
3135
- const disposeSwal = instance => {
3136
- disposeWeakMaps(instance); // Unset this.params so GC will dispose it (#1569)
3137
-
3138
- delete instance.params; // Unset globalState props so GC will dispose globalState (#1569)
3101
+ const toggleTimer = () => {
3102
+ const timer = globalState.timeout;
3103
+ return timer && (timer.running ? stopTimer() : resumeTimer());
3104
+ };
3105
+ /**
3106
+ * Increase timer. Returns number of milliseconds of an updated timer.
3107
+ * If `timer` parameter isn't set, returns undefined.
3108
+ */
3139
3109
 
3140
- delete globalState.keydownHandler;
3141
- delete globalState.keydownTarget; // Unset currentInstance
3110
+ const increaseTimer = n => {
3111
+ if (globalState.timeout) {
3112
+ const remaining = globalState.timeout.increase(n);
3113
+ animateTimerProgressBar(remaining, true);
3114
+ return remaining;
3115
+ }
3116
+ };
3117
+ /**
3118
+ * Check if timer is running. Returns true if timer is running
3119
+ * or false if timer is paused or stopped.
3120
+ * If `timer` parameter isn't set, returns undefined
3121
+ */
3142
3122
 
3143
- delete globalState.currentInstance;
3123
+ const isTimerRunning = () => {
3124
+ return globalState.timeout && globalState.timeout.isRunning();
3144
3125
  };
3145
3126
 
3146
- const disposeWeakMaps = instance => {
3147
- // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
3148
- if (instance.isAwaitingPromise()) {
3149
- unsetWeakMaps(privateProps, instance);
3150
- privateProps.awaitingPromise.set(instance, true);
3151
- } else {
3152
- unsetWeakMaps(privateMethods, instance);
3153
- unsetWeakMaps(privateProps, instance);
3127
+ let bodyClickListenerAdded = false;
3128
+ const clickHandlers = {};
3129
+ function bindClickHandler() {
3130
+ let attr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'data-swal-template';
3131
+ clickHandlers[attr] = this;
3132
+
3133
+ if (!bodyClickListenerAdded) {
3134
+ document.body.addEventListener('click', bodyClickListener);
3135
+ bodyClickListenerAdded = true;
3154
3136
  }
3155
- };
3137
+ }
3156
3138
 
3157
- const unsetWeakMaps = (obj, instance) => {
3158
- for (const i in obj) {
3159
- obj[i].delete(instance);
3139
+ const bodyClickListener = event => {
3140
+ for (let el = event.target; el && el !== document; el = el.parentNode) {
3141
+ for (const attr in clickHandlers) {
3142
+ const template = el.getAttribute(attr);
3143
+
3144
+ if (template) {
3145
+ clickHandlers[attr].fire({
3146
+ template
3147
+ });
3148
+ return;
3149
+ }
3150
+ }
3160
3151
  }
3161
3152
  };
3162
3153
 
3163
3154
 
3164
3155
 
3165
- var instanceMethods = /*#__PURE__*/Object.freeze({
3166
- hideLoading: hideLoading,
3167
- disableLoading: hideLoading,
3168
- getInput: getInput$1,
3169
- close: close,
3170
- isAwaitingPromise: isAwaitingPromise,
3171
- rejectPromise: rejectPromise,
3172
- closePopup: close,
3173
- closeModal: close,
3174
- closeToast: close,
3175
- enableButtons: enableButtons,
3176
- disableButtons: disableButtons,
3177
- enableInput: enableInput,
3178
- disableInput: disableInput,
3179
- showValidationMessage: showValidationMessage,
3180
- resetValidationMessage: resetValidationMessage$1,
3181
- getProgressSteps: getProgressSteps$1,
3182
- update: update,
3183
- _destroy: _destroy
3156
+ var staticMethods = /*#__PURE__*/Object.freeze({
3157
+ isValidParameter: isValidParameter,
3158
+ isUpdatableParameter: isUpdatableParameter,
3159
+ isDeprecatedParameter: isDeprecatedParameter,
3160
+ argsToParams: argsToParams,
3161
+ isVisible: isVisible$1,
3162
+ clickConfirm: clickConfirm,
3163
+ clickDeny: clickDeny,
3164
+ clickCancel: clickCancel,
3165
+ getContainer: getContainer,
3166
+ getPopup: getPopup,
3167
+ getTitle: getTitle,
3168
+ getHtmlContainer: getHtmlContainer,
3169
+ getImage: getImage,
3170
+ getIcon: getIcon,
3171
+ getInputLabel: getInputLabel,
3172
+ getCloseButton: getCloseButton,
3173
+ getActions: getActions,
3174
+ getConfirmButton: getConfirmButton,
3175
+ getDenyButton: getDenyButton,
3176
+ getCancelButton: getCancelButton,
3177
+ getLoader: getLoader,
3178
+ getFooter: getFooter,
3179
+ getTimerProgressBar: getTimerProgressBar,
3180
+ getFocusableElements: getFocusableElements,
3181
+ getValidationMessage: getValidationMessage,
3182
+ isLoading: isLoading,
3183
+ fire: fire,
3184
+ mixin: mixin,
3185
+ showLoading: showLoading,
3186
+ enableLoading: showLoading,
3187
+ getTimerLeft: getTimerLeft,
3188
+ stopTimer: stopTimer,
3189
+ resumeTimer: resumeTimer,
3190
+ toggleTimer: toggleTimer,
3191
+ increaseTimer: increaseTimer,
3192
+ isTimerRunning: isTimerRunning,
3193
+ bindClickHandler: bindClickHandler
3184
3194
  });
3185
3195
 
3186
3196
  let currentInstance;
@@ -3391,7 +3401,7 @@
3391
3401
  };
3392
3402
  });
3393
3403
  SweetAlert.DismissReason = DismissReason;
3394
- SweetAlert.version = '11.4.2';
3404
+ SweetAlert.version = '11.4.5';
3395
3405
 
3396
3406
  const Swal = SweetAlert; // @ts-ignore
3397
3407