@evergis/react 3.1.75 → 3.1.77

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.
@@ -1,4 +1,5 @@
1
- import { FC } from 'react';
1
+ import { CSSProperties, FC } from 'react';
2
2
  export declare const LocalLink: FC<{
3
3
  link: string;
4
+ style?: CSSProperties;
4
5
  }>;
@@ -1,4 +1,5 @@
1
1
  export declare const ExternalLink: import('styled-components').StyledComponent<any, any, any, any>;
2
+ export declare const Link: import('styled-components').StyledComponent<"a", any, {}, never>;
2
3
  export declare const LocalLinkBlank: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').IBlankProps, never>;
3
4
  export declare const LocalLinkButton: import('styled-components').StyledComponent<any, any, any, any>;
4
5
  export declare const LocalLinkCopy: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
@@ -1,5 +1 @@
1
1
  export declare const MarkdownWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
2
- export declare const SocialIconsWrapper: import('styled-components').StyledComponent<"div", any, import('@evergis/uilib-gl').FlexProps, never>;
3
- export declare const SocialIconLabel: import('styled-components').StyledComponent<"span", any, {}, never>;
4
- export declare const SocialIcon: import('styled-components').StyledComponent<"div", any, {}, never>;
5
- export declare const ExpandButton: import('styled-components').StyledComponent<import('react').FC<import('@evergis/uilib-gl').IIconButtonProps>, any, {}, never>;
package/dist/index.js CHANGED
@@ -5163,7 +5163,8 @@ const Container = styled(uilibGl.Flex) `
5163
5163
 
5164
5164
  ${({ isColumn }) => isColumn
5165
5165
  ? styled.css `
5166
- > * {
5166
+ &&& > * {
5167
+ justify-content: flex-start;
5167
5168
  width: 100%;
5168
5169
 
5169
5170
  :not(:last-child) {
@@ -5681,7 +5682,7 @@ const OneColumnContainer = React.memo(({ elementConfig, renderElement }) => {
5681
5682
  const hasUnits = elementConfig?.children?.some(({ id }) => id === "units");
5682
5683
  if (!value && hideEmpty)
5683
5684
  return null;
5684
- return (jsxRuntime.jsxs(Container, { id: id, style: innerTemplateStyle || style, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsxs(ContainerValue, { children: [value, hasUnits && jsxRuntime.jsx(ContainerUnits, { children: renderElement({ id: "units" }) })] })] }));
5685
+ return (jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: innerTemplateStyle || style, children: [jsxRuntime.jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxRuntime.jsxs(ContainerValue, { children: [value, hasUnits && jsxRuntime.jsx(ContainerUnits, { children: renderElement({ id: "units" }) })] })] }));
5685
5686
  });
5686
5687
 
