@atlaskit/media-card 72.0.0 → 73.1.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.
Files changed (157) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/cjs/actions.js +2 -2
  3. package/dist/cjs/errors.js +35 -11
  4. package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
  5. package/dist/cjs/files/cardImageView/index.js +1 -1
  6. package/dist/cjs/files/cardImageView/styled.js +1 -1
  7. package/dist/cjs/index.js +8 -8
  8. package/dist/cjs/root/card/cardAnalytics.js +2 -2
  9. package/dist/cjs/root/card/cardLoader.js +66 -124
  10. package/dist/cjs/root/card/cardState.js +2 -2
  11. package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
  12. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
  13. package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
  14. package/dist/cjs/root/card/getCardPreview/index.js +101 -18
  15. package/dist/cjs/root/card/getCardStatus.js +1 -1
  16. package/dist/cjs/root/card/index.js +191 -97
  17. package/dist/cjs/root/cardView.js +44 -57
  18. package/dist/cjs/root/inline/loader.js +45 -14
  19. package/dist/cjs/root/inline/mediaInlineCard.js +31 -11
  20. package/dist/cjs/root/inlinePlayer.js +77 -24
  21. package/dist/cjs/root/styled.js +7 -3
  22. package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
  23. package/dist/cjs/root/ui/blanket/styled.js +1 -1
  24. package/dist/cjs/root/ui/common.js +11 -5
  25. package/dist/cjs/root/ui/iconMessage/index.js +5 -3
  26. package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
  27. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +6 -2
  28. package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
  29. package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
  30. package/dist/cjs/root/ui/playButton/styled.js +1 -1
  31. package/dist/cjs/root/ui/progressBar/progressBar.js +7 -4
  32. package/dist/cjs/root/ui/progressBar/styled.js +8 -9
  33. package/dist/cjs/root/ui/styled.js +80 -17
  34. package/dist/cjs/root/ui/tickBox/styled.js +1 -1
  35. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
  36. package/dist/cjs/root/ui/titleBox/styled.js +2 -4
  37. package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
  38. package/dist/cjs/styles/index.js +25 -23
  39. package/dist/cjs/styles/mixins.js +1 -1
  40. package/dist/cjs/utils/analytics.js +2 -1
  41. package/dist/cjs/utils/breakpoint.js +1 -1
  42. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +18 -9
  43. package/dist/cjs/utils/cardActions/index.js +10 -10
  44. package/dist/cjs/utils/cardActions/styled.js +1 -1
  45. package/dist/cjs/utils/cardDimensions.js +1 -1
  46. package/dist/cjs/utils/getErrorMessage.js +2 -2
  47. package/dist/cjs/utils/index.js +46 -46
  48. package/dist/cjs/utils/lightCards/styled.js +1 -1
  49. package/dist/cjs/utils/objectURLCache.js +1 -1
  50. package/dist/cjs/utils/viewportDetector.js +49 -22
  51. package/dist/cjs/version.json +1 -1
  52. package/dist/es2019/errors.js +9 -1
  53. package/dist/es2019/root/card/cardAnalytics.js +1 -1
  54. package/dist/es2019/root/card/cardLoader.js +47 -53
  55. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
  56. package/dist/es2019/root/card/getCardPreview/index.js +45 -3
  57. package/dist/es2019/root/card/index.js +131 -35
  58. package/dist/es2019/root/cardView.js +26 -40
  59. package/dist/es2019/root/inline/loader.js +15 -4
  60. package/dist/es2019/root/inline/mediaInlineCard.js +30 -10
  61. package/dist/es2019/root/inlinePlayer.js +56 -4
  62. package/dist/es2019/root/styled.js +2 -1
  63. package/dist/es2019/root/ui/common.js +7 -1
  64. package/dist/es2019/root/ui/iconMessage/index.js +3 -2
  65. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +6 -2
  66. package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  67. package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
  68. package/dist/es2019/root/ui/progressBar/progressBar.js +5 -3
  69. package/dist/es2019/root/ui/progressBar/styled.js +7 -6
  70. package/dist/es2019/root/ui/styled.js +65 -4
  71. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
  72. package/dist/es2019/root/ui/titleBox/styled.js +1 -2
  73. package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
  74. package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
  75. package/dist/es2019/utils/getErrorMessage.js +1 -1
  76. package/dist/es2019/utils/viewportDetector.js +48 -18
  77. package/dist/es2019/version.json +1 -1
  78. package/dist/esm/actions.js +2 -2
  79. package/dist/esm/errors.js +28 -9
  80. package/dist/esm/root/card/cardAnalytics.js +1 -1
  81. package/dist/esm/root/card/cardLoader.js +66 -126
  82. package/dist/esm/root/card/cardState.js +2 -2
  83. package/dist/esm/root/card/getCardPreview/cache.js +3 -2
  84. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
  85. package/dist/esm/root/card/getCardPreview/index.js +74 -12
  86. package/dist/esm/root/card/index.js +198 -100
  87. package/dist/esm/root/cardView.js +42 -54
  88. package/dist/esm/root/inline/loader.js +46 -14
  89. package/dist/esm/root/inline/mediaInlineCard.js +30 -10
  90. package/dist/esm/root/inlinePlayer.js +74 -23
  91. package/dist/esm/root/styled.js +3 -2
  92. package/dist/esm/root/ui/common.js +7 -1
  93. package/dist/esm/root/ui/iconMessage/index.js +3 -2
  94. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +6 -2
  95. package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  96. package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
  97. package/dist/esm/root/ui/progressBar/progressBar.js +6 -3
  98. package/dist/esm/root/ui/progressBar/styled.js +7 -7
  99. package/dist/esm/root/ui/styled.js +61 -13
  100. package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
  101. package/dist/esm/root/ui/titleBox/styled.js +1 -2
  102. package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
  103. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +17 -9
  104. package/dist/esm/utils/getErrorMessage.js +1 -1
  105. package/dist/esm/utils/viewportDetector.js +48 -21
  106. package/dist/esm/version.json +1 -1
  107. package/dist/types/errors.d.ts +9 -3
  108. package/dist/types/index.d.ts +3 -1
  109. package/dist/types/root/card/cardLoader.d.ts +5 -19
  110. package/dist/types/root/card/getCardPreview/index.d.ts +7 -1
  111. package/dist/types/root/card/index.d.ts +9 -8
  112. package/dist/types/root/cardView.d.ts +5 -3
  113. package/dist/types/root/inline/loader.d.ts +2 -0
  114. package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
  115. package/dist/types/root/inlinePlayer.d.ts +8 -1
  116. package/dist/types/root/styled.d.ts +1 -0
  117. package/dist/types/root/ui/common.d.ts +4 -1
  118. package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
  119. package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
  120. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +3 -2
  121. package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
  122. package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
  123. package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
  124. package/dist/types/root/ui/progressBar/progressBar.d.ts +4 -2
  125. package/dist/types/root/ui/progressBar/styled.d.ts +3 -2
  126. package/dist/types/root/ui/styled.d.ts +10 -3
  127. package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
  128. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -3
  129. package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
  130. package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
  131. package/dist/types/types.d.ts +1 -1
  132. package/dist/types/utils/getErrorMessage.d.ts +1 -0
  133. package/dist/types/utils/viewportDetector.d.ts +13 -5
  134. package/example-helpers/developmentUseMessage.tsx +14 -0
  135. package/example-helpers/index.tsx +34 -4
  136. package/example-helpers/selectableCard.tsx +2 -1
  137. package/package.json +16 -15
  138. package/dist/cjs/root/card/cardSSRView.js +0 -114
  139. package/dist/cjs/root/ui/Breakpoint.js +0 -13
  140. package/dist/cjs/root/ui/styledSSR.js +0 -108
  141. package/dist/cjs/utils/lazyContent/index.js +0 -56
  142. package/dist/cjs/utils/lazyContent/styled.js +0 -23
  143. package/dist/es2019/root/card/cardSSRView.js +0 -93
  144. package/dist/es2019/root/ui/Breakpoint.js +0 -6
  145. package/dist/es2019/root/ui/styledSSR.js +0 -93
  146. package/dist/es2019/utils/lazyContent/index.js +0 -18
  147. package/dist/es2019/utils/lazyContent/styled.js +0 -12
  148. package/dist/esm/root/card/cardSSRView.js +0 -92
  149. package/dist/esm/root/ui/Breakpoint.js +0 -6
  150. package/dist/esm/root/ui/styledSSR.js +0 -76
  151. package/dist/esm/utils/lazyContent/index.js +0 -41
  152. package/dist/esm/utils/lazyContent/styled.js +0 -14
  153. package/dist/types/root/card/cardSSRView.d.ts +0 -13
  154. package/dist/types/root/ui/Breakpoint.d.ts +0 -4
  155. package/dist/types/root/ui/styledSSR.d.ts +0 -16
  156. package/dist/types/utils/lazyContent/index.d.ts +0 -11
  157. package/dist/types/utils/lazyContent/styled.d.ts +0 -5
