@openconsole/shadcn 0.2.5 → 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.
- package/components/index.ts +1 -2
- package/components/ui/accordion.tsx +66 -66
- package/components/ui/alert-dialog.tsx +196 -196
- package/components/ui/alert.tsx +66 -66
- package/components/ui/aspect-ratio.tsx +11 -11
- package/components/ui/avatar.tsx +53 -53
- package/components/ui/badge.tsx +46 -46
- package/components/ui/breadcrumb.tsx +109 -109
- package/components/ui/button-group.tsx +83 -83
- package/components/ui/button.tsx +60 -60
- package/components/ui/calendar.tsx +219 -219
- package/components/ui/card.tsx +92 -92
- package/components/ui/carousel.tsx +241 -241
- package/components/ui/chart.tsx +374 -374
- package/components/ui/checkbox.tsx +32 -32
- package/components/ui/collapsible.tsx +33 -33
- package/components/ui/command.tsx +184 -184
- package/components/ui/context-menu.tsx +252 -252
- package/components/ui/dialog.tsx +143 -143
- package/components/ui/direction.tsx +22 -22
- package/components/ui/drawer.tsx +135 -135
- package/components/ui/dropdown-menu.tsx +257 -257
- package/components/ui/empty.tsx +104 -104
- package/components/ui/field.tsx +248 -248
- package/components/ui/form.tsx +167 -167
- package/components/ui/hover-card.tsx +44 -44
- package/components/ui/index.ts +59 -59
- package/components/ui/input-group.tsx +170 -170
- package/components/ui/input-otp.tsx +77 -77
- package/components/ui/input.tsx +21 -21
- package/components/ui/item.tsx +193 -193
- package/components/ui/kbd.tsx +28 -28
- package/components/ui/label.tsx +24 -24
- package/components/ui/menubar.tsx +276 -276
- package/components/ui/native-select.tsx +62 -62
- package/components/ui/navigation-menu.tsx +168 -168
- package/components/ui/pagination.tsx +127 -127
- package/components/ui/popover.tsx +89 -89
- package/components/ui/progress.tsx +31 -31
- package/components/ui/radio-group.tsx +45 -45
- package/components/ui/resizable.tsx +53 -53
- package/components/ui/scroll-area.tsx +58 -58
- package/components/ui/select.tsx +187 -187
- package/components/ui/separator.tsx +28 -28
- package/components/ui/sheet.tsx +139 -139
- package/components/ui/sidebar.tsx +724 -724
- package/components/ui/skeleton.tsx +13 -13
- package/components/ui/slider.tsx +63 -63
- package/components/ui/sonner.tsx +40 -40
- package/components/ui/spinner.tsx +16 -16
- package/components/ui/switch.tsx +35 -35
- package/components/ui/table.tsx +116 -116
- package/components/ui/tabs.tsx +66 -66
- package/components/ui/textarea.tsx +18 -18
- package/components/ui/toggle-group.tsx +83 -83
- package/components/ui/toggle.tsx +47 -47
- package/components/ui/tooltip.tsx +61 -61
- package/hooks/index.ts +1 -1
- package/hooks/use-mobile.ts +19 -19
- package/index.ts +3 -3
- package/lib/index.ts +1 -1
- package/lib/utils.ts +6 -6
- package/package.json +1 -1
- package/styles.css +124 -124
- package/components/ai-elements/agent.tsx +0 -141
- package/components/ai-elements/artifact.tsx +0 -148
- package/components/ai-elements/attachments.tsx +0 -426
- package/components/ai-elements/audio-player.tsx +0 -231
- package/components/ai-elements/canvas.tsx +0 -26
- package/components/ai-elements/chain-of-thought.tsx +0 -222
- package/components/ai-elements/checkpoint.tsx +0 -71
- package/components/ai-elements/code-block.tsx +0 -562
- package/components/ai-elements/commit.tsx +0 -458
- package/components/ai-elements/confirmation.tsx +0 -174
- package/components/ai-elements/connection.tsx +0 -28
- package/components/ai-elements/context.tsx +0 -409
- package/components/ai-elements/controls.tsx +0 -18
- package/components/ai-elements/conversation.tsx +0 -168
- package/components/ai-elements/edge.tsx +0 -143
- package/components/ai-elements/environment-variables.tsx +0 -324
- package/components/ai-elements/file-tree.tsx +0 -304
- package/components/ai-elements/image.tsx +0 -24
- package/components/ai-elements/index.ts +0 -51
- package/components/ai-elements/inline-citation.tsx +0 -296
- package/components/ai-elements/jsx-preview.tsx +0 -310
- package/components/ai-elements/message.tsx +0 -360
- package/components/ai-elements/mic-selector.tsx +0 -375
- package/components/ai-elements/model-selector.tsx +0 -213
- package/components/ai-elements/node.tsx +0 -71
- package/components/ai-elements/open-in-chat.tsx +0 -370
- package/components/ai-elements/package-info.tsx +0 -239
- package/components/ai-elements/panel.tsx +0 -15
- package/components/ai-elements/persona.tsx +0 -306
- package/components/ai-elements/plan.tsx +0 -147
- package/components/ai-elements/prompt-input.tsx +0 -1463
- package/components/ai-elements/queue.tsx +0 -274
- package/components/ai-elements/reasoning.tsx +0 -228
- package/components/ai-elements/sandbox.tsx +0 -132
- package/components/ai-elements/schema-display.tsx +0 -471
- package/components/ai-elements/shimmer.tsx +0 -77
- package/components/ai-elements/snippet.tsx +0 -145
- package/components/ai-elements/sources.tsx +0 -77
- package/components/ai-elements/speech-input.tsx +0 -323
- package/components/ai-elements/stack-trace.tsx +0 -528
- package/components/ai-elements/suggestion.tsx +0 -57
- package/components/ai-elements/task.tsx +0 -87
- package/components/ai-elements/terminal.tsx +0 -273
- package/components/ai-elements/test-results.tsx +0 -496
- package/components/ai-elements/tool.tsx +0 -173
- package/components/ai-elements/toolbar.tsx +0 -16
- package/components/ai-elements/transcription.tsx +0 -125
- package/components/ai-elements/voice-selector.tsx +0 -524
- package/components/ai-elements/web-preview.tsx +0 -281
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Button } from "../ui/button";
|
|
4
|
-
import {
|
|
5
|
-
Collapsible,
|
|
6
|
-
CollapsibleContent,
|
|
7
|
-
CollapsibleTrigger,
|
|
8
|
-
} from "../ui/collapsible";
|
|
9
|
-
import { Input } from "../ui/input";
|
|
10
|
-
import {
|
|
11
|
-
Tooltip,
|
|
12
|
-
TooltipContent,
|
|
13
|
-
TooltipProvider,
|
|
14
|
-
TooltipTrigger,
|
|
15
|
-
} from "../ui/tooltip";
|
|
16
|
-
import { cn } from "../../lib/utils";
|
|
17
|
-
import { ChevronDownIcon } from "lucide-react";
|
|
18
|
-
import type { ComponentProps, ReactNode } from "react";
|
|
19
|
-
import {
|
|
20
|
-
createContext,
|
|
21
|
-
useCallback,
|
|
22
|
-
useContext,
|
|
23
|
-
useMemo,
|
|
24
|
-
useState,
|
|
25
|
-
} from "react";
|
|
26
|
-
|
|
27
|
-
export interface WebPreviewContextValue {
|
|
28
|
-
url: string;
|
|
29
|
-
setUrl: (url: string) => void;
|
|
30
|
-
consoleOpen: boolean;
|
|
31
|
-
setConsoleOpen: (open: boolean) => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const WebPreviewContext = createContext<WebPreviewContextValue | null>(null);
|
|
35
|
-
|
|
36
|
-
const useWebPreview = () => {
|
|
37
|
-
const context = useContext(WebPreviewContext);
|
|
38
|
-
if (!context) {
|
|
39
|
-
throw new Error("WebPreview components must be used within a WebPreview");
|
|
40
|
-
}
|
|
41
|
-
return context;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type WebPreviewProps = ComponentProps<"div"> & {
|
|
45
|
-
defaultUrl?: string;
|
|
46
|
-
onUrlChange?: (url: string) => void;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const WebPreview = ({
|
|
50
|
-
className,
|
|
51
|
-
children,
|
|
52
|
-
defaultUrl = "",
|
|
53
|
-
onUrlChange,
|
|
54
|
-
...props
|
|
55
|
-
}: WebPreviewProps) => {
|
|
56
|
-
const [url, setUrl] = useState(defaultUrl);
|
|
57
|
-
const [consoleOpen, setConsoleOpen] = useState(false);
|
|
58
|
-
|
|
59
|
-
const handleUrlChange = useCallback(
|
|
60
|
-
(newUrl: string) => {
|
|
61
|
-
setUrl(newUrl);
|
|
62
|
-
onUrlChange?.(newUrl);
|
|
63
|
-
},
|
|
64
|
-
[onUrlChange]
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const contextValue = useMemo<WebPreviewContextValue>(
|
|
68
|
-
() => ({
|
|
69
|
-
consoleOpen,
|
|
70
|
-
setConsoleOpen,
|
|
71
|
-
setUrl: handleUrlChange,
|
|
72
|
-
url,
|
|
73
|
-
}),
|
|
74
|
-
[consoleOpen, handleUrlChange, url]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<WebPreviewContext.Provider value={contextValue}>
|
|
79
|
-
<div
|
|
80
|
-
className={cn(
|
|
81
|
-
"flex size-full flex-col rounded-lg border bg-card",
|
|
82
|
-
className
|
|
83
|
-
)}
|
|
84
|
-
{...props}
|
|
85
|
-
>
|
|
86
|
-
{children}
|
|
87
|
-
</div>
|
|
88
|
-
</WebPreviewContext.Provider>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export type WebPreviewNavigationProps = ComponentProps<"div">;
|
|
93
|
-
|
|
94
|
-
export const WebPreviewNavigation = ({
|
|
95
|
-
className,
|
|
96
|
-
children,
|
|
97
|
-
...props
|
|
98
|
-
}: WebPreviewNavigationProps) => (
|
|
99
|
-
<div
|
|
100
|
-
className={cn("flex items-center gap-1 border-b p-2", className)}
|
|
101
|
-
{...props}
|
|
102
|
-
>
|
|
103
|
-
{children}
|
|
104
|
-
</div>
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
export type WebPreviewNavigationButtonProps = ComponentProps<typeof Button> & {
|
|
108
|
-
tooltip?: string;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const WebPreviewNavigationButton = ({
|
|
112
|
-
onClick,
|
|
113
|
-
disabled,
|
|
114
|
-
tooltip,
|
|
115
|
-
children,
|
|
116
|
-
...props
|
|
117
|
-
}: WebPreviewNavigationButtonProps) => (
|
|
118
|
-
<TooltipProvider>
|
|
119
|
-
<Tooltip>
|
|
120
|
-
<TooltipTrigger asChild>
|
|
121
|
-
<Button
|
|
122
|
-
className="h-8 w-8 p-0 hover:text-foreground"
|
|
123
|
-
disabled={disabled}
|
|
124
|
-
onClick={onClick}
|
|
125
|
-
size="sm"
|
|
126
|
-
variant="ghost"
|
|
127
|
-
{...props}
|
|
128
|
-
>
|
|
129
|
-
{children}
|
|
130
|
-
</Button>
|
|
131
|
-
</TooltipTrigger>
|
|
132
|
-
<TooltipContent>
|
|
133
|
-
<p>{tooltip}</p>
|
|
134
|
-
</TooltipContent>
|
|
135
|
-
</Tooltip>
|
|
136
|
-
</TooltipProvider>
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
export type WebPreviewUrlProps = ComponentProps<typeof Input>;
|
|
140
|
-
|
|
141
|
-
export const WebPreviewUrl = ({
|
|
142
|
-
value,
|
|
143
|
-
onChange,
|
|
144
|
-
onKeyDown,
|
|
145
|
-
...props
|
|
146
|
-
}: WebPreviewUrlProps) => {
|
|
147
|
-
const { url, setUrl } = useWebPreview();
|
|
148
|
-
const [prevUrl, setPrevUrl] = useState(url);
|
|
149
|
-
const [inputValue, setInputValue] = useState(url);
|
|
150
|
-
|
|
151
|
-
// Sync input value with context URL when it changes externally (derived state pattern)
|
|
152
|
-
if (url !== prevUrl) {
|
|
153
|
-
setPrevUrl(url);
|
|
154
|
-
setInputValue(url);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
158
|
-
setInputValue(event.target.value);
|
|
159
|
-
onChange?.(event);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const handleKeyDown = useCallback(
|
|
163
|
-
(event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
164
|
-
if (event.key === "Enter") {
|
|
165
|
-
const target = event.target as HTMLInputElement;
|
|
166
|
-
setUrl(target.value);
|
|
167
|
-
}
|
|
168
|
-
onKeyDown?.(event);
|
|
169
|
-
},
|
|
170
|
-
[setUrl, onKeyDown]
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<Input
|
|
175
|
-
className="h-8 flex-1 text-sm"
|
|
176
|
-
onChange={onChange ?? handleChange}
|
|
177
|
-
onKeyDown={handleKeyDown}
|
|
178
|
-
placeholder="Enter URL..."
|
|
179
|
-
value={value ?? inputValue}
|
|
180
|
-
{...props}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
export type WebPreviewBodyProps = ComponentProps<"iframe"> & {
|
|
186
|
-
loading?: ReactNode;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export const WebPreviewBody = ({
|
|
190
|
-
className,
|
|
191
|
-
loading,
|
|
192
|
-
src,
|
|
193
|
-
...props
|
|
194
|
-
}: WebPreviewBodyProps) => {
|
|
195
|
-
const { url } = useWebPreview();
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<div className="flex-1">
|
|
199
|
-
<iframe
|
|
200
|
-
className={cn("size-full", className)}
|
|
201
|
-
// oxlint-disable-next-line eslint-plugin-react(iframe-missing-sandbox)
|
|
202
|
-
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-presentation"
|
|
203
|
-
src={(src ?? url) || undefined}
|
|
204
|
-
title="Preview"
|
|
205
|
-
{...props}
|
|
206
|
-
/>
|
|
207
|
-
{loading}
|
|
208
|
-
</div>
|
|
209
|
-
);
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
export type WebPreviewConsoleProps = ComponentProps<"div"> & {
|
|
213
|
-
logs?: {
|
|
214
|
-
level: "log" | "warn" | "error";
|
|
215
|
-
message: string;
|
|
216
|
-
timestamp: Date;
|
|
217
|
-
}[];
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
export const WebPreviewConsole = ({
|
|
221
|
-
className,
|
|
222
|
-
logs = [],
|
|
223
|
-
children,
|
|
224
|
-
...props
|
|
225
|
-
}: WebPreviewConsoleProps) => {
|
|
226
|
-
const { consoleOpen, setConsoleOpen } = useWebPreview();
|
|
227
|
-
|
|
228
|
-
return (
|
|
229
|
-
<Collapsible
|
|
230
|
-
className={cn("border-t bg-muted/50 font-mono text-sm", className)}
|
|
231
|
-
onOpenChange={setConsoleOpen}
|
|
232
|
-
open={consoleOpen}
|
|
233
|
-
{...props}
|
|
234
|
-
>
|
|
235
|
-
<CollapsibleTrigger asChild>
|
|
236
|
-
<Button
|
|
237
|
-
className="flex w-full items-center justify-between p-4 text-left font-medium hover:bg-muted/50"
|
|
238
|
-
variant="ghost"
|
|
239
|
-
>
|
|
240
|
-
Console
|
|
241
|
-
<ChevronDownIcon
|
|
242
|
-
className={cn(
|
|
243
|
-
"h-4 w-4 transition-transform duration-200",
|
|
244
|
-
consoleOpen && "rotate-180"
|
|
245
|
-
)}
|
|
246
|
-
/>
|
|
247
|
-
</Button>
|
|
248
|
-
</CollapsibleTrigger>
|
|
249
|
-
<CollapsibleContent
|
|
250
|
-
className={cn(
|
|
251
|
-
"px-4 pb-4",
|
|
252
|
-
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in"
|
|
253
|
-
)}
|
|
254
|
-
>
|
|
255
|
-
<div className="max-h-48 space-y-1 overflow-y-auto">
|
|
256
|
-
{logs.length === 0 ? (
|
|
257
|
-
<p className="text-muted-foreground">No console output</p>
|
|
258
|
-
) : (
|
|
259
|
-
logs.map((log) => (
|
|
260
|
-
<div
|
|
261
|
-
className={cn(
|
|
262
|
-
"text-xs",
|
|
263
|
-
log.level === "error" && "text-destructive",
|
|
264
|
-
log.level === "warn" && "text-yellow-600",
|
|
265
|
-
log.level === "log" && "text-foreground"
|
|
266
|
-
)}
|
|
267
|
-
key={`${log.timestamp.getTime()}-${log.level}-${log.message}`}
|
|
268
|
-
>
|
|
269
|
-
<span className="text-muted-foreground">
|
|
270
|
-
{log.timestamp.toLocaleTimeString()}
|
|
271
|
-
</span>{" "}
|
|
272
|
-
{log.message}
|
|
273
|
-
</div>
|
|
274
|
-
))
|
|
275
|
-
)}
|
|
276
|
-
{children}
|
|
277
|
-
</div>
|
|
278
|
-
</CollapsibleContent>
|
|
279
|
-
</Collapsible>
|
|
280
|
-
);
|
|
281
|
-
};
|