@atlaskit/media-card 72.1.0 → 73.2.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 (165) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/cjs/actions.js +2 -2
  3. package/dist/cjs/errors.js +11 -7
  4. package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
  5. package/dist/cjs/files/cardImageView/index.js +52 -42
  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/cardState.js +2 -2
  10. package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
  11. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
  12. package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
  13. package/dist/cjs/root/card/getCardPreview/index.js +18 -9
  14. package/dist/cjs/root/card/getCardStatus.js +1 -1
  15. package/dist/cjs/root/card/index.js +279 -159
  16. package/dist/cjs/root/cardView.js +130 -118
  17. package/dist/cjs/root/inline/loader.js +45 -14
  18. package/dist/cjs/root/inline/mediaInlineCard.js +24 -9
  19. package/dist/cjs/root/inlinePlayer.js +80 -25
  20. package/dist/cjs/root/styled.js +7 -3
  21. package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
  22. package/dist/cjs/root/ui/blanket/styled.js +1 -1
  23. package/dist/cjs/root/ui/common.js +1 -1
  24. package/dist/cjs/root/ui/iconMessage/index.js +5 -3
  25. package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
  26. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
  27. package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +4 -2
  28. package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
  29. package/dist/cjs/root/ui/playButton/styled.js +1 -1
  30. package/dist/cjs/root/ui/progressBar/progressBar.js +5 -2
  31. package/dist/cjs/root/ui/progressBar/styled.js +7 -6
  32. package/dist/cjs/root/ui/styled.js +6 -6
  33. package/dist/cjs/root/ui/tickBox/styled.js +1 -1
  34. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
  35. package/dist/cjs/root/ui/titleBox/styled.js +1 -1
  36. package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
  37. package/dist/cjs/styles/index.js +25 -23
  38. package/dist/cjs/styles/mixins.js +1 -1
  39. package/dist/cjs/types.js +10 -1
  40. package/dist/cjs/utils/analytics.js +24 -7
  41. package/dist/cjs/utils/breakpoint.js +1 -1
  42. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +3 -1
  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/dimensionComparer.js +7 -13
  47. package/dist/cjs/utils/getErrorMessage.js +2 -2
  48. package/dist/cjs/utils/getMediaCardCursor.js +29 -0
  49. package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
  50. package/dist/cjs/utils/globalScope/globalScope.js +94 -0
  51. package/dist/cjs/utils/globalScope/index.js +39 -0
  52. package/dist/cjs/utils/globalScope/types.js +5 -0
  53. package/dist/cjs/utils/index.js +46 -46
  54. package/dist/cjs/utils/lightCards/styled.js +1 -1
  55. package/dist/cjs/utils/objectURLCache.js +1 -1
  56. package/dist/cjs/utils/printScript.js +44 -0
  57. package/dist/cjs/utils/viewportDetector.js +49 -22
  58. package/dist/cjs/version.json +1 -1
  59. package/dist/es2019/files/cardImageView/index.js +19 -5
  60. package/dist/es2019/root/card/cardAnalytics.js +1 -1
  61. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
  62. package/dist/es2019/root/card/getCardPreview/index.js +1 -0
  63. package/dist/es2019/root/card/index.js +150 -49
  64. package/dist/es2019/root/cardView.js +40 -30
  65. package/dist/es2019/root/inline/loader.js +15 -4
  66. package/dist/es2019/root/inline/mediaInlineCard.js +23 -8
  67. package/dist/es2019/root/inlinePlayer.js +59 -5
  68. package/dist/es2019/root/styled.js +2 -1
  69. package/dist/es2019/root/ui/iconMessage/index.js +3 -2
  70. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
  71. package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
  72. package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
  73. package/dist/es2019/root/ui/progressBar/progressBar.js +4 -2
  74. package/dist/es2019/root/ui/progressBar/styled.js +6 -4
  75. package/dist/es2019/root/ui/styled.js +5 -5
  76. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
  77. package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
  78. package/dist/es2019/types.js +7 -1
  79. package/dist/es2019/utils/analytics.js +8 -3
  80. package/dist/es2019/utils/dimensionComparer.js +6 -13
  81. package/dist/es2019/utils/getErrorMessage.js +1 -1
  82. package/dist/es2019/utils/getMediaCardCursor.js +19 -0
  83. package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
  84. package/dist/es2019/utils/globalScope/globalScope.js +62 -0
  85. package/dist/es2019/utils/globalScope/index.js +2 -0
  86. package/dist/es2019/utils/globalScope/types.js +1 -0
  87. package/dist/es2019/utils/printScript.js +19 -0
  88. package/dist/es2019/utils/viewportDetector.js +48 -18
  89. package/dist/es2019/version.json +1 -1
  90. package/dist/esm/actions.js +2 -2
  91. package/dist/esm/errors.js +6 -5
  92. package/dist/esm/files/cardImageView/index.js +53 -41
  93. package/dist/esm/root/card/cardAnalytics.js +1 -1
  94. package/dist/esm/root/card/cardState.js +2 -2
  95. package/dist/esm/root/card/getCardPreview/cache.js +3 -2
  96. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
  97. package/dist/esm/root/card/getCardPreview/index.js +5 -2
  98. package/dist/esm/root/card/index.js +266 -145
  99. package/dist/esm/root/cardView.js +128 -117
  100. package/dist/esm/root/inline/loader.js +46 -14
  101. package/dist/esm/root/inline/mediaInlineCard.js +23 -8
  102. package/dist/esm/root/inlinePlayer.js +77 -24
  103. package/dist/esm/root/styled.js +3 -2
  104. package/dist/esm/root/ui/iconMessage/index.js +3 -2
  105. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
  106. package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
  107. package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
  108. package/dist/esm/root/ui/progressBar/progressBar.js +5 -2
  109. package/dist/esm/root/ui/progressBar/styled.js +6 -5
  110. package/dist/esm/root/ui/styled.js +5 -5
  111. package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
  112. package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
  113. package/dist/esm/types.js +7 -1
  114. package/dist/esm/utils/analytics.js +17 -6
  115. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +2 -1
  116. package/dist/esm/utils/dimensionComparer.js +8 -13
  117. package/dist/esm/utils/getErrorMessage.js +1 -1
  118. package/dist/esm/utils/getMediaCardCursor.js +19 -0
  119. package/dist/esm/utils/globalScope/getSSRData.js +10 -0
  120. package/dist/esm/utils/globalScope/globalScope.js +69 -0
  121. package/dist/esm/utils/globalScope/index.js +2 -0
  122. package/dist/esm/utils/globalScope/types.js +1 -0
  123. package/dist/esm/utils/printScript.js +30 -0
  124. package/dist/esm/utils/viewportDetector.js +48 -21
  125. package/dist/esm/version.json +1 -1
  126. package/dist/types/errors.d.ts +1 -1
  127. package/dist/types/files/cardImageView/index.d.ts +6 -2
  128. package/dist/types/index.d.ts +1 -0
  129. package/dist/types/root/card/cardLoader.d.ts +2 -2
  130. package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
  131. package/dist/types/root/card/index.d.ts +10 -9
  132. package/dist/types/root/cardView.d.ts +10 -8
  133. package/dist/types/root/inline/loader.d.ts +2 -0
  134. package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
  135. package/dist/types/root/inlinePlayer.d.ts +10 -1
  136. package/dist/types/root/styled.d.ts +1 -0
  137. package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
  138. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +4 -4
  139. package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -0
  140. package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
  141. package/dist/types/root/ui/progressBar/progressBar.d.ts +3 -1
  142. package/dist/types/root/ui/progressBar/styled.d.ts +2 -1
  143. package/dist/types/root/ui/styled.d.ts +2 -1
  144. package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
  145. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -2
  146. package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -9
  147. package/dist/types/types.d.ts +6 -1
  148. package/dist/types/utils/analytics.d.ts +6 -0
  149. package/dist/types/utils/getErrorMessage.d.ts +1 -0
  150. package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
  151. package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
  152. package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
  153. package/dist/types/utils/globalScope/index.d.ts +4 -0
  154. package/dist/types/utils/globalScope/types.d.ts +8 -0
  155. package/dist/types/utils/printScript.d.ts +2 -0
  156. package/dist/types/utils/viewportDetector.d.ts +13 -5
  157. package/package.json +14 -16
  158. package/dist/cjs/utils/lazyContent/index.js +0 -56
  159. package/dist/cjs/utils/lazyContent/styled.js +0 -23
  160. package/dist/es2019/utils/lazyContent/index.js +0 -18
  161. package/dist/es2019/utils/lazyContent/styled.js +0 -12
  162. package/dist/esm/utils/lazyContent/index.js +0 -41
  163. package/dist/esm/utils/lazyContent/styled.js +0 -14
  164. package/dist/types/utils/lazyContent/index.d.ts +0 -11
  165. package/dist/types/utils/lazyContent/styled.d.ts +0 -5
