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,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
|
}
|
|
@@ -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;
|
|
@@ -4,7 +4,8 @@ import { TableContext } from "../useContext";
|
|
|
4
4
|
import React, { useContext } from "react";
|
|
5
5
|
const TableFooter = ({
|
|
6
6
|
// columnVirtualizer,
|
|
7
|
-
table
|
|
7
|
+
table,
|
|
8
|
+
footerDataSource
|
|
8
9
|
// virtualPaddingLeft,
|
|
9
10
|
// virtualPaddingRight,
|
|
10
11
|
// ...rest
|
|
@@ -20,15 +21,11 @@ const TableFooter = ({
|
|
|
20
21
|
bottom: 0,
|
|
21
22
|
zIndex: 1
|
|
22
23
|
}
|
|
23
|
-
}, /*#__PURE__*/React.createElement(TableFooterRow, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// virtualPaddingLeft={virtualPaddingLeft}
|
|
30
|
-
// virtualPaddingRight={virtualPaddingRight}
|
|
31
|
-
// {...rest}
|
|
32
|
-
}));
|
|
24
|
+
}, (footerDataSource ?? [undefined]).map((footerRow, index) => /*#__PURE__*/React.createElement(TableFooterRow, {
|
|
25
|
+
key: index,
|
|
26
|
+
table: table,
|
|
27
|
+
headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1],
|
|
28
|
+
footerRow: footerRow
|
|
29
|
+
})));
|
|
33
30
|
};
|
|
34
31
|
export 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;
|
|
@@ -5,7 +5,8 @@ import classNames from "classnames";
|
|
|
5
5
|
import { sumByField } from "../../grid-component/hooks";
|
|
6
6
|
import { numericFormatter } from "react-numeric-component";
|
|
7
7
|
const TableFooterCell = ({
|
|
8
|
-
column
|
|
8
|
+
column,
|
|
9
|
+
footerRow
|
|
9
10
|
}) => {
|
|
10
11
|
const isPinned = column.getIsPinned();
|
|
11
12
|
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
@@ -16,7 +17,10 @@ const TableFooterCell = ({
|
|
|
16
17
|
dataSource
|
|
17
18
|
} = useContext(TableContext);
|
|
18
19
|
const col = column.columnDef.meta ?? {};
|
|
19
|
-
const
|
|
20
|
+
const isCustomFooter = footerRow !== undefined;
|
|
21
|
+
const field = col.field;
|
|
22
|
+
const hasFooterValue = isCustomFooter && Object.prototype.hasOwnProperty.call(footerRow, field) && footerRow[field] != null;
|
|
23
|
+
const colFormat = typeof col.format === 'function' ? col.format(footerRow ?? {}) : col.format;
|
|
20
24
|
const cellFormat = getFormat(colFormat, format);
|
|
21
25
|
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
22
26
|
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
@@ -25,7 +29,7 @@ const TableFooterCell = ({
|
|
|
25
29
|
const dec = cellFormat?.decimalScale;
|
|
26
30
|
|
|
27
31
|
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
28
|
-
const sumValue = col.type === 'number' ? sumByField(dataSource,
|
|
32
|
+
const sumValue = col.type === 'number' ? isCustomFooter ? hasFooterValue ? Number(footerRow[field]) : 0 : sumByField(dataSource, field) : 0;
|
|
29
33
|
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
30
34
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
31
35
|
const numberValue = Number(value);
|
|
@@ -38,6 +42,7 @@ const TableFooterCell = ({
|
|
|
38
42
|
decimalScale: dec,
|
|
39
43
|
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
40
44
|
};
|
|
45
|
+
const content = isCustomFooter && (!hasFooterValue || col.isSummary === false) ? '' : col.summaryTemplate ? col.summaryTemplate(numberValue, field) : isCustomFooter && col.type !== 'number' ? footerRow[field] : numericFormatter(cellValue, numericFormatProps);
|
|
41
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
42
47
|
// ref={el => {
|
|
43
48
|
// if (el) columnVirtualizer.measureElement(el)
|
|
@@ -61,6 +66,6 @@ const TableFooterCell = ({
|
|
|
61
66
|
minWidth: column?.getSize()
|
|
62
67
|
// backgroundColor: "#fafafa",
|
|
63
68
|
}
|
|
64
|
-
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
69
|
+
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null, content) : '');
|
|
65
70
|
};
|
|
66
71
|
export 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;
|
|
@@ -3,7 +3,8 @@ import React from "react";
|
|
|
3
3
|
import { TableContext } from "../useContext";
|
|
4
4
|
const TableFooterRow = ({
|
|
5
5
|
table,
|
|
6
|
-
headerGroup
|
|
6
|
+
headerGroup,
|
|
7
|
+
footerRow
|
|
7
8
|
}) => {
|
|
8
9
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
9
10
|
const {
|
|
@@ -23,7 +24,8 @@ const TableFooterRow = ({
|
|
|
23
24
|
}, visibleColumns.map(header => {
|
|
24
25
|
return /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
25
26
|
key: header.id,
|
|
26
|
-
column: header
|
|
27
|
+
column: header,
|
|
28
|
+
footerRow: footerRow
|
|
27
29
|
});
|
|
28
30
|
}));
|
|
29
31
|
};
|
|
@@ -246,6 +246,7 @@ const TableWrapper = props => {
|
|
|
246
246
|
}, /*#__PURE__*/React.createElement("div", {
|
|
247
247
|
// id={id}
|
|
248
248
|
ref: tableContainerRef,
|
|
249
|
+
"data-grid-scroll": true,
|
|
249
250
|
style: {
|
|
250
251
|
overflow: 'auto',
|
|
251
252
|
//our scrollable table container
|
|
@@ -285,9 +286,10 @@ const TableWrapper = props => {
|
|
|
285
286
|
virtualPaddingRight: virtualPaddingRight,
|
|
286
287
|
fixedLeftColumns: fixedLeftColumns,
|
|
287
288
|
fixedRightColumns: fixedRightColumns
|
|
288
|
-
}), summary && /*#__PURE__*/React.createElement(TableFooter
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
}), summary && /*#__PURE__*/React.createElement(TableFooter, {
|
|
290
|
+
footerDataSource: props.footerDataSource
|
|
291
|
+
// columnVirtualizer={columnVirtualizer}
|
|
292
|
+
,
|
|
291
293
|
table: table
|
|
292
294
|
// virtualPaddingLeft={virtualPaddingLeft}
|
|
293
295
|
// virtualPaddingRight={virtualPaddingRight}
|
|
@@ -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;
|
|
@@ -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 { getCommonPinningStyles, getFormat } from "../hook/utils";
|
|
4
4
|
import Checkbox from "rc-master-ui/es/checkbox/Checkbox";
|
|
@@ -374,35 +374,18 @@ const TableBodyCell = props => {
|
|
|
374
374
|
}
|
|
375
375
|
},
|
|
376
376
|
onKeyDown: e => {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
390
|
-
if (cellFocus) {
|
|
391
|
-
cellFocus.focus();
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
395
|
-
const prevIndex = cell.row.index - 1;
|
|
396
|
-
const nextId = flatRows[prevIndex].id;
|
|
397
|
-
setFocusedCell?.({
|
|
398
|
-
colId: cell.column.id,
|
|
399
|
-
rowId: nextId
|
|
400
|
-
});
|
|
401
|
-
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
402
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
403
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
404
|
-
if (cellFocus) {
|
|
405
|
-
cellFocus.focus();
|
|
377
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
378
|
+
const rows = table.getRowModel().rows;
|
|
379
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
380
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
381
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
382
|
+
if (nextRow) {
|
|
383
|
+
setFocusedCell?.({
|
|
384
|
+
colId: cell.column.id,
|
|
385
|
+
rowId: nextRow.id
|
|
386
|
+
});
|
|
387
|
+
focusArrowRow(e, nextRow.id, cell.column.id, () => props.scrollToRow?.(nextIndex));
|
|
388
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
406
389
|
}
|
|
407
390
|
}
|
|
408
391
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
1
|
+
import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
|
|
2
2
|
import { getCommonPinningStyles } from "../hook/utils";
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import React from "react";
|
|
@@ -89,35 +89,18 @@ const TableBodyCellRowGroup = props => {
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
onKeyDown: e => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
105
|
-
if (cellFocus) {
|
|
106
|
-
cellFocus.focus();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (e.key === 'ArrowUp' && rowNumber > 0) {
|
|
110
|
-
const prevIndex = cell.row.index - 1;
|
|
111
|
-
const nextId = flatRows[prevIndex].id;
|
|
112
|
-
setFocusedCell?.({
|
|
113
|
-
colId: cell.column.id,
|
|
114
|
-
rowId: nextId
|
|
115
|
-
});
|
|
116
|
-
notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
117
|
-
const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
|
|
118
|
-
const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
|
|
119
|
-
if (cellFocus) {
|
|
120
|
-
cellFocus.focus();
|
|
92
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
93
|
+
const rows = table.getRowModel().rows;
|
|
94
|
+
const currentIndex = rows.findIndex(row => row.id === cell.row.id);
|
|
95
|
+
const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
|
|
96
|
+
const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
|
|
97
|
+
if (nextRow) {
|
|
98
|
+
setFocusedCell?.({
|
|
99
|
+
colId: cell.column.id,
|
|
100
|
+
rowId: nextRow.id
|
|
101
|
+
});
|
|
102
|
+
focusArrowRow(e, nextRow.id, cell.column.id, () => props.scrollToRow?.(nextIndex));
|
|
103
|
+
notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
|
|
121
104
|
}
|
|
122
105
|
}
|
|
123
106
|
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;
|
|
@@ -14,6 +14,7 @@ const TableBodyRow = ({
|
|
|
14
14
|
tableId,
|
|
15
15
|
table,
|
|
16
16
|
row,
|
|
17
|
+
scrollToRow,
|
|
17
18
|
virtualRow,
|
|
18
19
|
commandClick,
|
|
19
20
|
contextMenuItems,
|
|
@@ -133,7 +134,9 @@ const TableBodyRow = ({
|
|
|
133
134
|
rowData: row.original,
|
|
134
135
|
value: cellValue
|
|
135
136
|
}) : /*#__PURE__*/React.createElement(React.Fragment, null, headertext, headertext ? ': ' : '', " ", cellContent);
|
|
136
|
-
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({
|
|
137
|
+
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({
|
|
138
|
+
scrollToRow: scrollToRow
|
|
139
|
+
}, otherCellAttributes, {
|
|
137
140
|
table: table,
|
|
138
141
|
tableId: tableId,
|
|
139
142
|
key: cell.id,
|
|
@@ -166,7 +169,9 @@ const TableBodyRow = ({
|
|
|
166
169
|
const childrenData = row.subRows.map(it => it.original);
|
|
167
170
|
const sumValue = sumByField(childrenData, cell.column.id);
|
|
168
171
|
const sumValueFormat = numericFormatter(sumValue.toString(), numericFormatProps);
|
|
169
|
-
return /*#__PURE__*/React.createElement(TableBodyCellRowGroup, _extends({
|
|
172
|
+
return /*#__PURE__*/React.createElement(TableBodyCellRowGroup, _extends({
|
|
173
|
+
scrollToRow: scrollToRow
|
|
174
|
+
}, otherCellAttributes, {
|
|
170
175
|
table: table,
|
|
171
176
|
tableId: tableId,
|
|
172
177
|
key: cell.id,
|
|
@@ -179,7 +184,9 @@ const TableBodyRow = ({
|
|
|
179
184
|
sumValue: sumValueFormat
|
|
180
185
|
}));
|
|
181
186
|
}
|
|
182
|
-
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({
|
|
187
|
+
return /*#__PURE__*/React.createElement(TableBodyCell, _extends({
|
|
188
|
+
scrollToRow: scrollToRow
|
|
189
|
+
}, otherCellAttributes, {
|
|
183
190
|
table: table,
|
|
184
191
|
tableId: tableId,
|
|
185
192
|
key: cell.id,
|
|
@@ -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;
|
|
@@ -5,7 +5,8 @@ import classNames from "classnames";
|
|
|
5
5
|
import { sumByField } from "../../grid-component/hooks";
|
|
6
6
|
import { numericFormatter } from "react-numeric-component";
|
|
7
7
|
const TableFooterCell = ({
|
|
8
|
-
column
|
|
8
|
+
column,
|
|
9
|
+
footerRow
|
|
9
10
|
}) => {
|
|
10
11
|
const {
|
|
11
12
|
prefix,
|
|
@@ -13,7 +14,10 @@ const TableFooterCell = ({
|
|
|
13
14
|
dataSource
|
|
14
15
|
} = useContext(TableContext);
|
|
15
16
|
const col = column.columnDef.meta ?? {};
|
|
16
|
-
const
|
|
17
|
+
const isCustomFooter = footerRow !== undefined;
|
|
18
|
+
const field = col.field;
|
|
19
|
+
const hasFooterValue = isCustomFooter && Object.prototype.hasOwnProperty.call(footerRow, field) && footerRow[field] != null;
|
|
20
|
+
const colFormat = typeof col.format === 'function' ? col.format(footerRow ?? {}) : col.format;
|
|
17
21
|
const cellFormat = getFormat(colFormat, format);
|
|
18
22
|
const thousandSeparator = cellFormat?.thousandSeparator;
|
|
19
23
|
const decimalSeparator = cellFormat?.decimalSeparator;
|
|
@@ -22,7 +26,7 @@ const TableFooterCell = ({
|
|
|
22
26
|
const dec = cellFormat?.decimalScale;
|
|
23
27
|
|
|
24
28
|
// const sumValue = col.type === 'number' ? sumDataByField(filterDataByColumns4(dataSource, filterStates) as any[], col?.key as string) : 0
|
|
25
|
-
const sumValue = col.type === 'number' ? sumByField(dataSource,
|
|
29
|
+
const sumValue = col.type === 'number' ? isCustomFooter ? hasFooterValue ? Number(footerRow[field]) : 0 : sumByField(dataSource, field) : 0;
|
|
26
30
|
const value = !isEmpty(sumValue) ? dec || dec === 0 ? parseFloat(Number(sumValue).toFixed(dec)).toString() : sumValue.toString() : '0';
|
|
27
31
|
const cellValue = col.type === 'number' && col.isSummary !== false ? value : '';
|
|
28
32
|
const numberValue = Number(value);
|
|
@@ -35,6 +39,7 @@ const TableFooterCell = ({
|
|
|
35
39
|
decimalScale: dec,
|
|
36
40
|
fixedDecimalScale: cellFormat?.fixedDecimalScale ?? false
|
|
37
41
|
};
|
|
42
|
+
const content = isCustomFooter && (!hasFooterValue || col.isSummary === false) ? '' : col.summaryTemplate ? col.summaryTemplate(numberValue, field) : isCustomFooter && col.type !== 'number' ? footerRow[field] : numericFormatter(cellValue, numericFormatProps);
|
|
38
43
|
return /*#__PURE__*/React.createElement("th", {
|
|
39
44
|
className: classNames(`${prefix}-grid-cell`, {
|
|
40
45
|
// [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
@@ -49,6 +54,6 @@ const TableFooterCell = ({
|
|
|
49
54
|
minWidth: column?.getSize(),
|
|
50
55
|
height: 40
|
|
51
56
|
}
|
|
52
|
-
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
57
|
+
}, column.id !== "id" && column.id !== "selection_column" ? /*#__PURE__*/React.createElement(React.Fragment, null, content) : '');
|
|
53
58
|
};
|
|
54
59
|
export default TableFooterCell;
|
|
@@ -291,7 +291,9 @@ const TableContainer = props => {
|
|
|
291
291
|
pagination,
|
|
292
292
|
groupSetting
|
|
293
293
|
}
|
|
294
|
-
}, /*#__PURE__*/React.createElement(TableWrapper, _extends({
|
|
294
|
+
}, /*#__PURE__*/React.createElement(TableWrapper, _extends({
|
|
295
|
+
footerDataSource: props.footerDataSource
|
|
296
|
+
}, rest, {
|
|
295
297
|
tableContainerRef: tableContainerRef,
|
|
296
298
|
prefix: prefix,
|
|
297
299
|
id: id,
|
|
@@ -34,6 +34,11 @@ const TableWrapper = props => {
|
|
|
34
34
|
|
|
35
35
|
// ref cho scroll container
|
|
36
36
|
const scrollRef = useRef(null);
|
|
37
|
+
const virtuosoRef = useRef(null);
|
|
38
|
+
const scrollToRow = index => virtuosoRef.current?.scrollToIndex({
|
|
39
|
+
index,
|
|
40
|
+
align: 'center'
|
|
41
|
+
});
|
|
37
42
|
const {
|
|
38
43
|
rows
|
|
39
44
|
} = table.getRowModel();
|
|
@@ -126,6 +131,7 @@ const TableWrapper = props => {
|
|
|
126
131
|
position: "relative"
|
|
127
132
|
}
|
|
128
133
|
}, /*#__PURE__*/React.createElement(TableVirtuoso, _extends({
|
|
134
|
+
ref: virtuosoRef,
|
|
129
135
|
data: table.getRowModel().rows,
|
|
130
136
|
totalCount: rows.length
|
|
131
137
|
}, onVisibleRowsChange ? {
|
|
@@ -190,6 +196,7 @@ const TableWrapper = props => {
|
|
|
190
196
|
return /*#__PURE__*/React.createElement(TableBodyRow, _extends({
|
|
191
197
|
tableId: id,
|
|
192
198
|
row: row,
|
|
199
|
+
scrollToRow: scrollToRow,
|
|
193
200
|
table: table,
|
|
194
201
|
commandClick: commandClick,
|
|
195
202
|
rowheight: editAble ? 37 : rowheight,
|
|
@@ -247,14 +254,14 @@ const TableWrapper = props => {
|
|
|
247
254
|
},
|
|
248
255
|
fixedFooterContent: summary ? () => {
|
|
249
256
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
250
|
-
return /*#__PURE__*/React.createElement("tr", {
|
|
257
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, (props.footerDataSource ?? [undefined]).map((footerRow, index) => /*#__PURE__*/React.createElement("tr", {
|
|
258
|
+
key: index,
|
|
251
259
|
className: "ui-rc-grid-footer-row"
|
|
252
|
-
}, visibleColumns.map(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}));
|
|
260
|
+
}, visibleColumns.map(column => /*#__PURE__*/React.createElement(TableFooterCell, {
|
|
261
|
+
key: column.id,
|
|
262
|
+
column: column,
|
|
263
|
+
footerRow: footerRow
|
|
264
|
+
})))));
|
|
258
265
|
} : undefined
|
|
259
266
|
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
260
267
|
id: `${id}-tooltip-content`,
|