@ -1,4 +1,4 @@
import { Column , Row } from 'react-table' ;
import { Row } from 'react-table' ;
import memoizeOne from 'memoize-one' ;
import { Property } from 'csstype' ;
import {
@ -12,7 +12,7 @@ import {
import { DefaultCell } from './DefaultCell' ;
import { BarGaugeCell } from './BarGaugeCell' ;
import { CellComponent , TableCellDisplayMode , TableFieldOptions , FooterItem } from './types' ;
import { CellComponent , TableCellDisplayMode , TableFieldOptions , FooterItem , GrafanaTableColumn } from './types' ;
import { JSONViewCell } from './JSONViewCell' ;
import { ImageCell } from './ImageCell' ;
import { getFooterValue } from './FooterRow' ;
@ -47,8 +47,8 @@ export function getColumns(
availableWidth : number ,
columnMinWidth : number ,
footerValues? : FooterItem [ ]
) : Column [ ] {
const columns : any [ ] = [ ] ;
) : GrafanaTable Column[ ] {
const columns : GrafanaTableColumn [ ] = [ ] ;
let fieldCountWithoutWidth = 0 ;
for ( const [ fieldIndex , field ] of data . fields . entries ( ) ) {
@ -64,7 +64,7 @@ export function getColumns(
fieldCountWithoutWidth ++ ;
}
const selectSortType = ( type : FieldType ) : string = > {
const selectSortType = ( type : FieldType ) = > {
switch ( type ) {
case FieldType . number :
return 'number' ;
@ -79,13 +79,14 @@ export function getColumns(
columns . push ( {
Cell ,
id : fieldIndex.toString ( ) ,
field : field ,
Header : getFieldDisplayName ( field , data ) ,
accessor : ( row : any , i : number ) = > {
return field . values . get ( i ) ;
} ,
sortType : selectSortType ( field . type ) ,
width : fieldTableOptions.width ,
minWidth : fieldTableOptions.minWidth || columnMinWidth ,
minWidth : fieldTableOptions.minWidth ? ? columnMinWidth ,
filter : memoizeOne ( filterByValue ( field ) ) ,
justifyContent : getTextAlign ( field ) ,
Footer : getFooterValue ( fieldIndex , footerValues ) ,