ComponentScope

interface ComponentScope

The receiver a JoyDomComponent renders against. Exposes the current node and its parent (for layout/positioning calculations), a Children composable so a component can act as a container, a per-entry Child composable so a component can place children itself, and emit to dispatch events into the same onEvent callback the built-in renderer uses.

Properties

Link copied to clipboard
abstract val node: <Error class: unknown class>

The resolved node this component is rendering.

Link copied to clipboard
abstract val parent: <Error class: unknown class>?

The resolved parent node, or null when this is the document root.

Functions

Link copied to clipboard
abstract fun Child(child: <Error class: unknown class>, modifier: Modifier = Modifier)

Render a single entry of node's children, so a component can own placement instead of delegating it to Children — e.g. Row { node.children.forEach { Child(it) } } or a custom Layout with its own measure/place pass. An element child renders through the full node pipeline (styles, nested components, its own children); a text run renders as a joy-dom text node with its inherited text context.

Link copied to clipboard
abstract fun Children(modifier: Modifier = Modifier)

Render node's children using the standard flow/flex dispatch, so a component that replaces a container type (e.g. div) lays its children out like the built-in would.

Link copied to clipboard
abstract fun emit(event: EventType, payload: EventParams? = null)

Fire one of the node's inbuilt typed bindings — EventType.Click/Focus/ Blur/Change map to onClick/onFocus/onBlur/onChange. No-op when the node didn't bind that event. (Pass a EventType.Custom here and it is routed to the emit string overload.)

abstract fun emit(eventName: String, payload: EventParams? = null)

Fire an event by name. The event name is always the node's exact binding prop name — never rewritten. The four reserved prop names — "onclick"/"onfocus"/"onblur"/ "onchange" — fire the node's typed bindings, exactly like the EventType overload (serialization stores those props in typed fields). Any other name is a custom event, resolved from the node's props by that same name — emit("rate") looks up node.props["rate"]. No-op when no matching binding is present. payload reaches the handler as EventPayload.payload, alongside — never merged into — the binding's static EventPayload.params.