@evergis/react 3.1.126 → 3.1.128

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
@@ -5577,35 +5577,36 @@ const LayerListContainer = styled(Flex) `
5577
5577
 
5578
5578
  const ElementValueWrapper = styled.div `
5579
5579
  transition: background-color ${transition.toggle};
5580
-
5581
- ${({ noMargin }) => css `
5582
- &&&& {
5583
- margin-bottom: 0;
5584
- }
5585
- `};
5580
+
5581
+ ${({ noMargin }) => !!noMargin &&
5582
+ css `
5583
+ &&&& {
5584
+ margin-bottom: 0;
5585
+ }
5586
+ `};
5586
5587
  `;
5587
5588
  const Container = styled(Flex) `
5588
5589
  flex-direction: column;
5589
5590
  width: 100%;
5590
-
5591
+
5591
5592
  ${({ isColumn }) => isColumn
5592
5593
  ? css `
5593
- &&& > * {
5594
- justify-content: flex-start;
5595
- }
5596
- > * {
5597
- width: 100%;
5598
-
5599
- :not(:last-child) {
5600
- margin-bottom: 0.5rem;
5601
- }
5602
- }
5603
- `
5594
+ &&& > * {
5595
+ justify-content: flex-start;
5596
+ }
5597
+ > * {
5598
+ width: 100%;
5599
+
5600
+ :not(:last-child) {
5601
+ margin-bottom: 0.5rem;
5602
+ }
5603
+ }
5604
+ `
5604
5605
  : css `
5605
- flex-direction: row;
5606
- justify-content: space-between;
5607
- align-items: center;
5608
- `}
5606
+ flex-direction: row;
5607
+ justify-content: space-between;
5608
+ align-items: center;
5609
+ `}
5609
5610
 
5610
5611
  ${({ isTitle }) => isTitle &&
5611
5612
  css `
@@ -5614,12 +5615,13 @@ const Container = styled(Flex) `
5614
5615
  }
5615
5616
  `}
5616
5617
 
5617
- ${({ noBorders }) => noBorders && css `
5618
- ${ContainerWrapper} {
5619
- box-shadow: none;
5620
- padding: 0;
5621
- }
5622
- `}
5618
+ ${({ noBorders }) => noBorders &&
5619
+ css `
5620
+ ${ContainerWrapper} {
5621
+ box-shadow: none;
5622
+ padding: 0;
5623
+ }
5624
+ `}
5623
5625
  `;
5624
5626
  const ContainerWrapper = styled(Flex) `
5625
5627
  position: relative;
@@ -5634,12 +5636,13 @@ const ContainerWrapper = styled(Flex) `
5634
5636
  color: ${({ theme: { palette } }) => palette.textPrimary};
5635
5637
  z-index: ${({ $zIndex }) => $zIndex ?? 1};
5636
5638
  transition: background-color ${transition.toggle};
5637
-
5638
- ${({ $noMargin }) => $noMargin && css `
5639
- &&&& {
5640
- margin-bottom: 0;
5641
- }
5642
- `}
5639
+
5640
+ ${({ $noMargin }) => $noMargin &&
5641
+ css `
5642
+ &&&& {
5643
+ margin-bottom: 0;
5644
+ }
5645
+ `}
5643
5646
  `;
5644
5647
  const DashboardChip = styled(Chip) `
5645
5648
  margin: 0 0.25rem 0.25rem 0;
@@ -5654,7 +5657,7 @@ const DashboardChip = styled(Chip) `
5654
5657
  }
5655
5658
 
5656
5659
  span[kind]:after {
5657
- color: ${({ $isDefault, $fontColor, theme: { palette } }) => ($isDefault ? palette.icon : $fontColor || "#fff")};
5660
+ color: ${({ $isDefault, $fontColor, theme: { palette } }) => $isDefault ? palette.icon : $fontColor || "#fff"};
5658
5661
  }
5659
5662
  `;
5660
5663
  const DashboardPlaceholderWrap = styled(Flex) `
@@ -5675,7 +5678,7 @@ const DashboardPlaceholder = styled(Flex) `
5675
5678
  css `
5676
5679
  width: 6.25rem;
5677
5680
  `}
5678
-
5681
+
5679
5682
  &&& > * {
5680
5683
  margin-bottom: 0;
5681
5684
  }
