@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
@@ -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
 
@@ -45,6 +45,7 @@ import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUn
45
45
  import { isRateLimitedError, isPollingError } from '@atlaskit/media-client';
46
46
  import { newFileExperienceClassName } from './card/cardConstants';
47
47
  import { isUploadError } from '../errors';
48
+ import { MediaCardCursor } from '../types';
48
49
 
49
50
  /**
50
51
  * This is classic vanilla CardView class. To create an instance of class one would need to supply
@@ -72,31 +73,38 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
72
73
 
73
74
  _defineProperty(_assertThisInitialized(_this), "divRef", /*#__PURE__*/React.createRef());
74
75
 
75
- _defineProperty(_assertThisInitialized(_this), "onImageLoad", function () {
76
- var onImageLoad = _this.props.onImageLoad; // We render the icon & icon message always, even if there is dataURI available.
76
+ _defineProperty(_assertThisInitialized(_this), "onImageLoad", function (prevCardPreview) {
77
+ var _this$props = _this.props,
78
+ onImageLoad = _this$props.onImageLoad,
79
+ cardPreview = _this$props.cardPreview;
80
+
81
+ if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
82
+ return;
83
+ } // We render the icon & icon message always, even if there is cardPreview available.
77
84
  // If the image fails to load/render, the icon will remain, i.e. the user won't see a change until
78
85
  // the root card decides to chage status to error.
79
86
  // If the image renders successfully, we switch this variable to hide the icon & icon message
80
87
  // behind the thumbnail in case the image has transparency.
81
- // It is less likely that root component replaces a suceeded dataURI for a failed one
88
+ // It is less likely that root component replaces a suceeded cardPreview for a failed one
82
89
  // than the opposite case. Therefore we prefer to hide the icon instead show when the image fails,
83
90
  // for a smoother transition
84
91
 
92
+
85
93
  _this.setState({
86
94
  didImageRender: true
87
95
  });
88
96
 
89
- onImageLoad && onImageLoad();
97
+ onImageLoad && onImageLoad(cardPreview);
90
98
  });
91
99
 
92
- _defineProperty(_assertThisInitialized(_this), "onImageError", function () {
100
+ _defineProperty(_assertThisInitialized(_this), "onImageError", function (cardPreview) {
93
101
  var onImageError = _this.props.onImageError;
94
102
 
95
103
  _this.setState({
96
104
  didImageRender: false
97
105
  });
98
106
 
99
- onImageError && onImageError();
107
+ onImageError && onImageError(cardPreview);
100
108
  });
101
109
 
102
110
  _defineProperty(_assertThisInitialized(_this), "saveElementWidth", function () {
@@ -118,24 +126,24 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
118
126
  });
119
127
 
120
128
  _defineProperty(_assertThisInitialized(_this), "renderFileNewExperience", function () {
121
- var _this$props = _this.props,
122
- dimensions = _this$props.dimensions,
123
- appearance = _this$props.appearance,
124
- onClick = _this$props.onClick,
125
- onMouseEnter = _this$props.onMouseEnter,
126
- testId = _this$props.testId,
127
- metadata = _this$props.metadata,
128
- status = _this$props.status,
129
- selected = _this$props.selected,
130
- selectable = _this$props.selectable,
131
- disableOverlay = _this$props.disableOverlay,
132
- dataURI = _this$props.dataURI;
129
+ var _this$props2 = _this.props,
130
+ dimensions = _this$props2.dimensions,
131
+ appearance = _this$props2.appearance,
132
+ onClick = _this$props2.onClick,
133
+ onMouseEnter = _this$props2.onMouseEnter,
134
+ testId = _this$props2.testId,
135
+ metadata = _this$props2.metadata,
136
+ status = _this$props2.status,
137
+ selected = _this$props2.selected,
138
+ selectable = _this$props2.selectable,
139
+ disableOverlay = _this$props2.disableOverlay,
140
+ cardPreview = _this$props2.cardPreview,
141
+ mediaCardCursor = _this$props2.mediaCardCursor;
133
142
 
134
143
  var _ref = metadata || {},
135
144
  name = _ref.name;
136
145
 
137
- var shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
138
- var shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
146
+ var shouldDisplayBackground = !cardPreview || !disableOverlay || status === 'error' || status === 'failed-processing';
139
147
  var isPlayButtonClickable = !!(_this.shouldRenderPlayButton() && disableOverlay);
140
148
  var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
141
149
 
@@ -149,7 +157,7 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
149
157
  onMouseEnter: onMouseEnter,
150
158
  innerRef: _this.divRef,
151
159
  breakpoint: _this.breakpoint,
152
- shouldUsePointerCursor: shouldUsePointerCursor,
160
+ mediaCardCursor: mediaCardCursor,
153
161
  disableOverlay: !!disableOverlay,
154
162
  selected: !!selected,
155
163
  displayBackground: shouldDisplayBackground,
@@ -164,27 +172,30 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
164
172
  });
165
173
 
166
174
  _defineProperty(_assertThisInitialized(_this), "renderFile", function () {
167
- var _this$props2 = _this.props,
168
- status = _this$props2.status,
169
- mediaItemType = _this$props2.mediaItemType,
170
- metadata = _this$props2.metadata,
171
- dataURI = _this$props2.dataURI,
172
- progress = _this$props2.progress,
173
- resizeMode = _this$props2.resizeMode,
174
- dimensions = _this$props2.dimensions,
175
- selectable = _this$props2.selectable,
176
- selected = _this$props2.selected,
177
- disableOverlay = _this$props2.disableOverlay,
178
- previewOrientation = _this$props2.previewOrientation,
179
- alt = _this$props2.alt,
180
- onDisplayImage = _this$props2.onDisplayImage,
181
- actions = _this$props2.actions;
175
+ var _this$props3 = _this.props,
176
+ cardPreview = _this$props3.cardPreview,
177
+ status = _this$props3.status,
178
+ mediaItemType = _this$props3.mediaItemType,
179
+ metadata = _this$props3.metadata,
180
+ progress = _this$props3.progress,
181
+ resizeMode = _this$props3.resizeMode,
182
+ dimensions = _this$props3.dimensions,
183
+ selectable = _this$props3.selectable,
184
+ selected = _this$props3.selected,
185
+ disableOverlay = _this$props3.disableOverlay,
186
+ alt = _this$props3.alt,
187
+ onDisplayImage = _this$props3.onDisplayImage,
188
+ actions = _this$props3.actions;
182
189
 
183
- var _ref2 = metadata || {},
184
- name = _ref2.name,
185
- mediaType = _ref2.mediaType,
186
- mimeType = _ref2.mimeType,
187
- size = _ref2.size;
190
+ var _ref2 = cardPreview || {},
191
+ dataURI = _ref2.dataURI,
192
+ orientation = _ref2.orientation;
193
+
194
+ var _ref3 = metadata || {},
195
+ name = _ref3.name,
196
+ mediaType = _ref3.mediaType,
197
+ mimeType = _ref3.mimeType,
198
+ size = _ref3.size;
188
199
 
189
200
  var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
190
201
  var errorMessage = getErrorMessage(status);
@@ -206,33 +217,34 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
206
217
  onDisplayImage: onDisplayImage,
207
218
  actions: actionsWithDetails,
208
219
  disableOverlay: disableOverlay,
209
- previewOrientation: previewOrientation,
220
+ previewOrientation: orientation,
210
221
  alt: alt,
211
222
  onImageLoad: _this.onImageLoad,
212
- onImageError: _this.onImageError
223
+ onImageError: _this.onImageError,
224
+ cardPreview: cardPreview
213
225
  });
214
226
  });
215
227
 
216
228
  _defineProperty(_assertThisInitialized(_this), "getRenderConfigByStatus", function () {
217
- var _this$props3 = _this.props,
218
- dataURI = _this$props3.dataURI,
219
- status = _this$props3.status,
220
- metadata = _this$props3.metadata,
221
- disableOverlay = _this$props3.disableOverlay,
222
- error = _this$props3.error,
223
- selectable = _this$props3.selectable,
224
- disableAnimation = _this$props3.disableAnimation;
229
+ var _this$props4 = _this.props,
230
+ cardPreview = _this$props4.cardPreview,
231
+ status = _this$props4.status,
232
+ metadata = _this$props4.metadata,
233
+ disableOverlay = _this$props4.disableOverlay,
234
+ error = _this$props4.error,
235
+ selectable = _this$props4.selectable,
236
+ disableAnimation = _this$props4.disableAnimation;
225
237
 
226
- var _ref3 = metadata || {},
227
- name = _ref3.name,
228
- mediaType = _ref3.mediaType;
238
+ var _ref4 = metadata || {},
239
+ name = _ref4.name,
240
+ mediaType = _ref4.mediaType;
229
241
 
230
242
  var didImageRender = _this.state.didImageRender;
231
243
  var isZeroSize = !!(metadata && metadata.size === 0);
232
244
  var defaultConfig = {
233
245
  renderTypeIcon: !didImageRender,
234
- renderImageRenderer: !!dataURI,
235
- renderPlayButton: !!dataURI && mediaType === 'video',
246
+ renderImageRenderer: !!cardPreview,
247
+ renderPlayButton: !!cardPreview && mediaType === 'video',
236
248
  renderBlanket: !disableOverlay,
237
249
  renderTitleBox: !disableOverlay && !!name,
238
250
  renderTickBox: !disableOverlay && !!selectable
@@ -269,8 +281,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
269
281
  var iconMessage;
270
282
  var customTitleMessage;
271
283
 
272
- var _ref4 = error || {},
273
- secondaryError = _ref4.secondaryError;
284
+ var _ref5 = error || {},
285
+ secondaryError = _ref5.secondaryError;
274
286
 
275
287
  if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
276
288
  iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
@@ -322,14 +334,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
322
334
  isFixedBlanket = _this$getRenderConfig.isFixedBlanket,
323
335
  customTitleMessage = _this$getRenderConfig.customTitleMessage;
324
336
 
325
- var _this$props4 = _this.props,
326
- progress = _this$props4.progress,
327
- selected = _this$props4.selected,
328
- status = _this$props4.status,
329
- metadata = _this$props4.metadata;
337
+ var _this$props5 = _this.props,
338
+ progress = _this$props5.progress,
339
+ selected = _this$props5.selected,
340
+ status = _this$props5.status,
341
+ metadata = _this$props5.metadata;
330
342
 
331
- var _ref5 = metadata || {},
332
- name = _ref5.name;
343
+ var _ref6 = metadata || {},
344
+ name = _ref6.name;
333
345
 
334
346
  var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
335
347
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardImageContainer, {
@@ -354,14 +366,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
354
366
  }
355
367
  }, {
356
368
  key: "componentDidUpdate",
357
- value: function componentDidUpdate(_ref6) {
358
- var prevDataURI = _ref6.dataURI;
359
- var dataURI = this.props.dataURI; // We should only switch didImageRender to false
360
- // when dataURI goes undefined, not when it is updated.
369
+ value: function componentDidUpdate(_ref7) {
370
+ var prevCardPreview = _ref7.cardPreview;
371
+ var cardPreview = this.props.cardPreview; // We should only switch didImageRender to false
372
+ // when cardPreview goes undefined, not when it is updated.
361
373
  // as this method could be triggered after onImageLoad callback,
362
374
  // falling on a race condition
363
375
 
364
- prevDataURI && !dataURI && this.setState({
376
+ !!prevCardPreview && !cardPreview && this.setState({
365
377
  didImageRender: false
366
378
  });
367
379
  }
@@ -376,10 +388,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
376
388
  return elementWidth;
377
389
  }
378
390
 
379
- var _ref7 = this.props.dimensions || {
391
+ var _ref8 = this.props.dimensions || {
380
392
  width: undefined
381
393
  },
382
- width = _ref7.width;
394
+ width = _ref8.width;
383
395
 
384
396
  if (!width) {
385
397
  return defaultImageCardDimensions.width;
@@ -404,12 +416,12 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
404
416
  return this.renderFileNewExperience();
405
417
  }
406
418
 
407
- var _this$props5 = this.props,
408
- dimensions = _this$props5.dimensions,
409
- appearance = _this$props5.appearance,
410
- onClick = _this$props5.onClick,
411
- onMouseEnter = _this$props5.onMouseEnter,
412
- testId = _this$props5.testId;
419
+ var _this$props6 = this.props,
420
+ dimensions = _this$props6.dimensions,
421
+ appearance = _this$props6.appearance,
422
+ onClick = _this$props6.onClick,
423
+ onMouseEnter = _this$props6.onMouseEnter,
424
+ testId = _this$props6.testId;
413
425
  var wrapperDimensions = dimensions ? dimensions : getDefaultCardDimensions(appearance);
414
426
  return /*#__PURE__*/React.createElement(Wrapper, {
415
427
  "data-testid": testId || 'media-card-view',
@@ -432,14 +444,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
432
444
  }, {
433
445
  key: "shouldRenderPlayButton",
434
446
  value: function shouldRenderPlayButton() {
435
- var _this$props6 = this.props,
436
- metadata = _this$props6.metadata,
437
- dataURI = _this$props6.dataURI;
447
+ var _this$props7 = this.props,
448
+ metadata = _this$props7.metadata,
449
+ cardPreview = _this$props7.cardPreview;
438
450
 
439
- var _ref8 = metadata || {},
440
- mediaType = _ref8.mediaType;
451
+ var _ref9 = metadata || {},
452
+ mediaType = _ref9.mediaType;
441
453
 
442
- if (mediaType !== 'video' || !dataURI) {
454
+ if (mediaType !== 'video' || !cardPreview) {
443
455
  return false;
444
456
  }
445
457
 
@@ -465,14 +477,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
465
477
  }, {
466
478
  key: "renderTitleBox",
467
479
  value: function renderTitleBox() {
468
- var _this$props7 = this.props,
469
- metadata = _this$props7.metadata,
470
- titleBoxBgColor = _this$props7.titleBoxBgColor,
471
- titleBoxIcon = _this$props7.titleBoxIcon;
480
+ var _this$props8 = this.props,
481
+ metadata = _this$props8.metadata,
482
+ titleBoxBgColor = _this$props8.titleBoxBgColor,
483
+ titleBoxIcon = _this$props8.titleBoxIcon;
472
484
 
473
- var _ref9 = metadata || {},
474
- name = _ref9.name,
475
- createdAt = _ref9.createdAt;
485
+ var _ref10 = metadata || {},
486
+ name = _ref10.name,
487
+ createdAt = _ref10.createdAt;
476
488
 
477
489
  return !!name && /*#__PURE__*/React.createElement(TitleBox, {
478
490
  name: name,
@@ -503,22 +515,20 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
503
515
  }, {
504
516
  key: "renderImageRenderer",
505
517
  value: function renderImageRenderer() {
506
- var _this$props8 = this.props,
507
- dataURI = _this$props8.dataURI,
508
- _this$props8$metadata = _this$props8.metadata;
509
- _this$props8$metadata = _this$props8$metadata === void 0 ? {} : _this$props8$metadata;
510
- var _this$props8$metadata2 = _this$props8$metadata.mediaType,
511
- mediaType = _this$props8$metadata2 === void 0 ? 'unknown' : _this$props8$metadata2,
512
- previewOrientation = _this$props8.previewOrientation,
513
- alt = _this$props8.alt,
514
- resizeMode = _this$props8.resizeMode,
515
- onDisplayImage = _this$props8.onDisplayImage,
516
- nativeLazyLoad = _this$props8.nativeLazyLoad,
517
- forceSyncDisplay = _this$props8.forceSyncDisplay;
518
- return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
519
- dataURI: dataURI,
518
+ var _this$props9 = this.props,
519
+ cardPreview = _this$props9.cardPreview,
520
+ _this$props9$metadata = _this$props9.metadata;
521
+ _this$props9$metadata = _this$props9$metadata === void 0 ? {} : _this$props9$metadata;
522
+ var _this$props9$metadata2 = _this$props9$metadata.mediaType,
523
+ mediaType = _this$props9$metadata2 === void 0 ? 'unknown' : _this$props9$metadata2,
524
+ alt = _this$props9.alt,
525
+ resizeMode = _this$props9.resizeMode,
526
+ onDisplayImage = _this$props9.onDisplayImage,
527
+ nativeLazyLoad = _this$props9.nativeLazyLoad,
528
+ forceSyncDisplay = _this$props9.forceSyncDisplay;
529
+ return !!cardPreview && /*#__PURE__*/React.createElement(ImageRenderer, {
530
+ cardPreview: cardPreview,
520
531
  mediaType: mediaType,
521
- previewOrientation: previewOrientation,
522
532
  alt: alt,
523
533
  resizeMode: resizeMode,
524
534
  onDisplayImage: onDisplayImage,
@@ -541,10 +551,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
541
551
  value: function renderMediaTypeIcon(hasTitleBox, iconMessage) {
542
552
  var metadata = this.props.metadata;
543
553
 
544
- var _ref10 = metadata || {},
545
- mediaType = _ref10.mediaType,
546
- mimeType = _ref10.mimeType,
547
- name = _ref10.name;
554
+ var _ref11 = metadata || {},
555
+ mediaType = _ref11.mediaType,
556
+ mimeType = _ref11.mimeType,
557
+ name = _ref11.name;
548
558
 
549
559
  return /*#__PURE__*/React.createElement(IconWrapper, {
550
560
  breakpoint: this.breakpoint,
@@ -559,10 +569,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
559
569
  }, {
560
570
  key: "renderActionsBar",
561
571
  value: function renderActionsBar() {
562
- var _this$props9 = this.props,
563
- disableOverlay = _this$props9.disableOverlay,
564
- actions = _this$props9.actions,
565
- metadata = _this$props9.metadata;
572
+ var _this$props10 = this.props,
573
+ disableOverlay = _this$props10.disableOverlay,
574
+ actions = _this$props10.actions,
575
+ metadata = _this$props10.metadata;
566
576
  var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
567
577
 
568
578
  if (disableOverlay || !actions || actions.length === 0) {
@@ -579,7 +589,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
579
589
  }(React.Component);
580
590
 
581
591
  _defineProperty(CardViewBase, "defaultProps", {
582
- appearance: 'auto'
592
+ appearance: 'auto',
593
+ mediaCardCursor: MediaCardCursor.NoAction
583
594
  });
584
595
 
585
596
  export var CardView = withAnalyticsEvents({
@@ -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,29 +63,42 @@ 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),
82
95
  isSelected: isSelected
83
96
  });
84
97
  }
85
98
 
86
99
  if (isErrored) {
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
  }
@@ -99,7 +112,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
99
112
 
100
113
  if (fileState.status === 'failed-processing') {
101
114
  return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
102
- message: intl.formatMessage(messages.couldnt_load_file),
115
+ message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
103
116
  isSelected: isSelected
104
117
  });
105
118
  }
@@ -131,7 +144,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
131
144
  formattedDate = formatDate(fileState.createdAt, locale);
132
145
  }
133
146
 
134
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
147
+ return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
135
148
  position: "bottom",
136
149
  content: formattedDate,
137
150
  tag: "span"
@@ -140,6 +153,8 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
140
153
  title: name,
141
154
  onClick: onMediaInlineCardClick,
142
155
  isSelected: isSelected
143
- })), mediaViewer);
156
+ })), mediaViewer));
144
157
  };
145
- export var MediaInlineCard = injectIntl(MediaInlineCardInternal);
158
+ export var MediaInlineCard = injectIntl(MediaInlineCardInternal, {
159
+ enforceContext: false
160
+ });