@@ -6,9 +6,9 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
 
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
9
+ 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; }
10
10
 
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
11
+ 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; }
12
12
 
13
13
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
14
 
@@ -28,8 +28,7 @@ import { createAndFireMediaCardEvent } from '../utils/analytics';
28
28
  import { attachDetailsToActions } from '../actions';
29
29
  import { getErrorMessage } from '../utils/getErrorMessage';
30
30
  import { toHumanReadableMediaSize, messages } from '@atlaskit/media-ui';
31
- import { NewFileExperienceWrapper } from './ui/styled';
32
- import { CardImageContainer, calcBreakpointSize } from './ui/styledSSR';
31
+ import { NewFileExperienceWrapper, CardImageContainer, calcBreakpointSize } from './ui/styled';
33
32
  import { ImageRenderer } from './ui/imageRenderer/imageRenderer';
34
33
  import { TitleBox } from './ui/titleBox/titleBox';
35
34
  import { FailedTitleBox } from './ui/titleBox/failedTitleBox';
@@ -138,11 +137,9 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
138
137
  var shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
139
138
  var shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
140
139
  var isPlayButtonClickable = !!(_this.shouldRenderPlayButton() && disableOverlay);
141
- var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Make tooltip optional for media singles - images, videos.
142
- // Intention is to show full file name when it's truncate in titlebox,
143
- // and to hide it when no titlebox exists.
140
+ var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
144
141
 
