plushie/widget/table

Table widget builder. Data table with typed columns and children-based rows.

Columns are encoded as a prop. Rows are encoded as table_row children, each containing table_cell children. The rows() setter is a convenience that converts dict-based row data into children at build time. You can also provide table_row children directly.

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

Option type for table properties.

pub type Opt {
  Columns(List(Column))
  Rows(List(dict.Dict(String, node.PropValue)))
  Header(Bool)
  Separator(Bool)
  Width(length.Length)
  Height(length.Length)
  Padding(padding.Padding)
  SortBy(String)
  SortOrder(SortOrder)
  HeaderTextSize(Float)
  RowTextSize(Float)
  CellSpacing(Float)
  RowSpacing(Float)
  SeparatorThickness(Float)
  SeparatorColor(color.Color)
  A11y(a11y.A11y)
}

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.

If rows is set (convenience dict format), they are expanded into table_row/table_cell children. If children are set directly (via with_children), they are used as-is. Both cannot be combined.

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 table_cell(id: String, child: node.Node) -> node.Node

Create a table_cell node containing a single child widget.

pub fn table_row(id: String, cells: List(node.Node)) -> node.Node

Create a table_row node from a list of table_cell children.

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

Set the width.

pub fn with_children(
  t: Table,
  children: List(node.Node),
) -> Table

Set children (table_row nodes) directly.

pub fn with_opts(t: Table, opts: List(Opt)) -> Table

Apply a list of options to a table builder.

Search Document