primait/pyxis-components/5.0.0

NOTE: the latest version is 9.0.3

Prima.Pyxis.Table

Creates a customizable Table component by using predefined Html syntax.

Configuration

type Config msg

Represents the static configuration of the component.

Represents the table skin.

type State

Represents the basic state of the component.

type Row msg

Represents a Row which contains a list of Columns.

type Column msg

Represents a Column which can manage a specific kind of data.

type alias ColSpan =
Int

Represents the colSpan of a column. Alias for Integer.

type Sort

Represents the sort algorithm

type FooterColumn msg

Represents a Footer Column which can manage a specific kind of data.

type FooterRow msg

Represents a Footer Row which contains a list of Columns.

Configuration Helpers

-> Bool
-> List (Header msg)
-> List (Row msg)
-> Bool
-> List (FooterRow msg)
-> Config msg

Returns the config of the component.

...


type Msg =
    SortBy String
...


myTableConfig : Table.Config
myTableConfig =
    let
        headers : List (Table.Header Msg)
        headers =
            List.map (\content -> Table.header (String.toLower content) content SortBy) [ "Country", "Capital city" ]


        rows : List (Table.Row Msg)
        rows =
            List.map (Table.row << List.map Table.columnString ) [ ["Italy", "Rome"], ["France", "Paris"], ["U.K.", "London"] ]


        alternateRows =
            True


        createFooterColumns : List String -> List (Table.FooterColumn Msg)
        createFooterColumns columns =
            List.map (Table.footerColumnString 1) columns


        footer : List (Table.FooterRow Msg)
        footer =
            [ Table.footerRow (createFooterColumns [ "Country", "Capital city" ]) ]


    in
    Table.config Table.defaultType sorting headers rows alternateRows footerColumns


...
initialState : Maybe Sort -> Maybe String -> State

Creates an initial State defined by Sort and Column.

Represents the Default table skin.

Represents the Alternative table skin.

Configuration for Rows & Headers

row : List (Column msg) -> Row msg

Creates a Row

myRow : List (Column Msg) -> Table.Row Msg
myRow columns =
    Table.row columns
footerRow : List (FooterColumn msg) -> FooterRow msg

Creates a FooterRow

myRow : List (FooterColumn Msg) -> Table.footerRow Msg
myRow columns =
    Table.footerRow columns

Configuration for Columns

columnFloat : ColSpan -> Float -> Column msg

Creates a Column which content is Float primitive.

columnHtml : ColSpan -> List (Html msg) -> Column msg

Creates a Column which content is Html.

columnInteger : ColSpan -> Int -> Column msg

Creates a Column which content is Integer primitive.

columnString : ColSpan -> String -> Column msg

Creates a Column which content is String primitive.

footerColumnFloat : ColSpan -> Float -> FooterColumn msg

Creates a FooterColumn which content is Float primitive.

footerColumnHtml : ColSpan -> List (Html msg) -> FooterColumn msg

Creates a FooterColumn which content is Html.

footerColumnInteger : ColSpan -> Int -> FooterColumn msg

Creates a FooterColumn which content is Integer primitive.

footerColumnString : ColSpan -> String -> FooterColumn msg

Creates a FooterColumn which content is String primitive.

Helpers

sort : Maybe Slug -> Maybe Sort -> State -> State

Sets the sorting algorithm for a specific column.

sortAsc : Maybe Sort

Returns the Ascending sort algorithm.

sortDesc : Maybe Sort

Returns the Descending sort algorithm.

Render

render : State -> Config msg -> Html msg

Renders a Table by receiving a State and a Config