A2UIPhoenix.Inputs (A2UIPhoenix v0.1.1)

Copy Markdown View Source

How a form change on a surface becomes a write.

An input of node ref is named a2ui[ref][field] (A2UIPhoenix.Context.input_name/2), where field is normally the property the input writes. decode/4 turns the submitted string into the value the property holds — a boolean for a CheckBox, a list for a ChoicePicker, a number for a Slider, a combined date-time for a DateTimeInput — or into local UI state (a ChoicePicker filter). Any other component's field is written as the submitted string.

Summary

Functions

Whether a DateTimeInput picks a date: enableDate, which defaults to true only when enableTime is not set (a time-only input picks no date), as the basic catalog's guide and the reference renderers have it.

The YYYY-MM-DD part of a date or date-time value ("" when there is none).

Decodes the submitted raw value of field of node. today fills in the date when only the time of a date-and-time input is set.

The HH:MM part of a time or date-time value ("" when there is none).

The new value of a ChoicePicker when the chip for option is clicked: toggled in a multiple selection, the only one otherwise.

Types

decoded()

(since 0.1.0)
@type decoded() :: {:write, String.t(), term()} | {:ui, atom(), term()} | :ignore

Functions

date_enabled?(props)

(since 0.1.0)
@spec date_enabled?(map()) :: boolean()

Whether a DateTimeInput picks a date: enableDate, which defaults to true only when enableTime is not set (a time-only input picks no date), as the basic catalog's guide and the reference renderers have it.

iex> A2UIPhoenix.Inputs.date_enabled?(%{"enableTime" => true})
false
iex> A2UIPhoenix.Inputs.date_enabled?(%{})
true

date_part(value)

(since 0.1.0)
@spec date_part(String.t()) :: String.t()

The YYYY-MM-DD part of a date or date-time value ("" when there is none).

iex> A2UIPhoenix.Inputs.date_part("2026-10-14T09:30:00")
"2026-10-14"
iex> A2UIPhoenix.Inputs.date_part("09:30")
""

decode(node, field, raw, today)

(since 0.1.0)
@spec decode(A2UICore.Resolution.Node.t(), String.t(), term(), Date.t()) :: decoded()

Decodes the submitted raw value of field of node. today fills in the date when only the time of a date-and-time input is set.

time_part(value)

(since 0.1.0)
@spec time_part(String.t()) :: String.t()

The HH:MM part of a time or date-time value ("" when there is none).

iex> A2UIPhoenix.Inputs.time_part("2026-10-14T09:30:00")
"09:30"

toggle(node, option)

(since 0.1.0)
@spec toggle(A2UICore.Resolution.Node.t(), String.t()) ::
  {:write, String.t(), [String.t()]}

The new value of a ChoicePicker when the chip for option is clicked: toggled in a multiple selection, the only one otherwise.