material-react-table 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -10
- package/dist/index.esm.js +119 -62
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +119 -61
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/body/MRT_TableBody.tsx +25 -9
- package/src/body/MRT_TableBodyCell.tsx +10 -6
- package/src/body/MRT_TableBodyRow.tsx +13 -10
- package/src/body/MRT_TableDetailPanel.tsx +25 -10
- package/src/buttons/MRT_ExpandButton.tsx +16 -4
- package/src/footer/MRT_TableFooterCell.tsx +10 -2
- package/src/head/MRT_TableHeadCell.tsx +9 -3
- package/src/head/MRT_TableHeadRow.tsx +1 -1
- package/src/hooks/useMRT_DisplayColumns.tsx +10 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +14 -4
- package/src/hooks/useMRT_TableOptions.ts +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +2 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -3
- package/src/style.utils.ts +6 -1
- package/src/table/MRT_Table.tsx +1 -3
- package/src/toolbar/MRT_BottomToolbar.tsx +1 -1
- package/src/toolbar/MRT_TablePagination.tsx +8 -4
package/dist/index.esm.js
CHANGED
@@ -26,7 +26,6 @@ import Menu from '@mui/material/Menu';
|
|
26
26
|
import Checkbox from '@mui/material/Checkbox';
|
27
27
|
import Radio from '@mui/material/Radio';
|
28
28
|
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
|
29
|
-
import { useTheme as useTheme$1, alpha as alpha$1 } from '@mui/material';
|
30
29
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
31
30
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
32
31
|
import CancelIcon from '@mui/icons-material/Cancel';
|
@@ -343,14 +342,14 @@ const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: them
|
|
343
342
|
? darken(theme.palette.warning.dark, 0.25)
|
344
343
|
: lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
|
345
344
|
const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
346
|
-
var _a, _b, _c, _d, _e, _f;
|
345
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
347
346
|
const { options: { layoutMode }, } = table;
|
348
347
|
const widthStyles = {
|
349
348
|
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
|
350
|
-
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
|
349
|
+
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px${header ? ` + ${(_e = (_d = header === null || header === void 0 ? void 0 : header.subHeaders) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0}rem` : ''})`,
|
351
350
|
};
|
352
351
|
if (layoutMode === 'grid') {
|
353
|
-
widthStyles.flex = `var(--${header ? 'header' : 'col'}-${parseCSSVarId((
|
352
|
+
widthStyles.flex = `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_f = header === null || header === void 0 ? void 0 : header.id) !== null && _f !== void 0 ? _f : column.id)}-size) 0 auto`;
|
354
353
|
}
|
355
354
|
else if (layoutMode === 'grid-no-grow') {
|
356
355
|
widthStyles.flex = '0 0 auto';
|
@@ -363,8 +362,8 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
363
362
|
? `4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
|
364
363
|
: undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
|
365
364
|
? `${column.getStart('left')}px`
|
366
|
-
: undefined, opacity: ((
|
367
|
-
((
|
365
|
+
: undefined, opacity: ((_g = table.getState().draggingColumn) === null || _g === void 0 ? void 0 : _g.id) === column.id ||
|
366
|
+
((_h = table.getState().hoveredColumn) === null || _h === void 0 ? void 0 : _h.id) === column.id
|
368
367
|
? 0.5
|
369
368
|
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
370
369
|
? 'sticky'
|
@@ -385,6 +384,9 @@ const getCommonToolbarStyles = ({ table, theme, }) => ({
|
|
385
384
|
transition: 'all 150ms ease-in-out',
|
386
385
|
zIndex: 1,
|
387
386
|
});
|
387
|
+
const flipIconStyles = (theme) => theme.direction === 'rtl'
|
388
|
+
? { style: { transform: 'scaleX(-1)' } }
|
389
|
+
: undefined;
|
388
390
|
|
389
391
|
const allowedTypes = ['string', 'number'];
|
390
392
|
const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
|
@@ -573,9 +575,9 @@ const MRT_EditCellTextField = (_a) => {
|
|
573
575
|
|
574
576
|
const MRT_TableBodyCell = (_a) => {
|
575
577
|
var _b, _c, _d, _e, _f;
|
576
|
-
var { cell, measureElement, numRows,
|
578
|
+
var { cell, measureElement, numRows, rowRef, staticRowIndex, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowRef", "staticRowIndex", "table", "virtualColumnIndex"]);
|
577
579
|
const theme = useTheme();
|
578
|
-
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
580
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, positionExpandColumn, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
579
581
|
const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
580
582
|
const { column, row } = cell;
|
581
583
|
const { columnDef } = column;
|
@@ -605,7 +607,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
605
607
|
const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
|
606
608
|
const isFirstColumn = getIsFirstColumn(column, table);
|
607
609
|
const isLastColumn = getIsLastColumn(column, table);
|
608
|
-
const isLastRow = numRows &&
|
610
|
+
const isLastRow = numRows && staticRowIndex === numRows - 1;
|
609
611
|
const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
|
610
612
|
const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
|
611
613
|
const borderStyle = showResizeBorder
|
@@ -644,7 +646,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
644
646
|
draggingRow,
|
645
647
|
hoveredColumn,
|
646
648
|
hoveredRow,
|
647
|
-
|
649
|
+
staticRowIndex,
|
648
650
|
]);
|
649
651
|
const isEditable = !cell.getIsPlaceholder() &&
|
650
652
|
parseFromValuesOrFunc(enableEditing, row) &&
|
@@ -685,7 +687,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
685
687
|
cell,
|
686
688
|
table,
|
687
689
|
};
|
688
|
-
return (jsx(TableCell, Object.assign({ "data-index": virtualColumnIndex, ref: (node) => {
|
690
|
+
return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": virtualColumnIndex, ref: (node) => {
|
689
691
|
if (node) {
|
690
692
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
691
693
|
}
|
@@ -708,7 +710,9 @@ const MRT_TableBodyCell = (_a) => {
|
|
708
710
|
: '1rem'
|
709
711
|
: columnDefType === 'display'
|
710
712
|
? '1rem 1.25rem'
|
711
|
-
: '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, [theme.direction === 'rtl'
|
713
|
+
: '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, [theme.direction === 'rtl' || positionExpandColumn === 'last'
|
714
|
+
? 'pr'
|
715
|
+
: 'pl']: column.id === 'mrt-row-expand'
|
712
716
|
? `${row.depth +
|
713
717
|
(density === 'compact'
|
714
718
|
? 0.5
|
@@ -728,7 +732,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
728
732
|
renderedCellValue: cell.renderValue(),
|
729
733
|
row,
|
730
734
|
rowRef,
|
731
|
-
staticRowIndex
|
735
|
+
staticRowIndex,
|
732
736
|
table,
|
733
737
|
})) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
734
738
|
columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
|
@@ -736,32 +740,40 @@ const MRT_TableBodyCell = (_a) => {
|
|
736
740
|
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
737
741
|
|
738
742
|
const MRT_TableDetailPanel = (_a) => {
|
739
|
-
var { parentRowRef, row,
|
740
|
-
const { getState, getVisibleLeafColumns, options: { layoutMode, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
|
743
|
+
var { parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["parentRowRef", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
|
744
|
+
const { getState, getVisibleLeafColumns, options: { enableRowVirtualization, layoutMode, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
|
741
745
|
const { isLoading } = getState();
|
742
746
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
743
747
|
isDetailPanel: true,
|
744
748
|
row,
|
745
|
-
staticRowIndex
|
749
|
+
staticRowIndex,
|
746
750
|
table,
|
747
751
|
});
|
748
752
|
const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiDetailPanelProps, {
|
749
753
|
row,
|
750
754
|
table,
|
751
755
|
})), rest);
|
752
|
-
|
756
|
+
const DetailPanel = !isLoading && (renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
|
757
|
+
return (jsx(TableRow, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", "data-index": renderDetailPanel ? staticRowIndex * 2 + 1 : staticRowIndex, ref: (node) => {
|
758
|
+
var _a;
|
759
|
+
if (node) {
|
760
|
+
(_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
|
761
|
+
}
|
762
|
+
} }, tableRowProps, { sx: (theme) => {
|
753
763
|
var _a, _b;
|
754
764
|
return (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: virtualRow ? 'absolute' : undefined, top: virtualRow
|
755
765
|
? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
|
756
766
|
: undefined, transform: virtualRow
|
757
767
|
? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
|
758
|
-
: undefined, width: '100%'
|
768
|
+
: undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
|
759
769
|
}, children: jsx(TableCell, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
|
760
770
|
? getMRTTheme(table, theme).baseBackgroundColor
|
761
|
-
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: row.getIsExpanded() ? '1rem' : 0, transition:
|
771
|
+
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: !!DetailPanel && row.getIsExpanded() ? '1rem' : 0, transition: !enableRowVirtualization
|
772
|
+
? 'all 150ms ease-in-out'
|
773
|
+
: undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: enableRowVirtualization ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: !!row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
|
762
774
|
};
|
763
775
|
|
764
|
-
const MRT_TableBodyRow = ({ columnVirtualizer,
|
776
|
+
const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, }) => {
|
765
777
|
var _a, _b, _c, _d;
|
766
778
|
const theme = useTheme();
|
767
779
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
@@ -772,7 +784,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
772
784
|
const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
|
773
785
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
774
786
|
row,
|
775
|
-
staticRowIndex
|
787
|
+
staticRowIndex,
|
776
788
|
table,
|
777
789
|
});
|
778
790
|
const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
|
@@ -803,10 +815,11 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
803
815
|
};
|
804
816
|
const rowRef = useRef(null);
|
805
817
|
const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
|
806
|
-
return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index":
|
818
|
+
return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": renderDetailPanel ? staticRowIndex * 2 : staticRowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || row.getIsAllSubRowsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
819
|
+
var _a;
|
807
820
|
if (node) {
|
808
821
|
rowRef.current = node;
|
809
|
-
|
822
|
+
(_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
|
810
823
|
}
|
811
824
|
}, selected: row.getIsSelected() }, tableRowProps, { style: Object.assign({ transform: virtualRow
|
812
825
|
? `translateY(${virtualRow.start}px)`
|
@@ -848,8 +861,8 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
848
861
|
? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
|
849
862
|
: undefined,
|
850
863
|
numRows,
|
851
|
-
rowIndex,
|
852
864
|
rowRef,
|
865
|
+
staticRowIndex,
|
853
866
|
table,
|
854
867
|
virtualColumnIndex: columnVirtualizer
|
855
868
|
? cellOrVirtualCell.index
|
@@ -861,9 +874,9 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
861
874
|
!draggingRow &&
|
862
875
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
863
876
|
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), cell.id)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), cell.id))) : null;
|
864
|
-
}), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row,
|
877
|
+
}), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
|
865
878
|
};
|
866
|
-
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.
|
879
|
+
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
867
880
|
|
868
881
|
const useMRT_ColumnVirtualizer = (table) => {
|
869
882
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
@@ -1030,7 +1043,8 @@ const MRT_ExpandAllButton = (_a) => {
|
|
1030
1043
|
|
1031
1044
|
const MRT_ExpandButton = ({ row, table, }) => {
|
1032
1045
|
var _a, _b;
|
1033
|
-
const
|
1046
|
+
const theme = useTheme();
|
1047
|
+
const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
|
1034
1048
|
const { density } = getState();
|
1035
1049
|
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
1036
1050
|
row,
|
@@ -1044,8 +1058,16 @@ const MRT_ExpandButton = ({ row, table, }) => {
|
|
1044
1058
|
row.toggleExpanded();
|
1045
1059
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
1046
1060
|
};
|
1047
|
-
|
1048
|
-
|
1061
|
+
const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
|
1062
|
+
return (jsx(Tooltip, { disableHoverListener: !canExpand && !detailPanel, enterDelay: 1000, enterNextDelay: 1000, title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : (isExpanded ? localization.collapse : localization.expand), children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !detailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', opacity: !canExpand && !detailPanel ? 0.3 : 1, 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: {
|
1063
|
+
transform: `rotate(${!canExpand && !renderDetailPanel
|
1064
|
+
? positionExpandColumn === 'last' ||
|
1065
|
+
theme.direction === 'rtl'
|
1066
|
+
? 90
|
1067
|
+
: -90
|
1068
|
+
: isExpanded
|
1069
|
+
? -180
|
1070
|
+
: 0}deg)`,
|
1049
1071
|
transition: 'transform 150ms',
|
1050
1072
|
} })) })) }) }));
|
1051
1073
|
};
|
@@ -1507,7 +1529,7 @@ const MRT_SelectCheckbox = (_a) => {
|
|
1507
1529
|
: undefined;
|
1508
1530
|
const onSelectionChange = (event, row) => {
|
1509
1531
|
var _a;
|
1510
|
-
if (row.getIsAllSubRowsSelected()) {
|
1532
|
+
if (row.getIsAllSubRowsSelected() && row.getCanSelectSubRows()) {
|
1511
1533
|
(_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
|
1512
1534
|
}
|
1513
1535
|
row.getToggleSelectedHandler()(event);
|
@@ -1531,7 +1553,8 @@ const MRT_SelectCheckbox = (_a) => {
|
|
1531
1553
|
? localization.toggleSelectAll
|
1532
1554
|
: localization.toggleSelectRow, checked: selectAll
|
1533
1555
|
? allRowsSelected
|
1534
|
-
: (row === null || row === void 0 ? void 0 : row.getIsSelected()) ||
|
1556
|
+
: (row === null || row === void 0 ? void 0 : row.getIsSelected()) ||
|
1557
|
+
((row === null || row === void 0 ? void 0 : row.getIsAllSubRowsSelected()) && row.getCanSelectSubRows()), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
1535
1558
|
'aria-label': selectAll
|
1536
1559
|
? localization.toggleSelectAll
|
1537
1560
|
: localization.toggleSelectRow,
|
@@ -1547,7 +1570,7 @@ const MRT_SelectCheckbox = (_a) => {
|
|
1547
1570
|
? localization.toggleSelectAll
|
1548
1571
|
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: selectAll
|
1549
1572
|
? table.getIsSomeRowsSelected() && !allRowsSelected
|
1550
|
-
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps))) }));
|
1573
|
+
: (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) }));
|
1551
1574
|
};
|
1552
1575
|
|
1553
1576
|
const useMRT_DisplayColumns = (params) => {
|
@@ -1586,6 +1609,7 @@ const useMRT_DisplayColumns = (params) => {
|
|
1586
1609
|
tableOptions.groupedColumnMode,
|
1587
1610
|
tableOptions.localization,
|
1588
1611
|
tableOptions.positionActionsColumn,
|
1612
|
+
tableOptions.positionExpandColumn,
|
1589
1613
|
tableOptions.renderDetailPanel,
|
1590
1614
|
tableOptions.renderRowActionMenuItems,
|
1591
1615
|
tableOptions.renderRowActions,
|
@@ -1623,6 +1647,11 @@ function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
|
1623
1647
|
const id = 'mrt-row-expand';
|
1624
1648
|
if (order.includes(id) &&
|
1625
1649
|
showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
|
1650
|
+
const alignProps = tableOptions.positionExpandColumn === 'last'
|
1651
|
+
? {
|
1652
|
+
align: 'right',
|
1653
|
+
}
|
1654
|
+
: undefined;
|
1626
1655
|
return Object.assign({ Cell: ({ cell, column, row, table }) => {
|
1627
1656
|
var _a, _b, _c;
|
1628
1657
|
const expandButtonProps = { row, table };
|
@@ -1641,7 +1670,7 @@ function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
|
1641
1670
|
.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
|
1642
1671
|
.join(', ')] }));
|
1643
1672
|
}
|
1644
|
-
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
|
1673
|
+
: undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
|
1645
1674
|
? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
|
1646
1675
|
: 60));
|
1647
1676
|
}
|
@@ -1754,13 +1783,19 @@ const useMRT_Effects = (table) => {
|
|
1754
1783
|
|
1755
1784
|
const useMRT_RowVirtualizer = (table, rows) => {
|
1756
1785
|
var _a;
|
1757
|
-
const { getRowModel, getState, options: { enableRowVirtualization, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
1758
|
-
const { density, draggingRow } = getState();
|
1786
|
+
const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
1787
|
+
const { density, draggingRow, expanded } = getState();
|
1759
1788
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
1760
1789
|
table,
|
1761
1790
|
});
|
1791
|
+
const rowCount = (_a = rows === null || rows === void 0 ? void 0 : rows.length) !== null && _a !== void 0 ? _a : getRowModel().rows.length;
|
1792
|
+
const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
|
1762
1793
|
const rowVirtualizer = enableRowVirtualization
|
1763
|
-
? useVirtualizer(Object.assign({ count:
|
1794
|
+
? useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
|
1795
|
+
? expanded === true
|
1796
|
+
? 100
|
1797
|
+
: 0
|
1798
|
+
: normalRowHeight, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
|
1764
1799
|
navigator.userAgent.indexOf('Firefox') === -1
|
1765
1800
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
1766
1801
|
: undefined, overscan: 4, rangeExtractor: useCallback((range) => {
|
@@ -2254,7 +2289,7 @@ const MRT_DefaultDisplayColumn = {
|
|
2254
2289
|
const useMRT_TableOptions = (_a) => {
|
2255
2290
|
var _b;
|
2256
2291
|
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, 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, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "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", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
2257
|
-
const theme = useTheme
|
2292
|
+
const theme = useTheme();
|
2258
2293
|
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
2259
2294
|
const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
2260
2295
|
const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
@@ -2334,7 +2369,7 @@ const useMRT_TableOptions = (_a) => {
|
|
2334
2369
|
const MRT_TableBody = (_a) => {
|
2335
2370
|
var _b, _c, _d, _e, _f, _g;
|
2336
2371
|
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2337
|
-
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
2372
|
+
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
2338
2373
|
const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
|
2339
2374
|
const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
|
2340
2375
|
const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
|
@@ -2357,11 +2392,11 @@ const MRT_TableBody = (_a) => {
|
|
2357
2392
|
numRows: rows.length,
|
2358
2393
|
table,
|
2359
2394
|
};
|
2360
|
-
const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow,
|
2395
|
+
const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, staticRowIndex: -1 })));
|
2361
2396
|
return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
2362
|
-
getIsSomeRowsPinned('top') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row,
|
2397
|
+
getIsSomeRowsPinned('top') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, staticRowIndex) => {
|
2363
2398
|
const props = Object.assign(Object.assign({}, commonRowProps), { row,
|
2364
|
-
|
2399
|
+
staticRowIndex });
|
2365
2400
|
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
2366
2401
|
}) }))), rowVirtualizer && CreatingRow && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: CreatingRow }))), jsxs(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
|
2367
2402
|
? `${rowVirtualizer.getTotalSize()}px`
|
@@ -2378,20 +2413,35 @@ const MRT_TableBody = (_a) => {
|
|
2378
2413
|
width: '100%',
|
2379
2414
|
}, children: globalFilter || columnFilters.length
|
2380
2415
|
? localization.noResultsFound
|
2381
|
-
: localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow,
|
2416
|
+
: localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, staticRowIndex) => {
|
2417
|
+
if (rowVirtualizer) {
|
2418
|
+
if (renderDetailPanel) {
|
2419
|
+
if (rowOrVirtualRow.index % 2 === 1) {
|
2420
|
+
return null;
|
2421
|
+
}
|
2422
|
+
else {
|
2423
|
+
staticRowIndex = rowOrVirtualRow.index / 2;
|
2424
|
+
}
|
2425
|
+
}
|
2426
|
+
else {
|
2427
|
+
staticRowIndex = rowOrVirtualRow.index;
|
2428
|
+
}
|
2429
|
+
}
|
2382
2430
|
const row = rowVirtualizer
|
2383
|
-
? rows[
|
2431
|
+
? rows[staticRowIndex]
|
2384
2432
|
: rowOrVirtualRow;
|
2385
|
-
const props = Object.assign(Object.assign({}, commonRowProps), {
|
2386
|
-
row,
|
2433
|
+
const props = Object.assign(Object.assign({}, commonRowProps), { pinnedRowIds,
|
2434
|
+
row,
|
2435
|
+
rowVirtualizer,
|
2436
|
+
staticRowIndex, virtualRow: rowVirtualizer
|
2387
2437
|
? rowOrVirtualRow
|
2388
2438
|
: undefined });
|
2389
2439
|
const key = `${row.id}-${row.index}`;
|
2390
2440
|
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
|
2391
2441
|
}) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
2392
|
-
getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row,
|
2442
|
+
getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, staticRowIndex) => {
|
2393
2443
|
const props = Object.assign(Object.assign({}, commonRowProps), { row,
|
2394
|
-
|
2444
|
+
staticRowIndex });
|
2395
2445
|
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
2396
2446
|
}) })))] }));
|
2397
2447
|
};
|
@@ -2400,6 +2450,7 @@ const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.option
|
|
2400
2450
|
const MRT_TableFooterCell = (_a) => {
|
2401
2451
|
var _b, _c, _d;
|
2402
2452
|
var { footer, table } = _a, rest = __rest(_a, ["footer", "table"]);
|
2453
|
+
const theme = useTheme();
|
2403
2454
|
const { getState, options: { layoutMode, muiTableFooterCellProps }, } = table;
|
2404
2455
|
const { density } = getState();
|
2405
2456
|
const { column } = footer;
|
@@ -2407,7 +2458,11 @@ const MRT_TableFooterCell = (_a) => {
|
|
2407
2458
|
const { columnDefType } = columnDef;
|
2408
2459
|
const args = { column, table };
|
2409
2460
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2410
|
-
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
|
2461
|
+
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
|
2462
|
+
? 'center'
|
2463
|
+
: theme.direction === 'rtl'
|
2464
|
+
? 'right'
|
2465
|
+
: 'left', colSpan: footer.colSpan, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
|
2411
2466
|
? '0.5rem'
|
2412
2467
|
: density === 'comfortable'
|
2413
2468
|
? '1rem'
|
@@ -2704,7 +2759,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2704
2759
|
if (textFieldProps.inputRef) {
|
2705
2760
|
textFieldProps.inputRef = inputRef;
|
2706
2761
|
}
|
2707
|
-
}, margin: 'none',
|
2762
|
+
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
2708
2763
|
? undefined
|
2709
2764
|
: filterPlaceholder, variant: 'standard' }, textFieldProps), { sx: (theme) => (Object.assign({ minWidth: isDateFilter
|
2710
2765
|
? '160px'
|
@@ -2732,13 +2787,13 @@ const MRT_FilterTextField = (_a) => {
|
|
2732
2787
|
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
2733
2788
|
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
2734
2789
|
var _a;
|
2735
|
-
return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange })));
|
2790
|
+
return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
|
2736
2791
|
}, value: filterValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
2737
2792
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
2738
2793
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
2739
2794
|
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
2740
2795
|
}) }))
|
2741
|
-
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2796
|
+
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2742
2797
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
2743
2798
|
...[
|
2744
2799
|
(_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
@@ -3073,12 +3128,16 @@ const MRT_TableHeadCell = (_a) => {
|
|
3073
3128
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
3074
3129
|
}
|
3075
3130
|
};
|
3076
|
-
const
|
3131
|
+
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3077
3132
|
column,
|
3078
3133
|
header,
|
3079
3134
|
table,
|
3080
3135
|
})) !== null && _b !== void 0 ? _b : columnDef.header;
|
3081
|
-
return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group'
|
3136
|
+
return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group'
|
3137
|
+
? 'center'
|
3138
|
+
: theme.direction === 'rtl'
|
3139
|
+
? 'right'
|
3140
|
+
: 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
|
3082
3141
|
if (node) {
|
3083
3142
|
tableHeadCellRefs.current[column.id] = node;
|
3084
3143
|
}
|
@@ -3147,7 +3206,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3147
3206
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
3148
3207
|
? 'nowrap'
|
3149
3208
|
: 'normal',
|
3150
|
-
}, title: columnDefType === 'data' ? columnDef.header : undefined, children:
|
3209
|
+
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
3151
3210
|
whiteSpace: 'nowrap',
|
3152
3211
|
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3153
3212
|
current: tableHeadCellRefs.current[column.id],
|
@@ -3162,7 +3221,7 @@ const MRT_TableHeadRow = (_a) => {
|
|
3162
3221
|
headerGroup,
|
3163
3222
|
table,
|
3164
3223
|
})), rest);
|
3165
|
-
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, boxShadow: `4px 0 8px ${alpha
|
3224
|
+
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor, boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, 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) => {
|
3166
3225
|
const header = virtualColumns
|
3167
3226
|
? headerGroup.headers[headerOrVirtualHeader.index]
|
3168
3227
|
: headerOrVirtualHeader;
|
@@ -3189,6 +3248,7 @@ const MRT_LinearProgressBar = (_a) => {
|
|
3189
3248
|
const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
|
3190
3249
|
const MRT_TablePagination = (_a) => {
|
3191
3250
|
var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
|
3251
|
+
const theme = useTheme();
|
3192
3252
|
const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiPaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
|
3193
3253
|
const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
|
3194
3254
|
const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
|
@@ -3228,7 +3288,7 @@ const MRT_TablePagination = (_a) => {
|
|
3228
3288
|
last: LastPageIcon,
|
3229
3289
|
next: ChevronRightIcon,
|
3230
3290
|
previous: ChevronLeftIcon,
|
3231
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) }) }) })), jsx(Tooltip, { enterDelay: 1000, title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }) }) }), jsx(Tooltip, { enterDelay: 1000, title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }) }) }), showLastButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }) }) }))] })] })) : null] }));
|
3291
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, { enterDelay: 1000, title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) }), jsx(Tooltip, { enterDelay: 1000, title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) }), showLastButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))] })] })) : null] }));
|
3232
3292
|
};
|
3233
3293
|
|
3234
3294
|
const MRT_GlobalFilterTextField = (_a) => {
|
@@ -3357,7 +3417,7 @@ const MRT_BottomToolbar = (_a) => {
|
|
3357
3417
|
toolbarProps.ref.current = node;
|
3358
3418
|
}
|
3359
3419
|
}
|
3360
|
-
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table, theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha
|
3420
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table, theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha(theme.palette.grey[700], 0.5)} 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: {
|
3361
3421
|
alignItems: 'center',
|
3362
3422
|
boxSizing: 'border-box',
|
3363
3423
|
display: 'flex',
|
@@ -3644,14 +3704,11 @@ const MRT_Table = (_a) => {
|
|
3644
3704
|
const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = getState();
|
3645
3705
|
const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
|
3646
3706
|
const columnSizeVars = useMemo(() => {
|
3647
|
-
var _a;
|
3648
3707
|
const headers = getFlatHeaders();
|
3649
3708
|
const colSizes = {};
|
3650
3709
|
for (let i = 0; i < headers.length; i++) {
|
3651
3710
|
const header = headers[i];
|
3652
|
-
|
3653
|
-
if ((_a = header.subHeaders) === null || _a === void 0 ? void 0 : _a.length)
|
3654
|
-
colSize = colSize * 1.05 + header.subHeaders.length * 2;
|
3711
|
+
const colSize = header.getSize();
|
3655
3712
|
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
3656
3713
|
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
3657
3714
|
}
|
@@ -3809,5 +3866,5 @@ const MaterialReactTable = (props) => {
|
|
3809
3866
|
return jsx(MRT_TablePaper, { table: table });
|
3810
3867
|
};
|
3811
3868
|
|
3812
|
-
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_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, extraIndexRangeExtractor, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonMRTCellStyles, getCommonToolbarStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getMRTTheme, getTotalRight, getTrailingDisplayColumnIds, getValueAndLabel, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMRT_ColumnVirtualizer, useMRT_DisplayColumns, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
3869
|
+
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_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, extraIndexRangeExtractor, flexRender, flipIconStyles, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonMRTCellStyles, getCommonToolbarStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getMRTTheme, getTotalRight, getTrailingDisplayColumnIds, getValueAndLabel, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMRT_ColumnVirtualizer, useMRT_DisplayColumns, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
3813
3870
|
//# sourceMappingURL=index.esm.js.map
|