@atlaskit/smart-card 26.8.1 → 26.9.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,18 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`88cc5a0088c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/88cc5a0088c) - [ux] Flexible Smart Links: Hover preview to follow mouse position
8
+ - Updated dependencies
9
+
10
+ ## 26.9.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`7811ab546b9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7811ab546b9) - Cleans up FF platform.linking-platform.smart-card.enable-analytics-context introduced in 26.2.2 — resolved attributes now provided to all events fired within Smart Card by default.
15
+
3
16
  ## 26.8.1
4
17
 
5
18
  ### Patch Changes
@@ -12,7 +12,6 @@ var _reactDom = require("react-dom");
12
12
  var _analytics = require("../../analytics");
13
13
  var _helpers = require("../../helpers");
14
14
  var _linkingCommon = require("@atlaskit/linking-common");
15
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
15
  var _constants = require("../../actions/constants");
17
16
  var _jsonld = require("../../../utils/jsonld");
18
17
  var _constants2 = require("../../../constants");
@@ -120,19 +119,16 @@ var useResolve = function useResolve() {
120
119
  handleResolvedLinkError(resourceUrl, new _linkingCommon.APIError('error', hostname, _constants.ERROR_MESSAGE_METADATA), response, isMetadataRequest);
121
120
  return;
122
121
  }
123
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-analytics-context')) {
124
- /**
125
- * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
126
- * more info:
127
- * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
128
- * https://react-redux.js.org/api/batch
129
- */
130
- (0, _reactDom.unstable_batchedUpdates)(function () {
131
- handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
132
- });
133
- } else {
122
+
123
+ /**
124
+ * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
125
+ * more info:
126
+ * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
127
+ * https://react-redux.js.org/api/batch
128
+ */
129
+ (0, _reactDom.unstable_batchedUpdates)(function () {
134
130
  handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
135
- }
131
+ });
136
132
  }, [handleResolvedLinkError, handleResolvedLinkSuccess, hasAuthFlowSupported]);
137
133
  return (0, _react.useCallback)( /*#__PURE__*/function () {
138
134
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.8.1",
3
+ "version": "26.9.1",
4
4
  "sideEffects": false
5
5
  }
@@ -9,7 +9,6 @@ exports.CardWithUrlContent = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _analyticsNext = require("@atlaskit/analytics-next");
11
11
  var _linkProvider = require("@atlaskit/link-provider");
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
12
  var _utils = require("../../utils");
14
13
  var measure = _interopRequireWildcard(require("../../utils/performance"));
15
14
  var _helpers = require("../../state/helpers");
@@ -273,14 +272,11 @@ function Component(_ref) {
273
272
  }
274
273
  }
275
274
  var CardWithUrlContent = function CardWithUrlContent(props) {
276
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-analytics-context')) {
277
- var display = (0, _flexible.isFlexibleUiCard)(props.children) ? _constants.CardDisplay.Flexible : props.appearance;
278
- return /*#__PURE__*/_react.default.createElement(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
279
- url: props.url,
280
- id: props.id,
281
- display: display
282
- }, /*#__PURE__*/_react.default.createElement(Component, props));
283
- }
284
- return /*#__PURE__*/_react.default.createElement(Component, props);
275
+ var display = (0, _flexible.isFlexibleUiCard)(props.children) ? _constants.CardDisplay.Flexible : props.appearance;
276
+ return /*#__PURE__*/_react.default.createElement(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
277
+ url: props.url,
278
+ id: props.id,
279
+ display: display
280
+ }, /*#__PURE__*/_react.default.createElement(Component, props));
285
281
  };
286
282
  exports.CardWithUrlContent = CardWithUrlContent;
@@ -58,14 +58,14 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
58
58
  var _useSmartCardActions = (0, _actions.useSmartCardActions)(id, url, analytics),
59
59
  loadMetadata = _useSmartCardActions.loadMetadata;
60
60
  var setMousePosition = (0, _react2.useCallback)(function (event) {
61
- if (isOpen) {
61
+ if (isOpen && canOpen) {
62
62
  return;
63
63
  }
64
64
  mousePos.current = {
65
65
  x: event.clientX,
66
66
  y: event.clientY
67
67
  };
68
- }, [isOpen]);
68
+ }, [canOpen, isOpen]);
69
69
  var hideCard = (0, _react2.useCallback)(function () {
70
70
  setIsOpen(false);
71
71
  }, []);
@@ -131,20 +131,21 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
131
131
 
132
132
  //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
133
133
  setMousePosition(event);
