es-grid-template 1.7.41 → 1.7.43

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.
@@ -31,14 +31,14 @@ import Grid from "./table/Grid";
31
31
  // import ContextMenu from './ContextMenu'
32
32
  import { addRowIdArray, convertToObj, convertToObjTrue,
33
33
  // convertFilters,
34
- filterDataByColumns, flatColumns2,
34
+ filterDataByColumns, findAllChildrenKeys2, flatColumns2,
35
35
  // filterDataByColumns,
36
- getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns, isTreeArray } from "./hook/utils";
36
+ getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns, isTreeArray, updateWidthsByOther } from "./hook/utils";
37
37
  // import GridEdit from './table/GridEdit'
38
38
  import { convertToTanStackColumns } from "./hook/useColumns";
39
39
  import { convertColumns } from "./hook/convert";
40
40
  import { Modal } from 'antd';
41
- import { findAllChildrenKeys2 } from "../grid-component/hooks";
41
+ // import { findAllChildrenKeys2 } from '../grid-component/hooks'
42
42
  // import { columns111 } from '../test-2/columns'
43
43
 
44
44
  dayjs.extend(customParseFormat);
@@ -103,7 +103,8 @@ const InternalTable = props => {
103
103
  const [isFullScreen, setIsFullScreen] = React.useState(false);
104
104
  const [columns, setColumns] = React.useState([]);
105
105
  React.useEffect(() => {
106
- setColumns(propsColumns);
106
+ // setColumns(propsColumns as any)
107
+ setColumns(updateWidthsByOther(propsColumns, columns));
107
108
  }, [propsColumns]);
108
109
  const [expanded, setExpanded] = React.useState({});
109
110
  const convertData = React.useMemo(() => {
@@ -210,7 +211,8 @@ const InternalTable = props => {
210
211
  isDataTree: isDataTree,
211
212
  selectionSettings: selectionSettings,
212
213
  mergedSelectedKeys: mergedSelectedKeys,
213
- expandable: expandable
214
+ expandable: expandable,
215
+ setColumns: setColumns
214
216
  })), /*#__PURE__*/React.createElement(Modal, {
215
217
  open: isFullScreen,
216
218
  footer: null,
@@ -280,7 +282,8 @@ const InternalTable = props => {
280
282
  isDataTree: isDataTree,
281
283
  selectionSettings: selectionSettings,
282
284
  mergedSelectedKeys: mergedSelectedKeys,
283
- expandable: expandable
285
+ expandable: expandable,
286
+ setColumns: setColumns
284
287
  })))));
285
288
  };
286
289
  export default InternalTable;
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch, SetStateAction } from "react";
2
2
  import React from "react";
3
- import type { ColumnDef, Table } from "@tanstack/react-table";
3
+ import type { ColumnDef, ColumnSizingInfoState, ColumnSizingState, Table } from "@tanstack/react-table";
4
4
  import type { ColumnsTable, TableProps } from "./type";
5
5
  type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
6
6
  table: Table<T>;
@@ -32,6 +32,10 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
32
32
  columnHidden: any;
33
33
  isFullScreen: boolean;
34
34
  setIsFullScreen: Dispatch<SetStateAction<boolean>>;
35
+ setColumnSizing: Dispatch<SetStateAction<any>>;
36
+ setColumns: Dispatch<SetStateAction<any>>;
37
+ columnSizingInfo: ColumnSizingInfoState;
38
+ columnSizing: ColumnSizingState;
35
39
  };
36
40
  declare const TableContainerEdit: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
37
41
  export default TableContainerEdit;
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import React, { Fragment } from "react";
3
3
  import { checkDecimalSeparator, checkThousandSeparator, detectSeparators, findItemByKey, flattenArray, flattenData, getAllRowKey, getColIdsBetween, getDefaultValue, getFormat, getRowIdsBetween, getSelectedCellMatrix, isEditable, isFormattedNumber, newGuid, sumSize,
4
4
  // sumSize,
5
- unFlattenData, updateArrayByKey, updateOrInsert } from "./hook/utils";
5
+ unFlattenData, updateArrayByKey, updateColumnWidthsRecursive, updateOrInsert } from "./hook/utils";
6
6
  import { useVirtualizer } from "@tanstack/react-virtual";
7
7
  import { useForm } from 'react-hook-form';
8
8
  import { Button, Modal, Typography, Dropdown } from "antd";
@@ -117,7 +117,11 @@ const TableContainerEdit = props => {
117
117
  showDefaultContext,
118
118
  commandSettings,
119
119
  isDataTree,
120
- onCellClick
120
+ onCellClick,
121
+ // setColumnSizing,
122
+ setColumns,
123
+ columnSizing,
124
+ columnSizingInfo
121
125
  } = props;
122
126
  const containerRef = React.useRef(null);
123
127
  const bottomToolbarRef = React.useRef(null);
@@ -352,7 +356,9 @@ const TableContainerEdit = props => {
352
356
  return startCell && endCell ? getRowIdsBetween(table, startCell.rowId, endCell.rowId) : [];
353
357
  }, [endCell, startCell, table]);
354
358
  const copySelectionToClipboard = React.useCallback(() => {
355
- if (!startCell || !endCell) return;
359
+ if (!startCell || !endCell) {
360
+ return;
361
+ }
356
362
 
357
363
  // const allRows = table.getRowModel().rows;
358
364
  const allRows = table.getRowModel().flatRows;
@@ -665,19 +671,161 @@ const TableContainerEdit = props => {
665
671
  });
666
672
  }, [columnSizingState, columnVirtualizer]);
