@evergis/react 3.1.17 → 3.1.19

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
@@ -3944,13 +3944,18 @@ const useWidgetContext = (type = WidgetType.Dashboard) => {
3944
3944
 
3945
3945
  const useGlobalContext = () => {
3946
3946
  const { t, language, themeName, api, ewktGeometry } = useContext(GlobalContext) || {};
3947
+ const translate = useCallback((value, options) => {
3948
+ if (t)
3949
+ return t(value, options);
3950
+ return options?.defaultValue ?? value;
3951
+ }, [t]);
3947
3952
  return useMemo(() => ({
3948
- t,
3953
+ t: translate,
3949
3954
  language,
3950
3955
  themeName,
3951
3956
  api,
3952
3957
  ewktGeometry,
3953
- }), [language, t, api, ewktGeometry, themeName]);
3958
+ }), [language, translate, api, ewktGeometry, themeName]);
3954
3959
  };
3955
3960
 
3956
3961
  const HEIGHT_OFFSET = 20;
@@ -5668,7 +5673,7 @@ const DataSourceProgressContainer = memo(({ config, elementConfig, type, innerCo
5668
5673
  return jsx(DataSourceError, { name: elementConfig.templateName });
5669
5674
  }
5670
5675
  const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
5671
- return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), !isVisible ? null : dataSource ? (jsxs(DataSourceProgressContainerWrapper, { children: [sliceItems(dataSource?.features)?.map((feature, index) => (jsx(DataSourceInnerContainer, { type: type, index: index, feature: feature, config: config, elementConfig: elementConfig, maxValue: currentMaxValue, innerComponent: innerComponent }, index))), checkIsSliced(dataSource?.features) && (jsx(ContainerToggler, { toggled: showMore, onClick: onShowMore, children: showMore ? t("hide", { ns: "dashboard" }) : t("showAll", { ns: "dashboard" }) })), showTotal && (jsxs(Fragment$1, { children: [jsx(Divider, {}), jsxs(ProgressTotal, { children: [jsx(ProgressTotalTitle, { children: t("total", { ns: "dashboard" }) }), jsxs(ProgressValue, { children: [totalValue, jsx(ProgressUnits, { children: totalUnits })] })] })] }))] })) : (jsx(ContainerLoading, {})), jsx(HiddenTitleItems, { elementConfig: elementConfig, config: config, type: type })] }));
5676
+ return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), !isVisible ? null : dataSource ? (jsxs(DataSourceProgressContainerWrapper, { children: [sliceItems(dataSource?.features)?.map((feature, index) => (jsx(DataSourceInnerContainer, { type: type, index: index, feature: feature, config: config, elementConfig: elementConfig, maxValue: currentMaxValue, innerComponent: innerComponent }, index))), checkIsSliced(dataSource?.features) && (jsx(ContainerToggler, { toggled: showMore, onClick: onShowMore, children: showMore ? t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) : t("showAll", { ns: "dashboard", defaultValue: "Показать все" }) })), showTotal && (jsxs(Fragment$1, { children: [jsx(Divider, {}), jsxs(ProgressTotal, { children: [jsx(ProgressTotalTitle, { children: t("total", { ns: "dashboard", defaultValue: "Итого" }) }), jsxs(ProgressValue, { children: [totalValue, jsx(ProgressUnits, { children: totalUnits })] })] })] }))] })) : (jsx(ContainerLoading, {})), jsx(HiddenTitleItems, { elementConfig: elementConfig, config: config, type: type })] }));
5672
5677
  });
5673
5678
 
