@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.
package/dist/react.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
2
- import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, ThemeProvider, darkTheme, DialogContent, CircularProgress, LinearProgress, H2, defaultTheme, Preview, Blank, Popover, Expander, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Dropdown, Checkbox, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
2
+ import { IconButton, Flex, transition, Chip, Icon, Description, FlexSpan, IconToggle, Popup, Menu, DraggableTree, shadows, Divider, LegendToggler, Tooltip as Tooltip$1, DropdownField, MultiSelectContainer, IconButtonButton, FlatButton, DraggableTreeContainer, Dialog, DialogTitle, ThemeProvider, darkTheme, DialogContent, CircularProgress, LinearProgress, H2, defaultTheme, Preview, Blank, Popover, UploaderItemArea, UploaderTitleWrapper, Uploader, NumberRangeSlider, useAsyncAutocomplete, AutoComplete, Dropdown, Checkbox, RangeNumberInput, dateFormat } from '@evergis/uilib-gl';
3
3
  import { createContext, memo, useRef, useState, useEffect, useCallback, useContext, useMemo, Fragment } from 'react';
4
4
  import styled, { createGlobalStyle, css, useTheme } from 'styled-components';
5
5
  import { lineChartClassNames, BarChart as BarChart$1, barChartClassNames, LineChart, PieChart } from '@evergis/charts';
@@ -5161,7 +5161,8 @@ const Container = styled(Flex) `
5161
5161
 
5162
5162
  ${({ isColumn }) => isColumn
5163
5163
  ? css `
