Raxol. UI. Components. Display. Tree
(Raxol v2.6.0)
View Source
A tree view component with expand/collapse and keyboard navigation.
Displays hierarchical data as an indented tree. Nodes can be expanded and collapsed. The cursor tracks the currently selected visible node.
Node data format:
%{id: atom, label: string, children: [node], data: any}Keyboard bindings:
- Up/Down: move cursor through visible nodes
- Right: expand collapsed node (if it has children)
- Left: collapse expanded node, or move to parent
- Enter/Space: toggle expand/collapse; fire on_select for leaf nodes
- Home/End: jump to first/last visible node
Summary
Functions
Recursively searches for a node by id in the tree.
Finds the parent of a node by id. Returns nil if the node is a root or not found.
Callback implementation for Raxol.UI.Components.Base.Component.mount/1.
Callback implementation for Raxol.UI.Components.Base.Component.unmount/1.
Callback implementation for Raxol.UI.Components.Base.Component.update/2.
Returns a flat list of {node, depth} tuples for all currently visible nodes,
respecting the expanded set. Children of collapsed nodes are omitted.
Types
@type t() :: %{ id: String.t() | atom(), nodes: [tree_node()], expanded: MapSet.t(), cursor: atom() | nil, focused: boolean(), indent_size: non_neg_integer(), on_select: (atom(), any() -> any()) | nil, on_expand: (atom() -> any()) | nil, on_collapse: (atom() -> any()) | nil, style: map(), theme: map() }
Functions
Recursively searches for a node by id in the tree.
Finds the parent of a node by id. Returns nil if the node is a root or not found.
Callback implementation for Raxol.UI.Components.Base.Component.mount/1.
Callback implementation for Raxol.UI.Components.Base.Component.unmount/1.
Callback implementation for Raxol.UI.Components.Base.Component.update/2.
@spec visible_nodes(t()) :: [{tree_node(), non_neg_integer()}]
Returns a flat list of {node, depth} tuples for all currently visible nodes,
respecting the expanded set. Children of collapsed nodes are omitted.