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.
@@ -14,8 +14,6 @@ export type IFTableEditProps = {
14
14
  addDisable?: boolean;
15
15
  haveSum?: boolean;
16
16
  disableAutoKey?: boolean;
17
- isTree?: boolean;
18
- fieldChildren?: string;
19
17
  formatSetting?: IFTableEditFormat;
20
18
  pagingSetting?: IFTableEditPaging;
21
19
  buttonSetting?: IFTableEditButton;
@@ -26,6 +24,13 @@ export type IFTableEditProps = {
26
24
  allowFilter?: boolean;
27
25
  allowOrder?: boolean;
28
26
  optionsFilter?: any;
27
+ settingColumns?: {
28
+ field: string;
29
+ headerText?: string;
30
+ visible?: boolean;
31
+ fixedType?: "left" | "right";
32
+ width?: number | string;
33
+ }[];
29
34
  setSelectedItem?: Dispatch<SetStateAction<any>>;
30
35
  commandClick?: (data: any) => void;
31
36
  handleSelect?: (data: any) => void;
@@ -37,7 +37,13 @@ export declare const FindNodeByPath: (tree: any[], path: string) => {
37
37
  * fisrtObjWidthFixRight: number // Chỉ số cột đầu tiên fixed right
38
38
  * }
39
39
  */
40
- export declare const calculateTableStructure: (columns: any[]) => {
40
+ export declare const calculateTableStructure: (columns: any[], settingColumns?: {
41
+ field: string;
42
+ headerText?: string;
43
+ visible?: boolean;
44
+ fixedType?: "left" | "right";
45
+ width?: number | string;
46
+ }[]) => {
41
47
  levels: any[][];
42
48
  flat: any[];
43
49
  flatVisble: any[];
package/dist/index.d.ts CHANGED
@@ -402,8 +402,6 @@ type IFTableEditProps = {
402
402
  addDisable?: boolean;
403
403
  haveSum?: boolean;
404
404
  disableAutoKey?: boolean;
405
- isTree?: boolean;
406
- fieldChildren?: string;
407
405
  formatSetting?: IFTableEditFormat;
408
406
  pagingSetting?: IFTableEditPaging;
409
407
  buttonSetting?: IFTableEditButton;
@@ -414,6 +412,13 @@ type IFTableEditProps = {
414
412
  allowFilter?: boolean;
415
413
  allowOrder?: boolean;
416
414
  optionsFilter?: any;
415
+ settingColumns?: {
416
+ field: string;
417
+ headerText?: string;
418
+ visible?: boolean;
419
+ fixedType?: "left" | "right";
420
+ width?: number | string;
421
+ }[];
417
422
  setSelectedItem?: Dispatch<SetStateAction<any>>;
418
423
  commandClick?: (data: any) => void;
419
424
  handleSelect?: (data: any) => void;
@@ -481,7 +486,13 @@ declare const FindNodeByPath: (tree: any[], path: string) => {
481
486
  * fisrtObjWidthFixRight: number // Chỉ số cột đầu tiên fixed right
482
487
  * }
483
488
  */
484
- declare const calculateTableStructure: (columns: any[]) => {
489
+ declare const calculateTableStructure: (columns: any[], settingColumns?: {
490
+ field: string;
491
+ headerText?: string;
492
+ visible?: boolean;
493
+ fixedType?: "left" | "right";
494
+ width?: number | string;
495
+ }[]) => {
485
496
  levels: any[][];
486
497
  flat: any[];
487
498
  flatVisble: any[];
package/dist/index.js CHANGED
@@ -17682,7 +17682,7 @@ const FindNodeByPath = (tree, path) => {
17682
17682
  * fisrtObjWidthFixRight: number // Chỉ số cột đầu tiên fixed right
17683
17683
  * }
17684
17684
  */
17685
- const calculateTableStructure = (columns) => {
17685
+ const calculateTableStructure = (columns, settingColumns) => {
17686
17686
  const levels = [];
17687
17687
  const flat = [];
17688
17688
  const objWidthFixLeft = {};
@@ -17720,6 +17720,21 @@ const calculateTableStructure = (columns) => {
17720
17720
  colspan,
17721
17721
  rowspan: hasChildren ? 1 : maxDepth - level
17722
17722
  };
17723
+ if (settingColumns && settingColumns.length > 0) {
17724
+ const column = settingColumns.find((y) => y.field === cell.field);
17725
+ if (column) {
17726
+ cell.visible = column.visible;
17727
+ if (column.fixedType) {
17728
+ cell.fixedType = column.fixedType;
17729
+ }
17730
+ if (column.width) {
17731
+ cell.width = column.width;
17732
+ }
17733
+ }
17734
+ else {
17735
+ cell.visible = false;
17736
+ }
17737
+ }
17723
17738
  levels[level].push(cell);
17724
17739
  const headerKey = `${level}-${indexCol}`;
17725
17740
  if (col.fixedType === "left" && col.visible !== false) {
@@ -42824,7 +42839,7 @@ const ToolbarBottom = ({ handleAdd, handleDuplicate, handleInsertBefore, handleI
42824
42839
 
42825
42840
  const TableEdit = React$5.forwardRef((props, ref) => {
42826
42841
  const { t } = reactI18next.useTranslation();
42827
- 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;
42842
+ 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;
42828
42843
  React$5.useImperativeHandle(ref, () => {
42829
42844
  return {
42830
42845
  refeshFocusRow: handleRefeshRow
@@ -42837,7 +42852,6 @@ const TableEdit = React$5.forwardRef((props, ref) => {
42837
42852
  const [searchTerm, setSearchTerm] = React$5.useState("");
42838
42853
  const [orderBy, setOrderBy] = React$5.useState([]);
42839
42854
  const [filterBy, setFilterBy] = React$5.useState([]);
42840
- const [refreshColumns, setRefreshColumns] = React$5.useState(false);
42841
42855
  const tableElement = React$5.useRef(null);
42842
42856
  const gridRef = React$5.useRef(null);
42843
42857
  const totalCount = dataSource.length;
@@ -42851,8 +42865,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
42851
42865
  }
42852
42866
  }, [dataSource]);
42853
42867
  const { levels: headerColumns, flat: contentColumns, flatVisble, objWidthFixLeft, objWidthFixRight, lastObjWidthFixLeft, fisrtObjWidthFixRight, objHeaderWidthFixLeft, objHeaderWidthFixRight, indexFirstEdit: indexFirstEdit, indexLastEdit: indexLastEdit } = React$5.useMemo(() => {
42854
- return calculateTableStructure(columns);
42855
- }, [columns, refreshColumns]);
42868
+ return calculateTableStructure(columns, settingColumns);
42869
+ }, [columns, settingColumns]);
42856
42870
  const handleRefeshRow = () => {
42857
42871
  setRefreshRow(true);
42858
42872
  setTimeout(() => {
@@ -43691,15 +43705,9 @@ const TableEdit = React$5.forwardRef((props, ref) => {
43691
43705
  }, changeOrder: (val) => {
43692
43706
  setOrderBy([...val]);
43693
43707
  }, columns: contentColumns, setColumns: (newColumns) => {
43694
- newColumns.forEach((x) => {
43695
- const column = columns.find((y) => y.field === x.field);
43696
- if (column) {
43697
- column.visible = x.visible;
43698
- column.fixedType = x.fixedType;
43699
- column.width = x.width;
43700
- }
43701
- });
43702
- setRefreshColumns(!refreshColumns);
43708
+ if (saveSettingColumn) {
43709
+ saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
43710
+ }
43703
43711
  }, fisrtObjWidthFixRight: fisrtObjWidthFixRight, lastObjWidthFixLeft: lastObjWidthFixLeft, totalCount: totalCount }, `header-${indexParent}-${index}`));
43704
43712
  }) }, `header-${-indexParent}`));
43705
43713
  }) }), jsxRuntime.jsx("tbody", { className: "r-gridcontent", role: "rowgroup", children: dataSource.map((row, indexRow) => {
@@ -43726,18 +43734,8 @@ const TableEdit = React$5.forwardRef((props, ref) => {
43726
43734
  setOpenPopupSetupColumn(!openPopupSetupColumn);
43727
43735
  }, openSidebar: openPopupSetupColumn, column: [...contentColumns], setColumn: (newColumns) => {
43728
43736
  if (saveSettingColumn) {
43729
- console.log(newColumns);
43730
43737
  saveSettingColumn(newColumns.map((x) => ({ field: x.field, headerText: x.headerText, visible: x.visible, fixedType: x.fixedType, width: x.width })));
43731
43738
  }
43732
- newColumns.forEach((x) => {
43733
- const column = columns.find((y) => y.field === x.field);
43734
- if (column) {
43735
- column.visible = x.visible;
43736
- column.fixedType = x.fixedType;
43737
- column.width = x.width;
43738
- }
43739
- });
43740
- setRefreshColumns(!refreshColumns);
43741
43739
  } })] }));
43742
43740
  });
43743
43741