es-grid-template 1.7.23 → 1.7.25

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 (163) hide show
  1. package/es/index.d.ts +1 -0
  2. package/es/index.js +3 -1
  3. package/es/table-component/ColumnsChoose.d.ts +13 -0
  4. package/es/table-component/ColumnsChoose.js +206 -0
  5. package/es/table-component/ContextMenu.d.ts +20 -0
  6. package/es/table-component/ContextMenu.js +75 -0
  7. package/es/table-component/InternalTable.d.ts +9 -0
  8. package/es/table-component/InternalTable.js +308 -0
  9. package/es/table-component/TableContainer.d.ts +31 -0
  10. package/es/table-component/TableContainer.js +249 -0
  11. package/es/table-component/TableContainerEdit.d.ts +31 -0
  12. package/es/table-component/TableContainerEdit.js +1301 -0
  13. package/es/table-component/body/EditableCell.d.ts +16 -0
  14. package/es/table-component/body/EditableCell.js +1039 -0
  15. package/es/table-component/body/TableBody.d.ts +19 -0
  16. package/es/table-component/body/TableBody.js +64 -0
  17. package/es/table-component/body/TableBodyCell.d.ts +12 -0
  18. package/es/table-component/body/TableBodyCell.js +149 -0
  19. package/es/table-component/body/TableBodyCellEdit.d.ts +16 -0
  20. package/es/table-component/body/TableBodyCellEdit.js +931 -0
  21. package/es/table-component/body/TableBodyRow.d.ts +21 -0
  22. package/es/table-component/body/TableBodyRow.js +151 -0
  23. package/es/table-component/components/ControlCheckbox.d.ts +13 -0
  24. package/es/table-component/components/ControlCheckbox.js +84 -0
  25. package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
  26. package/es/table-component/components/EditForm/EditForm.js +395 -0
  27. package/es/table-component/components/EditForm/index.d.ts +1 -0
  28. package/es/table-component/components/EditForm/index.js +1 -0
  29. package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
  30. package/es/table-component/components/InputControl/InputControl.js +121 -0
  31. package/es/table-component/components/InputControl/index.d.ts +1 -0
  32. package/es/table-component/components/InputControl/index.js +1 -0
  33. package/es/table-component/components/async-select/index.d.ts +11 -0
  34. package/es/table-component/components/async-select/index.js +41 -0
  35. package/es/table-component/components/async-table-select/index.d.ts +11 -0
  36. package/es/table-component/components/async-table-select/index.js +44 -0
  37. package/es/table-component/components/checkbox-control/index.d.ts +13 -0
  38. package/es/table-component/components/checkbox-control/index.js +40 -0
  39. package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  40. package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
  41. package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  42. package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
  43. package/es/table-component/components/command/Command.d.ts +10 -0
  44. package/es/table-component/components/command/Command.js +33 -0
  45. package/es/table-component/components/number/index.d.ts +10 -0
  46. package/es/table-component/components/number/index.js +42 -0
  47. package/es/table-component/components/number-range/index.d.ts +11 -0
  48. package/es/table-component/components/number-range/index.js +66 -0
  49. package/es/table-component/features/operator.d.ts +24 -0
  50. package/es/table-component/features/operator.js +62 -0
  51. package/es/table-component/footer/TableFooter.d.ts +13 -0
  52. package/es/table-component/footer/TableFooter.js +33 -0
  53. package/es/table-component/footer/TableFooterCell.d.ts +10 -0
  54. package/es/table-component/footer/TableFooterCell.js +66 -0
  55. package/es/table-component/footer/TableFooterRow.d.ts +14 -0
  56. package/es/table-component/footer/TableFooterRow.js +73 -0
  57. package/es/table-component/header/TableHead.d.ts +14 -0
  58. package/es/table-component/header/TableHead.js +60 -0
  59. package/es/table-component/header/TableHeadCell.d.ts +14 -0
  60. package/es/table-component/header/TableHeadCell.js +343 -0
  61. package/es/table-component/header/TableHeadRow.d.ts +16 -0
  62. package/es/table-component/header/TableHeadRow.js +76 -0
  63. package/es/table-component/header/renderFilter.d.ts +20 -0
  64. package/es/table-component/header/renderFilter.js +281 -0
  65. package/es/table-component/hook/constant.d.ts +73 -0
  66. package/es/table-component/hook/constant.js +240 -0
  67. package/es/table-component/hook/useColumns.d.ts +9 -0
  68. package/es/table-component/hook/useColumns.js +169 -0
  69. package/es/table-component/hook/useFilterOperator.d.ts +7 -0
  70. package/es/table-component/hook/useFilterOperator.js +33 -0
  71. package/es/table-component/hook/utils.d.ts +133 -0
  72. package/es/table-component/hook/utils.js +1870 -0
  73. package/es/table-component/index.d.ts +5 -0
  74. package/es/table-component/index.js +2 -0
  75. package/es/table-component/style.scss +1129 -0
  76. package/es/table-component/table/Grid.d.ts +24 -0
  77. package/es/table-component/table/Grid.js +234 -0
  78. package/es/table-component/type.d.ts +513 -0
  79. package/es/table-component/type.js +1 -0
  80. package/es/table-component/useContext.d.ts +74 -0
  81. package/es/table-component/useContext.js +15 -0
  82. package/lib/index.d.ts +1 -0
  83. package/lib/index.js +8 -1
  84. package/lib/table-component/ColumnsChoose.d.ts +13 -0
  85. package/lib/table-component/ColumnsChoose.js +216 -0
  86. package/lib/table-component/ContextMenu.d.ts +20 -0
  87. package/lib/table-component/ContextMenu.js +85 -0
  88. package/lib/table-component/InternalTable.d.ts +9 -0
  89. package/lib/table-component/InternalTable.js +313 -0
  90. package/lib/table-component/TableContainer.d.ts +31 -0
  91. package/lib/table-component/TableContainer.js +257 -0
  92. package/lib/table-component/TableContainerEdit.d.ts +31 -0
  93. package/lib/table-component/TableContainerEdit.js +1310 -0
  94. package/lib/table-component/body/EditableCell.d.ts +16 -0
  95. package/lib/table-component/body/EditableCell.js +1041 -0
  96. package/lib/table-component/body/TableBody.d.ts +19 -0
  97. package/lib/table-component/body/TableBody.js +72 -0
  98. package/lib/table-component/body/TableBodyCell.d.ts +12 -0
  99. package/lib/table-component/body/TableBodyCell.js +158 -0
  100. package/lib/table-component/body/TableBodyCellEdit.d.ts +16 -0
  101. package/lib/table-component/body/TableBodyCellEdit.js +938 -0
  102. package/lib/table-component/body/TableBodyRow.d.ts +21 -0
  103. package/lib/table-component/body/TableBodyRow.js +158 -0
  104. package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
  105. package/lib/table-component/components/ControlCheckbox.js +92 -0
  106. package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
  107. package/lib/table-component/components/EditForm/EditForm.js +406 -0
  108. package/lib/table-component/components/EditForm/index.d.ts +1 -0
  109. package/lib/table-component/components/EditForm/index.js +16 -0
  110. package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
  111. package/lib/table-component/components/InputControl/InputControl.js +131 -0
  112. package/lib/table-component/components/InputControl/index.d.ts +1 -0
  113. package/lib/table-component/components/InputControl/index.js +16 -0
  114. package/lib/table-component/components/async-select/index.d.ts +11 -0
  115. package/lib/table-component/components/async-select/index.js +49 -0
  116. package/lib/table-component/components/async-table-select/index.d.ts +11 -0
  117. package/lib/table-component/components/async-table-select/index.js +53 -0
  118. package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
  119. package/lib/table-component/components/checkbox-control/index.js +48 -0
  120. package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  121. package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
  122. package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  123. package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
  124. package/lib/table-component/components/command/Command.d.ts +10 -0
  125. package/lib/table-component/components/command/Command.js +42 -0
  126. package/lib/table-component/components/number/index.d.ts +10 -0
  127. package/lib/table-component/components/number/index.js +50 -0
  128. package/lib/table-component/components/number-range/index.d.ts +11 -0
  129. package/lib/table-component/components/number-range/index.js +74 -0
  130. package/lib/table-component/features/operator.d.ts +24 -0
  131. package/lib/table-component/features/operator.js +67 -0
  132. package/lib/table-component/footer/TableFooter.d.ts +13 -0
  133. package/lib/table-component/footer/TableFooter.js +42 -0
  134. package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
  135. package/lib/table-component/footer/TableFooterCell.js +76 -0
  136. package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
  137. package/lib/table-component/footer/TableFooterRow.js +81 -0
  138. package/lib/table-component/header/TableHead.d.ts +14 -0
  139. package/lib/table-component/header/TableHead.js +69 -0
  140. package/lib/table-component/header/TableHeadCell.d.ts +14 -0
  141. package/lib/table-component/header/TableHeadCell.js +352 -0
  142. package/lib/table-component/header/TableHeadRow.d.ts +16 -0
  143. package/lib/table-component/header/TableHeadRow.js +84 -0
  144. package/lib/table-component/header/renderFilter.d.ts +20 -0
  145. package/lib/table-component/header/renderFilter.js +291 -0
  146. package/lib/table-component/hook/constant.d.ts +73 -0
  147. package/lib/table-component/hook/constant.js +247 -0
  148. package/lib/table-component/hook/useColumns.d.ts +9 -0
  149. package/lib/table-component/hook/useColumns.js +180 -0
  150. package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
  151. package/lib/table-component/hook/useFilterOperator.js +40 -0
  152. package/lib/table-component/hook/utils.d.ts +133 -0
  153. package/lib/table-component/hook/utils.js +1969 -0
  154. package/lib/table-component/index.d.ts +5 -0
  155. package/lib/table-component/index.js +9 -0
  156. package/lib/table-component/style.scss +1129 -0
  157. package/lib/table-component/table/Grid.d.ts +24 -0
  158. package/lib/table-component/table/Grid.js +236 -0
  159. package/lib/table-component/type.d.ts +513 -0
  160. package/lib/table-component/type.js +5 -0
  161. package/lib/table-component/useContext.d.ts +74 -0
  162. package/lib/table-component/useContext.js +21 -0
  163. package/package.json +4 -2
