@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.
@@ -1,9 +1,9 @@
1
1
  import { $anchorMeasurements } from "./internals.js";
2
- import { Rect } from "@monstermann/fn";
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) ?? Rect.origin;
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 { Rect } from "@monstermann/fn";
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: 19,
16
+ line: 21,
14
17
  name: "withAnchorMeasurement.$rect"
15
18
  };
16
19
  const meta1 = {
17
20
  path,
18
- line: 24,
21
+ line: 26,
19
22
  name: "withAnchorMeasurement.$measurement"
20
23
  };
21
24
  const meta2 = {
22
25
  path,
23
- line: 28,
26
+ line: 30,
24
27
  name: "withAnchorMeasurement"
25
28
  };
26
29
  const meta3 = {
27
30
  path,
28
- line: 37,
31
+ line: 39,
29
32
  name: "withAnchorMeasurement"
30
33
  };
31
34
  function withAnchorMeasurement(options) {
32
35
  const modal = currentModal();
33
- const $rect = signal(Rect.origin, {
34
- equals: Rect.isEqual,
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(Rect.fromElement(element));
44
- return observePosition(element, (bounds) => $rect(Rect.fromDOMRect(bounds)));
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 { Rect } from "@monstermann/fn";
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: 18,
15
+ line: 19,
14
16
  name: "withMouseAnchor.$rect"
15
17
  };
16
18
  const meta1 = {
17
19
  path,
18
- line: 23,
20
+ line: 24,
19
21
  name: "withMouseAnchor.$measurement"
20
22
  };
21
23
  const meta2 = {
22
24
  path,
23
- line: 27,
25
+ line: 28,
24
26
  name: "withMouseAnchor"
25
27
  };
26
28
  const meta3 = {
27
29
  path,
28
- line: 41,
30
+ line: 42,
29
31
  name: "withMouseAnchor"
30
32
  };
31
33
  function withMouseAnchor(options) {
32
34
  const modal = currentModal();
33
- const $rect = signal(Rect.origin, {
34
- equals: Rect.isEqual,
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(Rect.origin);
40
- else if (Rect.isOrigin($rect())) $rect({
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 { Rect } from "@monstermann/fn";
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) ?? Rect.origin;
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 { Rect } from "@monstermann/fn";
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: 19,
15
+ line: 20,
14
16
  name: "withFloatingMeasurement.$rect"
15
17
  };
16
18
  const meta1 = {
17
19
  path,
18
- line: 24,
20
+ line: 25,
19
21
  name: "withFloatingMeasurement.$measurement"
20
22
  };
21
23
  const meta2 = {
22
24
  path,
23
- line: 28,
25
+ line: 29,
24
26
  name: "withFloatingMeasurement"
25
27
  };
26
28
  const meta3 = {
27
29
  path,
28
- line: 48,
30
+ line: 49,
29
31
  name: "withFloatingMeasurement"
30
32
  };
31
33
  function withFloatingMeasurement(options) {
32
34
  const modal = currentModal();
33
- const $rect = signal(Rect.origin, {
34
- equals: Rect.isEqual,
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 = Rect.fromElement(element);
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 };
@@ -0,0 +1,6 @@
1
+ import { ModalPlacement } from "./withPlacement.js";
2
+
3
+ //#region src/position/getModalPlacement.d.ts
4
+ declare function getModalPlacement(key: string): ModalPlacement | undefined;
5
+ //#endregion
6
+ export { getModalPlacement };
@@ -0,0 +1,9 @@
1
+ import { $placements } from "./internals.js";
2
+
3
+ //#region src/position/getModalPlacement.ts
4
+ function getModalPlacement(key) {
5
+ return $placements().get(key);
6
+ }
7
+
8
+ //#endregion
9
+ export { getModalPlacement };
@@ -1,31 +1,38 @@
1
1
  import { SILENT, signal } from "@monstermann/signals";
2
- import { Rect } from "@monstermann/fn";
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: 6,
15
+ line: 13,
9
16
  name: "$positions"
10
17
  };
11
18
  const meta1 = {
12
19
  path,
13
- line: 7,
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 Rect.setBottom(boundary, Rect.top(anchor));
26
+ return setBottom(boundary, top(anchor));
20
27
  }
21
28
  function getBoundaryDown(boundary, anchor) {
22
- return Rect.setTop(boundary, Rect.bottom(anchor));
29
+ return setTop(boundary, bottom(anchor));
23
30
  }
24
31
  function getBoundaryLeft(boundary, anchor) {
25
- return Rect.setRight(boundary, Rect.left(anchor));
32
+ return setRight(boundary, left(anchor));
26
33
  }
27
34
  function getBoundaryRight(boundary, anchor) {
28
- return Rect.setLeft(boundary, Rect.right(anchor));
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 { Rect } from "@monstermann/fn";
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: 13,
11
+ line: 15,
10
12
  name: "withBoundary.$rect"
11
13
  };
12
14
  const meta1 = {
13
15
  path,
14
- line: 18,
16
+ line: 20,
15
17
  name: "withBoundary.$boundary"
16
18
  };
17
19
  const meta2 = {
18
20
  path,
19
- line: 22,
21
+ line: 24,
20
22
  name: "withBoundary"
21
23
  };
22
24
  function withBoundary(options) {
23
25
  const modal = currentModal();
24
- const $rect = signal(Rect.origin, {
25
- equals: Rect.isEqual,
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(Rect.fromWindow());
34
+ $rect(fromWindow());
33
35
  window.addEventListener("resize", () => {
34
- $rect(Rect.fromWindow());
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 { Rect } from "@monstermann/fn";
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 Rect.width(right) >= Rect.width(left) ? "right-center" : "left-center";
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 Rect.width(right) >= Rect.width(left) ? "right-down" : "left-down";
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 Rect.width(right) >= Rect.width(left) ? "right-up" : "left-up";
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 Rect.height(down) >= Rect.height(up) ? "down-center" : "up-center";
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 Rect.height(down) >= Rect.height(up) ? "down-left" : "up-left";
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 Rect.height(down) >= Rect.height(up) ? "down-right" : "up-right";
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 { Rect, pipe } from "@monstermann/fn";
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: 296,
32
+ line: 315,
14
33
  name: "withPosition.$position"
15
34
  };
16
35
  const meta1 = {
17
36
  path,
18
- line: 305,
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, Rect.alignCenterX(o.anchor), Rect.snapBelow(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
25
- const originX = Rect.centerX(o.anchor) - Rect.left(floating);
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: Rect.left(floating),
28
- floatingY: Rect.top(floating),
29
- maxHeight: Rect.height(boundary),
30
- maxWidth: Rect.width(boundary),
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, Rect.alignRight(o.anchor), Rect.snapBelow(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
38
- const originX = Rect.right(o.anchor) - Rect.left(floating);
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: Rect.left(floating),
41
- floatingY: Rect.top(floating),
42
- maxHeight: Rect.height(boundary),
43
- maxWidth: Rect.width(boundary),
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, Rect.alignLeft(o.anchor), Rect.snapBelow(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
69
+ const floating = pipe(o.floating, alignLeft(o.anchor), snapBelow(o.anchor), clamp(boundary), transform(roundByDPR), o.transform);
51
70
  return {
52
- floatingX: Rect.left(floating),
53
- floatingY: Rect.top(floating),
54
- maxHeight: Rect.height(boundary),
55
- maxWidth: Rect.width(boundary),
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, Rect.alignCenterY(o.anchor), Rect.snapLeftOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
63
- const originX = Rect.width(floating);
64
- const originY = Rect.centerY(o.anchor) - Rect.top(floating);
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: Rect.left(floating),
67
- floatingY: Rect.top(floating),
68
- maxHeight: Rect.height(boundary),
69
- maxWidth: Rect.width(boundary),
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, Rect.alignTop(o.anchor), Rect.snapLeftOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
77
- const originX = Rect.width(floating);
78
- const originY = Rect.centerY(o.anchor) - Rect.top(floating);
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: Rect.left(floating),
81
- floatingY: Rect.top(floating),
82
- maxHeight: Rect.height(boundary),
83
- maxWidth: Rect.width(boundary),
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, Rect.alignBottom(o.anchor), Rect.snapLeftOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
91
- const originX = Rect.width(floating);
92
- const originY = Rect.centerY(o.anchor) - Rect.top(floating);
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: Rect.left(floating),
95
- floatingY: Rect.top(floating),
96
- maxHeight: Rect.height(boundary),
97
- maxWidth: Rect.width(boundary),
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, Rect.alignCenterY(o.anchor), Rect.snapRightOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
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 = Rect.centerY(o.anchor) - Rect.top(floating);
125
+ const originY = centerY(o.anchor) - top(floating);
107
126
  return {
108
- floatingX: Rect.left(floating),
109
- floatingY: Rect.top(floating),
110
- maxHeight: Rect.height(boundary),
111
- maxWidth: Rect.width(boundary),
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, Rect.alignTop(o.anchor), Rect.snapRightOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
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 = Rect.centerY(o.anchor) - Rect.top(floating);
139
+ const originY = centerY(o.anchor) - top(floating);
121
140
  return {
122
- floatingX: Rect.left(floating),
123
- floatingY: Rect.top(floating),
124
- maxHeight: Rect.height(boundary),
125
- maxWidth: Rect.width(boundary),
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, Rect.alignBottom(o.anchor), Rect.snapRightOf(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
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 = Rect.centerY(o.anchor) - Rect.top(floating);
153
+ const originY = centerY(o.anchor) - top(floating);
135
154
  return {
136
- floatingX: Rect.left(floating),
137
- floatingY: Rect.top(floating),
138
- maxHeight: Rect.height(boundary),
139
- maxWidth: Rect.width(boundary),
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, Rect.alignCenterX(o.anchor), Rect.snapAbove(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
147
- const originX = Rect.centerX(o.anchor) - Rect.left(floating);
148
- const originY = Rect.height(floating);
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: Rect.left(floating),
151
- floatingY: Rect.top(floating),
152
- maxHeight: Rect.height(boundary),
153
- maxWidth: Rect.width(boundary),
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, Rect.alignRight(o.anchor), Rect.snapAbove(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
161
- const originX = Rect.right(o.anchor) - Rect.left(floating);
162
- const originY = Rect.height(floating);
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: Rect.left(floating),
165
- floatingY: Rect.top(floating),
166
- maxHeight: Rect.height(boundary),
167
- maxWidth: Rect.width(boundary),
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, Rect.alignLeft(o.anchor), Rect.snapAbove(o.anchor), Rect.clamp(boundary), Rect.transform(roundByDPR), o.transform);
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 = Rect.height(floating);
195
+ const originY = height(floating);
177
196
  return {
178
- floatingX: Rect.left(floating),
179
- floatingY: Rect.top(floating),
180
- maxHeight: Rect.height(boundary),
181
- maxWidth: Rect.width(boundary),
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,4 @@
1
+ //#region src/status/getOpenModals.d.ts
2
+ declare function getOpenModals(): string[];
3
+ //#endregion
4
+ export { getOpenModals };
@@ -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 };
@@ -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) => remove(m, key)));
25
- onModalOpened((key) => $openedModals((m) => remove(m, key)));
26
- onModalClosed((key) => $openedModals((m) => add(m, key)));
27
- onModalDisposed((key) => $openedModals((m) => add(m, key)));
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,4 @@
1
+ //#region src/status/isAnyModalOpen.d.ts
2
+ declare function isAnyModalOpen(): boolean;
3
+ //#endregion
4
+ export { isAnyModalOpen };
@@ -0,0 +1,9 @@
1
+ import { getOpenModals } from "./getOpenModals.js";
2
+
3
+ //#region src/status/isAnyModalOpen.ts
4
+ function isAnyModalOpen() {
5
+ return getOpenModals().length > 0;
6
+ }
7
+
8
+ //#endregion
9
+ export { isAnyModalOpen };
@@ -0,0 +1,4 @@
1
+ //#region src/status/isModalOpen.d.ts
2
+ declare function isModalOpen(key: string): boolean;
3
+ //#endregion
4
+ export { isModalOpen };
@@ -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): Signal<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 { INTERNAL, signal, watch } from "@monstermann/signals";
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: 15,
18
+ line: 23,
16
19
  name: "withModalStatus.$status"
17
20
  };
18
21
  const meta1 = {
19
22
  path,
20
- line: 20,
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 $status;
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.1.2",
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.3.1",
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.3.1",
40
+ "@monstermann/unplugin-fn": "^0.4.0",
41
41
  "@monstermann/unplugin-signals": "^0.1.1"
42
42
  }
43
43
  }