5164
- > * {
5164
+ &&& > * {
5165
+ justify-content: flex-start;
5165
5166
  width: 100%;
5166
5167
 
5167
5168
  :not(:last-child) {
@@ -5679,7 +5680,7 @@ const OneColumnContainer = memo(({ elementConfig, renderElement }) => {
5679
5680
  const hasUnits = elementConfig?.children?.some(({ id }) => id === "units");
5680
5681
  if (!value && hideEmpty)
5681
5682
  return null;
5682
- return (jsxs(Container, { id: id, style: innerTemplateStyle || style, children: [jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxs(ContainerValue, { children: [value, hasUnits && jsx(ContainerUnits, { children: renderElement({ id: "units" }) })] })] }));
5683
+ return (jsxs(Container, { id: id, isColumn: true, style: innerTemplateStyle || style, children: [jsxs(ContainerAlias, { hasBottomMargin: true, children: [renderElement({ id: "alias" }), renderElement({ id: "tooltip" })] }), jsxs(ContainerValue, { children: [value, hasUnits && jsx(ContainerUnits, { children: renderElement({ id: "units" }) })] })] }));
5683
5684
  });
5684
5685
 
5685
5686
  const TwoColumnContainer = memo(({ config, elementConfig, type, renderElement }) => {
@@ -7844,15 +7845,14 @@ const ExternalLink = styled(IconButton).attrs(() => ({
7844
7845
  color: ${({ theme: { palette } }) => palette.primaryDeep};
7845
7846
  }
7846
7847
  `;
7847
- const LocalLinkBlank = styled(Blank) `
7848
- min-width: 13.5rem;
7849
- padding: 0.5rem 0.75rem 0;
7850
-
7851
- a {
7848
+ const Link = styled.a `
7852
7849
  text-decoration: none;
7853
7850
  font-size: 0.75rem;
7854
7851
  color: ${({ theme: { palette } }) => palette.primary};
7855
- }
7852
+ `;
7853
+ const LocalLinkBlank = styled(Blank) `
7854
+ min-width: 13.5rem;
7855
+ padding: 0.5rem 0.75rem 0;
7856
7856
 
7857
7857
  ${IconButtonButton} {
7858
7858
  font-size: 0.75rem;
@@ -7887,23 +7887,30 @@ const LocalLinkCopy = styled(Flex) `
7887
7887
  justify-content: center;
7888
7888
  `;
7889
7889
 
7890
- const LocalLink = memo(({ link }) => {
7890
+ const LocalLink = memo(({ link, style }) => {
7891
7891
  const { t } = useGlobalContext();
7892
7892
  const [isOpen, toggleOpen] = useToggle();
7893
7893
  const onCopy = useCallback(() => {
7894
7894
  navigator.clipboard.writeText(link);
7895
7895
  toggleOpen();
7896
7896
  }, [link, toggleOpen]);
7897
- return (jsx(Popover, { open: isOpen, zIndex: 10, onRequestClose: toggleOpen, anchorOrigin: "bottom-right", targetOrigin: "top-right", anchor: jsx(LocalLinkButton, { onClick: toggleOpen }), children: jsxs(LocalLinkBlank, { children: [jsx("a", { href: link, target: "_blank", rel: "noreferrer", children: link }), jsx(LocalLinkCopy, { children: jsx(IconButton, { kind: "copy", onClick: onCopy, children: t("copy", { ns: "dashboard", defaultValue: "Копировать" }) }) })] }) }));
7897
+ return (jsx(Popover, { open: isOpen, zIndex: 10, onRequestClose: toggleOpen, anchorOrigin: "bottom-right", targetOrigin: "top-right", anchor: jsx(LocalLinkButton, { onClick: toggleOpen }), children: jsxs(LocalLinkBlank, { children: [jsx(Link, { href: link, target: "_blank", rel: "noreferrer", style: style, children: link }), jsx(LocalLinkCopy, { children: jsx(IconButton, { kind: "copy", onClick: onCopy, children: t("copy", { ns: "dashboard", defaultValue: "Копировать" }) }) })] }) }));
7898
7898
  });
7899
7899
 
7900
7900
  const ElementLink = memo(({ type, elementConfig }) => {
7901
7901
  const { attributes } = useWidgetContext(type);
7902
- const attribute = getAttributeByName(elementConfig?.attributeName, attributes);
7903
- const link = getResourceUrl(attribute?.value?.toString());
7902
+ const { options, style } = elementConfig || {};
7903
+ const { simple, title } = options || {};
7904
+ const attribute = useMemo(() => getAttributeByName(elementConfig?.attributeName, attributes), [attributes, elementConfig?.attributeName]);
7905
+ const link = useMemo(() => getResourceUrl(attribute?.value?.toString()), [attribute?.value]);
7904
7906
  if (!link)
7905
7907
  return null;
7906
- return link.startsWith("http") ? jsx(ExternalLink, { onClick: () => window.open(link) }) : jsx(LocalLink, { link: link });
7908
+ if (simple) {
7909
+ return (jsx(Link, { href: link, target: "_blank", rel: "noreferrer", style: style, children: title ?? link }));
7910
+ }
7911
+ return link.startsWith("http")
7912
+ ? jsx(ExternalLink, { style: style, onClick: () => window.open(link) })
7913
+ : jsx(LocalLink, { style: style, link: link });
7907
7914
  });
7908
7915
 
7909
7916
  const MarkdownWrapper = styled.div `
@@ -8005,37 +8012,6 @@ const MarkdownWrapper = styled.div `
8005
8012
  display: none;
8006
8013
  }
8007
8014
  `;
8008
- styled(Flex) `
8009
- align-items: center;
8010
- gap: 1rem;
8011
- margin-top: 1rem;
8012
- `;
8013
- styled.span `
8014
- display: block;
8015
- font-size: 0.75rem;
8016
- line-height: 0.875rem;
8017
- opacity: 0.36;
8018
- margin: 0 0 0.5rem 0;
8019
- `;
8020
- styled.div `
8021
- width: 1.25rem;
8022
- height: 1.25rem;
8023
- cursor: pointer;
8024
- transition: opacity 0.2s;
8025
-
8026
- &:hover {
8027
- opacity: 0.7;
8028
- }
8029
-
8030
- img, svg {
8031
- width: 100%;
8032
- height: 100%;
8033
- display: block;
8034
- }
8035
- `;
8036
- const ExpandButton = styled(IconButton) `
8037
- margin-bottom: 1rem;
8038
- `;
8039
8015
 
8040
8016
  const ElementMarkdown = memo(({ elementConfig, type }) => {
8041
8017
  const { attributes } = useWidgetContext(type);
@@ -8059,14 +8035,14 @@ const ElementMarkdown = memo(({ elementConfig, type }) => {
8059
8035
  if (!shouldShowExpand) {
8060
8036
  return (jsx(MarkdownWrapper, { children: jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString }) }));
8061
8037
  }
8062
- // Truncated content for collapsed state
8063
- const truncatedContent = markdownString.substring(0, expandLength);
8064
8038
  // Collapsed state
8065
8039
  if (!expanded) {
8066
- return (jsxs(MarkdownWrapper, { children: [jsx(ExpandButton, { primary: true, icon: jsx(Expander, { isSelected: false }), onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) }), jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: truncatedContent })] }));
8040
+ // Truncated content for collapsed state
8041
+ const truncatedContent = markdownString.substring(0, expandLength);
8042
+ return (jsxs(MarkdownWrapper, { children: [jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: truncatedContent }), jsx(LegendToggler, { onClick: () => setExpanded(true), children: t("more", { ns: "dashboard", defaultValue: "Подробнее" }) })] }));
8067
8043
  }
8068
8044
  // Expanded state
8069
- return (jsxs(MarkdownWrapper, { children: [jsx(ExpandButton, { primary: true, icon: jsx(Expander, { isSelected: true }), onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) }), jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString })] }));
8045
+ return (jsxs(MarkdownWrapper, { children: [jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: markdownString }), jsx(LegendToggler, { toggled: true, onClick: () => setExpanded(false), children: t("hide", { ns: "dashboard", defaultValue: "Свернуть" }) })] }));
8070
8046
  });
8071
8047
 
8072
8048
  const SmallPreviewContainer = styled.div `