material-react-table 0.36.0 → 0.37.0

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.
Files changed (33) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/MaterialReactTable.d.ts +33 -15
  3. package/dist/cjs/body/MRT_EditRowModal.d.ts +8 -0
  4. package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +5 -5
  5. package/dist/cjs/index.js +181 -108
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +5 -5
  8. package/dist/esm/MaterialReactTable.d.ts +33 -15
  9. package/dist/esm/body/MRT_EditRowModal.d.ts +8 -0
  10. package/dist/esm/buttons/MRT_EditActionButtons.d.ts +5 -5
  11. package/dist/esm/inputs/MRT_EditCellTextField.d.ts +5 -5
  12. package/dist/esm/material-react-table.esm.js +182 -109
  13. package/dist/esm/material-react-table.esm.js.map +1 -1
  14. package/dist/index.d.ts +33 -15
  15. package/package.json +1 -1
  16. package/src/MaterialReactTable.tsx +48 -12
  17. package/src/body/MRT_EditRowModal.tsx +59 -0
  18. package/src/body/MRT_TableBodyCell.tsx +22 -18
  19. package/src/body/MRT_TableBodyRow.tsx +1 -1
  20. package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
  21. package/src/buttons/MRT_CopyButton.tsx +2 -2
  22. package/src/buttons/MRT_EditActionButtons.tsx +49 -25
  23. package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
  24. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +2 -1
  25. package/src/column.utils.ts +6 -5
  26. package/src/inputs/MRT_EditCellTextField.tsx +33 -19
  27. package/src/inputs/MRT_FilterTextField.tsx +9 -6
  28. package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -2
  29. package/src/menus/MRT_ColumnActionMenu.tsx +2 -12
  30. package/src/table/MRT_TableContainer.tsx +10 -10
  31. package/src/table/MRT_TableRoot.tsx +26 -18
  32. package/src/toolbar/MRT_BottomToolbar.tsx +8 -2
  33. 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
- //@ts-ignore
514
- columnDef._filterFn = columnFilterFns[columnDef.id];
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,37 @@ 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 getLeadingDisplayColumnIds = (props) => [
534
- (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
535
- ((props.positionActionsColumn === 'first' && props.enableRowActions) ||
536
- (props.enableEditing && props.editingMode === 'row')) &&
537
- 'mrt-row-actions',
538
- props.positionExpandColumn === 'first' &&
539
- (props.enableExpanding ||
540
- props.enableGrouping ||
541
- props.renderDetailPanel) &&
542
- 'mrt-row-expand',
543
- props.enableRowSelection && 'mrt-row-select',
544
- props.enableRowNumbers && 'mrt-row-numbers',
545
- ].filter(Boolean);
546
- const getTrailingDisplayColumnIds = (props) => [
547
- ((props.positionActionsColumn === 'last' && props.enableRowActions) ||
548
- (props.enableEditing && props.editingMode === 'row')) &&
549
- 'mrt-row-actions',
550
- props.positionExpandColumn === 'last' &&
551
- (props.enableExpanding ||
552
- props.enableGrouping ||
553
- props.renderDetailPanel) &&
554
- 'mrt-row-expand',
555
- ];
532
+ const getLeadingDisplayColumnIds = (props) => {
533
+ var _a;
534
+ return [
535
+ (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
536
+ ((props.positionActionsColumn === 'first' && props.enableRowActions) ||
537
+ (props.enableEditing &&
538
+ ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
539
+ 'mrt-row-actions',
540
+ props.positionExpandColumn === 'first' &&
541
+ (props.enableExpanding ||
542
+ props.enableGrouping ||
543
+ props.renderDetailPanel) &&
544
+ 'mrt-row-expand',
545
+ props.enableRowSelection && 'mrt-row-select',
546
+ props.enableRowNumbers && 'mrt-row-numbers',
547
+ ].filter(Boolean);
548
+ };
549
+ const getTrailingDisplayColumnIds = (props) => {
550
+ var _a;
551
+ return [
552
+ ((props.positionActionsColumn === 'last' && props.enableRowActions) ||
553
+ (props.enableEditing &&
554
+ ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
555
+ 'mrt-row-actions',
556
+ props.positionExpandColumn === 'last' &&
557
+ (props.enableExpanding ||
558
+ props.enableGrouping ||
559
+ props.renderDetailPanel) &&
560
+ 'mrt-row-expand',
561
+ ];
562
+ };
556
563
  const getDefaultColumnOrderIds = (props) => [
557
564
  ...getLeadingDisplayColumnIds(props),
558
565
  ...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
@@ -704,7 +711,7 @@ const commonListItemStyles = {
704
711
  };
705
712
  const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
706
713
  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, }, tableId, localization, }, setShowFilters, } = table;
714
+ 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
715
  const { column } = header;
709
716
  const { columnDef } = column;
710
717
  const { columnSizing, columnVisibility, density } = getState();
@@ -745,13 +752,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
745
752
  };
746
753
  const handleFilterByColumn = () => {
747
754
  setShowFilters(true);
748
- setTimeout(() => {
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);
755
+ queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
755
756
  setAnchorEl(null);
756
757
  };
757
758
  const handleShowAllColumns = () => {
@@ -881,29 +882,36 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
881
882
  })));
882
883
  };
