@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.
@@ -403,7 +403,7 @@ export interface SlideshowContainerConfig extends Omit<ConfigContainerChild, "op
403
403
  export interface SlideshowContainerProps extends Omit<ContainerProps, "elementConfig"> {
404
404
  elementConfig?: SlideshowContainerConfig;
405
405
  }
406
- export type TabsContainerOptions = Pick<ConfigOptions, "radius" | "column" | "bgColor" | "noBg" | "onlyIcon" | "shownItems" | "maxLength">;
406
+ export type TabsContainerOptions = Pick<ConfigOptions, "radius" | "column" | "bgColor" | "noBg" | "onlyIcon" | "shownItems" | "maxLength" | "wordBreak">;
407
407
  export type TabOptions = Pick<ConfigOptions, "icon">;
408
408
  export interface TabChild extends Omit<ConfigContainerChild, "options" | "type" | "children"> {
409
409
  options?: TabOptions;
@@ -1,5 +1,7 @@
1
1
  import { FC } from 'react';
2
+ import { ConfigTextDisplayOptions } from '../../types';
2
3
  type TextTrimProps = {
4
+ wordBreak?: ConfigTextDisplayOptions["wordBreak"];
3
5
  maxLength?: number;
4
6
  expandable?: boolean;
5
7
  lineBreak?: string;
@@ -0,0 +1,4 @@
1
+ import { ConfigTextDisplayOptions } from '../../types';
2
+ export declare const TextTrimValue: import('styled-components').StyledComponent<"div", any, {
3
+ wordBreak?: ConfigTextDisplayOptions["wordBreak"];
4
+ }, never>;
@@ -0,0 +1,11 @@
1
+ import { ConfigContainerChild, WidgetType } from '../../types';
2
+ interface UseElementImageProps {
3
+ type?: WidgetType;
4
+ elementConfig?: ConfigContainerChild;
5
+ }
6
+ interface UseElementImageResult {
7
+ src: string | null;
8
+ alt: string;
9
+ }
10
+ export declare const useElementImage: ({ type, elementConfig, }: UseElementImageProps) => UseElementImageResult;
11
+ export {};
@@ -184,6 +184,7 @@ export interface ConfigTextDisplayOptions {
184
184
  hideTitle?: boolean;
185
185
  simple?: boolean;
186
186
  maxLength?: number;
187
+ wordBreak?: "break-word" | "break-all";
187
188
  separator?: string;
188
189
  lineBreak?: string;
189
190
  }
package/dist/index.js CHANGED
@@ -6254,7 +6254,7 @@ const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
6254
6254
 
6255
6255
  const getAttributeValue = (element, attributes) => {
6256
6256
  const attribute = getAttributeByName(element?.attributeName, attributes);
6257
- const { maxLength, separator, expandable, lineBreak } = element.options || {};
6257
+ const { maxLength, wordBreak, separator, expandable, lineBreak } = element.options || {};
6258
6258
  let value;
6259
6259
  if (attribute?.type === api.AttributeType.Boolean && typeof attribute.value === "boolean") {
6260
6260
  return jsxRuntime.jsx(DashboardCheckbox, { title: attribute.alias || attribute.attributeName, checked: attribute.value });
@@ -6269,7 +6269,7 @@ const getAttributeValue = (element, attributes) => {
6269
6269
  ? JSON.stringify(rawValue)
6270
6270
  : (rawValue || "");
6271
6271
  }
6272
- return typeof value === "string" && maxLength && maxLength < value.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
6272
+ return typeof value === "string" && maxLength && maxLength < value.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, wordBreak: wordBreak, expandable: expandable, lineBreak: lineBreak, children: value })) : (value);
6273
6273
  };
6274
6274
 
6275
6275
  const getChartAxes = (chartElement) => chartElement?.options?.relatedDataSources?.filter(({ chartAxis }) => chartAxis === "y");
