es-grid-template 1.3.6 → 1.3.7

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.
@@ -13,21 +13,13 @@ import dayjs from "dayjs";
13
13
  import 'dayjs/locale/es';
14
14
  import 'dayjs/locale/vi';
15
15
  import TableGrid from "../TableGrid";
16
- import { addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex,
17
- // isBottomMostInRanges,
18
- isBottomMostInRegion,
19
- // isContinuous,
20
- isEditable,
21
- // isEqualSet,
22
- isObjEmpty, isRightMostInRegion, isTopMostInRegion,
23
- // mergedSets,
24
- newGuid, sortedSetASC, totalFixedWidth, updateArrayByKey } from "../hooks";
16
+ import { addClassBorderPasteCell, addClassCellIndexSelected, addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex, hideDraggingPoint, isEditable, isEqualSet, isObjEmpty, newGuid, onAddClassBgSelectedCell, onRemoveClassSelectedCell, removeClassBorderPasteCell, removeClassCellIndexSelected, showDraggingPoint, sortedSetASC, totalFixedWidth, updateArrayByKey } from "../hooks";
25
17
  import Message from "../../Message/Message";
26
18
  // import Command from "../Command";
27
19
 
28
20
  import { Toolbar, ConfigProvider, InputNumber } from "rc-master-ui";
29
21
  import classnames from "classnames";
30
- import useMergedState from "rc-util/es/hooks/useMergedState";
22
+ // import useMergedState from "rc-util/lib/hooks/useMergedState";
31
23
  import { Plus, Trash2 } from "becoxy-icons";
32
24
  // import type {ContextMenuItem} from "../type";
33
25
  // import {ContextInfo, ContextMenuItem} from "../type";
@@ -117,6 +109,7 @@ const defaultContext = [{
117
109
  }];