@@ -5842,7 +5845,7 @@ const PresentationPanelContainer = styled.div `
5842
5845
  height: auto;
5843
5846
  margin: 0 -1.125rem -1.5rem;
5844
5847
  padding: 0;
5845
-
5848
+
5846
5849
  ${LayerGroupList} {
5847
5850
  padding: 0;
5848
5851
  }
@@ -5869,7 +5872,7 @@ const DataSourceErrorContainer = styled(Flex) `
5869
5872
  `;
5870
5873
  const AttributeLabel = styled(Description) `
5871
5874
  margin-top: 0 !important;
5872
- margin-bottom: ${({ forCheckbox }) => (forCheckbox ? "0.75rem" : "0.25rem")} !important;
5875
+ margin-bottom: ${({ forCheckbox }) => forCheckbox ? "0.75rem" : "0.25rem"} !important;
5873
5876
  padding-left: ${({ isEdit }) => (isEdit ? "0.5rem" : "0")};
5874
5877
  `;
5875
5878
  const FeatureControls = styled(Flex) `
@@ -5894,9 +5897,11 @@ const getAttributeByName = (attributeName, attributes) => {
5894
5897
  };
5895
5898
 
5896
5899
  const formatElementValue = ({ t, value, elementConfig, attributes, wrap, }) => {
5897
- const { id, type, defaultValue, options, style, attributeName, templateName } = elementConfig || {};
5898
- const attribute = attributeName ? getAttributeByName(attributeName, attributes) : null;
5899
- const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius, noMargin } = options || {};
5900
+ const { id, type, defaultValue, options, style, attributeName, templateName, } = elementConfig || {};
5901
+ const attribute = attributeName
5902
+ ? getAttributeByName(attributeName, attributes)
5903
+ : null;
5904
+ const { fontColor, fontSize, noUnits, tagView, bgColor, withDivider, radius, noMargin, } = options || {};
5900
5905
  const valueOrDefault = value || defaultValue;
5901
5906
  const resultValue = type === "attributeValue" && attribute?.type && attribute?.stringFormat
5902
5907
  ? formatAttributeValue({
@@ -6167,7 +6172,7 @@ const OneColumnContainer = memo(({ type, elementConfig, renderElement }) => {
6167
6172
  const { id, value, hideEmpty, style, hasUnits, render } = getRenderContainerItem(elementConfig, attribute);
6168
6173
  if (!value && hideEmpty)
6169
6174
  return null;
6170
- return (jsxs(Container, { id: id, isColumn: true, style: { ...BASE_CONTAINER_STYLE, ...style }, children: [jsxs(ContainerAlias, { hasBottomMargin: true, children: [render({ id: "alias" }), render({ id: "tooltip" })] }), jsxs(ContainerValue, { children: [value, hasUnits && (jsx(ContainerUnits, { children: render({ id: "units" }) }))] })] }));
6175
+ return (jsxs(Container, { id: id, isColumn: true, style: { ...BASE_CONTAINER_STYLE, ...style }, children: [jsxs(ContainerAlias, { hasBottomMargin: true, children: [render({ id: "alias" }), render({ id: "tooltip" }), render({ id: "modal" })] }), jsxs(ContainerValue, { children: [value, hasUnits && (jsx(ContainerUnits, { children: render({ id: "units" }) }))] })] }));
6171
6176
  }, [getRenderContainerItem, elementConfig]);
6172
6177
  return renderAttributes?.length ? (jsx(Fragment$1, { children: renderAttributes.map(renderContainer) })) : (renderContainer());
6173
6178
  });
@@ -6180,7 +6185,7 @@ const TwoColumnContainer = memo(({ elementConfig, type, renderElement }) => {
6180
6185
  const { id, value, hideEmpty, style, hasIcon, hasUnits, render } = getRenderContainerItem(elementConfig, attribute);
6181
6186
  if (!value && hideEmpty)
6182
6187
  return null;
6183
- return (jsxs(TwoColumnContainerWrapper, { id: id, style: style, children: [jsxs(ContainerAlias, { children: [hasIcon && jsx(ContainerAliasIcon, { children: render({ id: "icon" }) }), render({ id: "alias" }), render({ id: "tooltip" })] }), jsxs(ContainerValue, { big: true, children: [value, hasUnits && jsx(ContainerUnits, { children: render({ id: "units" }) })] })] }, attribute));
6188
+ return (jsxs(TwoColumnContainerWrapper, { id: id, style: style, children: [jsxs(ContainerAlias, { children: [hasIcon && (jsx(ContainerAliasIcon, { children: render({ id: "icon" }) })), render({ id: "alias" }), render({ id: "tooltip" }), render({ id: "modal" })] }), jsxs(ContainerValue, { big: true, children: [value, hasUnits && (jsx(ContainerUnits, { children: render({ id: "units" }) }))] })] }, attribute));
6184
6189
  }, [getRenderContainerItem, elementConfig]);
