import type { ReactNode, MouseEvent } from "react"; import type { NodeRendererProps, NodeApi, TreeApi } from "react-arborist"; export interface TreeNodeData { /** Unique key for the node (must be unique across entire tree) */ key: string; /** Display title for the node */ title: ReactNode; /** Child nodes */ children?: TreeNodeData[]; /** Whether the node is disabled */ disabled?: boolean; /** Whether the node can be selected */ selectable?: boolean; /** Whether the node is a leaf (hides expand icon) */ isLeaf?: boolean; } export interface CheckedKeys { checked: string[]; halfChecked: string[]; } export interface TreeProps { /** Tree data array */ treeData: TreeNodeData[]; /** Whether nodes can be selected */ selectable?: boolean; /** Controlled selected node keys */ selectedKeys?: string[]; /** Default selected node keys (uncontrolled) */ defaultSelectedKeys?: string[]; /** Allow multiple node selection */ multiple?: boolean; /** Called when selection changes */ onSelect?: (keys: string[], info: { node: TreeNodeData; }) => void; /** Controlled expanded node keys */ expandedKeys?: string[]; /** Default expanded node keys (uncontrolled) */ defaultExpandedKeys?: string[]; /** Auto-expand parent when child is expanded */ autoExpandParent?: boolean; /** Called when expansion changes */ onExpand?: (keys: string[], info: { expanded: boolean; node: TreeNodeData; }) => void; /** Show checkboxes before nodes */ checkable?: boolean; /** Controlled checked node keys */ checkedKeys?: string[] | CheckedKeys; /** Default checked node keys (uncontrolled) */ defaultCheckedKeys?: string[]; /** Decouple parent/child checkbox state */ checkStrictly?: boolean; /** Called when check state changes */ onCheck?: (keys: string[] | CheckedKeys, info: { checked: boolean; node: TreeNodeData; }) => void; /** Enable drag and drop */ draggable?: boolean; /** Allow dropping on nodes */ allowDrop?: boolean; /** Called when a node is moved via DnD */ onMove?: (info: { dragIds: string[]; parentId: string | null; index: number; }) => void; /** Customize node title rendering */ titleRender?: (nodeData: TreeNodeData) => ReactNode; /** Full custom node renderer (takes precedence over titleRender) */ renderNode?: (props: NodeRendererProps) => ReactNode; /** Custom expand/collapse icon */ switcherIcon?: ReactNode | ((props: { expanded: boolean; }) => ReactNode); /** Highlight function: returns true to add highlight class */ filterTreeNode?: (node: TreeNodeData) => boolean; /** Async data loading on expand */ loadData?: (nodeData: TreeNodeData) => Promise; /** Keys of nodes whose children have been loaded */ loadedKeys?: string[]; /** Called when a node finishes loading */ onLoad?: (loadedKeys: string[], info: { node: TreeNodeData; }) => void; /** Show connecting lines between nodes */ showLine?: boolean; /** Nodes fill remaining horizontal space */ blockNode?: boolean; /** Tree height in px (enables virtual scroll) */ height?: number; /** Enable virtual scrolling (default true when height is set) */ virtual?: boolean; /** Disable the entire tree */ disabled?: boolean; /** Right-click handler */ onRightClick?: (info: { event: MouseEvent; node: TreeNodeData; }) => void; /** Additional CSS class */ className?: string; /** Row height in px for virtual scroll */ rowHeight?: number; /** Indent per level in px */ indent?: number; } export type { NodeRendererProps, NodeApi, TreeApi };