@designa8/vibedesign-v6 1.6.7
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/README.md +66 -0
- package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
- package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
- package/dist/index.cjs +3231 -0
- package/dist/index.js +3201 -0
- package/dist/styles.css +1810 -0
- package/package.json +109 -0
- package/src/atoms/AppLayout/AppLayout.tsx +537 -0
- package/src/atoms/AppLayout/index.ts +2 -0
- package/src/atoms/AppLayout/preview.tsx +75 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +399 -0
- package/src/atoms/AppSidebar/index.ts +2 -0
- package/src/atoms/AppSidebar/preview.tsx +214 -0
- package/src/atoms/AuthScreen/AuthScreen.tsx +226 -0
- package/src/atoms/AuthScreen/index.ts +2 -0
- package/src/atoms/AuthScreen/preview.tsx +10 -0
- package/src/atoms/Button/Button.tsx +71 -0
- package/src/atoms/Button/index.ts +2 -0
- package/src/atoms/Button/preview.tsx +71 -0
- package/src/atoms/ChatScreen/ChatScreen.tsx +629 -0
- package/src/atoms/ChatScreen/index.ts +2 -0
- package/src/atoms/ChatScreen/preview.tsx +239 -0
- package/src/atoms/Chip/Chip.tsx +121 -0
- package/src/atoms/Chip/index.ts +2 -0
- package/src/atoms/Chip/preview.tsx +99 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +95 -0
- package/src/atoms/FilterTabBar/index.ts +2 -0
- package/src/atoms/FilterTabBar/preview.tsx +92 -0
- package/src/atoms/Input/Input.tsx +139 -0
- package/src/atoms/Input/index.ts +2 -0
- package/src/atoms/Input/preview.tsx +97 -0
- package/src/atoms/Modal/Modal.tsx +144 -0
- package/src/atoms/Modal/index.ts +2 -0
- package/src/atoms/Modal/preview.tsx +111 -0
- package/src/atoms/NavItem/NavItem.tsx +316 -0
- package/src/atoms/NavItem/index.ts +2 -0
- package/src/atoms/NavItem/preview.tsx +125 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +626 -0
- package/src/atoms/PromptInputBar/index.ts +2 -0
- package/src/atoms/PromptInputBar/preview.tsx +85 -0
- package/src/atoms/TopNavbar/TopNavbar.tsx +400 -0
- package/src/atoms/TopNavbar/index.ts +2 -0
- package/src/atoms/TopNavbar/preview.tsx +117 -0
- package/src/atoms/UpgradeCard/UpgradeCard.tsx +65 -0
- package/src/atoms/UpgradeCard/index.ts +2 -0
- package/src/atoms/UpgradeCard/preview.tsx +25 -0
- package/src/atoms/WorkspaceMenu/WorkspaceMenu.tsx +216 -0
- package/src/atoms/WorkspaceMenu/index.ts +2 -0
- package/src/atoms/WorkspaceMenu/preview.tsx +44 -0
- package/src/index.ts +16 -0
- package/src/tokens.css +165 -0
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button } from "../Button";
|
|
3
|
+
import { Input } from "../Input";
|
|
4
|
+
|
|
5
|
+
export type PromptMode = "Build" | "Chat" | "Design";
|
|
6
|
+
|
|
7
|
+
export interface PromptInputBarModel {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
tier?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface PastedImage {
|
|
15
|
+
id: string;
|
|
16
|
+
url: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface PromptInputBarProps {
|
|
21
|
+
/** Placeholder text for the textarea */
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/** Current value of the textarea */
|
|
24
|
+
value?: string;
|
|
25
|
+
/** Controlled change handler */
|
|
26
|
+
onChange?: (value: string) => void;
|
|
27
|
+
/** Current mode shown in the Build/Chat dropdown */
|
|
28
|
+
mode?: PromptMode;
|
|
29
|
+
/** Called when mode selection changes */
|
|
30
|
+
onModeChange?: (mode: PromptMode) => void;
|
|
31
|
+
/** Called when the send button is clicked */
|
|
32
|
+
onSend?: (value: string, images: PastedImage[]) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Called when the + button is clicked.
|
|
35
|
+
* When onFilesSelected is also provided, onFilesSelected takes priority.
|
|
36
|
+
*/
|
|
37
|
+
onAttach?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* When provided, the attach (+) button opens a hidden file input.
|
|
40
|
+
* Takes priority over onAttach when both are supplied.
|
|
41
|
+
*/
|
|
42
|
+
onFilesSelected?: (files: FileList) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Called when the visual edits button is clicked.
|
|
45
|
+
* When undefined the Visual Edits button is NOT rendered.
|
|
46
|
+
*/
|
|
47
|
+
onVisualEdits?: () => void;
|
|
48
|
+
/** Called when the mic button is clicked */
|
|
49
|
+
onMic?: () => void;
|
|
50
|
+
/** Whether the send button is disabled */
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* When true: disables textarea + send button and replaces send with Stop.
|
|
54
|
+
*/
|
|
55
|
+
isStreaming?: boolean;
|
|
56
|
+
/** Called when the Stop button is clicked */
|
|
57
|
+
onStop?: () => void;
|
|
58
|
+
/** Available AI models to select from */
|
|
59
|
+
models?: PromptInputBarModel[];
|
|
60
|
+
/** Currently selected model id */
|
|
61
|
+
selectedModelId?: string;
|
|
62
|
+
/** Called when the user changes the selected model */
|
|
63
|
+
onModelChange?: (modelId: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Controlled list of pasted images. When provided, the component is in
|
|
66
|
+
* controlled image mode and will call onImagesChange instead of managing
|
|
67
|
+
* images internally.
|
|
68
|
+
*/
|
|
69
|
+
pastedImages?: PastedImage[];
|
|
70
|
+
/** Called when the internal image list changes (add / remove) */
|
|
71
|
+
onImagesChange?: (images: PastedImage[]) => void;
|
|
72
|
+
className?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const MODES: PromptMode[] = ["Build", "Chat", "Design"];
|
|
76
|
+
|
|
77
|
+
// Small inline X icon reused for the image remove button overlay
|
|
78
|
+
const XIcon = () => (
|
|
79
|
+
<svg
|
|
80
|
+
viewBox="0 0 16 16"
|
|
81
|
+
fill="none"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
strokeWidth={2.5}
|
|
84
|
+
strokeLinecap="round"
|
|
85
|
+
className="w-2.5 h-2.5"
|
|
86
|
+
aria-hidden="true"
|
|
87
|
+
>
|
|
88
|
+
<line x1="4" y1="4" x2="12" y2="12" />
|
|
89
|
+
<line x1="12" y1="4" x2="4" y2="12" />
|
|
90
|
+
</svg>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/** Generic hook: calls `onClose` when a mousedown/touchstart fires outside `ref`. */
|
|
94
|
+
function useClickOutside(
|
|
95
|
+
ref: React.RefObject<HTMLElement | null>,
|
|
96
|
+
onClose: () => void,
|
|
97
|
+
enabled: boolean,
|
|
98
|
+
) {
|
|
99
|
+
React.useEffect(() => {
|
|
100
|
+
if (!enabled) return;
|
|
101
|
+
const handler = (e: MouseEvent | TouchEvent) => {
|
|
102
|
+
if (ref.current && !ref.current.contains(e.target as Node)) {
|
|
103
|
+
onClose();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
document.addEventListener("mousedown", handler);
|
|
107
|
+
document.addEventListener("touchstart", handler);
|
|
108
|
+
return () => {
|
|
109
|
+
document.removeEventListener("mousedown", handler);
|
|
110
|
+
document.removeEventListener("touchstart", handler);
|
|
111
|
+
};
|
|
112
|
+
}, [ref, onClose, enabled]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const PromptInputBar = React.forwardRef<
|
|
116
|
+
HTMLDivElement,
|
|
117
|
+
PromptInputBarProps
|
|
118
|
+
>(
|
|
119
|
+
(
|
|
120
|
+
{
|
|
121
|
+
placeholder = "Ask Lovable...",
|
|
122
|
+
value,
|
|
123
|
+
onChange,
|
|
124
|
+
mode = "Build",
|
|
125
|
+
onModeChange,
|
|
126
|
+
onSend,
|
|
127
|
+
onAttach,
|
|
128
|
+
onFilesSelected,
|
|
129
|
+
onVisualEdits,
|
|
130
|
+
onMic,
|
|
131
|
+
disabled = false,
|
|
132
|
+
isStreaming = false,
|
|
133
|
+
onStop,
|
|
134
|
+
models,
|
|
135
|
+
selectedModelId,
|
|
136
|
+
onModelChange,
|
|
137
|
+
pastedImages,
|
|
138
|
+
onImagesChange,
|
|
139
|
+
className,
|
|
140
|
+
},
|
|
141
|
+
ref,
|
|
142
|
+
) => {
|
|
143
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
144
|
+
const [internalImages, setInternalImages] = React.useState<PastedImage[]>([]);
|
|
145
|
+
const [modeOpen, setModeOpen] = React.useState(false);
|
|
146
|
+
const [modelOpen, setModelOpen] = React.useState(false);
|
|
147
|
+
|
|
148
|
+
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
|
149
|
+
const modeRef = React.useRef<HTMLDivElement>(null);
|
|
150
|
+
const modelRef = React.useRef<HTMLDivElement>(null);
|
|
151
|
+
|
|
152
|
+
// Close each dropdown when a click/touch lands outside its container
|
|
153
|
+
useClickOutside(modeRef, React.useCallback(() => setModeOpen(false), []), modeOpen);
|
|
154
|
+
useClickOutside(modelRef, React.useCallback(() => setModelOpen(false), []), modelOpen);
|
|
155
|
+
|
|
156
|
+
const textValue = value !== undefined ? value : internalValue;
|
|
157
|
+
const images = pastedImages !== undefined ? pastedImages : internalImages;
|
|
158
|
+
|
|
159
|
+
const selectedModel = models?.find((m) => m.id === selectedModelId) ?? models?.[0];
|
|
160
|
+
|
|
161
|
+
/** Add one or more image files to the image list. */
|
|
162
|
+
const addImageFiles = React.useCallback(
|
|
163
|
+
(files: File[]) => {
|
|
164
|
+
const next: PastedImage[] = files
|
|
165
|
+
.filter((f) => f.type.startsWith("image/"))
|
|
166
|
+
.map((f) => ({
|
|
167
|
+
id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
168
|
+
url: URL.createObjectURL(f),
|
|
169
|
+
name: f.name || "image",
|
|
170
|
+
}));
|
|
171
|
+
if (next.length === 0) return;
|
|
172
|
+
const updated = [...images, ...next];
|
|
173
|
+
if (pastedImages !== undefined) {
|
|
174
|
+
onImagesChange?.(updated);
|
|
175
|
+
} else {
|
|
176
|
+
setInternalImages(updated);
|
|
177
|
+
onImagesChange?.(updated);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
[images, pastedImages, onImagesChange],
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
/** Remove an image by id and revoke its object URL to avoid memory leaks. */
|
|
184
|
+
const removeImage = React.useCallback(
|
|
185
|
+
(id: string) => {
|
|
186
|
+
const target = images.find((img) => img.id === id);
|
|
187
|
+
if (target) URL.revokeObjectURL(target.url);
|
|
188
|
+
const updated = images.filter((img) => img.id !== id);
|
|
189
|
+
if (pastedImages !== undefined) {
|
|
190
|
+
onImagesChange?.(updated);
|
|
191
|
+
} else {
|
|
192
|
+
setInternalImages(updated);
|
|
193
|
+
onImagesChange?.(updated);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
[images, pastedImages, onImagesChange],
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
200
|
+
if (value === undefined) setInternalValue(e.target.value);
|
|
201
|
+
onChange?.(e.target.value);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const handleSend = () => {
|
|
205
|
+
if (!textValue.trim() && images.length === 0) return;
|
|
206
|
+
onSend?.(textValue, images);
|
|
207
|
+
if (value === undefined) setInternalValue("");
|
|
208
|
+
if (pastedImages !== undefined) {
|
|
209
|
+
onImagesChange?.([]);
|
|
210
|
+
} else {
|
|
211
|
+
internalImages.forEach((img) => URL.revokeObjectURL(img.url));
|
|
212
|
+
setInternalImages([]);
|
|
213
|
+
onImagesChange?.([]);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
218
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
219
|
+
e.preventDefault();
|
|
220
|
+
handleSend();
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/** Intercept paste events to capture image data. */
|
|
225
|
+
const handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
226
|
+
const files = Array.from(e.clipboardData.items)
|
|
227
|
+
.filter((item) => item.kind === "file" && item.type.startsWith("image/"))
|
|
228
|
+
.map((item) => item.getAsFile())
|
|
229
|
+
.filter((f): f is File => f !== null);
|
|
230
|
+
if (files.length > 0) {
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
addImageFiles(files);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const handleAttachClick = () => {
|
|
237
|
+
if (onFilesSelected) {
|
|
238
|
+
fileInputRef.current?.click();
|
|
239
|
+
} else {
|
|
240
|
+
onAttach?.();
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
245
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
246
|
+
onFilesSelected?.(e.target.files);
|
|
247
|
+
e.target.value = "";
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const canSend =
|
|
252
|
+
(textValue.trim().length > 0 || images.length > 0) && !disabled && !isStreaming;
|
|
253
|
+
const textareaDisabled = disabled || isStreaming;
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<div ref={ref} className={["w-full", className].filter(Boolean).join(" ")}>
|
|
257
|
+
{/* Hidden file input for the attach button */}
|
|
258
|
+
{onFilesSelected && (
|
|
259
|
+
<Input
|
|
260
|
+
ref={fileInputRef}
|
|
261
|
+
type="file"
|
|
262
|
+
multiple
|
|
263
|
+
aria-hidden="true"
|
|
264
|
+
tabIndex={-1}
|
|
265
|
+
className="sr-only"
|
|
266
|
+
onChange={handleFileInputChange}
|
|
267
|
+
/>
|
|
268
|
+
)}
|
|
269
|
+
|
|
270
|
+
{/* Outer container */}
|
|
271
|
+
<div className="w-full rounded-xl bg-canvas shadow-card border border-hairline px-lg pt-lg pb-md flex flex-col gap-md">
|
|
272
|
+
|
|
273
|
+
{/* ── Pasted image thumbnails ── */}
|
|
274
|
+
{images.length > 0 && (
|
|
275
|
+
<div
|
|
276
|
+
role="list"
|
|
277
|
+
aria-label="Attached images"
|
|
278
|
+
className="flex flex-wrap gap-sm"
|
|
279
|
+
>
|
|
280
|
+
{images.map((img) => (
|
|
281
|
+
<div
|
|
282
|
+
key={img.id}
|
|
283
|
+
role="listitem"
|
|
284
|
+
className="relative group flex-shrink-0"
|
|
285
|
+
>
|
|
286
|
+
<div className="w-16 h-16 rounded-md overflow-hidden border border-hairline bg-surface-soft">
|
|
287
|
+
<img
|
|
288
|
+
src={img.url}
|
|
289
|
+
alt={img.name}
|
|
290
|
+
className="w-full h-full object-cover"
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
293
|
+
<Button
|
|
294
|
+
variant="ghost"
|
|
295
|
+
size="sm"
|
|
296
|
+
onClick={() => removeImage(img.id)}
|
|
297
|
+
aria-label={`Remove image ${img.name}`}
|
|
298
|
+
className="absolute -top-1.5 -right-1.5 !p-0 !w-5 !h-5 !min-w-0 !rounded-full bg-ink text-on-primary hover:bg-body opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity duration-150 shadow-sm flex items-center justify-center"
|
|
299
|
+
>
|
|
300
|
+
<XIcon />
|
|
301
|
+
</Button>
|
|
302
|
+
</div>
|
|
303
|
+
))}
|
|
304
|
+
</div>
|
|
305
|
+
)}
|
|
306
|
+
|
|
307
|
+
{/* Textarea */}
|
|
308
|
+
<textarea
|
|
309
|
+
aria-label="Prompt input"
|
|
310
|
+
placeholder={placeholder}
|
|
311
|
+
value={textValue}
|
|
312
|
+
onChange={handleChange}
|
|
313
|
+
onKeyDown={handleKeyDown}
|
|
314
|
+
onPaste={handlePaste}
|
|
315
|
+
disabled={textareaDisabled}
|
|
316
|
+
rows={2}
|
|
317
|
+
className="w-full resize-none bg-transparent text-body-md text-ink placeholder:text-muted-soft outline-none border-none leading-relaxed disabled:opacity-50"
|
|
318
|
+
/>
|
|
319
|
+
|
|
320
|
+
{/* Bottom toolbar */}
|
|
321
|
+
<div className="flex items-center justify-between gap-sm">
|
|
322
|
+
{/* Left actions */}
|
|
323
|
+
<div className="flex items-center gap-sm">
|
|
324
|
+
{/* Attach (+) button */}
|
|
325
|
+
<span
|
|
326
|
+
role="button"
|
|
327
|
+
tabIndex={0}
|
|
328
|
+
onClick={handleAttachClick}
|
|
329
|
+
onKeyDown={(e) => e.key === "Enter" && handleAttachClick()}
|
|
330
|
+
aria-label="Attach"
|
|
331
|
+
className="flex items-center justify-center size-8 rounded-full bg-surface-soft border border-hairline text-ink hover:bg-surface-strong active:bg-surface-strong transition-colors duration-150 flex-shrink-0 cursor-pointer"
|
|
332
|
+
>
|
|
333
|
+
<svg
|
|
334
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
335
|
+
viewBox="0 0 24 24"
|
|
336
|
+
fill="none"
|
|
337
|
+
stroke="currentColor"
|
|
338
|
+
strokeWidth="2"
|
|
339
|
+
strokeLinecap="round"
|
|
340
|
+
strokeLinejoin="round"
|
|
341
|
+
className="size-4"
|
|
342
|
+
aria-hidden="true"
|
|
343
|
+
>
|
|
344
|
+
<line x1="12" y1="5" x2="12" y2="19" />
|
|
345
|
+
<line x1="5" y1="12" x2="19" y2="12" />
|
|
346
|
+
</svg>
|
|
347
|
+
</span>
|
|
348
|
+
|
|
349
|
+
{/* Visual Edits pill */}
|
|
350
|
+
{onVisualEdits !== undefined && (
|
|
351
|
+
<Button
|
|
352
|
+
variant="primary"
|
|
353
|
+
size="sm"
|
|
354
|
+
onClick={onVisualEdits}
|
|
355
|
+
aria-label="Visual edits"
|
|
356
|
+
className="rounded-full px-md gap-xs"
|
|
357
|
+
>
|
|
358
|
+
<svg
|
|
359
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
360
|
+
viewBox="0 0 24 24"
|
|
361
|
+
fill="none"
|
|
362
|
+
stroke="currentColor"
|
|
363
|
+
strokeWidth="2"
|
|
364
|
+
strokeLinecap="round"
|
|
365
|
+
strokeLinejoin="round"
|
|
366
|
+
className="size-4 flex-shrink-0"
|
|
367
|
+
aria-hidden="true"
|
|
368
|
+
>
|
|
369
|
+
<path d="M17 1l4 4-4 4" />
|
|
370
|
+
<path d="M3 11V9a4 4 0 0 1 4-4h14" />
|
|
371
|
+
<path d="M7 23l-4-4 4-4" />
|
|
372
|
+
<path d="M21 13v2a4 4 0 0 1-4 4H3" />
|
|
373
|
+
</svg>
|
|
374
|
+
Visual edits
|
|
375
|
+
</Button>
|
|
376
|
+
)}
|
|
377
|
+
|
|
378
|
+
{/* ── Model selector ── */}
|
|
379
|
+
{models && models.length > 0 && (
|
|
380
|
+
<div ref={modelRef} className="relative">
|
|
381
|
+
<span
|
|
382
|
+
role="button"
|
|
383
|
+
tabIndex={0}
|
|
384
|
+
onClick={() => setModelOpen((o) => !o)}
|
|
385
|
+
onKeyDown={(e) => {
|
|
386
|
+
if (e.key === "Enter") setModelOpen((o) => !o);
|
|
387
|
+
if (e.key === "Escape") setModelOpen(false);
|
|
388
|
+
}}
|
|
389
|
+
aria-haspopup="listbox"
|
|
390
|
+
aria-expanded={modelOpen}
|
|
391
|
+
aria-label="Select model"
|
|
392
|
+
className="flex items-center gap-xs text-body-sm font-weight-heading-sm text-muted hover:text-ink transition-colors duration-150 cursor-pointer select-none rounded-sm px-xs py-xxs"
|
|
393
|
+
>
|
|
394
|
+
{(models.find((m) => m.id === selectedModelId) ?? models[0])?.name ?? "Model"}
|
|
395
|
+
<svg
|
|
396
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
397
|
+
viewBox="0 0 24 24"
|
|
398
|
+
fill="none"
|
|
399
|
+
stroke="currentColor"
|
|
400
|
+
strokeWidth="2.5"
|
|
401
|
+
strokeLinecap="round"
|
|
402
|
+
strokeLinejoin="round"
|
|
403
|
+
className="size-3"
|
|
404
|
+
aria-hidden="true"
|
|
405
|
+
>
|
|
406
|
+
<polyline points="6 9 12 15 18 9" />
|
|
407
|
+
</svg>
|
|
408
|
+
</span>
|
|
409
|
+
|
|
410
|
+
{modelOpen && (
|
|
411
|
+
<ul
|
|
412
|
+
role="listbox"
|
|
413
|
+
aria-label="Model options"
|
|
414
|
+
className="absolute bottom-full mb-xs left-0 bg-canvas border border-hairline rounded-md shadow-md min-w-[12rem] max-h-[250px] overflow-y-auto"
|
|
415
|
+
style={{ zIndex: "var(--z-dropdown, 50)" }}
|
|
416
|
+
>
|
|
417
|
+
{models.map((m) => (
|
|
418
|
+
<li key={m.id} role="option" aria-selected={m.id === selectedModelId}>
|
|
419
|
+
<span
|
|
420
|
+
role="button"
|
|
421
|
+
tabIndex={0}
|
|
422
|
+
onClick={() => {
|
|
423
|
+
onModelChange?.(m.id);
|
|
424
|
+
setModelOpen(false);
|
|
425
|
+
}}
|
|
426
|
+
onKeyDown={(e) => {
|
|
427
|
+
if (e.key === "Enter") {
|
|
428
|
+
onModelChange?.(m.id);
|
|
429
|
+
setModelOpen(false);
|
|
430
|
+
}
|
|
431
|
+
if (e.key === "Escape") setModelOpen(false);
|
|
432
|
+
}}
|
|
433
|
+
className={[
|
|
434
|
+
"flex flex-col w-full text-left px-md py-sm transition-colors duration-100 cursor-pointer",
|
|
435
|
+
m.id === selectedModelId
|
|
436
|
+
? "bg-surface-soft"
|
|
437
|
+
: "hover:bg-surface-soft",
|
|
438
|
+
].join(" ")}
|
|
439
|
+
>
|
|
440
|
+
<span className="flex items-center gap-xs">
|
|
441
|
+
<span
|
|
442
|
+
className={[
|
|
443
|
+
"text-body-sm",
|
|
444
|
+
m.id === selectedModelId
|
|
445
|
+
? "font-weight-heading-sm text-ink"
|
|
446
|
+
: "text-body",
|
|
447
|
+
].join(" ")}
|
|
448
|
+
>
|
|
449
|
+
{m.name}
|
|
450
|
+
</span>
|
|
451
|
+
{m.tier && (
|
|
452
|
+
<span className="text-caption text-muted bg-surface-strong rounded-xs px-xs py-xxs leading-none">
|
|
453
|
+
{m.tier}
|
|
454
|
+
</span>
|
|
455
|
+
)}
|
|
456
|
+
</span>
|
|
457
|
+
{m.description && (
|
|
458
|
+
<span className="text-caption text-muted mt-xxs">
|
|
459
|
+
{m.description}
|
|
460
|
+
</span>
|
|
461
|
+
)}
|
|
462
|
+
</span>
|
|
463
|
+
</li>
|
|
464
|
+
))}
|
|
465
|
+
</ul>
|
|
466
|
+
)}
|
|
467
|
+
</div>
|
|
468
|
+
)}
|
|
469
|
+
</div>
|
|
470
|
+
|
|
471
|
+
{/* Right actions */}
|
|
472
|
+
<div className="flex items-center gap-sm">
|
|
473
|
+
{/* ── Mode selector dropdown ── */}
|
|
474
|
+
<div ref={modeRef} className="relative">
|
|
475
|
+
<span
|
|
476
|
+
role="button"
|
|
477
|
+
tabIndex={0}
|
|
478
|
+
onClick={() => setModeOpen((o) => !o)}
|
|
479
|
+
onKeyDown={(e) => {
|
|
480
|
+
if (e.key === "Enter") setModeOpen((o) => !o);
|
|
481
|
+
if (e.key === "Escape") setModeOpen(false);
|
|
482
|
+
}}
|
|
483
|
+
aria-haspopup="listbox"
|
|
484
|
+
aria-expanded={modeOpen}
|
|
485
|
+
className="flex items-center gap-xs text-body-md font-weight-heading-sm text-ink hover:text-muted transition-colors duration-150 cursor-pointer select-none"
|
|
486
|
+
>
|
|
487
|
+
{mode}
|
|
488
|
+
<svg
|
|
489
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
490
|
+
viewBox="0 0 24 24"
|
|
491
|
+
fill="none"
|
|
492
|
+
stroke="currentColor"
|
|
493
|
+
strokeWidth="2.5"
|
|
494
|
+
strokeLinecap="round"
|
|
495
|
+
strokeLinejoin="round"
|
|
496
|
+
className="size-4"
|
|
497
|
+
aria-hidden="true"
|
|
498
|
+
>
|
|
499
|
+
<polyline points="6 9 12 15 18 9" />
|
|
500
|
+
</svg>
|
|
501
|
+
</span>
|
|
502
|
+
|
|
503
|
+
{modeOpen && (
|
|
504
|
+
<ul
|
|
505
|
+
role="listbox"
|
|
506
|
+
className="absolute bottom-full mb-xs right-0 bg-canvas border border-hairline rounded-md shadow-md py-xs min-w-[8rem]"
|
|
507
|
+
style={{ zIndex: "var(--z-dropdown, 50)" }}
|
|
508
|
+
>
|
|
509
|
+
{MODES.map((m) => (
|
|
510
|
+
<li key={m} role="option" aria-selected={m === mode}>
|
|
511
|
+
<span
|
|
512
|
+
role="button"
|
|
513
|
+
tabIndex={0}
|
|
514
|
+
onClick={() => {
|
|
515
|
+
onModeChange?.(m);
|
|
516
|
+
setModeOpen(false);
|
|
517
|
+
}}
|
|
518
|
+
onKeyDown={(e) => {
|
|
519
|
+
if (e.key === "Enter") {
|
|
520
|
+
onModeChange?.(m);
|
|
521
|
+
setModeOpen(false);
|
|
522
|
+
}
|
|
523
|
+
if (e.key === "Escape") setModeOpen(false);
|
|
524
|
+
}}
|
|
525
|
+
className={[
|
|
526
|
+
"block w-full text-left px-md py-xs text-body-sm transition-colors duration-100 cursor-pointer",
|
|
527
|
+
m === mode
|
|
528
|
+
? "text-ink font-weight-heading-sm bg-surface-soft"
|
|
529
|
+
: "text-muted hover:bg-surface-soft",
|
|
530
|
+
].join(" ")}
|
|
531
|
+
>
|
|
532
|
+
{m}
|
|
533
|
+
</span>
|
|
534
|
+
</li>
|
|
535
|
+
))}
|
|
536
|
+
</ul>
|
|
537
|
+
)}
|
|
538
|
+
</div>
|
|
539
|
+
|
|
540
|
+
{/* Mic button */}
|
|
541
|
+
<span
|
|
542
|
+
role="button"
|
|
543
|
+
tabIndex={0}
|
|
544
|
+
onClick={onMic}
|
|
545
|
+
onKeyDown={(e) => e.key === "Enter" && onMic?.()}
|
|
546
|
+
aria-label="Voice input"
|
|
547
|
+
className="flex items-center justify-center size-9 rounded-full bg-surface-soft border border-hairline text-ink hover:bg-surface-strong active:bg-surface-strong transition-colors duration-150 flex-shrink-0 cursor-pointer"
|
|
548
|
+
>
|
|
549
|
+
<svg
|
|
550
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
551
|
+
viewBox="0 0 24 24"
|
|
552
|
+
fill="none"
|
|
553
|
+
stroke="currentColor"
|
|
554
|
+
strokeWidth="1.75"
|
|
555
|
+
strokeLinecap="round"
|
|
556
|
+
strokeLinejoin="round"
|
|
557
|
+
className="size-4"
|
|
558
|
+
aria-hidden="true"
|
|
559
|
+
>
|
|
560
|
+
<rect x="9" y="2" width="6" height="11" rx="3" />
|
|
561
|
+
<path d="M19 10a7 7 0 0 1-14 0" />
|
|
562
|
+
<line x1="12" y1="19" x2="12" y2="22" />
|
|
563
|
+
<line x1="8" y1="22" x2="16" y2="22" />
|
|
564
|
+
</svg>
|
|
565
|
+
</span>
|
|
566
|
+
|
|
567
|
+
{/* Send / Stop button */}
|
|
568
|
+
{isStreaming ? (
|
|
569
|
+
<span
|
|
570
|
+
role="button"
|
|
571
|
+
tabIndex={0}
|
|
572
|
+
onClick={onStop}
|
|
573
|
+
onKeyDown={(e) => e.key === "Enter" && onStop?.()}
|
|
574
|
+
aria-label="Stop generation"
|
|
575
|
+
className="flex items-center justify-center size-9 rounded-full bg-ink text-on-primary hover:bg-body transition-colors duration-150 flex-shrink-0 cursor-pointer"
|
|
576
|
+
>
|
|
577
|
+
<svg
|
|
578
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
579
|
+
viewBox="0 0 24 24"
|
|
580
|
+
fill="currentColor"
|
|
581
|
+
className="size-4"
|
|
582
|
+
aria-hidden="true"
|
|
583
|
+
>
|
|
584
|
+
<rect x="5" y="5" width="14" height="14" rx="2" />
|
|
585
|
+
</svg>
|
|
586
|
+
</span>
|
|
587
|
+
) : (
|
|
588
|
+
<span
|
|
589
|
+
role="button"
|
|
590
|
+
tabIndex={0}
|
|
591
|
+
onClick={canSend ? handleSend : undefined}
|
|
592
|
+
onKeyDown={(e) => e.key === "Enter" && canSend && handleSend()}
|
|
593
|
+
aria-label="Send"
|
|
594
|
+
aria-disabled={!canSend}
|
|
595
|
+
className={[
|
|
596
|
+
"flex items-center justify-center size-9 rounded-full transition-colors duration-150 flex-shrink-0",
|
|
597
|
+
canSend
|
|
598
|
+
? "bg-primary text-on-primary hover:bg-primary-hover active:bg-primary-active cursor-pointer"
|
|
599
|
+
: "bg-surface-strong text-muted-soft cursor-not-allowed",
|
|
600
|
+
].join(" ")}
|
|
601
|
+
>
|
|
602
|
+
<svg
|
|
603
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
604
|
+
viewBox="0 0 24 24"
|
|
605
|
+
fill="none"
|
|
606
|
+
stroke="currentColor"
|
|
607
|
+
strokeWidth="2.25"
|
|
608
|
+
strokeLinecap="round"
|
|
609
|
+
strokeLinejoin="round"
|
|
610
|
+
className="size-4"
|
|
611
|
+
aria-hidden="true"
|
|
612
|
+
>
|
|
613
|
+
<line x1="12" y1="19" x2="12" y2="5" />
|
|
614
|
+
<polyline points="5 12 12 5 19 12" />
|
|
615
|
+
</svg>
|
|
616
|
+
</span>
|
|
617
|
+
)}
|
|
618
|
+
</div>
|
|
619
|
+
</div>
|
|
620
|
+
</div>
|
|
621
|
+
</div>
|
|
622
|
+
);
|
|
623
|
+
},
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
PromptInputBar.displayName = "PromptInputBar";
|