diff --git a/packages/raystack/components/data-table/components/virtualized-content.tsx b/packages/raystack/components/data-table/components/virtualized-content.tsx index b1ac0e98d..6128b1772 100644 --- a/packages/raystack/components/data-table/components/virtualized-content.tsx +++ b/packages/raystack/components/data-table/components/virtualized-content.tsx @@ -10,6 +10,7 @@ import tableStyles from '~/components/table/table.module.css'; import { Badge } from '../../badge'; import { EmptyState } from '../../empty-state'; import { Flex } from '../../flex'; +import { Skeleton } from '../../skeleton'; import styles from '../data-table.module.css'; import { DataTableColumnDef, @@ -154,6 +155,47 @@ function VirtualRows({ }); } +function VirtualLoaderRows({ + rowCount, + columns, + rowHeight, + startTop +}: { + rowCount: number; + columns: DataTableColumnDef[]; + rowHeight: number; + startTop: number; +}) { + const rows = Array.from({ length: rowCount }); + + return rows.map((_, rowIndex) => ( +
+ {columns.map((col, colIndex) => ( +
+ +
+ ))} +
+ )); +} + const DefaultEmptyComponent = () => ( } heading='No Data' /> ); @@ -167,8 +209,14 @@ export function VirtualizedContent({ zeroState, classNames = {} }: VirtualizedContentProps) { - const { onRowClick, table, isLoading, loadMoreData, tableQuery } = - useDataTable(); + const { + onRowClick, + table, + isLoading, + loadMoreData, + tableQuery, + loadingRowCount = 3 + } = useDataTable(); const headerGroups = table?.getHeaderGroups(); const rowModel = table?.getRowModel(); @@ -215,6 +263,12 @@ export function VirtualizedContent({ return
{stateToShow}
; } + const showLoaderRows = isLoading && rows.length > 0; + const loaderRowsHeight = showLoaderRows ? loadingRowCount * rowHeight : 0; + const virtualTotalSize = virtualizer.getTotalSize(); + const totalHeight = virtualTotalSize + loaderRowsHeight; + const visibleColumns = table.getVisibleLeafColumns(); + return (
+ {showLoaderRows && ( + col.columnDef as DataTableColumnDef + )} + rowHeight={rowHeight} + startTop={virtualTotalSize} + /> + )}
diff --git a/packages/raystack/components/data-table/data-table.module.css b/packages/raystack/components/data-table/data-table.module.css index a9145f902..b57c5b204 100644 --- a/packages/raystack/components/data-table/data-table.module.css +++ b/packages/raystack/components/data-table/data-table.module.css @@ -82,6 +82,7 @@ overflow-x: auto; position: relative; height: 100%; + overscroll-behavior: auto; } .stickyHeader {