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