Table of Contents

smudgy:widgets — Text & data display

Generated from smudgy v0.4.2-dev (smudgy-widgets.d.ts @ e96061b683ea). Index: scriptref.

Display text, Markdown, progress values, tabular data, and the current session map.

Wrap a tall Table in Scrollable. For a table example, see Add controls and tables to a widget.

Components

Text

export function Text(props?: TextProps, children?: WidgetChildren): SmudgyElement;

A run of (optionally colored) text.

TextProps

export interface TextProps {
    color?: Bindable<string>;
    size?: Bindable<number>;
    children?: WidgetChildren;
}

Props for a run of text. The children are concatenated as the text content.

Markdown

export function Markdown(props?: MarkdownProps, children?: WidgetChildren): SmudgyElement;

A rendered Markdown document. Children are concatenated as the Markdown source.

MarkdownProps

export interface MarkdownProps {
    size?: Bindable<number>;
    onLink?: (url: string) => void;
    children?: WidgetChildren;
}

Props for a rendered Markdown document. The children are concatenated as the source.

Styling follows the terminal color scheme. Links render as clickable command chips, and code renders monospace on a panel; a fenced block whose opening fence names a language (like js) is syntax-highlighted.

Links can stand in for MUD commands, two ways:

Real URLs (<http://...>) stay ordinary links, and inline code / fenced code blocks are left literal.

ProgressBar

export function ProgressBar(props?: ProgressBarProps, children?: WidgetChildren): SmudgyElement;

A progress/health bar.

ProgressBarProps

export interface ProgressBarProps {
    min?: Bindable<number>;
    max?: Bindable<number>;
    value?: Bindable<number>;
    background?: Bindable<string>;
    color?: Bindable<string>;
    width?: Bindable<WidgetLength>;
    height?: Bindable<WidgetLength>;
    vertical?: boolean;
}

Props for a progress/health bar (a leaf – children are ignored).

Table

export function Table(props: TableProps, children?: WidgetChildren): SmudgyElement;

A data table: columns as records, rows as arrays of cells.

TableCell

export type TableCell =
| SmudgyElement
| string
| number
| boolean
| Binding<any>
| null
| undefined;

One value in a table cell. Elements, text, numbers, and bindings display as content. Null, undefined, and false produce an empty cell; true displays as text.

TableColumnSpec

export interface TableColumnSpec {
    header?: TableCell;
    width?: WidgetLength;
    align_x?: HorizontalAlign;
    align_y?: VerticalAlign;
}

One table column: its header plus optional layout.

TableProps

export interface TableProps {
    columns: TableColumnSpec[];
    rows?: TableCell[][];
    width?: Bindable<WidgetLength>;
    padding?: number;
    separator?: number;
    children?: WidgetChildren;
}

Props for a data table (a leaf; children are ignored).

Supply each row as an array in column order. A bound cell repaints when its value changes. Re-mount the widget when rows are added, removed, or reordered. A row with more cells than columns is invalid; a shorter row is padded with empty cells. Wrap a tall table in Scrollable.

MapView

export function MapView(props?: MapViewProps, children?: WidgetChildren): SmudgyElement;

The map view for the current session.

MapViewProps

export interface MapViewProps {
    children?: WidgetChildren;
}

Props for the map view (a leaf – props and children are ignored).

Working with Markdown

export function extractMarkdownLinks(source: string): MarkdownLink[];

The links source contains when read as a Markdown document, in order: exactly the links a Markdown widget shows for it, including bare <command> links, with backslash escapes honored and inline code / fenced code left literal. Use it to act on the same links a widget displays, like running the first link in a room's notes.

export interface MarkdownLink {
    label: string;
    url: string;
}

One link in a Markdown document, as extractMarkdownLinks reports it.


Script API reference · ← smudgy:widgets — Controls · smudgy:widgets — Canvas → · Scripting manual