@monstermann/signals-modal 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +0 -377
  2. package/dist/anchor/withAnchorElement.mjs +3 -16
  3. package/dist/anchor/withAnchorMeasurement.mjs +4 -14
  4. package/dist/anchor/withMouseAnchor.mjs +4 -14
  5. package/dist/createModal.d.mts +2 -2
  6. package/dist/createModal.mjs +2 -4
  7. package/dist/floating/withFloatingElement.mjs +3 -16
  8. package/dist/floating/withFloatingMeasurement.mjs +4 -14
  9. package/dist/groups/getDialogs.mjs +1 -3
  10. package/dist/groups/getGroupsForModal.mjs +1 -3
  11. package/dist/groups/getModalsForGroup.mjs +1 -3
  12. package/dist/groups/getPopovers.mjs +1 -3
  13. package/dist/groups/getTooltips.mjs +1 -3
  14. package/dist/groups/internals.mjs +1 -3
  15. package/dist/groups/isDialog.mjs +1 -3
  16. package/dist/groups/isModalInGroup.mjs +1 -3
  17. package/dist/groups/isPopover.mjs +1 -3
  18. package/dist/groups/isTooltip.mjs +1 -3
  19. package/dist/groups/modalGroups.mjs +1 -2
  20. package/dist/groups/withModalGroups.mjs +1 -3
  21. package/dist/index.d.mts +2 -14
  22. package/dist/index.mjs +5 -18
  23. package/dist/internals/observeDimensions.mjs +1 -2
  24. package/dist/internals/observePosition.mjs +8 -3
  25. package/dist/internals/roundByDPR.mjs +1 -2
  26. package/dist/position/internals.mjs +1 -23
  27. package/dist/position/withBoundary.mjs +1 -3
  28. package/dist/position/withPlacement.mjs +4 -16
  29. package/dist/position/withPosition.mjs +6 -18
  30. package/dist/scroll/withCloseOnScroll.mjs +1 -3
  31. package/dist/status/closeAllModals.mjs +1 -3
  32. package/dist/status/closeModal.mjs +1 -3
  33. package/dist/status/getClosedModals.mjs +1 -3
  34. package/dist/status/getClosingModals.mjs +1 -3
  35. package/dist/status/getModalStatus.mjs +1 -3
  36. package/dist/status/getOpenModals.mjs +1 -3
  37. package/dist/status/getOpenedModals.mjs +1 -3
  38. package/dist/status/getOpeningModals.mjs +1 -3
  39. package/dist/status/getVisibleModals.mjs +1 -3
  40. package/dist/status/internals.mjs +7 -38
  41. package/dist/status/isAnyModalClosed.mjs +1 -3
  42. package/dist/status/isAnyModalClosing.mjs +1 -3
  43. package/dist/status/isAnyModalOpen.mjs +1 -3
  44. package/dist/status/isAnyModalOpened.mjs +1 -3
  45. package/dist/status/isAnyModalOpening.mjs +1 -3
  46. package/dist/status/isAnyModalVisible.mjs +1 -3
  47. package/dist/status/isModalClosed.mjs +1 -3
  48. package/dist/status/isModalClosing.mjs +1 -3
  49. package/dist/status/isModalOpen.mjs +1 -3
  50. package/dist/status/isModalOpened.mjs +1 -3
  51. package/dist/status/isModalOpening.mjs +1 -3
  52. package/dist/status/isModalVisible.mjs +1 -3
  53. package/dist/status/onModalClosed.d.mts +2 -2
  54. package/dist/status/onModalClosed.mjs +6 -10
  55. package/dist/status/onModalClosing.d.mts +2 -2
  56. package/dist/status/onModalClosing.mjs +6 -10
  57. package/dist/status/onModalOpened.d.mts +2 -2
  58. package/dist/status/onModalOpened.mjs +6 -10
  59. package/dist/status/onModalOpening.d.mts +2 -2
  60. package/dist/status/onModalOpening.mjs +6 -10
  61. package/dist/status/openModal.mjs +1 -3
  62. package/dist/status/setModalStatus.mjs +1 -3
  63. package/dist/status/withModalStatus.mjs +4 -6
  64. package/package.json +1 -1
  65. package/dist/anchor/getAnchorElement.d.mts +0 -34
  66. package/dist/anchor/getAnchorElement.mjs +0 -39
  67. package/dist/anchor/getAnchorMeasurement.d.mts +0 -43
  68. package/dist/anchor/getAnchorMeasurement.mjs +0 -47
  69. package/dist/anchor/internals.mjs +0 -25
  70. package/dist/anchor/setAnchorElement.d.mts +0 -30
  71. package/dist/anchor/setAnchorElement.mjs +0 -35
  72. package/dist/floating/getFloatingElement.d.mts +0 -34
  73. package/dist/floating/getFloatingElement.mjs +0 -39
  74. package/dist/floating/getFloatingMeasurement.d.mts +0 -43
  75. package/dist/floating/getFloatingMeasurement.mjs +0 -47
  76. package/dist/floating/internals.mjs +0 -25
  77. package/dist/floating/setFloatingElement.d.mts +0 -30
  78. package/dist/floating/setFloatingElement.mjs +0 -35
  79. package/dist/internals/findParentElement.mjs +0 -9
  80. package/dist/position/getModalPlacement.d.mts +0 -55
  81. package/dist/position/getModalPlacement.mjs +0 -58
  82. package/dist/position/getModalPosition.d.mts +0 -64
  83. package/dist/position/getModalPosition.mjs +0 -67
  84. package/dist/status/closeLastModal.d.mts +0 -22
  85. package/dist/status/closeLastModal.mjs +0 -29
  86. package/dist/utils/closeLastModalOnClickOutside.d.mts +0 -22
  87. package/dist/utils/closeLastModalOnClickOutside.mjs +0 -37
  88. package/dist/utils/closeLastModalOnEsc.d.mts +0 -22
  89. package/dist/utils/closeLastModalOnEsc.mjs +0 -35
  90. package/dist/utils/syncModalGroupsToBody.d.mts +0 -41
  91. package/dist/utils/syncModalGroupsToBody.mjs +0 -72
