material-react-table-narender 2.13.17 → 2.13.19

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.esm.js CHANGED
@@ -435,15 +435,42 @@ const openEditingCell = ({ cell, table, }) => {
435
435
  }
436
436
  };
437
437
  const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
438
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
438
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
439
439
  debugger;
440
440
  const { getState, setEnableKeyboardShortcuts, } = table;
441
441
  const { enableKeyboardShortcuts } = getState();
442
- if (event.altKey && event.key.toLowerCase() === 'n') {
442
+ if (event.altKey) {
443
443
  event.preventDefault();
444
444
  setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
445
445
  const currentCell = event.currentTarget;
446
- currentCell.focus();
446
+ if (enableKeyboardShortcuts) {
447
+ const input = currentCell.querySelector('input');
448
+ const select = currentCell.querySelector('select');
449
+ const checkbox = currentCell.querySelector('input[type="checkbox"]');
450
+ const button = currentCell.querySelector('button');
451
+ const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
452
+ if (autocomplete) {
453
+ autocomplete.focus();
454
+ (_a = autocomplete.select) === null || _a === void 0 ? void 0 : _a.call(autocomplete);
455
+ }
456
+ else if (input) {
457
+ input.focus();
458
+ (_b = input.select) === null || _b === void 0 ? void 0 : _b.call(input);
459
+ }
460
+ else if (select) {
461
+ select.focus();
462
+ }
463
+ else if (checkbox) {
464
+ checkbox.focus();
465
+ // checkbox.click();
466
+ }
467
+ else if (button) {
468
+ button.focus();
469
+ }
470
+ else {
471
+ currentCell.focus();
472
+ }
473
+ }
447
474
  }
448
475
  // if (!table.options.enableKeyboardShortcuts) return;
449
476
  if (!enableKeyboardShortcuts)
@@ -455,7 +482,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
455
482
  navigator.clipboard.writeText(cellValue);
456
483
  }
457
484
  else if (['Enter', ' '].includes(event.key)) {
458
- if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
485
+ if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-select') {
459
486
  event.preventDefault();
460
487
  getMRT_RowSelectionHandler({
461
488
  row: cell.row,
@@ -464,20 +491,20 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
464
491
  staticRowIndex: +event.target.getAttribute('data-index'),
465
492
  })(event);
466
493
  }
467
- else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
494
+ else if (((_d = header === null || header === void 0 ? void 0 : header.column) === null || _d === void 0 ? void 0 : _d.id) === 'mrt-row-select' &&
468
495
  table.options.enableSelectAll) {
469
496
  event.preventDefault();
470
497
  getMRT_SelectAllHandler({
471
498
  table,
472
499
  })(event);
473
500
  }
474
- else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
501
+ else if (((_e = cell === null || cell === void 0 ? void 0 : cell.column) === null || _e === void 0 ? void 0 : _e.id) === 'mrt-row-expand' &&
475
502
  (cell.row.getCanExpand() ||
476
- ((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
503
+ ((_g = (_f = table.options).renderDetailPanel) === null || _g === void 0 ? void 0 : _g.call(_f, { row: cell.row, table })))) {
477
504
  event.preventDefault();
478
505
  cell.row.toggleExpanded();
479
506
  }
480
- else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
507
+ else if (((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.id) === 'mrt-row-expand' &&
481
508
  table.options.enableExpandAll) {
482
509
  event.preventDefault();
483
510
  table.toggleAllRowsExpanded();
@@ -486,7 +513,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
486
513
  event.preventDefault();
487
514
  cell.row.getIsPinned()
488
515
  ? cell.row.pin(false)
489
- : cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
516
+ : cell.row.pin(((_j = table.options.rowPinningDisplayMode) === null || _j === void 0 ? void 0 : _j.includes('bottom'))
490
517
  ? 'bottom'
491
518
  : 'top');
492
519
  }
@@ -496,7 +523,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
496
523
  actionsButton.click();
497
524
  }
498
525
  }
499
- else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
526
+ else if ((_k = header === null || header === void 0 ? void 0 : header.column) === null || _k === void 0 ? void 0 : _k.getCanSort()) {
500
527
  event.preventDefault();
501
528
  header.column.toggleSorting();
502
529
  }
@@ -511,11 +538,11 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
511
538
  // Focus the appropriate element
512
539
  if (autocomplete) {
513
540
  autocomplete.focus();
514
- (_j = autocomplete.select) === null || _j === void 0 ? void 0 : _j.call(autocomplete);
541
+ (_l = autocomplete.select) === null || _l === void 0 ? void 0 : _l.call(autocomplete);
515
542
  }
516
543
  else if (input) {
517
544
  input.focus();
518
- (_k = input.select) === null || _k === void 0 ? void 0 : _k.call(input);
545
+ (_m = input.select) === null || _m === void 0 ? void 0 : _m.call(input);
519
546
  }
520
547
  else if (select) {
521
548
  select.focus();
@@ -2298,6 +2325,7 @@ const MRT_TableBodyCell = (_a) => {
2298
2325
  const handleKeyDown = (event) => {
2299
2326
  var _a;
2300
2327
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2328
+ debugger;
2301
2329
  cellKeyboardShortcuts({
2302
2330
  cell,
2303
2331
  cellValue: cell.getValue(),