@nebularstreams/libmui 2.5.22 → 2.5.23
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/package.json +1 -1
- package/src/util/widgets.js +57 -54
package/package.json
CHANGED
package/src/util/widgets.js
CHANGED
|
@@ -1,72 +1,75 @@
|
|
|
1
1
|
import m from "mithril";
|
|
2
2
|
|
|
3
3
|
let
|
|
4
|
-
|
|
4
|
+
mCurrentCancelable;
|
|
5
5
|
|
|
6
6
|
function runCancelable(container) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
if (typeof mCurrentCancelable === "function") {
|
|
8
|
+
mCurrentCancelable();
|
|
9
|
+
mCurrentCancelable = undefined;
|
|
10
|
+
}
|
|
11
|
+
popupMessage.redraw(true);
|
|
12
|
+
container.style.display = "none";
|
|
13
|
+
delete popupMessage.redraw;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
|
|
15
17
|
// There are ways of doing this inside m.route but it is probably
|
|
16
18
|
// cleaner and faster when kept outside of the main auto
|
|
17
19
|
// rendering system
|
|
18
20
|
|
|
19
21
|
function popupMessage(message, cancelable = false, contentClass = ".modal-content") {
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
23
|
+
const container = document.getElementById("modal-container");
|
|
24
|
+
container.classList.toggle("iscustom", contentClass !== ".modal-content");
|
|
25
|
+
|
|
26
|
+
if (cancelable) {
|
|
27
|
+
|
|
28
|
+
mCurrentCancelable = cancelable;
|
|
29
|
+
|
|
30
|
+
container.onclick = (event) => {
|
|
31
|
+
if (event.target.id === "modal-container") {
|
|
32
|
+
runCancelable(container);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!message) {
|
|
38
|
+
|
|
39
|
+
popupMessage.redraw(true);
|
|
40
|
+
delete popupMessage.redraw;
|
|
41
|
+
if (message === null)
|
|
42
|
+
container.style.display = "none";
|
|
43
|
+
else
|
|
44
|
+
runCancelable(container);
|
|
45
|
+
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
container.style.display = "flex";
|
|
50
|
+
|
|
51
|
+
popupMessage.redraw = (remove) => {
|
|
52
|
+
m.render(
|
|
53
|
+
container,
|
|
54
|
+
m(contentClass, {
|
|
55
|
+
role: "alertdialog",
|
|
56
|
+
"aria-labelledby": "modaltitle",
|
|
57
|
+
"aria-modal": true
|
|
58
|
+
}, remove || !message ? [] : [
|
|
59
|
+
typeof message === "function" ? message() : message
|
|
60
|
+
])
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
popupMessage.redraw();
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
function clearModal() {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const container = document.getElementById("modal-container");
|
|
68
|
+
if (container.style.display !== "none") {
|
|
69
|
+
runCancelable(container);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
export {
|
|
75
|
+
export {popupMessage, clearModal};
|