mwg API
    Preparing search index...

    Class TreeView<T>

    A collapsible tree, flattened to the rows a game draws - a skill tree, a nested options menu, a directory of scenarios grouped by campaign.

    Renderer-free, like TabbedList. The visible rows are derived from the roots and the set of expanded ids every time they are asked for, rather than kept in a parallel list that could go stale. Two rules are worth naming: collapsing a branch that contains the highlight moves the highlight to the branch itself, and move only ever walks the rows actually on screen, so a collapsed child is unreachable without expanding it first.

    import { TreeView } from '@datamoc/mw_games/two-d/ui';

    const tree = new TreeView({
    roots: [{ id: 'a', label: 'A', children: [{ id: 'a1', label: 'A1' }] }],
    });
    tree.expand('a');
    console.log(tree.rows.map((row) => row.node.id)); // ['a', 'a1']

    Type Parameters

    • T = unknown
    Index
    onChange: Signal<void> = ...
    • moves the highlight a visible row at a time, skipping disabled rows and stopping at the ends

      Parameters

      • delta: number

      Returns void