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
-
Column( key: String, label: String, align: option.Option(String), width: option.Option(length.Length), sortable: option.Option(Bool), )
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
-
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)
Values
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 column(key: String, label: String) -> Column
Create a column with a key and display label.
pub fn column_to_prop_value(c: Column) -> node.PropValue
Encode a column to a PropValue dict.
pub fn rows(
t: Table,
r: List(dict.Dict(String, node.PropValue)),
) -> Table
Set the table rows.
pub fn separator_color(t: Table, c: color.Color) -> Table
Set the separator line color.
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.