@evergis/react 3.1.19 → 3.1.21

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.
package/dist/react.esm.js CHANGED
@@ -3719,17 +3719,19 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
3719
3719
  };
3720
3720
  const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false }) => {
3721
3721
  if (type === AttributeType.Point) {
3722
- if (!(stringFormat && stringFormat.format) || !value)
3722
+ if (!stringFormat?.format || !value)
3723
3723
  return null;
3724
3724
  const { coordinates } = value;
3725
3725
  return formatPointValue({ t, stringFormat, value: coordinates });
3726
3726
  }
3727
3727
  if (type === AttributeType.DateTime) {
3728
- if (!(stringFormat && stringFormat.format) || !value)
3728
+ if (!stringFormat?.format || !value)
3729
3729
  return null;
3730
3730
  return formatDateValue(stringFormat, value);
3731
3731
  }
3732
3732
  if (numberFormatTypes.includes(type) && !isNaN(value)) {
3733
+ if (!stringFormat?.format)
3734
+ return value.toString();
3733
3735
  return formatNumberValue(stringFormat, value, type, noUnits);
3734
3736
  }
3735
3737
  if (type === AttributeType.Json) {
@@ -6465,16 +6467,22 @@ const RoundedBackgroundContainer = memo(({ type, elementConfig, feature, renderE
6465
6467
  });
6466
6468
  const { options, style, children } = elementConfig || {};
6467
6469
  const { maxLength, center, fontColor, innerTemplateStyle, inlineUnits, big, bigIcon, hideEmpty, colorAttribute } = options || {};
6470
+ const iconElement = children?.find(({ id }) => id === "icon");
6468
6471
  const aliasElement = children?.find(({ id }) => id === "alias");
6469
6472
  const unitsElement = children?.find(({ id }) => id === "units");
6470
6473
  const valueElement = children?.find(({ id }) => id === "value");
6471
6474
  const value = renderElement({ id: "value" });
6472
6475
  const color = useMemo(() => attributes?.find(({ name }) => name === colorAttribute)?.value || fontColor, [attributes, colorAttribute, fontColor]);
6476
+ const renderIcon = useMemo(() => {
6477
+ if (!iconElement)
6478
+ return null;
6479
+ return (jsx(FlexSpan, { width: iconElement.options?.width || "1rem", alignItems: "center", mr: "0.5rem", children: renderElement({ id: "icon", wrap: false }) }));
6480
+ }, [iconElement, renderElement]);
6473
6481
  const renderAlias = useMemo(() => (jsx(ContainerAlias, { style: aliasElement?.style, children: jsx(TextTrim, { maxLength: maxLength || ALIAS_DEFAULT_MAX_LENGTH, children: renderElement({ id: "alias", wrap: false }) }) })), [aliasElement?.style, maxLength, renderElement]);
6474
6482
  const renderValue = useMemo(() => (jsxs(ContainerValue, { style: valueElement?.style, big: true, children: [value, !!unitsElement && (jsx(ContainerUnits, { style: unitsElement?.style, children: renderElement({ id: "units" }) }))] })), [valueElement?.style, value, unitsElement, renderElement]);
6475
6483
  if (!value && hideEmpty)
6476
6484
  return null;
6477
- return (jsxs(RoundedBackgroundContainerWrapper, { style: innerTemplateStyle || style, "$center": center, "$color": color, "$inlineUnits": inlineUnits, "$big": big, "$bigIcon": bigIcon, children: [jsxs(ContainerIconValue, { children: [renderElement({ id: "icon", wrap: false }), big ? renderAlias : renderValue] }), big ? renderValue : renderAlias] }));
6485
+ return (jsxs(RoundedBackgroundContainerWrapper, { style: innerTemplateStyle || style, "$center": center, "$color": color, "$inlineUnits": inlineUnits, "$big": big, "$bigIcon": bigIcon, children: [jsxs(ContainerIconValue, { children: [renderIcon, big ? renderAlias : renderValue] }), big ? renderValue : renderAlias] }));
6478
6486
  });
6479
6487
 
6480
6488
  const AddFeatureContainer = memo(({ elementConfig }) => {
@@ -9185,6 +9193,9 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
9185
9193
  const formatTooltipValue = useCallback((value, name) => isRelated
9186
9194
  ? tooltipValueFromRelatedFeatures(t, value, relatedAttributes, data[0]?.layerInfo)
9187
9195
  : tooltipValueFromAttributes(t, value, name, formattedAttributes), [data, formattedAttributes, isRelated, relatedAttributes]);
9196
+ const customYAxisLeft = useCallback(yAxisLeft => {
9197
+ yAxisLeft.tickFormat((index) => index);
9198
+ }, []);
9188
9199
  const customXAxisBottom = useCallback((xAxisBottom, data) => {
9189
9200
  xAxisBottom.tickFormat((index) => (showMarkers
9190
9201
  ? index % (showMarkers || 1) === 0
@@ -9238,12 +9249,13 @@ const Chart = memo(({ config, element, elementConfig, type, renderElement }) =>
9238
9249
  bottom: markers?.length ? 20 : markersMargin,
9239
9250
  left: markersMargin
9240
9251
  };
9241
- return (jsx(BarChartWrapper, { height: height + margin.bottom, children: jsx(BarChartContainer, { children: 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, className: "dashboardBarChart", customXAxisBottom: xAxisBottom => customXAxisBottom(xAxisBottom, barChartData), customYAxis: axis => !showLabels && axis.remove(), customBars: ({ bars }) => {
9252
+ return (jsx(BarChartWrapper, { height: height + margin.bottom, children: jsx(BarChartContainer, { children: 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 }) => {
9242
9253
  bars.attr("rx", radius);
9243
9254
  bars.attr("ry", radius);
9244
9255
  }, margin: margin, xAxisPadding: 0, yAxisPadding: 0, formatTooltipValue: formatTooltipValue, formatTooltipName: formatTooltipName, hideTooltipGroupName: true, dynamicTooltipEnable: true, isBarTooltip: true, onBarClick: filterName ? item => onFilter(item.name) : undefined }) }) }));
9245
9256
  }, [
9246
9257
  customXAxisBottom,
9258
+ customYAxisLeft,
9247
9259
  element,
9248
9260
  isLineChart,
9249
9261
  isStackBar,