material-react-table 2.0.0-rc.0 → 2.0.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 +2 -2
- package/dist/index.esm.js +23 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/body/MRT_TableBodyCell.tsx +14 -11
- package/src/body/MRT_TableBodyCellValue.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +13 -9
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +2 -1
- package/src/hooks/useMRT_TableOptions.ts +8 -8
- package/src/table/MRT_Table.tsx +3 -1
- package/src/types.ts +2 -2
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "2.0.0
|
2
|
+
"version": "2.0.0",
|
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,9 +66,9 @@
|
|
66
66
|
"@emotion/react": "^11.11.1",
|
67
67
|
"@emotion/styled": "^11.11.0",
|
68
68
|
"@faker-js/faker": "^8.2.0",
|
69
|
-
"@mui/icons-material": "^5.14.
|
70
|
-
"@mui/material": "^5.14.
|
71
|
-
"@mui/x-date-pickers": "^6.
|
69
|
+
"@mui/icons-material": "^5.14.15",
|
70
|
+
"@mui/material": "^5.14.15",
|
71
|
+
"@mui/x-date-pickers": "^6.17.0",
|
72
72
|
"@rollup/plugin-typescript": "^11.1.5",
|
73
73
|
"@size-limit/preset-small-lib": "^10.0.1",
|
74
74
|
"@storybook/addon-a11y": "^7.5.1",
|
@@ -80,8 +80,8 @@
|
|
80
80
|
"@storybook/react": "^7.5.1",
|
81
81
|
"@storybook/react-vite": "^7.5.1",
|
82
82
|
"@storybook/testing-library": "^0.2.2",
|
83
|
-
"@types/node": "^20.8.
|
84
|
-
"@types/react": "^18.2.
|
83
|
+
"@types/node": "^20.8.9",
|
84
|
+
"@types/react": "^18.2.33",
|
85
85
|
"@types/react-dom": "^18.2.14",
|
86
86
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
87
87
|
"@typescript-eslint/parser": "^6.9.0",
|
@@ -50,6 +50,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
50
50
|
const {
|
51
51
|
getState,
|
52
52
|
options: {
|
53
|
+
columnResizeMode,
|
53
54
|
createDisplayMode,
|
54
55
|
editDisplayMode,
|
55
56
|
enableClickToCopy,
|
@@ -118,19 +119,21 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
118
119
|
const isFirstColumn = getIsFirstColumn(column, table);
|
119
120
|
const isLastColumn = getIsLastColumn(column, table);
|
120
121
|
const isLastRow = numRows && rowIndex === numRows - 1;
|
122
|
+
const showResizeBorder =
|
123
|
+
columnSizingInfo.isResizingColumn === column.id &&
|
124
|
+
columnResizeMode === 'onChange';
|
121
125
|
|
122
|
-
const borderStyle =
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
: undefined;
|
126
|
+
const borderStyle = showResizeBorder
|
127
|
+
? `2px solid ${draggingBorderColor} !important`
|
128
|
+
: isDraggingColumn || isDraggingRow
|
129
|
+
? `1px dashed ${theme.palette.grey[500]} !important`
|
130
|
+
: isHoveredColumn ||
|
131
|
+
isHoveredRow ||
|
132
|
+
columnSizingInfo.isResizingColumn === column.id
|
133
|
+
? `2px dashed ${draggingBorderColor} !important`
|
134
|
+
: undefined;
|
132
135
|
|
133
|
-
if (
|
136
|
+
if (showResizeBorder) {
|
134
137
|
return { borderRight: borderStyle };
|
135
138
|
}
|
136
139
|
|
@@ -56,7 +56,7 @@ export const MRT_TableBodyCellValue = <TData extends MRT_RowData>({
|
|
56
56
|
if (
|
57
57
|
enableFilterMatchHighlighting &&
|
58
58
|
columnDef.enableFilterMatchHighlighting !== false &&
|
59
|
-
renderedCellValue &&
|
59
|
+
String(renderedCellValue) &&
|
60
60
|
allowedTypes.includes(typeof renderedCellValue) &&
|
61
61
|
((filterValue &&
|
62
62
|
allowedTypes.includes(typeof filterValue) &&
|
@@ -32,6 +32,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
32
32
|
getState,
|
33
33
|
options: {
|
34
34
|
columnFilterDisplayMode,
|
35
|
+
columnResizeMode,
|
35
36
|
enableColumnActions,
|
36
37
|
enableColumnDragging,
|
37
38
|
enableColumnOrdering,
|
@@ -88,17 +89,20 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
88
89
|
}, [showColumnActions, showDragHandle]);
|
89
90
|
|
90
91
|
const draggingBorders = useMemo(() => {
|
91
|
-
const
|
92
|
+
const showResizeBorder =
|
92
93
|
columnSizingInfo.isResizingColumn === column.id &&
|
93
|
-
|
94
|
-
|
95
|
-
: draggingColumn?.id === column.id
|
96
|
-
? `1px dashed ${theme.palette.grey[500]}`
|
97
|
-
: hoveredColumn?.id === column.id
|
98
|
-
? `2px dashed ${draggingBorderColor}`
|
99
|
-
: undefined;
|
94
|
+
columnResizeMode === 'onChange' &&
|
95
|
+
!header.subHeaders.length;
|
100
96
|
|
101
|
-
|
97
|
+
const borderStyle = showResizeBorder
|
98
|
+
? `2px solid ${draggingBorderColor} !important`
|
99
|
+
: draggingColumn?.id === column.id
|
100
|
+
? `1px dashed ${theme.palette.grey[500]}`
|
101
|
+
: hoveredColumn?.id === column.id
|
102
|
+
? `2px dashed ${draggingBorderColor}`
|
103
|
+
: undefined;
|
104
|
+
|
105
|
+
if (showResizeBorder) {
|
102
106
|
return { borderRight: borderStyle };
|
103
107
|
}
|
104
108
|
const draggingBorders = borderStyle
|
@@ -46,7 +46,8 @@ export const MRT_TableHeadCellResizeHandle = <TData extends MRT_RowData>({
|
|
46
46
|
sx={(theme) => ({
|
47
47
|
'&:active > hr': {
|
48
48
|
backgroundColor: theme.palette.info.main,
|
49
|
-
opacity:
|
49
|
+
opacity:
|
50
|
+
header.subHeaders.length || columnResizeMode === 'onEnd' ? 1 : 0,
|
50
51
|
},
|
51
52
|
cursor: 'col-resize',
|
52
53
|
mr:
|
@@ -73,7 +73,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
73
73
|
enableTopToolbar = true,
|
74
74
|
filterFns,
|
75
75
|
icons,
|
76
|
-
layoutMode
|
76
|
+
layoutMode,
|
77
77
|
localization,
|
78
78
|
manualFiltering,
|
79
79
|
manualGrouping,
|
@@ -118,13 +118,13 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
118
118
|
[defaultDisplayColumn],
|
119
119
|
);
|
120
120
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
121
|
+
layoutMode =
|
122
|
+
layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
|
123
|
+
if (
|
124
|
+
layoutMode === 'semantic' &&
|
125
|
+
(rest.enableRowVirtualization || rest.enableColumnVirtualization)
|
126
|
+
) {
|
127
|
+
layoutMode = 'grid';
|
128
128
|
}
|
129
129
|
|
130
130
|
if (rest.enableRowVirtualization) {
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -65,7 +65,9 @@ export const MRT_Table = <TData extends MRT_RowData>({
|
|
65
65
|
const colSizes: { [key: string]: number } = {};
|
66
66
|
for (let i = 0; i < headers.length; i++) {
|
67
67
|
const header = headers[i];
|
68
|
-
|
68
|
+
let colSize = header.getSize();
|
69
|
+
if (header.subHeaders?.length)
|
70
|
+
colSize = colSize * 1.05 + header.subHeaders.length * 2;
|
69
71
|
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
70
72
|
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
71
73
|
}
|
package/src/types.ts
CHANGED
@@ -714,7 +714,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
714
714
|
}) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>)
|
715
715
|
| Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>;
|
716
716
|
/**
|
717
|
-
* The columns to display in the table. `accessorKey`s or `accessorFn`s must match keys in the `data`
|
717
|
+
* The columns to display in the table. `accessorKey`s or `accessorFn`s must match keys in the `data` table option.
|
718
718
|
*
|
719
719
|
* See more info on creating columns on the official docs site:
|
720
720
|
* @link https://www.material-react-table.com/docs/guides/data-columns
|
@@ -733,7 +733,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
733
733
|
*/
|
734
734
|
data: TData[];
|
735
735
|
/**
|
736
|
-
* Instead of specifying a bunch of the same options for each column, you can just change an option in the `defaultColumn`
|
736
|
+
* Instead of specifying a bunch of the same options for each column, you can just change an option in the `defaultColumn` table option to change a default option for all columns.
|
737
737
|
*/
|
738
738
|
defaultColumn?: Partial<MRT_ColumnDef<TData>>;
|
739
739
|
/**
|