material-react-table 0.33.6 → 0.35.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 (61) hide show
  1. package/dist/cjs/MaterialReactTable.d.ts +45 -53
  2. package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +4 -5
  3. package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +3 -4
  4. package/dist/cjs/buttons/MRT_GrabHandleButton.d.ts +4 -4
  5. package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +3 -4
  6. package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +3 -4
  7. package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +3 -4
  8. package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +3 -4
  9. package/dist/cjs/index.d.ts +8 -2
  10. package/dist/cjs/index.js +651 -140
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +3 -4
  13. package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +3 -4
  14. package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +3 -4
  15. package/dist/cjs/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -8
  16. package/dist/cjs/table/MRT_TableRoot.d.ts +0 -1
  17. package/dist/cjs/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
  18. package/dist/esm/MaterialReactTable.d.ts +45 -53
  19. package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +4 -5
  20. package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +3 -4
  21. package/dist/esm/buttons/MRT_GrabHandleButton.d.ts +4 -4
  22. package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +3 -4
  23. package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +3 -4
  24. package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +3 -4
  25. package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +3 -4
  26. package/dist/esm/index.d.ts +8 -2
  27. package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +3 -4
  28. package/dist/esm/material-react-table.esm.js +644 -141
  29. package/dist/esm/material-react-table.esm.js.map +1 -1
  30. package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +3 -4
  31. package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +3 -4
  32. package/dist/esm/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -8
  33. package/dist/esm/table/MRT_TableRoot.d.ts +0 -1
  34. package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
  35. package/dist/index.d.ts +76 -54
  36. package/package.json +5 -5
  37. package/src/MaterialReactTable.tsx +49 -50
  38. package/src/body/MRT_TableBody.tsx +30 -11
  39. package/src/body/MRT_TableBodyCell.tsx +17 -18
  40. package/src/body/MRT_TableBodyRow.tsx +7 -10
  41. package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -5
  42. package/src/buttons/MRT_ColumnPinningButtons.tsx +10 -5
  43. package/src/buttons/MRT_EditActionButtons.tsx +10 -6
  44. package/src/buttons/MRT_FullScreenToggleButton.tsx +10 -4
  45. package/src/buttons/MRT_GrabHandleButton.tsx +5 -5
  46. package/src/buttons/MRT_ShowHideColumnsButton.tsx +10 -4
  47. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +10 -4
  48. package/src/buttons/MRT_ToggleFiltersButton.tsx +10 -4
  49. package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +10 -4
  50. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +4 -4
  51. package/src/head/MRT_TableHeadCell.tsx +11 -16
  52. package/src/head/MRT_TableHeadCellGrabHandle.tsx +11 -12
  53. package/src/index.tsx +17 -3
  54. package/src/inputs/MRT_EditCellTextField.tsx +13 -13
  55. package/src/inputs/MRT_GlobalFilterTextField.tsx +8 -10
  56. package/src/menus/MRT_FilterOptionMenu.tsx +5 -5
  57. package/src/menus/MRT_ShowHideColumnsMenu.tsx +13 -10
  58. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +24 -22
  59. package/src/table/MRT_TableRoot.tsx +59 -66
  60. package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -10
  61. package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -7
package/dist/cjs/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var React = require('react');
4
6
  var reactTable = require('@tanstack/react-table');
5
7
  var iconsMaterial = require('@mui/icons-material');
6
8
  var matchSorterUtils = require('@tanstack/match-sorter-utils');
7
9
  var material = require('@mui/material');
8
- var reactVirtual = require('@tanstack/react-virtual');
9
10
 
10
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
12
 
@@ -428,7 +429,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
428
429
  label)))));
429
430
  };
430
431
 
431
- const MRT_ColumnPinningButtons = ({ column, table }) => {
432
+ const MRT_ColumnPinningButtons = ({ column, table, }) => {
432
433
  const { options: { icons: { PushPinIcon }, localization, }, } = table;
433
434
  const handlePinColumn = (pinDirection) => {
434
435
  column.pin(pinDirection);
@@ -566,7 +567,7 @@ const getDefaultColumnFilterFn = (columnDef) => {
566
567
  return 'fuzzy';
567
568
  };
568
569
 
569
- const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCurrentHoveredColumn, column, isSubMenu, table, }) => {
570
+ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
570
571
  var _a;
571
572
  const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
572
573
  const { columnOrder } = getState();
@@ -586,7 +587,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
586
587
  column.toggleVisibility();
587
588
  }
588
589
  };
589
- const menuItemRef = React__default["default"].useRef(null);
590
+ const menuItemRef = React.useRef(null);
590
591
  const [isDragging, setIsDragging] = React.useState(false);
591
592
  const handleDragStart = (e) => {
592
593
  setIsDragging(true);
@@ -594,14 +595,14 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
594
595
  };
595
596
  const handleDragEnd = (_e) => {
596
597
  setIsDragging(false);
597
- setCurrentHoveredColumn(null);
598
- if (currentHoveredColumn) {
599
- setColumnOrder(reorderColumn(column, currentHoveredColumn, columnOrder));
598
+ setHoveredColumn(null);
599
+ if (hoveredColumn) {
600
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
600
601
  }
601
602
  };
602
603
  const handleDragEnter = (_e) => {
603
604
  if (!isDragging) {
604
- setCurrentHoveredColumn(column);
605
+ setHoveredColumn(column);
605
606
  }
606
607
  };
607
608
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
@@ -612,7 +613,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
612
613
  opacity: isDragging ? 0.5 : 1,
613
614
  outline: isDragging
614
615
  ? `1px dashed ${theme.palette.divider}`
615
- : (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
616
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
616
617
  ? `2px dashed ${theme.palette.primary.main}`
617
618
  : 'none',
618
619
  pl: `${(column.depth + 0.5) * 2}rem`,
@@ -642,7 +643,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
642
643
  React__default["default"].createElement(material.Switch, null)), disabled: (isSubMenu && switchChecked) ||
643
644
  !column.getCanHide() ||
644
645
  column.getIsGrouped(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (React__default["default"].createElement(material.Typography, { sx: { alignSelf: 'center' } }, columnDef.header)))), (_a = column.columns) === null || _a === void 0 ? void 0 :
645
- _a.map((c, i) => (React__default["default"].createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, currentHoveredColumn: currentHoveredColumn, isSubMenu: isSubMenu, key: `${i}-${c.id}`, setCurrentHoveredColumn: setCurrentHoveredColumn, table: table })))));
646
+ _a.map((c, i) => (React__default["default"].createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isSubMenu: isSubMenu, key: `${i}-${c.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
646
647
  };
647
648
 
648
649
  const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) => {
@@ -672,7 +673,7 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) =
672
673
  getLeftLeafColumns(),
673
674
  getRightLeafColumns(),
674
675
  ]);
675
- const [currentHoveredColumn, setCurrentHoveredColumn] = React.useState(null);
676
+ const [hoveredColumn, setHoveredColumn] = React.useState(null);
676
677
  return (React__default["default"].createElement(material.Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
677
678
  dense: density === 'compact',
678
679
  } },
@@ -687,7 +688,7 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) =
687
688
  !isSubMenu && enablePinning && (React__default["default"].createElement(material.Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true) }, localization.unpinAll)),
688
689
  React__default["default"].createElement(material.Button, { disabled: getIsAllColumnsVisible(), onClick: () => toggleAllColumnsVisible(true) }, localization.showAll)),
689
690
  React__default["default"].createElement(material.Divider, null),
690
- allColumns.map((column, index) => (React__default["default"].createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, currentHoveredColumn: currentHoveredColumn, isSubMenu: isSubMenu, key: `${index}-${column.id}`, setCurrentHoveredColumn: setCurrentHoveredColumn, table: table })))));
691
+ allColumns.map((column, index) => (React__default["default"].createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isSubMenu: isSubMenu, key: `${index}-${column.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
691
692
  };
692
693
 
693
694
  const commonMenuItemStyles = {
@@ -880,16 +881,20 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
880
881
  };
881
882
 
882
883
  const MRT_EditActionButtons = ({ row, table }) => {
883
- const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditRowSubmit, }, setCurrentEditingRow, } = table;
884
- const { currentEditingRow } = getState();
884
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditRowSubmit, }, setEditingRow, } = table;
885
+ const { editingRow } = getState();
885
886
  const handleCancel = () => {
886
- var _a;
887
- row._valuesCache = (_a = row.original) !== null && _a !== void 0 ? _a : {};
888
- setCurrentEditingRow(null);
887
+ row._valuesCache = Object.assign({}, row.original);
888
+ setEditingRow(null);
889
889
  };
