@monstermann/signals-modal 0.4.3 → 0.4.5

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 (124) hide show
  1. package/README.md +2011 -0
  2. package/dist/anchor/getAnchorElement.d.mts +30 -0
  3. package/dist/anchor/getAnchorElement.mjs +30 -0
  4. package/dist/anchor/getAnchorMeasurement.d.mts +39 -1
  5. package/dist/anchor/getAnchorMeasurement.mjs +37 -0
  6. package/dist/anchor/setAnchorElement.d.mts +26 -0
  7. package/dist/anchor/setAnchorElement.mjs +26 -0
  8. package/dist/anchor/withAnchorElement.d.mts +31 -0
  9. package/dist/anchor/withAnchorElement.mjs +31 -1
  10. package/dist/anchor/withAnchorMeasurement.d.mts +44 -1
  11. package/dist/anchor/withAnchorMeasurement.mjs +45 -3
  12. package/dist/anchor/withMouseAnchor.d.mts +35 -1
  13. package/dist/anchor/withMouseAnchor.mjs +36 -3
  14. package/dist/createModal.d.mts +29 -0
  15. package/dist/createModal.mjs +29 -0
  16. package/dist/floating/getFloatingElement.d.mts +30 -0
  17. package/dist/floating/getFloatingElement.mjs +30 -0
  18. package/dist/floating/getFloatingMeasurement.d.mts +39 -1
  19. package/dist/floating/getFloatingMeasurement.mjs +37 -0
  20. package/dist/floating/setFloatingElement.d.mts +26 -0
  21. package/dist/floating/setFloatingElement.mjs +26 -0
  22. package/dist/floating/withFloatingElement.d.mts +31 -0
  23. package/dist/floating/withFloatingElement.mjs +31 -1
  24. package/dist/floating/withFloatingMeasurement.d.mts +42 -1
  25. package/dist/floating/withFloatingMeasurement.mjs +43 -3
  26. package/dist/groups/getDialogs.d.mts +29 -0
  27. package/dist/groups/getDialogs.mjs +29 -0
  28. package/dist/groups/getGroupsForModal.d.mts +29 -0
  29. package/dist/groups/getGroupsForModal.mjs +29 -0
  30. package/dist/groups/getModalsForGroup.d.mts +29 -0
  31. package/dist/groups/getModalsForGroup.mjs +29 -0
  32. package/dist/groups/getPopovers.d.mts +29 -0
  33. package/dist/groups/getPopovers.mjs +29 -0
  34. package/dist/groups/getTooltips.d.mts +29 -0
  35. package/dist/groups/getTooltips.mjs +29 -0
  36. package/dist/groups/isDialog.d.mts +29 -0
  37. package/dist/groups/isDialog.mjs +29 -0
  38. package/dist/groups/isModalInGroup.d.mts +29 -0
  39. package/dist/groups/isModalInGroup.mjs +29 -0
  40. package/dist/groups/isPopover.d.mts +29 -0
  41. package/dist/groups/isPopover.mjs +29 -0
  42. package/dist/groups/isTooltip.d.mts +29 -0
  43. package/dist/groups/isTooltip.mjs +29 -0
  44. package/dist/groups/modalGroups.mjs +42 -0
  45. package/dist/groups/withModalGroups.d.mts +30 -0
  46. package/dist/groups/withModalGroups.mjs +30 -1
  47. package/dist/position/getModalPlacement.d.mts +50 -0
  48. package/dist/position/getModalPlacement.mjs +49 -0
  49. package/dist/position/getModalPosition.d.mts +59 -0
  50. package/dist/position/getModalPosition.mjs +58 -0
  51. package/dist/position/withBoundary.d.mts +32 -1
  52. package/dist/position/withBoundary.mjs +33 -3
  53. package/dist/position/withPlacement.d.mts +78 -1
  54. package/dist/position/withPlacement.mjs +78 -1
  55. package/dist/position/withPosition.d.mts +67 -1
  56. package/dist/position/withPosition.mjs +68 -2
  57. package/dist/scroll/withCloseOnScroll.d.mts +37 -0
  58. package/dist/scroll/withCloseOnScroll.mjs +37 -1
  59. package/dist/status/closeAllModals.d.mts +33 -0
  60. package/dist/status/closeAllModals.mjs +33 -0
  61. package/dist/status/closeLastModal.d.mts +18 -0
  62. package/dist/status/closeLastModal.mjs +18 -0
  63. package/dist/status/closeModal.d.mts +28 -0
  64. package/dist/status/closeModal.mjs +28 -0
  65. package/dist/status/getClosedModals.d.mts +32 -0
  66. package/dist/status/getClosedModals.mjs +32 -0
  67. package/dist/status/getClosingModals.d.mts +36 -0
  68. package/dist/status/getClosingModals.mjs +36 -0
  69. package/dist/status/getModalStatus.d.mts +31 -0
  70. package/dist/status/getModalStatus.mjs +30 -0
  71. package/dist/status/getOpenModals.d.mts +36 -0
  72. package/dist/status/getOpenModals.mjs +36 -0
  73. package/dist/status/getOpenedModals.d.mts +32 -0
  74. package/dist/status/getOpenedModals.mjs +32 -0
  75. package/dist/status/getOpeningModals.d.mts +36 -0
  76. package/dist/status/getOpeningModals.mjs +36 -0
  77. package/dist/status/getVisibleModals.d.mts +36 -0
  78. package/dist/status/getVisibleModals.mjs +36 -0
  79. package/dist/status/internals.mjs +15 -6
  80. package/dist/status/isAnyModalClosed.d.mts +32 -0
  81. package/dist/status/isAnyModalClosed.mjs +32 -0
  82. package/dist/status/isAnyModalClosing.d.mts +35 -0
  83. package/dist/status/isAnyModalClosing.mjs +35 -0
  84. package/dist/status/isAnyModalOpen.d.mts +32 -0
  85. package/dist/status/isAnyModalOpen.mjs +32 -0
  86. package/dist/status/isAnyModalOpened.d.mts +32 -0
  87. package/dist/status/isAnyModalOpened.mjs +32 -0
  88. package/dist/status/isAnyModalOpening.d.mts +35 -0
  89. package/dist/status/isAnyModalOpening.mjs +35 -0
  90. package/dist/status/isAnyModalVisible.d.mts +32 -0
  91. package/dist/status/isAnyModalVisible.mjs +32 -0
  92. package/dist/status/isModalClosed.d.mts +28 -0
  93. package/dist/status/isModalClosed.mjs +28 -0
  94. package/dist/status/isModalClosing.d.mts +32 -0
  95. package/dist/status/isModalClosing.mjs +32 -0
  96. package/dist/status/isModalOpen.d.mts +28 -0
  97. package/dist/status/isModalOpen.mjs +28 -0
  98. package/dist/status/isModalOpened.d.mts +30 -0
  99. package/dist/status/isModalOpened.mjs +30 -0
  100. package/dist/status/isModalOpening.d.mts +30 -0
  101. package/dist/status/isModalOpening.mjs +30 -0
  102. package/dist/status/isModalVisible.d.mts +30 -0
  103. package/dist/status/isModalVisible.mjs +30 -0
  104. package/dist/status/onModalClosed.d.mts +33 -2
  105. package/dist/status/onModalClosed.mjs +31 -1
  106. package/dist/status/onModalClosing.d.mts +33 -2
  107. package/dist/status/onModalClosing.mjs +31 -1
  108. package/dist/status/onModalOpened.d.mts +31 -0
  109. package/dist/status/onModalOpened.mjs +31 -1
  110. package/dist/status/onModalOpening.d.mts +31 -0
  111. package/dist/status/onModalOpening.mjs +31 -1
  112. package/dist/status/openModal.d.mts +26 -0
  113. package/dist/status/openModal.mjs +26 -0
  114. package/dist/status/setModalStatus.d.mts +29 -0
  115. package/dist/status/setModalStatus.mjs +28 -0
  116. package/dist/status/withModalStatus.d.mts +41 -0
  117. package/dist/status/withModalStatus.mjs +43 -3
  118. package/dist/utils/closeLastModalOnClickOutside.d.mts +18 -0
  119. package/dist/utils/closeLastModalOnClickOutside.mjs +18 -0
  120. package/dist/utils/closeLastModalOnEsc.d.mts +18 -0
  121. package/dist/utils/closeLastModalOnEsc.mjs +18 -0
  122. package/dist/utils/syncModalGroupsToBody.d.mts +37 -0
  123. package/dist/utils/syncModalGroupsToBody.mjs +38 -1
  124. package/package.json +6 -5
