import { useState } from "react"; import { createRoot } from "react-dom/client"; import { Tree } from "../src/ui/Tree"; interface Node { key: string; label: string; children?: Node[]; } const longLabel = `z_${"long_file_name_".repeat(16)}.ts`; const initial: Node[] = [ { key: "src", label: "src", children: [{ key: "child", label: "child.ts" }] }, ...Array.from({ length: 160 }, (_, i) => ({ key: `file-${i}`, label: `file_${i}.ts` })), { key: "wide", label: longLabel }, ]; const shorten = (nodes: Node[]): Node[] => nodes.map((node) => ({ ...node, label: node.key === "wide" ? "short.ts" : node.label, children: node.children ? shorten(node.children) : undefined, })); const getKey = (node: Node) => node.key; const getLabel = (node: Node) => node.label; const getChildren = (node: Node) => node.children; const isExpandable = (node: Node) => !!node.children; function Fixture() { const [roots, setRoots] = useState(initial); const [width, setWidth] = useState(240); const [font, setFont] = useState(14); const [indent, setIndent] = useState(16); const [hidden, setHidden] = useState(false); const [horizontal, setHorizontal] = useState(true); return ( <>