@atlaskit/media-card 77.1.2 → 77.2.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 (152) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  4. package/dist/cjs/card/useBreakpoint.js +29 -0
  5. package/dist/cjs/card/v2/cardV2.js +3 -5
  6. package/dist/cjs/card/v2/cardV2Loader.js +9 -16
  7. package/dist/cjs/card/v2/cardViewV2.js +5 -22
  8. package/dist/cjs/card/v2/inlinePlayerLazyV2.js +35 -0
  9. package/dist/cjs/card/v2/inlinePlayerV2.js +222 -0
  10. package/dist/cjs/inline/loader.js +1 -1
  11. package/dist/cjs/utils/ufoExperiences.js +1 -1
  12. package/dist/es2019/card/card.js +1 -1
  13. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  14. package/dist/es2019/card/useBreakpoint.js +22 -0
  15. package/dist/es2019/card/v2/cardV2.js +3 -5
  16. package/dist/es2019/card/v2/cardV2Loader.js +10 -17
  17. package/dist/es2019/card/v2/cardViewV2.js +4 -18
  18. package/dist/es2019/card/v2/inlinePlayerLazyV2.js +10 -0
  19. package/dist/es2019/card/v2/inlinePlayerV2.js +164 -0
  20. package/dist/es2019/inline/loader.js +1 -1
  21. package/dist/es2019/utils/ufoExperiences.js +1 -1
  22. package/dist/esm/card/card.js +1 -1
  23. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  24. package/dist/esm/card/useBreakpoint.js +24 -0
  25. package/dist/esm/card/v2/cardV2.js +3 -5
  26. package/dist/esm/card/v2/cardV2Loader.js +9 -16
  27. package/dist/esm/card/v2/cardViewV2.js +7 -24
  28. package/dist/esm/card/v2/inlinePlayerLazyV2.js +23 -0
  29. package/dist/esm/card/v2/inlinePlayerV2.js +212 -0
  30. package/dist/esm/inline/loader.js +1 -1
  31. package/dist/esm/utils/ufoExperiences.js +1 -1
  32. package/dist/types/card/useBreakpoint.d.ts +3 -0
  33. package/dist/types/card/v2/inlinePlayerLazyV2.d.ts +2 -0
  34. package/dist/types/card/v2/inlinePlayerV2.d.ts +23 -0
  35. package/dist/types-ts4.5/card/actions.d.ts +9 -0
  36. package/dist/types-ts4.5/card/card.d.ts +64 -0
  37. package/dist/types-ts4.5/card/cardAnalytics.d.ts +10 -0
  38. package/dist/types-ts4.5/card/cardConstants.d.ts +1 -0
  39. package/dist/types-ts4.5/card/cardLoader.d.ts +6 -0
  40. package/dist/types-ts4.5/card/cardState.d.ts +9 -0
  41. package/dist/types-ts4.5/card/cardSwitcher.d.ts +4 -0
  42. package/dist/types-ts4.5/card/cardView.d.ts +78 -0
  43. package/dist/types-ts4.5/card/classnames.d.ts +2 -0
  44. package/dist/types-ts4.5/card/getCardPreview/cache.d.ts +21 -0
  45. package/dist/types-ts4.5/card/getCardPreview/filePreviewStatus.d.ts +4 -0
  46. package/dist/types-ts4.5/card/getCardPreview/helpers.d.ts +10 -0
  47. package/dist/types-ts4.5/card/getCardPreview/index.d.ts +53 -0
  48. package/dist/types-ts4.5/card/getCardStatus.d.ts +4 -0
  49. package/dist/types-ts4.5/card/index.d.ts +1 -0
  50. package/dist/types-ts4.5/card/inlinePlayer.d.ts +52 -0
  51. package/dist/types-ts4.5/card/inlinePlayerLazy.d.ts +2 -0
  52. package/dist/types-ts4.5/card/inlinePlayerWrapper.d.ts +4 -0
  53. package/dist/types-ts4.5/card/inlinePlayerWrapperStyles.d.ts +6 -0
  54. package/dist/types-ts4.5/card/media-card-analytics-error-boundary.d.ts +14 -0
  55. package/dist/types-ts4.5/card/types.d.ts +13 -0
  56. package/dist/types-ts4.5/card/ui/actionsBar/actionsBar.d.ts +5 -0
  57. package/dist/types-ts4.5/card/ui/actionsBar/actionsBarWrapper.d.ts +4 -0
  58. package/dist/types-ts4.5/card/ui/actionsBar/cardActions/cardActionButton.d.ts +3 -0
  59. package/dist/types-ts4.5/card/ui/actionsBar/cardActions/cardActionIconButton.d.ts +12 -0
  60. package/dist/types-ts4.5/card/ui/actionsBar/cardActions/cardActionsDropdownMenu.d.ts +14 -0
  61. package/dist/types-ts4.5/card/ui/actionsBar/cardActions/cardActionsView.d.ts +16 -0
  62. package/dist/types-ts4.5/card/ui/actionsBar/cardActions/index.d.ts +7 -0
  63. package/dist/types-ts4.5/card/ui/actionsBar/cardActions/styles.d.ts +18 -0
  64. package/dist/types-ts4.5/card/ui/actionsBar/styles.d.ts +6 -0
  65. package/dist/types-ts4.5/card/ui/actionsBar/types.d.ts +10 -0
  66. package/dist/types-ts4.5/card/ui/blanket/blanket.d.ts +6 -0
  67. package/dist/types-ts4.5/card/ui/blanket/styles.d.ts +6 -0
  68. package/dist/types-ts4.5/card/ui/common.d.ts +23 -0
  69. package/dist/types-ts4.5/card/ui/iconMessage/iconMessageWrapper.d.ts +4 -0
  70. package/dist/types-ts4.5/card/ui/iconMessage/index.d.ts +8 -0
  71. package/dist/types-ts4.5/card/ui/iconMessage/styles.d.ts +5 -0
  72. package/dist/types-ts4.5/card/ui/iconMessage/types.d.ts +19 -0
  73. package/dist/types-ts4.5/card/ui/iconWrapper/iconWrapper.d.ts +4 -0
  74. package/dist/types-ts4.5/card/ui/iconWrapper/styles.d.ts +7 -0
  75. package/dist/types-ts4.5/card/ui/iconWrapper/types.d.ts +6 -0
  76. package/dist/types-ts4.5/card/ui/imageRenderer/imageRenderer.d.ts +15 -0
  77. package/dist/types-ts4.5/card/ui/imageRenderer/resizeModeToMediaImageProps.d.ts +5 -0
  78. package/dist/types-ts4.5/card/ui/playButton/playButton.d.ts +2 -0
  79. package/dist/types-ts4.5/card/ui/playButton/playButtonBackground.d.ts +3 -0
  80. package/dist/types-ts4.5/card/ui/playButton/playButtonWrapper.d.ts +3 -0
  81. package/dist/types-ts4.5/card/ui/playButton/styles.d.ts +5 -0
  82. package/dist/types-ts4.5/card/ui/progressBar/progressBar.d.ts +10 -0
  83. package/dist/types-ts4.5/card/ui/progressBar/styledBar.d.ts +4 -0
  84. package/dist/types-ts4.5/card/ui/progressBar/styles.d.ts +7 -0
  85. package/dist/types-ts4.5/card/ui/progressBar/types.d.ts +7 -0
  86. package/dist/types-ts4.5/card/ui/styles.d.ts +13 -0
  87. package/dist/types-ts4.5/card/ui/tickBox/styles.d.ts +7 -0
  88. package/dist/types-ts4.5/card/ui/tickBox/tickBox.d.ts +3 -0
  89. package/dist/types-ts4.5/card/ui/tickBox/tickBoxWrapper.d.ts +4 -0
  90. package/dist/types-ts4.5/card/ui/tickBox/types.d.ts +4 -0
  91. package/dist/types-ts4.5/card/ui/titleBox/failedTitleBox.d.ts +3 -0
  92. package/dist/types-ts4.5/card/ui/titleBox/styles.d.ts +15 -0
  93. package/dist/types-ts4.5/card/ui/titleBox/titleBox.d.ts +4 -0
  94. package/dist/types-ts4.5/card/ui/titleBox/titleBoxComponents.d.ts +8 -0
  95. package/dist/types-ts4.5/card/ui/titleBox/types.d.ts +34 -0
  96. package/dist/types-ts4.5/card/ui/unhandledErrorCard/index.d.ts +7 -0
  97. package/dist/types-ts4.5/card/ui/unhandledErrorCard/types.d.ts +6 -0
  98. package/dist/types-ts4.5/card/ui/wrapper/index.d.ts +1 -0
  99. package/dist/types-ts4.5/card/ui/wrapper/styles.d.ts +5 -0
  100. package/dist/types-ts4.5/card/ui/wrapper/types.d.ts +25 -0
  101. package/dist/types-ts4.5/card/ui/wrapper/wrapper.d.ts +4 -0
  102. package/dist/types-ts4.5/card/useBreakpoint.d.ts +3 -0
  103. package/dist/types-ts4.5/card/v2/cardV2.d.ts +63 -0
  104. package/dist/types-ts4.5/card/v2/cardV2Loader.d.ts +4 -0
  105. package/dist/types-ts4.5/card/v2/cardViewV2.d.ts +44 -0
  106. package/dist/types-ts4.5/card/v2/inlinePlayerLazyV2.d.ts +2 -0
  107. package/dist/types-ts4.5/card/v2/inlinePlayerV2.d.ts +23 -0
  108. package/dist/types-ts4.5/classnames.d.ts +5 -0
  109. package/dist/types-ts4.5/errors.d.ts +53 -0
  110. package/dist/types-ts4.5/index.d.ts +15 -0
  111. package/dist/types-ts4.5/inline/index.d.ts +1 -0
  112. package/dist/types-ts4.5/inline/loader.d.ts +26 -0
  113. package/dist/types-ts4.5/inline/mediaInlineAnalyticsErrorBoundary.d.ts +12 -0
  114. package/dist/types-ts4.5/inline/mediaInlineCard.d.ts +15 -0
  115. package/dist/types-ts4.5/inline/mediaInlineCardAnalytics.d.ts +6 -0
  116. package/dist/types-ts4.5/types.d.ts +105 -0
  117. package/dist/types-ts4.5/utils/analytics.d.ts +101 -0
  118. package/dist/types-ts4.5/utils/cardDimensions.d.ts +14 -0
  119. package/dist/types-ts4.5/utils/containsPixelUnit.d.ts +1 -0
  120. package/dist/types-ts4.5/utils/dimensionComparer.d.ts +3 -0
  121. package/dist/types-ts4.5/utils/document.d.ts +2 -0
  122. package/dist/types-ts4.5/utils/generateUniqueId.d.ts +1 -0
  123. package/dist/types-ts4.5/utils/getCSSUnitValue.d.ts +1 -0
  124. package/dist/types-ts4.5/utils/getDataURIDimension.d.ts +9 -0
  125. package/dist/types-ts4.5/utils/getElementDimension.d.ts +2 -0
  126. package/dist/types-ts4.5/utils/getMediaCardCursor.d.ts +6 -0
  127. package/dist/types-ts4.5/utils/globalScope/getSSRData.d.ts +3 -0
  128. package/dist/types-ts4.5/utils/globalScope/globalScope.d.ts +21 -0
  129. package/dist/types-ts4.5/utils/globalScope/index.d.ts +4 -0
  130. package/dist/types-ts4.5/utils/globalScope/types.d.ts +8 -0
  131. package/dist/types-ts4.5/utils/index.d.ts +6 -0
  132. package/dist/types-ts4.5/utils/isRetina.d.ts +1 -0
  133. package/dist/types-ts4.5/utils/isValidPercentageUnit.d.ts +1 -0
  134. package/dist/types-ts4.5/utils/lightCards/cardError.d.ts +12 -0
  135. package/dist/types-ts4.5/utils/lightCards/cardLoading.d.ts +5 -0
  136. package/dist/types-ts4.5/utils/lightCards/errorIcon/index.d.ts +12 -0
  137. package/dist/types-ts4.5/utils/lightCards/errorIcon/styles.d.ts +1 -0
  138. package/dist/types-ts4.5/utils/lightCards/getDimensionsWithDefault.d.ts +2 -0
  139. package/dist/types-ts4.5/utils/lightCards/lightCardWrappers.d.ts +4 -0
  140. package/dist/types-ts4.5/utils/lightCards/styles.d.ts +2 -0
  141. package/dist/types-ts4.5/utils/lightCards/types.d.ts +15 -0
  142. package/dist/types-ts4.5/utils/metadata.d.ts +2 -0
  143. package/dist/types-ts4.5/utils/mockIntersectionObserver.d.ts +20 -0
  144. package/dist/types-ts4.5/utils/objectURLCache.d.ts +12 -0
  145. package/dist/types-ts4.5/utils/preventClickThrough.d.ts +8 -0
  146. package/dist/types-ts4.5/utils/printScript.d.ts +2 -0
  147. package/dist/types-ts4.5/utils/ufoExperiences.d.ts +14 -0
  148. package/dist/types-ts4.5/utils/videoIsPlayable.d.ts +2 -0
  149. package/dist/types-ts4.5/utils/videoSnapshot.d.ts +1 -0
  150. package/dist/types-ts4.5/utils/viewportDetector.d.ts +6 -0
  151. package/package.json +5 -4
  152. package/tmp/api-report-tmp.d.ts +345 -0
