material-react-table 1.0.0-beta.0 → 1.0.0-beta.11
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 +20 -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 +247 -194
- 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 +248 -197
- 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 +13 -5
- package/src/inputs/MRT_GlobalFilterTextField.tsx +18 -5
- 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 +9 -3
- package/src/toolbar/MRT_TablePagination.tsx +8 -5
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +7 -1
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -4
- package/src/toolbar/MRT_TopToolbar.tsx +8 -1
- 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;
|
|
@@ -1010,6 +1051,9 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1010
1051
|
var _a;
|
|
1011
1052
|
const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
1012
1053
|
const { globalFilter, showGlobalFilter } = getState();
|
|
1054
|
+
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1055
|
+
? muiSearchTextFieldProps({ table })
|
|
1056
|
+
: muiSearchTextFieldProps;
|
|
1013
1057
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
1014
1058
|
const [searchValue, setSearchValue] = React.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
|
1015
1059
|
const handleChangeDebounced = React.useCallback(material.debounce((event) => {
|
|
@@ -1027,9 +1071,11 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1027
1071
|
setSearchValue('');
|
|
1028
1072
|
setGlobalFilter(undefined);
|
|
1029
1073
|
};
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1074
|
+
React.useEffect(() => {
|
|
1075
|
+
if (globalFilter === undefined) {
|
|
1076
|
+
handleClear();
|
|
1077
|
+
}
|
|
1078
|
+
}, [globalFilter]);
|
|
1033
1079
|
return (React__default["default"].createElement(material.Collapse, { in: showGlobalFilter, orientation: "horizontal", unmountOnExit: true, mountOnEnter: true },
|
|
1034
1080
|
React__default["default"].createElement(material.TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
|
|
1035
1081
|
startAdornment: enableGlobalFilterModes ? (React__default["default"].createElement(material.InputAdornment, { position: "start" },
|
|
@@ -1047,7 +1093,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1047
1093
|
textFieldProps.inputRef = inputRef;
|
|
1048
1094
|
}
|
|
1049
1095
|
} })),
|
|
1050
|
-
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1096
|
+
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table, onSelect: handleClear })));
|
|
1051
1097
|
};
|
|
1052
1098
|
|
|
1053
1099
|
const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
@@ -1065,7 +1111,7 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
|
1065
1111
|
React__default["default"].createElement(material.LinearProgress, Object.assign({ "aria-label": "Loading", "aria-busy": "true", sx: { position: 'relative' } }, linearProgressProps))));
|
|
1066
1112
|
};
|
|
1067
1113
|
|
|
1068
|
-
const MRT_TablePagination = ({ table, position }) => {
|
|
1114
|
+
const MRT_TablePagination = ({ table, position, }) => {
|
|
1069
1115
|
const { getPrePaginationRowModel, getState, setPageIndex, setPageSize, options: { muiTablePaginationProps, enableToolbarInternalActions, rowCount, }, } = table;
|
|
1070
1116
|
const { pagination: { pageSize = 10, pageIndex = 0 }, showGlobalFilter, } = getState();
|
|
1071
1117
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
|
@@ -1083,14 +1129,14 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1083
1129
|
enableToolbarInternalActions &&
|
|
1084
1130
|
!showGlobalFilter
|
|
1085
1131
|
? '3.5rem'
|
|
1086
|
-
:
|
|
1132
|
+
: undefined, position: 'relative', zIndex: 2 }, ((tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx) instanceof Function
|
|
1087
1133
|
? tablePaginationProps.sx(theme)
|
|
1088
1134
|
: tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx))) })));
|
|
1089
1135
|
};
|
|
1090
1136
|
|
|
1091
1137
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
1092
1138
|
var _a, _b;
|
|
1093
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
|
|
1139
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
|
|
1094
1140
|
const { grouping, showAlertBanner } = getState();
|
|
1095
1141
|
const alertProps = muiToolbarAlertBannerProps instanceof Function
|
|
1096
1142
|
? muiToolbarAlertBannerProps({ table })
|
|
@@ -1108,7 +1154,11 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1108
1154
|
index > 0 ? localization.thenBy : '',
|
|
1109
1155
|
React__default["default"].createElement(material.Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
|
|
1110
1156
|
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',
|
|
1157
|
+
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
|
|
1158
|
+
? 0
|
|
1159
|
+
: positionToolbarAlertBanner === 'bottom'
|
|
1160
|
+
? '-1rem'
|
|
1161
|
+
: undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
|
|
1112
1162
|
? alertProps.sx(theme)
|
|
1113
1163
|
: alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))) }),
|
|
1114
1164
|
(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && React__default["default"].createElement(material.AlertTitle, null, alertProps.title),
|
|
@@ -1180,16 +1230,16 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
|
1180
1230
|
var _b;
|
|
1181
1231
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1182
1232
|
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1183
|
-
const { showGlobalFilter } = getState();
|
|
1233
|
+
const { globalFilter, showGlobalFilter } = getState();
|
|
1184
1234
|
const handleToggleSearch = () => {
|
|
1185
1235
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1186
1236
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1187
1237
|
};
|
|
1188
1238
|
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))));
|
|
1239
|
+
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
1240
|
};
|
|
1191
1241
|
|
|
1192
|
-
const MRT_ToolbarInternalButtons = ({ table }) => {
|
|
1242
|
+
const MRT_ToolbarInternalButtons = ({ table, }) => {
|
|
1193
1243
|
var _a;
|
|
1194
1244
|
const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, enablePinning, initialState, renderToolbarInternalActions, }, } = table;
|
|
1195
1245
|
return (React__default["default"].createElement(material.Box, { sx: {
|
|
@@ -1237,6 +1287,7 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1237
1287
|
backgroundColor: material.lighten(theme.palette.background.default, 0.04),
|
|
1238
1288
|
backgroundImage: 'none',
|
|
1239
1289
|
display: 'grid',
|
|
1290
|
+
flexWrap: 'wrap-reverse',
|
|
1240
1291
|
minHeight: '3.5rem',
|
|
1241
1292
|
overflow: 'hidden',
|
|
1242
1293
|
p: '0 !important',
|
|
@@ -1275,7 +1326,11 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1275
1326
|
width: '100%',
|
|
1276
1327
|
} },
|
|
1277
1328
|
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),
|
|
1278
|
-
enableToolbarInternalActions ? (React__default["default"].createElement(material.Box, { sx: {
|
|
1329
|
+
enableToolbarInternalActions ? (React__default["default"].createElement(material.Box, { sx: {
|
|
1330
|
+
display: 'flex',
|
|
1331
|
+
flexWrap: 'wrap-reverse',
|
|
1332
|
+
justifyContent: 'flex-end',
|
|
1333
|
+
} },
|
|
1279
1334
|
enableGlobalFilter && positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })),
|
|
1280
1335
|
React__default["default"].createElement(MRT_ToolbarInternalButtons, { table: table }))) : (enableGlobalFilter &&
|
|
1281
1336
|
positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })))),
|
|
@@ -1298,14 +1353,14 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1298
1353
|
// @ts-ignore
|
|
1299
1354
|
toolbarProps.ref.current = ref;
|
|
1300
1355
|
}
|
|
1301
|
-
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow:
|
|
1356
|
+
}, 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
|
|
1302
1357
|
? toolbarProps.sx(theme)
|
|
1303
1358
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1304
1359
|
React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
1305
|
-
positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { table: table })),
|
|
1360
|
+
positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
1306
1361
|
['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React__default["default"].createElement(MRT_ToolbarDropZone, { table: table })),
|
|
1307
1362
|
React__default["default"].createElement(material.Box, { sx: {
|
|
1308
|
-
alignItems: '
|
|
1363
|
+
alignItems: 'center',
|
|
1309
1364
|
boxSizing: 'border-box',
|
|
1310
1365
|
display: 'flex',
|
|
1311
1366
|
justifyContent: 'space-between',
|
|
@@ -1454,8 +1509,10 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1454
1509
|
setAnchorEl(event.currentTarget);
|
|
1455
1510
|
};
|
|
1456
1511
|
React.useEffect(() => {
|
|
1457
|
-
|
|
1458
|
-
|
|
1512
|
+
if (column.getFilterValue() === undefined) {
|
|
1513
|
+
handleClear();
|
|
1514
|
+
}
|
|
1515
|
+
}, [column.getFilterValue()]);
|
|
1459
1516
|
if (columnDef.Filter) {
|
|
1460
1517
|
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 }));
|
|
1461
1518
|
}
|
|
@@ -1513,7 +1570,11 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1513
1570
|
if (textFieldProps.inputRef) {
|
|
1514
1571
|
textFieldProps.inputRef = inputRef;
|
|
1515
1572
|
}
|
|
1516
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth:
|
|
1573
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: columnDef.filterVariant === 'range'
|
|
1574
|
+
? '90px'
|
|
1575
|
+
: !filterChipLabel
|
|
1576
|
+
? '120px'
|
|
1577
|
+
: 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1517
1578
|
mr: '1.5rem',
|
|
1518
1579
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1519
1580
|
? textFieldProps.sx(theme)
|
|
@@ -1541,7 +1602,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1541
1602
|
isMultiSelectFilter && (React__default["default"].createElement(material.Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })),
|
|
1542
1603
|
text));
|
|
1543
1604
|
})),
|
|
1544
|
-
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1605
|
+
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table, setFilterValue: setFilterValue })));
|
|
1545
1606
|
};
|
|
1546
1607
|
|
|
1547
1608
|
const MRT_FilterRangeFields = ({ header, table }) => {
|
|
@@ -1563,11 +1624,8 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1563
1624
|
const { options: { icons: { FilterAltIcon }, localization, }, } = table;
|
|
1564
1625
|
const { column } = header;
|
|
1565
1626
|
const { columnDef } = column;
|
|
1566
|
-
const isRangeFilter =
|
|
1567
|
-
'between',
|
|
1568
|
-
'betweenInclusive',
|
|
1569
|
-
'inNumberRange',
|
|
1570
|
-
].includes(columnDef._filterFn);
|
|
1627
|
+
const isRangeFilter = columnDef.filterVariant === 'range' ||
|
|
1628
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
|
|
1571
1629
|
const currentFilterOption = columnDef._filterFn;
|
|
1572
1630
|
const filterTooltip = localization.filteringByColumn
|
|
1573
1631
|
.replace('{column}', String(columnDef.header))
|
|
@@ -1579,8 +1637,8 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1579
1637
|
? column.getFilterValue().join(`" ${isRangeFilter ? localization.and : localization.or} "`)
|
|
1580
1638
|
: column.getFilterValue()}"`)
|
|
1581
1639
|
.replace('" "', '');
|
|
1582
|
-
return (React__default["default"].createElement(material.Grow, { unmountOnExit: true, in: (!!column.getFilterValue() && isRangeFilter) ||
|
|
1583
|
-
(
|
|
1640
|
+
return (React__default["default"].createElement(material.Grow, { unmountOnExit: true, in: (!!column.getFilterValue() && !isRangeFilter) ||
|
|
1641
|
+
(isRangeFilter && // @ts-ignore
|
|
1584
1642
|
(!!((_b = column.getFilterValue()) === null || _b === void 0 ? void 0 : _b[0]) || !!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[1]))) },
|
|
1585
1643
|
React__default["default"].createElement("span", null,
|
|
1586
1644
|
React__default["default"].createElement(material.Tooltip, { arrow: true, placement: "top", title: filterTooltip },
|
|
@@ -1597,7 +1655,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1597
1655
|
};
|
|
1598
1656
|
|
|
1599
1657
|
const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
1600
|
-
const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps
|
|
1658
|
+
const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
|
1601
1659
|
const { columnDef } = column;
|
|
1602
1660
|
const { hoveredColumn, draggingColumn, columnOrder } = getState();
|
|
1603
1661
|
const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
|
|
@@ -1607,16 +1665,15 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
|
1607
1665
|
? columnDef.muiTableHeadCellDragHandleProps({ column, table })
|
|
1608
1666
|
: columnDef.muiTableHeadCellDragHandleProps;
|
|
1609
1667
|
const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
|
|
1610
|
-
const handleDragStart = (
|
|
1668
|
+
const handleDragStart = (event) => {
|
|
1669
|
+
var _a;
|
|
1670
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1611
1671
|
setDraggingColumn(column);
|
|
1612
|
-
|
|
1672
|
+
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
|
1613
1673
|
};
|
|
1614
1674
|
const handleDragEnd = (event) => {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
draggedColumn: column,
|
|
1618
|
-
targetColumn: hoveredColumn,
|
|
1619
|
-
});
|
|
1675
|
+
var _a;
|
|
1676
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1620
1677
|
if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1621
1678
|
column.toggleGrouping();
|
|
1622
1679
|
}
|
|
@@ -1684,7 +1741,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1684
1741
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1685
1742
|
var _a, _b, _c, _d;
|
|
1686
1743
|
const theme = material.useTheme();
|
|
1687
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering,
|
|
1744
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1688
1745
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
|
1689
1746
|
const { column } = header;
|
|
1690
1747
|
const { columnDef } = column;
|
|
@@ -1696,16 +1753,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1696
1753
|
? columnDef.muiTableHeadCellProps({ column, table })
|
|
1697
1754
|
: columnDef.muiTableHeadCellProps;
|
|
1698
1755
|
const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
|
|
1699
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
1700
|
-
return (column.getIsPinned() === 'left' &&
|
|
1701
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
1702
|
-
};
|
|
1703
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
1704
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
1705
|
-
};
|
|
1706
|
-
const getTotalRight = () => {
|
|
1707
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
1708
|
-
};
|
|
1709
1756
|
const handleDragEnter = (_e) => {
|
|
1710
1757
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1711
1758
|
setHoveredColumn(null);
|
|
@@ -1734,44 +1781,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1734
1781
|
})
|
|
1735
1782
|
: columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
|
|
1736
1783
|
const tableHeadCellRef = React__default["default"].useRef(null);
|
|
1737
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
?
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
:
|
|
1744
|
-
?
|
|
1745
|
-
:
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
? 0.
|
|
1749
|
-
:
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
? '0.25rem'
|
|
1765
|
-
: density === 'comfortable'
|
|
1766
|
-
? '.75rem'
|
|
1767
|
-
: '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
|
|
1768
|
-
? 3
|
|
1769
|
-
: column.getIsPinned() && columnDefType !== 'group'
|
|
1770
|
-
? 2
|
|
1771
|
-
: 1 }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
1772
|
-
? tableCellProps.sx(theme)
|
|
1773
|
-
: 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() }));
|
|
1774
|
-
} }),
|
|
1784
|
+
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'
|
|
1785
|
+
? '0.5rem'
|
|
1786
|
+
: density === 'comfortable'
|
|
1787
|
+
? columnDefType === 'display'
|
|
1788
|
+
? '0.75rem'
|
|
1789
|
+
: '1rem'
|
|
1790
|
+
: columnDefType === 'display'
|
|
1791
|
+
? '1rem 1.25rem'
|
|
1792
|
+
: '1.5rem', pb: columnDefType === 'display'
|
|
1793
|
+
? 0
|
|
1794
|
+
: showColumnFilters || density === 'compact'
|
|
1795
|
+
? '0.4rem'
|
|
1796
|
+
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
|
1797
|
+
? '0.25rem'
|
|
1798
|
+
: density === 'comfortable'
|
|
1799
|
+
? '.75rem'
|
|
1800
|
+
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1801
|
+
? 3
|
|
1802
|
+
: column.getIsPinned() && columnDefType !== 'group'
|
|
1803
|
+
? 2
|
|
1804
|
+
: 1 }, getCommonCellStyles({
|
|
1805
|
+
column,
|
|
1806
|
+
header,
|
|
1807
|
+
table,
|
|
1808
|
+
tableCellProps,
|
|
1809
|
+
theme,
|
|
1810
|
+
})), draggingBorders)) }),
|
|
1775
1811
|
header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { sx: {
|
|
1776
1812
|
alignItems: 'flex-start',
|
|
1777
1813
|
display: 'flex',
|
|
@@ -1826,11 +1862,13 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
|
|
1826
1862
|
};
|
|
1827
1863
|
|
|
1828
1864
|
const MRT_TableHead = ({ table }) => {
|
|
1829
|
-
const { getHeaderGroups, options: { muiTableHeadProps }, } = table;
|
|
1865
|
+
const { getHeaderGroups, options: { enableStickyHeader, muiTableHeadProps }, } = table;
|
|
1830
1866
|
const tableHeadProps = muiTableHeadProps instanceof Function
|
|
1831
1867
|
? muiTableHeadProps({ table })
|
|
1832
1868
|
: muiTableHeadProps;
|
|
1833
|
-
return (React__default["default"].createElement(material.TableHead, Object.assign({}, tableHeadProps
|
|
1869
|
+
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
|
|
1870
|
+
? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
|
|
1871
|
+
: 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 })))));
|
|
1834
1872
|
};
|
|
1835
1873
|
|
|
1836
1874
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
@@ -1926,28 +1964,27 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1926
1964
|
};
|
|
1927
1965
|
|
|
1928
1966
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
1929
|
-
const { options: { muiTableBodyRowDragHandleProps
|
|
1967
|
+
const { options: { muiTableBodyRowDragHandleProps }, } = table;
|
|
1930
1968
|
const { row } = cell;
|
|
1931
1969
|
const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
|
|
1932
1970
|
? muiTableBodyRowDragHandleProps({ row, table })
|
|
1933
1971
|
: muiTableBodyRowDragHandleProps;
|
|
1934
|
-
const handleDragStart = (
|
|
1935
|
-
|
|
1972
|
+
const handleDragStart = (event) => {
|
|
1973
|
+
var _a;
|
|
1974
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1975
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1936
1976
|
table.setDraggingRow(row);
|
|
1937
1977
|
};
|
|
1938
1978
|
const handleDragEnd = (event) => {
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
draggedRow: table.getState().draggingRow,
|
|
1942
|
-
targetRow: table.getState().hoveredRow,
|
|
1943
|
-
});
|
|
1979
|
+
var _a;
|
|
1980
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1944
1981
|
table.setDraggingRow(null);
|
|
1945
1982
|
table.setHoveredRow(null);
|
|
1946
1983
|
};
|
|
1947
1984
|
return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1948
1985
|
};
|
|
1949
1986
|
|
|
1950
|
-
const
|
|
1987
|
+
const _MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1951
1988
|
var _a, _b;
|
|
1952
1989
|
const { column, row } = cell;
|
|
1953
1990
|
const { columnDef } = column;
|
|
@@ -1969,6 +2006,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1969
2006
|
})
|
|
1970
2007
|
: (_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()));
|
|
1971
2008
|
};
|
|
2009
|
+
const MRT_TableBodyCellValue = React.memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
|
|
1972
2010
|
|
|
1973
2011
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1974
2012
|
var _a, _b;
|
|
@@ -1985,6 +2023,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1985
2023
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
1986
2024
|
: columnDef.muiTableBodyCellProps;
|
|
1987
2025
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
2026
|
+
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
2027
|
+
? muiTableBodyCellSkeletonProps({ cell, column, row, table })
|
|
2028
|
+
: muiTableBodyCellSkeletonProps;
|
|
1988
2029
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1989
2030
|
columnDef.enableEditing !== false;
|
|
1990
2031
|
const isEditing = isEditable &&
|
|
@@ -2015,16 +2056,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2015
2056
|
});
|
|
2016
2057
|
}
|
|
2017
2058
|
};
|
|
2018
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
2019
|
-
return (column.getIsPinned() === 'left' &&
|
|
2020
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
2021
|
-
};
|
|
2022
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
2023
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
2024
|
-
};
|
|
2025
|
-
const getTotalRight = () => {
|
|
2026
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
2027
|
-
};
|
|
2028
2059
|
const handleDragEnter = (e) => {
|
|
2029
2060
|
var _a;
|
|
2030
2061
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
|
@@ -2053,53 +2084,34 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2053
2084
|
: undefined,
|
|
2054
2085
|
}
|
|
2055
2086
|
: undefined;
|
|
2056
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
|
|
2062
|
-
: getIsFirstRightPinnedColumn()
|
|
2063
|
-
? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
|
|
2064
|
-
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2065
|
-
? `${column.getStart('left')}px`
|
|
2066
|
-
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2067
|
-
? 0.5
|
|
2068
|
-
: 1, overflow: 'hidden', p: density === 'compact'
|
|
2087
|
+
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'
|
|
2088
|
+
? columnDefType === 'display'
|
|
2089
|
+
? '0 0.5rem'
|
|
2090
|
+
: '0.5rem'
|
|
2091
|
+
: density === 'comfortable'
|
|
2069
2092
|
? columnDefType === 'display'
|
|
2070
|
-
? '0 0.
|
|
2071
|
-
: '
|
|
2072
|
-
:
|
|
2073
|
-
?
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
?
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
columnDef.enableEditing !== false &&
|
|
2093
|
-
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2094
|
-
? theme.palette.mode === 'dark'
|
|
2095
|
-
? `${material.lighten(theme.palette.background.default, 0.2)} !important`
|
|
2096
|
-
: `${material.darken(theme.palette.background.default, 0.1)} !important`
|
|
2097
|
-
: undefined,
|
|
2098
|
-
} }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2099
|
-
? tableCellProps.sx(theme)
|
|
2100
|
-
: 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() }));
|
|
2101
|
-
} }),
|
|
2102
|
-
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 &&
|
|
2093
|
+
? '0.5rem 0.75rem'
|
|
2094
|
+
: '1rem'
|
|
2095
|
+
: columnDefType === 'display'
|
|
2096
|
+
? '1rem 1.25rem'
|
|
2097
|
+
: '1.5rem', pl: column.id === 'mrt-row-expand'
|
|
2098
|
+
? `${row.depth +
|
|
2099
|
+
(density === 'compact'
|
|
2100
|
+
? 0.5
|
|
2101
|
+
: density === 'comfortable'
|
|
2102
|
+
? 0.75
|
|
2103
|
+
: 1.25)}rem`
|
|
2104
|
+
: 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': {
|
|
2105
|
+
backgroundColor: enableHover &&
|
|
2106
|
+
enableEditing &&
|
|
2107
|
+
columnDef.enableEditing !== false &&
|
|
2108
|
+
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2109
|
+
? theme.palette.mode === 'dark'
|
|
2110
|
+
? `${material.lighten(theme.palette.background.default, 0.2)} !important`
|
|
2111
|
+
: `${material.darken(theme.palette.background.default, 0.1)} !important`
|
|
2112
|
+
: undefined,
|
|
2113
|
+
} }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
|
|
2114
|
+
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 &&
|
|
2103
2115
|
rowNumberMode === 'static' &&
|
|
2104
2116
|
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' &&
|
|
2105
2117
|
(column.id === 'mrt-row-select' ||
|
|
@@ -2169,9 +2181,10 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2169
2181
|
renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2170
2182
|
};
|
|
2171
2183
|
|
|
2172
|
-
const MRT_TableBody = ({ table
|
|
2173
|
-
|
|
2174
|
-
const {
|
|
2184
|
+
const MRT_TableBody = ({ table }) => {
|
|
2185
|
+
var _a;
|
|
2186
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
|
|
2187
|
+
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2175
2188
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2176
2189
|
? muiTableBodyProps({ table })
|
|
2177
2190
|
: muiTableBodyProps;
|
|
@@ -2236,7 +2249,18 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2236
2249
|
// ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
2237
2250
|
// : 0;
|
|
2238
2251
|
// }
|
|
2239
|
-
return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps),
|
|
2252
|
+
return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps), !rows.length ? (React__default["default"].createElement("tr", null,
|
|
2253
|
+
React__default["default"].createElement("td", { colSpan: table.getVisibleLeafColumns().length },
|
|
2254
|
+
React__default["default"].createElement(material.Typography, { sx: {
|
|
2255
|
+
color: 'text.secondary',
|
|
2256
|
+
fontStyle: 'italic',
|
|
2257
|
+
maxWidth: `min(100vw, ${(_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px)`,
|
|
2258
|
+
py: '2rem',
|
|
2259
|
+
textAlign: 'center',
|
|
2260
|
+
width: '100%',
|
|
2261
|
+
} }, globalFilter || columnFilters.length
|
|
2262
|
+
? localization.noResultsFound
|
|
2263
|
+
: localization.noRecordsToDisplay)))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2240
2264
|
enableRowVirtualization && paddingTop > 0 && (React__default["default"].createElement("tr", null,
|
|
2241
2265
|
React__default["default"].createElement("td", { style: { height: `${paddingTop}px` } }))),
|
|
2242
2266
|
(enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
|
@@ -2246,12 +2270,12 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2246
2270
|
return (React__default["default"].createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
|
|
2247
2271
|
}),
|
|
2248
2272
|
enableRowVirtualization && paddingBottom > 0 && (React__default["default"].createElement("tr", null,
|
|
2249
|
-
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))));
|
|
2273
|
+
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2250
2274
|
};
|
|
2251
2275
|
|
|
2252
2276
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2253
2277
|
var _a, _b, _c;
|
|
2254
|
-
const { getState, options: { muiTableFooterCellProps
|
|
2278
|
+
const { getState, options: { muiTableFooterCellProps }, } = table;
|
|
2255
2279
|
const { density } = getState();
|
|
2256
2280
|
const { column } = footer;
|
|
2257
2281
|
const { columnDef } = column;
|
|
@@ -2263,13 +2287,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
|
2263
2287
|
? columnDef.muiTableFooterCellProps({ column, table })
|
|
2264
2288
|
: columnDef.muiTableFooterCellProps;
|
|
2265
2289
|
const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
|
|
2266
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({
|
|
2290
|
+
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'
|
|
2267
2291
|
? '0.5rem'
|
|
2268
2292
|
: density === 'comfortable'
|
|
2269
2293
|
? '1rem'
|
|
2270
|
-
: '1.5rem',
|
|
2271
|
-
? tableCellProps.sx(theme)
|
|
2272
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
|
|
2294
|
+
: '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
|
|
2273
2295
|
React__default["default"].createElement(React__default["default"].Fragment, null, footer.isPlaceholder
|
|
2274
2296
|
? null
|
|
2275
2297
|
: (_c = (_b = (columnDef.Footer instanceof Function
|
|
@@ -2302,16 +2324,16 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2302
2324
|
? muiTableFooterProps({ table })
|
|
2303
2325
|
: muiTableFooterProps;
|
|
2304
2326
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
|
2305
|
-
return (React__default["default"].createElement(material.TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({
|
|
2327
|
+
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
|
|
2306
2328
|
? theme.palette.mode === 'light'
|
|
2307
2329
|
? `1px solid ${theme.palette.grey[300]}`
|
|
2308
2330
|
: `1px solid ${theme.palette.grey[700]}`
|
|
2309
|
-
: undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
|
2331
|
+
: undefined, position: stickFooter ? 'sticky' : undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
|
2310
2332
|
? tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx(theme)
|
|
2311
2333
|
: 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 })))));
|
|
2312
2334
|
};
|
|
2313
2335
|
|
|
2314
|
-
const MRT_Table = ({
|
|
2336
|
+
const MRT_Table = ({ table }) => {
|
|
2315
2337
|
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
|
|
2316
2338
|
const { isFullScreen } = getState();
|
|
2317
2339
|
const tableProps = muiTableProps instanceof Function
|
|
@@ -2321,7 +2343,7 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2321
2343
|
? tableProps.sx(theme)
|
|
2322
2344
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
|
2323
2345
|
enableTableHead && React__default["default"].createElement(MRT_TableHead, { table: table }),
|
|
2324
|
-
React__default["default"].createElement(MRT_TableBody, {
|
|
2346
|
+
React__default["default"].createElement(MRT_TableBody, { table: table }),
|
|
2325
2347
|
enableTableFooter && React__default["default"].createElement(MRT_TableFooter, { table: table })));
|
|
2326
2348
|
};
|
|
2327
2349
|
|
|
@@ -2356,31 +2378,42 @@ const MRT_TableContainer = ({ table }) => {
|
|
|
2356
2378
|
: tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx))), style: Object.assign({ maxHeight: isFullScreen
|
|
2357
2379
|
? `calc(100vh - ${totalToolbarHeight}px)`
|
|
2358
2380
|
: undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style) }),
|
|
2359
|
-
React__default["default"].createElement(MRT_Table, {
|
|
2381
|
+
React__default["default"].createElement(MRT_Table, { table: table })));
|
|
2360
2382
|
};
|
|
2361
2383
|
|
|
2362
2384
|
const MRT_TablePaper = ({ table }) => {
|
|
2363
|
-
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, } = table;
|
|
2385
|
+
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
|
|
2364
2386
|
const { isFullScreen } = getState();
|
|
2365
|
-
React.useEffect(() => {
|
|
2366
|
-
if (typeof window !== 'undefined') {
|
|
2367
|
-
if (isFullScreen) {
|
|
2368
|
-
document.body.style.height = '100vh';
|
|
2369
|
-
}
|
|
2370
|
-
else {
|
|
2371
|
-
document.body.style.height = 'auto';
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
}, [isFullScreen]);
|
|
2375
2387
|
const tablePaperProps = muiTablePaperProps instanceof Function
|
|
2376
2388
|
? muiTablePaperProps({ table })
|
|
2377
2389
|
: muiTablePaperProps;
|
|
2378
|
-
return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, {
|
|
2390
|
+
return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
|
|
2391
|
+
tablePaperRef.current = ref;
|
|
2392
|
+
if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
|
|
2393
|
+
//@ts-ignore
|
|
2394
|
+
tablePaperProps.ref.current = ref;
|
|
2395
|
+
}
|
|
2396
|
+
}, sx: (theme) => (Object.assign({ transition: 'all 0.2s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2379
2397
|
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2380
|
-
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style),
|
|
2381
|
-
|
|
2398
|
+
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
|
2399
|
+
? {
|
|
2400
|
+
height: '100vh',
|
|
2401
|
+
margin: 0,
|
|
2402
|
+
maxHeight: '100vh',
|
|
2403
|
+
maxWidth: '100vw',
|
|
2404
|
+
padding: 0,
|
|
2405
|
+
width: '100vw',
|
|
2406
|
+
}
|
|
2407
|
+
: {})) }),
|
|
2408
|
+
enableTopToolbar &&
|
|
2409
|
+
(renderTopToolbar instanceof Function
|
|
2410
|
+
? renderTopToolbar({ table })
|
|
2411
|
+
: renderTopToolbar !== null && renderTopToolbar !== void 0 ? renderTopToolbar : React__default["default"].createElement(MRT_TopToolbar, { table: table })),
|
|
2382
2412
|
React__default["default"].createElement(MRT_TableContainer, { table: table }),
|
|
2383
|
-
enableBottomToolbar &&
|
|
2413
|
+
enableBottomToolbar &&
|
|
2414
|
+
(renderBottomToolbar instanceof Function
|
|
2415
|
+
? renderBottomToolbar({ table })
|
|
2416
|
+
: renderBottomToolbar !== null && renderBottomToolbar !== void 0 ? renderBottomToolbar : React__default["default"].createElement(MRT_BottomToolbar, { table: table }))));
|
|
2384
2417
|
};
|
|
2385
2418
|
|
|
2386
2419
|
const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
@@ -2408,6 +2441,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2408
2441
|
const filterInputRefs = React.useRef({});
|
|
2409
2442
|
const searchInputRef = React.useRef(null);
|
|
2410
2443
|
const tableContainerRef = React.useRef(null);
|
|
2444
|
+
const tablePaperRef = React.useRef(null);
|
|
2411
2445
|
const topToolbarRef = React.useRef(null);
|
|
2412
2446
|
const initialState = React.useMemo(() => {
|
|
2413
2447
|
var _a, _b;
|
|
@@ -2443,14 +2477,14 @@ const MRT_TableRoot = (props) => {
|
|
|
2443
2477
|
const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2444
2478
|
const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2445
2479
|
const displayColumns = React.useMemo(() => {
|
|
2446
|
-
var _a, _b, _c, _d, _e
|
|
2480
|
+
var _a, _b, _c, _d, _e;
|
|
2447
2481
|
return [
|
|
2448
|
-
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header:
|
|
2449
|
-
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:
|
|
2482
|
+
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' }),
|
|
2483
|
+
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' }),
|
|
2450
2484
|
columnOrder.includes('mrt-row-expand') &&
|
|
2451
|
-
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:
|
|
2452
|
-
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:
|
|
2453
|
-
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () =>
|
|
2485
|
+
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' }),
|
|
2486
|
+
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' }),
|
|
2487
|
+
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' }),
|
|
2454
2488
|
].filter(Boolean);
|
|
2455
2489
|
}, [
|
|
2456
2490
|
columnOrder,
|
|
@@ -2528,29 +2562,48 @@ const MRT_TableRoot = (props) => {
|
|
|
2528
2562
|
filterInputRefs,
|
|
2529
2563
|
searchInputRef,
|
|
2530
2564
|
tableContainerRef,
|
|
2565
|
+
tablePaperRef,
|
|
2531
2566
|
topToolbarRef,
|
|
2532
2567
|
}, 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 });
|
|
2533
2568
|
if (props.tableInstanceRef) {
|
|
2534
2569
|
props.tableInstanceRef.current = table;
|
|
2535
2570
|
}
|
|
2571
|
+
const initialBodyHeight = React.useRef();
|
|
2572
|
+
React.useEffect(() => {
|
|
2573
|
+
if (typeof window !== 'undefined') {
|
|
2574
|
+
initialBodyHeight.current = document.body.style.height;
|
|
2575
|
+
}
|
|
2576
|
+
}, []);
|
|
2577
|
+
React.useEffect(() => {
|
|
2578
|
+
if (typeof window !== 'undefined') {
|
|
2579
|
+
if (table.getState().isFullScreen) {
|
|
2580
|
+
document.body.style.height = '100vh';
|
|
2581
|
+
}
|
|
2582
|
+
else {
|
|
2583
|
+
document.body.style.height = initialBodyHeight.current;
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
}, [table.getState().isFullScreen]);
|
|
2536
2587
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2537
|
-
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 },
|
|
2588
|
+
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 },
|
|
2538
2589
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2539
|
-
!isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
|
|
2590
|
+
!table.getState().isFullScreen && (React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2540
2591
|
editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2541
2592
|
};
|
|
2542
2593
|
|
|
2543
2594
|
var MaterialReactTable = (_a) => {
|
|
2544
2595
|
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"]);
|
|
2545
|
-
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({},
|
|
2596
|
+
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)));
|
|
2546
2597
|
};
|
|
2547
2598
|
|
|
2548
2599
|
exports.MRT_CopyButton = MRT_CopyButton;
|
|
2549
2600
|
exports.MRT_FullScreenToggleButton = MRT_FullScreenToggleButton;
|
|
2550
2601
|
exports.MRT_GlobalFilterTextField = MRT_GlobalFilterTextField;
|
|
2551
2602
|
exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
|
|
2603
|
+
exports.MRT_TablePagination = MRT_TablePagination;
|
|
2552
2604
|
exports.MRT_ToggleDensePaddingButton = MRT_ToggleDensePaddingButton;
|
|
2553
2605
|
exports.MRT_ToggleFiltersButton = MRT_ToggleFiltersButton;
|
|
2554
2606
|
exports.MRT_ToggleGlobalFilterButton = MRT_ToggleGlobalFilterButton;
|
|
2607
|
+
exports.MRT_ToolbarInternalButtons = MRT_ToolbarInternalButtons;
|
|
2555
2608
|
exports["default"] = MaterialReactTable;
|
|
2556
2609
|
//# sourceMappingURL=index.js.map
|