es-grid-template 1.3.5 → 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.
Files changed (31) hide show
  1. package/assets/index.css +33 -13
  2. package/assets/index.scss +49 -14
  3. package/es/grid-component/EditableCell.js +1 -0
  4. package/es/grid-component/GridStyle.d.ts +5 -3
  5. package/es/grid-component/GridStyle.js +1 -1
  6. package/es/grid-component/TableGrid.js +16 -12
  7. package/es/grid-component/hooks/columns/index.js +4 -3
  8. package/es/grid-component/hooks/useColumns.js +7 -5
  9. package/es/grid-component/hooks/utils.d.ts +23 -0
  10. package/es/grid-component/hooks/utils.js +512 -2
  11. package/es/grid-component/number/index.d.ts +2 -2
  12. package/es/grid-component/number/index.js +2 -2
  13. package/es/grid-component/styles.scss +49 -14
  14. package/es/grid-component/table/Grid.js +1 -1
  15. package/es/grid-component/table/GridEdit.js +474 -206
  16. package/es/grid-component/table/Group.js +1 -1
  17. package/lib/grid-component/EditableCell.js +1 -0
  18. package/lib/grid-component/GridStyle.d.ts +5 -3
  19. package/lib/grid-component/GridStyle.js +1 -1
  20. package/lib/grid-component/TableGrid.js +14 -11
  21. package/lib/grid-component/hooks/columns/index.js +2 -1
  22. package/lib/grid-component/hooks/useColumns.js +7 -5
  23. package/lib/grid-component/hooks/utils.d.ts +23 -0
  24. package/lib/grid-component/hooks/utils.js +537 -8
  25. package/lib/grid-component/number/index.d.ts +2 -2
  26. package/lib/grid-component/number/index.js +2 -2
  27. package/lib/grid-component/styles.scss +49 -14
  28. package/lib/grid-component/table/Grid.js +1 -1
  29. package/lib/grid-component/table/GridEdit.js +474 -197
  30. package/lib/grid-component/table/Group.js +1 -1
  31. package/package.json +2 -2
@@ -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,37 +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
- setSelectedCells(mergedSet);
853
- setPasteCells(new Set());
854
- 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 => {
855
894
  const [row, col] = key.split("-").map(Number);
856
895
  // @ts-ignore
857
896
  const columnKey = columns[col].field;
@@ -865,6 +904,35 @@ const GridEdit = props => {
865
904
  // return { row, col, value: '' };
866
905
  });
867
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
+
868
936
  // Xác định min/max row và col để sắp xếp dữ liệu
869
937
  const minRow = Math.min(...selectedArray.map(cell => cell.row));
870
938
  const maxRow = Math.max(...selectedArray.map(cell => cell.row));
@@ -884,7 +952,17 @@ const GridEdit = props => {
884
952
  }) => {
885
953
  table[row - minRow][col - minCol] = value;
886
954
  });
