Table of Contents

smudgy:widgets — Text & data display

Generated from smudgy v0.5.6 (smudgy-widgets.d.ts @ 1859aed10d75). Index: scriptref.

Display text, raster images, 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).

Image

export function Image(props: ImageProps, children?: WidgetChildren): SmudgyElement;

A raster image loaded from src. Set width/height for stable layout.

ImageProps

export interface ImageProps {
    src: Bindable<string>;
    width?: Bindable<WidgetLength>;
    height?: Bindable<WidgetLength>;
    content_fit?: "contain" | "cover" | "fill" | "none" | "scale-down";
    filter_method?: "linear" | "nearest";
    opacity?: Bindable<number>;
    rotation?: number;
    children?: WidgetChildren;
}

Props for a raster image (PNG/JPEG/GIF first frame/WebP; a leaf – children are ignored), loaded asynchronously by the host. While loading (or after a failure) the widget renders an empty box honoring the explicit width/height, so set both for stable layout; under the default "shrink" sizing the widget is 0x0 until the image arrives, then jumps to its intrinsic size.

src grammar:

A src fed from a store binding is restricted to descend-only relative/@/ forms, data:, and http(s) – never file paths and never .. – because the binding's producer (e.g. the game, via GMCP) is not the widget's author. Failed or denied sources render the empty placeholder and log one warning; SVG sources are not supported yet.

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 {
    // View-global knobs, meaningless per-item, so not in MapStyle.
    roomSpacing?: Bindable<number>;
    playerColor?: Bindable<string>;
    showDoors?: Bindable<boolean>;
 
    defaultStyle?: Bindable<MapStyle>;
    styles?: Record<string, MapStyle>;
    apply?: Bindable<MapStyleApplication[]>;
    doors?: Bindable<MapDoorState[]>;
    children?: WidgetChildren;
}

Props for the map view (a leaf). The static styles palette names each look once; apply associates palette entries with rooms/exits and is the intended store-bound hot path (small payloads, no re-mount, zoom/pan preserved).

Map view presentation

MapStyle

export interface MapStyle {
    roomFill?: string;
    roomStroke?: string;
    roomStrokeWidth?: number;
    roomOpacity?: number;
    roomBorderRadius?: number;
    connectionColor?: string;
    connectionWidth?: number;
    connectionOpacity?: number;
    doorColor?: string;
    crossAreaLabelVisibility?: "always" | "hover" | "never";
    crossAreaLabelBackground?: string;
}

Presentation channels for individual rooms, connections, and doors. Absent fields inherit defaultStyle, then the widget default. Colors are CSS color strings. Nothing here modifies or syncs the underlying map.

MapExitRef

export interface MapExitRef {
    room: RoomNumber;
    direction: ExitDirection;
}

One Connection selected from either endpoint. room+direction (never ConnectionId) disambiguates parallel Connections, reaches the visible half of outbound cross-area links, and survives JSON store bindings.

MapStyleApplication

export interface MapStyleApplication {
    style: string;
    rooms?: RoomNumber[];
    exits?: MapExitRef[];
    area?: AreaId | string;
}

Associates a named style with rooms and/or exits. Later entries win field-by-field over earlier ones and over defaultStyle.

MapDoorState

export interface MapDoorState {
    exit: MapExitRef;
    closed?: boolean;
    locked?: boolean;
}

Semantic door-state override — state, not style (a door's look comes from doorColor in the styles). Omitted fields retain the persisted map value.

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