Compare commits
1 Commits
main
...
update-vie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0946688b1 |
@ -95,7 +95,10 @@ export type ElementProps<TableRowData extends object | CustomRowConfig, TableRow
|
|||||||
selectionBehavior?: 'replace' | 'toggle';
|
selectionBehavior?: 'replace' | 'toggle';
|
||||||
onRowAction?: (key: TableRowKey, row: TableRowData) => void;
|
onRowAction?: (key: TableRowKey, row: TableRowData) => void;
|
||||||
slotEmpty?: React.ReactNode;
|
slotEmpty?: React.ReactNode;
|
||||||
initialNumRowsToShow?: number;
|
viewMoreConfig?: {
|
||||||
|
initialNumRowsToShow: number;
|
||||||
|
numRowsPerPage?: number;
|
||||||
|
};
|
||||||
// collection: TableCollection<string>;
|
// collection: TableCollection<string>;
|
||||||
// children: React.ReactNode;
|
// children: React.ReactNode;
|
||||||
};
|
};
|
||||||
@ -125,7 +128,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
selectionMode = 'single',
|
selectionMode = 'single',
|
||||||
selectionBehavior = 'toggle',
|
selectionBehavior = 'toggle',
|
||||||
slotEmpty,
|
slotEmpty,
|
||||||
initialNumRowsToShow,
|
viewMoreConfig,
|
||||||
// shouldRowRender,
|
// shouldRowRender,
|
||||||
|
|
||||||
// collection,
|
// collection,
|
||||||
@ -141,8 +144,18 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
style,
|
style,
|
||||||
}: 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(viewMoreConfig?.initialNumRowsToShow);
|
||||||
const enableViewMore = numRowsToShow !== undefined;
|
const enableViewMore = viewMoreConfig !== undefined;
|
||||||
|
|
||||||
|
const onViewMoreClick = () => {
|
||||||
|
if (!viewMoreConfig) return;
|
||||||
|
const { numRowsPerPage } = viewMoreConfig;
|
||||||
|
if (numRowsPerPage) {
|
||||||
|
setNumRowsToShow((prev) => (prev ?? 0) + numRowsPerPage);
|
||||||
|
} else {
|
||||||
|
setNumRowsToShow(data.length);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const currentBreakpoints = useBreakpoints();
|
const currentBreakpoints = useBreakpoints();
|
||||||
const shownColumns = columns.filter(
|
const shownColumns = columns.filter(
|
||||||
@ -218,9 +231,7 @@ export const Table = <TableRowData extends object, TableRowKey extends Key>({
|
|||||||
}
|
}
|
||||||
numColumns={shownColumns.length}
|
numColumns={shownColumns.length}
|
||||||
onViewMoreClick={
|
onViewMoreClick={
|
||||||
enableViewMore && numRowsToShow < data.length
|
enableViewMore && numRowsToShow! < data.length ? onViewMoreClick : undefined
|
||||||
? () => setNumRowsToShow(data.length)
|
|
||||||
: undefined
|
|
||||||
}
|
}
|
||||||
// shouldRowRender={shouldRowRender}
|
// shouldRowRender={shouldRowRender}
|
||||||
hideHeader={hideHeader}
|
hideHeader={hideHeader}
|
||||||
|
|||||||
@ -121,7 +121,7 @@ export const TradingRewardHistoryTable = ({
|
|||||||
selectionBehavior="replace"
|
selectionBehavior="replace"
|
||||||
withOuterBorder={withOuterBorder}
|
withOuterBorder={withOuterBorder}
|
||||||
withInnerBorders={withInnerBorders}
|
withInnerBorders={withInnerBorders}
|
||||||
initialNumRowsToShow={5}
|
viewMoreConfig={{ initialNumRowsToShow: 5, numRowsPerPage: 10 }}
|
||||||
withScrollSnapColumns
|
withScrollSnapColumns
|
||||||
withScrollSnapRows
|
withScrollSnapRows
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user