@@ -1,4 +1,33 @@
1
1
  //#region src/groups/isDialog.d.ts
2
+ /**
3
+ * # isDialog
4
+ *
5
+ * <Badge type="tip">Reactive</Badge>
6
+ *
7
+ * ```ts
8
+ * function isDialog(key: string): boolean;
9
+ * ```
10
+ *
11
+ * Returns a boolean indicating whether the given `key` belongs to the `modalGroups.dialog` group.
12
+ *
13
+ * ## Example
14
+ *
15
+ * ```ts
16
+ * import {
17
+ * createModal,
18
+ * withModalGroups,
19
+ * modalGroups,
20
+ * isDialog,
21
+ * } from "@monstermann/signals-modal";
22
+ *
23
+ * createModal("key", () => {
24
+ * withModalGroups([modalGroups.popover]);
25
+ * });
26
+ *
27
+ * isDialog("key"); // true
28
+ * ```
29
+ *
30
+ */
2
31
  declare function isDialog(key: string): boolean;
3
32
  //#endregion
4
33
  export { isDialog };
@@ -2,6 +2,35 @@ import { modalGroups } from "./modalGroups.mjs";
2
2
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
3
3
 
4
4
  //#region src/groups/isDialog.ts
5
+ /**
6
+ * # isDialog
7
+ *
8
+ * <Badge type="tip">Reactive</Badge>
9
+ *
10
+ * ```ts
11
+ * function isDialog(key: string): boolean;
12
+ * ```
13
+ *
14
+ * Returns a boolean indicating whether the given `key` belongs to the `modalGroups.dialog` group.
15
+ *
16
+ * ## Example
17
+ *
18
+ * ```ts
19
+ * import {
20
+ * createModal,
21
+ * withModalGroups,
22
+ * modalGroups,
23
+ * isDialog,
24
+ * } from "@monstermann/signals-modal";
25
+ *
26
+ * createModal("key", () => {
27
+ * withModalGroups([modalGroups.popover]);
28
+ * });
29
+ *
30
+ * isDialog("key"); // true
31
+ * ```
32
+ *
33
+ */
5
34
  function isDialog(key) {
6
35
  return getGroupsForModal(key).has(modalGroups.dialog);
7
36
  }
