es-grid-template 1.9.96 → 1.9.97
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 +2 -1
- package/es/grid-component/hooks/rowFocus.js +26 -0
- 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 +2 -1
- package/lib/grid-component/hooks/rowFocus.js +27 -0
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MouseEvent } from 'react';
|
|
1
|
+
import type { KeyboardEvent, MouseEvent } from 'react';
|
|
2
2
|
import type { RowFocusEventArgs } from '../type';
|
|
3
3
|
type RowFocus<T> = (args: RowFocusEventArgs<T>) => void;
|
|
4
4
|
/** Capture clicks even when a cell handles the event itself. */
|
|
@@ -8,4 +8,5 @@ export declare function getRowFocusHandlers<T>(rowData: T, rowFocus?: RowFocus<T
|
|
|
8
8
|
};
|
|
9
9
|
/** Notify arrow focus without changing the existing navigation or selection. */
|
|
10
10
|
export declare function notifyArrowRowFocus<T>(rowData: T, method: 'arrowUp' | 'arrowDown', useArrow?: boolean, rowFocus?: RowFocus<T>): void;
|
|
11
|
+
export declare function focusArrowRow(event: KeyboardEvent, rowId: string, columnId: string, scrollToRow: () => void): void;
|
|
11
12
|
export {};
|
|
@@ -22,4 +22,30 @@ export function notifyArrowRowFocus(rowData, method, useArrow, rowFocus) {
|
|
|
22
22
|
rowData,
|
|
23
23
|
method
|
|
24
24
|
});
|
|
25
|
+
}
|
|
26
|
+
export function focusArrowRow(event, rowId, columnId, scrollToRow) {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
const source = event.currentTarget;
|
|
29
|
+
const body = source.closest('.ui-rc-grid-row')?.parentElement;
|
|
30
|
+
const row = body && Array.from(body.children).find(child => child.getAttribute('data-row-key') === rowId);
|
|
31
|
+
const viewport = source.closest('[data-grid-scroll], [data-virtuoso-scroller]');
|
|
32
|
+
const canScroll = viewport && viewport.scrollHeight > viewport.clientHeight;
|
|
33
|
+
if (!row) {
|
|
34
|
+
if (canScroll) scrollToRow();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const cell = Array.from(row.querySelectorAll(':scope > [data-col-key]')).find(element => element.getAttribute('data-col-key') === columnId) ?? row.querySelector(':scope > .ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
38
|
+
cell?.focus({
|
|
39
|
+
preventScroll: true
|
|
40
|
+
});
|
|
41
|
+
if (canScroll) {
|
|
42
|
+
const header = body?.parentElement?.querySelector(':scope > .ui-rc-grid-thead');
|
|
43
|
+
const footer = body?.parentElement?.querySelector(':scope > .ui-rc-grid-tfoot');
|
|
44
|
+
const headerHeight = header?.getBoundingClientRect().height ?? 0;
|
|
45
|
+
const footerHeight = footer?.getBoundingClientRect().height ?? 0;
|
|
46
|
+
const viewportTop = viewport.getBoundingClientRect().top + viewport.clientTop;
|
|
47
|
+
const viewportCenter = viewportTop + (viewport.clientHeight + headerHeight - footerHeight) / 2;
|
|
48
|
+
const rowRect = row.getBoundingClientRect();
|
|
49
|
+
viewport.scrollTop += rowRect.top + rowRect.height / 2 - viewportCenter;
|
|
50
|
+
}
|
|
25
51
|
}
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
4
|
import { getCommonPinningStyles, getSelectedCellMatrix } from "../hook/utils";
|
|
@@ -446,35 +446,20 @@ const TableBodyCell = props => {
|
|
|
446
446
|
}
|
|
447
447
|
},
|
|
448
448
|
onKeyDown: e => {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
cellFocus.focus();
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
467
|
-
const prevIndex = cell.row.index - 1;
|
|
468
|
-
const nextId = flatRows[prevIndex].id;
|
|
469
|
-
setFocusedCell?.({
|
|
470
|
-
colId: cell.column.id,
|
|
471
|
-
rowId: nextId
|
|
472
|
-
});
|
|
473
|
-
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
474
|
-
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
475
|
-
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
476
|
-
if (cellFocus) {
|
|
477
|
-
cellFocus.focus();
|
|
449
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
450
|
+
const rows = table.getRowModel().rows;
|
|
451
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
452
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
453
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
454
|
+
if (nextRow) {
|
|
455
|
+
setFocusedCell?.({
|
|
456
|
+
colId: cell.column.id,
|
|
457
|
+
rowId: nextRow.id
|
|
458
|
+
});
|
|
459
|
+
focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
460
|
+
align: 'center'
|
|
461
|
+
}));
|
|
462
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
478
463
|
}
|
|
479
464
|
}
|
|
480
465
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
4
|
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
|
|
@@ -787,93 +787,30 @@ const TableBodyCellEdit = props => {
|
|
|
787
787
|
}
|
|
788
788
|
return;
|
|
789
789
|
}
|
|
790
|
-
if (e.key === 'ArrowDown') {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
let
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
nextRow = table.getRowModel().rows[nextRowIndex];
|
|
790
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
791
|
+
const rows = table.getRowModel().rows;
|
|
792
|
+
const currentIndex = rows.findIndex(row => row.id === rowId);
|
|
793
|
+
if (currentIndex < 0) return;
|
|
794
|
+
const step = e.key === 'ArrowDown' ? 1 : -1;
|
|
795
|
+
let nextIndex = currentIndex + step;
|
|
796
|
+
let nextRow = rows[nextIndex];
|
|
797
|
+
while (nextRow?.subRows.length) {
|
|
798
|
+
nextIndex += step;
|
|
799
|
+
nextRow = rows[nextIndex];
|
|
801
800
|
}
|
|
802
801
|
if (nextRow) {
|
|
803
|
-
const
|
|
804
|
-
|
|
805
|
-
rowId: nextRowId,
|
|
806
|
-
colId
|
|
807
|
-
});
|
|
808
|
-
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
809
|
-
setStartCell?.({
|
|
810
|
-
rowId: nextRowId,
|
|
811
|
-
colId
|
|
812
|
-
});
|
|
813
|
-
setEndCell?.({
|
|
814
|
-
rowId: nextRowId,
|
|
815
|
-
colId
|
|
816
|
-
});
|
|
817
|
-
setRangeState?.(getSelectedCellMatrix(table, {
|
|
818
|
-
rowId: nextRowId,
|
|
819
|
-
colId
|
|
820
|
-
}, {
|
|
821
|
-
rowId: nextRowId,
|
|
822
|
-
colId
|
|
823
|
-
}));
|
|
824
|
-
|
|
825
|
-
// columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
826
|
-
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
827
|
-
|
|
828
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
829
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
830
|
-
if (cellFocus) {
|
|
831
|
-
cellFocus.focus();
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
if (e.key === 'ArrowUp') {
|
|
837
|
-
// e.preventDefault()
|
|
838
|
-
// e.stopPropagation()
|
|
839
|
-
|
|
840
|
-
// const nextRow = table.getRowModel().rows[rowNumber - 1]
|
|
841
|
-
|
|
842
|
-
let prevRowIndex = rowNumber - 1;
|
|
843
|
-
let prevRow = table.getRowModel().rows[prevRowIndex];
|
|
844
|
-
|
|
845
|
-
// Nếu nextRow có children và chưa được expand, thì tìm tiếp dòng tiếp theo
|
|
846
|
-
while (prevRow && prevRow.subRows && prevRow.subRows.length > 0) {
|
|
847
|
-
prevRowIndex--;
|
|
848
|
-
prevRow = table.getRowModel().rows[prevRowIndex];
|
|
849
|
-
}
|
|
850
|
-
if (prevRow) {
|
|
851
|
-
const nextRowId = prevRow.id;
|
|
852
|
-
setFocusedCell?.({
|
|
853
|
-
rowId: nextRowId,
|
|
854
|
-
colId
|
|
855
|
-
});
|
|
856
|
-
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
857
|
-
setStartCell?.({
|
|
858
|
-
rowId: nextRowId,
|
|
859
|
-
colId
|
|
860
|
-
});
|
|
861
|
-
setEndCell?.({
|
|
862
|
-
rowId: nextRowId,
|
|
863
|
-
colId
|
|
864
|
-
});
|
|
865
|
-
setRangeState?.(getSelectedCellMatrix(table, {
|
|
866
|
-
rowId: nextRowId,
|
|
867
|
-
colId
|
|
868
|
-
}, {
|
|
869
|
-
rowId: nextRowId,
|
|
802
|
+
const nextCell = {
|
|
803
|
+
rowId: nextRow.id,
|
|
870
804
|
colId
|
|
805
|
+
};
|
|
806
|
+
setFocusedCell?.(nextCell);
|
|
807
|
+
setStartCell?.(nextCell);
|
|
808
|
+
setEndCell?.(nextCell);
|
|
809
|
+
setRangeState?.(getSelectedCellMatrix(table, nextCell, nextCell));
|
|
810
|
+
focusArrowRow(e, nextRow.id, colId, () => rowVirtualizer.scrollToIndex(nextIndex, {
|
|
811
|
+
align: 'center'
|
|
871
812
|
}));
|
|
872
|
-
|
|
873
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
874
|
-
if (cellFocus) {
|
|
875
|
-
cellFocus.focus();
|
|
876
|
-
}
|
|
813
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
877
814
|
}
|
|
878
815
|
return;
|
|
879
816
|
}
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
// import ReactDOMServer from 'react-dom/server'
|
|
3
3
|
|
|
4
4
|
import { getCommonPinningStyles } from "../hook/utils";
|
|
@@ -92,35 +92,20 @@ const TableBodyCellEmpty = props => {
|
|
|
92
92
|
setIsPasting?.(false);
|
|
93
93
|
},
|
|
94
94
|
onKeyDown: e => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
cellFocus.focus();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
113
|
-
const prevIndex = cell.row.index - 1;
|
|
114
|
-
const nextId = flatRows[prevIndex].id;
|
|
115
|
-
setFocusedCell?.({
|
|
116
|
-
colId: cell.column.id,
|
|
117
|
-
rowId: nextId
|
|
118
|
-
});
|
|
119
|
-
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
120
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
121
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
122
|
-
if (cellFocus) {
|
|
123
|
-
cellFocus.focus();
|
|
95
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
96
|
+
const rows = table.getRowModel().rows;
|
|
97
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
98
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
99
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
100
|
+
if (nextRow) {
|
|
101
|
+
setFocusedCell?.({
|
|
102
|
+
colId: cell.column.id,
|
|
103
|
+
rowId: nextRow.id
|
|
104
|
+
});
|
|
105
|
+
focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
106
|
+
align: 'center'
|
|
107
|
+
}));
|
|
108
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
124
109
|
}
|
|
125
110
|
}
|
|
126
111
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
4
|
import { getCommonPinningStyles } from "../hook/utils";
|
|
@@ -426,35 +426,20 @@ const TableBodyCell = props => {
|
|
|
426
426
|
setIsPasting?.(false);
|
|
427
427
|
},
|
|
428
428
|
onKeyDown: e => {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
cellFocus.focus();
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
447
|
-
const prevIndex = cell.row.index - 1;
|
|
448
|
-
const nextId = flatRows[prevIndex].id;
|
|
449
|
-
setFocusedCell?.({
|
|
450
|
-
colId: cell.column.id,
|
|
451
|
-
rowId: nextId
|
|
452
|
-
});
|
|
453
|
-
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
454
|
-
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
455
|
-
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
456
|
-
if (cellFocus) {
|
|
457
|
-
cellFocus.focus();
|
|
429
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
430
|
+
const rows = table.getRowModel().rows;
|
|
431
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
432
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
433
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
434
|
+
if (nextRow) {
|
|
435
|
+
setFocusedCell?.({
|
|
436
|
+
colId: cell.column.id,
|
|
437
|
+
rowId: nextRow.id
|
|
438
|
+
});
|
|
439
|
+
focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
440
|
+
align: 'center'
|
|
441
|
+
}));
|
|
442
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
458
443
|
}
|
|
459
444
|
}
|
|
460
445
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -167,7 +167,7 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
167
167
|
haveSum?: boolean;
|
|
168
168
|
isSummary?: boolean;
|
|
169
169
|
sumGroup?: boolean;
|
|
170
|
-
summaryTemplate?: (data: number, key: string) => import("react").
|
|
170
|
+
summaryTemplate?: (data: number, key: string) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode;
|
|
171
171
|
sorter?: boolean;
|
|
172
172
|
allowFiltering?: boolean;
|
|
173
173
|
allowSortering?: boolean;
|
|
@@ -179,27 +179,27 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
|
|
|
179
179
|
showFilterSearch?: boolean;
|
|
180
180
|
hidden?: boolean;
|
|
181
181
|
visible?: boolean;
|
|
182
|
-
headerTooltip?: string | boolean | (() => import("react").
|
|
182
|
+
headerTooltip?: string | boolean | (() => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
183
183
|
columnGroupText?: string;
|
|
184
184
|
headerTextAlign?: import("./../../grid-component/type").ITextAlign;
|
|
185
|
-
headerTemplate?: import("react").
|
|
185
|
+
headerTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((column: ColumnTable<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
186
186
|
fixedType?: import("./../../grid-component/type").FixedType;
|
|
187
187
|
headerTextWrap?: boolean;
|
|
188
188
|
ellipsis?: boolean;
|
|
189
189
|
allowResizing?: boolean;
|
|
190
190
|
align?: import("./../../grid-component/type").ITextAlign;
|
|
191
191
|
textAlign?: import("./../../grid-component/type").ITextAlign;
|
|
192
|
-
template?: import("react").
|
|
193
|
-
linkTemplate?: import("react").
|
|
192
|
+
template?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
193
|
+
linkTemplate?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode | ((args: import("./../../grid-component/type").ColumnTemplate<RecordType>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
194
194
|
showTooltip?: boolean;
|
|
195
195
|
tooltipDescription?: string | ((args: {
|
|
196
196
|
value: any;
|
|
197
197
|
rowData: RecordType;
|
|
198
|
-
}) => import("react").
|
|
199
|
-
onCellStyles?: Omit<CSSProperties, "
|
|
200
|
-
onCellHeaderStyles?: Omit<CSSProperties, "
|
|
198
|
+
}) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
|
|
199
|
+
onCellStyles?: Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right">);
|
|
200
|
+
onCellHeaderStyles?: Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right">);
|
|
201
201
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
202
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
202
|
+
onCellFooterStyles?: Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right">);
|
|
203
203
|
getValue?: (row: any, rowIndex: number) => any;
|
|
204
204
|
getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
|
|
205
205
|
headerCellProps?: import("./../../grid-component/type").CellProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
4
|
import { getCommonPinningStyles, getFormat } from "../hook/utils";
|
|
@@ -435,44 +435,20 @@ const TableBodyCell = props => {
|
|
|
435
435
|
}
|
|
436
436
|
},
|
|
437
437
|
onKeyDown: e => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
// e.preventDefault()
|
|
453
|
-
// rowVirtualizer.scrollToIndex(cell.row.index, {
|
|
454
|
-
// align: 'center', // 'start' | 'center' | 'end'
|
|
455
|
-
// })
|
|
456
|
-
// }
|
|
457
|
-
|
|
458
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
459
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
460
|
-
if (cellFocus) {
|
|
461
|
-
cellFocus.focus();
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
465
|
-
const prevIndex = cell.row.index - 1;
|
|
466
|
-
const nextId = flatRows[prevIndex].id;
|
|
467
|
-
setFocusedCell?.({
|
|
468
|
-
colId: cell.column.id,
|
|
469
|
-
rowId: nextId
|
|
470
|
-
});
|
|
471
|
-
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
472
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
473
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
474
|
-
if (cellFocus) {
|
|
475
|
-
cellFocus.focus();
|
|
438
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
439
|
+
const rows = table.getRowModel().rows;
|
|
440
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
441
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
442
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
443
|
+
if (nextRow) {
|
|
444
|
+
setFocusedCell?.({
|
|
445
|
+
colId: cell.column.id,
|
|
446
|
+
rowId: nextRow.id
|
|
447
|
+
});
|
|
448
|
+
focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
449
|
+
align: 'center'
|
|
450
|
+
}));
|
|
451
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
476
452
|
}
|
|
477
453
|
}
|
|
478
454
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
import Space from "rc-master-ui/es/space";
|
|
3
3
|
import Command from "../components/command/Command";
|
|
4
4
|
import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getDragRightData, getEditType, getFormat,
|
|
@@ -819,77 +819,26 @@ const TableBodyCellEdit = props => {
|
|
|
819
819
|
}
|
|
820
820
|
return;
|
|
821
821
|
}
|
|
822
|
-
if (e.key === 'ArrowDown') {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
setFocusedCell?.({
|
|
830
|
-
rowId: nextRowId,
|
|
831
|
-
colId
|
|
832
|
-
});
|
|
833
|
-
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
834
|
-
setStartCell?.({
|
|
835
|
-
rowId: nextRowId,
|
|
836
|
-
colId
|
|
837
|
-
});
|
|
838
|
-
setEndCell?.({
|
|
839
|
-
rowId: nextRowId,
|
|
840
|
-
colId
|
|
841
|
-
});
|
|
842
|
-
setRangeState?.(getSelectedCellMatrix(table, {
|
|
843
|
-
rowId: nextRowId,
|
|
844
|
-
colId
|
|
845
|
-
}, {
|
|
846
|
-
rowId: nextRowId,
|
|
847
|
-
colId
|
|
848
|
-
}));
|
|
849
|
-
|
|
850
|
-
// columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
851
|
-
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
852
|
-
|
|
853
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
854
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
855
|
-
if (cellFocus) {
|
|
856
|
-
cellFocus.focus();
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
if (e.key === 'ArrowUp') {
|
|
862
|
-
// e.preventDefault()
|
|
863
|
-
// e.stopPropagation()
|
|
864
|
-
|
|
865
|
-
const nextRow = table.getRowModel().rows[rowNumber - 1];
|
|
822
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
823
|
+
const rows = table.getRowModel().rows;
|
|
824
|
+
const currentIndex = rows.findIndex(row => row.id === rowId);
|
|
825
|
+
if (currentIndex < 0) return;
|
|
826
|
+
const step = e.key === 'ArrowDown' ? 1 : -1;
|
|
827
|
+
const nextIndex = currentIndex + step;
|
|
828
|
+
const nextRow = rows[nextIndex];
|
|
866
829
|
if (nextRow) {
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
rowId: nextRowId,
|
|
870
|
-
colId
|
|
871
|
-
});
|
|
872
|
-
notifyArrowRowFocus(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
873
|
-
setStartCell?.({
|
|
874
|
-
rowId: nextRowId,
|
|
875
|
-
colId
|
|
876
|
-
});
|
|
877
|
-
setEndCell?.({
|
|
878
|
-
rowId: nextRowId,
|
|
879
|
-
colId
|
|
880
|
-
});
|
|
881
|
-
setRangeState?.(getSelectedCellMatrix(table, {
|
|
882
|
-
rowId: nextRowId,
|
|
883
|
-
colId
|
|
884
|
-
}, {
|
|
885
|
-
rowId: nextRowId,
|
|
830
|
+
const nextCell = {
|
|
831
|
+
rowId: nextRow.id,
|
|
886
832
|
colId
|
|
833
|
+
};
|
|
834
|
+
setFocusedCell?.(nextCell);
|
|
835
|
+
setStartCell?.(nextCell);
|
|
836
|
+
setEndCell?.(nextCell);
|
|
837
|
+
setRangeState?.(getSelectedCellMatrix(table, nextCell, nextCell));
|
|
838
|
+
focusArrowRow(e, nextRow.id, colId, () => rowVirtualizer.scrollToIndex(nextIndex, {
|
|
839
|
+
align: 'center'
|
|
887
840
|
}));
|
|
888
|
-
|
|
889
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
890
|
-
if (cellFocus) {
|
|
891
|
-
cellFocus.focus();
|
|
892
|
-
}
|
|
841
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
893
842
|
}
|
|
894
843
|
return;
|
|
895
844
|
}
|
|
@@ -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;
|