667
673
  React.useEffect(() => {
668
- if (!containerRef.current) return;
669
- const containerWidth = containerRef.current.offsetWidth - 1;
674
+ if (!tableContainerRef.current) {
675
+ return;
676
+ }
677
+ const containerWidth = tableContainerRef.current.offsetWidth;
670
678
  const totalWidth = table.getTotalSize();
679
+ if (totalWidth && totalWidth <= containerWidth) {
680
+ return;
681
+ }
682
+ if (columnSizingInfo.isResizingColumn === false) {
683
+ const aa = updateColumnWidthsRecursive(propsColumns, columnSizing);
684
+ setColumns(aa);
685
+ }
686
+ }, [columnSizingInfo]);
687
+ React.useEffect(() => {
688
+ // if (!containerRef.current || !tableContainerRef.current) {
689
+ if (!tableContainerRef.current) {
690
+ return;
691
+ }
692
+
693
+ // const containerWidth = containerRef.current.offsetWidth - 1
694
+ // const containerWidth = tableContainerRef.current.offsetWidth
695
+ const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
696
+ const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
697
+
698
+ // console.log('containerWidth', containerWidth)
699
+ // console.log('totalWidth', totalWidth)
700
+
671
701
  if (totalWidth && totalWidth < containerWidth) {
672
702
  const factor = containerWidth / totalWidth;
673
- table.setColumnSizing(table.getAllLeafColumns().reduce((acc, col) => {
674
- acc[col.id] = (col.getSize() || col.columnDef.size || 150) * factor;
703
+ const visibleCols = table.getVisibleLeafColumns();
704
+ const baseSizes = visibleCols.map(col => col.getSize() || col.columnDef.size || 150);
705
+ const scaledSizes = baseSizes.map(size => size * factor);
706
+ const roundedSizes = scaledSizes.map(size => Math.floor(size));
707
+ let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0);
708
+
709
+ // phân bổ diff cho các cột từ trái qua phải
710
+ for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
711
+ roundedSizes[i]++;
712
+ diff--;
713
+ }
714
+ const aaa = visibleCols.reduce((acc, col, idx) => {
715
+ acc[col.id] = roundedSizes[idx];
675
716
  return acc;
676
- }, {}));
717
+ }, {});
718
+
719
+ // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
720
+
721
+ // setColumns(aa)
722
+
723
+ // console.log('aaa', aaa)
724
+
725
+ table.setColumnSizing(aaa);
726
+
727
+ // setColumnSizing?.(aaa)
677
728
  }
678
- }, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing]);
729
+ }, [table.getTotalSize(), table.getState().columnSizing, dataSource.length]);
679
730
  // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
680
731
 
