Corex.Attrs (Corex v0.2.0)

View Source

Builders for the HTML attribute maps the Connect modules hand to templates.

Presence attributes follow the HTML convention where the attribute's mere presence is the signal: "" renders as a bare attribute and nil omits it. That is deliberately different from Checkable.Helpers, which emits the "true" | "false" | "indeterminate" enum a tri-state control needs, and from Corex.FormField.dataset_default_boolean/1, which always emits a string.

Summary

Functions

data_state(state, true_val, false_val)

@spec data_state(term(), term(), term()) :: term()

default_presence_attr(controlled, value)

@spec default_presence_attr(boolean() | nil, term()) :: String.t() | nil

Emits the presence attribute only for an uncontrolled component.

A controlled component takes its state from the server on every render, so the default-state attribute the hook reads on mount must not be emitted.

maybe_put(map, key, value)

@spec maybe_put(map(), term(), term()) :: map()

presence_attr(state)

@spec presence_attr(boolean() | nil) :: String.t() | nil

presence_attr(controlled, value)

@spec presence_attr(boolean() | nil, term()) :: String.t() | nil

Emits the presence attribute only for a controlled component.

put_data_dir_attr(map, dir)

@spec put_data_dir_attr(map(), String.t() | nil) :: map()

put_data_dir_attr_from_assigns(map, assigns)

@spec put_data_dir_attr_from_assigns(map(), map()) :: map()

put_dir_attr(map, dir)

@spec put_dir_attr(map(), String.t() | nil) :: map()

put_dir_attr_from_assigns(map, assigns)

@spec put_dir_attr_from_assigns(map(), map()) :: map()

visually_hidden_style()

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