@@ -7399,7 +7399,7 @@ const TabsContainer = React.memo(({ elementConfig, type }) => {
7399
7399
  const { palette } = styled.useTheme();
7400
7400
  const { selectedTabId, setSelectedTabId } = useWidgetContext(type);
7401
7401
  const { id, options, style, children: tabs } = elementConfig || {};
7402
- const { radius, column, bgColor, noBg, onlyIcon, shownItems, maxLength = 12 } = options || {};
7402
+ const { radius, column, bgColor, noBg, onlyIcon, shownItems, maxLength = 12, wordBreak } = options || {};
7403
7403
  const renderIcon = React.useCallback((icon, active) => {
7404
7404
  if (!icon)
7405
7405
  return null;
@@ -7407,16 +7407,16 @@ const TabsContainer = React.memo(({ elementConfig, type }) => {
7407
7407
  return jsxRuntime.jsx(uilibGl.Icon, { kind: icon });
7408
7408
  return icon.endsWith(".svg") ? (jsxRuntime.jsx(SvgImage, { url: icon, width: 16, fontColor: active ? palette.textContrast : palette.textSecondary })) : (jsxRuntime.jsx("img", { src: icon, alt: "" }));
7409
7409
  }, [palette.textContrast, palette.textSecondary]);
7410
- const onClick = React.useCallback((id) => {
7411
- setSelectedTabId(id);
7412
- window.location.hash = `#${id}`;
7410
+ const onClick = React.useCallback((tabId) => {
7411
+ setSelectedTabId(tabId);
7412
+ window.location.hash = `#${tabId}`;
7413
7413
  }, [setSelectedTabId]);
7414
7414
  React.useEffect(() => {
7415
7415
  if (!selectedTabId) {
7416
7416
  setSelectedTabId(tabs[0].id);
7417
7417
  }
7418
7418
  }, []);
7419
- return (jsxRuntime.jsx(SwiperContainer, { id: id, style: style, children: jsxRuntime.jsx(react.Swiper, { spaceBetween: 0, slidesPerView: shownItems || 2, children: tabs.map(({ id, value, options: tabOptions }) => (jsxRuntime.jsxs(react.SwiperSlide, { children: [jsxRuntime.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 && (jsxRuntime.jsx(TabValue, { children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength, children: value }) }))] }), jsxRuntime.jsx(TabAnchor, { id: id })] }, id))) }) }));
7419
+ return (jsxRuntime.jsx(SwiperContainer, { id: id, style: style, children: jsxRuntime.jsx(react.Swiper, { spaceBetween: 0, slidesPerView: shownItems || 2, children: tabs.map(({ id: tabId, value, options: tabOptions }) => (jsxRuntime.jsxs(react.SwiperSlide, { children: [jsxRuntime.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 && (jsxRuntime.jsx(TabValue, { children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength, wordBreak: wordBreak, children: value }) }))] }), jsxRuntime.jsx(TabAnchor, { id: tabId })] }, tabId))) }) }));
7420
7420
  });
7421
7421
 
7422
7422
  const ContainerIconValue = styled(uilibGl.Flex) ``;
