import { useState } from "react"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { ChevronRight, ChevronDown, FileText, Folder } from "lucide-react"; import filesToTree, { type TreeWithFullPath } from "@/lib/tree"; import Link from "next/link"; function countItems(item: TreeWithFullPath): number { let count = 0; for (const value of Object.values(item)) { if (typeof value === "string") { count++; } else { count += countItems(value); } } return count; } function Tree({ item, os, depth, expandAll, }: { item: TreeWithFullPath; os: string; depth: number; expandAll: boolean; }) { return ( ); } function TreeFolder({ name, item, os, depth, expandAll, }: { name: string; item: TreeWithFullPath; os: string; depth: number; expandAll: boolean; }) { const [open, setOpen] = useState(expandAll || depth < 1); const itemCount = countItems(item); return (
  • {open ? ( ) : ( )} {name} {itemCount}
  • ); } export default function FileSystem({ list, os, expandAll = false, }: { list: string[]; os: string; expandAll?: boolean; }) { const tree = filesToTree(list); return (
    ); }