material-react-table 0.7.0-alpha.8 → 0.7.1
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/README.md +3 -5
- package/dist/MaterialReactTable.d.ts +65 -46
- package/dist/buttons/{MRT_ToggleSearchButton.d.ts → MRT_ToggleGlobalFilterButton.d.ts} +1 -1
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +228 -167
- 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 +231 -170
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -2
- package/dist/utils.d.ts +5 -5
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +103 -57
- package/src/body/MRT_TableBodyCell.tsx +5 -3
- package/src/buttons/MRT_EditActionButtons.tsx +1 -1
- package/src/buttons/MRT_FullScreenToggleButton.tsx +13 -4
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +0 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +13 -4
- package/src/buttons/MRT_ToggleFiltersButton.tsx +13 -4
- package/src/buttons/{MRT_ToggleSearchButton.tsx → MRT_ToggleGlobalFilterButton.tsx} +14 -8
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +8 -9
- package/src/inputs/MRT_EditCellTextField.tsx +2 -5
- package/src/inputs/MRT_FilterTextField.tsx +2 -2
- package/src/inputs/MRT_SearchTextField.tsx +6 -6
- package/src/localization.ts +6 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +4 -4
- package/src/menus/MRT_FilterTypeMenu.tsx +5 -8
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -7
- package/src/table/MRT_Table.tsx +5 -5
- package/src/table/MRT_TableContainer.tsx +4 -4
- package/src/table/MRT_TablePaper.tsx +9 -13
- package/src/table/MRT_TableRoot.tsx +96 -79
- package/src/toolbar/MRT_ToolbarBottom.tsx +2 -2
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -9
- package/src/toolbar/MRT_ToolbarTop.tsx +2 -2
- package/src/utils.ts +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
|
-
column:
|
|
4
|
+
column: MRT_Column;
|
|
5
5
|
isSubMenu?: boolean;
|
|
6
6
|
tableInstance: MRT_TableInstance;
|
|
7
7
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ColumnDef, Table } from '@tanstack/react-table';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getAllLeafColumnDefs: (columns:
|
|
4
|
-
export declare const createGroup: <D extends Record<string, any> = {}>(table: Table<D>, column:
|
|
2
|
+
import { MRT_ColumnDef, MRT_FilterType } from '.';
|
|
3
|
+
export declare const getAllLeafColumnDefs: (columns: MRT_ColumnDef[]) => MRT_ColumnDef[];
|
|
4
|
+
export declare const createGroup: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterTypes: {
|
|
5
5
|
[key: string]: MRT_FilterType;
|
|
6
6
|
}) => ColumnDef<D>;
|
|
7
|
-
export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column:
|
|
7
|
+
export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterTypes: {
|
|
8
8
|
[key: string]: MRT_FilterType;
|
|
9
9
|
}) => ColumnDef<D>;
|
|
10
|
-
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<
|
|
10
|
+
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "footer" | "columns" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "defaultCanHide" | "defaultIsVisible" | "enablePinning" | "defaultCanPin" | "filterType" | "enableAllFilters" | "enableColumnFilter" | "enableGlobalFilter" | "defaultCanFilter" | "defaultCanColumnFilter" | "defaultCanGlobalFilter" | "sortType" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "defaultCanSort" | "invertSorting" | "sortUndefined" | "aggregationType" | "aggregateValue" | "aggregatedCell" | "enableGrouping" | "defaultCanGroup" | "enableResizing" | "defaultCanResize" | "width" | "minWidth" | "maxWidth" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableEditing" | "enabledFilterTypes" | "filter" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChange" | "onColumnFilterValueChange"> & {
|
|
11
11
|
header?: string | undefined;
|
|
12
12
|
}) => ColumnDef<D>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.1",
|
|
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.",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@emotion/styled": "^11.8.1",
|
|
61
61
|
"@etchteam/storybook-addon-status": "^4.2.1",
|
|
62
62
|
"@faker-js/faker": "^6.1.2",
|
|
63
|
-
"@mui/icons-material": "^5.6.
|
|
64
|
-
"@mui/material": "^5.6.
|
|
63
|
+
"@mui/icons-material": "^5.6.2",
|
|
64
|
+
"@mui/material": "^5.6.2",
|
|
65
65
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
66
66
|
"@storybook/addon-a11y": "^6.4.22",
|
|
67
67
|
"@storybook/addon-actions": "^6.4.22",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@storybook/react": "^6.4.22",
|
|
75
75
|
"@types/react": "^17.0.41",
|
|
76
76
|
"@types/react-dom": "^17.0.14",
|
|
77
|
-
"babel-loader": "^8.2.
|
|
77
|
+
"babel-loader": "^8.2.5",
|
|
78
78
|
"eslint": "^8.13.0",
|
|
79
79
|
"eslint-plugin-react-hooks": "^4.4.0",
|
|
80
80
|
"husky": "^7.0.4",
|
|
@@ -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.44",
|
|
101
101
|
"match-sorter": "^6.3.1"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -47,18 +47,13 @@ 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>,
|
|
58
53
|
'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'
|
|
59
54
|
>
|
|
60
55
|
> & {
|
|
61
|
-
columns:
|
|
56
|
+
columns: MRT_ColumnDef<D>[];
|
|
62
57
|
data: D[];
|
|
63
58
|
initialState?: Partial<MRT_TableState<D>>;
|
|
64
59
|
state?: Partial<MRT_TableState<D>>;
|
|
@@ -90,8 +85,8 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
90
85
|
| 'getState'
|
|
91
86
|
| 'options'
|
|
92
87
|
> & {
|
|
93
|
-
getAllColumns: () =>
|
|
94
|
-
getAllLeafColumns: () =>
|
|
88
|
+
getAllColumns: () => MRT_Column<D>[];
|
|
89
|
+
getAllLeafColumns: () => MRT_Column<D>[];
|
|
95
90
|
getExpandedRowModel: () => MRT_RowModel<D>;
|
|
96
91
|
getPaginationRowModel: () => MRT_RowModel<D>;
|
|
97
92
|
getPrePaginationRowModel: () => MRT_RowModel<D>;
|
|
@@ -103,18 +98,18 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
103
98
|
idPrefix: string;
|
|
104
99
|
filterTypes: { [key in MRT_FILTER_TYPE]: any };
|
|
105
100
|
localization: MRT_Localization;
|
|
106
|
-
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
107
|
-
setCurrentFilterTypes: Dispatch<
|
|
108
|
-
SetStateAction<{
|
|
109
|
-
[key: string]: MRT_FilterType;
|
|
110
|
-
}>
|
|
111
|
-
>;
|
|
112
|
-
setCurrentGlobalFilterType: Dispatch<SetStateAction<MRT_FILTER_TYPE>>;
|
|
113
|
-
setIsDensePadding: Dispatch<SetStateAction<boolean>>;
|
|
114
|
-
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
115
|
-
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
|
116
|
-
setShowSearch: Dispatch<SetStateAction<boolean>>;
|
|
117
101
|
};
|
|
102
|
+
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
103
|
+
setCurrentFilterTypes: Dispatch<
|
|
104
|
+
SetStateAction<{
|
|
105
|
+
[key: string]: MRT_FilterType;
|
|
106
|
+
}>
|
|
107
|
+
>;
|
|
108
|
+
setCurrentGlobalFilterType: Dispatch<SetStateAction<MRT_FILTER_TYPE>>;
|
|
109
|
+
setIsDensePadding: Dispatch<SetStateAction<boolean>>;
|
|
110
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
111
|
+
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
|
112
|
+
setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
|
|
118
113
|
};
|
|
119
114
|
|
|
120
115
|
export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
|
|
@@ -127,11 +122,11 @@ export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
|
|
|
127
122
|
isDensePadding: boolean;
|
|
128
123
|
isFullScreen: boolean;
|
|
129
124
|
showFilters: boolean;
|
|
130
|
-
|
|
125
|
+
showGlobalFilter: boolean;
|
|
131
126
|
pagination: Partial<PaginationState>;
|
|
132
127
|
};
|
|
133
128
|
|
|
134
|
-
export type
|
|
129
|
+
export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
135
130
|
ColumnDef<D>,
|
|
136
131
|
'header' | 'footer' | 'columns'
|
|
137
132
|
> & {
|
|
@@ -175,11 +170,11 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
|
|
|
175
170
|
tableInstance: MRT_TableInstance<D>;
|
|
176
171
|
}) => ReactNode;
|
|
177
172
|
id: keyof D | string;
|
|
178
|
-
columns?:
|
|
173
|
+
columns?: MRT_ColumnDef<D>[];
|
|
179
174
|
enableClickToCopy?: boolean;
|
|
180
175
|
enableColumnActions?: boolean;
|
|
181
176
|
enableEditing?: boolean;
|
|
182
|
-
|
|
177
|
+
enabledColumnFilterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
183
178
|
filter?: MRT_FilterType | string | FilterType<D>;
|
|
184
179
|
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
185
180
|
footer?: string;
|
|
@@ -218,7 +213,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
|
|
|
218
213
|
column,
|
|
219
214
|
}: {
|
|
220
215
|
tableInstance: MRT_TableInstance;
|
|
221
|
-
column:
|
|
216
|
+
column: MRT_Column<D>;
|
|
222
217
|
}) => TableCellProps);
|
|
223
218
|
muiTableHeadCellColumnActionsButtonProps?:
|
|
224
219
|
| IconButtonProps
|
|
@@ -227,7 +222,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
|
|
|
227
222
|
column,
|
|
228
223
|
}: {
|
|
229
224
|
tableInstance: MRT_TableInstance;
|
|
230
|
-
column:
|
|
225
|
+
column: MRT_Column<D>;
|
|
231
226
|
}) => IconButtonProps);
|
|
232
227
|
muiTableHeadCellFilterTextFieldProps?:
|
|
233
228
|
| TextFieldProps
|
|
@@ -236,7 +231,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
|
|
|
236
231
|
column,
|
|
237
232
|
}: {
|
|
238
233
|
tableInstance: MRT_TableInstance;
|
|
239
|
-
column:
|
|
234
|
+
column: MRT_Column<D>;
|
|
240
235
|
}) => TextFieldProps);
|
|
241
236
|
muiTableHeadCellProps?:
|
|
242
237
|
| TableCellProps
|
|
@@ -245,7 +240,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
|
|
|
245
240
|
column,
|
|
246
241
|
}: {
|
|
247
242
|
tableInstance: MRT_TableInstance;
|
|
248
|
-
column:
|
|
243
|
+
column: MRT_Column<D>;
|
|
249
244
|
}) => TableCellProps);
|
|
250
245
|
onCellEditBlur?: ({
|
|
251
246
|
cell,
|
|
@@ -274,19 +269,19 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
|
|
|
274
269
|
}) => void;
|
|
275
270
|
};
|
|
276
271
|
|
|
277
|
-
export type
|
|
272
|
+
export type MRT_Column<D extends Record<string, any> = {}> = Omit<
|
|
278
273
|
Column<D>,
|
|
279
274
|
'header' | 'footer' | 'columns'
|
|
280
275
|
> &
|
|
281
|
-
|
|
282
|
-
columns?:
|
|
276
|
+
MRT_ColumnDef<D> & {
|
|
277
|
+
columns?: MRT_Column<D>[];
|
|
283
278
|
};
|
|
284
279
|
|
|
285
280
|
export type MRT_Header<D extends Record<string, any> = {}> = Omit<
|
|
286
281
|
Header<D>,
|
|
287
282
|
'column'
|
|
288
283
|
> & {
|
|
289
|
-
column:
|
|
284
|
+
column: MRT_Column<D>;
|
|
290
285
|
};
|
|
291
286
|
|
|
292
287
|
export type MRT_HeaderGroup<D extends Record<string, any> = {}> = Omit<
|
|
@@ -319,7 +314,7 @@ export type MRT_Cell<D extends Record<string, any> = {}> = Omit<
|
|
|
319
314
|
Cell<D>,
|
|
320
315
|
'column' | 'row'
|
|
321
316
|
> & {
|
|
322
|
-
column:
|
|
317
|
+
column: MRT_Column<D>;
|
|
323
318
|
row: MRT_Row<D>;
|
|
324
319
|
};
|
|
325
320
|
|
|
@@ -329,27 +324,26 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
329
324
|
MRT_TableOptions<D> & {
|
|
330
325
|
enableClickToCopy?: boolean;
|
|
331
326
|
enableColumnActions?: boolean;
|
|
332
|
-
enableColumnPinning?: boolean;
|
|
333
327
|
enableDensePaddingToggle?: boolean;
|
|
328
|
+
enableEditing?: boolean;
|
|
334
329
|
enableExpandAll?: boolean;
|
|
335
330
|
enableFullScreenToggle?: boolean;
|
|
336
331
|
enablePagination?: boolean;
|
|
337
332
|
enableRowActions?: boolean;
|
|
338
|
-
enableStickyHeader?: boolean;
|
|
339
|
-
enableEditing?: boolean;
|
|
340
333
|
enableRowNumbers?: boolean;
|
|
341
334
|
enableSelectAll?: boolean;
|
|
335
|
+
enableStickyHeader?: boolean;
|
|
336
|
+
enableTableFooter?: boolean;
|
|
337
|
+
enableTableHead?: boolean;
|
|
338
|
+
enableToolbarBottom?: boolean;
|
|
339
|
+
enableToolbarInternalActions?: boolean;
|
|
340
|
+
enableToolbarTop?: boolean;
|
|
342
341
|
enabledGlobalFilterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
343
342
|
filterTypes?: { [key in MRT_FILTER_TYPE]: any };
|
|
344
|
-
hideTableFooter?: boolean;
|
|
345
|
-
hideTableHead?: boolean;
|
|
346
|
-
hideToolbarBottom?: boolean;
|
|
347
|
-
hideToolbarInternalActions?: boolean;
|
|
348
|
-
hideToolbarTop?: boolean;
|
|
349
343
|
icons?: Partial<MRT_Icons>;
|
|
350
344
|
idPrefix?: string;
|
|
351
|
-
isReloading?: boolean;
|
|
352
345
|
isLoading?: boolean;
|
|
346
|
+
isReloading?: boolean;
|
|
353
347
|
localization?: Partial<MRT_Localization>;
|
|
354
348
|
muiLinearProgressProps?:
|
|
355
349
|
| LinearProgressProps
|
|
@@ -451,7 +445,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
451
445
|
column,
|
|
452
446
|
}: {
|
|
453
447
|
tableInstance: MRT_TableInstance;
|
|
454
|
-
column:
|
|
448
|
+
column: MRT_Column<D>;
|
|
455
449
|
}) => TableCellProps);
|
|
456
450
|
muiTableFooterProps?:
|
|
457
451
|
| TableFooterProps
|
|
@@ -476,7 +470,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
476
470
|
column,
|
|
477
471
|
}: {
|
|
478
472
|
tableInstance: MRT_TableInstance;
|
|
479
|
-
column:
|
|
473
|
+
column: MRT_Column<D>;
|
|
480
474
|
}) => IconButtonProps);
|
|
481
475
|
muiTableHeadCellFilterTextFieldProps?:
|
|
482
476
|
| TextFieldProps
|
|
@@ -485,7 +479,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
485
479
|
column,
|
|
486
480
|
}: {
|
|
487
481
|
tableInstance: MRT_TableInstance;
|
|
488
|
-
column:
|
|
482
|
+
column: MRT_Column<D>;
|
|
489
483
|
}) => TextFieldProps);
|
|
490
484
|
muiTableHeadCellProps?:
|
|
491
485
|
| TableCellProps
|
|
@@ -494,7 +488,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
494
488
|
column,
|
|
495
489
|
}: {
|
|
496
490
|
tableInstance: MRT_TableInstance;
|
|
497
|
-
column:
|
|
491
|
+
column: MRT_Column<D>;
|
|
498
492
|
}) => TableCellProps);
|
|
499
493
|
muiTableHeadProps?:
|
|
500
494
|
| TableHeadProps
|
|
@@ -563,15 +557,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
563
557
|
tableInstance: MRT_TableInstance<D>;
|
|
564
558
|
event: MouseEvent<HTMLTableCellElement>;
|
|
565
559
|
}) => void;
|
|
566
|
-
onColumnHide?: ({
|
|
567
|
-
column,
|
|
568
|
-
columnVisibility,
|
|
569
|
-
tableInstance,
|
|
570
|
-
}: {
|
|
571
|
-
column: MRT_ColumnInstance<D>;
|
|
572
|
-
columnVisibility: VisibilityState;
|
|
573
|
-
tableInstance: MRT_TableInstance<D>;
|
|
574
|
-
}) => void;
|
|
575
560
|
onDetailPanelClick?: ({
|
|
576
561
|
event,
|
|
577
562
|
row,
|
|
@@ -581,7 +566,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
581
566
|
row: MRT_Row<D>;
|
|
582
567
|
tableInstance: MRT_TableInstance<D>;
|
|
583
568
|
}) => void;
|
|
584
|
-
|
|
569
|
+
onGlobalSearchFilterChange?: ({
|
|
585
570
|
event,
|
|
586
571
|
tableInstance,
|
|
587
572
|
}: {
|
|
@@ -632,6 +617,51 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
632
617
|
selectedRows: MRT_Row<D>[];
|
|
633
618
|
tableInstance: MRT_TableInstance<D>;
|
|
634
619
|
}) => void;
|
|
620
|
+
onToggleColumnVisibility?: ({
|
|
621
|
+
column,
|
|
622
|
+
columnVisibility,
|
|
623
|
+
tableInstance,
|
|
624
|
+
}: {
|
|
625
|
+
column: MRT_Column<D>;
|
|
626
|
+
columnVisibility: VisibilityState;
|
|
627
|
+
tableInstance: MRT_TableInstance<D>;
|
|
628
|
+
}) => void;
|
|
629
|
+
onToggleDensePadding?: ({
|
|
630
|
+
event,
|
|
631
|
+
isDensePadding,
|
|
632
|
+
tableInstance,
|
|
633
|
+
}: {
|
|
634
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
635
|
+
isDensePadding: boolean;
|
|
636
|
+
tableInstance: MRT_TableInstance<D>;
|
|
637
|
+
}) => void;
|
|
638
|
+
onToggleFullScreen?: ({
|
|
639
|
+
event,
|
|
640
|
+
isFullScreen,
|
|
641
|
+
tableInstance,
|
|
642
|
+
}: {
|
|
643
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
644
|
+
isFullScreen: boolean;
|
|
645
|
+
tableInstance: MRT_TableInstance<D>;
|
|
646
|
+
}) => void;
|
|
647
|
+
onToggleShowFilters?: ({
|
|
648
|
+
event,
|
|
649
|
+
showFilters,
|
|
650
|
+
tableInstance,
|
|
651
|
+
}: {
|
|
652
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
653
|
+
showFilters: boolean;
|
|
654
|
+
tableInstance: MRT_TableInstance<D>;
|
|
655
|
+
}) => void;
|
|
656
|
+
onToggleShowGlobalFilter?: ({
|
|
657
|
+
event,
|
|
658
|
+
showGlobalFilter,
|
|
659
|
+
tableInstance,
|
|
660
|
+
}: {
|
|
661
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
662
|
+
showGlobalFilter: boolean;
|
|
663
|
+
tableInstance: MRT_TableInstance<D>;
|
|
664
|
+
}) => void;
|
|
635
665
|
positionActionsColumn?: 'first' | 'last';
|
|
636
666
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
637
667
|
positionToolbarActions?: 'bottom' | 'top';
|
|
@@ -666,14 +696,14 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
666
696
|
}) => ReactNode;
|
|
667
697
|
renderToolbarInternalActions?: ({
|
|
668
698
|
tableInstance,
|
|
669
|
-
|
|
699
|
+
MRT_ToggleGlobalFilterButton,
|
|
670
700
|
MRT_ToggleFiltersButton,
|
|
671
701
|
MRT_ShowHideColumnsButton,
|
|
672
702
|
MRT_ToggleDensePaddingButton,
|
|
673
703
|
MRT_FullScreenToggleButton,
|
|
674
704
|
}: {
|
|
675
705
|
tableInstance: MRT_TableInstance<D>;
|
|
676
|
-
|
|
706
|
+
MRT_ToggleGlobalFilterButton: FC<
|
|
677
707
|
IconButtonProps & { tableInstance: MRT_TableInstance<D> }
|
|
678
708
|
>;
|
|
679
709
|
MRT_ToggleFiltersButton: FC<
|
|
@@ -692,17 +722,25 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
692
722
|
};
|
|
693
723
|
|
|
694
724
|
export default <D extends Record<string, any> = {}>({
|
|
725
|
+
autoResetExpanded = false,
|
|
695
726
|
enableColumnActions = true,
|
|
696
727
|
enableColumnFilters = true,
|
|
697
728
|
enableDensePaddingToggle = true,
|
|
698
729
|
enableExpandAll = true,
|
|
730
|
+
enableFilters = true,
|
|
699
731
|
enableFullScreenToggle = true,
|
|
700
732
|
enableGlobalFilter = true,
|
|
701
733
|
enableHiding = true,
|
|
734
|
+
enableMultiRowSelection = true,
|
|
702
735
|
enablePagination = true,
|
|
703
736
|
enableSelectAll = true,
|
|
704
737
|
enableSorting = true,
|
|
705
738
|
enableStickyHeader = true,
|
|
739
|
+
enableTableFooter = true,
|
|
740
|
+
enableTableHead = true,
|
|
741
|
+
enableToolbarBottom = true,
|
|
742
|
+
enableToolbarInternalActions = true,
|
|
743
|
+
enableToolbarTop = true,
|
|
706
744
|
icons,
|
|
707
745
|
localization,
|
|
708
746
|
positionActionsColumn = 'first',
|
|
@@ -712,17 +750,25 @@ export default <D extends Record<string, any> = {}>({
|
|
|
712
750
|
...rest
|
|
713
751
|
}: MaterialReactTableProps<D>) => (
|
|
714
752
|
<MRT_TableRoot
|
|
753
|
+
autoResetExpanded={autoResetExpanded}
|
|
715
754
|
enableColumnActions={enableColumnActions}
|
|
716
755
|
enableColumnFilters={enableColumnFilters}
|
|
717
756
|
enableDensePaddingToggle={enableDensePaddingToggle}
|
|
718
757
|
enableExpandAll={enableExpandAll}
|
|
758
|
+
enableFilters={enableFilters}
|
|
719
759
|
enableFullScreenToggle={enableFullScreenToggle}
|
|
720
760
|
enableGlobalFilter={enableGlobalFilter}
|
|
721
761
|
enableHiding={enableHiding}
|
|
762
|
+
enableMultiRowSelection={enableMultiRowSelection}
|
|
722
763
|
enablePagination={enablePagination}
|
|
723
764
|
enableSelectAll={enableSelectAll}
|
|
724
765
|
enableSorting={enableSorting}
|
|
725
766
|
enableStickyHeader={enableStickyHeader}
|
|
767
|
+
enableTableFooter={enableTableFooter}
|
|
768
|
+
enableTableHead={enableTableHead}
|
|
769
|
+
enableToolbarBottom={enableToolbarBottom}
|
|
770
|
+
enableToolbarInternalActions={enableToolbarInternalActions}
|
|
771
|
+
enableToolbarTop={enableToolbarTop}
|
|
726
772
|
icons={{ ...MRT_Default_Icons, ...icons }}
|
|
727
773
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
728
774
|
positionActionsColumn={positionActionsColumn}
|
|
@@ -15,7 +15,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
15
15
|
getState,
|
|
16
16
|
options: {
|
|
17
17
|
enableClickToCopy,
|
|
18
|
-
|
|
18
|
+
enablePinning,
|
|
19
19
|
enableEditing,
|
|
20
20
|
isLoading,
|
|
21
21
|
muiTableBodyCellProps,
|
|
@@ -73,7 +73,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
73
73
|
: undefined,
|
|
74
74
|
transition: 'all 0.2s ease-in-out',
|
|
75
75
|
whiteSpace:
|
|
76
|
-
isDensePadding || (
|
|
76
|
+
isDensePadding || (enablePinning && getIsSomeColumnsPinned())
|
|
77
77
|
? 'nowrap'
|
|
78
78
|
: 'normal',
|
|
79
79
|
//@ts-ignore
|
|
@@ -87,6 +87,8 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
87
87
|
width={skeletonWidth}
|
|
88
88
|
{...muiTableBodyCellSkeletonProps}
|
|
89
89
|
/>
|
|
90
|
+
) : column.columnDefType === 'display' ? (
|
|
91
|
+
column.Cell?.({ cell, tableInstance })
|
|
90
92
|
) : cell.getIsPlaceholder() ||
|
|
91
93
|
(row.getIsGrouped() &&
|
|
92
94
|
column.id !==
|
|
@@ -100,7 +102,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
100
102
|
column.enableClickToCopy !== false ? (
|
|
101
103
|
<>
|
|
102
104
|
<MRT_CopyButton cell={cell} tableInstance={tableInstance}>
|
|
103
|
-
{cell.renderCell()}
|
|
105
|
+
{cell.column?.Cell?.({ cell, tableInstance }) ?? cell.renderCell()}
|
|
104
106
|
</MRT_CopyButton>
|
|
105
107
|
{row.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
106
108
|
</>
|
|
@@ -15,8 +15,8 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, tableInstance }) => {
|
|
|
15
15
|
icons: { CancelIcon, SaveIcon },
|
|
16
16
|
localization,
|
|
17
17
|
onEditSubmit,
|
|
18
|
-
setCurrentEditingRow,
|
|
19
18
|
},
|
|
19
|
+
setCurrentEditingRow,
|
|
20
20
|
} = tableInstance;
|
|
21
21
|
|
|
22
22
|
const { currentEditingRow } = getState();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -15,18 +15,27 @@ export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onToggleFullScreen,
|
|
19
19
|
},
|
|
20
|
+
setIsFullScreen,
|
|
20
21
|
} = tableInstance;
|
|
21
22
|
|
|
22
23
|
const { isFullScreen } = getState();
|
|
23
24
|
|
|
25
|
+
const handleToggleFullScreen = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
onToggleFullScreen?.({
|
|
27
|
+
event,
|
|
28
|
+
isFullScreen: !isFullScreen,
|
|
29
|
+
tableInstance,
|
|
30
|
+
});
|
|
31
|
+
setIsFullScreen(!isFullScreen);
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
return (
|
|
25
35
|
<Tooltip arrow title={localization.toggleFullScreen}>
|
|
26
36
|
<IconButton
|
|
27
37
|
aria-label={localization.showHideFilters}
|
|
28
|
-
onClick={
|
|
29
|
-
size="small"
|
|
38
|
+
onClick={handleToggleFullScreen}
|
|
30
39
|
{...rest}
|
|
31
40
|
>
|
|
32
41
|
{isFullScreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -15,18 +15,27 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onToggleDensePadding,
|
|
19
19
|
},
|
|
20
|
+
setIsDensePadding,
|
|
20
21
|
} = tableInstance;
|
|
21
22
|
|
|
22
23
|
const { isDensePadding } = getState();
|
|
23
24
|
|
|
25
|
+
const handleToggleDensePadding = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
onToggleDensePadding?.({
|
|
27
|
+
event,
|
|
28
|
+
isDensePadding: !isDensePadding,
|
|
29
|
+
tableInstance,
|
|
30
|
+
});
|
|
31
|
+
setIsDensePadding(!isDensePadding);
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
return (
|
|
25
35
|
<Tooltip arrow title={localization.toggleDensePadding}>
|
|
26
36
|
<IconButton
|
|
27
37
|
aria-label={localization.toggleDensePadding}
|
|
28
|
-
onClick={
|
|
29
|
-
size="small"
|
|
38
|
+
onClick={handleToggleDensePadding}
|
|
30
39
|
{...rest}
|
|
31
40
|
>
|
|
32
41
|
{isDensePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -15,18 +15,27 @@ export const MRT_ToggleFiltersButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { FilterListIcon, FilterListOffIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onToggleShowFilters,
|
|
19
19
|
},
|
|
20
|
+
setShowFilters,
|
|
20
21
|
} = tableInstance;
|
|
21
22
|
|
|
22
23
|
const { showFilters } = getState();
|
|
23
24
|
|
|
25
|
+
const handleToggleShowFilters = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
onToggleShowFilters?.({
|
|
27
|
+
event,
|
|
28
|
+
showFilters: !showFilters,
|
|
29
|
+
tableInstance,
|
|
30
|
+
});
|
|
31
|
+
setShowFilters(!showFilters);
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
return (
|
|
25
35
|
<Tooltip arrow title={localization.showHideFilters}>
|
|
26
36
|
<IconButton
|
|
27
37
|
aria-label={localization.showHideFilters}
|
|
28
|
-
onClick={
|
|
29
|
-
size="small"
|
|
38
|
+
onClick={handleToggleShowFilters}
|
|
30
39
|
{...rest}
|
|
31
40
|
>
|
|
32
41
|
{showFilters ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ interface Props extends IconButtonProps {
|
|
|
6
6
|
tableInstance: MRT_TableInstance;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const MRT_ToggleGlobalFilterButton: FC<Props> = ({
|
|
10
10
|
tableInstance,
|
|
11
11
|
...rest
|
|
12
12
|
}) => {
|
|
@@ -17,19 +17,25 @@ export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
|
17
17
|
idPrefix,
|
|
18
18
|
localization,
|
|
19
19
|
muiSearchTextFieldProps,
|
|
20
|
-
|
|
20
|
+
onToggleShowGlobalFilter,
|
|
21
21
|
},
|
|
22
|
+
setShowGlobalFilter,
|
|
22
23
|
} = tableInstance;
|
|
23
24
|
|
|
24
|
-
const {
|
|
25
|
+
const { showGlobalFilter } = getState();
|
|
25
26
|
|
|
26
27
|
const textFieldProps =
|
|
27
28
|
muiSearchTextFieldProps instanceof Function
|
|
28
29
|
? muiSearchTextFieldProps({ tableInstance })
|
|
29
30
|
: muiSearchTextFieldProps;
|
|
30
31
|
|
|
31
|
-
const handleToggleSearch = () => {
|
|
32
|
-
|
|
32
|
+
const handleToggleSearch = (event: MouseEvent<HTMLButtonElement>) => {
|
|
33
|
+
onToggleShowGlobalFilter?.({
|
|
34
|
+
event,
|
|
35
|
+
showGlobalFilter: !showGlobalFilter,
|
|
36
|
+
tableInstance,
|
|
37
|
+
});
|
|
38
|
+
setShowGlobalFilter(!showGlobalFilter);
|
|
33
39
|
setTimeout(
|
|
34
40
|
() =>
|
|
35
41
|
document
|
|
@@ -43,8 +49,8 @@ export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
|
43
49
|
|
|
44
50
|
return (
|
|
45
51
|
<Tooltip arrow title={localization.showHideSearch}>
|
|
46
|
-
<IconButton
|
|
47
|
-
{
|
|
52
|
+
<IconButton onClick={handleToggleSearch} {...rest}>
|
|
53
|
+
{showGlobalFilter ? <SearchOffIcon /> : <SearchIcon />}
|
|
48
54
|
</IconButton>
|
|
49
55
|
</Tooltip>
|
|
50
56
|
);
|