@@ -30,6 +30,7 @@ import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUn
30
30
  import { isRateLimitedError, isPollingError } from '@atlaskit/media-client';
31
31
  import { newFileExperienceClassName } from './card/cardConstants';
32
32
  import { isUploadError } from '../errors';
33
+ import { MediaCardCursor } from '../types';
33
34
 
34
35
  /**
35
36
  * This is classic vanilla CardView class. To create an instance of class one would need to supply
@@ -45,32 +46,38 @@ export class CardViewBase extends React.Component {
45
46
 
46
47
  _defineProperty(this, "divRef", /*#__PURE__*/React.createRef());
47
48
 
48
- _defineProperty(this, "onImageLoad", () => {
49
+ _defineProperty(this, "onImageLoad", prevCardPreview => {
49
50
  const {
50
- onImageLoad
51
- } = this.props; // We render the icon & icon message always, even if there is dataURI available.
51
+ onImageLoad,
52
+ cardPreview
53
+ } = this.props;
54
+
55
+ if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
56
+ return;
57
+ } // We render the icon & icon message always, even if there is cardPreview available.
52
58
  // If the image fails to load/render, the icon will remain, i.e. the user won't see a change until
53
59
  // the root card decides to chage status to error.
54
60
  // If the image renders successfully, we switch this variable to hide the icon & icon message
55
61
  // behind the thumbnail in case the image has transparency.
56
- // It is less likely that root component replaces a suceeded dataURI for a failed one
62
+ // It is less likely that root component replaces a suceeded cardPreview for a failed one
57
63
  // than the opposite case. Therefore we prefer to hide the icon instead show when the image fails,
58
64
  // for a smoother transition
59
65
 
66
+
60
67
  this.setState({
61
68
  didImageRender: true
62
69
  });
63
- onImageLoad && onImageLoad();
70
+ onImageLoad && onImageLoad(cardPreview);
64
71
  });
