There are 2 breaking changes as part of the latest release:
NEW PROP: columns
to replace BpkDataTableColumn
children.
Pass columns
prop as an array of objects instead of passing the columns as children.
export default () => (
<BpkDataTable rows={rows} height={"12.5rem"} onRowClick={onRowClick}>
<BpkDataTableColumn
label={'Name'}
dataKey={'name'}
width={{"6.25rem"}}
disableSort
/>
<BpkDataTableColumn
label={'Description'}
dataKey={'description'}
width={{"6.25rem"}}
flexGrow={1}
/>
</BpkDataTable>
);
to
export default () => (
<BpkDataTable
rows={rows}
height={"12.5rem"}
onRowClick={onRowClick}
columns={[
{
label: 'name',
accessor: 'name',
width: '6.25rem',
disableSortBy: true
},
...
]}
/>
);
columns
is an array of Objects with the following schema:
{
Header: function({disableSortBy, accessor, label}),
accessor: string,
Cell: function({rowData, rowIndex, accessor, columnIndex, cellData}),
className: string,
disableSortBy: boolean,
defaultSortDirection: oneOf('ASC', 'DESC'),
flexGrow: number,
headerClassName: string,
headerStyle: Object,
label: string,
minWidth: string,
style: Object,
width: string,
}
The schema differs from the old BpkDataTableColumn
as follows:
disableSort
renamed todisableSortBy
dataKey
renamed toaccessor
headerRenderer
is removed. Use theHeader
prop instead to pass a function that formats the header value. If you pass a function, it will receive thedisableSortBy
,accessor
, andlabel
props of the column. Must return valid JSX.cellRenderer
andcellDataGetter
are removed. Use theCell
prop instead to pass a function that formats the column value. It will receive therowData
androwIndex
of the cell's row,accessor
andcolumnIndex
of the cell's column,cellData
props. Must return valid JSX.
All height and width properties should be using rem
values.