134
+
135
+ //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
136
+ if ((!isOpen || !canOpen) && parentSpan.current && mousePos.current) {
137
+ var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
138
+ bottom = _parentSpan$current$g.bottom,
139
+ left = _parentSpan$current$g.left;
140
+ popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + _styled.CARD_GAP_PX];
141
+ }
134
142
  if (!isOpen && !fadeInTimeoutId.current) {
135
143
  // setting a timeout to show a Hover Card after delay runs out
136
144
  fadeInTimeoutId.current = setTimeout(function () {
137
- //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
138
- if (parentSpan.current && mousePos.current) {
139
- var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
140
- bottom = _parentSpan$current$g.bottom,
141
- left = _parentSpan$current$g.left;
142
- popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + _styled.CARD_GAP_PX];
143
- }
144
145
  setIsOpen(true);
145
146
  }, FADE_IN_DELAY);
146
147
  }
147
- }, [initResolve, isOpen, setMousePosition]);
148
+ }, [canOpen, initResolve, isOpen, setMousePosition]);
148
149
  var linkActions = (0, _useSmartLinkActions.useSmartLinkActions)({
149
150
  url: url,
150
151
  appearance: _constants.CardDisplay.HoverCardPreview,
@@ -163,7 +164,6 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
163
164
  }, [hideCard]);
164
165
 
165
166
  // Stop hover preview content to propagate event to parent.
166
-
167
167
  var onChildClick = (0, _react2.useCallback)(function (e) {
168
168
  e.stopPropagation();
169
169
  if (closeOnChildClick) {
@@ -3,7 +3,6 @@ import { unstable_batchedUpdates } from 'react-dom';
3
3
  import { addMetadataToExperience } from '../../analytics';
4
4
  import { getStatus } from '../../helpers';
5
5
  import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction } from '@atlaskit/linking-common';
6
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
6
  import { ERROR_MESSAGE_FATAL, ERROR_MESSAGE_METADATA, ERROR_MESSAGE_OAUTH } from '../../actions/constants';
8
7
  import { getUnauthorizedJsonLd } from '../../../utils/jsonld';
9
8
  import { SmartLinkStatus } from '../../../constants';
@@ -113,19 +112,16 @@ const useResolve = () => {
113
112
  handleResolvedLinkError(resourceUrl, new APIError('error', hostname, ERROR_MESSAGE_METADATA), response, isMetadataRequest);
114
113
  return;
115
114
  }
116
- if (getBooleanFF('platform.linking-platform.smart-card.enable-analytics-context')) {
117
- /**
118
- * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
119
- * more info:
120
- * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
121
- * https://react-redux.js.org/api/batch
122
- */
123
- unstable_batchedUpdates(() => {
124
- handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
125
- });
126
- } else {
115
+
116
+ /**
117
+ * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
118
+ * more info:
119
+ * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
120
+ * https://react-redux.js.org/api/batch
121
+ */
122
+ unstable_batchedUpdates(() => {
127
123
  handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
128
- }
124
+ });
129
125
  }, [handleResolvedLinkError, handleResolvedLinkSuccess, hasAuthFlowSupported]);
130
126
  return useCallback(async (url, isReloading = false, isMetadataRequest = false, id = '') => {
131
127
  const {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.8.1",
3
+ "version": "26.9.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect, useCallback, useMemo } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { useFeatureFlag } from '@atlaskit/link-provider';
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
4
  import { isSpecialEvent } from '../../utils';
6
5
  import * as measure from '../../utils/performance';
7
6
  import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
@@ -260,13 +259,10 @@ function Component({
260
259
  }
261
260
  }
262
261
  export const CardWithUrlContent = props => {
263
- if (getBooleanFF('platform.linking-platform.smart-card.enable-analytics-context')) {
264
- const display = isFlexibleUiCard(props.children) ? CardDisplay.Flexible : props.appearance;
265
- return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
266
- url: props.url,
267
- id: props.id,
268
- display: display
269
- }, /*#__PURE__*/React.createElement(Component, props));
270
- }
271
- return /*#__PURE__*/React.createElement(Component, props);
262
+ const display = isFlexibleUiCard(props.children) ? CardDisplay.Flexible : props.appearance;
263
+ return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
264
+ url: props.url,
265
+ id: props.id,
266
+ display: display
267
+ }, /*#__PURE__*/React.createElement(Component, props));
272
268
  };