@@ -1,6 +1,5 @@
1
1
  import { getModalsForGroup } from "./getModalsForGroup.mjs";
2
2
  import { modalGroups } from "./modalGroups.mjs";
3
-
4
3
  //#region src/groups/getPopovers.ts
5
4
  /**
6
5
  * # getPopovers
@@ -34,6 +33,5 @@ import { modalGroups } from "./modalGroups.mjs";
34
33
  function getPopovers() {
35
34
  return getModalsForGroup(modalGroups.popover);
36
35
  }
37
-
38
36
  //#endregion
39
- export { getPopovers };
37
+ export { getPopovers };
@@ -1,6 +1,5 @@
1
1
  import { getModalsForGroup } from "./getModalsForGroup.mjs";
2
2
  import { modalGroups } from "./modalGroups.mjs";
3
-
4
3
  //#region src/groups/getTooltips.ts
5
4
  /**
6
5
  * # getTooltips
@@ -34,6 +33,5 @@ import { modalGroups } from "./modalGroups.mjs";
34
33
  function getTooltips() {
35
34
  return getModalsForGroup(modalGroups.tooltip);
36
35
  }
37
-
38
36
  //#endregion
39
- export { getTooltips };
37
+ export { getTooltips };
@@ -1,5 +1,4 @@
1
1
  import { INTERNAL, memo, signal } from "@monstermann/signals";
2
-
3
2
  //#region src/groups/internals.ts
4
3
  const path = "@signals-modal/groups/internals.ts";
5
4
  const meta = {
@@ -24,6 +23,5 @@ const $groupsToKeys = memo(() => {
24
23
  }
25
24
  return map;
26
25
  }, INTERNAL, meta1);
27
-
28
26
  //#endregion
29
- export { $groupsToKeys, $keysToGroups };
27
+ export { $groupsToKeys, $keysToGroups };
@@ -1,6 +1,5 @@
1
1
  import { modalGroups } from "./modalGroups.mjs";
2
2
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
3
-
4
3
  //#region src/groups/isDialog.ts
5
4
  /**
6
5
  * # isDialog
@@ -34,6 +33,5 @@ import { getGroupsForModal } from "./getGroupsForModal.mjs";
34
33
  function isDialog(key) {
35
34
  return getGroupsForModal(key).has(modalGroups.dialog);
36
35
  }
37
-
38
36
  //#endregion
39
- export { isDialog };
37
+ export { isDialog };
@@ -1,5 +1,4 @@
1
1
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
2
-
3
2
  //#region src/groups/isModalInGroup.ts
4
3
  /**
5
4
  * # isModalInGroup
@@ -33,6 +32,5 @@ import { getGroupsForModal } from "./getGroupsForModal.mjs";
33
32
  function isModalInGroup(key, group) {
34
33
  return getGroupsForModal(key).has(group);
35
34
  }
36
-
37
35
  //#endregion
38
- export { isModalInGroup };
36
+ export { isModalInGroup };
@@ -1,6 +1,5 @@
1
1
  import { modalGroups } from "./modalGroups.mjs";
2
2
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
3
-
4
3
  //#region src/groups/isPopover.ts
5
4
  /**
6
5
  * # isPopover
@@ -34,6 +33,5 @@ import { getGroupsForModal } from "./getGroupsForModal.mjs";
34
33
  function isPopover(key) {
35
34
  return getGroupsForModal(key).has(modalGroups.popover);
36
35
  }
37
-
38
36
  //#endregion
39
- export { isPopover };
37
+ export { isPopover };
@@ -1,6 +1,5 @@
1
1
  import { modalGroups } from "./modalGroups.mjs";
2
2
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
3
-
4
3
  //#region src/groups/isTooltip.ts
5
4
  /**
6
5
  * # isTooltip
@@ -34,6 +33,5 @@ import { getGroupsForModal } from "./getGroupsForModal.mjs";
34
33
  function isTooltip(key) {
35
34
  return getGroupsForModal(key).has(modalGroups.tooltip);
36
35
  }
37
-
38
36
  //#endregion
39
- export { isTooltip };
37
+ export { isTooltip };
@@ -46,6 +46,5 @@ const modalGroups = {
46
46
  * A record containing common modal groups.
47
47
  *
48
48
  */
