@atlaskit/media-card 77.10.12 → 77.11.0

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/cardView.js +2 -1
  4. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  5. package/dist/cjs/card/v2/cardV2.js +1 -1
  6. package/dist/cjs/card/v2/cardViewV2.js +2 -1
  7. package/dist/cjs/card/v2/cardviews/loadingCardView.js +2 -1
  8. package/dist/cjs/inline/loader.js +1 -1
  9. package/dist/cjs/utils/lightCards/cardLoading.js +3 -1
  10. package/dist/cjs/utils/ufoExperiences.js +1 -1
  11. package/dist/cjs/utils/viewportDetector.js +16 -4
  12. package/dist/es2019/card/card.js +1 -1
  13. package/dist/es2019/card/cardView.js +2 -1
  14. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  15. package/dist/es2019/card/v2/cardV2.js +1 -1
  16. package/dist/es2019/card/v2/cardViewV2.js +2 -1
  17. package/dist/es2019/card/v2/cardviews/loadingCardView.js +2 -1
  18. package/dist/es2019/inline/loader.js +1 -1
  19. package/dist/es2019/utils/lightCards/cardLoading.js +3 -1
  20. package/dist/es2019/utils/ufoExperiences.js +1 -1
  21. package/dist/es2019/utils/viewportDetector.js +13 -5
  22. package/dist/esm/card/card.js +1 -1
  23. package/dist/esm/card/cardView.js +2 -1
  24. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  25. package/dist/esm/card/v2/cardV2.js +1 -1
  26. package/dist/esm/card/v2/cardViewV2.js +2 -1
  27. package/dist/esm/card/v2/cardviews/loadingCardView.js +2 -1
  28. package/dist/esm/inline/loader.js +1 -1
  29. package/dist/esm/utils/lightCards/cardLoading.js +3 -1
  30. package/dist/esm/utils/ufoExperiences.js +1 -1
  31. package/dist/esm/utils/viewportDetector.js +17 -5
  32. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/media-card
2
2
 
3
+ ## 77.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#88895](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88895) [`a48b908e2bf6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a48b908e2bf6) - Add integration of React UFO to not hold react-ufo measurement when media is not in viewport
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 77.10.12
4
14
 
5
15
  ### Patch Changes
@@ -50,7 +50,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
50
50
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
51
51
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
52
52
  var packageName = "@atlaskit/media-card";
53
- var packageVersion = "77.10.12";
53
+ var packageVersion = "77.11.0";
54
54
  var CardBase = exports.CardBase = /*#__PURE__*/function (_Component) {
55
55
  (0, _inherits2.default)(CardBase, _Component);
56
56
  var _super = _createSuper(CardBase);
@@ -251,7 +251,8 @@ var CardViewBase = exports.CardViewBase = /*#__PURE__*/function (_React$Componen
251
251
  breakpoint: this.breakpoint,
252
252
  hasTitleBox: hasTitleBox
253
253
  }, (0, _react.jsx)(_spinner.default, {
254
- testId: 'media-card-loading'
254
+ testId: 'media-card-loading',
255
+ interactionName: 'media-card-loading'
255
256
  }));
256
257
  }
257
258
  }, {
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
90
90
  }(_react.default.Component);
91
91
  (0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
92
92
  var packageName = "@atlaskit/media-card";
93
- var packageVersion = "77.10.12";
93
+ var packageVersion = "77.11.0";
94
94
  var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
95
95
  packageVersion: packageVersion,
96
96
  packageName: packageName,
@@ -16,7 +16,7 @@ var _externalImageCard = require("./externalImageCard");
16
16
  var _fileCard = require("./fileCard");
17
17
  var _excluded = ["identifier"];
18
18
  var packageName = "@atlaskit/media-card";
19
- var packageVersion = "77.10.12";
19
+ var packageVersion = "77.11.0";
20
20
  var CardV2Base = exports.CardV2Base = function CardV2Base(_ref) {
21
21
  var identifier = _ref.identifier,
22
22
  otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -230,7 +230,8 @@ var CardViewV2Base = exports.CardViewV2Base = function CardViewV2Base(_ref) {
230
230
  breakpoint: breakpoint,
231
231
  hasTitleBox: hasTitleBox
232
232
  }, (0, _react.jsx)(_spinner.default, {
233
- testId: "media-card-loading"
233
+ testId: "media-card-loading",
234
+ interactionName: "media-card-loading"
234
235
  })), renderImageRenderer && !!cardPreview && (0, _react.jsx)(_imageRenderer.ImageRenderer, {
235
236
  cardPreview: cardPreview,
236
237
  mediaType: (metadata === null || metadata === void 0 ? void 0 : metadata.mediaType) || 'unknown',
@@ -37,7 +37,8 @@ var LoadingCardViewBase = function LoadingCardViewBase(props) {
37
37
  breakpoint: breakpoint,
38
38
  hasTitleBox: hasTitleBox
39
39
  }, (0, _react.jsx)(_spinner.default, {
40
- testId: "media-card-loading"
40
+ testId: "media-card-loading",
41
+ interactionName: "media-card-loading"
41
42
  })));
42
43
  };
