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.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,108 +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
|
-
|
279
|
-
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
280
|
-
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
281
|
-
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 });
|
282
|
-
}
|
283
|
-
const showRowPinningColumn = (tableOptions) => {
|
284
|
-
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
|
285
|
-
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
|
286
|
-
};
|
287
|
-
const showRowDragColumn = (tableOptions) => {
|
288
|
-
const { enableRowDragging, enableRowOrdering } = tableOptions;
|
289
|
-
return !!(enableRowDragging || enableRowOrdering);
|
290
|
-
};
|
291
|
-
const showRowExpandColumn = (tableOptions) => {
|
292
|
-
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
293
|
-
return !!(enableExpanding ||
|
294
|
-
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
295
|
-
renderDetailPanel);
|
296
|
-
};
|
297
|
-
const showRowActionsColumn = (tableOptions) => {
|
298
|
-
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
|
299
|
-
return !!(enableRowActions ||
|
300
|
-
(creatingRow && createDisplayMode === 'row') ||
|
301
|
-
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
|
302
|
-
};
|
303
|
-
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
|
304
|
-
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
|
305
|
-
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
|
306
|
-
const getLeadingDisplayColumnIds = (tableOptions) => [
|
307
|
-
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
|
308
|
-
showRowDragColumn(tableOptions) && 'mrt-row-drag',
|
309
|
-
tableOptions.positionActionsColumn === 'first' &&
|
310
|
-
showRowActionsColumn(tableOptions) &&
|
311
|
-
'mrt-row-actions',
|
312
|
-
tableOptions.positionExpandColumn === 'first' &&
|
313
|
-
showRowExpandColumn(tableOptions) &&
|
314
|
-
'mrt-row-expand',
|
315
|
-
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
|
316
|
-
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
|
317
|
-
].filter(Boolean);
|
318
|
-
const getTrailingDisplayColumnIds = (tableOptions) => [
|
319
|
-
tableOptions.positionActionsColumn === 'last' &&
|
320
|
-
showRowActionsColumn(tableOptions) &&
|
321
|
-
'mrt-row-actions',
|
322
|
-
tableOptions.positionExpandColumn === 'last' &&
|
323
|
-
showRowExpandColumn(tableOptions) &&
|
324
|
-
'mrt-row-expand',
|
325
|
-
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
|
326
|
-
].filter(Boolean);
|
327
|
-
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
328
|
-
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
|
329
|
-
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
|
330
|
-
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
|
331
|
-
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
|
332
|
-
let allLeafColumnDefIds = reset
|
333
|
-
? defaultColumnDefIds
|
334
|
-
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
|
335
|
-
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
|
336
|
-
!trailingDisplayColIds.includes(colId));
|
337
|
-
return [
|
338
|
-
...leadingDisplayColIds,
|
339
|
-
...allLeafColumnDefIds,
|
340
|
-
...trailingDisplayColIds,
|
341
|
-
];
|
342
|
-
};
|
343
|
-
|
344
|
-
const fuzzy$1 = (rowA, rowB, columnId) => {
|
345
|
-
let dir = 0;
|
346
|
-
if (rowA.columnFiltersMeta[columnId]) {
|
347
|
-
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
348
|
-
}
|
349
|
-
// Provide a fallback for when the item ranks are equal
|
350
|
-
return dir === 0
|
351
|
-
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
352
|
-
: dir;
|
353
|
-
};
|
354
|
-
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
|
355
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
356
|
-
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
357
|
-
|
358
270
|
const getMRT_Rows = (table, all) => {
|
359
271
|
const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
|
360
272
|
const { creatingRow, pagination } = getState();
|
@@ -495,6 +407,187 @@ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
|
|
495
407
|
lastSelectedRowId.current = null;
|
496
408
|
};
|
497
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
|
+
|
498
591
|
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
499
592
|
|
500
593
|
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
@@ -505,44 +598,51 @@ const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
505
598
|
return itemRank.passed;
|
506
599
|
};
|
507
600
|
fuzzy.autoRemove = (val) => !val;
|
508
|
-
const contains = (row, id, filterValue) =>
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
.includes(filterValue.toString().toLowerCase().trim());
|
601
|
+
const contains = (row, id, filterValue) => {
|
602
|
+
var _a;
|
603
|
+
return !!((_a = row
|
604
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
605
|
+
};
|
514
606
|
contains.autoRemove = (val) => !val;
|
515
|
-
const startsWith = (row, id, filterValue) =>
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
.startsWith(filterValue.toString().toLowerCase().trim());
|
607
|
+
const startsWith = (row, id, filterValue) => {
|
608
|
+
var _a;
|
609
|
+
return !!((_a = row
|
610
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
611
|
+
};
|
521
612
|
startsWith.autoRemove = (val) => !val;
|
522
|
-
const endsWith = (row, id, filterValue) =>
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
.endsWith(filterValue.toString().toLowerCase().trim());
|
613
|
+
const endsWith = (row, id, filterValue) => {
|
614
|
+
var _a;
|
615
|
+
return !!((_a = row
|
616
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
617
|
+
};
|
528
618
|
endsWith.autoRemove = (val) => !val;
|
529
|
-
const equals = (row, id, filterValue) =>
|
530
|
-
|
619
|
+
const equals = (row, id, filterValue) => {
|
620
|
+
var _a;
|
621
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
622
|
+
filterValue.toString().toLowerCase().trim();
|
623
|
+
};
|
531
624
|
equals.autoRemove = (val) => !val;
|
532
|
-
const notEquals = (row, id, filterValue) =>
|
533
|
-
|
625
|
+
const notEquals = (row, id, filterValue) => {
|
626
|
+
var _a;
|
627
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
628
|
+
filterValue.toString().toLowerCase().trim();
|
629
|
+
};
|
534
630
|
notEquals.autoRemove = (val) => !val;
|
535
|
-
const greaterThan = (row, id, filterValue) =>
|
536
|
-
|
537
|
-
|
538
|
-
(
|
631
|
+
const greaterThan = (row, id, filterValue) => {
|
632
|
+
var _a, _b, _c;
|
633
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
634
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
635
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
636
|
+
};
|
539
637
|
greaterThan.autoRemove = (val) => !val;
|
540
638
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
541
639
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
542
|
-
const lessThan = (row, id, filterValue) =>
|
543
|
-
|
544
|
-
|
545
|
-
(
|
640
|
+
const lessThan = (row, id, filterValue) => {
|
641
|
+
var _a, _b, _c;
|
642
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
643
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
644
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
645
|
+
};
|
546
646
|
lessThan.autoRemove = (val) => !val;
|
547
647
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
548
648
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
@@ -562,9 +662,9 @@ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(fi
|
|
562
662
|
['', undefined].includes(filterValues[1]) ||
|
563
663
|
lessThanOrEqualTo(row, id, filterValues[1]));
|
564
664
|
betweenInclusive.autoRemove = (val) => !val;
|
565
|
-
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
665
|
+
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
566
666
|
empty.autoRemove = (val) => !val;
|
567
|
-
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
667
|
+
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
568
668
|
notEmpty.autoRemove = (val) => !val;
|
569
669
|
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
570
670
|
betweenInclusive,
|
@@ -668,7 +768,7 @@ const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
668
768
|
const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
|
669
769
|
? lighten(muiTheme.palette.background.default, 0.05)
|
670
770
|
: muiTheme.palette.background.default);
|
671
|
-
return Object.assign({ baseBackgroundColor, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
771
|
+
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
672
772
|
? darken(muiTheme.palette.warning.dark, 0.25)
|
673
773
|
: lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
674
774
|
};
|
@@ -734,7 +834,10 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
734
834
|
? 2
|
735
835
|
: columnDefType !== 'group' && isColumnPinned
|
736
836
|
? 1
|
737
|
-
: 0
|
837
|
+
: 0, '&:focus-visible': {
|
838
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
839
|
+
outlineOffset: '-2px',
|
840
|
+
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
738
841
|
};
|
739
842
|
const getCommonToolbarStyles = ({ table, }) => ({
|
740
843
|
alignItems: 'flex-start',
|
@@ -766,7 +869,7 @@ const MRT_ActionMenuItem = (_a) => {
|
|
766
869
|
minWidth: '120px',
|
767
870
|
my: 0,
|
768
871
|
py: '6px',
|
769
|
-
} }, rest, { children: [jsxs(Box, { sx: {
|
872
|
+
}, tabIndex: 0 }, rest, { children: [jsxs(Box, { sx: {
|
770
873
|
alignItems: 'center',
|
771
874
|
display: 'flex',
|
772
875
|
}, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
|
@@ -776,18 +879,30 @@ const MRT_RowActionMenu = (_a) => {
|
|
776
879
|
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
777
880
|
const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
778
881
|
const { density } = getState();
|
779
|
-
|
882
|
+
const menuItems = useMemo(() => {
|
883
|
+
const items = [];
|
884
|
+
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
885
|
+
['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }));
|
886
|
+
if (editItem)
|
887
|
+
items.push(editItem);
|
888
|
+
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
889
|
+
closeMenu: () => setAnchorEl(null),
|
890
|
+
row,
|
891
|
+
staticRowIndex,
|
892
|
+
table,
|
893
|
+
});
|
894
|
+
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
895
|
+
items.push(...rowActionMenuItems);
|
896
|
+
return items;
|
897
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
898
|
+
if (!menuItems.length)
|
899
|
+
return null;
|
900
|
+
return (jsx(Menu, Object.assign({ MenuListProps: {
|
780
901
|
dense: density === 'compact',
|
781
902
|
sx: {
|
782
903
|
backgroundColor: menuBackgroundColor,
|
783
904
|
},
|
784
|
-
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children:
|
785
|
-
['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
786
|
-
closeMenu: () => setAnchorEl(null),
|
787
|
-
row,
|
788
|
-
staticRowIndex,
|
789
|
-
table,
|
790
|
-
})] })));
|
905
|
+
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
791
906
|
};
|
792
907
|
|
793
908
|
const commonIconButtonStyles = {
|
@@ -801,6 +916,7 @@ const commonIconButtonStyles = {
|
|
801
916
|
width: '2rem',
|
802
917
|
};
|
803
918
|
const MRT_ToggleRowActionMenuButton = (_a) => {
|
919
|
+
var _b;
|
804
920
|
var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
|
805
921
|
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
806
922
|
const { creatingRow, editingRow } = getState();
|
@@ -821,7 +937,11 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
821
937
|
};
|
822
938
|
return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
823
939
|
parseFromValuesOrFunc(enableEditing, row) &&
|
824
|
-
['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) :
|
940
|
+
['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
941
|
+
row,
|
942
|
+
staticRowIndex,
|
943
|
+
table,
|
944
|
+
})) === null || _b === void 0 ? void 0 : _b.length) ? (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) })), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
|
825
945
|
};
|
826
946
|
|
827
947
|
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
@@ -1249,7 +1369,7 @@ const MRT_DefaultDisplayColumn = {
|
|
1249
1369
|
};
|
1250
1370
|
const useMRT_TableOptions = (_a) => {
|
1251
1371
|
var _b;
|
1252
|
-
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"]);
|
1372
|
+
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"]);
|
1253
1373
|
const theme = useTheme();
|
1254
1374
|
icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
1255
1375
|
localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
@@ -1310,6 +1430,7 @@ const useMRT_TableOptions = (_a) => {
|
|
1310
1430
|
enableGlobalFilterRankedResults,
|
1311
1431
|
enableGrouping,
|
1312
1432
|
enableHiding,
|
1433
|
+
enableCellNavigation,
|
1313
1434
|
enableMultiRowSelection,
|
1314
1435
|
enableMultiSort,
|
1315
1436
|
enablePagination,
|
@@ -1956,7 +2077,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
1956
2077
|
var _b, _c, _d, _e, _f;
|
1957
2078
|
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
|
1958
2079
|
const theme = useTheme();
|
1959
|
-
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
2080
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
1960
2081
|
const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
1961
2082
|
const { column, row } = cell;
|
1962
2083
|
const { columnDef } = column;
|
@@ -2078,7 +2199,19 @@ const MRT_TableBodyCell = (_a) => {
|
|
2078
2199
|
table.refs.actionCellRef.current = e.currentTarget;
|
2079
2200
|
}
|
2080
2201
|
};
|
2081
|
-
|
2202
|
+
const handleKeyDown = (event) => {
|
2203
|
+
var _a;
|
2204
|
+
if (enableCellNavigation) {
|
2205
|
+
cellNavigation({
|
2206
|
+
cell,
|
2207
|
+
cellValue: cell.getValue(),
|
2208
|
+
event,
|
2209
|
+
table,
|
2210
|
+
});
|
2211
|
+
}
|
2212
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2213
|
+
};
|
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': {
|
2082
2215
|
outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
|
2083
2216
|
(editDisplayMode === 'cell' && isEditable) ||
|
2084
2217
|
(editDisplayMode === 'table' && (isCreating || isEditing))
|
@@ -2245,12 +2378,13 @@ const MRT_TableBodyRow = (_a) => {
|
|
2245
2378
|
staticRowIndex,
|
2246
2379
|
table,
|
2247
2380
|
};
|
2381
|
+
const key = `${cell.id}-${staticRowIndex}`;
|
2248
2382
|
return cell ? (memoMode === 'cells' &&
|
2249
2383
|
cell.column.columnDef.columnDefType === 'data' &&
|
2250
2384
|
!draggingColumn &&
|
2251
2385
|
!draggingRow &&
|
2252
2386
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
2253
|
-
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props),
|
2387
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
|
2254
2388
|
}), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
|
2255
2389
|
};
|
2256
2390
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
@@ -2338,7 +2472,7 @@ const MRT_TableFooterCell = (_a) => {
|
|
2338
2472
|
var _b, _c, _d;
|
2339
2473
|
var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
|
2340
2474
|
const theme = useTheme();
|
2341
|
-
const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
|
2475
|
+
const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableCellNavigation, }, } = table;
|
2342
2476
|
const { density } = getState();
|
2343
2477
|
const { column } = footer;
|
2344
2478
|
const { columnDef } = column;
|
@@ -2348,11 +2482,22 @@ const MRT_TableFooterCell = (_a) => {
|
|
2348
2482
|
column.getIsPinned();
|
2349
2483
|
const args = { column, table };
|
2350
2484
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2485
|
+
const handleKeyDown = (event) => {
|
2486
|
+
var _a;
|
2487
|
+
if (enableCellNavigation) {
|
2488
|
+
cellNavigation({
|
2489
|
+
event,
|
2490
|
+
cellValue: footer.column.columnDef.footer,
|
2491
|
+
table,
|
2492
|
+
});
|
2493
|
+
}
|
2494
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2495
|
+
};
|
2351
2496
|
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
|
2352
2497
|
? 'center'
|
2353
2498
|
: theme.direction === 'rtl'
|
2354
2499
|
? 'right'
|
2355
|
-
: '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'
|
2500
|
+
: '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'
|
2356
2501
|
? '0.5rem'
|
2357
2502
|
: density === 'comfortable'
|
2358
2503
|
? '1rem'
|
@@ -2399,12 +2544,22 @@ const MRT_TableFooterRow = (_a) => {
|
|
2399
2544
|
|
2400
2545
|
const MRT_TableFooter = (_a) => {
|
2401
2546
|
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2402
|
-
const {
|
2547
|
+
const { getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2403
2548
|
const { isFullScreen } = getState();
|
2404
2549
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
2405
2550
|
table,
|
2406
2551
|
})), rest);
|
2407
2552
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
2553
|
+
const footerGroups = table.getFooterGroups();
|
2554
|
+
//if no footer cells at all, skip footer
|
2555
|
+
if (!footerGroups.some((footerGroup) => {
|
2556
|
+
var _a;
|
2557
|
+
return (_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2558
|
+
!!header.column.columnDef.footer) ||
|
2559
|
+
header.column.columnDef.Footer);
|
2560
|
+
})) {
|
2561
|
+
return null;
|
2562
|
+
}
|
2408
2563
|
return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
|
2409
2564
|
tableFooterRef.current = ref;
|
2410
2565
|
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
@@ -2415,7 +2570,7 @@ const MRT_TableFooter = (_a) => {
|
|
2415
2570
|
? theme.palette.mode === 'light'
|
2416
2571
|
? `1px solid ${theme.palette.grey[300]}`
|
2417
2572
|
: `1px solid ${theme.palette.grey[700]}`
|
2418
|
-
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children:
|
2573
|
+
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: footerGroups.map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
|
2419
2574
|
};
|
2420
2575
|
|
2421
2576
|
const mrtFilterOptions = (localization) => [
|
@@ -2958,7 +3113,11 @@ const MRT_FilterTextField = (_a) => {
|
|
2958
3113
|
}
|
2959
3114
|
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
2960
3115
|
? undefined
|
2961
|
-
: 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
|
2962
3121
|
? '160px'
|
2963
3122
|
: enableColumnFilterModes && rangeFilterIndex === 0
|
2964
3123
|
? '110px'
|
@@ -3268,7 +3427,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3268
3427
|
var _b, _c, _d, _f, _g, _h;
|
3269
3428
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
3270
3429
|
const theme = useTheme();
|
3271
|
-
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3430
|
+
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3272
3431
|
const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3273
3432
|
const { column } = header;
|
3274
3433
|
const { columnDef } = column;
|
@@ -3337,6 +3496,18 @@ const MRT_TableHeadCell = (_a) => {
|
|
3337
3496
|
e.preventDefault();
|
3338
3497
|
}
|
3339
3498
|
};
|
3499
|
+
const handleKeyDown = (event) => {
|
3500
|
+
var _a;
|
3501
|
+
if (enableCellNavigation) {
|
3502
|
+
cellNavigation({
|
3503
|
+
event,
|
3504
|
+
cellValue: header.column.columnDef.header,
|
3505
|
+
table,
|
3506
|
+
header,
|
3507
|
+
});
|
3508
|
+
}
|
3509
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
3510
|
+
};
|
3340
3511
|
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3341
3512
|
column,
|
3342
3513
|
header,
|
@@ -3358,7 +3529,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3358
3529
|
(_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
|
3359
3530
|
}
|
3360
3531
|
}
|
3361
|
-
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3532
|
+
}, tabIndex: enableCellNavigation ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3362
3533
|
'.MuiButtonBase-root': {
|
3363
3534
|
opacity: 1,
|
3364
3535
|
},
|
@@ -4145,5 +4316,5 @@ const MaterialReactTable = (props) => {
|
|
4145
4316
|
return jsx(MRT_TablePaper, { table: table });
|
4146
4317
|
};
|
4147
4318
|
|
4148
|
-
export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
4319
|
+
export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, cellNavigation, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
4149
4320
|
//# sourceMappingURL=index.esm.js.map
|