feat(SW-441): Added table block component
This commit is contained in:
committed by
Pontus Dreij
parent
ef411b4cf9
commit
dfd40aa7aa
@@ -28,17 +28,20 @@ export const tableSchema = z.object({
|
||||
}),
|
||||
})
|
||||
.transform((data) => {
|
||||
const totalWidth = data.column_widths.reduce(
|
||||
(acc, width) => acc + width,
|
||||
0
|
||||
)
|
||||
const columns = data.table.tableState.columns.map((col, idx) => ({
|
||||
id: col.id,
|
||||
Header: col.label || "",
|
||||
accessor: col.accessor,
|
||||
columnWidth: data.column_widths[idx] || 0,
|
||||
header: col.label || "",
|
||||
width: data.column_widths[idx] || 0,
|
||||
}))
|
||||
|
||||
const rows = data.table.tableState.data.map((rowData) => {
|
||||
const transformedRow: Record<string, string> = {}
|
||||
columns.forEach((col) => {
|
||||
transformedRow[col.accessor] = rowData[col.accessor] || ""
|
||||
columns.forEach((header) => {
|
||||
transformedRow[header.id] = rowData[header.id] || ""
|
||||
})
|
||||
return transformedRow
|
||||
})
|
||||
@@ -46,6 +49,7 @@ export const tableSchema = z.object({
|
||||
return {
|
||||
columns,
|
||||
rows,
|
||||
totalWidth,
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user