material-react-table 0.36.2 → 0.37.2
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 +7 -3
- package/dist/cjs/MaterialReactTable.d.ts +34 -15
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/cjs/buttons/MRT_CopyButton.d.ts +5 -5
- package/dist/cjs/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/cjs/column.utils.d.ts +2 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +172 -122
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +34 -15
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/esm/buttons/MRT_CopyButton.d.ts +5 -5
- package/dist/esm/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/esm/column.utils.d.ts +2 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +172 -123
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +42 -16
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +49 -11
- package/src/body/MRT_EditRowModal.tsx +21 -19
- package/src/body/MRT_TableBodyCell.tsx +12 -26
- package/src/body/MRT_TableBodyCellValue.tsx +27 -0
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
- package/src/buttons/MRT_CopyButton.tsx +11 -7
- package/src/buttons/MRT_EditActionButtons.tsx +13 -4
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +9 -4
- package/src/column.utils.ts +15 -10
- package/src/head/MRT_TableHeadCell.tsx +3 -5
- package/src/index.tsx +2 -0
- package/src/inputs/MRT_EditCellTextField.tsx +16 -5
- package/src/inputs/MRT_FilterTextField.tsx +9 -6
- package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +2 -12
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TableRoot.tsx +45 -27
- package/src/toolbar/MRT_BottomToolbar.tsx +9 -5
- package/src/toolbar/MRT_TopToolbar.tsx +8 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction, ReactNode, DragEvent } from 'react';
|
|
1
|
+
import { MutableRefObject, Dispatch, SetStateAction, ReactNode, DragEvent } from 'react';
|
|
2
2
|
import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps, ToolbarProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, PaperProps, TableProps, AlertProps } from '@mui/material';
|
|
3
3
|
import { Row, Table, TableState, ColumnDef, DeepKeys, Column, Header, HeaderGroup, Cell, SortingFn, FilterFn, TableOptions, OnChangeFn } from '@tanstack/react-table';
|
|
4
4
|
import { Options } from 'react-virtual';
|
|
@@ -223,9 +223,16 @@ declare type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<Ta
|
|
|
223
223
|
getState: () => MRT_TableState<TData>;
|
|
224
224
|
options: MaterialReactTableProps<TData> & {
|
|
225
225
|
icons: MRT_Icons;
|
|
226
|
-
tableId: string;
|
|
227
226
|
localization: MRT_Localization;
|
|
228
227
|
};
|
|
228
|
+
refs: {
|
|
229
|
+
bottomToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
230
|
+
editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
231
|
+
filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
232
|
+
searchInputRef: MutableRefObject<HTMLInputElement>;
|
|
233
|
+
tableContainerRef: MutableRefObject<HTMLDivElement>;
|
|
234
|
+
topToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
235
|
+
};
|
|
229
236
|
setColumnFilterFns: Dispatch<SetStateAction<{
|
|
230
237
|
[key: string]: MRT_FilterOption;
|
|
231
238
|
}>>;
|
|
@@ -269,19 +276,22 @@ declare type MRT_TableState<TData extends Record<string, any> = {}> = TableState
|
|
|
269
276
|
showSkeletons: boolean;
|
|
270
277
|
};
|
|
271
278
|
declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<ColumnDef<TData, unknown>, 'aggregatedCell' | 'cell' | 'columns' | 'filterFn' | 'footer' | 'header' | 'id' | 'sortingFn'> & {
|
|
272
|
-
AggregatedCell?: ({ cell, column, table, }: {
|
|
279
|
+
AggregatedCell?: ({ cell, column, row, table, }: {
|
|
273
280
|
cell: MRT_Cell<TData>;
|
|
274
281
|
column: MRT_Column<TData>;
|
|
282
|
+
row: MRT_Row<TData>;
|
|
275
283
|
table: MRT_TableInstance<TData>;
|
|
276
284
|
}) => ReactNode;
|
|
277
|
-
Cell?: ({ cell, column, table, }: {
|
|
285
|
+
Cell?: ({ cell, column, row, table, }: {
|
|
278
286
|
cell: MRT_Cell<TData>;
|
|
279
287
|
column: MRT_Column<TData>;
|
|
288
|
+
row: MRT_Row<TData>;
|
|
280
289
|
table: MRT_TableInstance<TData>;
|
|
281
290
|
}) => ReactNode;
|
|
282
|
-
Edit?: ({ cell, column, table, }: {
|
|
291
|
+
Edit?: ({ cell, column, row, table, }: {
|
|
283
292
|
cell: MRT_Cell<TData>;
|
|
284
293
|
column: MRT_Column<TData>;
|
|
294
|
+
row: MRT_Row<TData>;
|
|
285
295
|
table: MRT_TableInstance<TData>;
|
|
286
296
|
}) => ReactNode;
|
|
287
297
|
Filter?: ({ column, header, table, }: {
|
|
@@ -360,8 +370,10 @@ declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<Column
|
|
|
360
370
|
table: MRT_TableInstance<TData>;
|
|
361
371
|
cell: MRT_Cell<TData>;
|
|
362
372
|
}) => ButtonProps);
|
|
363
|
-
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, table, }: {
|
|
373
|
+
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
|
|
364
374
|
cell: MRT_Cell<TData>;
|
|
375
|
+
column: MRT_Column<TData>;
|
|
376
|
+
row: MRT_Row<TData>;
|
|
365
377
|
table: MRT_TableInstance<TData>;
|
|
366
378
|
}) => TextFieldProps);
|
|
367
379
|
muiTableBodyCellProps?: TableCellProps | (({ cell, table, }: {
|
|
@@ -422,7 +434,7 @@ declare type MRT_SortingOption = LiteralUnion<string & keyof typeof MRT_SortingF
|
|
|
422
434
|
declare type MRT_SortingFn<TData extends Record<string, any> = {}> = SortingFn<TData> | MRT_SortingOption;
|
|
423
435
|
declare type MRT_FilterOption = LiteralUnion<string & keyof typeof MRT_FilterFns>;
|
|
424
436
|
declare type MRT_FilterFn<TData extends Record<string, any> = {}> = FilterFn<TData> | MRT_FilterOption;
|
|
425
|
-
declare type MRT_DisplayColumnIds = 'mrt-row-
|
|
437
|
+
declare type MRT_DisplayColumnIds = 'mrt-row-actions' | 'mrt-row-drag' | 'mrt-row-expand' | 'mrt-row-numbers' | 'mrt-row-select';
|
|
426
438
|
/**
|
|
427
439
|
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
|
428
440
|
*
|
|
@@ -492,17 +504,23 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
492
504
|
table: MRT_TableInstance<TData>;
|
|
493
505
|
row: MRT_Row<TData>;
|
|
494
506
|
}) => CheckboxProps);
|
|
495
|
-
muiTableBodyCellCopyButtonProps?: ButtonProps | (({
|
|
496
|
-
table: MRT_TableInstance<TData>;
|
|
507
|
+
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, column, row, table, }: {
|
|
497
508
|
cell: MRT_Cell<TData>;
|
|
509
|
+
column: MRT_Column<TData>;
|
|
510
|
+
row: MRT_Row<TData>;
|
|
511
|
+
table: MRT_TableInstance<TData>;
|
|
498
512
|
}) => ButtonProps);
|
|
499
|
-
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, table, }: {
|
|
513
|
+
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
|
|
500
514
|
cell: MRT_Cell<TData>;
|
|
515
|
+
column: MRT_Column<TData>;
|
|
516
|
+
row: MRT_Row<TData>;
|
|
501
517
|
table: MRT_TableInstance<TData>;
|
|
502
518
|
}) => TextFieldProps);
|
|
503
|
-
muiTableBodyCellProps?: TableCellProps | (({
|
|
504
|
-
table: MRT_TableInstance<TData>;
|
|
519
|
+
muiTableBodyCellProps?: TableCellProps | (({ cell, column, row, table, }: {
|
|
505
520
|
cell: MRT_Cell<TData>;
|
|
521
|
+
column: MRT_Column<TData>;
|
|
522
|
+
row: MRT_Row<TData>;
|
|
523
|
+
table: MRT_TableInstance<TData>;
|
|
506
524
|
}) => TableCellProps);
|
|
507
525
|
muiTableBodyCellSkeletonProps?: SkeletonProps | (({ table, cell, }: {
|
|
508
526
|
table: MRT_TableInstance<TData>;
|
|
@@ -589,7 +607,8 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
589
607
|
onDensityChange?: OnChangeFn<boolean>;
|
|
590
608
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
591
609
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
592
|
-
onEditingRowSave?: ({ row, table, values, }: {
|
|
610
|
+
onEditingRowSave?: ({ exitEditingMode, row, table, values, }: {
|
|
611
|
+
exitEditingMode: () => void;
|
|
593
612
|
row: MRT_Row<TData>;
|
|
594
613
|
table: MRT_TableInstance<TData>;
|
|
595
614
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
@@ -631,7 +650,8 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
631
650
|
row: MRT_Row<TData>;
|
|
632
651
|
table: MRT_TableInstance<TData>;
|
|
633
652
|
}) => ReactNode[];
|
|
634
|
-
renderRowActions?: ({ row, table, }: {
|
|
653
|
+
renderRowActions?: ({ cell, row, table, }: {
|
|
654
|
+
cell: MRT_Cell<TData>;
|
|
635
655
|
row: MRT_Row<TData>;
|
|
636
656
|
table: MRT_TableInstance<TData>;
|
|
637
657
|
}) => ReactNode;
|
|
@@ -645,13 +665,19 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
645
665
|
rowNumberMode?: 'original' | 'static';
|
|
646
666
|
selectAllMode?: 'all' | 'page';
|
|
647
667
|
state?: Partial<MRT_TableState<TData>>;
|
|
648
|
-
tableId?: string;
|
|
649
668
|
virtualizerProps?: Partial<Options<HTMLDivElement>> | (({ table, }: {
|
|
650
669
|
table: MRT_TableInstance<TData>;
|
|
651
670
|
}) => Partial<Options<HTMLDivElement>>);
|
|
652
671
|
};
|
|
653
672
|
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilterChangeMode, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterChangeMode, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
|
654
673
|
|
|
674
|
+
interface Props$6<TData extends Record<string, any> = {}> {
|
|
675
|
+
cell: MRT_Cell<TData>;
|
|
676
|
+
children: ReactNode;
|
|
677
|
+
table: MRT_TableInstance<TData>;
|
|
678
|
+
}
|
|
679
|
+
declare const MRT_CopyButton: <TData extends Record<string, any> = {}>({ cell, children, table, }: Props$6<TData>) => JSX.Element;
|
|
680
|
+
|
|
655
681
|
interface Props$5<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
656
682
|
table: MRT_TableInstance<TData>;
|
|
657
683
|
}
|
|
@@ -682,4 +708,4 @@ interface Props<TData extends Record<string, any> = {}> extends IconButtonProps
|
|
|
682
708
|
}
|
|
683
709
|
declare const MRT_ToggleGlobalFilterButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props<TData>) => JSX.Element;
|
|
684
710
|
|
|
685
|
-
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, _default as default };
|
|
711
|
+
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_CopyButton, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, _default as default };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.37.2",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@emotion/styled": "^11.10.0",
|
|
56
56
|
"@faker-js/faker": "^7.4.0",
|
|
57
57
|
"@mui/icons-material": "^5.8.4",
|
|
58
|
-
"@mui/material": "^5.10.
|
|
58
|
+
"@mui/material": "^5.10.1",
|
|
59
59
|
"@rollup/plugin-babel": "^5.3.1",
|
|
60
60
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
61
61
|
"@rollup/plugin-typescript": "^8.3.4",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"@types/react": "^18.0.17",
|
|
72
72
|
"@types/react-dom": "^18.0.6",
|
|
73
73
|
"babel-loader": "^8.2.5",
|
|
74
|
-
"eslint": "^8.
|
|
74
|
+
"eslint": "^8.22.0",
|
|
75
75
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
76
76
|
"husky": "^8.0.1",
|
|
77
77
|
"prettier": "^2.7.1",
|
|
78
78
|
"react": "^18.2.0",
|
|
79
79
|
"react-dom": "^18.2.0",
|
|
80
80
|
"react-is": "^18.2.0",
|
|
81
|
-
"rollup": "^2.
|
|
81
|
+
"rollup": "^2.78.0",
|
|
82
82
|
"rollup-plugin-dts": "^4.2.2",
|
|
83
83
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
84
84
|
"size-limit": "^8.0.1",
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
Dispatch,
|
|
3
|
+
DragEvent,
|
|
4
|
+
MutableRefObject,
|
|
5
|
+
ReactNode,
|
|
6
|
+
SetStateAction,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import type {
|
|
3
9
|
AlertProps,
|
|
4
10
|
ButtonProps,
|
|
@@ -86,9 +92,16 @@ export type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<
|
|
|
86
92
|
getState: () => MRT_TableState<TData>;
|
|
87
93
|
options: MaterialReactTableProps<TData> & {
|
|
88
94
|
icons: MRT_Icons;
|
|
89
|
-
tableId: string;
|
|
90
95
|
localization: MRT_Localization;
|
|
91
96
|
};
|
|
97
|
+
refs: {
|
|
98
|
+
bottomToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
99
|
+
editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
100
|
+
filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
101
|
+
searchInputRef: MutableRefObject<HTMLInputElement>;
|
|
102
|
+
tableContainerRef: MutableRefObject<HTMLDivElement>;
|
|
103
|
+
topToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
104
|
+
};
|
|
92
105
|
setColumnFilterFns: Dispatch<
|
|
93
106
|
SetStateAction<{ [key: string]: MRT_FilterOption }>
|
|
94
107
|
>;
|
|
@@ -144,28 +157,34 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
144
157
|
AggregatedCell?: ({
|
|
145
158
|
cell,
|
|
146
159
|
column,
|
|
160
|
+
row,
|
|
147
161
|
table,
|
|
148
162
|
}: {
|
|
149
163
|
cell: MRT_Cell<TData>;
|
|
150
164
|
column: MRT_Column<TData>;
|
|
165
|
+
row: MRT_Row<TData>;
|
|
151
166
|
table: MRT_TableInstance<TData>;
|
|
152
167
|
}) => ReactNode;
|
|
153
168
|
Cell?: ({
|
|
154
169
|
cell,
|
|
155
170
|
column,
|
|
171
|
+
row,
|
|
156
172
|
table,
|
|
157
173
|
}: {
|
|
158
174
|
cell: MRT_Cell<TData>;
|
|
159
175
|
column: MRT_Column<TData>;
|
|
176
|
+
row: MRT_Row<TData>;
|
|
160
177
|
table: MRT_TableInstance<TData>;
|
|
161
178
|
}) => ReactNode;
|
|
162
179
|
Edit?: ({
|
|
163
180
|
cell,
|
|
164
181
|
column,
|
|
182
|
+
row,
|
|
165
183
|
table,
|
|
166
184
|
}: {
|
|
167
185
|
cell: MRT_Cell<TData>;
|
|
168
186
|
column: MRT_Column<TData>;
|
|
187
|
+
row: MRT_Row<TData>;
|
|
169
188
|
table: MRT_TableInstance<TData>;
|
|
170
189
|
}) => ReactNode;
|
|
171
190
|
Filter?: ({
|
|
@@ -266,9 +285,13 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
266
285
|
| TextFieldProps
|
|
267
286
|
| (({
|
|
268
287
|
cell,
|
|
288
|
+
column,
|
|
289
|
+
row,
|
|
269
290
|
table,
|
|
270
291
|
}: {
|
|
271
292
|
cell: MRT_Cell<TData>;
|
|
293
|
+
column: MRT_Column<TData>;
|
|
294
|
+
row: MRT_Row<TData>;
|
|
272
295
|
table: MRT_TableInstance<TData>;
|
|
273
296
|
}) => TextFieldProps);
|
|
274
297
|
muiTableBodyCellProps?:
|
|
@@ -398,11 +421,11 @@ export type MRT_FilterFn<TData extends Record<string, any> = {}> =
|
|
|
398
421
|
| MRT_FilterOption;
|
|
399
422
|
|
|
400
423
|
export type MRT_DisplayColumnIds =
|
|
401
|
-
| 'mrt-row-drag'
|
|
402
424
|
| 'mrt-row-actions'
|
|
425
|
+
| 'mrt-row-drag'
|
|
403
426
|
| 'mrt-row-expand'
|
|
404
|
-
| 'mrt-row-
|
|
405
|
-
| 'mrt-row-
|
|
427
|
+
| 'mrt-row-numbers'
|
|
428
|
+
| 'mrt-row-select';
|
|
406
429
|
|
|
407
430
|
/**
|
|
408
431
|
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
|
@@ -501,29 +524,41 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
501
524
|
muiTableBodyCellCopyButtonProps?:
|
|
502
525
|
| ButtonProps
|
|
503
526
|
| (({
|
|
504
|
-
table,
|
|
505
527
|
cell,
|
|
528
|
+
column,
|
|
529
|
+
row,
|
|
530
|
+
table,
|
|
506
531
|
}: {
|
|
507
|
-
table: MRT_TableInstance<TData>;
|
|
508
532
|
cell: MRT_Cell<TData>;
|
|
533
|
+
column: MRT_Column<TData>;
|
|
534
|
+
row: MRT_Row<TData>;
|
|
535
|
+
table: MRT_TableInstance<TData>;
|
|
509
536
|
}) => ButtonProps);
|
|
510
537
|
muiTableBodyCellEditTextFieldProps?:
|
|
511
538
|
| TextFieldProps
|
|
512
539
|
| (({
|
|
513
540
|
cell,
|
|
541
|
+
column,
|
|
542
|
+
row,
|
|
514
543
|
table,
|
|
515
544
|
}: {
|
|
516
545
|
cell: MRT_Cell<TData>;
|
|
546
|
+
column: MRT_Column<TData>;
|
|
547
|
+
row: MRT_Row<TData>;
|
|
517
548
|
table: MRT_TableInstance<TData>;
|
|
518
549
|
}) => TextFieldProps);
|
|
519
550
|
muiTableBodyCellProps?:
|
|
520
551
|
| TableCellProps
|
|
521
552
|
| (({
|
|
522
|
-
table,
|
|
523
553
|
cell,
|
|
554
|
+
column,
|
|
555
|
+
row,
|
|
556
|
+
table,
|
|
524
557
|
}: {
|
|
525
|
-
table: MRT_TableInstance<TData>;
|
|
526
558
|
cell: MRT_Cell<TData>;
|
|
559
|
+
column: MRT_Column<TData>;
|
|
560
|
+
row: MRT_Row<TData>;
|
|
561
|
+
table: MRT_TableInstance<TData>;
|
|
527
562
|
}) => TableCellProps);
|
|
528
563
|
muiTableBodyCellSkeletonProps?:
|
|
529
564
|
| SkeletonProps
|
|
@@ -677,10 +712,12 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
677
712
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
678
713
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
679
714
|
onEditingRowSave?: ({
|
|
715
|
+
exitEditingMode,
|
|
680
716
|
row,
|
|
681
717
|
table,
|
|
682
718
|
values,
|
|
683
719
|
}: {
|
|
720
|
+
exitEditingMode: () => void;
|
|
684
721
|
row: MRT_Row<TData>;
|
|
685
722
|
table: MRT_TableInstance<TData>;
|
|
686
723
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
@@ -732,9 +769,11 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
732
769
|
table: MRT_TableInstance<TData>;
|
|
733
770
|
}) => ReactNode[];
|
|
734
771
|
renderRowActions?: ({
|
|
772
|
+
cell,
|
|
735
773
|
row,
|
|
736
774
|
table,
|
|
737
775
|
}: {
|
|
776
|
+
cell: MRT_Cell<TData>;
|
|
738
777
|
row: MRT_Row<TData>;
|
|
739
778
|
table: MRT_TableInstance<TData>;
|
|
740
779
|
}) => ReactNode;
|
|
@@ -752,7 +791,6 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
752
791
|
rowNumberMode?: 'original' | 'static';
|
|
753
792
|
selectAllMode?: 'all' | 'page';
|
|
754
793
|
state?: Partial<MRT_TableState<TData>>;
|
|
755
|
-
tableId?: string;
|
|
756
794
|
virtualizerProps?:
|
|
757
795
|
| Partial<VirtualizerOptions<HTMLDivElement>>
|
|
758
796
|
| (({
|
|
@@ -774,7 +812,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
774
812
|
autoResetExpanded = false,
|
|
775
813
|
columnResizeMode = 'onEnd',
|
|
776
814
|
defaultColumn = { minSize: 40, maxSize: 1000, size: 180 },
|
|
777
|
-
editingMode = '
|
|
815
|
+
editingMode = 'modal',
|
|
778
816
|
enableBottomToolbar = true,
|
|
779
817
|
enableColumnActions = true,
|
|
780
818
|
enableColumnFilterChangeMode = false,
|
|
@@ -29,25 +29,27 @@ export const MRT_EditRowModal = <TData extends Record<string, any> = {}>({
|
|
|
29
29
|
<Dialog open={open}>
|
|
30
30
|
<DialogTitle textAlign="center">{localization.edit}</DialogTitle>
|
|
31
31
|
<DialogContent>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
<form onSubmit={(e) => e.preventDefault()}>
|
|
33
|
+
<Stack
|
|
34
|
+
sx={{
|
|
35
|
+
width: '100%',
|
|
36
|
+
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
37
|
+
gap: '1.5rem',
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
{row
|
|
41
|
+
.getAllCells()
|
|
42
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
43
|
+
.map((cell) => (
|
|
44
|
+
<MRT_EditCellTextField
|
|
45
|
+
cell={cell as any}
|
|
46
|
+
key={cell.id}
|
|
47
|
+
showLabel
|
|
48
|
+
table={table as any}
|
|
49
|
+
/>
|
|
50
|
+
))}
|
|
51
|
+
</Stack>
|
|
52
|
+
</form>
|
|
51
53
|
</DialogContent>
|
|
52
54
|
<DialogActions sx={{ p: '1.25rem' }}>
|
|
53
55
|
<MRT_EditActionButtons row={row} table={table} variant="text" />
|
|
@@ -18,6 +18,7 @@ import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
|
18
18
|
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
|
19
19
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
|
20
20
|
import { MRT_TableBodyRowGrabHandle } from './MRT_TableBodyRowGrabHandle';
|
|
21
|
+
import { MRT_TableBodyCellValue } from './MRT_TableBodyCellValue';
|
|
21
22
|
|
|
22
23
|
interface Props {
|
|
23
24
|
cell: MRT_Cell;
|
|
@@ -48,8 +49,8 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
48
49
|
muiTableBodyCellProps,
|
|
49
50
|
muiTableBodyCellSkeletonProps,
|
|
50
51
|
rowNumberMode,
|
|
51
|
-
tableId,
|
|
52
52
|
},
|
|
53
|
+
refs: { editInputRefs },
|
|
53
54
|
setEditingCell,
|
|
54
55
|
setHoveredColumn,
|
|
55
56
|
} = table;
|
|
@@ -68,7 +69,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
68
69
|
|
|
69
70
|
const mTableCellBodyProps =
|
|
70
71
|
muiTableBodyCellProps instanceof Function
|
|
71
|
-
? muiTableBodyCellProps({ cell, table })
|
|
72
|
+
? muiTableBodyCellProps({ cell, column, row, table })
|
|
72
73
|
: muiTableBodyCellProps;
|
|
73
74
|
|
|
74
75
|
const mcTableCellBodyProps =
|
|
@@ -115,15 +116,13 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
115
116
|
editingMode === 'cell'
|
|
116
117
|
) {
|
|
117
118
|
setEditingCell(cell);
|
|
118
|
-
|
|
119
|
-
const textField =
|
|
120
|
-
`mrt-${tableId}-edit-cell-text-field-${cell.id}`,
|
|
121
|
-
) as HTMLInputElement;
|
|
119
|
+
queueMicrotask(() => {
|
|
120
|
+
const textField = editInputRefs.current[column.id];
|
|
122
121
|
if (textField) {
|
|
123
122
|
textField.focus();
|
|
124
123
|
textField.select();
|
|
125
124
|
}
|
|
126
|
-
}
|
|
125
|
+
});
|
|
127
126
|
}
|
|
128
127
|
};
|
|
129
128
|
|
|
@@ -279,32 +278,19 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
279
278
|
(column.id === 'mrt-row-select' ||
|
|
280
279
|
column.id === 'mrt-row-expand' ||
|
|
281
280
|
!row.getIsGrouped()) ? (
|
|
282
|
-
columnDef.Cell?.({ cell, column, table })
|
|
281
|
+
columnDef.Cell?.({ cell, column, row, table })
|
|
283
282
|
) : isEditing ? (
|
|
284
283
|
<MRT_EditCellTextField cell={cell} table={table} />
|
|
285
284
|
) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
286
285
|
columnDef.enableClickToCopy !== false ? (
|
|
287
|
-
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
{row.getIsGrouped() && !cell.getIsGrouped()
|
|
291
|
-
? null
|
|
292
|
-
: columnDef?.Cell?.({ cell, column, table }) ??
|
|
293
|
-
cell.renderValue()}
|
|
294
|
-
</>
|
|
295
|
-
</MRT_CopyButton>
|
|
296
|
-
{cell.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
297
|
-
</>
|
|
286
|
+
<MRT_CopyButton cell={cell} table={table}>
|
|
287
|
+
<MRT_TableBodyCellValue cell={cell} table={table} />
|
|
288
|
+
</MRT_CopyButton>
|
|
298
289
|
) : (
|
|
299
|
-
|
|
300
|
-
{row.getIsGrouped() && !cell.getIsGrouped()
|
|
301
|
-
? null
|
|
302
|
-
: columnDef?.Cell?.({ cell, column, table }) ??
|
|
303
|
-
cell.renderValue()}
|
|
304
|
-
{cell.getIsGrouped() && <> ({row.subRows?.length ?? ''})</>}
|
|
305
|
-
</>
|
|
290
|
+
<MRT_TableBodyCellValue cell={cell} table={table} />
|
|
306
291
|
)}
|
|
307
292
|
</>
|
|
293
|
+
{cell.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
308
294
|
</TableCell>
|
|
309
295
|
);
|
|
310
296
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
cell: MRT_Cell;
|
|
6
|
+
table: MRT_TableInstance;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
|
|
10
|
+
const { column, row } = cell;
|
|
11
|
+
const { columnDef } = column;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{cell.getIsAggregated() && column.columnDef.aggregationFn
|
|
16
|
+
? columnDef.AggregatedCell?.({
|
|
17
|
+
cell,
|
|
18
|
+
column,
|
|
19
|
+
row,
|
|
20
|
+
table,
|
|
21
|
+
})
|
|
22
|
+
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
23
|
+
? null
|
|
24
|
+
: columnDef?.Cell?.({ cell, column, row, table }) ?? cell.renderValue()}
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -76,8 +76,8 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, table }) => {
|
|
|
76
76
|
{row?.getVisibleCells()?.map?.((cell) => (
|
|
77
77
|
<MRT_TableBodyCell
|
|
78
78
|
cell={cell}
|
|
79
|
-
key={cell.id}
|
|
80
79
|
enableHover={tableRowProps?.hover !== false}
|
|
80
|
+
key={cell.id}
|
|
81
81
|
rowIndex={rowIndex}
|
|
82
82
|
rowRef={rowRef}
|
|
83
83
|
table={table}
|
|
@@ -16,15 +16,16 @@ export const MRT_TableBodyRowGrabHandle: FC<Props> = ({
|
|
|
16
16
|
const {
|
|
17
17
|
options: { muiTableBodyRowDragHandleProps, onRowDrop },
|
|
18
18
|
} = table;
|
|
19
|
+
const { row } = cell;
|
|
19
20
|
|
|
20
21
|
const iconButtonProps =
|
|
21
22
|
muiTableBodyRowDragHandleProps instanceof Function
|
|
22
|
-
? muiTableBodyRowDragHandleProps({ row
|
|
23
|
+
? muiTableBodyRowDragHandleProps({ row, table })
|
|
23
24
|
: muiTableBodyRowDragHandleProps;
|
|
24
25
|
|
|
25
26
|
const handleDragStart = (e: DragEvent<HTMLButtonElement>) => {
|
|
26
27
|
e.dataTransfer.setDragImage(rowRef.current as HTMLElement, 0, 0);
|
|
27
|
-
table.setDraggingRow(
|
|
28
|
+
table.setDraggingRow(row as any);
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
const handleDragEnd = (event: DragEvent<HTMLButtonElement>) => {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, useState } from 'react';
|
|
2
2
|
import { Button, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props {
|
|
6
|
-
cell: MRT_Cell
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
6
|
+
cell: MRT_Cell<TData>;
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
table: MRT_TableInstance
|
|
8
|
+
table: MRT_TableInstance<TData>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const MRT_CopyButton
|
|
11
|
+
export const MRT_CopyButton = <TData extends Record<string, any> = {}>({
|
|
12
|
+
cell,
|
|
13
|
+
children,
|
|
14
|
+
table,
|
|
15
|
+
}: Props<TData>) => {
|
|
12
16
|
const {
|
|
13
17
|
options: { localization, muiTableBodyCellCopyButtonProps },
|
|
14
18
|
} = table;
|
|
15
|
-
const { column } = cell;
|
|
19
|
+
const { column, row } = cell;
|
|
16
20
|
const { columnDef } = column;
|
|
17
21
|
|
|
18
22
|
const [copied, setCopied] = useState(false);
|
|
@@ -25,7 +29,7 @@ export const MRT_CopyButton: FC<Props> = ({ cell, children, table }) => {
|
|
|
25
29
|
|
|
26
30
|
const mTableBodyCellCopyButtonProps =
|
|
27
31
|
muiTableBodyCellCopyButtonProps instanceof Function
|
|
28
|
-
? muiTableBodyCellCopyButtonProps({ cell, table })
|
|
32
|
+
? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
|
|
29
33
|
: muiTableBodyCellCopyButtonProps;
|
|
30
34
|
|
|
31
35
|
const mcTableBodyCellCopyButtonProps =
|
|
@@ -20,21 +20,30 @@ export const MRT_EditActionButtons = <TData extends Record<string, any> = {}>({
|
|
|
20
20
|
localization,
|
|
21
21
|
onEditingRowSave,
|
|
22
22
|
},
|
|
23
|
+
refs: { editInputRefs },
|
|
23
24
|
setEditingRow,
|
|
24
25
|
} = table;
|
|
25
26
|
const { editingRow } = getState();
|
|
26
27
|
|
|
27
|
-
const handleCancel = () =>
|
|
28
|
-
setEditingRow(null);
|
|
29
|
-
};
|
|
28
|
+
const handleCancel = () => setEditingRow(null);
|
|
30
29
|
|
|
31
30
|
const handleSave = () => {
|
|
31
|
+
//look for auto-filled input values
|
|
32
|
+
Object.values(editInputRefs?.current)?.forEach((input) => {
|
|
33
|
+
if (
|
|
34
|
+
input.value !== undefined &&
|
|
35
|
+
Object.hasOwn(editingRow?._valuesCache as object, input.name)
|
|
36
|
+
) {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
editingRow._valuesCache[input.name] = input.value;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
32
41
|
onEditingRowSave?.({
|
|
42
|
+
exitEditingMode: () => setEditingRow(null),
|
|
33
43
|
row: editingRow ?? row,
|
|
34
44
|
table,
|
|
35
45
|
values: editingRow?._valuesCache ?? { ...row.original },
|
|
36
46
|
});
|
|
37
|
-
setEditingRow(null);
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
return (
|
|
@@ -17,30 +17,17 @@ export const MRT_ToggleGlobalFilterButton = <
|
|
|
17
17
|
getState,
|
|
18
18
|
options: {
|
|
19
19
|
icons: { SearchIcon, SearchOffIcon },
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
localization,
|
|
22
|
-
muiSearchTextFieldProps,
|
|
23
22
|
},
|
|
23
|
+
refs: { searchInputRef },
|
|
24
24
|
setShowGlobalFilter,
|
|
25
25
|
} = table;
|
|
26
26
|
const { showGlobalFilter } = getState();
|
|
27
27
|
|
|
28
|
-
const textFieldProps =
|
|
29
|
-
muiSearchTextFieldProps instanceof Function
|
|
30
|
-
? muiSearchTextFieldProps({ table })
|
|
31
|
-
: muiSearchTextFieldProps;
|
|
32
|
-
|
|
33
28
|
const handleToggleSearch = () => {
|
|
34
29
|
setShowGlobalFilter(!showGlobalFilter);
|
|
35
|
-
|
|
36
|
-
() =>
|
|
37
|
-
document
|
|
38
|
-
.getElementById(
|
|
39
|
-
textFieldProps?.id ?? `mrt-${tableId}-search-text-field`,
|
|
40
|
-
)
|
|
41
|
-
?.focus(),
|
|
42
|
-
200,
|
|
43
|
-
);
|
|
30
|
+
queueMicrotask(() => searchInputRef.current?.focus());
|
|
44
31
|
};
|
|
45
32
|
|
|
46
33
|
return (
|