145
- var shouldDisplayTooltip = !!name && !disableOverlay;
142
+ var shouldDisplayTooltip = !disableOverlay;
146
143
  return /*#__PURE__*/React.createElement(NewFileExperienceWrapper, {
147
144
  className: newFileExperienceClassName,
148
145
  "data-testid": testId || 'media-card-view',
@@ -270,40 +267,29 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
270
267
  });
271
268
 
272
269
  var iconMessage;
270
+ var customTitleMessage;
273
271
 
274
- if (!!metadata) {
275
- if (error) {
276
- var secondaryError = error.secondaryError;
277
-
278
- if (isRateLimitedError(secondaryError) || secondaryError && isPollingError(secondaryError)) {
279
- iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
280
- }
281
- } else if (!isZeroSize) {
282
- iconMessage = /*#__PURE__*/React.createElement(PreviewUnavailable, null);
283
- }
284
- } else if (!!disableOverlay) {
285
- iconMessage = /*#__PURE__*/React.createElement(FailedToLoad, null);
286
- }
287
-
288
- if (error && isUploadError(error)) {
289
- if (!disableOverlay) {
290
- return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
291
- renderFailedTitleBox: true,
292
- customTitleMessage: messages.failed_to_upload
293
- });
294
- }
272
+ var _ref4 = error || {},
273
+ secondaryError = _ref4.secondaryError;
295
274
 
296
- return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
297
- renderTitleBox: !metadata && !!name,
298
- iconMessage: /*#__PURE__*/React.createElement(FailedToUpload, null)
299
- });
275
+ if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
276
+ iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
277
+ } else if (isUploadError(error)) {
278
+ iconMessage = /*#__PURE__*/React.createElement(FailedToUpload, null);
279
+ customTitleMessage = messages.failed_to_upload;
280
+ } else if (!metadata) {
281
+ iconMessage = /*#__PURE__*/React.createElement(FailedToLoad, null);
282
+ } else {
283
+ iconMessage = /*#__PURE__*/React.createElement(PreviewUnavailable, null);
300
284
  }
301
285
 