@@ -1,17 +1,14 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
- import React, { useEffect, useState, useRef, useMemo } from 'react';
3
+ import React, { useEffect, useState, useRef } from 'react';
4
4
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
6
6
  import SpinnerIcon from '@atlaskit/spinner';
7
7
  import Tooltip from '@atlaskit/tooltip';
8
8
  import { messages } from '@atlaskit/media-ui';
9
- import { defaultImageCardDimensions } from '../../utils/cardDimensions';
10
- import { isValidPercentageUnit } from '../../utils/isValidPercentageUnit';
11
- import { getElementDimension } from '../../utils/getElementDimension';
12
9
  import { createAndFireMediaCardEvent } from '../../utils/analytics';
13
10
  import { attachDetailsToActions } from '../actions';
14
- import { cardImageContainerStyles, calcBreakpointSize } from '../ui/styles';
11
+ import { cardImageContainerStyles } from '../ui/styles';
15
12
  import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
16
13
  import { TitleBox } from '../ui/titleBox/titleBox';
17
14
  import { FailedTitleBox } from '../ui/titleBox/failedTitleBox';
@@ -25,6 +22,7 @@ import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUn
25
22
  import { isUploadError, isRateLimitedError, isPollingError } from '../../errors';
26
23
  import { Wrapper } from '../ui/wrapper';
