Package-level declarations
Types
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.
Typed accessors over any Map<String, JsonElement> whose values are raw spec JSON — read them through getXxxOrNull / getXxx instead of casting JsonElements by hand.
Passed to the host's JoyDomEventHandler when a bound event fires. Mirrors React's EventBinding dispatch (js/react/src/types.ts): the spec carries no DOM event, so instead of a SyntheticEvent the payload names the type kind alongside the bound name and its params.
The event that triggered a dispatch. The four inbuilt kinds map to a node's typed bindings (onclick/onfocus/onblur/onchange); Custom carries an arbitrary event name emitted by a custom component via ComponentScope.emit.
Renderer for a node type, registered via the components DSL. A component receives a ComponentScope giving it the current com.j0y.joy.dom.layout.ResolvedNode and its parent, a Children composable to render the node's children as a container, and an emit hook into the event system.
Builder for components.
The component registry passed to JoyDom. Build one with the components DSL.
The single host callback every node event binding dispatches into. There is no registry and no per-event registration: when any bound event fires, JoyDom invokes this with the full EventPayload, and the host switches on EventPayload.name to decide what to do (ignoring an event is just not matching it). Passing null (the default) still makes a bound node interactive (clickable/focusable) — the dispatch is just dropped.
The single host callback a store-backed JoyDom dispatches into.
Factory invoked when a replaced element (img) renders. The renderer reads src from node.props["src"] (or the node-level node["src"]) and asks the factory to produce a Painter; if it returns null, the element renders as an empty Box.
Diagnostics for an interaction that stopped early.
Properties
The default JoyDomPainterFactory: loads each src via Coil 3's rememberAsyncImagePainter. Exposed so a custom factory can delegate to it for srcs it doesn't handle itself (e.g. myScheme(src) ?: CoilPainterFactory(src)).
The current Viewport that drove this resolution — width, height, orientation, and print flag. Provided by JoyDom and accessible from inside any custom component registered via the components parameter, so a component can render differently based on the live environment (e.g. a "viewport info" debug overlay).
Functions
Build the component registry for JoyDom:
Render a hoisted JoyDomStore. The store's callbacks were fixed when it was created (see rememberJoyDomStore); this overload only draws it and feeds every fired binding back in.
Lower-level entry: render a pre-resolved ResolvedSpec without re-running cascade / breakpoint evaluation. Useful when the caller already has the resolved tree (e.g. from a test fixture or a memoised resolution) and wants to skip viewport probing.
Render a joy-dom Spec into Compose UI.
Render a view template — a document carrying state, defs and handlers alongside layout — with the logic layer wired up.
Creates and remembers the JoyDomStore for view, seeded with initialState.
Resolve a CSS font-family value to a Compose FontFamily.
The runtime data a custom component passed to emit — what {"$event": …} reads, before the binding's own params are merged over it.
The renderer's EventPayload as the binding the interpreter runs.
Maps this joy-dom FontStyle to the equivalent Compose ComposeFontStyle.
Maps this joy-dom FontWeight to the equivalent Compose ComposeFontWeight.
Maps this joy-dom TextAlign to the equivalent Compose ComposeTextAlign.
Maps this joy-dom TextDecoration to the equivalent Compose ComposeTextDecoration.
Maps this joy-dom TextOverflow (or null, the unset/clip default) to the Compose ComposeTextOverflow.
Build a Compose TextStyle from a fully-resolved TextContext.
toComposeTextStyle overload taking a custom font-family resolver — the renderer threads LocalJoyDomFontResolver here so a caller-supplied resolver (e.g. one that loads bundled faces) is honoured.
Convert a px Length to Compose Dp.
Convert a percent Length (0..100) to a fraction (0..1) for Compose modifiers like Modifier.fillMaxWidth(fraction). Returns null for px lengths.
Maps this joy-dom WhiteSpace to Compose's max-lines: 1 for nowrap, else Int.MAX_VALUE.
Maps this joy-dom WhiteSpace to Compose's soft-wrap flag: false for nowrap, else true.
Convert a px Length used as a typography size (font-size, letter-spacing, line-height-as-distance) to Compose TextUnit in sp. We use sp so user font-scale preferences apply — matching browser zoom behaviour for text. Returns null for percent.