302
286
  if (!disableOverlay) {
287
+ var renderFailedTitleBox = !name || !!customTitleMessage;
303
288
  return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
304
- renderTitleBox: !!name,
305
- renderFailedTitleBox: !metadata,
306
- iconMessage: iconMessage
289
+ renderTitleBox: !!name && !customTitleMessage,
290
+ renderFailedTitleBox: renderFailedTitleBox,
291
+ iconMessage: !renderFailedTitleBox ? iconMessage : undefined,
292
+ customTitleMessage: customTitleMessage
307
293
  });
308
294
  }
309
295
 
@@ -342,8 +328,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
342
328
  status = _this$props4.status,
343
329
  metadata = _this$props4.metadata;
344
330
 
345
- var _ref4 = metadata || {},
346
- name = _ref4.name;
331
+ var _ref5 = metadata || {},
332
+ name = _ref5.name;
347
333
 
348
334
  var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
349
335
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardImageContainer, {
@@ -368,8 +354,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
368
354
  }
369
355
  }, {
370
356
  key: "componentDidUpdate",
371
- value: function componentDidUpdate(_ref5) {
372
- var prevDataURI = _ref5.dataURI;
357
+ value: function componentDidUpdate(_ref6) {
358
+ var prevDataURI = _ref6.dataURI;
373
359
  var dataURI = this.props.dataURI; // We should only switch didImageRender to false
374
360
  // when dataURI goes undefined, not when it is updated.
375
361
  // as this method could be triggered after onImageLoad callback,
@@ -390,10 +376,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
390
376
  return elementWidth;
391
377
  }
392
378
 
393
- var _ref6 = this.props.dimensions || {
379
+ var _ref7 = this.props.dimensions || {
394
380
  width: undefined
395
381
  },
396
- width = _ref6.width;
382
+ width = _ref7.width;
397
383
 
398
384
  if (!width) {
399
385
  return defaultImageCardDimensions.width;
@@ -450,8 +436,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
450
436
  metadata = _this$props6.metadata,
451
437
  dataURI = _this$props6.dataURI;
452
438
 
453
- var _ref7 = metadata || {},
454
- mediaType = _ref7.mediaType;
439
+ var _ref8 = metadata || {},
440
+ mediaType = _ref8.mediaType;
455
441
 
456
442
  if (mediaType !== 'video' || !dataURI) {
457
443
  return false;
@@ -484,9 +470,9 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
484
470
  titleBoxBgColor = _this$props7.titleBoxBgColor,
485
471
  titleBoxIcon = _this$props7.titleBoxIcon;
486
472
 
487
- var _ref8 = metadata || {},
488
- name = _ref8.name,
489
- createdAt = _ref8.createdAt;
473
+ var _ref9 = metadata || {},
474
+ name = _ref9.name,
475
+ createdAt = _ref9.createdAt;
490
476
 
491
477
  return !!name && /*#__PURE__*/React.createElement(TitleBox, {
492
478
  name: name,
@@ -527,17 +513,19 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
527
513
  alt = _this$props8.alt,
528
514
  resizeMode = _this$props8.resizeMode,
529
515
  onDisplayImage = _this$props8.onDisplayImage,
530
- mediaItemType = _this$props8.mediaItemType;
516
+ nativeLazyLoad = _this$props8.nativeLazyLoad,
517
+ forceSyncDisplay = _this$props8.forceSyncDisplay;
531
518
  return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
532
519
  dataURI: dataURI,
533
520
  mediaType: mediaType,
534
- mediaItemType: mediaItemType,
535
521
  previewOrientation: previewOrientation,
536
522
  alt: alt,
537
523
  resizeMode: resizeMode,
538
524
  onDisplayImage: onDisplayImage,
539
525
  onImageLoad: this.onImageLoad,
540
- onImageError: this.onImageError
526
+ onImageError: this.onImageError,
527
+ nativeLazyLoad: nativeLazyLoad,
528
+ forceSyncDisplay: forceSyncDisplay
541
529
  });
542
530
  }
543
531
  }, {
@@ -553,10 +541,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
553
541
  value: function renderMediaTypeIcon(hasTitleBox, iconMessage) {
554
542
  var metadata = this.props.metadata;
555
543
 
556
- var _ref9 = metadata || {},
557
- mediaType = _ref9.mediaType,
558
- mimeType = _ref9.mimeType,
559
- name = _ref9.name;
544
+ var _ref10 = metadata || {},
545
+ mediaType = _ref10.mediaType,
546
+ mimeType = _ref10.mimeType,
547
+ name = _ref10.name;
560
548
 
561
549
  return /*#__PURE__*/React.createElement(IconWrapper, {
562
550
  breakpoint: this.breakpoint,
@@ -32,6 +32,8 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
32
32
 
33
33
  _this = _super.call.apply(_super, [this].concat(args));
34
34
 
35
+ _defineProperty(_assertThisInitialized(_this), "isMounted", false);
36
+
35
37
  _defineProperty(_assertThisInitialized(_this), "state", {
36
38
  MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
37
39
  ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
@@ -50,13 +52,15 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
50
52
  while (1) {
51
53
  switch (_context.prev = _context.next) {
52
54
  case 0:
55
+ this.isMounted = true;
56
+
53
57
  if (this.state.MediaInlineCard) {
54
- _context.next = 16;
58
+ _context.next = 17;
55
59
  break;
56
60
  }
57
61
 
58
- _context.prev = 1;
59
- _context.next = 4;
62
+ _context.prev = 2;
63
+ _context.next = 5;
60
64
  return Promise.all([import(
61
65
  /* webpackChunkName: "@atlaskit-internal_media-client" */
62
66
  '@atlaskit/media-client'), import(
@@ -65,7 +69,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
65
69
  /* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
66
70
  '../media-card-analytics-error-boundary')]);
67
71
 
68
- case 4:
72
+ case 5:
69
73
  _yield$Promise$all = _context.sent;
70
74
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
71
75
  mediaClient = _yield$Promise$all2[0];
@@ -73,23 +77,27 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
73
77
  mediaCardErrorBoundaryModule = _yield$Promise$all2[2];
74
78
  MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
75
79
  MediaInlineCardLoader.ErrorBoundary = mediaCardErrorBoundaryModule.default;
76
- this.setState({
77
- MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
78
- ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
79
- });
80
- _context.next = 16;
80
+
81
+ if (this.isMounted) {
82
+ this.setState({
83
+ MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
84
+ ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
85
+ });
86
+ }
87
+
88
+ _context.next = 17;
81
89
  break;
82
90
 
83
- case 14:
84
- _context.prev = 14;
85
- _context.t0 = _context["catch"](1);
91
+ case 15:
92
+ _context.prev = 15;
93
+ _context.t0 = _context["catch"](2);
86
94
 
87
- case 16:
95
+ case 17:
88
96
  case "end":
89
97
  return _context.stop();
90
98
  }
91
99
  }
92
- }, _callee, this, [[1, 14]]);
100
+ }, _callee, this, [[2, 15]]);
93
101
  }));
94
102
 
95
103
  function componentDidMount() {
@@ -98,6 +106,30 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
98
106
 
99
107
  return componentDidMount;
100
108
  }()
109
+ }, {
110
+ key: "componentWillUnmount",
111
+ value: function () {
112
+ var _componentWillUnmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
113
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
114
+ while (1) {
115
+ switch (_context2.prev = _context2.next) {
116
+ case 0:
117
+ this.isMounted = false;
118
+
119
+ case 1:
120
+ case "end":
121
+ return _context2.stop();
122
+ }
123
+ }
124
+ }, _callee2, this);
125
+ }));
126
+
127
+ function componentWillUnmount() {
128
+ return _componentWillUnmount.apply(this, arguments);
129
+ }
130
+
131
+ return componentWillUnmount;
132
+ }()
101
133
  }, {
102
134
  key: "render",
103
135
  value: function render() {
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
- import { injectIntl } from 'react-intl';
4
+ import { injectIntl, IntlProvider, createIntl } from 'react-intl-next';
5
5
  import { MediaInlineCardLoadedView, MediaInlineCardLoadingView, MediaInlineCardErroredView, messages } from '@atlaskit/media-ui';
6
6
  import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
7
7
  import { MediaViewer } from '@atlaskit/media-viewer';
@@ -63,46 +63,64 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
63
63
  return null;
64
64
  };
65
65
 
66
+ var renderContent = function renderContent(children) {
67
+ return intl ? children : /*#__PURE__*/React.createElement(IntlProvider, {
68
+ locale: "en"
69
+ }, children);
70
+ };
71
+
72
+ var defaultIntl = createIntl({
73
+ locale: 'en'
74
+ });
66
75
  useEffect(function () {
67
- mediaClient.file.getFileState(identifier.id, {
76
+ var subscription = mediaClient.file.getFileState(identifier.id, {
68
77
  collectionName: identifier.collectionName
69
78
  }).subscribe({
70
79
  next: function next(fileState) {
71
80
  setFileState(fileState);
81
+ setIsErrored(false);
72
82
  },
73
83
  error: function error() {
74
84
  setIsErrored(true);
75
85
  }
76
86
  });
87
+ return function () {
88
+ subscription.unsubscribe();
89
+ };
77
90
  }, [identifier.collectionName, identifier.id, mediaClient.file]);
78
91
 
79
92
  if (!fileState) {
80
93
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
81
- message: intl.formatMessage(messages.loading_file)
94
+ message: (intl || defaultIntl).formatMessage(messages.loading_file),
95
+ isSelected: isSelected
82
96
  });
83
97
  }
84
98
 
85
99
  if (isErrored) {
86
100
  return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
87
- message: intl.formatMessage(messages.couldnt_load_file)
101
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
102
+ isSelected: isSelected
88
103
  });
89
104
  }
90
105
 
91
106
  if (fileState.status === 'error') {
92
107
  return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
93
- message: fileState.message || ''
108
+ message: fileState.message || '',
109
+ isSelected: isSelected
94
110
  });
95
111
  }
96
112
 
97
113
  if (fileState.status === 'failed-processing') {
98
114
  return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
99
- message: intl.formatMessage(messages.couldnt_load_file)
115
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
116
+ isSelected: isSelected
100
117
  });
101
118
  }
102
119
 
103
120
  if (fileState.status === 'uploading') {
104
121
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
105
- message: fileState.name
122
+ message: fileState.name,
123
+ isSelected: isSelected
106
124
  });
107
125
  }
108
126
 
@@ -126,7 +144,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
126
144
  formattedDate = formatDate(fileState.createdAt, locale);
127
145
  }
128
146
 
129
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
147
+ return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
130
148
  position: "bottom",
131
149
  content: formattedDate,
132
150
  tag: "span"
@@ -135,6 +153,8 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
135
153
  title: name,
136
154
  onClick: onMediaInlineCardClick,
137
155
  isSelected: isSelected
138
- })), mediaViewer);
156
+ })), mediaViewer));
139
157
  };
