es-grid-template 1.9.61 → 1.9.63

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 (34) hide show
  1. package/es/ali-table/Grid.js +1 -1
  2. package/es/ali-table/InternalTable.d.ts +2 -1
  3. package/es/ali-table/InternalTable.js +24 -43
  4. package/es/ali-table/base-table/styles.js +1 -1
  5. package/es/ali-table/base-table/table.d.ts +2 -2
  6. package/es/ali-table/base-table/utils.d.ts +2 -0
  7. package/es/ali-table/base-table/utils.js +12 -1
  8. package/es/ali-table/interfaces.d.ts +4 -0
  9. package/es/ali-table/internals.d.ts +2 -1
  10. package/es/ali-table/pipeline/features/columnCustom.d.ts +2 -0
  11. package/es/ali-table/pipeline/features/columnCustom.js +310 -24
  12. package/es/ali-table/utils/utility.d.ts +1 -0
  13. package/es/ali-table/utils/utility.js +43 -1
  14. package/es/grid-component/type.d.ts +2 -1
  15. package/es/group-component/hook/utils.d.ts +3 -3
  16. package/es/table-component/components/async-select/index.js +1 -1
  17. package/es/table-component/hook/utils.d.ts +1 -3
  18. package/lib/ali-table/Grid.js +1 -1
  19. package/lib/ali-table/InternalTable.d.ts +2 -1
  20. package/lib/ali-table/InternalTable.js +24 -43
  21. package/lib/ali-table/base-table/styles.js +1 -1
  22. package/lib/ali-table/base-table/table.d.ts +2 -2
  23. package/lib/ali-table/base-table/utils.d.ts +2 -0
  24. package/lib/ali-table/base-table/utils.js +13 -0
  25. package/lib/ali-table/interfaces.d.ts +4 -0
  26. package/lib/ali-table/internals.d.ts +2 -1
  27. package/lib/ali-table/pipeline/features/columnCustom.d.ts +2 -0
  28. package/lib/ali-table/pipeline/features/columnCustom.js +310 -24
  29. package/lib/ali-table/utils/utility.d.ts +1 -0
  30. package/lib/ali-table/utils/utility.js +45 -1
  31. package/lib/grid-component/type.d.ts +2 -1
  32. package/lib/table-component/components/async-select/index.js +1 -1
  33. package/lib/table-component/hook/utils.d.ts +1 -3
  34. package/package.json +1 -1
@@ -16,6 +16,7 @@ import HeaderEditCell from "../../base-table/cell/HeaderEditCell";
16
16
  import { stateKeyResize, stateKeyColumnFilter, stateKeyFilter, stateKeyPagination, stateKeySorter, stateKeyTooltip, stateKeyTypePaste, stateKeyVisible,
17
17
  // state For edit
18
18
  stateKeyEndCell, stateKeyEndPasteCell, stateKeyStartCell, stateKeyStartPasteCell, stateKeyFocusedCell, stateKeyIsEditing, stateKeyIsPasting, stateKeyIsSelecting } from "../../utils/constants";
19
+ import { getColumnsAtLevel } from "../../base-table/utils";
19
20
  // import { getMaxDepth } from '../../utils/utility';
20
21
 
