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