@@ -1,4 +1,33 @@
1
1
  //#region src/groups/isModalInGroup.d.ts
2
+ /**
3
+ * # isModalInGroup
4
+ *
5
+ * <Badge type="tip">Reactive</Badge>
6
+ *
7
+ * ```ts
8
+ * function isModalInGroup(key: string, group: string): boolean;
9
+ * ```
10
+ *
11
+ * Returns a boolean indicating whether the given `key` belongs to the `group`.
12
+ *
13
+ * ## Example
14
+ *
15
+ * ```ts
16
+ * import {
17
+ * createModal,
18
+ * withModalGroups,
19
+ * modalGroups,
20
+ * isModalInGroup,
21
+ * } from "@monstermann/signals-modal";
22
+ *
23
+ * createModal("key", () => {
24
+ * withModalGroups([modalGroups.popover]);
25
+ * });
26
+ *
27
+ * isModalInGroup("key", modalGroups.popover); // true
28
+ * ```
29
+ *
30
+ */
2
31
  declare function isModalInGroup(key: string, group: string): boolean;
3
32
  //#endregion
4
33
  export { isModalInGroup };
@@ -1,6 +1,35 @@
1
1
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
2
2
 
3
3
  //#region src/groups/isModalInGroup.ts
4
+ /**
5
+ * # isModalInGroup
6
+ *
7
+ * <Badge type="tip">Reactive</Badge>
8
+ *
9
+ * ```ts
10
+ * function isModalInGroup(key: string, group: string): boolean;
11
+ * ```
12
+ *
13
+ * Returns a boolean indicating whether the given `key` belongs to the `group`.
14
+ *
15
+ * ## Example
16
+ *
17
+ * ```ts
18
+ * import {
19
+ * createModal,
20
+ * withModalGroups,
21
+ * modalGroups,
22
+ * isModalInGroup,
23
+ * } from "@monstermann/signals-modal";
24
+ *
25
+ * createModal("key", () => {
26
+ * withModalGroups([modalGroups.popover]);
27
+ * });
28
+ *
29
+ * isModalInGroup("key", modalGroups.popover); // true
30
+ * ```
31
+ *
32
+ */
4
33
  function isModalInGroup(key, group) {
5
34
  return getGroupsForModal(key).has(group);
6
35
  }
