Pular para o conteúdo principal

API Reference

Core: TreeNode<TMetadata>​

interface TreeNode<TMetadata = unknown> {
id: string;
name: string;
order?: number;
children?: TreeNode<TMetadata>[];
metadata?: TMetadata;
}

Adapters​

buildOpenApiTree(document, options?)​

Builds an OpenAPI navigation tree.

OptionTypeDefaultDescription
showInternalbooleanfalseHide x-internal operations
showComponentsbooleantrueShow components section
showWebhooksbooleantrueShow webhooks
defaultExpandDepthnumber2Default expansion depth

Navigation priority: OAS 3.2 native nested tags → x-tagGroups → flat tags.

buildSchemaTree(schema, options?)​

OptionTypeDefaultDescription
maxDepthnumber8Max nesting depth
showDeprecatedbooleantrueShow deprecated properties
expandCombinatorsbooleantrueExpand oneOf/anyOf/allOf
showArrayItemsbooleantrueExpand array items

buildDocTree(document, options?)​

Stripe-style documentation tree where each operation expands to show parameters, request body, and responses.

React <Tree /> Component​

Key props​

PropTypeDefaultDescription
nodesTreeNode[]requiredRoot nodes to render
onSelect(node) => void—Called when a node is selected
searchablebooleanfalseShow search input
defaultExpandDepthnumber1Initial expansion depth
showExpandAllbooleanfalseExpand/collapse all toggle
draggablebooleanfalseEnable drag-and-drop reordering
onReorder(result: ReorderResult) => void—Called on reorder within same parent
onMove(nodes, movedNode, targetParentId) => void—Called on cross-level move
canDrag(node) => boolean—Control which nodes can be dragged
canDrop(dragged, target, position) => boolean—Control allowed drop targets
contextMenuItems(node) => ContextMenuItem[]—Right-click menu items
onPatch(ops, context) => void—RFC 6902 patch ops on reorder
maxHeightnumber | string—Max height before scrolling
size"xs" | "sm" | "md""sm"Size variant

Imperative handle (via ref)​

MethodDescription
expandAll()Expand all nodes
collapseAll()Collapse all nodes
expandToDepth(depth)Expand to a specific depth
getExpandedIds()Get currently expanded node IDs
getSelectedNode()Get the currently selected node
scrollToNode(id)Scroll a node into view
locateNode(predicate)Find a node, expand ancestors, select, and scroll into view

Core utilities​

FunctionDescription
findNode(nodes, id)Find a node by ID
findPath(nodes, id)Find full path from root
getLeaves(nodes)Get all leaf nodes
countNodes(nodes)Count all nodes
filterTree(nodes, { query })Filter by search query
flattenTree(nodes)Flatten to pre-order list
updateNode(nodes, id, updater)Immutable node update
removeNode(nodes, id)Immutable node removal