material-react-table-narender 2.13.19 → 2.13.21

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.
package/dist/index.js CHANGED
@@ -526,43 +526,43 @@ const openEditingCell = ({ cell, table, }) => {
526
526
  }
527
527
  };
528
528
  const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
529
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
529
+ var _a, _b, _c, _d, _e, _f, _g, _h;
530
530
  debugger;
531
531
  const { getState, setEnableKeyboardShortcuts, } = table;
532
532
  const { enableKeyboardShortcuts } = getState();
533
- if (event.altKey) {
534
- event.preventDefault();
535
- setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
536
- const currentCell = event.currentTarget;
537
- if (enableKeyboardShortcuts) {
538
- const input = currentCell.querySelector('input');
539
- const select = currentCell.querySelector('select');
540
- const checkbox = currentCell.querySelector('input[type="checkbox"]');
541
- const button = currentCell.querySelector('button');
542
- const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
543
- if (autocomplete) {
544
- autocomplete.focus();
545
- (_a = autocomplete.select) === null || _a === void 0 ? void 0 : _a.call(autocomplete);
546
- }
547
- else if (input) {
548
- input.focus();
549
- (_b = input.select) === null || _b === void 0 ? void 0 : _b.call(input);
550
- }
551
- else if (select) {
552
- select.focus();
553
- }
554
- else if (checkbox) {
555
- checkbox.focus();
556
- // checkbox.click();
557
- }
558
- else if (button) {
559
- button.focus();
560
- }
561
- else {
562
- currentCell.focus();
563
- }
564
- }
565
- }
533
+ // alt + n
534
+ // if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
535
+ // event.preventDefault();
536
+ // setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
537
+ // const currentCell = event.currentTarget;
538
+ // if (enableKeyboardShortcuts) {
539
+ // const input = currentCell.querySelector('input') as HTMLInputElement;
540
+ // const select = currentCell.querySelector('select') as HTMLSelectElement;
541
+ // const checkbox = currentCell.querySelector('input[type="checkbox"]') as HTMLInputElement;
542
+ // const button = currentCell.querySelector('button') as HTMLButtonElement;
543
+ // const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]') as HTMLInputElement;
544
+ // if (autocomplete) {
545
+ // autocomplete.focus();
546
+ // autocomplete.select?.();
547
+ // } else if (input) {
548
+ // input.focus();
549
+ // input.select?.();
550
+ // } else if (select) {
551
+ // select.focus();
552
+ // } else if (checkbox) {
553
+ // checkbox.focus();
554
+ // // checkbox.click();
555
+ // } else if (button) {
556
+ // button.focus();
557
+ // } else {
558
+ // currentCell.focus();
559
+ // }
560
+ // }
561
+ // }
562
+ // if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
563
+ // event.preventDefault();
564
+ // setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
565
+ // }
566
566
  // if (!table.options.enableKeyboardShortcuts) return;
567
567
  if (!enableKeyboardShortcuts)
568
568
  return;
@@ -573,7 +573,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
573
573
  navigator.clipboard.writeText(cellValue);
574
574
  }
575
575
  else if (['Enter', ' '].includes(event.key)) {
576
- if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-select') {
576
+ if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
577
577
  event.preventDefault();
578
578
  getMRT_RowSelectionHandler({
579
579
  row: cell.row,
@@ -582,20 +582,20 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
582
582
  staticRowIndex: +event.target.getAttribute('data-index'),
583
583
  })(event);
584
584
  }
585
- else if (((_d = header === null || header === void 0 ? void 0 : header.column) === null || _d === void 0 ? void 0 : _d.id) === 'mrt-row-select' &&
585
+ else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
586
586
  table.options.enableSelectAll) {
587
587
  event.preventDefault();
588
588
  getMRT_SelectAllHandler({
589
589
  table,
590
590
  })(event);
591
591
  }
592
- else if (((_e = cell === null || cell === void 0 ? void 0 : cell.column) === null || _e === void 0 ? void 0 : _e.id) === 'mrt-row-expand' &&
592
+ else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
593
593
  (cell.row.getCanExpand() ||
594
- ((_g = (_f = table.options).renderDetailPanel) === null || _g === void 0 ? void 0 : _g.call(_f, { row: cell.row, table })))) {
594
+ ((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
595
595
  event.preventDefault();
596
596
  cell.row.toggleExpanded();
597
597
  }
598
- else if (((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.id) === 'mrt-row-expand' &&
598
+ else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
599
599
  table.options.enableExpandAll) {
600
600
  event.preventDefault();
601
601
  table.toggleAllRowsExpanded();
@@ -604,7 +604,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
604
604
  event.preventDefault();
605
605
  cell.row.getIsPinned()
606
606
  ? cell.row.pin(false)
607
- : cell.row.pin(((_j = table.options.rowPinningDisplayMode) === null || _j === void 0 ? void 0 : _j.includes('bottom'))
607
+ : cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
608
608
  ? 'bottom'
609
609
  : 'top');
610
610
  }
@@ -614,7 +614,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
614
614
  actionsButton.click();
615
615
  }
616
616
  }
617
- else if ((_k = header === null || header === void 0 ? void 0 : header.column) === null || _k === void 0 ? void 0 : _k.getCanSort()) {
617
+ else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
618
618
  event.preventDefault();
619
619
  header.column.toggleSorting();
620
620
  }
@@ -629,11 +629,11 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
629
629
  // Focus the appropriate element
630
630
  if (autocomplete) {
631
631
  autocomplete.focus();
632
- (_l = autocomplete.select) === null || _l === void 0 ? void 0 : _l.call(autocomplete);
632
+ // autocomplete.select?.();
633
633
  }
634
634
  else if (input) {
635
635
  input.focus();
636
- (_m = input.select) === null || _m === void 0 ? void 0 : _m.call(input);
636
+ // input.select?.();
637
637
  }
638
638
  else if (select) {
639
639
  select.focus();
@@ -671,7 +671,6 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
671
671
  // }
672
672
  if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
673
673
  const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
674
- // Check if the autocomplete input exists and is focused
675
674
  if (autocomplete && document.activeElement === autocomplete) {
676
675
  if (event.key === 'ArrowDown') {
677
676
  // Do something with the autocomplete input
@@ -685,7 +684,6 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
685
684
  }
686
685
  }
687
686
  }
688
- // Additional logic if not an Autocomplete or not focused
689
687
  }