49
-
50
49
  //#endregion
51
- export { modalGroups };
50
+ export { modalGroups };
@@ -2,7 +2,6 @@ import { currentModal } from "../createModal.mjs";
2
2
  import { $keysToGroups } from "./internals.mjs";
3
3
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
4
4
  import { INTERNAL, memo } from "@monstermann/signals";
5
-
6
5
  //#region src/groups/withModalGroups.ts
7
6
  const meta = {
8
7
  path: "@signals-modal/groups/withModalGroups.ts",
@@ -54,6 +53,5 @@ function withModalGroups(groups) {
54
53
  });
55
54
  return memo(() => getGroupsForModal(modal.key), INTERNAL, meta);
56
55
  }
57
-
58
56
  //#endregion
59
- export { withModalGroups };
57
+ export { withModalGroups };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,8 @@
1
- import { getAnchorElement } from "./anchor/getAnchorElement.mjs";
2
- import { getAnchorMeasurement } from "./anchor/getAnchorMeasurement.mjs";
3
- import { setAnchorElement } from "./anchor/setAnchorElement.mjs";
4
1
  import { withAnchorElement } from "./anchor/withAnchorElement.mjs";
5
2
  import { ModalStatus } from "./status/types.mjs";
6
3
  import { withAnchorMeasurement } from "./anchor/withAnchorMeasurement.mjs";
7
4
  import { withMouseAnchor } from "./anchor/withMouseAnchor.mjs";
8
5
  import { ModalContext, createModal, currentModal, onModalDisposed } from "./createModal.mjs";
9
- import { getFloatingElement } from "./floating/getFloatingElement.mjs";
10
- import { getFloatingMeasurement } from "./floating/getFloatingMeasurement.mjs";
11
- import { setFloatingElement } from "./floating/setFloatingElement.mjs";
12
6
  import { withFloatingElement } from "./floating/withFloatingElement.mjs";
13
7
  import { withFloatingMeasurement } from "./floating/withFloatingMeasurement.mjs";
14
8
  import { getDialogs } from "./groups/getDialogs.mjs";
@@ -22,14 +16,11 @@ import { isPopover } from "./groups/isPopover.mjs";
22
16
  import { isTooltip } from "./groups/isTooltip.mjs";
23
17
  import { modalGroups } from "./groups/modalGroups.mjs";
24
18
  import { withModalGroups } from "./groups/withModalGroups.mjs";
19
+ import { withBoundary } from "./position/withBoundary.mjs";
25
20
  import { ModalPlacement, ModalPlacementOption, withPlacement } from "./position/withPlacement.mjs";
26
- import { getModalPlacement } from "./position/getModalPlacement.mjs";
27
21
  import { ModalPosition, withPosition } from "./position/withPosition.mjs";
28
- import { getModalPosition } from "./position/getModalPosition.mjs";
29
- import { withBoundary } from "./position/withBoundary.mjs";
30
22
  import { withCloseOnScroll } from "./scroll/withCloseOnScroll.mjs";
31
23
  import { closeAllModals } from "./status/closeAllModals.mjs";
32
- import { closeLastModal } from "./status/closeLastModal.mjs";
33
24
  import { closeModal } from "./status/closeModal.mjs";
