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.
@@ -23,12 +23,13 @@ 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");
28
27
  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
28
  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
29
  // import Command from "../Command";
31
30
 
31
+ // import useMergedState from "rc-util/lib/hooks/useMergedState";
32
+
32
33
  // import type {ContextMenuItem} from "../type";
33
34
  // import {ContextInfo, ContextMenuItem} from "../type";
34
35
  // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
@@ -117,6 +118,7 @@ const defaultContext = [{
117
118
  }];
118
119
  const GridEdit = props => {
119
120
  const {
121
+ // id = newGuid(),
120
122
  id,
121
123
  tableRef,
122
124
  t,
@@ -145,21 +147,36 @@ const GridEdit = props => {
145
147
  showDefaultContext,
146
148
  ...rest
147
149
  } = props;
148
- const {
149
- mode,
150
- type,
151
- // checkboxOnly,
152
- // hideSelectAll,
153
- columnWidth
154
- // selectedRowKeys,
155
- // defaultSelectedRowKeys
156
- } = selectionSettings || {};
150
+
151
+ // const {
152
+ // mode,
153
+ // type,
154
+ // checkboxOnly,
155
+ // hideSelectAll,
156
+ // columnWidth,
157
+ // selectedRowKeys,
158
+ // defaultSelectedRowKeys
159
+ // } = selectionSettings || {}
160
+
157
161
  const ref = (0, _react.useRef)(null);
158
162
  const isSelecting = (0, _react.useRef)(false);
159
163
  const startCell = (0, _react.useRef)(null);
160
164
  const childrenColumnName = 'children';
161
165
  const isSelectingRow = (0, _react.useRef)(false);
162
166
  const rowStart = (0, _react.useRef)(null);
167
+ const rowsSelected = (0, _react.useRef)(new Set());
168
+ const selectedCells = (0, _react.useRef)(new Set());
169
+ const pasteCells = (0, _react.useRef)(new Set());
170
+ const startSelectedCells = (0, _react.useRef)(null);
171
+
172
+ // quét vùng chọn
173
+ const isDragMouse = (0, _react.useRef)(false);
174
+ const isMouseDown = (0, _react.useRef)(false);
175
+
176
+ // quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
177
+ // const isPasteDragging = useRef(false);
178
+
179
+ // const isPointEnter = useRef(false);
163
180
 
164
181
  // const [getRecordByKey] = useLazyKVMap(dataSource, childrenColumnName, getRowKey);
165
182
 
@@ -176,7 +193,9 @@ const GridEdit = props => {
176
193
  const [form] = _antd.Form.useForm();
177
194
  const [editingKey, setEditingKey] = (0, _react.useState)('');
178
195
  const [isFilter, setIsFilter] = _react.default.useState(false);
179
- const [selectedCells, setSelectedCells] = (0, _react.useState)(new Set());
196
+
197
+ // const [selectedCells, setSelectedCells] = useState(new Set())
198
+ // const [pasteCells, setPasteCells] = useState(new Set())
180
199
 
181
200
  // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
182
201
 
@@ -189,16 +208,17 @@ const GridEdit = props => {
189
208
  open: false,
190
209
  type: ''
191
210
  });
192
- // const [openModalPaste, setOpenModalPaste] = useState(defaultModalPaste)
193
-
194
211
  const [rowsAdd, setRowsAdd] = (0, _react.useState)(1);
195
- const [pasteCells, setPasteCells] = (0, _react.useState)(new Set());
196
212
  const [cellEditing, setCellEditing] = (0, _react.useState)(null);
197
- const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
213
+
214
+ // const [isSelectDragging, setSelectIsDragging] = useState(false)
215
+
198
216
  const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
199
217
 
200
- const [rowsSelected, setRowsSelected] = (0, _react.useState)(new Set());
201
- const [startSelectedCells, setStartSelectedCell] = (0, _react.useState)(null);
218
+ // const [rowsSelected, setRowsSelected] = useState(new Set())
219
+
220
+ // const [startSelectedCells, setStartSelectedCell] = useState<{ row: number; col: number } | null>(null)
221
+
202
222
  const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
203
223
  // if (defaultExpandedRowKeys) {
204
224
  // return defaultExpandedRowKeys;
@@ -209,11 +229,16 @@ const GridEdit = props => {
209
229
  // return [];
210
230
  });
211
231
  const mergedExpandedKeys = _react.default.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
212
- const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)([], {
213
- value: []
214
- });
232
+
233
+ // const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState<any[]>(
234
+ // [],
235
+ // {
236
+ // value: [],
237
+ // },
238
+ // );
239
+
215
240
  const rowsFocus = _react.default.useMemo(() => {
216
- return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
241
+ return [...new Set(Array.from(selectedCells.current).map(item => parseInt(item.split('-')[0])))] ?? [];
217
242
  }, [selectedCells]);
