{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "attachment",
  "title": "Attachment",
  "description": "File attachment chip with name, size and remove action, for chat and forms.",
  "dependencies": [
    "@base-ui/react@^1.8.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://rdf.dev.360online.com/r/button.json"
  ],
  "files": [
    {
      "path": "registry/rapid/ui/attachment/attachment.tsx",
      "content": "import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport type * as React from 'react'\nimport { Button } from '@/components/ui/button'\nimport { cn } from '@/lib/utils'\n\nconst attachmentVariants = cva(\n\t'group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-2 focus-within:ring-ring has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive-border data-[state=idle]:border-dashed',\n\t{\n\t\tvariants: {\n\t\t\tsize: {\n\t\t\t\tdefault:\n\t\t\t\t\t'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',\n\t\t\t\tsm: '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',\n\t\t\t\txs: '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',\n\t\t\t},\n\t\t\torientation: {\n\t\t\t\thorizontal: 'min-w-40 items-center',\n\t\t\t\tvertical: 'w-24 flex-col has-data-[slot=attachment-content]:w-30',\n\t\t\t},\n\t\t},\n\t},\n)\n\nfunction Attachment({\n\tclassName,\n\tstate = 'done',\n\tsize = 'default',\n\torientation = 'horizontal',\n\t...props\n}: React.ComponentProps<'div'> &\n\tVariantProps<typeof attachmentVariants> & {\n\t\tstate?: 'idle' | 'uploading' | 'processing' | 'error' | 'done'\n\t}) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"attachment\"\n\t\t\tdata-state={state}\n\t\t\tdata-size={size}\n\t\t\tdata-orientation={orientation}\n\t\t\tclassName={cn(attachmentVariants({ size, orientation }), className)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nconst attachmentMediaVariants = cva(\n\t\"relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive-subtle group-data-[state=error]/attachment:text-destructive-subtle-foreground group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_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\",\n\t{\n\t\tvariants: {\n\t\t\tvariant: {\n\t\t\t\ticon: '',\n\t\t\t\timage:\n\t\t\t\t\t'opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover',\n\t\t\t},\n\t\t},\n\t\tdefaultVariants: {\n\t\t\tvariant: 'icon',\n\t\t},\n\t},\n)\n\nfunction AttachmentMedia({\n\tclassName,\n\tvariant = 'icon',\n\t...props\n}: React.ComponentProps<'div'> & VariantProps<typeof attachmentMediaVariants>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"attachment-media\"\n\t\t\tdata-variant={variant}\n\t\t\tclassName={cn(attachmentMediaVariants({ variant }), className)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction AttachmentContent({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"attachment-content\"\n\t\t\tclassName={cn(\n\t\t\t\t'max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction AttachmentTitle({ className, ...props }: React.ComponentProps<'span'>) {\n\treturn (\n\t\t<span\n\t\t\tdata-slot=\"attachment-title\"\n\t\t\tclassName={cn(\n\t\t\t\t'block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction AttachmentDescription({ className, ...props }: React.ComponentProps<'span'>) {\n\treturn (\n\t\t<span\n\t\t\tdata-slot=\"attachment-description\"\n\t\t\tclassName={cn(\n\t\t\t\t'mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive-subtle-foreground',\n\t\t\t\t'max-w-full',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction AttachmentActions({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"attachment-actions\"\n\t\t\tclassName={cn(\n\t\t\t\t'relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nfunction AttachmentAction({ className, variant, size = 'icon-xs', ...props }: React.ComponentProps<typeof Button>) {\n\treturn (\n\t\t<Button data-slot=\"attachment-action\" variant={variant ?? 'ghost'} size={size} className={cn(className)} {...props} />\n\t)\n}\n\nfunction AttachmentTrigger({ className, render, type, ...props }: useRender.ComponentProps<'button'>) {\n\treturn useRender({\n\t\tdefaultTagName: 'button',\n\t\tprops: mergeProps<'button'>(\n\t\t\t{\n\t\t\t\ttype: render ? type : (type ?? 'button'),\n\t\t\t\tclassName: cn('absolute inset-0 z-10 outline-none', className),\n\t\t\t},\n\t\t\tprops,\n\t\t),\n\t\trender,\n\t\tstate: {\n\t\t\tslot: 'attachment-trigger',\n\t\t},\n\t})\n}\n\nfunction AttachmentGroup({ className, ...props }: React.ComponentProps<'div'>) {\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"attachment-group\"\n\t\t\tclassName={cn(\n\t\t\t\t'flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 scrollbar-none gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start',\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n\nexport {\n\tAttachment,\n\tAttachmentGroup,\n\tAttachmentMedia,\n\tAttachmentContent,\n\tAttachmentTitle,\n\tAttachmentDescription,\n\tAttachmentActions,\n\tAttachmentAction,\n\tAttachmentTrigger,\n}\n",
      "type": "registry:ui",
      "target": "components/ui/attachment.tsx"
    }
  ],
  "meta": {
    "new": true
  },
  "type": "registry:ui"
}