Skip to content

Commit

Permalink
v4.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
novykh committed Jan 10, 2025
1 parent cd7367e commit 7680dc9
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 84 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netdata/netdata-ui",
"version": "4.8.5",
"version": "4.8.6",
"description": "netdata UI kit",
"main": "dist/index.js",
"module": "dist/es6/index.js",
Expand Down
183 changes: 100 additions & 83 deletions src/components/table/body/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default memo(
index,
zIndex,
onHoverCell,
renderSubComponent,
...rest
}) => {
useTableState(rerenderSelector)
Expand All @@ -108,94 +109,110 @@ export default memo(
}, [row, onClickRow])

return (
<Flex
data-testid={`netdata-table-row${testPrefix}${
testPrefixCallback ? "-" + testPrefixCallback(row.original) : ""
}`}
onClick={useCallback(
isClickable
? () => onClickRow({ data: row.original, table: table, fullRow: row })
: undefined,
[isClickable, row, onClickRow]
)}
cursor={isClickable ? "pointer" : "default"}
onMouseEnter={() => onHoverCell?.({ row: row.index })}
onMouseLeave={() => onHoverCell?.({ row: null })}
flex
>
{!!row.getLeftVisibleCells().length && (
<Flex
position="sticky"
left={0}
border={{ side: "right" }}
zIndex={zIndex || 1}
basis={`${table.getLeftTotalSize()}px`}
flex={false}
background={index % 2 === 0 ? "tableRowBg2" : "tableRowBg"}
_hover={{
background: index % 2 === 0 ? "tableRowBg2Hover" : "tableRowBgHover",
}}
>
{row.getLeftVisibleCells().map((cell, index) => (
<CellGroup
cell={cell}
row={row}
key={cell.id}
testPrefix={testPrefix}
header={table.getLeftLeafHeaders()[index]}
{...rest}
/>
))}
</Flex>
)}
<>
<Flex
width={`${table.getCenterTotalSize()}px`}
flex="grow"
background={index % 2 === 0 ? "tableRowBg2" : "tableRowBg"}
_hover={{
background: index % 2 === 0 ? "tableRowBg2Hover" : "tableRowBgHover",
}}
data-testid={`netdata-table-row${testPrefix}${
testPrefixCallback ? "-" + testPrefixCallback(row.original) : ""
}`}
onClick={useCallback(
isClickable
? e => onClickRow({ data: row.original, table: table, fullRow: row }, e)
: undefined,
[isClickable, row, onClickRow]
)}
cursor={isClickable ? "pointer" : "default"}
onMouseEnter={() => onHoverCell?.({ row: row.index })}
onMouseLeave={() => onHoverCell?.({ row: null })}
flex
column
>
<Flex flex>
{row.getCenterVisibleCells().map((cell, index) => (
<CellGroup
cell={cell}
row={row}
key={cell.id}
testPrefix={testPrefix}
header={table.getCenterLeafHeaders()[index]}
{...rest}
/>
))}
{!!row.getLeftVisibleCells().length && (
<Flex
position="sticky"
left={0}
border={{ side: "right" }}
zIndex={zIndex || 1}
basis={`${table.getLeftTotalSize()}px`}
flex={false}
background={index % 2 === 0 ? "tableRowBg2" : "tableRowBg"}
_hover={{
background: index % 2 === 0 ? "tableRowBg2Hover" : "tableRowBgHover",
}}
>
{row.getLeftVisibleCells().map((cell, index) => (
<CellGroup
cell={cell}
row={row}
key={cell.id}
testPrefix={testPrefix}
header={table.getLeftLeafHeaders()[index]}
{...rest}
/>
))}
</Flex>
)}
<Flex
width={`${table.getCenterTotalSize()}px`}
flex="grow"
background={index % 2 === 0 ? "tableRowBg2" : "tableRowBg"}
_hover={{
background: index % 2 === 0 ? "tableRowBg2Hover" : "tableRowBgHover",
}}
>
<Flex flex>
{row.getCenterVisibleCells().map((cell, index) => (
<CellGroup
cell={cell}
row={row}
key={cell.id}
testPrefix={testPrefix}
header={table.getCenterLeafHeaders()[index]}
{...rest}
/>
))}
</Flex>
</Flex>
{!!row.getRightVisibleCells().length && (
<Flex
position="sticky"
right={0}
border={{ side: "left" }}
zIndex={zIndex || 1}
basis={`${table.getRightTotalSize()}px`}
flex={false}
background={index % 2 === 0 ? "tableRowBg2" : "tableRowBg"}
_hover={{
background: index % 2 === 0 ? "tableRowBg2Hover" : "tableRowBgHover",
}}
rowReverse
>
{row.getRightVisibleCells().map((cell, index) => (
<CellGroup
cell={cell}
row={row}
key={cell.id}
testPrefix={testPrefix}
header={table.getRightLeafHeaders()[index]}
{...rest}
/>
))}
</Flex>
)}
</Flex>
{renderSubComponent && row.getIsExpanded() && (
<Flex
flex
data-testid={`netdata-table-sub-row${testPrefix}${
testPrefixCallback ? "-" + testPrefixCallback(row.original) : ""
}`}
onClick={e => e.stopPropagation()}
>
{renderSubComponent({ data: row.original, table, fullRow: row })}
</Flex>
)}
</Flex>
{!!row.getRightVisibleCells().length && (
<Flex
position="sticky"
right={0}
border={{ side: "left" }}
zIndex={zIndex || 1}
basis={`${table.getRightTotalSize()}px`}
flex={false}
background={index % 2 === 0 ? "tableRowBg2" : "tableRowBg"}
_hover={{
background: index % 2 === 0 ? "tableRowBg2Hover" : "tableRowBgHover",
}}
rowReverse
>
{row.getRightVisibleCells().map((cell, index) => (
<CellGroup
cell={cell}
row={row}
key={cell.id}
testPrefix={testPrefix}
header={table.getRightLeafHeaders()[index]}
{...rest}
/>
))}
</Flex>
)}
</Flex>
</>
)
}
)
2 changes: 2 additions & 0 deletions src/components/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const Table = memo(
tableRef,
className,
width,
getRowCanExpand,
...rest
} = { ...tableDefaultProps, ...props }

Expand Down Expand Up @@ -191,6 +192,7 @@ const Table = memo(
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getExpandedRowModel: getExpandedRowModel(),
getRowCanExpand,
getGroupedRowModel: getGroupedRowModel(),
getSubRows: useCallback(row => row.children, []),
onPaginationChange,
Expand Down

0 comments on commit 7680dc9

Please sign in to comment.