es-grid-template 1.3.6 → 1.3.8

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 (31) hide show
  1. package/assets/index.css +35 -24
  2. package/assets/index.scss +57 -21
  3. package/es/grid-component/EditableCell.js +12 -11
  4. package/es/grid-component/GridStyle.d.ts +5 -3
  5. package/es/grid-component/GridStyle.js +1 -1
  6. package/es/grid-component/TableGrid.js +28 -21
  7. package/es/grid-component/hooks/columns/index.d.ts +1 -1
  8. package/es/grid-component/hooks/columns/index.js +15 -14
  9. package/es/grid-component/hooks/useColumns.js +12 -9
  10. package/es/grid-component/hooks/utils.d.ts +19 -4
  11. package/es/grid-component/hooks/utils.js +377 -26
  12. package/es/grid-component/styles.scss +57 -21
  13. package/es/grid-component/table/Grid.js +1 -1
  14. package/es/grid-component/table/GridEdit.js +383 -268
  15. package/es/grid-component/table/Group.js +1 -1
  16. package/es/grid-component/type.d.ts +4 -4
  17. package/lib/grid-component/EditableCell.js +12 -11
  18. package/lib/grid-component/GridStyle.d.ts +5 -3
  19. package/lib/grid-component/GridStyle.js +1 -1
  20. package/lib/grid-component/TableGrid.js +26 -20
  21. package/lib/grid-component/hooks/columns/index.d.ts +1 -1
  22. package/lib/grid-component/hooks/columns/index.js +15 -14
  23. package/lib/grid-component/hooks/useColumns.js +12 -9
  24. package/lib/grid-component/hooks/utils.d.ts +19 -4
  25. package/lib/grid-component/hooks/utils.js +401 -33
  26. package/lib/grid-component/styles.scss +57 -21
  27. package/lib/grid-component/table/Grid.js +1 -1
  28. package/lib/grid-component/table/GridEdit.js +382 -259
  29. package/lib/grid-component/table/Group.js +1 -1
  30. package/lib/grid-component/type.d.ts +4 -4
  31. package/package.json +2 -2
@@ -23,16 +23,10 @@ var _TableGrid = _interopRequireDefault(require("../TableGrid"));
23
23
  var _hooks = require("../hooks");
24
24
  var _Message = _interopRequireDefault(require("../../Message/Message"));
25
25
  var _rcMasterUi = require("rc-master-ui");
26
- var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
27
26
  var _becoxyIcons = require("becoxy-icons");
27
+ var _faker = require("@faker-js/faker");
28
28
  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); }
29
29
  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; }
