es-grid-template 1.5.0 → 1.5.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 (39) hide show
  1. package/es/grid-component/ColumnsChoose.js +1 -1
  2. package/es/grid-component/EditableCell.js +14 -12
  3. package/es/grid-component/GridStyle.js +1 -1
  4. package/es/grid-component/InternalTable.js +15 -4
  5. package/es/grid-component/TableGrid.js +1 -1
  6. package/es/grid-component/async-select/index.d.ts +4 -2
  7. package/es/grid-component/async-select/index.js +3 -0
  8. package/es/grid-component/async-table-select/index.d.ts +4 -2
  9. package/es/grid-component/async-table-select/index.js +4 -1
  10. package/es/grid-component/hooks/columns/index.d.ts +1 -1
  11. package/es/grid-component/hooks/columns/index.js +19 -31
  12. package/es/grid-component/hooks/utils.d.ts +3 -0
  13. package/es/grid-component/hooks/utils.js +85 -2
  14. package/es/grid-component/styles.scss +4 -0
  15. package/es/grid-component/table/GridEdit.js +93 -76
  16. package/es/grid-component/table/Group.js +11 -1
  17. package/es/grid-component/type.d.ts +9 -0
  18. package/es/grid-component/useContext.d.ts +1 -0
  19. package/es/grid-component/useContext.js +2 -1
  20. package/lib/grid-component/ColumnsChoose.js +1 -1
  21. package/lib/grid-component/EditableCell.js +14 -12
  22. package/lib/grid-component/GridStyle.js +1 -1
  23. package/lib/grid-component/InternalTable.js +14 -3
  24. package/lib/grid-component/TableGrid.js +1 -1
  25. package/lib/grid-component/async-select/index.d.ts +4 -2
  26. package/lib/grid-component/async-select/index.js +3 -0
  27. package/lib/grid-component/async-table-select/index.d.ts +4 -2
  28. package/lib/grid-component/async-table-select/index.js +4 -1
  29. package/lib/grid-component/hooks/columns/index.d.ts +1 -1
  30. package/lib/grid-component/hooks/columns/index.js +17 -29
  31. package/lib/grid-component/hooks/utils.d.ts +3 -0
  32. package/lib/grid-component/hooks/utils.js +96 -7
  33. package/lib/grid-component/styles.scss +4 -0
  34. package/lib/grid-component/table/GridEdit.js +93 -76
  35. package/lib/grid-component/table/Group.js +11 -1
  36. package/lib/grid-component/type.d.ts +9 -0
  37. package/lib/grid-component/useContext.d.ts +1 -0
  38. package/lib/grid-component/useContext.js +2 -1
  39. package/package.json +110 -110
@@ -207,6 +207,7 @@ const GridEdit = props => {
207
207
  showDefaultContext,
208
208
  validate,
209
209
  setTooltipContent,
210
+ onBlur,
210
211
  ...rest
211
212
  } = props;
212
213
  const ref = useRef(null);
