@monstermann/signals-modal 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -377
- package/dist/anchor/withAnchorElement.mjs +2 -13
- package/dist/anchor/withAnchorMeasurement.mjs +3 -11
- package/dist/anchor/withMouseAnchor.mjs +3 -11
- package/dist/createModal.mjs +1 -1
- package/dist/floating/withFloatingElement.mjs +2 -13
- package/dist/floating/withFloatingMeasurement.mjs +3 -11
- package/dist/index.d.mts +2 -14
- package/dist/index.mjs +5 -17
- package/dist/position/internals.mjs +1 -21
- package/dist/position/withPlacement.mjs +3 -13
- package/dist/position/withPosition.mjs +5 -15
- package/dist/status/internals.mjs +4 -31
- package/dist/status/withModalStatus.mjs +3 -3
- 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,9 @@
|
|
|
1
|
-
import { $anchorElements } from "./internals.mjs";
|
|
2
|
-
import { currentModal } from "../createModal.mjs";
|
|
3
1
|
import { INTERNAL, signal } from "@monstermann/signals";
|
|
4
2
|
|
|
5
3
|
//#region src/anchor/withAnchorElement.ts
|
|
6
4
|
const meta = {
|
|
7
5
|
path: "@signals-modal/anchor/withAnchorElement.ts",
|
|
8
|
-
line:
|
|
6
|
+
line: 35,
|
|
9
7
|
name: "withAnchorElement.$anchorElement"
|
|
10
8
|
};
|
|
11
9
|
/**
|
|
@@ -39,16 +37,7 @@ const meta = {
|
|
|
39
37
|
*
|
|
40
38
|
*/
|
|
41
39
|
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;
|
|
40
|
+
return signal(anchorElement ?? null, INTERNAL, meta);
|
|
52
41
|
}
|
|
53
42
|
|
|
54
43
|
//#endregion
|
|
@@ -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";
|
|
@@ -11,17 +10,17 @@ import { fromDOMRect } from "@monstermann/geometry/Rect/fromDOMRect.mjs";
|
|
|
11
10
|
const path = "@signals-modal/anchor/withAnchorMeasurement.ts";
|
|
12
11
|
const meta = {
|
|
13
12
|
path,
|
|
14
|
-
line:
|
|
13
|
+
line: 60,
|
|
15
14
|
name: "withAnchorMeasurement.$rect"
|
|
16
15
|
};
|
|
17
16
|
const meta1 = {
|
|
18
17
|
path,
|
|
19
|
-
line:
|
|
18
|
+
line: 65,
|
|
20
19
|
name: "withAnchorMeasurement.$measurement"
|
|
21
20
|
};
|
|
22
21
|
const meta2 = {
|
|
23
22
|
path,
|
|
24
|
-
line:
|
|
23
|
+
line: 69,
|
|
25
24
|
name: "withAnchorMeasurement"
|
|
26
25
|
};
|
|
27
26
|
/**
|
|
@@ -81,13 +80,6 @@ function withAnchorMeasurement(options) {
|
|
|
81
80
|
$rect(fromElement(element));
|
|
82
81
|
return observePosition(element, (bounds) => $rect(fromDOMRect(bounds)));
|
|
83
82
|
}, 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
83
|
return $measurement;
|
|
92
84
|
}
|
|
93
85
|
|
|
@@ -1,4 +1,3 @@
|
|
|
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";
|
|
@@ -10,17 +9,17 @@ import { $mouseX, $mouseY } from "@monstermann/signals-web";
|
|
|
10
9
|
const path = "@signals-modal/anchor/withMouseAnchor.ts";
|
|
11
10
|
const meta = {
|
|
12
11
|
path,
|
|
13
|
-
line:
|
|
12
|
+
line: 49,
|
|
14
13
|
name: "withMouseAnchor.$rect"
|
|
15
14
|
};
|
|
16
15
|
const meta1 = {
|
|
17
16
|
path,
|
|
18
|
-
line:
|
|
17
|
+
line: 54,
|
|
19
18
|
name: "withMouseAnchor.$measurement"
|
|
20
19
|
};
|
|
21
20
|
const meta2 = {
|
|
22
21
|
path,
|
|
23
|
-
line:
|
|
22
|
+
line: 58,
|
|
24
23
|
name: "withMouseAnchor"
|
|
25
24
|
};
|
|
26
25
|
/**
|
|
@@ -72,13 +71,6 @@ function withMouseAnchor(options) {
|
|
|
72
71
|
width: 0
|
|
73
72
|
});
|
|
74
73
|
}, 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
74
|
return $measurement;
|
|
83
75
|
}
|
|
84
76
|
|
package/dist/createModal.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
|
|
6
6
|
//#region src/createModal.ts
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { currentModal } from "../createModal.mjs";
|
|
2
|
-
import { $floatingElements } from "./internals.mjs";
|
|
3
1
|
import { INTERNAL, signal } from "@monstermann/signals";
|
|
4
2
|
|
|
5
3
|
//#region src/floating/withFloatingElement.ts
|
|
6
4
|
const meta = {
|
|
7
5
|
path: "@signals-modal/floating/withFloatingElement.ts",
|
|
8
|
-
line:
|
|
6
|
+
line: 35,
|
|
9
7
|
name: "withFloatingElement.$anchorElement"
|
|
10
8
|
};
|
|
11
9
|
/**
|
|
@@ -39,16 +37,7 @@ const meta = {
|
|
|
39
37
|
*
|
|
40
38
|
*/
|
|
41
39
|
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;
|
|
40
|
+
return signal(anchorElement ?? null, INTERNAL, meta);
|
|
52
41
|
}
|
|
53
42
|
|
|
54
43
|
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
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";
|
|
@@ -10,17 +9,17 @@ import { fromElement } from "@monstermann/geometry/Rect/fromElement.mjs";
|
|
|
10
9
|
const path = "@signals-modal/floating/withFloatingMeasurement.ts";
|
|
11
10
|
const meta = {
|
|
12
11
|
path,
|
|
13
|
-
line:
|
|
12
|
+
line: 57,
|
|
14
13
|
name: "withFloatingMeasurement.$rect"
|
|
15
14
|
};
|
|
16
15
|
const meta1 = {
|
|
17
16
|
path,
|
|
18
|
-
line:
|
|
17
|
+
line: 62,
|
|
19
18
|
name: "withFloatingMeasurement.$measurement"
|
|
20
19
|
};
|
|
21
20
|
const meta2 = {
|
|
22
21
|
path,
|
|
23
|
-
line:
|
|
22
|
+
line: 66,
|
|
24
23
|
name: "withFloatingMeasurement"
|
|
25
24
|
};
|
|
26
25
|
/**
|
|
@@ -89,13 +88,6 @@ function withFloatingMeasurement(options) {
|
|
|
89
88
|
width: bounds.width
|
|
90
89
|
}));
|
|
91
90
|
}, 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
91
|
return $measurement;
|
|
100
92
|
}
|
|
101
93
|
|
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
|
-
|
|
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 };
|