5674
5679
  const ProgressContainer = memo(({ type, elementConfig, feature, maxValue, index, renderElement }) => {
@@ -5703,7 +5708,7 @@ const ProgressContainer = memo(({ type, elementConfig, feature, maxValue, index,
5703
5708
  id: "icon",
5704
5709
  wrap: false
5705
5710
  }), [renderElement]);
5706
- const renderTooltip = useMemo(() => (jsxs(Fragment$1, { children: [jsx(ProgressTooltipAlias, { children: renderTooltipAlias }), jsxs(ProgressTooltipValueContainer, { children: [jsx(ProgressTooltipValue, { children: renderTooltipValue }), jsx(ProgressTooltipValueOf, { children: t("of", { ns: "dashboard" }) }), jsx("div", { children: formatAttributeValue({ t, type: valueType, value: currentMaxValue, stringFormat }) })] })] })), [currentMaxValue, renderTooltipAlias, renderTooltipValue, stringFormat, t, valueType]);
5711
+ const renderTooltip = useMemo(() => (jsxs(Fragment$1, { children: [jsx(ProgressTooltipAlias, { children: renderTooltipAlias }), jsxs(ProgressTooltipValueContainer, { children: [jsx(ProgressTooltipValue, { children: renderTooltipValue }), jsx(ProgressTooltipValueOf, { children: t("of", { ns: "dashboard", defaultValue: "из" }) }), jsx("div", { children: formatAttributeValue({ t, type: valueType, value: currentMaxValue, stringFormat }) })] })] })), [currentMaxValue, renderTooltipAlias, renderTooltipValue, stringFormat, t, valueType]);
5707
5712
  const color = useMemo(() => colorAttribute
5708
5713
  ? attributes?.find(({ name }) => name === colorAttribute)?.value
5709
5714
  : colors?.[index] || bgColor, [attributes, bgColor, colorAttribute, colors, index]);
@@ -6757,7 +6762,7 @@ const HeaderTitle = ({ noFeature }) => {
6757
6762
  })) ||
6758
6763
  feature?.id);
6759
6764
  }, [attributes, feature, layerDefinition]);
6760
- return (jsxs(HeaderTitleContainer, { children: [noFeature ? (jsx(FeatureTitleContainer, { children: t("noObjectFound", { ns: "dashboard" }) })) : (jsx(FeatureTitleContainer, { clickable: true, children: jsx(Tooltip$1, { arrow: true, placement: "top", content: t("zoomToFeature", { ns: "dashboard" }), delay: [600, 0], children: ref => (jsx(FlexSpan, { ref: ref, onClick: () => zoomToFeatures([feature]), children: resultTitle })) }) })), jsx(LayerDescription, { title: resultDescription, children: resultDescription })] }));
6765
+ return (jsxs(HeaderTitleContainer, { children: [noFeature ? (jsx(FeatureTitleContainer, { children: t("noObjectFound", { ns: "dashboard", defaultValue: "Объектов не найдено" }) })) : (jsx(FeatureTitleContainer, { clickable: true, children: jsx(Tooltip$1, { arrow: true, placement: "top", content: t("zoomToFeature", { ns: "dashboard", defaultValue: "Приблизить к объекту" }), delay: [600, 0], children: ref => (jsx(FlexSpan, { ref: ref, onClick: () => zoomToFeatures([feature]), children: resultTitle })) }) })), jsx(LayerDescription, { title: resultDescription, children: resultDescription })] }));
6761
6766
  };
6762
6767
 
