@floegence/floe-webapp-core 0.89.1 → 0.89.2
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.
|
@@ -1,120 +1,119 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
import { splitProps as
|
|
3
|
-
import { SurfaceFloatingLayer as
|
|
4
|
-
import { resolveFloatingBoundary as
|
|
5
|
-
import { observeViewport as
|
|
6
|
-
import { resolveSurfacePortalHost as
|
|
7
|
-
function
|
|
8
|
-
const [o,
|
|
1
|
+
import { createComponent as F, mergeProps as J, memo as K } from "solid-js/web";
|
|
2
|
+
import { splitProps as N, createSignal as f, createEffect as M, onCleanup as R, onMount as Q, Show as U } from "solid-js";
|
|
3
|
+
import { SurfaceFloatingLayer as X } from "./SurfaceFloatingLayer.js";
|
|
4
|
+
import { resolveFloatingBoundary as Z } from "./surfaceFloatingBoundary.js";
|
|
5
|
+
import { observeViewport as _ } from "../../viewport.js";
|
|
6
|
+
import { resolveSurfacePortalHost as E } from "./dialogSurfaceScope.js";
|
|
7
|
+
function ae(L) {
|
|
8
|
+
const [o, C] = N(L, ["anchor", "revision", "topOffset", "reservedSpace", "placement", "gap", "children", "class", "style", "layerRef", "onAnchorDisconnect"]), [O, H] = f(!1), [$, B] = f({
|
|
9
9
|
x: 0,
|
|
10
10
|
y: 0
|
|
11
|
-
}), [
|
|
12
|
-
let
|
|
13
|
-
const [
|
|
11
|
+
}), [V, Y] = f("above"), [P, v] = f(!1), [q, D] = f(480), [S, k] = f();
|
|
12
|
+
let d, w = !1;
|
|
13
|
+
const [z, T] = f({
|
|
14
14
|
x: 0,
|
|
15
15
|
y: 0
|
|
16
|
-
}), [
|
|
17
|
-
|
|
18
|
-
const n = o.anchor,
|
|
19
|
-
if (!n || !
|
|
16
|
+
}), [W, j] = f(0), G = () => {
|
|
17
|
+
d = void 0;
|
|
18
|
+
const n = o.anchor, l = S();
|
|
19
|
+
if (!n || !l) return;
|
|
20
20
|
if (!n.isConnected) {
|
|
21
|
-
|
|
21
|
+
v(!1), w || o.onAnchorDisconnect?.(), w = !0;
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
const t =
|
|
24
|
+
w = !1;
|
|
25
|
+
const t = Z(E({
|
|
26
26
|
owner: n
|
|
27
27
|
}));
|
|
28
28
|
if (!t) {
|
|
29
|
-
|
|
29
|
+
v(!1);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const e = n.getBoundingClientRect(),
|
|
33
|
-
|
|
34
|
-
const r =
|
|
35
|
-
let
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
let s = g, a = "above";
|
|
32
|
+
const e = n.getBoundingClientRect(), s = o.reservedSpace, m = t.top + (window.matchMedia("(max-width:760px)").matches ? s?.narrowTop ?? s?.top ?? 12 : s?.top ?? 12);
|
|
33
|
+
D(Math.max(120, t.width - 24)), j(Math.max(0, t.bottom - (s?.bottom ?? 12) - m));
|
|
34
|
+
const r = l.getBoundingClientRect(), I = (Math.max(t.left, e.left) + Math.min(t.right, e.right)) / 2;
|
|
35
|
+
let p = Math.max(t.left + 12, Math.min(I - r.width / 2, t.right - r.width - 12));
|
|
36
|
+
const x = e.top - (o.topOffset ?? 0), i = Math.max(0, o.gap ?? 12), g = x - r.height - i, y = Math.max(m, t.bottom - (s?.bottom ?? 12) - r.height), u = (b) => Math.max(m, Math.min(b, y));
|
|
37
|
+
let c = g, a = "above";
|
|
39
38
|
if (o.placement === "right" || o.placement === "left") {
|
|
40
|
-
const
|
|
41
|
-
a = o.placement, a === "right" && !
|
|
42
|
-
} else g <
|
|
39
|
+
const b = e.right + i + r.width <= t.right - 12, A = e.left - i - r.width >= t.left + 12;
|
|
40
|
+
a = o.placement, a === "right" && !b && A ? a = "left" : a === "left" && !A && b && (a = "right"), p = Math.max(t.left + 12, Math.min(a === "right" ? e.right + i : e.left - r.width - i, t.right - r.width - 12)), c = u(e.top + e.height / 2 - r.height / 2);
|
|
41
|
+
} else g < m ? e.bottom + i <= y ? (c = e.bottom + i, a = "below") : g >= t.top + 12 ? a = "above" : e.bottom + r.height + i <= t.bottom - 12 ? (c = e.bottom + i, a = "below") : e.right + r.width + i + 12 <= t.right ? (p = e.right + i, c = u(x), a = "right") : e.left - r.width - i - 12 >= t.left ? (p = e.left - r.width - i, c = u(x), a = "left") : (c = u(g), a = "edge") : c = Math.min(c, y);
|
|
43
42
|
T({
|
|
44
|
-
x: Math.max(18, Math.min(e.left + e.width / 2 -
|
|
45
|
-
y: Math.max(18, Math.min(e.top + e.height / 2 -
|
|
46
|
-
}),
|
|
47
|
-
x: Math.round(
|
|
48
|
-
y: Math.round(
|
|
49
|
-
}),
|
|
50
|
-
},
|
|
51
|
-
|
|
43
|
+
x: Math.max(18, Math.min(e.left + e.width / 2 - p, Math.max(18, r.width - 18))),
|
|
44
|
+
y: Math.max(18, Math.min(e.top + e.height / 2 - c, Math.max(18, r.height - 18)))
|
|
45
|
+
}), Y(a), B({
|
|
46
|
+
x: Math.round(p),
|
|
47
|
+
y: Math.round(c)
|
|
48
|
+
}), v(e.right > t.left && e.left < t.right && e.bottom > t.top && e.top < t.bottom);
|
|
49
|
+
}, h = () => {
|
|
50
|
+
d === void 0 && typeof requestAnimationFrame == "function" && (d = requestAnimationFrame(G));
|
|
52
51
|
};
|
|
53
|
-
return
|
|
54
|
-
o.anchor, o.revision, o.topOffset, o.reservedSpace, o.placement, o.gap,
|
|
55
|
-
}),
|
|
56
|
-
const n =
|
|
52
|
+
return M(() => {
|
|
53
|
+
o.anchor, o.revision, o.topOffset, o.reservedSpace, o.placement, o.gap, h();
|
|
54
|
+
}), M(() => {
|
|
55
|
+
const n = S();
|
|
57
56
|
if (!n || typeof ResizeObserver > "u") return;
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
if (!
|
|
62
|
-
const n = o.anchor,
|
|
57
|
+
const l = new ResizeObserver(h);
|
|
58
|
+
l.observe(n), R(() => l.disconnect());
|
|
59
|
+
}), Q(() => H(!0)), M(() => {
|
|
60
|
+
if (!O()) return;
|
|
61
|
+
const n = o.anchor, l = typeof ResizeObserver == "function" ? new ResizeObserver(h) : void 0, t = E({
|
|
63
62
|
owner: n
|
|
64
63
|
}).boundaryHost;
|
|
65
|
-
t &&
|
|
66
|
-
const e = new MutationObserver(
|
|
64
|
+
t && l?.observe(t), n && l?.observe(n);
|
|
65
|
+
const e = new MutationObserver(h);
|
|
67
66
|
n && e.observe(n, {
|
|
68
67
|
attributes: !0,
|
|
69
68
|
attributeFilter: ["style"]
|
|
70
69
|
});
|
|
71
|
-
let
|
|
72
|
-
for (;
|
|
70
|
+
let s = n?.parentElement;
|
|
71
|
+
for (; s && (e.observe(s, {
|
|
73
72
|
attributes: !0,
|
|
74
73
|
attributeFilter: ["style"],
|
|
75
74
|
childList: !0
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
window.addEventListener("scroll",
|
|
80
|
-
|
|
75
|
+
}), s !== t); )
|
|
76
|
+
s = s.parentElement;
|
|
77
|
+
const m = _(window, h);
|
|
78
|
+
window.addEventListener("scroll", h, !0), h(), R(() => {
|
|
79
|
+
l?.disconnect(), e.disconnect(), m(), window.removeEventListener("scroll", h, !0);
|
|
81
80
|
});
|
|
82
|
-
}),
|
|
83
|
-
|
|
84
|
-
}),
|
|
81
|
+
}), R(() => {
|
|
82
|
+
d !== void 0 && cancelAnimationFrame(d);
|
|
83
|
+
}), F(U, {
|
|
85
84
|
get when() {
|
|
86
|
-
return
|
|
85
|
+
return K(() => !!O())() && o.anchor;
|
|
87
86
|
},
|
|
88
87
|
get children() {
|
|
89
|
-
return
|
|
88
|
+
return F(X, J(C, {
|
|
90
89
|
get owner() {
|
|
91
90
|
return o.anchor;
|
|
92
91
|
},
|
|
93
92
|
get position() {
|
|
94
|
-
return
|
|
93
|
+
return $();
|
|
95
94
|
},
|
|
96
95
|
get class() {
|
|
97
96
|
return o.class;
|
|
98
97
|
},
|
|
99
98
|
get "data-placement"() {
|
|
100
|
-
return
|
|
99
|
+
return V();
|
|
101
100
|
},
|
|
102
101
|
get inert() {
|
|
103
|
-
return !
|
|
102
|
+
return !P();
|
|
104
103
|
},
|
|
105
104
|
get style() {
|
|
106
105
|
return {
|
|
107
106
|
...o.style,
|
|
108
|
-
"--floe-anchored-layer-anchor-x": `${
|
|
109
|
-
"--floe-anchored-layer-anchor-y": `${
|
|
110
|
-
"--floe-anchored-layer-max-height": `${
|
|
111
|
-
visibility:
|
|
112
|
-
"max-width": `${
|
|
107
|
+
"--floe-anchored-layer-anchor-x": `${z().x}px`,
|
|
108
|
+
"--floe-anchored-layer-anchor-y": `${z().y}px`,
|
|
109
|
+
"--floe-anchored-layer-max-height": `${W()}px`,
|
|
110
|
+
visibility: P() ? "visible" : "hidden",
|
|
111
|
+
"max-width": `${q()}px`,
|
|
113
112
|
"z-index": o.style?.["z-index"] ?? 60
|
|
114
113
|
};
|
|
115
114
|
},
|
|
116
115
|
layerRef: (n) => {
|
|
117
|
-
k(n), o.layerRef?.(n),
|
|
116
|
+
k(n), o.layerRef?.(n), h();
|
|
118
117
|
},
|
|
119
118
|
get children() {
|
|
120
119
|
return o.children;
|
|
@@ -124,5 +123,5 @@ function se(C) {
|
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
export {
|
|
127
|
-
|
|
126
|
+
ae as SurfaceAnchoredLayer
|
|
128
127
|
};
|