@atlaskit/smart-card 18.0.6 → 18.0.9

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.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6adaa6b5c18`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6adaa6b5c18) - Updated default renderer onClick to not fire on a Flexible UI link to prevent links from being openned twice
8
+
9
+ ## 18.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - [`d9b55e7cd29`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d9b55e7cd29) - Add classname for placeholder element that is shown while we load js module
14
+
15
+ ## 18.0.7
16
+
17
+ ### Patch Changes
18
+
19
+ - [`1f377bd17a4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1f377bd17a4) - Added open in new tab action to titleblock and refactored tests
20
+
3
21
  ## 18.0.6
4
22
 
5
23
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.6",
3
+ "version": "18.0.9",
4
4
  "sideEffects": false
5
5
  }
@@ -80,7 +80,11 @@ function CardWithUrlContent(_ref) {
80
80
  analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
81
81
  }
82
82
 
83
- onClick ? onClick(event) : handleClick(event);
83
+ if (onClick) {
84
+ onClick(event);
85
+ } else if (!isFlexibleUi) {
86
+ handleClick(event);
87
+ }
84
88
  }, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
85
89
  var handleAuthorize = (0, _react.useCallback)(function () {
86
90
  return actions.authorize(appearance);
@@ -23,7 +23,7 @@ var _reactErrorBoundary = require("react-error-boundary");
23
23
 
24
24
  var _ufoExperiences = require("../../state/analytics/ufoExperiences");
25
25
 
26
- var _LinkView = require("../LinkView");
26
+ var _LazyFallback = require("./component-lazy/LazyFallback");
27
27
 
28
28
  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); }
29
29
 
@@ -106,15 +106,7 @@ function CardWithURLRenderer(props) {
106
106
  throw new Error('@atlaskit/smart-card: url property is missing.');
107
107
  }
108
108
 
109
- return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
110
- FallbackComponent: ErrorFallback,
111
- onError: logError
112
- }, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
113
- fallback: /*#__PURE__*/_react.default.createElement(_LinkView.CardLinkView, {
114
- key: 'chunk-placeholder',
115
- link: url
116
- })
117
- }, /*#__PURE__*/_react.default.createElement(LazyCardWithUrlContent, {
109
+ var cardWithUrlProps = {
118
110
  id: id,
119
111
  url: url,
120
112
  appearance: appearance,
@@ -131,7 +123,13 @@ function CardWithURLRenderer(props) {
131
123
  embedIframeRef: embedIframeRef,
132
124
  inlinePreloaderStyle: inlinePreloaderStyle,
133
125
  ui: ui
134
- }, children)));
126
+ };
127
+ return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
128
+ FallbackComponent: ErrorFallback,
129
+ onError: logError
130
+ }, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
131
+ fallback: /*#__PURE__*/_react.default.createElement(_LazyFallback.LoadingCardLink, cardWithUrlProps)
132
+ }, /*#__PURE__*/_react.default.createElement(LazyCardWithUrlContent, cardWithUrlProps, children)));
135
133
  }
136
134
 
137
135
  var ErrorFallback = function ErrorFallback() {
@@ -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.6",
3
+ "version": "18.0.9",
4
4
  "sideEffects": false
5
5
  }
@@ -52,7 +52,11 @@ export function CardWithUrlContent({
52
52
  analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
53
53
  }
54
54
 
55
- onClick ? onClick(event) : handleClick(event);
55
+ if (onClick) {
56
+ onClick(event);
57
+ } else if (!isFlexibleUi) {
58
+ handleClick(event);
59
+ }
56
60
  }, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
57
61
  const handleAuthorize = useCallback(() => actions.authorize(appearance), [actions, appearance]);