43
44
 
@@ -119,7 +119,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
119
119
  ErrorBoundary = _this$state.ErrorBoundary;
120
120
  var analyticsContext = {
121
121
  packageVersion: "@atlaskit/media-card",
122
- packageName: "77.10.12",
122
+ packageName: "77.11.0",
123
123
  componentName: 'mediaInlineCard',
124
124
  component: 'mediaInlineCard'
125
125
  };
@@ -37,7 +37,9 @@ var CardLoading = exports.CardLoading = /*#__PURE__*/function (_Component) {
37
37
  "data-testid": testId || 'media-card-loading',
38
38
  "data-test-loading": true,
39
39
  dimensions: dimensions
40
- }, /*#__PURE__*/_react.default.createElement(_spinner.default, null));
40
+ }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
41
+ interactionName: "media-card-loading"
42
+ }));
41
43
  }
42
44
  }]);
43
45
  return CardLoading;
@@ -14,7 +14,7 @@ var _mediaClient = require("@atlaskit/media-client");
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var packageName = "@atlaskit/media-card";
17
- var packageVersion = "77.10.12";
17
+ var packageVersion = "77.11.0";
18
18
  var concurrentExperience;
19
19
  var getExperience = function getExperience(id) {
20
20
  if (!concurrentExperience) {
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.ViewportDetector = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
10
  var _react = _interopRequireWildcard(require("react"));
11
+ var _ufoInteractionIgnore = _interopRequireDefault(require("@atlaskit/ufo-interaction-ignore"));
10
12
  var _document = _interopRequireDefault(require("./document"));
11
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -39,15 +41,23 @@ var ViewportObserver = function ViewportObserver(_ref) {
39
41
  var onVisible = _ref.onVisible,
40
42
  cardEl = _ref.cardEl,
41
43
  children = _ref.children;
44
+ var _useState = (0, _react.useState)(false),
45
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
46
+ isVisible = _useState2[0],
47
+ setIsVisible = _useState2[1];
48
+ var onVisibleCallback = (0, _react.useCallback)(function () {
49
+ setIsVisible(true);
50
+ onVisible();
51
+ }, [onVisible]);
42
52
  (0, _react.useEffect)(function () {
43
53
  var intersectionObserver;
44
54
  try {
45
- intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
55
+ intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisibleCallback), {
46
56
  root: (0, _document.default)(),
47
57
  rootMargin: "".concat(ABS_VIEWPORT_ANCHOR_OFFSET_TOP, "px")
48
58
  });
49
59
  } catch (error) {
50
- intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
60
+ intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisibleCallback), {
51
61
  root: null,
52
62
  rootMargin: "".concat(ABS_VIEWPORT_ANCHOR_OFFSET_TOP, "px")
53
63
  });
@@ -56,8 +66,10 @@ var ViewportObserver = function ViewportObserver(_ref) {
56
66
  return function () {
57
67
  intersectionObserver.disconnect();
58
68
  };
59
- }, [cardEl, onVisible]);
60
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
69
+ }, [cardEl, onVisibleCallback]);
70
+ return /*#__PURE__*/_react.default.createElement(_ufoInteractionIgnore.default, {
71
+ ignore: !isVisible
72
+ }, children);
61
73
  };