27
24
  import { fileCardImageViewSelector } from '../classnames';
25
+ import { useBreakpoint } from '../useBreakpoint';
28
26
  export const CardViewV2Base = ({
29
27
  innerRef,
30
28
  onImageLoad,
@@ -54,18 +52,10 @@ export const CardViewV2Base = ({
54
52
  error,
55
53
  disableAnimation
56
54
  }) => {
57
- const [elementWidth, setElementWidth] = useState();
58
55
  const [didImageRender, setDidImageRender] = useState(false);
59
56
  const divRef = useRef(null);
60
57
  const prevCardPreviewRef = useRef();
61
- const width = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) || 0;
62
- useEffect(() => {
63
- // If the dimensions.width is a percentage, we need to transform it into a pixel value in order to get the right breakpoints applied.
64
- if (width && isValidPercentageUnit(width) && !!divRef.current) {
65
- const elementWidth = getElementDimension(divRef.current, 'width');
66
- setElementWidth(elementWidth);
67
- }
68
- }, [width]);
58
+ const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
69
59
  useEffect(() => {
70
60
  innerRef && !!divRef.current && innerRef(divRef.current);
71
61
  }, [innerRef]);
@@ -95,10 +85,6 @@ export const CardViewV2Base = ({
95
85
  setDidImageRender(false);
96
86
  onImageError === null || onImageError === void 0 ? void 0 : onImageError(cardPreview);
97
87
  };
98
- const breakpoint = useMemo(() => {
99
- const width = elementWidth || (dimensions ? dimensions.width : '') || defaultImageCardDimensions.width;
100
- return calcBreakpointSize(parseInt(`${width}`, 10));
101
- }, [elementWidth, dimensions]);
102
88
  const shouldRenderPlayButton = () => {
103
89
  const {
104
90
  mediaType
@@ -0,0 +1,10 @@
1
+ import { lazy } from 'react';
2
+ export const InlinePlayerLazyV2 = /*#__PURE__*/lazy(async () => {
3
+ const {
4
+ InlinePlayerV2
5
+ } = await import( /* webpackChunkName: "@atlaskit-internal_media-card-inlineplayer-v2" */
6
+ './inlinePlayerV2');
7
+ return {
8
+ default: InlinePlayerV2
9
+ };
10
+ });
@@ -0,0 +1,164 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useRef, useState, useEffect } from 'react';
3
+ import { globalMediaEventEmitter } from '@atlaskit/media-client';
4
+ import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
5
+ import { defaultImageCardDimensions } from '../../utils';
6
+ import { CardLoading } from '../../utils/lightCards/cardLoading';
7
+ import { ProgressBar } from '../ui/progressBar/progressBar';
8
+ import { InlinePlayerWrapper } from '../inlinePlayerWrapper';
9
+ import { useBreakpoint } from '../useBreakpoint';
10
+ import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
11
+ export const getPreferredVideoArtifact = fileState => {
12
+ if (fileState.status === 'processed' || fileState.status === 'processing') {
13
+ const {
14
+ artifacts
15
+ } = fileState;
16
+ if (!artifacts) {
17
+ return undefined;
18
+ }
19
+ return artifacts['video_1280.mp4'] ? 'video_1280.mp4' : artifacts['video_640.mp4'] ? 'video_640.mp4' : undefined;
20
+ }
21
+ return undefined;
22
+ };
23
+ export const InlinePlayerBaseV2 = ({
24
+ identifier,
25
+ onError,
26
+ onClick,
27
+ dimensions = defaultImageCardDimensions,
28
+ originalDimensions,
29
+ selected,
30
+ testId,
31
+ forwardRef,
32
+ autoplay,
33
+ cardPreview,
34
+ onFullscreenChange
35
+ }) => {
36
+ // === States ===
37
+ const [fileSrc, setFileSrc] = useState();
38
+ const [isUploading, setIsUploading] = useState();
39
+ const [progress, setProgress] = useState();
40
+
41
+ // === Refs and Local Variables ===
42
+ const divRef = useRef(null);
43
+ const onErrorRef = useRef(onError);
44
+ onErrorRef.current = onError;
45
+ const {
46
+ id,
47
+ collectionName,
48
+ occurrenceKey
49
+ } = identifier;
50
+ const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
51
+ const mediaClient = useMediaClient();
52
+ const {
53
+ fileState
54
+ } = useFileState(id, {
55
+ collectionName,
56
+ occurrenceKey
57
+ });
58
+ useEffect(() => {
59
+ const subscribeFileState = async fileState => {
60
+ if (fileState.status === 'uploading') {
61
+ setIsUploading(true);
62
+ setProgress(fileState.progress);
63
+ } else {
64
+ setIsUploading(false);
65
+ }
66
+
67
+ // We reuse the existing fileSrc to prevent re renders, therefore we only perform fileSrc updates when there isn't any
68
+ if (fileSrc) {
69
+ return;
70
+ }
71
+ if (fileState.status !== 'error' && fileState.preview) {
72
+ const {
73
+ value
74
+ } = await fileState.preview;
75
+ if (value instanceof Blob && value.type.indexOf('video/') === 0) {
76
+ const newFileSrc = URL.createObjectURL(value);
77
+ setFileSrc(newFileSrc);
78
+ return;
79
+ }
80
+ }
81
+ if (fileState.status === 'processed' || fileState.status === 'processing') {
82
+ const artifactName = getPreferredVideoArtifact(fileState);
83
+ const {
84
+ artifacts
85
+ } = fileState;
86
+ if (!artifactName || !artifacts) {
87
+ // Tries to use the binary artifact to provide something to play while the video is still processing
88
+ try {
89
+ const newFileSrc = await mediaClient.file.getFileBinaryURL(id, collectionName);
90
+ setFileSrc(newFileSrc);
91
+ } catch (error) {
92
+ if (onErrorRef.current && error instanceof Error) {
93
+ onErrorRef.current(error);
94
+ }
95
+ }
96
+ return;
97
+ }
98
+ try {
99
+ const newFileSrc = await mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
100
+ setFileSrc(newFileSrc);
101
+ } catch (error) {
102
+ if (onErrorRef.current && error instanceof Error) {
103
+ onErrorRef.current(error);
104
+ }
105
+ }
106
+ }
107
+ };
108
+ if (fileState) {
109
+ subscribeFileState(fileState);
110
+ }
111
+ }, [fileState, collectionName, fileSrc, id, mediaClient]);
112
+ useEffect(() => {
113
+ return () => {
114
+ fileSrc && URL.revokeObjectURL(fileSrc);
115
+ };
116
+ }, [fileSrc]);
117
+
118
+ // === Render ===
119
+ return fileSrc ? /*#__PURE__*/React.createElement(InlinePlayerWrapper, {
120
+ testId: testId || 'media-card-inline-player',
121
+ selected: {
122
+ selected
123
+ },
124
+ onClick: onClick,
125
+ innerRef: forwardRef || undefined,
126
+ dimensions: dimensions
127
+ }, /*#__PURE__*/React.createElement(InactivityDetector, null, checkMouseMovement => /*#__PURE__*/React.createElement(CustomMediaPlayer, {
128
+ type: "video",
129
+ src: fileSrc,
130
+ onFullscreenChange: onFullscreenChange,
131
+ fileId: id,
132
+ isAutoPlay: autoplay,
133
+ isHDAvailable: false,
134
+ onDownloadClick: () => {
135
+ mediaClient.file.downloadBinary(id, undefined, collectionName);
136
+ },
137
+ onFirstPlay: () => {
138
+ globalMediaEventEmitter.emit('media-viewed', {
139
+ fileId: id,
140
+ viewingLevel: 'full'
141
+ });
142
+ },
143
+ lastWatchTimeConfig: {
144
+ contentId: id
145
+ },
146
+ originalDimensions: originalDimensions,
147
+ showControls: checkMouseMovement,
148
+ poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI
149
+ })), isUploading && /*#__PURE__*/React.createElement(ProgressBar, {
150
+ progress: progress,
151
+ breakpoint: breakpoint,
152
+ positionBottom: true,
153
+ showOnTop: true
154
+ })) : /*#__PURE__*/React.createElement(CardLoading, {
155
+ testId: testId,
156
+ dimensions: dimensions
157
+ });
158
+ };
159
+ const InlinePlayerForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => {
160
+ return /*#__PURE__*/React.createElement(InlinePlayerBaseV2, _extends({}, props, {
161
+ forwardRef: ref
162
+ }));
163
+ });
164
+ export const InlinePlayerV2 = InlinePlayerForwardRef;
@@ -37,7 +37,7 @@ export default class MediaInlineCardLoader extends React.PureComponent {
37
37
  } = this.state;
38
38
  const analyticsContext = {
39
39
  packageVersion: "@atlaskit/media-card",
40
- packageName: "77.1.2",
40
+ packageName: "77.2.1",
41
41
  componentName: 'mediaInlineCard',
42
42
  component: 'mediaInlineCard'
43
43
  };
@@ -4,7 +4,7 @@ import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
4
4
  import { MediaCardError } from '../errors';
5
5
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
6
6
  const packageName = "@atlaskit/media-card";
7
- const packageVersion = "77.1.2";
7
+ const packageVersion = "77.2.1";
8
8
  let concurrentExperience;
9
9
  const getExperience = id => {
10
10
  if (!concurrentExperience) {
@@ -40,7 +40,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
40
40
  import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '../utils/ufoExperiences';
41
41
  import { generateUniqueId } from '../utils/generateUniqueId';
42
42
  var packageName = "@atlaskit/media-card";
43
- var packageVersion = "77.1.2";
43
+ var packageVersion = "77.2.1";
44
44
  export var CardBase = /*#__PURE__*/function (_Component) {
45
45
  _inherits(CardBase, _Component);
46
46
  var _super = _createSuper(CardBase);
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
83
83
  }(React.Component);
84
84
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
85
85
  var packageName = "@atlaskit/media-card";
86
- var packageVersion = "77.1.2";
86
+ var packageVersion = "77.2.1";
87
87
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
88
88
  packageVersion: packageVersion,
89
89
  packageName: packageName,
@@ -0,0 +1,24 @@
1
+ import { useMemo } from 'react';
2
+ import { calcBreakpointSize } from './ui/styles';
3
+ import { getElementDimension, isValidPercentageUnit, defaultImageCardDimensions } from '../utils';
4
+
5
+ // Hook to calculate the breakpoint based on the width of the element
6
+ export var useBreakpoint = function useBreakpoint() {
7
+ var dimensionWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
8
+ var divRef = arguments.length > 1 ? arguments[1] : undefined;
9
+ var breakpoint = useMemo(function () {
10
+ var widthToCalculate;
11
+ if (dimensionWidth) {
12
+ if (isValidPercentageUnit(dimensionWidth) && divRef.current) {
13
+ var width = getElementDimension(divRef.current, 'width');
14
+ widthToCalculate = width || defaultImageCardDimensions.width;
15
+ } else {
16
+ widthToCalculate = dimensionWidth;
17
+ }
18
+ } else {
19
+ widthToCalculate = defaultImageCardDimensions.width;
20
+ }
21
+ return calcBreakpointSize(parseInt("".concat(widthToCalculate), 10));
22
+ }, [dimensionWidth, divRef]);
23
+ return breakpoint;
24
+ };
@@ -28,7 +28,7 @@ import { videoIsPlayable } from '../../utils/videoIsPlayable';
28
28
  import { getRequestedDimensions } from '../../utils/getDataURIDimension';
29
29
  import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, isSSRDataPreview, fetchAndCacheRemotePreview } from '../getCardPreview';
30
30
  import { getFileDetails } from '../../utils/metadata';
31
- import { InlinePlayerLazy } from '../inlinePlayerLazy';
31
+ import { InlinePlayerLazyV2 } from './inlinePlayerLazyV2';
32
32
  import { getFileAttributes, extractErrorInfo } from '../../utils/analytics';
33
33
  import { isLocalPreviewError, MediaCardError, MediaFileStateError, ensureMediaCardError, ImageLoadError } from '../../errors';
34
34
  import { fireOperationalEvent as _fireOperationalEvent, fireCommencedEvent as _fireCommencedEvent, fireCopiedEvent, fireScreenEvent, fireNonCriticalErrorEvent } from '../cardAnalytics';
@@ -41,7 +41,7 @@ import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '.
41
41
  import { generateUniqueId } from '../../utils/generateUniqueId';
42
42
  import { useFileState } from '@atlaskit/media-client-react';
43
43
  var packageName = "@atlaskit/media-card";
44
- var packageVersion = "77.1.2";
44
+ var packageVersion = "77.2.1";
45
45
  export var CardV2Base = /*#__PURE__*/function (_Component) {
46
46
  _inherits(CardV2Base, _Component);
47
47
  var _super = _createSuper(CardV2Base);
@@ -443,7 +443,6 @@ export var CardV2Base = /*#__PURE__*/function (_Component) {
443
443
  _defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
444
444
  var _this$props6 = _this.props,
445
445
  identifier = _this$props6.identifier,
446
- mediaClient = _this$props6.mediaClient,
447
446
  dimensions = _this$props6.dimensions,
448
447
  selected = _this$props6.selected,
449
448
  testId = _this$props6.testId,
@@ -455,8 +454,7 @@ export var CardV2Base = /*#__PURE__*/function (_Component) {
455
454
  var card = _this.renderCard(false, 'loading', false);
456
455
  return /*#__PURE__*/React.createElement(Suspense, {
457
456
  fallback: card
458
- }, /*#__PURE__*/React.createElement(InlinePlayerLazy, {
459
- mediaClient: mediaClient,
457
+ }, /*#__PURE__*/React.createElement(InlinePlayerLazyV2, {
460
458
  dimensions: dimensions,
461
459
  originalDimensions: originalDimensions,
462
460
  identifier: identifier,
@@ -30,12 +30,14 @@ var MediaCardErrorBoundary = Loadable({
30
30
  return /*#__PURE__*/React.createElement(CardLoadingWithContext, null);
31
31
  }
32
32
  });
33
- var MediaCardWithMediaClient = function MediaCardWithMediaClient(props) {
33
+ var CardWithMediaClient = function CardWithMediaClient(props) {
34
34
  var dimensions = props.dimensions,
35
35
  onClick = props.onClick,
36
- useMediaClient = props.useMediaClient,
36
+ withMediaClient = props.withMediaClient,
37
37
  featureFlags = props.featureFlags;
38
- var mediaClient = useMediaClient();
38
+ var Card = React.useMemo(function () {
39
+ return withMediaClient(MediaV2Card);
40
+ }, [withMediaClient]);
39
41
  var featureFlagsWithMediaCardV2 = React.useMemo(function () {
40
42
  return _objectSpread(_objectSpread({}, featureFlags), {}, {
41
43
  mediaCardV2: true //used for analytics - internal use only
@@ -44,9 +46,8 @@ var MediaCardWithMediaClient = function MediaCardWithMediaClient(props) {
44
46
  return /*#__PURE__*/React.createElement(MediaCardErrorBoundary, {
45
47
  dimensions: dimensions,
46
48
  onClick: onClick
47
- }, /*#__PURE__*/React.createElement(MediaV2Card, _extends({}, props, {
48
- featureFlags: featureFlagsWithMediaCardV2,
49
- mediaClient: mediaClient
49
+ }, /*#__PURE__*/React.createElement(Card, _extends({}, props, {
50
+ featureFlags: featureFlagsWithMediaCardV2
50
51
  })));
51
52
  };
52
53
  var MediaCardWithMediaClientProvider = Loadable({
@@ -57,17 +58,9 @@ var MediaCardWithMediaClientProvider = Loadable({
57
58
  return /*#__PURE__*/React.createElement(CardLoadingWithContext, null);
58
59
  },
59
60
  render: function render(loaded, props) {
60
- var mediaCard = /*#__PURE__*/React.createElement(MediaCardWithMediaClient, _extends({}, props, {
61
- useMediaClient: loaded.useMediaClient
61
+ return /*#__PURE__*/React.createElement(CardWithMediaClient, _extends({}, props, {
62
+ withMediaClient: loaded.withMediaClient
62
63
  }));
63
- return /*#__PURE__*/React.createElement(loaded.MediaClientContext.Consumer, null, function (value) {
64
- return value ? mediaCard :
65
- /*#__PURE__*/
66
- // TODO - make clientConfig optional
67
- React.createElement(loaded.MediaClientProvider, {
68
- clientConfig: props.mediaClientConfig
69
- }, mediaCard);
70
- });
71
64
  }
72
65
  });
73
66
  var CardLoader = function CardLoader(props) {
@@ -4,18 +4,15 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  /** @jsx jsx */
6
6
  import { jsx } from '@emotion/react';
7
- import React, { useEffect, useState, useRef, useMemo } from 'react';
7
+ import React, { useEffect, useState, useRef } from 'react';
8
8
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
9
9
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
10
10
  import SpinnerIcon from '@atlaskit/spinner';
11
11
  import Tooltip from '@atlaskit/tooltip';
12
12
  import { messages } from '@atlaskit/media-ui';
13
- import { defaultImageCardDimensions } from '../../utils/cardDimensions';
14
- import { isValidPercentageUnit } from '../../utils/isValidPercentageUnit';
15
- import { getElementDimension } from '../../utils/getElementDimension';
16
13
  import { createAndFireMediaCardEvent } from '../../utils/analytics';
17
14
  import { attachDetailsToActions } from '../actions';
18
- import { cardImageContainerStyles, calcBreakpointSize } from '../ui/styles';
15
+ import { cardImageContainerStyles } from '../ui/styles';
19
16
  import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
20
17
  import { TitleBox } from '../ui/titleBox/titleBox';
21
18
  import { FailedTitleBox } from '../ui/titleBox/failedTitleBox';
@@ -29,6 +26,7 @@ import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUn
29
26
  import { isUploadError, isRateLimitedError, isPollingError } from '../../errors';
30
27
  import { Wrapper } from '../ui/wrapper';
31
28
  import { fileCardImageViewSelector } from '../classnames';
29
+ import { useBreakpoint } from '../useBreakpoint';
32
30
  export var CardViewV2Base = function CardViewV2Base(_ref) {
33
31
  var innerRef = _ref.innerRef,
34
32
  onImageLoad = _ref.onImageLoad,
@@ -58,24 +56,13 @@ export var CardViewV2Base = function CardViewV2Base(_ref) {
58
56
  titleBoxIcon = _ref.titleBoxIcon,
59
57
  error = _ref.error,
60
58
  disableAnimation = _ref.disableAnimation;
61
- var _useState = useState(),
59
+ var _useState = useState(false),
62
60
  _useState2 = _slicedToArray(_useState, 2),
63
- elementWidth = _useState2[0],
64
- setElementWidth = _useState2[1];
65
- var _useState3 = useState(false),
66
- _useState4 = _slicedToArray(_useState3, 2),
67
- didImageRender = _useState4[0],
68
- setDidImageRender = _useState4[1];
61
+ didImageRender = _useState2[0],
62
+ setDidImageRender = _useState2[1];
69
63
  var divRef = useRef(null);
70
64
  var prevCardPreviewRef = useRef();
71
- var width = (dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) || 0;
72
- useEffect(function () {
73
- // If the dimensions.width is a percentage, we need to transform it into a pixel value in order to get the right breakpoints applied.
74
- if (width && isValidPercentageUnit(width) && !!divRef.current) {
75
- var _elementWidth = getElementDimension(divRef.current, 'width');
76
- setElementWidth(_elementWidth);
77
- }
78
- }, [width]);
65
+ var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
79
66
  useEffect(function () {
80
67
  innerRef && !!divRef.current && innerRef(divRef.current);
81
68
  }, [innerRef]);
@@ -105,10 +92,6 @@ export var CardViewV2Base = function CardViewV2Base(_ref) {
105
92
  setDidImageRender(false);
106
93
  onImageError === null || onImageError === void 0 || onImageError(cardPreview);
107
94
  };
108
- var breakpoint = useMemo(function () {
109
- var width = elementWidth || (dimensions ? dimensions.width : '') || defaultImageCardDimensions.width;
110
- return calcBreakpointSize(parseInt("".concat(width), 10));
111
- }, [elementWidth, dimensions]);
112
95
  var shouldRenderPlayButton = function shouldRenderPlayButton() {
113
96
  var _ref2 = metadata || {},
114
97
  mediaType = _ref2.mediaType;
@@ -0,0 +1,23 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import { lazy } from 'react';
4
+ export var InlinePlayerLazyV2 = /*#__PURE__*/lazy( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
5
+ var _yield$import, InlinePlayerV2;
6
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
7
+ while (1) switch (_context.prev = _context.next) {
8
+ case 0:
9
+ _context.next = 2;
10
+ return import( /* webpackChunkName: "@atlaskit-internal_media-card-inlineplayer-v2" */
11
+ './inlinePlayerV2');
12
+ case 2:
13
+ _yield$import = _context.sent;
14
+ InlinePlayerV2 = _yield$import.InlinePlayerV2;
15
+ return _context.abrupt("return", {
16
+ default: InlinePlayerV2
17
+ });
18
+ case 5:
19
+ case "end":
20
+ return _context.stop();
21
+ }
22
+ }, _callee);
23
+ })));