import type { ReactNode } from 'react'; /** * A node in the tree hierarchy. * Represents one item that can be checked, expanded, disabled, or nested. */ export interface TreeNode { /** Unique identifier within the tree */ id: string; /** Visible text label */ label: string; /** Selection state */ checked: boolean; /** * Whether the node is interactive (system-controlled). * Disabled nodes cannot be toggled and retain their state during cascade. * @default false */ disabled?: boolean; /** Optional icon rendered before the label */ icon?: ReactNode; /** * Child nodes. * Empty array or undefined indicates a leaf node. */ children?: TreeNode[]; /** Arbitrary payload for consumer use */ data?: T; } /** * Event payload emitted by onChange after a successful state change. */ export interface TreeChangeEvent { /** The node the user directly interacted with */ source: TreeNode; /** All nodes that changed state (source + cascade) */ affected: TreeNode[]; /** The new checked state of the source node */ checked: boolean; } /** * Imperative ref handle exposed via forwardRef. * Allows parent components to inspect tree state programmatically. */ export interface TreeRef { /** All nodes with current state (flat) */ getAll(): TreeNode[]; /** Only checked nodes (flat) */ getChecked(): TreeNode[]; /** Only disabled nodes (flat) */ getDisabled(): TreeNode[]; /** Nodes changed since initial mount */ getModified(): TreeNode[]; /** Run validation over all nodes */ validate(fn: (node: TreeNode) => boolean): TreeValidationResult; } /** * Result of the validate() imperative method. */ export interface TreeValidationResult { /** Whether all nodes passed validation */ valid: boolean; /** Nodes that failed the validation function */ failures: TreeNode[]; } /** * Props for the Tree component. */ export interface TreeProps { /** Array of root nodes */ nodes: TreeNode[]; /** * Read-only mode — absolute priority over all interaction. * @default false */ readOnly?: boolean; /** Callback after every successful state change */ onChange?: (event: TreeChangeEvent) => void; /** * Intercept check/uncheck — return false to cancel. * Synchronous only. All-or-nothing: if rejected, zero state change. */ beforeCheck?: (node: TreeNode, nextChecked: boolean) => boolean; /** * Default expand state for all branches. * @default false */ defaultExpanded?: boolean; /** Specific node IDs to expand initially */ expandedIds?: string[]; /** * Show child count badge on branches. * @default false */ showBadge?: boolean; /** * Show dividers between root nodes. * @default false */ showDividers?: boolean; /** ARIA label for the tree container */ ariaLabel?: string; /** Additional CSS classes */ className?: string; /** * Interaction mode. MVP supports 'checkbox' only. * @default 'checkbox' */ mode?: 'checkbox'; } //# sourceMappingURL=Tree.types.d.ts.map