UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

26 lines (25 loc) 1.17 kB
import type { TreeNodeData } from '../Tree'; import type { TreeExpandedState } from '../use-tree'; export type FlatTreeLineState = 'continuing' | 'closing' | 'none'; export interface FlattenedTreeNodeData { /** Node data from tree data */ node: TreeNodeData; /** Nesting level of the node, starts at 1 */ level: number; /** Value of the parent node, `null` for root nodes */ parent: string | null; /** Whether the node has children */ hasChildren: boolean; /** Whether the node is expanded */ expanded: boolean; /** For each level from 2 to this node's `level`, indicates whether a connector * line should be drawn at that column for this row: * - `'continuing'`: full vertical line passes through this row * - `'closing'`: line ends at this row (truncated to the connector level) * - `'none'`: no line at this column for this row * * Index 0 corresponds to level 2, index 1 to level 3, etc. * Empty for level-1 (root) nodes. */ linesPath: FlatTreeLineState[]; } export declare function flattenTreeData(data: TreeNodeData[], expandedState: TreeExpandedState): FlattenedTreeNodeData[];