890
890
  const handleSave = () => {
891
- onEditRowSubmit === null || onEditRowSubmit === void 0 ? void 0 : onEditRowSubmit({ row: currentEditingRow !== null && currentEditingRow !== void 0 ? currentEditingRow : row, table });
892
- setCurrentEditingRow(null);
891
+ var _a;
892
+ onEditRowSubmit === null || onEditRowSubmit === void 0 ? void 0 : onEditRowSubmit({
893
+ row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
894
+ table,
895
+ values: (_a = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _a !== void 0 ? _a : Object.assign({}, row.original),
896
+ });
897
+ setEditingRow(null);
893
898
  };
894
899
  return (React__default["default"].createElement(material.Box, { sx: { display: 'flex', gap: '0.75rem' } },
895
900
  React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.cancel },
@@ -911,8 +916,8 @@ const commonIconButtonStyles = {
911
916
  },
912
917
  };
913
918
  const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
914
- const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setCurrentEditingRow, } = table;
915
- const { currentEditingRow } = getState();
919
+ const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
920
+ const { editingRow } = getState();
916
921
  const [anchorEl, setAnchorEl] = React.useState(null);
917
922
  const handleOpenRowActionMenu = (event) => {
918
923
  event.stopPropagation();
@@ -920,10 +925,10 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
920
925
  setAnchorEl(event.currentTarget);
921
926
  };
922
927
  const handleStartEditMode = () => {
923
- setCurrentEditingRow(Object.assign({}, row));
928
+ setEditingRow(Object.assign({}, row));
924
929
  setAnchorEl(null);
925
930
  };
926
- 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 === (currentEditingRow === null || currentEditingRow === void 0 ? void 0 : currentEditingRow.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 },
931
+ 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 },
927
932
  React__default["default"].createElement(material.IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
928
933
  React__default["default"].createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React__default["default"].createElement(React__default["default"].Fragment, null,
929
934
  React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
@@ -956,7 +961,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
956
961
  : checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) }))));
957
962
  };
958
963
 
959
- const MRT_GlobalFilterTextField = ({ table }) => {
964
+ const MRT_GlobalFilterTextField = ({ table, }) => {
960
965
  var _a;
961
966
  const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, tableId, }, } = table;
962
967
  const { globalFilter, showGlobalFilter } = getState();
@@ -1141,11 +1146,6 @@ const MRT_ToolbarInternalButtons = ({ table }) => {
1141
1146
  display: 'flex',
1142
1147
  zIndex: 3,
1143
1148
  } }, (_a = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({
1144
- MRT_FullScreenToggleButton,
1145
- MRT_ShowHideColumnsButton,
1146
- MRT_ToggleDensePaddingButton,
1147
- MRT_ToggleFiltersButton,
1148
- MRT_ToggleGlobalFilterButton,
1149
1149
  table,
1150
1150
  })) !== null && _a !== void 0 ? _a : (React__default["default"].createElement(React__default["default"].Fragment, null,
1151
1151
  enableGlobalFilter && positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })),
