@evergis/react 3.1.24 → 3.1.25

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.
@@ -1,4 +1,4 @@
1
- import { ConfigContainerChild, WidgetType } from '../types';
1
+ import { ConfigContainerChild, ConfigLayer, WidgetType } from '../types';
2
2
  export declare const useWidgetPage: (type?: WidgetType) => {
3
3
  pageIndex: number;
4
4
  currentPage: ConfigContainerChild;
@@ -6,4 +6,5 @@ export declare const useWidgetPage: (type?: WidgetType) => {
6
6
  updateConfigPage: (newConfig: ConfigContainerChild) => void;
7
7
  addConfigPage: () => void;
8
8
  deleteConfigPage: (index: number) => void;
9
+ updateConfigLayer: (name: string, newProps: Omit<ConfigLayer, "name">) => void;
9
10
  };
package/dist/index.js CHANGED
@@ -8726,7 +8726,17 @@ const useWidgetPage = (type = exports.WidgetType.Dashboard) => {
8726
8726
  changePage(pageIndex > 1 ? pageIndex - 1 : 1);
8727
8727
  }
8728
8728
  }, [changePage, pageIndex, projectInfo, updateProject]);
8729
- return { pageIndex, currentPage, changePage, updateConfigPage, addConfigPage, deleteConfigPage };
8729
+ const updateConfigLayer = React.useCallback((name, newProps) => {
8730
+ const newProjectInfo = JSON.parse(JSON.stringify(projectInfo));
8731
+ const pages = getPagesFromProjectInfo(newProjectInfo);
8732
+ const page = pages?.[pageIndex - 1];
8733
+ const index = page?.layers?.findIndex(layer => layer.name === name) ?? -1;
8734
+ if (index === -1)
8735
+ return;
8736
+ page.layers[index] = { ...page.layers[index], ...newProps };
8737
+ updateProject(newProjectInfo);
8738
+ }, [projectInfo, pageIndex, updateProject]);
8739
+ return { pageIndex, currentPage, changePage, updateConfigPage, addConfigPage, deleteConfigPage, updateConfigLayer };
8730
8740
  };
8731
8741
 
8732
8742
  const useChartData = ({ element, type }) => {