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