@@ -1,4 +1,33 @@
1
1
  //#region src/groups/isPopover.d.ts
2
+ /**
3
+ * # isPopover
4
+ *
5
+ * <Badge type="tip">Reactive</Badge>
6
+ *
7
+ * ```ts
8
+ * function isPopover(key: string): boolean;
9
+ * ```
10
+ *
11
+ * Returns a boolean indicating whether the given `key` belongs to the `modalGroups.popover` group.
12
+ *
13
+ * ## Example
14
+ *
15
+ * ```ts
16
+ * import {
17
+ * createModal,
18
+ * withModalGroups,
19
+ * modalGroups,
20
+ * isPopover,
21
+ * } from "@monstermann/signals-modal";
22
+ *
23
+ * createModal("key", () => {
24
+ * withModalGroups([modalGroups.popover]);
25
+ * });
26
+ *
27
+ * isPopover("key"); // true
28
+ * ```
29
+ *
30
+ */
2
31
  declare function isPopover(key: string): boolean;
3
32
  //#endregion
4
33
  export { isPopover };
@@ -2,6 +2,35 @@ import { modalGroups } from "./modalGroups.mjs";
2
2
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
3
3
 
4
4
  //#region src/groups/isPopover.ts
5
+ /**
6
+ * # isPopover
7
+ *
8
+ * <Badge type="tip">Reactive</Badge>
9
+ *
10
+ * ```ts
11
+ * function isPopover(key: string): boolean;
12
+ * ```
13
+ *
14
+ * Returns a boolean indicating whether the given `key` belongs to the `modalGroups.popover` group.
15
+ *
16
+ * ## Example
17
+ *
18
+ * ```ts
19
+ * import {
20
+ * createModal,
21
+ * withModalGroups,
22
+ * modalGroups,
23
+ * isPopover,
24
+ * } from "@monstermann/signals-modal";
25
+ *
26
+ * createModal("key", () => {
27
+ * withModalGroups([modalGroups.popover]);
28
+ * });
29
+ *
30
+ * isPopover("key"); // true
31
+ * ```
32
+ *
33
+ */
5
34
  function isPopover(key) {
6
35
  return getGroupsForModal(key).has(modalGroups.popover);
7
36
  }
@@ -1,4 +1,33 @@
1
1
  //#region src/groups/isTooltip.d.ts
