sweetalert2 11.26.12 → 11.26.14
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 +98 -61
- package/dist/sweetalert2.all.min.js +2 -2
- package/dist/sweetalert2.esm.all.js +98 -61
- package/dist/sweetalert2.esm.all.min.js +2 -2
- package/dist/sweetalert2.esm.js +98 -61
- package/dist/sweetalert2.esm.min.js +2 -2
- package/dist/sweetalert2.js +98 -61
- package/dist/sweetalert2.min.js +2 -2
- package/package.json +1 -1
- package/src/SweetAlert.js +1 -1
- package/src/utils/dom/inputUtils.js +1 -1
- package/src/utils/dom/parseHtmlToContainer.js +2 -2
- package/src/utils/dom/renderers/render.js +1 -1
- package/src/utils/dom/renderers/renderInput.js +80 -50
- package/src/utils/getTemplateParams.js +17 -5
package/dist/sweetalert2.all.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sweetalert2 v11.26.
|
|
2
|
+
* sweetalert2 v11.26.14
|
|
3
3
|
* Released under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -870,7 +870,7 @@
|
|
|
870
870
|
*/
|
|
871
871
|
const handleObject = (param, target) => {
|
|
872
872
|
// JQuery element(s)
|
|
873
|
-
if (param
|
|
873
|
+
if ('jquery' in param) {
|
|
874
874
|
handleJqueryElem(target, param);
|
|
875
875
|
}
|
|
876
876
|
|
|
@@ -882,7 +882,7 @@
|
|
|
882
882
|
|
|
883
883
|
/**
|
|
884
884
|
* @param {HTMLElement} target
|
|
885
|
-
* @param {
|
|
885
|
+
* @param {any} elem
|
|
886
886
|
*/
|
|
887
887
|
const handleJqueryElem = (target, elem) => {
|
|
888
888
|
target.textContent = '';
|
|
@@ -1269,96 +1269,119 @@
|
|
|
1269
1269
|
const renderInputType = {};
|
|
1270
1270
|
|
|
1271
1271
|
/**
|
|
1272
|
-
* @param {
|
|
1272
|
+
* @param {Input | HTMLElement} input
|
|
1273
1273
|
* @param {SweetAlertOptions} params
|
|
1274
|
-
* @returns {
|
|
1274
|
+
* @returns {Input}
|
|
1275
1275
|
*/
|
|
1276
1276
|
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} */
|
|
1277
1277
|
(input, params) => {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1278
|
+
const inputElement = /** @type {HTMLInputElement} */input;
|
|
1279
|
+
checkAndSetInputValue(inputElement, params.inputValue);
|
|
1280
|
+
setInputLabel(inputElement, inputElement, params);
|
|
1281
|
+
setInputPlaceholder(inputElement, params);
|
|
1282
|
+
inputElement.type = /** @type {string} */params.input;
|
|
1283
|
+
return inputElement;
|
|
1283
1284
|
};
|
|
1284
1285
|
|
|
1285
1286
|
/**
|
|
1286
|
-
* @param {
|
|
1287
|
+
* @param {Input | HTMLElement} input
|
|
1287
1288
|
* @param {SweetAlertOptions} params
|
|
1288
|
-
* @returns {
|
|
1289
|
+
* @returns {Input}
|
|
1289
1290
|
*/
|
|
1290
1291
|
renderInputType.file = (input, params) => {
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1292
|
+
const inputElement = /** @type {HTMLInputElement} */input;
|
|
1293
|
+
setInputLabel(inputElement, inputElement, params);
|
|
1294
|
+
setInputPlaceholder(inputElement, params);
|
|
1295
|
+
return inputElement;
|
|
1294
1296
|
};
|
|
1295
1297
|
|
|
1296
1298
|
/**
|
|
1297
|
-
* @param {
|
|
1299
|
+
* @param {Input | HTMLElement} range
|
|
1298
1300
|
* @param {SweetAlertOptions} params
|
|
1299
|
-
* @returns {
|
|
1301
|
+
* @returns {Input}
|
|
1300
1302
|
*/
|
|
1301
1303
|
renderInputType.range = (range, params) => {
|
|
1302
|
-
const
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
rangeInput
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1304
|
+
const rangeContainer = /** @type {HTMLElement} */range;
|
|
1305
|
+
const rangeInput = rangeContainer.querySelector('input');
|
|
1306
|
+
const rangeOutput = rangeContainer.querySelector('output');
|
|
1307
|
+
if (rangeInput) {
|
|
1308
|
+
checkAndSetInputValue(rangeInput, params.inputValue);
|
|
1309
|
+
rangeInput.type = /** @type {string} */params.input;
|
|
1310
|
+
setInputLabel(rangeInput, /** @type {Input} */range, params);
|
|
1311
|
+
}
|
|
1312
|
+
if (rangeOutput) {
|
|
1313
|
+
checkAndSetInputValue(rangeOutput, params.inputValue);
|
|
1314
|
+
}
|
|
1315
|
+
return /** @type {Input} */range;
|
|
1309
1316
|
};
|
|
1310
1317
|
|
|
1311
1318
|
/**
|
|
1312
|
-
* @param {
|
|
1319
|
+
* @param {Input | HTMLElement} select
|
|
1313
1320
|
* @param {SweetAlertOptions} params
|
|
1314
|
-
* @returns {
|
|
1321
|
+
* @returns {Input}
|
|
1315
1322
|
*/
|
|
1316
1323
|
renderInputType.select = (select, params) => {
|
|
1317
|
-
|
|
1324
|
+
const selectElement = /** @type {HTMLSelectElement} */select;
|
|
1325
|
+
selectElement.textContent = '';
|
|
1318
1326
|
if (params.inputPlaceholder) {
|
|
1319
1327
|
const placeholder = document.createElement('option');
|
|
1320
1328
|
setInnerHtml(placeholder, params.inputPlaceholder);
|
|
1321
1329
|
placeholder.value = '';
|
|
1322
1330
|
placeholder.disabled = true;
|
|
1323
1331
|
placeholder.selected = true;
|
|
1324
|
-
|
|
1332
|
+
selectElement.appendChild(placeholder);
|
|
1325
1333
|
}
|
|
1326
|
-
setInputLabel(
|
|
1327
|
-
return
|
|
1334
|
+
setInputLabel(selectElement, selectElement, params);
|
|
1335
|
+
return selectElement;
|
|
1328
1336
|
};
|
|
1329
1337
|
|
|
1330
1338
|
/**
|
|
1331
|
-
* @param {
|
|
1332
|
-
* @returns {
|
|
1339
|
+
* @param {Input | HTMLElement} radio
|
|
1340
|
+
* @returns {Input}
|
|
1333
1341
|
*/
|
|
1334
1342
|
renderInputType.radio = radio => {
|
|
1335
|
-
|
|
1336
|
-
|
|
1343
|
+
const radioElement = /** @type {HTMLElement} */radio;
|
|
1344
|
+
radioElement.textContent = '';
|
|
1345
|
+
return /** @type {Input} */radio;
|
|
1337
1346
|
};
|
|
1338
1347
|
|
|
1339
1348
|
/**
|
|
1340
|
-
* @param {
|
|
1349
|
+
* @param {Input | HTMLElement} checkboxContainer
|
|
1341
1350
|
* @param {SweetAlertOptions} params
|
|
1342
|
-
* @returns {
|
|
1351
|
+
* @returns {Input}
|
|
1343
1352
|
*/
|
|
1344
1353
|
renderInputType.checkbox = (checkboxContainer, params) => {
|
|
1345
|
-
const
|
|
1354
|
+
const popup = getPopup();
|
|
1355
|
+
if (!popup) {
|
|
1356
|
+
throw new Error('Popup not found');
|
|
1357
|
+
}
|
|
1358
|
+
const checkbox = getInput$1(popup, 'checkbox');
|
|
1359
|
+
if (!checkbox) {
|
|
1360
|
+
throw new Error('Checkbox input not found');
|
|
1361
|
+
}
|
|
1346
1362
|
checkbox.value = '1';
|
|
1347
1363
|
checkbox.checked = Boolean(params.inputValue);
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1364
|
+
const containerElement = /** @type {HTMLElement} */checkboxContainer;
|
|
1365
|
+
const label = containerElement.querySelector('span');
|
|
1366
|
+
if (label) {
|
|
1367
|
+
const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
|
|
1368
|
+
if (placeholderOrLabel) {
|
|
1369
|
+
setInnerHtml(label, placeholderOrLabel);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1350
1372
|
return checkbox;
|
|
1351
1373
|
};
|
|
1352
1374
|
|
|
1353
1375
|
/**
|
|
1354
|
-
* @param {
|
|
1376
|
+
* @param {Input | HTMLElement} textarea
|
|
1355
1377
|
* @param {SweetAlertOptions} params
|
|
1356
|
-
* @returns {
|
|
1378
|
+
* @returns {Input}
|
|
1357
1379
|
*/
|
|
1358
1380
|
renderInputType.textarea = (textarea, params) => {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1381
|
+
const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
|
|
1382
|
+
checkAndSetInputValue(textareaElement, params.inputValue);
|
|
1383
|
+
setInputPlaceholder(textareaElement, params);
|
|
1384
|
+
setInputLabel(textareaElement, textareaElement, params);
|
|
1362
1385
|
|
|
1363
1386
|
/**
|
|
1364
1387
|
* @param {HTMLElement} el
|
|
@@ -1370,26 +1393,33 @@
|
|
|
1370
1393
|
setTimeout(() => {
|
|
1371
1394
|
// https://github.com/sweetalert2/sweetalert2/issues/1699
|
|
1372
1395
|
if ('MutationObserver' in window) {
|
|
1373
|
-
const
|
|
1396
|
+
const popup = getPopup();
|
|
1397
|
+
if (!popup) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
|
|
1374
1401
|
const textareaResizeHandler = () => {
|
|
1375
1402
|
// check if texarea is still in document (i.e. popup wasn't closed in the meantime)
|
|
1376
|
-
if (!document.body.contains(
|
|
1403
|
+
if (!document.body.contains(textareaElement)) {
|
|
1377
1404
|
return;
|
|
1378
1405
|
}
|
|
1379
|
-
const textareaWidth =
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1406
|
+
const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
|
|
1407
|
+
const popupElement = getPopup();
|
|
1408
|
+
if (popupElement) {
|
|
1409
|
+
if (textareaWidth > initialPopupWidth) {
|
|
1410
|
+
popupElement.style.width = `${textareaWidth}px`;
|
|
1411
|
+
} else {
|
|
1412
|
+
applyNumericalStyle(popupElement, 'width', params.width);
|
|
1413
|
+
}
|
|
1384
1414
|
}
|
|
1385
1415
|
};
|
|
1386
|
-
new MutationObserver(textareaResizeHandler).observe(
|
|
1416
|
+
new MutationObserver(textareaResizeHandler).observe(textareaElement, {
|
|
1387
1417
|
attributes: true,
|
|
1388
1418
|
attributeFilter: ['style']
|
|
1389
1419
|
});
|
|
1390
1420
|
}
|
|
1391
1421
|
});
|
|
1392
|
-
return
|
|
1422
|
+
return textareaElement;
|
|
1393
1423
|
};
|
|
1394
1424
|
|
|
1395
1425
|
/**
|
|
@@ -1876,6 +1906,7 @@
|
|
|
1876
1906
|
* @param {SweetAlertOptions} params
|
|
1877
1907
|
*/
|
|
1878
1908
|
const render = (instance, params) => {
|
|
1909
|
+
var _globalState$eventEmi;
|
|
1879
1910
|
renderPopup(instance, params);
|
|
1880
1911
|
renderContainer(instance, params);
|
|
1881
1912
|
renderProgressSteps(instance, params);
|
|
@@ -1890,7 +1921,7 @@
|
|
|
1890
1921
|
if (typeof params.didRender === 'function' && popup) {
|
|
1891
1922
|
params.didRender(popup);
|
|
1892
1923
|
}
|
|
1893
|
-
globalState.eventEmitter.emit('didRender', popup);
|
|
1924
|
+
(_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
|
|
1894
1925
|
};
|
|
1895
1926
|
|
|
1896
1927
|
/*
|
|
@@ -2784,7 +2815,7 @@
|
|
|
2784
2815
|
* @returns {boolean}
|
|
2785
2816
|
*/
|
|
2786
2817
|
const isSelected = (optionValue, inputValue) => {
|
|
2787
|
-
return Boolean(inputValue) && inputValue.toString() === optionValue.toString();
|
|
2818
|
+
return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
|
|
2788
2819
|
};
|
|
2789
2820
|
|
|
2790
2821
|
/**
|
|
@@ -3960,9 +3991,9 @@
|
|
|
3960
3991
|
if (!paramName || !value) {
|
|
3961
3992
|
return;
|
|
3962
3993
|
}
|
|
3963
|
-
if (typeof defaultParams[paramName] === 'boolean') {
|
|
3994
|
+
if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
|
|
3964
3995
|
result[paramName] = value !== 'false';
|
|
3965
|
-
} else if (typeof defaultParams[paramName] === 'object') {
|
|
3996
|
+
} else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
|
|
3966
3997
|
result[paramName] = JSON.parse(value);
|
|
3967
3998
|
} else {
|
|
3968
3999
|
result[paramName] = value;
|
|
@@ -4009,10 +4040,16 @@
|
|
|
4009
4040
|
result[`${type}ButtonText`] = button.innerHTML;
|
|
4010
4041
|
result[`show${capitalizeFirstLetter(type)}Button`] = true;
|
|
4011
4042
|
if (button.hasAttribute('color')) {
|
|
4012
|
-
|
|
4043
|
+
const color = button.getAttribute('color');
|
|
4044
|
+
if (color !== null) {
|
|
4045
|
+
result[`${type}ButtonColor`] = color;
|
|
4046
|
+
}
|
|
4013
4047
|
}
|
|
4014
4048
|
if (button.hasAttribute('aria-label')) {
|
|
4015
|
-
|
|
4049
|
+
const ariaLabel = button.getAttribute('aria-label');
|
|
4050
|
+
if (ariaLabel !== null) {
|
|
4051
|
+
result[`${type}ButtonAriaLabel`] = ariaLabel;
|
|
4052
|
+
}
|
|
4016
4053
|
}
|
|
4017
4054
|
});
|
|
4018
4055
|
return result;
|
|
@@ -4070,7 +4107,7 @@
|
|
|
4070
4107
|
* @returns {object}
|
|
4071
4108
|
*/
|
|
4072
4109
|
const getSwalInput = templateContent => {
|
|
4073
|
-
/** @type {
|
|
4110
|
+
/** @type {Record<string, any>} */
|
|
4074
4111
|
const result = {};
|
|
4075
4112
|
/** @type {HTMLElement | null} */
|
|
4076
4113
|
const input = templateContent.querySelector('swal-input');
|
|
@@ -4637,7 +4674,7 @@
|
|
|
4637
4674
|
};
|
|
4638
4675
|
});
|
|
4639
4676
|
SweetAlert.DismissReason = DismissReason;
|
|
4640
|
-
SweetAlert.version = '11.26.
|
|
4677
|
+
SweetAlert.version = '11.26.14';
|
|
4641
4678
|
|
|
4642
4679
|
const Swal = SweetAlert;
|
|
4643
4680
|
// @ts-ignore
|