import { ReactNode } from 'react'; import { SortingRule, TableOptions } from 'react-table'; import { IconName } from '@grafana/data'; import { PopoverContent } from '../Tooltip/types'; import { Column } from './types'; export type InteractiveTableHeaderTooltip = { content: PopoverContent; iconName?: IconName; }; export type FetchDataArgs = { sortBy: Array>; }; export type FetchDataFunc = ({ sortBy }: FetchDataArgs) => void; interface BaseProps { className?: string; /** * Table's columns definition. Must be memoized. */ columns: Array>; /** * The data to display in the table. Must be memoized. */ data: TableData[]; /** * Must return a unique id for each row */ getRowId: TableOptions['getRowId']; /** * Optional tooltips for the table headers. The key must match the column id. */ headerTooltips?: Record; /** * Number of rows per page. A value of zero disables pagination. Defaults to 0. * A React hooks error will be thrown if pageSize goes from greater than 0 to 0 or vice versa. If enabling pagination, * make sure pageSize remains a non-zero value. */ pageSize?: number; /** * A custom function to fetch data when the table is sorted. If not provided, the table will be sorted client-side. * It's important for this function to have a stable identity, e.g. being wrapped into useCallback to prevent unnecessary * re-renders of the table. */ fetchData?: FetchDataFunc; /** * Optional way to set how the table is sorted from the beginning. Must be memoized. */ initialSortBy?: Array>; /** * Disable the ability to remove sorting on columns (none -> asc -> desc -> asc) */ disableSortRemove?: boolean; /** * Will automatically reset to the first page if the `data` prop is changed */ autoResetPage?: boolean; } interface WithExpandableRow extends BaseProps { /** * Render function for the expanded row. if not provided, the tables rows will not be expandable. */ renderExpandedRow: (row: TableData) => ReactNode; /** * Whether to show the "Expand all" button. Depends on renderExpandedRow to be provided. Defaults to false. */ showExpandAll?: boolean; } interface WithoutExpandableRow extends BaseProps { renderExpandedRow?: never; showExpandAll?: never; } type Props = WithExpandableRow | WithoutExpandableRow; /** * The InteractiveTable is used to display and select data efficiently. It allows for the display and modification of detailed information. * * https://developers.grafana.com/ui/latest/index.html?path=/docs/layout-interactivetable--docs * * @alpha */ export declare function InteractiveTable({ autoResetPage, className, columns, data, getRowId, headerTooltips, pageSize, renderExpandedRow, showExpandAll, fetchData, initialSortBy, disableSortRemove, }: Props): import("react/jsx-runtime").JSX.Element; export {};