
components
DataTable
v.1.0.0 | SaturnUsage
<DataTable
variant="DEFAULT"
columns={[
{ field: 'ref', headerContent: 'Ref', textAlign: 'left' },
{ field: 'firstName', headerContent: 'First name' },
{ field: 'lastName', headerContent: 'Last name' },
{ field: 'profile', headerContent: 'Profile' },
]}
rows={[
{ id: '1', ref: '1', firstName: 'John', lastName: 'Snow', profile: 'Admin' },Props
Let's delve into the versatility of the dataTable component by examining all its avalaible props.
| Property | Type | Default | Description |
|---|---|---|---|
| variant | string | - | Current variant of DataTable |
| columns | DataTableColumnType | - | Array of columns |
| rows | DataTableRowType | - | Array of rows |
| rowGroups | DataTableRowGroupType | - | Array of rowGroups |
| activeRows | string | - | Array of active rows. Referenced by the row id |
| hoverable | boolean | - | Generable hoverable prop for table body rows |
| hoverableRows | string | - | When defined, only these rows will be hoverable |
| nonHoverableRows | string | - | When defined, these rows will not be hoverable |
| stickyHead | boolean | - | When true, table head will be sticky |
| caption | DataTableTableCaptionType | - | Main table caption |
| config | DataTableConfigType | - | Allow to configure table, tableHead, tableHeadRow and tableBody extra props |
| aria-label | string | - | Only when it has scroll, scrollable container aria label |
| aria-labelledby | string | - | Only when it has scroll, scrollable container aria labelled by |
| dataTestId | string | dataTable | Id for testing |
| ctv | string | - | Modify styles for the component |
Types
DataTableColumnType
DataTableColumnType allows configure a column of a dataTable:
- field: string. The column identifier. It's used to map with the row cell value.
- headerContent?: DataTableCellValueType. Content to be displayed in the header cell.
- headerHiddenContent?: string. Content to be displayed in the header cell when headen. Usefull for screen readers when the header has focusable elements.
- width?: string. The width of the column.
- minWidth?: string. The minimum width of the column.
- maxWidth?: string. The maximum width of the column.
- hidden?: boolean. Hide the column header.
- sticky?: boolean. Make the column sticky.
- textAlign?: string. The text align of the header cell.
- valueTextAlign?: string. The text align of the value cell.
- valueGetter?: (value: DataTableCellValueType, row: DataTableRowType) => DataTableCellValueType. Function to get the value of the cell.
DataTableRowType
DataTableRowType allows configure a row of a dataTable:
- id?: string. The row identifier.
- config?: DataTableTableRowConfigType. This prop allows to override the row configuration.
- [key: string]: DataTableCellValueType | DataTableTableRowConfigType. This generate the map between the column and the header value
DataTableRowGroupType
DataTableRowGroupType allows configure a row group of a dataTable:
- divider?: DataTableRowDividerType. The divider of the row group.
- caption?: DataTableTableCaptionType. The caption of the row group.
- config?: This prop allows to override the row group configuration for the table and tableBody.
- rows: DataTableRowType[]. The rows of the row group.
DataTableConfigType
DataTableConfigType allows overrride the datatable configuration:
- table?: DataTableTableConfigType. This prop allows sto override the table configuration.
- tableHead?: DataTableTableHeadConfigType. This prop allows to override the table head configuration.
- tableHeadRow?: DataTableTableRowConfigType. This prop allows to override the table head row configuration.
- tableBody?: DataTableTableBodyConfigType. This prop allows sto override the table body configuration.
DataTableCellValueType
DataTableCellValueType represents the cell value in a dataTable. It can be a simple value like a string or JSX.Element or a complex one, using the complex prop.
- React.ReactNode | { complex?: DataTableCellType }
DataTableTableRowConfigType
DataTableTableRowConfigType allows to override a row configuration using the tableRow type, ITableRow.
DataTableRowDividerType
DataTableRowDividerType allows to configure a row divider using the tableDivider type, ITableDivider.
DataTableTableCaptionType
DataTableTableCaptionType allows to configure a table caption using the tableCaption type, ITableCaption.
DataTableTableConfigType
DataTableTableConfigType allows to configure a table using the table type, ITableV2.
DataTableTableHeadConfigType
DataTableTableHeadConfigType allows to configure a table head using the tableHead type, ITableHead.
DataTableTableBodyConfigType
DataTableTableBodyConfigType allows to configure a table body using the tableBody type, ITableBody.