1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 13:29:41 +02:00

chore(deps): upgrade react-table to v8 [EE-4837] (#8245)

This commit is contained in:
Chaim Lev-Ari 2023-05-02 13:42:16 +07:00 committed by GitHub
parent f20d3e72b9
commit 757461d58b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
140 changed files with 1805 additions and 2872 deletions

View file

@ -1,27 +1,28 @@
import {
useTable,
useFilters,
useSortBy,
Column,
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
TableOptions,
TableState,
usePagination,
} from 'react-table';
useReactTable,
} from '@tanstack/react-table';
import { defaultGetRowId } from './defaultGetRowId';
import { Table } from './Table';
import { multiple } from './filter-types';
import { NestedTable } from './NestedTable';
import { DatatableContent } from './DatatableContent';
import { defaultGetRowId } from './defaultGetRowId';
import { BasicTableSettings } from './types';
interface Props<D extends Record<string, unknown>> {
dataset: D[];
columns: readonly Column<D>[];
columns: TableOptions<D>['columns'];
getRowId?(row: D): string;
emptyContentLabel?: string;
initialTableState?: Partial<TableState<D>>;
initialTableState?: Partial<TableState>;
isLoading?: boolean;
defaultSortBy?: string;
initialSortBy?: BasicTableSettings['sortBy'];
}
export function NestedDatatable<D extends Record<string, unknown>>({
@ -31,25 +32,26 @@ export function NestedDatatable<D extends Record<string, unknown>>({
emptyContentLabel,
initialTableState = {},
isLoading,
defaultSortBy,
initialSortBy,
}: Props<D>) {
const tableInstance = useTable<D>(
{
defaultCanFilter: false,
columns,
data: dataset,
filterTypes: { multiple },
initialState: {
sortBy: defaultSortBy ? [{ id: defaultSortBy, desc: true }] : [],
...initialTableState,
},
autoResetSelectedRows: false,
getRowId,
const tableInstance = useReactTable<D>({
columns,
data: dataset,
initialState: {
sorting: initialSortBy ? [initialSortBy] : [],
...initialTableState,
},
useFilters,
useSortBy,
usePagination
);
defaultColumn: {
enableColumnFilter: false,
enableHiding: false,
},
getRowId,
autoResetExpanded: false,
getCoreRowModel: getCoreRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getSortedRowModel: getSortedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
});
return (
<NestedTable>
@ -58,15 +60,7 @@ export function NestedDatatable<D extends Record<string, unknown>>({
tableInstance={tableInstance}
isLoading={isLoading}
emptyContentLabel={emptyContentLabel}
renderRow={(row, { key, className, role, style }) => (
<Table.Row<D>
cells={row.cells}
key={key}
className={className}
role={role}
style={style}
/>
)}
renderRow={(row) => <Table.Row<D> cells={row.getVisibleCells()} />}
/>
</Table.Container>
</NestedTable>