pub struct Element {
pub type_name: String,
pub props: Value,
pub children: Vec<String>,
pub action: Option<Action>,
pub visible: Option<Visibility>,
pub each: Option<EachDirective>,
pub if_: Option<Visibility>,
}Expand description
A single type-erased UI element.
The type_name is an unrestricted string; catalog / renderer layers decide
whether the name resolves to a built-in or plugin component. props is a
free-form JSON value carrying component-specific fields; validation of
per-component props is deferred to the Phase 117 catalog.
Fields§
§type_name: StringComponent type name (renamed from type to avoid Rust keyword collision).
props: ValueComponent-specific props payload.
children: Vec<String>IDs of child elements (must resolve in the parent Spec.elements map).
action: Option<Action>Optional action attached to this element.
visible: Option<Visibility>Optional visibility rule governing whether this element renders.
each: Option<EachDirective>Optional iteration directive. When present, the element is treated as a template — resolve-time expansion (Plan 03) produces N clones with auto-suffixed IDs, one per row in the resolved data array.
if_: Option<Visibility>Optional conditional-emission directive. When the predicate evaluates
false against Spec::data at resolve time (Plan 03), the element is
REMOVED from the element map (no hidden DOM, no JS). Distinct from
visible which renders the element with hidden semantics.
Reuses the Visibility enum (D-04) — accepts flat conditions AND
And/Or/Not composition because Visibility is #[serde(untagged)].
§Interaction with $each
When both $if and $each are present on the same element, $if is
evaluated FIRST. If false, the element is removed before $each
expansion runs (no clones produced).
Implementations§
Source§impl Element
impl Element
Sourcepub fn new(type_name: impl Into<String>) -> ElementBuilder
pub fn new(type_name: impl Into<String>) -> ElementBuilder
Start building an Element with the given type name.
Returns an ElementBuilder rather than Self because element
construction is fluent; the terminal call is consumed by
SpecBuilder::element which invokes the crate-private build.