@atlaskit/smart-card 18.0.3 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 18.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`dd4ae8205d1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dd4ae8205d1) - Add actions for non-resolved view of flexible ui
8
+
3
9
  ## 18.0.3
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.3",
3
+ "version": "18.0.4",
4
4
  "sideEffects": false
5
5
  }
@@ -9,8 +9,6 @@ exports.default = void 0;
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
12
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
13
 
16
14
  var _react = _interopRequireDefault(require("react"));
@@ -19,10 +17,6 @@ var _reactIntlNext = require("react-intl-next");
19
17
 
20
18
  var _core = require("@emotion/core");
21
19
 
22
- var _elements = require("../../../elements");
23
-
24
- var _block = _interopRequireDefault(require("../../block"));
25
-
26
20
  var _constants = require("../../../../../../constants");
27
21
 
28
22
  var _utils = require("../../../utils");
@@ -31,7 +25,7 @@ var _elementGroup = _interopRequireDefault(require("../../element-group"));
31
25
 
32
26
  var _token = require("../../../../../../utils/token");
33
27
 
34
- var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
28
+ var _utils2 = require("../utils");
35
29
 
36
30
  var _templateObject, _templateObject2;
37
31
 
@@ -42,42 +36,29 @@ var getMessageStyles = function getMessageStyles(size, hasAction) {
42
36
  return (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n flex: 1 1 auto;\n justify-content: flex-end;\n ", "\n ", "\n ", "\n color: ", ";\n "])), hasAction ? actionStyles : '', sizeStyles, (0, _utils.getTruncateStyles)(1, (0, _utils.getLinkLineHeight)(size)), _token.tokens.errorMessage);
43
37
  };
44
38
 
45
- var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
46
- var maxLines = _ref.maxLines,
47
- retry = _ref.retry,
48
- position = _ref.position,
49
- testId = _ref.testId,
50
- theme = _ref.theme,
51
- text = _ref.text,
52
- blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
53
-
54
- var _ref2 = retry || {},
55
- descriptor = _ref2.descriptor,
56
- onClick = _ref2.onClick,
57
- values = _ref2.values;
58
-
59
- var _blockProps$size = blockProps.size,
60
- size = _blockProps$size === void 0 ? _constants.SmartLinkSize.Medium : _blockProps$size;
39
+ var TitleBlockErroredView = function TitleBlockErroredView(props) {
40
+ var _props$size = props.size,
41
+ size = _props$size === void 0 ? _constants.SmartLinkSize.Medium : _props$size,
42
+ retry = props.retry,
43
+ testId = props.testId;
44
+
45
+ var _ref = retry || {},
46
+ retryDescriptor = _ref.descriptor,
47
+ onClick = _ref.onClick,
48
+ retryValues = _ref.values;
49
+
61
50
  var hasAction = onClick !== undefined;
62
- var overrideText = !!text ? {
63
- text: text
64
- } : {};
65
- return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
66
- testId: "".concat(testId, "-errored-view")
67
- }), (0, _core.jsx)(_elements.LinkIcon, {
68
- position: position
69
- }), (0, _core.jsx)(_elements.Title, (0, _extends2.default)({}, overrideText, {
70
- maxLines: maxLines,
71
- theme: theme
72
- })), descriptor && (0, _core.jsx)(_elementGroup.default, {
51
+ return (0, _core.jsx)(_utils2.BaseTitleBlockComponent, (0, _extends2.default)({}, props, {
52
+ blockTestIdPostfix: "errored-view"
53
+ }), retryDescriptor && (0, _core.jsx)(_elementGroup.default, {
73
54
  direction: _constants.SmartLinkDirection.Horizontal,
74
55
  align: _constants.SmartLinkAlignment.Right
75
56
  }, (0, _core.jsx)("span", {
76
57
  css: getMessageStyles(size, hasAction),
77
58
  onClick: onClick,
78
59
  "data-testid": "".concat(testId, "-errored-view-message")
79
- }, (0, _core.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, descriptor, {
80
- values: values
60
+ }, (0, _core.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, retryDescriptor, {
61
+ values: retryValues
81
62
  })))));
82
63
  };
83
64
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
@@ -11,88 +9,16 @@ exports.default = void 0;
11
9
 
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
11
 
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
-
18
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
19
-
20
- var _react = _interopRequireWildcard(require("react"));
12
+ var _react = _interopRequireDefault(require("react"));
21
13
 
22
14
  var _core = require("@emotion/core");
23
15
 
24
- var _elements = require("../../../elements");
25
-
26
- var _block = _interopRequireDefault(require("../../block"));
27
-
28
- var _elementGroup = _interopRequireDefault(require("../../element-group"));
29
-
30
- var _constants = require("../../../../../../constants");
31
-
32
- var _utils = require("../../utils");
33
-
34
- var _actionGroup = _interopRequireDefault(require("../../action-group"));
35
-
36
- var _excluded = ["maxLines", "metadata", "position", "subtitle", "actions", "testId", "theme", "onClick", "text", "showActionOnHover"];
37
-
38
- var _templateObject;
39
-
40
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
-
42
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
-
44
- var actionOnHoverOnlyStyle = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .action-group-more-button {\n visibility: hidden;\n }\n\n &:hover {\n .action-group-more-button {\n visibility: visible;\n }\n }\n"])));
45
-
46
- var TitleBlockResolvedView = function TitleBlockResolvedView(_ref) {
47
- var maxLines = _ref.maxLines,
48
- _ref$metadata = _ref.metadata,
49
- metadata = _ref$metadata === void 0 ? [] : _ref$metadata,
50
- position = _ref.position,
51
- _ref$subtitle = _ref.subtitle,
52
- subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
53
- _ref$actions = _ref.actions,
54
- actions = _ref$actions === void 0 ? [] : _ref$actions,
55
- testId = _ref.testId,
56
- theme = _ref.theme,
57
- onClick = _ref.onClick,
58
- text = _ref.text,
59
- showActionOnHover = _ref.showActionOnHover,
60
- blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
61
-
62
- var _useState = (0, _react.useState)(false),
63
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
64
- actionDropdownOpen = _useState2[0],
65
- setActionDropdownOpen = _useState2[1];
16
+ var _utils = require("../utils");
66
17
 
67
- var metadataElements = (0, _utils.renderElementItems)(metadata);
68
- var subtitleElements = (0, _utils.renderElementItems)(subtitle);
69
- var overrideText = !!text ? {
70
- text: text
71
- } : {};
72
- var extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
73
- return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
74
- testId: "".concat(testId, "-resolved-view"),
75
- extraCss: extraCss
76
- }), (0, _core.jsx)(_elements.LinkIcon, {
77
- position: position
78
- }), (0, _core.jsx)(_elementGroup.default, {
79
- direction: _constants.SmartLinkDirection.Vertical,
80
- width: _constants.SmartLinkWidth.Flexible
81
- }, (0, _core.jsx)(_elements.Title, (0, _extends2.default)({
82
- maxLines: maxLines,
83
- theme: theme,
84
- onClick: onClick
85
- }, overrideText)), subtitleElements && (0, _core.jsx)(_elementGroup.default, {
86
- direction: _constants.SmartLinkDirection.Horizontal
87
- }, subtitleElements)), metadataElements && (0, _core.jsx)(_elementGroup.default, {
88
- direction: _constants.SmartLinkDirection.Horizontal,
89
- align: _constants.SmartLinkAlignment.Right
90
- }, metadataElements), actions.length > 0 && (0, _core.jsx)(_actionGroup.default, {
91
- items: actions,
92
- visibleButtonsNum: showActionOnHover ? 1 : 2,
93
- onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
94
- return setActionDropdownOpen(isOpen);
95
- }
18
+ /** @jsx jsx */
19
+ var TitleBlockResolvedView = function TitleBlockResolvedView(props) {
20
+ return (0, _core.jsx)(_utils.BaseTitleBlockComponent, (0, _extends2.default)({}, props, {
21
+ blockTestIdPostfix: "resolved-view"
96
22
  }));
97
23
  };
98
24
 
@@ -9,22 +9,17 @@ exports.default = void 0;
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
12
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
12
  var _react = _interopRequireDefault(require("react"));
15
13
 
16
14
  var _core = require("@emotion/core");
17
15
 
18
16
  var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
19
17
 
20
- var _elements = require("../../../elements");
21
-
22
- var _block = _interopRequireDefault(require("../../block"));
23
-
24
18
  var _constants = require("../../../../../../constants");
25
19
 
26
- var _excluded = ["maxLines", "retry", "position", "testId", "theme", "text"];
20
+ var _utils = require("../utils");
27
21
 
22
+ /** @jsx jsx */
28
23
  var getSpinnerSize = function getSpinnerSize(size) {
29
24
  // Spinner sizes should be equivalent or smaller than Icon size
30
25
  // to avoid the jumping.
@@ -44,28 +39,18 @@ var getSpinnerSize = function getSpinnerSize(size) {
44
39
  }
45
40
  };
46
41
 
47
- var TitleBlockResolvingView = function TitleBlockResolvingView(_ref) {
48
- var maxLines = _ref.maxLines,
49
- retry = _ref.retry,
50
- position = _ref.position,
51
- testId = _ref.testId,
52
- theme = _ref.theme,
53
- text = _ref.text,
54
- blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
55
- var _blockProps$size = blockProps.size,
56
- size = _blockProps$size === void 0 ? _constants.SmartLinkSize.Medium : _blockProps$size;
57
- var overrideText = !!text ? {
58
- text: text
59
- } : {};
60
- return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
61
- testId: "".concat(testId, "-resolving-view")
62
- }), (0, _core.jsx)(_spinner.default, {
42
+ var TitleBlockResolvingView = function TitleBlockResolvingView(props) {
43
+ var _props$size = props.size,
44
+ size = _props$size === void 0 ? _constants.SmartLinkSize.Medium : _props$size,
45
+ testId = props.testId;
46
+ var spinnerIcon = (0, _core.jsx)(_spinner.default, {
63
47
  size: getSpinnerSize(size),
64
48
  testId: "".concat(testId, "-resolving-spinner")
65
- }), (0, _core.jsx)(_elements.Title, (0, _extends2.default)({}, overrideText, {
66
- maxLines: maxLines,
67
- theme: theme
68
- })));
49
+ });
50
+ return (0, _core.jsx)(_utils.BaseTitleBlockComponent, (0, _extends2.default)({}, props, {
51
+ blockIcon: spinnerIcon,
52
+ blockTestIdPostfix: "resolving-view"
53
+ }));
69
54
  };
70
55
 
71
56
  var _default = TitleBlockResolvingView;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.actionOnHoverOnlyStyle = exports.BaseTitleBlockComponent = void 0;
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
+
18
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
19
+
20
+ var _react = _interopRequireWildcard(require("react"));
21
+
22
+ var _core = require("@emotion/core");
23
+
24
+ var _block = _interopRequireDefault(require("../block"));
25
+
26
+ var _elements = require("../../elements");
27
+
28
+ var _actionGroup = _interopRequireDefault(require("../action-group"));
29
+
30
+ var _constants = require("../../../../../constants");
31
+
32
+ var _elementGroup = _interopRequireDefault(require("../element-group"));
33
+
34
+ var _utils = require("../utils");
35
+
36
+ var _excluded = ["children", "blockTestIdPostfix", "blockIcon", "testId", "showActionOnHover", "position", "actions", "text", "maxLines", "theme", "onClick", "metadata", "subtitle"];
37
+
38
+ var _templateObject;
39
+
40
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
+
42
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
+
44
+ var actionOnHoverOnlyStyle = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .action-group-more-button {\n visibility: hidden;\n }\n\n &:hover {\n .action-group-more-button {\n visibility: visible;\n }\n }\n"])));
45
+ exports.actionOnHoverOnlyStyle = actionOnHoverOnlyStyle;
46
+
47
+ var BaseTitleBlockComponent = function BaseTitleBlockComponent(_ref) {
48
+ var children = _ref.children,
49
+ blockTestIdPostfix = _ref.blockTestIdPostfix,
50
+ blockIcon = _ref.blockIcon,
51
+ testId = _ref.testId,
52
+ showActionOnHover = _ref.showActionOnHover,
53
+ position = _ref.position,
54
+ _ref$actions = _ref.actions,
55
+ actions = _ref$actions === void 0 ? [] : _ref$actions,
56
+ text = _ref.text,
57
+ maxLines = _ref.maxLines,
58
+ theme = _ref.theme,
59
+ onClick = _ref.onClick,
60
+ _ref$metadata = _ref.metadata,
61
+ metadata = _ref$metadata === void 0 ? [] : _ref$metadata,
62
+ _ref$subtitle = _ref.subtitle,
63
+ subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
64
+ blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
65
+
66
+ var _useState = (0, _react.useState)(false),
67
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
68
+ actionDropdownOpen = _useState2[0],
69
+ setActionDropdownOpen = _useState2[1];
70
+
71
+ var extraCss = showActionOnHover && !actionDropdownOpen ? actionOnHoverOnlyStyle : undefined;
72
+ var overrideText = !!text ? {
73
+ text: text
74
+ } : {};
75
+ var metadataElements = (0, _utils.renderElementItems)(metadata);
76
+ var subtitleElements = (0, _utils.renderElementItems)(subtitle);
77
+ return (0, _core.jsx)(_block.default, (0, _extends2.default)({}, blockProps, {
78
+ testId: "".concat(testId, "-").concat(blockTestIdPostfix),
79
+ extraCss: extraCss
80
+ }), blockIcon || (0, _core.jsx)(_elements.LinkIcon, {
81
+ position: position
82
+ }), (0, _core.jsx)(_elementGroup.default, {
83
+ direction: _constants.SmartLinkDirection.Vertical,
84
+ width: _constants.SmartLinkWidth.Flexible
85
+ }, (0, _core.jsx)(_elements.Title, (0, _extends2.default)({
86
+ maxLines: maxLines,
87
+ theme: theme,
88
+ onClick: onClick
89
+ }, overrideText)), subtitleElements && (0, _core.jsx)(_elementGroup.default, {
90
+ direction: _constants.SmartLinkDirection.Horizontal
91
+ }, subtitleElements)), metadataElements && (0, _core.jsx)(_elementGroup.default, {
92
+ direction: _constants.SmartLinkDirection.Horizontal,
93
+ align: _constants.SmartLinkAlignment.Right
94
+ }, metadataElements), children, actions.length > 0 && (0, _core.jsx)(_actionGroup.default, {
95
+ items: actions,
96
+ visibleButtonsNum: showActionOnHover ? 1 : 2,
97
+ onDropdownOpenChange: function onDropdownOpenChange(isOpen) {
98
+ return setActionDropdownOpen(isOpen);
99
+ }
100
+ }));
101
+ };
102
+
103
+ exports.BaseTitleBlockComponent = BaseTitleBlockComponent;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.3",
3
+ "version": "18.0.4",
4
4
  "sideEffects": false
5
5
  }
@@ -4,12 +4,11 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import React from 'react';
5
5
  import { FormattedMessage } from 'react-intl-next';
6
6
  import { css, jsx } from '@emotion/core';
7
- import { LinkIcon, Title } from '../../../elements';
8
- import Block from '../../block';
9
7
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize } from '../../../../../../constants';
10
8
  import { getLinkLineHeight, getLinkSizeStyles, getTruncateStyles } from '../../../utils';
11
9
  import ElementGroup from '../../element-group';
12
10
  import { tokens } from '../../../../../../utils/token';
11
+ import { BaseTitleBlockComponent } from '../utils';
13
12
  const actionStyles = css`
