-
Notifications
You must be signed in to change notification settings - Fork 11.7k
/
types.ts
54 lines (43 loc) · 1.76 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Property } from 'csstype';
import { FC } from 'react';
import { CellProps, Column, Row } from 'react-table';
import { Field, KeyValue, SelectableValue } from '@grafana/data';
import { TableStyles } from './styles';
export { type TableFieldOptions, TableCellDisplayMode, type FieldTextAlignment } from '@grafana/schema';
export interface TableRow {
[x: string]: any;
}
export const FILTER_FOR_OPERATOR = '=';
export const FILTER_OUT_OPERATOR = '!=';
export type FilterOperator = typeof FILTER_FOR_OPERATOR | typeof FILTER_OUT_OPERATOR;
export type FilterItem = { key: string; value: string; operator: FilterOperator };
export type TableFilterActionCallback = (item: FilterItem) => void;
export type TableColumnResizeActionCallback = (fieldDisplayName: string, width: number) => void;
export type TableSortByActionCallback = (state: TableSortByFieldState[]) => void;
export interface TableSortByFieldState {
displayName: string;
desc?: boolean;
}
export interface TableCellProps extends CellProps<any> {
tableStyles: TableStyles;
cellProps: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
field: Field;
onCellFilterAdded?: TableFilterActionCallback;
innerWidth: number;
}
export type CellComponent = FC<TableCellProps>;
export type FooterItem = Array<KeyValue<string>> | string | undefined;
export type GrafanaTableColumn = Column & {
field: Field;
sortType: 'number' | 'basic' | 'alphanumeric-insensitive';
filter: (rows: Row[], id: string, filterValues?: SelectableValue[]) => SelectableValue[];
justifyContent: Property.JustifyContent;
minWidth: number;
};
export interface TableFooterCalc {
show: boolean;
reducer: string[]; // actually 1 value
fields?: string[];
enablePagination?: boolean;
countRows?: boolean;
}