@@ -0,0 +1,938 @@
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 _utils = require("../hook/utils");
12
+ var _Checkbox = _interopRequireDefault(require("rc-master-ui/lib/checkbox/Checkbox"));
13
+ var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _useContext = require("../useContext");
16
+ var _EditableCell = _interopRequireDefault(require("./EditableCell"));
17
+ var _constant = require("../hook/constant");
18
+ // import ReactDOMServer from 'react-dom/server'
19
+
20
+ // import { nonActionColumn } from "../hook/constant";
21
+
22
+ // import type { Dispatch, SetStateAction } from "react";
23
+
24
+ // import { nonActionColumn } from "../hook/constant";
25
+
26
+ const renderCellIndex = props => {
27
+ const {
28
+ parrents,
29
+ cell
30
+ } = props;
31
+ return /*#__PURE__*/_react.default.createElement("span", null, parrents.map(pr => {
32
+ return `${pr.index + 1}.`;
33
+ }), cell.row.index + 1);
34
+ };
35
+ const renderCommand = args => {
36
+ const {
37
+ cell,
38
+ commandClick,
39
+ id
40
+ } = args;
41
+ const col = cell.column.columnDef.meta ?? {};
42
+ const record = cell.row.original;
43
+
44
+ // const commandItems = args.cell.column.columnDef?.meta?.commandItems ?? []
45
+
46
+ const commands = col.commandItems ? col.commandItems.map(it => {
47
+ return {
48
+ ...it,
49
+ visible: typeof it.visible === 'function' ? it.visible?.(record) : it.visible
50
+ };
51
+ }) : [];
52
+ return /*#__PURE__*/_react.default.createElement(_space.default, null, commands.filter(it => it.visible !== false).map(item => {
53
+ return /*#__PURE__*/_react.default.createElement(_Command.default, {
54
+ id: id,
55
+ key: item.id,
56
+ item: item,
57
+ record: record,
58
+ onClick: () => {
59
+ commandClick?.({
60
+ id: item.id,
61
+ // rowId: getRowKey(record, index) as any,
62
+ rowId: record.rowId,
63
+ rowData: record,
64
+ index: cell.row.index
65
+ // rows: [...resource]
66
+ });
67
+ }
68
+ });
69
+ }));
70
+ };
71
+ const renderSelection = args => {
72
+ const {
73
+ row
74
+ } = args.cell;
75
+ return /*#__PURE__*/_react.default.createElement("div", {
76
+ style: {
77
+
78
+ // paddingLeft: `${row.depth * 2}rem`,
79
+ }
80
+ }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
81
+ checked: row.getIsSelected(),
82
+ indeterminate: row.getIsSomeSelected(),
83
+ onChange: row.getToggleSelectedHandler()
84
+ })));
85
+ };
86
+ const TableBodyCellEdit = props => {
87
+ const {
88
+ cell,
89
+ commandClick,
90
+ // tableId,
91
+ table,
92
+ isEditing,
93
+ columnVirtualizer,
94
+ rowVirtualizer
95
+ // virtualRow
96
+ } = props;
97
+ const {
98
+ id,
99
+ rowKey,
100
+ editingKey,
101
+ prefix,
102
+ focusedCell,
103
+ rangeState,
104
+ setFocusedCell,
105
+ setEditingKey,
106
+ setRangeState,
107
+ setRangePasteState,
108
+ endCell,
109
+ setEndCell,
110
+ isSelecting,
111
+ isPasting,
112
+ setEndPasteCell,
113
+ endPasteCell,
114
+ setIsPasting,
115
+ setIsSelecting,
116
+ setStartCell,
117
+ setStartPasteCell,
118
+ startCell,
119
+ startPasteCell,
120
+ originData,
121
+ dataSource,
122
+ triggerPaste,
123
+ handleDeleteContent,
124
+ reset,
125
+ setValue,
126
+ handleAddMulti,
127
+ dataErrors,
128
+ expanded,
129
+ setExpanded,
130
+ expandable
131
+ } = _react.default.useContext(_useContext.TableContext);
132
+ const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
133
+ const record = cell.row.original;
134
+ const columnMeta = cell.column.columnDef.meta ?? {};
135
+
136
+ // const cellContent = columnMeta.type === 'checkbox' ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
137
+ // const html = ReactDOMServer.renderToStaticMarkup(<>{cellContent}</>);
138
+ // const hasValue = html.trim().length > 0;
139
+
140
+ const rowError = dataErrors ? dataErrors.find(it => it.id === cell.row.id) : undefined;
141
+ // const message = rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : undefined
142
+
143
+ const canEdit = (0, _utils.isEditable)(cell.column.columnDef.meta, record);
144
+ // const allRows = table.getRowModel().rows;
145
+ const allRows = table.getRowModel().flatRows;
146
+
147
+ // const rowNumber = virtualRow.index
148
+ const rowNumber = allRows.findIndex(it => it.id === cell.row.id);
149
+ const colIndex = cell.column.getIndex();
150
+ const isPinned = cell.column.getIsPinned();
151
+ const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
152
+ const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
153
+ const isCellSelected = _react.default.useMemo(() => {
154
+ if (!startCell || !endCell) return false;
155
+ const rowIds = (0, _utils.getRowIdsBetween)(table, startCell.rowId, endCell.rowId);
156
+ const colIds = (0, _utils.getColIdsBetween)(table, startCell.colId, endCell.colId);
157
+ return rowIds.includes(cell.row.id) && colIds.includes(cell.column.id);
158
+ }, [cell.column.id, cell.row.id, endCell, startCell, table]);
159
+ const editType = typeof columnMeta.editType === 'function' ? columnMeta.editType(record) : columnMeta.editType;
160
+ const {
161
+ rowRange,
162
+ colRange,
163
+ rowIds,
164
+ colIds,
165
+ startColIndex,
166
+ startRowIndex,
167
+ endColIndex,
168
+ endRowIndex
169
+ } = rangeState ?? {};
170
+ const pasteRangeState = (0, _utils.getSelectedCellMatrix)(table, startPasteCell, endPasteCell);
171
+ const isInRange = colRange && rowRange && rowRange.includes(cell.row.id) && colRange.includes(cell.column.id);
172
+ const isInRangePaste = pasteRangeState.rowRange && pasteRangeState.rowRange.includes(cell.row.id) && pasteRangeState.colRange.includes(cell.column.id);
173
+
174
+ // const isInRangePaste = rowRange && rowRange.includes(cell.row.id) && colRange.includes(cell.column.id);
175
+
176
+ const rowIdx = rowIds ? rowIds.indexOf(cell.row.id) : -1;
177
+ const colIdx = colIds ? colIds.indexOf(cell.column.id) : -1;
178
+ const rowIdxPaste = pasteRangeState.rowIds.indexOf(cell.row.id);
179
+ const colIdxPaste = pasteRangeState.colIds.indexOf(cell.column.id);
180
+ const isTop = rowIdx === startRowIndex;
181
+ const isBottom = rowIdx === endRowIndex;
182
+ const isLeft = colIdx === startColIndex;
183
+ const isRight = colIdx === endColIndex;
184
+ const isTopPaste = rowIdxPaste === pasteRangeState.startRowIndex;
185
+ const isBottomPaste = rowIdxPaste === pasteRangeState.endRowIndex;
186
+ const isLeftPaste = colIdxPaste === pasteRangeState.startColIndex;
187
+ const isRightPaste = colIdxPaste === pasteRangeState.endColIndex;
188
+ const parrents = cell.row.getParentRows();
189
+ if (cell.column.id === "#") {
190
+ return /*#__PURE__*/_react.default.createElement("td", {
191
+ key: cell.id,
192
+ className: (0, _classnames.default)(`${prefix}-grid-cell`, {
193
+ [`${prefix}-grid-cell-ellipsis`]: true,
194
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
195
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
196
+ }),
197
+ style: {
198
+ display: 'flex',
199
+ height: '36px',
200
+ width: cell.column.getSize(),
201
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
202
+ }
203
+ }, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
204
+ className: "ui-rc-table-row-expand-trigger",
205
+ style: {
206
+ paddingLeft: `${cell.row.depth * 25}px`
207
+ }
208
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
209
+ // onClick: row.getToggleExpandedHandler(),
210
+ onClick: () => {
211
+ const keys = Object.keys(expanded);
212
+ // @ts-ignore
213
+ const tmp = {
214
+ ...expanded
215
+ };
216
+ if (keys.includes(cell.row.id)) {
217
+ delete tmp[cell.row.id];
218
+ setExpanded(tmp);
219
+ } else {
220
+ setExpanded(old => ({
221
+ ...old,
222
+ [cell.row.id]: true
223
+ }));
224
+ }
225
+ },
226
+ style: {
227
+ cursor: "pointer"
228
+ },
229
+ className: "ui-rc-table-row-expand"
230
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
231
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
232
+ }) : /*#__PURE__*/_react.default.createElement("span", {
233
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
234
+ })) : /*#__PURE__*/_react.default.createElement("span", {
235
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
236
+ }))), renderCellIndex({
237
+ parrents,
238
+ cell
239
+ }));
240
+ }
241
+ if (cell.column.id === "command") {
242
+ return /*#__PURE__*/_react.default.createElement("td", {
243
+ key: cell.id,
244
+ className: (0, _classnames.default)(`${prefix}-grid-cell`, {
245
+ [`${prefix}-grid-cell-ellipsis`]: true,
246
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
247
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
248
+ }),
249
+ style: {
250
+ display: 'flex',
251
+ height: '36px',
252
+ width: cell.column.getSize(),
253
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
254
+ }
255
+ }, renderCommand({
256
+ cell,
257
+ commandClick,
258
+ id
259
+ }));
260
+ }
261
+ if (cell.column.id === "selection_column") {
262
+ return /*#__PURE__*/_react.default.createElement("td", {
263
+ key: cell.id,
264
+ className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable111 `, {
265
+ [`${prefix}-grid-cell-ellipsis`]: true,
266
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
267
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
268
+ }),
269
+ style: {
270
+ display: 'flex',
271
+ height: '36px',
272
+ width: cell.column.getSize(),
273
+ ...(0, _utils.getCommonPinningStyles)(cell.column)
274
+ }
275
+ }, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
276
+ className: "ui-rc-table-row-expand-trigger",
277
+ style: {
278
+ paddingLeft: `${cell.row.depth * 25}px`
279
+ }
280
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
281
+ // onClick: row.getToggleExpandedHandler(),
282
+ onClick: () => {
283
+ const keys = Object.keys(expanded);
284
+ // @ts-ignore
285
+ const tmp = {
286
+ ...expanded
287
+ };
288
+ if (keys.includes(cell.row.id)) {
289
+ delete tmp[cell.row.id];
290
+ setExpanded(tmp);
291
+ } else {
292
+ setExpanded(old => ({
293
+ ...old,
294
+ [cell.row.id]: true
295
+ }));
296
+ }
297
+ },
298
+ style: {
299
+ cursor: "pointer"
300
+ },
301
+ className: "ui-rc-table-row-expand"
302
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
303
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
304
+ }) : /*#__PURE__*/_react.default.createElement("span", {
305
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
306
+ })) : /*#__PURE__*/_react.default.createElement("span", {
307
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
308
+ }))), renderSelection({
309
+ cell
310
+ }));
311
+ }
312
+ const triggerDragPaste = (pasteState, ctrlKey) => {
313
+ const tmpCols = table.getVisibleLeafColumns();
314
+ const rowPasteIds = (0, _utils.getRowIdsBetween)(table, startPasteCell?.rowId ?? '', endPasteCell?.rowId ?? '');
315
+ const colPasteds = (0, _utils.getColIdsBetween)(table, startPasteCell?.colId ?? '', endPasteCell?.colId ?? '');
316
+ const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
317
+ const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
318
+ const dataSelected = [];
319
+ rowSelectIds.forEach(rowId => {
320
+ const row = allRows.find(r => r.id === rowId);
321
+ if (!row) return;
322
+ const rowData = [];
323
+ colSelectIds.forEach(colId => {
324
+ const cellll = row.getVisibleCells().find(c => c.column.id === colId);
325
+ const value = cellll?.getValue();
326
+ rowData.push(value !== undefined ? String(value) : '');
327
+ });
328
+ dataSelected.push(rowData);
329
+ });
330
+ const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
331
+ let newRange;
332
+ if ((startRowIndex ?? 0) < (pasteRangeState.startRowIndex ?? 0)) {
333
+ // kéo xuóng
334
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, startCell, endPasteCell));
335
+ newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
336
+ } else {
337
+ // kéo lên
338
+ setStartCell?.(endCell);
339
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, endCell, endPasteCell));
340
+ newRange = ctrlKey ? (0, _utils.addRowsUpWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsUp)(dataSelected, rowPasteIds.length);
341
+ }
342
+
343
+ // Cập nhật data mới
344
+ const newData = (0, _utils.flattenArray)([...dataSource]);
345
+ const pastedRows = [];
346
+ newRange.addedRows.forEach((rowValues, rowIndex1) => {
347
+ const targetRow = pasteState.startRowIndex + rowIndex1;
348
+
349
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
350
+ if (targetRow >= newData.length) {
351
+ newData.push({
352
+ id: undefined,
353
+ rowId: (0, _utils.newGuid)()
354
+ });
355
+ }
356
+ rowValues.forEach((cellValue, colIndex1) => {
357
+ const targetCol = startColIndex + colIndex1;
358
+ if (targetCol >= tmpCols.length) {
359
+ // Không vượt quá số cột
360
+ return;
361
+ }
362
+ const columnKey = tmpCols[targetCol].id;
363
+ const disable = !(0, _utils.isEditable)(tmpCols[targetCol].columnDef.meta, record);
364
+ if (!disable) {
365
+ newData[targetRow] = {
366
+ ...newData[targetRow],
367
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
368
+ };
369
+ }
370
+ });
371
+
372
+ // Lưu dòng được paste
373
+ pastedRows.push(newData[targetRow]);
374
+ });
375
+ const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), newData);
376
+ const rs = (0, _utils.unFlattenData)(rsFilterData);
377
+ triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
378
+
379
+ // // setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell))
380
+
381
+ setEndCell?.(endPasteCell);
382
+ setEndPasteCell?.(undefined);
383
+ setStartPasteCell?.(undefined);
384
+ setRangePasteState?.(undefined);
385
+ };
386
+ const triggerPointPaste = (pasteState, cellStart, cellEnd, ctrlKey) => {
387
+ const tmpCols = table.getVisibleLeafColumns();
388
+ const rowPasteIds = (0, _utils.getRowIdsBetween)(table, cellStart?.rowId ?? '', cellEnd?.rowId ?? '');
389
+ const colPasteds = (0, _utils.getColIdsBetween)(table, cellStart?.colId ?? '', cellEnd?.colId ?? '');
390
+ const rowSelectIds = (0, _utils.getRowIdsBetween)(table, startCell?.rowId ?? '', endCell?.rowId ?? '');
391
+ const colSelectIds = (0, _utils.getColIdsBetween)(table, startCell?.colId ?? '', endCell?.colId ?? '');
392
+ const dataSelected = [];
393
+ rowSelectIds.forEach(rowId => {
394
+ const row = allRows.find(r => r.id === rowId);
395
+ if (!row) return;
396
+ const rowData = [];
397
+ colSelectIds.forEach(colId => {
398
+ const cellll = row.getVisibleCells().find(c => c.column.id === colId);
399
+ const value = cellll?.getValue();
400
+ rowData.push(value !== undefined ? String(value) : '');
401
+ });
402
+ dataSelected.push(rowData);
403
+ });
404
+ const copyRows = (0, _utils.flattenData)('children', dataSource).filter(it => rowSelectIds.includes(it[rowKey]));
405
+
406
+ // kéo xuóng
407
+ // setRangeState?.(getSelectedCellMatrix(table, startCell, endPasteCell))
408
+ const newRange = ctrlKey ? (0, _utils.addRowsDownWithCtrl)(dataSelected, rowPasteIds.length) : (0, _utils.addRowsDown)(dataSelected, rowPasteIds.length);
409
+
410
+ // Cập nhật data mới
411
+ const newData = (0, _utils.flattenArray)([...dataSource]);
412
+ const pastedRows = [];
413
+ newRange.addedRows.forEach((rowValues, rowIndex1) => {
414
+ const targetRow = pasteState.startRowIndex + rowIndex1;
415
+
416
+ // Nếu vượt quá số dòng hiện có, thêm dòng mới
417
+ if (targetRow >= newData.length) {
418
+ newData.push({
419
+ id: undefined,
420
+ rowId: (0, _utils.newGuid)()
421
+ });
422
+ }
423
+ rowValues.forEach((cellValue, colIndex1) => {
424
+ const targetCol = startColIndex + colIndex1;
425
+ if (targetCol >= tmpCols.length) {
426
+ // Không vượt quá số cột
427
+ return;
428
+ }
429
+ const columnKey = tmpCols[targetCol].id;
430
+ newData[targetRow] = {
431
+ ...newData[targetRow],
432
+ [columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
433
+ };
434
+ });
435
+
436
+ // Lưu dòng được paste
437
+ pastedRows.push(newData[targetRow]);
438
+ });
439
+ const rsFilterData = (0, _utils.updateOrInsert)((0, _utils.flattenArray)([...originData]), newData);
440
+ const rs = (0, _utils.unFlattenData)(rsFilterData);
441
+ triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
442
+ };
443
+ function handleMouseDown(rowId, colId) {
444
+ setIsSelecting?.(true);
445
+ if (startCell?.rowId !== rowId || startCell?.colId !== colId || endCell?.rowId !== rowId || endCell?.colId !== colId) {
446
+ setStartCell?.({
447
+ rowId,
448
+ colId
449
+ });
450
+ setEndCell?.({
451
+ rowId,
452
+ colId
453
+ });
454
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
455
+ rowId,
456
+ colId
457
+ }, {
458
+ rowId,
459
+ colId
460
+ }));
461
+ }
462
+ if (focusedCell?.rowId !== cell.row.id || focusedCell?.colId !== cell.column.id) {
463
+ setFocusedCell?.({
464
+ rowId: cell.row.id,
465
+ colId: cell.column.id
466
+ });
467
+ }
468
+ }
469
+ function handleMouseEnter(rowId, colId) {
470
+ if (isSelecting) {
471
+ setEndCell?.({
472
+ rowId,
473
+ colId
474
+ });
475
+ }
476
+ if (isPasting) {
477
+ const absRowIndex = table.getRowModel().flatRows.findIndex(it => it.id === cell.row.id);
478
+ if ((startRowIndex ?? 0) > absRowIndex) {
479
+ // kéo lên
480
+
481
+ const startRowPaste = allRows.find(it => it.index === (startRowIndex ?? 0) - 1);
482
+ setStartPasteCell?.({
483
+ colId: startCell?.colId ?? '',
484
+ rowId: startRowPaste?.id ?? ''
485
+ });
486
+ setEndPasteCell?.({
487
+ colId: endCell?.colId ?? '',
488
+ rowId
489
+ });
490
+ setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, {
491
+ colId: startCell?.colId ?? '',
492
+ rowId: startRowPaste?.id ?? ''
493
+ }, {
494
+ colId: endCell?.colId ?? '',
495
+ rowId
496
+ }));
497
+ }
498
+ if ((startRowIndex ?? 0) < absRowIndex) {
499
+ // kéo xuống
500
+
501
+ const findIndex = allRows.findIndex(it => it.id === endCell?.rowId);
502
+ const startRowPaste = allRows[findIndex + 1];
503
+ setStartPasteCell?.({
504
+ colId: startCell?.colId ?? '',
505
+ rowId: startRowPaste?.id ?? ''
506
+ });
507
+ setEndPasteCell?.({
508
+ colId: endCell?.colId ?? '',
509
+ rowId
510
+ });
511
+ setRangePasteState?.((0, _utils.getSelectedCellMatrix)(table, {
512
+ colId: startCell?.colId ?? '',
513
+ rowId: startRowPaste?.id ?? ''
514
+ }, {
515
+ colId: endCell?.colId ?? '',
516
+ rowId
517
+ }));
518
+ }
519
+ }
520
+ }
521
+ const handlePointDoubleClick = e => {
522
+ e.preventDefault();
523
+ e.stopPropagation();
524
+ const rowEnd = table.getRowModel().flatRows[table.getRowModel().flatRows.length - 1];
525
+ const cellEnd = {
526
+ rowId: rowEnd.id,
527
+ colId: cell.column.id
528
+ };
529
+ const currentRowId = allRows.findIndex(it => it.id === cell.row.id);
530
+ const pasteStartRow = allRows[currentRowId + 1];
531
+ const cellStart = {
532
+ rowId: pasteStartRow.id,
533
+ colId: endCell?.colId ?? ''
534
+ };
535
+ const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, cellEnd);
536
+ const selectPasteState = (0, _utils.getSelectedCellMatrix)(table, cellStart, cellEnd);
537
+ setRangeState?.(selectState);
538
+ setEndCell?.(cellEnd);
539
+ triggerPointPaste(selectPasteState, cellStart, cellEnd, e.ctrlKey);
540
+ };
541
+ function handleMouseUp(e) {
542
+ setIsSelecting?.(false);
543
+ setIsPasting?.(false);
544
+ const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, endCell);
545
+ const selectPasteState = (0, _utils.getSelectedCellMatrix)(table, startPasteCell, endPasteCell);
546
+ if (endPasteCell && endCell?.rowId !== endPasteCell?.rowId && isPasting) {
547
+ triggerDragPaste(selectPasteState, e.ctrlKey);
548
+ } else {
549
+ // if ( endCell?.rowId !== rowId || endCell?.colId !== colId) {
550
+ // setRangeState?.(selectState)
551
+ // }
552
+
553
+ if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
554
+ setRangeState?.(selectState);
555
+ }
556
+ }
557
+
558
+ // setRangePasteState(selectPasteState)
559
+ }
560
+ const handleEdit = e => {
561
+ setEditingKey?.(record[rowKey]);
562
+ // setTooltipContent('')
563
+
564
+ reset?.();
565
+
566
+ // const formattedRecord = { ...record };
567
+
568
+ if (!(0, _utils.isObjEmpty)(record)) {
569
+ Object.entries(record).forEach(([name, value]) => {
570
+ setValue?.(name, value);
571
+ });
572
+ }
573
+ if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
574
+ setValue(columnMeta.field, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
575
+ }
576
+ if (editType === 'select') {
577
+
578
+ // setSearchValue(e.key)
579
+ // setOpen(true)
580
+ }
581
+ if (focusedCell?.rowId) {
582
+ setTimeout(() => {
583
+ // 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
584
+ // 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
585
+ const textarea = document.querySelector(`.ui-rc-grid-row .cell-editing[data-row-key="${focusedCell.rowId}"].cell-editing[data-col-key="${focusedCell.colId}"] textarea`);
586
+ // const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells.current.col}"] .ant-select-selection-search input`)
587
+
588
+ if (textarea) {
589
+ textarea.focus();
590
+ textarea.setSelectionRange(textarea.value.length, textarea.value.length);
591
+ }
592
+ // if (input) {
593
+ // input.focus()
594
+ // }
595
+
596
+ // if (select) {
597
+ // // @ts-ignore
598
+ // select.searchValue = e.key
599
+ // // @ts-ignore
600
+ // select.focus()
601
+ // }
602
+ }, 10);
603
+ }
604
+ };
605
+ function handleKeyDown(e, rowId, colId) {
606
+ if (e.key === 'Tab') {
607
+ e.preventDefault();
608
+ const allCols = table.getVisibleLeafColumns();
609
+ const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
610
+ const nextCol = allCols[currentColIndex + 1];
611
+ if (nextCol) {
612
+ setFocusedCell?.({
613
+ rowId,
614
+ colId: nextCol.id
615
+ });
616
+ setStartCell?.({
617
+ rowId,
618
+ colId: nextCol.id
619
+ });
620
+ setEndCell?.({
621
+ rowId,
622
+ colId: nextCol.id
623
+ });
624
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
625
+ rowId,
626
+ colId: nextCol.id
627
+ }, {
628
+ rowId,
629
+ colId: nextCol.id
630
+ }));
631
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
632
+ align: 'center'
633
+ });
634
+ } else {
635
+ // Nếu là cột cuối cùng, có thể nhảy xuống dòng tiếp theo
636
+
637
+ const currentRowIndex = allRows.findIndex(r => r.id === rowId);
638
+ const nextRow = allRows[currentRowIndex + 1];
639
+ const nextRowCol = allCols[2];
640
+ if (nextRow) {
641
+ setFocusedCell?.({
642
+ rowId: nextRow.id,
643
+ colId: nextRowCol.id
644
+ }); // sang dòng, cột đầu
645
+
646
+ setStartCell?.({
647
+ rowId: nextRow.id,
648
+ colId: nextRowCol.id
649
+ });
650
+ setEndCell?.({
651
+ rowId: nextRow.id,
652
+ colId: nextRowCol.id
653
+ });
654
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
655
+ rowId: nextRow.id,
656
+ colId: nextRowCol.id
657
+ }, {
658
+ rowId: nextRow.id,
659
+ colId: nextRowCol.id
660
+ }));
661
+ columnVirtualizer.scrollToIndex(nextRowCol.getIndex());
662
+ rowVirtualizer.scrollToIndex(nextRow.index, {
663
+ align: 'auto'
664
+ });
665
+ }
666
+ }
667
+ }
668
+ if (e.key === 'ArrowRight') {
669
+ e.preventDefault();
670
+ e.stopPropagation();
671
+ const allCols = table.getVisibleLeafColumns().filter(it => !_constant.nonActionColumn.includes(it.id));
672
+ const currentColIndex = allCols.findIndex(it => it.id === cell.column.id);
673
+ const nextCol = allCols[currentColIndex + 1];
674
+ if (nextCol) {
675
+ setFocusedCell?.({
676
+ rowId,
677
+ colId: nextCol.id
678
+ });
679
+ setStartCell?.({
680
+ rowId,
681
+ colId: nextCol.id
682
+ });
683
+ setEndCell?.({
684
+ rowId,
685
+ colId: nextCol.id
686
+ });
687
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
688
+ rowId,
689
+ colId: nextCol.id
690
+ }, {
691
+ rowId,
692
+ colId: nextCol.id
693
+ }));
694
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
695
+ align: 'center'
696
+ });
697
+ }
698
+ }
699
+ if (e.key === 'ArrowLeft') {
700
+ e.preventDefault();
701
+ const allCols = table.getVisibleLeafColumns().filter(it => !_constant.nonActionColumn.includes(it.id));
702
+
703
+ // const currentColIndex = table.getColumn(colId)?.getIndex() ?? 0;
704
+ const currentColIndex = allCols.findIndex(it => it.id === cell.column.id);
705
+ const nextCol = allCols[currentColIndex - 1];
706
+ if (nextCol) {
707
+ setFocusedCell?.({
708
+ rowId,
709
+ colId: nextCol.id
710
+ });
711
+ setStartCell?.({
712
+ rowId,
713
+ colId: nextCol.id
714
+ });
715
+ setEndCell?.({
716
+ rowId,
717
+ colId: nextCol.id
718
+ });
719
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
720
+ rowId,
721
+ colId: nextCol.id
722
+ }, {
723
+ rowId,
724
+ colId: nextCol.id
725
+ }));
726
+ columnVirtualizer.scrollToIndex(nextCol.getIndex(), {
727
+ align: 'center'
728
+ });
729
+ }
730
+ }
731
+ if (e.key === 'Delete') {
732
+ handleDeleteContent?.();
733
+ }
734
+ if (e.key === 'Enter') {
735
+ handleEdit(e);
736
+ }
737
+ }
738
+ return /*#__PURE__*/_react.default.createElement("td", {
739
+ key: cell.id,
740
+ ref: el => {
741
+ if (focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id && !isEditing) {
742
+ el?.focus();
743
+ }
744
+ },
745
+ tabIndex: focusedCell?.rowId === cell.row.id && focusedCell?.colId === cell.column.id ? 0 : -1,
746
+ "data-col-index": colIndex,
747
+ "data-row-index": rowNumber,
748
+ "data-col-key": cell.column.id,
749
+ "data-row-key": cell.row.id
750
+ // data-tooltip-id={`${id}-tooltip-content`}
751
+ // data-tooltip-html={!isEditing && !hasValue && !message ? undefined : ReactDOMServer.renderToStaticMarkup(<>{rowError && rowError[cell.column.id]?.field === cell.column.id ? rowError[cell.column.id].message : cellContent}</>)}
752
+ ,
753
+
754
+ className: (0, _classnames.default)(`${prefix}-grid-cell cell-editable `, {
755
+ [`${prefix}-grid-cell-ellipsis`]: true,
756
+ 'cell-editing': isEditing,
757
+ disable: !(0, _utils.isEditable)(cell.column.columnDef.meta, record),
758
+ isValid: !isEditing && rowError && rowError[cell.column.id]?.field === cell.column.id,
759
+ [`${prefix}-grid-cell-selected`]: isCellSelected,
760
+ 'cell-border-bottom': !isEditing && isInRange && isBottom,
761
+ 'cell-border-right': !isEditing && isInRange && isRight,
762
+ 'cell-border-top': !isEditing && isInRange && isTop,
763
+ 'cell-border-left': !isEditing && isInRange && isLeft,
764
+ 'cell-paste-border-bottom': isInRangePaste && isBottomPaste && (pasteRangeState.endRowIndex ?? 0) > (endRowIndex ?? 0),
765
+ 'cell-paste-border-right': isInRangePaste && isRightPaste,
766
+ 'cell-paste-border-top': isInRangePaste && isTopPaste && (pasteRangeState.endRowIndex ?? 0) < (endRowIndex ?? 0),
767
+ 'cell-paste-border-left': isInRangePaste && isLeftPaste,
768
+ [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
769
+ [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
770
+ }),
771
+ style: {
772
+ display: 'flex',
773
+ width: cell.column.getSize(),
774
+ height: '36px',
775
+ ...(0, _utils.getCommonPinningStyles)(cell.column),
776
+ cursor: isPasting ? 'crosshair' : undefined
777
+ },
778
+ onMouseDown: () => {
779
+ if (record[rowKey] === editingKey) {
780
+ setFocusedCell?.({
781
+ rowId: cell.row.id,
782
+ colId: cell.column.id
783
+ });
784
+ } else {
785
+ handleMouseDown(cell.row.id, cell.column.id);
786
+ }
787
+ if (record[rowKey] !== editingKey) {
788
+ setTimeout(() => {
789
+ setEditingKey?.('');
790
+ reset?.();
791
+ });
792
+ }
793
+ },
794
+ onMouseEnter: () => handleMouseEnter(cell.row.id, cell.column.id),
795
+ onMouseUp: e => handleMouseUp(e),
796
+ onKeyDown: e => {
797
+ if (!isEditing) {
798
+ handleKeyDown(e, cell.row.id, cell.column.id);
799
+ } else {
800
+ // setStartCell?.(undefined)
801
+
802
+ if (e.shiftKey && e.key === 'Enter') {} else {
803
+ if (e.key === 'Enter') {
804
+ e.preventDefault();
805
+ e.stopPropagation();
806
+ setEditingKey?.('');
807
+ reset?.();
808
+ const currentRowIndex = allRows.findIndex(r => r.id === cell.row.id);
809
+ const nextRow = allRows[currentRowIndex + 1];
810
+ if (nextRow) {
811
+ setFocusedCell?.({
812
+ rowId: nextRow.id,
813
+ colId: cell.column.id
814
+ });
815
+ setStartCell?.({
816
+ rowId: nextRow.id,
817
+ colId: cell.column.id
818
+ });
819
+ setEndCell?.({
820
+ rowId: nextRow.id,
821
+ colId: cell.column.id
822
+ });
823
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
824
+ rowId: nextRow.id,
825
+ colId: cell.column.id
826
+ }, {
827
+ rowId: nextRow.id,
828
+ colId: cell.column.id
829
+ }));
830
+
831
+ // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
832
+ } else {
833
+ const newRowId = (0, _utils.newGuid)();
834
+ handleAddMulti?.({}, 1, newRowId);
835
+ setFocusedCell?.({
836
+ rowId: newRowId,
837
+ colId: cell.column.id
838
+ });
839
+ setStartCell?.({
840
+ rowId: newRowId,
841
+ colId: cell.column.id
842
+ });
843
+ setEndCell?.({
844
+ rowId: newRowId,
845
+ colId: cell.column.id
846
+ });
847
+ setTimeout(() => {
848
+ setRangeState?.((0, _utils.getSelectedCellMatrix)(table, {
849
+ rowId: newRowId,
850
+ colId: cell.column.id
851
+ }, {
852
+ rowId: newRowId,
853
+ colId: cell.column.id
854
+ }));
855
+ // rowVirtualizer.scrollToIndex(101)
856
+ }, 0);
857
+ }
858
+ if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _utils.flattenArray)(dataSource).length) {
859
+
860
+ // handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
861
+ } else {
862
+ // // focus cell hiện tại và tắt edit
863
+ // handleFocusCell((rowNumber ?? 0), colIndex, column, 'vertical', event)
864
+ // setEditingKey('')
865
+
866
+ // thêm dòng mới
867
+
868
+ // handleAddSingle()
869
+ // handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event, true)
870
+ }
871
+ }
872
+ }
873
+ }
874
+ },
875
+ onDoubleClick: e => {
876
+ if (!(record[rowKey] === editingKey && canEdit)) {
877
+ handleEdit(e);
878
+ }
879
+ }
880
+ }, isEditing && canEdit ? /*#__PURE__*/_react.default.createElement(_EditableCell.default, {
881
+ cellEditing: {},
882
+ column: cell.column.columnDef.meta,
883
+ dataIndex: cell.column.id,
884
+ editType: (0, _utils.getEditType)(cell.column.columnDef.meta, record),
885
+ indexCol: cell.column.getIndex(),
886
+ indexRow: cell.row.index,
887
+ record: record
888
+ // rowKey={rowKey}
889
+ }) : /*#__PURE__*/_react.default.createElement("div", {
890
+ className: "ui-rc_cell-content"
891
+ }, cell.column.getIndex() === expandIconColumnIndex && /*#__PURE__*/_react.default.createElement("div", {
892
+ className: "ui-rc-table-row-expand-trigger",
893
+ style: {
894
+ paddingLeft: `${cell.row.depth * 25}px`
895
+ }
896
+ }, /*#__PURE__*/_react.default.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/_react.default.createElement("button", {
897
+ // onClick: row.getToggleExpandedHandler(),
898
+ onClick: () => {
899
+ const keys = Object.keys(expanded);
900
+ // @ts-ignore
901
+ const tmp = {
902
+ ...expanded
903
+ };
904
+ if (keys.includes(cell.row.id)) {
905
+ delete tmp[cell.row.id];
906
+ setExpanded(tmp);
907
+ } else {
908
+ setExpanded(old => ({
909
+ ...old,
910
+ [cell.row.id]: true
911
+ }));
912
+ }
913
+ },
914
+ style: {
915
+ cursor: "pointer"
916
+ },
917
+ className: "ui-rc-table-row-expand"
918
+ }, cell.row.getIsExpanded() ? /*#__PURE__*/_react.default.createElement("span", {
919
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
920
+ }) : /*#__PURE__*/_react.default.createElement("span", {
921
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
922
+ })) : /*#__PURE__*/_react.default.createElement("span", {
923
+ className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
924
+ }))), (0, _reactTable.flexRender)(cell.column.columnDef.cell, cell.getContext())), !isSelecting && !isEditing && cell.row.id === endCell?.rowId && cell.column.getIndex() === rangeState?.endColIndex && /*#__PURE__*/_react.default.createElement("div", {
925
+ className: 'dragging-point',
926
+ onMouseDown: e => {
927
+ e.preventDefault();
928
+ e.stopPropagation();
929
+ if (e.button === 0) {
930
+ setIsPasting?.(true);
931
+ }
932
+ },
933
+ onDoubleClick: handlePointDoubleClick
934
+ }, /*#__PURE__*/_react.default.createElement("span", {
935
+ className: 'dot-point'
936
+ })));
937
+ };
938
+ var _default = exports.default = TableBodyCellEdit;