Corex.Item
(Corex v0.1.0-beta.2)
View Source
Struct for data items used in:
Use Corex.Item.new/1 to build a list of items from a list of maps.
Fields
:title(required) - the label/title of the item:value(optional) - the value of the item, auto-generated as"item-N"when omitted:meta(optional) - any extra data for custom rendering
Examples
Corex.Item.new([
%{title: "Name", value: "Marie Curie"},
%{title: "Status", value: "Active", meta: %{color: "green"}}
])
Summary
Functions
Creates a single Corex.Item from a map, auto-generating :value as "item-N" when not provided.
Creates a list of %Corex.Item{} structs from a list of maps.
Types
Functions
Creates a single Corex.Item from a map, auto-generating :value as "item-N" when not provided.
Raises ArgumentError if attrs is not a map or is missing required fields.
Creates a list of %Corex.Item{} structs from a list of maps.
Auto-generates :value as "item-N" (1-based index) when not provided.
Examples
iex> Corex.Item.new([%{title: "Name", value: "Ada"}])
[%Corex.Item{title: "Name", value: "Ada", meta: %{}}]
iex> Corex.Item.new([%{title: "Status", value: "Active", meta: %{color: "green"}}])
[%Corex.Item{title: "Status", value: "Active", meta: %{color: "green"}}]
iex> Corex.Item.new([%{title: "Name"}, %{title: "Status"}])
[
%Corex.Item{title: "Name", value: "item-1", meta: %{}},
%Corex.Item{title: "Status", value: "item-2", meta: %{}}
]Raises ArgumentError if items is not a list of maps.