883
884
 
884
- const MRT_EditActionButtons = ({ row, table }) => {
885
- const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
885
+ const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
886
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, refs: { editInputRefs }, setEditingRow, } = table;
886
887
  const { editingRow } = getState();
887
- const handleCancel = () => {
888
- row._valuesCache = Object.assign({}, row.original);
889
- setEditingRow(null);
890
- };
888
+ const handleCancel = () => setEditingRow(null);
891
889
  const handleSave = () => {
892
- var _a;
890
+ var _a, _b;
891
+ //look for auto-filled input values
892
+ (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
893
+ if (input.value !== undefined &&
894
+ Object.hasOwn(editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache, input.name)) {
895
+ // @ts-ignore
896
+ editingRow._valuesCache[input.name] = input.value;
897
+ }
898
+ });
893
899
  onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
900
+ exitEditingMode: () => setEditingRow(null),
894
901
  row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
895
902
  table,
896
- values: (_a = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _a !== void 0 ? _a : Object.assign({}, row.original),
903
+ values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
897
904
  });
898
- setEditingRow(null);
899
905
  };
900
- return (React__default["default"].createElement(material.Box, { sx: { display: 'flex', gap: '0.75rem' } },
906
+ 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
907
  React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.cancel },
902
908
  React__default["default"].createElement(material.IconButton, { "aria-label": localization.cancel, onClick: handleCancel },
903
909
  React__default["default"].createElement(CancelIcon, null))),
904
910
  React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.save },
905
911
  React__default["default"].createElement(material.IconButton, { "aria-label": localization.save, color: "info", onClick: handleSave },
906
- React__default["default"].createElement(SaveIcon, null)))));
912
+ React__default["default"].createElement(SaveIcon, null))))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
913
+ React__default["default"].createElement(material.Button, { onClick: handleCancel }, localization.cancel),
914
+ React__default["default"].createElement(material.Button, { onClick: handleSave, variant: "contained" }, localization.save)))));
907
915
  };
908
916
 
909
917
  const commonIconButtonStyles = {
@@ -917,7 +925,7 @@ const commonIconButtonStyles = {
917
925
  },
918
926
  };
919
927
  const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
920
- const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
928
+ const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
921
929
  const { editingRow } = getState();
922
930
  const [anchorEl, setAnchorEl] = React.useState(null);
923
931
  const handleOpenRowActionMenu = (event) => {
@@ -929,7 +937,7 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
929
937
  setEditingRow(Object.assign({}, row));
930
938
  setAnchorEl(null);
931
939
  };
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 },
940
+ 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
941
  React__default["default"].createElement(material.IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
934
942
  React__default["default"].createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React__default["default"].createElement(React__default["default"].Fragment, null,
935
943
  React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
@@ -964,7 +972,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
964
972
 
965
973
  const MRT_GlobalFilterTextField = ({ table, }) => {
966
974
  var _a;
967
- const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, tableId, }, } = table;
975
+ const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
968
976
  const { globalFilter, showGlobalFilter } = getState();
969
977
  const [anchorEl, setAnchorEl] = React.useState(null);
970
978
  const [searchValue, setSearchValue] = React.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
@@ -987,7 +995,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
987
995
  ? muiSearchTextFieldProps({ table })
988
996
  : muiSearchTextFieldProps;
989
997
  return (React__default["default"].createElement(material.Collapse, { in: showGlobalFilter, orientation: "horizontal" },
990
- React__default["default"].createElement(material.TextField, Object.assign({ id: `mrt-${tableId}-search-text-field`, placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
998
+ React__default["default"].createElement(material.TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
991
999
  startAdornment: enableGlobalFilterChangeMode ? (React__default["default"].createElement(material.InputAdornment, { position: "start" },
992
1000
  React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.changeSearchMode },
993
1001
  React__default["default"].createElement(material.IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' } },
@@ -997,7 +1005,12 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
997
1005
  React__default["default"].createElement("span", null,
998
1006
  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
1007
  React__default["default"].createElement(CloseIcon, null)))))),
1000
- } }, textFieldProps)),
1008
+ } }, textFieldProps, { inputRef: (inputRef) => {
1009
+ searchInputRef.current = inputRef;
1010
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
1011
+ textFieldProps.inputRef = inputRef;
1012
+ }
1013
+ } })),
1001
1014
  React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
