material-react-table 3.0.0-alpha.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/README.md +2 -2
- package/dist/index.d.ts +66 -5
- package/dist/index.esm.js +329 -158
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +329 -157
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/body/MRT_TableBodyCell.tsx +20 -1
- package/src/components/body/MRT_TableBodyRow.tsx +3 -2
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +5 -1
- package/src/components/footer/MRT_TableFooter.tsx +17 -2
- package/src/components/footer/MRT_TableFooterCell.tsx +18 -1
- package/src/components/head/MRT_TableHeadCell.tsx +16 -0
- package/src/components/inputs/MRT_FilterTextField.tsx +4 -0
- package/src/components/menus/MRT_ActionMenuItem.tsx +1 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +26 -16
- package/src/fns/filterFns.ts +43 -35
- package/src/hooks/useMRT_TableOptions.ts +2 -0
- package/src/types.ts +55 -7
- package/src/utils/cell.utils.ts +137 -0
- package/src/utils/style.utils.ts +5 -0
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,108 +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
|
-
|
369
|
-
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
370
|
-
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
371
|
-
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 });
|
372
|
-
}
|
373
|
-
const showRowPinningColumn = (tableOptions) => {
|
374
|
-
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
375
|
-
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
|
376
|
-
};
|
377
|
-
const showRowDragColumn = (tableOptions) => {
|
378
|
-
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
379
|
-
return !!(enableRowDragging || enableRowOrdering);
|
380
|
-
};
|
381
|
-
const showRowExpandColumn = (tableOptions) => {
|
382
|
-
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
383
|
-
return !!(enableExpanding ||
|
384
|
-
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
385
|
-
renderDetailPanel);
|
386
|
-
};
|
387
|
-
const showRowActionsColumn = (tableOptions) => {
|
388
|
-
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
|
389
|
-
return !!(enableRowActions ||
|
390
|
-
(creatingRow && createDisplayMode === 'row') ||
|
391
|
-
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
|
392
|
-
};
|
393
|
-
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
|
394
|
-
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
|
395
|
-
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
|
396
|
-
const getLeadingDisplayColumnIds = (tableOptions) => [
|
397
|
-
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
|
398
|
-
showRowDragColumn(tableOptions) && 'mrt-row-drag',
|
399
|
-
tableOptions.positionActionsColumn === 'first' &&
|
400
|
-
showRowActionsColumn(tableOptions) &&
|
401
|
-
'mrt-row-actions',
|
402
|
-
tableOptions.positionExpandColumn === 'first' &&
|
403
|
-
showRowExpandColumn(tableOptions) &&
|
404
|
-
'mrt-row-expand',
|
405
|
-
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
|
406
|
-
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
|
407
|
-
].filter(Boolean);
|
408
|
-
const getTrailingDisplayColumnIds = (tableOptions) => [
|
409
|
-
tableOptions.positionActionsColumn === 'last' &&
|
410
|
-
showRowActionsColumn(tableOptions) &&
|
411
|
-
'mrt-row-actions',
|
412
|
-
tableOptions.positionExpandColumn === 'last' &&
|
413
|
-
showRowExpandColumn(tableOptions) &&
|
414
|
-
'mrt-row-expand',
|
415
|
-
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
|
416
|
-
].filter(Boolean);
|
417
|
-
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
418
|
-
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
|
419
|
-
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
420
|
-
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
421
|
-
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
|
422
|
-
let allLeafColumnDefIds = reset
|
423
|
-
? defaultColumnDefIds
|
424
|
-
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
425
|
-
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
|
426
|
-
!trailingDisplayColIds.includes(colId));
|
427
|
-
return [
|
428
|
-
...leadingDisplayColIds,
|
429
|
-
...allLeafColumnDefIds,
|
430
|
-
...trailingDisplayColIds,
|
431
|
-
];
|
432
|
-
};
|
433
|
-
|
434
|
-
const fuzzy$1 = (rowA, rowB, columnId) => {
|
435
|
-
let dir = 0;
|
436
|
-
if (rowA.columnFiltersMeta[columnId]) {
|
437
|
-
dir = matchSorterUtils.compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
438
|
-
}
|
439
|
-
// Provide a fallback for when the item ranks are equal
|
440
|
-
return dir === 0
|
441
|
-
? reactTable.sortingFns.alphanumeric(rowA, rowB, columnId)
|
442
|
-
: dir;
|
443
|
-
};
|
444
|
-
const MRT_SortingFns = Object.assign(Object.assign({}, reactTable.sortingFns), { fuzzy: fuzzy$1 });
|
445
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
446
|
-
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
447
|
-
|
448
360
|
const getMRT_Rows = (table, all) => {
|
449
361
|
const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
|
450
362
|
const { creatingRow, pagination } = getState();
|
@@ -585,6 +497,187 @@ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
|
|
585
497
|
lastSelectedRowId.current = null;
|
586
498
|
};
|
587
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
|
+
|
588
681
|
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
589
682
|
|
590
683
|
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
@@ -595,44 +688,51 @@ const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
595
688
|
return itemRank.passed;
|
596
689
|
};
|
597
690
|
fuzzy.autoRemove = (val) => !val;
|
598
|
-
const contains = (row, id, filterValue) =>
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
.includes(filterValue.toString().toLowerCase().trim());
|
691
|
+
const contains = (row, id, filterValue) => {
|
692
|
+
var _a;
|
693
|
+
return !!((_a = row
|
694
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
695
|
+
};
|
604
696
|
contains.autoRemove = (val) => !val;
|
605
|
-
const startsWith = (row, id, filterValue) =>
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
.startsWith(filterValue.toString().toLowerCase().trim());
|
697
|
+
const startsWith = (row, id, filterValue) => {
|
698
|
+
var _a;
|
699
|
+
return !!((_a = row
|
700
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
701
|
+
};
|
611
702
|
startsWith.autoRemove = (val) => !val;
|
612
|
-
const endsWith = (row, id, filterValue) =>
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
.endsWith(filterValue.toString().toLowerCase().trim());
|
703
|
+
const endsWith = (row, id, filterValue) => {
|
704
|
+
var _a;
|
705
|
+
return !!((_a = row
|
706
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
707
|
+
};
|
618
708
|
endsWith.autoRemove = (val) => !val;
|
619
|
-
const equals = (row, id, filterValue) =>
|
620
|
-
|
709
|
+
const equals = (row, id, filterValue) => {
|
710
|
+
var _a;
|
711
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
712
|
+
filterValue.toString().toLowerCase().trim();
|
713
|
+
};
|
621
714
|
equals.autoRemove = (val) => !val;
|
622
|
-
const notEquals = (row, id, filterValue) =>
|
623
|
-
|
715
|
+
const notEquals = (row, id, filterValue) => {
|
716
|
+
var _a;
|
717
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
718
|
+
filterValue.toString().toLowerCase().trim();
|
719
|
+
};
|
624
720
|
notEquals.autoRemove = (val) => !val;
|
625
|
-
const greaterThan = (row, id, filterValue) =>
|
626
|
-
|
627
|
-
|
628
|
-
(
|
721
|
+
const greaterThan = (row, id, filterValue) => {
|
722
|
+
var _a, _b, _c;
|
723
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
724
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
725
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
726
|
+
};
|
629
727
|
greaterThan.autoRemove = (val) => !val;
|
630
728
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
631
729
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
632
|
-
const lessThan = (row, id, filterValue) =>
|
633
|
-
|
634
|
-
|
635
|
-
(
|
730
|
+
const lessThan = (row, id, filterValue) => {
|
731
|
+
var _a, _b, _c;
|
732
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
733
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
734
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
735
|
+
};
|
636
736
|
lessThan.autoRemove = (val) => !val;
|
637
737
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
638
738
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
@@ -652,9 +752,9 @@ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(fi
|
|
652
752
|
['', undefined].includes(filterValues[1]) ||
|
653
753
|
lessThanOrEqualTo(row, id, filterValues[1]));
|
654
754
|
betweenInclusive.autoRemove = (val) => !val;
|
655
|
-
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
755
|
+
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
656
756
|
empty.autoRemove = (val) => !val;
|
657
|
-
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
757
|
+
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
658
758
|
notEmpty.autoRemove = (val) => !val;
|
659
759
|
const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
|
660
760
|
betweenInclusive,
|
@@ -758,7 +858,7 @@ const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
758
858
|
const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
|
759
859
|
? styles.lighten(muiTheme.palette.background.default, 0.05)
|
760
860
|
: muiTheme.palette.background.default);
|
761
|
-
return Object.assign({ baseBackgroundColor, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
861
|
+
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
762
862
|
? styles.darken(muiTheme.palette.warning.dark, 0.25)
|
763
863
|
: styles.lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
764
864
|
};
|
@@ -824,7 +924,10 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
824
924
|
? 2
|
825
925
|
: columnDefType !== 'group' && isColumnPinned
|
826
926
|
? 1
|
827
|
-
: 0
|
927
|
+
: 0, '&:focus-visible': {
|
928
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
929
|
+
outlineOffset: '-2px',
|
930
|
+
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
828
931
|
};
|
829
932
|
const getCommonToolbarStyles = ({ table, }) => ({
|
830
933
|
alignItems: 'flex-start',
|
@@ -856,7 +959,7 @@ const MRT_ActionMenuItem = (_a) => {
|
|
856
959
|
minWidth: '120px',
|
857
960
|
my: 0,
|
858
961
|
py: '6px',
|
859
|
-
} }, rest, { children: [jsxRuntime.jsxs(Box__default["default"], { sx: {
|
962
|
+
}, tabIndex: 0 }, rest, { children: [jsxRuntime.jsxs(Box__default["default"], { sx: {
|
860
963
|
alignItems: 'center',
|
861
964
|
display: 'flex',
|
862
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, {}) }))] })));
|
@@ -866,18 +969,30 @@ const MRT_RowActionMenu = (_a) => {
|
|
866
969
|
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
867
970
|
const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
868
971
|
const { density } = getState();
|
869
|
-
|
972
|
+
const menuItems = react.useMemo(() => {
|
973
|
+
const items = [];
|
974
|
+
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
975
|
+
['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }));
|
976
|
+
if (editItem)
|
977
|
+
items.push(editItem);
|
978
|
+
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
979
|
+
closeMenu: () => setAnchorEl(null),
|
980
|
+
row,
|
981
|
+
staticRowIndex,
|
982
|
+
table,
|
983
|
+
});
|
984
|
+
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
985
|
+
items.push(...rowActionMenuItems);
|
986
|
+
return items;
|
987
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
988
|
+
if (!menuItems.length)
|
989
|
+
return null;
|
990
|
+
return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
|
870
991
|
dense: density === 'compact',
|
871
992
|
sx: {
|
872
993
|
backgroundColor: menuBackgroundColor,
|
873
994
|
},
|
874
|
-
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children:
|
875
|
-
['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
876
|
-
closeMenu: () => setAnchorEl(null),
|
877
|
-
row,
|
878
|
-
staticRowIndex,
|
879
|
-
table,
|
880
|
-
})] })));
|
995
|
+
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
881
996
|
};
|
882
997
|
|
883
998
|
const commonIconButtonStyles = {
|
@@ -891,6 +1006,7 @@ const commonIconButtonStyles = {
|
|
891
1006
|
width: '2rem',
|
892
1007
|
};
|
893
1008
|
const MRT_ToggleRowActionMenuButton = (_a) => {
|
1009
|
+
var _b;
|
894
1010
|
var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
|
895
1011
|
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
896
1012
|
const { creatingRow, editingRow } = getState();
|
@@ -911,7 +1027,11 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
911
1027
|
};
|
912
1028
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
913
1029
|
parseFromValuesOrFunc(enableEditing, row) &&
|
914
|
-
['modal', 'row'].includes(editDisplayMode) ? (jsxRuntime.jsx(Tooltip__default["default"], { placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(EditIcon, {}) })) })) :
|
1030
|
+
['modal', 'row'].includes(editDisplayMode) ? (jsxRuntime.jsx(Tooltip__default["default"], { placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
1031
|
+
row,
|
1032
|
+
staticRowIndex,
|
1033
|
+
table,
|
1034
|
+
})) === null || _b === void 0 ? void 0 : _b.length) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(MoreHorizIcon, {}) })) })), jsxRuntime.jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
|
915
1035
|
};
|
916
1036
|
|
917
1037
|
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
@@ -1339,7 +1459,7 @@ const MRT_DefaultDisplayColumn = {
|
|
1339
1459
|
};
|
1340
1460
|
const useMRT_TableOptions = (_a) => {
|
1341
1461
|
var _b;
|
1342
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
1462
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableCellNavigation = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableCellNavigation", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
1343
1463
|
const theme = styles.useTheme();
|
1344
1464
|
icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
1345
1465
|
localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
@@ -1400,6 +1520,7 @@ const useMRT_TableOptions = (_a) => {
|
|
1400
1520
|
enableGlobalFilterRankedResults,
|
1401
1521
|
enableGrouping,
|
1402
1522
|
enableHiding,
|
1523
|
+
enableCellNavigation,
|
1403
1524
|
enableMultiRowSelection,
|
1404
1525
|
enableMultiSort,
|
1405
1526
|
enablePagination,
|
@@ -2046,7 +2167,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2046
2167
|
var _b, _c, _d, _e, _f;
|
2047
2168
|
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
|
2048
2169
|
const theme = styles.useTheme();
|
2049
|
-
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
2170
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
2050
2171
|
const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
2051
2172
|
const { column, row } = cell;
|
2052
2173
|
const { columnDef } = column;
|
@@ -2168,7 +2289,19 @@ const MRT_TableBodyCell = (_a) => {
|
|
2168
2289
|
table.refs.actionCellRef.current = e.currentTarget;
|
2169
2290
|
}
|
2170
2291
|
};
|
2171
|
-
|
2292
|
+
const handleKeyDown = (event) => {
|
2293
|
+
var _a;
|
2294
|
+
if (enableCellNavigation) {
|
2295
|
+
cellNavigation({
|
2296
|
+
cell,
|
2297
|
+
cellValue: cell.getValue(),
|
2298
|
+
event,
|
2299
|
+
table,
|
2300
|
+
});
|
2301
|
+
}
|
2302
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2303
|
+
};
|
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': {
|
2172
2305
|
outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
|
2173
2306
|
(editDisplayMode === 'cell' && isEditable) ||
|
2174
2307
|
(editDisplayMode === 'table' && (isCreating || isEditing))
|
@@ -2335,12 +2468,13 @@ const MRT_TableBodyRow = (_a) => {
|
|
2335
2468
|
staticRowIndex,
|
2336
2469
|
table,
|
2337
2470
|
};
|
2471
|
+
const key = `${cell.id}-${staticRowIndex}`;
|
2338
2472
|
return cell ? (memoMode === 'cells' &&
|
2339
2473
|
cell.column.columnDef.columnDefType === 'data' &&
|
2340
2474
|
!draggingColumn &&
|
2341
2475
|
!draggingRow &&
|
2342
2476
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
2343
|
-
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props),
|
2477
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
|
2344
2478
|
}), virtualPaddingRight ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsxRuntime.jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
|
2345
2479
|
};
|
2346
2480
|
const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
@@ -2428,7 +2562,7 @@ const MRT_TableFooterCell = (_a) => {
|
|
2428
2562
|
var _b, _c, _d;
|
2429
2563
|
var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
|
2430
2564
|
const theme = styles.useTheme();
|
2431
|
-
const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
|
2565
|
+
const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableCellNavigation, }, } = table;
|
2432
2566
|
const { density } = getState();
|
2433
2567
|
const { column } = footer;
|
2434
2568
|
const { columnDef } = column;
|
@@ -2438,11 +2572,22 @@ const MRT_TableFooterCell = (_a) => {
|
|
2438
2572
|
column.getIsPinned();
|
2439
2573
|
const args = { column, table };
|
2440
2574
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2575
|
+
const handleKeyDown = (event) => {
|
2576
|
+
var _a;
|
2577
|
+
if (enableCellNavigation) {
|
2578
|
+
cellNavigation({
|
2579
|
+
event,
|
2580
|
+
cellValue: footer.column.columnDef.footer,
|
2581
|
+
table,
|
2582
|
+
});
|
2583
|
+
}
|
2584
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2585
|
+
};
|
2441
2586
|
return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group'
|
2442
2587
|
? 'center'
|
2443
2588
|
: theme.direction === 'rtl'
|
2444
2589
|
? 'right'
|
2445
|
-
: 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
|
2590
|
+
: 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
|
2446
2591
|
? '0.5rem'
|
2447
2592
|
: density === 'comfortable'
|
2448
2593
|
? '1rem'
|
@@ -2489,12 +2634,22 @@ const MRT_TableFooterRow = (_a) => {
|
|
2489
2634
|
|
2490
2635
|
const MRT_TableFooter = (_a) => {
|
2491
2636
|
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2492
|
-
const {
|
2637
|
+
const { getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2493
2638
|
const { isFullScreen } = getState();
|
2494
2639
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
2495
2640
|
table,
|
2496
2641
|
})), rest);
|
2497
2642
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
2643
|
+
const footerGroups = table.getFooterGroups();
|
2644
|
+
//if no footer cells at all, skip footer
|
2645
|
+
if (!footerGroups.some((footerGroup) => {
|
2646
|
+
var _a;
|
2647
|
+
return (_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2648
|
+
!!header.column.columnDef.footer) ||
|
2649
|
+
header.column.columnDef.Footer);
|
2650
|
+
})) {
|
2651
|
+
return null;
|
2652
|
+
}
|
2498
2653
|
return (jsxRuntime.jsx(TableFooter__default["default"], Object.assign({}, tableFooterProps, { ref: (ref) => {
|
2499
2654
|
tableFooterRef.current = ref;
|
2500
2655
|
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
@@ -2505,7 +2660,7 @@ const MRT_TableFooter = (_a) => {
|
|
2505
2660
|
? theme.palette.mode === 'light'
|
2506
2661
|
? `1px solid ${theme.palette.grey[300]}`
|
2507
2662
|
: `1px solid ${theme.palette.grey[700]}`
|
2508
|
-
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children:
|
2663
|
+
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: footerGroups.map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
|
2509
2664
|
};
|
2510
2665
|
|
2511
2666
|
const mrtFilterOptions = (localization) => [
|
@@ -3048,7 +3203,11 @@ const MRT_FilterTextField = (_a) => {
|
|
3048
3203
|
}
|
3049
3204
|
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
3050
3205
|
? undefined
|
3051
|
-
: 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
|
3052
3211
|
? '160px'
|
3053
3212
|
: enableColumnFilterModes && rangeFilterIndex === 0
|
3054
3213
|
? '110px'
|
@@ -3358,7 +3517,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3358
3517
|
var _b, _c, _d, _f, _g, _h;
|
3359
3518
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
3360
3519
|
const theme = styles.useTheme();
|
3361
|
-
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3520
|
+
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3362
3521
|
const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3363
3522
|
const { column } = header;
|
3364
3523
|
const { columnDef } = column;
|
@@ -3427,6 +3586,18 @@ const MRT_TableHeadCell = (_a) => {
|
|
3427
3586
|
e.preventDefault();
|
3428
3587
|
}
|
3429
3588
|
};
|
3589
|
+
const handleKeyDown = (event) => {
|
3590
|
+
var _a;
|
3591
|
+
if (enableCellNavigation) {
|
3592
|
+
cellNavigation({
|
3593
|
+
event,
|
3594
|
+
cellValue: header.column.columnDef.header,
|
3595
|
+
table,
|
3596
|
+
header,
|
3597
|
+
});
|
3598
|
+
}
|
3599
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
3600
|
+
};
|
3430
3601
|
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3431
3602
|
column,
|
3432
3603
|
header,
|
@@ -3448,7 +3619,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3448
3619
|
(_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
|
3449
3620
|
}
|
3450
3621
|
}
|
3451
|
-
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3622
|
+
}, tabIndex: enableCellNavigation ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3452
3623
|
'.MuiButtonBase-root': {
|
3453
3624
|
opacity: 1,
|
3454
3625
|
},
|
@@ -4301,6 +4472,7 @@ exports.MaterialReactTable = MaterialReactTable;
|
|
4301
4472
|
exports.Memo_MRT_TableBody = Memo_MRT_TableBody;
|
4302
4473
|
exports.Memo_MRT_TableBodyCell = Memo_MRT_TableBodyCell;
|
4303
4474
|
exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
|
4475
|
+
exports.cellNavigation = cellNavigation;
|
4304
4476
|
exports.createMRTColumnHelper = createMRTColumnHelper;
|
4305
4477
|
exports.createRow = createRow;
|
4306
4478
|
exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
|