@atlaskit/media-card 72.0.0 → 73.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/cjs/actions.js +2 -2
  3. package/dist/cjs/errors.js +35 -11
  4. package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
  5. package/dist/cjs/files/cardImageView/index.js +1 -1
  6. package/dist/cjs/files/cardImageView/styled.js +1 -1
  7. package/dist/cjs/index.js +8 -8
  8. package/dist/cjs/root/card/cardAnalytics.js +2 -2
  9. package/dist/cjs/root/card/cardLoader.js +66 -124
  10. package/dist/cjs/root/card/cardState.js +2 -2
  11. package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
  12. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
  13. package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
  14. package/dist/cjs/root/card/getCardPreview/index.js +101 -18
  15. package/dist/cjs/root/card/getCardStatus.js +1 -1
  16. package/dist/cjs/root/card/index.js +191 -97
  17. package/dist/cjs/root/cardView.js +44 -57
  18. package/dist/cjs/root/inline/loader.js +45 -14
  19. package/dist/cjs/root/inline/mediaInlineCard.js +31 -11
  20. package/dist/cjs/root/inlinePlayer.js +77 -24
  21. package/dist/cjs/root/styled.js +7 -3
  22. package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
  23. package/dist/cjs/root/ui/blanket/styled.js +1 -1
  24. package/dist/cjs/root/ui/common.js +11 -5
  25. package/dist/cjs/root/ui/iconMessage/index.js +5 -3
  26. package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
  27. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +6 -2
  28. package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
  29. package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
  30. package/dist/cjs/root/ui/playButton/styled.js +1 -1
  31. package/dist/cjs/root/ui/progressBar/progressBar.js +7 -4
  32. package/dist/cjs/root/ui/progressBar/styled.js +8 -9
  33. package/dist/cjs/root/ui/styled.js +80 -17
  34. package/dist/cjs/root/ui/tickBox/styled.js +1 -1
  35. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
  36. package/dist/cjs/root/ui/titleBox/styled.js +2 -4
  37. package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
  38. package/dist/cjs/styles/index.js +25 -23
  39. package/dist/cjs/styles/mixins.js +1 -1
  40. package/dist/cjs/utils/analytics.js +2 -1
  41. package/dist/cjs/utils/breakpoint.js +1 -1
  42. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +18 -9
  43. package/dist/cjs/utils/cardActions/index.js +10 -10
  44. package/dist/cjs/utils/cardActions/styled.js +1 -1
  45. package/dist/cjs/utils/cardDimensions.js +1 -1
  46. package/dist/cjs/utils/getErrorMessage.js +2 -2
  47. package/dist/cjs/utils/index.js +46 -46
  48. package/dist/cjs/utils/lightCards/styled.js +1 -1
  49. package/dist/cjs/utils/objectURLCache.js +1 -1
  50. package/dist/cjs/utils/viewportDetector.js +49 -22
  51. package/dist/cjs/version.json +1 -1
  52. package/dist/es2019/errors.js +9 -1
  53. package/dist/es2019/root/card/cardAnalytics.js +1 -1
  54. package/dist/es2019/root/card/cardLoader.js +47 -53
  55. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
  56. package/dist/es2019/root/card/getCardPreview/index.js +45 -3
  57. package/dist/es2019/root/card/index.js +131 -35
  58. package/dist/es2019/root/cardView.js +26 -40
  59. package/dist/es2019/root/inline/loader.js +15 -4
  60. package/dist/es2019/root/inline/mediaInlineCard.js +30 -10
  61. package/dist/es2019/root/inlinePlayer.js +56 -4
  62. package/dist/es2019/root/styled.js +2 -1
  63. package/dist/es2019/root/ui/common.js +7 -1
  64. package/dist/es2019/root/ui/iconMessage/index.js +3 -2
  65. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +6 -2
  66. package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  67. package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
  68. package/dist/es2019/root/ui/progressBar/progressBar.js +5 -3
  69. package/dist/es2019/root/ui/progressBar/styled.js +7 -6
  70. package/dist/es2019/root/ui/styled.js +65 -4
  71. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
  72. package/dist/es2019/root/ui/titleBox/styled.js +1 -2
  73. package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
  74. package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
  75. package/dist/es2019/utils/getErrorMessage.js +1 -1
  76. package/dist/es2019/utils/viewportDetector.js +48 -18
  77. package/dist/es2019/version.json +1 -1
  78. package/dist/esm/actions.js +2 -2
  79. package/dist/esm/errors.js +28 -9
  80. package/dist/esm/root/card/cardAnalytics.js +1 -1
  81. package/dist/esm/root/card/cardLoader.js +66 -126
  82. package/dist/esm/root/card/cardState.js +2 -2
  83. package/dist/esm/root/card/getCardPreview/cache.js +3 -2
  84. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
  85. package/dist/esm/root/card/getCardPreview/index.js +74 -12
  86. package/dist/esm/root/card/index.js +198 -100
  87. package/dist/esm/root/cardView.js +42 -54
  88. package/dist/esm/root/inline/loader.js +46 -14
  89. package/dist/esm/root/inline/mediaInlineCard.js +30 -10
  90. package/dist/esm/root/inlinePlayer.js +74 -23
  91. package/dist/esm/root/styled.js +3 -2
  92. package/dist/esm/root/ui/common.js +7 -1
  93. package/dist/esm/root/ui/iconMessage/index.js +3 -2
  94. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +6 -2
  95. package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  96. package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
  97. package/dist/esm/root/ui/progressBar/progressBar.js +6 -3
  98. package/dist/esm/root/ui/progressBar/styled.js +7 -7
  99. package/dist/esm/root/ui/styled.js +61 -13
  100. package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
  101. package/dist/esm/root/ui/titleBox/styled.js +1 -2
  102. package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
  103. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +17 -9
  104. package/dist/esm/utils/getErrorMessage.js +1 -1
  105. package/dist/esm/utils/viewportDetector.js +48 -21
  106. package/dist/esm/version.json +1 -1
  107. package/dist/types/errors.d.ts +9 -3
  108. package/dist/types/index.d.ts +3 -1
  109. package/dist/types/root/card/cardLoader.d.ts +5 -19
  110. package/dist/types/root/card/getCardPreview/index.d.ts +7 -1
  111. package/dist/types/root/card/index.d.ts +9 -8
  112. package/dist/types/root/cardView.d.ts +5 -3
  113. package/dist/types/root/inline/loader.d.ts +2 -0
  114. package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
  115. package/dist/types/root/inlinePlayer.d.ts +8 -1
  116. package/dist/types/root/styled.d.ts +1 -0
  117. package/dist/types/root/ui/common.d.ts +4 -1
  118. package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
  119. package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
  120. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +3 -2
  121. package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
  122. package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
  123. package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
  124. package/dist/types/root/ui/progressBar/progressBar.d.ts +4 -2
  125. package/dist/types/root/ui/progressBar/styled.d.ts +3 -2
  126. package/dist/types/root/ui/styled.d.ts +10 -3
  127. package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
  128. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -3
  129. package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
  130. package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
  131. package/dist/types/types.d.ts +1 -1
  132. package/dist/types/utils/getErrorMessage.d.ts +1 -0
  133. package/dist/types/utils/viewportDetector.d.ts +13 -5
  134. package/example-helpers/developmentUseMessage.tsx +14 -0
  135. package/example-helpers/index.tsx +34 -4
  136. package/example-helpers/selectableCard.tsx +2 -1
  137. package/package.json +16 -15
  138. package/dist/cjs/root/card/cardSSRView.js +0 -114
  139. package/dist/cjs/root/ui/Breakpoint.js +0 -13
  140. package/dist/cjs/root/ui/styledSSR.js +0 -108
  141. package/dist/cjs/utils/lazyContent/index.js +0 -56
  142. package/dist/cjs/utils/lazyContent/styled.js +0 -23
  143. package/dist/es2019/root/card/cardSSRView.js +0 -93
  144. package/dist/es2019/root/ui/Breakpoint.js +0 -6
  145. package/dist/es2019/root/ui/styledSSR.js +0 -93
  146. package/dist/es2019/utils/lazyContent/index.js +0 -18
  147. package/dist/es2019/utils/lazyContent/styled.js +0 -12
  148. package/dist/esm/root/card/cardSSRView.js +0 -92
  149. package/dist/esm/root/ui/Breakpoint.js +0 -6
  150. package/dist/esm/root/ui/styledSSR.js +0 -76
  151. package/dist/esm/utils/lazyContent/index.js +0 -41
  152. package/dist/esm/utils/lazyContent/styled.js +0 -14
  153. package/dist/types/root/card/cardSSRView.d.ts +0 -13
  154. package/dist/types/root/ui/Breakpoint.d.ts +0 -4
  155. package/dist/types/root/ui/styledSSR.d.ts +0 -16
  156. package/dist/types/utils/lazyContent/index.d.ts +0 -11
  157. package/dist/types/utils/lazyContent/styled.d.ts +0 -5
