mirror of https://github.com/portainer/portainer
feat(ui/datatables): support meta for expandable table
parent
86a848d927
commit
f780207b82
|
@ -1,4 +1,4 @@
|
||||||
import { Row } from '@tanstack/react-table';
|
import { Row, TableMeta } from '@tanstack/react-table';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
import { ExpandableDatatableTableRow } from './ExpandableDatatableRow';
|
import { ExpandableDatatableTableRow } from './ExpandableDatatableRow';
|
||||||
|
@ -9,20 +9,25 @@ import {
|
||||||
} from './Datatable';
|
} from './Datatable';
|
||||||
import { DefaultType } from './types';
|
import { DefaultType } from './types';
|
||||||
|
|
||||||
interface Props<D extends DefaultType>
|
interface Props<
|
||||||
extends Omit<DatatableProps<D>, 'renderRow' | 'expandable'> {
|
D extends DefaultType,
|
||||||
|
TMeta extends TableMeta<D> = TableMeta<D>
|
||||||
|
> extends Omit<DatatableProps<D, TMeta>, 'renderRow' | 'expandable'> {
|
||||||
renderSubRow(row: Row<D>): ReactNode;
|
renderSubRow(row: Row<D>): ReactNode;
|
||||||
expandOnRowClick?: boolean;
|
expandOnRowClick?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExpandableDatatable<D extends DefaultType>({
|
export function ExpandableDatatable<
|
||||||
|
D extends DefaultType,
|
||||||
|
TMeta extends TableMeta<D> = TableMeta<D>
|
||||||
|
>({
|
||||||
renderSubRow,
|
renderSubRow,
|
||||||
getRowCanExpand = () => true,
|
getRowCanExpand = () => true,
|
||||||
expandOnRowClick,
|
expandOnRowClick,
|
||||||
...props
|
...props
|
||||||
}: Props<D> & PaginationProps) {
|
}: Props<D, TMeta> & PaginationProps) {
|
||||||
return (
|
return (
|
||||||
<Datatable<D>
|
<Datatable<D, TMeta>
|
||||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||||
{...props}
|
{...props}
|
||||||
getRowCanExpand={getRowCanExpand}
|
getRowCanExpand={getRowCanExpand}
|
||||||
|
|
Loading…
Reference in New Issue