es-grid-template 1.4.1 → 1.4.2

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 (33) hide show
  1. package/es/grid-component/EditableCell.js +46 -15
  2. package/es/grid-component/InternalTable.d.ts +1 -0
  3. package/es/grid-component/InternalTable.js +467 -111
  4. package/es/grid-component/TableGrid.js +2 -7
  5. package/es/grid-component/hooks/columns/index.d.ts +1 -1
  6. package/es/grid-component/hooks/columns/index.js +3 -13
  7. package/es/grid-component/hooks/useColumns.js +2 -0
  8. package/es/grid-component/hooks/utils.d.ts +1 -1
  9. package/es/grid-component/hooks/utils.js +3 -3
  10. package/es/grid-component/styles.scss +1186 -1170
  11. package/es/grid-component/table/Grid.d.ts +1 -0
  12. package/es/grid-component/table/GridEdit.d.ts +1 -0
  13. package/es/grid-component/table/GridEdit.js +156 -121
  14. package/es/grid-component/table/Group.d.ts +1 -0
  15. package/es/grid-component/type.d.ts +7 -2
  16. package/es/grid-component/useContext.d.ts +1 -0
  17. package/lib/grid-component/EditableCell.js +46 -15
  18. package/lib/grid-component/InternalTable.d.ts +1 -0
  19. package/lib/grid-component/InternalTable.js +467 -100
  20. package/lib/grid-component/TableGrid.js +2 -7
  21. package/lib/grid-component/hooks/columns/index.d.ts +1 -1
  22. package/lib/grid-component/hooks/columns/index.js +5 -15
  23. package/lib/grid-component/hooks/useColumns.js +2 -0
  24. package/lib/grid-component/hooks/utils.d.ts +1 -1
  25. package/lib/grid-component/hooks/utils.js +3 -3
  26. package/lib/grid-component/styles.scss +1186 -1170
  27. package/lib/grid-component/table/Grid.d.ts +1 -0
  28. package/lib/grid-component/table/GridEdit.d.ts +1 -0
  29. package/lib/grid-component/table/GridEdit.js +156 -121
  30. package/lib/grid-component/table/Group.d.ts +1 -0
  31. package/lib/grid-component/type.d.ts +7 -2
  32. package/lib/grid-component/useContext.d.ts +1 -0
  33. package/package.json +109 -109
