plushie/widget/table

Table widget builder. Data table with typed columns and row maps.

Columns and rows are encoded as props (list of maps), not as child nodes. The Rust renderer expects this structure.

Types

A table column definition.

pub type Column {
  Column(
    key: String,
    label: String,
    align: option.Option(String),
    width: option.Option(length.Length),
    sortable: option.Option(Bool),
  )
}

Constructors

pub type SortOrder {
  Asc
  Desc
}

Constructors

  • Asc
  • Desc
pub opaque type Table

Values

pub fn a11y(t: Table, a: a11y.A11y) -> Table

Set accessibility properties for this widget.

pub fn build(t: Table) -> node.Node

Build the table into a renderable Node.

pub fn cell_spacing(t: Table, s: Float) -> Table

Set the horizontal spacing between cells.

pub fn column(key: String, label: String) -> Column

Create a column with a key and display label.

pub fn column_align(c: Column, align: String) -> Column

Set the column text alignment.

pub fn column_sortable(c: Column, s: Bool) -> Column

Set whether the column is sortable.

pub fn column_to_prop_value(c: Column) -> node.PropValue

Encode a column to a PropValue dict.

pub fn column_width(c: Column, w: length.Length) -> Column

Set the column width.

pub fn columns(t: Table, cols: List(Column)) -> Table

Set the number of columns.

pub fn header(t: Table, h: Bool) -> Table

Set whether the header row is shown.

pub fn header_text_size(t: Table, s: Float) -> Table

Set the header text size.

pub fn height(t: Table, h: length.Length) -> Table

Set the height.

pub fn new(id: String) -> Table

Create a new table builder.

pub fn padding(t: Table, p: padding.Padding) -> Table

Set the padding.

pub fn row_spacing(t: Table, s: Float) -> Table

Set the vertical spacing between rows.

pub fn row_text_size(t: Table, s: Float) -> Table

Set the row text size.

pub fn rows(
  t: Table,
  r: List(dict.Dict(String, node.PropValue)),
) -> Table

Set the table rows.

pub fn separator(t: Table, s: Bool) -> Table

Set whether row separators are shown.

pub fn separator_color(t: Table, c: color.Color) -> Table

Set the separator line color.

pub fn separator_thickness(t: Table, s: Float) -> Table

Set the separator line thickness.

pub fn sort_by(t: Table, key: String) -> Table

Set the column key to sort by.

pub fn sort_order(t: Table, order: SortOrder) -> Table

Set the sort order.

pub fn width(t: Table, w: length.Length) -> Table

Set the width.

Search Document