@@ -40,14 +40,14 @@ export const HoverCardComponent = ({
40
40
  loadMetadata
41
41
  } = useSmartCardActions(id, url, analytics);
42
42
  const setMousePosition = useCallback(event => {
43
- if (isOpen) {
43
+ if (isOpen && canOpen) {
44
44
  return;
45
45
  }
46
46
  mousePos.current = {
47
47
  x: event.clientX,
48
48
  y: event.clientY
49
49
  };
50
- }, [isOpen]);
50
+ }, [canOpen, isOpen]);
51
51
  const hideCard = useCallback(() => {
52
52
  setIsOpen(false);
53
53
  }, []);
@@ -111,21 +111,22 @@ export const HoverCardComponent = ({
111
111
 
112
112
  //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
113
113
  setMousePosition(event);
114
+
115
+ //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
116
+ if ((!isOpen || !canOpen) && parentSpan.current && mousePos.current) {
117
+ const {
118
+ bottom,
119
+ left
120
+ } = parentSpan.current.getBoundingClientRect();
121
+ popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
122
+ }
114
123
  if (!isOpen && !fadeInTimeoutId.current) {
115
124
  // setting a timeout to show a Hover Card after delay runs out
116
125
  fadeInTimeoutId.current = setTimeout(() => {
117
- //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
118
- if (parentSpan.current && mousePos.current) {
119
- const {
120
- bottom,
121
- left
122
- } = parentSpan.current.getBoundingClientRect();
123
- popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
124
- }
125
126
  setIsOpen(true);
126
127
  }, FADE_IN_DELAY);
127
128
  }
128
- }, [initResolve, isOpen, setMousePosition]);
129
+ }, [canOpen, initResolve, isOpen, setMousePosition]);
129
130
  const linkActions = useSmartLinkActions({
130
131
  url,
131
132
  appearance: CardDisplay.HoverCardPreview,
@@ -142,7 +143,6 @@ export const HoverCardComponent = ({
142
143
  }, [hideCard]);
143
144
 
144
145
  // Stop hover preview content to propagate event to parent.
145
-
146
146
  const onChildClick = useCallback(e => {
147
147
  e.stopPropagation();
148
148
  if (closeOnChildClick) {
@@ -5,7 +5,6 @@ import { unstable_batchedUpdates } from 'react-dom';
5
5
  import { addMetadataToExperience } from '../../analytics';
6
6
  import { getStatus } from '../../helpers';
7
7
  import { ACTION_ERROR, ACTION_ERROR_FALLBACK, ACTION_RELOADING, ACTION_RESOLVED, ACTION_UPDATE_METADATA_STATUS, APIError, cardAction } from '@atlaskit/linking-common';
8
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
8
  import { ERROR_MESSAGE_FATAL, ERROR_MESSAGE_METADATA, ERROR_MESSAGE_OAUTH } from '../../actions/constants';
10
9
  import { getUnauthorizedJsonLd } from '../../../utils/jsonld';
11
10
  import { SmartLinkStatus } from '../../../constants';
@@ -113,19 +112,16 @@ var useResolve = function useResolve() {
113
112
  handleResolvedLinkError(resourceUrl, new APIError('error', hostname, ERROR_MESSAGE_METADATA), response, isMetadataRequest);
114
113
  return;
115
114
  }
116
- if (getBooleanFF('platform.linking-platform.smart-card.enable-analytics-context')) {
117
- /**
118
- * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
119
- * more info:
120
- * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
121
- * https://react-redux.js.org/api/batch
122
- */
123
- unstable_batchedUpdates(function () {
124
- handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
125
- });
126
- } else {
115
+
116
+ /**
117
+ * Using unstable_batchedUpdates because this store update happens async and trigers a rerender
118
+ * more info:
119
+ * https://github.com/facebook/react/blob/v18.2.0/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L113
120
+ * https://react-redux.js.org/api/batch
121
+ */
122
+ unstable_batchedUpdates(function () {
127
123
  handleResolvedLinkSuccess(resourceUrl, response, isReloading, isMetadataRequest);
128
- }
124
+ });
129
125
  }, [handleResolvedLinkError, handleResolvedLinkSuccess, hasAuthFlowSupported]);
130
126
  return useCallback( /*#__PURE__*/function () {
131
127
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.8.1",
3
+ "version": "26.9.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect, useCallback, useMemo } from 'react';
2
2
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
3
3
  import { useFeatureFlag } from '@atlaskit/link-provider';
4
- import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
4
  import { isSpecialEvent } from '../../utils';
6
5
  import * as measure from '../../utils/performance';
7
6
  import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct } from '../../state/helpers';
@@ -263,13 +262,10 @@ function Component(_ref) {
263
262
  }
264
263
  }
265
264
  export var CardWithUrlContent = function CardWithUrlContent(props) {
266
- if (getBooleanFF('platform.linking-platform.smart-card.enable-analytics-context')) {
267
- var display = isFlexibleUiCard(props.children) ? CardDisplay.Flexible : props.appearance;
268
- return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
269
- url: props.url,
270
- id: props.id,
271
- display: display
272
- }, /*#__PURE__*/React.createElement(Component, props));
273
- }
274
- return /*#__PURE__*/React.createElement(Component, props);
265
+ var display = isFlexibleUiCard(props.children) ? CardDisplay.Flexible : props.appearance;
266
+ return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
267
+ url: props.url,
268
+ id: props.id,
269
+ display: display
270
+ }, /*#__PURE__*/React.createElement(Component, props));
275
271
  };