@@ -8,6 +8,7 @@ type Props<T> = GridTableProps<T> & {
8
8
  triggerChangeData?: (newData: T[], type: string) => void;
9
9
  getRowKey: GetRowKey<T>;
10
10
  triggerGroupColumns?: (groupedColumns: string[]) => void;
11
+ setTooltipContent?: any;
11
12
  triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
12
13
  isFilter?: boolean;
13
14
  setIsFilter?: React.Dispatch<React.SetStateAction<boolean>>;
@@ -11,6 +11,7 @@ type Props<RecordType> = TableProps<RecordType> & {
11
11
  triggerPaste?: (pastedRows: RecordType[], pastedColumnsArray: string[], newData: RecordType[]) => void;
12
12
  getRowKey: GetRowKey<RecordType>;
13
13
  triggerGroupColumns?: (groupedColumns: string[]) => void;
14
+ setTooltipContent?: any;
14
15
  };
15
16
  declare const GridEdit: <RecordType extends AnyObject = AnyObject>(props: Props<RecordType>) => React.JSX.Element;
16
17
  export default GridEdit;
@@ -12,6 +12,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
12
12
  var _antd = require("antd");
13
13
  var _reactHookForm = require("react-hook-form");
14
14
  var _reactHotToast = require("react-hot-toast");
15
+ var _yup = require("@hookform/resolvers/yup");
15
16
  var _columns = require("../hooks/columns");
16
17
  var _EditableCell = _interopRequireDefault(require("../EditableCell"));
17
18
  var _GridStyle = require("../GridStyle");
@@ -25,6 +26,7 @@ var _Message = _interopRequireDefault(require("../../Message/Message"));
25
26
  var _rcMasterUi = require("rc-master-ui");
26
27
  var _becoxyIcons = require("becoxy-icons");
27
28
  var _faker = require("@faker-js/faker");
29
+ var _InternalTable = require("../InternalTable");
28
30
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
29
31
  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
32
  const {
@@ -33,7 +35,6 @@ const {
33
35
  } = _antd.Typography;
34
36
  _dayjs.default.extend(_customParseFormat.default);
35
37
  const toast = 'top-right';
36
- // const defaultContext: ContextMenuItem[] = [
37
38
  const defaultContext = [{
38
39
  key: 'INSERT_BEFORE',
39
40
  label: 'Thêm dòng bên trên',
@@ -96,6 +97,44 @@ const defaultContext = [{
96
97
  key: 'INSERT_AFTER_ADV',
97
98
  label: 'Tùy chỉnh'
98
99
  }]
100
+ }, {
101
+ key: 'INSERT_CHILDREN',
102
+ // label: 'Insert item children',
103
+ label: 'Thêm cấp con',
104
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
105
+ fontSize: 14
106
+ })
107
+ // children: [
108
+ // {
109
+ // parentKey: 'INSERT_AFTER',
110
+ // key: 'INSERT_AFTER_1',
111
+ // label: 'Thêm 1 dòng',
112
+ // row: 1
113
+ // },
114
+ // {
115
+ // parentKey: 'INSERT_AFTER',
116
+ // key: 'INSERT_AFTER_10',
117
+ // label: 'Thêm 10 dòng',
118
+ // row: 10
119
+ // },
120
+ // {
121
+ // parentKey: 'INSERT_AFTER',
122
+ // key: 'INSERT_AFTER_50',
123
+ // label: 'Thêm 50 dòng',
124
+ // row: 50
125
+ // },
126
+ // {
127
+ // parentKey: 'INSERT_AFTER',
128
+ // key: 'INSERT_AFTER_100',
129
+ // label: 'Thêm 100 dòng',
130
+ // row: 100
131
+ // },
132
+ // {
133
+ // parentKey: 'INSERT_AFTER',
134
+ // key: 'INSERT_AFTER_ADV',
135
+ // label: 'Tùy chỉnh'
136
+ // }
137
+ // ]
99
138
  }, {
100
139
  key: 'DELETE_CONTENT',
101
140
  label: 'Xóa nội dung',
@@ -109,6 +148,37 @@ const defaultContext = [{
109
148
  fontSize: 14
110
149
  })
111
150
  }];
151
+ const validateData = async (data, formSchema) => {
152
+ if (!formSchema) {
153
+ return [];
154
+ } else {
155
+ const errors = [];
156
+ for (let i = 0; i < data.length; i++) {
157
+ try {
158
+ await formSchema.validate(data[i], {
159
+ abortEarly: false
160
+ });
161
+ } catch (error) {
162
+ errors.push(error.inner.reduce((acc, err) => {
163
+ acc[err.path] = {
164
+ field: err.path,
165
+ index: i,
166
+ message: err.message,
167
+ type: err.type,
168
+ ref: {
169
+ name: err.path
170
+ }
171
+ };
172
+ return {
173
+ ...acc,
174
+ index: i
175
+ };
176
+ }, {}));
177
+ }
178
+ }
179
+ return errors;
180
+ }
181
+ };
112
182
  const GridEdit = props => {
113
183
  const {
114
184
  id: tableId,
@@ -137,6 +207,8 @@ const GridEdit = props => {
137
207
  rowEditable,
138
208
  contextMenuItems: propsContext,
139
209
  showDefaultContext,
210
+ validate,
211
+ setTooltipContent,
140
212
  ...rest
141
213
  } = props;
142
214
  const ref = (0, _react.useRef)(null);
@@ -176,33 +248,17 @@ const GridEdit = props => {
176
248
  }];
177
249
  const [form] = _antd.Form.useForm();
178
250
  const [editingKey, setEditingKey] = (0, _react.useState)('');
251
+ const [dataErrors, setDataErrors] = (0, _react.useState)([]);
179
252
  const [isFilter, setIsFilter] = _react.default.useState(false);
180
253
  const [rangeCells, setRangeCells] = (0, _react.useState)(new Set());
181
-
182
- // const [pasteCells, setPasteCells] = useState(new Set())
183
-
184
- // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
185
-
186
- // const [isCtrlDown, setIsCtrlDown] = useState(false)
187
-
188
- // const [ctrlCells, setCtrlCells] = useState<any>([])
189
- // const [currentCtrlCells, setCurrentCtrlCells] = useState<any>(new Set())
190
-
191
254
  const [openModalAddRow, setOpenModalAddRow] = (0, _react.useState)({
192
255
  open: false,
193
256
  type: ''
194
257
  });
195
258
  const [rowsAdd, setRowsAdd] = (0, _react.useState)(1);
196
259
  const [cellEditing, setCellEditing] = (0, _react.useState)(null);
197
-
198
- // const [isSelectDragging, setSelectIsDragging] = useState(false)
199
-
200
260
  const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
201
261
 
202
- // const [rowsSelected, setRowsSelected] = useState(new Set())
203
-
204
- // const [startSelectedCells, setStartSelectedCell] = useState<{ row: number; col: number } | null>(null)
205
-
206
262
  const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
207
263
  // if (defaultExpandedRowKeys) {
208
264
  // return defaultExpandedRowKeys;
@@ -213,6 +269,16 @@ const GridEdit = props => {
213
269
  // return [];
214
270
  });