34
25
  import { getClosedModals } from "./status/getClosedModals.mjs";
35
26
  import { getClosingModals } from "./status/getClosingModals.mjs";
@@ -57,7 +48,4 @@ import { onModalOpening } from "./status/onModalOpening.mjs";
57
48
  import { openModal } from "./status/openModal.mjs";
58
49
  import { setModalStatus } from "./status/setModalStatus.mjs";
59
50
  import { withModalStatus } from "./status/withModalStatus.mjs";
60
- import { closeLastModalOnClickOutside } from "./utils/closeLastModalOnClickOutside.mjs";
61
- import { closeLastModalOnEsc } from "./utils/closeLastModalOnEsc.mjs";
62
- import { syncModalGroupsToBody } from "./utils/syncModalGroupsToBody.mjs";
63
- export { ModalContext, ModalPlacement, ModalPlacementOption, ModalPosition, ModalStatus, closeAllModals, closeLastModal, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPlacement, getModalPosition, getModalStatus, getModalsForGroup, getOpenModals, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpen, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, isModalOpen, isModalOpened, isModalOpening, isModalVisible, isPopover, isTooltip, modalGroups, onModalClosed, onModalClosing, onModalDisposed, onModalOpened, onModalOpening, openModal, setAnchorElement, setFloatingElement, setModalStatus, syncModalGroupsToBody, withAnchorElement, withAnchorMeasurement, withBoundary, withCloseOnScroll, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
51
+ export { ModalContext, ModalPlacement, ModalPlacementOption, ModalPosition, ModalStatus, closeAllModals, closeModal, createModal, currentModal, getClosedModals, getClosingModals, getDialogs, getGroupsForModal, 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, setModalStatus, withAnchorElement, withAnchorMeasurement, withBoundary, withCloseOnScroll, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
package/dist/index.mjs CHANGED
@@ -1,18 +1,10 @@
1
- import { getAnchorElement } from "./anchor/getAnchorElement.mjs";
2
- import { getAnchorMeasurement } from "./anchor/getAnchorMeasurement.mjs";
3
- import { setAnchorElement } from "./anchor/setAnchorElement.mjs";
4
- import { onModalClosed } from "./status/onModalClosed.mjs";
5
- import { onModalOpened } from "./status/onModalOpened.mjs";
6
- import { onModalOpening } from "./status/onModalOpening.mjs";
1
+ import { withAnchorElement } from "./anchor/withAnchorElement.mjs";
7
2
  import { closeModal } from "./status/closeModal.mjs";
8
3
  import { isModalClosed } from "./status/isModalClosed.mjs";
4
+ import { onModalClosed } from "./status/onModalClosed.mjs";
9
5
  import { createModal, currentModal, onModalDisposed } from "./createModal.mjs";
10
- import { withAnchorElement } from "./anchor/withAnchorElement.mjs";
11
6
  import { withAnchorMeasurement } from "./anchor/withAnchorMeasurement.mjs";
12
7
  import { withMouseAnchor } from "./anchor/withMouseAnchor.mjs";
13
- import { getFloatingElement } from "./floating/getFloatingElement.mjs";
14
- import { getFloatingMeasurement } from "./floating/getFloatingMeasurement.mjs";
15
- import { setFloatingElement } from "./floating/setFloatingElement.mjs";
16
8
  import { withFloatingElement } from "./floating/withFloatingElement.mjs";
17
9
  import { withFloatingMeasurement } from "./floating/withFloatingMeasurement.mjs";
18
10
  import { getModalsForGroup } from "./groups/getModalsForGroup.mjs";
@@ -26,14 +18,11 @@ import { isModalInGroup } from "./groups/isModalInGroup.mjs";
26
18
  import { isPopover } from "./groups/isPopover.mjs";
27
19
  import { isTooltip } from "./groups/isTooltip.mjs";
28
20
  import { withModalGroups } from "./groups/withModalGroups.mjs";
29
- import { getModalPlacement } from "./position/getModalPlacement.mjs";
30
- import { getModalPosition } from "./position/getModalPosition.mjs";
31
21
  import { withBoundary } from "./position/withBoundary.mjs";
32
22
  import { withPlacement } from "./position/withPlacement.mjs";
33
23
  import { withPosition } from "./position/withPosition.mjs";
34
24
  import { withCloseOnScroll } from "./scroll/withCloseOnScroll.mjs";
35
25
  import { closeAllModals } from "./status/closeAllModals.mjs";
36
- import { closeLastModal } from "./status/closeLastModal.mjs";
37
26
  import { getClosedModals } from "./status/getClosedModals.mjs";
38
27
  import { getClosingModals } from "./status/getClosingModals.mjs";
39
28
  import { getModalStatus } from "./status/getModalStatus.mjs";
@@ -53,11 +42,9 @@ import { isModalOpening } from "./status/isModalOpening.mjs";
53
42
  import { isModalOpen } from "./status/isModalOpen.mjs";
54
43
  import { isModalVisible } from "./status/isModalVisible.mjs";
55
44
  import { onModalClosing } from "./status/onModalClosing.mjs";
45
+ import { onModalOpened } from "./status/onModalOpened.mjs";
46
+ import { onModalOpening } from "./status/onModalOpening.mjs";
56
47
  import { openModal } from "./status/openModal.mjs";
57
48
  import { setModalStatus } from "./status/setModalStatus.mjs";
58
49
  import { withModalStatus } from "./status/withModalStatus.mjs";
59
- import { closeLastModalOnClickOutside } from "./utils/closeLastModalOnClickOutside.mjs";
60
- import { closeLastModalOnEsc } from "./utils/closeLastModalOnEsc.mjs";
61
- import { syncModalGroupsToBody } from "./utils/syncModalGroupsToBody.mjs";
62
-
63
- export { closeAllModals, closeLastModal, closeLastModalOnClickOutside, closeLastModalOnEsc, closeModal, createModal, currentModal, getAnchorElement, getAnchorMeasurement, getClosedModals, getClosingModals, getDialogs, getFloatingElement, getFloatingMeasurement, getGroupsForModal, getModalPlacement, getModalPosition, getModalStatus, getModalsForGroup, getOpenModals, getOpenedModals, getOpeningModals, getPopovers, getTooltips, getVisibleModals, isAnyModalClosed, isAnyModalClosing, isAnyModalOpen, isAnyModalOpened, isAnyModalOpening, isAnyModalVisible, isDialog, isModalClosed, isModalClosing, isModalInGroup, isModalOpen, isModalOpened, isModalOpening, isModalVisible, isPopover, isTooltip, modalGroups, onModalClosed, onModalClosing, onModalDisposed, onModalOpened, onModalOpening, openModal, setAnchorElement, setFloatingElement, setModalStatus, syncModalGroupsToBody, withAnchorElement, withAnchorMeasurement, withBoundary, withCloseOnScroll, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
50
+ export { closeAllModals, closeModal, createModal, currentModal, getClosedModals, getClosingModals, getDialogs, getGroupsForModal, 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, setModalStatus, withAnchorElement, withAnchorMeasurement, withBoundary, withCloseOnScroll, withFloatingElement, withFloatingMeasurement, withModalGroups, withModalStatus, withMouseAnchor, withPlacement, withPosition };
@@ -18,6 +18,5 @@ function observeDimensions(element, onResize) {
18
18
  ro.unobserve(element);
19
19
  };
20
20
  }
21
-
22
21
  //#endregion
23
- export { observeDimensions };
22
+ export { observeDimensions };
@@ -33,12 +33,17 @@ function observePosition(element, onMove) {
33
33
  });
34
34
  io.observe(element);
35
35
  }