@@ -1158,15 +1158,15 @@ const MRT_ToolbarInternalButtons = ({ table }) => {
1158
1158
 
1159
1159
  const MRT_ToolbarDropZone = ({ table }) => {
1160
1160
  var _a, _b;
1161
- const { getState, options: { enableGrouping, localization }, setCurrentHoveredColumn, } = table;
1162
- const { currentDraggingColumn, currentHoveredColumn } = getState();
1161
+ const { getState, options: { enableGrouping, localization }, setHoveredColumn, } = table;
1162
+ const { draggingColumn, hoveredColumn } = getState();
1163
1163
  const handleDragEnter = (_event) => {
1164
- setCurrentHoveredColumn({ id: 'drop-zone' });
1164
+ setHoveredColumn({ id: 'drop-zone' });
1165
1165
  };
1166
- return (React__default["default"].createElement(material.Fade, { unmountOnExit: true, mountOnEnter: true, in: !!enableGrouping && !!currentDraggingColumn },
1166
+ return (React__default["default"].createElement(material.Fade, { unmountOnExit: true, mountOnEnter: true, in: !!enableGrouping && !!draggingColumn },
1167
1167
  React__default["default"].createElement(material.Box, { sx: (theme) => ({
1168
1168
  alignItems: 'center',
1169
- backgroundColor: material.alpha(theme.palette.info.main, (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1),
1169
+ backgroundColor: material.alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1),
1170
1170
  border: `dashed ${theme.palette.info.main} 2px`,
1171
1171
  display: 'flex',
1172
1172
  justifyContent: 'center',
@@ -1175,7 +1175,7 @@ const MRT_ToolbarDropZone = ({ table }) => {
1175
1175
  width: 'calc(100% - 4px)',
1176
1176
  zIndex: 2,
1177
1177
  }), onDragEnter: handleDragEnter },
1178
- React__default["default"].createElement(material.Typography, null, localization.dropToGroupBy.replace('{column}', (_b = (_a = currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.columnDef) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : '')))));
1178
+ React__default["default"].createElement(material.Typography, null, localization.dropToGroupBy.replace('{column}', (_b = (_a = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : '')))));
1179
1179
  };
1180
1180
 
1181
1181
  const commonToolbarStyles = ({ theme }) => ({
@@ -1505,9 +1505,9 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1505
1505
  };
1506
1506
 
1507
1507
  const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1508
- const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps, onColumnDrop, }, setColumnOrder, setCurrentDraggingColumn, setCurrentHoveredColumn, } = table;
1508
+ const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps, onColumnDrop, }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
1509
1509
  const { columnDef } = column;
1510
- const { currentHoveredColumn, currentDraggingColumn, columnOrder } = getState();
1510
+ const { hoveredColumn, draggingColumn, columnOrder } = getState();
1511
1511
  const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
1512
1512
  ? muiTableHeadCellDragHandleProps({ column, table })
1513
1513
  : muiTableHeadCellDragHandleProps;
@@ -1516,25 +1516,25 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1516
1516
  : columnDef.muiTableHeadCellDragHandleProps;
1517
1517
  const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
1518
1518
  const handleDragStart = (e) => {
1519
- setCurrentDraggingColumn(column);
1519
+ setDraggingColumn(column);
1520
1520
  e.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
1521
1521
  };
1522
1522
  const handleDragEnd = (event) => {
1523
1523
  onColumnDrop === null || onColumnDrop === void 0 ? void 0 : onColumnDrop({
1524
1524
  event,
1525
1525
  draggedColumn: column,
1526
- targetColumn: currentHoveredColumn,
1526
+ targetColumn: hoveredColumn,
1527
1527
  });
1528
- if ((currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === 'drop-zone') {
1528
+ if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1529
1529
  column.toggleGrouping();
1530
1530
  }
1531
1531
  else if (enableColumnOrdering &&
1532
- currentHoveredColumn &&
1533
- (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) !== (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id)) {
1534
- setColumnOrder(reorderColumn(column, currentHoveredColumn, columnOrder));
1532
+ hoveredColumn &&
1533
+ (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
1534
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
1535
1535
  }
1536
- setCurrentDraggingColumn(null);
1537
- setCurrentHoveredColumn(null);
1536
+ setDraggingColumn(null);
1537
+ setHoveredColumn(null);
1538
1538
  };
1539
1539
  return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
1540
1540
  };
@@ -1592,8 +1592,8 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
1592
1592
  const MRT_TableHeadCell = ({ header, table }) => {
1593
1593
  var _a, _b, _c, _d;
1594
1594
  const theme = material.useTheme();
1595
- const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setCurrentHoveredColumn, } = table;
1596
- const { density, currentDraggingColumn, currentHoveredColumn, showColumnFilters, } = getState();
1595
+ const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1596
+ const { density, draggingColumn, hoveredColumn, showColumnFilters } = getState();
1597
1597
  const { column } = header;
1598
1598
  const { columnDef } = column;
1599
1599
  const { columnDefType } = columnDef;
@@ -1615,16 +1615,16 @@ const MRT_TableHeadCell = ({ header, table }) => {
1615
1615
  return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
1616
1616
  };
1617
1617
  const handleDragEnter = (_e) => {
1618
- if (enableGrouping && (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === 'drop-zone') {
1619
- setCurrentHoveredColumn(null);
1618
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1619
+ setHoveredColumn(null);
1620
1620
  }
1621
- if (enableColumnOrdering && currentDraggingColumn) {
1622
- setCurrentHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
1621
+ if (enableColumnOrdering && draggingColumn) {
1622
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
1623
1623
  }
1624
1624
  };
1625
- const draggingBorder = (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id) === column.id
1625
+ const draggingBorder = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1626
1626
  ? `1px dashed ${theme.palette.text.secondary}`
1627
- : (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
1627
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
1628
1628
  ? `2px dashed ${theme.palette.primary.main}`
1629
1629
  : undefined;
1630
1630
  const draggingBorders = draggingBorder
@@ -1652,8 +1652,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
1652
1652
  ? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
1653
1653
  : undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
1654
1654
  ? `${column.getStart('left')}px`
1655
- : undefined, overflow: 'visible', opacity: (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id) === column.id ||
1656
- (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
1655
+ : undefined, overflow: 'visible', opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
1657
1656
  ? 0.5
1658
1657
  : 1, p: density === 'compact'
1659
1658
  ? '0.5rem'
@@ -1675,7 +1674,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
1675
1674
  ? '0.25'
1676
1675
  : density === 'comfortable'
1677
1676
  ? '.75rem'
1678
- : '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id) === column.id
1677
+ : '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1679
1678
  ? 3
1680
1679
  : column.getIsPinned() && columnDefType !== 'group'
1681
1680
  ? 2
@@ -1739,29 +1738,522 @@ const MRT_TableHead = ({ table }) => {
1739
1738
  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
1739
  };
1741
1740
 
1741
+ function _extends() {
1742
+ _extends = Object.assign || function (target) {
1743
+ for (var i = 1; i < arguments.length; i++) {
1744
+ var source = arguments[i];
1745
+
1746
+ for (var key in source) {
1747
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1748
+ target[key] = source[key];
1749
+ }
1750
+ }
1751
+ }
1752
+
1753
+ return target;
1754
+ };
1755
+
1756
+ return _extends.apply(this, arguments);
1757
+ }
1758
+
1759
+ function _objectWithoutPropertiesLoose(source, excluded) {
1760
+ if (source == null) return {};
1761
+ var target = {};
1762
+ var sourceKeys = Object.keys(source);
1763
+ var key, i;
1764
+
1765
+ for (i = 0; i < sourceKeys.length; i++) {
1766
+ key = sourceKeys[i];
1767
+ if (excluded.indexOf(key) >= 0) continue;
1768
+ target[key] = source[key];
1769
+ }
1770
+
1771
+ return target;
1772
+ }
1773
+
1774
+ var props = ['bottom', 'height', 'left', 'right', 'top', 'width'];
1775
+
1776
+ var rectChanged = function rectChanged(a, b) {
1777
+ if (a === void 0) {
1778
+ a = {};
1779
+ }
1780
+
1781
+ if (b === void 0) {
1782
+ b = {};
1783
+ }
1784
+
1785
+ return props.some(function (prop) {
1786
+ return a[prop] !== b[prop];
1787
+ });
1788
+ };
1789
+
1790
+ var observedNodes = /*#__PURE__*/new Map();
1791
+ var rafId;
1792
+
1793
+ var run = function run() {
1794
+ var changedStates = [];
1795
+ observedNodes.forEach(function (state, node) {
1796
+ var newRect = node.getBoundingClientRect();
1797
+
1798
+ if (rectChanged(newRect, state.rect)) {
1799
+ state.rect = newRect;
1800
+ changedStates.push(state);
1801
+ }
1802
+ });
1803
+ changedStates.forEach(function (state) {
1804
+ state.callbacks.forEach(function (cb) {
1805
+ return cb(state.rect);
1806
+ });
1807
+ });
1808
+ rafId = window.requestAnimationFrame(run);
1809
+ };
1810
+
1811
+ function observeRect(node, cb) {
1812
+ return {
1813
+ observe: function observe() {
1814
+ var wasEmpty = observedNodes.size === 0;
1815
+
1816
+ if (observedNodes.has(node)) {
1817
+ observedNodes.get(node).callbacks.push(cb);
1818
+ } else {
1819
+ observedNodes.set(node, {
1820
+ rect: undefined,
1821
+ hasRectChanged: false,
1822
+ callbacks: [cb]
1823
+ });
1824
+ }
1825
+
1826
+ if (wasEmpty) run();
1827
+ },
1828
+ unobserve: function unobserve() {
1829
+ var state = observedNodes.get(node);
1830
+
1831
+ if (state) {
1832
+ // Remove the callback
1833
+ var index = state.callbacks.indexOf(cb);
1834
+ if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
1835
+
1836
+ if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
1837
+
1838
+ if (!observedNodes.size) cancelAnimationFrame(rafId);
1839
+ }
1840
+ }
1841
+ };
1842
+ }
1843
+
1844
+ var useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React__default["default"].useLayoutEffect : React__default["default"].useEffect;
1845
+
1846
+ function useRect(nodeRef, initialRect) {
1847
+ if (initialRect === void 0) {
1848
+ initialRect = {
1849
+ width: 0,
1850
+ height: 0
1851
+ };
1852
+ }
1853
+
1854
+ var _React$useState = React__default["default"].useState(nodeRef.current),
1855
+ element = _React$useState[0],
1856
+ setElement = _React$useState[1];
1857
+
1858
+ var _React$useReducer = React__default["default"].useReducer(rectReducer, initialRect),
1859
+ rect = _React$useReducer[0],
1860
+ dispatch = _React$useReducer[1];
1861
+
1862
+ var initialRectSet = React__default["default"].useRef(false);
1863
+ useIsomorphicLayoutEffect$1(function () {
1864
+ if (nodeRef.current !== element) {
1865
+ setElement(nodeRef.current);
1866
+ }
1867
+ });
1868
+ useIsomorphicLayoutEffect$1(function () {
1869
+ if (element && !initialRectSet.current) {
1870
+ initialRectSet.current = true;
1871
+
1872
+ var _rect = element.getBoundingClientRect();
1873
+
1874
+ dispatch({
1875
+ rect: _rect
1876
+ });
1877
+ }
1878
+ }, [element]);
1879
+ React__default["default"].useEffect(function () {
1880
+ if (!element) {
1881
+ return;
1882
+ }
1883
+
1884
+ var observer = observeRect(element, function (rect) {
1885
+ dispatch({
1886
+ rect: rect
1887
+ });
1888
+ });
1889
+ observer.observe();
1890
+ return function () {
1891
+ observer.unobserve();
1892
+ };
1893
+ }, [element]);
1894
+ return rect;
1895
+ }
1896
+
1897
+ function rectReducer(state, action) {
1898
+ var rect = action.rect;
1899
+
1900
+ if (state.height !== rect.height || state.width !== rect.width) {
1901
+ return rect;
1902
+ }
1903
+
1904
+ return state;
1905
+ }
1906
+
1907
+ var defaultEstimateSize = function defaultEstimateSize() {
1908
+ return 50;
1909
+ };
1910
+
1911
+ var defaultKeyExtractor = function defaultKeyExtractor(index) {
1912
+ return index;
1913
+ };
1914
+
1915
+ var defaultMeasureSize = function defaultMeasureSize(el, horizontal) {
1916
+ var key = horizontal ? 'offsetWidth' : 'offsetHeight';
1917
+ return el[key];
1918
+ };
1919
+
1920
+ var defaultRangeExtractor = function defaultRangeExtractor(range) {
1921
+ var start = Math.max(range.start - range.overscan, 0);
1922
+ var end = Math.min(range.end + range.overscan, range.size - 1);
1923
+ var arr = [];
1924
+
1925
+ for (var i = start; i <= end; i++) {
1926
+ arr.push(i);
1927
+ }
1928
+
1929
+ return arr;
1930
+ };
1931
+ function useVirtual(_ref) {
1932
+ var _measurements;
1933
+
1934
+ var _ref$size = _ref.size,
1935
+ size = _ref$size === void 0 ? 0 : _ref$size,
1936
+ _ref$estimateSize = _ref.estimateSize,
1937
+ estimateSize = _ref$estimateSize === void 0 ? defaultEstimateSize : _ref$estimateSize,
1938
+ _ref$overscan = _ref.overscan,
1939
+ overscan = _ref$overscan === void 0 ? 1 : _ref$overscan,
1940
+ _ref$paddingStart = _ref.paddingStart,
1941
+ paddingStart = _ref$paddingStart === void 0 ? 0 : _ref$paddingStart,
1942
+ _ref$paddingEnd = _ref.paddingEnd,
1943
+ paddingEnd = _ref$paddingEnd === void 0 ? 0 : _ref$paddingEnd,
1944
+ parentRef = _ref.parentRef,
1945
+ horizontal = _ref.horizontal,
1946
+ scrollToFn = _ref.scrollToFn,
1947
+ useObserver = _ref.useObserver,
1948
+ initialRect = _ref.initialRect,
1949
+ onScrollElement = _ref.onScrollElement,
1950
+ scrollOffsetFn = _ref.scrollOffsetFn,
1951
+ _ref$keyExtractor = _ref.keyExtractor,
1952
+ keyExtractor = _ref$keyExtractor === void 0 ? defaultKeyExtractor : _ref$keyExtractor,
1953
+ _ref$measureSize = _ref.measureSize,
1954
+ measureSize = _ref$measureSize === void 0 ? defaultMeasureSize : _ref$measureSize,
1955
+ _ref$rangeExtractor = _ref.rangeExtractor,
1956
+ rangeExtractor = _ref$rangeExtractor === void 0 ? defaultRangeExtractor : _ref$rangeExtractor;
1957
+ var sizeKey = horizontal ? 'width' : 'height';
1958
+ var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
1959
+ var latestRef = React__default["default"].useRef({
1960
+ scrollOffset: 0,
1961
+ measurements: []
1962
+ });
1963
+
1964
+ var _React$useState = React__default["default"].useState(0),
1965
+ scrollOffset = _React$useState[0],
1966
+ setScrollOffset = _React$useState[1];
1967
+
1968
+ latestRef.current.scrollOffset = scrollOffset;
1969
+ var useMeasureParent = useObserver || useRect;
1970
+
1971
+ var _useMeasureParent = useMeasureParent(parentRef, initialRect),
1972
+ outerSize = _useMeasureParent[sizeKey];
1973
+
1974
+ latestRef.current.outerSize = outerSize;
1975
+ var defaultScrollToFn = React__default["default"].useCallback(function (offset) {
1976
+ if (parentRef.current) {
1977
+ parentRef.current[scrollKey] = offset;
1978
+ }
1979
+ }, [parentRef, scrollKey]);
1980
+ var resolvedScrollToFn = scrollToFn || defaultScrollToFn;
1981
+ scrollToFn = React__default["default"].useCallback(function (offset) {
1982
+ resolvedScrollToFn(offset, defaultScrollToFn);
1983
+ }, [defaultScrollToFn, resolvedScrollToFn]);
1984
+
1985
+ var _React$useState2 = React__default["default"].useState({}),
1986
+ measuredCache = _React$useState2[0],
1987
+ setMeasuredCache = _React$useState2[1];
1988
+
1989
+ var measure = React__default["default"].useCallback(function () {
1990
+ return setMeasuredCache({});
1991
+ }, []);
1992
+ var pendingMeasuredCacheIndexesRef = React__default["default"].useRef([]);
1993
+ var measurements = React__default["default"].useMemo(function () {
1994
+ var min = pendingMeasuredCacheIndexesRef.current.length > 0 ? Math.min.apply(Math, pendingMeasuredCacheIndexesRef.current) : 0;
1995
+ pendingMeasuredCacheIndexesRef.current = [];
1996
+ var measurements = latestRef.current.measurements.slice(0, min);
1997
+
1998
+ for (var i = min; i < size; i++) {
1999
+ var key = keyExtractor(i);
2000
+ var measuredSize = measuredCache[key];
2001
+
2002
+ var _start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
2003
+
2004
+ var _size = typeof measuredSize === 'number' ? measuredSize : estimateSize(i);
2005
+
2006
+ var _end = _start + _size;
2007
+
2008
+ measurements[i] = {
2009
+ index: i,
2010
+ start: _start,
2011
+ size: _size,
2012
+ end: _end,
2013
+ key: key
2014
+ };
2015
+ }
2016
+
2017
+ return measurements;
2018
+ }, [estimateSize, measuredCache, paddingStart, size, keyExtractor]);
2019
+ var totalSize = (((_measurements = measurements[size - 1]) == null ? void 0 : _measurements.end) || paddingStart) + paddingEnd;
2020
+ latestRef.current.measurements = measurements;
2021
+ latestRef.current.totalSize = totalSize;
2022
+ var element = onScrollElement ? onScrollElement.current : parentRef.current;
2023
+ var scrollOffsetFnRef = React__default["default"].useRef(scrollOffsetFn);
2024
+ scrollOffsetFnRef.current = scrollOffsetFn;
2025
+ useIsomorphicLayoutEffect$1(function () {
2026
+ if (!element) {
2027
+ setScrollOffset(0);
2028
+ return;
2029
+ }
2030
+
2031
+ var onScroll = function onScroll(event) {
2032
+ var offset = scrollOffsetFnRef.current ? scrollOffsetFnRef.current(event) : element[scrollKey];
2033
+ setScrollOffset(offset);
2034
+ };
2035
+
2036
+ onScroll();
2037
+ element.addEventListener('scroll', onScroll, {
2038
+ capture: false,
2039
+ passive: true
2040
+ });
2041
+ return function () {
2042
+ element.removeEventListener('scroll', onScroll);
2043
+ };
2044
+ }, [element, scrollKey]);
2045
+
2046
+ var _calculateRange = calculateRange(latestRef.current),
2047
+ start = _calculateRange.start,
2048
+ end = _calculateRange.end;
2049
+
2050
+ var indexes = React__default["default"].useMemo(function () {
2051
+ return rangeExtractor({
2052
+ start: start,
2053
+ end: end,
2054
+ overscan: overscan,
2055
+ size: measurements.length
2056
+ });
2057
+ }, [start, end, overscan, measurements.length, rangeExtractor]);
2058
+ var measureSizeRef = React__default["default"].useRef(measureSize);
2059
+ measureSizeRef.current = measureSize;
2060
+ var virtualItems = React__default["default"].useMemo(function () {
2061
+ var virtualItems = [];
2062
+
2063
+ var _loop = function _loop(k, len) {
2064
+ var i = indexes[k];
2065
+ var measurement = measurements[i];
2066
+
2067
+ var item = _extends(_extends({}, measurement), {}, {
2068
+ measureRef: function measureRef(el) {
2069
+ if (el) {
2070
+ var measuredSize = measureSizeRef.current(el, horizontal);
2071
+
2072
+ if (measuredSize !== item.size) {
2073
+ var _scrollOffset = latestRef.current.scrollOffset;
2074
+
2075
+ if (item.start < _scrollOffset) {
2076
+ defaultScrollToFn(_scrollOffset + (measuredSize - item.size));
2077
+ }
2078
+
2079
+ pendingMeasuredCacheIndexesRef.current.push(i);
2080
+ setMeasuredCache(function (old) {
2081
+ var _extends2;
2082
+
2083
+ return _extends(_extends({}, old), {}, (_extends2 = {}, _extends2[item.key] = measuredSize, _extends2));
2084
+ });
2085
+ }
2086
+ }
2087
+ }
2088
+ });
2089
+
2090
+ virtualItems.push(item);
2091
+ };
2092
+
2093
+ for (var k = 0, len = indexes.length; k < len; k++) {
2094
+ _loop(k);
2095
+ }
2096
+
2097
+ return virtualItems;
2098
+ }, [indexes, defaultScrollToFn, horizontal, measurements]);
2099
+ var mountedRef = React__default["default"].useRef(false);
2100
+ useIsomorphicLayoutEffect$1(function () {
2101
+ if (mountedRef.current) {
2102
+ setMeasuredCache({});
2103
+ }
2104
+
2105
+ mountedRef.current = true;
2106
+ }, [estimateSize]);
2107
+ var scrollToOffset = React__default["default"].useCallback(function (toOffset, _temp) {
2108
+ var _ref2 = _temp === void 0 ? {} : _temp,
2109
+ _ref2$align = _ref2.align,
2110
+ align = _ref2$align === void 0 ? 'start' : _ref2$align;
2111
+
2112
+ var _latestRef$current = latestRef.current,
2113
+ scrollOffset = _latestRef$current.scrollOffset,
2114
+ outerSize = _latestRef$current.outerSize;
2115
+
2116
+ if (align === 'auto') {
2117
+ if (toOffset <= scrollOffset) {
2118
+ align = 'start';
2119
+ } else if (toOffset >= scrollOffset + outerSize) {
2120
+ align = 'end';
2121
+ } else {
2122
+ align = 'start';
2123
+ }
2124
+ }
2125
+
2126
+ if (align === 'start') {
2127
+ scrollToFn(toOffset);
2128
+ } else if (align === 'end') {
2129
+ scrollToFn(toOffset - outerSize);
2130
+ } else if (align === 'center') {
2131
+ scrollToFn(toOffset - outerSize / 2);
2132
+ }
2133
+ }, [scrollToFn]);
2134
+ var tryScrollToIndex = React__default["default"].useCallback(function (index, _temp2) {
2135
+ var _ref3 = _temp2 === void 0 ? {} : _temp2,
2136
+ _ref3$align = _ref3.align,
2137
+ align = _ref3$align === void 0 ? 'auto' : _ref3$align,
2138
+ rest = _objectWithoutPropertiesLoose(_ref3, ["align"]);
2139
+
2140
+ var _latestRef$current2 = latestRef.current,
2141
+ measurements = _latestRef$current2.measurements,
2142
+ scrollOffset = _latestRef$current2.scrollOffset,
2143
+ outerSize = _latestRef$current2.outerSize;
2144
+ var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
2145
+
2146
+ if (!measurement) {
2147
+ return;
2148
+ }
2149
+
2150
+ if (align === 'auto') {
2151
+ if (measurement.end >= scrollOffset + outerSize) {
2152
+ align = 'end';
2153
+ } else if (measurement.start <= scrollOffset) {
2154
+ align = 'start';
2155
+ } else {
2156
+ return;
2157
+ }
2158
+ }
2159
+
2160
+ var toOffset = align === 'center' ? measurement.start + measurement.size / 2 : align === 'end' ? measurement.end : measurement.start;
2161
+ scrollToOffset(toOffset, _extends({
2162
+ align: align
2163
+ }, rest));
2164
+ }, [scrollToOffset, size]);
2165
+ var scrollToIndex = React__default["default"].useCallback(function () {
2166
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2167
+ args[_key] = arguments[_key];
2168
+ }
2169
+
2170
+ // We do a double request here because of
2171
+ // dynamic sizes which can cause offset shift
2172
+ // and end up in the wrong spot. Unfortunately,
2173
+ // we can't know about those dynamic sizes until
2174
+ // we try and render them. So double down!
2175
+ tryScrollToIndex.apply(void 0, args);
2176
+ requestAnimationFrame(function () {
2177
+ tryScrollToIndex.apply(void 0, args);
2178
+ });
2179
+ }, [tryScrollToIndex]);
2180
+ return {
2181
+ virtualItems: virtualItems,
2182
+ totalSize: totalSize,
2183
+ scrollToOffset: scrollToOffset,
2184
+ scrollToIndex: scrollToIndex,
2185
+ measure: measure
2186
+ };
2187
+ }
2188
+
2189
+ var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
2190
+ while (low <= high) {
2191
+ var middle = (low + high) / 2 | 0;
2192
+ var currentValue = getCurrentValue(middle);
2193
+
2194
+ if (currentValue < value) {
2195
+ low = middle + 1;
2196
+ } else if (currentValue > value) {
2197
+ high = middle - 1;
2198
+ } else {
2199
+ return middle;
2200
+ }
2201
+ }
2202
+
2203
+ if (low > 0) {
2204
+ return low - 1;
2205
+ } else {
2206
+ return 0;
2207
+ }
2208
+ };
2209
+
2210
+ function calculateRange(_ref4) {
2211
+ var measurements = _ref4.measurements,
2212
+ outerSize = _ref4.outerSize,
2213
+ scrollOffset = _ref4.scrollOffset;
2214
+ var size = measurements.length - 1;
2215
+
2216
+ var getOffset = function getOffset(index) {
2217
+ return measurements[index].start;
2218
+ };
2219
+
2220
+ var start = findNearestBinarySearch(0, size, getOffset, scrollOffset);
2221
+ var end = start;
2222
+
2223
+ while (end < size && measurements[end].end < scrollOffset + outerSize) {
2224
+ end++;
2225
+ }
2226
+
2227
+ return {
2228
+ start: start,
2229
+ end: end
2230
+ };
2231
+ }
2232
+
1742
2233
  const MRT_EditCellTextField = ({ cell, table }) => {
1743
2234
  var _a;
1744
- const { getState, options: { tableId, enableEditing, muiTableBodyCellEditTextFieldProps, onCellEditBlur, onCellEditChange, }, setCurrentEditingCell, setCurrentEditingRow, } = table;
2235
+ const { getState, options: { tableId, muiTableBodyCellEditTextFieldProps, onCellEditBlur, onCellEditChange, }, setEditingCell, setEditingRow, } = table;
1745
2236
  const { column, row } = cell;
1746
2237
  const { columnDef } = column;
1747
- const [value, setValue] = React.useState(cell.getValue());
2238
+ const { editingRow } = getState();
2239
+ const [value, setValue] = React.useState(() => cell.getValue());
1748
2240
  const handleChange = (event) => {
1749
2241
  var _a;
1750
2242
  setValue(event.target.value);
1751
- (_a = columnDef.onCellEditChange) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table });
1752
- onCellEditChange === null || onCellEditChange === void 0 ? void 0 : onCellEditChange({ event, cell, table });
2243
+ (_a = columnDef.onCellEditChange) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table, value });
2244
+ onCellEditChange === null || onCellEditChange === void 0 ? void 0 : onCellEditChange({ event, cell, table, value });
1753
2245
  };
1754
2246
  const handleBlur = (event) => {
1755
2247
  var _a;
1756
- if (getState().currentEditingRow) {
2248
+ if (editingRow) {
1757
2249
  if (!row._valuesCache)
1758
2250
  row._valuesCache = {};
1759
2251
  row._valuesCache[column.id] = value;
1760
- setCurrentEditingRow(Object.assign({}, getState().currentEditingRow));
2252
+ setEditingRow(Object.assign({}, editingRow));
1761
2253
  }
1762
- setCurrentEditingCell(null);
1763
- (_a = columnDef.onCellEditBlur) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table });
1764
- onCellEditBlur === null || onCellEditBlur === void 0 ? void 0 : onCellEditBlur({ event, cell, table });
2254
+ setEditingCell(null);
2255
+ (_a = columnDef.onCellEditBlur) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table, value });
2256
+ onCellEditBlur === null || onCellEditBlur === void 0 ? void 0 : onCellEditBlur({ event, cell, table, value });
1765
2257
  };
