wcl_wdoc 0.11.2-alpha

WCL documentation format — build structured docs with WCL, render to HTML
    export let terminal_widget_textbox = (b) => {
        let row = attr_or(b, "row", 0)
        let col = attr_or(b, "col", 0)
        let rows = attr_or(b, "rows", 3)
        let cols = attr_or(b, "cols", 24)
        let disabled = attr_or(b, "disabled", "false") == "true"
        let value = attr_or(b, "value", "")
        let placeholder = attr_or(b, "placeholder", "")
        let shown = value != "" ? value : placeholder
        let fg = value != "" ? attr_or(b, "foreground_fill", attr_or(b, "label_fill", "#d7e0ff")) : attr_or(b, "muted_fill", attr_or(b, "placeholder_fill", "#94a3b8"))
        let bg = attr_or(b, "background_fill", "#111827")
        let accent = attr_or(b, "accent_fill", "#38bdf8")
        let hover_bg = attr_or(b, "hover_background_fill", bg)
        let base_class = attr_or(b, "class", "wdoc-widget-terminal_textbox")
        let control_class = disabled ? "wdoc-terminal-control wdoc-terminal-control-disabled" : "wdoc-terminal-control"
        let events = disabled ? [] : [{ trigger = "hover", state = "hovered", mode = "while" }]
        let prompt_rows = map(range(0, rows), (i) => {
            kind = "terminal_text",
            id = to_string(b.id) + "_prompt_" + to_string(i),
            row = row + i,
            col = col,
            content = i == 0 ? ">" : " ",
            foreground_fill = accent,
            _wdoc_runtime = "true",
            pointer_events = "none"
        })
        let cursor_col = attr_or(b, "cursor_col", -1)
        let cursor = cursor_col >= 0 ? [{
            kind = "terminal_cursor",
            id = to_string(b.id) + "_cursor",
            row = row,
            col = col + 2 + cursor_col,
            mode = "bar",
            fill = accent,
            _wdoc_runtime = "true",
            pointer_events = "none"
        }] : []
        [
            {
                kind = "group",
                id = to_string(b.id),
                row = row,
                col = col,
                rows = rows,
                cols = cols,
                class = base_class + " " + control_class,
                cursor = disabled ? "default" : "text",
                pointer_events = disabled ? "none" : "all",
                _wdoc_runtime = "true",
                _wdoc_terminal_grid_group = "true",
                events = events,
                children = concat(concat([
                    {
                        kind = "terminal_surface",
                        id = to_string(b.id) + "_surface",
                        row = row,
                        col = col,
                        rows = rows,
                        cols = cols,
                        background_fill = bg,
                        hover_background_fill = hover_bg,
                        _wdoc_runtime = "true"
                    },
                    {
                        kind = "terminal_text",
                        id = to_string(b.id) + "_value",
                        row = row,
                        col = col + 2,
                        cols = cols - 2,
                        content = shown,
                        foreground_fill = fg,
                        _wdoc_runtime = "true",
                        pointer_events = "none"
                    }
                ], prompt_rows), cursor)
            }
        ]
    }