@evergis/react 3.1.129-alpha.2 → 3.1.129-alpha.4

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,2 +1,2 @@
1
- import { AttributesConfigurationDc, ServiceInfoDc } from '@evergis/api';
2
- export declare const getAttributesConfiguration: (layer: ServiceInfoDc) => AttributesConfigurationDc;
1
+ import { AttributesConfigurationDc, QueryLayerServiceInfoDc } from '@evergis/api';
2
+ export declare const getAttributesConfiguration: (layer: QueryLayerServiceInfoDc) => AttributesConfigurationDc;
@@ -2,7 +2,5 @@ import { ProxyServiceInfoDc, QueryLayerServiceInfoDc, ServiceInfoDc } from '@eve
2
2
  import { ProxyServiceInfo } from '../../../types';
3
3
  export declare const isCompositeLayerConfiguration: (value?: unknown) => value is ServiceInfoDc;
4
4
  export declare const isProxyService: (value?: unknown) => value is ProxyServiceInfoDc;
5
- export declare const getProxyService: (layer?: ServiceInfoDc) => ProxyServiceInfo;
6
- export declare function getLayerInfo(layer?: ServiceInfoDc & {
7
- type?: string;
8
- }): QueryLayerServiceInfoDc;
5
+ export declare const getProxyService: (layer?: QueryLayerServiceInfoDc) => ProxyServiceInfo;
6
+ export declare function getLayerInfo(layer?: QueryLayerServiceInfoDc): QueryLayerServiceInfoDc;
package/dist/index.js CHANGED
@@ -3474,7 +3474,7 @@ const StackBarSection = styled.div `
3474
3474
  margin: 0 0.5px;
3475
3475
  background-color: ${({ $color }) => $color};
3476
3476
  opacity: ${({ hasAnyFilter, isFiltered }) => (isFiltered ? 1 : hasAnyFilter ? FILTERED_VALUE_OPACITY / 100 : 1)};
3477
- transition: opacity ${uilibGl.transition.release};
3477
+ transition: opacity ${uilibGl.transition.release}, background-color ${uilibGl.transition.release};
3478
3478
 
3479
3479
  :first-child {
3480
3480
  border-top-left-radius: ${({ cornerRadius }) => (cornerRadius ? `${cornerRadius}px` : "0.5rem")};
@@ -4426,7 +4426,7 @@ const getAttributesConfiguration = (layer) => {
4426
4426
  const configuration = layer?.configuration ??
4427
4427
  {};
4428
4428
  const emptyAttributesConfiguration = {
4429
- geometryAttribute: layer?.geometryType === api.OgcGeometryType.Unknown
4429
+ geometryAttribute: layer?.layerDefinition?.geometryType === api.OgcGeometryType.Unknown
4430
4430
  ? undefined
4431
4431
  : GEOMETRY_ATTRIBUTE,
4432
4432
  idAttribute: DEFAULT_ID_ATTRIBUTE_NAME,
@@ -4437,8 +4437,7 @@ const getAttributesConfiguration = (layer) => {
4437
4437
  }
4438
4438
  return {
4439
4439
  ...emptyAttributesConfiguration,
4440
- ...(configuration
4441
- .attributesConfiguration || {}),
4440
+ ...(configuration.attributesConfiguration || {}),
4442
4441
  };
4443
4442
  };
4444
4443
 
@@ -7811,8 +7810,8 @@ const HeaderTitle = ({ noFeature }) => {
7811
7810
  const { t } = useGlobalContext();
7812
7811
  const { attributes, layerInfo, feature } = useWidgetContext(exports.WidgetType.FeatureCard);
7813
7812
  const zoomToFeatures = useZoomToFeatures();
7814
- const { alias, name, layerDefinition } = layerInfo || {};
7815
- const resultDescription = alias || name || "";
7813
+ const { configuration, layerDefinition } = layerInfo || {};
7814
+ const resultDescription = configuration?.alias || configuration?.name || "";
7816
7815
  const resultTitle = React.useMemo(() => {
7817
7816
  const layerDefinitionAttribute = layerDefinition && attributes?.length
7818
7817
  ? attributes.find(item => item.name === layerDefinition.titleAttribute)
@@ -7860,10 +7859,10 @@ var img = "data:image/svg+xml,%3csvg width='32' height='32' viewBox='0 0 32 32'
7860
7859
 
7861
7860
  const LayerIcon = ({ layerInfo, error }) => {
7862
7861
  const renderSymbol = React.useMemo(() => {
7863
- if (!layerInfo.geometryType || error) {
7862
+ if (!layerInfo?.layerDefinition?.geometryType || error) {
7864
7863
  return (jsxRuntime.jsx(AlertIconContainer, { children: jsxRuntime.jsx(uilibGl.Icon, { kind: "warning" }) }));
7865
7864
  }
7866
- switch (layerInfo.geometryType) {
7865
+ switch (layerInfo?.layerDefinition?.geometryType) {
7867
7866
  case api.OgcGeometryType.MultiLineString:
7868
7867
  return jsxRuntime.jsx("img", { src: img$1, alt: "" });
7869
7868
  case api.OgcGeometryType.Polygon:
@@ -7873,7 +7872,7 @@ const LayerIcon = ({ layerInfo, error }) => {
7873
7872
  default:
7874
7873
  return jsxRuntime.jsx("img", { src: img$2, alt: "" });
7875
7874
  }
7876
- }, [layerInfo.geometryType]);
7875
+ }, [layerInfo?.layerDefinition?.geometryType]);
7877
7876
  return jsxRuntime.jsx(LayerIconContainer, { children: renderSymbol });
7878
7877
  };
7879
7878
 
@@ -10174,21 +10173,21 @@ const getProxyService = (layer) => {
10174
10173
  if (!isProxyService(layer))
10175
10174
  return {
10176
10175
  layers: [],
10177
- sourceType: "",
10178
10176
  sourceUrl: "",
10179
- copyrightText: "",
10177
+ sourceType: "",
10178
+ layerDefinition: layer?.layerDefinition,
10180
10179
  legend: {
10181
10180
  layers: [],
10182
10181
  },
10183
10182
  };
10184
- const { layers, sourceType, sourceUrl, legend, copyrightText } = layer;
10183
+ const { layers, sourceType, sourceUrl, legend, layerDefinition } = layer;
10185
10184
  return {
10186
10185
  layers: layers || [],
10187
- copyrightText: copyrightText || "",
10188
10186
  sourceUrl: sourceUrl || "",
10189
10187
  sourceType: sourceType || "",
10188
+ layerDefinition,
10190
10189
  legend: {
10191
- layers: (legend && legend.layers) || [],
10190
+ layers: legend?.layers || [],
10192
10191
  },
10193
10192
  };
10194
10193
  };
@@ -11090,8 +11089,9 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11090
11089
  const isRelated = !!relatedAttributes?.length;
11091
11090
  const { data, loading } = useChartData({ element, type });
11092
11091
  const totalWidthFromBarWidth = (data[0]?.items?.length || 0) * (barWidth + padding);
11093
- const width = options?.width ? options.width :
11094
- isStackBar
11092
+ const width = options?.width
11093
+ ? options.width
11094
+ : isStackBar
11095
11095
  ? "100%"
11096
11096
  : isBarChart
11097
11097
  ? totalWidthFromBarWidth || MAX_CHART_WIDTH
@@ -11113,21 +11113,24 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11113
11113
  ? getTotalFromRelatedFeatures((data[0]?.items || []))
11114
11114
  : getTotalFromAttributes(children, formattedAttributes), [data, children, formattedAttributes, isRelated]);
11115
11115
  const totalWord = React.useMemo(() => totalAttribute
11116
- ? attributes?.find(({ name }) => name === totalAttribute)?.value
11116
+ ? attributes?.find(({ name }) => name === totalAttribute)
11117
+ ?.value
11117
11118
  : configTotalWord, [attributes, totalAttribute, configTotalWord]);
11118
11119
  const renderPieChartTooltip = React.useCallback(item => isRelated
11119
11120
  ? pieChartTooltipFromRelatedFeatures(t, item, relatedAttributes, data[0]?.layerInfo)
11120
- : pieChartTooltipFromAttributes(t, item, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes]);
11121
+ : pieChartTooltipFromAttributes(t, item, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes, t]);
11121
11122
  const labels = React.useMemo(() => {
11122
11123
  if (!isLineChart)
11123
11124
  return [];
11124
- const result = data?.map(item => item?.items?.map(({ name }) => name?.toString()))?.flat();
11125
+ const result = data
11126
+ ?.map(item => item?.items?.map(({ name }) => name?.toString()))
11127
+ ?.flat();
11125
11128
  return result?.filter((name, index) => result.indexOf(name) === index);
11126
11129
  }, [data, isLineChart]);
11127
11130
  const renderLineChartTooltip = React.useCallback((items, { indexX }) => {
11128
11131
  return (jsxRuntime.jsxs(Tooltip, { children: [jsxRuntime.jsx(ChartTooltipLabel, { children: labels[indexX] }), items
11129
11132
  .filter(({ value }) => !isEmptyValue(value))
11130
- ?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
11133
+ ?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke, }, index) => {
11131
11134
  const layerInfo = layerInfos?.find(({ name }) => name === layerName);
11132
11135
  const attribute = layerInfo?.layerDefinition.attributes[attributeName];
11133
11136
  const dataSource = getDataSource(dataSourceName, dataSources);
@@ -11135,12 +11138,20 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11135
11138
  ? dataSource?.features?.[0]?.properties?.[attributeUnits]
11136
11139
  : attribute?.stringFormat?.unitsLabel;
11137
11140
  const formatValue = attribute
11138
- ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat, noUnits: true })
11141
+ ? formatAttributeValue({
11142
+ t,
11143
+ type: attribute.type,
11144
+ value,
11145
+ stringFormat: attribute.stringFormat,
11146
+ noUnits: true,
11147
+ })
11139
11148
  : value;
11140
- const resultValue = [formatValue, units].filter(Boolean).join(" ");
11149
+ const resultValue = [formatValue, units]
11150
+ .filter(Boolean)
11151
+ .join(" ");
11141
11152
  return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: resultValue })] }, index));
11142
11153
  })] }));
11143
- }, [labels, layerInfos, dataSources, dotSnapping]);
11154
+ }, [labels, layerInfos, dataSources, t]);
11144
11155
  const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
11145
11156
  const margin = React.useMemo(() => {
11146
11157
  const markersMargin = showMarkers ? 10 : 0;
@@ -11148,23 +11159,23 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11148
11159
  top: markersMargin,
11149
11160
  right: markersMargin,
11150
11161
  bottom: markers?.length ? 20 : markersMargin,
11151
- left: markersMargin
11162
+ left: markersMargin,
11152
11163
  };
11153
11164
  }, [showMarkers, markers?.length]);
11154
- const formatTooltipName = React.useCallback((name) => (isRelated ? name : tooltipNameFromAttributes(name, formattedAttributes)), [formattedAttributes, isRelated]);
11165
+ const formatTooltipName = React.useCallback((name) => isRelated ? name : tooltipNameFromAttributes(name, formattedAttributes), [formattedAttributes, isRelated]);
11155
11166
  const formatTooltipValue = React.useCallback((value, name) => isRelated
11156
11167
  ? tooltipValueFromRelatedFeatures(t, value, relatedAttributes, data[0]?.layerInfo)
11157
- : tooltipValueFromAttributes(t, value, name, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes]);
11168
+ : tooltipValueFromAttributes(t, value, name, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes, t]);
11158
11169
  const customYAxisLeft = React.useCallback(yAxisLeft => {
11159
11170
  yAxisLeft.tickFormat((index) => index);
11160
11171
  }, []);
11161
- const customXAxisBottom = React.useCallback((xAxisBottom, data) => {
11172
+ const customXAxisBottom = React.useCallback((xAxisBottom, xAxisData) => {
11162
11173
  xAxisBottom.tickFormat((index) => markers
11163
11174
  ? ""
11164
11175
  : (showMarkers
11165
11176
  ? index % showMarkers === 0
11166
- : index === 0 || index === data.length - 1)
11167
- ? data[index]?.groupName || ""
11177
+ : index === 0 || index === xAxisData.length - 1)
11178
+ ? xAxisData[index]?.groupName || ""
11168
11179
  : "");
11169
11180
  }, [markers, showMarkers]);
11170
11181
  const renderChart = React.useMemo(() => {
@@ -11179,7 +11190,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11179
11190
  stroke: item.color || primaryColor,
11180
11191
  values: item.items
11181
11192
  ?.filter(({ value }) => !isEmptyValue(value))
11182
- ?.map(({ value }) => Number(value))
11193
+ ?.map(({ value }) => Number(value)),
11183
11194
  }));
11184
11195
  const isHidedY = axes.every(({ hideAxis }) => hideAxis);
11185
11196
  const chartValues = lineChartData
@@ -11200,8 +11211,8 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11200
11211
  ?.filter(({ value }) => !isEmptyValue(value))
11201
11212
  ?.map(item => ({
11202
11213
  ...item,
11203
- color: formatFilterColor(item.name, item.color, defaultColor)
11204
- })) || []), width: +width, height: +width, padAngle: angle, outerRadius: radius, cornerRadius: cornerRadius, renderTooltip: renderPieChartTooltip, withTooltip: true, onClick: filterName ? item => onFilter(item.name) : undefined, children: showTotal && jsxRuntime.jsx(PieChartCenter, { children: totalWord || roundTotalSum(+totalSum) }) }) }));
11214
+ color: formatFilterColor(item.name, item.color, defaultColor),
11215
+ })) || []), width: +width, height: +width, padAngle: angle, outerRadius: radius, cornerRadius: cornerRadius, renderTooltip: renderPieChartTooltip, withTooltip: true, onClick: filterName ? item => onFilter(item.name) : undefined, children: showTotal && (jsxRuntime.jsx(PieChartCenter, { children: totalWord || roundTotalSum(+totalSum) })) }) }));
11205
11216
  }
11206
11217
  const barChartData = getDataFromFilterItems(data[0]?.items);
11207
11218
  return (jsxRuntime.jsx(BarChartWrapper, { height: height + margin.bottom, children: jsxRuntime.jsx(BarChartContainer, { children: jsxRuntime.jsx(StyledBarChart, { data: barChartData, colors: getColorsFromFilterItems(data[0]?.items, defaultColor, formatFilterColor), minValue: getMinValueFromFilterItems(data[0]?.items), markers: markers, width: +width, height: height, barWidth: barWidth, barPadding: padding, customYAxisLeft: customYAxisLeft, customXAxisBottom: xAxisBottom => customXAxisBottom(xAxisBottom, barChartData), customYAxis: axis => !showLabels && axis.remove(), customBars: ({ bars }) => {
@@ -11245,7 +11256,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11245
11256
  showTotal,
11246
11257
  totalWord,
11247
11258
  totalSum,
11248
- onFilter
11259
+ onFilter,
11249
11260
  ]);
11250
11261
  if (!isVisibleContainer(id, expandable, expanded, expandedContainers))
11251
11262
  return null;
@@ -11344,8 +11355,8 @@ const FeatureCardHeader = () => {
11344
11355
  const FeatureCardTitle = ({ title, description }) => {
11345
11356
  const { t } = useGlobalContext();
11346
11357
  const { attributes, layerInfo, feature } = useWidgetContext(exports.WidgetType.FeatureCard);
11347
- const { alias, name, layerDefinition } = layerInfo || {};
11348
- const resultDescription = description || alias || name || "";
11358
+ const { configuration, layerDefinition } = layerInfo || {};
11359
+ const resultDescription = description || configuration?.alias || configuration?.name || "";
11349
11360
  const resultTitle = React.useMemo(() => {
11350
11361
  const layerDefinitionAttribute = layerDefinition && attributes?.length
11351
11362
  ? attributes.find(item => item.name === layerDefinition.titleAttribute)