@atlaskit/media-card 71.0.0 → 73.1.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 (204) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/cjs/actions.js +2 -2
  3. package/dist/cjs/errors.js +83 -8
  4. package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
  5. package/dist/cjs/files/cardImageView/index.js +53 -104
  6. package/dist/cjs/files/cardImageView/styled.js +1 -1
  7. package/dist/cjs/files/index.js +0 -6
  8. package/dist/cjs/index.js +8 -8
  9. package/dist/cjs/root/card/cardAnalytics.js +4 -16
  10. package/dist/cjs/root/card/cardLoader.js +66 -124
  11. package/dist/cjs/root/card/cardState.js +50 -0
  12. package/dist/cjs/root/card/getCardPreview/cache.js +10 -5
  13. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +53 -0
  14. package/dist/cjs/root/card/getCardPreview/helpers.js +14 -22
  15. package/dist/cjs/root/card/getCardPreview/index.js +177 -97
  16. package/dist/cjs/root/card/getCardStatus.js +7 -1
  17. package/dist/cjs/root/card/index.js +384 -285
  18. package/dist/cjs/root/cardView.js +113 -88
  19. package/dist/cjs/root/inline/loader.js +47 -15
  20. package/dist/cjs/root/inline/mediaInlineCard.js +33 -12
  21. package/dist/cjs/root/inlinePlayer.js +77 -24
  22. package/dist/cjs/root/styled.js +7 -3
  23. package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
  24. package/dist/cjs/root/ui/blanket/styled.js +1 -1
  25. package/dist/cjs/root/ui/common.js +11 -5
  26. package/dist/cjs/root/ui/iconMessage/index.js +16 -7
  27. package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
  28. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +47 -123
  29. package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
  30. package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
  31. package/dist/cjs/root/ui/playButton/styled.js +1 -1
  32. package/dist/cjs/root/ui/progressBar/progressBar.js +7 -4
  33. package/dist/cjs/root/ui/progressBar/styled.js +8 -9
  34. package/dist/cjs/root/ui/styled.js +80 -17
  35. package/dist/cjs/root/ui/tickBox/styled.js +1 -1
  36. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +9 -3
  37. package/dist/cjs/root/ui/titleBox/styled.js +2 -4
  38. package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
  39. package/dist/cjs/styles/index.js +25 -23
  40. package/dist/cjs/styles/mixins.js +1 -1
  41. package/dist/cjs/utils/analytics.js +7 -44
  42. package/dist/cjs/utils/breakpoint.js +1 -1
  43. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +18 -9
  44. package/dist/cjs/utils/cardActions/index.js +10 -10
  45. package/dist/cjs/utils/cardActions/styled.js +1 -1
  46. package/dist/cjs/utils/cardDimensions.js +1 -1
  47. package/dist/cjs/utils/dimensionComparer.js +1 -1
  48. package/dist/cjs/utils/getErrorMessage.js +2 -2
  49. package/dist/cjs/utils/index.js +46 -46
  50. package/dist/cjs/utils/lightCards/styled.js +1 -1
  51. package/dist/cjs/utils/metadata.js +11 -3
  52. package/dist/cjs/utils/objectURLCache.js +7 -1
  53. package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
  54. package/dist/cjs/utils/viewportDetector.js +49 -22
  55. package/dist/cjs/version.json +1 -1
  56. package/dist/es2019/errors.js +42 -2
  57. package/dist/es2019/files/cardImageView/index.js +8 -61
  58. package/dist/es2019/files/index.js +1 -1
  59. package/dist/es2019/root/card/cardAnalytics.js +3 -14
  60. package/dist/es2019/root/card/cardLoader.js +47 -53
  61. package/dist/es2019/root/card/cardState.js +26 -0
  62. package/dist/es2019/root/card/getCardPreview/cache.js +5 -0
  63. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +38 -0
  64. package/dist/es2019/root/card/getCardPreview/helpers.js +2 -12
  65. package/dist/es2019/root/card/getCardPreview/index.js +112 -73
  66. package/dist/es2019/root/card/getCardStatus.js +1 -0
  67. package/dist/es2019/root/card/index.js +308 -190
  68. package/dist/es2019/root/cardView.js +97 -68
  69. package/dist/es2019/root/inline/loader.js +17 -5
  70. package/dist/es2019/root/inline/mediaInlineCard.js +32 -11
  71. package/dist/es2019/root/inlinePlayer.js +56 -4
  72. package/dist/es2019/root/styled.js +2 -1
  73. package/dist/es2019/root/ui/common.js +7 -1
  74. package/dist/es2019/root/ui/iconMessage/index.js +8 -5
  75. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +35 -88
  76. package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  77. package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
  78. package/dist/es2019/root/ui/progressBar/progressBar.js +5 -3
  79. package/dist/es2019/root/ui/progressBar/styled.js +7 -6
  80. package/dist/es2019/root/ui/styled.js +65 -4
  81. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +6 -3
  82. package/dist/es2019/root/ui/titleBox/styled.js +1 -2
  83. package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
  84. package/dist/es2019/utils/analytics.js +5 -34
  85. package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
  86. package/dist/es2019/utils/dimensionComparer.js +1 -1
  87. package/dist/es2019/utils/getErrorMessage.js +1 -1
  88. package/dist/es2019/utils/metadata.js +12 -4
  89. package/dist/es2019/utils/objectURLCache.js +5 -0
  90. package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
  91. package/dist/es2019/utils/viewportDetector.js +48 -18
  92. package/dist/es2019/version.json +1 -1
  93. package/dist/esm/actions.js +2 -2
  94. package/dist/esm/errors.js +64 -4
  95. package/dist/esm/files/cardImageView/index.js +51 -102
  96. package/dist/esm/files/index.js +1 -1
  97. package/dist/esm/root/card/cardAnalytics.js +3 -15
  98. package/dist/esm/root/card/cardLoader.js +66 -126
  99. package/dist/esm/root/card/cardState.js +32 -0
  100. package/dist/esm/root/card/getCardPreview/cache.js +9 -2
  101. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +38 -0
  102. package/dist/esm/root/card/getCardPreview/helpers.js +13 -21
  103. package/dist/esm/root/card/getCardPreview/index.js +144 -91
  104. package/dist/esm/root/card/getCardStatus.js +3 -0
  105. package/dist/esm/root/card/index.js +396 -288
  106. package/dist/esm/root/cardView.js +113 -86
  107. package/dist/esm/root/inline/loader.js +48 -15
  108. package/dist/esm/root/inline/mediaInlineCard.js +32 -11
  109. package/dist/esm/root/inlinePlayer.js +74 -23
  110. package/dist/esm/root/styled.js +3 -2
  111. package/dist/esm/root/ui/common.js +7 -1
  112. package/dist/esm/root/ui/iconMessage/index.js +10 -5
  113. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +37 -116
  114. package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  115. package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
  116. package/dist/esm/root/ui/progressBar/progressBar.js +6 -3
  117. package/dist/esm/root/ui/progressBar/styled.js +7 -7
  118. package/dist/esm/root/ui/styled.js +61 -13
  119. package/dist/esm/root/ui/titleBox/failedTitleBox.js +7 -3
  120. package/dist/esm/root/ui/titleBox/styled.js +1 -2
  121. package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
  122. package/dist/esm/utils/analytics.js +5 -36
  123. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +17 -9
  124. package/dist/esm/utils/dimensionComparer.js +1 -1
  125. package/dist/esm/utils/getErrorMessage.js +1 -1
  126. package/dist/esm/utils/metadata.js +12 -4
  127. package/dist/esm/utils/objectURLCache.js +6 -0
  128. package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
  129. package/dist/esm/utils/viewportDetector.js +48 -21
  130. package/dist/esm/version.json +1 -1
  131. package/dist/types/errors.d.ts +15 -1
  132. package/dist/types/files/cardImageView/index.d.ts +4 -13
  133. package/dist/types/files/cardImageView/styled.d.ts +1 -1
  134. package/dist/types/files/index.d.ts +1 -1
  135. package/dist/types/index.d.ts +7 -4
  136. package/dist/types/root/card/cardAnalytics.d.ts +1 -6
  137. package/dist/types/root/card/cardLoader.d.ts +5 -19
  138. package/dist/types/root/card/cardState.d.ts +5 -0
  139. package/dist/types/root/card/getCardPreview/cache.d.ts +3 -1
  140. package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
  141. package/dist/types/root/card/getCardPreview/helpers.d.ts +3 -4
  142. package/dist/types/root/card/getCardPreview/index.d.ts +24 -14
  143. package/dist/types/root/card/getCardStatus.d.ts +1 -0
  144. package/dist/types/root/card/index.d.ts +20 -18
  145. package/dist/types/root/cardView.d.ts +13 -8
  146. package/dist/types/root/inline/loader.d.ts +2 -0
  147. package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
  148. package/dist/types/root/inlinePlayer.d.ts +8 -1
  149. package/dist/types/root/styled.d.ts +1 -0
  150. package/dist/types/root/ui/common.d.ts +4 -1
  151. package/dist/types/root/ui/iconMessage/index.d.ts +4 -3
  152. package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
  153. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +14 -15
  154. package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
  155. package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
  156. package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
  157. package/dist/types/root/ui/progressBar/progressBar.d.ts +4 -2
  158. package/dist/types/root/ui/progressBar/styled.d.ts +3 -2
  159. package/dist/types/root/ui/styled.d.ts +10 -3
  160. package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
  161. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -1
  162. package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
  163. package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
  164. package/dist/types/styles/mixins.d.ts +1 -1
  165. package/dist/types/types.d.ts +7 -1
  166. package/dist/types/utils/analytics.d.ts +6 -15
  167. package/dist/types/utils/cardDimensions.d.ts +4 -4
  168. package/dist/types/utils/dimensionComparer.d.ts +1 -1
  169. package/dist/types/utils/getErrorMessage.d.ts +1 -0
  170. package/dist/types/utils/metadata.d.ts +2 -2
  171. package/dist/types/utils/objectURLCache.d.ts +2 -1
  172. package/dist/types/utils/viewportDetector.d.ts +13 -5
  173. package/example-helpers/developmentUseMessage.tsx +14 -0
  174. package/example-helpers/index.tsx +55 -4
  175. package/example-helpers/selectableCard.tsx +2 -1
  176. package/package.json +18 -16
  177. package/dist/cjs/root/card/cardSSRView.js +0 -112
  178. package/dist/cjs/root/card/getCardPreview/types.js +0 -5
  179. package/dist/cjs/root/ui/Breakpoint.js +0 -13
  180. package/dist/cjs/root/ui/styledSSR.js +0 -108
  181. package/dist/cjs/utils/fileAttributesContext.js +0 -40
  182. package/dist/cjs/utils/lazyContent/index.js +0 -56
  183. package/dist/cjs/utils/lazyContent/styled.js +0 -23
  184. package/dist/es2019/root/card/cardSSRView.js +0 -92
  185. package/dist/es2019/root/card/getCardPreview/types.js +0 -1
  186. package/dist/es2019/root/ui/Breakpoint.js +0 -6
  187. package/dist/es2019/root/ui/styledSSR.js +0 -93
  188. package/dist/es2019/utils/fileAttributesContext.js +0 -19
  189. package/dist/es2019/utils/lazyContent/index.js +0 -18
  190. package/dist/es2019/utils/lazyContent/styled.js +0 -12
  191. package/dist/esm/root/card/cardSSRView.js +0 -91
  192. package/dist/esm/root/card/getCardPreview/types.js +0 -1
  193. package/dist/esm/root/ui/Breakpoint.js +0 -6
  194. package/dist/esm/root/ui/styledSSR.js +0 -76
  195. package/dist/esm/utils/fileAttributesContext.js +0 -18
  196. package/dist/esm/utils/lazyContent/index.js +0 -41
  197. package/dist/esm/utils/lazyContent/styled.js +0 -14
  198. package/dist/types/root/card/cardSSRView.d.ts +0 -13
  199. package/dist/types/root/card/getCardPreview/types.d.ts +0 -5
  200. package/dist/types/root/ui/Breakpoint.d.ts +0 -4
  201. package/dist/types/root/ui/styledSSR.d.ts +0 -16
  202. package/dist/types/utils/fileAttributesContext.d.ts +0 -10
  203. package/dist/types/utils/lazyContent/index.d.ts +0 -11
  204. package/dist/types/utils/lazyContent/styled.d.ts +0 -5
