@openconsole/shadcn 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/components/index.ts +1 -2
  2. package/components/ui/accordion.tsx +66 -66
  3. package/components/ui/alert-dialog.tsx +196 -196
  4. package/components/ui/alert.tsx +66 -66
  5. package/components/ui/aspect-ratio.tsx +11 -11
  6. package/components/ui/avatar.tsx +53 -53
  7. package/components/ui/badge.tsx +46 -46
  8. package/components/ui/breadcrumb.tsx +109 -109
  9. package/components/ui/button-group.tsx +83 -83
  10. package/components/ui/button.tsx +60 -60
  11. package/components/ui/calendar.tsx +219 -219
  12. package/components/ui/card.tsx +92 -92
  13. package/components/ui/carousel.tsx +241 -241
  14. package/components/ui/chart.tsx +374 -374
  15. package/components/ui/checkbox.tsx +32 -32
  16. package/components/ui/collapsible.tsx +33 -33
  17. package/components/ui/command.tsx +184 -184
  18. package/components/ui/context-menu.tsx +252 -252
  19. package/components/ui/dialog.tsx +143 -143
  20. package/components/ui/direction.tsx +22 -22
  21. package/components/ui/drawer.tsx +135 -135
  22. package/components/ui/dropdown-menu.tsx +257 -257
  23. package/components/ui/empty.tsx +104 -104
  24. package/components/ui/field.tsx +248 -248
  25. package/components/ui/form.tsx +167 -167
  26. package/components/ui/hover-card.tsx +44 -44
  27. package/components/ui/index.ts +59 -59
  28. package/components/ui/input-group.tsx +170 -170
  29. package/components/ui/input-otp.tsx +77 -77
  30. package/components/ui/input.tsx +21 -21
  31. package/components/ui/item.tsx +193 -193
  32. package/components/ui/kbd.tsx +28 -28
  33. package/components/ui/label.tsx +24 -24
  34. package/components/ui/menubar.tsx +276 -276
  35. package/components/ui/native-select.tsx +62 -62
  36. package/components/ui/navigation-menu.tsx +168 -168
  37. package/components/ui/pagination.tsx +127 -127
  38. package/components/ui/popover.tsx +89 -89
  39. package/components/ui/progress.tsx +31 -31
  40. package/components/ui/radio-group.tsx +45 -45
  41. package/components/ui/resizable.tsx +53 -53
  42. package/components/ui/scroll-area.tsx +58 -58
  43. package/components/ui/select.tsx +187 -187
  44. package/components/ui/separator.tsx +28 -28
  45. package/components/ui/sheet.tsx +139 -139
  46. package/components/ui/sidebar.tsx +724 -724
  47. package/components/ui/skeleton.tsx +13 -13
  48. package/components/ui/slider.tsx +63 -63
  49. package/components/ui/sonner.tsx +40 -40
  50. package/components/ui/spinner.tsx +16 -16
  51. package/components/ui/switch.tsx +35 -35
  52. package/components/ui/table.tsx +116 -116
  53. package/components/ui/tabs.tsx +66 -66
  54. package/components/ui/textarea.tsx +18 -18
  55. package/components/ui/toggle-group.tsx +83 -83
  56. package/components/ui/toggle.tsx +47 -47
  57. package/components/ui/tooltip.tsx +61 -61
  58. package/hooks/index.ts +1 -1
  59. package/hooks/use-mobile.ts +19 -19
  60. package/index.ts +3 -3
  61. package/lib/index.ts +1 -1
  62. package/lib/utils.ts +6 -6
  63. package/package.json +1 -1
  64. package/styles.css +124 -124
  65. package/components/ai-elements/agent.tsx +0 -141
  66. package/components/ai-elements/artifact.tsx +0 -148
  67. package/components/ai-elements/attachments.tsx +0 -426
  68. package/components/ai-elements/audio-player.tsx +0 -231
  69. package/components/ai-elements/canvas.tsx +0 -26
  70. package/components/ai-elements/chain-of-thought.tsx +0 -222
  71. package/components/ai-elements/checkpoint.tsx +0 -71
  72. package/components/ai-elements/code-block.tsx +0 -562
  73. package/components/ai-elements/commit.tsx +0 -458
  74. package/components/ai-elements/confirmation.tsx +0 -174
  75. package/components/ai-elements/connection.tsx +0 -28
  76. package/components/ai-elements/context.tsx +0 -409
  77. package/components/ai-elements/controls.tsx +0 -18
  78. package/components/ai-elements/conversation.tsx +0 -168
  79. package/components/ai-elements/edge.tsx +0 -143
  80. package/components/ai-elements/environment-variables.tsx +0 -324
  81. package/components/ai-elements/file-tree.tsx +0 -304
  82. package/components/ai-elements/image.tsx +0 -24
  83. package/components/ai-elements/index.ts +0 -51
  84. package/components/ai-elements/inline-citation.tsx +0 -296
  85. package/components/ai-elements/jsx-preview.tsx +0 -310
  86. package/components/ai-elements/message.tsx +0 -360
  87. package/components/ai-elements/mic-selector.tsx +0 -375
  88. package/components/ai-elements/model-selector.tsx +0 -213
  89. package/components/ai-elements/node.tsx +0 -71
  90. package/components/ai-elements/open-in-chat.tsx +0 -370
  91. package/components/ai-elements/package-info.tsx +0 -239
  92. package/components/ai-elements/panel.tsx +0 -15
  93. package/components/ai-elements/persona.tsx +0 -306
  94. package/components/ai-elements/plan.tsx +0 -147
  95. package/components/ai-elements/prompt-input.tsx +0 -1463
  96. package/components/ai-elements/queue.tsx +0 -274
  97. package/components/ai-elements/reasoning.tsx +0 -228
  98. package/components/ai-elements/sandbox.tsx +0 -132
  99. package/components/ai-elements/schema-display.tsx +0 -471
  100. package/components/ai-elements/shimmer.tsx +0 -77
  101. package/components/ai-elements/snippet.tsx +0 -145
  102. package/components/ai-elements/sources.tsx +0 -77
  103. package/components/ai-elements/speech-input.tsx +0 -323
  104. package/components/ai-elements/stack-trace.tsx +0 -528
  105. package/components/ai-elements/suggestion.tsx +0 -57
  106. package/components/ai-elements/task.tsx +0 -87
  107. package/components/ai-elements/terminal.tsx +0 -273
  108. package/components/ai-elements/test-results.tsx +0 -496
  109. package/components/ai-elements/tool.tsx +0 -173
  110. package/components/ai-elements/toolbar.tsx +0 -16
  111. package/components/ai-elements/transcription.tsx +0 -125
  112. package/components/ai-elements/voice-selector.tsx +0 -524
  113. package/components/ai-elements/web-preview.tsx +0 -281