215
271
  const mergedExpandedKeys = _react.default.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
272
+ _react.default.useEffect(() => {
273
+ if (validate && dataSource && dataSource.length) {
274
+ validateData(dataSource, validate).then(error => {
275
+ setDataErrors([...error]);
276
+ // if (getErrors) {
277
+ // getErrors([...error])
278
+ // }
279
+ });
280
+ }
281
+ }, [validate, dataSource]);
216
282
  const rowsFocus = _react.default.useMemo(() => {
217
283
  return [...new Set(Array.from(rangeCells).map(item => parseInt(item.split('-')[0])))] ?? [];
218
284
  }, [rangeCells]);
@@ -234,8 +300,11 @@ const GridEdit = props => {
234
300
  newExpandedKeys = [...mergedExpandedKeys, key];
235
301
  }
236
302
  setInnerExpandedKeys(newExpandedKeys);
237
- }, [getRowKey, mergedExpandedKeys, dataSource]);
238
- const handleAddSingle = item => {
303
+ //
304
+ // onAddBgSelectedCell(rangeCells, id)
305
+ // onAddBorderSelectedCell(rangeCells, id)
306
+ }, [getRowKey, dataSource, mergedExpandedKeys]);
307
+ const handleAddSingle = _react.default.useCallback(item => {
239
308
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
240
309
  const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
241
310
  if (item && item.onClick) {
@@ -253,8 +322,8 @@ const GridEdit = props => {
253
322
  }];
254
323
  triggerChangeData?.(newData, 'Add');
255
324
  }
256
- };
257
- const handleAddMulti = (item, e) => {
325
+ }, [dataSource, defaultValue, triggerChangeData]);
326
+ const handleAddMulti = _react.default.useCallback((item, e) => {
258
327
  if (item.onClick) {
259
328
  item.onClick({
260
329
  toolbar: item
@@ -274,8 +343,8 @@ const GridEdit = props => {
274
343
  const newData = dataSource.concat(newRows);
275
344
  triggerChangeData?.(newData, 'Add');
276
345
  }
277
- };
278
- const handleDuplicate = () => {
346
+ }, [dataSource, defaultValue, triggerChangeData]);
347
+ const handleDuplicate = _react.default.useCallback(() => {
279
348
  // không tính tree
280
349
 
281
350
  // Cập nhật data mới
@@ -291,10 +360,10 @@ const GridEdit = props => {
291
360
  const insertAfter = Math.max(...rowsFocus);
292
361
  const rs = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
293
362
  triggerChangeData?.(rs, 'DUPLICATE');
294
- };
363
+ }, [dataSource, rowsFocus, triggerChangeData]);
295
364
 
296
365
  // thêm n dòng bên trên
297
- const handleInsertBefore = (item, n) => {
366
+ const handleInsertBefore = _react.default.useCallback((item, n) => {
298
367
  //
299
368
  (0, _hooks.onRemoveBgSelectedCell)(selectedCells.current, id);
300
369
  (0, _hooks.onRemoveBorderSelectedCell)(selectedCells.current, id);
@@ -373,10 +442,10 @@ const GridEdit = props => {
373
442
  triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
374
443
  }
375
444
  }
376
- };
445
+ }, [dataSource, defaultValue, id, isFilter, rowKey, rowsFocus, triggerChangeData]);
377
446
 
378
447
  //thêm 1 dòng bên dưới
379
- const handleInsertAfter = (item, n) => {
448
+ const handleInsertAfter = _react.default.useCallback((item, n) => {
380
449
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
381
450
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
382
451
 
@@ -447,8 +516,8 @@ const GridEdit = props => {
447
516
  triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
448
517
  }
449
518
  }
450
- };
451
- const handleInsertChild = item => {
519
+ }, [dataSource, defaultValue, isFilter, rowKey, rowsFocus, triggerChangeData]);
520
+ const handleInsertChild = _react.default.useCallback(item => {
452
521
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
453
522
  const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
454
523
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
@@ -489,8 +558,8 @@ const GridEdit = props => {
489
558
  const newExpandedKeys = [...mergedExpandedKeys, key];
490
559
  setInnerExpandedKeys(newExpandedKeys);
491
560
  }
492
- };
493
- const handleDeleteRows = item => {
561
+ }, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
562
+ const handleDeleteRows = _react.default.useCallback(item => {
494
563
  setTimeout(() => {
495
564
  (0, _hooks.onAddBgSelectedCell)(selectedCells.current, id);
496
565
  (0, _hooks.onAddBorderSelectedCell)(selectedCells.current, id);
@@ -509,11 +578,11 @@ const GridEdit = props => {
509
578
  });
510
579
  triggerChangeData?.([...newData], 'DELETE_ROWS');
511
580
  }
512
- };
513
- const handleDeleteAll = () => {
581
+ }, [dataSource, id, rowsFocus, triggerChangeData]);
582
+ const handleDeleteAll = _react.default.useCallback(() => {
514
583
  triggerChangeData?.([], 'INSERT_BEFORE');
515
- };
516
- const handleDeleteContent = () => {
584
+ }, [triggerChangeData]);
585
+ const handleDeleteContent = _react.default.useCallback(() => {
517
586
  if (selectedCells.current.size > 0) {
518
587
  const newData = [...dataSource];
519
588
 
@@ -533,7 +602,7 @@ const GridEdit = props => {
533
602
  }
534
603
  triggerChangeData?.([...newData], 'DELETE_CONTENT');
535
604
  }
536
- };
605
+ }, [dataSource, triggerChangeData, visibleCols]);
537
606
  const toolbarItemsBottom = (0, _react.useMemo)(() => {
538
607
  if (!rowsFocus || rowsFocus.length === 0) {
539
608
  return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
@@ -698,7 +767,7 @@ const GridEdit = props => {
698
767
  variant: 'outlined',
699
768
  onClick: () => handleInsertChild(item),
700
769
  className: "d-flex toolbar-button"
701
- }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
770
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children')));
702
771
  }
703
772
  };
704
773
  }
@@ -742,19 +811,24 @@ const GridEdit = props => {
742
811
  ...item
743
812
  };
744
813
  });
