@evergis/react 4.0.61 → 4.0.62

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
@@ -6252,7 +6252,7 @@ const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
6252
6252
 
6253
6253
  const getAttributeValue = (element, attributes) => {
6254
6254
  const attribute = getAttributeByName(element?.attributeName, attributes);
6255
- const { maxLength, separator, expandable, lineBreak } = element.options || {};
6255
+ const { maxLength, wordBreak, separator, expandable, lineBreak } = element.options || {};
6256
6256
  let value;
6257
6257
  if (attribute?.type === AttributeType.Boolean && typeof attribute.value === "boolean") {
6258
6258
  return jsx(DashboardCheckbox, { title: attribute.alias || attribute.attributeName, checked: attribute.value });
@@ -6267,7 +6267,7 @@ const getAttributeValue = (element, attributes) => {
6267
6267
  ? JSON.stringify(rawValue)
6268
6268
  : (rawValue || "");
6269
6269
  }
6270
- return typeof value === "string" && maxLength && maxLength < value.length ? (jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
6270
+ return typeof value === "string" && maxLength && maxLength < value.length ? (jsx(TextTrim, { maxLength: maxLength, wordBreak: wordBreak, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
6271
6271
  };
6272
6272
 
6273
6273
  const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
@@ -7397,7 +7397,7 @@ const TabsContainer = memo(({ elementConfig, type }) => {
7397
7397
  const { palette } = useTheme();
7398
7398
  const { selectedTabId, setSelectedTabId } = useWidgetContext(type);
7399
7399
  const { id, options, style, children: tabs } = elementConfig || {};
7400
- const { radius, column, bgColor, noBg, onlyIcon, shownItems, maxLength = 12 } = options || {};
7400
+ const { radius, column, bgColor, noBg, onlyIcon, shownItems, maxLength = 12, wordBreak } = options || {};
7401
7401
  const renderIcon = useCallback((icon, active) => {
7402
7402
  if (!icon)
7403
7403
  return null;
@@ -7405,16 +7405,16 @@ const TabsContainer = memo(({ elementConfig, type }) => {
7405
7405
  return jsx(Icon, { kind: icon });
7406
7406
  return icon.endsWith(".svg") ? (jsx(SvgImage, { url: icon, width: 16, fontColor: active ? palette.textContrast : palette.textSecondary })) : (jsx("img", { src: icon, alt: "" }));
7407
7407
  }, [palette.textContrast, palette.textSecondary]);
7408
- const onClick = useCallback((id) => {
7409
- setSelectedTabId(id);
7410
- window.location.hash = `#${id}`;
7408
+ const onClick = useCallback((tabId) => {
7409
+ setSelectedTabId(tabId);
7410
+ window.location.hash = `#${tabId}`;
7411
7411
  }, [setSelectedTabId]);
7412
7412
  useEffect(() => {
7413
7413
  if (!selectedTabId) {
7414
7414
  setSelectedTabId(tabs[0].id);
7415
7415
  }
7416
7416
  }, []);
7417
- return (jsx(SwiperContainer, { id: id, style: style, children: jsx(Swiper, { spaceBetween: 0, slidesPerView: shownItems || 2, children: tabs.map(({ id, value, options: tabOptions }) => (jsxs(SwiperSlide, { children: [jsxs(TabContainer, { href: `#${id}`, active: selectedTabId === id, column: column, bgColor: bgColor, noBg: noBg, radius: radius, onlyIcon: onlyIcon, hasIcon: !!tabOptions?.icon, onClick: () => onClick(id), children: [renderIcon(tabOptions?.icon, selectedTabId === id), !onlyIcon && (jsx(TabValue, { children: jsx(TextTrim, { maxLength: maxLength, children: value }) }))] }), jsx(TabAnchor, { id: id })] }, id))) }) }));
7417
+ return (jsx(SwiperContainer, { id: id, style: style, children: jsx(Swiper, { spaceBetween: 0, slidesPerView: shownItems || 2, children: tabs.map(({ id: tabId, value, options: tabOptions }) => (jsxs(SwiperSlide, { children: [jsxs(TabContainer, { href: `#${tabId}`, active: selectedTabId === tabId, column: column, bgColor: bgColor, noBg: noBg, radius: radius, onlyIcon: onlyIcon, hasIcon: !!tabOptions?.icon, onClick: () => onClick(tabId), children: [renderIcon(tabOptions?.icon, selectedTabId === tabId), !onlyIcon && (jsx(TabValue, { children: jsx(TextTrim, { maxLength: maxLength, wordBreak: wordBreak, children: value }) }))] }), jsx(TabAnchor, { id: tabId })] }, tabId))) }) }));
7418
7418
  });
7419
7419
 
7420
7420
  const ContainerIconValue = styled(Flex) ``;
@@ -7522,7 +7522,7 @@ const RoundedBackgroundContainer = memo(({ type, elementConfig, feature, renderE
7522
7522
  feature,
7523
7523
  });
7524
7524
  const { id, options, style, children } = elementConfig || {};
7525
- const { maxLength, center, fontColor, innerTemplateStyle, inlineUnits, big, bigIcon, hideEmpty, colorAttribute } = options || {};
7525
+ const { maxLength, wordBreak, center, fontColor, innerTemplateStyle, inlineUnits, big, bigIcon, hideEmpty, colorAttribute } = options || {};
7526
7526
  const iconElement = children?.find(item => item.id === "icon");
7527
7527
  const aliasElement = children?.find(item => item.id === "alias");
7528
7528
  const unitsElement = children?.find(item => item.id === "units");
@@ -7541,7 +7541,7 @@ const RoundedBackgroundContainer = memo(({ type, elementConfig, feature, renderE
7541
7541
  return null;
7542
7542
  return (jsx(FlexSpan, { width: iconElement.options?.width || "1rem", alignItems: "center", mr: "0.5rem", children: renderElement({ id: "icon", wrap: false }) }));
7543
7543
  }, [iconElement, renderElement]);
7544
- 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]);
7544
+ const renderAlias = useMemo(() => (jsx(ContainerAlias, { style: aliasElement?.style, children: jsx(TextTrim, { maxLength: maxLength || ALIAS_DEFAULT_MAX_LENGTH, wordBreak: wordBreak, children: renderElement({ id: "alias", wrap: false }) }) })), [aliasElement?.style, maxLength, renderElement, wordBreak]);
7545
7545
  const renderValue = useMemo(() => isNil(value) ? null : (jsxs(ContainerValue, { style: valueElement?.style, big: true, children: [value, !!unitsElement && (jsx(ContainerUnits, { style: unitsElement?.style, children: renderElement({ id: "units" }) }))] })), [valueElement?.style, value, unitsElement, renderElement]);
7546
7546
  if (isNil(value) && hideEmpty)
7547
7547
  return null;
@@ -8785,15 +8785,7 @@ const RowHeaderMixin = css `
8785
8785
  const OverlayHeaderMixin = (overlay) => css `
8786
8786
  &&& {
8787
8787
  :after {
8788
- content: "";
8789
- z-index: 2;
8790
- position: absolute;
8791
- top: 0;
8792
- left: 0;
8793
- width: 100%;
8794
- height: 100%;
8795
8788
  background: ${overlay};
8796
- pointer-events: none;
8797
8789
  }
8798
8790
  }
8799
8791
  `;
@@ -8849,8 +8841,10 @@ const LayerIconContainer = styled.div `
8849
8841
  display: flex;
8850
8842
  align-items: center;
8851
8843
  justify-content: center;
8852
- min-width: 2rem;
8853
- margin-right: 0.5rem;
8844
+ min-width: 1.5rem;
8845
+ width: 1.5rem;
8846
+ height: 1.5rem;
8847
+ margin-right: 1rem;
8854
8848
  `;
8855
8849
  const AlertIconContainer = styled(Flex) `
8856
8850
  align-items: center;
@@ -9482,29 +9476,49 @@ const ElementIcon = memo(({ type, elementConfig }) => {
9482
9476
  return (jsx(StyledIcon, { kind: iconValue, fontSize: fontSize, fontColor: fontColor, style: style }));
9483
9477
  });
9484
9478
 
9485
- const ElementImage = memo(({ type, elementConfig }) => {
9479
+ const useElementImage = ({ type, elementConfig, }) => {
9486
9480
  const { attributes } = useWidgetContext(type);
9487
- const { value, attributeName, options, style } = elementConfig || {};
9488
- const { width } = options || {};
9489
- const firstImage = useMemo(() => {
9490
- if (value) {
9481
+ const { value, attributeName } = elementConfig || {};
9482
+ const attribute = useMemo(() => {
9483
+ if (!attributeName || Array.isArray(attributeName))
9484
+ return undefined;
9485
+ return attributes?.find(item => item.attributeName === attributeName);
9486
+ }, [attributeName, attributes]);
9487
+ const isAttachmentAttribute = attribute?.subType === StringSubType.Attachments;
9488
+ const { items } = useAttachmentItems({ type, elementConfig });
9489
+ const imageItems = useMemo(() => items
9490
+ .filter(item => IMAGE_FILE_TYPES.includes(getFileType(item.mimeType, item.name)))
9491
+ .slice(0, 1), [items]);
9492
+ const attachmentImages = useAttachmentPreviewImages({
9493
+ items: imageItems,
9494
+ active: isAttachmentAttribute,
9495
+ });
9496
+ const stringUrl = useMemo(() => {
9497
+ if (value)
9491
9498
  return getResourceUrl(value.toString());
9492
- }
9493
- if (!attributeName || Array.isArray(attributeName)) {
9499
+ if (isAttachmentAttribute)
9500
+ return null;
9501
+ if (!attributeName || Array.isArray(attributeName))
9494
9502
  return null;
9495
- }
9496
- const attribute = attributes?.find(item => item.attributeName === attributeName);
9497
9503
  const imageUrl = attribute?.value?.split(";")?.[0];
9498
- if (!imageUrl) {
9504
+ if (!imageUrl)
9499
9505
  return null;
9500
- }
9501
9506
  return getResourceUrl(imageUrl);
9502
- }, [attributeName, attributes, value]);
9503
- const blobUrl = useFetchImageWithAuth(firstImage);
9504
- if (!blobUrl) {
9507
+ }, [value, isAttachmentAttribute, attributeName, attribute]);
9508
+ const stringBlobUrl = useFetchImageWithAuth(stringUrl);
9509
+ const attachmentSrc = attachmentImages[0]?.src || null;
9510
+ const src = isAttachmentAttribute ? attachmentSrc : stringBlobUrl;
9511
+ const alt = isAttachmentAttribute ? attachmentImages[0]?.fileName ?? "" : stringUrl ?? "";
9512
+ return { src, alt };
9513
+ };
9514
+
9515
+ const ElementImage = memo(({ type, elementConfig }) => {
9516
+ const { options, style } = elementConfig || {};
9517
+ const { width } = options || {};
9518
+ const { src, alt } = useElementImage({ type, elementConfig });
9519
+ if (!src)
9505
9520
  return null;
9506
- }
9507
- return (jsx("img", { src: blobUrl, alt: firstImage ?? "", width: width, style: style }));
9521
+ return jsx("img", { src: src, alt: alt, width: width, style: style });
9508
9522
  });
9509
9523
 
9510
9524
  const ElementLegend = memo(({ type, element, elementConfig }) => {
@@ -9872,7 +9886,8 @@ const SlideshowHeaderWrapper = styled.div `
9872
9886
  position: absolute;
9873
9887
  top: 0;
9874
9888
  left: 0;
9875
- right: 0;
9889
+ width: 100%;
9890
+ height: 100%;
9876
9891
  pointer-events: none;
9877
9892
  }
9878
9893
 
@@ -9882,8 +9897,7 @@ const SlideshowHeaderWrapper = styled.div `
9882
9897
  }
9883
9898
 
9884
9899
  :after {
9885
- height: 4.5rem;
9886
- background: linear-gradient(180deg, #000000 0%, rgba(0, 0, 0, 0) 100%);
9900
+ background: linear-gradient(180deg, rgba(17, 37, 47, 0.75) 0%, rgba(17, 37, 47, 0.00) 100%);
9887
9901
  }
9888
9902
 
9889
9903
  :hover {
@@ -9931,12 +9945,13 @@ const HeaderSlideshow = styled.div `
9931
9945
  `;
9932
9946
 
9933
9947
  const FeatureCardBackgroundHeader = () => {
9948
+ const { themeName: pageThemeName } = useGlobalContext();
9934
9949
  const { config } = useWidgetConfig(WidgetType.FeatureCard);
9935
9950
  const { header } = config || {};
9936
9951
  const { options } = header || {};
9937
9952
  const { fontColor, bgColor, height, overlay, bigIcon, withPadding, bottomBlur, themeName, column } = options || {};
9938
9953
  const renderElement = useHeaderRender(header);
9939
- return (jsx(BackgroundHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$height": height, "$bigIcon": bigIcon, "$withPadding": withPadding, "$bottomBlur": bottomBlur, children: jsx(ThemeProvider, { theme: getThemeByName(themeName), children: jsxs(Header, { "$overlay": overlay, "$isRow": !column, children: [jsxs(HeaderFrontView, { children: [jsxs(HeaderContainer, { column: column, children: [jsx(HeaderLayerIcon, {}), jsx(FeatureCardTitle, { title: renderElement({
9954
+ return (jsx(BackgroundHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$height": height, "$bigIcon": bigIcon, "$withPadding": withPadding, "$bottomBlur": bottomBlur, children: jsx(ThemeProvider, { theme: getThemeByName(themeName ?? pageThemeName), children: jsxs(Header, { "$overlay": overlay, "$isRow": !column, children: [jsxs(HeaderFrontView, { children: [jsxs(HeaderContainer, { column: column, children: [jsx(HeaderLayerIcon, {}), jsx(FeatureCardTitle, { title: renderElement({
9940
9955
  id: "title",
9941
9956
  wrap: false,
9942
9957
  }), description: renderElement({
@@ -10322,8 +10337,8 @@ const getElementValue = ({ getDefaultContainer, ...props }) => {
10322
10337
  return "";
10323
10338
  }
10324
10339
  const alias = attribute?.alias || attributeName || "";
10325
- const { maxLength, lineBreak, expandable } = options || {};
10326
- return alias && maxLength && maxLength < alias.length ? (jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: alias })) : (alias);
10340
+ const { maxLength, wordBreak, lineBreak, expandable } = options || {};
10341
+ return alias && maxLength && maxLength < alias.length ? (jsx(TextTrim, { maxLength: maxLength, wordBreak: wordBreak, expandable: expandable, lineBreak: lineBreak, children: alias })) : (alias);
10327
10342
  }
10328
10343
  if (type === "attributeValue") {
10329
10344
  /* return isHandbookAttribute(attribute?.name, layerInfo) ? (
@@ -13185,15 +13200,20 @@ const SvgImage = memo(({ url, width, height, fontColor }) => {
13185
13200
  return (jsx(StyledSvg, { "$width": width, "$height": height, "$fontColor": fontColor, dangerouslySetInnerHTML: { __html: svg } }));
13186
13201
  });
13187
13202
 
13188
- const TextTrim = memo(({ maxLength, expandable, lineBreak, children }) => {
13203
+ const TextTrimValue = styled.div `
13204
+ word-break: ${({ wordBreak }) => wordBreak ?? "break-word"};
13205
+ overflow: hidden;
13206
+ `;
13207
+
13208
+ const TextTrim = memo(({ maxLength, expandable, lineBreak, wordBreak, children }) => {
13189
13209
  const { t } = useGlobalContext();
13190
13210
  const [expanded, toggleExpanded] = useToggle();
13191
13211
  const text = children?.toString();
13192
13212
  const formatValue = useCallback((value) => {
13193
13213
  if (!lineBreak)
13194
- return value;
13195
- return jsx("div", { dangerouslySetInnerHTML: { __html: unescape(value).split(lineBreak).join("<br />") } });
13196
- }, [lineBreak]);
13214
+ return jsx(TextTrimValue, { wordBreak: wordBreak, children: value });
13215
+ return jsx(TextTrimValue, { wordBreak: wordBreak, dangerouslySetInnerHTML: { __html: unescape(value).split(lineBreak).join("<br />") } });
13216
+ }, [lineBreak, wordBreak]);
13197
13217
  if (!text?.length || !maxLength || text.length <= maxLength)
13198
13218
  return jsx(Fragment$1, { children: formatValue(text) });
13199
13219
  const substring = `${text.substring(0, maxLength)}...`;