@@ -7524,7 +7524,7 @@ const RoundedBackgroundContainer = React.memo(({ type, elementConfig, feature, r
7524
7524
  feature,
7525
7525
  });
7526
7526
  const { id, options, style, children } = elementConfig || {};
7527
- const { maxLength, center, fontColor, innerTemplateStyle, inlineUnits, big, bigIcon, hideEmpty, colorAttribute } = options || {};
7527
+ const { maxLength, wordBreak, center, fontColor, innerTemplateStyle, inlineUnits, big, bigIcon, hideEmpty, colorAttribute } = options || {};
7528
7528
  const iconElement = children?.find(item => item.id === "icon");
7529
7529
  const aliasElement = children?.find(item => item.id === "alias");
7530
7530
  const unitsElement = children?.find(item => item.id === "units");
@@ -7543,7 +7543,7 @@ const RoundedBackgroundContainer = React.memo(({ type, elementConfig, feature, r
7543
7543
  return null;
7544
7544
  return (jsxRuntime.jsx(uilibGl.FlexSpan, { width: iconElement.options?.width || "1rem", alignItems: "center", mr: "0.5rem", children: renderElement({ id: "icon", wrap: false }) }));
7545
7545
  }, [iconElement, renderElement]);
7546
- const renderAlias = React.useMemo(() => (jsxRuntime.jsx(ContainerAlias, { style: aliasElement?.style, children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength || ALIAS_DEFAULT_MAX_LENGTH, children: renderElement({ id: "alias", wrap: false }) }) })), [aliasElement?.style, maxLength, renderElement]);
7546
+ const renderAlias = React.useMemo(() => (jsxRuntime.jsx(ContainerAlias, { style: aliasElement?.style, children: jsxRuntime.jsx(TextTrim, { maxLength: maxLength || ALIAS_DEFAULT_MAX_LENGTH, wordBreak: wordBreak, children: renderElement({ id: "alias", wrap: false }) }) })), [aliasElement?.style, maxLength, renderElement, wordBreak]);
7547
7547
  const renderValue = React.useMemo(() => lodash.isNil(value) ? null : (jsxRuntime.jsxs(ContainerValue, { style: valueElement?.style, big: true, children: [value, !!unitsElement && (jsxRuntime.jsx(ContainerUnits, { style: unitsElement?.style, children: renderElement({ id: "units" }) }))] })), [valueElement?.style, value, unitsElement, renderElement]);
7548
7548
  if (lodash.isNil(value) && hideEmpty)
7549
7549
  return null;
@@ -8787,15 +8787,7 @@ const RowHeaderMixin = styled.css `
8787
8787
  const OverlayHeaderMixin = (overlay) => styled.css `
8788
8788
  &&& {
8789
8789
  :after {
8790
- content: "";
8791
- z-index: 2;
8792
- position: absolute;
8793
- top: 0;
8794
- left: 0;
8795
- width: 100%;
8796
- height: 100%;
8797
8790
  background: ${overlay};
8798
- pointer-events: none;
8799
8791
  }
8800
8792
  }
8801
8793
  `;
@@ -8851,8 +8843,10 @@ const LayerIconContainer = styled.div `
8851
8843
  display: flex;
8852
8844
  align-items: center;
8853
8845
  justify-content: center;
8854
- min-width: 2rem;
8855
- margin-right: 0.5rem;
8846
+ min-width: 1.5rem;
8847
+ width: 1.5rem;
8848
+ height: 1.5rem;
8849
+ margin-right: 1rem;
8856
8850
  `;
8857
8851
  const AlertIconContainer = styled(uilibGl.Flex) `
8858
8852
  align-items: center;
@@ -9484,29 +9478,49 @@ const ElementIcon = React.memo(({ type, elementConfig }) => {
9484
9478
  return (jsxRuntime.jsx(StyledIcon, { kind: iconValue, fontSize: fontSize, fontColor: fontColor, style: style }));
9485
9479
  });
9486
9480
 
