# `Dala.Plugin.Component`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/plugin/component.ex#L1)

Represents a single component schema within a plugin.

Contains all metadata needed for code generation, validation, and runtime
dispatch. This is the core of the schema-first architecture.

# `event`

```elixir
@type event() :: %{
  name: Dala.Plugin.event_name(),
  payload: map(),
  doc: String.t() | nil
}
```

# `lifecycle_event`

```elixir
@type lifecycle_event() :: :create | :update | :layout | :event | :dispose
```

# `prop`

```elixir
@type prop() :: %{
  name: Dala.Plugin.prop_name(),
  type: Dala.Plugin.prop_type(),
  required: boolean(),
  default: term(),
  doc: String.t() | nil
}
```

# `t`

```elixir
@type t() :: %Dala.Plugin.Component{
  capabilities: [Dala.Plugin.capability()],
  doc: String.t() | nil,
  event_structs: %{required(atom()) =&gt; module()},
  events: [event()],
  lifecycle: [lifecycle_event()],
  metadata: map(),
  name: Dala.Plugin.component_name(),
  natives: %{required(String.t()) =&gt; String.t()},
  optional_capabilities: [atom()],
  plugin: Dala.Plugin.plugin_name(),
  props: [prop()]
}
```

# `add_capability`

```elixir
@spec add_capability(t(), Dala.Plugin.capability()) :: t()
```

Adds a required capability to the component schema.

# `add_event`

```elixir
@spec add_event(t(), Dala.Plugin.event_name(), keyword()) :: t()
```

Adds an event to the component schema.

Options:
  * `:payload` — map of field names to types (default: %{})
  * `:doc` — documentation string (default: nil)

# `add_native`

```elixir
@spec add_native(t(), String.t(), String.t()) :: t()
```

Adds a native platform mapping to the component schema.

`platform` is the platform string (e.g. `"ios"`, `"android"`).
`class_name` is the native class name to instantiate.

# `add_optional_capability`

```elixir
@spec add_optional_capability(t(), atom()) :: t()
```

Adds an optional capability to the component schema.

Optional capabilities enhance the component but are not required for
basic functionality.

# `add_prop`

```elixir
@spec add_prop(t(), Dala.Plugin.prop_name(), Dala.Plugin.prop_type(), keyword()) ::
  t()
```

Adds a property to the component schema.

Options:
  * `:required` — boolean, whether the prop is required (default: false)
  * `:default` — default value (default: nil)
  * `:doc` — documentation string (default: nil)

---

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