Hanzo Dev
commited on
Commit
·
476d1b5
0
Parent(s):
Deploy ai-chat-interface static template
Browse files- README.md +19 -0
- components/avatar.tsx +53 -0
- components/badge.tsx +36 -0
- components/button.tsx +68 -0
- components/card.tsx +79 -0
- components/checkbox.tsx +32 -0
- components/collapsible.tsx +33 -0
- components/dialog.tsx +143 -0
- components/dropdown-menu.tsx +257 -0
- components/input.tsx +21 -0
- components/label.tsx +26 -0
- components/popover.tsx +48 -0
- components/progress.tsx +28 -0
- components/select.tsx +185 -0
- components/sonner.tsx +22 -0
- components/switch.tsx +31 -0
- components/tabs.tsx +66 -0
- components/toggle-group.tsx +73 -0
- components/toggle.tsx +47 -0
- components/tooltip.tsx +61 -0
- index.html +36 -0
- page.tsx +234 -0
- preview.html +1 -0
README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Ai Chat Interface
|
| 3 |
+
emoji: 🎨
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: static
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Ai Chat Interface
|
| 11 |
+
|
| 12 |
+
Modern chat UI with streaming responses
|
| 13 |
+
|
| 14 |
+
## Quick Actions
|
| 15 |
+
|
| 16 |
+
- [⚡ Deploy to Hanzo](https://hanzo.app/dev?template=https://github.com/Hanzo-Community/template-ai-chat-interface&action=deploy)
|
| 17 |
+
- [✏️ Edit on Hanzo](https://hanzo.app/dev?template=https://github.com/Hanzo-Community/template-ai-chat-interface&action=edit)
|
| 18 |
+
|
| 19 |
+
Part of the [Hanzo Community Gallery](https://huggingface.co/spaces/hanzoai/gallery)
|
components/avatar.tsx
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
|
| 8 |
+
function Avatar({
|
| 9 |
+
className,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Root>) {
|
| 12 |
+
return (
|
| 13 |
+
<AvatarPrimitive.Root
|
| 14 |
+
data-slot="avatar"
|
| 15 |
+
className={cn(
|
| 16 |
+
"relative flex size-8 shrink-0 overflow-hidden rounded-full",
|
| 17 |
+
className
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
/>
|
| 21 |
+
)
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
function AvatarImage({
|
| 25 |
+
className,
|
| 26 |
+
...props
|
| 27 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
| 28 |
+
return (
|
| 29 |
+
<AvatarPrimitive.Image
|
| 30 |
+
data-slot="avatar-image"
|
| 31 |
+
className={cn("aspect-square size-full", className)}
|
| 32 |
+
{...props}
|
| 33 |
+
/>
|
| 34 |
+
)
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function AvatarFallback({
|
| 38 |
+
className,
|
| 39 |
+
...props
|
| 40 |
+
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
| 41 |
+
return (
|
| 42 |
+
<AvatarPrimitive.Fallback
|
| 43 |
+
data-slot="avatar-fallback"
|
| 44 |
+
className={cn(
|
| 45 |
+
"bg-muted flex size-full items-center justify-center rounded-full",
|
| 46 |
+
className
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
)
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export { Avatar, AvatarImage, AvatarFallback }
|
components/badge.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils"
|
| 5 |
+
|
| 6 |
+
const badgeVariants = cva(
|
| 7 |
+
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
| 8 |
+
{
|
| 9 |
+
variants: {
|
| 10 |
+
variant: {
|
| 11 |
+
default:
|
| 12 |
+
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
|
| 13 |
+
secondary:
|
| 14 |
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
| 15 |
+
destructive:
|
| 16 |
+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
| 17 |
+
outline: "text-foreground",
|
| 18 |
+
},
|
| 19 |
+
},
|
| 20 |
+
defaultVariants: {
|
| 21 |
+
variant: "default",
|
| 22 |
+
},
|
| 23 |
+
}
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
export interface BadgeProps
|
| 27 |
+
extends React.HTMLAttributes<HTMLDivElement>,
|
| 28 |
+
VariantProps<typeof badgeVariants> {}
|
| 29 |
+
|
| 30 |
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
| 31 |
+
return (
|
| 32 |
+
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
| 33 |
+
)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
export { Badge, badgeVariants }
|
components/button.tsx
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react";
|
| 2 |
+
import { Slot } from "@radix-ui/react-slot";
|
| 3 |
+
import { cva, type VariantProps } from "class-variance-authority";
|
| 4 |
+
|
| 5 |
+
import { cn } from "@/lib/utils";
|
| 6 |
+
|
| 7 |
+
const buttonVariants = cva(
|
| 8 |
+
"inline-flex items-center cursor-pointer justify-center gap-2 whitespace-nowrap rounded-full text-sm font-sans font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
| 9 |
+
{
|
| 10 |
+
variants: {
|
| 11 |
+
variant: {
|
| 12 |
+
default:
|
| 13 |
+
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
|
| 14 |
+
destructive:
|
| 15 |
+
"bg-red-500 text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 [&_svg]:!text-white",
|
| 16 |
+
outline:
|
| 17 |
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
| 18 |
+
secondary:
|
| 19 |
+
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
| 20 |
+
ghost:
|
| 21 |
+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
| 22 |
+
lightGray: "bg-neutral-200/60 hover:bg-neutral-200",
|
| 23 |
+
link: "text-primary underline-offset-4 hover:underline",
|
| 24 |
+
ghostDarker:
|
| 25 |
+
"text-white shadow-xs focus-visible:ring-black/40 bg-black/40 hover:bg-black/70",
|
| 26 |
+
black: "bg-neutral-950 text-neutral-300 hover:brightness-110",
|
| 27 |
+
sky: "bg-sky-500 text-white hover:brightness-110",
|
| 28 |
+
},
|
| 29 |
+
size: {
|
| 30 |
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
| 31 |
+
sm: "h-8 rounded-full text-[13px] gap-1.5 px-3",
|
| 32 |
+
lg: "h-10 rounded-full px-6 has-[>svg]:px-4",
|
| 33 |
+
icon: "size-9",
|
| 34 |
+
iconXs: "size-7",
|
| 35 |
+
iconXss: "size-6",
|
| 36 |
+
iconXsss: "size-5",
|
| 37 |
+
xs: "h-6 text-xs rounded-full pl-2 pr-2 gap-1",
|
| 38 |
+
},
|
| 39 |
+
},
|
| 40 |
+
defaultVariants: {
|
| 41 |
+
variant: "default",
|
| 42 |
+
size: "default",
|
| 43 |
+
},
|
| 44 |
+
}
|
| 45 |
+
);
|
| 46 |
+
|
| 47 |
+
function Button({
|
| 48 |
+
className,
|
| 49 |
+
variant,
|
| 50 |
+
size,
|
| 51 |
+
asChild = false,
|
| 52 |
+
...props
|
| 53 |
+
}: React.ComponentProps<"button"> &
|
| 54 |
+
VariantProps<typeof buttonVariants> & {
|
| 55 |
+
asChild?: boolean;
|
| 56 |
+
}) {
|
| 57 |
+
const Comp = asChild ? Slot : "button";
|
| 58 |
+
|
| 59 |
+
return (
|
| 60 |
+
<Comp
|
| 61 |
+
data-slot="button"
|
| 62 |
+
className={cn(buttonVariants({ variant, size, className }))}
|
| 63 |
+
{...props}
|
| 64 |
+
/>
|
| 65 |
+
);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
export { Button, buttonVariants };
|
components/card.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils"
|
| 4 |
+
|
| 5 |
+
const Card = React.forwardRef<
|
| 6 |
+
HTMLDivElement,
|
| 7 |
+
React.HTMLAttributes<HTMLDivElement>
|
| 8 |
+
>(({ className, ...props }, ref) => (
|
| 9 |
+
<div
|
| 10 |
+
ref={ref}
|
| 11 |
+
className={cn(
|
| 12 |
+
"rounded-lg border bg-card text-card-foreground shadow-sm",
|
| 13 |
+
className
|
| 14 |
+
)}
|
| 15 |
+
{...props}
|
| 16 |
+
/>
|
| 17 |
+
))
|
| 18 |
+
Card.displayName = "Card"
|
| 19 |
+
|
| 20 |
+
const CardHeader = React.forwardRef<
|
| 21 |
+
HTMLDivElement,
|
| 22 |
+
React.HTMLAttributes<HTMLDivElement>
|
| 23 |
+
>(({ className, ...props }, ref) => (
|
| 24 |
+
<div
|
| 25 |
+
ref={ref}
|
| 26 |
+
className={cn("flex flex-col space-y-1.5 p-6", className)}
|
| 27 |
+
{...props}
|
| 28 |
+
/>
|
| 29 |
+
))
|
| 30 |
+
CardHeader.displayName = "CardHeader"
|
| 31 |
+
|
| 32 |
+
const CardTitle = React.forwardRef<
|
| 33 |
+
HTMLParagraphElement,
|
| 34 |
+
React.HTMLAttributes<HTMLHeadingElement>
|
| 35 |
+
>(({ className, ...props }, ref) => (
|
| 36 |
+
<h3
|
| 37 |
+
ref={ref}
|
| 38 |
+
className={cn(
|
| 39 |
+
"text-2xl font-semibold leading-none tracking-tight",
|
| 40 |
+
className
|
| 41 |
+
)}
|
| 42 |
+
{...props}
|
| 43 |
+
/>
|
| 44 |
+
))
|
| 45 |
+
CardTitle.displayName = "CardTitle"
|
| 46 |
+
|
| 47 |
+
const CardDescription = React.forwardRef<
|
| 48 |
+
HTMLParagraphElement,
|
| 49 |
+
React.HTMLAttributes<HTMLParagraphElement>
|
| 50 |
+
>(({ className, ...props }, ref) => (
|
| 51 |
+
<p
|
| 52 |
+
ref={ref}
|
| 53 |
+
className={cn("text-sm text-muted-foreground", className)}
|
| 54 |
+
{...props}
|
| 55 |
+
/>
|
| 56 |
+
))
|
| 57 |
+
CardDescription.displayName = "CardDescription"
|
| 58 |
+
|
| 59 |
+
const CardContent = React.forwardRef<
|
| 60 |
+
HTMLDivElement,
|
| 61 |
+
React.HTMLAttributes<HTMLDivElement>
|
| 62 |
+
>(({ className, ...props }, ref) => (
|
| 63 |
+
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
|
| 64 |
+
))
|
| 65 |
+
CardContent.displayName = "CardContent"
|
| 66 |
+
|
| 67 |
+
const CardFooter = React.forwardRef<
|
| 68 |
+
HTMLDivElement,
|
| 69 |
+
React.HTMLAttributes<HTMLDivElement>
|
| 70 |
+
>(({ className, ...props }, ref) => (
|
| 71 |
+
<div
|
| 72 |
+
ref={ref}
|
| 73 |
+
className={cn("flex items-center p-6 pt-0", className)}
|
| 74 |
+
{...props}
|
| 75 |
+
/>
|
| 76 |
+
))
|
| 77 |
+
CardFooter.displayName = "CardFooter"
|
| 78 |
+
|
| 79 |
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
|
components/checkbox.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
| 5 |
+
import { CheckIcon } from "lucide-react";
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
|
| 9 |
+
function Checkbox({
|
| 10 |
+
className,
|
| 11 |
+
...props
|
| 12 |
+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
| 13 |
+
return (
|
| 14 |
+
<CheckboxPrimitive.Root
|
| 15 |
+
data-slot="checkbox"
|
| 16 |
+
className={cn(
|
| 17 |
+
"peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-3.5 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
| 18 |
+
className
|
| 19 |
+
)}
|
| 20 |
+
{...props}
|
| 21 |
+
>
|
| 22 |
+
<CheckboxPrimitive.Indicator
|
| 23 |
+
data-slot="checkbox-indicator"
|
| 24 |
+
className="flex items-center justify-center text-current transition-none"
|
| 25 |
+
>
|
| 26 |
+
<CheckIcon className="size-3" />
|
| 27 |
+
</CheckboxPrimitive.Indicator>
|
| 28 |
+
</CheckboxPrimitive.Root>
|
| 29 |
+
);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
export { Checkbox };
|
components/collapsible.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
|
| 4 |
+
|
| 5 |
+
function Collapsible({
|
| 6 |
+
...props
|
| 7 |
+
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
| 8 |
+
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function CollapsibleTrigger({
|
| 12 |
+
...props
|
| 13 |
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
| 14 |
+
return (
|
| 15 |
+
<CollapsiblePrimitive.CollapsibleTrigger
|
| 16 |
+
data-slot="collapsible-trigger"
|
| 17 |
+
{...props}
|
| 18 |
+
/>
|
| 19 |
+
)
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
function CollapsibleContent({
|
| 23 |
+
...props
|
| 24 |
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
| 25 |
+
return (
|
| 26 |
+
<CollapsiblePrimitive.CollapsibleContent
|
| 27 |
+
data-slot="collapsible-content"
|
| 28 |
+
{...props}
|
| 29 |
+
/>
|
| 30 |
+
)
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
|
components/dialog.tsx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as DialogPrimitive from "@radix-ui/react-dialog"
|
| 5 |
+
import { XIcon } from "lucide-react"
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils"
|
| 8 |
+
|
| 9 |
+
function Dialog({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
| 12 |
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function DialogTrigger({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
| 18 |
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function DialogPortal({
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
| 24 |
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function DialogClose({
|
| 28 |
+
...props
|
| 29 |
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
| 30 |
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
function DialogOverlay({
|
| 34 |
+
className,
|
| 35 |
+
...props
|
| 36 |
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
| 37 |
+
return (
|
| 38 |
+
<DialogPrimitive.Overlay
|
| 39 |
+
data-slot="dialog-overlay"
|
| 40 |
+
className={cn(
|
| 41 |
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
| 42 |
+
className
|
| 43 |
+
)}
|
| 44 |
+
{...props}
|
| 45 |
+
/>
|
| 46 |
+
)
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
function DialogContent({
|
| 50 |
+
className,
|
| 51 |
+
children,
|
| 52 |
+
showCloseButton = true,
|
| 53 |
+
...props
|
| 54 |
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
| 55 |
+
showCloseButton?: boolean
|
| 56 |
+
}) {
|
| 57 |
+
return (
|
| 58 |
+
<DialogPortal data-slot="dialog-portal">
|
| 59 |
+
<DialogOverlay />
|
| 60 |
+
<DialogPrimitive.Content
|
| 61 |
+
data-slot="dialog-content"
|
| 62 |
+
className={cn(
|
| 63 |
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
| 64 |
+
className
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
>
|
| 68 |
+
{children}
|
| 69 |
+
{showCloseButton && (
|
| 70 |
+
<DialogPrimitive.Close
|
| 71 |
+
data-slot="dialog-close"
|
| 72 |
+
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
| 73 |
+
>
|
| 74 |
+
<XIcon />
|
| 75 |
+
<span className="sr-only">Close</span>
|
| 76 |
+
</DialogPrimitive.Close>
|
| 77 |
+
)}
|
| 78 |
+
</DialogPrimitive.Content>
|
| 79 |
+
</DialogPortal>
|
| 80 |
+
)
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
| 84 |
+
return (
|
| 85 |
+
<div
|
| 86 |
+
data-slot="dialog-header"
|
| 87 |
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
| 88 |
+
{...props}
|
| 89 |
+
/>
|
| 90 |
+
)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
| 94 |
+
return (
|
| 95 |
+
<div
|
| 96 |
+
data-slot="dialog-footer"
|
| 97 |
+
className={cn(
|
| 98 |
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
| 99 |
+
className
|
| 100 |
+
)}
|
| 101 |
+
{...props}
|
| 102 |
+
/>
|
| 103 |
+
)
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
function DialogTitle({
|
| 107 |
+
className,
|
| 108 |
+
...props
|
| 109 |
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
| 110 |
+
return (
|
| 111 |
+
<DialogPrimitive.Title
|
| 112 |
+
data-slot="dialog-title"
|
| 113 |
+
className={cn("text-lg leading-none font-semibold", className)}
|
| 114 |
+
{...props}
|
| 115 |
+
/>
|
| 116 |
+
)
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
function DialogDescription({
|
| 120 |
+
className,
|
| 121 |
+
...props
|
| 122 |
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
| 123 |
+
return (
|
| 124 |
+
<DialogPrimitive.Description
|
| 125 |
+
data-slot="dialog-description"
|
| 126 |
+
className={cn("text-muted-foreground text-sm", className)}
|
| 127 |
+
{...props}
|
| 128 |
+
/>
|
| 129 |
+
)
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
export {
|
| 133 |
+
Dialog,
|
| 134 |
+
DialogClose,
|
| 135 |
+
DialogContent,
|
| 136 |
+
DialogDescription,
|
| 137 |
+
DialogFooter,
|
| 138 |
+
DialogHeader,
|
| 139 |
+
DialogOverlay,
|
| 140 |
+
DialogPortal,
|
| 141 |
+
DialogTitle,
|
| 142 |
+
DialogTrigger,
|
| 143 |
+
}
|
components/dropdown-menu.tsx
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
| 5 |
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils";
|
| 8 |
+
|
| 9 |
+
function DropdownMenu({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
| 12 |
+
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function DropdownMenuPortal({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
|
| 18 |
+
return (
|
| 19 |
+
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
|
| 20 |
+
);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
function DropdownMenuTrigger({
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
| 26 |
+
return (
|
| 27 |
+
<DropdownMenuPrimitive.Trigger
|
| 28 |
+
data-slot="dropdown-menu-trigger"
|
| 29 |
+
{...props}
|
| 30 |
+
/>
|
| 31 |
+
);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function DropdownMenuContent({
|
| 35 |
+
className,
|
| 36 |
+
sideOffset = 4,
|
| 37 |
+
...props
|
| 38 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
| 39 |
+
return (
|
| 40 |
+
<DropdownMenuPrimitive.Portal>
|
| 41 |
+
<DropdownMenuPrimitive.Content
|
| 42 |
+
data-slot="dropdown-menu-content"
|
| 43 |
+
sideOffset={sideOffset}
|
| 44 |
+
className={cn(
|
| 45 |
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out 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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
|
| 46 |
+
className
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
</DropdownMenuPrimitive.Portal>
|
| 51 |
+
);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function DropdownMenuGroup({
|
| 55 |
+
...props
|
| 56 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
| 57 |
+
return (
|
| 58 |
+
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
| 59 |
+
);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function DropdownMenuItem({
|
| 63 |
+
className,
|
| 64 |
+
inset,
|
| 65 |
+
variant = "default",
|
| 66 |
+
...props
|
| 67 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
| 68 |
+
inset?: boolean;
|
| 69 |
+
variant?: "default" | "destructive";
|
| 70 |
+
}) {
|
| 71 |
+
return (
|
| 72 |
+
<DropdownMenuPrimitive.Item
|
| 73 |
+
data-slot="dropdown-menu-item"
|
| 74 |
+
data-inset={inset}
|
| 75 |
+
data-variant={variant}
|
| 76 |
+
className={cn(
|
| 77 |
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 78 |
+
className
|
| 79 |
+
)}
|
| 80 |
+
{...props}
|
| 81 |
+
/>
|
| 82 |
+
);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function DropdownMenuCheckboxItem({
|
| 86 |
+
className,
|
| 87 |
+
children,
|
| 88 |
+
checked,
|
| 89 |
+
...props
|
| 90 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
|
| 91 |
+
return (
|
| 92 |
+
<DropdownMenuPrimitive.CheckboxItem
|
| 93 |
+
data-slot="dropdown-menu-checkbox-item"
|
| 94 |
+
className={cn(
|
| 95 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 96 |
+
className
|
| 97 |
+
)}
|
| 98 |
+
checked={checked}
|
| 99 |
+
{...props}
|
| 100 |
+
>
|
| 101 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 102 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 103 |
+
<CheckIcon className="size-4" />
|
| 104 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 105 |
+
</span>
|
| 106 |
+
{children}
|
| 107 |
+
</DropdownMenuPrimitive.CheckboxItem>
|
| 108 |
+
);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
function DropdownMenuRadioGroup({
|
| 112 |
+
...props
|
| 113 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
|
| 114 |
+
return (
|
| 115 |
+
<DropdownMenuPrimitive.RadioGroup
|
| 116 |
+
data-slot="dropdown-menu-radio-group"
|
| 117 |
+
{...props}
|
| 118 |
+
/>
|
| 119 |
+
);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
function DropdownMenuRadioItem({
|
| 123 |
+
className,
|
| 124 |
+
children,
|
| 125 |
+
...props
|
| 126 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
|
| 127 |
+
return (
|
| 128 |
+
<DropdownMenuPrimitive.RadioItem
|
| 129 |
+
data-slot="dropdown-menu-radio-item"
|
| 130 |
+
className={cn(
|
| 131 |
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 132 |
+
className
|
| 133 |
+
)}
|
| 134 |
+
{...props}
|
| 135 |
+
>
|
| 136 |
+
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
|
| 137 |
+
<DropdownMenuPrimitive.ItemIndicator>
|
| 138 |
+
<CircleIcon className="size-2 fill-current" />
|
| 139 |
+
</DropdownMenuPrimitive.ItemIndicator>
|
| 140 |
+
</span>
|
| 141 |
+
{children}
|
| 142 |
+
</DropdownMenuPrimitive.RadioItem>
|
| 143 |
+
);
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
function DropdownMenuLabel({
|
| 147 |
+
className,
|
| 148 |
+
inset,
|
| 149 |
+
...props
|
| 150 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
|
| 151 |
+
inset?: boolean;
|
| 152 |
+
}) {
|
| 153 |
+
return (
|
| 154 |
+
<DropdownMenuPrimitive.Label
|
| 155 |
+
data-slot="dropdown-menu-label"
|
| 156 |
+
data-inset={inset}
|
| 157 |
+
className={cn(
|
| 158 |
+
"px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
|
| 159 |
+
className
|
| 160 |
+
)}
|
| 161 |
+
{...props}
|
| 162 |
+
/>
|
| 163 |
+
);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
function DropdownMenuSeparator({
|
| 167 |
+
className,
|
| 168 |
+
...props
|
| 169 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
| 170 |
+
return (
|
| 171 |
+
<DropdownMenuPrimitive.Separator
|
| 172 |
+
data-slot="dropdown-menu-separator"
|
| 173 |
+
className={cn("bg-border -mx-1 my-1 h-px", className)}
|
| 174 |
+
{...props}
|
| 175 |
+
/>
|
| 176 |
+
);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
function DropdownMenuShortcut({
|
| 180 |
+
className,
|
| 181 |
+
...props
|
| 182 |
+
}: React.ComponentProps<"span">) {
|
| 183 |
+
return (
|
| 184 |
+
<span
|
| 185 |
+
data-slot="dropdown-menu-shortcut"
|
| 186 |
+
className={cn(
|
| 187 |
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
| 188 |
+
className
|
| 189 |
+
)}
|
| 190 |
+
{...props}
|
| 191 |
+
/>
|
| 192 |
+
);
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
function DropdownMenuSub({
|
| 196 |
+
...props
|
| 197 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
|
| 198 |
+
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
function DropdownMenuSubTrigger({
|
| 202 |
+
className,
|
| 203 |
+
inset,
|
| 204 |
+
children,
|
| 205 |
+
...props
|
| 206 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
| 207 |
+
inset?: boolean;
|
| 208 |
+
}) {
|
| 209 |
+
return (
|
| 210 |
+
<DropdownMenuPrimitive.SubTrigger
|
| 211 |
+
data-slot="dropdown-menu-sub-trigger"
|
| 212 |
+
data-inset={inset}
|
| 213 |
+
className={cn(
|
| 214 |
+
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8",
|
| 215 |
+
className
|
| 216 |
+
)}
|
| 217 |
+
{...props}
|
| 218 |
+
>
|
| 219 |
+
{children}
|
| 220 |
+
<ChevronRightIcon className="ml-auto size-4" />
|
| 221 |
+
</DropdownMenuPrimitive.SubTrigger>
|
| 222 |
+
);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
function DropdownMenuSubContent({
|
| 226 |
+
className,
|
| 227 |
+
...props
|
| 228 |
+
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
|
| 229 |
+
return (
|
| 230 |
+
<DropdownMenuPrimitive.SubContent
|
| 231 |
+
data-slot="dropdown-menu-sub-content"
|
| 232 |
+
className={cn(
|
| 233 |
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out 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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",
|
| 234 |
+
className
|
| 235 |
+
)}
|
| 236 |
+
{...props}
|
| 237 |
+
/>
|
| 238 |
+
);
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
export {
|
| 242 |
+
DropdownMenu,
|
| 243 |
+
DropdownMenuPortal,
|
| 244 |
+
DropdownMenuTrigger,
|
| 245 |
+
DropdownMenuContent,
|
| 246 |
+
DropdownMenuGroup,
|
| 247 |
+
DropdownMenuLabel,
|
| 248 |
+
DropdownMenuItem,
|
| 249 |
+
DropdownMenuCheckboxItem,
|
| 250 |
+
DropdownMenuRadioGroup,
|
| 251 |
+
DropdownMenuRadioItem,
|
| 252 |
+
DropdownMenuSeparator,
|
| 253 |
+
DropdownMenuShortcut,
|
| 254 |
+
DropdownMenuSub,
|
| 255 |
+
DropdownMenuSubTrigger,
|
| 256 |
+
DropdownMenuSubContent,
|
| 257 |
+
};
|
components/input.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
|
| 3 |
+
import { cn } from "@/lib/utils"
|
| 4 |
+
|
| 5 |
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
| 6 |
+
return (
|
| 7 |
+
<input
|
| 8 |
+
type={type}
|
| 9 |
+
data-slot="input"
|
| 10 |
+
className={cn(
|
| 11 |
+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
| 12 |
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
| 13 |
+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
| 14 |
+
className
|
| 15 |
+
)}
|
| 16 |
+
{...props}
|
| 17 |
+
/>
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
export { Input }
|
components/label.tsx
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as LabelPrimitive from "@radix-ui/react-label"
|
| 5 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils"
|
| 8 |
+
|
| 9 |
+
const labelVariants = cva(
|
| 10 |
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
const Label = React.forwardRef<
|
| 14 |
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
| 15 |
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
| 16 |
+
VariantProps<typeof labelVariants>
|
| 17 |
+
>(({ className, ...props }, ref) => (
|
| 18 |
+
<LabelPrimitive.Root
|
| 19 |
+
ref={ref}
|
| 20 |
+
className={cn(labelVariants(), className)}
|
| 21 |
+
{...props}
|
| 22 |
+
/>
|
| 23 |
+
))
|
| 24 |
+
Label.displayName = LabelPrimitive.Root.displayName
|
| 25 |
+
|
| 26 |
+
export { Label }
|
components/popover.tsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import * as React from "react";
|
| 4 |
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils";
|
| 7 |
+
|
| 8 |
+
function Popover({
|
| 9 |
+
...props
|
| 10 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
| 11 |
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function PopoverTrigger({
|
| 15 |
+
...props
|
| 16 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
| 17 |
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
function PopoverContent({
|
| 21 |
+
className,
|
| 22 |
+
align = "center",
|
| 23 |
+
sideOffset = 4,
|
| 24 |
+
...props
|
| 25 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
| 26 |
+
return (
|
| 27 |
+
<PopoverPrimitive.Portal>
|
| 28 |
+
<PopoverPrimitive.Content
|
| 29 |
+
data-slot="popover-content"
|
| 30 |
+
align={align}
|
| 31 |
+
sideOffset={sideOffset}
|
| 32 |
+
className={cn(
|
| 33 |
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out 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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
| 34 |
+
className
|
| 35 |
+
)}
|
| 36 |
+
{...props}
|
| 37 |
+
/>
|
| 38 |
+
</PopoverPrimitive.Portal>
|
| 39 |
+
);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
function PopoverAnchor({
|
| 43 |
+
...props
|
| 44 |
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
| 45 |
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
|
components/progress.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as React from "react"
|
| 2 |
+
import * as ProgressPrimitive from "@radix-ui/react-progress"
|
| 3 |
+
|
| 4 |
+
import { cn } from "@/lib/utils"
|
| 5 |
+
|
| 6 |
+
const Progress = React.forwardRef<
|
| 7 |
+
React.ElementRef<typeof ProgressPrimitive.Root>,
|
| 8 |
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> & {
|
| 9 |
+
indicatorClassName?: string
|
| 10 |
+
}
|
| 11 |
+
>(({ className, value, indicatorClassName, ...props }, ref) => (
|
| 12 |
+
<ProgressPrimitive.Root
|
| 13 |
+
ref={ref}
|
| 14 |
+
className={cn(
|
| 15 |
+
"relative h-2 w-full overflow-hidden rounded-full bg-secondary",
|
| 16 |
+
className
|
| 17 |
+
)}
|
| 18 |
+
{...props}
|
| 19 |
+
>
|
| 20 |
+
<ProgressPrimitive.Indicator
|
| 21 |
+
className={cn("h-full w-full flex-1 bg-primary transition-all", indicatorClassName)}
|
| 22 |
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
| 23 |
+
/>
|
| 24 |
+
</ProgressPrimitive.Root>
|
| 25 |
+
))
|
| 26 |
+
Progress.displayName = ProgressPrimitive.Root.displayName
|
| 27 |
+
|
| 28 |
+
export { Progress }
|
components/select.tsx
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as SelectPrimitive from "@radix-ui/react-select"
|
| 5 |
+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils"
|
| 8 |
+
|
| 9 |
+
function Select({
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
| 12 |
+
return <SelectPrimitive.Root data-slot="select" {...props} />
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
function SelectGroup({
|
| 16 |
+
...props
|
| 17 |
+
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
| 18 |
+
return <SelectPrimitive.Group data-slot="select-group" {...props} />
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function SelectValue({
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
| 24 |
+
return <SelectPrimitive.Value data-slot="select-value" {...props} />
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
function SelectTrigger({
|
| 28 |
+
className,
|
| 29 |
+
size = "default",
|
| 30 |
+
children,
|
| 31 |
+
...props
|
| 32 |
+
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
| 33 |
+
size?: "sm" | "default"
|
| 34 |
+
}) {
|
| 35 |
+
return (
|
| 36 |
+
<SelectPrimitive.Trigger
|
| 37 |
+
data-slot="select-trigger"
|
| 38 |
+
data-size={size}
|
| 39 |
+
className={cn(
|
| 40 |
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 41 |
+
className
|
| 42 |
+
)}
|
| 43 |
+
{...props}
|
| 44 |
+
>
|
| 45 |
+
{children}
|
| 46 |
+
<SelectPrimitive.Icon asChild>
|
| 47 |
+
<ChevronDownIcon className="size-4 opacity-50" />
|
| 48 |
+
</SelectPrimitive.Icon>
|
| 49 |
+
</SelectPrimitive.Trigger>
|
| 50 |
+
)
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function SelectContent({
|
| 54 |
+
className,
|
| 55 |
+
children,
|
| 56 |
+
position = "popper",
|
| 57 |
+
...props
|
| 58 |
+
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
| 59 |
+
return (
|
| 60 |
+
<SelectPrimitive.Portal>
|
| 61 |
+
<SelectPrimitive.Content
|
| 62 |
+
data-slot="select-content"
|
| 63 |
+
className={cn(
|
| 64 |
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out 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 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
| 65 |
+
position === "popper" &&
|
| 66 |
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
| 67 |
+
className
|
| 68 |
+
)}
|
| 69 |
+
position={position}
|
| 70 |
+
{...props}
|
| 71 |
+
>
|
| 72 |
+
<SelectScrollUpButton />
|
| 73 |
+
<SelectPrimitive.Viewport
|
| 74 |
+
className={cn(
|
| 75 |
+
"p-1",
|
| 76 |
+
position === "popper" &&
|
| 77 |
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
| 78 |
+
)}
|
| 79 |
+
>
|
| 80 |
+
{children}
|
| 81 |
+
</SelectPrimitive.Viewport>
|
| 82 |
+
<SelectScrollDownButton />
|
| 83 |
+
</SelectPrimitive.Content>
|
| 84 |
+
</SelectPrimitive.Portal>
|
| 85 |
+
)
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function SelectLabel({
|
| 89 |
+
className,
|
| 90 |
+
...props
|
| 91 |
+
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
| 92 |
+
return (
|
| 93 |
+
<SelectPrimitive.Label
|
| 94 |
+
data-slot="select-label"
|
| 95 |
+
className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
|
| 96 |
+
{...props}
|
| 97 |
+
/>
|
| 98 |
+
)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
function SelectItem({
|
| 102 |
+
className,
|
| 103 |
+
children,
|
| 104 |
+
...props
|
| 105 |
+
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
| 106 |
+
return (
|
| 107 |
+
<SelectPrimitive.Item
|
| 108 |
+
data-slot="select-item"
|
| 109 |
+
className={cn(
|
| 110 |
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
| 111 |
+
className
|
| 112 |
+
)}
|
| 113 |
+
{...props}
|
| 114 |
+
>
|
| 115 |
+
<span className="absolute right-2 flex size-3.5 items-center justify-center">
|
| 116 |
+
<SelectPrimitive.ItemIndicator>
|
| 117 |
+
<CheckIcon className="size-4" />
|
| 118 |
+
</SelectPrimitive.ItemIndicator>
|
| 119 |
+
</span>
|
| 120 |
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
| 121 |
+
</SelectPrimitive.Item>
|
| 122 |
+
)
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function SelectSeparator({
|
| 126 |
+
className,
|
| 127 |
+
...props
|
| 128 |
+
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
| 129 |
+
return (
|
| 130 |
+
<SelectPrimitive.Separator
|
| 131 |
+
data-slot="select-separator"
|
| 132 |
+
className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
|
| 133 |
+
{...props}
|
| 134 |
+
/>
|
| 135 |
+
)
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function SelectScrollUpButton({
|
| 139 |
+
className,
|
| 140 |
+
...props
|
| 141 |
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
| 142 |
+
return (
|
| 143 |
+
<SelectPrimitive.ScrollUpButton
|
| 144 |
+
data-slot="select-scroll-up-button"
|
| 145 |
+
className={cn(
|
| 146 |
+
"flex cursor-default items-center justify-center py-1",
|
| 147 |
+
className
|
| 148 |
+
)}
|
| 149 |
+
{...props}
|
| 150 |
+
>
|
| 151 |
+
<ChevronUpIcon className="size-4" />
|
| 152 |
+
</SelectPrimitive.ScrollUpButton>
|
| 153 |
+
)
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
function SelectScrollDownButton({
|
| 157 |
+
className,
|
| 158 |
+
...props
|
| 159 |
+
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
| 160 |
+
return (
|
| 161 |
+
<SelectPrimitive.ScrollDownButton
|
| 162 |
+
data-slot="select-scroll-down-button"
|
| 163 |
+
className={cn(
|
| 164 |
+
"flex cursor-default items-center justify-center py-1",
|
| 165 |
+
className
|
| 166 |
+
)}
|
| 167 |
+
{...props}
|
| 168 |
+
>
|
| 169 |
+
<ChevronDownIcon className="size-4" />
|
| 170 |
+
</SelectPrimitive.ScrollDownButton>
|
| 171 |
+
)
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
export {
|
| 175 |
+
Select,
|
| 176 |
+
SelectContent,
|
| 177 |
+
SelectGroup,
|
| 178 |
+
SelectItem,
|
| 179 |
+
SelectLabel,
|
| 180 |
+
SelectScrollDownButton,
|
| 181 |
+
SelectScrollUpButton,
|
| 182 |
+
SelectSeparator,
|
| 183 |
+
SelectTrigger,
|
| 184 |
+
SelectValue,
|
| 185 |
+
}
|
components/sonner.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { Toaster as Sonner, ToasterProps } from "sonner";
|
| 4 |
+
|
| 5 |
+
const Toaster = ({ ...props }: ToasterProps) => {
|
| 6 |
+
return (
|
| 7 |
+
<Sonner
|
| 8 |
+
theme="dark"
|
| 9 |
+
className="toaster group"
|
| 10 |
+
style={
|
| 11 |
+
{
|
| 12 |
+
"--normal-bg": "var(--popover)",
|
| 13 |
+
"--normal-text": "var(--popover-foreground)",
|
| 14 |
+
"--normal-border": "var(--border)",
|
| 15 |
+
} as React.CSSProperties
|
| 16 |
+
}
|
| 17 |
+
{...props}
|
| 18 |
+
/>
|
| 19 |
+
);
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
export { Toaster };
|
components/switch.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as SwitchPrimitive from "@radix-ui/react-switch"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
|
| 8 |
+
function Switch({
|
| 9 |
+
className,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof SwitchPrimitive.Root>) {
|
| 12 |
+
return (
|
| 13 |
+
<SwitchPrimitive.Root
|
| 14 |
+
data-slot="switch"
|
| 15 |
+
className={cn(
|
| 16 |
+
"peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
| 17 |
+
className
|
| 18 |
+
)}
|
| 19 |
+
{...props}
|
| 20 |
+
>
|
| 21 |
+
<SwitchPrimitive.Thumb
|
| 22 |
+
data-slot="switch-thumb"
|
| 23 |
+
className={cn(
|
| 24 |
+
"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
| 25 |
+
)}
|
| 26 |
+
/>
|
| 27 |
+
</SwitchPrimitive.Root>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export { Switch }
|
components/tabs.tsx
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
|
| 8 |
+
function Tabs({
|
| 9 |
+
className,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
| 12 |
+
return (
|
| 13 |
+
<TabsPrimitive.Root
|
| 14 |
+
data-slot="tabs"
|
| 15 |
+
className={cn("flex flex-col gap-2", className)}
|
| 16 |
+
{...props}
|
| 17 |
+
/>
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function TabsList({
|
| 22 |
+
className,
|
| 23 |
+
...props
|
| 24 |
+
}: React.ComponentProps<typeof TabsPrimitive.List>) {
|
| 25 |
+
return (
|
| 26 |
+
<TabsPrimitive.List
|
| 27 |
+
data-slot="tabs-list"
|
| 28 |
+
className={cn(
|
| 29 |
+
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
|
| 30 |
+
className
|
| 31 |
+
)}
|
| 32 |
+
{...props}
|
| 33 |
+
/>
|
| 34 |
+
)
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function TabsTrigger({
|
| 38 |
+
className,
|
| 39 |
+
...props
|
| 40 |
+
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
|
| 41 |
+
return (
|
| 42 |
+
<TabsPrimitive.Trigger
|
| 43 |
+
data-slot="tabs-trigger"
|
| 44 |
+
className={cn(
|
| 45 |
+
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
| 46 |
+
className
|
| 47 |
+
)}
|
| 48 |
+
{...props}
|
| 49 |
+
/>
|
| 50 |
+
)
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function TabsContent({
|
| 54 |
+
className,
|
| 55 |
+
...props
|
| 56 |
+
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
|
| 57 |
+
return (
|
| 58 |
+
<TabsPrimitive.Content
|
| 59 |
+
data-slot="tabs-content"
|
| 60 |
+
className={cn("flex-1 outline-none", className)}
|
| 61 |
+
{...props}
|
| 62 |
+
/>
|
| 63 |
+
)
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
components/toggle-group.tsx
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
|
| 5 |
+
import { type VariantProps } from "class-variance-authority"
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils"
|
| 8 |
+
import { toggleVariants } from "@/components/ui/toggle"
|
| 9 |
+
|
| 10 |
+
const ToggleGroupContext = React.createContext<
|
| 11 |
+
VariantProps<typeof toggleVariants>
|
| 12 |
+
>({
|
| 13 |
+
size: "default",
|
| 14 |
+
variant: "default",
|
| 15 |
+
})
|
| 16 |
+
|
| 17 |
+
function ToggleGroup({
|
| 18 |
+
className,
|
| 19 |
+
variant,
|
| 20 |
+
size,
|
| 21 |
+
children,
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
| 24 |
+
VariantProps<typeof toggleVariants>) {
|
| 25 |
+
return (
|
| 26 |
+
<ToggleGroupPrimitive.Root
|
| 27 |
+
data-slot="toggle-group"
|
| 28 |
+
data-variant={variant}
|
| 29 |
+
data-size={size}
|
| 30 |
+
className={cn(
|
| 31 |
+
"group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs",
|
| 32 |
+
className
|
| 33 |
+
)}
|
| 34 |
+
{...props}
|
| 35 |
+
>
|
| 36 |
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
| 37 |
+
{children}
|
| 38 |
+
</ToggleGroupContext.Provider>
|
| 39 |
+
</ToggleGroupPrimitive.Root>
|
| 40 |
+
)
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function ToggleGroupItem({
|
| 44 |
+
className,
|
| 45 |
+
children,
|
| 46 |
+
variant,
|
| 47 |
+
size,
|
| 48 |
+
...props
|
| 49 |
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
| 50 |
+
VariantProps<typeof toggleVariants>) {
|
| 51 |
+
const context = React.useContext(ToggleGroupContext)
|
| 52 |
+
|
| 53 |
+
return (
|
| 54 |
+
<ToggleGroupPrimitive.Item
|
| 55 |
+
data-slot="toggle-group-item"
|
| 56 |
+
data-variant={context.variant || variant}
|
| 57 |
+
data-size={context.size || size}
|
| 58 |
+
className={cn(
|
| 59 |
+
toggleVariants({
|
| 60 |
+
variant: context.variant || variant,
|
| 61 |
+
size: context.size || size,
|
| 62 |
+
}),
|
| 63 |
+
"min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",
|
| 64 |
+
className
|
| 65 |
+
)}
|
| 66 |
+
{...props}
|
| 67 |
+
>
|
| 68 |
+
{children}
|
| 69 |
+
</ToggleGroupPrimitive.Item>
|
| 70 |
+
)
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
export { ToggleGroup, ToggleGroupItem }
|
components/toggle.tsx
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as TogglePrimitive from "@radix-ui/react-toggle"
|
| 5 |
+
import { cva, type VariantProps } from "class-variance-authority"
|
| 6 |
+
|
| 7 |
+
import { cn } from "@/lib/utils"
|
| 8 |
+
|
| 9 |
+
const toggleVariants = cva(
|
| 10 |
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
| 11 |
+
{
|
| 12 |
+
variants: {
|
| 13 |
+
variant: {
|
| 14 |
+
default: "bg-transparent",
|
| 15 |
+
outline:
|
| 16 |
+
"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
|
| 17 |
+
},
|
| 18 |
+
size: {
|
| 19 |
+
default: "h-9 px-2 min-w-9",
|
| 20 |
+
sm: "h-8 px-1.5 min-w-8",
|
| 21 |
+
lg: "h-10 px-2.5 min-w-10",
|
| 22 |
+
},
|
| 23 |
+
},
|
| 24 |
+
defaultVariants: {
|
| 25 |
+
variant: "default",
|
| 26 |
+
size: "default",
|
| 27 |
+
},
|
| 28 |
+
}
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
function Toggle({
|
| 32 |
+
className,
|
| 33 |
+
variant,
|
| 34 |
+
size,
|
| 35 |
+
...props
|
| 36 |
+
}: React.ComponentProps<typeof TogglePrimitive.Root> &
|
| 37 |
+
VariantProps<typeof toggleVariants>) {
|
| 38 |
+
return (
|
| 39 |
+
<TogglePrimitive.Root
|
| 40 |
+
data-slot="toggle"
|
| 41 |
+
className={cn(toggleVariants({ variant, size, className }))}
|
| 42 |
+
{...props}
|
| 43 |
+
/>
|
| 44 |
+
)
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
export { Toggle, toggleVariants }
|
components/tooltip.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import * as React from "react"
|
| 4 |
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
| 5 |
+
|
| 6 |
+
import { cn } from "@/lib/utils"
|
| 7 |
+
|
| 8 |
+
function TooltipProvider({
|
| 9 |
+
delayDuration = 0,
|
| 10 |
+
...props
|
| 11 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
| 12 |
+
return (
|
| 13 |
+
<TooltipPrimitive.Provider
|
| 14 |
+
data-slot="tooltip-provider"
|
| 15 |
+
delayDuration={delayDuration}
|
| 16 |
+
{...props}
|
| 17 |
+
/>
|
| 18 |
+
)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function Tooltip({
|
| 22 |
+
...props
|
| 23 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
| 24 |
+
return (
|
| 25 |
+
<TooltipProvider>
|
| 26 |
+
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
| 27 |
+
</TooltipProvider>
|
| 28 |
+
)
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
function TooltipTrigger({
|
| 32 |
+
...props
|
| 33 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
| 34 |
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
function TooltipContent({
|
| 38 |
+
className,
|
| 39 |
+
sideOffset = 0,
|
| 40 |
+
children,
|
| 41 |
+
...props
|
| 42 |
+
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
| 43 |
+
return (
|
| 44 |
+
<TooltipPrimitive.Portal>
|
| 45 |
+
<TooltipPrimitive.Content
|
| 46 |
+
data-slot="tooltip-content"
|
| 47 |
+
sideOffset={sideOffset}
|
| 48 |
+
className={cn(
|
| 49 |
+
"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
| 50 |
+
className
|
| 51 |
+
)}
|
| 52 |
+
{...props}
|
| 53 |
+
>
|
| 54 |
+
{children}
|
| 55 |
+
<TooltipPrimitive.Arrow className="bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
| 56 |
+
</TooltipPrimitive.Content>
|
| 57 |
+
</TooltipPrimitive.Portal>
|
| 58 |
+
)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
index.html
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Ai Chat Interface</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<style>
|
| 9 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
| 10 |
+
body { font-family: 'Inter', sans-serif; }
|
| 11 |
+
</style>
|
| 12 |
+
</head>
|
| 13 |
+
<body>
|
| 14 |
+
<div class="min-h-screen bg-gradient-to-b from-gray-50 to-white">
|
| 15 |
+
<div class="max-w-7xl mx-auto px-4 py-16">
|
| 16 |
+
<div class="text-center mb-12">
|
| 17 |
+
<h1 class="text-4xl font-bold mb-4">Ai Chat Interface</h1>
|
| 18 |
+
<p class="text-gray-600 mb-8">Modern chat UI with streaming responses</p>
|
| 19 |
+
<div class="flex justify-center gap-4">
|
| 20 |
+
<a href="https://hanzo.app/dev?template=https://github.com/Hanzo-Community/template-ai-chat-interface&action=deploy"
|
| 21 |
+
class="px-6 py-3 bg-purple-600 text-white rounded-lg hover:bg-purple-700 transition">
|
| 22 |
+
⚡ Deploy to Hanzo
|
| 23 |
+
</a>
|
| 24 |
+
<a href="https://hanzo.app/dev?template=https://github.com/Hanzo-Community/template-ai-chat-interface&action=edit"
|
| 25 |
+
class="px-6 py-3 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 transition">
|
| 26 |
+
✏️ Edit on Hanzo
|
| 27 |
+
</a>
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
<div class="bg-white rounded-lg shadow-xl p-8">
|
| 31 |
+
<iframe src="preview.html" class="w-full h-[600px] rounded border"></iframe>
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
| 34 |
+
</div>
|
| 35 |
+
</body>
|
| 36 |
+
</html>
|
page.tsx
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { useState, useRef, useEffect } from "react";
|
| 4 |
+
import {
|
| 5 |
+
Card,
|
| 6 |
+
CardContent,
|
| 7 |
+
CardDescription,
|
| 8 |
+
CardFooter,
|
| 9 |
+
CardHeader,
|
| 10 |
+
CardTitle
|
| 11 |
+
} from "@hanzo/ui/primitives/card";
|
| 12 |
+
import { Button } from "@hanzo/ui/primitives/button";
|
| 13 |
+
import { Input } from "@hanzo/ui/primitives/input";
|
| 14 |
+
import { ScrollArea } from "@hanzo/ui/primitives/scroll-area";
|
| 15 |
+
import { Avatar, AvatarFallback, AvatarImage } from "@hanzo/ui/primitives/avatar";
|
| 16 |
+
import { Badge } from "@hanzo/ui/primitives/badge";
|
| 17 |
+
import { Textarea } from "@hanzo/ui/primitives/textarea";
|
| 18 |
+
import {
|
| 19 |
+
Send,
|
| 20 |
+
Bot,
|
| 21 |
+
User,
|
| 22 |
+
Copy,
|
| 23 |
+
Download,
|
| 24 |
+
RefreshCw,
|
| 25 |
+
Loader2,
|
| 26 |
+
Sparkles,
|
| 27 |
+
Settings
|
| 28 |
+
} from "lucide-react";
|
| 29 |
+
import { cn } from "@hanzo/ui/util";
|
| 30 |
+
|
| 31 |
+
interface Message {
|
| 32 |
+
id: string;
|
| 33 |
+
role: "user" | "assistant";
|
| 34 |
+
content: string;
|
| 35 |
+
timestamp: Date;
|
| 36 |
+
isStreaming?: boolean;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
export default function AIChatInterface() {
|
| 40 |
+
const [messages, setMessages] = useState<Message[]>([
|
| 41 |
+
{
|
| 42 |
+
id: "1",
|
| 43 |
+
role: "assistant",
|
| 44 |
+
content: "Hello! I'm your AI assistant powered by @hanzo/ui. How can I help you today?",
|
| 45 |
+
timestamp: new Date(),
|
| 46 |
+
}
|
| 47 |
+
]);
|
| 48 |
+
const [input, setInput] = useState("");
|
| 49 |
+
const [isLoading, setIsLoading] = useState(false);
|
| 50 |
+
const scrollRef = useRef<HTMLDivElement>(null);
|
| 51 |
+
|
| 52 |
+
useEffect(() => {
|
| 53 |
+
scrollRef.current?.scrollIntoView({ behavior: "smooth" });
|
| 54 |
+
}, [messages]);
|
| 55 |
+
|
| 56 |
+
const handleSend = async () => {
|
| 57 |
+
if (!input.trim() || isLoading) return;
|
| 58 |
+
|
| 59 |
+
const userMessage: Message = {
|
| 60 |
+
id: Date.now().toString(),
|
| 61 |
+
role: "user",
|
| 62 |
+
content: input,
|
| 63 |
+
timestamp: new Date()
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
setMessages(prev => [...prev, userMessage]);
|
| 67 |
+
setInput("");
|
| 68 |
+
setIsLoading(true);
|
| 69 |
+
|
| 70 |
+
// Simulate streaming response
|
| 71 |
+
const assistantMessage: Message = {
|
| 72 |
+
id: (Date.now() + 1).toString(),
|
| 73 |
+
role: "assistant",
|
| 74 |
+
content: "",
|
| 75 |
+
timestamp: new Date(),
|
| 76 |
+
isStreaming: true
|
| 77 |
+
};
|
| 78 |
+
|
| 79 |
+
setMessages(prev => [...prev, assistantMessage]);
|
| 80 |
+
|
| 81 |
+
// Simulate streaming text
|
| 82 |
+
const response = `I understand you're asking about "${input}". Let me help you with that.
|
| 83 |
+
|
| 84 |
+
This response demonstrates the streaming capability of our chat interface built with @hanzo/ui components. The interface features:
|
| 85 |
+
|
| 86 |
+
• Real-time message streaming
|
| 87 |
+
• Markdown support for rich text formatting
|
| 88 |
+
• Code syntax highlighting
|
| 89 |
+
• Responsive design that works on all devices
|
| 90 |
+
• Dark/light theme support
|
| 91 |
+
|
| 92 |
+
The UI is built entirely with @hanzo/ui primitives like Card, Button, ScrollArea, and Avatar components, ensuring consistency with the Hanzo design system.`;
|
| 93 |
+
|
| 94 |
+
let currentText = "";
|
| 95 |
+
const words = response.split(" ");
|
| 96 |
+
|
| 97 |
+
for (let i = 0; i < words.length; i++) {
|
| 98 |
+
currentText += (i > 0 ? " " : "") + words[i];
|
| 99 |
+
await new Promise(resolve => setTimeout(resolve, 30));
|
| 100 |
+
|
| 101 |
+
setMessages(prev => prev.map(msg =>
|
| 102 |
+
msg.id === assistantMessage.id
|
| 103 |
+
? { ...msg, content: currentText }
|
| 104 |
+
: msg
|
| 105 |
+
));
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
setMessages(prev => prev.map(msg =>
|
| 109 |
+
msg.id === assistantMessage.id
|
| 110 |
+
? { ...msg, isStreaming: false }
|
| 111 |
+
: msg
|
| 112 |
+
));
|
| 113 |
+
|
| 114 |
+
setIsLoading(false);
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
return (
|
| 118 |
+
<div className="min-h-screen bg-background p-4">
|
| 119 |
+
<div className="max-w-4xl mx-auto">
|
| 120 |
+
<Card className="h-[80vh] flex flex-col">
|
| 121 |
+
<CardHeader className="border-b">
|
| 122 |
+
<div className="flex items-center justify-between">
|
| 123 |
+
<div className="flex items-center gap-2">
|
| 124 |
+
<div className="w-10 h-10 rounded-lg bg-gradient-to-br from-violet-500 to-purple-700 flex items-center justify-center">
|
| 125 |
+
<Sparkles className="w-6 h-6 text-white" />
|
| 126 |
+
</div>
|
| 127 |
+
<div>
|
| 128 |
+
<CardTitle>AI Chat Interface</CardTitle>
|
| 129 |
+
<CardDescription>Powered by @hanzo/ui components</CardDescription>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
<div className="flex items-center gap-2">
|
| 133 |
+
<Badge variant="outline">GPT-4</Badge>
|
| 134 |
+
<Button variant="ghost" size="icon">
|
| 135 |
+
<Settings className="w-4 h-4" />
|
| 136 |
+
</Button>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</CardHeader>
|
| 140 |
+
|
| 141 |
+
<ScrollArea className="flex-1 p-4">
|
| 142 |
+
<div className="space-y-4">
|
| 143 |
+
{messages.map((message) => (
|
| 144 |
+
<div
|
| 145 |
+
key={message.id}
|
| 146 |
+
className={cn(
|
| 147 |
+
"flex gap-3",
|
| 148 |
+
message.role === "user" ? "justify-end" : "justify-start"
|
| 149 |
+
)}
|
| 150 |
+
>
|
| 151 |
+
{message.role === "assistant" && (
|
| 152 |
+
<Avatar>
|
| 153 |
+
<AvatarFallback className="bg-violet-100">
|
| 154 |
+
<Bot className="w-5 h-5 text-violet-600" />
|
| 155 |
+
</AvatarFallback>
|
| 156 |
+
</Avatar>
|
| 157 |
+
)}
|
| 158 |
+
|
| 159 |
+
<Card className={cn(
|
| 160 |
+
"max-w-[70%]",
|
| 161 |
+
message.role === "user"
|
| 162 |
+
? "bg-gradient-to-r from-violet-500 to-purple-600 text-white"
|
| 163 |
+
: "bg-muted"
|
| 164 |
+
)}>
|
| 165 |
+
<CardContent className="p-3">
|
| 166 |
+
<p className="whitespace-pre-wrap">
|
| 167 |
+
{message.content}
|
| 168 |
+
{message.isStreaming && (
|
| 169 |
+
<span className="inline-block w-2 h-4 ml-1 bg-violet-500 animate-pulse" />
|
| 170 |
+
)}
|
| 171 |
+
</p>
|
| 172 |
+
<div className="flex items-center gap-2 mt-2">
|
| 173 |
+
<span className="text-xs opacity-60">
|
| 174 |
+
{message.timestamp.toLocaleTimeString()}
|
| 175 |
+
</span>
|
| 176 |
+
{message.role === "assistant" && !message.isStreaming && (
|
| 177 |
+
<div className="flex gap-1">
|
| 178 |
+
<Button variant="ghost" size="icon" className="h-6 w-6">
|
| 179 |
+
<Copy className="w-3 h-3" />
|
| 180 |
+
</Button>
|
| 181 |
+
<Button variant="ghost" size="icon" className="h-6 w-6">
|
| 182 |
+
<RefreshCw className="w-3 h-3" />
|
| 183 |
+
</Button>
|
| 184 |
+
</div>
|
| 185 |
+
)}
|
| 186 |
+
</div>
|
| 187 |
+
</CardContent>
|
| 188 |
+
</Card>
|
| 189 |
+
|
| 190 |
+
{message.role === "user" && (
|
| 191 |
+
<Avatar>
|
| 192 |
+
<AvatarFallback>
|
| 193 |
+
<User className="w-5 h-5" />
|
| 194 |
+
</AvatarFallback>
|
| 195 |
+
</Avatar>
|
| 196 |
+
)}
|
| 197 |
+
</div>
|
| 198 |
+
))}
|
| 199 |
+
<div ref={scrollRef} />
|
| 200 |
+
</div>
|
| 201 |
+
</ScrollArea>
|
| 202 |
+
|
| 203 |
+
<CardFooter className="border-t p-4">
|
| 204 |
+
<div className="flex gap-2 w-full">
|
| 205 |
+
<Textarea
|
| 206 |
+
placeholder="Type your message..."
|
| 207 |
+
value={input}
|
| 208 |
+
onChange={(e) => setInput(e.target.value)}
|
| 209 |
+
onKeyDown={(e) => {
|
| 210 |
+
if (e.key === "Enter" && !e.shiftKey) {
|
| 211 |
+
e.preventDefault();
|
| 212 |
+
handleSend();
|
| 213 |
+
}
|
| 214 |
+
}}
|
| 215 |
+
className="min-h-[50px] max-h-[150px]"
|
| 216 |
+
/>
|
| 217 |
+
<Button
|
| 218 |
+
onClick={handleSend}
|
| 219 |
+
disabled={isLoading || !input.trim()}
|
| 220 |
+
className="px-4"
|
| 221 |
+
>
|
| 222 |
+
{isLoading ? (
|
| 223 |
+
<Loader2 className="w-4 h-4 animate-spin" />
|
| 224 |
+
) : (
|
| 225 |
+
<Send className="w-4 h-4" />
|
| 226 |
+
)}
|
| 227 |
+
</Button>
|
| 228 |
+
</div>
|
| 229 |
+
</CardFooter>
|
| 230 |
+
</Card>
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
);
|
| 234 |
+
}
|
preview.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
<div class='p-8'><h1>Ai Chat Interface Preview</h1><p>Full template available on Hanzo Cloud</p></div>
|