es-grid-template 1.9.95 → 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/GridRefreshButton.css +9 -9
- package/es/grid-component/hooks/rowFocus.d.ts +2 -1
- package/es/grid-component/hooks/rowFocus.js +26 -0
- package/es/grid-component/type.d.ts +1 -1
- package/es/group-component/TableContainer.js +1 -0
- package/es/group-component/TableContainerEdit.js +1 -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/footer/TableFooter.d.ts +2 -1
- package/es/group-component/footer/TableFooter.js +8 -11
- package/es/group-component/footer/TableFooterCell.d.ts +2 -1
- package/es/group-component/footer/TableFooterCell.js +9 -4
- package/es/group-component/footer/TableFooterRow.d.ts +2 -1
- package/es/group-component/footer/TableFooterRow.js +4 -2
- package/es/group-component/hook/utils.d.ts +3 -3
- package/es/group-component/table/TableWrapper.d.ts +1 -0
- package/es/group-component/table/TableWrapper.js +5 -3
- package/es/table-component/TableContainer.js +3 -1
- package/es/table-component/TableContainerEdit.js +3 -1
- package/es/table-component/body/TableBodyCell.js +15 -39
- package/es/table-component/body/TableBodyCellEdit.js +18 -69
- package/es/table-component/footer/TableFooter.d.ts +2 -1
- package/es/table-component/footer/TableFooter.js +8 -11
- package/es/table-component/footer/TableFooterCell.d.ts +2 -1
- package/es/table-component/footer/TableFooterCell.js +9 -4
- package/es/table-component/footer/TableFooterRow.d.ts +2 -1
- package/es/table-component/footer/TableFooterRow.js +4 -2
- package/es/table-component/table/TableWrapper.d.ts +1 -0
- package/es/table-component/table/TableWrapper.js +5 -3
- 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/footer/TableFooterCell.d.ts +2 -1
- package/es/table-virtuoso/footer/TableFooterCell.js +9 -4
- package/es/table-virtuoso/table/TableContainer.js +3 -1
- package/es/table-virtuoso/table/TableWrapper.d.ts +1 -0
- package/es/table-virtuoso/table/TableWrapper.js +14 -7
- package/lib/grid-component/GridRefreshButton.css +9 -9
- package/lib/grid-component/hooks/rowFocus.d.ts +2 -1
- package/lib/grid-component/hooks/rowFocus.js +27 -0
- package/lib/grid-component/type.d.ts +1 -1
- package/lib/group-component/TableContainer.js +1 -0
- package/lib/group-component/TableContainerEdit.js +1 -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/footer/TableFooter.d.ts +2 -1
- package/lib/group-component/footer/TableFooter.js +8 -11
- package/lib/group-component/footer/TableFooterCell.d.ts +2 -1
- package/lib/group-component/footer/TableFooterCell.js +9 -4
- package/lib/group-component/footer/TableFooterRow.d.ts +2 -1
- package/lib/group-component/footer/TableFooterRow.js +4 -2
- package/lib/group-component/table/TableWrapper.d.ts +1 -0
- package/lib/group-component/table/TableWrapper.js +5 -3
- package/lib/table-component/TableContainer.js +3 -1
- package/lib/table-component/TableContainerEdit.js +3 -1
- package/lib/table-component/body/TableBodyCell.js +14 -38
- package/lib/table-component/body/TableBodyCellEdit.js +17 -68
- package/lib/table-component/footer/TableFooter.d.ts +2 -1
- package/lib/table-component/footer/TableFooter.js +8 -11
- package/lib/table-component/footer/TableFooterCell.d.ts +2 -1
- package/lib/table-component/footer/TableFooterCell.js +9 -4
- package/lib/table-component/footer/TableFooterRow.d.ts +2 -1
- package/lib/table-component/footer/TableFooterRow.js +4 -2
- package/lib/table-component/table/TableWrapper.d.ts +1 -0
- package/lib/table-component/table/TableWrapper.js +5 -3
- 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/footer/TableFooterCell.d.ts +2 -1
- package/lib/table-virtuoso/footer/TableFooterCell.js +9 -4
- package/lib/table-virtuoso/table/TableContainer.js +3 -1
- package/lib/table-virtuoso/table/TableWrapper.d.ts +1 -0
- package/lib/table-virtuoso/table/TableWrapper.js +14 -7
- package/package.json +1 -1
- package/CHANGELOG.md +0 -16
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
.ui-rc-grid-refresh-spin {
|
|
2
|
-
transform-origin: center;
|
|
3
|
-
transform-box: fill-box;
|
|
4
|
-
animation: ui-rc-grid-refresh-spin 0.8s linear infinite;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
@keyframes ui-rc-grid-refresh-spin {
|
|
8
|
-
to { transform: rotate(360deg); }
|
|
9
|
-
}
|
|
1
|
+
.ui-rc-grid-refresh-spin {
|
|
2
|
+
transform-origin: center;
|
|
3
|
+
transform-box: fill-box;
|
|
4
|
+
animation: ui-rc-grid-refresh-spin 0.8s linear infinite;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@keyframes ui-rc-grid-refresh-spin {
|
|
8
|
+
to { transform: rotate(360deg); }
|
|
9
|
+
}
|
|
@@ -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 {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.focusArrowRow = focusArrowRow;
|
|
6
7
|
exports.getRowFocusHandlers = getRowFocusHandlers;
|
|
7
8
|
exports.notifyArrowRowFocus = notifyArrowRowFocus;
|
|
8
9
|
/** Capture clicks even when a cell handles the event itself. */
|
|
@@ -29,4 +30,30 @@ function notifyArrowRowFocus(rowData, method, useArrow, rowFocus) {
|
|
|
29
30
|
rowData,
|
|
30
31
|
method
|
|
31
32
|
});
|
|
33
|
+
}
|
|
34
|
+
function focusArrowRow(event, rowId, columnId, scrollToRow) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
const source = event.currentTarget;
|
|
37
|
+
const body = source.closest('.ui-rc-grid-row')?.parentElement;
|
|
38
|
+
const row = body && Array.from(body.children).find(child => child.getAttribute('data-row-key') === rowId);
|
|
39
|
+
const viewport = source.closest('[data-grid-scroll], [data-virtuoso-scroller]');
|
|
40
|
+
const canScroll = viewport && viewport.scrollHeight > viewport.clientHeight;
|
|
41
|
+
if (!row) {
|
|
42
|
+
if (canScroll) scrollToRow();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
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)');
|
|
46
|
+
cell?.focus({
|
|
47
|
+
preventScroll: true
|
|
48
|
+
});
|
|
49
|
+
if (canScroll) {
|
|
50
|
+
const header = body?.parentElement?.querySelector(':scope > .ui-rc-grid-thead');
|
|
51
|
+
const footer = body?.parentElement?.querySelector(':scope > .ui-rc-grid-tfoot');
|
|
52
|
+
const headerHeight = header?.getBoundingClientRect().height ?? 0;
|
|
53
|
+
const footerHeight = footer?.getBoundingClientRect().height ?? 0;
|
|
54
|
+
const viewportTop = viewport.getBoundingClientRect().top + viewport.clientTop;
|
|
55
|
+
const viewportCenter = viewportTop + (viewport.clientHeight + headerHeight - footerHeight) / 2;
|
|
56
|
+
const rowRect = row.getBoundingClientRect();
|
|
57
|
+
viewport.scrollTop += rowRect.top + rowRect.height / 2 - viewportCenter;
|
|
58
|
+
}
|
|
32
59
|
}
|
|
@@ -494,7 +494,7 @@ export type TableProps<RecordType = AnyObject> = {
|
|
|
494
494
|
allowResizing?: boolean;
|
|
495
495
|
/** Hiển thị dòng tổng hợp */
|
|
496
496
|
summary?: boolean;
|
|
497
|
-
/** Dữ liệu footer */
|
|
497
|
+
/** Dữ liệu footer theo field của cột, dùng khi summary=true. Không truyền thì tự tính tổng; [] ẩn các dòng footer. */
|
|
498
498
|
footerDataSource?: any[];
|
|
499
499
|
/** Hiển thị text khi không có dữ liệu */
|
|
500
500
|
showEmptyText?: boolean;
|
|
@@ -347,6 +347,7 @@ const TableContainer = props => {
|
|
|
347
347
|
groupColumns
|
|
348
348
|
}
|
|
349
349
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
350
|
+
footerDataSource: props.footerDataSource,
|
|
350
351
|
contextMenuItems: contextMenuItems,
|
|
351
352
|
height: tableHeight,
|
|
352
353
|
minHeight: minHeight,
|
|
@@ -2267,6 +2267,7 @@ const TableContainerEdit = props => {
|
|
|
2267
2267
|
groupColumns
|
|
2268
2268
|
}
|
|
2269
2269
|
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, {
|
|
2270
|
+
footerDataSource: props.footerDataSource,
|
|
2270
2271
|
contextMenuItems: contextMenuItems,
|
|
2271
2272
|
height: tableHeight,
|
|
2272
2273
|
minHeight: minHeight,
|
|
@@ -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;
|
|
@@ -454,35 +454,20 @@ const TableBodyCell = props => {
|
|
|
454
454
|
}
|
|
455
455
|
},
|
|
456
456
|
onKeyDown: e => {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
cellFocus.focus();
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
475
|
-
const prevIndex = cell.row.index - 1;
|
|
476
|
-
const nextId = flatRows[prevIndex].id;
|
|
477
|
-
setFocusedCell?.({
|
|
478
|
-
colId: cell.column.id,
|
|
479
|
-
rowId: nextId
|
|
480
|
-
});
|
|
481
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
482
|
-
const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
483
|
-
const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
484
|
-
if (cellFocus) {
|
|
485
|
-
cellFocus.focus();
|
|
457
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
458
|
+
const rows = table.getRowModel().rows;
|
|
459
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
460
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
461
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
462
|
+
if (nextRow) {
|
|
463
|
+
setFocusedCell?.({
|
|
464
|
+
colId: cell.column.id,
|
|
465
|
+
rowId: nextRow.id
|
|
466
|
+
});
|
|
467
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
|
|
468
|
+
align: 'center'
|
|
469
|
+
}));
|
|
470
|
+
(0, _rowFocus.notifyArrowRowFocus)(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
486
471
|
}
|
|
487
472
|
}
|
|
488
473
|
if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
|
|
@@ -794,93 +794,30 @@ const TableBodyCellEdit = props => {
|
|
|
794
794
|
}
|
|
795
795
|
return;
|
|
796
796
|
}
|
|
797
|
-
if (e.key === 'ArrowDown') {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
let
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
nextRow = table.getRowModel().rows[nextRowIndex];
|
|
797
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
798
|
+
const rows = table.getRowModel().rows;
|
|
799
|
+
const currentIndex = rows.findIndex(row => row.id === rowId);
|
|
800
|
+
if (currentIndex < 0) return;
|
|
801
|
+
const step = e.key === 'ArrowDown' ? 1 : -1;
|
|
802
|
+
let nextIndex = currentIndex + step;
|
|
803
|
+
let nextRow = rows[nextIndex];
|
|
804
|
+
while (nextRow?.subRows.length) {
|
|
805
|
+
nextIndex += step;
|
|
806
|
+
nextRow = rows[nextIndex];
|
|
808
807
|
}
|
|
809
808
|
if (nextRow) {
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
rowId: nextRowId,
|
|
813
|
-
colId
|
|
814
|
-
});
|
|
815
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
|
|
816
|
-
setStartCell?.({
|
|
817
|
-
rowId: nextRowId,
|
|
818
|
-
colId
|
|
819
|
-
});
|
|
820
|
-
setEndCell?.({
|
|
821
|
-
rowId: nextRowId,
|
|
822
|
-
colId
|
|
823
|
-
});
|
|
824
|
-
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
825
|
-
rowId: nextRowId,
|
|
826
|
-
colId
|
|
827
|
-
}, {
|
|
828
|
-
rowId: nextRowId,
|
|
829
|
-
colId
|
|
830
|
-
}));
|
|
831
|
-
|
|
832
|
-
// columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
|
|
833
|
-
// rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
|
|
834
|
-
|
|
835
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
|
|
836
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
837
|
-
if (cellFocus) {
|
|
838
|
-
cellFocus.focus();
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
if (e.key === 'ArrowUp') {
|
|
844
|
-
// e.preventDefault()
|
|
845
|
-
// e.stopPropagation()
|
|
846
|
-
|
|
847
|
-
// const nextRow = table.getRowModel().rows[rowNumber - 1]
|
|
848
|
-
|
|
849
|
-
let prevRowIndex = rowNumber - 1;
|
|
850
|
-
let prevRow = table.getRowModel().rows[prevRowIndex];
|
|
851
|
-
|
|
852
|
-
// Nếu nextRow có children và chưa được expand, thì tìm tiếp dòng tiếp theo
|
|
853
|
-
while (prevRow && prevRow.subRows && prevRow.subRows.length > 0) {
|
|
854
|
-
prevRowIndex--;
|
|
855
|
-
prevRow = table.getRowModel().rows[prevRowIndex];
|
|
856
|
-
}
|
|
857
|
-
if (prevRow) {
|
|
858
|
-
const nextRowId = prevRow.id;
|
|
859
|
-
setFocusedCell?.({
|
|
860
|
-
rowId: nextRowId,
|
|
861
|
-
colId
|
|
862
|
-
});
|
|
863
|
-
(0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextRowId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
864
|
-
setStartCell?.({
|
|
865
|
-
rowId: nextRowId,
|
|
866
|
-
colId
|
|
867
|
-
});
|
|
868
|
-
setEndCell?.({
|
|
869
|
-
rowId: nextRowId,
|
|
870
|
-
colId
|
|
871
|
-
});
|
|
872
|
-
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
|
|
873
|
-
rowId: nextRowId,
|
|
874
|
-
colId
|
|
875
|
-
}, {
|
|
876
|
-
rowId: nextRowId,
|
|
809
|
+
const nextCell = {
|
|
810
|
+
rowId: nextRow.id,
|
|
877
811
|
colId
|
|
812
|
+
};
|
|
813
|
+
setFocusedCell?.(nextCell);
|
|
814
|
+
setStartCell?.(nextCell);
|
|
815
|
+
setEndCell?.(nextCell);
|
|
816
|
+
setRangeState?.((0, _utils.getSelectedCellMatrix)(table, nextCell, nextCell));
|
|
817
|
+
(0, _rowFocus.focusArrowRow)(e, nextRow.id, colId, () => rowVirtualizer.scrollToIndex(nextIndex, {
|
|
818
|
+
align: 'center'
|
|
878
819
|
}));
|
|
879
|
-
|
|
880
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
881
|
-
if (cellFocus) {
|
|
882
|
-
cellFocus.focus();
|
|
883
|
-
}
|
|
820
|
+
(0, _rowFocus.notifyArrowRowFocus)(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
884
821
|
}
|
|
885
822
|
return;
|
|
886
823
|
}
|
|
@@ -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;
|
|
@@ -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)(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)(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()) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Table } from "@tanstack/react-table";
|
|
3
3
|
interface TableFooterProps<T> {
|
|
4
4
|
table: Table<T>;
|
|
5
|
+
footerDataSource?: any[];
|
|
5
6
|
}
|
|
6
|
-
declare const TableFooter: <RecordType extends object>({ table, }: TableFooterProps<RecordType>) => JSX.Element;
|
|
7
|
+
declare const TableFooter: <RecordType extends object>({ table, footerDataSource, }: TableFooterProps<RecordType>) => JSX.Element;
|
|
7
8
|
export default TableFooter;
|
|
@@ -14,7 +14,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
14
14
|
|
|
15
15
|
const TableFooter = ({
|
|
16
16
|
// columnVirtualizer,
|
|
17
|
-
table
|
|
17
|
+
table,
|
|
18
|
+
footerDataSource
|
|
18
19
|
// virtualPaddingLeft,
|
|
19
20
|
// virtualPaddingRight,
|
|
20
21
|
// ...rest
|
|
@@ -30,15 +31,11 @@ const TableFooter = ({
|
|
|
30
31
|
bottom: 0,
|
|
31
32
|
zIndex: 1
|
|
32
33
|
}
|
|
33
|
-
}, /*#__PURE__*/_react.default.createElement(_TableFooterRow.default, {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// virtualPaddingLeft={virtualPaddingLeft}
|
|
40
|
-
// virtualPaddingRight={virtualPaddingRight}
|
|
41
|
-
// {...rest}
|
|
42
|
-
}));
|
|
34
|
+
}, (footerDataSource ?? [undefined]).map((footerRow, index) => /*#__PURE__*/_react.default.createElement(_TableFooterRow.default, {
|
|
35
|
+
key: index,
|
|
36
|
+
table: table,
|
|
37
|
+
headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1],
|
|
38
|
+
footerRow: footerRow
|
|
39
|
+
})));
|
|
43
40
|
};
|
|
44
41
|
var _default = exports.default = TableFooter;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Column } from "@tanstack/react-table";
|
|
3
3
|
interface TableFooterCellProps<T> {
|
|
4
4
|
column: Column<T, any>;
|
|
5
|
+
footerRow?: Record<string, any>;
|
|
5
6
|
}
|
|
6
|
-
declare const TableFooterCell: <RecordType extends object>({ column }: TableFooterCellProps<RecordType>) => JSX.Element;
|
|
7
|
+
declare const TableFooterCell: <RecordType extends object>({ column, footerRow }: TableFooterCellProps<RecordType>) => JSX.Element;
|
|
7
8
|
export default TableFooterCell;
|
|
@@ -14,7 +14,8 @@ var _reactNumericComponent = require("react-numeric-component");
|
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
const TableFooterCell = ({
|
|
17
|
-
column
|
|
17
|
+
column,
|
|
18
|
+
footerRow
|
|
18
19
|
}) => {
|
|
19
20
|
const isPinned = column.getIsPinned();
|
|
20
21
|
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
@@ -25,7 +26,10 @@ const TableFooterCell = ({
|
|
|
25
26
|
dataSource
|
|
26
27
|
} = (0, _react.useContext)(_useContext.TableContext);
|
|
27
28
|
const col = column.columnDef.meta ?? {};
|
|
28
|
-
const
|
|
29
|
+
const isCustomFooter = footerRow !== undefined;
|
|
30
|
+
const field = col.field;
|
|
31
|
+
const hasFooterValue = isCustomFooter && Object.prototype.hasOwnProperty.call(footerRow, field) && footerRow[field] != null;
|
|
32
|
+
const colFormat = typeof col.format === 'function' ? col.format(footerRow ?? {}) : col.format;
|
|
29
33
|
const cellFormat = (0, _utils.getFormat)(colFormat, format);
|
|
30
34
|
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
31
35
|
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
@@ -34,7 +38,7 @@ const TableFooterCell = ({
|
|
|
34
38
|
const dec = cellFormat?.decimalScale;
|
|
35
39
|
|
|
36
40
|
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
37
|
-
const sumValue = col.type === 'number' ? (0, _hooks.sumByField)(dataSource,
|
|
41
|
+
const sumValue = col.type === 'number' ? isCustomFooter ? hasFooterValue ? Number(footerRow[field]) : 0 : (0, _hooks.sumByField)(dataSource, field) : 0;
|
|
38
42
|
const value = !(0, _utils.isEmpty)(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
39
43
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
40
44
|
const numberValue = Number(value);
|
|
@@ -47,6 +51,7 @@ const TableFooterCell = ({
|
|
|
47
51
|
decimalScale: dec,
|
|
48
52
|
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
49
53
|
};
|
|
54
|
+
const content = isCustomFooter && (!hasFooterValue || col.isSummary === false) ? '' : col.summaryTemplate ? col.summaryTemplate(numberValue, field) : isCustomFooter && col.type !== 'number' ? footerRow[field] : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps);
|
|
50
55
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
51
56
|
// ref={el => {
|
|
52
57
|
// if (el) columnVirtualizer.measureElement(el)
|
|
@@ -70,6 +75,6 @@ const TableFooterCell = ({
|
|
|
70
75
|
minWidth: column?.getSize()
|
|
71
76
|
// backgroundColor: "#fafafa",
|
|
72
77
|
}
|
|
73
|
-
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
78
|
+
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, content) : '');
|
|
74
79
|
};
|
|
75
80
|
var _default = exports.default = TableFooterCell;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import type { HeaderGroup, Table } from "@tanstack/react-table";
|
|
3
3
|
interface TableFooterRowProps<T> {
|
|
4
4
|
table: Table<T>;
|
|
5
|
+
footerRow?: Record<string, any>;
|
|
5
6
|
headerGroup: HeaderGroup<T>;
|
|
6
7
|
}
|
|
7
|
-
declare const TableFooterRow: <RecordType extends object>({ table, headerGroup, }: TableFooterRowProps<RecordType>) => JSX.Element;
|
|
8
|
+
declare const TableFooterRow: <RecordType extends object>({ table, headerGroup, footerRow, }: TableFooterRowProps<RecordType>) => JSX.Element;
|
|
8
9
|
export default TableFooterRow;
|
|
@@ -10,7 +10,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _useContext = require("../useContext");
|
|
11
11
|
const TableFooterRow = ({
|
|
12
12
|
table,
|
|
13
|
-
headerGroup
|
|
13
|
+
headerGroup,
|
|
14
|
+
footerRow
|
|
14
15
|
}) => {
|
|
15
16
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
16
17
|
const {
|
|
@@ -30,7 +31,8 @@ const TableFooterRow = ({
|
|
|
30
31
|
}, visibleColumns.map(header => {
|
|
31
32
|
return /*#__PURE__*/_react.default.createElement(_TableFooterCell.default, {
|
|
32
33
|
key: header.id,
|
|
33
|
-
column: header
|
|
34
|
+
column: header,
|
|
35
|
+
footerRow: footerRow
|
|
34
36
|
});
|
|
35
37
|
}));
|
|
36
38
|
};
|
|
@@ -202,6 +202,7 @@ const TableWrapper = props => {
|
|
|
202
202
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
203
203
|
// id={id}
|
|
204
204
|
ref: tableContainerRef,
|
|
205
|
+
"data-grid-scroll": true,
|
|
205
206
|
style: {
|
|
206
207
|
overflow: 'auto',
|
|
207
208
|
//our scrollable table container
|
|
@@ -241,9 +242,10 @@ const TableWrapper = props => {
|
|
|
241
242
|
virtualPaddingRight: virtualPaddingRight,
|
|
242
243
|
fixedLeftColumns: fixedLeftColumns,
|
|
243
244
|
fixedRightColumns: fixedRightColumns
|
|
244
|
-
}), summary && /*#__PURE__*/_react.default.createElement(_TableFooter.default
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
}), summary && /*#__PURE__*/_react.default.createElement(_TableFooter.default, {
|
|
246
|
+
footerDataSource: props.footerDataSource
|
|
247
|
+
// columnVirtualizer={columnVirtualizer}
|
|
248
|
+
,
|
|
247
249
|
table: table
|
|
248
250
|
// virtualPaddingLeft={virtualPaddingLeft}
|
|
249
251
|
// virtualPaddingRight={virtualPaddingRight}
|
|
@@ -357,7 +357,9 @@ const TableContainer = props => {
|
|
|
357
357
|
setIsExpandClick,
|
|
358
358
|
maxDepth
|
|
359
359
|
}
|
|
360
|
-
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, (0, _extends2.default)({
|
|
360
|
+
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, (0, _extends2.default)({
|
|
361
|
+
footerDataSource: props.footerDataSource
|
|
362
|
+
}, rest, {
|
|
361
363
|
contextMenuItems: contextMenuItems,
|
|
362
364
|
height: tableHeight,
|
|
363
365
|
minHeight: minHeight,
|
|
@@ -2276,7 +2276,9 @@ const TableContainerEdit = props => {
|
|
|
2276
2276
|
setIsExpandClick,
|
|
2277
2277
|
isAddAble
|
|
2278
2278
|
}
|
|
2279
|
-
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, (0, _extends2.default)({
|
|
2279
|
+
}, /*#__PURE__*/_react.default.createElement(_TableWrapper.default, (0, _extends2.default)({
|
|
2280
|
+
footerDataSource: props.footerDataSource
|
|
2281
|
+
}, rest, {
|
|
2280
2282
|
contextMenuItems: contextMenuItems,
|
|
2281
2283
|
height: tableHeight,
|
|
2282
2284
|
minHeight: minHeight,
|