@sero-ai/ui 0.1.0

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/.turbo/turbo-typecheck.log +4 -0
  2. package/components.json +18 -0
  3. package/package.json +70 -0
  4. package/src/components/ai-elements/agent.tsx +142 -0
  5. package/src/components/ai-elements/artifact.tsx +149 -0
  6. package/src/components/ai-elements/attachments.tsx +427 -0
  7. package/src/components/ai-elements/audio-player.tsx +232 -0
  8. package/src/components/ai-elements/canvas.tsx +26 -0
  9. package/src/components/ai-elements/chain-of-thought.tsx +223 -0
  10. package/src/components/ai-elements/checkpoint.tsx +72 -0
  11. package/src/components/ai-elements/code-block.tsx +555 -0
  12. package/src/components/ai-elements/commit.tsx +449 -0
  13. package/src/components/ai-elements/confirmation.tsx +173 -0
  14. package/src/components/ai-elements/connection.tsx +28 -0
  15. package/src/components/ai-elements/context.tsx +410 -0
  16. package/src/components/ai-elements/controls.tsx +19 -0
  17. package/src/components/ai-elements/conversation.tsx +167 -0
  18. package/src/components/ai-elements/edge.tsx +144 -0
  19. package/src/components/ai-elements/environment-variables.tsx +325 -0
  20. package/src/components/ai-elements/file-tree.tsx +298 -0
  21. package/src/components/ai-elements/image.tsx +25 -0
  22. package/src/components/ai-elements/inline-citation.tsx +294 -0
  23. package/src/components/ai-elements/jsx-preview.tsx +250 -0
  24. package/src/components/ai-elements/message.tsx +359 -0
  25. package/src/components/ai-elements/mic-selector.tsx +372 -0
  26. package/src/components/ai-elements/model-selector.tsx +214 -0
  27. package/src/components/ai-elements/node.tsx +72 -0
  28. package/src/components/ai-elements/open-in-chat.tsx +367 -0
  29. package/src/components/ai-elements/package-info.tsx +235 -0
  30. package/src/components/ai-elements/panel.tsx +16 -0
  31. package/src/components/ai-elements/persona.tsx +280 -0
  32. package/src/components/ai-elements/plan.tsx +144 -0
  33. package/src/components/ai-elements/prompt-input.tsx +1341 -0
  34. package/src/components/ai-elements/queue.tsx +275 -0
  35. package/src/components/ai-elements/reasoning.tsx +229 -0
  36. package/src/components/ai-elements/sandbox.tsx +133 -0
  37. package/src/components/ai-elements/schema-display.tsx +473 -0
  38. package/src/components/ai-elements/shimmer.tsx +78 -0
  39. package/src/components/ai-elements/snippet.tsx +141 -0
  40. package/src/components/ai-elements/sources.tsx +78 -0
  41. package/src/components/ai-elements/speech-input.tsx +324 -0
  42. package/src/components/ai-elements/stack-trace.tsx +531 -0
  43. package/src/components/ai-elements/suggestion.tsx +58 -0
  44. package/src/components/ai-elements/task.tsx +88 -0
  45. package/src/components/ai-elements/terminal.tsx +277 -0
  46. package/src/components/ai-elements/test-results.tsx +497 -0
  47. package/src/components/ai-elements/tool.tsx +174 -0
  48. package/src/components/ai-elements/toolbar.tsx +17 -0
  49. package/src/components/ai-elements/transcription.tsx +126 -0
  50. package/src/components/ai-elements/voice-selector.tsx +525 -0
  51. package/src/components/ai-elements/web-preview.tsx +282 -0
  52. package/src/components/ui/accordion.tsx +64 -0
  53. package/src/components/ui/alert-dialog.tsx +196 -0
  54. package/src/components/ui/alert.tsx +66 -0
  55. package/src/components/ui/aspect-ratio.tsx +11 -0
  56. package/src/components/ui/avatar.tsx +107 -0
  57. package/src/components/ui/badge.tsx +48 -0
  58. package/src/components/ui/breadcrumb.tsx +109 -0
  59. package/src/components/ui/button-group.tsx +83 -0
  60. package/src/components/ui/button.tsx +64 -0
  61. package/src/components/ui/calendar.tsx +218 -0
  62. package/src/components/ui/card.tsx +92 -0
  63. package/src/components/ui/carousel.tsx +239 -0
  64. package/src/components/ui/chart.tsx +355 -0
  65. package/src/components/ui/checkbox.tsx +32 -0
  66. package/src/components/ui/collapsible.tsx +31 -0
  67. package/src/components/ui/combobox.tsx +310 -0
  68. package/src/components/ui/command.tsx +184 -0
  69. package/src/components/ui/context-menu.tsx +252 -0
  70. package/src/components/ui/dialog.tsx +158 -0
  71. package/src/components/ui/direction.tsx +22 -0
  72. package/src/components/ui/drawer.tsx +133 -0
  73. package/src/components/ui/dropdown-menu.tsx +257 -0
  74. package/src/components/ui/empty.tsx +104 -0
  75. package/src/components/ui/field.tsx +248 -0
  76. package/src/components/ui/form.tsx +165 -0
  77. package/src/components/ui/hover-card.tsx +42 -0
  78. package/src/components/ui/input-group.tsx +168 -0
  79. package/src/components/ui/input-otp.tsx +77 -0
  80. package/src/components/ui/input.tsx +21 -0
  81. package/src/components/ui/item.tsx +193 -0
  82. package/src/components/ui/kbd.tsx +28 -0
  83. package/src/components/ui/label.tsx +22 -0
  84. package/src/components/ui/menubar.tsx +276 -0
  85. package/src/components/ui/native-select.tsx +53 -0
  86. package/src/components/ui/navigation-menu.tsx +168 -0
  87. package/src/components/ui/pagination.tsx +127 -0
  88. package/src/components/ui/popover.tsx +87 -0
  89. package/src/components/ui/progress.tsx +31 -0
  90. package/src/components/ui/radio-group.tsx +43 -0
  91. package/src/components/ui/resizable.tsx +53 -0
  92. package/src/components/ui/scroll-area.tsx +56 -0
  93. package/src/components/ui/select.tsx +190 -0
  94. package/src/components/ui/separator.tsx +28 -0
  95. package/src/components/ui/sheet.tsx +145 -0
  96. package/src/components/ui/sidebar.tsx +724 -0
  97. package/src/components/ui/skeleton.tsx +13 -0
  98. package/src/components/ui/slider.tsx +61 -0
  99. package/src/components/ui/sonner.tsx +40 -0
  100. package/src/components/ui/spinner.tsx +16 -0
  101. package/src/components/ui/switch.tsx +33 -0
  102. package/src/components/ui/table.tsx +116 -0
  103. package/src/components/ui/tabs.tsx +91 -0
  104. package/src/components/ui/textarea.tsx +18 -0
  105. package/src/components/ui/toggle-group.tsx +83 -0
  106. package/src/components/ui/toggle.tsx +47 -0
  107. package/src/components/ui/tooltip.tsx +57 -0
  108. package/src/components/ui/tree.tsx +207 -0
  109. package/src/hooks/use-mobile.ts +17 -0
  110. package/src/index.ts +16 -0
  111. package/src/lib/utils.ts +6 -0
  112. package/src/styles/globals.css +373 -0
  113. package/tsconfig.json +18 -0
