material-react-table 2.5.0 → 2.5.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/dist/index.esm.js +42 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/body/MRT_TableBodyRow.tsx +10 -7
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -1
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +9 -5
- package/src/inputs/MRT_FilterRangeSlider.tsx +1 -0
- package/src/inputs/MRT_FilterTextField.tsx +2 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +3 -0
- package/src/menus/MRT_FilterOptionMenu.tsx +5 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +5 -1
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +9 -8
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "2.5.
|
2
|
+
"version": "2.5.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.",
|
@@ -66,10 +66,10 @@
|
|
66
66
|
"@emotion/react": "^11.11.3",
|
67
67
|
"@emotion/styled": "^11.11.0",
|
68
68
|
"@faker-js/faker": "^8.3.1",
|
69
|
-
"@mui/icons-material": "^5.15.
|
70
|
-
"@mui/material": "^5.15.
|
71
|
-
"@mui/x-date-pickers": "^6.18.
|
72
|
-
"@rollup/plugin-typescript": "^11.1.
|
69
|
+
"@mui/icons-material": "^5.15.4",
|
70
|
+
"@mui/material": "^5.15.4",
|
71
|
+
"@mui/x-date-pickers": "^6.18.7",
|
72
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
73
73
|
"@size-limit/preset-small-lib": "^11.0.1",
|
74
74
|
"@storybook/addon-a11y": "^7.6.7",
|
75
75
|
"@storybook/addon-essentials": "^7.6.7",
|
@@ -80,11 +80,11 @@
|
|
80
80
|
"@storybook/react": "^7.6.7",
|
81
81
|
"@storybook/react-vite": "^7.6.7",
|
82
82
|
"@storybook/testing-library": "^0.2.2",
|
83
|
-
"@types/node": "^20.10.
|
84
|
-
"@types/react": "^18.2.
|
83
|
+
"@types/node": "^20.10.8",
|
84
|
+
"@types/react": "^18.2.47",
|
85
85
|
"@types/react-dom": "^18.2.18",
|
86
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
87
|
-
"@typescript-eslint/parser": "^6.
|
86
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
87
|
+
"@typescript-eslint/parser": "^6.18.1",
|
88
88
|
"@vitejs/plugin-react": "^4.2.1",
|
89
89
|
"eslint": "^8.56.0",
|
90
90
|
"eslint-plugin-mui-path-imports": "^0.0.15",
|
@@ -101,7 +101,7 @@
|
|
101
101
|
"storybook-dark-mode": "^3.0.3",
|
102
102
|
"tslib": "^2.6.2",
|
103
103
|
"typescript": "^5.3.3",
|
104
|
-
"vite": "^5.0.
|
104
|
+
"vite": "^5.0.11"
|
105
105
|
},
|
106
106
|
"peerDependencies": {
|
107
107
|
"@emotion/react": ">=11.11",
|
@@ -74,6 +74,8 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
74
74
|
columnVirtualizer ?? {};
|
75
75
|
|
76
76
|
const isPinned = enableRowPinning && row.getIsPinned();
|
77
|
+
const isDraggingRow = draggingRow?.id === row.id;
|
78
|
+
const isHoveredRow = hoveredRow?.id === row.id;
|
77
79
|
|
78
80
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
79
81
|
row,
|
@@ -132,7 +134,9 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
132
134
|
<TableRow
|
133
135
|
data-index={rowIndex}
|
134
136
|
data-pinned={!!isPinned || undefined}
|
135
|
-
data-selected={
|
137
|
+
data-selected={
|
138
|
+
row.getIsSelected() || row.getIsAllSubRowsSelected() || undefined
|
139
|
+
}
|
136
140
|
onDragEnter={handleDragEnter}
|
137
141
|
ref={(node: HTMLTableRowElement) => {
|
138
142
|
if (node) {
|
@@ -169,11 +173,7 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
169
173
|
: undefined,
|
170
174
|
boxSizing: 'border-box',
|
171
175
|
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
172
|
-
opacity: isPinned
|
173
|
-
? 0.97
|
174
|
-
: draggingRow?.id === row.id || hoveredRow?.id === row.id
|
175
|
-
? 0.5
|
176
|
-
: 1,
|
176
|
+
opacity: isPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1,
|
177
177
|
position: virtualRow
|
178
178
|
? 'absolute'
|
179
179
|
: rowPinningDisplayMode?.includes('sticky') && isPinned
|
@@ -212,7 +212,10 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
212
212
|
: (cellOrVirtualCell as MRT_Cell<TData>);
|
213
213
|
const props = {
|
214
214
|
cell,
|
215
|
-
measureElement:
|
215
|
+
measureElement:
|
216
|
+
!isDraggingRow && !isHoveredRow
|
217
|
+
? columnVirtualizer?.measureElement
|
218
|
+
: undefined,
|
216
219
|
numRows,
|
217
220
|
rowIndex,
|
218
221
|
rowRef,
|
@@ -34,7 +34,11 @@ export const MRT_TableBodyRowGrabHandle = <TData extends MRT_RowData>({
|
|
34
34
|
|
35
35
|
const handleDragStart = (event: DragEvent<HTMLButtonElement>) => {
|
36
36
|
iconButtonProps?.onDragStart?.(event);
|
37
|
-
|
37
|
+
try {
|
38
|
+
event.dataTransfer.setDragImage(rowRef.current as HTMLElement, 0, 0);
|
39
|
+
} catch (e) {
|
40
|
+
console.error(e);
|
41
|
+
}
|
38
42
|
table.setDraggingRow(row as any);
|
39
43
|
};
|
40
44
|
|
@@ -139,6 +139,7 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
139
139
|
}}
|
140
140
|
onKeyDown={(event) => event.key === 'Enter' && setAnchorEl(null)}
|
141
141
|
open={!!anchorEl}
|
142
|
+
slotProps={{ paper: { sx: { overflow: 'visible' } } }}
|
142
143
|
transformOrigin={{
|
143
144
|
horizontal: 'center',
|
144
145
|
vertical: 'bottom',
|
@@ -42,11 +42,15 @@ export const MRT_TableHeadCellGrabHandle = <TData extends MRT_RowData>({
|
|
42
42
|
const handleDragStart = (event: DragEvent<HTMLButtonElement>) => {
|
43
43
|
iconButtonProps?.onDragStart?.(event);
|
44
44
|
setDraggingColumn(column);
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
try {
|
46
|
+
event.dataTransfer.setDragImage(
|
47
|
+
tableHeadCellRef.current as HTMLElement,
|
48
|
+
0,
|
49
|
+
0,
|
50
|
+
);
|
51
|
+
} catch (e) {
|
52
|
+
console.error(e);
|
53
|
+
}
|
50
54
|
};
|
51
55
|
|
52
56
|
const handleDragEnd = (event: DragEvent<HTMLButtonElement>) => {
|
@@ -353,7 +353,6 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
353
353
|
}
|
354
354
|
},
|
355
355
|
margin: 'none',
|
356
|
-
onClick: (e: MouseEvent<HTMLInputElement>) => e.stopPropagation(),
|
357
356
|
placeholder:
|
358
357
|
filterChipLabel || isSelectFilter || isMultiSelectFilter
|
359
358
|
? undefined
|
@@ -459,6 +458,7 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
459
458
|
...commonTextFieldProps?.inputProps,
|
460
459
|
}}
|
461
460
|
onChange={handleTextFieldChange}
|
461
|
+
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
462
462
|
/>
|
463
463
|
)}
|
464
464
|
value={filterValue}
|
@@ -493,6 +493,7 @@ export const MRT_FilterTextField = <TData extends MRT_RowData>({
|
|
493
493
|
...commonTextFieldProps.SelectProps,
|
494
494
|
}}
|
495
495
|
onChange={handleTextFieldChange}
|
496
|
+
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
496
497
|
value={filterValue ?? ''}
|
497
498
|
>
|
498
499
|
{(isSelectFilter || isMultiSelectFilter) && [
|
@@ -88,6 +88,9 @@ export const MRT_SelectCheckbox = <TData extends MRT_RowData>({
|
|
88
88
|
};
|
89
89
|
|
90
90
|
const commonProps = {
|
91
|
+
'aria-label': selectAll
|
92
|
+
? localization.toggleSelectAll
|
93
|
+
: localization.toggleSelectRow,
|
91
94
|
checked: selectAll
|
92
95
|
? allRowsSelected
|
93
96
|
: row?.getIsSelected() || row?.getIsAllSubRowsSelected(),
|
@@ -220,6 +220,11 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
|
|
220
220
|
if (Array.isArray(currentFilterValue)) {
|
221
221
|
column.setFilterValue('');
|
222
222
|
setFilterValue?.('');
|
223
|
+
} else if (
|
224
|
+
currentFilterValue === ' ' &&
|
225
|
+
emptyModes.includes(prevFilterMode)
|
226
|
+
) {
|
227
|
+
column.setFilterValue(undefined);
|
223
228
|
} else {
|
224
229
|
column.setFilterValue(currentFilterValue); // perform new filter render
|
225
230
|
}
|
@@ -72,7 +72,11 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
72
72
|
|
73
73
|
const handleDragStart = (e: DragEvent<HTMLButtonElement>) => {
|
74
74
|
setIsDragging(true);
|
75
|
-
|
75
|
+
try {
|
76
|
+
e.dataTransfer.setDragImage(menuItemRef.current as HTMLElement, 0, 0);
|
77
|
+
} catch (e) {
|
78
|
+
console.error(e);
|
79
|
+
}
|
76
80
|
};
|
77
81
|
|
78
82
|
const handleDragEnd = (_e: DragEvent<HTMLButtonElement>) => {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Fragment } from 'react';
|
1
|
+
import { Fragment, useMemo } from 'react';
|
2
2
|
import Alert, { type AlertProps } from '@mui/material/Alert';
|
3
3
|
import AlertTitle from '@mui/material/AlertTitle';
|
4
4
|
import Box from '@mui/material/Box';
|
@@ -21,7 +21,6 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
21
21
|
}: Props<TData>) => {
|
22
22
|
const {
|
23
23
|
getPrePaginationRowModel,
|
24
|
-
getSelectedRowModel,
|
25
24
|
getState,
|
26
25
|
options: {
|
27
26
|
enableRowSelection,
|
@@ -35,7 +34,7 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
35
34
|
},
|
36
35
|
refs: { tablePaperRef },
|
37
36
|
} = table;
|
38
|
-
const { density, grouping, showAlertBanner } = getState();
|
37
|
+
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
39
38
|
|
40
39
|
const alertProps = {
|
41
40
|
...parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
@@ -48,13 +47,15 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
48
47
|
table,
|
49
48
|
});
|
50
49
|
|
50
|
+
const selectedRowCount = useMemo(
|
51
|
+
() => Object.values(rowSelection).filter(Boolean).length,
|
52
|
+
[rowSelection],
|
53
|
+
);
|
54
|
+
|
51
55
|
const selectedAlert =
|
52
|
-
|
56
|
+
selectedRowCount > 0
|
53
57
|
? localization.selectedCountOfRowCountRowsSelected
|
54
|
-
?.replace(
|
55
|
-
'{selectedCount}',
|
56
|
-
getSelectedRowModel().rows.length.toString(),
|
57
|
-
)
|
58
|
+
?.replace('{selectedCount}', selectedRowCount.toLocaleString())
|
58
59
|
?.replace(
|
59
60
|
'{rowCount}',
|
60
61
|
(rowCount ?? getPrePaginationRowModel().rows.length).toString(),
|