@evergis/react 4.0.36 → 4.0.37

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
@@ -7,9 +7,9 @@ import { AttributeType, STORAGE_TOKEN_KEY, generateId, parseJwt, STORAGE_REFRESH
7
7
  import Gradient from 'javascript-color-gradient';
8
8
  import { Color as Color$1 } from '@evergis/color';
9
9
  import { isValid, format, parseJSON, parseISO, toDate } from 'date-fns';
10
+ import { isNil, uniqueId, isEmpty, isEqual, unescape } from 'lodash';
10
11
  import { ru } from 'date-fns/locale/ru';
11
12
  import { enUS } from 'date-fns/locale/en-US';
12
- import { uniqueId, isNil, isEmpty, isEqual, unescape } from 'lodash';
13
13
  import { HubConnectionBuilder, HttpTransportType, LogLevel } from '@microsoft/signalr';
14
14
  import { changeProps, returnFound } from 'find-and';
15
15
  import { jsPDF } from 'jspdf';
@@ -3827,15 +3827,16 @@ const formatNumberValue = (stringFormat, value, type, noUnits = false) => {
3827
3827
  return currentValue?.toString() || "";
3828
3828
  };
3829
3829
  const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false }) => {
3830
+ const isNilValue = isNil(value);
3830
3831
  if (type === AttributeType.Point) {
3831
- if (!stringFormat?.format || !value) {
3832
+ if (!stringFormat?.format || isNilValue) {
3832
3833
  return null;
3833
3834
  }
3834
3835
  const { coordinates } = value;
3835
3836
  return formatPointValue({ t, stringFormat, value: coordinates });
3836
3837
  }
3837
3838
  if (type === AttributeType.DateTime) {
3838
- if (!stringFormat?.format || !value)
3839
+ if (!stringFormat?.format || isNilValue)
3839
3840
  return null;
3840
3841
  return formatDateValue(stringFormat, value);
3841
3842
  }
@@ -3856,12 +3857,12 @@ const formatAttributeValue = ({ t, type, value, stringFormat, noUnits = false })
3856
3857
  return formatNumberValue(stringFormat, value, type, noUnits);
3857
3858
  }
3858
3859
  if (type === AttributeType.Json) {
3859
- if (!value || value?.length === 0) {
3860
+ if (isNilValue || value?.length === 0) {
3860
3861
  return "";
3861
3862
  }
3862
3863
  return `${t("total", { ns: "table" })} ${value.length}`;
3863
3864
  }
3864
- return value ? value.toString() : "";
3865
+ return !isNilValue ? value.toString() : "";
3865
3866
  };
3866
3867
  const formatNumber = (number) => {
3867
3868
  let result = "";
@@ -6342,18 +6343,7 @@ const DataSourceInnerContainer = memo(({ config, elementConfig, feature, maxValu
6342
6343
  setSelectedTabId,
6343
6344
  pageIndex,
6344
6345
  type,
6345
- }), [
6346
- getRenderElement,
6347
- config,
6348
- elementConfig,
6349
- attributes,
6350
- layerInfo,
6351
- expandedContainers,
6352
- selectedTabId,
6353
- setSelectedTabId,
6354
- pageIndex,
6355
- type,
6356
- ]);
6346
+ }), [config, elementConfig, attributes, layerInfo, expandedContainers, selectedTabId, setSelectedTabId, pageIndex, type]);
6357
6347
  if (!InnerContainer) {
6358
6348
  return null;
6359
6349
  }
@@ -8148,6 +8138,11 @@ const FeatureCardGradientHeader = ({ isRow }) => {
8148
8138
  }) })] }), jsx(FeatureCardButtons, {})] }) }) }) }));
8149
8139
  };
8150
8140
 
8141
+ const LayerIconClickable = styled.div `
8142
+ display: flex;
8143
+ align-items: center;
8144
+ cursor: pointer;
8145
+ `;
8151
8146
  const HeaderFontColorMixin = css `
8152
8147
  ${HeaderTitleContainer}, ${HeaderTitleContainer} *, ${LayerDescription} {
8153
8148
  color: ${({ $fontColor }) => $fontColor};
@@ -8225,13 +8220,16 @@ const IconHeaderWrapper = styled.div `
8225
8220
  `;
8226
8221
 
8227
8222
  const FeatureCardIconHeader = ({ isRow }) => {
8228
- const { layerInfo } = useWidgetContext(WidgetType.FeatureCard);
8223
+ const { t } = useGlobalContext();
8224
+ const { layerInfo, feature } = useWidgetContext(WidgetType.FeatureCard);
8229
8225
  const { config } = useWidgetConfig(WidgetType.FeatureCard);
8226
+ const zoomToFeatures = useZoomToFeatures();
8230
8227
  const { header } = config || {};
8231
8228
  const { options } = header || {};
8232
8229
  const { fontColor, bgColor, bigIcon } = options || {};
8233
8230
  const renderElement = useHeaderRender(header);
8234
- return (jsx(IconHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$bigIcon": bigIcon, children: jsx(ThemeProvider, { theme: defaultTheme, children: jsxs(Header, { "$isRow": isRow, children: [jsxs(HeaderFrontView, { children: [jsxs(HeaderContainer, { children: [jsx(LayerIcon, { layerInfo: layerInfo }), jsx(FeatureCardTitle, { title: renderElement({
8231
+ const handleIconClick = useCallback(() => zoomToFeatures([feature]), [zoomToFeatures, feature]);
8232
+ return (jsx(IconHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$bigIcon": bigIcon, children: jsx(ThemeProvider, { theme: defaultTheme, children: jsxs(Header, { "$isRow": isRow, children: [jsxs(HeaderFrontView, { children: [jsxs(HeaderContainer, { children: [jsx(Tooltip$1, { arrow: true, placement: "top", content: t("zoomToFeature", { ns: "dashboard", defaultValue: "Приблизить к объекту" }), delay: [600, 0], children: ref => (jsx(LayerIconClickable, { ref: ref, onClick: handleIconClick, children: jsx(LayerIcon, { layerInfo: layerInfo }) })) }), jsx(FeatureCardTitle, { title: renderElement({
8235
8233
  id: "title",
8236
8234
  wrap: false,
8237
8235
  }), description: renderElement({
@@ -9533,7 +9531,7 @@ function getFeatureAttributes(feature = {}, layer, dataSource) {
9533
9531
  readOnly: true,
9534
9532
  }
9535
9533
  : {
9536
- value: currentAttributes?.[attributeName] || dataSource?.features?.[0]?.properties?.[attributeName],
9534
+ value: currentAttributes?.[attributeName] ?? dataSource?.features?.[0]?.properties?.[attributeName],
9537
9535
  readOnly: attributeConfigurationType === AttributeConfigurationType.Calculated || !isEditable,
9538
9536
  };
9539
9537
  const clientData = layer?.configuration?.attributesConfiguration?.attributes?.find(layerAttribute => layerAttribute.attributeName === attributeName)?.clientData;