material-react-table-narender 2.13.3 → 2.13.4
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -16,7 +16,7 @@ import {
|
|
16
16
|
type MRT_RowData,
|
17
17
|
type MRT_TableInstance,
|
18
18
|
} from '../../types';
|
19
|
-
import { isCellEditable, openEditingCell } from '../../utils/cell.utils';
|
19
|
+
import { cellKeyboardShortcuts, isCellEditable, openEditingCell } from '../../utils/cell.utils';
|
20
20
|
import { getCommonMRTCellStyles } from '../../utils/style.utils';
|
21
21
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
22
22
|
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
@@ -228,6 +228,16 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
228
228
|
}
|
229
229
|
};
|
230
230
|
|
231
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLTableCellElement>) => {
|
232
|
+
tableCellProps?.onKeyDown?.(event);
|
233
|
+
cellKeyboardShortcuts({
|
234
|
+
cell,
|
235
|
+
cellValue: cell.getValue<string>(),
|
236
|
+
event,
|
237
|
+
table,
|
238
|
+
});
|
239
|
+
};
|
240
|
+
|
231
241
|
return (
|
232
242
|
<TableCell
|
233
243
|
align={theme.direction === 'rtl' ? 'right' : 'left'}
|
@@ -235,6 +245,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
235
245
|
data-pinned={!!isColumnPinned || undefined}
|
236
246
|
tabIndex={enableKeyboardShortcuts ? 0 : undefined}
|
237
247
|
{...tableCellProps}
|
248
|
+
onKeyDown={handleKeyDown}
|
238
249
|
onContextMenu={handleContextMenu}
|
239
250
|
onDoubleClick={handleDoubleClick}
|
240
251
|
onDragEnter={handleDragEnter}
|
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
} from '../../types';
|
8
8
|
import { getCommonMRTCellStyles } from '../../utils/style.utils';
|
9
9
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
10
|
+
import { cellKeyboardShortcuts } from '../../utils/cell.utils';
|
10
11
|
|
11
12
|
export interface MRT_TableFooterCellProps<TData extends MRT_RowData>
|
12
13
|
extends TableCellProps {
|
@@ -43,6 +44,16 @@ export const MRT_TableFooterCell = <TData extends MRT_RowData>({
|
|
43
44
|
...rest,
|
44
45
|
};
|
45
46
|
|
47
|
+
|
48
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLTableCellElement>) => {
|
49
|
+
tableCellProps?.onKeyDown?.(event);
|
50
|
+
cellKeyboardShortcuts({
|
51
|
+
event,
|
52
|
+
cellValue: footer.column.columnDef.footer,
|
53
|
+
table,
|
54
|
+
});
|
55
|
+
};
|
56
|
+
|
46
57
|
return (
|
47
58
|
<TableCell
|
48
59
|
align={
|
@@ -58,6 +69,7 @@ export const MRT_TableFooterCell = <TData extends MRT_RowData>({
|
|
58
69
|
tabIndex={enableKeyboardShortcuts ? 0 : undefined}
|
59
70
|
variant="footer"
|
60
71
|
{...tableCellProps}
|
72
|
+
onKeyDown={handleKeyDown}
|
61
73
|
sx={(theme) => ({
|
62
74
|
fontWeight: 'bold',
|
63
75
|
p:
|
@@ -17,6 +17,7 @@ import {
|
|
17
17
|
} from '../../types';
|
18
18
|
import { getCommonMRTCellStyles } from '../../utils/style.utils';
|
19
19
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
20
|
+
import { cellKeyboardShortcuts } from '../../utils/cell.utils';
|
20
21
|
|
21
22
|
export interface MRT_TableHeadCellProps<TData extends MRT_RowData>
|
22
23
|
extends TableCellProps {
|
@@ -148,6 +149,16 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
148
149
|
}
|
149
150
|
};
|
150
151
|
|
152
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLTableCellElement>) => {
|
153
|
+
tableCellProps?.onKeyDown?.(event);
|
154
|
+
cellKeyboardShortcuts({
|
155
|
+
event,
|
156
|
+
cellValue: header.column.columnDef.header,
|
157
|
+
table,
|
158
|
+
header,
|
159
|
+
});
|
160
|
+
};
|
161
|
+
|
151
162
|
const HeaderElement =
|
152
163
|
parseFromValuesOrFunc(columnDef.Header, {
|
153
164
|
column,
|
@@ -188,6 +199,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
188
199
|
}
|
189
200
|
}}
|
190
201
|
{...tableCellProps}
|
202
|
+
onKeyDown={handleKeyDown}
|
191
203
|
sx={(theme: Theme) => ({
|
192
204
|
'& :hover': {
|
193
205
|
'.MuiButtonBase-root': {
|
package/src/utils/cell.utils.ts
CHANGED
@@ -79,6 +79,7 @@ export const cellKeyboardShortcuts = <TData extends MRT_RowData = MRT_RowData>({
|
|
79
79
|
parentElement?: HTMLTableRowElement;
|
80
80
|
table: MRT_TableInstance<TData>;
|
81
81
|
}) => {
|
82
|
+
debugger;
|
82
83
|
if (!table.options.enableKeyboardShortcuts) return;
|
83
84
|
if (event.isPropagationStopped()) return;
|
84
85
|
const currentCell = event.currentTarget;
|