es-grid-template 1.9.60 → 1.9.62

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 (31) hide show
  1. package/es/ali-table/InternalTable.d.ts +2 -1
  2. package/es/ali-table/InternalTable.js +23 -43
  3. package/es/ali-table/base-table/table.d.ts +2 -2
  4. package/es/ali-table/base-table/utils.d.ts +2 -0
  5. package/es/ali-table/base-table/utils.js +12 -1
  6. package/es/ali-table/interfaces.d.ts +4 -0
  7. package/es/ali-table/internals.d.ts +2 -1
  8. package/es/ali-table/pipeline/features/columnCustom.d.ts +1 -0
  9. package/es/ali-table/pipeline/features/columnCustom.js +297 -17
  10. package/es/grid-component/type.d.ts +2 -1
  11. package/es/group-component/body/EditableCell.d.ts +3 -0
  12. package/es/group-component/body/EditableCell.js +402 -196
  13. package/es/table-component/body/EditableCell.js +1 -1
  14. package/es/table-component/components/async-select/index.js +1 -1
  15. package/es/table-component/hook/utils.d.ts +1 -3
  16. package/lib/ali-table/InternalTable.d.ts +2 -1
  17. package/lib/ali-table/InternalTable.js +23 -43
  18. package/lib/ali-table/base-table/table.d.ts +2 -2
  19. package/lib/ali-table/base-table/utils.d.ts +2 -0
  20. package/lib/ali-table/base-table/utils.js +13 -0
  21. package/lib/ali-table/interfaces.d.ts +4 -0
  22. package/lib/ali-table/internals.d.ts +2 -1
  23. package/lib/ali-table/pipeline/features/columnCustom.d.ts +1 -0
  24. package/lib/ali-table/pipeline/features/columnCustom.js +297 -17
  25. package/lib/grid-component/type.d.ts +2 -1
  26. package/lib/group-component/body/EditableCell.d.ts +3 -0
  27. package/lib/group-component/body/EditableCell.js +399 -194
  28. package/lib/table-component/body/EditableCell.js +1 -1
  29. package/lib/table-component/components/async-select/index.js +1 -1
  30. package/lib/table-component/hook/utils.d.ts +1 -3
  31. package/package.json +1 -1
@@ -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;
@@ -68,6 +68,7 @@ const InternalTable = props => {
68
68
  toolbarItems,
69
69
  defaultValue,
70
70
  commandSettings,
71
+ headerData,
71
72
  ...rest
72
73
  } = props;
73
74
  const tableRef = useRef(null);
@@ -314,51 +315,29 @@ const InternalTable = props => {
314
315
  type: changeType,
315
316
  newState,
316
317
  prevState,
317
- option,
318
- field,
319
- indexCol,
320
- indexRow,
321
- key
318
+ field
322
319
  } = args;
323
320
  if (changeType === 'blur') {
324
- const handleChangeCallback = callbackData => {
325
- const callbackRecord = callbackData;
326
- Object.entries(callbackRecord).forEach(([name, value]) => {
327
- setValue(name, value);
328
- });
329
- onSubmit(callbackRecord);
330
- };
331
- if (onHeaderCellChange) {
332
- if (onHeaderCellChange.length > 1) {
333
- onHeaderCellChange({
334
- field,
335
- indexCol,
336
- type: 'onChange',
337
- value: newState,
338
- option,
339
- indexRow,
340
- rowData: record,
341
- rowId: key,
342
- // rowsData: [...dataSource],
343
- rowsData: [...convertData],
344
- sumValue: []
345
- }, handleChangeCallback);
346
- } else {
347
- onHeaderCellChange({
348
- field,
349
- indexCol,
350
- type: 'onChange',
351
- option,
352
- value: newState,
353
- indexRow,
354
- rowData: record,
355
- rowId: key,
356
- rowsData: [...convertData],
357
- sumValue: []
358
- }, handleChangeCallback);
321
+ // const handleChangeCallback = (callbackData: RecordType[]) => {
322
+ // const callbackRecord = callbackData
359
323
 
360
- // onSubmit(record)
361
- }
324
+ // Object.entries(callbackRecord).forEach(
325
+ // ([name, value]: any) => {
326
+ // setValue(name, value)
327
+
328
+ // }
329
+ // )
330
+
331
+ // onSubmit(callbackRecord)
332
+
333
+ // }
334
+
335
+ if (onHeaderCellChange) {
336
+ const newObj = {
337
+ ...headerData,
338
+ [field]: newState
339
+ };
340
+ onHeaderCellChange(newObj);
362
341
  }
363
342
  }
364
343
  if (prevState && newState && prevState !== newState && changeType === 'enter') {
@@ -465,7 +444,8 @@ const InternalTable = props => {
465
444
  onSubmit,
466
445
  triggerPaste,
467
446
  handleCellChange,
468
- handleHeaderCellChange
447
+ handleHeaderCellChange,
448
+ headerData
469
449
  })).use(features.paginationFeature({
470
450
  pagination
471
451
  }));