62
74
  var ViewportDetector = exports.ViewportDetector = function ViewportDetector(_ref2) {
63
75
  var cardEl = _ref2.cardEl,
@@ -28,7 +28,7 @@ import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '.
28
28
  import { generateUniqueId } from '../utils/generateUniqueId';
29
29
  import { DateOverrideContext } from '../dateOverrideContext';
30
30
  const packageName = "@atlaskit/media-card";
31
- const packageVersion = "77.10.12";
31
+ const packageVersion = "77.11.0";
32
32
  export class CardBase extends Component {
33
33
  constructor(props) {
34
34
  super(props);
@@ -245,7 +245,8 @@ export class CardViewBase extends React.Component {
245
245
  breakpoint: this.breakpoint,
246
246
  hasTitleBox: hasTitleBox
247
247
  }, jsx(SpinnerIcon, {
248
- testId: 'media-card-loading'
248
+ testId: 'media-card-loading',
249
+ interactionName: 'media-card-loading'
249
250
  }));
250
251
  }
251
252
  shouldRenderPlayButton() {
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
66
66
  }
67
67
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
68
68
  const packageName = "@atlaskit/media-card";
69
- const packageVersion = "77.10.12";
69
+ const packageVersion = "77.11.0";
70
70
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
71
71
  packageVersion,
72
72
  packageName,
@@ -7,7 +7,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
7
7
  import { ExternalImageCard } from './externalImageCard';
8
8
  import { FileCard } from './fileCard';
9
9
  const packageName = "@atlaskit/media-card";
10
- const packageVersion = "77.10.12";
10
+ const packageVersion = "77.11.0";
11
11
  export const CardV2Base = ({
12
12
  identifier,
13
13
  ...otherProps
@@ -225,7 +225,8 @@ export const CardViewV2Base = ({
225
225
  breakpoint: breakpoint,
226
226
  hasTitleBox: hasTitleBox
227
227
  }, jsx(SpinnerIcon, {
228
- testId: "media-card-loading"
228
+ testId: "media-card-loading",
229
+ interactionName: "media-card-loading"
229
230
  })), renderImageRenderer && !!cardPreview && jsx(ImageRenderer, {
230
231
  cardPreview: cardPreview,
231
232
  mediaType: (metadata === null || metadata === void 0 ? void 0 : metadata.mediaType) || 'unknown',
@@ -32,7 +32,8 @@ const LoadingCardViewBase = props => {
32
32
  breakpoint: breakpoint,
33
33
  hasTitleBox: hasTitleBox
34
34
  }, jsx(SpinnerIcon, {
35
- testId: "media-card-loading"
35
+ testId: "media-card-loading",
36
+ interactionName: "media-card-loading"
36
37
  })));
37
38
  };
38
39
 
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
37
37
  } = this.state;
38
38
  const analyticsContext = {
39
39
  packageVersion: "@atlaskit/media-card",
40
- packageName: "77.10.12",
40
+ packageName: "77.11.0",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -14,6 +14,8 @@ export class CardLoading extends Component {
14
14
  "data-testid": testId || 'media-card-loading',
15
15
  "data-test-loading": true,
16
16
  dimensions: dimensions
17
- }, /*#__PURE__*/React.createElement(SpinnerIcon, null));
17
+ }, /*#__PURE__*/React.createElement(SpinnerIcon, {
18
+ interactionName: "media-card-loading"
19
+ }));
18
20
  }
19
21
  }
@@ -4,7 +4,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
4
4
  import { MediaCardError } from '../errors';
5
5
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
6
6
  const packageName = "@atlaskit/media-card";
7
- const packageVersion = "77.10.12";
7
+ const packageVersion = "77.11.0";
8
8
  let concurrentExperience;