140
- export var MediaInlineCard = injectIntl(MediaInlineCardInternal);
158
+ export var MediaInlineCard = injectIntl(MediaInlineCardInternal, {
159
+ enforceContext: false
160
+ });
@@ -20,6 +20,10 @@ import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
20
20
  import { InlinePlayerWrapper } from './styled';
21
21
  import { defaultImageCardDimensions } from '..';
22
22
  import { CardLoading } from '../utils/lightCards/cardLoading';
23
+ import { ProgressBar } from './ui/progressBar/progressBar';
24
+ import { calcBreakpointSize } from './ui/styled';
25
+ import { isValidPercentageUnit } from '../utils/isValidPercentageUnit';
26
+ import { getElementDimension } from '../utils/getElementDimension';
23
27
  export var inlinePlayerClassName = 'media-card-inline-player';
24
28
  export var getPreferredVideoArtifact = function getPreferredVideoArtifact(fileState) {
25
29
  if (fileState.status === 'processed' || fileState.status === 'processing') {
@@ -52,6 +56,8 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
52
56
 
53
57
  _defineProperty(_assertThisInitialized(_this), "state", {});
54
58
 
59
+ _defineProperty(_assertThisInitialized(_this), "divRef", /*#__PURE__*/React.createRef());
60
+
55
61
  _defineProperty(_assertThisInitialized(_this), "setFileSrc", function (fileSrc) {
56
62
  _this.setState({
57
63
  fileSrc: fileSrc
@@ -126,6 +132,24 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
126
132
  });
127
133
  });
128
134
 
135
+ _defineProperty(_assertThisInitialized(_this), "saveElementWidth", function () {
136
+ var dimensions = _this.props.dimensions;
137
+
138
+ if (!dimensions) {
139
+ return;
140
+ }
141
+
142
+ var width = dimensions.width;
143
+
144
+ if (width && isValidPercentageUnit(width) && !!_this.divRef.current) {
145
+ var elementWidth = getElementDimension(_this.divRef.current, 'width');
146
+
147
+ _this.setState({
148
+ elementWidth: elementWidth
149
+ });
150
+ }
151
+ });
152
+
129
153
  return _this;
130
154
  }
131
155
 
@@ -134,6 +158,7 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
134
158
  value: function componentDidMount() {
135
159
  var _this2 = this;
136
160
 
161
+ this.saveElementWidth();
137
162
  var _this$props3 = this.props,
138
163
  mediaClient = _this$props3.mediaClient,
139
164
  identifier = _this$props3.identifier;
@@ -152,30 +177,41 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
152
177
  while (1) {
153
178
  switch (_context2.prev = _context2.next) {
154
179
  case 0:
180
+ if (fileState.status === 'uploading') {
181
+ _this2.setState({
182
+ isUploading: true,
183
+ progress: fileState.progress
184
+ });
185
+ } else {
186
+ _this2.setState({
187
+ isUploading: false
188
+ });
189
+ }
190
+
155
191
  existingFileSrc = _this2.state.fileSrc; // we want to reuse the existing fileSrc to prevent re renders
156
192
 
157
193
  if (!existingFileSrc) {
158
- _context2.next = 3;
194
+ _context2.next = 4;
159
195
  break;
160
196
  }
161
197
 
162
198
  return _context2.abrupt("return");
163
199
 
164
- case 3:
200
+ case 4:
165
201
  if (!(fileState.status !== 'error' && fileState.preview)) {
166
- _context2.next = 12;
202
+ _context2.next = 13;
167
203
  break;
168
204
  }
169
205
 
170
- _context2.next = 6;
206
+ _context2.next = 7;
171
207
  return fileState.preview;
172
208
 
173
- case 6:
209
+ case 7:
174
210
  _yield$fileState$prev = _context2.sent;
175
211
  value = _yield$fileState$prev.value;
176
212
 
177
213
  if (!(value instanceof Blob && value.type.indexOf('video/') === 0)) {
178
- _context2.next = 12;
214
+ _context2.next = 13;
179
215
  break;
180
216
  }
181
217
 
@@ -185,9 +221,9 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
185
221
 
186
222
  return _context2.abrupt("return");
187
223
 
188
- case 12:
224
+ case 13:
189
225
  if (!(fileState.status === 'processed' || fileState.status === 'processing')) {
190
- _context2.next = 29;
226
+ _context2.next = 30;
191
227
  break;
192
228
  }
193
229
 
@@ -195,7 +231,7 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
195
231
  artifacts = fileState.artifacts;
196
232
 
197
233
  if (!(!artifactName || !artifacts)) {
198
- _context2.next = 18;
234
+ _context2.next = 19;
199
235
  break;
200
236
  }
201
237
 
@@ -203,34 +239,34 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
203
239
 
204
240
  return _context2.abrupt("return");
205
241
 
206
- case 18:
207
- _context2.prev = 18;
208
- _context2.next = 21;
242
+ case 19:
243
+ _context2.prev = 19;
244
+ _context2.next = 22;
209
245
  return mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
210
246
 
211
- case 21:
247
+ case 22:
212
248
  _fileSrc = _context2.sent;
213
249
 
214
250
  _this2.setFileSrc(_fileSrc);
215
251
 
216
- _context2.next = 29;
252
+ _context2.next = 30;
217
253
  break;
218
254
 
219
- case 25:
220
- _context2.prev = 25;
221
- _context2.t0 = _context2["catch"](18);
255
+ case 26:
256
+ _context2.prev = 26;
257
+ _context2.t0 = _context2["catch"](19);
222
258
  onError = _this2.props.onError;
223
259
 
224
260
  if (onError) {
225
261
  onError(_context2.t0);
226
262
  }
227
263
 
228
- case 29:
264
+ case 30:
229
265
  case "end":
230
266
  return _context2.stop();
231
267
  }
232
268
  }
233
- }, _callee2, null, [[18, 25]]);
269
+ }, _callee2, null, [[19, 26]]);
234
270
  }));