745
- }, [handleAddMulti, handleAddSingle, itemsAdd, rowsFocus.length, t, toolbarItems]);
814
+ }, [handleAddMulti, handleAddSingle, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
746
815
  const {
747
816
  control,
748
817
  handleSubmit,
749
818
  setValue,
750
819
  trigger,
751
820
  getValues,
752
- reset
821
+ reset,
822
+ formState: {
823
+ errors
824
+ }
753
825
  } = (0, _reactHookForm.useForm)({
754
- mode: 'onChange'
755
- // resolver: yupResolver(formSchema)
826
+ mode: 'onChange',
827
+ resolver: (0, _yup.yupResolver)(validate)
756
828
  });
757
- const isEditing = record => record[rowKey] === editingKey;
829
+ const isEditing = _react.default.useCallback(record => {
830
+ return record[rowKey] === editingKey;
831
+ }, [editingKey, rowKey]);
758
832
  (0, _react.useEffect)(() => {
759
833
  const handleClickOutside = event => {
760
834
  const element = event.target;
@@ -799,8 +873,11 @@ const GridEdit = props => {
799
873
  return () => {
800
874
  document.removeEventListener("click", handleClickOutside);
801
875
  };
802
- }, []);
876
+ }, [id]);
803
877
  const handleMouseDown = (record, row, col, e) => {
878
+ if (editingKey && editingKey === record[rowKey]) {
879
+ return;
880
+ }
804
881
  if (e.button === 2) {
805
882
  e.stopPropagation();
806
883
  return;
@@ -856,7 +933,7 @@ const GridEdit = props => {
856
933
  setTimeout(() => {
857
934
  (0, _hooks.onAddBgSelectedCell)(cells, id);
858
935
  (0, _hooks.onAddBorderSelectedCell)(cells, id);
859
- }, 100);
936
+ }, 200);
860
937
  } else {
861
938
  (0, _hooks.onAddBgSelectedCell)(cells, id);
862
939
  (0, _hooks.onAddBorderSelectedCell)(cells, id);
@@ -1003,9 +1080,12 @@ const GridEdit = props => {
1003
1080
  // selectedCells.current = sortedSetASC(mergedSet)
1004
1081
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1005
1082
  selectedCells.current = (0, _hooks.sortedSetASC)(mergedSet);
1006
- (0, _hooks.onAddBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1007
- (0, _hooks.onAddBorderSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1008
- (0, _hooks.showDraggingPoint)((0, _hooks.sortedSetASC)(mergedSet), id);
1083
+ setRangeCells((0, _hooks.sortedSetASC)(mergedSet));
1084
+ setTimeout(() => {
1085
+ (0, _hooks.onAddBgSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1086
+ (0, _hooks.onAddBorderSelectedCell)((0, _hooks.sortedSetASC)(mergedSet), id);
1087
+ (0, _hooks.showDraggingPoint)((0, _hooks.sortedSetASC)(mergedSet), id);
1088
+ }, 50);
1009
1089
 
1010
1090
  // setPasteCells(new Set())
1011
1091
 
@@ -1029,27 +1109,6 @@ const GridEdit = props => {
1029
1109
  (0, _hooks.hideDraggingPoint)(selectedCells.current, id);
1030
1110
  triggerDragPaste(newPasteCells);
1031
1111
  };
1032
-
1033
- // const handleClickCell = (e: any) => {
1034
- //
1035
- // if (e.ctrlKey) {
1036
- //
1037
- // const cell: any = new Set([`${row}-${col}`])
1038
- //
1039
- // const found = ctrlCells.find((s: any) => isEqualSet(s, cell));
1040
- //
1041
- // if (found) {
1042
- // const rs = ctrlCells.filter((s: any) => !isEqualSet(s, cell));
1043
- //
1044
- // setCtrlCells(rs)
1045
- //
1046
- // } else {
1047
- // setCtrlCells([...ctrlCells, cell])
1048
- // }
1049
- //
1050
- // }
1051
- // }
1052
-
1053
1112
  const handleMouseUp = e => {
1054
1113
  isSelecting.current = false;
1055
1114
  startCell.current = null;
@@ -1089,15 +1148,6 @@ const GridEdit = props => {
1089
1148
  (0, _hooks.showDraggingPoint)(selectedCells.current, id);
1090
1149
  }
1091
1150
  };
1092
-
1093
- // const handlePointEnter = () => {
1094
- // isPointEnter.current = true;
1095
- // }
1096
- //
1097
- // const handlePointLeave = () => {
1098
- // isPointEnter.current = false;
1099
- // }
1100
-
1101
1151
  const handleMouseEnter = (row, col, e) => {
1102
1152
  if (!isSelecting.current || !startCell.current) {
1103
1153
  return;
@@ -1203,32 +1253,6 @@ const GridEdit = props => {
1203
1253
  }
1204
1254
  }
1205
1255
  };
1206
-
1207
- // const handleClickRowHeader = (row: any, col: any) => {
1208
- //
1209
- // const newSelectedCells = new Set()
1210
- //
1211
- // const tCols = editAbleColumns(columns)
1212
- //
1213
- // for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1214
- // for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1215
- // newSelectedCells.add(`${r}-${c}`)
1216
- // }
1217
- // }
1218
- //
1219
- // // setSelectedCells(newSelectedCells)
1220
- //
1221
- // if (selectedCells.current && selectedCells.current.size > 0) {
1222
- // onRemoveBgSelectedCell(selectedCells.current, id)
1223
- // }
1224
- //
1225
- // selectedCells.current = newSelectedCells
1226
- //
1227
- // onAddBgSelectedCell(newSelectedCells, id)
1228
- //
1229
- //
1230
- // };
1231
-
1232
1256
  const handleClickColHeader = (column, indexColumn) => {
1233
1257
  const newSelectedCells = new Set();
1234
1258
  for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
@@ -1739,6 +1763,7 @@ const GridEdit = props => {
1739
1763
  }
1740
1764
  };
1741
1765
  const handleEdit = (record, col, editType, e) => {
1766
+ setTooltipContent('');
1742
1767
  // @ts-ignore
1743
1768
  setEditingKey(record[rowKey]);
1744
1769
  setCellEditing({
@@ -1889,10 +1914,10 @@ const GridEdit = props => {
1889
1914
  }
1890
1915
  };
1891
1916
  const convertColumns = (0, _columns.flatColumns2)(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1892
- if (!column?.field && !column?.key) {
1893
- return column;
1917
+ if (column === _InternalTable.SELECTION_COLUMN) {
1918
+ return _InternalTable.SELECTION_COLUMN;
1894
1919
  }
1895
- if (column.dataIndex === '#' || column.dataIndex === '#') {
1920
+ if (column.field === '#') {
1896
1921
  return {
1897
1922
  ...column,
1898
1923
  className: 'rc-ui-cell-editable rc-ui-cell-index',
@@ -1933,7 +1958,7 @@ const GridEdit = props => {
1933
1958
  }
1934
1959
  };
1935
1960
  }
1936
- if ((column.key || column.field) === 'command') {
1961
+ if (column.field === 'command') {
1937
1962
  return {
1938
1963
  ...column
1939
1964
  };
@@ -1986,10 +2011,8 @@ const GridEdit = props => {
1986
2011
  if (event.key === 'Tab') {
1987
2012
  if (editingKey) {} else {
1988
2013
  if (colIndex + 1 !== visibleCols.length) {
1989
- // console.log('bbbbb')
1990
2014
  handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1991
2015
  } else {
1992
- // console.log('fffff')
1993
2016
  event.stopPropagation();
1994
2017
  event.preventDefault();
1995
2018
  }
@@ -2068,10 +2091,6 @@ const GridEdit = props => {
2068
2091
  rowsSelected.current = new Set();
2069
2092
  }
2070
2093
  },
2071
- // onMouseEnter: () => {
2072
- //
2073
- // },
2074
-
2075
2094
  onClick: () => {
2076
2095
  if (record[rowKey] !== editingKey && editingKey !== '') {
2077
2096
  setEditingKey('');
@@ -2081,7 +2100,7 @@ const GridEdit = props => {
2081
2100
  }
2082
2101
  }
2083
2102
  },
2084
- className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
2103
+ className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!(0, _hooks.isEditable)(column, record) ? 'disable' : ''}`,
2085
2104
  record,
2086
2105
  column: column,
2087
2106
  editType: (0, _hooks.getEditType)(column, record),
@@ -2131,12 +2150,23 @@ const GridEdit = props => {
2131
2150
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
2132
2151
  const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
2133
2152
  const cellFormat = (0, _hooks.getFormat)(colFormat, format);
2153
+ const rowError = dataErrors.find(it => it.index === rowNumber);
2154
+ const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
2155
+
2156
+ // const aaa = dataErrors.find((it) => column?.field && it[column.field].field === column.field && it.index === rowNumber)
2157
+ // const aaa = column.field && rowError && rowError[column.field]?.field === column?.field
2158
+
2134
2159
  return /*#__PURE__*/_react.default.createElement("div", {
2135
2160
  className: (0, _classnames.default)('ui-rc_cell-content', {
2136
2161
  // disable: !isEditable(column as any, record)
2162
+ isValid: column.field && rowError && rowError[column.field]?.field === column?.field
2137
2163
  }),
2138
2164
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2139
- onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
2165
+ onMouseEnter: event => {
2166
+ // setTooltipContent(cellError ? cellError.message : renderContent(column as any, value, record, rowIndex, cellFormat))
2167
+ setTooltipContent(cellError ? cellError.message : '');
2168
+ handleMouseEnter(rowNumber, colIndex, event);
2169
+ },
2140
2170
  onMouseUp: handleMouseUp,
2141
2171
  onMouseMove: () => {
2142
2172
  if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
@@ -2176,9 +2206,9 @@ const GridEdit = props => {
2176
2206
  const transformColumns = _react.default.useCallback(cols => {
2177
2207
  // @ts-ignore
2178
2208
  return cols.map(column => {
2179
- const find = convertColumns.find(it => it.key === column.key);
2180
- if (!column?.field && !column?.key) {
2181
- return column;
2209
+ const find = convertColumns.find(it => it?.field === column.field);
2210
+ if (column === _InternalTable.SELECTION_COLUMN) {
2211
+ return _InternalTable.SELECTION_COLUMN;
2182
2212
  }
2183
2213
  if (find) {
2184
2214
  return {
@@ -2245,6 +2275,10 @@ const GridEdit = props => {
2245
2275
  }
2246
2276
  return;
2247
2277
  }
2278
+ if (args.item.key === 'INSERT_CHILDREN') {
2279
+ handleInsertChild(args.item);
2280
+ return;
2281
+ }
2248
2282
  if (args.item.key === 'DELETE_ROWS') {
2249
2283
  handleDeleteRows(args.item);
2250
2284
  return;
@@ -2287,6 +2321,7 @@ const GridEdit = props => {
2287
2321
  format,
2288
2322
  control,
2289
2323
  trigger,
2324
+ errors,
2290
2325
  getValues,
2291
2326
  handleCellChange,
2292
2327
  getRowKey
@@ -2343,7 +2378,7 @@ const GridEdit = props => {
2343
2378
  },
2344
2379
  rowHoverable: false,
2345
2380
  bottomToolbar: bottomToolbar,
2346
- expandable: {
2381
+ expandable: expandable ? {
2347
2382
  expandIconColumnIndex: (0, _hooks.checkChild)(dataSource) ? 3 : undefined,
2348
2383
  ...expandable,
2349
2384
  expandedRowKeys: innerExpandedKeys,
@@ -2378,7 +2413,7 @@ const GridEdit = props => {
2378
2413
  });
2379
2414
  }
2380
2415
  }
2381
- },
2416
+ } : undefined,
2382
2417
  triggerChangeColumns: triggerChangeColumns,
2383
2418
  clickHeaderToSort: false,
2384
2419
  isFilter: isFilter,
@@ -9,6 +9,7 @@ type Props<T> = GridTableProps<T> & {
9
9
  triggerGroupColumns?: (groupedColumns: string[]) => void;
10
10
  triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
11
11
  triggerFilter?: (queries: any) => void;
12
+ setTooltipContent?: any;
12
13
  };
13
14
  declare const Group: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
14
15
  export default Group;
@@ -1,7 +1,7 @@
1
1
  import type { Key, ReactElement, ReactNode } from "react";
2
2
  import type React from "react";
3
3
  import type { IOperator } from "./hooks";
4
- import type { TypeFilter, TableProps as RcTableProps, TableColumnType as RcColumnType, EditType } from "rc-master-ui";
4
+ import type { TypeFilter, TableProps as RcTableProps, TableColumnType as RcColumnType, EditType, TablePaginationConfig } from "rc-master-ui";
5
5
  import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/interface";
6
6
  import type { ToolbarItem as RcToolbarItem } from "rc-master-ui/es/toolbar";
7
7
  import type { ItemType } from "rc-master-ui/es/menu/interface";
@@ -135,12 +135,13 @@ export type ColumnTemplate<RecordType> = {
135
135
  field: string;
136
136
  };
137
137
  export type ColumnsTable<RecordType = AnyObject> = ColumnTable<RecordType>[];
138
- export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary'> {
138
+ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination'> {
139
139
  editAble?: boolean;
140
140
  groupAble?: boolean;
141
141
  groupColumns?: string[];
142
142
  groupSetting?: IGroupSetting;
143
143
  onChooseColumns?: (props: IOnChooseColumns) => void;
144
+ pagination?: false | PaginationConfig;
144
145
  showCustomTooltip?: boolean;
145
146
  sortMultiple?: boolean;
146
147
  dataSource: RecordType[];
@@ -193,7 +194,11 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
193
194
  onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
194
195
  onCellClick?: (args: ICellClick, callback?: any) => void;
195
196
  rowEditable?: (rowData: RecordType) => boolean;
197
+ validate?: any;
196
198
  }
199
+ export type PaginationConfig = TablePaginationConfig & {
200
+ currentPage?: number;
201
+ };
197
202
  export type ICellClick = {
198
203
  index: number;
199
204
  indexCol?: number;
@@ -12,6 +12,7 @@ export interface IContext<RecordType> {
12
12
  form?: any;
13
13
  format?: IFormat;
14
14
  control?: any;
15
+ errors?: any;
15
16
  trigger?: any;
16
17
  handleSubmit?: any;
17
18
  onSubmit?: SubmitHandler<any>;