material-react-table 0.30.2 → 0.32.0-alpha.1
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/README.md +3 -4
- package/dist/{MaterialReactTable.d.ts → cjs/MaterialReactTable.d.ts} +494 -473
- package/dist/{body → cjs/body}/MRT_TableBody.d.ts +8 -8
- package/dist/{body → cjs/body}/MRT_TableBodyCell.d.ts +11 -11
- package/dist/{body → cjs/body}/MRT_TableBodyRow.d.ts +9 -9
- package/dist/{body → cjs/body}/MRT_TableBodyRowGrabHandle.d.ts +9 -9
- package/dist/{body → cjs/body}/MRT_TableDetailPanel.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_ColumnPinningButtons.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_CopyButton.d.ts +9 -9
- package/dist/{buttons → cjs/buttons}/MRT_EditActionButtons.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_ExpandAllButton.d.ts +7 -7
- package/dist/{buttons → cjs/buttons}/MRT_ExpandButton.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_FullScreenToggleButton.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_GrabHandleButton.d.ts +11 -11
- package/dist/{buttons → cjs/buttons}/MRT_ShowHideColumnsButton.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_ToggleDensePaddingButton.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_ToggleFiltersButton.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_ToggleGlobalFilterButton.d.ts +8 -8
- package/dist/{buttons → cjs/buttons}/MRT_ToggleRowActionMenuButton.d.ts +8 -8
- package/dist/{column.utils.d.ts → cjs/column.utils.d.ts} +12 -11
- package/dist/{filtersFns.d.ts → cjs/filtersFns.d.ts} +68 -68
- package/dist/{footer → cjs/footer}/MRT_TableFooter.d.ts +7 -7
- package/dist/{footer → cjs/footer}/MRT_TableFooterCell.d.ts +8 -8
- package/dist/{footer → cjs/footer}/MRT_TableFooterRow.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHead.d.ts +7 -7
- package/dist/{head → cjs/head}/MRT_TableHeadCell.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHeadCellColumnActionsButton.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHeadCellFilterContainer.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHeadCellFilterLabel.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHeadCellGrabHandle.d.ts +9 -9
- package/dist/{head → cjs/head}/MRT_TableHeadCellResizeHandle.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHeadCellSortLabel.d.ts +8 -8
- package/dist/{head → cjs/head}/MRT_TableHeadRow.d.ts +8 -8
- package/dist/{icons.d.ts → cjs/icons.d.ts} +33 -33
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +7467 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/index.min.js +51 -0
- package/dist/cjs/index.min.js.map +1 -0
- package/dist/{inputs → cjs/inputs}/MRT_EditCellTextField.d.ts +8 -8
- package/dist/{inputs → cjs/inputs}/MRT_FilterRangeFields.d.ts +8 -8
- package/dist/{inputs → cjs/inputs}/MRT_FilterTextField.d.ts +9 -9
- package/dist/{inputs → cjs/inputs}/MRT_GlobalFilterTextField.d.ts +7 -7
- package/dist/{inputs → cjs/inputs}/MRT_SelectCheckbox.d.ts +9 -9
- package/dist/{localization.d.ts → cjs/localization.d.ts} +82 -81
- package/dist/{menus → cjs/menus}/MRT_ColumnActionMenu.d.ts +20 -20
- package/dist/{menus → cjs/menus}/MRT_FilterOptionMenu.d.ts +18 -18
- package/dist/{menus → cjs/menus}/MRT_RowActionMenu.d.ts +11 -11
- package/dist/{menus → cjs/menus}/MRT_ShowHideColumnsMenu.d.ts +10 -10
- package/dist/{menus → cjs/menus}/MRT_ShowHideColumnsMenuItems.d.ts +12 -12
- package/dist/{sortingFns.d.ts → cjs/sortingFns.d.ts} +12 -12
- package/dist/{table → cjs/table}/MRT_Table.d.ts +8 -8
- package/dist/{table → cjs/table}/MRT_TableContainer.d.ts +7 -7
- package/dist/{table → cjs/table}/MRT_TablePaper.d.ts +7 -7
- package/dist/{table → cjs/table}/MRT_TableRoot.d.ts +3 -3
- package/dist/{toolbar → cjs/toolbar}/MRT_LinearProgressBar.d.ts +8 -8
- package/dist/{toolbar → cjs/toolbar}/MRT_TablePagination.d.ts +8 -8
- package/dist/{toolbar → cjs/toolbar}/MRT_ToolbarAlertBanner.d.ts +8 -8
- package/dist/{toolbar → cjs/toolbar}/MRT_ToolbarBottom.d.ts +7 -7
- package/dist/cjs/toolbar/MRT_ToolbarDropZone.d.ts +7 -0
- package/dist/{toolbar → cjs/toolbar}/MRT_ToolbarInternalButtons.d.ts +7 -7
- package/dist/{toolbar → cjs/toolbar}/MRT_ToolbarTop.d.ts +21 -21
- package/dist/esm/MaterialReactTable.d.ts +494 -0
- package/dist/esm/body/MRT_TableBody.d.ts +8 -0
- package/dist/esm/body/MRT_TableBodyCell.d.ts +11 -0
- package/dist/esm/body/MRT_TableBodyRow.d.ts +9 -0
- package/dist/esm/body/MRT_TableBodyRowGrabHandle.d.ts +9 -0
- package/dist/esm/body/MRT_TableDetailPanel.d.ts +8 -0
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +8 -0
- package/dist/esm/buttons/MRT_CopyButton.d.ts +9 -0
- package/dist/esm/buttons/MRT_EditActionButtons.d.ts +8 -0
- package/dist/esm/buttons/MRT_ExpandAllButton.d.ts +7 -0
- package/dist/esm/buttons/MRT_ExpandButton.d.ts +8 -0
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +8 -0
- package/dist/esm/buttons/MRT_GrabHandleButton.d.ts +11 -0
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +8 -0
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +8 -0
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +8 -0
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +8 -0
- package/dist/esm/buttons/MRT_ToggleRowActionMenuButton.d.ts +8 -0
- package/dist/esm/column.utils.d.ts +12 -0
- package/dist/esm/filtersFns.d.ts +68 -0
- package/dist/esm/footer/MRT_TableFooter.d.ts +7 -0
- package/dist/esm/footer/MRT_TableFooterCell.d.ts +8 -0
- package/dist/esm/footer/MRT_TableFooterRow.d.ts +8 -0
- package/dist/esm/head/MRT_TableHead.d.ts +7 -0
- package/dist/esm/head/MRT_TableHeadCell.d.ts +8 -0
- package/dist/esm/head/MRT_TableHeadCellColumnActionsButton.d.ts +8 -0
- package/dist/esm/head/MRT_TableHeadCellFilterContainer.d.ts +8 -0
- package/dist/esm/head/MRT_TableHeadCellFilterLabel.d.ts +8 -0
- package/dist/esm/head/MRT_TableHeadCellGrabHandle.d.ts +9 -0
- package/dist/esm/head/MRT_TableHeadCellResizeHandle.d.ts +8 -0
- package/dist/esm/head/MRT_TableHeadCellSortLabel.d.ts +8 -0
- package/dist/esm/head/MRT_TableHeadRow.d.ts +8 -0
- package/dist/esm/icons.d.ts +33 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/inputs/MRT_EditCellTextField.d.ts +8 -0
- package/dist/esm/inputs/MRT_FilterRangeFields.d.ts +8 -0
- package/dist/esm/inputs/MRT_FilterTextField.d.ts +9 -0
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +7 -0
- package/dist/esm/inputs/MRT_SelectCheckbox.d.ts +9 -0
- package/dist/esm/localization.d.ts +82 -0
- package/dist/esm/material-react-table.esm.js +7443 -0
- package/dist/esm/material-react-table.esm.js.map +1 -0
- package/dist/esm/material-react-table.esm.min.js +51 -0
- package/dist/esm/material-react-table.esm.min.js.map +1 -0
- package/dist/esm/menus/MRT_ColumnActionMenu.d.ts +20 -0
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +18 -0
- package/dist/esm/menus/MRT_RowActionMenu.d.ts +11 -0
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +10 -0
- package/dist/esm/menus/MRT_ShowHideColumnsMenuItems.d.ts +12 -0
- package/dist/esm/sortingFns.d.ts +12 -0
- package/dist/esm/table/MRT_Table.d.ts +8 -0
- package/dist/esm/table/MRT_TableContainer.d.ts +7 -0
- package/dist/esm/table/MRT_TablePaper.d.ts +7 -0
- package/dist/esm/table/MRT_TableRoot.d.ts +3 -0
- package/dist/esm/toolbar/MRT_LinearProgressBar.d.ts +8 -0
- package/dist/esm/toolbar/MRT_TablePagination.d.ts +8 -0
- package/dist/esm/toolbar/MRT_ToolbarAlertBanner.d.ts +8 -0
- package/dist/esm/toolbar/MRT_ToolbarBottom.d.ts +7 -0
- package/dist/esm/toolbar/MRT_ToolbarDropZone.d.ts +7 -0
- package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +7 -0
- package/dist/esm/toolbar/MRT_ToolbarTop.d.ts +21 -0
- package/dist/index.d.ts +686 -7
- package/package.json +24 -25
- package/src/MaterialReactTable.tsx +31 -11
- package/src/body/MRT_TableBodyCell.tsx +10 -3
- package/src/column.utils.ts +20 -0
- package/src/footer/MRT_TableFooterCell.tsx +1 -0
- package/src/head/MRT_TableHeadCell.tsx +7 -3
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +6 -2
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +1 -1
- package/src/localization.ts +2 -0
- package/src/table/MRT_TableRoot.tsx +9 -23
- package/src/toolbar/MRT_ToolbarBottom.tsx +5 -0
- package/src/toolbar/MRT_ToolbarDropZone.tsx +54 -0
- package/src/toolbar/MRT_ToolbarTop.tsx +5 -0
- package/dist/index.js +0 -8
- package/dist/material-react-table.cjs.development.js +0 -3929
- package/dist/material-react-table.cjs.development.js.map +0 -1
- package/dist/material-react-table.cjs.production.min.js +0 -2
- package/dist/material-react-table.cjs.production.min.js.map +0 -1
- package/dist/material-react-table.esm.js +0 -3922
- package/dist/material-react-table.esm.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.32.0-alpha.1",
|
|
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.",
|
|
@@ -19,50 +19,46 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/KevinVandy/material-react-table/issues"
|
|
21
21
|
},
|
|
22
|
-
"main": "dist/index.js",
|
|
23
|
-
"module": "dist/material-react-table.esm.js",
|
|
22
|
+
"main": "dist/cjs/index.min.js",
|
|
23
|
+
"module": "dist/esm/material-react-table.esm.min.js",
|
|
24
24
|
"typings": "dist/index.d.ts",
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
27
|
"src"
|
|
28
28
|
],
|
|
29
|
+
"size-limit": [
|
|
30
|
+
{
|
|
31
|
+
"path": "dist/cjs/index.min.js",
|
|
32
|
+
"limit": "50 KB"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"path": "dist/esm/material-react-table.esm.min.js",
|
|
36
|
+
"limit": "50 KB"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
29
39
|
"engines": {
|
|
30
40
|
"node": ">=14"
|
|
31
41
|
},
|
|
32
42
|
"scripts": {
|
|
33
43
|
"analyze": "size-limit --why",
|
|
34
|
-
"build": "
|
|
44
|
+
"build": "rm -rf dist && rollup -c && size-limit && rm -rf material-react-table-docs/node_modules/material-react-table/dist && cp -r dist material-react-table-docs/node_modules/material-react-table/",
|
|
35
45
|
"build-storybook": "build-storybook",
|
|
36
46
|
"format": "prettier -w .",
|
|
37
47
|
"lint": "eslint .",
|
|
38
|
-
"prepare": "tsdx build",
|
|
39
48
|
"size": "size-limit",
|
|
40
|
-
"
|
|
41
|
-
"storybook": "start-storybook -p 6006",
|
|
42
|
-
"test": "tsdx test --passWithNoTests"
|
|
43
|
-
},
|
|
44
|
-
"husky": {
|
|
45
|
-
"hooks": {
|
|
46
|
-
"pre-commit": "tsdx lint && format"
|
|
47
|
-
}
|
|
49
|
+
"storybook": "start-storybook -p 6006"
|
|
48
50
|
},
|
|
49
|
-
"size-limit": [
|
|
50
|
-
{
|
|
51
|
-
"path": "dist/material-react-table.cjs.production.min.js",
|
|
52
|
-
"limit": "40 KB"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"path": "dist/material-react-table.esm.js",
|
|
56
|
-
"limit": "40 KB"
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
51
|
"devDependencies": {
|
|
60
52
|
"@babel/core": "^7.18.9",
|
|
53
|
+
"@babel/preset-react": "^7.18.6",
|
|
61
54
|
"@emotion/react": "^11.9.3",
|
|
62
55
|
"@emotion/styled": "^11.9.3",
|
|
63
56
|
"@faker-js/faker": "^7.3.0",
|
|
64
57
|
"@mui/icons-material": "^5.8.4",
|
|
65
58
|
"@mui/material": "^5.9.2",
|
|
59
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
60
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
61
|
+
"@rollup/plugin-typescript": "^8.3.4",
|
|
66
62
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
67
63
|
"@storybook/addon-a11y": "^6.5.9",
|
|
68
64
|
"@storybook/addon-actions": "^6.5.9",
|
|
@@ -82,9 +78,12 @@
|
|
|
82
78
|
"react": "^18.2.0",
|
|
83
79
|
"react-dom": "^18.2.0",
|
|
84
80
|
"react-is": "^18.2.0",
|
|
81
|
+
"rollup": "^2.77.2",
|
|
82
|
+
"rollup-plugin-dts": "^4.2.2",
|
|
83
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
84
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
85
85
|
"size-limit": "^7.0.8",
|
|
86
86
|
"storybook-dark-mode": "^1.1.0",
|
|
87
|
-
"tsdx": "^0.14.1",
|
|
88
87
|
"tslib": "^2.4.0",
|
|
89
88
|
"typescript": "^4.7.4"
|
|
90
89
|
},
|
|
@@ -98,6 +97,6 @@
|
|
|
98
97
|
"dependencies": {
|
|
99
98
|
"@tanstack/match-sorter-utils": "8.1.1",
|
|
100
99
|
"@tanstack/react-table": "8.5.2",
|
|
101
|
-
"@tanstack/react-virtual": "^3.0.0-beta.
|
|
100
|
+
"@tanstack/react-virtual": "^3.0.0-beta.14"
|
|
102
101
|
}
|
|
103
102
|
}
|
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
Cell,
|
|
31
31
|
Column,
|
|
32
32
|
ColumnDef,
|
|
33
|
+
CoreColumnDefAccessorKey,
|
|
33
34
|
FilterFn,
|
|
34
35
|
Header,
|
|
35
36
|
HeaderGroup,
|
|
@@ -104,8 +105,12 @@ export type MRT_TableInstance<TData extends Record<string, any> = {}> = Omit<
|
|
|
104
105
|
}>
|
|
105
106
|
>;
|
|
106
107
|
setCurrentGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
|
|
107
|
-
setCurrentHoveredColumn: Dispatch<
|
|
108
|
-
|
|
108
|
+
setCurrentHoveredColumn: Dispatch<
|
|
109
|
+
SetStateAction<MRT_Column<TData> | { id: string } | null>
|
|
110
|
+
>;
|
|
111
|
+
setCurrentHoveredRow: Dispatch<
|
|
112
|
+
SetStateAction<MRT_Row<TData> | { id: string } | null>
|
|
113
|
+
>;
|
|
109
114
|
setDensity: Dispatch<SetStateAction<'comfortable' | 'compact' | 'spacious'>>;
|
|
110
115
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
111
116
|
setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
|
|
@@ -121,8 +126,8 @@ export type MRT_TableState<TData extends Record<string, any> = {}> =
|
|
|
121
126
|
currentEditingRow: MRT_Row<TData> | null;
|
|
122
127
|
currentFilterFns: Record<string, MRT_FilterOption>;
|
|
123
128
|
currentGlobalFilterFn: Record<string, MRT_FilterOption>;
|
|
124
|
-
currentHoveredColumn: MRT_Column<TData> | null;
|
|
125
|
-
currentHoveredRow: MRT_Row<TData> | null;
|
|
129
|
+
currentHoveredColumn: MRT_Column<TData> | { id: string } | null;
|
|
130
|
+
currentHoveredRow: MRT_Row<TData> | { id: string } | null;
|
|
126
131
|
density: 'comfortable' | 'compact' | 'spacious';
|
|
127
132
|
isFullScreen: boolean;
|
|
128
133
|
isLoading: boolean;
|
|
@@ -135,8 +140,6 @@ export type MRT_TableState<TData extends Record<string, any> = {}> =
|
|
|
135
140
|
|
|
136
141
|
export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
137
142
|
ColumnDef<TData, unknown>,
|
|
138
|
-
| 'accessorFn'
|
|
139
|
-
| 'accessorKey'
|
|
140
143
|
| 'aggregatedCell'
|
|
141
144
|
| 'cell'
|
|
142
145
|
| 'columns'
|
|
@@ -148,47 +151,59 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
148
151
|
> & {
|
|
149
152
|
AggregatedCell?: ({
|
|
150
153
|
cell,
|
|
154
|
+
column,
|
|
151
155
|
table,
|
|
152
156
|
}: {
|
|
153
157
|
cell: MRT_Cell<TData>;
|
|
158
|
+
column: MRT_Column<TData>;
|
|
154
159
|
table: MRT_TableInstance<TData>;
|
|
155
160
|
}) => ReactNode;
|
|
156
161
|
Cell?: ({
|
|
157
162
|
cell,
|
|
163
|
+
column,
|
|
158
164
|
table,
|
|
159
165
|
}: {
|
|
160
166
|
cell: MRT_Cell<TData>;
|
|
167
|
+
column: MRT_Column<TData>;
|
|
161
168
|
table: MRT_TableInstance<TData>;
|
|
162
169
|
}) => ReactNode;
|
|
163
170
|
Edit?: ({
|
|
164
171
|
cell,
|
|
172
|
+
column,
|
|
165
173
|
table,
|
|
166
174
|
}: {
|
|
167
175
|
cell: MRT_Cell<TData>;
|
|
176
|
+
column: MRT_Column<TData>;
|
|
168
177
|
table: MRT_TableInstance<TData>;
|
|
169
178
|
}) => ReactNode;
|
|
170
179
|
Filter?: ({
|
|
180
|
+
column,
|
|
171
181
|
header,
|
|
172
182
|
table,
|
|
173
183
|
}: {
|
|
184
|
+
column: MRT_Column<TData>;
|
|
174
185
|
header: MRT_Header<TData>;
|
|
175
186
|
table: MRT_TableInstance<TData>;
|
|
176
187
|
}) => ReactNode;
|
|
177
188
|
Footer?:
|
|
178
189
|
| ReactNode
|
|
179
190
|
| (({
|
|
191
|
+
column,
|
|
180
192
|
footer,
|
|
181
193
|
table,
|
|
182
194
|
}: {
|
|
195
|
+
column: MRT_Column<TData>;
|
|
183
196
|
footer: MRT_Header<TData>;
|
|
184
197
|
table: MRT_TableInstance<TData>;
|
|
185
198
|
}) => ReactNode);
|
|
186
199
|
Header?:
|
|
187
200
|
| ReactNode
|
|
188
201
|
| (({
|
|
202
|
+
column,
|
|
189
203
|
header,
|
|
190
204
|
table,
|
|
191
205
|
}: {
|
|
206
|
+
column: MRT_Column<TData>;
|
|
192
207
|
header: MRT_Header<TData>;
|
|
193
208
|
table: MRT_TableInstance<TData>;
|
|
194
209
|
}) => ReactNode);
|
|
@@ -202,10 +217,12 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
202
217
|
/**
|
|
203
218
|
* Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
|
|
204
219
|
* Specify which key in the row this column should use to access the correct data.
|
|
220
|
+
* Also supports Deep Key Dot Notation.
|
|
205
221
|
*
|
|
206
|
-
* @example accessorKey: 'username'
|
|
222
|
+
* @example accessorKey: 'username' //simple
|
|
223
|
+
* @example accessorKey: 'name.firstName' //deep key dot notation
|
|
207
224
|
*/
|
|
208
|
-
accessorKey?:
|
|
225
|
+
accessorKey?: CoreColumnDefAccessorKey<TData, unknown>['accessorKey'];
|
|
209
226
|
/**
|
|
210
227
|
* Specify what type of column this is. Either `data`, `display`, or `group`. Defaults to `data`.
|
|
211
228
|
* Leave this blank if you are just creating a normal data column.
|
|
@@ -689,7 +706,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
689
706
|
}: {
|
|
690
707
|
event: DragEvent<HTMLButtonElement>;
|
|
691
708
|
draggedColumn: MRT_Column<TData>;
|
|
692
|
-
targetColumn: MRT_Column<TData> | null;
|
|
709
|
+
targetColumn: MRT_Column<TData> | { id: string } | null;
|
|
693
710
|
}) => void;
|
|
694
711
|
onCurrentDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
695
712
|
onCurrentDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
@@ -715,7 +732,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
715
732
|
}: {
|
|
716
733
|
event: DragEvent<HTMLButtonElement>;
|
|
717
734
|
draggedRow: MRT_Row<TData>;
|
|
718
|
-
targetRow: MRT_Row<TData> | null;
|
|
735
|
+
targetRow: MRT_Row<TData> | { id: string } | null;
|
|
719
736
|
}) => void;
|
|
720
737
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
|
721
738
|
onShowFiltersChange?: OnChangeFn<boolean>;
|
|
@@ -725,7 +742,8 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
725
742
|
positionExpandColumn?: 'first' | 'last';
|
|
726
743
|
positionGlobalFilter?: 'left' | 'right';
|
|
727
744
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
728
|
-
positionToolbarAlertBanner?: 'bottom' | 'top';
|
|
745
|
+
positionToolbarAlertBanner?: 'bottom' | 'top' | 'none';
|
|
746
|
+
positionToolbarDropZone?: 'bottom' | 'top' | 'none' | 'both';
|
|
729
747
|
renderDetailPanel?: ({
|
|
730
748
|
row,
|
|
731
749
|
table,
|
|
@@ -833,6 +851,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
833
851
|
positionGlobalFilter = 'right',
|
|
834
852
|
positionPagination = 'bottom',
|
|
835
853
|
positionToolbarAlertBanner = 'top',
|
|
854
|
+
positionToolbarDropZone = 'top',
|
|
836
855
|
rowNumberMode = 'original',
|
|
837
856
|
selectAllMode = 'all',
|
|
838
857
|
...rest
|
|
@@ -876,6 +895,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
876
895
|
positionGlobalFilter={positionGlobalFilter}
|
|
877
896
|
positionPagination={positionPagination}
|
|
878
897
|
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
|
898
|
+
positionToolbarDropZone={positionToolbarDropZone}
|
|
879
899
|
rowNumberMode={rowNumberMode}
|
|
880
900
|
selectAllMode={selectAllMode}
|
|
881
901
|
{...rest}
|
|
@@ -35,6 +35,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
35
35
|
enableClickToCopy,
|
|
36
36
|
enableColumnOrdering,
|
|
37
37
|
enableEditing,
|
|
38
|
+
enableGrouping,
|
|
38
39
|
enablePagination,
|
|
39
40
|
enableRowNumbers,
|
|
40
41
|
muiTableBodyCellProps,
|
|
@@ -129,6 +130,9 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
129
130
|
};
|
|
130
131
|
|
|
131
132
|
const handleDragEnter = (_e: DragEvent) => {
|
|
133
|
+
if (enableGrouping && currentHoveredColumn?.id === 'drop-zone') {
|
|
134
|
+
setCurrentHoveredColumn(null);
|
|
135
|
+
}
|
|
132
136
|
if (enableColumnOrdering && currentDraggingColumn) {
|
|
133
137
|
setCurrentHoveredColumn(
|
|
134
138
|
columnDef.enableColumnOrdering !== false ? column : null,
|
|
@@ -258,20 +262,23 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
258
262
|
table={table}
|
|
259
263
|
/>
|
|
260
264
|
) : columnDefType === 'display' ? (
|
|
261
|
-
columnDef.Cell?.({ cell, table })
|
|
265
|
+
columnDef.Cell?.({ cell, column, table })
|
|
262
266
|
) : isEditing ? (
|
|
263
267
|
<MRT_EditCellTextField cell={cell} table={table} />
|
|
264
268
|
) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
265
269
|
columnDef.enableClickToCopy !== false ? (
|
|
266
270
|
<>
|
|
267
271
|
<MRT_CopyButton cell={cell} table={table}>
|
|
268
|
-
<>
|
|
272
|
+
<>
|
|
273
|
+
{columnDef?.Cell?.({ cell, column, table }) ??
|
|
274
|
+
cell.renderValue()}
|
|
275
|
+
</>
|
|
269
276
|
</MRT_CopyButton>
|
|
270
277
|
{cell.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
271
278
|
</>
|
|
272
279
|
) : (
|
|
273
280
|
<>
|
|
274
|
-
{columnDef?.Cell?.({ cell, table }) ?? cell.renderValue()}
|
|
281
|
+
{columnDef?.Cell?.({ cell, column, table }) ?? cell.renderValue()}
|
|
275
282
|
{cell.getIsGrouped() && <> ({row.subRows?.length ?? ''})</>}
|
|
276
283
|
</>
|
|
277
284
|
)}
|
package/src/column.utils.ts
CHANGED
|
@@ -10,6 +10,21 @@ import {
|
|
|
10
10
|
import { MRT_FilterFns } from './filtersFns';
|
|
11
11
|
import { MRT_SortingFns } from './sortingFns';
|
|
12
12
|
|
|
13
|
+
export const defaultDisplayColumnDefOptions = {
|
|
14
|
+
columnDefType: 'display',
|
|
15
|
+
enableClickToCopy: false,
|
|
16
|
+
enableColumnActions: false,
|
|
17
|
+
enableColumnDragging: false,
|
|
18
|
+
enableColumnFilter: false,
|
|
19
|
+
enableColumnOrdering: false,
|
|
20
|
+
enableEditing: false,
|
|
21
|
+
enableGlobalFilter: false,
|
|
22
|
+
enableGrouping: false,
|
|
23
|
+
enableHiding: false,
|
|
24
|
+
enableResizing: false,
|
|
25
|
+
enableSorting: false,
|
|
26
|
+
} as Partial<MRT_ColumnDef>;
|
|
27
|
+
|
|
13
28
|
const getColumnId = <TData extends Record<string, any> = {}>(
|
|
14
29
|
columnDef: MRT_ColumnDef<TData>,
|
|
15
30
|
): string =>
|
|
@@ -60,6 +75,11 @@ export const prepareColumns = <TData extends Record<string, any> = {}>(
|
|
|
60
75
|
// @ts-ignore
|
|
61
76
|
columnDef.sortingFn = MRT_SortingFns[columnDef.sortingFn];
|
|
62
77
|
}
|
|
78
|
+
} else if (columnDef.columnDefType === 'display') {
|
|
79
|
+
columnDef = {
|
|
80
|
+
...columnDef,
|
|
81
|
+
...(defaultDisplayColumnDefOptions as MRT_ColumnDef<TData>),
|
|
82
|
+
};
|
|
63
83
|
}
|
|
64
84
|
return columnDef;
|
|
65
85
|
}) as MRT_DefinedColumnDef<TData>[];
|
|
@@ -71,6 +71,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const handleDragEnter = (_e: DragEvent) => {
|
|
74
|
+
if (enableGrouping && currentHoveredColumn?.id === 'drop-zone') {
|
|
75
|
+
setCurrentHoveredColumn(null);
|
|
76
|
+
}
|
|
74
77
|
if (enableColumnOrdering && currentDraggingColumn) {
|
|
75
78
|
setCurrentHoveredColumn(
|
|
76
79
|
columnDef.enableColumnOrdering !== false ? column : null,
|
|
@@ -95,6 +98,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
95
98
|
|
|
96
99
|
const headerElement = ((columnDef?.Header instanceof Function
|
|
97
100
|
? columnDef?.Header?.({
|
|
101
|
+
column,
|
|
98
102
|
header,
|
|
99
103
|
table,
|
|
100
104
|
})
|
|
@@ -144,9 +148,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
144
148
|
pb:
|
|
145
149
|
columnDefType === 'display'
|
|
146
150
|
? 0
|
|
147
|
-
: showColumnFilters
|
|
148
|
-
? '0.
|
|
149
|
-
:
|
|
151
|
+
: showColumnFilters || density === 'compact'
|
|
152
|
+
? '0.4rem'
|
|
153
|
+
: '0.6rem',
|
|
150
154
|
position:
|
|
151
155
|
column.getIsPinned() && columnDefType !== 'group'
|
|
152
156
|
? 'sticky'
|
|
@@ -55,12 +55,16 @@ export const MRT_TableHeadCellGrabHandle: FC<Props> = ({
|
|
|
55
55
|
draggedColumn: column,
|
|
56
56
|
targetColumn: currentHoveredColumn,
|
|
57
57
|
});
|
|
58
|
-
if (
|
|
58
|
+
if (currentHoveredColumn?.id === 'drop-zone') {
|
|
59
|
+
column.toggleGrouping();
|
|
60
|
+
} else if (
|
|
59
61
|
enableColumnOrdering &&
|
|
60
62
|
currentHoveredColumn &&
|
|
61
63
|
currentHoveredColumn?.id !== currentDraggingColumn?.id
|
|
62
64
|
) {
|
|
63
|
-
setColumnOrder(
|
|
65
|
+
setColumnOrder(
|
|
66
|
+
reorderColumn(column, currentHoveredColumn as MRT_Column, columnOrder),
|
|
67
|
+
);
|
|
64
68
|
}
|
|
65
69
|
setCurrentDraggingColumn(null);
|
|
66
70
|
setCurrentHoveredColumn(null);
|
|
@@ -67,7 +67,7 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell, table }) => {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
if (enableEditing && columnDef.enableEditing !== false && columnDef.Edit) {
|
|
70
|
-
return <>{columnDef.Edit?.({ cell, table })}</>;
|
|
70
|
+
return <>{columnDef.Edit?.({ cell, column, table })}</>;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return (
|
package/src/localization.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface MRT_Localization {
|
|
|
10
10
|
clickToCopy: string;
|
|
11
11
|
columnActions: string;
|
|
12
12
|
copiedToClipboard: string;
|
|
13
|
+
dropToGroupBy: string;
|
|
13
14
|
edit: string;
|
|
14
15
|
expand: string;
|
|
15
16
|
expandAll: string;
|
|
@@ -91,6 +92,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
91
92
|
clickToCopy: 'Click to copy',
|
|
92
93
|
columnActions: 'Column Actions',
|
|
93
94
|
copiedToClipboard: 'Copied to clipboard',
|
|
95
|
+
dropToGroupBy: 'Drop to group by {column}',
|
|
94
96
|
edit: 'Edit',
|
|
95
97
|
expand: 'Expand',
|
|
96
98
|
expandAll: 'Expand all',
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
getAllLeafColumnDefs,
|
|
22
22
|
getDefaultColumnOrderIds,
|
|
23
23
|
getDefaultColumnFilterFn,
|
|
24
|
+
defaultDisplayColumnDefOptions,
|
|
24
25
|
} from '../column.utils';
|
|
25
26
|
import { MRT_FilterFns } from '../filtersFns';
|
|
26
27
|
import type {
|
|
@@ -34,22 +35,6 @@ import type {
|
|
|
34
35
|
MaterialReactTableProps,
|
|
35
36
|
} from '..';
|
|
36
37
|
|
|
37
|
-
const defaultDisplayColumnDefOptions = {
|
|
38
|
-
columnDefType: 'display',
|
|
39
|
-
enableClickToCopy: false,
|
|
40
|
-
enableColumnActions: false,
|
|
41
|
-
enableColumnDragging: false,
|
|
42
|
-
enableColumnFilter: false,
|
|
43
|
-
enableColumnOrdering: false,
|
|
44
|
-
enableEditing: false,
|
|
45
|
-
enableGlobalFilter: false,
|
|
46
|
-
enableGrouping: false,
|
|
47
|
-
enableHiding: false,
|
|
48
|
-
enablePinning: false,
|
|
49
|
-
enableResizing: false,
|
|
50
|
-
enableSorting: false,
|
|
51
|
-
} as Partial<MRT_ColumnDef>;
|
|
52
|
-
|
|
53
38
|
export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
54
39
|
props: MaterialReactTableProps<TData>,
|
|
55
40
|
) => {
|
|
@@ -80,12 +65,12 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
80
65
|
useState<MRT_Cell<TData> | null>(initialState.currentEditingCell ?? null);
|
|
81
66
|
const [currentEditingRow, setCurrentEditingRow] =
|
|
82
67
|
useState<MRT_Row<TData> | null>(initialState.currentEditingRow ?? null);
|
|
83
|
-
const [currentHoveredColumn, setCurrentHoveredColumn] =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
const [currentHoveredColumn, setCurrentHoveredColumn] = useState<
|
|
69
|
+
MRT_Column<TData> | { id: string } | null
|
|
70
|
+
>(initialState.currentHoveredColumn ?? null);
|
|
71
|
+
const [currentHoveredRow, setCurrentHoveredRow] = useState<
|
|
72
|
+
MRT_Row<TData> | { id: string } | null
|
|
73
|
+
>(initialState.currentHoveredRow ?? null);
|
|
89
74
|
const [density, setDensity] = useState(
|
|
90
75
|
initialState?.density ?? 'comfortable',
|
|
91
76
|
);
|
|
@@ -248,11 +233,12 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
248
233
|
getPaginationRowModel: getPaginationRowModel(),
|
|
249
234
|
getSortedRowModel: getSortedRowModel(),
|
|
250
235
|
onColumnOrderChange: setColumnOrder,
|
|
236
|
+
getSubRows: (row) => row?.subRows,
|
|
251
237
|
...props,
|
|
252
238
|
//@ts-ignore
|
|
253
239
|
columns: columnDefs,
|
|
254
240
|
data,
|
|
255
|
-
|
|
241
|
+
|
|
256
242
|
globalFilterFn:
|
|
257
243
|
//@ts-ignore
|
|
258
244
|
MRT_FilterFns[currentGlobalFilterFn] ?? MRT_FilterFns.fuzzy,
|
|
@@ -5,6 +5,7 @@ import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
|
5
5
|
import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
6
6
|
import { commonToolbarStyles } from './MRT_ToolbarTop';
|
|
7
7
|
import { MRT_TableInstance } from '..';
|
|
8
|
+
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
10
11
|
table: MRT_TableInstance;
|
|
@@ -18,6 +19,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ table }) => {
|
|
|
18
19
|
muiTableToolbarBottomProps,
|
|
19
20
|
positionPagination,
|
|
20
21
|
positionToolbarAlertBanner,
|
|
22
|
+
positionToolbarDropZone,
|
|
21
23
|
renderToolbarBottomCustomActions,
|
|
22
24
|
tableId,
|
|
23
25
|
},
|
|
@@ -56,6 +58,9 @@ export const MRT_ToolbarBottom: FC<Props> = ({ table }) => {
|
|
|
56
58
|
{positionToolbarAlertBanner === 'bottom' && (
|
|
57
59
|
<MRT_ToolbarAlertBanner table={table} />
|
|
58
60
|
)}
|
|
61
|
+
{['both', 'bottom'].includes(positionToolbarDropZone ?? '') && (
|
|
62
|
+
<MRT_ToolbarDropZone table={table} />
|
|
63
|
+
)}
|
|
59
64
|
<Box
|
|
60
65
|
sx={{
|
|
61
66
|
display: 'flex',
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { DragEvent, FC } from 'react';
|
|
2
|
+
import { alpha, Box, Fade, Typography } from '@mui/material';
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
table: MRT_TableInstance;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const MRT_ToolbarDropZone: FC<Props> = ({ table }) => {
|
|
10
|
+
const {
|
|
11
|
+
getState,
|
|
12
|
+
options: { enableGrouping, localization },
|
|
13
|
+
setCurrentHoveredColumn,
|
|
14
|
+
} = table;
|
|
15
|
+
|
|
16
|
+
const { currentDraggingColumn, currentHoveredColumn } = getState();
|
|
17
|
+
|
|
18
|
+
const handleDragEnter = (_event: DragEvent<HTMLDivElement>) => {
|
|
19
|
+
setCurrentHoveredColumn({ id: 'drop-zone' });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Fade
|
|
24
|
+
unmountOnExit
|
|
25
|
+
mountOnEnter
|
|
26
|
+
in={!!enableGrouping && !!currentDraggingColumn}
|
|
27
|
+
>
|
|
28
|
+
<Box
|
|
29
|
+
sx={(theme) => ({
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
backgroundColor: alpha(
|
|
32
|
+
theme.palette.info.main,
|
|
33
|
+
currentHoveredColumn?.id === 'drop-zone' ? 0.2 : 0.1,
|
|
34
|
+
),
|
|
35
|
+
border: `dashed ${theme.palette.info.main} 2px`,
|
|
36
|
+
display: 'flex',
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
height: 'calc(100% - 4px)',
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
width: 'calc(100% - 4px)',
|
|
41
|
+
zIndex: 2,
|
|
42
|
+
})}
|
|
43
|
+
onDragEnter={handleDragEnter}
|
|
44
|
+
>
|
|
45
|
+
<Typography>
|
|
46
|
+
{localization.dropToGroupBy.replace(
|
|
47
|
+
'{column}',
|
|
48
|
+
currentDraggingColumn?.columnDef?.header ?? '',
|
|
49
|
+
)}
|
|
50
|
+
</Typography>
|
|
51
|
+
</Box>
|
|
52
|
+
</Fade>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
@@ -6,6 +6,7 @@ import { MRT_TableInstance } from '..';
|
|
|
6
6
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
7
7
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
8
8
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
9
|
+
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
|
9
10
|
|
|
10
11
|
export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
|
|
11
12
|
alignItems: 'flex-start',
|
|
@@ -34,6 +35,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ table }) => {
|
|
|
34
35
|
positionGlobalFilter,
|
|
35
36
|
positionPagination,
|
|
36
37
|
positionToolbarAlertBanner,
|
|
38
|
+
positionToolbarDropZone,
|
|
37
39
|
renderToolbarTopCustomActions,
|
|
38
40
|
tableId,
|
|
39
41
|
},
|
|
@@ -73,6 +75,9 @@ export const MRT_ToolbarTop: FC<Props> = ({ table }) => {
|
|
|
73
75
|
table={table}
|
|
74
76
|
/>
|
|
75
77
|
)}
|
|
78
|
+
{['both', 'top'].includes(positionToolbarDropZone ?? '') && (
|
|
79
|
+
<MRT_ToolbarDropZone table={table} />
|
|
80
|
+
)}
|
|
76
81
|
<Box
|
|
77
82
|
sx={{
|
|
78
83
|
alignItems: 'flex-start',
|