import "./components/ui/tidal.css"; import { useMemo, useState } from "react"; import { TidalTreeView, type TidalTreeNode } from "./components/ui/tree-view"; import "./components/ui/tree-view.css"; const tidalExampleStyles = ".tree-demo {\n display: grid;\n width: 100%;\n max-width: 620px;\n min-width: 0;\n gap: 12px;\n}\n\n.tree-demo-detail {\n display: grid;\n min-width: 0;\n gap: 3px;\n border: 1px solid var(--t-border);\n border-radius: 14px;\n padding: 12px 14px;\n background: var(--t-subtle);\n}\n\n.tree-demo-detail > span,\n.tree-demo-note {\n color: var(--t-muted);\n font-size: 11px;\n line-height: 1.45;\n}\n\n.tree-demo-detail strong {\n min-width: 0;\n font-size: 13px;\n line-height: 1.35;\n overflow-wrap: anywhere;\n}\n\n.tree-demo-detail p,\n.tree-demo-note {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.tree-demo-detail p {\n font-size: 12px;\n line-height: 1.45;\n}\n\n.tree-demo-note {\n padding-inline: 4px;\n}\n\n@media (max-width: 390px) {\n .tree-demo {\n gap: 10px;\n }\n\n .tree-demo-detail {\n padding: 10px 12px;\n }\n}"; function FolderIcon() { return ( ); } function FileIcon() { return ( ); } export function TreeViewDemo() { const [expandedIds, setExpandedIds] = useState([ "product", "research", ]); const [selectedId, setSelectedId] = useState("launch"); const [status, setStatus] = useState("Launch checklist selected."); const nodes = useMemo( () => [ { id: "product", label: "Product", textValue: "Product", description: "Planning and release work", icon: , children: [ { id: "roadmap", label: "Roadmap", textValue: "Roadmap", description: "Quarterly priorities", icon: , }, { id: "launch", label: "Launch checklist", textValue: "Launch checklist", description: "12 of 16 items complete", icon: , }, ], }, { id: "research", label: "Research", textValue: "Research", description: "Notes from recent interviews", icon: , children: [ { id: "interviews", label: "Interview notes", textValue: "Interview notes", description: "Six fictional local entries", icon: , }, { id: "themes", label: "Themes", textValue: "Themes", description: "Grouped observations", icon: , }, ], }, { id: "archive", label: "Archive", textValue: "Archive", description: "Older sample material", icon: , lazyState: "Archived items are not included in this local sample.", }, ], [], ); const selectedNode = useMemo(() => { const queue = [...nodes]; while (queue.length) { const node = queue.shift(); if (!node) continue; if (node.id === selectedId) return node; if (node.children) queue.push(...node.children); } return null; }, [nodes, selectedId]); return (
setExpandedIds(nextIds)} onSelectedChange={(nextId, node) => { setSelectedId(nextId); setStatus(`${node.textValue} selected.`); }} />
Selected resource {selectedNode?.label ?? "Nothing selected"}

{status}

This sample changes local selection and expansion only.

); } export default function AgentExample() { return (
); }