@floegence/floe-webapp-core 0.101.47 → 0.101.50

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,111 +1,122 @@
1
- import { createComponent as u, Portal as we, use as ee, setAttribute as y, insert as c, spread as Ce, mergeProps as Se, effect as X, setStyleProperty as M, className as Me, template as D, delegateEvents as Ee } from "solid-js/web";
2
- import { createUniqueId as Pe, createSignal as z, onCleanup as te, createMemo as F, untrack as K, createEffect as U, Show as E } from "solid-js";
1
+ import { createComponent as f, Portal as we, use as te, setAttribute as x, insert as c, spread as Ce, mergeProps as Se, effect as U, setStyleProperty as P, className as Me, template as A, delegateEvents as Pe } from "solid-js/web";
2
+ import { createUniqueId as Ee, createSignal as z, onCleanup as ne, createMemo as F, untrack as j, createEffect as Q, Show as E } from "solid-js";
3
3
  import { useOverlayMask as ke } from "../../hooks/useOverlayMask.js";
4
4
  import { deferAfterPaint as ue } from "../../utils/defer.js";
5
5
  import { ensureSurfacePortalInteractionTracking as me, resolveSurfacePortalHost as $e, resolveSurfacePortalScale as De, resolveSurfacePortalBoundaryRect as Ae, projectSurfacePortalPosition as Le, readFreshInteractionSnapshot as he, resolveSurfacePortalMount as Te, isSurfacePortalMode as Oe } from "./dialogSurfaceScope.js";
6
6
  import { cn as fe } from "../../utils/cn.js";
7
7
  import { readViewportSnapshot as Ie, observeViewport as ze } from "../../viewport.js";
