@monstermann/signals-modal 0.2.0 → 0.3.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/dist/createModal.d.ts +1 -0
- package/dist/createModal.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/status/closeLastModal.d.ts +4 -0
- package/dist/status/closeLastModal.js +11 -0
- package/dist/status/onModalClosed.d.ts +2 -2
- package/dist/status/onModalClosing.d.ts +2 -2
- package/dist/status/onModalOpened.d.ts +2 -2
- package/dist/status/onModalOpening.d.ts +2 -2
- package/dist/utils/syncModalGroupsToBody.js +19 -9
- package/package.json +1 -1
package/dist/createModal.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { MaybeDispose } from "@monstermann/signals";
|
|
|
5
5
|
interface ModalContext {
|
|
6
6
|
key: string;
|
|
7
7
|
dispose: () => void;
|
|
8
|
+
isDisposed: () => boolean;
|
|
8
9
|
onDispose: (dispose: MaybeDispose) => void;
|
|
9
10
|
}
|
|
10
11
|
declare const onModalDisposed: _monstermann_signals0.Emitter<string>;
|
package/dist/createModal.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { onModalClosed } from "./status/onModalClosed.js";
|
|
2
2
|
import { closeModal } from "./status/closeModal.js";
|
|
3
3
|
import { isModalClosed } from "./status/isModalClosed.js";
|
|
4
|
-
import { SILENT, context, disposer, emitter } from "@monstermann/signals";
|
|
4
|
+
import { SILENT, context, disposer, emitter, isDisposed } from "@monstermann/signals";
|
|
5
5
|
|
|
6
6
|
//#region src/createModal.ts
|
|
7
7
|
const meta = {
|
|
8
8
|
path: "@signals-modal/createModal.ts",
|
|
9
|
-
line:
|
|
9
|
+
line: 16,
|
|
10
10
|
name: "onModalDisposed"
|
|
11
11
|
};
|
|
12
12
|
const modalCtx = context();
|
|
@@ -21,6 +21,7 @@ function createModal(key, setup) {
|
|
|
21
21
|
const nextCtx = {
|
|
22
22
|
key,
|
|
23
23
|
onDispose: dispose,
|
|
24
|
+
isDisposed: () => isDisposed(dispose),
|
|
24
25
|
dispose() {
|
|
25
26
|
if (isModalClosed(key)) {
|
|
26
27
|
dispose();
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { ModalPosition, withPosition } from "./position/withPosition.js";
|
|
|
28
28
|
import { getModalPosition } from "./position/getModalPosition.js";
|
|
29
29
|
import { withBoundary } from "./position/withBoundary.js";
|
|
30
30
|
import { closeAllModals } from "./status/closeAllModals.js";
|
|
31
|
+
import { closeLastModal } from "./status/closeLastModal.js";
|
|
31
32
|
import { closeModal } from "./status/closeModal.js";
|
|
32
33
|
import { getClosedModals } from "./status/getClosedModals.js";
|
|
33
34
|
import { getClosingModals } from "./status/getClosingModals.js";
|
|
@@ -58,4 +59,4 @@ import { withModalStatus } from "./status/withModalStatus.js";
|
|
|
58
59
|
import { closeLastModalOnClickOutside } from "./utils/closeLastModalOnClickOutside.js";
|
|
59
60
|
import { closeLastModalOnEsc } from "./utils/closeLastModalOnEsc.js";
|
|
60
61
|
import { syncModalGroupsToBody } from "./utils/syncModalGroupsToBody.js";
|
|
61
|
-
export { ModalContext, ModalPlacement, ModalPlacementOption, ModalPosition, ModalStatus, closeAllModals, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPlacement, getModalPosition, getModalStatus, getModalsForGroup, getOpenModals, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpen, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, isModalOpen, isModalOpened, isModalOpening, isModalVisible, isPopover, isTooltip, modalGroups, onModalClosed, onModalClosing, onModalDisposed, onModalOpened, onModalOpening, openModal, setAnchorElement, setFloatingElement, setModalStatus, syncModalGroupsToBody, withAnchorElement, withAnchorMeasurement, withBoundary, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
|
|
62
|
+
export { ModalContext, ModalPlacement, ModalPlacementOption, ModalPosition, ModalStatus, closeAllModals, closeLastModal, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPlacement, getModalPosition, getModalStatus, getModalsForGroup, getOpenModals, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpen, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, isModalOpen, isModalOpened, isModalOpening, isModalVisible, isPopover, isTooltip, modalGroups, onModalClosed, onModalClosing, onModalDisposed, onModalOpened, onModalOpening, openModal, setAnchorElement, setFloatingElement, setModalStatus, syncModalGroupsToBody, withAnchorElement, withAnchorMeasurement, withBoundary, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import { withBoundary } from "./position/withBoundary.js";
|
|
|
32
32
|
import { withPlacement } from "./position/withPlacement.js";
|
|
33
33
|
import { withPosition } from "./position/withPosition.js";
|
|
34
34
|
import { closeAllModals } from "./status/closeAllModals.js";
|
|
35
|
+
import { closeLastModal } from "./status/closeLastModal.js";
|
|
35
36
|
import { getClosedModals } from "./status/getClosedModals.js";
|
|
36
37
|
import { getClosingModals } from "./status/getClosingModals.js";
|
|
37
38
|
import { getModalStatus } from "./status/getModalStatus.js";
|
|
@@ -58,4 +59,4 @@ import { closeLastModalOnClickOutside } from "./utils/closeLastModalOnClickOutsi
|
|
|
58
59
|
import { closeLastModalOnEsc } from "./utils/closeLastModalOnEsc.js";
|
|
59
60
|
import { syncModalGroupsToBody } from "./utils/syncModalGroupsToBody.js";
|
|
60
61
|
|
|
61
|
-
export { closeAllModals, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPlacement, getModalPosition, getModalStatus, getModalsForGroup, getOpenModals, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpen, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, isModalOpen, isModalOpened, isModalOpening, isModalVisible, isPopover, isTooltip, modalGroups, onModalClosed, onModalClosing, onModalDisposed, onModalOpened, onModalOpening, openModal, setAnchorElement, setFloatingElement, setModalStatus, syncModalGroupsToBody, withAnchorElement, withAnchorMeasurement, withBoundary, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
|
|
62
|
+
export { closeAllModals, closeLastModal, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPlacement, getModalPosition, getModalStatus, getModalsForGroup, getOpenModals, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpen, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, isModalOpen, isModalOpened, isModalOpening, isModalVisible, isPopover, isTooltip, modalGroups, onModalClosed, onModalClosing, onModalDisposed, onModalOpened, onModalOpening, openModal, setAnchorElement, setFloatingElement, setModalStatus, syncModalGroupsToBody, withAnchorElement, withAnchorMeasurement, withBoundary, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { $openedModals } from "./internals.js";
|
|
2
|
+
import { closeModal } from "./closeModal.js";
|
|
3
|
+
|
|
4
|
+
//#region src/status/closeLastModal.ts
|
|
5
|
+
function closeLastModal() {
|
|
6
|
+
const key = Array.from($openedModals()).at(-1);
|
|
7
|
+
if (key) closeModal(key);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { closeLastModal };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _monstermann_signals0 from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/status/onModalClosed.d.ts
|
|
4
|
-
declare const onModalClosed:
|
|
4
|
+
declare const onModalClosed: _monstermann_signals0.Emitter<string>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { onModalClosed };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _monstermann_signals2 from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/status/onModalClosing.d.ts
|
|
4
|
-
declare const onModalClosing:
|
|
4
|
+
declare const onModalClosing: _monstermann_signals2.Emitter<string>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { onModalClosing };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _monstermann_signals1 from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/status/onModalOpened.d.ts
|
|
4
|
-
declare const onModalOpened:
|
|
4
|
+
declare const onModalOpened: _monstermann_signals1.Emitter<string>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { onModalOpened };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _monstermann_signals3 from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/status/onModalOpening.d.ts
|
|
4
|
-
declare const onModalOpening:
|
|
4
|
+
declare const onModalOpening: _monstermann_signals3.Emitter<string>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { onModalOpening };
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import { getGroupsForModal } from "../groups/getGroupsForModal.js";
|
|
2
2
|
import { getVisibleModals } from "../status/getVisibleModals.js";
|
|
3
|
-
import { INTERNAL, effect } from "@monstermann/signals";
|
|
3
|
+
import { INTERNAL, effect, memo } from "@monstermann/signals";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/syncModalGroupsToBody.ts
|
|
6
|
+
const path = "@signals-modal/utils/syncModalGroupsToBody.ts";
|
|
6
7
|
const meta = {
|
|
7
|
-
path
|
|
8
|
-
line:
|
|
8
|
+
path,
|
|
9
|
+
line: 5,
|
|
10
|
+
name: "$classes"
|
|
11
|
+
};
|
|
12
|
+
const meta1 = {
|
|
13
|
+
path,
|
|
14
|
+
line: 17,
|
|
9
15
|
name: "syncModalGroupsToBody"
|
|
10
16
|
};
|
|
17
|
+
const $classes = memo(() => {
|
|
18
|
+
const modals = getVisibleModals();
|
|
19
|
+
const clx = /* @__PURE__ */ new Set();
|
|
20
|
+
for (const modal of modals) for (const group of getGroupsForModal(modal)) clx.add(`has-${group}`);
|
|
21
|
+
return Array.from(clx).sort().join(" ");
|
|
22
|
+
}, INTERNAL, meta);
|
|
11
23
|
function syncModalGroupsToBody() {
|
|
12
24
|
effect(() => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
for (const modal of modals) for (const group of getGroupsForModal(modal)) clx.add(`has-${group}`);
|
|
16
|
-
document.body.classList.add(...clx);
|
|
25
|
+
const classes = $classes().split(" ");
|
|
26
|
+
document.body.classList.add(...classes);
|
|
17
27
|
return () => {
|
|
18
|
-
document.body.classList.remove(...
|
|
28
|
+
document.body.classList.remove(...classes);
|
|
19
29
|
};
|
|
20
|
-
}, INTERNAL,
|
|
30
|
+
}, INTERNAL, meta1);
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
//#endregion
|