118
110
  const GridEdit = props => {
119
111
  const {
112
+ // id = newGuid(),
120
113
  id,
121
114
  tableRef,
122
115
  t,
@@ -145,21 +138,36 @@ const GridEdit = props => {
145
138
  showDefaultContext,
146
139
  ...rest
147
140
  } = props;
148
- const {
149
- mode,
150
- type,
151
- // checkboxOnly,
152
- // hideSelectAll,
153
- columnWidth
154
- // selectedRowKeys,
155
- // defaultSelectedRowKeys
156
- } = selectionSettings || {};
141
+
142
+ // const {
143
+ // mode,
144
+ // type,
145
+ // checkboxOnly,
146
+ // hideSelectAll,
147
+ // columnWidth,
148
+ // selectedRowKeys,
149
+ // defaultSelectedRowKeys
150
+ // } = selectionSettings || {}
151
+
157
152
  const ref = useRef(null);
158
153
  const isSelecting = useRef(false);
159
154
  const startCell = useRef(null);
160
155
  const childrenColumnName = 'children';
161
156
  const isSelectingRow = useRef(false);
162
157
  const rowStart = useRef(null);
158
+ const rowsSelected = useRef(new Set());
159
+ const selectedCells = useRef(new Set());
160
+ const pasteCells = useRef(new Set());
161
+ const startSelectedCells = useRef(null);
162
+
163
+ // quét vùng chọn
164
+ const isDragMouse = useRef(false);
165
+ const isMouseDown = useRef(false);
166
+
167
+ // quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
168
+ // const isPasteDragging = useRef(false);
169
+
170
+ // const isPointEnter = useRef(false);
163
171
 
164
172
  // const [getRecordByKey] = useLazyKVMap(dataSource, childrenColumnName, getRowKey);
165
173
 
@@ -176,7 +184,9 @@ const GridEdit = props => {
176
184
  const [form] = Form.useForm();
177
185
  const [editingKey, setEditingKey] = useState('');
178
186
  const [isFilter, setIsFilter] = React.useState(false);
179
- const [selectedCells, setSelectedCells] = useState(new Set());
187
+
188
+ // const [selectedCells, setSelectedCells] = useState(new Set())
189
+ // const [pasteCells, setPasteCells] = useState(new Set())
180
190
 
181
191
  // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
182
192
 
@@ -189,16 +199,17 @@ const GridEdit = props => {
189
199
  open: false,
190
200
  type: ''
191
201
  });
192
- // const [openModalPaste, setOpenModalPaste] = useState(defaultModalPaste)
193
-
194
202
  const [rowsAdd, setRowsAdd] = useState(1);
195
- const [pasteCells, setPasteCells] = useState(new Set());
196
203
  const [cellEditing, setCellEditing] = useState(null);
197
- const [isSelectDragging, setSelectIsDragging] = useState(false);
204
+
205
+ // const [isSelectDragging, setSelectIsDragging] = useState(false)
206
+
198
207
  const [isPasteDragging, setIsPasteDragging] = useState(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
199
208
 
200
- const [rowsSelected, setRowsSelected] = useState(new Set());
201
- const [startSelectedCells, setStartSelectedCell] = useState(null);
209
+ // const [rowsSelected, setRowsSelected] = useState(new Set())
210
+
211
+ // const [startSelectedCells, setStartSelectedCell] = useState<{ row: number; col: number } | null>(null)
212
+
202
213
  const [innerExpandedKeys, setInnerExpandedKeys] = React.useState(() => {
203
214
  // if (defaultExpandedRowKeys) {
204
215
  // return defaultExpandedRowKeys;
@@ -209,11 +220,16 @@ const GridEdit = props => {
209
220
  // return [];
210
221
  });
211
222
  const mergedExpandedKeys = React.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
212
- const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState([], {
213
- value: []
214
- });
223
+
224
+ // const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState<any[]>(
225
+ // [],
226
+ // {
227
+ // value: [],
228
+ // },
229
+ // );
230
+
215
231
  const rowsFocus = React.useMemo(() => {
216
- return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
232
+ return [...new Set(Array.from(selectedCells.current).map(item => parseInt(item.split('-')[0])))] ?? [];
217
233
  }, [selectedCells]);
218
234
  const contextMenuItems = React.useMemo(() => {
219
235
  const a = showDefaultContext !== false ? [...defaultContext] : [];
@@ -505,14 +521,14 @@ const GridEdit = props => {
505
521
  triggerChangeData?.([], 'INSERT_BEFORE');
506
522
  };
507
523
  const handleDeleteContent = () => {
508
- if (selectedCells.size > 0) {
524
+ if (selectedCells.current.size > 0) {
509
525
  const newData = [...dataSource];
510
526
 
511
527
  // colIndex => field
512
528
  const colIndexToField = flatColumns2(columns).map(col => col.field);
513
529
 
514
530
  // Duyệt qua mỗi ô cần xóa
515
- for (const cell of selectedCells) {
531
+ for (const cell of selectedCells.current) {
516
532
  const [rowIndexStr, colIndexStr] = cell.split("-");
517
533
  const rowIndex = Number(rowIndexStr);
518
534
  const colIndex = Number(colIndexStr);
@@ -777,8 +793,13 @@ const GridEdit = props => {
777
793
  setEditingKey('');
778
794
  isSelecting.current = false;
779
795
  startCell.current = null;
780
- setSelectedCells(new Set());
781
- setRowsSelected(new Set());
796
+ // setSelectedCells(new Set())
797
+ // setRowsSelected(new Set())
798
+
799
+ onRemoveClassSelectedCell(selectedCells.current, id);
800
+ hideDraggingPoint(selectedCells.current, id);
801
+ rowsSelected.current = new Set();
802
+ selectedCells.current = new Set();
782
803
  }
783
804
 
784
805
  // if (tableBodies.length > 0) {
@@ -805,6 +826,9 @@ const GridEdit = props => {
805
826
  e.stopPropagation();
806
827
  return;
807
828
  }
829
+
830
+ // isDragMouse.current = true
831
+ isMouseDown.current = true;
808
832
  if (e.ctrlKey) {
809
833
  isSelecting.current = true;
810
834
  startCell.current = {
@@ -821,43 +845,43 @@ const GridEdit = props => {
821
845
  row,
822
846
  col
823
847
  };
824
- if (e.target.className === 'dragging-point') {
825
- // e.stopPropagation()
826
- // e.preventDefault()
848
+ const target = e.target;
849
+ if (target.closest('.dragging-point')) {
850
+ e.stopPropagation();
851
+ e.preventDefault();
852
+ return; // Không xử lý gì cả
827
853
  } else {
828
- setStartSelectedCell({
854
+ // setStartSelectedCell({row, col})
855
+
856
+ startSelectedCells.current = {
829
857
  row,
830
858
  col
831
- });
832
- setSelectedCells(new Set([`${row}-${col}`]));
833
- setRowsSelected(new Set());
859
+ };
860
+
861
+ // setSelectedCells(new Set([`${row}-${col}`]));
862
+
863
+ const cells = new Set([`${row}-${col}`]);
864
+ if (selectedCells.current && selectedCells.current.size > 0) {
865
+ onRemoveClassSelectedCell(selectedCells.current, id);
866
+ if (!isEqualSet(cells, selectedCells.current)) {
867
+ hideDraggingPoint(selectedCells.current, id);
868
+ }
869
+ }
870
+ selectedCells.current = cells;
871
+ onAddClassBgSelectedCell(cells, id);
872
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
873
+ removeClassCellIndexSelected(rowsSelected.current, id);
874
+ }
875
+ // setRowsSelected(new Set())
876
+ rowsSelected.current = new Set();
834
877
  }
835
878
  }
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
879
  };
850
880
  const triggerDragPaste = pastesArray => {
851
- const mergedSet = new Set([...selectedCells, ...pastesArray]);
852
-
853
- // console.log('pastesArray', pastesArray)
854
- // console.log('selectedCells', selectedCells)
855
-
856
- setSelectedCells(sortedSetASC(mergedSet));
857
- setPasteCells(new Set());
858
- const rowSelectedFirst = getFirstSelectCell(selectedCells).row;
859
- const rowPasteLast = getLastSelectCell(pasteCells).row;
860
- const selectedArray = Array.from(selectedCells).map(key => {
881
+ const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
882
+ const rowSelectedFirst = getFirstSelectCell(selectedCells.current).row;
883
+ const rowPasteLast = getLastSelectCell(pasteCells.current).row;
884
+ const selectedArray = Array.from(selectedCells.current).map(key => {
861
885
  const [row, col] = key.split("-").map(Number);
862
886
  // @ts-ignore
863
887
  const columnKey = columns[col].field;
@@ -871,6 +895,35 @@ const GridEdit = props => {
871
895
  // return { row, col, value: '' };
872
896
  });
873
897
 
898
+ // let selectedArray = []
899
+ //
900
+ // if (rowPasteLast > rowSelectedFirst) {
901
+ // // kéo xuóng
902
+ // selectedArray = Array.from(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
+ // } else {
913
+ // // kéo lên
914
+ //
915
+ // selectedArray = Array.from(sortedSetDSC(selectedCells)).map((key: any) => {
916
+ //
917
+ // const [row, col] = key.split("-").map(Number);
918
+ // // @ts-ignore
919
+ // const columnKey = columns[col].field;
920
+ //
921
+ // // @ts-ignore
922
+ // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
923
+ // // return { row, col, value: '' };
924
+ // });
925
+ // }
926
+
874
927
  // Xác định min/max row và col để sắp xếp dữ liệu
875
928
  const minRow = Math.min(...selectedArray.map(cell => cell.row));
876
929
  const maxRow = Math.max(...selectedArray.map(cell => cell.row));
@@ -909,7 +962,7 @@ const GridEdit = props => {
909
962
  // Lấy vị trí bắt đầu
910
963
  // const { row: startRow, col: startCol } = selectedCell;
911
964
  const startRow = getFirstSelectCell(pastesArray).row;
912
- const startCol = getFirstSelectCell(selectedCells).col;
965
+ const startCol = getFirstSelectCell(selectedCells.current).col;
913
966
  const pastedRows = [];
914
967
  const pastedColumns = new Set();
915
968
  newRange.addedRows.forEach((rowValues, rowIndex) => {
@@ -947,19 +1000,38 @@ const GridEdit = props => {
947
1000
  const pastedColumnsArray = Array.from(pastedColumns) ?? [];
948
1001
  triggerPaste?.(pastedRows, pastedColumnsArray, newData);
949
1002
  }
1003
+
1004
+ /// cập nhật cell class
1005
+ if (selectedCells.current && selectedCells.current.size > 0) {
1006
+ onRemoveClassSelectedCell(selectedCells.current, id);
1007
+ }
1008
+
1009
+ // selectedCells.current = sortedSetASC(mergedSet)
1010
+ hideDraggingPoint(selectedCells.current, id);
1011
+ selectedCells.current = sortedSetASC(mergedSet);
1012
+ onAddClassBgSelectedCell(sortedSetASC(mergedSet), id);
1013
+ showDraggingPoint(sortedSetASC(mergedSet), id);
1014
+
1015
+ // setPasteCells(new Set())
1016
+
1017
+ if (pasteCells.current && pasteCells.current.size > 0) {
1018
+ removeClassBorderPasteCell(pasteCells.current, 'up', id);
1019
+ }
1020
+ pasteCells.current = new Set();
950
1021
  };
951
1022
  const handlePointDoubleClick = e => {
952
- e.preventDefault();
1023
+ // e.preventDefault()
953
1024
  e.stopPropagation();
954
- const colStart = getFirstSelectCell(selectedCells).col;
955
- const colEnd = getLastSelectCell(selectedCells).col;
956
- const startPasteRow = getLastSelectCell(selectedCells).row;
1025
+ const colStart = getFirstSelectCell(selectedCells.current).col;
1026
+ const colEnd = getLastSelectCell(selectedCells.current).col;
1027
+ const startPasteRow = getLastSelectCell(selectedCells.current).row;
957
1028
  const newPasteCells = new Set();
958
1029
  for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
959
1030
  for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
960
1031
  newPasteCells.add(`${r}-${c}`);
961
1032
  }
962
1033
  }
1034
+ hideDraggingPoint(selectedCells.current, id);
963
1035
  triggerDragPaste(newPasteCells);
964
1036
  };
965
1037
 
@@ -988,8 +1060,12 @@ const GridEdit = props => {
988
1060
  startCell.current = null;
989
1061
  isSelectingRow.current = false;
990
1062
  rowStart.current = null;
1063
+ isDragMouse.current = false;
1064
+ isMouseDown.current = false;
991
1065
  setIsPasteDragging(false);
992
- setSelectIsDragging(false);
1066
+
1067
+ // isPasteDragging.current = false
1068
+ // setSelectIsDragging(false);
993
1069
 
994
1070
  // setCurrentCtrlCells(new Set())
995
1071
 
@@ -1000,10 +1076,30 @@ const GridEdit = props => {
1000
1076
 
1001
1077
  // nếu ctrlCell length > 0 thì set selectCells
1002
1078
 
1003
- if (pasteCells.size > 0) {
1004
- triggerDragPaste(pasteCells);
1079
+ if (pasteCells && pasteCells.current.size > 0) {
1080
+ triggerDragPaste(pasteCells.current);
1081
+ } else {
1082
+ const target = e.target;
1083
+ if (target.closest('.dragging-point')) {
1084
+ e.stopPropagation();
1085
+ e.preventDefault();
1086
+ return; // Không xử lý gì cả
1087
+ }
1088
+ if (selectedCells.current && selectedCells.current.size > 0) {
1089
+ hideDraggingPoint(selectedCells.current, id);
1090
+ }
1091
+ showDraggingPoint(selectedCells.current, id);
1005
1092
  }
1006
1093
  };
1094
+
1095
+ // const handlePointEnter = () => {
1096
+ // isPointEnter.current = true;
1097
+ // }
1098
+ //
1099
+ // const handlePointLeave = () => {
1100
+ // isPointEnter.current = false;
1101
+ // }
1102
+
1007
1103
  const handleMouseEnter = (row, col, e) => {
1008
1104
  if (!isSelecting.current || !startCell.current) {
1009
1105
  return;
@@ -1027,29 +1123,41 @@ const GridEdit = props => {
1027
1123
  if (!isPasteDragging) {
1028
1124
  // chọn vùng copy
1029
1125
 
1030
- setSelectIsDragging(true);
1126
+ // setSelectIsDragging(true)
1127
+
1031
1128
  setIsPasteDragging(false);
1129
+ // isPasteDragging.current = false
1130
+
1032
1131
  const newSelectedCells = new Set();
1033
1132
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1034
1133
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1035
1134
  newSelectedCells.add(`${r}-${c}`);
1036
1135
  }
1037
1136
  }
1038
- setSelectedCells(newSelectedCells);
1137
+
1138
+ // setSelectedCells(newSelectedCells)
1139
+
1140
+ if (selectedCells.current && selectedCells.current.size > 0) {
1141
+ onRemoveClassSelectedCell(selectedCells.current, id);
1142
+ }
1143
+ selectedCells.current = newSelectedCells;
1144
+ onAddClassBgSelectedCell(newSelectedCells, id);
1039
1145
  } else {
1040
1146
  // chọn vùng paste
1041
1147
 
1042
- setSelectIsDragging(false);
1043
- setIsPasteDragging(true);
1148
+ // setSelectIsDragging(false)
1149
+
1150
+ // setIsPasteDragging(true) ////////
1151
+
1044
1152
  const newSelectedCells = new Set();
1045
1153
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1046
1154
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1047
1155
  newSelectedCells.add(`${r}-${c}`);
1048
1156
  }
1049
1157
  }
1050
- const colStart = getFirstSelectCell(selectedCells).col;
1051
- const colEnd = getLastSelectCell(selectedCells).col;
1052
- const rowSelectedEnd = getLastSelectCell(selectedCells).row;
1158
+ const colStart = getFirstSelectCell(selectedCells.current).col;
1159
+ const colEnd = getLastSelectCell(selectedCells.current).col;
1160
+ const rowSelectedEnd = getLastSelectCell(selectedCells.current).row;
1053
1161
  if (row >= rowSelectedEnd) {
1054
1162
  // kéo xuống dưới
1055
1163
 
@@ -1059,12 +1167,19 @@ const GridEdit = props => {
1059
1167
  newPasteCells.add(`${r}-${c}`);
1060
1168
  }
1061
1169
  }
1062
- setPasteCells(newPasteCells);
1170
+
1171
+ // setPasteCells(newPasteCells)
1172
+
1173
+ if (pasteCells.current && pasteCells.current.size > 0) {
1174
+ removeClassBorderPasteCell(pasteCells.current, 'down', id);
1175
+ }
1176
+ pasteCells.current = newPasteCells;
1177
+ addClassBorderPasteCell(newPasteCells, 'down', id);
1063
1178
  }
1064
1179
  if (row < rowSelectedEnd) {
1065
1180
  // kéo lên trên
1066
1181
 
1067
- const rowSelectedStart = getFirstSelectCell(selectedCells).row;
1182
+ const rowSelectedStart = getFirstSelectCell(selectedCells.current).row;
1068
1183
  if (row < rowSelectedStart) {
1069
1184
  const newPasteCells = new Set();
1070
1185
  for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
@@ -1072,7 +1187,14 @@ const GridEdit = props => {
1072
1187
  newPasteCells.add(`${r}-${c}`);
1073
1188
  }
1074
1189
  }
1075
- setPasteCells(newPasteCells);
1190
+
1191
+ // setPasteCells(newPasteCells)
1192
+
1193
+ if (pasteCells.current && pasteCells.current.size > 0) {
1194
+ removeClassBorderPasteCell(pasteCells.current, 'up', id);
1195
+ }
1196
+ pasteCells.current = newPasteCells;
1197
+ addClassBorderPasteCell(newPasteCells, 'up', id);
1076
1198
  }
1077
1199
  }
1078
1200
  if (col > colEnd) {
@@ -1083,16 +1205,32 @@ const GridEdit = props => {
1083
1205
  }
1084
1206
  }
1085
1207
  };
1086
- const handleClickRowHeader = (row, col) => {
1087
- const newSelectedCells = new Set();
1088
- const tCols = 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
- };
1208
+
1209
+ // const handleClickRowHeader = (row: any, col: any) => {
1210
+ //
1211
+ // const newSelectedCells = new Set()
1212
+ //
1213
+ // const tCols = editAbleColumns(columns)
1214
+ //
1215
+ // for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1216
+ // for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1217
+ // newSelectedCells.add(`${r}-${c}`)
1218
+ // }
1219
+ // }
1220
+ //
1221
+ // // setSelectedCells(newSelectedCells)
1222
+ //
1223
+ // if (selectedCells.current && selectedCells.current.size > 0) {
1224
+ // onRemoveClassSelectedCell(selectedCells.current, id)
1225
+ // }
1226
+ //
1227
+ // selectedCells.current = newSelectedCells
1228
+ //
1229
+ // onAddClassBgSelectedCell(newSelectedCells, id)
1230
+ //
1231
+ //
1232
+ // };
1233
+
1096
1234
  const handleClickColHeader = (column, indexColumn) => {
1097
1235
  const newSelectedCells = new Set();
1098
1236
  for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
@@ -1100,9 +1238,21 @@ const GridEdit = props => {
1100
1238
  newSelectedCells.add(`${r}-${c}`);
1101
1239
  }
1102
1240
  }
1103
- setSelectedCells(new Set(newSelectedCells));
1241
+
1242
+ // setSelectedCells(new Set(newSelectedCells));
1243
+
1244
+ if (selectedCells.current && selectedCells.current.size > 0) {
1245
+ onRemoveClassSelectedCell(selectedCells.current, id);
1246
+ }
1247
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1248
+ removeClassCellIndexSelected(rowsSelected.current, id);
1249
+ }
1250
+ selectedCells.current = newSelectedCells;
1251
+ onAddClassBgSelectedCell(newSelectedCells, id);
1252
+ hideDraggingPoint(selectedCells.current, id);
1253
+ showDraggingPoint(newSelectedCells, id);
1104
1254
  };
1105
- const handleMouseDownColIndex = (row, col, e) => {
1255
+ const handleMouseDownRowHeader = (row, col, column, e) => {
1106
1256
  if (e.button === 2) {
1107
1257
  e.stopPropagation();
1108
1258
  return;
@@ -1112,9 +1262,30 @@ const GridEdit = props => {
1112
1262
  row,
1113
1263
  col
1114
1264
  };
1115
- setRowsSelected(new Set([`${row}-${col}`]));
1265
+ const newSelectedCells = new Set();
1266
+ const tCols = editAbleColumns(columns);
1267
+ for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1268
+ for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1269
+ newSelectedCells.add(`${r}-${c}`);
1270
+ }
1271
+ }
1272
+
1273
+ // setSelectedCells(newSelectedCells)
1274
+ // setRowsSelected(new Set([`${row}-${col}`]));
1275
+
1276
+ if (selectedCells.current && selectedCells.current.size > 0) {
1277
+ onRemoveClassSelectedCell(selectedCells.current, id);
1278
+ }
1279
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1280
+ removeClassCellIndexSelected(rowsSelected.current, id);
1281
+ }
1282
+ hideDraggingPoint(selectedCells.current, id);
1283
+ selectedCells.current = newSelectedCells;
1284
+ rowsSelected.current = new Set([`${row}-${col}`]);
1285
+ onAddClassBgSelectedCell(newSelectedCells, id);
1286
+ addClassCellIndexSelected(new Set([`${row}-${col}`]), id);
1116
1287
  };
1117
- const handleMouseEnterColIndex = (row, col, e) => {
1288
+ const handleMouseEnterRowHeader = (row, col, e) => {
1118
1289
  // dừng sự kiện kéo để chọn từ các column khác khi vừa gặp column index
1119
1290
  if (isSelecting) {
1120
1291
  startCell.current = null;
@@ -1138,8 +1309,18 @@ const GridEdit = props => {
1138
1309
  newSelectedCells.add(`${r}-${c}`);
1139
1310
  }
1140
1311
  }
1141
- setRowsSelected(newSelectedRows);
1142
- setSelectedCells(newSelectedCells);
1312
+ if (selectedCells.current && selectedCells.current.size > 0) {
1313
+ onRemoveClassSelectedCell(selectedCells.current, id);
1314
+ }
1315
+ // setSelectedCells(newSelectedCells)
1316
+ selectedCells.current = newSelectedCells;
1317
+ onAddClassBgSelectedCell(newSelectedCells, id);
1318
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1319
+ removeClassCellIndexSelected(rowsSelected.current, id);
1320
+ }
1321
+ // setRowsSelected(newSelectedRows)
1322
+ rowsSelected.current = newSelectedRows;
1323
+ addClassCellIndexSelected(newSelectedRows, id);
1143
1324
  };
1144
1325
  const handleCellClick = (indexRow, record, column) => {
1145
1326
  const cellClickCallback = newOptions => {
@@ -1169,7 +1350,7 @@ const GridEdit = props => {
1169
1350
  }
1170
1351
  };
1171
1352
  const handleCopy = e => {
1172
- const selectedArray = Array.from(selectedCells).map(key => {
1353
+ const selectedArray = Array.from(selectedCells.current).map(key => {
1173
1354
  const [row, col] = key.split("-").map(Number);
1174
1355
  // @ts-ignore
1175
1356
  const columnKey = editAbleColumns(columns)[col - 1].field;
@@ -1534,7 +1715,7 @@ const GridEdit = props => {
1534
1715
  indexRow,
1535
1716
  rowData: record,
1536
1717
  rowId: key,
1537
- rowsData: [],
1718
+ rowsData: [...dataSource],
1538
1719
  sumValue: []
1539
1720
  }, handleChangeCallback);
1540
1721
  } else {
@@ -1547,7 +1728,7 @@ const GridEdit = props => {
1547
1728
  indexRow,
1548
1729
  rowData: record,
1549
1730
  rowId: key,
1550
- rowsData: [],
1731
+ rowsData: [...dataSource],
1551
1732
  sumValue: []
1552
1733
  }, handleChangeCallback);
1553
1734
  onSubmit(record);
@@ -1580,20 +1761,6 @@ const GridEdit = props => {
1580
1761
  // }
1581
1762
  });
1582
1763
  }
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
1764
  if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
1598
1765
  setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
1599
1766
  // setValue(col.dataIndex, e.key)
@@ -1602,13 +1769,13 @@ const GridEdit = props => {
1602
1769
  // setSearchValue(e.key)
1603
1770
  // setOpen(true)
1604
1771
  }
1605
- if (startSelectedCells?.row !== undefined && startSelectedCells?.col !== undefined) {
1772
+ if (startSelectedCells.current && startSelectedCells.current.row !== undefined && startSelectedCells.current.col !== undefined) {
1606
1773
  setTimeout(() => {
1607
1774
  // 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`);
1775
+ 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`);
1609
1776
  // const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
1610
1777
 
1611
- const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells?.col}"] .ant-select-selection-search input`);
1778
+ const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells.current.col}"] .ant-select-selection-search input`);
1612
1779
  if (input) {
1613
1780
  input.focus();
1614
1781
  }
@@ -1660,11 +1827,24 @@ const GridEdit = props => {
1660
1827
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1661
1828
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
1662
1829
  const updateSelection = () => {
1663
- setStartSelectedCell({
1830
+ // setStartSelectedCell({ row: rowIndex, col: colIndex });
1831
+ startSelectedCells.current = {
1664
1832
  row: rowIndex,
1665
1833
  col: colIndex
1666
- });
1667
- setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1834
+ };
1835
+ // setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1836
+
1837
+ const cells = new Set([`${rowIndex}-${colIndex}`]);
1838
+ console.log('cells', cells);
1839
+ if (selectedCells.current && selectedCells.current.size > 0) {
1840
+ onRemoveClassSelectedCell(selectedCells.current, id);
1841
+ }
1842
+ hideDraggingPoint(selectedCells.current, id);
1843
+ selectedCells.current = cells;
1844
+ setTimeout(() => {
1845
+ onAddClassBgSelectedCell(selectedCells.current, id);
1846
+ }, 10);
1847
+ showDraggingPoint(cells, id);
1668
1848
  };
1669
1849
  const focusNextCell = (editingCell, cellEditable) => {
1670
1850
  if (isEdit) {
@@ -1711,62 +1891,88 @@ const GridEdit = props => {
1711
1891
  focusNextCell(cellEdit, cell);
1712
1892
  }
1713
1893
  };
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 = flattenData(childrenColumnName, dataSource)[rowIndex + 1];
1730
- const cellStart = getFirstSelectCell(selectedCells);
1731
- const cellEnd = getLastSelectCell(selectedCells);
1732
- const cellPasteStart = getFirstSelectCell(pasteCells);
1733
- const cellPasteSEnd = 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) && 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 && 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 = 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 = 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
- };
1894
+
1895
+ // const getCellClass = (record: RecordType, rowIndex: number, colIndex: number) => {
1896
+ //
1897
+ //
1898
+ // const cellKey = `${rowIndex}-${colIndex}`;
1899
+ // const topCellKey = `${rowIndex + 1}-${colIndex}`;
1900
+ // const leftCellKey = `${rowIndex}-${colIndex + 1}`;
1901
+ // const rightCellKey = `${rowIndex}-${colIndex - 1}`;
1902
+ //
1903
+ // const isSelected = selectedCells.has(cellKey);
1904
+ // const isTopSelected = selectedCells.has(topCellKey);
1905
+ // const isLeftSelected = selectedCells.has(leftCellKey);
1906
+ // const isRightSelected = selectedCells.has(rightCellKey);
1907
+ //
1908
+ //
1909
+ // const isPasteSelected = pasteCells.has(cellKey);
1910
+ // const isPasteLeftSelected = pasteCells.has(leftCellKey);
1911
+ // const isPasteRightSelected = pasteCells.has(rightCellKey);
1912
+ //
1913
+ // const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable'
1914
+ //
1915
+ // const prevRecordEditing = flattenData(childrenColumnName, dataSource)[rowIndex + 1]
1916
+ //
1917
+ // const cellStart = getFirstSelectCell(selectedCells)
1918
+ // const cellEnd = getLastSelectCell(selectedCells)
1919
+ //
1920
+ // const cellPasteStart = getFirstSelectCell(pasteCells)
1921
+ // const cellPasteSEnd = getLastSelectCell(pasteCells)
1922
+ //
1923
+ //
1924
+ // const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row)
1925
+ //
1926
+ //
1927
+ // if (!isSelected && !isPasteSelected){
1928
+ //
1929
+ // // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1930
+ // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && isTopMostInRegion(rowIndex + 1, colIndex, selectedCells)
1931
+ //
1932
+ // const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1933
+ // const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1934
+ //
1935
+ // const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1936
+ // const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1937
+ //
1938
+ //
1939
+ // return (isTopSelected || isLeftSelected || isRightSelected ) ?
1940
+ // `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` :
1941
+ //
1942
+ // (isPasteLeftSelected || isPasteRightSelected) ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` :
1943
+ //
1944
+ // cellClass
1945
+ //
1946
+ // }
1947
+ //
1948
+ // const isBottom = isBottomMostInRegion(rowIndex, colIndex, selectedCells)
1949
+ // // const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
1950
+ //
1951
+ // // const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col)
1952
+ // const isRight = isRightMostInRegion(rowIndex, colIndex, selectedCells)
1953
+ //
1954
+ // const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col)
1955
+ //
1956
+ // const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col)
1957
+ // const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col)
1958
+ //
1959
+ //
1960
+ // 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` : '' }`
1961
+ //
1962
+ // };
1963
+
1759
1964
  const convertColumns = flatColumns2(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1760
1965
  if (!column?.field && !column?.key) {
1761
1966
  return column;
1762
1967
  }
1763
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
1968
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
1764
1969
  return {
1765
1970
  ...column,
1766
- className: 'rc-ui-cell-editable',
1971
+ className: 'rc-ui-cell-editable rc-ui-cell-index',
1767
1972
  onCell: (record, rowIndex) => {
1768
1973
  const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
1769
1974
  return {
1975
+ 'data-row-index': rowNumber,
1770
1976
  onPaste: event => {
1771
1977
  if (editingKey === '') {
1772
1978
  handlePaste(record, colIndex + 1, rowNumber, event);
@@ -1791,12 +1997,16 @@ const GridEdit = props => {
1791
1997
  const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
1792
1998
  return /*#__PURE__*/React.createElement("div", {
1793
1999
  className: classNames('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}-`))
2000
+
2001
+ // selected: rowsSelected.has(`${rowNumber}-${colIndex}`) ,
2002
+
2003
+ // focus: selectedCells && Array.from(selectedCells).some((item: any) => item.startsWith(`${rowNumber}-`))
1796
2004
  }),
1797
- onMouseDown: event => handleMouseDownColIndex(rowNumber, colIndex, event),
1798
- onMouseEnter: event => handleMouseEnterColIndex(rowNumber, colIndex, event),
1799
- onClick: () => handleClickRowHeader(rowNumber, colIndex),
2005
+ onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
2006
+ onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event)
2007
+
2008
+ // onClick={() => handleClickRowHeader(rowNumber, colIndex)}
2009
+ ,
1800
2010
  onMouseUp: handleMouseUp
1801
2011
  }, /*#__PURE__*/React.createElement("div", {
1802
2012
  className: 'ui-rc_content'
@@ -1826,6 +2036,7 @@ const GridEdit = props => {
1826
2036
  event.preventDefault();
1827
2037
  event.stopPropagation();
1828
2038
  handleEdit(record, column, column.editType, event);
2039
+ onRemoveClassSelectedCell(selectedCells.current, id);
1829
2040
  handleCellClick(rowNumber, record, column);
1830
2041
  const hasKey = mergedExpandedKeys.has(key);
1831
2042
  if (hasKey) {
@@ -1867,7 +2078,7 @@ const GridEdit = props => {
1867
2078
  }
1868
2079
  }
1869
2080
  if (event.key === 'ArrowLeft' && colIndex > 0) {
1870
- if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
2081
+ if (!column.dataIndex && !column.key || column.field === '#' || column.dataIndex === '#') {
1871
2082
  event.stopPropagation();
1872
2083
  event.preventDefault();
1873
2084
  } else {
@@ -1898,13 +2109,6 @@ const GridEdit = props => {
1898
2109
  }
1899
2110
  }
1900
2111
  },
1901
- // onKeyUp: (event: any) => {
1902
- // if (event.key === 'Control' && event.ctrlKey) {
1903
- //
1904
- // console.log('onKeyUp')
1905
- // }
1906
- // },
1907
-
1908
2112
  onPaste: event => {
1909
2113
  if (editingKey === '') {
1910
2114
  handlePaste(record, colIndex, rowNumber, event);
@@ -1928,12 +2132,15 @@ const GridEdit = props => {
1928
2132
  // startCell.current = { row: rowNumber, col: colIndex };
1929
2133
 
1930
2134
  if (selectedCells.size === 0) {
1931
- setStartSelectedCell({
2135
+ // setStartSelectedCell({ row: rowNumber, col: colIndex })
2136
+ // setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
2137
+
2138
+ startSelectedCells.current = {
1932
2139
  row: rowNumber,
1933
2140
  col: colIndex
1934
- });
1935
- setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
1936
- setRowsSelected(new Set());
2141
+ };
2142
+ selectedCells.current = new Set([`${rowNumber}-${colIndex}`]);
2143
+ rowsSelected.current = new Set();
1937
2144
  }
1938
2145
  },
1939
2146
  onClick: () => {
@@ -1941,12 +2148,14 @@ const GridEdit = props => {
1941
2148
  setEditingKey('');
1942
2149
  }
1943
2150
  },
1944
- // className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
1945
- className: getCellClass(record, rowNumber, colIndex),
2151
+ className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!isEditable(column, record) ? 'disable' : ''}`,
2152
+ // className: getCellClass(record, rowNumber, colIndex),
1946
2153
  record,
1947
2154
  column: column,
1948
2155
  editType: getEditType(column, record),
1949
2156
  dataIndex: column.dataIndex,
2157
+ indexRow: rowNumber,
2158
+ indexCol: colIndex,
1950
2159
  title: getValueCell(column, record[column.field], format),
1951
2160
  'data-col-index': colIndex,
1952
2161
  'data-row-index': rowNumber,
@@ -1962,6 +2171,8 @@ const GridEdit = props => {
1962
2171
  style: isPasteDragging ? {
1963
2172
  cursor: "crosshair"
1964
2173
  } : {}
2174
+
2175
+ // style: getStyle()
1965
2176
  };
1966
2177
  },
1967
2178
  onHeaderCell: (data, index) => {
@@ -1993,12 +2204,19 @@ const GridEdit = props => {
1993
2204
  className: classNames('ui-rc_cell-content', {
1994
2205
  // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
1995
2206
  // selected: selectedCells.has(`${rowNumber}-${colIndex}`) || currentCtrlCells.has(`${rowNumber}-${colIndex}`) || mergedSets([selectedCells, ...ctrlCells]).has(`${rowNumber}-${colIndex}`),
1996
- selected: selectedCells.has(`${rowNumber}-${colIndex}`),
1997
- disable: !isEditable(column, record)
2207
+ // selected: selectedCells.has(`${rowNumber}-${colIndex}`),
2208
+ // disable: !isEditable(column as any, record)
1998
2209
  }),
1999
2210
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2000
2211
  onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
2001
- onMouseUp: handleMouseUp
2212
+ onMouseUp: handleMouseUp,
2213
+ onMouseMove: () => {
2214
+ if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
2215
+ hideDraggingPoint(selectedCells.current, id);
2216
+ isDragMouse.current = true;
2217
+ }
2218
+ }
2219
+
2002
2220
  // onClick={(event) => {
2003
2221
  //
2004
2222
  // handleClickCell(event)
@@ -2006,18 +2224,21 @@ const GridEdit = props => {
2006
2224
  // }}
2007
2225
  }, /*#__PURE__*/React.createElement("div", {
2008
2226
  className: 'ui-rc_content'
2009
- }, renderContent(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && getLastSelectCell(selectedCells).row === rowNumber && getLastSelectCell(selectedCells).col === colIndex && isEditable(column, record) && !isSelectDragging && rowIndex !== dataSource.length - 1 &&
2010
- /*#__PURE__*/
2011
- // showDraggingPoint &&
2012
- React.createElement("div", {
2013
- className: 'dragging-point'
2014
- // onMouseEnter={(event) => handlePointEnter(event)}
2015
- // onMouseLeave={() => handlePointLeave()}
2016
- ,
2227
+ }, renderContent(column, value, record, rowIndex, format)),
2228
+ // selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
2229
+ // getLastSelectCell(selectedCells.current).col === colIndex &&
2230
+ // isEditable(column as any, record) &&
2231
+
2232
+ !isDragMouse.current && /*#__PURE__*/React.createElement("div", {
2233
+ className: 'dragging-point hidden',
2017
2234
  onMouseDown: e => {
2018
2235
  // e.stopPropagation()
2019
2236
  e.preventDefault();
2020
- setIsPasteDragging(true);
2237
+ if (e.button === 0) {
2238
+ setIsPasteDragging(true);
2239
+
2240
+ // isPasteDragging.current = true
2241
+ }
2021
2242
  },
2022
2243
  onDoubleClick: handlePointDoubleClick
2023
2244
  }, /*#__PURE__*/React.createElement("span", {
@@ -2071,9 +2292,13 @@ const GridEdit = props => {
2071
2292
  }
2072
2293
  }));
2073
2294
  };
2074
- const onSelectChange = keys => {
2075
- setMergedSelectedKeys(keys);
2076
- };
2295
+ //
2296
+ // const onSelectChange = (keys: any[]) => {
2297
+ //
2298
+ // console.log(keys)
2299
+ // setMergedSelectedKeys(keys)
2300
+ // }
2301
+
2077
2302
  const contextMenuClick = args => {
2078
2303
  if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
2079
2304
  if (args.item.key === 'INSERT_BEFORE_ADV') {
@@ -2131,7 +2356,7 @@ const GridEdit = props => {
2131
2356
  setRowsAdd(val);
2132
2357
  };
2133
2358
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
2134
- heightTable: height,
2359
+ $heightTable: height,
2135
2360
  style: {
2136
2361
  position: 'relative'
2137
2362
  },
@@ -2194,9 +2419,11 @@ const GridEdit = props => {
2194
2419
  ,
2195
2420
  selectionSettings: selectionSettings ? {
2196
2421
  ...selectionSettings,
2197
- checkboxOnly: true
2422
+ checkboxOnly: true,
2423
+ arrowKey: false
2198
2424
  } : {
2199
- checkboxOnly: true
2425
+ checkboxOnly: true,
2426
+ arrowKey: false
2200
2427
  },
2201
2428
  rowHoverable: false,
2202
2429
  bottomToolbar: bottomToolbar,
@@ -2237,18 +2464,33 @@ const GridEdit = props => {
2237
2464
  }
2238
2465
  },
2239
2466
  triggerChangeColumns: triggerChangeColumns,
2240
- 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
- },
2467
+ clickHeaderToSort: false
2468
+
2469
+ // rowSelection={ columns && columns.length === 0 ? undefined : {
2470
+ // type: mode,
2471
+ // columnWidth: columnWidth ?? 50 ,
2472
+ // onChange: onSelectChange,
2473
+ //
2474
+ // selectedRowKeys: mergedSelectedKeys,
2475
+ // preserveSelectedRowKeys: true,
2476
+ // arrowKey: false
2477
+ //
2478
+ // }}
2479
+ ,
2480
+
2248
2481
  isFilter: isFilter,
2249
2482
  setIsFilter: setIsFilter,
2250
2483
  contextMenuItems: contextMenuItems,
2251
- contextMenuClick: contextMenuClick
2484
+ contextMenuClick: contextMenuClick,
2485
+ onScroll: () => {
2486
+ if (selectedCells.current && selectedCells.current.size > 0) {
2487
+ onAddClassBgSelectedCell(selectedCells.current, id);
2488
+ showDraggingPoint(selectedCells.current, id);
2489
+ }
2490
+ if (rowsSelected && rowsSelected.current.size > 0) {
2491
+ addClassCellIndexSelected(rowsSelected.current, id);
2492
+ }
2493
+ }
2252
2494
  })))))), /*#__PURE__*/React.createElement(Toaster, {
2253
2495
  position: toast,
2254
2496
  toastOptions: {