@floegence/floe-webapp-core 0.93.0 → 0.94.0
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/ui/PromptCard.d.ts +2 -0
- package/dist/components/ui/PromptCard.js +38 -38
- package/dist/components/ui/contextSource.d.ts +25 -0
- package/dist/components/ui/contextSource.js +53 -0
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/floe.css +9 -2
- package/dist/full.js +145 -143
- package/dist/styles.css +1 -1
- package/dist/ui.js +135 -133
- package/package.json +1 -1
|
@@ -38,6 +38,8 @@ export interface PromptCardProps {
|
|
|
38
38
|
accept?: string;
|
|
39
39
|
onFiles: (files: File[]) => void;
|
|
40
40
|
}>;
|
|
41
|
+
/** Host-owned actions beside attachments; asynchronous work stays with the host. */
|
|
42
|
+
tools?: JSX.Element;
|
|
41
43
|
/** Compact host-owned choice, for example an assistant model. */
|
|
42
44
|
selection?: Readonly<{
|
|
43
45
|
label: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent as u, Portal as we, use as ee, setAttribute as
|
|
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
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";
|
|
3
3
|
import { useOverlayMask as ke } from "../../hooks/useOverlayMask.js";
|
|
4
4
|
import { deferAfterPaint as ue } from "../../utils/defer.js";
|
|
@@ -13,9 +13,9 @@ var Ve = /* @__PURE__ */ D("<span class=floe-prompt-card-icon aria-hidden=true>"
|
|
|
13
13
|
function Ue(t) {
|
|
14
14
|
if (typeof document > "u") return null;
|
|
15
15
|
me();
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
-
const P =
|
|
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
19
|
return P.width > 0 && P.height > 0 ? {
|
|
20
20
|
x: P.left,
|
|
21
21
|
y: P.bottom
|
|
@@ -23,7 +23,7 @@ function Ue(t) {
|
|
|
23
23
|
}
|
|
24
24
|
function it(t) {
|
|
25
25
|
me();
|
|
26
|
-
const
|
|
26
|
+
const w = Pe(), [P, ae] = z(!1), [ge, ie] = z(!1), l = () => t.busy || P();
|
|
27
27
|
let j = !1;
|
|
28
28
|
te(() => {
|
|
29
29
|
j = !0;
|
|
@@ -31,22 +31,22 @@ function it(t) {
|
|
|
31
31
|
const [g, ve] = z(Ie(window)), [A, be] = z(), [Q, xe] = z({
|
|
32
32
|
width: 0,
|
|
33
33
|
height: 0
|
|
34
|
-
}), ye = F((n) => t.open ? t.anchor ?? K(() => Ue(t.owner)) : n),
|
|
34
|
+
}), ye = F((n) => t.open ? t.anchor ?? K(() => Ue(t.owner)) : n), C = Re({
|
|
35
35
|
open: () => t.open,
|
|
36
36
|
element: A
|
|
37
37
|
});
|
|
38
|
-
let v, Y, L = !1,
|
|
39
|
-
const
|
|
38
|
+
let v, Y, L = !1, G, B;
|
|
39
|
+
const J = () => queueMicrotask(() => {
|
|
40
40
|
!j && t.open && !l() && !t.inputDisabled && v?.isConnected && v.focus({
|
|
41
41
|
preventScroll: !0
|
|
42
42
|
});
|
|
43
|
-
}),
|
|
44
|
-
t.open && !l() && !t.inputDisabled && n.length && (t.attachment?.onFiles(n),
|
|
43
|
+
}), Z = (n) => {
|
|
44
|
+
t.open && !l() && !t.inputDisabled && n.length && (t.attachment?.onFiles(n), J());
|
|
45
45
|
};
|
|
46
46
|
U(() => {
|
|
47
47
|
(!t.open || l() || t.inputDisabled) && ie(!1);
|
|
48
48
|
});
|
|
49
|
-
const T = F(() => !
|
|
49
|
+
const T = F(() => !C.mounted() || t.portalScope === "viewport" ? {
|
|
50
50
|
host: null,
|
|
51
51
|
boundaryHost: null,
|
|
52
52
|
mountHost: null,
|
|
@@ -58,10 +58,10 @@ function it(t) {
|
|
|
58
58
|
y: g().fixedScale
|
|
59
59
|
}));
|
|
60
60
|
U(() => {
|
|
61
|
-
|
|
61
|
+
C.mounted() && te(ze(window, ve));
|
|
62
62
|
}), U(() => {
|
|
63
63
|
const n = A();
|
|
64
|
-
if (!
|
|
64
|
+
if (!C.mounted() || !n) return;
|
|
65
65
|
const i = () => xe((s) => {
|
|
66
66
|
const f = n.offsetWidth, d = n.offsetHeight;
|
|
67
67
|
return s.width === f && s.height === d ? s : {
|
|
@@ -71,19 +71,19 @@ function it(t) {
|
|
|
71
71
|
}), r = new ResizeObserver(i);
|
|
72
72
|
r.observe(n), i(), te(() => r.disconnect());
|
|
73
73
|
});
|
|
74
|
-
const
|
|
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),
|
|
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);
|
|
76
76
|
return {
|
|
77
|
-
x
|
|
77
|
+
x,
|
|
78
78
|
y: V,
|
|
79
79
|
availableWidth: $,
|
|
80
80
|
maxHeight: e,
|
|
81
81
|
side: a ? I ? "bottom" : "top" : "edge",
|
|
82
|
-
originX: a ? h(a.x -
|
|
82
|
+
originX: a ? h(a.x - x, 16, b - 16) : b / 2
|
|
83
83
|
};
|
|
84
|
-
}), re = F(() => H() ? Le(
|
|
85
|
-
x: (
|
|
86
|
-
y: (
|
|
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
87
|
}), q = (n) => {
|
|
88
88
|
l() || !t.open || L || (t.onClose(), n && ue(() => K(() => {
|
|
89
89
|
!t.open && Y?.isConnected && Y.focus({
|
|
@@ -128,7 +128,7 @@ function it(t) {
|
|
|
128
128
|
};
|
|
129
129
|
return u(E, {
|
|
130
130
|
get when() {
|
|
131
|
-
return
|
|
131
|
+
return C.mounted();
|
|
132
132
|
},
|
|
133
133
|
get children() {
|
|
134
134
|
return u(we, {
|
|
@@ -136,10 +136,10 @@ function it(t) {
|
|
|
136
136
|
return Te(T());
|
|
137
137
|
},
|
|
138
138
|
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,
|
|
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;
|
|
140
140
|
return i.$$keydown = (e) => {
|
|
141
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),
|
|
142
|
+
}, i.$$focusin = () => t.onActivate?.(), i.$$pointerdown = () => t.onActivate?.(), ee(be, i), y(i, "aria-labelledby", w), c(r, u(E, {
|
|
143
143
|
get when() {
|
|
144
144
|
return t.icon;
|
|
145
145
|
},
|
|
@@ -147,7 +147,7 @@ function it(t) {
|
|
|
147
147
|
var e = Ve();
|
|
148
148
|
return c(e, () => t.icon), e;
|
|
149
149
|
}
|
|
150
|
-
}), s),
|
|
150
|
+
}), s), y(s, "id", w), c(s, () => t.title), c(r, u(ne, {
|
|
151
151
|
variant: "ghost",
|
|
152
152
|
size: "icon",
|
|
153
153
|
icon: Fe,
|
|
@@ -175,7 +175,7 @@ function it(t) {
|
|
|
175
175
|
return c(e, () => t.question), e;
|
|
176
176
|
}
|
|
177
177
|
}), d), d.addEventListener("drop", (e) => {
|
|
178
|
-
!t.attachment || !e.dataTransfer?.files.length || (e.preventDefault(),
|
|
178
|
+
!t.attachment || !e.dataTransfer?.files.length || (e.preventDefault(), Z(Array.from(e.dataTransfer.files)));
|
|
179
179
|
}), d.addEventListener("dragover", (e) => {
|
|
180
180
|
t.attachment && !l() && !t.inputDisabled && e.dataTransfer?.types.includes("Files") && e.preventDefault();
|
|
181
181
|
}), c(d, u(E, {
|
|
@@ -193,10 +193,10 @@ function it(t) {
|
|
|
193
193
|
}), o.addEventListener("compositionupdate", (e) => t.onValueChange(e.currentTarget.value)), o.addEventListener("compositionstart", () => {
|
|
194
194
|
L = !0;
|
|
195
195
|
}), o.$$input = (e) => t.onValueChange(e.currentTarget.value), o.addEventListener("paste", (e) => {
|
|
196
|
-
!t.attachment || !e.clipboardData?.files.length || (e.preventDefault(),
|
|
196
|
+
!t.attachment || !e.clipboardData?.files.length || (e.preventDefault(), Z(Array.from(e.clipboardData.files)));
|
|
197
197
|
}), ee((e) => {
|
|
198
198
|
v = e, t.editorRef?.(e);
|
|
199
|
-
}, o), c(
|
|
199
|
+
}, o), c(b, u(E, {
|
|
200
200
|
get when() {
|
|
201
201
|
return t.attachment;
|
|
202
202
|
},
|
|
@@ -204,12 +204,12 @@ function it(t) {
|
|
|
204
204
|
return [(() => {
|
|
205
205
|
var e = We();
|
|
206
206
|
e.addEventListener("change", (a) => {
|
|
207
|
-
|
|
208
|
-
}), e.addEventListener("cancel",
|
|
209
|
-
var m =
|
|
210
|
-
return typeof m == "function" ? ee(m, e) :
|
|
211
|
-
var h = t.attachment?.accept,
|
|
212
|
-
return h !== a.e &&
|
|
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;
|
|
213
213
|
}, {
|
|
214
214
|
e: void 0,
|
|
215
215
|
t: void 0
|
|
@@ -228,10 +228,10 @@ function it(t) {
|
|
|
228
228
|
get title() {
|
|
229
229
|
return t.attachment?.label;
|
|
230
230
|
},
|
|
231
|
-
onClick: () =>
|
|
231
|
+
onClick: () => G?.click()
|
|
232
232
|
})];
|
|
233
233
|
}
|
|
234
|
-
}), null), c(
|
|
234
|
+
}), null), c(b, () => t.tools, null), c(b, u(E, {
|
|
235
235
|
get when() {
|
|
236
236
|
return t.selection;
|
|
237
237
|
},
|
|
@@ -245,7 +245,7 @@ function it(t) {
|
|
|
245
245
|
return ge();
|
|
246
246
|
},
|
|
247
247
|
onOpenChange: ie,
|
|
248
|
-
onOptionSelect:
|
|
248
|
+
onOptionSelect: J,
|
|
249
249
|
get zIndex() {
|
|
250
250
|
return (t.zIndex ?? 100) + 1;
|
|
251
251
|
},
|
|
@@ -315,8 +315,8 @@ function it(t) {
|
|
|
315
315
|
return c(e, () => t.feedback), e;
|
|
316
316
|
}
|
|
317
317
|
}), null), X((e) => {
|
|
318
|
-
var m = H() ? "absolute" : "fixed", a = `${re().x}px`, h = `${re().y}px`,
|
|
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),
|
|
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;
|
|
320
320
|
}, {
|
|
321
321
|
e: void 0,
|
|
322
322
|
t: void 0,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ContextSource<T> {
|
|
2
|
+
id: string;
|
|
3
|
+
element: HTMLElement;
|
|
4
|
+
read: () => T;
|
|
5
|
+
}
|
|
6
|
+
export interface ContextSourceSnapshot<T> {
|
|
7
|
+
id: string;
|
|
8
|
+
element: HTMLElement;
|
|
9
|
+
value: T;
|
|
10
|
+
selection: string;
|
|
11
|
+
rect: Readonly<{
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/** Connection-local readers. Opening a menu or prompt never replaces its origin. */
|
|
19
|
+
export declare function createContextSourceRegistry<T>(doc: Document): {
|
|
20
|
+
register(source: ContextSource<T>): () => void;
|
|
21
|
+
/** Hosts may forward activation from their authenticated embedded channel. */
|
|
22
|
+
activate(id: string): void;
|
|
23
|
+
capture(target?: EventTarget | null): ContextSourceSnapshot<T> | undefined;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function m(o) {
|
|
2
|
+
const r = /* @__PURE__ */ new Map();
|
|
3
|
+
let i, s = "";
|
|
4
|
+
const c = (e) => {
|
|
5
|
+
const t = o.activeElement;
|
|
6
|
+
if (t && e.element.contains(t) && (t instanceof HTMLTextAreaElement || t instanceof HTMLInputElement))
|
|
7
|
+
return t instanceof HTMLInputElement && t.type === "password" ? "" : t.value.slice(t.selectionStart ?? 0, t.selectionEnd ?? 0);
|
|
8
|
+
const n = o.getSelection();
|
|
9
|
+
return n?.anchorNode && n.focusNode && e.element.contains(n.anchorNode) && e.element.contains(n.focusNode) ? n.toString() : "";
|
|
10
|
+
}, a = (e) => {
|
|
11
|
+
if (!(e instanceof Node)) return;
|
|
12
|
+
let t;
|
|
13
|
+
for (const n of r.values())
|
|
14
|
+
n.element.isConnected && n.element.contains(e) && (!t || t.element.contains(n.element)) && (t = n);
|
|
15
|
+
return t;
|
|
16
|
+
}, d = (e) => {
|
|
17
|
+
e?.element.isConnected && (e !== i && (s = ""), i = e, s = c(e));
|
|
18
|
+
}, l = (e) => {
|
|
19
|
+
i && i.element.contains(o.activeElement) && (s = c(i)), d(a(e.target));
|
|
20
|
+
}, v = () => {
|
|
21
|
+
i && i.element.contains(o.activeElement) && (s = c(i));
|
|
22
|
+
};
|
|
23
|
+
return o.addEventListener("pointerdown", l, !0), o.addEventListener("focusin", l, !0), o.addEventListener("selectionchange", v), {
|
|
24
|
+
register(e) {
|
|
25
|
+
return r.set(e.id, e), () => {
|
|
26
|
+
r.get(e.id) === e && r.delete(e.id), i === e && (i = void 0, s = "");
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
/** Hosts may forward activation from their authenticated embedded channel. */
|
|
30
|
+
activate(e) {
|
|
31
|
+
d(r.get(e));
|
|
32
|
+
},
|
|
33
|
+
capture(e) {
|
|
34
|
+
const t = (e ? a(e) : void 0) ?? i;
|
|
35
|
+
if (!t?.element.isConnected || r.get(t.id) !== t) return;
|
|
36
|
+
const n = t.element.getBoundingClientRect();
|
|
37
|
+
if (!(n.width <= 0 || n.height <= 0))
|
|
38
|
+
return {
|
|
39
|
+
id: t.id,
|
|
40
|
+
element: t.element,
|
|
41
|
+
value: t.read(),
|
|
42
|
+
selection: c(t) || (t === i ? s : ""),
|
|
43
|
+
rect: { x: n.x, y: n.y, width: n.width, height: n.height }
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
dispose() {
|
|
47
|
+
o.removeEventListener("pointerdown", l, !0), o.removeEventListener("focusin", l, !0), o.removeEventListener("selectionchange", v), r.clear(), i = void 0, s = "";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
m as createContextSourceRegistry
|
|
53
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { createContextSourceRegistry, type ContextSource, type ContextSourceSnapshot } from './contextSource';
|
|
1
2
|
export { PromptCard, capturePromptCardAnchor, type PromptCardProps } from './PromptCard';
|
|
2
3
|
export { FeedbackIndicator, type FeedbackIndicatorProps, type FeedbackIndicatorEntry } from './FeedbackIndicator';
|
|
3
4
|
export { Button, type ButtonProps, type ButtonVariant, type ButtonSize } from './Button';
|
package/dist/floe.css
CHANGED
|
@@ -1019,8 +1019,8 @@
|
|
|
1019
1019
|
overflow: hidden; pointer-events: auto;
|
|
1020
1020
|
border: 0;
|
|
1021
1021
|
border-radius: var(--floe-radius-card);
|
|
1022
|
-
/*
|
|
1023
|
-
background:
|
|
1022
|
+
/* An active editor uses the clean floating plane; elevation locates it. */
|
|
1023
|
+
background: var(--floe-plane-float);
|
|
1024
1024
|
color: var(--floe-ink);
|
|
1025
1025
|
font-size: var(--floe-type-body);
|
|
1026
1026
|
line-height: var(--floe-line-body);
|
|
@@ -1061,6 +1061,13 @@
|
|
|
1061
1061
|
.floe-prompt-card-input::placeholder { color: var(--floe-field-placeholder); }
|
|
1062
1062
|
.floe-prompt-card-actions { display: flex; align-items: center; gap: var(--floe-gap-control); padding: var(--floe-pad-control) 0 0; }
|
|
1063
1063
|
.floe-prompt-card-references { min-width: 0; }
|
|
1064
|
+
.floe-prompt-card-references [data-floe-prompt-reference] {
|
|
1065
|
+
border: 0;
|
|
1066
|
+
border-radius: var(--floe-radius-xs);
|
|
1067
|
+
background: var(--floe-well-strong);
|
|
1068
|
+
color: var(--floe-ink);
|
|
1069
|
+
box-shadow: none;
|
|
1070
|
+
}
|
|
1064
1071
|
.floe-prompt-card-tools { display: flex; align-items: center; flex: 1; min-width: 0; gap: var(--floe-gap-inline); }
|
|
1065
1072
|
.floe-prompt-card-tools > .relative { flex: 1; min-width: 0; }
|
|
1066
1073
|
.floe-prompt-card .floe-prompt-card-attach { flex-shrink: 0; width: var(--floe-control-height-sm); height: var(--floe-control-height-sm); border-radius: var(--floe-radius-sm); }
|