es-grid-template 1.3.7 → 1.3.8

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.
@@ -24,16 +24,9 @@ var _hooks = require("../hooks");
24
24
  var _Message = _interopRequireDefault(require("../../Message/Message"));
25
25
  var _rcMasterUi = require("rc-master-ui");
26
26
  var _becoxyIcons = require("becoxy-icons");
27
+ var _faker = require("@faker-js/faker");
27
28
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
28
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; }
29
- // import Command from "../Command";
30
-
31
- // import useMergedState from "rc-util/lib/hooks/useMergedState";
32
-
33
- // import type {ContextMenuItem} from "../type";
34
- // import {ContextInfo, ContextMenuItem} from "../type";
35
- // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
36
-
37
30
  const {
38
31
  Paragraph,
39
32
  Title
@@ -118,8 +111,7 @@ const defaultContext = [{
118
111
  }];
119
112
  const GridEdit = props => {
120
113
  const {
121
- // id = newGuid(),
122
- id,
114
+ id: tableId,
123
115
  tableRef,
124
116
  t,
125
117
  columns,
@@ -147,17 +139,6 @@ const GridEdit = props => {
147
139
  showDefaultContext,
148
140
  ...rest
149
141
  } = props;
150
-
151
- // const {
152
- // mode,
153
- // type,
154
- // checkboxOnly,
155
- // hideSelectAll,
156
- // columnWidth,
157
- // selectedRowKeys,
158
- // defaultSelectedRowKeys
159
- // } = selectionSettings || {}
160
-
161
142
  const ref = (0, _react.useRef)(null);
162
143
  const isSelecting = (0, _react.useRef)(false);
163
144
  const startCell = (0, _react.useRef)(null);
@@ -176,10 +157,10 @@ const GridEdit = props => {
176
157
  // quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
177
158
  // const isPasteDragging = useRef(false);
178
159
 
179
- // const isPointEnter = useRef(false);
180
-
181
- // const [getRecordByKey] = useLazyKVMap(dataSource, childrenColumnName, getRowKey);
182
-
160
+ const id = _react.default.useMemo(() => {
161
+ return tableId ?? _faker.faker.string.alpha(20);
162
+ // return tableId ?? newGuid()
163
+ }, [tableId]);
183
164
  const itemsAdd = [{
184
165
  key: '10',
185
166
  label: '10 rows'
@@ -193,8 +174,8 @@ const GridEdit = props => {
193
174
  const [form] = _antd.Form.useForm();
194
175
  const [editingKey, setEditingKey] = (0, _react.useState)('');
195
176
  const [isFilter, setIsFilter] = _react.default.useState(false);
177
+ const [rangeCells, setRangeCells] = (0, _react.useState)(new Set());
196
178
 
197
- // const [selectedCells, setSelectedCells] = useState(new Set())
198
179
  // const [pasteCells, setPasteCells] = useState(new Set())
199
180
 
200
181
  // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
@@ -229,17 +210,9 @@ const GridEdit = props => {
229
210
  // return [];
230
211
  });
231
212
  const mergedExpandedKeys = _react.default.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
232
-
233
- // const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState<any[]>(
234
- // [],
235
- // {
236
- // value: [],
237
- // },
238
- // );
239
-
240
213
  const rowsFocus = _react.default.useMemo(() => {
241
- return [...new Set(Array.from(selectedCells.current).map(item => parseInt(item.split('-')[0])))] ?? [];
242
- }, [selectedCells]);
214
+ return [...new Set(Array.from(rangeCells).map(item => parseInt(item.split('-')[0])))] ?? [];
215
+ }, [rangeCells]);
243
216
  const contextMenuItems = _react.default.useMemo(() => {
244
217
  const a = showDefaultContext !== false ? [...defaultContext] : [];
245
218
  const b = propsContext ? [...propsContext, {
@@ -319,6 +292,15 @@ const GridEdit = props => {
319
292
 
320
293
  // thêm n dòng bên trên
321
294
  const handleInsertBefore = (item, n) => {
295
+ //
296
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
297
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
298
+ //
299
+
300
+ setTimeout(() => {
301
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
302
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
303
+ }, 10);
322
304
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
323
305
  // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
324
306
 
@@ -393,9 +375,6 @@ const GridEdit = props => {
393
375
  //thêm 1 dòng bên dưới
394
376
  const handleInsertAfter = (item, n) => {
395
377
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
396
-
397
- // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
398
-
399
378
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
400
379
 
401
380
  // const record = getRecordByKey()
@@ -428,8 +407,6 @@ const GridEdit = props => {
428
407
  rowId: (0, _hooks.newGuid)()
429
408
  });
430
409
  const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
431
-
432
- // newData.splice(index + 1, 0, { ...defaultRowValue, rowId, parentId: null })
433
410
  newData.splice(index + 1, 0, ...newRows);
434
411
  triggerChangeData?.(newData, 'INSERT_AFTER');
435
412
  } else {
@@ -511,6 +488,10 @@ const GridEdit = props => {
511
488
  }
512
489
  };
513
490
  const handleDeleteRows = item => {
491
+ setTimeout(() => {
492
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
493
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
494
+ });
514
495
  if (item.onClick) {
515
496
  item.onClick({
516
497
  toolbar: item
@@ -766,10 +747,8 @@ const GridEdit = props => {
766
747
  trigger,
767
748
  getValues,
768
749
  reset
769
- // formState: { errors }
770
750
  } = (0, _reactHookForm.useForm)({
771
751
  mode: 'onChange'
772
- // defaultValues,
773
752
  // resolver: yupResolver(formSchema)
774
753
  });
775
754
  const isEditing = record => record[rowKey] === editingKey;
@@ -805,25 +784,13 @@ const GridEdit = props => {
805
784
  // setSelectedCells(new Set())
806
785
  // setRowsSelected(new Set())
807
786
 
808
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
787
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
788
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
809
789
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
810
790
  rowsSelected.current = new Set();
811
791
  selectedCells.current = new Set();
792
+ setRangeCells(new Set());
812
793
  }
813
-
814
- // if (tableBodies.length > 0) {
815
- // const tableBody = tableBodies[0]; // Chọn tbody đầu tiên (nếu có nhiều)
816
- //
817
- // if (!tableBody.contains(event.target as Node)) {
818
- // setEditingKey('')
819
- // isSelecting.current = false;
820
- // startCell.current = null;
821
- // setSelectedCells(new Set())
822
- // setRowsSelected(new Set())
823
- // } else {
824
- //
825
- // }
826
- // }
827
794
  };
828
795
  document.addEventListener("click", handleClickOutside);
829
796
  return () => {
@@ -871,16 +838,28 @@ const GridEdit = props => {
871
838
 
872
839
  const cells = new Set([`${row}-${col}`]);
873
840
  if (selectedCells.current && selectedCells.current.size > 0) {
874
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
875
- if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
841
+ if (!(0, _hooks.isEqualSet)(cells, rangeCells)) {
842
+ (0, _hooks.onRemoveBgSelectedCell)(rangeCells, id);
843
+ (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
876
844
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
877
845
  }
878
846
  }
879
- selectedCells.current = cells;
880
- (0, _hooks.onAddClassBgSelectedCell)(cells, id);
881
847
  if (rowsSelected.current && rowsSelected.current.size > 0) {
882
848
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
883
849
  }
850
+ if (!(0, _hooks.isEqualSet)(cells, selectedCells.current)) {
851
+ selectedCells.current = cells;
852
+ if (editingKey) {
853
+ setTimeout(() => {
854
+ (0, _hooks.onAddBgSelectedCell)(cells, id);
855
+ (0, _hooks.onAddBorderSelectedCell)(cells, id);
856
+ }, 100);
857
+ } else {
858
+ (0, _hooks.onAddBgSelectedCell)(cells, id);
859
+ (0, _hooks.onAddBorderSelectedCell)(cells, id);
860
+ }
861
+ }
862
+
884
863
  // setRowsSelected(new Set())
885
864
  rowsSelected.current = new Set();
886
865
  }
@@ -892,7 +871,6 @@ const GridEdit = props => {
892
871
  const rowPasteLast = (0, _hooks.getLastSelectCell)(pasteCells.current).row;
893
872
  const selectedArray = Array.from(selectedCells.current).map(key => {
894
873
  const [row, col] = key.split("-").map(Number);
895
- // @ts-ignore
896
874
  const columnKey = columns[col].field;
897
875
 
898
876
  // @ts-ignore
@@ -1012,13 +990,15 @@ const GridEdit = props => {
1012
990
 
1013
991
  /// cập nhật cell class
1014
992
  if (selectedCells.current && selectedCells.current.size > 0) {
1015
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
993
+ (0, _hooks.onRemoveBgSelectedCell)(rangeCells, id);
994
+ (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
1016
995
  }
1017
996
 
1018
997
  // selectedCells.current = sortedSetASC(mergedSet)
1019
998
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1020
999
  selectedCells.current = (0, _hooks.sortedSetASC)(mergedSet);
1021
- (0, _hooks.onAddClassBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1000
+ (0, _hooks.onAddBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1001
+ (0, _hooks.onAddBorderSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1022
1002
  (0, _hooks.showDraggingPoint)((0, _hooks.sortedSetASC)(mergedSet), id);
1023
1003
 
1024
1004
  // setPasteCells(new Set())
@@ -1088,6 +1068,9 @@ const GridEdit = props => {
1088
1068
  if (pasteCells && pasteCells.current.size > 0) {
1089
1069
  triggerDragPaste(pasteCells.current);
1090
1070
  } else {
1071
+ setRangeCells(selectedCells.current);
1072
+ (0, _hooks.onRemoveBorderSelectedCell)(rangeCells, id);
1073
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1091
1074
  const target = e.target;
1092
1075
  if (target.closest('.dragging-point')) {
1093
1076
  e.stopPropagation();
@@ -1147,10 +1130,10 @@ const GridEdit = props => {
1147
1130
  // setSelectedCells(newSelectedCells)
1148
1131
 
1149
1132
  if (selectedCells.current && selectedCells.current.size > 0) {
1150
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1133
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1151
1134
  }
1152
1135
  selectedCells.current = newSelectedCells;
1153
- (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1136
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1154
1137
  } else {
1155
1138
  // chọn vùng paste
1156
1139
 
@@ -1230,12 +1213,12 @@ const GridEdit = props => {
1230
1213
  // // setSelectedCells(newSelectedCells)
1231
1214
  //
1232
1215
  // if (selectedCells.current && selectedCells.current.size > 0) {
1233
- // onRemoveClassSelectedCell(selectedCells.current, id)
1216
+ // onRemoveBgSelectedCell(selectedCells.current, id)
1234
1217
  // }
1235
1218
  //
1236
1219
  // selectedCells.current = newSelectedCells
1237
1220
  //
1238
- // onAddClassBgSelectedCell(newSelectedCells, id)
1221
+ // onAddBgSelectedCell(newSelectedCells, id)
1239
1222
  //
1240
1223
  //
1241
1224
  // };
@@ -1251,13 +1234,15 @@ const GridEdit = props => {
1251
1234
  // setSelectedCells(new Set(newSelectedCells));
1252
1235
 
1253
1236
  if (selectedCells.current && selectedCells.current.size > 0) {
1254
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1237
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1238
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1255
1239
  }
1256
1240
  if (rowsSelected.current && rowsSelected.current.size > 0) {
1257
1241
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1258
1242
  }
1259
1243
  selectedCells.current = newSelectedCells;
1260
- (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1244
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1245
+ (0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
1261
1246
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1262
1247
  (0, _hooks.showDraggingPoint)(newSelectedCells, id);
1263
1248
  };
@@ -1283,7 +1268,8 @@ const GridEdit = props => {
1283
1268
  // setRowsSelected(new Set([`${row}-${col}`]));
1284
1269
 
1285
1270
  if (selectedCells.current && selectedCells.current.size > 0) {
1286
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1271
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1272
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1287
1273
  }
1288
1274
  if (rowsSelected.current && rowsSelected.current.size > 0) {
1289
1275
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
@@ -1291,7 +1277,8 @@ const GridEdit = props => {
1291
1277
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1292
1278
  selectedCells.current = newSelectedCells;
1293
1279
  rowsSelected.current = new Set([`${row}-${col}`]);
1294
- (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1280
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1281
+ (0, _hooks.onAddBorderSelectedCell)(newSelectedCells, id);
1295
1282
  (0, _hooks.addClassCellIndexSelected)(new Set([`${row}-${col}`]), id);
1296
1283
  };
1297
1284
  const handleMouseEnterRowHeader = (row, col, e) => {
@@ -1319,11 +1306,11 @@ const GridEdit = props => {
1319
1306
  }
1320
1307
  }
1321
1308
  if (selectedCells.current && selectedCells.current.size > 0) {
1322
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1309
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1323
1310
  }
1324
1311
  // setSelectedCells(newSelectedCells)
1325
1312
  selectedCells.current = newSelectedCells;
1326
- (0, _hooks.onAddClassBgSelectedCell)(newSelectedCells, id);
1313
+ (0, _hooks.onAddBgSelectedCell)(newSelectedCells, id);
1327
1314
  if (rowsSelected.current && rowsSelected.current.size > 0) {
1328
1315
  (0, _hooks.removeClassCellIndexSelected)(rowsSelected.current, id);
1329
1316
  }
@@ -1701,9 +1688,6 @@ const GridEdit = props => {
1701
1688
  indexRow,
1702
1689
  key
1703
1690
  } = args;
1704
-
1705
- // const newRecord = getValues()
1706
-
1707
1691
  if (changeType === 'enter') {}
1708
1692
  if (changeType === 'blur') {
1709
1693
  const handleChangeCallback = callbackData => {
@@ -1772,7 +1756,6 @@ const GridEdit = props => {
1772
1756
  }
1773
1757
  if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
1774
1758
  setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
1775
- // setValue(col.dataIndex, e.key)
1776
1759
  }
1777
1760
  if (editType === 'select') {
1778
1761
  // setSearchValue(e.key)
@@ -1780,10 +1763,7 @@ const GridEdit = props => {
1780
1763
  }
1781
1764
  if (startSelectedCells.current && startSelectedCells.current.row !== undefined && startSelectedCells.current.col !== undefined) {
1782
1765
  setTimeout(() => {
1783
- // const input = document.querySelector(`.ui-rc-table-row[data-row-key="${selectedCell.row}"] .cell-editing[data-col-index="${selectedCell.col}"] input`) as HTMLInputElement;
1784
1766
  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`);
1785
- // const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
1786
-
1787
1767
  const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells.current.col}"] .ant-select-selection-search input`);
1788
1768
  if (input) {
1789
1769
  input.focus();
@@ -1844,15 +1824,16 @@ const GridEdit = props => {
1844
1824
  // setSelectedCells(new Set([`${rowIndex}-${colIndex}`]));
1845
1825
 
1846
1826
  const cells = new Set([`${rowIndex}-${colIndex}`]);
1847
- console.log('cells', cells);
1848
1827
  if (selectedCells.current && selectedCells.current.size > 0) {
1849
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1828
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1829
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1850
1830
  }
1851
1831
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1852
1832
  selectedCells.current = cells;
1853
1833
  setTimeout(() => {
1854
- (0, _hooks.onAddClassBgSelectedCell)(selectedCells.current, id);
1855
- }, 10);
1834
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
1835
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
1836
+ }, 50);
1856
1837
  (0, _hooks.showDraggingPoint)(cells, id);
1857
1838
  };
1858
1839
  const focusNextCell = (editingCell, cellEditable) => {
@@ -1900,76 +1881,6 @@ const GridEdit = props => {
1900
1881
  focusNextCell(cellEdit, cell);
1901
1882
  }
1902
1883
  };
1903
-
1904
- // const getCellClass = (record: RecordType, rowIndex: number, colIndex: number) => {
1905
- //
1906
- //
1907
- // const cellKey = `${rowIndex}-${colIndex}`;
1908
- // const topCellKey = `${rowIndex + 1}-${colIndex}`;
1909
- // const leftCellKey = `${rowIndex}-${colIndex + 1}`;
1910
- // const rightCellKey = `${rowIndex}-${colIndex - 1}`;
1911
- //
1912
- // const isSelected = selectedCells.has(cellKey);
1913
- // const isTopSelected = selectedCells.has(topCellKey);
1914
- // const isLeftSelected = selectedCells.has(leftCellKey);
1915
- // const isRightSelected = selectedCells.has(rightCellKey);
1916
- //
1917
- //
1918
- // const isPasteSelected = pasteCells.has(cellKey);
1919
- // const isPasteLeftSelected = pasteCells.has(leftCellKey);
1920
- // const isPasteRightSelected = pasteCells.has(rightCellKey);
1921
- //
1922
- // const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable'
1923
- //
1924
- // const prevRecordEditing = flattenData(childrenColumnName, dataSource)[rowIndex + 1]
1925
- //
1926
- // const cellStart = getFirstSelectCell(selectedCells)
1927
- // const cellEnd = getLastSelectCell(selectedCells)
1928
- //
1929
- // const cellPasteStart = getFirstSelectCell(pasteCells)
1930
- // const cellPasteSEnd = getLastSelectCell(pasteCells)
1931
- //
1932
- //
1933
- // const isPasteBottom = pasteCells.size && cellPasteSEnd && rowIndex === Math.max(cellPasteStart.row, cellPasteSEnd.row)
1934
- //
1935
- //
1936
- // if (!isSelected && !isPasteSelected){
1937
- //
1938
- // // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
1939
- // const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && isTopMostInRegion(rowIndex + 1, colIndex, selectedCells)
1940
- //
1941
- // const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
1942
- // const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
1943
- //
1944
- // const isPasteLeft = colIndex + 1 === Math.min(cellPasteStart.col, cellPasteSEnd?.col);
1945
- // const isPasteRight = colIndex - 1 === Math.max(cellPasteStart.col, cellPasteSEnd?.col);
1946
- //
1947
- //
1948
- // return (isTopSelected || isLeftSelected || isRightSelected ) ?
1949
- // `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isRight ? `next-cell-border-left` : ''}` :
1950
- //
1951
- // (isPasteLeftSelected || isPasteRightSelected) ? `${cellClass} ${isPasteLeft ? `cell-paste-border-left` : ''} ${isPasteRight ? `next-cell-paste-border-left` : ''}` :
1952
- //
1953
- // cellClass
1954
- //
1955
- // }
1956
- //
1957
- // const isBottom = isBottomMostInRegion(rowIndex, colIndex, selectedCells)
1958
- // // const isBottom = isBottomMostInRanges(rowIndex, colIndex, [selectedCells, ...ctrlCells])
1959
- //
1960
- // // const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col)
1961
- // const isRight = isRightMostInRegion(rowIndex, colIndex, selectedCells)
1962
- //
1963
- // const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col)
1964
- //
1965
- // const isPasteRight = cellPasteSEnd && colIndex === Math.max(cellPasteStart.col, cellPasteSEnd.col)
1966
- // const isPasteLeft = colIndex === Math.min(cellPasteStart.col, cellPasteSEnd?.col)
1967
- //
1968
- //
1969
- // return `${cellClass} ${isPasteBottom ? `cell-paste-border-bottom` : ''} ${isPasteSelected && isPasteRight ? `cell-paste-border-right` : ''} ${isPasteSelected && isPasteLeft ? `fixed-cell-paste-border-left` : '' } ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isLeft ? `fixed-cell-border-left` : '' } ${isBottom && isRight ? `cell-border-end` : '' }`
1970
- //
1971
- // };
1972
-
1973
1884
  const convertColumns = (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1974
1885
  if (!column?.field && !column?.key) {
1975
1886
  return column;
@@ -2005,17 +1916,9 @@ const GridEdit = props => {
2005
1916
  render: (value, record) => {
2006
1917
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
2007
1918
  return /*#__PURE__*/_react.default.createElement("div", {
2008
- className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {
2009
-
2010
- // selected: rowsSelected.has(`${rowNumber}-${colIndex}`) ,
2011
-
2012
- // focus: selectedCells && Array.from(selectedCells).some((item: any) => item.startsWith(`${rowNumber}-`))
2013
- }),
1919
+ className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {}),
2014
1920
  onMouseDown: event => handleMouseDownRowHeader(rowNumber, colIndex, column, event),
2015
- onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event)
2016
-
2017
- // onClick={() => handleClickRowHeader(rowNumber, colIndex)}
2018
- ,
1921
+ onMouseEnter: event => handleMouseEnterRowHeader(rowNumber, colIndex, event),
2019
1922
  onMouseUp: handleMouseUp
2020
1923
  }, /*#__PURE__*/_react.default.createElement("div", {
2021
1924
  className: 'ui-rc_content'
@@ -2035,17 +1938,16 @@ const GridEdit = props => {
2035
1938
  return {
2036
1939
  onKeyDown: event => {
2037
1940
  const key = getRowKey(record, dataSource.indexOf(record));
2038
- if (event.key === 'Control' && event.ctrlKey) {
2039
-
2040
- // setIsCtrlDown(true)
2041
- } else {
1941
+ if (event.key === 'Control' && event.ctrlKey) {} else {
2042
1942
  if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
2043
1943
  if (record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
2044
1944
  // ~~ khi editingKey = ''
2045
1945
  event.preventDefault();
2046
1946
  event.stopPropagation();
2047
1947
  handleEdit(record, column, column.editType, event);
2048
- (0, _hooks.onRemoveClassSelectedCell)(selectedCells.current, id);
1948
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
1949
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
1950
+ selectedCells.current = new Set();
2049
1951
  handleCellClick(rowNumber, record, column);
2050
1952
  const hasKey = mergedExpandedKeys.has(key);
2051
1953
  if (hasKey) {
@@ -2133,6 +2035,8 @@ const GridEdit = props => {
2133
2035
  onDoubleClick: event => {
2134
2036
  if (!isEditing(record) && record[rowKey] !== editingKey && (0, _hooks.isEditable)(column, record)) {
2135
2037
  handleEdit(record, column, (0, _hooks.getEditType)(column, record), event);
2038
+ (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
2039
+ (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
2136
2040
  handleCellClick(rowNumber, record, column);
2137
2041
  }
2138
2042
  },
@@ -2158,7 +2062,6 @@ const GridEdit = props => {
2158
2062
  }
2159
2063
  },
2160
2064
  className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
2161
- // className: getCellClass(record, rowNumber, colIndex),
2162
2065
  record,
2163
2066
  column: column,
2164
2067
  editType: (0, _hooks.getEditType)(column, record),
@@ -2175,13 +2078,10 @@ const GridEdit = props => {
2175
2078
  editing: isEditing(record) && rowEditable?.(record) !== false && (0, _hooks.isEditable)(column, record),
2176
2079
  cellEditing,
2177
2080
  t,
2178
- // editing: isEditing(record) && rowEditable?.(record) !== false,
2179
2081
  tabIndex: (rowIndex ?? 0) * columns.length + colIndex,
2180
2082
  style: isPasteDragging ? {
2181
2083
  cursor: "crosshair"
2182
2084
  } : {}
2183
-
2184
- // style: getStyle()
2185
2085
  };
2186
2086
  },
2187
2087
  onHeaderCell: (data, index) => {
@@ -2211,9 +2111,6 @@ const GridEdit = props => {
2211
2111
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
2212
2112
  return /*#__PURE__*/_react.default.createElement("div", {
2213
2113
  className: (0, _classnames.default)('ui-rc_cell-content', {
2214
- // selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
2215
- // selected: selectedCells.has(`${rowNumber}-${colIndex}`) || currentCtrlCells.has(`${rowNumber}-${colIndex}`) || mergedSets([selectedCells, ...ctrlCells]).has(`${rowNumber}-${colIndex}`),
2216
- // selected: selectedCells.has(`${rowNumber}-${colIndex}`),
2217
2114
  // disable: !isEditable(column as any, record)
2218
2115
  }),
2219
2116
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
@@ -2233,7 +2130,7 @@ const GridEdit = props => {
2233
2130
  // }}
2234
2131
  }, /*#__PURE__*/_react.default.createElement("div", {
2235
2132
  className: 'ui-rc_content'
2236
- }, (0, _columns.renderContent)(column, value, record, rowIndex, format)),
2133
+ }, (0, _columns.renderContent)(column, value, record, rowIndex, column.format ? typeof column.format === 'function' ? column.format(record) : column.format : format)),
2237
2134
  // selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
2238
2135
  // getLastSelectCell(selectedCells.current).col === colIndex &&
2239
2136
  // isEditable(column as any, record) &&
@@ -2245,8 +2142,6 @@ const GridEdit = props => {
2245
2142
  e.preventDefault();
2246
2143
  if (e.button === 0) {
2247
2144
  setIsPasteDragging(true);
2248
-
2249
- // isPasteDragging.current = true
2250
2145
  }
2251
2146
  },
2252
2147
  onDoubleClick: handlePointDoubleClick
@@ -2301,13 +2196,6 @@ const GridEdit = props => {
2301
2196
  }
2302
2197
  }));
2303
2198
  };
2304
- //
2305
- // const onSelectChange = (keys: any[]) => {
2306
- //
2307
- // console.log(keys)
2308
- // setMergedSelectedKeys(keys)
2309
- // }
2310
-
2311
2199
  const contextMenuClick = args => {
2312
2200
  if (args.item?.parentKey && args.item.parentKey === 'INSERT_BEFORE') {
2313
2201
  if (args.item.key === 'INSERT_BEFORE_ADV') {
@@ -2370,7 +2258,6 @@ const GridEdit = props => {
2370
2258
  position: 'relative'
2371
2259
  },
2372
2260
  ref: ref
2373
- // onMouseUp={handleMouseUp}
2374
2261
  }, /*#__PURE__*/_react.default.createElement(_useContext.TableContext.Provider, {
2375
2262
  value: {
2376
2263
  rowKey,
@@ -2410,9 +2297,7 @@ const GridEdit = props => {
2410
2297
  components: {
2411
2298
  ...components,
2412
2299
  body: {
2413
- // wrapper: () => <div></div>,
2414
2300
  cell: _EditableCell.default
2415
- // cell: () => <EditableCell />,
2416
2301
  }
2417
2302
  },
2418
2303
  className: (0, _classnames.default)(className, 'grid-editable'),
@@ -2473,27 +2358,15 @@ const GridEdit = props => {
2473
2358
  }
2474
2359
  },
2475
2360
  triggerChangeColumns: triggerChangeColumns,
2476
- clickHeaderToSort: false
2477
-
2478
- // rowSelection={ columns && columns.length === 0 ? undefined : {
2479
- // type: mode,
2480
- // columnWidth: columnWidth ?? 50 ,
2481
- // onChange: onSelectChange,
2482
- //
2483
- // selectedRowKeys: mergedSelectedKeys,
2484
- // preserveSelectedRowKeys: true,
2485
- // arrowKey: false
2486
- //
2487
- // }}
2488
- ,
2489
-
2361
+ clickHeaderToSort: false,
2490
2362
  isFilter: isFilter,
2491
2363
  setIsFilter: setIsFilter,
2492
2364
  contextMenuItems: contextMenuItems,
2493
2365
  contextMenuClick: contextMenuClick,
2494
2366
  onScroll: () => {
2495
2367
  if (selectedCells.current && selectedCells.current.size > 0) {
2496
- (0, _hooks.onAddClassBgSelectedCell)(selectedCells.current, id);
2368
+ (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
2369
+ (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
2497
2370
  (0, _hooks.showDraggingPoint)(selectedCells.current, id);
2498
2371
  }
2499
2372
  if (rowsSelected && rowsSelected.current.size > 0) {
@@ -2505,9 +2378,8 @@ const GridEdit = props => {
2505
2378
  toastOptions: {
2506
2379
  className: 'react-hot-toast'
2507
2380
  }
2508
- }), /*#__PURE__*/_react.default.createElement(_antd.Modal
2509
- // title="Thêm dòng"
2510
- , {
2381
+ }), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
2382
+ title: "Th\xEAm d\xF2ng",
2511
2383
  open: openModalAddRow.open,
2512
2384
  onOk: onOkAddRow,
2513
2385
  onCancel: hideModalAddRow,
@@ -84,7 +84,7 @@ export type ToolbarClick = {
84
84
  item: any;
85
85
  column: any;
86
86
  };
87
- export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title'> & {
87
+ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title' | 'format' | 'commandItems'> & {
88
88
  field?: string;
89
89
  key?: any;
90
90
  type?: IColumnType;
@@ -93,7 +93,7 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
93
93
  isSummary?: boolean;
94
94
  summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
95
95
  maxWidth?: string | number;
96
- format?: IFormat;
96
+ format?: IFormat | ((rowData: any) => IFormat);
97
97
  allowFiltering?: boolean;
98
98
  allowSorter?: boolean;
99
99
  operator?: FilterOperator;
@@ -207,12 +207,12 @@ export type GridTableProps<RecordType = AnyObject> = TableProps<RecordType>;
207
207
  export interface CommandItem {
208
208
  id: string;
209
209
  type?: string;
210
- visible?: boolean;
210
+ visible?: boolean | ((record: any) => boolean);
211
211
  title: string;
212
212
  color?: 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';
213
213
  tooltip?: string;
214
214
  icon?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
215
- template?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
215
+ template?: ReactNode | ReactElement | ((record: any) => ReactNode | ReactElement);
216
216
  client?: boolean;
217
217
  confirmDialog?: boolean;
218
218
  }