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.
Files changed (91) hide show
  1. package/es/grid-component/GridRefreshButton.css +9 -9
  2. package/es/grid-component/hooks/rowFocus.d.ts +2 -1
  3. package/es/grid-component/hooks/rowFocus.js +26 -0
  4. package/es/grid-component/type.d.ts +1 -1
  5. package/es/group-component/TableContainer.js +1 -0
  6. package/es/group-component/TableContainerEdit.js +1 -0
  7. package/es/group-component/body/TableBodyCell.d.ts +2 -0
  8. package/es/group-component/body/TableBodyCell.js +15 -30
  9. package/es/group-component/body/TableBodyCellEdit.js +21 -84
  10. package/es/group-component/body/TableBodyCellEmpty.d.ts +2 -0
  11. package/es/group-component/body/TableBodyCellEmpty.js +15 -30
  12. package/es/group-component/body/TableBodyRowGroupCell.d.ts +2 -0
  13. package/es/group-component/body/TableBodyRowGroupCell.js +15 -30
  14. package/es/group-component/footer/TableFooter.d.ts +2 -1
  15. package/es/group-component/footer/TableFooter.js +8 -11
  16. package/es/group-component/footer/TableFooterCell.d.ts +2 -1
  17. package/es/group-component/footer/TableFooterCell.js +9 -4
  18. package/es/group-component/footer/TableFooterRow.d.ts +2 -1
  19. package/es/group-component/footer/TableFooterRow.js +4 -2
  20. package/es/group-component/hook/utils.d.ts +3 -3
  21. package/es/group-component/table/TableWrapper.d.ts +1 -0
  22. package/es/group-component/table/TableWrapper.js +5 -3
  23. package/es/table-component/TableContainer.js +3 -1
  24. package/es/table-component/TableContainerEdit.js +3 -1
  25. package/es/table-component/body/TableBodyCell.js +15 -39
  26. package/es/table-component/body/TableBodyCellEdit.js +18 -69
  27. package/es/table-component/footer/TableFooter.d.ts +2 -1
  28. package/es/table-component/footer/TableFooter.js +8 -11
  29. package/es/table-component/footer/TableFooterCell.d.ts +2 -1
  30. package/es/table-component/footer/TableFooterCell.js +9 -4
  31. package/es/table-component/footer/TableFooterRow.d.ts +2 -1
  32. package/es/table-component/footer/TableFooterRow.js +4 -2
  33. package/es/table-component/table/TableWrapper.d.ts +1 -0
  34. package/es/table-component/table/TableWrapper.js +5 -3
  35. package/es/table-virtuoso/body/TableBodyCell.d.ts +1 -0
  36. package/es/table-virtuoso/body/TableBodyCell.js +13 -30
  37. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +1 -0
  38. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +13 -30
  39. package/es/table-virtuoso/body/TableBodyRow.d.ts +2 -1
  40. package/es/table-virtuoso/body/TableBodyRow.js +10 -3
  41. package/es/table-virtuoso/footer/TableFooterCell.d.ts +2 -1
  42. package/es/table-virtuoso/footer/TableFooterCell.js +9 -4
  43. package/es/table-virtuoso/table/TableContainer.js +3 -1
  44. package/es/table-virtuoso/table/TableWrapper.d.ts +1 -0
  45. package/es/table-virtuoso/table/TableWrapper.js +14 -7
  46. package/lib/grid-component/GridRefreshButton.css +9 -9
  47. package/lib/grid-component/hooks/rowFocus.d.ts +2 -1
  48. package/lib/grid-component/hooks/rowFocus.js +27 -0
  49. package/lib/grid-component/type.d.ts +1 -1
  50. package/lib/group-component/TableContainer.js +1 -0
  51. package/lib/group-component/TableContainerEdit.js +1 -0
  52. package/lib/group-component/body/TableBodyCell.d.ts +2 -0
  53. package/lib/group-component/body/TableBodyCell.js +14 -29
  54. package/lib/group-component/body/TableBodyCellEdit.js +20 -83
  55. package/lib/group-component/body/TableBodyCellEmpty.d.ts +2 -0
  56. package/lib/group-component/body/TableBodyCellEmpty.js +14 -29
  57. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +2 -0
  58. package/lib/group-component/body/TableBodyRowGroupCell.js +14 -29
  59. package/lib/group-component/footer/TableFooter.d.ts +2 -1
  60. package/lib/group-component/footer/TableFooter.js +8 -11
  61. package/lib/group-component/footer/TableFooterCell.d.ts +2 -1
  62. package/lib/group-component/footer/TableFooterCell.js +9 -4
  63. package/lib/group-component/footer/TableFooterRow.d.ts +2 -1
  64. package/lib/group-component/footer/TableFooterRow.js +4 -2
  65. package/lib/group-component/table/TableWrapper.d.ts +1 -0
  66. package/lib/group-component/table/TableWrapper.js +5 -3
  67. package/lib/table-component/TableContainer.js +3 -1
  68. package/lib/table-component/TableContainerEdit.js +3 -1
  69. package/lib/table-component/body/TableBodyCell.js +14 -38
  70. package/lib/table-component/body/TableBodyCellEdit.js +17 -68
  71. package/lib/table-component/footer/TableFooter.d.ts +2 -1
  72. package/lib/table-component/footer/TableFooter.js +8 -11
  73. package/lib/table-component/footer/TableFooterCell.d.ts +2 -1
  74. package/lib/table-component/footer/TableFooterCell.js +9 -4
  75. package/lib/table-component/footer/TableFooterRow.d.ts +2 -1
  76. package/lib/table-component/footer/TableFooterRow.js +4 -2
  77. package/lib/table-component/table/TableWrapper.d.ts +1 -0
  78. package/lib/table-component/table/TableWrapper.js +5 -3
  79. package/lib/table-virtuoso/body/TableBodyCell.d.ts +1 -0
  80. package/lib/table-virtuoso/body/TableBodyCell.js +12 -29
  81. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +1 -0
  82. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +12 -29
  83. package/lib/table-virtuoso/body/TableBodyRow.d.ts +2 -1
  84. package/lib/table-virtuoso/body/TableBodyRow.js +10 -3
  85. package/lib/table-virtuoso/footer/TableFooterCell.d.ts +2 -1
  86. package/lib/table-virtuoso/footer/TableFooterCell.js +9 -4
  87. package/lib/table-virtuoso/table/TableContainer.js +3 -1
  88. package/lib/table-virtuoso/table/TableWrapper.d.ts +1 -0
  89. package/lib/table-virtuoso/table/TableWrapper.js +14 -7
  90. package/package.json +1 -1
  91. 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 {};
