es-grid-template 1.3.3 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/assets/index.css +10 -0
  2. package/assets/index.scss +15 -0
  3. package/es/grid-component/ContextMenu.js +4 -1
  4. package/es/grid-component/EditableCell.js +60 -18
  5. package/es/grid-component/TableGrid.js +5 -8
  6. package/es/grid-component/hooks/columns/index.js +17 -16
  7. package/es/grid-component/hooks/content/HeaderContent.js +3 -1
  8. package/es/grid-component/hooks/useColumns.js +2 -1
  9. package/es/grid-component/hooks/utils.d.ts +13 -0
  10. package/es/grid-component/hooks/utils.js +136 -4
  11. package/es/grid-component/number/index.d.ts +10 -0
  12. package/es/grid-component/number/index.js +39 -0
  13. package/es/grid-component/styles.scss +15 -0
  14. package/es/grid-component/table/GridEdit.js +597 -209
  15. package/es/grid-component/type.d.ts +3 -0
  16. package/es/grid-component/useContext.d.ts +2 -0
  17. package/lib/grid-component/ContextMenu.js +4 -1
  18. package/lib/grid-component/EditableCell.js +61 -18
  19. package/lib/grid-component/TableGrid.js +5 -8
  20. package/lib/grid-component/hooks/columns/index.js +16 -15
  21. package/lib/grid-component/hooks/content/HeaderContent.js +3 -1
  22. package/lib/grid-component/hooks/useColumns.js +2 -1
  23. package/lib/grid-component/hooks/utils.d.ts +13 -0
  24. package/lib/grid-component/hooks/utils.js +150 -7
  25. package/lib/grid-component/number/index.d.ts +10 -0
  26. package/lib/grid-component/number/index.js +47 -0
  27. package/lib/grid-component/styles.scss +15 -0
  28. package/lib/grid-component/table/GridEdit.js +585 -205
  29. package/lib/grid-component/type.d.ts +3 -0
  30. package/lib/grid-component/useContext.d.ts +2 -0
  31. package/package.json +109 -109
@@ -29,11 +29,92 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
29
29
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
30
30
  // import Command from "../Command";
31
31
 
32
+ // import type {ContextMenuItem} from "../type";
32
33
  // import {ContextInfo, ContextMenuItem} from "../type";
33
34
  // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
34
35
 
36
+ const {
37
+ Paragraph,
38
+ Title
39
+ } = _antd.Typography;
35
40
  _dayjs.default.extend(_customParseFormat.default);
36
41
  const toast = 'top-right';
