material-react-table 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -35,7 +35,9 @@ export const MRT_TableBody: FC<Props> = ({
|
|
35
35
|
enableRowVirtualization,
|
36
36
|
layoutMode,
|
37
37
|
localization,
|
38
|
+
manualExpanding,
|
38
39
|
manualFiltering,
|
40
|
+
manualGrouping,
|
39
41
|
manualPagination,
|
40
42
|
manualSorting,
|
41
43
|
memoMode,
|
@@ -47,8 +49,15 @@ export const MRT_TableBody: FC<Props> = ({
|
|
47
49
|
},
|
48
50
|
refs: { tableContainerRef, tablePaperRef },
|
49
51
|
} = table;
|
50
|
-
const {
|
51
|
-
|
52
|
+
const {
|
53
|
+
columnFilters,
|
54
|
+
density,
|
55
|
+
expanded,
|
56
|
+
globalFilter,
|
57
|
+
globalFilterFn,
|
58
|
+
pagination,
|
59
|
+
sorting,
|
60
|
+
} = getState();
|
52
61
|
|
53
62
|
const tableBodyProps =
|
54
63
|
muiTableBodyProps instanceof Function
|
@@ -65,30 +74,43 @@ export const MRT_TableBody: FC<Props> = ({
|
|
65
74
|
? rowVirtualizerProps({ table })
|
66
75
|
: rowVirtualizerProps;
|
67
76
|
|
68
|
-
const
|
69
|
-
|
70
|
-
|
71
|
-
globalFilter &&
|
77
|
+
const shouldRankResults = useMemo(
|
78
|
+
() =>
|
79
|
+
!manualExpanding &&
|
72
80
|
!manualFiltering &&
|
81
|
+
!manualGrouping &&
|
73
82
|
!manualSorting &&
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
enableGlobalFilterRankedResults &&
|
84
|
+
globalFilter &&
|
85
|
+
globalFilterFn === 'fuzzy' &&
|
86
|
+
expanded !== true &&
|
87
|
+
!Object.values(sorting).some(Boolean) &&
|
88
|
+
!Object.values(expanded).some(Boolean),
|
89
|
+
[
|
90
|
+
enableGlobalFilterRankedResults,
|
91
|
+
expanded,
|
92
|
+
globalFilter,
|
93
|
+
manualExpanding,
|
94
|
+
manualFiltering,
|
95
|
+
manualGrouping,
|
96
|
+
manualSorting,
|
97
|
+
sorting,
|
98
|
+
],
|
99
|
+
);
|
100
|
+
|
101
|
+
const rows = useMemo(() => {
|
102
|
+
if (!shouldRankResults) return getRowModel().rows;
|
103
|
+
const rankedRows = getPrePaginationRowModel().rows.sort((a, b) =>
|
104
|
+
rankGlobalFuzzy(a, b),
|
105
|
+
);
|
106
|
+
if (enablePagination && !manualPagination) {
|
107
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
108
|
+
return rankedRows.slice(start, start + pagination.pageSize);
|
84
109
|
}
|
85
|
-
return
|
110
|
+
return rankedRows;
|
86
111
|
}, [
|
87
|
-
|
88
|
-
|
89
|
-
? getPrePaginationRowModel().rows
|
90
|
-
: getRowModel().rows,
|
91
|
-
globalFilter,
|
112
|
+
shouldRankResults,
|
113
|
+
shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
|
92
114
|
pagination.pageIndex,
|
93
115
|
pagination.pageSize,
|
94
116
|
]);
|