material-react-table-narender 2.13.18 → 2.13.20

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -435,22 +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) {
442
+ // alt + n
443
+ if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
443
444
  event.preventDefault();
444
445
  setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
445
446
  const currentCell = event.currentTarget;
446
447
  if (enableKeyboardShortcuts) {
447
- currentCell.style.outline = '2px solid red';
448
- // setTimeout(() => {
449
- // currentCell.style.outline = '';
450
- // },
451
- // 1000);
452
- currentCell.focus();
453
- return;
448
+ const input = currentCell.querySelector('input');
449
+ const select = currentCell.querySelector('select');
450
+ const checkbox = currentCell.querySelector('input[type="checkbox"]');
451
+ const button = currentCell.querySelector('button');
452
+ const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
453
+ if (autocomplete) {
454
+ autocomplete.focus();
455
+ (_a = autocomplete.select) === null || _a === void 0 ? void 0 : _a.call(autocomplete);
456
+ }
457
+ else if (input) {
458
+ input.focus();
459
+ (_b = input.select) === null || _b === void 0 ? void 0 : _b.call(input);
460
+ }
461
+ else if (select) {
462
+ select.focus();
463
+ }
464
+ else if (checkbox) {
465
+ checkbox.focus();
466
+ // checkbox.click();
467
+ }
468
+ else if (button) {
469
+ button.focus();
470
+ }
471
+ else {
472
+ currentCell.focus();
473
+ }
454
474
  }
455
475
  }
456
476
  // if (!table.options.enableKeyboardShortcuts) return;
@@ -463,7 +483,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
463
483
  navigator.clipboard.writeText(cellValue);
464
484
  }
465
485
  else if (['Enter', ' '].includes(event.key)) {
466
- if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
486
+ if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-select') {
467
487
  event.preventDefault();
468
488
  getMRT_RowSelectionHandler({
469
489
  row: cell.row,
@@ -472,20 +492,20 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
472
492
  staticRowIndex: +event.target.getAttribute('data-index'),
473
493
  })(event);
474
494
  }
475
- else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
495
+ else if (((_d = header === null || header === void 0 ? void 0 : header.column) === null || _d === void 0 ? void 0 : _d.id) === 'mrt-row-select' &&
476
496
  table.options.enableSelectAll) {
477
497
  event.preventDefault();
478
498
  getMRT_SelectAllHandler({
479
499
  table,
480
500
  })(event);
481
501
  }
482
- else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
502
+ else if (((_e = cell === null || cell === void 0 ? void 0 : cell.column) === null || _e === void 0 ? void 0 : _e.id) === 'mrt-row-expand' &&
483
503
  (cell.row.getCanExpand() ||
484
- ((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
504
+ ((_g = (_f = table.options).renderDetailPanel) === null || _g === void 0 ? void 0 : _g.call(_f, { row: cell.row, table })))) {
485
505
  event.preventDefault();
486
506
  cell.row.toggleExpanded();
487
507
  }
488
- else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
508
+ else if (((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.id) === 'mrt-row-expand' &&
489
509
  table.options.enableExpandAll) {
490
510
  event.preventDefault();
491
511
  table.toggleAllRowsExpanded();
@@ -494,7 +514,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
494
514
  event.preventDefault();
495
515
  cell.row.getIsPinned()
496
516
  ? cell.row.pin(false)
497
- : cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
517
+ : cell.row.pin(((_j = table.options.rowPinningDisplayMode) === null || _j === void 0 ? void 0 : _j.includes('bottom'))
498
518
  ? 'bottom'
499
519
  : 'top');
500
520
  }
@@ -504,7 +524,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
504
524
  actionsButton.click();
505
525
  }
506
526
  }
507
- else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
527
+ else if ((_k = header === null || header === void 0 ? void 0 : header.column) === null || _k === void 0 ? void 0 : _k.getCanSort()) {
508
528
  event.preventDefault();
509
529
  header.column.toggleSorting();
510
530
  }
@@ -519,11 +539,11 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
519
539
  // Focus the appropriate element
520
540
  if (autocomplete) {
521
541
  autocomplete.focus();
522
- (_j = autocomplete.select) === null || _j === void 0 ? void 0 : _j.call(autocomplete);
542
+ (_l = autocomplete.select) === null || _l === void 0 ? void 0 : _l.call(autocomplete);
523
543
  }
524
544
  else if (input) {
525
545
  input.focus();
526
- (_k = input.select) === null || _k === void 0 ? void 0 : _k.call(input);
546
+ (_m = input.select) === null || _m === void 0 ? void 0 : _m.call(input);
527
547
  }
528
548
  else if (select) {
529
549
  select.focus();