9
9
  const getExperience = id => {
10
10
  if (!concurrentExperience) {
@@ -1,4 +1,5 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useCallback, useState } from 'react';
2
+ import UFOInteractionIgnore from '@atlaskit/ufo-interaction-ignore';
2
3
  import getDocument from './document';
3
4
  const ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
4
5
 
@@ -16,15 +17,20 @@ const ViewportObserver = ({
16
17
  cardEl,
17
18
  children
18
19
  }) => {
20
+ const [isVisible, setIsVisible] = useState(false);
21
+ const onVisibleCallback = useCallback(() => {
22
+ setIsVisible(true);
23
+ onVisible();
24
+ }, [onVisible]);
19
25
  useEffect(() => {
20
26
  let intersectionObserver;
21
27
  try {
22
- intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
28
+ intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisibleCallback), {
23
29
  root: getDocument(),
24
30
  rootMargin: `${ABS_VIEWPORT_ANCHOR_OFFSET_TOP}px`
25
31
  });
26
32
  } catch (error) {
27
- intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
33
+ intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisibleCallback), {
28
34
  root: null,
29
35
  rootMargin: `${ABS_VIEWPORT_ANCHOR_OFFSET_TOP}px`
30
36
  });
@@ -33,8 +39,10 @@ const ViewportObserver = ({
33
39
  return () => {
34
40
  intersectionObserver.disconnect();
35
41
  };
36
- }, [cardEl, onVisible]);
37
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
42
+ }, [cardEl, onVisibleCallback]);
43
+ return /*#__PURE__*/React.createElement(UFOInteractionIgnore, {
44
+ ignore: !isVisible
45
+ }, children);
38
46
  };
39
47
  export const ViewportDetector = ({
40
48
  cardEl,
@@ -41,7 +41,7 @@ import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '.
41
41
  import { generateUniqueId } from '../utils/generateUniqueId';
42
42
  import { DateOverrideContext } from '../dateOverrideContext';
43
43
  var packageName = "@atlaskit/media-card";
44
- var packageVersion = "77.10.12";
44
+ var packageVersion = "77.11.0";
45
45
  export var CardBase = /*#__PURE__*/function (_Component) {
46
46
  _inherits(CardBase, _Component);
47
47
  var _super = _createSuper(CardBase);
@@ -245,7 +245,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
245
245
  breakpoint: this.breakpoint,
246
246
  hasTitleBox: hasTitleBox
247
247
  }, jsx(SpinnerIcon, {
248
- testId: 'media-card-loading'
248
+ testId: 'media-card-loading',
249
+ interactionName: 'media-card-loading'
249
250
  }));
250
251
  }
251
252
  }, {
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
83
83
  }(React.Component);
84
84
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
85
85
  var packageName = "@atlaskit/media-card";
86
- var packageVersion = "77.10.12";
86
+ var packageVersion = "77.11.0";
87
87
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
88
88
  packageVersion: packageVersion,
89
89
  packageName: packageName,
@@ -9,7 +9,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
9
9
  import { ExternalImageCard } from './externalImageCard';
10
10
  import { FileCard } from './fileCard';
11
11
  var packageName = "@atlaskit/media-card";
12
- var packageVersion = "77.10.12";
12
+ var packageVersion = "77.11.0";
13
13
  export var CardV2Base = function CardV2Base(_ref) {
14
14
  var identifier = _ref.identifier,
15
15
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -221,7 +221,8 @@ export var CardViewV2Base = function CardViewV2Base(_ref) {
221
221
  breakpoint: breakpoint,
222
222
  hasTitleBox: hasTitleBox
223
223
  }, jsx(SpinnerIcon, {
224
- testId: "media-card-loading"
224
+ testId: "media-card-loading",
225
+ interactionName: "media-card-loading"
225
226
  })), renderImageRenderer && !!cardPreview && jsx(ImageRenderer, {
226
227
  cardPreview: cardPreview,
227
228
  mediaType: (metadata === null || metadata === void 0 ? void 0 : metadata.mediaType) || 'unknown',
@@ -29,7 +29,8 @@ var LoadingCardViewBase = function LoadingCardViewBase(props) {
29
29
  breakpoint: breakpoint,
30
30
  hasTitleBox: hasTitleBox
31
31
  }, jsx(SpinnerIcon, {
32
- testId: "media-card-loading"
32
+ testId: "media-card-loading",
33
+ interactionName: "media-card-loading"
33
34
  })));
34
35
  };
35
36
 
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
103
103
  ErrorBoundary = _this$state.ErrorBoundary;
104
104
  var analyticsContext = {
105
105
  packageVersion: "@atlaskit/media-card",
106
- packageName: "77.10.12",
106
+ packageName: "77.11.0",
107
107
  componentName: 'mediaInlineCard',
108
108
  component: 'mediaInlineCard'
109
109
  };