1002
1015
  };
1003
1016
 
@@ -1122,18 +1135,11 @@ const MRT_ToggleFiltersButton = (_a) => {
1122
1135
 
1123
1136
  const MRT_ToggleGlobalFilterButton = (_a) => {
1124
1137
  var { table } = _a, rest = __rest(_a, ["table"]);
1125
- const { getState, options: { icons: { SearchIcon, SearchOffIcon }, tableId, localization, muiSearchTextFieldProps, }, setShowGlobalFilter, } = table;
1138
+ const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
1126
1139
  const { showGlobalFilter } = getState();
1127
- const textFieldProps = muiSearchTextFieldProps instanceof Function
1128
- ? muiSearchTextFieldProps({ table })
1129
- : muiSearchTextFieldProps;
1130
1140
  const handleToggleSearch = () => {
1131
1141
  setShowGlobalFilter(!showGlobalFilter);
1132
- setTimeout(() => {
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);
1142
+ queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
1137
1143
  };
1138
1144
  return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.showHideSearch },
1139
1145
  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 +1198,20 @@ const commonToolbarStyles = ({ theme }) => ({
1192
1198
  });
1193
1199
  const MRT_TopToolbar = ({ table }) => {
1194
1200
  var _a;
1195
- const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, tableId, }, } = table;
1201
+ const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
1196
1202
  const { isFullScreen, showGlobalFilter } = getState();
1197
1203
  const isMobile = material.useMediaQuery('(max-width:720px)');
1198
1204
  const toolbarProps = muiTableTopToolbarProps instanceof Function
1199
1205
  ? muiTableTopToolbarProps({ table })
1200
1206
  : muiTableTopToolbarProps;
1201
1207
  const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
1202
- return (React__default["default"].createElement(material.Toolbar, Object.assign({ id: `mrt-${tableId}-toolbar-top`, variant: "dense" }, toolbarProps, { 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
1208
+ return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
1209
+ topToolbarRef.current = ref;
1210
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
1211
+ // @ts-ignore
1212
+ toolbarProps.ref.current = ref;
1213
+ }
1214
+ }, 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
1215
  ? toolbarProps.sx(theme)
1204
1216
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1205
1217
  positionToolbarAlertBanner === 'top' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
@@ -1224,14 +1236,20 @@ const MRT_TopToolbar = ({ table }) => {
1224
1236
  };
1225
1237
 
1226
1238
  const MRT_BottomToolbar = ({ table }) => {
1227
- const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, tableId, }, } = table;
1239
+ const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
1228
1240
  const { isFullScreen } = getState();
1229
1241
  const isMobile = material.useMediaQuery('(max-width:720px)');
1230
1242
  const toolbarProps = muiTableBottomToolbarProps instanceof Function
1231
1243
  ? muiTableBottomToolbarProps({ table })
1232
1244
  : muiTableBottomToolbarProps;
1233
1245
  const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
1234
- return (React__default["default"].createElement(material.Toolbar, Object.assign({ id: `mrt-${tableId}-toolbar-bottom`, variant: "dense" }, toolbarProps, { 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
1246
+ return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
1247
+ bottomToolbarRef.current = ref;
1248
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
1249
+ // @ts-ignore
1250
+ toolbarProps.ref.current = ref;
1251
+ }
1252
+ }, 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
1253
  ? toolbarProps.sx(theme)
1236
1254
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1237
1255
  React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
@@ -1286,7 +1304,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
1286
1304
 
1287
1305
  const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1288
1306
  var _a, _b, _c, _d, _e, _f, _g, _h;
1289
- const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, tableId, }, setColumnFilterFns, } = table;
1307
+ const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
1290
1308
  const { column } = header;
1291
1309
  const { columnDef } = column;
1292
1310
  const { columnFilterFns } = getState();
@@ -1311,7 +1329,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1311
1329
  const isTextboxFilter = columnDef.filterVariant === 'text' ||
1312
1330
  (!isSelectFilter && !isMultiSelectFilter);
1313
1331
  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
1332
  const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
1316
1333
  ? //@ts-ignore
1317
1334
  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 +1405,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1388
1405
  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
1406
  }
1390
1407
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
1391
- React__default["default"].createElement(material.TextField, Object.assign({ fullWidth: true, id: filterId, inputProps: {
1408
+ React__default["default"].createElement(material.TextField, Object.assign({ fullWidth: true, inputProps: {
1392
1409
  disabled: !!filterChipLabel,
1393
1410
  sx: {
1394
1411
  textOverflow: 'ellipsis',
1395
1412
  width: filterChipLabel ? 0 : undefined,
1396
1413
  },
1397
1414
  title: filterPlaceholder,
1398
- }, helperText: showChangeModeButton ? (React__default["default"].createElement("label", { htmlFor: filterId }, localization.filterMode.replace('{filterType}',
1415
+ }, helperText: showChangeModeButton ? (React__default["default"].createElement("label", null, localization.filterMode.replace('{filterType}',
1399
1416
  // @ts-ignore
1400
1417
  localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
1401
1418
  (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
@@ -1427,7 +1444,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1427
1444
  renderValue: isMultiSelectFilter
1428
1445
  ? (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
1446
  : undefined,
1430
- } }, textFieldProps, { sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
1447
+ } }, textFieldProps, { inputRef: (inputRef) => {
1448
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
1449
+ inputRef;
1450
+ if (textFieldProps.inputRef) {
1451
+ textFieldProps.inputRef = inputRef;
1452
+ }
1453
+ }, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
1431
1454
  mr: '1.5rem',
1432
1455
  } }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
1433
1456
  ? textFieldProps.sx(theme)
@@ -1739,19 +1762,21 @@ const MRT_TableHead = ({ table }) => {
1739
1762
  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
1763
  };
1741
1764
 
1742
- const MRT_EditCellTextField = ({ cell, table }) => {
1765
+ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
1743
1766
  var _a;
1744
- const { getState, options: { tableId, muiTableBodyCellEditTextFieldProps }, setEditingCell, setEditingRow, } = table;
1767
+ const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
1745
1768
  const { column, row } = cell;
1746
1769
  const { columnDef } = column;
1747
1770
  const { editingRow } = getState();
1748
1771
  const [value, setValue] = React.useState(() => cell.getValue());
1749
1772
  const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
1750
- ? muiTableBodyCellEditTextFieldProps({ cell, table })
1773
+ ? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
1751
1774
  : muiTableBodyCellEditTextFieldProps;
1752
1775
  const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
1753
1776
  ? columnDef.muiTableBodyCellEditTextFieldProps({
1754
1777
  cell,
1778
+ column,
1779
+ row,
1755
1780
  table,
1756
1781
  })
1757
1782
  : columnDef.muiTableBodyCellEditTextFieldProps;
@@ -1765,22 +1790,26 @@ const MRT_EditCellTextField = ({ cell, table }) => {
1765
1790
  var _a;
1766
1791
  (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
1767
1792
  if (editingRow) {
1768
- if (!row._valuesCache)
1769
- row._valuesCache = {};
1770
- row._valuesCache[column.id] = value;
1771
- setEditingRow(Object.assign({}, editingRow));
1793
+ setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: value }) }));
1772
1794
  }
1773
1795
  setEditingCell(null);
1774
1796
  };
1775
1797
  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 }));
1798
+ 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
1799
  }
1778
- return (React__default["default"].createElement(material.TextField, Object.assign({ id: `mrt-${tableId}-edit-cell-text-field-${cell.id}`, margin: "none", onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onBlur: handleBlur, onChange: handleChange })));
1800
+ 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) => {
1801
+ if (inputRef) {
1802
+ editInputRefs.current[column.id] = inputRef;
1803
+ if (textFieldProps.inputRef) {
1804
+ textFieldProps.inputRef = inputRef;
1805
+ }
1806
+ }
1807
+ }, onBlur: handleBlur, onChange: handleChange })));
1779
1808
  };
