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 { ExpandableDatatableTableRow } from './ExpandableDatatableRow';
|
||||
|
@ -9,20 +9,25 @@ import {
|
|||
} from './Datatable';
|
||||
import { DefaultType } from './types';
|
||||
|
||||
interface Props<D extends DefaultType>
|
||||
extends Omit<DatatableProps<D>, 'renderRow' | 'expandable'> {
|
||||
interface Props<
|
||||
D extends DefaultType,
|
||||
TMeta extends TableMeta<D> = TableMeta<D>
|
||||
> extends Omit<DatatableProps<D, TMeta>, 'renderRow' | 'expandable'> {
|
||||
renderSubRow(row: Row<D>): ReactNode;
|
||||
expandOnRowClick?: boolean;
|
||||
}
|
||||
|
||||
export function ExpandableDatatable<D extends DefaultType>({
|
||||
export function ExpandableDatatable<
|
||||
D extends DefaultType,
|
||||
TMeta extends TableMeta<D> = TableMeta<D>
|
||||
>({
|
||||
renderSubRow,
|
||||
getRowCanExpand = () => true,
|
||||
expandOnRowClick,
|
||||
...props
|
||||
}: Props<D> & PaginationProps) {
|
||||
}: Props<D, TMeta> & PaginationProps) {
|
||||
return (
|
||||
<Datatable<D>
|
||||
<Datatable<D, TMeta>
|
||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||
{...props}
|
||||
getRowCanExpand={getRowCanExpand}
|
||||
|
|
Loading…
Reference in New Issue