Type-safe MoonBit bindings for React with virtual DOM, hooks, and CSS-in-JS support (early experimental)
Dependencies
React bindings for MoonBit
import * as React from "react";
import * as ReactDOMServer from "react-dom/server";
globalThis.React = React;
globalThis.ReactDOMServer = ReactDOMServer;import * as React from "react";
import * as ReactDOM from "react-dom";
import * as ReactDOMClient from "react-dom/client";
globalThis.React = React;
globalThis.ReactDOM = ReactDOM;
globalThis.ReactDOMClient = ReactDOMClient;// Define your component props
struct ContainerProps {} derive(Default)
// Create a functional component
fn comp_container(_v : ContainerProps) -> @react.VirtualNode {
let (counter, set_counter) = @react.use_state(Float::from_double(0.0))
@react.div(
id="container",
style=@css.respo_style(
color=@css.CssColor::Blue,
font_family="Arial",
padding=@css.CssSize::Px(10.0),
),
on_click=fn(_) {
println("clicked \{counter}")
set_counter(counter + 1.0)
},
[
@react.Fragment([@react.Text("Demo: ")]),
@react.Text("Counter \{counter}")
],
)
}
// Render to DOM
fn main {
let window = @dom.window()
let doc = window.document()
let body = doc.body()
let props : ContainerProps = Default::default()
@react.render(
@react.component(comp_container, props, []),
body,
)
println("loaded")
}moon check
moon test
moon info
corepack yarn install --frozen-lockfile
corepack yarn generate:dom
corepack yarn check:generated
corepack yarn check:docs
corepack yarn test:server
corepack yarn build
corepack yarn test:browserpub type DOMEventpub(all) enum DOMEventType {
Copy
Cut
Paste
CompositionEnd
CompositionStart
CompositionUpdate
Click
DoubleClick
MouseDown
MouseUp
MouseMove
MouseEnter
MouseLeave
MouseOver
MouseOut
ContextMenu
PointerDown
PointerMove
PointerUp
PointerCancel
PointerEnter
PointerLeave
PointerOver
PointerOut
GotPointerCapture
LostPointerCapture
KeyDown
KeyUp
KeyPress
BeforeInput
Input
Change
Submit
Reset
Focus
Blur
Select
Load
Unload
Resize
Scroll
Wheel
Drag
DragStart
DragEnd
DragEnter
DragLeave
DragOver
Drop
TouchStart
TouchMove
TouchEnd
TouchCancel
Error
Abort
CanPlay
CanPlayThrough
DurationChange
Ended
LoadedData
LoadedMetadata
LoadStart
Pause
Play
Playing
Progress
RateChange
Seeked
Seeking
Stalled
Suspend
TimeUpdate
VolumeChange
Waiting
AnimationStart
AnimationEnd
AnimationIteration
TransitionEnd
Invalid
Toggle
Cancel
Close
} derive(Compare, Eq, Hash)fn ElementEvents::add(self : ElementEvents, event_type : DOMEventType, value : (DOMEvent) -> Unit) -> ElementEventsfn ElementEvents::set(self : ElementEvents, event_type : DOMEventType, value : (DOMEvent) -> Unit) -> Unittype FormStatustype ImperativeRef[T]pub(all) enum InputType {
Button
Checkbox
Color
Date
DatetimeLocal
Email
File
Hidden
Image
Month
Number
Password
Radio
Range
Reset
Search
Submit
Tel
Text
Time
Url
Week
} derive(Eq)type ModuleHintOptionsfn ModuleHintOptions::new(cross_origin? : ResourceCrossOrigin, integrity? : String, nonce? : String) -> ModuleHintOptions#external
pub type NativeEventtype PreinitOptionsfn PreinitOptions::script(cross_origin? : ResourceCrossOrigin, integrity? : String, nonce? : String, fetch_priority? : ResourceFetchPriority) -> PreinitOptionsfn PreinitOptions::style(precedence : ResourceStylePrecedence, cross_origin? : ResourceCrossOrigin, integrity? : String, nonce? : String, fetch_priority? : ResourceFetchPriority) -> PreinitOptionspub(all) enum PreloadDestination {
Audio
Document
Embed
Fetch
Font
Image
Object
Script
Style
Track
Video
Worker
} derive(Eq)type PreloadOptionsfn PreloadOptions::new(destination : PreloadDestination, cross_origin? : ResourceCrossOrigin, referrer_policy? : ResourceReferrerPolicy, integrity? : String, mime_type? : String, nonce? : String, fetch_priority? : ResourceFetchPriority, image_src_set? : String, image_sizes? : String) -> PreloadOptionstype ReactComponent[T]fn[T] ReactComponent::memo(self : ReactComponent[T], are_props_equal? : (T, T) -> Bool) -> ReactComponent[T]type ReactContext[T]fn[T] ReactContext::provider(self : ReactContext[T], value : T, children : Array[VirtualNode]) -> VirtualNodetype ReactDomRef#external
pub type ReactError#external
pub type ReactErrorInfo#external
pub type ReactFormDatatype ReactReadableStreamtype ReactRef[T]type ReactResource[T]pub(all) enum ResourceReferrerPolicy {
NoReferrerWhenDowngrade
NoReferrer
Origin
OriginWhenCrossOrigin
UnsafeUrl
} derive(Eq)type RootOptionsfn RootOptions::new(identifier_prefix? : String, on_caught_error? : (ReactError, ReactErrorInfo) -> Unit, on_uncaught_error? : (ReactError, ReactErrorInfo) -> Unit, on_recoverable_error? : (ReactError, ReactErrorInfo) -> Unit) -> RootOptionspub(all) enum StateUpdate[T] {
Set(T)
Update((T) -> T)
}type StreamRenderOptionsfn StreamRenderOptions::new(identifier_prefix? : String, bootstrap_scripts? : Array[String], bootstrap_modules? : Array[String], nonce? : String, on_error? : (ReactError) -> Unit) -> StreamRenderOptionspub struct VirtualElement {
name : String
attrs : ElementAttrs
event : ElementEvents
style : RespoStyle
children : Array[VirtualNode]
}pub(all) enum VirtualNode {
Element(VirtualElement)
Fragment(Array[VirtualNode])
Text(String)
JsNode(JsObscure)
}fn a(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, href? : String, target? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn address(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn article(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn aside(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn audio(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], src? : String, controls? : Bool, autoplay? : Bool, loop_enabled? : Bool, muted? : Bool, on_play? : (DOMEvent) -> Unit, on_pause? : (DOMEvent) -> Unit) -> VirtualNodefn blockquote(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cite? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn button(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, button_type? : String, name? : String, value? : String, disabled? : Bool, form_action? : FormAction, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn caption(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn circle(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cx? : String, cy? : String, r? : String, fill? : String, stroke? : String, stroke_width? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn clip_path(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn code(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn col(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn colgroup(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNodestruct ButtonProps {
text : String
disabled : Bool
} derive(Default)
fn my_button(props : ButtonProps) -> VirtualNode {
button(disabled=props.disabled, [Text(props.text)])
}
let node = component(my_button, ButtonProps { text: "Click me", disabled: false }, [])fn[T] component_with_children(f : (T, Array[VirtualNode]) -> VirtualNode, props : T, children : Array[VirtualNode]) -> VirtualNode#callsite(autofill(loc))
fn[U : Show] contained_static_style(rules : Array[(String?, U, RespoStyle)], loc~ : SourceLoc) -> Stringlet style_demo : String = contained_static_style(
[(Some("@media only screen and (max-width: 600px)"), "&", respo_style(margin=4 |> Px, background_color=Hsl(200, 90, 96)))],
)let style = @css.respo_style(background_color=Red, font_size=16.0 |> Px)
let js_style = convert_style_to_js_object(style)
// Results in: { backgroundColor: "red", fontSize: "16px" }fn create_element(name : String, attrs : ElementAttrs, event : ElementEvents, style~ : RespoStyle, children : Array[VirtualNode]) -> VirtualElement// Create a custom element
let _custom_elem = create_element(
"my-custom-element",
ElementAttrs::new(),
ElementEvents::new(),
style=@css.respo_style(),
[Text("Custom content")],
)fn css_prop_to_camel_case(name : String) -> Stringinspect(css_prop_to_camel_case("background-color"), content="backgroundColor")
inspect(css_prop_to_camel_case("border-top-left-radius"), content="borderTopLeftRadius")
inspect(css_prop_to_camel_case("-webkit-line-clamp"), content="WebkitLineClamp")fn datalist(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNode#deprecated("This function is deprecated.")
#callsite(autofill(loc))
fn[U : Show] declare_contained_style(rules : Array[(String?, U, RespoStyle)], loc~ : SourceLoc) -> Stringfn defs(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn details(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, open? : Bool, on_click? : (DOMEvent) -> Unit, on_toggle? : (DOMEvent) -> Unit) -> VirtualNodefn dialog(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, open? : Bool, on_click? : (DOMEvent) -> Unit, on_cancel? : (DOMEvent) -> Unit, on_close? : (DOMEvent) -> Unit) -> VirtualNodefn div(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn dom_attr_to_react_prop(attr_name : String) -> Stringinspect(dom_attr_to_react_prop("class"), content="className")
inspect(dom_attr_to_react_prop("for"), content="htmlFor")
inspect(dom_attr_to_react_prop("innerHTML"), content="dangerouslySetInnerHTML")
inspect(dom_attr_to_react_prop("id"), content="id")
inspect(dom_attr_to_react_prop("data-test"), content="data-test")inspect(dom_event_to_react_handler(KeyDown), content="onKeyDown")
inspect(dom_event_to_react_handler(Click), content="onClick")
inspect(dom_event_to_react_handler(MouseEnter), content="onMouseEnter")
inspect(dom_event_to_react_handler(DoubleClick), content="onDoubleClick")fn ellipse(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cx? : String, cy? : String, rx? : String, ry? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn em(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn error_boundary(fallback : (ReactError) -> VirtualNode, children : Array[VirtualNode], reset_key? : String, on_error? : (ReactError, ReactErrorInfo) -> Unit) -> VirtualNodefn fieldset(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, name? : String, disabled? : Bool, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn figcaption(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn figure(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn flush_sync(callback : () -> Unit) -> Unitfn footer(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn form(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], action? : FormAction, method_? : String, on_submit? : (DOMEvent) -> Unit) -> VirtualNodefn g(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, transform? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn h1(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn h2(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn h3(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn h4(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn h5(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn h6(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn header(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn img(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, src? : String, alt? : String, width? : String, height? : String, on_click? : (DOMEvent) -> Unit, on_load? : (DOMEvent) -> Unit, on_error? : (DOMEvent) -> Unit) -> VirtualNodefn input(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, type_? : InputType, name? : String, value? : String, default_value? : String, placeholder? : String, disabled? : Bool, read_only? : Bool, checked? : Bool, default_checked? : Bool, form_action? : FormAction, on_click? : (DOMEvent) -> Unit, on_change? : (DOMEvent) -> Unit, on_input? : (DOMEvent) -> Unit) -> VirtualNodefn is_boolean_prop(prop_name : String) -> Boolinspect(is_boolean_prop("checked"), content="true")
inspect(is_boolean_prop("disabled"), content="true")
inspect(is_boolean_prop("readOnly"), content="true")
inspect(is_boolean_prop("className"), content="false")fn label(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit, for_? : String) -> VirtualNodefn legend(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn li(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn line(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x1? : String, y1? : String, x2? : String, y2? : String, stroke? : String, stroke_width? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn linear_gradient(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x1? : String, y1? : String, x2? : String, y2? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn link(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, rel? : String, href? : String, media? : String, precedence? : String, cross_origin? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn main_(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn mask(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, width? : String, height? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn meta(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, name? : String, content? : String, charset? : String, http_equiv? : String, item_prop? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn meter(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, value? : Float, min? : Float, max? : Float, low? : Float, high? : Float, optimum? : Float, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn nav(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn ol(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn optgroup(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, label? : String, disabled? : Bool, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn option(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, value? : String, disabled? : Bool) -> VirtualNodefn output(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, name? : String, html_for? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn p(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn path(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, d? : String, fill? : String, stroke? : String, stroke_width? : String, path_length? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn polygon(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, points? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn polyline(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, points? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn pre(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn prefetch_dns(href : String) -> Unitfn progress(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, value? : Float, max? : Float, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn radial_gradient(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, cx? : String, cy? : String, r? : String, fx? : String, fy? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn rect(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, width? : String, height? : String, rx? : String, ry? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodeasync fn render_to_readable_stream(vdom : VirtualNode, options? : StreamRenderOptions) -> ReactReadableStreamfn script_tag(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, src? : String, type_? : String, cross_origin? : String, async_? : Bool, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn section(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn select(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], value? : String, values? : Array[String], default_value? : String, default_values? : Array[String], disabled? : Bool, multiple? : Bool, on_change? : (DOMEvent) -> Unit) -> VirtualNodefn span(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodelet _ = span(
class_name="text-bold",
on_click=fn(_e) { println("Clicked!") }, []
)fn start_transition(action : () -> Unit) -> Unit#callsite(autofill(loc))
fn[U : Show] static_style(rules : Array[(U, RespoStyle)], loc~ : SourceLoc) -> Stringlet style_demo : String = static_style(
[("&", respo_style(margin=4 |> Px, background_color=Hsl(200, 90, 96)))],
)fn stop(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, offset? : String, stop_color? : String, stop_opacity? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn strong(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn style_tag(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, precedence? : String, href? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn summary(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn svg(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, view_box? : String, width? : String, height? : String, xmlns? : String, fill? : String, stroke? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn svg_text(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, dx? : String, dy? : String, text_anchor? : String, fill? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn symbol(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, view_box? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn table(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn tbody(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn td(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, headers? : String, col_span? : Int, row_span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn textarea(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, value? : String, default_value? : String, placeholder? : String, rows? : Int, cols? : Int, disabled? : Bool, read_only? : Bool, on_change? : (DOMEvent) -> Unit, on_input? : (DOMEvent) -> Unit) -> VirtualNodefn tfoot(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn th(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, scope? : String, headers? : String, abbr? : String, col_span? : Int, row_span? : Int, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn thead(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn time_(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, date_time? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn title(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn tr(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn tspan(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, x? : String, y? : String, dx? : String, dy? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn ul(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], innerHTML? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn use_(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], role? : String, title? : String, tab_index? : Int, hidden? : Bool, aria_label? : String, data_testid? : String, href? : String, xlink_href? : String, x? : String, y? : String, width? : String, height? : String, on_click? : (DOMEvent) -> Unit) -> VirtualNodefn[S, A] use_action_state(initial : S, action : (S, A) -> S) -> (S, (A) -> Unit, Bool)fn[S, A] use_async_action_state(initial : S, action : async (S, A) -> S) -> (S, (A) -> Unit, Bool)fn[T] use_deferred_value(value : T) -> Tfn[F] use_effect_event(callback : F) -> Ffn use_effect_once(effect : () -> Unit) -> Unitfn use_effect_once_with_cleanup(effect : () -> (() -> Unit)) -> Unitfn use_id() -> Stringfn[T] use_imperative_handle_deps(handle_ref : ImperativeRef[T], create_handle : () -> T, deps : Array[JsObscure]) -> Unitfn[S, A] use_optimistic(value : S, reducer : (S, A) -> S) -> (S, (A) -> Unit)fn[S, A] use_reducer_with_initial(initial : S, reducer : (S, A) -> S) -> (S, (A) -> Unit)fn[T] use_state(initial : T) -> (T, (T) -> Unit)fn[T] use_sync_external_store(subscribe : (() -> Unit) -> (() -> Unit), get_snapshot : () -> T, get_server_snapshot? : () -> T) -> Tfn use_transition() -> (Bool, (() -> Unit) -> Unit)fn video(id? : String, class_name? : String, class_list? : Array[String], attrs? : ElementAttrs, event? : ElementEvents, style? : RespoStyle, children : Array[VirtualNode], src? : String, controls? : Bool, autoplay? : Bool, loop_enabled? : Bool, muted? : Bool, width? : String, height? : String, on_click? : (DOMEvent) -> Unit, on_play? : (DOMEvent) -> Unit, on_pause? : (DOMEvent) -> Unit) -> VirtualNodeInstall
Download zipType-safe MoonBit bindings for React with virtual DOM, hooks, and CSS-in-JS support (early experimental)
Dependencies