1780
1809
 
1781
1810
  const MRT_CopyButton = ({ cell, children, table }) => {
1782
1811
  const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
1783
- const { column } = cell;
1812
+ const { column, row } = cell;
1784
1813
  const { columnDef } = column;
1785
1814
  const [copied, setCopied] = React.useState(false);
1786
1815
  const handleCopy = (text) => {
@@ -1789,7 +1818,7 @@ const MRT_CopyButton = ({ cell, children, table }) => {
1789
1818
  setTimeout(() => setCopied(false), 4000);
1790
1819
  };
1791
1820
  const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
1792
- ? muiTableBodyCellCopyButtonProps({ cell, table })
1821
+ ? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
1793
1822
  : muiTableBodyCellCopyButtonProps;
1794
1823
  const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
1795
1824
  ? columnDef.muiTableBodyCellCopyButtonProps({
@@ -1806,12 +1835,13 @@ const MRT_CopyButton = ({ cell, children, table }) => {
1806
1835
 
1807
1836
  const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1808
1837
  const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
1838
+ const { row } = cell;
1809
1839
  const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
1810
- ? muiTableBodyRowDragHandleProps({ row: cell.row, table })
1840
+ ? muiTableBodyRowDragHandleProps({ row, table })
1811
1841
  : muiTableBodyRowDragHandleProps;
1812
1842
  const handleDragStart = (e) => {
1813
1843
  e.dataTransfer.setDragImage(rowRef.current, 0, 0);
1814
- table.setDraggingRow(cell.row);
1844
+ table.setDraggingRow(row);
1815
1845
  };
1816
1846
  const handleDragEnd = (event) => {
1817
1847
  onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
@@ -1828,13 +1858,13 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1828
1858
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1829
1859
  var _a, _b, _c, _d, _f, _g, _h, _j;
1830
1860
  const theme = material.useTheme();
1831
- const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, tableId, }, setEditingCell, setHoveredColumn, } = table;
1861
+ const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
1832
1862
  const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
1833
1863
  const { column, row } = cell;
1834
1864
  const { columnDef } = column;
1835
1865
  const { columnDefType } = columnDef;
1836
1866
  const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
1837
- ? muiTableBodyCellProps({ cell, table })
1867
+ ? muiTableBodyCellProps({ cell, column, row, table })
1838
1868
  : muiTableBodyCellProps;
1839
1869
  const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
1840
1870
  ? columnDef.muiTableBodyCellProps({ cell, table })
@@ -1843,6 +1873,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1843
1873
  const isEditable = (enableEditing || columnDef.enableEditing) &&
1844
1874
  columnDef.enableEditing !== false;
1845
1875
  const isEditing = isEditable &&
1876
+ editingMode !== 'modal' &&
1846
1877
  (editingMode === 'table' ||
1847
1878
  (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
1848
1879
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id);
@@ -1858,13 +1889,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1858
1889
  columnDef.enableEditing !== false &&
1859
1890
  editingMode === 'cell') {
1860
1891
  setEditingCell(cell);
1861
- setTimeout(() => {
1862
- const textField = document.getElementById(`mrt-${tableId}-edit-cell-text-field-${cell.id}`);
1892
+ queueMicrotask(() => {
1893
+ const textField = editInputRefs.current[column.id];
1863
1894
  if (textField) {
1864
1895
  textField.focus();
1865
1896
  textField.select();
1866
1897
  }
1867
- }, 200);
1898
+ });
1868
1899
  }
1869
1900
  };
1870
1901
  const getIsLastLeftPinnedColumn = () => {
@@ -1940,10 +1971,10 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1940
1971
  backgroundColor: enableHover &&
1941
1972
  enableEditing &&
1942
1973
  columnDef.enableEditing !== false &&
1943
- editingMode !== 'row'
1974
+ ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
1944
1975
  ? theme.palette.mode === 'dark'
1945
- ? `${material.lighten(theme.palette.background.default, 0.13)} !important`
1946
- : `${material.darken(theme.palette.background.default, 0.07)} !important`
1976
+ ? `${material.lighten(theme.palette.background.default, 0.2)} !important`
1977
+ : `${material.darken(theme.palette.background.default, 0.1)} !important`
1947
1978
  : undefined,
1948
1979
  } }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
1949
1980
  ? tableCellProps.sx(theme)
@@ -1951,14 +1982,22 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1951
1982
  } }),
