@floegence/floe-webapp-core 0.90.12 → 0.91.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 +63 -0
- package/dist/components/ui/PromptCard.js +312 -0
- package/dist/components/ui/Select.d.ts +2 -0
- package/dist/components/ui/Select.js +36 -35
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/floe.css +72 -0
- package/dist/full.js +294 -292
- package/dist/styles.css +1 -1
- package/dist/ui.js +87 -85
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type JSX } from 'solid-js';
|
|
2
|
+
import { type SelectOption } from './Select';
|
|
3
|
+
export interface PromptCardProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Viewport coordinates captured by the host at the contextual action. */
|
|
6
|
+
anchor?: Readonly<{
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}> | null;
|
|
10
|
+
viewportInsets?: Readonly<{
|
|
11
|
+
top?: number;
|
|
12
|
+
right?: number;
|
|
13
|
+
bottom?: number;
|
|
14
|
+
left?: number;
|
|
15
|
+
}>;
|
|
16
|
+
/** Defaults to the trigger's surface. Viewport scope is an explicit host choice. */
|
|
17
|
+
portalScope?: 'surface' | 'viewport';
|
|
18
|
+
owner?: HTMLElement;
|
|
19
|
+
title: string;
|
|
20
|
+
icon?: JSX.Element;
|
|
21
|
+
closeLabel: string;
|
|
22
|
+
question: JSX.Element;
|
|
23
|
+
value: string;
|
|
24
|
+
onValueChange: (value: string) => void;
|
|
25
|
+
inputLabel: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
submitLabel: string;
|
|
28
|
+
onSubmit: () => void;
|
|
29
|
+
onClose: () => void;
|
|
30
|
+
busy?: boolean;
|
|
31
|
+
inputDisabled?: boolean;
|
|
32
|
+
submitDisabled?: boolean;
|
|
33
|
+
autoFocus?: boolean;
|
|
34
|
+
references?: JSX.Element;
|
|
35
|
+
/** Optional host-owned files; selection, paste and drop share this callback. */
|
|
36
|
+
attachment?: Readonly<{
|
|
37
|
+
label: string;
|
|
38
|
+
accept?: string;
|
|
39
|
+
onFiles: (files: File[]) => void;
|
|
40
|
+
}>;
|
|
41
|
+
/** Compact host-owned choice, for example an assistant model. */
|
|
42
|
+
selection?: Readonly<{
|
|
43
|
+
label: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
value: string;
|
|
46
|
+
options: readonly SelectOption[];
|
|
47
|
+
onChange: (value: string) => void;
|
|
48
|
+
loading?: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
onRetry?: () => void;
|
|
51
|
+
}>;
|
|
52
|
+
/** Host input/scroll ownership attributes for the constrained reading viewport. */
|
|
53
|
+
bodyProps?: JSX.HTMLAttributes<HTMLDivElement>;
|
|
54
|
+
feedback?: JSX.Element;
|
|
55
|
+
/** Additional portalled content that belongs to this interaction. */
|
|
56
|
+
containsTarget?: (target: EventTarget | null) => boolean;
|
|
57
|
+
onActivate?: () => void;
|
|
58
|
+
editorRef?: (element: HTMLTextAreaElement) => void;
|
|
59
|
+
class?: string;
|
|
60
|
+
zIndex?: number;
|
|
61
|
+
}
|
|
62
|
+
/** A short contextual input. The host owns the draft and asynchronous result. */
|
|
63
|
+
export declare function PromptCard(props: PromptCardProps): JSX.Element;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { createComponent as u, Portal as xe, use as Y, setAttribute as x, insert as d, spread as ye, mergeProps as we, effect as N, setStyleProperty as C, className as Se, template as O, delegateEvents as Ce } from "solid-js/web";
|
|
2
|
+
import { createUniqueId as Me, createSignal as z, onCleanup as p, createMemo as F, createEffect as W, untrack as G, Show as $ } from "solid-js";
|
|
3
|
+
import { useOverlayMask as Pe } from "../../hooks/useOverlayMask.js";
|
|
4
|
+
import { deferAfterPaint as de } from "../../utils/defer.js";
|
|
5
|
+
import { ensureSurfacePortalInteractionTracking as ke, resolveSurfacePortalHost as $e, resolveSurfacePortalScale as De, resolveSurfacePortalBoundaryRect as Ee, projectSurfacePortalPosition as Ae, readFreshInteractionSnapshot as Le, resolveSurfacePortalMount as Te, isSurfacePortalMode as Ie } from "./dialogSurfaceScope.js";
|
|
6
|
+
import { cn as ue } from "../../utils/cn.js";
|
|
7
|
+
import { readViewportSnapshot as ze, observeViewport as Fe } from "../../viewport.js";
|
|
8
|
+
import { X as Oe, Paperclip as Be, ArrowUp as He } from "../icons/index.js";
|
|
9
|
+
import { Button as J } from "./Button.js";
|
|
10
|
+
import { Select as Re } from "./Select.js";
|
|
11
|
+
import { createFloatingPresence as Ve } from "./floatingPresence.js";
|
|
12
|
+
var qe = /* @__PURE__ */ O("<span class=floe-prompt-card-icon aria-hidden=true>"), _e = /* @__PURE__ */ O("<div class=floe-prompt-card-references>"), Ne = /* @__PURE__ */ O("<input type=file multiple hidden tabindex=-1>"), We = /* @__PURE__ */ O("<div class=floe-prompt-card-feedback>"), Xe = /* @__PURE__ */ O("<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-question></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 nt(t) {
|
|
14
|
+
ke();
|
|
15
|
+
const Z = Me(), [fe, ee] = z(!1), [me, te] = z(!1), c = () => t.busy || fe();
|
|
16
|
+
let ne = !1;
|
|
17
|
+
p(() => {
|
|
18
|
+
ne = !0;
|
|
19
|
+
});
|
|
20
|
+
const [h, he] = z(ze(window)), [D, ge] = z(), [X, ve] = z({
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0
|
|
23
|
+
}), be = F((n) => t.open ? t.anchor : n), y = Ve({
|
|
24
|
+
open: () => t.open,
|
|
25
|
+
element: D
|
|
26
|
+
});
|
|
27
|
+
let M, K, E = !1, U, B;
|
|
28
|
+
const j = (n) => {
|
|
29
|
+
t.open && !c() && !t.inputDisabled && n.length && t.attachment?.onFiles(n);
|
|
30
|
+
};
|
|
31
|
+
W(() => {
|
|
32
|
+
(!t.open || c() || t.inputDisabled) && te(!1);
|
|
33
|
+
});
|
|
34
|
+
const A = F(() => !y.mounted() || t.portalScope === "viewport" ? {
|
|
35
|
+
host: null,
|
|
36
|
+
boundaryHost: null,
|
|
37
|
+
mountHost: null,
|
|
38
|
+
mode: "global"
|
|
39
|
+
} : $e({
|
|
40
|
+
owner: t.owner
|
|
41
|
+
})), H = () => Ie(A()), L = F(() => (h(), X(), H() ? De(A()) : {
|
|
42
|
+
x: h().fixedScale,
|
|
43
|
+
y: h().fixedScale
|
|
44
|
+
}));
|
|
45
|
+
W(() => {
|
|
46
|
+
y.mounted() && p(Fe(window, he));
|
|
47
|
+
}), W(() => {
|
|
48
|
+
const n = D();
|
|
49
|
+
if (!y.mounted() || !n) return;
|
|
50
|
+
const a = () => ve((s) => {
|
|
51
|
+
const f = n.offsetWidth, m = n.offsetHeight;
|
|
52
|
+
return s.width === f && s.height === m ? s : {
|
|
53
|
+
width: f,
|
|
54
|
+
height: m
|
|
55
|
+
};
|
|
56
|
+
}), i = new ResizeObserver(a);
|
|
57
|
+
i.observe(n), a(), p(() => i.disconnect());
|
|
58
|
+
});
|
|
59
|
+
const w = F(() => {
|
|
60
|
+
const n = h(), a = H() ? Ee(A()) : n.visible, i = n.visible.width < 640 ? 8 : 12, s = t.viewportInsets, f = Math.max(n.visible.left, a.left) + Math.max(n.safeArea.left, s?.left ?? 0) + i, m = Math.max(n.visible.top, a.top) + Math.max(n.safeArea.top, s?.top ?? 0) + i, S = Math.min(n.visible.right, a.right) - Math.max(n.safeArea.right, s?.right ?? 0) - i, P = Math.min(n.visible.bottom, a.bottom) - Math.max(n.safeArea.bottom, s?.bottom ?? 0) - i, o = Math.max(0, S - f), g = Math.min(X().width * L().x, o), k = Math.max(0, P - m), e = Math.min(X().height * L().y, k), r = be(), l = (V, q, _) => Math.max(q, Math.min(V, _)), v = l(r ? r.x + 8 : f + (o - g) / 2, f, S - g), b = !r || r.y + 8 + e <= P, T = r ? b ? r.y + 8 : r.y - e - 8 : m + Math.max(0, (k - e) * 0.32), I = l(T, m, P - e);
|
|
61
|
+
return {
|
|
62
|
+
x: v,
|
|
63
|
+
y: I,
|
|
64
|
+
availableWidth: o,
|
|
65
|
+
maxHeight: k,
|
|
66
|
+
side: !r || I !== T ? "edge" : b ? "bottom" : "top",
|
|
67
|
+
originX: r ? l(r.x - v, 16, g - 16) : g / 2
|
|
68
|
+
};
|
|
69
|
+
}), ae = F(() => H() ? Ae(w(), A()) : {
|
|
70
|
+
x: (w().x + h().fixedOffset.left) / h().fixedScale,
|
|
71
|
+
y: (w().y + h().fixedOffset.top) / h().fixedScale
|
|
72
|
+
}), R = (n) => {
|
|
73
|
+
c() || !t.open || E || (t.onClose(), n && de(() => G(() => {
|
|
74
|
+
!t.open && K?.isConnected && K.focus({
|
|
75
|
+
preventScroll: !0
|
|
76
|
+
});
|
|
77
|
+
})));
|
|
78
|
+
};
|
|
79
|
+
W(() => {
|
|
80
|
+
if (!t.open) return;
|
|
81
|
+
const n = document.activeElement, i = t.owner ?? Le()?.target?.closest("button, a[href], input, [tabindex]") ?? (n instanceof HTMLElement && n !== document.body ? n : void 0);
|
|
82
|
+
i && !G(D)?.contains(i) && !t.containsTarget?.(i) && (K = i), queueMicrotask(() => {
|
|
83
|
+
!t.open || t.autoFocus === !1 || !M?.isConnected || (M.focus({
|
|
84
|
+
preventScroll: !0
|
|
85
|
+
}), M.setSelectionRange(M.value.length, M.value.length));
|
|
86
|
+
});
|
|
87
|
+
}), Pe({
|
|
88
|
+
open: () => t.open,
|
|
89
|
+
root: D,
|
|
90
|
+
containsTarget: (n) => !!(n instanceof Node && D()?.contains(n)) || !!t.containsTarget?.(n) || !!(n instanceof Node && document.getElementById(B?.getAttribute("aria-controls") ?? "")?.parentElement?.contains(n)),
|
|
91
|
+
onClose: () => R(!0),
|
|
92
|
+
onInteractOutside: (n) => {
|
|
93
|
+
n.type === "pointerdown" && R(!1);
|
|
94
|
+
},
|
|
95
|
+
// Related previews belong to pointer ownership, but own their Escape command.
|
|
96
|
+
closeOnEscape: "none",
|
|
97
|
+
escapeKeyPhase: "bubble",
|
|
98
|
+
lockBodyScroll: !1,
|
|
99
|
+
trapFocus: !1,
|
|
100
|
+
autoFocus: !1,
|
|
101
|
+
restoreFocus: !1,
|
|
102
|
+
blockHotkeys: !1
|
|
103
|
+
});
|
|
104
|
+
const ie = () => {
|
|
105
|
+
!t.open || c() || t.submitDisabled || (ee(!0), de(() => G(() => {
|
|
106
|
+
if (!ne)
|
|
107
|
+
try {
|
|
108
|
+
t.open && t.onSubmit();
|
|
109
|
+
} finally {
|
|
110
|
+
ee(!1);
|
|
111
|
+
}
|
|
112
|
+
})));
|
|
113
|
+
};
|
|
114
|
+
return u($, {
|
|
115
|
+
get when() {
|
|
116
|
+
return y.mounted();
|
|
117
|
+
},
|
|
118
|
+
get children() {
|
|
119
|
+
return u(xe, {
|
|
120
|
+
get mount() {
|
|
121
|
+
return Te(A());
|
|
122
|
+
},
|
|
123
|
+
get children() {
|
|
124
|
+
var n = Xe(), a = n.firstChild, i = a.firstChild, s = i.firstChild, f = i.nextSibling, m = f.firstChild, S = m.nextSibling, P = S.firstChild, o = P.firstChild, g = P.nextSibling, k = g.firstChild;
|
|
125
|
+
return a.$$keydown = (e) => {
|
|
126
|
+
e.key !== "Escape" || e.defaultPrevented || e.isComposing || E || B?.getAttribute("aria-expanded") === "true" && B.contains(e.target) || (e.preventDefault(), e.stopPropagation(), R(!0));
|
|
127
|
+
}, a.$$focusin = () => t.onActivate?.(), a.$$pointerdown = () => t.onActivate?.(), Y(ge, a), x(a, "aria-labelledby", Z), d(i, u($, {
|
|
128
|
+
get when() {
|
|
129
|
+
return t.icon;
|
|
130
|
+
},
|
|
131
|
+
get children() {
|
|
132
|
+
var e = qe();
|
|
133
|
+
return d(e, () => t.icon), e;
|
|
134
|
+
}
|
|
135
|
+
}), s), x(s, "id", Z), d(s, () => t.title), d(i, u(J, {
|
|
136
|
+
variant: "ghost",
|
|
137
|
+
size: "icon",
|
|
138
|
+
icon: Oe,
|
|
139
|
+
class: "floe-prompt-card-close",
|
|
140
|
+
get disabled() {
|
|
141
|
+
return c();
|
|
142
|
+
},
|
|
143
|
+
get title() {
|
|
144
|
+
return t.closeLabel;
|
|
145
|
+
},
|
|
146
|
+
get "aria-label"() {
|
|
147
|
+
return t.closeLabel;
|
|
148
|
+
},
|
|
149
|
+
onClick: () => R(!0)
|
|
150
|
+
}), null), ye(f, we(() => t.bodyProps, {
|
|
151
|
+
get class() {
|
|
152
|
+
return ue("floe-prompt-card-body", t.bodyProps?.class);
|
|
153
|
+
}
|
|
154
|
+
}), !1, !0), d(m, () => t.question), S.addEventListener("drop", (e) => {
|
|
155
|
+
!t.attachment || !e.dataTransfer?.files.length || (e.preventDefault(), j(Array.from(e.dataTransfer.files)));
|
|
156
|
+
}), S.addEventListener("dragover", (e) => {
|
|
157
|
+
t.attachment && !c() && !t.inputDisabled && e.dataTransfer?.types.includes("Files") && e.preventDefault();
|
|
158
|
+
}), o.$$keydown = (e) => {
|
|
159
|
+
e.key === "Enter" && !e.shiftKey && !e.isComposing && !E && (e.preventDefault(), ie());
|
|
160
|
+
}, o.addEventListener("compositionend", (e) => {
|
|
161
|
+
E = !1, t.onValueChange(e.currentTarget.value);
|
|
162
|
+
}), o.addEventListener("compositionupdate", (e) => t.onValueChange(e.currentTarget.value)), o.addEventListener("compositionstart", () => {
|
|
163
|
+
E = !0;
|
|
164
|
+
}), o.$$input = (e) => t.onValueChange(e.currentTarget.value), o.addEventListener("paste", (e) => {
|
|
165
|
+
!t.attachment || !e.clipboardData?.files.length || (e.preventDefault(), j(Array.from(e.clipboardData.files)));
|
|
166
|
+
}), Y((e) => {
|
|
167
|
+
M = e, t.editorRef?.(e);
|
|
168
|
+
}, o), d(S, u($, {
|
|
169
|
+
get when() {
|
|
170
|
+
return t.references;
|
|
171
|
+
},
|
|
172
|
+
get children() {
|
|
173
|
+
var e = _e();
|
|
174
|
+
return d(e, () => t.references), N(() => e.inert = !!c()), e;
|
|
175
|
+
}
|
|
176
|
+
}), g), d(k, u($, {
|
|
177
|
+
get when() {
|
|
178
|
+
return t.attachment;
|
|
179
|
+
},
|
|
180
|
+
get children() {
|
|
181
|
+
return [(() => {
|
|
182
|
+
var e = Ne();
|
|
183
|
+
e.addEventListener("change", (l) => {
|
|
184
|
+
j(Array.from(l.currentTarget.files ?? [])), l.currentTarget.value = "";
|
|
185
|
+
});
|
|
186
|
+
var r = U;
|
|
187
|
+
return typeof r == "function" ? Y(r, e) : U = e, N((l) => {
|
|
188
|
+
var v = t.attachment?.accept, b = c() || t.inputDisabled;
|
|
189
|
+
return v !== l.e && x(e, "accept", l.e = v), b !== l.t && (e.disabled = l.t = b), l;
|
|
190
|
+
}, {
|
|
191
|
+
e: void 0,
|
|
192
|
+
t: void 0
|
|
193
|
+
}), e;
|
|
194
|
+
})(), u(J, {
|
|
195
|
+
variant: "ghost",
|
|
196
|
+
size: "icon",
|
|
197
|
+
icon: Be,
|
|
198
|
+
class: "floe-prompt-card-attach",
|
|
199
|
+
get disabled() {
|
|
200
|
+
return c() || t.inputDisabled;
|
|
201
|
+
},
|
|
202
|
+
get "aria-label"() {
|
|
203
|
+
return t.attachment?.label;
|
|
204
|
+
},
|
|
205
|
+
get title() {
|
|
206
|
+
return t.attachment?.label;
|
|
207
|
+
},
|
|
208
|
+
onClick: () => U?.click()
|
|
209
|
+
})];
|
|
210
|
+
}
|
|
211
|
+
}), null), d(k, u($, {
|
|
212
|
+
get when() {
|
|
213
|
+
return t.selection;
|
|
214
|
+
},
|
|
215
|
+
get children() {
|
|
216
|
+
return u(Re, {
|
|
217
|
+
ref: (e) => {
|
|
218
|
+
B = e;
|
|
219
|
+
},
|
|
220
|
+
class: "floe-prompt-card-selection",
|
|
221
|
+
get open() {
|
|
222
|
+
return me();
|
|
223
|
+
},
|
|
224
|
+
onOpenChange: te,
|
|
225
|
+
get zIndex() {
|
|
226
|
+
return (t.zIndex ?? 100) + 1;
|
|
227
|
+
},
|
|
228
|
+
get ariaLabel() {
|
|
229
|
+
return t.selection.label;
|
|
230
|
+
},
|
|
231
|
+
get placeholder() {
|
|
232
|
+
return t.selection.placeholder;
|
|
233
|
+
},
|
|
234
|
+
get value() {
|
|
235
|
+
return t.selection.value;
|
|
236
|
+
},
|
|
237
|
+
get options() {
|
|
238
|
+
return t.selection.options;
|
|
239
|
+
},
|
|
240
|
+
onChange: (e) => t.selection.onChange(e),
|
|
241
|
+
get disabled() {
|
|
242
|
+
return c() || t.inputDisabled;
|
|
243
|
+
},
|
|
244
|
+
get loading() {
|
|
245
|
+
return t.selection.loading;
|
|
246
|
+
},
|
|
247
|
+
get error() {
|
|
248
|
+
return t.selection.error;
|
|
249
|
+
},
|
|
250
|
+
get onRetry() {
|
|
251
|
+
return t.selection.onRetry;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}), null), d(g, u(J, {
|
|
256
|
+
variant: "primary",
|
|
257
|
+
size: "icon",
|
|
258
|
+
icon: He,
|
|
259
|
+
class: "floe-prompt-card-submit",
|
|
260
|
+
get disabled() {
|
|
261
|
+
return t.submitDisabled;
|
|
262
|
+
},
|
|
263
|
+
get loading() {
|
|
264
|
+
return c();
|
|
265
|
+
},
|
|
266
|
+
get "aria-busy"() {
|
|
267
|
+
return c() ? "true" : "false";
|
|
268
|
+
},
|
|
269
|
+
get title() {
|
|
270
|
+
return t.submitLabel;
|
|
271
|
+
},
|
|
272
|
+
get "aria-label"() {
|
|
273
|
+
return t.submitLabel;
|
|
274
|
+
},
|
|
275
|
+
onClick: ie
|
|
276
|
+
}), null), d(f, u($, {
|
|
277
|
+
get when() {
|
|
278
|
+
return t.feedback;
|
|
279
|
+
},
|
|
280
|
+
get children() {
|
|
281
|
+
var e = We();
|
|
282
|
+
return d(e, () => t.feedback), e;
|
|
283
|
+
}
|
|
284
|
+
}), null), N((e) => {
|
|
285
|
+
var r = H() ? "absolute" : "fixed", l = `${ae().x}px`, v = `${ae().y}px`, b = `${w().availableWidth / L().x}px`, T = `${w().maxHeight / L().y}px`, I = `${w().originX / L().x}px`, Q = t.zIndex ?? 100, V = ue("floe-prompt-card floe-floating-presence", t.class), q = w().side, _ = y.state(), re = y.exiting(), oe = y.exiting() ? "true" : void 0, le = t.inputLabel, ce = t.placeholder, se = c() || t.inputDisabled;
|
|
286
|
+
return r !== e.e && C(n, "position", e.e = r), l !== e.t && C(n, "left", e.t = l), v !== e.a && C(n, "top", e.a = v), b !== e.o && C(n, "--floe-prompt-max-width", e.o = b), T !== e.i && C(n, "--floe-prompt-max-height", e.i = T), I !== e.n && C(n, "--floe-prompt-origin-x", e.n = I), Q !== e.s && C(n, "z-index", e.s = Q), V !== e.h && Se(a, e.h = V), q !== e.r && x(a, "data-floating-side", e.r = q), _ !== e.d && x(a, "data-floating-presence", e.d = _), re !== e.l && (a.inert = e.l = re), oe !== e.u && x(a, "aria-hidden", e.u = oe), le !== e.c && x(o, "aria-label", e.c = le), ce !== e.w && x(o, "placeholder", e.w = ce), se !== e.m && (o.disabled = e.m = se), e;
|
|
287
|
+
}, {
|
|
288
|
+
e: void 0,
|
|
289
|
+
t: void 0,
|
|
290
|
+
a: void 0,
|
|
291
|
+
o: void 0,
|
|
292
|
+
i: void 0,
|
|
293
|
+
n: void 0,
|
|
294
|
+
s: void 0,
|
|
295
|
+
h: void 0,
|
|
296
|
+
r: void 0,
|
|
297
|
+
d: void 0,
|
|
298
|
+
l: void 0,
|
|
299
|
+
u: void 0,
|
|
300
|
+
c: void 0,
|
|
301
|
+
w: void 0,
|
|
302
|
+
m: void 0
|
|
303
|
+
}), N(() => o.value = t.value), n;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
Ce(["pointerdown", "focusin", "keydown", "input"]);
|
|
310
|
+
export {
|
|
311
|
+
nt as PromptCard
|
|
312
|
+
};
|
|
@@ -19,6 +19,8 @@ export interface SelectBaseProps {
|
|
|
19
19
|
options: readonly SelectOption[];
|
|
20
20
|
placeholder?: string;
|
|
21
21
|
class?: string;
|
|
22
|
+
/** Optional layer for choices nested in elevated overlays. */
|
|
23
|
+
zIndex?: number;
|
|
22
24
|
open?: boolean;
|
|
23
25
|
defaultOpen?: boolean;
|
|
24
26
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent as c, mergeProps as
|
|
1
|
+
import { createComponent as c, mergeProps as I, insert as o, spread as te, memo as z, effect as P, use as le, setAttribute as m, className as ve, template as w, delegateEvents as ge } from "solid-js/web";
|
|
2
2
|
import { createUniqueId as me, createSignal as B, createMemo as he, createEffect as N, untrack as be, onCleanup as ae, onMount as ye, Show as V, For as Q } from "solid-js";
|
|
3
3
|
import { cn as re } from "../../utils/cn.js";
|
|
4
4
|
import { useFloeLocale as we } from "../../context/LocaleContext.js";
|
|
@@ -7,32 +7,32 @@ import { SurfaceFloatingLayer as xe } from "./SurfaceFloatingLayer.js";
|
|
|
7
7
|
import { createFloatingPresence as ke } from "./floatingPresence.js";
|
|
8
8
|
import { calculateMenuPosition as Ve } from "./menuUtils.js";
|
|
9
9
|
import { useFormControl as Le, joinAriaIds as Oe } from "./formFieldContext.js";
|
|
10
|
-
import { createControllableValue as
|
|
10
|
+
import { createControllableValue as K } from "./controllable.js";
|
|
11
11
|
import { ChevronDown as $e, Check as Ee } from "../icons/index.js";
|
|
12
12
|
import { resolveSurfacePortalBoundaryRect as De, resolveSurfacePortalHost as Pe } from "./dialogSurfaceScope.js";
|
|
13
|
-
var Se = /* @__PURE__ */ w("<input>"), _e = /* @__PURE__ */ w("<option value>"), qe = /* @__PURE__ */ w('<div role=status class="px-2 py-2 text-caption">'), Ae = /* @__PURE__ */ w("<button type=button>"), Fe = /* @__PURE__ */ w('<div role=alert class="p-2 text-error">'), Te = /* @__PURE__ */ w('<div role=status class="p-2 text-caption">'), Be = /* @__PURE__ */ w('<div class="floe-floating-presence floe-floating-menu rounded-panel border border-[var(--floe-line)] bg-popover text-popover-foreground shadow-[var(--floe-elevation-float)] p-1"data-floe-surface=floating><div role=listbox class="max-h-64 overflow-y-auto"data-floe-local-interaction-surface=true>'),
|
|
13
|
+
var Se = /* @__PURE__ */ w("<input>"), _e = /* @__PURE__ */ w("<option value>"), qe = /* @__PURE__ */ w('<div role=status class="px-2 py-2 text-caption">'), Ae = /* @__PURE__ */ w("<button type=button>"), Fe = /* @__PURE__ */ w('<div role=alert class="p-2 text-error">'), Te = /* @__PURE__ */ w('<div role=status class="p-2 text-caption">'), Be = /* @__PURE__ */ w('<div class="floe-floating-presence floe-floating-menu rounded-panel border border-[var(--floe-line)] bg-popover text-popover-foreground shadow-[var(--floe-elevation-float)] p-1"data-floe-surface=floating><div role=listbox class="max-h-64 overflow-y-auto"data-floe-local-interaction-surface=true>'), Ie = /* @__PURE__ */ w('<div class="relative min-w-0"><select tabindex=-1 aria-hidden=true class="sr-only pointer-events-none">'), Re = /* @__PURE__ */ w("<button><span class=truncate>"), ze = /* @__PURE__ */ w("<option selected>"), Ke = /* @__PURE__ */ w("<option>"), Me = /* @__PURE__ */ w('<div role=option><span class="h-3.5 w-3.5 shrink-0">');
|
|
14
14
|
function U(e) {
|
|
15
|
-
const u = we(), g = Le(), b = me(), W = () => e.id ?? g.id ?? "select-" + b, S = "options-" + b, _ = () => e.disabled ?? g.disabled, q = () => e.readOnly ?? g.readOnly, [h, ne] =
|
|
15
|
+
const u = we(), g = Le(), b = me(), W = () => e.id ?? g.id ?? "select-" + b, S = "options-" + b, _ = () => e.disabled ?? g.disabled, q = () => e.readOnly ?? g.readOnly, [h, ne] = K({
|
|
16
16
|
value: () => e.open,
|
|
17
17
|
defaultValue: e.defaultOpen ?? !1,
|
|
18
18
|
onChange: (t) => e.onOpenChange?.(t)
|
|
19
|
-
}), [
|
|
19
|
+
}), [M, G] = B(""), [L, E] = B(-1), [ie, oe] = B({
|
|
20
20
|
x: 0,
|
|
21
21
|
y: 0
|
|
22
22
|
}), [ue, de] = B(200);
|
|
23
|
-
let x, O, k,
|
|
23
|
+
let x, O, k, R;
|
|
24
24
|
const D = ke({
|
|
25
25
|
open: h,
|
|
26
26
|
element: () => k
|
|
27
27
|
}), [se, ce] = B("bottom");
|
|
28
|
-
let
|
|
28
|
+
let H = "", J = 0;
|
|
29
29
|
const C = he(() => {
|
|
30
|
-
if (!e.searchable || e.filter === !1 || !
|
|
31
|
-
const t =
|
|
30
|
+
if (!e.searchable || e.filter === !1 || !M()) return e.options;
|
|
31
|
+
const t = M().toLocaleLowerCase(u.locale);
|
|
32
32
|
return e.options.filter((a) => [a.label, ...a.keywords ?? []].some((i) => i.toLocaleLowerCase(u.locale).includes(t)));
|
|
33
33
|
}), X = () => e.values.map((t) => e.options.find((a) => a.value === t)?.label ?? t).join(", "), y = (t) => {
|
|
34
34
|
t && (_() || q()) || (ne(t), t || G(""));
|
|
35
|
-
},
|
|
35
|
+
}, j = (t) => {
|
|
36
36
|
_() || q() || t.disabled || (e.onValuesChange(e.multiple ? e.values.includes(t.value) ? e.values.filter((a) => a !== t.value) : [...e.values, t.value] : [t.value]), e.multiple || y(!1), x?.focus({
|
|
37
37
|
preventScroll: !0
|
|
38
38
|
}));
|
|
@@ -55,7 +55,7 @@ function U(e) {
|
|
|
55
55
|
})), i = Ve(
|
|
56
56
|
t,
|
|
57
57
|
// The position layer is never transformed; motion belongs to its child.
|
|
58
|
-
|
|
58
|
+
R?.getBoundingClientRect() ?? k.getBoundingClientRect(),
|
|
59
59
|
u.direction === "rtl" ? "end" : "start",
|
|
60
60
|
a
|
|
61
61
|
);
|
|
@@ -78,7 +78,7 @@ function U(e) {
|
|
|
78
78
|
};
|
|
79
79
|
a();
|
|
80
80
|
const i = new ResizeObserver(a);
|
|
81
|
-
x && i.observe(x),
|
|
81
|
+
x && i.observe(x), R && i.observe(R), window.addEventListener("resize", a), window.addEventListener("scroll", a, !0), ae(() => {
|
|
82
82
|
cancelAnimationFrame(t), i.disconnect(), window.removeEventListener("resize", a), window.removeEventListener("scroll", a, !0);
|
|
83
83
|
});
|
|
84
84
|
}), Ce({
|
|
@@ -175,14 +175,14 @@ function U(e) {
|
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
if (t.key === "Enter" || !e.searchable && t.key === " ") {
|
|
178
|
-
t.preventDefault(), h() && C()[L()] ?
|
|
178
|
+
t.preventDefault(), h() && C()[L()] ? j(C()[L()]) : y(!0);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
if (!e.searchable && t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey) {
|
|
182
182
|
const a = Date.now();
|
|
183
|
-
|
|
184
|
-
const i = e.options.find((l) => !l.disabled && l.label.toLocaleLowerCase(u.locale).startsWith(
|
|
185
|
-
i && (t.preventDefault(), h() ? E(C().indexOf(i)) :
|
|
183
|
+
H = a - J > 700 ? t.key : H + t.key, J = a;
|
|
184
|
+
const i = e.options.find((l) => !l.disabled && l.label.toLocaleLowerCase(u.locale).startsWith(H.toLocaleLowerCase(u.locale)));
|
|
185
|
+
i && (t.preventDefault(), h() ? E(C().indexOf(i)) : j(i));
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
},
|
|
@@ -191,15 +191,15 @@ function U(e) {
|
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
193
|
return (() => {
|
|
194
|
-
var t =
|
|
194
|
+
var t = Ie(), a = t.firstChild;
|
|
195
195
|
o(t, c(V, {
|
|
196
196
|
get when() {
|
|
197
197
|
return e.searchable;
|
|
198
198
|
},
|
|
199
199
|
get fallback() {
|
|
200
200
|
return (() => {
|
|
201
|
-
var l =
|
|
202
|
-
return te(l,
|
|
201
|
+
var l = Re(), n = l.firstChild;
|
|
202
|
+
return te(l, I(Z, {
|
|
203
203
|
type: "button",
|
|
204
204
|
onClick: () => y(!h())
|
|
205
205
|
}), !1, !0), o(n, () => X() || e.placeholder || u.t("selectPlaceholder")), o(l, c($e, {
|
|
@@ -209,7 +209,7 @@ function U(e) {
|
|
|
209
209
|
},
|
|
210
210
|
get children() {
|
|
211
211
|
var l = Se();
|
|
212
|
-
return te(l,
|
|
212
|
+
return te(l, I(Z, {
|
|
213
213
|
type: "text",
|
|
214
214
|
autocomplete: "off",
|
|
215
215
|
get readOnly() {
|
|
@@ -220,7 +220,7 @@ function U(e) {
|
|
|
220
220
|
return e.placeholder ?? u.t("searchPlaceholder");
|
|
221
221
|
},
|
|
222
222
|
get value() {
|
|
223
|
-
return
|
|
223
|
+
return z(() => !!h())() ? M() : X();
|
|
224
224
|
},
|
|
225
225
|
onClick: () => y(!0),
|
|
226
226
|
onInput: (n) => {
|
|
@@ -234,7 +234,7 @@ function U(e) {
|
|
|
234
234
|
var i = O;
|
|
235
235
|
return typeof i == "function" ? le(i, a) : O = a, o(a, c(V, {
|
|
236
236
|
get when() {
|
|
237
|
-
return
|
|
237
|
+
return z(() => !e.multiple)() && !e.options.some((l) => l.value === "");
|
|
238
238
|
},
|
|
239
239
|
get children() {
|
|
240
240
|
var l = _e();
|
|
@@ -245,7 +245,7 @@ function U(e) {
|
|
|
245
245
|
return e.values.filter((l) => l !== "" && !e.options.some((n) => n.value === l));
|
|
246
246
|
},
|
|
247
247
|
children: (l) => (() => {
|
|
248
|
-
var n =
|
|
248
|
+
var n = ze();
|
|
249
249
|
return n.value = l, o(n, l), n;
|
|
250
250
|
})()
|
|
251
251
|
}), null), o(a, c(Q, {
|
|
@@ -253,7 +253,7 @@ function U(e) {
|
|
|
253
253
|
return e.options;
|
|
254
254
|
},
|
|
255
255
|
children: (l) => (() => {
|
|
256
|
-
var n =
|
|
256
|
+
var n = Ke();
|
|
257
257
|
return o(n, () => l.label), P((v) => {
|
|
258
258
|
var r = e.values.includes(l.value), f = l.disabled;
|
|
259
259
|
return r !== v.e && (n.selected = v.e = r), f !== v.t && (n.disabled = v.t = f), v;
|
|
@@ -273,13 +273,14 @@ function U(e) {
|
|
|
273
273
|
return ie();
|
|
274
274
|
},
|
|
275
275
|
layerRef: (l) => {
|
|
276
|
-
|
|
276
|
+
R = l;
|
|
277
277
|
},
|
|
278
278
|
get dir() {
|
|
279
279
|
return u.direction;
|
|
280
280
|
},
|
|
281
281
|
get style() {
|
|
282
282
|
return {
|
|
283
|
+
"z-index": e.zIndex,
|
|
283
284
|
width: "max-content",
|
|
284
285
|
"min-width": ue() + "px",
|
|
285
286
|
"max-width": "calc(100vw - 24px)"
|
|
@@ -316,8 +317,8 @@ function U(e) {
|
|
|
316
317
|
return C();
|
|
317
318
|
},
|
|
318
319
|
children: (r, f) => (() => {
|
|
319
|
-
var s =
|
|
320
|
-
return s.$$click = () =>
|
|
320
|
+
var s = Me(), $ = s.firstChild;
|
|
321
|
+
return s.$$click = () => j(r), s.$$pointermove = () => !r.disabled && E(f()), s.$$pointerdown = (d) => d.preventDefault(), o($, c(V, {
|
|
321
322
|
get when() {
|
|
322
323
|
return e.values.includes(r.value);
|
|
323
324
|
},
|
|
@@ -327,7 +328,7 @@ function U(e) {
|
|
|
327
328
|
});
|
|
328
329
|
}
|
|
329
330
|
})), o(s, (() => {
|
|
330
|
-
var d =
|
|
331
|
+
var d = z(() => !!e.renderOption);
|
|
331
332
|
return () => d() ? e.renderOption(r) : r.label;
|
|
332
333
|
})(), null), P((d) => {
|
|
333
334
|
var A = S + "-" + f(), F = e.values.includes(r.value), T = r.disabled || void 0, p = e.values.includes(r.value) ? "true" : void 0, ee = re("flex min-h-[var(--floe-row-height)] items-center gap-2 rounded-sm px-2 text-[length:var(--floe-type-control)]", L() === f() && "bg-accent text-accent-foreground", r.disabled ? "opacity-50" : "cursor-pointer");
|
|
@@ -342,7 +343,7 @@ function U(e) {
|
|
|
342
343
|
})()
|
|
343
344
|
})), o(l, c(V, {
|
|
344
345
|
get when() {
|
|
345
|
-
return
|
|
346
|
+
return z(() => !C().length && !e.loading)() && !e.error;
|
|
346
347
|
},
|
|
347
348
|
get children() {
|
|
348
349
|
var r = Te();
|
|
@@ -377,12 +378,12 @@ function U(e) {
|
|
|
377
378
|
})();
|
|
378
379
|
}
|
|
379
380
|
function tt(e) {
|
|
380
|
-
const [u, g] =
|
|
381
|
+
const [u, g] = K({
|
|
381
382
|
value: () => e.value,
|
|
382
383
|
defaultValue: e.defaultValue ?? "",
|
|
383
384
|
onChange: (b) => e.onChange?.(b)
|
|
384
385
|
});
|
|
385
|
-
return c(U,
|
|
386
|
+
return c(U, I(e, {
|
|
386
387
|
get values() {
|
|
387
388
|
return [u()];
|
|
388
389
|
},
|
|
@@ -393,12 +394,12 @@ function tt(e) {
|
|
|
393
394
|
}));
|
|
394
395
|
}
|
|
395
396
|
function lt(e) {
|
|
396
|
-
const [u, g] =
|
|
397
|
+
const [u, g] = K({
|
|
397
398
|
value: () => e.value,
|
|
398
399
|
defaultValue: e.defaultValue ?? "",
|
|
399
400
|
onChange: (b) => e.onChange?.(b)
|
|
400
401
|
});
|
|
401
|
-
return c(U,
|
|
402
|
+
return c(U, I(e, {
|
|
402
403
|
searchable: !0,
|
|
403
404
|
get values() {
|
|
404
405
|
return [u()];
|
|
@@ -410,12 +411,12 @@ function lt(e) {
|
|
|
410
411
|
}));
|
|
411
412
|
}
|
|
412
413
|
function at(e) {
|
|
413
|
-
const [u, g] =
|
|
414
|
+
const [u, g] = K({
|
|
414
415
|
value: () => e.value,
|
|
415
416
|
defaultValue: e.defaultValue ?? [],
|
|
416
417
|
onChange: (b) => e.onChange?.(b)
|
|
417
418
|
});
|
|
418
|
-
return c(U,
|
|
419
|
+
return c(U, I(e, {
|
|
419
420
|
multiple: !0,
|
|
420
421
|
get values() {
|
|
421
422
|
return u();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { PromptCard, type PromptCardProps } from './PromptCard';
|
|
1
2
|
export { FeedbackIndicator, type FeedbackIndicatorProps, type FeedbackIndicatorEntry } from './FeedbackIndicator';
|
|
2
3
|
export { Button, type ButtonProps, type ButtonVariant, type ButtonSize } from './Button';
|
|
3
4
|
export { StableText, type StableTextProps } from './StableText';
|