@floegence/floe-webapp-core 0.96.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.
- package/dist/components/notes/useNotesOverlayModel.d.ts +3 -1
- package/dist/components/notes/useNotesOverlayModel.js +63 -63
- package/dist/components/ui/ContextMenuActions.d.ts +5 -0
- package/dist/components/ui/ContextMenuActions.js +140 -136
- package/dist/components/ui/SurfaceAnchoredLayer.d.ts +2 -0
- package/dist/components/ui/SurfaceAnchoredLayer.js +61 -61
- package/dist/components/ui/contextSource.d.ts +7 -1
- package/dist/components/ui/contextSource.js +54 -31
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/workbench/WorkbenchSurface.js +48 -45
- package/dist/full.js +572 -571
- package/dist/styles.css +1 -1
- package/dist/ui.css +11 -1
- package/dist/ui.js +178 -177
- package/package.json +1 -1
|
@@ -1,65 +1,76 @@
|
|
|
1
|
-
import { createComponent as f, insert as
|
|
1
|
+
import { createComponent as f, insert as b, effect as E, className as k, setAttribute as M, memo as q, template as L, delegateEvents as F } from "solid-js/web";
|
|
2
2
|
import { useResizeObserver as H } from "../../hooks/useResizeObserver.js";
|
|
3
|
-
import {
|
|
4
|
-
import { SurfaceFloatingLayer as
|
|
5
|
-
import { handleMenuKeyboardNavigation as
|
|
6
|
-
var B = /* @__PURE__ */
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { Show as T, useContext as A, For as p, createSignal as D, onMount as R, onCleanup as z, createContext as P, createMemo as K } from "solid-js";
|
|
4
|
+
import { SurfaceFloatingLayer as N } from "./SurfaceFloatingLayer.js";
|
|
5
|
+
import { handleMenuKeyboardNavigation as _ } from "./menuUtils.js";
|
|
6
|
+
var B = /* @__PURE__ */ L("<span aria-hidden=true>"), O = /* @__PURE__ */ L("<button type=button role=menuitem><span>"), X = /* @__PURE__ */ L("<button type=button role=menuitem class=floe-context-action><span>");
|
|
7
|
+
const C = P(), W = () => A(C);
|
|
8
|
+
function I(e) {
|
|
9
|
+
return f(T, {
|
|
10
|
+
get when() {
|
|
11
|
+
return e.icon;
|
|
12
|
+
},
|
|
13
|
+
children: (i) => (() => {
|
|
14
|
+
var a = B();
|
|
15
|
+
return b(a, () => i()()), E(() => k(a, `floe-context-action-icon ${e.class ?? ""}`)), a;
|
|
16
|
+
})()
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function Z(e) {
|
|
20
|
+
let i, a, r;
|
|
21
|
+
const c = /* @__PURE__ */ new Set(), [t, o] = D(), u = () => {
|
|
22
|
+
const n = i;
|
|
23
|
+
return i = void 0, a = void 0, r = void 0, n;
|
|
24
|
+
}, s = (n) => {
|
|
25
|
+
if (e.enabled === !1 || n.defaultPrevented || n instanceof KeyboardEvent && n.key !== "ContextMenu" && !(n.shiftKey && n.key === "F10")) return;
|
|
26
|
+
const l = n.composedPath().find((h) => h instanceof HTMLElement);
|
|
16
27
|
if (!l || l.closest('[inert], [hidden], [role="menu"], [data-floe-context-menu-native]')) return;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
return
|
|
28
|
+
const g = l.getBoundingClientRect(), d = n instanceof MouseEvent && (n.clientX !== 0 || n.clientY !== 0), v = l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement ? l instanceof HTMLInputElement && l.type === "password" ? "" : l.value.slice(l.selectionStart ?? 0, l.selectionEnd ?? 0) : (() => {
|
|
29
|
+
const h = document.getSelection();
|
|
30
|
+
return h?.rangeCount && h.getRangeAt(0).intersectsNode(l) ? h.toString() : "";
|
|
20
31
|
})(), w = {
|
|
21
32
|
target: l,
|
|
22
|
-
x:
|
|
23
|
-
y:
|
|
24
|
-
selection:
|
|
25
|
-
},
|
|
33
|
+
x: d ? n.clientX : g.left + 8,
|
|
34
|
+
y: d ? n.clientY : g.bottom,
|
|
35
|
+
selection: v
|
|
36
|
+
}, y = e.actions(w), x = {
|
|
26
37
|
origin: w,
|
|
27
|
-
actions:
|
|
38
|
+
actions: y
|
|
28
39
|
}, $ = {
|
|
29
40
|
origin: w,
|
|
30
|
-
actions: [...
|
|
41
|
+
actions: [...y, ...e.editing ? j(w, e.editing.labels, e.editing.onError) : []]
|
|
31
42
|
};
|
|
32
43
|
if (!x.actions.length) return;
|
|
33
|
-
|
|
44
|
+
i = x, a = n, r = $;
|
|
34
45
|
const S = setTimeout(() => {
|
|
35
|
-
|
|
46
|
+
i === x && (i = void 0, a = void 0, r = void 0), c.delete(S);
|
|
36
47
|
}, 0);
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
|
|
48
|
+
c.add(S);
|
|
49
|
+
}, m = (n) => {
|
|
50
|
+
i && a === n && !n.defaultPrevented && (n.preventDefault(), o(r), u());
|
|
40
51
|
};
|
|
41
|
-
return
|
|
42
|
-
document.addEventListener("contextmenu",
|
|
43
|
-
|
|
52
|
+
return R(() => {
|
|
53
|
+
document.addEventListener("contextmenu", s, !0), document.addEventListener("keydown", s, !0), window.addEventListener("contextmenu", m), window.addEventListener("keydown", m), z(() => {
|
|
54
|
+
c.forEach(clearTimeout), i = void 0, a = void 0, r = void 0, document.removeEventListener("contextmenu", s, !0), document.removeEventListener("keydown", s, !0), window.removeEventListener("contextmenu", m), window.removeEventListener("keydown", m);
|
|
44
55
|
});
|
|
45
|
-
}), f(
|
|
56
|
+
}), f(C.Provider, {
|
|
46
57
|
value: {
|
|
47
|
-
claim:
|
|
48
|
-
resolve: (
|
|
58
|
+
claim: u,
|
|
59
|
+
resolve: (n) => e.enabled === !1 ? [] : e.actions(n)
|
|
49
60
|
},
|
|
50
61
|
get children() {
|
|
51
|
-
return [
|
|
62
|
+
return [q(() => e.children), f(T, {
|
|
52
63
|
get when() {
|
|
53
|
-
return
|
|
64
|
+
return t();
|
|
54
65
|
},
|
|
55
66
|
keyed: !0,
|
|
56
|
-
children: (
|
|
57
|
-
request:
|
|
67
|
+
children: (n) => f(Y, {
|
|
68
|
+
request: n,
|
|
58
69
|
get label() {
|
|
59
|
-
return
|
|
70
|
+
return e.label;
|
|
60
71
|
},
|
|
61
72
|
get zIndex() {
|
|
62
|
-
return
|
|
73
|
+
return e.zIndex;
|
|
63
74
|
},
|
|
64
75
|
onClose: () => o(void 0)
|
|
65
76
|
})
|
|
@@ -67,111 +78,103 @@ function W(n) {
|
|
|
67
78
|
}
|
|
68
79
|
});
|
|
69
80
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
81
|
+
function ee(e) {
|
|
82
|
+
const i = A(C)?.claim(), a = () => i?.actions.filter((r) => !e.excludeIds?.includes(r.id)) ?? [];
|
|
72
83
|
return f(p, {
|
|
73
84
|
get each() {
|
|
74
|
-
return
|
|
85
|
+
return a();
|
|
75
86
|
},
|
|
76
|
-
children: (
|
|
77
|
-
var
|
|
78
|
-
return
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
get
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
})()
|
|
88
|
-
}), e), g(e, () => i.label), k((o) => {
|
|
89
|
-
var s = n.itemClass ?? "floe-context-action", a = i.id, d = i.disabled;
|
|
90
|
-
return s !== o.e && q(r, o.e = s), a !== o.t && M(r, "data-context-action-id", o.t = a), d !== o.a && (r.disabled = o.a = d), o;
|
|
87
|
+
children: (r) => (() => {
|
|
88
|
+
var c = O(), t = c.firstChild;
|
|
89
|
+
return c.$$click = () => {
|
|
90
|
+
e.onClose(), r.onSelect();
|
|
91
|
+
}, b(c, f(I, {
|
|
92
|
+
get icon() {
|
|
93
|
+
return r.icon;
|
|
94
|
+
}
|
|
95
|
+
}), t), b(t, () => r.label), E((o) => {
|
|
96
|
+
var u = e.itemClass ?? "floe-context-action", s = r.id, m = r.disabled;
|
|
97
|
+
return u !== o.e && k(c, o.e = u), s !== o.t && M(c, "data-context-action-id", o.t = s), m !== o.a && (c.disabled = o.a = m), o;
|
|
91
98
|
}, {
|
|
92
99
|
e: void 0,
|
|
93
100
|
t: void 0,
|
|
94
101
|
a: void 0
|
|
95
|
-
}),
|
|
102
|
+
}), c;
|
|
96
103
|
})()
|
|
97
104
|
});
|
|
98
105
|
}
|
|
99
|
-
function
|
|
100
|
-
let
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
106
|
+
function Y(e) {
|
|
107
|
+
let i;
|
|
108
|
+
const a = H(() => i), r = K(() => {
|
|
109
|
+
if (!a() || !i) return {
|
|
103
110
|
width: 208,
|
|
104
|
-
height: 8 +
|
|
111
|
+
height: 8 + e.request.actions.length * 30
|
|
105
112
|
};
|
|
106
|
-
const
|
|
113
|
+
const t = i.getBoundingClientRect();
|
|
107
114
|
return {
|
|
108
|
-
width:
|
|
109
|
-
height:
|
|
115
|
+
width: t.width,
|
|
116
|
+
height: t.height
|
|
110
117
|
};
|
|
111
|
-
}),
|
|
112
|
-
|
|
118
|
+
}), c = (t = !1) => {
|
|
119
|
+
e.onClose(), t && e.request.origin.target.isConnected && e.request.origin.target.focus({
|
|
113
120
|
preventScroll: !0
|
|
114
121
|
});
|
|
115
122
|
};
|
|
116
|
-
return
|
|
117
|
-
|
|
123
|
+
return R(() => {
|
|
124
|
+
i.querySelector('[role="menuitem"]:not(:disabled)')?.focus({
|
|
118
125
|
preventScroll: !0
|
|
119
126
|
});
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
}, o = () =>
|
|
123
|
-
document.addEventListener("pointerdown",
|
|
124
|
-
document.removeEventListener("pointerdown",
|
|
127
|
+
const t = (u) => {
|
|
128
|
+
u.target instanceof Node && !i.contains(u.target) && c();
|
|
129
|
+
}, o = () => c();
|
|
130
|
+
document.addEventListener("pointerdown", t, !0), document.addEventListener("focusin", t, !0), document.addEventListener("scroll", t, !0), window.addEventListener("resize", o), window.addEventListener("blur", o), z(() => {
|
|
131
|
+
document.removeEventListener("pointerdown", t, !0), document.removeEventListener("focusin", t, !0), document.removeEventListener("scroll", t, !0), window.removeEventListener("resize", o), window.removeEventListener("blur", o);
|
|
125
132
|
});
|
|
126
|
-
}), f(
|
|
133
|
+
}), f(N, {
|
|
127
134
|
get owner() {
|
|
128
|
-
return
|
|
135
|
+
return e.request.origin.target;
|
|
129
136
|
},
|
|
130
137
|
get position() {
|
|
131
|
-
return
|
|
138
|
+
return e.request.origin;
|
|
132
139
|
},
|
|
133
140
|
get estimatedSize() {
|
|
134
|
-
return
|
|
141
|
+
return r();
|
|
135
142
|
},
|
|
136
143
|
role: "menu",
|
|
137
144
|
get "aria-label"() {
|
|
138
|
-
return
|
|
145
|
+
return e.label;
|
|
139
146
|
},
|
|
140
|
-
layerRef: (
|
|
141
|
-
|
|
147
|
+
layerRef: (t) => {
|
|
148
|
+
i = t;
|
|
142
149
|
},
|
|
143
150
|
class: "floe-context-actions",
|
|
144
151
|
get style() {
|
|
145
152
|
return {
|
|
146
|
-
"z-index":
|
|
153
|
+
"z-index": e.zIndex
|
|
147
154
|
};
|
|
148
155
|
},
|
|
149
|
-
onContextMenu: (
|
|
150
|
-
onKeyDown: (
|
|
156
|
+
onContextMenu: (t) => t.preventDefault(),
|
|
157
|
+
onKeyDown: (t) => _(t, {
|
|
151
158
|
onActivate: (o) => o.click(),
|
|
152
|
-
onDismiss: () =>
|
|
159
|
+
onDismiss: () => c(!0),
|
|
153
160
|
preventDefaultOnTab: !0
|
|
154
161
|
}),
|
|
155
162
|
get children() {
|
|
156
163
|
return f(p, {
|
|
157
164
|
get each() {
|
|
158
|
-
return
|
|
165
|
+
return e.request.actions;
|
|
159
166
|
},
|
|
160
|
-
children: (
|
|
161
|
-
var o =
|
|
167
|
+
children: (t) => (() => {
|
|
168
|
+
var o = X(), u = o.firstChild;
|
|
162
169
|
return o.$$click = () => {
|
|
163
|
-
|
|
164
|
-
},
|
|
165
|
-
get
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
})()
|
|
172
|
-
}), s), g(s, () => e.label), k((a) => {
|
|
173
|
-
var d = e.id, t = e.disabled;
|
|
174
|
-
return d !== a.e && M(o, "data-context-action-id", a.e = d), t !== a.t && (o.disabled = a.t = t), a;
|
|
170
|
+
c(), t.onSelect();
|
|
171
|
+
}, b(o, f(I, {
|
|
172
|
+
get icon() {
|
|
173
|
+
return t.icon;
|
|
174
|
+
}
|
|
175
|
+
}), u), b(u, () => t.label), E((s) => {
|
|
176
|
+
var m = t.id, n = t.disabled;
|
|
177
|
+
return m !== s.e && M(o, "data-context-action-id", s.e = m), n !== s.t && (o.disabled = s.t = n), s;
|
|
175
178
|
}, {
|
|
176
179
|
e: void 0,
|
|
177
180
|
t: void 0
|
|
@@ -181,58 +184,59 @@ function X(n) {
|
|
|
181
184
|
}
|
|
182
185
|
});
|
|
183
186
|
}
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
+
function j(e, i, a) {
|
|
188
|
+
const r = e.target.closest('input, textarea, [contenteditable]:not([contenteditable="false"])'), c = r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement ? r : null, t = document.getSelection()?.rangeCount ? document.getSelection().getRangeAt(0).cloneRange() : void 0, o = c?.selectionStart, u = c?.selectionEnd, s = () => {
|
|
189
|
+
if (r?.focus({
|
|
187
190
|
preventScroll: !0
|
|
188
|
-
}),
|
|
189
|
-
else if (
|
|
190
|
-
const
|
|
191
|
-
|
|
191
|
+
}), c && o != null && u != null) c.setSelectionRange(o, u);
|
|
192
|
+
else if (t) {
|
|
193
|
+
const d = document.getSelection();
|
|
194
|
+
d?.removeAllRanges(), d?.addRange(t);
|
|
192
195
|
}
|
|
193
|
-
},
|
|
196
|
+
}, m = (d) => () => {
|
|
194
197
|
try {
|
|
195
|
-
Promise.resolve(
|
|
196
|
-
} catch (
|
|
197
|
-
|
|
198
|
+
Promise.resolve(d()).catch(a);
|
|
199
|
+
} catch (v) {
|
|
200
|
+
a(v);
|
|
198
201
|
}
|
|
199
|
-
},
|
|
200
|
-
id: `edit.${
|
|
201
|
-
label:
|
|
202
|
-
onSelect:
|
|
203
|
-
if (
|
|
204
|
-
|
|
202
|
+
}, n = (d) => ({
|
|
203
|
+
id: `edit.${d}`,
|
|
204
|
+
label: i[d],
|
|
205
|
+
onSelect: m(async () => {
|
|
206
|
+
if (s(), d === "selectAll" && c) {
|
|
207
|
+
c.select();
|
|
205
208
|
return;
|
|
206
209
|
}
|
|
207
|
-
if (document.execCommand(
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
+
if (document.execCommand(d) || d !== "paste") return;
|
|
211
|
+
const v = await navigator.clipboard.readText();
|
|
212
|
+
if (r?.isConnected && (s(), !document.execCommand("insertText", !1, v)))
|
|
210
213
|
throw new Error("Clipboard insertion is unavailable.");
|
|
211
214
|
})
|
|
212
215
|
}), l = [];
|
|
213
|
-
|
|
216
|
+
r && l.push(n("undo"), n("redo"), n("cut")), e.selection && l.push({
|
|
214
217
|
id: "edit.copy",
|
|
215
|
-
label:
|
|
216
|
-
onSelect:
|
|
217
|
-
}),
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
218
|
+
label: i.copy,
|
|
219
|
+
onSelect: m(() => navigator.clipboard.writeText(e.selection))
|
|
220
|
+
}), r && l.push(n("paste"), n("selectAll"));
|
|
221
|
+
const g = e.target.closest("a[href]");
|
|
222
|
+
if (g && ["http:", "https:", "mailto:"].includes(g.protocol)) {
|
|
223
|
+
const d = g.href;
|
|
221
224
|
l.push({
|
|
222
225
|
id: "link.open",
|
|
223
|
-
label:
|
|
224
|
-
onSelect: () => window.open(
|
|
226
|
+
label: i.openLink,
|
|
227
|
+
onSelect: () => window.open(d, "_blank", "noopener,noreferrer")
|
|
225
228
|
}), l.push({
|
|
226
229
|
id: "link.copy",
|
|
227
|
-
label:
|
|
228
|
-
onSelect:
|
|
230
|
+
label: i.copyLink,
|
|
231
|
+
onSelect: m(() => navigator.clipboard.writeText(d))
|
|
229
232
|
});
|
|
230
233
|
}
|
|
231
234
|
return l;
|
|
232
235
|
}
|
|
233
236
|
F(["click"]);
|
|
234
237
|
export {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
I as ContextMenuActionIcon,
|
|
239
|
+
ee as ContextMenuActionItems,
|
|
240
|
+
Z as ContextMenuActions,
|
|
241
|
+
W as useContextMenuActions
|
|
238
242
|
};
|
|
@@ -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
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export interface ContextSource<T> {
|
|
2
2
|
id: string;
|
|
3
3
|
element: HTMLElement;
|
|
4
|
-
read: () => T;
|
|
4
|
+
read: (target?: EventTarget | null) => T;
|
|
5
|
+
/** An unavailable inner owner remains a boundary; never substitute its parent. */
|
|
6
|
+
enabled?: () => boolean;
|
|
7
|
+
/** Navigation and chrome can be targets without becoming active reading sources. */
|
|
8
|
+
activateOnInteraction?: boolean;
|
|
5
9
|
}
|
|
6
10
|
export interface ContextSourceSnapshot<T> {
|
|
7
11
|
id: string;
|
|
@@ -21,5 +25,7 @@ export declare function createContextSourceRegistry<T>(doc: Document): {
|
|
|
21
25
|
/** Hosts may forward activation from their authenticated embedded channel. */
|
|
22
26
|
activate(id: string): void;
|
|
23
27
|
capture(target?: EventTarget | null): ContextSourceSnapshot<T> | undefined;
|
|
28
|
+
/** Explicit-target capture never inherits an unrelated or cached selection. */
|
|
29
|
+
captureTarget(target: EventTarget, selectedText?: string): ContextSourceSnapshot<T> | undefined;
|
|
24
30
|
dispose(): void;
|
|
25
31
|
};
|