6763
6768
  const LayerIconContainer = styled.div `
@@ -7167,7 +7172,7 @@ const SmallPreview = ({ images, totalCount, currentIndex, isLoading, setCurrentI
7167
7172
  onNextPage();
7168
7173
  }
7169
7174
  }, [currentIndex, images, isNextDisabled, onNextPage, setCurrentIndex]);
7170
- return (jsxs(SmallPreviewContainer$1, { currentIndex: currentIndex + 1, prevIndex: prevIndex + 1, children: [isLoading && jsx(LinearProgress, {}), images.length > 1 && (jsxs(Fragment$1, { children: [jsx(SmallPreviewLeft, { "$isDisabled": isPrevDisabled, onClick: prev }), jsx(SmallPreviewRight, { "$isDisabled": isNextDisabled, onClick: next }), jsx(SmallPreviewCounter, { children: jsxs("div", { children: [currentIndex + 1, " ", t("of", { ns: "dashboard" }), " ", total] }) })] })), jsx(SmallPreviewImages, { onClick: onClick, children: images.map(image => (jsx("img", { src: image.src, alt: "" }, image.src))) })] }));
7175
+ return (jsxs(SmallPreviewContainer$1, { currentIndex: currentIndex + 1, prevIndex: prevIndex + 1, children: [isLoading && jsx(LinearProgress, {}), images.length > 1 && (jsxs(Fragment$1, { children: [jsx(SmallPreviewLeft, { "$isDisabled": isPrevDisabled, onClick: prev }), jsx(SmallPreviewRight, { "$isDisabled": isNextDisabled, onClick: next }), jsx(SmallPreviewCounter, { children: jsxs("div", { children: [currentIndex + 1, " ", t("of", { ns: "dashboard", defaultValue: "из" }), " ", total] }) })] })), jsx(SmallPreviewImages, { onClick: onClick, children: images.map(image => (jsx("img", { src: image.src, alt: "" }, image.src))) })] }));
7171
7176
  };
7172
7177
 
7173
7178
  const DEFAULT_ARCHIVED_PERIOD = "#24h";
@@ -7436,7 +7441,7 @@ const LocalLink = memo(({ link }) => {
7436
7441
  navigator.clipboard.writeText(link);
7437
7442
  toggleOpen();
7438
7443
  }, [link, toggleOpen]);
7439
- return (jsx(Popover, { open: isOpen, zIndex: 10, onRequestClose: toggleOpen, anchorOrigin: "bottom-right", targetOrigin: "top-right", anchor: jsx(LocalLinkButton, { onClick: toggleOpen }), children: jsxs(LocalLinkBlank, { children: [jsx("a", { href: link, target: "_blank", rel: "noreferrer", children: link }), jsx(LocalLinkCopy, { children: jsx(IconButton, { kind: "copy", onClick: onCopy, children: t("copy", { ns: "dashboard" }) }) })] }) }));
7444
+ return (jsx(Popover, { open: isOpen, zIndex: 10, onRequestClose: toggleOpen, anchorOrigin: "bottom-right", targetOrigin: "top-right", anchor: jsx(LocalLinkButton, { onClick: toggleOpen }), children: jsxs(LocalLinkBlank, { children: [jsx("a", { href: link, target: "_blank", rel: "noreferrer", children: link }), jsx(LocalLinkCopy, { children: jsx(IconButton, { kind: "copy", onClick: onCopy, children: t("copy", { ns: "dashboard", defaultValue: "Копировать" }) }) })] }) }));
7440
7445
  });
7441
7446
 
7442
7447
  const ElementLink = memo(({ type, elementConfig }) => {
@@ -7631,7 +7636,7 @@ const getDataFromAttributes = (t, config, attributes) => {
7631
7636
  return [
7632
7637
  ...data?.slice(0, config.options?.otherItems),
7633
7638
  {
7634
- name: t("other", { ns: "dashboard" }),
7639
+ name: t("other", { ns: "dashboard", defaultValue: "Другое" }),
7635
7640
  color: FEATURE_CARD_OTHER_COLOR,
7636
7641
  value: Number(otherValue)
7637
7642
  }
@@ -7694,7 +7699,7 @@ const getDataFromRelatedFeatures = ({ t, config, filters, relatedConfig, dataSou
7694
7699
  }, []);
7695
7700
  if (isOtherSliced) {
7696
7701
  result.push({
7697
- name: t("other", { ns: "dashboard" }),
7702
+ name: t("other", { ns: "dashboard", defaultValue: "Другое" }),
7698
7703
  color: FEATURE_CARD_OTHER_COLOR,
7699
7704
  value: Number(otherValue)
7700
7705
  });
@@ -7843,7 +7848,7 @@ const RangeNumberFilter = ({ type, filter }) => {
7843
7848
  const configFilter = getConfigFilter(filterName, configFilters);
7844
7849
  if (!configFilter)
7845
7850
  return null;
7846
- return (jsx(NumberRangeSlider, { value: value, min: minValue, max: maxValue, step: step || 1, sliderWidth: width ? `${width}px` : "17rem", label: label || t("interval", { ns: "dashboard" }), hasReset: true, onChange: setValue }));
7851
+ return (jsx(NumberRangeSlider, { value: value, min: minValue, max: maxValue, step: step || 1, sliderWidth: width ? `${width}px` : "17rem", label: label || t("interval", { ns: "dashboard", defaultValue: "Интервал" }), hasReset: true, onChange: setValue }));
7847
7852
  };
7848
7853
 
7849
7854
  const TextFilter = ({ type, filter, config }) => {
@@ -8023,7 +8028,7 @@ const CheckboxFilter = ({ type, filter, elementConfig }) => {
8023
8028
  });
8024
8029
  changeFilters({ [filterName]: { value } });
8025
8030
  } }, optionIndex));
8026
- }), showMoreBtn && (jsx(LegendToggler, { onClick: onShowMore, toggled: showMore, children: showMore ? t("hide", { ns: "dashboard" }) : t("showAll", { ns: "dashboard" }) }))] }));
8031
+ }), showMoreBtn && (jsx(LegendToggler, { onClick: onShowMore, toggled: showMore, children: showMore ? t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) : t("showAll", { ns: "dashboard", defaultValue: "Показать все" }) }))] }));
8027
8032
  };
8028
8033
 
8029
8034
  const ChartLoading = ({ column }) => (jsx(Flex, { position: "absolute", width: "100%", height: "inherit", children: jsx(Flex, { justifyContent: "center", alignContent: "center", alignItems: "center", width: "100%", height: "inherit", marginRight: column || column === undefined ? 0 : "-2rem", children: jsx(CircularProgress, { diameter: 1.5, mono: true }) }) }));
@@ -8315,7 +8320,7 @@ const RangeDateFilter = ({ type, filter }) => {
8315
8320
  }, [value]); // eslint-disable-line
8316
8321
  if (!configFilter)
8317
8322
  return null;
8318
- return (jsx(RangeNumberInput, { label: label || t("interval", { ns: "dashboard" }), selectedOption: { range: true }, minDate: getDate(minDate), maxDate: getDate(maxDate), value: [getDate(value[0]), getDate(value[1])], zIndex: 100, prefix: jsx(Icon, { kind: "date", disabled: true }), suffix: !isEmpty && !isDefault && jsx(StyledIconButton, { kind: "error", onClick: reset }), withTime: withTime, isDate: true, onChange: onChange }));
8323
+ return (jsx(RangeNumberInput, { label: label || t("interval", { ns: "dashboard", defaultValue: "Интервал" }), selectedOption: { range: true }, minDate: getDate(minDate), maxDate: getDate(maxDate), value: [getDate(value[0]), getDate(value[1])], zIndex: 100, prefix: jsx(Icon, { kind: "date", disabled: true }), suffix: !isEmpty && !isDefault && jsx(StyledIconButton, { kind: "error", onClick: reset }), withTime: withTime, isDate: true, onChange: onChange }));
8319
8324
  };
8320
8325
 
8321
8326
  const getFilterComponent = (filterType) => {
@@ -8384,8 +8389,8 @@ const getFormattedAttributes = (t, data, attributes, config) => {
8384
8389
  ...attributes,
8385
8390
  {
8386
8391
  ...otherAttribute,
8387
- name: t("other", { ns: "dashboard" }),
8388
- alias: t("other", { ns: "dashboard" })
8392
+ name: t("other", { ns: "dashboard", defaultValue: "Другое" }),
8393
+ alias: t("other", { ns: "dashboard", defaultValue: "Другое" })
8389
8394
  }
8390
8395
  ]
8391
8396
  : attributes;
@@ -8630,7 +8635,7 @@ const useWidgetPage = (type = WidgetType.Dashboard) => {
8630
8635
  const pages = getPagesFromProjectInfo(newProjectInfo);
8631
8636
  if (!pages)
8632
8637
  return;
8633
- pages.push(createConfigPage({ pages, defaultTitle: t("page", { ns: "dashboard" }) }));
8638
+ pages.push(createConfigPage({ pages, defaultTitle: t("page", { ns: "dashboard", defaultValue: "Страница" }) }));
8634
8639
  updateProject(newProjectInfo);
8635
8640
  changePage(pages.length);
8636
8641
  }, [changePage, projectInfo, t, updateProject]);
@@ -9288,7 +9293,7 @@ const ChartLegend = ({ data, chartElement, type, twoColumns, loading }) => {
9288
9293
  const showMoreBtn = !!shownItems && data.length > shownItems;
9289
9294
  if (!loading && !data?.length && !!hideEmpty)
9290
9295
  return null;
9291
- return (jsxs(Flex, { flexDirection: "column", opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsx(ChartLegendColor, { color: color }), jsx(ChartLegendName, { "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsx(LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard" }) }))] }));
9296
+ return (jsxs(Flex, { flexDirection: "column", opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsx(ChartLegendColor, { color: color }), jsx(ChartLegendName, { "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsx(LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard", defaultValue: "Другое" }) }))] }));
9292
9297
  };
9293
9298
 
9294
9299
  const ContainerChildren = memo(({ items, isColumn, isMain, renderElement }) => {
@@ -9337,7 +9342,7 @@ const DashboardHeader = memo(() => {
9337
9342
 
9338
9343
  const DataSourceError = ({ name }) => {
9339
9344
  const { t } = useGlobalContext();
9340
- return (jsxs(DataSourceErrorContainer, { children: [jsx(Icon, { kind: "alert" }), jsxs("div", { children: [t("block", { ns: "dashboard" }), " \"", name, "\" ", t("isNotLoaded", { ns: "dashboard" })] })] }));
9345
+ return (jsxs(DataSourceErrorContainer, { children: [jsx(Icon, { kind: "alert" }), jsxs("div", { children: [t("block", { ns: "dashboard", defaultValue: "Блок" }), " \"", name, "\" ", t("isNotLoaded", { ns: "dashboard", defaultValue: "не загружен" })] })] }));
9341
9346
  };
9342
9347
 
9343
9348
  const ExpandableTitle = memo(({ elementConfig, type, renderElement }) => {
@@ -9392,7 +9397,7 @@ const FeatureCardTitle = ({ title, description }) => {
9392
9397
  })) ||
9393
9398
  feature?.id);
9394
9399
  }, [attributes, feature?.id, layerDefinition, title, titleAttribute]);
9395
- return (jsxs(HeaderTitleContainer, { children: [jsx(FeatureTitleContainer, { clickable: true, children: jsx(Tooltip$1, { arrow: true, placement: "top", content: t("zoomToFeature", { ns: "dashboard" }), delay: [600, 0], children: ref => (jsx(FlexSpan, { ref: ref, onClick: () => zoomToFeatures([feature]), children: resultTitle })) }) }), jsx(LayerDescription, { title: resultDescription, children: resultDescription })] }));
9400
+ return (jsxs(HeaderTitleContainer, { children: [jsx(FeatureTitleContainer, { clickable: true, children: jsx(Tooltip$1, { arrow: true, placement: "top", content: t("zoomToFeature", { ns: "dashboard", defaultValue: "Приблизить к объекту" }), delay: [600, 0], children: ref => (jsx(FlexSpan, { ref: ref, onClick: () => zoomToFeatures([feature]), children: resultTitle })) }) }), jsx(LayerDescription, { title: resultDescription, children: resultDescription })] }));
9396
9401
  };
9397
9402
 
9398
9403
  const HiddenFilters = styled(Flex) `
