@ -196,16 +196,16 @@ export function TableNG(props: TableNGProps) {
// Create a map of column key to column type
// Create a map of column key to column type
const columnTypes = useMemo (
const columnTypes = useMemo (
( ) = > props . data . fields . reduce ( ( acc , { name , type } ) = > ( { . . . acc , [ name ] : type } ) , { } as ColumnTypes ) ,
( ) = > props . data . fields . reduce < ColumnTypes > ( ( acc , { name , type } ) = > ( { . . . acc , [ name ] : type } ) , { } ) ,
[ props . data . fields ]
[ props . data . fields ]
) ;
) ;
// Create a map of column key to text wrap
// Create a map of column key to text wrap
const textWraps = useMemo (
const textWraps = useMemo (
( ) = >
( ) = >
props . data . fields . reduce (
props . data . fields . reduce < { [ key : string ] : boolean } > (
( acc , { name , config } ) = > ( { . . . acc , [ name ] : config ? . custom ? . cellOptions ? . wrapText ? ? false } ) ,
( acc , { name , config } ) = > ( { . . . acc , [ name ] : config ? . custom ? . cellOptions ? . wrapText ? ? false } ) ,
{ } as { [ key : string ] : boolean }
{ }
) ,
) ,
[ props . data . fields ]
[ props . data . fields ]
) ;
) ;
@ -243,15 +243,12 @@ export function TableNG(props: TableNGProps) {
} , [ props . data . fields ] ) ;
} , [ props . data . fields ] ) ;
const fieldDisplayType = useMemo ( ( ) = > {
const fieldDisplayType = useMemo ( ( ) = > {
return props . data . fields . reduce (
return props . data . fields . reduce < Record < string , TableCellDisplayMode > > ( ( acc , { config , name } ) = > {
( acc , { config , name } ) = > {
if ( config ? . custom ? . cellOptions ? . type ) {
if ( config ? . custom ? . cellOptions ? . type ) {
acc [ name ] = config . custom . cellOptions . type ;
acc [ name ] = config . custom . cellOptions . type ;
}
}
return acc ;
return acc ;
} , { } ) ;
} ,
{ } as Record < string , TableCellDisplayMode >
) ;
} , [ props . data . fields ] ) ;
} , [ props . data . fields ] ) ;
// Clean up fieldsData to simplify
// Clean up fieldsData to simplify
@ -752,7 +749,7 @@ export function mapFrameToDataGrid({
fieldOptions . cellOptions . applyToRow
fieldOptions . cellOptions . applyToRow
) {
) {
rowBg = ( rowIndex : number ) : CellColors = > {
rowBg = ( rowIndex : number ) : CellColors = > {
const display = field . display ! ( field . values . get ( sortedRows [ rowIndex ] . __index ) ) ;
const display = field . display ! ( field . values [ rowIndex ] ) ;
const colors = getCellColors ( theme , fieldOptions . cellOptions , display ) ;
const colors = getCellColors ( theme , fieldOptions . cellOptions , display ) ;
return colors ;
return colors ;
} ;
} ;