args
Shared argument resolver for zui container builders (`panel`, `vbox`, `hbox`, `grid`, …). Container builders historically took `(children, opts)` with children first, but the intuitive call is a single options table `Z.panel({ style = …, children = {…} })`. Passed to a `(children…
args
Shared argument resolver for zui container builders (panel, vbox, hbox, grid, …). Container builders historically took (children, opts) with children first, but the intuitive call is a single options table Z.panel({ style = …, children = {…} }). Passed to a (children, opts) builder, that table landed in the children slot and its children key was silently dropped. resolve removes that pit: it accepts every unambiguous shape and routes it correctly, and raises a precise error when a call is genuinely ambiguous instead of silently dropping content.
Exports
resolve(builderName: string, a: any, b: any) -> ({ any }, { [string]: any })— returns(children, opts)— an array of child widget tables (possibly empty) and an options table (possibly empty).
Accepted shapes
resolve("panel", { childA, childB }, opts?) -- canonical array + opts
resolve("panel", singleChildNode, opts?) -- a lone widget (auto-wrapped)
resolve("panel", { style = …, children = {…} }) -- single options table
resolve("panel", { style = … }) -- options only (no children)
resolve("panel", nil, opts?) -- no children
Errors (never silent)
- a children array that ALSO carries a
childrenkey - an options-shaped first argument passed alongside a 2nd options argument
opts.childrenthat isn't an array
Usage
local resolve = require("@builtin::modules.zui.widget.args")
local children, opts = resolve("panel", a, b)
Scoped to this part · feeds back into the world's score.