21
22
  function clamp(min, x, max) {
@@ -59,7 +60,9 @@ export function columnCustom(opts) {
59
60
  onSubmit,
60
61
  handleCellChange,
61
62
  handleHeaderCellChange,
62
- dataErrors
63
+ dataErrors,
64
+ headerData,
65
+ headerEditAble
63
66
  // originData
64
67
 
65
68
  // currentPage = 1,
@@ -87,8 +90,7 @@ export function columnCustom(opts) {
87
90
  const allRows = pipeline.getDataSource(); // flat data
88
91
 
89
92
  const leafColumns = collectNodes(pipeline.getColumns(), 'leaf-only');
90
- // const originCols = pipeline.getColumns()
91
-
93
+ const originCols = pipeline.getColumns();
92
94
  const rowIds = getKeys(allRows, 'rowId');
93
95
  const colIds = getKeys(leafColumns, 'field');
94
96
  const rowIndexMap = getRowIndexMap(allRows);
@@ -292,7 +294,7 @@ export function columnCustom(opts) {
292
294
 
293
295
  // Chức năng edit
294
296
 
295
- const handleEdit = (e, record, col, editType, isKeyDown) => {
297
+ const handleEdit = (e, record, col, editType, isKeyDown, isHeader) => {
296
298
  pipeline.setStateAtKey(stateKeyIsEditing, true);
297
299
  reset?.();
298
300
  if (!isObjEmpty(record)) {
@@ -314,6 +316,15 @@ export function columnCustom(opts) {
314
316
  }
315
317
  }, 10);
316
318
  }
319
+ if (focusedCell?.rowId && isHeader) {
320
+ setTimeout(() => {
321
+ const textarea = document.querySelector(`.ui-rc-grid-table-header-row .header-cell-editable[data-col-key="${focusedCell.colId}"] textarea`);
322
+ if (textarea) {
323
+ textarea.focus();
324
+ textarea.setSelectionRange(textarea.value.length, textarea.value.length);
325
+ }
326
+ }, 10);
327
+ }
317
328
  };
318
329
  const triggerDragPaste = (pasteState, ctrlKey) => {
319
330
  const tmpCols = [...leafColumns];
@@ -438,7 +449,7 @@ export function columnCustom(opts) {
438
449
  pastedRows.push(newData[targetRow]);
439
450
  });
440
451
  }
441
- const rsFilterData = updateOrInsert(flattenArray([...dataSource]), newData);
452
+ const rsFilterData = updateOrInsert(flattenArray(dataSource), newData);
442
453
  const rs = unFlattenData(rsFilterData);
443
454
  triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
444
455
  pipeline.setStateAtKey(stateKeyEndCell, endPasteCell);
@@ -497,7 +508,7 @@ export function columnCustom(opts) {
497
508
  // Lưu dòng được paste
498
509
  pastedRows.push(newData[targetRow]);
499
510
  });
500
- const rsFilterData = updateOrInsert(flattenArray([...dataSource]), newData);
511
+ const rsFilterData = updateOrInsert(flattenArray(dataSource), newData);
501
512
  const rs = unFlattenData(rsFilterData);
502
513
  triggerPaste?.(pastedRows, colPasteds, rs, copyRows);
503
514
  };