887
- const newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
955
+ let newRange = {
956
+ combined: [],
957
+ addedRows: []
958
+ };
959
+ if (rowPasteLast > rowSelectedFirst) {
960
+ // kéo xuóng
961
+ newRange = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
962
+ } else {
963
+ // kéo lên
964
+ newRange = (0, _hooks.addRowsUp)(table, (0, _hooks.getRowsPasteIndex)(pastesArray).length);
965
+ }
888
966
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pastesArray).row];
889
967
  if (!record?.parentId) {
890
968
  // Cập nhật data mới
@@ -893,7 +971,7 @@ const GridEdit = props => {
893
971
  // Lấy vị trí bắt đầu
894
972
  // const { row: startRow, col: startCol } = selectedCell;
895
973
  const startRow = (0, _hooks.getFirstSelectCell)(pastesArray).row;
896
- const startCol = (0, _hooks.getFirstSelectCell)(selectedCells).col;
974
+ const startCol = (0, _hooks.getFirstSelectCell)(selectedCells.current).col;
897
975
  const pastedRows = [];
898
976
  const pastedColumns = new Set();
899
977
  newRange.addedRows.forEach((rowValues, rowIndex) => {
@@ -931,19 +1009,38 @@ const GridEdit = props => {
931
1009
  const pastedColumnsArray = Array.from(pastedColumns) ?? [];
932
1010
  triggerPaste?.(pastedRows, pastedColumnsArray, newData);
933
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();
934
1030
  };
935
1031
  const handlePointDoubleClick = e => {
936
- e.preventDefault();
1032
+ // e.preventDefault()
937
1033
  e.stopPropagation();
938
- const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
939
- const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
940
- 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;
941
1037
  const newPasteCells = new Set();
942
1038
  for (let r = Math.min(startPasteRow, dataSource.length - 1) + 1; r <= Math.max(startPasteRow, dataSource.length - 1); r++) {
943
1039
  for (let c = Math.min(colStart, colStart); c <= Math.max(colStart, colEnd); c++) {
944
1040
  newPasteCells.add(`${r}-${c}`);
945
1041
  }
946
1042
  }
1043
+ (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
947
1044
  triggerDragPaste(newPasteCells);
948
1045
  };
949
1046
 
@@ -972,8 +1069,12 @@ const GridEdit = props => {
972
1069
  startCell.current = null;
973
1070
  isSelectingRow.current = false;
974
1071
  rowStart.current = null;
1072
+ isDragMouse.current = false;
1073
+ isMouseDown.current = false;
975
1074
  setIsPasteDragging(false);
976
- setSelectIsDragging(false);
1075
+
1076
+ // isPasteDragging.current = false
1077
+ // setSelectIsDragging(false);
977
1078
 
978
1079
  // setCurrentCtrlCells(new Set())
979
1080
 
@@ -984,10 +1085,30 @@ const GridEdit = props => {
984
1085
 
985
1086
  // nếu ctrlCell length > 0 thì set selectCells
986
1087
 
987
- if (pasteCells.size > 0) {
988
- 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);
989
1101
  }
990
1102
  };
1103
+
1104
+ // const handlePointEnter = () => {
1105
+ // isPointEnter.current = true;
1106
+ // }
1107
+ //
1108
+ // const handlePointLeave = () => {
1109
+ // isPointEnter.current = false;
1110
+ // }
1111
+
991
1112
  const handleMouseEnter = (row, col, e) => {
992
1113
  if (!isSelecting.current || !startCell.current) {
993
1114
  return;
@@ -1011,29 +1132,41 @@ const GridEdit = props => {
1011
1132
  if (!isPasteDragging) {
1012
1133
  // chọn vùng copy
1013
1134
 
1014
- setSelectIsDragging(true);
1135
+ // setSelectIsDragging(true)
1136
+
1015
1137
  setIsPasteDragging(false);
1138
+ // isPasteDragging.current = false
1139
+
1016
1140
  const newSelectedCells = new Set();
1017
1141
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1018
1142
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1019
1143
  newSelectedCells.add(`${r}-${c}`);
1020
1144
  }
1021
1145
  }
1022
- 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);
1023
1154
  } else {
1024
1155
  // chọn vùng paste
1025
1156
 
1026
- setSelectIsDragging(false);
1027
- setIsPasteDragging(true);
1157
+ // setSelectIsDragging(false)
1158
+
1159
+ // setIsPasteDragging(true) ////////
1160
+
1028
1161
  const newSelectedCells = new Set();
1029
1162
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1030
1163
  for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1031
1164
  newSelectedCells.add(`${r}-${c}`);
1032
1165
  }
1033
1166
  }
1034
- const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
1035
- const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
1036
- 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;
1037
1170
  if (row >= rowSelectedEnd) {
1038
1171
  // kéo xuống dưới
1039
1172
 
@@ -1043,17 +1176,34 @@ const GridEdit = props => {
1043
1176
  newPasteCells.add(`${r}-${c}`);
1044
1177
  }
1045
1178
  }
1046
- 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);
1047
1187
  }
1048
1188
  if (row < rowSelectedEnd) {
1049
1189
  // kéo lên trên
1050
1190
 
1051
- const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells).row;
1052
- const newPasteCells = new Set();
1053
- for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
1054
- for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
1055
- newPasteCells.add(`${r}-${c}`);
1191
+ const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells.current).row;
1192
+ if (row < rowSelectedStart) {
1193
+ const newPasteCells = new Set();
1194
+ for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
1195
+ for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
1196
+ newPasteCells.add(`${r}-${c}`);
1197
+ }
1056
1198
  }
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);
1057
1207
  }
