material-react-table 3.0.0-beta.0 → 3.0.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/index.d.ts +19 -4
- package/dist/index.esm.js +224 -166
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +224 -166
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/body/MRT_TableBodyCell.tsx +8 -3
- package/src/components/footer/MRT_TableFooterCell.tsx +7 -3
- package/src/components/head/MRT_TableHeadCell.tsx +8 -3
- package/src/components/inputs/MRT_FilterTextField.tsx +4 -0
- package/src/components/menus/MRT_ActionMenuItem.tsx +1 -0
- package/src/types.ts +9 -3
- package/src/utils/cell.utils.ts +77 -15
package/dist/index.d.ts
CHANGED
@@ -991,9 +991,6 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
|
|
991
991
|
staticRowIndex?: number;
|
992
992
|
table: MRT_TableInstance<TData>;
|
993
993
|
}) => CheckboxProps | RadioProps) | (CheckboxProps | RadioProps);
|
994
|
-
/**
|
995
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
996
|
-
*/
|
997
994
|
muiSkeletonProps?: ((props: {
|
998
995
|
cell: MRT_Cell<TData>;
|
999
996
|
column: MRT_Column<TData>;
|
@@ -1116,6 +1113,9 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
|
|
1116
1113
|
renderCaption?: ((props: {
|
1117
1114
|
table: MRT_TableInstance<TData>;
|
1118
1115
|
}) => ReactNode) | ReactNode;
|
1116
|
+
/**
|
1117
|
+
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1118
|
+
*/
|
1119
1119
|
renderCellActionMenuItems?: (props: {
|
1120
1120
|
cell: MRT_Cell<TData>;
|
1121
1121
|
closeMenu: () => void;
|
@@ -1126,12 +1126,18 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
|
|
1126
1126
|
staticRowIndex?: number;
|
1127
1127
|
table: MRT_TableInstance<TData>;
|
1128
1128
|
}) => ReactNode[];
|
1129
|
+
/**
|
1130
|
+
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1131
|
+
*/
|
1129
1132
|
renderColumnActionsMenuItems?: (props: {
|
1130
1133
|
closeMenu: () => void;
|
1131
1134
|
column: MRT_Column<TData>;
|
1132
1135
|
internalColumnMenuItems: ReactNode[];
|
1133
1136
|
table: MRT_TableInstance<TData>;
|
1134
1137
|
}) => ReactNode[];
|
1138
|
+
/**
|
1139
|
+
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1140
|
+
*/
|
1135
1141
|
renderColumnFilterModeMenuItems?: (props: {
|
1136
1142
|
column: MRT_Column<TData>;
|
1137
1143
|
internalFilterOptions: MRT_InternalFilterOption[];
|
@@ -1211,7 +1217,16 @@ declare const openEditingCell: <TData extends MRT_RowData>({ cell, table, }: {
|
|
1211
1217
|
cell: MRT_Cell<TData>;
|
1212
1218
|
table: MRT_TableInstance<TData>;
|
1213
1219
|
}) => void;
|
1214
|
-
declare const cellNavigation:
|
1220
|
+
declare const cellNavigation: <TData extends MRT_RowData = MRT_RowData>({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }: {
|
1221
|
+
cell?: MRT_Cell<TData>;
|
1222
|
+
header?: MRT_Header<TData>;
|
1223
|
+
cellElements?: Array<HTMLTableCellElement>;
|
1224
|
+
cellValue?: string;
|
1225
|
+
containerElement?: HTMLTableElement;
|
1226
|
+
event: React.KeyboardEvent<HTMLTableCellElement>;
|
1227
|
+
parentElement?: HTMLTableRowElement;
|
1228
|
+
table: MRT_TableInstance<TData>;
|
1229
|
+
}) => void;
|
1215
1230
|
|
1216
1231
|
declare const getColumnId: <TData extends MRT_RowData>(columnDef: MRT_ColumnDef<TData>) => string;
|
1217
1232
|
declare const getAllLeafColumnDefs: <TData extends MRT_RowData>(columns: MRT_ColumnDef<TData>[]) => MRT_ColumnDef<TData>[];
|
package/dist/index.esm.js
CHANGED
@@ -235,6 +235,20 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
235
235
|
[getColumnId(col)]: '',
|
236
236
|
}))), rowIndex, depth, subRows, parentId);
|
237
237
|
|
238
|
+
const fuzzy$1 = (rowA, rowB, columnId) => {
|
239
|
+
let dir = 0;
|
240
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
241
|
+
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
242
|
+
}
|
243
|
+
// Provide a fallback for when the item ranks are equal
|
244
|
+
return dir === 0
|
245
|
+
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
246
|
+
: dir;
|
247
|
+
};
|
248
|
+
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
|
249
|
+
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
250
|
+
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
251
|
+
|
238
252
|
const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
|
239
253
|
const getValueAndLabel = (option) => {
|
240
254
|
var _a, _b;
|
@@ -253,161 +267,6 @@ const getValueAndLabel = (option) => {
|
|
253
267
|
return { label, value };
|
254
268
|
};
|
255
269
|
|
256
|
-
const isCellEditable = ({ cell, table, }) => {
|
257
|
-
const { enableEditing } = table.options;
|
258
|
-
const { column: { columnDef }, row, } = cell;
|
259
|
-
return (!cell.getIsPlaceholder() &&
|
260
|
-
parseFromValuesOrFunc(enableEditing, row) &&
|
261
|
-
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
|
262
|
-
};
|
263
|
-
const openEditingCell = ({ cell, table, }) => {
|
264
|
-
const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
|
265
|
-
const { column } = cell;
|
266
|
-
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
267
|
-
table.setEditingCell(cell);
|
268
|
-
queueMicrotask(() => {
|
269
|
-
var _a;
|
270
|
-
const textField = editInputRefs.current[column.id];
|
271
|
-
if (textField) {
|
272
|
-
textField.focus();
|
273
|
-
(_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
|
274
|
-
}
|
275
|
-
});
|
276
|
-
}
|
277
|
-
};
|
278
|
-
const cellNavigation = (e) => {
|
279
|
-
if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(e.key)) {
|
280
|
-
e.preventDefault();
|
281
|
-
const currentCell = e.currentTarget;
|
282
|
-
const currentRow = currentCell.closest('tr');
|
283
|
-
const tableElement = currentCell.closest('table');
|
284
|
-
const allCells = Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
|
285
|
-
const currentCellIndex = allCells.indexOf(currentCell);
|
286
|
-
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
|
287
|
-
let nextCell = undefined;
|
288
|
-
//home/end first or last cell in row
|
289
|
-
const findEdgeCell = (rowIndex, edge) => {
|
290
|
-
var _a, _b, _c;
|
291
|
-
const row = rowIndex === 'c'
|
292
|
-
? currentRow
|
293
|
-
: rowIndex === 'f'
|
294
|
-
? (_a = currentCell.closest('table')) === null || _a === void 0 ? void 0 : _a.querySelector('tr')
|
295
|
-
: (_c = (_b = currentCell.closest('table')) === null || _b === void 0 ? void 0 : _b.lastElementChild) === null || _c === void 0 ? void 0 : _c.lastElementChild;
|
296
|
-
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
|
297
|
-
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
|
298
|
-
return targetCell;
|
299
|
-
};
|
300
|
-
const findAdjacentCell = (columnIndex, searchDirection) => {
|
301
|
-
const searchArray = searchDirection === 'f'
|
302
|
-
? allCells.slice(currentCellIndex + 1)
|
303
|
-
: allCells.slice(0, currentCellIndex).reverse();
|
304
|
-
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
|
305
|
-
};
|
306
|
-
switch (e.key) {
|
307
|
-
case 'ArrowRight':
|
308
|
-
nextCell = findAdjacentCell(currentIndex + 1, 'f');
|
309
|
-
break;
|
310
|
-
case 'ArrowLeft':
|
311
|
-
nextCell = findAdjacentCell(currentIndex - 1, 'b');
|
312
|
-
break;
|
313
|
-
case 'ArrowUp':
|
314
|
-
nextCell = findAdjacentCell(currentIndex, 'b');
|
315
|
-
break;
|
316
|
-
case 'ArrowDown':
|
317
|
-
nextCell = findAdjacentCell(currentIndex, 'f');
|
318
|
-
break;
|
319
|
-
case 'Home':
|
320
|
-
nextCell = findEdgeCell(e.ctrlKey ? 'f' : 'c', 'f');
|
321
|
-
break;
|
322
|
-
case 'End':
|
323
|
-
nextCell = findEdgeCell(e.ctrlKey ? 'l' : 'c', 'l');
|
324
|
-
break;
|
325
|
-
}
|
326
|
-
if (nextCell) {
|
327
|
-
nextCell.focus();
|
328
|
-
}
|
329
|
-
}
|
330
|
-
};
|
331
|
-
|
332
|
-
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
333
|
-
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
334
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
|
335
|
-
}
|
336
|
-
const showRowPinningColumn = (tableOptions) => {
|
337
|
-
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
338
|
-
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
|
339
|
-
};
|
340
|
-
const showRowDragColumn = (tableOptions) => {
|
341
|
-
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
342
|
-
return !!(enableRowDragging || enableRowOrdering);
|
343
|
-
};
|
344
|
-
const showRowExpandColumn = (tableOptions) => {
|
345
|
-
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
346
|
-
return !!(enableExpanding ||
|
347
|
-
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
348
|
-
renderDetailPanel);
|
349
|
-
};
|
350
|
-
const showRowActionsColumn = (tableOptions) => {
|
351
|
-
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
|
352
|
-
return !!(enableRowActions ||
|
353
|
-
(creatingRow && createDisplayMode === 'row') ||
|
354
|
-
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
|
355
|
-
};
|
356
|
-
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
|
357
|
-
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
|
358
|
-
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
|
359
|
-
const getLeadingDisplayColumnIds = (tableOptions) => [
|
360
|
-
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
|
361
|
-
showRowDragColumn(tableOptions) && 'mrt-row-drag',
|
362
|
-
tableOptions.positionActionsColumn === 'first' &&
|
363
|
-
showRowActionsColumn(tableOptions) &&
|
364
|
-
'mrt-row-actions',
|
365
|
-
tableOptions.positionExpandColumn === 'first' &&
|
366
|
-
showRowExpandColumn(tableOptions) &&
|
367
|
-
'mrt-row-expand',
|
368
|
-
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
|
369
|
-
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
|
370
|
-
].filter(Boolean);
|
371
|
-
const getTrailingDisplayColumnIds = (tableOptions) => [
|
372
|
-
tableOptions.positionActionsColumn === 'last' &&
|
373
|
-
showRowActionsColumn(tableOptions) &&
|
374
|
-
'mrt-row-actions',
|
375
|
-
tableOptions.positionExpandColumn === 'last' &&
|
376
|
-
showRowExpandColumn(tableOptions) &&
|
377
|
-
'mrt-row-expand',
|
378
|
-
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
|
379
|
-
].filter(Boolean);
|
380
|
-
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
381
|
-
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
|
382
|
-
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
383
|
-
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
384
|
-
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
|
385
|
-
let allLeafColumnDefIds = reset
|
386
|
-
? defaultColumnDefIds
|
387
|
-
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
388
|
-
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
|
389
|
-
!trailingDisplayColIds.includes(colId));
|
390
|
-
return [
|
391
|
-
...leadingDisplayColIds,
|
392
|
-
...allLeafColumnDefIds,
|
393
|
-
...trailingDisplayColIds,
|
394
|
-
];
|
395
|
-
};
|
396
|
-
|
397
|
-
const fuzzy$1 = (rowA, rowB, columnId) => {
|
398
|
-
let dir = 0;
|
399
|
-
if (rowA.columnFiltersMeta[columnId]) {
|
400
|
-
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
401
|
-
}
|
402
|
-
// Provide a fallback for when the item ranks are equal
|
403
|
-
return dir === 0
|
404
|
-
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
405
|
-
: dir;
|
406
|
-
};
|
407
|
-
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
|
408
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
409
|
-
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
410
|
-
|
411
270
|
const getMRT_Rows = (table, all) => {
|
412
271
|
const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
|
413
272
|
const { creatingRow, pagination } = getState();
|
@@ -548,6 +407,187 @@ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
|
|
548
407
|
lastSelectedRowId.current = null;
|
549
408
|
};
|
550
409
|
|
410
|
+
const isCellEditable = ({ cell, table, }) => {
|
411
|
+
const { enableEditing } = table.options;
|
412
|
+
const { column: { columnDef }, row, } = cell;
|
413
|
+
return (!cell.getIsPlaceholder() &&
|
414
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
415
|
+
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
|
416
|
+
};
|
417
|
+
const openEditingCell = ({ cell, table, }) => {
|
418
|
+
const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
|
419
|
+
const { column } = cell;
|
420
|
+
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
421
|
+
table.setEditingCell(cell);
|
422
|
+
queueMicrotask(() => {
|
423
|
+
var _a;
|
424
|
+
const textField = editInputRefs.current[column.id];
|
425
|
+
if (textField) {
|
426
|
+
textField.focus();
|
427
|
+
(_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
|
428
|
+
}
|
429
|
+
});
|
430
|
+
}
|
431
|
+
};
|
432
|
+
const cellNavigation = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
|
433
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
434
|
+
if (cellValue && (event.ctrlKey || event.metaKey) && event.key === 'c') {
|
435
|
+
navigator.clipboard.writeText(cellValue);
|
436
|
+
}
|
437
|
+
else if (['Enter', ' '].includes(event.key)) {
|
438
|
+
if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
|
439
|
+
getMRT_RowSelectionHandler({
|
440
|
+
row: cell.row,
|
441
|
+
table,
|
442
|
+
//@ts-ignore
|
443
|
+
staticRowIndex: +event.target.getAttribute('data-index'),
|
444
|
+
})(event);
|
445
|
+
}
|
446
|
+
else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
|
447
|
+
table.options.enableSelectAll) {
|
448
|
+
getMRT_SelectAllHandler({
|
449
|
+
table,
|
450
|
+
})(event);
|
451
|
+
}
|
452
|
+
else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
|
453
|
+
(cell.row.getCanExpand() ||
|
454
|
+
((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
|
455
|
+
cell.row.toggleExpanded();
|
456
|
+
}
|
457
|
+
else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
|
458
|
+
table.options.enableExpandAll) {
|
459
|
+
table.toggleAllRowsExpanded();
|
460
|
+
}
|
461
|
+
else if ((_g = header === null || header === void 0 ? void 0 : header.column) === null || _g === void 0 ? void 0 : _g.getCanSort()) {
|
462
|
+
header.column.toggleSorting();
|
463
|
+
}
|
464
|
+
else if ((cell === null || cell === void 0 ? void 0 : cell.column.id) === 'mrt-row-pin') {
|
465
|
+
cell.row.getIsPinned()
|
466
|
+
? cell.row.pin(false)
|
467
|
+
: cell.row.pin(((_h = table.options.rowPinningDisplayMode) === null || _h === void 0 ? void 0 : _h.includes('bottom'))
|
468
|
+
? 'bottom'
|
469
|
+
: 'top');
|
470
|
+
}
|
471
|
+
}
|
472
|
+
else if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) {
|
473
|
+
event.preventDefault();
|
474
|
+
const currentCell = event.currentTarget;
|
475
|
+
const currentRow = parentElement || currentCell.closest('tr');
|
476
|
+
const tableElement = containerElement || currentCell.closest('table');
|
477
|
+
const allCells = cellElements ||
|
478
|
+
Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
|
479
|
+
const currentCellIndex = allCells.indexOf(currentCell);
|
480
|
+
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
|
481
|
+
let nextCell = undefined;
|
482
|
+
//home/end first or last cell in row
|
483
|
+
const findEdgeCell = (rowIndex, edge) => {
|
484
|
+
var _a;
|
485
|
+
const row = rowIndex === 'c'
|
486
|
+
? currentRow
|
487
|
+
: rowIndex === 'f'
|
488
|
+
? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
|
489
|
+
: (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
|
490
|
+
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
|
491
|
+
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
|
492
|
+
return targetCell;
|
493
|
+
};
|
494
|
+
const findAdjacentCell = (columnIndex, searchDirection) => {
|
495
|
+
const searchArray = searchDirection === 'f'
|
496
|
+
? allCells.slice(currentCellIndex + 1)
|
497
|
+
: allCells.slice(0, currentCellIndex).reverse();
|
498
|
+
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
|
499
|
+
};
|
500
|
+
switch (event.key) {
|
501
|
+
case 'ArrowRight':
|
502
|
+
nextCell = findAdjacentCell(currentIndex + 1, 'f');
|
503
|
+
break;
|
504
|
+
case 'ArrowLeft':
|
505
|
+
nextCell = findAdjacentCell(currentIndex - 1, 'b');
|
506
|
+
break;
|
507
|
+
case 'ArrowUp':
|
508
|
+
nextCell = findAdjacentCell(currentIndex, 'b');
|
509
|
+
break;
|
510
|
+
case 'ArrowDown':
|
511
|
+
nextCell = findAdjacentCell(currentIndex, 'f');
|
512
|
+
break;
|
513
|
+
case 'Home':
|
514
|
+
nextCell = findEdgeCell(event.ctrlKey ? 'f' : 'c', 'f');
|
515
|
+
break;
|
516
|
+
case 'End':
|
517
|
+
nextCell = findEdgeCell(event.ctrlKey ? 'l' : 'c', 'l');
|
518
|
+
break;
|
519
|
+
}
|
520
|
+
if (nextCell) {
|
521
|
+
nextCell.focus();
|
522
|
+
}
|
523
|
+
}
|
524
|
+
};
|
525
|
+
|
526
|
+
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
527
|
+
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
528
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
|
529
|
+
}
|
530
|
+
const showRowPinningColumn = (tableOptions) => {
|
531
|
+
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
532
|
+
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
|
533
|
+
};
|
534
|
+
const showRowDragColumn = (tableOptions) => {
|
535
|
+
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
536
|
+
return !!(enableRowDragging || enableRowOrdering);
|
537
|
+
};
|
538
|
+
const showRowExpandColumn = (tableOptions) => {
|
539
|
+
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
540
|
+
return !!(enableExpanding ||
|
541
|
+
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
542
|
+
renderDetailPanel);
|
543
|
+
};
|
544
|
+
const showRowActionsColumn = (tableOptions) => {
|
545
|
+
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
|
546
|
+
return !!(enableRowActions ||
|
547
|
+
(creatingRow && createDisplayMode === 'row') ||
|
548
|
+
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
|
549
|
+
};
|
550
|
+
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
|
551
|
+
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
|
552
|
+
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
|
553
|
+
const getLeadingDisplayColumnIds = (tableOptions) => [
|
554
|
+
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
|
555
|
+
showRowDragColumn(tableOptions) && 'mrt-row-drag',
|
556
|
+
tableOptions.positionActionsColumn === 'first' &&
|
557
|
+
showRowActionsColumn(tableOptions) &&
|
558
|
+
'mrt-row-actions',
|
559
|
+
tableOptions.positionExpandColumn === 'first' &&
|
560
|
+
showRowExpandColumn(tableOptions) &&
|
561
|
+
'mrt-row-expand',
|
562
|
+
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
|
563
|
+
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
|
564
|
+
].filter(Boolean);
|
565
|
+
const getTrailingDisplayColumnIds = (tableOptions) => [
|
566
|
+
tableOptions.positionActionsColumn === 'last' &&
|
567
|
+
showRowActionsColumn(tableOptions) &&
|
568
|
+
'mrt-row-actions',
|
569
|
+
tableOptions.positionExpandColumn === 'last' &&
|
570
|
+
showRowExpandColumn(tableOptions) &&
|
571
|
+
'mrt-row-expand',
|
572
|
+
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
|
573
|
+
].filter(Boolean);
|
574
|
+
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
575
|
+
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
|
576
|
+
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
577
|
+
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
578
|
+
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
|
579
|
+
let allLeafColumnDefIds = reset
|
580
|
+
? defaultColumnDefIds
|
581
|
+
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
582
|
+
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
|
583
|
+
!trailingDisplayColIds.includes(colId));
|
584
|
+
return [
|
585
|
+
...leadingDisplayColIds,
|
586
|
+
...allLeafColumnDefIds,
|
587
|
+
...trailingDisplayColIds,
|
588
|
+
];
|
589
|
+
};
|
590
|
+
|
551
591
|
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
552
592
|
|
553
593
|
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
@@ -829,7 +869,7 @@ const MRT_ActionMenuItem = (_a) => {
|
|
829
869
|
minWidth: '120px',
|
830
870
|
my: 0,
|
831
871
|
py: '6px',
|
832
|
-
} }, rest, { children: [jsxs(Box, { sx: {
|
872
|
+
}, tabIndex: 0 }, rest, { children: [jsxs(Box, { sx: {
|
833
873
|
alignItems: 'center',
|
834
874
|
display: 'flex',
|
835
875
|
}, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
|
@@ -2159,12 +2199,17 @@ const MRT_TableBodyCell = (_a) => {
|
|
2159
2199
|
table.refs.actionCellRef.current = e.currentTarget;
|
2160
2200
|
}
|
2161
2201
|
};
|
2162
|
-
const handleKeyDown = (
|
2202
|
+
const handleKeyDown = (event) => {
|
2163
2203
|
var _a;
|
2164
2204
|
if (enableCellNavigation) {
|
2165
|
-
cellNavigation(
|
2205
|
+
cellNavigation({
|
2206
|
+
cell,
|
2207
|
+
cellValue: cell.getValue(),
|
2208
|
+
event,
|
2209
|
+
table,
|
2210
|
+
});
|
2166
2211
|
}
|
2167
|
-
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps,
|
2212
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2168
2213
|
};
|
2169
2214
|
return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableCellNavigation ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
|
2170
2215
|
outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
|
@@ -2437,12 +2482,16 @@ const MRT_TableFooterCell = (_a) => {
|
|
2437
2482
|
column.getIsPinned();
|
2438
2483
|
const args = { column, table };
|
2439
2484
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2440
|
-
const handleKeyDown = (
|
2485
|
+
const handleKeyDown = (event) => {
|
2441
2486
|
var _a;
|
2442
2487
|
if (enableCellNavigation) {
|
2443
|
-
cellNavigation(
|
2488
|
+
cellNavigation({
|
2489
|
+
event,
|
2490
|
+
cellValue: footer.column.columnDef.footer,
|
2491
|
+
table,
|
2492
|
+
});
|
2444
2493
|
}
|
2445
|
-
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps,
|
2494
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2446
2495
|
};
|
2447
2496
|
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
|
2448
2497
|
? 'center'
|
@@ -3064,7 +3113,11 @@ const MRT_FilterTextField = (_a) => {
|
|
3064
3113
|
}
|
3065
3114
|
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
3066
3115
|
? undefined
|
3067
|
-
: filterPlaceholder, variant: 'standard' }, textFieldProps), {
|
3116
|
+
: filterPlaceholder, variant: 'standard' }, textFieldProps), { onKeyDown: (e) => {
|
3117
|
+
var _a;
|
3118
|
+
e.stopPropagation();
|
3119
|
+
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
3120
|
+
}, sx: (theme) => (Object.assign({ minWidth: isDateFilter
|
3068
3121
|
? '160px'
|
3069
3122
|
: enableColumnFilterModes && rangeFilterIndex === 0
|
3070
3123
|
? '110px'
|
@@ -3443,12 +3496,17 @@ const MRT_TableHeadCell = (_a) => {
|
|
3443
3496
|
e.preventDefault();
|
3444
3497
|
}
|
3445
3498
|
};
|
3446
|
-
const handleKeyDown = (
|
3499
|
+
const handleKeyDown = (event) => {
|
3447
3500
|
var _a;
|
3448
3501
|
if (enableCellNavigation) {
|
3449
|
-
cellNavigation(
|
3502
|
+
cellNavigation({
|
3503
|
+
event,
|
3504
|
+
cellValue: header.column.columnDef.header,
|
3505
|
+
table,
|
3506
|
+
header,
|
3507
|
+
});
|
3450
3508
|
}
|
3451
|
-
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps,
|
3509
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
3452
3510
|
};
|
3453
3511
|
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3454
3512
|
column,
|