@evergis/react 3.1.59 → 3.1.61

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.
@@ -2,5 +2,4 @@ import { FC } from 'react';
2
2
  import { ConfigContainerChild, ContainerProps } from '../../types';
3
3
  export declare const ElementLegend: FC<ContainerProps & {
4
4
  element: ConfigContainerChild;
5
- expandedContainers: Record<string, boolean>;
6
5
  }>;
@@ -11,7 +11,6 @@ export declare const elementComponents: {
11
11
  readonly chart: import('react').FC<import('..').ContainerProps>;
12
12
  readonly legend: import('react').FC<import('..').ContainerProps & {
13
13
  element: import('..').ConfigContainerChild;
14
- expandedContainers: Record<string, boolean>;
15
14
  }>;
16
15
  readonly markdown: import('react').FC<import('..').ContainerProps>;
17
16
  readonly uploader: import('react').FC<import('..').ContainerProps>;
@@ -1,5 +1,5 @@
1
- import { ConfigContainer, ConfigContainerChild, WidgetType } from '../types';
1
+ import { ConfigContainerChild, WidgetType } from '../types';
2
2
  export declare const useWidgetConfig: (type?: WidgetType) => {
3
- config: ConfigContainer;
3
+ config: any;
4
4
  pages: ConfigContainerChild[];
5
5
  };
@@ -12,6 +12,7 @@ export declare const useWidgetContext: (type?: WidgetType) => {
12
12
  attributes: import('../types').ClientFeatureAttribute[];
13
13
  feature: import('../../..').SelectedFeature;
14
14
  closeFeatureCard: VoidFunction;
15
+ containerIds: string[];
15
16
  components: {
16
17
  LayerItem?: import('react').FC<import('../..').LayerItemProps>;
17
18
  ProjectCatalogMenu?: import('react').FC;
@@ -4,6 +4,7 @@ import { ConfigContainer, DashboardLayerPayload, DashboardState, LayerItemProps,
4
4
  import { LayerInfo } from '../../types';
5
5
  export type DashboardContextProps = PropsWithChildren<{
6
6
  config?: ConfigContainer;
7
+ containerIds?: string[];
7
8
  projectInfo?: ExtendedProjectInfoDc;
8
9
  updateProject?: (projectInfo: ExtendedProjectInfoDc) => void;
9
10
  pageIndex?: number;
package/dist/index.js CHANGED
@@ -3920,7 +3920,7 @@ const ServerNotificationsProvider = ({ url, initialized, children }) => {
3920
3920
  };
3921
3921
 
3922
3922
  const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
3923
- const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
3923
+ const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
3924
3924
  const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = React.useContext(FeatureCardContext) || {};
3925
3925
  return {
3926
3926
  projectInfo,
@@ -3933,6 +3933,7 @@ const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
3933
3933
  attributes,
3934
3934
  feature,
3935
3935
  closeFeatureCard,
3936
+ containerIds,
3936
3937
  components: dashboardComponents,
3937
3938
  config: type === exports.WidgetType.Dashboard ? dashboardConfig : featureConfig,
3938
3939
  isLoading: type === exports.WidgetType.Dashboard ? projectLoading : featureLoading,
@@ -7603,8 +7604,8 @@ const ElementImage = React.memo(({ type, elementConfig }) => {
7603
7604
  return firstImage ? jsxRuntime.jsx("img", { src: firstImage, alt: firstImage, width: width }) : null;
7604
7605
  });
7605
7606
 
7606
- const ElementLegend = React.memo(({ type, element, elementConfig, expandedContainers }) => {
7607
- const { attributes, dataSources } = useWidgetContext(type);
7607
+ const ElementLegend = React.memo(({ type, element, elementConfig }) => {
7608
+ const { attributes, dataSources, expandedContainers } = useWidgetContext(type);
7608
7609
  const { options } = elementConfig || {};
7609
7610
  const { twoColumns, chartId, relatedDataSources, fontSize } = options || {};
7610
7611
  const chartElement = React.useMemo(() => findAnd.returnFound(element?.children, { id: chartId }), [chartId, element?.children]);
@@ -9395,16 +9396,27 @@ const tooltipValueFromRelatedFeatures = (t, value, relatedAttributes, layerInfo)
9395
9396
  };
9396
9397
 
9397
9398
  const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
9398
- const { config: configProp, projectInfo, layerInfo } = useWidgetContext(type);
9399
+ const { config: configProp, containerIds, projectInfo, layerInfo } = useWidgetContext(type);
9399
9400
  const config = React.useMemo(() => {
9400
9401
  if (configProp) {
9401
9402
  return configProp;
9402
9403
  }
9403
- if (type === exports.WidgetType.Dashboard) {
9404
- return (projectInfo?.content?.dashboardConfiguration || {});
9404
+ const currentConfig = type === exports.WidgetType.Dashboard
9405
+ ? (projectInfo?.content?.dashboardConfiguration || {})
9406
+ : (layerInfo?.configuration?.cardConfiguration || {});
9407
+ if (containerIds?.length) {
9408
+ const elements = containerIds.map(id => findAnd.returnFound(currentConfig, { id })).filter(Boolean);
9409
+ if (!elements.length)
9410
+ return currentConfig;
9411
+ const newConfig = JSON.parse(JSON.stringify(currentConfig));
9412
+ const pages = getPagesFromConfig(newConfig);
9413
+ if (!pages?.[0]?.children)
9414
+ return currentConfig;
9415
+ pages[0].children = elements;
9416
+ return newConfig;
9405
9417
  }
9406
- return (layerInfo?.configuration?.cardConfiguration || {});
9407
- }, [configProp, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
9418
+ return currentConfig;
9419
+ }, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
9408
9420
  const pages = React.useMemo(() => (getPagesFromConfig(config) || []), [config]);
9409
9421
  return {
9410
9422
  config,
@@ -10340,9 +10352,9 @@ const ExpandableTitle = React.memo(({ elementConfig, type, renderElement }) => {
10340
10352
  const { id, options, templateName, children } = elementConfig || {};
10341
10353
  const { expandable, fontColor, expanded, layerNames } = options || {};
10342
10354
  const titleElement = children?.find(item => item.id === "title");
10343
- const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
10344
10355
  if (!titleElement)
10345
10356
  return null;
10357
+ const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
10346
10358
  return (jsxRuntime.jsx(TitleContainer, { containerId: id, elementConfig: titleElement, templateName: templateName, layerNames: layerNames, fontColor: fontColor, expandable: expandable, expanded: expanded, type: type, isVisible: isVisible, renderElement: renderElement }));
10347
10359
  });
10348
10360