@grafana/ui
Version:
Grafana Components Library
61 lines (60 loc) • 2.27 kB
TypeScript
import React, { Component } from 'react';
import { SortDirectionType, CellMeasurerCache, GridCellProps, Index } from 'react-virtualized';
import { Themeable } from '../../types/theme';
import { DataFrame } from '@grafana/data';
import { TableCellBuilder, ColumnStyle, TableCellBuilderOptions } from './TableCellBuilder';
import { InterpolateFunction } from '../../types/panel';
export interface Props extends Themeable {
data: DataFrame;
minColumnWidth: number;
showHeader: boolean;
fixedHeader: boolean;
fixedColumns: number;
rotate: boolean;
styles: ColumnStyle[];
replaceVariables: InterpolateFunction;
width: number;
height: number;
isUTC?: boolean;
}
interface State {
sortBy?: number;
sortDirection?: SortDirectionType;
data: DataFrame;
}
interface ColumnRenderInfo {
header: string;
width: number;
builder: TableCellBuilder;
}
interface DataIndex {
column: number;
row: number;
}
export declare class Table extends Component<Props, State> {
renderer: ColumnRenderInfo[];
measurer: CellMeasurerCache;
scrollToTop: boolean;
rotateWidth: number;
static defaultProps: {
showHeader: boolean;
fixedHeader: boolean;
fixedColumns: number;
rotate: boolean;
minColumnWidth: number;
};
constructor(props: Props);
componentDidUpdate(prevProps: Props, prevState: State): void;
/** Given the configuration, setup how each column gets rendered */
initColumns(props: Props): ColumnRenderInfo[];
doSort: (columnIndex: number) => void;
/** Converts the grid coordinates to DataFrame coordinates */
getCellRef: (rowIndex: number, columnIndex: number) => DataIndex;
onCellClick: (rowIndex: number, columnIndex: number) => void;
headerBuilder: (cell: TableCellBuilderOptions) => React.ReactElement<"div", string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
getTableCellBuilder: (column: number) => TableCellBuilder;
cellRenderer: (props: GridCellProps) => React.ReactNode;
getColumnWidth: (col: Index) => number;
render(): JSX.Element;
}
export default Table;