material-react-table-narender 2.13.18 → 2.13.19

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -435,7 +435,7 @@ 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();
@@ -444,13 +444,32 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
444
444
  setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
445
445
  const currentCell = event.currentTarget;
446
446
  if (enableKeyboardShortcuts) {
447
- currentCell.style.outline = '2px solid red';
448
- // setTimeout(() => {
449
- // currentCell.style.outline = '';
450
- // },
451
- // 1000);
452
- currentCell.focus();
453
- return;
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
+ }
454
473
  }
455
474
  }
456
475
  // if (!table.options.enableKeyboardShortcuts) return;
@@ -463,7 +482,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
463
482
  navigator.clipboard.writeText(cellValue);
464
483
  }
465
484
  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') {
485
+ if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-select') {
467
486
  event.preventDefault();
468
487
  getMRT_RowSelectionHandler({
469
488
  row: cell.row,
@@ -472,20 +491,20 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
472
491
  staticRowIndex: +event.target.getAttribute('data-index'),
473
492
  })(event);
474
493
  }
475
- 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' &&
476
495
  table.options.enableSelectAll) {
477
496
  event.preventDefault();
478
497
  getMRT_SelectAllHandler({
479
498
  table,
480
499
  })(event);
481
500
  }
482
- 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' &&
483
502
  (cell.row.getCanExpand() ||
484
- ((_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 })))) {
485
504
  event.preventDefault();
486
505
  cell.row.toggleExpanded();
487
506
  }
488
- 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' &&
489
508
  table.options.enableExpandAll) {
490
509
  event.preventDefault();
491
510
  table.toggleAllRowsExpanded();
@@ -494,7 +513,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
494
513
  event.preventDefault();
495
514
  cell.row.getIsPinned()
496
515
  ? cell.row.pin(false)
497
- : 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'))
498
517
  ? 'bottom'
499
518
  : 'top');
500
519
  }
@@ -504,7 +523,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
504
523
  actionsButton.click();
505
524
  }
506
525
  }
507
- 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()) {
508
527
  event.preventDefault();
509
528
  header.column.toggleSorting();
510
529
  }
@@ -519,11 +538,11 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
519
538
  // Focus the appropriate element
520
539
  if (autocomplete) {
521
540
  autocomplete.focus();
522
- (_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);
523
542
  }
524
543
  else if (input) {
525
544
  input.focus();
526
- (_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);
527
546
  }
528
547
  else if (select) {
529
548
  select.focus();