# `Macaw.Control`
[🔗](https://github.com/dcoai/macaw/blob/v0.6.0/lib/macaw/control.ex#L1)

A component that offers choices (spec/05 §6.7, #452): a behavior of macaw's, as
`Macaw.Container` and `Macaw.RequestReads` are.

A control names the one event it chooses with, `chooses/0`. Its placement says what
the choice writes: each `set` action of the cell on that event is a **choice**, the
state it sets and the place in the event's value it reads, `{:event, :value}` for a
control of one choice or `{:event, [:value, key]}` for one of several, one per key. The
core hands the component, in its settings, each choice's options, the state's current
legal values: its closed `values`, its `values_from` values as `Macaw.Surface.legal/3`
reads them, or, for the `theme` preference, the registry's themes. So a control offers
what the data holds and nothing else, and never names a state itself.

What the component is handed, in `@settings["choices"]`, is a list in the actions'
order of `%{"key", "state", "field", "current", "options"}`: the key it reads (`nil`
for the value itself), the state's name, the URL parameter a GET form writes it under
(`"<surface>[<state>]"`, as `Macaw.State.Persistence.Url` nests it), its current value,
and its options, each `%{"value", "text"}`, the value as the state holds it and its text
as persistence writes it. `@settings["form"]` is `nil`, or, rendering `:socketless`
with the host's `links:` (spec/03 §3.3), `%{"action", "hidden"}`: the page's address
and the visit's other params as `{name, text}` pairs, so a GET form keeps them.

# `chooses`

```elixir
@callback chooses() :: String.t()
```

The event the control chooses with: each `set` action on it is a choice.

# `control?`

```elixir
@spec control?(module()) :: boolean()
```

Whether `module` is a control: it answers `chooses/0`.

    iex> Macaw.Control.control?(Macaw.Builtin.Filter)
    true
    iex> Macaw.Control.control?(Macaw.Builtin.Table)
    false

---

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