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.
@@ -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, any>}
37
+ * @returns {Record<string, string | boolean | number>}
38
38
  */
39
39
  const getSwalParams = (templateContent) => {
40
- /** @type {Record<string, any>} */
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, any>}
64
+ * @returns {Record<string, () => void>}
65
65
  */
66
66
  const getSwalFunctionParams = (templateContent) => {
67
- /** @type {Record<string, any>} */
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, any>}
84
+ * @returns {Record<string, string | boolean>}
85
85
  */
86
86
  const getSwalButtons = (templateContent) => {
87
- /** @type {Record<string, any>} */
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 {Record<string, any>}
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 {Record<string, any>}
158
+ * @returns {object}
159
159
  */
160
160
  const getSwalInput = (templateContent) => {
161
- /** @type {Record<string, any>} */
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, any>}
198
+ * @returns {Record<string, string>}
199
199
  */
200
200
  const getSwalStringParams = (templateContent, paramNames) => {
201
- /** @type {Record<string, any>} */
201
+ /** @type {Record<string, string>} */
202
202
  const result = {}
203
203
  for (const i in paramNames) {
204
204
  const paramName = paramNames[i]
@@ -80,7 +80,7 @@ const shouldPreventTouchMove = (event) => {
80
80
  /**
81
81
  * https://github.com/sweetalert2/sweetalert2/issues/1786
82
82
  *
83
- * @param {*} event
83
+ * @param {object} event
84
84
  * @returns {boolean}
85
85
  */
86
86
  const isStylus = (event) => {
@@ -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
  /**
@@ -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 {Function | any} arg
68
- * @returns {any}
67
+ * @param {(() => *) | *} arg
68
+ * @returns {*}
69
69
  */
70
70
  export const callIfFunction = (arg) => (typeof arg === 'function' ? arg() : arg)
71
71
 
72
72
  /**
73
- * @param {any} arg
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 {any} arg
80
- * @returns {Promise<any>}
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 {any} arg
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?: Swal.DismissReason
530
+ readonly dismiss?: DismissReason
529
531
  }
530
532
 
531
533
  export type SweetAlertOptions = SweetAlertInputValidator & {