Option shapes and form plumbing shared by select, autocomplete, pillbox,
tags_input, pill_select, segmented, checkbox_group and radio_group.
An option is one of
- a string / number / atom: label and value are the same;
{label, value}(a keyword entry[Alabama: "AL"]is the same);{label, value, count};- a map with
:labeland:value(:count,:hint,:disabled,:icon,:description,:color,:initials,:tone; every other key goes todata); {group_label, [option]}, a group.
normalize/1 returns a list of option maps (%{label, value, disabled, hint, count, icon, description, color, initials, tone, data}; value is always a string) and
%{group: label, options: [option]} entries.
Summary
Functions
Avatar tone class (t1..t5) taken from a name.
Like values/1 but a binary is split on commas.
Options without the group wrappers.
Initials of a label: first letters of the first and last word.
Replaces %{query} (or any %{key}) in a text.
Normalizes options and groups (see the module doc).
Fills id, name, value and errors from field and derives a stable id when none is
given (never random: a hash of seed).
Form field for checkbox-like controls: returns {assigns, id}; checked?/1 tells if it is on.
To string, for option values (nil is the empty string).
%{style: s} for a style or %{}: an empty style={nil} would render style="".
Translates a changeset error ({msg, opts}) or passes a binary through.
A list of chosen values as strings: nil, a scalar, a list or a comma separated string.
Functions
Avatar tone class (t1..t5) taken from a name.
Like values/1 but a binary is split on commas.
Options without the group wrappers.
Initials of a label: first letters of the first and last word.
Replaces %{query} (or any %{key}) in a text.
Normalizes options and groups (see the module doc).
Fills id, name, value and errors from field and derives a stable id when none is
given (never random: a hash of seed).
Form field for checkbox-like controls: returns {assigns, id}; checked?/1 tells if it is on.
To string, for option values (nil is the empty string).
%{style: s} for a style or %{}: an empty style={nil} would render style="".
Translates a changeset error ({msg, opts}) or passes a binary through.
A list of chosen values as strings: nil, a scalar, a list or a comma separated string.