material-react-table 3.0.3 → 3.1.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/index.d.ts +22 -73
- package/dist/index.esm.js +94 -96
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +94 -96
- package/dist/index.js.map +1 -1
- package/package.json +31 -32
- package/src/components/body/MRT_TableBodyCell.tsx +2 -2
- package/src/components/body/MRT_TableBodyCellValue.tsx +1 -1
- package/src/components/body/MRT_TableBodyRow.tsx +1 -1
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +1 -1
- package/src/components/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/components/buttons/MRT_EditActionButtons.tsx +2 -2
- package/src/components/footer/MRT_TableFooter.tsx +1 -1
- package/src/components/head/MRT_TableHead.tsx +1 -1
- package/src/components/head/MRT_TableHeadCell.tsx +2 -2
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +8 -10
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +1 -1
- package/src/components/inputs/MRT_EditCellTextField.tsx +5 -3
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +12 -5
- package/src/components/inputs/MRT_FilterTextField.tsx +88 -66
- package/src/components/menus/MRT_ColumnActionMenu.tsx +3 -2
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +12 -0
- package/src/components/table/MRT_TableContainer.tsx +1 -1
- package/src/components/table/MRT_TablePaper.tsx +1 -1
- package/src/components/toolbar/MRT_BottomToolbar.tsx +1 -1
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +2 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -1
- package/src/hooks/useMRT_ColumnVirtualizer.ts +1 -1
- package/src/hooks/useMRT_Effects.ts +2 -2
- package/src/hooks/useMRT_RowVirtualizer.ts +1 -1
- package/src/hooks/useMRT_TableInstance.ts +1 -1
- package/src/types.ts +15 -67
- package/src/utils/cell.utils.ts +2 -2
- package/src/utils/column.utils.ts +1 -1
- package/src/utils/tanstack.helpers.ts +1 -1
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "3.0
|
2
|
+
"version": "3.1.0",
|
3
3
|
"license": "MIT",
|
4
4
|
"name": "material-react-table",
|
5
5
|
"description": "A fully featured Material UI V6 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
@@ -62,47 +62,46 @@
|
|
62
62
|
"build-storybook": "storybook build"
|
63
63
|
},
|
64
64
|
"devDependencies": {
|
65
|
-
"@emotion/react": "^11.
|
66
|
-
"@emotion/styled": "^11.
|
67
|
-
"@faker-js/faker": "^9.
|
68
|
-
"@mui/icons-material": "^6.1
|
69
|
-
"@mui/material": "^6.1
|
70
|
-
"@mui/x-date-pickers": "^7.23.
|
65
|
+
"@emotion/react": "^11.14.0",
|
66
|
+
"@emotion/styled": "^11.14.0",
|
67
|
+
"@faker-js/faker": "^9.3.0",
|
68
|
+
"@mui/icons-material": "^6.2.1",
|
69
|
+
"@mui/material": "^6.2.1",
|
70
|
+
"@mui/x-date-pickers": "^7.23.3",
|
71
71
|
"@rollup/plugin-typescript": "^11.1.6",
|
72
72
|
"@size-limit/preset-small-lib": "^11.1.6",
|
73
|
-
"@storybook/addon-a11y": "^8.4.
|
74
|
-
"@storybook/addon-essentials": "^8.4.
|
75
|
-
"@storybook/addon-links": "^8.4.
|
76
|
-
"@storybook/addon-storysource": "^8.4.
|
77
|
-
"@storybook/blocks": "^8.4.
|
78
|
-
"@storybook/preview-api": "^8.4.
|
79
|
-
"@storybook/react": "^8.4.
|
80
|
-
"@storybook/react-vite": "^8.4.
|
81
|
-
"@types/node": "^22.10.
|
82
|
-
"@types/react": "^
|
83
|
-
"@types/react-dom": "^
|
84
|
-
"@typescript-eslint/eslint-plugin": "
|
85
|
-
"@typescript-eslint/parser": "
|
73
|
+
"@storybook/addon-a11y": "^8.4.7",
|
74
|
+
"@storybook/addon-essentials": "^8.4.7",
|
75
|
+
"@storybook/addon-links": "^8.4.7",
|
76
|
+
"@storybook/addon-storysource": "^8.4.7",
|
77
|
+
"@storybook/blocks": "^8.4.7",
|
78
|
+
"@storybook/preview-api": "^8.4.7",
|
79
|
+
"@storybook/react": "^8.4.7",
|
80
|
+
"@storybook/react-vite": "^8.4.7",
|
81
|
+
"@types/node": "^22.10.2",
|
82
|
+
"@types/react": "^19.0.2",
|
83
|
+
"@types/react-dom": "^19.0.2",
|
84
|
+
"@typescript-eslint/eslint-plugin": "8.18.1",
|
85
|
+
"@typescript-eslint/parser": "8.18.1",
|
86
86
|
"@vitejs/plugin-react": "^4.3.4",
|
87
|
-
"eslint": "^9.
|
87
|
+
"eslint": "^9.17.0",
|
88
88
|
"eslint-plugin-mui-path-imports": "^0.0.15",
|
89
|
-
"eslint-plugin-perfectionist": "^4.
|
89
|
+
"eslint-plugin-perfectionist": "^4.4.0",
|
90
90
|
"eslint-plugin-storybook": "^0.11.1",
|
91
|
-
"
|
92
|
-
"react": "^
|
93
|
-
"react-
|
94
|
-
"react-is": "^18.3.1",
|
91
|
+
"react": "^19.0.0",
|
92
|
+
"react-dom": "^19.0.0",
|
93
|
+
"react-is": "^19.0.0",
|
95
94
|
"rollup": "^2.79.1",
|
96
95
|
"rollup-plugin-copy": "^3.5.0",
|
97
96
|
"rollup-plugin-delete": "^2.1.0",
|
98
97
|
"rollup-plugin-dts": "^6.1.1",
|
99
98
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
100
99
|
"size-limit": "^11.1.6",
|
101
|
-
"storybook": "^8.4.
|
100
|
+
"storybook": "^8.4.7",
|
102
101
|
"storybook-dark-mode": "^4.0.2",
|
103
102
|
"tslib": "^2.8.1",
|
104
|
-
"typescript": "
|
105
|
-
"vite": "^6.0.
|
103
|
+
"typescript": "5.7.2",
|
104
|
+
"vite": "^6.0.5"
|
106
105
|
},
|
107
106
|
"peerDependencies": {
|
108
107
|
"@emotion/react": ">=11.13",
|
@@ -115,8 +114,8 @@
|
|
115
114
|
},
|
116
115
|
"dependencies": {
|
117
116
|
"@tanstack/match-sorter-utils": "8.19.4",
|
118
|
-
"@tanstack/react-table": "8.20.
|
119
|
-
"@tanstack/react-virtual": "3.
|
117
|
+
"@tanstack/react-table": "8.20.6",
|
118
|
+
"@tanstack/react-virtual": "3.11.2",
|
120
119
|
"highlight-words": "2.0.0"
|
121
120
|
}
|
122
|
-
}
|
121
|
+
}
|
@@ -30,7 +30,7 @@ export interface MRT_TableBodyCellProps<TData extends MRT_RowData>
|
|
30
30
|
extends TableCellProps {
|
31
31
|
cell: MRT_Cell<TData>;
|
32
32
|
numRows?: number;
|
33
|
-
rowRef: RefObject<HTMLTableRowElement>;
|
33
|
+
rowRef: RefObject<HTMLTableRowElement | null>;
|
34
34
|
staticColumnIndex?: number;
|
35
35
|
staticRowIndex: number;
|
36
36
|
table: MRT_TableInstance<TData>;
|
@@ -187,7 +187,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
187
187
|
(parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
|
188
188
|
parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
|
189
189
|
!['context-menu', false].includes(
|
190
|
-
// @ts-
|
190
|
+
// @ts-expect-error
|
191
191
|
parseFromValuesOrFunc(columnDef.enableClickToCopy, cell),
|
192
192
|
);
|
193
193
|
|
@@ -11,7 +11,7 @@ const allowedTypes = ['string', 'number'];
|
|
11
11
|
|
12
12
|
export interface MRT_TableBodyCellValueProps<TData extends MRT_RowData> {
|
13
13
|
cell: MRT_Cell<TData>;
|
14
|
-
rowRef?: RefObject<HTMLTableRowElement>;
|
14
|
+
rowRef?: RefObject<HTMLTableRowElement | null>;
|
15
15
|
staticColumnIndex?: number;
|
16
16
|
staticRowIndex?: number;
|
17
17
|
table: MRT_TableInstance<TData>;
|
@@ -129,7 +129,7 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
129
129
|
density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
|
130
130
|
|
131
131
|
const customRowHeight =
|
132
|
-
// @ts-
|
132
|
+
// @ts-expect-error
|
133
133
|
parseInt(tableRowProps?.style?.height ?? sx?.height, 10) || undefined;
|
134
134
|
|
135
135
|
const rowHeight = customRowHeight || defaultRowHeight;
|
@@ -11,7 +11,7 @@ import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
11
11
|
export interface MRT_TableBodyRowGrabHandleProps<TData extends MRT_RowData>
|
12
12
|
extends IconButtonProps {
|
13
13
|
row: MRT_Row<TData>;
|
14
|
-
rowRef: RefObject<HTMLTableRowElement>;
|
14
|
+
rowRef: RefObject<HTMLTableRowElement | null>;
|
15
15
|
table: MRT_TableInstance<TData>;
|
16
16
|
}
|
17
17
|
|
@@ -13,7 +13,7 @@ import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
13
13
|
|
14
14
|
export interface MRT_TableDetailPanelProps<TData extends MRT_RowData>
|
15
15
|
extends TableCellProps {
|
16
|
-
parentRowRef: RefObject<HTMLTableRowElement>;
|
16
|
+
parentRowRef: RefObject<HTMLTableRowElement | null>;
|
17
17
|
row: MRT_Row<TData>;
|
18
18
|
rowVirtualizer?: MRT_RowVirtualizer;
|
19
19
|
staticRowIndex: number;
|
@@ -55,14 +55,14 @@ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
|
|
55
55
|
|
56
56
|
const handleSubmitRow = () => {
|
57
57
|
//look for auto-filled input values
|
58
|
-
Object.values(editInputRefs
|
58
|
+
Object.values(editInputRefs.current ?? {})
|
59
59
|
.filter((inputRef) => row.id === inputRef?.name?.split('_')?.[0])
|
60
60
|
?.forEach((input) => {
|
61
61
|
if (
|
62
62
|
input.value !== undefined &&
|
63
63
|
Object.hasOwn(row?._valuesCache as object, input.name)
|
64
64
|
) {
|
65
|
-
// @ts-
|
65
|
+
// @ts-expect-error
|
66
66
|
row._valuesCache[input.name] = input.value;
|
67
67
|
}
|
68
68
|
});
|
@@ -191,7 +191,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
191
191
|
onDragOver={handleDragOver}
|
192
192
|
ref={(node: HTMLTableCellElement) => {
|
193
193
|
if (node) {
|
194
|
-
tableHeadCellRefs.current[column.id] = node;
|
194
|
+
tableHeadCellRefs.current![column.id] = node;
|
195
195
|
if (columnDefType !== 'group') {
|
196
196
|
columnVirtualizer?.measureElement?.(node);
|
197
197
|
}
|
@@ -319,7 +319,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
319
319
|
column={column}
|
320
320
|
table={table}
|
321
321
|
tableHeadCellRef={{
|
322
|
-
current: tableHeadCellRefs.current[column.id]
|
322
|
+
current: tableHeadCellRefs.current?.[column.id]!,
|
323
323
|
}}
|
324
324
|
/>
|
325
325
|
)}
|
@@ -76,12 +76,11 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
76
76
|
.replace(
|
77
77
|
'{filterType}',
|
78
78
|
currentFilterOption
|
79
|
-
?
|
80
|
-
localization[
|
79
|
+
? localization[
|
81
80
|
`filter${
|
82
|
-
currentFilterOption
|
83
|
-
currentFilterOption
|
84
|
-
}`
|
81
|
+
currentFilterOption.charAt(0).toUpperCase() +
|
82
|
+
currentFilterOption.slice(1)
|
83
|
+
}` as keyof typeof localization
|
85
84
|
]
|
86
85
|
: '',
|
87
86
|
)
|
@@ -109,8 +108,7 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
109
108
|
in={
|
110
109
|
columnFilterDisplayMode === 'popover' ||
|
111
110
|
(!!filterValue && !isRangeFilter) ||
|
112
|
-
(isRangeFilter &&
|
113
|
-
(!!filterValue?.[0] || !!filterValue?.[1]))
|
111
|
+
(isRangeFilter && (!!filterValue?.[0] || !!filterValue?.[1]))
|
114
112
|
}
|
115
113
|
unmountOnExit
|
116
114
|
>
|
@@ -125,8 +123,8 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
125
123
|
setShowColumnFilters(true);
|
126
124
|
}
|
127
125
|
queueMicrotask(() => {
|
128
|
-
filterInputRefs.current[`${column.id}-0`]?.focus?.();
|
129
|
-
filterInputRefs.current[`${column.id}-0`]?.select?.();
|
126
|
+
filterInputRefs.current?.[`${column.id}-0`]?.focus?.();
|
127
|
+
filterInputRefs.current?.[`${column.id}-0`]?.select?.();
|
130
128
|
});
|
131
129
|
event.stopPropagation();
|
132
130
|
}}
|
@@ -158,7 +156,7 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
158
156
|
disableScrollLock
|
159
157
|
onClick={(event) => event.stopPropagation()}
|
160
158
|
onClose={(event) => {
|
161
|
-
//@ts-
|
159
|
+
//@ts-expect-error
|
162
160
|
event.stopPropagation();
|
163
161
|
setAnchorEl(null);
|
164
162
|
}}
|
@@ -13,7 +13,7 @@ export interface MRT_TableHeadCellGrabHandleProps<TData extends MRT_RowData>
|
|
13
13
|
extends IconButtonProps {
|
14
14
|
column: MRT_Column<TData>;
|
15
15
|
table: MRT_TableInstance<TData>;
|
16
|
-
tableHeadCellRef: RefObject<HTMLTableCellElement>;
|
16
|
+
tableHeadCellRef: RefObject<HTMLTableCellElement | null>;
|
17
17
|
}
|
18
18
|
|
19
19
|
export const MRT_TableHeadCellGrabHandle = <TData extends MRT_RowData>({
|
@@ -70,7 +70,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
70
70
|
const isSelectEdit = editVariant === 'select' || textFieldProps?.select;
|
71
71
|
|
72
72
|
const saveInputValueToRowCache = (newValue: string) => {
|
73
|
-
//@ts-
|
73
|
+
//@ts-expect-error
|
74
74
|
row._valuesCache[column.id] = newValue;
|
75
75
|
if (isCreating) {
|
76
76
|
setCreatingRow(row);
|
@@ -96,7 +96,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
96
96
|
const handleEnterKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
97
97
|
textFieldProps.onKeyDown?.(event);
|
98
98
|
if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
|
99
|
-
editInputRefs.current[column.id]?.blur();
|
99
|
+
editInputRefs.current?.[column.id]?.blur();
|
100
100
|
}
|
101
101
|
};
|
102
102
|
|
@@ -110,7 +110,9 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
110
110
|
fullWidth
|
111
111
|
inputRef={(inputRef) => {
|
112
112
|
if (inputRef) {
|
113
|
-
editInputRefs.current[column.id] =
|
113
|
+
editInputRefs.current![column.id] = isSelectEdit
|
114
|
+
? inputRef.node
|
115
|
+
: inputRef;
|
114
116
|
if (textFieldProps.inputRef) {
|
115
117
|
textFieldProps.inputRef = inputRef;
|
116
118
|
}
|
@@ -54,6 +54,13 @@ export const MRT_FilterRangeSlider = <TData extends MRT_RowData>({
|
|
54
54
|
|
55
55
|
const isMounted = useRef(false);
|
56
56
|
|
57
|
+
// prevent moving the focus to the next/prev cell when using the arrow keys
|
58
|
+
const handleKeyDown = (event: React.KeyboardEvent) => {
|
59
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
60
|
+
event.stopPropagation();
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
57
64
|
useEffect(() => {
|
58
65
|
if (isMounted.current) {
|
59
66
|
if (columnFilterValue === undefined) {
|
@@ -84,6 +91,7 @@ export const MRT_FilterRangeSlider = <TData extends MRT_RowData>({
|
|
84
91
|
}
|
85
92
|
}
|
86
93
|
}}
|
94
|
+
onKeyDown={handleKeyDown}
|
87
95
|
value={filterValues}
|
88
96
|
valueLabelDisplay="auto"
|
89
97
|
{...sliderProps}
|
@@ -91,10 +99,10 @@ export const MRT_FilterRangeSlider = <TData extends MRT_RowData>({
|
|
91
99
|
input: {
|
92
100
|
ref: (node) => {
|
93
101
|
if (node) {
|
94
|
-
filterInputRefs.current[`${column.id}-0`] = node;
|
95
|
-
// @ts-
|
102
|
+
filterInputRefs.current![`${column.id}-0`] = node;
|
103
|
+
// @ts-expect-error
|
96
104
|
if (sliderProps?.slotProps?.input?.ref) {
|
97
|
-
//@ts-
|
105
|
+
//@ts-expect-error
|
98
106
|
sliderProps.slotProps.input.ref = node;
|
99
107
|
}
|
100
108
|
}
|
@@ -121,12 +129,11 @@ export const MRT_FilterRangeSlider = <TData extends MRT_RowData>({
|
|
121
129
|
>
|
122
130
|
{localization.filterMode.replace(
|
123
131
|
'{filterType}',
|
124
|
-
// @ts-ignore
|
125
132
|
localization[
|
126
133
|
`filter${
|
127
134
|
currentFilterOption?.charAt(0)?.toUpperCase() +
|
128
135
|
currentFilterOption?.slice(1)
|
129
|
-
}`
|
136
|
+
}` as keyof typeof localization
|
130
137
|
],
|
131
138
|
)}
|
132
139
|
</FormHelperText>
|
@@ -107,12 +107,11 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
107
107
|
const dropdownOptions = useDropdownOptions({ header, table });
|
108
108
|
|
109
109
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
110
|
-
?
|
111
|
-
localization[
|
110
|
+
? localization[
|
112
111
|
`filter${
|
113
112
|
currentFilterOption?.charAt?.(0)?.toUpperCase() +
|
114
113
|
currentFilterOption?.slice(1)
|
115
|
-
}`
|
114
|
+
}` as keyof typeof localization
|
116
115
|
]
|
117
116
|
: '';
|
118
117
|
|
@@ -246,7 +245,10 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
246
245
|
!isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (
|
247
246
|
<InputAdornment
|
248
247
|
position="end"
|
249
|
-
sx={{
|
248
|
+
sx={{
|
249
|
+
mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined,
|
250
|
+
visibility: (filterValue?.length ?? 0) > 0 ? 'visible' : 'hidden',
|
251
|
+
}}
|
250
252
|
>
|
251
253
|
<Tooltip placement="right" title={localization.clearFilter ?? ''}>
|
252
254
|
<span>
|
@@ -288,44 +290,23 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
288
290
|
</InputAdornment>
|
289
291
|
) : null;
|
290
292
|
|
291
|
-
const commonTextFieldProps: TextFieldProps = {
|
292
|
-
FormHelperTextProps: {
|
293
|
-
sx: {
|
294
|
-
fontSize: '0.75rem',
|
295
|
-
lineHeight: '0.8rem',
|
296
|
-
whiteSpace: 'nowrap',
|
297
|
-
},
|
298
|
-
},
|
299
|
-
InputProps: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
|
300
|
-
? { endAdornment, startAdornment }
|
301
|
-
: { startAdornment },
|
293
|
+
const commonTextFieldProps: TextFieldProps<any> = {
|
302
294
|
fullWidth: true,
|
303
295
|
helperText: showChangeModeButton ? (
|
304
296
|
<label>
|
305
297
|
{localization.filterMode.replace(
|
306
298
|
'{filterType}',
|
307
|
-
// @ts-ignore
|
308
299
|
localization[
|
309
300
|
`filter${
|
310
301
|
currentFilterOption?.charAt(0)?.toUpperCase() +
|
311
302
|
currentFilterOption?.slice(1)
|
312
|
-
}`
|
303
|
+
}` as keyof typeof localization
|
313
304
|
],
|
314
305
|
)}
|
315
306
|
</label>
|
316
307
|
) : null,
|
317
|
-
inputProps: {
|
318
|
-
'aria-label': filterPlaceholder,
|
319
|
-
autoComplete: 'off',
|
320
|
-
disabled: !!filterChipLabel,
|
321
|
-
sx: {
|
322
|
-
textOverflow: 'ellipsis',
|
323
|
-
width: filterChipLabel ? 0 : undefined,
|
324
|
-
},
|
325
|
-
title: filterPlaceholder,
|
326
|
-
},
|
327
308
|
inputRef: (inputRef) => {
|
328
|
-
filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] =
|
309
|
+
filterInputRefs.current![`${column.id}-${rangeFilterIndex ?? 0}`] =
|
329
310
|
inputRef;
|
330
311
|
if (textFieldProps.inputRef) {
|
331
312
|
textFieldProps.inputRef = inputRef;
|
@@ -338,6 +319,31 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
338
319
|
: filterPlaceholder,
|
339
320
|
variant: 'standard',
|
340
321
|
...textFieldProps,
|
322
|
+
slotProps: {
|
323
|
+
...textFieldProps.slotProps,
|
324
|
+
formHelperText: {
|
325
|
+
sx: {
|
326
|
+
fontSize: '0.75rem',
|
327
|
+
lineHeight: '0.8rem',
|
328
|
+
whiteSpace: 'nowrap',
|
329
|
+
},
|
330
|
+
...textFieldProps.slotProps?.formHelperText,
|
331
|
+
},
|
332
|
+
input: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
|
333
|
+
? { endAdornment, startAdornment }
|
334
|
+
: { startAdornment },
|
335
|
+
htmlInput: {
|
336
|
+
'aria-label': filterPlaceholder,
|
337
|
+
autoComplete: 'off',
|
338
|
+
disabled: !!filterChipLabel,
|
339
|
+
sx: {
|
340
|
+
textOverflow: 'ellipsis',
|
341
|
+
width: filterChipLabel ? 0 : undefined,
|
342
|
+
},
|
343
|
+
title: filterPlaceholder,
|
344
|
+
...textFieldProps.slotProps?.htmlInput,
|
345
|
+
},
|
346
|
+
},
|
341
347
|
onKeyDown: (e) => {
|
342
348
|
e.stopPropagation();
|
343
349
|
textFieldProps.onKeyDown?.(e);
|
@@ -422,26 +428,32 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
422
428
|
getOptionLabel={(option: DropdownOption) =>
|
423
429
|
getValueAndLabel(option).label
|
424
430
|
}
|
425
|
-
|
426
|
-
|
427
|
-
handleAutocompleteChange(newValue)
|
431
|
+
onChange={(_e, newValue) =>
|
432
|
+
handleAutocompleteChange(newValue as DropdownOption | null)
|
428
433
|
}
|
429
434
|
options={
|
430
435
|
dropdownOptions?.map((option) => getValueAndLabel(option)) ?? []
|
431
436
|
}
|
432
437
|
{...autocompleteProps}
|
433
|
-
renderInput={(builtinTextFieldProps) => (
|
438
|
+
renderInput={(builtinTextFieldProps: TextFieldProps) => (
|
434
439
|
<TextField
|
435
|
-
{...builtinTextFieldProps}
|
436
440
|
{...commonTextFieldProps}
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
441
|
+
{...builtinTextFieldProps}
|
442
|
+
slotProps={{
|
443
|
+
...builtinTextFieldProps.slotProps,
|
444
|
+
...commonTextFieldProps.slotProps,
|
445
|
+
input: {
|
446
|
+
...builtinTextFieldProps.InputProps,
|
447
|
+
...builtinTextFieldProps.slotProps?.input,
|
448
|
+
startAdornment:
|
449
|
+
//@ts-expect-error
|
450
|
+
commonTextFieldProps?.slotProps?.input?.startAdornment,
|
451
|
+
},
|
452
|
+
htmlInput: {
|
453
|
+
...builtinTextFieldProps.inputProps,
|
454
|
+
...builtinTextFieldProps.slotProps?.htmlInput,
|
455
|
+
...commonTextFieldProps?.slotProps?.htmlInput,
|
456
|
+
},
|
445
457
|
}}
|
446
458
|
onChange={handleTextFieldChange}
|
447
459
|
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
@@ -453,31 +465,41 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
453
465
|
<TextField
|
454
466
|
select={isSelectFilter || isMultiSelectFilter}
|
455
467
|
{...commonTextFieldProps}
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
468
|
+
slotProps={{
|
469
|
+
...commonTextFieldProps.slotProps,
|
470
|
+
inputLabel: {
|
471
|
+
shrink: isSelectFilter || isMultiSelectFilter,
|
472
|
+
...(commonTextFieldProps.slotProps?.inputLabel as any),
|
473
|
+
},
|
474
|
+
select: {
|
475
|
+
MenuProps: { disableScrollLock: true },
|
476
|
+
displayEmpty: true,
|
477
|
+
multiple: isMultiSelectFilter,
|
478
|
+
renderValue: isMultiSelectFilter
|
479
|
+
? (selected: any) =>
|
480
|
+
!Array.isArray(selected) || selected?.length === 0 ? (
|
481
|
+
<Box sx={{ opacity: 0.5 }}>{filterPlaceholder}</Box>
|
482
|
+
) : (
|
483
|
+
<Box
|
484
|
+
sx={{ display: 'flex', flexWrap: 'wrap', gap: '2px' }}
|
485
|
+
>
|
486
|
+
{selected.map((value: string) => {
|
487
|
+
const selectedValue = dropdownOptions?.find(
|
488
|
+
(option) =>
|
489
|
+
getValueAndLabel(option).value === value,
|
490
|
+
);
|
491
|
+
return (
|
492
|
+
<Chip
|
493
|
+
key={value}
|
494
|
+
label={getValueAndLabel(selectedValue).label}
|
495
|
+
/>
|
496
|
+
);
|
497
|
+
})}
|
498
|
+
</Box>
|
499
|
+
)
|
500
|
+
: undefined,
|
501
|
+
...commonTextFieldProps.slotProps?.select,
|
502
|
+
},
|
481
503
|
}}
|
482
504
|
onChange={handleTextFieldChange}
|
483
505
|
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
@@ -117,7 +117,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
117
117
|
|
118
118
|
const handleFilterByColumn = () => {
|
119
119
|
setShowColumnFilters(true);
|
120
|
-
queueMicrotask(() => filterInputRefs.current[`${column.id}-0`]?.focus());
|
120
|
+
queueMicrotask(() => filterInputRefs.current?.[`${column.id}-0`]?.focus());
|
121
121
|
setAnchorEl(null);
|
122
122
|
};
|
123
123
|
|
@@ -150,6 +150,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
150
150
|
? [
|
151
151
|
enableSortingRemoval !== false && (
|
152
152
|
<MRT_ActionMenuItem
|
153
|
+
disabled={column.getIsSorted() === false}
|
153
154
|
icon={<ClearAllIcon />}
|
154
155
|
key={0}
|
155
156
|
label={localization.clearSort}
|
@@ -277,7 +278,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
277
278
|
...(enableColumnResizing && column.getCanResize()
|
278
279
|
? [
|
279
280
|
<MRT_ActionMenuItem
|
280
|
-
disabled={
|
281
|
+
disabled={columnSizing[column.id] === undefined}
|
281
282
|
icon={<RestartAltIcon />}
|
282
283
|
key={10}
|
283
284
|
label={localization.resetColumnSize}
|
@@ -35,6 +35,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
35
35
|
getLeftLeafColumns,
|
36
36
|
getRightLeafColumns,
|
37
37
|
getState,
|
38
|
+
initialState,
|
38
39
|
options: {
|
39
40
|
enableColumnOrdering,
|
40
41
|
enableColumnPinning,
|
@@ -79,6 +80,16 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
79
80
|
(col) => col.columnDef.columnDefType === 'group',
|
80
81
|
);
|
81
82
|
|
83
|
+
const hasColumnOrderChanged = useMemo(
|
84
|
+
() =>
|
85
|
+
columnOrder.length !== initialState.columnOrder.length ||
|
86
|
+
!columnOrder.every(
|
87
|
+
(column, index) => column === initialState.columnOrder[index],
|
88
|
+
),
|
89
|
+
|
90
|
+
[columnOrder, initialState.columnOrder],
|
91
|
+
);
|
92
|
+
|
82
93
|
const [hoveredColumn, setHoveredColumn] = useState<MRT_Column<TData> | null>(
|
83
94
|
null,
|
84
95
|
);
|
@@ -120,6 +131,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
120
131
|
getDefaultColumnOrderIds(table.options, true),
|
121
132
|
)
|
122
133
|
}
|
134
|
+
disabled={!hasColumnOrderChanged}
|
123
135
|
>
|
124
136
|
{localization.resetOrder}
|
125
137
|
</Button>
|