material-react-table 0.41.0 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -20
- package/dist/cjs/MaterialReactTable.d.ts +96 -19
- package/dist/cjs/_locales/en.d.ts +2 -0
- package/dist/cjs/_locales/es.d.ts +2 -0
- package/dist/cjs/body/MRT_EditRowModal.d.ts +0 -1
- package/dist/cjs/body/MRT_TableBody.d.ts +1 -2
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
- package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +0 -1
- package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
- package/dist/cjs/column.utils.d.ts +12 -1
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +244 -195
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +0 -1
- package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +3 -4
- package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
- package/dist/cjs/table/MRT_Table.d.ts +1 -2
- package/dist/cjs/table/MRT_TableRoot.d.ts +250 -3
- package/dist/cjs/toolbar/MRT_TablePagination.d.ts +3 -4
- package/dist/cjs/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/cjs/toolbar/MRT_ToolbarInternalButtons.d.ts +3 -4
- package/dist/cjs/toolbar/MRT_TopToolbar.d.ts +1 -0
- package/dist/en.cjs +90 -0
- package/dist/en.cjs.d.ts +2 -0
- package/dist/en.cjs.map +1 -0
- package/dist/en.esm.d.ts +2 -0
- package/dist/en.esm.js +86 -0
- package/dist/en.esm.js.map +1 -0
- package/dist/esm/MaterialReactTable.d.ts +96 -19
- package/dist/esm/_locales/en.d.ts +2 -0
- package/dist/esm/_locales/es.d.ts +2 -0
- package/dist/esm/body/MRT_EditRowModal.d.ts +0 -1
- package/dist/esm/body/MRT_TableBody.d.ts +1 -2
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
- package/dist/esm/buttons/MRT_EditActionButtons.d.ts +0 -1
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
- package/dist/esm/column.utils.d.ts +12 -1
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/inputs/MRT_EditCellTextField.d.ts +0 -1
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
- package/dist/esm/material-react-table.esm.js +245 -198
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +3 -4
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
- package/dist/esm/table/MRT_Table.d.ts +1 -2
- package/dist/esm/table/MRT_TableRoot.d.ts +250 -3
- package/dist/esm/toolbar/MRT_TablePagination.d.ts +3 -4
- package/dist/esm/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +3 -4
- package/dist/esm/toolbar/MRT_TopToolbar.d.ts +1 -0
- package/dist/index.d.ts +47 -41
- package/package.json +7 -6
- package/src/MaterialReactTable.tsx +100 -23
- package/src/_locales/de.ts +0 -0
- package/src/{localization.ts → _locales/en.ts} +4 -82
- package/src/_locales/es.ts +86 -0
- package/src/_locales/fr.ts +0 -0
- package/src/_locales/hi.ts +0 -0
- package/src/_locales/id.ts +0 -0
- package/src/_locales/ja.ts +0 -0
- package/src/_locales/nl.ts +0 -0
- package/src/_locales/pt.ts +0 -0
- package/src/_locales/ru.ts +0 -0
- package/src/_locales/uk.ts +0 -0
- package/src/_locales/vi.ts +0 -0
- package/src/_locales/zh.ts +0 -0
- package/src/body/MRT_TableBody.tsx +54 -30
- package/src/body/MRT_TableBodyCell.tsx +11 -58
- package/src/body/MRT_TableBodyCellValue.tsx +7 -2
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -8
- package/src/buttons/MRT_GrabHandleButton.tsx +2 -2
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +7 -2
- package/src/column.utils.ts +72 -0
- package/src/footer/MRT_TableFooter.tsx +3 -2
- package/src/footer/MRT_TableFooterCell.tsx +5 -15
- package/src/head/MRT_TableHead.tsx +10 -2
- package/src/head/MRT_TableHeadCell.tsx +9 -50
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +7 -7
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +5 -12
- package/src/index.tsx +6 -3
- package/src/inputs/MRT_FilterTextField.tsx +8 -7
- package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -1
- package/src/menus/MRT_FilterOptionMenu.tsx +19 -2
- package/src/table/MRT_Table.tsx +3 -4
- package/src/table/MRT_TableContainer.tsx +2 -11
- package/src/table/MRT_TablePaper.tsx +34 -20
- package/src/table/MRT_TableRoot.tsx +34 -11
- package/src/toolbar/MRT_BottomToolbar.tsx +11 -2
- package/src/toolbar/MRT_TablePagination.tsx +7 -5
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +7 -1
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +14 -12
- package/src/toolbar/MRT_TopToolbar.tsx +13 -2
- package/dist/cjs/localization.d.ts +0 -82
- package/dist/esm/localization.d.ts +0 -82
package/dist/cjs/index.js
CHANGED
|
@@ -159,7 +159,7 @@ const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { b
|
|
|
159
159
|
notEquals,
|
|
160
160
|
startsWith });
|
|
161
161
|
|
|
162
|
-
const
|
|
162
|
+
const MRT_Localization_EN = {
|
|
163
163
|
actions: 'Actions',
|
|
164
164
|
and: 'and',
|
|
165
165
|
cancel: 'Cancel',
|
|
@@ -208,6 +208,8 @@ const MRT_DefaultLocalization_EN = {
|
|
|
208
208
|
max: 'Max',
|
|
209
209
|
min: 'Min',
|
|
210
210
|
move: 'Move',
|
|
211
|
+
noRecordsToDisplay: 'No records to display',
|
|
212
|
+
noResultsFound: 'No results found',
|
|
211
213
|
or: 'or',
|
|
212
214
|
pinToLeft: 'Pin to left',
|
|
213
215
|
pinToRight: 'Pin to right',
|
|
@@ -391,7 +393,7 @@ const mrtFilterOptions = (localization) => [
|
|
|
391
393
|
divider: false,
|
|
392
394
|
},
|
|
393
395
|
];
|
|
394
|
-
const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table, }) => {
|
|
396
|
+
const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilterValue, table, }) => {
|
|
395
397
|
var _a, _b, _c, _d;
|
|
396
398
|
const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
|
|
397
399
|
const { globalFilterFn, density } = getState();
|
|
@@ -410,11 +412,19 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
|
|
|
410
412
|
if (['empty', 'notEmpty'].includes(option)) {
|
|
411
413
|
column.setFilterValue(' ');
|
|
412
414
|
}
|
|
413
|
-
else if (
|
|
415
|
+
else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
|
|
416
|
+
['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'].includes(option)) {
|
|
417
|
+
column.setFilterValue([]);
|
|
418
|
+
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
|
|
419
|
+
}
|
|
420
|
+
else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'range' ||
|
|
421
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(option)) {
|
|
414
422
|
column.setFilterValue(['', '']);
|
|
423
|
+
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
|
415
424
|
}
|
|
416
425
|
else {
|
|
417
426
|
column.setFilterValue('');
|
|
427
|
+
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
|
418
428
|
}
|
|
419
429
|
}
|
|
420
430
|
else {
|
|
@@ -477,11 +487,11 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
477
487
|
var _a;
|
|
478
488
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
479
489
|
return (React__default["default"].createElement(material.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.move },
|
|
480
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true",
|
|
490
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
|
|
481
491
|
var _a;
|
|
482
492
|
e.stopPropagation();
|
|
483
493
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
484
|
-
}, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
|
|
494
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
|
|
485
495
|
backgroundColor: 'transparent',
|
|
486
496
|
opacity: 1,
|
|
487
497
|
}, '&:active': {
|
|
@@ -595,6 +605,37 @@ const getDefaultColumnFilterFn = (columnDef) => {
|
|
|
595
605
|
return 'betweenInclusive';
|
|
596
606
|
return 'fuzzy';
|
|
597
607
|
};
|
|
608
|
+
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
609
|
+
return (column.getIsPinned() === 'left' &&
|
|
610
|
+
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
611
|
+
};
|
|
612
|
+
const getIsFirstRightPinnedColumn = (column) => {
|
|
613
|
+
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
614
|
+
};
|
|
615
|
+
const getTotalRight = (table, column) => {
|
|
616
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
617
|
+
};
|
|
618
|
+
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
619
|
+
var _a, _b, _c, _d;
|
|
620
|
+
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
621
|
+
? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
|
|
622
|
+
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
623
|
+
? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
624
|
+
: getIsFirstRightPinnedColumn(column)
|
|
625
|
+
? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
626
|
+
: undefined, left: column.getIsPinned() === 'left'
|
|
627
|
+
? `${column.getStart('left')}px`
|
|
628
|
+
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
629
|
+
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
630
|
+
? 0.5
|
|
631
|
+
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
632
|
+
? 'sticky'
|
|
633
|
+
: undefined, right: column.getIsPinned() === 'right'
|
|
634
|
+
? `${getTotalRight(table, column)}px`
|
|
635
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '0.2s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
636
|
+
? tableCellProps.sx(theme)
|
|
637
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
638
|
+
};
|
|
598
639
|
|
|
599
640
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
600
641
|
var _a;
|
|
@@ -1030,7 +1071,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1030
1071
|
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1031
1072
|
? muiSearchTextFieldProps({ table })
|
|
1032
1073
|
: muiSearchTextFieldProps;
|
|
1033
|
-
return (React__default["default"].createElement(material.Collapse, { in: showGlobalFilter, orientation: "horizontal" },
|
|
1074
|
+
return (React__default["default"].createElement(material.Collapse, { in: showGlobalFilter, orientation: "horizontal", unmountOnExit: true, mountOnEnter: true },
|
|
1034
1075
|
React__default["default"].createElement(material.TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
|
|
1035
1076
|
startAdornment: enableGlobalFilterModes ? (React__default["default"].createElement(material.InputAdornment, { position: "start" },
|
|
1036
1077
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.changeSearchMode },
|
|
@@ -1047,7 +1088,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1047
1088
|
textFieldProps.inputRef = inputRef;
|
|
1048
1089
|
}
|
|
1049
1090
|
} })),
|
|
1050
|
-
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1091
|
+
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table, onSelect: handleClear })));
|
|
1051
1092
|
};
|
|
1052
1093
|
|
|
1053
1094
|
const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
@@ -1065,7 +1106,7 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
|
1065
1106
|
React__default["default"].createElement(material.LinearProgress, Object.assign({ "aria-label": "Loading", "aria-busy": "true", sx: { position: 'relative' } }, linearProgressProps))));
|
|
1066
1107
|
};
|
|
1067
1108
|
|
|
1068
|
-
const MRT_TablePagination = ({ table, position }) => {
|
|
1109
|
+
const MRT_TablePagination = ({ table, position, }) => {
|
|
1069
1110
|
const { getPrePaginationRowModel, getState, setPageIndex, setPageSize, options: { muiTablePaginationProps, enableToolbarInternalActions, rowCount, }, } = table;
|
|
1070
1111
|
const { pagination: { pageSize = 10, pageIndex = 0 }, showGlobalFilter, } = getState();
|
|
1071
1112
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
|
@@ -1079,7 +1120,7 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1079
1120
|
return (React__default["default"].createElement(material.TablePagination, Object.assign({ SelectProps: {
|
|
1080
1121
|
sx: { m: '0 1rem 0 1ch' },
|
|
1081
1122
|
MenuProps: { MenuListProps: { disablePadding: true } },
|
|
1082
|
-
}, component: "div", count: totalRowCount, onPageChange: (_, newPage) => setPageIndex(newPage), onRowsPerPageChange: handleChangeRowsPerPage, page: pageIndex, rowsPerPage: pageSize, rowsPerPageOptions: [5, 10, 15, 20, 25, 30, 50, 100], showFirstButton: showFirstLastPageButtons, showLastButton: showFirstLastPageButtons }, tablePaginationProps, { sx: (theme) => (Object.assign({
|
|
1123
|
+
}, component: "div", count: totalRowCount, onPageChange: (_, newPage) => setPageIndex(newPage), onRowsPerPageChange: handleChangeRowsPerPage, page: pageIndex, rowsPerPage: pageSize, rowsPerPageOptions: [5, 10, 15, 20, 25, 30, 50, 100], showFirstButton: showFirstLastPageButtons, showLastButton: showFirstLastPageButtons }, tablePaginationProps, { sx: (theme) => (Object.assign({ mt: position === 'top' &&
|
|
1083
1124
|
enableToolbarInternalActions &&
|
|
1084
1125
|
!showGlobalFilter
|
|
1085
1126
|
? '3.5rem'
|
|
@@ -1090,7 +1131,7 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1090
1131
|
|
|
1091
1132
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
1092
1133
|
var _a, _b;
|
|
1093
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
|
|
1134
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
|
|
1094
1135
|
const { grouping, showAlertBanner } = getState();
|
|
1095
1136
|
const alertProps = muiToolbarAlertBannerProps instanceof Function
|
|
1096
1137
|
? muiToolbarAlertBannerProps({ table })
|
|
@@ -1108,7 +1149,11 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1108
1149
|
index > 0 ? localization.thenBy : '',
|
|
1109
1150
|
React__default["default"].createElement(material.Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
|
|
1110
1151
|
return (React__default["default"].createElement(material.Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0 },
|
|
1111
|
-
React__default["default"].createElement(material.Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative',
|
|
1152
|
+
React__default["default"].createElement(material.Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative', mb: stackAlertBanner
|
|
1153
|
+
? 0
|
|
1154
|
+
: positionToolbarAlertBanner === 'bottom'
|
|
1155
|
+
? '-1rem'
|
|
1156
|
+
: undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
|
|
1112
1157
|
? alertProps.sx(theme)
|
|
1113
1158
|
: alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))) }),
|
|
1114
1159
|
(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && React__default["default"].createElement(material.AlertTitle, null, alertProps.title),
|
|
@@ -1180,18 +1225,18 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
|
1180
1225
|
var _b;
|
|
1181
1226
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1182
1227
|
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1183
|
-
const { showGlobalFilter } = getState();
|
|
1228
|
+
const { globalFilter, showGlobalFilter } = getState();
|
|
1184
1229
|
const handleToggleSearch = () => {
|
|
1185
1230
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1186
1231
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1187
1232
|
};
|
|
1188
1233
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch },
|
|
1189
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ onClick: handleToggleSearch }, rest, { title: undefined }), showGlobalFilter ? React__default["default"].createElement(SearchOffIcon, null) : React__default["default"].createElement(SearchIcon, null))));
|
|
1234
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ disabled: !!globalFilter, onClick: handleToggleSearch }, rest, { title: undefined }), showGlobalFilter ? React__default["default"].createElement(SearchOffIcon, null) : React__default["default"].createElement(SearchIcon, null))));
|
|
1190
1235
|
};
|
|
1191
1236
|
|
|
1192
|
-
const MRT_ToolbarInternalButtons = ({ table }) => {
|
|
1237
|
+
const MRT_ToolbarInternalButtons = ({ table, }) => {
|
|
1193
1238
|
var _a;
|
|
1194
|
-
const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, enablePinning,
|
|
1239
|
+
const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, enablePinning, initialState, renderToolbarInternalActions, }, } = table;
|
|
1195
1240
|
return (React__default["default"].createElement(material.Box, { sx: {
|
|
1196
1241
|
alignItems: 'center',
|
|
1197
1242
|
display: 'flex',
|
|
@@ -1199,8 +1244,9 @@ const MRT_ToolbarInternalButtons = ({ table }) => {
|
|
|
1199
1244
|
} }, (_a = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({
|
|
1200
1245
|
table,
|
|
1201
1246
|
})) !== null && _a !== void 0 ? _a : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1202
|
-
|
|
1203
|
-
|
|
1247
|
+
enableFilters &&
|
|
1248
|
+
enableGlobalFilter &&
|
|
1249
|
+
!(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (React__default["default"].createElement(MRT_ToggleGlobalFilterButton, { table: table })),
|
|
1204
1250
|
enableFilters && enableColumnFilters && (React__default["default"].createElement(MRT_ToggleFiltersButton, { table: table })),
|
|
1205
1251
|
(enableHiding || enableColumnOrdering || enablePinning) && (React__default["default"].createElement(MRT_ShowHideColumnsButton, { table: table })),
|
|
1206
1252
|
enableDensityToggle && (React__default["default"].createElement(MRT_ToggleDensePaddingButton, { table: table })),
|
|
@@ -1236,6 +1282,7 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1236
1282
|
backgroundColor: material.lighten(theme.palette.background.default, 0.04),
|
|
1237
1283
|
backgroundImage: 'none',
|
|
1238
1284
|
display: 'grid',
|
|
1285
|
+
flexWrap: 'wrap-reverse',
|
|
1239
1286
|
minHeight: '3.5rem',
|
|
1240
1287
|
overflow: 'hidden',
|
|
1241
1288
|
p: '0 !important',
|
|
@@ -1274,7 +1321,13 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1274
1321
|
width: '100%',
|
|
1275
1322
|
} },
|
|
1276
1323
|
enableGlobalFilter && positionGlobalFilter === 'left' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : React__default["default"].createElement("span", null),
|
|
1277
|
-
enableToolbarInternalActions ? (React__default["default"].createElement(
|
|
1324
|
+
enableToolbarInternalActions ? (React__default["default"].createElement(material.Box, { sx: {
|
|
1325
|
+
display: 'flex',
|
|
1326
|
+
flexWrap: 'wrap-reverse',
|
|
1327
|
+
justifyContent: 'flex-end',
|
|
1328
|
+
} },
|
|
1329
|
+
enableGlobalFilter && positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })),
|
|
1330
|
+
React__default["default"].createElement(MRT_ToolbarInternalButtons, { table: table }))) : (enableGlobalFilter &&
|
|
1278
1331
|
positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })))),
|
|
1279
1332
|
enablePagination &&
|
|
1280
1333
|
['top', 'both'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (React__default["default"].createElement(MRT_TablePagination, { table: table, position: "top" })),
|
|
@@ -1295,15 +1348,18 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1295
1348
|
// @ts-ignore
|
|
1296
1349
|
toolbarProps.ref.current = ref;
|
|
1297
1350
|
}
|
|
1298
|
-
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow:
|
|
1351
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${material.alpha(theme.palette.common.black, 0.1)} inset`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
|
|
1299
1352
|
? toolbarProps.sx(theme)
|
|
1300
1353
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1301
1354
|
React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
1302
|
-
positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { table: table })),
|
|
1355
|
+
positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
1303
1356
|
['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React__default["default"].createElement(MRT_ToolbarDropZone, { table: table })),
|
|
1304
1357
|
React__default["default"].createElement(material.Box, { sx: {
|
|
1358
|
+
alignItems: 'center',
|
|
1359
|
+
boxSizing: 'border-box',
|
|
1305
1360
|
display: 'flex',
|
|
1306
1361
|
justifyContent: 'space-between',
|
|
1362
|
+
p: '0.5rem',
|
|
1307
1363
|
width: '100%',
|
|
1308
1364
|
} },
|
|
1309
1365
|
renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (React__default["default"].createElement("span", null)),
|
|
@@ -1447,9 +1503,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1447
1503
|
const handleFilterMenuOpen = (event) => {
|
|
1448
1504
|
setAnchorEl(event.currentTarget);
|
|
1449
1505
|
};
|
|
1450
|
-
React.useEffect(() => {
|
|
1451
|
-
setFilterValue('');
|
|
1452
|
-
}, [columnDef._filterFn]);
|
|
1453
1506
|
if (columnDef.Filter) {
|
|
1454
1507
|
return React__default["default"].createElement(React__default["default"].Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, table }));
|
|
1455
1508
|
}
|
|
@@ -1507,7 +1560,11 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1507
1560
|
if (textFieldProps.inputRef) {
|
|
1508
1561
|
textFieldProps.inputRef = inputRef;
|
|
1509
1562
|
}
|
|
1510
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth:
|
|
1563
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: columnDef.filterVariant === 'range'
|
|
1564
|
+
? '90px'
|
|
1565
|
+
: !filterChipLabel
|
|
1566
|
+
? '120px'
|
|
1567
|
+
: 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1511
1568
|
mr: '1.5rem',
|
|
1512
1569
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1513
1570
|
? textFieldProps.sx(theme)
|
|
@@ -1535,7 +1592,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1535
1592
|
isMultiSelectFilter && (React__default["default"].createElement(material.Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })),
|
|
1536
1593
|
text));
|
|
1537
1594
|
})),
|
|
1538
|
-
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1595
|
+
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table, setFilterValue: setFilterValue })));
|
|
1539
1596
|
};
|
|
1540
1597
|
|
|
1541
1598
|
const MRT_FilterRangeFields = ({ header, table }) => {
|
|
@@ -1557,11 +1614,8 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1557
1614
|
const { options: { icons: { FilterAltIcon }, localization, }, } = table;
|
|
1558
1615
|
const { column } = header;
|
|
1559
1616
|
const { columnDef } = column;
|
|
1560
|
-
const isRangeFilter =
|
|
1561
|
-
'between',
|
|
1562
|
-
'betweenInclusive',
|
|
1563
|
-
'inNumberRange',
|
|
1564
|
-
].includes(columnDef._filterFn);
|
|
1617
|
+
const isRangeFilter = columnDef.filterVariant === 'range' ||
|
|
1618
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
|
|
1565
1619
|
const currentFilterOption = columnDef._filterFn;
|
|
1566
1620
|
const filterTooltip = localization.filteringByColumn
|
|
1567
1621
|
.replace('{column}', String(columnDef.header))
|
|
@@ -1573,8 +1627,8 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1573
1627
|
? column.getFilterValue().join(`" ${isRangeFilter ? localization.and : localization.or} "`)
|
|
1574
1628
|
: column.getFilterValue()}"`)
|
|
1575
1629
|
.replace('" "', '');
|
|
1576
|
-
return (React__default["default"].createElement(material.Grow, { unmountOnExit: true, in: (!!column.getFilterValue() && isRangeFilter) ||
|
|
1577
|
-
(
|
|
1630
|
+
return (React__default["default"].createElement(material.Grow, { unmountOnExit: true, in: (!!column.getFilterValue() && !isRangeFilter) ||
|
|
1631
|
+
(isRangeFilter && // @ts-ignore
|
|
1578
1632
|
(!!((_b = column.getFilterValue()) === null || _b === void 0 ? void 0 : _b[0]) || !!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[1]))) },
|
|
1579
1633
|
React__default["default"].createElement("span", null,
|
|
1580
1634
|
React__default["default"].createElement(material.Tooltip, { arrow: true, placement: "top", title: filterTooltip },
|
|
@@ -1591,7 +1645,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1591
1645
|
};
|
|
1592
1646
|
|
|
1593
1647
|
const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
1594
|
-
const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps
|
|
1648
|
+
const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
|
1595
1649
|
const { columnDef } = column;
|
|
1596
1650
|
const { hoveredColumn, draggingColumn, columnOrder } = getState();
|
|
1597
1651
|
const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
|
|
@@ -1601,16 +1655,15 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
|
1601
1655
|
? columnDef.muiTableHeadCellDragHandleProps({ column, table })
|
|
1602
1656
|
: columnDef.muiTableHeadCellDragHandleProps;
|
|
1603
1657
|
const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
|
|
1604
|
-
const handleDragStart = (
|
|
1658
|
+
const handleDragStart = (event) => {
|
|
1659
|
+
var _a;
|
|
1660
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1605
1661
|
setDraggingColumn(column);
|
|
1606
|
-
|
|
1662
|
+
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
|
1607
1663
|
};
|
|
1608
1664
|
const handleDragEnd = (event) => {
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
draggedColumn: column,
|
|
1612
|
-
targetColumn: hoveredColumn,
|
|
1613
|
-
});
|
|
1665
|
+
var _a;
|
|
1666
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1614
1667
|
if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1615
1668
|
column.toggleGrouping();
|
|
1616
1669
|
}
|
|
@@ -1678,7 +1731,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1678
1731
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1679
1732
|
var _a, _b, _c, _d;
|
|
1680
1733
|
const theme = material.useTheme();
|
|
1681
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering,
|
|
1734
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1682
1735
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
|
1683
1736
|
const { column } = header;
|
|
1684
1737
|
const { columnDef } = column;
|
|
@@ -1690,16 +1743,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1690
1743
|
? columnDef.muiTableHeadCellProps({ column, table })
|
|
1691
1744
|
: columnDef.muiTableHeadCellProps;
|
|
1692
1745
|
const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
|
|
1693
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
1694
|
-
return (column.getIsPinned() === 'left' &&
|
|
1695
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
1696
|
-
};
|
|
1697
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
1698
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
1699
|
-
};
|
|
1700
|
-
const getTotalRight = () => {
|
|
1701
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
1702
|
-
};
|
|
1703
1746
|
const handleDragEnter = (_e) => {
|
|
1704
1747
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1705
1748
|
setHoveredColumn(null);
|
|
@@ -1728,44 +1771,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1728
1771
|
})
|
|
1729
1772
|
: columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
|
|
1730
1773
|
const tableHeadCellRef = React__default["default"].useRef(null);
|
|
1731
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => {
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
?
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
:
|
|
1738
|
-
?
|
|
1739
|
-
:
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
? 0.
|
|
1743
|
-
:
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
? '0.25rem'
|
|
1759
|
-
: density === 'comfortable'
|
|
1760
|
-
? '.75rem'
|
|
1761
|
-
: '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1762
|
-
? 3
|
|
1763
|
-
: column.getIsPinned() && columnDefType !== 'group'
|
|
1764
|
-
? 2
|
|
1765
|
-
: 1 }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
1766
|
-
? tableCellProps.sx(theme)
|
|
1767
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), draggingBorders), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_a = columnDef.minSize) !== null && _a !== void 0 ? _a : 30}px)`, width: header.getSize() }));
|
|
1768
|
-
} }),
|
|
1774
|
+
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
|
|
1775
|
+
? '0.5rem'
|
|
1776
|
+
: density === 'comfortable'
|
|
1777
|
+
? columnDefType === 'display'
|
|
1778
|
+
? '0.75rem'
|
|
1779
|
+
: '1rem'
|
|
1780
|
+
: columnDefType === 'display'
|
|
1781
|
+
? '1rem 1.25rem'
|
|
1782
|
+
: '1.5rem', pb: columnDefType === 'display'
|
|
1783
|
+
? 0
|
|
1784
|
+
: showColumnFilters || density === 'compact'
|
|
1785
|
+
? '0.4rem'
|
|
1786
|
+
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
|
1787
|
+
? '0.25rem'
|
|
1788
|
+
: density === 'comfortable'
|
|
1789
|
+
? '.75rem'
|
|
1790
|
+
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1791
|
+
? 3
|
|
1792
|
+
: column.getIsPinned() && columnDefType !== 'group'
|
|
1793
|
+
? 2
|
|
1794
|
+
: 1 }, getCommonCellStyles({
|
|
1795
|
+
column,
|
|
1796
|
+
header,
|
|
1797
|
+
table,
|
|
1798
|
+
tableCellProps,
|
|
1799
|
+
theme,
|
|
1800
|
+
})), draggingBorders)) }),
|
|
1769
1801
|
header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { sx: {
|
|
1770
1802
|
alignItems: 'flex-start',
|
|
1771
1803
|
display: 'flex',
|
|
@@ -1820,11 +1852,13 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
|
|
1820
1852
|
};
|
|
1821
1853
|
|
|
1822
1854
|
const MRT_TableHead = ({ table }) => {
|
|
1823
|
-
const { getHeaderGroups, options: { muiTableHeadProps }, } = table;
|
|
1855
|
+
const { getHeaderGroups, options: { enableStickyHeader, muiTableHeadProps }, } = table;
|
|
1824
1856
|
const tableHeadProps = muiTableHeadProps instanceof Function
|
|
1825
1857
|
? muiTableHeadProps({ table })
|
|
1826
1858
|
: muiTableHeadProps;
|
|
1827
|
-
return (React__default["default"].createElement(material.TableHead, Object.assign({}, tableHeadProps
|
|
1859
|
+
return (React__default["default"].createElement(material.TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ opacity: enableStickyHeader ? 0.95 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
|
|
1860
|
+
? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
|
|
1861
|
+
: tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React__default["default"].createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
|
|
1828
1862
|
};
|
|
1829
1863
|
|
|
1830
1864
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
@@ -1920,28 +1954,27 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1920
1954
|
};
|
|
1921
1955
|
|
|
1922
1956
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
1923
|
-
const { options: { muiTableBodyRowDragHandleProps
|
|
1957
|
+
const { options: { muiTableBodyRowDragHandleProps }, } = table;
|
|
1924
1958
|
const { row } = cell;
|
|
1925
1959
|
const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
|
|
1926
1960
|
? muiTableBodyRowDragHandleProps({ row, table })
|
|
1927
1961
|
: muiTableBodyRowDragHandleProps;
|
|
1928
|
-
const handleDragStart = (
|
|
1929
|
-
|
|
1962
|
+
const handleDragStart = (event) => {
|
|
1963
|
+
var _a;
|
|
1964
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1965
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1930
1966
|
table.setDraggingRow(row);
|
|
1931
1967
|
};
|
|
1932
1968
|
const handleDragEnd = (event) => {
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
draggedRow: table.getState().draggingRow,
|
|
1936
|
-
targetRow: table.getState().hoveredRow,
|
|
1937
|
-
});
|
|
1969
|
+
var _a;
|
|
1970
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1938
1971
|
table.setDraggingRow(null);
|
|
1939
1972
|
table.setHoveredRow(null);
|
|
1940
1973
|
};
|
|
1941
1974
|
return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1942
1975
|
};
|
|
1943
1976
|
|
|
1944
|
-
const
|
|
1977
|
+
const _MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1945
1978
|
var _a, _b;
|
|
1946
1979
|
const { column, row } = cell;
|
|
1947
1980
|
const { columnDef } = column;
|
|
@@ -1963,6 +1996,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1963
1996
|
})
|
|
1964
1997
|
: (_b = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : cell.renderValue()));
|
|
1965
1998
|
};
|
|
1999
|
+
const MRT_TableBodyCellValue = React.memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
|
|
1966
2000
|
|
|
1967
2001
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1968
2002
|
var _a, _b;
|
|
@@ -1979,6 +2013,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1979
2013
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
1980
2014
|
: columnDef.muiTableBodyCellProps;
|
|
1981
2015
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
2016
|
+
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
2017
|
+
? muiTableBodyCellSkeletonProps({ cell, column, row, table })
|
|
2018
|
+
: muiTableBodyCellSkeletonProps;
|
|
1982
2019
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1983
2020
|
columnDef.enableEditing !== false;
|
|
1984
2021
|
const isEditing = isEditable &&
|
|
@@ -2009,16 +2046,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2009
2046
|
});
|
|
2010
2047
|
}
|
|
2011
2048
|
};
|
|
2012
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
2013
|
-
return (column.getIsPinned() === 'left' &&
|
|
2014
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
2015
|
-
};
|
|
2016
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
2017
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
2018
|
-
};
|
|
2019
|
-
const getTotalRight = () => {
|
|
2020
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
2021
|
-
};
|
|
2022
2049
|
const handleDragEnter = (e) => {
|
|
2023
2050
|
var _a;
|
|
2024
2051
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
|
@@ -2047,53 +2074,34 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2047
2074
|
: undefined,
|
|
2048
2075
|
}
|
|
2049
2076
|
: undefined;
|
|
2050
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
|
|
2056
|
-
: getIsFirstRightPinnedColumn()
|
|
2057
|
-
? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
|
|
2058
|
-
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2059
|
-
? `${column.getStart('left')}px`
|
|
2060
|
-
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2061
|
-
? 0.5
|
|
2062
|
-
: 1, overflow: 'hidden', p: density === 'compact'
|
|
2077
|
+
return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', overflow: 'hidden', p: density === 'compact'
|
|
2078
|
+
? columnDefType === 'display'
|
|
2079
|
+
? '0 0.5rem'
|
|
2080
|
+
: '0.5rem'
|
|
2081
|
+
: density === 'comfortable'
|
|
2063
2082
|
? columnDefType === 'display'
|
|
2064
|
-
? '0 0.
|
|
2065
|
-
: '
|
|
2066
|
-
:
|
|
2067
|
-
?
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
?
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
columnDef.enableEditing !== false &&
|
|
2087
|
-
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2088
|
-
? theme.palette.mode === 'dark'
|
|
2089
|
-
? `${material.lighten(theme.palette.background.default, 0.2)} !important`
|
|
2090
|
-
: `${material.darken(theme.palette.background.default, 0.1)} !important`
|
|
2091
|
-
: undefined,
|
|
2092
|
-
} }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2093
|
-
? tableCellProps.sx(theme)
|
|
2094
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), draggingBorders), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_a = columnDef.minSize) !== null && _a !== void 0 ? _a : 30}px)`, width: column.getSize() }));
|
|
2095
|
-
} }),
|
|
2096
|
-
React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(material.Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
|
|
2083
|
+
? '0.5rem 0.75rem'
|
|
2084
|
+
: '1rem'
|
|
2085
|
+
: columnDefType === 'display'
|
|
2086
|
+
? '1rem 1.25rem'
|
|
2087
|
+
: '1.5rem', pl: column.id === 'mrt-row-expand'
|
|
2088
|
+
? `${row.depth +
|
|
2089
|
+
(density === 'compact'
|
|
2090
|
+
? 0.5
|
|
2091
|
+
: density === 'comfortable'
|
|
2092
|
+
? 0.75
|
|
2093
|
+
: 1.25)}rem`
|
|
2094
|
+
: 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': {
|
|
2095
|
+
backgroundColor: enableHover &&
|
|
2096
|
+
enableEditing &&
|
|
2097
|
+
columnDef.enableEditing !== false &&
|
|
2098
|
+
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2099
|
+
? theme.palette.mode === 'dark'
|
|
2100
|
+
? `${material.lighten(theme.palette.background.default, 0.2)} !important`
|
|
2101
|
+
: `${material.darken(theme.palette.background.default, 0.1)} !important`
|
|
2102
|
+
: undefined,
|
|
2103
|
+
} }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
|
|
2104
|
+
React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(material.Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
|
2097
2105
|
rowNumberMode === 'static' &&
|
|
2098
2106
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React__default["default"].createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
|
2099
2107
|
(column.id === 'mrt-row-select' ||
|
|
@@ -2163,9 +2171,10 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2163
2171
|
renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2164
2172
|
};
|
|
2165
2173
|
|
|
2166
|
-
const MRT_TableBody = ({ table
|
|
2167
|
-
|
|
2168
|
-
const {
|
|
2174
|
+
const MRT_TableBody = ({ table }) => {
|
|
2175
|
+
var _a;
|
|
2176
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2177
|
+
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2169
2178
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2170
2179
|
? muiTableBodyProps({ table })
|
|
2171
2180
|
: muiTableBodyProps;
|
|
@@ -2230,7 +2239,18 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2230
2239
|
// ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
2231
2240
|
// : 0;
|
|
2232
2241
|
// }
|
|
2233
|
-
return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps),
|
|
2242
|
+
return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps), !rows.length ? (React__default["default"].createElement("tr", null,
|
|
2243
|
+
React__default["default"].createElement("td", { colSpan: table.getVisibleLeafColumns().length },
|
|
2244
|
+
React__default["default"].createElement(material.Typography, { sx: {
|
|
2245
|
+
color: 'text.secondary',
|
|
2246
|
+
fontStyle: 'italic',
|
|
2247
|
+
maxWidth: `min(100vw, ${(_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px)`,
|
|
2248
|
+
py: '2rem',
|
|
2249
|
+
textAlign: 'center',
|
|
2250
|
+
width: '100%',
|
|
2251
|
+
} }, globalFilter || columnFilters.length
|
|
2252
|
+
? localization.noResultsFound
|
|
2253
|
+
: localization.noRecordsToDisplay)))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2234
2254
|
enableRowVirtualization && paddingTop > 0 && (React__default["default"].createElement("tr", null,
|
|
2235
2255
|
React__default["default"].createElement("td", { style: { height: `${paddingTop}px` } }))),
|
|
2236
2256
|
(enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
|
@@ -2240,12 +2260,12 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2240
2260
|
return (React__default["default"].createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
|
|
2241
2261
|
}),
|
|
2242
2262
|
enableRowVirtualization && paddingBottom > 0 && (React__default["default"].createElement("tr", null,
|
|
2243
|
-
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))));
|
|
2263
|
+
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2244
2264
|
};
|
|
2245
2265
|
|
|
2246
2266
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2247
2267
|
var _a, _b, _c;
|
|
2248
|
-
const { getState, options: { muiTableFooterCellProps
|
|
2268
|
+
const { getState, options: { muiTableFooterCellProps }, } = table;
|
|
2249
2269
|
const { density } = getState();
|
|
2250
2270
|
const { column } = footer;
|
|
2251
2271
|
const { columnDef } = column;
|
|
@@ -2257,13 +2277,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
|
2257
2277
|
? columnDef.muiTableFooterCellProps({ column, table })
|
|
2258
2278
|
: columnDef.muiTableFooterCellProps;
|
|
2259
2279
|
const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
|
|
2260
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({
|
|
2280
|
+
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ fontWeight: 'bold', p: density === 'compact'
|
|
2261
2281
|
? '0.5rem'
|
|
2262
2282
|
: density === 'comfortable'
|
|
2263
2283
|
? '1rem'
|
|
2264
|
-
: '1.5rem',
|
|
2265
|
-
? tableCellProps.sx(theme)
|
|
2266
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
|
|
2284
|
+
: '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
|
|
2267
2285
|
React__default["default"].createElement(React__default["default"].Fragment, null, footer.isPlaceholder
|
|
2268
2286
|
? null
|
|
2269
2287
|
: (_c = (_b = (columnDef.Footer instanceof Function
|
|
@@ -2296,16 +2314,16 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2296
2314
|
? muiTableFooterProps({ table })
|
|
2297
2315
|
: muiTableFooterProps;
|
|
2298
2316
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
|
2299
|
-
return (React__default["default"].createElement(material.TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({
|
|
2317
|
+
return (React__default["default"].createElement(material.TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ backgroundColor: material.lighten(theme.palette.background.default, 0.06), bottom: stickFooter ? 0 : undefined, opacity: stickFooter ? 0.95 : undefined, outline: stickFooter
|
|
2300
2318
|
? theme.palette.mode === 'light'
|
|
2301
2319
|
? `1px solid ${theme.palette.grey[300]}`
|
|
2302
2320
|
: `1px solid ${theme.palette.grey[700]}`
|
|
2303
|
-
: undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
|
2321
|
+
: undefined, position: stickFooter ? 'sticky' : undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
|
2304
2322
|
? tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx(theme)
|
|
2305
2323
|
: tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React__default["default"].createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table })))));
|
|
2306
2324
|
};
|
|
2307
2325
|
|
|
2308
|
-
const MRT_Table = ({
|
|
2326
|
+
const MRT_Table = ({ table }) => {
|
|
2309
2327
|
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
|
|
2310
2328
|
const { isFullScreen } = getState();
|
|
2311
2329
|
const tableProps = muiTableProps instanceof Function
|
|
@@ -2315,7 +2333,7 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2315
2333
|
? tableProps.sx(theme)
|
|
2316
2334
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
|
2317
2335
|
enableTableHead && React__default["default"].createElement(MRT_TableHead, { table: table }),
|
|
2318
|
-
React__default["default"].createElement(MRT_TableBody, {
|
|
2336
|
+
React__default["default"].createElement(MRT_TableBody, { table: table }),
|
|
2319
2337
|
enableTableFooter && React__default["default"].createElement(MRT_TableFooter, { table: table })));
|
|
2320
2338
|
};
|
|
2321
2339
|
|
|
@@ -2350,31 +2368,42 @@ const MRT_TableContainer = ({ table }) => {
|
|
|
2350
2368
|
: tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx))), style: Object.assign({ maxHeight: isFullScreen
|
|
2351
2369
|
? `calc(100vh - ${totalToolbarHeight}px)`
|
|
2352
2370
|
: undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style) }),
|
|
2353
|
-
React__default["default"].createElement(MRT_Table, {
|
|
2371
|
+
React__default["default"].createElement(MRT_Table, { table: table })));
|
|
2354
2372
|
};
|
|
2355
2373
|
|
|
2356
2374
|
const MRT_TablePaper = ({ table }) => {
|
|
2357
|
-
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, } = table;
|
|
2375
|
+
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
|
|
2358
2376
|
const { isFullScreen } = getState();
|
|
2359
|
-
React.useEffect(() => {
|
|
2360
|
-
if (typeof window !== 'undefined') {
|
|
2361
|
-
if (isFullScreen) {
|
|
2362
|
-
document.body.style.height = '100vh';
|
|
2363
|
-
}
|
|
2364
|
-
else {
|
|
2365
|
-
document.body.style.height = 'auto';
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
}, [isFullScreen]);
|
|
2369
2377
|
const tablePaperProps = muiTablePaperProps instanceof Function
|
|
2370
2378
|
? muiTablePaperProps({ table })
|
|
2371
2379
|
: muiTablePaperProps;
|
|
2372
|
-
return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, {
|
|
2380
|
+
return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
|
|
2381
|
+
tablePaperRef.current = ref;
|
|
2382
|
+
if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
|
|
2383
|
+
//@ts-ignore
|
|
2384
|
+
tablePaperProps.ref.current = ref;
|
|
2385
|
+
}
|
|
2386
|
+
}, sx: (theme) => (Object.assign({ transition: 'all 0.2s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2373
2387
|
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2374
|
-
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style),
|
|
2375
|
-
|
|
2388
|
+
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
|
2389
|
+
? {
|
|
2390
|
+
height: '100vh',
|
|
2391
|
+
margin: 0,
|
|
2392
|
+
maxHeight: '100vh',
|
|
2393
|
+
maxWidth: '100vw',
|
|
2394
|
+
padding: 0,
|
|
2395
|
+
width: '100vw',
|
|
2396
|
+
}
|
|
2397
|
+
: {})) }),
|
|
2398
|
+
enableTopToolbar &&
|
|
2399
|
+
(renderTopToolbar instanceof Function
|
|
2400
|
+
? renderTopToolbar({ table })
|
|
2401
|
+
: renderTopToolbar !== null && renderTopToolbar !== void 0 ? renderTopToolbar : React__default["default"].createElement(MRT_TopToolbar, { table: table })),
|
|
2376
2402
|
React__default["default"].createElement(MRT_TableContainer, { table: table }),
|
|
2377
|
-
enableBottomToolbar &&
|
|
2403
|
+
enableBottomToolbar &&
|
|
2404
|
+
(renderBottomToolbar instanceof Function
|
|
2405
|
+
? renderBottomToolbar({ table })
|
|
2406
|
+
: renderBottomToolbar !== null && renderBottomToolbar !== void 0 ? renderBottomToolbar : React__default["default"].createElement(MRT_BottomToolbar, { table: table }))));
|
|
2378
2407
|
};
|
|
2379
2408
|
|
|
2380
2409
|
const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
@@ -2402,6 +2431,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2402
2431
|
const filterInputRefs = React.useRef({});
|
|
2403
2432
|
const searchInputRef = React.useRef(null);
|
|
2404
2433
|
const tableContainerRef = React.useRef(null);
|
|
2434
|
+
const tablePaperRef = React.useRef(null);
|
|
2405
2435
|
const topToolbarRef = React.useRef(null);
|
|
2406
2436
|
const initialState = React.useMemo(() => {
|
|
2407
2437
|
var _a, _b;
|
|
@@ -2437,14 +2467,14 @@ const MRT_TableRoot = (props) => {
|
|
|
2437
2467
|
const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2438
2468
|
const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2439
2469
|
const displayColumns = React.useMemo(() => {
|
|
2440
|
-
var _a, _b, _c, _d, _e
|
|
2470
|
+
var _a, _b, _c, _d, _e;
|
|
2441
2471
|
return [
|
|
2442
|
-
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header:
|
|
2443
|
-
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header:
|
|
2472
|
+
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: props.localization.move, size: 60 }, props.defaultDisplayColumn), (_a = props.displayColumnDefOptions) === null || _a === void 0 ? void 0 : _a['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
|
2473
|
+
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: props.localization.actions, size: 70 }, props.defaultDisplayColumn), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2444
2474
|
columnOrder.includes('mrt-row-expand') &&
|
|
2445
|
-
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React__default["default"].createElement(MRT_ExpandAllButton, { table: table })) : null, header:
|
|
2446
|
-
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React__default["default"].createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header:
|
|
2447
|
-
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () =>
|
|
2475
|
+
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React__default["default"].createElement(MRT_ExpandAllButton, { table: table })) : null, header: props.localization.expand, size: 60 }, props.defaultDisplayColumn), (_c = props.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2476
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React__default["default"].createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2477
|
+
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => props.localization.rowNumber, header: props.localization.rowNumbers, size: 60 }, props.defaultDisplayColumn), (_e = props.displayColumnDefOptions) === null || _e === void 0 ? void 0 : _e['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2448
2478
|
].filter(Boolean);
|
|
2449
2479
|
}, [
|
|
2450
2480
|
columnOrder,
|
|
@@ -2522,29 +2552,48 @@ const MRT_TableRoot = (props) => {
|
|
|
2522
2552
|
filterInputRefs,
|
|
2523
2553
|
searchInputRef,
|
|
2524
2554
|
tableContainerRef,
|
|
2555
|
+
tablePaperRef,
|
|
2525
2556
|
topToolbarRef,
|
|
2526
2557
|
}, setColumnFilterFns: (_x = props.onFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns, setDensity: (_y = props.onDensityChange) !== null && _y !== void 0 ? _y : setDensity, setDraggingColumn: (_z = props.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn, setDraggingRow: (_0 = props.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow, setEditingCell: (_1 = props.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell, setEditingRow: (_2 = props.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow, setGlobalFilterFn: (_3 = props.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn, setHoveredColumn: (_4 = props.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn, setHoveredRow: (_5 = props.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow, setIsFullScreen: (_6 = props.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen, setShowAlertBanner: (_7 = props.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner, setShowFilters: (_8 = props.onShowFiltersChange) !== null && _8 !== void 0 ? _8 : setShowFilters, setShowGlobalFilter: (_9 = props.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter });
|
|
2527
2558
|
if (props.tableInstanceRef) {
|
|
2528
2559
|
props.tableInstanceRef.current = table;
|
|
2529
2560
|
}
|
|
2561
|
+
const initialBodyHeight = React.useRef();
|
|
2562
|
+
React.useEffect(() => {
|
|
2563
|
+
if (typeof window !== 'undefined') {
|
|
2564
|
+
initialBodyHeight.current = document.body.style.height;
|
|
2565
|
+
}
|
|
2566
|
+
}, []);
|
|
2567
|
+
React.useEffect(() => {
|
|
2568
|
+
if (typeof window !== 'undefined') {
|
|
2569
|
+
if (table.getState().isFullScreen) {
|
|
2570
|
+
document.body.style.height = '100vh';
|
|
2571
|
+
}
|
|
2572
|
+
else {
|
|
2573
|
+
document.body.style.height = initialBodyHeight.current;
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
}, [table.getState().isFullScreen]);
|
|
2530
2577
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2531
|
-
React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2578
|
+
React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
|
|
2532
2579
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2533
|
-
!isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
|
|
2580
|
+
!table.getState().isFullScreen && (React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2534
2581
|
editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2535
2582
|
};
|
|
2536
2583
|
|
|
2537
2584
|
var MaterialReactTable = (_a) => {
|
|
2538
2585
|
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, defaultDisplayColumn, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enablePinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, localization, positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'original', selectAllMode = 'all', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnResizeMode", "defaultColumn", "defaultDisplayColumn", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "localization", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
|
|
2539
|
-
return (React__default["default"].createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, defaultDisplayColumn: Object.assign({ columnDefType: 'display', enableClickToCopy: false, enableColumnActions: false, enableColumnDragging: false, enableColumnFilter: false, enableColumnOrdering: false, enableEditing: false, enableGlobalFilter: false, enableGrouping: false, enableHiding: false, enableResizing: false, enableSorting: false }, defaultDisplayColumn), editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: Object.assign(Object.assign({}, MRT_FilterFns), filterFns), icons: Object.assign(Object.assign({}, MRT_Default_Icons), icons), localization: Object.assign(Object.assign({},
|
|
2586
|
+
return (React__default["default"].createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, defaultDisplayColumn: Object.assign({ columnDefType: 'display', enableClickToCopy: false, enableColumnActions: false, enableColumnDragging: false, enableColumnFilter: false, enableColumnOrdering: false, enableEditing: false, enableGlobalFilter: false, enableGrouping: false, enableHiding: false, enableResizing: false, enableSorting: false }, defaultDisplayColumn), editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: Object.assign(Object.assign({}, MRT_FilterFns), filterFns), icons: Object.assign(Object.assign({}, MRT_Default_Icons), icons), localization: Object.assign(Object.assign({}, MRT_Localization_EN), localization), positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: Object.assign(Object.assign({}, MRT_SortingFns), sortingFns) }, rest)));
|
|
2540
2587
|
};
|
|
2541
2588
|
|
|
2542
2589
|
exports.MRT_CopyButton = MRT_CopyButton;
|
|
2543
2590
|
exports.MRT_FullScreenToggleButton = MRT_FullScreenToggleButton;
|
|
2544
2591
|
exports.MRT_GlobalFilterTextField = MRT_GlobalFilterTextField;
|
|
2545
2592
|
exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
|
|
2593
|
+
exports.MRT_TablePagination = MRT_TablePagination;
|
|
2546
2594
|
exports.MRT_ToggleDensePaddingButton = MRT_ToggleDensePaddingButton;
|
|
2547
2595
|
exports.MRT_ToggleFiltersButton = MRT_ToggleFiltersButton;
|
|
2548
2596
|
exports.MRT_ToggleGlobalFilterButton = MRT_ToggleGlobalFilterButton;
|
|
2597
|
+
exports.MRT_ToolbarInternalButtons = MRT_ToolbarInternalButtons;
|
|
2549
2598
|
exports["default"] = MaterialReactTable;
|
|
2550
2599
|
//# sourceMappingURL=index.js.map
|