Skip to content

Commit c8988a3

Browse files
committed
Pass table meta.
1 parent 88efb3b commit c8988a3

7 files changed

Lines changed: 22 additions & 14 deletions

File tree

src/components/tableV2/core/base-table.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,16 @@ Table.Cell = forwardRef(
259259
(
260260
{
261261
align = "left",
262-
cellStyles = {},
263262
children,
264263
maxWidth,
265264
minWidth,
266265
onClick,
267-
pinnedStyles = {},
268-
styles = {},
269266
width,
270267
isColumnHovering,
271268
isRowHovering,
272269
index,
270+
meta,
271+
tableMeta,
273272
...rest
274273
},
275274
ref
@@ -291,9 +290,12 @@ Table.Cell = forwardRef(
291290
height: "65px",
292291
maxHeight: "65px",
293292
whiteSpace: "nowrap",
294-
...cellStyles,
295-
...pinnedStyles,
296-
...styles,
293+
...tableMeta.cellStyles,
294+
...tableMeta.pinnedStyles,
295+
...tableMeta.styles,
296+
...meta.cellStyles,
297+
...meta.pinnedStyles,
298+
...meta.styles,
297299
}}
298300
width={{
299301
base: `${width || maxWidth}px`,

src/components/tableV2/core/headCell.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ const HeadCell = ({
4848
}) =>
4949
headers.map(({ id, colSpan, getContext, isPlaceholder, column, getResizeHandler, getSize }) => {
5050
const { getCanSort, columnDef, getCanResize, getIsResizing } = column
51-
const { meta } = columnDef
51+
const { meta, tableMeta } = columnDef
5252
const headStyles = {
5353
verticalAlign: "baseline",
54+
...(tableMeta?.headStyles || {}),
5455
...(meta?.headStyles || {}),
5556
...pinnedStyles,
5657
}

src/components/tableV2/core/rows.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ const Rows = ({
8181
width={cell.column.getSize()}
8282
onMouseEnter={() => onHover({ row: row.id, column: cell.column.id })}
8383
onMouseLeave={() => onHover()}
84-
{...cell.column.columnDef.meta}
84+
tableMeta={cell.column.columnDef.tableMeta}
85+
meta={cell.column.columnDef.meta}
8586
{...(cell.column.getCanSort() &&
8687
coloredSortedColumn &&
8788
!!cell.column.getIsSorted() && {

src/components/tableV2/features/useColumns.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { useMemo } from "react"
22
import useRowSelection from "./useRowSelection"
33
import useRowActions from "./useRowActions"
44

5-
export default (dataColumns, { rowActions, enableSelection, testPrefix }) => {
6-
const rowActionsColumn = useRowActions(rowActions, { testPrefix })
7-
const selectionColumn = useRowSelection(enableSelection, { testPrefix })
5+
export default (dataColumns, { rowActions, enableSelection, testPrefix, tableMeta }) => {
6+
const rowActionsColumn = useRowActions(rowActions, { testPrefix, tableMeta })
7+
const selectionColumn = useRowSelection(enableSelection, { testPrefix, tableMeta })
88

99
return useMemo(() => {
1010
if (!dataColumns || dataColumns.length < 1) return []
@@ -22,6 +22,7 @@ export default (dataColumns, { rowActions, enableSelection, testPrefix }) => {
2222
enableHiding: true,
2323
enableResize: true,
2424
footer: props => props.column.id,
25+
tableMeta,
2526
...col,
2627
accessorKey: col.accessorKey || col.id,
2728
}

src/components/tableV2/features/useRowActions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const supportedRowActions = {
4343
},
4444
}
4545

46-
export default (rowActions, { testPrefix } = {}) => {
46+
export default (rowActions, { testPrefix, tableMeta } = {}) => {
4747
const availableRowActions = useMemo(
4848
() =>
4949
Object.keys(rowActions).reduce((acc, key) => {
@@ -90,5 +90,6 @@ export default (rowActions, { testPrefix } = {}) => {
9090
enableColumnFilter: false,
9191
enableSorting: false,
9292
meta: { stopPropagation: true },
93+
tableMeta,
9394
}
9495
}

src/components/tableV2/features/useRowSelection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Checkbox } from "src/components/checkbox"
33

44
const width = 45
55

6-
export default (enabled, { testPrefix }) =>
6+
export default (enabled, { testPrefix, tableMeta }) =>
77
useMemo(
88
() =>
99
enabled
@@ -34,6 +34,7 @@ export default (enabled, { testPrefix }) =>
3434
maxSize: width,
3535
minSize: width,
3636
meta: { stopPropagation: true },
37+
tableMeta,
3738
}
3839
: null,
3940
[enabled]

src/components/tableV2/netdataTable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const NetdataTable = ({
5959
testPrefixCallback,
6060
virtualizeOptions = {},
6161
coloredSortedColumn = true,
62+
meta: tableMeta = {},
6263
...rest
6364
}) => {
6465
const [columnVisibility, setColumnVisibility] = useState(defaultColumnVisibility)
@@ -115,7 +116,7 @@ const NetdataTable = ({
115116
setGlobalFilter(String(value))
116117
}, [])
117118

118-
const columns = useColumns(dataColumns, { testPrefix, enableSelection, rowActions })
119+
const columns = useColumns(dataColumns, { testPrefix, enableSelection, rowActions, tableMeta })
119120

120121
const table = useReactTable({
121122
columns,

0 commit comments

Comments
 (0)