6185
6190
  return renderAttributes?.length ? (jsx(Fragment$1, { children: renderAttributes.map(attribute => renderContainer(attribute)) })) : (renderContainer());
6186
6191
  });
@@ -9127,6 +9132,131 @@ const ElementUploader = memo(({ elementConfig, type }) => {
9127
9132
  return (jsx(UploaderContainer, { id: id, style: style, children: jsx("div", { children: jsx(Uploader, { currentRef: refInput, title: renderTitle, accept: fileExtensions, width: "100%", fileItems: files, isMultiple: multiSelect, onUpload: onUpload, onDelete: onDelete }) }) }));
9128
9133
  });
9129
9134
 
9135
+ const ModalIcon = styled(Icon) `
9136
+ &&& {
9137
+ cursor: pointer;
9138
+
9139
+ :after {
9140
+ font-size: 0.75rem;
9141
+ color: ${({ theme: { palette } }) => palette.iconDisabled};
9142
+ transition: color ${transition.hover};
9143
+ }
9144
+
9145
+ :hover:after {
9146
+ color: ${({ theme: { palette } }) => palette.icon};
9147
+ }
9148
+ }
9149
+ `;
9150
+
9151
+ const isEmptyElementValue = (value) => value === "" || value === null || value === undefined;
9152
+
9153
+ const isHiddenEmptyValue = ({ value, children, hideEmpty, renderElement, }) => {
9154
+ const valueElement = children?.find(item => item.id === "value");
9155
+ const renderedValue = valueElement ? renderElement({ id: "value" }) : null;
9156
+ const isEmpty = isEmptyElementValue(value) || (valueElement && (renderedValue === null || renderedValue === ""));
9157
+ return isEmpty && hideEmpty;
9158
+ };
9159
+
9160
+ const isNotValidSelectedTab = (tabId, selectedTabId) => {
9161
+ if (!tabId || !selectedTabId)
9162
+ return false;
9163
+ return Array.isArray(tabId) ? !tabId.includes(selectedTabId) : tabId !== selectedTabId;
9164
+ };
9165
+
9166
+ const isVisibleContainer = (id, expandable, expanded, expandedContainers) => !expandable || (expandedContainers?.[id] !== undefined ? expandedContainers[id] : expanded) || false;
9167
+
9168
+ const isContainerRef = (element) => "containerId" in element &&
9169
+ !("templateName" in element) &&
9170
+ !("type" in element) &&
9171
+ !("children" in element);
9172
+ const getRenderElement = ({ t, config, elementConfig, attributes = [], layerInfo, selectedTabId, setSelectedTabId, pageIndex, expandedContainers, type = WidgetType.FeatureCard, }) => (props) => {
9173
+ const { id, index, wrap = true } = props;
9174
+ const currentConfig = elementConfig || config;
9175
+ let element = id
9176
+ ? returnFound(currentConfig?.children, { id })
9177
+ : index !== undefined
9178
+ ? currentConfig?.children[index]
9179
+ : null;
9180
+ if (Array.isArray(element)) {
9181
+ element = element[0];
9182
+ }
9183
+ if (element && isContainerRef(element)) {
9184
+ let container = returnFound(config, { id: element.containerId });
9185
+ if (Array.isArray(container))
9186
+ container = container[0];
9187
+ element = container || undefined;
9188
+ }
9189
+ const { options, children, templateName } = element || {};
9190
+ const { tabId, hideEmpty, expandable, expanded, innerTemplateName } = options || {};
9191
+ if (isNotValidSelectedTab(tabId, selectedTabId))
9192
+ return null;
9193
+ const renderElement = getRenderElement({
9194
+ t,
9195
+ config,
9196
+ elementConfig: element,
9197
+ attributes,
9198
+ layerInfo,
9199
+ expandedContainers,
9200
+ selectedTabId,
9201
+ setSelectedTabId,
9202
+ pageIndex,
9203
+ type,
9204
+ });
9205
+ const value = getElementValue({
9206
+ type,
9207
+ element: currentConfig,
9208
+ elementConfig: element,
9209
+ config,
9210
+ attributes,
9211
+ layerInfo,
9212
+ renderElement,
9213
+ getDefaultContainer: () => {
9214
+ if (!templateName) {
9215
+ return null;
9216
+ }
9217
+ const ContainerTemplateValue = getContainerComponent(templateName);
9218
+ if (!ContainerTemplateValue) {
9219
+ return null;
9220
+ }
9221
+ return (jsx(ContainerTemplateValue, { id: id, type: type, config: config, elementConfig: element, layerInfo: layerInfo, attributes: attributes, innerComponent: getContainerComponent(innerTemplateName), isVisible: isVisibleContainer(id, expandable, expanded, expandedContainers), renderElement: renderElement }, id));
9222
+ },
9223
+ });
9224
+ if (isHiddenEmptyValue({ value, children, hideEmpty, renderElement }))
9225
+ return null;
9226
+ return formatElementValue({
9227
+ t,
9228
+ value,
9229
+ elementConfig: element,
9230
+ attributes,
9231
+ wrap,
9232
+ });
9233
+ };
9234
+
9235
+ const ElementModal = memo(({ type = WidgetType.Dashboard, elementConfig }) => {
9236
+ const { config } = useWidgetConfig(type);
9237
+ const { expandedContainers, attributes, isLoading } = useWidgetContext(type);
9238
+ const [isOpen, setIsOpen] = useState(false);
9239
+ const { options } = elementConfig || {};
9240
+ const { modalId, icon } = options || {};
9241
+ const modalConfig = useMemo(() => (config?.modals ?? []).find(({ id }) => id === modalId) ?? null, [config?.modals, modalId]);
9242
+ const modalContent = useMemo(() => (modalConfig?.children ?? []), [modalConfig]);
9243
+ const renderElementConfig = useMemo(() => ({ children: modalContent }), [modalContent]);
9244
+ const renderElement = useMemo(() => getRenderElement({
9245
+ type,
9246
+ config,
9247
+ elementConfig: renderElementConfig,
9248
+ attributes,
9249
+ expandedContainers,
9250
+ }), [type, config, renderElementConfig, attributes, expandedContainers]);
9251
+ const handleOpen = useCallback(() => setIsOpen(true), []);
9252
+ const handleClose = useCallback(() => setIsOpen(false), []);
9253
+ if (!modalConfig)
9254
+ return null;
9255
+ const { options: modalOptions } = modalConfig;
9256
+ const { title, maxWidth, minWidth, minHeight } = modalOptions || {};
9257
+ return (jsxs(Fragment$1, { children: [jsx(ModalIcon, { kind: icon || "new_window", onClick: handleOpen }), jsxs(Dialog, { isOpen: isOpen, onCloseRequest: handleClose, modal: true, maxWidth: maxWidth, minWidth: minWidth, minHeight: minHeight, style: { paddingBottom: "2rem" }, children: [jsx(DialogTitle, { children: jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [!!title && jsx("span", { children: title }), jsx(IconButton, { kind: "close", onClick: handleClose })] }) }), jsx(DialogContent, { children: isLoading ? (jsx(DashboardLoading, {})) : (jsx(Container, { isColumn: true, noBorders: true, children: jsx(ContainerChildren, { type: type, items: modalContent, isMain: true, renderElement: renderElement }) })) })] })] }));
9258
+ });
9259
+
9130
9260
  const elementComponents = {
9131
9261
  control: ElementControl,
9132
9262
  image: ElementImage,
@@ -9142,6 +9272,7 @@ const elementComponents = {
9142
9272
  legend: ElementLegend,
9143
9273
  markdown: ElementMarkdown,
9144
9274
  uploader: ElementUploader,
9275
+ modal: ElementModal,
9145
9276
  };
9146
9277
 
9147
9278
  const getElementValue = ({ getDefaultContainer, ...props }) => {
@@ -9170,10 +9301,13 @@ const getElementValue = ({ getDefaultContainer, ...props }) => {
9170
9301
  }
9171
9302
  if (type === "attributeDescription") {
9172
9303
  const attribute = getAttributeByName(attributeName, attributes);
9173
- return attribute?.name ? layerInfo.layerDefinition.attributes[attribute.name]?.description || null : null;
9304
+ return attribute?.name
9305
+ ? layerInfo.layerDefinition.attributes[attribute.name]?.description ||
9306
+ null
9307
+ : null;
9174
9308
  }
9175
9309
  const ElementComponent = type ? elementComponents[type] : null;
9176
- return ElementComponent ? jsx(ElementComponent, { ...props }) : getDefaultContainer?.();
9310
+ return ElementComponent ? (jsx(ElementComponent, { ...props })) : (getDefaultContainer?.());
9177
9311
  };
9178
9312
 
9179
9313
  const getLayerAttributes = (layerDefinition) => {
@@ -10142,69 +10276,6 @@ const getRelatedAttribute = (layerInfo, sourceAttributeName, relatedLayerName) =
10142
10276
  return attributeConfig?.options?.relatedAttributes?.find(({ layerName }) => layerName === relatedLayerName);
10143
10277
  };
10144
10278
 
10145
- const isEmptyElementValue = (value) => value === "" || value === null || value === undefined;
10146
-
10147
- const isHiddenEmptyValue = ({ value, children, hideEmpty, renderElement, }) => {
10148
- const valueElement = children?.find(item => item.id === "value");
10149
- const renderedValue = valueElement ? renderElement({ id: "value" }) : null;
10150
- const isEmpty = isEmptyElementValue(value) || (valueElement && (renderedValue === null || renderedValue === ""));
10151
- return isEmpty && hideEmpty;
10152
- };
10153
-
10154
- const isNotValidSelectedTab = (tabId, selectedTabId) => {
10155
- if (!tabId || !selectedTabId)
10156
- return false;
10157
- return Array.isArray(tabId) ? !tabId.includes(selectedTabId) : tabId !== selectedTabId;
10158
- };
10159
-
10160
- const isVisibleContainer = (id, expandable, expanded, expandedContainers) => !expandable || (expandedContainers?.[id] !== undefined ? expandedContainers[id] : expanded) || false;
10161
-
10162
- const getRenderElement = ({ t, config, elementConfig, attributes = [], layerInfo, selectedTabId, setSelectedTabId, pageIndex, expandedContainers, type = WidgetType.FeatureCard, }) => (props) => {
10163
- const { id, index, wrap = true } = props;
10164
- const currentConfig = elementConfig || config;
10165
- let element = id ? returnFound(currentConfig?.children, { id }) : index ? currentConfig?.children[index] : null;
10166
- if (Array.isArray(element)) {
10167
- element = element[0];
10168
- }
10169
- const { options, children, templateName } = element || {};
10170
- const { tabId, hideEmpty, expandable, expanded, innerTemplateName } = options || {};
10171
- if (isNotValidSelectedTab(tabId, selectedTabId))
10172
- return null;
10173
- const renderElement = getRenderElement({
10174
- t,
10175
- config,
10176
- elementConfig: element,
10177
- attributes,
10178
- layerInfo,
10179
- expandedContainers,
10180
- selectedTabId,
10181
- setSelectedTabId,
10182
- pageIndex,
10183
- type,
10184
- });
10185
- const value = getElementValue({
10186
- type,
10187
- element: currentConfig,
10188
- elementConfig: element,
10189
- attributes,
10190
- layerInfo,
10191
- renderElement,
10192
- getDefaultContainer: () => {
10193
- if (!templateName) {
10194
- return null;
10195
- }
10196
- const ContainerTemplateValue = getContainerComponent(templateName);
10197
- if (!ContainerTemplateValue) {
10198
- return null;
10199
- }
10200
- return (jsx(ContainerTemplateValue, { id: id, type: type, config: config, elementConfig: element, layerInfo: layerInfo, attributes: attributes, innerComponent: getContainerComponent(innerTemplateName), isVisible: isVisibleContainer(id, expandable, expanded, expandedContainers), renderElement: renderElement }, id));
10201
- },
10202
- });
10203
- if (isHiddenEmptyValue({ value, children, hideEmpty, renderElement }))
10204
- return null;
10205
- return formatElementValue({ t, value, elementConfig: element, attributes, wrap });
10206
- };
10207
-
10208
10279
  const getResourceUrl = (url) => {
10209
10280
  return url ? (url.startsWith("http") ? url : `/sp/resources/file/${url}`) : "";
10210
10281
  };