@@ -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,13 @@ export class InlinePlayerBase extends Component {
171
215
  selected,
172
216
  testId,
173
217
  identifier,
174
- forwardRef
218
+ forwardRef,
219
+ autoplay
175
220
  } = this.props;
176
221
  const {
177
- fileSrc
222
+ fileSrc,
223
+ isUploading,
224
+ progress
178
225
  } = this.state;
179
226
 
180
227
  if (!fileSrc) {
@@ -195,7 +242,7 @@ export class InlinePlayerBase extends Component {
195
242
  type: "video",
196
243
  src: fileSrc,
197
244
  fileId: identifier.id,
198
- isAutoPlay: true,
245
+ isAutoPlay: autoplay,
199
246
  isHDAvailable: false,
200
247
  onDownloadClick: this.onDownloadClick,
201
248
  onFirstPlay: this.onFirstPlay,
@@ -204,7 +251,12 @@ export class InlinePlayerBase extends Component {
204
251
  },
205
252
  originalDimensions: originalDimensions,
206
253
  showControls: checkMouseMovement
207
- })));
254
+ })), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
255
+ progress: progress,
256
+ breakpoint: this.breakpoint,
257
+ positionBottom: true,
258
+ showOnTop: true
259
+ }) : null);
208
260
  }
209
261
 
