@monstermann/signals-modal 0.0.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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/anchor/getAnchorElement.d.ts +4 -0
- package/dist/anchor/getAnchorElement.js +9 -0
- package/dist/anchor/getAnchorMeasurement.d.ts +6 -0
- package/dist/anchor/getAnchorMeasurement.js +10 -0
- package/dist/anchor/internals.js +19 -0
- package/dist/anchor/setAnchorElement.d.ts +4 -0
- package/dist/anchor/setAnchorElement.js +9 -0
- package/dist/anchor/withAnchorElement.d.ts +6 -0
- package/dist/anchor/withAnchorElement.js +32 -0
- package/dist/anchor/withAnchorMeasurement.d.ts +12 -0
- package/dist/anchor/withAnchorMeasurement.js +56 -0
- package/dist/anchor/withMouseAnchor.d.ts +11 -0
- package/dist/anchor/withMouseAnchor.js +57 -0
- package/dist/createModal.d.ts +14 -0
- package/dist/createModal.js +47 -0
- package/dist/floating/getFloatingElement.d.ts +4 -0
- package/dist/floating/getFloatingElement.js +9 -0
- package/dist/floating/getFloatingMeasurement.d.ts +6 -0
- package/dist/floating/getFloatingMeasurement.js +10 -0
- package/dist/floating/internals.js +19 -0
- package/dist/floating/setFloatingElement.d.ts +4 -0
- package/dist/floating/setFloatingElement.js +9 -0
- package/dist/floating/withFloatingElement.d.ts +6 -0
- package/dist/floating/withFloatingElement.js +32 -0
- package/dist/floating/withFloatingMeasurement.d.ts +12 -0
- package/dist/floating/withFloatingMeasurement.js +67 -0
- package/dist/groups/getDialogs.d.ts +4 -0
- package/dist/groups/getDialogs.js +10 -0
- package/dist/groups/getGroupsForModal.d.ts +4 -0
- package/dist/groups/getGroupsForModal.js +10 -0
- package/dist/groups/getModalsForGroup.d.ts +4 -0
- package/dist/groups/getModalsForGroup.js +10 -0
- package/dist/groups/getPopovers.d.ts +4 -0
- package/dist/groups/getPopovers.js +10 -0
- package/dist/groups/getTooltips.d.ts +4 -0
- package/dist/groups/getTooltips.js +10 -0
- package/dist/groups/internals.js +26 -0
- package/dist/groups/isDialog.d.ts +4 -0
- package/dist/groups/isDialog.js +10 -0
- package/dist/groups/isModalInGroup.d.ts +4 -0
- package/dist/groups/isModalInGroup.js +9 -0
- package/dist/groups/isPopover.d.ts +4 -0
- package/dist/groups/isPopover.js +10 -0
- package/dist/groups/isTooltip.d.ts +4 -0
- package/dist/groups/isTooltip.js +10 -0
- package/dist/groups/modalGroups.d.ts +8 -0
- package/dist/groups/modalGroups.js +9 -0
- package/dist/groups/withModalGroups.d.ts +6 -0
- package/dist/groups/withModalGroups.js +29 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +57 -0
- package/dist/internals/findParentElement.js +9 -0
- package/dist/internals/observeDimensions.js +23 -0
- package/dist/internals/observePosition.js +44 -0
- package/dist/internals/roundByDPR.js +8 -0
- package/dist/position/getModalPosition.d.ts +6 -0
- package/dist/position/getModalPosition.js +9 -0
- package/dist/position/internals.js +32 -0
- package/dist/position/withBoundary.d.ts +11 -0
- package/dist/position/withBoundary.js +45 -0
- package/dist/position/withPlacement.d.ts +14 -0
- package/dist/position/withPlacement.js +75 -0
- package/dist/position/withPosition.d.ts +22 -0
- package/dist/position/withPosition.js +207 -0
- package/dist/status/closeAllModals.d.ts +4 -0
- package/dist/status/closeAllModals.js +16 -0
- package/dist/status/closeModal.d.ts +4 -0
- package/dist/status/closeModal.js +16 -0
- package/dist/status/getClosedModals.d.ts +4 -0
- package/dist/status/getClosedModals.js +12 -0
- package/dist/status/getClosingModals.d.ts +4 -0
- package/dist/status/getClosingModals.js +12 -0
- package/dist/status/getModalStatus.d.ts +6 -0
- package/dist/status/getModalStatus.js +9 -0
- package/dist/status/getOpenedModals.d.ts +4 -0
- package/dist/status/getOpenedModals.js +12 -0
- package/dist/status/getOpeningModals.d.ts +4 -0
- package/dist/status/getOpeningModals.js +12 -0
- package/dist/status/getVisibleModals.d.ts +4 -0
- package/dist/status/getVisibleModals.js +12 -0
- package/dist/status/internals.js +30 -0
- package/dist/status/isAnyModalClosed.d.ts +4 -0
- package/dist/status/isAnyModalClosed.js +9 -0
- package/dist/status/isAnyModalClosing.d.ts +4 -0
- package/dist/status/isAnyModalClosing.js +9 -0
- package/dist/status/isAnyModalOpened.d.ts +4 -0
- package/dist/status/isAnyModalOpened.js +9 -0
- package/dist/status/isAnyModalOpening.d.ts +4 -0
- package/dist/status/isAnyModalOpening.js +9 -0
- package/dist/status/isAnyModalVisible.d.ts +4 -0
- package/dist/status/isAnyModalVisible.js +9 -0
- package/dist/status/isModalClosed.d.ts +4 -0
- package/dist/status/isModalClosed.js +10 -0
- package/dist/status/isModalClosing.d.ts +4 -0
- package/dist/status/isModalClosing.js +9 -0
- package/dist/status/isModalOpened.d.ts +4 -0
- package/dist/status/isModalOpened.js +9 -0
- package/dist/status/isModalOpening.d.ts +4 -0
- package/dist/status/isModalOpening.js +9 -0
- package/dist/status/isModalVisible.d.ts +4 -0
- package/dist/status/isModalVisible.js +9 -0
- package/dist/status/onModalClosed.d.ts +6 -0
- package/dist/status/onModalClosed.js +12 -0
- package/dist/status/onModalClosing.d.ts +6 -0
- package/dist/status/onModalClosing.js +12 -0
- package/dist/status/onModalOpened.d.ts +6 -0
- package/dist/status/onModalOpened.js +12 -0
- package/dist/status/onModalOpening.d.ts +6 -0
- package/dist/status/onModalOpening.js +12 -0
- package/dist/status/openModal.d.ts +4 -0
- package/dist/status/openModal.js +16 -0
- package/dist/status/setModalStatus.d.ts +6 -0
- package/dist/status/setModalStatus.js +9 -0
- package/dist/status/types.d.ts +4 -0
- package/dist/status/withModalStatus.d.ts +7 -0
- package/dist/status/withModalStatus.js +38 -0
- package/dist/utils/closeLastModalOnClickOutside.d.ts +4 -0
- package/dist/utils/closeLastModalOnClickOutside.js +19 -0
- package/dist/utils/closeLastModalOnEsc.d.ts +4 -0
- package/dist/utils/closeLastModalOnEsc.js +17 -0
- package/dist/utils/syncModalGroupsToBody.d.ts +4 -0
- package/dist/utils/syncModalGroupsToBody.js +24 -0
- package/package.json +43 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { set } from "../node_modules/@monstermann/map/dist/Map/set.js";
|
|
2
|
+
import { remove } from "../node_modules/@monstermann/map/dist/Map/remove.js";
|
|
3
|
+
import { currentModal } from "../createModal.js";
|
|
4
|
+
import { $positions, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.js";
|
|
5
|
+
import { roundByDPR } from "../internals/roundByDPR.js";
|
|
6
|
+
import { INTERNAL, effect, memo } from "@monstermann/signals";
|
|
7
|
+
import { Rect, pipe } from "@monstermann/fn";
|
|
8
|
+
|
|
9
|
+
//#region src/position/withPosition.ts
|
|
10
|
+
const path = "@signals-modal/position/withPosition.ts";
|
|
11
|
+
const meta = {
|
|
12
|
+
path,
|
|
13
|
+
line: 296,
|
|
14
|
+
name: "withPosition.$position"
|
|
15
|
+
};
|
|
16
|
+
const meta1 = {
|
|
17
|
+
path,
|
|
18
|
+
line: 305,
|
|
19
|
+
name: "withPosition"
|
|
20
|
+
};
|
|
21
|
+
const positionResolvers = {
|
|
22
|
+
"down-center": function(o) {
|
|
23
|
+
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
24
|
+
const floating = pipe(o.floating, Rect.alignCenterX(o.anchor), Rect.snapBelow(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
25
|
+
const originX = Rect.centerX(o.anchor) - Rect.left(floating);
|
|
26
|
+
return {
|
|
27
|
+
floatingX: Rect.left(floating),
|
|
28
|
+
floatingY: Rect.top(floating),
|
|
29
|
+
maxHeight: Rect.height(boundary),
|
|
30
|
+
maxWidth: Rect.width(boundary),
|
|
31
|
+
originX,
|
|
32
|
+
originY: 0
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
"down-left": function(o) {
|
|
36
|
+
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
37
|
+
const floating = pipe(o.floating, Rect.alignRight(o.anchor), Rect.snapBelow(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
38
|
+
const originX = Rect.right(o.anchor) - Rect.left(floating);
|
|
39
|
+
return {
|
|
40
|
+
floatingX: Rect.left(floating),
|
|
41
|
+
floatingY: Rect.top(floating),
|
|
42
|
+
maxHeight: Rect.height(boundary),
|
|
43
|
+
maxWidth: Rect.width(boundary),
|
|
44
|
+
originX,
|
|
45
|
+
originY: 0
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
"down-right": function(o) {
|
|
49
|
+
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
50
|
+
const floating = pipe(o.floating, Rect.alignLeft(o.anchor), Rect.snapBelow(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
51
|
+
return {
|
|
52
|
+
floatingX: Rect.left(floating),
|
|
53
|
+
floatingY: Rect.top(floating),
|
|
54
|
+
maxHeight: Rect.height(boundary),
|
|
55
|
+
maxWidth: Rect.width(boundary),
|
|
56
|
+
originX: 0,
|
|
57
|
+
originY: 0
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
"left-center": function(o) {
|
|
61
|
+
const boundary = getBoundaryLeft(o.boundary, o.anchor);
|
|
62
|
+
const floating = pipe(o.floating, Rect.alignCenterY(o.anchor), Rect.snapLeftOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
63
|
+
const originX = Rect.width(floating);
|
|
64
|
+
const originY = Rect.centerY(o.anchor) - Rect.top(floating);
|
|
65
|
+
return {
|
|
66
|
+
floatingX: Rect.left(floating),
|
|
67
|
+
floatingY: Rect.top(floating),
|
|
68
|
+
maxHeight: Rect.height(boundary),
|
|
69
|
+
maxWidth: Rect.width(boundary),
|
|
70
|
+
originX,
|
|
71
|
+
originY
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
"left-down": function(o) {
|
|
75
|
+
const boundary = getBoundaryLeft(o.boundary, o.anchor);
|
|
76
|
+
const floating = pipe(o.floating, Rect.alignTop(o.anchor), Rect.snapLeftOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
77
|
+
const originX = Rect.width(floating);
|
|
78
|
+
const originY = Rect.centerY(o.anchor) - Rect.top(floating);
|
|
79
|
+
return {
|
|
80
|
+
floatingX: Rect.left(floating),
|
|
81
|
+
floatingY: Rect.top(floating),
|
|
82
|
+
maxHeight: Rect.height(boundary),
|
|
83
|
+
maxWidth: Rect.width(boundary),
|
|
84
|
+
originX,
|
|
85
|
+
originY
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
"left-up": function(o) {
|
|
89
|
+
const boundary = getBoundaryLeft(o.boundary, o.anchor);
|
|
90
|
+
const floating = pipe(o.floating, Rect.alignBottom(o.anchor), Rect.snapLeftOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
91
|
+
const originX = Rect.width(floating);
|
|
92
|
+
const originY = Rect.centerY(o.anchor) - Rect.top(floating);
|
|
93
|
+
return {
|
|
94
|
+
floatingX: Rect.left(floating),
|
|
95
|
+
floatingY: Rect.top(floating),
|
|
96
|
+
maxHeight: Rect.height(boundary),
|
|
97
|
+
maxWidth: Rect.width(boundary),
|
|
98
|
+
originX,
|
|
99
|
+
originY
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
"right-center": function(o) {
|
|
103
|
+
const boundary = getBoundaryRight(o.boundary, o.anchor);
|
|
104
|
+
const floating = pipe(o.floating, Rect.alignCenterY(o.anchor), Rect.snapRightOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
105
|
+
const originX = 0;
|
|
106
|
+
const originY = Rect.centerY(o.anchor) - Rect.top(floating);
|
|
107
|
+
return {
|
|
108
|
+
floatingX: Rect.left(floating),
|
|
109
|
+
floatingY: Rect.top(floating),
|
|
110
|
+
maxHeight: Rect.height(boundary),
|
|
111
|
+
maxWidth: Rect.width(boundary),
|
|
112
|
+
originX,
|
|
113
|
+
originY
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
"right-down": function(o) {
|
|
117
|
+
const boundary = getBoundaryRight(o.boundary, o.anchor);
|
|
118
|
+
const floating = pipe(o.floating, Rect.alignTop(o.anchor), Rect.snapRightOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
119
|
+
const originX = 0;
|
|
120
|
+
const originY = Rect.centerY(o.anchor) - Rect.top(floating);
|
|
121
|
+
return {
|
|
122
|
+
floatingX: Rect.left(floating),
|
|
123
|
+
floatingY: Rect.top(floating),
|
|
124
|
+
maxHeight: Rect.height(boundary),
|
|
125
|
+
maxWidth: Rect.width(boundary),
|
|
126
|
+
originX,
|
|
127
|
+
originY
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
"right-up": function(o) {
|
|
131
|
+
const boundary = getBoundaryRight(o.boundary, o.anchor);
|
|
132
|
+
const floating = pipe(o.floating, Rect.alignBottom(o.anchor), Rect.snapRightOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
133
|
+
const originX = 0;
|
|
134
|
+
const originY = Rect.centerY(o.anchor) - Rect.top(floating);
|
|
135
|
+
return {
|
|
136
|
+
floatingX: Rect.left(floating),
|
|
137
|
+
floatingY: Rect.top(floating),
|
|
138
|
+
maxHeight: Rect.height(boundary),
|
|
139
|
+
maxWidth: Rect.width(boundary),
|
|
140
|
+
originX,
|
|
141
|
+
originY
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
"up-center": function(o) {
|
|
145
|
+
const boundary = getBoundaryUp(o.boundary, o.anchor);
|
|
146
|
+
const floating = pipe(o.floating, Rect.alignCenterX(o.anchor), Rect.snapAbove(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
147
|
+
const originX = Rect.centerX(o.anchor) - Rect.left(floating);
|
|
148
|
+
const originY = Rect.height(floating);
|
|
149
|
+
return {
|
|
150
|
+
floatingX: Rect.left(floating),
|
|
151
|
+
floatingY: Rect.top(floating),
|
|
152
|
+
maxHeight: Rect.height(boundary),
|
|
153
|
+
maxWidth: Rect.width(boundary),
|
|
154
|
+
originX,
|
|
155
|
+
originY
|
|
156
|
+
};
|
|
157
|
+
},
|
|
158
|
+
"up-left": function(o) {
|
|
159
|
+
const boundary = getBoundaryUp(o.boundary, o.anchor);
|
|
160
|
+
const floating = pipe(o.floating, Rect.alignRight(o.anchor), Rect.snapAbove(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
161
|
+
const originX = Rect.right(o.anchor) - Rect.left(floating);
|
|
162
|
+
const originY = Rect.height(floating);
|
|
163
|
+
return {
|
|
164
|
+
floatingX: Rect.left(floating),
|
|
165
|
+
floatingY: Rect.top(floating),
|
|
166
|
+
maxHeight: Rect.height(boundary),
|
|
167
|
+
maxWidth: Rect.width(boundary),
|
|
168
|
+
originX,
|
|
169
|
+
originY
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
"up-right": function(o) {
|
|
173
|
+
const boundary = getBoundaryUp(o.boundary, o.anchor);
|
|
174
|
+
const floating = pipe(o.floating, Rect.alignLeft(o.anchor), Rect.snapAbove(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
|
|
175
|
+
const originX = 0;
|
|
176
|
+
const originY = Rect.height(floating);
|
|
177
|
+
return {
|
|
178
|
+
floatingX: Rect.left(floating),
|
|
179
|
+
floatingY: Rect.top(floating),
|
|
180
|
+
maxHeight: Rect.height(boundary),
|
|
181
|
+
maxWidth: Rect.width(boundary),
|
|
182
|
+
originX,
|
|
183
|
+
originY
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
function withPosition(options) {
|
|
188
|
+
const modal = currentModal();
|
|
189
|
+
const $position = memo(() => {
|
|
190
|
+
return positionResolvers[options.$placement()]({
|
|
191
|
+
anchor: options.$anchorMeasurement(),
|
|
192
|
+
boundary: options.$boundary(),
|
|
193
|
+
floating: options.$floatingMeasurement(),
|
|
194
|
+
transform: options.transform ?? ((r) => r)
|
|
195
|
+
});
|
|
196
|
+
}, INTERNAL, meta);
|
|
197
|
+
modal.onDispose(effect(() => {
|
|
198
|
+
$positions((p) => set(p, modal.key, $position()));
|
|
199
|
+
}, INTERNAL, meta1));
|
|
200
|
+
modal.onDispose(() => {
|
|
201
|
+
$positions((p) => remove(p, modal.key));
|
|
202
|
+
});
|
|
203
|
+
return $position;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
export { withPosition };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
import { untrack } from "@monstermann/signals";
|
|
3
|
+
|
|
4
|
+
//#region src/status/closeAllModals.ts
|
|
5
|
+
function closeAllModals() {
|
|
6
|
+
untrack(() => {
|
|
7
|
+
for (const $status of $keysToStatus().values()) {
|
|
8
|
+
if ($status() === "closed") continue;
|
|
9
|
+
if ($status() === "closing") continue;
|
|
10
|
+
$status("closing");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { closeAllModals };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
import { untrack } from "@monstermann/signals";
|
|
3
|
+
|
|
4
|
+
//#region src/status/closeModal.ts
|
|
5
|
+
function closeModal(key) {
|
|
6
|
+
untrack(() => {
|
|
7
|
+
const $status = $keysToStatus().get(key);
|
|
8
|
+
if (!$status) return;
|
|
9
|
+
if ($status() === "closing") return;
|
|
10
|
+
if ($status() === "closed") return;
|
|
11
|
+
$status("closing");
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { closeModal };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/getClosedModals.ts
|
|
4
|
+
function getClosedModals() {
|
|
5
|
+
const result = [];
|
|
6
|
+
const map = $keysToStatus();
|
|
7
|
+
for (const [key, $status] of map) if ($status() === "closed") result.push(key);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getClosedModals };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/getClosingModals.ts
|
|
4
|
+
function getClosingModals() {
|
|
5
|
+
const result = [];
|
|
6
|
+
const map = $keysToStatus();
|
|
7
|
+
for (const [key, $status] of map) if ($status() === "closing") result.push(key);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getClosingModals };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/getOpenedModals.ts
|
|
4
|
+
function getOpenedModals() {
|
|
5
|
+
const result = [];
|
|
6
|
+
const map = $keysToStatus();
|
|
7
|
+
for (const [key, $status] of map) if ($status() === "opened") result.push(key);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getOpenedModals };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/getOpeningModals.ts
|
|
4
|
+
function getOpeningModals() {
|
|
5
|
+
const result = [];
|
|
6
|
+
const map = $keysToStatus();
|
|
7
|
+
for (const [key, $status] of map) if ($status() === "opening") result.push(key);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getOpeningModals };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/getVisibleModals.ts
|
|
4
|
+
function getVisibleModals() {
|
|
5
|
+
const result = [];
|
|
6
|
+
const map = $keysToStatus();
|
|
7
|
+
for (const [key, $status] of map) if ($status() !== "closed") result.push(key);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getVisibleModals };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { create } from "../node_modules/@monstermann/set/dist/Set/create.js";
|
|
2
|
+
import { remove } from "../node_modules/@monstermann/set/dist/Set/remove.js";
|
|
3
|
+
import { add } from "../node_modules/@monstermann/set/dist/Set/add.js";
|
|
4
|
+
import { onModalClosed } from "./onModalClosed.js";
|
|
5
|
+
import { onModalOpened } from "./onModalOpened.js";
|
|
6
|
+
import { onModalOpening } from "./onModalOpening.js";
|
|
7
|
+
import { onModalDisposed } from "../createModal.js";
|
|
8
|
+
import { INTERNAL, SILENT, signal } from "@monstermann/signals";
|
|
9
|
+
|
|
10
|
+
//#region src/status/internals.ts
|
|
11
|
+
const path = "@signals-modal/status/internals.ts";
|
|
12
|
+
const meta = {
|
|
13
|
+
path,
|
|
14
|
+
line: 12,
|
|
15
|
+
name: "$keysToStatus"
|
|
16
|
+
};
|
|
17
|
+
const meta1 = {
|
|
18
|
+
path,
|
|
19
|
+
line: 13,
|
|
20
|
+
name: "$openedModals"
|
|
21
|
+
};
|
|
22
|
+
const $keysToStatus = signal(/* @__PURE__ */ new Map(), SILENT, meta);
|
|
23
|
+
const $openedModals = signal(create(), INTERNAL, meta1);
|
|
24
|
+
onModalOpening((key) => $openedModals((m) => remove(m, key)));
|
|
25
|
+
onModalOpened((key) => $openedModals((m) => remove(m, key)));
|
|
26
|
+
onModalClosed((key) => $openedModals((m) => add(m, key)));
|
|
27
|
+
onModalDisposed((key) => $openedModals((m) => add(m, key)));
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { $keysToStatus, $openedModals };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/isModalClosed.ts
|
|
4
|
+
function isModalClosed(key) {
|
|
5
|
+
const $status = $keysToStatus().get(key);
|
|
6
|
+
return $status === void 0 || $status() === "closed";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isModalClosed };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { emitter } from "@monstermann/signals";
|
|
2
|
+
|
|
3
|
+
//#region src/status/onModalClosed.ts
|
|
4
|
+
const meta = {
|
|
5
|
+
path: "@signals-modal/status/onModalClosed.ts",
|
|
6
|
+
line: 3,
|
|
7
|
+
name: "onModalClosed"
|
|
8
|
+
};
|
|
9
|
+
const onModalClosed = emitter(void 0, meta);
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { onModalClosed };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { emitter } from "@monstermann/signals";
|
|
2
|
+
|
|
3
|
+
//#region src/status/onModalClosing.ts
|
|
4
|
+
const meta = {
|
|
5
|
+
path: "@signals-modal/status/onModalClosing.ts",
|
|
6
|
+
line: 3,
|
|
7
|
+
name: "onModalClosing"
|
|
8
|
+
};
|
|
9
|
+
const onModalClosing = emitter(void 0, meta);
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { onModalClosing };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { emitter } from "@monstermann/signals";
|
|
2
|
+
|
|
3
|
+
//#region src/status/onModalOpened.ts
|
|
4
|
+
const meta = {
|
|
5
|
+
path: "@signals-modal/status/onModalOpened.ts",
|
|
6
|
+
line: 3,
|
|
7
|
+
name: "onModalOpened"
|
|
8
|
+
};
|
|
9
|
+
const onModalOpened = emitter(void 0, meta);
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { onModalOpened };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { emitter } from "@monstermann/signals";
|
|
2
|
+
|
|
3
|
+
//#region src/status/onModalOpening.ts
|
|
4
|
+
const meta = {
|
|
5
|
+
path: "@signals-modal/status/onModalOpening.ts",
|
|
6
|
+
line: 3,
|
|
7
|
+
name: "onModalOpening"
|
|
8
|
+
};
|
|
9
|
+
const onModalOpening = emitter(void 0, meta);
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { onModalOpening };
|