@@ -22,4 +22,30 @@ export function notifyArrowRowFocus(rowData, method, useArrow, rowFocus) {
22
22
  rowData,
23
23
  method
24
24
  });
25
+ }
26
+ export function focusArrowRow(event, rowId, columnId, scrollToRow) {
27
+ event.preventDefault();
28
+ const source = event.currentTarget;
29
+ const body = source.closest('.ui-rc-grid-row')?.parentElement;
30
+ const row = body && Array.from(body.children).find(child => child.getAttribute('data-row-key') === rowId);
31
+ const viewport = source.closest('[data-grid-scroll], [data-virtuoso-scroller]');
32
+ const canScroll = viewport && viewport.scrollHeight > viewport.clientHeight;
33
+ if (!row) {
34
+ if (canScroll) scrollToRow();
35
+ return;
36
+ }
37
+ const cell = Array.from(row.querySelectorAll(':scope > [data-col-key]')).find(element => element.getAttribute('data-col-key') === columnId) ?? row.querySelector(':scope > .ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
38
+ cell?.focus({
39
+ preventScroll: true
40
+ });
41
+ if (canScroll) {
42
+ const header = body?.parentElement?.querySelector(':scope > .ui-rc-grid-thead');
43
+ const footer = body?.parentElement?.querySelector(':scope > .ui-rc-grid-tfoot');
44
+ const headerHeight = header?.getBoundingClientRect().height ?? 0;
45
+ const footerHeight = footer?.getBoundingClientRect().height ?? 0;
46
+ const viewportTop = viewport.getBoundingClientRect().top + viewport.clientTop;
47
+ const viewportCenter = viewportTop + (viewport.clientHeight + headerHeight - footerHeight) / 2;
48
+ const rowRect = row.getBoundingClientRect();
49
+ viewport.scrollTop += rowRect.top + rowRect.height / 2 - viewportCenter;
50
+ }
25
51
  }
@@ -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;
@@ -339,6 +339,7 @@ const TableContainer = props => {
339
339
  groupColumns
340
340
  }
341
341
  }, /*#__PURE__*/React.createElement(TableWrapper, {
342
+ footerDataSource: props.footerDataSource,
342
343
  contextMenuItems: contextMenuItems,
343
344
  height: tableHeight,
344
345
  minHeight: minHeight,
@@ -2259,6 +2259,7 @@ const TableContainerEdit = props => {
2259
2259
  groupColumns
2260
2260
  }
2261
2261
  }, /*#__PURE__*/React.createElement(TableWrapper, {
2262
+ footerDataSource: props.footerDataSource,
2262
2263
  contextMenuItems: contextMenuItems,
2263
2264
  height: tableHeight,
2264
2265
  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;
@@ -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
- const flatRows = table.getRowModel().flatRows;
450
- if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
451
- const nextIndex = cell.row.index + 1;
452
- // const nextIndex = rowNumber + 1
453
-
454
- const nextId = flatRows[nextIndex].id;
455
- setFocusedCell?.({
456
- colId: cell.column.id,
457
- rowId: nextId
458
- });
459
- notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
460
- const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
461
- const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
462
- if (cellFocus) {
463
- cellFocus.focus();
464
- }
465
- }
466
- if (e.key === 'ArrowUp' && rowNumber > 0) {
467
- const prevIndex = cell.row.index - 1;
468
- const nextId = flatRows[prevIndex].id;
469
- setFocusedCell?.({
470
- colId: cell.column.id,
471
- rowId: nextId
472
- });
473
- notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
474
- const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
475
- const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
476
- if (cellFocus) {
477
- cellFocus.focus();
449
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
450
+ const rows = table.getRowModel().rows;
451
+ const currentIndex = rows.findIndex(row => row.id === cell.row.id);
452
+ const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
453
+ const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
454
+ if (nextRow) {
455
+ setFocusedCell?.({
456
+ colId: cell.column.id,
457
+ rowId: nextRow.id
458
+ });
459
+ focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
460
+ align: 'center'
461
+ }));
462
+ notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
478
463
  }
479
464
  }
