@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.
@@ -1,65 +1,76 @@
1
- import { createComponent as f, insert as g, effect as k, className as q, setAttribute as M, memo as I, template as E, delegateEvents as F } from "solid-js/web";
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 { useContext as T, For as p, Show as L, createSignal as D, onMount as A, onCleanup as R, createContext as P, createMemo as _ } from "solid-js";
4
- import { SurfaceFloatingLayer as K } from "./SurfaceFloatingLayer.js";
5
- import { handleMenuKeyboardNavigation as N } from "./menuUtils.js";
6
- var B = /* @__PURE__ */ E("<button type=button role=menuitem><span>"), z = /* @__PURE__ */ E("<span aria-hidden=true>"), O = /* @__PURE__ */ E("<button type=button role=menuitem class=floe-context-action><span>");
7
- const y = P(), V = () => T(y);
8
- function W(n) {
9
- let c, m, i;
10
- const r = /* @__PURE__ */ new Set(), [e, o] = D(), s = () => {
11
- const t = c;
12
- return c = void 0, m = void 0, i = void 0, t;
13
- }, a = (t) => {
14
- if (n.enabled === !1 || t.defaultPrevented || t instanceof KeyboardEvent && t.key !== "ContextMenu" && !(t.shiftKey && t.key === "F10")) return;
15
- const l = t.composedPath().find((b) => b instanceof HTMLElement);
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 v = l.getBoundingClientRect(), u = t instanceof MouseEvent && (t.clientX !== 0 || t.clientY !== 0), h = l instanceof HTMLInputElement || l instanceof HTMLTextAreaElement ? l instanceof HTMLInputElement && l.type === "password" ? "" : l.value.slice(l.selectionStart ?? 0, l.selectionEnd ?? 0) : (() => {
18
- const b = document.getSelection();
19
- return b?.rangeCount && b.getRangeAt(0).intersectsNode(l) ? b.toString() : "";
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: u ? t.clientX : v.left + 8,
23
- y: u ? t.clientY : v.bottom,
24
- selection: h
25
- }, C = n.actions(w), x = {
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: C
38
+ actions: y
28
39
  }, $ = {
29
40
  origin: w,
30
- actions: [...C, ...n.editing ? Y(w, n.editing.labels, n.editing.onError) : []]
41
+ actions: [...y, ...e.editing ? j(w, e.editing.labels, e.editing.onError) : []]
31
42
  };
32
43
  if (!x.actions.length) return;
33
- c = x, m = t, i = $;
44
+ i = x, a = n, r = $;
34
45
  const S = setTimeout(() => {
35
- c === x && (c = void 0, m = void 0, i = void 0), r.delete(S);
46
+ i === x && (i = void 0, a = void 0, r = void 0), c.delete(S);
36
47
  }, 0);
37
- r.add(S);
38
- }, d = (t) => {
39
- c && m === t && !t.defaultPrevented && (t.preventDefault(), o(i), s());
48
+ c.add(S);
49
+ }, m = (n) => {
50
+ i && a === n && !n.defaultPrevented && (n.preventDefault(), o(r), u());
40
51
  };
41
- return A(() => {
42
- document.addEventListener("contextmenu", a, !0), document.addEventListener("keydown", a, !0), window.addEventListener("contextmenu", d), window.addEventListener("keydown", d), R(() => {
43
- r.forEach(clearTimeout), c = void 0, m = void 0, i = void 0, document.removeEventListener("contextmenu", a, !0), document.removeEventListener("keydown", a, !0), window.removeEventListener("contextmenu", d), window.removeEventListener("keydown", d);
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(y.Provider, {
56
+ }), f(C.Provider, {
46
57
  value: {
47
- claim: s,
48
- resolve: (t) => n.enabled === !1 ? [] : n.actions(t)
58
+ claim: u,
59
+ resolve: (n) => e.enabled === !1 ? [] : e.actions(n)
49
60
  },
50
61
  get children() {
51
- return [I(() => n.children), f(L, {
62
+ return [q(() => e.children), f(T, {
52
63
  get when() {
53
- return e();
64
+ return t();
54
65
  },
55
66
  keyed: !0,
56
- children: (t) => f(X, {
57
- request: t,
67
+ children: (n) => f(Y, {
68
+ request: n,
58
69
  get label() {
59
- return n.label;
70
+ return e.label;
60
71
  },
61
72
  get zIndex() {
62
- return n.zIndex;
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 Z(n) {
71
- const c = T(y)?.claim(), m = () => c?.actions.filter((i) => !n.excludeIds?.includes(i.id)) ?? [];
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 m();
85
+ return a();
75
86
  },
76
- children: (i) => (() => {
77
- var r = B(), e = r.firstChild;
78
- return r.$$click = () => {
79
- n.onClose(), i.onSelect();
80
- }, g(r, f(L, {
81
- get when() {
82
- return i.icon;
83
- },
84
- children: (o) => (() => {
85
- var s = z();
86
- return g(s, () => o()()), s;
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
- }), r;
102
+ }), c;
96
103
  })()
97
104
  });
98
105
  }
99
- function X(n) {
100
- let c;
101
- const m = H(() => c), i = _(() => {
102
- if (!m() || !c) return {
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 + n.request.actions.length * 30
111
+ height: 8 + e.request.actions.length * 30
105
112
  };
106
- const e = c.getBoundingClientRect();
113
+ const t = i.getBoundingClientRect();
107
114
  return {
108
- width: e.width,
109
- height: e.height
115
+ width: t.width,
116
+ height: t.height
110
117
  };
111
- }), r = (e = !1) => {
112
- n.onClose(), e && n.request.origin.target.isConnected && n.request.origin.target.focus({
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 A(() => {
117
- c.querySelector('[role="menuitem"]:not(:disabled)')?.focus({
123
+ return R(() => {
124
+ i.querySelector('[role="menuitem"]:not(:disabled)')?.focus({
118
125
  preventScroll: !0
119
126
  });
120
- const e = (s) => {
121
- s.target instanceof Node && !c.contains(s.target) && r();
122
- }, o = () => r();
123
- document.addEventListener("pointerdown", e, !0), document.addEventListener("focusin", e, !0), document.addEventListener("scroll", e, !0), window.addEventListener("resize", o), window.addEventListener("blur", o), R(() => {
124
- document.removeEventListener("pointerdown", e, !0), document.removeEventListener("focusin", e, !0), document.removeEventListener("scroll", e, !0), window.removeEventListener("resize", o), window.removeEventListener("blur", o);
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(K, {
133
+ }), f(N, {
127
134
  get owner() {
128
- return n.request.origin.target;
135
+ return e.request.origin.target;
129
136
  },
130
137
  get position() {
131
- return n.request.origin;
138
+ return e.request.origin;
132
139
  },
133
140
  get estimatedSize() {
134
- return i();
141
+ return r();
135
142
  },
136
143
  role: "menu",
137
144
  get "aria-label"() {
138
- return n.label;
145
+ return e.label;
139
146
  },
140
- layerRef: (e) => {
141
- c = e;
147
+ layerRef: (t) => {
148
+ i = t;
142
149
  },
143
150
  class: "floe-context-actions",
144
151
  get style() {
145
152
  return {
146
- "z-index": n.zIndex
153
+ "z-index": e.zIndex
147
154
  };
148
155
  },
149
- onContextMenu: (e) => e.preventDefault(),
150
- onKeyDown: (e) => N(e, {
156
+ onContextMenu: (t) => t.preventDefault(),
157
+ onKeyDown: (t) => _(t, {
151
158
  onActivate: (o) => o.click(),
152
- onDismiss: () => r(!0),
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 n.request.actions;
165
+ return e.request.actions;
159
166
  },
160
- children: (e) => (() => {
161
- var o = O(), s = o.firstChild;
167
+ children: (t) => (() => {
168
+ var o = X(), u = o.firstChild;
162
169
  return o.$$click = () => {
163
- r(), e.onSelect();
164
- }, g(o, f(L, {
165
- get when() {
166
- return e.icon;
167
- },
168
- children: (a) => (() => {
169
- var d = z();
170
- return g(d, () => a()()), d;
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 Y(n, c, m) {
185
- const i = n.target.closest('input, textarea, [contenteditable]:not([contenteditable="false"])'), r = i instanceof HTMLInputElement || i instanceof HTMLTextAreaElement ? i : null, e = document.getSelection()?.rangeCount ? document.getSelection().getRangeAt(0).cloneRange() : void 0, o = r?.selectionStart, s = r?.selectionEnd, a = () => {
186
- if (i?.focus({
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
- }), r && o != null && s != null) r.setSelectionRange(o, s);
189
- else if (e) {
190
- const u = document.getSelection();
191
- u?.removeAllRanges(), u?.addRange(e);
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
- }, d = (u) => () => {
196
+ }, m = (d) => () => {
194
197
  try {
195
- Promise.resolve(u()).catch(m);
196
- } catch (h) {
197
- m(h);
198
+ Promise.resolve(d()).catch(a);
199
+ } catch (v) {
200
+ a(v);
198
201
  }
199
- }, t = (u) => ({
200
- id: `edit.${u}`,
201
- label: c[u],
202
- onSelect: d(async () => {
203
- if (a(), u === "selectAll" && r) {
204
- r.select();
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(u) || u !== "paste") return;
208
- const h = await navigator.clipboard.readText();
209
- if (i?.isConnected && (a(), !document.execCommand("insertText", !1, h)))
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
- i && l.push(t("undo"), t("redo"), t("cut")), n.selection && l.push({
216
+ r && l.push(n("undo"), n("redo"), n("cut")), e.selection && l.push({
214
217
  id: "edit.copy",
215
- label: c.copy,
216
- onSelect: d(() => navigator.clipboard.writeText(n.selection))
217
- }), i && l.push(t("paste"), t("selectAll"));
218
- const v = n.target.closest("a[href]");
219
- if (v && ["http:", "https:", "mailto:"].includes(v.protocol)) {
220
- const u = v.href;
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: c.openLink,
224
- onSelect: () => window.open(u, "_blank", "noopener,noreferrer")
226
+ label: i.openLink,
227
+ onSelect: () => window.open(d, "_blank", "noopener,noreferrer")
225
228
  }), l.push({
226
229
  id: "link.copy",
227
- label: c.copyLink,
228
- onSelect: d(() => navigator.clipboard.writeText(u))
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
- Z as ContextMenuActionItems,
236
- W as ContextMenuActions,
237
- V as useContextMenuActions
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 C, 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, untrack 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 E } from "./dialogSurfaceScope.js";
7
- function se(L) {
8
- const [o, H] = N(L, ["anchor", "revision", "topOffset", "reservedSpace", "placement", "gap", "children", "class", "style", "layerRef", "onAnchorDisconnect"]), [A, $] = f(!1), [k, q] = f({
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
- }), [B, V] = f("above"), [F, v] = f(!1), [Y, D] = f(480), [O, T] = f();
11
+ }), [V, Y] = f("above"), [A, v] = f(!1), [D, T] = f(480), [F, W] = f();
12
12
  let m, w = !1;
13
- const [P, W] = f({
13
+ const [O, X] = f({
14
14
  x: 0,
15
15
  y: 0
16
- }), [j, G] = f(0), S = () => {
16
+ }), [j, G] = f(0), P = () => {
17
17
  m = void 0;
18
- const n = o.anchor, l = O();
18
+ const n = e.anchor, l = F();
19
19
  if (!n || !l) return;
20
20
  if (!n.isConnected) {
21
- v(!1), w || o.onAnchorDisconnect?.(), w = !0;
21
+ v(!1), w || e.onAnchorDisconnect?.(), w = !0;
22
22
  return;
23
23
  }
24
24
  w = !1;
25
- const t = _(E({
25
+ const o = et(L({
26
26
  owner: n
27
27
  }));
28
- if (!t) {
28
+ if (!o) {
29
29
  v(!1);
30
30
  return;
31
31
  }
32
- const e = n.getBoundingClientRect(), s = o.reservedSpace, d = t.top + (window.matchMedia("(max-width:760px)").matches ? s?.narrowTop ?? s?.top ?? 12 : s?.top ?? 12);
33
- D(Math.max(120, t.width - 24)), G(Math.max(0, t.bottom - (s?.bottom ?? 12) - d));
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), u = x - r.height - i, y = Math.max(d, t.bottom - (s?.bottom ?? 12) - r.height), g = (b) => Math.max(d, Math.min(b, y));
37
- let c = u, a = "above";
38
- if (o.placement === "right" || o.placement === "left") {
39
- const b = e.right + i + r.width <= t.right - 12, z = e.left - i - r.width >= t.left + 12;
40
- a = o.placement, a === "right" && !b && z ? a = "left" : a === "left" && !z && 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 = g(e.top + e.height / 2 - r.height / 2);
41
- } else u < d ? e.bottom + i <= y ? (c = e.bottom + i, a = "below") : u >= 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 = g(x), a = "right") : e.left - r.width - i - 12 >= t.left ? (p = e.left - r.width - i, c = g(x), a = "left") : (c = g(u), a = "edge") : c = Math.min(c, y);
42
- W({
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
- }), V(a), q({
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(e.right > t.left && e.left < t.right && e.bottom > t.top && e.top < t.bottom);
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(S));
50
+ m === void 0 && typeof requestAnimationFrame == "function" && (m = requestAnimationFrame(P));
51
51
  };
52
52
  return M(() => {
53
- o.anchor, o.revision, o.topOffset, o.reservedSpace, o.placement, o.gap, h();
53
+ e.anchor, e.revision, e.topOffset, e.reservedSpace, e.placement, e.align, e.gap, h();
54
54
  }), M(() => {
55
- const n = O();
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
- }), Q(() => $(!0)), M(() => {
60
- if (!A()) return;
61
- const n = o.anchor, l = typeof ResizeObserver == "function" ? new ResizeObserver(h) : void 0, t = E({
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
- t && l?.observe(t), n && l?.observe(n);
65
- const e = new MutationObserver(h);
66
- n && e.observe(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 && (e.observe(s, {
71
+ for (; s && (t.observe(s, {
72
72
  attributes: !0,
73
73
  attributeFilter: ["style"],
74
74
  childList: !0
75
- }), s !== t); )
75
+ }), s !== o); )
76
76
  s = s.parentElement;
77
- const d = ee(window, h);
77
+ const d = ot(window, h);
78
78
  window.addEventListener("scroll", h, !0), h(), R(() => {
79
- l?.disconnect(), e.disconnect(), d(), window.removeEventListener("scroll", h, !0);
79
+ l?.disconnect(), t.disconnect(), d(), window.removeEventListener("scroll", h, !0);
80
80
  });
81
81
  }), R(() => {
82
82
  m !== void 0 && cancelAnimationFrame(m);
83
- }), C(U, {
83
+ }), E(Z, {
84
84
  get when() {
85
- return K(() => !!A())() && o.anchor;
85
+ return N(() => !!S())() && e.anchor;
86
86
  },
87
87
  get children() {
88
- return C(Z, J(H, {
88
+ return E(tt, K($, {
89
89
  get owner() {
90
- return o.anchor;
90
+ return e.anchor;
91
91
  },
92
92
  get position() {
93
- return k();
93
+ return q();
94
94
  },
95
95
  get class() {
96
- return o.class;
96
+ return e.class;
97
97
  },
98
98
  get "data-placement"() {
99
- return B();
99
+ return V();
100
100
  },
101
101
  get inert() {
102
- return !F();
102
+ return !A();
103
103
  },
104
104
  get style() {
105
105
  return {
106
- ...o.style,
107
- "--floe-anchored-layer-anchor-x": `${P().x}px`,
108
- "--floe-anchored-layer-anchor-y": `${P().y}px`,
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: F() ? "visible" : "hidden",
111
- "max-width": `${Y()}px`,
112
- "z-index": o.style?.["z-index"] ?? 60
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
- T(n), o.layerRef?.(n), queueMicrotask(() => X(() => {
117
- n.isConnected && (m !== void 0 && cancelAnimationFrame(m), S());
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 o.children;
121
+ return e.children;
122
122
  }
123
123
  }));
124
124
  }
125
125
  });
126
126
  }
127
127
  export {
128
- se as SurfaceAnchoredLayer
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
  };