material-react-table 2.10.0 → 2.11.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 +3 -2
- package/dist/index.d.ts +144 -125
- package/dist/index.esm.js +213 -154
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +213 -151
- package/dist/index.js.map +1 -1
- package/locales/ar/index.esm.js +1 -0
- package/locales/ar/index.js +1 -0
- package/locales/az/index.esm.js +1 -0
- package/locales/az/index.js +1 -0
- package/locales/bg/index.esm.js +1 -0
- package/locales/bg/index.js +1 -0
- package/locales/cs/index.esm.js +1 -0
- package/locales/cs/index.js +1 -0
- package/locales/da/index.esm.js +1 -0
- package/locales/da/index.js +1 -0
- package/locales/de/index.esm.js +1 -0
- package/locales/de/index.js +1 -0
- package/locales/en/index.esm.js +1 -0
- package/locales/en/index.js +1 -0
- package/locales/es/index.esm.js +1 -0
- package/locales/es/index.js +1 -0
- package/locales/et/index.esm.js +1 -0
- package/locales/et/index.js +1 -0
- package/locales/fa/index.esm.js +1 -0
- package/locales/fa/index.js +1 -0
- package/locales/fi/index.esm.js +1 -0
- package/locales/fi/index.js +1 -0
- package/locales/fr/index.esm.js +1 -0
- package/locales/fr/index.js +1 -0
- package/locales/he/index.esm.js +1 -0
- package/locales/he/index.js +1 -0
- package/locales/hu/index.esm.js +1 -0
- package/locales/hu/index.js +1 -0
- package/locales/hy/index.esm.js +1 -0
- package/locales/hy/index.js +1 -0
- package/locales/id/index.esm.js +1 -0
- package/locales/id/index.js +1 -0
- package/locales/it/index.esm.js +1 -0
- package/locales/it/index.js +1 -0
- package/locales/ja/index.esm.js +1 -0
- package/locales/ja/index.js +1 -0
- package/locales/ko/index.esm.js +1 -0
- package/locales/ko/index.js +1 -0
- package/locales/nl/index.esm.js +1 -0
- package/locales/nl/index.js +1 -0
- package/locales/no/index.esm.js +1 -0
- package/locales/no/index.js +1 -0
- package/locales/np/index.esm.js +1 -0
- package/locales/np/index.js +1 -0
- package/locales/pl/index.esm.js +1 -0
- package/locales/pl/index.js +1 -0
- package/locales/pt/index.esm.js +1 -0
- package/locales/pt/index.js +1 -0
- package/locales/pt-BR/index.esm.js +1 -0
- package/locales/pt-BR/index.js +1 -0
- package/locales/ro/index.esm.js +1 -0
- package/locales/ro/index.js +1 -0
- package/locales/ru/index.esm.js +1 -0
- package/locales/ru/index.js +1 -0
- package/locales/sk/index.esm.js +1 -0
- package/locales/sk/index.js +1 -0
- package/locales/sr-Cyrl-RS/index.esm.js +1 -0
- package/locales/sr-Cyrl-RS/index.js +1 -0
- package/locales/sr-Latn-RS/index.esm.js +1 -0
- package/locales/sr-Latn-RS/index.js +1 -0
- package/locales/sv/index.esm.js +1 -0
- package/locales/sv/index.js +1 -0
- package/locales/tr/index.esm.js +1 -0
- package/locales/tr/index.js +1 -0
- package/locales/uk/index.esm.js +1 -0
- package/locales/uk/index.js +1 -0
- package/locales/vi/index.esm.js +1 -0
- package/locales/vi/index.js +1 -0
- package/locales/zh-Hans/index.esm.js +1 -0
- package/locales/zh-Hans/index.js +1 -0
- package/locales/zh-Hant/index.esm.js +1 -0
- package/locales/zh-Hant/index.js +1 -0
- package/package.json +18 -18
- package/src/components/MaterialReactTable.tsx +3 -3
- package/src/components/body/MRT_TableBody.tsx +3 -2
- package/src/components/body/MRT_TableBodyCell.tsx +4 -2
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -2
- package/src/components/body/MRT_TableBodyRow.tsx +13 -8
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -3
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +3 -2
- package/src/components/body/MRT_TableDetailPanel.tsx +3 -2
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +3 -2
- package/src/components/buttons/MRT_CopyButton.tsx +3 -2
- package/src/components/buttons/MRT_EditActionButtons.tsx +3 -2
- package/src/components/buttons/MRT_ExpandAllButton.tsx +3 -2
- package/src/components/buttons/MRT_ExpandButton.tsx +3 -2
- package/src/components/buttons/MRT_GrabHandleButton.tsx +9 -15
- package/src/components/buttons/MRT_RowPinButton.tsx +3 -2
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +3 -2
- package/src/components/footer/MRT_TableFooter.tsx +3 -2
- package/src/components/footer/MRT_TableFooterCell.tsx +3 -2
- package/src/components/footer/MRT_TableFooterRow.tsx +5 -3
- package/src/components/head/MRT_TableHead.tsx +3 -2
- package/src/components/head/MRT_TableHeadCell.tsx +3 -5
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +3 -2
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +4 -3
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +3 -2
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +3 -2
- package/src/components/head/MRT_TableHeadRow.tsx +3 -2
- package/src/components/inputs/MRT_EditCellTextField.tsx +3 -2
- package/src/components/inputs/MRT_FilterCheckbox.tsx +3 -2
- package/src/components/inputs/MRT_FilterRangeFields.tsx +3 -2
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +3 -2
- package/src/components/inputs/MRT_FilterTextField.tsx +15 -6
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +3 -2
- package/src/components/inputs/MRT_SelectCheckbox.tsx +28 -35
- package/src/components/menus/MRT_ActionMenuItem.tsx +3 -2
- package/src/components/menus/MRT_CellActionMenu.tsx +5 -4
- package/src/components/menus/MRT_ColumnActionMenu.tsx +5 -4
- package/src/components/menus/MRT_FilterOptionMenu.tsx +3 -2
- package/src/components/menus/MRT_RowActionMenu.tsx +3 -2
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +8 -2
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -5
- package/src/components/modals/MRT_EditRowModal.tsx +3 -2
- package/src/components/table/MRT_Table.tsx +2 -2
- package/src/components/table/MRT_TableContainer.tsx +3 -2
- package/src/components/table/MRT_TableLoadingOverlay.tsx +11 -8
- package/src/components/table/MRT_TablePaper.tsx +3 -2
- package/src/components/toolbar/MRT_BottomToolbar.tsx +3 -2
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +3 -2
- package/src/components/toolbar/MRT_TablePagination.tsx +2 -2
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +30 -13
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +3 -2
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +3 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +2 -2
- package/src/hooks/useMRT_Effects.ts +11 -11
- package/src/hooks/useMRT_Rows.ts +11 -79
- package/src/hooks/useMRT_TableInstance.ts +2 -0
- package/src/hooks/useMRT_TableOptions.ts +2 -0
- package/src/locales/ar.ts +1 -0
- package/src/locales/az.ts +1 -0
- package/src/locales/bg.ts +1 -0
- package/src/locales/cs.ts +1 -0
- package/src/locales/da.ts +1 -0
- package/src/locales/de.ts +1 -0
- package/src/locales/en.ts +1 -0
- package/src/locales/es.ts +1 -0
- package/src/locales/et.ts +1 -0
- package/src/locales/fa.ts +1 -0
- package/src/locales/fi.ts +1 -0
- package/src/locales/fr.ts +1 -0
- package/src/locales/he.ts +1 -0
- package/src/locales/hu.ts +1 -0
- package/src/locales/hy.ts +1 -0
- package/src/locales/id.ts +1 -0
- package/src/locales/it.ts +1 -0
- package/src/locales/ja.ts +1 -0
- package/src/locales/ko.ts +1 -0
- package/src/locales/nl.ts +1 -0
- package/src/locales/no.ts +1 -0
- package/src/locales/np.ts +1 -0
- package/src/locales/pl.ts +1 -0
- package/src/locales/pt-BR.ts +1 -0
- package/src/locales/pt.ts +1 -0
- package/src/locales/ro.ts +1 -0
- package/src/locales/ru.ts +1 -0
- package/src/locales/sk.ts +1 -0
- package/src/locales/sr-Cyrl-RS.ts +1 -0
- package/src/locales/sr-Latn-RS.ts +1 -0
- package/src/locales/sv.ts +1 -0
- package/src/locales/tr.ts +1 -0
- package/src/locales/uk.ts +1 -0
- package/src/locales/vi.ts +1 -0
- package/src/locales/zh-Hans.ts +1 -0
- package/src/locales/zh-Hant.ts +1 -0
- package/src/types.ts +10 -4
- package/src/utils/column.utils.ts +4 -6
- package/src/utils/displayColumn.utils.ts +1 -1
- package/src/utils/row.utils.ts +196 -21
- package/locales/am/index.d.ts +0 -3
- package/locales/am/index.esm.d.ts +0 -3
- package/locales/am/index.esm.js +0 -93
- package/locales/am/index.js +0 -97
- package/locales/am/package.json +0 -6
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns,
|
|
2
|
-
import { rankItem, rankings
|
|
1
|
+
import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, aggregationFns, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
|
|
2
|
+
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
|
|
3
3
|
import { useState, useMemo, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import IconButton from '@mui/material/IconButton';
|
|
@@ -160,13 +160,12 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
|
160
160
|
return newColumnOrder;
|
|
161
161
|
};
|
|
162
162
|
const getDefaultColumnFilterFn = (columnDef) => {
|
|
163
|
-
|
|
164
|
-
if (
|
|
163
|
+
const { filterVariant } = columnDef;
|
|
164
|
+
if (filterVariant === 'multi-select')
|
|
165
165
|
return 'arrIncludesSome';
|
|
166
|
-
if (
|
|
166
|
+
if (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range'))
|
|
167
167
|
return 'betweenInclusive';
|
|
168
|
-
if (
|
|
169
|
-
columnDef.filterVariant === 'checkbox')
|
|
168
|
+
if (filterVariant === 'select' || filterVariant === 'checkbox')
|
|
170
169
|
return 'equals';
|
|
171
170
|
return 'fuzzy';
|
|
172
171
|
};
|
|
@@ -269,7 +268,7 @@ const showRowDragColumn = (tableOptions) => {
|
|
|
269
268
|
const showRowExpandColumn = (tableOptions) => {
|
|
270
269
|
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
|
|
271
270
|
return !!(enableExpanding ||
|
|
272
|
-
(enableGrouping && (grouping ===
|
|
271
|
+
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
|
|
273
272
|
renderDetailPanel);
|
|
274
273
|
};
|
|
275
274
|
const showRowActionsColumn = (tableOptions) => {
|
|
@@ -319,16 +318,65 @@ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
|
|
319
318
|
];
|
|
320
319
|
};
|
|
321
320
|
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
(
|
|
326
|
-
|
|
327
|
-
|
|
321
|
+
const fuzzy$1 = (rowA, rowB, columnId) => {
|
|
322
|
+
let dir = 0;
|
|
323
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
|
324
|
+
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
|
325
|
+
}
|
|
326
|
+
// Provide a fallback for when the item ranks are equal
|
|
327
|
+
return dir === 0
|
|
328
|
+
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
|
329
|
+
: dir;
|
|
330
|
+
};
|
|
331
|
+
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
|
|
332
|
+
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
|
333
|
+
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
|
334
|
+
|
|
335
|
+
const getMRT_Rows = (table, pinnedRowIds = [], all) => {
|
|
336
|
+
const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
|
|
337
|
+
const { creatingRow, pagination } = getState();
|
|
338
|
+
const isRankingRows = getIsRankingRows(table);
|
|
339
|
+
let rows = [];
|
|
340
|
+
if (!isRankingRows) {
|
|
341
|
+
rows =
|
|
342
|
+
!enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
|
|
343
|
+
? all
|
|
344
|
+
? getPrePaginationRowModel().rows
|
|
345
|
+
: getRowModel().rows
|
|
346
|
+
: getCenterRows();
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
|
|
350
|
+
if (enablePagination && !manualPagination && !all) {
|
|
351
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
|
352
|
+
rows = rows.slice(start, start + pagination.pageSize);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
|
|
356
|
+
rows = [
|
|
357
|
+
...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
|
358
|
+
...rows,
|
|
359
|
+
...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
if (positionCreatingRow !== undefined &&
|
|
363
|
+
creatingRow &&
|
|
364
|
+
createDisplayMode === 'row') {
|
|
365
|
+
const creatingRowIndex = !isNaN(+positionCreatingRow)
|
|
366
|
+
? +positionCreatingRow
|
|
367
|
+
: positionCreatingRow === 'top'
|
|
368
|
+
? 0
|
|
369
|
+
: rows.length;
|
|
370
|
+
rows = [
|
|
371
|
+
...rows.slice(0, creatingRowIndex),
|
|
372
|
+
creatingRow,
|
|
373
|
+
...rows.slice(creatingRowIndex),
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
return rows;
|
|
328
377
|
};
|
|
329
378
|
const getCanRankRows = (table) => {
|
|
330
|
-
const { getState, options } = table;
|
|
331
|
-
const { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, } = options;
|
|
379
|
+
const { getState, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
|
|
332
380
|
const { expanded, globalFilterFn } = getState();
|
|
333
381
|
return (!manualExpanding &&
|
|
334
382
|
!manualFiltering &&
|
|
@@ -339,17 +387,77 @@ const getCanRankRows = (table) => {
|
|
|
339
387
|
expanded !== true &&
|
|
340
388
|
!Object.values(expanded).some(Boolean));
|
|
341
389
|
};
|
|
390
|
+
const getIsRankingRows = (table) => {
|
|
391
|
+
const { globalFilter, sorting } = table.getState();
|
|
392
|
+
return (getCanRankRows(table) &&
|
|
393
|
+
globalFilter &&
|
|
394
|
+
!Object.values(sorting).some(Boolean));
|
|
395
|
+
};
|
|
396
|
+
const getIsRowSelected = ({ row, table, }) => {
|
|
397
|
+
const { options: { enableRowSelection }, } = table;
|
|
398
|
+
return (row.getIsSelected() ||
|
|
399
|
+
(parseFromValuesOrFunc(enableRowSelection, row) &&
|
|
400
|
+
row.getCanSelectSubRows() &&
|
|
401
|
+
row.getIsAllSubRowsSelected()));
|
|
402
|
+
};
|
|
403
|
+
const getMRT_RowSelectionHandler = () => ({ event, row, staticRowIndex = 0, table, }) => {
|
|
404
|
+
var _a;
|
|
405
|
+
const { getState, options: { enableBatchRowSelection, enableRowPinning, manualPagination, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
|
|
406
|
+
const { pagination: { pageIndex, pageSize }, } = getState();
|
|
407
|
+
const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
|
|
408
|
+
const isCurrentRowChecked = getIsRowSelected({ row, table });
|
|
409
|
+
const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
|
|
410
|
+
// toggle selection of this row
|
|
411
|
+
row.getToggleSelectedHandler()(event);
|
|
412
|
+
// if shift key is pressed, select all rows between last selected and this one
|
|
413
|
+
if (enableBatchRowSelection &&
|
|
414
|
+
event.nativeEvent.shiftKey &&
|
|
415
|
+
lastSelectedRowId.current !== null) {
|
|
416
|
+
const rows = getMRT_Rows(table, undefined, true);
|
|
417
|
+
const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
|
|
418
|
+
if (lastIndex !== -1) {
|
|
419
|
+
const isLastIndexChecked = getIsRowSelected({
|
|
420
|
+
row: rows === null || rows === void 0 ? void 0 : rows[lastIndex],
|
|
421
|
+
table,
|
|
422
|
+
});
|
|
423
|
+
const currentIndex = staticRowIndex + paginationOffset;
|
|
424
|
+
const [start, end] = lastIndex < currentIndex
|
|
425
|
+
? [lastIndex, currentIndex]
|
|
426
|
+
: [currentIndex, lastIndex];
|
|
427
|
+
// toggle selection of all rows between last selected and this one
|
|
428
|
+
// but only if the last selected row is not the same as the current one
|
|
429
|
+
if (isCurrentRowChecked !== isLastIndexChecked) {
|
|
430
|
+
for (let i = start; i <= end; i++) {
|
|
431
|
+
rows[i].toggleSelected(!isCurrentRowChecked);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// record the last selected row id
|
|
437
|
+
lastSelectedRowId.current = row.id;
|
|
438
|
+
// if all sub rows were selected, unselect them
|
|
439
|
+
if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
|
|
440
|
+
(_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
|
|
441
|
+
}
|
|
442
|
+
if (isStickySelection) {
|
|
443
|
+
row.pin(!row.getIsPinned() && isCurrentRowChecked
|
|
444
|
+
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
|
445
|
+
? 'bottom'
|
|
446
|
+
: 'top'
|
|
447
|
+
: false);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
342
450
|
|
|
343
451
|
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
|
344
452
|
|
|
345
|
-
const fuzzy
|
|
453
|
+
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
346
454
|
const itemRank = rankItem(row.getValue(columnId), filterValue, {
|
|
347
455
|
threshold: rankings.MATCHES,
|
|
348
456
|
});
|
|
349
457
|
addMeta(itemRank);
|
|
350
458
|
return itemRank.passed;
|
|
351
459
|
};
|
|
352
|
-
fuzzy
|
|
460
|
+
fuzzy.autoRemove = (val) => !val;
|
|
353
461
|
const contains = (row, id, filterValue) => row
|
|
354
462
|
.getValue(id)
|
|
355
463
|
.toString()
|
|
@@ -417,7 +525,7 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
|
417
525
|
empty,
|
|
418
526
|
endsWith,
|
|
419
527
|
equals,
|
|
420
|
-
fuzzy
|
|
528
|
+
fuzzy,
|
|
421
529
|
greaterThan,
|
|
422
530
|
greaterThanOrEqualTo,
|
|
423
531
|
lessThan,
|
|
@@ -426,20 +534,6 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
|
426
534
|
notEquals,
|
|
427
535
|
startsWith });
|
|
428
536
|
|
|
429
|
-
const fuzzy = (rowA, rowB, columnId) => {
|
|
430
|
-
let dir = 0;
|
|
431
|
-
if (rowA.columnFiltersMeta[columnId]) {
|
|
432
|
-
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
|
433
|
-
}
|
|
434
|
-
// Provide a fallback for when the item ranks are equal
|
|
435
|
-
return dir === 0
|
|
436
|
-
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
|
437
|
-
: dir;
|
|
438
|
-
};
|
|
439
|
-
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy });
|
|
440
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
|
441
|
-
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
|
442
|
-
|
|
443
537
|
/******************************************************************************
|
|
444
538
|
Copyright (c) Microsoft Corporation.
|
|
445
539
|
|
|
@@ -695,19 +789,18 @@ const getMRT_RowActionsColumnDef = (tableOptions) => {
|
|
|
695
789
|
|
|
696
790
|
const MRT_GrabHandleButton = (_a) => {
|
|
697
791
|
var _b, _c;
|
|
698
|
-
var {
|
|
792
|
+
var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
|
|
699
793
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
700
|
-
|
|
701
|
-
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
|
|
794
|
+
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, rest, { onClick: (e) => {
|
|
702
795
|
var _a;
|
|
703
796
|
e.stopPropagation();
|
|
704
|
-
(_a =
|
|
705
|
-
},
|
|
797
|
+
(_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
|
|
798
|
+
}, sx: (theme) => (Object.assign({ '&:active': {
|
|
706
799
|
cursor: 'grabbing',
|
|
707
800
|
}, '&:hover': {
|
|
708
801
|
backgroundColor: 'transparent',
|
|
709
802
|
opacity: 1,
|
|
710
|
-
}, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.
|
|
803
|
+
}, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) })));
|
|
711
804
|
};
|
|
712
805
|
|
|
713
806
|
const MRT_TableBodyRowGrabHandle = (_a) => {
|
|
@@ -734,7 +827,7 @@ const MRT_TableBodyRowGrabHandle = (_a) => {
|
|
|
734
827
|
table.setDraggingRow(null);
|
|
735
828
|
table.setHoveredRow(null);
|
|
736
829
|
};
|
|
737
|
-
return (jsx(MRT_GrabHandleButton, { iconButtonProps
|
|
830
|
+
return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
|
|
738
831
|
};
|
|
739
832
|
|
|
740
833
|
const getMRT_RowDragColumnDef = (tableOptions) => {
|
|
@@ -898,36 +991,25 @@ const getMRT_RowPinningColumnDef = (tableOptions) => {
|
|
|
898
991
|
const MRT_SelectCheckbox = (_a) => {
|
|
899
992
|
var _b;
|
|
900
993
|
var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
|
|
901
|
-
const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
|
|
994
|
+
const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, refs: { lastSelectedRowId }, } = table;
|
|
902
995
|
const { density, isLoading } = getState();
|
|
903
996
|
const selectAll = !row;
|
|
904
|
-
const checkboxProps = Object.assign(Object.assign({}, (!row
|
|
905
|
-
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
|
906
|
-
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
907
|
-
row,
|
|
908
|
-
staticRowIndex,
|
|
909
|
-
table,
|
|
910
|
-
}))), rest);
|
|
911
997
|
const isStickySelection = enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'));
|
|
912
998
|
const allRowsSelected = selectAll
|
|
913
999
|
? selectAllMode === 'page'
|
|
914
1000
|
? table.getIsAllPageRowsSelected()
|
|
915
1001
|
: table.getIsAllRowsSelected()
|
|
916
1002
|
: undefined;
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
: 'top'
|
|
928
|
-
: false);
|
|
929
|
-
}
|
|
930
|
-
};
|
|
1003
|
+
const isChecked = selectAll
|
|
1004
|
+
? allRowsSelected
|
|
1005
|
+
: getIsRowSelected({ row, table });
|
|
1006
|
+
const checkboxProps = Object.assign(Object.assign({}, (selectAll
|
|
1007
|
+
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
|
1008
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
1009
|
+
row,
|
|
1010
|
+
table,
|
|
1011
|
+
}))), rest);
|
|
1012
|
+
const onSelectionChange = getMRT_RowSelectionHandler();
|
|
931
1013
|
const onSelectAllChange = (event) => {
|
|
932
1014
|
selectAllMode === 'all'
|
|
933
1015
|
? table.getToggleAllRowsSelectedHandler()(event)
|
|
@@ -935,16 +1017,19 @@ const MRT_SelectCheckbox = (_a) => {
|
|
|
935
1017
|
if (isStickySelection) {
|
|
936
1018
|
table.setRowPinning({ bottom: [], top: [] });
|
|
937
1019
|
}
|
|
1020
|
+
lastSelectedRowId.current = null;
|
|
938
1021
|
};
|
|
939
1022
|
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
|
940
1023
|
? localization.toggleSelectAll
|
|
941
|
-
: localization.toggleSelectRow, checked:
|
|
1024
|
+
: localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
|
942
1025
|
'aria-label': selectAll
|
|
943
1026
|
? localization.toggleSelectAll
|
|
944
1027
|
: localization.toggleSelectRow,
|
|
945
1028
|
}, onChange: (event) => {
|
|
946
1029
|
event.stopPropagation();
|
|
947
|
-
row
|
|
1030
|
+
row
|
|
1031
|
+
? onSelectionChange({ event, row, staticRowIndex, table })
|
|
1032
|
+
: onSelectAllChange(event);
|
|
948
1033
|
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
949
1034
|
var _a;
|
|
950
1035
|
e.stopPropagation();
|
|
@@ -952,8 +1037,8 @@ const MRT_SelectCheckbox = (_a) => {
|
|
|
952
1037
|
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
|
|
953
1038
|
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
|
|
954
1039
|
? localization.toggleSelectAll
|
|
955
|
-
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: selectAll
|
|
956
|
-
? table.getIsSomeRowsSelected()
|
|
1040
|
+
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: !isChecked && selectAll
|
|
1041
|
+
? table.getIsSomeRowsSelected()
|
|
957
1042
|
: (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
|
|
958
1043
|
};
|
|
959
1044
|
|
|
@@ -1014,6 +1099,7 @@ const MRT_Localization_EN = {
|
|
|
1014
1099
|
changeSearchMode: 'Change search mode',
|
|
1015
1100
|
clearFilter: 'Clear filter',
|
|
1016
1101
|
clearSearch: 'Clear search',
|
|
1102
|
+
clearSelection: 'Clear selection',
|
|
1017
1103
|
clearSort: 'Clear sort',
|
|
1018
1104
|
clickToCopy: 'Click to copy',
|
|
1019
1105
|
copy: 'Copy',
|
|
@@ -1121,7 +1207,7 @@ const MRT_DefaultDisplayColumn = {
|
|
|
1121
1207
|
};
|
|
1122
1208
|
const useMRT_TableOptions = (_a) => {
|
|
1123
1209
|
var _b;
|
|
1124
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', 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, 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", "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", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
|
1210
|
+
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, 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", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
|
1125
1211
|
const theme = useTheme();
|
|
1126
1212
|
icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
|
1127
1213
|
localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
|
@@ -1162,6 +1248,7 @@ const useMRT_TableOptions = (_a) => {
|
|
|
1162
1248
|
defaultColumn,
|
|
1163
1249
|
defaultDisplayColumn,
|
|
1164
1250
|
editDisplayMode,
|
|
1251
|
+
enableBatchRowSelection,
|
|
1165
1252
|
enableBottomToolbar,
|
|
1166
1253
|
enableColumnActions,
|
|
1167
1254
|
enableColumnFilters,
|
|
@@ -1244,7 +1331,6 @@ const useMRT_Effects = (table) => {
|
|
|
1244
1331
|
const totalColumnCount = table.options.columns.length;
|
|
1245
1332
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
|
1246
1333
|
const rerender = useReducer(() => ({}), {})[1];
|
|
1247
|
-
const isMounted = useRef(false);
|
|
1248
1334
|
const initialBodyHeight = useRef();
|
|
1249
1335
|
const previousTop = useRef();
|
|
1250
1336
|
useEffect(() => {
|
|
@@ -1252,11 +1338,12 @@ const useMRT_Effects = (table) => {
|
|
|
1252
1338
|
initialBodyHeight.current = document.body.style.height;
|
|
1253
1339
|
}
|
|
1254
1340
|
}, []);
|
|
1341
|
+
//hide scrollbars when table is in full screen mode, preserve body scroll position after full screen exit
|
|
1255
1342
|
useEffect(() => {
|
|
1256
|
-
if (
|
|
1343
|
+
if (typeof window !== 'undefined') {
|
|
1257
1344
|
if (isFullScreen) {
|
|
1258
1345
|
previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
|
|
1259
|
-
document.body.style.height = '
|
|
1346
|
+
document.body.style.height = '100dvh'; //hide page scrollbars when table is in full screen mode
|
|
1260
1347
|
}
|
|
1261
1348
|
else {
|
|
1262
1349
|
document.body.style.height = initialBodyHeight.current;
|
|
@@ -1269,8 +1356,13 @@ const useMRT_Effects = (table) => {
|
|
|
1269
1356
|
});
|
|
1270
1357
|
}
|
|
1271
1358
|
}
|
|
1272
|
-
isMounted.current = true;
|
|
1273
1359
|
}, [isFullScreen]);
|
|
1360
|
+
//recalculate column order when columns change or features are toggled on/off
|
|
1361
|
+
useEffect(() => {
|
|
1362
|
+
if (totalColumnCount !== columnOrder.length) {
|
|
1363
|
+
table.setColumnOrder(getDefaultColumnOrderIds(table.options));
|
|
1364
|
+
}
|
|
1365
|
+
}, [totalColumnCount]);
|
|
1274
1366
|
//if page index is out of bounds, set it to the last page
|
|
1275
1367
|
useEffect(() => {
|
|
1276
1368
|
if (!enablePagination || isLoading || showSkeletons)
|
|
@@ -1298,6 +1390,7 @@ const useMRT_Effects = (table) => {
|
|
|
1298
1390
|
table.setSorting(() => appliedSort.current || []);
|
|
1299
1391
|
}
|
|
1300
1392
|
}, [globalFilter]);
|
|
1393
|
+
//fix pinned row top style when density changes
|
|
1301
1394
|
useEffect(() => {
|
|
1302
1395
|
if (enableRowPinning && getIsSomeRowsPinned()) {
|
|
1303
1396
|
setTimeout(() => {
|
|
@@ -1305,12 +1398,6 @@ const useMRT_Effects = (table) => {
|
|
|
1305
1398
|
}, 150);
|
|
1306
1399
|
}
|
|
1307
1400
|
}, [density]);
|
|
1308
|
-
//recalculate column order when columns change or features are toggled on/off
|
|
1309
|
-
useEffect(() => {
|
|
1310
|
-
if (totalColumnCount !== columnOrder.length) {
|
|
1311
|
-
table.setColumnOrder(getDefaultColumnOrderIds(table.options));
|
|
1312
|
-
}
|
|
1313
|
-
}, [totalColumnCount]);
|
|
1314
1401
|
};
|
|
1315
1402
|
|
|
1316
1403
|
/**
|
|
@@ -1320,6 +1407,7 @@ const useMRT_Effects = (table) => {
|
|
|
1320
1407
|
*/
|
|
1321
1408
|
const useMRT_TableInstance = (definedTableOptions) => {
|
|
1322
1409
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
|
1410
|
+
const lastSelectedRowId = useRef(null);
|
|
1323
1411
|
const actionCellRef = useRef(null);
|
|
1324
1412
|
const bottomToolbarRef = useRef(null);
|
|
1325
1413
|
const editInputRefs = useRef({});
|
|
@@ -1446,6 +1534,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
1446
1534
|
bottomToolbarRef,
|
|
1447
1535
|
editInputRefs,
|
|
1448
1536
|
filterInputRefs,
|
|
1537
|
+
lastSelectedRowId,
|
|
1449
1538
|
searchInputRef,
|
|
1450
1539
|
tableContainerRef,
|
|
1451
1540
|
tableFooterRef,
|
|
@@ -1601,71 +1690,26 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
|
1601
1690
|
};
|
|
1602
1691
|
|
|
1603
1692
|
const useMRT_Rows = (table, pinnedRowIds = []) => {
|
|
1604
|
-
const {
|
|
1693
|
+
const { getRowModel, getState, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table;
|
|
1605
1694
|
const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState();
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
|
|
1695
|
+
const rows = useMemo(() => getMRT_Rows(table, pinnedRowIds), [
|
|
1696
|
+
creatingRow,
|
|
1697
|
+
data,
|
|
1609
1698
|
enableGlobalFilterRankedResults,
|
|
1610
1699
|
expanded,
|
|
1700
|
+
getRowModel().rows,
|
|
1611
1701
|
globalFilter,
|
|
1612
|
-
manualExpanding,
|
|
1613
|
-
manualFiltering,
|
|
1614
|
-
manualGrouping,
|
|
1615
|
-
manualSorting,
|
|
1616
|
-
sorting,
|
|
1617
|
-
]);
|
|
1618
|
-
const rows = useMemo(() => {
|
|
1619
|
-
let rows = [];
|
|
1620
|
-
if (!shouldRankRows) {
|
|
1621
|
-
rows =
|
|
1622
|
-
!enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
|
|
1623
|
-
? getRowModel().rows
|
|
1624
|
-
: getCenterRows();
|
|
1625
|
-
}
|
|
1626
|
-
else {
|
|
1627
|
-
rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
|
|
1628
|
-
if (enablePagination && !manualPagination) {
|
|
1629
|
-
const start = pagination.pageIndex * pagination.pageSize;
|
|
1630
|
-
rows = rows.slice(start, start + pagination.pageSize);
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
|
|
1634
|
-
rows = [
|
|
1635
|
-
...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
|
1636
|
-
...rows,
|
|
1637
|
-
...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
|
1638
|
-
];
|
|
1639
|
-
}
|
|
1640
|
-
if (positionCreatingRow !== undefined &&
|
|
1641
|
-
creatingRow &&
|
|
1642
|
-
createDisplayMode === 'row') {
|
|
1643
|
-
const creatingRowIndex = !isNaN(+positionCreatingRow)
|
|
1644
|
-
? +positionCreatingRow
|
|
1645
|
-
: positionCreatingRow === 'top'
|
|
1646
|
-
? 0
|
|
1647
|
-
: rows.length;
|
|
1648
|
-
rows = [
|
|
1649
|
-
...rows.slice(0, creatingRowIndex),
|
|
1650
|
-
creatingRow,
|
|
1651
|
-
...rows.slice(creatingRowIndex),
|
|
1652
|
-
];
|
|
1653
|
-
}
|
|
1654
|
-
return rows;
|
|
1655
|
-
}, [
|
|
1656
|
-
creatingRow,
|
|
1657
1702
|
pagination.pageIndex,
|
|
1658
1703
|
pagination.pageSize,
|
|
1659
1704
|
positionCreatingRow,
|
|
1660
1705
|
rowPinning,
|
|
1661
|
-
|
|
1662
|
-
shouldRankRows,
|
|
1706
|
+
sorting,
|
|
1663
1707
|
]);
|
|
1664
1708
|
return rows;
|
|
1665
1709
|
};
|
|
1666
1710
|
|
|
1667
1711
|
const allowedTypes = ['string', 'number'];
|
|
1668
|
-
const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
|
|
1712
|
+
const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowIndex, table, }) => {
|
|
1669
1713
|
var _a, _b, _c;
|
|
1670
1714
|
const { getState, options: { enableFilterMatchHighlighting }, } = table;
|
|
1671
1715
|
const { column, row } = cell;
|
|
@@ -1728,6 +1772,7 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
|
|
|
1728
1772
|
renderedCellValue,
|
|
1729
1773
|
row,
|
|
1730
1774
|
rowRef,
|
|
1775
|
+
staticColumnIndex,
|
|
1731
1776
|
staticRowIndex,
|
|
1732
1777
|
table,
|
|
1733
1778
|
});
|
|
@@ -2014,6 +2059,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
2014
2059
|
renderedCellValue: cell.renderValue(),
|
|
2015
2060
|
row,
|
|
2016
2061
|
rowRef,
|
|
2062
|
+
staticColumnIndex,
|
|
2017
2063
|
staticRowIndex,
|
|
2018
2064
|
table,
|
|
2019
2065
|
})) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
|
|
@@ -2054,8 +2100,9 @@ const MRT_TableDetailPanel = (_a) => {
|
|
|
2054
2100
|
: undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: enableRowVirtualization ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
|
|
2055
2101
|
};
|
|
2056
2102
|
|
|
2057
|
-
const MRT_TableBodyRow = (
|
|
2058
|
-
var
|
|
2103
|
+
const MRT_TableBodyRow = (_a) => {
|
|
2104
|
+
var _b, _c, _d, _f;
|
|
2105
|
+
var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
|
|
2059
2106
|
const theme = useTheme();
|
|
2060
2107
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
|
2061
2108
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
|
@@ -2065,11 +2112,11 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
|
|
|
2065
2112
|
const isRowPinned = enableRowPinning && row.getIsPinned();
|
|
2066
2113
|
const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
|
|
2067
2114
|
const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
|
|
2068
|
-
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
|
2115
|
+
const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyRowProps, {
|
|
2069
2116
|
row,
|
|
2070
2117
|
staticRowIndex,
|
|
2071
2118
|
table,
|
|
2072
|
-
});
|
|
2119
|
+
})), rest);
|
|
2073
2120
|
const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
|
|
2074
2121
|
if (!enableRowPinning ||
|
|
2075
2122
|
!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
|
|
@@ -2082,14 +2129,14 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
|
|
|
2082
2129
|
];
|
|
2083
2130
|
}, [pinnedRowIds, rowPinning]);
|
|
2084
2131
|
const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
|
|
2085
|
-
((
|
|
2132
|
+
((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
|
|
2086
2133
|
0;
|
|
2087
|
-
const tableFooterHeight = (enableStickyFooter && ((
|
|
2134
|
+
const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
|
|
2088
2135
|
const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
|
|
2089
2136
|
const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
|
|
2090
2137
|
const customRowHeight =
|
|
2091
2138
|
// @ts-ignore
|
|
2092
|
-
parseInt((
|
|
2139
|
+
parseInt((_f = (_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height) !== null && _f !== void 0 ? _f : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
|
|
2093
2140
|
const rowHeight = customRowHeight || defaultRowHeight;
|
|
2094
2141
|
const handleDragEnter = (_e) => {
|
|
2095
2142
|
if (enableRowOrdering && draggingRow) {
|
|
@@ -2279,8 +2326,9 @@ const MRT_TableFooterRow = (_a) => {
|
|
|
2279
2326
|
// if no content in row, skip row
|
|
2280
2327
|
if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
|
2281
2328
|
!!header.column.columnDef.footer) ||
|
|
2282
|
-
header.column.columnDef.Footer)))
|
|
2329
|
+
header.column.columnDef.Footer))) {
|
|
2283
2330
|
return null;
|
|
2331
|
+
}
|
|
2284
2332
|
const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
|
|
2285
2333
|
footerGroup,
|
|
2286
2334
|
table,
|
|
@@ -2522,7 +2570,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
|
2522
2570
|
const MRT_ColumnActionMenu = (_a) => {
|
|
2523
2571
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
2524
2572
|
var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
|
|
2525
|
-
const {
|
|
2573
|
+
const { getAllLeafColumns, getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
|
|
2526
2574
|
const { column } = header;
|
|
2527
2575
|
const { columnDef } = column;
|
|
2528
2576
|
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
|
@@ -2770,6 +2818,7 @@ const MRT_FilterTextField = (_a) => {
|
|
|
2770
2818
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
|
2771
2819
|
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
|
2772
2820
|
});
|
|
2821
|
+
const [autocompleteValue, setAutocompleteValue] = useState(isAutocompleteFilter ? filterValue : null);
|
|
2773
2822
|
const handleChangeDebounced = useCallback(debounce((newValue) => {
|
|
2774
2823
|
if (isRangeFilter) {
|
|
2775
2824
|
column.setFilterValue((old) => {
|
|
@@ -2796,6 +2845,10 @@ const MRT_FilterTextField = (_a) => {
|
|
|
2796
2845
|
handleChange(newValue);
|
|
2797
2846
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
2798
2847
|
};
|
|
2848
|
+
const handleAutocompleteChange = (newValue) => {
|
|
2849
|
+
setAutocompleteValue(newValue);
|
|
2850
|
+
handleChange(getValueAndLabel(newValue).value);
|
|
2851
|
+
};
|
|
2799
2852
|
const handleClear = () => {
|
|
2800
2853
|
if (isMultiSelectFilter) {
|
|
2801
2854
|
setFilterValue([]);
|
|
@@ -2916,10 +2969,10 @@ const MRT_FilterTextField = (_a) => {
|
|
|
2916
2969
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
|
2917
2970
|
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field),
|
|
2918
2971
|
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
|
2919
|
-
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) =>
|
|
2972
|
+
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
|
2920
2973
|
var _a;
|
|
2921
2974
|
return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
|
|
2922
|
-
}, value:
|
|
2975
|
+
}, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
|
2923
2976
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
|
2924
2977
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
|
2925
2978
|
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
|
@@ -3119,7 +3172,7 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
|
3119
3172
|
setDraggingColumn(null);
|
|
3120
3173
|
setHoveredColumn(null);
|
|
3121
3174
|
};
|
|
3122
|
-
return (jsx(MRT_GrabHandleButton, { iconButtonProps
|
|
3175
|
+
return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
|
|
3123
3176
|
};
|
|
3124
3177
|
|
|
3125
3178
|
const MRT_TableHeadCellResizeHandle = (_a) => {
|
|
@@ -3341,7 +3394,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
3341
3394
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
|
3342
3395
|
? 'nowrap'
|
|
3343
3396
|
: 'normal',
|
|
3344
|
-
},
|
|
3397
|
+
}, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
|
3345
3398
|
whiteSpace: 'nowrap',
|
|
3346
3399
|
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
|
3347
3400
|
current: tableHeadCellRefs.current[column.id],
|
|
@@ -3372,7 +3425,7 @@ const MRT_TableHeadRow = (_a) => {
|
|
|
3372
3425
|
const MRT_ToolbarAlertBanner = (_a) => {
|
|
3373
3426
|
var _b, _c, _d;
|
|
3374
3427
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
|
3375
|
-
const { getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
|
3428
|
+
const { getFilteredSelectedRowModel, getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { lastSelectedRowId, tablePaperRef }, } = table;
|
|
3376
3429
|
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
|
3377
3430
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
|
3378
3431
|
table,
|
|
@@ -3380,10 +3433,14 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
|
3380
3433
|
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
|
3381
3434
|
table,
|
|
3382
3435
|
});
|
|
3383
|
-
const
|
|
3384
|
-
const
|
|
3385
|
-
?
|
|
3386
|
-
:
|
|
3436
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
|
3437
|
+
const selectedRowCount = useMemo(() => manualPagination
|
|
3438
|
+
? Object.values(rowSelection).filter(Boolean).length
|
|
3439
|
+
: getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
|
|
3440
|
+
const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { alignItems: "center", direction: "row", gap: "16px", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toString()), jsx(Button, { onClick: () => {
|
|
3441
|
+
table.toggleAllRowsSelected(false);
|
|
3442
|
+
lastSelectedRowId.current = null;
|
|
3443
|
+
}, size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
|
|
3387
3444
|
const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
|
3388
3445
|
return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
|
3389
3446
|
var _a, _b;
|
|
@@ -3459,6 +3516,7 @@ const MRT_Table = (_a) => {
|
|
|
3459
3516
|
};
|
|
3460
3517
|
|
|
3461
3518
|
const MRT_TableLoadingOverlay = (_a) => {
|
|
3519
|
+
var _b;
|
|
3462
3520
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
3463
3521
|
const { options: { localization, muiCircularProgressProps }, } = table;
|
|
3464
3522
|
const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
|
|
@@ -3474,8 +3532,8 @@ const MRT_TableLoadingOverlay = (_a) => {
|
|
|
3474
3532
|
right: 0,
|
|
3475
3533
|
top: 0,
|
|
3476
3534
|
width: '100%',
|
|
3477
|
-
zIndex:
|
|
3478
|
-
}), children: jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
|
|
3535
|
+
zIndex: 3,
|
|
3536
|
+
}), children: (_b = circularProgressProps === null || circularProgressProps === void 0 ? void 0 : circularProgressProps.Component) !== null && _b !== void 0 ? _b : (jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps))) }));
|
|
3479
3537
|
};
|
|
3480
3538
|
|
|
3481
3539
|
const MRT_CellActionMenu = (_a) => {
|
|
@@ -3739,7 +3797,7 @@ const MRT_ColumnPinningButtons = (_a) => {
|
|
|
3739
3797
|
|
|
3740
3798
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3741
3799
|
var _b;
|
|
3742
|
-
var { allColumns, column, hoveredColumn, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "setHoveredColumn", "table"]);
|
|
3800
|
+
var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
|
|
3743
3801
|
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, setColumnOrder, } = table;
|
|
3744
3802
|
const { columnOrder } = getState();
|
|
3745
3803
|
const { columnDef } = column;
|
|
@@ -3794,7 +3852,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
|
3794
3852
|
gap: '8px',
|
|
3795
3853
|
}, children: [columnDefType !== 'group' &&
|
|
3796
3854
|
enableColumnOrdering &&
|
|
3797
|
-
!
|
|
3855
|
+
!isNestedColumns &&
|
|
3798
3856
|
(columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { sx: { width: '28px' } }))), enableColumnPinning &&
|
|
3799
3857
|
(column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
|
|
3800
3858
|
typography: {
|
|
@@ -3803,7 +3861,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
|
3803
3861
|
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
|
3804
3862
|
},
|
|
3805
3863
|
},
|
|
3806
|
-
}, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
|
|
3864
|
+
}, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
|
|
3807
3865
|
};
|
|
3808
3866
|
|
|
3809
3867
|
const MRT_ShowHideColumnsMenu = (_a) => {
|
|
@@ -3834,6 +3892,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
|
3834
3892
|
getLeftLeafColumns(),
|
|
3835
3893
|
getRightLeafColumns(),
|
|
3836
3894
|
]);
|
|
3895
|
+
const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
|
|
3837
3896
|
const [hoveredColumn, setHoveredColumn] = useState(null);
|
|
3838
3897
|
const theme = useTheme();
|
|
3839
3898
|
const { menuBackgroundColor } = getMRTTheme(table, theme);
|
|
@@ -3847,7 +3906,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
|
3847
3906
|
justifyContent: 'space-between',
|
|
3848
3907
|
p: '0.5rem',
|
|
3849
3908
|
pt: 0,
|
|
3850
|
-
}, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
|
|
3909
|
+
}, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
|
|
3851
3910
|
};
|
|
3852
3911
|
|
|
3853
3912
|
const MRT_ShowHideColumnsButton = (_a) => {
|
|
@@ -4064,5 +4123,5 @@ const MaterialReactTable = (props) => {
|
|
|
4064
4123
|
return jsx(MRT_TablePaper, { table: table });
|
|
4065
4124
|
};
|
|
4066
4125
|
|
|
4067
|
-
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, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getIsRowSelected, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
4126
|
+
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, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getTotalRight, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
4068
4127
|
//# sourceMappingURL=index.esm.js.map
|