@atlaskit/smart-card 26.5.14 → 26.5.16

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,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.5.16
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 26.5.15
10
+
11
+ ### Patch Changes
12
+
13
+ - [`7b2d54a82d0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7b2d54a82d0) - Cleans up a FF introduced in 26.3.3 & Fixes HoverCard component providing hover card analytics context to the wrapped trigger component
14
+
3
15
  ## 26.5.14
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.14",
3
+ "version": "26.5.16",
4
4
  "sideEffects": false
5
5
  }
@@ -7,9 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.HoverCardComponent = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
11
  var _popup = _interopRequireDefault(require("@atlaskit/popup"));
14
12
  var _react = require("@emotion/react");
15
13
  var _react2 = _interopRequireWildcard(require("react"));
@@ -22,15 +20,14 @@ var _constants = require("../../../constants");
22
20
  var _SmartLinkAnalyticsContext = require("../../../utils/analytics/SmartLinkAnalyticsContext");
23
21
  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); }
24
22
  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; }
25
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /** @jsx jsx */
23
+ /** @jsx jsx */
24
+
27
25
  var HOVER_CARD_SOURCE = 'smartLinkPreviewHoverCard';
28
26
  var HoverCardComponent = function HoverCardComponent(_ref) {
29
27
  var children = _ref.children,
30
28
  url = _ref.url,
31
29
  id = _ref.id,
32
30
  analyticsHandler = _ref.analyticsHandler,
33
- analytics = _ref.analytics,
34
31
  _ref$canOpen = _ref.canOpen,
35
32
  canOpen = _ref$canOpen === void 0 ? true : _ref$canOpen,
36
33
  _ref$closeOnChildClic = _ref.closeOnChildClick,
@@ -46,15 +43,11 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
46
43
  setIsOpen = _React$useState2[1];
47
44
  var fadeOutTimeoutId = (0, _react2.useRef)();
48
45
  var fadeInTimeoutId = (0, _react2.useRef)();
49
- var cardOpenTime = (0, _react2.useRef)();
50
46
  var mousePos = (0, _react2.useRef)();
51
47
  var popupOffset = (0, _react2.useRef)();
52
48
  var parentSpan = (0, _react2.useRef)(null);
53
49
  var renderers = (0, _renderers.useSmartLinkRenderers)();
54
50
  var linkState = (0, _store.useSmartCardState)(url);
55
- var linkStatus = linkState.status;
56
- var hoverDisplay = 'card';
57
- var invokeMethod = 'mouse_hover';
58
51
  var setMousePosition = (0, _react2.useCallback)(function (event) {
59
52
  if (isOpen) {
60
53
  return;
@@ -65,24 +58,8 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
65
58
  };
66
59
  }, [isOpen]);
67
60
  var hideCard = (0, _react2.useCallback)(function () {
68
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
69
- /**
70
- * Defer to inner HoverCardContent to fire this event
71
- */
72
- } else {
73
- //Check its previously open to avoid firing events when moving between the child and hover card components
74
- if (isOpen === true && cardOpenTime.current) {
75
- var hoverTime = Date.now() - cardOpenTime.current;
76
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.hoverCardDismissedEvent({
77
- previewDisplay: 'card',
78
- hoverTime: hoverTime,
79
- previewInvokeMethod: 'mouse_hover',
80
- status: linkStatus
81
- });
82
- }
83
- }
84
61
  setIsOpen(false);
85
- }, [analytics, isOpen, linkStatus]);
62
+ }, []);
86
63
  var initHideCard = (0, _react2.useCallback)(function () {
87
64
  if (fadeInTimeoutId.current) {
88
65
  clearTimeout(fadeInTimeoutId.current);
@@ -98,21 +75,6 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
98
75
  //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
99
76
  setMousePosition(event);
100
77
  fadeInTimeoutId.current = setTimeout(function () {
101
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
102
- /**
103
- * Defer to inner HoverCardContent to fire this event
104
- */
105
- } else {
106
- //Check if its previously closed to avoid firing events when moving between the child and hover card components
107
- if (isOpen === false) {
108
- cardOpenTime.current = Date.now();
109
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.hoverCardViewedEvent({
110
- previewDisplay: hoverDisplay,
111
- previewInvokeMethod: invokeMethod,
112
- status: linkStatus
113
- });
114
- }
115
- }
116
78
  //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
117
79
  if (parentSpan.current && mousePos.current) {
118
80
  var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
@@ -122,7 +84,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
122
84
  }
123
85
  setIsOpen(true);
124
86
  }, delay);
125
- }, [isOpen, setMousePosition, analytics, linkStatus]);
87
+ }, [setMousePosition]);
126
88
  var linkActions = (0, _useSmartLinkActions.useSmartLinkActions)({
127
89
  url: url,
128
90
  appearance: _constants.CardDisplay.HoverCardPreview,
@@ -150,7 +112,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
150
112
  }, [closeOnChildClick, hideCard]);
151
113
  var content = (0, _react2.useCallback)(function (_ref2) {
152
114
  var update = _ref2.update;
153
- var hoverCardContentProps = _objectSpread({
115
+ var hoverCardContentProps = {
154
116
  onMouseEnter: initShowCard,
155
117
  onMouseLeave: initHideCard,
156
118
  cardActions: filteredActions,
@@ -161,16 +123,14 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
161
123
  showServerActions: showServerActions,
162
124
  url: url,
163
125
  id: id
164
- }, (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? {} : {
165
- analytics: analytics
166
- });
167
- return (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-analytics-context') ? (0, _react.jsx)(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
126
+ };
127
+ return (0, _react.jsx)(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
168
128
  url: url,
169
129
  display: _constants.CardDisplay.HoverCardPreview,
170
130
  id: id,
171
131
  source: HOVER_CARD_SOURCE
172
- }, (0, _react.jsx)(_HoverCardContent.default, hoverCardContentProps)) : (0, _react.jsx)(_HoverCardContent.default, hoverCardContentProps);
173
- }, [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
132
+ }, (0, _react.jsx)(_HoverCardContent.default, hoverCardContentProps));
133
+ }, [initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
174
134
  var trigger = (0, _react2.useCallback)(function (triggerProps) {
175
135
  return (0, _react.jsx)("span", {
176
136
  ref: parentSpan
@@ -10,7 +10,6 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _react = require("@emotion/react");
12
12
  var _analyticsNext = require("@atlaskit/analytics-next");
13
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
13
  var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
15
14
  var _copy = _interopRequireDefault(require("@atlaskit/icon/glyph/copy"));
16
15
  var _react2 = _interopRequireWildcard(require("react"));
@@ -135,25 +134,23 @@ var HoverCardContent = function HoverCardContent(_ref) {
135
134
  }
136
135
  }, [analytics, linkStatus]);
137
136
  (0, _react2.useEffect)(function () {
138
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
139
- var previewDisplay = 'card';
140
- var previewInvokeMethod = 'mouse_hover';
141
- var cardOpenTime = Date.now();
142
- analyticsRef.current.ui.hoverCardViewedEvent({
137
+ var previewDisplay = 'card';
138
+ var previewInvokeMethod = 'mouse_hover';
139
+ var cardOpenTime = Date.now();
140
+ analyticsRef.current.ui.hoverCardViewedEvent({
141
+ previewDisplay: previewDisplay,
142
+ previewInvokeMethod: previewInvokeMethod,
143
+ status: statusRef.current
144
+ });
145
+ return function () {
146
+ var hoverTime = Date.now() - cardOpenTime;
147
+ analyticsRef.current.ui.hoverCardDismissedEvent({
143
148
  previewDisplay: previewDisplay,
144
149
  previewInvokeMethod: previewInvokeMethod,
150
+ hoverTime: hoverTime,
145
151
  status: statusRef.current
146
152
  });
147
- return function () {
148
- var hoverTime = Date.now() - cardOpenTime;
149
- analyticsRef.current.ui.hoverCardDismissedEvent({
150
- previewDisplay: previewDisplay,
151
- previewInvokeMethod: previewInvokeMethod,
152
- hoverTime: hoverTime,
153
- status: statusRef.current
154
- });
155
- };
156
- }
153
+ };
157
154
  }, []);
158
155
  var onClick = (0, _react2.useCallback)(function (event) {
159
156
  var isModifierKeyPressed = (0, _utils.isSpecialEvent)(event);
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.HoverCard = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
7
  var _analyticsNext = require("@atlaskit/analytics-next");
10
8
  var _react = require("@emotion/react");
11
9
  var _react2 = require("react");
12
10
  var _reactErrorBoundary = require("react-error-boundary");
13
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
11
  var _analytics = require("../../state/analytics");
15
- var _analytics2 = require("../../utils/analytics");
16
12
  var _HoverCardComponent = require("./components/HoverCardComponent");
17
13
  var _constants = require("../../constants");
18
14
  /** @jsx jsx */
@@ -20,16 +16,8 @@ var _constants = require("../../constants");
20
16
  var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
21
17
  var url = props.url,
22
18
  id = props.id,
23
- children = props.children,
24
- createAnalyticsEvent = props.createAnalyticsEvent;
25
- var analyticsHandler = (0, _react2.useCallback)(function (analyticsPayload) {
26
- (0, _analytics2.fireSmartLinkEvent)(analyticsPayload, createAnalyticsEvent);
27
- }, [createAnalyticsEvent]);
28
-
29
- /**
30
- * Feature flag disables prop drilling of analytics handlers
31
- */
32
- var analytics = (0, _analytics.useSmartLinkAnalytics)(url, (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? undefined : analyticsHandler, id);
19
+ children = props.children;
20
+ var analytics = (0, _analytics.useSmartLinkAnalytics)(url, undefined, id);
33
21
  var onError = (0, _react2.useCallback)(function (error, info) {
34
22
  analytics.ui.renderFailedEvent({
35
23
  display: _constants.CardDisplay.HoverCardPreview,
@@ -38,30 +26,13 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
38
26
  errorInfo: info
39
27
  });
40
28
  }, [analytics.ui, id]);
41
-
42
- /**
43
- * Feature flag disables the prop drilling of analytics handlers to hover card component
44
- */
45
- var analyticsProps = (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? {} : {
46
- analyticsHandler: analyticsHandler,
47
- analytics: analytics
48
- };
49
29
  return (0, _react.jsx)(_reactErrorBoundary.ErrorBoundary, {
50
30
  fallback: children,
51
31
  onError: onError
52
- }, (0, _react.jsx)(_HoverCardComponent.HoverCardComponent, (0, _extends2.default)({}, props, analyticsProps), children));
32
+ }, (0, _react.jsx)(_HoverCardComponent.HoverCardComponent, props, children));
53
33
  };
54
- var HoverCardWithAnalyticsContext = (0, _analyticsNext.withAnalyticsContext)({
55
- source: 'smartLinkPreviewHoverCard',
56
- attributes: {
57
- display: _constants.CardDisplay.HoverCardPreview
58
- }
59
- })((0, _analyticsNext.withAnalyticsEvents)()(HoverCardWithErrorBoundary));
60
34
  var HoverCardWithoutAnalyticsContext = (0, _analyticsNext.withAnalyticsEvents)()(HoverCardWithErrorBoundary);
61
35
  var HoverCard = function HoverCard(props) {
62
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
63
- return (0, _react.jsx)(HoverCardWithoutAnalyticsContext, props);
64
- }
65
- return (0, _react.jsx)(HoverCardWithAnalyticsContext, props);
36
+ return (0, _react.jsx)(HoverCardWithoutAnalyticsContext, props);
66
37
  };
67
38
  exports.HoverCard = HoverCard;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.14",
3
+ "version": "26.5.16",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
3
  import Popup from '@atlaskit/popup';
5
4
  import { jsx } from '@emotion/react';
6
5
  import React, { useCallback, useMemo, useRef } from 'react';
@@ -17,7 +16,6 @@ export const HoverCardComponent = ({
17
16
  url,
18
17
  id,
19
18
  analyticsHandler,
20
- analytics,
21
19
  canOpen = true,
22
20
  closeOnChildClick = false,
23
21
  hidePreviewButton = false,
@@ -27,15 +25,11 @@ export const HoverCardComponent = ({
27
25
  const [isOpen, setIsOpen] = React.useState(false);
28
26
  const fadeOutTimeoutId = useRef();
29
27
  const fadeInTimeoutId = useRef();
30
- const cardOpenTime = useRef();
31
28
  const mousePos = useRef();
32
29
  const popupOffset = useRef();
33
30
  const parentSpan = useRef(null);
34
31
  const renderers = useSmartLinkRenderers();
35
32
  const linkState = useLinkState(url);
36
- const linkStatus = linkState.status;
37
- const hoverDisplay = 'card';
38
- const invokeMethod = 'mouse_hover';
39
33
  const setMousePosition = useCallback(event => {
40
34
  if (isOpen) {
41
35
  return;
@@ -46,24 +40,8 @@ export const HoverCardComponent = ({
46
40
  };
47
41
  }, [isOpen]);
48
42
  const hideCard = useCallback(() => {
49
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
50
- /**
51
- * Defer to inner HoverCardContent to fire this event
52
- */
53
- } else {
54
- //Check its previously open to avoid firing events when moving between the child and hover card components
55
- if (isOpen === true && cardOpenTime.current) {
56
- const hoverTime = Date.now() - cardOpenTime.current;
57
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.hoverCardDismissedEvent({
58
- previewDisplay: 'card',
59
- hoverTime,
60
- previewInvokeMethod: 'mouse_hover',
61
- status: linkStatus
62
- });
63
- }
64
- }
65
43
  setIsOpen(false);
66
- }, [analytics, isOpen, linkStatus]);
44
+ }, []);
67
45
  const initHideCard = useCallback(() => {
68
46
  if (fadeInTimeoutId.current) {
69
47
  clearTimeout(fadeInTimeoutId.current);
@@ -77,21 +55,6 @@ export const HoverCardComponent = ({
77
55
  //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
78
56
  setMousePosition(event);
79
57
  fadeInTimeoutId.current = setTimeout(() => {
80
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
81
- /**
82
- * Defer to inner HoverCardContent to fire this event
83
- */
84
- } else {
85
- //Check if its previously closed to avoid firing events when moving between the child and hover card components
86
- if (isOpen === false) {
87
- cardOpenTime.current = Date.now();
88
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.hoverCardViewedEvent({
89
- previewDisplay: hoverDisplay,
90
- previewInvokeMethod: invokeMethod,
91
- status: linkStatus
92
- });
93
- }
94
- }
95
58
  //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
96
59
  if (parentSpan.current && mousePos.current) {
97
60
  const {
@@ -102,7 +65,7 @@ export const HoverCardComponent = ({
102
65
  }
103
66
  setIsOpen(true);
104
67
  }, delay);
105
- }, [isOpen, setMousePosition, analytics, linkStatus]);
68
+ }, [setMousePosition]);
106
69
  const linkActions = useSmartLinkActions({
107
70
  url,
108
71
  appearance: CardDisplay.HoverCardPreview,
@@ -139,18 +102,15 @@ export const HoverCardComponent = ({
139
102
  renderers,
140
103
  showServerActions,
141
104
  url,
142
- id,
143
- ...(getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? {} : {
144
- analytics
145
- })
105
+ id
146
106
  };
147
- return getBooleanFF('platform.linking-platform.smart-card.enable-analytics-context') ? jsx(SmartLinkAnalyticsContext, {
107
+ return jsx(SmartLinkAnalyticsContext, {
148
108
  url: url,
149
109
  display: CardDisplay.HoverCardPreview,
150
110
  id: id,
151
111
  source: HOVER_CARD_SOURCE
152
- }, jsx(HoverCardContent, hoverCardContentProps)) : jsx(HoverCardContent, hoverCardContentProps);
153
- }, [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
112
+ }, jsx(HoverCardContent, hoverCardContentProps));
113
+ }, [initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
154
114
  const trigger = useCallback(triggerProps => jsx("span", {
155
115
  ref: parentSpan
156
116
  }, jsx("span", _extends({}, triggerProps, {
@@ -1,7 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
4
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
6
5
  import CopyIcon from '@atlaskit/icon/glyph/copy';
7
6
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
@@ -94,25 +93,23 @@ const HoverCardContent = ({
94
93
  }
95
94
  }, [analytics, linkStatus]);
96
95
  useEffect(() => {
97
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
98
- const previewDisplay = 'card';
99
- const previewInvokeMethod = 'mouse_hover';
100
- const cardOpenTime = Date.now();
101
- analyticsRef.current.ui.hoverCardViewedEvent({
96
+ const previewDisplay = 'card';
97
+ const previewInvokeMethod = 'mouse_hover';
98
+ const cardOpenTime = Date.now();
99
+ analyticsRef.current.ui.hoverCardViewedEvent({
100
+ previewDisplay,
101
+ previewInvokeMethod,
102
+ status: statusRef.current
103
+ });
104
+ return () => {
105
+ const hoverTime = Date.now() - cardOpenTime;
106
+ analyticsRef.current.ui.hoverCardDismissedEvent({
102
107
  previewDisplay,
103
108
  previewInvokeMethod,
109
+ hoverTime,
104
110
  status: statusRef.current
105
111
  });
106
- return () => {
107
- const hoverTime = Date.now() - cardOpenTime;
108
- analyticsRef.current.ui.hoverCardDismissedEvent({
109
- previewDisplay,
110
- previewInvokeMethod,
111
- hoverTime,
112
- status: statusRef.current
113
- });
114
- };
115
- }
112
+ };
116
113
  }, []);
117
114
  const onClick = useCallback(event => {
118
115
  const isModifierKeyPressed = isSpecialEvent(event);
@@ -1,29 +1,18 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  /** @jsx jsx */
3
- import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
2
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
4
3
  import { jsx } from '@emotion/react';
5
4
  import { useCallback } from 'react';
6
5
  import { ErrorBoundary } from 'react-error-boundary';
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
6
  import { useSmartLinkAnalytics } from '../../state/analytics';
9
- import { fireSmartLinkEvent } from '../../utils/analytics';
10
7
  import { HoverCardComponent } from './components/HoverCardComponent';
11
8
  import { CardDisplay } from '../../constants';
12
9
  const HoverCardWithErrorBoundary = props => {
13
10
  const {
14
11
  url,
15
12
  id,
16
- children,
17
- createAnalyticsEvent
13
+ children
18
14
  } = props;
19
- const analyticsHandler = useCallback(analyticsPayload => {
20
- fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
21
- }, [createAnalyticsEvent]);
22
-
23
- /**
24
- * Feature flag disables prop drilling of analytics handlers
25
- */
26
- const analytics = useSmartLinkAnalytics(url, getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? undefined : analyticsHandler, id);
15
+ const analytics = useSmartLinkAnalytics(url, undefined, id);
27
16
  const onError = useCallback((error, info) => {
28
17
  analytics.ui.renderFailedEvent({
29
18
  display: CardDisplay.HoverCardPreview,
@@ -32,29 +21,12 @@ const HoverCardWithErrorBoundary = props => {
32
21
  errorInfo: info
33
22
  });
34
23
  }, [analytics.ui, id]);
35
-
36
- /**
37
- * Feature flag disables the prop drilling of analytics handlers to hover card component
38
- */
39
- const analyticsProps = getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? {} : {
40
- analyticsHandler,
41
- analytics
42
- };
43
24
  return jsx(ErrorBoundary, {
44
25
  fallback: children,
45
26
  onError: onError
46
- }, jsx(HoverCardComponent, _extends({}, props, analyticsProps), children));
27
+ }, jsx(HoverCardComponent, props, children));
47
28
  };
48
- const HoverCardWithAnalyticsContext = withAnalyticsContext({
49
- source: 'smartLinkPreviewHoverCard',
50
- attributes: {
51
- display: CardDisplay.HoverCardPreview
52
- }
53
- })(withAnalyticsEvents()(HoverCardWithErrorBoundary));
54
29
  const HoverCardWithoutAnalyticsContext = withAnalyticsEvents()(HoverCardWithErrorBoundary);
55
30
  export const HoverCard = props => {
56
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
57
- return jsx(HoverCardWithoutAnalyticsContext, props);
58
- }
59
- return jsx(HoverCardWithAnalyticsContext, props);
31
+ return jsx(HoverCardWithoutAnalyticsContext, props);
60
32
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.14",
3
+ "version": "26.5.16",
4
4
  "sideEffects": false
5
5
  }
@@ -1,10 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
3
  /** @jsx jsx */
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
4
  import Popup from '@atlaskit/popup';
9
5
  import { jsx } from '@emotion/react';
10
6
  import React, { useCallback, useMemo, useRef } from 'react';
@@ -21,7 +17,6 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
21
17
  url = _ref.url,
22
18
  id = _ref.id,
23
19
  analyticsHandler = _ref.analyticsHandler,
24
- analytics = _ref.analytics,
25
20
  _ref$canOpen = _ref.canOpen,
26
21
  canOpen = _ref$canOpen === void 0 ? true : _ref$canOpen,
27
22
  _ref$closeOnChildClic = _ref.closeOnChildClick,
@@ -37,15 +32,11 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
37
32
  setIsOpen = _React$useState2[1];
38
33
  var fadeOutTimeoutId = useRef();
39
34
  var fadeInTimeoutId = useRef();
40
- var cardOpenTime = useRef();
41
35
  var mousePos = useRef();
42
36
  var popupOffset = useRef();
43
37
  var parentSpan = useRef(null);
44
38
  var renderers = useSmartLinkRenderers();
45
39
  var linkState = useLinkState(url);
46
- var linkStatus = linkState.status;
47
- var hoverDisplay = 'card';
48
- var invokeMethod = 'mouse_hover';
49
40
  var setMousePosition = useCallback(function (event) {
50
41
  if (isOpen) {
51
42
  return;
@@ -56,24 +47,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
56
47
  };
57
48
  }, [isOpen]);
58
49
  var hideCard = useCallback(function () {
59
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
60
- /**
61
- * Defer to inner HoverCardContent to fire this event
62
- */
63
- } else {
64
- //Check its previously open to avoid firing events when moving between the child and hover card components
65
- if (isOpen === true && cardOpenTime.current) {
66
- var hoverTime = Date.now() - cardOpenTime.current;
67
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.hoverCardDismissedEvent({
68
- previewDisplay: 'card',
69
- hoverTime: hoverTime,
70
- previewInvokeMethod: 'mouse_hover',
71
- status: linkStatus
72
- });
73
- }
74
- }
75
50
  setIsOpen(false);
76
- }, [analytics, isOpen, linkStatus]);
51
+ }, []);
77
52
  var initHideCard = useCallback(function () {
78
53
  if (fadeInTimeoutId.current) {
79
54
  clearTimeout(fadeInTimeoutId.current);
@@ -89,21 +64,6 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
89
64
  //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
90
65
  setMousePosition(event);
91
66
  fadeInTimeoutId.current = setTimeout(function () {
92
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
93
- /**
94
- * Defer to inner HoverCardContent to fire this event
95
- */
96
- } else {
97
- //Check if its previously closed to avoid firing events when moving between the child and hover card components
98
- if (isOpen === false) {
99
- cardOpenTime.current = Date.now();
100
- analytics === null || analytics === void 0 ? void 0 : analytics.ui.hoverCardViewedEvent({
101
- previewDisplay: hoverDisplay,
102
- previewInvokeMethod: invokeMethod,
103
- status: linkStatus
104
- });
105
- }
106
- }
107
67
  //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
108
68
  if (parentSpan.current && mousePos.current) {
109
69
  var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
@@ -113,7 +73,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
113
73
  }
114
74
  setIsOpen(true);
115
75
  }, delay);
116
- }, [isOpen, setMousePosition, analytics, linkStatus]);
76
+ }, [setMousePosition]);
117
77
  var linkActions = useSmartLinkActions({
118
78
  url: url,
119
79
  appearance: CardDisplay.HoverCardPreview,
@@ -141,7 +101,7 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
141
101
  }, [closeOnChildClick, hideCard]);
142
102
  var content = useCallback(function (_ref2) {
143
103
  var update = _ref2.update;
144
- var hoverCardContentProps = _objectSpread({
104
+ var hoverCardContentProps = {
145
105
  onMouseEnter: initShowCard,
146
106
  onMouseLeave: initHideCard,
147
107
  cardActions: filteredActions,
@@ -152,16 +112,14 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
152
112
  showServerActions: showServerActions,
153
113
  url: url,
154
114
  id: id
155
- }, getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? {} : {
156
- analytics: analytics
157
- });
158
- return getBooleanFF('platform.linking-platform.smart-card.enable-analytics-context') ? jsx(SmartLinkAnalyticsContext, {
115
+ };
116
+ return jsx(SmartLinkAnalyticsContext, {
159
117
  url: url,
160
118
  display: CardDisplay.HoverCardPreview,
161
119
  id: id,
162
120
  source: HOVER_CARD_SOURCE
163
- }, jsx(HoverCardContent, hoverCardContentProps)) : jsx(HoverCardContent, hoverCardContentProps);
164
- }, [analytics, initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
121
+ }, jsx(HoverCardContent, hoverCardContentProps));
122
+ }, [initHideCard, initShowCard, filteredActions, linkState, onActionClick, renderers, showServerActions, url, id]);
165
123
  var trigger = useCallback(function (triggerProps) {
166
124
  return jsx("span", {
167
125
  ref: parentSpan
@@ -3,7 +3,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  /** @jsx jsx */
4
4
  import { jsx } from '@emotion/react';
5
5
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
6
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
8
7
  import CopyIcon from '@atlaskit/icon/glyph/copy';
9
8
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
@@ -121,25 +120,23 @@ var HoverCardContent = function HoverCardContent(_ref) {
121
120
  }
122
121
  }, [analytics, linkStatus]);
123
122
  useEffect(function () {
124
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
125
- var previewDisplay = 'card';
126
- var previewInvokeMethod = 'mouse_hover';
127
- var cardOpenTime = Date.now();
128
- analyticsRef.current.ui.hoverCardViewedEvent({
123
+ var previewDisplay = 'card';
124
+ var previewInvokeMethod = 'mouse_hover';
125
+ var cardOpenTime = Date.now();
126
+ analyticsRef.current.ui.hoverCardViewedEvent({
127
+ previewDisplay: previewDisplay,
128
+ previewInvokeMethod: previewInvokeMethod,
129
+ status: statusRef.current
130
+ });
131
+ return function () {
132
+ var hoverTime = Date.now() - cardOpenTime;
133
+ analyticsRef.current.ui.hoverCardDismissedEvent({
129
134
  previewDisplay: previewDisplay,
130
135
  previewInvokeMethod: previewInvokeMethod,
136
+ hoverTime: hoverTime,
131
137
  status: statusRef.current
132
138
  });
133
- return function () {
134
- var hoverTime = Date.now() - cardOpenTime;
135
- analyticsRef.current.ui.hoverCardDismissedEvent({
136
- previewDisplay: previewDisplay,
137
- previewInvokeMethod: previewInvokeMethod,
138
- hoverTime: hoverTime,
139
- status: statusRef.current
140
- });
141
- };
142
- }
139
+ };
143
140
  }, []);
144
141
  var onClick = useCallback(function (event) {
145
142
  var isModifierKeyPressed = isSpecialEvent(event);
@@ -1,27 +1,16 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  /** @jsx jsx */
3
- import { withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
2
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
4
3
  import { jsx } from '@emotion/react';
5
4
  import { useCallback } from 'react';
6
5
  import { ErrorBoundary } from 'react-error-boundary';
7
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
6
  import { useSmartLinkAnalytics } from '../../state/analytics';
9
- import { fireSmartLinkEvent } from '../../utils/analytics';
10
7
  import { HoverCardComponent } from './components/HoverCardComponent';
11
8
  import { CardDisplay } from '../../constants';
12
9
  var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
13
10
  var url = props.url,
14
11
  id = props.id,
15
- children = props.children,
16
- createAnalyticsEvent = props.createAnalyticsEvent;
17
- var analyticsHandler = useCallback(function (analyticsPayload) {
18
- fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
19
- }, [createAnalyticsEvent]);
20
-
21
- /**
22
- * Feature flag disables prop drilling of analytics handlers
23
- */
24
- var analytics = useSmartLinkAnalytics(url, getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? undefined : analyticsHandler, id);
12
+ children = props.children;
13
+ var analytics = useSmartLinkAnalytics(url, undefined, id);
25
14
  var onError = useCallback(function (error, info) {
26
15
  analytics.ui.renderFailedEvent({
27
16
  display: CardDisplay.HoverCardPreview,
@@ -30,29 +19,12 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
30
19
  errorInfo: info
31
20
  });
32
21
  }, [analytics.ui, id]);
33
-
34
- /**
35
- * Feature flag disables the prop drilling of analytics handlers to hover card component
36
- */
37
- var analyticsProps = getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics') ? {} : {
38
- analyticsHandler: analyticsHandler,
39
- analytics: analytics
40
- };
41
22
  return jsx(ErrorBoundary, {
42
23
  fallback: children,
43
24
  onError: onError
44
- }, jsx(HoverCardComponent, _extends({}, props, analyticsProps), children));
25
+ }, jsx(HoverCardComponent, props, children));
45
26
  };
46
- var HoverCardWithAnalyticsContext = withAnalyticsContext({
47
- source: 'smartLinkPreviewHoverCard',
48
- attributes: {
49
- display: CardDisplay.HoverCardPreview
50
- }
51
- })(withAnalyticsEvents()(HoverCardWithErrorBoundary));
52
27
  var HoverCardWithoutAnalyticsContext = withAnalyticsEvents()(HoverCardWithErrorBoundary);
53
28
  export var HoverCard = function HoverCard(props) {
54
- if (getBooleanFF('platform.linking-platform.smart-card.refactor-hover-card-analytics')) {
55
- return jsx(HoverCardWithoutAnalyticsContext, props);
56
- }
57
- return jsx(HoverCardWithAnalyticsContext, props);
29
+ return jsx(HoverCardWithoutAnalyticsContext, props);
58
30
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "ui" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "ui" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.14",
3
+ "version": "26.5.16",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,8 +34,8 @@
34
34
  "@atlaskit/analytics-next": "^9.1.0",
35
35
  "@atlaskit/avatar": "^21.3.0",
36
36
  "@atlaskit/avatar-group": "^9.3.0",
37
- "@atlaskit/button": "^16.7.0",
38
- "@atlaskit/dropdown-menu": "^11.9.0",
37
+ "@atlaskit/button": "^16.8.0",
38
+ "@atlaskit/dropdown-menu": "^11.10.0",
39
39
  "@atlaskit/frontend-utilities": "^2.7.0",
40
40
  "@atlaskit/icon": "^21.12.0",
41
41
  "@atlaskit/icon-file-type": "^6.4.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/in-product-testing": "^0.2.0",
45
45
  "@atlaskit/link-analytics": "^8.0.2",
46
46
  "@atlaskit/link-client-extension": "^1.2.1",
47
- "@atlaskit/linking-common": "^2.15.0",
47
+ "@atlaskit/linking-common": "^3.0.0",
48
48
  "@atlaskit/linking-types": "^6.0.0",
49
49
  "@atlaskit/logo": "^13.14.0",
50
50
  "@atlaskit/lozenge": "^11.4.0",
@@ -52,10 +52,10 @@
52
52
  "@atlaskit/modal-dialog": "^12.6.0",
53
53
  "@atlaskit/outbound-auth-flow-client": "^3.4.0",
54
54
  "@atlaskit/platform-feature-flags": "^0.2.1",
55
- "@atlaskit/popup": "^1.7.0",
55
+ "@atlaskit/popup": "^1.8.0",
56
56
  "@atlaskit/spinner": "^15.5.0",
57
57
  "@atlaskit/theme": "^12.5.0",
58
- "@atlaskit/tokens": "^1.6.0",
58
+ "@atlaskit/tokens": "^1.9.0",
59
59
  "@atlaskit/tooltip": "^17.8.0",
60
60
  "@atlaskit/ufo": "^0.2.0",
61
61
  "@babel/runtime": "^7.0.0",
@@ -141,9 +141,6 @@
141
141
  "platform.linking-platform.smart-card.enable-analytics-context": {
142
142
  "type": "boolean"
143
143
  },
144
- "platform.linking-platform.smart-card.refactor-hover-card-analytics": {
145
- "type": "boolean"
146
- },
147
144
  "platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop": {
148
145
  "type": "boolean"
149
146
  },