11import _ from 'lodash' ;
22import React , { useContext , useEffect } from 'react' ;
33import { useSelector } from 'react-redux' ;
4- import { Tbody , Tr , Td , Div } from '../styled-components' ;
4+ import { Tbody , Tr , Td , Div , Row } from '../styled-components' ;
55import { Body as Renderers } from './Renderer' ;
66import { getStyles , getRenderer , getInitialVisibleColumns } from '../utils' ;
77import { MODIFY_DATA , SET_BODY_INNER_WIDTH , SET_TABLE_WIDTH , SET_VISIBLE_COLUMN_IDS , SET_COLUMN_WIDTHS } from '../actions' ;
@@ -34,19 +34,44 @@ const renderCol = (rowIndex, primaryKey, schema, styles, colClassName, column, i
3434 ) ;
3535} ;
3636
37- const renderRow = ( columns , rowHeight , styles , primaryKey , schema , rowClassName , colClassName , rowIndex , top ) => (
38- < Tr
39- key = { rowIndex }
40- className = { rowClassName }
41- position = "absolute"
42- top = { top }
43- columns = { columns }
44- height = { rowHeight }
45- even = { rowIndex % 2 === 0 }
46- styles = { getStyles ( styles . tr , 'body' ) }
47- >
48- { renderCol . bind ( this , rowIndex , primaryKey , schema , styles , colClassName ) }
49- </ Tr >
37+ const renderRow = (
38+ columns ,
39+ rowHeight ,
40+ styles ,
41+ primaryKey ,
42+ schema ,
43+ rowClassName ,
44+ colClassName ,
45+ noResultsMessage ,
46+ rowIndex ,
47+ top
48+ ) => (
49+ rowIndex !== - 1
50+ ? (
51+ < Tr
52+ key = { rowIndex }
53+ className = { rowClassName }
54+ position = "absolute"
55+ top = { top }
56+ columns = { columns }
57+ height = { rowHeight }
58+ even = { rowIndex % 2 === 0 }
59+ styles = { getStyles ( styles . tr , 'body' ) }
60+ >
61+ { renderCol . bind ( this , rowIndex , primaryKey , schema , styles , colClassName ) }
62+ </ Tr >
63+ ) : (
64+ < Row
65+ className = { rowClassName }
66+ height = { rowHeight + 'px' }
67+ style = { {
68+ justifyContent : 'center' ,
69+ alignItems : 'center'
70+ }
71+ } >
72+ { noResultsMessage }
73+ </ Row >
74+ )
5075) ;
5176
5277const Body = React . forwardRef ( ( { top : startTop = 0 , config } , ref ) => {
@@ -61,6 +86,7 @@ const Body = React.forwardRef(({ top: startTop = 0, config }, ref) => {
6186 height : minHeight ,
6287 primaryKey,
6388 overScanCount = 10 ,
89+ noResultsMessage = 'No results found' ,
6490 components : {
6591 Table : { styles = { } }
6692 } ,
@@ -130,13 +156,23 @@ const Body = React.forwardRef(({ top: startTop = 0, config }, ref) => {
130156 styles = { getStyles ( styles , 'tbody' ) }
131157 ref = { ref }
132158 isPrinting = { isPrinting }
133- height = { height }
159+ height = { height > 0 ? height : rowHeight }
134160 visibleHeight = { visibleHeight }
135- innerHeight = { innerHeight }
161+ innerHeight = { innerHeight > 0 ? innerHeight : rowHeight }
136162 range = { range }
137163 rowHeight = { rowHeight }
138164 >
139- { renderRow . bind ( this , columns , rowHeight , styles , primaryKey , schema , rowClassName , colClassName ) }
165+ { renderRow . bind (
166+ this ,
167+ columns ,
168+ rowHeight ,
169+ styles ,
170+ primaryKey ,
171+ schema ,
172+ rowClassName ,
173+ colClassName ,
174+ noResultsMessage
175+ ) }
140176 </ Tbody >
141177 ) ;
142178} ) ;
0 commit comments