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.js
CHANGED
@@ -325,6 +325,20 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
325
325
|
[getColumnId(col)]: '',
|
326
326
|
}))), rowIndex, depth, subRows, parentId);
|
327
327
|
|
328
|
+
const fuzzy$1 = (rowA, rowB, columnId) => {
|
329
|
+
let dir = 0;
|
330
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
331
|
+
dir = matchSorterUtils.compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
332
|
+
}
|
333
|
+
// Provide a fallback for when the item ranks are equal
|
334
|
+
return dir === 0
|
335
|
+
? reactTable.sortingFns.alphanumeric(rowA, rowB, columnId)
|
336
|
+
: dir;
|
337
|
+
};
|
338
|
+
const MRT_SortingFns = Object.assign(Object.assign({}, reactTable.sortingFns), { fuzzy: fuzzy$1 });
|
339
|
+
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
340
|
+
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
341
|
+
|
328
342
|
const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
|
329
343
|
const getValueAndLabel = (option) => {
|
330
344
|
var _a, _b;
|
@@ -343,161 +357,6 @@ const getValueAndLabel = (option) => {
|
|
343
357
|
return { label, value };
|
344
358
|
};
|
345
359
|
|
346
|
-
const isCellEditable = ({ cell, table, }) => {
|
347
|
-
const { enableEditing } = table.options;
|
348
|
-
const { column: { columnDef }, row, } = cell;
|
349
|
-
return (!cell.getIsPlaceholder() &&
|
350
|
-
parseFromValuesOrFunc(enableEditing, row) &&
|
351
|
-
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
|
352
|
-
};
|
353
|
-
const openEditingCell = ({ cell, table, }) => {
|
354
|
-
const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
|
355
|
-
const { column } = cell;
|
356
|
-
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
357
|
-
table.setEditingCell(cell);
|
358
|
-
queueMicrotask(() => {
|
359
|
-
var _a;
|
360
|
-
const textField = editInputRefs.current[column.id];
|
361
|
-
if (textField) {
|
362
|
-
textField.focus();
|
363
|
-
(_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
|
364
|
-
}
|
365
|
-
});
|
366
|
-
}
|
367
|
-
};
|
368
|
-
const cellNavigation = (e) => {
|
369
|
-
if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(e.key)) {
|
370
|
-
e.preventDefault();
|
371
|
-
const currentCell = e.currentTarget;
|
372
|
-
const currentRow = currentCell.closest('tr');
|
373
|
-
const tableElement = currentCell.closest('table');
|
374
|
-
const allCells = Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
|
375
|
-
const currentCellIndex = allCells.indexOf(currentCell);
|
376
|
-
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
|
377
|
-
let nextCell = undefined;
|
378
|
-
//home/end first or last cell in row
|
379
|
-
const findEdgeCell = (rowIndex, edge) => {
|
380
|
-
var _a, _b, _c;
|
381
|
-
const row = rowIndex === 'c'
|
382
|
-
? currentRow
|
383
|
-
: rowIndex === 'f'
|
384
|
-
? (_a = currentCell.closest('table')) === null || _a === void 0 ? void 0 : _a.querySelector('tr')
|
385
|
-
: (_c = (_b = currentCell.closest('table')) === null || _b === void 0 ? void 0 : _b.lastElementChild) === null || _c === void 0 ? void 0 : _c.lastElementChild;
|
386
|
-
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
|
387
|
-
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
|
388
|
-
return targetCell;
|
389
|
-
};
|
390
|
-
const findAdjacentCell = (columnIndex, searchDirection) => {
|
391
|
-
const searchArray = searchDirection === 'f'
|
392
|
-
? allCells.slice(currentCellIndex + 1)
|
393
|
-
: allCells.slice(0, currentCellIndex).reverse();
|
394
|
-
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
|
395
|
-
};
|
396
|
-
switch (e.key) {
|
397
|
-
case 'ArrowRight':
|
398
|
-
nextCell = findAdjacentCell(currentIndex + 1, 'f');
|
399
|
-
break;
|
400
|
-
case 'ArrowLeft':
|
401
|
-
nextCell = findAdjacentCell(currentIndex - 1, 'b');
|
402
|
-
break;
|
403
|
-
case 'ArrowUp':
|
404
|
-
nextCell = findAdjacentCell(currentIndex, 'b');
|
405
|
-
break;
|
406
|
-
case 'ArrowDown':
|
407
|
-
nextCell = findAdjacentCell(currentIndex, 'f');
|
408
|
-
break;
|
409
|
-
case 'Home':
|
410
|
-
nextCell = findEdgeCell(e.ctrlKey ? 'f' : 'c', 'f');
|
411
|
-
break;
|
412
|
-
case 'End':
|
413
|
-
nextCell = findEdgeCell(e.ctrlKey ? 'l' : 'c', 'l');
|
414
|
-
break;
|
415
|
-
}
|
416
|
-
if (nextCell) {
|
417
|
-
nextCell.focus();
|
418
|
-
}
|
419
|
-
}
|
420
|
-
};
|
421
|
-
|
422
|
-
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
423
|
-
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
424
|
-
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 });
|
425
|
-
}
|
426
|
-
const showRowPinningColumn = (tableOptions) => {
|
427
|
-
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
428
|
-
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
|
429
|
-
};
|
430
|
-
const showRowDragColumn = (tableOptions) => {
|
431
|
-
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
432
|
-
return !!(enableRowDragging || enableRowOrdering);
|
433
|
-
};
|
434
|
-
const showRowExpandColumn = (tableOptions) => {
|
435
|
-
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
436
|
-
return !!(enableExpanding ||
|
437
|
-
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
438
|
-
renderDetailPanel);
|
439
|
-
};
|
440
|
-
const showRowActionsColumn = (tableOptions) => {
|
441
|
-
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
|
442
|
-
return !!(enableRowActions ||
|
443
|
-
(creatingRow && createDisplayMode === 'row') ||
|
444
|
-
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
|
445
|
-
};
|
446
|
-
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
|
447
|
-
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
|
448
|
-
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
|
449
|
-
const getLeadingDisplayColumnIds = (tableOptions) => [
|
450
|
-
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
|
451
|
-
showRowDragColumn(tableOptions) && 'mrt-row-drag',
|
452
|
-
tableOptions.positionActionsColumn === 'first' &&
|
453
|
-
showRowActionsColumn(tableOptions) &&
|
454
|
-
'mrt-row-actions',
|
455
|
-
tableOptions.positionExpandColumn === 'first' &&
|
456
|
-
showRowExpandColumn(tableOptions) &&
|
457
|
-
'mrt-row-expand',
|
458
|
-
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
|
459
|
-
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
|
460
|
-
].filter(Boolean);
|
461
|
-
const getTrailingDisplayColumnIds = (tableOptions) => [
|
462
|
-
tableOptions.positionActionsColumn === 'last' &&
|
463
|
-
showRowActionsColumn(tableOptions) &&
|
464
|
-
'mrt-row-actions',
|
465
|
-
tableOptions.positionExpandColumn === 'last' &&
|
466
|
-
showRowExpandColumn(tableOptions) &&
|
467
|
-
'mrt-row-expand',
|
468
|
-
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
|
469
|
-
].filter(Boolean);
|
470
|
-
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
471
|
-
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
|
472
|
-
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
473
|
-
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
474
|
-
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
|
475
|
-
let allLeafColumnDefIds = reset
|
476
|
-
? defaultColumnDefIds
|
477
|
-
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
478
|
-
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
|
479
|
-
!trailingDisplayColIds.includes(colId));
|
480
|
-
return [
|
481
|
-
...leadingDisplayColIds,
|
482
|
-
...allLeafColumnDefIds,
|
483
|
-
...trailingDisplayColIds,
|
484
|
-
];
|
485
|
-
};
|
486
|
-
|
487
|
-
const fuzzy$1 = (rowA, rowB, columnId) => {
|
488
|
-
let dir = 0;
|
489
|
-
if (rowA.columnFiltersMeta[columnId]) {
|
490
|
-
dir = matchSorterUtils.compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
491
|
-
}
|
492
|
-
// Provide a fallback for when the item ranks are equal
|
493
|
-
return dir === 0
|
494
|
-
? reactTable.sortingFns.alphanumeric(rowA, rowB, columnId)
|
495
|
-
: dir;
|
496
|
-
};
|
497
|
-
const MRT_SortingFns = Object.assign(Object.assign({}, reactTable.sortingFns), { fuzzy: fuzzy$1 });
|
498
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
499
|
-
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
500
|
-
|
501
360
|
const getMRT_Rows = (table, all) => {
|
502
361
|
const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
|
503
362
|
const { creatingRow, pagination } = getState();
|
@@ -638,6 +497,187 @@ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
|
|
638
497
|
lastSelectedRowId.current = null;
|
639
498
|
};
|
640
499
|
|
500
|
+
const isCellEditable = ({ cell, table, }) => {
|
501
|
+
const { enableEditing } = table.options;
|
502
|
+
const { column: { columnDef }, row, } = cell;
|
503
|
+
return (!cell.getIsPlaceholder() &&
|
504
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
505
|
+
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
|
506
|
+
};
|
507
|
+
const openEditingCell = ({ cell, table, }) => {
|
508
|
+
const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
|
509
|
+
const { column } = cell;
|
510
|
+
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
511
|
+
table.setEditingCell(cell);
|
512
|
+
queueMicrotask(() => {
|
513
|
+
var _a;
|
514
|
+
const textField = editInputRefs.current[column.id];
|
515
|
+
if (textField) {
|
516
|
+
textField.focus();
|
517
|
+
(_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
|
518
|
+
}
|
519
|
+
});
|
520
|
+
}
|
521
|
+
};
|
522
|
+
const cellNavigation = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
|
523
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
524
|
+
if (cellValue && (event.ctrlKey || event.metaKey) && event.key === 'c') {
|
525
|
+
navigator.clipboard.writeText(cellValue);
|
526
|
+
}
|
527
|
+
else if (['Enter', ' '].includes(event.key)) {
|
528
|
+
if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
|
529
|
+
getMRT_RowSelectionHandler({
|
530
|
+
row: cell.row,
|
531
|
+
table,
|
532
|
+
//@ts-ignore
|
533
|
+
staticRowIndex: +event.target.getAttribute('data-index'),
|
534
|
+
})(event);
|
535
|
+
}
|
536
|
+
else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
|
537
|
+
table.options.enableSelectAll) {
|
538
|
+
getMRT_SelectAllHandler({
|
539
|
+
table,
|
540
|
+
})(event);
|
541
|
+
}
|
542
|
+
else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
|
543
|
+
(cell.row.getCanExpand() ||
|
544
|
+
((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
|
545
|
+
cell.row.toggleExpanded();
|
546
|
+
}
|
547
|
+
else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
|
548
|
+
table.options.enableExpandAll) {
|
549
|
+
table.toggleAllRowsExpanded();
|
550
|
+
}
|
551
|
+
else if ((_g = header === null || header === void 0 ? void 0 : header.column) === null || _g === void 0 ? void 0 : _g.getCanSort()) {
|
552
|
+
header.column.toggleSorting();
|
553
|
+
}
|
554
|
+
else if ((cell === null || cell === void 0 ? void 0 : cell.column.id) === 'mrt-row-pin') {
|
555
|
+
cell.row.getIsPinned()
|
556
|
+
? cell.row.pin(false)
|
557
|
+
: cell.row.pin(((_h = table.options.rowPinningDisplayMode) === null || _h === void 0 ? void 0 : _h.includes('bottom'))
|
558
|
+
? 'bottom'
|
559
|
+
: 'top');
|
560
|
+
}
|
561
|
+
}
|
562
|
+
else if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) {
|
563
|
+
event.preventDefault();
|
564
|
+
const currentCell = event.currentTarget;
|
565
|
+
const currentRow = parentElement || currentCell.closest('tr');
|
566
|
+
const tableElement = containerElement || currentCell.closest('table');
|
567
|
+
const allCells = cellElements ||
|
568
|
+
Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
|
569
|
+
const currentCellIndex = allCells.indexOf(currentCell);
|
570
|
+
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
|
571
|
+
let nextCell = undefined;
|
572
|
+
//home/end first or last cell in row
|
573
|
+
const findEdgeCell = (rowIndex, edge) => {
|
574
|
+
var _a;
|
575
|
+
const row = rowIndex === 'c'
|
576
|
+
? currentRow
|
577
|
+
: rowIndex === 'f'
|
578
|
+
? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
|
579
|
+
: (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
|
580
|
+
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
|
581
|
+
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
|
582
|
+
return targetCell;
|
583
|
+
};
|
584
|
+
const findAdjacentCell = (columnIndex, searchDirection) => {
|
585
|
+
const searchArray = searchDirection === 'f'
|
586
|
+
? allCells.slice(currentCellIndex + 1)
|
587
|
+
: allCells.slice(0, currentCellIndex).reverse();
|
588
|
+
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
|
589
|
+
};
|
590
|
+
switch (event.key) {
|
591
|
+
case 'ArrowRight':
|
592
|
+
nextCell = findAdjacentCell(currentIndex + 1, 'f');
|
593
|
+
break;
|
594
|
+
case 'ArrowLeft':
|
595
|
+
nextCell = findAdjacentCell(currentIndex - 1, 'b');
|
596
|
+
break;
|
597
|
+
case 'ArrowUp':
|
598
|
+
nextCell = findAdjacentCell(currentIndex, 'b');
|
599
|
+
break;
|
600
|
+
case 'ArrowDown':
|
601
|
+
nextCell = findAdjacentCell(currentIndex, 'f');
|
602
|
+
break;
|
603
|
+
case 'Home':
|
604
|
+
nextCell = findEdgeCell(event.ctrlKey ? 'f' : 'c', 'f');
|
605
|
+
break;
|
606
|
+
case 'End':
|
607
|
+
nextCell = findEdgeCell(event.ctrlKey ? 'l' : 'c', 'l');
|
608
|
+
break;
|
609
|
+
}
|
610
|
+
if (nextCell) {
|
611
|
+
nextCell.focus();
|
612
|
+
}
|
613
|
+
}
|
614
|
+
};
|
615
|
+
|
616
|
+
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
617
|
+
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
618
|
+
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 });
|
619
|
+
}
|
620
|
+
const showRowPinningColumn = (tableOptions) => {
|
621
|
+
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
622
|
+
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
|
623
|
+
};
|
624
|
+
const showRowDragColumn = (tableOptions) => {
|
625
|
+
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
626
|
+
return !!(enableRowDragging || enableRowOrdering);
|
627
|
+
};
|
628
|
+
const showRowExpandColumn = (tableOptions) => {
|
629
|
+
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
630
|
+
return !!(enableExpanding ||
|
631
|
+
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
632
|
+
renderDetailPanel);
|
633
|
+
};
|
634
|
+
const showRowActionsColumn = (tableOptions) => {
|
635
|
+
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
|
636
|
+
return !!(enableRowActions ||
|
637
|
+
(creatingRow && createDisplayMode === 'row') ||
|
638
|
+
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
|
639
|
+
};
|
640
|
+
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
|
641
|
+
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
|
642
|
+
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
|
643
|
+
const getLeadingDisplayColumnIds = (tableOptions) => [
|
644
|
+
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
|
645
|
+
showRowDragColumn(tableOptions) && 'mrt-row-drag',
|
646
|
+
tableOptions.positionActionsColumn === 'first' &&
|
647
|
+
showRowActionsColumn(tableOptions) &&
|
648
|
+
'mrt-row-actions',
|
649
|
+
tableOptions.positionExpandColumn === 'first' &&
|
650
|
+
showRowExpandColumn(tableOptions) &&
|
651
|
+
'mrt-row-expand',
|
652
|
+
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
|
653
|
+
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
|
654
|
+
].filter(Boolean);
|
655
|
+
const getTrailingDisplayColumnIds = (tableOptions) => [
|
656
|
+
tableOptions.positionActionsColumn === 'last' &&
|
657
|
+
showRowActionsColumn(tableOptions) &&
|
658
|
+
'mrt-row-actions',
|
659
|
+
tableOptions.positionExpandColumn === 'last' &&
|
660
|
+
showRowExpandColumn(tableOptions) &&
|
661
|
+
'mrt-row-expand',
|
662
|
+
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
|
663
|
+
].filter(Boolean);
|
664
|
+
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
665
|
+
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
|
666
|
+
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
667
|
+
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
668
|
+
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
|
669
|
+
let allLeafColumnDefIds = reset
|
670
|
+
? defaultColumnDefIds
|
671
|
+
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
672
|
+
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
|
673
|
+
!trailingDisplayColIds.includes(colId));
|
674
|
+
return [
|
675
|
+
...leadingDisplayColIds,
|
676
|
+
...allLeafColumnDefIds,
|
677
|
+
...trailingDisplayColIds,
|
678
|
+
];
|
679
|
+
};
|
680
|
+
|
641
681
|
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
642
682
|
|
643
683
|
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
@@ -919,7 +959,7 @@ const MRT_ActionMenuItem = (_a) => {
|
|
919
959
|
minWidth: '120px',
|
920
960
|
my: 0,
|
921
961
|
py: '6px',
|
922
|
-
} }, rest, { children: [jsxRuntime.jsxs(Box__default["default"], { sx: {
|
962
|
+
}, tabIndex: 0 }, rest, { children: [jsxRuntime.jsxs(Box__default["default"], { sx: {
|
923
963
|
alignItems: 'center',
|
924
964
|
display: 'flex',
|
925
965
|
}, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: icon }), label] }), onOpenSubMenu && (jsxRuntime.jsx(IconButton__default["default"], { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] })));
|
@@ -2249,12 +2289,17 @@ const MRT_TableBodyCell = (_a) => {
|
|
2249
2289
|
table.refs.actionCellRef.current = e.currentTarget;
|
2250
2290
|
}
|
2251
2291
|
};
|
2252
|
-
const handleKeyDown = (
|
2292
|
+
const handleKeyDown = (event) => {
|
2253
2293
|
var _a;
|
2254
2294
|
if (enableCellNavigation) {
|
2255
|
-
cellNavigation(
|
2295
|
+
cellNavigation({
|
2296
|
+
cell,
|
2297
|
+
cellValue: cell.getValue(),
|
2298
|
+
event,
|
2299
|
+
table,
|
2300
|
+
});
|
2256
2301
|
}
|
2257
|
-
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps,
|
2302
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2258
2303
|
};
|
2259
2304
|
return (jsxRuntime.jsx(TableCell__default["default"], 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': {
|
2260
2305
|
outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
|
@@ -2527,12 +2572,16 @@ const MRT_TableFooterCell = (_a) => {
|
|
2527
2572
|
column.getIsPinned();
|
2528
2573
|
const args = { column, table };
|
2529
2574
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2530
|
-
const handleKeyDown = (
|
2575
|
+
const handleKeyDown = (event) => {
|
2531
2576
|
var _a;
|
2532
2577
|
if (enableCellNavigation) {
|
2533
|
-
cellNavigation(
|
2578
|
+
cellNavigation({
|
2579
|
+
event,
|
2580
|
+
cellValue: footer.column.columnDef.footer,
|
2581
|
+
table,
|
2582
|
+
});
|
2534
2583
|
}
|
2535
|
-
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps,
|
2584
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2536
2585
|
};
|
2537
2586
|
return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group'
|
2538
2587
|
? 'center'
|
@@ -3154,7 +3203,11 @@ const MRT_FilterTextField = (_a) => {
|
|
3154
3203
|
}
|
3155
3204
|
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
3156
3205
|
? undefined
|
3157
|
-
: filterPlaceholder, variant: 'standard' }, textFieldProps), {
|
3206
|
+
: filterPlaceholder, variant: 'standard' }, textFieldProps), { onKeyDown: (e) => {
|
3207
|
+
var _a;
|
3208
|
+
e.stopPropagation();
|
3209
|
+
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
3210
|
+
}, sx: (theme) => (Object.assign({ minWidth: isDateFilter
|
3158
3211
|
? '160px'
|
3159
3212
|
: enableColumnFilterModes && rangeFilterIndex === 0
|
3160
3213
|
? '110px'
|
@@ -3533,12 +3586,17 @@ const MRT_TableHeadCell = (_a) => {
|
|
3533
3586
|
e.preventDefault();
|
3534
3587
|
}
|
3535
3588
|
};
|
3536
|
-
const handleKeyDown = (
|
3589
|
+
const handleKeyDown = (event) => {
|
3537
3590
|
var _a;
|
3538
3591
|
if (enableCellNavigation) {
|
3539
|
-
cellNavigation(
|
3592
|
+
cellNavigation({
|
3593
|
+
event,
|
3594
|
+
cellValue: header.column.columnDef.header,
|
3595
|
+
table,
|
3596
|
+
header,
|
3597
|
+
});
|
3540
3598
|
}
|
3541
|
-
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps,
|
3599
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
3542
3600
|
};
|
3543
3601
|
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3544
3602
|
column,
|