@atlaskit/smart-card 18.0.1 → 18.0.4

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/CardWithUrl/component.js +12 -6
  4. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +17 -36
  5. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -80
  6. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +12 -27
  7. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/utils.js +103 -0
  8. package/dist/cjs/view/HoverCard/index.js +36 -7
  9. package/dist/cjs/view/HoverCard/styled.js +2 -4
  10. package/dist/es2019/version.json +1 -1
  11. package/dist/es2019/view/CardWithUrl/component.js +11 -6
  12. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +14 -29
  13. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -60
  14. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +11 -23
  15. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/utils.js +69 -0
  16. package/dist/es2019/view/HoverCard/index.js +30 -9
  17. package/dist/es2019/view/HoverCard/styled.js +2 -4
  18. package/dist/esm/version.json +1 -1
  19. package/dist/esm/view/CardWithUrl/component.js +11 -6
  20. package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +15 -31
  21. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -65
  22. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +11 -25
  23. package/dist/esm/view/FlexibleCard/components/blocks/title-block/utils.js +74 -0
  24. package/dist/esm/view/HoverCard/index.js +36 -9
  25. package/dist/esm/view/HoverCard/styled.js +2 -3
  26. package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
  27. package/dist/types/view/Card/index.d.ts +1 -1
  28. package/dist/types/view/FlexibleCard/components/blocks/title-block/utils.d.ts +11 -0
  29. package/dist/types/view/HoverCard/styled.d.ts +1 -2
  30. package/package.json +1 -1