36
+ const ro = new ResizeObserver(() => refresh());
37
+ ro.observe(element);
38
+ const fullCleanup = () => {
39
+ cleanup();
40
+ ro.disconnect();
41
+ };
36
42
  refresh(true);
37
- return cleanup;
43
+ return fullCleanup;
38
44
  }
39
45
  function rectsEqual(a, b) {
40
46
  return a.top === b.top && a.left === b.left && a.width === b.width && a.height === b.height;
41
47
  }
42
-
43
48
  //#endregion
44
- export { observePosition };
49
+ export { observePosition };
@@ -3,6 +3,5 @@ function roundByDPR(value) {
3
3
  const dpr = window.devicePixelRatio || 1;
4
4
  return Math.round(value * dpr) / dpr;
5
5
  }
6
-
7
6
  //#endregion
8
- export { roundByDPR };
7
+ export { roundByDPR };
@@ -1,4 +1,3 @@
1
- import { signal } from "@monstermann/signals";
2
1
  import { setBottom } from "@monstermann/geometry/Rect/setBottom.mjs";
3
2
  import { top } from "@monstermann/geometry/Rect/top.mjs";
4
3
  import { setTop } from "@monstermann/geometry/Rect/setTop.mjs";
@@ -7,27 +6,7 @@ import { setRight } from "@monstermann/geometry/Rect/setRight.mjs";
7
6
  import { left } from "@monstermann/geometry/Rect/left.mjs";
