@monstermann/signals-modal 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -377
- package/dist/anchor/withAnchorElement.mjs +3 -16
- package/dist/anchor/withAnchorMeasurement.mjs +4 -14
- package/dist/anchor/withMouseAnchor.mjs +4 -14
- package/dist/createModal.d.mts +2 -2
- package/dist/createModal.mjs +2 -4
- package/dist/floating/withFloatingElement.mjs +3 -16
- package/dist/floating/withFloatingMeasurement.mjs +4 -14
- package/dist/groups/getDialogs.mjs +1 -3
- package/dist/groups/getGroupsForModal.mjs +1 -3
- package/dist/groups/getModalsForGroup.mjs +1 -3
- package/dist/groups/getPopovers.mjs +1 -3
- package/dist/groups/getTooltips.mjs +1 -3
- package/dist/groups/internals.mjs +1 -3
- package/dist/groups/isDialog.mjs +1 -3
- package/dist/groups/isModalInGroup.mjs +1 -3
- package/dist/groups/isPopover.mjs +1 -3
- package/dist/groups/isTooltip.mjs +1 -3
- package/dist/groups/modalGroups.mjs +1 -2
- package/dist/groups/withModalGroups.mjs +1 -3
- package/dist/index.d.mts +2 -14
- package/dist/index.mjs +5 -18
- package/dist/internals/observeDimensions.mjs +1 -2
- package/dist/internals/observePosition.mjs +8 -3
- package/dist/internals/roundByDPR.mjs +1 -2
- package/dist/position/internals.mjs +1 -23
- package/dist/position/withBoundary.mjs +1 -3
- package/dist/position/withPlacement.mjs +4 -16
- package/dist/position/withPosition.mjs +6 -18
- package/dist/scroll/withCloseOnScroll.mjs +1 -3
- package/dist/status/closeAllModals.mjs +1 -3
- package/dist/status/closeModal.mjs +1 -3
- package/dist/status/getClosedModals.mjs +1 -3
- package/dist/status/getClosingModals.mjs +1 -3
- package/dist/status/getModalStatus.mjs +1 -3
- package/dist/status/getOpenModals.mjs +1 -3
- package/dist/status/getOpenedModals.mjs +1 -3
- package/dist/status/getOpeningModals.mjs +1 -3
- package/dist/status/getVisibleModals.mjs +1 -3
- package/dist/status/internals.mjs +7 -38
- package/dist/status/isAnyModalClosed.mjs +1 -3
- package/dist/status/isAnyModalClosing.mjs +1 -3
- package/dist/status/isAnyModalOpen.mjs +1 -3
- package/dist/status/isAnyModalOpened.mjs +1 -3
- package/dist/status/isAnyModalOpening.mjs +1 -3
- package/dist/status/isAnyModalVisible.mjs +1 -3
- package/dist/status/isModalClosed.mjs +1 -3
- package/dist/status/isModalClosing.mjs +1 -3
- package/dist/status/isModalOpen.mjs +1 -3
- package/dist/status/isModalOpened.mjs +1 -3
- package/dist/status/isModalOpening.mjs +1 -3
- package/dist/status/isModalVisible.mjs +1 -3
- package/dist/status/onModalClosed.d.mts +2 -2
- package/dist/status/onModalClosed.mjs +6 -10
- package/dist/status/onModalClosing.d.mts +2 -2
- package/dist/status/onModalClosing.mjs +6 -10
- package/dist/status/onModalOpened.d.mts +2 -2
- package/dist/status/onModalOpened.mjs +6 -10
- package/dist/status/onModalOpening.d.mts +2 -2
- package/dist/status/onModalOpening.mjs +6 -10
- package/dist/status/openModal.mjs +1 -3
- package/dist/status/setModalStatus.mjs +1 -3
- package/dist/status/withModalStatus.mjs +4 -6
- package/package.json +1 -1
- package/dist/anchor/getAnchorElement.d.mts +0 -34
- package/dist/anchor/getAnchorElement.mjs +0 -39
- package/dist/anchor/getAnchorMeasurement.d.mts +0 -43
- package/dist/anchor/getAnchorMeasurement.mjs +0 -47
- package/dist/anchor/internals.mjs +0 -25
- package/dist/anchor/setAnchorElement.d.mts +0 -30
- package/dist/anchor/setAnchorElement.mjs +0 -35
- package/dist/floating/getFloatingElement.d.mts +0 -34
- package/dist/floating/getFloatingElement.mjs +0 -39
- package/dist/floating/getFloatingMeasurement.d.mts +0 -43
- package/dist/floating/getFloatingMeasurement.mjs +0 -47
- package/dist/floating/internals.mjs +0 -25
- package/dist/floating/setFloatingElement.d.mts +0 -30
- package/dist/floating/setFloatingElement.mjs +0 -35
- package/dist/internals/findParentElement.mjs +0 -9
- package/dist/position/getModalPlacement.d.mts +0 -55
- package/dist/position/getModalPlacement.mjs +0 -58
- package/dist/position/getModalPosition.d.mts +0 -64
- package/dist/position/getModalPosition.mjs +0 -67
- package/dist/status/closeLastModal.d.mts +0 -22
- package/dist/status/closeLastModal.mjs +0 -29
- package/dist/utils/closeLastModalOnClickOutside.d.mts +0 -22
- package/dist/utils/closeLastModalOnClickOutside.mjs +0 -37
- package/dist/utils/closeLastModalOnEsc.d.mts +0 -22
- package/dist/utils/closeLastModalOnEsc.mjs +0 -35
- package/dist/utils/syncModalGroupsToBody.d.mts +0 -41
- package/dist/utils/syncModalGroupsToBody.mjs +0 -72
package/README.md
CHANGED
|
@@ -54,21 +54,6 @@ const modal = createModal("key", () => {
|
|
|
54
54
|
$status,
|
|
55
55
|
};
|
|
56
56
|
});
|
|
57
|
-
|
|
58
|
-
const anchor = document.querySelector(".anchor");
|
|
59
|
-
const floating = document.querySelector(".popover");
|
|
60
|
-
|
|
61
|
-
// Directly access the returned properties:
|
|
62
|
-
modal.$anchor(anchor);
|
|
63
|
-
modal.$floating(floating);
|
|
64
|
-
modal.$status("opened");
|
|
65
|
-
const { floatingX, floatingY, maxHeight, maxWidth } = modal.$position();
|
|
66
|
-
|
|
67
|
-
// Or use the global utilities:
|
|
68
|
-
setAnchorElement("key", anchor);
|
|
69
|
-
setFloatingElement("key", floating);
|
|
70
|
-
setModalStatus("key", "opened");
|
|
71
|
-
const { floatingX, floatingY, maxHeight, maxWidth } = getModalPosition("key");
|
|
72
57
|
```
|
|
73
58
|
|
|
74
59
|
## Installation
|
|
@@ -91,93 +76,6 @@ bun add @monstermann/signals-modal
|
|
|
91
76
|
|
|
92
77
|
## Anchor
|
|
93
78
|
|
|
94
|
-
### getAnchorElement
|
|
95
|
-
|
|
96
|
-

|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
function getAnchorElement(key: string): HTMLElement | undefined;
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Retrieves the current anchor element for the given `key`.
|
|
103
|
-
|
|
104
|
-
#### Example
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
import {
|
|
108
|
-
createModal,
|
|
109
|
-
withAnchorElement,
|
|
110
|
-
setAnchorElement,
|
|
111
|
-
getAnchorElement,
|
|
112
|
-
} from "@monstermann/signals-modal";
|
|
113
|
-
|
|
114
|
-
createModal("key", () => {
|
|
115
|
-
withAnchorElement();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
setAnchorElement("key", document.querySelector(".anchor"));
|
|
119
|
-
getAnchorElement("key"); // HTMLElement
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### getAnchorMeasurement
|
|
123
|
-
|
|
124
|
-

|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
function getAnchorMeasurement(key: string): Rect;
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Retrieves the current result of `withAnchorMeasurement` or `withMouseAnchor`, falling back to an empty `Rect`.
|
|
131
|
-
|
|
132
|
-
#### Example
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
import {
|
|
136
|
-
createModal,
|
|
137
|
-
withAnchorElement,
|
|
138
|
-
withModalStatus,
|
|
139
|
-
withAnchorMeasurement,
|
|
140
|
-
getAnchorMeasurement,
|
|
141
|
-
} from "@monstermann/signals-modal";
|
|
142
|
-
|
|
143
|
-
createModal("key", () => {
|
|
144
|
-
const { $status } = withModalStatus();
|
|
145
|
-
const $anchorElement = withAnchorElement();
|
|
146
|
-
// Memo({ top: number, left: number, width: number, height: number })
|
|
147
|
-
const $anchorMeasurement = withAnchorMeasurement({
|
|
148
|
-
$status,
|
|
149
|
-
$anchorElement,
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// { top: number, left: number, width: number, height: number }
|
|
154
|
-
getAnchorMeasurement("key");
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### setAnchorElement
|
|
158
|
-
|
|
159
|
-
```ts
|
|
160
|
-
function setAnchorElement(key: string, element: HTMLElement | null): void;
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Sets the current anchor element for the given `key`.
|
|
164
|
-
|
|
165
|
-
#### Example
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
import {
|
|
169
|
-
createModal,
|
|
170
|
-
withAnchorElement,
|
|
171
|
-
getAnchorElement,
|
|
172
|
-
} from "@monstermann/signals-modal";
|
|
173
|
-
|
|
174
|
-
createModal("key", () => {
|
|
175
|
-
withAnchorElement();
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
setAnchorElement("key", document.querySelector(".anchor"));
|
|
179
|
-
```
|
|
180
|
-
|
|
181
79
|
### withAnchorElement
|
|
182
80
|
|
|
183
81
|
```ts
|
|
@@ -354,93 +252,6 @@ stopListening();
|
|
|
354
252
|
|
|
355
253
|
## Floating
|
|
356
254
|
|
|
357
|
-
### getFloatingElement
|
|
358
|
-
|
|
359
|
-

|
|
360
|
-
|
|
361
|
-
```ts
|
|
362
|
-
function getFloatingElement(key: string): HTMLElement | undefined;
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
Retrieves the current floating element for the given `key`.
|
|
366
|
-
|
|
367
|
-
#### Example
|
|
368
|
-
|
|
369
|
-
```ts
|
|
370
|
-
import {
|
|
371
|
-
createModal,
|
|
372
|
-
withFloatingElement,
|
|
373
|
-
setFloatingElement,
|
|
374
|
-
getFloatingElement,
|
|
375
|
-
} from "@monstermann/signals-modal";
|
|
376
|
-
|
|
377
|
-
createModal("key", () => {
|
|
378
|
-
withFloatingElement();
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
setFloatingElement("key", document.querySelector(".floating"));
|
|
382
|
-
getFloatingElement("key"); // HTMLElement
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
### getFloatingMeasurement
|
|
386
|
-
|
|
387
|
-

|
|
388
|
-
|
|
389
|
-
```ts
|
|
390
|
-
function getFloatingMeasurement(key: string): Rect;
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
Retrieves the current result of `withFloatingMeasurement`, falling back to an empty `Rect`.
|
|
394
|
-
|
|
395
|
-
#### Example
|
|
396
|
-
|
|
397
|
-
```ts
|
|
398
|
-
import {
|
|
399
|
-
createModal,
|
|
400
|
-
withFloatingElement,
|
|
401
|
-
withModalStatus,
|
|
402
|
-
withFloatingMeasurement,
|
|
403
|
-
getFloatingMeasurement,
|
|
404
|
-
} from "@monstermann/signals-modal";
|
|
405
|
-
|
|
406
|
-
createModal("key", () => {
|
|
407
|
-
const { $status } = withModalStatus();
|
|
408
|
-
const $floatingElement = withFloatingElement();
|
|
409
|
-
// Memo({ top: number, left: number, width: number, height: number })
|
|
410
|
-
const $floatingMeasurement = withFloatingMeasurement({
|
|
411
|
-
$status,
|
|
412
|
-
$floatingElement,
|
|
413
|
-
});
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
// { top: number, left: number, width: number, height: number }
|
|
417
|
-
getFloatingMeasurement("key");
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
### setFloatingElement
|
|
421
|
-
|
|
422
|
-
```ts
|
|
423
|
-
function setFloatingElement(key: string, element: HTMLElement | null): void;
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
Sets the current floating element for the given `key`.
|
|
427
|
-
|
|
428
|
-
#### Example
|
|
429
|
-
|
|
430
|
-
```ts
|
|
431
|
-
import {
|
|
432
|
-
createModal,
|
|
433
|
-
withFloatingElement,
|
|
434
|
-
getFloatingElement,
|
|
435
|
-
} from "@monstermann/signals-modal";
|
|
436
|
-
|
|
437
|
-
createModal("key", () => {
|
|
438
|
-
withFloatingElement();
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
setFloatingElement("key", document.querySelector(".floating"));
|
|
442
|
-
```
|
|
443
|
-
|
|
444
255
|
### withFloatingElement
|
|
445
256
|
|
|
446
257
|
```ts
|
|
@@ -793,109 +604,6 @@ getModalsForGroup("dialog"); // Set(["key"])
|
|
|
793
604
|
|
|
794
605
|
## Position
|
|
795
606
|
|
|
796
|
-
### getModalPlacement
|
|
797
|
-
|
|
798
|
-
```ts
|
|
799
|
-
function getModalPlacement(key: string): ModalPlacement | undefined;
|
|
800
|
-
```
|
|
801
|
-
|
|
802
|
-
Returns the current placement for the given `key`.
|
|
803
|
-
|
|
804
|
-
#### Example
|
|
805
|
-
|
|
806
|
-
```ts
|
|
807
|
-
import {
|
|
808
|
-
createModal,
|
|
809
|
-
withModalStatus,
|
|
810
|
-
withAnchorElement,
|
|
811
|
-
withAnchorMeasurement,
|
|
812
|
-
withFloatingElement,
|
|
813
|
-
withFloatingMeasurement,
|
|
814
|
-
withBoundary,
|
|
815
|
-
withPlacement,
|
|
816
|
-
getModalPlacement,
|
|
817
|
-
} from "@monstermann/signals-modal";
|
|
818
|
-
|
|
819
|
-
createModal("key", () => {
|
|
820
|
-
const { $status } = withModalStatus();
|
|
821
|
-
const $anchorElement = withAnchorElement();
|
|
822
|
-
const $floatingElement = withFloatingElement();
|
|
823
|
-
const $anchorMeasurement = withAnchorMeasurement({
|
|
824
|
-
$status,
|
|
825
|
-
$anchorElement,
|
|
826
|
-
});
|
|
827
|
-
const $floatingMeasurement = withFloatingMeasurement({
|
|
828
|
-
$status,
|
|
829
|
-
$floatingElement,
|
|
830
|
-
});
|
|
831
|
-
const $boundary = withBoundary({ $status });
|
|
832
|
-
const $placement = withPlacement({
|
|
833
|
-
placement: "vertical-center",
|
|
834
|
-
$boundary,
|
|
835
|
-
$anchorMeasurement,
|
|
836
|
-
$floatingMeasurement,
|
|
837
|
-
});
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
getModalPlacement("key"); // up-center | down-center
|
|
841
|
-
```
|
|
842
|
-
|
|
843
|
-
### getModalPosition
|
|
844
|
-
|
|
845
|
-

|
|
846
|
-
|
|
847
|
-
```ts
|
|
848
|
-
function getModalPosition(key: string): ModalPosition | undefined;
|
|
849
|
-
```
|
|
850
|
-
|
|
851
|
-
Returns the current result of `withPosition`.
|
|
852
|
-
|
|
853
|
-
#### Example
|
|
854
|
-
|
|
855
|
-
```ts
|
|
856
|
-
import {
|
|
857
|
-
createModal,
|
|
858
|
-
withModalStatus,
|
|
859
|
-
withAnchorElement,
|
|
860
|
-
withAnchorMeasurement,
|
|
861
|
-
withFloatingElement,
|
|
862
|
-
withFloatingMeasurement,
|
|
863
|
-
withBoundary,
|
|
864
|
-
withPlacement,
|
|
865
|
-
withPosition,
|
|
866
|
-
getModalPosition,
|
|
867
|
-
} from "@monstermann/signals-modal";
|
|
868
|
-
|
|
869
|
-
createModal("key", () => {
|
|
870
|
-
const { $status } = withModalStatus();
|
|
871
|
-
const $anchorElement = withAnchorElement();
|
|
872
|
-
const $floatingElement = withFloatingElement();
|
|
873
|
-
const $anchorMeasurement = withAnchorMeasurement({
|
|
874
|
-
$status,
|
|
875
|
-
$anchorElement,
|
|
876
|
-
});
|
|
877
|
-
const $floatingMeasurement = withFloatingMeasurement({
|
|
878
|
-
$status,
|
|
879
|
-
$floatingElement,
|
|
880
|
-
});
|
|
881
|
-
const $boundary = withBoundary({ $status });
|
|
882
|
-
const $placement = withPlacement({
|
|
883
|
-
placement: "vertical-center",
|
|
884
|
-
$boundary,
|
|
885
|
-
$anchorMeasurement,
|
|
886
|
-
$floatingMeasurement,
|
|
887
|
-
});
|
|
888
|
-
const $position = withPosition({
|
|
889
|
-
$boundary,
|
|
890
|
-
$placement,
|
|
891
|
-
$anchorMeasurement,
|
|
892
|
-
$floatingMeasurement,
|
|
893
|
-
});
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
getModalPosition("key"); // ModalPosition | undefined
|
|
897
|
-
```
|
|
898
|
-
|
|
899
607
|
### withBoundary
|
|
900
608
|
|
|
901
609
|
```ts
|
|
@@ -1132,22 +840,6 @@ openModal("modal2");
|
|
|
1132
840
|
closeAllModals();
|
|
1133
841
|
```
|
|
1134
842
|
|
|
1135
|
-
### closeLastModal
|
|
1136
|
-
|
|
1137
|
-
```ts
|
|
1138
|
-
function closeLastModal(): void;
|
|
1139
|
-
```
|
|
1140
|
-
|
|
1141
|
-
Closes the last opened modal by setting its status to `"closing"`.
|
|
1142
|
-
|
|
1143
|
-
#### Example
|
|
1144
|
-
|
|
1145
|
-
```ts
|
|
1146
|
-
import { closeLastModal } from "@monstermann/signals-modal";
|
|
1147
|
-
|
|
1148
|
-
closeLastModal();
|
|
1149
|
-
```
|
|
1150
|
-
|
|
1151
843
|
### closeModal
|
|
1152
844
|
|
|
1153
845
|
```ts
|
|
@@ -1949,72 +1641,3 @@ createModal("modal2", () => {
|
|
|
1949
1641
|
$status("closing");
|
|
1950
1642
|
});
|
|
1951
1643
|
```
|
|
1952
|
-
|
|
1953
|
-
## Utils
|
|
1954
|
-
|
|
1955
|
-
### closeLastModalOnClickOutside
|
|
1956
|
-
|
|
1957
|
-
```ts
|
|
1958
|
-
function closeLastModalOnClickOutside(): void;
|
|
1959
|
-
```
|
|
1960
|
-
|
|
1961
|
-
Sets up a global `mousedown` listener that closes the last opened modal when clicked outside the floating element.
|
|
1962
|
-
|
|
1963
|
-
#### Example
|
|
1964
|
-
|
|
1965
|
-
```ts
|
|
1966
|
-
import { closeLastModalOnClickOutside } from "@monstermann/signals-modal";
|
|
1967
|
-
|
|
1968
|
-
closeLastModalOnClickOutside();
|
|
1969
|
-
```
|
|
1970
|
-
|
|
1971
|
-
### closeLastModalOnEsc
|
|
1972
|
-
|
|
1973
|
-
```ts
|
|
1974
|
-
function closeLastModalOnEsc(): void;
|
|
1975
|
-
```
|
|
1976
|
-
|
|
1977
|
-
Sets up a global `keydown` listener that closes the last opened modal when `esc` is pressed, unless the target was an editable element such as `<input>`.
|
|
1978
|
-
|
|
1979
|
-
#### Example
|
|
1980
|
-
|
|
1981
|
-
```ts
|
|
1982
|
-
import { closeLastModalOnEsc } from "@monstermann/signals-modal";
|
|
1983
|
-
|
|
1984
|
-
closeLastModalOnEsc();
|
|
1985
|
-
```
|
|
1986
|
-
|
|
1987
|
-
### syncModalGroupsToBody
|
|
1988
|
-
|
|
1989
|
-
```ts
|
|
1990
|
-
function syncModalGroupsToBody(): void;
|
|
1991
|
-
```
|
|
1992
|
-
|
|
1993
|
-
Sets up a global `Effect` that adds `has-${group}` class names to `document.body` for opened modals.
|
|
1994
|
-
|
|
1995
|
-
#### Example
|
|
1996
|
-
|
|
1997
|
-
```ts
|
|
1998
|
-
import {
|
|
1999
|
-
createModal,
|
|
2000
|
-
withModalGroups,
|
|
2001
|
-
withModalStatus,
|
|
2002
|
-
syncModalGroupsToBody,
|
|
2003
|
-
openModal,
|
|
2004
|
-
closeModal,
|
|
2005
|
-
} from "@monstermann/signals-modal";
|
|
2006
|
-
|
|
2007
|
-
syncModalGroupsToBody();
|
|
2008
|
-
|
|
2009
|
-
const modal = createModal("key", () => {
|
|
2010
|
-
const $groups = withModalGroups(["dialog"]);
|
|
2011
|
-
const { $status } = withModalStatus();
|
|
2012
|
-
return { $groups, $status };
|
|
2013
|
-
});
|
|
2014
|
-
|
|
2015
|
-
document.body.classList; // []
|
|
2016
|
-
openModal("key");
|
|
2017
|
-
document.body.classList; // ["has-dialog"]
|
|
2018
|
-
closeModal("key");
|
|
2019
|
-
document.body.classList; // []
|
|
2020
|
-
```
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { $anchorElements } from "./internals.mjs";
|
|
2
|
-
import { currentModal } from "../createModal.mjs";
|
|
3
1
|
import { INTERNAL, signal } from "@monstermann/signals";
|
|
4
|
-
|
|
5
2
|
//#region src/anchor/withAnchorElement.ts
|
|
6
3
|
const meta = {
|
|
7
4
|
path: "@signals-modal/anchor/withAnchorElement.ts",
|
|
8
|
-
line:
|
|
5
|
+
line: 35,
|
|
9
6
|
name: "withAnchorElement.$anchorElement"
|
|
10
7
|
};
|
|
11
8
|
/**
|
|
@@ -39,17 +36,7 @@ const meta = {
|
|
|
39
36
|
*
|
|
40
37
|
*/
|
|
41
38
|
function withAnchorElement(anchorElement) {
|
|
42
|
-
|
|
43
|
-
const $anchorElement = signal(anchorElement ?? null, INTERNAL, meta);
|
|
44
|
-
$anchorElements((map) => map.set(modal.key, $anchorElement));
|
|
45
|
-
modal.onDispose(() => {
|
|
46
|
-
$anchorElements((map) => {
|
|
47
|
-
map.delete(modal.key);
|
|
48
|
-
return map;
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return $anchorElement;
|
|
39
|
+
return signal(anchorElement ?? null, INTERNAL, meta);
|
|
52
40
|
}
|
|
53
|
-
|
|
54
41
|
//#endregion
|
|
55
|
-
export { withAnchorElement };
|
|
42
|
+
export { withAnchorElement };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { $anchorMeasurements } from "./internals.mjs";
|
|
2
1
|
import { currentModal } from "../createModal.mjs";
|
|
3
2
|
import { observePosition } from "../internals/observePosition.mjs";
|
|
4
3
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
@@ -6,22 +5,21 @@ import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
|
6
5
|
import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
|
|
7
6
|
import { fromElement } from "@monstermann/geometry/Rect/fromElement.mjs";
|
|
8
7
|
import { fromDOMRect } from "@monstermann/geometry/Rect/fromDOMRect.mjs";
|
|
9
|
-
|
|
10
8
|
//#region src/anchor/withAnchorMeasurement.ts
|
|
11
9
|
const path = "@signals-modal/anchor/withAnchorMeasurement.ts";
|
|
12
10
|
const meta = {
|
|
13
11
|
path,
|
|
14
|
-
line:
|
|
12
|
+
line: 60,
|
|
15
13
|
name: "withAnchorMeasurement.$rect"
|
|
16
14
|
};
|
|
17
15
|
const meta1 = {
|
|
18
16
|
path,
|
|
19
|
-
line:
|
|
17
|
+
line: 65,
|
|
20
18
|
name: "withAnchorMeasurement.$measurement"
|
|
21
19
|
};
|
|
22
20
|
const meta2 = {
|
|
23
21
|
path,
|
|
24
|
-
line:
|
|
22
|
+
line: 69,
|
|
25
23
|
name: "withAnchorMeasurement"
|
|
26
24
|
};
|
|
27
25
|
/**
|
|
@@ -81,15 +79,7 @@ function withAnchorMeasurement(options) {
|
|
|
81
79
|
$rect(fromElement(element));
|
|
82
80
|
return observePosition(element, (bounds) => $rect(fromDOMRect(bounds)));
|
|
83
81
|
}, INTERNAL, meta2));
|
|
84
|
-
$anchorMeasurements((map) => map.set(modal.key, $rect));
|
|
85
|
-
modal.onDispose(() => {
|
|
86
|
-
$anchorMeasurements((map) => {
|
|
87
|
-
map.delete(modal.key);
|
|
88
|
-
return map;
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
82
|
return $measurement;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
//#endregion
|
|
95
|
-
export { withAnchorMeasurement };
|
|
85
|
+
export { withAnchorMeasurement };
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { $anchorMeasurements } from "./internals.mjs";
|
|
2
1
|
import { currentModal } from "../createModal.mjs";
|
|
3
2
|
import { INTERNAL, effect, memo, peek, signal } from "@monstermann/signals";
|
|
4
3
|
import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
5
4
|
import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
|
|
6
5
|
import { isOrigin } from "@monstermann/geometry/Rect/isOrigin.mjs";
|
|
7
6
|
import { $mouseX, $mouseY } from "@monstermann/signals-web";
|
|
8
|
-
|
|
9
7
|
//#region src/anchor/withMouseAnchor.ts
|
|
10
8
|
const path = "@signals-modal/anchor/withMouseAnchor.ts";
|
|
11
9
|
const meta = {
|
|
12
10
|
path,
|
|
13
|
-
line:
|
|
11
|
+
line: 49,
|
|
14
12
|
name: "withMouseAnchor.$rect"
|
|
15
13
|
};
|
|
16
14
|
const meta1 = {
|
|
17
15
|
path,
|
|
18
|
-
line:
|
|
16
|
+
line: 54,
|
|
19
17
|
name: "withMouseAnchor.$measurement"
|
|
20
18
|
};
|
|
21
19
|
const meta2 = {
|
|
22
20
|
path,
|
|
23
|
-
line:
|
|
21
|
+
line: 58,
|
|
24
22
|
name: "withMouseAnchor"
|
|
25
23
|
};
|
|
26
24
|
/**
|
|
@@ -72,15 +70,7 @@ function withMouseAnchor(options) {
|
|
|
72
70
|
width: 0
|
|
73
71
|
});
|
|
74
72
|
}, INTERNAL, meta2));
|
|
75
|
-
$anchorMeasurements((map) => map.set(modal.key, $rect));
|
|
76
|
-
modal.onDispose(() => {
|
|
77
|
-
$anchorMeasurements((map) => {
|
|
78
|
-
map.delete(modal.key);
|
|
79
|
-
return map;
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
73
|
return $measurement;
|
|
83
74
|
}
|
|
84
|
-
|
|
85
75
|
//#endregion
|
|
86
|
-
export { withMouseAnchor };
|
|
76
|
+
export { withMouseAnchor };
|
package/dist/createModal.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as _monstermann_signals0 from "@monstermann/signals";
|
|
1
|
+
import * as _$_monstermann_signals0 from "@monstermann/signals";
|
|
2
2
|
import { MaybeDispose } from "@monstermann/signals";
|
|
3
3
|
|
|
4
4
|
//#region src/createModal.d.ts
|
|
@@ -8,7 +8,7 @@ interface ModalContext {
|
|
|
8
8
|
isDisposed: () => boolean;
|
|
9
9
|
onDispose: (dispose: MaybeDispose) => void;
|
|
10
10
|
}
|
|
11
|
-
declare const onModalDisposed: _monstermann_signals0.Emitter<string>;
|
|
11
|
+
declare const onModalDisposed: _$_monstermann_signals0.Emitter<string>;
|
|
12
12
|
declare function currentModal(): ModalContext;
|
|
13
13
|
/**
|
|
14
14
|
* # createModal
|
package/dist/createModal.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { onModalClosed } from "./status/onModalClosed.mjs";
|
|
2
1
|
import { closeModal } from "./status/closeModal.mjs";
|
|
3
2
|
import { isModalClosed } from "./status/isModalClosed.mjs";
|
|
3
|
+
import { onModalClosed } from "./status/onModalClosed.mjs";
|
|
4
4
|
import { SILENT, context, disposer, emitter, isDisposed } from "@monstermann/signals";
|
|
5
|
-
|
|
6
5
|
//#region src/createModal.ts
|
|
7
6
|
const meta = {
|
|
8
7
|
path: "@signals-modal/createModal.ts",
|
|
@@ -72,6 +71,5 @@ function createModal(key, setup) {
|
|
|
72
71
|
modalCtx(prevCtx);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
|
-
|
|
76
74
|
//#endregion
|
|
77
|
-
export { createModal, currentModal, onModalDisposed };
|
|
75
|
+
export { createModal, currentModal, onModalDisposed };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { currentModal } from "../createModal.mjs";
|
|
2
|
-
import { $floatingElements } from "./internals.mjs";
|
|
3
1
|
import { INTERNAL, signal } from "@monstermann/signals";
|
|
4
|
-
|
|
5
2
|
//#region src/floating/withFloatingElement.ts
|
|
6
3
|
const meta = {
|
|
7
4
|
path: "@signals-modal/floating/withFloatingElement.ts",
|
|
8
|
-
line:
|
|
5
|
+
line: 35,
|
|
9
6
|
name: "withFloatingElement.$anchorElement"
|
|
10
7
|
};
|
|
11
8
|
/**
|
|
@@ -39,17 +36,7 @@ const meta = {
|
|
|
39
36
|
*
|
|
40
37
|
*/
|
|
41
38
|
function withFloatingElement(anchorElement) {
|
|
42
|
-
|
|
43
|
-
const $anchorElement = signal(anchorElement ?? null, INTERNAL, meta);
|
|
44
|
-
$floatingElements((map) => map.set(modal.key, $anchorElement));
|
|
45
|
-
modal.onDispose(() => {
|
|
46
|
-
$floatingElements((map) => {
|
|
47
|
-
map.delete(modal.key);
|
|
48
|
-
return map;
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return $anchorElement;
|
|
39
|
+
return signal(anchorElement ?? null, INTERNAL, meta);
|
|
52
40
|
}
|
|
53
|
-
|
|
54
41
|
//#endregion
|
|
55
|
-
export { withFloatingElement };
|
|
42
|
+
export { withFloatingElement };
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { currentModal } from "../createModal.mjs";
|
|
2
|
-
import { $floatingMeasurements } from "./internals.mjs";
|
|
3
2
|
import { observeDimensions } from "../internals/observeDimensions.mjs";
|
|
4
3
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
5
4
|
import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
6
5
|
import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
|
|
7
6
|
import { fromElement } from "@monstermann/geometry/Rect/fromElement.mjs";
|
|
8
|
-
|
|
9
7
|
//#region src/floating/withFloatingMeasurement.ts
|
|
10
8
|
const path = "@signals-modal/floating/withFloatingMeasurement.ts";
|
|
11
9
|
const meta = {
|
|
12
10
|
path,
|
|
13
|
-
line:
|
|
11
|
+
line: 57,
|
|
14
12
|
name: "withFloatingMeasurement.$rect"
|
|
15
13
|
};
|
|
16
14
|
const meta1 = {
|
|
17
15
|
path,
|
|
18
|
-
line:
|
|
16
|
+
line: 62,
|
|
19
17
|
name: "withFloatingMeasurement.$measurement"
|
|
20
18
|
};
|
|
21
19
|
const meta2 = {
|
|
22
20
|
path,
|
|
23
|
-
line:
|
|
21
|
+
line: 66,
|
|
24
22
|
name: "withFloatingMeasurement"
|
|
25
23
|
};
|
|
26
24
|
/**
|
|
@@ -89,15 +87,7 @@ function withFloatingMeasurement(options) {
|
|
|
89
87
|
width: bounds.width
|
|
90
88
|
}));
|
|
91
89
|
}, INTERNAL, meta2));
|
|
92
|
-
$floatingMeasurements((map) => map.set(modal.key, $rect));
|
|
93
|
-
modal.onDispose(() => {
|
|
94
|
-
$floatingMeasurements((map) => {
|
|
95
|
-
map.delete(modal.key);
|
|
96
|
-
return map;
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
90
|
return $measurement;
|
|
100
91
|
}
|
|
101
|
-
|
|
102
92
|
//#endregion
|
|
103
|
-
export { withFloatingMeasurement };
|
|
93
|
+
export { withFloatingMeasurement };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getModalsForGroup } from "./getModalsForGroup.mjs";
|
|
2
2
|
import { modalGroups } from "./modalGroups.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/groups/getDialogs.ts
|
|
5
4
|
/**
|
|
6
5
|
* # getDialogs
|
|
@@ -34,6 +33,5 @@ import { modalGroups } from "./modalGroups.mjs";
|
|
|
34
33
|
function getDialogs() {
|
|
35
34
|
return getModalsForGroup(modalGroups.dialog);
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
|
-
export { getDialogs };
|
|
37
|
+
export { getDialogs };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $keysToGroups } from "./internals.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/groups/getGroupsForModal.ts
|
|
4
3
|
const empty = /* @__PURE__ */ new Set();
|
|
5
4
|
/**
|
|
@@ -34,6 +33,5 @@ const empty = /* @__PURE__ */ new Set();
|
|
|
34
33
|
function getGroupsForModal(key) {
|
|
35
34
|
return $keysToGroups().get(key) ?? empty;
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
|
-
export { getGroupsForModal };
|
|
37
|
+
export { getGroupsForModal };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $groupsToKeys } from "./internals.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/groups/getModalsForGroup.ts
|
|
4
3
|
const empty = /* @__PURE__ */ new Set();
|
|
5
4
|
/**
|
|
@@ -34,6 +33,5 @@ const empty = /* @__PURE__ */ new Set();
|
|
|
34
33
|
function getModalsForGroup(group) {
|
|
35
34
|
return $groupsToKeys().get(group) ?? empty;
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
|
-
export { getModalsForGroup };
|
|
37
|
+
export { getModalsForGroup };
|