sweetalert2 11.26.22 → 11.26.24
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/dist/sweetalert2.all.js +67 -94
- package/dist/sweetalert2.all.min.js +2 -2
- package/dist/sweetalert2.esm.all.js +67 -94
- package/dist/sweetalert2.esm.all.min.js +2 -2
- package/dist/sweetalert2.esm.js +67 -94
- package/dist/sweetalert2.esm.min.js +2 -2
- package/dist/sweetalert2.js +67 -94
- package/dist/sweetalert2.min.js +2 -2
- package/package.json +6 -17
- package/src/SweetAlert.js +2 -1
- package/src/keydown-handler.js +24 -6
- package/src/types.js +2 -0
- package/src/utils/dom/domUtils.js +10 -18
- package/src/utils/dom/inputUtils.js +8 -23
- package/src/utils/dom/renderers/renderActions.js +13 -15
- package/src/utils/dom/renderers/renderInput.js +2 -0
- package/src/utils/draggable.js +4 -10
- package/src/utils/getTemplateParams.js +15 -22
- package/src/utils/utils.js +5 -0
- package/sweetalert2.d.ts +1 -1
package/dist/sweetalert2.all.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sweetalert2 v11.26.
|
|
2
|
+
* sweetalert2 v11.26.24
|
|
3
3
|
* Released under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -170,6 +170,11 @@
|
|
|
170
170
|
*/
|
|
171
171
|
const isPromise = arg => arg && Promise.resolve(arg) === arg;
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* @returns {boolean}
|
|
175
|
+
*/
|
|
176
|
+
const isFirefox = () => navigator.userAgent.includes('Firefox');
|
|
177
|
+
|
|
173
178
|
/**
|
|
174
179
|
* Gets the popup container which contains the backdrop and the popup itself.
|
|
175
180
|
*
|
|
@@ -485,25 +490,16 @@
|
|
|
485
490
|
if (!target || !classList) {
|
|
486
491
|
return;
|
|
487
492
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (Array.isArray(target)) {
|
|
493
|
-
target.forEach(elem => {
|
|
494
|
-
if (condition) {
|
|
495
|
-
elem.classList.add(className);
|
|
496
|
-
} else {
|
|
497
|
-
elem.classList.remove(className);
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
} else {
|
|
493
|
+
const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
|
|
494
|
+
const targets = Array.isArray(target) ? target : [target];
|
|
495
|
+
targets.forEach(elem => {
|
|
496
|
+
classes.forEach(className => {
|
|
501
497
|
if (condition) {
|
|
502
|
-
|
|
498
|
+
elem.classList.add(className);
|
|
503
499
|
} else {
|
|
504
|
-
|
|
500
|
+
elem.classList.remove(className);
|
|
505
501
|
}
|
|
506
|
-
}
|
|
502
|
+
});
|
|
507
503
|
});
|
|
508
504
|
};
|
|
509
505
|
|
|
@@ -549,7 +545,7 @@
|
|
|
549
545
|
if (value === `${parseInt(`${value}`)}`) {
|
|
550
546
|
value = parseInt(value);
|
|
551
547
|
}
|
|
552
|
-
if (value ||
|
|
548
|
+
if (value || value === 0) {
|
|
553
549
|
elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
|
|
554
550
|
} else {
|
|
555
551
|
elem.style.removeProperty(property);
|
|
@@ -998,21 +994,15 @@
|
|
|
998
994
|
}
|
|
999
995
|
addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
|
|
1000
996
|
|
|
1001
|
-
// Apply custom background colors to action buttons
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// Apply the outline color to action buttons
|
|
1013
|
-
applyOutlineColor(confirmButton);
|
|
1014
|
-
applyOutlineColor(denyButton);
|
|
1015
|
-
applyOutlineColor(cancelButton);
|
|
997
|
+
// Apply custom background colors and outline colors to action buttons
|
|
998
|
+
/** @type {[HTMLElement, string, string | undefined][]} */
|
|
999
|
+
const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
|
|
1000
|
+
buttons.forEach(([button, type, color]) => {
|
|
1001
|
+
if (color) {
|
|
1002
|
+
button.style.setProperty(`--swal2-${type}-button-background-color`, color);
|
|
1003
|
+
}
|
|
1004
|
+
applyOutlineColor(button);
|
|
1005
|
+
});
|
|
1016
1006
|
}
|
|
1017
1007
|
|
|
1018
1008
|
/**
|
|
@@ -1307,10 +1297,12 @@
|
|
|
1307
1297
|
*/
|
|
1308
1298
|
renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType['datetime-local'] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
|
|
1309
1299
|
(input, params) => {
|
|
1300
|
+
// oxfmt-ignore
|
|
1310
1301
|
const inputElement = /** @type {HTMLInputElement} */input;
|
|
1311
1302
|
checkAndSetInputValue(inputElement, params.inputValue);
|
|
1312
1303
|
setInputLabel(inputElement, inputElement, params);
|
|
1313
1304
|
setInputPlaceholder(inputElement, params);
|
|
1305
|
+
// oxfmt-ignore
|
|
1314
1306
|
inputElement.type = /** @type {string} */params.input;
|
|
1315
1307
|
return inputElement;
|
|
1316
1308
|
};
|
|
@@ -1760,18 +1752,10 @@
|
|
|
1760
1752
|
* @returns {{ clientX: number, clientY: number }}
|
|
1761
1753
|
*/
|
|
1762
1754
|
const getClientXY = event => {
|
|
1763
|
-
|
|
1764
|
-
clientY = 0;
|
|
1765
|
-
if (event.type.startsWith('mouse')) {
|
|
1766
|
-
clientX = /** @type {MouseEvent} */event.clientX;
|
|
1767
|
-
clientY = /** @type {MouseEvent} */event.clientY;
|
|
1768
|
-
} else if (event.type.startsWith('touch')) {
|
|
1769
|
-
clientX = /** @type {TouchEvent} */event.touches[0].clientX;
|
|
1770
|
-
clientY = /** @type {TouchEvent} */event.touches[0].clientY;
|
|
1771
|
-
}
|
|
1755
|
+
const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
|
|
1772
1756
|
return {
|
|
1773
|
-
clientX,
|
|
1774
|
-
clientY
|
|
1757
|
+
clientX: source.clientX,
|
|
1758
|
+
clientY: source.clientY
|
|
1775
1759
|
};
|
|
1776
1760
|
};
|
|
1777
1761
|
|
|
@@ -2001,7 +1985,8 @@
|
|
|
2001
1985
|
*/
|
|
2002
1986
|
const removeKeydownHandler = globalState => {
|
|
2003
1987
|
if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
|
|
2004
|
-
const handler = /** @type {EventListenerOrEventListenerObject} */
|
|
1988
|
+
const handler = /** @type {EventListenerOrEventListenerObject} */
|
|
1989
|
+
/** @type {unknown} */globalState.keydownHandler;
|
|
2005
1990
|
globalState.keydownTarget.removeEventListener('keydown', handler, {
|
|
2006
1991
|
capture: globalState.keydownListenerCapture
|
|
2007
1992
|
});
|
|
@@ -2036,6 +2021,7 @@
|
|
|
2036
2021
|
/**
|
|
2037
2022
|
* @param {number} index
|
|
2038
2023
|
* @param {number} increment
|
|
2024
|
+
* @returns {boolean} shouldPreventDefault
|
|
2039
2025
|
*/
|
|
2040
2026
|
const setFocus = (index, increment) => {
|
|
2041
2027
|
var _dom$getPopup;
|
|
@@ -2058,10 +2044,17 @@
|
|
|
2058
2044
|
index = focusableElements.length - 1;
|
|
2059
2045
|
}
|
|
2060
2046
|
focusableElements[index].focus();
|
|
2061
|
-
|
|
2047
|
+
|
|
2048
|
+
// don't prevent default for iframes (Firefox fix)
|
|
2049
|
+
// https://github.com/sweetalert2/sweetalert2/issues/2931
|
|
2050
|
+
if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
|
|
2051
|
+
return false;
|
|
2052
|
+
}
|
|
2053
|
+
return true;
|
|
2062
2054
|
}
|
|
2063
2055
|
// no visible focusable elements, focus the popup
|
|
2064
2056
|
(_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
|
|
2057
|
+
return true;
|
|
2065
2058
|
};
|
|
2066
2059
|
const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
|
|
2067
2060
|
const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
|
|
@@ -2145,17 +2138,23 @@
|
|
|
2145
2138
|
}
|
|
2146
2139
|
}
|
|
2147
2140
|
|
|
2141
|
+
// don't prevent default for iframes (Firefox fix)
|
|
2142
|
+
// https://github.com/sweetalert2/sweetalert2/issues/2931
|
|
2143
|
+
let shouldPreventDefault = true;
|
|
2144
|
+
|
|
2148
2145
|
// Cycle to the next button
|
|
2149
2146
|
if (!event.shiftKey) {
|
|
2150
|
-
setFocus(btnIndex, 1);
|
|
2147
|
+
shouldPreventDefault = setFocus(btnIndex, 1);
|
|
2151
2148
|
}
|
|
2152
2149
|
|
|
2153
2150
|
// Cycle to the prev button
|
|
2154
2151
|
else {
|
|
2155
|
-
setFocus(btnIndex, -1);
|
|
2152
|
+
shouldPreventDefault = setFocus(btnIndex, -1);
|
|
2156
2153
|
}
|
|
2157
2154
|
event.stopPropagation();
|
|
2158
|
-
|
|
2155
|
+
if (shouldPreventDefault) {
|
|
2156
|
+
event.preventDefault();
|
|
2157
|
+
}
|
|
2159
2158
|
};
|
|
2160
2159
|
|
|
2161
2160
|
/**
|
|
@@ -2839,28 +2838,8 @@
|
|
|
2839
2838
|
* @returns {InputOptionFlattened[]}
|
|
2840
2839
|
*/
|
|
2841
2840
|
const formatInputOptions = inputOptions => {
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
if (inputOptions instanceof Map) {
|
|
2845
|
-
inputOptions.forEach((value, key) => {
|
|
2846
|
-
let valueFormatted = value;
|
|
2847
|
-
if (typeof valueFormatted === 'object') {
|
|
2848
|
-
// case of <optgroup>
|
|
2849
|
-
valueFormatted = formatInputOptions(valueFormatted);
|
|
2850
|
-
}
|
|
2851
|
-
result.push([key, valueFormatted]);
|
|
2852
|
-
});
|
|
2853
|
-
} else {
|
|
2854
|
-
Object.keys(inputOptions).forEach(key => {
|
|
2855
|
-
let valueFormatted = inputOptions[key];
|
|
2856
|
-
if (typeof valueFormatted === 'object') {
|
|
2857
|
-
// case of <optgroup>
|
|
2858
|
-
valueFormatted = formatInputOptions(valueFormatted);
|
|
2859
|
-
}
|
|
2860
|
-
result.push([key, valueFormatted]);
|
|
2861
|
-
});
|
|
2862
|
-
}
|
|
2863
|
-
return result;
|
|
2841
|
+
const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
|
|
2842
|
+
return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
|
|
2864
2843
|
};
|
|
2865
2844
|
|
|
2866
2845
|
/**
|
|
@@ -4173,17 +4152,13 @@
|
|
|
4173
4152
|
}
|
|
4174
4153
|
result[`${type}ButtonText`] = button.innerHTML;
|
|
4175
4154
|
result[`show${capitalizeFirstLetter(type)}Button`] = true;
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
result[`${type}ButtonColor`] = color;
|
|
4180
|
-
}
|
|
4155
|
+
const color = button.getAttribute('color');
|
|
4156
|
+
if (color !== null) {
|
|
4157
|
+
result[`${type}ButtonColor`] = color;
|
|
4181
4158
|
}
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
result[`${type}ButtonAriaLabel`] = ariaLabel;
|
|
4186
|
-
}
|
|
4159
|
+
const ariaLabel = button.getAttribute('aria-label');
|
|
4160
|
+
if (ariaLabel !== null) {
|
|
4161
|
+
result[`${type}ButtonAriaLabel`] = ariaLabel;
|
|
4187
4162
|
}
|
|
4188
4163
|
});
|
|
4189
4164
|
return result;
|
|
@@ -4199,18 +4174,15 @@
|
|
|
4199
4174
|
const image = templateContent.querySelector('swal-image');
|
|
4200
4175
|
if (image) {
|
|
4201
4176
|
showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
|
|
4202
|
-
if
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
if (
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
if (image.hasAttribute('alt')) {
|
|
4212
|
-
result.imageAlt = image.getAttribute('alt') || undefined;
|
|
4213
|
-
}
|
|
4177
|
+
// getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
|
|
4178
|
+
const src = image.getAttribute('src');
|
|
4179
|
+
if (src !== null) result.imageUrl = src || undefined;
|
|
4180
|
+
const width = image.getAttribute('width');
|
|
4181
|
+
if (width !== null) result.imageWidth = width || undefined;
|
|
4182
|
+
const height = image.getAttribute('height');
|
|
4183
|
+
if (height !== null) result.imageHeight = height || undefined;
|
|
4184
|
+
const alt = image.getAttribute('alt');
|
|
4185
|
+
if (alt !== null) result.imageAlt = alt || undefined;
|
|
4214
4186
|
}
|
|
4215
4187
|
return result;
|
|
4216
4188
|
};
|
|
@@ -4596,6 +4568,7 @@
|
|
|
4596
4568
|
/**
|
|
4597
4569
|
* @param {any} onFulfilled
|
|
4598
4570
|
*/
|
|
4571
|
+
// oxlint-disable-next-line unicorn/no-thenable
|
|
4599
4572
|
then(onFulfilled) {
|
|
4600
4573
|
return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
|
|
4601
4574
|
}
|
|
@@ -4828,7 +4801,7 @@
|
|
|
4828
4801
|
};
|
|
4829
4802
|
});
|
|
4830
4803
|
SweetAlert.DismissReason = DismissReason;
|
|
4831
|
-
SweetAlert.version = '11.26.
|
|
4804
|
+
SweetAlert.version = '11.26.24';
|
|
4832
4805
|
|
|
4833
4806
|
const Swal = SweetAlert;
|
|
4834
4807
|
// @ts-ignore
|