8
7
  import { setLeft } from "@monstermann/geometry/Rect/setLeft.mjs";
9
8
  import { right } from "@monstermann/geometry/Rect/right.mjs";
10
-
11
9
  //#region src/position/internals.ts
12
- const path = "@signals-modal/position/internals.ts";
13
- const meta = {
14
- path,
15
- line: 14,
16
- name: "$positions"
17
- };
18
- const meta1 = {
19
- path,
20
- line: 19,
21
- name: "$placements"
22
- };
23
- const $positions = signal(/* @__PURE__ */ new Map(), {
24
- mutable: true,
25
- silent: true
26
- }, meta);
27
- const $placements = signal(/* @__PURE__ */ new Map(), {
28
- mutable: true,
29
- silent: true
30
- }, meta1);
31
10
  function getBoundaryUp(boundary, anchor) {
32
11
  return setBottom(boundary, top(anchor));
33
12
  }
@@ -40,6 +19,5 @@ function getBoundaryLeft(boundary, anchor) {
40
19
  function getBoundaryRight(boundary, anchor) {
41
20
  return setLeft(boundary, right(anchor));
42
21
  }
43
-
44
22
  //#endregion
45
- export { $placements, $positions, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp };
23
+ export { getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp };
@@ -3,7 +3,6 @@ import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
3
3
  import { origin } from "@monstermann/geometry/Rect/origin.mjs";
4
4
  import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
5
5
  import { fromWindow } from "@monstermann/geometry/Rect/fromWindow.mjs";
6
-
7
6
  //#region src/position/withBoundary.ts
8
7
  const path = "@signals-modal/position/withBoundary.ts";
9
8
  const meta = {
@@ -72,6 +71,5 @@ function withBoundary(options) {
72
71
  }, INTERNAL, meta2));
73
72
  return $boundary;
74
73
  }
75
-
76
74
  //#endregion
