diff --git a/src/components/designSystem/Table/HorizontalDataTable.tsx b/src/components/designSystem/Table/HorizontalDataTable.tsx index e576b775e..d340ce8b0 100644 --- a/src/components/designSystem/Table/HorizontalDataTable.tsx +++ b/src/components/designSystem/Table/HorizontalDataTable.tsx @@ -9,7 +9,7 @@ const DEFAULT_COLUMN_WIDTH = 160 const DEFAULT_LEFT_COLUMN_WIDTH = 120 type DataItem = { - id: string + [key: string]: unknown } type RowType = 'header' | 'data' @@ -25,7 +25,7 @@ type DotNestedKeys = ( ? Extract : never -type TColumns = { +type TRows = { content: (item: T) => ReactNode key: DotNestedKeys label: string | ReactNode @@ -33,7 +33,7 @@ type TColumns = { }[] type HorizontalDataTableProps = { - columns: TColumns + rows: TRows data: T[] columnWidth?: number leftColumnWidth?: number @@ -48,7 +48,7 @@ const getRowHeight = (rowType: RowType) => { export const HorizontalDataTable = ({ data = [], - columns = [], + rows = [], leftColumnWidth = DEFAULT_LEFT_COLUMN_WIDTH, columnWidth = DEFAULT_COLUMN_WIDTH, columnIdPrefix = 'column-', @@ -71,20 +71,20 @@ export const HorizontalDataTable = ({ }, []) const tableHeight = useMemo( - () => columns.reduce((acc, item) => acc + getRowHeight(item.type), 0), - [columns], + () => rows.reduce((acc, item) => acc + getRowHeight(item.type), 0), + [rows], ) return (
- {!!columns.length && ( + {!!rows.length && (
- {columns.map((item, index) => ( + {rows.map((item, index) => (
({ transform: `translateX(${virtualColumn.start}px)`, }} > - {columns.map((column, index) => ( + {rows.map((row, index) => (
- {column.content(data[virtualColumn.index])} + {row.content(data[virtualColumn.index])}
))}
diff --git a/src/pages/__devOnly/DesignSystem.tsx b/src/pages/__devOnly/DesignSystem.tsx index e2f28c352..24487574f 100644 --- a/src/pages/__devOnly/DesignSystem.tsx +++ b/src/pages/__devOnly/DesignSystem.tsx @@ -721,7 +721,7 @@ const DesignSystem = () => {