1766
2258
  const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
1767
2259
  ? muiTableBodyCellEditTextFieldProps({ cell, table })
@@ -1773,10 +2265,10 @@ const MRT_EditCellTextField = ({ cell, table }) => {
1773
2265
  })
1774
2266
  : columnDef.muiTableBodyCellEditTextFieldProps;
1775
2267
  const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
1776
- if (enableEditing && columnDef.enableEditing !== false && columnDef.Edit) {
2268
+ if (columnDef.Edit) {
1777
2269
  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 }));
1778
2270
  }
1779
- return (React__default["default"].createElement(material.TextField, Object.assign({ id: `mrt-${tableId}-edit-cell-text-field-${cell.id}`, margin: "dense", onBlur: handleBlur, onChange: handleChange, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps)));
2271
+ return (React__default["default"].createElement(material.TextField, Object.assign({ id: `mrt-${tableId}-edit-cell-text-field-${cell.id}`, margin: "none", onBlur: handleBlur, onChange: handleChange, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps)));
1780
2272
  };
1781
2273
 
1782
2274
  const MRT_CopyButton = ({ cell, children, table }) => {
@@ -1812,16 +2304,16 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1812
2304
  : muiTableBodyRowDragHandleProps;
1813
2305
  const handleDragStart = (e) => {
1814
2306
  e.dataTransfer.setDragImage(rowRef.current, 0, 0);
1815
- table.setCurrentDraggingRow(cell.row);
2307
+ table.setDraggingRow(cell.row);
1816
2308
  };
1817
2309
  const handleDragEnd = (event) => {
1818
2310
  onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
1819
2311
  event,
1820
- draggedRow: table.getState().currentDraggingRow,
1821
- targetRow: table.getState().currentHoveredRow,
2312
+ draggedRow: table.getState().draggingRow,
2313
+ targetRow: table.getState().hoveredRow,
1822
2314
  });
1823
- table.setCurrentDraggingRow(null);
1824
- table.setCurrentHoveredRow(null);
2315
+ table.setDraggingRow(null);
2316
+ table.setHoveredRow(null);
1825
2317
  };
