material-react-table-narender 2.13.18 → 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 +36 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +36 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/cell.utils.ts +26 -9
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
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
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 (((
|
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 (((
|
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 (((
|
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
|
-
((
|
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 (((
|
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(((
|
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 ((
|
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
|
-
(
|
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
|
-
(
|
545
|
+
(_m = input.select) === null || _m === void 0 ? void 0 : _m.call(input);
|
527
546
|
}
|
528
547
|
else if (select) {
|
529
548
|
select.focus();
|