material-react-table 2.0.0-alpha.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +437 -384
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +3 -2
- package/dist/cjs/types/body/MRT_TableBodyRowPinButton.d.ts +7 -0
- package/dist/cjs/types/body/index.d.ts +1 -0
- package/dist/cjs/types/buttons/MRT_RowPinButton.d.ts +9 -0
- package/dist/cjs/types/buttons/index.d.ts +2 -1
- package/dist/cjs/types/column.utils.d.ts +1 -0
- package/dist/cjs/types/types.d.ts +15 -9
- package/dist/esm/material-react-table.esm.js +433 -383
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/body/MRT_TableBodyRow.d.ts +3 -2
- package/dist/esm/types/body/MRT_TableBodyRowPinButton.d.ts +7 -0
- package/dist/esm/types/body/index.d.ts +1 -0
- package/dist/esm/types/buttons/MRT_RowPinButton.d.ts +9 -0
- package/dist/esm/types/buttons/index.d.ts +2 -1
- package/dist/esm/types/column.utils.d.ts +1 -0
- package/dist/esm/types/types.d.ts +15 -9
- package/dist/index.d.ts +68 -47
- package/locales/en.esm.js +1 -0
- package/locales/en.esm.js.map +1 -1
- package/locales/en.js +1 -0
- package/locales/en.js.map +1 -1
- package/package.json +9 -9
- package/src/body/MRT_TableBody.tsx +178 -74
- package/src/body/MRT_TableBodyCell.tsx +23 -21
- package/src/body/MRT_TableBodyRow.tsx +104 -16
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -4
- package/src/body/MRT_TableBodyRowPinButton.tsx +46 -0
- package/src/body/MRT_TableDetailPanel.tsx +13 -19
- package/src/body/index.ts +2 -1
- package/src/buttons/MRT_CopyButton.tsx +14 -20
- package/src/buttons/MRT_ExpandAllButton.tsx +5 -7
- package/src/buttons/MRT_ExpandButton.tsx +6 -7
- package/src/buttons/MRT_GrabHandleButton.tsx +2 -3
- package/src/buttons/MRT_RowPinButton.tsx +74 -0
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +2 -3
- package/src/buttons/index.ts +2 -1
- package/src/column.utils.ts +11 -5
- package/src/footer/MRT_TableFooter.tsx +13 -7
- package/src/footer/MRT_TableFooterCell.tsx +7 -20
- package/src/footer/MRT_TableFooterRow.tsx +6 -7
- package/src/head/MRT_TableHead.tsx +11 -7
- package/src/head/MRT_TableHeadCell.tsx +9 -20
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +10 -18
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +6 -13
- package/src/head/MRT_TableHeadRow.tsx +6 -7
- package/src/hooks/useMRT_DisplayColumns.tsx +13 -0
- package/src/hooks/useMRT_TableInstance.ts +6 -0
- package/src/hooks/useMRT_TableOptions.ts +6 -2
- package/src/inputs/MRT_EditCellTextField.tsx +14 -22
- package/src/inputs/MRT_FilterCheckbox.tsx +11 -23
- package/src/inputs/MRT_FilterRangeSlider.tsx +6 -23
- package/src/inputs/MRT_FilterTextField.tsx +9 -25
- package/src/inputs/MRT_GlobalFilterTextField.tsx +4 -4
- package/src/inputs/MRT_SelectCheckbox.tsx +31 -17
- package/src/locales/en.ts +1 -1
- package/src/menus/MRT_RowActionMenu.tsx +11 -12
- package/src/modals/MRT_EditRowModal.tsx +5 -13
- package/src/table/MRT_Table.tsx +8 -13
- package/src/table/MRT_TableContainer.tsx +6 -12
- package/src/table/MRT_TablePaper.tsx +9 -13
- package/src/toolbar/MRT_BottomToolbar.tsx +14 -20
- package/src/toolbar/MRT_LinearProgressBar.tsx +5 -4
- package/src/toolbar/MRT_TablePagination.tsx +5 -7
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +8 -11
- package/src/toolbar/MRT_TopToolbar.tsx +8 -14
- package/src/types.ts +25 -8
- package/locales/tr.d.ts +0 -2
- package/locales/tr.esm.d.ts +0 -2
- package/locales/tr.esm.js +0 -93
- package/locales/tr.esm.js.map +0 -1
- package/locales/tr.js +0 -97
- package/locales/tr.js.map +0 -1
- package/locales/uk.d.ts +0 -2
- package/locales/uk.esm.d.ts +0 -2
- package/locales/uk.esm.js +0 -93
- package/locales/uk.esm.js.map +0 -1
- package/locales/uk.js +0 -97
- package/locales/uk.js.map +0 -1
- package/locales/vi.d.ts +0 -2
- package/locales/vi.esm.d.ts +0 -2
- package/locales/vi.esm.js +0 -93
- package/locales/vi.esm.js.map +0 -1
- package/locales/vi.js +0 -97
- package/locales/vi.js.map +0 -1
- package/locales/zh-Hans.d.ts +0 -2
- package/locales/zh-Hans.esm.d.ts +0 -2
- package/locales/zh-Hans.esm.js +0 -93
- package/locales/zh-Hans.esm.js.map +0 -1
- package/locales/zh-Hans.js +0 -97
- package/locales/zh-Hans.js.map +0 -1
- package/locales/zh-Hant.d.ts +0 -2
- package/locales/zh-Hant.esm.d.ts +0 -2
- package/locales/zh-Hant.esm.js +0 -93
- package/locales/zh-Hant.esm.js.map +0 -1
- package/locales/zh-Hant.js +0 -97
- package/locales/zh-Hant.js.map +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { jsx,
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
2
2
|
import { useMemo, useState, memo, useEffect, useRef, useCallback, Fragment as Fragment$1, useLayoutEffect } from 'react';
|
3
3
|
import { aggregationFns, filterFns, sortingFns, flexRender as flexRender$1, createRow as createRow$1, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
@@ -31,6 +31,9 @@ import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
31
31
|
import SortIcon from '@mui/icons-material/Sort';
|
32
32
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
33
33
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
34
|
+
import Box from '@mui/material/Box';
|
35
|
+
import IconButton from '@mui/material/IconButton';
|
36
|
+
import Tooltip from '@mui/material/Tooltip';
|
34
37
|
import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
|
35
38
|
import TableBody from '@mui/material/TableBody';
|
36
39
|
import Typography from '@mui/material/Typography';
|
@@ -40,9 +43,6 @@ import TableCell from '@mui/material/TableCell';
|
|
40
43
|
import TextField from '@mui/material/TextField';
|
41
44
|
import MenuItem from '@mui/material/MenuItem';
|
42
45
|
import Button from '@mui/material/Button';
|
43
|
-
import Tooltip from '@mui/material/Tooltip';
|
44
|
-
import IconButton from '@mui/material/IconButton';
|
45
|
-
import Box from '@mui/material/Box';
|
46
46
|
import highlightWords from 'highlight-words';
|
47
47
|
import Collapse from '@mui/material/Collapse';
|
48
48
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
@@ -281,13 +281,16 @@ const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
281
281
|
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
282
282
|
props.renderDetailPanel);
|
283
283
|
const getLeadingDisplayColumnIds = (props) => {
|
284
|
-
var _a;
|
284
|
+
var _a, _b;
|
285
285
|
return [
|
286
|
+
props.enableRowPinning &&
|
287
|
+
!((_a = props.rowPinningDisplayMode) === null || _a === void 0 ? void 0 : _a.startsWith('select')) &&
|
288
|
+
'mrt-row-pin',
|
286
289
|
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
287
290
|
props.positionActionsColumn === 'first' &&
|
288
291
|
(props.enableRowActions ||
|
289
292
|
(props.enableEditing &&
|
290
|
-
['row', 'modal'].includes((
|
293
|
+
['row', 'modal'].includes((_b = props.editDisplayMode) !== null && _b !== void 0 ? _b : ''))) &&
|
291
294
|
'mrt-row-actions',
|
292
295
|
props.positionExpandColumn === 'first' &&
|
293
296
|
showExpandColumn(props) &&
|
@@ -398,9 +401,7 @@ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, })
|
|
398
401
|
? `${getTotalRight(table, column)}px`
|
399
402
|
: undefined, transition: table.options.enableColumnVirtualization
|
400
403
|
? 'none'
|
401
|
-
: `padding 150ms ease-in-out` }, (!table.options.enableColumnResizing && widthStyles)), (
|
402
|
-
? tableCellProps.sx(theme)
|
403
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), (table.options.enableColumnResizing && widthStyles));
|
404
|
+
: `padding 150ms ease-in-out` }, (!table.options.enableColumnResizing && widthStyles)), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme)), (table.options.enableColumnResizing && widthStyles));
|
404
405
|
};
|
405
406
|
const MRT_DefaultColumn = {
|
406
407
|
filterVariant: 'text',
|
@@ -422,6 +423,7 @@ const MRT_DefaultDisplayColumn = {
|
|
422
423
|
enableResizing: false,
|
423
424
|
enableSorting: false,
|
424
425
|
};
|
426
|
+
const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
|
425
427
|
const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
426
428
|
const flexRender = flexRender$1;
|
427
429
|
const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
|
@@ -487,6 +489,7 @@ const MRT_Localization_EN = {
|
|
487
489
|
noResultsFound: 'No results found',
|
488
490
|
of: 'of',
|
489
491
|
or: 'or',
|
492
|
+
pin: 'Pin',
|
490
493
|
pinToLeft: 'Pin to left',
|
491
494
|
pinToRight: 'Pin to right',
|
492
495
|
resetColumnSize: 'Reset column size',
|
@@ -552,7 +555,7 @@ const MRT_Default_Icons = {
|
|
552
555
|
|
553
556
|
const useMRT_TableOptions = (_a) => {
|
554
557
|
var _b;
|
555
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true,
|
558
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode = 'semantic', localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
556
559
|
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
557
560
|
const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
558
561
|
const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
@@ -583,6 +586,7 @@ const useMRT_TableOptions = (_a) => {
|
|
583
586
|
enableColumnActions,
|
584
587
|
enableColumnFilters,
|
585
588
|
enableColumnOrdering,
|
589
|
+
enableColumnPinning,
|
586
590
|
enableColumnResizing,
|
587
591
|
enableDensityToggle,
|
588
592
|
enableExpandAll,
|
@@ -597,7 +601,7 @@ const useMRT_TableOptions = (_a) => {
|
|
597
601
|
enableMultiRowSelection,
|
598
602
|
enableMultiSort,
|
599
603
|
enablePagination,
|
600
|
-
|
604
|
+
enableRowPinning,
|
601
605
|
enableRowSelection,
|
602
606
|
enableSelectAll,
|
603
607
|
enableSorting,
|
@@ -617,9 +621,46 @@ const useMRT_TableOptions = (_a) => {
|
|
617
621
|
positionToolbarAlertBanner,
|
618
622
|
positionToolbarDropZone,
|
619
623
|
rowNumberMode,
|
624
|
+
rowPinningDisplayMode,
|
620
625
|
selectAllMode, sortingFns: _sortingFns }, rest);
|
621
626
|
};
|
622
627
|
|
628
|
+
const MRT_RowPinButton = ({ row, table, pinningPosition, }) => {
|
629
|
+
const { options: { icons: { PushPinIcon, CloseIcon }, localization, rowPinningDisplayMode, }, } = table;
|
630
|
+
const isPinned = row.getIsPinned();
|
631
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
632
|
+
const handleTogglePin = (event) => {
|
633
|
+
setTooltipOpened(false);
|
634
|
+
event.stopPropagation();
|
635
|
+
row.pin(isPinned ? false : pinningPosition);
|
636
|
+
};
|
637
|
+
return (jsx(Tooltip, { arrow: true, open: tooltipOpened, enterDelay: 1000, enterNextDelay: 1000, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, { "aria-label": localization.pin, onClick: handleTogglePin, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small", sx: {
|
638
|
+
height: '24px',
|
639
|
+
width: '24px',
|
640
|
+
}, children: isPinned ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
|
641
|
+
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
642
|
+
? 135
|
643
|
+
: pinningPosition === 'top'
|
644
|
+
? 180
|
645
|
+
: 0}deg)`,
|
646
|
+
} })) }) }));
|
647
|
+
};
|
648
|
+
|
649
|
+
const MRT_TableBodyRowPinButton = ({ row, table, }) => {
|
650
|
+
const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
|
651
|
+
const { density } = getState();
|
652
|
+
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
653
|
+
if (!canPin)
|
654
|
+
return null;
|
655
|
+
if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
|
656
|
+
return (jsxs(Box, { sx: {
|
657
|
+
display: 'flex',
|
658
|
+
flexDirection: density === 'compact' ? 'row' : 'column',
|
659
|
+
}, children: [jsx(MRT_RowPinButton, { row: row, table: table, pinningPosition: "top" }), jsx(MRT_RowPinButton, { row: row, table: table, pinningPosition: "bottom" })] }));
|
660
|
+
}
|
661
|
+
return (jsx(MRT_RowPinButton, { row: row, table: table, pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }));
|
662
|
+
};
|
663
|
+
|
623
664
|
const MRT_EditCellTextField = ({ cell, table, }) => {
|
624
665
|
var _a, _b, _c;
|
625
666
|
const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, setCreatingRow, } = table;
|
@@ -630,18 +671,17 @@ const MRT_EditCellTextField = ({ cell, table, }) => {
|
|
630
671
|
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
631
672
|
const isSelectEdit = columnDef.editVariant === 'select';
|
632
673
|
const [value, setValue] = useState(() => cell.getValue());
|
633
|
-
const
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
|
674
|
+
const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
|
675
|
+
cell,
|
676
|
+
column,
|
677
|
+
row,
|
678
|
+
table,
|
679
|
+
})), parseFromValuesOrFunc(columnDef.muiEditTextFieldProps, {
|
680
|
+
cell,
|
681
|
+
column,
|
682
|
+
row,
|
683
|
+
table,
|
684
|
+
}));
|
645
685
|
const saveInputValueToRowCache = (newValue) => {
|
646
686
|
//@ts-ignore
|
647
687
|
row._valuesCache[column.id] = newValue;
|
@@ -676,9 +716,7 @@ const MRT_EditCellTextField = ({ cell, table, }) => {
|
|
676
716
|
if (columnDef.Edit) {
|
677
717
|
return jsx(Fragment, { children: (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }) });
|
678
718
|
}
|
679
|
-
return (jsx(TextField, Object.assign({ disabled: (columnDef.enableEditing
|
680
|
-
? columnDef.enableEditing(row)
|
681
|
-
: columnDef.enableEditing) === false, fullWidth: true, inputRef: (inputRef) => {
|
719
|
+
return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
|
682
720
|
if (inputRef) {
|
683
721
|
editInputRefs.current[column.id] = inputRef;
|
684
722
|
if (textFieldProps.inputRef) {
|
@@ -725,21 +763,18 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
725
763
|
setCopied(true);
|
726
764
|
setTimeout(() => setCopied(false), 4000);
|
727
765
|
};
|
728
|
-
const
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
|
741
|
-
? buttonProps.sx(theme)
|
742
|
-
: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))), title: undefined, children: children })) }));
|
766
|
+
const buttonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
|
767
|
+
cell,
|
768
|
+
column,
|
769
|
+
row,
|
770
|
+
table,
|
771
|
+
})), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
|
772
|
+
cell,
|
773
|
+
column,
|
774
|
+
row,
|
775
|
+
table,
|
776
|
+
}));
|
777
|
+
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined, children: children })) }));
|
743
778
|
};
|
744
779
|
|
745
780
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
@@ -754,16 +789,15 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
754
789
|
opacity: 1,
|
755
790
|
}, '&:active': {
|
756
791
|
cursor: 'grabbing',
|
757
|
-
} }, (
|
758
|
-
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
759
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
|
792
|
+
} }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
|
760
793
|
};
|
761
794
|
|
762
795
|
const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, }) => {
|
763
796
|
const { options: { muiRowDragHandleProps }, } = table;
|
764
|
-
const iconButtonProps = muiRowDragHandleProps
|
765
|
-
|
766
|
-
|
797
|
+
const iconButtonProps = parseFromValuesOrFunc(muiRowDragHandleProps, {
|
798
|
+
row,
|
799
|
+
table,
|
800
|
+
});
|
767
801
|
const handleDragStart = (event) => {
|
768
802
|
var _a;
|
769
803
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
@@ -856,16 +890,23 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
856
890
|
const { column, row } = cell;
|
857
891
|
const { columnDef } = column;
|
858
892
|
const { columnDefType } = columnDef;
|
859
|
-
const
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
893
|
+
const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, {
|
894
|
+
cell,
|
895
|
+
column,
|
896
|
+
row,
|
897
|
+
table,
|
898
|
+
})), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, {
|
899
|
+
cell,
|
900
|
+
column,
|
901
|
+
row,
|
902
|
+
table,
|
903
|
+
}));
|
904
|
+
const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
|
905
|
+
cell,
|
906
|
+
column,
|
907
|
+
row,
|
908
|
+
table,
|
909
|
+
});
|
869
910
|
const [skeletonWidth, setSkeletonWidth] = useState(100);
|
870
911
|
useEffect(() => {
|
871
912
|
if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
|
@@ -907,10 +948,8 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
907
948
|
}
|
908
949
|
: undefined;
|
909
950
|
}, [draggingColumn, draggingRow, hoveredColumn, hoveredRow, rowIndex]);
|
910
|
-
const isEditable = (enableEditing
|
911
|
-
(columnDef.enableEditing
|
912
|
-
? columnDef.enableEditing(row)
|
913
|
-
: columnDef.enableEditing) !== false;
|
951
|
+
const isEditable = parseFromValuesOrFunc(enableEditing, row) &&
|
952
|
+
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
|
914
953
|
const isEditing = isEditable &&
|
915
954
|
!['modal', 'custom'].includes(editDisplayMode) &&
|
916
955
|
(editDisplayMode === 'table' ||
|
@@ -964,7 +1003,7 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
964
1003
|
: density === 'comfortable'
|
965
1004
|
? 0.75
|
966
1005
|
: 1.25)}rem`
|
967
|
-
: undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
|
1006
|
+
: undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
|
968
1007
|
outline: ['table', 'cell'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')
|
969
1008
|
? `1px solid ${theme.palette.text.secondary}`
|
970
1009
|
: undefined,
|
@@ -994,39 +1033,59 @@ const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell
|
|
994
1033
|
const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow, }) => {
|
995
1034
|
const { getVisibleLeafColumns, getState, options: { layoutMode, muiTableBodyRowProps, muiDetailPanelProps, renderDetailPanel, }, } = table;
|
996
1035
|
const { isLoading } = getState();
|
997
|
-
const tableRowProps = muiTableBodyRowProps
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
: muiDetailPanelProps;
|
1036
|
+
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
1037
|
+
isDetailPanel: true,
|
1038
|
+
row,
|
1039
|
+
staticRowIndex: rowIndex,
|
1040
|
+
table,
|
1041
|
+
});
|
1042
|
+
const tableCellProps = parseFromValuesOrFunc(muiDetailPanelProps, {
|
1043
|
+
row,
|
1044
|
+
table,
|
1045
|
+
});
|
1008
1046
|
return (jsx(TableRow, Object.assign({ className: "Mui-TableBodyCell-DetailPanel" }, tableRowProps, { sx: (theme) => {
|
1009
1047
|
var _a, _b;
|
1010
1048
|
return (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row', position: virtualRow ? 'absolute' : undefined, top: virtualRow
|
1011
1049
|
? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
|
1012
1050
|
: undefined, transform: virtualRow
|
1013
1051
|
? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
|
1014
|
-
: undefined, width: '100%', zIndex: virtualRow ? 2 : undefined }, (
|
1015
|
-
? tableRowProps.sx(theme)
|
1016
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)));
|
1052
|
+
: undefined, width: '100%', zIndex: virtualRow ? 2 : undefined }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
|
1017
1053
|
}, children: jsx(TableCell, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
|
1018
1054
|
? lighten(theme.palette.background.default, 0.06)
|
1019
|
-
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: layoutMode === 'grid' ? 'flex' : 'table-cell', pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, (
|
1020
|
-
? tableCellProps.sx(theme)
|
1021
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))), children: renderDetailPanel && (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
|
1055
|
+
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: layoutMode === 'grid' ? 'flex' : 'table-cell', pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
|
1022
1056
|
};
|
1023
1057
|
|
1024
|
-
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
|
1025
|
-
|
1026
|
-
const
|
1027
|
-
const
|
1028
|
-
|
1029
|
-
|
1058
|
+
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
|
1059
|
+
var _a, _b, _c, _d;
|
1060
|
+
const theme = useTheme();
|
1061
|
+
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, rowPinningDisplayMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, refs: { tableHeadRef, tableFooterRef }, setHoveredRow, } = table;
|
1062
|
+
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
1063
|
+
const isPinned = enableRowPinning && row.getIsPinned();
|
1064
|
+
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
1065
|
+
row,
|
1066
|
+
staticRowIndex: rowIndex,
|
1067
|
+
table,
|
1068
|
+
});
|
1069
|
+
const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
|
1070
|
+
if (!enableRowPinning ||
|
1071
|
+
!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
|
1072
|
+
!pinnedRowIds ||
|
1073
|
+
!row.getIsPinned())
|
1074
|
+
return [];
|
1075
|
+
return [
|
1076
|
+
[...pinnedRowIds].reverse().indexOf(row.id),
|
1077
|
+
pinnedRowIds.indexOf(row.id),
|
1078
|
+
];
|
1079
|
+
}, [pinnedRowIds, rowPinning]);
|
1080
|
+
const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
|
1081
|
+
((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
|
1082
|
+
0;
|
1083
|
+
const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
|
1084
|
+
const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
|
1085
|
+
const rowHeight =
|
1086
|
+
// @ts-ignore
|
1087
|
+
parseInt((_d = (_c = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : sx === null || sx === void 0 ? void 0 : sx.height, 10) ||
|
1088
|
+
(density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69);
|
1030
1089
|
const handleDragEnter = (_e) => {
|
1031
1090
|
if (enableRowOrdering && draggingRow) {
|
1032
1091
|
setHoveredRow(row);
|
@@ -1038,7 +1097,31 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
1038
1097
|
rowRef.current = node;
|
1039
1098
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
1040
1099
|
}
|
1041
|
-
} }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06)
|
1100
|
+
} }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: `${lighten(theme.palette.background.default, 0.06)} !important`, boxSizing: 'border-box', bottom: bottomPinnedIndex !== undefined && isPinned
|
1101
|
+
? `${bottomPinnedIndex * rowHeight +
|
1102
|
+
(enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
|
1103
|
+
: undefined, display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: isPinned
|
1104
|
+
? 0.98
|
1105
|
+
: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
|
1106
|
+
? 0.5
|
1107
|
+
: 1, position: virtualRow
|
1108
|
+
? 'absolute'
|
1109
|
+
: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
1110
|
+
? 'sticky'
|
1111
|
+
: undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', top: virtualRow
|
1112
|
+
? 0
|
1113
|
+
: topPinnedIndex !== undefined && isPinned
|
1114
|
+
? `${topPinnedIndex * rowHeight +
|
1115
|
+
(enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
|
1116
|
+
: undefined, width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
1117
|
+
? 1
|
1118
|
+
: undefined, td: {
|
1119
|
+
backgroundColor: row.getIsSelected()
|
1120
|
+
? alpha(theme.palette.primary.main, 0.2)
|
1121
|
+
: isPinned
|
1122
|
+
? alpha(theme.palette.primary.main, 0.1)
|
1123
|
+
: undefined,
|
1124
|
+
}, '&:hover td': {
|
1042
1125
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
|
1043
1126
|
? row.getIsSelected()
|
1044
1127
|
? `${alpha(theme.palette.primary.main, 0.2)}`
|
@@ -1046,9 +1129,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
1046
1129
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
1047
1130
|
: `${darken(theme.palette.background.default, 0.05)}`
|
1048
1131
|
: undefined,
|
1049
|
-
} },
|
1050
|
-
? tableRowProps.sx(theme)
|
1051
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), style: Object.assign({ transform: virtualRow
|
1132
|
+
} }, sx)), style: Object.assign({ transform: virtualRow
|
1052
1133
|
? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
|
1053
1134
|
: undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
|
1054
1135
|
const cell = columnVirtualizer
|
@@ -1076,15 +1157,17 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
1076
1157
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
|
1077
1158
|
|
1078
1159
|
const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
1079
|
-
var _a, _b, _c, _d;
|
1080
|
-
const {
|
1081
|
-
const { columnFilters, density, expanded, globalFilter, globalFilterFn, pagination, sorting, } = getState();
|
1082
|
-
const tableBodyProps = muiTableBodyProps
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
:
|
1160
|
+
var _a, _b, _c, _d, _e, _f;
|
1161
|
+
const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getIsSomeRowsPinned, getTopRows, options: { enableGlobalFilterRankedResults, enablePagination, enableRowPinning, enableRowVirtualization, enableStickyHeader, enableStickyFooter, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef, tablePaperRef, tableFooterRef, tableHeadRef }, } = table;
|
1162
|
+
const { columnFilters, density, expanded, globalFilter, globalFilterFn, pagination, sorting, rowPinning, isFullScreen, } = getState();
|
1163
|
+
const tableBodyProps = parseFromValuesOrFunc(muiTableBodyProps, { table });
|
1164
|
+
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
1165
|
+
table,
|
1166
|
+
});
|
1167
|
+
const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
|
1168
|
+
((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
|
1169
|
+
0;
|
1170
|
+
const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
|
1088
1171
|
const shouldRankResults = useMemo(() => !manualExpanding &&
|
1089
1172
|
!manualFiltering &&
|
1090
1173
|
!manualGrouping &&
|
@@ -1104,26 +1187,44 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
1104
1187
|
manualSorting,
|
1105
1188
|
sorting,
|
1106
1189
|
]);
|
1190
|
+
const pinnedRowIds = useMemo(() => getRowModel()
|
1191
|
+
.rows.filter((row) => row.getIsPinned())
|
1192
|
+
.map((r) => r.id), [rowPinning, table.getRowModel().rows]);
|
1107
1193
|
const rows = useMemo(() => {
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1194
|
+
let rows = [];
|
1195
|
+
if (!shouldRankResults) {
|
1196
|
+
rows =
|
1197
|
+
!enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
|
1198
|
+
? getRowModel().rows
|
1199
|
+
: getCenterRows();
|
1200
|
+
}
|
1201
|
+
else {
|
1202
|
+
rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
|
1203
|
+
if (enablePagination && !manualPagination) {
|
1204
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
1205
|
+
rows = rows.slice(start, start + pagination.pageSize);
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
|
1209
|
+
rows = [
|
1210
|
+
...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
1211
|
+
...rows,
|
1212
|
+
...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
1213
|
+
];
|
1114
1214
|
}
|
1115
|
-
return
|
1215
|
+
return rows;
|
1116
1216
|
}, [
|
1117
1217
|
shouldRankResults,
|
1118
1218
|
shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
|
1119
1219
|
pagination.pageIndex,
|
1120
1220
|
pagination.pageSize,
|
1221
|
+
rowPinning,
|
1121
1222
|
]);
|
1122
1223
|
const rowVirtualizer = enableRowVirtualization
|
1123
1224
|
? useVirtualizer(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
|
1124
1225
|
navigator.userAgent.indexOf('Firefox') === -1
|
1125
1226
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
1126
|
-
: undefined, overscan: 4 },
|
1227
|
+
: undefined, overscan: 4 }, rowVirtualizerProps))
|
1127
1228
|
: undefined;
|
1128
1229
|
if (rowVirtualizerInstanceRef && rowVirtualizer) {
|
1129
1230
|
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
@@ -1131,41 +1232,68 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
1131
1232
|
const virtualRows = rowVirtualizer
|
1132
1233
|
? rowVirtualizer.getVirtualItems()
|
1133
1234
|
: undefined;
|
1134
|
-
return (
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
},
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1235
|
+
return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
1236
|
+
getIsSomeRowsPinned('top') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, rowIndex) => {
|
1237
|
+
const props = {
|
1238
|
+
columnVirtualizer,
|
1239
|
+
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
1240
|
+
numRows: rows.length,
|
1241
|
+
row,
|
1242
|
+
rowIndex,
|
1243
|
+
table,
|
1244
|
+
virtualColumns,
|
1245
|
+
virtualPaddingLeft,
|
1246
|
+
virtualPaddingRight,
|
1247
|
+
};
|
1248
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1249
|
+
}) }))), jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', height: rowVirtualizer
|
1250
|
+
? `${rowVirtualizer.getTotalSize()}px`
|
1251
|
+
: 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_c = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _c !== void 0 ? _c : (!rows.length ? (jsx("tr", { style: { display: layoutMode === 'grid' ? 'grid' : 'table-row' }, children: jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
|
1252
|
+
display: layoutMode === 'grid' ? 'grid' : 'table-cell',
|
1253
|
+
}, children: (_d = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _d !== void 0 ? _d : (jsx(Typography, { sx: {
|
1254
|
+
color: 'text.secondary',
|
1255
|
+
fontStyle: 'italic',
|
1256
|
+
maxWidth: `min(100vw, ${(_f = (_e = tablePaperRef.current) === null || _e === void 0 ? void 0 : _e.clientWidth) !== null && _f !== void 0 ? _f : 360}px)`,
|
1257
|
+
py: '2rem',
|
1258
|
+
textAlign: 'center',
|
1259
|
+
width: '100%',
|
1260
|
+
}, children: globalFilter || columnFilters.length
|
1261
|
+
? localization.noResultsFound
|
1262
|
+
: localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
1263
|
+
const row = rowVirtualizer
|
1264
|
+
? rows[rowOrVirtualRow.index]
|
1265
|
+
: rowOrVirtualRow;
|
1266
|
+
const props = {
|
1267
|
+
columnVirtualizer,
|
1268
|
+
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
1269
|
+
numRows: rows.length,
|
1270
|
+
pinnedRowIds,
|
1271
|
+
row,
|
1272
|
+
rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
|
1273
|
+
table,
|
1274
|
+
virtualColumns,
|
1275
|
+
virtualPaddingLeft,
|
1276
|
+
virtualPaddingRight,
|
1277
|
+
virtualRow: rowVirtualizer
|
1278
|
+
? rowOrVirtualRow
|
1279
|
+
: undefined,
|
1280
|
+
};
|
1281
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1282
|
+
}) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
1283
|
+
getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', position: 'sticky', bottom: tableFooterHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
|
1284
|
+
const props = {
|
1285
|
+
columnVirtualizer,
|
1286
|
+
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
1287
|
+
numRows: rows.length,
|
1288
|
+
row,
|
1289
|
+
rowIndex,
|
1290
|
+
table,
|
1291
|
+
virtualColumns,
|
1292
|
+
virtualPaddingLeft,
|
1293
|
+
virtualPaddingRight,
|
1294
|
+
};
|
1295
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1296
|
+
}) })))] }));
|
1169
1297
|
};
|
1170
1298
|
const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
1171
1299
|
|
@@ -1173,15 +1301,13 @@ const MRT_ExpandAllButton = ({ table, }) => {
|
|
1173
1301
|
var _a, _b;
|
1174
1302
|
const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
1175
1303
|
const { density, isLoading } = getState();
|
1176
|
-
const iconButtonProps = muiExpandAllButtonProps
|
1177
|
-
|
1178
|
-
|
1304
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
1305
|
+
table,
|
1306
|
+
});
|
1179
1307
|
const isAllRowsExpanded = getIsAllRowsExpanded();
|
1180
1308
|
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isAllRowsExpanded)
|
1181
1309
|
? localization.collapseAll
|
1182
|
-
: localization.expandAll, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, (
|
1183
|
-
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
1184
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(KeyboardDoubleArrowDownIcon, { style: {
|
1310
|
+
: localization.expandAll, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(KeyboardDoubleArrowDownIcon, { style: {
|
1185
1311
|
transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
|
1186
1312
|
transition: 'transform 150ms',
|
1187
1313
|
} })) })) }) }));
|
@@ -1191,9 +1317,10 @@ const MRT_ExpandButton = ({ row, table, }) => {
|
|
1191
1317
|
var _a, _b;
|
1192
1318
|
const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table;
|
1193
1319
|
const { density } = getState();
|
1194
|
-
const iconButtonProps = muiExpandButtonProps
|
1195
|
-
|
1196
|
-
|
1320
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
1321
|
+
row,
|
1322
|
+
table,
|
1323
|
+
});
|
1197
1324
|
const canExpand = row.getCanExpand();
|
1198
1325
|
const isExpanded = row.getIsExpanded();
|
1199
1326
|
const handleToggleExpand = (event) => {
|
@@ -1204,9 +1331,7 @@ const MRT_ExpandButton = ({ row, table, }) => {
|
|
1204
1331
|
};
|
1205
1332
|
return (jsx(Tooltip, { arrow: true, disableHoverListener: !canExpand && !renderDetailPanel, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isExpanded)
|
1206
1333
|
? localization.collapse
|
1207
|
-
: localization.expand, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, (
|
1208
|
-
? iconButtonProps.sx(theme)
|
1209
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(ExpandMoreIcon, { style: {
|
1334
|
+
: localization.expand, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(ExpandMoreIcon, { style: {
|
1210
1335
|
transform: `rotate(${!canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0}deg)`,
|
1211
1336
|
transition: 'transform 150ms',
|
1212
1337
|
} })) })) }) }));
|
@@ -1546,9 +1671,7 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
|
|
1546
1671
|
const { density } = getState();
|
1547
1672
|
return (jsxs(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), MenuListProps: {
|
1548
1673
|
dense: density === 'compact',
|
1549
|
-
}, children: [enableEditing
|
1550
|
-
? enableEditing(row)
|
1551
|
-
: enableEditing && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
1674
|
+
}, children: [parseFromValuesOrFunc(enableEditing, row) && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
1552
1675
|
row,
|
1553
1676
|
table,
|
1554
1677
|
closeMenu: () => setAnchorEl(null),
|
@@ -1630,22 +1753,16 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
1630
1753
|
setAnchorEl(null);
|
1631
1754
|
};
|
1632
1755
|
return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
1633
|
-
(enableEditing
|
1634
|
-
? enableEditing(row)
|
1635
|
-
: enableEditing) ? (jsx(Tooltip, { placement: "right", arrow: true, title: localization.edit, children: jsx(IconButton, { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode, children: jsx(EditIcon, {}) }) })) : renderRowActionMenuItems ? (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsx(IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles, children: jsx(MoreHorizIcon, {}) }) }), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
|
1756
|
+
parseFromValuesOrFunc(enableEditing, row) ? (jsx(Tooltip, { placement: "right", arrow: true, title: localization.edit, children: jsx(IconButton, { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode, children: jsx(EditIcon, {}) }) })) : renderRowActionMenuItems ? (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsx(IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles, children: jsx(MoreHorizIcon, {}) }) }), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
|
1636
1757
|
};
|
1637
1758
|
|
1638
1759
|
const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
|
1639
1760
|
var _a;
|
1640
|
-
const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
1761
|
+
const { getState, options: { localization, enableMultiRowSelection, rowPinningDisplayMode, enableRowPinning, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
1641
1762
|
const { density, isLoading } = getState();
|
1642
1763
|
const checkboxProps = !row
|
1643
|
-
? muiSelectAllCheckboxProps
|
1644
|
-
|
1645
|
-
: muiSelectAllCheckboxProps
|
1646
|
-
: muiSelectCheckboxProps instanceof Function
|
1647
|
-
? muiSelectCheckboxProps({ row, table })
|
1648
|
-
: muiSelectCheckboxProps;
|
1764
|
+
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
1765
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table });
|
1649
1766
|
const allRowsSelected = selectAll
|
1650
1767
|
? selectAllMode === 'page'
|
1651
1768
|
? table.getIsAllPageRowsSelected()
|
@@ -1655,17 +1772,30 @@ const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
|
|
1655
1772
|
'aria-label': selectAll
|
1656
1773
|
? localization.toggleSelectAll
|
1657
1774
|
: localization.toggleSelectRow,
|
1658
|
-
}, onChange:
|
1659
|
-
|
1660
|
-
|
1661
|
-
?
|
1662
|
-
:
|
1775
|
+
}, onChange: (event) => {
|
1776
|
+
event.stopPropagation();
|
1777
|
+
row
|
1778
|
+
? row.getToggleSelectedHandler()(event)
|
1779
|
+
: selectAllMode === 'all'
|
1780
|
+
? table.getToggleAllRowsSelectedHandler()(event)
|
1781
|
+
: table.getToggleAllPageRowsSelectedHandler()(event);
|
1782
|
+
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
1783
|
+
if (row) {
|
1784
|
+
row.pin(!row.getIsPinned() && event.target.checked
|
1785
|
+
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
1786
|
+
? 'bottom'
|
1787
|
+
: 'top'
|
1788
|
+
: false);
|
1789
|
+
}
|
1790
|
+
else {
|
1791
|
+
table.setRowPinning({ bottom: [], top: [] });
|
1792
|
+
}
|
1793
|
+
}
|
1794
|
+
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
1663
1795
|
var _a;
|
1664
1796
|
e.stopPropagation();
|
1665
1797
|
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
1666
|
-
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, (
|
1667
|
-
? checkboxProps.sx(theme)
|
1668
|
-
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined });
|
1798
|
+
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
|
1669
1799
|
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
1670
1800
|
? localization.toggleSelectAll
|
1671
1801
|
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: selectAll
|
@@ -1676,20 +1806,21 @@ const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
|
|
1676
1806
|
const useMRT_DisplayColumns = ({ creatingRow, columnOrder, grouping, tableOptions, }) => {
|
1677
1807
|
var _a, _b;
|
1678
1808
|
return useMemo(() => {
|
1679
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
1809
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
1680
1810
|
return [
|
1681
|
-
((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-
|
1682
|
-
((
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1811
|
+
((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-pin') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), header: tableOptions.localization.pin, size: 60 }, tableOptions.defaultDisplayColumn), (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-pin']), { id: 'mrt-row-pin' }),
|
1812
|
+
((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, tableOptions.defaultDisplayColumn), (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
1813
|
+
(((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-actions') ||
|
1814
|
+
(creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, tableOptions.defaultDisplayColumn), (_j = tableOptions.displayColumnDefOptions) === null || _j === void 0 ? void 0 : _j['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
1815
|
+
((_l = (_k = tableOptions.state) === null || _k === void 0 ? void 0 : _k.columnOrder) !== null && _l !== void 0 ? _l : columnOrder).includes('mrt-row-expand') &&
|
1816
|
+
showExpandColumn(tableOptions, (_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.grouping) !== null && _o !== void 0 ? _o : grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
|
1686
1817
|
? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
|
1687
|
-
: null, header: tableOptions.localization.expand, size: 60 }, tableOptions.defaultDisplayColumn), (
|
1688
|
-
((
|
1818
|
+
: null, header: tableOptions.localization.expand, size: 60 }, tableOptions.defaultDisplayColumn), (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
1819
|
+
((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
|
1689
1820
|
tableOptions.enableMultiRowSelection
|
1690
1821
|
? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
1691
|
-
: null, header: tableOptions.localization.select, size: 60 }, tableOptions.defaultDisplayColumn), (
|
1692
|
-
((
|
1822
|
+
: null, header: tableOptions.localization.select, size: 60 }, tableOptions.defaultDisplayColumn), (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-select']), { id: 'mrt-row-select' }),
|
1823
|
+
((_u = (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnOrder) !== null && _u !== void 0 ? _u : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, tableOptions.defaultDisplayColumn), (_v = tableOptions.displayColumnDefOptions) === null || _v === void 0 ? void 0 : _v['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
1693
1824
|
].filter(Boolean);
|
1694
1825
|
}, [
|
1695
1826
|
columnOrder,
|
@@ -1789,6 +1920,8 @@ const useMRT_TableInstance = (tableOptions) => {
|
|
1789
1920
|
const tableHeadCellRefs = useRef({});
|
1790
1921
|
const tablePaperRef = useRef(null);
|
1791
1922
|
const topToolbarRef = useRef(null);
|
1923
|
+
const tableHeadRef = useRef(null);
|
1924
|
+
const tableFooterRef = useRef(null);
|
1792
1925
|
const initialState = useMemo(() => {
|
1793
1926
|
var _a, _b, _c;
|
1794
1927
|
const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
|
@@ -1913,6 +2046,10 @@ const useMRT_TableInstance = (tableOptions) => {
|
|
1913
2046
|
tablePaperRef,
|
1914
2047
|
// @ts-ignore
|
1915
2048
|
topToolbarRef,
|
2049
|
+
// @ts-ignore
|
2050
|
+
tableFooterRef,
|
2051
|
+
// @ts-ignore
|
2052
|
+
tableHeadRef,
|
1916
2053
|
};
|
1917
2054
|
const setCreatingRow = (row) => {
|
1918
2055
|
if (row === true) {
|
@@ -1959,9 +2096,9 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
1959
2096
|
var _a;
|
1960
2097
|
const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
1961
2098
|
const { globalFilter, showGlobalFilter } = getState();
|
1962
|
-
const textFieldProps = muiSearchTextFieldProps
|
1963
|
-
|
1964
|
-
|
2099
|
+
const textFieldProps = parseFromValuesOrFunc(muiSearchTextFieldProps, {
|
2100
|
+
table,
|
2101
|
+
});
|
1965
2102
|
const isMounted = useRef(false);
|
1966
2103
|
const [anchorEl, setAnchorEl] = useState(null);
|
1967
2104
|
const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
@@ -2005,9 +2142,10 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
2005
2142
|
const MRT_LinearProgressBar = ({ isTopToolbar, table, }) => {
|
2006
2143
|
const { options: { muiLinearProgressProps }, getState, } = table;
|
2007
2144
|
const { isLoading, showProgressBars } = getState();
|
2008
|
-
const linearProgressProps = muiLinearProgressProps
|
2009
|
-
|
2010
|
-
|
2145
|
+
const linearProgressProps = parseFromValuesOrFunc(muiLinearProgressProps, {
|
2146
|
+
isTopToolbar,
|
2147
|
+
table,
|
2148
|
+
});
|
2011
2149
|
return (jsx(Collapse, { in: isLoading || showProgressBars, mountOnEnter: true, unmountOnExit: true, sx: {
|
2012
2150
|
bottom: isTopToolbar ? 0 : undefined,
|
2013
2151
|
position: 'absolute',
|
@@ -2021,9 +2159,9 @@ const MRT_TablePagination = ({ table, position = 'bottom', }) => {
|
|
2021
2159
|
const { pagination: { pageSize = 10, pageIndex = 0 }, showGlobalFilter, } = getState();
|
2022
2160
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
2023
2161
|
const showFirstLastPageButtons = totalRowCount / pageSize > 2;
|
2024
|
-
const tablePaginationProps = muiTablePaginationProps
|
2025
|
-
|
2026
|
-
|
2162
|
+
const tablePaginationProps = parseFromValuesOrFunc(muiTablePaginationProps, {
|
2163
|
+
table,
|
2164
|
+
});
|
2027
2165
|
const handleChangeRowsPerPage = (event) => {
|
2028
2166
|
setPageSize(+event.target.value);
|
2029
2167
|
};
|
@@ -2050,21 +2188,19 @@ const MRT_TablePagination = ({ table, position = 'bottom', }) => {
|
|
2050
2188
|
enableToolbarInternalActions &&
|
2051
2189
|
!showGlobalFilter
|
2052
2190
|
? '3.5rem'
|
2053
|
-
: undefined, position: 'relative', zIndex: 2 }, (
|
2054
|
-
? tablePaginationProps.sx(theme)
|
2055
|
-
: tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx))) })));
|
2191
|
+
: undefined, position: 'relative', zIndex: 2 }, parseFromValuesOrFunc(tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx, theme))) })));
|
2056
2192
|
};
|
2057
2193
|
|
2058
2194
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
2059
2195
|
var _a, _b;
|
2060
2196
|
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, rowCount, }, } = table;
|
2061
2197
|
const { grouping, showAlertBanner } = getState();
|
2062
|
-
const alertProps = muiToolbarAlertBannerProps
|
2063
|
-
|
2064
|
-
|
2065
|
-
const chipProps = muiToolbarAlertBannerChipProps
|
2066
|
-
|
2067
|
-
|
2198
|
+
const alertProps = parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
2199
|
+
table,
|
2200
|
+
});
|
2201
|
+
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
2202
|
+
table,
|
2203
|
+
});
|
2068
2204
|
const selectMessage = getSelectedRowModel().rows.length > 0
|
2069
2205
|
? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
|
2070
2206
|
: null;
|
@@ -2073,9 +2209,7 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
2073
2209
|
? 0
|
2074
2210
|
: positionToolbarAlertBanner === 'bottom'
|
2075
2211
|
? '-1rem'
|
2076
|
-
: undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx)
|
2077
|
-
? alertProps.sx(theme)
|
2078
|
-
: alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))), children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsx(AlertTitle, { children: alertProps.title }), jsxs(Box, { sx: { p: '0.5rem 1rem' }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectMessage || groupedByMessage) && (jsx("br", {})), selectMessage, selectMessage && groupedByMessage && jsx("br", {}), groupedByMessage] })] })) }));
|
2212
|
+
: undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme))), children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsx(AlertTitle, { children: alertProps.title }), jsxs(Box, { sx: { p: '0.5rem 1rem' }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectMessage || groupedByMessage) && (jsx("br", {})), selectMessage, selectMessage && groupedByMessage && jsx("br", {}), groupedByMessage] })] })) }));
|
2079
2213
|
};
|
2080
2214
|
|
2081
2215
|
const MRT_ToggleFullScreenButton = (_a) => {
|
@@ -2322,9 +2456,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
2322
2456
|
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
2323
2457
|
const { isFullScreen, showGlobalFilter } = getState();
|
2324
2458
|
const isMobile = useMediaQuery('(max-width:720px)');
|
2325
|
-
const toolbarProps = muiTopToolbarProps
|
2326
|
-
? muiTopToolbarProps({ table })
|
2327
|
-
: muiTopToolbarProps;
|
2459
|
+
const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
|
2328
2460
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
2329
2461
|
return (jsxs(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
2330
2462
|
topToolbarRef.current = ref;
|
@@ -2332,9 +2464,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
2332
2464
|
// @ts-ignore
|
2333
2465
|
toolbarProps.ref.current = ref;
|
2334
2466
|
}
|
2335
|
-
}, sx: (theme) => (Object.assign(Object.assign({ position: isFullScreen ? 'sticky' : undefined, top: isFullScreen ? '0' : undefined }, commonToolbarStyles({ theme })), (
|
2336
|
-
? toolbarProps.sx(theme)
|
2337
|
-
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))), children: [positionToolbarAlertBanner === 'top' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
|
2467
|
+
}, sx: (theme) => (Object.assign(Object.assign({ position: isFullScreen ? 'sticky' : undefined, top: isFullScreen ? '0' : undefined }, commonToolbarStyles({ theme })), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [positionToolbarAlertBanner === 'top' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
|
2338
2468
|
alignItems: 'flex-start',
|
2339
2469
|
boxSizing: 'border-box',
|
2340
2470
|
display: 'flex',
|
@@ -2357,9 +2487,7 @@ const MRT_BottomToolbar = ({ table, }) => {
|
|
2357
2487
|
const { getState, options: { enablePagination, muiBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
2358
2488
|
const { isFullScreen } = getState();
|
2359
2489
|
const isMobile = useMediaQuery('(max-width:720px)');
|
2360
|
-
const toolbarProps = muiBottomToolbarProps
|
2361
|
-
? muiBottomToolbarProps({ table })
|
2362
|
-
: muiBottomToolbarProps;
|
2490
|
+
const toolbarProps = parseFromValuesOrFunc(muiBottomToolbarProps, { table });
|
2363
2491
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
2364
2492
|
return (jsxs(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (node) => {
|
2365
2493
|
if (node) {
|
@@ -2369,9 +2497,7 @@ const MRT_BottomToolbar = ({ table, }) => {
|
|
2369
2497
|
toolbarProps.ref.current = node;
|
2370
2498
|
}
|
2371
2499
|
}
|
2372
|
-
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha(theme.palette.common.black, 0.1)} inset`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), (
|
2373
|
-
? toolbarProps.sx(theme)
|
2374
|
-
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))), children: [jsx(MRT_LinearProgressBar, { isTopToolbar: false, table: table }), positionToolbarAlertBanner === 'bottom' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
|
2500
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha(theme.palette.common.black, 0.1)} inset`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [jsx(MRT_LinearProgressBar, { isTopToolbar: false, table: table }), positionToolbarAlertBanner === 'bottom' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
|
2375
2501
|
alignItems: 'center',
|
2376
2502
|
boxSizing: 'border-box',
|
2377
2503
|
display: 'flex',
|
@@ -2399,21 +2525,16 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
2399
2525
|
event.preventDefault();
|
2400
2526
|
setAnchorEl(event.currentTarget);
|
2401
2527
|
};
|
2402
|
-
const
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
|
2408
|
-
|
2409
|
-
})
|
2410
|
-
: columnDef.muiColumnActionsButtonProps;
|
2411
|
-
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
2528
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnActionsButtonProps, {
|
2529
|
+
column,
|
2530
|
+
table,
|
2531
|
+
})), parseFromValuesOrFunc(columnDef.muiColumnActionsButtonProps, {
|
2532
|
+
column,
|
2533
|
+
table,
|
2534
|
+
}));
|
2412
2535
|
return (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.columnActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', m: '-8px -4px', opacity: 0.5, transform: 'scale(0.85) translateX(-4px)', transition: 'opacity 150ms', width: '2rem', '&:hover': {
|
2413
2536
|
opacity: 1,
|
2414
|
-
} }, (
|
2415
|
-
? iconButtonProps.sx(theme)
|
2416
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: jsx(MoreVertIcon, {}) })) }), anchorEl && (jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
|
2537
|
+
} }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsx(MoreVertIcon, {}) })) }), anchorEl && (jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
|
2417
2538
|
};
|
2418
2539
|
|
2419
2540
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
@@ -2421,21 +2542,10 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
2421
2542
|
const { options: { enableColumnFilterModes, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, manualFiltering, muiFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
2422
2543
|
const { column } = header;
|
2423
2544
|
const { columnDef } = column;
|
2424
|
-
const
|
2425
|
-
|
2426
|
-
|
2427
|
-
|
2428
|
-
rangeFilterIndex,
|
2429
|
-
})
|
2430
|
-
: muiFilterTextFieldProps;
|
2431
|
-
const mcTableHeadCellFilterTextFieldProps = columnDef.muiFilterTextFieldProps instanceof Function
|
2432
|
-
? columnDef.muiFilterTextFieldProps({
|
2433
|
-
column,
|
2434
|
-
table,
|
2435
|
-
rangeFilterIndex,
|
2436
|
-
})
|
2437
|
-
: columnDef.muiFilterTextFieldProps;
|
2438
|
-
const textFieldProps = Object.assign(Object.assign({}, mTableHeadCellFilterTextFieldProps), mcTableHeadCellFilterTextFieldProps);
|
2545
|
+
const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTextFieldProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterTextFieldProps, {
|
2546
|
+
column,
|
2547
|
+
table,
|
2548
|
+
}));
|
2439
2549
|
const isRangeFilter = columnDef.filterVariant === 'range' || rangeFilterIndex !== undefined;
|
2440
2550
|
const isSelectFilter = columnDef.filterVariant === 'select';
|
2441
2551
|
const isMultiSelectFilter = columnDef.filterVariant === 'multi-select';
|
@@ -2601,9 +2711,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
2601
2711
|
? '120px'
|
2602
2712
|
: 'auto', width: 'calc(100% + 4px)', mx: '-2px', '& .MuiSelect-icon': {
|
2603
2713
|
mr: '1.5rem',
|
2604
|
-
} }, (
|
2605
|
-
? textFieldProps.sx(theme)
|
2606
|
-
: textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx))), children: [(isSelectFilter || isMultiSelectFilter) && (jsx(MenuItem, { divider: true, disabled: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) })), (_k = textFieldProps.children) !== null && _k !== void 0 ? _k : filterSelectOptions === null || filterSelectOptions === void 0 ? void 0 : filterSelectOptions.map((option) => {
|
2714
|
+
} }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))), children: [(isSelectFilter || isMultiSelectFilter) && (jsx(MenuItem, { divider: true, disabled: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) })), (_k = textFieldProps.children) !== null && _k !== void 0 ? _k : filterSelectOptions === null || filterSelectOptions === void 0 ? void 0 : filterSelectOptions.map((option) => {
|
2607
2715
|
var _a;
|
2608
2716
|
if (!option)
|
2609
2717
|
return '';
|
@@ -2636,19 +2744,13 @@ const MRT_FilterCheckbox = ({ column, table, }) => {
|
|
2636
2744
|
const { getState, options: { localization, muiFilterCheckboxProps }, } = table;
|
2637
2745
|
const { density } = getState();
|
2638
2746
|
const { columnDef } = column;
|
2639
|
-
const
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2646
|
-
? columnDef.muiFilterCheckboxProps({
|
2647
|
-
column,
|
2648
|
-
table,
|
2649
|
-
})
|
2650
|
-
: columnDef.muiFilterCheckboxProps;
|
2651
|
-
const checkboxProps = Object.assign(Object.assign({}, mTableHeadCellFilterCheckboxProps), mcTableHeadCellFilterCheckboxProps);
|
2747
|
+
const checkboxProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterCheckboxProps, {
|
2748
|
+
column,
|
2749
|
+
table,
|
2750
|
+
})), parseFromValuesOrFunc(columnDef.muiFilterCheckboxProps, {
|
2751
|
+
column,
|
2752
|
+
table,
|
2753
|
+
}));
|
2652
2754
|
const filterLabel = (_a = localization.filterByColumn) === null || _a === void 0 ? void 0 : _a.replace('{column}', columnDef.header);
|
2653
2755
|
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : filterLabel, children: jsx(FormControlLabel, { control: jsx(Checkbox, Object.assign({ checked: column.getFilterValue() === 'true', indeterminate: column.getFilterValue() === undefined, color: column.getFilterValue() === undefined ? 'default' : 'primary', size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
2654
2756
|
var _a;
|
@@ -2662,9 +2764,7 @@ const MRT_FilterCheckbox = ({ column, table, }) => {
|
|
2662
2764
|
? 'false'
|
2663
2765
|
: undefined);
|
2664
2766
|
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
|
2665
|
-
}, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, (
|
2666
|
-
? checkboxProps.sx(theme)
|
2667
|
-
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }, title: undefined }) }));
|
2767
|
+
}, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }, title: undefined }) }));
|
2668
2768
|
};
|
2669
2769
|
|
2670
2770
|
const MRT_FilterRangeSlider = ({ header, table, }) => {
|
@@ -2674,19 +2774,7 @@ const MRT_FilterRangeSlider = ({ header, table, }) => {
|
|
2674
2774
|
const { columnDef } = column;
|
2675
2775
|
const currentFilterOption = columnDef._filterFn;
|
2676
2776
|
const showChangeModeButton = enableColumnFilterModes && columnDef.enableColumnFilterModes !== false;
|
2677
|
-
const
|
2678
|
-
? muiFilterSliderProps({
|
2679
|
-
column,
|
2680
|
-
table,
|
2681
|
-
})
|
2682
|
-
: muiFilterSliderProps;
|
2683
|
-
const mcFilterSliderProps = columnDef.muiFilterSliderProps instanceof Function
|
2684
|
-
? columnDef.muiFilterSliderProps({
|
2685
|
-
column,
|
2686
|
-
table,
|
2687
|
-
})
|
2688
|
-
: columnDef.muiFilterSliderProps;
|
2689
|
-
const sliderProps = Object.assign(Object.assign({}, mFilterSliderProps), mcFilterSliderProps);
|
2777
|
+
const sliderProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table }));
|
2690
2778
|
let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
|
2691
2779
|
? [sliderProps.min, sliderProps.max]
|
2692
2780
|
: (_a = column.getFacetedMinMaxValues()) !== null && _a !== void 0 ? _a : [0, 1];
|
@@ -2739,9 +2827,7 @@ const MRT_FilterRangeSlider = ({ header, table, }) => {
|
|
2739
2827
|
}
|
2740
2828
|
},
|
2741
2829
|
},
|
2742
|
-
}, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, (
|
2743
|
-
? sliderProps.sx(theme)
|
2744
|
-
: sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx))) })), showChangeModeButton ? (jsx(FormHelperText, { sx: {
|
2830
|
+
}, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsx(FormHelperText, { sx: {
|
2745
2831
|
m: '-3px -6px',
|
2746
2832
|
fontSize: '0.75rem',
|
2747
2833
|
lineHeight: '0.8rem',
|
@@ -2803,13 +2889,10 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
2803
2889
|
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
2804
2890
|
const { columnDef } = column;
|
2805
2891
|
const { hoveredColumn, draggingColumn, columnOrder } = getState();
|
2806
|
-
const
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
? columnDef.muiColumnDragHandleProps({ column, table })
|
2811
|
-
: columnDef.muiColumnDragHandleProps;
|
2812
|
-
const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
|
2892
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
2893
|
+
column,
|
2894
|
+
table,
|
2895
|
+
}));
|
2813
2896
|
const handleDragStart = (event) => {
|
2814
2897
|
var _a;
|
2815
2898
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
@@ -2896,20 +2979,14 @@ const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
|
2896
2979
|
};
|
2897
2980
|
|
2898
2981
|
const MRT_TableHeadCell = ({ header, table, }) => {
|
2899
|
-
var _a, _b, _c, _d, _f
|
2982
|
+
var _a, _b, _c, _d, _f;
|
2900
2983
|
const theme = useTheme();
|
2901
2984
|
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
2902
2985
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
2903
2986
|
const { column } = header;
|
2904
2987
|
const { columnDef } = column;
|
2905
2988
|
const { columnDefType } = columnDef;
|
2906
|
-
const
|
2907
|
-
? muiTableHeadCellProps({ column, table })
|
2908
|
-
: muiTableHeadCellProps;
|
2909
|
-
const mcTableHeadCellProps = columnDef.muiTableHeadCellProps instanceof Function
|
2910
|
-
? columnDef.muiTableHeadCellProps({ column, table })
|
2911
|
-
: columnDef.muiTableHeadCellProps;
|
2912
|
-
const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
|
2989
|
+
const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, { column, table }));
|
2913
2990
|
const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
|
2914
2991
|
columnDef.enableColumnActions !== false;
|
2915
2992
|
const showDragHandle = enableColumnDragging !== false &&
|
@@ -2949,13 +3026,11 @@ const MRT_TableHeadCell = ({ header, table, }) => {
|
|
2949
3026
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
2950
3027
|
}
|
2951
3028
|
};
|
2952
|
-
const headerElement = (
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
})
|
2958
|
-
: (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) !== null && _b !== void 0 ? _b : columnDef.header;
|
3029
|
+
const headerElement = (_a = parseFromValuesOrFunc(columnDef.Header, {
|
3030
|
+
column,
|
3031
|
+
header,
|
3032
|
+
table,
|
3033
|
+
})) !== null && _a !== void 0 ? _a : columnDef.header;
|
2959
3034
|
return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
|
2960
3035
|
if (node) {
|
2961
3036
|
tableHeadCellRefs.current[column.id] = node;
|
@@ -3009,10 +3084,10 @@ const MRT_TableHeadCell = ({ header, table, }) => {
|
|
3009
3084
|
? `${headerPL}rem`
|
3010
3085
|
: undefined,
|
3011
3086
|
}, children: [jsx(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
3012
|
-
minWidth: `${Math.min((
|
3087
|
+
minWidth: `${Math.min((_c = (_b = columnDef.header) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0, 5)}ch`,
|
3013
3088
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
3014
3089
|
textOverflow: 'ellipsis',
|
3015
|
-
whiteSpace: ((
|
3090
|
+
whiteSpace: ((_f = (_d = columnDef.header) === null || _d === void 0 ? void 0 : _d.length) !== null && _f !== void 0 ? _f : 0) < 20 ? 'nowrap' : 'normal',
|
3016
3091
|
'&:hover': {
|
3017
3092
|
textOverflow: 'clip',
|
3018
3093
|
},
|
@@ -3023,12 +3098,11 @@ const MRT_TableHeadCell = ({ header, table, }) => {
|
|
3023
3098
|
|
3024
3099
|
const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
3025
3100
|
const { options: { layoutMode, muiTableHeadRowProps }, } = table;
|
3026
|
-
const tableRowProps = muiTableHeadRowProps
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
|
3101
|
+
const tableRowProps = parseFromValuesOrFunc(muiTableHeadRowProps, {
|
3102
|
+
headerGroup,
|
3103
|
+
table,
|
3104
|
+
});
|
3105
|
+
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
|
3032
3106
|
const header = virtualColumns
|
3033
3107
|
? headerGroup.headers[headerOrVirtualHeader.index]
|
3034
3108
|
: headerOrVirtualHeader;
|
@@ -3037,31 +3111,30 @@ const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLe
|
|
3037
3111
|
};
|
3038
3112
|
|
3039
3113
|
const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
3040
|
-
const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, } = table;
|
3114
|
+
const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, refs: { tableHeadRef }, } = table;
|
3041
3115
|
const { isFullScreen } = getState();
|
3042
|
-
const tableHeadProps = muiTableHeadProps
|
3043
|
-
? muiTableHeadProps({ table })
|
3044
|
-
: muiTableHeadProps;
|
3116
|
+
const tableHeadProps = parseFromValuesOrFunc(muiTableHeadProps, { table });
|
3045
3117
|
const stickyHeader = enableStickyHeader || isFullScreen;
|
3046
|
-
return (jsx(TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, (
|
3047
|
-
|
3048
|
-
|
3118
|
+
return (jsx(TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), ref: (ref) => {
|
3119
|
+
tableHeadRef.current = ref;
|
3120
|
+
if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
|
3121
|
+
// @ts-ignore
|
3122
|
+
tableHeadProps.ref.current = ref;
|
3123
|
+
}
|
3124
|
+
}, children: getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, headerGroup.id))) })));
|
3049
3125
|
};
|
3050
3126
|
|
3051
3127
|
const MRT_TableFooterCell = ({ footer, table, }) => {
|
3052
|
-
var _a, _b
|
3128
|
+
var _a, _b;
|
3053
3129
|
const { getState, options: { layoutMode, muiTableFooterCellProps }, } = table;
|
3054
3130
|
const { density } = getState();
|
3055
3131
|
const { column } = footer;
|
3056
3132
|
const { columnDef } = column;
|
3057
3133
|
const { columnDefType } = columnDef;
|
3058
|
-
const
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
? columnDef.muiTableFooterCellProps({ column, table })
|
3063
|
-
: columnDef.muiTableFooterCellProps;
|
3064
|
-
const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
|
3134
|
+
const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, {
|
3135
|
+
column,
|
3136
|
+
table,
|
3137
|
+
}));
|
3065
3138
|
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-cell', fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
|
3066
3139
|
? '0.5rem'
|
3067
3140
|
: density === 'comfortable'
|
@@ -3073,13 +3146,7 @@ const MRT_TableFooterCell = ({ footer, table, }) => {
|
|
3073
3146
|
tableCellProps,
|
3074
3147
|
}))), children: jsx(Fragment, { children: footer.isPlaceholder
|
3075
3148
|
? null
|
3076
|
-
: (
|
3077
|
-
? (_a = columnDef.Footer) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
|
3078
|
-
column,
|
3079
|
-
footer,
|
3080
|
-
table,
|
3081
|
-
})
|
3082
|
-
: columnDef.Footer)) !== null && _b !== void 0 ? _b : columnDef.footer) !== null && _c !== void 0 ? _c : null }) })));
|
3149
|
+
: (_b = (_a = parseFromValuesOrFunc(columnDef.Footer, { column, footer, table })) !== null && _a !== void 0 ? _a : columnDef.footer) !== null && _b !== void 0 ? _b : null }) })));
|
3083
3150
|
};
|
3084
3151
|
|
3085
3152
|
const MRT_TableFooterRow = ({ footerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
@@ -3090,12 +3157,11 @@ const MRT_TableFooterRow = ({ footerGroup, table, virtualColumns, virtualPadding
|
|
3090
3157
|
!!header.column.columnDef.footer) ||
|
3091
3158
|
header.column.columnDef.Footer)))
|
3092
3159
|
return null;
|
3093
|
-
const tableRowProps = muiTableFooterRowProps
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
|
3160
|
+
const tableRowProps = parseFromValuesOrFunc(muiTableFooterRowProps, {
|
3161
|
+
footerGroup,
|
3162
|
+
table,
|
3163
|
+
});
|
3164
|
+
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.04), display: layoutMode === 'grid' ? 'flex' : 'table-row', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
|
3099
3165
|
const footer = virtualColumns
|
3100
3166
|
? footerGroup.headers[footerOrVirtualFooter.index]
|
3101
3167
|
: footerOrVirtualFooter;
|
@@ -3104,31 +3170,31 @@ const MRT_TableFooterRow = ({ footerGroup, table, virtualColumns, virtualPadding
|
|
3104
3170
|
};
|
3105
3171
|
|
3106
3172
|
const MRT_TableFooter = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
3107
|
-
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, } = table;
|
3173
|
+
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
3108
3174
|
const { isFullScreen } = getState();
|
3109
|
-
const tableFooterProps = muiTableFooterProps
|
3110
|
-
|
3111
|
-
|
3175
|
+
const tableFooterProps = parseFromValuesOrFunc(muiTableFooterProps, {
|
3176
|
+
table,
|
3177
|
+
});
|
3112
3178
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
3113
3179
|
return (jsx(TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
|
3114
3180
|
? theme.palette.mode === 'light'
|
3115
3181
|
? `1px solid ${theme.palette.grey[300]}`
|
3116
3182
|
: `1px solid ${theme.palette.grey[700]}`
|
3117
|
-
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, (
|
3118
|
-
|
3119
|
-
|
3183
|
+
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), ref: (ref) => {
|
3184
|
+
tableFooterRef.current = ref;
|
3185
|
+
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
3186
|
+
// @ts-ignore
|
3187
|
+
tableFooterProps.ref.current = ref;
|
3188
|
+
}
|
3189
|
+
}, children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { footerGroup: footerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, footerGroup.id))) })));
|
3120
3190
|
};
|
3121
3191
|
|
3122
3192
|
const MRT_Table = ({ table, }) => {
|
3123
3193
|
var _a, _b, _c, _d;
|
3124
3194
|
const { getFlatHeaders, getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, columns, enableColumnResizing, enableColumnVirtualization, enableColumnPinning, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
|
3125
3195
|
const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, isFullScreen, } = getState();
|
3126
|
-
const tableProps = muiTableProps
|
3127
|
-
|
3128
|
-
: muiTableProps;
|
3129
|
-
const vProps = columnVirtualizerOptions instanceof Function
|
3130
|
-
? columnVirtualizerOptions({ table })
|
3131
|
-
: columnVirtualizerOptions;
|
3196
|
+
const tableProps = parseFromValuesOrFunc(muiTableProps, { table });
|
3197
|
+
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, { table });
|
3132
3198
|
const columnSizeVars = useMemo(() => {
|
3133
3199
|
const headers = getFlatHeaders();
|
3134
3200
|
const colSizes = {};
|
@@ -3165,7 +3231,7 @@ const MRT_Table = ({ table, }) => {
|
|
3165
3231
|
...defaultRangeExtractor(range),
|
3166
3232
|
...rightPinnedIndexes,
|
3167
3233
|
]),
|
3168
|
-
], [leftPinnedIndexes, rightPinnedIndexes]) },
|
3234
|
+
], [leftPinnedIndexes, rightPinnedIndexes]) }, columnVirtualizerProps))
|
3169
3235
|
: undefined;
|
3170
3236
|
if (columnVirtualizerInstanceRef && columnVirtualizer) {
|
3171
3237
|
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
@@ -3187,9 +3253,7 @@ const MRT_Table = ({ table, }) => {
|
|
3187
3253
|
virtualPaddingLeft,
|
3188
3254
|
virtualPaddingRight,
|
3189
3255
|
};
|
3190
|
-
return (jsx(Fragment, { children: jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, (
|
3191
|
-
? tableProps.sx(theme)
|
3192
|
-
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))), style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), children: [enableTableHead && jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
|
3256
|
+
return (jsx(Fragment, { children: jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), children: [enableTableHead && jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
|
3193
3257
|
};
|
3194
3258
|
|
3195
3259
|
const MRT_EditRowModal = ({ open, table, }) => {
|
@@ -3197,13 +3261,8 @@ const MRT_EditRowModal = ({ open, table, }) => {
|
|
3197
3261
|
const { getState, options: { localization, onEditingRowCancel, onCreatingRowCancel, renderEditRowModalContent, renderCreateRowModalContent, muiCreateRowModalProps, muiEditRowModalProps, }, setEditingRow, setCreatingRow, } = table;
|
3198
3262
|
const { creatingRow, editingRow } = getState();
|
3199
3263
|
const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
|
3200
|
-
const
|
3201
|
-
|
3202
|
-
: muiCreateRowModalProps;
|
3203
|
-
const editModalProps = muiEditRowModalProps instanceof Function
|
3204
|
-
? muiEditRowModalProps({ row, table })
|
3205
|
-
: muiEditRowModalProps;
|
3206
|
-
const dialogProps = Object.assign(Object.assign({}, editModalProps), (creatingRow && createModalProps));
|
3264
|
+
const dialogProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowModalProps, { row, table })), (creatingRow &&
|
3265
|
+
parseFromValuesOrFunc(muiCreateRowModalProps, { row, table })));
|
3207
3266
|
const internalEditComponents = row
|
3208
3267
|
.getAllCells()
|
3209
3268
|
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
@@ -3230,7 +3289,7 @@ const MRT_EditRowModal = ({ open, table, }) => {
|
|
3230
3289
|
row,
|
3231
3290
|
table,
|
3232
3291
|
internalEditComponents,
|
3233
|
-
})))) !== null && _a !== void 0 ? _a : (jsxs(Fragment, { children: [jsx(DialogTitle, { sx: { textAlign: 'center' }, children:
|
3292
|
+
})))) !== null && _a !== void 0 ? _a : (jsxs(Fragment, { children: [jsx(DialogTitle, { sx: { textAlign: 'center' }, children: localization.edit }), jsx(DialogContent, { children: jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsx(Stack, { sx: {
|
3234
3293
|
gap: '24px',
|
3235
3294
|
paddingTop: '16px',
|
3236
3295
|
width: '100%',
|
@@ -3240,11 +3299,11 @@ const MRT_EditRowModal = ({ open, table, }) => {
|
|
3240
3299
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
3241
3300
|
const MRT_TableContainer = ({ table, }) => {
|
3242
3301
|
const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
|
3243
|
-
const { isFullScreen, creatingRow, editingRow
|
3302
|
+
const { isFullScreen, creatingRow, editingRow } = getState();
|
3244
3303
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
3245
|
-
const tableContainerProps = muiTableContainerProps
|
3246
|
-
|
3247
|
-
|
3304
|
+
const tableContainerProps = parseFromValuesOrFunc(muiTableContainerProps, {
|
3305
|
+
table,
|
3306
|
+
});
|
3248
3307
|
useIsomorphicLayoutEffect(() => {
|
3249
3308
|
var _a, _b, _c, _d;
|
3250
3309
|
const topToolbarHeight = typeof document !== 'undefined'
|
@@ -3267,28 +3326,23 @@ const MRT_TableContainer = ({ table, }) => {
|
|
3267
3326
|
}
|
3268
3327
|
}, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader
|
3269
3328
|
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
3270
|
-
: undefined, overflow: 'auto' }, (
|
3271
|
-
? tableContainerProps.sx(theme)
|
3272
|
-
: tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx))), style: Object.assign({ maxHeight: isFullScreen
|
3329
|
+
: undefined, overflow: 'auto' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), style: Object.assign({ maxHeight: isFullScreen
|
3273
3330
|
? `calc(100vh - ${totalToolbarHeight}px)`
|
3274
3331
|
: undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), children: [jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table }))] })));
|
3275
3332
|
};
|
3276
3333
|
|
3277
3334
|
const MRT_TablePaper = ({ table, }) => {
|
3335
|
+
var _a, _b;
|
3278
3336
|
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
|
3279
3337
|
const { isFullScreen } = getState();
|
3280
|
-
const tablePaperProps = muiTablePaperProps
|
3281
|
-
? muiTablePaperProps({ table })
|
3282
|
-
: muiTablePaperProps;
|
3338
|
+
const tablePaperProps = parseFromValuesOrFunc(muiTablePaperProps, { table });
|
3283
3339
|
return (jsxs(Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
|
3284
3340
|
tablePaperRef.current = ref;
|
3285
3341
|
if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
|
3286
3342
|
//@ts-ignore
|
3287
3343
|
tablePaperProps.ref.current = ref;
|
3288
3344
|
}
|
3289
|
-
}, sx: (theme) => (Object.assign({ overflow: 'hidden', transition: 'all 100ms ease-in-out' }, (
|
3290
|
-
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
3291
|
-
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
3345
|
+
}, sx: (theme) => (Object.assign({ overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx, theme))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
3292
3346
|
? {
|
3293
3347
|
bottom: 0,
|
3294
3348
|
height: '100vh',
|
@@ -3304,12 +3358,8 @@ const MRT_TablePaper = ({ table, }) => {
|
|
3304
3358
|
zIndex: 10,
|
3305
3359
|
}
|
3306
3360
|
: {})), children: [enableTopToolbar &&
|
3307
|
-
(renderTopToolbar
|
3308
|
-
|
3309
|
-
: renderTopToolbar !== null && renderTopToolbar !== void 0 ? renderTopToolbar : jsx(MRT_TopToolbar, { table: table })), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
|
3310
|
-
(renderBottomToolbar instanceof Function
|
3311
|
-
? renderBottomToolbar({ table })
|
3312
|
-
: renderBottomToolbar !== null && renderBottomToolbar !== void 0 ? renderBottomToolbar : jsx(MRT_BottomToolbar, { table: table }))] })));
|
3361
|
+
((_a = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _a !== void 0 ? _a : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
|
3362
|
+
((_b = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_BottomToolbar, { table: table })))] })));
|
3313
3363
|
};
|
3314
3364
|
|
3315
3365
|
const isTableInstanceProp = (props) => props.table !== undefined;
|
@@ -3324,5 +3374,5 @@ const MaterialReactTable = (props) => {
|
|
3324
3374
|
return jsx(MRT_TablePaper, { table: table });
|
3325
3375
|
};
|
3326
3376
|
|
3327
|
-
export { 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_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, 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_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, commonListItemStyles, commonMenuItemStyles, commonToolbarStyles, createRow, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonCellStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, parseCSSVarId, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMaterialReactTable };
|
3377
|
+
export { 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_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, commonListItemStyles, commonMenuItemStyles, commonToolbarStyles, createRow, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonCellStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMaterialReactTable };
|
3328
3378
|
//# sourceMappingURL=material-react-table.esm.js.map
|