@@ -47,14 +47,14 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
47
47
  var _useSmartCardActions = useSmartCardActions(id, url, analytics),
48
48
  loadMetadata = _useSmartCardActions.loadMetadata;
49
49
  var setMousePosition = useCallback(function (event) {
50
- if (isOpen) {
50
+ if (isOpen && canOpen) {
51
51
  return;
52
52
  }
53
53
  mousePos.current = {
54
54
  x: event.clientX,
55
55
  y: event.clientY
56
56
  };
57
- }, [isOpen]);
57
+ }, [canOpen, isOpen]);
58
58
  var hideCard = useCallback(function () {
59
59
  setIsOpen(false);
60
60
  }, []);
@@ -120,20 +120,21 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
120
120
 
121
121
  //Set mouse position in the case it's not already set by onMouseMove, as in the case of scrolling
122
122
  setMousePosition(event);
123
+
124
+ //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
125
+ if ((!isOpen || !canOpen) && parentSpan.current && mousePos.current) {
126
+ var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
127
+ bottom = _parentSpan$current$g.bottom,
128
+ left = _parentSpan$current$g.left;
129
+ popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
130
+ }
123
131
  if (!isOpen && !fadeInTimeoutId.current) {
124
132
  // setting a timeout to show a Hover Card after delay runs out
125
133
  fadeInTimeoutId.current = setTimeout(function () {
126
- //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
127
- if (parentSpan.current && mousePos.current) {
128
- var _parentSpan$current$g = parentSpan.current.getBoundingClientRect(),
129
- bottom = _parentSpan$current$g.bottom,
130
- left = _parentSpan$current$g.left;
131
- popupOffset.current = [mousePos.current.x - left, mousePos.current.y - bottom + CARD_GAP_PX];
132
- }
133
134
  setIsOpen(true);
134
135
  }, FADE_IN_DELAY);
135
136
  }
136
- }, [initResolve, isOpen, setMousePosition]);
137
+ }, [canOpen, initResolve, isOpen, setMousePosition]);
137
138
  var linkActions = useSmartLinkActions({
138
139
  url: url,
139
140
  appearance: CardDisplay.HoverCardPreview,
@@ -152,7 +153,6 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
152
153
  }, [hideCard]);
153
154
 
154
155
  // Stop hover preview content to propagate event to parent.
155
-
156
156
  var onChildClick = useCallback(function (e) {
157
157
  e.stopPropagation();
158
158
  if (closeOnChildClick) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.8.1",
3
+ "version": "26.9.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -42,9 +42,9 @@
42
42
  "@atlaskit/icon-object": "^6.3.0",
43
43
  "@atlaskit/icon-priority": "^6.3.0",
44
44
  "@atlaskit/in-product-testing": "^0.2.0",
45
- "@atlaskit/link-analytics": "^8.1.0",
45
+ "@atlaskit/link-analytics": "^8.2.0",
46
46
  "@atlaskit/link-client-extension": "^1.5.0",
47
- "@atlaskit/linking-common": "^3.1.0",
47
+ "@atlaskit/linking-common": "^3.2.0",
48
48
  "@atlaskit/linking-types": "^8.1.0",
49
49
  "@atlaskit/logo": "^13.14.0",
50
50
  "@atlaskit/lozenge": "^11.4.0",
@@ -138,9 +138,6 @@
138
138
  ".": "./src/index.ts"
139
139
  },
140
140
  "platform-feature-flags": {
141
- "platform.linking-platform.smart-card.enable-analytics-context": {
142
- "type": "boolean"
143
- },
144
141
  "platform.linking-platform.smart-card.remove-dispatch-analytics-as-prop": {
145
142
  "type": "boolean"
146
143
  },