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
@@ -2,7 +2,7 @@ import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, use
2
2
  import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
3
3
  import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
4
4
  import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
5
- import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, alpha, useMediaQuery, Toolbar, lighten, ListItemText, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog } from '@mui/material';
5
+ import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, alpha, useMediaQuery, Toolbar, lighten, ListItemText, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
6
6
  import { useVirtual } from 'react-virtual';
7
7
 
8
8
  /******************************************************************************
@@ -500,10 +500,9 @@ const prepareColumns = (columnDefs, columnFilterFns, filterFns, sortingFns) => c
500
500
  else if (columnDef.columnDefType === 'data') {
501
501
  if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
502
502
  columnDef.filterFn =
503
- // @ts-ignore
504
503
  (_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
505
- //@ts-ignore
506
- columnDef._filterFn = columnFilterFns[columnDef.id];
504
+ columnDef._filterFn =
505
+ columnFilterFns[columnDef.id];
507
506
  }
508
507
  if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
509
508
  // @ts-ignore
@@ -522,29 +521,37 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
522
521
  columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
523
522
  return [...columnOrder];
524
523
  };
525
- const getLeadingDisplayColumnIds = (props) => [
526
- (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
527
- ((props.positionActionsColumn === 'first' && props.enableRowActions) ||
528
- (props.enableEditing && props.editingMode === 'row')) &&
529
- 'mrt-row-actions',
530
- props.positionExpandColumn === 'first' &&
531
- (props.enableExpanding ||
532
- props.enableGrouping ||
533
- props.renderDetailPanel) &&
534
- 'mrt-row-expand',
535
- props.enableRowSelection && 'mrt-row-select',
536
- props.enableRowNumbers && 'mrt-row-numbers',
537
- ].filter(Boolean);
538
- const getTrailingDisplayColumnIds = (props) => [
539
- ((props.positionActionsColumn === 'last' && props.enableRowActions) ||
540
- (props.enableEditing && props.editingMode === 'row')) &&
541
- 'mrt-row-actions',
542
- props.positionExpandColumn === 'last' &&
543
- (props.enableExpanding ||
544
- props.enableGrouping ||
545
- props.renderDetailPanel) &&
546
- 'mrt-row-expand',
547
- ];
524
+ const getLeadingDisplayColumnIds = (props) => {
525
+ var _a;
526
+ return [
527
+ (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
528
+ ((props.positionActionsColumn === 'first' && props.enableRowActions) ||
529
+ (props.enableEditing &&
530
+ ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
531
+ 'mrt-row-actions',
532
+ props.positionExpandColumn === 'first' &&
533
+ (props.enableExpanding ||
534
+ props.enableGrouping ||
535
+ props.renderDetailPanel) &&
536
+ 'mrt-row-expand',
537
+ props.enableRowSelection && 'mrt-row-select',
538
+ props.enableRowNumbers && 'mrt-row-numbers',
539
+ ].filter(Boolean);
540
+ };
541
+ const getTrailingDisplayColumnIds = (props) => {
542
+ var _a;
543
+ return [
544
+ ((props.positionActionsColumn === 'last' && props.enableRowActions) ||
545
+ (props.enableEditing &&
546
+ ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
547
+ 'mrt-row-actions',
548
+ props.positionExpandColumn === 'last' &&
549
+ (props.enableExpanding ||
550
+ props.enableGrouping ||
551
+ props.renderDetailPanel) &&
552
+ 'mrt-row-expand',
553
+ ];
554
+ };
548
555
  const getDefaultColumnOrderIds = (props) => [
549
556
  ...getLeadingDisplayColumnIds(props),
550
557
  ...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
@@ -696,7 +703,7 @@ const commonListItemStyles = {
696
703
  };
697
704
  const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
698
705
  var _a, _b, _c, _d, _e, _f, _g;
699
- 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;
706
+ 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;
700
707
  const { column } = header;
701
708
  const { columnDef } = column;
702
709
  const { columnSizing, columnVisibility, density } = getState();
@@ -737,13 +744,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
737
744
  };
738
745
  const handleFilterByColumn = () => {
739
746
  setShowFilters(true);
740
- setTimeout(() => {
741
- var _a, _b, _c;
742
- return (_c = document
743
- .getElementById(
744
- // @ts-ignore
745
- (_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();
746
- }, 200);
747
+ queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
747
748
  setAnchorEl(null);
748
749
  };
749
750
  const handleShowAllColumns = () => {
@@ -873,29 +874,36 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
873
874
  })));
874
875
  };
875
876
 
876
- const MRT_EditActionButtons = ({ row, table }) => {
877
- const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
877
+ const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
878
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, refs: { editInputRefs }, setEditingRow, } = table;
878
879
  const { editingRow } = getState();
879
- const handleCancel = () => {
880
- row._valuesCache = Object.assign({}, row.original);
881
- setEditingRow(null);
882
- };
880
+ const handleCancel = () => setEditingRow(null);
883
881
  const handleSave = () => {
884
- var _a;
882
+ var _a, _b;
883
+ //look for auto-filled input values
884
+ (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
885
+ if (input.value !== undefined &&
886
+ Object.hasOwn(editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache, input.name)) {
887
+ // @ts-ignore
888
+ editingRow._valuesCache[input.name] = input.value;
889
+ }
890
+ });
885
891
  onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
892
+ exitEditingMode: () => setEditingRow(null),
886
893
  row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
887
894
  table,
888
- values: (_a = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _a !== void 0 ? _a : Object.assign({}, row.original),
895
+ values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
889
896
  });
890
- setEditingRow(null);
891
897
  };
892
- return (React.createElement(Box, { sx: { display: 'flex', gap: '0.75rem' } },
898
+ return (React.createElement(Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React.createElement(React.Fragment, null,
893
899
  React.createElement(Tooltip, { arrow: true, title: localization.cancel },
894
900
  React.createElement(IconButton, { "aria-label": localization.cancel, onClick: handleCancel },
895
901
  React.createElement(CancelIcon, null))),
896
902
  React.createElement(Tooltip, { arrow: true, title: localization.save },
897
903
  React.createElement(IconButton, { "aria-label": localization.save, color: "info", onClick: handleSave },
898
- React.createElement(SaveIcon, null)))));
904
+ React.createElement(SaveIcon, null))))) : (React.createElement(React.Fragment, null,
905
+ React.createElement(Button, { onClick: handleCancel }, localization.cancel),
906
+ React.createElement(Button, { onClick: handleSave, variant: "contained" }, localization.save)))));
899
907
  };
900
908
 
901
909
  const commonIconButtonStyles = {
@@ -909,7 +917,7 @@ const commonIconButtonStyles = {
909
917
  },
910
918
  };
911
919
  const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
912
- const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
920
+ const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
913
921
  const { editingRow } = getState();
914
922
  const [anchorEl, setAnchorEl] = useState(null);
915
923
  const handleOpenRowActionMenu = (event) => {
@@ -921,7 +929,7 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
921
929
  setEditingRow(Object.assign({}, row));
922
930
  setAnchorEl(null);
923
931
  };
924
- return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
932
+ return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
925
933
  React.createElement(IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
926
934
  React.createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React.createElement(React.Fragment, null,
927
935
  React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
@@ -956,7 +964,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
956
964
 
957
965
  const MRT_GlobalFilterTextField = ({ table, }) => {
958
966
  var _a;
959
- const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, tableId, }, } = table;
967
+ const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
960
968
  const { globalFilter, showGlobalFilter } = getState();
961
969
  const [anchorEl, setAnchorEl] = useState(null);
962
970
  const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
@@ -979,7 +987,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
979
987
  ? muiSearchTextFieldProps({ table })
980
988
  : muiSearchTextFieldProps;
981
989
  return (React.createElement(Collapse, { in: showGlobalFilter, orientation: "horizontal" },
982
- React.createElement(TextField, Object.assign({ id: `mrt-${tableId}-search-text-field`, placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
990
+ React.createElement(TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
983
991
  startAdornment: enableGlobalFilterChangeMode ? (React.createElement(InputAdornment, { position: "start" },
984
992
  React.createElement(Tooltip, { arrow: true, title: localization.changeSearchMode },
985
993
  React.createElement(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' } },
@@ -989,7 +997,12 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
989
997
  React.createElement("span", null,
990
998
  React.createElement(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small" },
991
999
  React.createElement(CloseIcon, null)))))),
992
- } }, textFieldProps)),
1000
+ } }, textFieldProps, { inputRef: (inputRef) => {
1001
+ searchInputRef.current = inputRef;
1002
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
1003
+ textFieldProps.inputRef = inputRef;
1004
+ }
1005
+ } })),
993
1006
  React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
994
1007
  };
995
1008
 
@@ -1114,18 +1127,11 @@ const MRT_ToggleFiltersButton = (_a) => {
1114
1127
 
1115
1128
  const MRT_ToggleGlobalFilterButton = (_a) => {
1116
1129
  var { table } = _a, rest = __rest(_a, ["table"]);
1117
- const { getState, options: { icons: { SearchIcon, SearchOffIcon }, tableId, localization, muiSearchTextFieldProps, }, setShowGlobalFilter, } = table;
1130
+ const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
1118
1131
  const { showGlobalFilter } = getState();
1119
- const textFieldProps = muiSearchTextFieldProps instanceof Function
1120
- ? muiSearchTextFieldProps({ table })
1121
- : muiSearchTextFieldProps;
1122
1132
  const handleToggleSearch = () => {
1123
1133
  setShowGlobalFilter(!showGlobalFilter);
1124
- setTimeout(() => {
1125
- var _a, _b;
1126
- return (_b = document
1127
- .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();
1128
- }, 200);
1134
+ queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
1129
1135
  };
1130
1136
  return (React.createElement(Tooltip, { arrow: true, title: localization.showHideSearch },
1131
1137
  React.createElement(IconButton, Object.assign({ onClick: handleToggleSearch }, rest), showGlobalFilter ? React.createElement(SearchOffIcon, null) : React.createElement(SearchIcon, null))));
@@ -1184,14 +1190,20 @@ const commonToolbarStyles = ({ theme }) => ({
1184
1190
  });
1185
1191
  const MRT_TopToolbar = ({ table }) => {
1186
1192
  var _a;
1187
- const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, tableId, }, } = table;
1193
+ const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
1188
1194
  const { isFullScreen, showGlobalFilter } = getState();
1189
1195
  const isMobile = useMediaQuery('(max-width:720px)');
1190
1196
  const toolbarProps = muiTableTopToolbarProps instanceof Function
1191
1197
  ? muiTableTopToolbarProps({ table })
1192
1198
  : muiTableTopToolbarProps;
1193
1199
  const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
1194
- return (React.createElement(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
1200
+ return (React.createElement(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
1201
+ topToolbarRef.current = ref;
1202
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
1203
+ // @ts-ignore
1204
+ toolbarProps.ref.current = ref;
1205
+ }
1206
+ }, 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
1195
1207
  ? toolbarProps.sx(theme)
1196
1208
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1197
1209
  positionToolbarAlertBanner === 'top' && (React.createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
@@ -1216,14 +1228,20 @@ const MRT_TopToolbar = ({ table }) => {
1216
1228
  };
1217
1229
 
1218
1230
  const MRT_BottomToolbar = ({ table }) => {
1219
- const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, tableId, }, } = table;
1231
+ const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
1220
1232
  const { isFullScreen } = getState();
1221
1233
  const isMobile = useMediaQuery('(max-width:720px)');
1222
1234
  const toolbarProps = muiTableBottomToolbarProps instanceof Function
1223
1235
  ? muiTableBottomToolbarProps({ table })
1224
1236
  : muiTableBottomToolbarProps;
1225
1237
  const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
1226
- return (React.createElement(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 ${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
1238
+ return (React.createElement(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
1239
+ bottomToolbarRef.current = ref;
1240
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
1241
+ // @ts-ignore
1242
+ toolbarProps.ref.current = ref;
1243
+ }
1244
+ }, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `-3px 0 6px ${alpha(theme.palette.common.black, 0.1)}`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
1227
1245
  ? toolbarProps.sx(theme)
1228
1246
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1229
1247
  React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
@@ -1278,7 +1296,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
1278
1296
 
1279
1297
  const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1280
1298
  var _a, _b, _c, _d, _e, _f, _g, _h;
1281
- const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, tableId, }, setColumnFilterFns, } = table;
1299
+ const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
1282
1300
  const { column } = header;
1283
1301
  const { columnDef } = column;
1284
1302
  const { columnFilterFns } = getState();
@@ -1303,7 +1321,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1303
1321
  const isTextboxFilter = columnDef.filterVariant === 'text' ||
1304
1322
  (!isSelectFilter && !isMultiSelectFilter);
1305
1323
  const currentFilterOption = columnFilterFns === null || columnFilterFns === void 0 ? void 0 : columnFilterFns[header.id];
1306
- const filterId = `mrt-${tableId}-${header.id}-filter-text-field${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : ''}`;
1307
1324
  const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
1308
1325
  ? //@ts-ignore
1309
1326
  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()) +
@@ -1380,14 +1397,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1380
1397
  return React.createElement(React.Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, table }));
1381
1398
  }
1382
1399
  return (React.createElement(React.Fragment, null,
1383
- React.createElement(TextField, Object.assign({ fullWidth: true, id: filterId, inputProps: {
1400
+ React.createElement(TextField, Object.assign({ fullWidth: true, inputProps: {
1384
1401
  disabled: !!filterChipLabel,
1385
1402
  sx: {
1386
1403
  textOverflow: 'ellipsis',
1387
1404
  width: filterChipLabel ? 0 : undefined,
1388
1405
  },
1389
1406
  title: filterPlaceholder,
1390
- }, helperText: showChangeModeButton ? (React.createElement("label", { htmlFor: filterId }, localization.filterMode.replace('{filterType}',
1407
+ }, helperText: showChangeModeButton ? (React.createElement("label", null, localization.filterMode.replace('{filterType}',
1391
1408
  // @ts-ignore
1392
1409
  localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
1393
1410
  (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
@@ -1419,7 +1436,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1419
1436
  renderValue: isMultiSelectFilter
1420
1437
  ? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (React.createElement(Box, { sx: { opacity: 0.5 } }, filterPlaceholder)) : (React.createElement(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' } }, selected === null || selected === void 0 ? void 0 : selected.map((value) => (React.createElement(Chip, { key: value, label: value })))))
1421
1438
  : undefined,
1422
- } }, textFieldProps, { sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
1439
+ } }, textFieldProps, { inputRef: (inputRef) => {
1440
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
1441
+ inputRef;
1442
+ if (textFieldProps.inputRef) {
1443
+ textFieldProps.inputRef = inputRef;
1444
+ }
1445
+ }, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
1423
1446
  mr: '1.5rem',
1424
1447
  } }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
1425
1448
  ? textFieldProps.sx(theme)
@@ -1731,19 +1754,21 @@ const MRT_TableHead = ({ table }) => {
1731
1754
  return (React.createElement(TableHead, Object.assign({}, tableHeadProps), getHeaderGroups().map((headerGroup) => (React.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
1732
1755
  };
1733
1756
 
1734
- const MRT_EditCellTextField = ({ cell, table }) => {
1757
+ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
1735
1758
  var _a;
1736
- const { getState, options: { tableId, muiTableBodyCellEditTextFieldProps }, setEditingCell, setEditingRow, } = table;
1759
+ const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
1737
1760
  const { column, row } = cell;
1738
1761
  const { columnDef } = column;
1739
1762
  const { editingRow } = getState();
1740
1763
  const [value, setValue] = useState(() => cell.getValue());
1741
1764
  const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
1742
- ? muiTableBodyCellEditTextFieldProps({ cell, table })
1765
+ ? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
1743
1766
  : muiTableBodyCellEditTextFieldProps;
1744
1767
  const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
1745
1768
  ? columnDef.muiTableBodyCellEditTextFieldProps({
1746
1769
  cell,
1770
+ column,
1771
+ row,
1747
1772
  table,
1748
1773
  })
1749
1774
  : columnDef.muiTableBodyCellEditTextFieldProps;
@@ -1757,22 +1782,26 @@ const MRT_EditCellTextField = ({ cell, table }) => {
1757
1782
  var _a;
1758
1783
  (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
1759
1784
  if (editingRow) {
1760
- if (!row._valuesCache)
1761
- row._valuesCache = {};
1762
- row._valuesCache[column.id] = value;
1763
- setEditingRow(Object.assign({}, editingRow));
1785
+ setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: value }) }));
1764
1786
  }
1765
1787
  setEditingCell(null);
1766
1788
  };
1767
1789
  if (columnDef.Edit) {
1768
- return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table }));
1790
+ return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
1769
1791
  }
1770
- return (React.createElement(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 })));
1792
+ return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: cell.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
1793
+ if (inputRef) {
1794
+ editInputRefs.current[column.id] = inputRef;
1795
+ if (textFieldProps.inputRef) {
1796
+ textFieldProps.inputRef = inputRef;
1797
+ }
1798
+ }
1799
+ }, onBlur: handleBlur, onChange: handleChange })));
1771
1800
  };
1772
1801
 
1773
1802
  const MRT_CopyButton = ({ cell, children, table }) => {
1774
1803
  const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
1775
- const { column } = cell;
1804
+ const { column, row } = cell;
1776
1805
  const { columnDef } = column;
1777
1806
  const [copied, setCopied] = useState(false);
1778
1807
  const handleCopy = (text) => {
@@ -1781,7 +1810,7 @@ const MRT_CopyButton = ({ cell, children, table }) => {
1781
1810
  setTimeout(() => setCopied(false), 4000);
1782
1811
  };
1783
1812
  const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
1784
- ? muiTableBodyCellCopyButtonProps({ cell, table })
1813
+ ? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
1785
1814
  : muiTableBodyCellCopyButtonProps;
1786
1815
  const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
1787
1816
  ? columnDef.muiTableBodyCellCopyButtonProps({
@@ -1798,12 +1827,13 @@ const MRT_CopyButton = ({ cell, children, table }) => {
1798
1827
 
1799
1828
  const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1800
1829
  const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
1830
+ const { row } = cell;
1801
1831
  const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
1802
- ? muiTableBodyRowDragHandleProps({ row: cell.row, table })
1832
+ ? muiTableBodyRowDragHandleProps({ row, table })
1803
1833
  : muiTableBodyRowDragHandleProps;
1804
1834
  const handleDragStart = (e) => {
1805
1835
  e.dataTransfer.setDragImage(rowRef.current, 0, 0);
1806
- table.setDraggingRow(cell.row);
1836
+ table.setDraggingRow(row);
1807
1837
  };
1808
1838
  const handleDragEnd = (event) => {
1809
1839
  onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
@@ -1820,13 +1850,13 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1820
1850
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1821
1851
  var _a, _b, _c, _d, _f, _g, _h, _j;
1822
1852
  const theme = useTheme();
1823
- const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, tableId, }, setEditingCell, setHoveredColumn, } = table;
1853
+ const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
1824
1854
  const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
1825
1855
  const { column, row } = cell;
1826
1856
  const { columnDef } = column;
1827
1857
  const { columnDefType } = columnDef;
1828
1858
  const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
1829
- ? muiTableBodyCellProps({ cell, table })
1859
+ ? muiTableBodyCellProps({ cell, column, row, table })
1830
1860
  : muiTableBodyCellProps;
1831
1861
  const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
1832
1862
  ? columnDef.muiTableBodyCellProps({ cell, table })
@@ -1835,6 +1865,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1835
1865
  const isEditable = (enableEditing || columnDef.enableEditing) &&
1836
1866
  columnDef.enableEditing !== false;
1837
1867
  const isEditing = isEditable &&
1868
+ editingMode !== 'modal' &&
1838
1869
  (editingMode === 'table' ||
1839
1870
  (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
1840
1871
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id);
@@ -1850,13 +1881,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1850
1881
  columnDef.enableEditing !== false &&
1851
1882
  editingMode === 'cell') {
1852
1883
  setEditingCell(cell);
1853
- setTimeout(() => {
1854
- const textField = document.getElementById(`mrt-${tableId}-edit-cell-text-field-${cell.id}`);
1884
+ queueMicrotask(() => {
1885
+ const textField = editInputRefs.current[column.id];
1855
1886
  if (textField) {
1856
1887
  textField.focus();
1857
1888
  textField.select();
1858
1889
  }
1859
- }, 200);
1890
+ });
1860
1891
  }
1861
1892
  };
1862
1893
  const getIsLastLeftPinnedColumn = () => {
@@ -1932,10 +1963,10 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1932
1963
  backgroundColor: enableHover &&
1933
1964
  enableEditing &&
1934
1965
  columnDef.enableEditing !== false &&
1935
- editingMode !== 'row'
1966
+ ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
1936
1967
  ? theme.palette.mode === 'dark'
1937
- ? `${lighten(theme.palette.background.default, 0.13)} !important`
1938
- : `${darken(theme.palette.background.default, 0.07)} !important`
1968
+ ? `${lighten(theme.palette.background.default, 0.2)} !important`
1969
+ : `${darken(theme.palette.background.default, 0.1)} !important`
1939
1970
  : undefined,
1940
1971
  } }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
1941
1972
  ? tableCellProps.sx(theme)
@@ -1943,14 +1974,22 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1943
1974
  } }),
1944
1975
  React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
1945
1976
  rowNumberMode === 'static' &&
1946
- column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.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.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
1977
+ column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
1978
+ (column.id === 'mrt-row-select' ||
1979
+ column.id === 'mrt-row-expand' ||
1980
+ !row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
1947
1981
  columnDef.enableClickToCopy !== false ? (React.createElement(React.Fragment, null,
1948
1982
  React.createElement(MRT_CopyButton, { cell: cell, table: table },
1949
- React.createElement(React.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())),
1983
+ React.createElement(React.Fragment, null, row.getIsGrouped() && !cell.getIsGrouped()
1984
+ ? null
1985
+ : (_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())),
1950
1986
  cell.getIsGrouped() && React.createElement(React.Fragment, null,
1951
1987
  " (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
1952
1988
  _d.length,
1953
- ")"))) : (React.createElement(React.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(),
1989
+ ")"))) : (React.createElement(React.Fragment, null,
1990
+ row.getIsGrouped() && !cell.getIsGrouped()
1991
+ ? null
1992
+ : (_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(),
1954
1993
  cell.getIsGrouped() && React.createElement(React.Fragment, null,
1955
1994
  " (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
1956
1995
  ")"))))));
@@ -2003,7 +2042,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
2003
2042
  : undefined,
2004
2043
  } }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2005
2044
  ? tableRowProps.sx(theme)
2006
- : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => (React.createElement(MRT_TableBodyCell, { cell: cell, key: cell.id, enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false, rowIndex: rowIndex, rowRef: rowRef, table: table })))),
2045
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => (React.createElement(MRT_TableBodyCell, { cell: cell, enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false, key: cell.id, rowIndex: rowIndex, rowRef: rowRef, table: table })))),
2007
2046
  renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { row: row, table: table }))));
2008
2047
  };
2009
2048
 
@@ -2151,25 +2190,29 @@ const MRT_Table = ({ tableContainerRef, table }) => {
2151
2190
 
2152
2191
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
2153
2192
  const MRT_TableContainer = ({ table }) => {
2154
- var _a;
2155
- const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, tableId, }, } = table;
2193
+ const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
2156
2194
  const { isFullScreen } = getState();
2157
2195
  const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
2158
2196
  const tableContainerProps = muiTableContainerProps instanceof Function
2159
2197
  ? muiTableContainerProps({ table })
2160
2198
  : muiTableContainerProps;
2161
- const tableContainerRef = (_a = tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) !== null && _a !== void 0 ? _a : useRef(null);
2162
2199
  useIsomorphicLayoutEffect(() => {
2163
2200
  var _a, _b, _c, _d;
2164
2201
  const topToolbarHeight = typeof document !== 'undefined'
2165
- ? (_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
2202
+ ? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
2166
2203
  : 0;
2167
2204
  const bottomToolbarHeight = typeof document !== 'undefined'
2168
- ? (_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
2205
+ ? (_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
2169
2206
  : 0;
2170
2207
  setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
2171
2208
  });
2172
- return (React.createElement(TableContainer, Object.assign({ ref: tableContainerRef }, tableContainerProps, { sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
2209
+ return (React.createElement(TableContainer, Object.assign({}, tableContainerProps, { ref: (ref) => {
2210
+ tableContainerRef.current = ref;
2211
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
2212
+ //@ts-ignore
2213
+ tableContainerProps.ref.current = ref;
2214
+ }
2215
+ }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
2173
2216
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
2174
2217
  : undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
2175
2218
  ? tableContainerProps.sx(theme)
@@ -2201,10 +2244,32 @@ const MRT_TablePaper = ({ table }) => {
2201
2244
  enableBottomToolbar && React.createElement(MRT_BottomToolbar, { table: table })));
2202
2245
  };
2203
2246
 
2247
+ const MRT_EditRowModal = ({ open, row, table, }) => {
2248
+ const { options: { localization }, } = table;
2249
+ return (React.createElement(Dialog, { open: open },
2250
+ React.createElement(DialogTitle, { textAlign: "center" }, localization.edit),
2251
+ React.createElement(DialogContent, null,
2252
+ React.createElement("form", { onSubmit: (e) => e.preventDefault() },
2253
+ React.createElement(Stack, { sx: {
2254
+ width: '100%',
2255
+ minWidth: { xs: '300px', sm: '360px', md: '400px' },
2256
+ gap: '1.5rem',
2257
+ } }, row
2258
+ .getAllCells()
2259
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
2260
+ .map((cell) => (React.createElement(MRT_EditCellTextField, { cell: cell, key: cell.id, showLabel: true, table: table })))))),
2261
+ React.createElement(DialogActions, { sx: { p: '1.25rem' } },
2262
+ React.createElement(MRT_EditActionButtons, { row: row, table: table, variant: "text" }))));
2263
+ };
2264
+
2204
2265
  const MRT_TableRoot = (props) => {
2205
2266
  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;
2206
- const [tableId, setIdPrefix] = useState(props.tableId);
2207
- useEffect(() => { var _a; return setIdPrefix((_a = props.tableId) !== null && _a !== void 0 ? _a : Math.random().toString(36).substring(2, 9)); }, [props.tableId]);
2267
+ const bottomToolbarRef = useRef(null);
2268
+ const editInputRefs = useRef({});
2269
+ const filterInputRefs = useRef({});
2270
+ const searchInputRef = useRef(null);
2271
+ const tableContainerRef = useRef(null);
2272
+ const topToolbarRef = useRef(null);
2208
2273
  const initialState = useMemo(() => {
2209
2274
  var _a, _b;
2210
2275
  const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
@@ -2241,10 +2306,10 @@ const MRT_TableRoot = (props) => {
2241
2306
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2242
2307
  return [
2243
2308
  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' }),
2244
- columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React.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' }),
2245
- columnOrder.includes('mrt-row-expand') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React.createElement(MRT_ExpandButton, { row: cell.row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: (_e = props.localization) === null || _e === void 0 ? void 0 : _e.expand, size: 60 }, defaultDisplayColumnDefOptions), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-expand']), { id: 'mrt-row-expand' }),
2246
- columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell }) => (React.createElement(MRT_SelectCheckbox, { row: cell.row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: (_g = props.localization) === null || _g === void 0 ? void 0 : _g.select, size: 60 }, defaultDisplayColumnDefOptions), (_h = props.displayColumnDefOptions) === null || _h === void 0 ? void 0 : _h['mrt-row-select']), { id: 'mrt-row-select' }),
2247
- 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' }),
2309
+ columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.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' }),
2310
+ columnOrder.includes('mrt-row-expand') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: (_e = props.localization) === null || _e === void 0 ? void 0 : _e.expand, size: 60 }, defaultDisplayColumnDefOptions), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-expand']), { id: 'mrt-row-expand' }),
2311
+ columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: (_g = props.localization) === null || _g === void 0 ? void 0 : _g.select, size: 60 }, defaultDisplayColumnDefOptions), (_h = props.displayColumnDefOptions) === null || _h === void 0 ? void 0 : _h['mrt-row-select']), { id: 'mrt-row-select' }),
2312
+ 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' }),
2248
2313
  ].filter(Boolean);
2249
2314
  }, [
2250
2315
  columnOrder,
@@ -2298,15 +2363,23 @@ const MRT_TableRoot = (props) => {
2298
2363
  isFullScreen,
2299
2364
  showAlertBanner,
2300
2365
  showColumnFilters,
2301
- 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 });
2366
+ showGlobalFilter }, props.state) }))), { refs: {
2367
+ bottomToolbarRef,
2368
+ editInputRefs,
2369
+ filterInputRefs,
2370
+ searchInputRef,
2371
+ tableContainerRef,
2372
+ topToolbarRef,
2373
+ }, 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 });
2302
2374
  return (React.createElement(React.Fragment, null,
2303
2375
  React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
2304
2376
  React.createElement(MRT_TablePaper, { table: table })),
2305
- !isFullScreen && React.createElement(MRT_TablePaper, { table: table })));
2377
+ !isFullScreen && React.createElement(MRT_TablePaper, { table: table }),
2378
+ editingRow && props.editingMode === 'modal' && (React.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
2306
2379
  };
2307
2380
 
2308
2381
  var MaterialReactTable = (_a) => {
2309
- 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"]);
2382
+ 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"]);
2310
2383
  return (React.createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilterChangeMode: enableColumnFilterChangeMode, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterChangeMode: enableGlobalFilterChangeMode, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: Object.assign(Object.assign({}, MRT_FilterFns), filterFns), icons: Object.assign(Object.assign({}, MRT_Default_Icons), icons), localization: Object.assign(Object.assign({}, MRT_DefaultLocalization_EN), localization), positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: Object.assign(Object.assign({}, MRT_SortingFns), sortingFns) }, rest)));
2311
2384
  };
2312
2385