@@ -1,15 +1,19 @@
1
1
  import React from 'react';
2
2
  import { TitleBoxWrapper, ErrorMessageWrapper } from './styled';
3
3
  import EditorWarningIcon from '@atlaskit/icon/glyph/editor/warning';
4
+ import { messages } from '@atlaskit/media-ui';
4
5
  import { R300 } from '@atlaskit/theme/colors';
5
- import { getErrorMessage } from '../../../utils/getErrorMessage';
6
+ import { FormattedMessage } from 'react-intl-next';
7
+ import { FormattedMessageWrapper } from '../../styled';
6
8
  export var FailedTitleBox = function FailedTitleBox(_ref) {
7
- var breakpoint = _ref.breakpoint;
9
+ var breakpoint = _ref.breakpoint,
10
+ _ref$customMessage = _ref.customMessage,
11
+ customMessage = _ref$customMessage === void 0 ? messages.failed_to_load : _ref$customMessage;
8
12
  return /*#__PURE__*/React.createElement(TitleBoxWrapper, {
9
13
  breakpoint: breakpoint
10
14
  }, /*#__PURE__*/React.createElement(ErrorMessageWrapper, null, /*#__PURE__*/React.createElement(EditorWarningIcon, {
11
15
  label: 'Warning',
12
16
  size: 'small',
13
17
  primaryColor: R300
14
- }), getErrorMessage('error')));
18
+ }), /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, customMessage))));
15
19
  };