@@ -223,6 +224,8 @@ const GridEdit = props => {
223
224
  // quét vùng chọn
224
225
  const isDragMouse = useRef(false);
225
226
  const isMouseDown = useRef(false);
227
+ const editingKey = useRef('');
228
+ const cellEditing = useRef({});
226
229
 
227
230
  // quét vùng được paste - tiếp tục hiển thị con trỏ crosshair
228
231
  // const isPasteDragging = useRef(false);
@@ -368,7 +371,9 @@ const GridEdit = props => {
368
371
  // }, [])
369
372
 
370
373
  const [form] = Form.useForm();
371
- const [editingKey, setEditingKey] = useState('');
374
+
375
+ // const [editingKey, setEditingKey] = useState<string | number>('')
376
+
372
377
  const [dataErrors, setDataErrors] = useState([]);
373
378
  const [isFilter, setIsFilter] = React.useState(false);
374
379
  const [rangeCells, setRangeCells] = useState(new Set());
@@ -377,7 +382,9 @@ const GridEdit = props => {
377
382
  type: ''
378
383
  });
379
384
  const [rowsAdd, setRowsAdd] = useState(1);
380
- const [cellEditing, setCellEditing] = useState(null);
385
+
386
+ // const [cellEditing, setCellEditing] = useState<any>(null)
387
+
381
388
  const [isPasteDragging, setIsPasteDragging] = useState(false); // isPasteDragging == tiếp tục hiển thị con trỏ crosshair
382
389
 
383
390
  const [innerExpandedKeys, setInnerExpandedKeys] = React.useState(() => {
@@ -490,10 +497,11 @@ const GridEdit = props => {
490
497
  // onRemoveBorderSelectedCell(selectedCells.current, id)
491
498
  //
492
499
 
493
- setTimeout(() => {
494
- // onAddBgSelectedCell(selectedCells.current, id)
495
- // onAddBorderSelectedCell(selectedCells.current, id)
496
- }, 10);
500
+ // setTimeout(() => {
501
+ // onAddBgSelectedCell(selectedCells.current, id)
502
+ // onAddBorderSelectedCell(selectedCells.current, id)
503
+ // }, 10)
504
+
497
505
  const defaultRowValue = getDefaultValue(defaultValue);
498
506
  // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
499
507
 
@@ -681,10 +689,11 @@ const GridEdit = props => {
681
689
  }
682
690
  }, [dataSource, defaultValue, getRowKey, mergedExpandedKeys, rowKey, rowsFocus, triggerChangeData]);
683
691
  const handleDeleteRows = React.useCallback(item => {
684
- setTimeout(() => {
685
- // onAddBgSelectedCell(selectedCells.current, id)
686
- // onAddBorderSelectedCell(selectedCells.current, id)
687
- });
692
+ // setTimeout(() => {
693
+ // onAddBgSelectedCell(selectedCells.current, id)
694
+ // onAddBorderSelectedCell(selectedCells.current, id)
695
+ // })
696
+
688
697
  if (item.onClick) {
689
698
  item.onClick({
690
699
  toolbar: item
@@ -716,7 +725,9 @@ const GridEdit = props => {
716
725
  const rowIndex = Number(rowIndexStr);
717
726
  const colIndex = Number(colIndexStr);
718
727
  const field = colIndexToField[colIndex];
719
- if (newData[rowIndex] && field && field in newData[rowIndex]) {
728
+ const column = flatColumns2(visibleCols)[colIndex];
729
+ const rowData = flattenData(childrenColumnName, dataSource)[rowIndex];
730
+ if (newData[rowIndex] && field && field in newData[rowIndex] && isEditable(column, rowData)) {
720
731
  // @ts-ignore
721
732
  newData[rowIndex][field] = '';
722
733
  }
@@ -947,9 +958,13 @@ const GridEdit = props => {
947
958
  mode: 'onChange',
948
959
  resolver: validate ? yupResolver(validate) : undefined
949
960
  });
950
- const isEditing = React.useCallback(record => {
951
- return record[rowKey] === editingKey;
952
- }, [editingKey, rowKey]);
961
+
962
+ // const isEditing = React.useCallback((record: RecordType) => {
963
+ // return record[rowKey as any] === editingKey.current
964
+ // }, [editingKey, rowKey])
965
+
966
+ // console.log('isEditing', isEditing)
967
+
953
968
  React.useEffect(() => {
954
969
  const handleClickOutside = event => {
955
970
  const element = event.target;
@@ -976,9 +991,12 @@ const GridEdit = props => {
976
991
  // if (ref.current && tableId && !tableId.contains(event.target as Node)) {
977
992
 
978
993
  if (ref.current && tableBody && !tableBody.contains(event.target)) {
979
- // setEditingKey('')
994
+ if (editingKey.current) {
995
+ onBlur?.(dataSource);
996
+ }
980
997
  setTimeout(() => {
981
- setEditingKey('');
998
+ // setEditingKey('')
999
+ editingKey.current = '';
982
1000
  });
983
1001
  isSelecting.current = false;
984
1002
  startCell.current = null;
@@ -996,13 +1014,14 @@ const GridEdit = props => {
996
1014
 
997
1015
  // document.addEventListener('click', handleClickOutside)
998
1016
  document.addEventListener('mousedown', handleClickOutside);
999
- document.addEventListener('touchstart', handleClickOutside);
1017
+ // document.addEventListener('touchstart', handleClickOutside)
1018
+
1000
1019
  return () => {
1001
1020
  // document.removeEventListener('click', handleClickOutside)
1002
1021
  document.removeEventListener('mousedown', handleClickOutside);
1003
- document.removeEventListener('touchstart', handleClickOutside);
1022
+ // document.removeEventListener('touchstart', handleClickOutside)
1004
1023
  };
1005
- }, [id]);
1024
+ }, [dataSource, id, onBlur]);
1006
1025
  const triggerDragPaste = pastesArray => {
1007
1026
  const mergedSet = new Set([...selectedCells.current, ...pastesArray]);
1008
1027
  const tmpCols = {
@@ -1412,12 +1431,14 @@ const GridEdit = props => {
1412
1431
  e.stopPropagation();
1413
1432
  return;
1414
1433
  }
1415
- if (editingKey && editingKey === record[rowKey]) {
1434
+ if (editingKey && editingKey.current === record[rowKey]) {
1416
1435
  return;
1417
1436
  }
1418
- if (record[rowKey] !== editingKey && editingKey !== '') {
1437
+ if (record[rowKey] !== editingKey.current && editingKey.current !== '') {
1419
1438
  setTimeout(() => {
1420
- setEditingKey('');
1439
+ // setEditingKey('')
1440
+ editingKey.current = '';
1441
+ onBlur?.(dataSource);
1421
1442
  });
1422
1443
  }
1423
1444
 
@@ -1653,8 +1674,9 @@ const GridEdit = props => {
1653
1674
  e.stopPropagation();
1654
1675
  return;
1655
1676
  }
1656
- if (editingKey) {
1657
- setEditingKey('');
1677
+ if (editingKey.current) {
1678
+ editingKey.current = '';
1679
+ // setEditingKey('')
1658
1680
  }
1659
1681
  isSelectingRow.current = true;
1660
1682
  rowStart.current = {
@@ -1870,12 +1892,20 @@ const GridEdit = props => {
1870
1892
  const handleEdit = (record, col, editType, e) => {
1871
1893
  onRemoveBorderSelectedCell(selectedCells.current, id);
1872
1894
  setTooltipContent('');
1895
+
1873
1896
  // @ts-ignore
1874
- setEditingKey(record[rowKey]);
1875
- setCellEditing({
1897
+ // setEditingKey(record[rowKey])
1898
+ editingKey.current = record[rowKey];
1899
+
1900
+ // setCellEditing({
1901
+ // row: record,
1902
+ // column: col
1903
+ // })
1904
+
1905
+ cellEditing.current = {
1876
1906
  row: record,
1877
1907
  column: col
1878
- });
1908
+ };
1879
1909
  reset();
1880
1910
 
1881
1911
  // const formattedRecord = { ...record };
@@ -1949,7 +1979,7 @@ const GridEdit = props => {
1949
1979
  }
1950
1980
  };
1951
1981
  const handleFocusCell = (rowIndex, colIndex, col, scrollType, e, isTimeout) => {
1952
- const isEdit = editingKey !== '';
1982
+ const isEdit = editingKey.current !== '';
1953
1983
  const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
1954
1984
  const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
1955
1985
  const updateSelection = () => {
@@ -1993,7 +2023,8 @@ const GridEdit = props => {
1993
2023
  scrollToCell(rowIndex, colIndex, editingCell, 'horizontal');
1994
2024
  }
1995
2025
  if (scrollType === 'vertical' && cellEditable) {
1996
- setEditingKey('');
2026
+ // setEditingKey('')
2027
+ editingKey.current = '';
1997
2028
  updateSelection();
1998
2029
  scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
1999
2030
  if (e?.key !== 'Tab') {
@@ -2042,13 +2073,13 @@ const GridEdit = props => {
2042
2073
  return {
2043
2074
  'data-row-index': rowNumber,
2044
2075
  onPaste: event => {
2045
- if (editingKey === '') {
2076
+ if (editingKey.current === '') {
2046
2077
  handlePaste(record, colIndex + 1, rowNumber, event);
2047
2078
  event.preventDefault();
2048
2079
  }
2049
2080
  },
2050
2081
  onCopy: e => {
2051
- if (editingKey === '') {
2082
+ if (editingKey.current === '') {
2052
2083
  handleCopy(e);
2053
2084
  e.preventDefault();
2054
2085
  }
@@ -2089,7 +2120,7 @@ const GridEdit = props => {
2089
2120
  const key = getRowKey(record, dataSource.indexOf(record));
2090
2121
  if (event.key === 'Control' && event.ctrlKey) {} else {
2091
2122
  if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
2092
- if (record[rowKey] !== editingKey && isEditable(column, record)) {
2123
+ if (record[rowKey] !== editingKey.current && isEditable(column, record)) {
2093
2124
  // ~~ khi editingKey = ''
2094
2125
  event.preventDefault();
2095
2126
  event.stopPropagation();
@@ -2112,7 +2143,7 @@ const GridEdit = props => {
2112
2143
  if (event.key === 'Enter') {
2113
2144
  event.preventDefault();
2114
2145
  event.stopPropagation();
2115
- if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length && event.key === 'Enter') {
2146
+ if (editingKey && editingKey.current !== '' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length && event.key === 'Enter') {
2116
2147
  handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
2117
2148
  } else {
2118
2149
  // // focus cell hiện tại và tắt edit
@@ -2128,7 +2159,7 @@ const GridEdit = props => {
2128
2159
  }
2129
2160
  }
2130
2161
  if (event.key === 'Tab') {
2131
- if (editingKey) {} else {
2162
+ if (editingKey.current) {} else {
2132
2163
  if (colIndex + 1 !== visibleCols.length) {
2133
2164
  handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
2134
2165
  } else {
@@ -2138,7 +2169,7 @@ const GridEdit = props => {
2138
2169
  }
2139
2170
  }
2140
2171
  if (event.key === 'ArrowRight' && colIndex + 1 !== visibleCols.length) {
2141
- if (editingKey !== '') {} else {
2172
+ if (editingKey.current !== '') {} else {
2142
2173
  handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
2143
2174
  }
2144
2175
  }
@@ -2147,47 +2178,51 @@ const GridEdit = props => {
2147
2178
  event.stopPropagation();
2148
2179
  event.preventDefault();
2149
2180
  } else {
2150
- if (editingKey !== '') {} else {
2181
+ if (editingKey.current !== '') {} else {
2151
2182
  handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
2152
2183
  }
2153
2184
  }
2154
2185
  }
2155
2186
  if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < flattenArray(dataSource).length) {
2156
- if (isEditing(record) && (getEditType(column, record) === 'treeSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'asyncSelect')) {
2187
+ // if (isEditing(record) && (
2188
+ if (record[rowKey] === editingKey.current && (getEditType(column, record) === 'treeSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'asyncSelect')) {
2157
2189
  event.stopPropagation();
2158
2190
  } else {
2159
2191
  handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
2160
2192
  }
2161
2193
  }
2162
2194
  if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
2163
- if (isEditing(record) && (getEditType(column, record) === 'asyncSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'treeSelect')) {
2195
+ if (record[rowKey] === editingKey.current && (getEditType(column, record) === 'asyncSelect' || getEditType(column, record) === 'select' || getEditType(column, record) === 'selectTable' || getEditType(column, record) === 'treeSelect')) {
2164
2196
  event.stopPropagation();
2165
2197
  } else {
2166
2198
  handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
2167
2199
  }
2168
2200
  }
2169
2201
  if (event.key === 'Delete') {
2202
+ if (!isEditable(column, record)) {}
2170
2203
  handleDeleteContent();
2171
2204
  }
2172
2205
  if (event.key === 'Escape') {
2173
- setEditingKey('');
2206
+ // setEditingKey('')
2207
+ editingKey.current = '';
2174
2208
  }
2175
2209
  }
2176
2210
  },
2177
2211
  onPaste: event => {
2178
- if (editingKey === '') {
2212
+ if (editingKey.current === '') {
2179
2213
  handlePaste(record, colIndex, rowNumber, event);
2180
2214
  event.preventDefault();
2181
2215
  }
2182
2216
  },
2183
2217
  onCopy: e => {
2184
- if (editingKey === '') {
2218
+ if (editingKey.current === '') {
2185
2219
  handleCopy(e);
2186
2220
  e.preventDefault();
2187
2221
  }
2188
2222
  },
2189
2223
  onDoubleClick: event => {
2190
- if (!isEditing(record) && record[rowKey] !== editingKey && isEditable(column, record)) {
2224
+ // if (!isEditing(record) && record[rowKey] !== editingKey.current && isEditable(column as any, record)) {
2225
+ if (!(record[rowKey] === editingKey.current) && record[rowKey] !== editingKey.current && isEditable(column, record)) {
2191
2226
  handleEdit(record, column, getEditType(column, record), event);
2192
2227
 
2193
2228
  // onRemoveBgSelectedCell(selectedCells.current, id)
@@ -2212,26 +2247,21 @@ const GridEdit = props => {
2212
2247
  }
2213
2248
  },
2214
2249
  onClick: () => {
2215
- if (record[rowKey] !== editingKey && editingKey !== '') {
2250
+ if (record[rowKey] !== editingKey.current && editingKey.current !== '') {
2216
2251
  // setEditingKey('')
2217
2252
  } else {
2218
- if (record[rowKey] !== editingKey) {
2253
+ if (record[rowKey] !== editingKey.current) {
2219
2254
  onAddBorderSelectedCell(selectedCells.current, id);
2220
2255
  }
2221
- if (editingKey) {
2256
+ if (editingKey.current) {
2222
2257
  handleCellClick(rowNumber, record, column);
2223
2258
  }
2224
2259
  }
2225
2260
  },
2226
2261
  // className: isEditing(record) ? `rc-ui-cell-editable cell-editing ${!isEditable(column as any, record) ? 'disable' : ''}` : `rc-ui-cell-editable cell-editable ${!isEditable(column as any, record) ? 'disable' : ''}`,
2227
2262
  className: classNames('rc-ui-cell-editable', {
2228
- 'cell-editing': isEditing(record),
2229
- 'cell-editable': !isEditing(record),
2230
- // selected: isSelectedCell(rangeCells,rowIndex, colIndex),
2231
- // 'cell-border-bottom': isRangeCell(rangeCells, 'bottom',rowIndex, colIndex),
2232
- // 'cell-border-right': isRangeCell(rangeCells, 'right',rowIndex, colIndex),
2233
- // 'cell-border-top': isRangeCell(rangeCells, 'top',rowIndex, colIndex),
2234
- // 'cell-border-left': isRangeCell(rangeCells, 'left',rowIndex, colIndex),
2263
+ 'cell-editing': record[rowKey] === editingKey.current,
2264
+ 'cell-editable': !(record[rowKey] === editingKey.current),
2235
2265
  disable: !isEditable(column, record)
2236
2266
  }),
2237
2267
  record,
@@ -2243,9 +2273,11 @@ const GridEdit = props => {
2243
2273
  title: getValueCell(column, record[column.field], format),
2244
2274
  'data-col-index': colIndex,
2245
2275
  'data-row-index': rowNumber,
2246
- 'data-tooltip-id': "tooltip-cell-content",
2247
- editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column, record),
2248
- cellEditing,
2276
+ // 'data-tooltip-id': "tooltip-cell-content",
2277
+ 'data-tooltip-id': `${id}-tooltip-cell-content`,
2278
+ // editing: isEditing(record) && rowEditable?.(record) !== false && isEditable(column as any, record),
2279
+ editing: record.rowId === editingKey.current && rowEditable?.(record) !== false && isEditable(column, record),
2280
+ cellEditing: cellEditing.current,
2249
2281
  t,
2250
2282
  tabIndex: (rowIndex ?? 0) * visibleCols.length + colIndex,
2251
2283
  style: isPasteDragging ? {
@@ -2260,13 +2292,13 @@ const GridEdit = props => {
2260
2292
  handleClickColHeader(column, colIndex);
2261
2293
  },
2262
2294
  onCopy: e => {
2263
- if (editingKey === '') {
2295
+ if (editingKey.current === '') {
2264
2296
  handleCopy(e);
2265
2297
  e.preventDefault();
2266
2298
  }
2267
2299
  },
2268
2300
  onPaste: event => {
2269
- if (editingKey === '') {
2301
+ if (editingKey.current === '') {
2270
2302
  handlePaste(dataSource[0], colIndex, 0, event);
2271
2303
  event.preventDefault();
2272
2304
  }
@@ -2282,18 +2314,12 @@ const GridEdit = props => {
2282
2314
  const cellFormat = getFormat(colFormat, format);
2283
2315
  const rowError = dataErrors.find(it => it.index === rowNumber);
2284
2316
  const cellError = rowError && column.field && rowError[column.field]?.field === column.field ? rowError[column.field] : null;
2285
-
2286
- // const aaa = dataErrors.find((it) => column?.field && it[column.field].field === column.field && it.index === rowNumber)
2287
- // const aaa = column.field && rowError && rowError[column.field]?.field === column?.field
2288
-
2289
2317
  return /*#__PURE__*/React.createElement("div", {
2290
2318
  className: classNames('ui-rc_cell-content', {
2291
- // disable: !isEditable(column as any, record)
2292
2319
  isValid: column.field && rowError && rowError[column.field]?.field === column?.field
2293
2320
  }),
2294
2321
  onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
2295
2322
  onMouseEnter: event => {
2296
- // setTooltipContent(cellError ? cellError.message : renderContent(column as any, value, record, rowIndex, cellFormat))
2297
2323
  setTooltipContent(cellError ? cellError.message : '');
2298
2324
  handleMouseEnter(rowNumber, colIndex, event);
2299
2325
  },
@@ -2304,20 +2330,9 @@ const GridEdit = props => {
2304
2330
  isDragMouse.current = true;
2305
2331
  }
2306
2332
  }
2307
-
2308
- // onClick={(event) => {
2309
- //
2310
- // handleClickCell(event)
2311
- //
2312
- // }}
2313
2333
  }, /*#__PURE__*/React.createElement("div", {
2314
2334
  className: 'ui-rc_content'
2315
- }, renderContent(column, value, record, rowIndex, cellFormat)),
2316
- // selectedCells.current && selectedCells.current.size > 0 && getLastSelectCell(selectedCells.current).row === rowNumber &&
2317
- // getLastSelectCell(selectedCells.current).col === colIndex &&
2318
- // isEditable(column as any, record) &&
2319
-
2320
- !isDragMouse.current && /*#__PURE__*/React.createElement("div", {
2335
+ }, renderContent(column, value, record, rowIndex, cellFormat)), !isDragMouse.current && /*#__PURE__*/React.createElement("div", {
2321
2336
  className: 'dragging-point hidden',
2322
2337
  onMouseDown: e => {
2323
2338
  // e.stopPropagation()
@@ -2408,7 +2423,8 @@ const GridEdit = props => {
2408
2423
  items: toolbarItemsBottom ?? [],
2409
2424
  mode: 'scroll',
2410
2425
  onClick: ({}) => {
2411
- setEditingKey('');
2426
+ editingKey.current = '';
2427
+ // setEditingKey('')
2412
2428
  }
2413
2429
  }));
2414
2430
  };
@@ -2481,6 +2497,7 @@ const GridEdit = props => {
2481
2497
  id: id
2482
2498
  }, /*#__PURE__*/React.createElement(TableContext.Provider, {
2483
2499
  value: {
2500
+ id: id ?? '',
2484
2501
  rowKey,
2485
2502
  form,
2486
2503
  format,
@@ -20,10 +20,12 @@ const Group = props => {
20
20
  groupAble,
21
21
  expandable,
22
22
  dataSource,
23
+ rowKey,
23
24
  getRowKey,
24
25
  groupSetting,
25
26
  groupColumns,
26
27
  triggerGroupColumns,
28
+ onExpandClick,
27
29
  ...rest
28
30
  } = props;
29
31
  const {
@@ -58,9 +60,16 @@ const Group = props => {
58
60
  newExpandedKeys = [...mergedExpandedKeys];
59
61
  } else {
60
62
  newExpandedKeys = [...mergedExpandedKeys, key];
63
+ // gọi sự kiện expand
64
+
65
+ onExpandClick?.({
66
+ expandedKeys: newExpandedKeys,
67
+ key: key,
68
+ rowData: record
69
+ });
61
70
  }
62
71
  setInnerExpandedKeys(newExpandedKeys);
63
- }, [getRowKey, mergedExpandedKeys, dataSource]);
72
+ }, [getRowKey, dataSource, mergedExpandedKeys, onExpandClick]);
64
73
  const handleExpandAllGroup = () => {
65
74
  setInnerExpandedKeys(findAllChildrenKeys(dataSource, getRowKey, childrenColumnName) ?? []);
66
75
  };
@@ -107,6 +116,7 @@ const Group = props => {
107
116
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
108
117
  t: t,
109
118
  id: id,
119
+ rowKey: rowKey,
110
120
  columns: columns,
111
121
  style: {
112
122
  ...style,
@@ -84,6 +84,9 @@ export type ToolbarClick = {
84
84
  item: any;
85
85
  column: any;
86
86
  };
87
+ export type LoadOptionsArgs = {
88
+ rowData?: any;
89
+ };
87
90
  export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>, 'headerTemplate' | 'title' | 'format' | 'commandItems'> & {
88
91
  field?: string;
89
92
  key?: any;
@@ -195,6 +198,12 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
195
198
  onCellClick?: (args: ICellClick, callback?: any) => void;
196
199
  rowEditable?: (rowData: RecordType) => boolean;
197
200
  validate?: any;
201
+ onBlur?: (data: RecordType[]) => void;
202
+ onExpandClick?: (args: {
203
+ expandedKeys: string[];
204
+ key: string;
205
+ rowData: any;
206
+ }) => void;
198
207
  }
199
208
  export type PaginationConfig = TablePaginationConfig & {
200
209
  currentPage?: number;
@@ -19,6 +19,7 @@ export interface IContext<RecordType> {
19
19
  getValues?: any;
20
20
  handleCellChange?: (args: ContextCellChange<RecordType>) => void;
21
21
  getRowKey?: GetRowKey<RecordType>;
22
+ id: string;
22
23
  }
23
24
  export type ContextCellChange<RecordType = AnyObject> = {
24
25
  key: string | keyof RecordType | GetRowKey<RecordType>;
@@ -3,5 +3,6 @@ import { createContext } from 'react';
3
3
  // import {AnyObject} from "antd/es/_util/type";
4
4
 
5
5
  export const TableContext = /*#__PURE__*/createContext({
6
- rowKey: 'id'
6
+ rowKey: 'rowId',
7
+ id: ''
7
8
  });
@@ -498,7 +498,7 @@ const ColumnsChoose = props => {
498
498
  autoExpandParent: autoExpandParent
499
499
  // treeData={treeData}
500
500
  ,
501
- treeData: columns,
501
+ treeData: columns.filter(it => !columnsGroup?.includes(it.field)),
502
502
  defaultExpandAll: true,
503
503
  checkable: true
504
504
  // onSelect={(keys, info) => {
@@ -63,7 +63,8 @@ const EditableCell = props => {
63
63
  getValues,
64
64
  handleCellChange,
65
65
  getRowKey,
66
- errors
66
+ errors,
67
+ id
67
68
  } = (0, _react.useContext)(_useContext.TableContext);
68
69
  const datePickerRef = _react.default.useRef(null);
69
70
  const dateTimePickerRef = _react.default.useRef(null);
@@ -162,7 +163,7 @@ const EditableCell = props => {
162
163
  popupClassName: 'be-popup-container',
163
164
  status: isInvalid ? 'error' : undefined,
164
165
  "data-tooltip-content": message,
165
- "data-tooltip-id": "tooltip-form-error"
166
+ "data-tooltip-id": `${id}-tooltip-form-error`
166
167
  });
167
168
  case 'datetime':
168
169
  return /*#__PURE__*/_react.default.createElement(_antd.DatePicker
@@ -218,7 +219,7 @@ const EditableCell = props => {
218
219
  popupClassName: 'be-popup-container',
219
220
  status: isInvalid ? 'error' : undefined,
220
221
  "data-tooltip-content": message,
221
- "data-tooltip-id": "tooltip-form-error"
222
+ "data-tooltip-id": `${id}-tooltip-form-error`
222
223
  });
223
224
  case 'month':
224
225
  case 'quarter':
@@ -244,7 +245,7 @@ const EditableCell = props => {
244
245
  popupClassName: 'be-popup-container',
245
246
  status: isInvalid ? 'error' : undefined,
246
247
  "data-tooltip-content": message,
247
- "data-tooltip-id": "tooltip-form-error"
248
+ "data-tooltip-id": `${id}-tooltip-form-error`
248
249
  });
249
250
  case 'week':
250
251
  const weekFormat = (0, _hooks.getDatepickerFormat)(editType, cellFormat);
@@ -264,7 +265,7 @@ const EditableCell = props => {
264
265
  popupClassName: 'be-popup-container',
265
266
  status: isInvalid ? 'error' : undefined,
266
267
  "data-tooltip-content": message,
267
- "data-tooltip-id": "tooltip-form-error"
268
+ "data-tooltip-id": `${id}-tooltip-form-error`
268
269
  });
269
270
  case 'time':
270
271
  const timeFormat = (0, _hooks.getDatepickerFormat)(editType, cellFormat);
@@ -291,7 +292,7 @@ const EditableCell = props => {
291
292
  popupClassName: 'be-popup-container',
292
293
  status: isInvalid ? 'error' : undefined,
293
294
  "data-tooltip-content": message,
294
- "data-tooltip-id": "tooltip-form-error"
295
+ "data-tooltip-id": `${id}-tooltip-form-error`
295
296
  });
296
297
  case 'selectTable':
297
298
  const rr = selectColumns ?? [];
@@ -329,6 +330,7 @@ const EditableCell = props => {
329
330
  options: options,
330
331
  defaultOptions: options,
331
332
  value: valueSelectTable,
333
+ rowData: record,
332
334
  onChange: (val, option) => {
333
335
  onChange(val ?? '');
334
336
  const formState = getValues();
@@ -398,7 +400,7 @@ const EditableCell = props => {
398
400
  label: inputKey ?? 'label'
399
401
  },
400
402
  "data-tooltip-content": message,
401
- "data-tooltip-id": "tooltip-form-error"
403
+ "data-tooltip-id": `${id}-tooltip-form-error`
402
404
  });
403
405
  case 'select':
404
406
  let valueSelect = value;
@@ -456,7 +458,7 @@ const EditableCell = props => {
456
458
  label: inputKey ?? 'label'
457
459
  },
458
460
  "data-tooltip-content": message,
459
- "data-tooltip-id": "tooltip-form-error"
461
+ "data-tooltip-id": `${id}-tooltip-form-error`
460
462
  });
461
463
  case 'asyncSelect':
462
464
  let valueAsyncSelect = value;
@@ -553,7 +555,7 @@ const EditableCell = props => {
553
555
  label: inputKey ?? 'label'
554
556
  },
555
557
  "data-tooltip-content": message,
556
- "data-tooltip-id": "tooltip-form-error"
558
+ "data-tooltip-id": `${id}-tooltip-form-error`
557
559
  });
558
560
  case 'treeSelect':
559
561
  // let valueTreeSelect
@@ -626,7 +628,7 @@ const EditableCell = props => {
626
628
  popupClassName: 'be-popup-container',
627
629
  status: isInvalid ? 'error' : undefined,
628
630
  "data-tooltip-content": message,
629
- "data-tooltip-id": "tooltip-form-error"
631
+ "data-tooltip-id": `${id}-tooltip-form-error`
630
632
  });
631
633
  case 'checkbox':
632
634
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -849,7 +851,7 @@ const EditableCell = props => {
849
851
  }
850
852
  },
851
853
  "data-tooltip-content": message,
852
- "data-tooltip-id": "tooltip-form-error"
854
+ "data-tooltip-id": `${id}-tooltip-form-error`
853
855
  }));
854
856
  default:
855
857
  return /*#__PURE__*/_react.default.createElement(_antd.Input, {
@@ -912,7 +914,7 @@ const EditableCell = props => {
912
914
  onChange: onChange,
913
915
  status: isInvalid ? 'error' : undefined,
914
916
  "data-tooltip-content": message,
915
- "data-tooltip-id": "tooltip-form-error"
917
+ "data-tooltip-id": `${id}-tooltip-form-error`
916
918
  });
917
919
  }
918
920
  };
@@ -9,4 +9,4 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
  const GridStyle = exports.GridStyle = _styledComponents.default.div.withConfig({
10
10
  displayName: "GridStyle",
11
11
  componentId: "es-grid-template__sc-sueu2e-0"
12
- })(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{&:has(.ui-rc-table-tbody-virtual-scrollbar-horizontal){padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined);
12
+ })(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{&:has(.ui-rc-table-tbody-virtual-scrollbar-horizontal){padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}.ui-rc-table-body{&:has(.ui-rc-table-placeholder){height:", ";}table{height:100%;.ui-rc-table-placeholder{vertical-align:top;}}}.ui-rc-table-placeholder{}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll - 1}px` : undefined);