material-react-table-narender 2.13.4 → 2.13.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -233,6 +233,9 @@ declare const MRT_Default_Icons: {
233
233
  readonly VisibilityOffIcon: _mui_material_OverridableComponent.OverridableComponent<_mui_material.SvgIconTypeMap<{}, "svg">> & {
234
234
  muiName: string;
235
235
  };
236
+ readonly SettingsBackupRestoreIcon: _mui_material_OverridableComponent.OverridableComponent<_mui_material.SvgIconTypeMap<{}, "svg">> & {
237
+ muiName: string;
238
+ };
236
239
  };
237
240
  type MRT_Icons = Record<keyof typeof MRT_Default_Icons, any>;
238
241
 
package/dist/index.esm.js CHANGED
@@ -48,9 +48,10 @@ import SortIcon from '@mui/icons-material/Sort';
48
48
  import SyncAltIcon from '@mui/icons-material/SyncAlt';
49
49
  import ViewColumnIcon from '@mui/icons-material/ViewColumn';
50
50
  import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
51
+ import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore';
51
52
  import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
52
53
  import Paper from '@mui/material/Paper';
53
- import { useTheme as useTheme$1 } from '@mui/material';
54
+ import { Button as Button$1, useTheme as useTheme$1 } from '@mui/material';
54
55
  import TableContainer from '@mui/material/TableContainer';
55
56
  import Table from '@mui/material/Table';
56
57
  import TableBody from '@mui/material/TableBody';
@@ -435,6 +436,7 @@ const openEditingCell = ({ cell, table, }) => {
435
436
  };
436
437
  const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
437
438
  var _a, _b, _c, _d, _e, _f, _g, _h;
439
+ debugger;
438
440
  if (!table.options.enableKeyboardShortcuts)
439
441
  return;
440
442
  if (event.isPropagationStopped())
@@ -501,6 +503,16 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
501
503
  'PageDown',
502
504
  ].includes(event.key)) {
503
505
  event.preventDefault();
506
+ if (['ArrowDown'].includes(event.key)) {
507
+ debugger; // This will pause execution for debugging purposes
508
+ // Select the input element within the MUI Autocomplete component
509
+ const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
510
+ // Check if the current cell is an MUI Autocomplete
511
+ if (autocomplete) {
512
+ return; // Exit the function if it's an Autocomplete
513
+ }
514
+ // Additional logic for when it's not an Autocomplete can go here
515
+ }
504
516
  const currentRow = parentElement || currentCell.closest('tr');
505
517
  const tableElement = containerElement || currentCell.closest('table');
506
518
  const allCells = cellElements ||
@@ -1269,6 +1281,7 @@ const MRT_Default_Icons = {
1269
1281
  SyncAltIcon,
1270
1282
  ViewColumnIcon,
1271
1283
  VisibilityOffIcon,
1284
+ SettingsBackupRestoreIcon
1272
1285
  };
1273
1286
 
1274
1287
  const MRT_Localization_EN = {
@@ -2217,7 +2230,17 @@ const MRT_TableBodyCell = (_a) => {
2217
2230
  table.refs.actionCellRef.current = e.currentTarget;
2218
2231
  }
2219
2232
  };
2220
- return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2233
+ const handleKeyDown = (event) => {
2234
+ var _a;
2235
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2236
+ cellKeyboardShortcuts({
2237
+ cell,
2238
+ cellValue: cell.getValue(),
2239
+ event,
2240
+ table,
2241
+ });
2242
+ };
2243
+ return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2221
2244
  outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
2222
2245
  (editDisplayMode === 'cell' && isEditable) ||
2223
2246
  (editDisplayMode === 'table' && (isCreating || isEditing))
@@ -2487,11 +2510,20 @@ const MRT_TableFooterCell = (_a) => {
2487
2510
  column.getIsPinned();
2488
2511
  const args = { column, table };
2489
2512
  const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2513
+ const handleKeyDown = (event) => {
2514
+ var _a;
2515
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2516
+ cellKeyboardShortcuts({
2517
+ event,
2518
+ cellValue: footer.column.columnDef.footer,
2519
+ table,
2520
+ });
2521
+ };
2490
2522
  return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2491
2523
  ? 'center'
2492
2524
  : theme.direction === 'rtl'
2493
2525
  ? 'right'
2494
- : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
2526
+ : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
2495
2527
  ? '0.5rem'
2496
2528
  : density === 'comfortable'
2497
2529
  ? '1rem'
@@ -3476,6 +3508,16 @@ const MRT_TableHeadCell = (_a) => {
3476
3508
  e.preventDefault();
3477
3509
  }
3478
3510
  };
3511
+ const handleKeyDown = (event) => {
3512
+ var _a;
3513
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
3514
+ cellKeyboardShortcuts({
3515
+ event,
3516
+ cellValue: header.column.columnDef.header,
3517
+ table,
3518
+ header,
3519
+ });
3520
+ };
3479
3521
  const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
3480
3522
  column,
3481
3523
  header,
@@ -3497,7 +3539,7 @@ const MRT_TableHeadCell = (_a) => {
3497
3539
  (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
3498
3540
  }
3499
3541
  }
3500
- } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3542
+ } }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3501
3543
  '.MuiButtonBase-root': {
3502
3544
  opacity: 1,
3503
3545
  },
