# `LedgerUI.Components.Select.Options`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/select.ex#L1)

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 `:label` and `:value` (`:count`, `:hint`, `:disabled`, `:icon`,
    `:description`, `:color`, `:initials`, `:tone`; every other key goes to `data`);
  * `{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.

# `avatar_tone`

Avatar tone class (`t1`..`t5`) taken from a name.

# `csv_values`

Like `values/1` but a binary is split on commas.

# `flatten`

Options without the group wrappers.

# `initials`

Initials of a label: first letters of the first and last word.

# `interpolate`

Replaces `%{query}` (or any `%{key}`) in a text.

# `normalize`

Normalizes options and groups (see the module doc).

# `resolve`

Fills `id`, `name`, `value` and `errors` from `field` and derives a stable id when none is
given (never random: a hash of `seed`).

# `resolve_field`

Form field for checkbox-like controls: returns `{assigns, id}`; `checked?/1` tells if it is on.

# `str`

To string, for option values (`nil` is the empty string).

# `style_attrs`

`%{style: s}` for a style or `%{}`: an empty `style={nil}` would render `style=""`.

# `translate_error`

Translates a changeset error (`{msg, opts}`) or passes a binary through.

# `values`

A list of chosen values as strings: `nil`, a scalar, a list or a comma separated string.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
