es-grid-template 1.8.70 → 1.8.72

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 (239) hide show
  1. package/es/grid-component/TempTable.js +2 -1
  2. package/es/group-component/ColumnsChoose.d.ts +13 -0
  3. package/es/group-component/ColumnsChoose.js +211 -0
  4. package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  5. package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
  6. package/es/group-component/ColumnsGroup/index.d.ts +1 -0
  7. package/es/group-component/ColumnsGroup/index.js +1 -0
  8. package/es/group-component/ContextMenu.d.ts +19 -0
  9. package/es/group-component/ContextMenu.js +74 -0
  10. package/es/group-component/InternalTable.d.ts +8 -0
  11. package/es/group-component/InternalTable.js +224 -0
  12. package/es/group-component/TableContainer.d.ts +49 -0
  13. package/es/group-component/TableContainer.js +375 -0
  14. package/es/group-component/TableContainerEdit.d.ts +48 -0
  15. package/es/group-component/TableContainerEdit.js +2068 -0
  16. package/es/group-component/body/EditableCell.d.ts +16 -0
  17. package/es/group-component/body/EditableCell.js +1066 -0
  18. package/es/group-component/body/TableBody.d.ts +14 -0
  19. package/es/group-component/body/TableBody.js +82 -0
  20. package/es/group-component/body/TableBodyCell.d.ts +12 -0
  21. package/es/group-component/body/TableBodyCell.js +587 -0
  22. package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
  23. package/es/group-component/body/TableBodyCellEdit.js +1398 -0
  24. package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  25. package/es/group-component/body/TableBodyCellEmpty.js +149 -0
  26. package/es/group-component/body/TableBodyRow.d.ts +21 -0
  27. package/es/group-component/body/TableBodyRow.js +199 -0
  28. package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  29. package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
  30. package/es/group-component/components/ControlCheckbox.d.ts +13 -0
  31. package/es/group-component/components/ControlCheckbox.js +84 -0
  32. package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
  33. package/es/group-component/components/EditForm/EditForm.js +394 -0
  34. package/es/group-component/components/EditForm/index.d.ts +1 -0
  35. package/es/group-component/components/EditForm/index.js +1 -0
  36. package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
  37. package/es/group-component/components/InputControl/InputControl.js +118 -0
  38. package/es/group-component/components/InputControl/index.d.ts +1 -0
  39. package/es/group-component/components/InputControl/index.js +1 -0
  40. package/es/group-component/components/async-select/index.d.ts +11 -0
  41. package/es/group-component/components/async-select/index.js +38 -0
  42. package/es/group-component/components/async-table-select/index.d.ts +11 -0
  43. package/es/group-component/components/async-table-select/index.js +40 -0
  44. package/es/group-component/components/checkbox-control/index.d.ts +13 -0
  45. package/es/group-component/components/checkbox-control/index.js +40 -0
  46. package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  47. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
  48. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  49. package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
  50. package/es/group-component/components/command/Command.d.ts +10 -0
  51. package/es/group-component/components/command/Command.js +35 -0
  52. package/es/group-component/components/number/index.d.ts +12 -0
  53. package/es/group-component/components/number/index.js +42 -0
  54. package/es/group-component/components/number-range/index.d.ts +13 -0
  55. package/es/group-component/components/number-range/index.js +79 -0
  56. package/es/group-component/features/operator.d.ts +24 -0
  57. package/es/group-component/features/operator.js +62 -0
  58. package/es/group-component/footer/TableFooter.d.ts +7 -0
  59. package/es/group-component/footer/TableFooter.js +34 -0
  60. package/es/group-component/footer/TableFooterCell.d.ts +7 -0
  61. package/es/group-component/footer/TableFooterCell.js +66 -0
  62. package/es/group-component/footer/TableFooterRow.d.ts +8 -0
  63. package/es/group-component/footer/TableFooterRow.js +30 -0
  64. package/es/group-component/header/TableHead.d.ts +15 -0
  65. package/es/group-component/header/TableHead.js +98 -0
  66. package/es/group-component/header/TableHeadCell.d.ts +15 -0
  67. package/es/group-component/header/TableHeadCell.js +310 -0
  68. package/es/group-component/header/TableHeadCell2.d.ts +17 -0
  69. package/es/group-component/header/TableHeadCell2.js +321 -0
  70. package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
  71. package/es/group-component/header/TableHeadGroupCell.js +94 -0
  72. package/es/group-component/header/TableHeadRow.d.ts +15 -0
  73. package/es/group-component/header/TableHeadRow.js +52 -0
  74. package/es/group-component/header/renderFilter.d.ts +20 -0
  75. package/es/group-component/header/renderFilter.js +291 -0
  76. package/es/group-component/hook/convert.d.ts +1 -0
  77. package/es/group-component/hook/convert.js +28 -0
  78. package/es/group-component/hook/useColumns.d.ts +28 -0
  79. package/es/group-component/hook/useColumns.js +306 -0
  80. package/es/group-component/hook/useFilterOperator.d.ts +7 -0
  81. package/es/group-component/hook/useFilterOperator.js +33 -0
  82. package/es/group-component/hook/utils.d.ts +220 -0
  83. package/es/group-component/hook/utils.js +2340 -0
  84. package/es/group-component/index.d.ts +2 -0
  85. package/es/group-component/index.js +2 -0
  86. package/es/group-component/style.d.ts +22 -0
  87. package/es/group-component/style.js +48 -0
  88. package/es/group-component/style.scss +1438 -0
  89. package/es/group-component/table/Grid.d.ts +33 -0
  90. package/es/group-component/table/Grid.js +438 -0
  91. package/es/group-component/table/TableWrapper.d.ts +33 -0
  92. package/es/group-component/table/TableWrapper.js +250 -0
  93. package/es/group-component/useContext.d.ts +100 -0
  94. package/es/group-component/useContext.js +21 -0
  95. package/es/table-component/InternalTable.js +6 -1
  96. package/es/table-component/TableContainer.js +4 -2
  97. package/es/table-component/TableContainerEdit.js +2 -2
  98. package/es/table-component/body/TableBodyCell.js +49 -40
  99. package/es/table-component/body/TableBodyCellEdit.js +9 -3
  100. package/es/table-component/body/TableBodyRow.js +4 -1
  101. package/es/table-component/hook/utils.d.ts +1 -0
  102. package/es/table-component/hook/utils.js +15 -7
  103. package/es/table-component/style.js +1 -1
  104. package/es/table-component/table/Grid.js +3 -0
  105. package/es/table-component/useContext.d.ts +5 -0
  106. package/es/table-virtuoso/InternalTable.js +2 -2
  107. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  108. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  109. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  110. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  111. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  112. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  113. package/es/table-virtuoso/hook/utils.js +29 -0
  114. package/es/table-virtuoso/style.js +3 -1
  115. package/es/table-virtuoso/table/Grid.js +2 -2
  116. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  117. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  118. package/es/table-virtuoso/useContext.d.ts +6 -3
  119. package/es/table-virtuoso/useContext.js +18 -0
  120. package/lib/grid-component/TempTable.js +2 -1
  121. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  122. package/lib/group-component/ColumnsChoose.js +221 -0
  123. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  124. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  125. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  126. package/lib/group-component/ColumnsGroup/index.js +16 -0
  127. package/lib/group-component/ContextMenu.d.ts +19 -0
  128. package/lib/group-component/ContextMenu.js +83 -0
  129. package/lib/group-component/InternalTable.d.ts +8 -0
  130. package/lib/group-component/InternalTable.js +233 -0
  131. package/lib/group-component/TableContainer.d.ts +49 -0
  132. package/lib/group-component/TableContainer.js +382 -0
  133. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  134. package/lib/group-component/TableContainerEdit.js +2075 -0
  135. package/lib/group-component/body/EditableCell.d.ts +16 -0
  136. package/lib/group-component/body/EditableCell.js +1075 -0
  137. package/lib/group-component/body/TableBody.d.ts +14 -0
  138. package/lib/group-component/body/TableBody.js +91 -0
  139. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  140. package/lib/group-component/body/TableBodyCell.js +595 -0
  141. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  142. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  143. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  144. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  145. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  146. package/lib/group-component/body/TableBodyRow.js +206 -0
  147. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  148. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  149. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  150. package/lib/group-component/components/ControlCheckbox.js +92 -0
  151. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  152. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  153. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  154. package/lib/group-component/components/EditForm/index.js +16 -0
  155. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  156. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  157. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  158. package/lib/group-component/components/InputControl/index.js +16 -0
  159. package/lib/group-component/components/async-select/index.d.ts +11 -0
  160. package/lib/group-component/components/async-select/index.js +47 -0
  161. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  162. package/lib/group-component/components/async-table-select/index.js +49 -0
  163. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  164. package/lib/group-component/components/checkbox-control/index.js +48 -0
  165. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  166. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  167. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  168. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  169. package/lib/group-component/components/command/Command.d.ts +10 -0
  170. package/lib/group-component/components/command/Command.js +44 -0
  171. package/lib/group-component/components/number/index.d.ts +12 -0
  172. package/lib/group-component/components/number/index.js +50 -0
  173. package/lib/group-component/components/number-range/index.d.ts +13 -0
  174. package/lib/group-component/components/number-range/index.js +87 -0
  175. package/lib/group-component/features/operator.d.ts +24 -0
  176. package/lib/group-component/features/operator.js +67 -0
  177. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  178. package/lib/group-component/footer/TableFooter.js +44 -0
  179. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  180. package/lib/group-component/footer/TableFooterCell.js +75 -0
  181. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  182. package/lib/group-component/footer/TableFooterRow.js +37 -0
  183. package/lib/group-component/header/TableHead.d.ts +15 -0
  184. package/lib/group-component/header/TableHead.js +107 -0
  185. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  186. package/lib/group-component/header/TableHeadCell.js +319 -0
  187. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  188. package/lib/group-component/header/TableHeadCell2.js +330 -0
  189. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  190. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  191. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  192. package/lib/group-component/header/TableHeadRow.js +59 -0
  193. package/lib/group-component/header/renderFilter.d.ts +20 -0
  194. package/lib/group-component/header/renderFilter.js +301 -0
  195. package/lib/group-component/hook/convert.d.ts +1 -0
  196. package/lib/group-component/hook/convert.js +34 -0
  197. package/lib/group-component/hook/useColumns.d.ts +28 -0
  198. package/lib/group-component/hook/useColumns.js +318 -0
  199. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  200. package/lib/group-component/hook/useFilterOperator.js +40 -0
  201. package/lib/group-component/hook/utils.d.ts +220 -0
  202. package/lib/group-component/hook/utils.js +2468 -0
  203. package/lib/group-component/index.d.ts +2 -0
  204. package/lib/group-component/index.js +9 -0
  205. package/lib/group-component/style.d.ts +22 -0
  206. package/lib/group-component/style.js +55 -0
  207. package/lib/group-component/style.scss +1438 -0
  208. package/lib/group-component/table/Grid.d.ts +33 -0
  209. package/lib/group-component/table/Grid.js +443 -0
  210. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  211. package/lib/group-component/table/TableWrapper.js +259 -0
  212. package/lib/group-component/useContext.d.ts +100 -0
  213. package/lib/group-component/useContext.js +27 -0
  214. package/lib/table-component/InternalTable.js +6 -1
  215. package/lib/table-component/TableContainer.js +4 -2
  216. package/lib/table-component/TableContainerEdit.js +2 -2
  217. package/lib/table-component/body/TableBodyCell.js +49 -40
  218. package/lib/table-component/body/TableBodyCellEdit.js +9 -3
  219. package/lib/table-component/body/TableBodyRow.js +4 -1
  220. package/lib/table-component/hook/utils.d.ts +1 -0
  221. package/lib/table-component/hook/utils.js +16 -7
  222. package/lib/table-component/style.js +1 -1
  223. package/lib/table-component/table/Grid.js +3 -0
  224. package/lib/table-component/useContext.d.ts +5 -0
  225. package/lib/table-virtuoso/InternalTable.js +2 -2
  226. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  227. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  228. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  229. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  230. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  231. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  232. package/lib/table-virtuoso/hook/utils.js +32 -1
  233. package/lib/table-virtuoso/style.js +3 -1
  234. package/lib/table-virtuoso/table/Grid.js +2 -2
  235. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  236. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  237. package/lib/table-virtuoso/useContext.d.ts +6 -3
  238. package/lib/table-virtuoso/useContext.js +18 -0
  239. package/package.json +1 -1
