sweetalert2 11.2.2 → 11.3.3
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/README.md +13 -9
- package/dist/sweetalert2.all.js +1305 -1216
- package/dist/sweetalert2.all.min.js +2 -2
- package/dist/sweetalert2.css +5 -5
- package/dist/sweetalert2.js +1304 -1215
- package/dist/sweetalert2.min.css +1 -1
- package/dist/sweetalert2.min.js +1 -1
- package/package.json +12 -11
- package/src/SweetAlert.js +169 -1
- package/src/{instanceMethods/buttons-handlers.js → buttons-handlers.js} +7 -7
- package/src/instanceMethods/getInput.js +4 -1
- package/src/instanceMethods/update.js +2 -2
- package/src/instanceMethods.js +0 -1
- package/src/{instanceMethods/keydown-handler.js → keydown-handler.js} +6 -6
- package/src/{instanceMethods/popup-click-handler.js → popup-click-handler.js} +15 -11
- package/src/staticMethods/showLoading.js +1 -1
- package/src/sweetalert2.js +1 -0
- package/src/utils/Timer.js +1 -1
- package/src/utils/dom/domUtils.js +66 -13
- package/src/utils/dom/getters.js +5 -0
- package/src/utils/dom/init.js +7 -9
- package/src/utils/dom/inputUtils.js +3 -3
- package/src/utils/dom/renderers/renderInput.js +4 -3
- package/src/utils/dom/renderers/renderPopup.js +5 -0
- package/src/utils/iosFix.js +1 -0
- package/src/utils/params.js +5 -3
- package/src/utils/setParameters.js +0 -1
- package/src/variables.scss +4 -4
- package/sweetalert2.d.ts +8 -1
- package/src/instanceMethods/_main.js +0 -168
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isVisible } from '
|
|
2
|
-
import { getInputValue } from '
|
|
3
|
-
import { getDenyButton, getValidationMessage } from '
|
|
4
|
-
import { asPromise } from '
|
|
5
|
-
import { showLoading } from '
|
|
6
|
-
import { DismissReason } from '
|
|
7
|
-
import privateProps from '
|
|
1
|
+
import { isVisible } from './utils/dom/domUtils.js'
|
|
2
|
+
import { getInputValue } from './utils/dom/inputUtils.js'
|
|
3
|
+
import { getDenyButton, getValidationMessage } from './utils/dom/getters.js'
|
|
4
|
+
import { asPromise } from './utils/utils.js'
|
|
5
|
+
import { showLoading } from './staticMethods/showLoading.js'
|
|
6
|
+
import { DismissReason } from './utils/DismissReason.js'
|
|
7
|
+
import privateProps from './privateProps.js'
|
|
8
8
|
|
|
9
9
|
export const handleConfirmButtonClick = (instance) => {
|
|
10
10
|
const innerParams = privateProps.innerParams.get(instance)
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as dom from '../utils/dom/index.js'
|
|
2
2
|
import privateProps from '../privateProps.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Gets the input DOM node, this method works with input parameter.
|
|
6
|
+
* @returns {HTMLElement | null}
|
|
7
|
+
*/
|
|
5
8
|
export function getInput (instance) {
|
|
6
9
|
const innerParams = privateProps.innerParams.get(instance || this)
|
|
7
10
|
const domCache = privateProps.domCache.get(instance || this)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as dom from '../../src/utils/dom/index.js'
|
|
2
2
|
import { warn } from '../../src/utils/utils.js'
|
|
3
|
-
import sweetAlert from '../sweetalert2.js'
|
|
4
3
|
import privateProps from '../privateProps.js'
|
|
4
|
+
import { isUpdatableParameter } from '../../src/utils/params.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Updates popup parameters.
|
|
@@ -18,7 +18,7 @@ export function update (params) {
|
|
|
18
18
|
|
|
19
19
|
// assign valid params from `params` to `defaults`
|
|
20
20
|
Object.keys(params).forEach(param => {
|
|
21
|
-
if (
|
|
21
|
+
if (isUpdatableParameter(param)) {
|
|
22
22
|
validUpdatableParams[param] = params[param]
|
|
23
23
|
} else {
|
|
24
24
|
warn(`Invalid parameter to update: "${param}". Updatable params are listed here: https://github.com/sweetalert2/sweetalert2/blob/master/src/utils/params.js\n\nIf you think this parameter should be updatable, request it here: https://github.com/sweetalert2/sweetalert2/issues/new?template=02_feature_request.md`)
|
package/src/instanceMethods.js
CHANGED
|
@@ -4,6 +4,5 @@ export * from './instanceMethods/close.js'
|
|
|
4
4
|
export * from './instanceMethods/enable-disable-elements.js'
|
|
5
5
|
export * from './instanceMethods/validation-message.js'
|
|
6
6
|
export * from './instanceMethods/progress-steps.js'
|
|
7
|
-
export * from './instanceMethods/_main.js'
|
|
8
7
|
export * from './instanceMethods/update.js'
|
|
9
8
|
export * from './instanceMethods/_destroy.js'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as dom from '
|
|
2
|
-
import { DismissReason } from '
|
|
3
|
-
import { callIfFunction } from '
|
|
4
|
-
import { clickConfirm } from '
|
|
5
|
-
import privateProps from '
|
|
1
|
+
import * as dom from './utils/dom/index.js'
|
|
2
|
+
import { DismissReason } from './utils/DismissReason.js'
|
|
3
|
+
import { callIfFunction } from './utils/utils.js'
|
|
4
|
+
import { clickConfirm } from './staticMethods/dom.js'
|
|
5
|
+
import privateProps from './privateProps.js'
|
|
6
6
|
|
|
7
7
|
export const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
|
|
8
8
|
if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
|
|
@@ -126,7 +126,7 @@ const handleArrows = (key) => {
|
|
|
126
126
|
}
|
|
127
127
|
const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling'
|
|
128
128
|
const buttonToFocus = document.activeElement[sibling]
|
|
129
|
-
if (buttonToFocus) {
|
|
129
|
+
if (buttonToFocus instanceof HTMLElement) {
|
|
130
130
|
buttonToFocus.focus()
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { callIfFunction } from '
|
|
2
|
-
import { DismissReason } from '
|
|
3
|
-
import privateProps from '
|
|
1
|
+
import { callIfFunction } from './utils/utils.js'
|
|
2
|
+
import { DismissReason } from './utils/DismissReason.js'
|
|
3
|
+
import privateProps from './privateProps.js'
|
|
4
4
|
|
|
5
5
|
export const handlePopupClick = (instance, domCache, dismissWith) => {
|
|
6
6
|
const innerParams = privateProps.innerParams.get(instance)
|
|
@@ -22,20 +22,24 @@ const handleToastClick = (instance, domCache, dismissWith) => {
|
|
|
22
22
|
// Closing toast by internal click
|
|
23
23
|
domCache.popup.onclick = () => {
|
|
24
24
|
const innerParams = privateProps.innerParams.get(instance)
|
|
25
|
-
if (
|
|
26
|
-
innerParams.showConfirmButton ||
|
|
27
|
-
innerParams.showDenyButton ||
|
|
28
|
-
innerParams.showCancelButton ||
|
|
29
|
-
innerParams.showCloseButton ||
|
|
30
|
-
innerParams.timer ||
|
|
31
|
-
innerParams.input
|
|
32
|
-
) {
|
|
25
|
+
if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
|
|
33
26
|
return
|
|
34
27
|
}
|
|
35
28
|
dismissWith(DismissReason.close)
|
|
36
29
|
}
|
|
37
30
|
}
|
|
38
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @param {*} innerParams
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
const isAnyButtonShown = (innerParams) => {
|
|
37
|
+
return innerParams.showConfirmButton ||
|
|
38
|
+
innerParams.showDenyButton ||
|
|
39
|
+
innerParams.showCancelButton ||
|
|
40
|
+
innerParams.showCloseButton
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
let ignoreOutsideClick = false
|
|
40
44
|
|
|
41
45
|
const handleModalMousedown = (domCache) => {
|
|
@@ -9,7 +9,7 @@ import { swalClasses } from '../utils/classes.js'
|
|
|
9
9
|
const showLoading = (buttonToReplace) => {
|
|
10
10
|
let popup = dom.getPopup()
|
|
11
11
|
if (!popup) {
|
|
12
|
-
Swal
|
|
12
|
+
new Swal() // eslint-disable-line no-new
|
|
13
13
|
}
|
|
14
14
|
popup = dom.getPopup()
|
|
15
15
|
const loader = dom.getLoader()
|
package/src/sweetalert2.js
CHANGED
package/src/utils/Timer.js
CHANGED
|
@@ -7,7 +7,14 @@ export const states = {
|
|
|
7
7
|
previousBodyPadding: null
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Securely set innerHTML of an element
|
|
12
|
+
* https://github.com/sweetalert2/sweetalert2/issues/1926
|
|
13
|
+
*
|
|
14
|
+
* @param {HTMLElement} elem
|
|
15
|
+
* @param {string} html
|
|
16
|
+
*/
|
|
17
|
+
export const setInnerHtml = (elem, html) => {
|
|
11
18
|
elem.textContent = ''
|
|
12
19
|
if (html) {
|
|
13
20
|
const parser = new DOMParser()
|
|
@@ -21,6 +28,11 @@ export const setInnerHtml = (elem, html) => { // #1926
|
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @param {HTMLElement} elem
|
|
33
|
+
* @param {string} className
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
24
36
|
export const hasClass = (elem, className) => {
|
|
25
37
|
if (!className) {
|
|
26
38
|
return false
|
|
@@ -58,6 +70,11 @@ export const applyCustomClass = (elem, params, className) => {
|
|
|
58
70
|
}
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {HTMLElement} popup
|
|
75
|
+
* @param {string} inputType
|
|
76
|
+
* @returns {HTMLInputElement | null}
|
|
77
|
+
*/
|
|
61
78
|
export const getInput = (popup, inputType) => {
|
|
62
79
|
if (!inputType) {
|
|
63
80
|
return null
|
|
@@ -66,19 +83,22 @@ export const getInput = (popup, inputType) => {
|
|
|
66
83
|
case 'select':
|
|
67
84
|
case 'textarea':
|
|
68
85
|
case 'file':
|
|
69
|
-
return
|
|
86
|
+
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputType]}`)
|
|
70
87
|
case 'checkbox':
|
|
71
|
-
return popup.querySelector(`.${swalClasses.checkbox} input`)
|
|
88
|
+
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`)
|
|
72
89
|
case 'radio':
|
|
73
|
-
return popup.querySelector(`.${swalClasses.radio} input:checked`) ||
|
|
74
|
-
popup.querySelector(`.${swalClasses.radio} input:first-child`)
|
|
90
|
+
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) ||
|
|
91
|
+
popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`)
|
|
75
92
|
case 'range':
|
|
76
|
-
return popup.querySelector(`.${swalClasses.range} input`)
|
|
93
|
+
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`)
|
|
77
94
|
default:
|
|
78
|
-
return
|
|
95
|
+
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`)
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @param {HTMLInputElement} input
|
|
101
|
+
*/
|
|
82
102
|
export const focusInput = (input) => {
|
|
83
103
|
input.focus()
|
|
84
104
|
|
|
@@ -91,6 +111,11 @@ export const focusInput = (input) => {
|
|
|
91
111
|
}
|
|
92
112
|
}
|
|
93
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @param {HTMLElement | HTMLElement[] | null} target
|
|
116
|
+
* @param {string | string[]} classList
|
|
117
|
+
* @param {boolean} condition
|
|
118
|
+
*/
|
|
94
119
|
export const toggleClass = (target, classList, condition) => {
|
|
95
120
|
if (!target || !classList) {
|
|
96
121
|
return
|
|
@@ -99,7 +124,7 @@ export const toggleClass = (target, classList, condition) => {
|
|
|
99
124
|
classList = classList.split(/\s+/).filter(Boolean)
|
|
100
125
|
}
|
|
101
126
|
classList.forEach((className) => {
|
|
102
|
-
if (target
|
|
127
|
+
if (Array.isArray(target)) {
|
|
103
128
|
target.forEach((elem) => {
|
|
104
129
|
condition ? elem.classList.add(className) : elem.classList.remove(className)
|
|
105
130
|
})
|
|
@@ -109,22 +134,43 @@ export const toggleClass = (target, classList, condition) => {
|
|
|
109
134
|
})
|
|
110
135
|
}
|
|
111
136
|
|
|
137
|
+
/**
|
|
138
|
+
* @param {HTMLElement | HTMLElement[] | null} target
|
|
139
|
+
* @param {string | string[]} classList
|
|
140
|
+
*/
|
|
112
141
|
export const addClass = (target, classList) => {
|
|
113
142
|
toggleClass(target, classList, true)
|
|
114
143
|
}
|
|
115
144
|
|
|
145
|
+
/**
|
|
146
|
+
* @param {HTMLElement | HTMLElement[] | null} target
|
|
147
|
+
* @param {string | string[]} classList
|
|
148
|
+
*/
|
|
116
149
|
export const removeClass = (target, classList) => {
|
|
117
150
|
toggleClass(target, classList, false)
|
|
118
151
|
}
|
|
119
152
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Get direct child of an element by class name
|
|
155
|
+
*
|
|
156
|
+
* @param {HTMLElement} elem
|
|
157
|
+
* @param {string} className
|
|
158
|
+
* @returns {HTMLElement | null}
|
|
159
|
+
*/
|
|
160
|
+
export const getDirectChildByClass = (elem, className) => {
|
|
161
|
+
const childNodes = toArray(elem.childNodes)
|
|
162
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
163
|
+
if (hasClass(childNodes[i], className)) {
|
|
164
|
+
return childNodes[i]
|
|
124
165
|
}
|
|
125
166
|
}
|
|
126
167
|
}
|
|
127
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @param {HTMLElement} elem
|
|
171
|
+
* @param {string} property
|
|
172
|
+
* @param {*} value
|
|
173
|
+
*/
|
|
128
174
|
export const applyNumericalStyle = (elem, property, value) => {
|
|
129
175
|
if (value === `${parseInt(value)}`) {
|
|
130
176
|
value = parseInt(value)
|
|
@@ -136,10 +182,17 @@ export const applyNumericalStyle = (elem, property, value) => {
|
|
|
136
182
|
}
|
|
137
183
|
}
|
|
138
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @param {HTMLElement} elem
|
|
187
|
+
* @param {string} display
|
|
188
|
+
*/
|
|
139
189
|
export const show = (elem, display = 'flex') => {
|
|
140
190
|
elem.style.display = display
|
|
141
191
|
}
|
|
142
192
|
|
|
193
|
+
/**
|
|
194
|
+
* @param {HTMLElement} elem
|
|
195
|
+
*/
|
|
143
196
|
export const hide = (elem) => {
|
|
144
197
|
elem.style.display = 'none'
|
|
145
198
|
}
|
|
@@ -192,7 +245,7 @@ export const stopTimerProgressBar = () => {
|
|
|
192
245
|
timerProgressBar.style.removeProperty('transition')
|
|
193
246
|
timerProgressBar.style.width = '100%'
|
|
194
247
|
const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width)
|
|
195
|
-
const timerProgressBarPercent =
|
|
248
|
+
const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100
|
|
196
249
|
timerProgressBar.style.removeProperty('transition')
|
|
197
250
|
timerProgressBar.style.width = `${timerProgressBarPercent}%`
|
|
198
251
|
}
|
package/src/utils/dom/getters.js
CHANGED
|
@@ -2,6 +2,11 @@ import { swalClasses } from '../classes.js'
|
|
|
2
2
|
import { uniqueArray, toArray } from '../utils.js'
|
|
3
3
|
import { isVisible, hasClass } from './domUtils.js'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Gets the popup container which contains the backdrop and the popup itself.
|
|
7
|
+
*
|
|
8
|
+
* @returns {HTMLElement | null}
|
|
9
|
+
*/
|
|
5
10
|
export const getContainer = () => document.body.querySelector(`.${swalClasses.container}`)
|
|
6
11
|
|
|
7
12
|
export const elementBySelector = (selectorString) => {
|
package/src/utils/dom/init.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { swalClasses } from '../classes.js'
|
|
2
2
|
import { getContainer, getPopup } from './getters.js'
|
|
3
|
-
import { addClass, removeClass,
|
|
3
|
+
import { addClass, removeClass, getDirectChildByClass, setInnerHtml } from './domUtils.js'
|
|
4
4
|
import { isNodeEnv } from '../isNodeEnv.js'
|
|
5
5
|
import { error } from '../utils.js'
|
|
6
|
-
import
|
|
6
|
+
import globalState from '../../globalState.js'
|
|
7
7
|
|
|
8
8
|
const sweetHTML = `
|
|
9
9
|
<div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
|
|
@@ -60,21 +60,19 @@ const resetOldContainer = () => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const resetValidationMessage = () => {
|
|
63
|
-
|
|
64
|
-
sweetAlert.resetValidationMessage()
|
|
65
|
-
}
|
|
63
|
+
globalState.currentInstance.resetValidationMessage()
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
const addInputChangeListeners = () => {
|
|
69
67
|
const popup = getPopup()
|
|
70
68
|
|
|
71
|
-
const input =
|
|
72
|
-
const file =
|
|
69
|
+
const input = getDirectChildByClass(popup, swalClasses.input)
|
|
70
|
+
const file = getDirectChildByClass(popup, swalClasses.file)
|
|
73
71
|
const range = popup.querySelector(`.${swalClasses.range} input`)
|
|
74
72
|
const rangeOutput = popup.querySelector(`.${swalClasses.range} output`)
|
|
75
|
-
const select =
|
|
73
|
+
const select = getDirectChildByClass(popup, swalClasses.select)
|
|
76
74
|
const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`)
|
|
77
|
-
const textarea =
|
|
75
|
+
const textarea = getDirectChildByClass(popup, swalClasses.textarea)
|
|
78
76
|
|
|
79
77
|
input.oninput = resetValidationMessage
|
|
80
78
|
file.onchange = resetValidationMessage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as dom from './index.js'
|
|
2
2
|
import { swalClasses } from '../classes.js'
|
|
3
|
-
import {
|
|
3
|
+
import { getDirectChildByClass } from './domUtils.js'
|
|
4
4
|
import { asPromise, error, hasToPromiseFn, isPromise } from '../utils.js'
|
|
5
5
|
import { showLoading } from '../../staticMethods/showLoading.js'
|
|
6
6
|
|
|
@@ -75,7 +75,7 @@ const handleInputValue = (instance, params) => {
|
|
|
75
75
|
|
|
76
76
|
const populateInputOptions = {
|
|
77
77
|
select: (popup, inputOptions, params) => {
|
|
78
|
-
const select =
|
|
78
|
+
const select = getDirectChildByClass(popup, swalClasses.select)
|
|
79
79
|
const renderOption = (parent, optionLabel, optionValue) => {
|
|
80
80
|
const option = document.createElement('option')
|
|
81
81
|
option.value = optionValue
|
|
@@ -104,7 +104,7 @@ const populateInputOptions = {
|
|
|
104
104
|
},
|
|
105
105
|
|
|
106
106
|
radio: (popup, inputOptions, params) => {
|
|
107
|
-
const radio =
|
|
107
|
+
const radio = getDirectChildByClass(popup, swalClasses.radio)
|
|
108
108
|
inputOptions.forEach(inputOption => {
|
|
109
109
|
const radioValue = inputOption[0]
|
|
110
110
|
const radioLabel = inputOption[1]
|
|
@@ -12,7 +12,7 @@ export const renderInput = (instance, params) => {
|
|
|
12
12
|
|
|
13
13
|
inputTypes.forEach((inputType) => {
|
|
14
14
|
const inputClass = swalClasses[inputType]
|
|
15
|
-
const inputContainer = dom.
|
|
15
|
+
const inputContainer = dom.getDirectChildByClass(popup, inputClass)
|
|
16
16
|
|
|
17
17
|
// set attributes
|
|
18
18
|
setAttributes(inputType, params.inputAttributes)
|
|
@@ -99,7 +99,7 @@ const setInputLabel = (input, prependTo, params) => {
|
|
|
99
99
|
|
|
100
100
|
const getInputContainer = (inputType) => {
|
|
101
101
|
const inputClass = swalClasses[inputType] ? swalClasses[inputType] : swalClasses.input
|
|
102
|
-
return dom.
|
|
102
|
+
return dom.getDirectChildByClass(dom.getPopup(), inputClass)
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const renderInputType = {}
|
|
@@ -157,8 +157,9 @@ renderInputType.radio = (radio) => {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
renderInputType.checkbox = (checkboxContainer, params) => {
|
|
160
|
+
/** @type {HTMLInputElement} */
|
|
160
161
|
const checkbox = dom.getInput(dom.getPopup(), 'checkbox')
|
|
161
|
-
checkbox.value = 1
|
|
162
|
+
checkbox.value = '1'
|
|
162
163
|
checkbox.id = swalClasses.checkbox
|
|
163
164
|
checkbox.checked = Boolean(params.inputValue)
|
|
164
165
|
const label = checkboxContainer.querySelector('span')
|
|
@@ -17,6 +17,11 @@ export const renderPopup = (instance, params) => {
|
|
|
17
17
|
// Padding
|
|
18
18
|
dom.applyNumericalStyle(popup, 'padding', params.padding)
|
|
19
19
|
|
|
20
|
+
// Color
|
|
21
|
+
if (params.color) {
|
|
22
|
+
popup.style.color = params.color
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
// Background
|
|
21
26
|
if (params.background) {
|
|
22
27
|
popup.style.background = params.background
|
package/src/utils/iosFix.js
CHANGED
|
@@ -5,6 +5,7 @@ import { swalClasses } from '../utils/classes.js'
|
|
|
5
5
|
// Fix iOS scrolling http://stackoverflow.com/q/39626302
|
|
6
6
|
|
|
7
7
|
export const iOSfix = () => {
|
|
8
|
+
// @ts-ignore
|
|
8
9
|
const iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
|
|
9
10
|
if (iOS && !dom.hasClass(document.body, swalClasses.iosfix)) {
|
|
10
11
|
const offset = document.body.scrollTop
|
package/src/utils/params.js
CHANGED
|
@@ -23,6 +23,7 @@ export const defaultParams = {
|
|
|
23
23
|
},
|
|
24
24
|
customClass: {},
|
|
25
25
|
target: 'body',
|
|
26
|
+
color: undefined,
|
|
26
27
|
backdrop: true,
|
|
27
28
|
heightAuto: true,
|
|
28
29
|
allowOutsideClick: true,
|
|
@@ -99,6 +100,7 @@ export const updatableParams = [
|
|
|
99
100
|
'cancelButtonText',
|
|
100
101
|
'closeButtonAriaLabel',
|
|
101
102
|
'closeButtonHtml',
|
|
103
|
+
'color',
|
|
102
104
|
'confirmButtonAriaLabel',
|
|
103
105
|
'confirmButtonColor',
|
|
104
106
|
'confirmButtonText',
|
|
@@ -150,7 +152,7 @@ const toastIncompatibleParams = [
|
|
|
150
152
|
|
|
151
153
|
/**
|
|
152
154
|
* Is valid parameter
|
|
153
|
-
* @param {
|
|
155
|
+
* @param {string} paramName
|
|
154
156
|
*/
|
|
155
157
|
export const isValidParameter = (paramName) => {
|
|
156
158
|
return Object.prototype.hasOwnProperty.call(defaultParams, paramName)
|
|
@@ -158,7 +160,7 @@ export const isValidParameter = (paramName) => {
|
|
|
158
160
|
|
|
159
161
|
/**
|
|
160
162
|
* Is valid parameter for Swal.update() method
|
|
161
|
-
* @param {
|
|
163
|
+
* @param {string} paramName
|
|
162
164
|
*/
|
|
163
165
|
export const isUpdatableParameter = (paramName) => {
|
|
164
166
|
return updatableParams.indexOf(paramName) !== -1
|
|
@@ -166,7 +168,7 @@ export const isUpdatableParameter = (paramName) => {
|
|
|
166
168
|
|
|
167
169
|
/**
|
|
168
170
|
* Is deprecated parameter
|
|
169
|
-
* @param {
|
|
171
|
+
* @param {string} paramName
|
|
170
172
|
*/
|
|
171
173
|
export const isDeprecatedParameter = (paramName) => {
|
|
172
174
|
return deprecatedParams[paramName]
|
package/src/variables.scss
CHANGED
|
@@ -51,7 +51,7 @@ $swal2-title-position: relative !default;
|
|
|
51
51
|
$swal2-title-max-width: 100% !default;
|
|
52
52
|
$swal2-title-margin: 0 !default;
|
|
53
53
|
$swal2-title-padding: .8em 1em 0 !default;
|
|
54
|
-
$swal2-title-color:
|
|
54
|
+
$swal2-title-color: inherit !default;
|
|
55
55
|
$swal2-title-font-size: 1.875em !default;
|
|
56
56
|
$swal2-title-font-weight: 600 !default;
|
|
57
57
|
$swal2-title-text-align: center !default;
|
|
@@ -61,7 +61,7 @@ $swal2-html-container-justify-content: center !default;
|
|
|
61
61
|
$swal2-html-container-margin: 1em 1.6em .3em !default;
|
|
62
62
|
$swal2-html-container-padding: 0 !default;
|
|
63
63
|
$swal2-html-container-overflow: auto !default;
|
|
64
|
-
$swal2-html-container-color:
|
|
64
|
+
$swal2-html-container-color: inherit !default;
|
|
65
65
|
$swal2-html-container-font-size: 1.125em !default;
|
|
66
66
|
$swal2-html-container-font-weight: normal !default;
|
|
67
67
|
$swal2-html-container-line-height: normal !default;
|
|
@@ -70,7 +70,7 @@ $swal2-html-container-word-wrap: break-word !default;
|
|
|
70
70
|
$swal2-html-container-word-break: break-word !default;
|
|
71
71
|
|
|
72
72
|
// INPUT
|
|
73
|
-
$swal2-input-margin: 1em 2em
|
|
73
|
+
$swal2-input-margin: 1em 2em 3px !default;
|
|
74
74
|
$swal2-input-width: auto !default;
|
|
75
75
|
$swal2-input-height: 2.625em !default;
|
|
76
76
|
$swal2-input-padding: 0 .75em !default;
|
|
@@ -129,7 +129,7 @@ $swal2-active-step-color: $swal2-white !default;
|
|
|
129
129
|
$swal2-footer-margin: 1em 0 0 !default;
|
|
130
130
|
$swal2-footer-padding: 1em 1em 0 !default;
|
|
131
131
|
$swal2-footer-border-color: #eee !default;
|
|
132
|
-
$swal2-footer-color:
|
|
132
|
+
$swal2-footer-color: inherit !default;
|
|
133
133
|
$swal2-footer-font-size: 1em !default;
|
|
134
134
|
|
|
135
135
|
// TIMER POGRESS BAR
|
package/sweetalert2.d.ts
CHANGED
|
@@ -580,7 +580,14 @@ declare module 'sweetalert2' {
|
|
|
580
580
|
padding?: number | string;
|
|
581
581
|
|
|
582
582
|
/**
|
|
583
|
-
*
|
|
583
|
+
* Color for title, content and footer (CSS `color` property). The default color is `#545454`.
|
|
584
|
+
*
|
|
585
|
+
* @default undefined
|
|
586
|
+
*/
|
|
587
|
+
color?: string;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Popup background (CSS `background` property). The default background is `#fff`.
|
|
584
591
|
*
|
|
585
592
|
* @default undefined
|
|
586
593
|
*/
|