@@ -32,18 +32,19 @@ import { rankItem } from '@tanstack/match-sorter-utils'
32
32
import type { VirtualItem } from '@tanstack/react-virtual'
33
33
import { useVirtualizer } from '@tanstack/react-virtual'
34
34
import styled from 'styled-components'
35
+ import { isEmpty } from 'lodash-es'
35
36
36
37
import Button from './Button'
37
38
import CaretUpIcon from './icons/CaretUpIcon'
38
39
import ArrowRightIcon from './icons/ArrowRightIcon'
39
40
import { FillLevelProvider } from './contexts/FillLevelContext'
41
+ import EmptyState from './EmptyState'
40
42
41
43
export type TableProps = Omit <
42
44
DivProps ,
43
45
| 'data'
44
46
| 'columns'
45
47
| 'getRowCanExpand'
46
- | 'getRowIsSelected'
47
48
| 'renderExpanded'
48
49
| 'loose'
49
50
| 'stickyColumn'
@@ -52,11 +53,11 @@ export type TableProps = Omit<
52
53
| 'virtualizerOptions'
53
54
| 'reactTableOptions'
54
55
| 'onRowClick'
56
+ | 'emptyStateProps'
55
57
> & {
56
58
data : any [ ]
57
59
columns : any [ ]
58
60
getRowCanExpand ?: any
59
- getRowIsSelected ?: ( row : Row < any > ) => boolean
60
61
renderExpanded ?: any
61
62
loose ?: boolean
62
63
stickyColumn ?: boolean
@@ -69,6 +70,7 @@ export type TableProps = Omit<
69
70
>
70
71
reactTableOptions ?: Partial < Omit < TableOptions < any > , 'data' | 'columns' > >
71
72
onRowClick ?: ( e : MouseEvent < HTMLTableRowElement > , row : Row < any > ) => void
73
+ emptyStateProps ?: ComponentProps < typeof EmptyState >
72
74
}
73
75
74
76
const propTypes = { }
@@ -445,7 +447,6 @@ function TableRef(
445
447
data,
446
448
columns,
447
449
getRowCanExpand,
448
- getRowIsSelected,
449
450
renderExpanded,
450
451
loose = false ,
451
452
stickyColumn = false ,
@@ -456,6 +457,7 @@ function TableRef(
456
457
reactVirtualOptions : virtualizerOptions ,
457
458
reactTableOptions,
458
459
onRowClick,
460
+ emptyStateProps,
459
461
...props
460
462
} : TableProps ,
461
463
forwardRef : Ref < any >
@@ -646,8 +648,8 @@ function TableRef(
646
648
key = { row . id }
647
649
onClick = { ( e ) => onRowClick ?.( e , row ) }
648
650
$lighter = { i % 2 === 0 }
649
- $selectable = { ! ! getRowIsSelected }
650
- $selected = { getRowIsSelected ?. ( row ) ?? false }
651
+ $selectable = { row . getCanSelect ( ) }
652
+ $selected = { row . getIsSelected ( ) ?? false }
651
653
$clickable = { ! ! onRowClick }
652
654
// data-index is required for virtual scrolling to work
653
655
data-index = { row . index }
@@ -693,6 +695,11 @@ function TableRef(
693
695
) }
694
696
</ Tbody >
695
697
</ T >
698
+ { isEmpty ( rows ) && (
699
+ < EmptyState
700
+ { ...{ message : 'No results match your query' , ...emptyStateProps } }
701
+ />
702
+ ) }
696
703
</ Div >
697
704
{ hover && scrollTop > scrollTopMargin && (
698
705
< Button
0 commit comments