235
271
 
236
272
  function next(_x) {
@@ -247,6 +283,12 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
247
283
  this.unsubscribe();
248
284
  this.revoke();
249
285
  }
286
+ }, {
287
+ key: "breakpoint",
288
+ get: function get() {
289
+ var width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || defaultImageCardDimensions.width;
290
+ return calcBreakpointSize(parseInt("".concat(width), 10));
291
+ }
250
292
  }, {
251
293
  key: "render",
252
294
  value: function render() {
@@ -259,8 +301,12 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
259
301
  selected = _this$props4.selected,
260
302
  testId = _this$props4.testId,
261
303
  identifier = _this$props4.identifier,
262
- forwardRef = _this$props4.forwardRef;
263
- var fileSrc = this.state.fileSrc;
304
+ forwardRef = _this$props4.forwardRef,
305
+ autoplay = _this$props4.autoplay;
306
+ var _this$state = this.state,
307
+ fileSrc = _this$state.fileSrc,
308
+ isUploading = _this$state.isUploading,
309
+ progress = _this$state.progress;
264
310
 
265
311
  if (!fileSrc) {
266
312
  return /*#__PURE__*/React.createElement(CardLoading, {
@@ -281,7 +327,7 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
281
327
  type: "video",
282
328
  src: fileSrc,
283
329
  fileId: identifier.id,
284
- isAutoPlay: true,
330
+ isAutoPlay: autoplay,
285
331
  isHDAvailable: false,
286
332
  onDownloadClick: _this3.onDownloadClick,
287
333
  onFirstPlay: _this3.onFirstPlay,
@@ -291,7 +337,12 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
291
337
  originalDimensions: originalDimensions,
292
338
  showControls: checkMouseMovement
293
339
  });
294
- }));
340
+ }), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
341
+ progress: progress,
342
+ breakpoint: this.breakpoint,
343
+ positionBottom: true,
344
+ showOnTop: true
345
+ }) : null);
295
346
  }
