@openconsole/shadcn 0.2.4 → 0.2.6

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 (117) 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/{icon.tsx → components/ui/icon.tsx} +55 -55
  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/tsconfig.json +0 -12
  117. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,273 @@
1
+ "use client";
2
+
3
+ import { Button } from "../ui/button";
4
+ import { cn } from "../../lib/utils";
5
+ import Ansi from "ansi-to-react";
6
+ import { CheckIcon, CopyIcon, TerminalIcon, Trash2Icon } from "lucide-react";
7
+ import type { ComponentProps, HTMLAttributes } from "react";
8
+ import {
9
+ createContext,
10
+ useCallback,
11
+ useContext,
12
+ useEffect,
13
+ useMemo,
14
+ useRef,
15
+ useState,
16
+ } from "react";
17
+
18
+ interface TerminalContextType {
19
+ output: string;
20
+ isStreaming: boolean;
21
+ autoScroll: boolean;
22
+ onClear?: () => void;
23
+ }
24
+
25
+ const TerminalContext = createContext<TerminalContextType>({
26
+ autoScroll: true,
27
+ isStreaming: false,
28
+ output: "",
29
+ });
30
+
31
+ export type TerminalHeaderProps = HTMLAttributes<HTMLDivElement>;
32
+
33
+ export const TerminalHeader = ({
34
+ className,
35
+ children,
36
+ ...props
37
+ }: TerminalHeaderProps) => (
38
+ <div
39
+ className={cn(
40
+ "flex items-center justify-between border-zinc-800 border-b px-4 py-2",
41
+ className
42
+ )}
43
+ {...props}
44
+ >
45
+ {children}
46
+ </div>
47
+ );
48
+
49
+ export type TerminalTitleProps = HTMLAttributes<HTMLDivElement>;
50
+
51
+ export const TerminalTitle = ({
52
+ className,
53
+ children,
54
+ ...props
55
+ }: TerminalTitleProps) => (
56
+ <div
57
+ className={cn("flex items-center gap-2 text-sm text-zinc-400", className)}
58
+ {...props}
59
+ >
60
+ <TerminalIcon className="size-4" />
61
+ {children ?? "Terminal"}
62
+ </div>
63
+ );
64
+
65
+ export type TerminalStatusProps = HTMLAttributes<HTMLDivElement>;
66
+
67
+ export const TerminalStatus = ({
68
+ className,
69
+ children,
70
+ ...props
71
+ }: TerminalStatusProps) => {
72
+ const { isStreaming } = useContext(TerminalContext);
73
+
74
+ if (!isStreaming) {
75
+ return null;
76
+ }
77
+
78
+ return (
79
+ <div
80
+ className={cn("flex items-center gap-2 text-xs text-zinc-400", className)}
81
+ {...props}
82
+ >
83
+ {children}
84
+ </div>
85
+ );
86
+ };
87
+
88
+ export type TerminalActionsProps = HTMLAttributes<HTMLDivElement>;
89
+
90
+ export const TerminalActions = ({
91
+ className,
92
+ children,
93
+ ...props
94
+ }: TerminalActionsProps) => (
95
+ <div className={cn("flex items-center gap-1", className)} {...props}>
96
+ {children}
97
+ </div>
98
+ );
99
+
100
+ export type TerminalCopyButtonProps = ComponentProps<typeof Button> & {
101
+ onCopy?: () => void;
102
+ onError?: (error: Error) => void;
103
+ timeout?: number;
104
+ };
105
+
106
+ export const TerminalCopyButton = ({
107
+ onCopy,
108
+ onError,
109
+ timeout = 2000,
110
+ children,
111
+ className,
112
+ ...props
113
+ }: TerminalCopyButtonProps) => {
114
+ const [isCopied, setIsCopied] = useState(false);
115
+ const timeoutRef = useRef<number>(0);
116
+ const { output } = useContext(TerminalContext);
117
+
118
+ const copyToClipboard = useCallback(async () => {
119
+ if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {
120
+ onError?.(new Error("Clipboard API not available"));
121
+ return;
122
+ }
123
+
124
+ try {
125
+ await navigator.clipboard.writeText(output);
126
+ setIsCopied(true);
127
+ onCopy?.();
128
+ timeoutRef.current = window.setTimeout(() => setIsCopied(false), timeout);
129
+ } catch (error) {
130
+ onError?.(error as Error);
131
+ }
132
+ }, [output, onCopy, onError, timeout]);
133
+
134
+ useEffect(
135
+ () => () => {
136
+ window.clearTimeout(timeoutRef.current);
137
+ },
138
+ []
139
+ );
140
+
141
+ const Icon = isCopied ? CheckIcon : CopyIcon;
142
+
143
+ return (
144
+ <Button
145
+ className={cn(
146
+ "size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",
147
+ className
148
+ )}
149
+ onClick={copyToClipboard}
150
+ size="icon"
151
+ variant="ghost"
152
+ {...props}
153
+ >
154
+ {children ?? <Icon size={14} />}
155
+ </Button>
156
+ );
157
+ };
158
+
159
+ export type TerminalClearButtonProps = ComponentProps<typeof Button>;
160
+
161
+ export const TerminalClearButton = ({
162
+ children,
163
+ className,
164
+ ...props
165
+ }: TerminalClearButtonProps) => {
166
+ const { onClear } = useContext(TerminalContext);
167
+
168
+ if (!onClear) {
169
+ return null;
170
+ }
171
+
172
+ return (
173
+ <Button
174
+ className={cn(
175
+ "size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",
176
+ className
177
+ )}
178
+ onClick={onClear}
179
+ size="icon"
180
+ variant="ghost"
181
+ {...props}
182
+ >
183
+ {children ?? <Trash2Icon size={14} />}
184
+ </Button>
185
+ );
186
+ };
187
+
188
+ export type TerminalContentProps = HTMLAttributes<HTMLDivElement>;
189
+
190
+ export const TerminalContent = ({
191
+ className,
192
+ children,
193
+ ...props
194
+ }: TerminalContentProps) => {
195
+ const { output, isStreaming, autoScroll } = useContext(TerminalContext);
196
+ const containerRef = useRef<HTMLDivElement>(null);
197
+
198
+ useEffect(() => {
199
+ if (autoScroll && containerRef.current) {
200
+ containerRef.current.scrollTop = containerRef.current.scrollHeight;
201
+ }
202
+ }, [output, autoScroll]);
203
+
204
+ return (
205
+ <div
206
+ className={cn(
207
+ "max-h-96 overflow-auto p-4 font-mono text-sm leading-relaxed",
208
+ className
209
+ )}
210
+ ref={containerRef}
211
+ {...props}
212
+ >
213
+ {children ?? (
214
+ <pre className="whitespace-pre-wrap break-words">
215
+ <Ansi>{output}</Ansi>
216
+ {isStreaming && (
217
+ <span className="ml-0.5 inline-block h-4 w-2 animate-pulse bg-zinc-100" />
218
+ )}
219
+ </pre>
220
+ )}
221
+ </div>
222
+ );
223
+ };
224
+
225
+ export type TerminalProps = HTMLAttributes<HTMLDivElement> & {
226
+ output: string;
227
+ isStreaming?: boolean;
228
+ autoScroll?: boolean;
229
+ onClear?: () => void;
230
+ };
231
+
232
+ export const Terminal = ({
233
+ output,
234
+ isStreaming = false,
235
+ autoScroll = true,
236
+ onClear,
237
+ className,
238
+ children,
239
+ ...props
240
+ }: TerminalProps) => {
241
+ const contextValue = useMemo(
242
+ () => ({ autoScroll, isStreaming, onClear, output }),
243
+ [autoScroll, isStreaming, onClear, output]
244
+ );
245
+
246
+ return (
247
+ <TerminalContext.Provider value={contextValue}>
248
+ <div
249
+ className={cn(
250
+ "flex flex-col overflow-hidden rounded-lg border bg-zinc-950 text-zinc-100",
251
+ className
252
+ )}
253
+ {...props}
254
+ >
255
+ {children ?? (
256
+ <>
257
+ <TerminalHeader>
258
+ <TerminalTitle />
259
+ <div className="flex items-center gap-1">
260
+ <TerminalStatus />
261
+ <TerminalActions>
262
+ <TerminalCopyButton />
263
+ {onClear && <TerminalClearButton />}
264
+ </TerminalActions>
265
+ </div>
266
+ </TerminalHeader>
267
+ <TerminalContent />
268
+ </>
269
+ )}
270
+ </div>
271
+ </TerminalContext.Provider>
272
+ );
273
+ };