@@ -9522,7 +9527,8 @@ const StyledSvgColorMixin = css `
9522
9527
  }
9523
9528
  }
9524
9529
  `;
9525
- const StyledSvg = styled.div `
9530
+ const StyledSvg = styled(Flex) `
9531
+ align-items: center;
9526
9532
  ${({ $width }) => !!$width && StyledSvgWidthMixin};
9527
9533
  ${({ $height }) => !!$height && StyledSvgHeightMixin};
9528
9534
  ${({ $fontColor }) => !!$fontColor && StyledSvgColorMixin};
@@ -9546,7 +9552,8 @@ const SvgImage = memo(({ url, width, height, fontColor }) => {
9546
9552
  useEffect(() => () => {
9547
9553
  setSvg(null);
9548
9554
  }, []);
9549
- if (!svg?.endsWith("</svg>"))
9555
+ const regexp = /<\/svg>\s*$/im;
9556
+ if (!regexp.test(svg))
9550
9557
  return null;
9551
9558
  return (jsx(StyledSvg, { "$width": width, "$height": height, "$fontColor": fontColor, dangerouslySetInnerHTML: { __html: svg } }));
9552
9559
  });
@@ -9564,7 +9571,7 @@ const TextTrim = memo(({ maxLength, expandable, lineBreak, children }) => {
9564
9571
  return jsx(Fragment$1, { children: formatValue(text) });
9565
9572
  const substring = `${text.substring(0, maxLength)}...`;
9566
9573
  if (expandable) {
9567
- return (jsxs(Fragment$1, { children: [formatValue(expanded ? text : substring), jsx(LegendToggler, { toggled: expanded, onClick: toggleExpanded, children: expanded ? t("hide", { ns: "dashboard" }) : t("more", { ns: "dashboard" }) })] }));
9574
+ return (jsxs(Fragment$1, { children: [formatValue(expanded ? text : substring), jsx(LegendToggler, { toggled: expanded, onClick: toggleExpanded, children: expanded ? t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) : t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
9568
9575
  }
9569
9576
  return (jsx(Tooltip$1, { placement: "top", arrow: true, content: text, children: ref => jsx("div", { ref: ref, children: formatValue(substring) }) }));
9570
9577
  });