8
- import { X as Fe, Plus as Be, ArrowUp as He } from "../icons/index.js";
9
- import { Button as ne } from "./Button.js";
10
- import { Select as qe } from "./Select.js";
11
- import { createFloatingPresence as Re } from "./floatingPresence.js";
12
- var Ve = /* @__PURE__ */ D("<span class=floe-prompt-card-icon aria-hidden=true>"), _e = /* @__PURE__ */ D("<div class=floe-prompt-card-question>"), Ne = /* @__PURE__ */ D("<div class=floe-prompt-card-references>"), We = /* @__PURE__ */ D("<input type=file multiple hidden tabindex=-1>"), Xe = /* @__PURE__ */ D("<div class=floe-prompt-card-feedback>"), Ke = /* @__PURE__ */ D("<div class=floe-prompt-card-positioner><div role=dialog aria-modal=false tabindex=-1 data-floe-prompt-card data-floe-input-surface data-floe-surface=floating data-floe-local-interaction-surface=true><header class=floe-prompt-card-header><h2></h2></header><div><div class=floe-prompt-card-composer><div class=floe-prompt-card-field><textarea class=floe-prompt-card-input rows=2></textarea></div><div class=floe-prompt-card-actions><div class=floe-prompt-card-tools>");
13
- function Ue(t) {
8
+ import { X as Fe, Plus as Be, ArrowUp as Re } from "../icons/index.js";
9
+ import { Button as ae } from "./Button.js";
10
+ import { Select as He } from "./Select.js";
11
+ import { createFloatingPresence as qe } from "./floatingPresence.js";
12
+ import { avoidPromptCardRegions as Ve } from "./promptCardPlacement.js";
13
+ var _e = /* @__PURE__ */ A("<span class=floe-prompt-card-icon aria-hidden=true>"), Ne = /* @__PURE__ */ A("<div class=floe-prompt-card-question>"), We = /* @__PURE__ */ A("<div class=floe-prompt-card-references>"), Xe = /* @__PURE__ */ A("<input type=file multiple hidden tabindex=-1>"), Ke = /* @__PURE__ */ A("<div class=floe-prompt-card-feedback>"), Ue = /* @__PURE__ */ A("<div class=floe-prompt-card-positioner><div role=dialog aria-modal=false tabindex=-1 data-floe-prompt-card data-floe-input-surface data-floe-surface=floating data-floe-local-interaction-surface=true><header class=floe-prompt-card-header><h2></h2></header><div><div class=floe-prompt-card-composer><div class=floe-prompt-card-field><textarea class=floe-prompt-card-input rows=2></textarea></div><div class=floe-prompt-card-actions><div class=floe-prompt-card-tools>");
14
+ function je(t) {
14
15
  if (typeof document > "u") return null;
15
16
  me();
16
- const w = t ?? he()?.target ?? document.activeElement;
17
- if (!w?.isConnected || w === document.body || w === document.documentElement) return null;
18
- const P = w.getBoundingClientRect();
19
- return P.width > 0 && P.height > 0 ? {
20
- x: P.left,
21
- y: P.bottom
17
+ const y = t ?? he()?.target ?? document.activeElement;
18
+ if (!y?.isConnected || y === document.body || y === document.documentElement) return null;
19
+ const k = y.getBoundingClientRect();
20
+ return k.width > 0 && k.height > 0 ? {
21
+ x: k.left,
22
+ y: k.bottom
22
23
  } : null;
23
24
  }
24
- function it(t) {
25
+ function ot(t) {
25
26
  me();
26
- const w = Pe(), [P, ae] = z(!1), [ge, ie] = z(!1), l = () => t.busy || P();
27
- let j = !1;
28
- te(() => {
29
- j = !0;
27
+ const y = Ee(), [k, ie] = z(!1), [ge, re] = z(!1), l = () => t.busy || k();
28
+ let Y = !1;
29
+ ne(() => {
30
+ Y = !0;
30
31
  });
31
- const [g, ve] = z(Ie(window)), [A, be] = z(), [Q, xe] = z({
32
+ const [v, ve] = z(Ie(window)), [L, be] = z(), [G, xe] = z({
32
33
  width: 0,
33
34
  height: 0
34
- }), ye = F((n) => t.open ? t.anchor ?? K(() => Ue(t.owner)) : n), C = Re({
35
+ }), ye = F((n) => t.open ? t.anchor ?? j(() => je(t.owner)) : n), w = qe({
35
36
  open: () => t.open,
36
- element: A
37
+ element: L
37
38
  });
38
- let v, Y, L = !1, G, B;
39
- const J = () => queueMicrotask(() => {
40
- !j && t.open && !l() && !t.inputDisabled && v?.isConnected && v.focus({
39
+ let b, J, T = !1, Z, B;
40
+ const p = () => queueMicrotask(() => {
41
+ !Y && t.open && !l() && !t.inputDisabled && b?.isConnected && b.focus({
41
42
  preventScroll: !0
42
43
  });
43
- }), Z = (n) => {
44
- t.open && !l() && !t.inputDisabled && n.length && (t.attachment?.onFiles(n), J());
44
+ }), ee = (n) => {
45
+ t.open && !l() && !t.inputDisabled && n.length && (t.attachment?.onFiles(n), p());
45
46
  };
46
- U(() => {
47
- (!t.open || l() || t.inputDisabled) && ie(!1);
47
+ Q(() => {
48
+ (!t.open || l() || t.inputDisabled) && re(!1);
48
49
  });
49
- const T = F(() => !C.mounted() || t.portalScope === "viewport" ? {
50
+ const O = F(() => !w.mounted() || t.portalScope === "viewport" ? {
50
51
  host: null,
51
52
  boundaryHost: null,
52
53
  mountHost: null,
53
54
  mode: "global"
54
55
  } : $e({
55
56
  owner: t.owner
56
- })), H = () => Oe(T()), O = F(() => (g(), Q(), H() ? De(T()) : {
57
- x: g().fixedScale,
58
- y: g().fixedScale
57
+ })), R = () => Oe(O()), I = F(() => (v(), G(), R() ? De(O()) : {
58
+ x: v().fixedScale,
59
+ y: v().fixedScale
59
60
  }));
60
- U(() => {
61
- C.mounted() && te(ze(window, ve));
62
- }), U(() => {
63
- const n = A();
64
- if (!C.mounted() || !n) return;
65
- const i = () => xe((s) => {
66
- const f = n.offsetWidth, d = n.offsetHeight;
67
- return s.width === f && s.height === d ? s : {
68
- width: f,
69
- height: d
61
+ Q(() => {
62
+ w.mounted() && ne(ze(window, ve));
63
+ }), Q(() => {
64
+ const n = L();
65
+ if (!w.mounted() || !n) return;
66
+ const i = () => xe((d) => {
67
+ const u = n.offsetWidth, s = n.offsetHeight;
68
+ return d.width === u && d.height === s ? d : {
69
+ width: u,
70
+ height: s
70
71
  };
71
72
  }), r = new ResizeObserver(i);
72
- r.observe(n), i(), te(() => r.disconnect());
73
+ r.observe(n), i(), ne(() => r.disconnect());
73
74
  });
74
- const S = F(() => {
75
- const n = g(), i = H() ? Ae(T()) : n.visible, r = n.visible.width < 640 ? 8 : 12, s = t.viewportInsets, f = Math.max(n.visible.left, i.left) + Math.max(n.safeArea.left, s?.left ?? 0) + r, d = Math.max(n.visible.top, i.top) + Math.max(n.safeArea.top, s?.top ?? 0) + r, k = Math.min(n.visible.right, i.right) - Math.max(n.safeArea.right, s?.right ?? 0) - r, o = Math.min(n.visible.bottom, i.bottom) - Math.max(n.safeArea.bottom, s?.bottom ?? 0) - r, $ = Math.max(0, k - f), b = Math.min(Q().width * O().x, $), e = Math.max(0, o - d), m = Math.min(Q().height * O().y, e), a = ye(), h = (_, N, W) => Math.max(N, Math.min(_, W)), x = h(a ? a.x + 8 : f + ($ - b) / 2, f, k - b), I = !a || a.y + 8 + m <= o, R = a ? I ? a.y + 8 : a.y - m - 8 : d + Math.max(0, (e - m) * 0.32), V = h(R, d, o - m);
75
+ const C = F(() => {
76
+ const n = v(), i = R() ? Ae(O()) : n.visible, r = n.visible.width < 640 ? 8 : 12, d = t.viewportInsets, u = Math.max(n.visible.left, i.left) + Math.max(n.safeArea.left, d?.left ?? 0) + r, s = Math.max(n.visible.top, i.top) + Math.max(n.safeArea.top, d?.top ?? 0) + r, S = Math.min(n.visible.right, i.right) - Math.max(n.safeArea.right, d?.right ?? 0) - r, o = Math.min(n.visible.bottom, i.bottom) - Math.max(n.safeArea.bottom, d?.bottom ?? 0) - r, $ = Math.max(0, S - u), h = Math.min(G().width * I().x, $), e = Math.max(0, o - s), m = Math.min(G().height * I().y, e), a = ye(), g = (W, X, K) => Math.max(X, Math.min(W, K)), M = g(a ? a.x + 8 : u + ($ - h) / 2, u, S - h), q = !a || a.y + 8 + m <= o, V = a ? q ? a.y + 8 : a.y - m - 8 : s + Math.max(0, (e - m) * 0.32), _ = g(V, s, o - m), D = Ve({
77
+ x: M,
78
+ y: _
79
+ }, {
80
+ width: h,
81
+ height: m
82
+ }, {
83
+ left: u,
84
+ top: s,
85
+ right: S,
86
+ bottom: o
87
+ }, t.avoidRegions ?? []), N = a ? D.y >= a.y ? "bottom" : "top" : "edge";
76
88
  return {
77
- x,
78
- y: V,
89
+ ...D,
79
90
  availableWidth: $,
80
91
  maxHeight: e,
81
- side: a ? I ? "bottom" : "top" : "edge",
82
- originX: a ? h(a.x - x, 16, b - 16) : b / 2
92
+ side: N,
93
+ originX: a ? g(a.x - D.x, 16, h - 16) : h / 2
83
94
  };
84
- }), re = F(() => H() ? Le(S(), T()) : {
85
- x: (S().x + g().fixedOffset.left) / g().fixedScale,
86
- y: (S().y + g().fixedOffset.top) / g().fixedScale
87
- }), q = (n) => {
88
- l() || !t.open || L || (t.onClose(), n && ue(() => K(() => {
89
- !t.open && Y?.isConnected && Y.focus({
95
+ }), oe = F(() => R() ? Le(C(), O()) : {
96
+ x: (C().x + v().fixedOffset.left) / v().fixedScale,
97
+ y: (C().y + v().fixedOffset.top) / v().fixedScale
98
+ }), H = (n) => {
99
+ l() || !t.open || T || (t.onClose(), n && ue(() => j(() => {
100
+ !t.open && J?.isConnected && J.focus({
90
101
  preventScroll: !0
91
102
  });
92
103
  })));
93
104
  };
94
- U(() => {
105
+ Q(() => {
95
106
  if (!t.open) return;
96
107
  const n = document.activeElement, r = t.owner ?? he()?.target?.closest("button, a[href], input, [tabindex]") ?? (n instanceof HTMLElement && n !== document.body ? n : void 0);
97
- r && !K(A)?.contains(r) && !t.containsTarget?.(r) && (Y = r), queueMicrotask(() => {
98
- !t.open || t.autoFocus === !1 || !v?.isConnected || (v.focus({
108
+ r && !j(L)?.contains(r) && !t.containsTarget?.(r) && (J = r), queueMicrotask(() => {
109
+ !t.open || t.autoFocus === !1 || !b?.isConnected || (b.focus({
99
110
  preventScroll: !0
100
- }), v.setSelectionRange(v.value.length, v.value.length));
111
+ }), b.setSelectionRange(b.value.length, b.value.length));
101
112
  });
102
113
  }), ke({
103
114
  open: () => t.open,
104
- root: A,
105
- containsTarget: (n) => !!(n instanceof Node && A()?.contains(n)) || !!t.containsTarget?.(n) || !!(n instanceof Node && document.getElementById(B?.getAttribute("aria-controls") ?? "")?.parentElement?.contains(n)),
106
- onClose: () => q(!0),
115
+ root: L,
116
+ containsTarget: (n) => !!(n instanceof Node && L()?.contains(n)) || !!t.containsTarget?.(n) || !!(n instanceof Node && document.getElementById(B?.getAttribute("aria-controls") ?? "")?.parentElement?.contains(n)),
117
+ onClose: () => H(!0),
107
118
  onInteractOutside: (n) => {
108
- n.type === "pointerdown" && n.button === 0 && q(!1);
119
+ n.type === "pointerdown" && n.button === 0 && H(!1);
109
120
  },
110
121
  // Related previews belong to pointer ownership, but own their Escape command.
111
122
  closeOnEscape: "none",
@@ -116,38 +127,38 @@ function it(t) {
116
127
  restoreFocus: !1,
117
128
  blockHotkeys: !1
118
129
  });
119
- const oe = () => {
120
- !t.open || l() || t.submitDisabled || (ae(!0), ue(() => K(() => {
121
- if (!j)
130
+ const le = () => {
131
+ !t.open || l() || t.submitDisabled || (ie(!0), ue(() => j(() => {
132
+ if (!Y)
122
133
  try {
123
134
  t.open && t.onSubmit();
124
135
  } finally {
125
- ae(!1);
136
+ ie(!1);
126
137
  }
127
138
  })));
128
139
  };
129
- return u(E, {
140
+ return f(E, {
130
141
  get when() {
131
- return C.mounted();
142
+ return w.mounted();
132
143
  },
133
144
  get children() {
134
- return u(we, {
145
+ return f(we, {
135
146
  get mount() {
136
- return Te(T());
147
+ return Te(O());
137
148
  },
138
149
  get children() {
139
- var n = Ke(), i = n.firstChild, r = i.firstChild, s = r.firstChild, f = r.nextSibling, d = f.firstChild, k = d.firstChild, o = k.firstChild, $ = k.nextSibling, b = $.firstChild;
150
+ var n = Ue(), i = n.firstChild, r = i.firstChild, d = r.firstChild, u = r.nextSibling, s = u.firstChild, S = s.firstChild, o = S.firstChild, $ = S.nextSibling, h = $.firstChild;
140
151
  return i.$$keydown = (e) => {
141
- e.key !== "Escape" || e.defaultPrevented || e.isComposing || L || B?.getAttribute("aria-expanded") === "true" && B.contains(e.target) || (e.preventDefault(), e.stopPropagation(), q(!0));
142
- }, i.$$focusin = () => t.onActivate?.(), i.$$pointerdown = () => t.onActivate?.(), ee(be, i), y(i, "aria-labelledby", w), c(r, u(E, {
152
+ e.key !== "Escape" || e.defaultPrevented || e.isComposing || T || B?.getAttribute("aria-expanded") === "true" && B.contains(e.target) || (e.preventDefault(), e.stopPropagation(), H(!0));
153
+ }, i.$$focusin = () => t.onActivate?.(), i.$$pointerdown = () => t.onActivate?.(), te(be, i), x(i, "aria-labelledby", y), c(r, f(E, {
143
154
  get when() {
144
155
  return t.icon;
145
156
  },
146
157
  get children() {
147
- var e = Ve();
158
+ var e = _e();
148
159
  return c(e, () => t.icon), e;
149
160
  }
150
- }), s), y(s, "id", w), c(s, () => t.title), c(r, u(ne, {
161
+ }), d), x(d, "id", y), c(d, () => t.title), c(r, f(ae, {
151
162
  variant: "ghost",
152
163
  size: "icon",
153
164
  icon: Fe,
@@ -161,60 +172,60 @@ function it(t) {
161
172
  get "aria-label"() {
162
173
  return t.closeLabel;
163
174
  },
164
- onClick: () => q(!0)
165
- }), null), Ce(f, Se(() => t.bodyProps, {
175
+ onClick: () => H(!0)
176
+ }), null), Ce(u, Se(() => t.bodyProps, {
166
177
  get class() {
167
178
  return fe("floe-prompt-card-body", t.bodyProps?.class);
168
179
  }
169
- }), !1, !0), c(f, u(E, {
180
+ }), !1, !0), c(u, f(E, {
170
181
  get when() {
171
182
  return t.question;
172
183
  },
173
184
  get children() {
174
- var e = _e();
185
+ var e = Ne();
175
186
  return c(e, () => t.question), e;
176
187
  }
177
- }), d), d.addEventListener("drop", (e) => {
178
- !t.attachment || !e.dataTransfer?.files.length || (e.preventDefault(), Z(Array.from(e.dataTransfer.files)));
179
- }), d.addEventListener("dragover", (e) => {
188
+ }), s), s.addEventListener("drop", (e) => {
189
+ !t.attachment || !e.dataTransfer?.files.length || (e.preventDefault(), ee(Array.from(e.dataTransfer.files)));
190
+ }), s.addEventListener("dragover", (e) => {
180
191
  t.attachment && !l() && !t.inputDisabled && e.dataTransfer?.types.includes("Files") && e.preventDefault();
181
- }), c(d, u(E, {
192
+ }), c(s, f(E, {
182
193
  get when() {
183
194
  return t.references;
184
195
  },
185
196
  get children() {
186
- var e = Ne();
187
- return c(e, () => t.references), X(() => e.inert = !!l()), e;
197
+ var e = We();
198
+ return c(e, () => t.references), U(() => e.inert = !!l()), e;
188
199
  }
189
- }), k), o.$$keydown = (e) => {
190
- e.key === "Enter" && !e.shiftKey && !e.isComposing && !L && (e.preventDefault(), oe());
200
+ }), S), o.$$keydown = (e) => {
201
+ e.key === "Enter" && !e.shiftKey && !e.isComposing && !T && (e.preventDefault(), le());
191
202
  }, o.addEventListener("compositionend", (e) => {
192
- L = !1, t.onValueChange(e.currentTarget.value);
203
+ T = !1, t.onValueChange(e.currentTarget.value);
193
204
  }), o.addEventListener("compositionupdate", (e) => t.onValueChange(e.currentTarget.value)), o.addEventListener("compositionstart", () => {
194
- L = !0;
205
+ T = !0;
195
206
  }), o.$$input = (e) => t.onValueChange(e.currentTarget.value), o.addEventListener("paste", (e) => {
196
- !t.attachment || !e.clipboardData?.files.length || (e.preventDefault(), Z(Array.from(e.clipboardData.files)));
197
- }), ee((e) => {
198
- v = e, t.editorRef?.(e);
199
- }, o), c(b, u(E, {
207
+ !t.attachment || !e.clipboardData?.files.length || (e.preventDefault(), ee(Array.from(e.clipboardData.files)));
208
+ }), te((e) => {
209
+ b = e, t.editorRef?.(e);
210
+ }, o), c(h, f(E, {
200
211
  get when() {
201
212
  return t.attachment;
202
213
  },
203
214
  get children() {
204
215
  return [(() => {
205
- var e = We();
216
+ var e = Xe();
206
217
  e.addEventListener("change", (a) => {
207
- Z(Array.from(a.currentTarget.files ?? [])), a.currentTarget.value = "";
208
- }), e.addEventListener("cancel", J);
209
- var m = G;
210
- return typeof m == "function" ? ee(m, e) : G = e, X((a) => {
211
- var h = t.attachment?.accept, x = l() || t.inputDisabled;
212
- return h !== a.e && y(e, "accept", a.e = h), x !== a.t && (e.disabled = a.t = x), a;
218
+ ee(Array.from(a.currentTarget.files ?? [])), a.currentTarget.value = "";
219
+ }), e.addEventListener("cancel", p);
220
+ var m = Z;
221
+ return typeof m == "function" ? te(m, e) : Z = e, U((a) => {
222
+ var g = t.attachment?.accept, M = l() || t.inputDisabled;
223
+ return g !== a.e && x(e, "accept", a.e = g), M !== a.t && (e.disabled = a.t = M), a;
213
224
  }, {
214
225
  e: void 0,
215
226
  t: void 0
216
227
  }), e;
217
- })(), u(ne, {
228
+ })(), f(ae, {
218
229
  variant: "ghost",
219
230
  size: "icon",
220
231
  icon: Be,
@@ -228,15 +239,15 @@ function it(t) {
228
239
  get title() {
229
240
  return t.attachment?.label;
230
241
  },
231
- onClick: () => G?.click()
242
+ onClick: () => Z?.click()
232
243
  })];
233
244
  }
234
- }), null), c(b, () => t.tools, null), c(b, u(E, {
245
+ }), null), c(h, () => t.tools, null), c(h, f(E, {
235
246
  get when() {
236
247
  return t.selection;
237
248
  },
238
249
  get children() {
239
- return u(qe, {
250
+ return f(He, {
240
251
  ref: (e) => {
241
252
  B = e;
242
253
  },
@@ -244,8 +255,8 @@ function it(t) {
244
255
  get open() {
245
256
  return ge();
246
257
  },
247
- onOpenChange: ie,
248
- onOptionSelect: J,
258
+ onOpenChange: re,
259
+ onOptionSelect: p,
249
260
  get zIndex() {
250
261
  return (t.zIndex ?? 100) + 1;
251
262
  },
@@ -285,10 +296,10 @@ function it(t) {
285
296
  }
286
297
  });
287
298
  }
288
- }), null), c($, u(ne, {
299
+ }), null), c($, f(ae, {
289
300
  variant: "primary",
290
301
  size: "icon",
291
- icon: He,
302
+ icon: Re,
292
303
  class: "floe-prompt-card-submit",
293
304
  get disabled() {
294
305
  return t.submitDisabled;
@@ -305,18 +316,18 @@ function it(t) {
305
316
  get "aria-label"() {
306
317
  return t.submitLabel;
307
318
  },
308
- onClick: oe
309
- }), null), c(f, u(E, {
319
+ onClick: le
320
+ }), null), c(u, f(E, {
310
321
  get when() {
311
322
  return t.feedback;
312
323
  },
313
324
  get children() {
314
- var e = Xe();
325
+ var e = Ke();
315
326
  return c(e, () => t.feedback), e;
316
327
  }
317
- }), null), X((e) => {
318
- var m = H() ? "absolute" : "fixed", a = `${re().x}px`, h = `${re().y}px`, x = `${S().availableWidth / O().x}px`, I = `${S().maxHeight / O().y}px`, R = `${S().originX / O().x}px`, V = t.zIndex ?? 100, p = fe("floe-prompt-card floe-floating-presence", t.class), _ = S().side, N = C.state(), W = C.exiting(), le = C.exiting() ? "true" : void 0, ce = t.inputLabel, se = t.placeholder, de = l() || t.inputDisabled;
319
- return m !== e.e && M(n, "position", e.e = m), a !== e.t && M(n, "left", e.t = a), h !== e.a && M(n, "top", e.a = h), x !== e.o && M(n, "--floe-prompt-max-width", e.o = x), I !== e.i && M(n, "--floe-prompt-max-height", e.i = I), R !== e.n && M(n, "--floe-prompt-origin-x", e.n = R), V !== e.s && M(n, "z-index", e.s = V), p !== e.h && Me(i, e.h = p), _ !== e.r && y(i, "data-floating-side", e.r = _), N !== e.d && y(i, "data-floating-presence", e.d = N), W !== e.l && (i.inert = e.l = W), le !== e.u && y(i, "aria-hidden", e.u = le), ce !== e.c && y(o, "aria-label", e.c = ce), se !== e.w && y(o, "placeholder", e.w = se), de !== e.m && (o.disabled = e.m = de), e;
328
+ }), null), U((e) => {
329
+ var m = R() ? "absolute" : "fixed", a = `${oe().x}px`, g = `${oe().y}px`, M = `${C().availableWidth / I().x}px`, q = `${C().maxHeight / I().y}px`, V = `${C().originX / I().x}px`, _ = t.zIndex ?? 100, D = fe("floe-prompt-card floe-floating-presence", t.class), N = C().side, W = w.state(), X = w.exiting(), K = w.exiting() ? "true" : void 0, ce = t.inputLabel, se = t.placeholder, de = l() || t.inputDisabled;
330
+ return m !== e.e && P(n, "position", e.e = m), a !== e.t && P(n, "left", e.t = a), g !== e.a && P(n, "top", e.a = g), M !== e.o && P(n, "--floe-prompt-max-width", e.o = M), q !== e.i && P(n, "--floe-prompt-max-height", e.i = q), V !== e.n && P(n, "--floe-prompt-origin-x", e.n = V), _ !== e.s && P(n, "z-index", e.s = _), D !== e.h && Me(i, e.h = D), N !== e.r && x(i, "data-floating-side", e.r = N), W !== e.d && x(i, "data-floating-presence", e.d = W), X !== e.l && (i.inert = e.l = X), K !== e.u && x(i, "aria-hidden", e.u = K), ce !== e.c && x(o, "aria-label", e.c = ce), se !== e.w && x(o, "placeholder", e.w = se), de !== e.m && (o.disabled = e.m = de), e;
320
331
  }, {
321
332
  e: void 0,
322
333
  t: void 0,
@@ -333,14 +344,14 @@ function it(t) {
333
344
  c: void 0,
334
345
  w: void 0,
335
346
  m: void 0
336
- }), X(() => o.value = t.value), n;
347
+ }), U(() => o.value = t.value), n;
337
348
  }
338
349
  });
339
350
  }
340
351
  });
341
352
  }
342
- Ee(["pointerdown", "focusin", "keydown", "input"]);
353
+ Pe(["pointerdown", "focusin", "keydown", "input"]);
343
354
  export {
344
- it as PromptCard,
345
- Ue as capturePromptCardAnchor
355
+ ot as PromptCard,
356
+ je as capturePromptCardAnchor
346
357
  };
@@ -0,0 +1,24 @@
1
+ export type PromptCardRegion = Readonly<{
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ }>;
7
+ /** Keep a contextual editor near its anchor while avoiding the content it edits.
8
+ * All inputs and results are viewport pixels; portal projection happens afterward.
9
+ */
10
+ export declare function avoidPromptCardRegions(preferred: {
11
+ x: number;
12
+ y: number;
13
+ }, { width, height }: {
14
+ width: number;
15
+ height: number;
16
+ }, { left, top, right, bottom }: {
17
+ left: number;
18
+ top: number;
19
+ right: number;
20
+ bottom: number;
21
+ }, regions: readonly PromptCardRegion[]): {
22
+ x: number;
23
+ y: number;
24
+ };
@@ -0,0 +1,12 @@
1
+ function e(h, { width: m, height: M }, { left: o, top: i, right: c, bottom: d }, n) {
2
+ const s = [[h.x, h.y], ...n.flatMap((a) => [
3
+ [a.x + a.width + 12, a.y],
4
+ [a.x - m - 12, a.y],
5
+ [a.x, a.y + a.height + 12],
6
+ [a.x, a.y - M - 12]
7
+ ])].map(([a, x]) => ({ x: Math.max(o, Math.min(a, c - m)), y: Math.max(i, Math.min(x, d - M)) })), y = (a) => n.reduce((x, t) => x + Math.max(0, Math.min(a.x + m, t.x + t.width + 8) - Math.max(a.x, t.x - 8)) * Math.max(0, Math.min(a.y + M, t.y + t.height + 8) - Math.max(a.y, t.y - 8)), 0);
8
+ return s.sort((a, x) => y(a) - y(x))[0];
9
+ }
10
+ export {
11
+ e as avoidPromptCardRegions
12
+ };