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.esm.js +38 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/cell.utils.ts +28 -10
package/package.json
CHANGED
package/src/utils/cell.utils.ts
CHANGED
@@ -90,22 +90,40 @@ export const cellKeyboardShortcuts = <TData extends MRT_RowData = MRT_RowData>({
|
|
90
90
|
|
91
91
|
const { enableKeyboardShortcuts } = getState();
|
92
92
|
|
93
|
-
|
93
|
+
// alt + n
|
94
|
+
if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
|
94
95
|
event.preventDefault();
|
95
96
|
setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
|
96
97
|
const currentCell = event.currentTarget;
|
97
98
|
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
100
|
+
if (enableKeyboardShortcuts) {
|
101
|
+
const input = currentCell.querySelector('input') as HTMLInputElement;
|
102
|
+
const select = currentCell.querySelector('select') as HTMLSelectElement;
|
103
|
+
const checkbox = currentCell.querySelector('input[type="checkbox"]') as HTMLInputElement;
|
104
|
+
const button = currentCell.querySelector('button') as HTMLButtonElement;
|
105
|
+
const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]') as HTMLInputElement;
|
106
|
+
|
107
|
+
|
108
|
+
if (autocomplete) {
|
109
|
+
autocomplete.focus();
|
110
|
+
autocomplete.select?.();
|
111
|
+
} else if (input) {
|
112
|
+
input.focus();
|
113
|
+
input.select?.();
|
114
|
+
} else if (select) {
|
115
|
+
select.focus();
|
116
|
+
} else if (checkbox) {
|
117
|
+
checkbox.focus();
|
118
|
+
// checkbox.click();
|
119
|
+
} else if (button) {
|
120
|
+
button.focus();
|
121
|
+
} else {
|
122
|
+
currentCell.focus();
|
108
123
|
}
|
124
|
+
}
|
125
|
+
|
126
|
+
}
|
109
127
|
|
110
128
|
// if (!table.options.enableKeyboardShortcuts) return;
|
111
129
|
if (!enableKeyboardShortcuts) return
|