732
+ // React.useEffect(() => {
733
+
734
+ // if (!tableContainerRef.current) {
735
+ // return
736
+ // }
737
+
738
+ // const containerWidth = tableContainerRef.current.offsetWidth
739
+ // const totalWidth = table.getTotalSize()
740
+
741
+ // if (totalWidth && totalWidth <= containerWidth) {
742
+
743
+ // return
744
+
745
+ // }
746
+
747
+ // if (columnSizingInfo.isResizingColumn === false) {
748
+
749
+ // const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
750
+ // setColumns(aa)
751
+
752
+ // }
753
+
754
+ // }, [columnSizing, columnSizingInfo, propsColumns, setColumns])
755
+
756
+ // React.useEffect(() => {
757
+
758
+ // // if (!containerRef.current || !tableContainerRef.current) {
759
+ // if (!tableContainerRef.current) {
760
+ // return
761
+ // }
762
+
763
+ // // const containerWidth = containerRef.current.offsetWidth - 1
764
+ // const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0 )
765
+
766
+ // const totalWidth = table.getTotalSize()
767
+
768
+ // if (totalWidth && totalWidth < containerWidth) {
769
+
770
+ // const factor = containerWidth / totalWidth
771
+
772
+ // const visibleCols = table.getVisibleLeafColumns()
773
+
774
+ // const baseSizes = visibleCols.map(
775
+ // (col) => col.getSize() || col.columnDef.size || 150
776
+ // )
777
+
778
+ // const scaledSizes = baseSizes.map((size) => size * factor)
779
+ // const roundedSizes = scaledSizes.map((size) => Math.floor(size))
780
+
781
+ // let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
782
+
783
+ // // phân bổ diff cho các cột từ trái qua phải
784
+ // for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
785
+ // roundedSizes[i]++
786
+ // diff--
787
+ // }
788
+
789
+ // const aaa = visibleCols.reduce((acc, col, idx) => {
790
+ // acc[col.id] = roundedSizes[idx]
791
+ // return acc
792
+ // }, {} as Record<string, number>)
793
+
794
+ // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
795
+
796
+ // // setColumns(aa)
797
+
798
+ // table.setColumnSizing(aaa)
799
+
800
+ // // setColumnSizing?.(aaa)
801
+ // }
802
+
803
+ // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing])
804
+ // // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing, dataSource.length])
805
+ // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
806
+
807
+ // React.useEffect(() => {
808
+
809
+ // if (!containerRef.current) return;
810
+
811
+ // const containerWidth = containerRef.current.offsetWidth - 1;
812
+ // const totalWidth = table.getTotalSize();
813
+
814
+ // if (totalWidth && totalWidth < containerWidth) {
815
+
816
+ // const factor = containerWidth / totalWidth;
817
+
818
+ // table.setColumnSizing(
819
+ // table.getVisibleLeafColumns().reduce((acc, col) => {
820
+ // acc[col.id] = ((col.getSize() || col.columnDef.size || 150) * factor);
821
+ // return acc;
822
+ // }, {} as Record<string, number>)
823
+ // );
824
+ // }
825
+
826
+ // }, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing])
827
+ // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
828
+
681
829
  React.useEffect(() => {
682
830
  const totalHeight = minHeight ?? height;
683
831
  if (totalHeight) {
@@ -425,7 +425,8 @@ const EditableCell = props => {
425
425
  newState,
426
426
  option: {
427
427
  value: val,
428
- label: val
428
+ label: val,
429
+ searchTextAsValue: true
429
430
  },
430
431
  indexCol,
431
432
  indexRow,
@@ -511,7 +512,8 @@ const EditableCell = props => {
511
512
  newState,
512
513
  option: {
513
514
  value: val,
514
- label: val
515
+ label: val,
516
+ searchTextAsValue: true
515
517
  },
516
518
  indexCol,
517
519
  indexRow,
@@ -636,7 +638,8 @@ const EditableCell = props => {
636
638
  newState,
637
639
  option: {
638
640
  value: val,
639
- label: val
641
+ label: val,
642
+ searchTextAsValue: true
640
643
  },
641
644
  indexCol,
642
645
  indexRow,
@@ -691,7 +691,8 @@ const TableBodyCellEdit = props => {
691
691
  }
692
692
  }
693
693
  const handleMouseDownIndex = rowId => {
694
- const allColumns = table.getVisibleLeafColumns();
694
+ setIsSelecting?.(true);
695
+ const allColumns = table.getVisibleLeafColumns().filter(it => !nonActionColumn.includes(it.id));
695
696
  const firstCOl = findFirst(allColumns);
696
697
  const startCol = allColumns[0].id;
697
698
  const endCol = allColumns[allColumns.length - 1].id;
@@ -717,6 +718,31 @@ const TableBodyCellEdit = props => {
717
718
  colId: endCol
718
719
  }));
719
720
  };
721
+ const handleMouseEnterIndex = rowId => {
722
+ if (isSelecting) {
723
+ const allColumns = table.getVisibleLeafColumns().filter(it => !nonActionColumn.includes(it.id));
724
+
725
+ // const firstCOl = findFirst(allColumns)
726
+
727
+ // const startCol = allColumns[0].id
728
+ const endCol = allColumns[allColumns.length - 1].id;
729
+
730
+ // setStartCell?.({ rowId, colId: startCol });
731
+ setEndCell?.({
732
+ rowId,
733
+ colId: endCol
734
+ });
735
+ }
736
+ };
737
+ const handleMouseUpIndex = () => {
738
+ setIsSelecting?.(false);
739
+ // setIsPasting?.(false);
740
+
741
+ const selectState = getSelectedCellMatrix(table, startCell, endCell);
742
+ if (!isObjEqual(rangeState, selectState)) {
743
+ setRangeState?.(selectState);
744
+ }
745
+ };
720
746
  if (cell.column.id === "#") {
721
747
  return /*#__PURE__*/React.createElement("td", {
722
748
  key: cell.id,
@@ -756,7 +782,16 @@ const TableBodyCellEdit = props => {
756
782
 
757
783
  // reset?.()
758
784
  }
759
- }
785
+ },
786
+ onMouseEnter: () => {
787
+ handleMouseEnterIndex(cell.row.id);
788
+ },
789
+ onMouseUp: handleMouseUpIndex
790
+ // onMouseUp={() => {
791
+
792
+ // handleMouseUpIndex()
793
+
794
+ // }}
760
795
  }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
761
796
  className: "ui-rc-table-row-expand-trigger",
762
797
  style: {
@@ -214,8 +214,8 @@ const TableHeadCell = props => {
214
214
  [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
215
215
  [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
216
216
  [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
217
- [`${prefix}-grid-cell-text-center`]: originalColumn?.headerTextAlign === 'center',
218
- [`${prefix}-grid-cell-text-right`]: originalColumn?.headerTextAlign === 'right'
217
+ [`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
218
+ [`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
219
219
  }),
220
220
  colSpan: colSpan,
221
221
  rowSpan: rowSpan,
@@ -2,7 +2,7 @@ import type { Table } from "@tanstack/react-table";
2
2
  import { type Column } from "@tanstack/react-table";
3
3
  import type { VirtualItem } from "@tanstack/react-virtual";
4
4
  import type { AnyObject, ColumnsTable, ColumnTable, EditType, FilterOperator, IColumnType, IFormat, RangeState, Sorter, TypeFilter } from "./../type";
5
- import { type CSSProperties } from "react";
5
+ import { Key, type CSSProperties } from "react";
6
6
  import dayjs from "dayjs";
7
7
  import type { IPositionCell } from "../useContext";
8
8
  import type { ColumnDef } from "@tanstack/react-table";
@@ -137,3 +137,6 @@ export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
137
137
  export declare function isTree(arr: any[]): boolean;
138
138
  export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
139
139
  export declare function isTreeArray(arr: any[]): boolean;
140
+ export declare function updateColumnWidthsRecursive(columns: any[], sizing: Record<string, number>): any[];
141
+ export declare function updateWidthsByOther(source: any[], target: any[]): any[];
142
+ export declare function findAllChildrenKeys2<RecordType>(data: readonly RecordType[], rowKey: any, childrenColumnName: string): Key[];
@@ -1917,4 +1917,64 @@ export function isTreeArray(arr) {
1917
1917
  }
1918
1918
  return true; // node lá thì hợp lệ
1919
1919
  });
1920
+ }
1921
+ export function updateColumnWidthsRecursive(columns, sizing) {
1922
+ return columns.map(col => {
1923
+ const updated = {
1924
+ ...col
1925
+ };
1926
+
1927
+ // cập nhật width nếu có trong sizing
1928
+ if (sizing[col.field] !== undefined) {
1929
+ updated.width = sizing[col.field];
1930
+ }
1931
+
1932
+ // nếu có children thì gọi đệ quy
1933
+ if (col.children && col.children.length > 0) {
1934
+ updated.children = updateColumnWidthsRecursive(col.children, sizing);
1935
+ }
1936
+ return updated;
1937
+ });
1938
+ }
1939
+ export function updateWidthsByOther(source, target) {
1940
+ const targetMap = new Map();
1941
+
1942
+ // tạo map {field -> width} từ target
1943
+ const buildMap = cols => {
1944
+ cols.forEach(col => {
1945
+ if (col.width !== undefined) {
1946
+ targetMap.set(col.field, col.width);
1947
+ }
1948
+ if (col.children) {
1949
+ buildMap(col.children);
1950
+ }
1951
+ });
1952
+ };
1953
+ buildMap(target);
1954
+
1955
+ // cập nhật width từ map
1956
+ const update = cols => cols.map(col => {
1957
+ const updated = {
1958
+ ...col
1959
+ };
1960
+ if (targetMap.has(col.field)) {
1961
+ updated.width = targetMap.get(col.field);
1962
+ }
1963
+ if (col.children) {
1964
+ updated.children = update(col.children);
1965
+ }
1966
+ return updated;
1967
+ });
1968
+ return update(source);
1969
+ }
1970
+ export function findAllChildrenKeys2(data, rowKey, childrenColumnName) {
1971
+ const keys = [];
1972
+ function dig(list) {
1973
+ (list || []).forEach(item => {
1974
+ keys.push(item[rowKey]);
1975
+ dig(item[childrenColumnName]);
1976
+ });
1977
+ }
1978
+ dig(data);
1979
+ return keys;
1920
1980
  }
@@ -293,7 +293,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
293
293
  }
294
294
 
295
295
  &.#{$prefix}-grid-cell-index-selected {
296
- background-color: $cell-index-selected-bg;
296
+ background-color: $cell-index-selected-bg !important;
297
297
  color: #ffffff;
298
298
  }
299
299
 
@@ -8,6 +8,7 @@ type Props<T> = Omit<TableProps<T>, 'columns'> & {
8
8
  prefix: string;
9
9
  columns: ColumnDef<T>[];
10
10
  propsColumns: ColumnsTable<T>;
11
+ setColumns: Dispatch<SetStateAction<ColumnsTable<T>>>;
11
12
  columnHidden: VisibilityState;
12
13
  expanded: ExpandedState;
13
14
  setExpanded: any;
@@ -28,6 +28,7 @@ const Grid = props => {
28
28
  originData,
29
29
  columns,
30
30
  propsColumns,
31
+ setColumns,
31
32
  pagination,
32
33
  expanded,
33
34
  setExpanded,
@@ -64,6 +65,7 @@ const Grid = props => {
64
65
  const [rowSelection, setRowSelection] = React.useState(convertToObjTrue(mergedSelectedKeys));
65
66
  const [grouping, setGrouping] = React.useState([]);
66
67
  const [columnSizing, setColumnSizing] = React.useState({});
68
+ const [columnSizingInfo, setColumnSizingInfo] = React.useState({});
67
69
  // const [manualUpdate, setManualUpdate] = React.useState(false)
68
70
  // const [manualResize, setManualResize] = React.useState(false)
69
71
 
@@ -112,6 +114,7 @@ const Grid = props => {
112
114
  columnResizeMode,
113
115
  columnResizeDirection,
114
116
  onColumnSizingChange: setColumnSizing,
117
+ onColumnSizingInfoChange: setColumnSizingInfo,
115
118
  // ColumnSizing
116
119
 
117
120
  // ColumnSorting
@@ -141,13 +144,25 @@ const Grid = props => {
141
144
  React.useEffect(() => {
142
145
  if (columnHidden) {
143
146
  const abb = table.getVisibleLeafColumns()?.[0];
144
- if (abb) {
147
+ if (abb && Object.keys(columnSizingInfo).length === 0) {
145
148
  setColumnSizing({
146
149
  "#": abb.getSize()
147
150
  });
148
151
  }
149
152
  }
150
- }, [columnHidden, table]);
153
+ }, [columnHidden, columnSizingInfo]);
154
+
155
+ // React.useEffect(() => {
156
+ // if (columnSizingInfo.isResizingColumn === false) {
157
+
158
+ // const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
159
+
160
+ // setColumns(aa)
161
+
162
+ // }
163
+
164
+ // }, [columnSizingInfo])
165
+
151
166
  React.useEffect(() => {
152
167
  // if (!manualUpdate) {
153
168
  if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys)) {
@@ -267,7 +282,11 @@ const Grid = props => {
267
282
  setExpanded: setExpanded,
268
283
  expanded: expanded,
269
284
  infiniteScroll: infiniteScroll,
270
- setMergedFilterKeys: setMergedFilterKeys
285
+ setMergedFilterKeys: setMergedFilterKeys,
286
+ setColumnSizing: setColumnSizing,
287
+ setColumns: setColumns,
288
+ columnSizing: columnSizing,
289
+ columnSizingInfo: columnSizingInfo
271
290
  }))));
272
291
  };
273
292
  export default Grid;
@@ -300,6 +300,10 @@ export type IEditSelectSettings = {
300
300
  fieldLabel?: string;
301
301
  /** cho phép nhập giá trị - onBlur: giá trị search được set thành value **/
302
302
  searchTextAsValue?: boolean;
303
+ /**
304
+ * @deprecated Please use `allowSorter` instead.
305
+ * @since 1.7.25
306
+ */
303
307
  inputKey?: string;
304
308
  filterKey?: string[];
305
309
  selectMode?: SelectMode;
@@ -20,7 +20,6 @@ var _utils = require("./hook/utils");
20
20
  var _useColumns = require("./hook/useColumns");
21
21
  var _convert = require("./hook/convert");
22
22
  var _antd = require("antd");
23
- var _hooks = require("../grid-component/hooks");
24
23
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
25
24
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
26
25
  // import en from "rc-master-ui/es/date-picker/locale/en_US"
@@ -45,6 +44,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
45
44
 
46
45
  // import GridEdit from './table/GridEdit'
47
46
 
47
+ // import { findAllChildrenKeys2 } from '../grid-component/hooks'
48
48
  // import { columns111 } from '../test-2/columns'
49
49
 
50
50
  _dayjs.default.extend(_customParseFormat.default);
@@ -109,7 +109,8 @@ const InternalTable = props => {
109
109
  const [isFullScreen, setIsFullScreen] = _react.default.useState(false);
110
110
  const [columns, setColumns] = _react.default.useState([]);
111
111
  _react.default.useEffect(() => {
112
- setColumns(propsColumns);
112
+ // setColumns(propsColumns as any)
113
+ setColumns((0, _utils.updateWidthsByOther)(propsColumns, columns));
113
114
  }, [propsColumns]);
114
115
  const [expanded, setExpanded] = _react.default.useState({});
115
116
  const convertData = _react.default.useMemo(() => {
@@ -144,7 +145,7 @@ const InternalTable = props => {
144
145
  });
145
146
  _react.default.useEffect(() => {
146
147
  if (defaultExpandAllRows) {
147
- const allKeys = (0, _hooks.findAllChildrenKeys2)(convertData, rowKey, 'children');
148
+ const allKeys = (0, _utils.findAllChildrenKeys2)(convertData, rowKey, 'children');
148
149
  setExpanded((0, _utils.convertToObjTrue)(allKeys));
149
150
  } else {
150
151
  if (defaultExpandedRowKeys) {
@@ -216,7 +217,8 @@ const InternalTable = props => {
216
217
  isDataTree: isDataTree,
217
218
  selectionSettings: selectionSettings,
218
219
  mergedSelectedKeys: mergedSelectedKeys,
219
- expandable: expandable
220
+ expandable: expandable,
221
+ setColumns: setColumns
220
222
  })), /*#__PURE__*/_react.default.createElement(_antd.Modal, {
221
223
  open: isFullScreen,
222
224
  footer: null,
@@ -286,7 +288,8 @@ const InternalTable = props => {
286
288
  isDataTree: isDataTree,
287
289
  selectionSettings: selectionSettings,
288
290
  mergedSelectedKeys: mergedSelectedKeys,
289
- expandable: expandable
291
+ expandable: expandable,
292
+ setColumns: setColumns
290
293
  })))));
291
294
  };
292
295
  var _default = exports.default = InternalTable;
@@ -1,6 +1,6 @@
1
1
  import type { Dispatch, SetStateAction } from "react";
2
2
  import React from "react";
3
- import type { ColumnDef, Table } from "@tanstack/react-table";
3
+ import type { ColumnDef, ColumnSizingInfoState, ColumnSizingState, Table } from "@tanstack/react-table";
4
4
  import type { ColumnsTable, TableProps } from "./type";
5
5
  type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
6
6
  table: Table<T>;
@@ -32,6 +32,10 @@ type TableContainerProps<T> = Omit<TableProps<T>, 'columns'> & {
32
32
  columnHidden: any;
33
33
  isFullScreen: boolean;
34
34
  setIsFullScreen: Dispatch<SetStateAction<boolean>>;
35
+ setColumnSizing: Dispatch<SetStateAction<any>>;
36
+ setColumns: Dispatch<SetStateAction<any>>;
37
+ columnSizingInfo: ColumnSizingInfoState;
38
+ columnSizing: ColumnSizingState;
35
39
  };
36
40
  declare const TableContainerEdit: <RecordType extends object>(props: TableContainerProps<RecordType>) => React.JSX.Element;
37
41
  export default TableContainerEdit;
@@ -124,7 +124,11 @@ const TableContainerEdit = props => {
124
124
  showDefaultContext,
125
125
  commandSettings,
126
126
  isDataTree,
127
- onCellClick
127
+ onCellClick,
128
+ // setColumnSizing,
129
+ setColumns,
130
+ columnSizing,
131
+ columnSizingInfo
128
132
  } = props;
129
133
  const containerRef = _react.default.useRef(null);
130
134
  const bottomToolbarRef = _react.default.useRef(null);
@@ -359,7 +363,9 @@ const TableContainerEdit = props => {
359
363
  return startCell && endCell ? (0, _utils.getRowIdsBetween)(table, startCell.rowId, endCell.rowId) : [];
360
364
  }, [endCell, startCell, table]);
361
365
  const copySelectionToClipboard = _react.default.useCallback(() => {
362
- if (!startCell || !endCell) return;
366
+ if (!startCell || !endCell) {
367
+ return;
368
+ }
363
369
 
364
370
  // const allRows = table.getRowModel().rows;
365
371
  const allRows = table.getRowModel().flatRows;
@@ -672,19 +678,161 @@ const TableContainerEdit = props => {
672
678
  });
673
679
  }, [columnSizingState, columnVirtualizer]);
674
680
  _react.default.useEffect(() => {
675
- if (!containerRef.current) return;
676
- const containerWidth = containerRef.current.offsetWidth - 1;
681
+ if (!tableContainerRef.current) {
682
+ return;
683
+ }
684
+ const containerWidth = tableContainerRef.current.offsetWidth;
677
685
  const totalWidth = table.getTotalSize();
686
+ if (totalWidth && totalWidth <= containerWidth) {
687
+ return;
688
+ }
689
+ if (columnSizingInfo.isResizingColumn === false) {
690
+ const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, columnSizing);
691
+ setColumns(aa);
692
+ }
693
+ }, [columnSizingInfo]);
694
+ _react.default.useEffect(() => {
695
+ // if (!containerRef.current || !tableContainerRef.current) {
696
+ if (!tableContainerRef.current) {
697
+ return;
698
+ }
699
+
700
+ // const containerWidth = containerRef.current.offsetWidth - 1
701
+ // const containerWidth = tableContainerRef.current.offsetWidth
702
+ const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
703
+ const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0);
704
+
705
+ // console.log('containerWidth', containerWidth)
706
+ // console.log('totalWidth', totalWidth)
707
+
678
708
  if (totalWidth && totalWidth < containerWidth) {
679
709
  const factor = containerWidth / totalWidth;
680
- table.setColumnSizing(table.getAllLeafColumns().reduce((acc, col) => {
681
- acc[col.id] = (col.getSize() || col.columnDef.size || 150) * factor;
710
+ const visibleCols = table.getVisibleLeafColumns();
711
+ const baseSizes = visibleCols.map(col => col.getSize() || col.columnDef.size || 150);
712
+ const scaledSizes = baseSizes.map(size => size * factor);
713
+ const roundedSizes = scaledSizes.map(size => Math.floor(size));
714
+ let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0);
715
+
716
+ // phân bổ diff cho các cột từ trái qua phải
717
+ for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
718
+ roundedSizes[i]++;
719
+ diff--;
720
+ }
721
+ const aaa = visibleCols.reduce((acc, col, idx) => {
722
+ acc[col.id] = roundedSizes[idx];
682
723
  return acc;
683
- }, {}));
724
+ }, {});
725
+
726
+ // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
727
+
728
+ // setColumns(aa)
729
+
730
+ // console.log('aaa', aaa)
731
+
732
+ table.setColumnSizing(aaa);
733
+
734
+ // setColumnSizing?.(aaa)
684
735
  }
