Jido.Chat.Modal (Jido Chat v1.0.0)

Copy Markdown View Source

Canonical modal open payload and builder helpers.

Summary

Functions

Builds a modal from serialized map data.

Creates a canonical modal.

Builds a radio select element.

Returns the schema for modals.

Builds a select element.

Builds a select option element.

Builds a text input element.

Returns a plain map suitable for adapter-specific modal rendering.

Serializes the modal into a plain map with a type marker.

Types

t()

@type t() :: %Jido.Chat.Modal{
  callback_id: nil | nil | binary(),
  close_label: binary(),
  elements: [any()],
  id: nil | nil | binary(),
  metadata: map(),
  notify_on_close: boolean(),
  private_metadata: nil | nil | binary(),
  submit_label: binary(),
  title: binary()
}

Functions

from_map(map)

@spec from_map(map()) :: t()

Builds a modal from serialized map data.

new(modal)

@spec new(t() | map()) :: t()

Creates a canonical modal.

radio_select(id, label, options, opts \\ [])

@spec radio_select(
  String.t(),
  String.t(),
  [Jido.Chat.Modal.Element.t() | map()],
  keyword() | map()
) ::
  Jido.Chat.Modal.Element.t()

Builds a radio select element.

schema()

Returns the schema for modals.

select(id, label, options, opts \\ [])

Builds a select element.

select_option(label, value, opts \\ [])

@spec select_option(String.t(), String.t(), keyword() | map()) ::
  Jido.Chat.Modal.Element.t()

Builds a select option element.

text_input(id, label, opts \\ [])

@spec text_input(String.t(), String.t(), keyword() | map()) ::
  Jido.Chat.Modal.Element.t()

Builds a text input element.

to_adapter_payload(modal)

@spec to_adapter_payload(t()) :: map()

Returns a plain map suitable for adapter-specific modal rendering.

to_map(modal)

@spec to_map(t()) :: map()

Serializes the modal into a plain map with a type marker.