@@ -1,67 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
- import React, { useState } from 'react';
5
- import { css, jsx } from '@emotion/core';
6
- import { LinkIcon, Title } from '../../../elements';
7
- import Block from '../../block';
8
- import ElementGroup from '../../element-group';
9
- import { SmartLinkAlignment, SmartLinkDirection, SmartLinkWidth } from '../../../../../../constants';
10
- import { renderElementItems } from '../../utils';
11
- import ActionGroup from '../../action-group';
12
- const actionOnHoverOnlyStyle = css`
13
- .action-group-more-button {
14
- visibility: hidden;
15
- }
4
+ import React from 'react';
5
+ import { jsx } from '@emotion/core';
6
+ import { BaseTitleBlockComponent } from '../utils';
16
7
 
17
- &:hover {
18
- .action-group-more-button {
19
- visibility: visible;
20
- }
21
- }
22
- `;
23
-
24
- const TitleBlockResolvedView = ({
25
- maxLines,
26
- metadata = [],
27
- position,
28
- subtitle = [],
29
- actions = [],
30
- testId,
31
- theme,
32
- onClick,
33
- text,
34
- showActionOnHover,
35
- ...blockProps
36
- }) => {
37
- const [actionDropdownOpen, setActionDropdownOpen] = useState(false);
38
- const metadataElements = renderElementItems(metadata);
39
- const subtitleElements = renderElementItems(subtitle);
40
- const overrideText = !!text ? {
41
- text
42
- } : {};
43
- const extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
44
- return jsx(Block, _extends({}, blockProps, {
45
- testId: `${testId}-resolved-view`,
46
- extraCss: extraCss
47
- }), jsx(LinkIcon, {
48
- position: position
49
- }), jsx(ElementGroup, {
50
- direction: SmartLinkDirection.Vertical,
51
- width: SmartLinkWidth.Flexible
52
- }, jsx(Title, _extends({
53
- maxLines: maxLines,
54
- theme: theme,
55
- onClick: onClick
56
- }, overrideText)), subtitleElements && jsx(ElementGroup, {
57
- direction: SmartLinkDirection.Horizontal
58
- }, subtitleElements)), metadataElements && jsx(ElementGroup, {
59
- direction: SmartLinkDirection.Horizontal,
60
- align: SmartLinkAlignment.Right
61
- }, metadataElements), actions.length > 0 && jsx(ActionGroup, {
62
- items: actions,
63
- visibleButtonsNum: showActionOnHover ? 1 : 2,
64
- onDropdownOpenChange: isOpen => setActionDropdownOpen(isOpen)
8
+ const TitleBlockResolvedView = props => {
9
+ return jsx(BaseTitleBlockComponent, _extends({}, props, {
10
+ blockTestIdPostfix: "resolved-view"
65
11
  }));
66
12
  };
67
13
 
@@ -4,9 +4,8 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import React from 'react';
5
5
  import { jsx } from '@emotion/core';
6
6
  import Spinner from '@atlaskit/spinner';
7
- import { Title } from '../../../elements';
8
- import Block from '../../block';
9
7
  import { SmartLinkSize } from '../../../../../../constants';
8
+ import { BaseTitleBlockComponent } from '../utils';
10
9
 
11
10
  const getSpinnerSize = size => {
12
11
  // Spinner sizes should be equivalent or smaller than Icon size
@@ -27,30 +26,19 @@ const getSpinnerSize = size => {
27
26
  }
28
27
  };
29
28
 
30
- const TitleBlockResolvingView = ({
31
- maxLines,
32
- retry,
33
- position,
34
- testId,
35
- theme,
36
- text,
37
- ...blockProps
38
- }) => {
29
+ const TitleBlockResolvingView = props => {
39
30
  const {
40
- size = SmartLinkSize.Medium
41
- } = blockProps;
42
- const overrideText = !!text ? {
43
- text
44
- } : {};
45
- return jsx(Block, _extends({}, blockProps, {
46
- testId: `${testId}-resolving-view`
47
- }), jsx(Spinner, {
31
+ size = SmartLinkSize.Medium,
32
+ testId
33
+ } = props;
34
+ const spinnerIcon = jsx(Spinner, {
48
35
  size: getSpinnerSize(size),
49
36
  testId: `${testId}-resolving-spinner`
50
- }), jsx(Title, _extends({}, overrideText, {
51
- maxLines: maxLines,
52
- theme: theme
53
- })));
37
+ });
38
+ return jsx(BaseTitleBlockComponent, _extends({}, props, {
39
+ blockIcon: spinnerIcon,
40
+ blockTestIdPostfix: "resolving-view"
41
+ }));
54
42
  };
55
43
 
56
44
  export default TitleBlockResolvingView;
@@ -0,0 +1,69 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /** @jsx jsx */
4
+ import React, { useState } from 'react';
5
+ import { jsx } from '@emotion/core';
6
+ import { css } from '@emotion/core';
7
+ import Block from '../block';
8
+ import { LinkIcon, Title } from '../../elements';
9
+ import ActionGroup from '../action-group';
10
+ import { SmartLinkAlignment, SmartLinkWidth, SmartLinkDirection } from '../../../../../constants';
11
+ import ElementGroup from '../element-group';
12
+ import { renderElementItems } from '../utils';
13
+ export const actionOnHoverOnlyStyle = css`
14
+ .action-group-more-button {
15
+ visibility: hidden;
16
+ }
17
+
18
+ &:hover {
19
+ .action-group-more-button {
20
+ visibility: visible;
21
+ }
22
+ }
23
+ `;
24
+ export const BaseTitleBlockComponent = ({
25
+ children,
26
+ blockTestIdPostfix,
27
+ blockIcon,
28
+ testId,
29
+ showActionOnHover,
30
+ position,
31
+ actions = [],
32
+ text,
33
+ maxLines,
34
+ theme,
35
+ onClick,
36
+ metadata = [],
37
+ subtitle = [],
38
+ ...blockProps
39
+ }) => {
40
+ const [actionDropdownOpen, setActionDropdownOpen] = useState(false);
41
+ const extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
42
+ const overrideText = !!text ? {
43
+ text
44
+ } : {};
45
+ const metadataElements = renderElementItems(metadata);
46
+ const subtitleElements = renderElementItems(subtitle);
47
+ return jsx(Block, _extends({}, blockProps, {
48
+ testId: `${testId}-${blockTestIdPostfix}`,
49
+ extraCss: extraCss
50
+ }), blockIcon || jsx(LinkIcon, {
51
+ position: position
52
+ }), jsx(ElementGroup, {
53
+ direction: SmartLinkDirection.Vertical,
54
+ width: SmartLinkWidth.Flexible
55
+ }, jsx(Title, _extends({
56
+ maxLines: maxLines,
57
+ theme: theme,
58
+ onClick: onClick
59
+ }, overrideText)), subtitleElements && jsx(ElementGroup, {
60
+ direction: SmartLinkDirection.Horizontal
61
+ }, subtitleElements)), metadataElements && jsx(ElementGroup, {
62
+ direction: SmartLinkDirection.Horizontal,
63
+ align: SmartLinkAlignment.Right
64
+ }, metadataElements), children, actions.length > 0 && jsx(ActionGroup, {
65
+ items: actions,
66
+ visibleButtonsNum: showActionOnHover ? 1 : 2,
67
+ onDropdownOpenChange: isOpen => setActionDropdownOpen(isOpen)
68
+ }));
69
+ };
@@ -1,9 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useCallback, useRef } from 'react';
2
+
3
+ /** @jsx jsx */
4
+ import { jsx } from '@emotion/core';
5
+ import React, { useCallback, useRef, useMemo } from 'react';
3
6
  import { TitleBlock, SnippetBlock, FooterBlock } from '../FlexibleCard/components/blocks';
4
7
  import { Card } from '../Card';
5
8
  import Popup from '@atlaskit/popup';
6
- import { SmartLinkSize } from '../../constants';
9
+ import { SmartLinkSize, ActionName } from '../../constants';
10
+ import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
11
+ import { HoverCardContainer } from './styled';
7
12
  export const HoverCard = ({
8
13
  children,
9
14
  url
@@ -29,28 +34,44 @@ export const HoverCard = ({
29
34
  fadeInTimeoutId.current = setTimeout(() => {
30
35
  setIsOpen(true);
31
36
  }, delay);
32
- }, [delay]);
37
+ }, [delay]); //TODO: EDM-2905: Add analytics events
38
+
39
+ const analyticsHandler = useCallback(() => {}, []);
40
+ const linkActions = useSmartLinkActions({
41
+ url,
42
+ appearance: 'block',
43
+ analyticsHandler
44
+ });
45
+ const actions = useMemo(() => linkActions.map(action => ({
46
+ content: action.text,
47
+ name: ActionName.CustomAction,
48
+ onClick: () => action.invoke(),
49
+ testId: action.id
50
+ })), [linkActions]);
33
51
 
34
- const cardComponent = () => /*#__PURE__*/React.createElement("span", {
52
+ const cardComponent = () => jsx("div", {
35
53
  onMouseEnter: initShowCard,
36
- onMouseLeave: initHideCard
37
- }, /*#__PURE__*/React.createElement(Card, {
54
+ onMouseLeave: initHideCard,
55
+ css: HoverCardContainer
56
+ }, jsx(Card, {
38
57
  appearance: "block",
39
58
  url: url,
40
59
  ui: {
41
60
  hideElevation: true,
42
61
  size: SmartLinkSize.Large
43
62
  }
44
- }, /*#__PURE__*/React.createElement(TitleBlock, null), /*#__PURE__*/React.createElement(SnippetBlock, null), /*#__PURE__*/React.createElement(FooterBlock, null)));
63
+ }, jsx(TitleBlock, null), jsx(SnippetBlock, null), jsx(FooterBlock, {
64
+ actions: actions
65
+ })));
45
66
 
46
67
  const onClose = useCallback(() => setIsOpen(false), []);
47
- return /*#__PURE__*/React.createElement(Popup, {
68
+ return jsx(Popup, {
48
69
  testId: "hover-card",
49
70
  isOpen: isOpen,
50
71
  onClose: onClose,
51
72
  placement: "bottom",
52
73
  content: cardComponent,
53
- trigger: triggerProps => /*#__PURE__*/React.createElement("span", _extends({}, triggerProps, {
74
+ trigger: triggerProps => jsx("span", _extends({}, triggerProps, {
54
75
  onMouseEnter: initShowCard,
55
76
  onMouseLeave: initHideCard
56
77
  }), children)
@@ -1,9 +1,7 @@
1
- import styled from '@emotion/styled';
2
- import { TooltipPrimitive } from '@atlaskit/tooltip';
3
- export const HoverCardContainer = styled(TooltipPrimitive)`
1
+ import { css } from '@emotion/core';
2
+ export const HoverCardContainer = css`
4
3
  background: none;
5
4
  border-width: 0;
6
- box-sizing: content-box; /* do not set this to border-box or it will break the overflow handling */
7
5
  max-width: 500px;
8
6
  padding: 0;
9
7
  `;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.1",
3
+ "version": "18.0.4",
4
4
  "sideEffects": false
5
5
  }
@@ -8,6 +8,7 @@ import { InlineCard } from '../InlineCard';
8
8
  import { EmbedCard } from '../EmbedCard';
9
9
  import { isFlexibleUiCard } from '../../utils/flexible';
10
10
  import FlexibleCard from '../FlexibleCard';
11
+ import { APIError } from '../..';
11
12
  export function CardWithUrlContent(_ref) {
12
13
  var id = _ref.id,
13
14
  url = _ref.url,
@@ -82,15 +83,14 @@ export function CardWithUrlContent(_ref) {
82
83
  if (isFinalState(state.status)) {
83
84
  analytics.ui.renderSuccessEvent(appearance, id, definitionId, extensionKey);
84
85
  }
85
- }, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]); // We have to keep this last to prevent hook order from being violated
86
-
87
- if (error) {
88
- throw error;
89
- }
86
+ }, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]);
90
87
 
91
88
  if (isFlexibleUi) {
89
+ var cardState = (error === null || error === void 0 ? void 0 : error.constructor) === APIError ? {
90
+ status: 'errored'
91
+ } : state;
92
92
  return /*#__PURE__*/React.createElement(FlexibleCard, {
93
- cardState: state,
93
+ cardState: cardState,
94
94
  onAuthorize: services.length && handleAuthorize || undefined,
95
95
  onClick: handleClickWrapper,
96
96
  renderers: renderers,
@@ -98,6 +98,11 @@ export function CardWithUrlContent(_ref) {
98
98
  url: url,
99
99
  testId: testId
100
100
  }, children);
101
+ } // We have to keep this last to prevent hook order from being violated
102
+
103
+
104
+ if (error) {
105
+ throw error;
101
106
  }
102
107
 
103
108
  switch (appearance) {
@@ -1,7 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
- var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
5
3
 
6
4
  var _templateObject, _templateObject2;
7
5
 
@@ -9,12 +7,11 @@ var _templateObject, _templateObject2;
9
7
  import React from 'react';
10
8
  import { FormattedMessage } from 'react-intl-next';
11
9
  import { css, jsx } from '@emotion/core';
12
- import { LinkIcon, Title } from '../../../elements';
13
- import Block from '../../block';
14
10
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize } from '../../../../../../constants';
15
11
  import { getLinkLineHeight, getLinkSizeStyles, getTruncateStyles } from '../../../utils';
16
12
  import ElementGroup from '../../element-group';
17
13
  import { tokens } from '../../../../../../utils/token';
14
+ import { BaseTitleBlockComponent } from '../utils';
18
15
  var actionStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n :hover {\n color: ", ";\n text-decoration: underline;\n }\n"])), tokens.errorMessageHover);
19
16
 
20
17
  var getMessageStyles = function getMessageStyles(size, hasAction) {
@@ -22,42 +19,29 @@ var getMessageStyles = function getMessageStyles(size, hasAction) {
22
19
  return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex: 1 1 auto;\n justify-content: flex-end;\n ", "\n ", "\n ", "\n color: ", ";\n "])), hasAction ? actionStyles : '', sizeStyles, getTruncateStyles(1, getLinkLineHeight(size)), tokens.errorMessage);
23
20
  };
24
21
 
25
- var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
26
- var maxLines = _ref.maxLines,
27
- retry = _ref.retry,
28
- position = _ref.position,
29
- testId = _ref.testId,
30
- theme = _ref.theme,
31
- text = _ref.text,
32
- blockProps = _objectWithoutProperties(_ref, _excluded);
22
+ var TitleBlockErroredView = function TitleBlockErroredView(props) {
23
+ var _props$size = props.size,
24
+ size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
25
+ retry = props.retry,
26
+ testId = props.testId;
33
27
 
34
- var _ref2 = retry || {},
35
- descriptor = _ref2.descriptor,
36
- onClick = _ref2.onClick,
37
- values = _ref2.values;
28
+ var _ref = retry || {},
29
+ retryDescriptor = _ref.descriptor,
30
+ onClick = _ref.onClick,
31
+ retryValues = _ref.values;
38
32
 
39
- var _blockProps$size = blockProps.size,
40
- size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
41
33
  var hasAction = onClick !== undefined;
42
- var overrideText = !!text ? {
43
- text: text
44
- } : {};
45
- return jsx(Block, _extends({}, blockProps, {
46
- testId: "".concat(testId, "-errored-view")
47
- }), jsx(LinkIcon, {
48
- position: position
49
- }), jsx(Title, _extends({}, overrideText, {
50
- maxLines: maxLines,
51
- theme: theme
52
- })), descriptor && jsx(ElementGroup, {
34
+ return jsx(BaseTitleBlockComponent, _extends({}, props, {
35
+ blockTestIdPostfix: "errored-view"
36
+ }), retryDescriptor && jsx(ElementGroup, {
53
37
  direction: SmartLinkDirection.Horizontal,
54
38
  align: SmartLinkAlignment.Right
55
39
  }, jsx("span", {
56
40
  css: getMessageStyles(size, hasAction),
57
41
  onClick: onClick,
58
42
  "data-testid": "".concat(testId, "-errored-view-message")
59
- }, jsx(FormattedMessage, _extends({}, descriptor, {
60
- values: values
43
+ }, jsx(FormattedMessage, _extends({}, retryDescriptor, {
44
+ values: retryValues
61
45
  })))));
62
46
  };
63
47
 
@@ -1,72 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
- var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "onClick", "text", "showActionOnHover"];
6
-
7
- var _templateObject;
8
2
 
9
3
  /** @jsx jsx */
10
- import React, { useState } from 'react';
11
- import { css, jsx } from '@emotion/core';
12
- import { LinkIcon, Title } from '../../../elements';
13
- import Block from '../../block';
14
- import ElementGroup from '../../element-group';
15
- import { SmartLinkAlignment, SmartLinkDirection, SmartLinkWidth } from '../../../../../../constants';
16
- import { renderElementItems } from '../../utils';
17
- import ActionGroup from '../../action-group';
18
- var actionOnHoverOnlyStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .action-group-more-button {\n visibility: hidden;\n }\n\n &:hover {\n .action-group-more-button {\n visibility: visible;\n }\n }\n"])));
19
-
20
- var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
21
- var maxLines = _ref.maxLines,
22
- _ref$metadata = _ref.metadata,
23
- metadata = _ref$metadata === void 0 ? [] : _ref$metadata,
24
- position = _ref.position,
25
- _ref$subtitle = _ref.subtitle,
26
- subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
27
- _ref$actions = _ref.actions,
28
- actions = _ref$actions === void 0 ? [] : _ref$actions,
29
- testId = _ref.testId,
30
- theme = _ref.theme,
31
- onClick = _ref.onClick,
32
- text = _ref.text,
33
- showActionOnHover = _ref.showActionOnHover,
34
- blockProps = _objectWithoutProperties(_ref, _excluded);
35
-
36
- var _useState = useState(false),
37
- _useState2 = _slicedToArray(_useState, 2),
38
- actionDropdownOpen = _useState2[0],
39
- setActionDropdownOpen = _useState2[1];
4
+ import React from 'react';
5
+ import { jsx } from '@emotion/core';
6
+ import { BaseTitleBlockComponent } from '../utils';
40
7
 
41
- var metadataElements = renderElementItems(metadata);
42
- var subtitleElements = renderElementItems(subtitle);
43
- var overrideText = !!text ? {
44
- text: text
45
- } : {};
46
- var extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
47
- return jsx(Block, _extends({}, blockProps, {
48
- testId: "".concat(testId, "-resolved-view"),
49
- extraCss: extraCss
50
- }), jsx(LinkIcon, {
51
- position: position
52
- }), jsx(ElementGroup, {
53
- direction: SmartLinkDirection.Vertical,
54
- width: SmartLinkWidth.Flexible
55
- }, jsx(Title, _extends({
56
- maxLines: maxLines,
57
- theme: theme,
58
- onClick: onClick
59
- }, overrideText)), subtitleElements && jsx(ElementGroup, {
60
- direction: SmartLinkDirection.Horizontal
61
- }, subtitleElements)), metadataElements && jsx(ElementGroup, {
62
- direction: SmartLinkDirection.Horizontal,
63
- align: SmartLinkAlignment.Right
64
- }, metadataElements), actions.length > 0 && jsx(ActionGroup, {
65
- items: actions,
66
- visibleButtonsNum: showActionOnHover ? 1 : 2,
67
- onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
68
- return setActionDropdownOpen(isOpen);
69
- }
8
+ var TitleBlockResolvedView = function TitleBlockResolvedView(props) {
9
+ return jsx(BaseTitleBlockComponent, _extends({}, props, {
10
+ blockTestIdPostfix: "resolved-view"
70
11
  }));
71
12
  };
72
13
 
@@ -1,14 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
4
2
 
5
3
  /** @jsx jsx */
6
4
  import React from 'react';
7
5
  import { jsx } from '@emotion/core';
8
6
  import Spinner from '@atlaskit/spinner';
9
- import { Title } from '../../../elements';
10
- import Block from '../../block';
11
7
  import { SmartLinkSize } from '../../../../../../constants';
8
+ import { BaseTitleBlockComponent } from '../utils';
12
9
 
13
10
  var getSpinnerSize = function getSpinnerSize(size) {
14
11
  // Spinner sizes should be equivalent or smaller than Icon size
@@ -29,29 +26,18 @@ var getSpinnerSize = function getSpinnerSize(size) {
29
26
  }
30
27
  };
31
28
 
32
- var TitleBlockResolvingView = function TitleBlockResolvingView(_ref) {
33
- var maxLines = _ref.maxLines,
34
- retry = _ref.retry,
35
- position = _ref.position,
36
- testId = _ref.testId,
37
- theme = _ref.theme,
38
- text = _ref.text,
39
- blockProps = _objectWithoutProperties(_ref, _excluded);
40
-
41
- var _blockProps$size = blockProps.size,
42
- size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
43
- var overrideText = !!text ? {
44
- text: text
45
- } : {};
46
- return jsx(Block, _extends({}, blockProps, {
47
- testId: "".concat(testId, "-resolving-view")
48
- }), jsx(Spinner, {
29
+ var TitleBlockResolvingView = function TitleBlockResolvingView(props) {
30
+ var _props$size = props.size,
31
+ size = _props$size === void 0 ? SmartLinkSize.Medium : _props$size,
32
+ testId = props.testId;
33
+ var spinnerIcon = jsx(Spinner, {
49
34
  size: getSpinnerSize(size),
50
35
  testId: "".concat(testId, "-resolving-spinner")
51
- }), jsx(Title, _extends({}, overrideText, {
52
- maxLines: maxLines,
53
- theme: theme
54
- })));
36
+ });
37
+ return jsx(BaseTitleBlockComponent, _extends({}, props, {
38
+ blockIcon: spinnerIcon,
39
+ blockTestIdPostfix: "resolving-view"
40
+ }));
55
41
  };
56
42
 
57
43
  export default TitleBlockResolvingView;
@@ -0,0 +1,74 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
+ var _excluded = ["children", "blockTestIdPostfix", "blockIcon", "testId", "showActionOnHover", "position", "actions", "text", "maxLines", "theme", "onClick", "metadata", "subtitle"];
6
+
7
+ var _templateObject;
8
+
9
+ /** @jsx jsx */
10
+ import React, { useState } from 'react';
11
+ import { jsx } from '@emotion/core';
12
+ import { css } from '@emotion/core';
13
+ import Block from '../block';
14
+ import { LinkIcon, Title } from '../../elements';
15
+ import ActionGroup from '../action-group';
16
+ import { SmartLinkAlignment, SmartLinkWidth, SmartLinkDirection } from '../../../../../constants';
17
+ import ElementGroup from '../element-group';
18
+ import { renderElementItems } from '../utils';
19
+ export var actionOnHoverOnlyStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .action-group-more-button {\n visibility: hidden;\n }\n\n &:hover {\n .action-group-more-button {\n visibility: visible;\n }\n }\n"])));
20
+ export var BaseTitleBlockComponent = function BaseTitleBlockComponent(_ref) {
21
+ var children = _ref.children,
22
+ blockTestIdPostfix = _ref.blockTestIdPostfix,
23
+ blockIcon = _ref.blockIcon,
24
+ testId = _ref.testId,
25
+ showActionOnHover = _ref.showActionOnHover,
26
+ position = _ref.position,
27
+ _ref$actions = _ref.actions,
28
+ actions = _ref$actions === void 0 ? [] : _ref$actions,
29
+ text = _ref.text,
30
+ maxLines = _ref.maxLines,
31
+ theme = _ref.theme,
32
+ onClick = _ref.onClick,
33
+ _ref$metadata = _ref.metadata,
34
+ metadata = _ref$metadata === void 0 ? [] : _ref$metadata,
35
+ _ref$subtitle = _ref.subtitle,
36
+ subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
37
+ blockProps = _objectWithoutProperties(_ref, _excluded);
38
+
39
+ var _useState = useState(false),
40
+ _useState2 = _slicedToArray(_useState, 2),
41
+ actionDropdownOpen = _useState2[0],
42
+ setActionDropdownOpen = _useState2[1];
43
+
44
+ var extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
45
+ var overrideText = !!text ? {
46
+ text: text
47
+ } : {};
48
+ var metadataElements = renderElementItems(metadata);
49
+ var subtitleElements = renderElementItems(subtitle);
50
+ return jsx(Block, _extends({}, blockProps, {
51
+ testId: "".concat(testId, "-").concat(blockTestIdPostfix),
52
+ extraCss: extraCss
53
+ }), blockIcon || jsx(LinkIcon, {
54
+ position: position
55
+ }), jsx(ElementGroup, {
56
+ direction: SmartLinkDirection.Vertical,
57
+ width: SmartLinkWidth.Flexible
58
+ }, jsx(Title, _extends({
59
+ maxLines: maxLines,
60
+ theme: theme,
61
+ onClick: onClick
62
+ }, overrideText)), subtitleElements && jsx(ElementGroup, {
63
+ direction: SmartLinkDirection.Horizontal
64
+ }, subtitleElements)), metadataElements && jsx(ElementGroup, {
65
+ direction: SmartLinkDirection.Horizontal,
66
+ align: SmartLinkAlignment.Right
67
+ }, metadataElements), children, actions.length > 0 && jsx(ActionGroup, {
68
+ items: actions,
69
+ visibleButtonsNum: showActionOnHover ? 1 : 2,
70
+ onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
71
+ return setActionDropdownOpen(isOpen);
72
+ }
73
+ }));
74
+ };