es-grid-template 1.4.3 → 1.4.4
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.
- package/es/grid-component/InternalTable.js +14 -2
- package/es/grid-component/hooks/content/HeaderContent.js +3 -5
- package/es/grid-component/hooks/useColumns.js +1 -2
- package/es/grid-component/hooks/utils.d.ts +6 -2
- package/es/grid-component/hooks/utils.js +136 -45
- package/es/grid-component/styles.scss +62 -5
- package/es/grid-component/table/GridEdit.js +407 -400
- package/lib/grid-component/InternalTable.js +14 -2
- package/lib/grid-component/hooks/content/HeaderContent.js +3 -5
- package/lib/grid-component/hooks/useColumns.js +1 -2
- package/lib/grid-component/hooks/utils.d.ts +6 -2
- package/lib/grid-component/hooks/utils.js +145 -50
- package/lib/grid-component/styles.scss +62 -5
- package/lib/grid-component/table/GridEdit.js +401 -399
- package/package.json +1 -1
|
@@ -14,7 +14,12 @@ import dayjs from "dayjs";
|
|
|
14
14
|
import 'dayjs/locale/es';
|
|
15
15
|
import 'dayjs/locale/vi';
|
|
16
16
|
import TableGrid from "../TableGrid";
|
|
17
|
-
import { addClassBorderPasteCell, addClassCellIndexSelected, addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex, hideDraggingPoint, isEditable, isEqualSet, isObjEmpty, newGuid,
|
|
17
|
+
import { addClassBorderPasteCell, addClassCellIndexSelected, addRows8, addRowsUp, checkChild, editAbleColumns, findAllChildrenKeys, findItemByKey, findItemPath, flattenArray, flattenData, getDefaultValue, getEditType, getFirstSelectCell, getLastSelectCell, getRowNumber, getRowsPasteIndex, hideDraggingPoint, isEditable, isEqualSet, isObjEmpty, newGuid, onAddBgSelectedCell,
|
|
18
|
+
// onRemoveBorderSelectedCell,
|
|
19
|
+
onRemoveBgSelectedCell, removeClassBorderPasteCell, removeClassCellIndexSelected, showDraggingPoint, sortedSetASC, totalFixedWidth, updateArrayByKey, getFormat,
|
|
20
|
+
// isRangeCell,
|
|
21
|
+
// isSelectedCell,
|
|
22
|
+
onRemoveBgCellIndex, onAddBgCellIndex, onAddBorderSelectedCell, onRemoveBorderSelectedCell } from "../hooks";
|
|
18
23
|
import Message from "../../Message/Message";
|
|
19
24
|
import { Toolbar, ConfigProvider, InputNumber } from "rc-master-ui";
|
|
20
25
|
import classnames from "classnames";
|
|
@@ -180,7 +185,7 @@ const GridEdit = props => {
|
|
|
180
185
|
dataSource,
|
|
181
186
|
components,
|
|
182
187
|
allowResizing,
|
|
183
|
-
rowKey = '
|
|
188
|
+
rowKey = 'rowId',
|
|
184
189
|
selectionSettings,
|
|
185
190
|
height,
|
|
186
191
|
format,
|
|
@@ -357,13 +362,13 @@ const GridEdit = props => {
|
|
|
357
362
|
// thêm n dòng bên trên
|
|
358
363
|
const handleInsertBefore = React.useCallback((item, n) => {
|
|
359
364
|
//
|
|
360
|
-
onRemoveBgSelectedCell(selectedCells.current, id)
|
|
361
|
-
onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
365
|
+
// onRemoveBgSelectedCell(selectedCells.current, id)
|
|
366
|
+
// onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
362
367
|
//
|
|
363
368
|
|
|
364
369
|
setTimeout(() => {
|
|
365
|
-
onAddBgSelectedCell(selectedCells.current, id)
|
|
366
|
-
onAddBorderSelectedCell(selectedCells.current, id)
|
|
370
|
+
// onAddBgSelectedCell(selectedCells.current, id)
|
|
371
|
+
// onAddBorderSelectedCell(selectedCells.current, id)
|
|
367
372
|
}, 10);
|
|
368
373
|
const defaultRowValue = getDefaultValue(defaultValue);
|
|
369
374
|
// const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
|
|
@@ -553,8 +558,8 @@ const GridEdit = props => {
|
|
|
553
558
|
}, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
|
|
554
559
|
const handleDeleteRows = React.useCallback(item => {
|
|
555
560
|
setTimeout(() => {
|
|
556
|
-
onAddBgSelectedCell(selectedCells.current, id)
|
|
557
|
-
onAddBorderSelectedCell(selectedCells.current, id)
|
|
561
|
+
// onAddBgSelectedCell(selectedCells.current, id)
|
|
562
|
+
// onAddBorderSelectedCell(selectedCells.current, id)
|
|
558
563
|
});
|
|
559
564
|
if (item.onClick) {
|
|
560
565
|
item.onClick({
|
|
@@ -816,7 +821,7 @@ const GridEdit = props => {
|
|
|
816
821
|
}
|
|
817
822
|
} = useForm({
|
|
818
823
|
mode: 'onChange',
|
|
819
|
-
resolver: yupResolver(validate)
|
|
824
|
+
resolver: validate ? yupResolver(validate) : undefined
|
|
820
825
|
});
|
|
821
826
|
const isEditing = React.useCallback(record => {
|
|
822
827
|
return record[rowKey] === editingKey;
|
|
@@ -866,77 +871,6 @@ const GridEdit = props => {
|
|
|
866
871
|
document.removeEventListener("click", handleClickOutside);
|
|
867
872
|
};
|
|
868
873
|
}, [id]);
|
|
869
|
-
const handleMouseDown = (record, row, col, e) => {
|
|
870
|
-
if (editingKey && editingKey === record[rowKey]) {
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
if (e.button === 2) {
|
|
874
|
-
e.stopPropagation();
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
// isDragMouse.current = true
|
|
879
|
-
isMouseDown.current = true;
|
|
880
|
-
if (e.ctrlKey) {
|
|
881
|
-
isSelecting.current = true;
|
|
882
|
-
startCell.current = {
|
|
883
|
-
row,
|
|
884
|
-
col
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// const cell: any = new Set([`${row}-${col}`])
|
|
888
|
-
|
|
889
|
-
// setCurrentCtrlCells(cell)
|
|
890
|
-
} else {
|
|
891
|
-
isSelecting.current = true;
|
|
892
|
-
startCell.current = {
|
|
893
|
-
row,
|
|
894
|
-
col
|
|
895
|
-
};
|
|
896
|
-
const target = e.target;
|
|
897
|
-
if (target.closest('.dragging-point')) {
|
|
898
|
-
e.stopPropagation();
|
|
899
|
-
e.preventDefault();
|
|
900
|
-
return; // Không xử lý gì cả
|
|
901
|
-
} else {
|
|
902
|
-
// setStartSelectedCell({row, col})
|
|
903
|
-
|
|
904
|
-
startSelectedCells.current = {
|
|
905
|
-
row,
|
|
906
|
-
col
|
|
907
|
-
};
|
|
908
|
-
|
|
909
|
-
// setSelectedCells(new Set([`${row}-${col}`]));
|
|
910
|
-
|
|
911
|
-
const cells = new Set([`${row}-${col}`]);
|
|
912
|
-
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
913
|
-
if (!isEqualSet(cells, rangeCells)) {
|
|
914
|
-
onRemoveBgSelectedCell(rangeCells, id);
|
|
915
|
-
onRemoveBorderSelectedCell(rangeCells, id);
|
|
916
|
-
hideDraggingPoint(rangeCells, id);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
920
|
-
removeClassCellIndexSelected(rowsSelected.current, id);
|
|
921
|
-
}
|
|
922
|
-
if (!isEqualSet(cells, selectedCells.current)) {
|
|
923
|
-
selectedCells.current = cells;
|
|
924
|
-
if (editingKey) {
|
|
925
|
-
setTimeout(() => {
|
|
926
|
-
onAddBgSelectedCell(cells, id);
|
|
927
|
-
onAddBorderSelectedCell(cells, id);
|
|
928
|
-
}, 200);
|
|
929
|
-
} else {
|
|
930
|
-
onAddBgSelectedCell(cells, id);
|
|
931
|
-
onAddBorderSelectedCell(cells, id);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
// setRowsSelected(new Set())
|
|
936
|
-
rowsSelected.current = new Set();
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
};
|
|
940
874
|
const triggerDragPaste = pastesArray => {
|
|
941
875
|
const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
|
|
942
876
|
const tmpCols = {
|
|
@@ -957,35 +891,6 @@ const GridEdit = props => {
|
|
|
957
891
|
// return { row, col, value: '' };
|
|
958
892
|
});
|
|
959
893
|
|
|
960
|
-
// let selectedArray = []
|
|
961
|
-
//
|
|
962
|
-
// if (rowPasteLast > rowSelectedFirst) {
|
|
963
|
-
// // kéo xuóng
|
|
964
|
-
// selectedArray = Array.from(selectedCells).map((key: any) => {
|
|
965
|
-
//
|
|
966
|
-
// const [row, col] = key.split("-").map(Number);
|
|
967
|
-
// // @ts-ignore
|
|
968
|
-
// const columnKey = columns[col].field;
|
|
969
|
-
//
|
|
970
|
-
// // @ts-ignore
|
|
971
|
-
// return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
|
|
972
|
-
// // return { row, col, value: '' };
|
|
973
|
-
// });
|
|
974
|
-
// } else {
|
|
975
|
-
// // kéo lên
|
|
976
|
-
//
|
|
977
|
-
// selectedArray = Array.from(sortedSetDSC(selectedCells)).map((key: any) => {
|
|
978
|
-
//
|
|
979
|
-
// const [row, col] = key.split("-").map(Number);
|
|
980
|
-
// // @ts-ignore
|
|
981
|
-
// const columnKey = columns[col].field;
|
|
982
|
-
//
|
|
983
|
-
// // @ts-ignore
|
|
984
|
-
// return { row, col, value: flattenData(childrenColumnName as any,dataSource)[row][columnKey] };
|
|
985
|
-
// // return { row, col, value: '' };
|
|
986
|
-
// });
|
|
987
|
-
// }
|
|
988
|
-
|
|
989
894
|
// Xác định min/max row và col để sắp xếp dữ liệu
|
|
990
895
|
const minRow = Math.min(...selectedArray.map(cell => cell.row));
|
|
991
896
|
const maxRow = Math.max(...selectedArray.map(cell => cell.row));
|
|
@@ -1065,18 +970,20 @@ const GridEdit = props => {
|
|
|
1065
970
|
|
|
1066
971
|
/// cập nhật cell class
|
|
1067
972
|
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1068
|
-
onRemoveBgSelectedCell(rangeCells, id)
|
|
1069
|
-
onRemoveBorderSelectedCell(rangeCells, id)
|
|
973
|
+
// onRemoveBgSelectedCell(rangeCells, id)
|
|
974
|
+
// onRemoveBorderSelectedCell(rangeCells, id)
|
|
1070
975
|
}
|
|
1071
976
|
|
|
1072
977
|
// selectedCells.current = sortedSetASC(mergedSet)
|
|
1073
978
|
hideDraggingPoint(selectedCells.current, id);
|
|
1074
|
-
|
|
1075
|
-
|
|
979
|
+
const newCells = sortedSetASC(mergedSet);
|
|
980
|
+
selectedCells.current = newCells;
|
|
981
|
+
onAddBgCellIndex(newCells, id);
|
|
982
|
+
setRangeCells(newCells);
|
|
983
|
+
onAddBgSelectedCell(newCells, id);
|
|
984
|
+
onAddBorderSelectedCell(newCells, id);
|
|
1076
985
|
setTimeout(() => {
|
|
1077
|
-
|
|
1078
|
-
onAddBorderSelectedCell(sortedSetASC(mergedSet), id);
|
|
1079
|
-
showDraggingPoint(sortedSetASC(mergedSet), id);
|
|
986
|
+
showDraggingPoint(newCells, id);
|
|
1080
987
|
}, 50);
|
|
1081
988
|
|
|
1082
989
|
// setPasteCells(new Set())
|
|
@@ -1101,6 +1008,80 @@ const GridEdit = props => {
|
|
|
1101
1008
|
hideDraggingPoint(selectedCells.current, id);
|
|
1102
1009
|
triggerDragPaste(newPasteCells);
|
|
1103
1010
|
};
|
|
1011
|
+
const handleMouseDown = (record, row, col, e) => {
|
|
1012
|
+
if (e.button === 2) {
|
|
1013
|
+
e.stopPropagation();
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
if (editingKey && editingKey === record[rowKey]) {
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1020
|
+
setEditingKey('');
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// isDragMouse.current = true
|
|
1024
|
+
isMouseDown.current = true;
|
|
1025
|
+
if (e.ctrlKey) {
|
|
1026
|
+
isSelecting.current = true;
|
|
1027
|
+
startCell.current = {
|
|
1028
|
+
row,
|
|
1029
|
+
col
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
// const cell: any = new Set([`${row}-${col}`])
|
|
1033
|
+
|
|
1034
|
+
// setCurrentCtrlCells(cell)
|
|
1035
|
+
} else {
|
|
1036
|
+
isSelecting.current = true;
|
|
1037
|
+
startCell.current = {
|
|
1038
|
+
row,
|
|
1039
|
+
col
|
|
1040
|
+
};
|
|
1041
|
+
const target = e.target;
|
|
1042
|
+
if (target.closest('.dragging-point')) {
|
|
1043
|
+
e.stopPropagation();
|
|
1044
|
+
e.preventDefault();
|
|
1045
|
+
return; // Không xử lý gì cả
|
|
1046
|
+
} else {
|
|
1047
|
+
// setStartSelectedCell({row, col})
|
|
1048
|
+
|
|
1049
|
+
startSelectedCells.current = {
|
|
1050
|
+
row,
|
|
1051
|
+
col
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
// setSelectedCells(new Set([`${row}-${col}`]));
|
|
1055
|
+
|
|
1056
|
+
const cells = new Set([`${row}-${col}`]);
|
|
1057
|
+
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1058
|
+
if (!isEqualSet(cells, rangeCells)) {
|
|
1059
|
+
// onRemoveBgSelectedCell(rangeCells, id)
|
|
1060
|
+
// onRemoveBorderSelectedCell(rangeCells, id)
|
|
1061
|
+
hideDraggingPoint(rangeCells, id);
|
|
1062
|
+
onRemoveBgCellIndex(selectedCells.current, id);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
1066
|
+
removeClassCellIndexSelected(rowsSelected.current, id);
|
|
1067
|
+
}
|
|
1068
|
+
if (!isEqualSet(cells, selectedCells.current)) {
|
|
1069
|
+
onRemoveBgSelectedCell(selectedCells.current, id);
|
|
1070
|
+
hideDraggingPoint(selectedCells.current, id);
|
|
1071
|
+
selectedCells.current = cells;
|
|
1072
|
+
// setRangeCells(cells)
|
|
1073
|
+
|
|
1074
|
+
onAddBgCellIndex(cells, id);
|
|
1075
|
+
onAddBorderSelectedCell(cells, id);
|
|
1076
|
+
onAddBgSelectedCell(selectedCells.current, id, false);
|
|
1077
|
+
showDraggingPoint(selectedCells.current, id);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// setRowsSelected(new Set())
|
|
1081
|
+
rowsSelected.current = new Set();
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1104
1085
|
const handleMouseUp = e => {
|
|
1105
1086
|
isSelecting.current = false;
|
|
1106
1087
|
startCell.current = null;
|
|
@@ -1109,12 +1090,6 @@ const GridEdit = props => {
|
|
|
1109
1090
|
isDragMouse.current = false;
|
|
1110
1091
|
isMouseDown.current = false;
|
|
1111
1092
|
setIsPasteDragging(false);
|
|
1112
|
-
|
|
1113
|
-
// isPasteDragging.current = false
|
|
1114
|
-
// setSelectIsDragging(false);
|
|
1115
|
-
|
|
1116
|
-
// setCurrentCtrlCells(new Set())
|
|
1117
|
-
|
|
1118
1093
|
if (e.ctrlKey) {
|
|
1119
1094
|
|
|
1120
1095
|
// setCtrlCells([...ctrlCells, currentCtrlCells])
|
|
@@ -1126,18 +1101,20 @@ const GridEdit = props => {
|
|
|
1126
1101
|
triggerDragPaste(pasteCells.current);
|
|
1127
1102
|
} else {
|
|
1128
1103
|
setRangeCells(selectedCells.current);
|
|
1129
|
-
onRemoveBorderSelectedCell(rangeCells, id);
|
|
1130
|
-
onAddBorderSelectedCell(selectedCells.current, id);
|
|
1131
1104
|
const target = e.target;
|
|
1132
1105
|
if (target.closest('.dragging-point')) {
|
|
1133
1106
|
e.stopPropagation();
|
|
1134
1107
|
e.preventDefault();
|
|
1135
1108
|
return; // Không xử lý gì cả
|
|
1136
1109
|
}
|
|
1137
|
-
if (selectedCells.current && selectedCells.current.size >
|
|
1110
|
+
if (selectedCells.current && selectedCells.current.size > 1) {
|
|
1138
1111
|
hideDraggingPoint(selectedCells.current, id);
|
|
1112
|
+
onAddBorderSelectedCell(selectedCells.current, id);
|
|
1113
|
+
|
|
1114
|
+
// showDraggingPoint(selectedCells.current, id)
|
|
1139
1115
|
}
|
|
1140
1116
|
showDraggingPoint(selectedCells.current, id);
|
|
1117
|
+
// onAddBorderSelectedCell(selectedCells.current, id)
|
|
1141
1118
|
}
|
|
1142
1119
|
};
|
|
1143
1120
|
const handleMouseEnter = (row, col, e) => {
|
|
@@ -1256,15 +1233,17 @@ const GridEdit = props => {
|
|
|
1256
1233
|
// setSelectedCells(new Set(newSelectedCells));
|
|
1257
1234
|
|
|
1258
1235
|
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1259
|
-
onRemoveBgSelectedCell(selectedCells.current, id)
|
|
1260
|
-
onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
1236
|
+
// onRemoveBgSelectedCell(selectedCells.current, id)
|
|
1237
|
+
// onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
1261
1238
|
}
|
|
1262
1239
|
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
1263
1240
|
removeClassCellIndexSelected(rowsSelected.current, id);
|
|
1264
1241
|
}
|
|
1265
1242
|
selectedCells.current = newSelectedCells;
|
|
1266
|
-
|
|
1267
|
-
|
|
1243
|
+
|
|
1244
|
+
// onAddBgSelectedCell(newSelectedCells, id)
|
|
1245
|
+
// onAddBorderSelectedCell(newSelectedCells, id)
|
|
1246
|
+
|
|
1268
1247
|
hideDraggingPoint(selectedCells.current, id);
|
|
1269
1248
|
showDraggingPoint(newSelectedCells, id);
|
|
1270
1249
|
};
|
|
@@ -1273,6 +1252,9 @@ const GridEdit = props => {
|
|
|
1273
1252
|
e.stopPropagation();
|
|
1274
1253
|
return;
|
|
1275
1254
|
}
|
|
1255
|
+
if (editingKey) {
|
|
1256
|
+
setEditingKey('');
|
|
1257
|
+
}
|
|
1276
1258
|
isSelectingRow.current = true;
|
|
1277
1259
|
rowStart.current = {
|
|
1278
1260
|
row,
|
|
@@ -1285,13 +1267,11 @@ const GridEdit = props => {
|
|
|
1285
1267
|
newSelectedCells.add(`${r}-${c}`);
|
|
1286
1268
|
}
|
|
1287
1269
|
}
|
|
1288
|
-
|
|
1289
|
-
// setSelectedCells(newSelectedCells)
|
|
1290
|
-
// setRowsSelected(new Set([`${row}-${col}`]));
|
|
1291
|
-
|
|
1292
1270
|
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1271
|
+
onRemoveBgCellIndex(selectedCells.current, id);
|
|
1293
1272
|
onRemoveBgSelectedCell(selectedCells.current, id);
|
|
1294
1273
|
onRemoveBorderSelectedCell(selectedCells.current, id);
|
|
1274
|
+
// onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
1295
1275
|
}
|
|
1296
1276
|
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
1297
1277
|
removeClassCellIndexSelected(rowsSelected.current, id);
|
|
@@ -1300,7 +1280,9 @@ const GridEdit = props => {
|
|
|
1300
1280
|
selectedCells.current = newSelectedCells;
|
|
1301
1281
|
rowsSelected.current = new Set([`${row}-${col}`]);
|
|
1302
1282
|
onAddBgSelectedCell(newSelectedCells, id, false);
|
|
1303
|
-
|
|
1283
|
+
setTimeout(() => {
|
|
1284
|
+
onAddBgSelectedCell(newSelectedCells, id, false);
|
|
1285
|
+
}, 10);
|
|
1304
1286
|
addClassCellIndexSelected(new Set([`${row}-${col}`]), id);
|
|
1305
1287
|
};
|
|
1306
1288
|
const handleMouseEnterRowHeader = (row, col, e) => {
|
|
@@ -1330,13 +1312,11 @@ const GridEdit = props => {
|
|
|
1330
1312
|
if (selectedCells.current && selectedCells.current.size > 0) {
|
|
1331
1313
|
onRemoveBgSelectedCell(selectedCells.current, id);
|
|
1332
1314
|
}
|
|
1333
|
-
// setSelectedCells(newSelectedCells)
|
|
1334
1315
|
selectedCells.current = newSelectedCells;
|
|
1335
1316
|
onAddBgSelectedCell(newSelectedCells, id);
|
|
1336
1317
|
if (rowsSelected.current && rowsSelected.current.size > 0) {
|
|
1337
1318
|
removeClassCellIndexSelected(rowsSelected.current, id);
|
|
1338
1319
|
}
|
|
1339
|
-
// setRowsSelected(newSelectedRows)
|
|
1340
1320
|
rowsSelected.current = newSelectedRows;
|
|
1341
1321
|
addClassCellIndexSelected(newSelectedRows, id);
|
|
1342
1322
|
};
|
|
@@ -1755,6 +1735,7 @@ const GridEdit = props => {
|
|
|
1755
1735
|
}
|
|
1756
1736
|
};
|
|
1757
1737
|
const handleEdit = (record, col, editType, e) => {
|
|
1738
|
+
onRemoveBorderSelectedCell(selectedCells.current, id);
|
|
1758
1739
|
setTooltipContent('');
|
|
1759
1740
|
// @ts-ignore
|
|
1760
1741
|
setEditingKey(record[rowKey]);
|
|
@@ -1854,10 +1835,16 @@ const GridEdit = props => {
|
|
|
1854
1835
|
hideDraggingPoint(selectedCells.current, id);
|
|
1855
1836
|
selectedCells.current = cells;
|
|
1856
1837
|
setRangeCells(cells);
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1838
|
+
|
|
1839
|
+
// setTimeout(() => {
|
|
1840
|
+
//
|
|
1841
|
+
// // onAddBgSelectedCell(selectedCells.current, id)
|
|
1842
|
+
// // onAddBorderSelectedCell(selectedCells.current, id)
|
|
1843
|
+
//
|
|
1844
|
+
// }, 50)
|
|
1845
|
+
|
|
1846
|
+
onAddBgSelectedCell(selectedCells.current, id);
|
|
1847
|
+
onAddBorderSelectedCell(selectedCells.current, id);
|
|
1861
1848
|
showDraggingPoint(cells, id);
|
|
1862
1849
|
};
|
|
1863
1850
|
const focusNextCell = (editingCell, cellEditable) => {
|
|
@@ -1866,6 +1853,7 @@ const GridEdit = props => {
|
|
|
1866
1853
|
updateSelection();
|
|
1867
1854
|
if (e?.key !== 'Tab') {
|
|
1868
1855
|
editingCell.focus();
|
|
1856
|
+
// editingCell.click()
|
|
1869
1857
|
}
|
|
1870
1858
|
}
|
|
1871
1859
|
if (scrollType === 'horizontal' && editingCell) {
|
|
@@ -1877,6 +1865,8 @@ const GridEdit = props => {
|
|
|
1877
1865
|
scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
|
|
1878
1866
|
if (e?.key !== 'Tab') {
|
|
1879
1867
|
cellEditable.focus();
|
|
1868
|
+
onAddBorderSelectedCell(selectedCells.current, id);
|
|
1869
|
+
// editingCell.click()
|
|
1880
1870
|
}
|
|
1881
1871
|
}
|
|
1882
1872
|
} else {
|
|
@@ -1884,6 +1874,7 @@ const GridEdit = props => {
|
|
|
1884
1874
|
updateSelection();
|
|
1885
1875
|
if (e?.key !== 'Tab') {
|
|
1886
1876
|
cellEditable.focus();
|
|
1877
|
+
onAddBorderSelectedCell(selectedCells.current, id);
|
|
1887
1878
|
}
|
|
1888
1879
|
}
|
|
1889
1880
|
if (cellEditable) {
|
|
@@ -1905,296 +1896,312 @@ const GridEdit = props => {
|
|
|
1905
1896
|
focusNextCell(cellEdit, cell);
|
|
1906
1897
|
}
|
|
1907
1898
|
};
|
|
1908
|
-
const convertColumns =
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1899
|
+
const convertColumns = React.useMemo(() => {
|
|
1900
|
+
return flatColumns2(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
|
|
1901
|
+
if (column === SELECTION_COLUMN) {
|
|
1902
|
+
return SELECTION_COLUMN;
|
|
1903
|
+
}
|
|
1904
|
+
if (column.field === '#') {
|
|
1905
|
+
return {
|
|
1906
|
+
...column,
|
|
1907
|
+
className: 'rc-ui-cell-editable rc-ui-cell-index',
|
|
1908
|
+
onCell: (record, rowIndex) => {
|
|
1909
|
+
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
1910
|
+
return {
|
|
1911
|
+
'data-row-index': rowNumber,
|
|
1912
|
+
onPaste: event => {
|
|
1913
|
+
if (editingKey === '') {
|
|
1914
|
+
handlePaste(record, colIndex + 1, rowNumber, event);
|
|
1915
|
+
event.preventDefault();
|
|
1916
|
+
}
|
|
1917
|
+
},
|
|
1918
|
+
onCopy: e => {
|
|
1919
|
+
if (editingKey === '') {
|
|
1920
|
+
handleCopy(e);
|
|
1921
|
+
e.preventDefault();
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
// onClick: () => {
|
|
1925
|
+
// if (record[rowKey] !== editingKey && (editingKey !== '')) {
|
|
1926
|
+
// setEditingKey('')
|
|
1927
|
+
// }
|
|
1928
|
+
// },
|
|
1929
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex
|
|
1930
|
+
};
|
|
1931
|
+
},
|
|
1932
|
+
render: (value, record) => {
|
|
1933
|
+
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
1934
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1935
|
+
className: classNames('ui-rc_cell-content ui-rc_cell-content--index', {}),
|
|
1936
|
+
onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
|
|
1937
|
+
onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event),
|
|
1938
|
+
onMouseUp: event => handleMouseUp(event)
|
|
1939
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1940
|
+
className: 'ui-rc_content'
|
|
1941
|
+
}, findItemPath(dataSource, record, rowKey)));
|
|
1942
|
+
}
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
if (column.field === 'command') {
|
|
1946
|
+
return {
|
|
1947
|
+
...column
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1913
1950
|
return {
|
|
1914
1951
|
...column,
|
|
1915
|
-
className: 'rc-ui-cell-editable rc-ui-cell-index',
|
|
1916
1952
|
onCell: (record, rowIndex) => {
|
|
1917
1953
|
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
1918
1954
|
return {
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
event.
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
onCopy: e => {
|
|
1927
|
-
if (editingKey === '') {
|
|
1928
|
-
handleCopy(e);
|
|
1929
|
-
e.preventDefault();
|
|
1930
|
-
}
|
|
1931
|
-
},
|
|
1932
|
-
onClick: () => {
|
|
1933
|
-
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1934
|
-
setEditingKey('');
|
|
1935
|
-
}
|
|
1936
|
-
},
|
|
1937
|
-
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex
|
|
1938
|
-
};
|
|
1939
|
-
},
|
|
1940
|
-
render: (value, record) => {
|
|
1941
|
-
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
1942
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1943
|
-
className: classNames('ui-rc_cell-content ui-rc_cell-content--index', {}),
|
|
1944
|
-
onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
|
|
1945
|
-
onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event),
|
|
1946
|
-
onMouseUp: handleMouseUp
|
|
1947
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1948
|
-
className: 'ui-rc_content'
|
|
1949
|
-
}, findItemPath(dataSource, record, rowKey)));
|
|
1950
|
-
}
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
|
-
if (column.field === 'command') {
|
|
1954
|
-
return {
|
|
1955
|
-
...column
|
|
1956
|
-
};
|
|
1957
|
-
}
|
|
1958
|
-
return {
|
|
1959
|
-
...column,
|
|
1960
|
-
onCell: (record, rowIndex) => {
|
|
1961
|
-
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
1962
|
-
return {
|
|
1963
|
-
...column?.onCell?.(record, rowIndex),
|
|
1964
|
-
onKeyDown: event => {
|
|
1965
|
-
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1966
|
-
if (event.key === 'Control' && event.ctrlKey) {} else {
|
|
1967
|
-
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1968
|
-
if (record[rowKey] !== editingKey && isEditable(column, record)) {
|
|
1969
|
-
// ~~ khi editingKey = ''
|
|
1970
|
-
event.preventDefault();
|
|
1971
|
-
event.stopPropagation();
|
|
1972
|
-
handleEdit(record, column, column.editType, event);
|
|
1973
|
-
onRemoveBgSelectedCell(selectedCells.current, id);
|
|
1974
|
-
onRemoveBorderSelectedCell(selectedCells.current, id);
|
|
1975
|
-
selectedCells.current = new Set();
|
|
1976
|
-
handleCellClick(rowNumber, record, column);
|
|
1977
|
-
const hasKey = mergedExpandedKeys.has(key);
|
|
1978
|
-
if (hasKey) {
|
|
1979
|
-
// mergedExpandedKeys.delete(key);
|
|
1980
|
-
// newExpandedKeys = [...mergedExpandedKeys];
|
|
1981
|
-
} else {
|
|
1982
|
-
onTriggerExpand(record);
|
|
1983
|
-
}
|
|
1984
|
-
} else {
|
|
1985
|
-
if (event.key === 'Enter') {
|
|
1955
|
+
...column?.onCell?.(record, rowIndex),
|
|
1956
|
+
onKeyDown: event => {
|
|
1957
|
+
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1958
|
+
if (event.key === 'Control' && event.ctrlKey) {} else {
|
|
1959
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1960
|
+
if (record[rowKey] !== editingKey && isEditable(column, record)) {
|
|
1961
|
+
// ~~ khi editingKey = ''
|
|
1986
1962
|
event.preventDefault();
|
|
1987
1963
|
event.stopPropagation();
|
|
1988
|
-
|
|
1989
|
-
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1990
|
-
} else {
|
|
1991
|
-
// // focus cell hiện tại và tắt edit
|
|
1992
|
-
// handleFocusCell((rowNumber ?? 0), colIndex, column, 'vertical', event)
|
|
1993
|
-
// setEditingKey('')
|
|
1964
|
+
handleEdit(record, column, column.editType, event);
|
|
1994
1965
|
|
|
1995
|
-
|
|
1966
|
+
// onRemoveBgSelectedCell(selectedCells.current, id)
|
|
1967
|
+
// onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
1996
1968
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1969
|
+
// selectedCells.current = new Set()
|
|
1970
|
+
|
|
1971
|
+
handleCellClick(rowNumber, record, column);
|
|
1972
|
+
const hasKey = mergedExpandedKeys.has(key);
|
|
1973
|
+
if (hasKey) {
|
|
1974
|
+
// mergedExpandedKeys.delete(key);
|
|
1975
|
+
// newExpandedKeys = [...mergedExpandedKeys];
|
|
1976
|
+
} else {
|
|
1977
|
+
onTriggerExpand(record);
|
|
1978
|
+
}
|
|
1979
|
+
} else {
|
|
1980
|
+
if (event.key === 'Enter') {
|
|
1981
|
+
event.preventDefault();
|
|
1982
|
+
event.stopPropagation();
|
|
1983
|
+
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length && event.key === 'Enter') {
|
|
1984
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1985
|
+
} else {
|
|
1986
|
+
// // focus cell hiện tại và tắt edit
|
|
1987
|
+
// handleFocusCell((rowNumber ?? 0), colIndex, column, 'vertical', event)
|
|
1988
|
+
// setEditingKey('')
|
|
1989
|
+
|
|
1990
|
+
// thêm dòng mới
|
|
1991
|
+
|
|
1992
|
+
handleAddSingle();
|
|
1993
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event, true);
|
|
1994
|
+
}
|
|
1999
1995
|
}
|
|
2000
1996
|
}
|
|
2001
1997
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
1998
|
+
if (event.key === 'Tab') {
|
|
1999
|
+
if (editingKey) {} else {
|
|
2000
|
+
if (colIndex + 1 !== visibleCols.length) {
|
|
2001
|
+
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
2002
|
+
} else {
|
|
2003
|
+
event.stopPropagation();
|
|
2004
|
+
event.preventDefault();
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
if (event.key === 'ArrowRight' && colIndex + 1 !== visibleCols.length) {
|
|
2009
|
+
if (editingKey !== '') {} else {
|
|
2006
2010
|
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
2007
|
-
}
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
if (event.key === 'ArrowLeft' && colIndex > 0) {
|
|
2014
|
+
if (!column.dataIndex && !column.key || column.field === '#' || column.dataIndex === '#') {
|
|
2008
2015
|
event.stopPropagation();
|
|
2009
2016
|
event.preventDefault();
|
|
2017
|
+
} else {
|
|
2018
|
+
if (editingKey !== '') {} else {
|
|
2019
|
+
handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
|
|
2020
|
+
}
|
|
2010
2021
|
}
|
|
2011
2022
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2023
|
+
if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length) {
|
|
2024
|
+
if (isEditing(record) && (getEditType(column, record) === 'treeSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'asyncSelect')) {
|
|
2025
|
+
event.stopPropagation();
|
|
2026
|
+
} else {
|
|
2027
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
2028
|
+
}
|
|
2016
2029
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
} else {
|
|
2023
|
-
if (editingKey !== '') {} else {
|
|
2024
|
-
handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
|
|
2030
|
+
if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
|
|
2031
|
+
if (isEditing(record) && (getEditType(column, record) === 'asyncSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'treeSelect')) {
|
|
2032
|
+
event.stopPropagation();
|
|
2033
|
+
} else {
|
|
2034
|
+
handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
|
|
2025
2035
|
}
|
|
2026
2036
|
}
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
if (isEditing(record) && (getEditType(column, record) === 'treeSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'asyncSelect')) {
|
|
2030
|
-
event.stopPropagation();
|
|
2031
|
-
} else {
|
|
2032
|
-
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
2037
|
+
if (event.key === 'Delete') {
|
|
2038
|
+
handleDeleteContent();
|
|
2033
2039
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
if (isEditing(record) && (getEditType(column, record) === 'asyncSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'treeSelect')) {
|
|
2037
|
-
event.stopPropagation();
|
|
2038
|
-
} else {
|
|
2039
|
-
handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
|
|
2040
|
+
if (event.key === 'Escape') {
|
|
2041
|
+
setEditingKey('');
|
|
2040
2042
|
}
|
|
2041
2043
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
+
},
|
|
2045
|
+
onPaste: event => {
|
|
2046
|
+
if (editingKey === '') {
|
|
2047
|
+
handlePaste(record, colIndex, rowNumber, event);
|
|
2048
|
+
event.preventDefault();
|
|
2044
2049
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2050
|
+
},
|
|
2051
|
+
onCopy: e => {
|
|
2052
|
+
if (editingKey === '') {
|
|
2053
|
+
handleCopy(e);
|
|
2054
|
+
e.preventDefault();
|
|
2047
2055
|
}
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
},
|
|
2056
|
-
onCopy: e => {
|
|
2057
|
-
if (editingKey === '') {
|
|
2058
|
-
handleCopy(e);
|
|
2059
|
-
e.preventDefault();
|
|
2060
|
-
}
|
|
2061
|
-
},
|
|
2062
|
-
onDoubleClick: event => {
|
|
2063
|
-
if (!isEditing(record) && record[rowKey] !== editingKey && isEditable(column, record)) {
|
|
2064
|
-
handleEdit(record, column, getEditType(column, record), event);
|
|
2065
|
-
onRemoveBgSelectedCell(selectedCells.current, id);
|
|
2066
|
-
onRemoveBorderSelectedCell(selectedCells.current, id);
|
|
2067
|
-
handleCellClick(rowNumber, record, column);
|
|
2068
|
-
}
|
|
2069
|
-
},
|
|
2070
|
-
onContextMenu: () => {
|
|
2071
|
-
// isSelecting.current = true;
|
|
2072
|
-
// startCell.current = { row: rowNumber, col: colIndex };
|
|
2073
|
-
|
|
2074
|
-
if (selectedCells.size === 0) {
|
|
2075
|
-
// setStartSelectedCell({ row: rowNumber, col: colIndex })
|
|
2076
|
-
// setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
|
|
2077
|
-
|
|
2078
|
-
startSelectedCells.current = {
|
|
2079
|
-
row: rowNumber,
|
|
2080
|
-
col: colIndex
|
|
2081
|
-
};
|
|
2082
|
-
selectedCells.current = new Set([`${rowNumber}-${colIndex}`]);
|
|
2083
|
-
rowsSelected.current = new Set();
|
|
2084
|
-
}
|
|
2085
|
-
},
|
|
2086
|
-
onClick: () => {
|
|
2087
|
-
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
2088
|
-
setEditingKey('');
|
|
2089
|
-
} else {
|
|
2090
|
-
if (editingKey) {
|
|
2056
|
+
},
|
|
2057
|
+
onDoubleClick: event => {
|
|
2058
|
+
if (!isEditing(record) && record[rowKey] !== editingKey && isEditable(column, record)) {
|
|
2059
|
+
handleEdit(record, column, getEditType(column, record), event);
|
|
2060
|
+
|
|
2061
|
+
// onRemoveBgSelectedCell(selectedCells.current, id)
|
|
2062
|
+
// onRemoveBorderSelectedCell(selectedCells.current, id)
|
|
2091
2063
|
handleCellClick(rowNumber, record, column);
|
|
2092
2064
|
}
|
|
2065
|
+
},
|
|
2066
|
+
onContextMenu: () => {
|
|
2067
|
+
// isSelecting.current = true;
|
|
2068
|
+
// startCell.current = { row: rowNumber, col: colIndex };
|
|
2069
|
+
|
|
2070
|
+
if (selectedCells.size === 0) {
|
|
2071
|
+
// setStartSelectedCell({ row: rowNumber, col: colIndex })
|
|
2072
|
+
// setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
|
|
2073
|
+
|
|
2074
|
+
startSelectedCells.current = {
|
|
2075
|
+
row: rowNumber,
|
|
2076
|
+
col: colIndex
|
|
2077
|
+
};
|
|
2078
|
+
selectedCells.current = new Set([`${rowNumber}-${colIndex}`]);
|
|
2079
|
+
rowsSelected.current = new Set();
|
|
2080
|
+
}
|
|
2081
|
+
},
|
|
2082
|
+
onClick: () => {
|
|
2083
|
+
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
2084
|
+
// setEditingKey('')
|
|
2085
|
+
} else {
|
|
2086
|
+
if (record[rowKey] !== editingKey) {
|
|
2087
|
+
onAddBorderSelectedCell(selectedCells.current, id);
|
|
2088
|
+
}
|
|
2089
|
+
if (editingKey) {
|
|
2090
|
+
handleCellClick(rowNumber, record, column);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
},
|
|
2094
|
+
// className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!isEditable(column as any, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!isEditable(column as any, record) ? 'disable' : ''}`,
|
|
2095
|
+
className: classNames('rc-ui-cell-editable', {
|
|
2096
|
+
'cell-editing': isEditing(record),
|
|
2097
|
+
'cell-editable': !isEditing(record)
|
|
2098
|
+
// selected: isSelectedCell(rangeCells,rowIndex, colIndex),
|
|
2099
|
+
// 'cell-border-bottom': isRangeCell(rangeCells, 'bottom',rowIndex, colIndex),
|
|
2100
|
+
// 'cell-border-right': isRangeCell(rangeCells, 'right',rowIndex, colIndex),
|
|
2101
|
+
// 'cell-border-top': isRangeCell(rangeCells, 'top',rowIndex, colIndex),
|
|
2102
|
+
// 'cell-border-left': isRangeCell(rangeCells, 'left',rowIndex, colIndex),
|
|
2103
|
+
// disable: !isEditable(column as any, record)
|
|
2104
|
+
}),
|
|
2105
|
+
record,
|
|
2106
|
+
column: column,
|
|
2107
|
+
editType: getEditType(column, record),
|
|
2108
|
+
dataIndex: column.dataIndex,
|
|
2109
|
+
indexRow: rowNumber,
|
|
2110
|
+
indexCol: colIndex,
|
|
2111
|
+
title: getValueCell(column, record[column.field], format),
|
|
2112
|
+
'data-col-index': colIndex,
|
|
2113
|
+
'data-row-index': rowNumber,
|
|
2114
|
+
'data-tooltip-id': "tooltip-cell-content",
|
|
2115
|
+
editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column, record),
|
|
2116
|
+
cellEditing,
|
|
2117
|
+
t,
|
|
2118
|
+
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
|
|
2119
|
+
style: isPasteDragging ? {
|
|
2120
|
+
cursor: "crosshair"
|
|
2121
|
+
} : {}
|
|
2122
|
+
};
|
|
2123
|
+
},
|
|
2124
|
+
onHeaderCell: (data, index) => {
|
|
2125
|
+
return {
|
|
2126
|
+
...(column.onHeaderCell ? column.onHeaderCell?.(data, index) : {}),
|
|
2127
|
+
onClick: () => {
|
|
2128
|
+
handleClickColHeader(column, colIndex);
|
|
2129
|
+
},
|
|
2130
|
+
onCopy: e => {
|
|
2131
|
+
if (editingKey === '') {
|
|
2132
|
+
handleCopy(e);
|
|
2133
|
+
e.preventDefault();
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
onPaste: event => {
|
|
2137
|
+
if (editingKey === '') {
|
|
2138
|
+
handlePaste(dataSource[0], colIndex, 0, event);
|
|
2139
|
+
event.preventDefault();
|
|
2140
|
+
}
|
|
2141
|
+
},
|
|
2142
|
+
style: {
|
|
2143
|
+
userSelect: 'none'
|
|
2093
2144
|
}
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
title: getValueCell(column, record[column.field], format),
|
|
2103
|
-
'data-col-index': colIndex,
|
|
2104
|
-
'data-row-index': rowNumber,
|
|
2105
|
-
'data-tooltip-id': "tooltip-cell-content",
|
|
2106
|
-
// 'data-tooltip-content': 'tooltip-cell-content',
|
|
2107
|
-
// 'data-tooltip-delay-show': 1000,
|
|
2108
|
-
// 'data-tooltip-content': getValueCell(column, record[column.field as any], format),
|
|
2109
|
-
editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column, record),
|
|
2110
|
-
cellEditing,
|
|
2111
|
-
t,
|
|
2112
|
-
tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
|
|
2113
|
-
style: isPasteDragging ? {
|
|
2114
|
-
cursor: "crosshair"
|
|
2115
|
-
} : {}
|
|
2116
|
-
};
|
|
2117
|
-
},
|
|
2118
|
-
onHeaderCell: (data, index) => {
|
|
2119
|
-
return {
|
|
2120
|
-
...(column.onHeaderCell ? column.onHeaderCell?.(data, index) : {}),
|
|
2121
|
-
onClick: () => {
|
|
2122
|
-
handleClickColHeader(column, colIndex);
|
|
2123
|
-
},
|
|
2124
|
-
onCopy: e => {
|
|
2125
|
-
if (editingKey === '') {
|
|
2126
|
-
handleCopy(e);
|
|
2127
|
-
e.preventDefault();
|
|
2128
|
-
}
|
|
2129
|
-
},
|
|
2130
|
-
onPaste: event => {
|
|
2131
|
-
if (editingKey === '') {
|
|
2132
|
-
handlePaste(dataSource[0], colIndex, 0, event);
|
|
2133
|
-
event.preventDefault();
|
|
2134
|
-
}
|
|
2135
|
-
},
|
|
2136
|
-
style: {
|
|
2137
|
-
userSelect: 'none'
|
|
2138
|
-
}
|
|
2139
|
-
};
|
|
2140
|
-
},
|
|
2141
|
-
render: (value, record, rowIndex) => {
|
|
2142
|
-
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
2143
|
-
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
2144
|
-
const cellFormat = getFormat(colFormat, format);
|
|
2145
|
-
const rowError = dataErrors.find(it => it.index === rowNumber);
|
|
2146
|
-
const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
|
|
2147
|
-
|
|
2148
|
-
// const aaa = dataErrors.find((it) => column?.field && it[column.field].field === column.field && it.index === rowNumber)
|
|
2149
|
-
// const aaa = column.field && rowError && rowError[column.field]?.field === column?.field
|
|
2150
|
-
|
|
2151
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
2152
|
-
className: classNames('ui-rc_cell-content', {
|
|
2153
|
-
// disable: !isEditable(column as any, record)
|
|
2154
|
-
isValid: column.field && rowError && rowError[column.field]?.field === column?.field
|
|
2155
|
-
}),
|
|
2156
|
-
onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
|
|
2157
|
-
onMouseEnter: event => {
|
|
2158
|
-
// setTooltipContent(cellError ? cellError.message : renderContent(column as any, value, record, rowIndex, cellFormat))
|
|
2159
|
-
setTooltipContent(cellError ? cellError.message : '');
|
|
2160
|
-
handleMouseEnter(rowNumber, colIndex, event);
|
|
2161
|
-
},
|
|
2162
|
-
onMouseUp: handleMouseUp,
|
|
2163
|
-
onMouseMove: () => {
|
|
2164
|
-
if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
|
|
2165
|
-
hideDraggingPoint(selectedCells.current, id);
|
|
2166
|
-
isDragMouse.current = true;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2145
|
+
};
|
|
2146
|
+
},
|
|
2147
|
+
render: (value, record, rowIndex) => {
|
|
2148
|
+
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
2149
|
+
const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
|
|
2150
|
+
const cellFormat = getFormat(colFormat, format);
|
|
2151
|
+
const rowError = dataErrors.find(it => it.index === rowNumber);
|
|
2152
|
+
const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
|
|
2169
2153
|
|
|
2170
|
-
//
|
|
2171
|
-
//
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2154
|
+
// const aaa = dataErrors.find((it) => column?.field && it[column.field].field === column.field && it.index === rowNumber)
|
|
2155
|
+
// const aaa = column.field && rowError && rowError[column.field]?.field === column?.field
|
|
2156
|
+
|
|
2157
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2158
|
+
className: classNames('ui-rc_cell-content', {
|
|
2159
|
+
// disable: !isEditable(column as any, record)
|
|
2160
|
+
isValid: column.field && rowError && rowError[column.field]?.field === column?.field
|
|
2161
|
+
}),
|
|
2162
|
+
onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
|
|
2163
|
+
onMouseEnter: event => {
|
|
2164
|
+
// setTooltipContent(cellError ? cellError.message : renderContent(column as any, value, record, rowIndex, cellFormat))
|
|
2165
|
+
setTooltipContent(cellError ? cellError.message : '');
|
|
2166
|
+
handleMouseEnter(rowNumber, colIndex, event);
|
|
2167
|
+
},
|
|
2168
|
+
onMouseUp: handleMouseUp,
|
|
2169
|
+
onMouseMove: () => {
|
|
2170
|
+
if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
|
|
2171
|
+
hideDraggingPoint(selectedCells.current, id);
|
|
2172
|
+
isDragMouse.current = true;
|
|
2173
|
+
}
|
|
2189
2174
|
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2175
|
+
|
|
2176
|
+
// onClick={(event) => {
|
|
2177
|
+
//
|
|
2178
|
+
// handleClickCell(event)
|
|
2179
|
+
//
|
|
2180
|
+
// }}
|
|
2181
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2182
|
+
className: 'ui-rc_content'
|
|
2183
|
+
}, renderContent(column, value, record, rowIndex, cellFormat)),
|
|
2184
|
+
// selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
|
|
2185
|
+
// getLastSelectCell(selectedCells.current).col === colIndex &&
|
|
2186
|
+
// isEditable(column as any, record) &&
|
|
2187
|
+
|
|
2188
|
+
!isDragMouse.current && /*#__PURE__*/React.createElement("div", {
|
|
2189
|
+
className: 'dragging-point hidden',
|
|
2190
|
+
onMouseDown: e => {
|
|
2191
|
+
// e.stopPropagation()
|
|
2192
|
+
e.preventDefault();
|
|
2193
|
+
if (e.button === 0) {
|
|
2194
|
+
setIsPasteDragging(true);
|
|
2195
|
+
}
|
|
2196
|
+
},
|
|
2197
|
+
onDoubleClick: handlePointDoubleClick
|
|
2198
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2199
|
+
className: 'dot-point'
|
|
2200
|
+
})));
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
});
|
|
2204
|
+
}, [cellEditing, columns, dataErrors, dataSource, editingKey, format, getRowKey, handleAddSingle, handleCellClick, handleClickColHeader, handleCopy, handleDeleteContent, handleEdit, handleFocusCell, handleMouseDown, handleMouseDownRowHeader, handleMouseEnter, handleMouseEnterRowHeader, handleMouseUp, handlePaste, handlePointDoubleClick, id, isEditing, isPasteDragging, mergedExpandedKeys, onTriggerExpand, rangeCells, rowEditable, rowKey, setTooltipContent, t, visibleCols.length]);
|
|
2198
2205
|
const transformColumns = React.useCallback(cols => {
|
|
2199
2206
|
// @ts-ignore
|
|
2200
2207
|
return cols.map(column => {
|