material-react-table 1.0.11 → 1.1.0-beta.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/dist/cjs/MaterialReactTable.d.ts +12 -5
- package/dist/cjs/_locales/ja.d.ts +2 -0
- package/dist/cjs/body/MRT_TableBody.d.ts +2 -1
- package/dist/cjs/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/cjs/body/MRT_TableBodyRow.d.ts +2 -1
- package/dist/cjs/index.js +352 -323
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/table/MRT_TableRoot.d.ts +5 -4
- package/dist/esm/MaterialReactTable.d.ts +12 -5
- package/dist/esm/_locales/ja.d.ts +2 -0
- package/dist/esm/body/MRT_TableBody.d.ts +2 -1
- package/dist/esm/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/esm/body/MRT_TableBodyRow.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +353 -324
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/table/MRT_TableRoot.d.ts +5 -4
- package/dist/index.d.ts +44 -37
- package/locales/ja.d.ts +2 -0
- package/locales/ja.esm.d.ts +2 -0
- package/locales/ja.esm.js +92 -0
- package/locales/ja.esm.js.map +1 -0
- package/locales/ja.js +96 -0
- package/locales/ja.js.map +1 -0
- package/package.json +13 -13
- package/src/MaterialReactTable.tsx +15 -7
- package/src/_locales/ja.ts +92 -1
- package/src/body/MRT_TableBody.tsx +18 -12
- package/src/body/MRT_TableBodyCell.tsx +7 -1
- package/src/body/MRT_TableBodyRow.tsx +36 -15
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +1 -1
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/column.utils.ts +1 -1
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -7
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +3 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +51 -46
- package/src/table/MRT_Table.tsx +7 -2
- package/src/table/MRT_TablePaper.tsx +1 -1
- package/src/table/MRT_TableRoot.tsx +1 -1
- package/src/toolbar/MRT_TopToolbar.tsx +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, useLayoutEffect } from 'react';
|
|
1
|
+
import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, memo, useLayoutEffect } from 'react';
|
|
2
2
|
import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
3
|
-
import {
|
|
3
|
+
import { alpha, lighten, Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Radio, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, useMediaQuery, Toolbar, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
5
|
-
import {
|
|
5
|
+
import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
|
|
6
6
|
import { useVirtual } from 'react-virtual';
|
|
7
7
|
|
|
8
8
|
/******************************************************************************
|
|
@@ -34,37 +34,161 @@ function __rest(s, e) {
|
|
|
34
34
|
|
|
35
35
|
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
|
|
38
|
+
const getAllLeafColumnDefs = (columns) => {
|
|
39
|
+
const allLeafColumnDefs = [];
|
|
40
|
+
const getLeafColumns = (cols) => {
|
|
41
|
+
cols.forEach((col) => {
|
|
42
|
+
if (col.columns) {
|
|
43
|
+
getLeafColumns(col.columns);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
allLeafColumnDefs.push(col);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
getLeafColumns(columns);
|
|
51
|
+
return allLeafColumnDefs;
|
|
52
|
+
};
|
|
53
|
+
const prepareColumns = ({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if (!columnDef.id)
|
|
56
|
+
columnDef.id = getColumnId(columnDef);
|
|
57
|
+
if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
|
|
58
|
+
console.error('Column definitions must have a valid `accessorKey` or `id` property');
|
|
59
|
+
}
|
|
60
|
+
if (!columnDef.columnDefType)
|
|
61
|
+
columnDef.columnDefType = 'data';
|
|
62
|
+
if (!!((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
63
|
+
columnDef.columnDefType = 'group';
|
|
64
|
+
columnDef.columns = prepareColumns({
|
|
65
|
+
columnDefs: columnDef.columns,
|
|
66
|
+
columnFilterFns,
|
|
67
|
+
defaultDisplayColumn,
|
|
68
|
+
filterFns,
|
|
69
|
+
sortingFns,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else if (columnDef.columnDefType === 'data') {
|
|
73
|
+
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
74
|
+
columnDef.filterFn =
|
|
75
|
+
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
76
|
+
columnDef._filterFn =
|
|
77
|
+
columnFilterFns[columnDef.id];
|
|
78
|
+
}
|
|
79
|
+
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (columnDef.columnDefType === 'display') {
|
|
85
|
+
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
|
|
86
|
+
}
|
|
87
|
+
return columnDef;
|
|
88
|
+
});
|
|
89
|
+
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
90
|
+
if (draggedColumn.getCanPin()) {
|
|
91
|
+
draggedColumn.pin(targetColumn.getIsPinned());
|
|
92
|
+
}
|
|
93
|
+
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
94
|
+
return [...columnOrder];
|
|
95
|
+
};
|
|
96
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
97
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
98
|
+
props.renderDetailPanel);
|
|
99
|
+
const getLeadingDisplayColumnIds = (props) => {
|
|
100
|
+
var _a;
|
|
101
|
+
return [
|
|
102
|
+
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
103
|
+
props.positionActionsColumn === 'first' &&
|
|
104
|
+
(props.enableRowActions ||
|
|
105
|
+
(props.enableEditing &&
|
|
106
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
107
|
+
'mrt-row-actions',
|
|
108
|
+
props.positionExpandColumn === 'first' &&
|
|
109
|
+
showExpandColumn(props) &&
|
|
110
|
+
'mrt-row-expand',
|
|
111
|
+
props.enableRowSelection && 'mrt-row-select',
|
|
112
|
+
props.enableRowNumbers && 'mrt-row-numbers',
|
|
113
|
+
].filter(Boolean);
|
|
114
|
+
};
|
|
115
|
+
const getTrailingDisplayColumnIds = (props) => {
|
|
116
|
+
var _a;
|
|
117
|
+
return [
|
|
118
|
+
props.positionActionsColumn === 'last' &&
|
|
119
|
+
(props.enableRowActions ||
|
|
120
|
+
(props.enableEditing &&
|
|
121
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
122
|
+
'mrt-row-actions',
|
|
123
|
+
props.positionExpandColumn === 'last' &&
|
|
124
|
+
showExpandColumn(props) &&
|
|
125
|
+
'mrt-row-expand',
|
|
126
|
+
];
|
|
127
|
+
};
|
|
128
|
+
const getDefaultColumnOrderIds = (props) => [
|
|
129
|
+
...getLeadingDisplayColumnIds(props),
|
|
130
|
+
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
131
|
+
...getTrailingDisplayColumnIds(props),
|
|
132
|
+
].filter(Boolean);
|
|
133
|
+
const getDefaultColumnFilterFn = (columnDef) => {
|
|
134
|
+
if (columnDef.filterVariant === 'multi-select')
|
|
135
|
+
return 'arrIncludesSome';
|
|
136
|
+
if (columnDef.filterVariant === 'range')
|
|
137
|
+
return 'betweenInclusive';
|
|
138
|
+
if (columnDef.filterVariant === 'select' ||
|
|
139
|
+
columnDef.filterVariant === 'checkbox')
|
|
140
|
+
return 'equals';
|
|
141
|
+
return 'fuzzy';
|
|
142
|
+
};
|
|
143
|
+
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
144
|
+
return (column.getIsPinned() === 'left' &&
|
|
145
|
+
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
146
|
+
};
|
|
147
|
+
const getIsFirstRightPinnedColumn = (column) => {
|
|
148
|
+
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
149
|
+
};
|
|
150
|
+
const getTotalRight = (table, column) => {
|
|
151
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
152
|
+
};
|
|
153
|
+
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
154
|
+
var _a, _b, _c, _d;
|
|
155
|
+
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
156
|
+
? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
|
|
157
|
+
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
158
|
+
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
159
|
+
: getIsFirstRightPinnedColumn(column)
|
|
160
|
+
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
161
|
+
: undefined, left: column.getIsPinned() === 'left'
|
|
162
|
+
? `${column.getStart('left')}px`
|
|
163
|
+
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
164
|
+
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
165
|
+
? 0.5
|
|
166
|
+
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
167
|
+
? 'sticky'
|
|
168
|
+
: undefined, right: column.getIsPinned() === 'right'
|
|
169
|
+
? `${getTotalRight(table, column)}px`
|
|
170
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '150ms'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
171
|
+
? tableCellProps.sx(theme)
|
|
172
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
173
|
+
};
|
|
174
|
+
const MRT_DefaultColumn = {
|
|
175
|
+
minSize: 40,
|
|
176
|
+
maxSize: 1000,
|
|
177
|
+
size: 180,
|
|
178
|
+
};
|
|
179
|
+
const MRT_DefaultDisplayColumn = {
|
|
180
|
+
columnDefType: 'display',
|
|
181
|
+
enableClickToCopy: false,
|
|
182
|
+
enableColumnActions: false,
|
|
183
|
+
enableColumnDragging: false,
|
|
184
|
+
enableColumnFilter: false,
|
|
185
|
+
enableColumnOrdering: false,
|
|
186
|
+
enableEditing: false,
|
|
187
|
+
enableGlobalFilter: false,
|
|
188
|
+
enableGrouping: false,
|
|
189
|
+
enableHiding: false,
|
|
190
|
+
enableResizing: false,
|
|
191
|
+
enableSorting: false,
|
|
68
192
|
};
|
|
69
193
|
|
|
70
194
|
const fuzzy$1 = (row, columnId, filterValue, addMeta) => {
|
|
@@ -151,94 +275,37 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
|
151
275
|
notEquals,
|
|
152
276
|
startsWith });
|
|
153
277
|
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
filterIncludesString: 'Contains',
|
|
186
|
-
filterIncludesStringSensitive: 'Contains',
|
|
187
|
-
filterLessThan: 'Less Than',
|
|
188
|
-
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
189
|
-
filterMode: 'Filter Mode: {filterType}',
|
|
190
|
-
filterNotEmpty: 'Not Empty',
|
|
191
|
-
filterNotEquals: 'Not Equals',
|
|
192
|
-
filterStartsWith: 'Starts With',
|
|
193
|
-
filterWeakEquals: 'Equals',
|
|
194
|
-
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
195
|
-
goToFirstPage: 'Go to first page',
|
|
196
|
-
goToLastPage: 'Go to last page',
|
|
197
|
-
goToNextPage: 'Go to next page',
|
|
198
|
-
goToPreviousPage: 'Go to previous page',
|
|
199
|
-
grab: 'Grab',
|
|
200
|
-
groupByColumn: 'Group by {column}',
|
|
201
|
-
groupedBy: 'Grouped by ',
|
|
202
|
-
hideAll: 'Hide all',
|
|
203
|
-
hideColumn: 'Hide {column} column',
|
|
204
|
-
max: 'Max',
|
|
205
|
-
min: 'Min',
|
|
206
|
-
move: 'Move',
|
|
207
|
-
noRecordsToDisplay: 'No records to display',
|
|
208
|
-
noResultsFound: 'No results found',
|
|
209
|
-
of: 'of',
|
|
210
|
-
or: 'or',
|
|
211
|
-
pinToLeft: 'Pin to left',
|
|
212
|
-
pinToRight: 'Pin to right',
|
|
213
|
-
resetColumnSize: 'Reset column size',
|
|
214
|
-
resetOrder: 'Reset order',
|
|
215
|
-
rowActions: 'Row Actions',
|
|
216
|
-
rowNumber: '#',
|
|
217
|
-
rowNumbers: 'Row Numbers',
|
|
218
|
-
rowsPerPage: 'Rows per page',
|
|
219
|
-
save: 'Save',
|
|
220
|
-
search: 'Search',
|
|
221
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
222
|
-
select: 'Select',
|
|
223
|
-
showAll: 'Show all',
|
|
224
|
-
showAllColumns: 'Show all columns',
|
|
225
|
-
showHideColumns: 'Show/Hide columns',
|
|
226
|
-
showHideFilters: 'Show/Hide filters',
|
|
227
|
-
showHideSearch: 'Show/Hide search',
|
|
228
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
|
229
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
|
230
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
231
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
232
|
-
thenBy: ', then by ',
|
|
233
|
-
toggleDensity: 'Toggle density',
|
|
234
|
-
toggleFullScreen: 'Toggle full screen',
|
|
235
|
-
toggleSelectAll: 'Toggle select all',
|
|
236
|
-
toggleSelectRow: 'Toggle select row',
|
|
237
|
-
toggleVisibility: 'Toggle visibility',
|
|
238
|
-
ungroupByColumn: 'Ungroup by {column}',
|
|
239
|
-
unpin: 'Unpin',
|
|
240
|
-
unpinAll: 'Unpin all',
|
|
241
|
-
unsorted: 'Unsorted',
|
|
278
|
+
const MRT_Default_Icons = {
|
|
279
|
+
ArrowRightIcon: ArrowRight,
|
|
280
|
+
CancelIcon: Cancel,
|
|
281
|
+
CheckBoxIcon: CheckBox,
|
|
282
|
+
ClearAllIcon: ClearAll,
|
|
283
|
+
CloseIcon: Close,
|
|
284
|
+
DensityLargeIcon: DensityLarge,
|
|
285
|
+
DensityMediumIcon: DensityMedium,
|
|
286
|
+
DensitySmallIcon: DensitySmall,
|
|
287
|
+
DragHandleIcon: DragHandle,
|
|
288
|
+
DynamicFeedIcon: DynamicFeed,
|
|
289
|
+
EditIcon: Edit,
|
|
290
|
+
ExpandLessIcon: ExpandLess,
|
|
291
|
+
ExpandMoreIcon: ExpandMore,
|
|
292
|
+
FilterAltIcon: FilterAlt,
|
|
293
|
+
FilterAltOffIcon: FilterAltOff,
|
|
294
|
+
FilterListIcon: FilterList,
|
|
295
|
+
FilterListOffIcon: FilterListOff,
|
|
296
|
+
FullscreenExitIcon: FullscreenExit,
|
|
297
|
+
FullscreenIcon: Fullscreen,
|
|
298
|
+
KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDown,
|
|
299
|
+
MoreHorizIcon: MoreHoriz,
|
|
300
|
+
MoreVertIcon: MoreVert,
|
|
301
|
+
PushPinIcon: PushPin,
|
|
302
|
+
RestartAltIcon: RestartAlt,
|
|
303
|
+
SaveIcon: Save,
|
|
304
|
+
SearchIcon: Search,
|
|
305
|
+
SearchOffIcon: SearchOff,
|
|
306
|
+
SortIcon: Sort,
|
|
307
|
+
ViewColumnIcon: ViewColumn,
|
|
308
|
+
VisibilityOffIcon: VisibilityOff,
|
|
242
309
|
};
|
|
243
310
|
|
|
244
311
|
const fuzzy = (rowA, rowB, columnId) => {
|
|
@@ -273,7 +340,7 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
273
340
|
: getIsSomeRowsExpanded()
|
|
274
341
|
? -90
|
|
275
342
|
: 0}deg)`,
|
|
276
|
-
transition: 'transform
|
|
343
|
+
transition: 'transform 150ms',
|
|
277
344
|
} })))));
|
|
278
345
|
};
|
|
279
346
|
|
|
@@ -301,7 +368,7 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
301
368
|
: row.getIsExpanded()
|
|
302
369
|
? -180
|
|
303
370
|
: 0}deg)`,
|
|
304
|
-
transition: 'transform
|
|
371
|
+
transition: 'transform 150ms',
|
|
305
372
|
} })))));
|
|
306
373
|
};
|
|
307
374
|
|
|
@@ -489,7 +556,7 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
489
556
|
var _a;
|
|
490
557
|
e.stopPropagation();
|
|
491
558
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
492
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all
|
|
559
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
493
560
|
backgroundColor: 'transparent',
|
|
494
561
|
opacity: 1,
|
|
495
562
|
}, '&:active': {
|
|
@@ -500,163 +567,6 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
500
567
|
React.createElement(DragHandleIcon, null))));
|
|
501
568
|
};
|
|
502
569
|
|
|
503
|
-
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
|
|
504
|
-
const getAllLeafColumnDefs = (columns) => {
|
|
505
|
-
const allLeafColumnDefs = [];
|
|
506
|
-
const getLeafColumns = (cols) => {
|
|
507
|
-
cols.forEach((col) => {
|
|
508
|
-
if (col.columns) {
|
|
509
|
-
getLeafColumns(col.columns);
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
allLeafColumnDefs.push(col);
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
};
|
|
516
|
-
getLeafColumns(columns);
|
|
517
|
-
return allLeafColumnDefs;
|
|
518
|
-
};
|
|
519
|
-
const prepareColumns = ({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
|
520
|
-
var _a, _b;
|
|
521
|
-
if (!columnDef.id)
|
|
522
|
-
columnDef.id = getColumnId(columnDef);
|
|
523
|
-
if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
|
|
524
|
-
console.error('Column definitions must have a valid `accessorKey` or `id` property');
|
|
525
|
-
}
|
|
526
|
-
if (!columnDef.columnDefType)
|
|
527
|
-
columnDef.columnDefType = 'data';
|
|
528
|
-
if (!!((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
529
|
-
columnDef.columnDefType = 'group';
|
|
530
|
-
columnDef.columns = prepareColumns({
|
|
531
|
-
columnDefs: columnDef.columns,
|
|
532
|
-
columnFilterFns,
|
|
533
|
-
defaultDisplayColumn,
|
|
534
|
-
filterFns,
|
|
535
|
-
sortingFns,
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
else if (columnDef.columnDefType === 'data') {
|
|
539
|
-
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
540
|
-
columnDef.filterFn =
|
|
541
|
-
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
542
|
-
columnDef._filterFn =
|
|
543
|
-
columnFilterFns[columnDef.id];
|
|
544
|
-
}
|
|
545
|
-
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
546
|
-
// @ts-ignore
|
|
547
|
-
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
else if (columnDef.columnDefType === 'display') {
|
|
551
|
-
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
|
|
552
|
-
}
|
|
553
|
-
return columnDef;
|
|
554
|
-
});
|
|
555
|
-
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
556
|
-
if (draggedColumn.getCanPin()) {
|
|
557
|
-
draggedColumn.pin(targetColumn.getIsPinned());
|
|
558
|
-
}
|
|
559
|
-
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
560
|
-
return [...columnOrder];
|
|
561
|
-
};
|
|
562
|
-
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
563
|
-
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
564
|
-
props.renderDetailPanel);
|
|
565
|
-
const getLeadingDisplayColumnIds = (props) => {
|
|
566
|
-
var _a;
|
|
567
|
-
return [
|
|
568
|
-
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
569
|
-
props.positionActionsColumn === 'first' &&
|
|
570
|
-
(props.enableRowActions ||
|
|
571
|
-
(props.enableEditing &&
|
|
572
|
-
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
573
|
-
'mrt-row-actions',
|
|
574
|
-
props.positionExpandColumn === 'first' &&
|
|
575
|
-
showExpandColumn(props) &&
|
|
576
|
-
'mrt-row-expand',
|
|
577
|
-
props.enableRowSelection && 'mrt-row-select',
|
|
578
|
-
props.enableRowNumbers && 'mrt-row-numbers',
|
|
579
|
-
].filter(Boolean);
|
|
580
|
-
};
|
|
581
|
-
const getTrailingDisplayColumnIds = (props) => {
|
|
582
|
-
var _a;
|
|
583
|
-
return [
|
|
584
|
-
props.positionActionsColumn === 'last' &&
|
|
585
|
-
(props.enableRowActions ||
|
|
586
|
-
(props.enableEditing &&
|
|
587
|
-
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
588
|
-
'mrt-row-actions',
|
|
589
|
-
props.positionExpandColumn === 'last' &&
|
|
590
|
-
showExpandColumn(props) &&
|
|
591
|
-
'mrt-row-expand',
|
|
592
|
-
];
|
|
593
|
-
};
|
|
594
|
-
const getDefaultColumnOrderIds = (props) => [
|
|
595
|
-
...getLeadingDisplayColumnIds(props),
|
|
596
|
-
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
597
|
-
...getTrailingDisplayColumnIds(props),
|
|
598
|
-
].filter(Boolean);
|
|
599
|
-
const getDefaultColumnFilterFn = (columnDef) => {
|
|
600
|
-
if (columnDef.filterVariant === 'multi-select')
|
|
601
|
-
return 'arrIncludesSome';
|
|
602
|
-
if (columnDef.filterVariant === 'range')
|
|
603
|
-
return 'betweenInclusive';
|
|
604
|
-
if (columnDef.filterVariant === 'select' ||
|
|
605
|
-
columnDef.filterVariant === 'checkbox')
|
|
606
|
-
return 'equals';
|
|
607
|
-
return 'fuzzy';
|
|
608
|
-
};
|
|
609
|
-
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
610
|
-
return (column.getIsPinned() === 'left' &&
|
|
611
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
612
|
-
};
|
|
613
|
-
const getIsFirstRightPinnedColumn = (column) => {
|
|
614
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
615
|
-
};
|
|
616
|
-
const getTotalRight = (table, column) => {
|
|
617
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
618
|
-
};
|
|
619
|
-
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
620
|
-
var _a, _b, _c, _d;
|
|
621
|
-
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
622
|
-
? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
|
|
623
|
-
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
624
|
-
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
625
|
-
: getIsFirstRightPinnedColumn(column)
|
|
626
|
-
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
627
|
-
: undefined, left: column.getIsPinned() === 'left'
|
|
628
|
-
? `${column.getStart('left')}px`
|
|
629
|
-
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
630
|
-
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
631
|
-
? 0.5
|
|
632
|
-
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
633
|
-
? 'sticky'
|
|
634
|
-
: undefined, right: column.getIsPinned() === 'right'
|
|
635
|
-
? `${getTotalRight(table, column)}px`
|
|
636
|
-
: undefined, transition: `all ${column.getIsResizing() ? 0 : '0.1s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
637
|
-
? tableCellProps.sx(theme)
|
|
638
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
639
|
-
};
|
|
640
|
-
const MRT_DefaultColumn = {
|
|
641
|
-
minSize: 40,
|
|
642
|
-
maxSize: 1000,
|
|
643
|
-
size: 180,
|
|
644
|
-
};
|
|
645
|
-
const MRT_DefaultDisplayColumn = {
|
|
646
|
-
columnDefType: 'display',
|
|
647
|
-
enableClickToCopy: false,
|
|
648
|
-
enableColumnActions: false,
|
|
649
|
-
enableColumnDragging: false,
|
|
650
|
-
enableColumnFilter: false,
|
|
651
|
-
enableColumnOrdering: false,
|
|
652
|
-
enableEditing: false,
|
|
653
|
-
enableGlobalFilter: false,
|
|
654
|
-
enableGrouping: false,
|
|
655
|
-
enableHiding: false,
|
|
656
|
-
enableResizing: false,
|
|
657
|
-
enableSorting: false,
|
|
658
|
-
};
|
|
659
|
-
|
|
660
570
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
661
571
|
var _a;
|
|
662
572
|
const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
|
|
@@ -1007,7 +917,7 @@ const commonIconButtonStyles = {
|
|
|
1007
917
|
height: '2rem',
|
|
1008
918
|
ml: '10px',
|
|
1009
919
|
opacity: 0.5,
|
|
1010
|
-
transition: 'opacity
|
|
920
|
+
transition: 'opacity 150ms',
|
|
1011
921
|
width: '2rem',
|
|
1012
922
|
'&:hover': {
|
|
1013
923
|
opacity: 1,
|
|
@@ -1038,7 +948,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
|
1038
948
|
|
|
1039
949
|
const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
1040
950
|
var _a;
|
|
1041
|
-
const { getState, options: { localization, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
951
|
+
const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
1042
952
|
const { density } = getState();
|
|
1043
953
|
const checkboxProps = !row
|
|
1044
954
|
? muiSelectAllCheckboxProps instanceof Function
|
|
@@ -1047,33 +957,33 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
1047
957
|
: muiSelectCheckboxProps instanceof Function
|
|
1048
958
|
? muiSelectCheckboxProps({ row, table })
|
|
1049
959
|
: muiSelectCheckboxProps;
|
|
960
|
+
const commonProps = Object.assign(Object.assign({ checked: selectAll
|
|
961
|
+
? selectAllMode === 'page'
|
|
962
|
+
? table.getIsAllPageRowsSelected()
|
|
963
|
+
: table.getIsAllRowsSelected()
|
|
964
|
+
: row === null || row === void 0 ? void 0 : row.getIsSelected(), inputProps: {
|
|
965
|
+
'aria-label': selectAll
|
|
966
|
+
? localization.toggleSelectAll
|
|
967
|
+
: localization.toggleSelectRow,
|
|
968
|
+
}, onChange: row
|
|
969
|
+
? row.getToggleSelectedHandler()
|
|
970
|
+
: selectAllMode === 'all'
|
|
971
|
+
? table.getToggleAllRowsSelectedHandler()
|
|
972
|
+
: table.getToggleAllPageRowsSelectedHandler(), size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
973
|
+
var _a;
|
|
974
|
+
e.stopPropagation();
|
|
975
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
976
|
+
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
977
|
+
? checkboxProps.sx(theme)
|
|
978
|
+
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined });
|
|
1050
979
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
|
1051
980
|
? localization.toggleSelectAll
|
|
1052
|
-
: localization.toggleSelectRow) },
|
|
1053
|
-
|
|
1054
|
-
|
|
981
|
+
: localization.toggleSelectRow) }, enableMultiRowSelection === false ? (React.createElement(Radio, Object.assign({}, commonProps))) : (React.createElement(Checkbox, Object.assign({ indeterminate: selectAll
|
|
982
|
+
? table.getIsSomeRowsSelected() &&
|
|
983
|
+
!(selectAllMode === 'page'
|
|
1055
984
|
? table.getIsAllPageRowsSelected()
|
|
1056
|
-
: table.getIsAllRowsSelected()
|
|
1057
|
-
|
|
1058
|
-
? table.getIsSomeRowsSelected() &&
|
|
1059
|
-
!(selectAllMode === 'page'
|
|
1060
|
-
? table.getIsAllPageRowsSelected()
|
|
1061
|
-
: table.getIsAllRowsSelected())
|
|
1062
|
-
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected(), inputProps: {
|
|
1063
|
-
'aria-label': selectAll
|
|
1064
|
-
? localization.toggleSelectAll
|
|
1065
|
-
: localization.toggleSelectRow,
|
|
1066
|
-
}, onChange: row
|
|
1067
|
-
? row.getToggleSelectedHandler()
|
|
1068
|
-
: selectAllMode === 'all'
|
|
1069
|
-
? table.getToggleAllRowsSelectedHandler()
|
|
1070
|
-
: table.getToggleAllPageRowsSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1071
|
-
var _a;
|
|
1072
|
-
e.stopPropagation();
|
|
1073
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1074
|
-
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
1075
|
-
? checkboxProps.sx(theme)
|
|
1076
|
-
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined }))));
|
|
985
|
+
: table.getIsAllRowsSelected())
|
|
986
|
+
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps)))));
|
|
1077
987
|
};
|
|
1078
988
|
|
|
1079
989
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
@@ -1336,7 +1246,7 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1336
1246
|
minHeight: '3.5rem',
|
|
1337
1247
|
overflow: 'hidden',
|
|
1338
1248
|
p: '0 !important',
|
|
1339
|
-
transition: 'all
|
|
1249
|
+
transition: 'all 150ms ease-in-out',
|
|
1340
1250
|
zIndex: 1,
|
|
1341
1251
|
});
|
|
1342
1252
|
const MRT_TopToolbar = ({ table }) => {
|
|
@@ -1446,13 +1356,13 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1446
1356
|
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
|
1447
1357
|
return (React.createElement(React.Fragment, null,
|
|
1448
1358
|
React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.columnActions },
|
|
1449
|
-
React.createElement(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity
|
|
1359
|
+
React.createElement(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity 150ms', width: '2rem', '&:hover': {
|
|
1450
1360
|
opacity: 1,
|
|
1451
1361
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
1452
1362
|
? iconButtonProps.sx(theme)
|
|
1453
1363
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
1454
1364
|
React.createElement(MoreVertIcon, null))),
|
|
1455
|
-
React.createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1365
|
+
anchorEl && (React.createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))));
|
|
1456
1366
|
};
|
|
1457
1367
|
|
|
1458
1368
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
@@ -1790,7 +1700,9 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1790
1700
|
position: 'absolute',
|
|
1791
1701
|
right: '1px',
|
|
1792
1702
|
touchAction: 'none',
|
|
1793
|
-
transition: column.getIsResizing()
|
|
1703
|
+
transition: column.getIsResizing()
|
|
1704
|
+
? undefined
|
|
1705
|
+
: 'all 150ms ease-in-out',
|
|
1794
1706
|
userSelect: 'none',
|
|
1795
1707
|
zIndex: 4,
|
|
1796
1708
|
'&:active': {
|
|
@@ -2174,7 +2086,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2174
2086
|
: undefined,
|
|
2175
2087
|
}
|
|
2176
2088
|
: undefined;
|
|
2177
|
-
return (React.createElement(TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : '
|
|
2089
|
+
return (React.createElement(TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
|
|
2178
2090
|
? columnDefType === 'display'
|
|
2179
2091
|
? '0 0.5rem'
|
|
2180
2092
|
: '0.5rem'
|
|
@@ -2214,6 +2126,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2214
2126
|
_b.length,
|
|
2215
2127
|
")"))));
|
|
2216
2128
|
};
|
|
2129
|
+
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
|
2217
2130
|
|
|
2218
2131
|
const MRT_TableDetailPanel = ({ row, table }) => {
|
|
2219
2132
|
const { getVisibleLeafColumns, options: { muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
|
|
@@ -2224,7 +2137,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2224
2137
|
? muiTableDetailPanelProps({ row, table })
|
|
2225
2138
|
: muiTableDetailPanelProps;
|
|
2226
2139
|
return (React.createElement(TableRow, Object.assign({}, tableRowProps),
|
|
2227
|
-
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all
|
|
2140
|
+
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2228
2141
|
? tableCellProps.sx(theme)
|
|
2229
2142
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in: row.getIsExpanded() }, renderDetailPanel({ row, table }))))));
|
|
2230
2143
|
};
|
|
@@ -2232,8 +2145,8 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2232
2145
|
const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
2233
2146
|
var _a, _b;
|
|
2234
2147
|
const theme = useTheme();
|
|
2235
|
-
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setHoveredRow, } = table;
|
|
2236
|
-
const { draggingRow, hoveredRow } = getState();
|
|
2148
|
+
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
|
|
2149
|
+
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
|
|
2237
2150
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
|
2238
2151
|
? muiTableBodyRowProps({ row, table })
|
|
2239
2152
|
: muiTableBodyRowProps;
|
|
@@ -2259,7 +2172,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2259
2172
|
if (virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.measureRef) {
|
|
2260
2173
|
virtualRow.measureRef = node;
|
|
2261
2174
|
}
|
|
2262
|
-
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all
|
|
2175
|
+
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 150ms ease-in-out', '&:hover td': {
|
|
2263
2176
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
|
|
2264
2177
|
? theme.palette.mode === 'dark'
|
|
2265
2178
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
@@ -2267,13 +2180,29 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2267
2180
|
: undefined,
|
|
2268
2181
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2269
2182
|
? tableRowProps.sx(theme)
|
|
2270
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) =>
|
|
2183
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => {
|
|
2184
|
+
const props = {
|
|
2185
|
+
cell,
|
|
2186
|
+
enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false,
|
|
2187
|
+
key: cell.id,
|
|
2188
|
+
rowIndex,
|
|
2189
|
+
rowRef,
|
|
2190
|
+
table,
|
|
2191
|
+
};
|
|
2192
|
+
return memoMode === 'cell' &&
|
|
2193
|
+
cell.column.columnDef.columnDefType === 'data' &&
|
|
2194
|
+
!draggingColumn &&
|
|
2195
|
+
!draggingRow &&
|
|
2196
|
+
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
|
2197
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (React.createElement(Memo_MRT_TableBodyCell, Object.assign({}, props))) : (React.createElement(MRT_TableBodyCell, Object.assign({}, props)));
|
|
2198
|
+
})),
|
|
2271
2199
|
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2272
2200
|
};
|
|
2201
|
+
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
|
|
2273
2202
|
|
|
2274
2203
|
const MRT_TableBody = ({ table }) => {
|
|
2275
2204
|
var _a;
|
|
2276
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2205
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, memoMode, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2277
2206
|
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2278
2207
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2279
2208
|
? muiTableBodyProps({ table })
|
|
@@ -2357,11 +2286,21 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2357
2286
|
const row = enableRowVirtualization
|
|
2358
2287
|
? rows[rowOrVirtualRow.index]
|
|
2359
2288
|
: rowOrVirtualRow;
|
|
2360
|
-
|
|
2289
|
+
const props = {
|
|
2290
|
+
key: row.id,
|
|
2291
|
+
row,
|
|
2292
|
+
rowIndex: enableRowVirtualization
|
|
2293
|
+
? rowOrVirtualRow.index
|
|
2294
|
+
: rowIndex,
|
|
2295
|
+
table,
|
|
2296
|
+
virtualRow: enableRowVirtualization ? rowOrVirtualRow : null,
|
|
2297
|
+
};
|
|
2298
|
+
return memoMode === 'row' ? (React.createElement(Memo_MRT_TableBodyRow, Object.assign({}, props))) : (React.createElement(MRT_TableBodyRow, Object.assign({}, props)));
|
|
2361
2299
|
}),
|
|
2362
2300
|
enableRowVirtualization && paddingBottom > 0 && (React.createElement("tr", null,
|
|
2363
2301
|
React.createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2364
2302
|
};
|
|
2303
|
+
const Memo_MRT_TableBody = memo(MRT_TableBody, () => true);
|
|
2365
2304
|
|
|
2366
2305
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2367
2306
|
var _a, _b, _c;
|
|
@@ -2424,7 +2363,7 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2424
2363
|
};
|
|
2425
2364
|
|
|
2426
2365
|
const MRT_Table = ({ table }) => {
|
|
2427
|
-
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
|
|
2366
|
+
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, memoMode, muiTableProps, }, } = table;
|
|
2428
2367
|
const { isFullScreen } = getState();
|
|
2429
2368
|
const tableProps = muiTableProps instanceof Function
|
|
2430
2369
|
? muiTableProps({ table })
|
|
@@ -2433,7 +2372,7 @@ const MRT_Table = ({ table }) => {
|
|
|
2433
2372
|
? tableProps.sx(theme)
|
|
2434
2373
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
|
2435
2374
|
enableTableHead && React.createElement(MRT_TableHead, { table: table }),
|
|
2436
|
-
React.createElement(MRT_TableBody, { table: table }),
|
|
2375
|
+
memoMode === 'table-body' ? (React.createElement(Memo_MRT_TableBody, { table: table })) : (React.createElement(MRT_TableBody, { table: table })),
|
|
2437
2376
|
enableTableFooter && React.createElement(MRT_TableFooter, { table: table })));
|
|
2438
2377
|
};
|
|
2439
2378
|
|
|
@@ -2483,7 +2422,7 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2483
2422
|
//@ts-ignore
|
|
2484
2423
|
tablePaperProps.ref.current = ref;
|
|
2485
2424
|
}
|
|
2486
|
-
}, sx: (theme) => (Object.assign({ transition: 'all
|
|
2425
|
+
}, sx: (theme) => (Object.assign({ transition: 'all 150ms ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2487
2426
|
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2488
2427
|
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
|
2489
2428
|
? {
|
|
@@ -2574,7 +2513,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2574
2513
|
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: props.localization.actions, size: 70 }, props.defaultDisplayColumn), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2575
2514
|
columnOrder.includes('mrt-row-expand') &&
|
|
2576
2515
|
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: props.localization.expand, size: 60 }, props.defaultDisplayColumn), (_c = props.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2577
|
-
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2516
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll && props.enableMultiRowSelection ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2578
2517
|
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => props.localization.rowNumber, header: props.localization.rowNumbers, size: 60 }, props.defaultDisplayColumn), (_e = props.displayColumnDefOptions) === null || _e === void 0 ? void 0 : _e['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2579
2518
|
].filter(Boolean);
|
|
2580
2519
|
}, [
|
|
@@ -2682,6 +2621,96 @@ const MRT_TableRoot = (props) => {
|
|
|
2682
2621
|
editingRow && props.editingMode === 'modal' && (React.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2683
2622
|
};
|
|
2684
2623
|
|
|
2624
|
+
const MRT_Localization_EN = {
|
|
2625
|
+
actions: 'Actions',
|
|
2626
|
+
and: 'and',
|
|
2627
|
+
cancel: 'Cancel',
|
|
2628
|
+
changeFilterMode: 'Change filter mode',
|
|
2629
|
+
changeSearchMode: 'Change search mode',
|
|
2630
|
+
clearFilter: 'Clear filter',
|
|
2631
|
+
clearSearch: 'Clear search',
|
|
2632
|
+
clearSort: 'Clear sort',
|
|
2633
|
+
clickToCopy: 'Click to copy',
|
|
2634
|
+
columnActions: 'Column Actions',
|
|
2635
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
2636
|
+
dropToGroupBy: 'Drop to group by {column}',
|
|
2637
|
+
edit: 'Edit',
|
|
2638
|
+
expand: 'Expand',
|
|
2639
|
+
expandAll: 'Expand all',
|
|
2640
|
+
filterArrIncludes: 'Includes',
|
|
2641
|
+
filterArrIncludesAll: 'Includes all',
|
|
2642
|
+
filterArrIncludesSome: 'Includes',
|
|
2643
|
+
filterBetween: 'Between',
|
|
2644
|
+
filterBetweenInclusive: 'Between Inclusive',
|
|
2645
|
+
filterByColumn: 'Filter by {column}',
|
|
2646
|
+
filterContains: 'Contains',
|
|
2647
|
+
filterEmpty: 'Empty',
|
|
2648
|
+
filterEndsWith: 'Ends With',
|
|
2649
|
+
filterEquals: 'Equals',
|
|
2650
|
+
filterEqualsString: 'Equals',
|
|
2651
|
+
filterFuzzy: 'Fuzzy',
|
|
2652
|
+
filterGreaterThan: 'Greater Than',
|
|
2653
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
2654
|
+
filterInNumberRange: 'Between',
|
|
2655
|
+
filterIncludesString: 'Contains',
|
|
2656
|
+
filterIncludesStringSensitive: 'Contains',
|
|
2657
|
+
filterLessThan: 'Less Than',
|
|
2658
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
2659
|
+
filterMode: 'Filter Mode: {filterType}',
|
|
2660
|
+
filterNotEmpty: 'Not Empty',
|
|
2661
|
+
filterNotEquals: 'Not Equals',
|
|
2662
|
+
filterStartsWith: 'Starts With',
|
|
2663
|
+
filterWeakEquals: 'Equals',
|
|
2664
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
2665
|
+
goToFirstPage: 'Go to first page',
|
|
2666
|
+
goToLastPage: 'Go to last page',
|
|
2667
|
+
goToNextPage: 'Go to next page',
|
|
2668
|
+
goToPreviousPage: 'Go to previous page',
|
|
2669
|
+
grab: 'Grab',
|
|
2670
|
+
groupByColumn: 'Group by {column}',
|
|
2671
|
+
groupedBy: 'Grouped by ',
|
|
2672
|
+
hideAll: 'Hide all',
|
|
2673
|
+
hideColumn: 'Hide {column} column',
|
|
2674
|
+
max: 'Max',
|
|
2675
|
+
min: 'Min',
|
|
2676
|
+
move: 'Move',
|
|
2677
|
+
noRecordsToDisplay: 'No records to display',
|
|
2678
|
+
noResultsFound: 'No results found',
|
|
2679
|
+
of: 'of',
|
|
2680
|
+
or: 'or',
|
|
2681
|
+
pinToLeft: 'Pin to left',
|
|
2682
|
+
pinToRight: 'Pin to right',
|
|
2683
|
+
resetColumnSize: 'Reset column size',
|
|
2684
|
+
resetOrder: 'Reset order',
|
|
2685
|
+
rowActions: 'Row Actions',
|
|
2686
|
+
rowNumber: '#',
|
|
2687
|
+
rowNumbers: 'Row Numbers',
|
|
2688
|
+
rowsPerPage: 'Rows per page',
|
|
2689
|
+
save: 'Save',
|
|
2690
|
+
search: 'Search',
|
|
2691
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
2692
|
+
select: 'Select',
|
|
2693
|
+
showAll: 'Show all',
|
|
2694
|
+
showAllColumns: 'Show all columns',
|
|
2695
|
+
showHideColumns: 'Show/Hide columns',
|
|
2696
|
+
showHideFilters: 'Show/Hide filters',
|
|
2697
|
+
showHideSearch: 'Show/Hide search',
|
|
2698
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
|
2699
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
|
2700
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
2701
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
2702
|
+
thenBy: ', then by ',
|
|
2703
|
+
toggleDensity: 'Toggle density',
|
|
2704
|
+
toggleFullScreen: 'Toggle full screen',
|
|
2705
|
+
toggleSelectAll: 'Toggle select all',
|
|
2706
|
+
toggleSelectRow: 'Toggle select row',
|
|
2707
|
+
toggleVisibility: 'Toggle visibility',
|
|
2708
|
+
ungroupByColumn: 'Ungroup by {column}',
|
|
2709
|
+
unpin: 'Unpin',
|
|
2710
|
+
unpinAll: 'Unpin all',
|
|
2711
|
+
unsorted: 'Unsorted',
|
|
2712
|
+
};
|
|
2713
|
+
|
|
2685
2714
|
const MaterialReactTable = (_a) => {
|
|
2686
2715
|
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn, defaultDisplayColumn, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enablePinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, localization, positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'original', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnResizeMode", "defaultColumn", "defaultDisplayColumn", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "localization", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
|
|
2687
2716
|
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), []);
|