"use client"
import * as React from "react"
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentDescription,
AttachmentGroup,
AttachmentMedia,
AttachmentTitle,
AttachmentTrigger,
type AttachmentState,
} from "@/components/ui/attachment"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
function FileIcon({ kind }: { kind?: "pdf" | "code" | "zip" | "sheet" | "image" | "generic" }) {
const cls =
kind === "pdf"
? "fa-light fa-file-pdf"
: kind === "code"
? "fa-light fa-file-code"
: kind === "zip"
? "fa-light fa-file-zipper"
: kind === "sheet"
? "fa-light fa-file-spreadsheet"
: kind === "image"
? "fa-light fa-image"
: "fa-light fa-file"
return
}
function RemoveAction({ name }: { name: string }) {
return (
)
}
export function AttachmentBasicPreview() {
return (
sales-dashboard.pdf
PDF · 2.4 MB
message-renderer.tsx
TypeScript · 12 KB
)
}
const STATE_ROWS: {
state: AttachmentState
title: string
description: string
icon: React.ReactNode
}[] = [
{
state: "idle",
title: "selected-file.pdf",
description: "Ready to upload",
icon: ,
},
{
state: "uploading",
title: "design-system.zip",
description: "Uploading · 64%",
icon: ,
},
{
state: "processing",
title: "market-research.pdf",
description: "Processing document",
icon: ,
},
{
state: "error",
title: "financial-model.xlsx",
description: "Upload failed. Try again.",
icon: ,
},
{
state: "done",
title: "uploaded-report.pdf",
description: "Uploaded · 1.8 MB",
icon: ,
},
]
export function AttachmentStatesPreview() {
return (
{STATE_ROWS.map(row => (
{row.icon}
{row.title}
{row.description}
))}
)
}
export function AttachmentImagePreview() {
return (
{[
{ name: "workspace.png", meta: "PNG · 820 KB", src: "https://picsum.photos/seed/exxat-a/240/240" },
{ name: "desk-reference.jpg", meta: "JPG · 1.1 MB", src: "https://picsum.photos/seed/exxat-b/240/240" },
{ name: "office-reference.jpg", meta: "JPG · 940 KB", src: "https://picsum.photos/seed/exxat-c/240/240" },
].map(item => (
{item.name}
{item.meta}
))}
)
}
/** Document files using `AttachmentMedia variant="image"` for page/thumbnail previews. */
export function AttachmentDocumentImagePreview() {
return (
{[
{
name: "placement-handbook.pdf",
meta: "PDF · 2.1 MB",
src: "https://picsum.photos/seed/exxat-doc-a/240/240",
},
{
name: "compliance-checklist.pdf",
meta: "PDF · 640 KB",
src: "https://picsum.photos/seed/exxat-doc-b/240/240",
},
{
name: "site-agreement.docx",
meta: "DOCX · 180 KB",
src: "https://picsum.photos/seed/exxat-doc-c/240/240",
},
].map(item => (
{item.name}
{item.meta}
))}
rotation-schedule.pdf
PDF · 410 KB
background-check.pdf
Uploading · 42%
)
}
export function AttachmentSizesPreview() {
return (
{(["default", "sm", "xs"] as const).map(size => (
{size === "default" ? "Default" : size === "sm" ? "Small" : "Extra small"} attachment
{size !== "xs" ? (
PDF · 2.4 MB
) : null}
))}
)
}
const GROUP_ITEMS = [
{ name: "briefing-notes.pdf", meta: "PDF · 1.4 MB", kind: "pdf" as const },
{ name: "workspace.png", meta: "PNG · 820 KB", kind: "image" as const },
{ name: "customers.csv", meta: "CSV · 18 KB", kind: "sheet" as const },
{ name: "renderer.tsx", meta: "TSX · 12 KB", kind: "code" as const },
]
export function AttachmentGroupPreview() {
return (
{GROUP_ITEMS.map(item => (
{item.name}
{item.meta}
))}
)
}
export function AttachmentTriggerPreview() {
return (
)
}