import * as React from "react" import { cva, type VariantProps } from "class-variance-authority" import { Slot } from "radix-ui" import { cn } from "../../lib/utils" import { Button } from "./button" const attachmentVariants = cva( "group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border border-border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed", { variants: { size: { default: "gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2", sm: "gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5", xs: "gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1", }, orientation: { horizontal: "min-w-40 items-center", // Match shadcn image cards — full media fills a ~9rem chip (not the sm 32px icon slot). vertical: "w-36 flex-col has-data-[slot=attachment-content]:w-36", }, }, }, ) export type AttachmentState = | "idle" | "uploading" | "processing" | "error" | "done" function Attachment({ className, state = "done", size = "default", orientation = "horizontal", ...props }: React.ComponentProps<"div"> & VariantProps & { state?: AttachmentState }) { return (
) } const attachmentMediaVariants = cva( [ "relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground", // Vertical media fills the card. Size scale only shrinks horizontal icon chips — // otherwise `size=sm` overrides `w-full` and image thumbs collapse to 32px. "group-data-[orientation=vertical]/attachment:w-full", "group-data-[orientation=horizontal]/attachment:group-data-[size=sm]/attachment:w-8", "group-data-[orientation=horizontal]/attachment:group-data-[size=xs]/attachment:w-7", "group-data-[size=xs]/attachment:rounded-md", "group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive-ink", "[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", "group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6", "group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5", "[&_i]:pointer-events-none [&_i]:leading-none [&_i]:text-base", "group-data-[orientation=vertical]/attachment:[&_i]:text-xl", "group-data-[size=xs]/attachment:[&_i]:text-sm", ].join(" "), { variants: { variant: { icon: "", image: "opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:size-full *:[img]:object-cover", }, }, defaultVariants: { variant: "icon", }, }, ) function AttachmentMedia({ className, variant = "icon", ...props }: React.ComponentProps<"div"> & VariantProps) { return (
) } function AttachmentContent({ className, ...props }: React.ComponentProps<"div">) { return (
) } function AttachmentTitle({ className, ...props }: React.ComponentProps<"span">) { return ( ) } function AttachmentDescription({ className, ...props }: React.ComponentProps<"span">) { return ( ) } function AttachmentActions({ className, ...props }: React.ComponentProps<"div">) { return (
) } function AttachmentAction({ className, variant, size = "icon-xs", ...props }: React.ComponentProps) { return (