material-react-table-narender 2.13.18 → 2.13.20

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,22 +526,42 @@ 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;
529
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
530
530
  debugger;
531
531
  const { getState, setEnableKeyboardShortcuts, } = table;
532
532
  const { enableKeyboardShortcuts } = getState();
533
- if (event.altKey) {
533
+ // alt + n
534
+ if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
534
535
  event.preventDefault();
535
536
  setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
536
537
  const currentCell = event.currentTarget;
537
538
  if (enableKeyboardShortcuts) {
538
- currentCell.style.outline = '2px solid red';
539
- // setTimeout(() => {
540
- // currentCell.style.outline = '';
541
- // },
542
- // 1000);
543
- currentCell.focus();
544
- return;
539
+ const input = currentCell.querySelector('input');
540
+ const select = currentCell.querySelector('select');
541
+ const checkbox = currentCell.querySelector('input[type="checkbox"]');
542
+ const button = currentCell.querySelector('button');
543
+ const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
544
+ if (autocomplete) {
545
+ autocomplete.focus();
546
+ (_a = autocomplete.select) === null || _a === void 0 ? void 0 : _a.call(autocomplete);
547
+ }
548
+ else if (input) {
549
+ input.focus();
550
+ (_b = input.select) === null || _b === void 0 ? void 0 : _b.call(input);
551
+ }
552
+ else if (select) {
553
+ select.focus();
554
+ }
555
+ else if (checkbox) {
556
+ checkbox.focus();
557
+ // checkbox.click();
558
+ }
559
+ else if (button) {
560
+ button.focus();
561
+ }
562
+ else {
563
+ currentCell.focus();
564
+ }
545
565
  }
546
566
  }
547
567
  // if (!table.options.enableKeyboardShortcuts) return;
@@ -554,7 +574,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
554
574
  navigator.clipboard.writeText(cellValue);
555
575
  }
556
576
  else if (['Enter', ' '].includes(event.key)) {
557
- if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
577
+ if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-select') {
558
578
  event.preventDefault();
559
579
  getMRT_RowSelectionHandler({
560
580
  row: cell.row,
@@ -563,20 +583,20 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
563
583
  staticRowIndex: +event.target.getAttribute('data-index'),
564
584
  })(event);
565
585
  }
566
- else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
586
+ else if (((_d = header === null || header === void 0 ? void 0 : header.column) === null || _d === void 0 ? void 0 : _d.id) === 'mrt-row-select' &&
567
587
  table.options.enableSelectAll) {
568
588
  event.preventDefault();
569
589
  getMRT_SelectAllHandler({
570
590
  table,
571
591
  })(event);
572
592
  }
573
- else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
593
+ else if (((_e = cell === null || cell === void 0 ? void 0 : cell.column) === null || _e === void 0 ? void 0 : _e.id) === 'mrt-row-expand' &&
574
594
  (cell.row.getCanExpand() ||
575
- ((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
595
+ ((_g = (_f = table.options).renderDetailPanel) === null || _g === void 0 ? void 0 : _g.call(_f, { row: cell.row, table })))) {
576
596
  event.preventDefault();
577
597
  cell.row.toggleExpanded();
578
598
  }
579
- else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
599
+ else if (((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.id) === 'mrt-row-expand' &&
580
600
  table.options.enableExpandAll) {
581
601
  event.preventDefault();
582
602
  table.toggleAllRowsExpanded();
@@ -585,7 +605,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
585
605
  event.preventDefault();
586
606
  cell.row.getIsPinned()
587
607
  ? cell.row.pin(false)
588
- : cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
608
+ : cell.row.pin(((_j = table.options.rowPinningDisplayMode) === null || _j === void 0 ? void 0 : _j.includes('bottom'))
589
609
  ? 'bottom'
590
610
  : 'top');
591
611
  }
@@ -595,7 +615,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
595
615
  actionsButton.click();
596
616
  }
597
617
  }
598
- else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
618
+ else if ((_k = header === null || header === void 0 ? void 0 : header.column) === null || _k === void 0 ? void 0 : _k.getCanSort()) {
599
619
  event.preventDefault();
600
620
  header.column.toggleSorting();
601
621
  }
@@ -610,11 +630,11 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
610
630
  // Focus the appropriate element
611
631
  if (autocomplete) {
612
632
  autocomplete.focus();
613
- (_j = autocomplete.select) === null || _j === void 0 ? void 0 : _j.call(autocomplete);
633
+ (_l = autocomplete.select) === null || _l === void 0 ? void 0 : _l.call(autocomplete);
614
634
  }
615
635
  else if (input) {
616
636
  input.focus();
617
- (_k = input.select) === null || _k === void 0 ? void 0 : _k.call(input);
637
+ (_m = input.select) === null || _m === void 0 ? void 0 : _m.call(input);
618
638
  }
619
639
  else if (select) {
620
640
  select.focus();