Skip to content
docsv0.3.0

TuiNode

One node in the retained TUI tree — the TUI analog of an HTML element. `$type` selects which {@see \Milpa\Live\Contracts\Tui\TuiNodeRendererInterface} paints this node (see {@see \Milpa\Live\Contracts\Tui\TuiNodeRendererInterface::supports()}); `$props` is renderer- and layout-engine-defined (e.g. `'hidden'`, `'overlay'`, `'layer'`, `'width'`/`'height'`/`'flex'`, `'gap'`, `'padding'`) rather than a fixed schema, mirroring how HTML attributes are interpreted differently per element/CSS rule.

TuiNode::__construct()

public function __construct(string $id, string $type, array $props = [], array $children = [], bool $focusable = false):

Parameters

Parameters of __construct()
NameTypeDescription
$idstringUnique id within the tree; MUST NOT be empty.
$typestringThe node type, dispatched to a matching node renderer; MUST NOT be empty.
$propsarray<string, mixed>Renderer/layout-engine-defined properties.
$childrenarray<int, TuiNode>Child nodes, laid out according to `$props['layout']` (vertical by default).
$focusableboolWhether this node participates in keyboard focus rotation.

Throws

\InvalidArgumentException If `$id` or `$type` is empty, or if `$children` contains a non-{@see TuiNode} value.

TuiNode::hidden()

public function hidden(): bool

Whether the layout engine MUST exclude this node (and its subtree) from {@see \Milpa\Live\ValueObjects\Tui\TuiLayoutFrame}. Reads `props['hidden']`.

TuiNode::overlay()

public function overlay(): bool

Whether this node is positioned independently of normal document flow (e.g. centered/floating over its parent) rather than participating in the parent's vertical/horizontal allocation. Reads `props['overlay']`.

TuiNode::layer()

public function layer(): int

The paint-order layer this node belongs to; higher layers are painted on top of lower ones. Reads `props['layer']`, defaulting to `100` for {@see overlay()} nodes and `0` otherwise, so overlays sit above normal content without every overlay node having to set `layer` explicitly.