1826
2318
  return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
1827
2319
  };
@@ -1829,8 +2321,8 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1829
2321
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1830
2322
  var _a, _b, _c, _d, _f, _g, _h, _j;
1831
2323
  const theme = material.useTheme();
1832
- const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, tableId, }, setCurrentEditingCell, setCurrentHoveredColumn, } = table;
1833
- const { currentDraggingColumn, currentEditingCell, currentEditingRow, currentHoveredColumn, density, isLoading, showSkeletons, } = getState();
2324
+ const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, tableId, }, setEditingCell, setHoveredColumn, } = table;
2325
+ const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
1834
2326
  const { column, row } = cell;
1835
2327
  const { columnDef } = column;
1836
2328
  const { columnDefType } = columnDef;
@@ -1845,8 +2337,8 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1845
2337
  columnDef.enableEditing !== false;
1846
2338
  const isEditing = isEditable &&
1847
2339
  (editingMode === 'table' ||
1848
- (currentEditingRow === null || currentEditingRow === void 0 ? void 0 : currentEditingRow.id) === row.id ||
1849
- (currentEditingCell === null || currentEditingCell === void 0 ? void 0 : currentEditingCell.id) === cell.id);
2340
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
2341
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id);
1850
2342
  const [skeletonWidth, setSkeletonWidth] = React.useState(0);