296
347
  }]);
297
348
 
@@ -1,6 +1,6 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
2
 
3
- var _templateObject, _templateObject2;
3
+ var _templateObject, _templateObject2, _templateObject3;
4
4
 
5
5
  import styled from 'styled-components';
6
6
  import { borderRadius } from '@atlaskit/theme/constants';
@@ -32,4 +32,5 @@ export var InlinePlayerWrapper = styled.div(_templateObject2 || (_templateObject
32
32
  }, function (props) {
33
33
  return getDimensionsWithDefault(props.dimensions).height || 'auto';
34
34
  }, borderRadius(), getSelectedBorderStyle);
35
- InlinePlayerWrapper.displayName = 'InlinePlayerWrapper';
35
+ InlinePlayerWrapper.displayName = 'InlinePlayerWrapper';
36
+ export var FormattedMessageWrapper = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
@@ -2,7 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
3
  var _responsiveSettings;
4
4
 
5
- import { Breakpoint } from './Breakpoint';
5
+ export var Breakpoint;
6
+
7
+ (function (Breakpoint) {
8
+ Breakpoint["SMALL"] = "small";
9
+ Breakpoint["LARGE"] = "large";
10
+ })(Breakpoint || (Breakpoint = {}));
11
+
6
12
  export var responsiveSettings = (_responsiveSettings = {}, _defineProperty(_responsiveSettings, Breakpoint.SMALL, {
7
13
  fontSize: 11,
8
14
  lineHeight: 14,
@@ -2,7 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import { IconMessageWrapper } from './styled';
4
4
  import { messages } from '@atlaskit/media-ui';
5
- import { FormattedMessage } from 'react-intl';
5
+ import { FormattedMessage } from 'react-intl-next';
6
+ import { FormattedMessageWrapper } from '../../styled';
6
7
  export var IconMessage = function IconMessage(_ref) {
7
8
  var messageDescriptor = _ref.messageDescriptor,
8
9
  _ref$animated = _ref.animated,
@@ -12,7 +13,7 @@ export var IconMessage = function IconMessage(_ref) {
12
13
  return /*#__PURE__*/React.createElement(IconMessageWrapper, {
13
14
  animated: animated,
14
15
  reducedFont: reducedFont
15
- }, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor));
16
+ }, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor)));
16
17
  };
17
18
  export var CreatingPreview = function CreatingPreview(_ref2) {
18
19
  var disableAnimation = _ref2.disableAnimation;