690
688
  const currentRow = parentElement || currentCell.closest('tr');
691
689
  const tableElement = containerElement || currentCell.closest('table');
@@ -722,6 +720,11 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
722
720
  : allCells.slice(0, currentCellIndex).reverse();
723
721
  return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
724
722
  };
723
+ // const findCurrentCell = () => {
724
+ // return allCells.find((cell) =>
725
+ // cell.matches(`[data-index="${currentIndex}"]`),
726
+ // );
727
+ // }
725
728
  switch (event.key) {
726
729
  case 'ArrowRight':
727
730
  nextCell = findAdjacentCell(currentIndex + 1, 'f');
@@ -4261,7 +4264,9 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
4261
4264
 
4262
4265
  const MRT_ShowHideColumnsMenu = (_a) => {
4263
4266
  var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
4264
- const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, enableColumnResizing, mrtTheme: { menuBackgroundColor }, }, } = table;
4267
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization,
4268
+ // enableColumnResizing,
4269
+ mrtTheme: { menuBackgroundColor }, }, } = table;
4265
4270
  const { columnOrder, columnPinning, density } = getState();
4266
4271
  const handleToggleAllColumns = (value) => {
4267
4272
  getAllLeafColumns()
@@ -4299,9 +4304,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
4299
4304
  justifyContent: 'space-between',
4300
4305
  p: '0.5rem',
4301
4306
  pt: 0,
4302
- }, children: [enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(Button__default["default"], { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll })), enableColumnResizing && (jsxRuntime.jsx(Button__default["default"], { onClick: () => {
4303
- table.resetColumnSizing(true);
4304
- }, children: localization.resetColumnSize }))] }), jsxRuntime.jsx(Divider__default["default"], {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
4307
+ }, children: [enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(Button__default["default"], { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsxRuntime.jsx(Divider__default["default"], {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
4305
4308
  };
4306
4309
 
4307
4310
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -4367,17 +4370,30 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
4367
4370
  return (jsxRuntime.jsx(Tooltip__default["default"], { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsxRuntime.jsx(SearchOffIcon, {}) : jsxRuntime.jsx(SearchIcon, {}) })) }));
4368
4371
  };
4369
4372
 
4373
+ const MRT_ToggleNavigationButton = (_a) => {
4374
+ var _b;
4375
+ var { table } = _a, rest = __rest(_a, ["table"]);
4376
+ const { getState, options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization, }, setEnableKeyboardShortcuts, } = table;
4377
+ const { enableKeyboardShortcuts } = getState();
4378
+ const [tooltipOpened, setTooltipOpened] = react.useState(false);
4379
+ const handleToggleFullScreen = () => {
4380
+ setTooltipOpened(false);
4381
+ setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
4382
+ };
4383
+ return (jsxRuntime.jsx(Tooltip__default["default"], { open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.keyboardNavigation, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.keyboardNavigation, onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: enableKeyboardShortcuts ? jsxRuntime.jsx(FullscreenExitIcon, {}) : jsxRuntime.jsx(FullscreenIcon, {}) })) }));
4384
+ };
4385
+
4370
4386
  const MRT_ToolbarInternalButtons = (_a) => {
4371
4387
  var _b;
4372
4388
  var { table } = _a, rest = __rest(_a, ["table"]);
4373
- const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, }, } = table;
4389
+ const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, enableKeyboardShortcuts }, } = table;
4374
4390
  return (jsxRuntime.jsx(Box__default["default"], Object.assign({}, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', display: 'flex', zIndex: 3 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: (_b = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({
4375
4391
  table,
4376
4392
  })) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableFilters &&
4377
4393
  enableGlobalFilter &&
4378
4394
  !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsxRuntime.jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
4379
4395
  enableColumnFilters &&
4380
- columnFilterDisplayMode !== 'popover' && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsxRuntime.jsx(MRT_ToggleFullScreenButton, { table: table }))] })) })));
4396
+ columnFilterDisplayMode !== 'popover' && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsxRuntime.jsx(MRT_ToggleFullScreenButton, { table: table })), enableKeyboardShortcuts && (jsxRuntime.jsx(MRT_ToggleNavigationButton, { table: table }))] })) })));
4381
4397
  };
4382
4398
 
4383
4399
  const MRT_GlobalFilterTextField = (_a) => {