material-react-table 1.8.5 → 1.9.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/dist/cjs/index.js +54 -49
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/_locales/sr-Cyrl-RS.d.ts +2 -0
  4. package/dist/cjs/types/_locales/sr-Latn-RS.d.ts +2 -0
  5. package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +2 -3
  6. package/dist/esm/material-react-table.esm.js +53 -49
  7. package/dist/esm/material-react-table.esm.js.map +1 -1
  8. package/dist/esm/types/_locales/sr-Cyrl-RS.d.ts +2 -0
  9. package/dist/esm/types/_locales/sr-Latn-RS.d.ts +2 -0
  10. package/dist/esm/types/body/MRT_TableBodyCell.d.ts +2 -3
  11. package/locales/sr-Cyrl-RS.d.ts +2 -0
  12. package/locales/sr-Cyrl-RS.esm.d.ts +2 -0
  13. package/locales/sr-Cyrl-RS.esm.js +94 -0
  14. package/locales/sr-Cyrl-RS.esm.js.map +1 -0
  15. package/locales/sr-Cyrl-RS.js +98 -0
  16. package/locales/sr-Cyrl-RS.js.map +1 -0
  17. package/locales/sr-Latn-RS.d.ts +2 -0
  18. package/locales/sr-Latn-RS.esm.d.ts +2 -0
  19. package/locales/sr-Latn-RS.esm.js +94 -0
  20. package/locales/sr-Latn-RS.esm.js.map +1 -0
  21. package/locales/sr-Latn-RS.js +98 -0
  22. package/locales/sr-Latn-RS.js.map +1 -0
  23. package/package.json +1 -1
  24. package/src/_locales/sr-Cyrl-RS.ts +94 -0
  25. package/src/_locales/sr-Latn-RS.ts +94 -0
  26. package/src/body/MRT_TableBodyCell.tsx +9 -14
  27. package/src/body/MRT_TableBodyRow.tsx +1 -4
  28. package/src/head/MRT_TableHeadCell.tsx +4 -0
  29. package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
  30. package/src/head/MRT_TableHeadCellSortLabel.tsx +30 -22
  31. package/src/menus/MRT_FilterOptionMenu.tsx +1 -3
  32. package/src/menus/MRT_RowActionMenu.tsx +1 -0
  33. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -1
package/dist/cjs/index.js CHANGED
@@ -68,6 +68,7 @@ var Table = require('@mui/material/Table');
68
68
  var TableHead = require('@mui/material/TableHead');
69
69
  var TableRow = require('@mui/material/TableRow');
70
70
  var TableCell = require('@mui/material/TableCell');
71
+ var Badge = require('@mui/material/Badge');
71
72
  var TableSortLabel = require('@mui/material/TableSortLabel');
72
73
  var TableBody = require('@mui/material/TableBody');
73
74
  var Skeleton = require('@mui/material/Skeleton');
@@ -141,6 +142,7 @@ var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
141
142
  var TableHead__default = /*#__PURE__*/_interopDefaultLegacy(TableHead);
142
143
  var TableRow__default = /*#__PURE__*/_interopDefaultLegacy(TableRow);
143
144
  var TableCell__default = /*#__PURE__*/_interopDefaultLegacy(TableCell);
145
+ var Badge__default = /*#__PURE__*/_interopDefaultLegacy(Badge);
144
146
  var TableSortLabel__default = /*#__PURE__*/_interopDefaultLegacy(TableSortLabel);
145
147
  var TableBody__default = /*#__PURE__*/_interopDefaultLegacy(TableBody);
146
148
  var Skeleton__default = /*#__PURE__*/_interopDefaultLegacy(Skeleton);