2
+ /**
3
+ * # isTooltip
4
+ *
5
+ * <Badge type="tip">Reactive</Badge>
6
+ *
7
+ * ```ts
8
+ * function isTooltip(key: string): boolean;
9
+ * ```
10
+ *
11
+ * Returns a boolean indicating whether the given `key` belongs to the `modalGroups.tooltip` group.
12
+ *
13
+ * ## Example
14
+ *
15
+ * ```ts
16
+ * import {
17
+ * createModal,
18
+ * withModalGroups,
19
+ * modalGroups,
20
+ * isTooltip,
21
+ * } from "@monstermann/signals-modal";
22
+ *
23
+ * createModal("key", () => {
24
+ * withModalGroups([modalGroups.popover]);
25
+ * });
26
+ *
27
+ * isTooltip("key"); // true
28
+ * ```
29
+ *
30
+ */
2
31
  declare function isTooltip(key: string): boolean;
3
32
  //#endregion
4
33
  export { isTooltip };
@@ -2,6 +2,35 @@ import { modalGroups } from "./modalGroups.mjs";
2
2
  import { getGroupsForModal } from "./getGroupsForModal.mjs";
3
3
 
4
4
  //#region src/groups/isTooltip.ts
5
+ /**
6
+ * # isTooltip
7
+ *
8
+ * <Badge type="tip">Reactive</Badge>
9
+ *
10
+ * ```ts
11
+ * function isTooltip(key: string): boolean;
12
+ * ```
13
+ *
14
+ * Returns a boolean indicating whether the given `key` belongs to the `modalGroups.tooltip` group.
15
+ *
16
+ * ## Example
17
+ *
18
+ * ```ts
19
+ * import {
20
+ * createModal,
21
+ * withModalGroups,
22
+ * modalGroups,
23
+ * isTooltip,
24
+ * } from "@monstermann/signals-modal";
25
+ *
26
+ * createModal("key", () => {
27
+ * withModalGroups([modalGroups.popover]);
28
+ * });
29
+ *
30
+ * isTooltip("key"); // true
31
+ * ```
32
+ *
33
+ */
5
34
  function isTooltip(key) {
6
35
  return getGroupsForModal(key).has(modalGroups.tooltip);
7
36
  }
@@ -4,6 +4,48 @@ const modalGroups = {
4
4
  popover: "popover",
5
5
  tooltip: "tooltip"
6
6
  };
7
+ /**
8
+ * # modalGroups
9
+ *
10
+ * ```ts
11
+ * const modalGroups = {
12
+ * dialog: "dialog",
13
+ * popover: "popover",
14
+ * tooltip: "tooltip",
15
+ * };
16
+ * ```
17
+ *
18
+ * A record containing common modal groups.
19
+ *
20
+ */
21
+ /**
22
+ * # modalGroups
23
+ *
24
+ * ```ts
25
+ * const modalGroups = {
26
+ * dialog: "dialog",
27
+ * popover: "popover",
28
+ * tooltip: "tooltip",
29
+ * };
30
+ * ```
31
+ *
32
+ * A record containing common modal groups.
33
+ *
34
+ */
35
+ /**
36
+ * # modalGroups
37
+ *
38
+ * ```ts
39
+ * const modalGroups = {
40
+ * dialog: "dialog",
41
+ * popover: "popover",
42
+ * tooltip: "tooltip",
43
+ * };
44
+ * ```
45
+ *
46
+ * A record containing common modal groups.
47
+ *
48
+ */
7
49
 
8
50
  //#endregion
9
51
  export { modalGroups };
@@ -1,6 +1,36 @@
1
1
  import { Memo } from "@monstermann/signals";
2
2
 
3
3
  //#region src/groups/withModalGroups.d.ts
4
+
5
+ /**
6
+ * # withModalGroups
7
+ *
8
+ * ```ts
9
+ * function withModalGroups(groups: Iterable<string>): Memo<ReadonlySet<string>>;
10
+ * ```
11
+ *
12
+ * Assigns the current modal to a list of groups. Can be used to for example mark the modal as a dialog/popover/tooltip. This function must be called inside a `createModal` callback.
13
+ *
14
+ * ## Example
15
+ *
16
+ * ```ts
17
+ * import {
18
+ * createModal,
19
+ * withModalGroups,
20
+ * getDialogs,
21
+ * getGroupsForModal,
22
+ * getModalsForGroup,
23
+ * } from "@monstermann/signals-modal";
24
+ *
25
+ * createModal("key", () => {
26
+ * withModalGroups(["dialog"]);
27
+ * });
28
+ *
29
+ * getGroupsForModal("key"); // Set(["dialog"])
30
+ * getModalsForGroup("dialog"); // Set(["key"])
31
+ * ```
32
+ *
33
+ */
4
34
  declare function withModalGroups(groups: Iterable<string>): Memo<ReadonlySet<string>>;
