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 {};
@@ -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
- const flatRows = table.getRowModel().flatRows;
458
- if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
459
- const nextIndex = cell.row.index + 1;
460
- // const nextIndex = rowNumber + 1
461
-
462
- const nextId = flatRows[nextIndex].id;
463
- setFocusedCell?.({
464
- colId: cell.column.id,
465
- rowId: nextId
466
- });
467
- (0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
468
- const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
469
- const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
470
- if (cellFocus) {
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
- // e.preventDefault()
799
- // e.stopPropagation()
800
-
801
- let nextRowIndex = rowNumber + 1;
802
- let nextRow = table.getRowModel().rows[nextRowIndex];
803
-
804
- // Nếu nextRow có children và chưa được expand, thì tìm tiếp dòng tiếp theo
805
- while (nextRow && nextRow.subRows && nextRow.subRows.length > 0) {
806
- nextRowIndex++;
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 nextRowId = nextRow.id;
811
- setFocusedCell?.({
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
- const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
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
- const flatRows = table.getRowModel().flatRows;
103
- if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
104
- const nextIndex = cell.row.index + 1;
105
- // const nextIndex = rowNumber + 1
106
-
107
- const nextId = flatRows[nextIndex].id;
108
- setFocusedCell?.({
109
- colId: cell.column.id,
110
- rowId: nextId
111
- });
112
- (0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
113
- const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
114
- const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
115
- if (cellFocus) {
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
- const flatRows = table.getRowModel().flatRows;
438
- if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
439
- const nextIndex = cell.row.index + 1;
440
- // const nextIndex = rowNumber + 1
441
-
442
- const nextId = flatRows[nextIndex].id;
443
- setFocusedCell?.({
444
- colId: cell.column.id,
445
- rowId: nextId
446
- });
447
- (0, _rowFocus.notifyArrowRowFocus)(table.getRow(nextId).original, 'arrowDown', selectionSettings?.useArrow, rowFocus);
448
- const rowQr = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
449
- const cellFocus = rowQr?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
450
- if (cellFocus) {
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
- table: table
35
- // columnVirtualizer={columnVirtualizer}
36
- ,
37
- headerGroup: table.getHeaderGroups()[table.getHeaderGroups().length - 1]
38
- // key={headerGroup.id}
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 colFormat = typeof col.format === 'function' ? col.format({}) : col.format;
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, col?.field) : 0;
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, col.summaryTemplate ? col.summaryTemplate(numberValue, col.field) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps)) : '');
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
  };
@@ -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;
@@ -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
- // columnVirtualizer={columnVirtualizer}
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)({}, rest, {
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)({}, rest, {
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,