react-table-edit 1.4.37 → 1.4.39

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.
package/dist/index.mjs CHANGED
@@ -17654,7 +17654,7 @@ const FindNodeByPath = (tree, path) => {
17654
17654
  * fisrtObjWidthFixRight: number // Chỉ số cột đầu tiên fixed right
17655
17655
  * }
17656
17656
  */
17657
- const calculateTableStructure = (columns) => {
17657
+ const calculateTableStructure = (columns, settingColumns) => {
17658
17658
  const levels = [];
17659
17659
  const flat = [];
17660
17660
  const objWidthFixLeft = {};
@@ -17692,6 +17692,21 @@ const calculateTableStructure = (columns) => {
17692
17692
  colspan,
17693
17693
  rowspan: hasChildren ? 1 : maxDepth - level
17694
17694
  };
17695
+ if (settingColumns && settingColumns.length > 0) {
17696
+ const column = settingColumns.find((y) => y.field === cell.field);
17697
+ if (column) {
17698
+ cell.visible = column.visible;
17699
+ if (column.fixedType) {
17700
+ cell.fixedType = column.fixedType;
17701
+ }
17702
+ if (column.width) {
17703
+ cell.width = column.width;
17704
+ }
17705
+ }
17706
+ else {
17707
+ cell.visible = false;
17708
+ }
17709
+ }
17695
17710
  levels[level].push(cell);
17696
17711
  const headerKey = `${level}-${indexCol}`;
17697
17712
  if (col.fixedType === "left" && col.visible !== false) {
@@ -42796,7 +42811,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
42796
42811
 
42797
42812
  const TableEdit = forwardRef((props, ref) => {
42798
42813
  const { t } = useTranslation();
42799
- const { idTable, dataSource, columns, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, haveSum, isMulti, disableAutoKey, commandClick, dataSourceChange, rowChange, setSelectedItem, handleSelect, onDuplicate, saveSettingColumn, allowFilter = true, allowOrder, optionsFilter } = props;
42814
+ const { idTable, dataSource, columns, pagingSetting, setDataSource, height, maxHeight, minHeight, defaultValue, toolbarSetting, searchSetting, selectedItem, selectEnable, editDisable, addDisable, buttonSetting, formatSetting, haveSum, isMulti, disableAutoKey, commandClick, dataSourceChange, rowChange, setSelectedItem, handleSelect, onDuplicate, saveSettingColumn, allowFilter = true, allowOrder, settingColumns, optionsFilter } = props;
42800
42815
  useImperativeHandle(ref, () => {
42801
42816
  return {
42802
42817
  refeshFocusRow: handleRefeshRow
@@ -42809,7 +42824,6 @@ const TableEdit = forwardRef((props, ref) => {
42809
42824
  const [searchTerm, setSearchTerm] = useState("");
42810
42825
  const [orderBy, setOrderBy] = useState([]);
42811
42826
  const [filterBy, setFilterBy] = useState([]);
42812
- const [refreshColumns, setRefreshColumns] = useState(false);
42813
42827
  const tableElement = useRef(null);
42814
42828
  const gridRef = useRef(null);
42815
42829
  const totalCount = dataSource.length;
@@ -42823,8 +42837,8 @@ const TableEdit = forwardRef((props, ref) => {
42823
42837
  }
42824
42838
  }, [dataSource]);
42825
42839
  const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = useMemo(() => {
42826
- return calculateTableStructure(columns);
42827
- }, [columns, refreshColumns]);
42840
+ return calculateTableStructure(columns, settingColumns);
42841
+ }, [columns, settingColumns]);
42828
42842
  const handleRefeshRow = () => {
42829
42843
  setRefreshRow(true);
42830
42844
  setTimeout(() => {
@@ -43663,15 +43677,9 @@ const TableEdit = forwardRef((props, ref) => {
43663
43677
  }, changeOrder: (val) => {
43664
43678
  setOrderBy([...val]);
43665
43679
  }, columns: contentColumns, setColumns: (newColumns) => {
43666
- newColumns.forEach((x) => {
43667
- const column = columns.find((y) => y.field === x.field);
43668
- if (column) {
43669
- column.visible = x.visible;
43670
- column.fixedType = x.fixedType;
43671
- column.width = x.width;
43672
- }
43673
- });
43674
- setRefreshColumns(!refreshColumns);
43680
+ if (saveSettingColumn) {
43681
+ saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
43682
+ }
43675
43683
  }, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
43676
43684
  }) }, `header-${-indexParent}`));
43677
43685
  }) }), jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
@@ -43698,18 +43706,8 @@ const TableEdit = forwardRef((props, ref) => {
43698
43706
  setOpenPopupSetupColumn(!openPopupSetupColumn);
43699
43707
  }, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
43700
43708
  if (saveSettingColumn) {
43701
- console.log(newColumns);
43702
43709
  saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
43703
43710
  }
43704
- newColumns.forEach((x) => {
43705
- const column = columns.find((y) => y.field === x.field);
43706
- if (column) {
43707
- column.visible = x.visible;
43708
- column.fixedType = x.fixedType;
43709
- column.width = x.width;
43710
- }
43711
- });
43712
- setRefreshColumns(!refreshColumns);
43713
43711
  } })] }));
43714
43712
  });
43715
43713