@@ -3962,7 +4004,7 @@ const MRT_ColumnPinningButtons = (_a) => {
3962
4004
  const MRT_ShowHideColumnsMenuItems = (_a) => {
3963
4005
  var _b;
3964
4006
  var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
3965
- const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, } = table;
4007
+ const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, enableColumnResizing, mrtTheme: { draggingBorderColor }, icons: { SettingsBackupRestoreIcon }, }, setColumnOrder, } = table;
3966
4008
  const { columnOrder } = getState();
3967
4009
  const { columnDef } = column;
3968
4010
  const { columnDefType } = columnDef;
@@ -4023,12 +4065,15 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
4023
4065
  opacity: columnDefType !== 'display' ? 1 : 0.5,
4024
4066
  },
4025
4067
  },
4026
- }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
4068
+ }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header })), enableColumnResizing && columnDefType !== 'group' &&
4069
+ (columnDef.enableResizing !== false ? (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.resetColumnSize, children: jsx(Button$1, { onClick: () => {
4070
+ column.resetSize();
4071
+ }, children: jsx(SettingsBackupRestoreIcon, {}) }) }))) : (jsx(Box, { sx: { width: '28px' } })))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
4027
4072
  };
4028
4073
 
4029
4074
  const MRT_ShowHideColumnsMenu = (_a) => {
4030
4075
  var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
4031
- const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
4076
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, enableColumnResizing, mrtTheme: { menuBackgroundColor }, }, } = table;
4032
4077
  const { columnOrder, columnPinning, density } = getState();
4033
4078
  const handleToggleAllColumns = (value) => {
4034
4079
  getAllLeafColumns()
@@ -4066,7 +4111,9 @@ const MRT_ShowHideColumnsMenu = (_a) => {
4066
4111
  justifyContent: 'space-between',
4067
4112
  p: '0.5rem',
4068
4113
  pt: 0,
4069
- }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
4114
+ }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll })), enableColumnResizing && (jsx(Button, { onClick: () => {
4115
+ table.resetColumnSizing(true);
4116
+ }, children: localization.resetColumnSize }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
4070
4117
  };
4071
4118
 
4072
4119
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -4275,6 +4322,7 @@ const MRT_TablePaper = (_a) => {
4275
4322
  const isTableInstanceProp = (props) => props.table !== undefined;
4276
4323
  const MaterialReactTable = (props) => {
4277
4324
  let table;
4325
+ debugger;
4278
4326
  if (isTableInstanceProp(props)) {
4279
4327
  table = props.table;
4280
4328
  }