1851
2343
  React.useEffect(() => setSkeletonWidth(isLoading || showSkeletons
1852
2344
  ? columnDefType === 'display'
@@ -1858,7 +2350,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1858
2350
  if ((enableEditing || columnDef.enableEditing) &&
1859
2351
  columnDef.enableEditing !== false &&
1860
2352
  editingMode === 'cell') {
1861
- setCurrentEditingCell(cell);
2353
+ setEditingCell(cell);
1862
2354
  setTimeout(() => {
1863
2355
  const textField = document.getElementById(`mrt-${tableId}-edit-cell-text-field-${cell.id}`);
1864
2356
  if (textField) {
@@ -1879,16 +2371,16 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1879
2371
  return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
1880
2372
  };
1881
2373
  const handleDragEnter = (_e) => {
1882
- if (enableGrouping && (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === 'drop-zone') {
1883
- setCurrentHoveredColumn(null);
2374
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2375
+ setHoveredColumn(null);
1884
2376
  }
1885
- if (enableColumnOrdering && currentDraggingColumn) {
1886
- setCurrentHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2377
+ if (enableColumnOrdering && draggingColumn) {
2378
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
1887
2379
  }
1888
2380
  };
1889
- const draggingBorder = (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id) === column.id
2381
+ const draggingBorder = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1890
2382
  ? `1px dashed ${theme.palette.text.secondary}`
1891
- : (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
2383
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
1892
2384
  ? `2px dashed ${theme.palette.primary.main}`
1893
2385
  : undefined;
1894
2386
  const draggingBorders = draggingBorder
@@ -1914,8 +2406,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1914
2406
  ? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
1915
2407
  : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
1916
2408
  ? `${column.getStart('left')}px`
1917
- : undefined, opacity: (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id) === column.id ||
1918
- (currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
2409
+ : undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
1919
2410
  ? 0.5
1920
2411
  : 1, overflow: 'hidden', p: density === 'compact'
1921
2412
  ? columnDefType === 'display'
@@ -1934,7 +2425,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1934
2425
  : density === 'comfortable'
1935
2426
  ? 0.75
1936
2427
  : 1.25)}rem`
1937
- : undefined, position: column.getIsPinned() ? 'sticky' : 'relative', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, transition: 'all 0.2s ease-in-out', whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (currentDraggingColumn === null || currentDraggingColumn === void 0 ? void 0 : currentDraggingColumn.id) === column.id
2428
+ : undefined, position: column.getIsPinned() ? 'sticky' : 'relative', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, transition: 'all 0.2s ease-in-out', whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1938
2429
  ? 2
1939
2430
  : column.getIsPinned()
1940
2431
  ? 1
@@ -1980,20 +2471,20 @@ const MRT_TableDetailPanel = ({ row, table }) => {
1980
2471
  const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
1981
2472
  var _a, _b;
1982
2473
  const theme = material.useTheme();
1983
- const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setCurrentHoveredRow, } = table;
1984
- const { currentDraggingRow, currentHoveredRow } = getState();
2474
+ const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setHoveredRow, } = table;
2475
+ const { draggingRow, hoveredRow } = getState();
1985
2476
  const tableRowProps = muiTableBodyRowProps instanceof Function
1986
2477
  ? muiTableBodyRowProps({ row, table })
1987
2478
  : muiTableBodyRowProps;
1988
2479
  const handleDragEnter = (_e) => {
1989
- if (enableRowOrdering && currentDraggingRow) {
1990
- setCurrentHoveredRow(row);
2480
+ if (enableRowOrdering && draggingRow) {
2481
+ setHoveredRow(row);
1991
2482
  }
1992
2483
  };
1993
2484
  const rowRef = React.useRef(null);
1994
- const draggingBorder = (currentDraggingRow === null || currentDraggingRow === void 0 ? void 0 : currentDraggingRow.id) === row.id
2485
+ const draggingBorder = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id
1995
2486
  ? `1px dashed ${theme.palette.text.secondary}`
1996
- : (currentHoveredRow === null || currentHoveredRow === void 0 ? void 0 : currentHoveredRow.id) === row.id
2487
+ : (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
1997
2488
  ? `2px dashed ${theme.palette.primary.main}`
1998
2489
  : undefined;
1999
2490
  const draggingBorders = draggingBorder
@@ -2002,10 +2493,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
2002
2493
  }
2003
2494
  : undefined;
2004
2495
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2005
- React__default["default"].createElement(material.TableRow, Object.assign({ onDragEnter: handleDragEnter, hover: true, selected: row.getIsSelected(), ref: rowRef }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: material.lighten(theme.palette.background.default, 0.06), opacity: (currentDraggingRow === null || currentDraggingRow === void 0 ? void 0 : currentDraggingRow.id) === row.id ||
2006
- (currentHoveredRow === null || currentHoveredRow === void 0 ? void 0 : currentHoveredRow.id) === row.id
2007
- ? 0.5
2008
- : 1, transition: 'all 0.2s ease-in-out', '&:hover td': {
2496
+ React__default["default"].createElement(material.TableRow, Object.assign({ onDragEnter: handleDragEnter, hover: true, selected: row.getIsSelected(), ref: rowRef }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: material.lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 0.2s ease-in-out', '&:hover td': {
2009
2497
  backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
2010
2498
  ? theme.palette.mode === 'dark'
2011
2499
  ? `${material.lighten(theme.palette.background.default, 0.12)}`
@@ -2019,7 +2507,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
2019
2507
 
2020
2508
  const MRT_TableBody = ({ table, tableContainerRef }) => {
2021
2509
  const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, muiTableBodyProps, virtualizerProps, }, } = table;
2022
- const { density, globalFilter, pagination, sorting } = getState();
2510
+ const { globalFilter, pagination, sorting } = getState();
2023
2511
  const tableBodyProps = muiTableBodyProps instanceof Function
2024
2512
  ? muiTableBodyProps({ table })
2025
2513
  : muiTableBodyProps;
@@ -2047,19 +2535,37 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
2047
2535
  globalFilter,
2048
2536
  ]);
2049
2537
  const rowVirtualizer = enableRowVirtualization
2050
- ? reactVirtual.useVirtualizer(Object.assign({ count: rows.length, estimateSize: () => (density === 'compact' ? 20 : 50), getScrollElement: () => tableContainerRef.current, overscan: 10 }, vProps))
2538
+ ? useVirtual(Object.assign({ size: rows.length, parentRef: tableContainerRef, overscan: 15 }, vProps))
2051
2539
  : {};
2540
+ // const rowVirtualizer: Virtualizer = enableRowVirtualization
2541
+ // ? useVirtualizer({
2542
+ // count: rows.length,
2543
+ // estimateSize: () => (density === 'compact' ? 25 : 50),
2544
+ // getScrollElement: () => tableContainerRef.current as HTMLDivElement,
2545
+ // overscan: 15,
2546
+ // ...vProps,
2547
+ // })
2548
+ // : ({} as any);
2052
2549
  const virtualRows = enableRowVirtualization
2053
- ? rowVirtualizer.getVirtualItems()
2550
+ ? rowVirtualizer.virtualItems
2054
2551
  : [];
2552
+ // const virtualRows = enableRowVirtualization
2553
+ // ? rowVirtualizer.getVirtualItems()
2554
+ // : [];
2055
2555
  let paddingTop = 0;
2056
2556
  let paddingBottom = 0;
2057
2557
  if (enableRowVirtualization) {
2058
2558
  paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
2059
2559
  paddingBottom = !!virtualRows.length
2060
- ? rowVirtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
2560
+ ? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end
2061
2561
  : 0;
2062
2562
  }
2563
+ // if (enableRowVirtualization) {
2564
+ // paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
2565
+ // paddingBottom = !!virtualRows.length
2566
+ // ? rowVirtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
2567
+ // : 0;
2568
+ // }
2063
2569
  return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps),
2064
2570
  enableRowVirtualization && paddingTop > 0 && (React__default["default"].createElement("tr", null,
2065
2571
  React__default["default"].createElement("td", { style: { height: `${paddingTop}px` } }))),
@@ -2194,7 +2700,7 @@ const MRT_TablePaper = ({ table }) => {
2194
2700
  };
2195
2701
 
2196
2702
  const MRT_TableRoot = (props) => {
2197
- 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;
2703
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
2198
2704
  const [tableId, setIdPrefix] = React.useState(props.tableId);
2199
2705
  React.useEffect(() => { var _a; return setIdPrefix((_a = props.tableId) !== null && _a !== void 0 ? _a : Math.random().toString(36).substring(2, 9)); }, [props.tableId]);
2200
2706
  const initialState = React.useMemo(() => {
@@ -2202,31 +2708,34 @@ const MRT_TableRoot = (props) => {
2202
2708
  const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
2203
2709
  initState.columnOrder =
2204
2710
  (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(props);
2711
+ initState.columnFilterFns = Object.assign({}, ...getAllLeafColumnDefs(props.columns).map((col) => {
2712
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2713
+ return ({
2714
+ [(_d = (_b = (_a = col.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : (_c = col.accessorKey) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : '']: col.filterFn instanceof Function
2715
+ ? (_e = col.filterFn.name) !== null && _e !== void 0 ? _e : 'custom'
2716
+ : (_m = (_f = col.filterFn) !== null && _f !== void 0 ? _f : (_g = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _g === void 0 ? void 0 : _g[(_l = (_j = (_h = col.id) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : (_k = col.accessorKey) === null || _k === void 0 ? void 0 : _k.toString()) !== null && _l !== void 0 ? _l : '']) !== null && _m !== void 0 ? _m : getDefaultColumnFilterFn(col),
2717
+ });
2718
+ }));
2719
+ initState.globalFilterFn =
2720
+ props.globalFilterFn instanceof String
2721
+ ? props.globalFilterFn
2722
+ : 'fuzzy';
2205
2723
  return initState;
2206
2724
  }, []);
2207
- const [columnOrder, setColumnOrder] = React.useState((_a = initialState.columnOrder) !== null && _a !== void 0 ? _a : []);
2208
- const [currentDraggingColumn, setCurrentDraggingColumn] = React.useState((_b = initialState.currentDraggingColumn) !== null && _b !== void 0 ? _b : null);
2209
- const [currentDraggingRow, setCurrentDraggingRow] = React.useState((_c = initialState.currentDraggingRow) !== null && _c !== void 0 ? _c : null);
2210
- const [currentEditingCell, setCurrentEditingCell] = React.useState((_d = initialState.currentEditingCell) !== null && _d !== void 0 ? _d : null);
2211
- const [currentEditingRow, setCurrentEditingRow] = React.useState((_e = initialState.currentEditingRow) !== null && _e !== void 0 ? _e : null);
2212
- const [currentHoveredColumn, setCurrentHoveredColumn] = React.useState((_f = initialState.currentHoveredColumn) !== null && _f !== void 0 ? _f : null);
2213
- const [currentHoveredRow, setCurrentHoveredRow] = React.useState((_g = initialState.currentHoveredRow) !== null && _g !== void 0 ? _g : null);
2214
- const [density, setDensity] = React.useState((_h = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _h !== void 0 ? _h : 'comfortable');
2215
- const [isFullScreen, setIsFullScreen] = React.useState((_j = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _j !== void 0 ? _j : false);
2216
- const [showAlertBanner, setShowAlertBanner] = React.useState((_l = (_k = props.initialState) === null || _k === void 0 ? void 0 : _k.showAlertBanner) !== null && _l !== void 0 ? _l : false);
2217
- const [showColumnFilters, setShowFilters] = React.useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _m !== void 0 ? _m : false);
2218
- const [showGlobalFilter, setShowGlobalFilter] = React.useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _o !== void 0 ? _o : false);
2219
- const [columnFilterFns, setColumnFilterFns] = React.useState(() => Object.assign({}, ...getAllLeafColumnDefs(props.columns).map((col) => {
2220
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
2221
- return ({
2222
- [(_d = (_b = (_a = col.id) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : (_c = col.accessorKey) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : '']: col.filterFn instanceof Function
2223
- ? (_e = col.filterFn.name) !== null && _e !== void 0 ? _e : 'custom'
2224
- : (_m = (_f = col.filterFn) !== null && _f !== void 0 ? _f : (_g = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _g === void 0 ? void 0 : _g[(_l = (_j = (_h = col.id) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : (_k = col.accessorKey) === null || _k === void 0 ? void 0 : _k.toString()) !== null && _l !== void 0 ? _l : '']) !== null && _m !== void 0 ? _m : getDefaultColumnFilterFn(col),
2225
- });
2226
- })));
2227
- const [globalFilterFn, setGlobalFilterFn] = React.useState(props.globalFilterFn instanceof String
2228
- ? props.globalFilterFn
2229
- : 'fuzzy');
2725
+ const [columnFilterFns, setColumnFilterFns] = React.useState((_a = initialState.columnFilterFns) !== null && _a !== void 0 ? _a : {});
2726
+ const [columnOrder, setColumnOrder] = React.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
2727
+ const [density, setDensity] = React.useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
2728
+ const [draggingColumn, setDraggingColumn] = React.useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
2729
+ const [draggingRow, setDraggingRow] = React.useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
2730
+ const [editingCell, setEditingCell] = React.useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
2731
+ const [editingRow, setEditingRow] = React.useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
2732
+ const [globalFilterFn, setGlobalFilterFn] = React.useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
2733
+ const [hoveredColumn, setHoveredColumn] = React.useState((_j = initialState.hoveredColumn) !== null && _j !== void 0 ? _j : null);
2734
+ const [hoveredRow, setHoveredRow] = React.useState((_k = initialState.hoveredRow) !== null && _k !== void 0 ? _k : null);
2735
+ const [isFullScreen, setIsFullScreen] = React.useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _l !== void 0 ? _l : false);
2736
+ const [showAlertBanner, setShowAlertBanner] = React.useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
2737
+ const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
2738
+ const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
2230
2739
  const displayColumns = React.useMemo(() => {
2231
2740
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2232
2741
  return [
@@ -2253,8 +2762,6 @@ const MRT_TableRoot = (props) => {
2253
2762
  props.enableRowSelection,
2254
2763
  props.enableSelectAll,
2255
2764
  props.localization,
2256
- props.muiTableBodyCellProps,
2257
- props.muiTableHeadCellProps,
2258
2765
  props.positionActionsColumn,
2259
2766
  ]);
2260
2767
  const columnDefs = React.useMemo(() => prepareColumns([...displayColumns, ...props.columns], columnFilterFns, props.filterFns, props.sortingFns), [columnFilterFns, displayColumns, props.columns]);
@@ -2273,26 +2780,24 @@ const MRT_TableRoot = (props) => {
2273
2780
  });
2274
2781
  })))
2275
2782
  : props.data;
2276
- }, [props.data, (_p = props.state) === null || _p === void 0 ? void 0 : _p.isLoading, (_q = props.state) === null || _q === void 0 ? void 0 : _q.showSkeletons]);
2783
+ }, [props.data, (_r = props.state) === null || _r === void 0 ? void 0 : _r.isLoading, (_s = props.state) === null || _s === void 0 ? void 0 : _s.showSkeletons]);
2277
2784
  //@ts-ignore
2278
2785
  const table = Object.assign(Object.assign({}, reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: reactTable.getExpandedRowModel(), getFacetedRowModel: reactTable.getFacetedRowModel(), getFilteredRowModel: reactTable.getFilteredRowModel(), getGroupedRowModel: reactTable.getGroupedRowModel(), getPaginationRowModel: reactTable.getPaginationRowModel(), getSortedRowModel: reactTable.getSortedRowModel(), onColumnOrderChange: setColumnOrder, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
2279
2786
  //@ts-ignore
2280
- columns: columnDefs, data, globalFilterFn:
2281
- //@ts-ignore
2282
- (_r = props.filterFns[globalFilterFn]) !== null && _r !== void 0 ? _r : props.filterFns.fuzzy, initialState, state: Object.assign({ columnOrder,
2283
- currentDraggingColumn,
2284
- currentDraggingRow,
2285
- currentEditingCell,
2286
- currentEditingRow,
2287
- columnFilterFns,
2288
- globalFilterFn,
2289
- currentHoveredColumn,
2290
- currentHoveredRow,
2787
+ columns: columnDefs, data, globalFilterFn: (_u = (_t = props.filterFns) === null || _t === void 0 ? void 0 : _t[globalFilterFn]) !== null && _u !== void 0 ? _u : (_v = props.filterFns) === null || _v === void 0 ? void 0 : _v.fuzzy, initialState, state: Object.assign({ columnFilterFns,
2788
+ columnOrder,
2291
2789
  density,
2790
+ draggingColumn,
2791
+ draggingRow,
2792
+ editingCell,
2793
+ editingRow,
2794
+ globalFilterFn,
2795
+ hoveredColumn,
2796
+ hoveredRow,
2292
2797
  isFullScreen,
2293
2798
  showAlertBanner,
2294
2799
  showColumnFilters,
2295
- showGlobalFilter }, props.state), tableId }))), { setCurrentDraggingColumn: (_s = props.onCurrentDraggingColumnChange) !== null && _s !== void 0 ? _s : setCurrentDraggingColumn, setCurrentDraggingRow: (_t = props.onCurrentDraggingRowChange) !== null && _t !== void 0 ? _t : setCurrentDraggingRow, setCurrentEditingCell: (_u = props.onCurrentEditingCellChange) !== null && _u !== void 0 ? _u : setCurrentEditingCell, setCurrentEditingRow: (_v = props.onCurrentEditingRowChange) !== null && _v !== void 0 ? _v : setCurrentEditingRow, setColumnFilterFns: (_w = props.onCurrentFilterFnsChange) !== null && _w !== void 0 ? _w : setColumnFilterFns, setGlobalFilterFn: (_x = props.onCurrentGlobalFilterFnChange) !== null && _x !== void 0 ? _x : setGlobalFilterFn, setCurrentHoveredColumn: (_y = props.onCurrentHoveredColumnChange) !== null && _y !== void 0 ? _y : setCurrentHoveredColumn, setCurrentHoveredRow: (_z = props.onCurrentHoveredRowChange) !== null && _z !== void 0 ? _z : setCurrentHoveredRow, setDensity: (_0 = props.onDensityChange) !== null && _0 !== void 0 ? _0 : setDensity, setIsFullScreen: (_1 = props.onIsFullScreenChange) !== null && _1 !== void 0 ? _1 : setIsFullScreen, setShowAlertBanner: (_2 = props.onShowAlertBannerChange) !== null && _2 !== void 0 ? _2 : setShowAlertBanner, setShowFilters: (_3 = props.onShowFiltersChange) !== null && _3 !== void 0 ? _3 : setShowFilters, setShowGlobalFilter: (_4 = props.onShowGlobalFilterChange) !== null && _4 !== void 0 ? _4 : setShowGlobalFilter });
2800
+ showGlobalFilter }, props.state), tableId }))), { setColumnFilterFns: (_w = props.onFilterFnsChange) !== null && _w !== void 0 ? _w : setColumnFilterFns, setDensity: (_x = props.onDensityChange) !== null && _x !== void 0 ? _x : setDensity, setDraggingColumn: (_y = props.onDraggingColumnChange) !== null && _y !== void 0 ? _y : setDraggingColumn, setDraggingRow: (_z = props.onDraggingRowChange) !== null && _z !== void 0 ? _z : setDraggingRow, setEditingCell: (_0 = props.onEditingCellChange) !== null && _0 !== void 0 ? _0 : setEditingCell, setEditingRow: (_1 = props.onEditingRowChange) !== null && _1 !== void 0 ? _1 : setEditingRow, setGlobalFilterFn: (_2 = props.onGlobalFilterFnChange) !== null && _2 !== void 0 ? _2 : setGlobalFilterFn, setHoveredColumn: (_3 = props.onHoveredColumnChange) !== null && _3 !== void 0 ? _3 : setHoveredColumn, setHoveredRow: (_4 = props.onHoveredRowChange) !== null && _4 !== void 0 ? _4 : setHoveredRow, setIsFullScreen: (_5 = props.onIsFullScreenChange) !== null && _5 !== void 0 ? _5 : setIsFullScreen, setShowAlertBanner: (_6 = props.onShowAlertBannerChange) !== null && _6 !== void 0 ? _6 : setShowAlertBanner, setShowFilters: (_7 = props.onShowFiltersChange) !== null && _7 !== void 0 ? _7 : setShowFilters, setShowGlobalFilter: (_8 = props.onShowGlobalFilterChange) !== null && _8 !== void 0 ? _8 : setShowGlobalFilter });
2296
2801
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2297
2802
  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 },
2298
2803
  React__default["default"].createElement(MRT_TablePaper, { table: table })),
@@ -2304,5 +2809,11 @@ var MaterialReactTable = (_a) => {
2304
2809
  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)));
2305
2810
  };
2306
2811
 
2307
- module.exports = MaterialReactTable;
2812
+ exports.MRT_FullScreenToggleButton = MRT_FullScreenToggleButton;
2813
+ exports.MRT_GlobalFilterTextField = MRT_GlobalFilterTextField;
2814
+ exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
2815
+ exports.MRT_ToggleDensePaddingButton = MRT_ToggleDensePaddingButton;
2816
+ exports.MRT_ToggleFiltersButton = MRT_ToggleFiltersButton;
2817
+ exports.MRT_ToggleGlobalFilterButton = MRT_ToggleGlobalFilterButton;
2818
+ exports["default"] = MaterialReactTable;
2308
2819
  //# sourceMappingURL=index.js.map