58
62
  const handleRetry = useCallback(() => {
@@ -4,7 +4,7 @@ import { uiRenderFailedEvent, fireSmartLinkEvent } from '../../utils/analytics';
4
4
  import { clearMarks, clearMeasures } from '../../utils/performance';
5
5
  import { ErrorBoundary } from 'react-error-boundary';
6
6
  import { failUfoExperience, startUfoExperience } from '../../state/analytics/ufoExperiences';
7
- import { CardLinkView } from '../LinkView';
7
+ import { LoadingCardLink } from './component-lazy/LazyFallback';
8
8
  const LazyCardWithUrlContent = /*#__PURE__*/lazy(() => import(
9
9
  /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
10
10
  './component-lazy/index'));
@@ -78,32 +78,30 @@ export function CardWithURLRenderer(props) {
78
78
  throw new Error('@atlaskit/smart-card: url property is missing.');
79
79
  }
80
80
 
81
+ const cardWithUrlProps = {
82
+ id,
83
+ url,
84
+ appearance,
85
+ onClick,
86
+ isSelected,
87
+ isFrameVisible,
88
+ dispatchAnalytics,
89
+ container,
90
+ onResolve,
91
+ testId,
92
+ showActions,
93
+ inheritDimensions,
94
+ platform,
95
+ embedIframeRef,
96
+ inlinePreloaderStyle,
97
+ ui
98
+ };
81
99
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
82
100
  FallbackComponent: ErrorFallback,
83
101
  onError: logError
84
102
  }, /*#__PURE__*/React.createElement(Suspense, {
85
- fallback: /*#__PURE__*/React.createElement(CardLinkView, {
86
- key: 'chunk-placeholder',
87
- link: url
88
- })
89
- }, /*#__PURE__*/React.createElement(LazyCardWithUrlContent, {
90
- id: id,
91
- url: url,
92
- appearance: appearance,
93
- onClick: onClick,
94
- isSelected: isSelected,
95
- isFrameVisible: isFrameVisible,
96
- dispatchAnalytics: dispatchAnalytics,
97
- container: container,
98
- onResolve: onResolve,
99
- testId: testId,
100
- showActions: showActions,
101
- inheritDimensions: inheritDimensions,
102
- platform: platform,
103
- embedIframeRef: embedIframeRef,
104
- inlinePreloaderStyle: inlinePreloaderStyle,
105
- ui: ui
106
- }, children)));
103
+ fallback: /*#__PURE__*/React.createElement(LoadingCardLink, cardWithUrlProps)
104
+ }, /*#__PURE__*/React.createElement(LazyCardWithUrlContent, cardWithUrlProps, children)));
107
105
  }
108
106
 
109
107
  const ErrorFallback = () => {
@@ -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.6",
3
+ "version": "18.0.9",
4
4
  "sideEffects": false
5
5
  }
@@ -54,7 +54,11 @@ export function CardWithUrlContent(_ref) {
54
54
  analytics.ui.cardClickedEvent(isFlexibleUi ? 'flexible' : appearance, definitionId, extensionKey, isModifierKeyPressed);
55
55
  }
56
56
 
57
- onClick ? onClick(event) : handleClick(event);
57
+ if (onClick) {
58
+ onClick(event);
59
+ } else if (!isFlexibleUi) {
60
+ handleClick(event);
61
+ }
58
62
  }, [state.status, analytics.ui, appearance, definitionId, extensionKey, onClick, handleClick, isFlexibleUi]);
59
63
  var handleAuthorize = useCallback(function () {
60
64
  return actions.authorize(appearance);
@@ -5,7 +5,7 @@ import { uiRenderFailedEvent, fireSmartLinkEvent } from '../../utils/analytics';
5
5
  import { clearMarks, clearMeasures } from '../../utils/performance';
6
6
  import { ErrorBoundary } from 'react-error-boundary';
7
7
  import { failUfoExperience, startUfoExperience } from '../../state/analytics/ufoExperiences';
8
- import { CardLinkView } from '../LinkView';
8
+ import { LoadingCardLink } from './component-lazy/LazyFallback';
9
9
  var LazyCardWithUrlContent = /*#__PURE__*/lazy(function () {
10
10
  return import(
11
11
  /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
@@ -82,15 +82,7 @@ export function CardWithURLRenderer(props) {
82
82
  throw new Error('@atlaskit/smart-card: url property is missing.');
83
83
  }
84
84
 
85
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
86
- FallbackComponent: ErrorFallback,
87
- onError: logError
88
- }, /*#__PURE__*/React.createElement(Suspense, {
89
- fallback: /*#__PURE__*/React.createElement(CardLinkView, {
90
- key: 'chunk-placeholder',
91
- link: url
92
- })
93
- }, /*#__PURE__*/React.createElement(LazyCardWithUrlContent, {
85
+ var cardWithUrlProps = {
94
86
  id: id,
95
87
  url: url,
96
88
  appearance: appearance,
@@ -107,7 +99,13 @@ export function CardWithURLRenderer(props) {
107
99
  embedIframeRef: embedIframeRef,
108
100
  inlinePreloaderStyle: inlinePreloaderStyle,
109
101
  ui: ui
110
- }, children)));
102
+ };
103
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
104
+ FallbackComponent: ErrorFallback,
105
+ onError: logError
106
+ }, /*#__PURE__*/React.createElement(Suspense, {
107
+ fallback: /*#__PURE__*/React.createElement(LoadingCardLink, cardWithUrlProps)
108
+ }, /*#__PURE__*/React.createElement(LazyCardWithUrlContent, cardWithUrlProps, children)));
111
109
  }
112
110
 
113
111
  var ErrorFallback = function ErrorFallback() {
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.6",
3
+ "version": "18.0.9",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"