@@ -3,8 +3,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
3
3
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
4
4
 
5
5
  import styled from 'styled-components';
6
- import { responsiveSettings, getTitleBoxHeight } from '../common';
7
- import { Breakpoint } from '../Breakpoint';
6
+ import { responsiveSettings, getTitleBoxHeight, Breakpoint } from '../common';
8
7
  import { N0 } from '@atlaskit/theme/colors';
9
8
  import { rgba } from '../../../styles/mixins';
10
9
 
@@ -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';
@@ -2,14 +2,6 @@ import { getMediaClientErrorReason, isRequestError } from '@atlaskit/media-clien
2
2
  import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
3
3
  import { createAndFireEvent } from '@atlaskit/analytics-next';
4
4
  import { isMediaCardError } from '../errors';
5
- export var RenderEventAction;
6
-
7
- (function (RenderEventAction) {
8
- RenderEventAction["COMMENCED"] = "commenced";
9
- RenderEventAction["SUCCEEDED"] = "succeeded";
10
- RenderEventAction["FAILED"] = "failed";
11
- })(RenderEventAction || (RenderEventAction = {}));
12
-
13
5
  export var getFileAttributes = function getFileAttributes(metadata, fileStatus) {
14
6
  return {
15
7
  fileMediatype: metadata.mediaType,
@@ -34,7 +26,7 @@ export var getRenderPreviewableCardPayload = function getRenderPreviewableCardPa
34
26
  export var getRenderCommencedEventPayload = function getRenderCommencedEventPayload(fileAttributes, performanceAttributes) {
35
27
  return {
36
28
  eventType: 'operational',
37
- action: RenderEventAction.COMMENCED,
29
+ action: 'commenced',
38
30
  actionSubject: 'mediaCardRender',
39
31
  attributes: {
40
32
  fileAttributes: fileAttributes,
@@ -45,7 +37,7 @@ export var getRenderCommencedEventPayload = function getRenderCommencedEventPayl
45
37
  export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes) {
46
38
  return {
47
39
  eventType: 'operational',
48
- action: RenderEventAction.SUCCEEDED,
40
+ action: 'succeeded',
49
41
  actionSubject: 'mediaCardRender',
50
42
  attributes: {
51
43
  fileAttributes: fileAttributes,
@@ -54,33 +46,10 @@ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayl
54
46
  }
55
47
  };
56
48
  };
57
- export var getFailedFileUriFailReason = function getFailedFileUriFailReason(fileStatus) {
58
- if (!fileStatus) {
59
- // This fail reason will come from a bug, most likely.
60
- return "unknown-uri";
61
- } else if (fileStatus === 'uploading') {
62
- return 'local-uri';
63
- }
64
-
65
- return 'remote-uri';
66
- };
67
- export var getRenderFailedFileUriPayload = function getRenderFailedFileUriPayload(fileAttributes, performanceAttributes) {
68
- return {
69
- eventType: 'operational',
70
- action: RenderEventAction.FAILED,
71
- actionSubject: 'mediaCardRender',
72
- attributes: {
73
- fileAttributes: fileAttributes,
74
- performanceAttributes: performanceAttributes,
75
- status: 'fail',
76
- failReason: getFailedFileUriFailReason(fileAttributes.fileStatus)
77
- }
78
- };
79
- };
80
49
  export var getRenderFailedExternalUriPayload = function getRenderFailedExternalUriPayload(fileAttributes, performanceAttributes) {
81
50
  return {
82
51
  eventType: 'operational',
83
- action: RenderEventAction.FAILED,
52
+ action: 'failed',
84
53
  actionSubject: 'mediaCardRender',
85
54
  attributes: {
86
55
  fileAttributes: fileAttributes,
@@ -123,7 +92,7 @@ export var getRenderErrorRequestMetadata = function getRenderErrorRequestMetadat
123
92
  export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error) {
124
93
  return {
125
94
  eventType: 'operational',
126
- action: RenderEventAction.FAILED,
95
+ action: 'failed',
127
96
  actionSubject: 'mediaCardRender',
128
97
  attributes: {
129
98
  fileAttributes: fileAttributes,
@@ -139,7 +108,7 @@ export var getRenderErrorEventPayload = function getRenderErrorEventPayload(file
139
108
  export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes) {
140
109
  return {
141
110
  eventType: 'operational',
142
- action: RenderEventAction.FAILED,
111
+ action: 'failed',
143
112
  actionSubject: 'mediaCardRender',
144
113
  attributes: {
145
114
  fileAttributes: fileAttributes,
@@ -1,9 +1,11 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _inherits from "@babel/runtime/helpers/inherits";
4
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
7
  import _extends from "@babel/runtime/helpers/extends";
8
+ var _excluded = ["triggerRef"];
7
9
 
8
10
  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); }; }
9
11
 
@@ -80,16 +82,22 @@ export var CardActionsDropdownMenu = /*#__PURE__*/function (_Component) {
80
82
 
81
83
  if (actions.length > 0) {
82
84
  return /*#__PURE__*/React.createElement(DropdownMenu, {
83
- "data-testid": "media-card-actions-menu",
85
+ testId: "media-card-actions-menu",
84
86
  onOpenChange: onOpenChange,
85
- trigger: /*#__PURE__*/React.createElement(CardActionButtonWithAnalytics, {
86
- variant: triggerVariant,
87
- style: {
88
- color: triggerColor
89
- }
90
- }, /*#__PURE__*/React.createElement(MoreIcon, {
91
- label: "more"
92
- }))
87
+ trigger: function trigger(_ref) {
88
+ var triggerRef = _ref.triggerRef,
89
+ providedProps = _objectWithoutProperties(_ref, _excluded);
90
+
91
+ return /*#__PURE__*/React.createElement(CardActionButtonWithAnalytics, _extends({
92
+ variant: triggerVariant,
93
+ style: {
94
+ color: triggerColor
95
+ },
96
+ ref: triggerRef
97
+ }, providedProps), /*#__PURE__*/React.createElement(MoreIcon, {
98
+ label: "more"
99
+ }));
100
+ }
93
101
  }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, actions.map(createDropdownItemWithAnalytics)));
94
102
  } else {
95
103
  return null;
@@ -20,7 +20,7 @@ export var canCompareDimension = function canCompareDimension(current, next) {
20
20
  return false;
21
21
  };
22
22
  export var isBigger = function isBigger(current, next) {
23
- if (canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
23
+ if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
24
24
  var nextIsHigher = parseInt("".concat(current.width), 10) < parseInt("".concat(next.width), 10);
25
25
  var nextIsWider = parseInt("".concat(current.height), 10) < parseInt("".concat(next.height), 10);
26
26
  return nextIsHigher || nextIsWider;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { FormattedMessage } from 'react-intl';
2
+ import { FormattedMessage } from 'react-intl-next';
3
3
  import { messages } from '@atlaskit/media-ui';
4
4
  export var getErrorMessage = function getErrorMessage(status) {
5
5
  return status === 'error' && /*#__PURE__*/React.createElement(FormattedMessage, messages.failed_to_load);
@@ -1,4 +1,4 @@
1
- import { isErrorFileState } from '@atlaskit/media-client';
1
+ import { isErrorFileState, isFileIdentifier } from '@atlaskit/media-client';
2
2
 
3
3
  var getProcessingStatusFromFileState = function getProcessingStatusFromFileState(status) {
4
4
  switch (status) {
@@ -13,8 +13,8 @@ var getProcessingStatusFromFileState = function getProcessingStatusFromFileState
13
13
  }
14
14
  };
15
15
 
16
- export var getFileDetails = function getFileDetails(state) {
17
- return !isErrorFileState(state) ? {
16
+ var getFileDetailsFromFileState = function getFileDetailsFromFileState(state) {
17
+ return {
18
18
  id: state.id,
19
19
  name: state.name,
20
20
  size: state.size,
@@ -22,7 +22,15 @@ export var getFileDetails = function getFileDetails(state) {
22
22
  createdAt: state.createdAt,
23
23
  mediaType: state.mediaType,
24
24
  processingStatus: getProcessingStatusFromFileState(state.status)
25
+ };
26
+ };
27
+
28
+ export var getFileDetails = function getFileDetails(identifier, fileState) {
29
+ return isFileIdentifier(identifier) ? fileState && !isErrorFileState(fileState) ? getFileDetailsFromFileState(fileState) : {
30
+ id: identifier.id
25
31
  } : {
26
- id: state.id
32
+ id: identifier.mediaItemType,
33
+ name: identifier.name || identifier.dataURI,
34
+ mediaType: 'image'
27
35
  };
28
36
  };
@@ -73,6 +73,12 @@ export var ObjectURLCache = /*#__PURE__*/function () {
73
73
  value: function set(key, value) {
74
74
  this.cache.set(key, value);
75
75
  }
76
+ }, {
77
+ key: "remove",
78
+ value: function remove(key) {
79
+ var removed = this.cache.remove(key);
80
+ removed && URL.revokeObjectURL(removed.dataURI);
81
+ }
76
82
  }]);
77
83
 
78
84
  return ObjectURLCache;
@@ -5,7 +5,7 @@ export var shouldDisplayImageThumbnail = function shouldDisplayImageThumbnail(ca
5
5
  }
6
6
 
7
7
  if (dataURI) {
8
- return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete';
8
+ return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete' || cardStatus === 'loading-preview';
9
9
  }
10
10
 
11
11
  return false;
@@ -4,8 +4,28 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
 
5
5
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6
6
 
7
- import React, { useEffect } from 'react';
8
- import { LazyContent } from './lazyContent';
7
+ import React, { useEffect, forwardRef } from 'react';
8
+ /**
9
+ * As IntersectionObserver::rootMargin doesn't work within IFrames, we use an empty div + dynamic offsetTop to eagerly detect cards entering viewport.
10
+ * Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
11
+ */
12
+
13
+ export var ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
14
+
15
+ export var ViewportAnchor = /*#__PURE__*/forwardRef(function (props, ref) {
16
+ if (typeof IntersectionObserver === 'undefined') {
17
+ return null;
18
+ }
19
+
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ ref: ref,
22
+ className: "media-card-viewport-anchor",
23
+ style: {
24
+ position: 'absolute',
25
+ top: "".concat(props.offsetTop, "px")
26
+ }
27
+ });
28
+ });
9
29
 
10
30
  var createIntersectionObserverCallback = function createIntersectionObserverCallback(onVisible) {
11
31
  return function (entries, observer) {
@@ -30,33 +50,40 @@ var createIntersectionObserverCallback = function createIntersectionObserverCall
30
50
  };
31
51
  };
32
52
 
33
- var Observer = function Observer(_ref) {
53
+ var ViewportObserver = function ViewportObserver(_ref) {
34
54
  var onVisible = _ref.onVisible,
55
+ cardEl = _ref.cardEl,
35
56
  children = _ref.children,
36
- targetRef = _ref.targetRef;
57
+ preAnchorRef = _ref.preAnchorRef,
58
+ postAnchorRef = _ref.postAnchorRef;
37
59
  useEffect(function () {
38
60
  // IntersectionObserver uses root and target elements to detect intersections, defaulting root to the viewport
39
61
  var intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible));
40
- targetRef && intersectionObserver.observe(targetRef);
62
+ (preAnchorRef === null || preAnchorRef === void 0 ? void 0 : preAnchorRef.current) && intersectionObserver.observe(preAnchorRef.current);
63
+ (postAnchorRef === null || postAnchorRef === void 0 ? void 0 : postAnchorRef.current) && intersectionObserver.observe(postAnchorRef.current);
64
+ cardEl && intersectionObserver.observe(cardEl);
41
65
  return function () {
42
66
  intersectionObserver.disconnect();
43
67
  };
44
- }, [targetRef, onVisible]);
68
+ }, [cardEl, preAnchorRef, postAnchorRef, onVisible]);
45
69
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
46
70
  };
47
71
 
48
- export var createViewportDetector = function createViewportDetector(isIntersectionObserverSupported) {
49
- return function (_ref2) {
50
- var children = _ref2.children,
51
- targetRef = _ref2.targetRef,
52
- onVisible = _ref2.onVisible;
53
- return isIntersectionObserverSupported ? /*#__PURE__*/React.createElement(Observer, {
54
- targetRef: targetRef,
55
- onVisible: onVisible
56
- }, children) : /*#__PURE__*/React.createElement(LazyContent, {
57
- placeholder: /*#__PURE__*/React.createElement(React.Fragment, null, children),
58
- onRender: onVisible
59
- }, children);
60
- };
61
- };
62
- export var ViewportDetector = createViewportDetector(typeof IntersectionObserver !== 'undefined');
72
+ export var ViewportDetector = function ViewportDetector(_ref2) {
73
+ var cardEl = _ref2.cardEl,
74
+ preAnchorRef = _ref2.preAnchorRef,
75
+ postAnchorRef = _ref2.postAnchorRef,
76
+ onVisible = _ref2.onVisible,
77
+ children = _ref2.children;
78
+
79
+ if (typeof IntersectionObserver === 'undefined') {
80
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
81
+ }
82
+
83
+ return /*#__PURE__*/React.createElement(ViewportObserver, {
84
+ cardEl: cardEl,
85
+ preAnchorRef: preAnchorRef,
86
+ postAnchorRef: postAnchorRef,
87
+ onVisible: onVisible
88
+ }, children);
89
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "71.0.0",
3
+ "version": "73.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,9 @@
1
- export declare type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | 'preview-fetch';
1
+ import { CardPreview } from '.';
2
+ export declare type MediaCardErrorPrimaryReason = 'upload' | 'metadata-fetch' | 'error-file-state' | RemotePreviewPrimaryReason | LocalPreviewPrimaryReason | ImageLoadPrimaryReason | SsrPreviewPrimaryReason | 'preview-fetch';
3
+ export declare type ImageLoadPrimaryReason = 'cache-remote-uri' | 'cache-local-uri' | 'local-uri' | 'remote-uri' | 'external-uri' | 'unknown-uri';
2
4
  export declare type RemotePreviewPrimaryReason = 'remote-preview-fetch' | 'remote-preview-not-ready';
3
5
  export declare type LocalPreviewPrimaryReason = 'local-preview-get' | 'local-preview-unsupported' | 'local-preview-rejected' | 'local-preview-image' | 'local-preview-video';
6
+ export declare type SsrPreviewPrimaryReason = 'ssr-client-uri' | 'ssr-client-load' | 'ssr-server-uri' | 'ssr-server-load';
4
7
  export declare class MediaCardError extends Error {
5
8
  readonly primaryReason: MediaCardErrorPrimaryReason;
6
9
  readonly secondaryError?: Error | undefined;
@@ -16,8 +19,19 @@ export declare class RemotePreviewError extends MediaCardError {
16
19
  readonly secondaryError?: Error | undefined;
17
20
  constructor(primaryReason: RemotePreviewPrimaryReason, secondaryError?: Error | undefined);
18
21
  }
22
+ export declare class SsrPreviewError extends MediaCardError {
23
+ readonly primaryReason: SsrPreviewPrimaryReason;
24
+ readonly secondaryError?: Error | undefined;
25
+ constructor(primaryReason: SsrPreviewPrimaryReason, secondaryError?: Error | undefined);
26
+ }
27
+ export declare const getImageLoadPrimaryReason: (source?: "local" | "remote" | "ssr-server" | "ssr-client" | "cache-local" | "cache-remote" | "cache-ssr-client" | "cache-ssr-server" | "external" | undefined) => ImageLoadPrimaryReason;
28
+ export declare class ImageLoadError extends MediaCardError {
29
+ constructor(source?: CardPreview['source']);
30
+ }
19
31
  export declare function isMediaCardError(err: Error): err is MediaCardError;
20
32
  export declare const isLocalPreviewError: (err: Error) => err is LocalPreviewError;
21
33
  export declare const isRemotePreviewError: (err: Error) => err is LocalPreviewError;
22
34
  export declare const isUnsupportedLocalPreviewError: (err: Error) => boolean;
35
+ export declare function isImageLoadError(err: Error): err is ImageLoadError;
23
36
  export declare const ensureMediaCardError: (primaryReason: MediaCardErrorPrimaryReason, error: Error) => MediaCardError;
37
+ export declare const isUploadError: (error?: MediaCardError | undefined) => boolean | undefined;
@@ -1,11 +1,7 @@
1
- import React from 'react';
2
1
  import { Component, ReactNode } from 'react';
3
2
  import { MediaItemType, MediaType, ImageResizeMode } from '@atlaskit/media-client';
4
3
  import { CardDimensions, CardStatus } from '../../index';
5
4
  import { CardAction } from '../../actions';
6
- import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
7
- import { RenderEventAction } from '../../utils/analytics';
8
- import { WithFileAttributesProps } from '../../utils/fileAttributesContext';
9
5
  export interface FileCardImageViewProps {
10
6
  readonly mediaName?: string;
11
7
  readonly mediaType?: MediaType;
@@ -25,15 +21,14 @@ export interface FileCardImageViewProps {
25
21
  readonly actions?: CardAction[];
26
22
  readonly onDisplayImage?: () => void;
27
23
  readonly previewOrientation?: number;
28
- readonly timeElapsedTillCommenced?: number;
24
+ readonly onImageError?: () => void;
25
+ readonly onImageLoad?: () => void;
29
26
  }
30
27
  export declare const fileCardImageViewSelector = "media-file-card-view";
31
28
  export declare const fileCardImageViewSelectedSelector = "media-file-card-view-selected";
32
- export declare type FileCardImageViewBaseProps = FileCardImageViewProps & WithAnalyticsEventsProps & WithFileAttributesProps;
33
- export declare class FileCardImageViewBase extends Component<FileCardImageViewBaseProps> {
29
+ export declare class FileCardImageView extends Component<FileCardImageViewProps> {
34
30
  private wasThumbnailDisplayed;
35
- private lastAnalyticsAction;
36
- static defaultProps: Partial<FileCardImageViewBaseProps>;
31
+ static defaultProps: Partial<FileCardImageViewProps>;
37
32
  render(): JSX.Element;
38
33
  private renderCardContents;
39
34
  private renderLoadingContents;
@@ -41,10 +36,7 @@ export declare class FileCardImageViewBase extends Component<FileCardImageViewBa
41
36
  private renderFailedContents;
42
37
  private renderUploadingCardOverlay;
43
38
  private renderPlayButton;
44
- onImageLoad: () => void;
45
- onImageError: () => void;
46
39
  private renderMediaImage;
47
- shouldFireEvent: (action: RenderEventAction) => boolean;
48
40
  private renderProgressBar;
49
41
  private renderSuccessCardContents;
50
42
  private renderSuccessCardOverlay;
@@ -52,4 +44,3 @@ export declare class FileCardImageViewBase extends Component<FileCardImageViewBa
52
44
  private get isCropped();
53
45
  private get isStretched();
54
46
  }
55
- export declare const FileCardImageView: React.ForwardRefExoticComponent<Pick<React.PropsWithChildren<FileCardImageViewProps & WithAnalyticsEventsProps>, "progress" | "error" | "alt" | "dimensions" | "resizeMode" | "mediaType" | "mimeType" | "children" | "actions" | "mediaName" | "selectable" | "selected" | "disableOverlay" | "fileSize" | "dataURI" | "status" | "mediaItemType" | "onDisplayImage" | "previewOrientation" | "timeElapsedTillCommenced"> & React.RefAttributes<any>>;
@@ -6,7 +6,7 @@ export interface WrapperProps {
6
6
  hasOnClick?: boolean;
7
7
  mediaType?: string;
8
8
  }
9
- export declare const Wrapper: import("styled-components").StyledComponentClass<import("react").HTMLAttributes<{}> & WrapperProps, any, Pick<import("react").HTMLAttributes<{}>, "dir" | "slot" | "style" | "title" | "id" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css"> & {
9
+ export declare const Wrapper: import("styled-components").StyledComponentClass<import("react").HTMLAttributes<{}> & WrapperProps, any, Pick<import("react").HTMLAttributes<{}>, "style" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "css"> & {
10
10
  theme?: any;
11
11
  } & WrapperProps>;
12
12
  export declare const PlayIconWrapper: import("styled-components").StyledComponentClass<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
@@ -1,2 +1,2 @@
1
- export { FileCardImageView, FileCardImageViewBase } from './cardImageView';
1
+ export { FileCardImageView } from './cardImageView';
2
2
  export type { FileCardImageViewProps } from './cardImageView';
@@ -1,18 +1,17 @@
1
1
  import { MouseEvent } from 'react';
2
2
  import { FileDetails, MediaClient, Identifier, ImageResizeMode, FileState } from '@atlaskit/media-client';
3
3
  import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
4
- import { MediaFeatureFlags, NumericalCardDimensions } from '@atlaskit/media-common';
4
+ import { MediaFeatureFlags, NumericalCardDimensions, SSR } from '@atlaskit/media-common';
5
5
  import { CardAction } from './actions';
6
6
  import { MediaViewerDataSource } from '@atlaskit/media-viewer';
7
- import { CardPreview } from './root/card/getCardPreview';
8
- import { CardStatus, CardAppearance } from './types';
7
+ import { CardPreview, CardStatus, CardAppearance } from './types';
9
8
  import { MediaCardError } from './errors';
10
9
  import { CardDimensions } from './utils';
11
10
  export type { CardDimensions } from './utils';
12
11
  export type { NumericalCardDimensions } from '@atlaskit/media-common';
13
12
  export { Card, MediaInlineCard } from './root';
14
13
  export type { CardAction, CardEventHandler } from './actions';
15
- export type { CardStatus, CardAppearance, CardDimensionValue } from './types';
14
+ export type { CardStatus, CardAppearance, CardDimensionValue, CardPreview, } from './types';
16
15
  export declare type TitleBoxIcon = 'LockFilledIcon';
17
16
  export interface CardEvent {
18
17
  event: MouseEvent<HTMLElement>;
@@ -49,10 +48,12 @@ export interface CardProps extends SharedCardProps, CardEventProps {
49
48
  readonly mediaViewerDataSource?: MediaViewerDataSource;
50
49
  readonly contextId?: string;
51
50
  readonly shouldEnableDownloadButton?: boolean;
51
+ readonly ssr?: SSR;
52
52
  }
53
53
  export interface CardState {
54
54
  status: CardStatus;
55
55
  isCardVisible: boolean;
56
+ shouldAutoplay?: boolean;
56
57
  isPlayingFile: boolean;
57
58
  mediaViewerSelectedItem?: Identifier;
58
59
  fileState?: FileState;
@@ -60,6 +61,8 @@ export interface CardState {
60
61
  cardPreview?: CardPreview;
61
62
  error?: MediaCardError;
62
63
  cardRef: HTMLDivElement | null;
64
+ isBannedLocalPreview: boolean;
65
+ previewDidRender: boolean;
63
66
  }
64
67
  export { CardLoading } from './utils/lightCards/cardLoading';
65
68
  export { CardError } from './utils/lightCards/cardError';
@@ -1,14 +1,9 @@
1
1
  import { FileAttributes, MediaFeatureFlags, PerformanceAttributes } from '@atlaskit/media-common';
2
2
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
3
  import { CardStatus } from '../..';
4
- import { CardPreview } from './getCardPreview';
5
4
  import { MediaCardError } from './../../errors';
6
5
  export declare const relevantFeatureFlagNames: Array<keyof MediaFeatureFlags>;
7
- export declare type FireOperationalEventParams = {
8
- cardPreview?: CardPreview;
9
- error?: MediaCardError;
10
- };
11
- export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, { cardPreview, error }?: FireOperationalEventParams) => void;
6
+ export declare const fireOperationalEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, status: CardStatus, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes, error?: MediaCardError | undefined) => void;
12
7
  export declare const fireCommencedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => void;
13
8
  export declare const fireCopiedEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileId: string, cardRef: HTMLDivElement) => void;
14
9
  export declare const fireScreenEvent: (createAnalyticsEvent: CreateUIAnalyticsEvent, fileAttributes: FileAttributes) => void;
@@ -1,20 +1,6 @@
1
1
  import React from 'react';
2
- import { WithMediaClientConfigProps } from '@atlaskit/media-client';
3
- import { MediaCardAnalyticsErrorBoundaryProps } from '../media-card-analytics-error-boundary';
4
- import { CardWithAnalyticsEventsProps } from '.';
5
- export declare type CardWithMediaClientConfigProps = WithMediaClientConfigProps<CardWithAnalyticsEventsProps>;
6
- declare type CardWithMediaClientConfigComponent = React.ComponentType<CardWithMediaClientConfigProps>;
7
- declare type MediaCardErrorBoundaryComponent = React.ComponentType<MediaCardAnalyticsErrorBoundaryProps>;
8
- export interface AsyncCardState {
9
- Card?: CardWithMediaClientConfigComponent;
10
- MediaCardErrorBoundary?: MediaCardErrorBoundaryComponent;
11
- }
12
- export default class CardLoader extends React.PureComponent<CardWithMediaClientConfigProps & AsyncCardState, AsyncCardState> {
13
- static displayName: string;
14
- static Card?: CardWithMediaClientConfigComponent;
15
- static MediaCardErrorBoundary?: MediaCardErrorBoundaryComponent;
16
- state: AsyncCardState;
17
- componentDidMount(): Promise<void>;
18
- render(): JSX.Element;
19
- }
20
- export {};
2
+ import type { WithMediaClientConfigProps } from '@atlaskit/media-client';
3
+ import type { CardBaseProps } from '.';
4
+ export declare type CardWithMediaClientConfigProps = WithMediaClientConfigProps<CardBaseProps>;
5
+ declare const CardLoader: React.FC<CardWithMediaClientConfigProps>;
6
+ export default CardLoader;
@@ -0,0 +1,5 @@
1
+ import { FileState } from '@atlaskit/media-client';
2
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
3
+ import { CardState } from '../..';
4
+ export declare const createStateUpdater: (newState: Partial<CardState>) => (prevState: CardState) => Pick<CardState, keyof CardState>;
5
+ export declare const getCardStateFromFileState: (fileState: FileState, isBannedLocalPreview: boolean, featureFlags?: MediaFeatureFlags | undefined) => Partial<CardState>;
@@ -1,16 +1,18 @@
1
1
  import { ObjectURLCache } from '../../../utils/objectURLCache';
2
2
  import { CardDimensions } from '../../../utils/cardDimensions';
3
- import { CardPreview } from './types';
3
+ import { CardPreview } from '../../../types';
4
4
  export declare const getCacheKey: (id: string, dimensions: CardDimensions) => string;
5
5
  export interface CardPreviewCache {
6
6
  get(id: string, dimensions: CardDimensions): CardPreview | undefined;
7
7
  set(id: string, dimensions: CardDimensions, cardPreview: CardPreview): void;
8
+ remove(id: string, dimensions: CardDimensions): void;
8
9
  }
9
10
  export declare class CardPreviewCacheImpl implements CardPreviewCache {
10
11
  private previewCache;
11
12
  constructor(previewCache: ObjectURLCache);
12
13
  get: (id: string, dimensions: CardDimensions) => CardPreview | undefined;
13
14
  set: (id: string, dimensions: CardDimensions, cardPreview: CardPreview) => void;
15
+ remove: (id: string, dimensions: CardDimensions) => void;
14
16
  }
15
17
  declare const _default: CardPreviewCacheImpl;
16
18
  export default _default;
@@ -0,0 +1,5 @@
1
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
2
+ import { CardStatus, FilePreviewStatus } from '../../../types';
3
+ import { FileState } from '@atlaskit/media-client';
4
+ export declare const extractFilePreviewStatus: (fileState: FileState, isBannedLocalPreview: boolean, featureFlags?: MediaFeatureFlags | undefined) => FilePreviewStatus;
5
+ export declare const isPreviewableStatus: (cardStatus: CardStatus, { isPreviewable, hasPreview, isSupportedByBrowser }: FilePreviewStatus) => boolean;
@@ -1,10 +1,9 @@
1
- import { MediaClient, FilePreview } from '@atlaskit/media-client';
2
- import { NumericalCardDimensions } from '../../..';
3
- import { CardPreview } from './types';
1
+ import { MediaClient, FilePreview, MediaStoreGetFileImageParams } from '@atlaskit/media-client';
2
+ import { CardPreview } from '../../../types';
4
3
  /**
5
4
  * This method tells the support for the media
6
5
  * types covered in getCardPreviewFromFilePreview
7
6
  */
8
7
  export declare const isSupportedLocalPreview: (mediaType?: "audio" | "video" | "image" | "doc" | "archive" | "unknown" | undefined) => boolean;
9
8
  export declare const getCardPreviewFromFilePreview: (filePreview: FilePreview | Promise<FilePreview>) => Promise<CardPreview>;
10
- export declare const getCardPreviewFromBackend: (mediaClient: MediaClient, id: string, { width, height }: NumericalCardDimensions, collectionName?: string | undefined, resizeMode?: "crop" | "fit" | "full-fit" | "stretchy-fit" | undefined) => Promise<CardPreview>;
9
+ export declare const getCardPreviewFromBackend: (mediaClient: MediaClient, id: string, params: MediaStoreGetFileImageParams) => Promise<CardPreview>;