@cloudbase/agent-react-ui 1.0.1-alpha.32
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 +123 -0
- package/components.json +21 -0
- package/dist/index.css +4241 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +2169 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2182 -0
- package/dist/index.mjs.map +1 -0
- package/example/.env.sample +2 -0
- package/example/App.tsx +368 -0
- package/example/app.css +1 -0
- package/example/index.html +12 -0
- package/example/main.tsx +9 -0
- package/example/vite.config.ts +34 -0
- package/package.json +75 -0
- package/postcss.config.cjs +3 -0
- package/src/components/ai-elements/agent.tsx +140 -0
- package/src/components/ai-elements/artifact.tsx +147 -0
- package/src/components/ai-elements/attachments.tsx +421 -0
- package/src/components/ai-elements/audio-player.tsx +228 -0
- package/src/components/ai-elements/canvas.tsx +22 -0
- package/src/components/ai-elements/chain-of-thought.tsx +228 -0
- package/src/components/ai-elements/checkpoint.tsx +71 -0
- package/src/components/ai-elements/code-block.tsx +532 -0
- package/src/components/ai-elements/commit.tsx +448 -0
- package/src/components/ai-elements/confirmation.tsx +176 -0
- package/src/components/ai-elements/connection.tsx +28 -0
- package/src/components/ai-elements/context.tsx +408 -0
- package/src/components/ai-elements/controls.tsx +18 -0
- package/src/components/ai-elements/conversation.tsx +100 -0
- package/src/components/ai-elements/edge.tsx +140 -0
- package/src/components/ai-elements/environment-variables.tsx +295 -0
- package/src/components/ai-elements/file-tree.tsx +258 -0
- package/src/components/ai-elements/image.tsx +24 -0
- package/src/components/ai-elements/inline-citation.tsx +287 -0
- package/src/components/ai-elements/message.tsx +336 -0
- package/src/components/ai-elements/mic-selector.tsx +370 -0
- package/src/components/ai-elements/model-selector.tsx +211 -0
- package/src/components/ai-elements/node.tsx +71 -0
- package/src/components/ai-elements/open-in-chat.tsx +365 -0
- package/src/components/ai-elements/package-info.tsx +233 -0
- package/src/components/ai-elements/panel.tsx +15 -0
- package/src/components/ai-elements/persona.tsx +270 -0
- package/src/components/ai-elements/plan.tsx +142 -0
- package/src/components/ai-elements/prompt-input.tsx +1263 -0
- package/src/components/ai-elements/queue.tsx +274 -0
- package/src/components/ai-elements/reasoning.tsx +193 -0
- package/src/components/ai-elements/sandbox.tsx +126 -0
- package/src/components/ai-elements/schema-display.tsx +458 -0
- package/src/components/ai-elements/shimmer.tsx +64 -0
- package/src/components/ai-elements/snippet.tsx +139 -0
- package/src/components/ai-elements/sources.tsx +77 -0
- package/src/components/ai-elements/speech-input.tsx +301 -0
- package/src/components/ai-elements/stack-trace.tsx +482 -0
- package/src/components/ai-elements/suggestion.tsx +53 -0
- package/src/components/ai-elements/task.tsx +87 -0
- package/src/components/ai-elements/terminal.tsx +261 -0
- package/src/components/ai-elements/test-results.tsx +485 -0
- package/src/components/ai-elements/tool.tsx +174 -0
- package/src/components/ai-elements/toolbar.tsx +16 -0
- package/src/components/ai-elements/transcription.tsx +124 -0
- package/src/components/ai-elements/voice-selector.tsx +479 -0
- package/src/components/ai-elements/web-preview.tsx +263 -0
- package/src/components/chat/Chat.tsx +178 -0
- package/src/components/chat/Input.tsx +98 -0
- package/src/components/chat/Message.tsx +276 -0
- package/src/components/chat/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/components/ui/accordion.tsx +64 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/avatar.tsx +107 -0
- package/src/components/ui/badge.tsx +48 -0
- package/src/components/ui/button-group.tsx +83 -0
- package/src/components/ui/button.tsx +64 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/carousel.tsx +239 -0
- package/src/components/ui/collapsible.tsx +31 -0
- package/src/components/ui/command.tsx +184 -0
- package/src/components/ui/dialog.tsx +158 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/hover-card.tsx +42 -0
- package/src/components/ui/input-group.tsx +168 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/popover.tsx +87 -0
- package/src/components/ui/progress.tsx +31 -0
- package/src/components/ui/scroll-area.tsx +56 -0
- package/src/components/ui/select.tsx +190 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/spinner.tsx +16 -0
- package/src/components/ui/switch.tsx +33 -0
- package/src/components/ui/tabs.tsx +91 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/css/global.css +123 -0
- package/src/css/index.css +1 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-copy-to-clipboard.ts +31 -0
- package/src/index.ts +4 -0
- package/src/lib/utils.ts +6 -0
- package/src/locales/context.ts +8 -0
- package/src/locales/hooks.ts +20 -0
- package/src/locales/index.ts +3 -0
- package/src/locales/langs/en.ts +17 -0
- package/src/locales/langs/index.ts +12 -0
- package/src/locales/langs/zh-cn.ts +18 -0
- package/tsconfig.json +21 -0
- package/tsup.config.ts +21 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
import type { Experimental_TranscriptionResult as TranscriptionResult } from "ai";
|
|
6
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
7
|
+
import { createContext, useContext } from "react";
|
|
8
|
+
|
|
9
|
+
type TranscriptionSegment = TranscriptionResult["segments"][number];
|
|
10
|
+
|
|
11
|
+
interface TranscriptionContextValue {
|
|
12
|
+
segments: TranscriptionSegment[];
|
|
13
|
+
currentTime: number;
|
|
14
|
+
onTimeUpdate: (time: number) => void;
|
|
15
|
+
onSeek?: (time: number) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const TranscriptionContext = createContext<TranscriptionContextValue | null>(
|
|
19
|
+
null
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const useTranscription = () => {
|
|
23
|
+
const context = useContext(TranscriptionContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"Transcription components must be used within Transcription"
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return context;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type TranscriptionProps = Omit<ComponentProps<"div">, "children"> & {
|
|
33
|
+
segments: TranscriptionSegment[];
|
|
34
|
+
currentTime?: number;
|
|
35
|
+
onSeek?: (time: number) => void;
|
|
36
|
+
children: (segment: TranscriptionSegment, index: number) => ReactNode;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Transcription = ({
|
|
40
|
+
segments,
|
|
41
|
+
currentTime: externalCurrentTime,
|
|
42
|
+
onSeek,
|
|
43
|
+
className,
|
|
44
|
+
children,
|
|
45
|
+
...props
|
|
46
|
+
}: TranscriptionProps) => {
|
|
47
|
+
const [currentTime, setCurrentTime] = useControllableState({
|
|
48
|
+
prop: externalCurrentTime,
|
|
49
|
+
defaultProp: 0,
|
|
50
|
+
onChange: onSeek,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<TranscriptionContext.Provider
|
|
55
|
+
value={{
|
|
56
|
+
segments,
|
|
57
|
+
currentTime,
|
|
58
|
+
onTimeUpdate: setCurrentTime,
|
|
59
|
+
onSeek,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
className={cn(
|
|
64
|
+
"flex flex-wrap gap-1 text-sm leading-relaxed",
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
data-slot="transcription"
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
{segments
|
|
71
|
+
.filter((segment) => segment.text.trim())
|
|
72
|
+
.map((segment, index) => children(segment, index))}
|
|
73
|
+
</div>
|
|
74
|
+
</TranscriptionContext.Provider>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type TranscriptionSegmentProps = ComponentProps<"button"> & {
|
|
79
|
+
segment: TranscriptionSegment;
|
|
80
|
+
index: number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const TranscriptionSegment = ({
|
|
84
|
+
segment,
|
|
85
|
+
index,
|
|
86
|
+
className,
|
|
87
|
+
onClick,
|
|
88
|
+
...props
|
|
89
|
+
}: TranscriptionSegmentProps) => {
|
|
90
|
+
const { currentTime, onSeek } = useTranscription();
|
|
91
|
+
|
|
92
|
+
const isActive =
|
|
93
|
+
currentTime >= segment.startSecond && currentTime < segment.endSecond;
|
|
94
|
+
const isPast = currentTime >= segment.endSecond;
|
|
95
|
+
|
|
96
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
97
|
+
if (onSeek) {
|
|
98
|
+
onSeek(segment.startSecond);
|
|
99
|
+
}
|
|
100
|
+
onClick?.(event);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<button
|
|
105
|
+
className={cn(
|
|
106
|
+
"inline text-left",
|
|
107
|
+
isActive && "text-primary",
|
|
108
|
+
isPast && "text-muted-foreground",
|
|
109
|
+
!(isActive || isPast) && "text-muted-foreground/60",
|
|
110
|
+
onSeek && "cursor-pointer hover:text-foreground",
|
|
111
|
+
!onSeek && "cursor-default",
|
|
112
|
+
className
|
|
113
|
+
)}
|
|
114
|
+
data-active={isActive}
|
|
115
|
+
data-index={index}
|
|
116
|
+
data-slot="transcription-segment"
|
|
117
|
+
onClick={handleClick}
|
|
118
|
+
type="button"
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
{segment.text}
|
|
122
|
+
</button>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
4
|
+
import { Button } from "@/components/ui/button";
|
|
5
|
+
import {
|
|
6
|
+
Command,
|
|
7
|
+
CommandDialog,
|
|
8
|
+
CommandEmpty,
|
|
9
|
+
CommandGroup,
|
|
10
|
+
CommandInput,
|
|
11
|
+
CommandItem,
|
|
12
|
+
CommandList,
|
|
13
|
+
CommandSeparator,
|
|
14
|
+
CommandShortcut,
|
|
15
|
+
} from "@/components/ui/command";
|
|
16
|
+
import {
|
|
17
|
+
Dialog,
|
|
18
|
+
DialogContent,
|
|
19
|
+
DialogTitle,
|
|
20
|
+
DialogTrigger,
|
|
21
|
+
} from "@/components/ui/dialog";
|
|
22
|
+
import { Spinner } from "@/components/ui/spinner";
|
|
23
|
+
import { cn } from "@/lib/utils";
|
|
24
|
+
import {
|
|
25
|
+
CircleSmallIcon,
|
|
26
|
+
MarsIcon,
|
|
27
|
+
MarsStrokeIcon,
|
|
28
|
+
NonBinaryIcon,
|
|
29
|
+
PauseIcon,
|
|
30
|
+
PlayIcon,
|
|
31
|
+
TransgenderIcon,
|
|
32
|
+
VenusAndMarsIcon,
|
|
33
|
+
VenusIcon,
|
|
34
|
+
} from "lucide-react";
|
|
35
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
36
|
+
import { createContext, useContext, useMemo } from "react";
|
|
37
|
+
|
|
38
|
+
interface VoiceSelectorContextValue {
|
|
39
|
+
value: string | undefined;
|
|
40
|
+
setValue: (value: string | undefined) => void;
|
|
41
|
+
open: boolean;
|
|
42
|
+
setOpen: (open: boolean) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const VoiceSelectorContext = createContext<VoiceSelectorContextValue | null>(
|
|
46
|
+
null
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const useVoiceSelector = () => {
|
|
50
|
+
const context = useContext(VoiceSelectorContext);
|
|
51
|
+
if (!context) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
"VoiceSelector components must be used within VoiceSelector"
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return context;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type VoiceSelectorProps = ComponentProps<typeof Dialog> & {
|
|
60
|
+
value?: string;
|
|
61
|
+
defaultValue?: string;
|
|
62
|
+
onValueChange?: (value: string | undefined) => void;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const VoiceSelector = ({
|
|
66
|
+
value: valueProp,
|
|
67
|
+
defaultValue,
|
|
68
|
+
onValueChange,
|
|
69
|
+
open: openProp,
|
|
70
|
+
defaultOpen = false,
|
|
71
|
+
onOpenChange,
|
|
72
|
+
children,
|
|
73
|
+
...props
|
|
74
|
+
}: VoiceSelectorProps) => {
|
|
75
|
+
const [value, setValue] = useControllableState({
|
|
76
|
+
prop: valueProp,
|
|
77
|
+
defaultProp: defaultValue,
|
|
78
|
+
onChange: onValueChange,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const [open, setOpen] = useControllableState({
|
|
82
|
+
prop: openProp,
|
|
83
|
+
defaultProp: defaultOpen,
|
|
84
|
+
onChange: onOpenChange,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const voiceSelectorContext = useMemo(
|
|
88
|
+
() => ({ value, setValue, open, setOpen }),
|
|
89
|
+
[value, setValue, open, setOpen]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<VoiceSelectorContext.Provider value={voiceSelectorContext}>
|
|
94
|
+
<Dialog onOpenChange={setOpen} open={open} {...props}>
|
|
95
|
+
{children}
|
|
96
|
+
</Dialog>
|
|
97
|
+
</VoiceSelectorContext.Provider>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type VoiceSelectorTriggerProps = ComponentProps<typeof DialogTrigger>;
|
|
102
|
+
|
|
103
|
+
export const VoiceSelectorTrigger = (props: VoiceSelectorTriggerProps) => (
|
|
104
|
+
<DialogTrigger {...props} />
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
export type VoiceSelectorContentProps = ComponentProps<typeof DialogContent> & {
|
|
108
|
+
title?: ReactNode;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const VoiceSelectorContent = ({
|
|
112
|
+
className,
|
|
113
|
+
children,
|
|
114
|
+
title = "Voice Selector",
|
|
115
|
+
...props
|
|
116
|
+
}: VoiceSelectorContentProps) => (
|
|
117
|
+
<DialogContent className={cn("p-0", className)} {...props}>
|
|
118
|
+
<DialogTitle className="sr-only">{title}</DialogTitle>
|
|
119
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-auto">
|
|
120
|
+
{children}
|
|
121
|
+
</Command>
|
|
122
|
+
</DialogContent>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
export type VoiceSelectorDialogProps = ComponentProps<typeof CommandDialog>;
|
|
126
|
+
|
|
127
|
+
export const VoiceSelectorDialog = (props: VoiceSelectorDialogProps) => (
|
|
128
|
+
<CommandDialog {...props} />
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
export type VoiceSelectorInputProps = ComponentProps<typeof CommandInput>;
|
|
132
|
+
|
|
133
|
+
export const VoiceSelectorInput = ({
|
|
134
|
+
className,
|
|
135
|
+
...props
|
|
136
|
+
}: VoiceSelectorInputProps) => (
|
|
137
|
+
<CommandInput className={cn("h-auto py-3.5", className)} {...props} />
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
export type VoiceSelectorListProps = ComponentProps<typeof CommandList>;
|
|
141
|
+
|
|
142
|
+
export const VoiceSelectorList = (props: VoiceSelectorListProps) => (
|
|
143
|
+
<CommandList {...props} />
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
export type VoiceSelectorEmptyProps = ComponentProps<typeof CommandEmpty>;
|
|
147
|
+
|
|
148
|
+
export const VoiceSelectorEmpty = (props: VoiceSelectorEmptyProps) => (
|
|
149
|
+
<CommandEmpty {...props} />
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
export type VoiceSelectorGroupProps = ComponentProps<typeof CommandGroup>;
|
|
153
|
+
|
|
154
|
+
export const VoiceSelectorGroup = (props: VoiceSelectorGroupProps) => (
|
|
155
|
+
<CommandGroup {...props} />
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
export type VoiceSelectorItemProps = ComponentProps<typeof CommandItem>;
|
|
159
|
+
|
|
160
|
+
export const VoiceSelectorItem = ({
|
|
161
|
+
className,
|
|
162
|
+
...props
|
|
163
|
+
}: VoiceSelectorItemProps) => (
|
|
164
|
+
<CommandItem className={cn("px-4 py-2", className)} {...props} />
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
export type VoiceSelectorShortcutProps = ComponentProps<typeof CommandShortcut>;
|
|
168
|
+
|
|
169
|
+
export const VoiceSelectorShortcut = (props: VoiceSelectorShortcutProps) => (
|
|
170
|
+
<CommandShortcut {...props} />
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
export type VoiceSelectorSeparatorProps = ComponentProps<
|
|
174
|
+
typeof CommandSeparator
|
|
175
|
+
>;
|
|
176
|
+
|
|
177
|
+
export const VoiceSelectorSeparator = (props: VoiceSelectorSeparatorProps) => (
|
|
178
|
+
<CommandSeparator {...props} />
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
export type VoiceSelectorGenderProps = ComponentProps<"span"> & {
|
|
182
|
+
value?:
|
|
183
|
+
| "male"
|
|
184
|
+
| "female"
|
|
185
|
+
| "transgender"
|
|
186
|
+
| "androgyne"
|
|
187
|
+
| "non-binary"
|
|
188
|
+
| "intersex";
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const VoiceSelectorGender = ({
|
|
192
|
+
className,
|
|
193
|
+
value,
|
|
194
|
+
children,
|
|
195
|
+
...props
|
|
196
|
+
}: VoiceSelectorGenderProps) => {
|
|
197
|
+
let icon: ReactNode | null = null;
|
|
198
|
+
|
|
199
|
+
switch (value) {
|
|
200
|
+
case "male":
|
|
201
|
+
icon = <MarsIcon className="size-4" />;
|
|
202
|
+
break;
|
|
203
|
+
case "female":
|
|
204
|
+
icon = <VenusIcon className="size-4" />;
|
|
205
|
+
break;
|
|
206
|
+
case "transgender":
|
|
207
|
+
icon = <TransgenderIcon className="size-4" />;
|
|
208
|
+
break;
|
|
209
|
+
case "androgyne":
|
|
210
|
+
icon = <MarsStrokeIcon className="size-4" />;
|
|
211
|
+
break;
|
|
212
|
+
case "non-binary":
|
|
213
|
+
icon = <NonBinaryIcon className="size-4" />;
|
|
214
|
+
break;
|
|
215
|
+
case "intersex":
|
|
216
|
+
icon = <VenusAndMarsIcon className="size-4" />;
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
icon = <CircleSmallIcon className="size-4" />;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<span className={cn("text-muted-foreground text-xs", className)} {...props}>
|
|
224
|
+
{children ?? icon}
|
|
225
|
+
</span>
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type VoiceSelectorAccentProps = ComponentProps<"span"> & {
|
|
230
|
+
value?:
|
|
231
|
+
| "american"
|
|
232
|
+
| "british"
|
|
233
|
+
| "australian"
|
|
234
|
+
| "canadian"
|
|
235
|
+
| "irish"
|
|
236
|
+
| "scottish"
|
|
237
|
+
| "indian"
|
|
238
|
+
| "south-african"
|
|
239
|
+
| "new-zealand"
|
|
240
|
+
| "spanish"
|
|
241
|
+
| "french"
|
|
242
|
+
| "german"
|
|
243
|
+
| "italian"
|
|
244
|
+
| "portuguese"
|
|
245
|
+
| "brazilian"
|
|
246
|
+
| "mexican"
|
|
247
|
+
| "argentinian"
|
|
248
|
+
| "japanese"
|
|
249
|
+
| "chinese"
|
|
250
|
+
| "korean"
|
|
251
|
+
| "russian"
|
|
252
|
+
| "arabic"
|
|
253
|
+
| "dutch"
|
|
254
|
+
| "swedish"
|
|
255
|
+
| "norwegian"
|
|
256
|
+
| "danish"
|
|
257
|
+
| "finnish"
|
|
258
|
+
| "polish"
|
|
259
|
+
| "turkish"
|
|
260
|
+
| "greek"
|
|
261
|
+
| string;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const VoiceSelectorAccent = ({
|
|
265
|
+
className,
|
|
266
|
+
value,
|
|
267
|
+
children,
|
|
268
|
+
...props
|
|
269
|
+
}: VoiceSelectorAccentProps) => {
|
|
270
|
+
let emoji: string | null = null;
|
|
271
|
+
|
|
272
|
+
switch (value) {
|
|
273
|
+
case "american":
|
|
274
|
+
emoji = "🇺🇸";
|
|
275
|
+
break;
|
|
276
|
+
case "british":
|
|
277
|
+
emoji = "🇬🇧";
|
|
278
|
+
break;
|
|
279
|
+
case "australian":
|
|
280
|
+
emoji = "🇦🇺";
|
|
281
|
+
break;
|
|
282
|
+
case "canadian":
|
|
283
|
+
emoji = "🇨🇦";
|
|
284
|
+
break;
|
|
285
|
+
case "irish":
|
|
286
|
+
emoji = "🇮🇪";
|
|
287
|
+
break;
|
|
288
|
+
case "scottish":
|
|
289
|
+
emoji = "🏴";
|
|
290
|
+
break;
|
|
291
|
+
case "indian":
|
|
292
|
+
emoji = "🇮🇳";
|
|
293
|
+
break;
|
|
294
|
+
case "south-african":
|
|
295
|
+
emoji = "🇿🇦";
|
|
296
|
+
break;
|
|
297
|
+
case "new-zealand":
|
|
298
|
+
emoji = "🇳🇿";
|
|
299
|
+
break;
|
|
300
|
+
case "spanish":
|
|
301
|
+
emoji = "🇪🇸";
|
|
302
|
+
break;
|
|
303
|
+
case "french":
|
|
304
|
+
emoji = "🇫🇷";
|
|
305
|
+
break;
|
|
306
|
+
case "german":
|
|
307
|
+
emoji = "🇩🇪";
|
|
308
|
+
break;
|
|
309
|
+
case "italian":
|
|
310
|
+
emoji = "🇮🇹";
|
|
311
|
+
break;
|
|
312
|
+
case "portuguese":
|
|
313
|
+
emoji = "🇵🇹";
|
|
314
|
+
break;
|
|
315
|
+
case "brazilian":
|
|
316
|
+
emoji = "🇧🇷";
|
|
317
|
+
break;
|
|
318
|
+
case "mexican":
|
|
319
|
+
emoji = "🇲🇽";
|
|
320
|
+
break;
|
|
321
|
+
case "argentinian":
|
|
322
|
+
emoji = "🇦🇷";
|
|
323
|
+
break;
|
|
324
|
+
case "japanese":
|
|
325
|
+
emoji = "🇯🇵";
|
|
326
|
+
break;
|
|
327
|
+
case "chinese":
|
|
328
|
+
emoji = "🇨🇳";
|
|
329
|
+
break;
|
|
330
|
+
case "korean":
|
|
331
|
+
emoji = "🇰🇷";
|
|
332
|
+
break;
|
|
333
|
+
case "russian":
|
|
334
|
+
emoji = "🇷🇺";
|
|
335
|
+
break;
|
|
336
|
+
case "arabic":
|
|
337
|
+
emoji = "🇸🇦";
|
|
338
|
+
break;
|
|
339
|
+
case "dutch":
|
|
340
|
+
emoji = "🇳🇱";
|
|
341
|
+
break;
|
|
342
|
+
case "swedish":
|
|
343
|
+
emoji = "🇸🇪";
|
|
344
|
+
break;
|
|
345
|
+
case "norwegian":
|
|
346
|
+
emoji = "🇳🇴";
|
|
347
|
+
break;
|
|
348
|
+
case "danish":
|
|
349
|
+
emoji = "🇩🇰";
|
|
350
|
+
break;
|
|
351
|
+
case "finnish":
|
|
352
|
+
emoji = "🇫🇮";
|
|
353
|
+
break;
|
|
354
|
+
case "polish":
|
|
355
|
+
emoji = "🇵🇱";
|
|
356
|
+
break;
|
|
357
|
+
case "turkish":
|
|
358
|
+
emoji = "🇹🇷";
|
|
359
|
+
break;
|
|
360
|
+
case "greek":
|
|
361
|
+
emoji = "🇬🇷";
|
|
362
|
+
break;
|
|
363
|
+
default:
|
|
364
|
+
emoji = null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<span className={cn("text-muted-foreground text-xs", className)} {...props}>
|
|
369
|
+
{children ?? emoji}
|
|
370
|
+
</span>
|
|
371
|
+
);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
export type VoiceSelectorAgeProps = ComponentProps<"span">;
|
|
375
|
+
|
|
376
|
+
export const VoiceSelectorAge = ({
|
|
377
|
+
className,
|
|
378
|
+
...props
|
|
379
|
+
}: VoiceSelectorAgeProps) => (
|
|
380
|
+
<span
|
|
381
|
+
className={cn("text-muted-foreground text-xs tabular-nums", className)}
|
|
382
|
+
{...props}
|
|
383
|
+
/>
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
export type VoiceSelectorNameProps = ComponentProps<"span">;
|
|
387
|
+
|
|
388
|
+
export const VoiceSelectorName = ({
|
|
389
|
+
className,
|
|
390
|
+
...props
|
|
391
|
+
}: VoiceSelectorNameProps) => (
|
|
392
|
+
<span
|
|
393
|
+
className={cn("flex-1 truncate text-left font-medium", className)}
|
|
394
|
+
{...props}
|
|
395
|
+
/>
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
export type VoiceSelectorDescriptionProps = ComponentProps<"span">;
|
|
399
|
+
|
|
400
|
+
export const VoiceSelectorDescription = ({
|
|
401
|
+
className,
|
|
402
|
+
...props
|
|
403
|
+
}: VoiceSelectorDescriptionProps) => (
|
|
404
|
+
<span className={cn("text-muted-foreground text-xs", className)} {...props} />
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
export type VoiceSelectorAttributesProps = ComponentProps<"div">;
|
|
408
|
+
|
|
409
|
+
export const VoiceSelectorAttributes = ({
|
|
410
|
+
className,
|
|
411
|
+
children,
|
|
412
|
+
...props
|
|
413
|
+
}: VoiceSelectorAttributesProps) => (
|
|
414
|
+
<div className={cn("flex items-center text-xs", className)} {...props}>
|
|
415
|
+
{children}
|
|
416
|
+
</div>
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
export type VoiceSelectorBulletProps = ComponentProps<"span">;
|
|
420
|
+
|
|
421
|
+
export const VoiceSelectorBullet = ({
|
|
422
|
+
className,
|
|
423
|
+
...props
|
|
424
|
+
}: VoiceSelectorBulletProps) => (
|
|
425
|
+
<span
|
|
426
|
+
aria-hidden="true"
|
|
427
|
+
className={cn("select-none text-border", className)}
|
|
428
|
+
{...props}
|
|
429
|
+
>
|
|
430
|
+
•
|
|
431
|
+
</span>
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
export type VoiceSelectorPreviewProps = Omit<
|
|
435
|
+
ComponentProps<"button">,
|
|
436
|
+
"children"
|
|
437
|
+
> & {
|
|
438
|
+
playing?: boolean;
|
|
439
|
+
loading?: boolean;
|
|
440
|
+
onPlay?: () => void;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
export const VoiceSelectorPreview = ({
|
|
444
|
+
className,
|
|
445
|
+
playing,
|
|
446
|
+
loading,
|
|
447
|
+
onPlay,
|
|
448
|
+
onClick,
|
|
449
|
+
...props
|
|
450
|
+
}: VoiceSelectorPreviewProps) => {
|
|
451
|
+
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
452
|
+
event.stopPropagation();
|
|
453
|
+
onClick?.(event);
|
|
454
|
+
onPlay?.();
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
let icon = <PlayIcon className="size-3" />;
|
|
458
|
+
|
|
459
|
+
if (loading) {
|
|
460
|
+
icon = <Spinner className="size-3" />;
|
|
461
|
+
} else if (playing) {
|
|
462
|
+
icon = <PauseIcon className="size-3" />;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
return (
|
|
466
|
+
<Button
|
|
467
|
+
aria-label={playing ? "Pause preview" : "Play preview"}
|
|
468
|
+
className={cn("size-6", className)}
|
|
469
|
+
disabled={loading}
|
|
470
|
+
onClick={handleClick}
|
|
471
|
+
size="icon-sm"
|
|
472
|
+
type="button"
|
|
473
|
+
variant="outline"
|
|
474
|
+
{...props}
|
|
475
|
+
>
|
|
476
|
+
{icon}
|
|
477
|
+
</Button>
|
|
478
|
+
);
|
|
479
|
+
};
|