import type { ComponentPropsWithRef } from 'react' import { IconLoader2, IconX, type Icon } from '@tabler/icons-react' import { Button } from '@/client/components/ui/button' import { cn } from '@/client/lib/cn' type AttachmentChipProps = ComponentPropsWithRef<'div'> & { label: string icon: Icon onRemove?: () => void previewUrl?: string loading?: boolean } // Two layouts share one frame: a labelled chip or an image thumbnail. // Upload status is an overlay; it doesn't introduce another layout. export function AttachmentChip({ label, icon, onRemove, previewUrl, loading, className, children, ...props }: AttachmentChipProps) { return (
{loading && (
)} {previewUrl ? ( ) : ( )} {children}
) } type LabelChipContentProps = Pick function LabelChipContent({ label, icon: IconComponent, onRemove }: LabelChipContentProps) { return ( <> {onRemove ? ( ) : ( )} {label} ) } type ImageChipContentProps = Pick & { previewUrl: string } function ImageChipContent({ label, previewUrl, onRemove }: ImageChipContentProps) { return ( <> {label} {onRemove && ( )} ) }