30
- // import Command from "../Command";
31
-
32
- // import type {ContextMenuItem} from "../type";
33
- // import {ContextInfo, ContextMenuItem} from "../type";
34
- // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
35
-
36
30
  const {
37
31
  Paragraph,
38
32
  Title
@@ -117,7 +111,7 @@ const defaultContext = [{
117
111
  }];
118
112
  const GridEdit = props => {
119
113
  const {
120
- id,
114
+ id: tableId,
121
115
  tableRef,
122
116
  t,
123
117
  columns,
@@ -145,24 +139,28 @@ const GridEdit = props => {
145
139
  showDefaultContext,
146
140
  ...rest
147
141
  } = props;
148
- const {
149
- mode,
150
- type,
151
- // checkboxOnly,
152
- // hideSelectAll,
153
- columnWidth
154
- // selectedRowKeys,
155
- // defaultSelectedRowKeys
156
- } = selectionSettings || {};
157
142
  const ref = (0, _react.useRef)(null);
158
143
  const isSelecting = (0, _react.useRef)(false);
159
144
  const startCell = (0, _react.useRef)(null);
160
145
  const childrenColumnName = 'children';
161
146
  const isSelectingRow = (0, _react.useRef)(false);
162
147
  const rowStart = (0, _react.useRef)(null);
163
-
164
- // const [getRecordByKey] = useLazyKVMap(dataSource, childrenColumnName, getRowKey);
165
-
148
+ const rowsSelected = (0, _react.useRef)(new Set());
149
+ const selectedCells = (0, _react.useRef)(new Set());
150
+ const pasteCells = (0, _react.useRef)(new Set());
151
+ const startSelectedCells = (0, _react.useRef)(null);
152
+
153
+ // quét vùng chọn
154
+ const isDragMouse = (0, _react.useRef)(false);
155
+ const isMouseDown = (0, _react.useRef)(false);
156
+
157
+ // quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
158
+ // const isPasteDragging = useRef(false);
159
+
160
+ const id = _react.default.useMemo(() => {
161
+ return tableId ?? _faker.faker.string.alpha(20);
162
+ // return tableId ?? newGuid()
163
+ }, [tableId]);
166
164
  const itemsAdd = [{
167
165
  key: '10',
168
166
  label: '10 rows'
@@ -176,7 +174,9 @@ const GridEdit = props => {
176
174
  const [form] = _antd.Form.useForm();
177
175
  const [editingKey, setEditingKey] = (0, _react.useState)('');
178
176
  const [isFilter, setIsFilter] = _react.default.useState(false);
179
- const [selectedCells, setSelectedCells] = (0, _react.useState)(new Set());
177
+ const [rangeCells, setRangeCells] = (0, _react.useState)(new Set());
178
+
179
+ // const [pasteCells, setPasteCells] = useState(new Set())
180
180
 
181
181
  // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
182
182
 
@@ -189,16 +189,17 @@ const GridEdit = props => {
189
189
  open: false,
190
190
  type: ''
191
191
  });
192
- // const [openModalPaste, setOpenModalPaste] = useState(defaultModalPaste)
193
-
194
192
  const [rowsAdd, setRowsAdd] = (0, _react.useState)(1);
195
- const [pasteCells, setPasteCells] = (0, _react.useState)(new Set());
196
193
  const [cellEditing, setCellEditing] = (0, _react.useState)(null);
197
- const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
194
+
195
+ // const [isSelectDragging, setSelectIsDragging] = useState(false)
196
+
198
197
  const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
199
198
 
200
- const [rowsSelected, setRowsSelected] = (0, _react.useState)(new Set());
201
- const [startSelectedCells, setStartSelectedCell] = (0, _react.useState)(null);
199
+ // const [rowsSelected, setRowsSelected] = useState(new Set())
200
+
201
+ // const [startSelectedCells, setStartSelectedCell] = useState<{ row: number; col: number } | null>(null)
202
+
202
203
  const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
203
204
  // if (defaultExpandedRowKeys) {
204
205
  // return defaultExpandedRowKeys;
@@ -209,12 +210,9 @@ const GridEdit = props => {
209
210
  // return [];
210
211
  });
211
212
  const mergedExpandedKeys = _react.default.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
212
- const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)([], {
213
- value: []
214
- });
215
213
  const rowsFocus = _react.default.useMemo(() => {
216
- return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
217
- }, [selectedCells]);
214
+ return [...new Set(Array.from(rangeCells).map(item => parseInt(item.split('-')[0])))] ?? [];
215
+ }, [rangeCells]);
218
216
  const contextMenuItems = _react.default.useMemo(() => {
219
217
  const a = showDefaultContext !== false ? [...defaultContext] : [];
220
218
  const b = propsContext ? [...propsContext, {
@@ -294,6 +292,15 @@ const GridEdit = props => {
294
292
 
295
293
  // thêm n dòng bên trên
296
294
  const handleInsertBefore = (item, n) => {
295
+ //
296
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
297
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
298
+ //
299
+
300
+ setTimeout(() => {
301
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
302
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
303
+ }, 10);
297
304
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
298
305
  // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
299
306
 
@@ -368,9 +375,6 @@ const GridEdit = props => {
368
375
  //thêm 1 dòng bên dưới
369
376
  const handleInsertAfter = (item, n) => {
370
377
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
371
-
372
- // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
373
-
374
378
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
375
379
 
376
380
  // const record = getRecordByKey()
@@ -403,8 +407,6 @@ const GridEdit = props => {
403
407
  rowId: (0, _hooks.newGuid)()
404
408
  });
405
409
  const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
406
-
407
- // newData.splice(index + 1, 0, { ...defaultRowValue, rowId, parentId: null })
408
410
  newData.splice(index + 1, 0, ...newRows);
409
411
  triggerChangeData?.(newData, 'INSERT_AFTER');
410
412
  } else {
@@ -486,6 +488,10 @@ const GridEdit = props => {
486
488
  }
487
489
  };
488
490
  const handleDeleteRows = item => {
491
+ setTimeout(() => {
492
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
493
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
494
+ });
489
495
  if (item.onClick) {
490
496
  item.onClick({
491
497
  toolbar: item
@@ -505,14 +511,14 @@ const GridEdit = props => {
505
511
  triggerChangeData?.([], 'INSERT_BEFORE');
506
512
  };
507
513
  const handleDeleteContent = () => {
508
- if (selectedCells.size > 0) {
514
+ if (selectedCells.current.size > 0) {
509
515
  const newData = [...dataSource];
510
516
 
511
517
  // colIndex => field
512
518
  const colIndexToField = (0, _columns.flatColumns2)(columns).map(col => col.field);
513
519
 
514
520
  // Duyệt qua mỗi ô cần xóa
515
- for (const cell of selectedCells) {
521
+ for (const cell of selectedCells.current) {
516
522
  const [rowIndexStr, colIndexStr] = cell.split("-");
517
523
  const rowIndex = Number(rowIndexStr);
518
524
  const colIndex = Number(colIndexStr);
@@ -741,10 +747,8 @@ const GridEdit = props => {
741
747
  trigger,
742
748
  getValues,
743
749
  reset
744
- // formState: { errors }
745
750
  } = (0, _reactHookForm.useForm)({
746
751
  mode: 'onChange'
747
- // defaultValues,
748
752
  // resolver: yupResolver(formSchema)
749
753
  });
750
754
  const isEditing = record => record[rowKey] === editingKey;
@@ -777,23 +781,16 @@ const GridEdit = props => {
777
781
  setEditingKey('');
778
782
  isSelecting.current = false;
779
783
  startCell.current = null;
780
- setSelectedCells(new Set());
781
- setRowsSelected(new Set());
784
+ // setSelectedCells(new Set())
785
+ // setRowsSelected(new Set())
786
+
787
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
788
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
789
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
790
+ rowsSelected.current = new Set();
791
+ selectedCells.current = new Set();
792
+ setRangeCells(new Set());
782
793
  }
783
-
784
- // if (tableBodies.length > 0) {
785
- // const tableBody = tableBodies[0]; // Chọn tbody đầu tiên (nếu có nhiều)
786
- //
787
- // if (!tableBody.contains(event.target as Node)) {
788
- // setEditingKey('')
789
- // isSelecting.current = false;
790
- // startCell.current = null;
791
- // setSelectedCells(new Set())
792
- // setRowsSelected(new Set())
793
- // } else {
794
- //
795
- // }
796
- // }
797
794
  };
798
795
  document.addEventListener("click", handleClickOutside);
799
796
  return () => {
@@ -805,6 +802,9 @@ const GridEdit = props => {
805
802
  e.stopPropagation();
806
803
  return;
807
804
  }
805
+
806
+ // isDragMouse.current = true
807
+ isMouseDown.current = true;
808
808
  if (e.ctrlKey) {
809
809
  isSelecting.current = true;
810
810
  startCell.current = {
@@ -821,45 +821,56 @@ const GridEdit = props => {
821
821
  row,
822
822
  col
823
823
  };
824
- if (e.target.className === 'dragging-point') {
825
- // e.stopPropagation()
826
- // e.preventDefault()
824
+ const target = e.target;
825
+ if (target.closest('.dragging-point')) {
826
+ e.stopPropagation();
827
+ e.preventDefault();
828
+ return; // Không xử lý gì cả
827
829
  } else {
828
- setStartSelectedCell({
830
+ // setStartSelectedCell({row, col})
831
+
832
+ startSelectedCells.current = {
829
833
  row,
830
834
  col
831
- });
832
- setSelectedCells(new Set([`${row}-${col}`]));
833
- setRowsSelected(new Set());
835
+ };
836
+
837
+ // setSelectedCells(new Set([`${row}-${col}`]));
838
+
839
+ const cells = new Set([`${row}-${col}`]);
840
+ if (selectedCells.current && selectedCells.current.size > 0) {
841
+ if (!(0, _hooks.isEqualSet)(cells, rangeCells)) {
842
+ (0, _hooks.onRemoveBgSelectedCell)(rangeCells, id);
843
+ (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
844
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
845
+ }
846
+ }
847
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
848
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
849
+ }
850
+ if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
851
+ selectedCells.current = cells;
852
+ if (editingKey) {
853
+ setTimeout(() => {
854
+ (0, _hooks.onAddBgSelectedCell)(cells, id);
855
+ (0, _hooks.onAddBorderSelectedCell)(cells, id);
856
+ }, 100);
857
+ } else {
858
+ (0, _hooks.onAddBgSelectedCell)(cells, id);
859
+ (0, _hooks.onAddBorderSelectedCell)(cells, id);
860
+ }
861
+ }
862
+
863
+ // setRowsSelected(new Set())
864
+ rowsSelected.current = new Set();
834
865
  }
835
866
  }
836
-
837
- // isSelecting.current = true;
838
- // startCell.current = { row, col };
839
- //
840
- // if (e.target.className === 'dragging-point') {
841
- // // e.stopPropagation()
842
- // // e.preventDefault()
843
- // } else {
844
- //
845
- // setStartSelectedCell({row, col})
846
- // setSelectedCells(new Set([`${row}-${col}`]));
847
- // setRowsSelected(new Set())
848
- // }
849
867
  };
850
868
  const triggerDragPaste = pastesArray => {
851
- const mergedSet = new Set([...selectedCells, ...pastesArray]);
852
-
853
- // console.log('pastesArray', pastesArray)
854
- // console.log('selectedCells', selectedCells)
855
-
856
- setSelectedCells((0, _hooks.sortedSetASC)(mergedSet));
857
- setPasteCells(new Set());
858
- const rowSelectedFirst = (0, _hooks.getFirstSelectCell)(selectedCells).row;
859
- const rowPasteLast = (0, _hooks.getLastSelectCell)(pasteCells).row;
860
- const selectedArray = Array.from(selectedCells).map(key => {
869
+ const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
870
+ const rowSelectedFirst = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
871
+ const rowPasteLast = (0, _hooks.getLastSelectCell)(pasteCells.current).row;
872
+ const selectedArray = Array.from(selectedCells.current).map(key => {
861
873
  const [row, col] = key.split("-").map(Number);
862
- // @ts-ignore
863
874
  const columnKey = columns[col].field;
864
875
 
865
876
  // @ts-ignore
@@ -871,6 +882,35 @@ const GridEdit = props => {
871
882
  // return { row, col, value: '' };
872
883
  });
873
884
 
885
+ // let selectedArray = []
886
+ //
887
+ // if (rowPasteLast > rowSelectedFirst) {
888
+ // // kéo xuóng
889
+ // selectedArray = Array.from(selectedCells).map((key: any) => {
890
+ //
891
+ // const [row, col] = key.split("-").map(Number);
892
+ // // @ts-ignore
893
+ // const columnKey = columns[col].field;
894
+ //
895
+ // // @ts-ignore
896
+ // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
897
+ // // return { row, col, value: '' };
898
+ // });
899
+ // } else {
900
+ // // kéo lên
901
+ //
902
+ // selectedArray = Array.from(sortedSetDSC(selectedCells)).map((key: any) => {
903
+ //
904
+ // const [row, col] = key.split("-").map(Number);
905
+ // // @ts-ignore
906
+ // const columnKey = columns[col].field;
907
+ //
908
+ // // @ts-ignore
909
+ // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
910
+ // // return { row, col, value: '' };
911
+ // });
912
+ // }
913
+
874
914
  // Xác định min/max row và col để sắp xếp dữ liệu
875
915
  const minRow = Math.min(...selectedArray.map(cell => cell.row));
876
916
  const maxRow = Math.max(...selectedArray.map(cell => cell.row));
@@ -909,7 +949,7 @@ const GridEdit = props => {
909
949
  // Lấy vị trí bắt đầu
910
950
  // const { row: startRow, col: startCol } = selectedCell;
911
951
  const startRow = (0, _hooks.getFirstSelectCell)(pastesArray).row;
912
- const startCol = (0, _hooks.getFirstSelectCell)(selectedCells).col;
952
+ const startCol = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
913
953
  const pastedRows = [];
914
954
  const pastedColumns = new Set();
915
955
  newRange.addedRows.forEach((rowValues, rowIndex) => {
@@ -947,19 +987,40 @@ const GridEdit = props => {
947
987
  const pastedColumnsArray = Array.from(pastedColumns) ?? [];
948
988
  triggerPaste?.(pastedRows, pastedColumnsArray, newData);
949
989
  }
990
+
991
+ /// cập nhật cell class
992
+ if (selectedCells.current && selectedCells.current.size > 0) {
993
+ (0, _hooks.onRemoveBgSelectedCell)(rangeCells, id);
994
+ (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
995
+ }
996
+
997
+ // selectedCells.current = sortedSetASC(mergedSet)
998
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
999
+ selectedCells.current = (0, _hooks.sortedSetASC)(mergedSet);
1000
+ (0, _hooks.onAddBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1001
+ (0, _hooks.onAddBorderSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1002
+ (0, _hooks.showDraggingPoint)((0, _hooks.sortedSetASC)(mergedSet), id);
1003
+
1004
+ // setPasteCells(new Set())
1005
+
1006
+ if (pasteCells.current && pasteCells.current.size > 0) {
1007
+ (0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'up', id);
1008
+ }
1009
+ pasteCells.current = new Set();
950
1010
  };
951
1011
  const handlePointDoubleClick = e => {
952
- e.preventDefault();
1012
+ // e.preventDefault()
953
1013
  e.stopPropagation();
954
- const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
955
- const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
956
- const startPasteRow = (0, _hooks.getLastSelectCell)(selectedCells).row;
1014
+ const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
1015
+ const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
1016
+ const startPasteRow = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
957
1017
  const newPasteCells = new Set();
958
1018
  for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
959
1019
  for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
960
1020
  newPasteCells.add(`${r}-${c}`);
961
1021
  }
962
1022
  }
1023
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
963
1024
  triggerDragPaste(newPasteCells);
964
1025
  };
965
1026
 
@@ -988,8 +1049,12 @@ const GridEdit = props => {
988
1049
  startCell.current = null;
989
1050
  isSelectingRow.current = false;
990
1051
  rowStart.current = null;
1052
+ isDragMouse.current = false;
1053
+ isMouseDown.current = false;
991
1054
  setIsPasteDragging(false);
992
- setSelectIsDragging(false);
1055
+
1056
+ // isPasteDragging.current = false
1057
+ // setSelectIsDragging(false);
993
1058
 
994
1059
  // setCurrentCtrlCells(new Set())
995
1060
 
@@ -1000,10 +1065,33 @@ const GridEdit = props => {
1000
1065
 
1001
1066
  // nếu ctrlCell length > 0 thì set selectCells
1002
1067
 
1003
- if (pasteCells.size > 0) {
1004
- triggerDragPaste(pasteCells);
1068
+ if (pasteCells && pasteCells.current.size > 0) {
1069
+ triggerDragPaste(pasteCells.current);
1070
+ } else {
1071
+ setRangeCells(selectedCells.current);
1072
+ (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
1073
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1074
+ const target = e.target;
1075
+ if (target.closest('.dragging-point')) {
1076
+ e.stopPropagation();
1077
+ e.preventDefault();
1078
+ return; // Không xử lý gì cả
1079
+ }
1080
+ if (selectedCells.current && selectedCells.current.size > 0) {
1081
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1082
+ }
1083
+ (0, _hooks.showDraggingPoint)(selectedCells.current, id);
1005
1084
  }
1006
1085
  };
1086
+
1087
+ // const handlePointEnter = () => {
1088
+ // isPointEnter.current = true;
1089
+ // }
1090
+ //
1091
+ // const handlePointLeave = () => {
1092
+ // isPointEnter.current = false;
1093
+ // }
1094
+
1007
1095
  const handleMouseEnter = (row, col, e) => {
1008
1096
  if (!isSelecting.current || !startCell.current) {
1009
1097
  return;
@@ -1027,29 +1115,41 @@ const GridEdit = props => {
1027
1115
  if (!isPasteDragging) {
1028
1116
  // chọn vùng copy
1029
1117
 
1030
- setSelectIsDragging(true);
1118
+ // setSelectIsDragging(true)
1119
+
1031
1120
  setIsPasteDragging(false);
1121
+ // isPasteDragging.current = false
1122
+
1032
1123
  const newSelectedCells = new Set();
1033
1124
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1034
1125
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1035
1126
  newSelectedCells.add(`${r}-${c}`);
1036
1127
  }
1037
1128
  }
1038
- setSelectedCells(newSelectedCells);
1129
+
1130
+ // setSelectedCells(newSelectedCells)
1131
+
1132
+ if (selectedCells.current && selectedCells.current.size > 0) {
1133
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1134
+ }
1135
+ selectedCells.current = newSelectedCells;
1136
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1039
1137
  } else {
1040
1138
  // chọn vùng paste
1041
1139
 
1042
- setSelectIsDragging(false);
1043
- setIsPasteDragging(true);
1140
+ // setSelectIsDragging(false)
1141
+
1142
+ // setIsPasteDragging(true) ////////
1143
+
1044
1144
  const newSelectedCells = new Set();
1045
1145
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1046
1146
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1047
1147
  newSelectedCells.add(`${r}-${c}`);
1048
1148
  }
1049
1149
  }
1050
- const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
1051
- const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
1052
- const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells).row;
1150
+ const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
1151
+ const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
1152
+ const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
1053
1153
  if (row >= rowSelectedEnd) {
1054
1154
  // kéo xuống dưới
1055
1155
 
@@ -1059,12 +1159,19 @@ const GridEdit = props => {
1059
1159
  newPasteCells.add(`${r}-${c}`);
1060
1160
  }
1061
1161
  }
1062
- setPasteCells(newPasteCells);
1162
+
1163
+ // setPasteCells(newPasteCells)
1164
+
1165
+ if (pasteCells.current && pasteCells.current.size > 0) {
1166
+ (0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'down', id);
1167
+ }
1168
+ pasteCells.current = newPasteCells;
1169
+ (0, _hooks.addClassBorderPasteCell)(newPasteCells, 'down', id);
1063
1170
  }
1064
1171
  if (row < rowSelectedEnd) {
1065
1172
  // kéo lên trên
1066
1173
 
1067
- const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells).row;
1174
+ const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
1068
1175
  if (row < rowSelectedStart) {
1069
1176
  const newPasteCells = new Set();
1070
1177
  for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
@@ -1072,7 +1179,14 @@ const GridEdit = props => {
1072
1179
  newPasteCells.add(`${r}-${c}`);
1073
1180
  }
1074
1181
  }
1075
- setPasteCells(newPasteCells);
1182
+
1183
+ // setPasteCells(newPasteCells)
1184
+
1185
+ if (pasteCells.current && pasteCells.current.size > 0) {
1186
+ (0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'up', id);
1187
+ }
1188
+ pasteCells.current = newPasteCells;
1189
+ (0, _hooks.addClassBorderPasteCell)(newPasteCells, 'up', id);
1076
1190
  }
1077
1191
  }
1078
1192
  if (col > colEnd) {
@@ -1083,16 +1197,32 @@ const GridEdit = props => {
1083
1197
  }
1084
1198
  }
1085
1199
  };
1086
- const handleClickRowHeader = (row, col) => {
1087
- const newSelectedCells = new Set();
1088
- const tCols = (0, _hooks.editAbleColumns)(columns);
1089
- for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1090
- for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1091
- newSelectedCells.add(`${r}-${c}`);
1092
- }
1093
- }
1094
- setSelectedCells(newSelectedCells);
1095
- };
1200
+
1201
+ // const handleClickRowHeader = (row: any, col: any) => {
1202
+ //
1203
+ // const newSelectedCells = new Set()
1204
+ //
1205
+ // const tCols = editAbleColumns(columns)
1206
+ //
1207
+ // for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1208
+ // for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1209
+ // newSelectedCells.add(`${r}-${c}`)
1210
+ // }
1211
+ // }
1212
+ //
1213
+ // // setSelectedCells(newSelectedCells)
1214
+ //
1215
+ // if (selectedCells.current && selectedCells.current.size > 0) {
1216
+ // onRemoveBgSelectedCell(selectedCells.current, id)
1217
+ // }
1218
+ //
1219
+ // selectedCells.current = newSelectedCells
1220
+ //
1221
+ // onAddBgSelectedCell(newSelectedCells, id)
1222
+ //
1223
+ //
1224
+ // };
1225
+
1096
1226
  const handleClickColHeader = (column, indexColumn) => {
1097
1227
  const newSelectedCells = new Set();
1098
1228
  for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
@@ -1100,9 +1230,23 @@ const GridEdit = props => {
1100
1230
  newSelectedCells.add(`${r}-${c}`);
1101
1231
  }
1102
1232
  }
1103
- setSelectedCells(new Set(newSelectedCells));
1233
+
1234
+ // setSelectedCells(new Set(newSelectedCells));
1235
+
1236
+ if (selectedCells.current && selectedCells.current.size > 0) {
1237
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1238
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1239
+ }
1240
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1241
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1242
+ }
1243
+ selectedCells.current = newSelectedCells;
1244
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1245
+ (0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
1246
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1247
+ (0, _hooks.showDraggingPoint)(newSelectedCells, id);
1104
1248
  };
1105
- const handleMouseDownColIndex = (row, col, e) => {
1249
+ const handleMouseDownRowHeader = (row, col, column, e) => {
1106
1250
  if (e.button === 2) {
1107
1251
  e.stopPropagation();
1108
1252
  return;
@@ -1112,9 +1256,32 @@ const GridEdit = props => {
1112
1256
  row,
1113
1257
  col
1114
1258
  };
1115
- setRowsSelected(new Set([`${row}-${col}`]));
1259
+ const newSelectedCells = new Set();
1260
+ const tCols = (0, _hooks.editAbleColumns)(columns);
1261
+ for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1262
+ for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1263
+ newSelectedCells.add(`${r}-${c}`);
1264
+ }
1265
+ }
1266
+
1267
+ // setSelectedCells(newSelectedCells)
1268
+ // setRowsSelected(new Set([`${row}-${col}`]));
1269
+
1270
+ if (selectedCells.current && selectedCells.current.size > 0) {
1271
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1272
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1273
+ }
1274
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1275
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1276
+ }
1277
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1278
+ selectedCells.current = newSelectedCells;
1279
+ rowsSelected.current = new Set([`${row}-${col}`]);
1280
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1281
+ (0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
1282
+ (0, _hooks.addClassCellIndexSelected)(new Set([`${row}-${col}`]), id);
1116
1283
  };
1117
- const handleMouseEnterColIndex = (row, col, e) => {
1284
+ const handleMouseEnterRowHeader = (row, col, e) => {
1118
1285
  // dừng sự kiện kéo để chọn từ các column khác khi vừa gặp column index
1119
1286
  if (isSelecting) {
1120
1287
  startCell.current = null;
@@ -1138,8 +1305,18 @@ const GridEdit = props => {
1138
1305
  newSelectedCells.add(`${r}-${c}`);
1139
1306
  }
1140
1307
  }
1141
- setRowsSelected(newSelectedRows);
1142
- setSelectedCells(newSelectedCells);
1308
+ if (selectedCells.current && selectedCells.current.size > 0) {
1309
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1310
+ }
1311
+ // setSelectedCells(newSelectedCells)
1312
+ selectedCells.current = newSelectedCells;
1313
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1314
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1315
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1316
+ }
1317
+ // setRowsSelected(newSelectedRows)
1318
+ rowsSelected.current = newSelectedRows;
1319
+ (0, _hooks.addClassCellIndexSelected)(newSelectedRows, id);
1143
1320
  };
1144
1321
  const handleCellClick = (indexRow, record, column) => {
1145
1322
  const cellClickCallback = newOptions => {
@@ -1169,7 +1346,7 @@ const GridEdit = props => {
1169
1346
  }
1170
1347
  };
1171
1348
  const handleCopy = e => {
1172
- const selectedArray = Array.from(selectedCells).map(key => {
1349
+ const selectedArray = Array.from(selectedCells.current).map(key => {
1173
1350
  const [row, col] = key.split("-").map(Number);
1174
1351
  // @ts-ignore
1175
1352
  const columnKey = (0, _hooks.editAbleColumns)(columns)[col - 1].field;
@@ -1511,9 +1688,6 @@ const GridEdit = props => {
1511
1688
  indexRow,
1512
1689
  key
1513
1690
  } = args;
1514
-
1515
- // const newRecord = getValues()
1516
-
1517
1691
  if (changeType === 'enter') {}
1518
1692
  if (changeType === 'blur') {
1519
1693
  const handleChangeCallback = callbackData => {
@@ -1534,7 +1708,7 @@ const GridEdit = props => {
1534
1708
  indexRow,
1535
1709
  rowData: record,
1536
1710
  rowId: key,
1537
- rowsData: [],
1711
+ rowsData: [...dataSource],
1538
1712
  sumValue: []
1539
1713
  }, handleChangeCallback);
1540
1714
  } else {
@@ -1547,7 +1721,7 @@ const GridEdit = props => {
1547
1721
  indexRow,
1548
1722
  rowData: record,
1549
1723
  rowId: key,
1550
- rowsData: [],
1724
+ rowsData: [...dataSource],
1551
1725
  sumValue: []
1552
1726
  }, handleChangeCallback);
1553
1727
  onSubmit(record);
@@ -1580,35 +1754,17 @@ const GridEdit = props => {
1580
1754
  // }
1581
1755
  });
1582
1756
  }
1583
-
1584
- // columns.forEach(column => {
1585
- //
1586
- // const dateFormat = getDatepickerFormat(editType, column)
1587
- //
1588
- // // @ts-ignore
1589
- // if ((column.editType === 'date' || column.editType === 'datetime') && record[column.dataIndex]) {
1590
- //
1591
- // // @ts-ignore
1592
- // formattedRecord[column.dataIndex] = !isEmpty(record[column.dataIndex]) ? convertDateToDayjs(new Date(record[column.dataIndex]), dateFormat) : null
1593
- // }
1594
- //
1595
- // });
1596
-
1597
1757
  if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
1598
1758
  setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
1599
- // setValue(col.dataIndex, e.key)
1600
1759
  }
1601
1760
  if (editType === 'select') {
1602
1761
  // setSearchValue(e.key)
1603
1762
  // setOpen(true)
1604
1763
  }
1605
- if (startSelectedCells?.row !== undefined && startSelectedCells?.col !== undefined) {
1764
+ if (startSelectedCells.current && startSelectedCells.current.row !== undefined && startSelectedCells.current.col !== undefined) {
1606
1765
  setTimeout(() => {
1607
- // const input = document.querySelector(`.ui-rc-table-row[data-row-key="${selectedCell.row}"] .cell-editing[data-col-index="${selectedCell.col}"] input`) as HTMLInputElement;
1608
- const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${startSelectedCells.row}"].cell-editing[data-col-index="${startSelectedCells.col}"] input`);
1609
- // const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
1610
-
1611
- const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells?.col}"] .ant-select-selection-search input`);
1766
+ 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`);
1767
+ const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells.current.col}"] .ant-select-selection-search input`);
1612
1768
  if (input) {
1613
1769
  input.focus();
1614
1770
  }
@@ -1660,11 +1816,25 @@ const GridEdit = props => {
1660
1816
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1661
1817
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
1662
1818
  const updateSelection = () => {
1663
- setStartSelectedCell({
1819
+ // setStartSelectedCell({ row: rowIndex, col: colIndex });
1820
+ startSelectedCells.current = {
1664
1821
  row: rowIndex,
1665
1822
  col: colIndex
1666
- });
1667
- setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1823
+ };
1824
+ // setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1825
+
1826
+ const cells = new Set([`${rowIndex}-${colIndex}`]);
1827
+ if (selectedCells.current && selectedCells.current.size > 0) {
1828
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1829
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1830
+ }
1831
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1832
+ selectedCells.current = cells;
1833
+ setTimeout(() => {
1834
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
1835
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1836
+ }, 50);
1837
+ (0, _hooks.showDraggingPoint)(cells, id);
1668
1838
  };
1669
1839
  const focusNextCell = (editingCell, cellEditable) => {
1670
1840
  if (isEdit) {
@@ -1711,62 +1881,18 @@ const GridEdit = props => {
1711
1881
  focusNextCell(cellEdit, cell);
1712
1882
  }
1713
1883
  };
1714
- const getCellClass = (record, rowIndex, colIndex) => {
1715
- const cellKey = `${rowIndex}-${colIndex}`;
1716
- const topCellKey = `${rowIndex + 1}-${colIndex}`;
1717
- const leftCellKey = `${rowIndex}-${colIndex + 1}`;
1718
- const rightCellKey = `${rowIndex}-${colIndex - 1}`;
1719
- const isSelected = selectedCells.has(cellKey);
1720
- const isTopSelected = selectedCells.has(topCellKey);
1721
- const isLeftSelected = selectedCells.has(leftCellKey);
1722
- const isRightSelected = selectedCells.has(rightCellKey);
1723
- const topPasteCellKey = `${rowIndex + 1}-${colIndex}`;
1724
- const isPasteSelected = pasteCells.has(cellKey);
1725
- const isPasteTopSelected = pasteCells.has(topPasteCellKey);
1726
- const isPasteLeftSelected = pasteCells.has(leftCellKey);
1727
- const isPasteRightSelected = pasteCells.has(rightCellKey);
1728
- const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
1729
- const prevRecordEditing = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowIndex + 1];
1730
- const cellStart = (0, _hooks.getFirstSelectCell)(selectedCells);
1731
- const cellEnd = (0, _hooks.getLastSelectCell)(selectedCells);
1732
- const cellPasteStart = (0, _hooks.getFirstSelectCell)(pasteCells);
1733
- const cellPasteSEnd = (0, _hooks.getLastSelectCell)(pasteCells);
1734
- const isPasteBottom = cellPasteSEnd.row > cellStart.row && pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
1735
-
1736
- // const rowSelectedFirst = getFirstSelectCell(selectedCells).row
1737
- // const rowPasteLast = getLastSelectCell(pasteCells).row
1738
-
1739
- if (!isSelected && !isPasteSelected) {
1740
- // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1741
- const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && (0, _hooks.isTopMostInRegion)(rowIndex + 1, colIndex, selectedCells);
1742
- const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1743
- const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1744
- const isPasteTop = cellPasteSEnd.row < cellStart.row && (0, _hooks.isTopMostInRegion)(rowIndex + 1, colIndex, pasteCells);
1745
- const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1746
- const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1747
- return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected || isPasteTopSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''} ${isPasteTop ? `cell-paste-border-top` : ''}` : cellClass;
1748
- }
1749
- const isBottom = (0, _hooks.isBottomMostInRegion)(rowIndex, colIndex, selectedCells);
1750
- // const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
1751
-
1752
- // const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col)
1753
- const isRight = (0, _hooks.isRightMostInRegion)(rowIndex, colIndex, selectedCells);
1754
- const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col);
1755
- const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col);
1756
- const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1757
- return `${cellClass} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isPasteSelected && isPasteRight ? `cell-paste-border-right` : ''} ${isPasteSelected && isPasteLeft ? `fixed-cell-paste-border-left` : ''} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : ''} ${isLeft ? `fixed-cell-border-left` : ''} ${isBottom && isRight ? `cell-border-end` : ''}`;
1758
- };
1759
1884
  const convertColumns = (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1760
1885
  if (!column?.field && !column?.key) {
1761
1886
  return column;
1762
1887
  }
1763
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
1888
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
1764
1889
  return {
1765
1890
  ...column,
1766
- className: 'rc-ui-cell-editable',
1891
+ className: 'rc-ui-cell-editable rc-ui-cell-index',
1767
1892
  onCell: (record, rowIndex) => {
1768
1893
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1769
1894
  return {
1895
+ 'data-row-index': rowNumber,
1770
1896
  onPaste: event => {
1771
1897
  if (editingKey === '') {
1772
1898
  handlePaste(record, colIndex + 1, rowNumber, event);
@@ -1790,13 +1916,9 @@ const GridEdit = props => {
1790
1916
  render: (value, record) => {
1791
1917
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1792
1918
  return /*#__PURE__*/_react.default.createElement("div", {
1793
- className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {
1794
- selected: rowsSelected.has(`${rowNumber}-${colIndex}`),
1795
- focus: selectedCells && Array.from(selectedCells).some(item => item.startsWith(`${rowNumber}-`))
1796
- }),
1797
- onMouseDown: event => handleMouseDownColIndex(rowNumber, colIndex, event),
1798
- onMouseEnter: event => handleMouseEnterColIndex(rowNumber, colIndex, event),
1799
- onClick: () => handleClickRowHeader(rowNumber, colIndex),
1919
+ className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {}),
1920
+ onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
1921
+ onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event),
1800
1922
  onMouseUp: handleMouseUp
1801
1923
  }, /*#__PURE__*/_react.default.createElement("div", {
1802
1924
  className: 'ui-rc_content'
@@ -1816,16 +1938,16 @@ const GridEdit = props => {
1816
1938
  return {
1817
1939
  onKeyDown: event => {
1818
1940
  const key = getRowKey(record, dataSource.indexOf(record));
1819
- if (event.key === 'Control' && event.ctrlKey) {
1820
-
1821
- // setIsCtrlDown(true)
1822
- } else {
1941
+ if (event.key === 'Control' && event.ctrlKey) {} else {
1823
1942
  if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
1824
1943
  if (record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
1825
1944
  // ~~ khi editingKey = ''
1826
1945
  event.preventDefault();
1827
1946
  event.stopPropagation();
1828
1947
  handleEdit(record, column, column.editType, event);
1948
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1949
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1950
+ selectedCells.current = new Set();
1829
1951
  handleCellClick(rowNumber, record, column);
1830
1952
  const hasKey = mergedExpandedKeys.has(key);
1831
1953
  if (hasKey) {
@@ -1867,7 +1989,7 @@ const GridEdit = props => {
1867
1989
  }
1868
1990
  }
1869
1991
  if (event.key === 'ArrowLeft' && colIndex > 0) {
1870
- if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
1992
+ if (!column.dataIndex && !column.key || column.field === '#' || column.dataIndex === '#') {
1871
1993
  event.stopPropagation();
1872
1994
  event.preventDefault();
1873
1995
  } else {
@@ -1898,13 +2020,6 @@ const GridEdit = props => {
1898
2020
  }
1899
2021
  }
1900
2022
  },
1901
- // onKeyUp: (event: any) => {
1902
- // if (event.key === 'Control' && event.ctrlKey) {
1903
- //
1904
- // console.log('onKeyUp')
1905
- // }
1906
- // },
1907
-
1908
2023
  onPaste: event => {
1909
2024
  if (editingKey === '') {
1910
2025
  handlePaste(record, colIndex, rowNumber, event);
@@ -1920,6 +2035,8 @@ const GridEdit = props => {
1920
2035
  onDoubleClick: event => {
1921
2036
  if (!isEditing(record) && record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
1922
2037
  handleEdit(record, column, (0, _hooks.getEditType)(column, record), event);
2038
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
2039
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1923
2040
  handleCellClick(rowNumber, record, column);
1924
2041
  }
1925
2042
  },
@@ -1928,12 +2045,15 @@ const GridEdit = props => {
1928
2045
  // startCell.current = { row: rowNumber, col: colIndex };
1929
2046
 
1930
2047
  if (selectedCells.size === 0) {
1931
- setStartSelectedCell({
2048
+ // setStartSelectedCell({ row: rowNumber, col: colIndex })
2049
+ // setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
2050
+
2051
+ startSelectedCells.current = {
1932
2052
  row: rowNumber,
1933
2053
  col: colIndex
1934
- });
1935
- setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
1936
- setRowsSelected(new Set());
2054
+ };
2055
+ selectedCells.current = new Set([`${rowNumber}-${colIndex}`]);
2056
+ rowsSelected.current = new Set();
1937
2057
  }
1938
2058
  },
1939
2059
  onClick: () => {
@@ -1941,12 +2061,13 @@ const GridEdit = props => {
1941
2061
  setEditingKey('');
1942
2062
  }
1943
2063
  },
1944
- // className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
1945
- className: getCellClass(record, rowNumber, colIndex),
2064
+ className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
1946
2065
  record,
1947
2066
  column: column,
1948
2067
  editType: (0, _hooks.getEditType)(column, record),
1949
2068
  dataIndex: column.dataIndex,
2069
+ indexRow: rowNumber,
2070
+ indexCol: colIndex,
1950
2071
  title: (0, _columns.getValueCell)(column, record[column.field], format),
1951
2072
  'data-col-index': colIndex,
1952
2073
  'data-row-index': rowNumber,
@@ -1957,7 +2078,6 @@ const GridEdit = props => {
1957
2078
  editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
1958
2079
  cellEditing,
1959
2080
  t,
1960
- // editing: isEditing(record) && rowEditable?.(record) !== false,
1961
2081
  tabIndex: (rowIndex ?? 0) * columns.length + colIndex,
1962
2082
  style: isPasteDragging ? {
1963
2083
  cursor: "crosshair"
@@ -1991,14 +2111,18 @@ const GridEdit = props => {
1991
2111
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1992
2112
  return /*#__PURE__*/_react.default.createElement("div", {
1993
2113
  className: (0, _classnames.default)('ui-rc_cell-content', {
1994
- // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
1995
- // selected: selectedCells.has(`${rowNumber}-${colIndex}`) || currentCtrlCells.has(`${rowNumber}-${colIndex}`) || mergedSets([selectedCells, ...ctrlCells]).has(`${rowNumber}-${colIndex}`),
1996
- selected: selectedCells.has(`${rowNumber}-${colIndex}`),
1997
- disable: !(0, _hooks.isEditable)(column, record)
2114
+ // disable: !isEditable(column as any, record)
1998
2115
  }),
1999
2116
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2000
2117
  onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
2001
- onMouseUp: handleMouseUp
2118
+ onMouseUp: handleMouseUp,
2119
+ onMouseMove: () => {
2120
+ if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
2121
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
2122
+ isDragMouse.current = true;
2123
+ }
2124
+ }
2125
+
2002
2126
  // onClick={(event) => {
2003
2127
  //
2004
2128
  // handleClickCell(event)
@@ -2006,18 +2130,19 @@ const GridEdit = props => {
2006
2130
  // }}
2007
2131
  }, /*#__PURE__*/_react.default.createElement("div", {
2008
2132
  className: 'ui-rc_content'
2009
- }, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && (0, _hooks.isEditable)(column, record) && !isSelectDragging && rowIndex !== dataSource.length - 1 &&
2010
- /*#__PURE__*/
2011
- // showDraggingPoint &&
2012
- _react.default.createElement("div", {
2013
- className: 'dragging-point'
2014
- // onMouseEnter={(event) => handlePointEnter(event)}
2015
- // onMouseLeave={() => handlePointLeave()}
2016
- ,
2133
+ }, (0, _columns.renderContent)(column, value, record, rowIndex, column.format ? typeof column.format === 'function' ? column.format(record) : column.format : format)),
2134
+ // selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
2135
+ // getLastSelectCell(selectedCells.current).col === colIndex &&
2136
+ // isEditable(column as any, record) &&
2137
+
2138
+ !isDragMouse.current && /*#__PURE__*/_react.default.createElement("div", {
2139
+ className: 'dragging-point hidden',
2017
2140
  onMouseDown: e => {
2018
2141
  // e.stopPropagation()
2019
2142
  e.preventDefault();
2020
- setIsPasteDragging(true);
2143
+ if (e.button === 0) {
2144
+ setIsPasteDragging(true);
2145
+ }
2021
2146
  },
2022
2147
  onDoubleClick: handlePointDoubleClick
2023
2148
  }, /*#__PURE__*/_react.default.createElement("span", {
@@ -2071,9 +2196,6 @@ const GridEdit = props => {
2071
2196
  }
2072
2197
  }));
2073
2198
  };
2074
- const onSelectChange = keys => {
2075
- setMergedSelectedKeys(keys);
2076
- };
2077
2199
  const contextMenuClick = args => {
2078
2200
  if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
2079
2201
  if (args.item.key === 'INSERT_BEFORE_ADV') {
@@ -2131,12 +2253,11 @@ const GridEdit = props => {
2131
2253
  setRowsAdd(val);
2132
2254
  };
2133
2255
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
2134
- heightTable: height,
2256
+ $heightTable: height,
2135
2257
  style: {
2136
2258
  position: 'relative'
2137
2259
  },
2138
2260
  ref: ref
2139
- // onMouseUp={handleMouseUp}
2140
2261
  }, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
2141
2262
  value: {
2142
2263
  rowKey,
@@ -2176,9 +2297,7 @@ const GridEdit = props => {
2176
2297
  components: {
2177
2298
  ...components,
2178
2299
  body: {
2179
- // wrapper: () => <div></div>,
2180
2300
  cell: _EditableCell.default
2181
- // cell: () => <EditableCell />,
2182
2301
  }
2183
2302
  },
2184
2303
  className: (0, _classnames.default)(className, 'grid-editable'),
@@ -2194,9 +2313,11 @@ const GridEdit = props => {
2194
2313
  ,
2195
2314
  selectionSettings: selectionSettings ? {
2196
2315
  ...selectionSettings,
2197
- checkboxOnly: true
2316
+ checkboxOnly: true,
2317
+ arrowKey: false
2198
2318
  } : {
2199
- checkboxOnly: true
2319
+ checkboxOnly: true,
2320
+ arrowKey: false
2200
2321
  },
2201
2322
  rowHoverable: false,
2202
2323
  bottomToolbar: bottomToolbar,
@@ -2238,25 +2359,27 @@ const GridEdit = props => {
2238
2359
  },
2239
2360
  triggerChangeColumns: triggerChangeColumns,
2240
2361
  clickHeaderToSort: false,
2241
- rowSelection: columns && columns.length === 0 ? undefined : {
2242
- type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
2243
- columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
2244
- onChange: onSelectChange,
2245
- selectedRowKeys: mergedSelectedKeys,
2246
- preserveSelectedRowKeys: true
2247
- },
2248
2362
  isFilter: isFilter,
2249
2363
  setIsFilter: setIsFilter,
2250
2364
  contextMenuItems: contextMenuItems,
2251
- contextMenuClick: contextMenuClick
2365
+ contextMenuClick: contextMenuClick,
2366
+ onScroll: () => {
2367
+ if (selectedCells.current && selectedCells.current.size > 0) {
2368
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
2369
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
2370
+ (0, _hooks.showDraggingPoint)(selectedCells.current, id);
2371
+ }
2372
+ if (rowsSelected && rowsSelected.current.size > 0) {
2373
+ (0, _hooks.addClassCellIndexSelected)(rowsSelected.current, id);
2374
+ }
2375
+ }
2252
2376
  })))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
2253
2377
  position: toast,
2254
2378
  toastOptions: {
2255
2379
  className: 'react-hot-toast'
2256
2380
  }
2257
- }), /*#__PURE__*/_react.default.createElement(_antd.Modal
2258
- // title="Thêm dòng"
2259
- , {
2381
+ }), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
2382
+ title: "Th\xEAm d\xF2ng",
2260
2383
  open: openModalAddRow.open,
2261
2384
  onOk: onOkAddRow,
2262
2385
  onCancel: hideModalAddRow,