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