@@ -647,9 +649,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
647
649
  if (header && column) {
648
650
  setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
649
651
  if (['empty', 'notEmpty'].includes(option)) {
650
- if (currentFilterValue !== ' ') {
651
- column.setFilterValue(' ');
652
- }
652
+ column.setFilterValue(' ');
653
653
  }
654
654
  else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
655
655
  ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'].includes(option)) {
@@ -792,8 +792,9 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredCol
792
792
  justifyContent: 'flex-start',
793
793
  my: 0,
794
794
  opacity: isDragging ? 0.5 : 1,
795
+ outlineOffset: '-2px',
795
796
  outline: isDragging
796
- ? `1px dashed ${theme.palette.divider}`
797
+ ? `2px dashed ${theme.palette.divider}`
797
798
  : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
798
799
  ? `2px dashed ${theme.palette.primary.main}`
799
800
  : 'none',
@@ -1046,7 +1047,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
1046
1047
  const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) => {
1047
1048
  const { getState, options: { icons: { EditIcon }, enableEditing, localization, renderRowActionMenuItems, }, } = table;
1048
1049
  const { density } = getState();
1049
- return (React__default["default"].createElement(Menu__default["default"], { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
1050
+ return (React__default["default"].createElement(Menu__default["default"], { anchorEl: anchorEl, open: !!anchorEl, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), MenuListProps: {
1050
1051
  dense: density === 'compact',
1051
1052
  } },
1052
1053
  enableEditing instanceof Function
@@ -1909,7 +1910,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
1909
1910
  column.resetSize();
1910
1911
  }, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), sx: (theme) => ({
1911
1912
  cursor: 'col-resize',
1912
- mr: density === 'compact' ? '-0.5rem' : '-1rem',
1913
+ mr: density === 'compact' ? '-0.75rem' : '-1rem',
1913
1914
  position: 'absolute',
1914
1915
  right: '1px',
1915
1916
  px: '4px',
@@ -1936,28 +1937,30 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
1936
1937
  };
1937
1938
 
1938
1939
  const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
1939
- const { options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
1940
+ const { getState, options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
1940
1941
  const { column } = header;
1941
1942
  const { columnDef } = column;
1943
+ const { sorting } = getState();
1942
1944
  const sortTooltip = column.getIsSorted()
1943
1945
  ? column.getIsSorted() === 'desc'
1944
1946
  ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
1945
1947
  : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
1946
1948
  : localization.unsorted;
1947
1949
  return (React__default["default"].createElement(Tooltip__default["default"], { arrow: true, placement: "top", title: sortTooltip },
1948
- React__default["default"].createElement(TableSortLabel__default["default"], { "aria-label": sortTooltip, active: !!column.getIsSorted(), direction: column.getIsSorted()
1949
- ? column.getIsSorted()
1950
- : undefined, sx: {
1951
- flex: '0 0',
1952
- width: '2.3ch',
1953
- transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
1954
- ? 'translateX(-0.5ch)'
1955
- : undefined,
1956
- }, IconComponent: ArrowDownwardIcon, onClick: (e) => {
1957
- var _a;
1958
- e.stopPropagation();
1959
- (_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
1960
- } })));
1950
+ React__default["default"].createElement(Badge__default["default"], { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular" },
1951
+ React__default["default"].createElement(TableSortLabel__default["default"], { "aria-label": sortTooltip, active: !!column.getIsSorted(), direction: column.getIsSorted()
1952
+ ? column.getIsSorted()
1953
+ : undefined, sx: {
1954
+ flex: '0 0',
1955
+ width: '2.4ch',
1956
+ transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
1957
+ ? 'translateX(-0.5ch)'
1958
+ : undefined,
1959
+ }, IconComponent: ArrowDownwardIcon, onClick: (e) => {
1960
+ var _a;
1961
+ e.stopPropagation();
1962
+ (_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
1963
+ } }))));
1961
1964
  };
1962
1965
 
1963
1966
  const MRT_TableHeadCell = ({ header, table }) => {
@@ -2077,9 +2080,13 @@ const MRT_TableHeadCell = ({ header, table }) => {
2077
2080
  : undefined,
2078
2081
  } },
2079
2082
  React__default["default"].createElement(Box__default["default"], { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
2083
+ minWidth: '5ch',
2080
2084
  overflow: columnDefType === 'data' ? 'hidden' : undefined,
2081
2085
  textOverflow: 'ellipsis',
2082
2086
  whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 20 ? 'nowrap' : 'normal',
2087
+ '&:hover': {
2088
+ textOverflow: 'clip',
2089
+ },
2083
2090
  }, title: columnDefType === 'data' ? columnDef.header : undefined }, headerElement),
2084
2091
  column.getCanSort() && (React__default["default"].createElement(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })),
2085
2092
  column.getCanFilter() && (React__default["default"].createElement(MRT_TableHeadCellFilterLabel, { header: header, table: table }))),
@@ -2321,7 +2328,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
2321
2328
  return React__default["default"].createElement(React__default["default"].Fragment, null, renderedCellValue);
2322
2329
  };
2323
2330
 
2324
- const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
2331
+ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
2325
2332
  var _a, _b, _c, _d;
2326
2333
  const theme = styles.useTheme();
2327
2334
  const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
@@ -2435,37 +2442,36 @@ const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowInde
2435
2442
  ? 0.75
2436
2443
  : 1.25)}rem`
2437
2444
  : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
2438
- backgroundColor: enableHover &&
2439
- isEditable &&
2440
- ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2441
- ? theme.palette.mode === 'dark'
2442
- ? `${styles.lighten(theme.palette.background.default, 0.2)} !important`
2443
- : `${styles.darken(theme.palette.background.default, 0.1)} !important`
2445
+ outline: ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2446
+ ? `1px solid ${theme.palette.text.secondary}`
2444
2447
  : undefined,
2448
+ outlineOffset: '-1px',
2449
+ textOverflow: 'clip',
2445
2450
  } }, getCommonCellStyles({
2446
2451
  column,
2447
2452
  table,
2448
2453
  theme,
2449
2454
  tableCellProps,
2450
2455
  })), draggingBorders)) }),
2451
- React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? ((_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null) : isLoading || showSkeletons ? (React__default["default"].createElement(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
2452
- rowNumberMode === 'static' &&
2453
- column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React__default["default"].createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
2454
- (column.id === 'mrt-row-select' ||
2455
- column.id === 'mrt-row-expand' ||
2456
- !row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2457
- cell,
2458
- renderedCellValue: cell.renderValue(),
2459
- column,
2460
- row,
2461
- table,
2462
- })) : isEditing ? (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2463
- columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
2464
- React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
2465
- cell.getIsGrouped() && !columnDef.GroupedCell && (React__default["default"].createElement(React__default["default"].Fragment, null,
2466
- " (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
2467
- _d.length,
2468
- ")"))));
2456
+ React__default["default"].createElement(React__default["default"].Fragment, null,
2457
+ cell.getIsPlaceholder() ? ((_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null) : isLoading || showSkeletons ? (React__default["default"].createElement(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
2458
+ rowNumberMode === 'static' &&
2459
+ column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React__default["default"].createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
2460
+ (column.id === 'mrt-row-select' ||
2461
+ column.id === 'mrt-row-expand' ||
2462
+ !row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2463
+ cell,
2464
+ renderedCellValue: cell.renderValue(),
2465
+ column,
2466
+ row,
2467
+ table,
2468
+ })) : isEditing ? (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2469
+ columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
2470
+ React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table })),
2471
+ cell.getIsGrouped() && !columnDef.GroupedCell && (React__default["default"].createElement(React__default["default"].Fragment, null,
2472
+ " (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
2473
+ _d.length,
2474
+ ")")))));
2469
2475
  };
2470
2476
  const Memo_MRT_TableBodyCell = React.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2471
2477
 
@@ -2496,7 +2502,7 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, table, virtualRow, }) => {
2496
2502
  };
2497
2503
 
2498
2504
  const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
2499
- const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
2505
+ const { getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
2500
2506
  const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
2501
2507
  const tableRowProps = muiTableBodyRowProps instanceof Function
2502
2508
  ? muiTableBodyRowProps({ row, table })
@@ -2508,7 +2514,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
2508
2514
  };
2509
2515
  const rowRef = React.useRef(null);
2510
2516
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2511
- React__default["default"].createElement(TableRow__default["default"], Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, hover: true, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
2517
+ React__default["default"].createElement(TableRow__default["default"], Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
2512
2518
  if (node) {
2513
2519
  rowRef.current = node;
2514
2520
  measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
@@ -2516,7 +2522,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
2516
2522
  } }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.06), display: layoutMode === 'grid' ? 'flex' : 'table-row', 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, position: virtualRow ? 'absolute' : undefined, top: virtualRow ? 0 : undefined, transform: virtualRow
2517
2523
  ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2518
2524
  : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', '&:hover td': {
2519
- backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
2525
+ backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
2520
2526
  ? theme.palette.mode === 'dark'
2521
2527
  ? `${styles.lighten(theme.palette.background.default, 0.12)}`
2522
2528
  : `${styles.darken(theme.palette.background.default, 0.05)}`
@@ -2531,7 +2537,6 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
2531
2537
  : cellOrVirtualCell;
2532
2538
  const props = {
2533
2539
  cell,
2534
- enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false,
2535
2540
  key: cell.id,
2536
2541
  measureElement: columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement,
2537
2542
  numRows,