@atlaskit/smart-card 23.8.0 → 23.8.1

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
+ ## 23.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`af251caa485`](https://bitbucket.org/atlassian/atlassian-frontend/commits/af251caa485) - Push div from hoverCardComponent into hoverCardContent to allow conditional rendering from inside hoverCardContent.
8
+
3
9
  ## 23.8.0
4
10
 
5
11
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.8.0",
3
+ "version": "23.8.1",
4
4
  "sideEffects": false
5
5
  }
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.hoverCardClassName = exports.HoverCardComponent = void 0;
10
+ exports.HoverCardComponent = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
@@ -36,9 +36,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
36
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; }
37
37
 
38
38
  /** @jsx jsx */
39
- var hoverCardClassName = 'smart-links-hover-preview';
40
- exports.hoverCardClassName = hoverCardClassName;
41
-
42
39
  var HoverCardComponent = function HoverCardComponent(_ref) {
43
40
  var children = _ref.children,
44
41
  url = _ref.url,
@@ -137,9 +134,6 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
137
134
  }
138
135
  }, [hideCard]); // Stop hover preview content to propagate event to parent.
139
136
 
140
- var onClick = (0, _react2.useCallback)(function (e) {
141
- return e.stopPropagation();
142
- }, []);
143
137
  return (0, _react.jsx)(_popup.default, {
144
138
  testId: "hover-card",
145
139
  isOpen: isOpen,
@@ -149,14 +143,9 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
149
143
  autoFocus: false,
150
144
  content: function content(_ref2) {
151
145
  var update = _ref2.update;
152
- return (0, _react.jsx)("div", {
146
+ return (0, _react.jsx)(_HoverCardContent.default, {
153
147
  onMouseEnter: initShowCard,
154
148
  onMouseLeave: initHideCard,
155
- onClick: onClick,
156
- css: _styled.HoverCardContainer // class name for trello to exclude click events
157
- ,
158
- className: hoverCardClassName
159
- }, (0, _react.jsx)(_HoverCardContent.default, {
160
149
  analytics: analytics,
161
150
  cardActions: linkActions,
162
151
  cardState: linkState,
@@ -164,7 +153,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
164
153
  onResolve: update,
165
154
  renderers: renderers,
166
155
  url: url
167
- }));
156
+ });
168
157
  },
169
158
  trigger: function trigger(triggerProps) {
170
159
  return (0, _react.jsx)("span", {
@@ -7,13 +7,15 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.getOpenAction = exports.default = void 0;
10
+ exports.hoverCardClassName = exports.getOpenAction = exports.default = void 0;
11
+
12
+ var _react = require("@emotion/react");
11
13
 
12
14
  var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
13
15
 
14
16
  var _extractors = require("@atlaskit/linking-common/extractors");
15
17
 
16
- var _react = _interopRequireWildcard(require("react"));
18
+ var _react2 = _interopRequireWildcard(require("react"));
17
19
 
18
20
  var _constants = require("../../../constants");
19
21
 
@@ -41,10 +43,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
41
43
 
42
44
  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
45
 
46
+ /** @jsx jsx */
47
+ var hoverCardClassName = 'smart-links-hover-preview';
48
+ exports.hoverCardClassName = hoverCardClassName;
49
+
44
50
  var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
45
51
  return {
46
52
  name: _constants.ActionName.CustomAction,
47
- icon: /*#__PURE__*/_react.default.createElement(_shortcut.default, {
53
+ icon: (0, _react.jsx)(_shortcut.default, {
48
54
  label: "open in new tab",
49
55
  size: "medium"
50
56
  }),
@@ -59,7 +65,7 @@ var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
59
65
  previewDisplay: 'card'
60
66
  });
61
67
  },
62
- tooltipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.open_link_in_a_new_tab),
68
+ tooltipMessage: (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.open_link_in_a_new_tab),
63
69
  testId: 'hover-card-open-button'
64
70
  };
65
71
  };
@@ -78,11 +84,13 @@ var HoverCardContent = function HoverCardContent(_ref) {
78
84
  onActionClick = _ref.onActionClick,
79
85
  onResolve = _ref.onResolve,
80
86
  renderers = _ref.renderers,
81
- url = _ref.url;
82
- var extensionKey = (0, _react.useMemo)(function () {
87
+ url = _ref.url,
88
+ onMouseEnter = _ref.onMouseEnter,
89
+ onMouseLeave = _ref.onMouseLeave;
90
+ var extensionKey = (0, _react2.useMemo)(function () {
83
91
  return (0, _helpers.getExtensionKey)(cardState.details);
84
92
  }, [cardState.details]);
85
- var onClick = (0, _react.useCallback)(function (event) {
93
+ var onClick = (0, _react2.useCallback)(function (event) {
86
94
  var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
87
95
  analytics.ui.cardClickedEvent({
88
96
  id: id,
@@ -92,7 +100,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
92
100
  actionSubjectId: 'titleGoToLink'
93
101
  });
94
102
  }, [cardState.status, analytics.ui, id]);
95
- var titleActions = (0, _react.useMemo)(function () {
103
+ var titleActions = (0, _react2.useMemo)(function () {
96
104
  return [getOpenAction(url, analytics, onActionClick)];
97
105
  }, [url, analytics, onActionClick]);
98
106
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
@@ -119,36 +127,53 @@ var HoverCardContent = function HoverCardContent(_ref) {
119
127
  url: url,
120
128
  children: {}
121
129
  };
130
+ var onClickStopPropagation = (0, _react2.useCallback)(function (e) {
131
+ return e.stopPropagation();
132
+ }, []);
133
+
134
+ var getCardView = function getCardView(cardState) {
135
+ if (cardState.metadataStatus === 'pending') {
136
+ return (0, _react.jsx)(_resolving.default, {
137
+ flexibleCardProps: flexibleCardProps,
138
+ titleBlockProps: titleBlockProps
139
+ });
140
+ }
141
+
142
+ if (cardState.status === 'unauthorized') {
143
+ return (0, _react.jsx)(_unauthorised.default, {
144
+ analytics: analytics,
145
+ extensionKey: extensionKey,
146
+ id: id,
147
+ flexibleCardProps: flexibleCardProps,
148
+ url: url
149
+ });
150
+ }
151
+
152
+ if (cardState.status === 'resolved') {
153
+ return (0, _react.jsx)(_resolved.default, {
154
+ id: id,
155
+ url: url,
156
+ extensionKey: extensionKey,
157
+ analytics: analytics,
158
+ cardActions: cardActions,
159
+ cardState: cardState,
160
+ flexibleCardProps: flexibleCardProps,
161
+ onActionClick: onActionClick,
162
+ titleBlockProps: titleBlockProps
163
+ });
164
+ }
122
165
 
123
- if (cardState.metadataStatus === 'pending') {
124
- return /*#__PURE__*/_react.default.createElement(_resolving.default, {
125
- flexibleCardProps: flexibleCardProps,
126
- titleBlockProps: titleBlockProps
127
- });
128
- }
129
-
130
- if (cardState.status === 'unauthorized') {
131
- return /*#__PURE__*/_react.default.createElement(_unauthorised.default, {
132
- analytics: analytics,
133
- extensionKey: extensionKey,
134
- id: id,
135
- flexibleCardProps: flexibleCardProps,
136
- url: url
137
- });
138
- } // if metadataStatus is 'errored' simply render using data available (normal path)
139
-
166
+ return null;
167
+ };
140
168
 
141
- return /*#__PURE__*/_react.default.createElement(_resolved.default, {
142
- id: id,
143
- url: url,
144
- extensionKey: extensionKey,
145
- analytics: analytics,
146
- cardActions: cardActions,
147
- cardState: cardState,
148
- flexibleCardProps: flexibleCardProps,
149
- onActionClick: onActionClick,
150
- titleBlockProps: titleBlockProps
151
- });
169
+ var cardView = getCardView(cardState);
170
+ return cardView ? (0, _react.jsx)("div", {
171
+ onMouseEnter: onMouseEnter,
172
+ onMouseLeave: onMouseLeave,
173
+ onClick: onClickStopPropagation,
174
+ className: hoverCardClassName,
175
+ css: _styled.HoverCardContainer
176
+ }, cardView) : null;
152
177
  };
153
178
 
154
179
  var _default = HoverCardContent;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.8.0",
3
+ "version": "23.8.1",
4
4
  "sideEffects": false
5
5
  }
@@ -8,9 +8,8 @@ import { useSmartLinkActions } from '../../../state/hooks-external/useSmartLinkA
8
8
  import { useSmartLinkRenderers } from '../../../state/renderers';
9
9
  import { useSmartCardState as useLinkState } from '../../../state/store';
10
10
  import HoverCardContent from '../components/HoverCardContent';
11
- import { HoverCardContainer, CARD_GAP_PX } from '../styled';
11
+ import { CARD_GAP_PX } from '../styled';
12
12
  import { CardDisplay } from '../../../constants';
13
- export const hoverCardClassName = 'smart-links-hover-preview';
14
13
  export const HoverCardComponent = ({
15
14
  children,
16
15
  url,
@@ -103,7 +102,6 @@ export const HoverCardComponent = ({
103
102
  }
104
103
  }, [hideCard]); // Stop hover preview content to propagate event to parent.
105
104
 
106
- const onClick = useCallback(e => e.stopPropagation(), []);
107
105
  return jsx(Popup, {
108
106
  testId: "hover-card",
109
107
  isOpen: isOpen,
@@ -113,14 +111,9 @@ export const HoverCardComponent = ({
113
111
  autoFocus: false,
114
112
  content: ({
115
113
  update
116
- }) => jsx("div", {
114
+ }) => jsx(HoverCardContent, {
117
115
  onMouseEnter: initShowCard,
118
116
  onMouseLeave: initHideCard,
119
- onClick: onClick,
120
- css: HoverCardContainer // class name for trello to exclude click events
121
- ,
122
- className: hoverCardClassName
123
- }, jsx(HoverCardContent, {
124
117
  analytics: analytics,
125
118
  cardActions: linkActions,
126
119
  cardState: linkState,
@@ -128,7 +121,7 @@ export const HoverCardComponent = ({
128
121
  onResolve: update,
129
122
  renderers: renderers,
130
123
  url: url
131
- })),
124
+ }),
132
125
  trigger: triggerProps => jsx("span", {
133
126
  ref: parentSpan
134
127
  }, jsx("span", _extends({}, triggerProps, {
@@ -1,3 +1,5 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
1
3
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
2
4
  import { extractType } from '@atlaskit/linking-common/extractors';
3
5
  import React, { useCallback, useMemo } from 'react';
@@ -5,16 +7,17 @@ import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../..
5
7
  import { extractMetadata } from '../../../extractors/hover/extractMetadata';
6
8
  import { getExtensionKey } from '../../../state/helpers';
7
9
  import { isSpecialEvent } from '../../../utils';
8
- import { flexibleUiOptions, titleBlockCss } from '../styled';
10
+ import { HoverCardContainer, flexibleUiOptions, titleBlockCss } from '../styled';
9
11
  import { getSimulatedMetadata } from '../utils';
10
12
  import HoverCardLoadingView from './views/resolving';
11
13
  import HoverCardUnauthorisedView from './views/unauthorised';
12
14
  import HoverCardResolvedView from './views/resolved';
13
15
  import { FormattedMessage } from 'react-intl-next';
14
16
  import { messages } from '../../../messages';
17
+ export const hoverCardClassName = 'smart-links-hover-preview';
15
18
  export const getOpenAction = (url, analytics, onActionClick) => ({
16
19
  name: ActionName.CustomAction,
17
- icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
20
+ icon: jsx(ShortcutIcon, {
18
21
  label: "open in new tab",
19
22
  size: "medium"
20
23
  }),
@@ -29,7 +32,7 @@ export const getOpenAction = (url, analytics, onActionClick) => ({
29
32
  previewDisplay: 'card'
30
33
  });
31
34
  },
32
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.open_link_in_a_new_tab),
35
+ tooltipMessage: jsx(FormattedMessage, messages.open_link_in_a_new_tab),
33
36
  testId: 'hover-card-open-button'
34
37
  });
35
38
 
@@ -41,7 +44,9 @@ const HoverCardContent = ({
41
44
  onActionClick,
42
45
  onResolve,
43
46
  renderers,
44
- url
47
+ url,
48
+ onMouseEnter,
49
+ onMouseLeave
45
50
  }) => {
46
51
  var _cardState$details;
47
52
 
@@ -80,36 +85,51 @@ const HoverCardContent = ({
80
85
  url: url,
81
86
  children: {}
82
87
  };
88
+ const onClickStopPropagation = useCallback(e => e.stopPropagation(), []);
83
89
 
84
- if (cardState.metadataStatus === 'pending') {
85
- return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
86
- flexibleCardProps: flexibleCardProps,
87
- titleBlockProps: titleBlockProps
88
- });
89
- }
90
+ const getCardView = cardState => {
91
+ if (cardState.metadataStatus === 'pending') {
92
+ return jsx(HoverCardLoadingView, {
93
+ flexibleCardProps: flexibleCardProps,
94
+ titleBlockProps: titleBlockProps
95
+ });
96
+ }
90
97
 
91
- if (cardState.status === 'unauthorized') {
92
- return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
93
- analytics: analytics,
94
- extensionKey: extensionKey,
95
- id: id,
96
- flexibleCardProps: flexibleCardProps,
97
- url: url
98
- });
99
- } // if metadataStatus is 'errored' simply render using data available (normal path)
98
+ if (cardState.status === 'unauthorized') {
99
+ return jsx(HoverCardUnauthorisedView, {
100
+ analytics: analytics,
101
+ extensionKey: extensionKey,
102
+ id: id,
103
+ flexibleCardProps: flexibleCardProps,
104
+ url: url
105
+ });
106
+ }
100
107
 
108
+ if (cardState.status === 'resolved') {
109
+ return jsx(HoverCardResolvedView, {
110
+ id: id,
111
+ url: url,
112
+ extensionKey: extensionKey,
113
+ analytics: analytics,
114
+ cardActions: cardActions,
115
+ cardState: cardState,
116
+ flexibleCardProps: flexibleCardProps,
117
+ onActionClick: onActionClick,
118
+ titleBlockProps: titleBlockProps
119
+ });
120
+ }
101
121
 
102
- return /*#__PURE__*/React.createElement(HoverCardResolvedView, {
103
- id: id,
104
- url: url,
105
- extensionKey: extensionKey,
106
- analytics: analytics,
107
- cardActions: cardActions,
108
- cardState: cardState,
109
- flexibleCardProps: flexibleCardProps,
110
- onActionClick: onActionClick,
111
- titleBlockProps: titleBlockProps
112
- });
122
+ return null;
123
+ };
124
+
125
+ const cardView = getCardView(cardState);
126
+ return cardView ? jsx("div", {
127
+ onMouseEnter: onMouseEnter,
128
+ onMouseLeave: onMouseLeave,
129
+ onClick: onClickStopPropagation,
130
+ className: hoverCardClassName,
131
+ css: HoverCardContainer
132
+ }, cardView) : null;
113
133
  };
114
134
 
115
135
  export default HoverCardContent;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.8.0",
3
+ "version": "23.8.1",
4
4
  "sideEffects": false
5
5
  }
@@ -9,9 +9,8 @@ import { useSmartLinkActions } from '../../../state/hooks-external/useSmartLinkA
9
9
  import { useSmartLinkRenderers } from '../../../state/renderers';
10
10
  import { useSmartCardState as useLinkState } from '../../../state/store';
11
11
  import HoverCardContent from '../components/HoverCardContent';
12
- import { HoverCardContainer, CARD_GAP_PX } from '../styled';
12
+ import { CARD_GAP_PX } from '../styled';
13
13
  import { CardDisplay } from '../../../constants';
14
- export var hoverCardClassName = 'smart-links-hover-preview';
15
14
  export var HoverCardComponent = function HoverCardComponent(_ref) {
16
15
  var children = _ref.children,
17
16
  url = _ref.url,
@@ -110,9 +109,6 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
110
109
  }
111
110
  }, [hideCard]); // Stop hover preview content to propagate event to parent.
112
111
 
113
- var onClick = useCallback(function (e) {
114
- return e.stopPropagation();
115
- }, []);
116
112
  return jsx(Popup, {
117
113
  testId: "hover-card",
118
114
  isOpen: isOpen,
@@ -122,14 +118,9 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
122
118
  autoFocus: false,
123
119
  content: function content(_ref2) {
124
120
  var update = _ref2.update;
125
- return jsx("div", {
121
+ return jsx(HoverCardContent, {
126
122
  onMouseEnter: initShowCard,
127
123
  onMouseLeave: initHideCard,
128
- onClick: onClick,
129
- css: HoverCardContainer // class name for trello to exclude click events
130
- ,
131
- className: hoverCardClassName
132
- }, jsx(HoverCardContent, {
133
124
  analytics: analytics,
134
125
  cardActions: linkActions,
135
126
  cardState: linkState,
@@ -137,7 +128,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
137
128
  onResolve: update,
138
129
  renderers: renderers,
139
130
  url: url
140
- }));
131
+ });
141
132
  },
142
133
  trigger: function trigger(triggerProps) {
143
134
  return jsx("span", {
@@ -1,3 +1,5 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
1
3
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
2
4
  import { extractType } from '@atlaskit/linking-common/extractors';
3
5
  import React, { useCallback, useMemo } from 'react';
@@ -5,17 +7,18 @@ import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../..
5
7
  import { extractMetadata } from '../../../extractors/hover/extractMetadata';
6
8
  import { getExtensionKey } from '../../../state/helpers';
7
9
  import { isSpecialEvent } from '../../../utils';
8
- import { flexibleUiOptions, titleBlockCss } from '../styled';
10
+ import { HoverCardContainer, flexibleUiOptions, titleBlockCss } from '../styled';
9
11
  import { getSimulatedMetadata } from '../utils';
10
12
  import HoverCardLoadingView from './views/resolving';
11
13
  import HoverCardUnauthorisedView from './views/unauthorised';
12
14
  import HoverCardResolvedView from './views/resolved';
13
15
  import { FormattedMessage } from 'react-intl-next';
14
16
  import { messages } from '../../../messages';
17
+ export var hoverCardClassName = 'smart-links-hover-preview';
15
18
  export var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
16
19
  return {
17
20
  name: ActionName.CustomAction,
18
- icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
21
+ icon: jsx(ShortcutIcon, {
19
22
  label: "open in new tab",
20
23
  size: "medium"
21
24
  }),
@@ -30,7 +33,7 @@ export var getOpenAction = function getOpenAction(url, analytics, onActionClick)
30
33
  previewDisplay: 'card'
31
34
  });
32
35
  },
33
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.open_link_in_a_new_tab),
36
+ tooltipMessage: jsx(FormattedMessage, messages.open_link_in_a_new_tab),
34
37
  testId: 'hover-card-open-button'
35
38
  };
36
39
  };
@@ -47,7 +50,9 @@ var HoverCardContent = function HoverCardContent(_ref) {
47
50
  onActionClick = _ref.onActionClick,
48
51
  onResolve = _ref.onResolve,
49
52
  renderers = _ref.renderers,
50
- url = _ref.url;
53
+ url = _ref.url,
54
+ onMouseEnter = _ref.onMouseEnter,
55
+ onMouseLeave = _ref.onMouseLeave;
51
56
  var extensionKey = useMemo(function () {
52
57
  return getExtensionKey(cardState.details);
53
58
  }, [cardState.details]);
@@ -88,36 +93,53 @@ var HoverCardContent = function HoverCardContent(_ref) {
88
93
  url: url,
89
94
  children: {}
90
95
  };
96
+ var onClickStopPropagation = useCallback(function (e) {
97
+ return e.stopPropagation();
98
+ }, []);
91
99
 
92
- if (cardState.metadataStatus === 'pending') {
93
- return /*#__PURE__*/React.createElement(HoverCardLoadingView, {
94
- flexibleCardProps: flexibleCardProps,
95
- titleBlockProps: titleBlockProps
96
- });
97
- }
100
+ var getCardView = function getCardView(cardState) {
101
+ if (cardState.metadataStatus === 'pending') {
102
+ return jsx(HoverCardLoadingView, {
103
+ flexibleCardProps: flexibleCardProps,
104
+ titleBlockProps: titleBlockProps
105
+ });
106
+ }
98
107
 
99
- if (cardState.status === 'unauthorized') {
100
- return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
101
- analytics: analytics,
102
- extensionKey: extensionKey,
103
- id: id,
104
- flexibleCardProps: flexibleCardProps,
105
- url: url
106
- });
107
- } // if metadataStatus is 'errored' simply render using data available (normal path)
108
+ if (cardState.status === 'unauthorized') {
109
+ return jsx(HoverCardUnauthorisedView, {
110
+ analytics: analytics,
111
+ extensionKey: extensionKey,
112
+ id: id,
113
+ flexibleCardProps: flexibleCardProps,
114
+ url: url
115
+ });
116
+ }
108
117
 
118
+ if (cardState.status === 'resolved') {
119
+ return jsx(HoverCardResolvedView, {
120
+ id: id,
121
+ url: url,
122
+ extensionKey: extensionKey,
123
+ analytics: analytics,
124
+ cardActions: cardActions,
125
+ cardState: cardState,
126
+ flexibleCardProps: flexibleCardProps,
127
+ onActionClick: onActionClick,
128
+ titleBlockProps: titleBlockProps
129
+ });
130
+ }
109
131
 
110
- return /*#__PURE__*/React.createElement(HoverCardResolvedView, {
111
- id: id,
112
- url: url,
113
- extensionKey: extensionKey,
114
- analytics: analytics,
115
- cardActions: cardActions,
116
- cardState: cardState,
117
- flexibleCardProps: flexibleCardProps,
118
- onActionClick: onActionClick,
119
- titleBlockProps: titleBlockProps
120
- });
132
+ return null;
133
+ };
134
+
135
+ var cardView = getCardView(cardState);
136
+ return cardView ? jsx("div", {
137
+ onMouseEnter: onMouseEnter,
138
+ onMouseLeave: onMouseLeave,
139
+ onClick: onClickStopPropagation,
140
+ className: hoverCardClassName,
141
+ css: HoverCardContainer
142
+ }, cardView) : null;
121
143
  };
122
144
 
123
145
  export default HoverCardContent;
@@ -1,4 +1,3 @@
1
1
  import { FC } from 'react';
2
2
  import { HoverCardComponentProps } from '../types';
3
- export declare const hoverCardClassName = "smart-links-hover-preview";
4
3
  export declare const HoverCardComponent: FC<HoverCardComponentProps>;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { AnalyticsFacade } from '../../../state/analytics';
3
3
  import { ActionItem } from '../../FlexibleCard/components/blocks/types';
4
4
  import { HoverCardContentProps } from '../types';
5
+ export declare const hoverCardClassName = "smart-links-hover-preview";
5
6
  export declare const getOpenAction: (url: string, analytics: AnalyticsFacade, onActionClick?: ((actionId: string) => void) | undefined) => ActionItem;
6
7
  declare const HoverCardContent: React.FC<HoverCardContentProps>;
7
8
  export default HoverCardContent;
@@ -5,7 +5,7 @@ import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
5
5
  import { CardState } from '@atlaskit/linking-common';
6
6
  import { CardProviderRenderers } from '@atlaskit/link-provider';
7
7
  import { AnalyticsHandler } from '../../utils/types';
8
- import { ReactElement } from 'react';
8
+ import { ReactElement, MouseEventHandler } from 'react';
9
9
  import { JsonLd } from 'json-ld-types';
10
10
  export interface HoverCardProps extends WithAnalyticsEventsProps {
11
11
  id?: string;
@@ -33,6 +33,8 @@ export declare type HoverCardContentProps = {
33
33
  onActionClick: (actionId: string) => void;
34
34
  onResolve: () => void;
35
35
  url: string;
36
+ onMouseEnter?: MouseEventHandler;
37
+ onMouseLeave?: MouseEventHandler;
36
38
  };
37
39
  export declare type SnippetOrPreviewProps = {
38
40
  data: JsonLd.Data.BaseData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.8.0",
3
+ "version": "23.8.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"