import { useState } from 'react'; import { Icon } from '@iconify/react'; import type { ObjectTreeNode } from '@tts/extract'; import { iconsForObject } from './objectIcons'; interface Props { nodes: ObjectTreeNode[]; selectedPath: string | null; onSelect: (path: string) => void; } export default function ObjectTree({ nodes, selectedPath, onSelect }: Props) { return ( ); } function TreeNode({ node, depth, path, selectedPath, onSelect, }: { node: ObjectTreeNode; depth: number; /** Index path from the root, used as a stable unique key and selection id. */ path: string; selectedPath: string | null; onSelect: (path: string) => void; }) { // Selection is keyed by the node's unique index path, not its GUID: cards in // a deck frequently share a GUID (the deck's), so GUID-based selection would // highlight and render the wrong card. const selected = path === selectedPath; const hasChildren = node.children.length > 0; const [expanded, setExpanded] = useState(false); return (
  • {hasChildren ? ( ) : ( )}
    {hasChildren && expanded && ( )}
  • ); }