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;
@@ -5,6 +5,7 @@ import classNames from "classnames";
5
5
  import { Button, Dropdown, Form, Modal, Typography } from "antd";
6
6
  import { useForm } from 'react-hook-form';
7
7
  import { Toaster } from "react-hot-toast";
8
+ import { yupResolver } from "@hookform/resolvers/yup";
8
9
  import { flatColumns2, getValueCell, renderContent } from "../hooks/columns";
9
10
  import EditableCell from "../EditableCell";
10
11
  import { GridStyle } from "../GridStyle";
@@ -19,13 +20,13 @@ import { Toolbar, ConfigProvider, InputNumber } from "rc-master-ui";
19
20
  import classnames from "classnames";
20
21
  import { Plus, Trash2 } from "becoxy-icons";
21
22
  import { faker } from "@faker-js/faker";
23
+ import { SELECTION_COLUMN } from "../InternalTable";
22
24
  const {
23
25
  Paragraph,
24
26
  Title
25
27
  } = Typography;
26
28
  dayjs.extend(customParseFormat);
27
29
  const toast = 'top-right';
28
- // const defaultContext: ContextMenuItem[] = [
29
30
  const defaultContext = [{
30
31
  key: 'INSERT_BEFORE',
31
32
  label: 'Thêm dòng bên trên',
@@ -88,6 +89,44 @@ const defaultContext = [{
88
89
  key: 'INSERT_AFTER_ADV',
89
90
  label: 'Tùy chỉnh'
90
91
  }]
92
+ }, {
93
+ key: 'INSERT_CHILDREN',
94
+ // label: 'Insert item children',
95
+ label: 'Thêm cấp con',
96
+ icon: /*#__PURE__*/React.createElement(Plus, {
97
+ fontSize: 14
98
+ })
99
+ // children: [
100
+ // {
101
+ // parentKey: 'INSERT_AFTER',
102
+ // key: 'INSERT_AFTER_1',
103
+ // label: 'Thêm 1 dòng',
104
+ // row: 1
105
+ // },
106
+ // {
107
+ // parentKey: 'INSERT_AFTER',
108
+ // key: 'INSERT_AFTER_10',
109
+ // label: 'Thêm 10 dòng',
110
+ // row: 10
111
+ // },
112
+ // {
113
+ // parentKey: 'INSERT_AFTER',
114
+ // key: 'INSERT_AFTER_50',
115
+ // label: 'Thêm 50 dòng',
116
+ // row: 50
117
+ // },
118
+ // {
119
+ // parentKey: 'INSERT_AFTER',
120
+ // key: 'INSERT_AFTER_100',
121
+ // label: 'Thêm 100 dòng',
122
+ // row: 100
123
+ // },
124
+ // {
125
+ // parentKey: 'INSERT_AFTER',
126
+ // key: 'INSERT_AFTER_ADV',
127
+ // label: 'Tùy chỉnh'
128
+ // }
129
+ // ]
91
130
  }, {
92
131
  key: 'DELETE_CONTENT',
93
132
  label: 'Xóa nội dung',
@@ -101,6 +140,37 @@ const defaultContext = [{
101
140
  fontSize: 14
102
141
  })
103
142
  }];
