es-grid-template 1.9.96 → 1.9.98
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/es/grid-component/hooks/rowFocus.d.ts +4 -3
- package/es/grid-component/hooks/rowFocus.js +65 -3
- package/es/grid-component/type.d.ts +1 -1
- package/es/group-component/body/TableBodyCell.d.ts +2 -0
- package/es/group-component/body/TableBodyCell.js +15 -30
- package/es/group-component/body/TableBodyCellEdit.js +21 -84
- package/es/group-component/body/TableBodyCellEmpty.d.ts +2 -0
- package/es/group-component/body/TableBodyCellEmpty.js +15 -30
- package/es/group-component/body/TableBodyRowGroupCell.d.ts +2 -0
- package/es/group-component/body/TableBodyRowGroupCell.js +15 -30
- package/es/group-component/hook/utils.d.ts +9 -9
- package/es/group-component/table/TableWrapper.js +1 -0
- package/es/table-component/body/TableBodyCell.js +15 -39
- package/es/table-component/body/TableBodyCellEdit.js +18 -69
- package/es/table-component/table/TableWrapper.js +1 -0
- package/es/table-virtuoso/body/TableBodyCell.d.ts +1 -0
- package/es/table-virtuoso/body/TableBodyCell.js +13 -30
- package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +1 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +13 -30
- package/es/table-virtuoso/body/TableBodyRow.d.ts +2 -1
- package/es/table-virtuoso/body/TableBodyRow.js +10 -3
- package/es/table-virtuoso/table/TableWrapper.js +7 -0
- package/lib/grid-component/hooks/rowFocus.d.ts +4 -3
- package/lib/grid-component/hooks/rowFocus.js +66 -3
- package/lib/grid-component/type.d.ts +1 -1
- package/lib/group-component/body/TableBodyCell.d.ts +2 -0
- package/lib/group-component/body/TableBodyCell.js +14 -29
- package/lib/group-component/body/TableBodyCellEdit.js +20 -83
- package/lib/group-component/body/TableBodyCellEmpty.d.ts +2 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +14 -29
- package/lib/group-component/body/TableBodyRowGroupCell.d.ts +2 -0
- package/lib/group-component/body/TableBodyRowGroupCell.js +14 -29
- package/lib/group-component/table/TableWrapper.js +1 -0
- package/lib/table-component/body/TableBodyCell.js +14 -38
- package/lib/table-component/body/TableBodyCellEdit.js +17 -68
- package/lib/table-component/table/TableWrapper.js +1 -0
- package/lib/table-virtuoso/body/TableBodyCell.d.ts +1 -0
- package/lib/table-virtuoso/body/TableBodyCell.js +12 -29
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +1 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +12 -29
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +2 -1
- package/lib/table-virtuoso/body/TableBodyRow.js +10 -3
- package/lib/table-virtuoso/table/TableWrapper.js +7 -0
- package/package.json +1 -1
|
@@ -99,35 +99,20 @@ const TableBodyCellEmpty = props => {
|
|
|
99
99
|
setIsPasting?.(false);
|
|
100
100
|
},
|
|
101
101
|
onKeyDown: e => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
cellFocus.focus();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
120
|
-
const prevIndex = cell.row.index - 1;
|
|
121
|
-
const nextId = flatRows[prevIndex].id;
|
|
122
|
-
setFocusedCell?.({
|
|
123
|
-
colId: cell.column.id,
|
|
124
|
-
rowId: nextId
|
|
125
|
-
});
|
|
126
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
127
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
128
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
129
|
-
if (cellFocus) {
|
|
130
|
-
cellFocus.focus();
|
|
102
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
103
|
+
const rows = table.getRowModel().rows;
|
|
104
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
105
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
106
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
107
|
+
if (nextRow) {
|
|
108
|
+
setFocusedCell?.({
|
|
109
|
+
colId: cell.column.id,
|
|
110
|
+
rowId: nextRow.id
|
|
111
|
+
});
|
|
112
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
113
|
+
align: 'center'
|
|
114
|
+
}));
|
|
115
|
+
(0, _rowFocus.notifyArrowRowFocus)(e, nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
118
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
2
3
|
import type { Cell, Table } from "@tanstack/react-table";
|
|
3
4
|
import type { CommandClick } from "../../grid-component/type";
|
|
4
5
|
interface TableBodyCellProps<T> {
|
|
5
6
|
table: Table<T>;
|
|
7
|
+
rowVirtualizer?: Virtualizer<HTMLDivElement, HTMLDivElement>;
|
|
6
8
|
tableId: string;
|
|
7
9
|
cell: Cell<T, unknown>;
|
|
8
10
|
commandClick?: (args: CommandClick<T>) => void;
|
|
@@ -434,35 +434,20 @@ const TableBodyCell = props => {
|
|
|
434
434
|
setIsPasting?.(false);
|
|
435
435
|
},
|
|
436
436
|
onKeyDown: e => {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
cellFocus.focus();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
455
|
-
const prevIndex = cell.row.index - 1;
|
|
456
|
-
const nextId = flatRows[prevIndex].id;
|
|
457
|
-
setFocusedCell?.({
|
|
458
|
-
colId: cell.column.id,
|
|
459
|
-
rowId: nextId
|
|
460
|
-
});
|
|
461
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
462
|
-
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
463
|
-
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
464
|
-
if (cellFocus) {
|
|
465
|
-
cellFocus.focus();
|
|
437
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
438
|
+
const rows = table.getRowModel().rows;
|
|
439
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
440
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
441
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
442
|
+
if (nextRow) {
|
|
443
|
+
setFocusedCell?.({
|
|
444
|
+
colId: cell.column.id,
|
|
445
|
+
rowId: nextRow.id
|
|
446
|
+
});
|
|
447
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
448
|
+
align: 'center'
|
|
449
|
+
}));
|
|
450
|
+
(0, _rowFocus.notifyArrowRowFocus)(e, nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
466
451
|
}
|
|
467
452
|
}
|
|
468
453
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -442,44 +442,20 @@ const TableBodyCell = props => {
|
|
|
442
442
|
}
|
|
443
443
|
},
|
|
444
444
|
onKeyDown: e => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
// e.preventDefault()
|
|
460
|
-
// rowVirtualizer.scrollToIndex(cell.row.index, {
|
|
461
|
-
// align: 'center', // 'start' | 'center' | 'end'
|
|
462
|
-
// })
|
|
463
|
-
// }
|
|
464
|
-
|
|
465
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
466
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
467
|
-
if (cellFocus) {
|
|
468
|
-
cellFocus.focus();
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
472
|
-
const prevIndex = cell.row.index - 1;
|
|
473
|
-
const nextId = flatRows[prevIndex].id;
|
|
474
|
-
setFocusedCell?.({
|
|
475
|
-
colId: cell.column.id,
|
|
476
|
-
rowId: nextId
|
|
477
|
-
});
|
|
478
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
479
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
480
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
481
|
-
if (cellFocus) {
|
|
482
|
-
cellFocus.focus();
|
|
445
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
446
|
+
const rows = table.getRowModel().rows;
|
|
447
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
448
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
449
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
450
|
+
if (nextRow) {
|
|
451
|
+
setFocusedCell?.({
|
|
452
|
+
colId: cell.column.id,
|
|
453
|
+
rowId: nextRow.id
|
|
454
|
+
});
|
|
455
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
456
|
+
align: 'center'
|
|
457
|
+
}));
|
|
458
|
+
(0, _rowFocus.notifyArrowRowFocus)(e, nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
483
459
|
}
|
|
484
460
|
}
|
|
485
461
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -824,77 +824,26 @@ const TableBodyCellEdit = props => {
|
|
|
824
824
|
}
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (e.key === 'ArrowDown') {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
setFocusedCell?.({
|
|
835
|
-
rowId: nextRowId,
|
|
836
|
-
colId
|
|
837
|
-
});
|
|
838
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
839
|
-
setStartCell?.({
|
|
840
|
-
rowId: nextRowId,
|
|
841
|
-
colId
|
|
842
|
-
});
|
|
843
|
-
setEndCell?.({
|
|
844
|
-
rowId: nextRowId,
|
|
845
|
-
colId
|
|
846
|
-
});
|
|
847
|
-
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
848
|
-
rowId: nextRowId,
|
|
849
|
-
colId
|
|
850
|
-
}, {
|
|
851
|
-
rowId: nextRowId,
|
|
852
|
-
colId
|
|
853
|
-
}));
|
|
854
|
-
|
|
855
|
-
// columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
856
|
-
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
857
|
-
|
|
858
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
859
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
860
|
-
if (cellFocus) {
|
|
861
|
-
cellFocus.focus();
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
if (e.key === 'ArrowUp') {
|
|
867
|
-
// e.preventDefault()
|
|
868
|
-
// e.stopPropagation()
|
|
869
|
-
|
|
870
|
-
const nextRow = table.getRowModel().rows[rowNumber - 1];
|
|
827
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
828
|
+
const rows = table.getRowModel().rows;
|
|
829
|
+
const currentIndex = rows.findIndex(row => row.id === rowId);
|
|
830
|
+
if (currentIndex < 0) return;
|
|
831
|
+
const step = e.key === 'ArrowDown' ? 1 : -1;
|
|
832
|
+
const nextIndex = currentIndex + step;
|
|
833
|
+
const nextRow = rows[nextIndex];
|
|
871
834
|
if (nextRow) {
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
rowId: nextRowId,
|
|
875
|
-
colId
|
|
876
|
-
});
|
|
877
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
878
|
-
setStartCell?.({
|
|
879
|
-
rowId: nextRowId,
|
|
880
|
-
colId
|
|
881
|
-
});
|
|
882
|
-
setEndCell?.({
|
|
883
|
-
rowId: nextRowId,
|
|
884
|
-
colId
|
|
885
|
-
});
|
|
886
|
-
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
887
|
-
rowId: nextRowId,
|
|
888
|
-
colId
|
|
889
|
-
}, {
|
|
890
|
-
rowId: nextRowId,
|
|
835
|
+
const nextCell = {
|
|
836
|
+
rowId: nextRow.id,
|
|
891
837
|
colId
|
|
838
|
+
};
|
|
839
|
+
setFocusedCell?.(nextCell);
|
|
840
|
+
setStartCell?.(nextCell);
|
|
841
|
+
setEndCell?.(nextCell);
|
|
842
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, nextCell, nextCell));
|
|
843
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, colId, () => rowVirtualizer.scrollToIndex(nextIndex, {
|
|
844
|
+
align: 'center'
|
|
892
845
|
}));
|
|
893
|
-
|
|
894
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
895
|
-
if (cellFocus) {
|
|
896
|
-
cellFocus.focus();
|
|
897
|
-
}
|
|
846
|
+
(0, _rowFocus.notifyArrowRowFocus)(e, nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
898
847
|
}
|
|
899
848
|
return;
|
|
900
849
|
}
|
|
@@ -4,6 +4,7 @@ import type { CommandClick } from "../../grid-component/type";
|
|
|
4
4
|
import type { VirtualItem } from "@tanstack/react-virtual";
|
|
5
5
|
interface TableBodyCellProps<T> {
|
|
6
6
|
table: Table<T>;
|
|
7
|
+
scrollToRow?: (index: number) => void;
|
|
7
8
|
tableId: string;
|
|
8
9
|
cell: Cell<T, unknown>;
|
|
9
10
|
commandClick?: (args: CommandClick<T>) => void;
|
|
@@ -381,35 +381,18 @@ const TableBodyCell = props => {
|
|
|
381
381
|
}
|
|
382
382
|
},
|
|
383
383
|
onKeyDown: e => {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
397
|
-
if (cellFocus) {
|
|
398
|
-
cellFocus.focus();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
402
|
-
const prevIndex = cell.row.index - 1;
|
|
403
|
-
const nextId = flatRows[prevIndex].id;
|
|
404
|
-
setFocusedCell?.({
|
|
405
|
-
colId: cell.column.id,
|
|
406
|
-
rowId: nextId
|
|
407
|
-
});
|
|
408
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
409
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
410
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
411
|
-
if (cellFocus) {
|
|
412
|
-
cellFocus.focus();
|
|
384
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
385
|
+
const rows = table.getRowModel().rows;
|
|
386
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
387
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
388
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
389
|
+
if (nextRow) {
|
|
390
|
+
setFocusedCell?.({
|
|
391
|
+
colId: cell.column.id,
|
|
392
|
+
rowId: nextRow.id
|
|
393
|
+
});
|
|
394
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, cell.column.id, () => props.scrollToRow?.(nextIndex));
|
|
395
|
+
(0, _rowFocus.notifyArrowRowFocus)(e, nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
413
396
|
}
|
|
414
397
|
}
|
|
415
398
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -4,6 +4,7 @@ import type { CommandClick } from "../../grid-component/type";
|
|
|
4
4
|
import type { VirtualItem } from "@tanstack/react-virtual";
|
|
5
5
|
interface TableBodyCellProps<T> {
|
|
6
6
|
table: Table<T>;
|
|
7
|
+
scrollToRow?: (index: number) => void;
|
|
7
8
|
tableId: string;
|
|
8
9
|
cell: Cell<T, unknown>;
|
|
9
10
|
commandClick?: (args: CommandClick<T>) => void;
|
|
@@ -96,35 +96,18 @@ const TableBodyCellRowGroup = props => {
|
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
onKeyDown: e => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
112
|
-
if (cellFocus) {
|
|
113
|
-
cellFocus.focus();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
117
|
-
const prevIndex = cell.row.index - 1;
|
|
118
|
-
const nextId = flatRows[prevIndex].id;
|
|
119
|
-
setFocusedCell?.({
|
|
120
|
-
colId: cell.column.id,
|
|
121
|
-
rowId: nextId
|
|
122
|
-
});
|
|
123
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
124
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
125
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
126
|
-
if (cellFocus) {
|
|
127
|
-
cellFocus.focus();
|
|
99
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
100
|
+
const rows = table.getRowModel().rows;
|
|
101
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
102
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
103
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
104
|
+
if (nextRow) {
|
|
105
|
+
setFocusedCell?.({
|
|
106
|
+
colId: cell.column.id,
|
|
107
|
+
rowId: nextRow.id
|
|
108
|
+
});
|
|
109
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, cell.column.id, () => props.scrollToRow?.(nextIndex));
|
|
110
|
+
(0, _rowFocus.notifyArrowRowFocus)(e, nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
128
111
|
}
|
|
129
112
|
}
|
|
130
113
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -4,10 +4,11 @@ import type { CommandClick } from "../../grid-component/type";
|
|
|
4
4
|
interface TableBodyRowProps<T> {
|
|
5
5
|
tableId: string;
|
|
6
6
|
table: Table<T>;
|
|
7
|
+
scrollToRow?: (index: number) => void;
|
|
7
8
|
row: Row<T>;
|
|
8
9
|
commandClick?: (args: CommandClick<T>) => void;
|
|
9
10
|
editAble?: boolean;
|
|
10
11
|
[key: string]: any;
|
|
11
12
|
}
|
|
12
|
-
declare const TableBodyRow: <RecordType extends object>({ tableId, table, row, virtualRow, commandClick, contextMenuItems, onContextMenu, rowheight, editAble, isEditing, isRowEditable, ...rest }: TableBodyRowProps<RecordType>) => JSX.Element;
|
|
13
|
+
declare const TableBodyRow: <RecordType extends object>({ tableId, table, row, scrollToRow, virtualRow, commandClick, contextMenuItems, onContextMenu, rowheight, editAble, isEditing, isRowEditable, ...rest }: TableBodyRowProps<RecordType>) => JSX.Element;
|
|
13
14
|
export default TableBodyRow;
|
|
@@ -21,6 +21,7 @@ const TableBodyRow = ({
|
|
|
21
21
|
tableId,
|
|
22
22
|
table,
|
|
23
23
|
row,
|
|
24
|
+
scrollToRow,
|
|
24
25
|
virtualRow,
|
|
25
26
|
commandClick,
|
|
26
27
|
contextMenuItems,
|
|
@@ -140,7 +141,9 @@ const TableBodyRow = ({
|
|
|
140
141
|
rowData: row.original,
|
|
141
142
|
value: cellValue
|
|
142
143
|
}) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, headertext, headertext ? ': ' : '', " ", cellContent);
|
|
143
|
-
return /*#__PURE__*/_react.default.createElement(_TableBodyCell.default, (0, _extends2.default)({
|
|
144
|
+
return /*#__PURE__*/_react.default.createElement(_TableBodyCell.default, (0, _extends2.default)({
|
|
145
|
+
scrollToRow: scrollToRow
|
|
146
|
+
}, otherCellAttributes, {
|
|
144
147
|
table: table,
|
|
145
148
|
tableId: tableId,
|
|
146
149
|
key: cell.id,
|
|
@@ -173,7 +176,9 @@ const TableBodyRow = ({
|
|
|
173
176
|
const childrenData = row.subRows.map(it => it.original);
|
|
174
177
|
const sumValue = (0, _hooks.sumByField)(childrenData, cell.column.id);
|
|
175
178
|
const sumValueFormat = (0, _reactNumericComponent.numericFormatter)(sumValue.toString(), numericFormatProps);
|
|
176
|
-
return /*#__PURE__*/_react.default.createElement(_TableBodyCellRowGroup.default, (0, _extends2.default)({
|
|
179
|
+
return /*#__PURE__*/_react.default.createElement(_TableBodyCellRowGroup.default, (0, _extends2.default)({
|
|
180
|
+
scrollToRow: scrollToRow
|
|
181
|
+
}, otherCellAttributes, {
|
|
177
182
|
table: table,
|
|
178
183
|
tableId: tableId,
|
|
179
184
|
key: cell.id,
|
|
@@ -186,7 +191,9 @@ const TableBodyRow = ({
|
|
|
186
191
|
sumValue: sumValueFormat
|
|
187
192
|
}));
|
|
188
193
|
}
|
|
189
|
-
return /*#__PURE__*/_react.default.createElement(_TableBodyCell.default, (0, _extends2.default)({
|
|
194
|
+
return /*#__PURE__*/_react.default.createElement(_TableBodyCell.default, (0, _extends2.default)({
|
|
195
|
+
scrollToRow: scrollToRow
|
|
196
|
+
}, otherCellAttributes, {
|
|
190
197
|
table: table,
|
|
191
198
|
tableId: tableId,
|
|
192
199
|
key: cell.id,
|
|
@@ -45,6 +45,11 @@ const TableWrapper = props => {
|
|
|
45
45
|
|
|
46
46
|
// ref cho scroll container
|
|
47
47
|
const scrollRef = (0, _react.useRef)(null);
|
|
48
|
+
const virtuosoRef = (0, _react.useRef)(null);
|
|
49
|
+
const scrollToRow = index => virtuosoRef.current?.scrollToIndex({
|
|
50
|
+
index,
|
|
51
|
+
align: 'center'
|
|
52
|
+
});
|
|
48
53
|
const {
|
|
49
54
|
rows
|
|
50
55
|
} = table.getRowModel();
|
|
@@ -137,6 +142,7 @@ const TableWrapper = props => {
|
|
|
137
142
|
position: "relative"
|
|
138
143
|
}
|
|
139
144
|
}, /*#__PURE__*/_react.default.createElement(_reactVirtuoso.TableVirtuoso, (0, _extends2.default)({
|
|
145
|
+
ref: virtuosoRef,
|
|
140
146
|
data: table.getRowModel().rows,
|
|
141
147
|
totalCount: rows.length
|
|
142
148
|
}, onVisibleRowsChange ? {
|
|
@@ -201,6 +207,7 @@ const TableWrapper = props => {
|
|
|
201
207
|
return /*#__PURE__*/_react.default.createElement(_TableBodyRow.default, (0, _extends2.default)({
|
|
202
208
|
tableId: id,
|
|
203
209
|
row: row,
|
|
210
|
+
scrollToRow: scrollToRow,
|
|
204
211
|
table: table,
|
|
205
212
|
commandClick: commandClick,
|
|
206
213
|
rowheight: editAble ? 37 : rowheight,
|