@monstermann/signals-modal 0.6.0 → 0.7.1
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 +0 -377
- package/dist/anchor/withAnchorElement.mjs +3 -16
- package/dist/anchor/withAnchorMeasurement.mjs +4 -14
- package/dist/anchor/withMouseAnchor.mjs +4 -14
- package/dist/createModal.d.mts +2 -2
- package/dist/createModal.mjs +2 -4
- package/dist/floating/withFloatingElement.mjs +3 -16
- package/dist/floating/withFloatingMeasurement.mjs +4 -14
- package/dist/groups/getDialogs.mjs +1 -3
- package/dist/groups/getGroupsForModal.mjs +1 -3
- package/dist/groups/getModalsForGroup.mjs +1 -3
- package/dist/groups/getPopovers.mjs +1 -3
- package/dist/groups/getTooltips.mjs +1 -3
- package/dist/groups/internals.mjs +1 -3
- package/dist/groups/isDialog.mjs +1 -3
- package/dist/groups/isModalInGroup.mjs +1 -3
- package/dist/groups/isPopover.mjs +1 -3
- package/dist/groups/isTooltip.mjs +1 -3
- package/dist/groups/modalGroups.mjs +1 -2
- package/dist/groups/withModalGroups.mjs +1 -3
- package/dist/index.d.mts +2 -14
- package/dist/index.mjs +5 -18
- package/dist/internals/observeDimensions.mjs +1 -2
- package/dist/internals/observePosition.mjs +8 -3
- package/dist/internals/roundByDPR.mjs +1 -2
- package/dist/position/internals.mjs +1 -23
- package/dist/position/withBoundary.mjs +1 -3
- package/dist/position/withPlacement.mjs +4 -16
- package/dist/position/withPosition.mjs +6 -18
- package/dist/scroll/withCloseOnScroll.mjs +1 -3
- package/dist/status/closeAllModals.mjs +1 -3
- package/dist/status/closeModal.mjs +1 -3
- package/dist/status/getClosedModals.mjs +1 -3
- package/dist/status/getClosingModals.mjs +1 -3
- package/dist/status/getModalStatus.mjs +1 -3
- package/dist/status/getOpenModals.mjs +1 -3
- package/dist/status/getOpenedModals.mjs +1 -3
- package/dist/status/getOpeningModals.mjs +1 -3
- package/dist/status/getVisibleModals.mjs +1 -3
- package/dist/status/internals.mjs +7 -38
- package/dist/status/isAnyModalClosed.mjs +1 -3
- package/dist/status/isAnyModalClosing.mjs +1 -3
- package/dist/status/isAnyModalOpen.mjs +1 -3
- package/dist/status/isAnyModalOpened.mjs +1 -3
- package/dist/status/isAnyModalOpening.mjs +1 -3
- package/dist/status/isAnyModalVisible.mjs +1 -3
- package/dist/status/isModalClosed.mjs +1 -3
- package/dist/status/isModalClosing.mjs +1 -3
- package/dist/status/isModalOpen.mjs +1 -3
- package/dist/status/isModalOpened.mjs +1 -3
- package/dist/status/isModalOpening.mjs +1 -3
- package/dist/status/isModalVisible.mjs +1 -3
- package/dist/status/onModalClosed.d.mts +2 -2
- package/dist/status/onModalClosed.mjs +6 -10
- package/dist/status/onModalClosing.d.mts +2 -2
- package/dist/status/onModalClosing.mjs +6 -10
- package/dist/status/onModalOpened.d.mts +2 -2
- package/dist/status/onModalOpened.mjs +6 -10
- package/dist/status/onModalOpening.d.mts +2 -2
- package/dist/status/onModalOpening.mjs +6 -10
- package/dist/status/openModal.mjs +1 -3
- package/dist/status/setModalStatus.mjs +1 -3
- package/dist/status/withModalStatus.mjs +4 -6
- package/package.json +1 -1
- package/dist/anchor/getAnchorElement.d.mts +0 -34
- package/dist/anchor/getAnchorElement.mjs +0 -39
- package/dist/anchor/getAnchorMeasurement.d.mts +0 -43
- package/dist/anchor/getAnchorMeasurement.mjs +0 -47
- package/dist/anchor/internals.mjs +0 -25
- package/dist/anchor/setAnchorElement.d.mts +0 -30
- package/dist/anchor/setAnchorElement.mjs +0 -35
- package/dist/floating/getFloatingElement.d.mts +0 -34
- package/dist/floating/getFloatingElement.mjs +0 -39
- package/dist/floating/getFloatingMeasurement.d.mts +0 -43
- package/dist/floating/getFloatingMeasurement.mjs +0 -47
- package/dist/floating/internals.mjs +0 -25
- package/dist/floating/setFloatingElement.d.mts +0 -30
- package/dist/floating/setFloatingElement.mjs +0 -35
- package/dist/internals/findParentElement.mjs +0 -9
- package/dist/position/getModalPlacement.d.mts +0 -55
- package/dist/position/getModalPlacement.mjs +0 -58
- package/dist/position/getModalPosition.d.mts +0 -64
- package/dist/position/getModalPosition.mjs +0 -67
- package/dist/status/closeLastModal.d.mts +0 -22
- package/dist/status/closeLastModal.mjs +0 -29
- package/dist/utils/closeLastModalOnClickOutside.d.mts +0 -22
- package/dist/utils/closeLastModalOnClickOutside.mjs +0 -37
- package/dist/utils/closeLastModalOnEsc.d.mts +0 -22
- package/dist/utils/closeLastModalOnEsc.mjs +0 -35
- package/dist/utils/syncModalGroupsToBody.d.mts +0 -41
- package/dist/utils/syncModalGroupsToBody.mjs +0 -72
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { $floatingElements } from "./internals.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/floating/getFloatingElement.ts
|
|
4
|
-
/**
|
|
5
|
-
* # getFloatingElement
|
|
6
|
-
*
|
|
7
|
-
* <Badge type="tip">Reactive</Badge>
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* function getFloatingElement(key: string): HTMLElement | undefined;
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Retrieves the current floating element for the given `key`.
|
|
14
|
-
*
|
|
15
|
-
* ## Example
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* import {
|
|
19
|
-
* createModal,
|
|
20
|
-
* withFloatingElement,
|
|
21
|
-
* setFloatingElement,
|
|
22
|
-
* getFloatingElement,
|
|
23
|
-
* } from "@monstermann/signals-modal";
|
|
24
|
-
*
|
|
25
|
-
* createModal("key", () => {
|
|
26
|
-
* withFloatingElement();
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* setFloatingElement("key", document.querySelector(".floating"));
|
|
30
|
-
* getFloatingElement("key"); // HTMLElement
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
function getFloatingElement(key) {
|
|
35
|
-
return $floatingElements().get(key)?.() ?? void 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { getFloatingElement };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Rect } from "@monstermann/geometry";
|
|
2
|
-
|
|
3
|
-
//#region src/floating/getFloatingMeasurement.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* # getFloatingMeasurement
|
|
6
|
-
*
|
|
7
|
-
* <Badge type="tip">Reactive</Badge>
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* function getFloatingMeasurement(key: string): Rect;
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Retrieves the current result of `withFloatingMeasurement`, falling back to an empty `Rect`.
|
|
14
|
-
*
|
|
15
|
-
* ## Example
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* import {
|
|
19
|
-
* createModal,
|
|
20
|
-
* withFloatingElement,
|
|
21
|
-
* withModalStatus,
|
|
22
|
-
* withFloatingMeasurement,
|
|
23
|
-
* getFloatingMeasurement,
|
|
24
|
-
* } from "@monstermann/signals-modal";
|
|
25
|
-
*
|
|
26
|
-
* createModal("key", () => {
|
|
27
|
-
* const { $status } = withModalStatus();
|
|
28
|
-
* const $floatingElement = withFloatingElement();
|
|
29
|
-
* // Memo({ top: number, left: number, width: number, height: number })
|
|
30
|
-
* const $floatingMeasurement = withFloatingMeasurement({
|
|
31
|
-
* $status,
|
|
32
|
-
* $floatingElement,
|
|
33
|
-
* });
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* // { top: number, left: number, width: number, height: number }
|
|
37
|
-
* getFloatingMeasurement("key");
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
declare function getFloatingMeasurement(key: string): Rect;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { getFloatingMeasurement };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { $floatingMeasurements } from "./internals.mjs";
|
|
2
|
-
import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/floating/getFloatingMeasurement.ts
|
|
5
|
-
/**
|
|
6
|
-
* # getFloatingMeasurement
|
|
7
|
-
*
|
|
8
|
-
* <Badge type="tip">Reactive</Badge>
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* function getFloatingMeasurement(key: string): Rect;
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* Retrieves the current result of `withFloatingMeasurement`, falling back to an empty `Rect`.
|
|
15
|
-
*
|
|
16
|
-
* ## Example
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* import {
|
|
20
|
-
* createModal,
|
|
21
|
-
* withFloatingElement,
|
|
22
|
-
* withModalStatus,
|
|
23
|
-
* withFloatingMeasurement,
|
|
24
|
-
* getFloatingMeasurement,
|
|
25
|
-
* } from "@monstermann/signals-modal";
|
|
26
|
-
*
|
|
27
|
-
* createModal("key", () => {
|
|
28
|
-
* const { $status } = withModalStatus();
|
|
29
|
-
* const $floatingElement = withFloatingElement();
|
|
30
|
-
* // Memo({ top: number, left: number, width: number, height: number })
|
|
31
|
-
* const $floatingMeasurement = withFloatingMeasurement({
|
|
32
|
-
* $status,
|
|
33
|
-
* $floatingElement,
|
|
34
|
-
* });
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // { top: number, left: number, width: number, height: number }
|
|
38
|
-
* getFloatingMeasurement("key");
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
function getFloatingMeasurement(key) {
|
|
43
|
-
return $floatingMeasurements().get(key)?.() ?? origin;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
export { getFloatingMeasurement };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { signal } from "@monstermann/signals";
|
|
2
|
-
|
|
3
|
-
//#region src/floating/internals.ts
|
|
4
|
-
const path = "@signals-modal/floating/internals.ts";
|
|
5
|
-
const meta = {
|
|
6
|
-
path,
|
|
7
|
-
line: 5,
|
|
8
|
-
name: "$floatingElements"
|
|
9
|
-
};
|
|
10
|
-
const meta1 = {
|
|
11
|
-
path,
|
|
12
|
-
line: 10,
|
|
13
|
-
name: "$floatingMeasurements"
|
|
14
|
-
};
|
|
15
|
-
const $floatingElements = signal(/* @__PURE__ */ new Map(), {
|
|
16
|
-
mutable: true,
|
|
17
|
-
silent: true
|
|
18
|
-
}, meta);
|
|
19
|
-
const $floatingMeasurements = signal(/* @__PURE__ */ new Map(), {
|
|
20
|
-
mutable: true,
|
|
21
|
-
silent: true
|
|
22
|
-
}, meta1);
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { $floatingElements, $floatingMeasurements };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region src/floating/setFloatingElement.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* # setFloatingElement
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* function setFloatingElement(key: string, element: HTMLElement | null): void;
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* Sets the current floating element for the given `key`.
|
|
10
|
-
*
|
|
11
|
-
* ## Example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import {
|
|
15
|
-
* createModal,
|
|
16
|
-
* withFloatingElement,
|
|
17
|
-
* getFloatingElement,
|
|
18
|
-
* } from "@monstermann/signals-modal";
|
|
19
|
-
*
|
|
20
|
-
* createModal("key", () => {
|
|
21
|
-
* withFloatingElement();
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* setFloatingElement("key", document.querySelector(".floating"));
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
declare function setFloatingElement(key: string, element: HTMLElement | null): void;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { setFloatingElement };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { $floatingElements } from "./internals.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/floating/setFloatingElement.ts
|
|
4
|
-
/**
|
|
5
|
-
* # setFloatingElement
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* function setFloatingElement(key: string, element: HTMLElement | null): void;
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* Sets the current floating element for the given `key`.
|
|
12
|
-
*
|
|
13
|
-
* ## Example
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import {
|
|
17
|
-
* createModal,
|
|
18
|
-
* withFloatingElement,
|
|
19
|
-
* getFloatingElement,
|
|
20
|
-
* } from "@monstermann/signals-modal";
|
|
21
|
-
*
|
|
22
|
-
* createModal("key", () => {
|
|
23
|
-
* withFloatingElement();
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* setFloatingElement("key", document.querySelector(".floating"));
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
function setFloatingElement(key, element) {
|
|
31
|
-
$floatingElements().get(key)?.(element);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { setFloatingElement };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/internals/findParentElement.ts
|
|
2
|
-
function findParentElement(element, predicate) {
|
|
3
|
-
if (!element) return void 0;
|
|
4
|
-
if (predicate(element)) return element;
|
|
5
|
-
return findParentElement(element.parentElement, predicate);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { findParentElement };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ModalPlacement } from "./withPlacement.mjs";
|
|
2
|
-
|
|
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
|
-
*/
|
|
53
|
-
declare function getModalPlacement(key: string): ModalPlacement | undefined;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { getModalPlacement };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { $placements } from "./internals.mjs";
|
|
2
|
-
|
|
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
|
-
*/
|
|
53
|
-
function getModalPlacement(key) {
|
|
54
|
-
return $placements().get(key)?.();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { getModalPlacement };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ModalPosition } from "./withPosition.mjs";
|
|
2
|
-
|
|
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
|
-
*/
|
|
62
|
-
declare function getModalPosition(key: string): ModalPosition | undefined;
|
|
63
|
-
//#endregion
|
|
64
|
-
export { getModalPosition };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { $positions } from "./internals.mjs";
|
|
2
|
-
|
|
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
|
-
*/
|
|
62
|
-
function getModalPosition(key) {
|
|
63
|
-
return $positions().get(key)?.();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
export { getModalPosition };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/status/closeLastModal.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* # closeLastModal
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* function closeLastModal(): void;
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* Closes the last opened modal by setting its status to `"closing"`.
|
|
10
|
-
*
|
|
11
|
-
* ## Example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { closeLastModal } from "@monstermann/signals-modal";
|
|
15
|
-
*
|
|
16
|
-
* closeLastModal();
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
declare function closeLastModal(): void;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { closeLastModal };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { $openedModals } from "./internals.mjs";
|
|
2
|
-
import { closeModal } from "./closeModal.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/status/closeLastModal.ts
|
|
5
|
-
/**
|
|
6
|
-
* # closeLastModal
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* function closeLastModal(): void;
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* Closes the last opened modal by setting its status to `"closing"`.
|
|
13
|
-
*
|
|
14
|
-
* ## Example
|
|
15
|
-
*
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { closeLastModal } from "@monstermann/signals-modal";
|
|
18
|
-
*
|
|
19
|
-
* closeLastModal();
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
function closeLastModal() {
|
|
24
|
-
const key = Array.from($openedModals()).at(-1);
|
|
25
|
-
if (key) closeModal(key);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
export { closeLastModal };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/utils/closeLastModalOnClickOutside.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* # closeLastModalOnClickOutside
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* function closeLastModalOnClickOutside(): void;
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* Sets up a global `mousedown` listener that closes the last opened modal when clicked outside the floating element.
|
|
10
|
-
*
|
|
11
|
-
* ## Example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { closeLastModalOnClickOutside } from "@monstermann/signals-modal";
|
|
15
|
-
*
|
|
16
|
-
* closeLastModalOnClickOutside();
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
declare function closeLastModalOnClickOutside(): void;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { closeLastModalOnClickOutside };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { $openedModals } from "../status/internals.mjs";
|
|
2
|
-
import { closeModal } from "../status/closeModal.mjs";
|
|
3
|
-
import { getFloatingElement } from "../floating/getFloatingElement.mjs";
|
|
4
|
-
import { findParentElement } from "../internals/findParentElement.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/utils/closeLastModalOnClickOutside.ts
|
|
7
|
-
/**
|
|
8
|
-
* # closeLastModalOnClickOutside
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* function closeLastModalOnClickOutside(): void;
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* Sets up a global `mousedown` listener that closes the last opened modal when clicked outside the floating element.
|
|
15
|
-
*
|
|
16
|
-
* ## Example
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* import { closeLastModalOnClickOutside } from "@monstermann/signals-modal";
|
|
20
|
-
*
|
|
21
|
-
* closeLastModalOnClickOutside();
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
function closeLastModalOnClickOutside() {
|
|
26
|
-
document.addEventListener("mousedown", (evt) => {
|
|
27
|
-
const key = Array.from($openedModals()).at(-1);
|
|
28
|
-
if (!key) return;
|
|
29
|
-
const target = evt.target;
|
|
30
|
-
const floating = getFloatingElement(key);
|
|
31
|
-
if (!floating) return;
|
|
32
|
-
if (!findParentElement(target, (el) => el === floating)) closeModal(key);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { closeLastModalOnClickOutside };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/utils/closeLastModalOnEsc.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* # closeLastModalOnEsc
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* function closeLastModalOnEsc(): void;
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* Sets up a global `keydown` listener that closes the last opened modal when `esc` is pressed, unless the target was an editable element such as `<input>`.
|
|
10
|
-
*
|
|
11
|
-
* ## Example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { closeLastModalOnEsc } from "@monstermann/signals-modal";
|
|
15
|
-
*
|
|
16
|
-
* closeLastModalOnEsc();
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
declare function closeLastModalOnEsc(): void;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { closeLastModalOnEsc };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { $openedModals } from "../status/internals.mjs";
|
|
2
|
-
import { closeModal } from "../status/closeModal.mjs";
|
|
3
|
-
import { findParentElement } from "../internals/findParentElement.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/closeLastModalOnEsc.ts
|
|
6
|
-
/**
|
|
7
|
-
* # closeLastModalOnEsc
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* function closeLastModalOnEsc(): void;
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Sets up a global `keydown` listener that closes the last opened modal when `esc` is pressed, unless the target was an editable element such as `<input>`.
|
|
14
|
-
*
|
|
15
|
-
* ## Example
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* import { closeLastModalOnEsc } from "@monstermann/signals-modal";
|
|
19
|
-
*
|
|
20
|
-
* closeLastModalOnEsc();
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
function closeLastModalOnEsc() {
|
|
25
|
-
document.addEventListener("keydown", (evt) => {
|
|
26
|
-
if (evt.key !== "Escape") return;
|
|
27
|
-
const key = Array.from($openedModals()).at(-1);
|
|
28
|
-
if (!key) return;
|
|
29
|
-
const target = evt.target;
|
|
30
|
-
if (!(target.nodeName === "INPUT" || target.nodeName === "TEXTAREA" || findParentElement(target, (el) => el.getAttribute("contenteditable") === "true"))) closeModal(key);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { closeLastModalOnEsc };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/utils/syncModalGroupsToBody.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* # syncModalGroupsToBody
|
|
4
|
-
*
|
|
5
|
-
* ```ts
|
|
6
|
-
* function syncModalGroupsToBody(): void;
|
|
7
|
-
* ```
|
|
8
|
-
*
|
|
9
|
-
* Sets up a global `Effect` that adds `has-${group}` class names to `document.body` for opened modals.
|
|
10
|
-
*
|
|
11
|
-
* ## Example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* import {
|
|
15
|
-
* createModal,
|
|
16
|
-
* withModalGroups,
|
|
17
|
-
* withModalStatus,
|
|
18
|
-
* syncModalGroupsToBody,
|
|
19
|
-
* openModal,
|
|
20
|
-
* closeModal,
|
|
21
|
-
* } from "@monstermann/signals-modal";
|
|
22
|
-
*
|
|
23
|
-
* syncModalGroupsToBody();
|
|
24
|
-
*
|
|
25
|
-
* const modal = createModal("key", () => {
|
|
26
|
-
* const $groups = withModalGroups(["dialog"]);
|
|
27
|
-
* const { $status } = withModalStatus();
|
|
28
|
-
* return { $groups, $status };
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* document.body.classList; // []
|
|
32
|
-
* openModal("key");
|
|
33
|
-
* document.body.classList; // ["has-dialog"]
|
|
34
|
-
* closeModal("key");
|
|
35
|
-
* document.body.classList; // []
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
declare function syncModalGroupsToBody(): void;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { syncModalGroupsToBody };
|