es-grid-template 1.4.3 → 1.4.5

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.
@@ -25,10 +25,11 @@ var _hooks = require("../hooks");
25
25
  var _Message = _interopRequireDefault(require("../../Message/Message"));
26
26
  var _rcMasterUi = require("rc-master-ui");
27
27
  var _becoxyIcons = require("becoxy-icons");
28
- var _faker = require("@faker-js/faker");
29
28
  var _InternalTable = require("../InternalTable");
30
29
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
31
30
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
31
+ // import {faker} from "@faker-js/faker";
32
+
32
33
  const {
33
34
  Paragraph,
34
35
  Title
@@ -181,7 +182,7 @@ const validateData = async (data, formSchema) => {
181
182
  };
182
183
  const GridEdit = props => {
183
184
  const {
184
- id: tableId,
185
+ id,
185
186
  tableRef,
186
187
  t,
187
188
  columns,
@@ -191,6 +192,7 @@ const GridEdit = props => {
191
192
  rowKey = 'id',
192
193
  selectionSettings,
193
194
  height,
195
+ scrollHeight,
194
196
  format,
195
197
  triggerChangeData,
196
198
  triggerChangeColumns,
@@ -232,20 +234,143 @@ const GridEdit = props => {
232
234
  const visibleCols = _react.default.useMemo(() => {
233
235
  return (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false));
234
236
  }, [columns]);
235
- const id = _react.default.useMemo(() => {
236
- return tableId ?? _faker.faker.string.alpha(20);
237
- // return tableId ?? newGuid()
238
- }, [tableId]);
239
- const itemsAdd = [{
240
- key: '10',
241
- label: '10 rows'
242
- }, {
243
- key: '50',
244
- label: '50 rows'
245
- }, {
246
- key: '100',
247
- label: '100 rows'
248
- }];
237
+
238
+ // const id = React.useMemo(() => {
239
+ //
240
+ // return tableId ?? faker.string.alpha(20)
241
+ // // return tableId ?? newGuid()
242
+ //
243
+ // }, [tableId])
244
+
245
+ const itemsAdd = _react.default.useMemo(() => {
246
+ return [{
247
+ key: '10',
248
+ label: `10 ${t ? t('rows') : 'rows'}`
249
+ }, {
250
+ key: '50',
251
+ label: `50 ${t ? t('rows') : 'rows'}`
252
+ }, {
253
+ key: '100',
254
+ label: `100 ${t ? t('rows') : 'rows'}`
255
+ }];
256
+ }, [t]);
257
+
258
+ // const defaultContext = React.useMemo(() => {
259
+ // return [
260
+ // {
261
+ // key: 'INSERT_BEFORE',
262
+ // label: 'Thêm dòng bên trên',
263
+ // icon: <Plus fontSize={14} />,
264
+ // children: [
265
+ // {
266
+ // parentKey: 'INSERT_BEFORE',
267
+ // key: 'INSERT_BEFORE_1',
268
+ // label: 'Thêm 1 dòng',
269
+ // row: 1
270
+ // },
271
+ // {
272
+ // parentKey: 'INSERT_BEFORE',
273
+ // key: 'INSERT_BEFORE_10',
274
+ // label: 'Thêm 10 dòng',
275
+ // row: 10
276
+ // },
277
+ // {
278
+ // parentKey: 'INSERT_BEFORE',
279
+ // key: 'INSERT_BEFORE_50',
280
+ // label: 'Thêm 50 dòng',
281
+ // row: 50
282
+ // },
283
+ // {
284
+ // parentKey: 'INSERT_BEFORE',
285
+ // key: 'INSERT_BEFORE_100',
286
+ // label: 'Thêm 100 dòng',
287
+ // row: 100
288
+ // },
289
+ // {
290
+ // parentKey: 'INSERT_BEFORE',
291
+ // key: 'INSERT_BEFORE_ADV',
292
+ // label: 'Tùy chỉnh'
293
+ // }
294
+ // ]
295
+ // },
296
+ // {
297
+ // key: 'INSERT_AFTER',
298
+ // label: 'Thêm dòng bên dưới',
299
+ // icon: <Plus fontSize={14} />,
300
+ // children: [
301
+ // {
302
+ // parentKey: 'INSERT_AFTER',
303
+ // key: 'INSERT_AFTER_1',
304
+ // label: 'Thêm 1 dòng',
305
+ // row: 1
306
+ // },
307
+ // {
308
+ // parentKey: 'INSERT_AFTER',
309
+ // key: 'INSERT_AFTER_10',
310
+ // label: 'Thêm 10 dòng',
311
+ // row: 10
312
+ // },
313
+ // {
314
+ // parentKey: 'INSERT_AFTER',
315
+ // key: 'INSERT_AFTER_50',
316
+ // label: 'Thêm 50 dòng',
317
+ // row: 50
318
+ // },
319
+ // {
320
+ // parentKey: 'INSERT_AFTER',
321
+ // key: 'INSERT_AFTER_100',
322
+ // label: 'Thêm 100 dòng',
323
+ // row: 100
324
+ // },
325
+ // {
326
+ // parentKey: 'INSERT_AFTER',
327
+ // key: 'INSERT_AFTER_ADV',
328
+ // label: 'Tùy chỉnh'
329
+ // }
330
+ // ]
331
+ // },
332
+ // {
333
+ // key: 'INSERT_CHILDREN',
334
+ // // label: 'Insert item children',
335
+ // label: 'Thêm cấp con',
336
+ // icon: <Plus fontSize={14} />
337
+ // // children: [
338
+ // // {
339
+ // // parentKey: 'INSERT_AFTER',
340
+ // // key: 'INSERT_AFTER_1',
341
+ // // label: 'Thêm 1 dòng',
342
+ // // row: 1
343
+ // // },
344
+ // // {
345
+ // // parentKey: 'INSERT_AFTER',
346
+ // // key: 'INSERT_AFTER_10',
347
+ // // label: 'Thêm 10 dòng',
348
+ // // row: 10
349
+ // // },
350
+ // // {
351
+ // // parentKey: 'INSERT_AFTER',
352
+ // // key: 'INSERT_AFTER_50',
353
+ // // label: 'Thêm 50 dòng',
354
+ // // row: 50
355
+ // // },
356
+ // // {
357
+ // // parentKey: 'INSERT_AFTER',
358
+ // // key: 'INSERT_AFTER_100',
359
+ // // label: 'Thêm 100 dòng',
360
+ // // row: 100
361
+ // // },
362
+ // // {
363
+ // // parentKey: 'INSERT_AFTER',
364
+ // // key: 'INSERT_AFTER_ADV',
365
+ // // label: 'Tùy chỉnh'
366
+ // // }
367
+ // // ]
368
+ // },
369
+ // { key: 'DELETE_CONTENT', label: 'Xóa nội dung', icon: <Trash2 fontSize={14} /> },
370
+ // { key: 'DELETE_ROWS', label: 'Xóa dòng', icon: <Trash2 fontSize={14} /> }
371
+ // ]
372
+ // }, [])
373
+
249
374
  const [form] = _antd.Form.useForm();
250
375
  const [editingKey, setEditingKey] = (0, _react.useState)('');
251
376
  const [dataErrors, setDataErrors] = (0, _react.useState)([]);
@@ -365,13 +490,13 @@ const GridEdit = props => {
365
490
  // thêm n dòng bên trên
366
491
  const handleInsertBefore = _react.default.useCallback((item, n) => {
367
492
  //
368
- (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
369
- (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
493
+ // onRemoveBgSelectedCell(selectedCells.current, id)
494
+ // onRemoveBorderSelectedCell(selectedCells.current, id)
370
495
  //
371
496
 
372
497
  setTimeout(() => {
373
- (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
374
- (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
498
+ // onAddBgSelectedCell(selectedCells.current, id)
499
+ // onAddBorderSelectedCell(selectedCells.current, id)
375
500
  }, 10);
376
501
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
377
502
  // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
@@ -442,7 +567,7 @@ const GridEdit = props => {
442
567
  triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
443
568
  }
444
569
  }
445
- }, [dataSource, defaultValue, id, isFilter, rowKey, rowsFocus, triggerChangeData]);
570
+ }, [dataSource, defaultValue, isFilter, rowKey, rowsFocus, triggerChangeData]);
446
571
 
447
572
  //thêm 1 dòng bên dưới
448
573
  const handleInsertAfter = _react.default.useCallback((item, n) => {
@@ -527,7 +652,7 @@ const GridEdit = props => {
527
652
  });
528
653
  } else {
529
654
  const newData = [...dataSource];
530
- let newElement = {};
655
+ let newElement;
531
656
  if (!record.children || record.children.length === 0) {
532
657
  newElement = {
533
658
  ...record,
@@ -561,8 +686,8 @@ const GridEdit = props => {
561
686
  }, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
562
687
  const handleDeleteRows = _react.default.useCallback(item => {
563
688
  setTimeout(() => {
564
- (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
565
- (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
689
+ // onAddBgSelectedCell(selectedCells.current, id)
690
+ // onAddBorderSelectedCell(selectedCells.current, id)
566
691
  });
567
692
  if (item.onClick) {
568
693
  item.onClick({
@@ -578,7 +703,7 @@ const GridEdit = props => {
578
703
  });
579
704
  triggerChangeData?.([...newData], 'DELETE_ROWS');
580
705
  }
581
- }, [dataSource, id, rowsFocus, triggerChangeData]);
706
+ }, [dataSource, rowsFocus, triggerChangeData]);
582
707
  const handleDeleteAll = _react.default.useCallback(() => {
583
708
  triggerChangeData?.([], 'INSERT_BEFORE');
584
709
  }, [triggerChangeData]);
@@ -824,7 +949,7 @@ const GridEdit = props => {
824
949
  }
825
950
  } = (0, _reactHookForm.useForm)({
826
951
  mode: 'onChange',
827
- resolver: (0, _yup.yupResolver)(validate)
952
+ resolver: validate ? (0, _yup.yupResolver)(validate) : undefined
828
953
  });
829
954
  const isEditing = _react.default.useCallback(record => {
830
955
  return record[rowKey] === editingKey;
@@ -874,77 +999,6 @@ const GridEdit = props => {
874
999
  document.removeEventListener("click", handleClickOutside);
875
1000
  };
876
1001
  }, [id]);
877
- const handleMouseDown = (record, row, col, e) => {
878
- if (editingKey && editingKey === record[rowKey]) {
879
- return;
880
- }
881
- if (e.button === 2) {
882
- e.stopPropagation();
883
- return;
884
- }
885
-
886
- // isDragMouse.current = true
887
- isMouseDown.current = true;
888
- if (e.ctrlKey) {
889
- isSelecting.current = true;
890
- startCell.current = {
891
- row,
892
- col
893
- };
894
-
895
- // const cell: any = new Set([`${row}-${col}`])
896
-
897
- // setCurrentCtrlCells(cell)
898
- } else {
899
- isSelecting.current = true;
900
- startCell.current = {
901
- row,
902
- col
903
- };
904
- const target = e.target;
905
- if (target.closest('.dragging-point')) {
906
- e.stopPropagation();
907
- e.preventDefault();
908
- return; // Không xử lý gì cả
909
- } else {
910
- // setStartSelectedCell({row, col})
911
-
912
- startSelectedCells.current = {
913
- row,
914
- col
915
- };
916
-
917
- // setSelectedCells(new Set([`${row}-${col}`]));
918
-
919
- const cells = new Set([`${row}-${col}`]);
920
- if (selectedCells.current && selectedCells.current.size > 0) {
921
- if (!(0, _hooks.isEqualSet)(cells, rangeCells)) {
922
- (0, _hooks.onRemoveBgSelectedCell)(rangeCells, id);
923
- (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
924
- (0, _hooks.hideDraggingPoint)(rangeCells, id);
925
- }
926
- }
927
- if (rowsSelected.current && rowsSelected.current.size > 0) {
928
- (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
929
- }
930
- if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
931
- selectedCells.current = cells;
932
- if (editingKey) {
933
- setTimeout(() => {
934
- (0, _hooks.onAddBgSelectedCell)(cells, id);
935
- (0, _hooks.onAddBorderSelectedCell)(cells, id);
936
- }, 200);
937
- } else {
938
- (0, _hooks.onAddBgSelectedCell)(cells, id);
939
- (0, _hooks.onAddBorderSelectedCell)(cells, id);
940
- }
941
- }
942
-
943
- // setRowsSelected(new Set())
944
- rowsSelected.current = new Set();
945
- }
946
- }
947
- };
948
1002
  const triggerDragPaste = pastesArray => {
949
1003
  const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
950
1004
  const tmpCols = {
@@ -965,35 +1019,6 @@ const GridEdit = props => {
965
1019
  // return { row, col, value: '' };
966
1020
  });
967
1021
 
968
- // let selectedArray = []
969
- //
970
- // if (rowPasteLast > rowSelectedFirst) {
971
- // // kéo xuóng
972
- // selectedArray = Array.from(selectedCells).map((key: any) => {
973
- //
974
- // const [row, col] = key.split("-").map(Number);
975
- // // @ts-ignore
976
- // const columnKey = columns[col].field;
977
- //
978
- // // @ts-ignore
979
- // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
980
- // // return { row, col, value: '' };
981
- // });
982
- // } else {
983
- // // kéo lên
984
- //
985
- // selectedArray = Array.from(sortedSetDSC(selectedCells)).map((key: any) => {
986
- //
987
- // const [row, col] = key.split("-").map(Number);
988
- // // @ts-ignore
989
- // const columnKey = columns[col].field;
990
- //
991
- // // @ts-ignore
992
- // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
993
- // // return { row, col, value: '' };
994
- // });
995
- // }
996
-
997
1022
  // Xác định min/max row và col để sắp xếp dữ liệu
998
1023
  const minRow = Math.min(...selectedArray.map(cell => cell.row));
999
1024
  const maxRow = Math.max(...selectedArray.map(cell => cell.row));
@@ -1013,10 +1038,7 @@ const GridEdit = props => {
1013
1038
  }) => {
1014
1039
  table[row - minRow][col - minCol] = value;
1015
1040
  });
1016
- let newRange = {
1017
- combined: [],
1018
- addedRows: []
1019
- };
1041
+ let newRange;
1020
1042
  if (rowPasteLast > rowSelectedFirst) {
1021
1043
  // kéo xuóng
1022
1044
  newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
@@ -1073,18 +1095,20 @@ const GridEdit = props => {
1073
1095
 
1074
1096
  /// cập nhật cell class
1075
1097
  if (selectedCells.current && selectedCells.current.size > 0) {
1076
- (0, _hooks.onRemoveBgSelectedCell)(rangeCells, id);
1077
- (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
1098
+ // onRemoveBgSelectedCell(rangeCells, id)
1099
+ // onRemoveBorderSelectedCell(rangeCells, id)
1078
1100
  }
1079
1101
 
1080
1102
  // selectedCells.current = sortedSetASC(mergedSet)
1081
1103
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1082
- selectedCells.current = (0, _hooks.sortedSetASC)(mergedSet);
1083
- setRangeCells((0, _hooks.sortedSetASC)(mergedSet));
1104
+ const newCells = (0, _hooks.sortedSetASC)(mergedSet);
1105
+ selectedCells.current = newCells;
1106
+ (0, _hooks.onAddBgCellIndex)(newCells, id);
1107
+ setRangeCells(newCells);
1108
+ (0, _hooks.onAddBgSelectedCell)(newCells, id);
1109
+ (0, _hooks.onAddBorderSelectedCell)(newCells, id);
1084
1110
  setTimeout(() => {
1085
- (0, _hooks.onAddBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1086
- (0, _hooks.onAddBorderSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1087
- (0, _hooks.showDraggingPoint)((0, _hooks.sortedSetASC)(mergedSet), id);
1111
+ (0, _hooks.showDraggingPoint)(newCells, id);
1088
1112
  }, 50);
1089
1113
 
1090
1114
  // setPasteCells(new Set())
@@ -1109,6 +1133,80 @@ const GridEdit = props => {
1109
1133
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1110
1134
  triggerDragPaste(newPasteCells);
1111
1135
  };
1136
+ const handleMouseDown = (record, row, col, e) => {
1137
+ if (e.button === 2) {
1138
+ e.stopPropagation();
1139
+ return;
1140
+ }
1141
+ if (editingKey && editingKey === record[rowKey]) {
1142
+ return;
1143
+ }
1144
+ if (record[rowKey] !== editingKey && editingKey !== '') {
1145
+ setEditingKey('');
1146
+ }
1147
+
1148
+ // isDragMouse.current = true
1149
+ isMouseDown.current = true;
1150
+ if (e.ctrlKey) {
1151
+ isSelecting.current = true;
1152
+ startCell.current = {
1153
+ row,
1154
+ col
1155
+ };
1156
+
1157
+ // const cell: any = new Set([`${row}-${col}`])
1158
+
1159
+ // setCurrentCtrlCells(cell)
1160
+ } else {
1161
+ isSelecting.current = true;
1162
+ startCell.current = {
1163
+ row,
1164
+ col
1165
+ };
1166
+ const target = e.target;
1167
+ if (target.closest('.dragging-point')) {
1168
+ e.stopPropagation();
1169
+ e.preventDefault();
1170
+ return; // Không xử lý gì cả
1171
+ } else {
1172
+ // setStartSelectedCell({row, col})
1173
+
1174
+ startSelectedCells.current = {
1175
+ row,
1176
+ col
1177
+ };
1178
+
1179
+ // setSelectedCells(new Set([`${row}-${col}`]));
1180
+
1181
+ const cells = new Set([`${row}-${col}`]);
1182
+ if (selectedCells.current && selectedCells.current.size > 0) {
1183
+ if (!(0, _hooks.isEqualSet)(cells, rangeCells)) {
1184
+ // onRemoveBgSelectedCell(rangeCells, id)
1185
+ // onRemoveBorderSelectedCell(rangeCells, id)
1186
+ (0, _hooks.hideDraggingPoint)(rangeCells, id);
1187
+ (0, _hooks.onRemoveBgCellIndex)(selectedCells.current, id);
1188
+ }
1189
+ }
1190
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1191
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1192
+ }
1193
+ if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
1194
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1195
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1196
+ selectedCells.current = cells;
1197
+ // setRangeCells(cells)
1198
+
1199
+ (0, _hooks.onAddBgCellIndex)(cells, id);
1200
+ (0, _hooks.onAddBorderSelectedCell)(cells, id);
1201
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id, false);
1202
+ (0, _hooks.showDraggingPoint)(selectedCells.current, id);
1203
+ }
1204
+
1205
+ // setRowsSelected(new Set())
1206
+ rowsSelected.current = new Set();
1207
+ }
1208
+ }
1209
+ };
1112
1210
  const handleMouseUp = e => {
1113
1211
  isSelecting.current = false;
1114
1212
  startCell.current = null;
@@ -1117,12 +1215,6 @@ const GridEdit = props => {
1117
1215
  isDragMouse.current = false;
1118
1216
  isMouseDown.current = false;
1119
1217
  setIsPasteDragging(false);
1120
-
1121
- // isPasteDragging.current = false
1122
- // setSelectIsDragging(false);
1123
-
1124
- // setCurrentCtrlCells(new Set())
1125
-
1126
1218
  if (e.ctrlKey) {
1127
1219
 
1128
1220
  // setCtrlCells([...ctrlCells, currentCtrlCells])
@@ -1134,18 +1226,20 @@ const GridEdit = props => {
1134
1226
  triggerDragPaste(pasteCells.current);
1135
1227
  } else {
1136
1228
  setRangeCells(selectedCells.current);
1137
- (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
1138
- (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1139
1229
  const target = e.target;
1140
1230
  if (target.closest('.dragging-point')) {
1141
1231
  e.stopPropagation();
1142
1232
  e.preventDefault();
1143
1233
  return; // Không xử lý gì cả
1144
1234
  }
1145
- if (selectedCells.current && selectedCells.current.size > 0) {
1235
+ if (selectedCells.current && selectedCells.current.size > 1) {
1146
1236
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1237
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1238
+
1239
+ // showDraggingPoint(selectedCells.current, id)
1147
1240
  }
1148
1241
  (0, _hooks.showDraggingPoint)(selectedCells.current, id);
1242
+ // onAddBorderSelectedCell(selectedCells.current, id)
1149
1243
  }
1150
1244
  };
1151
1245
  const handleMouseEnter = (row, col, e) => {
@@ -1264,15 +1358,17 @@ const GridEdit = props => {
1264
1358
  // setSelectedCells(new Set(newSelectedCells));
1265
1359
 
1266
1360
  if (selectedCells.current && selectedCells.current.size > 0) {
1267
- (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1268
- (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1361
+ // onRemoveBgSelectedCell(selectedCells.current, id)
1362
+ // onRemoveBorderSelectedCell(selectedCells.current, id)
1269
1363
  }
1270
1364
  if (rowsSelected.current && rowsSelected.current.size > 0) {
1271
1365
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1272
1366
  }
1273
1367
  selectedCells.current = newSelectedCells;
1274
- (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1275
- (0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
1368
+
1369
+ // onAddBgSelectedCell(newSelectedCells, id)
1370
+ // onAddBorderSelectedCell(newSelectedCells, id)
1371
+
1276
1372
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1277
1373
  (0, _hooks.showDraggingPoint)(newSelectedCells, id);
1278
1374
  };
@@ -1281,6 +1377,9 @@ const GridEdit = props => {
1281
1377
  e.stopPropagation();
1282
1378
  return;
1283
1379
  }
1380
+ if (editingKey) {
1381
+ setEditingKey('');
1382
+ }
1284
1383
  isSelectingRow.current = true;
1285
1384
  rowStart.current = {
1286
1385
  row,
@@ -1293,13 +1392,11 @@ const GridEdit = props => {
1293
1392
  newSelectedCells.add(`${r}-${c}`);
1294
1393
  }
1295
1394
  }
1296
-
1297
- // setSelectedCells(newSelectedCells)
1298
- // setRowsSelected(new Set([`${row}-${col}`]));
1299
-
1300
1395
  if (selectedCells.current && selectedCells.current.size > 0) {
1396
+ (0, _hooks.onRemoveBgCellIndex)(selectedCells.current, id);
1301
1397
  (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1302
1398
  (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1399
+ // onRemoveBorderSelectedCell(selectedCells.current, id)
1303
1400
  }
1304
1401
  if (rowsSelected.current && rowsSelected.current.size > 0) {
1305
1402
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
@@ -1308,7 +1405,9 @@ const GridEdit = props => {
1308
1405
  selectedCells.current = newSelectedCells;
1309
1406
  rowsSelected.current = new Set([`${row}-${col}`]);
1310
1407
  (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id, false);
1311
- (0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
1408
+ setTimeout(() => {
1409
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id, false);
1410
+ }, 10);
1312
1411
  (0, _hooks.addClassCellIndexSelected)(new Set([`${row}-${col}`]), id);
1313
1412
  };
1314
1413
  const handleMouseEnterRowHeader = (row, col, e) => {
@@ -1338,13 +1437,11 @@ const GridEdit = props => {
1338
1437
  if (selectedCells.current && selectedCells.current.size > 0) {
1339
1438
  (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1340
1439
  }
1341
- // setSelectedCells(newSelectedCells)
1342
1440
  selectedCells.current = newSelectedCells;
1343
1441
  (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1344
1442
  if (rowsSelected.current && rowsSelected.current.size > 0) {
1345
1443
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1346
1444
  }
1347
- // setRowsSelected(newSelectedRows)
1348
1445
  rowsSelected.current = newSelectedRows;
1349
1446
  (0, _hooks.addClassCellIndexSelected)(newSelectedRows, id);
1350
1447
  };
@@ -1763,6 +1860,7 @@ const GridEdit = props => {
1763
1860
  }
1764
1861
  };
1765
1862
  const handleEdit = (record, col, editType, e) => {
1863
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1766
1864
  setTooltipContent('');
1767
1865
  // @ts-ignore
1768
1866
  setEditingKey(record[rowKey]);
@@ -1862,10 +1960,16 @@ const GridEdit = props => {
1862
1960
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1863
1961
  selectedCells.current = cells;
1864
1962
  setRangeCells(cells);
1865
- setTimeout(() => {
1866
- (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
1867
- (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1868
- }, 50);
1963
+
1964
+ // setTimeout(() => {
1965
+ //
1966
+ // // onAddBgSelectedCell(selectedCells.current, id)
1967
+ // // onAddBorderSelectedCell(selectedCells.current, id)
1968
+ //
1969
+ // }, 50)
1970
+
1971
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
1972
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1869
1973
  (0, _hooks.showDraggingPoint)(cells, id);
1870
1974
  };
1871
1975
  const focusNextCell = (editingCell, cellEditable) => {
@@ -1874,6 +1978,7 @@ const GridEdit = props => {
1874
1978
  updateSelection();
1875
1979
  if (e?.key !== 'Tab') {
1876
1980
  editingCell.focus();
1981
+ // editingCell.click()
1877
1982
  }
1878
1983
  }
1879
1984
  if (scrollType === 'horizontal' && editingCell) {
@@ -1885,6 +1990,8 @@ const GridEdit = props => {
1885
1990
  scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
1886
1991
  if (e?.key !== 'Tab') {
1887
1992
  cellEditable.focus();
1993
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1994
+ // editingCell.click()
1888
1995
  }
1889
1996
  }
1890
1997
  } else {
@@ -1892,6 +1999,7 @@ const GridEdit = props => {
1892
1999
  updateSelection();
1893
2000
  if (e?.key !== 'Tab') {
1894
2001
  cellEditable.focus();
2002
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1895
2003
  }
1896
2004
  }
1897
2005
  if (cellEditable) {
@@ -1937,11 +2045,11 @@ const GridEdit = props => {
1937
2045
  e.preventDefault();
1938
2046
  }
1939
2047
  },
1940
- onClick: () => {
1941
- if (record[rowKey] !== editingKey && editingKey !== '') {
1942
- setEditingKey('');
1943
- }
1944
- },
2048
+ // onClick: () => {
2049
+ // if (record[rowKey] !== editingKey && (editingKey !== '')) {
2050
+ // setEditingKey('')
2051
+ // }
2052
+ // },
1945
2053
  tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex
1946
2054
  };
1947
2055
  },
@@ -1951,7 +2059,7 @@ const GridEdit = props => {
1951
2059
  className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {}),
1952
2060
  onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
1953
2061
  onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event),
1954
- onMouseUp: handleMouseUp
2062
+ onMouseUp: event => handleMouseUp(event)
1955
2063
  }, /*#__PURE__*/_react.default.createElement("div", {
1956
2064
  className: 'ui-rc_content'
1957
2065
  }, (0, _hooks.findItemPath)(dataSource, record, rowKey)));
@@ -1978,9 +2086,12 @@ const GridEdit = props => {
1978
2086
  event.preventDefault();
1979
2087
  event.stopPropagation();
1980
2088
  handleEdit(record, column, column.editType, event);
1981
- (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1982
- (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1983
- selectedCells.current = new Set();
2089
+
2090
+ // onRemoveBgSelectedCell(selectedCells.current, id)
2091
+ // onRemoveBorderSelectedCell(selectedCells.current, id)
2092
+
2093
+ // selectedCells.current = new Set()
2094
+
1984
2095
  handleCellClick(rowNumber, record, column);
1985
2096
  const hasKey = mergedExpandedKeys.has(key);
1986
2097
  if (hasKey) {
@@ -2070,8 +2181,9 @@ const GridEdit = props => {
2070
2181
  onDoubleClick: event => {
2071
2182
  if (!isEditing(record) && record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
2072
2183
  handleEdit(record, column, (0, _hooks.getEditType)(column, record), event);
2073
- (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
2074
- (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
2184
+
2185
+ // onRemoveBgSelectedCell(selectedCells.current, id)
2186
+ // onRemoveBorderSelectedCell(selectedCells.current, id)
2075
2187
  handleCellClick(rowNumber, record, column);
2076
2188
  }
2077
2189
  },
@@ -2093,14 +2205,27 @@ const GridEdit = props => {
2093
2205
  },
2094
2206
  onClick: () => {
2095
2207
  if (record[rowKey] !== editingKey && editingKey !== '') {
2096
- setEditingKey('');
2208
+ // setEditingKey('')
2097
2209
  } else {
2210
+ if (record[rowKey] !== editingKey) {
2211
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
2212
+ }
2098
2213
  if (editingKey) {
2099
2214
  handleCellClick(rowNumber, record, column);
2100
2215
  }
2101
2216
  }
2102
2217
  },
2103
- className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
2218
+ // className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!isEditable(column as any, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!isEditable(column as any, record) ? 'disable' : ''}`,
2219
+ className: (0, _classnames.default)('rc-ui-cell-editable', {
2220
+ 'cell-editing': isEditing(record),
2221
+ 'cell-editable': !isEditing(record),
2222
+ // selected: isSelectedCell(rangeCells,rowIndex, colIndex),
2223
+ // 'cell-border-bottom': isRangeCell(rangeCells, 'bottom',rowIndex, colIndex),
2224
+ // 'cell-border-right': isRangeCell(rangeCells, 'right',rowIndex, colIndex),
2225
+ // 'cell-border-top': isRangeCell(rangeCells, 'top',rowIndex, colIndex),
2226
+ // 'cell-border-left': isRangeCell(rangeCells, 'left',rowIndex, colIndex),
2227
+ disable: !(0, _hooks.isEditable)(column, record)
2228
+ }),
2104
2229
  record,
2105
2230
  column: column,
2106
2231
  editType: (0, _hooks.getEditType)(column, record),
@@ -2111,9 +2236,6 @@ const GridEdit = props => {
2111
2236
  'data-col-index': colIndex,
2112
2237
  'data-row-index': rowNumber,
2113
2238
  'data-tooltip-id': "tooltip-cell-content",
2114
- // 'data-tooltip-content': 'tooltip-cell-content',
2115
- // 'data-tooltip-delay-show': 1000,
2116
- // 'data-tooltip-content': getValueCell(column, record[column.field as any], format),
2117
2239
  editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
2118
2240
  cellEditing,
2119
2241
  t,
@@ -2203,6 +2325,40 @@ const GridEdit = props => {
2203
2325
  }
2204
2326
  };
2205
2327
  });
2328
+ // [
2329
+ // cellEditing,
2330
+ // columns,
2331
+ // dataErrors,
2332
+ // dataSource,
2333
+ // editingKey,
2334
+ // format,
2335
+ // getRowKey,
2336
+ // handleAddSingle,
2337
+ // handleCellClick,
2338
+ // handleClickColHeader,
2339
+ // handleCopy,
2340
+ // handleDeleteContent,
2341
+ // handleEdit,
2342
+ // handleFocusCell,
2343
+ // handleMouseDown,
2344
+ // handleMouseDownRowHeader,
2345
+ // handleMouseEnter,
2346
+ // handleMouseEnterRowHeader,
2347
+ // handleMouseUp,
2348
+ // handlePaste,
2349
+ // handlePointDoubleClick,
2350
+ // id,
2351
+ // isEditing,
2352
+ // isPasteDragging,
2353
+ // mergedExpandedKeys,
2354
+ // onTriggerExpand,
2355
+ // rowEditable,
2356
+ // rowKey,
2357
+ // setTooltipContent,
2358
+ // t,
2359
+ // visibleCols.length
2360
+ // ])
2361
+
2206
2362
  const transformColumns = _react.default.useCallback(cols => {
2207
2363
  // @ts-ignore
2208
2364
  return cols.map(column => {
@@ -2210,6 +2366,14 @@ const GridEdit = props => {
2210
2366
  if (column === _InternalTable.SELECTION_COLUMN) {
2211
2367
  return _InternalTable.SELECTION_COLUMN;
2212
2368
  }
2369
+
2370
+ // Xử lý đệ quy cho children
2371
+ if (column.children?.length) {
2372
+ return {
2373
+ ...column,
2374
+ children: transformColumns(column.children)
2375
+ };
2376
+ }
2213
2377
  if (find) {
2214
2378
  return {
2215
2379
  ...find
@@ -2220,14 +2384,6 @@ const GridEdit = props => {
2220
2384
  ...column
2221
2385
  };
2222
2386
  }
2223
-
2224
- // Xử lý đệ quy cho children
2225
- if (column.children?.length) {
2226
- return {
2227
- ...column,
2228
- children: transformColumns(column.children)
2229
- };
2230
- }
2231
2387
  });
2232
2388
  }, [convertColumns]);
2233
2389
  const mergedColumns = _react.default.useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
@@ -2310,10 +2466,12 @@ const GridEdit = props => {
2310
2466
  };
2311
2467
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
2312
2468
  $heightTable: height,
2469
+ $heightScroll: scrollHeight,
2313
2470
  style: {
2314
2471
  position: 'relative'
2315
2472
  },
2316
- ref: ref
2473
+ ref: ref,
2474
+ id: id
2317
2475
  }, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
2318
2476
  value: {
2319
2477
  rowKey,