@@ -0,0 +1,1405 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _reactTable = require("@tanstack/react-table");
9
+ var _space = _interopRequireDefault(require("rc-master-ui/es/space"));
10
+ var _Command = _interopRequireDefault(require("../components/command/Command"));
11
+ var _server = _interopRequireDefault(require("react-dom/server"));
12
+ var _utils = require("../hook/utils");
13
+ var _Checkbox = _interopRequireDefault(require("rc-master-ui/lib/checkbox/Checkbox"));
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+ var _react = _interopRequireDefault(require("react"));
16
+ var _useContext = require("../useContext");
17
+ var _EditableCell = _interopRequireDefault(require("./EditableCell"));
18
+ var _hooks = require("../../grid-component/hooks");
19
+ var _useColumns = require("../hook/useColumns");
20
+ var _utils2 = require("../../table-virtuoso/hook/utils");
21
+ const renderCellIndex = props => {
22
+ const {
23
+ parrents,
24
+ cell,
25
+ pagination
26
+ } = props;
27
+ if (parrents && parrents.length > 0) {
28
+ return /*#__PURE__*/_react.default.createElement("span", {
29
+ className: "ui-rc_cell-content"
30
+ }, parrents.map(pr => {
31
+ return `${pr.index + 1}.`;
32
+ }), cell.row.index + 1);
33
+ }
34
+ if (pagination && pagination.onChange) {
35
+ return /*#__PURE__*/_react.default.createElement("span", {
36
+ className: "ui-rc_cell-content"
37
+ }, cell.row.index + (pagination ? ((pagination.currentPage ?? 1) - 1) * (pagination?.pageSize ?? 0) : 0) + 1);
38
+ }
39
+ return /*#__PURE__*/_react.default.createElement("span", {
40
+ className: "ui-rc_cell-content"
41
+ }, cell.row.index + 1);
42
+ };
43
+ const renderCommand = args => {
44
+ const {
45
+ cell,
46
+ commandClick,
47
+ id,
48
+ data
49
+ } = args;
50
+ const col = cell.column.columnDef.meta ?? {};
51
+ const record = cell.row.original;
52
+
53
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
54
+
55
+ const commands = col.commandItems ? col.commandItems.map(it => {
56
+ return {
57
+ ...it,
58
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
59
+ };
60
+ }) : [];
61
+ return /*#__PURE__*/_react.default.createElement("div", {
62
+ className: "ui-rc_cell-content"
63
+ }, /*#__PURE__*/_react.default.createElement(_space.default, null, commands.filter(it => it.visible !== false).map(item => {
64
+ return /*#__PURE__*/_react.default.createElement(_Command.default, {
65
+ id: id,
66
+ key: item.id,
67
+ item: item,
68
+ record: record,
69
+ onClick: () => {
70
+ commandClick?.({
71
+ id: item.id,
72
+ // rowId: getRowKey(record, index) as any,
73
+ rowId: record.rowId,
74
+ rowData: record,
75
+ index: cell.row.index,
76
+ rows: [...data]
77
+ });
78
+ }
79
+ });
80
+ })));
81
+ };
82
+ const renderSelection = args => {
83
+ const {
84
+ row
85
+ } = args.cell;
86
+ const {
87
+ cell,
88
+ expandIconColumnIndex,
89
+ isDataTree,
90
+ expanded,
91
+ setExpanded
92
+ } = args;
93
+ const {
94
+ selectionSettings,
95
+ setIsSelectionChange,
96
+ isSelectionChange
97
+ } = args;
98
+ return /*#__PURE__*/_react.default.createElement("div", {
99
+ style: {
100
+
101
+ // paddingLeft: `${row.depth * 2}rem`,
102
+ }
103
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
104
+ className: "ui-rc-table-row-expand-trigger",
105
+ style: {
106
+ paddingLeft: `${cell.row.depth * 25}px`
107
+ }
108
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
109
+ // onClick: row.getToggleExpandedHandler(),
110
+ onClick: e => {
111
+ e.stopPropagation();
112
+ e.preventDefault();
113
+ const keys = Object.keys(expanded);
114
+ // @ts-ignore
115
+ const tmp = {
116
+ ...expanded
117
+ };
118
+ if (keys.includes(cell.row.id)) {
119
+ delete tmp[cell.row.id];
120
+ setExpanded(tmp);
121
+ } else {
122
+ setExpanded(old => ({
123
+ ...old,
124
+ [cell.row.id]: true
125
+ }));
126
+ }
127
+ },
128
+ style: {
129
+ cursor: "pointer"
130
+ },
131
+ className: "ui-rc-table-row-expand"
132
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
133
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
134
+ }) : /*#__PURE__*/_react.default.createElement("span", {
135
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
136
+ })) : /*#__PURE__*/_react.default.createElement("span", {
137
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
138
+ }))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
139
+ checked: row.getIsSelected() || row.getIsAllSubRowsSelected(),
140
+ indeterminate: row.getIsSomeSelected() && selectionSettings && selectionSettings.mode === 'checkbox' && selectionSettings.type !== 'single'
141
+ // indeterminate={row.getIsSomeSelected() }
142
+ // onChange={(e) => {
143
+
144
+ // row.getToggleSelectedHandler()(e)
145
+
146
+ // if (row.getIsSelected()) { // nếu đã chọn
147
+
148
+ // const aaa = isSelectionChange?.rowsData.filter((it) => it.id !== row.id)
149
+
150
+ // setIsSelectionChange({
151
+ // isChange: true,
152
+ // type: 'rowSelected',
153
+ // rowData: row.original,
154
+ // rowsData: aaa ?? []
155
+ // })
156
+
157
+ // } else {
158
+
159
+ // const { rowsData } = isSelectionChange ?? {}
160
+
161
+ // const abc = rowsData && rowsData.length > 0 ? [...rowsData] : []
162
+
163
+ // abc.push(row)
164
+
165
+ // setIsSelectionChange({
166
+ // isChange: true,
167
+ // type: 'rowSelected',
168
+ // rowData: row.original,
169
+ // rowsData: abc
170
+ // })
171
+ // }
172
+
173
+ // }}
174
+ ,
175
+
176
+ onChange: e => {
177
+ (0, _useColumns.toggleRowSelection)({
178
+ e,
179
+ cell,
180
+ setIsSelectionChange,
181
+ isSelectionChange,
182
+ selectionSettings
183
+ });
184
+ },
185
+ disabled: !row.getCanSelect()
186
+ })));
187
+ };
188
+ const TableBodyCellEdit = props => {
189
+ const {
190
+ cell,
191
+ commandClick,
192
+ // tableId,
193
+ table,
194
+ isEditing,
195
+ isRowEditable,
196
+ columnVirtualizer,
197
+ rowVirtualizer
198
+ // virtualRow
199
+ } = props;
200
+ const {
201
+ id,
202
+ rowKey,
203
+ editingKey,
204
+ prefix,
205
+ focusedCell,
206
+ rangeState,
207
+ setFocusedCell,
208
+ setEditingKey,
209
+ setRangeState,
210
+ setRangePasteState,
211
+ endCell,
212
+ setEndCell,
213
+ isSelecting,
214
+ isPasting,
215
+ setEndPasteCell,
216
+ endPasteCell,
217
+ setIsPasting,
218
+ setIsSelecting,
219
+ setStartCell,
220
+ setStartPasteCell,
221
+ startCell,
222
+ startPasteCell,
223
+ originData,
224
+ dataSource,
225
+ triggerPaste,
226
+ handleDeleteContent,
227
+ reset,
228
+ setValue,
229
+ getValues,
230
+ handleCellChange,
231
+ handleCellChangeAndAddRow,
232
+ dataErrors,
233
+ expanded,
234
+ setExpanded,
235
+ expandable,
236
+ isDataTree,
237
+ handleCellClick,
238
+ isSelectionChange,
239
+ setIsSelectionChange,
240
+ selectionSettings,
241
+ pagination,
242
+ handleAddMulti,
243
+ groupColumns
244
+ } = _react.default.useContext(_useContext.TableContext);
245
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex;
246
+ const record = cell.row.original;
247
+ const columnMeta = cell.column.columnDef.meta ?? {};
248
+ const [isOpenTooltip, setIsOpenTooltip] = _react.default.useState(false);
249
+ const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
250
+ const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined;
251
+ const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
252
+ value: cell.getValue(),
253
+ record
254
+ }) : columnMeta.tooltipDescription : columnMeta.template && typeof columnMeta.template !== 'function' ? columnMeta.template : cell.getValue();
255
+ const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record) && isRowEditable !== false;
256
+
257
+ // const allRows = table.getRowModel().rows;
258
+ const allRows = table.getRowModel().flatRows;
259
+
260
+ // const rowNumber = virtualRow.index
261
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
262
+ const colIndex = cell.column.getIndex();
263
+ const isPinned = cell.column.getIsPinned();
264
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
265
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
266
+ const selectRowIds = _react.default.useMemo(() => {
267
+ return startCell && endCell ? (0, _utils.getRowIdsBetween)(table, startCell.rowId, endCell.rowId) : [];
268
+ }, [endCell, startCell, table]);
269
+ const isCellSelected = _react.default.useMemo(() => {
270
+ if (!startCell || !endCell) return false;
271
+
272
+ // const rowIds = getRowIdsBetween(table, startCell.rowId, endCell.rowId);
273
+ const colIds = (0, _utils.getColIdsBetween)(table, startCell.colId, endCell.colId);
274
+ return selectRowIds.includes(cell.row.id) && colIds.includes(cell.column.id);
275
+ }, [cell.column.id, cell.row.id, endCell, selectRowIds, startCell, table]);
276
+ const editType = typeof columnMeta.editType === 'function' ? columnMeta.editType(record) : columnMeta.editType;
277
+ const {
278
+ rowRange,
279
+ colRange,
280
+ rowIds,
281
+ colIds,
282
+ startColIndex,
283
+ startRowIndex,
284
+ endColIndex,
285
+ endRowIndex
286
+ } = rangeState ?? {};
287
+ const pasteRangeState = (0, _utils.getSelectedCellMatrix)(table, startPasteCell, endPasteCell);
288
+ const isInRange = colRange && rowRange && rowRange.includes(cell.row.id) && colRange.includes(cell.column.id);
289
+ const isInRangePaste = pasteRangeState.rowRange && pasteRangeState.rowRange.includes(cell.row.id) && pasteRangeState.colRange.includes(cell.column.id);
290
+
291
+ // const isInRangePaste = rowRange && rowRange.includes(cell.row.id) && colRange.includes(cell.column.id);
292
+
293
+ const rowIdx = rowIds ? rowIds.indexOf(cell.row.id) : -1;
294
+ const colIdx = colIds ? colIds.indexOf(cell.column.id) : -1;
295
+ const rowIdxPaste = pasteRangeState.rowIds.indexOf(cell.row.id);
296
+ const colIdxPaste = pasteRangeState.colIds.indexOf(cell.column.id);
297
+ const isTop = rowIdx === startRowIndex;
298
+ const isBottom = rowIdx === endRowIndex;
299
+ const isLeft = colIdx === startColIndex;
300
+ const isRight = colIdx === endColIndex;
301
+ const isTopPaste = rowIdxPaste === pasteRangeState.startRowIndex;
302
+ const isBottomPaste = rowIdxPaste === pasteRangeState.endRowIndex;
303
+ const isLeftPaste = colIdxPaste === pasteRangeState.startColIndex;
304
+ const isRightPaste = colIdxPaste === pasteRangeState.endColIndex;
305
+ const parrents = cell.row.getParentRows();
306
+ const triggerDragPaste = (pasteState, ctrlKey) => {
307
+ const tmpCols = table.getVisibleLeafColumns();
308
+ const rowPasteIds = (0, _utils.getRowIdsBetween)(table, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
309
+ const colPasteds = (0, _utils.getColIdsBetween)(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
310
+ const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
311
+ const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
312
+ const dataSelected = [];
313
+ rowSelectIds.forEach(rowId => {
314
+ const row = allRows.find(r => r.id === rowId);
315
+ if (!row) return;
316
+ const rowData = [];
317
+ colSelectIds.forEach(colId => {
318
+ const cellll = row.getVisibleCells().find(c => c.column.id === colId);
319
+ const value = cellll?.getValue();
320
+ rowData.push(value !== undefined ? value : '');
321
+ });
322
+ dataSelected.push(rowData);
323
+ });
324
+ const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
325
+ let newRange;
326
+ if ((startRowIndex ?? 0) < (pasteRangeState.startRowIndex ?? 0)) {
327
+ // kéo xuóng
328
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
329
+ newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
330
+ } else {
331
+ // kéo lên
332
+ setStartCell?.(endCell);
333
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, endCell, endPasteCell));
334
+ newRange = ctrlKey ? (0, _utils.addRowsUpWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsUp)(dataSelected, rowPasteIds.length);
335
+ }
336
+
337
+ // Cập nhật data mới
338
+ const newData = (0, _utils.flattenArray)([...dataSource]);
339
+ const pastedRows = [];
340
+ newRange.addedRows.forEach((rowValues, rowIndex1) => {
341
+ const targetRow = pasteState.startRowIndex + rowIndex1;
342
+
343
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
344
+ if (targetRow >= newData.length) {
345
+ newData.push({
346
+ id: undefined,
347
+ rowId: (0, _utils.newGuid)()
348
+ });
349
+ }
350
+ rowValues.forEach((cellValue, colIndex1) => {
351
+ const targetCol = startColIndex + colIndex1;
352
+ if (targetCol >= tmpCols.length) {
353
+ // Không vượt quá số cột
354
+ return;
355
+ }
356
+ const columnKey = tmpCols[targetCol].id;
357
+ const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
358
+ if (!disable) {
359
+ newData[targetRow] = {
360
+ ...newData[targetRow],
361
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
362
+ };
363
+ }
364
+ });
365
+
366
+ // Lưu dòng được paste
367
+ pastedRows.push(newData[targetRow]);
368
+ });
369
+ const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), newData);
370
+ const rs = (0, _utils.unFlattenData)(rsFilterData);
371
+ triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
372
+
373
+ // // setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell))
374
+
375
+ setEndCell?.(endPasteCell);
376
+ setEndPasteCell?.(undefined);
377
+ setStartPasteCell?.(undefined);
378
+ setRangePasteState?.(undefined);
379
+ };
380
+ const triggerDragPasteGroup = (pasteState, ctrlKey) => {
381
+ const tmpCols = table.getVisibleLeafColumns();
382
+ const rowPasteIds = (0, _utils.getRowIdsBetween)(table, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
383
+ const colPasteds = (0, _utils.getColIdsBetween)(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
384
+ const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
385
+ const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
386
+ const dataSelected = [];
387
+ rowSelectIds.forEach(rowId => {
388
+ const row = allRows.find(r => r.id === rowId);
389
+ if (!row) return;
390
+ const rowData = [];
391
+ colSelectIds.forEach(colId => {
392
+ const cellll = row.getVisibleCells().find(c => c.column.id === colId);
393
+ const value = cellll?.getValue();
394
+ rowData.push(value !== undefined ? value : '');
395
+ });
396
+ dataSelected.push(rowData);
397
+ });
398
+ const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
399
+ // const copyRows = flattenData('children', originData).filter((it) => rowSelectIds.includes(it[rowKey]))
400
+
401
+ let newRange;
402
+ if ((startRowIndex ?? 0) < (pasteRangeState.startRowIndex ?? 0)) {
403
+ // kéo xuóng
404
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
405
+ newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
406
+ } else {
407
+ // kéo lên
408
+ setStartCell?.(endCell);
409
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, endCell, endPasteCell));
410
+ newRange = ctrlKey ? (0, _utils.addRowsUpWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsUp)(dataSelected, rowPasteIds.length);
411
+ }
412
+
413
+ // Cập nhật data mới
414
+ const newData = (0, _utils.flattenArray)([...dataSource]);
415
+ const pastedRows = [];
416
+ newRange.addedRows.forEach((rowValues, rowIndex1) => {
417
+ const targetRow = pasteState.startRowIndex + rowIndex1;
418
+
419
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
420
+ if (targetRow >= newData.length) {
421
+ newData.push({
422
+ id: undefined,
423
+ rowId: (0, _utils.newGuid)()
424
+ });
425
+ }
426
+ rowValues.forEach((cellValue, colIndex1) => {
427
+ const targetCol = startColIndex + colIndex1;
428
+ if (targetCol >= tmpCols.length) {
429
+ // Không vượt quá số cột
430
+ return;
431
+ }
432
+ const columnKey = tmpCols[targetCol].id;
433
+ const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
434
+ if (!disable) {
435
+ newData[targetRow] = {
436
+ ...newData[targetRow],
437
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
438
+ };
439
+ }
440
+ });
441
+
442
+ // Lưu dòng được paste
443
+ pastedRows.push(newData[targetRow]);
444
+ });
445
+
446
+ // return
447
+
448
+ const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...dataSource]), newData);
449
+ // const rsFilterData = updateOrInsert(flattenArray([...originData]), newData)
450
+
451
+ const rs = (0, _utils.unFlattenData)(rsFilterData);
452
+ const dta = (0, _utils2.unGroupData)(rs, originData);
453
+ triggerPaste?.(pastedRows, colPasteds, dta, copyRows);
454
+
455
+ // // setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell))
456
+
457
+ setEndCell?.(endPasteCell);
458
+ setEndPasteCell?.(undefined);
459
+ setStartPasteCell?.(undefined);
460
+ setRangePasteState?.(undefined);
461
+ };
462
+ const triggerPointPaste = (pasteState, cellStart, cellEnd, ctrlKey) => {
463
+ const tmpCols = table.getVisibleLeafColumns();
464
+ const rowPasteIds = (0, _utils.getRowIdsBetween)(table, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
465
+ const colPasteds = (0, _utils.getColIdsBetween)(table, cellStart?.colId ?? '', cellEnd?.colId ?? '');
466
+ const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
467
+ const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
468
+ const dataSelected = [];
469
+ rowSelectIds.forEach(rowId => {
470
+ const row = allRows.find(r => r.id === rowId);
471
+ if (!row) return;
472
+ const rowData = [];
473
+ colSelectIds.forEach(colId => {
474
+ const cellll = row.getVisibleCells().find(c => c.column.id === colId);
475
+ const value = cellll?.getValue();
476
+ rowData.push(value !== undefined ? value : '');
477
+ });
478
+ dataSelected.push(rowData);
479
+ });
480
+ const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
481
+
482
+ // kéo xuóng
483
+ // setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell))
484
+ const newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
485
+
486
+ // Cập nhật data mới
487
+ const newData = (0, _utils.flattenArray)([...dataSource]);
488
+ const pastedRows = [];
489
+ newRange.addedRows.forEach((rowValues, rowIndex1) => {
490
+ const targetRow = pasteState.startRowIndex + rowIndex1;
491
+
492
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
493
+ // if (targetRow >= newData.length) {
494
+
495
+ // newData.push({ id: undefined, rowId: newGuid() })
496
+ // }
497
+
498
+ rowValues.forEach((cellValue, colIndex1) => {
499
+ const targetCol = startColIndex + colIndex1;
500
+ if (targetCol >= tmpCols.length) {
501
+ // Không vượt quá số cột
502
+ return;
503
+ }
504
+ const columnKey = tmpCols[targetCol].id;
505
+ newData[targetRow] = {
506
+ ...newData[targetRow],
507
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
508
+ };
509
+ });
510
+
511
+ // Lưu dòng được paste
512
+ pastedRows.push(newData[targetRow]);
513
+ });
514
+ const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), newData);
515
+ const rs = (0, _utils.unFlattenData)(rsFilterData);
516
+ triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
517
+ };
518
+ function handleMouseEnter(e, rowId, colId) {
519
+ if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
520
+ setIsOpenTooltip(true);
521
+ }
522
+ if (isSelecting) {
523
+ setEndCell?.({
524
+ rowId,
525
+ colId
526
+ });
527
+ }
528
+ if (isPasting) {
529
+ const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === cell.row.id);
530
+ if ((startRowIndex ?? 0) > absRowIndex) {
531
+ // kéo lên
532
+
533
+ const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
534
+ setStartPasteCell?.({
535
+ colId: startCell?.colId ?? '',
536
+ rowId: startRowPaste?.id ?? ''
537
+ });
538
+ setEndPasteCell?.({
539
+ colId: endCell?.colId ?? '',
540
+ rowId
541
+ });
542
+ setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, {
543
+ colId: startCell?.colId ?? '',
544
+ rowId: startRowPaste?.id ?? ''
545
+ }, {
546
+ colId: endCell?.colId ?? '',
547
+ rowId
548
+ }));
549
+ }
550
+ if ((startRowIndex ?? 0) < absRowIndex) {
551
+ // kéo xuống
552
+
553
+ const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
554
+ const startRowPaste = allRows[findIndex + 1];
555
+ setStartPasteCell?.({
556
+ colId: startCell?.colId ?? '',
557
+ rowId: startRowPaste?.id ?? ''
558
+ });
559
+ setEndPasteCell?.({
560
+ colId: endCell?.colId ?? '',
561
+ rowId
562
+ });
563
+ setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, {
564
+ colId: startCell?.colId ?? '',
565
+ rowId: startRowPaste?.id ?? ''
566
+ }, {
567
+ colId: endCell?.colId ?? '',
568
+ rowId
569
+ }));
570
+ }
571
+ }
572
+ }
573
+ const handlePointDoubleClick = e => {
574
+ e.preventDefault();
575
+ e.stopPropagation();
576
+ const rowEnd = table.getRowModel().flatRows[table.getRowModel().flatRows.length - 1];
577
+ const cellEnd = {
578
+ rowId: rowEnd.id,
579
+ colId: cell.column.id
580
+ };
581
+ const currentRowId = allRows.findIndex(it => it.id === cell.row.id);
582
+ const pasteStartRow = allRows[currentRowId + 1];
583
+ const cellStart = {
584
+ rowId: pasteStartRow.id,
585
+ colId: endCell?.colId ?? ''
586
+ };
587
+ const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, cellEnd);
588
+ const selectPasteState = (0, _utils.getSelectedCellMatrix)(table, cellStart, cellEnd);
589
+ setRangeState?.(selectState);
590
+ setEndCell?.(cellEnd);
591
+ triggerPointPaste(selectPasteState, cellStart, cellEnd, e.ctrlKey);
592
+ };
593
+ function handleMouseUp(e) {
594
+ setIsSelecting?.(false);
595
+ setIsPasting?.(false);
596
+ const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, endCell);
597
+ const selectPasteState = (0, _utils.getSelectedCellMatrix)(table, startPasteCell, endPasteCell);
598
+ if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
599
+ // triggerDragPaste(selectPasteState, e.ctrlKey)
600
+
601
+ if (groupColumns && groupColumns.length > 0) {
602
+ triggerDragPasteGroup(selectPasteState, e.ctrlKey);
603
+ } else {
604
+ triggerDragPaste(selectPasteState, e.ctrlKey);
605
+ }
606
+ } else {
607
+ // if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
608
+ // setRangeState?.(selectState)
609
+ // }
610
+
611
+ if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
612
+ setRangeState?.(selectState);
613
+ }
614
+ }
615
+
616
+ // setRangePasteState(selectPasteState)
617
+ }
618
+ const handleEdit = (e, isKeyDown) => {
619
+ setEditingKey?.(record[rowKey]);
620
+ // setTooltipContent('')
621
+
622
+ handleCellClick?.(rowNumber, record, columnMeta, record[rowKey], record[columnMeta.field ?? '']);
623
+ reset?.();
624
+
625
+ // const formattedRecord = { ...record };
626
+
627
+ if (!(0, _utils.isObjEmpty)(record)) {
628
+ Object.entries(record).forEach(([name, value]) => {
629
+ setValue?.(name, value);
630
+ });
631
+ }
632
+ if (isKeyDown) {
633
+ if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
634
+ setValue(columnMeta.field, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
635
+ }
636
+ }
637
+ if (editType === 'select') {
638
+
639
+ // setSearchValue(e.key)
640
+ // setOpen(true)
641
+ }
642
+ if (focusedCell?.rowId) {
643
+ setTimeout(() => {
644
+ // const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${startSelectedCells.current.row}"].cell-editing[data-col-index="${startSelectedCells.current.col}"] input`) as HTMLInputElement
645
+ // const textarea = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowNumber}"].cell-editing[data-col-index="${startSelectedCells.current.col}"] textarea`) as any
646
+ const textarea = document.querySelector(`.ui-rc-grid-row .cell-editing[data-row-key="${focusedCell.rowId}"].cell-editing[data-col-key="${focusedCell.colId}"] textarea`);
647
+ // const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells.current.col}"] .ant-select-selection-search input`)
648
+
649
+ if (textarea) {
650
+ textarea.focus();
651
+ textarea.setSelectionRange(textarea.value.length, textarea.value.length);
652
+ }
653
+ // if (input) {
654
+ // input.focus()
655
+ // }
656
+
657
+ // if (select) {
658
+ // // @ts-ignore
659
+ // select.searchValue = e.key
660
+ // // @ts-ignore
661
+ // select.focus()
662
+ // }
663
+ }, 10);
664
+ }
665
+ };
666
+ function handleKeyDown(e, rowId, colId) {
667
+ if (e.key === 'Tab') {
668
+ e.preventDefault();
669
+ const allCols = table.getVisibleLeafColumns();
670
+ const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
671
+ const nextCol = allCols[currentColIndex + 1];
672
+ if (nextCol) {
673
+ setFocusedCell?.({
674
+ rowId,
675
+ colId: nextCol.id
676
+ });
677
+ setStartCell?.({
678
+ rowId,
679
+ colId: nextCol.id
680
+ });
681
+ setEndCell?.({
682
+ rowId,
683
+ colId: nextCol.id
684
+ });
685
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
686
+ rowId,
687
+ colId: nextCol.id
688
+ }, {
689
+ rowId,
690
+ colId: nextCol.id
691
+ }));
692
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
693
+ align: 'center'
694
+ });
695
+ } else {
696
+ // Nếu là cột cuối cùng, có thể nhảy xuống dòng tiếp theo
697
+
698
+ const currentRowIndex = allRows.findIndex(r => r.id === rowId);
699
+ const nextRow = allRows[currentRowIndex + 1];
700
+ const nextRowCol = allCols[2];
701
+ if (nextRow) {
702
+ setFocusedCell?.({
703
+ rowId: nextRow.id,
704
+ colId: nextRowCol.id
705
+ }); // sang dòng, cột đầu
706
+
707
+ setStartCell?.({
708
+ rowId: nextRow.id,
709
+ colId: nextRowCol.id
710
+ });
711
+ setEndCell?.({
712
+ rowId: nextRow.id,
713
+ colId: nextRowCol.id
714
+ });
715
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
716
+ rowId: nextRow.id,
717
+ colId: nextRowCol.id
718
+ }, {
719
+ rowId: nextRow.id,
720
+ colId: nextRowCol.id
721
+ }));
722
+ columnVirtualizer.scrollToIndex(nextRowCol.getIndex());
723
+ rowVirtualizer.scrollToIndex(nextRow.index, {
724
+ align: 'auto'
725
+ });
726
+ }
727
+ }
728
+ return;
729
+ }
730
+ if (e.key === 'ArrowRight') {
731
+ e.preventDefault();
732
+ e.stopPropagation();
733
+ const allCols = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
734
+ const currentColIndex = allCols.findIndex(it => it.id === cell.column.id);
735
+ const nextCol = allCols[currentColIndex + 1];
736
+ if (nextCol) {
737
+ setFocusedCell?.({
738
+ rowId,
739
+ colId: nextCol.id
740
+ });
741
+ setStartCell?.({
742
+ rowId,
743
+ colId: nextCol.id
744
+ });
745
+ setEndCell?.({
746
+ rowId,
747
+ colId: nextCol.id
748
+ });
749
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
750
+ rowId,
751
+ colId: nextCol.id
752
+ }, {
753
+ rowId,
754
+ colId: nextCol.id
755
+ }));
756
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
757
+ align: 'center'
758
+ });
759
+ }
760
+ return;
761
+ }
762
+ if (e.key === 'ArrowLeft') {
763
+ e.preventDefault();
764
+ const allCols = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
765
+
766
+ // const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
767
+ const currentColIndex = allCols.findIndex(it => it.id === cell.column.id);
768
+ const nextCol = allCols[currentColIndex - 1];
769
+ if (nextCol) {
770
+ setFocusedCell?.({
771
+ rowId,
772
+ colId: nextCol.id
773
+ });
774
+ setStartCell?.({
775
+ rowId,
776
+ colId: nextCol.id
777
+ });
778
+ setEndCell?.({
779
+ rowId,
780
+ colId: nextCol.id
781
+ });
782
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
783
+ rowId,
784
+ colId: nextCol.id
785
+ }, {
786
+ rowId,
787
+ colId: nextCol.id
788
+ }));
789
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
790
+ align: 'center'
791
+ });
792
+ }
793
+ return;
794
+ }
795
+ if (e.key === 'ArrowDown') {
796
+ // e.preventDefault()
797
+ // e.stopPropagation()
798
+
799
+ let nextRowIndex = rowNumber + 1;
800
+ let nextRow = table.getRowModel().rows[nextRowIndex];
801
+
802
+ // Nếu nextRow có children và chưa được expand, thì tìm tiếp dòng tiếp theo
803
+ while (nextRow && nextRow.subRows && nextRow.subRows.length > 0) {
804
+ nextRowIndex++;
805
+ nextRow = table.getRowModel().rows[nextRowIndex];
806
+ }
807
+ if (nextRow) {
808
+ const nextRowId = nextRow.id;
809
+ setFocusedCell?.({
810
+ rowId: nextRowId,
811
+ colId
812
+ });
813
+ setStartCell?.({
814
+ rowId: nextRowId,
815
+ colId
816
+ });
817
+ setEndCell?.({
818
+ rowId: nextRowId,
819
+ colId
820
+ });
821
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
822
+ rowId: nextRowId,
823
+ colId
824
+ }, {
825
+ rowId: nextRowId,
826
+ colId
827
+ }));
828
+
829
+ // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
830
+ // rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
831
+
832
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
833
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
834
+ if (cellFocus) {
835
+ cellFocus.focus();
836
+ }
837
+ }
838
+ return;
839
+ }
840
+ if (e.key === 'ArrowUp') {
841
+ // e.preventDefault()
842
+ // e.stopPropagation()
843
+
844
+ // const nextRow = table.getRowModel().rows[rowNumber - 1]
845
+
846
+ let prevRowIndex = rowNumber - 1;
847
+ let prevRow = table.getRowModel().rows[prevRowIndex];
848
+
849
+ // Nếu nextRow có children và chưa được expand, thì tìm tiếp dòng tiếp theo
850
+ while (prevRow && prevRow.subRows && prevRow.subRows.length > 0) {
851
+ prevRowIndex--;
852
+ prevRow = table.getRowModel().rows[prevRowIndex];
853
+ }
854
+ if (prevRow) {
855
+ const nextRowId = prevRow.id;
856
+ setFocusedCell?.({
857
+ rowId: nextRowId,
858
+ colId
859
+ });
860
+ setStartCell?.({
861
+ rowId: nextRowId,
862
+ colId
863
+ });
864
+ setEndCell?.({
865
+ rowId: nextRowId,
866
+ colId
867
+ });
868
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
869
+ rowId: nextRowId,
870
+ colId
871
+ }, {
872
+ rowId: nextRowId,
873
+ colId
874
+ }));
875
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextRowId}"]`);
876
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
877
+ if (cellFocus) {
878
+ cellFocus.focus();
879
+ }
880
+ }
881
+ return;
882
+ }
883
+ if (e.key === 'Delete') {
884
+ handleDeleteContent?.();
885
+ return;
886
+ }
887
+ if (e.key === 'Enter') {
888
+ e.preventDefault();
889
+ e.stopPropagation();
890
+ handleEdit(e, true);
891
+ return;
892
+ }
893
+ if (e.key.length === 1 && !e.ctrlKey) {
894
+ e.preventDefault();
895
+ e.stopPropagation();
896
+ handleEdit(e, true);
897
+ // setValue(cell.column.id, editType === 'numeric' ? (!isNaN(Number(e.key)) ? Number(e.key) : '') : e.key)
898
+ }
899
+ }
900
+ function handleMouseDown(rowId, colId) {
901
+ setIsSelecting?.(true);
902
+ if (startCell?.rowId !== rowId || startCell?.colId !== colId || endCell?.rowId !== rowId || endCell?.colId !== colId) {
903
+ setStartCell?.({
904
+ rowId,
905
+ colId
906
+ });
907
+ setEndCell?.({
908
+ rowId,
909
+ colId
910
+ });
911
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
912
+ rowId,
913
+ colId
914
+ }, {
915
+ rowId,
916
+ colId
917
+ }));
918
+ }
919
+ if (focusedCell?.rowId !== cell.row.id || focusedCell?.colId !== cell.column.id) {
920
+ setFocusedCell?.({
921
+ rowId: cell.row.id,
922
+ colId: cell.column.id
923
+ });
924
+ }
925
+ }
926
+ const handleMouseDownIndex = rowId => {
927
+ setIsSelecting?.(true);
928
+ const allColumns = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
929
+ const firstCOlSpin = (0, _utils.findFirst)(allColumns);
930
+ const startCol = allColumns[0].id;
931
+ const endCol = allColumns[allColumns.length - 1].id;
932
+ setStartCell?.({
933
+ rowId,
934
+ colId: startCol
935
+ });
936
+ setEndCell?.({
937
+ rowId,
938
+ colId: endCol
939
+ });
940
+ if (firstCOlSpin) {
941
+ setFocusedCell?.({
942
+ rowId: cell.row.id,
943
+ colId: firstCOlSpin.id
944
+ });
945
+ } else {
946
+ const firstCOlVisible = allColumns[0];
947
+ setFocusedCell?.({
948
+ rowId: cell.row.id,
949
+ colId: firstCOlVisible.id
950
+ });
951
+ }
952
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
953
+ rowId,
954
+ colId: startCol
955
+ }, {
956
+ rowId,
957
+ colId: endCol
958
+ }));
959
+ };
960
+ const handleMouseEnterIndex = rowId => {
961
+ if (isSelecting) {
962
+ const allColumns = table.getVisibleLeafColumns().filter(it => !_hooks.nonActionColumn.includes(it.id));
963
+
964
+ // const firstCOl = findFirst(allColumns)
965
+
966
+ // const startCol = allColumns[0].id
967
+ const endCol = allColumns[allColumns.length - 1].id;
968
+
969
+ // setStartCell?.({ rowId, colId: startCol });
970
+ setEndCell?.({
971
+ rowId,
972
+ colId: endCol
973
+ });
974
+ }
975
+ };
976
+ const handleMouseUpIndex = () => {
977
+ setIsSelecting?.(false);
978
+ // setIsPasting?.(false);
979
+
980
+ const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, endCell);
981
+ if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
982
+ setRangeState?.(selectState);
983
+ }
984
+ };
985
+ if (cell.column.id === "#") {
986
+ return /*#__PURE__*/_react.default.createElement("div", {
987
+ key: cell.id,
988
+ className: (0, _classnames.default)(`${prefix}-grid-cell ${prefix}-grid-cell-index editable`, {
989
+ [`${prefix}-grid-cell-ellipsis`]: true,
990
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
991
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
992
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
993
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right',
994
+ // [`${prefix}-grid-cell-index-selected`]: rowRange?.includes(cell.row.id),
995
+ [`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(cell.row.id)
996
+ }),
997
+ style: {
998
+ display: 'flex',
999
+ height: '36px',
1000
+ userSelect: 'none',
1001
+ width: cell.column.getSize(),
1002
+ // flexBasis: cell.column.getSize(),
1003
+ minWidth: cell.column.getSize(),
1004
+ // flex: 1,
1005
+ // maxWidth: cell.column.getSize(),
1006
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
1007
+ },
1008
+ onMouseDown: () => {
1009
+ if (record[rowKey] === editingKey) {
1010
+ setFocusedCell?.({
1011
+ rowId: cell.row.id,
1012
+ colId: cell.column.id
1013
+ });
1014
+ } else {
1015
+ handleMouseDownIndex(cell.row.id);
1016
+ if (editingKey) {
1017
+ setTimeout(() => {
1018
+ setEditingKey?.('');
1019
+ reset?.();
1020
+ });
1021
+ }
1022
+
1023
+ // reset?.()
1024
+ }
1025
+ },
1026
+ onMouseEnter: () => {
1027
+ handleMouseEnterIndex(cell.row.id);
1028
+ },
1029
+ onMouseUp: handleMouseUpIndex
1030
+ // onMouseUp={() => {
1031
+
1032
+ // handleMouseUpIndex()
1033
+
1034
+ // }}
1035
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
1036
+ className: "ui-rc-table-row-expand-trigger",
1037
+ style: {
1038
+ paddingLeft: `${cell.row.depth * 25}px`
1039
+ }
1040
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
1041
+ // onClick: row.getToggleExpandedHandler(),
1042
+ onClick: e => {
1043
+ e.stopPropagation();
1044
+ e.preventDefault();
1045
+ const keys = Object.keys(expanded);
1046
+ // @ts-ignore
1047
+ const tmp = {
1048
+ ...expanded
1049
+ };
1050
+ if (keys.includes(cell.row.id)) {
1051
+ delete tmp[cell.row.id];
1052
+ setExpanded(tmp);
1053
+ } else {
1054
+ setExpanded(old => ({
1055
+ ...old,
1056
+ [cell.row.id]: true
1057
+ }));
1058
+ }
1059
+ },
1060
+ style: {
1061
+ cursor: "pointer"
1062
+ },
1063
+ className: "ui-rc-table-row-expand"
1064
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
1065
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
1066
+ }) : /*#__PURE__*/_react.default.createElement("span", {
1067
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
1068
+ })) : /*#__PURE__*/_react.default.createElement("span", {
1069
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
1070
+ }))), renderCellIndex({
1071
+ parrents,
1072
+ cell,
1073
+ pagination
1074
+ }));
1075
+ }
1076
+ if (cell.column.id === "command") {
1077
+ return /*#__PURE__*/_react.default.createElement("div", {
1078
+ key: cell.id,
1079
+ className: (0, _classnames.default)(`${prefix}-grid-cell ${prefix}-grid-cell-command editable`, {
1080
+ [`${prefix}-grid-cell-ellipsis`]: true,
1081
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
1082
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
1083
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
1084
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
1085
+ }),
1086
+ style: {
1087
+ display: 'flex',
1088
+ height: '36px',
1089
+ width: cell.column.getSize(),
1090
+ minWidth: cell.column.getSize(),
1091
+ // flex: 1,
1092
+ // maxWidth: cell.column.getSize(),
1093
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
1094
+ }
1095
+ }, renderCommand({
1096
+ cell,
1097
+ commandClick,
1098
+ id,
1099
+ data: originData
1100
+ }));
1101
+ }
1102
+ if (cell.column.id === "selection_column") {
1103
+ return /*#__PURE__*/_react.default.createElement("div", {
1104
+ key: cell.id,
1105
+ className: (0, _classnames.default)(`${prefix}-grid-cell ${prefix}-grid-cell-selection editable`, {
1106
+ [`${prefix}-grid-cell-ellipsis`]: true,
1107
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
1108
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
1109
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
1110
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
1111
+ }),
1112
+ style: {
1113
+ display: 'flex',
1114
+ height: '36px',
1115
+ width: cell.column.getSize(),
1116
+ minWidth: cell.column.getSize(),
1117
+ // flex: 1,
1118
+ // maxWidth: cell.column.getSize(),
1119
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
1120
+ }
1121
+ }, cell.column.id === "selection_column" && renderSelection({
1122
+ cell,
1123
+ table,
1124
+ selectionSettings,
1125
+ setIsSelectionChange,
1126
+ expanded,
1127
+ isDataTree,
1128
+ setExpanded,
1129
+ expandIconColumnIndex,
1130
+ isSelectionChange
1131
+ }));
1132
+ }
1133
+ const handleChange = () => {
1134
+ const currentRowIndex = allRows.findIndex(r => r.id === editingKey);
1135
+ const formState = getValues();
1136
+ const itemState = getValues(cell.column.id);
1137
+ const prevState = record[cell.column.id];
1138
+ const newState = itemState;
1139
+ if (newState !== prevState) {
1140
+ handleCellChange?.({
1141
+ key: cell.row.id,
1142
+ field: cell.column.id,
1143
+ record: formState,
1144
+ prevState,
1145
+ newState,
1146
+ option: newState,
1147
+ indexCol: cell.column.getIndex(),
1148
+ indexRow: currentRowIndex,
1149
+ type: 'blur'
1150
+ });
1151
+ } else {}
1152
+ };
1153
+ const handleChangeAndCreateRow = () => {
1154
+ const currentRowIndex = allRows.findIndex(r => r.id === editingKey);
1155
+ const formState = getValues();
1156
+ const itemState = getValues(cell.column.id);
1157
+ const prevState = record[cell.column.id];
1158
+ const newState = itemState;
1159
+ if (newState !== prevState) {
1160
+ // vừa cell change + add new row
1161
+ handleCellChangeAndAddRow?.({
1162
+ key: cell.row.id,
1163
+ field: cell.column.id,
1164
+ record: formState,
1165
+ prevState,
1166
+ newState,
1167
+ option: newState,
1168
+ indexCol: cell.column.getIndex(),
1169
+ indexRow: currentRowIndex,
1170
+ type: 'blur'
1171
+ });
1172
+ } else {
1173
+ // chỉ add new row
1174
+
1175
+ const newRowId = (0, _utils.newGuid)();
1176
+ handleAddMulti?.({}, 1, newRowId);
1177
+ setFocusedCell?.({
1178
+ rowId: newRowId,
1179
+ colId: cell.column.id
1180
+ });
1181
+ setStartCell?.({
1182
+ rowId: newRowId,
1183
+ colId: cell.column.id
1184
+ });
1185
+ setEndCell?.({
1186
+ rowId: newRowId,
1187
+ colId: cell.column.id
1188
+ });
1189
+ setTimeout(() => {
1190
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
1191
+ rowId: newRowId,
1192
+ colId: cell.column.id
1193
+ }, {
1194
+ rowId: newRowId,
1195
+ colId: cell.column.id
1196
+ }));
1197
+ });
1198
+ setTimeout(() => {
1199
+ const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${newRowId}"]`);
1200
+ const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
1201
+ if (cellFocus) {
1202
+ cellFocus.scrollIntoView({
1203
+ behavior: "smooth",
1204
+ block: "start"
1205
+ });
1206
+ cellFocus.focus();
1207
+ }
1208
+ }, 100);
1209
+ }
1210
+ };
1211
+ return /*#__PURE__*/_react.default.createElement("div", {
1212
+ key: cell.id,
1213
+ ref: el => {
1214
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
1215
+ el?.focus();
1216
+ }
1217
+ },
1218
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
1219
+ "data-col-index": colIndex,
1220
+ "data-row-index": rowNumber,
1221
+ "data-col-key": cell.column.id,
1222
+ "data-row-key": cell.row.id,
1223
+ "data-tooltip-id": `${id}-tooltip-content`,
1224
+ "data-tooltip-delay-show": 500,
1225
+ "data-tooltip-html": isEditing && message ? message : rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tooltipContent)),
1226
+ className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable editable `, {
1227
+ [`${prefix}-grid-cell-ellipsis`]: true,
1228
+ 'cell-editing': isEditing,
1229
+ // disable: !isEditable(cell.column.columnDef.meta as any, record),
1230
+ disable: !canEdit,
1231
+ isValid: !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id,
1232
+ [`${prefix}-grid-cell-selected`]: isCellSelected,
1233
+ 'cell-border-bottom': !isEditing && isInRange && isBottom,
1234
+ 'cell-border-right': !isEditing && isInRange && isRight,
1235
+ 'cell-border-top': !isEditing && isInRange && isTop,
1236
+ 'cell-border-left': !isEditing && isInRange && isLeft,
1237
+ 'cell-paste-border-bottom': isInRangePaste && isBottomPaste && (pasteRangeState.endRowIndex ?? 0) > (endRowIndex ?? 0),
1238
+ 'cell-paste-border-right': isInRangePaste && isRightPaste,
1239
+ 'cell-paste-border-top': isInRangePaste && isTopPaste && (pasteRangeState.endRowIndex ?? 0) < (endRowIndex ?? 0),
1240
+ 'cell-paste-border-left': isInRangePaste && isLeftPaste,
1241
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
1242
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
1243
+ [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
1244
+ [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
1245
+ }),
1246
+ style: {
1247
+ display: 'flex',
1248
+ width: cell.column.getSize(),
1249
+ minWidth: cell.column.getSize(),
1250
+ // flex: 1,
1251
+ // maxWidth: cell.column.getSize(),
1252
+ height: '36px',
1253
+ ...(0, _utils.getCommonPinningStyles)(cell.column),
1254
+ cursor: isPasting ? 'crosshair' : undefined
1255
+ },
1256
+ onMouseDown: () => {
1257
+ if (record[rowKey] === editingKey) {
1258
+ setFocusedCell?.({
1259
+ rowId: cell.row.id,
1260
+ colId: cell.column.id
1261
+ });
1262
+ if (canEdit) {
1263
+ handleCellClick?.(rowNumber, record, columnMeta, record[rowKey], record[columnMeta.field ?? '']);
1264
+ }
1265
+ } else {
1266
+ handleMouseDown(cell.row.id, cell.column.id);
1267
+ if (editingKey) {
1268
+ setTimeout(() => {
1269
+ setEditingKey?.('');
1270
+ reset?.();
1271
+ });
1272
+ }
1273
+ }
1274
+ },
1275
+ onMouseEnter: e => handleMouseEnter(e, cell.row.id, cell.column.id),
1276
+ onMouseUp: e => handleMouseUp(e),
1277
+ onKeyDown: e => {
1278
+ if (!isEditing) {
1279
+ handleKeyDown(e, cell.row.id, cell.column.id);
1280
+ } else {
1281
+ if (e.shiftKey && e.key === 'Enter') {
1282
+ e.preventDefault();
1283
+ e.stopPropagation();
1284
+ } else {
1285
+ if (e.key === 'Enter') {
1286
+ e.preventDefault();
1287
+ e.stopPropagation();
1288
+ const currentRowIndex = allRows.findIndex(r => r.id === cell.row.id);
1289
+ const nextRow = allRows[currentRowIndex + 1];
1290
+ if (nextRow) {
1291
+ setFocusedCell?.({
1292
+ rowId: nextRow.id,
1293
+ colId: cell.column.id
1294
+ });
1295
+ setStartCell?.({
1296
+ rowId: nextRow.id,
1297
+ colId: cell.column.id
1298
+ });
1299
+ setEndCell?.({
1300
+ rowId: nextRow.id,
1301
+ colId: cell.column.id
1302
+ });
1303
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
1304
+ rowId: nextRow.id,
1305
+ colId: cell.column.id
1306
+ }, {
1307
+ rowId: nextRow.id,
1308
+ colId: cell.column.id
1309
+ }));
1310
+ rowVirtualizer.scrollToIndex(nextRow.index, {
1311
+ align: 'center'
1312
+ });
1313
+ handleChange();
1314
+ } else {
1315
+ handleChangeAndCreateRow();
1316
+ }
1317
+ setEditingKey?.('');
1318
+ reset?.();
1319
+ }
1320
+ }
1321
+ }
1322
+ },
1323
+ onDoubleClick: e => {
1324
+ if (!canEdit) {
1325
+ e.stopPropagation();
1326
+ e.preventDefault();
1327
+ return;
1328
+ }
1329
+ if (!(record[rowKey] === editingKey && canEdit)) {
1330
+ handleEdit(e);
1331
+ }
1332
+ }
1333
+ }, isEditing && canEdit ? /*#__PURE__*/_react.default.createElement(_EditableCell.default, {
1334
+ cellEditing: {},
1335
+ column: cell.column.columnDef.meta,
1336
+ dataIndex: cell.column.id,
1337
+ editType: (0, _utils.getEditType)(cell.column.columnDef.meta, record),
1338
+ indexCol: cell.column.getIndex(),
1339
+ indexRow: cell.row.index,
1340
+ record: record
1341
+ // rowKey={rowKey}
1342
+ }) : /*#__PURE__*/_react.default.createElement("div", {
1343
+ className: (0, _classnames.default)('ui-rc_cell-content', {
1344
+ 'select-cell': ['select', 'selectTable', 'asyncSelect'].includes((0, _utils.getEditType)(columnMeta, record))
1345
+ })
1346
+ }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
1347
+ className: "ui-rc-table-row-expand-trigger",
1348
+ style: {
1349
+ paddingLeft: `${cell.row.depth * 25}px`
1350
+ }
1351
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
1352
+ // onClick: row.getToggleExpandedHandler(),
1353
+ onClick: e => {
1354
+ e.stopPropagation();
1355
+ e.preventDefault();
1356
+ const keys = Object.keys(expanded);
1357
+ // @ts-ignore
1358
+ const tmp = {
1359
+ ...expanded
1360
+ };
1361
+ if (keys.includes(cell.row.id)) {
1362
+ delete tmp[cell.row.id];
1363
+ setExpanded(tmp);
1364
+ } else {
1365
+ setExpanded(old => ({
1366
+ ...old,
1367
+ [cell.row.id]: true
1368
+ }));
1369
+ }
1370
+ },
1371
+ style: {
1372
+ cursor: "pointer"
1373
+ },
1374
+ className: "ui-rc-table-row-expand"
1375
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
1376
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
1377
+ }) : /*#__PURE__*/_react.default.createElement("span", {
1378
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
1379
+ })) : /*#__PURE__*/_react.default.createElement("span", {
1380
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
1381
+ }))), (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext()), (editType === 'select' || editType === 'selectTable' || editType === 'asyncSelect' || editType === 'treeSelect') && canEdit && /*#__PURE__*/_react.default.createElement("span", {
1382
+ className: 'caret-down',
1383
+ onClick: e => {
1384
+ handleEdit(e);
1385
+ // setEditingKey?.(cell.row.id)
1386
+ }
1387
+ })), !isSelecting && !isEditing && rowRange &&
1388
+ // rowNumber === rangeState?.endRowIndex &&
1389
+ cell.row.id === rowRange[rowRange?.length - 1] && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/_react.default.createElement("div", {
1390
+ className: 'dragging-point',
1391
+ onMouseDown: e => {
1392
+ e.preventDefault();
1393
+ e.stopPropagation();
1394
+ if (e.button === 0) {
1395
+ setIsPasting?.(true);
1396
+ }
1397
+ },
1398
+ onDoubleClick: handlePointDoubleClick
1399
+ }, /*#__PURE__*/_react.default.createElement("span", {
1400
+ className: 'dot-point'
1401
+ })), !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id && /*#__PURE__*/_react.default.createElement("span", {
1402
+ className: "isValid"
1403
+ }));
1404
+ };
1405
+ var _default = exports.default = TableBodyCellEdit;