import { useState } from 'react'; import { DocTreeNode } from '../api'; interface Props { nodes: DocTreeNode[]; currentPath: string; onSelect: (path: string) => void; onCreate: (parentPath: string) => void; depth?: number; } export function DocTree({ nodes, currentPath, onSelect, onCreate, depth = 0 }: Props) { return (
0 ? 16 : 0 }}> {nodes.map(node => ( ))}
); } function TreeNode({ node, currentPath, onSelect, onCreate, depth, }: { node: DocTreeNode; currentPath: string; onSelect: (path: string) => void; onCreate: (parentPath: string) => void; depth: number; }) { const [expanded, setExpanded] = useState(depth < 2); const isActive = node.path === currentPath; if (node.type === 'folder') { return (
setExpanded(!expanded)} > {expanded ? '📂' : '📁'} {node.name}
{expanded && node.children && ( )}
); } return (
onSelect(node.path)} > 📄 {node.name}
); }