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
package/dist/cjs/index.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var reactTable = require('@tanstack/react-table');
|
|
7
|
-
var iconsMaterial = require('@mui/icons-material');
|
|
8
|
-
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
9
7
|
var material = require('@mui/material');
|
|
8
|
+
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
9
|
+
var iconsMaterial = require('@mui/icons-material');
|
|
10
10
|
var reactVirtual = require('react-virtual');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -42,37 +42,161 @@ function __rest(s, e) {
|
|
|
42
42
|
|
|
43
43
|
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
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; };
|
|
46
|
+
const getAllLeafColumnDefs = (columns) => {
|
|
47
|
+
const allLeafColumnDefs = [];
|
|
48
|
+
const getLeafColumns = (cols) => {
|
|
49
|
+
cols.forEach((col) => {
|
|
50
|
+
if (col.columns) {
|
|
51
|
+
getLeafColumns(col.columns);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
allLeafColumnDefs.push(col);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
getLeafColumns(columns);
|
|
59
|
+
return allLeafColumnDefs;
|
|
60
|
+
};
|
|
61
|
+
const prepareColumns = ({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
if (!columnDef.id)
|
|
64
|
+
columnDef.id = getColumnId(columnDef);
|
|
65
|
+
if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
|
|
66
|
+
console.error('Column definitions must have a valid `accessorKey` or `id` property');
|
|
67
|
+
}
|
|
68
|
+
if (!columnDef.columnDefType)
|
|
69
|
+
columnDef.columnDefType = 'data';
|
|
70
|
+
if (!!((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
71
|
+
columnDef.columnDefType = 'group';
|
|
72
|
+
columnDef.columns = prepareColumns({
|
|
73
|
+
columnDefs: columnDef.columns,
|
|
74
|
+
columnFilterFns,
|
|
75
|
+
defaultDisplayColumn,
|
|
76
|
+
filterFns,
|
|
77
|
+
sortingFns,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (columnDef.columnDefType === 'data') {
|
|
81
|
+
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
82
|
+
columnDef.filterFn =
|
|
83
|
+
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
84
|
+
columnDef._filterFn =
|
|
85
|
+
columnFilterFns[columnDef.id];
|
|
86
|
+
}
|
|
87
|
+
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (columnDef.columnDefType === 'display') {
|
|
93
|
+
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
|
|
94
|
+
}
|
|
95
|
+
return columnDef;
|
|
96
|
+
});
|
|
97
|
+
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
98
|
+
if (draggedColumn.getCanPin()) {
|
|
99
|
+
draggedColumn.pin(targetColumn.getIsPinned());
|
|
100
|
+
}
|
|
101
|
+
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
102
|
+
return [...columnOrder];
|
|
103
|
+
};
|
|
104
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
105
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
106
|
+
props.renderDetailPanel);
|
|
107
|
+
const getLeadingDisplayColumnIds = (props) => {
|
|
108
|
+
var _a;
|
|
109
|
+
return [
|
|
110
|
+
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
111
|
+
props.positionActionsColumn === 'first' &&
|
|
112
|
+
(props.enableRowActions ||
|
|
113
|
+
(props.enableEditing &&
|
|
114
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
115
|
+
'mrt-row-actions',
|
|
116
|
+
props.positionExpandColumn === 'first' &&
|
|
117
|
+
showExpandColumn(props) &&
|
|
118
|
+
'mrt-row-expand',
|
|
119
|
+
props.enableRowSelection && 'mrt-row-select',
|
|
120
|
+
props.enableRowNumbers && 'mrt-row-numbers',
|
|
121
|
+
].filter(Boolean);
|
|
122
|
+
};
|
|
123
|
+
const getTrailingDisplayColumnIds = (props) => {
|
|
124
|
+
var _a;
|
|
125
|
+
return [
|
|
126
|
+
props.positionActionsColumn === 'last' &&
|
|
127
|
+
(props.enableRowActions ||
|
|
128
|
+
(props.enableEditing &&
|
|
129
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
130
|
+
'mrt-row-actions',
|
|
131
|
+
props.positionExpandColumn === 'last' &&
|
|
132
|
+
showExpandColumn(props) &&
|
|
133
|
+
'mrt-row-expand',
|
|
134
|
+
];
|
|
135
|
+
};
|
|
136
|
+
const getDefaultColumnOrderIds = (props) => [
|
|
137
|
+
...getLeadingDisplayColumnIds(props),
|
|
138
|
+
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
139
|
+
...getTrailingDisplayColumnIds(props),
|
|
140
|
+
].filter(Boolean);
|
|
141
|
+
const getDefaultColumnFilterFn = (columnDef) => {
|
|
142
|
+
if (columnDef.filterVariant === 'multi-select')
|
|
143
|
+
return 'arrIncludesSome';
|
|
144
|
+
if (columnDef.filterVariant === 'range')
|
|
145
|
+
return 'betweenInclusive';
|
|
146
|
+
if (columnDef.filterVariant === 'select' ||
|
|
147
|
+
columnDef.filterVariant === 'checkbox')
|
|
148
|
+
return 'equals';
|
|
149
|
+
return 'fuzzy';
|
|
150
|
+
};
|
|
151
|
+
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
152
|
+
return (column.getIsPinned() === 'left' &&
|
|
153
|
+
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
154
|
+
};
|
|
155
|
+
const getIsFirstRightPinnedColumn = (column) => {
|
|
156
|
+
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
157
|
+
};
|
|
158
|
+
const getTotalRight = (table, column) => {
|
|
159
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
160
|
+
};
|
|
161
|
+
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
164
|
+
? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.97)
|
|
165
|
+
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
166
|
+
? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
167
|
+
: getIsFirstRightPinnedColumn(column)
|
|
168
|
+
? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
169
|
+
: undefined, left: column.getIsPinned() === 'left'
|
|
170
|
+
? `${column.getStart('left')}px`
|
|
171
|
+
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
172
|
+
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
173
|
+
? 0.5
|
|
174
|
+
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
175
|
+
? 'sticky'
|
|
176
|
+
: undefined, right: column.getIsPinned() === 'right'
|
|
177
|
+
? `${getTotalRight(table, column)}px`
|
|
178
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '150ms'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
179
|
+
? tableCellProps.sx(theme)
|
|
180
|
+
: 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() }));
|
|
181
|
+
};
|
|
182
|
+
const MRT_DefaultColumn = {
|
|
183
|
+
minSize: 40,
|
|
184
|
+
maxSize: 1000,
|
|
185
|
+
size: 180,
|
|
186
|
+
};
|
|
187
|
+
const MRT_DefaultDisplayColumn = {
|
|
188
|
+
columnDefType: 'display',
|
|
189
|
+
enableClickToCopy: false,
|
|
190
|
+
enableColumnActions: false,
|
|
191
|
+
enableColumnDragging: false,
|
|
192
|
+
enableColumnFilter: false,
|
|
193
|
+
enableColumnOrdering: false,
|
|
194
|
+
enableEditing: false,
|
|
195
|
+
enableGlobalFilter: false,
|
|
196
|
+
enableGrouping: false,
|
|
197
|
+
enableHiding: false,
|
|
198
|
+
enableResizing: false,
|
|
199
|
+
enableSorting: false,
|
|
76
200
|
};
|
|
77
201
|
|
|
78
202
|
const fuzzy$1 = (row, columnId, filterValue, addMeta) => {
|
|
@@ -159,94 +283,37 @@ const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { b
|
|
|
159
283
|
notEquals,
|
|
160
284
|
startsWith });
|
|
161
285
|
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
filterIncludesString: 'Contains',
|
|
194
|
-
filterIncludesStringSensitive: 'Contains',
|
|
195
|
-
filterLessThan: 'Less Than',
|
|
196
|
-
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
197
|
-
filterMode: 'Filter Mode: {filterType}',
|
|
198
|
-
filterNotEmpty: 'Not Empty',
|
|
199
|
-
filterNotEquals: 'Not Equals',
|
|
200
|
-
filterStartsWith: 'Starts With',
|
|
201
|
-
filterWeakEquals: 'Equals',
|
|
202
|
-
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
203
|
-
goToFirstPage: 'Go to first page',
|
|
204
|
-
goToLastPage: 'Go to last page',
|
|
205
|
-
goToNextPage: 'Go to next page',
|
|
206
|
-
goToPreviousPage: 'Go to previous page',
|
|
207
|
-
grab: 'Grab',
|
|
208
|
-
groupByColumn: 'Group by {column}',
|
|
209
|
-
groupedBy: 'Grouped by ',
|
|
210
|
-
hideAll: 'Hide all',
|
|
211
|
-
hideColumn: 'Hide {column} column',
|
|
212
|
-
max: 'Max',
|
|
213
|
-
min: 'Min',
|
|
214
|
-
move: 'Move',
|
|
215
|
-
noRecordsToDisplay: 'No records to display',
|
|
216
|
-
noResultsFound: 'No results found',
|
|
217
|
-
of: 'of',
|
|
218
|
-
or: 'or',
|
|
219
|
-
pinToLeft: 'Pin to left',
|
|
220
|
-
pinToRight: 'Pin to right',
|
|
221
|
-
resetColumnSize: 'Reset column size',
|
|
222
|
-
resetOrder: 'Reset order',
|
|
223
|
-
rowActions: 'Row Actions',
|
|
224
|
-
rowNumber: '#',
|
|
225
|
-
rowNumbers: 'Row Numbers',
|
|
226
|
-
rowsPerPage: 'Rows per page',
|
|
227
|
-
save: 'Save',
|
|
228
|
-
search: 'Search',
|
|
229
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
230
|
-
select: 'Select',
|
|
231
|
-
showAll: 'Show all',
|
|
232
|
-
showAllColumns: 'Show all columns',
|
|
233
|
-
showHideColumns: 'Show/Hide columns',
|
|
234
|
-
showHideFilters: 'Show/Hide filters',
|
|
235
|
-
showHideSearch: 'Show/Hide search',
|
|
236
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
|
237
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
|
238
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
239
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
240
|
-
thenBy: ', then by ',
|
|
241
|
-
toggleDensity: 'Toggle density',
|
|
242
|
-
toggleFullScreen: 'Toggle full screen',
|
|
243
|
-
toggleSelectAll: 'Toggle select all',
|
|
244
|
-
toggleSelectRow: 'Toggle select row',
|
|
245
|
-
toggleVisibility: 'Toggle visibility',
|
|
246
|
-
ungroupByColumn: 'Ungroup by {column}',
|
|
247
|
-
unpin: 'Unpin',
|
|
248
|
-
unpinAll: 'Unpin all',
|
|
249
|
-
unsorted: 'Unsorted',
|
|
286
|
+
const MRT_Default_Icons = {
|
|
287
|
+
ArrowRightIcon: iconsMaterial.ArrowRight,
|
|
288
|
+
CancelIcon: iconsMaterial.Cancel,
|
|
289
|
+
CheckBoxIcon: iconsMaterial.CheckBox,
|
|
290
|
+
ClearAllIcon: iconsMaterial.ClearAll,
|
|
291
|
+
CloseIcon: iconsMaterial.Close,
|
|
292
|
+
DensityLargeIcon: iconsMaterial.DensityLarge,
|
|
293
|
+
DensityMediumIcon: iconsMaterial.DensityMedium,
|
|
294
|
+
DensitySmallIcon: iconsMaterial.DensitySmall,
|
|
295
|
+
DragHandleIcon: iconsMaterial.DragHandle,
|
|
296
|
+
DynamicFeedIcon: iconsMaterial.DynamicFeed,
|
|
297
|
+
EditIcon: iconsMaterial.Edit,
|
|
298
|
+
ExpandLessIcon: iconsMaterial.ExpandLess,
|
|
299
|
+
ExpandMoreIcon: iconsMaterial.ExpandMore,
|
|
300
|
+
FilterAltIcon: iconsMaterial.FilterAlt,
|
|
301
|
+
FilterAltOffIcon: iconsMaterial.FilterAltOff,
|
|
302
|
+
FilterListIcon: iconsMaterial.FilterList,
|
|
303
|
+
FilterListOffIcon: iconsMaterial.FilterListOff,
|
|
304
|
+
FullscreenExitIcon: iconsMaterial.FullscreenExit,
|
|
305
|
+
FullscreenIcon: iconsMaterial.Fullscreen,
|
|
306
|
+
KeyboardDoubleArrowDownIcon: iconsMaterial.KeyboardDoubleArrowDown,
|
|
307
|
+
MoreHorizIcon: iconsMaterial.MoreHoriz,
|
|
308
|
+
MoreVertIcon: iconsMaterial.MoreVert,
|
|
309
|
+
PushPinIcon: iconsMaterial.PushPin,
|
|
310
|
+
RestartAltIcon: iconsMaterial.RestartAlt,
|
|
311
|
+
SaveIcon: iconsMaterial.Save,
|
|
312
|
+
SearchIcon: iconsMaterial.Search,
|
|
313
|
+
SearchOffIcon: iconsMaterial.SearchOff,
|
|
314
|
+
SortIcon: iconsMaterial.Sort,
|
|
315
|
+
ViewColumnIcon: iconsMaterial.ViewColumn,
|
|
316
|
+
VisibilityOffIcon: iconsMaterial.VisibilityOff,
|
|
250
317
|
};
|
|
251
318
|
|
|
252
319
|
const fuzzy = (rowA, rowB, columnId) => {
|
|
@@ -281,7 +348,7 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
281
348
|
: getIsSomeRowsExpanded()
|
|
282
349
|
? -90
|
|
283
350
|
: 0}deg)`,
|
|
284
|
-
transition: 'transform
|
|
351
|
+
transition: 'transform 150ms',
|
|
285
352
|
} })))));
|
|
286
353
|
};
|
|
287
354
|
|
|
@@ -309,7 +376,7 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
309
376
|
: row.getIsExpanded()
|
|
310
377
|
? -180
|
|
311
378
|
: 0}deg)`,
|
|
312
|
-
transition: 'transform
|
|
379
|
+
transition: 'transform 150ms',
|
|
313
380
|
} })))));
|
|
314
381
|
};
|
|
315
382
|
|
|
@@ -497,7 +564,7 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
497
564
|
var _a;
|
|
498
565
|
e.stopPropagation();
|
|
499
566
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
500
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all
|
|
567
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
501
568
|
backgroundColor: 'transparent',
|
|
502
569
|
opacity: 1,
|
|
503
570
|
}, '&:active': {
|
|
@@ -508,163 +575,6 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
508
575
|
React__default["default"].createElement(DragHandleIcon, null))));
|
|
509
576
|
};
|
|
510
577
|
|
|
511
|
-
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; };
|
|
512
|
-
const getAllLeafColumnDefs = (columns) => {
|
|
513
|
-
const allLeafColumnDefs = [];
|
|
514
|
-
const getLeafColumns = (cols) => {
|
|
515
|
-
cols.forEach((col) => {
|
|
516
|
-
if (col.columns) {
|
|
517
|
-
getLeafColumns(col.columns);
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
allLeafColumnDefs.push(col);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
getLeafColumns(columns);
|
|
525
|
-
return allLeafColumnDefs;
|
|
526
|
-
};
|
|
527
|
-
const prepareColumns = ({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
|
528
|
-
var _a, _b;
|
|
529
|
-
if (!columnDef.id)
|
|
530
|
-
columnDef.id = getColumnId(columnDef);
|
|
531
|
-
if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
|
|
532
|
-
console.error('Column definitions must have a valid `accessorKey` or `id` property');
|
|
533
|
-
}
|
|
534
|
-
if (!columnDef.columnDefType)
|
|
535
|
-
columnDef.columnDefType = 'data';
|
|
536
|
-
if (!!((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
537
|
-
columnDef.columnDefType = 'group';
|
|
538
|
-
columnDef.columns = prepareColumns({
|
|
539
|
-
columnDefs: columnDef.columns,
|
|
540
|
-
columnFilterFns,
|
|
541
|
-
defaultDisplayColumn,
|
|
542
|
-
filterFns,
|
|
543
|
-
sortingFns,
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
else if (columnDef.columnDefType === 'data') {
|
|
547
|
-
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
548
|
-
columnDef.filterFn =
|
|
549
|
-
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
550
|
-
columnDef._filterFn =
|
|
551
|
-
columnFilterFns[columnDef.id];
|
|
552
|
-
}
|
|
553
|
-
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
554
|
-
// @ts-ignore
|
|
555
|
-
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
else if (columnDef.columnDefType === 'display') {
|
|
559
|
-
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
|
|
560
|
-
}
|
|
561
|
-
return columnDef;
|
|
562
|
-
});
|
|
563
|
-
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
564
|
-
if (draggedColumn.getCanPin()) {
|
|
565
|
-
draggedColumn.pin(targetColumn.getIsPinned());
|
|
566
|
-
}
|
|
567
|
-
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
568
|
-
return [...columnOrder];
|
|
569
|
-
};
|
|
570
|
-
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
571
|
-
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
572
|
-
props.renderDetailPanel);
|
|
573
|
-
const getLeadingDisplayColumnIds = (props) => {
|
|
574
|
-
var _a;
|
|
575
|
-
return [
|
|
576
|
-
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
577
|
-
props.positionActionsColumn === 'first' &&
|
|
578
|
-
(props.enableRowActions ||
|
|
579
|
-
(props.enableEditing &&
|
|
580
|
-
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
581
|
-
'mrt-row-actions',
|
|
582
|
-
props.positionExpandColumn === 'first' &&
|
|
583
|
-
showExpandColumn(props) &&
|
|
584
|
-
'mrt-row-expand',
|
|
585
|
-
props.enableRowSelection && 'mrt-row-select',
|
|
586
|
-
props.enableRowNumbers && 'mrt-row-numbers',
|
|
587
|
-
].filter(Boolean);
|
|
588
|
-
};
|
|
589
|
-
const getTrailingDisplayColumnIds = (props) => {
|
|
590
|
-
var _a;
|
|
591
|
-
return [
|
|
592
|
-
props.positionActionsColumn === 'last' &&
|
|
593
|
-
(props.enableRowActions ||
|
|
594
|
-
(props.enableEditing &&
|
|
595
|
-
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
596
|
-
'mrt-row-actions',
|
|
597
|
-
props.positionExpandColumn === 'last' &&
|
|
598
|
-
showExpandColumn(props) &&
|
|
599
|
-
'mrt-row-expand',
|
|
600
|
-
];
|
|
601
|
-
};
|
|
602
|
-
const getDefaultColumnOrderIds = (props) => [
|
|
603
|
-
...getLeadingDisplayColumnIds(props),
|
|
604
|
-
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
605
|
-
...getTrailingDisplayColumnIds(props),
|
|
606
|
-
].filter(Boolean);
|
|
607
|
-
const getDefaultColumnFilterFn = (columnDef) => {
|
|
608
|
-
if (columnDef.filterVariant === 'multi-select')
|
|
609
|
-
return 'arrIncludesSome';
|
|
610
|
-
if (columnDef.filterVariant === 'range')
|
|
611
|
-
return 'betweenInclusive';
|
|
612
|
-
if (columnDef.filterVariant === 'select' ||
|
|
613
|
-
columnDef.filterVariant === 'checkbox')
|
|
614
|
-
return 'equals';
|
|
615
|
-
return 'fuzzy';
|
|
616
|
-
};
|
|
617
|
-
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
618
|
-
return (column.getIsPinned() === 'left' &&
|
|
619
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
620
|
-
};
|
|
621
|
-
const getIsFirstRightPinnedColumn = (column) => {
|
|
622
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
623
|
-
};
|
|
624
|
-
const getTotalRight = (table, column) => {
|
|
625
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
626
|
-
};
|
|
627
|
-
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
628
|
-
var _a, _b, _c, _d;
|
|
629
|
-
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
630
|
-
? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.97)
|
|
631
|
-
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
632
|
-
? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
633
|
-
: getIsFirstRightPinnedColumn(column)
|
|
634
|
-
? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
635
|
-
: undefined, left: column.getIsPinned() === 'left'
|
|
636
|
-
? `${column.getStart('left')}px`
|
|
637
|
-
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
638
|
-
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
639
|
-
? 0.5
|
|
640
|
-
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
641
|
-
? 'sticky'
|
|
642
|
-
: undefined, right: column.getIsPinned() === 'right'
|
|
643
|
-
? `${getTotalRight(table, column)}px`
|
|
644
|
-
: undefined, transition: `all ${column.getIsResizing() ? 0 : '0.1s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
645
|
-
? tableCellProps.sx(theme)
|
|
646
|
-
: 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() }));
|
|
647
|
-
};
|
|
648
|
-
const MRT_DefaultColumn = {
|
|
649
|
-
minSize: 40,
|
|
650
|
-
maxSize: 1000,
|
|
651
|
-
size: 180,
|
|
652
|
-
};
|
|
653
|
-
const MRT_DefaultDisplayColumn = {
|
|
654
|
-
columnDefType: 'display',
|
|
655
|
-
enableClickToCopy: false,
|
|
656
|
-
enableColumnActions: false,
|
|
657
|
-
enableColumnDragging: false,
|
|
658
|
-
enableColumnFilter: false,
|
|
659
|
-
enableColumnOrdering: false,
|
|
660
|
-
enableEditing: false,
|
|
661
|
-
enableGlobalFilter: false,
|
|
662
|
-
enableGrouping: false,
|
|
663
|
-
enableHiding: false,
|
|
664
|
-
enableResizing: false,
|
|
665
|
-
enableSorting: false,
|
|
666
|
-
};
|
|
667
|
-
|
|
668
578
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
669
579
|
var _a;
|
|
670
580
|
const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
|
|
@@ -1015,7 +925,7 @@ const commonIconButtonStyles = {
|
|
|
1015
925
|
height: '2rem',
|
|
1016
926
|
ml: '10px',
|
|
1017
927
|
opacity: 0.5,
|
|
1018
|
-
transition: 'opacity
|
|
928
|
+
transition: 'opacity 150ms',
|
|
1019
929
|
width: '2rem',
|
|
1020
930
|
'&:hover': {
|
|
1021
931
|
opacity: 1,
|
|
@@ -1046,7 +956,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
|
1046
956
|
|
|
1047
957
|
const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
1048
958
|
var _a;
|
|
1049
|
-
const { getState, options: { localization, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
959
|
+
const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
1050
960
|
const { density } = getState();
|
|
1051
961
|
const checkboxProps = !row
|
|
1052
962
|
? muiSelectAllCheckboxProps instanceof Function
|
|
@@ -1055,33 +965,33 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
1055
965
|
: muiSelectCheckboxProps instanceof Function
|
|
1056
966
|
? muiSelectCheckboxProps({ row, table })
|
|
1057
967
|
: muiSelectCheckboxProps;
|
|
968
|
+
const commonProps = Object.assign(Object.assign({ checked: selectAll
|
|
969
|
+
? selectAllMode === 'page'
|
|
970
|
+
? table.getIsAllPageRowsSelected()
|
|
971
|
+
: table.getIsAllRowsSelected()
|
|
972
|
+
: row === null || row === void 0 ? void 0 : row.getIsSelected(), inputProps: {
|
|
973
|
+
'aria-label': selectAll
|
|
974
|
+
? localization.toggleSelectAll
|
|
975
|
+
: localization.toggleSelectRow,
|
|
976
|
+
}, onChange: row
|
|
977
|
+
? row.getToggleSelectedHandler()
|
|
978
|
+
: selectAllMode === 'all'
|
|
979
|
+
? table.getToggleAllRowsSelectedHandler()
|
|
980
|
+
: table.getToggleAllPageRowsSelectedHandler(), size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
981
|
+
var _a;
|
|
982
|
+
e.stopPropagation();
|
|
983
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
984
|
+
}, 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
|
|
985
|
+
? checkboxProps.sx(theme)
|
|
986
|
+
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined });
|
|
1058
987
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
|
1059
988
|
? localization.toggleSelectAll
|
|
1060
|
-
: localization.toggleSelectRow) },
|
|
1061
|
-
|
|
1062
|
-
|
|
989
|
+
: localization.toggleSelectRow) }, enableMultiRowSelection === false ? (React__default["default"].createElement(material.Radio, Object.assign({}, commonProps))) : (React__default["default"].createElement(material.Checkbox, Object.assign({ indeterminate: selectAll
|
|
990
|
+
? table.getIsSomeRowsSelected() &&
|
|
991
|
+
!(selectAllMode === 'page'
|
|
1063
992
|
? table.getIsAllPageRowsSelected()
|
|
1064
|
-
: table.getIsAllRowsSelected()
|
|
1065
|
-
|
|
1066
|
-
? table.getIsSomeRowsSelected() &&
|
|
1067
|
-
!(selectAllMode === 'page'
|
|
1068
|
-
? table.getIsAllPageRowsSelected()
|
|
1069
|
-
: table.getIsAllRowsSelected())
|
|
1070
|
-
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected(), inputProps: {
|
|
1071
|
-
'aria-label': selectAll
|
|
1072
|
-
? localization.toggleSelectAll
|
|
1073
|
-
: localization.toggleSelectRow,
|
|
1074
|
-
}, onChange: row
|
|
1075
|
-
? row.getToggleSelectedHandler()
|
|
1076
|
-
: selectAllMode === 'all'
|
|
1077
|
-
? table.getToggleAllRowsSelectedHandler()
|
|
1078
|
-
: table.getToggleAllPageRowsSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1079
|
-
var _a;
|
|
1080
|
-
e.stopPropagation();
|
|
1081
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1082
|
-
}, 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
|
|
1083
|
-
? checkboxProps.sx(theme)
|
|
1084
|
-
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined }))));
|
|
993
|
+
: table.getIsAllRowsSelected())
|
|
994
|
+
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps)))));
|
|
1085
995
|
};
|
|
1086
996
|
|
|
1087
997
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
@@ -1344,7 +1254,7 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1344
1254
|
minHeight: '3.5rem',
|
|
1345
1255
|
overflow: 'hidden',
|
|
1346
1256
|
p: '0 !important',
|
|
1347
|
-
transition: 'all
|
|
1257
|
+
transition: 'all 150ms ease-in-out',
|
|
1348
1258
|
zIndex: 1,
|
|
1349
1259
|
});
|
|
1350
1260
|
const MRT_TopToolbar = ({ table }) => {
|
|
@@ -1454,13 +1364,13 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1454
1364
|
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
|
1455
1365
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1456
1366
|
React__default["default"].createElement(material.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 },
|
|
1457
|
-
React__default["default"].createElement(material.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
|
|
1367
|
+
React__default["default"].createElement(material.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': {
|
|
1458
1368
|
opacity: 1,
|
|
1459
1369
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
1460
1370
|
? iconButtonProps.sx(theme)
|
|
1461
1371
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
1462
1372
|
React__default["default"].createElement(MoreVertIcon, null))),
|
|
1463
|
-
React__default["default"].createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1373
|
+
anchorEl && (React__default["default"].createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))));
|
|
1464
1374
|
};
|
|
1465
1375
|
|
|
1466
1376
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
@@ -1798,7 +1708,9 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1798
1708
|
position: 'absolute',
|
|
1799
1709
|
right: '1px',
|
|
1800
1710
|
touchAction: 'none',
|
|
1801
|
-
transition: column.getIsResizing()
|
|
1711
|
+
transition: column.getIsResizing()
|
|
1712
|
+
? undefined
|
|
1713
|
+
: 'all 150ms ease-in-out',
|
|
1802
1714
|
userSelect: 'none',
|
|
1803
1715
|
zIndex: 4,
|
|
1804
1716
|
'&:active': {
|
|
@@ -2182,7 +2094,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2182
2094
|
: undefined,
|
|
2183
2095
|
}
|
|
2184
2096
|
: undefined;
|
|
2185
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : '
|
|
2097
|
+
return (React__default["default"].createElement(material.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'
|
|
2186
2098
|
? columnDefType === 'display'
|
|
2187
2099
|
? '0 0.5rem'
|
|
2188
2100
|
: '0.5rem'
|
|
@@ -2222,6 +2134,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2222
2134
|
_b.length,
|
|
2223
2135
|
")"))));
|
|
2224
2136
|
};
|
|
2137
|
+
const Memo_MRT_TableBodyCell = React.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
|
2225
2138
|
|
|
2226
2139
|
const MRT_TableDetailPanel = ({ row, table }) => {
|
|
2227
2140
|
const { getVisibleLeafColumns, options: { muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
|
|
@@ -2232,7 +2145,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2232
2145
|
? muiTableDetailPanelProps({ row, table })
|
|
2233
2146
|
: muiTableDetailPanelProps;
|
|
2234
2147
|
return (React__default["default"].createElement(material.TableRow, Object.assign({}, tableRowProps),
|
|
2235
|
-
React__default["default"].createElement(material.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
|
|
2148
|
+
React__default["default"].createElement(material.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
|
|
2236
2149
|
? tableCellProps.sx(theme)
|
|
2237
2150
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React__default["default"].createElement(material.Collapse, { in: row.getIsExpanded() }, renderDetailPanel({ row, table }))))));
|
|
2238
2151
|
};
|
|
@@ -2240,8 +2153,8 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2240
2153
|
const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
2241
2154
|
var _a, _b;
|
|
2242
2155
|
const theme = material.useTheme();
|
|
2243
|
-
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setHoveredRow, } = table;
|
|
2244
|
-
const { draggingRow, hoveredRow } = getState();
|
|
2156
|
+
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
|
|
2157
|
+
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
|
|
2245
2158
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
|
2246
2159
|
? muiTableBodyRowProps({ row, table })
|
|
2247
2160
|
: muiTableBodyRowProps;
|
|
@@ -2267,7 +2180,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2267
2180
|
if (virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.measureRef) {
|
|
2268
2181
|
virtualRow.measureRef = node;
|
|
2269
2182
|
}
|
|
2270
|
-
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: material.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
|
|
2183
|
+
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: material.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': {
|
|
2271
2184
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
|
|
2272
2185
|
? theme.palette.mode === 'dark'
|
|
2273
2186
|
? `${material.lighten(theme.palette.background.default, 0.12)}`
|
|
@@ -2275,13 +2188,29 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2275
2188
|
: undefined,
|
|
2276
2189
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2277
2190
|
? tableRowProps.sx(theme)
|
|
2278
|
-
: 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) =>
|
|
2191
|
+
: 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) => {
|
|
2192
|
+
const props = {
|
|
2193
|
+
cell,
|
|
2194
|
+
enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false,
|
|
2195
|
+
key: cell.id,
|
|
2196
|
+
rowIndex,
|
|
2197
|
+
rowRef,
|
|
2198
|
+
table,
|
|
2199
|
+
};
|
|
2200
|
+
return memoMode === 'cell' &&
|
|
2201
|
+
cell.column.columnDef.columnDefType === 'data' &&
|
|
2202
|
+
!draggingColumn &&
|
|
2203
|
+
!draggingRow &&
|
|
2204
|
+
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
|
2205
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (React__default["default"].createElement(Memo_MRT_TableBodyCell, Object.assign({}, props))) : (React__default["default"].createElement(MRT_TableBodyCell, Object.assign({}, props)));
|
|
2206
|
+
})),
|
|
2279
2207
|
renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2280
2208
|
};
|
|
2209
|
+
const Memo_MRT_TableBodyRow = React.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
|
|
2281
2210
|
|
|
2282
2211
|
const MRT_TableBody = ({ table }) => {
|
|
2283
2212
|
var _a;
|
|
2284
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2213
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, memoMode, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2285
2214
|
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2286
2215
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2287
2216
|
? muiTableBodyProps({ table })
|
|
@@ -2365,11 +2294,21 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2365
2294
|
const row = enableRowVirtualization
|
|
2366
2295
|
? rows[rowOrVirtualRow.index]
|
|
2367
2296
|
: rowOrVirtualRow;
|
|
2368
|
-
|
|
2297
|
+
const props = {
|
|
2298
|
+
key: row.id,
|
|
2299
|
+
row,
|
|
2300
|
+
rowIndex: enableRowVirtualization
|
|
2301
|
+
? rowOrVirtualRow.index
|
|
2302
|
+
: rowIndex,
|
|
2303
|
+
table,
|
|
2304
|
+
virtualRow: enableRowVirtualization ? rowOrVirtualRow : null,
|
|
2305
|
+
};
|
|
2306
|
+
return memoMode === 'row' ? (React__default["default"].createElement(Memo_MRT_TableBodyRow, Object.assign({}, props))) : (React__default["default"].createElement(MRT_TableBodyRow, Object.assign({}, props)));
|
|
2369
2307
|
}),
|
|
2370
2308
|
enableRowVirtualization && paddingBottom > 0 && (React__default["default"].createElement("tr", null,
|
|
2371
2309
|
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2372
2310
|
};
|
|
2311
|
+
const Memo_MRT_TableBody = React.memo(MRT_TableBody, () => true);
|
|
2373
2312
|
|
|
2374
2313
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2375
2314
|
var _a, _b, _c;
|
|
@@ -2432,7 +2371,7 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2432
2371
|
};
|
|
2433
2372
|
|
|
2434
2373
|
const MRT_Table = ({ table }) => {
|
|
2435
|
-
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
|
|
2374
|
+
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, memoMode, muiTableProps, }, } = table;
|
|
2436
2375
|
const { isFullScreen } = getState();
|
|
2437
2376
|
const tableProps = muiTableProps instanceof Function
|
|
2438
2377
|
? muiTableProps({ table })
|
|
@@ -2441,7 +2380,7 @@ const MRT_Table = ({ table }) => {
|
|
|
2441
2380
|
? tableProps.sx(theme)
|
|
2442
2381
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
|
2443
2382
|
enableTableHead && React__default["default"].createElement(MRT_TableHead, { table: table }),
|
|
2444
|
-
React__default["default"].createElement(MRT_TableBody, { table: table }),
|
|
2383
|
+
memoMode === 'table-body' ? (React__default["default"].createElement(Memo_MRT_TableBody, { table: table })) : (React__default["default"].createElement(MRT_TableBody, { table: table })),
|
|
2445
2384
|
enableTableFooter && React__default["default"].createElement(MRT_TableFooter, { table: table })));
|
|
2446
2385
|
};
|
|
2447
2386
|
|
|
@@ -2491,7 +2430,7 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2491
2430
|
//@ts-ignore
|
|
2492
2431
|
tablePaperProps.ref.current = ref;
|
|
2493
2432
|
}
|
|
2494
|
-
}, sx: (theme) => (Object.assign({ transition: 'all
|
|
2433
|
+
}, sx: (theme) => (Object.assign({ transition: 'all 150ms ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2495
2434
|
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2496
2435
|
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
|
2497
2436
|
? {
|
|
@@ -2582,7 +2521,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2582
2521
|
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React__default["default"].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' }),
|
|
2583
2522
|
columnOrder.includes('mrt-row-expand') &&
|
|
2584
2523
|
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React__default["default"].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' }),
|
|
2585
|
-
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React__default["default"].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' }),
|
|
2524
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll && props.enableMultiRowSelection ? (React__default["default"].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' }),
|
|
2586
2525
|
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' }),
|
|
2587
2526
|
].filter(Boolean);
|
|
2588
2527
|
}, [
|
|
@@ -2690,6 +2629,96 @@ const MRT_TableRoot = (props) => {
|
|
|
2690
2629
|
editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2691
2630
|
};
|
|
2692
2631
|
|
|
2632
|
+
const MRT_Localization_EN = {
|
|
2633
|
+
actions: 'Actions',
|
|
2634
|
+
and: 'and',
|
|
2635
|
+
cancel: 'Cancel',
|
|
2636
|
+
changeFilterMode: 'Change filter mode',
|
|
2637
|
+
changeSearchMode: 'Change search mode',
|
|
2638
|
+
clearFilter: 'Clear filter',
|
|
2639
|
+
clearSearch: 'Clear search',
|
|
2640
|
+
clearSort: 'Clear sort',
|
|
2641
|
+
clickToCopy: 'Click to copy',
|
|
2642
|
+
columnActions: 'Column Actions',
|
|
2643
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
2644
|
+
dropToGroupBy: 'Drop to group by {column}',
|
|
2645
|
+
edit: 'Edit',
|
|
2646
|
+
expand: 'Expand',
|
|
2647
|
+
expandAll: 'Expand all',
|
|
2648
|
+
filterArrIncludes: 'Includes',
|
|
2649
|
+
filterArrIncludesAll: 'Includes all',
|
|
2650
|
+
filterArrIncludesSome: 'Includes',
|
|
2651
|
+
filterBetween: 'Between',
|
|
2652
|
+
filterBetweenInclusive: 'Between Inclusive',
|
|
2653
|
+
filterByColumn: 'Filter by {column}',
|
|
2654
|
+
filterContains: 'Contains',
|
|
2655
|
+
filterEmpty: 'Empty',
|
|
2656
|
+
filterEndsWith: 'Ends With',
|
|
2657
|
+
filterEquals: 'Equals',
|
|
2658
|
+
filterEqualsString: 'Equals',
|
|
2659
|
+
filterFuzzy: 'Fuzzy',
|
|
2660
|
+
filterGreaterThan: 'Greater Than',
|
|
2661
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
2662
|
+
filterInNumberRange: 'Between',
|
|
2663
|
+
filterIncludesString: 'Contains',
|
|
2664
|
+
filterIncludesStringSensitive: 'Contains',
|
|
2665
|
+
filterLessThan: 'Less Than',
|
|
2666
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
2667
|
+
filterMode: 'Filter Mode: {filterType}',
|
|
2668
|
+
filterNotEmpty: 'Not Empty',
|
|
2669
|
+
filterNotEquals: 'Not Equals',
|
|
2670
|
+
filterStartsWith: 'Starts With',
|
|
2671
|
+
filterWeakEquals: 'Equals',
|
|
2672
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
2673
|
+
goToFirstPage: 'Go to first page',
|
|
2674
|
+
goToLastPage: 'Go to last page',
|
|
2675
|
+
goToNextPage: 'Go to next page',
|
|
2676
|
+
goToPreviousPage: 'Go to previous page',
|
|
2677
|
+
grab: 'Grab',
|
|
2678
|
+
groupByColumn: 'Group by {column}',
|
|
2679
|
+
groupedBy: 'Grouped by ',
|
|
2680
|
+
hideAll: 'Hide all',
|
|
2681
|
+
hideColumn: 'Hide {column} column',
|
|
2682
|
+
max: 'Max',
|
|
2683
|
+
min: 'Min',
|
|
2684
|
+
move: 'Move',
|
|
2685
|
+
noRecordsToDisplay: 'No records to display',
|
|
2686
|
+
noResultsFound: 'No results found',
|
|
2687
|
+
of: 'of',
|
|
2688
|
+
or: 'or',
|
|
2689
|
+
pinToLeft: 'Pin to left',
|
|
2690
|
+
pinToRight: 'Pin to right',
|
|
2691
|
+
resetColumnSize: 'Reset column size',
|
|
2692
|
+
resetOrder: 'Reset order',
|
|
2693
|
+
rowActions: 'Row Actions',
|
|
2694
|
+
rowNumber: '#',
|
|
2695
|
+
rowNumbers: 'Row Numbers',
|
|
2696
|
+
rowsPerPage: 'Rows per page',
|
|
2697
|
+
save: 'Save',
|
|
2698
|
+
search: 'Search',
|
|
2699
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
2700
|
+
select: 'Select',
|
|
2701
|
+
showAll: 'Show all',
|
|
2702
|
+
showAllColumns: 'Show all columns',
|
|
2703
|
+
showHideColumns: 'Show/Hide columns',
|
|
2704
|
+
showHideFilters: 'Show/Hide filters',
|
|
2705
|
+
showHideSearch: 'Show/Hide search',
|
|
2706
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
|
2707
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
|
2708
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
2709
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
2710
|
+
thenBy: ', then by ',
|
|
2711
|
+
toggleDensity: 'Toggle density',
|
|
2712
|
+
toggleFullScreen: 'Toggle full screen',
|
|
2713
|
+
toggleSelectAll: 'Toggle select all',
|
|
2714
|
+
toggleSelectRow: 'Toggle select row',
|
|
2715
|
+
toggleVisibility: 'Toggle visibility',
|
|
2716
|
+
ungroupByColumn: 'Ungroup by {column}',
|
|
2717
|
+
unpin: 'Unpin',
|
|
2718
|
+
unpinAll: 'Unpin all',
|
|
2719
|
+
unsorted: 'Unsorted',
|
|
2720
|
+
};
|
|
2721
|
+
|
|
2693
2722
|
const MaterialReactTable = (_a) => {
|
|
2694
2723
|
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"]);
|
|
2695
2724
|
const _icons = React.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), []);
|