'use client'; import * as React from 'react'; import { AnimatePresence, type HTMLMotionProps, motion } from 'motion/react'; import { FileIcon, FolderIcon, FolderOpenIcon } from 'lucide-react'; import { cn } from '@workspace/ui/lib/utils'; import { Accordion, AccordionContent, AccordionItem, AccordionItemProps, AccordionTrigger, AccordionTriggerProps, useAccordionItem, } from '@/registry/radix/accordion'; import { MotionHighlight, MotionHighlightItem, } from '@/registry/effects/motion-highlight'; interface FileButtonProps extends HTMLMotionProps<'div'> { icons?: { close: React.ReactNode; open: React.ReactNode; }; icon?: React.ReactNode; open?: boolean; layoutId?: string; } const FileButton = React.forwardRef( ({ children, icons, icon, open, layoutId, ...props }, ref) => { return ( {icon ? typeof icon !== 'string' ? icon : null : icons && ( {open ? typeof icons.open !== 'string' ? icons.open : null : typeof icons.close !== 'string' ? icons.close : null} )} {children} ); }, ); FileButton.displayName = 'FileButton'; type FilesProps = React.HTMLAttributes & { defaultOpen?: string[]; open?: string[]; onOpenChange?: (open: string[]) => void; }; const Files = React.forwardRef( ({ children, className, defaultOpen, open, onOpenChange, ...props }, ref) => { return (
{children}
); }, ); Files.displayName = 'Files'; type FolderTriggerProps = AccordionTriggerProps & { layoutId?: string; }; const FolderTrigger = React.forwardRef( ({ children, layoutId, ...props }, ref) => { const { isOpen } = useAccordionItem(); return ( , close: }} layoutId={layoutId} > {children} ); }, ); FolderTrigger.displayName = 'FolderTrigger'; type FolderProps = Omit & { name: string; open?: string[]; onOpenChange?: (open: string[]) => void; defaultOpen?: string[]; layoutId?: string; }; const Folder = React.forwardRef( ( { children, name, open, defaultOpen, onOpenChange, layoutId, ...props }, ref, ) => ( {name} {children} ), ); Folder.displayName = 'Folder'; type FileProps = Omit, 'children'> & { name: string; layoutId?: string; }; const File = React.forwardRef( ({ name, layoutId, ...props }, ref) => ( } layoutId={layoutId} {...props}> {name} ), ); File.displayName = 'File'; export { Files, Folder, File };