480
465
  if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
@@ -1,4 +1,4 @@
1
- import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
1
+ import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
2
2
  import Space from "rc-master-ui/es/space";
3
3
  import Command from "../components/command/Command";
4
4
  import { addRowsDown, addRowsDownWithCtrl, addRowsUp, addRowsUpWithCtrl, findFirst, flattenArray, flattenData, getColIdsBetween, getCommonPinningStyles, getEditType, getRowIdsBetween, getSelectedCellMatrix, isEditable, isObjEmpty, isObjEqual, newGuid, unFlattenData, updateOrInsert } from "../hook/utils";
@@ -787,93 +787,30 @@ const TableBodyCellEdit = props => {
787
787
  }
788
788
  return;
789
789
  }
790
- if (e.key === 'ArrowDown') {
791
- // e.preventDefault()
792
- // e.stopPropagation()
793
-
794
- let nextRowIndex = rowNumber + 1;
795
- let nextRow = table.getRowModel().rows[nextRowIndex];
796
-
797
- // Nếu nextRow có children và chưa được expand, thì tìm tiếp dòng tiếp theo
798
- while (nextRow && nextRow.subRows && nextRow.subRows.length > 0) {
799
- nextRowIndex++;
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 nextRowId = nextRow.id;
804
- setFocusedCell?.({
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
- const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
873
- const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
874
- if (cellFocus) {
875
- cellFocus.focus();
876
- }
813
+ notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
877
814
  }
878
815
  return;
879
816
  }
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import type { Virtualizer } from "@tanstack/react-virtual";
2
3
  import type { Cell, Table } from "@tanstack/react-table";
3
4
  import type { CommandClick } from "../../grid-component/type";
4
5
  interface TableBodyCellProps<T> {
5
6
  table: Table<T>;
7
+ rowVirtualizer?: Virtualizer<HTMLDivElement, HTMLDivElement>;
6
8
  tableId: string;
7
9
  cell: Cell<T, unknown>;
8
10
  commandClick?: (args: CommandClick<T>) => void;
@@ -1,4 +1,4 @@
1
- import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
1
+ import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
2
2
  // import ReactDOMServer from 'react-dom/server'
3
3
 
4
4
  import { getCommonPinningStyles } from "../hook/utils";
@@ -92,35 +92,20 @@ const TableBodyCellEmpty = props => {
92
92
  setIsPasting?.(false);
93
93
  },
94
94
  onKeyDown: e => {
95
- const flatRows = table.getRowModel().flatRows;
96
- if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
97
- const nextIndex = cell.row.index + 1;
98
- // const nextIndex = rowNumber + 1
99
-
100
- const nextId = flatRows[nextIndex].id;
101
- setFocusedCell?.({
102
- colId: cell.column.id,
103
- rowId: nextId
104
- });
105
- notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
106
- const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
107
- const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
108
- if (cellFocus) {
109
- cellFocus.focus();
110
- }
111
- }
112
- if (e.key === 'ArrowUp' && rowNumber > 0) {
113
- const prevIndex = cell.row.index - 1;
114
- const nextId = flatRows[prevIndex].id;
115
- setFocusedCell?.({
116
- colId: cell.column.id,
117
- rowId: nextId
118
- });
119
- notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
120
- const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
121
- const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
122
- if (cellFocus) {
123
- cellFocus.focus();
95
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
96
+ const rows = table.getRowModel().rows;
97
+ const currentIndex = rows.findIndex(row => row.id === cell.row.id);
98
+ const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
99
+ const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
100
+ if (nextRow) {
101
+ setFocusedCell?.({
102
+ colId: cell.column.id,
103
+ rowId: nextRow.id
104
+ });
105
+ focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
106
+ align: 'center'
107
+ }));
108
+ notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
124
109
  }
125
110
  }
126
111
  if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
@@ -1,8 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import type { Virtualizer } from "@tanstack/react-virtual";
2
3
  import type { Cell, Table } from "@tanstack/react-table";
3
4
  import type { CommandClick } from "../../grid-component/type";
4
5
  interface TableBodyCellProps<T> {
5
6
  table: Table<T>;
7
+ rowVirtualizer?: Virtualizer<HTMLDivElement, HTMLDivElement>;
6
8
  tableId: string;
7
9
  cell: Cell<T, unknown>;
8
10
  commandClick?: (args: CommandClick<T>) => void;
@@ -1,4 +1,4 @@
1
- import { notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
1
+ import { focusArrowRow, notifyArrowRowFocus } from "../../grid-component/hooks/rowFocus";
2
2
  import Space from "rc-master-ui/es/space";
3
3
  import Command from "../components/command/Command";
4
4
  import { getCommonPinningStyles } from "../hook/utils";
@@ -426,35 +426,20 @@ const TableBodyCell = props => {
426
426
  setIsPasting?.(false);
427
427
  },
428
428
  onKeyDown: e => {
429
- const flatRows = table.getRowModel().flatRows;
430
- if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
431
- const nextIndex = cell.row.index + 1;
432
- // const nextIndex = rowNumber + 1
433
-
434
- const nextId = flatRows[nextIndex].id;
435
- setFocusedCell?.({
436
- colId: cell.column.id,
437
- rowId: nextId
438
- });
439
- notifyArrowRowFocus(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
440
- const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
441
- const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
442
- if (cellFocus) {
443
- cellFocus.focus();
444
- }
445
- }
446
- if (e.key === 'ArrowUp' && rowNumber > 0) {
447
- const prevIndex = cell.row.index - 1;
448
- const nextId = flatRows[prevIndex].id;
449
- setFocusedCell?.({
450
- colId: cell.column.id,
451
- rowId: nextId
452
- });
453
- notifyArrowRowFocus(table.getRow(nextId).original, 'arrowUp', selectionSettings?.useArrow, rowFocus);
454
- const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
455
- const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
456
- if (cellFocus) {
457
- cellFocus.focus();
429
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
430
+ const rows = table.getRowModel().rows;
431
+ const currentIndex = rows.findIndex(row => row.id === cell.row.id);
432
+ const nextIndex = currentIndex + (e.key === 'ArrowDown' ? 1 : -1);
433
+ const nextRow = currentIndex >= 0 ? rows[nextIndex] : undefined;
434
+ if (nextRow) {
435
+ setFocusedCell?.({
436
+ colId: cell.column.id,
437
+ rowId: nextRow.id
438
+ });
439
+ focusArrowRow(e, nextRow.id, cell.column.id, () => props.rowVirtualizer?.scrollToIndex(nextIndex, {
440
+ align: 'center'
441
+ }));
442
+ notifyArrowRowFocus(nextRow.original, e.key === 'ArrowDown' ? 'arrowDown' : 'arrowUp', selectionSettings?.useArrow, rowFocus);
458
443
  }
459
444
  }
460
445
  if (e.ctrlKey && e.code === 'Space' && cell.row.getCanSelect()) {
@@ -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
- table: table
25
- // columnVirtualizer={columnVirtualizer}
26
- ,
27
- headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
28
- // key={headerGroup.id}
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 colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
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, col?.field) : 0;
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, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : numericFormatter(cellValue, numericFormatProps)) : '');
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
  };
@@ -196,10 +196,10 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
196
196
  value: any;
197
197
  rowData: RecordType;
198
198
  }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
199
- onCellStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
200
- onCellHeaderStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
199
+ onCellStyles?: Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right">);
200
+ onCellHeaderStyles?: Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right">);
201
201
  onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
202
- onCellFooterStyles?: Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "minWidth" | "left" | "right" | "position" | "display">);
202
+ onCellFooterStyles?: Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "position" | "display" | "width" | "minWidth" | "left" | "right">);
203
203
  getValue?: (row: any, rowIndex: number) => any;