218
243
  const contextMenuItems = _react.default.useMemo(() => {
219
244
  const a = showDefaultContext !== false ? [...defaultContext] : [];
@@ -505,14 +530,14 @@ const GridEdit = props => {
505
530
  triggerChangeData?.([], 'INSERT_BEFORE');
506
531
  };
507
532
  const handleDeleteContent = () => {
508
- if (selectedCells.size > 0) {
533
+ if (selectedCells.current.size > 0) {
509
534
  const newData = [...dataSource];
510
535
 
511
536
  // colIndex => field
512
537
  const colIndexToField = (0, _columns.flatColumns2)(columns).map(col => col.field);
513
538
 
514
539
  // Duyệt qua mỗi ô cần xóa
515
- for (const cell of selectedCells) {
540
+ for (const cell of selectedCells.current) {
516
541
  const [rowIndexStr, colIndexStr] = cell.split("-");
517
542
  const rowIndex = Number(rowIndexStr);
518
543
  const colIndex = Number(colIndexStr);
@@ -777,8 +802,13 @@ const GridEdit = props => {
777
802
  setEditingKey('');
778
803
  isSelecting.current = false;
779
804
  startCell.current = null;
780
- setSelectedCells(new Set());
781
- setRowsSelected(new Set());
805
+ // setSelectedCells(new Set())
806
+ // setRowsSelected(new Set())
807
+
808
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
809
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
810
+ rowsSelected.current = new Set();
811
+ selectedCells.current = new Set();
782
812
  }
783
813
 
784
814
  // if (tableBodies.length > 0) {
@@ -805,6 +835,9 @@ const GridEdit = props => {
805
835
  e.stopPropagation();
806
836
  return;
807
837
  }
838
+
839
+ // isDragMouse.current = true
840
+ isMouseDown.current = true;
808
841
  if (e.ctrlKey) {
809
842
  isSelecting.current = true;
810
843
  startCell.current = {
@@ -821,43 +854,43 @@ const GridEdit = props => {
821
854
  row,
822
855
  col
823
856
  };
824
- if (e.target.className === 'dragging-point') {
825
- // e.stopPropagation()
826
- // e.preventDefault()
857
+ const target = e.target;
858
+ if (target.closest('.dragging-point')) {
859
+ e.stopPropagation();
860
+ e.preventDefault();
861
+ return; // Không xử lý gì cả
827
862
  } else {
828
- setStartSelectedCell({
863
+ // setStartSelectedCell({row, col})
864
+
865
+ startSelectedCells.current = {
829
866
  row,
830
867
  col
831
- });
832
- setSelectedCells(new Set([`${row}-${col}`]));
833
- setRowsSelected(new Set());
868
+ };
869
+
870
+ // setSelectedCells(new Set([`${row}-${col}`]));
871
+
872
+ const cells = new Set([`${row}-${col}`]);
873
+ if (selectedCells.current && selectedCells.current.size > 0) {
874
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
875
+ if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
876
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
877
+ }
878
+ }
879
+ selectedCells.current = cells;
880
+ (0, _hooks.onAddClassBgSelectedCell)(cells, id);
881
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
882
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
883
+ }
884
+ // setRowsSelected(new Set())
885
+ rowsSelected.current = new Set();
834
886
  }
835
887
  }
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
888
  };
850
889
  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 => {
890
+ const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
891
+ const rowSelectedFirst = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
892
+ const rowPasteLast = (0, _hooks.getLastSelectCell)(pasteCells.current).row;
893
+ const selectedArray = Array.from(selectedCells.current).map(key => {
861
894
  const [row, col] = key.split("-").map(Number);
862
895
  // @ts-ignore
863
896
  const columnKey = columns[col].field;
@@ -871,6 +904,35 @@ const GridEdit = props => {
871
904
  // return { row, col, value: '' };
872
905
  });
873
906
 
907
+ // let selectedArray = []
908
+ //
909
+ // if (rowPasteLast > rowSelectedFirst) {
910
+ // // kéo xuóng
911
+ // selectedArray = Array.from(selectedCells).map((key: any) => {
912
+ //
913
+ // const [row, col] = key.split("-").map(Number);
914
+ // // @ts-ignore
915
+ // const columnKey = columns[col].field;
916
+ //
917
+ // // @ts-ignore
918
+ // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
919
+ // // return { row, col, value: '' };
920
+ // });
921
+ // } else {
922
+ // // kéo lên
923
+ //
924
+ // selectedArray = Array.from(sortedSetDSC(selectedCells)).map((key: any) => {
925
+ //
926
+ // const [row, col] = key.split("-").map(Number);
927
+ // // @ts-ignore
928
+ // const columnKey = columns[col].field;
929
+ //
930
+ // // @ts-ignore
931
+ // return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
932
+ // // return { row, col, value: '' };
933
+ // });
934
+ // }
935
+
874
936
  // Xác định min/max row và col để sắp xếp dữ liệu
875
937
  const minRow = Math.min(...selectedArray.map(cell => cell.row));
876
938
  const maxRow = Math.max(...selectedArray.map(cell => cell.row));
@@ -909,7 +971,7 @@ const GridEdit = props => {
909
971
  // Lấy vị trí bắt đầu
910
972
  // const { row: startRow, col: startCol } = selectedCell;
911
973
  const startRow = (0, _hooks.getFirstSelectCell)(pastesArray).row;
912
- const startCol = (0, _hooks.getFirstSelectCell)(selectedCells).col;
974
+ const startCol = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
913
975
  const pastedRows = [];
914
976
  const pastedColumns = new Set();
915
977
  newRange.addedRows.forEach((rowValues, rowIndex) => {
@@ -947,19 +1009,38 @@ const GridEdit = props => {
947
1009
  const pastedColumnsArray = Array.from(pastedColumns) ?? [];
948
1010
  triggerPaste?.(pastedRows, pastedColumnsArray, newData);
949
1011
  }
1012
+
1013
+ /// cập nhật cell class
1014
+ if (selectedCells.current && selectedCells.current.size > 0) {
1015
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1016
+ }
1017
+
1018
+ // selectedCells.current = sortedSetASC(mergedSet)
1019
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1020
+ selectedCells.current = (0, _hooks.sortedSetASC)(mergedSet);
1021
+ (0, _hooks.onAddClassBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1022
+ (0, _hooks.showDraggingPoint)((0, _hooks.sortedSetASC)(mergedSet), id);
1023
+
1024
+ // setPasteCells(new Set())
1025
+
1026
+ if (pasteCells.current && pasteCells.current.size > 0) {
1027
+ (0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'up', id);
1028
+ }
1029
+ pasteCells.current = new Set();
950
1030
  };
951
1031
  const handlePointDoubleClick = e => {
952
- e.preventDefault();
1032
+ // e.preventDefault()
953
1033
  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;
1034
+ const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
1035
+ const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
1036
+ const startPasteRow = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
957
1037
  const newPasteCells = new Set();
958
1038
  for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
959
1039
  for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
960
1040
  newPasteCells.add(`${r}-${c}`);
961
1041
  }
962
1042
  }
1043
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
963
1044
  triggerDragPaste(newPasteCells);
964
1045
  };
965
1046
 
@@ -988,8 +1069,12 @@ const GridEdit = props => {
988
1069
  startCell.current = null;
989
1070
  isSelectingRow.current = false;
990
1071
  rowStart.current = null;
1072
+ isDragMouse.current = false;
1073
+ isMouseDown.current = false;
991
1074
  setIsPasteDragging(false);
992
- setSelectIsDragging(false);
1075
+
1076
+ // isPasteDragging.current = false
1077
+ // setSelectIsDragging(false);
993
1078
 
994
1079
  // setCurrentCtrlCells(new Set())
995
1080
 
@@ -1000,10 +1085,30 @@ const GridEdit = props => {
1000
1085
 
1001
1086
  // nếu ctrlCell length > 0 thì set selectCells
1002
1087
 
1003
- if (pasteCells.size > 0) {
1004
- triggerDragPaste(pasteCells);
1088
+ if (pasteCells && pasteCells.current.size > 0) {
1089
+ triggerDragPaste(pasteCells.current);
1090
+ } else {
1091
+ const target = e.target;
1092
+ if (target.closest('.dragging-point')) {
1093
+ e.stopPropagation();
1094
+ e.preventDefault();
1095
+ return; // Không xử lý gì cả
1096
+ }
1097
+ if (selectedCells.current && selectedCells.current.size > 0) {
1098
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1099
+ }
1100
+ (0, _hooks.showDraggingPoint)(selectedCells.current, id);
1005
1101
  }
1006
1102
  };
1103
+
1104
+ // const handlePointEnter = () => {
1105
+ // isPointEnter.current = true;
1106
+ // }
1107
+ //
1108
+ // const handlePointLeave = () => {
1109
+ // isPointEnter.current = false;
1110
+ // }
1111
+
1007
1112
  const handleMouseEnter = (row, col, e) => {
1008
1113
  if (!isSelecting.current || !startCell.current) {
1009
1114
  return;
@@ -1027,29 +1132,41 @@ const GridEdit = props => {
1027
1132
  if (!isPasteDragging) {
1028
1133
  // chọn vùng copy
1029
1134
 
1030
- setSelectIsDragging(true);
1135
+ // setSelectIsDragging(true)
1136
+
1031
1137
  setIsPasteDragging(false);
1138
+ // isPasteDragging.current = false
1139
+
1032
1140
  const newSelectedCells = new Set();
1033
1141
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1034
1142
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1035
1143
  newSelectedCells.add(`${r}-${c}`);
1036
1144
  }
1037
1145
  }
1038
- setSelectedCells(newSelectedCells);
1146
+
1147
+ // setSelectedCells(newSelectedCells)
1148
+
1149
+ if (selectedCells.current && selectedCells.current.size > 0) {
1150
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1151
+ }
1152
+ selectedCells.current = newSelectedCells;
1153
+ (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1039
1154
  } else {
1040
1155
  // chọn vùng paste
1041
1156
 
1042
- setSelectIsDragging(false);
1043
- setIsPasteDragging(true);
1157
+ // setSelectIsDragging(false)
1158
+
1159
+ // setIsPasteDragging(true) ////////
1160
+
1044
1161
  const newSelectedCells = new Set();
1045
1162
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1046
1163
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1047
1164
  newSelectedCells.add(`${r}-${c}`);
1048
1165
  }
1049
1166
  }
1050
- const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
1051
- const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
1052
- const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells).row;
1167
+ const colStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
1168
+ const colEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).col;
1169
+ const rowSelectedEnd = (0, _hooks.getLastSelectCell)(selectedCells.current).row;
1053
1170
  if (row >= rowSelectedEnd) {
1054
1171
  // kéo xuống dưới
1055
1172
 
@@ -1059,12 +1176,19 @@ const GridEdit = props => {
1059
1176
  newPasteCells.add(`${r}-${c}`);
1060
1177
  }
1061
1178
  }
1062
- setPasteCells(newPasteCells);
1179
+
1180
+ // setPasteCells(newPasteCells)
1181
+
1182
+ if (pasteCells.current && pasteCells.current.size > 0) {
1183
+ (0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'down', id);
1184
+ }
1185
+ pasteCells.current = newPasteCells;
1186
+ (0, _hooks.addClassBorderPasteCell)(newPasteCells, 'down', id);
1063
1187
  }
1064
1188
  if (row < rowSelectedEnd) {
1065
1189
  // kéo lên trên
1066
1190
 
1067
- const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells).row;
1191
+ const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
1068
1192
  if (row < rowSelectedStart) {
1069
1193
  const newPasteCells = new Set();
1070
1194
  for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
@@ -1072,7 +1196,14 @@ const GridEdit = props => {
1072
1196
  newPasteCells.add(`${r}-${c}`);
1073
1197
  }
1074
1198
  }
1075
- setPasteCells(newPasteCells);
1199
+
1200
+ // setPasteCells(newPasteCells)
1201
+
1202
+ if (pasteCells.current && pasteCells.current.size > 0) {
1203
+ (0, _hooks.removeClassBorderPasteCell)(pasteCells.current, 'up', id);
1204
+ }
1205
+ pasteCells.current = newPasteCells;
1206
+ (0, _hooks.addClassBorderPasteCell)(newPasteCells, 'up', id);
1076
1207
  }
1077
1208
  }
1078
1209
  if (col > colEnd) {
@@ -1083,16 +1214,32 @@ const GridEdit = props => {
1083
1214
  }
1084
1215
  }
1085
1216
  };
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
- };
1217
+
1218
+ // const handleClickRowHeader = (row: any, col: any) => {
1219
+ //
1220
+ // const newSelectedCells = new Set()
1221
+ //
1222
+ // const tCols = editAbleColumns(columns)
1223
+ //
1224
+ // for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1225
+ // for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1226
+ // newSelectedCells.add(`${r}-${c}`)
1227
+ // }
1228
+ // }
1229
+ //
1230
+ // // setSelectedCells(newSelectedCells)
1231
+ //
1232
+ // if (selectedCells.current && selectedCells.current.size > 0) {
1233
+ // onRemoveClassSelectedCell(selectedCells.current, id)
1234
+ // }
1235
+ //
1236
+ // selectedCells.current = newSelectedCells
1237
+ //
1238
+ // onAddClassBgSelectedCell(newSelectedCells, id)
1239
+ //
1240
+ //
1241
+ // };
1242
+
1096
1243
  const handleClickColHeader = (column, indexColumn) => {
1097
1244
  const newSelectedCells = new Set();
1098
1245
  for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
@@ -1100,9 +1247,21 @@ const GridEdit = props => {
1100
1247
  newSelectedCells.add(`${r}-${c}`);
1101
1248
  }
1102
1249
  }
1103
- setSelectedCells(new Set(newSelectedCells));
1250
+
1251
+ // setSelectedCells(new Set(newSelectedCells));
1252
+
1253
+ if (selectedCells.current && selectedCells.current.size > 0) {
1254
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1255
+ }
1256
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1257
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1258
+ }
1259
+ selectedCells.current = newSelectedCells;
1260
+ (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1261
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1262
+ (0, _hooks.showDraggingPoint)(newSelectedCells, id);
1104
1263
  };
1105
- const handleMouseDownColIndex = (row, col, e) => {
1264
+ const handleMouseDownRowHeader = (row, col, column, e) => {
1106
1265
  if (e.button === 2) {
1107
1266
  e.stopPropagation();
1108
1267
  return;
@@ -1112,9 +1271,30 @@ const GridEdit = props => {
1112
1271
  row,
1113
1272
  col
1114
1273
  };
1115
- setRowsSelected(new Set([`${row}-${col}`]));
1274
+ const newSelectedCells = new Set();
1275
+ const tCols = (0, _hooks.editAbleColumns)(columns);
1276
+ for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1277
+ for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1278
+ newSelectedCells.add(`${r}-${c}`);
1279
+ }
1280
+ }
1281
+
1282
+ // setSelectedCells(newSelectedCells)
1283
+ // setRowsSelected(new Set([`${row}-${col}`]));
1284
+
1285
+ if (selectedCells.current && selectedCells.current.size > 0) {
1286
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1287
+ }
1288
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1289
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1290
+ }
1291
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1292
+ selectedCells.current = newSelectedCells;
1293
+ rowsSelected.current = new Set([`${row}-${col}`]);
1294
+ (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1295
+ (0, _hooks.addClassCellIndexSelected)(new Set([`${row}-${col}`]), id);
1116
1296
  };
1117
- const handleMouseEnterColIndex = (row, col, e) => {
1297
+ const handleMouseEnterRowHeader = (row, col, e) => {
1118
1298
  // dừng sự kiện kéo để chọn từ các column khác khi vừa gặp column index
1119
1299
  if (isSelecting) {
1120
1300
  startCell.current = null;
@@ -1138,8 +1318,18 @@ const GridEdit = props => {
1138
1318
  newSelectedCells.add(`${r}-${c}`);
1139
1319
  }
1140
1320
  }
1141
- setRowsSelected(newSelectedRows);
1142
- setSelectedCells(newSelectedCells);
1321
+ if (selectedCells.current && selectedCells.current.size > 0) {
1322
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1323
+ }
1324
+ // setSelectedCells(newSelectedCells)
1325
+ selectedCells.current = newSelectedCells;
1326
+ (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1327
+ if (rowsSelected.current && rowsSelected.current.size > 0) {
1328
+ (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1329
+ }
1330
+ // setRowsSelected(newSelectedRows)
1331
+ rowsSelected.current = newSelectedRows;
1332
+ (0, _hooks.addClassCellIndexSelected)(newSelectedRows, id);
1143
1333
  };
1144
1334
  const handleCellClick = (indexRow, record, column) => {
1145
1335
  const cellClickCallback = newOptions => {
@@ -1169,7 +1359,7 @@ const GridEdit = props => {
1169
1359
  }
1170
1360
  };
1171
1361
  const handleCopy = e => {
1172
- const selectedArray = Array.from(selectedCells).map(key => {
1362
+ const selectedArray = Array.from(selectedCells.current).map(key => {
1173
1363
  const [row, col] = key.split("-").map(Number);
1174
1364
  // @ts-ignore
1175
1365
  const columnKey = (0, _hooks.editAbleColumns)(columns)[col - 1].field;
@@ -1534,7 +1724,7 @@ const GridEdit = props => {
1534
1724
  indexRow,
1535
1725
  rowData: record,
1536
1726
  rowId: key,
1537
- rowsData: [],
1727
+ rowsData: [...dataSource],
1538
1728
  sumValue: []
1539
1729
  }, handleChangeCallback);
1540
1730
  } else {
@@ -1547,7 +1737,7 @@ const GridEdit = props => {
1547
1737
  indexRow,
1548
1738
  rowData: record,
1549
1739
  rowId: key,
1550
- rowsData: [],
1740
+ rowsData: [...dataSource],
1551
1741
  sumValue: []
1552
1742
  }, handleChangeCallback);
1553
1743
  onSubmit(record);
@@ -1580,20 +1770,6 @@ const GridEdit = props => {
1580
1770
  // }
1581
1771
  });
1582
1772
  }
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
1773
  if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
1598
1774
  setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
1599
1775
  // setValue(col.dataIndex, e.key)
@@ -1602,13 +1778,13 @@ const GridEdit = props => {
1602
1778
  // setSearchValue(e.key)
1603
1779
  // setOpen(true)
1604
1780
  }
1605
- if (startSelectedCells?.row !== undefined && startSelectedCells?.col !== undefined) {
1781
+ if (startSelectedCells.current && startSelectedCells.current.row !== undefined && startSelectedCells.current.col !== undefined) {
1606
1782
  setTimeout(() => {
1607
1783
  // 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`);
1784
+ 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
1785
  // const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
1610
1786
 
1611
- const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells?.col}"] .ant-select-selection-search input`);
1787
+ const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells.current.col}"] .ant-select-selection-search input`);
1612
1788
  if (input) {
1613
1789
  input.focus();
1614
1790
  }
@@ -1660,11 +1836,24 @@ const GridEdit = props => {
1660
1836
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1661
1837
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
1662
1838
  const updateSelection = () => {
1663
- setStartSelectedCell({
1839
+ // setStartSelectedCell({ row: rowIndex, col: colIndex });
1840
+ startSelectedCells.current = {
1664
1841
  row: rowIndex,
1665
1842
  col: colIndex
1666
- });
1667
- setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1843
+ };
1844
+ // setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1845
+
1846
+ const cells = new Set([`${rowIndex}-${colIndex}`]);
1847
+ console.log('cells', cells);
1848
+ if (selectedCells.current && selectedCells.current.size > 0) {
1849
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1850
+ }
1851
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1852
+ selectedCells.current = cells;
1853
+ setTimeout(() => {
1854
+ (0, _hooks.onAddClassBgSelectedCell)(selectedCells.current, id);
1855
+ }, 10);
1856
+ (0, _hooks.showDraggingPoint)(cells, id);
1668
1857
  };
1669
1858
  const focusNextCell = (editingCell, cellEditable) => {
1670
1859
  if (isEdit) {
@@ -1711,62 +1900,88 @@ const GridEdit = props => {
1711
1900
  focusNextCell(cellEdit, cell);
1712
1901
  }
1713
1902
  };
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
- };
1903
+
1904
+ // const getCellClass = (record: RecordType, rowIndex: number, colIndex: number) => {
1905
+ //
1906
+ //
1907
+ // const cellKey = `${rowIndex}-${colIndex}`;
1908
+ // const topCellKey = `${rowIndex + 1}-${colIndex}`;
1909
+ // const leftCellKey = `${rowIndex}-${colIndex + 1}`;
1910
+ // const rightCellKey = `${rowIndex}-${colIndex - 1}`;
1911
+ //
1912
+ // const isSelected = selectedCells.has(cellKey);
1913
+ // const isTopSelected = selectedCells.has(topCellKey);
1914
+ // const isLeftSelected = selectedCells.has(leftCellKey);
1915
+ // const isRightSelected = selectedCells.has(rightCellKey);
1916
+ //
1917
+ //
1918
+ // const isPasteSelected = pasteCells.has(cellKey);
1919
+ // const isPasteLeftSelected = pasteCells.has(leftCellKey);
1920
+ // const isPasteRightSelected = pasteCells.has(rightCellKey);
1921
+ //
1922
+ // const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable'
1923
+ //
1924
+ // const prevRecordEditing = flattenData(childrenColumnName, dataSource)[rowIndex + 1]
1925
+ //
1926
+ // const cellStart = getFirstSelectCell(selectedCells)
1927
+ // const cellEnd = getLastSelectCell(selectedCells)
1928
+ //
1929
+ // const cellPasteStart = getFirstSelectCell(pasteCells)
1930
+ // const cellPasteSEnd = getLastSelectCell(pasteCells)
1931
+ //
1932
+ //
1933
+ // const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row)
1934
+ //
1935
+ //
1936
+ // if (!isSelected && !isPasteSelected){
1937
+ //
1938
+ // // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1939
+ // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && isTopMostInRegion(rowIndex + 1, colIndex, selectedCells)
1940
+ //
1941
+ // const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1942
+ // const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1943
+ //
1944
+ // const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1945
+ // const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1946
+ //
1947
+ //
1948
+ // return (isTopSelected || isLeftSelected || isRightSelected ) ?
1949
+ // `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` :
1950
+ //
1951
+ // (isPasteLeftSelected || isPasteRightSelected) ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` :
1952
+ //
1953
+ // cellClass
1954
+ //
1955
+ // }
1956
+ //
1957
+ // const isBottom = isBottomMostInRegion(rowIndex, colIndex, selectedCells)
1958
+ // // const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
1959
+ //
1960
+ // // const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col)
1961
+ // const isRight = isRightMostInRegion(rowIndex, colIndex, selectedCells)
1962
+ //
1963
+ // const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col)
1964
+ //
1965
+ // const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col)
1966
+ // const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col)
1967
+ //
1968
+ //
1969
+ // 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` : '' }`
1970
+ //
1971
+ // };
1972
+
1759
1973
  const convertColumns = (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1760
1974
  if (!column?.field && !column?.key) {
1761
1975
  return column;
1762
1976
  }
1763
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
1977
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
1764
1978
  return {
1765
1979
  ...column,
1766
- className: 'rc-ui-cell-editable',
1980
+ className: 'rc-ui-cell-editable rc-ui-cell-index',
1767
1981
  onCell: (record, rowIndex) => {
1768
1982
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1769
1983
  return {
1984
+ 'data-row-index': rowNumber,
1770
1985
  onPaste: event => {
1771
1986
  if (editingKey === '') {
1772
1987
  handlePaste(record, colIndex + 1, rowNumber, event);
@@ -1791,12 +2006,16 @@ const GridEdit = props => {
1791
2006
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1792
2007
  return /*#__PURE__*/_react.default.createElement("div", {
1793
2008
  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}-`))
2009
+
2010
+ // selected: rowsSelected.has(`${rowNumber}-${colIndex}`) ,
2011
+
2012
+ // focus: selectedCells && Array.from(selectedCells).some((item: any) => item.startsWith(`${rowNumber}-`))
1796
2013
  }),
1797
- onMouseDown: event => handleMouseDownColIndex(rowNumber, colIndex, event),
1798
- onMouseEnter: event => handleMouseEnterColIndex(rowNumber, colIndex, event),
1799
- onClick: () => handleClickRowHeader(rowNumber, colIndex),
2014
+ onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
2015
+ onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event)
2016
+
2017
+ // onClick={() => handleClickRowHeader(rowNumber, colIndex)}
2018
+ ,
1800
2019
  onMouseUp: handleMouseUp
1801
2020
  }, /*#__PURE__*/_react.default.createElement("div", {
1802
2021
  className: 'ui-rc_content'
@@ -1826,6 +2045,7 @@ const GridEdit = props => {
1826
2045
  event.preventDefault();
1827
2046
  event.stopPropagation();
1828
2047
  handleEdit(record, column, column.editType, event);
2048
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1829
2049
  handleCellClick(rowNumber, record, column);
1830
2050
  const hasKey = mergedExpandedKeys.has(key);
1831
2051
  if (hasKey) {
@@ -1867,7 +2087,7 @@ const GridEdit = props => {
1867
2087
  }
1868
2088
  }
1869
2089
  if (event.key === 'ArrowLeft' && colIndex > 0) {
1870
- if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
2090
+ if (!column.dataIndex && !column.key || column.field === '#' || column.dataIndex === '#') {
1871
2091
  event.stopPropagation();
1872
2092
  event.preventDefault();
1873
2093
  } else {
@@ -1898,13 +2118,6 @@ const GridEdit = props => {
1898
2118
  }
1899
2119
  }
1900
2120
  },
1901
- // onKeyUp: (event: any) => {
1902
- // if (event.key === 'Control' && event.ctrlKey) {
1903
- //
1904
- // console.log('onKeyUp')
1905
- // }
1906
- // },
1907
-
1908
2121
  onPaste: event => {
1909
2122
  if (editingKey === '') {
1910
2123
  handlePaste(record, colIndex, rowNumber, event);
@@ -1928,12 +2141,15 @@ const GridEdit = props => {
1928
2141
  // startCell.current = { row: rowNumber, col: colIndex };
1929
2142
 
1930
2143
  if (selectedCells.size === 0) {
1931
- setStartSelectedCell({
2144
+ // setStartSelectedCell({ row: rowNumber, col: colIndex })
2145
+ // setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
2146
+
2147
+ startSelectedCells.current = {
1932
2148
  row: rowNumber,
1933
2149
  col: colIndex
1934
- });
1935
- setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
1936
- setRowsSelected(new Set());
2150
+ };
2151
+ selectedCells.current = new Set([`${rowNumber}-${colIndex}`]);
2152
+ rowsSelected.current = new Set();
1937
2153
  }
1938
2154
  },
1939
2155
  onClick: () => {
@@ -1941,12 +2157,14 @@ const GridEdit = props => {
1941
2157
  setEditingKey('');
1942
2158
  }
1943
2159
  },
1944
- // className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
1945
- className: getCellClass(record, rowNumber, colIndex),
2160
+ className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
2161
+ // className: getCellClass(record, rowNumber, colIndex),
1946
2162
  record,
1947
2163
  column: column,
1948
2164
  editType: (0, _hooks.getEditType)(column, record),
1949
2165
  dataIndex: column.dataIndex,
2166
+ indexRow: rowNumber,
2167
+ indexCol: colIndex,
1950
2168
  title: (0, _columns.getValueCell)(column, record[column.field], format),
1951
2169
  'data-col-index': colIndex,
1952
2170
  'data-row-index': rowNumber,
@@ -1962,6 +2180,8 @@ const GridEdit = props => {
1962
2180
  style: isPasteDragging ? {
1963
2181
  cursor: "crosshair"
1964
2182
  } : {}
2183
+
2184
+ // style: getStyle()
1965
2185
  };
1966
2186
  },
1967
2187
  onHeaderCell: (data, index) => {
@@ -1993,12 +2213,19 @@ const GridEdit = props => {
1993
2213
  className: (0, _classnames.default)('ui-rc_cell-content', {
1994
2214
  // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
1995
2215
  // 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)
2216
+ // selected: selectedCells.has(`${rowNumber}-${colIndex}`),
2217
+ // disable: !isEditable(column as any, record)
1998
2218
  }),
1999
2219
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2000
2220
  onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
2001
- onMouseUp: handleMouseUp
2221
+ onMouseUp: handleMouseUp,
2222
+ onMouseMove: () => {
2223
+ if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
2224
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
2225
+ isDragMouse.current = true;
2226
+ }
2227
+ }
2228
+
2002
2229
  // onClick={(event) => {
2003
2230
  //
2004
2231
  // handleClickCell(event)
@@ -2006,18 +2233,21 @@ const GridEdit = props => {
2006
2233
  // }}
2007
2234
  }, /*#__PURE__*/_react.default.createElement("div", {
2008
2235
  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
- ,
2236
+ }, (0, _columns.renderContent)(column, value, record, rowIndex, format)),
2237
+ // selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
2238
+ // getLastSelectCell(selectedCells.current).col === colIndex &&
2239
+ // isEditable(column as any, record) &&
2240
+
2241
+ !isDragMouse.current && /*#__PURE__*/_react.default.createElement("div", {
2242
+ className: 'dragging-point hidden',
2017
2243
  onMouseDown: e => {
2018
2244
  // e.stopPropagation()
2019
2245
  e.preventDefault();
2020
- setIsPasteDragging(true);
2246
+ if (e.button === 0) {
2247
+ setIsPasteDragging(true);
2248
+
2249
+ // isPasteDragging.current = true
2250
+ }
2021
2251
  },
2022
2252
  onDoubleClick: handlePointDoubleClick
2023
2253
  }, /*#__PURE__*/_react.default.createElement("span", {
@@ -2071,9 +2301,13 @@ const GridEdit = props => {
2071
2301
  }
2072
2302
  }));
2073
2303
  };
2074
- const onSelectChange = keys => {
2075
- setMergedSelectedKeys(keys);
2076
- };
2304
+ //
2305
+ // const onSelectChange = (keys: any[]) => {
2306
+ //
2307
+ // console.log(keys)
2308
+ // setMergedSelectedKeys(keys)
2309
+ // }
2310
+
2077
2311
  const contextMenuClick = args => {
2078
2312
  if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
2079
2313
  if (args.item.key === 'INSERT_BEFORE_ADV') {
@@ -2131,7 +2365,7 @@ const GridEdit = props => {
2131
2365
  setRowsAdd(val);
2132
2366
  };
2133
2367
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
2134
- heightTable: height,
2368
+ $heightTable: height,
2135
2369
  style: {
2136
2370
  position: 'relative'
2137
2371
  },
@@ -2194,9 +2428,11 @@ const GridEdit = props => {
2194
2428
  ,
2195
2429
  selectionSettings: selectionSettings ? {
2196
2430
  ...selectionSettings,
2197
- checkboxOnly: true
2431
+ checkboxOnly: true,
2432
+ arrowKey: false
2198
2433
  } : {
2199
- checkboxOnly: true
2434
+ checkboxOnly: true,
2435
+ arrowKey: false
2200
2436
  },
2201
2437
  rowHoverable: false,
2202
2438
  bottomToolbar: bottomToolbar,
@@ -2237,18 +2473,33 @@ const GridEdit = props => {
2237
2473
  }
2238
2474
  },
2239
2475
  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
- },
2476
+ clickHeaderToSort: false
2477
+
2478
+ // rowSelection={ columns && columns.length === 0 ? undefined : {
2479
+ // type: mode,
2480
+ // columnWidth: columnWidth ?? 50 ,
2481
+ // onChange: onSelectChange,
2482
+ //
2483
+ // selectedRowKeys: mergedSelectedKeys,
2484
+ // preserveSelectedRowKeys: true,
2485
+ // arrowKey: false
2486
+ //
2487
+ // }}
2488
+ ,
2489
+
2248
2490
  isFilter: isFilter,
2249
2491
  setIsFilter: setIsFilter,
2250
2492
  contextMenuItems: contextMenuItems,
2251
- contextMenuClick: contextMenuClick
2493
+ contextMenuClick: contextMenuClick,
2494
+ onScroll: () => {
2495
+ if (selectedCells.current && selectedCells.current.size > 0) {
2496
+ (0, _hooks.onAddClassBgSelectedCell)(selectedCells.current, id);
2497
+ (0, _hooks.showDraggingPoint)(selectedCells.current, id);
2498
+ }
2499
+ if (rowsSelected && rowsSelected.current.size > 0) {
2500
+ (0, _hooks.addClassCellIndexSelected)(rowsSelected.current, id);
2501
+ }
2502
+ }
2252
2503
  })))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
2253
2504
  position: toast,
2254
2505
  toastOptions: {