1058
1208
  }
1059
1209
  if (col > colEnd) {
@@ -1064,16 +1214,32 @@ const GridEdit = props => {
1064
1214
  }
1065
1215
  }
1066
1216
  };
1067
- const handleClickRowHeader = (row, col) => {
1068
- const newSelectedCells = new Set();
1069
- const tCols = (0, _hooks.editAbleColumns)(columns);
1070
- for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1071
- for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1072
- newSelectedCells.add(`${r}-${c}`);
1073
- }
1074
- }
1075
- setSelectedCells(newSelectedCells);
1076
- };
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
+
1077
1243
  const handleClickColHeader = (column, indexColumn) => {
1078
1244
  const newSelectedCells = new Set();
1079
1245
  for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
@@ -1081,9 +1247,21 @@ const GridEdit = props => {
1081
1247
  newSelectedCells.add(`${r}-${c}`);
1082
1248
  }
1083
1249
  }
1084
- 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);
1085
1263
  };
1086
- const handleMouseDownColIndex = (row, col, e) => {
1264
+ const handleMouseDownRowHeader = (row, col, column, e) => {
1087
1265
  if (e.button === 2) {
1088
1266
  e.stopPropagation();
1089
1267
  return;
@@ -1093,9 +1271,30 @@ const GridEdit = props => {
1093
1271
  row,
1094
1272
  col
1095
1273
  };
1096
- 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);
1097
1296
  };
1098
- const handleMouseEnterColIndex = (row, col, e) => {
1297
+ const handleMouseEnterRowHeader = (row, col, e) => {
1099
1298
  // dừng sự kiện kéo để chọn từ các column khác khi vừa gặp column index
1100
1299
  if (isSelecting) {
1101
1300
  startCell.current = null;
@@ -1119,8 +1318,18 @@ const GridEdit = props => {
1119
1318
  newSelectedCells.add(`${r}-${c}`);
1120
1319
  }
1121
1320
  }
1122
- setRowsSelected(newSelectedRows);
1123
- 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);
1124
1333
  };
1125
1334
  const handleCellClick = (indexRow, record, column) => {
1126
1335
  const cellClickCallback = newOptions => {
@@ -1150,7 +1359,7 @@ const GridEdit = props => {
1150
1359
  }
1151
1360
  };
1152
1361
  const handleCopy = e => {
1153
- const selectedArray = Array.from(selectedCells).map(key => {
1362
+ const selectedArray = Array.from(selectedCells.current).map(key => {
1154
1363
  const [row, col] = key.split("-").map(Number);
1155
1364
  // @ts-ignore
1156
1365
  const columnKey = (0, _hooks.editAbleColumns)(columns)[col - 1].field;
@@ -1515,7 +1724,7 @@ const GridEdit = props => {
1515
1724
  indexRow,
1516
1725
  rowData: record,
1517
1726
  rowId: key,
1518
- rowsData: [],
1727
+ rowsData: [...dataSource],
1519
1728
  sumValue: []
1520
1729
  }, handleChangeCallback);
1521
1730
  } else {
@@ -1528,7 +1737,7 @@ const GridEdit = props => {
1528
1737
  indexRow,
1529
1738
  rowData: record,
1530
1739
  rowId: key,
1531
- rowsData: [],
1740
+ rowsData: [...dataSource],
1532
1741
  sumValue: []
1533
1742
  }, handleChangeCallback);
1534
1743
  onSubmit(record);
@@ -1561,20 +1770,6 @@ const GridEdit = props => {
1561
1770
  // }
1562
1771
  });
1563
1772
  }
1564
-
1565
- // columns.forEach(column => {
1566
- //
1567
- // const dateFormat = getDatepickerFormat(editType, column)
1568
- //
1569
- // // @ts-ignore
1570
- // if ((column.editType === 'date' || column.editType === 'datetime') && record[column.dataIndex]) {
1571
- //
1572
- // // @ts-ignore
1573
- // formattedRecord[column.dataIndex] = !isEmpty(record[column.dataIndex]) ? convertDateToDayjs(new Date(record[column.dataIndex]), dateFormat) : null
1574
- // }
1575
- //
1576
- // });
1577
-
1578
1773
  if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
1579
1774
  setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
1580
1775
  // setValue(col.dataIndex, e.key)
@@ -1583,13 +1778,13 @@ const GridEdit = props => {
1583
1778
  // setSearchValue(e.key)
1584
1779
  // setOpen(true)
1585
1780
  }
1586
- if (startSelectedCells?.row !== undefined && startSelectedCells?.col !== undefined) {
1781
+ if (startSelectedCells.current && startSelectedCells.current.row !== undefined && startSelectedCells.current.col !== undefined) {
1587
1782
  setTimeout(() => {
1588
1783
  // const input = document.querySelector(`.ui-rc-table-row[data-row-key="${selectedCell.row}"] .cell-editing[data-col-index="${selectedCell.col}"] input`) as HTMLInputElement;
1589
- 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`);
1590
1785
  // const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
1591
1786
 
1592
- 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`);
1593
1788
  if (input) {
1594
1789
  input.focus();
1595
1790
  }
@@ -1641,11 +1836,24 @@ const GridEdit = props => {
1641
1836
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1642
1837
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
1643
1838
  const updateSelection = () => {
1644
- setStartSelectedCell({
1839
+ // setStartSelectedCell({ row: rowIndex, col: colIndex });
1840
+ startSelectedCells.current = {
1645
1841
  row: rowIndex,
1646
1842
  col: colIndex
1647
- });
1648
- 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);
1649
1857
  };
1650
1858
  const focusNextCell = (editingCell, cellEditable) => {
1651
1859
  if (isEdit) {
@@ -1692,55 +1900,88 @@ const GridEdit = props => {
1692
1900
  focusNextCell(cellEdit, cell);
1693
1901
  }
1694
1902
  };
1695
- const getCellClass = (record, rowIndex, colIndex) => {
1696
- const cellKey = `${rowIndex}-${colIndex}`;
1697
- const topCellKey = `${rowIndex + 1}-${colIndex}`;
1698
- const leftCellKey = `${rowIndex}-${colIndex + 1}`;
1699
- const rightCellKey = `${rowIndex}-${colIndex - 1}`;
1700
- const isSelected = selectedCells.has(cellKey);
1701
- const isTopSelected = selectedCells.has(topCellKey);
1702
- const isLeftSelected = selectedCells.has(leftCellKey);
1703
- const isRightSelected = selectedCells.has(rightCellKey);
1704
- const isPasteSelected = pasteCells.has(cellKey);
1705
- const isPasteLeftSelected = pasteCells.has(leftCellKey);
1706
- const isPasteRightSelected = pasteCells.has(rightCellKey);
1707
- const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
1708
- const prevRecordEditing = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowIndex + 1];
1709
- const cellStart = (0, _hooks.getFirstSelectCell)(selectedCells);
1710
- const cellEnd = (0, _hooks.getLastSelectCell)(selectedCells);
1711
- const cellPasteStart = (0, _hooks.getFirstSelectCell)(pasteCells);
1712
- const cellPasteSEnd = (0, _hooks.getLastSelectCell)(pasteCells);
1713
- const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
1714
- if (!isSelected && !isPasteSelected) {
1715
- // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1716
- const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && (0, _hooks.isTopMostInRegion)(rowIndex + 1, colIndex, selectedCells);
1717
- const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1718
- const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1719
- const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1720
- const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1721
- 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 ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` : cellClass;
1722
- }
1723
- const isBottom = (0, _hooks.isBottomMostInRegion)(rowIndex, colIndex, selectedCells);
1724
- // const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
1725
-
1726
- // const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col)
1727
- const isRight = (0, _hooks.isRightMostInRegion)(rowIndex, colIndex, selectedCells);
1728
- const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col);
1729
- const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col);
1730
- const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1731
- 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` : ''}`;
1732
- };
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
+
1733
1973
  const convertColumns = (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1734
1974
  if (!column?.field && !column?.key) {
1735
1975
  return column;
1736
1976
  }
1737
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
1977
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
1738
1978
  return {
1739
1979
  ...column,
1740
- className: 'rc-ui-cell-editable',
1980
+ className: 'rc-ui-cell-editable rc-ui-cell-index',
1741
1981
  onCell: (record, rowIndex) => {
1742
1982
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1743
1983
  return {
1984
+ 'data-row-index': rowNumber,
1744
1985
  onPaste: event => {
1745
1986
  if (editingKey === '') {
1746
1987
  handlePaste(record, colIndex + 1, rowNumber, event);
@@ -1765,12 +2006,16 @@ const GridEdit = props => {
1765
2006
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1766
2007
  return /*#__PURE__*/_react.default.createElement("div", {
1767
2008
  className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {
1768
- selected: rowsSelected.has(`${rowNumber}-${colIndex}`),
1769
- 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}-`))
1770
2013
  }),
1771
- onMouseDown: event => handleMouseDownColIndex(rowNumber, colIndex, event),
1772
- onMouseEnter: event => handleMouseEnterColIndex(rowNumber, colIndex, event),
1773
- 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
+ ,
1774
2019
  onMouseUp: handleMouseUp
1775
2020
  }, /*#__PURE__*/_react.default.createElement("div", {
1776
2021
  className: 'ui-rc_content'
@@ -1800,6 +2045,7 @@ const GridEdit = props => {
1800
2045
  event.preventDefault();
1801
2046
  event.stopPropagation();
1802
2047
  handleEdit(record, column, column.editType, event);
2048
+ (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1803
2049
  handleCellClick(rowNumber, record, column);
1804
2050
  const hasKey = mergedExpandedKeys.has(key);
1805
2051
  if (hasKey) {
@@ -1841,7 +2087,7 @@ const GridEdit = props => {
1841
2087
  }
1842
2088
  }
1843
2089
  if (event.key === 'ArrowLeft' && colIndex > 0) {
1844
- 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 === '#') {
1845
2091
  event.stopPropagation();
1846
2092
  event.preventDefault();
1847
2093
  } else {
@@ -1872,13 +2118,6 @@ const GridEdit = props => {
1872
2118
  }
1873
2119
  }
1874
2120
  },
1875
- // onKeyUp: (event: any) => {
1876
- // if (event.key === 'Control' && event.ctrlKey) {
1877
- //
1878
- // console.log('onKeyUp')
1879
- // }
1880
- // },
1881
-
1882
2121
  onPaste: event => {
1883
2122
  if (editingKey === '') {
1884
2123
  handlePaste(record, colIndex, rowNumber, event);
@@ -1902,12 +2141,15 @@ const GridEdit = props => {
1902
2141
  // startCell.current = { row: rowNumber, col: colIndex };
1903
2142
 
1904
2143
  if (selectedCells.size === 0) {
1905
- setStartSelectedCell({
2144
+ // setStartSelectedCell({ row: rowNumber, col: colIndex })
2145
+ // setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
2146
+
2147
+ startSelectedCells.current = {
1906
2148
  row: rowNumber,
1907
2149
  col: colIndex
1908
- });
1909
- setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
1910
- setRowsSelected(new Set());
2150
+ };
2151
+ selectedCells.current = new Set([`${rowNumber}-${colIndex}`]);
2152
+ rowsSelected.current = new Set();
1911
2153
  }
1912
2154
  },
1913
2155
  onClick: () => {
@@ -1915,12 +2157,14 @@ const GridEdit = props => {
1915
2157
  setEditingKey('');
1916
2158
  }
1917
2159
  },
1918
- // className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
1919
- 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),
1920
2162
  record,
1921
2163
  column: column,
1922
2164
  editType: (0, _hooks.getEditType)(column, record),
1923
2165
  dataIndex: column.dataIndex,
2166
+ indexRow: rowNumber,
2167
+ indexCol: colIndex,
1924
2168
  title: (0, _columns.getValueCell)(column, record[column.field], format),
1925
2169
  'data-col-index': colIndex,
1926
2170
  'data-row-index': rowNumber,
@@ -1936,6 +2180,8 @@ const GridEdit = props => {
1936
2180
  style: isPasteDragging ? {
1937
2181
  cursor: "crosshair"
1938
2182
  } : {}
2183
+
2184
+ // style: getStyle()
1939
2185
  };
1940
2186
  },
1941
2187
  onHeaderCell: (data, index) => {
@@ -1967,12 +2213,19 @@ const GridEdit = props => {
1967
2213
  className: (0, _classnames.default)('ui-rc_cell-content', {
1968
2214
  // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
1969
2215
  // selected: selectedCells.has(`${rowNumber}-${colIndex}`) || currentCtrlCells.has(`${rowNumber}-${colIndex}`) || mergedSets([selectedCells, ...ctrlCells]).has(`${rowNumber}-${colIndex}`),
1970
- selected: selectedCells.has(`${rowNumber}-${colIndex}`),
1971
- disable: !(0, _hooks.isEditable)(column, record)
2216
+ // selected: selectedCells.has(`${rowNumber}-${colIndex}`),
2217
+ // disable: !isEditable(column as any, record)
1972
2218
  }),
1973
2219
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
1974
2220
  onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
1975
- 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
+
1976
2229
  // onClick={(event) => {
1977
2230
  //
1978
2231
  // handleClickCell(event)
@@ -1980,18 +2233,21 @@ const GridEdit = props => {
1980
2233
  // }}
1981
2234
  }, /*#__PURE__*/_react.default.createElement("div", {
1982
2235
  className: 'ui-rc_content'
1983
- }, (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 &&
1984
- /*#__PURE__*/
1985
- // showDraggingPoint &&
1986
- _react.default.createElement("div", {
1987
- className: 'dragging-point'
1988
- // onMouseEnter={(event) => handlePointEnter(event)}
1989
- // onMouseLeave={() => handlePointLeave()}
1990
- ,
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',
1991
2243
  onMouseDown: e => {
1992
2244
  // e.stopPropagation()
1993
- // e.preventDefault()
1994
- setIsPasteDragging(true);
2245
+ e.preventDefault();
2246
+ if (e.button === 0) {
2247
+ setIsPasteDragging(true);
2248
+
2249
+ // isPasteDragging.current = true
2250
+ }
1995
2251
  },
1996
2252
  onDoubleClick: handlePointDoubleClick
1997
2253
  }, /*#__PURE__*/_react.default.createElement("span", {
@@ -2045,9 +2301,13 @@ const GridEdit = props => {
2045
2301
  }
2046
2302
  }));
2047
2303
  };
2048
- const onSelectChange = keys => {
2049
- setMergedSelectedKeys(keys);
2050
- };
2304
+ //
2305
+ // const onSelectChange = (keys: any[]) => {
2306
+ //
2307
+ // console.log(keys)
2308
+ // setMergedSelectedKeys(keys)
2309
+ // }
2310
+
2051
2311
  const contextMenuClick = args => {
2052
2312
  if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
2053
2313
  if (args.item.key === 'INSERT_BEFORE_ADV') {
@@ -2105,7 +2365,7 @@ const GridEdit = props => {
2105
2365
  setRowsAdd(val);
2106
2366
  };
2107
2367
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
2108
- heightTable: height,
2368
+ $heightTable: height,
2109
2369
  style: {
2110
2370
  position: 'relative'
2111
2371
  },
@@ -2168,9 +2428,11 @@ const GridEdit = props => {
2168
2428
  ,
2169
2429
  selectionSettings: selectionSettings ? {
2170
2430
  ...selectionSettings,
2171
- checkboxOnly: true
2431
+ checkboxOnly: true,
2432
+ arrowKey: false
2172
2433
  } : {
2173
- checkboxOnly: true
2434
+ checkboxOnly: true,
2435
+ arrowKey: false
2174
2436
  },
2175
2437
  rowHoverable: false,
2176
2438
  bottomToolbar: bottomToolbar,
@@ -2211,18 +2473,33 @@ const GridEdit = props => {
2211
2473
  }
2212
2474
  },
2213
2475
  triggerChangeColumns: triggerChangeColumns,
2214
- clickHeaderToSort: false,
2215
- rowSelection: columns && columns.length === 0 ? undefined : {
2216
- type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
2217
- columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
2218
- onChange: onSelectChange,
2219
- selectedRowKeys: mergedSelectedKeys,
2220
- preserveSelectedRowKeys: true
2221
- },
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
+
2222
2490
  isFilter: isFilter,
2223
2491
  setIsFilter: setIsFilter,
2224
2492
  contextMenuItems: contextMenuItems,
2225
- 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
+ }
2226
2503
  })))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
2227
2504
  position: toast,
2228
2505
  toastOptions: {