Sign in

    yami_kumo

    Pure MoonBit HTML components matching a pinned subset of Cloudflare Kumo

    Download zip
    Author
    Version
    0.1.0
    License
    MIT
    Last updated
    9 hours ago
    Downloads
    26

    #Yami-kumo MoonBit components

    Yami-kumo is a pure MoonBit library for rendering safe HTML with a semantic application shell and a pinned subset of Cloudflare Kumo components. The root package has no React or npm dependency.

    Install the module with:

    moon add f4ah6o/yami_kumo

    #Render an application shell

    let brand = @yami_kumo.text("Workspace")
    let main = @yami_kumo.text_component(
    @yami_kumo.text("Project settings"),
    variant=@yami_kumo.Heading,
    size=@yami_kumo.Lg,
    )
    let shell = @yami_kumo.app_shell(brand, main)
    let html = @yami_kumo.render_html(shell)

    The HTML API validates element and attribute names, rejects unsafe URL schemes, and escapes text and attribute values. It has no raw-HTML or inline-style escape hatch.

    The component API currently includes Button, Input, Text, and LayerCard. Input requires a caller-provided stable id; generated labels and helper/error references remain unique when fields are composed together.

    #Styles and browser input state

    Serve both checked-in stylesheets with your application, loading styles/kumo-standalone.css before styles/yami-kumo-components.css. They are generated from the pinned Cloudflare Kumo 2.14.0 package. The emphasis button classes keep primary and destructive variants compatible with a strict style-src 'self' Content Security Policy.

    For browser input state markers, import f4ah6o/yami_kumo/dom and call @dom.enhance() after inserting the rendered markup. The adapter tracks focus, dirty, filled, touched, and Enter-triggered validity state from native input events. Disabled controls include data-disabled in their rendered markup.

    The library source is MIT licensed; the redistributed Kumo stylesheet retains its upstream license in licenses/cloudflare-kumo-LICENSE.

    Attribute

    pub struct Attribute {
    // private fields
    }

    An escaped HTML attribute created with attr or boolean_attr.

    ButtonVariant

    pub(all) enum ButtonVariant {
    Primary
    Secondary
    Ghost
    Destructive
    SecondaryDestructive
    Outline
    }

    The Kumo Button variants supported by this MoonBit implementation.

    ControlSize

    pub(all) enum ControlSize {
    Xs
    Sm
    Base
    Lg
    }

    Kumo-compatible control sizes supported by Button and Input.

    Html

    pub struct Html {
    // private fields
    }

    A safe HTML tree. Text and attribute values are escaped by render_html.

    HtmlError

    pub enum HtmlError {
    InvalidTag(String)
    InvalidAttributeName(String)
    UnsafeAttribute(String)
    UnsafeUrl(String)
    DuplicateAttribute(String)
    VoidElementHasChildren(String)
    }

    Errors raised when a node, attribute, or URL is unsafe to serialize.

    HtmlNode

    type HtmlNode

    InputVariant

    pub(all) enum InputVariant {
    Default
    Error
    }

    Input appearance. An error message selects Error automatically when the caller leaves this value unspecified.

    TextVariant

    pub(all) enum TextVariant {
    Heading
    Body
    Secondary
    Success
    Error
    Mono
    MonoSecondary
    }

    The Kumo Text variants supported by this MoonBit implementation.

    app_shell

    fn app_shell(brand : Html, main : Html, navigation_trigger? : Html, global_search? : Html, header_actions? : Html, account_menu? : Html, rail? : Html, sidebar? : Html, tabs? : Html, context_panel? : Html, context_panel_label? : String, bottom_bar? : Html, sidebar_collapsed? : Bool, mobile_sidebar_open? : Bool, context_panel_open? : Bool, primary_navigation_label? : String, workspace_navigation_label? : String, close_workspace_navigation_label? : String, close_context_panel_label? : String) -> Html

    Render Yami-kumo's semantic application shell. Optional slots are omitted when absent; localized aria labels and current drawer state are explicit.

    attr

    fn attr(name : String, value : String) -> Result[Attribute, HtmlError]

    Create a text attribute after validating its name and any URL value.

    boolean_attr

    fn boolean_attr(name : String) -> Result[Attribute, HtmlError]

    Create a true HTML boolean attribute such as disabled or hidden. Omit the attribute entirely when its value should be false.

    button

    fn button(children : Html, variant? : ButtonVariant, size? : ControlSize, disabled? : Bool, button_type? : String, class_name? : String, attrs? : Array[Attribute]) -> Html

    Render a Kumo Button as safe HTML. attrs adds ordinary HTML attributes such as id, aria-label, or data-* values.

    element

    fn element(tag : String, attributes : Array[Attribute], children : Array[Html]) -> Result[Html, HtmlError]

    Create a validated HTML element. Script, embedded-document, and custom elements are excluded so callers cannot turn markup into executable code.

    fragment

    fn fragment(children : Array[Html]) -> Html

    Join several nodes without adding a wrapper element.

    input

    fn input(id~ : String, size? : ControlSize, variant? : InputVariant, label? : Html, description? : Html, error? : Html, placeholder? : String, disabled? : Bool, required? : Bool, class_name? : String, attrs? : Array[Attribute]) -> Html

    Render a Kumo Input. Labels, descriptions, and errors are semantic nodes; the field wrapper links them to the control with stable ids.

    layer_card

    fn layer_card(children : Html, layered? : Bool, class_name? : String, attrs? : Array[Attribute]) -> Html

    Render a simple or layered Kumo LayerCard container.

    layer_card_primary

    fn layer_card_primary(children : Html, class_name? : String, attrs? : Array[Attribute]) -> Html

    Render the primary content section used inside a layered LayerCard.

    layer_card_secondary

    fn layer_card_secondary(children : Html, class_name? : String, attrs? : Array[Attribute]) -> Html

    Render the secondary heading section used inside a layered LayerCard.

    render_html

    fn render_html(html : Html) -> Result[String, HtmlError]

    Serialize a safe node to deterministic, escaped HTML.

    text

    fn text(value : String) -> Html

    Create escaped text content.

    text_component

    fn text_component(children : Html, variant? : TextVariant, size? : ControlSize, as_element? : String, bold? : Bool, truncate? : Bool, class_name? : String, attrs? : Array[Attribute]) -> Html

    Render a Kumo Text element with an optional semantic tag override.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io