@openconsole/shadcn 0.2.4 → 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.
- package/README.md +460 -380
- package/components/ai-elements/agent.tsx +141 -0
- package/components/ai-elements/artifact.tsx +148 -0
- package/components/ai-elements/attachments.tsx +426 -0
- package/components/ai-elements/audio-player.tsx +231 -0
- package/components/ai-elements/canvas.tsx +26 -0
- package/components/ai-elements/chain-of-thought.tsx +222 -0
- package/components/ai-elements/checkpoint.tsx +71 -0
- package/components/ai-elements/code-block.tsx +562 -0
- package/components/ai-elements/commit.tsx +458 -0
- package/components/ai-elements/confirmation.tsx +174 -0
- package/components/ai-elements/connection.tsx +28 -0
- package/components/ai-elements/context.tsx +409 -0
- package/components/ai-elements/controls.tsx +18 -0
- package/components/ai-elements/conversation.tsx +168 -0
- package/components/ai-elements/edge.tsx +143 -0
- package/components/ai-elements/environment-variables.tsx +324 -0
- package/components/ai-elements/file-tree.tsx +304 -0
- package/components/ai-elements/image.tsx +24 -0
- package/components/ai-elements/index.ts +51 -0
- package/components/ai-elements/inline-citation.tsx +296 -0
- package/components/ai-elements/jsx-preview.tsx +310 -0
- package/components/ai-elements/message.tsx +360 -0
- package/components/ai-elements/mic-selector.tsx +375 -0
- package/components/ai-elements/model-selector.tsx +213 -0
- package/components/ai-elements/node.tsx +71 -0
- package/components/ai-elements/open-in-chat.tsx +370 -0
- package/components/ai-elements/package-info.tsx +239 -0
- package/components/ai-elements/panel.tsx +15 -0
- package/components/ai-elements/persona.tsx +306 -0
- package/components/ai-elements/plan.tsx +147 -0
- package/components/ai-elements/prompt-input.tsx +1463 -0
- package/components/ai-elements/queue.tsx +274 -0
- package/components/ai-elements/reasoning.tsx +228 -0
- package/components/ai-elements/sandbox.tsx +132 -0
- package/components/ai-elements/schema-display.tsx +471 -0
- package/components/ai-elements/shimmer.tsx +77 -0
- package/components/ai-elements/snippet.tsx +145 -0
- package/components/ai-elements/sources.tsx +77 -0
- package/components/ai-elements/speech-input.tsx +323 -0
- package/components/ai-elements/stack-trace.tsx +528 -0
- package/components/ai-elements/suggestion.tsx +57 -0
- package/components/ai-elements/task.tsx +87 -0
- package/components/ai-elements/terminal.tsx +273 -0
- package/components/ai-elements/test-results.tsx +496 -0
- package/components/ai-elements/tool.tsx +173 -0
- package/components/ai-elements/toolbar.tsx +16 -0
- package/components/ai-elements/transcription.tsx +125 -0
- package/components/ai-elements/voice-selector.tsx +524 -0
- package/components/ai-elements/web-preview.tsx +281 -0
- package/components/index.ts +3 -0
- package/{accordion.tsx → components/ui/accordion.tsx} +66 -66
- package/{alert-dialog.tsx → components/ui/alert-dialog.tsx} +196 -196
- package/{alert.tsx → components/ui/alert.tsx} +66 -66
- package/{aspect-ratio.tsx → components/ui/aspect-ratio.tsx} +11 -11
- package/{avatar.tsx → components/ui/avatar.tsx} +53 -53
- package/{badge.tsx → components/ui/badge.tsx} +46 -46
- package/{breadcrumb.tsx → components/ui/breadcrumb.tsx} +109 -109
- package/{button-group.tsx → components/ui/button-group.tsx} +83 -83
- package/{button.tsx → components/ui/button.tsx} +60 -60
- package/{calendar.tsx → components/ui/calendar.tsx} +219 -219
- package/{card.tsx → components/ui/card.tsx} +92 -92
- package/{carousel.tsx → components/ui/carousel.tsx} +241 -241
- package/{chart.tsx → components/ui/chart.tsx} +374 -374
- package/{checkbox.tsx → components/ui/checkbox.tsx} +32 -32
- package/{collapsible.tsx → components/ui/collapsible.tsx} +33 -33
- package/{command.tsx → components/ui/command.tsx} +184 -184
- package/{context-menu.tsx → components/ui/context-menu.tsx} +252 -252
- package/{dialog.tsx → components/ui/dialog.tsx} +143 -143
- package/{direction.tsx → components/ui/direction.tsx} +22 -22
- package/{drawer.tsx → components/ui/drawer.tsx} +135 -135
- package/{dropdown-menu.tsx → components/ui/dropdown-menu.tsx} +257 -257
- package/{empty.tsx → components/ui/empty.tsx} +104 -104
- package/{field.tsx → components/ui/field.tsx} +248 -248
- package/{form.tsx → components/ui/form.tsx} +167 -167
- package/{hover-card.tsx → components/ui/hover-card.tsx} +44 -44
- package/{icon.tsx → components/ui/icon.tsx} +55 -55
- package/components/ui/index.ts +59 -0
- package/{input-group.tsx → components/ui/input-group.tsx} +170 -170
- package/{input-otp.tsx → components/ui/input-otp.tsx} +77 -77
- package/{input.tsx → components/ui/input.tsx} +21 -21
- package/{item.tsx → components/ui/item.tsx} +193 -193
- package/{kbd.tsx → components/ui/kbd.tsx} +28 -28
- package/{label.tsx → components/ui/label.tsx} +24 -24
- package/{menubar.tsx → components/ui/menubar.tsx} +276 -276
- package/{native-select.tsx → components/ui/native-select.tsx} +62 -62
- package/{navigation-menu.tsx → components/ui/navigation-menu.tsx} +168 -168
- package/{pagination.tsx → components/ui/pagination.tsx} +127 -127
- package/{popover.tsx → components/ui/popover.tsx} +89 -89
- package/{progress.tsx → components/ui/progress.tsx} +31 -31
- package/{radio-group.tsx → components/ui/radio-group.tsx} +45 -45
- package/{resizable.tsx → components/ui/resizable.tsx} +53 -53
- package/{scroll-area.tsx → components/ui/scroll-area.tsx} +58 -58
- package/{select.tsx → components/ui/select.tsx} +187 -187
- package/{separator.tsx → components/ui/separator.tsx} +28 -28
- package/{sheet.tsx → components/ui/sheet.tsx} +139 -139
- package/{sidebar.tsx → components/ui/sidebar.tsx} +724 -724
- package/{skeleton.tsx → components/ui/skeleton.tsx} +13 -13
- package/{slider.tsx → components/ui/slider.tsx} +63 -63
- package/{sonner.tsx → components/ui/sonner.tsx} +40 -40
- package/{spinner.tsx → components/ui/spinner.tsx} +16 -16
- package/{switch.tsx → components/ui/switch.tsx} +35 -35
- package/{table.tsx → components/ui/table.tsx} +116 -116
- package/{tabs.tsx → components/ui/tabs.tsx} +66 -66
- package/{textarea.tsx → components/ui/textarea.tsx} +18 -18
- package/{toggle-group.tsx → components/ui/toggle-group.tsx} +83 -83
- package/{toggle.tsx → components/ui/toggle.tsx} +47 -47
- package/{tooltip.tsx → components/ui/tooltip.tsx} +61 -61
- package/hooks/index.ts +1 -1
- package/hooks/use-mobile.ts +19 -19
- package/index.ts +3 -59
- package/lib/index.ts +1 -1
- package/lib/utils.ts +6 -6
- package/package.json +79 -1
- package/styles.css +124 -124
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,281 @@
|
|
|
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
|
+
};
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
5
|
-
import { ChevronDownIcon } from "lucide-react";
|
|
6
|
-
|
|
7
|
-
import { cn } from "
|
|
8
|
-
|
|
9
|
-
function Accordion({
|
|
10
|
-
...props
|
|
11
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Root>) {
|
|
12
|
-
return <AccordionPrimitive.Root data-slot="accordion" {...props} />;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function AccordionItem({
|
|
16
|
-
className,
|
|
17
|
-
...props
|
|
18
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
|
|
19
|
-
return (
|
|
20
|
-
<AccordionPrimitive.Item
|
|
21
|
-
data-slot="accordion-item"
|
|
22
|
-
className={cn("border-b last:border-b-0", className)}
|
|
23
|
-
{...props}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function AccordionTrigger({
|
|
29
|
-
className,
|
|
30
|
-
children,
|
|
31
|
-
...props
|
|
32
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
|
|
33
|
-
return (
|
|
34
|
-
<AccordionPrimitive.Header className="flex">
|
|
35
|
-
<AccordionPrimitive.Trigger
|
|
36
|
-
data-slot="accordion-trigger"
|
|
37
|
-
className={cn(
|
|
38
|
-
"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
|
39
|
-
className,
|
|
40
|
-
)}
|
|
41
|
-
{...props}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
<ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
|
|
45
|
-
</AccordionPrimitive.Trigger>
|
|
46
|
-
</AccordionPrimitive.Header>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function AccordionContent({
|
|
51
|
-
className,
|
|
52
|
-
children,
|
|
53
|
-
...props
|
|
54
|
-
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
|
|
55
|
-
return (
|
|
56
|
-
<AccordionPrimitive.Content
|
|
57
|
-
data-slot="accordion-content"
|
|
58
|
-
className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
|
|
59
|
-
{...props}
|
|
60
|
-
>
|
|
61
|
-
<div className={cn("pt-0 pb-4", className)}>{children}</div>
|
|
62
|
-
</AccordionPrimitive.Content>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion";
|
|
5
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
|
|
9
|
+
function Accordion({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Root>) {
|
|
12
|
+
return <AccordionPrimitive.Root data-slot="accordion" {...props} />;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function AccordionItem({
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
|
|
19
|
+
return (
|
|
20
|
+
<AccordionPrimitive.Item
|
|
21
|
+
data-slot="accordion-item"
|
|
22
|
+
className={cn("border-b last:border-b-0", className)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function AccordionTrigger({
|
|
29
|
+
className,
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
|
|
33
|
+
return (
|
|
34
|
+
<AccordionPrimitive.Header className="flex">
|
|
35
|
+
<AccordionPrimitive.Trigger
|
|
36
|
+
data-slot="accordion-trigger"
|
|
37
|
+
className={cn(
|
|
38
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
<ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
|
|
45
|
+
</AccordionPrimitive.Trigger>
|
|
46
|
+
</AccordionPrimitive.Header>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function AccordionContent({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
|
|
55
|
+
return (
|
|
56
|
+
<AccordionPrimitive.Content
|
|
57
|
+
data-slot="accordion-content"
|
|
58
|
+
className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
<div className={cn("pt-0 pb-4", className)}>{children}</div>
|
|
62
|
+
</AccordionPrimitive.Content>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|