Skip to content
docsv0.3.0

ComponentTuiNodeRenderer

The bridge between the retained TUI tree (layout engine, overlays, {@see \Milpa\Live\Tui\VirtualTerminalBuffer} diffing) and the real component render path -- the same {@see ComponentRendererInterface} seam the HTML renderers use, resolved here for {@see RenderTarget::TUI}. Before this class existed, the retained tree could only host decorative node types (panel/status-bar/job-monitor/...); this makes 'component' a node type that renders an actual autocomplete/data-table/form-field/ dashboard-primitive component, painted by whichever ComponentRendererInterface the caller wires in (today: TuiComponentRenderer). Deliberately stateless: a node's props carry the component name, its props, and its already-mounted {@see StateSnapshot} (or null to mount fresh). Owning/caching that state across frames is the job of whatever builds the TuiNode tree each frame (mirroring how every other TuiNodeRendererInterface implementation in this codebase is a pure node-in/frame-out mapping, and how {@see \Milpa\Live\Tui\TuiComponentInstance} already owns state for the legacy loop) -- not this renderer's concern. Caveat for tree-builders: {@see \Milpa\Live\Rendering\TuiComponentRenderer} clamps its own render width to a floor of 40 columns regardless of what is requested. Give a 'component' node bounds narrower than that and the component will render wider than its allotted space; TuiFrameFactory then right-truncates every line to fit, which silently mangles box borders instead of failing loudly. Size 'component' node widths to >= 40 (directly, or via enough flex share of the parent).

ComponentTuiNodeRenderer::__construct()

public function __construct(Milpa\Live\Contracts\Component\ComponentRegistryInterface $components, Milpa\Live\Contracts\Rendering\ComponentRendererInterface $componentRenderer):

Parameters

Parameters of __construct()
NameTypeDescription
$componentsMilpa\Live\Contracts\Component\ComponentRegistryInterface
$componentRendererMilpa\Live\Contracts\Rendering\ComponentRendererInterface

ComponentTuiNodeRenderer::supports()

public function supports(Milpa\Live\ValueObjects\Tui\TuiNode $node): bool

Matches nodes of type `'component'`.

Parameters

Parameters of supports()
NameTypeDescription
$nodeMilpa\Live\ValueObjects\Tui\TuiNode

ComponentTuiNodeRenderer::render()

public function render(Milpa\Live\ValueObjects\Tui\TuiNode $node, Milpa\Live\ValueObjects\Tui\TuiRenderContext $context): Milpa\Live\ValueObjects\Tui\TuiFrame

Renders the named component (from `$node->props['component']`) through the injected {@see ComponentRendererInterface} and adapts its text output into a {@see TuiFrame} sized to `$context->bounds`. See the class docblock's caveat: bounds narrower than 40 columns cause silent right-truncation of the component's own output rather than a loud failure.

Parameters

Parameters of render()
NameTypeDescription
$nodeMilpa\Live\ValueObjects\Tui\TuiNode
$contextMilpa\Live\ValueObjects\Tui\TuiRenderContext

Throws

\InvalidArgumentException If the node has no `props['component']` name, or `props['state']` is set but is not a {@see StateSnapshot}.

\RuntimeException If the injected renderer does not support {@see RenderTarget::TUI}.