@@ -769,7 +780,7 @@ export function columnCustom(opts) {
769
780
  if (e.key === 'Enter') {
770
781
  e.preventDefault();
771
782
  e.stopPropagation();
772
- handleEdit(e, record, column, editType);
783
+ handleEdit(e, record, column, editType, false);
773
784
  return;
774
785
  }
775
786
  if (e.key.length === 1 && !e.ctrlKey) {
@@ -778,6 +789,168 @@ export function columnCustom(opts) {
778
789
  handleEdit(e, record, column, editType, true);
779
790
  }
780
791
  };
792
+ const handleHeaderKeyDown = (e, rowId, colId, rowIndex, column, record, editType) => {
793
+ if (e.key === 'Tab') {
794
+ const currentHeaderRowCols = getColumnsAtLevel(originCols, rowIndex);
795
+ const currentHeaderRowColsEditAble = currentHeaderRowCols ? currentHeaderRowCols.filter(it => it.headerEditEnable) : undefined;
796
+ const nextCol = currentHeaderRowColsEditAble ? getNextColumn(currentHeaderRowColsEditAble, focusedCell.colId) : undefined;
797
+ const nextHeaderRowCols = getColumnsAtLevel(originCols, rowIndex + 1);
798
+ const nextHeaderRowColsEditAble = nextHeaderRowCols ? nextHeaderRowCols.filter(it => it.headerEditEnable) : undefined;
799
+ const nextRow = nextHeaderRowColsEditAble ? nextHeaderRowColsEditAble : undefined;
800
+ const checkEnd = nextCol && currentHeaderRowColsEditAble ? getNextColumn1(currentHeaderRowColsEditAble, nextCol.column.field) : undefined;
801
+ if (!checkEnd) {
802
+ e.preventDefault();
803
+ e.stopPropagation();
804
+ }
805
+ if (nextCol?.column && !nextCol.isWrapped) {
806
+ const nextCellPosition = {
807
+ rowId,
808
+ colId: nextCol.column.field
809
+ };
810
+ pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
811
+ pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
812
+ pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
813
+ } else {
814
+ // Nếu là cột cuối cùng, có thể nhảy xuống dòng tiếp theo
815
+
816
+ // const currentRowIndex = allRows.findIndex(r => r.rowId === rowId);
817
+ // const nextRow = allRows[currentRowIndex + 1];
818
+
819
+ const firstCol = nextRow?.[0];
820
+ if (nextRow && firstCol) {
821
+ const nextRowId = `header-field-${rowIndex + 1}`;
822
+ const nextCellPosition = {
823
+ rowId: nextRowId,
824
+ colId: firstCol.field
825
+ };
826
+ pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
827
+ pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
828
+ pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
829
+ if (tableRef) {
830
+ // tableRef?.current?.artTableWrapperRef?.current?.scrollLeft = 0
831
+
832
+ // const wrapper = tableRef.current?.artTableWrapperRef?.current;
833
+ const wrapper = tableRef.current?.domHelper?.stickyScroll;
834
+ if (!wrapper) return;
835
+ wrapper.scrollLeft = 0;
836
+ }
837
+ } else {
838
+ e.preventDefault();
839
+ e.stopPropagation();
840
+ }
841
+ }
842
+ return;
843
+ }
844
+
845
+ // if (e.key === 'ArrowRight') {
846
+
847
+ // // e.preventDefault();
848
+ // // e.stopPropagation()
849
+
850
+ // const nextCol = getNextColumn(leafColumns, column.field)
851
+
852
+ // if (nextCol.column && !nextCol.isWrapped) {
853
+
854
+ // const nextCellPosition = { rowId, colId: nextCol.column.field }
855
+
856
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
857
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
858
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
859
+
860
+ // }
861
+
862
+ // return
863
+ // }
864
+
865
+ // if (e.key === 'ArrowLeft') {
866
+
867
+ // // e.preventDefault()
868
+ // // e.stopPropagation()
869
+
870
+ // const prevCol = getPrevColumn(leafColumns, column.field)
871
+
872
+ // if (prevCol) {
873
+
874
+ // const nextCellPosition = { rowId, colId: prevCol.field }
875
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
876
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
877
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
878
+
879
+ // }
880
+ // return
881
+ // }
882
+
883
+ // if (e.key === 'ArrowDown') {
884
+
885
+ // // e.preventDefault()
886
+ // // e.stopPropagation()
887
+
888
+ // const nextRow = allRows[rowIndex + 1]
889
+
890
+ // if (nextRow) {
891
+ // const nextRowId = nextRow.rowId
892
+
893
+ // const nextCellPosition = { rowId: nextRowId, colId }
894
+ // // setFocusedCell?.({ rowId: nextRowId, colId });
895
+ // // setStartCell?.({ rowId: nextRowId, colId });
896
+ // // setEndCell?.({ rowId: nextRowId, colId });
897
+
898
+ // // setRangeState?.(getSelectedCellMatrix(table, { rowId: nextRowId, colId }, { rowId: nextRowId, colId }))
899
+
900
+ // // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
901
+ // // rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
902
+
903
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
904
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
905
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
906
+
907
+ // // const rowElement: any = document.querySelector(`.ui-rc-grid-table-row[data-row-key="${nextRowId}"]`)
908
+
909
+ // // const cellFocus = rowElement?.querySelector('.ui-rc-grid-cell')
910
+
911
+ // }
912
+
913
+ // return
914
+ // }
915
+
916
+ // if (e.key === 'ArrowUp') {
917
+
918
+ // // e.preventDefault()
919
+ // // e.stopPropagation()
920
+
921
+ // const nextRow = allRows[rowIndex - 1]
922
+
923
+ // if (nextRow) {
924
+ // const nextRowId = nextRow.rowId
925
+
926
+ // const nextCellPosition = { rowId: nextRowId, colId }
927
+
928
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
929
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
930
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
931
+
932
+ // }
933
+
934
+ // return
935
+ // }
936
+
937
+ // if (e.key === 'Delete') {
938
+ // handleDeleteContent?.()
939
+ // return
940
+ // }
941
+
942
+ if (e.key === 'Enter') {
943
+ e.preventDefault();
944
+ e.stopPropagation();
945
+ handleEdit(e, record, column, editType, false, true);
946
+ return;
947
+ }
948
+ if (e.key.length === 1 && !e.ctrlKey) {
949
+ e.preventDefault();
950
+ e.stopPropagation();
951
+ handleEdit(e, record, column, editType, true, true);
952
+ }
953
+ };
781
954
  const handleChange = (record, column, indexCol) => {
782
955
  const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
783
956
  const formState = getValues();
@@ -798,6 +971,26 @@ export function columnCustom(opts) {
798
971
  });
799
972
  } else {}