@@ -28,7 +28,9 @@ export var CardLoading = /*#__PURE__*/function (_Component) {
28
28
  "data-testid": testId || 'media-card-loading',
29
29
  "data-test-loading": true,
30
30
  dimensions: dimensions
31
- }, /*#__PURE__*/React.createElement(SpinnerIcon, null));
31
+ }, /*#__PURE__*/React.createElement(SpinnerIcon, {
32
+ interactionName: "media-card-loading"
33
+ }));
32
34
  }
33
35
  }]);
34
36
  return CardLoading;
@@ -7,7 +7,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
7
7
  import { MediaCardError } from '../errors';
8
8
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
9
9
  var packageName = "@atlaskit/media-card";
10
- var packageVersion = "77.10.12";
10
+ var packageVersion = "77.11.0";
11
11
  var concurrentExperience;
12
12
  var getExperience = function getExperience(id) {
13
13
  if (!concurrentExperience) {
@@ -1,7 +1,9 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
- import React, { useEffect } from 'react';
5
+ import React, { useEffect, useCallback, useState } from 'react';
6
+ import UFOInteractionIgnore from '@atlaskit/ufo-interaction-ignore';
5
7
  import getDocument from './document';
6
8
  var ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
7
9
 
@@ -29,15 +31,23 @@ var ViewportObserver = function ViewportObserver(_ref) {
29
31
  var onVisible = _ref.onVisible,
30
32
  cardEl = _ref.cardEl,
31
33
  children = _ref.children;
34
+ var _useState = useState(false),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ isVisible = _useState2[0],
37
+ setIsVisible = _useState2[1];
38
+ var onVisibleCallback = useCallback(function () {
39
+ setIsVisible(true);
40
+ onVisible();
41
+ }, [onVisible]);
32
42
  useEffect(function () {
33
43
  var intersectionObserver;
34
44
  try {
35
- intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
45
+ intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisibleCallback), {
36
46
  root: getDocument(),
37
47
  rootMargin: "".concat(ABS_VIEWPORT_ANCHOR_OFFSET_TOP, "px")
38
48
  });
39
49
  } catch (error) {
40
- intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible), {
50
+ intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisibleCallback), {
41
51
  root: null,
42
52
  rootMargin: "".concat(ABS_VIEWPORT_ANCHOR_OFFSET_TOP, "px")
43
53
  });
@@ -46,8 +56,10 @@ var ViewportObserver = function ViewportObserver(_ref) {
46
56
  return function () {
47
57
  intersectionObserver.disconnect();
48
58
  };
49
- }, [cardEl, onVisible]);
50
- return /*#__PURE__*/React.createElement(React.Fragment, null, children);
59
+ }, [cardEl, onVisibleCallback]);
60
+ return /*#__PURE__*/React.createElement(UFOInteractionIgnore, {
61
+ ignore: !isVisible
62
+ }, children);
51
63
  };
52
64
  export var ViewportDetector = function ViewportDetector(_ref2) {
53
65
  var cardEl = _ref2.cardEl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "77.10.12",
3
+ "version": "77.11.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -40,7 +40,7 @@
40
40
  "@atlaskit/dropdown-menu": "^12.8.0",
41
41
  "@atlaskit/editor-shared-styles": "^2.9.0",
42
42
  "@atlaskit/icon": "^22.1.0",
43
- "@atlaskit/media-client": "^26.2.0",
43
+ "@atlaskit/media-client": "^26.3.0",
44
44
  "@atlaskit/media-client-react": "^2.0.0",
45
45
  "@atlaskit/media-common": "^11.1.0",
46
46
  "@atlaskit/media-file-preview": "^0.5.0",
@@ -51,8 +51,9 @@
51
51
  "@atlaskit/spinner": "^16.0.0",
52
52
  "@atlaskit/theme": "^12.7.0",
53
53
  "@atlaskit/tokens": "^1.43.0",
54
- "@atlaskit/tooltip": "^18.1.0",
54
+ "@atlaskit/tooltip": "^18.2.0",
55
55
  "@atlaskit/ufo": "^0.2.0",
56
+ "@atlaskit/ufo-interaction-ignore": "^1.1.0",
56
57
  "@babel/runtime": "^7.0.0",
57
58
  "classnames": "^2.2.5",
58
59
  "eventemitter2": "^4.1.0",