PaackEng/paack-ui/3.2.0

NOTE: the latest version is 7.23.0

UI.Tables.Common

Desktop

type alias Columns columns =
NArray Column columns

Array with all the columns from a table.

This is a type-safe sized-array. See TypeNumbers for how to compose its phantom type.

columnsEmpty : Columns Zero

An empty Columns set.

columnsEmpty
    |> column "Star" (columnWidthPortion 3)
    |> column "Constellation" (columnWidthPortion 3)
    |> column "Distance" (columnWidthPortion 2)
String
-> ColumnWidth
-> Columns columns
-> Columns (Increase columns)

Appends a new column to the list of columns, defining its header's label and the entire column's width.

columnsEmpty
    |> column "Name" (columnWidthPortion 3)
    |> column "Age" (columnWidthPortion 1)

Individual column

type alias ColumnWidth =
ColumnWidth

ColumnWidth specifies a cell's width.

columnWidthPortion : Int -> ColumnWidth

Similar to Element.fillPortion but applied to an entire Table's column.

columnsEmpty
    |> column "Title" (columnWidthPortion 3)
    |> column "Author" (columnWidthPortion 3)
    |> column "Year" (columnWidthPortion 2)
columnWidthPixels : Int -> ColumnWidth

Similar to Element.px but applied to an entire Table's column.

columnEmpty
    |> column "Name" (columnWidthPixels 320)
    |> column "Length" (columnWidthPixels 240)
    |> column "Population" (columnWidthPixels 240)

Desktop rows

type alias Row msg columns =
NArray (Cell msg) columns

Array with all the cells in a single row.

This is a type-safe sized-array. See TypeNumbers for how to compose the phantom type.

type alias ToRow msg item columns =
{ toKey : item -> String
, view : item -> Row msg columns
}

Helper for composing a map function for a single row.

rowEmpty : Row msg Zero

An empty set of cells for a row.

rowEmpty
    |> rowCellText (Text.body1 "Hello")
    |> rowCellText (Text.body2 "World")
rowCellText : Text -> Row msg columns -> Row msg (Increase columns)

Transforms a UI.Text into a cell appending it to a row.

Similar to cellFromText but infused for rows.

rowEmpty
    |> rowCellText (Text.body1 "Coffee")
    |> rowCellText (Text.body2 "Brazil")
rowCellButton : Button msg -> Row msg columns -> Row msg (Increase columns)

Transforms a UI.Button into a cell appending it to a row.

Similar to cellFromButton but infused for rows.

rowEmpty
    |> rowCellText (Text.body1 "Aldebaran")
    |> rowCellButton
        ("See in Stellarium"
            |> Button.fromText
            |> Button.redirect "stellarium://gj/9159"
                Button.hyperlink
        )
rowCellCustom : Element msg -> Row msg columns -> Row msg (Increase columns)

Transforms any Element msg into a cell appending it to a row.

Similar to cellFromCustom but infused for rows.

rowEmpty
    |> rowCellText (Text.body1 "Aldebaran")
    |> rowCellCustom (Element.text "Hello")

Individual cell

type alias Cell msg =
Cell msg

A singular cell of a table. Can hold texts, buttons or any custom Element msg.

cellFromText : Text -> Cell msg

Creates a cell with some text content.

Text may be ellipsized to fit cell's width.

cellFromText <| Text.body2 "Watermelon"
cellFromButton : Button msg -> Cell msg

Creates a cell with a button inside.

Button.fromText "Delete"
    |> Button.cmd Msg.Delete Button.danger
    |> cellFromButton
cellFromCustom : Element msg -> Cell msg

Creates a cell with an Element msg inside.

cellFromCustom <| Element.row [] [ Element.text "Hello", Element.text "World" ]