@monstermann/signals-modal 0.4.3 → 0.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 +2011 -0
- package/dist/anchor/getAnchorElement.d.mts +30 -0
- package/dist/anchor/getAnchorElement.mjs +30 -0
- package/dist/anchor/getAnchorMeasurement.d.mts +38 -1
- package/dist/anchor/getAnchorMeasurement.mjs +37 -0
- package/dist/anchor/setAnchorElement.d.mts +26 -0
- package/dist/anchor/setAnchorElement.mjs +26 -0
- package/dist/anchor/withAnchorElement.d.mts +30 -0
- package/dist/anchor/withAnchorElement.mjs +31 -1
- package/dist/anchor/withAnchorMeasurement.d.mts +43 -1
- package/dist/anchor/withAnchorMeasurement.mjs +45 -3
- package/dist/anchor/withMouseAnchor.d.mts +34 -1
- package/dist/anchor/withMouseAnchor.mjs +36 -3
- package/dist/createModal.d.mts +29 -0
- package/dist/createModal.mjs +29 -0
- package/dist/floating/getFloatingElement.d.mts +30 -0
- package/dist/floating/getFloatingElement.mjs +30 -0
- package/dist/floating/getFloatingMeasurement.d.mts +38 -1
- package/dist/floating/getFloatingMeasurement.mjs +37 -0
- package/dist/floating/setFloatingElement.d.mts +26 -0
- package/dist/floating/setFloatingElement.mjs +26 -0
- package/dist/floating/withFloatingElement.d.mts +30 -0
- package/dist/floating/withFloatingElement.mjs +31 -1
- package/dist/floating/withFloatingMeasurement.d.mts +41 -1
- package/dist/floating/withFloatingMeasurement.mjs +46 -6
- package/dist/groups/getDialogs.d.mts +29 -0
- package/dist/groups/getDialogs.mjs +29 -0
- package/dist/groups/getGroupsForModal.d.mts +29 -0
- package/dist/groups/getGroupsForModal.mjs +29 -0
- package/dist/groups/getModalsForGroup.d.mts +29 -0
- package/dist/groups/getModalsForGroup.mjs +29 -0
- package/dist/groups/getPopovers.d.mts +29 -0
- package/dist/groups/getPopovers.mjs +29 -0
- package/dist/groups/getTooltips.d.mts +29 -0
- package/dist/groups/getTooltips.mjs +29 -0
- package/dist/groups/isDialog.d.mts +29 -0
- package/dist/groups/isDialog.mjs +29 -0
- package/dist/groups/isModalInGroup.d.mts +29 -0
- package/dist/groups/isModalInGroup.mjs +29 -0
- package/dist/groups/isPopover.d.mts +29 -0
- package/dist/groups/isPopover.mjs +29 -0
- package/dist/groups/isTooltip.d.mts +29 -0
- package/dist/groups/isTooltip.mjs +29 -0
- package/dist/groups/modalGroups.mjs +42 -0
- package/dist/groups/withModalGroups.d.mts +29 -0
- package/dist/groups/withModalGroups.mjs +30 -1
- package/dist/internals/observeDimensions.mjs +3 -3
- package/dist/position/getModalPlacement.d.mts +49 -0
- package/dist/position/getModalPlacement.mjs +49 -0
- package/dist/position/getModalPosition.d.mts +58 -0
- package/dist/position/getModalPosition.mjs +58 -0
- package/dist/position/withBoundary.d.mts +31 -1
- package/dist/position/withBoundary.mjs +33 -3
- package/dist/position/withPlacement.d.mts +78 -1
- package/dist/position/withPlacement.mjs +78 -1
- package/dist/position/withPosition.d.mts +67 -1
- package/dist/position/withPosition.mjs +68 -2
- package/dist/scroll/withCloseOnScroll.d.mts +36 -0
- package/dist/scroll/withCloseOnScroll.mjs +39 -3
- package/dist/status/closeAllModals.d.mts +33 -0
- package/dist/status/closeAllModals.mjs +33 -0
- package/dist/status/closeLastModal.d.mts +18 -0
- package/dist/status/closeLastModal.mjs +18 -0
- package/dist/status/closeModal.d.mts +28 -0
- package/dist/status/closeModal.mjs +28 -0
- package/dist/status/getClosedModals.d.mts +32 -0
- package/dist/status/getClosedModals.mjs +32 -0
- package/dist/status/getClosingModals.d.mts +36 -0
- package/dist/status/getClosingModals.mjs +36 -0
- package/dist/status/getModalStatus.d.mts +30 -0
- package/dist/status/getModalStatus.mjs +30 -0
- package/dist/status/getOpenModals.d.mts +36 -0
- package/dist/status/getOpenModals.mjs +36 -0
- package/dist/status/getOpenedModals.d.mts +32 -0
- package/dist/status/getOpenedModals.mjs +32 -0
- package/dist/status/getOpeningModals.d.mts +36 -0
- package/dist/status/getOpeningModals.mjs +36 -0
- package/dist/status/getVisibleModals.d.mts +36 -0
- package/dist/status/getVisibleModals.mjs +36 -0
- package/dist/status/internals.mjs +15 -6
- package/dist/status/isAnyModalClosed.d.mts +32 -0
- package/dist/status/isAnyModalClosed.mjs +32 -0
- package/dist/status/isAnyModalClosing.d.mts +35 -0
- package/dist/status/isAnyModalClosing.mjs +35 -0
- package/dist/status/isAnyModalOpen.d.mts +32 -0
- package/dist/status/isAnyModalOpen.mjs +32 -0
- package/dist/status/isAnyModalOpened.d.mts +32 -0
- package/dist/status/isAnyModalOpened.mjs +32 -0
- package/dist/status/isAnyModalOpening.d.mts +35 -0
- package/dist/status/isAnyModalOpening.mjs +35 -0
- package/dist/status/isAnyModalVisible.d.mts +32 -0
- package/dist/status/isAnyModalVisible.mjs +32 -0
- package/dist/status/isModalClosed.d.mts +28 -0
- package/dist/status/isModalClosed.mjs +28 -0
- package/dist/status/isModalClosing.d.mts +32 -0
- package/dist/status/isModalClosing.mjs +32 -0
- package/dist/status/isModalOpen.d.mts +28 -0
- package/dist/status/isModalOpen.mjs +28 -0
- package/dist/status/isModalOpened.d.mts +30 -0
- package/dist/status/isModalOpened.mjs +30 -0
- package/dist/status/isModalOpening.d.mts +30 -0
- package/dist/status/isModalOpening.mjs +30 -0
- package/dist/status/isModalVisible.d.mts +30 -0
- package/dist/status/isModalVisible.mjs +30 -0
- package/dist/status/onModalClosed.d.mts +32 -2
- package/dist/status/onModalClosed.mjs +31 -1
- package/dist/status/onModalClosing.d.mts +30 -0
- package/dist/status/onModalClosing.mjs +31 -1
- package/dist/status/onModalOpened.d.mts +32 -2
- package/dist/status/onModalOpened.mjs +31 -1
- package/dist/status/onModalOpening.d.mts +32 -2
- package/dist/status/onModalOpening.mjs +31 -1
- package/dist/status/openModal.d.mts +26 -0
- package/dist/status/openModal.mjs +26 -0
- package/dist/status/setModalStatus.d.mts +28 -0
- package/dist/status/setModalStatus.mjs +28 -0
- package/dist/status/withModalStatus.d.mts +40 -0
- package/dist/status/withModalStatus.mjs +48 -8
- package/dist/utils/closeLastModalOnClickOutside.d.mts +18 -0
- package/dist/utils/closeLastModalOnClickOutside.mjs +18 -0
- package/dist/utils/closeLastModalOnEsc.d.mts +18 -0
- package/dist/utils/closeLastModalOnEsc.mjs +18 -0
- package/dist/utils/syncModalGroupsToBody.d.mts +37 -0
- package/dist/utils/syncModalGroupsToBody.mjs +38 -1
- package/package.json +6 -5
|
@@ -2,6 +2,35 @@ import { getModalsForGroup } from "./getModalsForGroup.mjs";
|
|
|
2
2
|
import { modalGroups } from "./modalGroups.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/groups/getTooltips.ts
|
|
5
|
+
/**
|
|
6
|
+
* # getTooltips
|
|
7
|
+
*
|
|
8
|
+
* <Badge type="tip">Reactive</Badge>
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* function getTooltips(): ReadonlySet<string>;
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Returns all tooltip keys from the `modalGroups.tooltip` group.
|
|
15
|
+
*
|
|
16
|
+
* ## Example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import {
|
|
20
|
+
* createModal,
|
|
21
|
+
* withModalGroups,
|
|
22
|
+
* modalGroups,
|
|
23
|
+
* getTooltips,
|
|
24
|
+
* } from "@monstermann/signals-modal";
|
|
25
|
+
*
|
|
26
|
+
* createModal("key", () => {
|
|
27
|
+
* withModalGroups([modalGroups.tooltip]);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* getTooltips(); // Set(["key"])
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
5
34
|
function getTooltips() {
|
|
6
35
|
return getModalsForGroup(modalGroups.tooltip);
|
|
7
36
|
}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
//#region src/groups/isDialog.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* # isDialog
|
|
4
|
+
*
|
|
5
|
+
* <Badge type="tip">Reactive</Badge>
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function isDialog(key: string): boolean;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Returns a boolean indicating whether the given `key` belongs to the `modalGroups.dialog` group.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalGroups,
|
|
19
|
+
* modalGroups,
|
|
20
|
+
* isDialog,
|
|
21
|
+
* } from "@monstermann/signals-modal";
|
|
22
|
+
*
|
|
23
|
+
* createModal("key", () => {
|
|
24
|
+
* withModalGroups([modalGroups.popover]);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* isDialog("key"); // true
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
2
31
|
declare function isDialog(key: string): boolean;
|
|
3
32
|
//#endregion
|
|
4
33
|
export { isDialog };
|
package/dist/groups/isDialog.mjs
CHANGED
|
@@ -2,6 +2,35 @@ import { modalGroups } from "./modalGroups.mjs";
|
|
|
2
2
|
import { getGroupsForModal } from "./getGroupsForModal.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/groups/isDialog.ts
|
|
5
|
+
/**
|
|
6
|
+
* # isDialog
|
|
7
|
+
*
|
|
8
|
+
* <Badge type="tip">Reactive</Badge>
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* function isDialog(key: string): boolean;
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Returns a boolean indicating whether the given `key` belongs to the `modalGroups.dialog` group.
|
|
15
|
+
*
|
|
16
|
+
* ## Example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import {
|
|
20
|
+
* createModal,
|
|
21
|
+
* withModalGroups,
|
|
22
|
+
* modalGroups,
|
|
23
|
+
* isDialog,
|
|
24
|
+
* } from "@monstermann/signals-modal";
|
|
25
|
+
*
|
|
26
|
+
* createModal("key", () => {
|
|
27
|
+
* withModalGroups([modalGroups.popover]);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* isDialog("key"); // true
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
5
34
|
function isDialog(key) {
|
|
6
35
|
return getGroupsForModal(key).has(modalGroups.dialog);
|
|
7
36
|
}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
//#region src/groups/isModalInGroup.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* # isModalInGroup
|
|
4
|
+
*
|
|
5
|
+
* <Badge type="tip">Reactive</Badge>
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function isModalInGroup(key: string, group: string): boolean;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Returns a boolean indicating whether the given `key` belongs to the `group`.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalGroups,
|
|
19
|
+
* modalGroups,
|
|
20
|
+
* isModalInGroup,
|
|
21
|
+
* } from "@monstermann/signals-modal";
|
|
22
|
+
*
|
|
23
|
+
* createModal("key", () => {
|
|
24
|
+
* withModalGroups([modalGroups.popover]);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* isModalInGroup("key", modalGroups.popover); // true
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
2
31
|
declare function isModalInGroup(key: string, group: string): boolean;
|
|
3
32
|
//#endregion
|
|
4
33
|
export { isModalInGroup };
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import { getGroupsForModal } from "./getGroupsForModal.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/groups/isModalInGroup.ts
|
|
4
|
+
/**
|
|
5
|
+
* # isModalInGroup
|
|
6
|
+
*
|
|
7
|
+
* <Badge type="tip">Reactive</Badge>
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* function isModalInGroup(key: string, group: string): boolean;
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Returns a boolean indicating whether the given `key` belongs to the `group`.
|
|
14
|
+
*
|
|
15
|
+
* ## Example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import {
|
|
19
|
+
* createModal,
|
|
20
|
+
* withModalGroups,
|
|
21
|
+
* modalGroups,
|
|
22
|
+
* isModalInGroup,
|
|
23
|
+
* } from "@monstermann/signals-modal";
|
|
24
|
+
*
|
|
25
|
+
* createModal("key", () => {
|
|
26
|
+
* withModalGroups([modalGroups.popover]);
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* isModalInGroup("key", modalGroups.popover); // true
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
4
33
|
function isModalInGroup(key, group) {
|
|
5
34
|
return getGroupsForModal(key).has(group);
|
|
6
35
|
}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
//#region src/groups/isPopover.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* # isPopover
|
|
4
|
+
*
|
|
5
|
+
* <Badge type="tip">Reactive</Badge>
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function isPopover(key: string): boolean;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Returns a boolean indicating whether the given `key` belongs to the `modalGroups.popover` group.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalGroups,
|
|
19
|
+
* modalGroups,
|
|
20
|
+
* isPopover,
|
|
21
|
+
* } from "@monstermann/signals-modal";
|
|
22
|
+
*
|
|
23
|
+
* createModal("key", () => {
|
|
24
|
+
* withModalGroups([modalGroups.popover]);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* isPopover("key"); // true
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
2
31
|
declare function isPopover(key: string): boolean;
|
|
3
32
|
//#endregion
|
|
4
33
|
export { isPopover };
|
|
@@ -2,6 +2,35 @@ import { modalGroups } from "./modalGroups.mjs";
|
|
|
2
2
|
import { getGroupsForModal } from "./getGroupsForModal.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/groups/isPopover.ts
|
|
5
|
+
/**
|
|
6
|
+
* # isPopover
|
|
7
|
+
*
|
|
8
|
+
* <Badge type="tip">Reactive</Badge>
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* function isPopover(key: string): boolean;
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Returns a boolean indicating whether the given `key` belongs to the `modalGroups.popover` group.
|
|
15
|
+
*
|
|
16
|
+
* ## Example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import {
|
|
20
|
+
* createModal,
|
|
21
|
+
* withModalGroups,
|
|
22
|
+
* modalGroups,
|
|
23
|
+
* isPopover,
|
|
24
|
+
* } from "@monstermann/signals-modal";
|
|
25
|
+
*
|
|
26
|
+
* createModal("key", () => {
|
|
27
|
+
* withModalGroups([modalGroups.popover]);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* isPopover("key"); // true
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
5
34
|
function isPopover(key) {
|
|
6
35
|
return getGroupsForModal(key).has(modalGroups.popover);
|
|
7
36
|
}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
//#region src/groups/isTooltip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* # isTooltip
|
|
4
|
+
*
|
|
5
|
+
* <Badge type="tip">Reactive</Badge>
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function isTooltip(key: string): boolean;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Returns a boolean indicating whether the given `key` belongs to the `modalGroups.tooltip` group.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalGroups,
|
|
19
|
+
* modalGroups,
|
|
20
|
+
* isTooltip,
|
|
21
|
+
* } from "@monstermann/signals-modal";
|
|
22
|
+
*
|
|
23
|
+
* createModal("key", () => {
|
|
24
|
+
* withModalGroups([modalGroups.popover]);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* isTooltip("key"); // true
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
2
31
|
declare function isTooltip(key: string): boolean;
|
|
3
32
|
//#endregion
|
|
4
33
|
export { isTooltip };
|
|
@@ -2,6 +2,35 @@ import { modalGroups } from "./modalGroups.mjs";
|
|
|
2
2
|
import { getGroupsForModal } from "./getGroupsForModal.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/groups/isTooltip.ts
|
|
5
|
+
/**
|
|
6
|
+
* # isTooltip
|
|
7
|
+
*
|
|
8
|
+
* <Badge type="tip">Reactive</Badge>
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* function isTooltip(key: string): boolean;
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Returns a boolean indicating whether the given `key` belongs to the `modalGroups.tooltip` group.
|
|
15
|
+
*
|
|
16
|
+
* ## Example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import {
|
|
20
|
+
* createModal,
|
|
21
|
+
* withModalGroups,
|
|
22
|
+
* modalGroups,
|
|
23
|
+
* isTooltip,
|
|
24
|
+
* } from "@monstermann/signals-modal";
|
|
25
|
+
*
|
|
26
|
+
* createModal("key", () => {
|
|
27
|
+
* withModalGroups([modalGroups.popover]);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* isTooltip("key"); // true
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
5
34
|
function isTooltip(key) {
|
|
6
35
|
return getGroupsForModal(key).has(modalGroups.tooltip);
|
|
7
36
|
}
|
|
@@ -4,6 +4,48 @@ const modalGroups = {
|
|
|
4
4
|
popover: "popover",
|
|
5
5
|
tooltip: "tooltip"
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* # modalGroups
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const modalGroups = {
|
|
12
|
+
* dialog: "dialog",
|
|
13
|
+
* popover: "popover",
|
|
14
|
+
* tooltip: "tooltip",
|
|
15
|
+
* };
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* A record containing common modal groups.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* # modalGroups
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const modalGroups = {
|
|
26
|
+
* dialog: "dialog",
|
|
27
|
+
* popover: "popover",
|
|
28
|
+
* tooltip: "tooltip",
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* A record containing common modal groups.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* # modalGroups
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const modalGroups = {
|
|
40
|
+
* dialog: "dialog",
|
|
41
|
+
* popover: "popover",
|
|
42
|
+
* tooltip: "tooltip",
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* A record containing common modal groups.
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
7
49
|
|
|
8
50
|
//#endregion
|
|
9
51
|
export { modalGroups };
|
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import { Memo } from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/groups/withModalGroups.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* # withModalGroups
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function withModalGroups(groups: Iterable<string>): Memo<ReadonlySet<string>>;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Assigns the current modal to a list of groups. Can be used to for example mark the modal as a dialog/popover/tooltip. This function must be called inside a `createModal` callback.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalGroups,
|
|
19
|
+
* getDialogs,
|
|
20
|
+
* getGroupsForModal,
|
|
21
|
+
* getModalsForGroup,
|
|
22
|
+
* } from "@monstermann/signals-modal";
|
|
23
|
+
*
|
|
24
|
+
* createModal("key", () => {
|
|
25
|
+
* withModalGroups(["dialog"]);
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* getGroupsForModal("key"); // Set(["dialog"])
|
|
29
|
+
* getModalsForGroup("dialog"); // Set(["key"])
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
4
33
|
declare function withModalGroups(groups: Iterable<string>): Memo<ReadonlySet<string>>;
|
|
5
34
|
//#endregion
|
|
6
35
|
export { withModalGroups };
|
|
@@ -6,9 +6,38 @@ import { INTERNAL, memo } from "@monstermann/signals";
|
|
|
6
6
|
//#region src/groups/withModalGroups.ts
|
|
7
7
|
const meta = {
|
|
8
8
|
path: "@signals-modal/groups/withModalGroups.ts",
|
|
9
|
-
line:
|
|
9
|
+
line: 53,
|
|
10
10
|
name: "withModalGroups"
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* # withModalGroups
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* function withModalGroups(groups: Iterable<string>): Memo<ReadonlySet<string>>;
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Assigns the current modal to a list of groups. Can be used to for example mark the modal as a dialog/popover/tooltip. This function must be called inside a `createModal` callback.
|
|
20
|
+
*
|
|
21
|
+
* ## Example
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import {
|
|
25
|
+
* createModal,
|
|
26
|
+
* withModalGroups,
|
|
27
|
+
* getDialogs,
|
|
28
|
+
* getGroupsForModal,
|
|
29
|
+
* getModalsForGroup,
|
|
30
|
+
* } from "@monstermann/signals-modal";
|
|
31
|
+
*
|
|
32
|
+
* createModal("key", () => {
|
|
33
|
+
* withModalGroups(["dialog"]);
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* getGroupsForModal("key"); // Set(["dialog"])
|
|
37
|
+
* getModalsForGroup("dialog"); // Set(["key"])
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
12
41
|
function withModalGroups(groups) {
|
|
13
42
|
const modal = currentModal();
|
|
14
43
|
$keysToGroups((keys) => {
|
|
@@ -12,9 +12,9 @@ function observeDimensions(element, onResize) {
|
|
|
12
12
|
observers.set(element, callbacks);
|
|
13
13
|
ro.observe(element);
|
|
14
14
|
return () => {
|
|
15
|
-
const callbacks
|
|
16
|
-
callbacks
|
|
17
|
-
if (callbacks
|
|
15
|
+
const callbacks = observers.get(element);
|
|
16
|
+
callbacks?.delete(onResize);
|
|
17
|
+
if (callbacks && callbacks.size > 0) return;
|
|
18
18
|
ro.unobserve(element);
|
|
19
19
|
};
|
|
20
20
|
}
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
import { ModalPlacement } from "./withPlacement.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/position/getModalPlacement.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* # getModalPlacement
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function getModalPlacement(key: string): ModalPlacement | undefined;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Returns the current placement for the given `key`.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalStatus,
|
|
19
|
+
* withAnchorElement,
|
|
20
|
+
* withAnchorMeasurement,
|
|
21
|
+
* withFloatingElement,
|
|
22
|
+
* withFloatingMeasurement,
|
|
23
|
+
* withBoundary,
|
|
24
|
+
* withPlacement,
|
|
25
|
+
* getModalPlacement,
|
|
26
|
+
* } from "@monstermann/signals-modal";
|
|
27
|
+
*
|
|
28
|
+
* createModal("key", () => {
|
|
29
|
+
* const { $status } = withModalStatus();
|
|
30
|
+
* const $anchorElement = withAnchorElement();
|
|
31
|
+
* const $floatingElement = withFloatingElement();
|
|
32
|
+
* const $anchorMeasurement = withAnchorMeasurement({
|
|
33
|
+
* $status,
|
|
34
|
+
* $anchorElement,
|
|
35
|
+
* });
|
|
36
|
+
* const $floatingMeasurement = withFloatingMeasurement({
|
|
37
|
+
* $status,
|
|
38
|
+
* $floatingElement,
|
|
39
|
+
* });
|
|
40
|
+
* const $boundary = withBoundary({ $status });
|
|
41
|
+
* const $placement = withPlacement({
|
|
42
|
+
* placement: "vertical-center",
|
|
43
|
+
* $boundary,
|
|
44
|
+
* $anchorMeasurement,
|
|
45
|
+
* $floatingMeasurement,
|
|
46
|
+
* });
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* getModalPlacement("key"); // up-center | down-center
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
4
53
|
declare function getModalPlacement(key: string): ModalPlacement | undefined;
|
|
5
54
|
//#endregion
|
|
6
55
|
export { getModalPlacement };
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
import { $placements } from "./internals.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/position/getModalPlacement.ts
|
|
4
|
+
/**
|
|
5
|
+
* # getModalPlacement
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* function getModalPlacement(key: string): ModalPlacement | undefined;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Returns the current placement for the given `key`.
|
|
12
|
+
*
|
|
13
|
+
* ## Example
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createModal,
|
|
18
|
+
* withModalStatus,
|
|
19
|
+
* withAnchorElement,
|
|
20
|
+
* withAnchorMeasurement,
|
|
21
|
+
* withFloatingElement,
|
|
22
|
+
* withFloatingMeasurement,
|
|
23
|
+
* withBoundary,
|
|
24
|
+
* withPlacement,
|
|
25
|
+
* getModalPlacement,
|
|
26
|
+
* } from "@monstermann/signals-modal";
|
|
27
|
+
*
|
|
28
|
+
* createModal("key", () => {
|
|
29
|
+
* const { $status } = withModalStatus();
|
|
30
|
+
* const $anchorElement = withAnchorElement();
|
|
31
|
+
* const $floatingElement = withFloatingElement();
|
|
32
|
+
* const $anchorMeasurement = withAnchorMeasurement({
|
|
33
|
+
* $status,
|
|
34
|
+
* $anchorElement,
|
|
35
|
+
* });
|
|
36
|
+
* const $floatingMeasurement = withFloatingMeasurement({
|
|
37
|
+
* $status,
|
|
38
|
+
* $floatingElement,
|
|
39
|
+
* });
|
|
40
|
+
* const $boundary = withBoundary({ $status });
|
|
41
|
+
* const $placement = withPlacement({
|
|
42
|
+
* placement: "vertical-center",
|
|
43
|
+
* $boundary,
|
|
44
|
+
* $anchorMeasurement,
|
|
45
|
+
* $floatingMeasurement,
|
|
46
|
+
* });
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* getModalPlacement("key"); // up-center | down-center
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
4
53
|
function getModalPlacement(key) {
|
|
5
54
|
return $placements().get(key)?.();
|
|
6
55
|
}
|
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
import { ModalPosition } from "./withPosition.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/position/getModalPosition.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* # getModalPosition
|
|
6
|
+
*
|
|
7
|
+
* <Badge type="tip">Reactive</Badge>
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* function getModalPosition(key: string): ModalPosition | undefined;
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Returns the current result of `withPosition`.
|
|
14
|
+
*
|
|
15
|
+
* ## Example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import {
|
|
19
|
+
* createModal,
|
|
20
|
+
* withModalStatus,
|
|
21
|
+
* withAnchorElement,
|
|
22
|
+
* withAnchorMeasurement,
|
|
23
|
+
* withFloatingElement,
|
|
24
|
+
* withFloatingMeasurement,
|
|
25
|
+
* withBoundary,
|
|
26
|
+
* withPlacement,
|
|
27
|
+
* withPosition,
|
|
28
|
+
* getModalPosition,
|
|
29
|
+
* } from "@monstermann/signals-modal";
|
|
30
|
+
*
|
|
31
|
+
* createModal("key", () => {
|
|
32
|
+
* const { $status } = withModalStatus();
|
|
33
|
+
* const $anchorElement = withAnchorElement();
|
|
34
|
+
* const $floatingElement = withFloatingElement();
|
|
35
|
+
* const $anchorMeasurement = withAnchorMeasurement({
|
|
36
|
+
* $status,
|
|
37
|
+
* $anchorElement,
|
|
38
|
+
* });
|
|
39
|
+
* const $floatingMeasurement = withFloatingMeasurement({
|
|
40
|
+
* $status,
|
|
41
|
+
* $floatingElement,
|
|
42
|
+
* });
|
|
43
|
+
* const $boundary = withBoundary({ $status });
|
|
44
|
+
* const $placement = withPlacement({
|
|
45
|
+
* placement: "vertical-center",
|
|
46
|
+
* $boundary,
|
|
47
|
+
* $anchorMeasurement,
|
|
48
|
+
* $floatingMeasurement,
|
|
49
|
+
* });
|
|
50
|
+
* const $position = withPosition({
|
|
51
|
+
* $boundary,
|
|
52
|
+
* $placement,
|
|
53
|
+
* $anchorMeasurement,
|
|
54
|
+
* $floatingMeasurement,
|
|
55
|
+
* });
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* getModalPosition("key"); // ModalPosition | undefined
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
4
62
|
declare function getModalPosition(key: string): ModalPosition | undefined;
|
|
5
63
|
//#endregion
|
|
6
64
|
export { getModalPosition };
|
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
import { $positions } from "./internals.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/position/getModalPosition.ts
|
|
4
|
+
/**
|
|
5
|
+
* # getModalPosition
|
|
6
|
+
*
|
|
7
|
+
* <Badge type="tip">Reactive</Badge>
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* function getModalPosition(key: string): ModalPosition | undefined;
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Returns the current result of `withPosition`.
|
|
14
|
+
*
|
|
15
|
+
* ## Example
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import {
|
|
19
|
+
* createModal,
|
|
20
|
+
* withModalStatus,
|
|
21
|
+
* withAnchorElement,
|
|
22
|
+
* withAnchorMeasurement,
|
|
23
|
+
* withFloatingElement,
|
|
24
|
+
* withFloatingMeasurement,
|
|
25
|
+
* withBoundary,
|
|
26
|
+
* withPlacement,
|
|
27
|
+
* withPosition,
|
|
28
|
+
* getModalPosition,
|
|
29
|
+
* } from "@monstermann/signals-modal";
|
|
30
|
+
*
|
|
31
|
+
* createModal("key", () => {
|
|
32
|
+
* const { $status } = withModalStatus();
|
|
33
|
+
* const $anchorElement = withAnchorElement();
|
|
34
|
+
* const $floatingElement = withFloatingElement();
|
|
35
|
+
* const $anchorMeasurement = withAnchorMeasurement({
|
|
36
|
+
* $status,
|
|
37
|
+
* $anchorElement,
|
|
38
|
+
* });
|
|
39
|
+
* const $floatingMeasurement = withFloatingMeasurement({
|
|
40
|
+
* $status,
|
|
41
|
+
* $floatingElement,
|
|
42
|
+
* });
|
|
43
|
+
* const $boundary = withBoundary({ $status });
|
|
44
|
+
* const $placement = withPlacement({
|
|
45
|
+
* placement: "vertical-center",
|
|
46
|
+
* $boundary,
|
|
47
|
+
* $anchorMeasurement,
|
|
48
|
+
* $floatingMeasurement,
|
|
49
|
+
* });
|
|
50
|
+
* const $position = withPosition({
|
|
51
|
+
* $boundary,
|
|
52
|
+
* $placement,
|
|
53
|
+
* $anchorMeasurement,
|
|
54
|
+
* $floatingMeasurement,
|
|
55
|
+
* });
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* getModalPosition("key"); // ModalPosition | undefined
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
4
62
|
function getModalPosition(key) {
|
|
5
63
|
return $positions().get(key)?.();
|
|
6
64
|
}
|