material-react-table 0.36.1 → 0.37.1
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 +33 -15
- package/dist/cjs/body/MRT_EditRowModal.d.ts +8 -0
- package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +5 -5
- package/dist/cjs/column.utils.d.ts +2 -1
- package/dist/cjs/index.js +187 -118
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +5 -5
- package/dist/esm/MaterialReactTable.d.ts +33 -15
- package/dist/esm/body/MRT_EditRowModal.d.ts +8 -0
- package/dist/esm/buttons/MRT_EditActionButtons.d.ts +5 -5
- package/dist/esm/column.utils.d.ts +2 -1
- package/dist/esm/inputs/MRT_EditCellTextField.d.ts +5 -5
- package/dist/esm/material-react-table.esm.js +188 -119
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +33 -15
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +48 -12
- package/src/body/MRT_EditRowModal.tsx +59 -0
- package/src/body/MRT_TableBodyCell.tsx +12 -16
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
- package/src/buttons/MRT_CopyButton.tsx +2 -2
- package/src/buttons/MRT_EditActionButtons.tsx +49 -25
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +2 -1
- package/src/column.utils.ts +19 -12
- package/src/inputs/MRT_EditCellTextField.tsx +33 -19
- 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 +48 -30
- package/src/toolbar/MRT_BottomToolbar.tsx +8 -2
- 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,29 +529,36 @@ 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
|
};
|
|
533
|
-
const
|
|
534
|
-
(props.
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
(props.
|
|
540
|
-
|
|
541
|
-
props.
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
'
|
|
555
|
-
|
|
532
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
533
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
534
|
+
props.renderDetailPanel);
|
|
535
|
+
const getLeadingDisplayColumnIds = (props) => {
|
|
536
|
+
var _a;
|
|
537
|
+
return [
|
|
538
|
+
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
539
|
+
((props.positionActionsColumn === 'first' && props.enableRowActions) ||
|
|
540
|
+
(props.enableEditing &&
|
|
541
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
542
|
+
'mrt-row-actions',
|
|
543
|
+
props.positionExpandColumn === 'first' &&
|
|
544
|
+
showExpandColumn(props) &&
|
|
545
|
+
'mrt-row-expand',
|
|
546
|
+
props.enableRowSelection && 'mrt-row-select',
|
|
547
|
+
props.enableRowNumbers && 'mrt-row-numbers',
|
|
548
|
+
].filter(Boolean);
|
|
549
|
+
};
|
|
550
|
+
const getTrailingDisplayColumnIds = (props) => {
|
|
551
|
+
var _a;
|
|
552
|
+
return [
|
|
553
|
+
((props.positionActionsColumn === 'last' && props.enableRowActions) ||
|
|
554
|
+
(props.enableEditing &&
|
|
555
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
556
|
+
'mrt-row-actions',
|
|
557
|
+
props.positionExpandColumn === 'last' &&
|
|
558
|
+
showExpandColumn(props) &&
|
|
559
|
+
'mrt-row-expand',
|
|
560
|
+
];
|
|
561
|
+
};
|
|
556
562
|
const getDefaultColumnOrderIds = (props) => [
|
|
557
563
|
...getLeadingDisplayColumnIds(props),
|
|
558
564
|
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
@@ -704,7 +710,7 @@ const commonListItemStyles = {
|
|
|
704
710
|
};
|
|
705
711
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
706
712
|
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, },
|
|
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;
|
|
708
714
|
const { column } = header;
|
|
709
715
|
const { columnDef } = column;
|
|
710
716
|
const { columnSizing, columnVisibility, density } = getState();
|
|
@@ -745,13 +751,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
745
751
|
};
|
|
746
752
|
const handleFilterByColumn = () => {
|
|
747
753
|
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);
|
|
754
|
+
queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
755
755
|
setAnchorEl(null);
|
|
756
756
|
};
|
|
757
757
|
const handleShowAllColumns = () => {
|
|
@@ -881,29 +881,36 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
|
|
|
881
881
|
})));
|
|
882
882
|
};
|
|
883
883
|
|
|
884
|
-
const MRT_EditActionButtons = ({ row, table }) => {
|
|
885
|
-
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
|
|
884
|
+
const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
|
885
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, refs: { editInputRefs }, setEditingRow, } = table;
|
|
886
886
|
const { editingRow } = getState();
|
|
887
|
-
const handleCancel = () =>
|
|
888
|
-
row._valuesCache = Object.assign({}, row.original);
|
|
889
|
-
setEditingRow(null);
|
|
890
|
-
};
|
|
887
|
+
const handleCancel = () => setEditingRow(null);
|
|
891
888
|
const handleSave = () => {
|
|
892
|
-
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
|
+
});
|
|
893
898
|
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
899
|
+
exitEditingMode: () => setEditingRow(null),
|
|
894
900
|
row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
|
|
895
901
|
table,
|
|
896
|
-
values: (
|
|
902
|
+
values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
|
|
897
903
|
});
|
|
898
|
-
setEditingRow(null);
|
|
899
904
|
};
|
|
900
|
-
return (React__default["default"].createElement(material.Box, { sx: { display: 'flex', gap: '0.75rem' } },
|
|
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,
|
|
901
906
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.cancel },
|
|
902
907
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.cancel, onClick: handleCancel },
|
|
903
908
|
React__default["default"].createElement(CancelIcon, null))),
|
|
904
909
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.save },
|
|
905
910
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.save, color: "info", onClick: handleSave },
|
|
906
|
-
React__default["default"].createElement(SaveIcon, null)))))
|
|
911
|
+
React__default["default"].createElement(SaveIcon, null))))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
912
|
+
React__default["default"].createElement(material.Button, { onClick: handleCancel }, localization.cancel),
|
|
913
|
+
React__default["default"].createElement(material.Button, { onClick: handleSave, variant: "contained" }, localization.save)))));
|
|
907
914
|
};
|
|
908
915
|
|
|
909
916
|
const commonIconButtonStyles = {
|
|
@@ -917,7 +924,7 @@ const commonIconButtonStyles = {
|
|
|
917
924
|
},
|
|
918
925
|
};
|
|
919
926
|
const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
920
|
-
const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
927
|
+
const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
921
928
|
const { editingRow } = getState();
|
|
922
929
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
923
930
|
const handleOpenRowActionMenu = (event) => {
|
|
@@ -929,7 +936,7 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
|
929
936
|
setEditingRow(Object.assign({}, row));
|
|
930
937
|
setAnchorEl(null);
|
|
931
938
|
};
|
|
932
|
-
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) ? (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 },
|
|
939
|
+
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 },
|
|
933
940
|
React__default["default"].createElement(material.IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
934
941
|
React__default["default"].createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
935
942
|
React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
|
|
@@ -964,7 +971,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
964
971
|
|
|
965
972
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
966
973
|
var _a;
|
|
967
|
-
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps,
|
|
974
|
+
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
968
975
|
const { globalFilter, showGlobalFilter } = getState();
|
|
969
976
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
970
977
|
const [searchValue, setSearchValue] = React.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
|
@@ -987,7 +994,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
987
994
|
? muiSearchTextFieldProps({ table })
|
|
988
995
|
: muiSearchTextFieldProps;
|
|
989
996
|
return (React__default["default"].createElement(material.Collapse, { in: showGlobalFilter, orientation: "horizontal" },
|
|
990
|
-
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: {
|
|
991
998
|
startAdornment: enableGlobalFilterChangeMode ? (React__default["default"].createElement(material.InputAdornment, { position: "start" },
|
|
992
999
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.changeSearchMode },
|
|
993
1000
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' } },
|
|
@@ -997,7 +1004,12 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
997
1004
|
React__default["default"].createElement("span", null,
|
|
998
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" },
|
|
999
1006
|
React__default["default"].createElement(CloseIcon, null)))))),
|
|
1000
|
-
} }, 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
|
+
} })),
|
|
1001
1013
|
React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1002
1014
|
};
|
|
1003
1015
|
|
|
@@ -1122,18 +1134,11 @@ const MRT_ToggleFiltersButton = (_a) => {
|
|
|
1122
1134
|
|
|
1123
1135
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
1124
1136
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1125
|
-
const { getState, options: { icons: { SearchIcon, SearchOffIcon },
|
|
1137
|
+
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1126
1138
|
const { showGlobalFilter } = getState();
|
|
1127
|
-
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1128
|
-
? muiSearchTextFieldProps({ table })
|
|
1129
|
-
: muiSearchTextFieldProps;
|
|
1130
1139
|
const handleToggleSearch = () => {
|
|
1131
1140
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1132
|
-
|
|
1133
|
-
var _a, _b;
|
|
1134
|
-
return (_b = document
|
|
1135
|
-
.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();
|
|
1136
|
-
}, 200);
|
|
1141
|
+
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1137
1142
|
};
|
|
1138
1143
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.showHideSearch },
|
|
1139
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))));
|
|
@@ -1192,14 +1197,20 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1192
1197
|
});
|
|
1193
1198
|
const MRT_TopToolbar = ({ table }) => {
|
|
1194
1199
|
var _a;
|
|
1195
|
-
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;
|
|
1196
1201
|
const { isFullScreen, showGlobalFilter } = getState();
|
|
1197
1202
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1198
1203
|
const toolbarProps = muiTableTopToolbarProps instanceof Function
|
|
1199
1204
|
? muiTableTopToolbarProps({ table })
|
|
1200
1205
|
: muiTableTopToolbarProps;
|
|
1201
1206
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
1202
|
-
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
|
|
1203
1214
|
? toolbarProps.sx(theme)
|
|
1204
1215
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1205
1216
|
positionToolbarAlertBanner === 'top' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
@@ -1224,14 +1235,20 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1224
1235
|
};
|
|
1225
1236
|
|
|
1226
1237
|
const MRT_BottomToolbar = ({ table }) => {
|
|
1227
|
-
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions,
|
|
1238
|
+
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
|
1228
1239
|
const { isFullScreen } = getState();
|
|
1229
1240
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1230
1241
|
const toolbarProps = muiTableBottomToolbarProps instanceof Function
|
|
1231
1242
|
? muiTableBottomToolbarProps({ table })
|
|
1232
1243
|
: muiTableBottomToolbarProps;
|
|
1233
1244
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
1234
|
-
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
|
|
1235
1252
|
? toolbarProps.sx(theme)
|
|
1236
1253
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1237
1254
|
React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
@@ -1286,7 +1303,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1286
1303
|
|
|
1287
1304
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1288
1305
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1289
|
-
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;
|
|
1290
1307
|
const { column } = header;
|
|
1291
1308
|
const { columnDef } = column;
|
|
1292
1309
|
const { columnFilterFns } = getState();
|
|
@@ -1311,7 +1328,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1311
1328
|
const isTextboxFilter = columnDef.filterVariant === 'text' ||
|
|
1312
1329
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
1313
1330
|
const currentFilterOption = columnFilterFns === null || columnFilterFns === void 0 ? void 0 : columnFilterFns[header.id];
|
|
1314
|
-
const filterId = `mrt-${tableId}-${header.id}-filter-text-field${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : ''}`;
|
|
1315
1331
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
|
1316
1332
|
? //@ts-ignore
|
|
1317
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()) +
|
|
@@ -1388,14 +1404,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1388
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 }));
|
|
1389
1405
|
}
|
|
1390
1406
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1391
|
-
React__default["default"].createElement(material.TextField, Object.assign({ fullWidth: true,
|
|
1407
|
+
React__default["default"].createElement(material.TextField, Object.assign({ fullWidth: true, inputProps: {
|
|
1392
1408
|
disabled: !!filterChipLabel,
|
|
1393
1409
|
sx: {
|
|
1394
1410
|
textOverflow: 'ellipsis',
|
|
1395
1411
|
width: filterChipLabel ? 0 : undefined,
|
|
1396
1412
|
},
|
|
1397
1413
|
title: filterPlaceholder,
|
|
1398
|
-
}, helperText: showChangeModeButton ? (React__default["default"].createElement("label",
|
|
1414
|
+
}, helperText: showChangeModeButton ? (React__default["default"].createElement("label", null, localization.filterMode.replace('{filterType}',
|
|
1399
1415
|
// @ts-ignore
|
|
1400
1416
|
localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
|
|
1401
1417
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
|
|
@@ -1427,7 +1443,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1427
1443
|
renderValue: isMultiSelectFilter
|
|
1428
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 })))))
|
|
1429
1445
|
: undefined,
|
|
1430
|
-
} }, 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': {
|
|
1431
1453
|
mr: '1.5rem',
|
|
1432
1454
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1433
1455
|
? textFieldProps.sx(theme)
|
|
@@ -1739,19 +1761,21 @@ const MRT_TableHead = ({ table }) => {
|
|
|
1739
1761
|
return (React__default["default"].createElement(material.TableHead, Object.assign({}, tableHeadProps), getHeaderGroups().map((headerGroup) => (React__default["default"].createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
|
|
1740
1762
|
};
|
|
1741
1763
|
|
|
1742
|
-
const MRT_EditCellTextField = ({ cell, table }) => {
|
|
1764
|
+
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
1743
1765
|
var _a;
|
|
1744
|
-
const { getState, options: {
|
|
1766
|
+
const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
|
|
1745
1767
|
const { column, row } = cell;
|
|
1746
1768
|
const { columnDef } = column;
|
|
1747
1769
|
const { editingRow } = getState();
|
|
1748
1770
|
const [value, setValue] = React.useState(() => cell.getValue());
|
|
1749
1771
|
const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1750
|
-
? muiTableBodyCellEditTextFieldProps({ cell, table })
|
|
1772
|
+
? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
|
|
1751
1773
|
: muiTableBodyCellEditTextFieldProps;
|
|
1752
1774
|
const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1753
1775
|
? columnDef.muiTableBodyCellEditTextFieldProps({
|
|
1754
1776
|
cell,
|
|
1777
|
+
column,
|
|
1778
|
+
row,
|
|
1755
1779
|
table,
|
|
1756
1780
|
})
|
|
1757
1781
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
@@ -1765,22 +1789,26 @@ const MRT_EditCellTextField = ({ cell, table }) => {
|
|
|
1765
1789
|
var _a;
|
|
1766
1790
|
(_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1767
1791
|
if (editingRow) {
|
|
1768
|
-
|
|
1769
|
-
row._valuesCache = {};
|
|
1770
|
-
row._valuesCache[column.id] = value;
|
|
1771
|
-
setEditingRow(Object.assign({}, editingRow));
|
|
1792
|
+
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: value }) }));
|
|
1772
1793
|
}
|
|
1773
1794
|
setEditingCell(null);
|
|
1774
1795
|
};
|
|
1775
1796
|
if (columnDef.Edit) {
|
|
1776
|
-
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 }));
|
|
1797
|
+
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 }));
|
|
1777
1798
|
}
|
|
1778
|
-
return (React__default["default"].createElement(material.TextField, Object.assign({
|
|
1799
|
+
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) => {
|
|
1800
|
+
if (inputRef) {
|
|
1801
|
+
editInputRefs.current[column.id] = inputRef;
|
|
1802
|
+
if (textFieldProps.inputRef) {
|
|
1803
|
+
textFieldProps.inputRef = inputRef;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1779
1807
|
};
|
|
1780
1808
|
|
|
1781
1809
|
const MRT_CopyButton = ({ cell, children, table }) => {
|
|
1782
1810
|
const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
|
|
1783
|
-
const { column } = cell;
|
|
1811
|
+
const { column, row } = cell;
|
|
1784
1812
|
const { columnDef } = column;
|
|
1785
1813
|
const [copied, setCopied] = React.useState(false);
|
|
1786
1814
|
const handleCopy = (text) => {
|
|
@@ -1789,7 +1817,7 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1789
1817
|
setTimeout(() => setCopied(false), 4000);
|
|
1790
1818
|
};
|
|
1791
1819
|
const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
|
|
1792
|
-
? muiTableBodyCellCopyButtonProps({ cell, table })
|
|
1820
|
+
? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
|
|
1793
1821
|
: muiTableBodyCellCopyButtonProps;
|
|
1794
1822
|
const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
|
|
1795
1823
|
? columnDef.muiTableBodyCellCopyButtonProps({
|
|
@@ -1806,12 +1834,13 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1806
1834
|
|
|
1807
1835
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
1808
1836
|
const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
|
|
1837
|
+
const { row } = cell;
|
|
1809
1838
|
const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
|
|
1810
|
-
? muiTableBodyRowDragHandleProps({ row
|
|
1839
|
+
? muiTableBodyRowDragHandleProps({ row, table })
|
|
1811
1840
|
: muiTableBodyRowDragHandleProps;
|
|
1812
1841
|
const handleDragStart = (e) => {
|
|
1813
1842
|
e.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1814
|
-
table.setDraggingRow(
|
|
1843
|
+
table.setDraggingRow(row);
|
|
1815
1844
|
};
|
|
1816
1845
|
const handleDragEnd = (event) => {
|
|
1817
1846
|
onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
|
|
@@ -1828,13 +1857,13 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1828
1857
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1829
1858
|
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
1830
1859
|
const theme = material.useTheme();
|
|
1831
|
-
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode,
|
|
1860
|
+
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
|
1832
1861
|
const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
|
|
1833
1862
|
const { column, row } = cell;
|
|
1834
1863
|
const { columnDef } = column;
|
|
1835
1864
|
const { columnDefType } = columnDef;
|
|
1836
1865
|
const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
|
|
1837
|
-
? muiTableBodyCellProps({ cell, table })
|
|
1866
|
+
? muiTableBodyCellProps({ cell, column, row, table })
|
|
1838
1867
|
: muiTableBodyCellProps;
|
|
1839
1868
|
const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
|
|
1840
1869
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
@@ -1843,6 +1872,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1843
1872
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1844
1873
|
columnDef.enableEditing !== false;
|
|
1845
1874
|
const isEditing = isEditable &&
|
|
1875
|
+
editingMode !== 'modal' &&
|
|
1846
1876
|
(editingMode === 'table' ||
|
|
1847
1877
|
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
|
|
1848
1878
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id);
|
|
@@ -1858,13 +1888,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1858
1888
|
columnDef.enableEditing !== false &&
|
|
1859
1889
|
editingMode === 'cell') {
|
|
1860
1890
|
setEditingCell(cell);
|
|
1861
|
-
|
|
1862
|
-
const textField =
|
|
1891
|
+
queueMicrotask(() => {
|
|
1892
|
+
const textField = editInputRefs.current[column.id];
|
|
1863
1893
|
if (textField) {
|
|
1864
1894
|
textField.focus();
|
|
1865
1895
|
textField.select();
|
|
1866
1896
|
}
|
|
1867
|
-
}
|
|
1897
|
+
});
|
|
1868
1898
|
}
|
|
1869
1899
|
};
|
|
1870
1900
|
const getIsLastLeftPinnedColumn = () => {
|
|
@@ -1940,10 +1970,10 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1940
1970
|
backgroundColor: enableHover &&
|
|
1941
1971
|
enableEditing &&
|
|
1942
1972
|
columnDef.enableEditing !== false &&
|
|
1943
|
-
editingMode !== '
|
|
1973
|
+
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
1944
1974
|
? theme.palette.mode === 'dark'
|
|
1945
|
-
? `${material.lighten(theme.palette.background.default, 0.
|
|
1946
|
-
: `${material.darken(theme.palette.background.default, 0.
|
|
1975
|
+
? `${material.lighten(theme.palette.background.default, 0.2)} !important`
|
|
1976
|
+
: `${material.darken(theme.palette.background.default, 0.1)} !important`
|
|
1947
1977
|
: undefined,
|
|
1948
1978
|
} }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
1949
1979
|
? tableCellProps.sx(theme)
|
|
@@ -1954,19 +1984,19 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1954
1984
|
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' &&
|
|
1955
1985
|
(column.id === 'mrt-row-select' ||
|
|
1956
1986
|
column.id === 'mrt-row-expand' ||
|
|
1957
|
-
!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) &&
|
|
1987
|
+
!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) &&
|
|
1958
1988
|
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1959
1989
|
React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
|
|
1960
1990
|
React__default["default"].createElement(React__default["default"].Fragment, null, row.getIsGrouped() && !cell.getIsGrouped()
|
|
1961
1991
|
? null
|
|
1962
|
-
: (_c = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, table })) !== null && _c !== void 0 ? _c : cell.renderValue())),
|
|
1992
|
+
: (_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())),
|
|
1963
1993
|
cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1964
1994
|
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
|
1965
1995
|
_d.length,
|
|
1966
1996
|
")"))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1967
1997
|
row.getIsGrouped() && !cell.getIsGrouped()
|
|
1968
1998
|
? null
|
|
1969
|
-
: (_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(),
|
|
1999
|
+
: (_g = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _f === void 0 ? void 0 : _f.call(columnDef, { cell, column, row, table })) !== null && _g !== void 0 ? _g : cell.renderValue(),
|
|
1970
2000
|
cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1971
2001
|
" (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
|
|
1972
2002
|
")"))))));
|
|
@@ -2019,7 +2049,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
|
2019
2049
|
: undefined,
|
|
2020
2050
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2021
2051
|
? tableRowProps.sx(theme)
|
|
2022
|
-
: 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,
|
|
2052
|
+
: 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 })))),
|
|
2023
2053
|
renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2024
2054
|
};
|
|
2025
2055
|
|
|
@@ -2167,25 +2197,29 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2167
2197
|
|
|
2168
2198
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
2169
2199
|
const MRT_TableContainer = ({ table }) => {
|
|
2170
|
-
|
|
2171
|
-
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, tableId, }, } = table;
|
|
2200
|
+
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
|
|
2172
2201
|
const { isFullScreen } = getState();
|
|
2173
2202
|
const [totalToolbarHeight, setTotalToolbarHeight] = React.useState(0);
|
|
2174
2203
|
const tableContainerProps = muiTableContainerProps instanceof Function
|
|
2175
2204
|
? muiTableContainerProps({ table })
|
|
2176
2205
|
: muiTableContainerProps;
|
|
2177
|
-
const tableContainerRef = (_a = tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) !== null && _a !== void 0 ? _a : React.useRef(null);
|
|
2178
2206
|
useIsomorphicLayoutEffect(() => {
|
|
2179
2207
|
var _a, _b, _c, _d;
|
|
2180
2208
|
const topToolbarHeight = typeof document !== 'undefined'
|
|
2181
|
-
? (_b = (_a =
|
|
2209
|
+
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
|
2182
2210
|
: 0;
|
|
2183
2211
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
|
2184
|
-
? (_d = (_c =
|
|
2212
|
+
? (_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
|
|
2185
2213
|
: 0;
|
|
2186
2214
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
|
2187
2215
|
});
|
|
2188
|
-
return (React__default["default"].createElement(material.TableContainer, Object.assign({
|
|
2216
|
+
return (React__default["default"].createElement(material.TableContainer, Object.assign({}, tableContainerProps, { ref: (ref) => {
|
|
2217
|
+
tableContainerRef.current = ref;
|
|
2218
|
+
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
|
2219
|
+
//@ts-ignore
|
|
2220
|
+
tableContainerProps.ref.current = ref;
|
|
2221
|
+
}
|
|
2222
|
+
}, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
|
|
2189
2223
|
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
|
2190
2224
|
: undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
|
|
2191
2225
|
? tableContainerProps.sx(theme)
|
|
@@ -2217,10 +2251,32 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2217
2251
|
enableBottomToolbar && React__default["default"].createElement(MRT_BottomToolbar, { table: table })));
|
|
2218
2252
|
};
|
|
2219
2253
|
|
|
2254
|
+
const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
2255
|
+
const { options: { localization }, } = table;
|
|
2256
|
+
return (React__default["default"].createElement(material.Dialog, { open: open },
|
|
2257
|
+
React__default["default"].createElement(material.DialogTitle, { textAlign: "center" }, localization.edit),
|
|
2258
|
+
React__default["default"].createElement(material.DialogContent, null,
|
|
2259
|
+
React__default["default"].createElement("form", { onSubmit: (e) => e.preventDefault() },
|
|
2260
|
+
React__default["default"].createElement(material.Stack, { sx: {
|
|
2261
|
+
width: '100%',
|
|
2262
|
+
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
2263
|
+
gap: '1.5rem',
|
|
2264
|
+
} }, row
|
|
2265
|
+
.getAllCells()
|
|
2266
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
2267
|
+
.map((cell) => (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, key: cell.id, showLabel: true, table: table })))))),
|
|
2268
|
+
React__default["default"].createElement(material.DialogActions, { sx: { p: '1.25rem' } },
|
|
2269
|
+
React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table, variant: "text" }))));
|
|
2270
|
+
};
|
|
2271
|
+
|
|
2220
2272
|
const MRT_TableRoot = (props) => {
|
|
2221
|
-
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;
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2273
|
+
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;
|
|
2274
|
+
const bottomToolbarRef = React.useRef(null);
|
|
2275
|
+
const editInputRefs = React.useRef({});
|
|
2276
|
+
const filterInputRefs = React.useRef({});
|
|
2277
|
+
const searchInputRef = React.useRef(null);
|
|
2278
|
+
const tableContainerRef = React.useRef(null);
|
|
2279
|
+
const topToolbarRef = React.useRef(null);
|
|
2224
2280
|
const initialState = React.useMemo(() => {
|
|
2225
2281
|
var _a, _b;
|
|
2226
2282
|
const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
|
|
@@ -2247,23 +2303,26 @@ const MRT_TableRoot = (props) => {
|
|
|
2247
2303
|
const [editingCell, setEditingCell] = React.useState((_e = initialState.editingCell) !== null && _e !== void 0 ? _e : null);
|
|
2248
2304
|
const [editingRow, setEditingRow] = React.useState((_f = initialState.editingRow) !== null && _f !== void 0 ? _f : null);
|
|
2249
2305
|
const [globalFilterFn, setGlobalFilterFn] = React.useState((_g = initialState.globalFilterFn) !== null && _g !== void 0 ? _g : 'fuzzy');
|
|
2250
|
-
const [
|
|
2251
|
-
const [
|
|
2252
|
-
const [
|
|
2253
|
-
const [
|
|
2254
|
-
const [
|
|
2255
|
-
const [
|
|
2306
|
+
const [grouping, setGrouping] = React.useState((_h = initialState.grouping) !== null && _h !== void 0 ? _h : []);
|
|
2307
|
+
const [hoveredColumn, setHoveredColumn] = React.useState((_j = initialState.hoveredColumn) !== null && _j !== void 0 ? _j : null);
|
|
2308
|
+
const [hoveredRow, setHoveredRow] = React.useState((_k = initialState.hoveredRow) !== null && _k !== void 0 ? _k : null);
|
|
2309
|
+
const [isFullScreen, setIsFullScreen] = React.useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _l !== void 0 ? _l : false);
|
|
2310
|
+
const [showAlertBanner, setShowAlertBanner] = React.useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
|
|
2311
|
+
const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2312
|
+
const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2256
2313
|
const displayColumns = React.useMemo(() => {
|
|
2257
2314
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2258
2315
|
return [
|
|
2259
2316
|
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' }),
|
|
2260
|
-
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({
|
|
2261
|
-
columnOrder.includes('mrt-row-expand') &&
|
|
2262
|
-
|
|
2263
|
-
columnOrder.includes('mrt-row-
|
|
2317
|
+
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, { 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' }),
|
|
2318
|
+
columnOrder.includes('mrt-row-expand') &&
|
|
2319
|
+
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' }),
|
|
2320
|
+
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' }),
|
|
2321
|
+
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' }),
|
|
2264
2322
|
].filter(Boolean);
|
|
2265
2323
|
}, [
|
|
2266
2324
|
columnOrder,
|
|
2325
|
+
grouping,
|
|
2267
2326
|
props.displayColumnDefOptions,
|
|
2268
2327
|
props.editingMode,
|
|
2269
2328
|
props.enableColumnDragging,
|
|
@@ -2280,6 +2339,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2280
2339
|
props.enableSelectAll,
|
|
2281
2340
|
props.localization,
|
|
2282
2341
|
props.positionActionsColumn,
|
|
2342
|
+
props.renderDetailPanel,
|
|
2283
2343
|
]);
|
|
2284
2344
|
const columnDefs = React.useMemo(() => prepareColumns([...displayColumns, ...props.columns], columnFilterFns, props.filterFns, props.sortingFns), [columnFilterFns, displayColumns, props.columns]);
|
|
2285
2345
|
const data = React.useMemo(() => {
|
|
@@ -2297,11 +2357,11 @@ const MRT_TableRoot = (props) => {
|
|
|
2297
2357
|
});
|
|
2298
2358
|
})))
|
|
2299
2359
|
: props.data;
|
|
2300
|
-
}, [props.data, (
|
|
2360
|
+
}, [props.data, (_r = props.state) === null || _r === void 0 ? void 0 : _r.isLoading, (_s = props.state) === null || _s === void 0 ? void 0 : _s.showSkeletons]);
|
|
2301
2361
|
//@ts-ignore
|
|
2302
|
-
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), {
|
|
2362
|
+
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), {
|
|
2303
2363
|
//@ts-ignore
|
|
2304
|
-
columns: columnDefs, data, globalFilterFn: (
|
|
2364
|
+
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,
|
|
2305
2365
|
columnOrder,
|
|
2306
2366
|
density,
|
|
2307
2367
|
draggingColumn,
|
|
@@ -2309,20 +2369,29 @@ const MRT_TableRoot = (props) => {
|
|
|
2309
2369
|
editingCell,
|
|
2310
2370
|
editingRow,
|
|
2311
2371
|
globalFilterFn,
|
|
2372
|
+
grouping,
|
|
2312
2373
|
hoveredColumn,
|
|
2313
2374
|
hoveredRow,
|
|
2314
2375
|
isFullScreen,
|
|
2315
2376
|
showAlertBanner,
|
|
2316
2377
|
showColumnFilters,
|
|
2317
|
-
showGlobalFilter }, props.state)
|
|
2378
|
+
showGlobalFilter }, props.state) }))), { refs: {
|
|
2379
|
+
bottomToolbarRef,
|
|
2380
|
+
editInputRefs,
|
|
2381
|
+
filterInputRefs,
|
|
2382
|
+
searchInputRef,
|
|
2383
|
+
tableContainerRef,
|
|
2384
|
+
topToolbarRef,
|
|
2385
|
+
}, 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 });
|
|
2318
2386
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2319
2387
|
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 },
|
|
2320
2388
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2321
|
-
!isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table })
|
|
2389
|
+
!isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
|
|
2390
|
+
editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2322
2391
|
};
|
|
2323
2392
|
|
|
2324
2393
|
var MaterialReactTable = (_a) => {
|
|
2325
|
-
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = '
|
|
2394
|
+
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"]);
|
|
2326
2395
|
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)));
|
|
2327
2396
|
};
|
|
2328
2397
|
|