14
13
  cursor: pointer;
15
14
  :hover {
@@ -30,43 +29,29 @@ const getMessageStyles = (size, hasAction) => {
30
29
  `;
31
30
  };
32
31
 
33
- const TitleBlockErroredView = ({
34
- maxLines,
35
- retry,
36
- position,
37
- testId,
38
- theme,
39
- text,
40
- ...blockProps
41
- }) => {
32
+ const TitleBlockErroredView = props => {
42
33
  const {
43
- descriptor,
34
+ size = SmartLinkSize.Medium,
35
+ retry,
36
+ testId
37
+ } = props;
38
+ const {
39
+ descriptor: retryDescriptor,
44
40
  onClick,
45
- values
41
+ values: retryValues
46
42
  } = retry || {};
47
- const {
48
- size = SmartLinkSize.Medium
49
- } = blockProps;
50
43
  const hasAction = onClick !== undefined;
51
- const overrideText = !!text ? {
52
- text
53
- } : {};
54
- return jsx(Block, _extends({}, blockProps, {
55
- testId: `${testId}-errored-view`
56
- }), jsx(LinkIcon, {
57
- position: position
58
- }), jsx(Title, _extends({}, overrideText, {
59
- maxLines: maxLines,
60
- theme: theme
61
- })), descriptor && jsx(ElementGroup, {
44
+ return jsx(BaseTitleBlockComponent, _extends({}, props, {
45
+ blockTestIdPostfix: "errored-view"
46
+ }), retryDescriptor && jsx(ElementGroup, {
62
47
  direction: SmartLinkDirection.Horizontal,
63
48
  align: SmartLinkAlignment.Right
64
49
  }, jsx("span", {
65
50
  css: getMessageStyles(size, hasAction),
66
51
  onClick: onClick,
67
52
  "data-testid": `${testId}-errored-view-message`
68
- }, jsx(FormattedMessage, _extends({}, descriptor, {
69
- values: values
53
+ }, jsx(FormattedMessage, _extends({}, retryDescriptor, {
54
+ values: retryValues
70
55
  })))));
71
56
  };
72
57
 
@@ -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,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.3",
3
+ "version": "18.0.4",
4
4
  "sideEffects": false
5
5
  }
@@ -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
+ };
@@ -0,0 +1,11 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { SerializedStyles } from '@emotion/core';
4
+ import { TitleBlockProps } from './types';
5
+ export declare const actionOnHoverOnlyStyle: SerializedStyles;
6
+ interface BaseTitleBlockProps {
7
+ blockTestIdPostfix: string;
8
+ blockIcon?: React.ReactElement;
9
+ }
10
+ export declare const BaseTitleBlockComponent: React.FC<TitleBlockProps & BaseTitleBlockProps>;
11
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.3",
3
+ "version": "18.0.4",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"