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/README.md
CHANGED
|
@@ -21,7 +21,7 @@ For all questions related to sponsorship please contact me via email limon.monte
|
|
|
21
21
|
|
|
22
22
|
[<img src="https://sweetalert2.github.io/images/plus.png" width="80">](SPONSORS.md#sponsors) | [<img src="https://avatars2.githubusercontent.com/u/28631236?s=80&v=4" width="80">](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/vegega.jpeg" width="80">](https://www.vegega.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/phatoil.png" width="80">](https://phatoil.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/celltrackingapps.png" width="80">](https://celltrackingapps.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/mybitcoinslots.png" width="80">](https://www.mybitcoinslots.com/?utm_source=sweetalert2&utm_medium=logo)
|
|
23
23
|
-|-|-|-|-|-
|
|
24
|
-
[Become a sponsor](SPONSORS.md#sponsors) | [FlowCrypt](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [
|
|
24
|
+
[Become a sponsor](SPONSORS.md#sponsors) | [FlowCrypt](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [Metal Raised Garden Bed](https://www.vegega.com/) | [Pure Essential Oil](https://phatoil.com/) | [Phone Tracking Apps](https://celltrackingapps.com) | [My Bitcoin slots](https://www.mybitcoinslots.com/?utm_source=sweetalert2&utm_medium=logo)
|
|
25
25
|
|
|
26
26
|
[<img src="https://sweetalert2.github.io/images/sponsors/torc-stark.png" width="80">](https://torcstark.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/coderubik.png" width="80">](https://coderubik.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/halvinlaina.png" width="80">](https://halvinlaina.fi/) | [<img src="https://avatars0.githubusercontent.com/u/3986989?s=80&v=4" width="80">](https://github.com/tiagostutz) | [<img src="https://sweetalert2.github.io/images/sponsors/sebaebc.png" width="80">](https://github.com/sebaebc)
|
|
27
27
|
-|-|-|-|-
|
|
@@ -30,11 +30,9 @@ For all questions related to sponsorship please contact me via email limon.monte
|
|
|
30
30
|
NSFW Sponsors
|
|
31
31
|
-------------
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[
|
|
36
|
-
-|-|-|-
|
|
37
|
-
[Become a NSFW sponsor](SPONSORS.md#sponsors) | [BestRealDoll](https://www.bestrealdoll.com/collections/us-warehouse) | [SexDollTech](https://www.sexdolltech.com/product-category/us-warehouse/) | [Rose Wives](https://rosewives.com/)
|
|
33
|
+
[<img src="https://sweetalert2.github.io/images/plus.png" width="80">](SPONSORS.md#sponsors) | [<img src="https://sweetalert2.github.io/images/sponsors/sensualdolls.png" width="80">](https://www.sensualdolls.com) | [<img src="https://sweetalert2.github.io/images/sponsors/bestrealdoll.jpeg" width="80">](https://www.bestrealdoll.com/collections/us-warehouse) | [<img src="https://sweetalert2.github.io/images/sponsors/sexdolltech.jpeg" width="80">](https://www.sexdolltech.com/product-category/us-warehouse/) | [<img src="https://sweetalert2.github.io/images/sponsors/rosewives.png" width="80">](https://rosewives.com/)
|
|
34
|
+
-|-|-|-|-
|
|
35
|
+
[Become a NSFW sponsor](SPONSORS.md#sponsors) | [Sensual Dolls](https://www.sensualdolls.com) | [BestRealDoll](https://www.bestrealdoll.com/collections/us-warehouse) | [SexDollTech](https://www.sexdolltech.com/product-category/us-warehouse/) | [Rose Wives](https://rosewives.com/)
|
|
38
36
|
|
|
39
37
|
[<img src="https://sweetalert2.github.io/images/sponsors/sexdollsoff.png" width="80">](https://www.sexdollsoff.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/realsexdoll.png" width="80">](https://realsexdoll.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/yourdoll.jpg" width="80">](https://www.yourdoll.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/annies-dollhouse.png" width="80">](https://anniesdollhouse.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/sexdollcenter.png" width="80">](https://sexdollcenter.vip/) |
|
|
40
38
|
-|-|-|-|-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sweetalert2",
|
|
3
|
-
"version": "11.3.
|
|
3
|
+
"version": "11.3.9",
|
|
4
4
|
"repository": "sweetalert2/sweetalert2",
|
|
5
5
|
"homepage": "https://sweetalert2.github.io/",
|
|
6
6
|
"description": "A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert",
|
|
@@ -14,12 +14,15 @@
|
|
|
14
14
|
"@rollup/plugin-json": "^4.0.2",
|
|
15
15
|
"@sweetalert2/eslint-config": "^1.0.11",
|
|
16
16
|
"@sweetalert2/execute": "^1.0.0",
|
|
17
|
+
"@sweetalert2/prettier-config": "^1.0.0",
|
|
17
18
|
"@sweetalert2/stylelint-config": "^2.0.6",
|
|
18
19
|
"browser-sync": "^2.27.7",
|
|
19
20
|
"cspell": "^5.15.1",
|
|
20
21
|
"cypress": "^9.2.0",
|
|
21
|
-
"
|
|
22
|
+
"edit-json-file": "^1.7.0",
|
|
23
|
+
"eslint": "^8.7.0",
|
|
22
24
|
"eslint-plugin-cypress": "^2.12.1",
|
|
25
|
+
"eslint-plugin-import": "^2.25.4",
|
|
23
26
|
"eslint-plugin-no-unsanitized": "^4.0.1",
|
|
24
27
|
"gulp": "^4.0.0",
|
|
25
28
|
"gulp-autoprefixer": "^8.0.0",
|
|
@@ -33,8 +36,8 @@
|
|
|
33
36
|
"jquery": "^3.6.0",
|
|
34
37
|
"merge2": "^1.2.3",
|
|
35
38
|
"postcss-scss": "^4.0.2",
|
|
36
|
-
"
|
|
37
|
-
"rollup": "^2.
|
|
39
|
+
"prettier": "^2.5.1",
|
|
40
|
+
"rollup": "^2.64.0",
|
|
38
41
|
"rollup-plugin-babel": "^4.3.2",
|
|
39
42
|
"sass": "^1.47.0",
|
|
40
43
|
"sinon": "^12.0.1",
|
|
@@ -76,7 +79,7 @@
|
|
|
76
79
|
],
|
|
77
80
|
"scripts": {
|
|
78
81
|
"start": "gulp develop --continue-on-error --skip-minification --skip-standalone",
|
|
79
|
-
"lint": "stylelint src/**/*.scss && eslint src test cypress tools *.js *.ts && cspell lint 'src/**/*.js' --no-progress --no-summary",
|
|
82
|
+
"lint": "stylelint src/**/*.scss && eslint src test cypress tools *.js *.ts && prettier --check src/**/*.js cypress/**/*.js test/**/*.{js,ts} tools/**/*.js *.js && cspell lint 'src/**/*.js' --no-progress --no-summary",
|
|
80
83
|
"build": "gulp build",
|
|
81
84
|
"test": "cypress run --headless",
|
|
82
85
|
"check-types": "tsc --noEmit -p jsconfig.json",
|
package/src/SweetAlert.js
CHANGED
|
@@ -8,7 +8,7 @@ import setParameters from './utils/setParameters.js'
|
|
|
8
8
|
import Timer from './utils/Timer.js'
|
|
9
9
|
import { openPopup } from './utils/openPopup.js'
|
|
10
10
|
import { handleInputOptionsAndValue } from './utils/dom/inputUtils.js'
|
|
11
|
-
import { handleConfirmButtonClick, handleDenyButtonClick
|
|
11
|
+
import { handleCancelButtonClick, handleConfirmButtonClick, handleDenyButtonClick } from './buttons-handlers.js'
|
|
12
12
|
import { handlePopupClick } from './popup-click-handler.js'
|
|
13
13
|
import { addKeydownHandler, setFocus } from './keydown-handler.js'
|
|
14
14
|
import * as staticMethods from './staticMethods.js'
|
|
@@ -20,7 +20,7 @@ import globalState from './globalState.js'
|
|
|
20
20
|
let currentInstance
|
|
21
21
|
|
|
22
22
|
class SweetAlert {
|
|
23
|
-
constructor
|
|
23
|
+
constructor(...args) {
|
|
24
24
|
// Prevent run in Node env
|
|
25
25
|
if (typeof window === 'undefined') {
|
|
26
26
|
return
|
|
@@ -36,8 +36,8 @@ class SweetAlert {
|
|
|
36
36
|
value: outerParams,
|
|
37
37
|
writable: false,
|
|
38
38
|
enumerable: true,
|
|
39
|
-
configurable: true
|
|
40
|
-
}
|
|
39
|
+
configurable: true,
|
|
40
|
+
},
|
|
41
41
|
})
|
|
42
42
|
|
|
43
43
|
// @ts-ignore
|
|
@@ -45,7 +45,7 @@ class SweetAlert {
|
|
|
45
45
|
privateProps.promise.set(this, promise)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
_main
|
|
48
|
+
_main(userParams, mixinParams = {}) {
|
|
49
49
|
showWarningsForParams(Object.assign({}, mixinParams, userParams))
|
|
50
50
|
|
|
51
51
|
if (globalState.currentInstance) {
|
|
@@ -79,12 +79,12 @@ class SweetAlert {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// `catch` cannot be the name of a module export, so we define our thenable methods here instead
|
|
82
|
-
then
|
|
82
|
+
then(onFulfilled) {
|
|
83
83
|
const promise = privateProps.promise.get(this)
|
|
84
84
|
return promise.then(onFulfilled)
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
finally
|
|
87
|
+
finally(onFinally) {
|
|
88
88
|
const promise = privateProps.promise.get(this)
|
|
89
89
|
return promise.finally(onFinally)
|
|
90
90
|
}
|
|
@@ -144,7 +144,7 @@ const populateDomCache = (instance) => {
|
|
|
144
144
|
loader: dom.getLoader(),
|
|
145
145
|
closeButton: dom.getCloseButton(),
|
|
146
146
|
validationMessage: dom.getValidationMessage(),
|
|
147
|
-
progressSteps: dom.getProgressSteps()
|
|
147
|
+
progressSteps: dom.getProgressSteps(),
|
|
148
148
|
}
|
|
149
149
|
privateProps.domCache.set(instance, domCache)
|
|
150
150
|
|
|
@@ -162,7 +162,8 @@ const setupTimer = (globalState, innerParams, dismissWith) => {
|
|
|
162
162
|
if (innerParams.timerProgressBar) {
|
|
163
163
|
dom.show(timerProgressBar)
|
|
164
164
|
setTimeout(() => {
|
|
165
|
-
if (globalState.timeout && globalState.timeout.running) {
|
|
165
|
+
if (globalState.timeout && globalState.timeout.running) {
|
|
166
|
+
// timer can be already stopped or unset at this point
|
|
166
167
|
dom.animateTimerProgressBar(innerParams.timer)
|
|
167
168
|
}
|
|
168
169
|
})
|
|
@@ -216,7 +217,7 @@ Object.assign(SweetAlert.prototype, instanceMethods)
|
|
|
216
217
|
Object.assign(SweetAlert, staticMethods)
|
|
217
218
|
|
|
218
219
|
// Proxy to instance methods to constructor, for now, for backwards compatibility
|
|
219
|
-
Object.keys(instanceMethods).forEach(key => {
|
|
220
|
+
Object.keys(instanceMethods).forEach((key) => {
|
|
220
221
|
SweetAlert[key] = function (...args) {
|
|
221
222
|
if (currentInstance) {
|
|
222
223
|
return currentInstance[key](...args)
|
|
@@ -226,6 +227,6 @@ Object.keys(instanceMethods).forEach(key => {
|
|
|
226
227
|
|
|
227
228
|
SweetAlert.DismissReason = DismissReason
|
|
228
229
|
|
|
229
|
-
SweetAlert.version = '11.3.
|
|
230
|
+
SweetAlert.version = '11.3.8'
|
|
230
231
|
|
|
231
232
|
export default SweetAlert
|
package/src/buttons-handlers.js
CHANGED
|
@@ -34,7 +34,9 @@ export const handleCancelButtonClick = (instance, dismissWith) => {
|
|
|
34
34
|
const handleConfirmOrDenyWithInput = (instance, type /* 'confirm' | 'deny' */) => {
|
|
35
35
|
const innerParams = privateProps.innerParams.get(instance)
|
|
36
36
|
if (!innerParams.input) {
|
|
37
|
-
return error(
|
|
37
|
+
return error(
|
|
38
|
+
`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`
|
|
39
|
+
)
|
|
38
40
|
}
|
|
39
41
|
const inputValue = getInputValue(instance, innerParams)
|
|
40
42
|
if (innerParams.inputValidator) {
|
|
@@ -52,22 +54,20 @@ const handleConfirmOrDenyWithInput = (instance, type /* 'confirm' | 'deny' */) =
|
|
|
52
54
|
const handleInputValidator = (instance, inputValue, type /* 'confirm' | 'deny' */) => {
|
|
53
55
|
const innerParams = privateProps.innerParams.get(instance)
|
|
54
56
|
instance.disableInput()
|
|
55
|
-
const validationPromise = Promise.resolve().then(() =>
|
|
56
|
-
innerParams.inputValidator(inputValue, innerParams.validationMessage))
|
|
57
|
+
const validationPromise = Promise.resolve().then(() =>
|
|
58
|
+
asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage))
|
|
57
59
|
)
|
|
58
|
-
validationPromise.then(
|
|
59
|
-
(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
confirm(instance, inputValue)
|
|
68
|
-
}
|
|
60
|
+
validationPromise.then((validationMessage) => {
|
|
61
|
+
instance.enableButtons()
|
|
62
|
+
instance.enableInput()
|
|
63
|
+
if (validationMessage) {
|
|
64
|
+
instance.showValidationMessage(validationMessage)
|
|
65
|
+
} else if (type === 'deny') {
|
|
66
|
+
deny(instance, inputValue)
|
|
67
|
+
} else {
|
|
68
|
+
confirm(instance, inputValue)
|
|
69
69
|
}
|
|
70
|
-
)
|
|
70
|
+
})
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const deny = (instance, value) => {
|
|
@@ -79,18 +79,18 @@ const deny = (instance, value) => {
|
|
|
79
79
|
|
|
80
80
|
if (innerParams.preDeny) {
|
|
81
81
|
privateProps.awaitingPromise.set(instance || this, true) // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
|
|
82
|
-
const preDenyPromise = Promise.resolve().then(() =>
|
|
83
|
-
innerParams.preDeny(value, innerParams.validationMessage))
|
|
82
|
+
const preDenyPromise = Promise.resolve().then(() =>
|
|
83
|
+
asPromise(innerParams.preDeny(value, innerParams.validationMessage))
|
|
84
84
|
)
|
|
85
|
-
preDenyPromise
|
|
86
|
-
(preDenyValue) => {
|
|
85
|
+
preDenyPromise
|
|
86
|
+
.then((preDenyValue) => {
|
|
87
87
|
if (preDenyValue === false) {
|
|
88
88
|
instance.hideLoading()
|
|
89
89
|
} else {
|
|
90
90
|
instance.closePopup({ isDenied: true, value: typeof preDenyValue === 'undefined' ? value : preDenyValue })
|
|
91
91
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
92
|
+
})
|
|
93
|
+
.catch((error) => rejectWith(instance || this, error))
|
|
94
94
|
} else {
|
|
95
95
|
instance.closePopup({ isDenied: true, value })
|
|
96
96
|
}
|
|
@@ -114,18 +114,18 @@ const confirm = (instance, value) => {
|
|
|
114
114
|
if (innerParams.preConfirm) {
|
|
115
115
|
instance.resetValidationMessage()
|
|
116
116
|
privateProps.awaitingPromise.set(instance || this, true) // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
|
|
117
|
-
const preConfirmPromise = Promise.resolve().then(() =>
|
|
118
|
-
innerParams.preConfirm(value, innerParams.validationMessage))
|
|
117
|
+
const preConfirmPromise = Promise.resolve().then(() =>
|
|
118
|
+
asPromise(innerParams.preConfirm(value, innerParams.validationMessage))
|
|
119
119
|
)
|
|
120
|
-
preConfirmPromise
|
|
121
|
-
(preConfirmValue) => {
|
|
120
|
+
preConfirmPromise
|
|
121
|
+
.then((preConfirmValue) => {
|
|
122
122
|
if (isVisible(getValidationMessage()) || preConfirmValue === false) {
|
|
123
123
|
instance.hideLoading()
|
|
124
124
|
} else {
|
|
125
125
|
succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue)
|
|
126
126
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
127
|
+
})
|
|
128
|
+
.catch((error) => rejectWith(instance || this, error))
|
|
129
129
|
} else {
|
|
130
130
|
succeedWith(instance, value)
|
|
131
131
|
}
|
package/src/globalState.js
CHANGED
|
@@ -15,7 +15,7 @@ const focusPreviousActiveElement = () => {
|
|
|
15
15
|
|
|
16
16
|
// Restore previous active (focused) element
|
|
17
17
|
export const restoreActiveElement = (returnFocus) => {
|
|
18
|
-
return new Promise(resolve => {
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
19
|
if (!returnFocus) {
|
|
20
20
|
return resolve()
|
|
21
21
|
}
|
|
@@ -2,7 +2,7 @@ import globalState from '../globalState.js'
|
|
|
2
2
|
import privateProps from '../privateProps.js'
|
|
3
3
|
import privateMethods from '../privateMethods.js'
|
|
4
4
|
|
|
5
|
-
export function _destroy
|
|
5
|
+
export function _destroy() {
|
|
6
6
|
const domCache = privateProps.domCache.get(this)
|
|
7
7
|
const innerParams = privateProps.innerParams.get(this)
|
|
8
8
|
|
|
@@ -11,12 +11,14 @@ import privateMethods from '../privateMethods.js'
|
|
|
11
11
|
* Instance method to close sweetAlert
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
function removePopupAndResetState
|
|
14
|
+
function removePopupAndResetState(instance, container, returnFocus, didClose) {
|
|
15
15
|
if (dom.isToast()) {
|
|
16
16
|
triggerDidCloseAndDispose(instance, didClose)
|
|
17
17
|
} else {
|
|
18
18
|
restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose))
|
|
19
|
-
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
|
|
19
|
+
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
|
|
20
|
+
capture: globalState.keydownListenerCapture,
|
|
21
|
+
})
|
|
20
22
|
globalState.keydownHandlerAdded = false
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -40,19 +42,14 @@ function removePopupAndResetState (instance, container, returnFocus, didClose) {
|
|
|
40
42
|
removeBodyClasses()
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
function removeBodyClasses
|
|
45
|
+
function removeBodyClasses() {
|
|
44
46
|
dom.removeClass(
|
|
45
47
|
[document.documentElement, document.body],
|
|
46
|
-
[
|
|
47
|
-
swalClasses.shown,
|
|
48
|
-
swalClasses['height-auto'],
|
|
49
|
-
swalClasses['no-backdrop'],
|
|
50
|
-
swalClasses['toast-shown'],
|
|
51
|
-
]
|
|
48
|
+
[swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]
|
|
52
49
|
)
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
export function close
|
|
52
|
+
export function close(resolveValue) {
|
|
56
53
|
resolveValue = prepareResolveValue(resolveValue)
|
|
57
54
|
|
|
58
55
|
const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this)
|
|
@@ -71,7 +68,7 @@ export function close (resolveValue) {
|
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
export function isAwaitingPromise
|
|
71
|
+
export function isAwaitingPromise() {
|
|
75
72
|
return !!privateProps.awaitingPromise.get(this)
|
|
76
73
|
}
|
|
77
74
|
|
|
@@ -99,7 +96,7 @@ const triggerClosePopup = (instance) => {
|
|
|
99
96
|
return true
|
|
100
97
|
}
|
|
101
98
|
|
|
102
|
-
export function rejectPromise
|
|
99
|
+
export function rejectPromise(error) {
|
|
103
100
|
const rejectPromise = privateMethods.swalPromiseReject.get(this)
|
|
104
101
|
handleAwaitingPromise(this)
|
|
105
102
|
if (rejectPromise) {
|
|
@@ -128,11 +125,14 @@ const prepareResolveValue = (resolveValue) => {
|
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
return Object.assign(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
return Object.assign(
|
|
129
|
+
{
|
|
130
|
+
isConfirmed: false,
|
|
131
|
+
isDenied: false,
|
|
132
|
+
isDismissed: false,
|
|
133
|
+
},
|
|
134
|
+
resolveValue
|
|
135
|
+
)
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const handlePopupAnimation = (instance, popup, innerParams) => {
|
|
@@ -153,7 +153,13 @@ const handlePopupAnimation = (instance, popup, innerParams) => {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
const animatePopup = (instance, popup, container, returnFocus, didClose) => {
|
|
156
|
-
globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(
|
|
156
|
+
globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(
|
|
157
|
+
null,
|
|
158
|
+
instance,
|
|
159
|
+
container,
|
|
160
|
+
returnFocus,
|
|
161
|
+
didClose
|
|
162
|
+
)
|
|
157
163
|
popup.addEventListener(dom.animationEndEvent, function (e) {
|
|
158
164
|
if (e.target === popup) {
|
|
159
165
|
globalState.swalCloseEventFinishedCallback()
|
|
@@ -171,8 +177,4 @@ const triggerDidCloseAndDispose = (instance, didClose) => {
|
|
|
171
177
|
})
|
|
172
178
|
}
|
|
173
179
|
|
|
174
|
-
export {
|
|
175
|
-
close as closePopup,
|
|
176
|
-
close as closeModal,
|
|
177
|
-
close as closeToast
|
|
178
|
-
}
|
|
180
|
+
export { close as closePopup, close as closeModal, close as closeToast }
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import privateProps from '../privateProps.js'
|
|
2
2
|
|
|
3
|
-
function setButtonsDisabled
|
|
3
|
+
function setButtonsDisabled(instance, buttons, disabled) {
|
|
4
4
|
const domCache = privateProps.domCache.get(instance)
|
|
5
|
-
buttons.forEach(button => {
|
|
5
|
+
buttons.forEach((button) => {
|
|
6
6
|
domCache[button].disabled = disabled
|
|
7
7
|
})
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function setInputDisabled
|
|
10
|
+
function setInputDisabled(input, disabled) {
|
|
11
11
|
if (!input) {
|
|
12
12
|
return false
|
|
13
13
|
}
|
|
@@ -22,18 +22,18 @@ function setInputDisabled (input, disabled) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function enableButtons
|
|
25
|
+
export function enableButtons() {
|
|
26
26
|
setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function disableButtons
|
|
29
|
+
export function disableButtons() {
|
|
30
30
|
setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function enableInput
|
|
33
|
+
export function enableInput() {
|
|
34
34
|
return setInputDisabled(this.getInput(), false)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function disableInput
|
|
37
|
+
export function disableInput() {
|
|
38
38
|
return setInputDisabled(this.getInput(), true)
|
|
39
39
|
}
|
|
@@ -5,7 +5,7 @@ import privateProps from '../privateProps.js'
|
|
|
5
5
|
* Gets the input DOM node, this method works with input parameter.
|
|
6
6
|
* @returns {HTMLElement | null}
|
|
7
7
|
*/
|
|
8
|
-
export function getInput
|
|
8
|
+
export function getInput(instance) {
|
|
9
9
|
const innerParams = privateProps.innerParams.get(instance || this)
|
|
10
10
|
const domCache = privateProps.domCache.get(instance || this)
|
|
11
11
|
if (!domCache) {
|
|
@@ -5,7 +5,7 @@ import privateProps from '../privateProps.js'
|
|
|
5
5
|
/**
|
|
6
6
|
* Hides loader and shows back the button which was hidden by .showLoading()
|
|
7
7
|
*/
|
|
8
|
-
function hideLoading
|
|
8
|
+
function hideLoading() {
|
|
9
9
|
// do nothing if popup is closed
|
|
10
10
|
const innerParams = privateProps.innerParams.get(this)
|
|
11
11
|
if (!innerParams) {
|
|
@@ -37,7 +37,4 @@ const showRelatedButton = (domCache) => {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export {
|
|
41
|
-
hideLoading,
|
|
42
|
-
hideLoading as disableLoading
|
|
43
|
-
}
|
|
40
|
+
export { hideLoading, hideLoading as disableLoading }
|
|
@@ -6,24 +6,17 @@ import { isUpdatableParameter } from '../../src/utils/params.js'
|
|
|
6
6
|
/**
|
|
7
7
|
* Updates popup parameters.
|
|
8
8
|
*/
|
|
9
|
-
export function update
|
|
9
|
+
export function update(params) {
|
|
10
10
|
const popup = dom.getPopup()
|
|
11
11
|
const innerParams = privateProps.innerParams.get(this)
|
|
12
12
|
|
|
13
13
|
if (!popup || dom.hasClass(popup, innerParams.hideClass.popup)) {
|
|
14
|
-
return warn(
|
|
14
|
+
return warn(
|
|
15
|
+
`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`
|
|
16
|
+
)
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
const validUpdatableParams =
|
|
18
|
-
|
|
19
|
-
// assign valid params from `params` to `defaults`
|
|
20
|
-
Object.keys(params).forEach(param => {
|
|
21
|
-
if (isUpdatableParameter(param)) {
|
|
22
|
-
validUpdatableParams[param] = params[param]
|
|
23
|
-
} else {
|
|
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`)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
19
|
+
const validUpdatableParams = filterValidParams(params)
|
|
27
20
|
|
|
28
21
|
const updatedParams = Object.assign({}, innerParams, validUpdatableParams)
|
|
29
22
|
|
|
@@ -34,7 +27,21 @@ export function update (params) {
|
|
|
34
27
|
params: {
|
|
35
28
|
value: Object.assign({}, this.params, params),
|
|
36
29
|
writable: false,
|
|
37
|
-
enumerable: true
|
|
30
|
+
enumerable: true,
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const filterValidParams = (params) => {
|
|
36
|
+
const validUpdatableParams = {}
|
|
37
|
+
Object.keys(params).forEach((param) => {
|
|
38
|
+
if (isUpdatableParameter(param)) {
|
|
39
|
+
validUpdatableParams[param] = params[param]
|
|
40
|
+
} else {
|
|
41
|
+
warn(
|
|
42
|
+
`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`
|
|
43
|
+
)
|
|
38
44
|
}
|
|
39
45
|
})
|
|
46
|
+
return validUpdatableParams
|
|
40
47
|
}
|
|
@@ -3,7 +3,7 @@ import { swalClasses } from '../utils/classes.js'
|
|
|
3
3
|
import privateProps from '../privateProps.js'
|
|
4
4
|
|
|
5
5
|
// Show block with validation message
|
|
6
|
-
export function showValidationMessage
|
|
6
|
+
export function showValidationMessage(error) {
|
|
7
7
|
const domCache = privateProps.domCache.get(this)
|
|
8
8
|
const params = privateProps.innerParams.get(this)
|
|
9
9
|
dom.setInnerHtml(domCache.validationMessage, error)
|
|
@@ -23,7 +23,7 @@ export function showValidationMessage (error) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Hide block with validation message
|
|
26
|
-
export function resetValidationMessage
|
|
26
|
+
export function resetValidationMessage() {
|
|
27
27
|
const domCache = privateProps.domCache.get(this)
|
|
28
28
|
if (domCache.validationMessage) {
|
|
29
29
|
dom.hide(domCache.validationMessage)
|
package/src/keydown-handler.js
CHANGED
|
@@ -6,7 +6,9 @@ import privateProps from './privateProps.js'
|
|
|
6
6
|
|
|
7
7
|
export const addKeydownHandler = (instance, globalState, innerParams, dismissWith) => {
|
|
8
8
|
if (globalState.keydownTarget && globalState.keydownHandlerAdded) {
|
|
9
|
-
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
|
|
9
|
+
globalState.keydownTarget.removeEventListener('keydown', globalState.keydownHandler, {
|
|
10
|
+
capture: globalState.keydownListenerCapture,
|
|
11
|
+
})
|
|
10
12
|
globalState.keydownHandlerAdded = false
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -14,7 +16,9 @@ export const addKeydownHandler = (instance, globalState, innerParams, dismissWit
|
|
|
14
16
|
globalState.keydownHandler = (e) => keydownHandler(instance, e, dismissWith)
|
|
15
17
|
globalState.keydownTarget = innerParams.keydownListenerCapture ? window : dom.getPopup()
|
|
16
18
|
globalState.keydownListenerCapture = innerParams.keydownListenerCapture
|
|
17
|
-
globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
|
|
19
|
+
globalState.keydownTarget.addEventListener('keydown', globalState.keydownHandler, {
|
|
20
|
+
capture: globalState.keydownListenerCapture,
|
|
21
|
+
})
|
|
18
22
|
globalState.keydownHandlerAdded = true
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -41,13 +45,9 @@ export const setFocus = (innerParams, index, increment) => {
|
|
|
41
45
|
dom.getPopup().focus()
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
const arrowKeysNextButton = [
|
|
45
|
-
'ArrowRight', 'ArrowDown',
|
|
46
|
-
]
|
|
48
|
+
const arrowKeysNextButton = ['ArrowRight', 'ArrowDown']
|
|
47
49
|
|
|
48
|
-
const arrowKeysPreviousButton = [
|
|
49
|
-
'ArrowLeft', 'ArrowUp',
|
|
50
|
-
]
|
|
50
|
+
const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp']
|
|
51
51
|
|
|
52
52
|
const keydownHandler = (instance, e, dismissWith) => {
|
|
53
53
|
const innerParams = privateProps.innerParams.get(instance)
|
|
@@ -63,24 +63,27 @@ const keydownHandler = (instance, e, dismissWith) => {
|
|
|
63
63
|
// ENTER
|
|
64
64
|
if (e.key === 'Enter') {
|
|
65
65
|
handleEnter(instance, e, innerParams)
|
|
66
|
+
}
|
|
66
67
|
|
|
67
68
|
// TAB
|
|
68
|
-
|
|
69
|
+
else if (e.key === 'Tab') {
|
|
69
70
|
handleTab(e, innerParams)
|
|
71
|
+
}
|
|
70
72
|
|
|
71
73
|
// ARROWS - switch focus between buttons
|
|
72
|
-
|
|
74
|
+
else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(e.key)) {
|
|
73
75
|
handleArrows(e.key)
|
|
76
|
+
}
|
|
74
77
|
|
|
75
78
|
// ESC
|
|
76
|
-
|
|
79
|
+
else if (e.key === 'Escape') {
|
|
77
80
|
handleEsc(e, innerParams, dismissWith)
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
const handleEnter = (instance, e, innerParams) => {
|
|
82
|
-
// #720 #721
|
|
83
|
-
if (e.isComposing) {
|
|
85
|
+
// #2386 #720 #721
|
|
86
|
+
if (!callIfFunction(innerParams.allowEnterKey) || e.isComposing) {
|
|
84
87
|
return
|
|
85
88
|
}
|
|
86
89
|
|
|
@@ -106,13 +109,16 @@ const handleTab = (e, innerParams) => {
|
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
|
|
112
|
+
// Cycle to the next button
|
|
109
113
|
if (!e.shiftKey) {
|
|
110
|
-
// Cycle to the next button
|
|
111
114
|
setFocus(innerParams, btnIndex, 1)
|
|
112
|
-
}
|
|
113
|
-
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Cycle to the prev button
|
|
118
|
+
else {
|
|
114
119
|
setFocus(innerParams, btnIndex, -1)
|
|
115
120
|
}
|
|
121
|
+
|
|
116
122
|
e.stopPropagation()
|
|
117
123
|
e.preventDefault()
|
|
118
124
|
}
|
|
@@ -34,10 +34,12 @@ const handleToastClick = (instance, domCache, dismissWith) => {
|
|
|
34
34
|
* @returns {boolean}
|
|
35
35
|
*/
|
|
36
36
|
const isAnyButtonShown = (innerParams) => {
|
|
37
|
-
return
|
|
37
|
+
return (
|
|
38
|
+
innerParams.showConfirmButton ||
|
|
38
39
|
innerParams.showDenyButton ||
|
|
39
40
|
innerParams.showCancelButton ||
|
|
40
41
|
innerParams.showCloseButton
|
|
42
|
+
)
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
let ignoreOutsideClick = false
|
package/src/privateMethods.js
CHANGED
package/src/privateProps.js
CHANGED
|
@@ -8,7 +8,7 @@ export const argsToParams = (args) => {
|
|
|
8
8
|
if (typeof args[0] === 'object' && !isElement(args[0])) {
|
|
9
9
|
Object.assign(params, args[0])
|
|
10
10
|
} else {
|
|
11
|
-
['title', 'html', 'icon'].forEach((name, index) => {
|
|
11
|
+
;['title', 'html', 'icon'].forEach((name, index) => {
|
|
12
12
|
const arg = args[index]
|
|
13
13
|
if (typeof arg === 'string' || isElement(arg)) {
|
|
14
14
|
params[name] = arg
|