# `Macaw.Component.Declarations`
[🔗](https://github.com/dcoai/macaw_component/blob/v0.13.0/lib/macaw/component/declarations.ex#L1)

A component's configured declarations (spec/01 §1.2), built by `new/2` from its
`declarations/1` answer, every key checked, every fault at once.

No atom is made from a name: names are strings, and an observation spelled as a string
is matched against the vocabulary's atoms.

# `action`

```elixir
@type action() :: %{on: String.t(), set: String.t(), value: event_path()}
```

A default action (spec/01 §1.6): an event sets one of the component's bindable parameters.

# `event_path`

```elixir
@type event_path() ::
  {:event, :value | :identity | [:value | :identity | :row | String.t()]}
```

A field of an event an action reads (spec/01 §1.6).

# `t`

```elixir
@type t() :: %Macaw.Component.Declarations{
  access: String.t() | nil,
  actions: [action()],
  announces: [String.t()],
  events: [String.t()],
  isolation: :pure | :contained,
  local: %{required(String.t()) =&gt; Macaw.Component.State.type()},
  observes: [atom()],
  proxy_routes: [Macaw.Component.Proxy.route()],
  reading: :glance | :scan | :read,
  requests: [String.t()],
  shortcuts: [%{key: String.t(), action: String.t(), description: String.t()}],
  slots: %{required(String.t()) =&gt; Macaw.Component.Slot.t()},
  stylesheets: [String.t()],
  words: non_neg_integer() | nil,
  writes: %{required(String.t()) =&gt; Macaw.Component.State.type()}
}
```

# `emits?`

```elixir
@spec emits?(t(), String.t()) :: boolean()
```

Whether the declarations name an event.

# `event_path?`

```elixir
@spec event_path?(term()) :: boolean()
```

Whether a term is one of the five event paths.

    iex> Macaw.Component.Declarations.event_path?({:event, [:value, "sort"]})
    true
    iex> Macaw.Component.Declarations.event_path?({:event, [:value]})
    false

# `event_paths`

```elixir
@spec event_paths() :: [event_path(), ...]
```

The five event paths an action may read (spec/01 §1.6), `key` and `field` standing for
any non-empty string.

    iex> length(Macaw.Component.Declarations.event_paths())
    5

# `keys`

```elixir
@spec keys() :: [atom(), ...]
```

The keys, in the order of spec/01 §1.2's table.

# `new`

```elixir
@spec new(keyword() | map(), module() | nil) ::
  {:ok, t()} | {:error, [Macaw.Component.fault(), ...]}
```

The declarations from an answer (a keyword list or a map with atom keys) for a component
module, which `isolation: :contained` is checked against.

    iex> {:ok, d} = Macaw.Component.Declarations.new([events: ["open"], reading: :scan], nil)
    iex> {d.events, d.reading, d.isolation}
    {["open"], :scan, :pure}

---

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