800
973
  };
974
+ const handleHeaderChange = (record, column, indexCol) => {
975
+ const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
976
+ const formState = getValues();
977
+ const itemState = getValues(column.field);
978
+ const prevState = record[column.field];
979
+ const newState = itemState;
980
+ if (newState !== prevState) {
981
+ handleHeaderCellChange?.({
982
+ key: record.rowId,
983
+ field: column.field,
984
+ record: formState,
985
+ prevState,
986
+ newState,
987
+ option: newState,
988
+ indexCol: indexCol,
989
+ indexRow: currentRowIndex,
990
+ type: 'blur'
991
+ });
992
+ } else {}
993
+ };
801
994
  const handlePointDoubleClick = (e, column, record) => {
802
995
  e.preventDefault();
803
996
  e.stopPropagation();
@@ -1042,15 +1235,19 @@ export function columnCustom(opts) {
1042
1235
  const htmlTooltip = headerCustomTooltip;
1043
1236
  const headerEditType = col.headerEditType;
1044
1237
  const headerRowIndex = params.path.findIndex(it => it.field === col.field);
1045
- const tmpValue = allRows.length > 0 ? allRows[0][col.field] : undefined;
1238
+ const headerRowId = `header-field-${headerRowIndex}`;
1239
+
1240
+ // const headerRecord: any = { ...col, rowId: `field-${headerRowIndex}`, [col.field]: tmpValue, children: undefined }
1241
+
1046
1242
  const headerRecord = {
1047
- ...col,
1048
- rowId: `field-${headerRowIndex}`,
1049
- [col.field]: tmpValue,
1050
- children: undefined
1243
+ [col.field]: headerData?.[col.field] ?? ''
1051
1244
  };
1052
- const cellHeaderEditing = isEditing && headerRecord.rowId === focusedCell.rowId && col.field === focusedCell.colId;
1053
- const isCellSelect = startCell?.rowId === headerRecord.rowId && startCell?.colId === col.field;
1245
+ const headerValue = headerData?.[col.field] ?? '';
1246
+ const cellHeaderEditing = isEditing && headerRowId === focusedCell.rowId && col.field === focusedCell.colId;
1247
+ const isCellSelect = headerRowId === focusedCell.rowId && startCell?.colId === col.field;
1248
+ const aa = getColumnsAtLevel(originCols, headerRowIndex);
1249
+ const aaEditAble = aa ? aa.filter(it => it.headerEditEnable) : undefined;
1250
+ const nextHeaderCol = aaEditAble ? getNextColumn(aaEditAble, focusedCell.colId) : undefined;
1054
1251
 
1055
1252
  // Cell thường có thể filter và sort được
1056
1253
  return {
@@ -1073,7 +1270,7 @@ export function columnCustom(opts) {
1073
1270
  [`${prefix}-grid-cell-text-center`]: (col?.headerTextAlign ?? col?.textAlign) === 'center',
1074
1271
  [`${prefix}-grid-cell-text-right`]: (col?.headerTextAlign ?? col.textAlign) === 'right'
1075
1272
  })
1076
- }, col.headerEditEnable && cellHeaderEditing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HeaderEditCell, {
1273
+ }, headerEditAble && col.headerEditEnable && cellHeaderEditing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HeaderEditCell, {
1077
1274
  column: col,
1078
1275
  editType: headerEditType ?? 'text',
1079
1276
  record: headerRecord,
@@ -1097,7 +1294,7 @@ export function columnCustom(opts) {
1097
1294
  startCell: startCell,
1098
1295
  handleSubmit: handleSubmit,
1099
1296
  onSubmit: onSubmit
1100
- })) : col.headerEditEnable ? /*#__PURE__*/React.createElement(React.Fragment, null, tmpValue) : col.headerTemplate ? /*#__PURE__*/React.createElement(React.Fragment, null, typeof col.headerTemplate === 'function' ? col.headerTemplate(col) : col.headerTemplate) : /*#__PURE__*/React.createElement(React.Fragment, null, prevTitle))), !col.headerEditEnable && (!nonActionColumn.includes(col.field) && !col?.children || col?.children && col?.children.length < 1) && /*#__PURE__*/React.createElement("span", {
1297
+ })) : headerEditAble && col.headerEditEnable ? /*#__PURE__*/React.createElement(React.Fragment, null, headerValue) : col.headerTemplate ? /*#__PURE__*/React.createElement(React.Fragment, null, typeof col.headerTemplate === 'function' ? col.headerTemplate(col) : col.headerTemplate) : /*#__PURE__*/React.createElement(React.Fragment, null, prevTitle))), !col.headerEditEnable && (!nonActionColumn.includes(col.field) && !col?.children || col?.children && col?.children.length < 1) && /*#__PURE__*/React.createElement("span", {
1101
1298
  className: "ui-rc-header-trigger d-flex gap-50"
1102
1299
  }, canSort && /*#__PURE__*/React.createElement("div", {
1103
1300
  style: {
@@ -1148,9 +1345,20 @@ export function columnCustom(opts) {
1148
1345
  headerCellProps: mergeCellProps(col.headerCellProps ?? {}, {
1149
1346
  'data-tooltip-id': `${id}-tooltip-content`,
1150
1347
  'data-tooltip-content': htmlTooltip,
1348
+ // @ts-ignore
1349
+ 'data-col-key': col.field,
1350
+ ref: el => {
1351
+ if (focusedCell?.rowId === headerRowId && focusedCell?.colId === col.field && !isEditing) {
1352
+ el?.focus({
1353
+ preventScroll: true
1354
+ });
1355
+ }
1356
+ },
1357
+ tabIndex: focusedCell?.rowId === headerRowId && focusedCell?.colId === col.field ? 1 : col.field === nextHeaderCol?.column?.field ? 1 : -1,
1151
1358
  style: {
1152
1359
  overflow: 'visible',
1153
1360
  position: 'relative',
1361
+ outline: 'none',
1154
1362
  padding: cellHeaderEditing ? 0 : undefined
1155
1363
  },
1156
1364
  className: classNames('', {
@@ -1163,19 +1371,97 @@ export function columnCustom(opts) {
1163
1371
  }),
1164
1372
  onMouseDown: () => {
1165
1373
  if (col.headerEditEnable) {
1166
- handleMouseDown(headerRecord.rowId, col.field);
1374
+ handleMouseDown(headerRowId, col.field);
1167
1375
  }
1168
1376
  },
1169
1377
  onDoubleClick: e => {
1170
1378
  // prevCellProps?.onDoubleClick?.(e)
1171
1379
 
1172
- if (!col.headerEditEnable) {
1173
- e.stopPropagation();
1174
- e.preventDefault();
1175
- return;
1380
+ if (headerEditAble) {
1381
+ if (!col.headerEditEnable) {
1382
+ e.stopPropagation();
1383
+ e.preventDefault();
1384
+ return;
1385
+ }
1386
+ if (headerRowId === focusedCell.rowId && col.field === focusedCell.colId && col.headerEditEnable) {
1387
+ handleEdit(e, headerRecord, col, headerEditType ?? 'text', false, true);
1388
+ }
1176
1389
  }
1177
- if (headerRecord.rowId === focusedCell.rowId && col.field === focusedCell.colId && col.headerEditEnable) {
1178
- handleEdit(e, headerRecord, col, headerEditType ?? 'text');
1390
+ },
1391
+ onKeyDown: e => {
1392
+ // prevCellProps?.onKeyDown?.(e)
1393
+ // chưa editing
1394
+
1395
+ if (headerEditAble) {
1396
+ if (!isEditing) {
1397
+ handleHeaderKeyDown(e, headerRowId, col.field, headerRowIndex, col, headerRecord, headerEditType ?? 'text');
1398
+ } else {
1399
+ if (e.shiftKey && e.key === 'Enter') {
1400
+ e.preventDefault();
1401
+ e.stopPropagation();
1402
+ } else {
1403
+ if (e.key === 'Enter') {
1404
+ e.preventDefault();
1405
+ e.stopPropagation();
1406
+
1407
+ // const currentRowIndex = allRows.findIndex(r => r.rowId === headerRowId);
1408
+ // const nextRow = allRows[currentRowIndex + 1];
1409
+
1410
+ // if (nextRow) {
1411
+ // const nextCellPosition = { rowId: nextRow.rowId, colId: col.field }
1412
+
1413
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
1414
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
1415
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
1416
+
1417
+ handleHeaderChange(headerRecord, col, startIndex);
1418
+ pipeline.setStateAtKey(stateKeyIsEditing, false);
1419
+
1420
+ // }
1421
+ }
1422
+ if (e.key === 'Tab') {
1423
+ e.preventDefault();
1424
+
1425
+ // const nextCol = getNextColumn(allCols, col.field)
1426
+
1427
+ if (nextHeaderCol?.column?.field && !nextHeaderCol?.isWrapped) {
1428
+ const nextCellPosition = {
1429
+ rowId: headerRowId,
1430
+ colId: nextHeaderCol.column.field
1431
+ };
1432
+ pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
1433
+ pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
1434
+ pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
1435
+
1436
+ // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
1437
+ } else {
1438
+ // Nếu là cột cuối cùng, có thể nhảy xuống dòng tiếp theo
1439
+
1440
+ // const currentRowIndex = allRows.findIndex(r => r.rowId === headerRowId);
1441
+ // const nextRow = allRows[currentRowIndex + 1];
1442
+
1443
+ // const firstCol = nextCol.column
1444
+
1445
+ // if (nextRow) {
1446
+
1447
+ // const nextCellPosition = { rowId: nextRow.rowId, colId: firstCol.field }
1448
+
1449
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
1450
+
1451
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
1452
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
1453
+
1454
+ // // columnVirtualizer.scrollToIndex(nextRowCol.getIndex())
1455
+
1456
+ // // rowVirtualizer.scrollToIndex(nextRow.index, { align: 'auto' })
1457
+
1458
+ // }
1459
+ }
1460
+ handleHeaderChange(headerRecord, col, startIndex);
1461
+ pipeline.setStateAtKey(stateKeyIsEditing, false);
1462
+ }
1463
+ }
1464
+ }
1179
1465
  }
1180
1466
  }
1181
1467
  }),
@@ -1330,7 +1616,7 @@ export function columnCustom(opts) {
1330
1616
  return;
1331
1617
  }
1332
1618
  if (record.rowId === focusedCell.rowId && col.field === focusedCell.colId && canEdit) {
1333
- handleEdit(e, record, col, editType ?? 'text');
1619
+ handleEdit(e, record, col, editType ?? 'text', false);
1334
1620
  }
1335
1621
  },
1336
1622
  onKeyDown: e => {
@@ -9,4 +9,5 @@ export declare function sortData1(data: any[], sorter: Sorter[]): any[];
9
9
  export declare function sortData(data: any[], sorter: Sorter[]): any[];
10
10
  export declare function filterDataByColumns1(data: any[], queries: FilterItem[] | undefined, sorter: Sorter[] | undefined, keysFilter: string[] | undefined, ignoreAccents?: boolean): any[];
11
11
  export declare const getMaxDepth: (data: any[]) => number;
12
+ export declare const addRowIdArray: (inputArray: any[]) => any[];
12
13
  export {};
@@ -1,4 +1,4 @@
1
- import { compareDates, compareValues, convertFomatedDateToDate, getSortValue, isDate, isDateString, isDateValue, parseToDate, removeVietnameseTones } from "../../table-component/hook/utils";
1
+ import { compareDates, compareValues, convertFomatedDateToDate, getSortValue, isDate, isDateString, isDateValue, newGuid, parseToDate, removeVietnameseTones } from "../../table-component/hook/utils";
2
2
  const prepareFilters = (queries, ignoreAccents = true) => {
3
3
  return queries.map(query => {
4
4
  const {
@@ -252,4 +252,46 @@ export const getMaxDepth = data => {
252
252
  }
253
253
  }
254
254
  return maxDepth;
255
+ };
256
+ export const addRowIdArray = inputArray => {
257
+ if (!inputArray || inputArray.length === 0) return [];
258
+ const result = new Array(inputArray.length);
259
+ const pending = [];
260
+ for (let index = inputArray.length - 1; index >= 0; index -= 1) {
261
+ pending.push({
262
+ source: inputArray[index],
263
+ target: result,
264
+ index
265
+ });
266
+ }
267
+ while (pending.length > 0) {
268
+ const {
269
+ source,
270
+ target,
271
+ index,
272
+ parentId
273
+ } = pending.pop();
274
+ const rowId = source.id ?? source.rowId ?? newGuid();
275
+ const node = {
276
+ ...source,
277
+ rowId,
278
+ ...(parentId !== undefined && source.parentId == null ? {
279
+ parentId
280
+ } : {})
281
+ };
282
+ target[index] = node;
283
+ if (Array.isArray(source.children) && source.children.length > 0) {
284
+ const children = new Array(source.children.length);
285
+ node.children = children;
286
+ for (let childIndex = source.children.length - 1; childIndex >= 0; childIndex -= 1) {
287
+ pending.push({
288
+ source: source.children[childIndex],
289
+ target: children,
290
+ index: childIndex,
291
+ parentId: rowId
292
+ });
293
+ }
294
+ }
295
+ }
296
+ return result;
255
297
  };
@@ -478,6 +478,7 @@ export type TableProps<RecordType = AnyObject> = {
478
478
  showEmptyText?: boolean;
479
479
  /** Cấu hình command column */
480
480
  commandSettings?: CommandSettings;
481
+ headerData?: object;
481
482
  /**
482
483
  * Func khi click command
483
484
  * Ví dụ: Edit, Delete, Copy...
@@ -525,7 +526,7 @@ export type TableProps<RecordType = AnyObject> = {
525
526
  * handleCallback dùng để cập nhật giá trị sau khi xử lý custom
526
527
  */
527
528
  onCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
528
- onHeaderCellChange?: (args: CellChangeArgs<RecordType>, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
529
+ onHeaderCellChange?: (data: object) => void;
529
530
  /** Callback click cell */
530
531
  onCellClick?: (args: ICellClick, callback?: any) => void;
531
532
  /** Xác định row có được edit hay không */
@@ -196,10 +196,10 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
196
196
  value: any;
197
197
  rowData: RecordType;
198
198
  }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNode);
199
- onCellStyles?: Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position">);
200
- onCellHeaderStyles?: Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position">);
199
+ onCellStyles?: Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width">);
200
+ onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width">);
201
201
  onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
202
- onCellFooterStyles?: Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "left" | "right" | "display" | "minWidth" | "position">);
202
+ onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "position" | "display" | "minWidth" | "width">);
203
203
  getValue?: (row: any, rowIndex: number) => any;
204
204
  getCellProps?: (value: any, row: any, rowIndex: number) => import("./../../grid-component/type").CellProps;
205
205
  headerCellProps?: import("./../../grid-component/type").CellProps;
@@ -25,7 +25,7 @@ export function AsyncSelect({
25
25
  }
26
26
  };
27
27
  return debounce(fetchOptions, debounceTimeout);
28
- }, [loadOptions, debounceTimeout]);
28
+ }, [debounceTimeout, loadOptions, defaultOptions, rowData]);
29
29
  useEffect(() => {
30
30
  setOptions(defaultOptions ?? []);
31
31
  }, [defaultOptions]);
@@ -199,7 +199,5 @@ export declare const getIds: <T extends {
199
199
  }>(data: T[]) => string[];
200
200
  export declare const getKeys: <T extends Record<string, any>, K extends keyof T>(data: T[], key: K) => T[K][];
201
201
  export declare const getRowIndexMap: (flatRows: any[]) => Map<string, number>;
202
- export declare function getRowIdsBetween3(flatRows: {
203
- rowId: string;
204
- }[], rowIndexMap: Map<string, number>, a: string, b: string): string[];
202
+ export declare function getRowIdsBetween3(flatRows: any[], rowIndexMap: Map<string, number>, a: string, b: string): string[];
205
203
  export {};
@@ -378,7 +378,7 @@ const Grid = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
378
378
  theme: theme,
379
379
  dataRowIds: dataRowIds,
380
380
  footerDataSource: footerDataSource
381
- })), (bottom || pagination && !infiniteScroll) && /*#__PURE__*/_react.default.createElement("div", {
381
+ })), (bottom || toolbarItemsBottom && toolbarItemsBottom.length > 0 || pagination && !infiniteScroll) && /*#__PURE__*/_react.default.createElement("div", {
382
382
  className: (0, _classnames.default)(`${prefix}-grid-bottom`, {})
383
383
  }, bottom, toolbarItemsBottom && toolbarItemsBottom.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
384
384
  className: (0, _classnames.default)('ui-rc-toolbar-bottom', {
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import './base-table/styles.scss';
3
3
  import type { TableProps } from "../grid-component/type";
4
- declare const InternalTable: <RecordType extends object>(props: TableProps<RecordType>) => JSX.Element;
4
+ import type { BaseRecord } from "./interfaces";
5
+ declare const InternalTable: <RecordType extends BaseRecord>(props: TableProps<RecordType>) => JSX.Element;
5
6
  export default InternalTable;