143
+ const validateData = async (data, formSchema) => {
144
+ if (!formSchema) {
145
+ return [];
146
+ } else {
147
+ const errors = [];
148
+ for (let i = 0; i < data.length; i++) {
149
+ try {
150
+ await formSchema.validate(data[i], {
151
+ abortEarly: false
152
+ });
153
+ } catch (error) {
154
+ errors.push(error.inner.reduce((acc, err) => {
155
+ acc[err.path] = {
156
+ field: err.path,
157
+ index: i,
158
+ message: err.message,
159
+ type: err.type,
160
+ ref: {
161
+ name: err.path
162
+ }
163
+ };
164
+ return {
165
+ ...acc,
166
+ index: i
167
+ };
168
+ }, {}));
169
+ }
170
+ }
171
+ return errors;
172
+ }
173
+ };
104
174
  const GridEdit = props => {
105
175
  const {
106
176
  id: tableId,
@@ -129,6 +199,8 @@ const GridEdit = props => {
129
199
  rowEditable,
130
200
  contextMenuItems: propsContext,
131
201
  showDefaultContext,
202
+ validate,
203
+ setTooltipContent,
132
204
  ...rest
133
205
  } = props;
134
206
  const ref = useRef(null);
@@ -168,33 +240,17 @@ const GridEdit = props => {
168
240
  }];
169
241
  const [form] = Form.useForm();
170
242
  const [editingKey, setEditingKey] = useState('');
243
+ const [dataErrors, setDataErrors] = useState([]);
171
244
  const [isFilter, setIsFilter] = React.useState(false);
172
245
  const [rangeCells, setRangeCells] = useState(new Set());
173
-
174
- // const [pasteCells, setPasteCells] = useState(new Set())
175
-
176
- // const defaultModalPaste = {open: false, rowIndex: -1, colIndex: -1, record: {}, rowsPasted: []}
177
-
178
- // const [isCtrlDown, setIsCtrlDown] = useState(false)
179
-
180
- // const [ctrlCells, setCtrlCells] = useState<any>([])
181
- // const [currentCtrlCells, setCurrentCtrlCells] = useState<any>(new Set())
182
-
183
246
  const [openModalAddRow, setOpenModalAddRow] = useState({
184
247
  open: false,
185
248
  type: ''
186
249
  });
187
250
  const [rowsAdd, setRowsAdd] = useState(1);
188
251
  const [cellEditing, setCellEditing] = useState(null);
189
-
190
- // const [isSelectDragging, setSelectIsDragging] = useState(false)
191
-
192
252
  const [isPasteDragging, setIsPasteDragging] = useState(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
193
253
 
194
- // const [rowsSelected, setRowsSelected] = useState(new Set())
195
-
196
- // const [startSelectedCells, setStartSelectedCell] = useState<{ row: number; col: number } | null>(null)
197
-
198
254
  const [innerExpandedKeys, setInnerExpandedKeys] = React.useState(() => {
199
255
  // if (defaultExpandedRowKeys) {
200
256
  // return defaultExpandedRowKeys;
@@ -205,6 +261,16 @@ const GridEdit = props => {
205
261
  // return [];
206
262
  });
207
263
  const mergedExpandedKeys = React.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
264
+ React.useEffect(() => {
265
+ if (validate && dataSource && dataSource.length) {
266
+ validateData(dataSource, validate).then(error => {
267
+ setDataErrors([...error]);
268
+ // if (getErrors) {
269
+ // getErrors([...error])
270
+ // }
271
+ });
272
+ }
273
+ }, [validate, dataSource]);
208
274
  const rowsFocus = React.useMemo(() => {
209
275
  return [...new Set(Array.from(rangeCells).map(item => parseInt(item.split('-')[0])))] ?? [];
210
276
  }, [rangeCells]);
@@ -226,8 +292,11 @@ const GridEdit = props => {
226
292
  newExpandedKeys = [...mergedExpandedKeys, key];
227
293
  }
228
294
  setInnerExpandedKeys(newExpandedKeys);
229
- }, [getRowKey, mergedExpandedKeys, dataSource]);
230
- const handleAddSingle = item => {
295
+ //
296
+ // onAddBgSelectedCell(rangeCells, id)
297
+ // onAddBorderSelectedCell(rangeCells, id)
298
+ }, [getRowKey, dataSource, mergedExpandedKeys]);
299
+ const handleAddSingle = React.useCallback(item => {
231
300
  const defaultRowValue = getDefaultValue(defaultValue);
232
301
  const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
233
302
  if (item && item.onClick) {
@@ -245,8 +314,8 @@ const GridEdit = props => {
245
314
  }];
246
315
  triggerChangeData?.(newData, 'Add');
247
316
  }
248
- };
249
- const handleAddMulti = (item, e) => {
317
+ }, [dataSource, defaultValue, triggerChangeData]);
318
+ const handleAddMulti = React.useCallback((item, e) => {
250
319
  if (item.onClick) {
251
320
  item.onClick({
252
321
  toolbar: item
@@ -266,8 +335,8 @@ const GridEdit = props => {
266
335
  const newData = dataSource.concat(newRows);
267
336
  triggerChangeData?.(newData, 'Add');
268
337
  }
269
- };
270
- const handleDuplicate = () => {
338
+ }, [dataSource, defaultValue, triggerChangeData]);
339
+ const handleDuplicate = React.useCallback(() => {
271
340
  // không tính tree
272
341
 
273
342
  // Cập nhật data mới
@@ -283,10 +352,10 @@ const GridEdit = props => {
283
352
  const insertAfter = Math.max(...rowsFocus);
284
353
  const rs = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
285
354
  triggerChangeData?.(rs, 'DUPLICATE');
286
- };
355
+ }, [dataSource, rowsFocus, triggerChangeData]);
287
356
 
288
357
  // thêm n dòng bên trên
289
- const handleInsertBefore = (item, n) => {
358
+ const handleInsertBefore = React.useCallback((item, n) => {
290
359
  //
291
360
  onRemoveBgSelectedCell(selectedCells.current, id);
292
361
  onRemoveBorderSelectedCell(selectedCells.current, id);
@@ -365,10 +434,10 @@ const GridEdit = props => {
365
434
  triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
366
435
  }
367
436
  }
368
- };
437
+ }, [dataSource, defaultValue, id, isFilter, rowKey, rowsFocus, triggerChangeData]);
369
438
 
370
439
  //thêm 1 dòng bên dưới
371
- const handleInsertAfter = (item, n) => {
440
+ const handleInsertAfter = React.useCallback((item, n) => {
372
441
  const defaultRowValue = getDefaultValue(defaultValue);
373
442
  const record = flattenData(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
374
443
 
@@ -439,8 +508,8 @@ const GridEdit = props => {
439
508
  triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
440
509
  }
441
510
  }
442
- };
443
- const handleInsertChild = item => {
511
+ }, [dataSource, defaultValue, isFilter, rowKey, rowsFocus, triggerChangeData]);
512
+ const handleInsertChild = React.useCallback(item => {
444
513
  const defaultRowValue = getDefaultValue(defaultValue);
445
514
  const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid();
446
515
  const record = flattenData(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
@@ -481,8 +550,8 @@ const GridEdit = props => {
481
550
  const newExpandedKeys = [...mergedExpandedKeys, key];
482
551
  setInnerExpandedKeys(newExpandedKeys);
483
552
  }
484
- };
485
- const handleDeleteRows = item => {
553
+ }, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
554
+ const handleDeleteRows = React.useCallback(item => {
486
555
  setTimeout(() => {
487
556
  onAddBgSelectedCell(selectedCells.current, id);
488
557
  onAddBorderSelectedCell(selectedCells.current, id);
@@ -501,11 +570,11 @@ const GridEdit = props => {
501
570
  });
502
571
  triggerChangeData?.([...newData], 'DELETE_ROWS');
503
572
  }
504
- };
505
- const handleDeleteAll = () => {
573
+ }, [dataSource, id, rowsFocus, triggerChangeData]);
574
+ const handleDeleteAll = React.useCallback(() => {
506
575
  triggerChangeData?.([], 'INSERT_BEFORE');
507
- };
508
- const handleDeleteContent = () => {
576
+ }, [triggerChangeData]);
577
+ const handleDeleteContent = React.useCallback(() => {
509
578
  if (selectedCells.current.size > 0) {
510
579
  const newData = [...dataSource];
511
580
 
@@ -525,7 +594,7 @@ const GridEdit = props => {
525
594
  }
526
595
  triggerChangeData?.([...newData], 'DELETE_CONTENT');
527
596
  }
528
- };
597
+ }, [dataSource, triggerChangeData, visibleCols]);
529
598
  const toolbarItemsBottom = useMemo(() => {
530
599
  if (!rowsFocus || rowsFocus.length === 0) {
531
600
  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 => {
@@ -690,7 +759,7 @@ const GridEdit = props => {
690
759
  variant: 'outlined',
691
760
  onClick: () => handleInsertChild(item),
692
761
  className: "d-flex toolbar-button"
693
- }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
762
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children')));
694
763
  }
695
764
  };
696
765
  }
@@ -734,19 +803,24 @@ const GridEdit = props => {
734
803
  ...item
735
804
  };
736
805
  });
737
- }, [handleAddMulti, handleAddSingle, itemsAdd, rowsFocus.length, t, toolbarItems]);
806
+ }, [handleAddMulti, handleAddSingle, handleDeleteAll, handleDeleteRows, handleDuplicate, handleInsertAfter, handleInsertBefore, handleInsertChild, itemsAdd, rowsFocus, t, toolbarItems]);
738
807
  const {
739
808
  control,
740
809
  handleSubmit,
741
810
  setValue,
742
811
  trigger,
743
812
  getValues,
744
- reset
813
+ reset,
814
+ formState: {
815
+ errors
816
+ }
745
817
  } = useForm({
746
- mode: 'onChange'
747
- // resolver: yupResolver(formSchema)
818
+ mode: 'onChange',
819
+ resolver: yupResolver(validate)
748
820
  });
