mirror of
https://github.com/portainer/portainer.git
synced 2026-06-23 07:40:11 +00:00
dd68560ad0
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
41 lines
988 B
TypeScript
41 lines
988 B
TypeScript
import { Row } from '@tanstack/react-table';
|
|
import { ReactNode } from 'react';
|
|
|
|
import { ExpandableDatatableTableRow } from './ExpandableDatatableRow';
|
|
import {
|
|
Datatable,
|
|
Props as DatatableProps,
|
|
PaginationProps,
|
|
} from './Datatable';
|
|
import { DefaultType } from './types';
|
|
|
|
interface Props<D extends DefaultType> extends Omit<
|
|
DatatableProps<D>,
|
|
'renderRow' | 'expandable'
|
|
> {
|
|
renderSubRow(row: Row<D>): ReactNode;
|
|
expandOnRowClick?: boolean;
|
|
}
|
|
|
|
export function ExpandableDatatable<D extends DefaultType>({
|
|
renderSubRow,
|
|
getRowCanExpand = () => true,
|
|
expandOnRowClick,
|
|
...props
|
|
}: Props<D> & PaginationProps) {
|
|
return (
|
|
<Datatable<D>
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
{...props}
|
|
getRowCanExpand={getRowCanExpand}
|
|
renderRow={(row) => (
|
|
<ExpandableDatatableTableRow<D>
|
|
row={row}
|
|
renderSubRow={renderSubRow}
|
|
expandOnClick={expandOnRowClick}
|
|
/>
|
|
)}
|
|
/>
|
|
);
|
|
}
|