1952
1983
  React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(material.Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
1953
1984
  rowNumberMode === 'static' &&
1954
- 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' ? ((_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) &&
1985
+ 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' &&
1986
+ (column.id === 'mrt-row-select' ||
1987
+ column.id === 'mrt-row-expand' ||
1988
+ !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) &&
1955
1989
  columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(React__default["default"].Fragment, null,
1956
1990
  React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
1957
- React__default["default"].createElement(React__default["default"].Fragment, null, (_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())),
1991
+ React__default["default"].createElement(React__default["default"].Fragment, null, row.getIsGrouped() && !cell.getIsGrouped()
1992
+ ? null
1993
+ : (_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())),
1958
1994
  cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
1959
1995
  " (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
1960
1996
  _d.length,
1961
- ")"))) : (React__default["default"].createElement(React__default["default"].Fragment, null, (_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(),
1997
+ ")"))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
1998
+ row.getIsGrouped() && !cell.getIsGrouped()
1999
+ ? null
2000
+ : (_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(),
1962
2001
  cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
1963
2002
  " (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
1964
2003
  ")"))))));
@@ -2011,7 +2050,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
2011
2050
  : undefined,
2012
2051
  } }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2013
2052
  ? tableRowProps.sx(theme)
2014
- : 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, key: cell.id, enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false, rowIndex: rowIndex, rowRef: rowRef, table: table })))),
2053
+ : 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 })))),
2015
2054
  renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
