"use client" import { ChevronDown, ChevronRight } from "lucide-react" import type { Node } from "@/types/node" import { Button } from "@/components/ui/button" interface TreeNodeProps { node: Node selectedNodeId: string | null onNodeSelect: (node: Node, path: string[]) => void path: string[] expandedNodes: Set onToggleExpanded: (nodeId: string) => void } export function TreeNode({ node, selectedNodeId, onNodeSelect, path, expandedNodes, onToggleExpanded }: TreeNodeProps) { const hasChildren = node.children && node.children.length > 0 const isExpanded = expandedNodes.has(node.id) const isSelected = selectedNodeId === node.id const currentPath = [...path, node.type] return (
onNodeSelect(node, currentPath)} > {hasChildren ? ( ) : (
)} {node.type}
{hasChildren && isExpanded && (
{node.children!.map((child) => ( ))}
)}
) }