@@ -3,7 +3,7 @@ import { useTable, usePagination } from 'react-table'
33import { DEFAULT_EMPTY_TABLE_MESSAGE } from 'constants/index'
44import style from './table-container.module.css'
55
6- interface DataGetterReturn {
6+ export interface DataGetterReturn {
77 data : any
88 totalCount : number
99}
@@ -35,7 +35,7 @@ const TableContainer = ({ columns, dataGetter, opts, ssr, tableRefreshCount, emp
3535 const [ pageCount , setPageCount ] = useState ( 0 )
3636 const [ loading , setLoading ] = useState ( true )
3737 const emptyMessageDisplay = emptyMessage ?? DEFAULT_EMPTY_TABLE_MESSAGE
38- const [ hiddenColumns , setHiddenColumns ] = useState ( { } )
38+ const [ hiddenColumns , setHiddenColumns ] = useState < Record < string , boolean > > ( { } )
3939
4040 const triggerSort = ( column : any ) : void => {
4141 if ( column . disableSortBy === true || hiddenColumns [ column . id ] ) return
@@ -49,9 +49,9 @@ const TableContainer = ({ columns, dataGetter, opts, ssr, tableRefreshCount, emp
4949 }
5050 gotoPage ( 0 )
5151 }
52-
52+
5353 const toggleColumn = ( id : any ) : void => {
54- setHiddenColumns ( ( prev ) => ( { ...prev , [ id ] : ! prev [ id ] } ) )
54+ setHiddenColumns ( ( prev ) => ( { ...prev , [ id ] : ! prev [ id ] } ) )
5555 }
5656
5757 const {
@@ -122,12 +122,12 @@ const TableContainer = ({ columns, dataGetter, opts, ssr, tableRefreshCount, emp
122122 < th { ...column . getHeaderProps ( ) } style = { column . disableSortBy === true ? null : { cursor : 'pointer' } } onClick = { ( ) => { triggerSort ( column ) } } >
123123 < div >
124124 { column . render ( 'Header' ) }
125- { column . shrinkable && (
125+ { column . shrinkable === true && (
126126 < span onClick = { ( ) => toggleColumn ( column . id ) } style = { { cursor : 'pointer' } } >
127- { hiddenColumns [ column . id ] ? < div style = { { marginRight : '5px' } } className = 'table-arrow-right' /> : < div style = { { marginRight : '5px' } } className = 'table-sort-arrow-down' /> }
127+ { hiddenColumns [ column . id ] ? < div style = { { marginRight : '5px' } } className = 'table-arrow-right' /> : < div style = { { marginRight : '5px' } } className = 'table-sort-arrow-down' /> }
128128 </ span >
129129 ) }
130- { ! column . shrinkable && generateSortingIndicator ( column ) }
130+ { column . shrinkable !== true && generateSortingIndicator ( column ) }
131131 </ div >
132132 </ th >
133133 ) ) }
@@ -143,7 +143,7 @@ const TableContainer = ({ columns, dataGetter, opts, ssr, tableRefreshCount, emp
143143 return (
144144 < tr { ...row . getRowProps ( ) } >
145145 { row . cells . map ( ( cell : any ) =>
146- hiddenColumns [ cell . column . id ] ? < td > </ td > : < td { ...cell . getCellProps ( ) } > { cell . render ( 'Cell' ) } </ td >
146+ hiddenColumns [ cell . column . id ] ? < td > </ td > : < td { ...cell . getCellProps ( ) } > { cell . render ( 'Cell' ) } </ td >
147147 ) }
148148 </ tr >
149149 )
0 commit comments