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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MouseEvent } from 'react';
|
|
1
|
+
import type { KeyboardEvent as ReactKeyboardEvent, 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. */
|
|
@@ -6,6 +6,7 @@ export declare function getRowFocusHandlers<T>(rowData: T, rowFocus?: RowFocus<T
|
|
|
6
6
|
onClickCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
7
7
|
onContextMenuCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
export declare function notifyArrowRowFocus<T>(rowData: T, method: 'arrowUp' | 'arrowDown', useArrow?: boolean, rowFocus?: RowFocus<T>): void;
|
|
9
|
+
/** Report the last focused row after the arrow key is released. */
|
|
10
|
+
export declare function notifyArrowRowFocus<T>(event: ReactKeyboardEvent, rowData: T, method: 'arrowUp' | 'arrowDown', useArrow?: boolean, rowFocus?: RowFocus<T>): void;
|
|
11
|
+
export declare function focusArrowRow(event: ReactKeyboardEvent, rowId: string, columnId: string, scrollToRow: () => void): void;
|
|
11
12
|
export {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const gridViewportSelector = '[data-grid-scroll], [data-virtuoso-scroller]';
|
|
2
|
+
const pendingArrowFocus = new WeakMap();
|
|
3
|
+
|
|
1
4
|
/** Capture clicks even when a cell handles the event itself. */
|
|
2
5
|
export function getRowFocusHandlers(rowData, rowFocus) {
|
|
3
6
|
return {
|
|
@@ -16,10 +19,69 @@ export function getRowFocusHandlers(rowData, rowFocus) {
|
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
/**
|
|
20
|
-
export function notifyArrowRowFocus(rowData, method, useArrow, rowFocus) {
|
|
21
|
-
if (useArrow
|
|
22
|
+
/** Report the last focused row after the arrow key is released. */
|
|
23
|
+
export function notifyArrowRowFocus(event, rowData, method, useArrow, rowFocus) {
|
|
24
|
+
if (useArrow !== true || !rowFocus) return;
|
|
25
|
+
const viewport = event.currentTarget.closest(gridViewportSelector);
|
|
26
|
+
const view = viewport?.ownerDocument.defaultView;
|
|
27
|
+
if (!viewport || !view) return;
|
|
28
|
+
const notify = () => rowFocus({
|
|
22
29
|
rowData,
|
|
23
30
|
method
|
|
24
31
|
});
|
|
32
|
+
const pending = pendingArrowFocus.get(viewport);
|
|
33
|
+
if (pending) {
|
|
34
|
+
pending.key = event.key;
|
|
35
|
+
pending.notify = notify;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const focus = {
|
|
39
|
+
key: event.key,
|
|
40
|
+
notify
|
|
41
|
+
};
|
|
42
|
+
pendingArrowFocus.set(viewport, focus);
|
|
43
|
+
const cancel = () => {
|
|
44
|
+
pendingArrowFocus.delete(viewport);
|
|
45
|
+
view.removeEventListener('keyup', release, true);
|
|
46
|
+
view.removeEventListener('blur', cancel);
|
|
47
|
+
view.removeEventListener('pointerdown', cancel, true);
|
|
48
|
+
};
|
|
49
|
+
const release = keyEvent => {
|
|
50
|
+
if (keyEvent.key !== focus.key) return;
|
|
51
|
+
cancel();
|
|
52
|
+
view.setTimeout(() => {
|
|
53
|
+
if (viewport.isConnected) focus.notify();
|
|
54
|
+
}, 0);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// A virtualized row can unmount before keyup reaches its original cell.
|
|
58
|
+
view.addEventListener('keyup', release, true);
|
|
59
|
+
view.addEventListener('blur', cancel);
|
|
60
|
+
view.addEventListener('pointerdown', cancel, true);
|
|
61
|
+
}
|
|
62
|
+
export function focusArrowRow(event, rowId, columnId, scrollToRow) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
const source = event.currentTarget;
|
|
65
|
+
const body = source.closest('.ui-rc-grid-row')?.parentElement;
|
|
66
|
+
const row = body && Array.from(body.children).find(child => child.getAttribute('data-row-key') === rowId);
|
|
67
|
+
const viewport = source.closest(gridViewportSelector);
|
|
68
|
+
const canScroll = viewport && viewport.scrollHeight > viewport.clientHeight;
|
|
69
|
+
if (!row) {
|
|
70
|
+
if (canScroll) scrollToRow();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
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)');
|
|
74
|
+
cell?.focus({
|
|
75
|
+
preventScroll: true
|
|
76
|
+
});
|
|
77
|
+
if (canScroll) {
|
|
78
|
+
const header = body?.parentElement?.querySelector(':scope > .ui-rc-grid-thead');
|
|
79
|
+
const footer = body?.parentElement?.querySelector(':scope > .ui-rc-grid-tfoot');
|
|
80
|
+
const headerHeight = header?.getBoundingClientRect().height ?? 0;
|
|
81
|
+
const footerHeight = footer?.getBoundingClientRect().height ?? 0;
|
|
82
|
+
const viewportTop = viewport.getBoundingClientRect().top + viewport.clientTop;
|
|
83
|
+
const viewportCenter = viewportTop + (viewport.clientHeight + headerHeight - footerHeight) / 2;
|
|
84
|
+
const rowRect = row.getBoundingClientRect();
|
|
85
|
+
viewport.scrollTop += rowRect.top + rowRect.height / 2 - viewportCenter;
|
|
86
|
+
}
|
|
25
87
|
}
|
|
@@ -791,7 +791,7 @@ export type IWrapSettings = {
|
|
|
791
791
|
wrapMode?: IWrapMode;
|
|
792
792
|
};
|
|
793
793
|
export type SelectionSettings<T = AnyObject> = {
|
|
794
|
-
/** Invoke rowFocus
|
|
794
|
+
/** Invoke rowFocus for the final row after releasing ArrowUp or ArrowDown. Defaults to false. */
|
|
795
795
|
useArrow?: boolean;
|
|
796
796
|
mode?: 'checkbox' | 'radio';
|
|
797
797
|
type?: 'single' | 'multiple';
|
|
@@ -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(e, 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(e, 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(e, 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(e, 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" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
|
|
200
|
+
onCellHeaderStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
|
|
201
201
|
onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
|
|
202
|
-
onCellFooterStyles?: Omit<CSSProperties, "
|
|
202
|
+
onCellFooterStyles?: Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "left" | "right" | "display" | "width" | "minWidth">);
|
|
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(e, 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()) {
|