sweetalert2 11.4.37 → 11.5.0
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 +17 -0
- package/dist/sweetalert2.all.js +28 -35
- package/dist/sweetalert2.all.min.js +2 -2
- package/dist/sweetalert2.css +0 -52
- package/dist/sweetalert2.js +27 -34
- package/dist/sweetalert2.min.css +1 -1
- package/dist/sweetalert2.min.js +1 -1
- package/package.json +1 -1
- package/src/SweetAlert.js +4 -30
- package/src/scss/_core.scss +0 -57
- package/src/utils/getTemplateParams.js +21 -2
- package/src/utils/utils.js +0 -6
package/src/scss/_core.scss
CHANGED
|
@@ -823,60 +823,3 @@ $icon-zoom: math.div(strip-units($swal2-icon-size), 5);
|
|
|
823
823
|
left: auto;
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
|
-
|
|
827
|
-
.save-yourself-from-war {
|
|
828
|
-
display: flex;
|
|
829
|
-
position: fixed;
|
|
830
|
-
z-index: 1939;
|
|
831
|
-
top: 0;
|
|
832
|
-
right: 0;
|
|
833
|
-
bottom: 0;
|
|
834
|
-
left: 0;
|
|
835
|
-
flex-direction: column;
|
|
836
|
-
align-items: center;
|
|
837
|
-
justify-content: center;
|
|
838
|
-
padding: 25px 0 20px;
|
|
839
|
-
background: #20232a;
|
|
840
|
-
color: #fff;
|
|
841
|
-
text-align: center;
|
|
842
|
-
|
|
843
|
-
div {
|
|
844
|
-
max-width: 560px;
|
|
845
|
-
margin: 10px;
|
|
846
|
-
line-height: 146%;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
iframe {
|
|
850
|
-
max-width: 100%;
|
|
851
|
-
max-height: calc(100vmin / 1.8);
|
|
852
|
-
margin: 16px auto;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
strong {
|
|
856
|
-
border-bottom: 2px dashed white;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
button {
|
|
860
|
-
display: flex;
|
|
861
|
-
position: fixed;
|
|
862
|
-
z-index: 1940;
|
|
863
|
-
top: 0;
|
|
864
|
-
right: 0;
|
|
865
|
-
align-items: center;
|
|
866
|
-
justify-content: center;
|
|
867
|
-
width: 48px;
|
|
868
|
-
height: 48px;
|
|
869
|
-
margin-right: 10px;
|
|
870
|
-
margin-bottom: -10px;
|
|
871
|
-
border: none;
|
|
872
|
-
background: transparent;
|
|
873
|
-
color: #aaa;
|
|
874
|
-
font-size: 48px;
|
|
875
|
-
font-weight: bold;
|
|
876
|
-
cursor: pointer;
|
|
877
|
-
|
|
878
|
-
&:hover {
|
|
879
|
-
color: #fff;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
@@ -20,6 +20,7 @@ export const getTemplateParams = (params) => {
|
|
|
20
20
|
|
|
21
21
|
const result = Object.assign(
|
|
22
22
|
getSwalParams(templateContent),
|
|
23
|
+
getSwalFunctionParams(templateContent),
|
|
23
24
|
getSwalButtons(templateContent),
|
|
24
25
|
getSwalImage(templateContent),
|
|
25
26
|
getSwalIcon(templateContent),
|
|
@@ -43,14 +44,31 @@ const getSwalParams = (templateContent) => {
|
|
|
43
44
|
const value = param.getAttribute('value')
|
|
44
45
|
if (typeof defaultParams[paramName] === 'boolean') {
|
|
45
46
|
result[paramName] = value !== 'false'
|
|
46
|
-
}
|
|
47
|
-
if (typeof defaultParams[paramName] === 'object') {
|
|
47
|
+
} else if (typeof defaultParams[paramName] === 'object') {
|
|
48
48
|
result[paramName] = JSON.parse(value)
|
|
49
|
+
} else {
|
|
50
|
+
result[paramName] = value
|
|
49
51
|
}
|
|
50
52
|
})
|
|
51
53
|
return result
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @param {DocumentFragment} templateContent
|
|
58
|
+
* @returns {SweetAlertOptions}
|
|
59
|
+
*/
|
|
60
|
+
const getSwalFunctionParams = (templateContent) => {
|
|
61
|
+
const result = {}
|
|
62
|
+
/** @type {HTMLElement[]} */
|
|
63
|
+
const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'))
|
|
64
|
+
swalFunctions.forEach((param) => {
|
|
65
|
+
const paramName = param.getAttribute('name')
|
|
66
|
+
const value = param.getAttribute('value')
|
|
67
|
+
result[paramName] = new Function(`return ${value}`)()
|
|
68
|
+
})
|
|
69
|
+
return result
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
/**
|
|
55
73
|
* @param {DocumentFragment} templateContent
|
|
56
74
|
* @returns {SweetAlertOptions}
|
|
@@ -185,6 +203,7 @@ const getSwalStringParams = (templateContent, paramNames) => {
|
|
|
185
203
|
const showWarningsForElements = (templateContent) => {
|
|
186
204
|
const allowedElements = swalStringParams.concat([
|
|
187
205
|
'swal-param',
|
|
206
|
+
'swal-function-param',
|
|
188
207
|
'swal-button',
|
|
189
208
|
'swal-image',
|
|
190
209
|
'swal-icon',
|
package/src/utils/utils.js
CHANGED
|
@@ -100,9 +100,3 @@ export const asPromise = (arg) => (hasToPromiseFn(arg) ? arg.toPromise() : Promi
|
|
|
100
100
|
* @returns {boolean}
|
|
101
101
|
*/
|
|
102
102
|
export const isPromise = (arg) => arg && Promise.resolve(arg) === arg
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @param {Array} arr
|
|
106
|
-
* @returns {any}
|
|
107
|
-
*/
|
|
108
|
-
export const getRandomElement = (arr) => arr[Math.floor(Math.random() * arr.length)]
|