5
35
  //#endregion
6
36
  export { withModalGroups };
@@ -6,9 +6,38 @@ import { INTERNAL, memo } from "@monstermann/signals";
6
6
  //#region src/groups/withModalGroups.ts
7
7
  const meta = {
8
8
  path: "@signals-modal/groups/withModalGroups.ts",
9
- line: 24,
9
+ line: 53,
10
10
  name: "withModalGroups"
11
11
  };
12
+ /**
13
+ * # withModalGroups
14
+ *
15
+ * ```ts
16
+ * function withModalGroups(groups: Iterable<string>): Memo<ReadonlySet<string>>;
17
+ * ```
18
+ *
19
+ * Assigns the current modal to a list of groups. Can be used to for example mark the modal as a dialog/popover/tooltip. This function must be called inside a `createModal` callback.
20
+ *
21
+ * ## Example
22
+ *
23
+ * ```ts
24
+ * import {
25
+ * createModal,
26
+ * withModalGroups,
27
+ * getDialogs,
28
+ * getGroupsForModal,
29
+ * getModalsForGroup,
30
+ * } from "@monstermann/signals-modal";
31
+ *
32
+ * createModal("key", () => {
33
+ * withModalGroups(["dialog"]);
34
+ * });
35
+ *
36
+ * getGroupsForModal("key"); // Set(["dialog"])
37
+ * getModalsForGroup("dialog"); // Set(["key"])
38
+ * ```
39
+ *
40
+ */
12
41
  function withModalGroups(groups) {
13
42
  const modal = currentModal();
14
43
  $keysToGroups((keys) => {
@@ -1,6 +1,56 @@
1
1
  import { ModalPlacement } from "./withPlacement.mjs";
2
2
 
3
3
  //#region src/position/getModalPlacement.d.ts
4
+
5
+ /**
6
+ * # getModalPlacement
7
+ *
8
+ * ```ts
9
+ * function getModalPlacement(key: string): ModalPlacement | undefined;
10
+ * ```
11
+ *
12
+ * Returns the current placement for the given `key`.
13
+ *
14
+ * ## Example
15
+ *
16
+ * ```ts
17
+ * import {
18
+ * createModal,
19
+ * withModalStatus,
20
+ * withAnchorElement,
21
+ * withAnchorMeasurement,
22
+ * withFloatingElement,
23
+ * withFloatingMeasurement,
24
+ * withBoundary,
25
+ * withPlacement,
26
+ * getModalPlacement,
27
+ * } from "@monstermann/signals-modal";
28
+ *
29
+ * createModal("key", () => {
30
+ * const { $status } = withModalStatus();
31
+ * const $anchorElement = withAnchorElement();
32
+ * const $floatingElement = withFloatingElement();
33
+ * const $anchorMeasurement = withAnchorMeasurement({
34
+ * $status,
35
+ * $anchorElement,
36
+ * });
37
+ * const $floatingMeasurement = withFloatingMeasurement({
38
+ * $status,
39
+ * $floatingElement,
40
+ * });
41
+ * const $boundary = withBoundary({ $status });
42
+ * const $placement = withPlacement({
43
+ * placement: "vertical-center",
44
+ * $boundary,
45
+ * $anchorMeasurement,
46
+ * $floatingMeasurement,
47
+ * });
48
+ * });
49
+ *
50
+ * getModalPlacement("key"); // up-center | down-center
51
+ * ```
52
+ *
53
+ */
4
54
  declare function getModalPlacement(key: string): ModalPlacement | undefined;
5
55
  //#endregion
6
56
  export { getModalPlacement };
@@ -1,6 +1,55 @@
1
1
  import { $placements } from "./internals.mjs";
2
2
 
3
3
  //#region src/position/getModalPlacement.ts
4
+ /**
5
+ * # getModalPlacement
6
+ *
7
+ * ```ts
8
+ * function getModalPlacement(key: string): ModalPlacement | undefined;
9
+ * ```
10
+ *
11
+ * Returns the current placement for the given `key`.
12
+ *
13
+ * ## Example
14
+ *
15
+ * ```ts
16
+ * import {
17
+ * createModal,
18
+ * withModalStatus,
19
+ * withAnchorElement,
20
+ * withAnchorMeasurement,
21
+ * withFloatingElement,
22
+ * withFloatingMeasurement,
23
+ * withBoundary,
24
+ * withPlacement,
25
+ * getModalPlacement,
26
+ * } from "@monstermann/signals-modal";
27
+ *
28
+ * createModal("key", () => {
29
+ * const { $status } = withModalStatus();
30
+ * const $anchorElement = withAnchorElement();
31
+ * const $floatingElement = withFloatingElement();
32
+ * const $anchorMeasurement = withAnchorMeasurement({
33
+ * $status,
34
+ * $anchorElement,
35
+ * });
36
+ * const $floatingMeasurement = withFloatingMeasurement({
37
+ * $status,
38
+ * $floatingElement,
39
+ * });
40
+ * const $boundary = withBoundary({ $status });
41
+ * const $placement = withPlacement({
42
+ * placement: "vertical-center",
43
+ * $boundary,
44
+ * $anchorMeasurement,
45
+ * $floatingMeasurement,
46
+ * });
47
+ * });
48
+ *
49
+ * getModalPlacement("key"); // up-center | down-center
50
+ * ```
51
+ *
52
+ */
4
53
  function getModalPlacement(key) {
5
54
  return $placements().get(key)?.();
6
55
  }
@@ -1,6 +1,65 @@
1
1
  import { ModalPosition } from "./withPosition.mjs";
2
2
 
3
3
  //#region src/position/getModalPosition.d.ts
4
+
5
+ /**
6
+ * # getModalPosition
7
+ *
8
+ * <Badge type="tip">Reactive</Badge>
9
+ *
10
+ * ```ts
11
+ * function getModalPosition(key: string): ModalPosition | undefined;
12
+ * ```
13
+ *
14
+ * Returns the current result of `withPosition`.
15
+ *
16
+ * ## Example
17
+ *
18
+ * ```ts
19
+ * import {
20
+ * createModal,
21
+ * withModalStatus,
22
+ * withAnchorElement,
23
+ * withAnchorMeasurement,
24
+ * withFloatingElement,
25
+ * withFloatingMeasurement,
26
+ * withBoundary,
27
+ * withPlacement,
28
+ * withPosition,
29
+ * getModalPosition,
30
+ * } from "@monstermann/signals-modal";
31
+ *
32
+ * createModal("key", () => {
33
+ * const { $status } = withModalStatus();
34
+ * const $anchorElement = withAnchorElement();
35
+ * const $floatingElement = withFloatingElement();
36
+ * const $anchorMeasurement = withAnchorMeasurement({
37
+ * $status,
38
+ * $anchorElement,
39
+ * });
40
+ * const $floatingMeasurement = withFloatingMeasurement({
41
+ * $status,
42
+ * $floatingElement,
43
+ * });
44
+ * const $boundary = withBoundary({ $status });
45
+ * const $placement = withPlacement({
46
+ * placement: "vertical-center",
47
+ * $boundary,
48
+ * $anchorMeasurement,
49
+ * $floatingMeasurement,
50
+ * });
51
+ * const $position = withPosition({
52
+ * $boundary,
53
+ * $placement,
54
+ * $anchorMeasurement,
55
+ * $floatingMeasurement,
56
+ * });
57
+ * });
58
+ *
59
+ * getModalPosition("key"); // ModalPosition | undefined
60
+ * ```
61
+ *
62
+ */
4
63
  declare function getModalPosition(key: string): ModalPosition | undefined;
5
64
  //#endregion
6
65
  export { getModalPosition };
@@ -1,6 +1,64 @@
1
1
  import { $positions } from "./internals.mjs";
2
2
 
3
3
  //#region src/position/getModalPosition.ts
4
+ /**
5
+ * # getModalPosition
6
+ *
7
+ * <Badge type="tip">Reactive</Badge>
8
+ *
9
+ * ```ts
10
+ * function getModalPosition(key: string): ModalPosition | undefined;
11
+ * ```
12
+ *
13
+ * Returns the current result of `withPosition`.
14
+ *
15
+ * ## Example
16
+ *
17
+ * ```ts
18
+ * import {
19
+ * createModal,
20
+ * withModalStatus,
21
+ * withAnchorElement,
22
+ * withAnchorMeasurement,
23
+ * withFloatingElement,
24
+ * withFloatingMeasurement,
25
+ * withBoundary,
26
+ * withPlacement,
27
+ * withPosition,
28
+ * getModalPosition,
29
+ * } from "@monstermann/signals-modal";
30
+ *
31
+ * createModal("key", () => {
32
+ * const { $status } = withModalStatus();
33
+ * const $anchorElement = withAnchorElement();
34
+ * const $floatingElement = withFloatingElement();
35
+ * const $anchorMeasurement = withAnchorMeasurement({
36
+ * $status,
37
+ * $anchorElement,
38
+ * });
39
+ * const $floatingMeasurement = withFloatingMeasurement({
40
+ * $status,
41
+ * $floatingElement,
42
+ * });
43
+ * const $boundary = withBoundary({ $status });
44
+ * const $placement = withPlacement({
45
+ * placement: "vertical-center",
46
+ * $boundary,
47
+ * $anchorMeasurement,
48
+ * $floatingMeasurement,
49
+ * });
50
+ * const $position = withPosition({
51
+ * $boundary,
52
+ * $placement,
53
+ * $anchorMeasurement,
54
+ * $floatingMeasurement,
55
+ * });
56
+ * });
57
+ *
58
+ * getModalPosition("key"); // ModalPosition | undefined
59
+ * ```
60
+ *
61
+ */
4
62
  function getModalPosition(key) {
5
63
  return $positions().get(key)?.();
6
64
  }
@@ -1,8 +1,39 @@
1
1
  import { ModalStatus } from "../status/types.mjs";
2
2
  import { Memo, Reactive } from "@monstermann/signals";
3
- import { Rect } from "@monstermann/fn";
3
+ import { Rect } from "@monstermann/geometry";
4
4
 
5
5
  //#region src/position/withBoundary.d.ts
6
+
7
+ /**
8
+ * # withBoundary
9
+ *
10
+ * ```ts
11
+ * function withBoundary(options: {
12
+ * $status: Reactive<ModalStatus>;
13
+ * transform?: (rect: Rect) => Rect;
14
+ * }): Memo<Rect>;
15
+ * ```
16
+ *
17
+ * Constructs a `Rect` resembling the window dimensions, to be fed into `withPlacement` and `withPosition`, used to constrain the floating element to be within the window boundary. This function must be called inside a `createModal` callback.
18
+ *
19
+ * The optional `transform` option can be used to eg. make the `Rect` smaller, increasing the distance between the floating element and the edges of the window.
20
+ *
21
+ * ## Example
22
+ *
23
+ * ```ts
24
+ * import {
25
+ * createModal,
26
+ * withModalStatus,
27
+ * withBoundary,
28
+ * } from "@monstermann/signals-modal";
29
+ *
30
+ * createModal("key", () => {
31
+ * const { $status } = withModalStatus();
32
+ * const $boundary = withBoundary({ $status });
33
+ * });
34
+ * ```
35
+ *
36
+ */
6
37
  declare function withBoundary(options: {
7
38
  $status: Reactive<ModalStatus>;
8
39
  transform?: (rect: Rect) => Rect;