@monstermann/signals-modal 0.1.2 → 0.2.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/anchor/getAnchorMeasurement.js +2 -2
- package/dist/anchor/withAnchorElement.d.ts +1 -1
- package/dist/anchor/withAnchorElement.js +2 -2
- package/dist/anchor/withAnchorMeasurement.js +14 -11
- package/dist/anchor/withMouseAnchor.js +13 -11
- package/dist/floating/getFloatingMeasurement.js +2 -2
- package/dist/floating/withFloatingElement.d.ts +1 -1
- package/dist/floating/withFloatingElement.js +2 -2
- package/dist/floating/withFloatingMeasurement.js +12 -10
- package/dist/groups/withModalGroups.js +5 -5
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/position/getModalPlacement.d.ts +6 -0
- package/dist/position/getModalPlacement.js +9 -0
- package/dist/position/internals.js +14 -7
- package/dist/position/withBoundary.js +10 -8
- package/dist/position/withPlacement.js +10 -9
- package/dist/position/withPosition.js +100 -81
- package/dist/status/getOpenModals.d.ts +4 -0
- package/dist/status/getOpenModals.js +12 -0
- package/dist/status/internals.js +7 -7
- package/dist/status/isAnyModalOpen.d.ts +4 -0
- package/dist/status/isAnyModalOpen.js +9 -0
- package/dist/status/isModalOpen.d.ts +4 -0
- package/dist/status/isModalOpen.js +10 -0
- package/dist/status/withModalStatus.d.ts +7 -2
- package/dist/status/withModalStatus.js +19 -6
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { $anchorMeasurements } from "./internals.js";
|
|
2
|
-
import {
|
|
2
|
+
import { origin } from "@monstermann/geometry/Rect/origin.js";
|
|
3
3
|
|
|
4
4
|
//#region src/anchor/getAnchorMeasurement.ts
|
|
5
5
|
function getAnchorMeasurement(key) {
|
|
6
|
-
return $anchorMeasurements().get(key) ??
|
|
6
|
+
return $anchorMeasurements().get(key) ?? origin;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Signal } from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/anchor/withAnchorElement.d.ts
|
|
4
|
-
declare function withAnchorElement(anchorElement?: HTMLElement): Signal<HTMLElement | null>;
|
|
4
|
+
declare function withAnchorElement(anchorElement?: HTMLElement | null): Signal<HTMLElement | null>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { withAnchorElement };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { $anchorElements } from "./internals.js";
|
|
2
|
-
import { set } from "../node_modules/@monstermann/map/dist/Map/set.js";
|
|
3
|
-
import { remove } from "../node_modules/@monstermann/map/dist/Map/remove.js";
|
|
4
2
|
import { currentModal } from "../createModal.js";
|
|
5
3
|
import { INTERNAL, effect, signal } from "@monstermann/signals";
|
|
4
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
5
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
6
6
|
|
|
7
7
|
//#region src/anchor/withAnchorElement.ts
|
|
8
8
|
const path = "@signals-modal/anchor/withAnchorElement.ts";
|
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
import { $anchorMeasurements } from "./internals.js";
|
|
2
|
-
import { set } from "../node_modules/@monstermann/map/dist/Map/set.js";
|
|
3
|
-
import { remove } from "../node_modules/@monstermann/map/dist/Map/remove.js";
|
|
4
2
|
import { currentModal } from "../createModal.js";
|
|
5
3
|
import { observePosition } from "../internals/observePosition.js";
|
|
6
4
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
7
|
-
import {
|
|
5
|
+
import { origin } from "@monstermann/geometry/Rect/origin.js";
|
|
6
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
7
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
8
|
+
import { isEqual } from "@monstermann/geometry/Rect/isEqual.js";
|
|
9
|
+
import { fromElement } from "@monstermann/geometry/Rect/fromElement.js";
|
|
10
|
+
import { fromDOMRect } from "@monstermann/geometry/Rect/fromDOMRect.js";
|
|
8
11
|
|
|
9
12
|
//#region src/anchor/withAnchorMeasurement.ts
|
|
10
13
|
const path = "@signals-modal/anchor/withAnchorMeasurement.ts";
|
|
11
14
|
const meta = {
|
|
12
15
|
path,
|
|
13
|
-
line:
|
|
16
|
+
line: 21,
|
|
14
17
|
name: "withAnchorMeasurement.$rect"
|
|
15
18
|
};
|
|
16
19
|
const meta1 = {
|
|
17
20
|
path,
|
|
18
|
-
line:
|
|
21
|
+
line: 26,
|
|
19
22
|
name: "withAnchorMeasurement.$measurement"
|
|
20
23
|
};
|
|
21
24
|
const meta2 = {
|
|
22
25
|
path,
|
|
23
|
-
line:
|
|
26
|
+
line: 30,
|
|
24
27
|
name: "withAnchorMeasurement"
|
|
25
28
|
};
|
|
26
29
|
const meta3 = {
|
|
27
30
|
path,
|
|
28
|
-
line:
|
|
31
|
+
line: 39,
|
|
29
32
|
name: "withAnchorMeasurement"
|
|
30
33
|
};
|
|
31
34
|
function withAnchorMeasurement(options) {
|
|
32
35
|
const modal = currentModal();
|
|
33
|
-
const $rect = signal(
|
|
34
|
-
equals:
|
|
36
|
+
const $rect = signal(origin, {
|
|
37
|
+
equals: isEqual,
|
|
35
38
|
internal: true
|
|
36
39
|
}, meta);
|
|
37
40
|
const $measurement = memo(() => options.transform ? options.transform($rect()) : $rect(), INTERNAL, meta1);
|
|
@@ -40,8 +43,8 @@ function withAnchorMeasurement(options) {
|
|
|
40
43
|
const status = options.$status();
|
|
41
44
|
if (!element) return;
|
|
42
45
|
if (status === "closed") return;
|
|
43
|
-
$rect(
|
|
44
|
-
return observePosition(element, (bounds) => $rect(
|
|
46
|
+
$rect(fromElement(element));
|
|
47
|
+
return observePosition(element, (bounds) => $rect(fromDOMRect(bounds)));
|
|
45
48
|
}, INTERNAL, meta2));
|
|
46
49
|
modal.onDispose(effect(() => {
|
|
47
50
|
$anchorMeasurements((map) => set(map, modal.key, $rect()));
|
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
import { $anchorMeasurements } from "./internals.js";
|
|
2
|
-
import { set } from "../node_modules/@monstermann/map/dist/Map/set.js";
|
|
3
|
-
import { remove } from "../node_modules/@monstermann/map/dist/Map/remove.js";
|
|
4
2
|
import { currentModal } from "../createModal.js";
|
|
5
3
|
import { INTERNAL, effect, memo, peek, signal } from "@monstermann/signals";
|
|
6
|
-
import {
|
|
4
|
+
import { origin } from "@monstermann/geometry/Rect/origin.js";
|
|
5
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
6
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
7
|
+
import { isEqual } from "@monstermann/geometry/Rect/isEqual.js";
|
|
8
|
+
import { isOrigin } from "@monstermann/geometry/Rect/isOrigin.js";
|
|
7
9
|
import { $mouseX, $mouseY } from "@monstermann/signals-web";
|
|
8
10
|
|
|
9
11
|
//#region src/anchor/withMouseAnchor.ts
|
|
10
12
|
const path = "@signals-modal/anchor/withMouseAnchor.ts";
|
|
11
13
|
const meta = {
|
|
12
14
|
path,
|
|
13
|
-
line:
|
|
15
|
+
line: 19,
|
|
14
16
|
name: "withMouseAnchor.$rect"
|
|
15
17
|
};
|
|
16
18
|
const meta1 = {
|
|
17
19
|
path,
|
|
18
|
-
line:
|
|
20
|
+
line: 24,
|
|
19
21
|
name: "withMouseAnchor.$measurement"
|
|
20
22
|
};
|
|
21
23
|
const meta2 = {
|
|
22
24
|
path,
|
|
23
|
-
line:
|
|
25
|
+
line: 28,
|
|
24
26
|
name: "withMouseAnchor"
|
|
25
27
|
};
|
|
26
28
|
const meta3 = {
|
|
27
29
|
path,
|
|
28
|
-
line:
|
|
30
|
+
line: 42,
|
|
29
31
|
name: "withMouseAnchor"
|
|
30
32
|
};
|
|
31
33
|
function withMouseAnchor(options) {
|
|
32
34
|
const modal = currentModal();
|
|
33
|
-
const $rect = signal(
|
|
34
|
-
equals:
|
|
35
|
+
const $rect = signal(origin, {
|
|
36
|
+
equals: isEqual,
|
|
35
37
|
internal: true
|
|
36
38
|
}, meta);
|
|
37
39
|
const $measurement = memo(() => options.transform ? options.transform($rect()) : $rect(), INTERNAL, meta1);
|
|
38
40
|
modal.onDispose(effect(() => {
|
|
39
|
-
if (options.$status() === "closed") $rect(
|
|
40
|
-
else if (
|
|
41
|
+
if (options.$status() === "closed") $rect(origin);
|
|
42
|
+
else if (isOrigin($rect())) $rect({
|
|
41
43
|
height: 0,
|
|
42
44
|
left: peek($mouseX()),
|
|
43
45
|
top: peek($mouseY()),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { $floatingMeasurements } from "./internals.js";
|
|
2
|
-
import {
|
|
2
|
+
import { origin } from "@monstermann/geometry/Rect/origin.js";
|
|
3
3
|
|
|
4
4
|
//#region src/floating/getFloatingMeasurement.ts
|
|
5
5
|
function getFloatingMeasurement(key) {
|
|
6
|
-
return $floatingMeasurements().get(key) ??
|
|
6
|
+
return $floatingMeasurements().get(key) ?? origin;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Signal } from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/floating/withFloatingElement.d.ts
|
|
4
|
-
declare function withFloatingElement(anchorElement?: HTMLElement): Signal<HTMLElement | null>;
|
|
4
|
+
declare function withFloatingElement(anchorElement?: HTMLElement | null): Signal<HTMLElement | null>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { withFloatingElement };
|
|
@@ -1,8 +1,8 @@
|
|
|
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
1
|
import { currentModal } from "../createModal.js";
|
|
4
2
|
import { $floatingElements } from "./internals.js";
|
|
5
3
|
import { INTERNAL, effect, signal } from "@monstermann/signals";
|
|
4
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
5
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
6
6
|
|
|
7
7
|
//#region src/floating/withFloatingElement.ts
|
|
8
8
|
const path = "@signals-modal/floating/withFloatingElement.ts";
|
|
@@ -1,37 +1,39 @@
|
|
|
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
1
|
import { currentModal } from "../createModal.js";
|
|
4
2
|
import { $floatingMeasurements } from "./internals.js";
|
|
5
3
|
import { observeDimensions } from "../internals/observeDimensions.js";
|
|
6
4
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
7
|
-
import {
|
|
5
|
+
import { origin } from "@monstermann/geometry/Rect/origin.js";
|
|
6
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
7
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
8
|
+
import { isEqual } from "@monstermann/geometry/Rect/isEqual.js";
|
|
9
|
+
import { fromElement } from "@monstermann/geometry/Rect/fromElement.js";
|
|
8
10
|
|
|
9
11
|
//#region src/floating/withFloatingMeasurement.ts
|
|
10
12
|
const path = "@signals-modal/floating/withFloatingMeasurement.ts";
|
|
11
13
|
const meta = {
|
|
12
14
|
path,
|
|
13
|
-
line:
|
|
15
|
+
line: 20,
|
|
14
16
|
name: "withFloatingMeasurement.$rect"
|
|
15
17
|
};
|
|
16
18
|
const meta1 = {
|
|
17
19
|
path,
|
|
18
|
-
line:
|
|
20
|
+
line: 25,
|
|
19
21
|
name: "withFloatingMeasurement.$measurement"
|
|
20
22
|
};
|
|
21
23
|
const meta2 = {
|
|
22
24
|
path,
|
|
23
|
-
line:
|
|
25
|
+
line: 29,
|
|
24
26
|
name: "withFloatingMeasurement"
|
|
25
27
|
};
|
|
26
28
|
const meta3 = {
|
|
27
29
|
path,
|
|
28
|
-
line:
|
|
30
|
+
line: 49,
|
|
29
31
|
name: "withFloatingMeasurement"
|
|
30
32
|
};
|
|
31
33
|
function withFloatingMeasurement(options) {
|
|
32
34
|
const modal = currentModal();
|
|
33
|
-
const $rect = signal(
|
|
34
|
-
equals:
|
|
35
|
+
const $rect = signal(origin, {
|
|
36
|
+
equals: isEqual,
|
|
35
37
|
internal: true
|
|
36
38
|
}, meta);
|
|
37
39
|
const $measurement = memo(() => options.transform ? options.transform($rect()) : $rect(), INTERNAL, meta1);
|
|
@@ -40,7 +42,7 @@ function withFloatingMeasurement(options) {
|
|
|
40
42
|
const status = options.$status();
|
|
41
43
|
if (!element) return;
|
|
42
44
|
if (status === "closed") return;
|
|
43
|
-
const bounds =
|
|
45
|
+
const bounds = fromElement(element);
|
|
44
46
|
$rect({
|
|
45
47
|
height: bounds.height,
|
|
46
48
|
left: 0,
|
|
@@ -1,12 +1,12 @@
|
|
|
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 { create } from "../node_modules/@monstermann/set/dist/Set/create.js";
|
|
4
1
|
import { currentModal } from "../createModal.js";
|
|
5
2
|
import { $keysToGroups } from "./internals.js";
|
|
6
3
|
import { getGroupsForModal } from "./getGroupsForModal.js";
|
|
7
|
-
import { mapOrElse } from "../node_modules/@monstermann/map/dist/Map/mapOrElse.js";
|
|
8
|
-
import { addAll } from "../node_modules/@monstermann/set/dist/Set/addAll.js";
|
|
9
4
|
import { INTERNAL, memo } from "@monstermann/signals";
|
|
5
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
6
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
7
|
+
import { create } from "@monstermann/set/Set/create.js";
|
|
8
|
+
import { mapOrElse } from "@monstermann/map/Map/mapOrElse.js";
|
|
9
|
+
import { addAll } from "@monstermann/set/Set/addAll.js";
|
|
10
10
|
|
|
11
11
|
//#region src/groups/withModalGroups.ts
|
|
12
12
|
const meta = {
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { isTooltip } from "./groups/isTooltip.js";
|
|
|
23
23
|
import { modalGroups } from "./groups/modalGroups.js";
|
|
24
24
|
import { withModalGroups } from "./groups/withModalGroups.js";
|
|
25
25
|
import { ModalPlacement, ModalPlacementOption, withPlacement } from "./position/withPlacement.js";
|
|
26
|
+
import { getModalPlacement } from "./position/getModalPlacement.js";
|
|
26
27
|
import { ModalPosition, withPosition } from "./position/withPosition.js";
|
|
27
28
|
import { getModalPosition } from "./position/getModalPosition.js";
|
|
28
29
|
import { withBoundary } from "./position/withBoundary.js";
|
|
@@ -33,14 +34,17 @@ import { getClosingModals } from "./status/getClosingModals.js";
|
|
|
33
34
|
import { getModalStatus } from "./status/getModalStatus.js";
|
|
34
35
|
import { getOpenedModals } from "./status/getOpenedModals.js";
|
|
35
36
|
import { getOpeningModals } from "./status/getOpeningModals.js";
|
|
37
|
+
import { getOpenModals } from "./status/getOpenModals.js";
|
|
36
38
|
import { getVisibleModals } from "./status/getVisibleModals.js";
|
|
37
39
|
import { isAnyModalClosed } from "./status/isAnyModalClosed.js";
|
|
38
40
|
import { isAnyModalClosing } from "./status/isAnyModalClosing.js";
|
|
41
|
+
import { isAnyModalOpen } from "./status/isAnyModalOpen.js";
|
|
39
42
|
import { isAnyModalOpened } from "./status/isAnyModalOpened.js";
|
|
40
43
|
import { isAnyModalOpening } from "./status/isAnyModalOpening.js";
|
|
41
44
|
import { isAnyModalVisible } from "./status/isAnyModalVisible.js";
|
|
42
45
|
import { isModalClosed } from "./status/isModalClosed.js";
|
|
43
46
|
import { isModalClosing } from "./status/isModalClosing.js";
|
|
47
|
+
import { isModalOpen } from "./status/isModalOpen.js";
|
|
44
48
|
import { isModalOpened } from "./status/isModalOpened.js";
|
|
45
49
|
import { isModalOpening } from "./status/isModalOpening.js";
|
|
46
50
|
import { isModalVisible } from "./status/isModalVisible.js";
|
|
@@ -54,4 +58,4 @@ import { withModalStatus } from "./status/withModalStatus.js";
|
|
|
54
58
|
import { closeLastModalOnClickOutside } from "./utils/closeLastModalOnClickOutside.js";
|
|
55
59
|
import { closeLastModalOnEsc } from "./utils/closeLastModalOnEsc.js";
|
|
56
60
|
import { syncModalGroupsToBody } from "./utils/syncModalGroupsToBody.js";
|
|
57
|
-
export { ModalContext, ModalPlacement, ModalPlacementOption, ModalPosition, ModalStatus, closeAllModals, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPosition, getModalStatus, getModalsForGroup, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import { isModalInGroup } from "./groups/isModalInGroup.js";
|
|
|
26
26
|
import { isPopover } from "./groups/isPopover.js";
|
|
27
27
|
import { isTooltip } from "./groups/isTooltip.js";
|
|
28
28
|
import { withModalGroups } from "./groups/withModalGroups.js";
|
|
29
|
+
import { getModalPlacement } from "./position/getModalPlacement.js";
|
|
29
30
|
import { getModalPosition } from "./position/getModalPosition.js";
|
|
30
31
|
import { withBoundary } from "./position/withBoundary.js";
|
|
31
32
|
import { withPlacement } from "./position/withPlacement.js";
|
|
@@ -36,15 +37,18 @@ import { getClosingModals } from "./status/getClosingModals.js";
|
|
|
36
37
|
import { getModalStatus } from "./status/getModalStatus.js";
|
|
37
38
|
import { getOpenedModals } from "./status/getOpenedModals.js";
|
|
38
39
|
import { getOpeningModals } from "./status/getOpeningModals.js";
|
|
40
|
+
import { getOpenModals } from "./status/getOpenModals.js";
|
|
39
41
|
import { getVisibleModals } from "./status/getVisibleModals.js";
|
|
40
42
|
import { isAnyModalClosed } from "./status/isAnyModalClosed.js";
|
|
41
43
|
import { isAnyModalClosing } from "./status/isAnyModalClosing.js";
|
|
44
|
+
import { isAnyModalOpen } from "./status/isAnyModalOpen.js";
|
|
42
45
|
import { isAnyModalOpened } from "./status/isAnyModalOpened.js";
|
|
43
46
|
import { isAnyModalOpening } from "./status/isAnyModalOpening.js";
|
|
44
47
|
import { isAnyModalVisible } from "./status/isAnyModalVisible.js";
|
|
45
48
|
import { isModalClosing } from "./status/isModalClosing.js";
|
|
46
49
|
import { isModalOpened } from "./status/isModalOpened.js";
|
|
47
50
|
import { isModalOpening } from "./status/isModalOpening.js";
|
|
51
|
+
import { isModalOpen } from "./status/isModalOpen.js";
|
|
48
52
|
import { isModalVisible } from "./status/isModalVisible.js";
|
|
49
53
|
import { onModalClosing } from "./status/onModalClosing.js";
|
|
50
54
|
import { openModal } from "./status/openModal.js";
|
|
@@ -54,4 +58,4 @@ import { closeLastModalOnClickOutside } from "./utils/closeLastModalOnClickOutsi
|
|
|
54
58
|
import { closeLastModalOnEsc } from "./utils/closeLastModalOnEsc.js";
|
|
55
59
|
import { syncModalGroupsToBody } from "./utils/syncModalGroupsToBody.js";
|
|
56
60
|
|
|
57
|
-
export { closeAllModals, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPosition, getModalStatus, getModalsForGroup, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, 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 };
|
|
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 };
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
import { SILENT, signal } from "@monstermann/signals";
|
|
2
|
-
import {
|
|
2
|
+
import { setBottom } from "@monstermann/geometry/Rect/setBottom.js";
|
|
3
|
+
import { top } from "@monstermann/geometry/Rect/top.js";
|
|
4
|
+
import { setTop } from "@monstermann/geometry/Rect/setTop.js";
|
|
5
|
+
import { bottom } from "@monstermann/geometry/Rect/bottom.js";
|
|
6
|
+
import { setRight } from "@monstermann/geometry/Rect/setRight.js";
|
|
7
|
+
import { left } from "@monstermann/geometry/Rect/left.js";
|
|
8
|
+
import { setLeft } from "@monstermann/geometry/Rect/setLeft.js";
|
|
9
|
+
import { right } from "@monstermann/geometry/Rect/right.js";
|
|
3
10
|
|
|
4
11
|
//#region src/position/internals.ts
|
|
5
12
|
const path = "@signals-modal/position/internals.ts";
|
|
6
13
|
const meta = {
|
|
7
14
|
path,
|
|
8
|
-
line:
|
|
15
|
+
line: 13,
|
|
9
16
|
name: "$positions"
|
|
10
17
|
};
|
|
11
18
|
const meta1 = {
|
|
12
19
|
path,
|
|
13
|
-
line:
|
|
20
|
+
line: 14,
|
|
14
21
|
name: "$placements"
|
|
15
22
|
};
|
|
16
23
|
const $positions = signal(/* @__PURE__ */ new Map(), SILENT, meta);
|
|
17
24
|
const $placements = signal(/* @__PURE__ */ new Map(), SILENT, meta1);
|
|
18
25
|
function getBoundaryUp(boundary, anchor) {
|
|
19
|
-
return
|
|
26
|
+
return setBottom(boundary, top(anchor));
|
|
20
27
|
}
|
|
21
28
|
function getBoundaryDown(boundary, anchor) {
|
|
22
|
-
return
|
|
29
|
+
return setTop(boundary, bottom(anchor));
|
|
23
30
|
}
|
|
24
31
|
function getBoundaryLeft(boundary, anchor) {
|
|
25
|
-
return
|
|
32
|
+
return setRight(boundary, left(anchor));
|
|
26
33
|
}
|
|
27
34
|
function getBoundaryRight(boundary, anchor) {
|
|
28
|
-
return
|
|
35
|
+
return setLeft(boundary, right(anchor));
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
//#endregion
|
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import { currentModal } from "../createModal.js";
|
|
2
2
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
3
|
-
import {
|
|
3
|
+
import { origin } from "@monstermann/geometry/Rect/origin.js";
|
|
4
|
+
import { isEqual } from "@monstermann/geometry/Rect/isEqual.js";
|
|
5
|
+
import { fromWindow } from "@monstermann/geometry/Rect/fromWindow.js";
|
|
4
6
|
|
|
5
7
|
//#region src/position/withBoundary.ts
|
|
6
8
|
const path = "@signals-modal/position/withBoundary.ts";
|
|
7
9
|
const meta = {
|
|
8
10
|
path,
|
|
9
|
-
line:
|
|
11
|
+
line: 15,
|
|
10
12
|
name: "withBoundary.$rect"
|
|
11
13
|
};
|
|
12
14
|
const meta1 = {
|
|
13
15
|
path,
|
|
14
|
-
line:
|
|
16
|
+
line: 20,
|
|
15
17
|
name: "withBoundary.$boundary"
|
|
16
18
|
};
|
|
17
19
|
const meta2 = {
|
|
18
20
|
path,
|
|
19
|
-
line:
|
|
21
|
+
line: 24,
|
|
20
22
|
name: "withBoundary"
|
|
21
23
|
};
|
|
22
24
|
function withBoundary(options) {
|
|
23
25
|
const modal = currentModal();
|
|
24
|
-
const $rect = signal(
|
|
25
|
-
equals:
|
|
26
|
+
const $rect = signal(origin, {
|
|
27
|
+
equals: isEqual,
|
|
26
28
|
internal: true
|
|
27
29
|
}, meta);
|
|
28
30
|
const $boundary = memo(() => options.transform ? options.transform($rect()) : $rect(), INTERNAL, meta1);
|
|
29
31
|
modal.onDispose(effect(() => {
|
|
30
32
|
if (options.$status() === "closed") return;
|
|
31
33
|
const ac = new AbortController();
|
|
32
|
-
$rect(
|
|
34
|
+
$rect(fromWindow());
|
|
33
35
|
window.addEventListener("resize", () => {
|
|
34
|
-
$rect(
|
|
36
|
+
$rect(fromWindow());
|
|
35
37
|
}, {
|
|
36
38
|
passive: true,
|
|
37
39
|
signal: ac.signal
|
|
@@ -1,9 +1,10 @@
|
|
|
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
1
|
import { currentModal } from "../createModal.js";
|
|
4
2
|
import { $placements, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.js";
|
|
5
3
|
import { INTERNAL, effect, memo } from "@monstermann/signals";
|
|
6
|
-
import {
|
|
4
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
5
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
6
|
+
import { width } from "@monstermann/geometry/Rect/width.js";
|
|
7
|
+
import { height } from "@monstermann/geometry/Rect/height.js";
|
|
7
8
|
|
|
8
9
|
//#region src/position/withPlacement.ts
|
|
9
10
|
const path = "@signals-modal/position/withPlacement.ts";
|
|
@@ -25,32 +26,32 @@ const placementResolvers = {
|
|
|
25
26
|
"horizontal-center": function(o) {
|
|
26
27
|
const left = getBoundaryLeft(o.boundary, o.anchor);
|
|
27
28
|
const right = getBoundaryRight(o.boundary, o.anchor);
|
|
28
|
-
return
|
|
29
|
+
return width(right) >= width(left) ? "right-center" : "left-center";
|
|
29
30
|
},
|
|
30
31
|
"horizontal-down": function(o) {
|
|
31
32
|
const left = getBoundaryLeft(o.boundary, o.anchor);
|
|
32
33
|
const right = getBoundaryRight(o.boundary, o.anchor);
|
|
33
|
-
return
|
|
34
|
+
return width(right) >= width(left) ? "right-down" : "left-down";
|
|
34
35
|
},
|
|
35
36
|
"horizontal-up": function(o) {
|
|
36
37
|
const left = getBoundaryLeft(o.boundary, o.anchor);
|
|
37
38
|
const right = getBoundaryRight(o.boundary, o.anchor);
|
|
38
|
-
return
|
|
39
|
+
return width(right) >= width(left) ? "right-up" : "left-up";
|
|
39
40
|
},
|
|
40
41
|
"vertical-center": function(o) {
|
|
41
42
|
const up = getBoundaryUp(o.boundary, o.anchor);
|
|
42
43
|
const down = getBoundaryDown(o.boundary, o.anchor);
|
|
43
|
-
return
|
|
44
|
+
return height(down) >= height(up) ? "down-center" : "up-center";
|
|
44
45
|
},
|
|
45
46
|
"vertical-left": function(o) {
|
|
46
47
|
const up = getBoundaryUp(o.boundary, o.anchor);
|
|
47
48
|
const down = getBoundaryDown(o.boundary, o.anchor);
|
|
48
|
-
return
|
|
49
|
+
return height(down) >= height(up) ? "down-left" : "up-left";
|
|
49
50
|
},
|
|
50
51
|
"vertical-right": function(o) {
|
|
51
52
|
const up = getBoundaryUp(o.boundary, o.anchor);
|
|
52
53
|
const down = getBoundaryDown(o.boundary, o.anchor);
|
|
53
|
-
return
|
|
54
|
+
return height(down) >= height(up) ? "down-right" : "up-right";
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
function withPlacement(options) {
|
|
@@ -1,184 +1,203 @@
|
|
|
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
1
|
import { currentModal } from "../createModal.js";
|
|
4
2
|
import { $positions, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.js";
|
|
5
3
|
import { roundByDPR } from "../internals/roundByDPR.js";
|
|
6
4
|
import { INTERNAL, effect, memo } from "@monstermann/signals";
|
|
7
|
-
import {
|
|
5
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
6
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
7
|
+
import { top } from "@monstermann/geometry/Rect/top.js";
|
|
8
|
+
import { left } from "@monstermann/geometry/Rect/left.js";
|
|
9
|
+
import { right } from "@monstermann/geometry/Rect/right.js";
|
|
10
|
+
import { width } from "@monstermann/geometry/Rect/width.js";
|
|
11
|
+
import { height } from "@monstermann/geometry/Rect/height.js";
|
|
12
|
+
import { pipe } from "@monstermann/fn";
|
|
13
|
+
import { alignCenterX } from "@monstermann/geometry/Rect/alignCenterX.js";
|
|
14
|
+
import { snapBelow } from "@monstermann/geometry/Rect/snapBelow.js";
|
|
15
|
+
import { clamp } from "@monstermann/geometry/Rect/clamp.js";
|
|
16
|
+
import { transform } from "@monstermann/geometry/Rect/transform.js";
|
|
17
|
+
import { centerX } from "@monstermann/geometry/Rect/centerX.js";
|
|
18
|
+
import { alignRight } from "@monstermann/geometry/Rect/alignRight.js";
|
|
19
|
+
import { alignLeft } from "@monstermann/geometry/Rect/alignLeft.js";
|
|
20
|
+
import { alignCenterY } from "@monstermann/geometry/Rect/alignCenterY.js";
|
|
21
|
+
import { snapLeftOf } from "@monstermann/geometry/Rect/snapLeftOf.js";
|
|
22
|
+
import { centerY } from "@monstermann/geometry/Rect/centerY.js";
|
|
23
|
+
import { alignTop } from "@monstermann/geometry/Rect/alignTop.js";
|
|
24
|
+
import { alignBottom } from "@monstermann/geometry/Rect/alignBottom.js";
|
|
25
|
+
import { snapRightOf } from "@monstermann/geometry/Rect/snapRightOf.js";
|
|
26
|
+
import { snapAbove } from "@monstermann/geometry/Rect/snapAbove.js";
|
|
8
27
|
|
|
9
28
|
//#region src/position/withPosition.ts
|
|
10
29
|
const path = "@signals-modal/position/withPosition.ts";
|
|
11
30
|
const meta = {
|
|
12
31
|
path,
|
|
13
|
-
line:
|
|
32
|
+
line: 315,
|
|
14
33
|
name: "withPosition.$position"
|
|
15
34
|
};
|
|
16
35
|
const meta1 = {
|
|
17
36
|
path,
|
|
18
|
-
line:
|
|
37
|
+
line: 324,
|
|
19
38
|
name: "withPosition"
|
|
20
39
|
};
|
|
21
40
|
const positionResolvers = {
|
|
22
41
|
"down-center": function(o) {
|
|
23
42
|
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
24
|
-
const floating = pipe(o.floating,
|
|
25
|
-
const originX =
|
|
43
|
+
const floating = pipe(o.floating, alignCenterX(o.anchor), snapBelow(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
44
|
+
const originX = centerX(o.anchor) - left(floating);
|
|
26
45
|
return {
|
|
27
|
-
floatingX:
|
|
28
|
-
floatingY:
|
|
29
|
-
maxHeight:
|
|
30
|
-
maxWidth:
|
|
46
|
+
floatingX: left(floating),
|
|
47
|
+
floatingY: top(floating),
|
|
48
|
+
maxHeight: height(boundary),
|
|
49
|
+
maxWidth: width(boundary),
|
|
31
50
|
originX,
|
|
32
51
|
originY: 0
|
|
33
52
|
};
|
|
34
53
|
},
|
|
35
54
|
"down-left": function(o) {
|
|
36
55
|
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
37
|
-
const floating = pipe(o.floating,
|
|
38
|
-
const originX =
|
|
56
|
+
const floating = pipe(o.floating, alignRight(o.anchor), snapBelow(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
57
|
+
const originX = right(o.anchor) - left(floating);
|
|
39
58
|
return {
|
|
40
|
-
floatingX:
|
|
41
|
-
floatingY:
|
|
42
|
-
maxHeight:
|
|
43
|
-
maxWidth:
|
|
59
|
+
floatingX: left(floating),
|
|
60
|
+
floatingY: top(floating),
|
|
61
|
+
maxHeight: height(boundary),
|
|
62
|
+
maxWidth: width(boundary),
|
|
44
63
|
originX,
|
|
45
64
|
originY: 0
|
|
46
65
|
};
|
|
47
66
|
},
|
|
48
67
|
"down-right": function(o) {
|
|
49
68
|
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
50
|
-
const floating = pipe(o.floating,
|
|
69
|
+
const floating = pipe(o.floating, alignLeft(o.anchor), snapBelow(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
51
70
|
return {
|
|
52
|
-
floatingX:
|
|
53
|
-
floatingY:
|
|
54
|
-
maxHeight:
|
|
55
|
-
maxWidth:
|
|
71
|
+
floatingX: left(floating),
|
|
72
|
+
floatingY: top(floating),
|
|
73
|
+
maxHeight: height(boundary),
|
|
74
|
+
maxWidth: width(boundary),
|
|
56
75
|
originX: 0,
|
|
57
76
|
originY: 0
|
|
58
77
|
};
|
|
59
78
|
},
|
|
60
79
|
"left-center": function(o) {
|
|
61
80
|
const boundary = getBoundaryLeft(o.boundary, o.anchor);
|
|
62
|
-
const floating = pipe(o.floating,
|
|
63
|
-
const originX =
|
|
64
|
-
const originY =
|
|
81
|
+
const floating = pipe(o.floating, alignCenterY(o.anchor), snapLeftOf(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
82
|
+
const originX = width(floating);
|
|
83
|
+
const originY = centerY(o.anchor) - top(floating);
|
|
65
84
|
return {
|
|
66
|
-
floatingX:
|
|
67
|
-
floatingY:
|
|
68
|
-
maxHeight:
|
|
69
|
-
maxWidth:
|
|
85
|
+
floatingX: left(floating),
|
|
86
|
+
floatingY: top(floating),
|
|
87
|
+
maxHeight: height(boundary),
|
|
88
|
+
maxWidth: width(boundary),
|
|
70
89
|
originX,
|
|
71
90
|
originY
|
|
72
91
|
};
|
|
73
92
|
},
|
|
74
93
|
"left-down": function(o) {
|
|
75
94
|
const boundary = getBoundaryLeft(o.boundary, o.anchor);
|
|
76
|
-
const floating = pipe(o.floating,
|
|
77
|
-
const originX =
|
|
78
|
-
const originY =
|
|
95
|
+
const floating = pipe(o.floating, alignTop(o.anchor), snapLeftOf(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
96
|
+
const originX = width(floating);
|
|
97
|
+
const originY = centerY(o.anchor) - top(floating);
|
|
79
98
|
return {
|
|
80
|
-
floatingX:
|
|
81
|
-
floatingY:
|
|
82
|
-
maxHeight:
|
|
83
|
-
maxWidth:
|
|
99
|
+
floatingX: left(floating),
|
|
100
|
+
floatingY: top(floating),
|
|
101
|
+
maxHeight: height(boundary),
|
|
102
|
+
maxWidth: width(boundary),
|
|
84
103
|
originX,
|
|
85
104
|
originY
|
|
86
105
|
};
|
|
87
106
|
},
|
|
88
107
|
"left-up": function(o) {
|
|
89
108
|
const boundary = getBoundaryLeft(o.boundary, o.anchor);
|
|
90
|
-
const floating = pipe(o.floating,
|
|
91
|
-
const originX =
|
|
92
|
-
const originY =
|
|
109
|
+
const floating = pipe(o.floating, alignBottom(o.anchor), snapLeftOf(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
110
|
+
const originX = width(floating);
|
|
111
|
+
const originY = centerY(o.anchor) - top(floating);
|
|
93
112
|
return {
|
|
94
|
-
floatingX:
|
|
95
|
-
floatingY:
|
|
96
|
-
maxHeight:
|
|
97
|
-
maxWidth:
|
|
113
|
+
floatingX: left(floating),
|
|
114
|
+
floatingY: top(floating),
|
|
115
|
+
maxHeight: height(boundary),
|
|
116
|
+
maxWidth: width(boundary),
|
|
98
117
|
originX,
|
|
99
118
|
originY
|
|
100
119
|
};
|
|
101
120
|
},
|
|
102
121
|
"right-center": function(o) {
|
|
103
122
|
const boundary = getBoundaryRight(o.boundary, o.anchor);
|
|
104
|
-
const floating = pipe(o.floating,
|
|
123
|
+
const floating = pipe(o.floating, alignCenterY(o.anchor), snapRightOf(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
105
124
|
const originX = 0;
|
|
106
|
-
const originY =
|
|
125
|
+
const originY = centerY(o.anchor) - top(floating);
|
|
107
126
|
return {
|
|
108
|
-
floatingX:
|
|
109
|
-
floatingY:
|
|
110
|
-
maxHeight:
|
|
111
|
-
maxWidth:
|
|
127
|
+
floatingX: left(floating),
|
|
128
|
+
floatingY: top(floating),
|
|
129
|
+
maxHeight: height(boundary),
|
|
130
|
+
maxWidth: width(boundary),
|
|
112
131
|
originX,
|
|
113
132
|
originY
|
|
114
133
|
};
|
|
115
134
|
},
|
|
116
135
|
"right-down": function(o) {
|
|
117
136
|
const boundary = getBoundaryRight(o.boundary, o.anchor);
|
|
118
|
-
const floating = pipe(o.floating,
|
|
137
|
+
const floating = pipe(o.floating, alignTop(o.anchor), snapRightOf(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
119
138
|
const originX = 0;
|
|
120
|
-
const originY =
|
|
139
|
+
const originY = centerY(o.anchor) - top(floating);
|
|
121
140
|
return {
|
|
122
|
-
floatingX:
|
|
123
|
-
floatingY:
|
|
124
|
-
maxHeight:
|
|
125
|
-
maxWidth:
|
|
141
|
+
floatingX: left(floating),
|
|
142
|
+
floatingY: top(floating),
|
|
143
|
+
maxHeight: height(boundary),
|
|
144
|
+
maxWidth: width(boundary),
|
|
126
145
|
originX,
|
|
127
146
|
originY
|
|
128
147
|
};
|
|
129
148
|
},
|
|
130
149
|
"right-up": function(o) {
|
|
131
150
|
const boundary = getBoundaryRight(o.boundary, o.anchor);
|
|
132
|
-
const floating = pipe(o.floating,
|
|
151
|
+
const floating = pipe(o.floating, alignBottom(o.anchor), snapRightOf(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
133
152
|
const originX = 0;
|
|
134
|
-
const originY =
|
|
153
|
+
const originY = centerY(o.anchor) - top(floating);
|
|
135
154
|
return {
|
|
136
|
-
floatingX:
|
|
137
|
-
floatingY:
|
|
138
|
-
maxHeight:
|
|
139
|
-
maxWidth:
|
|
155
|
+
floatingX: left(floating),
|
|
156
|
+
floatingY: top(floating),
|
|
157
|
+
maxHeight: height(boundary),
|
|
158
|
+
maxWidth: width(boundary),
|
|
140
159
|
originX,
|
|
141
160
|
originY
|
|
142
161
|
};
|
|
143
162
|
},
|
|
144
163
|
"up-center": function(o) {
|
|
145
164
|
const boundary = getBoundaryUp(o.boundary, o.anchor);
|
|
146
|
-
const floating = pipe(o.floating,
|
|
147
|
-
const originX =
|
|
148
|
-
const originY =
|
|
165
|
+
const floating = pipe(o.floating, alignCenterX(o.anchor), snapAbove(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
166
|
+
const originX = centerX(o.anchor) - left(floating);
|
|
167
|
+
const originY = height(floating);
|
|
149
168
|
return {
|
|
150
|
-
floatingX:
|
|
151
|
-
floatingY:
|
|
152
|
-
maxHeight:
|
|
153
|
-
maxWidth:
|
|
169
|
+
floatingX: left(floating),
|
|
170
|
+
floatingY: top(floating),
|
|
171
|
+
maxHeight: height(boundary),
|
|
172
|
+
maxWidth: width(boundary),
|
|
154
173
|
originX,
|
|
155
174
|
originY
|
|
156
175
|
};
|
|
157
176
|
},
|
|
158
177
|
"up-left": function(o) {
|
|
159
178
|
const boundary = getBoundaryUp(o.boundary, o.anchor);
|
|
160
|
-
const floating = pipe(o.floating,
|
|
161
|
-
const originX =
|
|
162
|
-
const originY =
|
|
179
|
+
const floating = pipe(o.floating, alignRight(o.anchor), snapAbove(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
180
|
+
const originX = right(o.anchor) - left(floating);
|
|
181
|
+
const originY = height(floating);
|
|
163
182
|
return {
|
|
164
|
-
floatingX:
|
|
165
|
-
floatingY:
|
|
166
|
-
maxHeight:
|
|
167
|
-
maxWidth:
|
|
183
|
+
floatingX: left(floating),
|
|
184
|
+
floatingY: top(floating),
|
|
185
|
+
maxHeight: height(boundary),
|
|
186
|
+
maxWidth: width(boundary),
|
|
168
187
|
originX,
|
|
169
188
|
originY
|
|
170
189
|
};
|
|
171
190
|
},
|
|
172
191
|
"up-right": function(o) {
|
|
173
192
|
const boundary = getBoundaryUp(o.boundary, o.anchor);
|
|
174
|
-
const floating = pipe(o.floating,
|
|
193
|
+
const floating = pipe(o.floating, alignLeft(o.anchor), snapAbove(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
|
|
175
194
|
const originX = 0;
|
|
176
|
-
const originY =
|
|
195
|
+
const originY = height(floating);
|
|
177
196
|
return {
|
|
178
|
-
floatingX:
|
|
179
|
-
floatingY:
|
|
180
|
-
maxHeight:
|
|
181
|
-
maxWidth:
|
|
197
|
+
floatingX: left(floating),
|
|
198
|
+
floatingY: top(floating),
|
|
199
|
+
maxHeight: height(boundary),
|
|
200
|
+
maxWidth: width(boundary),
|
|
182
201
|
originX,
|
|
183
202
|
originY
|
|
184
203
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { $keysToStatus } from "./internals.js";
|
|
2
|
+
|
|
3
|
+
//#region src/status/getOpenModals.ts
|
|
4
|
+
function getOpenModals() {
|
|
5
|
+
const result = [];
|
|
6
|
+
const map = $keysToStatus();
|
|
7
|
+
for (const [key, $status] of map) if ($status() === "opening" || $status() === "opened") result.push(key);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getOpenModals };
|
package/dist/status/internals.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
1
|
import { onModalClosed } from "./onModalClosed.js";
|
|
5
2
|
import { onModalOpened } from "./onModalOpened.js";
|
|
6
3
|
import { onModalOpening } from "./onModalOpening.js";
|
|
7
4
|
import { onModalDisposed } from "../createModal.js";
|
|
8
5
|
import { INTERNAL, SILENT, signal } from "@monstermann/signals";
|
|
6
|
+
import { create } from "@monstermann/set/Set/create.js";
|
|
7
|
+
import { add } from "@monstermann/set/Set/add.js";
|
|
8
|
+
import { remove } from "@monstermann/set/Set/remove.js";
|
|
9
9
|
|
|
10
10
|
//#region src/status/internals.ts
|
|
11
11
|
const path = "@signals-modal/status/internals.ts";
|
|
@@ -21,10 +21,10 @@ const meta1 = {
|
|
|
21
21
|
};
|
|
22
22
|
const $keysToStatus = signal(/* @__PURE__ */ new Map(), SILENT, meta);
|
|
23
23
|
const $openedModals = signal(create(), INTERNAL, meta1);
|
|
24
|
-
onModalOpening((key) => $openedModals((m) =>
|
|
25
|
-
onModalOpened((key) => $openedModals((m) =>
|
|
26
|
-
onModalClosed((key) => $openedModals((m) =>
|
|
27
|
-
onModalDisposed((key) => $openedModals((m) =>
|
|
24
|
+
onModalOpening((key) => $openedModals((m) => add(m, key)));
|
|
25
|
+
onModalOpened((key) => $openedModals((m) => add(m, key)));
|
|
26
|
+
onModalClosed((key) => $openedModals((m) => remove(m, key)));
|
|
27
|
+
onModalDisposed((key) => $openedModals((m) => remove(m, key)));
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
30
|
export { $keysToStatus, $openedModals };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isModalOpened } from "./isModalOpened.js";
|
|
2
|
+
import { isModalOpening } from "./isModalOpening.js";
|
|
3
|
+
|
|
4
|
+
//#region src/status/isModalOpen.ts
|
|
5
|
+
function isModalOpen(key) {
|
|
6
|
+
return isModalOpening(key) || isModalOpened(key);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { isModalOpen };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ModalStatus } from "./types.js";
|
|
2
|
-
import { Signal } from "@monstermann/signals";
|
|
2
|
+
import { Memo, Signal } from "@monstermann/signals";
|
|
3
3
|
|
|
4
4
|
//#region src/status/withModalStatus.d.ts
|
|
5
|
-
declare function withModalStatus(status?: ModalStatus):
|
|
5
|
+
declare function withModalStatus(status?: ModalStatus): {
|
|
6
|
+
$isOpen: Memo<boolean>;
|
|
7
|
+
$status: Signal<ModalStatus>;
|
|
8
|
+
close: () => void;
|
|
9
|
+
open: () => void;
|
|
10
|
+
};
|
|
6
11
|
//#endregion
|
|
7
12
|
export { withModalStatus };
|
|
@@ -1,25 +1,33 @@
|
|
|
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
1
|
import { onModalClosed } from "./onModalClosed.js";
|
|
4
2
|
import { onModalOpened } from "./onModalOpened.js";
|
|
5
3
|
import { onModalOpening } from "./onModalOpening.js";
|
|
6
4
|
import { $keysToStatus } from "./internals.js";
|
|
5
|
+
import { closeModal } from "./closeModal.js";
|
|
7
6
|
import { currentModal } from "../createModal.js";
|
|
7
|
+
import { isModalOpen } from "./isModalOpen.js";
|
|
8
8
|
import { onModalClosing } from "./onModalClosing.js";
|
|
9
|
-
import {
|
|
9
|
+
import { openModal } from "./openModal.js";
|
|
10
|
+
import { INTERNAL, memo, signal, watch } from "@monstermann/signals";
|
|
11
|
+
import { set } from "@monstermann/map/Map/set.js";
|
|
12
|
+
import { remove } from "@monstermann/map/Map/remove.js";
|
|
10
13
|
|
|
11
14
|
//#region src/status/withModalStatus.ts
|
|
12
15
|
const path = "@signals-modal/status/withModalStatus.ts";
|
|
13
16
|
const meta = {
|
|
14
17
|
path,
|
|
15
|
-
line:
|
|
18
|
+
line: 23,
|
|
16
19
|
name: "withModalStatus.$status"
|
|
17
20
|
};
|
|
18
21
|
const meta1 = {
|
|
19
22
|
path,
|
|
20
|
-
line:
|
|
23
|
+
line: 28,
|
|
21
24
|
name: "withModalStatus"
|
|
22
25
|
};
|
|
26
|
+
const meta2 = {
|
|
27
|
+
path,
|
|
28
|
+
line: 36,
|
|
29
|
+
name: "withModalStatus.$isOpen"
|
|
30
|
+
};
|
|
23
31
|
function withModalStatus(status = "closed") {
|
|
24
32
|
const modal = currentModal();
|
|
25
33
|
const $status = signal(status, INTERNAL, meta);
|
|
@@ -31,7 +39,12 @@ function withModalStatus(status = "closed") {
|
|
|
31
39
|
else if (status$1 === "opening") onModalOpening(modal.key);
|
|
32
40
|
else if (status$1 === "opened") onModalOpened(modal.key);
|
|
33
41
|
}, INTERNAL, meta1));
|
|
34
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
$isOpen: memo(() => isModalOpen(modal.key), void 0, meta2),
|
|
44
|
+
$status,
|
|
45
|
+
close: () => closeModal(modal.key),
|
|
46
|
+
open: () => openModal(modal.key)
|
|
47
|
+
};
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monstermann/signals-modal",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "Composable modal management.",
|
|
6
6
|
"author": "Michael Ostermann <michaelostermann@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"release": "bun publish --access public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@monstermann/fn": "^0.
|
|
35
|
+
"@monstermann/fn": "^0.4.0",
|
|
36
36
|
"@monstermann/signals": "^0.1.1",
|
|
37
37
|
"@monstermann/signals-web": "^0.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@monstermann/unplugin-fn": "^0.
|
|
40
|
+
"@monstermann/unplugin-fn": "^0.4.0",
|
|
41
41
|
"@monstermann/unplugin-signals": "^0.1.1"
|
|
42
42
|
}
|
|
43
43
|
}
|