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
|
@@ -500,10 +500,9 @@ const prepareColumns = (columnDefs, columnFilterFns, filterFns, sortingFns) => c
|
|
|
500
500
|
else if (columnDef.columnDefType === 'data') {
|
|
501
501
|
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
502
502
|
columnDef.filterFn =
|
|
503
|
-
// @ts-ignore
|
|
504
503
|
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
columnDef._filterFn =
|
|
505
|
+
columnFilterFns[columnDef.id];
|
|
507
506
|
}
|
|
508
507
|
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
509
508
|
// @ts-ignore
|
|
@@ -522,6 +521,9 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
|
522
521
|
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
523
522
|
return [...columnOrder];
|
|
524
523
|
};
|
|
524
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
525
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
526
|
+
props.renderDetailPanel);
|
|
525
527
|
const getLeadingDisplayColumnIds = (props) => {
|
|
526
528
|
var _a;
|
|
527
529
|
return [
|
|
@@ -531,9 +533,7 @@ const getLeadingDisplayColumnIds = (props) => {
|
|
|
531
533
|
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
532
534
|
'mrt-row-actions',
|
|
533
535
|
props.positionExpandColumn === 'first' &&
|
|
534
|
-
(props
|
|
535
|
-
props.enableGrouping ||
|
|
536
|
-
props.renderDetailPanel) &&
|
|
536
|
+
showExpandColumn(props) &&
|
|
537
537
|
'mrt-row-expand',
|
|
538
538
|
props.enableRowSelection && 'mrt-row-select',
|
|
539
539
|
props.enableRowNumbers && 'mrt-row-numbers',
|
|
@@ -547,9 +547,7 @@ const getTrailingDisplayColumnIds = (props) => {
|
|
|
547
547
|
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
548
548
|
'mrt-row-actions',
|
|
549
549
|
props.positionExpandColumn === 'last' &&
|
|
550
|
-
(props
|
|
551
|
-
props.enableGrouping ||
|
|
552
|
-
props.renderDetailPanel) &&
|
|
550
|
+
showExpandColumn(props) &&
|
|
553
551
|
'mrt-row-expand',
|
|
554
552
|
];
|
|
555
553
|
};
|
|
@@ -704,7 +702,7 @@ const commonListItemStyles = {
|
|
|
704
702
|
};
|
|
705
703
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
706
704
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
707
|
-
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterChangeMode, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, columnFilterModeOptions, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, },
|
|
705
|
+
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;
|
|
708
706
|
const { column } = header;
|
|
709
707
|
const { columnDef } = column;
|
|
710
708
|
const { columnSizing, columnVisibility, density } = getState();
|
|
@@ -745,13 +743,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
745
743
|
};
|
|
746
744
|
const handleFilterByColumn = () => {
|
|
747
745
|
setShowFilters(true);
|
|
748
|
-
|
|
749
|
-
var _a, _b, _c;
|
|
750
|
-
return (_c = document
|
|
751
|
-
.getElementById(
|
|
752
|
-
// @ts-ignore
|
|
753
|
-
(_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();
|
|
754
|
-
}, 200);
|
|
746
|
+
queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
755
747
|
setAnchorEl(null);
|
|
756
748
|
};
|
|
757
749
|
const handleShowAllColumns = () => {
|
|
@@ -882,19 +874,25 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
|
|
|
882
874
|
};
|
|
883
875
|
|
|
884
876
|
const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
|
885
|
-
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
|
|
877
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, refs: { editInputRefs }, setEditingRow, } = table;
|
|
886
878
|
const { editingRow } = getState();
|
|
887
|
-
const handleCancel = () =>
|
|
888
|
-
setEditingRow(null);
|
|
889
|
-
};
|
|
879
|
+
const handleCancel = () => setEditingRow(null);
|
|
890
880
|
const handleSave = () => {
|
|
891
|
-
var _a;
|
|
881
|
+
var _a, _b;
|
|
882
|
+
//look for auto-filled input values
|
|
883
|
+
(_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
|
|
884
|
+
if (input.value !== undefined &&
|
|
885
|
+
Object.hasOwn(editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache, input.name)) {
|
|
886
|
+
// @ts-ignore
|
|
887
|
+
editingRow._valuesCache[input.name] = input.value;
|
|
888
|
+
}
|
|
889
|
+
});
|
|
892
890
|
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
891
|
+
exitEditingMode: () => setEditingRow(null),
|
|
893
892
|
row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
|
|
894
893
|
table,
|
|
895
|
-
values: (
|
|
894
|
+
values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
|
|
896
895
|
});
|
|
897
|
-
setEditingRow(null);
|
|
898
896
|
};
|
|
899
897
|
return (React.createElement(Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React.createElement(React.Fragment, null,
|
|
900
898
|
React.createElement(Tooltip, { arrow: true, title: localization.cancel },
|
|
@@ -917,7 +915,7 @@ const commonIconButtonStyles = {
|
|
|
917
915
|
opacity: 1,
|
|
918
916
|
},
|
|
919
917
|
};
|
|
920
|
-
const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
918
|
+
const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
921
919
|
const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
922
920
|
const { editingRow } = getState();
|
|
923
921
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
@@ -930,8 +928,8 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
|
930
928
|
setEditingRow(Object.assign({}, row));
|
|
931
929
|
setAnchorEl(null);
|
|
932
930
|
};
|
|
933
|
-
return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
934
|
-
React.createElement(IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
931
|
+
return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ cell, row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
932
|
+
React.createElement(IconButton, { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
935
933
|
React.createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React.createElement(React.Fragment, null,
|
|
936
934
|
React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
|
|
937
935
|
React.createElement(IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles },
|
|
@@ -965,7 +963,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
965
963
|
|
|
966
964
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
967
965
|
var _a;
|
|
968
|
-
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps,
|
|
966
|
+
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
969
967
|
const { globalFilter, showGlobalFilter } = getState();
|
|
970
968
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
971
969
|
const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
|
@@ -988,7 +986,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
988
986
|
? muiSearchTextFieldProps({ table })
|
|
989
987
|
: muiSearchTextFieldProps;
|
|
990
988
|
return (React.createElement(Collapse, { in: showGlobalFilter, orientation: "horizontal" },
|
|
991
|
-
React.createElement(TextField, Object.assign({
|
|
989
|
+
React.createElement(TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
|
|
992
990
|
startAdornment: enableGlobalFilterChangeMode ? (React.createElement(InputAdornment, { position: "start" },
|
|
993
991
|
React.createElement(Tooltip, { arrow: true, title: localization.changeSearchMode },
|
|
994
992
|
React.createElement(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' } },
|
|
@@ -998,7 +996,12 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
998
996
|
React.createElement("span", null,
|
|
999
997
|
React.createElement(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small" },
|
|
1000
998
|
React.createElement(CloseIcon, null)))))),
|
|
1001
|
-
} }, textFieldProps)
|
|
999
|
+
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1000
|
+
searchInputRef.current = inputRef;
|
|
1001
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
|
|
1002
|
+
textFieldProps.inputRef = inputRef;
|
|
1003
|
+
}
|
|
1004
|
+
} })),
|
|
1002
1005
|
React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1003
1006
|
};
|
|
1004
1007
|
|
|
@@ -1123,18 +1126,11 @@ const MRT_ToggleFiltersButton = (_a) => {
|
|
|
1123
1126
|
|
|
1124
1127
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
1125
1128
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1126
|
-
const { getState, options: { icons: { SearchIcon, SearchOffIcon },
|
|
1129
|
+
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1127
1130
|
const { showGlobalFilter } = getState();
|
|
1128
|
-
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1129
|
-
? muiSearchTextFieldProps({ table })
|
|
1130
|
-
: muiSearchTextFieldProps;
|
|
1131
1131
|
const handleToggleSearch = () => {
|
|
1132
1132
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1133
|
-
|
|
1134
|
-
var _a, _b;
|
|
1135
|
-
return (_b = document
|
|
1136
|
-
.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();
|
|
1137
|
-
}, 200);
|
|
1133
|
+
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1138
1134
|
};
|
|
1139
1135
|
return (React.createElement(Tooltip, { arrow: true, title: localization.showHideSearch },
|
|
1140
1136
|
React.createElement(IconButton, Object.assign({ onClick: handleToggleSearch }, rest), showGlobalFilter ? React.createElement(SearchOffIcon, null) : React.createElement(SearchIcon, null))));
|
|
@@ -1193,14 +1189,20 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1193
1189
|
});
|
|
1194
1190
|
const MRT_TopToolbar = ({ table }) => {
|
|
1195
1191
|
var _a;
|
|
1196
|
-
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions,
|
|
1192
|
+
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
|
1197
1193
|
const { isFullScreen, showGlobalFilter } = getState();
|
|
1198
1194
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
1199
1195
|
const toolbarProps = muiTableTopToolbarProps instanceof Function
|
|
1200
1196
|
? muiTableTopToolbarProps({ table })
|
|
1201
1197
|
: muiTableTopToolbarProps;
|
|
1202
1198
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
1203
|
-
return (React.createElement(Toolbar, Object.assign({
|
|
1199
|
+
return (React.createElement(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1200
|
+
topToolbarRef.current = ref;
|
|
1201
|
+
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
1202
|
+
// @ts-ignore
|
|
1203
|
+
toolbarProps.ref.current = ref;
|
|
1204
|
+
}
|
|
1205
|
+
}, 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
|
|
1204
1206
|
? toolbarProps.sx(theme)
|
|
1205
1207
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1206
1208
|
positionToolbarAlertBanner === 'top' && (React.createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
@@ -1225,14 +1227,20 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1225
1227
|
};
|
|
1226
1228
|
|
|
1227
1229
|
const MRT_BottomToolbar = ({ table }) => {
|
|
1228
|
-
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions,
|
|
1230
|
+
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
|
1229
1231
|
const { isFullScreen } = getState();
|
|
1230
1232
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
1231
1233
|
const toolbarProps = muiTableBottomToolbarProps instanceof Function
|
|
1232
1234
|
? muiTableBottomToolbarProps({ table })
|
|
1233
1235
|
: muiTableBottomToolbarProps;
|
|
1234
1236
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
1235
|
-
return (React.createElement(Toolbar, Object.assign({
|
|
1237
|
+
return (React.createElement(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1238
|
+
bottomToolbarRef.current = ref;
|
|
1239
|
+
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
1240
|
+
// @ts-ignore
|
|
1241
|
+
toolbarProps.ref.current = ref;
|
|
1242
|
+
}
|
|
1243
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `-3px 0 6px ${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
|
|
1236
1244
|
? toolbarProps.sx(theme)
|
|
1237
1245
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1238
1246
|
React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
@@ -1243,7 +1251,7 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1243
1251
|
justifyContent: 'space-between',
|
|
1244
1252
|
width: '100%',
|
|
1245
1253
|
} },
|
|
1246
|
-
renderBottomToolbarCustomActions ? (
|
|
1254
|
+
renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (React.createElement("span", null)),
|
|
1247
1255
|
React.createElement(Box, { sx: {
|
|
1248
1256
|
display: 'flex',
|
|
1249
1257
|
justifyContent: 'flex-end',
|
|
@@ -1287,7 +1295,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1287
1295
|
|
|
1288
1296
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1289
1297
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1290
|
-
const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps,
|
|
1298
|
+
const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
|
1291
1299
|
const { column } = header;
|
|
1292
1300
|
const { columnDef } = column;
|
|
1293
1301
|
const { columnFilterFns } = getState();
|
|
@@ -1312,7 +1320,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1312
1320
|
const isTextboxFilter = columnDef.filterVariant === 'text' ||
|
|
1313
1321
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
1314
1322
|
const currentFilterOption = columnFilterFns === null || columnFilterFns === void 0 ? void 0 : columnFilterFns[header.id];
|
|
1315
|
-
const filterId = `mrt-${tableId}-${header.id}-filter-text-field${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : ''}`;
|
|
1316
1323
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
|
1317
1324
|
? //@ts-ignore
|
|
1318
1325
|
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()) +
|
|
@@ -1389,14 +1396,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1389
1396
|
return React.createElement(React.Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, table }));
|
|
1390
1397
|
}
|
|
1391
1398
|
return (React.createElement(React.Fragment, null,
|
|
1392
|
-
React.createElement(TextField, Object.assign({ fullWidth: true,
|
|
1399
|
+
React.createElement(TextField, Object.assign({ fullWidth: true, inputProps: {
|
|
1393
1400
|
disabled: !!filterChipLabel,
|
|
1394
1401
|
sx: {
|
|
1395
1402
|
textOverflow: 'ellipsis',
|
|
1396
1403
|
width: filterChipLabel ? 0 : undefined,
|
|
1397
1404
|
},
|
|
1398
1405
|
title: filterPlaceholder,
|
|
1399
|
-
}, helperText: showChangeModeButton ? (React.createElement("label",
|
|
1406
|
+
}, helperText: showChangeModeButton ? (React.createElement("label", null, localization.filterMode.replace('{filterType}',
|
|
1400
1407
|
// @ts-ignore
|
|
1401
1408
|
localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
|
|
1402
1409
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
|
|
@@ -1428,7 +1435,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1428
1435
|
renderValue: isMultiSelectFilter
|
|
1429
1436
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (React.createElement(Box, { sx: { opacity: 0.5 } }, filterPlaceholder)) : (React.createElement(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' } }, selected === null || selected === void 0 ? void 0 : selected.map((value) => (React.createElement(Chip, { key: value, label: value })))))
|
|
1430
1437
|
: undefined,
|
|
1431
|
-
} }, textFieldProps, {
|
|
1438
|
+
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1439
|
+
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
|
1440
|
+
inputRef;
|
|
1441
|
+
if (textFieldProps.inputRef) {
|
|
1442
|
+
textFieldProps.inputRef = inputRef;
|
|
1443
|
+
}
|
|
1444
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1432
1445
|
mr: '1.5rem',
|
|
1433
1446
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1434
1447
|
? textFieldProps.sx(theme)
|
|
@@ -1620,7 +1633,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1620
1633
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1621
1634
|
setHoveredColumn(null);
|
|
1622
1635
|
}
|
|
1623
|
-
if (enableColumnOrdering && draggingColumn) {
|
|
1636
|
+
if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
|
|
1624
1637
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
1625
1638
|
}
|
|
1626
1639
|
};
|
|
@@ -1670,13 +1683,11 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1670
1683
|
? '0.4rem'
|
|
1671
1684
|
: '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
|
|
1672
1685
|
? 'sticky'
|
|
1673
|
-
: undefined, pt: columnDefType === 'group'
|
|
1674
|
-
? 0
|
|
1675
|
-
: density === '
|
|
1676
|
-
? '
|
|
1677
|
-
:
|
|
1678
|
-
? '.75rem'
|
|
1679
|
-
: '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
|
|
1686
|
+
: undefined, pt: columnDefType === 'group' || density === 'compact'
|
|
1687
|
+
? '0.25rem'
|
|
1688
|
+
: density === 'comfortable'
|
|
1689
|
+
? '.75rem'
|
|
1690
|
+
: '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
|
|
1680
1691
|
? 3
|
|
1681
1692
|
: column.getIsPinned() && columnDefType !== 'group'
|
|
1682
1693
|
? 2
|
|
@@ -1742,17 +1753,19 @@ const MRT_TableHead = ({ table }) => {
|
|
|
1742
1753
|
|
|
1743
1754
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
1744
1755
|
var _a;
|
|
1745
|
-
const { getState, options: {
|
|
1746
|
-
const { column } = cell;
|
|
1756
|
+
const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
|
|
1757
|
+
const { column, row } = cell;
|
|
1747
1758
|
const { columnDef } = column;
|
|
1748
1759
|
const { editingRow } = getState();
|
|
1749
1760
|
const [value, setValue] = useState(() => cell.getValue());
|
|
1750
1761
|
const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1751
|
-
? muiTableBodyCellEditTextFieldProps({ cell, table })
|
|
1762
|
+
? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
|
|
1752
1763
|
: muiTableBodyCellEditTextFieldProps;
|
|
1753
1764
|
const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1754
1765
|
? columnDef.muiTableBodyCellEditTextFieldProps({
|
|
1755
1766
|
cell,
|
|
1767
|
+
column,
|
|
1768
|
+
row,
|
|
1756
1769
|
table,
|
|
1757
1770
|
})
|
|
1758
1771
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
@@ -1771,14 +1784,21 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1771
1784
|
setEditingCell(null);
|
|
1772
1785
|
};
|
|
1773
1786
|
if (columnDef.Edit) {
|
|
1774
|
-
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table }));
|
|
1787
|
+
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1775
1788
|
}
|
|
1776
|
-
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true,
|
|
1789
|
+
return (React.createElement(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) => {
|
|
1790
|
+
if (inputRef) {
|
|
1791
|
+
editInputRefs.current[column.id] = inputRef;
|
|
1792
|
+
if (textFieldProps.inputRef) {
|
|
1793
|
+
textFieldProps.inputRef = inputRef;
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1777
1797
|
};
|
|
1778
1798
|
|
|
1779
|
-
const MRT_CopyButton = ({ cell, children, table }) => {
|
|
1799
|
+
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
1780
1800
|
const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
|
|
1781
|
-
const { column } = cell;
|
|
1801
|
+
const { column, row } = cell;
|
|
1782
1802
|
const { columnDef } = column;
|
|
1783
1803
|
const [copied, setCopied] = useState(false);
|
|
1784
1804
|
const handleCopy = (text) => {
|
|
@@ -1787,7 +1807,7 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1787
1807
|
setTimeout(() => setCopied(false), 4000);
|
|
1788
1808
|
};
|
|
1789
1809
|
const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
|
|
1790
|
-
? muiTableBodyCellCopyButtonProps({ cell, table })
|
|
1810
|
+
? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
|
|
1791
1811
|
: muiTableBodyCellCopyButtonProps;
|
|
1792
1812
|
const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
|
|
1793
1813
|
? columnDef.muiTableBodyCellCopyButtonProps({
|
|
@@ -1804,12 +1824,13 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1804
1824
|
|
|
1805
1825
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
1806
1826
|
const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
|
|
1827
|
+
const { row } = cell;
|
|
1807
1828
|
const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
|
|
1808
|
-
? muiTableBodyRowDragHandleProps({ row
|
|
1829
|
+
? muiTableBodyRowDragHandleProps({ row, table })
|
|
1809
1830
|
: muiTableBodyRowDragHandleProps;
|
|
1810
1831
|
const handleDragStart = (e) => {
|
|
1811
1832
|
e.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1812
|
-
table.setDraggingRow(
|
|
1833
|
+
table.setDraggingRow(row);
|
|
1813
1834
|
};
|
|
1814
1835
|
const handleDragEnd = (event) => {
|
|
1815
1836
|
onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
|
|
@@ -1823,16 +1844,32 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1823
1844
|
return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1824
1845
|
};
|
|
1825
1846
|
|
|
1847
|
+
const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1848
|
+
var _a, _b, _c;
|
|
1849
|
+
const { column, row } = cell;
|
|
1850
|
+
const { columnDef } = column;
|
|
1851
|
+
return (React.createElement(React.Fragment, null, cell.getIsAggregated() && column.columnDef.aggregationFn
|
|
1852
|
+
? (_a = columnDef.AggregatedCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
|
|
1853
|
+
cell,
|
|
1854
|
+
column,
|
|
1855
|
+
row,
|
|
1856
|
+
table,
|
|
1857
|
+
})
|
|
1858
|
+
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
1859
|
+
? null
|
|
1860
|
+
: (_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()));
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1826
1863
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1827
|
-
var _a, _b
|
|
1864
|
+
var _a, _b;
|
|
1828
1865
|
const theme = useTheme();
|
|
1829
|
-
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode,
|
|
1866
|
+
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
|
1830
1867
|
const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
|
|
1831
1868
|
const { column, row } = cell;
|
|
1832
1869
|
const { columnDef } = column;
|
|
1833
1870
|
const { columnDefType } = columnDef;
|
|
1834
1871
|
const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
|
|
1835
|
-
? muiTableBodyCellProps({ cell, table })
|
|
1872
|
+
? muiTableBodyCellProps({ cell, column, row, table })
|
|
1836
1873
|
: muiTableBodyCellProps;
|
|
1837
1874
|
const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
|
|
1838
1875
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
@@ -1857,13 +1894,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1857
1894
|
columnDef.enableEditing !== false &&
|
|
1858
1895
|
editingMode === 'cell') {
|
|
1859
1896
|
setEditingCell(cell);
|
|
1860
|
-
|
|
1861
|
-
const textField =
|
|
1897
|
+
queueMicrotask(() => {
|
|
1898
|
+
const textField = editInputRefs.current[column.id];
|
|
1862
1899
|
if (textField) {
|
|
1863
1900
|
textField.focus();
|
|
1864
1901
|
textField.select();
|
|
1865
1902
|
}
|
|
1866
|
-
}
|
|
1903
|
+
});
|
|
1867
1904
|
}
|
|
1868
1905
|
};
|
|
1869
1906
|
const getIsLastLeftPinnedColumn = () => {
|
|
@@ -1953,22 +1990,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1953
1990
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
|
1954
1991
|
(column.id === 'mrt-row-select' ||
|
|
1955
1992
|
column.id === 'mrt-row-expand' ||
|
|
1956
|
-
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table })) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
1957
|
-
columnDef.enableClickToCopy !== false ? (React.createElement(
|
|
1958
|
-
React.createElement(
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
|
1964
|
-
_d.length,
|
|
1965
|
-
")"))) : (React.createElement(React.Fragment, null,
|
|
1966
|
-
row.getIsGrouped() && !cell.getIsGrouped()
|
|
1967
|
-
? null
|
|
1968
|
-
: (_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(),
|
|
1969
|
-
cell.getIsGrouped() && React.createElement(React.Fragment, null,
|
|
1970
|
-
" (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
|
|
1971
|
-
")"))))));
|
|
1993
|
+
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
1994
|
+
columnDef.enableClickToCopy !== false ? (React.createElement(MRT_CopyButton, { cell: cell, table: table },
|
|
1995
|
+
React.createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React.createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
|
|
1996
|
+
cell.getIsGrouped() && React.createElement(React.Fragment, null,
|
|
1997
|
+
" (", (_b = row.subRows) === null || _b === void 0 ? void 0 :
|
|
1998
|
+
_b.length,
|
|
1999
|
+
")")));
|
|
1972
2000
|
};
|
|
1973
2001
|
|
|
1974
2002
|
const MRT_TableDetailPanel = ({ row, table }) => {
|
|
@@ -2018,7 +2046,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
|
2018
2046
|
: undefined,
|
|
2019
2047
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2020
2048
|
? tableRowProps.sx(theme)
|
|
2021
|
-
: 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.createElement(MRT_TableBodyCell, { cell: cell,
|
|
2049
|
+
: 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.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 })))),
|
|
2022
2050
|
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2023
2051
|
};
|
|
2024
2052
|
|
|
@@ -2166,25 +2194,29 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2166
2194
|
|
|
2167
2195
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
2168
2196
|
const MRT_TableContainer = ({ table }) => {
|
|
2169
|
-
|
|
2170
|
-
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, tableId, }, } = table;
|
|
2197
|
+
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
|
|
2171
2198
|
const { isFullScreen } = getState();
|
|
2172
2199
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
2173
2200
|
const tableContainerProps = muiTableContainerProps instanceof Function
|
|
2174
2201
|
? muiTableContainerProps({ table })
|
|
2175
2202
|
: muiTableContainerProps;
|
|
2176
|
-
const tableContainerRef = (_a = tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) !== null && _a !== void 0 ? _a : useRef(null);
|
|
2177
2203
|
useIsomorphicLayoutEffect(() => {
|
|
2178
2204
|
var _a, _b, _c, _d;
|
|
2179
2205
|
const topToolbarHeight = typeof document !== 'undefined'
|
|
2180
|
-
? (_b = (_a =
|
|
2206
|
+
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
|
2181
2207
|
: 0;
|
|
2182
2208
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
|
2183
|
-
? (_d = (_c =
|
|
2209
|
+
? (_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
|
|
2184
2210
|
: 0;
|
|
2185
2211
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
|
2186
2212
|
});
|
|
2187
|
-
return (React.createElement(TableContainer, Object.assign({
|
|
2213
|
+
return (React.createElement(TableContainer, Object.assign({}, tableContainerProps, { ref: (ref) => {
|
|
2214
|
+
tableContainerRef.current = ref;
|
|
2215
|
+
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
|
2216
|
+
//@ts-ignore
|
|
2217
|
+
tableContainerProps.ref.current = ref;
|
|
2218
|
+
}
|
|
2219
|
+
}, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
|
|
2188
2220
|
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
|
2189
2221
|
: undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
|
|
2190
2222
|
? tableContainerProps.sx(theme)
|
|
@@ -2221,22 +2253,27 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
|
2221
2253
|
return (React.createElement(Dialog, { open: open },
|
|
2222
2254
|
React.createElement(DialogTitle, { textAlign: "center" }, localization.edit),
|
|
2223
2255
|
React.createElement(DialogContent, null,
|
|
2224
|
-
React.createElement(
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2256
|
+
React.createElement("form", { onSubmit: (e) => e.preventDefault() },
|
|
2257
|
+
React.createElement(Stack, { sx: {
|
|
2258
|
+
width: '100%',
|
|
2259
|
+
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
2260
|
+
gap: '1.5rem',
|
|
2261
|
+
} }, row
|
|
2262
|
+
.getAllCells()
|
|
2263
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
2264
|
+
.map((cell) => (React.createElement(MRT_EditCellTextField, { cell: cell, key: cell.id, showLabel: true, table: table })))))),
|
|
2232
2265
|
React.createElement(DialogActions, { sx: { p: '1.25rem' } },
|
|
2233
2266
|
React.createElement(MRT_EditActionButtons, { row: row, table: table, variant: "text" }))));
|
|
2234
2267
|
};
|
|
2235
2268
|
|
|
2236
2269
|
const MRT_TableRoot = (props) => {
|
|
2237
|
-
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;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2270
|
+
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;
|
|
2271
|
+
const bottomToolbarRef = useRef(null);
|
|
2272
|
+
const editInputRefs = useRef({});
|
|
2273
|
+
const filterInputRefs = useRef({});
|
|
2274
|
+
const searchInputRef = useRef(null);
|
|
2275
|
+
const tableContainerRef = useRef(null);
|
|
2276
|
+
const topToolbarRef = useRef(null);
|
|
2240
2277
|
const initialState = useMemo(() => {
|
|
2241
2278
|
var _a, _b;
|
|
2242
2279
|
const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
|
|
@@ -2263,23 +2300,26 @@ const MRT_TableRoot = (props) => {
|
|
|
2263
2300
|
const [editingCell, setEditingCell] = useState((_e = initialState.editingCell) !== null && _e !== void 0 ? _e : null);
|
|
2264
2301
|
const [editingRow, setEditingRow] = useState((_f = initialState.editingRow) !== null && _f !== void 0 ? _f : null);
|
|
2265
2302
|
const [globalFilterFn, setGlobalFilterFn] = useState((_g = initialState.globalFilterFn) !== null && _g !== void 0 ? _g : 'fuzzy');
|
|
2266
|
-
const [
|
|
2267
|
-
const [
|
|
2268
|
-
const [
|
|
2269
|
-
const [
|
|
2270
|
-
const [
|
|
2271
|
-
const [
|
|
2303
|
+
const [grouping, setGrouping] = useState((_h = initialState.grouping) !== null && _h !== void 0 ? _h : []);
|
|
2304
|
+
const [hoveredColumn, setHoveredColumn] = useState((_j = initialState.hoveredColumn) !== null && _j !== void 0 ? _j : null);
|
|
2305
|
+
const [hoveredRow, setHoveredRow] = useState((_k = initialState.hoveredRow) !== null && _k !== void 0 ? _k : null);
|
|
2306
|
+
const [isFullScreen, setIsFullScreen] = useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _l !== void 0 ? _l : false);
|
|
2307
|
+
const [showAlertBanner, setShowAlertBanner] = useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
|
|
2308
|
+
const [showColumnFilters, setShowFilters] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2309
|
+
const [showGlobalFilter, setShowGlobalFilter] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2272
2310
|
const displayColumns = useMemo(() => {
|
|
2273
2311
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2274
2312
|
return [
|
|
2275
2313
|
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' }),
|
|
2276
|
-
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React.createElement(MRT_ToggleRowActionMenuButton, {
|
|
2277
|
-
columnOrder.includes('mrt-row-expand') &&
|
|
2278
|
-
|
|
2279
|
-
columnOrder.includes('mrt-row-
|
|
2314
|
+
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React.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' }),
|
|
2315
|
+
columnOrder.includes('mrt-row-expand') &&
|
|
2316
|
+
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.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' }),
|
|
2317
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.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' }),
|
|
2318
|
+
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' }),
|
|
2280
2319
|
].filter(Boolean);
|
|
2281
2320
|
}, [
|
|
2282
2321
|
columnOrder,
|
|
2322
|
+
grouping,
|
|
2283
2323
|
props.displayColumnDefOptions,
|
|
2284
2324
|
props.editingMode,
|
|
2285
2325
|
props.enableColumnDragging,
|
|
@@ -2296,6 +2336,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2296
2336
|
props.enableSelectAll,
|
|
2297
2337
|
props.localization,
|
|
2298
2338
|
props.positionActionsColumn,
|
|
2339
|
+
props.renderDetailPanel,
|
|
2299
2340
|
]);
|
|
2300
2341
|
const columnDefs = useMemo(() => prepareColumns([...displayColumns, ...props.columns], columnFilterFns, props.filterFns, props.sortingFns), [columnFilterFns, displayColumns, props.columns]);
|
|
2301
2342
|
const data = useMemo(() => {
|
|
@@ -2313,11 +2354,11 @@ const MRT_TableRoot = (props) => {
|
|
|
2313
2354
|
});
|
|
2314
2355
|
})))
|
|
2315
2356
|
: props.data;
|
|
2316
|
-
}, [props.data, (
|
|
2357
|
+
}, [props.data, (_r = props.state) === null || _r === void 0 ? void 0 : _r.isLoading, (_s = props.state) === null || _s === void 0 ? void 0 : _s.showSkeletons]);
|
|
2317
2358
|
//@ts-ignore
|
|
2318
|
-
const table = Object.assign(Object.assign({}, useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: getExpandedRowModel(), getFacetedRowModel: getFacetedRowModel(), getFilteredRowModel: getFilteredRowModel(), getGroupedRowModel: getGroupedRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), onColumnOrderChange: setColumnOrder, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2359
|
+
const table = Object.assign(Object.assign({}, useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: getExpandedRowModel(), getFacetedRowModel: getFacetedRowModel(), getFilteredRowModel: getFilteredRowModel(), getGroupedRowModel: getGroupedRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2319
2360
|
//@ts-ignore
|
|
2320
|
-
columns: columnDefs, data, globalFilterFn: (
|
|
2361
|
+
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,
|
|
2321
2362
|
columnOrder,
|
|
2322
2363
|
density,
|
|
2323
2364
|
draggingColumn,
|
|
@@ -2325,12 +2366,20 @@ const MRT_TableRoot = (props) => {
|
|
|
2325
2366
|
editingCell,
|
|
2326
2367
|
editingRow,
|
|
2327
2368
|
globalFilterFn,
|
|
2369
|
+
grouping,
|
|
2328
2370
|
hoveredColumn,
|
|
2329
2371
|
hoveredRow,
|
|
2330
2372
|
isFullScreen,
|
|
2331
2373
|
showAlertBanner,
|
|
2332
2374
|
showColumnFilters,
|
|
2333
|
-
showGlobalFilter }, props.state)
|
|
2375
|
+
showGlobalFilter }, props.state) }))), { refs: {
|
|
2376
|
+
bottomToolbarRef,
|
|
2377
|
+
editInputRefs,
|
|
2378
|
+
filterInputRefs,
|
|
2379
|
+
searchInputRef,
|
|
2380
|
+
tableContainerRef,
|
|
2381
|
+
topToolbarRef,
|
|
2382
|
+
}, 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 });
|
|
2334
2383
|
return (React.createElement(React.Fragment, null,
|
|
2335
2384
|
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2336
2385
|
React.createElement(MRT_TablePaper, { table: table })),
|
|
@@ -2339,9 +2388,9 @@ const MRT_TableRoot = (props) => {
|
|
|
2339
2388
|
};
|
|
2340
2389
|
|
|
2341
2390
|
var MaterialReactTable = (_a) => {
|
|
2342
|
-
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = '
|
|
2391
|
+
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"]);
|
|
2343
2392
|
return (React.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)));
|
|
2344
2393
|
};
|
|
2345
2394
|
|
|
2346
|
-
export { MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTable as default };
|
|
2395
|
+
export { MRT_CopyButton, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTable as default };
|
|
2347
2396
|
//# sourceMappingURL=material-react-table.esm.js.map
|