@openconsole/shadcn 0.2.2 → 0.2.5

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