@atlaskit/smart-card 18.0.4 → 18.0.7

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,23 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 18.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1f377bd17a4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1f377bd17a4) - Added open in new tab action to titleblock and refactored tests
8
+
9
+ ## 18.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [`9945f8983f0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9945f8983f0) - TitleBlock now has "anchorTarget" property
14
+
15
+ ## 18.0.5
16
+
17
+ ### Patch Changes
18
+
19
+ - [`54d8579fe05`](https://bitbucket.org/atlassian/atlassian-frontend/commits/54d8579fe05) - Flexible UI: Reduce link title font weight
20
+
3
21
  ## 18.0.4
4
22
 
5
23
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.4",
3
+ "version": "18.0.7",
4
4
  "sideEffects": false
5
5
  }
@@ -112,9 +112,18 @@ function CardWithUrlContent(_ref) {
112
112
  }, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]);
113
113
 
114
114
  if (isFlexibleUi) {
115
- var cardState = (error === null || error === void 0 ? void 0 : error.constructor) === _.APIError ? {
116
- status: 'errored'
117
- } : state;
115
+ var cardState = state;
116
+
117
+ if (error) {
118
+ if ((error === null || error === void 0 ? void 0 : error.constructor) === _.APIError) {
119
+ cardState = {
120
+ status: 'errored'
121
+ };
122
+ } else {
123
+ throw error;
124
+ }
125
+ }
126
+
118
127
  return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
119
128
  cardState: cardState,
120
129
  onAuthorize: services.length && handleAuthorize || undefined,
@@ -33,7 +33,7 @@ var _elementGroup = _interopRequireDefault(require("../element-group"));
33
33
 
34
34
  var _utils = require("../utils");
35
35
 
36
- var _excluded = ["children", "blockTestIdPostfix", "blockIcon", "testId", "showActionOnHover", "position", "actions", "text", "maxLines", "theme", "onClick", "metadata", "subtitle"];
36
+ var _excluded = ["children", "blockTestIdPostfix", "blockIcon", "testId", "showActionOnHover", "position", "actions", "text", "maxLines", "theme", "onClick", "metadata", "subtitle", "anchorTarget"];
37
37
 
38
38
  var _templateObject;
39
39
 
@@ -61,6 +61,7 @@ var BaseTitleBlockComponent = function BaseTitleBlockComponent(_ref) {
61
61
  metadata = _ref$metadata === void 0 ? [] : _ref$metadata,
62
62
  _ref$subtitle = _ref.subtitle,
63
63
  subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
64
+ anchorTarget = _ref.anchorTarget,
64
65
  blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
65
66
 
66
67
  var _useState = (0, _react.useState)(false),
@@ -85,6 +86,7 @@ var BaseTitleBlockComponent = function BaseTitleBlockComponent(_ref) {
85
86
  }, (0, _core.jsx)(_elements.Title, (0, _extends2.default)({
86
87
  maxLines: maxLines,
87
88
  theme: theme,
89
+ target: anchorTarget,
88
90
  onClick: onClick
89
91
  }, overrideText)), subtitleElements && (0, _core.jsx)(_elementGroup.default, {
90
92
  direction: _constants.SmartLinkDirection.Horizontal
@@ -67,7 +67,8 @@ var Link = function Link(_ref) {
67
67
  _ref$theme = _ref.theme,
68
68
  theme = _ref$theme === void 0 ? _constants.SmartLinkTheme.Link : _ref$theme,
69
69
  url = _ref.url,
70
- onClick = _ref.onClick;
70
+ onClick = _ref.onClick,
71
+ target = _ref.target;
71
72
  return (0, _core.jsx)("span", {
72
73
  css: containerStyles
73
74
  }, (0, _core.jsx)(_tooltip.default, {
@@ -79,7 +80,8 @@ var Link = function Link(_ref) {
79
80
  "data-smart-element-link": true,
80
81
  "data-testid": testId,
81
82
  onClick: onClick,
82
- href: url
83
+ href: url,
84
+ target: target || '_blank'
83
85
  }, text)));
84
86
  };
85
87
 
@@ -66,11 +66,11 @@ var getLinkSizeStyles = function getLinkSizeStyles(size) {
66
66
 
67
67
  case _constants.SmartLinkSize.Large:
68
68
  case _constants.SmartLinkSize.Medium:
69
- return (0, _core.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 0.875rem;\n font-weight: 500;\n letter-spacing: -0.003em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
69
+ return (0, _core.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 0.875rem;\n font-weight: 400;\n letter-spacing: -0.003em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
70
70
 
71
71
  case _constants.SmartLinkSize.Small:
72
72
  default:
73
- return (0, _core.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 0.75rem;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
73
+ return (0, _core.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 0.75rem;\n font-weight: 400;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
74
74
  }
75
75
  };
76
76
 
@@ -29,6 +29,8 @@ var _useSmartLinkActions = require("../../state/hooks-external/useSmartLinkActio
29
29
 
30
30
  var _styled = require("./styled");
31
31
 
32
+ var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
33
+
32
34
  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); }
33
35
 
34
36
  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; }
@@ -71,7 +73,7 @@ var HoverCard = function HoverCard(_ref) {
71
73
  appearance: 'block',
72
74
  analyticsHandler: analyticsHandler
73
75
  });
74
- var actions = (0, _react.useMemo)(function () {
76
+ var smartlinkActions = (0, _react.useMemo)(function () {
75
77
  return linkActions.map(function (action) {
76
78
  return {
77
79
  content: action.text,
@@ -83,6 +85,20 @@ var HoverCard = function HoverCard(_ref) {
83
85
  };
84
86
  });
85
87
  }, [linkActions]);
88
+ var openAction = (0, _react.useMemo)(function () {
89
+ return {
90
+ name: _constants.ActionName.CustomAction,
91
+ icon: (0, _core.jsx)(_shortcut.default, {
92
+ label: "open in new tab",
93
+ size: "medium"
94
+ }),
95
+ iconPosition: 'before',
96
+ onClick: function onClick() {
97
+ return window.open(url, '_blank');
98
+ },
99
+ testId: 'hover-card-open-button'
100
+ };
101
+ }, [url]);
86
102
 
87
103
  var cardComponent = function cardComponent() {
88
104
  return (0, _core.jsx)("div", {
@@ -96,8 +112,10 @@ var HoverCard = function HoverCard(_ref) {
96
112
  hideElevation: true,
97
113
  size: _constants.SmartLinkSize.Large
98
114
  }
99
- }, (0, _core.jsx)(_blocks.TitleBlock, null), (0, _core.jsx)(_blocks.SnippetBlock, null), (0, _core.jsx)(_blocks.FooterBlock, {
100
- actions: actions
115
+ }, (0, _core.jsx)(_blocks.TitleBlock, {
116
+ actions: [openAction]
117
+ }), (0, _core.jsx)(_blocks.SnippetBlock, null), (0, _core.jsx)(_blocks.FooterBlock, {
118
+ actions: smartlinkActions
101
119
  })));
102
120
  };
103
121
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.4",
3
+ "version": "18.0.7",
4
4
  "sideEffects": false
5
5
  }
@@ -80,9 +80,18 @@ export function CardWithUrlContent({
80
80
  }, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]);
81
81
 
82
82
  if (isFlexibleUi) {
83
- let cardState = (error === null || error === void 0 ? void 0 : error.constructor) === APIError ? {
84
- status: 'errored'
85
- } : state;
83
+ let cardState = state;
84
+
85
+ if (error) {
86
+ if ((error === null || error === void 0 ? void 0 : error.constructor) === APIError) {
87
+ cardState = {
88
+ status: 'errored'
89
+ };
90
+ } else {
91
+ throw error;
92
+ }
93
+ }
94
+
86
95
  return /*#__PURE__*/React.createElement(FlexibleCard, {
87
96
  cardState: cardState,
88
97
  onAuthorize: services.length && handleAuthorize || undefined,
@@ -35,6 +35,7 @@ export const BaseTitleBlockComponent = ({
35
35
  onClick,
36
36
  metadata = [],
37
37
  subtitle = [],
38
+ anchorTarget,
38
39
  ...blockProps
39
40
  }) => {
40
41
  const [actionDropdownOpen, setActionDropdownOpen] = useState(false);
@@ -55,6 +56,7 @@ export const BaseTitleBlockComponent = ({
55
56
  }, jsx(Title, _extends({
56
57
  maxLines: maxLines,
57
58
  theme: theme,
59
+ target: anchorTarget,
58
60
  onClick: onClick
59
61
  }, overrideText)), subtitleElements && jsx(ElementGroup, {
60
62
  direction: SmartLinkDirection.Horizontal
@@ -71,7 +71,8 @@ const Link = ({
71
71
  text,
72
72
  theme = SmartLinkTheme.Link,
73
73
  url,
74
- onClick
74
+ onClick,
75
+ target
75
76
  }) => jsx("span", {
76
77
  css: containerStyles
77
78
  }, jsx(Tooltip, {
@@ -83,7 +84,8 @@ const Link = ({
83
84
  "data-smart-element-link": true,
84
85
  "data-testid": testId,
85
86
  onClick: onClick,
86
- href: url
87
+ href: url,
88
+ target: target || '_blank'
87
89
  }, text)));
88
90
 
89
91
  export default Link;
@@ -65,7 +65,7 @@ export const getLinkSizeStyles = size => {
65
65
  case SmartLinkSize.Medium:
66
66
  return css`
67
67
  font-size: 0.875rem;
68
- font-weight: 500;
68
+ font-weight: 400;
69
69
  letter-spacing: -0.003em;
70
70
  line-height: ${getLinkLineHeight(size)};
71
71
  `;
@@ -74,7 +74,7 @@ export const getLinkSizeStyles = size => {
74
74
  default:
75
75
  return css`
76
76
  font-size: 0.75rem;
77
- font-weight: 500;
77
+ font-weight: 400;
78
78
  letter-spacing: 0em;
79
79
  line-height: ${getLinkLineHeight(size)};
80
80
  `;
@@ -9,6 +9,7 @@ import Popup from '@atlaskit/popup';
9
9
  import { SmartLinkSize, ActionName } from '../../constants';
10
10
  import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
11
11
  import { HoverCardContainer } from './styled';
12
+ import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
12
13
  export const HoverCard = ({
13
14
  children,
14
15
  url
@@ -42,12 +43,24 @@ export const HoverCard = ({
42
43
  appearance: 'block',
43
44
  analyticsHandler
44
45
  });
45
- const actions = useMemo(() => linkActions.map(action => ({
46
+ const smartlinkActions = useMemo(() => linkActions.map(action => ({
46
47
  content: action.text,
47
48
  name: ActionName.CustomAction,
48
49
  onClick: () => action.invoke(),
49
50
  testId: action.id
50
51
  })), [linkActions]);
52
+ const openAction = useMemo(() => {
53
+ return {
54
+ name: ActionName.CustomAction,
55
+ icon: jsx(ShortcutIcon, {
56
+ label: "open in new tab",
57
+ size: "medium"
58
+ }),
59
+ iconPosition: 'before',
60
+ onClick: () => window.open(url, '_blank'),
61
+ testId: 'hover-card-open-button'
62
+ };
63
+ }, [url]);
51
64
 
52
65
  const cardComponent = () => jsx("div", {
53
66
  onMouseEnter: initShowCard,
@@ -60,8 +73,10 @@ export const HoverCard = ({
60
73
  hideElevation: true,
61
74
  size: SmartLinkSize.Large
62
75
  }
63
- }, jsx(TitleBlock, null), jsx(SnippetBlock, null), jsx(FooterBlock, {
64
- actions: actions
76
+ }, jsx(TitleBlock, {
77
+ actions: [openAction]
78
+ }), jsx(SnippetBlock, null), jsx(FooterBlock, {
79
+ actions: smartlinkActions
65
80
  })));
66
81
 
67
82
  const onClose = useCallback(() => setIsOpen(false), []);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.4",
3
+ "version": "18.0.7",
4
4
  "sideEffects": false
5
5
  }
@@ -86,9 +86,18 @@ export function CardWithUrlContent(_ref) {
86
86
  }, [appearance, state.details, state.status, url, definitionId, extensionKey, analytics.ui, id]);
87
87
 
88
88
  if (isFlexibleUi) {
89
- var cardState = (error === null || error === void 0 ? void 0 : error.constructor) === APIError ? {
90
- status: 'errored'
91
- } : state;
89
+ var cardState = state;
90
+
91
+ if (error) {
92
+ if ((error === null || error === void 0 ? void 0 : error.constructor) === APIError) {
93
+ cardState = {
94
+ status: 'errored'
95
+ };
96
+ } else {
97
+ throw error;
98
+ }
99
+ }
100
+
92
101
  return /*#__PURE__*/React.createElement(FlexibleCard, {
93
102
  cardState: cardState,
94
103
  onAuthorize: services.length && handleAuthorize || undefined,
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
- var _excluded = ["children", "blockTestIdPostfix", "blockIcon", "testId", "showActionOnHover", "position", "actions", "text", "maxLines", "theme", "onClick", "metadata", "subtitle"];
5
+ var _excluded = ["children", "blockTestIdPostfix", "blockIcon", "testId", "showActionOnHover", "position", "actions", "text", "maxLines", "theme", "onClick", "metadata", "subtitle", "anchorTarget"];
6
6
 
7
7
  var _templateObject;
8
8
 
@@ -34,6 +34,7 @@ export var BaseTitleBlockComponent = function BaseTitleBlockComponent(_ref) {
34
34
  metadata = _ref$metadata === void 0 ? [] : _ref$metadata,
35
35
  _ref$subtitle = _ref.subtitle,
36
36
  subtitle = _ref$subtitle === void 0 ? [] : _ref$subtitle,
37
+ anchorTarget = _ref.anchorTarget,
37
38
  blockProps = _objectWithoutProperties(_ref, _excluded);
38
39
 
39
40
  var _useState = useState(false),
@@ -58,6 +59,7 @@ export var BaseTitleBlockComponent = function BaseTitleBlockComponent(_ref) {
58
59
  }, jsx(Title, _extends({
59
60
  maxLines: maxLines,
60
61
  theme: theme,
62
+ target: anchorTarget,
61
63
  onClick: onClick
62
64
  }, overrideText)), subtitleElements && jsx(ElementGroup, {
63
65
  direction: SmartLinkDirection.Horizontal
@@ -53,7 +53,8 @@ var Link = function Link(_ref) {
53
53
  _ref$theme = _ref.theme,
54
54
  theme = _ref$theme === void 0 ? SmartLinkTheme.Link : _ref$theme,
55
55
  url = _ref.url,
56
- onClick = _ref.onClick;
56
+ onClick = _ref.onClick,
57
+ target = _ref.target;
57
58
  return jsx("span", {
58
59
  css: containerStyles
59
60
  }, jsx(Tooltip, {
@@ -65,7 +66,8 @@ var Link = function Link(_ref) {
65
66
  "data-smart-element-link": true,
66
67
  "data-testid": testId,
67
68
  onClick: onClick,
68
- href: url
69
+ href: url,
70
+ target: target || '_blank'
69
71
  }, text)));
70
72
  };
71
73
 
@@ -44,11 +44,11 @@ export var getLinkSizeStyles = function getLinkSizeStyles(size) {
44
44
 
45
45
  case SmartLinkSize.Large:
46
46
  case SmartLinkSize.Medium:
47
- return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: 0.875rem;\n font-weight: 500;\n letter-spacing: -0.003em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
47
+ return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n font-size: 0.875rem;\n font-weight: 400;\n letter-spacing: -0.003em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
48
48
 
49
49
  case SmartLinkSize.Small:
50
50
  default:
51
- return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
51
+ return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 400;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
52
52
  }
53
53
  };
54
54
  export var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
@@ -10,6 +10,7 @@ import Popup from '@atlaskit/popup';
10
10
  import { SmartLinkSize, ActionName } from '../../constants';
11
11
  import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
12
12
  import { HoverCardContainer } from './styled';
13
+ import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
13
14
  export var HoverCard = function HoverCard(_ref) {
14
15
  var children = _ref.children,
15
16
  url = _ref.url;
@@ -47,7 +48,7 @@ export var HoverCard = function HoverCard(_ref) {
47
48
  appearance: 'block',
48
49
  analyticsHandler: analyticsHandler
49
50
  });
50
- var actions = useMemo(function () {
51
+ var smartlinkActions = useMemo(function () {
51
52
  return linkActions.map(function (action) {
52
53
  return {
53
54
  content: action.text,
@@ -59,6 +60,20 @@ export var HoverCard = function HoverCard(_ref) {
59
60
  };
60
61
  });
61
62
  }, [linkActions]);
63
+ var openAction = useMemo(function () {
64
+ return {
65
+ name: ActionName.CustomAction,
66
+ icon: jsx(ShortcutIcon, {
67
+ label: "open in new tab",
68
+ size: "medium"
69
+ }),
70
+ iconPosition: 'before',
71
+ onClick: function onClick() {
72
+ return window.open(url, '_blank');
73
+ },
74
+ testId: 'hover-card-open-button'
75
+ };
76
+ }, [url]);
62
77
 
63
78
  var cardComponent = function cardComponent() {
64
79
  return jsx("div", {
@@ -72,8 +87,10 @@ export var HoverCard = function HoverCard(_ref) {
72
87
  hideElevation: true,
73
88
  size: SmartLinkSize.Large
74
89
  }
75
- }, jsx(TitleBlock, null), jsx(SnippetBlock, null), jsx(FooterBlock, {
76
- actions: actions
90
+ }, jsx(TitleBlock, {
91
+ actions: [openAction]
92
+ }), jsx(SnippetBlock, null), jsx(FooterBlock, {
93
+ actions: smartlinkActions
77
94
  })));
78
95
  };
79
96
 
@@ -2,6 +2,7 @@
2
2
  import { BlockProps, ElementItem, ActionItem } from '../types';
3
3
  import { SmartLinkPosition, SmartLinkTheme } from '../../../../../constants';
4
4
  import { RetryOptions } from '../../../types';
5
+ import { LinkProps } from '../../elements/link/types';
5
6
  export declare type TitleBlockProps = BlockProps & {
6
7
  maxLines?: number;
7
8
  metadata?: ElementItem[];
@@ -13,4 +14,5 @@ export declare type TitleBlockProps = BlockProps & {
13
14
  text?: string;
14
15
  showActionOnHover?: boolean;
15
16
  onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
17
+ anchorTarget?: LinkProps['target'];
16
18
  };
@@ -7,4 +7,5 @@ export declare type LinkProps = ElementProps & {
7
7
  text?: string;
8
8
  theme?: SmartLinkTheme;
9
9
  url?: string;
10
+ target?: '_blank' | '_self' | '_top' | '_parent';
10
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.4",
3
+ "version": "18.0.7",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"