material-react-table 0.37.2 → 0.38.0
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/cjs/MaterialReactTable.d.ts +16 -7
- package/dist/cjs/index.js +27 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +16 -7
- package/dist/esm/material-react-table.esm.js +27 -17
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +16 -7
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +21 -6
- package/src/body/MRT_TableBodyCell.tsx +3 -1
- package/src/body/MRT_TableBodyCellValue.tsx +9 -1
- package/src/toolbar/MRT_BottomToolbar.tsx +4 -4
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +14 -5
- package/src/toolbar/MRT_TopToolbar.tsx +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MutableRefObject, Dispatch, SetStateAction, ReactNode, DragEvent } from 'react';
|
|
2
|
-
import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps,
|
|
2
|
+
import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, ToolbarProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, PaperProps, TableProps, ChipProps, 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';
|
|
5
5
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
@@ -304,6 +304,12 @@ declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<Column
|
|
|
304
304
|
footer: MRT_Header<TData>;
|
|
305
305
|
table: MRT_TableInstance<TData>;
|
|
306
306
|
}) => ReactNode);
|
|
307
|
+
GroupedCell?: ({ cell, column, row, table, }: {
|
|
308
|
+
cell: MRT_Cell<TData>;
|
|
309
|
+
column: MRT_Column<TData>;
|
|
310
|
+
row: MRT_Row<TData>;
|
|
311
|
+
table: MRT_TableInstance<TData>;
|
|
312
|
+
}) => ReactNode;
|
|
307
313
|
Header?: ReactNode | (({ column, header, table, }: {
|
|
308
314
|
column: MRT_Column<TData>;
|
|
309
315
|
header: MRT_Header<TData>;
|
|
@@ -483,6 +489,9 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
483
489
|
icons?: Partial<MRT_Icons>;
|
|
484
490
|
initialState?: Partial<MRT_TableState<TData>>;
|
|
485
491
|
localization?: Partial<MRT_Localization>;
|
|
492
|
+
muiBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
493
|
+
table: MRT_TableInstance<TData>;
|
|
494
|
+
}) => ToolbarProps);
|
|
486
495
|
muiExpandAllButtonProps?: IconButtonProps | (({ table }: {
|
|
487
496
|
table: MRT_TableInstance<TData>;
|
|
488
497
|
}) => IconButtonProps);
|
|
@@ -537,9 +546,6 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
537
546
|
table: MRT_TableInstance<TData>;
|
|
538
547
|
row: MRT_Row<TData>;
|
|
539
548
|
}) => TableRowProps);
|
|
540
|
-
muiTableBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
541
|
-
table: MRT_TableInstance<TData>;
|
|
542
|
-
}) => ToolbarProps);
|
|
543
549
|
muiTableContainerProps?: TableContainerProps | (({ table, }: {
|
|
544
550
|
table: MRT_TableInstance<TData>;
|
|
545
551
|
}) => TableContainerProps);
|
|
@@ -591,10 +597,13 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
591
597
|
muiTableProps?: TableProps | (({ table }: {
|
|
592
598
|
table: MRT_TableInstance<TData>;
|
|
593
599
|
}) => TableProps);
|
|
594
|
-
|
|
600
|
+
muiToolbarAlertBannerChipProps?: ChipProps | (({ table }: {
|
|
601
|
+
table: MRT_TableInstance<TData>;
|
|
602
|
+
}) => ChipProps);
|
|
603
|
+
muiToolbarAlertBannerProps?: AlertProps | (({ table }: {
|
|
595
604
|
table: MRT_TableInstance<TData>;
|
|
596
605
|
}) => AlertProps);
|
|
597
|
-
|
|
606
|
+
muiTopToolbarProps?: ToolbarProps | (({ table }: {
|
|
598
607
|
table: MRT_TableInstance<TData>;
|
|
599
608
|
}) => ToolbarProps);
|
|
600
609
|
onColumnDrop?: ({ event, draggedColumn, targetColumn, }: {
|
|
@@ -607,13 +616,13 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
607
616
|
onDensityChange?: OnChangeFn<boolean>;
|
|
608
617
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
609
618
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
619
|
+
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
610
620
|
onEditingRowSave?: ({ exitEditingMode, row, table, values, }: {
|
|
611
621
|
exitEditingMode: () => void;
|
|
612
622
|
row: MRT_Row<TData>;
|
|
613
623
|
table: MRT_TableInstance<TData>;
|
|
614
624
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
615
625
|
}) => Promise<void> | void;
|
|
616
|
-
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
617
626
|
onEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
618
627
|
onFilterFnsChange?: OnChangeFn<{
|
|
619
628
|
[key: string]: MRT_FilterOption;
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
AlertProps,
|
|
10
10
|
ButtonProps,
|
|
11
11
|
CheckboxProps,
|
|
12
|
+
ChipProps,
|
|
12
13
|
IconButtonProps,
|
|
13
14
|
LinearProgressProps,
|
|
14
15
|
PaperProps,
|
|
@@ -207,6 +208,17 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
207
208
|
footer: MRT_Header<TData>;
|
|
208
209
|
table: MRT_TableInstance<TData>;
|
|
209
210
|
}) => ReactNode);
|
|
211
|
+
GroupedCell?: ({
|
|
212
|
+
cell,
|
|
213
|
+
column,
|
|
214
|
+
row,
|
|
215
|
+
table,
|
|
216
|
+
}: {
|
|
217
|
+
cell: MRT_Cell<TData>;
|
|
218
|
+
column: MRT_Column<TData>;
|
|
219
|
+
row: MRT_Row<TData>;
|
|
220
|
+
table: MRT_TableInstance<TData>;
|
|
221
|
+
}) => ReactNode;
|
|
210
222
|
Header?:
|
|
211
223
|
| ReactNode
|
|
212
224
|
| (({
|
|
@@ -486,6 +498,9 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
486
498
|
icons?: Partial<MRT_Icons>;
|
|
487
499
|
initialState?: Partial<MRT_TableState<TData>>;
|
|
488
500
|
localization?: Partial<MRT_Localization>;
|
|
501
|
+
muiBottomToolbarProps?:
|
|
502
|
+
| ToolbarProps
|
|
503
|
+
| (({ table }: { table: MRT_TableInstance<TData> }) => ToolbarProps);
|
|
489
504
|
muiExpandAllButtonProps?:
|
|
490
505
|
| IconButtonProps
|
|
491
506
|
| (({ table }: { table: MRT_TableInstance<TData> }) => IconButtonProps);
|
|
@@ -590,9 +605,6 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
590
605
|
table: MRT_TableInstance<TData>;
|
|
591
606
|
row: MRT_Row<TData>;
|
|
592
607
|
}) => TableRowProps);
|
|
593
|
-
muiTableBottomToolbarProps?:
|
|
594
|
-
| ToolbarProps
|
|
595
|
-
| (({ table }: { table: MRT_TableInstance<TData> }) => ToolbarProps);
|
|
596
608
|
muiTableContainerProps?:
|
|
597
609
|
| TableContainerProps
|
|
598
610
|
| (({
|
|
@@ -693,10 +705,13 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
693
705
|
muiTableProps?:
|
|
694
706
|
| TableProps
|
|
695
707
|
| (({ table }: { table: MRT_TableInstance<TData> }) => TableProps);
|
|
696
|
-
|
|
708
|
+
muiToolbarAlertBannerChipProps?:
|
|
709
|
+
| ChipProps
|
|
710
|
+
| (({ table }: { table: MRT_TableInstance<TData> }) => ChipProps);
|
|
711
|
+
muiToolbarAlertBannerProps?:
|
|
697
712
|
| AlertProps
|
|
698
713
|
| (({ table }: { table: MRT_TableInstance<TData> }) => AlertProps);
|
|
699
|
-
|
|
714
|
+
muiTopToolbarProps?:
|
|
700
715
|
| ToolbarProps
|
|
701
716
|
| (({ table }: { table: MRT_TableInstance<TData> }) => ToolbarProps);
|
|
702
717
|
onColumnDrop?: ({
|
|
@@ -711,6 +726,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
711
726
|
onDensityChange?: OnChangeFn<boolean>;
|
|
712
727
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
713
728
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
729
|
+
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
714
730
|
onEditingRowSave?: ({
|
|
715
731
|
exitEditingMode,
|
|
716
732
|
row,
|
|
@@ -722,7 +738,6 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
722
738
|
table: MRT_TableInstance<TData>;
|
|
723
739
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
724
740
|
}) => Promise<void> | void;
|
|
725
|
-
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
726
741
|
onEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
727
742
|
onFilterFnsChange?: OnChangeFn<{ [key: string]: MRT_FilterOption }>;
|
|
728
743
|
onGlobalFilterFnChange?: OnChangeFn<MRT_FilterOption>;
|
|
@@ -290,7 +290,9 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
290
290
|
<MRT_TableBodyCellValue cell={cell} table={table} />
|
|
291
291
|
)}
|
|
292
292
|
</>
|
|
293
|
-
{cell.getIsGrouped() &&
|
|
293
|
+
{cell.getIsGrouped() && !columnDef.GroupedCell && (
|
|
294
|
+
<> ({row.subRows?.length})</>
|
|
295
|
+
)}
|
|
294
296
|
</TableCell>
|
|
295
297
|
);
|
|
296
298
|
};
|
|
@@ -21,7 +21,15 @@ export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
|
|
|
21
21
|
})
|
|
22
22
|
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
23
23
|
? null
|
|
24
|
-
:
|
|
24
|
+
: (cell.getIsGrouped() &&
|
|
25
|
+
columnDef.GroupedCell?.({
|
|
26
|
+
cell,
|
|
27
|
+
column,
|
|
28
|
+
row,
|
|
29
|
+
table,
|
|
30
|
+
})) ||
|
|
31
|
+
(columnDef?.Cell?.({ cell, column, row, table }) ??
|
|
32
|
+
cell.renderValue())}
|
|
25
33
|
</>
|
|
26
34
|
);
|
|
27
35
|
};
|
|
@@ -16,7 +16,7 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
|
|
|
16
16
|
getState,
|
|
17
17
|
options: {
|
|
18
18
|
enablePagination,
|
|
19
|
-
|
|
19
|
+
muiBottomToolbarProps,
|
|
20
20
|
positionPagination,
|
|
21
21
|
positionToolbarAlertBanner,
|
|
22
22
|
positionToolbarDropZone,
|
|
@@ -29,9 +29,9 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
|
|
|
29
29
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
30
30
|
|
|
31
31
|
const toolbarProps =
|
|
32
|
-
|
|
33
|
-
?
|
|
34
|
-
:
|
|
32
|
+
muiBottomToolbarProps instanceof Function
|
|
33
|
+
? muiBottomToolbarProps({ table })
|
|
34
|
+
: muiBottomToolbarProps;
|
|
35
35
|
|
|
36
36
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
37
37
|
|
|
@@ -15,14 +15,23 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({
|
|
|
15
15
|
getPrePaginationRowModel,
|
|
16
16
|
getSelectedRowModel,
|
|
17
17
|
getState,
|
|
18
|
-
options: {
|
|
18
|
+
options: {
|
|
19
|
+
localization,
|
|
20
|
+
muiToolbarAlertBannerProps,
|
|
21
|
+
muiToolbarAlertBannerChipProps,
|
|
22
|
+
},
|
|
19
23
|
} = table;
|
|
20
24
|
const { grouping, showAlertBanner } = getState();
|
|
21
25
|
|
|
22
26
|
const alertProps =
|
|
23
|
-
|
|
24
|
-
?
|
|
25
|
-
:
|
|
27
|
+
muiToolbarAlertBannerProps instanceof Function
|
|
28
|
+
? muiToolbarAlertBannerProps({ table })
|
|
29
|
+
: muiToolbarAlertBannerProps;
|
|
30
|
+
|
|
31
|
+
const chipProps =
|
|
32
|
+
muiToolbarAlertBannerChipProps instanceof Function
|
|
33
|
+
? muiToolbarAlertBannerChipProps({ table })
|
|
34
|
+
: muiToolbarAlertBannerChipProps;
|
|
26
35
|
|
|
27
36
|
const selectMessage =
|
|
28
37
|
getSelectedRowModel().rows.length > 0
|
|
@@ -45,9 +54,9 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({
|
|
|
45
54
|
<Fragment key={`${index}-${columnId}`}>
|
|
46
55
|
{index > 0 ? localization.thenBy : ''}
|
|
47
56
|
<Chip
|
|
48
|
-
color="secondary"
|
|
49
57
|
label={table.getColumn(columnId).columnDef.header}
|
|
50
58
|
onDelete={() => table.getColumn(columnId).toggleGrouping()}
|
|
59
|
+
{...chipProps}
|
|
51
60
|
/>
|
|
52
61
|
</Fragment>
|
|
53
62
|
))}
|
|
@@ -31,7 +31,7 @@ export const MRT_TopToolbar: FC<Props> = ({ table }) => {
|
|
|
31
31
|
enableGlobalFilter,
|
|
32
32
|
enablePagination,
|
|
33
33
|
enableToolbarInternalActions,
|
|
34
|
-
|
|
34
|
+
muiTopToolbarProps,
|
|
35
35
|
positionGlobalFilter,
|
|
36
36
|
positionPagination,
|
|
37
37
|
positionToolbarAlertBanner,
|
|
@@ -46,9 +46,9 @@ export const MRT_TopToolbar: FC<Props> = ({ table }) => {
|
|
|
46
46
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
47
47
|
|
|
48
48
|
const toolbarProps =
|
|
49
|
-
|
|
50
|
-
?
|
|
51
|
-
:
|
|
49
|
+
muiTopToolbarProps instanceof Function
|
|
50
|
+
? muiTopToolbarProps({ table })
|
|
51
|
+
: muiTopToolbarProps;
|
|
52
52
|
|
|
53
53
|
const stackAlertBanner =
|
|
54
54
|
isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|