65
72
 
66
- _defineProperty(this, "onImageError", () => {
73
+ _defineProperty(this, "onImageError", cardPreview => {
67
74
  const {
68
75
  onImageError
69
76
  } = this.props;
70
77
  this.setState({
71
78
  didImageRender: false
72
79
  });
73
- onImageError && onImageError();
80
+ onImageError && onImageError(cardPreview);
74
81
  });
75
82
 
76
83
  _defineProperty(this, "saveElementWidth", () => {
@@ -106,13 +113,13 @@ export class CardViewBase extends React.Component {
106
113
  selected,
107
114
  selectable,
108
115
  disableOverlay,
109
- dataURI
116
+ cardPreview,
117
+ mediaCardCursor
110
118
  } = this.props;
111
119
  const {
112
120
  name
113
121
  } = metadata || {};
114
- const shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
115
- const shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
122
+ const shouldDisplayBackground = !cardPreview || !disableOverlay || status === 'error' || status === 'failed-processing';
116
123
  const isPlayButtonClickable = !!(this.shouldRenderPlayButton() && disableOverlay);
117
124
  const isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
118
125
 
@@ -126,7 +133,7 @@ export class CardViewBase extends React.Component {
126
133
  onMouseEnter: onMouseEnter,
127
134
  innerRef: this.divRef,
128
135
  breakpoint: this.breakpoint,
129
- shouldUsePointerCursor: shouldUsePointerCursor,
136
+ mediaCardCursor: mediaCardCursor,
130
137
  disableOverlay: !!disableOverlay,
131
138
  selected: !!selected,
132
139
  displayBackground: shouldDisplayBackground,
@@ -142,21 +149,24 @@ export class CardViewBase extends React.Component {
142
149
 
143
150
  _defineProperty(this, "renderFile", () => {
144
151
  const {
152
+ cardPreview,
145
153
  status,
146
154
  mediaItemType,
147
155
  metadata,
148
- dataURI,
149
156
  progress,
150
157
  resizeMode,
151
158
  dimensions,
152
159
  selectable,
153
160
  selected,
154
161
  disableOverlay,
155
- previewOrientation,
156
162
  alt,
157
163
  onDisplayImage,
158
164
  actions
159
165
  } = this.props;
166
+ const {
167
+ dataURI,
168
+ orientation
169
+ } = cardPreview || {};
160
170
  const {
161
171
  name,
162
172
  mediaType,
@@ -183,16 +193,17 @@ export class CardViewBase extends React.Component {
183
193
  onDisplayImage: onDisplayImage,
184
194
  actions: actionsWithDetails,
185
195
  disableOverlay: disableOverlay,
186
- previewOrientation: previewOrientation,
196
+ previewOrientation: orientation,
187
197
  alt: alt,
188
198
  onImageLoad: this.onImageLoad,
189
- onImageError: this.onImageError
199
+ onImageError: this.onImageError,
200
+ cardPreview: cardPreview
190
201
  });
191
202
  });
192
203
 
193
204
  _defineProperty(this, "getRenderConfigByStatus", () => {
194
205
  const {
195
- dataURI,
206
+ cardPreview,
196
207
  status,
197
208
  metadata,
198
209
  disableOverlay,
@@ -210,8 +221,8 @@ export class CardViewBase extends React.Component {
210
221
  const isZeroSize = !!(metadata && metadata.size === 0);
211
222
  const defaultConfig = {
212
223
  renderTypeIcon: !didImageRender,
213
- renderImageRenderer: !!dataURI,
214
- renderPlayButton: !!dataURI && mediaType === 'video',
224
+ renderImageRenderer: !!cardPreview,
225
+ renderPlayButton: !!cardPreview && mediaType === 'video',
215
226
  renderBlanket: !disableOverlay,
216
227
  renderTitleBox: !disableOverlay && !!name,
217
228
  renderTickBox: !disableOverlay && !!selectable
@@ -330,16 +341,16 @@ export class CardViewBase extends React.Component {
330
341
  }
331
342
 
332
343
  componentDidUpdate({
333
- dataURI: prevDataURI
344
+ cardPreview: prevCardPreview
334
345
  }) {
335
346
  const {
336
- dataURI
347
+ cardPreview
337
348
  } = this.props; // We should only switch didImageRender to false
338
- // when dataURI goes undefined, not when it is updated.
349
+ // when cardPreview goes undefined, not when it is updated.
339
350
  // as this method could be triggered after onImageLoad callback,
340
351
  // falling on a race condition
341
352
 
342
- prevDataURI && !dataURI && this.setState({
353
+ !!prevCardPreview && !cardPreview && this.setState({
343
354
  didImageRender: false
344
355
  });
345
356
  }
@@ -413,13 +424,13 @@ export class CardViewBase extends React.Component {
413
424
  shouldRenderPlayButton() {
414
425
  const {
415
426
  metadata,
416
- dataURI
427
+ cardPreview
417
428
  } = this.props;
418
429
  const {
419
430
  mediaType
420
431
  } = metadata || {};
421
432
 
422
- if (mediaType !== 'video' || !dataURI) {
433
+ if (mediaType !== 'video' || !cardPreview) {
423
434
  return false;
424
435
  }
425
436
 
@@ -480,21 +491,19 @@ export class CardViewBase extends React.Component {
480
491
 
481
492
  renderImageRenderer() {
482
493
  const {
483
- dataURI,
494
+ cardPreview,
484
495
  metadata: {
485
496
  mediaType = 'unknown'
486
497
  } = {},
487
- previewOrientation,
488
498
  alt,
489
499
  resizeMode,
490
500
  onDisplayImage,
491
501
  nativeLazyLoad,
492
502
  forceSyncDisplay
493
503
  } = this.props;
494
- return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
495
- dataURI: dataURI,
504
+ return !!cardPreview && /*#__PURE__*/React.createElement(ImageRenderer, {
505
+ cardPreview: cardPreview,
496
506
  mediaType: mediaType,
497
- previewOrientation: previewOrientation,
498
507
  alt: alt,
499
508
  resizeMode: resizeMode,
500
509
  onDisplayImage: onDisplayImage,
@@ -554,7 +563,8 @@ export class CardViewBase extends React.Component {
554
563
  }
555
564
 
556
565
  _defineProperty(CardViewBase, "defaultProps", {
557
- appearance: 'auto'
566
+ appearance: 'auto',
567
+ mediaCardCursor: MediaCardCursor.NoAction
558
568
  });
559
569
 
560
570
  export const CardView = withAnalyticsEvents({
@@ -5,6 +5,8 @@ export default class MediaInlineCardLoader extends React.PureComponent {
5
5
  constructor(...args) {
6
6
  super(...args);
7
7
 
8
+ _defineProperty(this, "isMounted", false);
9
+
8
10
  _defineProperty(this, "state", {
9
11
  MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
10
12
  ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
@@ -12,6 +14,8 @@ export default class MediaInlineCardLoader extends React.PureComponent {
12
14
  }
13
15
 
14
16
  async componentDidMount() {
17
+ this.isMounted = true;
18
+
15
19
  if (!this.state.MediaInlineCard) {
16
20
  try {
17
21
  const [mediaClient, cardModule, mediaCardErrorBoundaryModule] = await Promise.all([import(
@@ -23,14 +27,21 @@ export default class MediaInlineCardLoader extends React.PureComponent {
23
27
  '../media-card-analytics-error-boundary')]);
24
28
  MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
25
29
  MediaInlineCardLoader.ErrorBoundary = mediaCardErrorBoundaryModule.default;
26
- this.setState({
27
- MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
28
- ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
29
- });
30
+
31
+ if (this.isMounted) {
32
+ this.setState({
33
+ MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
34
+ ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
35
+ });
36
+ }
30
37
  } catch (error) {}
31
38
  }
32
39
  }
33
40
 
41
+ async componentWillUnmount() {
42
+ this.isMounted = false;
43
+ }
44
+
34
45
  render() {
35
46
  const {
36
47
  MediaInlineCard,
@@ -1,6 +1,6 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
- import { injectIntl } from 'react-intl';
3
+ import { injectIntl, IntlProvider, createIntl } from 'react-intl-next';
4
4
  import { MediaInlineCardLoadedView, MediaInlineCardLoadingView, MediaInlineCardErroredView, messages } from '@atlaskit/media-ui';
5
5
  import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
6
6
  import { MediaViewer } from '@atlaskit/media-viewer';
@@ -49,29 +49,42 @@ export const MediaInlineCardInternal = ({
49
49
  return null;
50
50
  };
51
51
 
52
+ const renderContent = children => {
53
+ return intl ? children : /*#__PURE__*/React.createElement(IntlProvider, {
54
+ locale: "en"
55
+ }, children);
56
+ };
57
+
58
+ const defaultIntl = createIntl({
59
+ locale: 'en'
60
+ });
52
61
  useEffect(() => {
53
- mediaClient.file.getFileState(identifier.id, {
62
+ const subscription = mediaClient.file.getFileState(identifier.id, {
54
63
  collectionName: identifier.collectionName
55
64
  }).subscribe({
56
65
  next: fileState => {
57
66
  setFileState(fileState);
67
+ setIsErrored(false);
58
68
  },
59
69
  error: () => {
60
70
  setIsErrored(true);
61
71
  }
62
72
  });
73
+ return () => {
74
+ subscription.unsubscribe();
75
+ };
63
76
  }, [identifier.collectionName, identifier.id, mediaClient.file]);
64
77
 
65
78
  if (!fileState) {
66
79
  return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
67
- message: intl.formatMessage(messages.loading_file),
80
+ message: (intl || defaultIntl).formatMessage(messages.loading_file),
68
81
  isSelected: isSelected
69
82
  });
70
83
  }
71
84
 
72
85
  if (isErrored) {
73
86
  return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
74
- message: intl.formatMessage(messages.couldnt_load_file),
87
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
75
88
  isSelected: isSelected
76
89
  });
77
90
  }
@@ -85,7 +98,7 @@ export const MediaInlineCardInternal = ({
85
98
 
86
99
  if (fileState.status === 'failed-processing') {
87
100
  return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
88
- message: intl.formatMessage(messages.couldnt_load_file),
101
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
89
102
  isSelected: isSelected
90
103
  });
91
104
  }
@@ -118,7 +131,7 @@ export const MediaInlineCardInternal = ({
118
131
  formattedDate = formatDate(fileState.createdAt, locale);
119
132
  }
120
133
 
121
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
134
+ return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
122
135
  position: "bottom",
123
136
  content: formattedDate,
124
137
  tag: "span"
@@ -127,6 +140,8 @@ export const MediaInlineCardInternal = ({
127
140
  title: name,
128
141
  onClick: onMediaInlineCardClick,
129
142
  isSelected: isSelected
130
- })), mediaViewer);
143
+ })), mediaViewer));
131
144
  };
132
- export const MediaInlineCard = injectIntl(MediaInlineCardInternal);
145
+ export const MediaInlineCard = injectIntl(MediaInlineCardInternal, {
146
+ enforceContext: false
147
+ });
@@ -7,6 +7,10 @@ import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
7
7
  import { InlinePlayerWrapper } from './styled';
8
8
  import { defaultImageCardDimensions } from '..';
9
9
  import { CardLoading } from '../utils/lightCards/cardLoading';
10
+ import { ProgressBar } from './ui/progressBar/progressBar';
11
+ import { calcBreakpointSize } from './ui/styled';
12
+ import { isValidPercentageUnit } from '../utils/isValidPercentageUnit';
13
+ import { getElementDimension } from '../utils/getElementDimension';
10
14
  export const inlinePlayerClassName = 'media-card-inline-player';
11
15
  export const getPreferredVideoArtifact = fileState => {
12
16
  if (fileState.status === 'processed' || fileState.status === 'processing') {
@@ -29,6 +33,8 @@ export class InlinePlayerBase extends Component {
29
33
 
30
34
  _defineProperty(this, "state", {});
31
35
 
36
+ _defineProperty(this, "divRef", /*#__PURE__*/React.createRef());
37
+
32
38
  _defineProperty(this, "setFileSrc", fileSrc => {
33
39
  this.setState({
34
40
  fileSrc
@@ -93,9 +99,31 @@ export class InlinePlayerBase extends Component {
93
99
  viewingLevel: 'full'
94
100
  });
95
101
  });
102
+
103
+ _defineProperty(this, "saveElementWidth", () => {
104
+ const {
105
+ dimensions
106
+ } = this.props;
107
+
108
+ if (!dimensions) {
109
+ return;
110
+ }
111
+
112
+ const {
113
+ width
114
+ } = dimensions;
115
+
116
+ if (width && isValidPercentageUnit(width) && !!this.divRef.current) {
117
+ const elementWidth = getElementDimension(this.divRef.current, 'width');
118
+ this.setState({
119
+ elementWidth
120
+ });
121
+ }
122
+ });
96
123
  }
97
124
 
98
125
  componentDidMount() {
126
+ this.saveElementWidth();
99
127
  const {
100
128
  mediaClient,
101
129
  identifier
@@ -110,6 +138,17 @@ export class InlinePlayerBase extends Component {
110
138
  collectionName
111
139
  }).subscribe({
112
140
  next: async fileState => {
141
+ if (fileState.status === 'uploading') {
142
+ this.setState({
143
+ isUploading: true,
144
+ progress: fileState.progress
145
+ });
146
+ } else {
147
+ this.setState({
148
+ isUploading: false
149
+ });
150
+ }
151
+
113
152
  const {
114
153
  fileSrc: existingFileSrc
115
154
  } = this.state; // we want to reuse the existing fileSrc to prevent re renders
@@ -163,6 +202,11 @@ export class InlinePlayerBase extends Component {
163
202
  this.revoke();
164
203
  }
165
204
 
205
+ get breakpoint() {
206
+ const width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || defaultImageCardDimensions.width;
207
+ return calcBreakpointSize(parseInt(`${width}`, 10));
208
+ }
209
+
166
210
  render() {
167
211
  const {
168
212
  onClick,
@@ -171,10 +215,14 @@ export class InlinePlayerBase extends Component {
171
215
  selected,
172
216
  testId,
173
217
  identifier,
174
- forwardRef
218
+ forwardRef,
219
+ autoplay,
220
+ cardPreview
175
221
  } = this.props;
176
222
  const {
177
- fileSrc
223
+ fileSrc,
224
+ isUploading,
225
+ progress
178
226
  } = this.state;
179
227
 
180
228
  if (!fileSrc) {
@@ -195,7 +243,7 @@ export class InlinePlayerBase extends Component {
195
243
  type: "video",
196
244
  src: fileSrc,
197
245
  fileId: identifier.id,
198
- isAutoPlay: true,
246
+ isAutoPlay: autoplay,
199
247
  isHDAvailable: false,
200
248
  onDownloadClick: this.onDownloadClick,
201
249
  onFirstPlay: this.onFirstPlay,
@@ -203,8 +251,14 @@ export class InlinePlayerBase extends Component {
203
251
  contentId: identifier.id
204
252
  },
205
253
  originalDimensions: originalDimensions,
206
- showControls: checkMouseMovement
207
- })));
254
+ showControls: checkMouseMovement,
255
+ poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI
256
+ })), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
257
+ progress: progress,
258
+ breakpoint: this.breakpoint,
259
+ positionBottom: true,
260
+ showOnTop: true
261
+ }) : null);
208
262
  }
209
263
 
210
264
  }
@@ -42,4 +42,5 @@ export const InlinePlayerWrapper = styled.div`
42
42
  height: 100%;
43
43
  }
44
44
  `;
45
- InlinePlayerWrapper.displayName = 'InlinePlayerWrapper';
45
+ InlinePlayerWrapper.displayName = 'InlinePlayerWrapper';
46
+ export const FormattedMessageWrapper = styled.span``;
@@ -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 const IconMessage = ({
7
8
  messageDescriptor,
8
9
  animated = false,
@@ -11,7 +12,7 @@ export const IconMessage = ({
11
12
  return /*#__PURE__*/React.createElement(IconMessageWrapper, {
12
13
  animated: animated,
13
14
  reducedFont: reducedFont
14
- }, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor));
15
+ }, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messageDescriptor)));
15
16
  };
16
17
  export const CreatingPreview = ({
17
18
  disableAnimation
@@ -3,8 +3,7 @@ import React, { useEffect } from 'react';
3
3
  import { MediaImage } from '@atlaskit/media-ui';
4
4
  import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
5
5
  export const ImageRenderer = ({
6
- dataURI,
7
- previewOrientation,
6
+ cardPreview,
8
7
  alt,
9
8
  resizeMode,
10
9
  onImageLoad,
@@ -20,12 +19,21 @@ export const ImageRenderer = ({
20
19
  onDisplayImage();
21
20
  }
22
21
  }, [mediaType, onDisplayImage]);
22
+
23
+ const onLoad = () => {
24
+ onImageLoad && onImageLoad(cardPreview);
25
+ };
26
+
27
+ const onError = () => {
28
+ onImageError && onImageError(cardPreview);
29
+ };
30
+
23
31
  return /*#__PURE__*/React.createElement(MediaImage, _extends({
24
- dataURI: dataURI,
32
+ dataURI: cardPreview.dataURI,
25
33
  alt: alt,
26
- previewOrientation: previewOrientation,
27
- onImageLoad: onImageLoad,
28
- onImageError: onImageError,
34
+ previewOrientation: cardPreview.orientation,
35
+ onImageLoad: onLoad,
36
+ onImageError: onError,
29
37
  loading: nativeLazyLoad ? 'lazy' : undefined,
30
38
  forceSyncDisplay: forceSyncDisplay
31
39
  }, resizeModeToMediaImageProps(resizeMode)));
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { errorIcon } from '@atlaskit/media-ui/errorIcon';
3
3
  import { WarningIconWrapper, LoadingRateLimitedContainer, CouldntLoadWrapper, ErrorWrapper, LoadingRateLimitedTextWrapper } from './styled';
4
+ import { FormattedMessageWrapper } from '../../styled';
4
5
  import { messages } from '@atlaskit/media-ui';
5
- import { FormattedMessage } from 'react-intl';
6
+ import { FormattedMessage } from 'react-intl-next';
6
7
  import { Breakpoint } from '../common';
7
8
  export const LoadingRateLimited = ({
8
9
  breakpoint = Breakpoint.SMALL,
@@ -11,5 +12,5 @@ export const LoadingRateLimited = ({
11
12
  return /*#__PURE__*/React.createElement(LoadingRateLimitedContainer, null, /*#__PURE__*/React.createElement(WarningIconWrapper, null, errorIcon), /*#__PURE__*/React.createElement(LoadingRateLimitedTextWrapper, {
12
13
  breakpoint: breakpoint,
13
14
  positionBottom: positionBottom
14
- }, /*#__PURE__*/React.createElement(CouldntLoadWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.couldnt_load_file)), /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.error_429))));
15
+ }, /*#__PURE__*/React.createElement(CouldntLoadWrapper, null, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.couldnt_load_file))), /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.error_429)))));
15
16
  };
@@ -31,7 +31,7 @@ export const LoadingRateLimitedTextWrapper = styled.div`
31
31
  display: block;
32
32
  width:100%;
33
33
  text-align:center;
34
- ${generateResponsiveStyles(breakpoint, positionBottom, 1)}
34
+ ${generateResponsiveStyles(breakpoint, positionBottom, false, 1)}
35
35
  `}
36
36
  `;
37
37
  LoadingRateLimitedTextWrapper.displayName = 'LoadingRateLimitedTextWrapper';
@@ -4,12 +4,14 @@ import { Breakpoint } from '../common';
4
4
  export const ProgressBar = ({
5
5
  progress,
6
6
  breakpoint = Breakpoint.SMALL,
7
- positionBottom = false
7
+ positionBottom = false,
8
+ showOnTop = false
8
9
  }) => {
9
10
  const normalizedProgress = Math.min(1, Math.max(0, progress || 0)) * 100;
10
11
  return /*#__PURE__*/React.createElement(StyledBar, {
11
12
  progress: normalizedProgress,
12
13
  breakpoint: breakpoint,
13
- positionBottom: positionBottom
14
+ positionBottom: positionBottom,
15
+ showOnTop: showOnTop
14
16
  });
15
17
  };
@@ -15,19 +15,20 @@ const smallSizeSettings = {
15
15
  const largeSizeSettings = {
16
16
  marginBottom: 12
17
17
  };
18
- export function generateResponsiveStyles(breakpoint, positionBottom, multiplier = 1) {
18
+ export function generateResponsiveStyles(breakpoint, positionBottom, showOnTop, multiplier = 1) {
19
19
  const setting = breakpoint === Breakpoint.SMALL ? smallSizeSettings : largeSizeSettings;
20
20
  const marginPositionBottom = responsiveSettings[breakpoint].titleBox.verticalPadding;
21
21
  const marginBottom = setting.marginBottom * multiplier + (positionBottom ? marginPositionBottom : getTitleBoxHeight(breakpoint));
22
22
  return `
23
- bottom: ${marginBottom}px
23
+ ${showOnTop ? 'top' : 'bottom'}: ${marginBottom}px
24
24
  `;
25
25
  }
26
26
  export const StyledBar = styled.div`
27
27
  ${({
28
28
  progress,
29
29
  breakpoint,
30
- positionBottom
30
+ positionBottom,
31
+ showOnTop
31
32
  }) => `
32
33
  ${borderRadius}
33
34
  overflow: hidden;
@@ -37,6 +38,7 @@ export const StyledBar = styled.div`
37
38
  background-color: ${rgba(N0, 0.8)};
38
39
  height: ${height + padding * 2}px;
39
40
  padding: ${padding}px;
41
+ box-sizing: border-box;
40
42
 
41
43
  ::before {
42
44
  content: '';
@@ -47,7 +49,7 @@ export const StyledBar = styled.div`
47
49
  display: block;
48
50
  }
49
51
 
50
- ${generateResponsiveStyles(breakpoint, positionBottom)}
52
+ ${generateResponsiveStyles(breakpoint, positionBottom, showOnTop)}
51
53
  `}
52
54
  `;
53
55
  StyledBar.displayName = 'StyledProgressBar';
@@ -52,7 +52,7 @@ const getWrapperShadow = (disableOverlay, selected) => {
52
52
  return shadow ? `box-shadow: ${shadow};` : '';
53
53
  };
54
54
 
55
- const getCursorStyle = shouldUsePointerCursor => `cursor: ${shouldUsePointerCursor ? 'pointer' : 'default'};`;
55
+ const getCursorStyle = cursor => `cursor: ${cursor};`;
56
56
 
57
57
  const getClickablePlayButtonStyles = isPlayButtonClickable => {
58
58
  if (!isPlayButtonClickable) {
@@ -83,13 +83,13 @@ export const NewFileExperienceWrapper = styled.div`
83
83
  breakpoint,
84
84
  dimensions,
85
85
  appearance,
86
- shouldUsePointerCursor,
87
86
  disableOverlay,
88
87
  displayBackground,
89
88
  selected,
90
89
  isPlayButtonClickable,
91
90
  isTickBoxSelectable,
92
- shouldDisplayTooltip
91
+ shouldDisplayTooltip,
92
+ mediaCardCursor
93
93
  }) => `
94
94
  ${transition()}
95
95
  box-sizing: border-box;
@@ -101,7 +101,7 @@ export const NewFileExperienceWrapper = styled.div`
101
101
  ${getWrapperDimensions(dimensions, appearance)}
102
102
  ${displayBackground ? `background-color: ${N20};` : ''}
103
103
  ${borderRadius}
104
- ${getCursorStyle(shouldUsePointerCursor)}
104
+ ${getCursorStyle(mediaCardCursor)}
105
105
  ${getWrapperShadow(disableOverlay, selected)}
106
106
  ${generateResponsiveStyles(breakpoint)}
107
107
  ${hideNativeBrowserTextSelectionStyles}
@@ -118,7 +118,7 @@ export const NewFileExperienceWrapper = styled.div`
118
118
  }
119
119
 
120
120
  /* Tooltip does not support percentage dimensions. We enforce them here */
121
- ${shouldDisplayTooltip ? `> div { ${getWrapperDimensions(dimensions, appearance)} }` : ''}
121
+ ${shouldDisplayTooltip ? `> div { width: 100%; height: 100% }` : ''}
122
122
  `}
123
123
  `;
124
124
  NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
@@ -3,7 +3,8 @@ import { TitleBoxWrapper, ErrorMessageWrapper } from './styled';
3
3
  import EditorWarningIcon from '@atlaskit/icon/glyph/editor/warning';
4
4
  import { messages } from '@atlaskit/media-ui';
5
5
  import { R300 } from '@atlaskit/theme/colors';
6
- import { FormattedMessage } from 'react-intl';
6
+ import { FormattedMessage } from 'react-intl-next';
7
+ import { FormattedMessageWrapper } from '../../styled';
7
8
  export const FailedTitleBox = ({
8
9
  breakpoint,
9
10
  customMessage = messages.failed_to_load
@@ -14,5 +15,5 @@ export const FailedTitleBox = ({
14
15
  label: 'Warning',
15
16
  size: 'small',
16
17
  primaryColor: R300
17
- }), /*#__PURE__*/React.createElement(FormattedMessage, customMessage)));
18
+ }), /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, customMessage))));
18
19
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import LockFilledIcon from '@atlaskit/icon/glyph/lock-filled';
3
- import { injectIntl } from 'react-intl';
3
+ import { injectIntl } from 'react-intl-next';
4
4
  import { TitleBoxWrapper, TitleBoxHeader, TitleBoxFooter, TitleBoxIcon } from './styled';
5
5
  import { Truncate } from '@atlaskit/media-ui/truncateText';
6
6
  import { formatDate } from '@atlaskit/media-ui/formatDate';