Jido.Chat.Card (Jido Chat v1.0.0)

Copy Markdown View Source

Canonical cross-platform card model with fallback rendering helpers.

Summary

Functions

Builds an actions component.

Adds a component to the end of a card.

Builds a button component.

Builds a divider component.

Returns the best text fallback for a card.

Builds a field component.

Builds a grouped fields component.

Builds a card from serialized map data.

Builds an image component.

Builds a text link component.

Builds a link button component.

Creates a canonical card.

Normalizes card input.

Builds a radio select component.

Returns the schema for cards.

Builds a section component.

Builds a select component.

Builds a select option component.

Builds a table component.

Builds a text component.

Returns a plain map suitable for adapter-specific rendering.

Serializes a card into a plain map with a type marker.

Renders the card to canonical Markdown.

Types

component()

@type component() :: Jido.Chat.Card.Component.t()

t()

@type t() :: %Jido.Chat.Card{
  components: [any()],
  id: nil | nil | binary(),
  markdown: nil | nil | any(),
  metadata: map(),
  summary: nil | nil | binary(),
  title: nil | nil | binary()
}

Functions

actions(items, opts \\ [])

@spec actions([component() | map()], keyword() | map()) :: component()

Builds an actions component.

add(card, component)

@spec add(t(), component() | map() | String.t()) :: t()

Adds a component to the end of a card.

button(label, action_id, opts \\ [])

@spec button(String.t(), String.t(), keyword() | map()) :: component()

Builds a button component.

divider()

@spec divider() :: component()

Builds a divider component.

fallback_text(card)

@spec fallback_text(t()) :: String.t()

Returns the best text fallback for a card.

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

@spec field(String.t(), String.t(), keyword() | map()) :: component()

Builds a field component.

fields(items, opts \\ [])

@spec fields([component() | map()], keyword() | map()) :: component()

Builds a grouped fields component.

from_map(map)

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

Builds a card from serialized map data.

image(url, opts \\ [])

@spec image(String.t(), keyword() | map()) :: component()

Builds an image component.

link(label, url, opts \\ [])

@spec link(String.t(), String.t(), keyword() | map()) :: component()

Builds a text link component.

new(card)

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

Creates a canonical card.

normalize(card)

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

Normalizes card input.

radio_select(action_id, options, opts \\ [])

@spec radio_select(String.t(), [component() | map()], keyword() | map()) ::
  component()

Builds a radio select component.

schema()

Returns the schema for cards.

section(attrs)

@spec section(keyword() | map()) :: component()

Builds a section component.

select(action_id, options, opts \\ [])

@spec select(String.t(), [component() | map()], keyword() | map()) :: component()

Builds a select component.

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

@spec select_option(String.t(), String.t(), keyword() | map()) :: component()

Builds a select option component.

table(columns, rows, opts \\ [])

@spec table([String.t()], [[String.t()]], keyword() | map()) :: component()

Builds a table component.

text(value, opts \\ [])

@spec text(String.t(), keyword() | map()) :: component()

Builds a text component.

to_adapter_payload(card)

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

Returns a plain map suitable for adapter-specific rendering.

to_map(card)

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

Serializes a card into a plain map with a type marker.

to_markdown(card)

@spec to_markdown(t()) :: Jido.Chat.Markdown.t()

Renders the card to canonical Markdown.