@@ -0,0 +1,277 @@
1
+ "use client";
2
+
3
+ import type { ComponentProps, HTMLAttributes } from "react";
4
+
5
+ import { Button } from "../ui/button";
6
+ import { cn } from "../../lib/utils";
7
+ import Ansi from "ansi-to-react";
8
+ import { CheckIcon, CopyIcon, TerminalIcon, Trash2Icon } from "lucide-react";
9
+ import {
10
+ createContext,
11
+ useCallback,
12
+ useContext,
13
+ useEffect,
14
+ useMemo,
15
+ useRef,
16
+ useState,
17
+ } from "react";
18
+
19
+ import { Shimmer } from "./shimmer";
20
+
21
+ interface TerminalContextType {
22
+ output: string;
23
+ isStreaming: boolean;
24
+ autoScroll: boolean;
25
+ onClear?: () => void;
26
+ }
27
+
28
+ const TerminalContext = createContext<TerminalContextType>({
29
+ autoScroll: true,
30
+ isStreaming: false,
31
+ output: "",
32
+ });
33
+
34
+ export type TerminalProps = HTMLAttributes<HTMLDivElement> & {
35
+ output: string;
36
+ isStreaming?: boolean;
37
+ autoScroll?: boolean;
38
+ onClear?: () => void;
39
+ };
40
+
41
+ export const Terminal = ({
42
+ output,
43
+ isStreaming = false,
44
+ autoScroll = true,
45
+ onClear,
46
+ className,
47
+ children,
48
+ ...props
49
+ }: TerminalProps) => {
50
+ const contextValue = useMemo(
51
+ () => ({ autoScroll, isStreaming, onClear, output }),
52
+ [autoScroll, isStreaming, onClear, output]
53
+ );
54
+
55
+ return (
56
+ <TerminalContext.Provider value={contextValue}>
57
+ <div
58
+ className={cn(
59
+ "flex flex-col overflow-hidden rounded-lg border bg-zinc-950 text-zinc-100",
60
+ className
61
+ )}
62
+ {...props}
63
+ >
64
+ {children ?? (
65
+ <>
66
+ <TerminalHeader>
67
+ <TerminalTitle />
68
+ <div className="flex items-center gap-1">
69
+ <TerminalStatus />
70
+ <TerminalActions>
71
+ <TerminalCopyButton />
72
+ {onClear && <TerminalClearButton />}
73
+ </TerminalActions>
74
+ </div>
75
+ </TerminalHeader>
76
+ <TerminalContent />
77
+ </>
78
+ )}
79
+ </div>
80
+ </TerminalContext.Provider>
81
+ );
82
+ };
83
+
84
+ export type TerminalHeaderProps = HTMLAttributes<HTMLDivElement>;
85
+
86
+ export const TerminalHeader = ({
87
+ className,
88
+ children,
89
+ ...props
90
+ }: TerminalHeaderProps) => (
91
+ <div
92
+ className={cn(
93
+ "flex items-center justify-between border-zinc-800 border-b px-4 py-2",
94
+ className
95
+ )}
96
+ {...props}
97
+ >
98
+ {children}
99
+ </div>
100
+ );
101
+
102
+ export type TerminalTitleProps = HTMLAttributes<HTMLDivElement>;
103
+
104
+ export const TerminalTitle = ({
105
+ className,
106
+ children,
107
+ ...props
108
+ }: TerminalTitleProps) => (
109
+ <div
110
+ className={cn("flex items-center gap-2 text-sm text-zinc-400", className)}
111
+ {...props}
112
+ >
113
+ <TerminalIcon className="size-4" />
114
+ {children ?? "Terminal"}
115
+ </div>
116
+ );
117
+
118
+ export type TerminalStatusProps = HTMLAttributes<HTMLDivElement>;
119
+
120
+ export const TerminalStatus = ({
121
+ className,
122
+ children,
123
+ ...props
124
+ }: TerminalStatusProps) => {
125
+ const { isStreaming } = useContext(TerminalContext);
126
+
127
+ if (!isStreaming) {
128
+ return null;
129
+ }
130
+
131
+ return (
132
+ <div
133
+ className={cn("flex items-center gap-2 text-xs text-zinc-400", className)}
134
+ {...props}
135
+ >
136
+ {children ?? <Shimmer className="w-16">{'\u00A0'}</Shimmer>}
137
+ </div>
138
+ );
139
+ };
140
+
141
+ export type TerminalActionsProps = HTMLAttributes<HTMLDivElement>;
142
+
143
+ export const TerminalActions = ({
144
+ className,
145
+ children,
146
+ ...props
147
+ }: TerminalActionsProps) => (
148
+ <div className={cn("flex items-center gap-1", className)} {...props}>
149
+ {children}
150
+ </div>
151
+ );
152
+
153
+ export type TerminalCopyButtonProps = ComponentProps<typeof Button> & {
154
+ onCopy?: () => void;
155
+ onError?: (error: Error) => void;
156
+ timeout?: number;
157
+ };
158
+
159
+ export const TerminalCopyButton = ({
160
+ onCopy,
161
+ onError,
162
+ timeout = 2000,
163
+ children,
164
+ className,
165
+ ...props
166
+ }: TerminalCopyButtonProps) => {
167
+ const [isCopied, setIsCopied] = useState(false);
168
+ const timeoutRef = useRef<number>(0);
169
+ const { output } = useContext(TerminalContext);
170
+
171
+ const copyToClipboard = useCallback(async () => {
172
+ if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {
173
+ onError?.(new Error("Clipboard API not available"));
174
+ return;
175
+ }
176
+
177
+ try {
178
+ await navigator.clipboard.writeText(output);
179
+ setIsCopied(true);
180
+ onCopy?.();
181
+ timeoutRef.current = window.setTimeout(() => setIsCopied(false), timeout);
182
+ } catch (error) {
183
+ onError?.(error as Error);
184
+ }
185
+ }, [output, onCopy, onError, timeout]);
186
+
187
+ useEffect(
188
+ () => () => {
189
+ window.clearTimeout(timeoutRef.current);
190
+ },
191
+ []
192
+ );
193
+
194
+ const Icon = isCopied ? CheckIcon : CopyIcon;
195
+
196
+ return (
197
+ <Button
198
+ className={cn(
199
+ "size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",
200
+ className
201
+ )}
202
+ onClick={copyToClipboard}
203
+ size="icon"
204
+ variant="ghost"
205
+ {...props}
206
+ >
207
+ {children ?? <Icon size={14} />}
208
+ </Button>
209
+ );
210
+ };
211
+
212
+ export type TerminalClearButtonProps = ComponentProps<typeof Button>;
213
+
214
+ export const TerminalClearButton = ({
215
+ children,
216
+ className,
217
+ ...props
218
+ }: TerminalClearButtonProps) => {
219
+ const { onClear } = useContext(TerminalContext);
220
+
221
+ if (!onClear) {
222
+ return null;
223
+ }
224
+
225
+ return (
226
+ <Button
227
+ className={cn(
228
+ "size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",
229
+ className
230
+ )}
231
+ onClick={onClear}
232
+ size="icon"
233
+ variant="ghost"
234
+ {...props}
235
+ >
236
+ {children ?? <Trash2Icon size={14} />}
237
+ </Button>
238
+ );
239
+ };
240
+
241
+ export type TerminalContentProps = HTMLAttributes<HTMLDivElement>;
242
+
243
+ export const TerminalContent = ({
244
+ className,
245
+ children,
246
+ ...props
247
+ }: TerminalContentProps) => {
248
+ const { output, isStreaming, autoScroll } = useContext(TerminalContext);
249
+ const containerRef = useRef<HTMLDivElement>(null);
250
+
251
+ // biome-ignore lint/correctness/useExhaustiveDependencies: output triggers auto-scroll when new content arrives
252
+ useEffect(() => {
253
+ if (autoScroll && containerRef.current) {
254
+ containerRef.current.scrollTop = containerRef.current.scrollHeight;
255
+ }
256
+ }, [output, autoScroll]);
257
+
258
+ return (
259
+ <div
260
+ className={cn(
261
+ "max-h-96 overflow-auto p-4 font-mono text-sm leading-relaxed",
262
+ className
263
+ )}
264
+ ref={containerRef}
265
+ {...props}
266
+ >
267
+ {children ?? (
268
+ <pre className="whitespace-pre-wrap break-words">
269
+ <Ansi>{output}</Ansi>
270
+ {isStreaming && (
271
+ <span className="ml-0.5 inline-block h-4 w-2 animate-pulse bg-zinc-100" />
272
+ )}
273
+ </pre>
274
+ )}
275
+ </div>
276
+ );
277
+ };