sweetalert2 11.3.5 → 11.3.9
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/CHANGELOG.md +2272 -0
- package/README.md +4 -6
- package/package.json +8 -5
- package/src/SweetAlert.js +12 -11
- package/src/buttons-handlers.js +27 -27
- package/src/globalState.js +1 -1
- package/src/instanceMethods/_destroy.js +1 -1
- package/src/instanceMethods/close.js +25 -23
- package/src/instanceMethods/enable-disable-elements.js +7 -7
- package/src/instanceMethods/getInput.js +1 -1
- package/src/instanceMethods/hideLoading.js +2 -5
- package/src/instanceMethods/progress-steps.js +1 -1
- package/src/instanceMethods/update.js +20 -13
- package/src/instanceMethods/validation-message.js +2 -2
- package/src/keydown-handler.js +22 -16
- package/src/popup-click-handler.js +3 -1
- package/src/privateMethods.js +1 -1
- package/src/privateProps.js +1 -1
- package/src/staticMethods/argsToParams.js +1 -1
- package/src/staticMethods/bindClickHandler.js +1 -1
- package/src/staticMethods/dom.js +1 -1
- package/src/staticMethods/fire.js +2 -2
- package/src/staticMethods/mixin.js +2 -2
- package/src/staticMethods/showLoading.js +1 -4
- package/src/staticMethods.js +1 -5
- package/src/utils/DismissReason.js +1 -1
- package/src/utils/Timer.js +6 -6
- package/src/utils/aria.js +2 -2
- package/src/utils/classes.js +1 -7
- package/src/utils/defaultInputValidators.js +1 -1
- package/src/utils/dom/animationEndEvent.js +1 -1
- package/src/utils/dom/domUtils.js +16 -9
- package/src/utils/dom/getters.js +7 -7
- package/src/utils/dom/init.js +3 -7
- package/src/utils/dom/inputUtils.js +26 -19
- package/src/utils/dom/parseHtmlToContainer.js +14 -3
- package/src/utils/dom/renderers/renderActions.js +3 -3
- package/src/utils/dom/renderers/renderContainer.js +3 -3
- package/src/utils/dom/renderers/renderContent.js +4 -2
- package/src/utils/dom/renderers/renderIcon.js +24 -15
- package/src/utils/dom/renderers/renderInput.js +30 -21
- package/src/utils/dom/renderers/renderPopup.js +2 -1
- package/src/utils/dom/renderers/renderProgressSteps.js +1 -1
- package/src/utils/getTemplateParams.js +36 -5
- package/src/utils/iosFix.js +16 -5
- package/src/utils/isNodeEnv.js +5 -1
- package/src/utils/params.js +2 -2
- package/src/utils/setParameters.js +5 -5
- package/src/utils/utils.js +5 -3
- package/dist/sweetalert2.all.js +0 -3317
- package/dist/sweetalert2.all.min.js +0 -2
- package/dist/sweetalert2.css +0 -1400
- package/dist/sweetalert2.js +0 -3315
- package/dist/sweetalert2.min.css +0 -1
- package/dist/sweetalert2.min.js +0 -1
package/src/staticMethods/dom.js
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @param mixinParams
|
|
18
18
|
*/
|
|
19
|
-
export function mixin
|
|
19
|
+
export function mixin(mixinParams) {
|
|
20
20
|
class MixinSwal extends this {
|
|
21
|
-
_main
|
|
21
|
+
_main(params, priorityMixinParams) {
|
|
22
22
|
return super._main(params, Object.assign({}, mixinParams, priorityMixinParams))
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/staticMethods.js
CHANGED
|
@@ -5,8 +5,4 @@ export * from './staticMethods/mixin.js'
|
|
|
5
5
|
export * from './staticMethods/showLoading.js'
|
|
6
6
|
export * from './staticMethods/timer.js'
|
|
7
7
|
export * from './staticMethods/bindClickHandler.js'
|
|
8
|
-
export {
|
|
9
|
-
isValidParameter,
|
|
10
|
-
isUpdatableParameter,
|
|
11
|
-
isDeprecatedParameter
|
|
12
|
-
} from './utils/params.js'
|
|
8
|
+
export { isValidParameter, isUpdatableParameter, isDeprecatedParameter } from './utils/params.js'
|
package/src/utils/Timer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default class Timer {
|
|
2
|
-
constructor
|
|
2
|
+
constructor(callback, delay) {
|
|
3
3
|
this.callback = callback
|
|
4
4
|
this.remaining = delay
|
|
5
5
|
this.running = false
|
|
@@ -7,7 +7,7 @@ export default class Timer {
|
|
|
7
7
|
this.start()
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
start
|
|
10
|
+
start() {
|
|
11
11
|
if (!this.running) {
|
|
12
12
|
this.running = true
|
|
13
13
|
this.started = new Date()
|
|
@@ -16,7 +16,7 @@ export default class Timer {
|
|
|
16
16
|
return this.remaining
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
stop
|
|
19
|
+
stop() {
|
|
20
20
|
if (this.running) {
|
|
21
21
|
this.running = false
|
|
22
22
|
clearTimeout(this.id)
|
|
@@ -25,7 +25,7 @@ export default class Timer {
|
|
|
25
25
|
return this.remaining
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
increase
|
|
28
|
+
increase(n) {
|
|
29
29
|
const running = this.running
|
|
30
30
|
if (running) {
|
|
31
31
|
this.stop()
|
|
@@ -37,7 +37,7 @@ export default class Timer {
|
|
|
37
37
|
return this.remaining
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
getTimerLeft
|
|
40
|
+
getTimerLeft() {
|
|
41
41
|
if (this.running) {
|
|
42
42
|
this.stop()
|
|
43
43
|
this.start()
|
|
@@ -45,7 +45,7 @@ export default class Timer {
|
|
|
45
45
|
return this.remaining
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
isRunning
|
|
48
|
+
isRunning() {
|
|
49
49
|
return this.running
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/utils/aria.js
CHANGED
|
@@ -8,7 +8,7 @@ import { toArray } from './utils.js'
|
|
|
8
8
|
|
|
9
9
|
export const setAriaHidden = () => {
|
|
10
10
|
const bodyChildren = toArray(document.body.children)
|
|
11
|
-
bodyChildren.forEach(el => {
|
|
11
|
+
bodyChildren.forEach((el) => {
|
|
12
12
|
if (el === getContainer() || el.contains(getContainer())) {
|
|
13
13
|
return
|
|
14
14
|
}
|
|
@@ -22,7 +22,7 @@ export const setAriaHidden = () => {
|
|
|
22
22
|
|
|
23
23
|
export const unsetAriaHidden = () => {
|
|
24
24
|
const bodyChildren = toArray(document.body.children)
|
|
25
|
-
bodyChildren.forEach(el => {
|
|
25
|
+
bodyChildren.forEach((el) => {
|
|
26
26
|
if (el.hasAttribute('data-previous-aria-hidden')) {
|
|
27
27
|
el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden'))
|
|
28
28
|
el.removeAttribute('data-previous-aria-hidden')
|
package/src/utils/classes.js
CHANGED
|
@@ -80,10 +80,4 @@ export const swalClasses = prefix([
|
|
|
80
80
|
'icon-error',
|
|
81
81
|
])
|
|
82
82
|
|
|
83
|
-
export const iconTypes = prefix([
|
|
84
|
-
'success',
|
|
85
|
-
'warning',
|
|
86
|
-
'info',
|
|
87
|
-
'question',
|
|
88
|
-
'error'
|
|
89
|
-
])
|
|
83
|
+
export const iconTypes = prefix(['success', 'warning', 'info', 'question', 'error'])
|
|
@@ -10,7 +10,7 @@ export const animationEndEvent = (() => {
|
|
|
10
10
|
const testEl = document.createElement('div')
|
|
11
11
|
const transEndEventNames = {
|
|
12
12
|
WebkitAnimation: 'webkitAnimationEnd', // Chrome, Safari and Opera
|
|
13
|
-
animation: 'animationend' // Standard syntax
|
|
13
|
+
animation: 'animationend', // Standard syntax
|
|
14
14
|
}
|
|
15
15
|
for (const i in transEndEventNames) {
|
|
16
16
|
if (Object.prototype.hasOwnProperty.call(transEndEventNames, i) && typeof testEl.style[i] !== 'undefined') {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getCancelButton, getConfirmButton, getDenyButton, getTimerProgressBar } from './getters.js'
|
|
2
|
+
import { iconTypes, swalClasses } from '../classes.js'
|
|
3
3
|
import { toArray, warn } from '../utils.js'
|
|
4
4
|
|
|
5
5
|
// Remember state in cases where opening and handling a modal will fiddle with it.
|
|
6
6
|
export const states = {
|
|
7
|
-
previousBodyPadding: null
|
|
7
|
+
previousBodyPadding: null,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -47,7 +47,7 @@ export const hasClass = (elem, className) => {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const removeCustomClasses = (elem, params) => {
|
|
50
|
-
toArray(elem.classList).forEach(className => {
|
|
50
|
+
toArray(elem.classList).forEach((className) => {
|
|
51
51
|
if (
|
|
52
52
|
!Object.values(swalClasses).includes(className) &&
|
|
53
53
|
!Object.values(iconTypes).includes(className) &&
|
|
@@ -63,7 +63,11 @@ export const applyCustomClass = (elem, params, className) => {
|
|
|
63
63
|
|
|
64
64
|
if (params.customClass && params.customClass[className]) {
|
|
65
65
|
if (typeof params.customClass[className] !== 'string' && !params.customClass[className].forEach) {
|
|
66
|
-
return warn(
|
|
66
|
+
return warn(
|
|
67
|
+
`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof params.customClass[
|
|
68
|
+
className
|
|
69
|
+
]}"`
|
|
70
|
+
)
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
addClass(elem, params.customClass[className])
|
|
@@ -87,8 +91,10 @@ export const getInput = (popup, inputType) => {
|
|
|
87
91
|
case 'checkbox':
|
|
88
92
|
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`)
|
|
89
93
|
case 'radio':
|
|
90
|
-
return
|
|
94
|
+
return (
|
|
95
|
+
popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) ||
|
|
91
96
|
popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`)
|
|
97
|
+
)
|
|
92
98
|
case 'range':
|
|
93
99
|
return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`)
|
|
94
100
|
default:
|
|
@@ -176,7 +182,7 @@ export const applyNumericalStyle = (elem, property, value) => {
|
|
|
176
182
|
value = parseInt(value)
|
|
177
183
|
}
|
|
178
184
|
if (value || parseInt(value) === 0) {
|
|
179
|
-
elem.style[property] =
|
|
185
|
+
elem.style[property] = typeof value === 'number' ? `${value}px` : value
|
|
180
186
|
} else {
|
|
181
187
|
elem.style.removeProperty(property)
|
|
182
188
|
}
|
|
@@ -211,7 +217,8 @@ export const toggle = (elem, condition, display) => {
|
|
|
211
217
|
// borrowed from jquery $(elem).is(':visible') implementation
|
|
212
218
|
export const isVisible = (elem) => !!(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length))
|
|
213
219
|
|
|
214
|
-
export const allButtonsAreHidden = () =>
|
|
220
|
+
export const allButtonsAreHidden = () =>
|
|
221
|
+
!isVisible(getConfirmButton()) && !isVisible(getDenyButton()) && !isVisible(getCancelButton())
|
|
215
222
|
|
|
216
223
|
export const isScrollable = (elem) => !!(elem.scrollHeight > elem.clientHeight)
|
|
217
224
|
|
|
@@ -245,7 +252,7 @@ export const stopTimerProgressBar = () => {
|
|
|
245
252
|
timerProgressBar.style.removeProperty('transition')
|
|
246
253
|
timerProgressBar.style.width = '100%'
|
|
247
254
|
const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width)
|
|
248
|
-
const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100
|
|
255
|
+
const timerProgressBarPercent = (timerProgressBarWidth / timerProgressBarFullWidth) * 100
|
|
249
256
|
timerProgressBar.style.removeProperty('transition')
|
|
250
257
|
timerProgressBar.style.width = `${timerProgressBarPercent}%`
|
|
251
258
|
}
|
package/src/utils/dom/getters.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { swalClasses } from '../classes.js'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { toArray, uniqueArray } from '../utils.js'
|
|
3
|
+
import { hasClass, isVisible } from './domUtils.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Gets the popup container which contains the backdrop and the popup itself.
|
|
@@ -72,7 +72,7 @@ export const getFocusableElements = () => {
|
|
|
72
72
|
const focusableElementsWithTabindex = toArray(
|
|
73
73
|
getPopup().querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])')
|
|
74
74
|
)
|
|
75
|
-
|
|
75
|
+
// sort according to tabindex
|
|
76
76
|
.sort((a, b) => {
|
|
77
77
|
const tabindexA = parseInt(a.getAttribute('tabindex'))
|
|
78
78
|
const tabindexB = parseInt(b.getAttribute('tabindex'))
|
|
@@ -84,11 +84,11 @@ export const getFocusableElements = () => {
|
|
|
84
84
|
return 0
|
|
85
85
|
})
|
|
86
86
|
|
|
87
|
-
const otherFocusableElements = toArray(
|
|
88
|
-
|
|
89
|
-
)
|
|
87
|
+
const otherFocusableElements = toArray(getPopup().querySelectorAll(focusable)).filter(
|
|
88
|
+
(el) => el.getAttribute('tabindex') !== '-1'
|
|
89
|
+
)
|
|
90
90
|
|
|
91
|
-
return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter(el => isVisible(el))
|
|
91
|
+
return uniqueArray(focusableElementsWithTabindex.concat(otherFocusableElements)).filter((el) => isVisible(el))
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export const isModal = () => {
|
package/src/utils/dom/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { swalClasses } from '../classes.js'
|
|
2
2
|
import { getContainer, getPopup } from './getters.js'
|
|
3
|
-
import { addClass,
|
|
3
|
+
import { addClass, getDirectChildByClass, removeClass, setInnerHtml } from './domUtils.js'
|
|
4
4
|
import { isNodeEnv } from '../isNodeEnv.js'
|
|
5
5
|
import { error } from '../utils.js'
|
|
6
6
|
import globalState from '../../globalState.js'
|
|
@@ -49,11 +49,7 @@ const resetOldContainer = () => {
|
|
|
49
49
|
oldContainer.remove()
|
|
50
50
|
removeClass(
|
|
51
51
|
[document.documentElement, document.body],
|
|
52
|
-
[
|
|
53
|
-
swalClasses['no-backdrop'],
|
|
54
|
-
swalClasses['toast-shown'],
|
|
55
|
-
swalClasses['has-column']
|
|
56
|
-
]
|
|
52
|
+
[swalClasses['no-backdrop'], swalClasses['toast-shown'], swalClasses['has-column']]
|
|
57
53
|
)
|
|
58
54
|
|
|
59
55
|
return true
|
|
@@ -91,7 +87,7 @@ const addInputChangeListeners = () => {
|
|
|
91
87
|
}
|
|
92
88
|
}
|
|
93
89
|
|
|
94
|
-
const getTarget = (target) => typeof target === 'string' ? document.querySelector(target) : target
|
|
90
|
+
const getTarget = (target) => (typeof target === 'string' ? document.querySelector(target) : target)
|
|
95
91
|
|
|
96
92
|
const setupAccessibility = (params) => {
|
|
97
93
|
const popup = getPopup()
|
|
@@ -33,15 +33,17 @@ export const getInputValue = (instance, innerParams) => {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const getCheckboxValue = (input) => input.checked ? 1 : 0
|
|
36
|
+
const getCheckboxValue = (input) => (input.checked ? 1 : 0)
|
|
37
37
|
|
|
38
|
-
const getRadioValue = (input) => input.checked ? input.value : null
|
|
38
|
+
const getRadioValue = (input) => (input.checked ? input.value : null)
|
|
39
39
|
|
|
40
|
-
const getFileValue = (input) =>
|
|
40
|
+
const getFileValue = (input) =>
|
|
41
|
+
input.files.length ? (input.getAttribute('multiple') !== null ? input.files : input.files[0]) : null
|
|
41
42
|
|
|
42
43
|
const handleInputOptions = (instance, params) => {
|
|
43
44
|
const popup = dom.getPopup()
|
|
44
|
-
const processInputOptions = (inputOptions) =>
|
|
45
|
+
const processInputOptions = (inputOptions) =>
|
|
46
|
+
populateInputOptions[params.input](popup, formatInputOptions(inputOptions), params)
|
|
45
47
|
if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
|
|
46
48
|
showLoading(dom.getConfirmButton())
|
|
47
49
|
asPromise(params.inputOptions).then((inputOptions) => {
|
|
@@ -58,12 +60,13 @@ const handleInputOptions = (instance, params) => {
|
|
|
58
60
|
const handleInputValue = (instance, params) => {
|
|
59
61
|
const input = instance.getInput()
|
|
60
62
|
dom.hide(input)
|
|
61
|
-
asPromise(params.inputValue)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
asPromise(params.inputValue)
|
|
64
|
+
.then((inputValue) => {
|
|
65
|
+
input.value = params.input === 'number' ? parseFloat(inputValue) || 0 : `${inputValue}`
|
|
66
|
+
dom.show(input)
|
|
67
|
+
input.focus()
|
|
68
|
+
instance.hideLoading()
|
|
69
|
+
})
|
|
67
70
|
.catch((err) => {
|
|
68
71
|
error(`Error in inputValue promise: ${err}`)
|
|
69
72
|
input.value = ''
|
|
@@ -83,20 +86,22 @@ const populateInputOptions = {
|
|
|
83
86
|
option.selected = isSelected(optionValue, params.inputValue)
|
|
84
87
|
parent.appendChild(option)
|
|
85
88
|
}
|
|
86
|
-
inputOptions.forEach(inputOption => {
|
|
89
|
+
inputOptions.forEach((inputOption) => {
|
|
87
90
|
const optionValue = inputOption[0]
|
|
88
91
|
const optionLabel = inputOption[1]
|
|
89
92
|
// <optgroup> spec:
|
|
90
93
|
// https://www.w3.org/TR/html401/interact/forms.html#h-17.6
|
|
91
94
|
// "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
|
|
92
95
|
// check whether this is a <optgroup>
|
|
93
|
-
if (Array.isArray(optionLabel)) {
|
|
96
|
+
if (Array.isArray(optionLabel)) {
|
|
97
|
+
// if it is an array, then it is an <optgroup>
|
|
94
98
|
const optgroup = document.createElement('optgroup')
|
|
95
99
|
optgroup.label = optionValue
|
|
96
100
|
optgroup.disabled = false // not configurable for now
|
|
97
101
|
select.appendChild(optgroup)
|
|
98
|
-
optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]))
|
|
99
|
-
} else {
|
|
102
|
+
optionLabel.forEach((o) => renderOption(optgroup, o[1], o[0]))
|
|
103
|
+
} else {
|
|
104
|
+
// case of <option>
|
|
100
105
|
renderOption(select, optionLabel, optionValue)
|
|
101
106
|
}
|
|
102
107
|
})
|
|
@@ -105,7 +110,7 @@ const populateInputOptions = {
|
|
|
105
110
|
|
|
106
111
|
radio: (popup, inputOptions, params) => {
|
|
107
112
|
const radio = getDirectChildByClass(popup, swalClasses.radio)
|
|
108
|
-
inputOptions.forEach(inputOption => {
|
|
113
|
+
inputOptions.forEach((inputOption) => {
|
|
109
114
|
const radioValue = inputOption[0]
|
|
110
115
|
const radioLabel = inputOption[1]
|
|
111
116
|
const radioInput = document.createElement('input')
|
|
@@ -127,7 +132,7 @@ const populateInputOptions = {
|
|
|
127
132
|
if (radios.length) {
|
|
128
133
|
radios[0].focus()
|
|
129
134
|
}
|
|
130
|
-
}
|
|
135
|
+
},
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
/**
|
|
@@ -139,15 +144,17 @@ const formatInputOptions = (inputOptions) => {
|
|
|
139
144
|
if (typeof Map !== 'undefined' && inputOptions instanceof Map) {
|
|
140
145
|
inputOptions.forEach((value, key) => {
|
|
141
146
|
let valueFormatted = value
|
|
142
|
-
if (typeof valueFormatted === 'object') {
|
|
147
|
+
if (typeof valueFormatted === 'object') {
|
|
148
|
+
// case of <optgroup>
|
|
143
149
|
valueFormatted = formatInputOptions(valueFormatted)
|
|
144
150
|
}
|
|
145
151
|
result.push([key, valueFormatted])
|
|
146
152
|
})
|
|
147
153
|
} else {
|
|
148
|
-
Object.keys(inputOptions).forEach(key => {
|
|
154
|
+
Object.keys(inputOptions).forEach((key) => {
|
|
149
155
|
let valueFormatted = inputOptions[key]
|
|
150
|
-
if (typeof valueFormatted === 'object') {
|
|
156
|
+
if (typeof valueFormatted === 'object') {
|
|
157
|
+
// case of <optgroup>
|
|
151
158
|
valueFormatted = formatInputOptions(valueFormatted)
|
|
152
159
|
}
|
|
153
160
|
result.push([key, valueFormatted])
|
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
import { setInnerHtml } from './domUtils.js'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @param {HTMLElement | object | string} param
|
|
5
|
+
* @param {HTMLElement} target
|
|
6
|
+
*/
|
|
3
7
|
export const parseHtmlToContainer = (param, target) => {
|
|
4
8
|
// DOM element
|
|
5
9
|
if (param instanceof HTMLElement) {
|
|
6
10
|
target.appendChild(param)
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
// Object
|
|
9
|
-
|
|
14
|
+
else if (typeof param === 'object') {
|
|
10
15
|
handleObject(param, target)
|
|
16
|
+
}
|
|
11
17
|
|
|
12
18
|
// Plain string
|
|
13
|
-
|
|
19
|
+
else if (param) {
|
|
14
20
|
setInnerHtml(target, param)
|
|
15
21
|
}
|
|
16
22
|
}
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @param {object} param
|
|
26
|
+
* @param {HTMLElement} target
|
|
27
|
+
*/
|
|
18
28
|
const handleObject = (param, target) => {
|
|
19
29
|
// JQuery element(s)
|
|
20
30
|
if (param.jquery) {
|
|
21
31
|
handleJqueryElem(target, param)
|
|
32
|
+
}
|
|
22
33
|
|
|
23
34
|
// For other objects use their string representation
|
|
24
|
-
|
|
35
|
+
else {
|
|
25
36
|
setInnerHtml(target, param.toString())
|
|
26
37
|
}
|
|
27
38
|
}
|
|
@@ -24,7 +24,7 @@ export const renderActions = (instance, params) => {
|
|
|
24
24
|
dom.applyCustomClass(loader, params, 'loader')
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function renderButtons
|
|
27
|
+
function renderButtons(actions, loader, params) {
|
|
28
28
|
const confirmButton = dom.getConfirmButton()
|
|
29
29
|
const denyButton = dom.getDenyButton()
|
|
30
30
|
const cancelButton = dom.getCancelButton()
|
|
@@ -47,7 +47,7 @@ function renderButtons (actions, loader, params) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function handleButtonsStyling
|
|
50
|
+
function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
|
|
51
51
|
if (!params.buttonsStyling) {
|
|
52
52
|
return dom.removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled)
|
|
53
53
|
}
|
|
@@ -69,7 +69,7 @@ function handleButtonsStyling (confirmButton, denyButton, cancelButton, params)
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function renderButton
|
|
72
|
+
function renderButton(button, buttonType, params) {
|
|
73
73
|
dom.toggle(button, params[`show${capitalizeFirstLetter(buttonType)}Button`], 'inline-block')
|
|
74
74
|
dom.setInnerHtml(button, params[`${buttonType}ButtonText`]) // Set caption text
|
|
75
75
|
button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`]) // ARIA label
|
|
@@ -2,7 +2,7 @@ import { swalClasses } from '../../classes.js'
|
|
|
2
2
|
import { warn } from '../../utils.js'
|
|
3
3
|
import * as dom from '../../dom/index.js'
|
|
4
4
|
|
|
5
|
-
function handleBackdropParam
|
|
5
|
+
function handleBackdropParam(container, backdrop) {
|
|
6
6
|
if (typeof backdrop === 'string') {
|
|
7
7
|
container.style.background = backdrop
|
|
8
8
|
} else if (!backdrop) {
|
|
@@ -10,7 +10,7 @@ function handleBackdropParam (container, backdrop) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function handlePositionParam
|
|
13
|
+
function handlePositionParam(container, position) {
|
|
14
14
|
if (position in swalClasses) {
|
|
15
15
|
dom.addClass(container, swalClasses[position])
|
|
16
16
|
} else {
|
|
@@ -19,7 +19,7 @@ function handlePositionParam (container, position) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function handleGrowParam
|
|
22
|
+
function handleGrowParam(container, grow) {
|
|
23
23
|
if (grow && typeof grow === 'string') {
|
|
24
24
|
const growClass = `grow-${grow}`
|
|
25
25
|
if (growClass in swalClasses) {
|
|
@@ -10,14 +10,16 @@ export const renderContent = (instance, params) => {
|
|
|
10
10
|
if (params.html) {
|
|
11
11
|
dom.parseHtmlToContainer(params.html, htmlContainer)
|
|
12
12
|
dom.show(htmlContainer, 'block')
|
|
13
|
+
}
|
|
13
14
|
|
|
14
15
|
// Content as plain text
|
|
15
|
-
|
|
16
|
+
else if (params.text) {
|
|
16
17
|
htmlContainer.textContent = params.text
|
|
17
18
|
dom.show(htmlContainer, 'block')
|
|
19
|
+
}
|
|
18
20
|
|
|
19
21
|
// No content
|
|
20
|
-
|
|
22
|
+
else {
|
|
21
23
|
dom.hide(htmlContainer)
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { iconTypes, swalClasses } from '../../classes.js'
|
|
2
2
|
import { error } from '../../utils.js'
|
|
3
3
|
import * as dom from '../../dom/index.js'
|
|
4
4
|
import privateProps from '../../../privateProps.js'
|
|
@@ -64,30 +64,34 @@ const adjustSuccessIconBackgroundColor = () => {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
const successIconHtml = `
|
|
68
|
+
<div class="swal2-success-circular-line-left"></div>
|
|
69
|
+
<span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
|
|
70
|
+
<div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>
|
|
71
|
+
<div class="swal2-success-circular-line-right"></div>
|
|
72
|
+
`
|
|
73
|
+
|
|
74
|
+
const errorIconHtml = `
|
|
75
|
+
<span class="swal2-x-mark">
|
|
76
|
+
<span class="swal2-x-mark-line-left"></span>
|
|
77
|
+
<span class="swal2-x-mark-line-right"></span>
|
|
78
|
+
</span>
|
|
79
|
+
`
|
|
80
|
+
|
|
67
81
|
const setContent = (icon, params) => {
|
|
68
82
|
icon.textContent = ''
|
|
69
83
|
|
|
70
84
|
if (params.iconHtml) {
|
|
71
85
|
dom.setInnerHtml(icon, iconContent(params.iconHtml))
|
|
72
86
|
} else if (params.icon === 'success') {
|
|
73
|
-
dom.setInnerHtml(icon,
|
|
74
|
-
<div class="swal2-success-circular-line-left"></div>
|
|
75
|
-
<span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
|
|
76
|
-
<div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>
|
|
77
|
-
<div class="swal2-success-circular-line-right"></div>
|
|
78
|
-
`)
|
|
87
|
+
dom.setInnerHtml(icon, successIconHtml)
|
|
79
88
|
} else if (params.icon === 'error') {
|
|
80
|
-
dom.setInnerHtml(icon,
|
|
81
|
-
<span class="swal2-x-mark">
|
|
82
|
-
<span class="swal2-x-mark-line-left"></span>
|
|
83
|
-
<span class="swal2-x-mark-line-right"></span>
|
|
84
|
-
</span>
|
|
85
|
-
`)
|
|
89
|
+
dom.setInnerHtml(icon, errorIconHtml)
|
|
86
90
|
} else {
|
|
87
91
|
const defaultIconHtml = {
|
|
88
92
|
question: '?',
|
|
89
93
|
warning: '!',
|
|
90
|
-
info: 'i'
|
|
94
|
+
info: 'i',
|
|
91
95
|
}
|
|
92
96
|
dom.setInnerHtml(icon, iconContent(defaultIconHtml[params.icon]))
|
|
93
97
|
}
|
|
@@ -99,7 +103,12 @@ const setColor = (icon, params) => {
|
|
|
99
103
|
}
|
|
100
104
|
icon.style.color = params.iconColor
|
|
101
105
|
icon.style.borderColor = params.iconColor
|
|
102
|
-
for (const sel of [
|
|
106
|
+
for (const sel of [
|
|
107
|
+
'.swal2-success-line-tip',
|
|
108
|
+
'.swal2-success-line-long',
|
|
109
|
+
'.swal2-x-mark-line-left',
|
|
110
|
+
'.swal2-x-mark-line-right',
|
|
111
|
+
]) {
|
|
103
112
|
dom.setStyle(icon, sel, 'backgroundColor', params.iconColor)
|
|
104
113
|
}
|
|
105
114
|
dom.setStyle(icon, '.swal2-success-ring', 'borderColor', params.iconColor)
|