@designa8/vibedesign-v6 1.20.20 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/fonts/plusjakartasans/PlusJakartaSans-Italic[wght].ttf +0 -0
- package/dist/fonts/plusjakartasans/PlusJakartaSans[wght].ttf +0 -0
- package/dist/index.cjs +12027 -4942
- package/dist/index.js +12089 -5004
- package/dist/styles.css +1393 -97
- package/package.json +116 -1
- package/src/atoms/AgentQuestionCard/AgentQuestionCard.tsx +567 -0
- package/src/atoms/AgentQuestionCard/index.ts +6 -0
- package/src/atoms/AgentQuestionCard/preview.tsx +199 -0
- package/src/atoms/AppLayout/AppLayout.tsx +85 -22
- package/src/atoms/AppLayout/preview.tsx +4 -0
- package/src/atoms/AppSidebar/AppSidebar.tsx +222 -137
- package/src/atoms/AppSidebar/preview.tsx +61 -8
- package/src/atoms/AppSidebarMobile/AppSidebarMobile.tsx +241 -169
- package/src/atoms/AppSidebarMobile/preview.tsx +59 -89
- package/src/atoms/AuthLogin/AuthLogin.tsx +86 -49
- package/src/atoms/AuthLogin/preview.tsx +16 -0
- package/src/atoms/AuthSignUp/AuthSignUp.tsx +206 -126
- package/src/atoms/AuthSignUp/preview.tsx +10 -0
- package/src/atoms/BottomSheet/BottomSheet.tsx +199 -0
- package/src/atoms/BottomSheet/index.ts +2 -0
- package/src/atoms/BottomSheet/preview.tsx +50 -0
- package/src/atoms/Button/Button.tsx +19 -3
- package/src/atoms/Button/preview.tsx +2 -1
- package/src/atoms/ChatHistorySidebar/ChatHistorySidebar.tsx +160 -84
- package/src/atoms/ChatHistorySidebar/preview.tsx +81 -42
- package/src/atoms/ChatScreen/ChatScreen.tsx +298 -33
- package/src/atoms/ChatScreen/preview.tsx +54 -90
- package/src/atoms/Chip/Chip.tsx +81 -33
- package/src/atoms/Chip/preview.tsx +39 -21
- package/src/atoms/CodeEditor/CodeEditor.tsx +10 -4
- package/src/atoms/ComponentActionsSheet/ComponentActionsSheet.tsx +165 -0
- package/src/atoms/ComponentActionsSheet/index.ts +7 -0
- package/src/atoms/ComponentActionsSheet/preview.tsx +67 -0
- package/src/atoms/ComponentCard/ComponentCard.tsx +17 -35
- package/src/atoms/ComponentCard/preview.tsx +9 -9
- package/src/atoms/DesignSystemLoader/DesignSystemLoader.tsx +153 -0
- package/src/atoms/DesignSystemLoader/index.ts +2 -0
- package/src/atoms/DesignSystemLoader/preview.tsx +19 -0
- package/src/atoms/DesignSystemShowcase/DesignSystemShowcase.tsx +410 -0
- package/src/atoms/DesignSystemShowcase/index.ts +6 -0
- package/src/atoms/DesignSystemShowcase/preview.tsx +22 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.data.ts +254 -0
- package/src/atoms/DesignTokensPanel/DesignTokensPanel.tsx +946 -0
- package/src/atoms/DesignTokensPanel/index.ts +9 -0
- package/src/atoms/DesignTokensPanel/preview.tsx +39 -0
- package/src/atoms/ExpandableMessage/ExpandableMessage.tsx +239 -0
- package/src/atoms/ExpandableMessage/fix-link-note.txt +3 -0
- package/src/atoms/ExpandableMessage/index.ts +2 -0
- package/src/atoms/ExpandableMessage/markdown.tsx +310 -0
- package/src/atoms/ExpandableMessage/preview.tsx +83 -0
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +2 -2
- package/src/atoms/FontCombobox/FontCombobox.tsx +655 -0
- package/src/atoms/FontCombobox/index.ts +6 -0
- package/src/atoms/FontCombobox/preview.tsx +111 -0
- package/src/atoms/HomePageTemplate/HomePageTemplate.tsx +894 -96
- package/src/atoms/HomePageTemplate/preview.tsx +4 -0
- package/src/atoms/Icon/Icon.tsx +17 -11
- package/src/atoms/Icon/icons.data.ts +34 -0
- package/src/atoms/Input/Input.tsx +37 -21
- package/src/atoms/LandingHero/LandingHero.tsx +545 -0
- package/src/atoms/LandingHero/index.ts +6 -0
- package/src/atoms/LandingHero/preview.tsx +88 -0
- package/src/atoms/MarketingFooter/MarketingFooter.tsx +215 -0
- package/src/atoms/MarketingFooter/index.ts +7 -0
- package/src/atoms/MarketingFooter/preview.tsx +28 -0
- package/src/atoms/MarketingNavbar/MarketingNavbar.tsx +451 -0
- package/src/atoms/MarketingNavbar/index.ts +7 -0
- package/src/atoms/MarketingNavbar/preview.tsx +109 -0
- package/src/atoms/MobileActionsDrawer/MobileActionsDrawer.tsx +548 -0
- package/src/atoms/MobileActionsDrawer/index.ts +9 -0
- package/src/atoms/MobileActionsDrawer/preview.tsx +109 -0
- package/src/atoms/Modal/Modal.tsx +77 -28
- package/src/atoms/PreviewDock/PreviewDock.tsx +119 -0
- package/src/atoms/PreviewDock/index.ts +2 -0
- package/src/atoms/PreviewDock/preview.tsx +30 -0
- package/src/atoms/PreviewToolbar/PreviewToolbar.tsx +47 -30
- package/src/atoms/PricingCard/PricingCard.tsx +15 -4
- package/src/atoms/PricingPageTemplate/PricingPageTemplate.tsx +109 -89
- package/src/atoms/ProjectSettingsModal/ProjectSettingsModal.tsx +314 -0
- package/src/atoms/ProjectSettingsModal/index.ts +2 -0
- package/src/atoms/ProjectSettingsModal/preview.tsx +130 -0
- package/src/atoms/ProjectSettingsModal/switch.snippet.txt +8 -0
- package/src/atoms/PromptInputBar/PromptInputBar.tsx +750 -302
- package/src/atoms/PromptInputBar/preview.tsx +64 -64
- package/src/atoms/SettingsPageTemplate/SettingsPageTemplate.tsx +272 -0
- package/src/atoms/SettingsPageTemplate/index.ts +2 -0
- package/src/atoms/SettingsPageTemplate/preview.tsx +29 -0
- package/src/atoms/SidebarUpgradeBanner/SidebarUpgradeBanner.tsx +178 -0
- package/src/atoms/SidebarUpgradeBanner/index.ts +2 -0
- package/src/atoms/SidebarUpgradeBanner/preview.tsx +47 -0
- package/src/atoms/SkeletonChip/SkeletonChip.tsx +198 -0
- package/src/atoms/SkeletonChip/index.ts +2 -0
- package/src/atoms/SkeletonChip/preview.tsx +44 -0
- package/src/atoms/TemplateHeader/TemplateHeader.tsx +129 -0
- package/src/atoms/TemplateHeader/index.ts +2 -0
- package/src/atoms/TemplateHeader/preview.tsx +39 -0
- package/src/atoms/TemplateHero/TemplateHero.tsx +286 -0
- package/src/atoms/TemplateHero/index.ts +2 -0
- package/src/atoms/TemplateHero/preview.tsx +32 -0
- package/src/atoms/TemplateSummary/TemplateSummary.tsx +85 -0
- package/src/atoms/TemplateSummary/index.ts +2 -0
- package/src/atoms/TemplateSummary/preview.tsx +10 -0
- package/src/atoms/Toast/Toast.tsx +178 -0
- package/src/atoms/Toast/index.ts +2 -0
- package/src/atoms/Toast/preview.tsx +100 -0
- package/src/atoms/TopNavbar/TopNavbar.tsx +145 -67
- package/src/atoms/TopNavbar/preview.tsx +13 -7
- package/src/atoms/TopupModal/TopupModal.tsx +94 -0
- package/src/atoms/TopupModal/index.ts +2 -0
- package/src/atoms/TopupModal/preview.tsx +22 -0
- package/src/atoms/UpgradeCard/UpgradeCard.tsx +124 -43
- package/src/atoms/UpgradeCard/index.ts +1 -1
- package/src/atoms/UpgradeCard/preview.tsx +7 -14
- package/src/atoms/UpgradeModal/UpgradeModal.tsx +192 -0
- package/src/atoms/UpgradeModal/index.ts +2 -0
- package/src/atoms/UpgradeModal/preview.tsx +41 -0
- package/src/index.ts +23 -0
- package/src/tokens.css +45 -7
- package/dist/fonts/inter/Inter-Italic[opsz,wght].ttf +0 -0
- package/dist/fonts/inter/Inter[opsz,wght].ttf +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Button } from "../Button";
|
|
3
2
|
import { Input } from "../Input";
|
|
4
3
|
import { Icon } from "../Icon";
|
|
5
4
|
|
|
@@ -10,6 +9,13 @@ export interface PromptInputBarModel {
|
|
|
10
9
|
name: string;
|
|
11
10
|
tier?: string;
|
|
12
11
|
description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether this model can be selected. Defaults to true when omitted.
|
|
14
|
+
* When false, the row still renders (not hidden) but is visually muted,
|
|
15
|
+
* marked "Unavailable", and activating it does not select the model — it
|
|
16
|
+
* calls `onUnavailableModelClick` instead and closes the menu.
|
|
17
|
+
*/
|
|
18
|
+
available?: boolean;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export interface PastedImage {
|
|
@@ -29,68 +35,114 @@ export interface PromptInputBarProps {
|
|
|
29
35
|
mode?: PromptMode;
|
|
30
36
|
/** Called when mode selection changes */
|
|
31
37
|
onModeChange?: (mode: PromptMode) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Whether to render the Build/Chat/Design mode dropdown in the toolbar.
|
|
34
|
-
* Default: true. Set to false for consumers (like ChatScreen) that don't
|
|
35
|
-
* need mode switching.
|
|
36
|
-
*/
|
|
38
|
+
/** Whether to render the Build/Chat/Design mode dropdown. Default: true. */
|
|
37
39
|
showModeSelector?: boolean;
|
|
38
40
|
/** Called when the send button is clicked */
|
|
39
41
|
onSend?: (value: string, images: PastedImage[]) => void;
|
|
40
42
|
/**
|
|
41
|
-
* Called when the +
|
|
43
|
+
* Called when "Upload file" is chosen in the + menu.
|
|
42
44
|
* When onFilesSelected is also provided, onFilesSelected takes priority.
|
|
43
45
|
*/
|
|
44
46
|
onAttach?: () => void;
|
|
45
47
|
/**
|
|
46
|
-
* When provided,
|
|
48
|
+
* When provided, "Upload file" opens a hidden file input.
|
|
47
49
|
* Takes priority over onAttach when both are supplied.
|
|
48
50
|
*/
|
|
49
51
|
onFilesSelected?: (files: FileList) => void;
|
|
52
|
+
/** Called when the visual edits button is clicked. Not rendered when undefined. */
|
|
53
|
+
onVisualEdits?: () => void;
|
|
50
54
|
/**
|
|
51
|
-
* Called when the
|
|
52
|
-
*
|
|
55
|
+
* Called when the mic button is clicked. In uncontrolled mode the bar also
|
|
56
|
+
* enters its compact recording state; in controlled mode (`recording`
|
|
57
|
+
* provided) the consumer decides.
|
|
53
58
|
*/
|
|
54
|
-
onVisualEdits?: () => void;
|
|
55
|
-
/** Called when the mic button is clicked */
|
|
56
59
|
onMic?: () => void;
|
|
57
|
-
/** Whether the send button is disabled */
|
|
58
|
-
disabled?: boolean;
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* Controlled recording state. Omit for uncontrolled: the bar enters
|
|
62
|
+
* recording when the mic is clicked and leaves it on confirm / cancel.
|
|
63
|
+
*/
|
|
64
|
+
recording?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* When set while recording, the recording pill shows this message (for
|
|
67
|
+
* example "Microphone blocked") in the error style and only the close
|
|
68
|
+
* button remains.
|
|
69
|
+
*/
|
|
70
|
+
recordingError?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Optional live audio levels (0 to 1, oldest first) that drive the mini
|
|
73
|
+
* waveform. When provided, the waveform stays hidden until one of the most
|
|
74
|
+
* recent 12 raw levels is above 0. When omitted the waveform runs a
|
|
75
|
+
* simulated animation and is always visible.
|
|
61
76
|
*/
|
|
77
|
+
audioLevels?: number[];
|
|
78
|
+
/** Auto-confirm after this many seconds. Default: 120. */
|
|
79
|
+
maxRecordingSeconds?: number;
|
|
80
|
+
/** Called when the confirm (check) button is pressed or the max is hit. */
|
|
81
|
+
onRecordingConfirm?: (durationSeconds: number) => void;
|
|
82
|
+
/** Called when recording is cancelled (cancel button or Escape). */
|
|
83
|
+
onRecordingCancel?: () => void;
|
|
84
|
+
/** Whether the input is disabled */
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
/** When true: disables textarea + "+" and shows the Stop button. */
|
|
62
87
|
isStreaming?: boolean;
|
|
63
88
|
/** Called when the Stop button is clicked */
|
|
64
89
|
onStop?: () => void;
|
|
65
|
-
/**
|
|
90
|
+
/** AI models listed under "Choose model" in the + menu */
|
|
66
91
|
models?: PromptInputBarModel[];
|
|
67
92
|
/** Currently selected model id */
|
|
68
93
|
selectedModelId?: string;
|
|
69
|
-
/** Called when the user
|
|
94
|
+
/** Called when the user picks an available model */
|
|
70
95
|
onModelChange?: (modelId: string) => void;
|
|
71
96
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* images internally.
|
|
97
|
+
* Called when the user activates a model row whose `available` is false.
|
|
98
|
+
* The menu closes but `onModelChange` is NOT called.
|
|
75
99
|
*/
|
|
100
|
+
onUnavailableModelClick?: (modelId: string) => void;
|
|
101
|
+
/** Controlled list of pasted images. */
|
|
76
102
|
pastedImages?: PastedImage[];
|
|
77
|
-
/** Called when the
|
|
103
|
+
/** Called when the image list changes (add / remove) */
|
|
78
104
|
onImagesChange?: (images: PastedImage[]) => void;
|
|
79
|
-
/**
|
|
80
|
-
* Whether the compact "Suggest Designs" switch (rendered immediately to
|
|
81
|
-
* the right of the model dropdown) is on. Controlled — omit for an
|
|
82
|
-
* uncontrolled switch that defaults to off and is never persisted across
|
|
83
|
-
* remounts.
|
|
84
|
-
*/
|
|
105
|
+
/** Whether the "Suggest designs" chip is on. Omit for uncontrolled (off). */
|
|
85
106
|
suggestDesigns?: boolean;
|
|
86
|
-
/** Called when the Suggest
|
|
107
|
+
/** Called when the Suggest designs chip is toggled */
|
|
87
108
|
onSuggestDesignsChange?: (on: boolean) => void;
|
|
88
109
|
className?: string;
|
|
89
110
|
}
|
|
90
111
|
|
|
91
112
|
const MODES: PromptMode[] = ["Build", "Chat", "Design"];
|
|
92
113
|
|
|
93
|
-
/**
|
|
114
|
+
/** Waveform: dense rounded bars scrolling in from the right, faded on the left. */
|
|
115
|
+
const BAR_COUNT = 56;
|
|
116
|
+
const MIN_LEVEL = 0.16;
|
|
117
|
+
/** How many of the most recent raw levels decide whether live audio is present. */
|
|
118
|
+
const ACTIVITY_WINDOW = 12;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Resting waveform (also used for reduced motion): a soft speech-like
|
|
122
|
+
* envelope that swells toward the right with small ripples, tapering at both
|
|
123
|
+
* ends, like the reference.
|
|
124
|
+
*/
|
|
125
|
+
const RESTING_LEVELS: number[] = Array.from({ length: BAR_COUNT }, (_, i) => {
|
|
126
|
+
const x = i / (BAR_COUNT - 1);
|
|
127
|
+
const swell = Math.exp(-(((x - 0.68) / 0.24) ** 2));
|
|
128
|
+
const ripple = 0.55 + 0.45 * Math.abs(Math.sin(i * 0.85));
|
|
129
|
+
return Math.max(MIN_LEVEL, 0.14 + 0.86 * swell * ripple);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
/** Next simulated level: smoothed so neighbouring bars flow like a voice. */
|
|
133
|
+
function nextLevel(prev: number) {
|
|
134
|
+
const pause = Math.random() < 0.16;
|
|
135
|
+
const target = pause ? 0.1 + Math.random() * 0.15 : 0.35 + Math.random() * 0.65;
|
|
136
|
+
return Math.max(MIN_LEVEL, Math.min(1, prev * 0.45 + target * 0.55));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function formatTime(total: number) {
|
|
140
|
+
const m = Math.floor(total / 60);
|
|
141
|
+
const s = total % 60;
|
|
142
|
+
return `${m}:${String(s).padStart(2, "0")}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Calls `onClose` when a mousedown/touchstart fires outside `ref`. */
|
|
94
146
|
function useClickOutside(
|
|
95
147
|
ref: React.RefObject<HTMLElement | null>,
|
|
96
148
|
onClose: () => void,
|
|
@@ -112,13 +164,35 @@ function useClickOutside(
|
|
|
112
164
|
}, [ref, onClose, enabled]);
|
|
113
165
|
}
|
|
114
166
|
|
|
167
|
+
const FOCUS =
|
|
168
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
169
|
+
const PRESS =
|
|
170
|
+
"cursor-pointer transition duration-150 ease-out active:scale-[0.98]";
|
|
171
|
+
const PANEL =
|
|
172
|
+
"absolute transition duration-200 ease-out data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100 data-[state=closed]:pointer-events-none data-[state=closed]:translate-y-1 data-[state=closed]:scale-95 data-[state=closed]:opacity-0";
|
|
173
|
+
const VIEW =
|
|
174
|
+
"w-full transition duration-200 ease-out data-[active=true]:relative data-[active=true]:translate-x-0 data-[active=true]:opacity-100 data-[active=false]:pointer-events-none data-[active=false]:absolute data-[active=false]:inset-x-0 data-[active=false]:top-0 data-[active=false]:opacity-0";
|
|
175
|
+
const LAYER =
|
|
176
|
+
"absolute inset-0 flex items-center justify-center rounded-full transition duration-150 ease-out data-[state=active]:scale-100 data-[state=active]:opacity-100 data-[state=idle]:pointer-events-none data-[state=idle]:scale-75 data-[state=idle]:opacity-0";
|
|
177
|
+
const ROW_LAYER =
|
|
178
|
+
"col-start-1 row-start-1 flex min-w-0 items-center gap-sm transition duration-200 ease-out data-[state=active]:opacity-100 data-[state=idle]:pointer-events-none data-[state=idle]:opacity-0";
|
|
179
|
+
/**
|
|
180
|
+
* Round control shared by "+", mic and cancel. The hairline is an inset ring
|
|
181
|
+
* (box-shadow) rather than a border, so the visible fill stays the full
|
|
182
|
+
* size-9 and matches the solid Send circle exactly.
|
|
183
|
+
*/
|
|
184
|
+
const ROUND_BTN =
|
|
185
|
+
"relative flex items-center justify-center size-9 flex-shrink-0 rounded-full inset-ring-1 inset-ring-hairline bg-surface-soft text-ink hover:bg-surface-strong after:absolute after:-inset-1 after:content-['']";
|
|
186
|
+
const ROW =
|
|
187
|
+
"flex w-full items-center gap-sm rounded-md px-sm py-sm text-left cursor-pointer transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue";
|
|
188
|
+
|
|
115
189
|
export const PromptInputBar = React.forwardRef<
|
|
116
190
|
HTMLDivElement,
|
|
117
191
|
PromptInputBarProps
|
|
118
192
|
>(
|
|
119
193
|
(
|
|
120
194
|
{
|
|
121
|
-
placeholder = "
|
|
195
|
+
placeholder = "Paste an image or type your prompt...",
|
|
122
196
|
value,
|
|
123
197
|
onChange,
|
|
124
198
|
mode = "Build",
|
|
@@ -129,12 +203,19 @@ export const PromptInputBar = React.forwardRef<
|
|
|
129
203
|
onFilesSelected,
|
|
130
204
|
onVisualEdits,
|
|
131
205
|
onMic,
|
|
206
|
+
recording,
|
|
207
|
+
recordingError,
|
|
208
|
+
audioLevels,
|
|
209
|
+
maxRecordingSeconds = 120,
|
|
210
|
+
onRecordingConfirm,
|
|
211
|
+
onRecordingCancel,
|
|
132
212
|
disabled = false,
|
|
133
213
|
isStreaming = false,
|
|
134
214
|
onStop,
|
|
135
215
|
models,
|
|
136
216
|
selectedModelId,
|
|
137
217
|
onModelChange,
|
|
218
|
+
onUnavailableModelClick,
|
|
138
219
|
pastedImages,
|
|
139
220
|
onImagesChange,
|
|
140
221
|
suggestDesigns,
|
|
@@ -143,29 +224,147 @@ export const PromptInputBar = React.forwardRef<
|
|
|
143
224
|
},
|
|
144
225
|
ref,
|
|
145
226
|
) => {
|
|
227
|
+
const uid = React.useId();
|
|
146
228
|
const [internalValue, setInternalValue] = React.useState("");
|
|
147
229
|
const [internalImages, setInternalImages] = React.useState<PastedImage[]>([]);
|
|
148
230
|
const [modeOpen, setModeOpen] = React.useState(false);
|
|
149
|
-
const [
|
|
150
|
-
|
|
151
|
-
// off and is never persisted across remounts.
|
|
231
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
232
|
+
const [menuView, setMenuView] = React.useState<"root" | "models">("root");
|
|
152
233
|
const [internalSuggestDesigns, setInternalSuggestDesigns] = React.useState(false);
|
|
234
|
+
const [internalRecording, setInternalRecording] = React.useState(false);
|
|
235
|
+
const [seconds, setSeconds] = React.useState(0);
|
|
236
|
+
const [levels, setLevels] = React.useState<number[]>(RESTING_LEVELS);
|
|
153
237
|
|
|
154
238
|
const fileInputRef = React.useRef<HTMLInputElement>(null);
|
|
239
|
+
const textareaRef = React.useRef<HTMLTextAreaElement>(null);
|
|
155
240
|
const modeRef = React.useRef<HTMLDivElement>(null);
|
|
156
|
-
const
|
|
241
|
+
const menuWrapRef = React.useRef<HTMLDivElement>(null);
|
|
242
|
+
const menuPanelRef = React.useRef<HTMLDivElement>(null);
|
|
243
|
+
const plusRef = React.useRef<HTMLButtonElement>(null);
|
|
244
|
+
const micRef = React.useRef<HTMLButtonElement>(null);
|
|
245
|
+
const confirmRef = React.useRef<HTMLButtonElement>(null);
|
|
246
|
+
const cancelRef = React.useRef<HTMLButtonElement>(null);
|
|
247
|
+
const wasOpen = React.useRef(false);
|
|
248
|
+
const wasRecording = React.useRef(false);
|
|
249
|
+
const endFocus = React.useRef<"mic" | "textarea">("mic");
|
|
250
|
+
|
|
251
|
+
const isRecording = recording !== undefined ? recording : internalRecording;
|
|
252
|
+
const hasError = isRecording && Boolean(recordingError);
|
|
253
|
+
|
|
254
|
+
const closeMenu = React.useCallback(() => {
|
|
255
|
+
setMenuOpen(false);
|
|
256
|
+
setMenuView("root");
|
|
257
|
+
}, []);
|
|
157
258
|
|
|
158
|
-
// Close each dropdown when a click/touch lands outside its container
|
|
159
259
|
useClickOutside(modeRef, React.useCallback(() => setModeOpen(false), []), modeOpen);
|
|
160
|
-
useClickOutside(
|
|
260
|
+
useClickOutside(menuWrapRef, closeMenu, menuOpen);
|
|
161
261
|
|
|
162
262
|
const textValue = value !== undefined ? value : internalValue;
|
|
163
263
|
const images = pastedImages !== undefined ? pastedImages : internalImages;
|
|
164
|
-
const
|
|
264
|
+
const suggestOn = suggestDesigns !== undefined ? suggestDesigns : internalSuggestDesigns;
|
|
265
|
+
|
|
266
|
+
const hasModels = Boolean(models && models.length > 0);
|
|
267
|
+
const currentModel = models?.find((m) => m.id === selectedModelId) ?? models?.[0];
|
|
268
|
+
|
|
269
|
+
/* ── Recording ── */
|
|
270
|
+
const prefersReducedMotion = React.useCallback(
|
|
271
|
+
() =>
|
|
272
|
+
typeof window !== "undefined" &&
|
|
273
|
+
typeof window.matchMedia === "function" &&
|
|
274
|
+
window.matchMedia("(prefers-reduced-motion: reduce)").matches,
|
|
275
|
+
[],
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
const confirmRecording = React.useCallback(() => {
|
|
279
|
+
endFocus.current = "textarea";
|
|
280
|
+
onRecordingConfirm?.(seconds);
|
|
281
|
+
if (recording === undefined) setInternalRecording(false);
|
|
282
|
+
}, [onRecordingConfirm, seconds, recording]);
|
|
283
|
+
|
|
284
|
+
const cancelRecording = React.useCallback(() => {
|
|
285
|
+
endFocus.current = "mic";
|
|
286
|
+
onRecordingCancel?.();
|
|
287
|
+
if (recording === undefined) setInternalRecording(false);
|
|
288
|
+
}, [onRecordingCancel, recording]);
|
|
289
|
+
|
|
290
|
+
const startRecording = () => {
|
|
291
|
+
onMic?.();
|
|
292
|
+
if (recording === undefined) setInternalRecording(true);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// Timer
|
|
296
|
+
React.useEffect(() => {
|
|
297
|
+
if (!isRecording || hasError) return undefined;
|
|
298
|
+
setSeconds(0);
|
|
299
|
+
const t = window.setInterval(() => setSeconds((s) => s + 1), 1000);
|
|
300
|
+
return () => window.clearInterval(t);
|
|
301
|
+
}, [isRecording, hasError]);
|
|
302
|
+
|
|
303
|
+
// Auto-stop at the max duration
|
|
304
|
+
React.useEffect(() => {
|
|
305
|
+
if (isRecording && !hasError && seconds >= maxRecordingSeconds) confirmRecording();
|
|
306
|
+
}, [isRecording, hasError, seconds, maxRecordingSeconds, confirmRecording]);
|
|
307
|
+
|
|
308
|
+
// Simulated waveform (skipped when real levels are supplied)
|
|
309
|
+
React.useEffect(() => {
|
|
310
|
+
if (!isRecording || hasError || audioLevels || prefersReducedMotion()) {
|
|
311
|
+
return undefined;
|
|
312
|
+
}
|
|
313
|
+
setLevels(RESTING_LEVELS);
|
|
314
|
+
const t = window.setInterval(() => {
|
|
315
|
+
setLevels((prev) => [...prev.slice(1), nextLevel(prev[prev.length - 1] ?? MIN_LEVEL)]);
|
|
316
|
+
}, 90);
|
|
317
|
+
return () => window.clearInterval(t);
|
|
318
|
+
}, [isRecording, hasError, audioLevels, prefersReducedMotion]);
|
|
319
|
+
|
|
320
|
+
// Focus handoff on start / end
|
|
321
|
+
React.useEffect(() => {
|
|
322
|
+
if (isRecording) {
|
|
323
|
+
wasRecording.current = true;
|
|
324
|
+
const id = window.requestAnimationFrame(() => {
|
|
325
|
+
(hasError ? cancelRef.current : confirmRef.current)?.focus();
|
|
326
|
+
});
|
|
327
|
+
return () => window.cancelAnimationFrame(id);
|
|
328
|
+
}
|
|
329
|
+
if (wasRecording.current) {
|
|
330
|
+
wasRecording.current = false;
|
|
331
|
+
(endFocus.current === "textarea" ? textareaRef.current : micRef.current)?.focus();
|
|
332
|
+
}
|
|
333
|
+
return undefined;
|
|
334
|
+
}, [isRecording, hasError]);
|
|
335
|
+
|
|
336
|
+
const shownLevels = React.useMemo(() => {
|
|
337
|
+
if (!audioLevels) return levels;
|
|
338
|
+
const tail = audioLevels.slice(-BAR_COUNT);
|
|
339
|
+
return [...Array(BAR_COUNT - tail.length).fill(MIN_LEVEL), ...tail] as number[];
|
|
340
|
+
}, [audioLevels, levels]);
|
|
341
|
+
|
|
342
|
+
// With live levels, keep the waveform hidden until one of the most recent
|
|
343
|
+
// raw levels is above 0. Simulated waveform is always visible.
|
|
344
|
+
const waveformVisible = React.useMemo(
|
|
345
|
+
() => (audioLevels ? audioLevels.slice(-ACTIVITY_WINDOW).some((l) => l > 0) : true),
|
|
346
|
+
[audioLevels],
|
|
347
|
+
);
|
|
165
348
|
|
|
166
|
-
|
|
349
|
+
// Focus management for the + menu: first row on open / view change, "+" on close.
|
|
350
|
+
React.useEffect(() => {
|
|
351
|
+
if (menuOpen) {
|
|
352
|
+
wasOpen.current = true;
|
|
353
|
+
const t = window.setTimeout(() => {
|
|
354
|
+
const first = menuPanelRef.current?.querySelector<HTMLElement>(
|
|
355
|
+
'[data-active="true"] [data-menu-item]',
|
|
356
|
+
);
|
|
357
|
+
first?.focus();
|
|
358
|
+
}, 0);
|
|
359
|
+
return () => window.clearTimeout(t);
|
|
360
|
+
}
|
|
361
|
+
if (wasOpen.current) {
|
|
362
|
+
wasOpen.current = false;
|
|
363
|
+
plusRef.current?.focus();
|
|
364
|
+
}
|
|
365
|
+
return undefined;
|
|
366
|
+
}, [menuOpen, menuView]);
|
|
167
367
|
|
|
168
|
-
/** Add one or more image files to the image list. */
|
|
169
368
|
const addImageFiles = React.useCallback(
|
|
170
369
|
(files: File[]) => {
|
|
171
370
|
const next: PastedImage[] = files
|
|
@@ -177,28 +376,19 @@ export const PromptInputBar = React.forwardRef<
|
|
|
177
376
|
}));
|
|
178
377
|
if (next.length === 0) return;
|
|
179
378
|
const updated = [...images, ...next];
|
|
180
|
-
if (pastedImages
|
|
181
|
-
|
|
182
|
-
} else {
|
|
183
|
-
setInternalImages(updated);
|
|
184
|
-
onImagesChange?.(updated);
|
|
185
|
-
}
|
|
379
|
+
if (pastedImages === undefined) setInternalImages(updated);
|
|
380
|
+
onImagesChange?.(updated);
|
|
186
381
|
},
|
|
187
382
|
[images, pastedImages, onImagesChange],
|
|
188
383
|
);
|
|
189
384
|
|
|
190
|
-
/** Remove an image by id and revoke its object URL to avoid memory leaks. */
|
|
191
385
|
const removeImage = React.useCallback(
|
|
192
386
|
(id: string) => {
|
|
193
387
|
const target = images.find((img) => img.id === id);
|
|
194
|
-
if (target) URL.revokeObjectURL(target.url);
|
|
388
|
+
if (target?.url.startsWith("blob:")) URL.revokeObjectURL(target.url);
|
|
195
389
|
const updated = images.filter((img) => img.id !== id);
|
|
196
|
-
if (pastedImages
|
|
197
|
-
|
|
198
|
-
} else {
|
|
199
|
-
setInternalImages(updated);
|
|
200
|
-
onImagesChange?.(updated);
|
|
201
|
-
}
|
|
390
|
+
if (pastedImages === undefined) setInternalImages(updated);
|
|
391
|
+
onImagesChange?.(updated);
|
|
202
392
|
},
|
|
203
393
|
[images, pastedImages, onImagesChange],
|
|
204
394
|
);
|
|
@@ -212,13 +402,13 @@ export const PromptInputBar = React.forwardRef<
|
|
|
212
402
|
if (!textValue.trim() && images.length === 0) return;
|
|
213
403
|
onSend?.(textValue, images);
|
|
214
404
|
if (value === undefined) setInternalValue("");
|
|
215
|
-
if (pastedImages
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
405
|
+
if (pastedImages === undefined) {
|
|
406
|
+
internalImages.forEach((img) => {
|
|
407
|
+
if (img.url.startsWith("blob:")) URL.revokeObjectURL(img.url);
|
|
408
|
+
});
|
|
219
409
|
setInternalImages([]);
|
|
220
|
-
onImagesChange?.([]);
|
|
221
410
|
}
|
|
411
|
+
onImagesChange?.([]);
|
|
222
412
|
};
|
|
223
413
|
|
|
224
414
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
@@ -228,7 +418,6 @@ export const PromptInputBar = React.forwardRef<
|
|
|
228
418
|
}
|
|
229
419
|
};
|
|
230
420
|
|
|
231
|
-
/** Intercept paste events to capture image data. */
|
|
232
421
|
const handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {
|
|
233
422
|
const files = Array.from(e.clipboardData.items)
|
|
234
423
|
.filter((item) => item.kind === "file" && item.type.startsWith("image/"))
|
|
@@ -240,12 +429,10 @@ export const PromptInputBar = React.forwardRef<
|
|
|
240
429
|
}
|
|
241
430
|
};
|
|
242
431
|
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
onAttach?.();
|
|
248
|
-
}
|
|
432
|
+
const handleUploadClick = () => {
|
|
433
|
+
closeMenu();
|
|
434
|
+
if (onFilesSelected) fileInputRef.current?.click();
|
|
435
|
+
else onAttach?.();
|
|
249
436
|
};
|
|
250
437
|
|
|
251
438
|
const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -255,19 +442,81 @@ export const PromptInputBar = React.forwardRef<
|
|
|
255
442
|
}
|
|
256
443
|
};
|
|
257
444
|
|
|
258
|
-
const
|
|
259
|
-
const next = !
|
|
445
|
+
const toggleSuggest = () => {
|
|
446
|
+
const next = !suggestOn;
|
|
260
447
|
if (suggestDesigns === undefined) setInternalSuggestDesigns(next);
|
|
261
448
|
onSuggestDesignsChange?.(next);
|
|
262
449
|
};
|
|
263
450
|
|
|
264
|
-
const
|
|
265
|
-
(
|
|
451
|
+
const handleModelSelect = (m: PromptInputBarModel) => {
|
|
452
|
+
if (m.available === false) {
|
|
453
|
+
onUnavailableModelClick?.(m.id);
|
|
454
|
+
} else {
|
|
455
|
+
onModelChange?.(m.id);
|
|
456
|
+
}
|
|
457
|
+
closeMenu();
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/** Arrow-key roving focus + back navigation inside the + menu. */
|
|
461
|
+
const handleMenuKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
462
|
+
if (e.key === "Escape") {
|
|
463
|
+
e.stopPropagation();
|
|
464
|
+
closeMenu();
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (e.key === "ArrowLeft" || e.key === "Backspace") {
|
|
468
|
+
if (menuView === "models") {
|
|
469
|
+
e.preventDefault();
|
|
470
|
+
setMenuView("root");
|
|
471
|
+
}
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
475
|
+
e.preventDefault();
|
|
476
|
+
const items = Array.from(
|
|
477
|
+
menuPanelRef.current?.querySelectorAll<HTMLElement>(
|
|
478
|
+
'[data-active="true"] [data-menu-item]',
|
|
479
|
+
) ?? [],
|
|
480
|
+
);
|
|
481
|
+
if (items.length === 0) return;
|
|
482
|
+
const idx = items.indexOf(document.activeElement as HTMLElement);
|
|
483
|
+
const delta = e.key === "ArrowDown" ? 1 : -1;
|
|
484
|
+
const next = idx === -1 ? 0 : (idx + delta + items.length) % items.length;
|
|
485
|
+
items[next]?.focus();
|
|
486
|
+
}
|
|
487
|
+
if (e.key === "ArrowRight" && menuView === "root" && hasModels) {
|
|
488
|
+
const el = document.activeElement as HTMLElement | null;
|
|
489
|
+
if (el?.dataset.menuItem === "models") {
|
|
490
|
+
e.preventDefault();
|
|
491
|
+
setMenuView("models");
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const hasContent = textValue.trim().length > 0 || images.length > 0;
|
|
497
|
+
const canSend = hasContent && !disabled && !isStreaming;
|
|
266
498
|
const textareaDisabled = disabled || isStreaming;
|
|
499
|
+
const plusDisabled = disabled || isStreaming;
|
|
500
|
+
|
|
501
|
+
// Send and stop share one slot at the right of the mic: send is always
|
|
502
|
+
// shown when idle (dimmed until there is content); stop replaces it while streaming.
|
|
503
|
+
const sendState = isStreaming ? "idle" : "active";
|
|
504
|
+
const stopState = isStreaming ? "active" : "idle";
|
|
505
|
+
|
|
506
|
+
const idleLayerState = isRecording ? "idle" : "active";
|
|
507
|
+
const recLayerState = isRecording ? "active" : "idle";
|
|
508
|
+
const nearLimit = seconds >= maxRecordingSeconds - 10;
|
|
509
|
+
const announce = isRecording
|
|
510
|
+
? hasError
|
|
511
|
+
? ""
|
|
512
|
+
: `Recording, ${Math.floor(seconds / 10) * 10} seconds`
|
|
513
|
+
: "";
|
|
267
514
|
|
|
268
515
|
return (
|
|
269
|
-
<div
|
|
270
|
-
{
|
|
516
|
+
<div
|
|
517
|
+
ref={ref}
|
|
518
|
+
className={["w-full min-w-0", className].filter(Boolean).join(" ")}
|
|
519
|
+
>
|
|
271
520
|
{onFilesSelected && (
|
|
272
521
|
<Input
|
|
273
522
|
ref={fileInputRef}
|
|
@@ -280,45 +529,55 @@ export const PromptInputBar = React.forwardRef<
|
|
|
280
529
|
/>
|
|
281
530
|
)}
|
|
282
531
|
|
|
283
|
-
{/*
|
|
284
|
-
<div
|
|
532
|
+
{/* Card */}
|
|
533
|
+
<div
|
|
534
|
+
onKeyDown={(e) => {
|
|
535
|
+
if (e.key === "Escape" && isRecording) {
|
|
536
|
+
e.stopPropagation();
|
|
537
|
+
cancelRecording();
|
|
538
|
+
}
|
|
539
|
+
}}
|
|
540
|
+
className={[
|
|
541
|
+
"w-full min-w-0 rounded-xl bg-canvas shadow-card border p-base sm:px-lg sm:pt-lg sm:pb-md flex flex-col gap-md transition-colors duration-200 ease-out",
|
|
542
|
+
hasError
|
|
543
|
+
? "border-semantic-error"
|
|
544
|
+
: isRecording
|
|
545
|
+
? "border-primary"
|
|
546
|
+
: "border-hairline",
|
|
547
|
+
].join(" ")}
|
|
548
|
+
>
|
|
549
|
+
{/* Screen-reader status for recording */}
|
|
550
|
+
<span className="sr-only" role="status" aria-live="polite">
|
|
551
|
+
{isRecording && !hasError ? announce : ""}
|
|
552
|
+
</span>
|
|
285
553
|
|
|
286
|
-
{/*
|
|
554
|
+
{/* Pasted image thumbnails */}
|
|
287
555
|
{images.length > 0 && (
|
|
288
|
-
<
|
|
289
|
-
role="list"
|
|
556
|
+
<ul
|
|
290
557
|
aria-label="Attached images"
|
|
291
|
-
className="flex
|
|
558
|
+
className="flex min-w-0 gap-sm overflow-x-auto list-none m-0 p-0"
|
|
292
559
|
>
|
|
293
560
|
{images.map((img) => (
|
|
294
|
-
<
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
className="relative group flex-shrink-0"
|
|
298
|
-
>
|
|
299
|
-
<div className="w-16 h-16 rounded-md overflow-hidden border border-hairline bg-surface-soft">
|
|
300
|
-
<img
|
|
301
|
-
src={img.url}
|
|
302
|
-
alt={img.name}
|
|
303
|
-
className="w-full h-full object-cover"
|
|
304
|
-
/>
|
|
561
|
+
<li key={img.id} className="relative flex-shrink-0">
|
|
562
|
+
<div className="size-16 rounded-md overflow-hidden border border-hairline bg-surface-soft">
|
|
563
|
+
<img src={img.url} alt={img.name} className="size-full object-cover" />
|
|
305
564
|
</div>
|
|
306
|
-
<
|
|
307
|
-
|
|
308
|
-
size="sm"
|
|
565
|
+
<button
|
|
566
|
+
type="button"
|
|
309
567
|
onClick={() => removeImage(img.id)}
|
|
310
568
|
aria-label={`Remove image ${img.name}`}
|
|
311
|
-
className=
|
|
569
|
+
className={`absolute top-xs right-xs flex items-center justify-center size-5 rounded-full bg-ink text-on-primary hover:bg-body ${PRESS} ${FOCUS}`}
|
|
312
570
|
>
|
|
313
571
|
<Icon name="close" size={10} strokeWidth={2.5} />
|
|
314
|
-
</
|
|
315
|
-
</
|
|
572
|
+
</button>
|
|
573
|
+
</li>
|
|
316
574
|
))}
|
|
317
|
-
</
|
|
575
|
+
</ul>
|
|
318
576
|
)}
|
|
319
577
|
|
|
320
578
|
{/* Textarea */}
|
|
321
579
|
<textarea
|
|
580
|
+
ref={textareaRef}
|
|
322
581
|
aria-label="Prompt input"
|
|
323
582
|
placeholder={placeholder}
|
|
324
583
|
value={textValue}
|
|
@@ -326,254 +585,443 @@ export const PromptInputBar = React.forwardRef<
|
|
|
326
585
|
onKeyDown={handleKeyDown}
|
|
327
586
|
onPaste={handlePaste}
|
|
328
587
|
disabled={textareaDisabled}
|
|
588
|
+
readOnly={isRecording}
|
|
329
589
|
rows={2}
|
|
330
|
-
className=
|
|
590
|
+
className={`block w-full min-w-0 max-w-full resize-none bg-transparent text-body-md text-ink placeholder:text-muted-soft outline-none border-none transition-opacity duration-200 ease-out disabled:cursor-not-allowed disabled:opacity-50 ${isRecording ? "opacity-70" : ""}`}
|
|
331
591
|
/>
|
|
332
592
|
|
|
333
|
-
{/*
|
|
334
|
-
<div className="
|
|
335
|
-
{/*
|
|
336
|
-
<div
|
|
337
|
-
{
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
className="
|
|
593
|
+
{/* Single-row toolbar: idle layer and recording layer share one shrinkable cell */}
|
|
594
|
+
<div className="grid min-w-0 grid-cols-1">
|
|
595
|
+
{/* ── Idle layer ── */}
|
|
596
|
+
<div
|
|
597
|
+
data-state={idleLayerState}
|
|
598
|
+
inert={isRecording}
|
|
599
|
+
className={ROW_LAYER}
|
|
600
|
+
>
|
|
601
|
+
{/* "+" button and its menu */}
|
|
602
|
+
<div
|
|
603
|
+
ref={menuWrapRef}
|
|
604
|
+
className="relative flex-shrink-0"
|
|
605
|
+
style={{ zIndex: menuOpen ? "var(--z-dropdown, 1000)" : undefined }}
|
|
345
606
|
>
|
|
346
|
-
<
|
|
347
|
-
|
|
607
|
+
<button
|
|
608
|
+
ref={plusRef}
|
|
609
|
+
type="button"
|
|
610
|
+
onClick={() => (menuOpen ? closeMenu() : setMenuOpen(true))}
|
|
611
|
+
onKeyDown={(e) => {
|
|
612
|
+
if (e.key === "Escape") closeMenu();
|
|
613
|
+
}}
|
|
614
|
+
disabled={plusDisabled}
|
|
615
|
+
aria-label="Add attachment or change model"
|
|
616
|
+
aria-haspopup="menu"
|
|
617
|
+
aria-expanded={menuOpen}
|
|
618
|
+
aria-controls={`${uid}-menu`}
|
|
619
|
+
className={[
|
|
620
|
+
ROUND_BTN,
|
|
621
|
+
PRESS,
|
|
622
|
+
FOCUS,
|
|
623
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
624
|
+
menuOpen ? "bg-surface-strong" : "",
|
|
625
|
+
].join(" ")}
|
|
626
|
+
>
|
|
627
|
+
<Icon
|
|
628
|
+
name="plus-add"
|
|
629
|
+
size={16}
|
|
630
|
+
className={`transition-transform duration-200 ease-out ${menuOpen ? "rotate-45" : ""}`}
|
|
631
|
+
/>
|
|
632
|
+
</button>
|
|
348
633
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
634
|
+
<div
|
|
635
|
+
ref={menuPanelRef}
|
|
636
|
+
id={`${uid}-menu`}
|
|
637
|
+
data-state={menuOpen ? "open" : "closed"}
|
|
638
|
+
inert={!menuOpen}
|
|
639
|
+
onKeyDown={handleMenuKeyDown}
|
|
640
|
+
className={`${PANEL} bottom-full left-0 mb-md origin-bottom-left min-w-64 max-w-[calc(100vw-2rem)] rounded-xl border border-hairline bg-canvas p-xs shadow-md`}
|
|
641
|
+
style={{ zIndex: "var(--z-dropdown, 1000)" }}
|
|
357
642
|
>
|
|
358
|
-
<
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
643
|
+
<div className="relative">
|
|
644
|
+
{/* Root view */}
|
|
645
|
+
<div
|
|
646
|
+
role="menu"
|
|
647
|
+
aria-label="Add to prompt"
|
|
648
|
+
data-active={menuView === "root"}
|
|
649
|
+
inert={menuView !== "root"}
|
|
650
|
+
className={`${VIEW} ${menuView === "root" ? "" : "-translate-x-2"}`}
|
|
651
|
+
>
|
|
652
|
+
<button
|
|
653
|
+
type="button"
|
|
654
|
+
role="menuitem"
|
|
655
|
+
data-menu-item="upload"
|
|
656
|
+
onClick={handleUploadClick}
|
|
657
|
+
className={ROW}
|
|
658
|
+
>
|
|
659
|
+
<span className="flex size-9 flex-shrink-0 items-center justify-center rounded-md bg-surface-soft text-ink">
|
|
660
|
+
<Icon name="upload" size={18} />
|
|
661
|
+
</span>
|
|
662
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
663
|
+
<span className="text-body-md text-ink">Upload file</span>
|
|
664
|
+
<span className="text-caption text-muted">Images, PDFs and docs</span>
|
|
665
|
+
</span>
|
|
666
|
+
</button>
|
|
362
667
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
668
|
+
{hasModels && (
|
|
669
|
+
<>
|
|
670
|
+
<div role="separator" className="mx-sm my-xs h-px bg-hairline-soft" />
|
|
671
|
+
<button
|
|
672
|
+
type="button"
|
|
673
|
+
role="menuitem"
|
|
674
|
+
data-menu-item="models"
|
|
675
|
+
aria-haspopup="menu"
|
|
676
|
+
onClick={() => setMenuView("models")}
|
|
677
|
+
className={ROW}
|
|
678
|
+
>
|
|
679
|
+
<span className="flex size-9 flex-shrink-0 items-center justify-center rounded-md bg-surface-soft text-ink">
|
|
680
|
+
<Icon name="sparkle" size={18} />
|
|
681
|
+
</span>
|
|
682
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
683
|
+
<span className="text-body-md text-ink">Choose model</span>
|
|
684
|
+
<span className="truncate text-caption text-muted">
|
|
685
|
+
{currentModel?.name}
|
|
686
|
+
</span>
|
|
687
|
+
</span>
|
|
688
|
+
<Icon
|
|
689
|
+
name="chevron-right"
|
|
690
|
+
size={16}
|
|
691
|
+
strokeWidth={2}
|
|
692
|
+
className="flex-shrink-0 text-muted"
|
|
693
|
+
/>
|
|
694
|
+
</button>
|
|
695
|
+
</>
|
|
696
|
+
)}
|
|
697
|
+
</div>
|
|
382
698
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}}
|
|
399
|
-
onKeyDown={(e) => {
|
|
400
|
-
if (e.key === "Enter") {
|
|
401
|
-
onModelChange?.(m.id);
|
|
402
|
-
setModelOpen(false);
|
|
403
|
-
}
|
|
404
|
-
if (e.key === "Escape") setModelOpen(false);
|
|
405
|
-
}}
|
|
406
|
-
className={[
|
|
407
|
-
"flex flex-col w-full text-left px-md py-sm transition-colors duration-100 cursor-pointer",
|
|
408
|
-
m.id === selectedModelId
|
|
409
|
-
? "bg-surface-soft"
|
|
410
|
-
: "hover:bg-surface-soft",
|
|
411
|
-
].join(" ")}
|
|
699
|
+
{/* Model view (drill-in) */}
|
|
700
|
+
{hasModels && (
|
|
701
|
+
<div
|
|
702
|
+
role="menu"
|
|
703
|
+
aria-label="Model"
|
|
704
|
+
data-active={menuView === "models"}
|
|
705
|
+
inert={menuView !== "models"}
|
|
706
|
+
className={`${VIEW} ${menuView === "models" ? "" : "translate-x-2"}`}
|
|
707
|
+
>
|
|
708
|
+
<div className="flex items-center gap-sm px-xs pb-xs pt-xs">
|
|
709
|
+
<button
|
|
710
|
+
type="button"
|
|
711
|
+
data-menu-item="back"
|
|
712
|
+
onClick={() => setMenuView("root")}
|
|
713
|
+
aria-label="Back"
|
|
714
|
+
className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border border-hairline bg-surface-soft text-ink hover:bg-surface-strong ${PRESS} ${FOCUS}`}
|
|
412
715
|
>
|
|
413
|
-
<
|
|
414
|
-
|
|
716
|
+
<Icon name="arrow-left" size={16} />
|
|
717
|
+
</button>
|
|
718
|
+
<span className="text-body-md text-ink">Model</span>
|
|
719
|
+
</div>
|
|
720
|
+
|
|
721
|
+
{models?.map((m, i) => {
|
|
722
|
+
const isAvailable = m.available !== false;
|
|
723
|
+
const isSelected = isAvailable && m.id === currentModel?.id;
|
|
724
|
+
return (
|
|
725
|
+
<React.Fragment key={m.id}>
|
|
726
|
+
{i > 0 && (
|
|
727
|
+
<div role="separator" className="mx-sm h-px bg-hairline-soft" />
|
|
728
|
+
)}
|
|
729
|
+
<button
|
|
730
|
+
type="button"
|
|
731
|
+
role="menuitemradio"
|
|
732
|
+
aria-checked={isSelected}
|
|
733
|
+
aria-disabled={!isAvailable}
|
|
734
|
+
data-menu-item="model"
|
|
735
|
+
onClick={() => handleModelSelect(m)}
|
|
415
736
|
className={[
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
737
|
+
ROW,
|
|
738
|
+
"py-sm",
|
|
739
|
+
isSelected ? "bg-primary-soft hover:bg-primary-soft" : "",
|
|
740
|
+
!isAvailable ? "opacity-60" : "",
|
|
420
741
|
].join(" ")}
|
|
421
742
|
>
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
743
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
744
|
+
<span className="flex items-center gap-sm">
|
|
745
|
+
<span
|
|
746
|
+
className={`text-body-md ${isAvailable ? "text-ink" : "text-muted"}`}
|
|
747
|
+
>
|
|
748
|
+
{m.name}
|
|
749
|
+
</span>
|
|
750
|
+
{m.tier && (
|
|
751
|
+
<span className="rounded-full bg-surface-soft px-sm py-xxs text-caption text-body">
|
|
752
|
+
{m.tier}
|
|
753
|
+
</span>
|
|
754
|
+
)}
|
|
755
|
+
</span>
|
|
756
|
+
{m.description && isAvailable && (
|
|
757
|
+
<span className="text-caption text-muted">{m.description}</span>
|
|
758
|
+
)}
|
|
759
|
+
{!isAvailable && (
|
|
760
|
+
<span className="text-caption text-muted-soft">Unavailable</span>
|
|
761
|
+
)}
|
|
427
762
|
</span>
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
763
|
+
{isSelected && (
|
|
764
|
+
<Icon
|
|
765
|
+
name="check-checkmark"
|
|
766
|
+
size={18}
|
|
767
|
+
strokeWidth={2.25}
|
|
768
|
+
className="flex-shrink-0 text-primary"
|
|
769
|
+
/>
|
|
770
|
+
)}
|
|
771
|
+
</button>
|
|
772
|
+
</React.Fragment>
|
|
773
|
+
);
|
|
774
|
+
})}
|
|
775
|
+
</div>
|
|
776
|
+
)}
|
|
777
|
+
</div>
|
|
778
|
+
|
|
779
|
+
{/* Caret pointing at the + button */}
|
|
780
|
+
<span
|
|
781
|
+
aria-hidden="true"
|
|
782
|
+
className="absolute -bottom-1.5 left-base size-3 rotate-45 border-b border-r border-hairline bg-canvas"
|
|
783
|
+
/>
|
|
440
784
|
</div>
|
|
785
|
+
</div>
|
|
786
|
+
|
|
787
|
+
{/* Visual edits (optional) */}
|
|
788
|
+
{onVisualEdits !== undefined && (
|
|
789
|
+
<button
|
|
790
|
+
type="button"
|
|
791
|
+
onClick={onVisualEdits}
|
|
792
|
+
className={`flex min-w-0 flex-shrink items-center gap-xs overflow-hidden rounded-full bg-primary px-md py-xs text-body-sm text-on-primary whitespace-nowrap hover:bg-primary-hover active:bg-primary-active ${PRESS} ${FOCUS}`}
|
|
793
|
+
>
|
|
794
|
+
<Icon name="visual-edits-swap-arrows" size={16} className="flex-shrink-0" />
|
|
795
|
+
<span className="min-w-0 truncate">Visual edits</span>
|
|
796
|
+
</button>
|
|
441
797
|
)}
|
|
442
798
|
|
|
443
|
-
{/*
|
|
444
|
-
<
|
|
799
|
+
{/* Suggest designs toggle chip (the shrinkable element on narrow widths) */}
|
|
800
|
+
<button
|
|
801
|
+
type="button"
|
|
802
|
+
role="switch"
|
|
803
|
+
aria-checked={suggestOn}
|
|
804
|
+
aria-label="Suggest designs"
|
|
805
|
+
onClick={toggleSuggest}
|
|
806
|
+
className={[
|
|
807
|
+
"flex min-w-0 flex-shrink items-center gap-sm overflow-hidden rounded-full border px-md py-xs text-body-sm whitespace-nowrap",
|
|
808
|
+
PRESS,
|
|
809
|
+
FOCUS,
|
|
810
|
+
suggestOn
|
|
811
|
+
? "border-primary bg-primary-soft text-primary"
|
|
812
|
+
: "border-hairline bg-surface-soft text-muted hover:bg-surface-strong hover:text-ink",
|
|
813
|
+
].join(" ")}
|
|
814
|
+
>
|
|
815
|
+
<Icon
|
|
816
|
+
name="sparkle"
|
|
817
|
+
size={14}
|
|
818
|
+
className={`flex-shrink-0 transition duration-150 ease-out ${suggestOn ? "fill-current" : ""}`}
|
|
819
|
+
/>
|
|
820
|
+
<span className="min-w-0 truncate">Suggest designs</span>
|
|
445
821
|
<span
|
|
446
|
-
|
|
447
|
-
tabIndex={0}
|
|
448
|
-
aria-checked={suggestDesignsOn}
|
|
449
|
-
aria-label="Suggest Designs"
|
|
450
|
-
onClick={toggleSuggestDesigns}
|
|
451
|
-
onKeyDown={(e) => {
|
|
452
|
-
if (e.key === " " || e.key === "Enter") {
|
|
453
|
-
e.preventDefault();
|
|
454
|
-
toggleSuggestDesigns();
|
|
455
|
-
}
|
|
456
|
-
}}
|
|
822
|
+
aria-hidden="true"
|
|
457
823
|
className={[
|
|
458
|
-
"relative
|
|
459
|
-
|
|
824
|
+
"relative hidden h-4 w-7 flex-shrink-0 items-center rounded-full transition duration-150 ease-out sm:inline-flex",
|
|
825
|
+
suggestOn ? "bg-primary" : "bg-surface-strong",
|
|
460
826
|
].join(" ")}
|
|
461
827
|
>
|
|
462
828
|
<span
|
|
463
|
-
aria-hidden="true"
|
|
464
829
|
className={[
|
|
465
|
-
"inline-block size-3 rounded-full shadow-sm
|
|
466
|
-
|
|
467
|
-
? "translate-x-3.5 bg-on-primary"
|
|
468
|
-
: "translate-x-0.5 bg-canvas",
|
|
830
|
+
"inline-block size-3 rounded-full shadow-sm transition duration-150 ease-out",
|
|
831
|
+
suggestOn ? "translate-x-3.5 bg-on-primary" : "translate-x-0.5 bg-canvas",
|
|
469
832
|
].join(" ")}
|
|
470
833
|
/>
|
|
471
834
|
</span>
|
|
472
|
-
|
|
473
|
-
</span>
|
|
474
|
-
</div>
|
|
835
|
+
</button>
|
|
475
836
|
|
|
476
|
-
|
|
477
|
-
<div className="flex items-center gap-sm">
|
|
478
|
-
{/* ── Mode selector dropdown ── */}
|
|
837
|
+
{/* Mode selector (takes the free space so the cluster stays far right) */}
|
|
479
838
|
{showModeSelector && (
|
|
480
|
-
<div
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
839
|
+
<div
|
|
840
|
+
ref={modeRef}
|
|
841
|
+
className="relative ml-auto flex-shrink-0"
|
|
842
|
+
style={{ zIndex: modeOpen ? "var(--z-dropdown, 1000)" : undefined }}
|
|
843
|
+
onKeyDown={(e) => {
|
|
844
|
+
if (e.key === "Escape") setModeOpen(false);
|
|
845
|
+
}}
|
|
846
|
+
>
|
|
847
|
+
<button
|
|
848
|
+
type="button"
|
|
484
849
|
onClick={() => setModeOpen((o) => !o)}
|
|
485
|
-
onKeyDown={(e) => {
|
|
486
|
-
if (e.key === "Enter") setModeOpen((o) => !o);
|
|
487
|
-
if (e.key === "Escape") setModeOpen(false);
|
|
488
|
-
}}
|
|
489
850
|
aria-haspopup="listbox"
|
|
490
851
|
aria-expanded={modeOpen}
|
|
491
|
-
|
|
852
|
+
aria-controls={`${uid}-modes`}
|
|
853
|
+
aria-label={`Mode, current ${mode}`}
|
|
854
|
+
className={`flex items-center gap-sm rounded-sm px-sm py-xs text-body-md text-ink whitespace-nowrap hover:bg-surface-soft ${PRESS} ${FOCUS}`}
|
|
492
855
|
>
|
|
493
856
|
{mode}
|
|
494
|
-
<Icon
|
|
495
|
-
|
|
857
|
+
<Icon
|
|
858
|
+
name="chevron-down"
|
|
859
|
+
size={16}
|
|
860
|
+
strokeWidth={2.5}
|
|
861
|
+
className={`transition-transform duration-200 ease-out ${modeOpen ? "rotate-180" : ""}`}
|
|
862
|
+
/>
|
|
863
|
+
</button>
|
|
496
864
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
</span>
|
|
528
|
-
</li>
|
|
529
|
-
))}
|
|
530
|
-
</ul>
|
|
531
|
-
)}
|
|
865
|
+
<ul
|
|
866
|
+
id={`${uid}-modes`}
|
|
867
|
+
role="listbox"
|
|
868
|
+
aria-label="Mode options"
|
|
869
|
+
data-state={modeOpen ? "open" : "closed"}
|
|
870
|
+
inert={!modeOpen}
|
|
871
|
+
className={`${PANEL} bottom-full right-0 mb-xs origin-bottom-right min-w-32 list-none m-0 py-xs px-0 rounded-md border border-hairline bg-canvas shadow-md`}
|
|
872
|
+
style={{ zIndex: "var(--z-dropdown, 1000)" }}
|
|
873
|
+
>
|
|
874
|
+
{MODES.map((m) => (
|
|
875
|
+
<li key={m} role="presentation">
|
|
876
|
+
<button
|
|
877
|
+
type="button"
|
|
878
|
+
role="option"
|
|
879
|
+
aria-selected={m === mode}
|
|
880
|
+
onClick={() => {
|
|
881
|
+
onModeChange?.(m);
|
|
882
|
+
setModeOpen(false);
|
|
883
|
+
}}
|
|
884
|
+
className={[
|
|
885
|
+
"block w-full px-md py-xs text-left text-body-sm cursor-pointer transition duration-150 ease-out hover:bg-surface-soft active:scale-[0.98]",
|
|
886
|
+
FOCUS,
|
|
887
|
+
m === mode ? "bg-surface-soft text-ink" : "text-muted",
|
|
888
|
+
].join(" ")}
|
|
889
|
+
>
|
|
890
|
+
{m}
|
|
891
|
+
</button>
|
|
892
|
+
</li>
|
|
893
|
+
))}
|
|
894
|
+
</ul>
|
|
532
895
|
</div>
|
|
533
896
|
)}
|
|
534
897
|
|
|
535
|
-
{/*
|
|
536
|
-
<
|
|
537
|
-
|
|
538
|
-
tabIndex={0}
|
|
539
|
-
onClick={onMic}
|
|
540
|
-
onKeyDown={(e) => e.key === "Enter" && onMic?.()}
|
|
541
|
-
aria-label="Voice input"
|
|
542
|
-
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"
|
|
898
|
+
{/* Trailing cluster: mic + (send | stop), pushed to the far right */}
|
|
899
|
+
<div
|
|
900
|
+
className={`flex flex-shrink-0 items-center gap-sm ${showModeSelector ? "" : "ms-auto"}`}
|
|
543
901
|
>
|
|
544
|
-
<
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
tabIndex={0}
|
|
552
|
-
onClick={onStop}
|
|
553
|
-
onKeyDown={(e) => e.key === "Enter" && onStop?.()}
|
|
554
|
-
aria-label="Stop generation"
|
|
555
|
-
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"
|
|
902
|
+
<button
|
|
903
|
+
ref={micRef}
|
|
904
|
+
type="button"
|
|
905
|
+
onClick={startRecording}
|
|
906
|
+
disabled={disabled || isStreaming}
|
|
907
|
+
aria-label="Voice input"
|
|
908
|
+
className={`${ROUND_BTN} ${PRESS} ${FOCUS} disabled:cursor-not-allowed disabled:opacity-50`}
|
|
556
909
|
>
|
|
557
|
-
<Icon name="
|
|
558
|
-
</
|
|
910
|
+
<Icon name="mic" size={16} strokeWidth={1.75} />
|
|
911
|
+
</button>
|
|
912
|
+
|
|
913
|
+
{/* Send and stop share one size-9 slot; stop replaces send while streaming */}
|
|
914
|
+
<div className="relative size-9 flex-shrink-0">
|
|
915
|
+
<button
|
|
916
|
+
type="button"
|
|
917
|
+
onClick={handleSend}
|
|
918
|
+
disabled={!canSend}
|
|
919
|
+
inert={sendState === "idle"}
|
|
920
|
+
data-state={sendState}
|
|
921
|
+
aria-label="Send"
|
|
922
|
+
className={`${LAYER} bg-primary text-on-primary hover:bg-primary-hover active:bg-primary-active cursor-pointer active:scale-[0.98] ${FOCUS} data-[state=active]:disabled:opacity-50 disabled:cursor-not-allowed`}
|
|
923
|
+
>
|
|
924
|
+
<Icon name="arrow-up-send" size={16} strokeWidth={2.25} />
|
|
925
|
+
</button>
|
|
926
|
+
|
|
927
|
+
<button
|
|
928
|
+
type="button"
|
|
929
|
+
onClick={onStop}
|
|
930
|
+
inert={stopState === "idle"}
|
|
931
|
+
data-state={stopState}
|
|
932
|
+
aria-label="Stop generation"
|
|
933
|
+
className={`${LAYER} bg-ink text-on-primary hover:bg-body cursor-pointer active:scale-[0.98] ${FOCUS}`}
|
|
934
|
+
>
|
|
935
|
+
<Icon name="stop-square" size={16} strokeWidth={0} className="fill-current" />
|
|
936
|
+
</button>
|
|
937
|
+
</div>
|
|
938
|
+
</div>
|
|
939
|
+
</div>
|
|
940
|
+
|
|
941
|
+
{/* ── Recording layer (compact, same row height) ── */}
|
|
942
|
+
<div
|
|
943
|
+
data-state={recLayerState}
|
|
944
|
+
inert={!isRecording}
|
|
945
|
+
className={ROW_LAYER}
|
|
946
|
+
>
|
|
947
|
+
{/* Cancel / close */}
|
|
948
|
+
<button
|
|
949
|
+
ref={cancelRef}
|
|
950
|
+
type="button"
|
|
951
|
+
onClick={cancelRecording}
|
|
952
|
+
aria-label={hasError ? "Close" : "Cancel recording"}
|
|
953
|
+
className={`${ROUND_BTN} ${PRESS} ${FOCUS}`}
|
|
954
|
+
>
|
|
955
|
+
<Icon name="close" size={16} strokeWidth={2} />
|
|
956
|
+
</button>
|
|
957
|
+
|
|
958
|
+
{/* Recording pill */}
|
|
959
|
+
{hasError ? (
|
|
960
|
+
<div className="flex h-9 min-w-0 flex-1 items-center gap-sm rounded-full border border-semantic-error bg-semantic-error-soft px-md">
|
|
961
|
+
<Icon
|
|
962
|
+
name="circle-alert"
|
|
963
|
+
size={18}
|
|
964
|
+
className="flex-shrink-0 text-semantic-error"
|
|
965
|
+
/>
|
|
966
|
+
<span role="alert" className="min-w-0 truncate text-body-sm text-semantic-error">
|
|
967
|
+
{recordingError}
|
|
968
|
+
</span>
|
|
969
|
+
</div>
|
|
559
970
|
) : (
|
|
971
|
+
<div className="flex h-9 min-w-0 flex-1 items-center gap-md overflow-hidden rounded-full border border-hairline bg-surface-soft px-md">
|
|
972
|
+
<span
|
|
973
|
+
aria-hidden="true"
|
|
974
|
+
className="size-2 flex-shrink-0 rounded-full bg-semantic-error animate-pulse motion-reduce:animate-none"
|
|
975
|
+
/>
|
|
976
|
+
{/* Dense rounded bars fill the space between the dot and the timer; oldest clip off the left edge */}
|
|
977
|
+
<div
|
|
978
|
+
aria-hidden="true"
|
|
979
|
+
data-visible={waveformVisible}
|
|
980
|
+
className="flex h-6 min-w-0 flex-1 items-center justify-end gap-xxs overflow-hidden transition-opacity duration-200 ease-out data-[visible=false]:opacity-0"
|
|
981
|
+
>
|
|
982
|
+
{shownLevels.map((lvl, i) => (
|
|
983
|
+
<span
|
|
984
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
985
|
+
key={i}
|
|
986
|
+
className="min-w-1 flex-1 rounded-full bg-primary"
|
|
987
|
+
style={{
|
|
988
|
+
height: `${Math.round(Math.max(MIN_LEVEL, Math.min(1, lvl)) * 100)}%`,
|
|
989
|
+
// Rounded to 3 decimals so server and client serialize identically (no hydration mismatch).
|
|
990
|
+
opacity:
|
|
991
|
+
Math.round((0.18 + 0.82 * (i / (BAR_COUNT - 1)) ** 1.3) * 1000) / 1000,
|
|
992
|
+
}}
|
|
993
|
+
/>
|
|
994
|
+
))}
|
|
995
|
+
</div>
|
|
996
|
+
<span
|
|
997
|
+
aria-hidden="true"
|
|
998
|
+
className={`flex-shrink-0 text-body-sm tabular-nums ${nearLimit ? "text-semantic-warning" : "text-ink"}`}
|
|
999
|
+
>
|
|
1000
|
+
{formatTime(seconds)}
|
|
1001
|
+
</span>
|
|
1002
|
+
</div>
|
|
1003
|
+
)}
|
|
1004
|
+
|
|
1005
|
+
{/* Confirm (hidden in the error state) */}
|
|
1006
|
+
<div
|
|
1007
|
+
className={`relative size-9 flex-shrink-0 transition duration-150 ease-out ${hasError ? "pointer-events-none scale-75 opacity-0" : "scale-100 opacity-100"}`}
|
|
1008
|
+
>
|
|
560
1009
|
<span
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
].join(" ")}
|
|
1010
|
+
aria-hidden="true"
|
|
1011
|
+
className="absolute -inset-1 rounded-full bg-primary-soft animate-pulse motion-reduce:animate-none"
|
|
1012
|
+
/>
|
|
1013
|
+
<button
|
|
1014
|
+
ref={confirmRef}
|
|
1015
|
+
type="button"
|
|
1016
|
+
onClick={confirmRecording}
|
|
1017
|
+
disabled={hasError}
|
|
1018
|
+
tabIndex={hasError ? -1 : 0}
|
|
1019
|
+
aria-label="Stop recording and use transcript"
|
|
1020
|
+
className={`relative flex size-full items-center justify-center rounded-full bg-primary text-on-primary hover:bg-primary-hover active:bg-primary-active after:absolute after:-inset-1 after:content-[''] ${PRESS} ${FOCUS} disabled:cursor-not-allowed`}
|
|
573
1021
|
>
|
|
574
|
-
<Icon name="
|
|
575
|
-
</
|
|
576
|
-
|
|
1022
|
+
<Icon name="check-checkmark" size={16} strokeWidth={2.5} />
|
|
1023
|
+
</button>
|
|
1024
|
+
</div>
|
|
577
1025
|
</div>
|
|
578
1026
|
</div>
|
|
579
1027
|
</div>
|