5687
5688
  const TwoColumnContainer = React.memo(({ config, elementConfig, type, renderElement }) => {
@@ -7846,15 +7847,14 @@ const ExternalLink = styled(uilibGl.IconButton).attrs(() => ({
7846
7847
  color: ${({ theme: { palette } }) => palette.primaryDeep};
7847
7848
  }
7848
7849
  `;
7849
- const LocalLinkBlank = styled(uilibGl.Blank) `
7850
- min-width: 13.5rem;
7851
- padding: 0.5rem 0.75rem 0;
7852
-
7853
- a {
7850
+ const Link = styled.a `
7854
7851
  text-decoration: none;
7855
7852
  font-size: 0.75rem;
7856
7853
  color: ${({ theme: { palette } }) => palette.primary};
7857
- }
7854
+ `;
7855
+ const LocalLinkBlank = styled(uilibGl.Blank) `
7856
+ min-width: 13.5rem;
7857
+ padding: 0.5rem 0.75rem 0;
7858
7858
 
7859
7859
  ${uilibGl.IconButtonButton} {
7860
7860
  font-size: 0.75rem;
@@ -7889,23 +7889,30 @@ const LocalLinkCopy = styled(uilibGl.Flex) `
7889
7889
  justify-content: center;
7890
7890
  `;
7891
7891
 
7892
- const LocalLink = React.memo(({ link }) => {
7892
+ const LocalLink = React.memo(({ link, style }) => {
7893
7893
  const { t } = useGlobalContext();
7894
7894
  const [isOpen, toggleOpen] = useToggle();
7895
7895
  const onCopy = React.useCallback(() => {
7896
7896
  navigator.clipboard.writeText(link);
7897
7897
  toggleOpen();
7898
7898
  }, [link, toggleOpen]);
7899
- return (jsxRuntime.jsx(uilibGl.Popover, { open: isOpen, zIndex: 10, onRequestClose: toggleOpen, anchorOrigin: "bottom-right", targetOrigin: "top-right", anchor: jsxRuntime.jsx(LocalLinkButton, { onClick: toggleOpen }), children: jsxRuntime.jsxs(LocalLinkBlank, { children: [jsxRuntime.jsx("a", { href: link, target: "_blank", rel: "noreferrer", children: link }), jsxRuntime.jsx(LocalLinkCopy, { children: jsxRuntime.jsx(uilibGl.IconButton, { kind: "copy", onClick: onCopy, children: t("copy", { ns: "dashboard", defaultValue: "Копировать" }) }) })] }) }));
7899
+ return (jsxRuntime.jsx(uilibGl.Popover, { open: isOpen, zIndex: 10, onRequestClose: toggleOpen, anchorOrigin: "bottom-right", targetOrigin: "top-right", anchor: jsxRuntime.jsx(LocalLinkButton, { onClick: toggleOpen }), children: jsxRuntime.jsxs(LocalLinkBlank, { children: [jsxRuntime.jsx(Link, { href: link, target: "_blank", rel: "noreferrer", style: style, children: link }), jsxRuntime.jsx(LocalLinkCopy, { children: jsxRuntime.jsx(uilibGl.IconButton, { kind: "copy", onClick: onCopy, children: t("copy", { ns: "dashboard", defaultValue: "Копировать" }) }) })] }) }));
7900
7900
  });
7901
7901
 
7902
7902
  const ElementLink = React.memo(({ type, elementConfig }) => {
7903
7903
  const { attributes } = useWidgetContext(type);
7904
- const attribute = getAttributeByName(elementConfig?.attributeName, attributes);
7905
- const link = getResourceUrl(attribute?.value?.toString());
7904
+ const { options, style } = elementConfig || {};
7905
+ const { simple, title } = options || {};
7906
+ const attribute = React.useMemo(() => getAttributeByName(elementConfig?.attributeName, attributes), [attributes, elementConfig?.attributeName]);
7907
+ const link = React.useMemo(() => getResourceUrl(attribute?.value?.toString()), [attribute?.value]);
7906
7908
  if (!link)
7907
7909
  return null;
7908
- return link.startsWith("http") ? jsxRuntime.jsx(ExternalLink, { onClick: () => window.open(link) }) : jsxRuntime.jsx(LocalLink, { link: link });
7910
+ if (simple) {
7911
+ return (jsxRuntime.jsx(Link, { href: link, target: "_blank", rel: "noreferrer", style: style, children: title ?? link }));
7912
+ }
7913
+ return link.startsWith("http")
7914
+ ? jsxRuntime.jsx(ExternalLink, { style: style, onClick: () => window.open(link) })
7915
+ : jsxRuntime.jsx(LocalLink, { style: style, link: link });
7909
7916
  });
7910
7917
 
7911
7918
  const MarkdownWrapper = styled.div `
@@ -8007,37 +8014,6 @@ const MarkdownWrapper = styled.div `
8007
8014
  display: none;
8008
8015
  }
8009
8016
  `;
8010
- styled(uilibGl.Flex) `
8011
- align-items: center;
8012
- gap: 1rem;
8013
- margin-top: 1rem;
8014
- `;
8015
- styled.span `
8016
- display: block;
8017
- font-size: 0.75rem;
8018
- line-height: 0.875rem;
8019
- opacity: 0.36;
8020
- margin: 0 0 0.5rem 0;
8021
- `;
8022
- styled.div `
8023
- width: 1.25rem;
8024
- height: 1.25rem;
8025
- cursor: pointer;
8026
- transition: opacity 0.2s;
8027
-
8028
- &:hover {
8029
- opacity: 0.7;
8030
- }
8031
-
8032
- img, svg {
8033
- width: 100%;
8034
- height: 100%;
8035
- display: block;
8036
- }
8037
- `;
8038
- const ExpandButton = styled(uilibGl.IconButton) `
8039
- margin-bottom: 1rem;
8040
- `;
8041
8017
 
8042
8018
  const ElementMarkdown = React.memo(({ elementConfig, type }) => {
8043
8019
  const { attributes } = useWidgetContext(type);
@@ -8061,14 +8037,14 @@ const ElementMarkdown = React.memo(({ elementConfig, type }) => {
8061
8037
  if (!shouldShowExpand) {
8062
8038
  return (jsxRuntime.jsx(MarkdownWrapper, { children: jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString }) }));
8063
8039
  }
8064
- // Truncated content for collapsed state
8065
- const truncatedContent = markdownString.substring(0, expandLength);
8066
8040
  // Collapsed state
8067
8041
  if (!expanded) {
8068
- return (jsxRuntime.jsxs(MarkdownWrapper, { children: [jsxRuntime.jsx(ExpandButton, { primary: true, icon: jsxRuntime.jsx(uilibGl.Expander, { isSelected: false }), onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) }), jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: truncatedContent })] }));
8042
+ // Truncated content for collapsed state
8043
+ const truncatedContent = markdownString.substring(0, expandLength);
8044
+ return (jsxRuntime.jsxs(MarkdownWrapper, { children: [jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: truncatedContent }), jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
8069
8045
  }
8070
8046
  // Expanded state
8071
- return (jsxRuntime.jsxs(MarkdownWrapper, { children: [jsxRuntime.jsx(ExpandButton, { primary: true, icon: jsxRuntime.jsx(uilibGl.Expander, { isSelected: true }), onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) }), jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString })] }));
8047
+ return (jsxRuntime.jsxs(MarkdownWrapper, { children: [jsxRuntime.jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString }), jsxRuntime.jsx(uilibGl.LegendToggler, { toggled: true, onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) })] }));
8072
8048
  });
8073
8049
 
8074
8050
  const SmallPreviewContainer = styled.div `