77
- export { withBoundary };
75
+ export { withBoundary };
@@ -1,13 +1,11 @@
1
- import { currentModal } from "../createModal.mjs";
2
- import { $placements, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.mjs";
1
+ import { getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.mjs";
3
2
  import { INTERNAL, memo } from "@monstermann/signals";
4
3
  import { width } from "@monstermann/geometry/Rect/width.mjs";
5
4
  import { height } from "@monstermann/geometry/Rect/height.mjs";
6
-
7
5
  //#region src/position/withPlacement.ts
8
6
  const meta = {
9
7
  path: "@signals-modal/position/withPlacement.ts",
10
- line: 174,
8
+ line: 172,
11
9
  name: "withPlacement.$placement"
12
10
  };
13
11
  const placementResolvers = {
@@ -118,23 +116,13 @@ const placementResolvers = {
118
116
  *
119
117
  */
120
118
  function withPlacement(options) {
121
- const modal = currentModal();
122
- const $placement = memo(() => {
119
+ return memo(() => {
123
120
  return placementResolvers[options.placement]({
124
121
  anchor: options.$anchorMeasurement(),
125
122
  boundary: options.$boundary(),
126
123
  floating: options.$floatingMeasurement()
127
124
  });
128
125
  }, INTERNAL, meta);
129
- $placements((p) => p.set(modal.key, $placement));
130
- modal.onDispose(() => {
131
- $placements((p) => {
132
- p.delete(modal.key);
133
- return p;
134
- });
135
- });
136
- return $placement;
137
126
  }
138
-
139
127
  //#endregion
140
- export { withPlacement };
128
+ export { withPlacement };
@@ -1,12 +1,11 @@
1
- import { currentModal } from "../createModal.mjs";
2
- import { $positions, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.mjs";
1
+ import { getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.mjs";
3
2
  import { roundByDPR } from "../internals/roundByDPR.mjs";
4
3
  import { INTERNAL, memo } from "@monstermann/signals";
4
+ import { width } from "@monstermann/geometry/Rect/width.mjs";
5
+ import { height } from "@monstermann/geometry/Rect/height.mjs";
5
6
  import { top } from "@monstermann/geometry/Rect/top.mjs";
6
7
  import { left } from "@monstermann/geometry/Rect/left.mjs";
7
8
  import { right } from "@monstermann/geometry/Rect/right.mjs";
8
- import { width } from "@monstermann/geometry/Rect/width.mjs";
9
- import { height } from "@monstermann/geometry/Rect/height.mjs";
10
9
  import { pipe } from "@monstermann/dfdl";
11
10
  import { alignCenterX } from "@monstermann/geometry/Rect/alignCenterX.mjs";
12
11
  import { snapBelow } from "@monstermann/geometry/Rect/snapBelow.mjs";
@@ -22,11 +21,10 @@ import { alignTop } from "@monstermann/geometry/Rect/alignTop.mjs";
22
21
  import { alignBottom } from "@monstermann/geometry/Rect/alignBottom.mjs";
23
22
  import { snapRightOf } from "@monstermann/geometry/Rect/snapRightOf.mjs";
24
23
  import { snapAbove } from "@monstermann/geometry/Rect/snapAbove.mjs";
25
-
26
24
  //#region src/position/withPosition.ts
27
25
  const meta = {
28
26
  path: "@signals-modal/position/withPosition.ts",
29
- line: 378,
27
+ line: 376,
30
28
  name: "withPosition.$position"
31
29
  };
32
30
  const positionResolvers = {
@@ -262,8 +260,7 @@ const positionResolvers = {
262
260
  *
263
261
  */
264
262
  function withPosition(options) {
265
- const modal = currentModal();
266
- const $position = memo(() => {
263
+ return memo(() => {
267
264
  return positionResolvers[options.$placement()]({
268
265
  anchor: options.$anchorMeasurement(),
269
266
  boundary: options.$boundary(),
@@ -271,15 +268,6 @@ function withPosition(options) {
271
268
  transform: options.transform ?? ((r) => r)
272
269
  });
273
270
  }, INTERNAL, meta);
274
- $positions((p) => p.set(modal.key, $position));
275
- modal.onDispose(() => {
276
- $positions((p) => {
277
- p.delete(modal.key);
278
- return p;
279
- });
280
- });
281
- return $position;
282
271
  }
283
-
284
272
  //#endregion
285
- export { withPosition };
273
+ export { withPosition };
@@ -1,7 +1,6 @@
1
1
  import { closeModal } from "../status/closeModal.mjs";
2
2
  import { currentModal } from "../createModal.mjs";
3
3
  import { INTERNAL, effect } from "@monstermann/signals";
4
-
5
4
  //#region src/scroll/withCloseOnScroll.ts
6
5
  const meta = {
7
6
  path: "@signals-modal/scroll/withCloseOnScroll.ts",
@@ -72,6 +71,5 @@ function getScrollableAncestors(element) {
72
71
  }
73
72
  return scrollableAncestors;
74
73
  }
75
-
76
74
  //#endregion
77
- export { withCloseOnScroll };
75
+ export { withCloseOnScroll };
@@ -1,6 +1,5 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
2
  import { untrack } from "@monstermann/signals";
3
-
4
3
  //#region src/status/closeAllModals.ts
5
4
  /**
6
5
  * # closeAllModals
@@ -44,6 +43,5 @@ function closeAllModals() {
44
43
  }
45
44
  });
46
45
  }
47
-
48
46
  //#endregion
49
- export { closeAllModals };
47
+ export { closeAllModals };
@@ -1,6 +1,5 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
2
  import { untrack } from "@monstermann/signals";
3
-
4
3
  //#region src/status/closeModal.ts
5
4
  /**
6
5
  * # closeModal
@@ -39,6 +38,5 @@ function closeModal(key) {
39
38
  $status("closing");
40
39
  });
41
40
  }
42
-
43
41
  //#endregion
44
- export { closeModal };
42
+ export { closeModal };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getClosedModals.ts
4
3
  /**
5
4
  * # getClosedModals
@@ -39,6 +38,5 @@ function getClosedModals() {
39
38
  for (const [key, $status] of map) if ($status() === "closed") result.push(key);
40
39
  return result;
41
40
  }
42
-
43
41
  //#endregion
44
- export { getClosedModals };
42
+ export { getClosedModals };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getClosingModals.ts
4
3
  /**
5
4
  * # getClosingModals
@@ -43,6 +42,5 @@ function getClosingModals() {
43
42
  for (const [key, $status] of map) if ($status() === "closing") result.push(key);
44
43
  return result;
45
44
  }
46
-
47
45
  //#endregion
48
- export { getClosingModals };
46
+ export { getClosingModals };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getModalStatus.ts
4
3
  /**
5
4
  * # getModalStatus
@@ -34,6 +33,5 @@ import { $keysToStatus } from "./internals.mjs";
34
33
  function getModalStatus(key) {
35
34
  return $keysToStatus().get(key)?.() ?? "closed";
36
35
  }
37
-
38
36
  //#endregion
39
- export { getModalStatus };
37
+ export { getModalStatus };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getOpenModals.ts
4
3
  /**
5
4
  * # getOpenModals
@@ -43,6 +42,5 @@ function getOpenModals() {
43
42
  for (const [key, $status] of map) if ($status() === "opening" || $status() === "opened") result.push(key);
44
43
  return result;
45
44
  }
46
-
47
45
  //#endregion
48
- export { getOpenModals };
46
+ export { getOpenModals };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getOpenedModals.ts
4
3
  /**
5
4
  * # getOpenedModals
@@ -39,6 +38,5 @@ function getOpenedModals() {
39
38
  for (const [key, $status] of map) if ($status() === "opened") result.push(key);
40
39
  return result;
41
40
  }
42
-
43
41
  //#endregion
44
- export { getOpenedModals };
42
+ export { getOpenedModals };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getOpeningModals.ts
4
3
  /**
5
4
  * # getOpeningModals
@@ -43,6 +42,5 @@ function getOpeningModals() {
43
42
  for (const [key, $status] of map) if ($status() === "opening") result.push(key);
44
43
  return result;
45
44
  }
46
-
47
45
  //#endregion
48
- export { getOpeningModals };
46
+ export { getOpeningModals };
@@ -1,5 +1,4 @@
1
1
  import { $keysToStatus } from "./internals.mjs";
2
-
3
2
  //#region src/status/getVisibleModals.ts
4
3
  /**
5
4
  * # getVisibleModals
@@ -43,6 +42,5 @@ function getVisibleModals() {
43
42
  for (const [key, $status] of map) if ($status() !== "closed") result.push(key);
44
43
  return result;
45
44
  }
46
-
47
45
  //#endregion
48
- export { getVisibleModals };
46
+ export { getVisibleModals };
@@ -1,42 +1,11 @@
1
- import { onModalClosed } from "./onModalClosed.mjs";
2
- import { onModalOpened } from "./onModalOpened.mjs";
3
- import { onModalOpening } from "./onModalOpening.mjs";
4
- import { onModalDisposed } from "../createModal.mjs";
5
- import { INTERNAL, signal } from "@monstermann/signals";
6
-
7
- //#region src/status/internals.ts
8
- const path = "@signals-modal/status/internals.ts";
9
- const meta = {
10
- path,
11
- line: 9,
12
- name: "$keysToStatus"
13
- };
14
- const meta1 = {
15
- path,
16
- line: 14,
17
- name: "$openedModals"
18
- };
1
+ import { signal } from "@monstermann/signals";
19
2
  const $keysToStatus = signal(/* @__PURE__ */ new Map(), {
20
3
  mutable: true,
21
4
  silent: true
22
- }, meta);
23
- const $openedModals = signal(/* @__PURE__ */ new Set(), INTERNAL, meta1);
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
- function add(set, key) {
29
- if (set.has(key)) return set;
30
- const clone = new Set(set);
31
- clone.add(key);
32
- return clone;
33
- }
34
- function remove(set, key) {
35
- if (!set.has(key)) return set;
36
- const clone = new Set(set);
37
- clone.delete(key);
38
- return clone;
39
- }
40
-
5
+ }, {
6
+ path: "@signals-modal/status/internals.ts",
7
+ line: 5,
8
+ name: "$keysToStatus"
9
+ });
41
10
  //#endregion
42
- export { $keysToStatus, $openedModals };
11
+ export { $keysToStatus };
@@ -1,5 +1,4 @@
1
1
  import { getClosedModals } from "./getClosedModals.mjs";
2
-
3
2
  //#region src/status/isAnyModalClosed.ts
4
3
  /**
5
4
  * # isAnyModalClosed
@@ -36,6 +35,5 @@ import { getClosedModals } from "./getClosedModals.mjs";
36
35
  function isAnyModalClosed() {
37
36
  return getClosedModals().length > 0;
38
37
  }
39
-
40
38
  //#endregion
41
- export { isAnyModalClosed };
39
+ export { isAnyModalClosed };
@@ -1,5 +1,4 @@
1
1
  import { getClosingModals } from "./getClosingModals.mjs";
2
-
3
2
  //#region src/status/isAnyModalClosing.ts
4
3
  /**
5
4
  * # isAnyModalClosing
@@ -39,6 +38,5 @@ import { getClosingModals } from "./getClosingModals.mjs";
39
38
  function isAnyModalClosing() {
40
39
  return getClosingModals().length > 0;
41
40
  }
42
-
43
41
  //#endregion
44
- export { isAnyModalClosing };
42
+ export { isAnyModalClosing };