204
204
  getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
205
205
  headerCellProps?: import("./../../grid-component/type").CellProps;
@@ -11,6 +11,7 @@ type Props<T> = {
11
11
  height: number;
12
12
  minHeight?: number;
13
13
  table: Table<T>;
14
+ footerDataSource?: any[];
14
15
  summary?: boolean;
15
16
  loading?: boolean;
16
17
  commandClick?: (args: Omit<CommandClick<T>, 'rows'>) => void;
@@ -193,6 +193,7 @@ const TableWrapper = props => {
193
193
  }, /*#__PURE__*/React.createElement("div", {
194
194
  // id={id}
195
195
  ref: tableContainerRef,
196
+ "data-grid-scroll": true,
196
197
  style: {
197
198
  overflow: 'auto',
198
199
  //our scrollable table container
@@ -232,9 +233,10 @@ const TableWrapper = props => {
232
233
  virtualPaddingRight: virtualPaddingRight,
233
234
  fixedLeftColumns: fixedLeftColumns,
234
235
  fixedRightColumns: fixedRightColumns
235
- }), summary && /*#__PURE__*/React.createElement(TableFooter
236
- // columnVirtualizer={columnVirtualizer}
237
- , {
236
+ }), summary && /*#__PURE__*/React.createElement(TableFooter, {
237
+ footerDataSource: props.footerDataSource
238
+ // columnVirtualizer={columnVirtualizer}
239
+ ,
238
240
  table: table
239
241
  // virtualPaddingLeft={virtualPaddingLeft}
240
242
  // virtualPaddingRight={virtualPaddingRight}
@@ -350,7 +350,9 @@ const TableContainer = props => {
350
350
  setIsExpandClick,
351
351
  maxDepth
352
352
  }
353
- }, /*#__PURE__*/React.createElement(TableWrapper, _extends({}, rest, {
353
+ }, /*#__PURE__*/React.createElement(TableWrapper, _extends({
354
+ footerDataSource: props.footerDataSource
355
+ }, rest, {
354
356
  contextMenuItems: contextMenuItems,
355
357
  height: tableHeight,
356
358
  minHeight: minHeight,
@@ -2277,7 +2277,9 @@ const TableContainerEdit = props => {
2277
2277
  setIsExpandClick,
2278
2278
  isAddAble
2279
2279
  }
2280
- }, /*#__PURE__*/React.createElement(TableWrapper, _extends({}, rest, {
2280
+ }, /*#__PURE__*/React.createElement(TableWrapper, _extends({
2281
+ footerDataSource: props.footerDataSource
2282
+ }, rest, {
2281
2283
  contextMenuItems: contextMenuItems,
2282
2284
  height: tableHeight,
2283
2285
  minHeight: minHeight,