@@ -6,8 +6,8 @@ import { TableDOMHelper } from './helpers/TableDOMUtils';
6
6
  import type { ResolvedUseVirtual, VerticalRenderRange, VirtualEnum } from './interfaces';
7
7
  import type { LoadingContentWrapperProps } from './loading';
8
8
  import type { BaseTableCSSVariables } from './styles';
9
- import type { CommandClick, ExpandedRowRender, IFormat, IFTheme, RenderExpandIcon, RowClassName } from '../../grid-component/type';
10
- export type PrimaryKey = string | ((row: any) => string);
9
+ import type { AnyObject, CommandClick, ExpandedRowRender, IFormat, IFTheme, RenderExpandIcon, RowClassName } from '../../grid-component/type';
10
+ export type PrimaryKey<RecordType = AnyObject> = keyof RecordType | ((row: RecordType) => keyof RecordType);
11
11
  export type ColumnResizeMode = 'onChange' | 'onEnd';
12
12
  export type ExpandableConfig<RecordType> = {
13
13
  expandedRowKeys?: readonly Key[];
@@ -1,4 +1,5 @@
1
1
  import { Subscription } from 'rxjs';
2
+ import { ColumnTable } from '../../grid-component';
2
3
  /** styled-components 类库的版本,ali-react-table 同时支持 v3 和 v5 */
3
4
  export declare const STYLED_VERSION: string;
4
5
  export declare const STYLED_REF_PROP: string;
@@ -19,3 +20,4 @@ export declare function syncScrollLeft(elements: HTMLElement[], callback: (scrol
19
20
  */
20
21
  export declare function shallowEqual<T>(objA: T, objB: T): boolean;
21
22
  export declare function getParentElement(element: any, selector: any): any;
23
+ export declare function getColumnsAtLevel(columns: ColumnTable[], level: number): ColumnTable[];
@@ -1,7 +1,6 @@
1
1
  import { asyncScheduler, BehaviorSubject, defer, fromEvent, Subscription } from 'rxjs';
2
2
  import { map, throttleTime } from 'rxjs/operators';
3
3
  import * as styledComponents from 'styled-components';
4
-
5
4
  /** styled-components 类库的版本,ali-react-table 同时支持 v3 和 v5 */
6
5
  export const STYLED_VERSION = styledComponents.createGlobalStyle != null ? 'v5' : 'v3';
7
6
  export const STYLED_REF_PROP = STYLED_VERSION === 'v3' ? 'innerRef' : 'ref';
@@ -151,4 +150,16 @@ export function getParentElement(element, selector) {
151
150
  }
152
151
  }
153
152
  return getParent(element, selector);
153
+ }
154
+ export function getColumnsAtLevel(columns, level) {
155
+ if (level === 0) {
156
+ return columns;
157
+ }
158
+ const result = [];
159
+ for (const column of columns) {
160
+ if (column.children?.length) {
161
+ result.push(...getColumnsAtLevel(column.children, level - 1));
162
+ }
163
+ }
164
+ return result;
154
165
  }
@@ -1,7 +1,11 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
2
  import type React from 'react';
3
3
  import type { ColumnTemplate, CommandItem, EditType, FilterOperator, IColumnType, IFormat, ITextAlign, TypeFilter } from '../grid-component/type';
4
+ import type { PrimaryKey } from './base-table/table';
4
5
  export type CellProps = React.TdHTMLAttributes<HTMLTableCellElement>;
6
+ export type BaseRecord = {
7
+ rowId: PrimaryKey;
8
+ };
5
9
  export type FilterState = {
6
10
  field: any;
7
11
  key: any;
@@ -1,9 +1,10 @@
1
1
  /// <reference types="react" />
2
+ import type { PrimaryKey } from './base-table/table';
2
3
  import type { ArtColumn } from './interfaces';
3
4
  declare function safeRenderHeader(column: ArtColumn): import("react").ReactNode;
4
5
  declare function safeRenderHeaderContent(column: ArtColumn, t?: any): any;
5
6
  declare function safeGetValue(column: ArtColumn, record: any, rowIndex: number): any;
6
- declare function safeGetRowKey(primaryKey: string | ((record: any) => string), record: any, rowIndex: number): string;
7
+ declare function safeGetRowKey(primaryKey: PrimaryKey, record: any, rowIndex: number): string;
7
8
  declare function safeGetCellProps(column: ArtColumn, record: any, rowIndex: number): import("./interfaces").CellProps;
8
9
  declare function safeRender(column: ArtColumn, record: any, rowIndex: number): any;
9
10
  export declare const internals: {
@@ -71,6 +71,7 @@ export interface ColumnFeatureOptions {
71
71
  handleCellChange: any;
72
72
  handleHeaderCellChange?: any;
73
73
  dataErrors?: any[];
74
+ headerData?: any;
74
75
  }
75
76
  export declare function columnCustom(opts: ColumnFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
76
77
  export {};
@@ -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,8 @@ export function columnCustom(opts) {
59
60
  onSubmit,
60
61
  handleCellChange,
61
62
  handleHeaderCellChange,
62
- dataErrors
63
+ dataErrors,
64
+ headerData
63
65
  // originData
64
66
 
65
67
  // currentPage = 1,
@@ -87,8 +89,7 @@ export function columnCustom(opts) {
87
89
  const allRows = pipeline.getDataSource(); // flat data
88
90
 
89
91
  const leafColumns = collectNodes(pipeline.getColumns(), 'leaf-only');
90
- // const originCols = pipeline.getColumns()
91
-
92
+ const originCols = pipeline.getColumns();
92
93
  const rowIds = getKeys(allRows, 'rowId');
93
94
  const colIds = getKeys(leafColumns, 'field');
94
95
  const rowIndexMap = getRowIndexMap(allRows);
@@ -292,7 +293,7 @@ export function columnCustom(opts) {
292
293
 
293
294
  // Chức năng edit
294
295
 
295
- const handleEdit = (e, record, col, editType, isKeyDown) => {
296
+ const handleEdit = (e, record, col, editType, isKeyDown, isHeader) => {
296
297
  pipeline.setStateAtKey(stateKeyIsEditing, true);
297
298
  reset?.();
298
299
  if (!isObjEmpty(record)) {
@@ -314,6 +315,15 @@ export function columnCustom(opts) {
314
315
  }
315
316
  }, 10);
316
317
  }
318
+ if (focusedCell?.rowId && isHeader) {
319
+ setTimeout(() => {
320
+ const textarea = document.querySelector(`.ui-rc-grid-table-header-row .header-cell-editable[data-col-key="${focusedCell.colId}"] textarea`);
321
+ if (textarea) {
322
+ textarea.focus();
323
+ textarea.setSelectionRange(textarea.value.length, textarea.value.length);
324
+ }
325
+ }, 10);
326
+ }
317
327
  };
318
328
  const triggerDragPaste = (pasteState, ctrlKey) => {
319
329
  const tmpCols = [...leafColumns];
@@ -769,7 +779,7 @@ export function columnCustom(opts) {
769
779
  if (e.key === 'Enter') {
770
780
  e.preventDefault();
771
781
  e.stopPropagation();
772
- handleEdit(e, record, column, editType);
782
+ handleEdit(e, record, column, editType, false);
773
783
  return;
774
784
  }
775
785
  if (e.key.length === 1 && !e.ctrlKey) {
@@ -778,6 +788,168 @@ export function columnCustom(opts) {
778
788
  handleEdit(e, record, column, editType, true);
779
789
  }
780
790
  };
791
+ const handleHeaderKeyDown = (e, rowId, colId, rowIndex, column, record, editType) => {
792
+ if (e.key === 'Tab') {
793
+ const currentHeaderRowCols = getColumnsAtLevel(originCols, rowIndex);
794
+ const currentHeaderRowColsEditAble = currentHeaderRowCols ? currentHeaderRowCols.filter(it => it.headerEditEnable) : undefined;
795
+ const nextCol = currentHeaderRowColsEditAble ? getNextColumn(currentHeaderRowColsEditAble, focusedCell.colId) : undefined;
796
+ const nextHeaderRowCols = getColumnsAtLevel(originCols, rowIndex + 1);
797
+ const nextHeaderRowColsEditAble = nextHeaderRowCols ? nextHeaderRowCols.filter(it => it.headerEditEnable) : undefined;
798
+ const nextRow = nextHeaderRowColsEditAble ? nextHeaderRowColsEditAble : undefined;
799
+ const checkEnd = nextCol && currentHeaderRowColsEditAble ? getNextColumn1(currentHeaderRowColsEditAble, nextCol.column.field) : undefined;
800
+ if (!checkEnd) {
801
+ e.preventDefault();
802
+ e.stopPropagation();
803
+ }
804
+ if (nextCol?.column && !nextCol.isWrapped) {
805
+ const nextCellPosition = {
806
+ rowId,
807
+ colId: nextCol.column.field
808
+ };
809
+ pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
810
+ pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
811
+ pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
812
+ } else {
813
+ // Nếu là cột cuối cùng, có thể nhảy xuống dòng tiếp theo
814
+
815
+ // const currentRowIndex = allRows.findIndex(r => r.rowId === rowId);
816
+ // const nextRow = allRows[currentRowIndex + 1];
817
+
818
+ const firstCol = nextRow?.[0];
819
+ if (nextRow && firstCol) {
820
+ const nextRowId = `header-field-${rowIndex + 1}`;
821
+ const nextCellPosition = {
822
+ rowId: nextRowId,
823
+ colId: firstCol.field
824
+ };
825
+ pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
826
+ pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
827
+ pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
828
+ if (tableRef) {
829
+ // tableRef?.current?.artTableWrapperRef?.current?.scrollLeft = 0
830
+
831
+ // const wrapper = tableRef.current?.artTableWrapperRef?.current;
832
+ const wrapper = tableRef.current?.domHelper?.stickyScroll;
833
+ if (!wrapper) return;
834
+ wrapper.scrollLeft = 0;
835
+ }
836
+ } else {
837
+ e.preventDefault();
838
+ e.stopPropagation();
839
+ }
840
+ }
841
+ return;
842
+ }
843
+
844
+ // if (e.key === 'ArrowRight') {
845
+
846
+ // // e.preventDefault();
847
+ // // e.stopPropagation()
848
+
849
+ // const nextCol = getNextColumn(leafColumns, column.field)
850
+
851
+ // if (nextCol.column && !nextCol.isWrapped) {
852
+
853
+ // const nextCellPosition = { rowId, colId: nextCol.column.field }
854
+
855
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
856
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
857
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
858
+
859
+ // }
860
+
861
+ // return
862
+ // }
863
+
864
+ // if (e.key === 'ArrowLeft') {
865
+
866
+ // // e.preventDefault()
867
+ // // e.stopPropagation()
868
+
869
+ // const prevCol = getPrevColumn(leafColumns, column.field)
870
+
871
+ // if (prevCol) {
872
+
873
+ // const nextCellPosition = { rowId, colId: prevCol.field }
874
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
875
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
876
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
877
+
878
+ // }
879
+ // return
880
+ // }
881
+
882
+ // if (e.key === 'ArrowDown') {
883
+
884
+ // // e.preventDefault()
885
+ // // e.stopPropagation()
886
+
887
+ // const nextRow = allRows[rowIndex + 1]
888
+
889
+ // if (nextRow) {
890
+ // const nextRowId = nextRow.rowId
891
+
892
+ // const nextCellPosition = { rowId: nextRowId, colId }
893
+ // // setFocusedCell?.({ rowId: nextRowId, colId });
894
+ // // setStartCell?.({ rowId: nextRowId, colId });
895
+ // // setEndCell?.({ rowId: nextRowId, colId });
896
+
897
+ // // setRangeState?.(getSelectedCellMatrix(table, { rowId: nextRowId, colId }, { rowId: nextRowId, colId }))
898
+
899
+ // // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
900
+ // // rowVirtualizer.scrollToIndex(nextRow.index, { align: 'center' })
901
+
902
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
903
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
904
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
905
+
906
+ // // const rowElement: any = document.querySelector(`.ui-rc-grid-table-row[data-row-key="${nextRowId}"]`)
907
+
908
+ // // const cellFocus = rowElement?.querySelector('.ui-rc-grid-cell')
909
+
910
+ // }
911
+
912
+ // return
913
+ // }
914
+
915
+ // if (e.key === 'ArrowUp') {
916
+
917
+ // // e.preventDefault()
918
+ // // e.stopPropagation()
919
+
920
+ // const nextRow = allRows[rowIndex - 1]
921
+
922
+ // if (nextRow) {
923
+ // const nextRowId = nextRow.rowId
924
+
925
+ // const nextCellPosition = { rowId: nextRowId, colId }
926
+
927
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
928
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
929
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
930
+
931
+ // }
932
+
933
+ // return
934
+ // }
935
+
936
+ // if (e.key === 'Delete') {
937
+ // handleDeleteContent?.()
938
+ // return
939
+ // }
940
+
941
+ if (e.key === 'Enter') {
942
+ e.preventDefault();
943
+ e.stopPropagation();
944
+ handleEdit(e, record, column, editType, false, true);
945
+ return;
946
+ }
947
+ if (e.key.length === 1 && !e.ctrlKey) {
948
+ e.preventDefault();
949
+ e.stopPropagation();
950
+ handleEdit(e, record, column, editType, true, true);
951
+ }
952
+ };
781
953
  const handleChange = (record, column, indexCol) => {
782
954
  const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
783
955
  const formState = getValues();
@@ -798,6 +970,26 @@ export function columnCustom(opts) {
798
970
  });
799
971
  } else {}
800
972
  };
973
+ const handleHeaderChange = (record, column, indexCol) => {
974
+ const currentRowIndex = allRows.findIndex(r => r.rowId === record.rowId);
975
+ const formState = getValues();
976
+ const itemState = getValues(column.field);
977
+ const prevState = record[column.field];
978
+ const newState = itemState;
979
+ if (newState !== prevState) {
980
+ handleHeaderCellChange?.({
981
+ key: record.rowId,
982
+ field: column.field,
983
+ record: formState,
984
+ prevState,
985
+ newState,
986
+ option: newState,
987
+ indexCol: indexCol,
988
+ indexRow: currentRowIndex,
989
+ type: 'blur'
990
+ });
991
+ } else {}
992
+ };
801
993
  const handlePointDoubleClick = (e, column, record) => {
802
994
  e.preventDefault();
803
995
  e.stopPropagation();
@@ -1042,15 +1234,19 @@ export function columnCustom(opts) {
1042
1234
  const htmlTooltip = headerCustomTooltip;
1043
1235
  const headerEditType = col.headerEditType;
1044
1236
  const headerRowIndex = params.path.findIndex(it => it.field === col.field);
1045
- const tmpValue = allRows.length > 0 ? allRows[0][col.field] : undefined;
1237
+ const headerRowId = `header-field-${headerRowIndex}`;
1238
+
1239
+ // const headerRecord: any = { ...col, rowId: `field-${headerRowIndex}`, [col.field]: tmpValue, children: undefined }
1240
+
1046
1241
  const headerRecord = {
1047
- ...col,
1048
- rowId: `field-${headerRowIndex}`,
1049
- [col.field]: tmpValue,
1050
- children: undefined
1242
+ [col.field]: headerData?.[col.field] ?? ''
1051
1243
  };
1052
- const cellHeaderEditing = isEditing && headerRecord.rowId === focusedCell.rowId && col.field === focusedCell.colId;
1053
- const isCellSelect = startCell?.rowId === headerRecord.rowId && startCell?.colId === col.field;
1244
+ const headerValue = headerData?.[col.field] ?? '';
1245
+ const cellHeaderEditing = isEditing && headerRowId === focusedCell.rowId && col.field === focusedCell.colId;
1246
+ const isCellSelect = headerRowId === focusedCell.rowId && startCell?.colId === col.field;
1247
+ const aa = getColumnsAtLevel(originCols, headerRowIndex);
1248
+ const aaEditAble = aa ? aa.filter(it => it.headerEditEnable) : undefined;
1249
+ const nextHeaderCol = aaEditAble ? getNextColumn(aaEditAble, focusedCell.colId) : undefined;
1054
1250
 
1055
1251
  // Cell thường có thể filter và sort được
1056
1252
  return {
@@ -1097,7 +1293,7 @@ export function columnCustom(opts) {
1097
1293
  startCell: startCell,
1098
1294
  handleSubmit: handleSubmit,
1099
1295
  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", {
1296
+ })) : 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
1297
  className: "ui-rc-header-trigger d-flex gap-50"
1102
1298
  }, canSort && /*#__PURE__*/React.createElement("div", {
1103
1299
  style: {
@@ -1148,9 +1344,20 @@ export function columnCustom(opts) {
1148
1344
  headerCellProps: mergeCellProps(col.headerCellProps ?? {}, {
1149
1345
  'data-tooltip-id': `${id}-tooltip-content`,
1150
1346
  'data-tooltip-content': htmlTooltip,
1347
+ // @ts-ignore
1348
+ 'data-col-key': col.field,
1349
+ ref: el => {
1350
+ if (focusedCell?.rowId === headerRowId && focusedCell?.colId === col.field && !isEditing) {
1351
+ el?.focus({
1352
+ preventScroll: true
1353
+ });
1354
+ }
1355
+ },
1356
+ tabIndex: focusedCell?.rowId === headerRowId && focusedCell?.colId === col.field ? 1 : col.field === nextHeaderCol?.column?.field ? 1 : -1,
1151
1357
  style: {
1152
1358
  overflow: 'visible',
1153
1359
  position: 'relative',
1360
+ outline: 'none',
1154
1361
  padding: cellHeaderEditing ? 0 : undefined
1155
1362
  },
1156
1363
  className: classNames('', {
@@ -1163,7 +1370,7 @@ export function columnCustom(opts) {
1163
1370
  }),
1164
1371
  onMouseDown: () => {
1165
1372
  if (col.headerEditEnable) {
1166
- handleMouseDown(headerRecord.rowId, col.field);
1373
+ handleMouseDown(headerRowId, col.field);
1167
1374
  }
1168
1375
  },
1169
1376
  onDoubleClick: e => {
@@ -1174,8 +1381,81 @@ export function columnCustom(opts) {
1174
1381
  e.preventDefault();
1175
1382
  return;
1176
1383
  }
1177
- if (headerRecord.rowId === focusedCell.rowId && col.field === focusedCell.colId && col.headerEditEnable) {
1178
- handleEdit(e, headerRecord, col, headerEditType ?? 'text');
1384
+ if (headerRowId === focusedCell.rowId && col.field === focusedCell.colId && col.headerEditEnable) {
1385
+ handleEdit(e, headerRecord, col, headerEditType ?? 'text', false, true);
1386
+ }
1387
+ },
1388
+ onKeyDown: e => {
1389
+ // prevCellProps?.onKeyDown?.(e)
1390
+ // chưa editing
1391
+ if (!isEditing) {
1392
+ handleHeaderKeyDown(e, headerRowId, col.field, headerRowIndex, col, headerRecord, headerEditType ?? 'text');
1393
+ } else {
1394
+ if (e.shiftKey && e.key === 'Enter') {
1395
+ e.preventDefault();
1396
+ e.stopPropagation();
1397
+ } else {
1398
+ if (e.key === 'Enter') {
1399
+ e.preventDefault();
1400
+ e.stopPropagation();
1401
+
1402
+ // const currentRowIndex = allRows.findIndex(r => r.rowId === headerRowId);
1403
+ // const nextRow = allRows[currentRowIndex + 1];
1404
+
1405
+ // if (nextRow) {
1406
+ // const nextCellPosition = { rowId: nextRow.rowId, colId: col.field }
1407
+
1408
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
1409
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
1410
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
1411
+
1412
+ handleHeaderChange(headerRecord, col, startIndex);
1413
+ pipeline.setStateAtKey(stateKeyIsEditing, false);
1414
+
1415
+ // }
1416
+ }
1417
+ if (e.key === 'Tab') {
1418
+ e.preventDefault();
1419
+
1420
+ // const nextCol = getNextColumn(allCols, col.field)
1421
+
1422
+ if (nextHeaderCol?.column?.field && !nextHeaderCol?.isWrapped) {
1423
+ const nextCellPosition = {
1424
+ rowId: headerRowId,
1425
+ colId: nextHeaderCol.column.field
1426
+ };
1427
+ pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition);
1428
+ pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition);
1429
+ pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition);
1430
+
1431
+ // columnVirtualizer.scrollToIndex(nextCol.getIndex(), { align: 'center' })
1432
+ } else {
1433
+ // Nếu là cột cuối cùng, có thể nhảy xuống dòng tiếp theo
1434
+
1435
+ // const currentRowIndex = allRows.findIndex(r => r.rowId === headerRowId);
1436
+ // const nextRow = allRows[currentRowIndex + 1];
1437
+
1438
+ // const firstCol = nextCol.column
1439
+
1440
+ // if (nextRow) {
1441
+
1442
+ // const nextCellPosition = { rowId: nextRow.rowId, colId: firstCol.field }
1443
+
1444
+ // pipeline.setStateAtKey(stateKeyFocusedCell, nextCellPosition)
1445
+
1446
+ // pipeline.setStateAtKey(stateKeyStartCell, nextCellPosition)
1447
+ // pipeline.setStateAtKey(stateKeyEndCell, nextCellPosition)
1448
+
1449
+ // // columnVirtualizer.scrollToIndex(nextRowCol.getIndex())
1450
+
1451
+ // // rowVirtualizer.scrollToIndex(nextRow.index, { align: 'auto' })
1452
+
1453
+ // }
1454
+ }
1455
+ handleHeaderChange(headerRecord, col, startIndex);
1456
+ pipeline.setStateAtKey(stateKeyIsEditing, false);
1457
+ }
1458
+ }
1179
1459
  }
1180
1460
  }
1181
1461
  }),
@@ -1330,7 +1610,7 @@ export function columnCustom(opts) {
1330
1610
  return;
1331
1611
  }
1332
1612
  if (record.rowId === focusedCell.rowId && col.field === focusedCell.colId && canEdit) {
1333
- handleEdit(e, record, col, editType ?? 'text');
1613
+ handleEdit(e, record, col, editType ?? 'text', false);
1334
1614
  }
1335
1615
  },
1336
1616
  onKeyDown: e => {
@@ -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 */
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import type { ColumnTable, EditType, IFormat } from "../../grid-component/type";
3
+ import type { Column } from "@tanstack/react-table";
3
4
  interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
4
5
  t?: any;
5
6
  dataIndex: string;
@@ -10,6 +11,8 @@ interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement>
10
11
  indexRow: number;
11
12
  indexCol: number;
12
13
  cellEditing?: any;
14
+ visibleColumns?: Column<DataType>[];
15
+ handleNextCell?: () => void;
13
16
  }
14
17
  declare const EditableCell: <T>(props: EditableCellProps<T>) => JSX.Element;
15
18
  export default EditableCell;