material-react-table 2.6.1 → 2.8.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 +390 -260
- package/dist/index.esm.js +1977 -1921
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2372 -2318
- package/dist/index.js.map +1 -1
- package/package.json +20 -20
- package/src/{MaterialReactTable.tsx → components/MaterialReactTable.tsx} +3 -3
- package/src/{body → components/body}/MRT_TableBody.tsx +6 -28
- package/src/{body → components/body}/MRT_TableBodyCell.tsx +6 -23
- package/src/{body → components/body}/MRT_TableBodyCellValue.tsx +2 -2
- package/src/{body → components/body}/MRT_TableBodyRow.tsx +7 -5
- package/src/{body → components/body}/MRT_TableBodyRowGrabHandle.tsx +3 -3
- package/src/{body → components/body}/MRT_TableBodyRowPinButton.tsx +3 -3
- package/src/{body → components/body}/MRT_TableDetailPanel.tsx +6 -6
- package/src/{buttons → components/buttons}/MRT_ColumnPinningButtons.tsx +2 -2
- package/src/{buttons → components/buttons}/MRT_CopyButton.tsx +4 -5
- package/src/{buttons → components/buttons}/MRT_EditActionButtons.tsx +2 -2
- package/src/{buttons → components/buttons}/MRT_ExpandAllButton.tsx +4 -4
- package/src/{buttons → components/buttons}/MRT_ExpandButton.tsx +10 -4
- package/src/{buttons → components/buttons}/MRT_GrabHandleButton.tsx +4 -5
- package/src/{buttons → components/buttons}/MRT_RowPinButton.tsx +4 -4
- package/src/{buttons → components/buttons}/MRT_ShowHideColumnsButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleDensePaddingButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleFiltersButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleFullScreenButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleGlobalFilterButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleRowActionMenuButton.tsx +9 -9
- package/src/{footer → components/footer}/MRT_TableFooter.tsx +2 -2
- package/src/{footer → components/footer}/MRT_TableFooterCell.tsx +3 -3
- package/src/{footer → components/footer}/MRT_TableFooterRow.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHead.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHeadCell.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHeadCellColumnActionsButton.tsx +5 -6
- package/src/{head → components/head}/MRT_TableHeadCellFilterContainer.tsx +5 -5
- package/src/{head → components/head}/MRT_TableHeadCellFilterLabel.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadCellGrabHandle.tsx +4 -3
- package/src/{head → components/head}/MRT_TableHeadCellResizeHandle.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadCellSortLabel.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadRow.tsx +3 -3
- package/src/{inputs → components/inputs}/MRT_EditCellTextField.tsx +12 -4
- package/src/{inputs → components/inputs}/MRT_FilterCheckbox.tsx +4 -4
- package/src/{inputs → components/inputs}/MRT_FilterRangeFields.tsx +2 -2
- package/src/{inputs → components/inputs}/MRT_FilterRangeSlider.tsx +2 -2
- package/src/{inputs → components/inputs}/MRT_FilterTextField.tsx +3 -3
- package/src/{inputs → components/inputs}/MRT_GlobalFilterTextField.tsx +2 -2
- package/src/{inputs → components/inputs}/MRT_SelectCheckbox.tsx +4 -4
- package/src/{menus → components/menus}/MRT_ColumnActionMenu.tsx +9 -1
- package/src/{menus → components/menus}/MRT_FilterOptionMenu.tsx +9 -1
- package/src/{menus → components/menus}/MRT_RowActionMenu.tsx +13 -2
- package/src/{menus → components/menus}/MRT_ShowHideColumnsMenu.tsx +11 -5
- package/src/{menus → components/menus}/MRT_ShowHideColumnsMenuItems.tsx +7 -7
- package/src/{modals → components/modals}/MRT_EditRowModal.tsx +4 -4
- package/src/{table → components/table}/MRT_Table.tsx +4 -4
- package/src/{table → components/table}/MRT_TableContainer.tsx +3 -3
- package/src/{table → components/table}/MRT_TableLoadingOverlay.tsx +3 -3
- package/src/{table → components/table}/MRT_TablePaper.tsx +3 -3
- package/src/{toolbar → components/toolbar}/MRT_BottomToolbar.tsx +3 -3
- package/src/{toolbar → components/toolbar}/MRT_LinearProgressBar.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_TablePagination.tsx +9 -7
- package/src/{toolbar → components/toolbar}/MRT_ToolbarAlertBanner.tsx +3 -3
- package/src/{toolbar → components/toolbar}/MRT_ToolbarDropZone.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_ToolbarInternalButtons.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_TopToolbar.tsx +3 -3
- package/src/{filterFns.ts → fns/filterFns.ts} +1 -1
- package/src/{sortingFns.ts → fns/sortingFns.ts} +1 -1
- package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +26 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +34 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +35 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +96 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +36 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +40 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +40 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +2 -4
- package/src/hooks/useMRT_Effects.ts +7 -6
- package/src/hooks/useMRT_RowVirtualizer.ts +2 -4
- package/src/hooks/useMRT_Rows.ts +32 -6
- package/src/hooks/useMRT_TableInstance.ts +91 -87
- package/src/hooks/useMRT_TableOptions.ts +5 -3
- package/src/{useMaterialReactTable.ts → hooks/useMaterialReactTable.ts} +3 -3
- package/src/icons.ts +4 -38
- package/src/index.ts +88 -17
- package/src/types.ts +59 -26
- package/src/utils/column.utils.ts +173 -0
- package/src/utils/displayColumn.utils.ts +134 -0
- package/src/utils/row.utils.ts +26 -0
- package/src/{style.utils.ts → utils/style.utils.ts} +50 -28
- package/src/utils/tanstack.helpers.ts +64 -0
- package/src/utils/utils.ts +23 -0
- package/src/utils/virtualization.utils.ts +19 -0
- package/src/utils.ts +0 -0
- package/src/body/index.ts +0 -7
- package/src/buttons/index.ts +0 -13
- package/src/column.utils.ts +0 -368
- package/src/footer/index.ts +0 -3
- package/src/head/index.ts +0 -9
- package/src/hooks/index.ts +0 -7
- package/src/hooks/useMRT_DisplayColumns.tsx +0 -299
- package/src/inputs/index.ts +0 -7
- package/src/menus/index.ts +0 -5
- package/src/modals/index.ts +0 -1
- package/src/table/index.ts +0 -5
- package/src/toolbar/index.ts +0 -7
- /package/src/{aggregationFns.ts → fns/aggregationFns.ts} +0 -0
package/src/hooks/useMRT_Rows.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
|
-
import {
|
3
|
-
import { rankGlobalFuzzy } from '../sortingFns';
|
2
|
+
import { rankGlobalFuzzy } from '../fns/sortingFns';
|
4
3
|
import {
|
5
4
|
type MRT_Row,
|
6
5
|
type MRT_RowData,
|
7
6
|
type MRT_TableInstance,
|
8
7
|
} from '../types';
|
8
|
+
import { getCanRankRows } from '../utils/row.utils';
|
9
9
|
|
10
10
|
export const useMRT_Rows = <TData extends MRT_RowData>(
|
11
11
|
table: MRT_TableInstance<TData>,
|
@@ -19,6 +19,7 @@ export const useMRT_Rows = <TData extends MRT_RowData>(
|
|
19
19
|
getState,
|
20
20
|
getTopRows,
|
21
21
|
options: {
|
22
|
+
createDisplayMode,
|
22
23
|
enableGlobalFilterRankedResults,
|
23
24
|
enablePagination,
|
24
25
|
enableRowPinning,
|
@@ -27,11 +28,18 @@ export const useMRT_Rows = <TData extends MRT_RowData>(
|
|
27
28
|
manualGrouping,
|
28
29
|
manualPagination,
|
29
30
|
manualSorting,
|
31
|
+
positionCreatingRow,
|
30
32
|
rowPinningDisplayMode,
|
31
33
|
},
|
32
34
|
} = table;
|
33
|
-
const {
|
34
|
-
|
35
|
+
const {
|
36
|
+
creatingRow,
|
37
|
+
expanded,
|
38
|
+
globalFilter,
|
39
|
+
pagination,
|
40
|
+
rowPinning,
|
41
|
+
sorting,
|
42
|
+
} = getState();
|
35
43
|
|
36
44
|
const shouldRankRows = useMemo(
|
37
45
|
() =>
|
@@ -73,14 +81,32 @@ export const useMRT_Rows = <TData extends MRT_RowData>(
|
|
73
81
|
...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
74
82
|
];
|
75
83
|
}
|
84
|
+
if (
|
85
|
+
positionCreatingRow !== undefined &&
|
86
|
+
creatingRow &&
|
87
|
+
createDisplayMode === 'row'
|
88
|
+
) {
|
89
|
+
const creatingRowIndex = !isNaN(+positionCreatingRow)
|
90
|
+
? +positionCreatingRow
|
91
|
+
: positionCreatingRow === 'top'
|
92
|
+
? 0
|
93
|
+
: rows.length;
|
94
|
+
rows = [
|
95
|
+
...rows.slice(0, creatingRowIndex),
|
96
|
+
creatingRow,
|
97
|
+
...rows.slice(creatingRowIndex),
|
98
|
+
];
|
99
|
+
}
|
76
100
|
|
77
101
|
return rows;
|
78
102
|
}, [
|
79
|
-
|
80
|
-
shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
|
103
|
+
creatingRow,
|
81
104
|
pagination.pageIndex,
|
82
105
|
pagination.pageSize,
|
106
|
+
positionCreatingRow,
|
83
107
|
rowPinning,
|
108
|
+
shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
|
109
|
+
shouldRankRows,
|
84
110
|
]);
|
85
111
|
|
86
112
|
return rows;
|
@@ -11,38 +11,39 @@ import {
|
|
11
11
|
getSortedRowModel,
|
12
12
|
useReactTable,
|
13
13
|
} from '@tanstack/react-table';
|
14
|
-
import {
|
15
|
-
createRow,
|
16
|
-
getAllLeafColumnDefs,
|
17
|
-
getColumnId,
|
18
|
-
getDefaultColumnFilterFn,
|
19
|
-
getDefaultColumnOrderIds,
|
20
|
-
prepareColumns,
|
21
|
-
} from '../column.utils';
|
22
14
|
import {
|
23
15
|
type MRT_Cell,
|
24
16
|
type MRT_Column,
|
25
17
|
type MRT_ColumnDef,
|
26
18
|
type MRT_ColumnFilterFnsState,
|
27
19
|
type MRT_ColumnOrderState,
|
20
|
+
type MRT_ColumnSizingInfoState,
|
28
21
|
type MRT_DefinedTableOptions,
|
29
22
|
type MRT_DensityState,
|
30
23
|
type MRT_FilterOption,
|
31
24
|
type MRT_GroupingState,
|
25
|
+
type MRT_PaginationState,
|
32
26
|
type MRT_Row,
|
33
27
|
type MRT_RowData,
|
28
|
+
type MRT_StatefulTableOptions,
|
34
29
|
type MRT_TableInstance,
|
35
30
|
type MRT_TableState,
|
36
31
|
type MRT_Updater,
|
37
32
|
} from '../types';
|
38
|
-
import {
|
33
|
+
import {
|
34
|
+
getAllLeafColumnDefs,
|
35
|
+
getColumnId,
|
36
|
+
getDefaultColumnFilterFn,
|
37
|
+
prepareColumns,
|
38
|
+
} from '../utils/column.utils';
|
39
|
+
import { getDefaultColumnOrderIds } from '../utils/displayColumn.utils';
|
40
|
+
import { createRow } from '../utils/tanstack.helpers';
|
41
|
+
import { getMRT_DisplayColumns } from './display-columns/getMRT_DisplayColumns';
|
39
42
|
import { useMRT_Effects } from './useMRT_Effects';
|
40
43
|
|
41
|
-
export const useMRT_TableInstance
|
42
|
-
|
43
|
-
)
|
44
|
-
tableOptions: MRT_DefinedTableOptions<TData>,
|
45
|
-
) => {
|
44
|
+
export const useMRT_TableInstance = <TData extends MRT_RowData>(
|
45
|
+
_tableOptions: MRT_DefinedTableOptions<TData>,
|
46
|
+
): MRT_TableInstance<TData> => {
|
46
47
|
const bottomToolbarRef = useRef<HTMLDivElement>(null);
|
47
48
|
const editInputRefs = useRef<Record<string, HTMLInputElement>>({});
|
48
49
|
const filterInputRefs = useRef<Record<string, HTMLInputElement>>({});
|
@@ -55,13 +56,19 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
55
56
|
const tableFooterRef = useRef<HTMLTableSectionElement>(null);
|
56
57
|
|
57
58
|
const initialState: Partial<MRT_TableState<TData>> = useMemo(() => {
|
58
|
-
const initState =
|
59
|
+
const initState = _tableOptions.initialState ?? {};
|
59
60
|
initState.columnOrder =
|
60
|
-
initState.columnOrder ??
|
61
|
-
|
61
|
+
initState.columnOrder ??
|
62
|
+
getDefaultColumnOrderIds({
|
63
|
+
..._tableOptions,
|
64
|
+
state: { ..._tableOptions.initialState, ..._tableOptions.state },
|
65
|
+
} as MRT_StatefulTableOptions<TData>);
|
66
|
+
initState.globalFilterFn = _tableOptions.globalFilterFn ?? 'fuzzy';
|
62
67
|
return initState;
|
63
68
|
}, []);
|
64
69
|
|
70
|
+
_tableOptions.initialState = initialState;
|
71
|
+
|
65
72
|
const [creatingRow, _setCreatingRow] = useState<MRT_Row<TData> | null>(
|
66
73
|
initialState.creatingRow ?? null,
|
67
74
|
);
|
@@ -70,7 +77,7 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
70
77
|
Object.assign(
|
71
78
|
{},
|
72
79
|
...getAllLeafColumnDefs(
|
73
|
-
|
80
|
+
_tableOptions.columns as MRT_ColumnDef<TData>[],
|
74
81
|
).map((col) => ({
|
75
82
|
[getColumnId(col)]:
|
76
83
|
col.filterFn instanceof Function
|
@@ -81,9 +88,13 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
81
88
|
})),
|
82
89
|
),
|
83
90
|
);
|
84
|
-
const [columnOrder,
|
91
|
+
const [columnOrder, onColumnOrderChange] = useState<MRT_ColumnOrderState>(
|
85
92
|
initialState.columnOrder ?? [],
|
86
93
|
);
|
94
|
+
const [columnSizingInfo, onColumnSizingInfoChange] =
|
95
|
+
useState<MRT_ColumnSizingInfoState>(
|
96
|
+
initialState.columnSizingInfo ?? ({} as MRT_ColumnSizingInfoState),
|
97
|
+
);
|
87
98
|
const [density, setDensity] = useState<MRT_DensityState>(
|
88
99
|
initialState?.density ?? 'comfortable',
|
89
100
|
);
|
@@ -101,7 +112,7 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
101
112
|
const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
|
102
113
|
initialState.globalFilterFn ?? 'fuzzy',
|
103
114
|
);
|
104
|
-
const [grouping,
|
115
|
+
const [grouping, onGroupingChange] = useState<MRT_GroupingState>(
|
105
116
|
initialState.grouping ?? [],
|
106
117
|
);
|
107
118
|
const [hoveredColumn, setHoveredColumn] = useState<Partial<
|
@@ -113,8 +124,11 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
113
124
|
const [isFullScreen, setIsFullScreen] = useState<boolean>(
|
114
125
|
initialState?.isFullScreen ?? false,
|
115
126
|
);
|
127
|
+
const [pagination, onPaginationChange] = useState<MRT_PaginationState>(
|
128
|
+
initialState?.pagination ?? { pageIndex: 0, pageSize: 10 },
|
129
|
+
);
|
116
130
|
const [showAlertBanner, setShowAlertBanner] = useState<boolean>(
|
117
|
-
|
131
|
+
initialState?.showAlertBanner ?? false,
|
118
132
|
);
|
119
133
|
const [showColumnFilters, setShowColumnFilters] = useState<boolean>(
|
120
134
|
initialState?.showColumnFilters ?? false,
|
@@ -126,41 +140,55 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
126
140
|
initialState?.showToolbarDropZone ?? false,
|
127
141
|
);
|
128
142
|
|
129
|
-
|
143
|
+
_tableOptions.state = {
|
144
|
+
columnFilterFns,
|
130
145
|
columnOrder,
|
146
|
+
columnSizingInfo,
|
131
147
|
creatingRow,
|
148
|
+
density,
|
149
|
+
draggingColumn,
|
150
|
+
draggingRow,
|
151
|
+
editingCell,
|
152
|
+
editingRow,
|
153
|
+
globalFilterFn,
|
132
154
|
grouping,
|
133
|
-
|
134
|
-
|
155
|
+
hoveredColumn,
|
156
|
+
hoveredRow,
|
157
|
+
isFullScreen,
|
158
|
+
pagination,
|
159
|
+
showAlertBanner,
|
160
|
+
showColumnFilters,
|
161
|
+
showGlobalFilter,
|
162
|
+
showToolbarDropZone,
|
163
|
+
..._tableOptions.state,
|
164
|
+
};
|
135
165
|
|
136
|
-
const
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
166
|
+
const tableOptions = _tableOptions as MRT_StatefulTableOptions<TData>;
|
167
|
+
|
168
|
+
//don't recompute columnDefs while resizing column or dragging column/row
|
169
|
+
const columnDefsRef = useRef<MRT_ColumnDef<TData>[]>([]);
|
170
|
+
tableOptions.columns =
|
171
|
+
tableOptions.state.columnSizingInfo.isResizingColumn ||
|
172
|
+
tableOptions.state.draggingColumn ||
|
173
|
+
tableOptions.state.draggingRow
|
174
|
+
? columnDefsRef.current
|
175
|
+
: prepareColumns({
|
176
|
+
columnDefs: [
|
177
|
+
...getMRT_DisplayColumns(tableOptions),
|
178
|
+
...tableOptions.columns,
|
179
|
+
],
|
180
|
+
tableOptions,
|
181
|
+
});
|
182
|
+
columnDefsRef.current = tableOptions.columns;
|
153
183
|
|
154
|
-
|
184
|
+
tableOptions.data = useMemo(
|
155
185
|
() =>
|
156
|
-
(tableOptions.state
|
186
|
+
(tableOptions.state.isLoading || tableOptions.state.showSkeletons) &&
|
157
187
|
!tableOptions.data.length
|
158
188
|
? [
|
159
|
-
...Array(
|
160
|
-
|
161
|
-
|
162
|
-
10,
|
163
|
-
).fill(null),
|
189
|
+
...Array(Math.min(tableOptions.state.pagination.pageSize, 20)).fill(
|
190
|
+
null,
|
191
|
+
),
|
164
192
|
].map(() =>
|
165
193
|
Object.assign(
|
166
194
|
{},
|
@@ -172,8 +200,8 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
172
200
|
: tableOptions.data,
|
173
201
|
[
|
174
202
|
tableOptions.data,
|
175
|
-
tableOptions.state
|
176
|
-
tableOptions.state
|
203
|
+
tableOptions.state.isLoading,
|
204
|
+
tableOptions.state.showSkeletons,
|
177
205
|
],
|
178
206
|
);
|
179
207
|
|
@@ -209,58 +237,36 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
209
237
|
? getSortedRowModel()
|
210
238
|
: undefined,
|
211
239
|
getSubRows: (row) => row?.subRows,
|
212
|
-
onColumnOrderChange
|
213
|
-
|
240
|
+
onColumnOrderChange,
|
241
|
+
onColumnSizingInfoChange,
|
242
|
+
onGroupingChange,
|
243
|
+
onPaginationChange,
|
214
244
|
...tableOptions,
|
215
|
-
//@ts-ignore
|
216
|
-
columns: columnDefs,
|
217
|
-
data,
|
218
245
|
globalFilterFn: tableOptions.filterFns?.[globalFilterFn ?? 'fuzzy'],
|
219
|
-
initialState,
|
220
|
-
state: {
|
221
|
-
columnFilterFns,
|
222
|
-
columnOrder,
|
223
|
-
creatingRow,
|
224
|
-
density,
|
225
|
-
draggingColumn,
|
226
|
-
draggingRow,
|
227
|
-
editingCell,
|
228
|
-
editingRow,
|
229
|
-
globalFilterFn,
|
230
|
-
grouping,
|
231
|
-
hoveredColumn,
|
232
|
-
hoveredRow,
|
233
|
-
isFullScreen,
|
234
|
-
showAlertBanner,
|
235
|
-
showColumnFilters,
|
236
|
-
showGlobalFilter,
|
237
|
-
showToolbarDropZone,
|
238
|
-
...tableOptions.state,
|
239
|
-
},
|
240
246
|
}) as MRT_TableInstance<TData>;
|
241
247
|
|
242
|
-
|
248
|
+
//@ts-ignore
|
243
249
|
table.refs = {
|
244
|
-
|
250
|
+
//@ts-ignore
|
245
251
|
bottomToolbarRef,
|
246
252
|
editInputRefs,
|
247
253
|
filterInputRefs,
|
248
|
-
|
254
|
+
//@ts-ignore
|
249
255
|
searchInputRef,
|
250
|
-
|
256
|
+
//@ts-ignore
|
251
257
|
tableContainerRef,
|
252
|
-
|
258
|
+
//@ts-ignore
|
253
259
|
tableFooterRef,
|
254
260
|
tableHeadCellRefs,
|
255
|
-
|
261
|
+
//@ts-ignore
|
256
262
|
tableHeadRef,
|
257
|
-
|
263
|
+
//@ts-ignore
|
258
264
|
tablePaperRef,
|
259
|
-
|
265
|
+
//@ts-ignore
|
260
266
|
topToolbarRef,
|
261
267
|
};
|
262
268
|
|
263
|
-
|
269
|
+
table.setCreatingRow = (row: MRT_Updater<MRT_Row<TData> | null | true>) => {
|
264
270
|
let _row = row;
|
265
271
|
if (row === true) {
|
266
272
|
_row = createRow(table);
|
@@ -268,8 +274,6 @@ export const useMRT_TableInstance: <TData extends MRT_RowData>(
|
|
268
274
|
tableOptions?.onCreatingRowChange?.(_row as MRT_Row<TData> | null) ??
|
269
275
|
_setCreatingRow(_row as MRT_Row<TData> | null);
|
270
276
|
};
|
271
|
-
|
272
|
-
table.setCreatingRow = setCreatingRow;
|
273
277
|
table.setColumnFilterFns =
|
274
278
|
tableOptions.onColumnFilterFnsChange ?? setColumnFilterFns;
|
275
279
|
table.setDensity = tableOptions.onDensityChange ?? setDensity;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
import { useTheme } from '@mui/material/styles';
|
3
|
-
import { MRT_AggregationFns } from '../aggregationFns';
|
4
|
-
import { MRT_FilterFns } from '../filterFns';
|
3
|
+
import { MRT_AggregationFns } from '../fns/aggregationFns';
|
4
|
+
import { MRT_FilterFns } from '../fns/filterFns';
|
5
|
+
import { MRT_SortingFns } from '../fns/sortingFns';
|
5
6
|
import { MRT_Default_Icons } from '../icons';
|
6
7
|
import { MRT_Localization_EN } from '../locales/en';
|
7
|
-
import { MRT_SortingFns } from '../sortingFns';
|
8
8
|
import {
|
9
9
|
type MRT_DefinedTableOptions,
|
10
10
|
type MRT_RowData,
|
@@ -83,6 +83,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
83
83
|
manualSorting,
|
84
84
|
paginationDisplayMode = 'default',
|
85
85
|
positionActionsColumn = 'first',
|
86
|
+
positionCreatingRow = 'top',
|
86
87
|
positionExpandColumn = 'first',
|
87
88
|
positionGlobalFilter = 'right',
|
88
89
|
positionPagination = 'bottom',
|
@@ -197,6 +198,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
197
198
|
manualSorting,
|
198
199
|
paginationDisplayMode,
|
199
200
|
positionActionsColumn,
|
201
|
+
positionCreatingRow,
|
200
202
|
positionExpandColumn,
|
201
203
|
positionGlobalFilter,
|
202
204
|
positionPagination,
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { useMRT_TableInstance } from './hooks/useMRT_TableInstance';
|
2
|
-
import { useMRT_TableOptions } from './hooks/useMRT_TableOptions';
|
3
1
|
import {
|
4
2
|
type MRT_RowData,
|
5
3
|
type MRT_TableInstance,
|
6
4
|
type MRT_TableOptions,
|
7
|
-
} from '
|
5
|
+
} from '../types';
|
6
|
+
import { useMRT_TableInstance } from './useMRT_TableInstance';
|
7
|
+
import { useMRT_TableOptions } from './useMRT_TableOptions';
|
8
8
|
|
9
9
|
export const useMaterialReactTable = <TData extends MRT_RowData>(
|
10
10
|
tableOptions: MRT_TableOptions<TData>,
|
package/src/icons.ts
CHANGED
@@ -32,43 +32,7 @@ import SyncAltIcon from '@mui/icons-material/SyncAlt';
|
|
32
32
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
33
33
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
34
34
|
|
35
|
-
export
|
36
|
-
ArrowDownwardIcon: any;
|
37
|
-
ArrowRightIcon: any;
|
38
|
-
CancelIcon: any;
|
39
|
-
ChevronLeftIcon: any;
|
40
|
-
ChevronRightIcon: any;
|
41
|
-
ClearAllIcon: any;
|
42
|
-
CloseIcon: any;
|
43
|
-
DensityLargeIcon: any;
|
44
|
-
DensityMediumIcon: any;
|
45
|
-
DensitySmallIcon: any;
|
46
|
-
DragHandleIcon: any;
|
47
|
-
DynamicFeedIcon: any;
|
48
|
-
EditIcon: any;
|
49
|
-
ExpandMoreIcon: any;
|
50
|
-
FilterAltIcon: any;
|
51
|
-
FilterListIcon: any;
|
52
|
-
FilterListOffIcon: any;
|
53
|
-
FirstPageIcon?: any;
|
54
|
-
FullscreenExitIcon: any;
|
55
|
-
FullscreenIcon: any;
|
56
|
-
KeyboardDoubleArrowDownIcon: any;
|
57
|
-
LastPageIcon?: any;
|
58
|
-
MoreHorizIcon: any;
|
59
|
-
MoreVertIcon: any;
|
60
|
-
PushPinIcon: any;
|
61
|
-
RestartAltIcon: any;
|
62
|
-
SaveIcon: any;
|
63
|
-
SearchIcon: any;
|
64
|
-
SearchOffIcon: any;
|
65
|
-
SortIcon: any;
|
66
|
-
SyncAltIcon?: any;
|
67
|
-
ViewColumnIcon: any;
|
68
|
-
VisibilityOffIcon: any;
|
69
|
-
}
|
70
|
-
|
71
|
-
export const MRT_Default_Icons: MRT_Icons = {
|
35
|
+
export const MRT_Default_Icons = {
|
72
36
|
ArrowDownwardIcon,
|
73
37
|
ArrowRightIcon,
|
74
38
|
CancelIcon,
|
@@ -102,4 +66,6 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
102
66
|
SyncAltIcon,
|
103
67
|
ViewColumnIcon,
|
104
68
|
VisibilityOffIcon,
|
105
|
-
};
|
69
|
+
} as const;
|
70
|
+
|
71
|
+
export type MRT_Icons = Record<keyof typeof MRT_Default_Icons, any>;
|
package/src/index.ts
CHANGED
@@ -1,18 +1,89 @@
|
|
1
|
-
export * from './MaterialReactTable';
|
2
|
-
export * from './aggregationFns';
|
3
|
-
export * from './body';
|
4
|
-
export * from './buttons';
|
5
|
-
export * from './column.utils';
|
6
|
-
export * from './filterFns';
|
7
|
-
export * from './footer';
|
8
|
-
export * from './head';
|
9
|
-
export * from './hooks';
|
10
|
-
export * from './inputs';
|
11
|
-
export * from './menus';
|
12
|
-
export * from './modals';
|
13
|
-
export * from './sortingFns';
|
14
|
-
export * from './style.utils';
|
15
|
-
export * from './table';
|
16
|
-
export * from './toolbar';
|
17
1
|
export * from './types';
|
18
|
-
|
2
|
+
|
3
|
+
//helpers
|
4
|
+
export * from './utils/tanstack.helpers';
|
5
|
+
export * from './utils/column.utils';
|
6
|
+
export * from './utils/displayColumn.utils';
|
7
|
+
export * from './utils/row.utils';
|
8
|
+
|
9
|
+
//fns
|
10
|
+
export * from './fns/aggregationFns';
|
11
|
+
export * from './fns/filterFns';
|
12
|
+
export * from './fns/sortingFns';
|
13
|
+
|
14
|
+
//hooks
|
15
|
+
export * from './hooks/useMaterialReactTable';
|
16
|
+
export * from './hooks/useMRT_ColumnVirtualizer';
|
17
|
+
export * from './hooks/useMRT_Effects';
|
18
|
+
export * from './hooks/useMRT_RowVirtualizer';
|
19
|
+
export * from './hooks/useMRT_Rows';
|
20
|
+
export * from './hooks/useMRT_TableInstance';
|
21
|
+
export * from './hooks/useMRT_TableOptions';
|
22
|
+
|
23
|
+
//components
|
24
|
+
export * from './components/MaterialReactTable';
|
25
|
+
//body components
|
26
|
+
export * from './components/body/MRT_TableBody';
|
27
|
+
export * from './components/body/MRT_TableBodyCell';
|
28
|
+
export * from './components/body/MRT_TableBodyCellValue';
|
29
|
+
export * from './components/body/MRT_TableBodyRow';
|
30
|
+
export * from './components/body/MRT_TableBodyRowGrabHandle';
|
31
|
+
export * from './components/body/MRT_TableBodyRowPinButton';
|
32
|
+
export * from './components/body/MRT_TableDetailPanel';
|
33
|
+
//button components
|
34
|
+
export * from './components/buttons/MRT_ColumnPinningButtons';
|
35
|
+
export * from './components/buttons/MRT_CopyButton';
|
36
|
+
export * from './components/buttons/MRT_EditActionButtons';
|
37
|
+
export * from './components/buttons/MRT_ExpandAllButton';
|
38
|
+
export * from './components/buttons/MRT_ExpandButton';
|
39
|
+
export * from './components/buttons/MRT_GrabHandleButton';
|
40
|
+
export * from './components/buttons/MRT_RowPinButton';
|
41
|
+
export * from './components/buttons/MRT_ShowHideColumnsButton';
|
42
|
+
export * from './components/buttons/MRT_ToggleDensePaddingButton';
|
43
|
+
export * from './components/buttons/MRT_ToggleFiltersButton';
|
44
|
+
export * from './components/buttons/MRT_ToggleFullScreenButton';
|
45
|
+
export * from './components/buttons/MRT_ToggleGlobalFilterButton';
|
46
|
+
export * from './components/buttons/MRT_ToggleRowActionMenuButton';
|
47
|
+
//footer components
|
48
|
+
export * from './components/footer/MRT_TableFooter';
|
49
|
+
export * from './components/footer/MRT_TableFooterCell';
|
50
|
+
export * from './components/footer/MRT_TableFooterRow';
|
51
|
+
//head components
|
52
|
+
export * from './components/head/MRT_TableHead';
|
53
|
+
export * from './components/head/MRT_TableHeadCell';
|
54
|
+
export * from './components/head/MRT_TableHeadCellColumnActionsButton';
|
55
|
+
export * from './components/head/MRT_TableHeadCellFilterContainer';
|
56
|
+
export * from './components/head/MRT_TableHeadCellFilterLabel';
|
57
|
+
export * from './components/head/MRT_TableHeadCellGrabHandle';
|
58
|
+
export * from './components/head/MRT_TableHeadCellResizeHandle';
|
59
|
+
export * from './components/head/MRT_TableHeadCellSortLabel';
|
60
|
+
export * from './components/head/MRT_TableHeadRow';
|
61
|
+
//input components
|
62
|
+
export * from './components/inputs/MRT_EditCellTextField';
|
63
|
+
export * from './components/inputs/MRT_FilterCheckbox';
|
64
|
+
export * from './components/inputs/MRT_FilterRangeFields';
|
65
|
+
export * from './components/inputs/MRT_FilterRangeSlider';
|
66
|
+
export * from './components/inputs/MRT_FilterTextField';
|
67
|
+
export * from './components/inputs/MRT_GlobalFilterTextField';
|
68
|
+
export * from './components/inputs/MRT_SelectCheckbox';
|
69
|
+
//menu components
|
70
|
+
export * from './components/menus/MRT_ColumnActionMenu';
|
71
|
+
export * from './components/menus/MRT_FilterOptionMenu';
|
72
|
+
export * from './components/menus/MRT_RowActionMenu';
|
73
|
+
export * from './components/menus/MRT_ShowHideColumnsMenu';
|
74
|
+
export * from './components/menus/MRT_ShowHideColumnsMenuItems';
|
75
|
+
//modal components
|
76
|
+
export * from './components/modals/MRT_EditRowModal';
|
77
|
+
//table components
|
78
|
+
export * from './components/table/MRT_Table';
|
79
|
+
export * from './components/table/MRT_TableContainer';
|
80
|
+
export * from './components/table/MRT_TableLoadingOverlay';
|
81
|
+
export * from './components/table/MRT_TablePaper';
|
82
|
+
//toolbar components
|
83
|
+
export * from './components/toolbar/MRT_BottomToolbar';
|
84
|
+
export * from './components/toolbar/MRT_LinearProgressBar';
|
85
|
+
export * from './components/toolbar/MRT_TablePagination';
|
86
|
+
export * from './components/toolbar/MRT_ToolbarAlertBanner';
|
87
|
+
export * from './components/toolbar/MRT_ToolbarDropZone';
|
88
|
+
export * from './components/toolbar/MRT_ToolbarInternalButtons';
|
89
|
+
export * from './components/toolbar/MRT_TopToolbar';
|