42
+ // const defaultContext: ContextMenuItem[] = [
43
+ const defaultContext = [{
44
+ key: 'INSERT_BEFORE',
45
+ label: 'Thêm dòng bên trên',
46
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
47
+ fontSize: 14
48
+ }),
49
+ children: [{
50
+ parentKey: 'INSERT_BEFORE',
51
+ key: 'INSERT_BEFORE_1',
52
+ label: 'Thêm 1 dòng',
53
+ row: 1
54
+ }, {
55
+ parentKey: 'INSERT_BEFORE',
56
+ key: 'INSERT_BEFORE_10',
57
+ label: 'Thêm 10 dòng',
58
+ row: 10
59
+ }, {
60
+ parentKey: 'INSERT_BEFORE',
61
+ key: 'INSERT_BEFORE_50',
62
+ label: 'Thêm 50 dòng',
63
+ row: 50
64
+ }, {
65
+ parentKey: 'INSERT_BEFORE',
66
+ key: 'INSERT_BEFORE_100',
67
+ label: 'Thêm 100 dòng',
68
+ row: 100
69
+ }, {
70
+ parentKey: 'INSERT_BEFORE',
71
+ key: 'INSERT_BEFORE_ADV',
72
+ label: 'Tùy chỉnh'
73
+ }]
74
+ }, {
75
+ key: 'INSERT_AFTER',
76
+ label: 'Thêm dòng bên dưới',
77
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
78
+ fontSize: 14
79
+ }),
80
+ children: [{
81
+ parentKey: 'INSERT_AFTER',
82
+ key: 'INSERT_AFTER_1',
83
+ label: 'Thêm 1 dòng',
84
+ row: 1
85
+ }, {
86
+ parentKey: 'INSERT_AFTER',
87
+ key: 'INSERT_AFTER_10',
88
+ label: 'Thêm 10 dòng',
89
+ row: 10
90
+ }, {
91
+ parentKey: 'INSERT_AFTER',
92
+ key: 'INSERT_AFTER_50',
93
+ label: 'Thêm 50 dòng',
94
+ row: 50
95
+ }, {
96
+ parentKey: 'INSERT_AFTER',
97
+ key: 'INSERT_AFTER_100',
98
+ label: 'Thêm 100 dòng',
99
+ row: 100
100
+ }, {
101
+ parentKey: 'INSERT_AFTER',
102
+ key: 'INSERT_AFTER_ADV',
103
+ label: 'Tùy chỉnh'
104
+ }]
105
+ }, {
106
+ key: 'DELETE_CONTENT',
107
+ label: 'Xóa nội dung',
108
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Trash2, {
109
+ fontSize: 14
110
+ })
111
+ }, {
112
+ key: 'DELETE_ROWS',
113
+ label: 'Xóa dòng',
114
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Trash2, {
115
+ fontSize: 14
116
+ })
117
+ }];
37
118
  const GridEdit = props => {
38
119
  const {
39
120
  id,
@@ -60,6 +141,8 @@ const GridEdit = props => {
60
141
  expandable,
61
142
  onCellClick,
62
143
  rowEditable,
144
+ contextMenuItems: propsContext,
145
+ showDefaultContext,
63
146
  ...rest
64
147
  } = props;
65
148
  const {
@@ -94,6 +177,21 @@ const GridEdit = props => {
94
177
  const [editingKey, setEditingKey] = (0, _react.useState)('');
95
178
  const [isFilter, setIsFilter] = _react.default.useState(false);
96
179
  const [selectedCells, setSelectedCells] = (0, _react.useState)(new Set());
180
+
181
+ // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
182
+
183
+ // const [isCtrlDown, setIsCtrlDown] = useState(false)
184
+
185
+ // const [ctrlCells, setCtrlCells] = useState<any>([])
186
+ // const [currentCtrlCells, setCurrentCtrlCells] = useState<any>(new Set())
187
+
188
+ const [openModalAddRow, setOpenModalAddRow] = (0, _react.useState)({
189
+ open: false,
190
+ type: ''
191
+ });
192
+ // const [openModalPaste, setOpenModalPaste] = useState(defaultModalPaste)
193
+
194
+ const [rowsAdd, setRowsAdd] = (0, _react.useState)(1);
97
195
  const [pasteCells, setPasteCells] = (0, _react.useState)(new Set());
98
196
  const [cellEditing, setCellEditing] = (0, _react.useState)(null);
99
197
  const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
@@ -118,32 +216,12 @@ const GridEdit = props => {
118
216
  return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
119
217
  }, [selectedCells]);
120
218
  const contextMenuItems = _react.default.useMemo(() => {
121
- return [{
122
- key: 'INSERT_BEFORE',
123
- label: 'Thêm dòng bên trên',
124
- icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
125
- fontSize: 14
126
- })
127
- }, {
128
- key: 'INSERT_AFTER',
129
- label: 'Thêm dòng bên dưới',
130
- icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
131
- fontSize: 14
132
- })
133
- }, {
134
- key: 'DELETE_CONTENT',
135
- label: 'Xóa nội dung',
136
- icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Trash2, {
137
- fontSize: 14
138
- })
139
- }, {
140
- key: 'DELETE_ROWS',
141
- label: 'Xóa dòng',
142
- icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Trash2, {
143
- fontSize: 14
144
- })
145
- }];
146
- }, []);
219
+ const a = showDefaultContext !== false ? [...defaultContext] : [];
220
+ const b = propsContext ? [...propsContext, {
221
+ type: 'divider'
222
+ }] : [];
223
+ return [...b, ...a];
224
+ }, [propsContext, showDefaultContext]);
147
225
  const onTriggerExpand = _react.default.useCallback(record => {
148
226
  const key = getRowKey(record, dataSource.indexOf(record));
149
227
  let newExpandedKeys;
@@ -458,6 +536,7 @@ const GridEdit = props => {
458
536
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
459
537
  }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
460
538
  overlayClassName: 'be-popup-container',
539
+ trigger: ['click'],
461
540
  style: {
462
541
  color: '#28c76f',
463
542
  borderColor: '#28c76f'
@@ -668,8 +747,6 @@ const GridEdit = props => {
668
747
  // defaultValues,
669
748
  // resolver: yupResolver(formSchema)
670
749
  });
671
-
672
- // @ts-ignore
673
750
  const isEditing = record => record[rowKey] === editingKey;
674
751
  (0, _react.useEffect)(() => {
675
752
  const handleClickOutside = event => {
@@ -678,6 +755,7 @@ const GridEdit = props => {
678
755
  // const tableId = id ? document.getElementById(id) : undefined
679
756
  // const tableBodies = document.getElementsByClassName("ui-rc-table-tbody");
680
757
  const container = document.querySelector(".be-popup-container");
758
+ const containerContextMenu = document.querySelector(".popup-context-menu");
681
759
  const tableBody = document.querySelector(`#${id} .ui-rc-table-tbody`);
682
760
  // const containerHidden = document.querySelector(".be-popup-container.ant-picker-dropdown-hidden")
683
761
 
@@ -685,9 +763,10 @@ const GridEdit = props => {
685
763
  const itemContainer = document.querySelector(`#${id} .ui-rc-toolbar-selection-overflow-item`);
686
764
  const itemHeader = document.querySelector(`#${id} .ui-rc-table-thead`);
687
765
  const isInsideContainer = element.closest(".be-popup-container") && container;
766
+ const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
688
767
  const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
689
768
  const isInsideHeader = itemHeader && itemHeader.contains(event.target);
690
- if (isInsideContainer || isInsideToolbar || isInsideHeader) {
769
+ if (isInsideContainer || isInsideToolbar || isInsideHeader || isInsideContainerContext) {
691
770
  return;
692
771
  }
693
772
 
@@ -721,66 +800,53 @@ const GridEdit = props => {
721
800
  document.removeEventListener("click", handleClickOutside);
722
801
  };
723
802
  }, []);
724
- const handleMouseDown = (0, _react.useCallback)((record, row, col, e) => {
725
- // setEditingKey('')
726
-
803
+ const handleMouseDown = (record, row, col, e) => {
727
804
  if (e.button === 2) {
728
805
  e.stopPropagation();
729
806
  return;
730
807
  }
731
- isSelecting.current = true;
732
- startCell.current = {
733
- row,
734
- col
735
- };
736
- if (e.target.className === 'dragging-point') {
737
- // e.stopPropagation()
738
- // e.preventDefault()
739
- } else {
740
- // isSelecting.current = true;
741
- // startCell.current = { row, col };
808
+ if (e.ctrlKey) {
809
+ isSelecting.current = true;
810
+ startCell.current = {
811
+ row,
812
+ col
813
+ };
742
814
 
743
- // if (!isPasteDragging) {
744
- setStartSelectedCell({
815
+ // const cell: any = new Set([`${row}-${col}`])
816
+
817
+ // setCurrentCtrlCells(cell)
818
+ } else {
819
+ isSelecting.current = true;
820
+ startCell.current = {
745
821
  row,
746
822
  col
747
- });
748
- setSelectedCells(new Set([`${row}-${col}`]));
749
- setRowsSelected(new Set());
750
- // }
823
+ };
824
+ if (e.target.className === 'dragging-point') {
825
+ // e.stopPropagation()
826
+ // e.preventDefault()
827
+ } else {
828
+ setStartSelectedCell({
829
+ row,
830
+ col
831
+ });
832
+ setSelectedCells(new Set([`${row}-${col}`]));
833
+ setRowsSelected(new Set());
834
+ }
751
835
  }
752
836
 
753
- // setSelectIsDragging(true)
754
-
755
837
  // isSelecting.current = true;
756
838
  // startCell.current = { row, col };
757
839
  //
758
- // if (!isPasteDragging) {
759
- // setStartSelectedCell({ row, col })
840
+ // if (e.target.className === 'dragging-point') {
841
+ // // e.stopPropagation()
842
+ // // e.preventDefault()
843
+ // } else {
844
+ //
845
+ // setStartSelectedCell({row, col})
760
846
  // setSelectedCells(new Set([`${row}-${col}`]));
761
847
  // setRowsSelected(new Set())
762
848
  // }
763
- }, []);
764
-
765
- // const handlePointEnter = (e: any) => {
766
- //
767
- // if (e.button === 2) {
768
- // e.stopPropagation()
769
- // return
770
- // }
771
- //
772
- // // setIsPasteDragging(true);
773
- //
774
- // };
775
-
776
- // const handlePointLeave = () => {
777
- //
778
- // if (isPasteDragging && !isSelectDragging) {
779
- // // setIsPasteDragging(false);
780
- // }
781
- //
782
- // };
783
-
849
+ };
784
850
  const triggerDragPaste = pastesArray => {
785
851
  const mergedSet = new Set([...selectedCells, ...pastesArray]);
786
852
  setSelectedCells(mergedSet);
@@ -880,18 +946,49 @@ const GridEdit = props => {
880
946
  }
881
947
  triggerDragPaste(newPasteCells);
882
948
  };
883
- const handleMouseUp = () => {
949
+
950
+ // const handleClickCell = (e: any) => {
951
+ //
952
+ // if (e.ctrlKey) {
953
+ //
954
+ // const cell: any = new Set([`${row}-${col}`])
955
+ //
956
+ // const found = ctrlCells.find((s: any) => isEqualSet(s, cell));
957
+ //
958
+ // if (found) {
959
+ // const rs = ctrlCells.filter((s: any) => !isEqualSet(s, cell));
960
+ //
961
+ // setCtrlCells(rs)
962
+ //
963
+ // } else {
964
+ // setCtrlCells([...ctrlCells, cell])
965
+ // }
966
+ //
967
+ // }
968
+ // }
969
+
970
+ const handleMouseUp = e => {
884
971
  isSelecting.current = false;
885
972
  startCell.current = null;
886
973
  isSelectingRow.current = false;
887
974
  rowStart.current = null;
888
975
  setIsPasteDragging(false);
889
976
  setSelectIsDragging(false);
977
+
978
+ // setCurrentCtrlCells(new Set())
979
+
980
+ if (e.ctrlKey) {
981
+
982
+ // setCtrlCells([...ctrlCells, currentCtrlCells])
983
+ }
984
+
985
+ // nếu ctrlCell length > 0 thì set selectCells
986
+
890
987
  if (pasteCells.size > 0) {
891
988
  triggerDragPaste(pasteCells);
892
989
  }
893
990
  };
894
- const handleMouseEnter = (row, col) => {
991
+ const handleMouseEnter = (row, col, e) => {
895
992
  if (!isSelecting.current || !startCell.current) {
896
993
  return;
897
994
  }
@@ -899,6 +996,18 @@ const GridEdit = props => {
899
996
  row: startRow,
900
997
  col: startCol
901
998
  } = startCell.current;
999
+ if (e.ctrlKey) {
1000
+ // const newCtrlCells = new Set();
1001
+ // for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
1002
+ // for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
1003
+ // newCtrlCells.add(`${r}-${c}`)
1004
+ // }
1005
+ // }
1006
+
1007
+ // setCurrentCtrlCells(newCtrlCells)
1008
+
1009
+ return;
1010
+ }
902
1011
  if (!isPasteDragging) {
903
1012
  // chọn vùng copy
904
1013
 
@@ -938,6 +1047,14 @@ const GridEdit = props => {
938
1047
  }
939
1048
  if (row < rowSelectedEnd) {
940
1049
  // kéo lên trên
1050
+
1051
+ const rowSelectedStart = (0, _hooks.getFirstSelectCell)(selectedCells).row;
1052
+ const newPasteCells = new Set();
1053
+ for (let r = Math.min(rowSelectedStart, row); r <= Math.max(rowSelectedStart, row) - 1; r++) {
1054
+ for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
1055
+ newPasteCells.add(`${r}-${c}`);
1056
+ }
1057
+ }
941
1058
  }
942
1059
  if (col > colEnd) {
943
1060
  // kéo sang phải
@@ -945,14 +1062,6 @@ const GridEdit = props => {
945
1062
  if (row < colStart) {
946
1063
  // kéo sang trái
947
1064
  }
948
-
949
- // const newPasteCells = new Set()
950
- // for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
951
- // for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
952
- // newPasteCells.add(`${r}-${c}`);
953
- // }
954
- // }
955
- // setPasteCells(newPasteCells)
956
1065
  }
957
1066
  };
958
1067
  const handleClickRowHeader = (row, col) => {
@@ -1050,7 +1159,7 @@ const GridEdit = props => {
1050
1159
  return {
1051
1160
  row,
1052
1161
  col,
1053
- value: (0, _hooks.flattenData)(childrenColumnName, dataSource)[row][columnKey]
1162
+ value: (0, _hooks.flattenData)(childrenColumnName, dataSource)[row][columnKey] ?? ''
1054
1163
  };
1055
1164
  // return { row, col, value: '' };
1056
1165
  });
@@ -1083,22 +1192,17 @@ const GridEdit = props => {
1083
1192
  e.clipboardData.setData("text/plain", copyText);
1084
1193
  (0, _Message.default)(t ? t('CopySuccessful') : 'Copy Successful');
1085
1194
  };
1086
- const handlePaste = (record, indexCol, rowNumber, e) => {
1087
- // const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
1088
- const pasteData = e.clipboardData.getData("text/plain").trim();
1089
-
1090
- // Chuyển đổi dữ liệu từ clipboard thành mảng
1091
- const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
1195
+ const handlePasted = (record, indexCol, rowNumber, pasteData) => {
1196
+ const rows = pasteData.slice(0, onCellPaste?.maxRowsPaste ?? 200);
1092
1197
  if (!record?.parentId) {
1093
1198
  // Cập nhật data mới
1094
1199
  const newData = [...dataSource];
1095
1200
 
1096
- // @ts-ignore
1097
- const indexRows = newData.findIndex(it => it[rowKey] === record[rowKey]);
1201
+ // const indexRows = newData.findIndex((it) => it[rowKey as any] === record[rowKey])
1098
1202
 
1099
1203
  // Lấy vị trí bắt đầu
1100
1204
  // const { row: startRow, col: startCol } = selectedCell;
1101
- const startRow = indexRows;
1205
+ const startRow = newData.findIndex(it => it[rowKey] === record[rowKey]);
1102
1206
  const startCol = indexCol;
1103
1207
 
1104
1208
  // const flattData = flattenArray(newData);
@@ -1197,6 +1301,167 @@ const GridEdit = props => {
1197
1301
  triggerPaste?.(pastedRows, pastedColumnsArray, newDataSource);
1198
1302
  }
1199
1303
  };
1304
+ const handlePaste = (record, indexCol, rowNumber, e) => {
1305
+ // const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
1306
+ const pasteData = e.clipboardData.getData("text/plain");
1307
+
1308
+ // Chuyển đổi dữ liệu từ clipboard thành mảng
1309
+ const rowsPasted = pasteData.split("\n").map(row =>
1310
+ // const rows = pasteData.split("\n").map((row: any) =>
1311
+ row.replace(/\r/g, "").split("\t"));
1312
+ if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
1313
+ // bật popup thông báo
1314
+
1315
+ _antd.Modal.confirm({
1316
+ content: /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Paragraph, {
1317
+ style: {
1318
+ marginBottom: '.25rem',
1319
+ fontSize: 14
1320
+ }
1321
+ }, "D\u1EEF li\u1EC7u sao ch\xE9p v\u01B0\u1EE3t qu\xE1 s\u1ED1 d\xF2ng cho ph\xE9p (500 d\xF2ng).Ph\u1EA7n m\u1EC1n s\u1EBD ch\u1EC9 l\u1EA5y 500 d\xF2ng \u0111\u1EA7u ti\xEAn."), /*#__PURE__*/_react.default.createElement(Title, {
1322
+ level: 5,
1323
+ style: {
1324
+ marginTop: '.75rem'
1325
+ }
1326
+ }, "B\u1EA1n c\xF3 mu\u1ED1n ti\u1EBFp t\u1EE5c sao ch\xE9p kh\xF4ng?")),
1327
+ centered: true,
1328
+ className: 'be-popup-container',
1329
+ onOk: () => {
1330
+ handlePasted(record, indexCol, rowNumber, rowsPasted);
1331
+ }
1332
+ // footer: (_, { OkBtn, CancelBtn }) => (
1333
+ // <>
1334
+ // <OkBtn />
1335
+ // <CancelBtn />
1336
+ // </>
1337
+ // ),
1338
+ });
1339
+ } else {
1340
+ handlePasted(record, indexCol, rowNumber, rowsPasted);
1341
+ }
1342
+
1343
+ // const rows = rowsPasted.slice(0, (onCellPaste?.maxRowsPaste ?? 200));
1344
+ //
1345
+ //
1346
+ // if (!record?.parentId ) {
1347
+ //
1348
+ // // Cập nhật data mới
1349
+ // const newData = [...dataSource];
1350
+ //
1351
+ // // @ts-ignore
1352
+ // const indexRows = newData.findIndex((it) => it[rowKey] === record[rowKey])
1353
+ //
1354
+ // // Lấy vị trí bắt đầu
1355
+ // // const { row: startRow, col: startCol } = selectedCell;
1356
+ // const startRow = indexRows
1357
+ // const startCol = indexCol
1358
+ //
1359
+ //
1360
+ //
1361
+ // // const flattData = flattenArray(newData);
1362
+ //
1363
+ // const pastedRows: RecordType[] = [];
1364
+ // const pastedColumns = new Set()
1365
+ //
1366
+ //
1367
+ // rows.forEach((rowValues: any, rowIndex: any) => {
1368
+ // const targetRow = startRow + rowIndex;
1369
+ //
1370
+ // // Nếu vượt quá số dòng hiện có, thêm dòng mới
1371
+ // if (targetRow >= newData.length) {
1372
+ // // @ts-ignore
1373
+ // // newData.push({ id: newGuid()});
1374
+ // newData.push({ id: undefined, rowId: newGuid()});
1375
+ // }
1376
+ //
1377
+ // rowValues.forEach((cellValue: any, colIndex: any) => {
1378
+ // const targetCol = startCol + colIndex;
1379
+ // if (targetCol >= columns.length) { // Không vượt quá số cột
1380
+ // return
1381
+ // }
1382
+ //
1383
+ // if (columns[targetCol].editEnable) {
1384
+ // // @ts-ignore
1385
+ // const columnKey = columns[targetCol].field;
1386
+ //
1387
+ // // @ts-ignore
1388
+ // newData[targetRow] = { ...newData[targetRow], [columnKey]: cellValue.trim() };
1389
+ // pastedColumns.add(columnKey);
1390
+ // }
1391
+ //
1392
+ // });
1393
+ //
1394
+ // // Lưu dòng được paste
1395
+ // pastedRows.push(newData[targetRow]);
1396
+ //
1397
+ // });
1398
+ //
1399
+ // const pastedColumnsArray = Array.from(pastedColumns) ?? [];
1400
+ //
1401
+ // triggerPaste?.(pastedRows, pastedColumnsArray as string[], newData)
1402
+ //
1403
+ //
1404
+ // } else {
1405
+ //
1406
+ // // Cập nhật data mới
1407
+ // const newData = [...dataSource];
1408
+ //
1409
+ // const parent = findItemByKey(newData, rowKey as any, record.parentId)
1410
+ //
1411
+ // // Cập nhật childData mới
1412
+ // const childData: any[] = parent?.children ? [...parent.children] : []
1413
+ //
1414
+ //
1415
+ // // Lấy vị trí bắt đầu
1416
+ // // const { row: startRow, col: startCol } = selectedCell;
1417
+ // const startRow = childData.findIndex((it) => it[rowKey] === record[rowKey])
1418
+ // const startCol = indexCol
1419
+ //
1420
+ // const pastedRows: RecordType[] = []
1421
+ // const pastedColumns = new Set()
1422
+ //
1423
+ //
1424
+ // rows.forEach((rowValues: any, rowIndex: any) => {
1425
+ // const targetRow = startRow + rowIndex
1426
+ //
1427
+ // // Nếu vượt quá số dòng hiện có, thêm dòng mới
1428
+ // if (targetRow >= childData.length) {
1429
+ //
1430
+ // childData.push({ id: undefined, rowId: newGuid(), parentId: parent[rowKey ?? 'id']})
1431
+ // }
1432
+ //
1433
+ // rowValues.forEach((cellValue: any, colIndex: any) => {
1434
+ // const targetCol = startCol + colIndex
1435
+ // if (targetCol >= columns.length) { // Không vượt quá số cột
1436
+ // return
1437
+ // }
1438
+ //
1439
+ // if (columns[targetCol].editEnable) {
1440
+ //
1441
+ // // @ts-ignore
1442
+ // const columnKey = columns[targetCol].field
1443
+ //
1444
+ // // @ts-ignore
1445
+ // childData[targetRow] = { ...childData[targetRow], [columnKey]: cellValue.trim() }
1446
+ // pastedColumns.add(columnKey)
1447
+ // }
1448
+ //
1449
+ // })
1450
+ //
1451
+ // // Lưu dòng được paste
1452
+ // pastedRows.push(childData[targetRow])
1453
+ //
1454
+ // })
1455
+ //
1456
+ // const pastedColumnsArray = Array.from(pastedColumns) ?? []
1457
+ //
1458
+ // const newRowData = {...parent, children: childData}
1459
+ //
1460
+ // const newDataSource = updateArrayByKey(newData, newRowData, rowKey as string)
1461
+ //
1462
+ // triggerPaste?.(pastedRows, pastedColumnsArray as string[], newDataSource )
1463
+ // }
1464
+ };
1200
1465
  const onSubmit = formData => {
1201
1466
  try {
1202
1467
  // const record = (await form.validateFields()) as RecordType;
@@ -1222,7 +1487,10 @@ const GridEdit = props => {
1222
1487
  newState,
1223
1488
  prevState,
1224
1489
  option,
1225
- field
1490
+ field,
1491
+ indexCol,
1492
+ indexRow,
1493
+ key
1226
1494
  } = args;
1227
1495
 
1228
1496
  // const newRecord = getValues()
@@ -1240,26 +1508,26 @@ const GridEdit = props => {
1240
1508
  if (onCellChange.length > 1) {
1241
1509
  onCellChange({
1242
1510
  field,
1243
- indexCol: 1,
1511
+ indexCol,
1244
1512
  type: 'onChange',
1245
1513
  value: newState,
1246
1514
  option,
1247
- indexRow: 1,
1515
+ indexRow,
1248
1516
  rowData: record,
1249
- rowId: '',
1517
+ rowId: key,
1250
1518
  rowsData: [],
1251
1519
  sumValue: []
1252
1520
  }, handleChangeCallback);
1253
1521
  } else {
1254
1522
  onCellChange({
1255
1523
  field,
1256
- indexCol: 1,
1524
+ indexCol,
1257
1525
  type: 'onChange',
1258
1526
  option,
1259
1527
  value: newState,
1260
- indexRow: 1,
1528
+ indexRow,
1261
1529
  rowData: record,
1262
- rowId: '',
1530
+ rowId: key,
1263
1531
  rowsData: [],
1264
1532
  sumValue: []
1265
1533
  }, handleChangeCallback);
@@ -1368,7 +1636,7 @@ const GridEdit = props => {
1368
1636
  });
1369
1637
  }
1370
1638
  };
1371
- const handleFocusCell = (rowIndex, colIndex, col, scrollType, e) => {
1639
+ const handleFocusCell = (rowIndex, colIndex, col, scrollType, e, isTimeout) => {
1372
1640
  const isEdit = editingKey !== '';
1373
1641
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1374
1642
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
@@ -1379,34 +1647,49 @@ const GridEdit = props => {
1379
1647
  });
1380
1648
  setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1381
1649
  };
1382
- if (isEdit) {
1383
- if (cellEdit) {
1384
- updateSelection();
1385
- if (e?.key !== 'Tab') {
1386
- cellEdit.focus();
1650
+ const focusNextCell = (editingCell, cellEditable) => {
1651
+ if (isEdit) {
1652
+ if (editingCell) {
1653
+ updateSelection();
1654
+ if (e?.key !== 'Tab') {
1655
+ editingCell.focus();
1656
+ }
1387
1657
  }
1388
- }
1389
- if (scrollType === 'horizontal' && cellEdit) {
1390
- scrollToCell(rowIndex, colIndex, cellEdit, 'horizontal');
1391
- }
1392
- if (scrollType === 'vertical' && cell) {
1393
- setEditingKey('');
1394
- updateSelection();
1395
- scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
1396
- if (e?.key !== 'Tab') {
1397
- cell.focus();
1658
+ if (scrollType === 'horizontal' && editingCell) {
1659
+ scrollToCell(rowIndex, colIndex, editingCell, 'horizontal');
1398
1660
  }
1399
- }
1400
- } else {
1401
- if (cell) {
1402
- updateSelection();
1403
- if (e?.key !== 'Tab') {
1404
- cell.focus();
1661
+ if (scrollType === 'vertical' && cellEditable) {
1662
+ setEditingKey('');
1663
+ updateSelection();
1664
+ scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
1665
+ if (e?.key !== 'Tab') {
1666
+ cellEditable.focus();
1667
+ }
1668
+ }
1669
+ } else {
1670
+ if (cellEditable) {
1671
+ updateSelection();
1672
+ if (e?.key !== 'Tab') {
1673
+ cellEditable.focus();
1674
+ }
1675
+ }
1676
+ if (cellEditable) {
1677
+ scrollToCell(rowIndex, colIndex, cellEditable, scrollType);
1405
1678
  }
1406
1679
  }
1407
- if (cell) {
1408
- scrollToCell(rowIndex, colIndex, cell, scrollType);
1409
- }
1680
+ };
1681
+ if (isTimeout) {
1682
+ let cellEdit1 = undefined;
1683
+ let cell1 = undefined;
1684
+ setTimeout(() => {
1685
+ cellEdit1 = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1686
+ cell1 = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
1687
+ }, 20);
1688
+ setTimeout(() => {
1689
+ focusNextCell(cellEdit1, cell1);
1690
+ }, 50);
1691
+ } else {
1692
+ focusNextCell(cellEdit, cell);
1410
1693
  }
1411
1694
  };
1412
1695
  const getCellClass = (record, rowIndex, colIndex) => {
@@ -1429,28 +1712,25 @@ const GridEdit = props => {
1429
1712
  const cellPasteSEnd = (0, _hooks.getLastSelectCell)(pasteCells);
1430
1713
  const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row);
1431
1714
  if (!isSelected && !isPasteSelected) {
1432
- const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1715
+ // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1716
+ const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && (0, _hooks.isTopMostInRegion)(rowIndex + 1, colIndex, selectedCells);
1433
1717
  const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1434
1718
  const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1435
1719
  const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1436
1720
  const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1437
- return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` :
1438
- // (isPasteLeftSelected || isPasteRightSelected) ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''}` :
1439
-
1440
- cellClass;
1721
+ return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` : isPasteLeftSelected || isPasteRightSelected ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` : cellClass;
1441
1722
  }
1442
- const isBottom = cellEnd && rowIndex === Math.max(cellStart.row, cellEnd.row);
1443
- const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col);
1723
+ const isBottom = (0, _hooks.isBottomMostInRegion)(rowIndex, colIndex, selectedCells);
1724
+ // const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
1725
+
1726
+ // const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col)
1727
+ const isRight = (0, _hooks.isRightMostInRegion)(rowIndex, colIndex, selectedCells);
1444
1728
  const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col);
1445
1729
  const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col);
1446
1730
  const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1447
-
1448
- // return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isBottom && isRight ? `cell-border-end` : '' }
1449
- // return `${cellClass} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isLeft ? `fixed-cell-border-left` : '' } ${isBottom && isRight ? `cell-border-end` : '' }`
1450
-
1451
1731
  return `${cellClass} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isPasteSelected && isPasteRight ? `cell-paste-border-right` : ''} ${isPasteSelected && isPasteLeft ? `fixed-cell-paste-border-left` : ''} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : ''} ${isLeft ? `fixed-cell-border-left` : ''} ${isBottom && isRight ? `cell-border-end` : ''}`;
1452
1732
  };
1453
- const convertColumns = (0, _columns.flatColumns2)(columns).map((column, colIndex) => {
1733
+ const convertColumns = (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1454
1734
  if (!column?.field && !column?.key) {
1455
1735
  return column;
1456
1736
  }
@@ -1508,79 +1788,97 @@ const GridEdit = props => {
1508
1788
  onCell: (record, rowIndex) => {
1509
1789
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1510
1790
  return {
1511
- // onKeyPress: () => {
1512
- //
1513
- // },
1514
-
1515
1791
  onKeyDown: event => {
1516
1792
  const key = getRowKey(record, dataSource.indexOf(record));
1517
- if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
1518
- if (record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
1519
- // ~~ khi editingKey = ''
1520
- event.preventDefault();
1521
- event.stopPropagation();
1522
- handleEdit(record, column, column.editType, event);
1523
- handleCellClick(rowNumber, record, column);
1524
- const hasKey = mergedExpandedKeys.has(key);
1525
- if (hasKey) {
1526
- // mergedExpandedKeys.delete(key);
1527
- // newExpandedKeys = [...mergedExpandedKeys];
1528
- } else {
1529
- onTriggerExpand(record);
1530
- }
1531
- } else {
1532
- if (event.key === 'Enter') {
1793
+ if (event.key === 'Control' && event.ctrlKey) {
1794
+
1795
+ // setIsCtrlDown(true)
1796
+ } else {
1797
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
1798
+ if (record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
1799
+ // ~~ khi editingKey = ''
1533
1800
  event.preventDefault();
1534
1801
  event.stopPropagation();
1535
- if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
1536
- handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
1802
+ handleEdit(record, column, column.editType, event);
1803
+ handleCellClick(rowNumber, record, column);
1804
+ const hasKey = mergedExpandedKeys.has(key);
1805
+ if (hasKey) {
1806
+ // mergedExpandedKeys.delete(key);
1807
+ // newExpandedKeys = [...mergedExpandedKeys];
1537
1808
  } else {
1538
- // focus cell hiện tại và tắt edit
1539
- handleFocusCell(rowNumber ?? 0, colIndex, column, 'vertical', event);
1540
- setEditingKey('');
1541
-
1542
- // thêm dòng mới
1543
-
1544
- // handleAddSingle()
1545
- //
1546
- // handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event)
1809
+ onTriggerExpand(record);
1810
+ }
1811
+ } else {
1812
+ if (event.key === 'Enter') {
1813
+ event.preventDefault();
1814
+ event.stopPropagation();
1815
+ if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
1816
+ handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
1817
+ } else {
1818
+ // // focus cell hiện tại và tắt edit
1819
+ // handleFocusCell((rowNumber ?? 0), colIndex, column, 'vertical', event)
1820
+ // setEditingKey('')
1821
+
1822
+ // thêm dòng mới
1823
+
1824
+ handleAddSingle();
1825
+ handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event, true);
1826
+ }
1547
1827
  }
1548
1828
  }
1549
1829
  }
1550
- }
1551
- if (event.key === 'Tab') {
1552
- if (colIndex + 1 !== columns.length) {
1553
- handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1554
- } else {
1555
- event.stopPropagation();
1556
- event.preventDefault();
1557
- }
1558
- }
1559
- if (event.key === 'ArrowRight' && colIndex + 1 !== columns.length) {
1560
- if (editingKey !== '') {} else {
1561
- handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1830
+ if (event.key === 'Tab') {
1831
+ if (colIndex + 1 !== columns.length) {
1832
+ handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1833
+ } else {
1834
+ event.stopPropagation();
1835
+ event.preventDefault();
1836
+ }
1562
1837
  }
1563
- }
1564
- if (event.key === 'ArrowLeft' && colIndex > 0) {
1565
- if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
1566
- event.stopPropagation();
1567
- event.preventDefault();
1568
- } else {
1838
+ if (event.key === 'ArrowRight' && colIndex + 1 !== columns.length) {
1569
1839
  if (editingKey !== '') {} else {
1570
- handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
1840
+ handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1571
1841
  }
1572
1842
  }
1573
- }
1574
- if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length) {
1575
- handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
1576
- }
1577
- if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
1578
- handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
1579
- }
1580
- if (event.key === 'Delete') {
1581
- handleDeleteContent();
1843
+ if (event.key === 'ArrowLeft' && colIndex > 0) {
1844
+ if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
1845
+ event.stopPropagation();
1846
+ event.preventDefault();
1847
+ } else {
1848
+ if (editingKey !== '') {} else {
1849
+ handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
1850
+ }
1851
+ }
1852
+ }
1853
+ if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length) {
1854
+ if (isEditing(record) && ((0, _hooks.getEditType)(column, record) === 'treeSelect' || (0, _hooks.getEditType)(column, record) === 'select' || (0, _hooks.getEditType)(column, record) === 'selectTable' || (0, _hooks.getEditType)(column, record) === 'asyncSelect')) {
1855
+ event.stopPropagation();
1856
+ } else {
1857
+ handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
1858
+ }
1859
+ }
1860
+ if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
1861
+ if (isEditing(record) && ((0, _hooks.getEditType)(column, record) === 'asyncSelect' || (0, _hooks.getEditType)(column, record) === 'select' || (0, _hooks.getEditType)(column, record) === 'selectTable' || (0, _hooks.getEditType)(column, record) === 'treeSelect')) {
1862
+ event.stopPropagation();
1863
+ } else {
1864
+ handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
1865
+ }
1866
+ }
1867
+ if (event.key === 'Delete') {
1868
+ handleDeleteContent();
1869
+ }
1870
+ if (event.key === 'Escape') {
1871
+ setEditingKey('');
1872
+ }
1582
1873
  }
1583
1874
  },
1875
+ // onKeyUp: (event: any) => {
1876
+ // if (event.key === 'Control' && event.ctrlKey) {
1877
+ //
1878
+ // console.log('onKeyUp')
1879
+ // }
1880
+ // },
1881
+
1584
1882
  onPaste: event => {
1585
1883
  if (editingKey === '') {
1586
1884
  handlePaste(record, colIndex, rowNumber, event);
@@ -1626,6 +1924,10 @@ const GridEdit = props => {
1626
1924
  title: (0, _columns.getValueCell)(column, record[column.field], format),
1627
1925
  'data-col-index': colIndex,
1628
1926
  'data-row-index': rowNumber,
1927
+ // 'data-tooltip-id': "tooltip-cell-content",
1928
+ // 'data-tooltip-content': 'tooltip-cell-content',
1929
+ // 'data-tooltip-delay-show': 1000,
1930
+ // 'data-tooltip-content': getValueCell(column, record[column.field as any], format),
1629
1931
  editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
1630
1932
  cellEditing,
1631
1933
  t,
@@ -1636,8 +1938,9 @@ const GridEdit = props => {
1636
1938
  } : {}
1637
1939
  };
1638
1940
  },
1639
- onHeaderCell: () => {
1941
+ onHeaderCell: (data, index) => {
1640
1942
  return {
1943
+ ...(column.onHeaderCell ? column.onHeaderCell?.(data, index) : {}),
1641
1944
  onClick: () => {
1642
1945
  handleClickColHeader(column, colIndex);
1643
1946
  },
@@ -1663,12 +1966,18 @@ const GridEdit = props => {
1663
1966
  return /*#__PURE__*/_react.default.createElement("div", {
1664
1967
  className: (0, _classnames.default)('ui-rc_cell-content', {
1665
1968
  // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
1969
+ // selected: selectedCells.has(`${rowNumber}-${colIndex}`) || currentCtrlCells.has(`${rowNumber}-${colIndex}`) || mergedSets([selectedCells, ...ctrlCells]).has(`${rowNumber}-${colIndex}`),
1666
1970
  selected: selectedCells.has(`${rowNumber}-${colIndex}`),
1667
1971
  disable: !(0, _hooks.isEditable)(column, record)
1668
1972
  }),
1669
1973
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
1670
- onMouseEnter: () => handleMouseEnter(rowNumber, colIndex),
1974
+ onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
1671
1975
  onMouseUp: handleMouseUp
1976
+ // onClick={(event) => {
1977
+ //
1978
+ // handleClickCell(event)
1979
+ //
1980
+ // }}
1672
1981
  }, /*#__PURE__*/_react.default.createElement("div", {
1673
1982
  className: 'ui-rc_content'
1674
1983
  }, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && (0, _hooks.isEditable)(column, record) && !isSelectDragging && rowIndex !== dataSource.length - 1 &&
@@ -1679,7 +1988,9 @@ const GridEdit = props => {
1679
1988
  // onMouseEnter={(event) => handlePointEnter(event)}
1680
1989
  // onMouseLeave={() => handlePointLeave()}
1681
1990
  ,
1682
- onMouseDown: () => {
1991
+ onMouseDown: e => {
1992
+ // e.stopPropagation()
1993
+ // e.preventDefault()
1683
1994
  setIsPasteDragging(true);
1684
1995
  },
1685
1996
  onDoubleClick: handlePointDoubleClick
@@ -1701,6 +2012,11 @@ const GridEdit = props => {
1701
2012
  ...find
1702
2013
  };
1703
2014
  }
2015
+ if (!find) {
2016
+ return {
2017
+ ...column
2018
+ };
2019
+ }
1704
2020
 
1705
2021
  // Xử lý đệ quy cho children
1706
2022
  if (column.children?.length) {
@@ -1733,18 +2049,60 @@ const GridEdit = props => {
1733
2049
  setMergedSelectedKeys(keys);
1734
2050
  };
1735
2051
  const contextMenuClick = args => {
1736
- if (args.item.key === 'INSERT_BEFORE') {
1737
- handleInsertAfter(args.item, 1);
2052
+ if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
2053
+ if (args.item.key === 'INSERT_BEFORE_ADV') {
2054
+ // mở Modal
2055
+
2056
+ setOpenModalAddRow(prev => ({
2057
+ ...prev,
2058
+ open: true,
2059
+ type: 'INSERT_BEFORE'
2060
+ }));
2061
+ } else {
2062
+ handleInsertBefore(args.item, args.item.row);
2063
+ }
2064
+ return;
1738
2065
  }
1739
- if (args.item.key === 'INSERT_AFTER') {
1740
- handleInsertBefore(args.item, 1);
2066
+ if (args.item?.parentKey && args.item.parentKey === 'INSERT_AFTER') {
2067
+ if (args.item.key === 'INSERT_AFTER_ADV') {
2068
+ setOpenModalAddRow(prev => ({
2069
+ ...prev,
2070
+ open: true,
2071
+ type: 'INSERT_AFTER'
2072
+ }));
2073
+ } else {
2074
+ handleInsertAfter(args.item, args.item.row);
2075
+ }
2076
+ return;
1741
2077
  }
1742
2078
  if (args.item.key === 'DELETE_ROWS') {
1743
2079
  handleDeleteRows(args.item);
2080
+ return;
1744
2081
  }
1745
2082
  if (args.item.key === 'DELETE_CONTENT') {
1746
2083
  handleDeleteContent();
2084
+ return;
2085
+ }
2086
+ };
2087
+ const hideModalAddRow = () => {
2088
+ setOpenModalAddRow(prev => ({
2089
+ ...prev,
2090
+ open: false,
2091
+ type: ''
2092
+ }));
2093
+ setRowsAdd(1);
2094
+ };
2095
+ const onOkAddRow = () => {
2096
+ if (openModalAddRow.type === 'INSERT_AFTER') {
2097
+ handleInsertAfter({}, rowsAdd);
2098
+ }
2099
+ if (openModalAddRow.type === 'INSERT_BEFORE') {
2100
+ handleInsertBefore({}, rowsAdd);
1747
2101
  }
2102
+ hideModalAddRow();
2103
+ };
2104
+ const onChangeRows = val => {
2105
+ setRowsAdd(val);
1748
2106
  };
1749
2107
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
1750
2108
  heightTable: height,
@@ -1870,6 +2228,28 @@ const GridEdit = props => {
1870
2228
  toastOptions: {
1871
2229
  className: 'react-hot-toast'
1872
2230
  }
1873
- }));
2231
+ }), /*#__PURE__*/_react.default.createElement(_antd.Modal
2232
+ // title="Thêm dòng"
2233
+ , {
2234
+ open: openModalAddRow.open,
2235
+ onOk: onOkAddRow,
2236
+ onCancel: hideModalAddRow,
2237
+ okText: "Ok",
2238
+ cancelText: "H\u1EE7y",
2239
+ className: 'be-popup-container',
2240
+ centered: true,
2241
+ width: 250,
2242
+ closable: false
2243
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.InputNumber, {
2244
+ style: {
2245
+ width: '100%'
2246
+ },
2247
+ defaultValue: 1,
2248
+ value: rowsAdd,
2249
+ min: 1,
2250
+ max: 1000,
2251
+ onChange: onChangeRows,
2252
+ changeOnWheel: true
2253
+ })));
1874
2254
  };
1875
2255
  var _default = exports.default = GridEdit;