Corex. Item
(Corex v0.2.0)
View Source
The shared contract behind Corex.Content.Item, Corex.List.Item, and
Corex.Tree.Item.
The three structs stay separate because their required fields differ: content
items carry :content, tree items carry :children, list items carry neither.
Everything else is shared, and this module is where the shared parts live: the
field set, the generated :value, and the :items assign validator.
Shared fields
All three carry :value, :label, :disabled, and :meta. Corex.List.Item
and Corex.Tree.Item add the navigation set: :to, :redirect, :new_tab,
and :group.
Validation
:items is authored in a template, not received from params, so a wrong shape
is a developer mistake and assert_items!/3 raises rather than coercing. This
is the opposite of Corex.Value, which coerces because its input comes from
handle_event.
Summary
Functions
Asserts that a component's :items assign holds structs of module.
Generates a unique :value for an item that was built without one.
The fields carried by the item structs that support redirect-on-select.
The fields every item struct carries.
Functions
Asserts that a component's :items assign holds structs of module.
Returns assigns unchanged so it can sit in an assign pipeline. Options:
:component(required) - name used in the error message:required- when true, anil:itemsraises instead of passing through:example(required) - theCorex.*.new/1snippet shown in the error
Generates a unique :value for an item that was built without one.