One component instance on a surface: its id, catalog type, and properties.
The wire form is a flat object — {"id": "title", "component": "Text", "text": "Hello"}. A Component splits that into id, type and
props (everything else), and tree/1 puts it back together.
A component optionally records the catalog_id it was created
against, so a surface holding components from several catalogs can
look up each one's schema and child-reference spec.
Child references are derived from a A2UICore.Catalog.RefSpec, which
the catalog supplies for the component's type (see
child_references/3).
iex> alias A2UICore.State.Component
iex> component = Component.from_wire(%{"id" => "c", "component" => "Card", "child" => "t"})
iex> {component.id, component.type, component.props}
{"c", "Card", %{"child" => "t"}}
iex> Component.tree(component)
%{"id" => "c", "component" => "Card", "child" => "t"}
Summary
Types
What a catalog knows about a component type: the child-reference spec
and the composition constraints (nil or [] means unconstrained).
Functions
The {child_id, property_path} pairs this component references.
Builds a component from a wire object (id, component, and the
properties).
Builds a component from its parts.
The wire object: the properties plus id and component.
Types
@type info() :: %{ optional(:ref_spec) => A2UICore.Catalog.RefSpec.t() | nil, optional(:allowed_parents) => [String.t()] | nil, optional(:allowed_children) => [String.t()] | nil }
What a catalog knows about a component type: the child-reference spec
and the composition constraints (nil or [] means unconstrained).
Functions
@spec child_references(t(), A2UICore.Catalog.RefSpec.t() | nil, Enumerable.t() | nil) :: [ A2UICore.Catalog.RefSpec.child_ref() ]
The {child_id, property_path} pairs this component references.
A catalog's spec is authoritative when it names child properties.
Without one (an unknown type, or a schema with no ComponentId /
ChildList references) the references are inferred from property
names and shapes: child, children, *Child, values holding a
componentId / child key, and — when known_ids is given — strings
naming a component on the surface.
Builds a component from a wire object (id, component, and the
properties).
Builds a component from its parts.
The wire object: the properties plus id and component.