@evergis/react 3.1.81 → 3.1.82

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,7 +1,6 @@
1
1
  import { FC } from 'react';
2
- import { ConfigContainer, WidgetType } from '../../types';
2
+ import { WidgetType } from '../../types';
3
3
  export declare const Dashboard: FC<{
4
4
  type?: WidgetType;
5
- config?: ConfigContainer;
6
5
  noBorders?: boolean;
7
6
  }>;
@@ -1,6 +1,5 @@
1
- import { ConfigContainer, ConfigContainerChild, WidgetType } from '../types';
1
+ import { ConfigContainerChild, WidgetType } from '../types';
2
2
  export declare const useWidgetConfig: (type?: WidgetType) => {
3
3
  config: any;
4
- editConfig: ConfigContainer;
5
4
  pages: ConfigContainerChild[];
6
5
  };
@@ -20,6 +20,7 @@ export declare const useWidgetContext: (type?: WidgetType) => {
20
20
  ProjectPagesMenu?: import('react').FC;
21
21
  };
22
22
  config: import('../types').ConfigContainer;
23
+ isEditing: boolean;
23
24
  isLoading: boolean;
24
25
  pageIndex: number;
25
26
  filters: import('../types').SelectedFilters;
@@ -48,6 +48,7 @@ export interface ConfigOptions {
48
48
  relatedResources?: ConfigRelatedResource[];
49
49
  statusColors?: Record<RemoteTaskStatus, string>;
50
50
  chartType?: "bar" | "line" | "pie" | "stack";
51
+ controlType?: "dropdown" | "checkbox";
51
52
  layerNames?: string[];
52
53
  layerName?: string;
53
54
  geometryType?: GeometryType | EditGeometryType;
@@ -12,6 +12,7 @@ export type DashboardContextProps = PropsWithChildren<{
12
12
  dataSources?: WidgetDataSource[];
13
13
  geometryFilter?: boolean;
14
14
  loading?: boolean;
15
+ editMode?: boolean;
15
16
  filters?: SelectedFilters;
16
17
  dashboardLayers?: DashboardState["layers"];
17
18
  setDashboardLayer?: (props: DashboardLayerPayload) => void;
@@ -10,7 +10,7 @@ export type FeatureCardContextSettings = PropsWithChildren<{
10
10
  pageIndex?: number;
11
11
  handBookReference?: LayerReferenceConfigurationDc;
12
12
  isRaster?: boolean;
13
- isEditing?: boolean;
13
+ editMode?: boolean;
14
14
  isFeatureEditable?: boolean;
15
15
  hasCopyRights?: boolean;
16
16
  editOnly?: boolean;
package/dist/index.js CHANGED
@@ -4003,8 +4003,8 @@ const ServerNotificationsProvider = ({ url, initialized, children }) => {
4003
4003
  };
4004
4004
 
4005
4005
  const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
4006
- 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) || {};
4007
- 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) || {};
4006
+ const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, editMode: projectEditMode, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
4007
+ const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, editMode: featureEditMode, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = React.useContext(FeatureCardContext) || {};
4008
4008
  return {
4009
4009
  projectInfo,
4010
4010
  layerInfos,
@@ -4019,6 +4019,7 @@ const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
4019
4019
  containerIds,
4020
4020
  components: dashboardComponents,
4021
4021
  config: type === exports.WidgetType.Dashboard ? dashboardConfig : featureConfig,
4022
+ isEditing: type === exports.WidgetType.Dashboard ? projectEditMode : featureEditMode,
4022
4023
  isLoading: type === exports.WidgetType.Dashboard ? projectLoading : featureLoading,
4023
4024
  pageIndex: type === exports.WidgetType.Dashboard ? projectPageIndex || 1 : featurePageIndex || 1,
4024
4025
  filters: type === exports.WidgetType.Dashboard ? projectFilters : featureFilters,
@@ -7771,33 +7772,30 @@ const ElementChips = React.memo(({ type, elementConfig }) => {
7771
7772
  const ElementControl = ({ elementConfig }) => {
7772
7773
  const { t } = useGlobalContext();
7773
7774
  const { dataSources, filters, changeFilters } = useWidgetContext(exports.WidgetType.FeatureCard);
7775
+ const [value, setValue] = React.useState();
7774
7776
  const { options, attributeName } = elementConfig || {};
7775
7777
  const { filterName, relatedDataSource, label, placeholder = t("selectValue", { ns: "dashboard", defaultValue: "Выберите значение" }) } = options || {};
7776
- // Получаем данные из datasource
7777
7778
  const dataSource = React.useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
7778
- // Формируем опции для dropdown из features datasource
7779
7779
  const items = React.useMemo(() => {
7780
7780
  if (!dataSource?.features?.length || !attributeName) {
7781
7781
  return [];
7782
7782
  }
7783
- return dataSource.features.map((feature, index) => ({
7784
- id: feature.id || index,
7785
- value: feature.attributes?.[attributeName] || "",
7786
- label: feature.attributes?.[attributeName] || "",
7783
+ return dataSource.features.map(({ attributes }) => ({
7784
+ value: attributes?.[attributeName] || "",
7785
+ text: attributes?.[attributeName] || "",
7787
7786
  }));
7788
- }, [dataSource, attributeName]);
7789
- // Получаем текущее выбранное значение
7790
- const selectedItem = React.useMemo(() => items.find(opt => opt.value === filters?.[filterName]?.value), [items, filters, filterName]);
7791
- const handleChange = React.useCallback((option) => {
7792
- if (changeFilters && filterName) {
7793
- changeFilters({
7787
+ }, [dataSource?.features, attributeName]);
7788
+ const handleChange = React.useCallback(([option]) => {
7789
+ setValue(option?.value);
7790
+ if (filterName) {
7791
+ changeFilters?.({
7794
7792
  [filterName]: {
7795
- value: option?.value || null,
7793
+ value: option?.value,
7796
7794
  },
7797
7795
  });
7798
7796
  }
7799
7797
  }, [changeFilters, filterName]);
7800
- return (jsxRuntime.jsx(uilibGl.Dropdown, { label: label, options: items, value: selectedItem, onChange: handleChange, width: "100%", placeholder: placeholder }));
7798
+ return (jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, width: "100%", label: label, options: items, value: filters?.[filterName]?.value ?? value, placeholder: placeholder, onChange: handleChange }));
7801
7799
  };
7802
7800
 
7803
7801
  const StyledIconFontSizeMixin = styled.css `
@@ -9620,11 +9618,16 @@ const tooltipValueFromRelatedFeatures = (t, value, relatedAttributes, layerInfo)
9620
9618
  };
9621
9619
 
9622
9620
  const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
9623
- const { config: configProp, containerIds, projectInfo, layerInfo } = useWidgetContext(type);
9621
+ const { config: configProp, containerIds, projectInfo, layerInfo, isEditing } = useWidgetContext(type);
9624
9622
  const config = React.useMemo(() => {
9625
9623
  if (configProp) {
9626
9624
  return configProp;
9627
9625
  }
9626
+ if (isEditing) {
9627
+ return type === exports.WidgetType.Dashboard
9628
+ ? (projectInfo?.content?.editConfiguration || {})
9629
+ : (layerInfo?.configuration?.editConfiguration || {});
9630
+ }
9628
9631
  const currentConfig = type === exports.WidgetType.Dashboard
9629
9632
  ? (projectInfo?.content?.dashboardConfiguration || {})
9630
9633
  : (layerInfo?.configuration?.cardConfiguration || {});
@@ -9640,14 +9643,10 @@ const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
9640
9643
  return newConfig;
9641
9644
  }
9642
9645
  return currentConfig;
9643
- }, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
9644
- const editConfig = React.useMemo(() => type === exports.WidgetType.Dashboard
9645
- ? (projectInfo?.content?.editConfiguration || {})
9646
- : (layerInfo?.configuration?.editConfiguration || {}), []);
9646
+ }, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type, isEditing]);
9647
9647
  const pages = React.useMemo(() => (getPagesFromConfig(config) || []), [config]);
9648
9648
  return {
9649
9649
  config,
9650
- editConfig,
9651
9650
  pages,
9652
9651
  };
9653
9652
  };
@@ -10384,20 +10383,17 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
10384
10383
  return (jsxRuntime.jsxs(Tooltip, { children: [jsxRuntime.jsx(ChartTooltipLabel, { children: labels[indexX] }), items
10385
10384
  .filter(({ value }) => !isEmptyValue(value))
10386
10385
  ?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
10387
- const layerInfo = !attributeUnits
10388
- ? layerInfos?.find(({ name }) => name === layerName)
10389
- : null;
10390
- const attribute = !attributeUnits
10391
- ? layerInfo?.layerDefinition.attributes[attributeName]
10392
- : null;
10393
- const dataSource = dataSourceName ? getDataSource(dataSourceName, dataSources) : null;
10394
- const dataSourceUnits = !dataSource || !attributeUnits
10395
- ? null
10396
- : dataSource.features?.[0]?.attributes?.[attributeUnits];
10397
- const legendValue = attribute
10398
- ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
10399
- : [value, dataSourceUnits].filter(Boolean).join(" ");
10400
- return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: legendValue })] }, index));
10386
+ const layerInfo = layerInfos?.find(({ name }) => name === layerName);
10387
+ const attribute = layerInfo?.layerDefinition.attributes[attributeName];
10388
+ const dataSource = getDataSource(dataSourceName, dataSources);
10389
+ const units = attributeUnits
10390
+ ? dataSource?.features?.[0]?.attributes?.[attributeUnits]
10391
+ : attribute?.stringFormat?.unitsLabel;
10392
+ const formatValue = attribute
10393
+ ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat, noUnits: true })
10394
+ : value;
10395
+ const resultValue = [formatValue, units].filter(Boolean).join(" ");
10396
+ return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: resultValue })] }, index));
10401
10397
  })] }));
10402
10398
  }, [labels, layerInfos, dataSources, dotSnapping]);
10403
10399
  const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
@@ -10543,7 +10539,7 @@ const DashboardLoading = React.memo(() => {
10543
10539
  return (jsxRuntime.jsx(Container, { noBorders: true, children: jsxRuntime.jsx(ContainerWrapper, { "$noMargin": true, children: jsxRuntime.jsx(DashboardWrapper, { children: jsxRuntime.jsx(DashboardPlaceholderWrap, { children: jsxRuntime.jsxs(DashboardPlaceholder, { isLoading: true, children: [jsxRuntime.jsx(uilibGl.Icon, { kind: "dashboard_loading" }), jsxRuntime.jsx(uilibGl.Flex, { width: "8rem", children: jsxRuntime.jsx(uilibGl.LinearProgress, {}) })] }) }) }) }) }));
10544
10540
  });
10545
10541
 
10546
- const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, config, noBorders }) => {
10542
+ const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, noBorders }) => {
10547
10543
  const { dataSources, isLoading } = useWidgetContext(type);
10548
10544
  const { currentPage } = useWidgetPage(type);
10549
10545
  const isDiffPage = useDiffPage(type);
@@ -10551,7 +10547,7 @@ const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, config, noB
10551
10547
  if (dataSourceLoading || isDiffPage) {
10552
10548
  return (jsxRuntime.jsx(DashboardLoading, {}));
10553
10549
  }
10554
- return (jsxRuntime.jsx(PagesContainer, { type: type, config: config, noBorders: noBorders }));
10550
+ return (jsxRuntime.jsx(PagesContainer, { type: type, noBorders: noBorders }));
10555
10551
  });
10556
10552
 
10557
10553
  const CardCheckbox = styled(uilibGl.Checkbox) `