A2UIComponentScope

One component of a surface as its renderer sees it: its properties, resolved against the surface's data, its children, and what it does when the person uses it.

Values are plain Kotlin values: maps, lists, strings, numbers (Long or Double), booleans and null. A value the agent bound to the data model reads the data model now, and the surface draws again when the data changes.

Read it while composing, on the main thread.

Properties

Link copied to clipboard

Whether the component does something when the person uses it.

Link copied to clipboard
val id: String

The component's id, unique in its surface.

Link copied to clipboard

Whether none of the component's checks blocks it.

Link copied to clipboard

The modifier the parent gives this component, such as its weight in a Row, with the component's accessibility label. Apply it to the outermost element.

Link copied to clipboard

The component's type, such as Text.

Link copied to clipboard

The messages of the component's checks that fail now and should block it, such as a button's form being incomplete.

Functions

Link copied to clipboard
fun boolean(name: String): Boolean?

Property name as a boolean; a check's result reads as whether it passed.

Link copied to clipboard
fun Child(child: A2UIChild, modifier: Modifier = Modifier)

Draws child with the surface's catalog.

Link copied to clipboard
fun child(name: String = "child"): A2UIChild?

The single child property name refers to, such as a Card's child.

Link copied to clipboard
fun children(name: String = "children"): List<A2UIChild>

The children property name lists: the components it names, or its template repeated for every item of the list it is bound to.

Link copied to clipboard
fun childWithId(id: String, slot: String = id): A2UIChild?

The component with id, placed as this one's child, such as a tab's content.

Link copied to clipboard
fun hint(name: String): String?

Property name as the agent wrote it, for a hint such as variant, which is never bound.

Link copied to clipboard
fun isBound(name: String): Boolean

Whether property name is bound to the data model, so write changes it.

Link copied to clipboard
fun number(name: String): Double?

Property name as a number.

Link copied to clipboard

Does what the component does when the person uses it: sends its event to the agent, with its context read now, or runs its function.

Link copied to clipboard
fun string(name: String): String?

Property name as text; numbers show without a needless .0.

Link copied to clipboard

Property name as a list of strings.

Link copied to clipboard
fun value(name: String): Any?

Property name, resolved, or null when it is missing or not there yet. A list or an object the agent wrote resolves all the way down, so a binding or a call nested in it, such as an option's label, reads as its value. A value read from the data model is data, as it is.

Link copied to clipboard
fun write(name: String, value: Any?)

Writes value to the data model where property name is bound, as an input does when the person changes it. Does nothing when the property isn't bound.