material-react-table 0.36.2 → 0.37.2
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 +7 -3
- package/dist/cjs/MaterialReactTable.d.ts +34 -15
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/cjs/buttons/MRT_CopyButton.d.ts +5 -5
- package/dist/cjs/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/cjs/column.utils.d.ts +2 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +172 -122
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +34 -15
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/esm/buttons/MRT_CopyButton.d.ts +5 -5
- package/dist/esm/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/esm/column.utils.d.ts +2 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +172 -123
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +42 -16
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +49 -11
- package/src/body/MRT_EditRowModal.tsx +21 -19
- package/src/body/MRT_TableBodyCell.tsx +12 -26
- package/src/body/MRT_TableBodyCellValue.tsx +27 -0
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
- package/src/buttons/MRT_CopyButton.tsx +11 -7
- package/src/buttons/MRT_EditActionButtons.tsx +13 -4
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +9 -4
- package/src/column.utils.ts +15 -10
- package/src/head/MRT_TableHeadCell.tsx +3 -5
- package/src/index.tsx +2 -0
- package/src/inputs/MRT_EditCellTextField.tsx +16 -5
- package/src/inputs/MRT_FilterTextField.tsx +9 -6
- package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +2 -12
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TableRoot.tsx +45 -27
- package/src/toolbar/MRT_BottomToolbar.tsx +9 -5
- package/src/toolbar/MRT_TopToolbar.tsx +8 -2
package/dist/cjs/index.js
CHANGED
|
@@ -508,10 +508,9 @@ const prepareColumns = (columnDefs, columnFilterFns, filterFns, sortingFns) => c
|
|
|
508
508
|
else if (columnDef.columnDefType === 'data') {
|
|
509
509
|
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
510
510
|
columnDef.filterFn =
|
|
511
|
-
// @ts-ignore
|
|
512
511
|
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
513
|
-
|
|
514
|
-
|
|
512
|
+
columnDef._filterFn =
|
|
513
|
+
columnFilterFns[columnDef.id];
|
|
515
514
|
}
|
|
516
515
|
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
517
516
|
// @ts-ignore
|
|
@@ -530,6 +529,9 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
|
530
529
|
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
531
530
|
return [...columnOrder];
|
|
532
531
|
};
|
|
532
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
533
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
534
|
+
props.renderDetailPanel);
|
|
533
535
|
const getLeadingDisplayColumnIds = (props) => {
|
|
534
536
|
var _a;
|
|
535
537
|
return [
|
|
@@ -539,9 +541,7 @@ const getLeadingDisplayColumnIds = (props) => {
|
|
|
539
541
|
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
540
542
|
'mrt-row-actions',
|
|
541
543
|
props.positionExpandColumn === 'first' &&
|
|
542
|
-
(props
|
|
543
|
-
props.enableGrouping ||
|
|
544
|
-
props.renderDetailPanel) &&
|
|
544
|
+
showExpandColumn(props) &&
|
|
545
545
|
'mrt-row-expand',
|
|
546
546
|
props.enableRowSelection && 'mrt-row-select',
|
|
547
547
|
props.enableRowNumbers && 'mrt-row-numbers',
|
|
@@ -555,9 +555,7 @@ const getTrailingDisplayColumnIds = (props) => {
|
|
|
555
555
|
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
556
556
|
'mrt-row-actions',
|
|
557
557
|
props.positionExpandColumn === 'last' &&
|
|
558
|
-
(props
|
|
559
|
-
props.enableGrouping ||
|
|
560
|
-
props.renderDetailPanel) &&
|
|
558
|
+
showExpandColumn(props) &&
|
|
561
559
|
'mrt-row-expand',
|
|
562
560
|
];
|
|
563
561
|
};
|
|
@@ -712,7 +710,7 @@ const commonListItemStyles = {
|
|
|
712
710
|
};
|
|
713
711
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
714
712
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
715
|
-
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterChangeMode, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, columnFilterModeOptions, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, },
|
|
713
|
+
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterChangeMode, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, columnFilterModeOptions, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, }, refs: { filterInputRefs }, setShowFilters, } = table;
|
|
716
714
|
const { column } = header;
|
|
717
715
|
const { columnDef } = column;
|
|
718
716
|
const { columnSizing, columnVisibility, density } = getState();
|
|
@@ -753,13 +751,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
753
751
|
};
|
|
754
752
|
const handleFilterByColumn = () => {
|
|
755
753
|
setShowFilters(true);
|
|
756
|
-
|
|
757
|
-
var _a, _b, _c;
|
|
758
|
-
return (_c = document
|
|
759
|
-
.getElementById(
|
|
760
|
-
// @ts-ignore
|
|
761
|
-
(_b = (_a = header.muiTableHeadCellFilterTextFieldProps) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : `mrt-${tableId}-${header.id}-filter-text-field`)) === null || _c === void 0 ? void 0 : _c.focus();
|
|
762
|
-
}, 200);
|
|
754
|
+
queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
763
755
|
setAnchorEl(null);
|
|
764
756
|
};
|
|
765
757
|
const handleShowAllColumns = () => {
|
|
@@ -890,19 +882,25 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
|
|
|
890
882
|
};
|
|
891
883
|
|
|
892
884
|
const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
|
893
|
-
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
|
|
885
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, refs: { editInputRefs }, setEditingRow, } = table;
|
|
894
886
|
const { editingRow } = getState();
|
|
895
|
-
const handleCancel = () =>
|
|
896
|
-
setEditingRow(null);
|
|
897
|
-
};
|
|
887
|
+
const handleCancel = () => setEditingRow(null);
|
|
898
888
|
const handleSave = () => {
|
|
899
|
-
var _a;
|
|
889
|
+
var _a, _b;
|
|
890
|
+
//look for auto-filled input values
|
|
891
|
+
(_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
|
|
892
|
+
if (input.value !== undefined &&
|
|
893
|
+
Object.hasOwn(editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache, input.name)) {
|
|
894
|
+
// @ts-ignore
|
|
895
|
+
editingRow._valuesCache[input.name] = input.value;
|
|
896
|
+
}
|
|
897
|
+
});
|
|
900
898
|
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
899
|
+
exitEditingMode: () => setEditingRow(null),
|
|
901
900
|
row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
|
|
902
901
|
table,
|
|
903
|
-
values: (
|
|
902
|
+
values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
|
|
904
903
|
});
|
|
905
|
-
setEditingRow(null);
|
|
906
904
|
};
|
|
907
905
|
return (React__default["default"].createElement(material.Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
908
906
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.cancel },
|
|
@@ -925,7 +923,7 @@ const commonIconButtonStyles = {
|
|
|
925
923
|
opacity: 1,
|
|
926
924
|
},
|
|
927
925
|
};
|
|
928
|
-
const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
926
|
+
const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
929
927
|
const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
930
928
|
const { editingRow } = getState();
|
|
931
929
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
@@ -938,8 +936,8 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
|
938
936
|
setEditingRow(Object.assign({}, row));
|
|
939
937
|
setAnchorEl(null);
|
|
940
938
|
};
|
|
941
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions ? (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React__default["default"].createElement(material.Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
942
|
-
React__default["default"].createElement(material.IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
939
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions ? (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions({ cell, row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React__default["default"].createElement(material.Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
940
|
+
React__default["default"].createElement(material.IconButton, { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
943
941
|
React__default["default"].createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
944
942
|
React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
|
|
945
943
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles },
|
|
@@ -973,7 +971,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
973
971
|
|
|
974
972
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
975
973
|
var _a;
|
|
976
|
-
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps,
|
|
974
|
+
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
977
975
|
const { globalFilter, showGlobalFilter } = getState();
|
|
978
976
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
979
977
|
const [searchValue, setSearchValue] = React.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
|
@@ -996,7 +994,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
996
994
|
? muiSearchTextFieldProps({ table })
|
|
997
995
|
: muiSearchTextFieldProps;
|
|
998
996
|
return (React__default["default"].createElement(material.Collapse, { in: showGlobalFilter, orientation: "horizontal" },
|
|
999
|
-
React__default["default"].createElement(material.TextField, Object.assign({
|
|
997
|
+
React__default["default"].createElement(material.TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
|
|
1000
998
|
startAdornment: enableGlobalFilterChangeMode ? (React__default["default"].createElement(material.InputAdornment, { position: "start" },
|
|
1001
999
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.changeSearchMode },
|
|
1002
1000
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' } },
|
|
@@ -1006,7 +1004,12 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1006
1004
|
React__default["default"].createElement("span", null,
|
|
1007
1005
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small" },
|
|
1008
1006
|
React__default["default"].createElement(CloseIcon, null)))))),
|
|
1009
|
-
} }, textFieldProps)
|
|
1007
|
+
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1008
|
+
searchInputRef.current = inputRef;
|
|
1009
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
|
|
1010
|
+
textFieldProps.inputRef = inputRef;
|
|
1011
|
+
}
|
|
1012
|
+
} })),
|
|
1010
1013
|
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1011
1014
|
};
|
|
1012
1015
|
|
|
@@ -1131,18 +1134,11 @@ const MRT_ToggleFiltersButton = (_a) => {
|
|
|
1131
1134
|
|
|
1132
1135
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
1133
1136
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1134
|
-
const { getState, options: { icons: { SearchIcon, SearchOffIcon },
|
|
1137
|
+
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1135
1138
|
const { showGlobalFilter } = getState();
|
|
1136
|
-
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1137
|
-
? muiSearchTextFieldProps({ table })
|
|
1138
|
-
: muiSearchTextFieldProps;
|
|
1139
1139
|
const handleToggleSearch = () => {
|
|
1140
1140
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1141
|
-
|
|
1142
|
-
var _a, _b;
|
|
1143
|
-
return (_b = document
|
|
1144
|
-
.getElementById((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.id) !== null && _a !== void 0 ? _a : `mrt-${tableId}-search-text-field`)) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1145
|
-
}, 200);
|
|
1141
|
+
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1146
1142
|
};
|
|
1147
1143
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.showHideSearch },
|
|
1148
1144
|
React__default["default"].createElement(material.IconButton, Object.assign({ onClick: handleToggleSearch }, rest), showGlobalFilter ? React__default["default"].createElement(SearchOffIcon, null) : React__default["default"].createElement(SearchIcon, null))));
|
|
@@ -1201,14 +1197,20 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1201
1197
|
});
|
|
1202
1198
|
const MRT_TopToolbar = ({ table }) => {
|
|
1203
1199
|
var _a;
|
|
1204
|
-
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions,
|
|
1200
|
+
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
|
1205
1201
|
const { isFullScreen, showGlobalFilter } = getState();
|
|
1206
1202
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1207
1203
|
const toolbarProps = muiTableTopToolbarProps instanceof Function
|
|
1208
1204
|
? muiTableTopToolbarProps({ table })
|
|
1209
1205
|
: muiTableTopToolbarProps;
|
|
1210
1206
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
1211
|
-
return (React__default["default"].createElement(material.Toolbar, Object.assign({
|
|
1207
|
+
return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1208
|
+
topToolbarRef.current = ref;
|
|
1209
|
+
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
1210
|
+
// @ts-ignore
|
|
1211
|
+
toolbarProps.ref.current = ref;
|
|
1212
|
+
}
|
|
1213
|
+
}, sx: (theme) => (Object.assign(Object.assign({ position: isFullScreen ? 'sticky' : undefined, top: isFullScreen ? '0' : undefined }, commonToolbarStyles({ theme })), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
|
|
1212
1214
|
? toolbarProps.sx(theme)
|
|
1213
1215
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1214
1216
|
positionToolbarAlertBanner === 'top' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
@@ -1233,14 +1235,20 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1233
1235
|
};
|
|
1234
1236
|
|
|
1235
1237
|
const MRT_BottomToolbar = ({ table }) => {
|
|
1236
|
-
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions,
|
|
1238
|
+
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
|
1237
1239
|
const { isFullScreen } = getState();
|
|
1238
1240
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1239
1241
|
const toolbarProps = muiTableBottomToolbarProps instanceof Function
|
|
1240
1242
|
? muiTableBottomToolbarProps({ table })
|
|
1241
1243
|
: muiTableBottomToolbarProps;
|
|
1242
1244
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
1243
|
-
return (React__default["default"].createElement(material.Toolbar, Object.assign({
|
|
1245
|
+
return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1246
|
+
bottomToolbarRef.current = ref;
|
|
1247
|
+
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
1248
|
+
// @ts-ignore
|
|
1249
|
+
toolbarProps.ref.current = ref;
|
|
1250
|
+
}
|
|
1251
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `-3px 0 6px ${material.alpha(theme.palette.common.black, 0.1)}`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
|
|
1244
1252
|
? toolbarProps.sx(theme)
|
|
1245
1253
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1246
1254
|
React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
@@ -1251,7 +1259,7 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1251
1259
|
justifyContent: 'space-between',
|
|
1252
1260
|
width: '100%',
|
|
1253
1261
|
} },
|
|
1254
|
-
renderBottomToolbarCustomActions ? (
|
|
1262
|
+
renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (React__default["default"].createElement("span", null)),
|
|
1255
1263
|
React__default["default"].createElement(material.Box, { sx: {
|
|
1256
1264
|
display: 'flex',
|
|
1257
1265
|
justifyContent: 'flex-end',
|
|
@@ -1295,7 +1303,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1295
1303
|
|
|
1296
1304
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1297
1305
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1298
|
-
const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps,
|
|
1306
|
+
const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
|
1299
1307
|
const { column } = header;
|
|
1300
1308
|
const { columnDef } = column;
|
|
1301
1309
|
const { columnFilterFns } = getState();
|
|
@@ -1320,7 +1328,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1320
1328
|
const isTextboxFilter = columnDef.filterVariant === 'text' ||
|
|
1321
1329
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
1322
1330
|
const currentFilterOption = columnFilterFns === null || columnFilterFns === void 0 ? void 0 : columnFilterFns[header.id];
|
|
1323
|
-
const filterId = `mrt-${tableId}-${header.id}-filter-text-field${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : ''}`;
|
|
1324
1331
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
|
1325
1332
|
? //@ts-ignore
|
|
1326
1333
|
localization[`filter${((_b = (_a = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _a === void 0 ? void 0 : _a.call(currentFilterOption, 0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
|
@@ -1397,14 +1404,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1397
1404
|
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 }));
|
|
1398
1405
|
}
|
|
1399
1406
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1400
|
-
React__default["default"].createElement(material.TextField, Object.assign({ fullWidth: true,
|
|
1407
|
+
React__default["default"].createElement(material.TextField, Object.assign({ fullWidth: true, inputProps: {
|
|
1401
1408
|
disabled: !!filterChipLabel,
|
|
1402
1409
|
sx: {
|
|
1403
1410
|
textOverflow: 'ellipsis',
|
|
1404
1411
|
width: filterChipLabel ? 0 : undefined,
|
|
1405
1412
|
},
|
|
1406
1413
|
title: filterPlaceholder,
|
|
1407
|
-
}, helperText: showChangeModeButton ? (React__default["default"].createElement("label",
|
|
1414
|
+
}, helperText: showChangeModeButton ? (React__default["default"].createElement("label", null, localization.filterMode.replace('{filterType}',
|
|
1408
1415
|
// @ts-ignore
|
|
1409
1416
|
localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
|
|
1410
1417
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
|
|
@@ -1436,7 +1443,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1436
1443
|
renderValue: isMultiSelectFilter
|
|
1437
1444
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (React__default["default"].createElement(material.Box, { sx: { opacity: 0.5 } }, filterPlaceholder)) : (React__default["default"].createElement(material.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' } }, selected === null || selected === void 0 ? void 0 : selected.map((value) => (React__default["default"].createElement(material.Chip, { key: value, label: value })))))
|
|
1438
1445
|
: undefined,
|
|
1439
|
-
} }, textFieldProps, {
|
|
1446
|
+
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1447
|
+
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
|
1448
|
+
inputRef;
|
|
1449
|
+
if (textFieldProps.inputRef) {
|
|
1450
|
+
textFieldProps.inputRef = inputRef;
|
|
1451
|
+
}
|
|
1452
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1440
1453
|
mr: '1.5rem',
|
|
1441
1454
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1442
1455
|
? textFieldProps.sx(theme)
|
|
@@ -1628,7 +1641,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1628
1641
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1629
1642
|
setHoveredColumn(null);
|
|
1630
1643
|
}
|
|
1631
|
-
if (enableColumnOrdering && draggingColumn) {
|
|
1644
|
+
if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
|
|
1632
1645
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
1633
1646
|
}
|
|
1634
1647
|
};
|
|
@@ -1678,13 +1691,11 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1678
1691
|
? '0.4rem'
|
|
1679
1692
|
: '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
|
|
1680
1693
|
? 'sticky'
|
|
1681
|
-
: undefined, pt: columnDefType === 'group'
|
|
1682
|
-
? 0
|
|
1683
|
-
: density === '
|
|
1684
|
-
? '
|
|
1685
|
-
:
|
|
1686
|
-
? '.75rem'
|
|
1687
|
-
: '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
|
|
1694
|
+
: undefined, pt: columnDefType === 'group' || density === 'compact'
|
|
1695
|
+
? '0.25rem'
|
|
1696
|
+
: density === 'comfortable'
|
|
1697
|
+
? '.75rem'
|
|
1698
|
+
: '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
|
|
1688
1699
|
? 3
|
|
1689
1700
|
: column.getIsPinned() && columnDefType !== 'group'
|
|
1690
1701
|
? 2
|
|
@@ -1750,17 +1761,19 @@ const MRT_TableHead = ({ table }) => {
|
|
|
1750
1761
|
|
|
1751
1762
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
1752
1763
|
var _a;
|
|
1753
|
-
const { getState, options: {
|
|
1754
|
-
const { column } = cell;
|
|
1764
|
+
const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
|
|
1765
|
+
const { column, row } = cell;
|
|
1755
1766
|
const { columnDef } = column;
|
|
1756
1767
|
const { editingRow } = getState();
|
|
1757
1768
|
const [value, setValue] = React.useState(() => cell.getValue());
|
|
1758
1769
|
const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1759
|
-
? muiTableBodyCellEditTextFieldProps({ cell, table })
|
|
1770
|
+
? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
|
|
1760
1771
|
: muiTableBodyCellEditTextFieldProps;
|
|
1761
1772
|
const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1762
1773
|
? columnDef.muiTableBodyCellEditTextFieldProps({
|
|
1763
1774
|
cell,
|
|
1775
|
+
column,
|
|
1776
|
+
row,
|
|
1764
1777
|
table,
|
|
1765
1778
|
})
|
|
1766
1779
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
@@ -1779,14 +1792,21 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1779
1792
|
setEditingCell(null);
|
|
1780
1793
|
};
|
|
1781
1794
|
if (columnDef.Edit) {
|
|
1782
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table }));
|
|
1795
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1783
1796
|
}
|
|
1784
|
-
return (React__default["default"].createElement(material.TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true,
|
|
1797
|
+
return (React__default["default"].createElement(material.TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: cell.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
|
|
1798
|
+
if (inputRef) {
|
|
1799
|
+
editInputRefs.current[column.id] = inputRef;
|
|
1800
|
+
if (textFieldProps.inputRef) {
|
|
1801
|
+
textFieldProps.inputRef = inputRef;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1785
1805
|
};
|
|
1786
1806
|
|
|
1787
|
-
const MRT_CopyButton = ({ cell, children, table }) => {
|
|
1807
|
+
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
1788
1808
|
const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
|
|
1789
|
-
const { column } = cell;
|
|
1809
|
+
const { column, row } = cell;
|
|
1790
1810
|
const { columnDef } = column;
|
|
1791
1811
|
const [copied, setCopied] = React.useState(false);
|
|
1792
1812
|
const handleCopy = (text) => {
|
|
@@ -1795,7 +1815,7 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1795
1815
|
setTimeout(() => setCopied(false), 4000);
|
|
1796
1816
|
};
|
|
1797
1817
|
const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
|
|
1798
|
-
? muiTableBodyCellCopyButtonProps({ cell, table })
|
|
1818
|
+
? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
|
|
1799
1819
|
: muiTableBodyCellCopyButtonProps;
|
|
1800
1820
|
const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
|
|
1801
1821
|
? columnDef.muiTableBodyCellCopyButtonProps({
|
|
@@ -1812,12 +1832,13 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1812
1832
|
|
|
1813
1833
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
1814
1834
|
const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
|
|
1835
|
+
const { row } = cell;
|
|
1815
1836
|
const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
|
|
1816
|
-
? muiTableBodyRowDragHandleProps({ row
|
|
1837
|
+
? muiTableBodyRowDragHandleProps({ row, table })
|
|
1817
1838
|
: muiTableBodyRowDragHandleProps;
|
|
1818
1839
|
const handleDragStart = (e) => {
|
|
1819
1840
|
e.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1820
|
-
table.setDraggingRow(
|
|
1841
|
+
table.setDraggingRow(row);
|
|
1821
1842
|
};
|
|
1822
1843
|
const handleDragEnd = (event) => {
|
|
1823
1844
|
onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
|
|
@@ -1831,16 +1852,32 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1831
1852
|
return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1832
1853
|
};
|
|
1833
1854
|
|
|
1855
|
+
const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1856
|
+
var _a, _b, _c;
|
|
1857
|
+
const { column, row } = cell;
|
|
1858
|
+
const { columnDef } = column;
|
|
1859
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsAggregated() && column.columnDef.aggregationFn
|
|
1860
|
+
? (_a = columnDef.AggregatedCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
|
|
1861
|
+
cell,
|
|
1862
|
+
column,
|
|
1863
|
+
row,
|
|
1864
|
+
table,
|
|
1865
|
+
})
|
|
1866
|
+
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
1867
|
+
? null
|
|
1868
|
+
: (_c = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table })) !== null && _c !== void 0 ? _c : cell.renderValue()));
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1834
1871
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1835
|
-
var _a, _b
|
|
1872
|
+
var _a, _b;
|
|
1836
1873
|
const theme = material.useTheme();
|
|
1837
|
-
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode,
|
|
1874
|
+
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
|
1838
1875
|
const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
|
|
1839
1876
|
const { column, row } = cell;
|
|
1840
1877
|
const { columnDef } = column;
|
|
1841
1878
|
const { columnDefType } = columnDef;
|
|
1842
1879
|
const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
|
|
1843
|
-
? muiTableBodyCellProps({ cell, table })
|
|
1880
|
+
? muiTableBodyCellProps({ cell, column, row, table })
|
|
1844
1881
|
: muiTableBodyCellProps;
|
|
1845
1882
|
const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
|
|
1846
1883
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
@@ -1865,13 +1902,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1865
1902
|
columnDef.enableEditing !== false &&
|
|
1866
1903
|
editingMode === 'cell') {
|
|
1867
1904
|
setEditingCell(cell);
|
|
1868
|
-
|
|
1869
|
-
const textField =
|
|
1905
|
+
queueMicrotask(() => {
|
|
1906
|
+
const textField = editInputRefs.current[column.id];
|
|
1870
1907
|
if (textField) {
|
|
1871
1908
|
textField.focus();
|
|
1872
1909
|
textField.select();
|
|
1873
1910
|
}
|
|
1874
|
-
}
|
|
1911
|
+
});
|
|
1875
1912
|
}
|
|
1876
1913
|
};
|
|
1877
1914
|
const getIsLastLeftPinnedColumn = () => {
|
|
@@ -1961,22 +1998,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1961
1998
|
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' &&
|
|
1962
1999
|
(column.id === 'mrt-row-select' ||
|
|
1963
2000
|
column.id === 'mrt-row-expand' ||
|
|
1964
|
-
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table })) : isEditing ? (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
1965
|
-
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(
|
|
1966
|
-
React__default["default"].createElement(
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
|
1972
|
-
_d.length,
|
|
1973
|
-
")"))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1974
|
-
row.getIsGrouped() && !cell.getIsGrouped()
|
|
1975
|
-
? null
|
|
1976
|
-
: (_g = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _f === void 0 ? void 0 : _f.call(columnDef, { cell, column, table })) !== null && _g !== void 0 ? _g : cell.renderValue(),
|
|
1977
|
-
cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1978
|
-
" (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
|
|
1979
|
-
")"))))));
|
|
2001
|
+
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
2002
|
+
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
|
|
2003
|
+
React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
|
|
2004
|
+
cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2005
|
+
" (", (_b = row.subRows) === null || _b === void 0 ? void 0 :
|
|
2006
|
+
_b.length,
|
|
2007
|
+
")")));
|
|
1980
2008
|
};
|
|
1981
2009
|
|
|
1982
2010
|
const MRT_TableDetailPanel = ({ row, table }) => {
|
|
@@ -2026,7 +2054,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
|
2026
2054
|
: undefined,
|
|
2027
2055
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2028
2056
|
? tableRowProps.sx(theme)
|
|
2029
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => (React__default["default"].createElement(MRT_TableBodyCell, { cell: cell,
|
|
2057
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => (React__default["default"].createElement(MRT_TableBodyCell, { cell: cell, enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false, key: cell.id, rowIndex: rowIndex, rowRef: rowRef, table: table })))),
|
|
2030
2058
|
renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2031
2059
|
};
|
|
2032
2060
|
|
|
@@ -2174,25 +2202,29 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2174
2202
|
|
|
2175
2203
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
2176
2204
|
const MRT_TableContainer = ({ table }) => {
|
|
2177
|
-
|
|
2178
|
-
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, tableId, }, } = table;
|
|
2205
|
+
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
|
|
2179
2206
|
const { isFullScreen } = getState();
|
|
2180
2207
|
const [totalToolbarHeight, setTotalToolbarHeight] = React.useState(0);
|
|
2181
2208
|
const tableContainerProps = muiTableContainerProps instanceof Function
|
|
2182
2209
|
? muiTableContainerProps({ table })
|
|
2183
2210
|
: muiTableContainerProps;
|
|
2184
|
-
const tableContainerRef = (_a = tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) !== null && _a !== void 0 ? _a : React.useRef(null);
|
|
2185
2211
|
useIsomorphicLayoutEffect(() => {
|
|
2186
2212
|
var _a, _b, _c, _d;
|
|
2187
2213
|
const topToolbarHeight = typeof document !== 'undefined'
|
|
2188
|
-
? (_b = (_a =
|
|
2214
|
+
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
|
2189
2215
|
: 0;
|
|
2190
2216
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
|
2191
|
-
? (_d = (_c =
|
|
2217
|
+
? (_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
|
|
2192
2218
|
: 0;
|
|
2193
2219
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
|
2194
2220
|
});
|
|
2195
|
-
return (React__default["default"].createElement(material.TableContainer, Object.assign({
|
|
2221
|
+
return (React__default["default"].createElement(material.TableContainer, Object.assign({}, tableContainerProps, { ref: (ref) => {
|
|
2222
|
+
tableContainerRef.current = ref;
|
|
2223
|
+
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
|
2224
|
+
//@ts-ignore
|
|
2225
|
+
tableContainerProps.ref.current = ref;
|
|
2226
|
+
}
|
|
2227
|
+
}, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
|
|
2196
2228
|
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
|
2197
2229
|
: undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
|
|
2198
2230
|
? tableContainerProps.sx(theme)
|
|
@@ -2229,22 +2261,27 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
|
2229
2261
|
return (React__default["default"].createElement(material.Dialog, { open: open },
|
|
2230
2262
|
React__default["default"].createElement(material.DialogTitle, { textAlign: "center" }, localization.edit),
|
|
2231
2263
|
React__default["default"].createElement(material.DialogContent, null,
|
|
2232
|
-
React__default["default"].createElement(
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2264
|
+
React__default["default"].createElement("form", { onSubmit: (e) => e.preventDefault() },
|
|
2265
|
+
React__default["default"].createElement(material.Stack, { sx: {
|
|
2266
|
+
width: '100%',
|
|
2267
|
+
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
2268
|
+
gap: '1.5rem',
|
|
2269
|
+
} }, row
|
|
2270
|
+
.getAllCells()
|
|
2271
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
2272
|
+
.map((cell) => (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, key: cell.id, showLabel: true, table: table })))))),
|
|
2240
2273
|
React__default["default"].createElement(material.DialogActions, { sx: { p: '1.25rem' } },
|
|
2241
2274
|
React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table, variant: "text" }))));
|
|
2242
2275
|
};
|
|
2243
2276
|
|
|
2244
2277
|
const MRT_TableRoot = (props) => {
|
|
2245
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
2246
|
-
const
|
|
2247
|
-
|
|
2278
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
2279
|
+
const bottomToolbarRef = React.useRef(null);
|
|
2280
|
+
const editInputRefs = React.useRef({});
|
|
2281
|
+
const filterInputRefs = React.useRef({});
|
|
2282
|
+
const searchInputRef = React.useRef(null);
|
|
2283
|
+
const tableContainerRef = React.useRef(null);
|
|
2284
|
+
const topToolbarRef = React.useRef(null);
|
|
2248
2285
|
const initialState = React.useMemo(() => {
|
|
2249
2286
|
var _a, _b;
|
|
2250
2287
|
const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
|
|
@@ -2271,23 +2308,26 @@ const MRT_TableRoot = (props) => {
|
|
|
2271
2308
|
const [editingCell, setEditingCell] = React.useState((_e = initialState.editingCell) !== null && _e !== void 0 ? _e : null);
|
|
2272
2309
|
const [editingRow, setEditingRow] = React.useState((_f = initialState.editingRow) !== null && _f !== void 0 ? _f : null);
|
|
2273
2310
|
const [globalFilterFn, setGlobalFilterFn] = React.useState((_g = initialState.globalFilterFn) !== null && _g !== void 0 ? _g : 'fuzzy');
|
|
2274
|
-
const [
|
|
2275
|
-
const [
|
|
2276
|
-
const [
|
|
2277
|
-
const [
|
|
2278
|
-
const [
|
|
2279
|
-
const [
|
|
2311
|
+
const [grouping, setGrouping] = React.useState((_h = initialState.grouping) !== null && _h !== void 0 ? _h : []);
|
|
2312
|
+
const [hoveredColumn, setHoveredColumn] = React.useState((_j = initialState.hoveredColumn) !== null && _j !== void 0 ? _j : null);
|
|
2313
|
+
const [hoveredRow, setHoveredRow] = React.useState((_k = initialState.hoveredRow) !== null && _k !== void 0 ? _k : null);
|
|
2314
|
+
const [isFullScreen, setIsFullScreen] = React.useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _l !== void 0 ? _l : false);
|
|
2315
|
+
const [showAlertBanner, setShowAlertBanner] = React.useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
|
|
2316
|
+
const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2317
|
+
const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2280
2318
|
const displayColumns = React.useMemo(() => {
|
|
2281
2319
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2282
2320
|
return [
|
|
2283
2321
|
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: (_a = props.localization) === null || _a === void 0 ? void 0 : _a.move, size: 60 }, defaultDisplayColumnDefOptions), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
|
2284
|
-
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, {
|
|
2285
|
-
columnOrder.includes('mrt-row-expand') &&
|
|
2286
|
-
|
|
2287
|
-
columnOrder.includes('mrt-row-
|
|
2322
|
+
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: (_c = props.localization) === null || _c === void 0 ? void 0 : _c.actions, size: 70 }, defaultDisplayColumnDefOptions), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2323
|
+
columnOrder.includes('mrt-row-expand') &&
|
|
2324
|
+
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: (_e = props.localization) === null || _e === void 0 ? void 0 : _e.expand, size: 60 }, defaultDisplayColumnDefOptions), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2325
|
+
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: (_g = props.localization) === null || _g === void 0 ? void 0 : _g.select, size: 60 }, defaultDisplayColumnDefOptions), (_h = props.displayColumnDefOptions) === null || _h === void 0 ? void 0 : _h['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2326
|
+
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => { var _a; return (_a = props.localization) === null || _a === void 0 ? void 0 : _a.rowNumber; }, header: (_j = props.localization) === null || _j === void 0 ? void 0 : _j.rowNumbers, size: 60 }, defaultDisplayColumnDefOptions), (_k = props.displayColumnDefOptions) === null || _k === void 0 ? void 0 : _k['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2288
2327
|
].filter(Boolean);
|
|
2289
2328
|
}, [
|
|
2290
2329
|
columnOrder,
|
|
2330
|
+
grouping,
|
|
2291
2331
|
props.displayColumnDefOptions,
|
|
2292
2332
|
props.editingMode,
|
|
2293
2333
|
props.enableColumnDragging,
|
|
@@ -2304,6 +2344,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2304
2344
|
props.enableSelectAll,
|
|
2305
2345
|
props.localization,
|
|
2306
2346
|
props.positionActionsColumn,
|
|
2347
|
+
props.renderDetailPanel,
|
|
2307
2348
|
]);
|
|
2308
2349
|
const columnDefs = React.useMemo(() => prepareColumns([...displayColumns, ...props.columns], columnFilterFns, props.filterFns, props.sortingFns), [columnFilterFns, displayColumns, props.columns]);
|
|
2309
2350
|
const data = React.useMemo(() => {
|
|
@@ -2321,11 +2362,11 @@ const MRT_TableRoot = (props) => {
|
|
|
2321
2362
|
});
|
|
2322
2363
|
})))
|
|
2323
2364
|
: props.data;
|
|
2324
|
-
}, [props.data, (
|
|
2365
|
+
}, [props.data, (_r = props.state) === null || _r === void 0 ? void 0 : _r.isLoading, (_s = props.state) === null || _s === void 0 ? void 0 : _s.showSkeletons]);
|
|
2325
2366
|
//@ts-ignore
|
|
2326
|
-
const table = Object.assign(Object.assign({}, reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: reactTable.getExpandedRowModel(), getFacetedRowModel: reactTable.getFacetedRowModel(), getFilteredRowModel: reactTable.getFilteredRowModel(), getGroupedRowModel: reactTable.getGroupedRowModel(), getPaginationRowModel: reactTable.getPaginationRowModel(), getSortedRowModel: reactTable.getSortedRowModel(), onColumnOrderChange: setColumnOrder, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2367
|
+
const table = Object.assign(Object.assign({}, reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: reactTable.getExpandedRowModel(), getFacetedRowModel: reactTable.getFacetedRowModel(), getFilteredRowModel: reactTable.getFilteredRowModel(), getGroupedRowModel: reactTable.getGroupedRowModel(), getPaginationRowModel: reactTable.getPaginationRowModel(), getSortedRowModel: reactTable.getSortedRowModel(), onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2327
2368
|
//@ts-ignore
|
|
2328
|
-
columns: columnDefs, data, globalFilterFn: (
|
|
2369
|
+
columns: columnDefs, data, globalFilterFn: (_u = (_t = props.filterFns) === null || _t === void 0 ? void 0 : _t[globalFilterFn]) !== null && _u !== void 0 ? _u : (_v = props.filterFns) === null || _v === void 0 ? void 0 : _v.fuzzy, initialState, state: Object.assign({ columnFilterFns,
|
|
2329
2370
|
columnOrder,
|
|
2330
2371
|
density,
|
|
2331
2372
|
draggingColumn,
|
|
@@ -2333,12 +2374,20 @@ const MRT_TableRoot = (props) => {
|
|
|
2333
2374
|
editingCell,
|
|
2334
2375
|
editingRow,
|
|
2335
2376
|
globalFilterFn,
|
|
2377
|
+
grouping,
|
|
2336
2378
|
hoveredColumn,
|
|
2337
2379
|
hoveredRow,
|
|
2338
2380
|
isFullScreen,
|
|
2339
2381
|
showAlertBanner,
|
|
2340
2382
|
showColumnFilters,
|
|
2341
|
-
showGlobalFilter }, props.state)
|
|
2383
|
+
showGlobalFilter }, props.state) }))), { refs: {
|
|
2384
|
+
bottomToolbarRef,
|
|
2385
|
+
editInputRefs,
|
|
2386
|
+
filterInputRefs,
|
|
2387
|
+
searchInputRef,
|
|
2388
|
+
tableContainerRef,
|
|
2389
|
+
topToolbarRef,
|
|
2390
|
+
}, setColumnFilterFns: (_w = props.onFilterFnsChange) !== null && _w !== void 0 ? _w : setColumnFilterFns, setDensity: (_x = props.onDensityChange) !== null && _x !== void 0 ? _x : setDensity, setDraggingColumn: (_y = props.onDraggingColumnChange) !== null && _y !== void 0 ? _y : setDraggingColumn, setDraggingRow: (_z = props.onDraggingRowChange) !== null && _z !== void 0 ? _z : setDraggingRow, setEditingCell: (_0 = props.onEditingCellChange) !== null && _0 !== void 0 ? _0 : setEditingCell, setEditingRow: (_1 = props.onEditingRowChange) !== null && _1 !== void 0 ? _1 : setEditingRow, setGlobalFilterFn: (_2 = props.onGlobalFilterFnChange) !== null && _2 !== void 0 ? _2 : setGlobalFilterFn, setHoveredColumn: (_3 = props.onHoveredColumnChange) !== null && _3 !== void 0 ? _3 : setHoveredColumn, setHoveredRow: (_4 = props.onHoveredRowChange) !== null && _4 !== void 0 ? _4 : setHoveredRow, setIsFullScreen: (_5 = props.onIsFullScreenChange) !== null && _5 !== void 0 ? _5 : setIsFullScreen, setShowAlertBanner: (_6 = props.onShowAlertBannerChange) !== null && _6 !== void 0 ? _6 : setShowAlertBanner, setShowFilters: (_7 = props.onShowFiltersChange) !== null && _7 !== void 0 ? _7 : setShowFilters, setShowGlobalFilter: (_8 = props.onShowGlobalFilterChange) !== null && _8 !== void 0 ? _8 : setShowGlobalFilter });
|
|
2342
2391
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2343
2392
|
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 },
|
|
2344
2393
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
@@ -2347,10 +2396,11 @@ const MRT_TableRoot = (props) => {
|
|
|
2347
2396
|
};
|
|
2348
2397
|
|
|
2349
2398
|
var MaterialReactTable = (_a) => {
|
|
2350
|
-
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = '
|
|
2399
|
+
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilterChangeMode = false, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterChangeMode = false, 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", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilterChangeMode", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterChangeMode", "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"]);
|
|
2351
2400
|
return (React__default["default"].createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilterChangeMode: enableColumnFilterChangeMode, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterChangeMode: enableGlobalFilterChangeMode, 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_DefaultLocalization_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)));
|
|
2352
2401
|
};
|
|
2353
2402
|
|
|
2403
|
+
exports.MRT_CopyButton = MRT_CopyButton;
|
|
2354
2404
|
exports.MRT_FullScreenToggleButton = MRT_FullScreenToggleButton;
|
|
2355
2405
|
exports.MRT_GlobalFilterTextField = MRT_GlobalFilterTextField;
|
|
2356
2406
|
exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
|