@monstermann/signals-modal 0.3.4 → 0.4.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/dist/anchor/getAnchorMeasurement.mjs +1 -1
- package/dist/anchor/internals.mjs +10 -4
- package/dist/anchor/withAnchorElement.mjs +8 -15
- package/dist/anchor/withAnchorMeasurement.mjs +8 -14
- package/dist/anchor/withMouseAnchor.mjs +8 -14
- package/dist/floating/getFloatingMeasurement.mjs +1 -1
- package/dist/floating/internals.mjs +10 -4
- package/dist/floating/withFloatingElement.mjs +8 -15
- package/dist/floating/withFloatingMeasurement.mjs +8 -14
- package/dist/groups/internals.mjs +6 -3
- package/dist/groups/withModalGroups.mjs +9 -8
- package/dist/position/getModalPlacement.mjs +1 -1
- package/dist/position/getModalPosition.mjs +1 -1
- package/dist/position/internals.mjs +11 -5
- package/dist/position/withPlacement.mjs +8 -15
- package/dist/position/withPosition.mjs +8 -15
- package/dist/status/internals.mjs +6 -3
- package/dist/status/withModalStatus.mjs +8 -7
- package/package.json +6 -6
|
@@ -3,7 +3,7 @@ import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
|
3
3
|
|
|
4
4
|
//#region src/anchor/getAnchorMeasurement.ts
|
|
5
5
|
function getAnchorMeasurement(key) {
|
|
6
|
-
return $anchorMeasurements().get(key) ?? origin;
|
|
6
|
+
return $anchorMeasurements().get(key)?.() ?? origin;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { signal } from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/anchor/internals.ts
|
|
4
4
|
const path = "@signals-modal/anchor/internals.ts";
|
|
@@ -9,11 +9,17 @@ const meta = {
|
|
|
9
9
|
};
|
|
10
10
|
const meta1 = {
|
|
11
11
|
path,
|
|
12
|
-
line:
|
|
12
|
+
line: 10,
|
|
13
13
|
name: "$anchorMeasurements"
|
|
14
14
|
};
|
|
15
|
-
const $anchorElements = signal(/* @__PURE__ */ new Map(),
|
|
16
|
-
|
|
15
|
+
const $anchorElements = signal(/* @__PURE__ */ new Map(), {
|
|
16
|
+
mutable: true,
|
|
17
|
+
silent: true
|
|
18
|
+
}, meta);
|
|
19
|
+
const $anchorMeasurements = signal(/* @__PURE__ */ new Map(), {
|
|
20
|
+
mutable: true,
|
|
21
|
+
silent: true
|
|
22
|
+
}, meta1);
|
|
17
23
|
|
|
18
24
|
//#endregion
|
|
19
25
|
export { $anchorElements, $anchorMeasurements };
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
import { $anchorElements } from "./internals.mjs";
|
|
2
2
|
import { currentModal } from "../createModal.mjs";
|
|
3
|
-
import { INTERNAL,
|
|
4
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
5
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
3
|
+
import { INTERNAL, signal } from "@monstermann/signals";
|
|
6
4
|
|
|
7
5
|
//#region src/anchor/withAnchorElement.ts
|
|
8
|
-
const path = "@signals-modal/anchor/withAnchorElement.ts";
|
|
9
6
|
const meta = {
|
|
10
|
-
path,
|
|
11
|
-
line:
|
|
7
|
+
path: "@signals-modal/anchor/withAnchorElement.ts",
|
|
8
|
+
line: 8,
|
|
12
9
|
name: "withAnchorElement.$anchorElement"
|
|
13
10
|
};
|
|
14
|
-
const meta1 = {
|
|
15
|
-
path,
|
|
16
|
-
line: 12,
|
|
17
|
-
name: "withAnchorElement"
|
|
18
|
-
};
|
|
19
11
|
function withAnchorElement(anchorElement) {
|
|
20
12
|
const modal = currentModal();
|
|
21
13
|
const $anchorElement = signal(anchorElement ?? null, INTERNAL, meta);
|
|
22
|
-
|
|
23
|
-
$anchorElements((map) => set(map, modal.key, $anchorElement));
|
|
24
|
-
}, INTERNAL, meta1));
|
|
14
|
+
$anchorElements((map) => map.set(modal.key, $anchorElement));
|
|
25
15
|
modal.onDispose(() => {
|
|
26
|
-
$anchorElements((map) =>
|
|
16
|
+
$anchorElements((map) => {
|
|
17
|
+
map.delete(modal.key);
|
|
18
|
+
return map;
|
|
19
|
+
});
|
|
27
20
|
});
|
|
28
21
|
return $anchorElement;
|
|
29
22
|
}
|
|
@@ -3,8 +3,6 @@ import { currentModal } from "../createModal.mjs";
|
|
|
3
3
|
import { observePosition } from "../internals/observePosition.mjs";
|
|
4
4
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
5
5
|
import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
6
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
7
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
8
6
|
import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
|
|
9
7
|
import { fromElement } from "@monstermann/geometry/Rect/fromElement.mjs";
|
|
10
8
|
import { fromDOMRect } from "@monstermann/geometry/Rect/fromDOMRect.mjs";
|
|
@@ -13,22 +11,17 @@ import { fromDOMRect } from "@monstermann/geometry/Rect/fromDOMRect.mjs";
|
|
|
13
11
|
const path = "@signals-modal/anchor/withAnchorMeasurement.ts";
|
|
14
12
|
const meta = {
|
|
15
13
|
path,
|
|
16
|
-
line:
|
|
14
|
+
line: 19,
|
|
17
15
|
name: "withAnchorMeasurement.$rect"
|
|
18
16
|
};
|
|
19
17
|
const meta1 = {
|
|
20
18
|
path,
|
|
21
|
-
line:
|
|
19
|
+
line: 24,
|
|
22
20
|
name: "withAnchorMeasurement.$measurement"
|
|
23
21
|
};
|
|
24
22
|
const meta2 = {
|
|
25
23
|
path,
|
|
26
|
-
line:
|
|
27
|
-
name: "withAnchorMeasurement"
|
|
28
|
-
};
|
|
29
|
-
const meta3 = {
|
|
30
|
-
path,
|
|
31
|
-
line: 39,
|
|
24
|
+
line: 28,
|
|
32
25
|
name: "withAnchorMeasurement"
|
|
33
26
|
};
|
|
34
27
|
function withAnchorMeasurement(options) {
|
|
@@ -46,11 +39,12 @@ function withAnchorMeasurement(options) {
|
|
|
46
39
|
$rect(fromElement(element));
|
|
47
40
|
return observePosition(element, (bounds) => $rect(fromDOMRect(bounds)));
|
|
48
41
|
}, INTERNAL, meta2));
|
|
49
|
-
|
|
50
|
-
$anchorMeasurements((map) => set(map, modal.key, $rect()));
|
|
51
|
-
}, INTERNAL, meta3));
|
|
42
|
+
$anchorMeasurements((map) => map.set(modal.key, $rect));
|
|
52
43
|
modal.onDispose(() => {
|
|
53
|
-
$anchorMeasurements((map) =>
|
|
44
|
+
$anchorMeasurements((map) => {
|
|
45
|
+
map.delete(modal.key);
|
|
46
|
+
return map;
|
|
47
|
+
});
|
|
54
48
|
});
|
|
55
49
|
return $measurement;
|
|
56
50
|
}
|
|
@@ -2,8 +2,6 @@ import { $anchorMeasurements } from "./internals.mjs";
|
|
|
2
2
|
import { currentModal } from "../createModal.mjs";
|
|
3
3
|
import { INTERNAL, effect, memo, peek, signal } from "@monstermann/signals";
|
|
4
4
|
import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
5
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
6
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
7
5
|
import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
|
|
8
6
|
import { isOrigin } from "@monstermann/geometry/Rect/isOrigin.mjs";
|
|
9
7
|
import { $mouseX, $mouseY } from "@monstermann/signals-web";
|
|
@@ -12,22 +10,17 @@ import { $mouseX, $mouseY } from "@monstermann/signals-web";
|
|
|
12
10
|
const path = "@signals-modal/anchor/withMouseAnchor.ts";
|
|
13
11
|
const meta = {
|
|
14
12
|
path,
|
|
15
|
-
line:
|
|
13
|
+
line: 17,
|
|
16
14
|
name: "withMouseAnchor.$rect"
|
|
17
15
|
};
|
|
18
16
|
const meta1 = {
|
|
19
17
|
path,
|
|
20
|
-
line:
|
|
18
|
+
line: 22,
|
|
21
19
|
name: "withMouseAnchor.$measurement"
|
|
22
20
|
};
|
|
23
21
|
const meta2 = {
|
|
24
22
|
path,
|
|
25
|
-
line:
|
|
26
|
-
name: "withMouseAnchor"
|
|
27
|
-
};
|
|
28
|
-
const meta3 = {
|
|
29
|
-
path,
|
|
30
|
-
line: 42,
|
|
23
|
+
line: 26,
|
|
31
24
|
name: "withMouseAnchor"
|
|
32
25
|
};
|
|
33
26
|
function withMouseAnchor(options) {
|
|
@@ -46,11 +39,12 @@ function withMouseAnchor(options) {
|
|
|
46
39
|
width: 0
|
|
47
40
|
});
|
|
48
41
|
}, INTERNAL, meta2));
|
|
49
|
-
|
|
50
|
-
$anchorMeasurements((map) => set(map, modal.key, $rect()));
|
|
51
|
-
}, INTERNAL, meta3));
|
|
42
|
+
$anchorMeasurements((map) => map.set(modal.key, $rect));
|
|
52
43
|
modal.onDispose(() => {
|
|
53
|
-
$anchorMeasurements((map) =>
|
|
44
|
+
$anchorMeasurements((map) => {
|
|
45
|
+
map.delete(modal.key);
|
|
46
|
+
return map;
|
|
47
|
+
});
|
|
54
48
|
});
|
|
55
49
|
return $measurement;
|
|
56
50
|
}
|
|
@@ -3,7 +3,7 @@ import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
|
3
3
|
|
|
4
4
|
//#region src/floating/getFloatingMeasurement.ts
|
|
5
5
|
function getFloatingMeasurement(key) {
|
|
6
|
-
return $floatingMeasurements().get(key) ?? origin;
|
|
6
|
+
return $floatingMeasurements().get(key)?.() ?? origin;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { signal } from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/floating/internals.ts
|
|
4
4
|
const path = "@signals-modal/floating/internals.ts";
|
|
@@ -9,11 +9,17 @@ const meta = {
|
|
|
9
9
|
};
|
|
10
10
|
const meta1 = {
|
|
11
11
|
path,
|
|
12
|
-
line:
|
|
12
|
+
line: 10,
|
|
13
13
|
name: "$floatingMeasurements"
|
|
14
14
|
};
|
|
15
|
-
const $floatingElements = signal(/* @__PURE__ */ new Map(),
|
|
16
|
-
|
|
15
|
+
const $floatingElements = signal(/* @__PURE__ */ new Map(), {
|
|
16
|
+
mutable: true,
|
|
17
|
+
silent: true
|
|
18
|
+
}, meta);
|
|
19
|
+
const $floatingMeasurements = signal(/* @__PURE__ */ new Map(), {
|
|
20
|
+
mutable: true,
|
|
21
|
+
silent: true
|
|
22
|
+
}, meta1);
|
|
17
23
|
|
|
18
24
|
//#endregion
|
|
19
25
|
export { $floatingElements, $floatingMeasurements };
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
import { currentModal } from "../createModal.mjs";
|
|
2
2
|
import { $floatingElements } from "./internals.mjs";
|
|
3
|
-
import { INTERNAL,
|
|
4
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
5
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
3
|
+
import { INTERNAL, signal } from "@monstermann/signals";
|
|
6
4
|
|
|
7
5
|
//#region src/floating/withFloatingElement.ts
|
|
8
|
-
const path = "@signals-modal/floating/withFloatingElement.ts";
|
|
9
6
|
const meta = {
|
|
10
|
-
path,
|
|
11
|
-
line:
|
|
7
|
+
path: "@signals-modal/floating/withFloatingElement.ts",
|
|
8
|
+
line: 8,
|
|
12
9
|
name: "withFloatingElement.$anchorElement"
|
|
13
10
|
};
|
|
14
|
-
const meta1 = {
|
|
15
|
-
path,
|
|
16
|
-
line: 12,
|
|
17
|
-
name: "withFloatingElement"
|
|
18
|
-
};
|
|
19
11
|
function withFloatingElement(anchorElement) {
|
|
20
12
|
const modal = currentModal();
|
|
21
13
|
const $anchorElement = signal(anchorElement ?? null, INTERNAL, meta);
|
|
22
|
-
|
|
23
|
-
$floatingElements((map) => set(map, modal.key, $anchorElement));
|
|
24
|
-
}, INTERNAL, meta1));
|
|
14
|
+
$floatingElements((map) => map.set(modal.key, $anchorElement));
|
|
25
15
|
modal.onDispose(() => {
|
|
26
|
-
$floatingElements((map) =>
|
|
16
|
+
$floatingElements((map) => {
|
|
17
|
+
map.delete(modal.key);
|
|
18
|
+
return map;
|
|
19
|
+
});
|
|
27
20
|
});
|
|
28
21
|
return $anchorElement;
|
|
29
22
|
}
|
|
@@ -3,8 +3,6 @@ import { $floatingMeasurements } from "./internals.mjs";
|
|
|
3
3
|
import { observeDimensions } from "../internals/observeDimensions.mjs";
|
|
4
4
|
import { INTERNAL, effect, memo, signal } from "@monstermann/signals";
|
|
5
5
|
import { origin } from "@monstermann/geometry/Rect/origin.mjs";
|
|
6
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
7
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
8
6
|
import { isEqual } from "@monstermann/geometry/Rect/isEqual.mjs";
|
|
9
7
|
import { fromElement } from "@monstermann/geometry/Rect/fromElement.mjs";
|
|
10
8
|
|
|
@@ -12,22 +10,17 @@ import { fromElement } from "@monstermann/geometry/Rect/fromElement.mjs";
|
|
|
12
10
|
const path = "@signals-modal/floating/withFloatingMeasurement.ts";
|
|
13
11
|
const meta = {
|
|
14
12
|
path,
|
|
15
|
-
line:
|
|
13
|
+
line: 18,
|
|
16
14
|
name: "withFloatingMeasurement.$rect"
|
|
17
15
|
};
|
|
18
16
|
const meta1 = {
|
|
19
17
|
path,
|
|
20
|
-
line:
|
|
18
|
+
line: 23,
|
|
21
19
|
name: "withFloatingMeasurement.$measurement"
|
|
22
20
|
};
|
|
23
21
|
const meta2 = {
|
|
24
22
|
path,
|
|
25
|
-
line:
|
|
26
|
-
name: "withFloatingMeasurement"
|
|
27
|
-
};
|
|
28
|
-
const meta3 = {
|
|
29
|
-
path,
|
|
30
|
-
line: 49,
|
|
23
|
+
line: 27,
|
|
31
24
|
name: "withFloatingMeasurement"
|
|
32
25
|
};
|
|
33
26
|
function withFloatingMeasurement(options) {
|
|
@@ -56,11 +49,12 @@ function withFloatingMeasurement(options) {
|
|
|
56
49
|
width: bounds$1.width
|
|
57
50
|
}));
|
|
58
51
|
}, INTERNAL, meta2));
|
|
59
|
-
|
|
60
|
-
$floatingMeasurements((map) => set(map, modal.key, $rect()));
|
|
61
|
-
}, INTERNAL, meta3));
|
|
52
|
+
$floatingMeasurements((map) => map.set(modal.key, $rect));
|
|
62
53
|
modal.onDispose(() => {
|
|
63
|
-
$floatingMeasurements((map) =>
|
|
54
|
+
$floatingMeasurements((map) => {
|
|
55
|
+
map.delete(modal.key);
|
|
56
|
+
return map;
|
|
57
|
+
});
|
|
64
58
|
});
|
|
65
59
|
return $measurement;
|
|
66
60
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INTERNAL,
|
|
1
|
+
import { INTERNAL, memo, signal } from "@monstermann/signals";
|
|
2
2
|
|
|
3
3
|
//#region src/groups/internals.ts
|
|
4
4
|
const path = "@signals-modal/groups/internals.ts";
|
|
@@ -9,10 +9,13 @@ const meta = {
|
|
|
9
9
|
};
|
|
10
10
|
const meta1 = {
|
|
11
11
|
path,
|
|
12
|
-
line:
|
|
12
|
+
line: 8,
|
|
13
13
|
name: "$groupsToKeys"
|
|
14
14
|
};
|
|
15
|
-
const $keysToGroups = signal(/* @__PURE__ */ new Map(),
|
|
15
|
+
const $keysToGroups = signal(/* @__PURE__ */ new Map(), {
|
|
16
|
+
mutable: true,
|
|
17
|
+
silent: true
|
|
18
|
+
}, meta);
|
|
16
19
|
const $groupsToKeys = memo(() => {
|
|
17
20
|
const map = /* @__PURE__ */ new Map();
|
|
18
21
|
for (const [key, groups] of $keysToGroups()) for (const group of groups) {
|
|
@@ -2,25 +2,26 @@ 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
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
6
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
7
|
-
import { create } from "@monstermann/set/Set/create.mjs";
|
|
8
|
-
import { mapOrElse } from "@monstermann/map/Map/mapOrElse.mjs";
|
|
9
|
-
import { addAll } from "@monstermann/set/Set/addAll.mjs";
|
|
10
5
|
|
|
11
6
|
//#region src/groups/withModalGroups.ts
|
|
12
7
|
const meta = {
|
|
13
8
|
path: "@signals-modal/groups/withModalGroups.ts",
|
|
14
|
-
line:
|
|
9
|
+
line: 24,
|
|
15
10
|
name: "withModalGroups"
|
|
16
11
|
};
|
|
17
12
|
function withModalGroups(groups) {
|
|
18
13
|
const modal = currentModal();
|
|
19
14
|
$keysToGroups((keys) => {
|
|
20
|
-
|
|
15
|
+
if (!keys.has(modal.key)) keys.set(modal.key, /* @__PURE__ */ new Set());
|
|
16
|
+
const g = keys.get(modal.key);
|
|
17
|
+
for (const group of groups) g.add(group);
|
|
18
|
+
return keys;
|
|
21
19
|
});
|
|
22
20
|
modal.onDispose(() => {
|
|
23
|
-
$keysToGroups((keys) =>
|
|
21
|
+
$keysToGroups((keys) => {
|
|
22
|
+
keys.delete(modal.key);
|
|
23
|
+
return keys;
|
|
24
|
+
});
|
|
24
25
|
});
|
|
25
26
|
return memo(() => getGroupsForModal(modal.key), INTERNAL, meta);
|
|
26
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { signal } from "@monstermann/signals";
|
|
2
2
|
import { setBottom } from "@monstermann/geometry/Rect/setBottom.mjs";
|
|
3
3
|
import { top } from "@monstermann/geometry/Rect/top.mjs";
|
|
4
4
|
import { setTop } from "@monstermann/geometry/Rect/setTop.mjs";
|
|
@@ -12,16 +12,22 @@ import { right } from "@monstermann/geometry/Rect/right.mjs";
|
|
|
12
12
|
const path = "@signals-modal/position/internals.ts";
|
|
13
13
|
const meta = {
|
|
14
14
|
path,
|
|
15
|
-
line:
|
|
15
|
+
line: 14,
|
|
16
16
|
name: "$positions"
|
|
17
17
|
};
|
|
18
18
|
const meta1 = {
|
|
19
19
|
path,
|
|
20
|
-
line:
|
|
20
|
+
line: 19,
|
|
21
21
|
name: "$placements"
|
|
22
22
|
};
|
|
23
|
-
const $positions = signal(/* @__PURE__ */ new Map(),
|
|
24
|
-
|
|
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);
|
|
25
31
|
function getBoundaryUp(boundary, anchor) {
|
|
26
32
|
return setBottom(boundary, top(anchor));
|
|
27
33
|
}
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { currentModal } from "../createModal.mjs";
|
|
2
2
|
import { $placements, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.mjs";
|
|
3
|
-
import { INTERNAL,
|
|
4
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
5
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
3
|
+
import { INTERNAL, memo } from "@monstermann/signals";
|
|
6
4
|
import { width } from "@monstermann/geometry/Rect/width.mjs";
|
|
7
5
|
import { height } from "@monstermann/geometry/Rect/height.mjs";
|
|
8
6
|
|
|
9
7
|
//#region src/position/withPlacement.ts
|
|
10
|
-
const path = "@signals-modal/position/withPlacement.ts";
|
|
11
8
|
const meta = {
|
|
12
|
-
path,
|
|
13
|
-
line:
|
|
9
|
+
path: "@signals-modal/position/withPlacement.ts",
|
|
10
|
+
line: 97,
|
|
14
11
|
name: "withPlacement.$placement"
|
|
15
12
|
};
|
|
16
|
-
const meta1 = {
|
|
17
|
-
path,
|
|
18
|
-
line: 107,
|
|
19
|
-
name: "withPlacement"
|
|
20
|
-
};
|
|
21
13
|
const placementResolvers = {
|
|
22
14
|
"down-center": () => "down-center",
|
|
23
15
|
"left-down": () => "left-down",
|
|
@@ -57,11 +49,12 @@ function withPlacement(options) {
|
|
|
57
49
|
floating: options.$floatingMeasurement()
|
|
58
50
|
});
|
|
59
51
|
}, INTERNAL, meta);
|
|
60
|
-
|
|
61
|
-
$placements((p) => set(p, modal.key, $placement()));
|
|
62
|
-
}, void 0, meta1));
|
|
52
|
+
$placements((p) => p.set(modal.key, $placement));
|
|
63
53
|
modal.onDispose(() => {
|
|
64
|
-
$placements((p) =>
|
|
54
|
+
$placements((p) => {
|
|
55
|
+
p.delete(modal.key);
|
|
56
|
+
return p;
|
|
57
|
+
});
|
|
65
58
|
});
|
|
66
59
|
return $placement;
|
|
67
60
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { currentModal } from "../createModal.mjs";
|
|
2
2
|
import { $positions, getBoundaryDown, getBoundaryLeft, getBoundaryRight, getBoundaryUp } from "./internals.mjs";
|
|
3
3
|
import { roundByDPR } from "../internals/roundByDPR.mjs";
|
|
4
|
-
import { INTERNAL,
|
|
5
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
6
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
4
|
+
import { INTERNAL, memo } from "@monstermann/signals";
|
|
7
5
|
import { top } from "@monstermann/geometry/Rect/top.mjs";
|
|
8
6
|
import { left } from "@monstermann/geometry/Rect/left.mjs";
|
|
9
7
|
import { right } from "@monstermann/geometry/Rect/right.mjs";
|
|
@@ -26,17 +24,11 @@ import { snapRightOf } from "@monstermann/geometry/Rect/snapRightOf.mjs";
|
|
|
26
24
|
import { snapAbove } from "@monstermann/geometry/Rect/snapAbove.mjs";
|
|
27
25
|
|
|
28
26
|
//#region src/position/withPosition.ts
|
|
29
|
-
const path = "@signals-modal/position/withPosition.ts";
|
|
30
27
|
const meta = {
|
|
31
|
-
path,
|
|
32
|
-
line:
|
|
28
|
+
path: "@signals-modal/position/withPosition.ts",
|
|
29
|
+
line: 313,
|
|
33
30
|
name: "withPosition.$position"
|
|
34
31
|
};
|
|
35
|
-
const meta1 = {
|
|
36
|
-
path,
|
|
37
|
-
line: 324,
|
|
38
|
-
name: "withPosition"
|
|
39
|
-
};
|
|
40
32
|
const positionResolvers = {
|
|
41
33
|
"down-center": function(o) {
|
|
42
34
|
const boundary = getBoundaryDown(o.boundary, o.anchor);
|
|
@@ -213,11 +205,12 @@ function withPosition(options) {
|
|
|
213
205
|
transform: options.transform ?? ((r) => r)
|
|
214
206
|
});
|
|
215
207
|
}, INTERNAL, meta);
|
|
216
|
-
|
|
217
|
-
$positions((p) => set(p, modal.key, $position()));
|
|
218
|
-
}, INTERNAL, meta1));
|
|
208
|
+
$positions((p) => p.set(modal.key, $position));
|
|
219
209
|
modal.onDispose(() => {
|
|
220
|
-
$positions((p) =>
|
|
210
|
+
$positions((p) => {
|
|
211
|
+
p.delete(modal.key);
|
|
212
|
+
return p;
|
|
213
|
+
});
|
|
221
214
|
});
|
|
222
215
|
return $position;
|
|
223
216
|
}
|
|
@@ -2,7 +2,7 @@ import { onModalClosed } from "./onModalClosed.mjs";
|
|
|
2
2
|
import { onModalOpened } from "./onModalOpened.mjs";
|
|
3
3
|
import { onModalOpening } from "./onModalOpening.mjs";
|
|
4
4
|
import { onModalDisposed } from "../createModal.mjs";
|
|
5
|
-
import { INTERNAL,
|
|
5
|
+
import { INTERNAL, signal } from "@monstermann/signals";
|
|
6
6
|
import { create } from "@monstermann/set/Set/create.mjs";
|
|
7
7
|
import { add } from "@monstermann/set/Set/add.mjs";
|
|
8
8
|
import { remove } from "@monstermann/set/Set/remove.mjs";
|
|
@@ -16,10 +16,13 @@ const meta = {
|
|
|
16
16
|
};
|
|
17
17
|
const meta1 = {
|
|
18
18
|
path,
|
|
19
|
-
line:
|
|
19
|
+
line: 17,
|
|
20
20
|
name: "$openedModals"
|
|
21
21
|
};
|
|
22
|
-
const $keysToStatus = signal(/* @__PURE__ */ new Map(),
|
|
22
|
+
const $keysToStatus = signal(/* @__PURE__ */ new Map(), {
|
|
23
|
+
mutable: true,
|
|
24
|
+
silent: true
|
|
25
|
+
}, meta);
|
|
23
26
|
const $openedModals = signal(create(), INTERNAL, meta1);
|
|
24
27
|
onModalOpening((key) => $openedModals((m) => add(m, key)));
|
|
25
28
|
onModalOpened((key) => $openedModals((m) => add(m, key)));
|
|
@@ -8,31 +8,32 @@ import { isModalOpen } from "./isModalOpen.mjs";
|
|
|
8
8
|
import { onModalClosing } from "./onModalClosing.mjs";
|
|
9
9
|
import { openModal } from "./openModal.mjs";
|
|
10
10
|
import { INTERNAL, memo, signal, watch } from "@monstermann/signals";
|
|
11
|
-
import { set } from "@monstermann/map/Map/set.mjs";
|
|
12
|
-
import { remove } from "@monstermann/map/Map/remove.mjs";
|
|
13
11
|
|
|
14
12
|
//#region src/status/withModalStatus.ts
|
|
15
13
|
const path = "@signals-modal/status/withModalStatus.ts";
|
|
16
14
|
const meta = {
|
|
17
15
|
path,
|
|
18
|
-
line:
|
|
16
|
+
line: 21,
|
|
19
17
|
name: "withModalStatus.$status"
|
|
20
18
|
};
|
|
21
19
|
const meta1 = {
|
|
22
20
|
path,
|
|
23
|
-
line:
|
|
21
|
+
line: 29,
|
|
24
22
|
name: "withModalStatus"
|
|
25
23
|
};
|
|
26
24
|
const meta2 = {
|
|
27
25
|
path,
|
|
28
|
-
line:
|
|
26
|
+
line: 37,
|
|
29
27
|
name: "withModalStatus.$isOpen"
|
|
30
28
|
};
|
|
31
29
|
function withModalStatus(status = "closed") {
|
|
32
30
|
const modal = currentModal();
|
|
33
31
|
const $status = signal(status, INTERNAL, meta);
|
|
34
|
-
$keysToStatus((keys) => set(
|
|
35
|
-
modal.onDispose(() => $keysToStatus((keys) =>
|
|
32
|
+
$keysToStatus((keys) => keys.set(modal.key, $status));
|
|
33
|
+
modal.onDispose(() => $keysToStatus((keys) => {
|
|
34
|
+
keys.delete(modal.key);
|
|
35
|
+
return keys;
|
|
36
|
+
}));
|
|
36
37
|
modal.onDispose(watch($status, (status$1) => {
|
|
37
38
|
if (status$1 === "closed") onModalClosed(modal.key);
|
|
38
39
|
else if (status$1 === "closing") onModalClosing(modal.key);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monstermann/signals-modal",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "Composable modal management.",
|
|
6
6
|
"author": "Michael Ostermann <michaelostermann@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"release": "bun publish --access public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@monstermann/fn": "^0.4.
|
|
36
|
-
"@monstermann/signals": "^0.
|
|
37
|
-
"@monstermann/signals-web": "^0.2.
|
|
35
|
+
"@monstermann/fn": "^0.4.4",
|
|
36
|
+
"@monstermann/signals": "^0.2.0",
|
|
37
|
+
"@monstermann/signals-web": "^0.2.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@monstermann/unplugin-fn": "^0.4.
|
|
41
|
-
"@monstermann/unplugin-signals": "^0.
|
|
40
|
+
"@monstermann/unplugin-fn": "^0.4.4",
|
|
41
|
+
"@monstermann/unplugin-signals": "^0.2.0"
|
|
42
42
|
}
|
|
43
43
|
}
|