AshSDUI.Intent (ash_sdui v0.2.0)

Copy Markdown View Source

Generic user intent model for views.

Intents separate presentation metadata from execution targets so the same declarative definition can be rendered in different component systems.

Summary

Functions

Executes an intent target when possible, otherwise returns a normalized runtime instruction tuple.

Returns the normalized UI presentation for an intent.

Normalizes an intent declaration.

Types

t()

@type t() :: %AshSDUI.Intent{
  component_override: String.t() | nil,
  confirm: boolean() | String.t() | nil,
  enabled_when: term(),
  icon: String.t() | nil,
  label: String.t(),
  loading_when: term(),
  name: atom(),
  placement: atom() | nil,
  refreshes: [atom()] | nil,
  requires_actor?: boolean(),
  source: term(),
  style: atom() | nil,
  target: term(),
  visible_when: atom() | nil
}

Functions

command(intent, payload \\ %{}, runtime \\ %{})

@spec command(
  t() | struct() | map(),
  map() | keyword() | nil,
  map() | keyword() | nil
) ::
  {:ok, map()} | {:error, term()}

Executes an intent target when possible, otherwise returns a normalized runtime instruction tuple.

execute(intent, payload \\ %{}, runtime \\ %{})

@spec execute(
  t() | struct() | map(),
  map() | keyword() | nil,
  map() | keyword() | nil
) ::
  {:ok, term()} | {:error, term()}

presentation(intent, subject \\ nil, opts \\ %{})

@spec presentation(t() | struct() | map(), map() | keyword() | nil, map()) :: map()

Returns the normalized UI presentation for an intent.

resolve(source, backend_or_context \\ nil)

@spec resolve(
  struct() | map(),
  module() | AshSDUI.Context.t() | map() | keyword() | nil
) :: t()

Normalizes an intent declaration.