sweetalert2 11.26.0 → 11.26.2
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 +61 -59
- package/dist/sweetalert2.all.min.js +3 -3
- package/dist/sweetalert2.css +1 -1
- package/dist/sweetalert2.esm.all.js +61 -59
- package/dist/sweetalert2.esm.all.min.js +3 -3
- package/dist/sweetalert2.esm.js +60 -58
- package/dist/sweetalert2.esm.min.js +2 -2
- package/dist/sweetalert2.js +60 -58
- package/dist/sweetalert2.min.css +1 -1
- package/dist/sweetalert2.min.js +2 -2
- package/package.json +2 -2
- package/src/SweetAlert.js +6 -6
- package/src/buttons-handlers.js +12 -7
- package/src/instanceMethods/close.js +6 -6
- package/src/keydown-handler.js +3 -3
- package/src/popup-click-handler.js +3 -3
- package/src/sweetalert2.scss +1 -1
- package/src/types.js +3 -2
- package/src/utils/DismissReason.js +0 -2
- package/src/utils/Timer.js +1 -1
- package/src/utils/dom/domUtils.js +4 -4
- package/src/utils/dom/inputUtils.js +2 -2
- package/src/utils/dom/parseHtmlToContainer.js +2 -2
- package/src/utils/dom/renderers/renderFooter.js +1 -1
- package/src/utils/dom/renderers/renderTitle.js +1 -1
- package/src/utils/getTemplateParams.js +11 -11
- package/src/utils/iosFix.js +1 -1
- package/src/utils/openPopup.js +3 -2
- package/src/utils/utils.js +6 -6
- package/sweetalert2.d.ts +3 -1
|
@@ -12,7 +12,7 @@ export const renderTitle = (instance, params) => {
|
|
|
12
12
|
|
|
13
13
|
dom.showWhenInnerHtmlPresent(title)
|
|
14
14
|
|
|
15
|
-
dom.toggle(title, params.title || params.titleText, 'block')
|
|
15
|
+
dom.toggle(title, Boolean(params.title || params.titleText), 'block')
|
|
16
16
|
|
|
17
17
|
if (params.title) {
|
|
18
18
|
dom.parseHtmlToContainer(params.title, title)
|
|
@@ -34,10 +34,10 @@ export const getTemplateParams = (params) => {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* @param {DocumentFragment} templateContent
|
|
37
|
-
* @returns {Record<string,
|
|
37
|
+
* @returns {Record<string, string | boolean | number>}
|
|
38
38
|
*/
|
|
39
39
|
const getSwalParams = (templateContent) => {
|
|
40
|
-
/** @type {Record<string,
|
|
40
|
+
/** @type {Record<string, string | boolean | number>} */
|
|
41
41
|
const result = {}
|
|
42
42
|
/** @type {HTMLElement[]} */
|
|
43
43
|
const swalParams = Array.from(templateContent.querySelectorAll('swal-param'))
|
|
@@ -61,10 +61,10 @@ const getSwalParams = (templateContent) => {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* @param {DocumentFragment} templateContent
|
|
64
|
-
* @returns {Record<string,
|
|
64
|
+
* @returns {Record<string, () => void>}
|
|
65
65
|
*/
|
|
66
66
|
const getSwalFunctionParams = (templateContent) => {
|
|
67
|
-
/** @type {Record<string,
|
|
67
|
+
/** @type {Record<string, () => void>} */
|
|
68
68
|
const result = {}
|
|
69
69
|
/** @type {HTMLElement[]} */
|
|
70
70
|
const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'))
|
|
@@ -81,10 +81,10 @@ const getSwalFunctionParams = (templateContent) => {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* @param {DocumentFragment} templateContent
|
|
84
|
-
* @returns {Record<string,
|
|
84
|
+
* @returns {Record<string, string | boolean>}
|
|
85
85
|
*/
|
|
86
86
|
const getSwalButtons = (templateContent) => {
|
|
87
|
-
/** @type {Record<string,
|
|
87
|
+
/** @type {Record<string, string | boolean>} */
|
|
88
88
|
const result = {}
|
|
89
89
|
/** @type {HTMLElement[]} */
|
|
90
90
|
const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'))
|
|
@@ -134,7 +134,7 @@ const getSwalImage = (templateContent) => {
|
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
* @param {DocumentFragment} templateContent
|
|
137
|
-
* @returns {
|
|
137
|
+
* @returns {object}
|
|
138
138
|
*/
|
|
139
139
|
const getSwalIcon = (templateContent) => {
|
|
140
140
|
const result = {}
|
|
@@ -155,10 +155,10 @@ const getSwalIcon = (templateContent) => {
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* @param {DocumentFragment} templateContent
|
|
158
|
-
* @returns {
|
|
158
|
+
* @returns {object}
|
|
159
159
|
*/
|
|
160
160
|
const getSwalInput = (templateContent) => {
|
|
161
|
-
/** @type {
|
|
161
|
+
/** @type {object} */
|
|
162
162
|
const result = {}
|
|
163
163
|
/** @type {HTMLElement | null} */
|
|
164
164
|
const input = templateContent.querySelector('swal-input')
|
|
@@ -195,10 +195,10 @@ const getSwalInput = (templateContent) => {
|
|
|
195
195
|
/**
|
|
196
196
|
* @param {DocumentFragment} templateContent
|
|
197
197
|
* @param {string[]} paramNames
|
|
198
|
-
* @returns {Record<string,
|
|
198
|
+
* @returns {Record<string, string>}
|
|
199
199
|
*/
|
|
200
200
|
const getSwalStringParams = (templateContent, paramNames) => {
|
|
201
|
-
/** @type {Record<string,
|
|
201
|
+
/** @type {Record<string, string>} */
|
|
202
202
|
const result = {}
|
|
203
203
|
for (const i in paramNames) {
|
|
204
204
|
const paramName = paramNames[i]
|
package/src/utils/iosFix.js
CHANGED
package/src/utils/openPopup.js
CHANGED
|
@@ -43,8 +43,6 @@ export const openPopup = (params) => {
|
|
|
43
43
|
setTimeout(() => params.didOpen(popup))
|
|
44
44
|
}
|
|
45
45
|
globalState.eventEmitter.emit('didOpen', popup)
|
|
46
|
-
|
|
47
|
-
dom.removeClass(container, swalClasses['no-transition'])
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
/**
|
|
@@ -59,6 +57,9 @@ const swalOpenAnimationFinished = (event) => {
|
|
|
59
57
|
popup.removeEventListener('animationend', swalOpenAnimationFinished)
|
|
60
58
|
popup.removeEventListener('transitionend', swalOpenAnimationFinished)
|
|
61
59
|
container.style.overflowY = 'auto'
|
|
60
|
+
|
|
61
|
+
// no-transition is added in init() in case one swal is opened right after another
|
|
62
|
+
dom.removeClass(container, swalClasses['no-transition'])
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/**
|
package/src/utils/utils.js
CHANGED
|
@@ -64,25 +64,25 @@ export const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
|
|
|
64
64
|
* If `arg` is a function, call it (with no arguments or context) and return the result.
|
|
65
65
|
* Otherwise, just pass the value through
|
|
66
66
|
*
|
|
67
|
-
* @param {
|
|
68
|
-
* @returns {
|
|
67
|
+
* @param {(() => *) | *} arg
|
|
68
|
+
* @returns {*}
|
|
69
69
|
*/
|
|
70
70
|
export const callIfFunction = (arg) => (typeof arg === 'function' ? arg() : arg)
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* @param {
|
|
73
|
+
* @param {*} arg
|
|
74
74
|
* @returns {boolean}
|
|
75
75
|
*/
|
|
76
76
|
export const hasToPromiseFn = (arg) => arg && typeof arg.toPromise === 'function'
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* @param {
|
|
80
|
-
* @returns {Promise
|
|
79
|
+
* @param {*} arg
|
|
80
|
+
* @returns {Promise<*>}
|
|
81
81
|
*/
|
|
82
82
|
export const asPromise = (arg) => (hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg))
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @param {
|
|
85
|
+
* @param {*} arg
|
|
86
86
|
* @returns {boolean}
|
|
87
87
|
*/
|
|
88
88
|
export const isPromise = (arg) => arg && Promise.resolve(arg) === arg
|
package/sweetalert2.d.ts
CHANGED
|
@@ -500,6 +500,8 @@ declare module 'sweetalert2' {
|
|
|
500
500
|
| 'theme'
|
|
501
501
|
| 'willClose'
|
|
502
502
|
|
|
503
|
+
export type DismissReason = 'cancel' | 'backdrop' | 'close' | 'esc' | 'timer'
|
|
504
|
+
|
|
503
505
|
export interface SweetAlertCustomClass {
|
|
504
506
|
container?: string | readonly string[]
|
|
505
507
|
popup?: string | readonly string[]
|
|
@@ -525,7 +527,7 @@ declare module 'sweetalert2' {
|
|
|
525
527
|
readonly isDenied: boolean
|
|
526
528
|
readonly isDismissed: boolean
|
|
527
529
|
readonly value?: T
|
|
528
|
-
readonly dismiss?:
|
|
530
|
+
readonly dismiss?: DismissReason
|
|
529
531
|
}
|
|
530
532
|
|
|
531
533
|
export type SweetAlertOptions = SweetAlertInputValidator & {
|