210
262
  }
@@ -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``;
@@ -1,4 +1,10 @@
1
- import { Breakpoint } from './Breakpoint';
1
+ export let Breakpoint;
2
+
3
+ (function (Breakpoint) {
4
+ Breakpoint["SMALL"] = "small";
5
+ Breakpoint["LARGE"] = "large";
6
+ })(Breakpoint || (Breakpoint = {}));
7
+
2
8
  export const responsiveSettings = {
3
9
  [Breakpoint.SMALL]: {
4
10
  fontSize: 11,
@@ -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
@@ -10,7 +10,9 @@ export const ImageRenderer = ({
10
10
  onImageLoad,
11
11
  onImageError,
12
12
  onDisplayImage,
13
- mediaType
13
+ mediaType,
14
+ nativeLazyLoad,
15
+ forceSyncDisplay
14
16
  }) => {
15
17
  useEffect(() => {
16
18
  // TODO: trigger accordingly with the succeeded event. This could be a breaking change
@@ -23,6 +25,8 @@ export const ImageRenderer = ({
23
25
  alt: alt,
24
26
  previewOrientation: previewOrientation,
25
27
  onImageLoad: onImageLoad,
26
- onImageError: onImageError
28
+ onImageError: onImageError,
29
+ loading: nativeLazyLoad ? 'lazy' : undefined,
30
+ forceSyncDisplay: forceSyncDisplay
27
31
  }, resizeModeToMediaImageProps(resizeMode)));
28
32
  };
@@ -1,9 +1,10 @@
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 { Breakpoint } from '../Breakpoint';
6
+ import { FormattedMessage } from 'react-intl-next';
7
+ import { Breakpoint } from '../common';
7
8
  export const LoadingRateLimited = ({
8
9
  breakpoint = Breakpoint.SMALL,
9
10
  positionBottom = true
@@ -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';
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import { StyledBar } from './styled';
3
- import { Breakpoint } from '../Breakpoint';
3
+ 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
  };
@@ -2,8 +2,7 @@ import styled from 'styled-components';
2
2
  import { borderRadius } from '@atlaskit/media-ui';
3
3
  import { rgba } from '../../../styles/mixins';
4
4
  import { N0, N400 } from '@atlaskit/theme/colors';
5
- import { getTitleBoxHeight, responsiveSettings } from '../common';
6
- import { Breakpoint } from '../Breakpoint';
5
+ import { Breakpoint, getTitleBoxHeight, responsiveSettings } from '../common';
7
6
  const height = 3;
8
7
  const padding = 1;
9
8
  const width = 95; // %
@@ -16,19 +15,20 @@ const smallSizeSettings = {
16
15
  const largeSizeSettings = {
17
16
  marginBottom: 12
18
17
  };
19
- export function generateResponsiveStyles(breakpoint, positionBottom, multiplier = 1) {
18
+ export function generateResponsiveStyles(breakpoint, positionBottom, showOnTop, multiplier = 1) {
20
19
  const setting = breakpoint === Breakpoint.SMALL ? smallSizeSettings : largeSizeSettings;
21
20
  const marginPositionBottom = responsiveSettings[breakpoint].titleBox.verticalPadding;
22
21
  const marginBottom = setting.marginBottom * multiplier + (positionBottom ? marginPositionBottom : getTitleBoxHeight(breakpoint));
23
22
  return `
24
- bottom: ${marginBottom}px
23
+ ${showOnTop ? 'top' : 'bottom'}: ${marginBottom}px
25
24
  `;
26
25
  }
27
26
  export const StyledBar = styled.div`
28
27
  ${({
29
28
  progress,
30
29
  breakpoint,
31
- positionBottom
30
+ positionBottom,
31
+ showOnTop
32
32
  }) => `
33
33
  ${borderRadius}
34
34
  overflow: hidden;
@@ -38,6 +38,7 @@ export const StyledBar = styled.div`
38
38
  background-color: ${rgba(N0, 0.8)};
39
39
  height: ${height + padding * 2}px;
40
40
  padding: ${padding}px;
41
+ box-sizing: border-box;
41
42
 
42
43
  ::before {
43
44
  content: '';
@@ -48,7 +49,7 @@ export const StyledBar = styled.div`
48
49
  display: block;
49
50
  }
50
51
 
51
- ${generateResponsiveStyles(breakpoint, positionBottom)}
52
+ ${generateResponsiveStyles(breakpoint, positionBottom, showOnTop)}
52
53
  `}
53
54
  `;
54
55
  StyledBar.displayName = 'StyledProgressBar';
@@ -1,11 +1,30 @@
1
1
  import styled from 'styled-components';
2
2
  import { getCSSUnitValue } from '../../utils/getCSSUnitValue';
3
3
  import { getDefaultCardDimensions } from '../../utils/cardDimensions';
4
+ import { fontFamily } from '@atlaskit/theme/constants';
5
+ import { borderRadius } from '@atlaskit/media-ui';
6
+ import { N20, N60A } from '@atlaskit/theme/colors';
7
+ import { akEditorSelectedBoxShadow } from '@atlaskit/editor-shared-styles/consts';
4
8
  import { hideNativeBrowserTextSelectionStyles } from '@atlaskit/editor-shared-styles/selection';
9
+ import { transition } from '../../styles';
5
10
  import { tickBoxClassName, tickboxFixedStyles } from './tickBox/styled';
11
+ import { fixedBlanketStyles, blanketClassName } from './blanket/styled';
6
12
  import { fixedActionBarStyles, actionsBarClassName } from './actionsBar/styled';
7
13
  import { fixedPlayButtonStyles, playButtonClassName } from './playButton/styled';
8
- import { SSRFileExperienceWrapper } from './styledSSR';
14
+ import { Breakpoint, responsiveSettings } from './common';
15
+ const breakpointSizes = [[Breakpoint.SMALL, 599], [Breakpoint.LARGE, Infinity]];
16
+ export const calcBreakpointSize = (wrapperWidth = 0) => {
17
+ const [breakpoint] = breakpointSizes.find(([_breakpoint, limit]) => wrapperWidth <= limit) || [Breakpoint.SMALL];
18
+ return breakpoint;
19
+ };
20
+
21
+ const generateResponsiveStyles = (breakpoint = Breakpoint.SMALL) => {
22
+ const setting = responsiveSettings[breakpoint];
23
+ return `
24
+ font-size: ${setting.fontSize}px;
25
+ line-height: ${setting.lineHeight}px;
26
+ `;
27
+ };
9
28
 
10
29
  const getWrapperDimensions = (dimensions, appearance) => {
11
30
  const {
@@ -22,8 +41,19 @@ const getWrapperDimensions = (dimensions, appearance) => {
22
41
  height: ${getCSSUnitValue(height || defaultHeight)};
23
42
  max-height: 100%;
24
43
  `;
44
+ }; // This is a trick to simulate the blue border without affecting the dimensions.
45
+ // CSS outline has no 'radius', therefore we can't achieve the same effect with it
46
+
47
+
48
+ const getWrapperShadow = (disableOverlay, selected) => {
49
+ const withOverlayShadow = !disableOverlay ? `0 1px 1px ${N60A}, 0 0 1px 0 ${N60A}` : '';
50
+ const selectedShadow = selected ? akEditorSelectedBoxShadow : '';
51
+ const shadow = [selectedShadow, withOverlayShadow].filter(Boolean).join(', ');
52
+ return shadow ? `box-shadow: ${shadow};` : '';
25
53
  };
26
54
 
55
+ const getCursorStyle = shouldUsePointerCursor => `cursor: ${shouldUsePointerCursor ? 'pointer' : 'default'};`;
56
+
27
57
  const getClickablePlayButtonStyles = isPlayButtonClickable => {
28
58
  if (!isPlayButtonClickable) {
29
59
  return '';
@@ -48,26 +78,57 @@ const getSelectableTickBoxStyles = isTickBoxSelectable => {
48
78
  `;
49
79
  };
50
80
 
51
- export const NewFileExperienceWrapper = styled(SSRFileExperienceWrapper)`
81
+ export const NewFileExperienceWrapper = styled.div`
52
82
  ${({
83
+ breakpoint,
53
84
  dimensions,
54
85
  appearance,
86
+ shouldUsePointerCursor,
87
+ disableOverlay,
88
+ displayBackground,
89
+ selected,
55
90
  isPlayButtonClickable,
56
91
  isTickBoxSelectable,
57
92
  shouldDisplayTooltip
58
93
  }) => `
94
+ ${transition()}
95
+ box-sizing: border-box;
96
+ * {
97
+ box-sizing: border-box;
98
+ }
99
+ position: relative;
100
+ font-family: ${fontFamily()};
101
+ ${getWrapperDimensions(dimensions, appearance)}
102
+ ${displayBackground ? `background-color: ${N20};` : ''}
103
+ ${borderRadius}
104
+ ${getCursorStyle(shouldUsePointerCursor)}
105
+ ${getWrapperShadow(disableOverlay, selected)}
106
+ ${generateResponsiveStyles(breakpoint)}
59
107
  ${hideNativeBrowserTextSelectionStyles}
60
108
 
61
109
  /* We use classnames from here exceptionally to be able to handle styles when the Card is on hover */
62
110
  ${getClickablePlayButtonStyles(isPlayButtonClickable)}
63
111
  ${getSelectableTickBoxStyles(isTickBoxSelectable)}
112
+ &:hover .${blanketClassName} {
113
+ ${fixedBlanketStyles}
114
+ }
64
115
 
65
116
  &:hover .${actionsBarClassName} {
66
117
  ${fixedActionBarStyles}
67
118
  }
68
119
 
69
120
  /* Tooltip does not support percentage dimensions. We enforce them here */
70
- ${shouldDisplayTooltip ? `> div { ${getWrapperDimensions(dimensions, appearance)} }` : ''}
121
+ ${shouldDisplayTooltip ? `> div { width: 100%; height: 100% }` : ''}
71
122
  `}
72
123
  `;
73
- NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
124
+ NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
125
+ export const CardImageContainer = styled.div`
126
+ display: flex;
127
+ position: relative;
128
+ max-width: 100%;
129
+ width: 100%;
130
+ height: 100%;
131
+ max-height: 100%;
132
+ overflow: hidden;
133
+ ${borderRadius}
134
+ `;
@@ -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,5 @@
1
1
  import styled from 'styled-components';
2
- import { responsiveSettings, getTitleBoxHeight } from '../common';
3
- import { Breakpoint } from '../Breakpoint';
2
+ import { responsiveSettings, getTitleBoxHeight, Breakpoint } from '../common';
4
3
  import { N0 } from '@atlaskit/theme/colors';
5
4
  import { rgba } from '../../../styles/mixins';
6
5
 
@@ -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';
@@ -57,14 +57,18 @@ export class CardActionsDropdownMenu extends Component {
57
57
 
58
58
  if (actions.length > 0) {
59
59
  return /*#__PURE__*/React.createElement(DropdownMenu, {
60
- "data-testid": "media-card-actions-menu",
60
+ testId: "media-card-actions-menu",
61
61
  onOpenChange: onOpenChange,
62
- trigger: /*#__PURE__*/React.createElement(CardActionButtonWithAnalytics, {
62
+ trigger: ({
63
+ triggerRef,
64
+ ...providedProps
65
+ }) => /*#__PURE__*/React.createElement(CardActionButtonWithAnalytics, _extends({
63
66
  variant: triggerVariant,
64
67
  style: {
65
68
  color: triggerColor
66
- }
67
- }, /*#__PURE__*/React.createElement(MoreIcon, {
69
+ },
70
+ ref: triggerRef
71
+ }, providedProps), /*#__PURE__*/React.createElement(MoreIcon, {
68
72
  label: "more"
69
73
  }))
70
74
  }, /*#__PURE__*/React.createElement(DropdownItemGroup, null, actions.map(createDropdownItemWithAnalytics)));
@@ -1,4 +1,4 @@
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 const getErrorMessage = status => status === 'error' && /*#__PURE__*/React.createElement(FormattedMessage, messages.failed_to_load);
@@ -1,5 +1,25 @@
1
- import React, { useEffect } from 'react';
2
- import { LazyContent } from './lazyContent';
1
+ import React, { useEffect, forwardRef } from 'react';
2
+ /**
3
+ * As IntersectionObserver::rootMargin doesn't work within IFrames, we use an empty div + dynamic offsetTop to eagerly detect cards entering viewport.
4
+ * Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
5
+ */
6
+
7
+ export const ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
8
+
9
+ export const ViewportAnchor = /*#__PURE__*/forwardRef((props, ref) => {
10
+ if (typeof IntersectionObserver === 'undefined') {
11
+ return null;
12
+ }
13
+
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ ref: ref,
16
+ className: "media-card-viewport-anchor",
17
+ style: {
18
+ position: 'absolute',
19
+ top: `${props.offsetTop}px`
20
+ }
21
+ });
22
+ });
3
23
 
4
24
  const createIntersectionObserverCallback = onVisible => (entries, observer) => {
5
25
  for (let entry of entries) {
@@ -11,31 +31,41 @@ const createIntersectionObserverCallback = onVisible => (entries, observer) => {
11
31
  }
12
32
  };
13
33
 
14
- const Observer = ({
34
+ const ViewportObserver = ({
15
35
  onVisible,
36
+ cardEl,
16
37
  children,
17
- targetRef
38
+ preAnchorRef,
39
+ postAnchorRef
18
40
  }) => {
19
41
  useEffect(() => {
20
42
  // IntersectionObserver uses root and target elements to detect intersections, defaulting root to the viewport
21
43
  const intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible));
22
- targetRef && intersectionObserver.observe(targetRef);
44
+ (preAnchorRef === null || preAnchorRef === void 0 ? void 0 : preAnchorRef.current) && intersectionObserver.observe(preAnchorRef.current);
45
+ (postAnchorRef === null || postAnchorRef === void 0 ? void 0 : postAnchorRef.current) && intersectionObserver.observe(postAnchorRef.current);
46
+ cardEl && intersectionObserver.observe(cardEl);
23
47
  return () => {
24
48
  intersectionObserver.disconnect();
25
49
  };
26
- }, [targetRef, onVisible]);
50
+ }, [cardEl, preAnchorRef, postAnchorRef, onVisible]);
27
51
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
28
52
  };
29
53
 
30
- export const createViewportDetector = isIntersectionObserverSupported => ({
31
- children,
32
- targetRef,
33
- onVisible
34
- }) => isIntersectionObserverSupported ? /*#__PURE__*/React.createElement(Observer, {
35
- targetRef: targetRef,
36
- onVisible: onVisible
37
- }, children) : /*#__PURE__*/React.createElement(LazyContent, {
38
- placeholder: /*#__PURE__*/React.createElement(React.Fragment, null, children),
39
- onRender: onVisible
40
- }, children);
41
- export const ViewportDetector = createViewportDetector(typeof IntersectionObserver !== 'undefined');
54
+ export const ViewportDetector = ({
55
+ cardEl,
56
+ preAnchorRef,
57
+ postAnchorRef,
58
+ onVisible,
59
+ children
60
+ }) => {
61
+ if (typeof IntersectionObserver === 'undefined') {
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
63
+ }
64
+
65
+ return /*#__PURE__*/React.createElement(ViewportObserver, {
66
+ cardEl: cardEl,
67
+ preAnchorRef: preAnchorRef,
68
+ postAnchorRef: postAnchorRef,
69
+ onVisible: onVisible
70
+ }, children);
71
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "72.0.0",
3
+ "version": "73.1.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- 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; }
3
+ 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; }
4
4
 
5
- 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; }
5
+ 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; }
6
6
 
7
7
  export function attachDetailsToActions(actions, details) {
8
8
  return actions.map(function (action) {
@@ -1,3 +1,4 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
3
4
  import _inherits from "@babel/runtime/helpers/inherits";
@@ -32,7 +33,7 @@ export var MediaCardError = /*#__PURE__*/function (_Error) {
32
33
  return _this;
33
34
  }
34
35
 
35
- return MediaCardError;
36
+ return _createClass(MediaCardError);
36
37
  }( /*#__PURE__*/_wrapNativeSuper(Error));
37
38
  export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
38
39
  _inherits(LocalPreviewError, _MediaCardError);
@@ -50,7 +51,7 @@ export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
50
51
  return _this2;
51
52
  }
52
53
 
53
- return LocalPreviewError;
54
+ return _createClass(LocalPreviewError);
54
55
  }(MediaCardError);
55
56
  export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
56
57
  _inherits(RemotePreviewError, _MediaCardError2);
@@ -68,7 +69,25 @@ export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
68
69
  return _this3;
69
70
  }
70
71
 
71
- return RemotePreviewError;
72
+ return _createClass(RemotePreviewError);
73
+ }(MediaCardError);
74
+ export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
75
+ _inherits(SsrPreviewError, _MediaCardError3);
76
+
77
+ var _super4 = _createSuper(SsrPreviewError);
78
+
79
+ function SsrPreviewError(primaryReason, secondaryError) {
80
+ var _this4;
81
+
82
+ _classCallCheck(this, SsrPreviewError);
83
+
84
+ _this4 = _super4.call(this, primaryReason, secondaryError);
85
+ _this4.primaryReason = primaryReason;
86
+ _this4.secondaryError = secondaryError;
87
+ return _this4;
88
+ }
89
+
90
+ return _createClass(SsrPreviewError);
72
91
  }(MediaCardError);
73
92
  export var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
74
93
  switch (source) {
@@ -92,18 +111,18 @@ export var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source
92
111
  return "unknown-uri";
93
112
  }
94
113
  };
95
- export var ImageLoadError = /*#__PURE__*/function (_MediaCardError3) {
96
- _inherits(ImageLoadError, _MediaCardError3);
114
+ export var ImageLoadError = /*#__PURE__*/function (_MediaCardError4) {
115
+ _inherits(ImageLoadError, _MediaCardError4);
97
116
 
98
- var _super4 = _createSuper(ImageLoadError);
117
+ var _super5 = _createSuper(ImageLoadError);
99
118
 
100
119
  function ImageLoadError(source) {
101
120
  _classCallCheck(this, ImageLoadError);
102
121
 
103
- return _super4.call(this, getImageLoadPrimaryReason(source));
122
+ return _super5.call(this, getImageLoadPrimaryReason(source));
104
123
  }
105
124
 
106
- return ImageLoadError;
125
+ return _createClass(ImageLoadError);
107
126
  }(MediaCardError);
108
127
  export function isMediaCardError(err) {
109
128
  return err instanceof MediaCardError;
@@ -126,5 +145,5 @@ export var ensureMediaCardError = function ensureMediaCardError(primaryReason, e
126
145
  return isMediaCardError(error) ? error : new MediaCardError(primaryReason, error);
127
146
  };
128
147
  export var isUploadError = function isUploadError(error) {
129
- return error.primaryReason === 'upload';
148
+ return error && error.primaryReason === 'upload';
130
149
  };
@@ -1,5 +1,5 @@
1
1
  import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../../utils/analytics';
2
- export var relevantFeatureFlagNames = ['newCardExperience', 'captions'];
2
+ export var relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
3
3
  export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) {
4
4
  var fireEvent = function fireEvent(payload) {
5
5
  return fireMediaCardEvent(payload, createAnalyticsEvent);