749
- const isEditing = record => record[rowKey] === editingKey;
821
+ const isEditing = React.useCallback(record => {
822
+ return record[rowKey] === editingKey;
823
+ }, [editingKey, rowKey]);
750
824
  useEffect(() => {
751
825
  const handleClickOutside = event => {
752
826
  const element = event.target;
@@ -791,8 +865,11 @@ const GridEdit = props => {
791
865
  return () => {
792
866
  document.removeEventListener("click", handleClickOutside);
793
867
  };
794
- }, []);
868
+ }, [id]);
795
869
  const handleMouseDown = (record, row, col, e) => {
870
+ if (editingKey && editingKey === record[rowKey]) {
871
+ return;
872
+ }
796
873
  if (e.button === 2) {
797
874
  e.stopPropagation();
798
875
  return;
@@ -848,7 +925,7 @@ const GridEdit = props => {
848
925
  setTimeout(() => {
849
926
  onAddBgSelectedCell(cells, id);
850
927
  onAddBorderSelectedCell(cells, id);
851
- }, 100);
928
+ }, 200);
852
929
  } else {
853
930
  onAddBgSelectedCell(cells, id);
854
931
  onAddBorderSelectedCell(cells, id);
@@ -995,9 +1072,12 @@ const GridEdit = props => {
995
1072
  // selectedCells.current = sortedSetASC(mergedSet)
996
1073
  hideDraggingPoint(selectedCells.current, id);
997
1074
  selectedCells.current = sortedSetASC(mergedSet);
998
- onAddBgSelectedCell(sortedSetASC(mergedSet), id);
999
- onAddBorderSelectedCell(sortedSetASC(mergedSet), id);
1000
- showDraggingPoint(sortedSetASC(mergedSet), id);
1075
+ setRangeCells(sortedSetASC(mergedSet));
1076
+ setTimeout(() => {
1077
+ onAddBgSelectedCell(sortedSetASC(mergedSet), id);
1078
+ onAddBorderSelectedCell(sortedSetASC(mergedSet), id);
1079
+ showDraggingPoint(sortedSetASC(mergedSet), id);
1080
+ }, 50);
1001
1081
 
1002
1082
  // setPasteCells(new Set())
1003
1083
 
@@ -1021,27 +1101,6 @@ const GridEdit = props => {
1021
1101
  hideDraggingPoint(selectedCells.current, id);
1022
1102
  triggerDragPaste(newPasteCells);
1023
1103
  };
1024
-
1025
- // const handleClickCell = (e: any) => {
1026
- //
1027
- // if (e.ctrlKey) {
1028
- //
1029
- // const cell: any = new Set([`${row}-${col}`])
1030
- //
1031
- // const found = ctrlCells.find((s: any) => isEqualSet(s, cell));
1032
- //
1033
- // if (found) {
1034
- // const rs = ctrlCells.filter((s: any) => !isEqualSet(s, cell));
1035
- //
1036
- // setCtrlCells(rs)
1037
- //
1038
- // } else {
1039
- // setCtrlCells([...ctrlCells, cell])
1040
- // }
1041
- //
1042
- // }
1043
- // }
1044
-
1045
1104
  const handleMouseUp = e => {
1046
1105
  isSelecting.current = false;
1047
1106
  startCell.current = null;
@@ -1081,15 +1140,6 @@ const GridEdit = props => {
1081
1140
  showDraggingPoint(selectedCells.current, id);
1082
1141
  }
1083
1142
  };
1084
-
1085
- // const handlePointEnter = () => {
1086
- // isPointEnter.current = true;
1087
- // }
1088
- //
1089
- // const handlePointLeave = () => {
1090
- // isPointEnter.current = false;
1091
- // }
1092
-
1093
1143
  const handleMouseEnter = (row, col, e) => {
1094
1144
  if (!isSelecting.current || !startCell.current) {
1095
1145
  return;
@@ -1195,32 +1245,6 @@ const GridEdit = props => {
1195
1245
  }
1196
1246
  }
1197
1247
  };
1198
-
1199
- // const handleClickRowHeader = (row: any, col: any) => {
1200
- //
1201
- // const newSelectedCells = new Set()
1202
- //
1203
- // const tCols = editAbleColumns(columns)
1204
- //
1205
- // for (let r = Math.min(row, row); r <= Math.max(row, row); r++) {
1206
- // for (let c = Math.min(tCols.length, col) + 1; c <= Math.max(tCols.length, col); c++) {
1207
- // newSelectedCells.add(`${r}-${c}`)
1208
- // }
1209
- // }
1210
- //
1211
- // // setSelectedCells(newSelectedCells)
1212
- //
1213
- // if (selectedCells.current && selectedCells.current.size > 0) {
1214
- // onRemoveBgSelectedCell(selectedCells.current, id)
1215
- // }
1216
- //
1217
- // selectedCells.current = newSelectedCells
1218
- //
1219
- // onAddBgSelectedCell(newSelectedCells, id)
1220
- //
1221
- //
1222
- // };
1223
-
1224
1248
  const handleClickColHeader = (column, indexColumn) => {
1225
1249
  const newSelectedCells = new Set();
1226
1250
  for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
@@ -1731,6 +1755,7 @@ const GridEdit = props => {
1731
1755
  }
1732
1756
  };
1733
1757
  const handleEdit = (record, col, editType, e) => {
1758
+ setTooltipContent('');
1734
1759
  // @ts-ignore
1735
1760
  setEditingKey(record[rowKey]);
1736
1761
  setCellEditing({
@@ -1881,10 +1906,10 @@ const GridEdit = props => {
1881
1906
  }
1882
1907
  };
1883
1908
  const convertColumns = flatColumns2(columns.filter(it => it.visible !== false)).map((column, colIndex) => {
1884
- if (!column?.field && !column?.key) {
1885
- return column;
1909
+ if (column === SELECTION_COLUMN) {
1910
+ return SELECTION_COLUMN;
1886
1911
  }
1887
- if (column.dataIndex === '#' || column.dataIndex === '#') {
1912
+ if (column.field === '#') {
1888
1913
  return {
1889
1914
  ...column,
1890
1915
  className: 'rc-ui-cell-editable rc-ui-cell-index',
@@ -1925,7 +1950,7 @@ const GridEdit = props => {
1925
1950
  }
1926
1951
  };
1927
1952
  }
1928
- if ((column.key || column.field) === 'command') {
1953
+ if (column.field === 'command') {
1929
1954
  return {
1930
1955
  ...column
1931
1956
  };
@@ -1978,10 +2003,8 @@ const GridEdit = props => {
1978
2003
  if (event.key === 'Tab') {
1979
2004
  if (editingKey) {} else {
1980
2005
  if (colIndex + 1 !== visibleCols.length) {
1981
- // console.log('bbbbb')
1982
2006
  handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
1983
2007
  } else {
1984
- // console.log('fffff')
1985
2008
  event.stopPropagation();
1986
2009
  event.preventDefault();
1987
2010
  }
@@ -2060,10 +2083,6 @@ const GridEdit = props => {
2060
2083
  rowsSelected.current = new Set();
2061
2084
  }
2062
2085
  },
2063
- // onMouseEnter: () => {
2064
- //
2065
- // },
2066
-
2067
2086
  onClick: () => {
2068
2087
  if (record[rowKey] !== editingKey && editingKey !== '') {
2069
2088
  setEditingKey('');
@@ -2073,7 +2092,7 @@ const GridEdit = props => {
2073
2092
  }
2074
2093
  }
2075
2094
  },
2076
- className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : `rc-ui-cell-editable cell-editable ${!isEditable(column, record) ? 'disable' : ''}`,
2095
+ className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!isEditable(column, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!isEditable(column, record) ? 'disable' : ''}`,
2077
2096
  record,
2078
2097
  column: column,
2079
2098
  editType: getEditType(column, record),
@@ -2123,12 +2142,23 @@ const GridEdit = props => {
2123
2142
  const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
2124
2143
  const colFormat = typeof column.format === 'function' ? column.format(record) : column.format;
2125
2144
  const cellFormat = getFormat(colFormat, format);
2145
+ const rowError = dataErrors.find(it => it.index === rowNumber);
2146
+ const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
2147
+
2148
+ // const aaa = dataErrors.find((it) => column?.field && it[column.field].field === column.field && it.index === rowNumber)
2149
+ // const aaa = column.field && rowError && rowError[column.field]?.field === column?.field
2150
+
2126
2151
  return /*#__PURE__*/React.createElement("div", {
2127
2152
  className: classNames('ui-rc_cell-content', {
2128
2153
  // disable: !isEditable(column as any, record)
2154
+ isValid: column.field && rowError && rowError[column.field]?.field === column?.field
2129
2155
  }),
2130
2156
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2131
- onMouseEnter: event => handleMouseEnter(rowNumber, colIndex, event),
2157
+ onMouseEnter: event => {
2158
+ // setTooltipContent(cellError ? cellError.message : renderContent(column as any, value, record, rowIndex, cellFormat))
2159
+ setTooltipContent(cellError ? cellError.message : '');
2160
+ handleMouseEnter(rowNumber, colIndex, event);
2161
+ },
2132
2162
  onMouseUp: handleMouseUp,
2133
2163
  onMouseMove: () => {
2134
2164
  if (selectedCells && selectedCells.current.size > 0 && isMouseDown.current) {
@@ -2168,9 +2198,9 @@ const GridEdit = props => {
2168
2198
  const transformColumns = React.useCallback(cols => {
2169
2199
  // @ts-ignore
2170
2200
  return cols.map(column => {
2171
- const find = convertColumns.find(it => it.key === column.key);
2172
- if (!column?.field && !column?.key) {
2173
- return column;
2201
+ const find = convertColumns.find(it => it?.field === column.field);
2202
+ if (column === SELECTION_COLUMN) {
2203
+ return SELECTION_COLUMN;
2174
2204
  }
2175
2205
  if (find) {
2176
2206
  return {
@@ -2237,6 +2267,10 @@ const GridEdit = props => {
2237
2267
  }
2238
2268
  return;
2239
2269
  }
2270
+ if (args.item.key === 'INSERT_CHILDREN') {
2271
+ handleInsertChild(args.item);
2272
+ return;
2273
+ }
2240
2274
  if (args.item.key === 'DELETE_ROWS') {
2241
2275
  handleDeleteRows(args.item);
2242
2276
  return;
@@ -2279,6 +2313,7 @@ const GridEdit = props => {
2279
2313
  format,
2280
2314
  control,
2281
2315
  trigger,
2316
+ errors,
2282
2317
  getValues,
2283
2318
  handleCellChange,
2284
2319
  getRowKey
@@ -2335,7 +2370,7 @@ const GridEdit = props => {
2335
2370
  },
2336
2371
  rowHoverable: false,
2337
2372
  bottomToolbar: bottomToolbar,
2338
- expandable: {
2373
+ expandable: expandable ? {
2339
2374
  expandIconColumnIndex: checkChild(dataSource) ? 3 : undefined,
2340
2375
  ...expandable,
2341
2376
  expandedRowKeys: innerExpandedKeys,
@@ -2370,7 +2405,7 @@ const GridEdit = props => {
2370
2405
  });
2371
2406
  }
2372
2407
  }
2373
- },
2408
+ } : undefined,
2374
2409
  triggerChangeColumns: triggerChangeColumns,
2375
2410
  clickHeaderToSort: false,
2376
2411
  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>;