sweetalert2 11.26.13 → 11.26.15
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 +112 -49
- package/dist/sweetalert2.all.min.js +2 -2
- package/dist/sweetalert2.esm.all.js +112 -49
- package/dist/sweetalert2.esm.all.min.js +2 -2
- package/dist/sweetalert2.esm.js +112 -49
- package/dist/sweetalert2.esm.min.js +2 -2
- package/dist/sweetalert2.js +112 -49
- package/dist/sweetalert2.min.js +2 -2
- package/package.json +1 -1
- package/src/SweetAlert.js +31 -18
- package/src/staticMethods/mixin.js +6 -0
- package/src/utils/dom/domUtils.js +2 -2
- package/src/utils/dom/init.js +53 -19
- 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/getTemplateParams.js +17 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sweetalert2 v11.26.
|
|
2
|
+
* sweetalert2 v11.26.15
|
|
3
3
|
* Released under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
function _assertClassBrand(e, t, n) {
|
|
@@ -544,7 +544,7 @@ const applyNumericalStyle = (elem, property, value) => {
|
|
|
544
544
|
value = parseInt(value);
|
|
545
545
|
}
|
|
546
546
|
if (value || parseInt(`${value}`) === 0) {
|
|
547
|
-
elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : value);
|
|
547
|
+
elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
|
|
548
548
|
} else {
|
|
549
549
|
elem.style.removeProperty(property);
|
|
550
550
|
}
|
|
@@ -639,7 +639,7 @@ const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
|
|
|
639
639
|
* @returns {boolean}
|
|
640
640
|
*/
|
|
641
641
|
const selfOrParentIsScrollable = (element, stopElement) => {
|
|
642
|
-
let parent = element;
|
|
642
|
+
let parent = /** @type {HTMLElement | null} */element;
|
|
643
643
|
while (parent && parent !== stopElement) {
|
|
644
644
|
if (isScrollable(parent)) {
|
|
645
645
|
return true;
|
|
@@ -746,50 +746,81 @@ const resetOldContainer = () => {
|
|
|
746
746
|
return false;
|
|
747
747
|
}
|
|
748
748
|
oldContainer.remove();
|
|
749
|
-
removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
|
|
749
|
+
removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
|
|
750
|
+
// @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
|
|
751
|
+
swalClasses['has-column']]);
|
|
750
752
|
return true;
|
|
751
753
|
};
|
|
752
754
|
const resetValidationMessage$1 = () => {
|
|
753
|
-
globalState.currentInstance
|
|
755
|
+
if (globalState.currentInstance) {
|
|
756
|
+
globalState.currentInstance.resetValidationMessage();
|
|
757
|
+
}
|
|
754
758
|
};
|
|
755
759
|
const addInputChangeListeners = () => {
|
|
756
760
|
const popup = getPopup();
|
|
761
|
+
if (!popup) {
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
757
764
|
const input = getDirectChildByClass(popup, swalClasses.input);
|
|
758
765
|
const file = getDirectChildByClass(popup, swalClasses.file);
|
|
759
|
-
/** @type {HTMLInputElement} */
|
|
766
|
+
/** @type {HTMLInputElement | null} */
|
|
760
767
|
const range = popup.querySelector(`.${swalClasses.range} input`);
|
|
761
|
-
/** @type {HTMLOutputElement} */
|
|
768
|
+
/** @type {HTMLOutputElement | null} */
|
|
762
769
|
const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
|
|
763
770
|
const select = getDirectChildByClass(popup, swalClasses.select);
|
|
764
|
-
/** @type {HTMLInputElement} */
|
|
771
|
+
/** @type {HTMLInputElement | null} */
|
|
765
772
|
const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
|
|
766
773
|
const textarea = getDirectChildByClass(popup, swalClasses.textarea);
|
|
767
|
-
input
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
resetValidationMessage$1
|
|
778
|
-
|
|
779
|
-
|
|
774
|
+
if (input) {
|
|
775
|
+
input.oninput = resetValidationMessage$1;
|
|
776
|
+
}
|
|
777
|
+
if (file) {
|
|
778
|
+
file.onchange = resetValidationMessage$1;
|
|
779
|
+
}
|
|
780
|
+
if (select) {
|
|
781
|
+
select.onchange = resetValidationMessage$1;
|
|
782
|
+
}
|
|
783
|
+
if (checkbox) {
|
|
784
|
+
checkbox.onchange = resetValidationMessage$1;
|
|
785
|
+
}
|
|
786
|
+
if (textarea) {
|
|
787
|
+
textarea.oninput = resetValidationMessage$1;
|
|
788
|
+
}
|
|
789
|
+
if (range && rangeOutput) {
|
|
790
|
+
range.oninput = () => {
|
|
791
|
+
resetValidationMessage$1();
|
|
792
|
+
rangeOutput.value = range.value;
|
|
793
|
+
};
|
|
794
|
+
range.onchange = () => {
|
|
795
|
+
resetValidationMessage$1();
|
|
796
|
+
rangeOutput.value = range.value;
|
|
797
|
+
};
|
|
798
|
+
}
|
|
780
799
|
};
|
|
781
800
|
|
|
782
801
|
/**
|
|
783
802
|
* @param {string | HTMLElement} target
|
|
784
803
|
* @returns {HTMLElement}
|
|
785
804
|
*/
|
|
786
|
-
const getTarget = target =>
|
|
805
|
+
const getTarget = target => {
|
|
806
|
+
if (typeof target === 'string') {
|
|
807
|
+
const element = document.querySelector(target);
|
|
808
|
+
if (!element) {
|
|
809
|
+
throw new Error(`Target element "${target}" not found`);
|
|
810
|
+
}
|
|
811
|
+
return /** @type {HTMLElement} */element;
|
|
812
|
+
}
|
|
813
|
+
return target;
|
|
814
|
+
};
|
|
787
815
|
|
|
788
816
|
/**
|
|
789
817
|
* @param {SweetAlertOptions} params
|
|
790
818
|
*/
|
|
791
819
|
const setupAccessibility = params => {
|
|
792
820
|
const popup = getPopup();
|
|
821
|
+
if (!popup) {
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
793
824
|
popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
|
|
794
825
|
popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
|
|
795
826
|
if (!params.toast) {
|
|
@@ -826,7 +857,7 @@ const init = params => {
|
|
|
826
857
|
}
|
|
827
858
|
setInnerHtml(container, sweetHTML);
|
|
828
859
|
container.dataset['swal2Theme'] = params.theme;
|
|
829
|
-
const targetElement = getTarget(params.target);
|
|
860
|
+
const targetElement = getTarget(params.target || 'body');
|
|
830
861
|
targetElement.appendChild(container);
|
|
831
862
|
if (params.topLayer) {
|
|
832
863
|
container.setAttribute('popover', '');
|
|
@@ -864,7 +895,7 @@ const parseHtmlToContainer = (param, target) => {
|
|
|
864
895
|
*/
|
|
865
896
|
const handleObject = (param, target) => {
|
|
866
897
|
// JQuery element(s)
|
|
867
|
-
if (param
|
|
898
|
+
if ('jquery' in param) {
|
|
868
899
|
handleJqueryElem(target, param);
|
|
869
900
|
}
|
|
870
901
|
|
|
@@ -876,7 +907,7 @@ const handleObject = (param, target) => {
|
|
|
876
907
|
|
|
877
908
|
/**
|
|
878
909
|
* @param {HTMLElement} target
|
|
879
|
-
* @param {
|
|
910
|
+
* @param {any} elem
|
|
880
911
|
*/
|
|
881
912
|
const handleJqueryElem = (target, elem) => {
|
|
882
913
|
target.textContent = '';
|
|
@@ -1900,6 +1931,7 @@ const renderTitle = (instance, params) => {
|
|
|
1900
1931
|
* @param {SweetAlertOptions} params
|
|
1901
1932
|
*/
|
|
1902
1933
|
const render = (instance, params) => {
|
|
1934
|
+
var _globalState$eventEmi;
|
|
1903
1935
|
renderPopup(instance, params);
|
|
1904
1936
|
renderContainer(instance, params);
|
|
1905
1937
|
renderProgressSteps(instance, params);
|
|
@@ -1914,7 +1946,7 @@ const render = (instance, params) => {
|
|
|
1914
1946
|
if (typeof params.didRender === 'function' && popup) {
|
|
1915
1947
|
params.didRender(popup);
|
|
1916
1948
|
}
|
|
1917
|
-
globalState.eventEmitter.emit('didRender', popup);
|
|
1949
|
+
(_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
|
|
1918
1950
|
};
|
|
1919
1951
|
|
|
1920
1952
|
/*
|
|
@@ -2808,7 +2840,7 @@ const formatInputOptions = inputOptions => {
|
|
|
2808
2840
|
* @returns {boolean}
|
|
2809
2841
|
*/
|
|
2810
2842
|
const isSelected = (optionValue, inputValue) => {
|
|
2811
|
-
return Boolean(inputValue) && inputValue.toString() === optionValue.toString();
|
|
2843
|
+
return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
|
|
2812
2844
|
};
|
|
2813
2845
|
|
|
2814
2846
|
/**
|
|
@@ -3591,9 +3623,15 @@ function fire(...args) {
|
|
|
3591
3623
|
*
|
|
3592
3624
|
* @param {SweetAlertOptions} mixinParams
|
|
3593
3625
|
* @returns {SweetAlert}
|
|
3626
|
+
* @this {typeof import('../SweetAlert.js').SweetAlert}
|
|
3594
3627
|
*/
|
|
3595
3628
|
function mixin(mixinParams) {
|
|
3629
|
+
// @ts-ignore: 'this' refers to the SweetAlert constructor
|
|
3596
3630
|
class MixinSwal extends this {
|
|
3631
|
+
/**
|
|
3632
|
+
* @param {any} params
|
|
3633
|
+
* @param {any} priorityMixinParams
|
|
3634
|
+
*/
|
|
3597
3635
|
_main(params, priorityMixinParams) {
|
|
3598
3636
|
return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
|
|
3599
3637
|
}
|
|
@@ -3984,9 +4022,9 @@ const getSwalParams = templateContent => {
|
|
|
3984
4022
|
if (!paramName || !value) {
|
|
3985
4023
|
return;
|
|
3986
4024
|
}
|
|
3987
|
-
if (typeof defaultParams[paramName] === 'boolean') {
|
|
4025
|
+
if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
|
|
3988
4026
|
result[paramName] = value !== 'false';
|
|
3989
|
-
} else if (typeof defaultParams[paramName] === 'object') {
|
|
4027
|
+
} else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
|
|
3990
4028
|
result[paramName] = JSON.parse(value);
|
|
3991
4029
|
} else {
|
|
3992
4030
|
result[paramName] = value;
|
|
@@ -4033,10 +4071,16 @@ const getSwalButtons = templateContent => {
|
|
|
4033
4071
|
result[`${type}ButtonText`] = button.innerHTML;
|
|
4034
4072
|
result[`show${capitalizeFirstLetter(type)}Button`] = true;
|
|
4035
4073
|
if (button.hasAttribute('color')) {
|
|
4036
|
-
|
|
4074
|
+
const color = button.getAttribute('color');
|
|
4075
|
+
if (color !== null) {
|
|
4076
|
+
result[`${type}ButtonColor`] = color;
|
|
4077
|
+
}
|
|
4037
4078
|
}
|
|
4038
4079
|
if (button.hasAttribute('aria-label')) {
|
|
4039
|
-
|
|
4080
|
+
const ariaLabel = button.getAttribute('aria-label');
|
|
4081
|
+
if (ariaLabel !== null) {
|
|
4082
|
+
result[`${type}ButtonAriaLabel`] = ariaLabel;
|
|
4083
|
+
}
|
|
4040
4084
|
}
|
|
4041
4085
|
});
|
|
4042
4086
|
return result;
|
|
@@ -4094,7 +4138,7 @@ const getSwalIcon = templateContent => {
|
|
|
4094
4138
|
* @returns {object}
|
|
4095
4139
|
*/
|
|
4096
4140
|
const getSwalInput = templateContent => {
|
|
4097
|
-
/** @type {
|
|
4141
|
+
/** @type {Record<string, any>} */
|
|
4098
4142
|
const result = {};
|
|
4099
4143
|
/** @type {HTMLElement | null} */
|
|
4100
4144
|
const input = templateContent.querySelector('swal-input');
|
|
@@ -4377,7 +4421,11 @@ class SweetAlert {
|
|
|
4377
4421
|
/**
|
|
4378
4422
|
* @type {Promise<SweetAlertResult>}
|
|
4379
4423
|
*/
|
|
4380
|
-
_classPrivateFieldInitSpec(this, _promise,
|
|
4424
|
+
_classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
|
|
4425
|
+
isConfirmed: false,
|
|
4426
|
+
isDenied: false,
|
|
4427
|
+
isDismissed: true
|
|
4428
|
+
}));
|
|
4381
4429
|
// Prevent run in Node env
|
|
4382
4430
|
if (typeof window === 'undefined') {
|
|
4383
4431
|
return;
|
|
@@ -4394,6 +4442,11 @@ class SweetAlert {
|
|
|
4394
4442
|
this.isAwaitingPromise = false;
|
|
4395
4443
|
_classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
|
|
4396
4444
|
}
|
|
4445
|
+
|
|
4446
|
+
/**
|
|
4447
|
+
* @param {any} userParams
|
|
4448
|
+
* @param {any} mixinParams
|
|
4449
|
+
*/
|
|
4397
4450
|
_main(userParams, mixinParams = {}) {
|
|
4398
4451
|
showWarningsForParams(Object.assign({}, mixinParams, userParams));
|
|
4399
4452
|
if (globalState.currentInstance) {
|
|
@@ -4431,9 +4484,16 @@ class SweetAlert {
|
|
|
4431
4484
|
}
|
|
4432
4485
|
|
|
4433
4486
|
// `catch` cannot be the name of a module export, so we define our thenable methods here instead
|
|
4487
|
+
/**
|
|
4488
|
+
* @param {any} onFulfilled
|
|
4489
|
+
*/
|
|
4434
4490
|
then(onFulfilled) {
|
|
4435
4491
|
return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
|
|
4436
4492
|
}
|
|
4493
|
+
|
|
4494
|
+
/**
|
|
4495
|
+
* @param {any} onFinally
|
|
4496
|
+
*/
|
|
4437
4497
|
finally(onFinally) {
|
|
4438
4498
|
return _classPrivateFieldGet2(_promise, this).finally(onFinally);
|
|
4439
4499
|
}
|
|
@@ -4443,7 +4503,7 @@ class SweetAlert {
|
|
|
4443
4503
|
* @param {SweetAlert} instance
|
|
4444
4504
|
* @param {DomCache} domCache
|
|
4445
4505
|
* @param {SweetAlertOptions} innerParams
|
|
4446
|
-
* @returns {Promise}
|
|
4506
|
+
* @returns {Promise<SweetAlertResult>}
|
|
4447
4507
|
*/
|
|
4448
4508
|
const swalPromise = (instance, domCache, innerParams) => {
|
|
4449
4509
|
return new Promise((resolve, reject) => {
|
|
@@ -4511,17 +4571,17 @@ const prepareParams = (userParams, mixinParams) => {
|
|
|
4511
4571
|
* @returns {DomCache}
|
|
4512
4572
|
*/
|
|
4513
4573
|
const populateDomCache = instance => {
|
|
4514
|
-
const domCache = {
|
|
4515
|
-
popup: getPopup(),
|
|
4516
|
-
container: getContainer(),
|
|
4517
|
-
actions: getActions(),
|
|
4518
|
-
confirmButton: getConfirmButton(),
|
|
4519
|
-
denyButton: getDenyButton(),
|
|
4520
|
-
cancelButton: getCancelButton(),
|
|
4521
|
-
loader: getLoader(),
|
|
4522
|
-
closeButton: getCloseButton(),
|
|
4523
|
-
validationMessage: getValidationMessage(),
|
|
4524
|
-
progressSteps: getProgressSteps()
|
|
4574
|
+
const domCache = /** @type {DomCache} */{
|
|
4575
|
+
popup: (/** @type {HTMLElement} */getPopup()),
|
|
4576
|
+
container: (/** @type {HTMLElement} */getContainer()),
|
|
4577
|
+
actions: (/** @type {HTMLElement} */getActions()),
|
|
4578
|
+
confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
|
|
4579
|
+
denyButton: (/** @type {HTMLElement} */getDenyButton()),
|
|
4580
|
+
cancelButton: (/** @type {HTMLElement} */getCancelButton()),
|
|
4581
|
+
loader: (/** @type {HTMLElement} */getLoader()),
|
|
4582
|
+
closeButton: (/** @type {HTMLElement} */getCloseButton()),
|
|
4583
|
+
validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
|
|
4584
|
+
progressSteps: (/** @type {HTMLElement} */getProgressSteps())
|
|
4525
4585
|
};
|
|
4526
4586
|
privateProps.domCache.set(instance, domCache);
|
|
4527
4587
|
return domCache;
|
|
@@ -4540,13 +4600,13 @@ const setupTimer = (globalState, innerParams, dismissWith) => {
|
|
|
4540
4600
|
dismissWith('timer');
|
|
4541
4601
|
delete globalState.timeout;
|
|
4542
4602
|
}, innerParams.timer);
|
|
4543
|
-
if (innerParams.timerProgressBar) {
|
|
4603
|
+
if (innerParams.timerProgressBar && timerProgressBar) {
|
|
4544
4604
|
show(timerProgressBar);
|
|
4545
4605
|
applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
|
|
4546
4606
|
setTimeout(() => {
|
|
4547
4607
|
if (globalState.timeout && globalState.timeout.running) {
|
|
4548
4608
|
// timer can be already stopped or unset at this point
|
|
4549
|
-
animateTimerProgressBar(innerParams.timer);
|
|
4609
|
+
animateTimerProgressBar(/** @type {number} */innerParams.timer);
|
|
4550
4610
|
}
|
|
4551
4611
|
});
|
|
4552
4612
|
}
|
|
@@ -4653,15 +4713,18 @@ Object.keys(instanceMethods).forEach(key => {
|
|
|
4653
4713
|
* @param {...(SweetAlertOptions | string | undefined)} args
|
|
4654
4714
|
* @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
|
|
4655
4715
|
*/
|
|
4716
|
+
// @ts-ignore: Dynamic property assignment for backwards compatibility
|
|
4656
4717
|
SweetAlert[key] = function (...args) {
|
|
4718
|
+
// @ts-ignore
|
|
4657
4719
|
if (currentInstance && currentInstance[key]) {
|
|
4720
|
+
// @ts-ignore
|
|
4658
4721
|
return currentInstance[key](...args);
|
|
4659
4722
|
}
|
|
4660
|
-
return
|
|
4723
|
+
return undefined;
|
|
4661
4724
|
};
|
|
4662
4725
|
});
|
|
4663
4726
|
SweetAlert.DismissReason = DismissReason;
|
|
4664
|
-
SweetAlert.version = '11.26.
|
|
4727
|
+
SweetAlert.version = '11.26.15';
|
|
4665
4728
|
|
|
4666
4729
|
const Swal = SweetAlert;
|
|
4667
4730
|
// @ts-ignore
|