material-react-table 0.7.0-alpha.12 → 0.7.0-alpha.13
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/dist/MaterialReactTable.d.ts +1 -1
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +33 -48
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +34 -49
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +1 -6
- package/src/buttons/MRT_FullScreenToggleButton.tsx +0 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +0 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +0 -1
- package/src/buttons/MRT_ToggleFiltersButton.tsx +0 -1
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +6 -7
- package/src/inputs/MRT_FilterTextField.tsx +1 -1
- package/src/inputs/MRT_SearchTextField.tsx +4 -4
- package/src/localization.ts +6 -0
- package/src/table/MRT_TableRoot.tsx +25 -22
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +0 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.0-alpha.
|
|
2
|
+
"version": "0.7.0-alpha.13",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of react-table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"react": ">=16.8"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@tanstack/react-table": "^8.0.0-alpha.
|
|
100
|
+
"@tanstack/react-table": "^8.0.0-alpha.42",
|
|
101
101
|
"match-sorter": "^6.3.1"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -47,11 +47,6 @@ import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
|
47
47
|
import { MRT_FILTER_TYPE } from './enums';
|
|
48
48
|
import { MRT_TableRoot } from './table/MRT_TableRoot';
|
|
49
49
|
|
|
50
|
-
//@ts-ignore
|
|
51
|
-
global.performance = global.performance || {
|
|
52
|
-
now: () => new Date().getTime(),
|
|
53
|
-
};
|
|
54
|
-
|
|
55
50
|
export type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<
|
|
56
51
|
Omit<
|
|
57
52
|
Options<D>,
|
|
@@ -571,7 +566,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
571
566
|
row: MRT_Row<D>;
|
|
572
567
|
tableInstance: MRT_TableInstance<D>;
|
|
573
568
|
}) => void;
|
|
574
|
-
|
|
569
|
+
onGlobalSearchFilterChange?: ({
|
|
575
570
|
event,
|
|
576
571
|
tableInstance,
|
|
577
572
|
}: {
|
|
@@ -49,7 +49,7 @@ export const MRT_ToggleGlobalFilterButton: FC<Props> = ({
|
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<Tooltip arrow title={localization.showHideSearch}>
|
|
52
|
-
<IconButton
|
|
52
|
+
<IconButton onClick={handleToggleSearch} {...rest}>
|
|
53
53
|
{showGlobalFilter ? <SearchOffIcon /> : <SearchIcon />}
|
|
54
54
|
</IconButton>
|
|
55
55
|
</Tooltip>
|
|
@@ -56,9 +56,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
56
56
|
|
|
57
57
|
const sortTooltip = !!column.getIsSorted()
|
|
58
58
|
? column.getIsSorted() === 'desc'
|
|
59
|
-
? localization.
|
|
60
|
-
: localization.
|
|
61
|
-
: localization.
|
|
59
|
+
? localization.sortedByColumnDesc.replace('{column}', column.header)
|
|
60
|
+
: localization.sortedByColumnAsc.replace('{column}', column.header)
|
|
61
|
+
: localization.unsorted;
|
|
62
62
|
|
|
63
63
|
const filterType = getState()?.currentFilterTypes?.[header.id];
|
|
64
64
|
|
|
@@ -135,7 +135,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
135
135
|
}}
|
|
136
136
|
>
|
|
137
137
|
<Box
|
|
138
|
-
{
|
|
138
|
+
onClick={() => column.toggleSorting()}
|
|
139
139
|
sx={{
|
|
140
140
|
alignItems: 'center',
|
|
141
141
|
cursor:
|
|
@@ -146,7 +146,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
146
146
|
flexWrap: 'nowrap',
|
|
147
147
|
whiteSpace: column.header.length < 15 ? 'nowrap' : 'normal',
|
|
148
148
|
}}
|
|
149
|
-
title={undefined}
|
|
150
149
|
>
|
|
151
150
|
{headerElement}
|
|
152
151
|
{column.columnDefType !== 'group' && column.getCanSort() && (
|
|
@@ -185,9 +184,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
185
184
|
}}
|
|
186
185
|
>
|
|
187
186
|
{showFilters && !column.getColumnFilterValue() ? (
|
|
188
|
-
<FilterAltOff
|
|
187
|
+
<FilterAltOff />
|
|
189
188
|
) : (
|
|
190
|
-
<FilterAltIcon
|
|
189
|
+
<FilterAltIcon />
|
|
191
190
|
)}
|
|
192
191
|
</IconButton>
|
|
193
192
|
</Tooltip>
|
|
@@ -29,7 +29,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
29
29
|
idPrefix,
|
|
30
30
|
localization,
|
|
31
31
|
muiSearchTextFieldProps,
|
|
32
|
-
|
|
32
|
+
onGlobalSearchFilterChange,
|
|
33
33
|
},
|
|
34
34
|
} = tableInstance;
|
|
35
35
|
|
|
@@ -41,7 +41,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
41
41
|
const handleChange = useCallback(
|
|
42
42
|
debounce((event: ChangeEvent<HTMLInputElement>) => {
|
|
43
43
|
setGlobalFilter(event.target.value ?? undefined);
|
|
44
|
-
|
|
44
|
+
onGlobalSearchFilterChange?.({ event, tableInstance });
|
|
45
45
|
}, 200),
|
|
46
46
|
[],
|
|
47
47
|
);
|
|
@@ -82,7 +82,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
82
82
|
size="small"
|
|
83
83
|
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
84
84
|
>
|
|
85
|
-
<SearchIcon
|
|
85
|
+
<SearchIcon />
|
|
86
86
|
</IconButton>
|
|
87
87
|
</span>
|
|
88
88
|
</Tooltip>
|
|
@@ -97,7 +97,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
97
97
|
size="small"
|
|
98
98
|
title={localization.clearSearch}
|
|
99
99
|
>
|
|
100
|
-
<CloseIcon
|
|
100
|
+
<CloseIcon />
|
|
101
101
|
</IconButton>
|
|
102
102
|
</InputAdornment>
|
|
103
103
|
),
|
package/src/localization.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface MRT_Localization {
|
|
|
46
46
|
showHideSearch: string;
|
|
47
47
|
sortByColumnAsc: string;
|
|
48
48
|
sortByColumnDesc: string;
|
|
49
|
+
sortedByColumnAsc: string;
|
|
50
|
+
sortedByColumnDesc: string;
|
|
49
51
|
thenBy: string;
|
|
50
52
|
toggleDensePadding: string;
|
|
51
53
|
toggleFullScreen: string;
|
|
@@ -53,6 +55,7 @@ export interface MRT_Localization {
|
|
|
53
55
|
toggleSelectRow: string;
|
|
54
56
|
ungroupByColumn: string;
|
|
55
57
|
unpin: string;
|
|
58
|
+
unsorted: string;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
@@ -104,6 +107,8 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
104
107
|
showHideSearch: 'Show/Hide search',
|
|
105
108
|
sortByColumnAsc: 'Sort by {column} ascending',
|
|
106
109
|
sortByColumnDesc: 'Sort by {column} descending',
|
|
110
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
111
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
107
112
|
thenBy: ', then by ',
|
|
108
113
|
toggleDensePadding: 'Toggle dense padding',
|
|
109
114
|
toggleFullScreen: 'Toggle full screen',
|
|
@@ -111,4 +116,5 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
111
116
|
toggleSelectRow: 'Toggle select row',
|
|
112
117
|
ungroupByColumn: 'Ungroup by {column}',
|
|
113
118
|
unpin: 'Unpin',
|
|
119
|
+
unsorted: 'Unsorted',
|
|
114
120
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
1
2
|
import {
|
|
2
|
-
columnFilterRowsFn,
|
|
3
|
-
createTable,
|
|
4
|
-
expandRowsFn,
|
|
5
|
-
functionalUpdate,
|
|
6
|
-
globalFilterRowsFn,
|
|
7
|
-
groupRowsFn,
|
|
8
|
-
paginateRowsFn,
|
|
9
3
|
PaginationState,
|
|
10
|
-
sortRowsFn,
|
|
11
4
|
Table,
|
|
12
|
-
|
|
5
|
+
createTable,
|
|
6
|
+
functionalUpdate,
|
|
7
|
+
getColumnFilteredRowModelSync,
|
|
8
|
+
getExpandedRowModel,
|
|
9
|
+
getGlobalFilteredRowModelSync,
|
|
10
|
+
getGroupedRowModelSync,
|
|
11
|
+
getPaginationRowModel,
|
|
12
|
+
getSortedRowModelSync,
|
|
13
|
+
useTableInstance,
|
|
14
|
+
getCoreRowModelSync,
|
|
15
|
+
ColumnDef,
|
|
13
16
|
} from '@tanstack/react-table';
|
|
14
|
-
import React, { useMemo, useState } from 'react';
|
|
15
17
|
import {
|
|
16
18
|
MRT_ColumnInterface,
|
|
17
19
|
MRT_FilterType,
|
|
@@ -70,7 +72,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
70
72
|
(c) => ({
|
|
71
73
|
[c.id as string]:
|
|
72
74
|
c.filter ??
|
|
73
|
-
props?.initialState?.columnFilters?.
|
|
75
|
+
props?.initialState?.columnFilters?.find((cf) => cf.id === c.id) ??
|
|
74
76
|
(!!c.filterSelectOptions?.length
|
|
75
77
|
? MRT_FILTER_TYPE.EQUALS
|
|
76
78
|
: MRT_FILTER_TYPE.BEST_MATCH),
|
|
@@ -95,7 +97,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
95
97
|
createDisplayColumn(table, {
|
|
96
98
|
Cell: ({ cell }) => (
|
|
97
99
|
<MRT_ToggleRowActionMenuButton
|
|
98
|
-
row={cell.row as
|
|
100
|
+
row={cell.row as MRT_Row}
|
|
99
101
|
tableInstance={tableInstance}
|
|
100
102
|
/>
|
|
101
103
|
),
|
|
@@ -108,7 +110,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
108
110
|
createDisplayColumn(table, {
|
|
109
111
|
Cell: ({ cell }) => (
|
|
110
112
|
<MRT_ExpandButton
|
|
111
|
-
row={cell.row as
|
|
113
|
+
row={cell.row as MRT_Row}
|
|
112
114
|
tableInstance={tableInstance}
|
|
113
115
|
/>
|
|
114
116
|
),
|
|
@@ -125,7 +127,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
125
127
|
createDisplayColumn(table, {
|
|
126
128
|
Cell: ({ cell }) => (
|
|
127
129
|
<MRT_SelectCheckbox
|
|
128
|
-
row={cell.row as
|
|
130
|
+
row={cell.row as MRT_Row}
|
|
129
131
|
tableInstance={tableInstance}
|
|
130
132
|
/>
|
|
131
133
|
),
|
|
@@ -172,7 +174,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
172
174
|
? createGroup(table, column, currentFilterTypes)
|
|
173
175
|
: createDataColumn(table, column, currentFilterTypes),
|
|
174
176
|
),
|
|
175
|
-
] as
|
|
177
|
+
] as ColumnDef<D>[]),
|
|
176
178
|
[table, props.columns, currentFilterTypes],
|
|
177
179
|
);
|
|
178
180
|
|
|
@@ -195,25 +197,26 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
195
197
|
|
|
196
198
|
//@ts-ignore
|
|
197
199
|
const tableInstance: MRT_TableInstance<{}> = {
|
|
198
|
-
...
|
|
200
|
+
...useTableInstance(table, {
|
|
199
201
|
...props,
|
|
200
|
-
columnFilterRowsFn: columnFilterRowsFn,
|
|
201
202
|
columns,
|
|
202
203
|
data,
|
|
203
|
-
expandRowsFn: expandRowsFn,
|
|
204
204
|
//@ts-ignore
|
|
205
205
|
filterTypes: defaultFilterFNs,
|
|
206
|
+
getColumnFilteredRowModel: getColumnFilteredRowModelSync(),
|
|
207
|
+
getCoreRowModel: getCoreRowModelSync(),
|
|
208
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
209
|
+
getGlobalFilteredRowModel: getGlobalFilteredRowModelSync(),
|
|
210
|
+
getGroupedRowModel: getGroupedRowModelSync(),
|
|
211
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
212
|
+
getSortedRowModel: getSortedRowModelSync(),
|
|
206
213
|
getSubRows: props.getSubRows ?? ((originalRow: D) => originalRow.subRows),
|
|
207
|
-
globalFilterRowsFn: globalFilterRowsFn,
|
|
208
214
|
globalFilterType: currentGlobalFilterType,
|
|
209
|
-
groupRowsFn: groupRowsFn,
|
|
210
215
|
idPrefix,
|
|
211
216
|
//@ts-ignore
|
|
212
217
|
initialState: props.initialState,
|
|
213
218
|
onPaginationChange: (updater: any) =>
|
|
214
219
|
setPagination((old) => functionalUpdate(updater, old)),
|
|
215
|
-
paginateRowsFn: paginateRowsFn,
|
|
216
|
-
sortRowsFn,
|
|
217
220
|
state: {
|
|
218
221
|
currentEditingRow,
|
|
219
222
|
currentFilterTypes,
|