@evergis/react 3.1.75 → 3.1.76

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>;
package/dist/index.js CHANGED
@@ -7846,15 +7846,14 @@ const ExternalLink = styled(uilibGl.IconButton).attrs(() => ({
7846
7846
  color: ${({ theme: { palette } }) => palette.primaryDeep};
7847
7847
  }
7848
7848
  `;
7849
- const LocalLinkBlank = styled(uilibGl.Blank) `
7850
- min-width: 13.5rem;
7851
- padding: 0.5rem 0.75rem 0;
7852
-
7853
- a {
7849
+ const Link = styled.a `
7854
7850
  text-decoration: none;
7855
7851
  font-size: 0.75rem;
7856
7852
  color: ${({ theme: { palette } }) => palette.primary};
7857
- }
7853
+ `;
7854
+ const LocalLinkBlank = styled(uilibGl.Blank) `
7855
+ min-width: 13.5rem;
7856
+ padding: 0.5rem 0.75rem 0;
7858
7857
 
7859
7858
  ${uilibGl.IconButtonButton} {
7860
7859
  font-size: 0.75rem;
@@ -7889,23 +7888,30 @@ const LocalLinkCopy = styled(uilibGl.Flex) `
7889
7888
  justify-content: center;
7890
7889
  `;
7891
7890
 
7892
- const LocalLink = React.memo(({ link }) => {
7891
+ const LocalLink = React.memo(({ link, style }) => {
7893
7892
  const { t } = useGlobalContext();
7894
7893
  const [isOpen, toggleOpen] = useToggle();
7895
7894
  const onCopy = React.useCallback(() => {
7896
7895
  navigator.clipboard.writeText(link);
7897
7896
  toggleOpen();
7898
7897
  }, [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: "Копировать" }) }) })] }) }));
7898
+ 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
7899
  });
7901
7900
 
7902
7901
  const ElementLink = React.memo(({ type, elementConfig }) => {
7903
7902
  const { attributes } = useWidgetContext(type);
7904
- const attribute = getAttributeByName(elementConfig?.attributeName, attributes);
7905
- const link = getResourceUrl(attribute?.value?.toString());
7903
+ const { options, style } = elementConfig || {};
7904
+ const { simple, title } = options || {};
7905
+ const attribute = React.useMemo(() => getAttributeByName(elementConfig?.attributeName, attributes), [attributes, elementConfig?.attributeName]);
7906
+ const link = React.useMemo(() => getResourceUrl(attribute?.value?.toString()), [attribute?.value]);
7906
7907
  if (!link)
7907
7908
  return null;
7908
- return link.startsWith("http") ? jsxRuntime.jsx(ExternalLink, { onClick: () => window.open(link) }) : jsxRuntime.jsx(LocalLink, { link: link });
7909
+ if (simple) {
7910
+ return (jsxRuntime.jsx(Link, { href: link, target: "_blank", rel: "noreferrer", style: style, children: title ?? link }));
7911
+ }
7912
+ return link.startsWith("http")
7913
+ ? jsxRuntime.jsx(ExternalLink, { style: style, onClick: () => window.open(link) })
7914
+ : jsxRuntime.jsx(LocalLink, { style: style, link: link });
7909
7915
  });
7910
7916
 
7911
7917
  const MarkdownWrapper = styled.div `