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
package/dist/sweetalert2.all.js
CHANGED
|
@@ -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 (global, factory) {
|
|
@@ -550,7 +550,7 @@
|
|
|
550
550
|
value = parseInt(value);
|
|
551
551
|
}
|
|
552
552
|
if (value || parseInt(`${value}`) === 0) {
|
|
553
|
-
elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : value);
|
|
553
|
+
elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
|
|
554
554
|
} else {
|
|
555
555
|
elem.style.removeProperty(property);
|
|
556
556
|
}
|
|
@@ -645,7 +645,7 @@
|
|
|
645
645
|
* @returns {boolean}
|
|
646
646
|
*/
|
|
647
647
|
const selfOrParentIsScrollable = (element, stopElement) => {
|
|
648
|
-
let parent = element;
|
|
648
|
+
let parent = /** @type {HTMLElement | null} */element;
|
|
649
649
|
while (parent && parent !== stopElement) {
|
|
650
650
|
if (isScrollable(parent)) {
|
|
651
651
|
return true;
|
|
@@ -752,50 +752,81 @@
|
|
|
752
752
|
return false;
|
|
753
753
|
}
|
|
754
754
|
oldContainer.remove();
|
|
755
|
-
removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
|
|
755
|
+
removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
|
|
756
|
+
// @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
|
|
757
|
+
swalClasses['has-column']]);
|
|
756
758
|
return true;
|
|
757
759
|
};
|
|
758
760
|
const resetValidationMessage$1 = () => {
|
|
759
|
-
globalState.currentInstance
|
|
761
|
+
if (globalState.currentInstance) {
|
|
762
|
+
globalState.currentInstance.resetValidationMessage();
|
|
763
|
+
}
|
|
760
764
|
};
|
|
761
765
|
const addInputChangeListeners = () => {
|
|
762
766
|
const popup = getPopup();
|
|
767
|
+
if (!popup) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
763
770
|
const input = getDirectChildByClass(popup, swalClasses.input);
|
|
764
771
|
const file = getDirectChildByClass(popup, swalClasses.file);
|
|
765
|
-
/** @type {HTMLInputElement} */
|
|
772
|
+
/** @type {HTMLInputElement | null} */
|
|
766
773
|
const range = popup.querySelector(`.${swalClasses.range} input`);
|
|
767
|
-
/** @type {HTMLOutputElement} */
|
|
774
|
+
/** @type {HTMLOutputElement | null} */
|
|
768
775
|
const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
|
|
769
776
|
const select = getDirectChildByClass(popup, swalClasses.select);
|
|
770
|
-
/** @type {HTMLInputElement} */
|
|
777
|
+
/** @type {HTMLInputElement | null} */
|
|
771
778
|
const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
|
|
772
779
|
const textarea = getDirectChildByClass(popup, swalClasses.textarea);
|
|
773
|
-
input
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
resetValidationMessage$1
|
|
784
|
-
|
|
785
|
-
|
|
780
|
+
if (input) {
|
|
781
|
+
input.oninput = resetValidationMessage$1;
|
|
782
|
+
}
|
|
783
|
+
if (file) {
|
|
784
|
+
file.onchange = resetValidationMessage$1;
|
|
785
|
+
}
|
|
786
|
+
if (select) {
|
|
787
|
+
select.onchange = resetValidationMessage$1;
|
|
788
|
+
}
|
|
789
|
+
if (checkbox) {
|
|
790
|
+
checkbox.onchange = resetValidationMessage$1;
|
|
791
|
+
}
|
|
792
|
+
if (textarea) {
|
|
793
|
+
textarea.oninput = resetValidationMessage$1;
|
|
794
|
+
}
|
|
795
|
+
if (range && rangeOutput) {
|
|
796
|
+
range.oninput = () => {
|
|
797
|
+
resetValidationMessage$1();
|
|
798
|
+
rangeOutput.value = range.value;
|
|
799
|
+
};
|
|
800
|
+
range.onchange = () => {
|
|
801
|
+
resetValidationMessage$1();
|
|
802
|
+
rangeOutput.value = range.value;
|
|
803
|
+
};
|
|
804
|
+
}
|
|
786
805
|
};
|
|
787
806
|
|
|
788
807
|
/**
|
|
789
808
|
* @param {string | HTMLElement} target
|
|
790
809
|
* @returns {HTMLElement}
|
|
791
810
|
*/
|
|
792
|
-
const getTarget = target =>
|
|
811
|
+
const getTarget = target => {
|
|
812
|
+
if (typeof target === 'string') {
|
|
813
|
+
const element = document.querySelector(target);
|
|
814
|
+
if (!element) {
|
|
815
|
+
throw new Error(`Target element "${target}" not found`);
|
|
816
|
+
}
|
|
817
|
+
return /** @type {HTMLElement} */element;
|
|
818
|
+
}
|
|
819
|
+
return target;
|
|
820
|
+
};
|
|
793
821
|
|
|
794
822
|
/**
|
|
795
823
|
* @param {SweetAlertOptions} params
|
|
796
824
|
*/
|
|
797
825
|
const setupAccessibility = params => {
|
|
798
826
|
const popup = getPopup();
|
|
827
|
+
if (!popup) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
799
830
|
popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
|
|
800
831
|
popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
|
|
801
832
|
if (!params.toast) {
|
|
@@ -832,7 +863,7 @@
|
|
|
832
863
|
}
|
|
833
864
|
setInnerHtml(container, sweetHTML);
|
|
834
865
|
container.dataset['swal2Theme'] = params.theme;
|
|
835
|
-
const targetElement = getTarget(params.target);
|
|
866
|
+
const targetElement = getTarget(params.target || 'body');
|
|
836
867
|
targetElement.appendChild(container);
|
|
837
868
|
if (params.topLayer) {
|
|
838
869
|
container.setAttribute('popover', '');
|
|
@@ -870,7 +901,7 @@
|
|
|
870
901
|
*/
|
|
871
902
|
const handleObject = (param, target) => {
|
|
872
903
|
// JQuery element(s)
|
|
873
|
-
if (param
|
|
904
|
+
if ('jquery' in param) {
|
|
874
905
|
handleJqueryElem(target, param);
|
|
875
906
|
}
|
|
876
907
|
|
|
@@ -882,7 +913,7 @@
|
|
|
882
913
|
|
|
883
914
|
/**
|
|
884
915
|
* @param {HTMLElement} target
|
|
885
|
-
* @param {
|
|
916
|
+
* @param {any} elem
|
|
886
917
|
*/
|
|
887
918
|
const handleJqueryElem = (target, elem) => {
|
|
888
919
|
target.textContent = '';
|
|
@@ -1906,6 +1937,7 @@
|
|
|
1906
1937
|
* @param {SweetAlertOptions} params
|
|
1907
1938
|
*/
|
|
1908
1939
|
const render = (instance, params) => {
|
|
1940
|
+
var _globalState$eventEmi;
|
|
1909
1941
|
renderPopup(instance, params);
|
|
1910
1942
|
renderContainer(instance, params);
|
|
1911
1943
|
renderProgressSteps(instance, params);
|
|
@@ -1920,7 +1952,7 @@
|
|
|
1920
1952
|
if (typeof params.didRender === 'function' && popup) {
|
|
1921
1953
|
params.didRender(popup);
|
|
1922
1954
|
}
|
|
1923
|
-
globalState.eventEmitter.emit('didRender', popup);
|
|
1955
|
+
(_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
|
|
1924
1956
|
};
|
|
1925
1957
|
|
|
1926
1958
|
/*
|
|
@@ -2814,7 +2846,7 @@
|
|
|
2814
2846
|
* @returns {boolean}
|
|
2815
2847
|
*/
|
|
2816
2848
|
const isSelected = (optionValue, inputValue) => {
|
|
2817
|
-
return Boolean(inputValue) && inputValue.toString() === optionValue.toString();
|
|
2849
|
+
return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
|
|
2818
2850
|
};
|
|
2819
2851
|
|
|
2820
2852
|
/**
|
|
@@ -3597,9 +3629,15 @@
|
|
|
3597
3629
|
*
|
|
3598
3630
|
* @param {SweetAlertOptions} mixinParams
|
|
3599
3631
|
* @returns {SweetAlert}
|
|
3632
|
+
* @this {typeof import('../SweetAlert.js').SweetAlert}
|
|
3600
3633
|
*/
|
|
3601
3634
|
function mixin(mixinParams) {
|
|
3635
|
+
// @ts-ignore: 'this' refers to the SweetAlert constructor
|
|
3602
3636
|
class MixinSwal extends this {
|
|
3637
|
+
/**
|
|
3638
|
+
* @param {any} params
|
|
3639
|
+
* @param {any} priorityMixinParams
|
|
3640
|
+
*/
|
|
3603
3641
|
_main(params, priorityMixinParams) {
|
|
3604
3642
|
return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
|
|
3605
3643
|
}
|
|
@@ -3990,9 +4028,9 @@
|
|
|
3990
4028
|
if (!paramName || !value) {
|
|
3991
4029
|
return;
|
|
3992
4030
|
}
|
|
3993
|
-
if (typeof defaultParams[paramName] === 'boolean') {
|
|
4031
|
+
if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
|
|
3994
4032
|
result[paramName] = value !== 'false';
|
|
3995
|
-
} else if (typeof defaultParams[paramName] === 'object') {
|
|
4033
|
+
} else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
|
|
3996
4034
|
result[paramName] = JSON.parse(value);
|
|
3997
4035
|
} else {
|
|
3998
4036
|
result[paramName] = value;
|
|
@@ -4039,10 +4077,16 @@
|
|
|
4039
4077
|
result[`${type}ButtonText`] = button.innerHTML;
|
|
4040
4078
|
result[`show${capitalizeFirstLetter(type)}Button`] = true;
|
|
4041
4079
|
if (button.hasAttribute('color')) {
|
|
4042
|
-
|
|
4080
|
+
const color = button.getAttribute('color');
|
|
4081
|
+
if (color !== null) {
|
|
4082
|
+
result[`${type}ButtonColor`] = color;
|
|
4083
|
+
}
|
|
4043
4084
|
}
|
|
4044
4085
|
if (button.hasAttribute('aria-label')) {
|
|
4045
|
-
|
|
4086
|
+
const ariaLabel = button.getAttribute('aria-label');
|
|
4087
|
+
if (ariaLabel !== null) {
|
|
4088
|
+
result[`${type}ButtonAriaLabel`] = ariaLabel;
|
|
4089
|
+
}
|
|
4046
4090
|
}
|
|
4047
4091
|
});
|
|
4048
4092
|
return result;
|
|
@@ -4100,7 +4144,7 @@
|
|
|
4100
4144
|
* @returns {object}
|
|
4101
4145
|
*/
|
|
4102
4146
|
const getSwalInput = templateContent => {
|
|
4103
|
-
/** @type {
|
|
4147
|
+
/** @type {Record<string, any>} */
|
|
4104
4148
|
const result = {};
|
|
4105
4149
|
/** @type {HTMLElement | null} */
|
|
4106
4150
|
const input = templateContent.querySelector('swal-input');
|
|
@@ -4383,7 +4427,11 @@
|
|
|
4383
4427
|
/**
|
|
4384
4428
|
* @type {Promise<SweetAlertResult>}
|
|
4385
4429
|
*/
|
|
4386
|
-
_classPrivateFieldInitSpec(this, _promise,
|
|
4430
|
+
_classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
|
|
4431
|
+
isConfirmed: false,
|
|
4432
|
+
isDenied: false,
|
|
4433
|
+
isDismissed: true
|
|
4434
|
+
}));
|
|
4387
4435
|
// Prevent run in Node env
|
|
4388
4436
|
if (typeof window === 'undefined') {
|
|
4389
4437
|
return;
|
|
@@ -4400,6 +4448,11 @@
|
|
|
4400
4448
|
this.isAwaitingPromise = false;
|
|
4401
4449
|
_classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
|
|
4402
4450
|
}
|
|
4451
|
+
|
|
4452
|
+
/**
|
|
4453
|
+
* @param {any} userParams
|
|
4454
|
+
* @param {any} mixinParams
|
|
4455
|
+
*/
|
|
4403
4456
|
_main(userParams, mixinParams = {}) {
|
|
4404
4457
|
showWarningsForParams(Object.assign({}, mixinParams, userParams));
|
|
4405
4458
|
if (globalState.currentInstance) {
|
|
@@ -4437,9 +4490,16 @@
|
|
|
4437
4490
|
}
|
|
4438
4491
|
|
|
4439
4492
|
// `catch` cannot be the name of a module export, so we define our thenable methods here instead
|
|
4493
|
+
/**
|
|
4494
|
+
* @param {any} onFulfilled
|
|
4495
|
+
*/
|
|
4440
4496
|
then(onFulfilled) {
|
|
4441
4497
|
return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
|
|
4442
4498
|
}
|
|
4499
|
+
|
|
4500
|
+
/**
|
|
4501
|
+
* @param {any} onFinally
|
|
4502
|
+
*/
|
|
4443
4503
|
finally(onFinally) {
|
|
4444
4504
|
return _classPrivateFieldGet2(_promise, this).finally(onFinally);
|
|
4445
4505
|
}
|
|
@@ -4449,7 +4509,7 @@
|
|
|
4449
4509
|
* @param {SweetAlert} instance
|
|
4450
4510
|
* @param {DomCache} domCache
|
|
4451
4511
|
* @param {SweetAlertOptions} innerParams
|
|
4452
|
-
* @returns {Promise}
|
|
4512
|
+
* @returns {Promise<SweetAlertResult>}
|
|
4453
4513
|
*/
|
|
4454
4514
|
const swalPromise = (instance, domCache, innerParams) => {
|
|
4455
4515
|
return new Promise((resolve, reject) => {
|
|
@@ -4517,17 +4577,17 @@
|
|
|
4517
4577
|
* @returns {DomCache}
|
|
4518
4578
|
*/
|
|
4519
4579
|
const populateDomCache = instance => {
|
|
4520
|
-
const domCache = {
|
|
4521
|
-
popup: getPopup(),
|
|
4522
|
-
container: getContainer(),
|
|
4523
|
-
actions: getActions(),
|
|
4524
|
-
confirmButton: getConfirmButton(),
|
|
4525
|
-
denyButton: getDenyButton(),
|
|
4526
|
-
cancelButton: getCancelButton(),
|
|
4527
|
-
loader: getLoader(),
|
|
4528
|
-
closeButton: getCloseButton(),
|
|
4529
|
-
validationMessage: getValidationMessage(),
|
|
4530
|
-
progressSteps: getProgressSteps()
|
|
4580
|
+
const domCache = /** @type {DomCache} */{
|
|
4581
|
+
popup: (/** @type {HTMLElement} */getPopup()),
|
|
4582
|
+
container: (/** @type {HTMLElement} */getContainer()),
|
|
4583
|
+
actions: (/** @type {HTMLElement} */getActions()),
|
|
4584
|
+
confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
|
|
4585
|
+
denyButton: (/** @type {HTMLElement} */getDenyButton()),
|
|
4586
|
+
cancelButton: (/** @type {HTMLElement} */getCancelButton()),
|
|
4587
|
+
loader: (/** @type {HTMLElement} */getLoader()),
|
|
4588
|
+
closeButton: (/** @type {HTMLElement} */getCloseButton()),
|
|
4589
|
+
validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
|
|
4590
|
+
progressSteps: (/** @type {HTMLElement} */getProgressSteps())
|
|
4531
4591
|
};
|
|
4532
4592
|
privateProps.domCache.set(instance, domCache);
|
|
4533
4593
|
return domCache;
|
|
@@ -4546,13 +4606,13 @@
|
|
|
4546
4606
|
dismissWith('timer');
|
|
4547
4607
|
delete globalState.timeout;
|
|
4548
4608
|
}, innerParams.timer);
|
|
4549
|
-
if (innerParams.timerProgressBar) {
|
|
4609
|
+
if (innerParams.timerProgressBar && timerProgressBar) {
|
|
4550
4610
|
show(timerProgressBar);
|
|
4551
4611
|
applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
|
|
4552
4612
|
setTimeout(() => {
|
|
4553
4613
|
if (globalState.timeout && globalState.timeout.running) {
|
|
4554
4614
|
// timer can be already stopped or unset at this point
|
|
4555
|
-
animateTimerProgressBar(innerParams.timer);
|
|
4615
|
+
animateTimerProgressBar(/** @type {number} */innerParams.timer);
|
|
4556
4616
|
}
|
|
4557
4617
|
});
|
|
4558
4618
|
}
|
|
@@ -4659,15 +4719,18 @@
|
|
|
4659
4719
|
* @param {...(SweetAlertOptions | string | undefined)} args
|
|
4660
4720
|
* @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
|
|
4661
4721
|
*/
|
|
4722
|
+
// @ts-ignore: Dynamic property assignment for backwards compatibility
|
|
4662
4723
|
SweetAlert[key] = function (...args) {
|
|
4724
|
+
// @ts-ignore
|
|
4663
4725
|
if (currentInstance && currentInstance[key]) {
|
|
4726
|
+
// @ts-ignore
|
|
4664
4727
|
return currentInstance[key](...args);
|
|
4665
4728
|
}
|
|
4666
|
-
return
|
|
4729
|
+
return undefined;
|
|
4667
4730
|
};
|
|
4668
4731
|
});
|
|
4669
4732
|
SweetAlert.DismissReason = DismissReason;
|
|
4670
|
-
SweetAlert.version = '11.26.
|
|
4733
|
+
SweetAlert.version = '11.26.15';
|
|
4671
4734
|
|
|
4672
4735
|
const Swal = SweetAlert;
|
|
4673
4736
|
// @ts-ignore
|