material-react-table 2.0.0-beta.5 → 2.0.0-beta.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.js +533 -538
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/material-react-table.esm.js +534 -539
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +18 -17
- package/locales/ar/index.d.ts +1 -1
- package/locales/ar/index.esm.d.ts +1 -1
- package/locales/ar/package.json +9 -1
- package/locales/az/index.d.ts +1 -1
- package/locales/az/index.esm.d.ts +1 -1
- package/locales/az/package.json +9 -1
- package/locales/bg/index.d.ts +1 -1
- package/locales/bg/index.esm.d.ts +1 -1
- package/locales/bg/package.json +9 -1
- package/locales/cs/index.d.ts +1 -1
- package/locales/cs/index.esm.d.ts +1 -1
- package/locales/cs/package.json +9 -1
- package/locales/da/index.d.ts +1 -1
- package/locales/da/index.esm.d.ts +1 -1
- package/locales/da/package.json +9 -1
- package/locales/de/index.d.ts +1 -1
- package/locales/de/index.esm.d.ts +1 -1
- package/locales/de/package.json +9 -1
- package/locales/en/index.d.ts +1 -1
- package/locales/en/index.esm.d.ts +1 -1
- package/locales/en/package.json +9 -1
- package/locales/es/index.d.ts +1 -1
- package/locales/es/index.esm.d.ts +1 -1
- package/locales/es/package.json +9 -1
- package/locales/et/index.d.ts +1 -1
- package/locales/et/index.esm.d.ts +1 -1
- package/locales/et/package.json +9 -1
- package/locales/fa/index.d.ts +1 -1
- package/locales/fa/index.esm.d.ts +1 -1
- package/locales/fa/package.json +9 -1
- package/locales/fi/index.d.ts +1 -1
- package/locales/fi/index.esm.d.ts +1 -1
- package/locales/fi/package.json +9 -1
- package/locales/fr/index.d.ts +1 -1
- package/locales/fr/index.esm.d.ts +1 -1
- package/locales/fr/package.json +9 -1
- package/locales/hu/index.d.ts +1 -1
- package/locales/hu/index.esm.d.ts +1 -1
- package/locales/hu/package.json +9 -1
- package/locales/hy/index.d.ts +1 -1
- package/locales/hy/index.esm.d.ts +1 -1
- package/locales/hy/package.json +9 -1
- package/locales/id/index.d.ts +1 -1
- package/locales/id/index.esm.d.ts +1 -1
- package/locales/id/package.json +9 -1
- package/locales/it/index.d.ts +1 -1
- package/locales/it/index.esm.d.ts +1 -1
- package/locales/it/package.json +9 -1
- package/locales/ja/index.d.ts +1 -1
- package/locales/ja/index.esm.d.ts +1 -1
- package/locales/ja/package.json +9 -1
- package/locales/ko/index.d.ts +1 -1
- package/locales/ko/index.esm.d.ts +1 -1
- package/locales/ko/package.json +9 -1
- package/locales/nl/index.d.ts +1 -1
- package/locales/nl/index.esm.d.ts +1 -1
- package/locales/nl/package.json +9 -1
- package/locales/no/index.d.ts +1 -1
- package/locales/no/index.esm.d.ts +1 -1
- package/locales/no/package.json +9 -1
- package/locales/np/index.d.ts +1 -1
- package/locales/np/index.esm.d.ts +1 -1
- package/locales/np/package.json +9 -1
- package/locales/pl/index.d.ts +1 -1
- package/locales/pl/index.esm.d.ts +1 -1
- package/locales/pl/package.json +9 -1
- package/locales/pt/index.d.ts +1 -1
- package/locales/pt/index.esm.d.ts +1 -1
- package/locales/pt/package.json +9 -1
- package/locales/pt-BR/index.d.ts +1 -1
- package/locales/pt-BR/index.esm.d.ts +1 -1
- package/locales/pt-BR/package.json +9 -1
- package/locales/ro/index.d.ts +1 -1
- package/locales/ro/index.esm.d.ts +1 -1
- package/locales/ro/package.json +9 -1
- package/locales/ru/index.d.ts +1 -1
- package/locales/ru/index.esm.d.ts +1 -1
- package/locales/ru/package.json +9 -1
- package/locales/sk/index.d.ts +1 -1
- package/locales/sk/index.esm.d.ts +1 -1
- package/locales/sk/package.json +9 -1
- package/locales/sr-Cyrl-RS/index.d.ts +1 -1
- package/locales/sr-Cyrl-RS/index.esm.d.ts +1 -1
- package/locales/sr-Cyrl-RS/package.json +9 -1
- package/locales/sr-Latn-RS/index.d.ts +1 -1
- package/locales/sr-Latn-RS/index.esm.d.ts +1 -1
- package/locales/sr-Latn-RS/package.json +9 -1
- package/locales/sv/index.d.ts +1 -1
- package/locales/sv/index.esm.d.ts +1 -1
- package/locales/sv/package.json +9 -1
- package/locales/tr/index.d.ts +1 -1
- package/locales/tr/index.esm.d.ts +1 -1
- package/locales/tr/package.json +9 -1
- package/locales/uk/index.d.ts +1 -1
- package/locales/uk/index.esm.d.ts +1 -1
- package/locales/uk/package.json +9 -1
- package/locales/vi/index.d.ts +1 -1
- package/locales/vi/index.esm.d.ts +1 -1
- package/locales/vi/package.json +9 -1
- package/locales/zh-Hans/index.d.ts +1 -1
- package/locales/zh-Hans/index.esm.d.ts +1 -1
- package/locales/zh-Hans/package.json +9 -1
- package/locales/zh-Hant/index.d.ts +1 -1
- package/locales/zh-Hant/index.esm.d.ts +1 -1
- package/locales/zh-Hant/package.json +9 -1
- package/package.json +1 -1
- package/src/body/MRT_TableBodyCell.tsx +2 -2
- package/src/body/MRT_TableBodyRow.tsx +3 -1
- package/src/column.utils.ts +4 -4
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
- package/src/hooks/useMRT_DisplayColumns.tsx +9 -7
- package/src/hooks/useMRT_TableOptions.ts +2 -2
- package/src/inputs/MRT_EditCellTextField.tsx +0 -4
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -0
- package/src/modals/MRT_EditRowModal.tsx +6 -6
- package/src/style.utils.ts +1 -1
- package/src/table/MRT_TablePaper.tsx +2 -0
- package/src/types.ts +17 -13
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
type MRT_Row,
|
15
15
|
type MRT_RowData,
|
16
16
|
} from '../types';
|
17
|
+
import { MRT_DefaultDisplayColumn } from './useMRT_TableOptions';
|
17
18
|
|
18
19
|
const blankColProps = {
|
19
20
|
children: null,
|
@@ -50,8 +51,8 @@ export const useMRT_DisplayColumns = <TData extends MRT_RowData>({
|
|
50
51
|
),
|
51
52
|
header: tableOptions.localization.pin,
|
52
53
|
size: 60,
|
53
|
-
...tableOptions.defaultDisplayColumn,
|
54
54
|
...tableOptions.displayColumnDefOptions?.['mrt-row-pin'],
|
55
|
+
columnDefType: 'display',
|
55
56
|
id: 'mrt-row-pin',
|
56
57
|
},
|
57
58
|
(tableOptions.state?.columnOrder ?? columnOrder).includes(
|
@@ -66,8 +67,8 @@ export const useMRT_DisplayColumns = <TData extends MRT_RowData>({
|
|
66
67
|
),
|
67
68
|
header: tableOptions.localization.move,
|
68
69
|
size: 60,
|
69
|
-
...tableOptions.defaultDisplayColumn,
|
70
70
|
...tableOptions.displayColumnDefOptions?.['mrt-row-drag'],
|
71
|
+
columnDefType: 'display',
|
71
72
|
id: 'mrt-row-drag',
|
72
73
|
},
|
73
74
|
((tableOptions.state?.columnOrder ?? columnOrder).includes(
|
@@ -83,8 +84,8 @@ export const useMRT_DisplayColumns = <TData extends MRT_RowData>({
|
|
83
84
|
),
|
84
85
|
header: tableOptions.localization.actions,
|
85
86
|
size: 70,
|
86
|
-
...tableOptions.defaultDisplayColumn,
|
87
87
|
...tableOptions.displayColumnDefOptions?.['mrt-row-actions'],
|
88
|
+
columnDefType: 'display',
|
88
89
|
id: 'mrt-row-actions',
|
89
90
|
},
|
90
91
|
(tableOptions.state?.columnOrder ?? columnOrder).includes(
|
@@ -102,8 +103,8 @@ export const useMRT_DisplayColumns = <TData extends MRT_RowData>({
|
|
102
103
|
: null,
|
103
104
|
header: tableOptions.localization.expand,
|
104
105
|
size: 60,
|
105
|
-
...tableOptions.defaultDisplayColumn,
|
106
106
|
...tableOptions.displayColumnDefOptions?.['mrt-row-expand'],
|
107
|
+
columnDefType: 'display',
|
107
108
|
id: 'mrt-row-expand',
|
108
109
|
},
|
109
110
|
(tableOptions.state?.columnOrder ?? columnOrder).includes(
|
@@ -119,8 +120,8 @@ export const useMRT_DisplayColumns = <TData extends MRT_RowData>({
|
|
119
120
|
: null,
|
120
121
|
header: tableOptions.localization.select,
|
121
122
|
size: 60,
|
122
|
-
...tableOptions.defaultDisplayColumn,
|
123
123
|
...tableOptions.displayColumnDefOptions?.['mrt-row-select'],
|
124
|
+
columnDefType: 'display',
|
124
125
|
id: 'mrt-row-select',
|
125
126
|
},
|
126
127
|
(tableOptions.state?.columnOrder ?? columnOrder).includes(
|
@@ -130,14 +131,15 @@ export const useMRT_DisplayColumns = <TData extends MRT_RowData>({
|
|
130
131
|
Header: () => tableOptions.localization.rowNumber,
|
131
132
|
header: tableOptions.localization.rowNumbers,
|
132
133
|
size: 60,
|
133
|
-
...tableOptions.defaultDisplayColumn,
|
134
134
|
...tableOptions.displayColumnDefOptions?.['mrt-row-numbers'],
|
135
|
+
columnDefType: 'display',
|
135
136
|
id: 'mrt-row-numbers',
|
136
137
|
},
|
137
|
-
|
138
138
|
(tableOptions.state?.columnOrder ?? columnOrder).includes(
|
139
139
|
'mrt-row-spacer',
|
140
140
|
) && {
|
141
|
+
...tableOptions.displayColumnDefOptions?.['mrt-row-spacer'],
|
142
|
+
...MRT_DefaultDisplayColumn,
|
141
143
|
columnDefType: 'display',
|
142
144
|
header: '',
|
143
145
|
id: 'mrt-row-spacer',
|
@@ -10,14 +10,14 @@ import {
|
|
10
10
|
type MRT_TableOptions,
|
11
11
|
} from '../types';
|
12
12
|
|
13
|
-
const MRT_DefaultColumn = {
|
13
|
+
export const MRT_DefaultColumn = {
|
14
14
|
filterVariant: 'text',
|
15
15
|
maxSize: 1000,
|
16
16
|
minSize: 40,
|
17
17
|
size: 180,
|
18
18
|
} as const;
|
19
19
|
|
20
|
-
const MRT_DefaultDisplayColumn = {
|
20
|
+
export const MRT_DefaultDisplayColumn = {
|
21
21
|
columnDefType: 'display',
|
22
22
|
enableClickToCopy: false,
|
23
23
|
enableColumnActions: false,
|
@@ -139,10 +139,6 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
139
139
|
}}
|
140
140
|
inputProps={{
|
141
141
|
autoComplete: 'new-password', // disable autocomplete and autofill
|
142
|
-
sx: {
|
143
|
-
p: 0,
|
144
|
-
...textFieldProps?.inputProps?.sx,
|
145
|
-
},
|
146
142
|
...textFieldProps.inputProps,
|
147
143
|
}}
|
148
144
|
onBlur={handleBlur}
|
@@ -27,11 +27,11 @@ export const MRT_EditRowModal = <TData extends MRT_RowData>({
|
|
27
27
|
options: {
|
28
28
|
localization,
|
29
29
|
muiCreateRowModalProps,
|
30
|
-
|
30
|
+
muiEditRowDialogProps,
|
31
31
|
onCreatingRowCancel,
|
32
32
|
onEditingRowCancel,
|
33
|
-
|
34
|
-
|
33
|
+
renderCreateRowDialogContent,
|
34
|
+
renderEditRowDialogContent,
|
35
35
|
},
|
36
36
|
setCreatingRow,
|
37
37
|
setEditingRow,
|
@@ -40,7 +40,7 @@ export const MRT_EditRowModal = <TData extends MRT_RowData>({
|
|
40
40
|
const row = (creatingRow ?? editingRow) as MRT_Row<TData>;
|
41
41
|
|
42
42
|
const dialogProps = {
|
43
|
-
...parseFromValuesOrFunc(
|
43
|
+
...parseFromValuesOrFunc(muiEditRowDialogProps, { row, table }),
|
44
44
|
...(creatingRow &&
|
45
45
|
parseFromValuesOrFunc(muiCreateRowModalProps, { row, table })),
|
46
46
|
...rest,
|
@@ -76,12 +76,12 @@ export const MRT_EditRowModal = <TData extends MRT_RowData>({
|
|
76
76
|
{...dialogProps}
|
77
77
|
>
|
78
78
|
{((creatingRow &&
|
79
|
-
|
79
|
+
renderCreateRowDialogContent?.({
|
80
80
|
internalEditComponents,
|
81
81
|
row,
|
82
82
|
table,
|
83
83
|
})) ||
|
84
|
-
|
84
|
+
renderEditRowDialogContent?.({
|
85
85
|
internalEditComponents,
|
86
86
|
row,
|
87
87
|
table,
|
package/src/style.utils.ts
CHANGED
@@ -32,7 +32,7 @@ export const getMRTTheme = <TData extends MRT_RowData>(
|
|
32
32
|
: lighten(theme.palette.warning.light, 0.5),
|
33
33
|
pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1),
|
34
34
|
selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2),
|
35
|
-
...table.options.mrtTheme,
|
35
|
+
...parseFromValuesOrFunc(table.options.mrtTheme, theme),
|
36
36
|
});
|
37
37
|
|
38
38
|
export const getCommonMRTCellStyles = <TData extends MRT_RowData>({
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import Paper, { type PaperProps } from '@mui/material/Paper';
|
2
2
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
3
3
|
import { parseFromValuesOrFunc } from '../column.utils';
|
4
|
+
import { getMRTTheme } from '../style.utils';
|
4
5
|
import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
|
5
6
|
import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
|
6
7
|
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
@@ -62,6 +63,7 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
62
63
|
...tablePaperProps?.style,
|
63
64
|
}}
|
64
65
|
sx={(theme) => ({
|
66
|
+
backgroundColor: getMRTTheme(table, theme).baseBackgroundColor,
|
65
67
|
overflow: 'hidden',
|
66
68
|
transition: 'all 100ms ease-in-out',
|
67
69
|
...(parseFromValuesOrFunc(tablePaperProps?.sx, theme) as any),
|
package/src/types.ts
CHANGED
@@ -64,6 +64,7 @@ import { type TableFooterProps } from '@mui/material/TableFooter';
|
|
64
64
|
import { type TableHeadProps } from '@mui/material/TableHead';
|
65
65
|
import { type TableRowProps } from '@mui/material/TableRow';
|
66
66
|
import { type TextFieldProps } from '@mui/material/TextField';
|
67
|
+
import { type Theme } from '@mui/material/styles';
|
67
68
|
import { type DatePickerProps } from '@mui/x-date-pickers';
|
68
69
|
import { type MRT_AggregationFns } from './aggregationFns';
|
69
70
|
import { type MRT_FilterFns } from './filterFns';
|
@@ -213,6 +214,14 @@ export interface MRT_Localization {
|
|
213
214
|
unpinAll: string;
|
214
215
|
}
|
215
216
|
|
217
|
+
export interface MRT_Theme {
|
218
|
+
baseBackgroundColor?: CSSProperties['backgroundColor'];
|
219
|
+
draggingBorderColor?: CSSProperties['borderColor'];
|
220
|
+
matchHighlightColor?: CSSProperties['backgroundColor'];
|
221
|
+
pinnedRowBackgroundColor?: CSSProperties['backgroundColor'];
|
222
|
+
selectedRowBackgroundColor?: CSSProperties['backgroundColor'];
|
223
|
+
}
|
224
|
+
|
216
225
|
export interface MRT_RowModel<TData extends MRT_RowData> {
|
217
226
|
flatRows: MRT_Row<TData>[];
|
218
227
|
rows: MRT_Row<TData>[];
|
@@ -646,7 +655,8 @@ export type MRT_DisplayColumnIds =
|
|
646
655
|
| 'mrt-row-expand'
|
647
656
|
| 'mrt-row-numbers'
|
648
657
|
| 'mrt-row-pin'
|
649
|
-
| 'mrt-row-select'
|
658
|
+
| 'mrt-row-select'
|
659
|
+
| 'mrt-row-spacer';
|
650
660
|
|
651
661
|
/**
|
652
662
|
* `columns` and `data` props are the only required props, but there are over 170 other optional props.
|
@@ -709,9 +719,9 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
709
719
|
/**
|
710
720
|
* Change the default options for display columns.
|
711
721
|
*/
|
712
|
-
defaultDisplayColumn?: Partial<
|
722
|
+
defaultDisplayColumn?: Partial<MRT_DisplayColumnDef<TData>>;
|
713
723
|
displayColumnDefOptions?: Partial<{
|
714
|
-
[key in MRT_DisplayColumnIds]: Partial<
|
724
|
+
[key in MRT_DisplayColumnIds]: Partial<MRT_DisplayColumnDef<TData>>;
|
715
725
|
}>;
|
716
726
|
editDisplayMode?: 'cell' | 'custom' | 'modal' | 'row' | 'table';
|
717
727
|
enableBottomToolbar?: boolean;
|
@@ -771,13 +781,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
771
781
|
* @link https://www.material-react-table.com/docs/guides/memoize-components
|
772
782
|
*/
|
773
783
|
memoMode?: 'cells' | 'rows' | 'table-body';
|
774
|
-
mrtTheme?:
|
775
|
-
baseBackgroundColor?: CSSProperties['backgroundColor'];
|
776
|
-
draggingBorderColor?: CSSProperties['borderColor'];
|
777
|
-
matchHighlightColor?: CSSProperties['backgroundColor'];
|
778
|
-
pinnedRowBackgroundColor?: CSSProperties['backgroundColor'];
|
779
|
-
selectedRowBackgroundColor?: CSSProperties['backgroundColor'];
|
780
|
-
};
|
784
|
+
mrtTheme?: ((theme: Theme) => MRT_Theme) | MRT_Theme;
|
781
785
|
muiBottomToolbarProps?:
|
782
786
|
| ((props: { table: MRT_TableInstance<TData> }) => BoxProps)
|
783
787
|
| BoxProps;
|
@@ -816,7 +820,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
816
820
|
table: MRT_TableInstance<TData>;
|
817
821
|
}) => TableCellProps)
|
818
822
|
| TableCellProps;
|
819
|
-
|
823
|
+
muiEditRowDialogProps?:
|
820
824
|
| ((props: {
|
821
825
|
row: MRT_Row<TData>;
|
822
826
|
table: MRT_TableInstance<TData>;
|
@@ -1043,7 +1047,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
1043
1047
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
1044
1048
|
table: MRT_TableInstance<TData>;
|
1045
1049
|
}) => ReactNode[];
|
1046
|
-
|
1050
|
+
renderCreateRowDialogContent?: (props: {
|
1047
1051
|
internalEditComponents: ReactNode[];
|
1048
1052
|
row: MRT_Row<TData>;
|
1049
1053
|
table: MRT_TableInstance<TData>;
|
@@ -1052,7 +1056,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
1052
1056
|
row: MRT_Row<TData>;
|
1053
1057
|
table: MRT_TableInstance<TData>;
|
1054
1058
|
}) => ReactNode;
|
1055
|
-
|
1059
|
+
renderEditRowDialogContent?: (props: {
|
1056
1060
|
internalEditComponents: ReactNode[];
|
1057
1061
|
row: MRT_Row<TData>;
|
1058
1062
|
table: MRT_TableInstance<TData>;
|