685
- }, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing]);
736
+ }, [table.getTotalSize(), table.getState().columnSizing, dataSource.length]);
686
737
  // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
687
738
 
739
+ // React.useEffect(() => {
740
+
741
+ // if (!tableContainerRef.current) {
742
+ // return
743
+ // }
744
+
745
+ // const containerWidth = tableContainerRef.current.offsetWidth
746
+ // const totalWidth = table.getTotalSize()
747
+
748
+ // if (totalWidth && totalWidth <= containerWidth) {
749
+
750
+ // return
751
+
752
+ // }
753
+
754
+ // if (columnSizingInfo.isResizingColumn === false) {
755
+
756
+ // const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
757
+ // setColumns(aa)
758
+
759
+ // }
760
+
761
+ // }, [columnSizing, columnSizingInfo, propsColumns, setColumns])
762
+
763
+ // React.useEffect(() => {
764
+
765
+ // // if (!containerRef.current || !tableContainerRef.current) {
766
+ // if (!tableContainerRef.current) {
767
+ // return
768
+ // }
769
+
770
+ // // const containerWidth = containerRef.current.offsetWidth - 1
771
+ // const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0 )
772
+
773
+ // const totalWidth = table.getTotalSize()
774
+
775
+ // if (totalWidth && totalWidth < containerWidth) {
776
+
777
+ // const factor = containerWidth / totalWidth
778
+
779
+ // const visibleCols = table.getVisibleLeafColumns()
780
+
781
+ // const baseSizes = visibleCols.map(
782
+ // (col) => col.getSize() || col.columnDef.size || 150
783
+ // )
784
+
785
+ // const scaledSizes = baseSizes.map((size) => size * factor)
786
+ // const roundedSizes = scaledSizes.map((size) => Math.floor(size))
787
+
788
+ // let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
789
+
790
+ // // phân bổ diff cho các cột từ trái qua phải
791
+ // for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
792
+ // roundedSizes[i]++
793
+ // diff--
794
+ // }
795
+
796
+ // const aaa = visibleCols.reduce((acc, col, idx) => {
797
+ // acc[col.id] = roundedSizes[idx]
798
+ // return acc
799
+ // }, {} as Record<string, number>)
800
+
801
+ // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
802
+
803
+ // // setColumns(aa)
804
+
805
+ // table.setColumnSizing(aaa)
806
+
807
+ // // setColumnSizing?.(aaa)
808
+ // }
809
+
810
+ // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing])
811
+ // // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing, dataSource.length])
812
+ // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
813
+
814
+ // React.useEffect(() => {
815
+
816
+ // if (!containerRef.current) return;
817
+
818
+ // const containerWidth = containerRef.current.offsetWidth - 1;
819
+ // const totalWidth = table.getTotalSize();
820
+
821
+ // if (totalWidth && totalWidth < containerWidth) {
822
+
823
+ // const factor = containerWidth / totalWidth;
824
+
825
+ // table.setColumnSizing(
826
+ // table.getVisibleLeafColumns().reduce((acc, col) => {
827
+ // acc[col.id] = ((col.getSize() || col.columnDef.size || 150) * factor);
828
+ // return acc;
829
+ // }, {} as Record<string, number>)
830
+ // );
831
+ // }
832
+
833
+ // }, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing])
834
+ // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
835
+
688
836
  _react.default.useEffect(() => {
689
837
  const totalHeight = minHeight ?? height;
690
838
  if (totalHeight) {
@@ -427,7 +427,8 @@ const EditableCell = props => {
427
427
  newState,
428
428
  option: {
429
429
  value: val,
430
- label: val
430
+ label: val,
431
+ searchTextAsValue: true
431
432
  },
432
433
  indexCol,
433
434
  indexRow,
@@ -513,7 +514,8 @@ const EditableCell = props => {
513
514
  newState,
514
515
  option: {
515
516
  value: val,
516
- label: val
517
+ label: val,
518
+ searchTextAsValue: true
517
519
  },
518
520
  indexCol,
519
521
  indexRow,
@@ -638,7 +640,8 @@ const EditableCell = props => {
638
640
  newState,
639
641
  option: {
640
642
  value: val,
641
- label: val
643
+ label: val,
644
+ searchTextAsValue: true
642
645
  },
643
646
  indexCol,
644
647
  indexRow,
@@ -697,7 +697,8 @@ const TableBodyCellEdit = props => {
697
697
  }
698
698
  }
699
699
  const handleMouseDownIndex = rowId => {
700
- const allColumns = table.getVisibleLeafColumns();
700
+ setIsSelecting?.(true);
701
+ const allColumns = table.getVisibleLeafColumns().filter(it => !_constant.nonActionColumn.includes(it.id));
701
702
  const firstCOl = (0, _utils.findFirst)(allColumns);
702
703
  const startCol = allColumns[0].id;
703
704
  const endCol = allColumns[allColumns.length - 1].id;
@@ -723,6 +724,31 @@ const TableBodyCellEdit = props => {
723
724
  colId: endCol
724
725
  }));
725
726
  };
727
+ const handleMouseEnterIndex = rowId => {
728
+ if (isSelecting) {
729
+ const allColumns = table.getVisibleLeafColumns().filter(it => !_constant.nonActionColumn.includes(it.id));
730
+
731
+ // const firstCOl = findFirst(allColumns)
732
+
733
+ // const startCol = allColumns[0].id
734
+ const endCol = allColumns[allColumns.length - 1].id;
735
+
736
+ // setStartCell?.({ rowId, colId: startCol });
737
+ setEndCell?.({
738
+ rowId,
739
+ colId: endCol
740
+ });
741
+ }
742
+ };
743
+ const handleMouseUpIndex = () => {
744
+ setIsSelecting?.(false);
745
+ // setIsPasting?.(false);
746
+
747
+ const selectState = (0, _utils.getSelectedCellMatrix)(table, startCell, endCell);
748
+ if (!(0, _utils.isObjEqual)(rangeState, selectState)) {
749
+ setRangeState?.(selectState);
750
+ }
751
+ };
726
752
  if (cell.column.id === "#") {
727
753
  return /*#__PURE__*/_react.default.createElement("td", {
728
754
  key: cell.id,
@@ -762,7 +788,16 @@ const TableBodyCellEdit = props => {
762
788
 
763
789
  // reset?.()
764
790
  }
765
- }
791
+ },
792
+ onMouseEnter: () => {
793
+ handleMouseEnterIndex(cell.row.id);
794
+ },
795
+ onMouseUp: handleMouseUpIndex
796
+ // onMouseUp={() => {
797
+
798
+ // handleMouseUpIndex()
799
+
800
+ // }}
766
801
  }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/_react.default.createElement("div", {
767
802
  className: "ui-rc-table-row-expand-trigger",
768
803
  style: {
@@ -223,8 +223,8 @@ const TableHeadCell = props => {
223
223
  [`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
224
224
  [`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
225
225
  [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
226
- [`${prefix}-grid-cell-text-center`]: originalColumn?.headerTextAlign === 'center',
227
- [`${prefix}-grid-cell-text-right`]: originalColumn?.headerTextAlign === 'right'
226
+ [`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
227
+ [`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
228
228
  }),
229
229
  colSpan: colSpan,
230
230
  rowSpan: rowSpan,
@@ -2,7 +2,7 @@ import type { Table } from "@tanstack/react-table";
2
2
  import { type Column } from "@tanstack/react-table";
3
3
  import type { VirtualItem } from "@tanstack/react-virtual";
4
4
  import type { AnyObject, ColumnsTable, ColumnTable, EditType, FilterOperator, IColumnType, IFormat, RangeState, Sorter, TypeFilter } from "./../type";
5
- import { type CSSProperties } from "react";
5
+ import { Key, type CSSProperties } from "react";
6
6
  import dayjs from "dayjs";
7
7
  import type { IPositionCell } from "../useContext";
8
8
  import type { ColumnDef } from "@tanstack/react-table";
@@ -137,3 +137,6 @@ export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
137
137
  export declare function isTree(arr: any[]): boolean;
138
138
  export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
139
139
  export declare function isTreeArray(arr: any[]): boolean;
140
+ export declare function updateColumnWidthsRecursive(columns: any[], sizing: Record<string, number>): any[];
141
+ export declare function updateWidthsByOther(source: any[], target: any[]): any[];
142
+ export declare function findAllChildrenKeys2<RecordType>(data: readonly RecordType[], rowKey: any, childrenColumnName: string): Key[];
@@ -20,6 +20,7 @@ exports.convertFilters = exports.convertDayjsToDate = exports.convertDateToDayjs
20
20
  exports.convertFormat = convertFormat;
21
21
  exports.extendsObject = exports.detectSeparators = exports.customWeekStartEndFormat = exports.convertToObjTrue = exports.convertToObj = exports.convertLabelToTitle = void 0;
22
22
  exports.filterDataByColumns = filterDataByColumns;
23
+ exports.findAllChildrenKeys2 = findAllChildrenKeys2;
23
24
  exports.findFirst = findFirst;
24
25
  exports.getAllVisibleKeys1 = exports.getAllVisibleKeys = exports.getAllRowKey = exports.genPresets = exports.flattenData = exports.flattenArray = exports.flatColumns2 = exports.findItemByKey = void 0;
25
26
  exports.getCellsByPosition = getCellsByPosition;
@@ -42,8 +43,11 @@ exports.isTree = isTree;
42
43
  exports.isTreeArray = isTreeArray;
43
44
  exports.sortByType = exports.shouldInclude = exports.removeVietnameseTones = exports.parseBooleanToValue = exports.onRemoveBgSelectedCell = exports.onAddBgSelectedCell = exports.newGuid = void 0;
44
45
  exports.sortData = sortData;
45
- exports.updateColumns1 = exports.updateArrayByKey = exports.unFlattenData = exports.sumSize = void 0;
46
+ exports.updateArrayByKey = exports.unFlattenData = exports.sumSize = void 0;
47
+ exports.updateColumnWidthsRecursive = updateColumnWidthsRecursive;
48
+ exports.updateColumns1 = void 0;
46
49
  exports.updateOrInsert = updateOrInsert;
50
+ exports.updateWidthsByOther = updateWidthsByOther;
47
51
  var _useSelection = require("rc-master-ui/es/table/hooks/useSelection");
48
52
  var _uuid = require("uuid");
49
53
  var _colors = require("@ant-design/colors");
@@ -2019,4 +2023,64 @@ function isTreeArray(arr) {
2019
2023
  }
2020
2024
  return true; // node lá thì hợp lệ
2021
2025
  });
2026
+ }
2027
+ function updateColumnWidthsRecursive(columns, sizing) {
2028
+ return columns.map(col => {
2029
+ const updated = {
2030
+ ...col
2031
+ };
2032
+
2033
+ // cập nhật width nếu có trong sizing
2034
+ if (sizing[col.field] !== undefined) {
2035
+ updated.width = sizing[col.field];
2036
+ }
2037
+
2038
+ // nếu có children thì gọi đệ quy
2039
+ if (col.children && col.children.length > 0) {
2040
+ updated.children = updateColumnWidthsRecursive(col.children, sizing);
2041
+ }
2042
+ return updated;
2043
+ });
2044
+ }
2045
+ function updateWidthsByOther(source, target) {
2046
+ const targetMap = new Map();
2047
+
2048
+ // tạo map {field -> width} từ target
2049
+ const buildMap = cols => {
2050
+ cols.forEach(col => {
2051
+ if (col.width !== undefined) {
2052
+ targetMap.set(col.field, col.width);
2053
+ }
2054
+ if (col.children) {
2055
+ buildMap(col.children);
2056
+ }
2057
+ });
2058
+ };
2059
+ buildMap(target);
2060
+
2061
+ // cập nhật width từ map
2062
+ const update = cols => cols.map(col => {
2063
+ const updated = {
2064
+ ...col
2065
+ };
2066
+ if (targetMap.has(col.field)) {
2067
+ updated.width = targetMap.get(col.field);
2068
+ }
2069
+ if (col.children) {
2070
+ updated.children = update(col.children);
2071
+ }
2072
+ return updated;
2073
+ });
2074
+ return update(source);
2075
+ }
2076
+ function findAllChildrenKeys2(data, rowKey, childrenColumnName) {
2077
+ const keys = [];
2078
+ function dig(list) {
2079
+ (list || []).forEach(item => {
2080
+ keys.push(item[rowKey]);
2081
+ dig(item[childrenColumnName]);
2082
+ });
2083
+ }
2084
+ dig(data);
2085
+ return keys;
2022
2086
  }
@@ -293,7 +293,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
293
293
  }
294
294
 
295
295
  &.#{$prefix}-grid-cell-index-selected {
296
- background-color: $cell-index-selected-bg;
296
+ background-color: $cell-index-selected-bg !important;
297
297
  color: #ffffff;
298
298
  }
299
299
 
@@ -8,6 +8,7 @@ type Props<T> = Omit<TableProps<T>, 'columns'> & {
8
8
  prefix: string;
9
9
  columns: ColumnDef<T>[];
10
10
  propsColumns: ColumnsTable<T>;
11
+ setColumns: Dispatch<SetStateAction<ColumnsTable<T>>>;
11
12
  columnHidden: VisibilityState;
12
13
  expanded: ExpandedState;
13
14
  setExpanded: any;
@@ -30,6 +30,7 @@ const Grid = props => {
30
30
  originData,
31
31
  columns,
32
32
  propsColumns,
33
+ setColumns,
33
34
  pagination,
34
35
  expanded,
35
36
  setExpanded,
@@ -66,6 +67,7 @@ const Grid = props => {
66
67
  const [rowSelection, setRowSelection] = _react.default.useState((0, _utils.convertToObjTrue)(mergedSelectedKeys));
67
68
  const [grouping, setGrouping] = _react.default.useState([]);
68
69
  const [columnSizing, setColumnSizing] = _react.default.useState({});
70
+ const [columnSizingInfo, setColumnSizingInfo] = _react.default.useState({});
69
71
  // const [manualUpdate, setManualUpdate] = React.useState(false)
70
72
  // const [manualResize, setManualResize] = React.useState(false)
71
73
 
@@ -114,6 +116,7 @@ const Grid = props => {
114
116
  columnResizeMode,
115
117
  columnResizeDirection,
116
118
  onColumnSizingChange: setColumnSizing,
119
+ onColumnSizingInfoChange: setColumnSizingInfo,
117
120
  // ColumnSizing
118
121
 
119
122
  // ColumnSorting
@@ -143,13 +146,25 @@ const Grid = props => {
143
146
  _react.default.useEffect(() => {
144
147
  if (columnHidden) {
145
148
  const abb = table.getVisibleLeafColumns()?.[0];
146
- if (abb) {
149
+ if (abb && Object.keys(columnSizingInfo).length === 0) {
147
150
  setColumnSizing({
148
151
  "#": abb.getSize()
149
152
  });
150
153
  }
151
154
  }
152
- }, [columnHidden, table]);
155
+ }, [columnHidden, columnSizingInfo]);
156
+
157
+ // React.useEffect(() => {
158
+ // if (columnSizingInfo.isResizingColumn === false) {
159
+
160
+ // const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
161
+
162
+ // setColumns(aa)
163
+
164
+ // }
165
+
166
+ // }, [columnSizingInfo])
167
+
153
168
  _react.default.useEffect(() => {
154
169
  // if (!manualUpdate) {
155
170
  if (Object.keys(rowSelection) !== Object.keys(mergedSelectedKeys)) {
@@ -269,7 +284,11 @@ const Grid = props => {
269
284
  setExpanded: setExpanded,
270
285
  expanded: expanded,
271
286
  infiniteScroll: infiniteScroll,
272
- setMergedFilterKeys: setMergedFilterKeys
287
+ setMergedFilterKeys: setMergedFilterKeys,
288
+ setColumnSizing: setColumnSizing,
289
+ setColumns: setColumns,
290
+ columnSizing: columnSizing,
291
+ columnSizingInfo: columnSizingInfo
273
292
  }))));
274
293
  };
275
294
  var _default = exports.default = Grid;
@@ -300,6 +300,10 @@ export type IEditSelectSettings = {
300
300
  fieldLabel?: string;
301
301
  /** cho phép nhập giá trị - onBlur: giá trị search được set thành value **/
302
302
  searchTextAsValue?: boolean;
303
+ /**
304
+ * @deprecated Please use `allowSorter` instead.
305
+ * @since 1.7.25
306
+ */
303
307
  inputKey?: string;
304
308
  filterKey?: string[];
305
309
  selectMode?: SelectMode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.7.41",
3
+ "version": "1.7.43",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",