Compare commits
1 Commits
main
...
fix-table-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c6508f574 |
@ -125,7 +125,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
selectionMode = 'single',
|
selectionMode = 'single',
|
||||||
selectionBehavior = 'toggle',
|
selectionBehavior = 'toggle',
|
||||||
slotEmpty,
|
slotEmpty,
|
||||||
initialNumRowsToShow = data.length,
|
initialNumRowsToShow,
|
||||||
// shouldRowRender,
|
// shouldRowRender,
|
||||||
|
|
||||||
// collection,
|
// collection,
|
||||||
@ -142,6 +142,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
}: ElementProps<TableRowData, TableRowKey> & StyleProps) => {
|
}: ElementProps<TableRowData, TableRowKey> & StyleProps) => {
|
||||||
const [selectedKeys, setSelectedKeys] = useState(new Set<TableRowKey>());
|
const [selectedKeys, setSelectedKeys] = useState(new Set<TableRowKey>());
|
||||||
const [numRowsToShow, setNumRowsToShow] = useState(initialNumRowsToShow);
|
const [numRowsToShow, setNumRowsToShow] = useState(initialNumRowsToShow);
|
||||||
|
const enableViewMore = numRowsToShow !== undefined;
|
||||||
|
|
||||||
const currentBreakpoints = useBreakpoints();
|
const currentBreakpoints = useBreakpoints();
|
||||||
const shownColumns = columns.filter(
|
const shownColumns = columns.filter(
|
||||||
@ -217,7 +218,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
}
|
}
|
||||||
numColumns={shownColumns.length}
|
numColumns={shownColumns.length}
|
||||||
onViewMoreClick={
|
onViewMoreClick={
|
||||||
numRowsToShow !== undefined && numRowsToShow < data.length
|
enableViewMore && numRowsToShow < data.length
|
||||||
? () => setNumRowsToShow(data.length)
|
? () => setNumRowsToShow(data.length)
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
@ -245,7 +246,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
)}
|
)}
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
|
|
||||||
<TableBody items={list.items.slice(0, numRowsToShow)}>
|
<TableBody items={enableViewMore ? list.items.slice(0, numRowsToShow) : list.items}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<Row key={getRowKey(item)}>
|
<Row key={getRowKey(item)}>
|
||||||
{(columnKey) => (
|
{(columnKey) => (
|
||||||
@ -982,4 +983,4 @@ Styled.ViewMoreButton = styled(Button)`
|
|||||||
width: 0.675rem;
|
width: 0.675rem;
|
||||||
margin-left: 0.5ch;
|
margin-left: 0.5ch;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user