9487
- const ElementImage = React.memo(({ type, elementConfig }) => {
9481
+ const useElementImage = ({ type, elementConfig, }) => {
9488
9482
  const { attributes } = useWidgetContext(type);
9489
- const { value, attributeName, options, style } = elementConfig || {};
9490
- const { width } = options || {};
9491
- const firstImage = React.useMemo(() => {
9492
- if (value) {
9483
+ const { value, attributeName } = elementConfig || {};
9484
+ const attribute = React.useMemo(() => {
9485
+ if (!attributeName || Array.isArray(attributeName))
9486
+ return undefined;
9487
+ return attributes?.find(item => item.attributeName === attributeName);
9488
+ }, [attributeName, attributes]);
9489
+ const isAttachmentAttribute = attribute?.subType === api.StringSubType.Attachments;
9490
+ const { items } = useAttachmentItems({ type, elementConfig });
9491
+ const imageItems = React.useMemo(() => items
9492
+ .filter(item => IMAGE_FILE_TYPES.includes(getFileType(item.mimeType, item.name)))
9493
+ .slice(0, 1), [items]);
9494
+ const attachmentImages = useAttachmentPreviewImages({
9495
+ items: imageItems,
9496
+ active: isAttachmentAttribute,
9497
+ });
9498
+ const stringUrl = React.useMemo(() => {
9499
+ if (value)
9493
9500
  return getResourceUrl(value.toString());
9494
- }
9495
- if (!attributeName || Array.isArray(attributeName)) {
9501
+ if (isAttachmentAttribute)
9502
+ return null;
9503
+ if (!attributeName || Array.isArray(attributeName))
9496
9504
  return null;
9497
- }
9498
- const attribute = attributes?.find(item => item.attributeName === attributeName);
9499
9505
  const imageUrl = attribute?.value?.split(";")?.[0];
9500
- if (!imageUrl) {
9506
+ if (!imageUrl)
9501
9507
  return null;
9502
- }
9503
9508
  return getResourceUrl(imageUrl);
9504
- }, [attributeName, attributes, value]);
9505
- const blobUrl = useFetchImageWithAuth(firstImage);
9506
- if (!blobUrl) {
9509
+ }, [value, isAttachmentAttribute, attributeName, attribute]);
9510
+ const stringBlobUrl = useFetchImageWithAuth(stringUrl);
9511
+ const attachmentSrc = attachmentImages[0]?.src || null;
9512
+ const src = isAttachmentAttribute ? attachmentSrc : stringBlobUrl;
9513
+ const alt = isAttachmentAttribute ? attachmentImages[0]?.fileName ?? "" : stringUrl ?? "";
9514
+ return { src, alt };
9515
+ };
9516
+
9517
+ const ElementImage = React.memo(({ type, elementConfig }) => {
9518
+ const { options, style } = elementConfig || {};
9519
+ const { width } = options || {};
9520
+ const { src, alt } = useElementImage({ type, elementConfig });
9521
+ if (!src)
9507
9522
  return null;
9508
- }
9509
- return (jsxRuntime.jsx("img", { src: blobUrl, alt: firstImage ?? "", width: width, style: style }));
9523
+ return jsxRuntime.jsx("img", { src: src, alt: alt, width: width, style: style });
9510
9524
  });
9511
9525
 
9512
9526
  const ElementLegend = React.memo(({ type, element, elementConfig }) => {
@@ -9874,7 +9888,8 @@ const SlideshowHeaderWrapper = styled.div `
9874
9888
  position: absolute;
9875
9889
  top: 0;
9876
9890
  left: 0;
9877
- right: 0;
9891
+ width: 100%;
9892
+ height: 100%;
9878
9893
  pointer-events: none;
9879
9894
  }
9880
9895
 
@@ -9884,8 +9899,7 @@ const SlideshowHeaderWrapper = styled.div `
9884
9899
  }
9885
9900
 
9886
9901
  :after {
9887
- height: 4.5rem;
9888
- background: linear-gradient(180deg, #000000 0%, rgba(0, 0, 0, 0) 100%);
9902
+ background: linear-gradient(180deg, rgba(17, 37, 47, 0.75) 0%, rgba(17, 37, 47, 0.00) 100%);
9889
9903
  }
9890
9904
 
9891
9905
  :hover {
@@ -9933,12 +9947,13 @@ const HeaderSlideshow = styled.div `
9933
9947
  `;
9934
9948
 
9935
9949
  const FeatureCardBackgroundHeader = () => {
9950
+ const { themeName: pageThemeName } = useGlobalContext();
9936
9951
  const { config } = useWidgetConfig(exports.WidgetType.FeatureCard);
9937
9952
  const { header } = config || {};
9938
9953
  const { options } = header || {};
9939
9954
  const { fontColor, bgColor, height, overlay, bigIcon, withPadding, bottomBlur, themeName, column } = options || {};
9940
9955
  const renderElement = useHeaderRender(header);
9941
- return (jsxRuntime.jsx(BackgroundHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$height": height, "$bigIcon": bigIcon, "$withPadding": withPadding, "$bottomBlur": bottomBlur, children: jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: getThemeByName(themeName), children: jsxRuntime.jsxs(Header, { "$overlay": overlay, "$isRow": !column, children: [jsxRuntime.jsxs(HeaderFrontView, { children: [jsxRuntime.jsxs(HeaderContainer, { column: column, children: [jsxRuntime.jsx(HeaderLayerIcon, {}), jsxRuntime.jsx(FeatureCardTitle, { title: renderElement({
9956
+ return (jsxRuntime.jsx(BackgroundHeaderWrapper, { "$fontColor": fontColor, "$bgColor": bgColor, "$height": height, "$bigIcon": bigIcon, "$withPadding": withPadding, "$bottomBlur": bottomBlur, children: jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: getThemeByName(themeName ?? pageThemeName), children: jsxRuntime.jsxs(Header, { "$overlay": overlay, "$isRow": !column, children: [jsxRuntime.jsxs(HeaderFrontView, { children: [jsxRuntime.jsxs(HeaderContainer, { column: column, children: [jsxRuntime.jsx(HeaderLayerIcon, {}), jsxRuntime.jsx(FeatureCardTitle, { title: renderElement({
9942
9957
  id: "title",
9943
9958
  wrap: false,
9944
9959
  }), description: renderElement({
@@ -10324,8 +10339,8 @@ const getElementValue = ({ getDefaultContainer, ...props }) => {
10324
10339
  return "";
10325
10340
  }
10326
10341
  const alias = attribute?.alias || attributeName || "";
10327
- const { maxLength, lineBreak, expandable } = options || {};
10328
- return alias && maxLength && maxLength < alias.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, expandable: expandable, lineBreak: lineBreak, children: alias })) : (alias);
10342
+ const { maxLength, wordBreak, lineBreak, expandable } = options || {};
10343
+ return alias && maxLength && maxLength < alias.length ? (jsxRuntime.jsx(TextTrim, { maxLength: maxLength, wordBreak: wordBreak, expandable: expandable, lineBreak: lineBreak, children: alias })) : (alias);
10329
10344
  }
10330
10345
  if (type === "attributeValue") {
10331
10346
  /* return isHandbookAttribute(attribute?.name, layerInfo) ? (
@@ -13187,15 +13202,20 @@ const SvgImage = React.memo(({ url, width, height, fontColor }) => {
13187
13202
  return (jsxRuntime.jsx(StyledSvg, { "$width": width, "$height": height, "$fontColor": fontColor, dangerouslySetInnerHTML: { __html: svg } }));
13188
13203
  });
13189
13204
 
13190
- const TextTrim = React.memo(({ maxLength, expandable, lineBreak, children }) => {
13205
+ const TextTrimValue = styled.div `
13206
+ word-break: ${({ wordBreak }) => wordBreak ?? "break-word"};
13207
+ overflow: hidden;
13208
+ `;
13209
+
13210
+ const TextTrim = React.memo(({ maxLength, expandable, lineBreak, wordBreak, children }) => {
13191
13211
  const { t } = useGlobalContext();
13192
13212
  const [expanded, toggleExpanded] = useToggle();
13193
13213
  const text = children?.toString();
13194
13214
  const formatValue = React.useCallback((value) => {
13195
13215
  if (!lineBreak)
13196
- return value;
13197
- return jsxRuntime.jsx("div", { dangerouslySetInnerHTML: { __html: lodash.unescape(value).split(lineBreak).join("<br />") } });
13198
- }, [lineBreak]);
13216
+ return jsxRuntime.jsx(TextTrimValue, { wordBreak: wordBreak, children: value });
13217
+ return jsxRuntime.jsx(TextTrimValue, { wordBreak: wordBreak, dangerouslySetInnerHTML: { __html: lodash.unescape(value).split(lineBreak).join("<br />") } });
13218
+ }, [lineBreak, wordBreak]);
13199
13219
  if (!text?.length || !maxLength || text.length <= maxLength)
13200
13220
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: formatValue(text) });
13201
13221
  const substring = `${text.substring(0, maxLength)}...`;