@@ -1,77 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- Collapsible,
5
- CollapsibleContent,
6
- CollapsibleTrigger,
7
- } from "../ui/collapsible";
8
- import { cn } from "../../lib/utils";
9
- import { BookIcon, ChevronDownIcon } from "lucide-react";
10
- import type { ComponentProps } from "react";
11
-
12
- export type SourcesProps = ComponentProps<"div">;
13
-
14
- export const Sources = ({ className, ...props }: SourcesProps) => (
15
- <Collapsible
16
- className={cn("not-prose mb-4 text-primary text-xs", className)}
17
- {...props}
18
- />
19
- );
20
-
21
- export type SourcesTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {
22
- count: number;
23
- };
24
-
25
- export const SourcesTrigger = ({
26
- className,
27
- count,
28
- children,
29
- ...props
30
- }: SourcesTriggerProps) => (
31
- <CollapsibleTrigger
32
- className={cn("flex items-center gap-2", className)}
33
- {...props}
34
- >
35
- {children ?? (
36
- <>
37
- <p className="font-medium">Used {count} sources</p>
38
- <ChevronDownIcon className="h-4 w-4" />
39
- </>
40
- )}
41
- </CollapsibleTrigger>
42
- );
43
-
44
- export type SourcesContentProps = ComponentProps<typeof CollapsibleContent>;
45
-
46
- export const SourcesContent = ({
47
- className,
48
- ...props
49
- }: SourcesContentProps) => (
50
- <CollapsibleContent
51
- className={cn(
52
- "mt-3 flex w-fit flex-col gap-2",
53
- "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
54
- className
55
- )}
56
- {...props}
57
- />
58
- );
59
-
60
- export type SourceProps = ComponentProps<"a">;
61
-
62
- export const Source = ({ href, title, children, ...props }: SourceProps) => (
63
- <a
64
- className="flex items-center gap-2"
65
- href={href}
66
- rel="noreferrer"
67
- target="_blank"
68
- {...props}
69
- >
70
- {children ?? (
71
- <>
72
- <BookIcon className="h-4 w-4" />
73
- <span className="block font-medium">{title}</span>
74
- </>
75
- )}
76
- </a>
77
- );
@@ -1,323 +0,0 @@
1
- "use client";
2
-
3
- import { Button } from "../ui/button";
4
- import { Spinner } from "../ui/spinner";
5
- import { cn } from "../../lib/utils";
6
- import { MicIcon, SquareIcon } from "lucide-react";
7
- import type { ComponentProps } from "react";
8
- import { useCallback, useEffect, useRef, useState } from "react";
9
-
10
- interface SpeechRecognition extends EventTarget {
11
- continuous: boolean;
12
- interimResults: boolean;
13
- lang: string;
14
- start(): void;
15
- stop(): void;
16
- onstart: ((this: SpeechRecognition, ev: Event) => void) | null;
17
- onend: ((this: SpeechRecognition, ev: Event) => void) | null;
18
- onresult:
19
- | ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => void)
20
- | null;
21
- onerror:
22
- | ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => void)
23
- | null;
24
- }
25
-
26
- interface SpeechRecognitionEvent extends Event {
27
- results: SpeechRecognitionResultList;
28
- resultIndex: number;
29
- }
30
-
31
- interface SpeechRecognitionResultList {
32
- readonly length: number;
33
- item(index: number): SpeechRecognitionResult;
34
- [index: number]: SpeechRecognitionResult;
35
- }
36
-
37
- interface SpeechRecognitionResult {
38
- readonly length: number;
39
- item(index: number): SpeechRecognitionAlternative;
40
- [index: number]: SpeechRecognitionAlternative;
41
- isFinal: boolean;
42
- }
43
-
44
- interface SpeechRecognitionAlternative {
45
- transcript: string;
46
- confidence: number;
47
- }
48
-
49
- interface SpeechRecognitionErrorEvent extends Event {
50
- error: string;
51
- }
52
-
53
- declare global {
54
- interface Window {
55
- SpeechRecognition: new () => SpeechRecognition;
56
- webkitSpeechRecognition: new () => SpeechRecognition;
57
- }
58
- }
59
-
60
- type SpeechInputMode = "speech-recognition" | "media-recorder" | "none";
61
-
62
- export type SpeechInputProps = ComponentProps<typeof Button> & {
63
- onTranscriptionChange?: (text: string) => void;
64
- /**
65
- * Callback for when audio is recorded using MediaRecorder fallback.
66
- * This is called in browsers that don't support the Web Speech API (Firefox, Safari).
67
- * The callback receives an audio Blob that should be sent to a transcription service.
68
- * Return the transcribed text, which will be passed to onTranscriptionChange.
69
- */
70
- onAudioRecorded?: (audioBlob: Blob) => Promise<string>;
71
- lang?: string;
72
- };
73
-
74
- const detectSpeechInputMode = (): SpeechInputMode => {
75
- if (typeof window === "undefined") {
76
- return "none";
77
- }
78
-
79
- if ("SpeechRecognition" in window || "webkitSpeechRecognition" in window) {
80
- return "speech-recognition";
81
- }
82
-
83
- if ("MediaRecorder" in window && "mediaDevices" in navigator) {
84
- return "media-recorder";
85
- }
86
-
87
- return "none";
88
- };
89
-
90
- export const SpeechInput = ({
91
- className,
92
- onTranscriptionChange,
93
- onAudioRecorded,
94
- lang = "en-US",
95
- ...props
96
- }: SpeechInputProps) => {
97
- const [isListening, setIsListening] = useState(false);
98
- const [isProcessing, setIsProcessing] = useState(false);
99
- const [mode] = useState<SpeechInputMode>(detectSpeechInputMode);
100
- const [isRecognitionReady, setIsRecognitionReady] = useState(false);
101
- const recognitionRef = useRef<SpeechRecognition | null>(null);
102
- const mediaRecorderRef = useRef<MediaRecorder | null>(null);
103
- const streamRef = useRef<MediaStream | null>(null);
104
- const audioChunksRef = useRef<Blob[]>([]);
105
- const onTranscriptionChangeRef = useRef<
106
- SpeechInputProps["onTranscriptionChange"]
107
- >(onTranscriptionChange);
108
- const onAudioRecordedRef =
109
- useRef<SpeechInputProps["onAudioRecorded"]>(onAudioRecorded);
110
-
111
- // Keep refs in sync
112
- onTranscriptionChangeRef.current = onTranscriptionChange;
113
- onAudioRecordedRef.current = onAudioRecorded;
114
-
115
- // Initialize Speech Recognition when mode is speech-recognition
116
- useEffect(() => {
117
- if (mode !== "speech-recognition") {
118
- return;
119
- }
120
-
121
- const SpeechRecognition =
122
- window.SpeechRecognition || window.webkitSpeechRecognition;
123
- const speechRecognition = new SpeechRecognition();
124
-
125
- speechRecognition.continuous = true;
126
- speechRecognition.interimResults = true;
127
- speechRecognition.lang = lang;
128
-
129
- const handleStart = () => {
130
- setIsListening(true);
131
- };
132
-
133
- const handleEnd = () => {
134
- setIsListening(false);
135
- };
136
-
137
- const handleResult = (event: Event) => {
138
- const speechEvent = event as SpeechRecognitionEvent;
139
- let finalTranscript = "";
140
-
141
- for (
142
- let i = speechEvent.resultIndex;
143
- i < speechEvent.results.length;
144
- i += 1
145
- ) {
146
- const result = speechEvent.results[i];
147
- if (result.isFinal) {
148
- finalTranscript += result[0]?.transcript ?? "";
149
- }
150
- }
151
-
152
- if (finalTranscript) {
153
- onTranscriptionChangeRef.current?.(finalTranscript);
154
- }
155
- };
156
-
157
- const handleError = () => {
158
- setIsListening(false);
159
- };
160
-
161
- speechRecognition.addEventListener("start", handleStart);
162
- speechRecognition.addEventListener("end", handleEnd);
163
- speechRecognition.addEventListener("result", handleResult);
164
- speechRecognition.addEventListener("error", handleError);
165
-
166
- recognitionRef.current = speechRecognition;
167
- setIsRecognitionReady(true);
168
-
169
- return () => {
170
- speechRecognition.removeEventListener("start", handleStart);
171
- speechRecognition.removeEventListener("end", handleEnd);
172
- speechRecognition.removeEventListener("result", handleResult);
173
- speechRecognition.removeEventListener("error", handleError);
174
- speechRecognition.stop();
175
- recognitionRef.current = null;
176
- setIsRecognitionReady(false);
177
- };
178
- }, [mode, lang]);
179
-
180
- // Cleanup MediaRecorder and stream on unmount
181
- useEffect(
182
- () => () => {
183
- if (mediaRecorderRef.current?.state === "recording") {
184
- mediaRecorderRef.current.stop();
185
- }
186
- if (streamRef.current) {
187
- for (const track of streamRef.current.getTracks()) {
188
- track.stop();
189
- }
190
- }
191
- },
192
- []
193
- );
194
-
195
- // Start MediaRecorder recording
196
- const startMediaRecorder = useCallback(async () => {
197
- if (!onAudioRecordedRef.current) {
198
- return;
199
- }
200
-
201
- try {
202
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
203
- streamRef.current = stream;
204
- const mediaRecorder = new MediaRecorder(stream);
205
- audioChunksRef.current = [];
206
-
207
- const handleDataAvailable = (event: BlobEvent) => {
208
- if (event.data.size > 0) {
209
- audioChunksRef.current.push(event.data);
210
- }
211
- };
212
-
213
- const handleStop = async () => {
214
- for (const track of stream.getTracks()) {
215
- track.stop();
216
- }
217
- streamRef.current = null;
218
-
219
- const audioBlob = new Blob(audioChunksRef.current, {
220
- type: "audio/webm",
221
- });
222
-
223
- if (audioBlob.size > 0 && onAudioRecordedRef.current) {
224
- setIsProcessing(true);
225
- try {
226
- const transcript = await onAudioRecordedRef.current(audioBlob);
227
- if (transcript) {
228
- onTranscriptionChangeRef.current?.(transcript);
229
- }
230
- } catch {
231
- // Error handling delegated to the onAudioRecorded caller
232
- } finally {
233
- setIsProcessing(false);
234
- }
235
- }
236
- };
237
-
238
- const handleError = () => {
239
- setIsListening(false);
240
- for (const track of stream.getTracks()) {
241
- track.stop();
242
- }
243
- streamRef.current = null;
244
- };
245
-
246
- mediaRecorder.addEventListener("dataavailable", handleDataAvailable);
247
- mediaRecorder.addEventListener("stop", handleStop);
248
- mediaRecorder.addEventListener("error", handleError);
249
-
250
- mediaRecorderRef.current = mediaRecorder;
251
- mediaRecorder.start();
252
- setIsListening(true);
253
- } catch {
254
- setIsListening(false);
255
- }
256
- }, []);
257
-
258
- // Stop MediaRecorder recording
259
- const stopMediaRecorder = useCallback(() => {
260
- if (mediaRecorderRef.current?.state === "recording") {
261
- mediaRecorderRef.current.stop();
262
- }
263
- setIsListening(false);
264
- }, []);
265
-
266
- const toggleListening = useCallback(() => {
267
- if (mode === "speech-recognition" && recognitionRef.current) {
268
- if (isListening) {
269
- recognitionRef.current.stop();
270
- } else {
271
- recognitionRef.current.start();
272
- }
273
- } else if (mode === "media-recorder") {
274
- if (isListening) {
275
- stopMediaRecorder();
276
- } else {
277
- startMediaRecorder();
278
- }
279
- }
280
- }, [mode, isListening, startMediaRecorder, stopMediaRecorder]);
281
-
282
- // Determine if button should be disabled
283
- const isDisabled =
284
- mode === "none" ||
285
- (mode === "speech-recognition" && !isRecognitionReady) ||
286
- (mode === "media-recorder" && !onAudioRecorded) ||
287
- isProcessing;
288
-
289
- return (
290
- <div className="relative inline-flex items-center justify-center">
291
- {/* Animated pulse rings */}
292
- {isListening &&
293
- [0, 1, 2].map((index) => (
294
- <div
295
- className="absolute inset-0 animate-ping rounded-full border-2 border-red-400/30"
296
- key={index}
297
- style={{
298
- animationDelay: `${index * 0.3}s`,
299
- animationDuration: "2s",
300
- }}
301
- />
302
- ))}
303
-
304
- {/* Main record button */}
305
- <Button
306
- className={cn(
307
- "relative z-10 rounded-full transition-all duration-300",
308
- isListening
309
- ? "bg-destructive text-white hover:bg-destructive/80 hover:text-white"
310
- : "bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground",
311
- className
312
- )}
313
- disabled={isDisabled}
314
- onClick={toggleListening}
315
- {...props}
316
- >
317
- {isProcessing && <Spinner />}
318
- {!isProcessing && isListening && <SquareIcon className="size-4" />}
319
- {!(isProcessing || isListening) && <MicIcon className="size-4" />}
320
- </Button>
321
- </div>
322
- );
323
- };