2016
2055
  };
2017
2056
 
@@ -2159,25 +2198,29 @@ const MRT_Table = ({ tableContainerRef, table }) => {
2159
2198
 
2160
2199
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
2161
2200
  const MRT_TableContainer = ({ table }) => {
2162
- var _a;
2163
- const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, tableId, }, } = table;
2201
+ const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
2164
2202
  const { isFullScreen } = getState();
2165
2203
  const [totalToolbarHeight, setTotalToolbarHeight] = React.useState(0);
2166
2204
  const tableContainerProps = muiTableContainerProps instanceof Function
2167
2205
  ? muiTableContainerProps({ table })
2168
2206
  : muiTableContainerProps;
2169
- const tableContainerRef = (_a = tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) !== null && _a !== void 0 ? _a : React.useRef(null);
2170
2207
  useIsomorphicLayoutEffect(() => {
2171
2208
  var _a, _b, _c, _d;
2172
2209
  const topToolbarHeight = typeof document !== 'undefined'
2173
- ? (_b = (_a = document === null || document === void 0 ? void 0 : document.getElementById(`mrt-${tableId}-toolbar-top`)) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
2210
+ ? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
2174
2211
  : 0;
2175
2212
  const bottomToolbarHeight = typeof document !== 'undefined'
2176
- ? (_d = (_c = document === null || document === void 0 ? void 0 : document.getElementById(`mrt-${tableId}-toolbar-bottom`)) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
2213
+ ? (_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
2177
2214
  : 0;
2178
2215
  setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
2179
2216
  });
2180
- return (React__default["default"].createElement(material.TableContainer, Object.assign({ ref: tableContainerRef }, tableContainerProps, { sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
2217
+ return (React__default["default"].createElement(material.TableContainer, Object.assign({}, tableContainerProps, { ref: (ref) => {
2218
+ tableContainerRef.current = ref;
2219
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
2220
+ //@ts-ignore
2221
+ tableContainerProps.ref.current = ref;
2222
+ }
2223
+ }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
2181
2224
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
2182
2225
  : undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
2183
2226
  ? tableContainerProps.sx(theme)
@@ -2209,10 +2252,32 @@ const MRT_TablePaper = ({ table }) => {
2209
2252
  enableBottomToolbar && React__default["default"].createElement(MRT_BottomToolbar, { table: table })));
2210
2253
  };
2211
2254
 
2255
+ const MRT_EditRowModal = ({ open, row, table, }) => {
2256
+ const { options: { localization }, } = table;
2257
+ return (React__default["default"].createElement(material.Dialog, { open: open },
2258
+ React__default["default"].createElement(material.DialogTitle, { textAlign: "center" }, localization.edit),
2259
+ React__default["default"].createElement(material.DialogContent, null,
2260
+ React__default["default"].createElement("form", { onSubmit: (e) => e.preventDefault() },
2261
+ React__default["default"].createElement(material.Stack, { sx: {
2262
+ width: '100%',
2263
+ minWidth: { xs: '300px', sm: '360px', md: '400px' },
2264
+ gap: '1.5rem',
2265
+ } }, row
2266
+ .getAllCells()
2267
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
2268
+ .map((cell) => (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, key: cell.id, showLabel: true, table: table })))))),
2269
+ React__default["default"].createElement(material.DialogActions, { sx: { p: '1.25rem' } },
2270
+ React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table, variant: "text" }))));
2271
+ };
2272
+
2212
2273
  const MRT_TableRoot = (props) => {
2213
2274
  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;
2214
- const [tableId, setIdPrefix] = React.useState(props.tableId);
2215
- React.useEffect(() => { var _a; return setIdPrefix((_a = props.tableId) !== null && _a !== void 0 ? _a : Math.random().toString(36).substring(2, 9)); }, [props.tableId]);
2275
+ const bottomToolbarRef = React.useRef(null);
2276
+ const editInputRefs = React.useRef({});
2277
+ const filterInputRefs = React.useRef({});
2278
+ const searchInputRef = React.useRef(null);
2279
+ const tableContainerRef = React.useRef(null);
2280
+ const topToolbarRef = React.useRef(null);
2216
2281
  const initialState = React.useMemo(() => {
2217
2282
  var _a, _b;
2218
2283
  const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
@@ -2249,10 +2314,10 @@ const MRT_TableRoot = (props) => {
2249
2314
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2250
2315
  return [
2251
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' }),
2252
- columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, { row: cell.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' }),
2253
- columnOrder.includes('mrt-row-expand') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React__default["default"].createElement(MRT_ExpandButton, { row: cell.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' }),
2254
- columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React__default["default"].createElement(MRT_SelectCheckbox, { row: cell.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' }),
2255
- columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => cell.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' }),
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') && 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' }),
2319
+ 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' }),
2320
+ 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' }),
2256
2321
  ].filter(Boolean);
2257
2322
  }, [
2258
2323
  columnOrder,
@@ -2306,15 +2371,23 @@ const MRT_TableRoot = (props) => {
2306
2371
  isFullScreen,
2307
2372
  showAlertBanner,
2308
2373
  showColumnFilters,
2309
- showGlobalFilter }, props.state), tableId }))), { setColumnFilterFns: (_v = props.onFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns, setDensity: (_w = props.onDensityChange) !== null && _w !== void 0 ? _w : setDensity, setDraggingColumn: (_x = props.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn, setDraggingRow: (_y = props.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow, setEditingCell: (_z = props.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell, setEditingRow: (_0 = props.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow, setGlobalFilterFn: (_1 = props.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn, setHoveredColumn: (_2 = props.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn, setHoveredRow: (_3 = props.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow, setIsFullScreen: (_4 = props.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen, setShowAlertBanner: (_5 = props.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner, setShowFilters: (_6 = props.onShowFiltersChange) !== null && _6 !== void 0 ? _6 : setShowFilters, setShowGlobalFilter: (_7 = props.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter });
2374
+ showGlobalFilter }, props.state) }))), { refs: {
2375
+ bottomToolbarRef,
2376
+ editInputRefs,
2377
+ filterInputRefs,
2378
+ searchInputRef,
2379
+ tableContainerRef,
2380
+ topToolbarRef,
2381
+ }, setColumnFilterFns: (_v = props.onFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns, setDensity: (_w = props.onDensityChange) !== null && _w !== void 0 ? _w : setDensity, setDraggingColumn: (_x = props.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn, setDraggingRow: (_y = props.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow, setEditingCell: (_z = props.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell, setEditingRow: (_0 = props.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow, setGlobalFilterFn: (_1 = props.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn, setHoveredColumn: (_2 = props.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn, setHoveredRow: (_3 = props.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow, setIsFullScreen: (_4 = props.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen, setShowAlertBanner: (_5 = props.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner, setShowFilters: (_6 = props.onShowFiltersChange) !== null && _6 !== void 0 ? _6 : setShowFilters, setShowGlobalFilter: (_7 = props.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter });
2310
2382
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2311
2383
  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 },
2312
2384
  React__default["default"].createElement(MRT_TablePaper, { table: table })),
2313
- !isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table })));
2385
+ !isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
2386
+ editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
2314
2387
  };
2315
2388
 
2316
2389
  var MaterialReactTable = (_a) => {
2317
- var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = 'row', 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"]);
2390
+ 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"]);
2318
2391
  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)));
2319
2392
  };
2320
2393