@atlaskit/media-card 77.12.3 → 78.0.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 (151) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/card/card.js +20 -1039
  3. package/dist/cjs/card/cardLoader.js +2 -2
  4. package/dist/cjs/card/cardView.js +255 -417
  5. package/dist/cjs/card/cardWithMediaClient.js +5 -9
  6. package/dist/cjs/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
  7. package/dist/cjs/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
  8. package/dist/cjs/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
  9. package/dist/cjs/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
  10. package/dist/cjs/card/{v2/cardviews → cardviews}/index.js +2 -2
  11. package/dist/cjs/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
  12. package/dist/cjs/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
  13. package/dist/cjs/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
  14. package/dist/cjs/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
  15. package/dist/cjs/card/{v2/fileCard.js → fileCard.js} +18 -18
  16. package/dist/cjs/card/index.js +2 -2
  17. package/dist/cjs/card/inlinePlayer.js +184 -267
  18. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  19. package/dist/cjs/card/{v2/svgView → svgView}/svgView.js +9 -9
  20. package/dist/cjs/inline/loader.js +1 -1
  21. package/dist/cjs/utils/ufoExperiences.js +1 -1
  22. package/dist/es2019/card/card.js +20 -1023
  23. package/dist/es2019/card/cardLoader.js +2 -2
  24. package/dist/es2019/card/cardView.js +252 -403
  25. package/dist/es2019/card/cardWithMediaClient.js +6 -10
  26. package/dist/es2019/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
  27. package/dist/es2019/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
  28. package/dist/es2019/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
  29. package/dist/es2019/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
  30. package/dist/es2019/card/{v2/cardviews → cardviews}/index.js +2 -2
  31. package/dist/es2019/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
  32. package/dist/es2019/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
  33. package/dist/es2019/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
  34. package/dist/es2019/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
  35. package/dist/es2019/card/{v2/fileCard.js → fileCard.js} +18 -18
  36. package/dist/es2019/card/index.js +1 -1
  37. package/dist/es2019/card/inlinePlayer.js +127 -208
  38. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  39. package/dist/es2019/card/{v2/svgView → svgView}/svgView.js +9 -9
  40. package/dist/es2019/inline/loader.js +1 -1
  41. package/dist/es2019/utils/ufoExperiences.js +1 -1
  42. package/dist/esm/card/card.js +21 -1040
  43. package/dist/esm/card/cardLoader.js +2 -2
  44. package/dist/esm/card/cardView.js +251 -416
  45. package/dist/esm/card/cardWithMediaClient.js +6 -10
  46. package/dist/esm/card/{v2/cardviews → cardviews}/cardViewWrapper.js +8 -8
  47. package/dist/esm/card/{v2/cardviews → cardviews}/errorCardView.js +6 -6
  48. package/dist/esm/card/{v2/cardviews → cardviews}/iconCardView.js +5 -5
  49. package/dist/esm/card/{v2/cardviews → cardviews}/imageCardView.js +5 -5
  50. package/dist/esm/card/{v2/cardviews → cardviews}/index.js +2 -2
  51. package/dist/esm/card/{v2/cardviews → cardviews}/loadingCardView.js +3 -3
  52. package/dist/esm/card/{v2/cardviews → cardviews}/processingCardView.js +4 -4
  53. package/dist/esm/card/{v2/cardviews → cardviews}/videoCardView.js +7 -7
  54. package/dist/esm/card/{v2/externalImageCard.js → externalImageCard.js} +11 -11
  55. package/dist/esm/card/{v2/fileCard.js → fileCard.js} +18 -18
  56. package/dist/esm/card/index.js +1 -1
  57. package/dist/esm/card/inlinePlayer.js +185 -269
  58. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  59. package/dist/esm/card/{v2/svgView → svgView}/svgView.js +9 -9
  60. package/dist/esm/inline/loader.js +1 -1
  61. package/dist/esm/utils/ufoExperiences.js +1 -1
  62. package/dist/types/card/card.d.ts +5 -66
  63. package/dist/types/card/cardLoader.d.ts +1 -1
  64. package/dist/types/card/cardView.d.ts +23 -45
  65. package/dist/types/card/cardWithMediaClient.d.ts +1 -1
  66. package/dist/types/card/{v2/cardviews → cardviews}/cardViewWrapper.d.ts +3 -3
  67. package/dist/types/card/{v2/cardviews → cardviews}/errorCardView.d.ts +1 -1
  68. package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/iconCardView.d.ts +1 -1
  69. package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/imageCardView.d.ts +1 -1
  70. package/dist/{types-ts4.5/card/v2 → types/card}/cardviews/index.d.ts +5 -5
  71. package/dist/types/card/{v2/cardviews → cardviews}/videoCardView.d.ts +1 -1
  72. package/dist/types/card/{v2/externalImageCard.d.ts → externalImageCard.d.ts} +1 -1
  73. package/dist/types/card/{v2/fileCard.d.ts → fileCard.d.ts} +2 -2
  74. package/dist/types/card/index.d.ts +1 -1
  75. package/dist/types/card/inlinePlayer.d.ts +2 -31
  76. package/dist/types/card/{v2/svgView → svgView}/errors.d.ts +1 -1
  77. package/dist/{types-ts4.5/card/v2 → types/card}/svgView/svgView.d.ts +2 -2
  78. package/dist/types-ts4.5/card/card.d.ts +5 -66
  79. package/dist/types-ts4.5/card/cardLoader.d.ts +1 -1
  80. package/dist/types-ts4.5/card/cardView.d.ts +23 -45
  81. package/dist/types-ts4.5/card/cardWithMediaClient.d.ts +1 -1
  82. package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/cardViewWrapper.d.ts +3 -3
  83. package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/errorCardView.d.ts +1 -1
  84. package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/iconCardView.d.ts +1 -1
  85. package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/imageCardView.d.ts +1 -1
  86. package/dist/{types/card/v2 → types-ts4.5/card}/cardviews/index.d.ts +5 -5
  87. package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/videoCardView.d.ts +1 -1
  88. package/dist/types-ts4.5/card/{v2/externalImageCard.d.ts → externalImageCard.d.ts} +1 -1
  89. package/dist/types-ts4.5/card/{v2/fileCard.d.ts → fileCard.d.ts} +2 -2
  90. package/dist/types-ts4.5/card/index.d.ts +1 -1
  91. package/dist/types-ts4.5/card/inlinePlayer.d.ts +2 -31
  92. package/dist/types-ts4.5/card/{v2/svgView → svgView}/errors.d.ts +1 -1
  93. package/dist/{types/card/v2 → types-ts4.5/card}/svgView/svgView.d.ts +2 -2
  94. package/package.json +3 -6
  95. package/dist/cjs/card/cardSwitcher.js +0 -15
  96. package/dist/cjs/card/v2/cardV2.js +0 -41
  97. package/dist/cjs/card/v2/cardV2Loader.js +0 -36
  98. package/dist/cjs/card/v2/cardViewV2.js +0 -298
  99. package/dist/cjs/card/v2/cardWithMediaClientV2.js +0 -34
  100. package/dist/cjs/card/v2/inlinePlayerLazyV2.js +0 -35
  101. package/dist/cjs/card/v2/inlinePlayerV2.js +0 -224
  102. package/dist/es2019/card/cardSwitcher.js +0 -8
  103. package/dist/es2019/card/v2/cardV2.js +0 -33
  104. package/dist/es2019/card/v2/cardV2Loader.js +0 -18
  105. package/dist/es2019/card/v2/cardViewV2.js +0 -294
  106. package/dist/es2019/card/v2/cardWithMediaClientV2.js +0 -25
  107. package/dist/es2019/card/v2/inlinePlayerLazyV2.js +0 -10
  108. package/dist/es2019/card/v2/inlinePlayerV2.js +0 -166
  109. package/dist/esm/card/cardSwitcher.js +0 -8
  110. package/dist/esm/card/v2/cardV2.js +0 -34
  111. package/dist/esm/card/v2/cardV2Loader.js +0 -24
  112. package/dist/esm/card/v2/cardViewV2.js +0 -290
  113. package/dist/esm/card/v2/cardWithMediaClientV2.js +0 -27
  114. package/dist/esm/card/v2/inlinePlayerLazyV2.js +0 -23
  115. package/dist/esm/card/v2/inlinePlayerV2.js +0 -214
  116. package/dist/types/card/cardSwitcher.d.ts +0 -4
  117. package/dist/types/card/v2/cardV2.d.ts +0 -7
  118. package/dist/types/card/v2/cardV2Loader.d.ts +0 -4
  119. package/dist/types/card/v2/cardViewV2.d.ts +0 -59
  120. package/dist/types/card/v2/cardWithMediaClientV2.d.ts +0 -3
  121. package/dist/types/card/v2/inlinePlayerLazyV2.d.ts +0 -2
  122. package/dist/types/card/v2/inlinePlayerV2.d.ts +0 -24
  123. package/dist/types-ts4.5/card/cardSwitcher.d.ts +0 -4
  124. package/dist/types-ts4.5/card/v2/cardV2.d.ts +0 -7
  125. package/dist/types-ts4.5/card/v2/cardV2Loader.d.ts +0 -4
  126. package/dist/types-ts4.5/card/v2/cardViewV2.d.ts +0 -59
  127. package/dist/types-ts4.5/card/v2/cardWithMediaClientV2.d.ts +0 -3
  128. package/dist/types-ts4.5/card/v2/inlinePlayerLazyV2.d.ts +0 -2
  129. package/dist/types-ts4.5/card/v2/inlinePlayerV2.d.ts +0 -24
  130. /package/dist/cjs/card/{v2/performance.js → performance.js} +0 -0
  131. /package/dist/cjs/card/{v2/svgView → svgView}/errors.js +0 -0
  132. /package/dist/cjs/card/{v2/svgView → svgView}/helpers.js +0 -0
  133. /package/dist/cjs/card/{v2/svgView → svgView}/index.js +0 -0
  134. /package/dist/es2019/card/{v2/performance.js → performance.js} +0 -0
  135. /package/dist/es2019/card/{v2/svgView → svgView}/errors.js +0 -0
  136. /package/dist/es2019/card/{v2/svgView → svgView}/helpers.js +0 -0
  137. /package/dist/es2019/card/{v2/svgView → svgView}/index.js +0 -0
  138. /package/dist/esm/card/{v2/performance.js → performance.js} +0 -0
  139. /package/dist/esm/card/{v2/svgView → svgView}/errors.js +0 -0
  140. /package/dist/esm/card/{v2/svgView → svgView}/helpers.js +0 -0
  141. /package/dist/esm/card/{v2/svgView → svgView}/index.js +0 -0
  142. /package/dist/types/card/{v2/cardviews → cardviews}/loadingCardView.d.ts +0 -0
  143. /package/dist/types/card/{v2/cardviews → cardviews}/processingCardView.d.ts +0 -0
  144. /package/dist/types/card/{v2/performance.d.ts → performance.d.ts} +0 -0
  145. /package/dist/types/card/{v2/svgView → svgView}/helpers.d.ts +0 -0
  146. /package/dist/types/card/{v2/svgView → svgView}/index.d.ts +0 -0
  147. /package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/loadingCardView.d.ts +0 -0
  148. /package/dist/types-ts4.5/card/{v2/cardviews → cardviews}/processingCardView.d.ts +0 -0
  149. /package/dist/types-ts4.5/card/{v2/performance.d.ts → performance.d.ts} +0 -0
  150. /package/dist/types-ts4.5/card/{v2/svgView → svgView}/helpers.d.ts +0 -0
  151. /package/dist/types-ts4.5/card/{v2/svgView → svgView}/index.d.ts +0 -0
@@ -1,21 +1,17 @@
1
1
  import React from 'react';
2
2
  import { withMediaClient } from '@atlaskit/media-client-react';
3
- import { Card as MediaCard } from './card';
4
3
  import MediaCardAnalyticsErrorBoundary from './media-card-analytics-error-boundary';
4
+ import { Card as InternalCard } from './card';
5
5
  export const CardWithMediaClient = props => {
6
6
  const {
7
7
  dimensions,
8
8
  onClick
9
9
  } = props;
10
10
  const Card = React.useMemo(() => {
11
- return withMediaClient(MediaCard);
11
+ return withMediaClient(InternalCard);
12
12
  }, []);
13
- return (
14
- /*#__PURE__*/
15
- // onClick is passed into MediaCardErrorBoundary so MediaGroup items can get the toolbar menu in Editor
16
- React.createElement(MediaCardAnalyticsErrorBoundary, {
17
- dimensions: dimensions,
18
- onClick: onClick
19
- }, /*#__PURE__*/React.createElement(Card, props))
20
- );
13
+ return /*#__PURE__*/React.createElement(MediaCardAnalyticsErrorBoundary, {
14
+ dimensions: dimensions,
15
+ onClick: onClick
16
+ }, /*#__PURE__*/React.createElement(Card, props));
21
17
  };
@@ -4,14 +4,14 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import { jsx } from '@emotion/react';
5
5
  import React from 'react';
6
6
  import Tooltip from '@atlaskit/tooltip';
7
- import { ImageContainer, Wrapper } from '../../ui/wrapper';
8
- import { attachDetailsToActions } from '../../actions';
9
- import { TitleBox } from '../../ui/titleBox/titleBox';
10
- import { TickBox } from '../../ui/tickBox/tickBox';
11
- import { Blanket } from '../../ui/blanket/blanket';
12
- import { ActionsBar } from '../../ui/actionsBar/actionsBar';
13
- import { fileCardImageViewSelector } from '../../classnames';
14
- import OpenMediaViewerButton from '../../ui/openMediaViewerButton/openMediaViewerButton';
7
+ import { ImageContainer, Wrapper } from '../ui/wrapper';
8
+ import { attachDetailsToActions } from '../actions';
9
+ import { TitleBox } from '../ui/titleBox/titleBox';
10
+ import { TickBox } from '../ui/tickBox/tickBox';
11
+ import { Blanket } from '../ui/blanket/blanket';
12
+ import { ActionsBar } from '../ui/actionsBar/actionsBar';
13
+ import { fileCardImageViewSelector } from '../classnames';
14
+ import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
15
15
  export const CardViewWrapper = /*#__PURE__*/React.forwardRef(({
16
16
  cardPreview,
17
17
  testId,
@@ -4,14 +4,14 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import { jsx } from '@emotion/react';
5
5
  import { useRef } from 'react';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
8
- import { useBreakpoint } from '../../useBreakpoint';
7
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
8
+ import { useBreakpoint } from '../useBreakpoint';
9
9
  import { CardViewWrapper } from './cardViewWrapper';
10
10
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
11
- import { IconWrapper } from '../../ui/iconWrapper/iconWrapper';
12
- import { FailedTitleBox } from '../../ui/titleBox/failedTitleBox';
13
- import { PreviewUnavailable, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from '../../ui/iconMessage';
14
- import { isUploadError, isRateLimitedError, isPollingError } from '../../../errors';
11
+ import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
12
+ import { FailedTitleBox } from '../ui/titleBox/failedTitleBox';
13
+ import { PreviewUnavailable, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from '../ui/iconMessage';
14
+ import { isUploadError, isRateLimitedError, isPollingError } from '../../errors';
15
15
  import { messages } from '@atlaskit/media-ui';
16
16
  const IconMessage = ({
17
17
  error,
@@ -5,12 +5,12 @@ import { jsx } from '@emotion/react';
5
5
  import { useEffect, useRef } from 'react';
6
6
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
7
7
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
8
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
9
- import { IconWrapper } from '../../ui/iconWrapper/iconWrapper';
10
- import { useBreakpoint } from '../../useBreakpoint';
8
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
9
+ import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
10
+ import { useBreakpoint } from '../useBreakpoint';
11
11
  import { CardViewWrapper } from './cardViewWrapper';
12
- import { ProgressBar } from '../../ui/progressBar/progressBar';
13
- import { Blanket } from '../../ui/blanket/blanket';
12
+ import { ProgressBar } from '../ui/progressBar/progressBar';
13
+ import { Blanket } from '../ui/blanket/blanket';
14
14
  // NOTE: should we call this Icon or UploadingCardView since we now have ProgressBar?
15
15
 
16
16
  const IconCardViewBase = props => {
@@ -4,12 +4,12 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import { jsx } from '@emotion/react';
5
5
  import { useEffect, useRef } from 'react';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
8
- import { ImageRenderer } from '../../ui/imageRenderer/imageRenderer';
9
- import { useBreakpoint } from '../../useBreakpoint';
7
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
8
+ import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
9
+ import { useBreakpoint } from '../useBreakpoint';
10
10
  import { CardViewWrapper } from './cardViewWrapper';
11
- import { ProgressBar } from '../../ui/progressBar/progressBar';
12
- import { Blanket } from '../../ui/blanket/blanket';
11
+ import { ProgressBar } from '../ui/progressBar/progressBar';
12
+ import { Blanket } from '../ui/blanket/blanket';
13
13
  const ImageCardViewBase = props => {
14
14
  const {
15
15
  status,
@@ -4,8 +4,8 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import { jsx } from '@emotion/react';
5
5
  import React, { useEffect, useState, useRef } from 'react';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
8
- import { useBreakpoint } from '../../useBreakpoint';
7
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
8
+ import { useBreakpoint } from '../useBreakpoint';
9
9
  import { ProcessingCardView } from './processingCardView';
10
10
  import { ErrorCardView } from './errorCardView';
11
11
  import { VideoCardView } from './videoCardView';
@@ -5,9 +5,9 @@ import { jsx } from '@emotion/react';
5
5
  import { useEffect, useRef } from 'react';
6
6
  import SpinnerIcon from '@atlaskit/spinner';
7
7
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
8
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
9
- import { IconWrapper } from '../../ui/iconWrapper/iconWrapper';
10
- import { useBreakpoint } from '../../useBreakpoint';
8
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
9
+ import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
10
+ import { useBreakpoint } from '../useBreakpoint';
11
11
  import { CardViewWrapper } from './cardViewWrapper';
12
12
  const LoadingCardViewBase = props => {
13
13
  const {
@@ -5,10 +5,10 @@ import { jsx } from '@emotion/react';
5
5
  import { useEffect, useRef } from 'react';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
7
  import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
8
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
9
- import { IconWrapper } from '../../ui/iconWrapper/iconWrapper';
10
- import { CreatingPreview } from '../../ui/iconMessage';
11
- import { useBreakpoint } from '../../useBreakpoint';
8
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
9
+ import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
10
+ import { CreatingPreview } from '../ui/iconMessage';
11
+ import { useBreakpoint } from '../useBreakpoint';
12
12
  import { CardViewWrapper } from './cardViewWrapper';
13
13
  const ProcessingCardViewBase = props => {
14
14
  const {
@@ -4,14 +4,14 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import { jsx } from '@emotion/react';
5
5
  import { useEffect, useRef } from 'react';
6
6
  import { withAnalyticsEvents } from '@atlaskit/analytics-next';
7
- import { createAndFireMediaCardEvent } from '../../../utils/analytics';
8
- import { IconWrapper } from '../../ui/iconWrapper/iconWrapper';
9
- import { PlayButton } from '../../ui/playButton/playButton';
10
- import { ImageRenderer } from '../../ui/imageRenderer/imageRenderer';
11
- import { useBreakpoint } from '../../useBreakpoint';
7
+ import { createAndFireMediaCardEvent } from '../../utils/analytics';
8
+ import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
9
+ import { PlayButton } from '../ui/playButton/playButton';
10
+ import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
11
+ import { useBreakpoint } from '../useBreakpoint';
12
12
  import { CardViewWrapper } from './cardViewWrapper';
13
- import { ProgressBar } from '../../ui/progressBar/progressBar';
14
- import { Blanket } from '../../ui/blanket/blanket';
13
+ import { ProgressBar } from '../ui/progressBar/progressBar';
14
+ import { Blanket } from '../ui/blanket/blanket';
15
15
  const VideoCardViewBase = props => {
16
16
  const {
17
17
  status,
@@ -3,16 +3,16 @@ import { getRandomHex } from '@atlaskit/media-common';
3
3
  import { MediaViewer } from '@atlaskit/media-viewer';
4
4
  import React, { useEffect, useMemo, useRef, useState } from 'react';
5
5
  import ReactDOM from 'react-dom';
6
- import { ImageLoadError } from '../../errors';
7
- import getDocument from '../../utils/document';
8
- import { generateUniqueId } from '../../utils/generateUniqueId';
9
- import { getMediaCardCursor } from '../../utils/getMediaCardCursor';
10
- import { abortUfoExperience, completeUfoExperience, startUfoExperience } from '../../utils/ufoExperiences';
11
- import { useCurrentValueRef } from '../../utils/useCurrentValueRef';
12
- import { getDefaultCardDimensions } from '../../utils/cardDimensions';
13
- import { usePrevious } from '../../utils/usePrevious';
14
- import { fireCommencedEvent, fireCopiedEvent, fireOperationalEvent, fireScreenEvent } from '../cardAnalytics';
15
- import { CardViewV2 } from './cardViewV2';
6
+ import { ImageLoadError } from '../errors';
7
+ import getDocument from '../utils/document';
8
+ import { generateUniqueId } from '../utils/generateUniqueId';
9
+ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
10
+ import { abortUfoExperience, completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
11
+ import { useCurrentValueRef } from '../utils/useCurrentValueRef';
12
+ import { getDefaultCardDimensions } from '../utils/cardDimensions';
13
+ import { usePrevious } from '../utils/usePrevious';
14
+ import { fireCommencedEvent, fireCopiedEvent, fireOperationalEvent, fireScreenEvent } from './cardAnalytics';
15
+ import { CardView } from './cardView';
16
16
  import { performanceNow } from './performance';
17
17
  export const ExternalImageCard = ({
18
18
  mediaClient,
@@ -190,7 +190,7 @@ export const ExternalImageCard = ({
190
190
  //----------------------------------------------------------------//
191
191
 
192
192
  const mediaCardCursor = getMediaCardCursor(false, !!shouldOpenMediaViewer, status === 'error', !!cardPreview, metadata.mediaType);
193
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardViewV2, {
193
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardView, {
194
194
  status: status,
195
195
  error: error,
196
196
  mediaItemType: identifier.mediaItemType,
@@ -6,28 +6,28 @@ import { getRandomHex, isMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByB
6
6
  import { MediaViewer } from '@atlaskit/media-viewer';
7
7
  import React, { Suspense, useEffect, useMemo, useRef, useState } from 'react';
8
8
  import ReactDOM from 'react-dom';
9
- import { MediaCardError } from '../../errors';
10
- import getDocument from '../../utils/document';
11
- import { generateUniqueId } from '../../utils/generateUniqueId';
12
- import { resolveCardPreviewDimensions } from '../../utils/getDataURIDimension';
13
- import { getMediaCardCursor } from '../../utils/getMediaCardCursor';
14
- import { getFileDetails } from '../../utils/metadata';
15
- import { abortUfoExperience, completeUfoExperience, startUfoExperience } from '../../utils/ufoExperiences';
16
- import { useCurrentValueRef } from '../../utils/useCurrentValueRef';
17
- import { usePrevious } from '../../utils/usePrevious';
18
- import { ViewportDetector } from '../../utils/viewportDetector';
19
- import { getDefaultCardDimensions } from '../../utils/cardDimensions';
20
- import { fireCommencedEvent, fireCopiedEvent, fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent } from '../cardAnalytics';
21
- import { isSSRPreview } from '../getCardPreview';
22
- import { CardViewV2 } from './cardViewV2';
9
+ import { MediaCardError } from '../errors';
10
+ import getDocument from '../utils/document';
11
+ import { generateUniqueId } from '../utils/generateUniqueId';
12
+ import { resolveCardPreviewDimensions } from '../utils/getDataURIDimension';
13
+ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
14
+ import { getFileDetails } from '../utils/metadata';
15
+ import { abortUfoExperience, completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
16
+ import { useCurrentValueRef } from '../utils/useCurrentValueRef';
17
+ import { usePrevious } from '../utils/usePrevious';
18
+ import { ViewportDetector } from '../utils/viewportDetector';
19
+ import { getDefaultCardDimensions } from '../utils/cardDimensions';
20
+ import { fireCommencedEvent, fireCopiedEvent, fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent } from './cardAnalytics';
21
+ import { isSSRPreview } from './getCardPreview';
22
+ import { CardView } from './cardView';
23
23
  import { CardViews } from './cardviews';
24
- import { InlinePlayerLazyV2 } from './inlinePlayerLazyV2';
24
+ import { InlinePlayerLazy } from './inlinePlayerLazy';
25
25
  import { useFilePreview } from '@atlaskit/media-file-preview';
26
26
  import { performanceNow } from './performance';
27
27
  import { useContext } from 'react';
28
- import { DateOverrideContext } from '../../dateOverrideContext';
28
+ import { DateOverrideContext } from '../dateOverrideContext';
29
29
  import { SvgView } from './svgView';
30
- const LoadedCardView = getBooleanFF('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardViewV2;
30
+ const LoadedCardView = getBooleanFF('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardView;
31
31
  export const FileCard = ({
32
32
  appearance = 'auto',
33
33
  resizeMode = 'crop',
@@ -579,7 +579,7 @@ export const FileCard = ({
579
579
  const collectionName = identifier.collectionName || '';
580
580
  return /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? /*#__PURE__*/React.createElement(Suspense, {
581
581
  fallback: inlinePlayerFallback
582
- }, /*#__PURE__*/React.createElement(InlinePlayerLazyV2, {
582
+ }, /*#__PURE__*/React.createElement(InlinePlayerLazy, {
583
583
  dimensions: cardDimensions,
584
584
  originalDimensions: originalDimensions,
585
585
  identifier: identifier,
@@ -1 +1 @@
1
- export { default as Card } from './cardSwitcher';
1
+ export { default as Card } from './cardLoader';
@@ -1,16 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import React from 'react';
4
- import { Component } from 'react';
2
+ import React, { useRef, useState, useEffect } from 'react';
5
3
  import { globalMediaEventEmitter } from '@atlaskit/media-client';
6
4
  import { CustomMediaPlayer, InactivityDetector } from '@atlaskit/media-ui';
7
5
  import { defaultImageCardDimensions } from '../utils';
8
6
  import { CardLoading } from '../utils/lightCards/cardLoading';
9
7
  import { ProgressBar } from './ui/progressBar/progressBar';
10
- import { calcBreakpointSize } from './ui/styles';
11
- import { isValidPercentageUnit } from '../utils/isValidPercentageUnit';
12
- import { getElementDimension } from '../utils/getElementDimension';
13
8
  import { InlinePlayerWrapper } from './inlinePlayerWrapper';
9
+ import { useBreakpoint } from './useBreakpoint';
10
+ import { useFileState, useMediaClient } from '@atlaskit/media-client-react';
14
11
  export const getPreferredVideoArtifact = fileState => {
15
12
  if (fileState.status === 'processed' || fileState.status === 'processing') {
16
13
  const {
@@ -23,222 +20,144 @@ export const getPreferredVideoArtifact = fileState => {
23
20
  }
24
21
  return undefined;
25
22
  };
26
- export class InlinePlayerBase extends Component {
27
- constructor(...args) {
28
- super(...args);
29
- _defineProperty(this, "state", {});
30
- _defineProperty(this, "divRef", /*#__PURE__*/React.createRef());
31
- _defineProperty(this, "setFileSrc", fileSrc => {
32
- this.setState({
33
- fileSrc
34
- });
35
- });
36
- // Tries to use the binary artifact to provide something to play while the video is still processing
37
- _defineProperty(this, "setBinaryURL", async () => {
38
- const {
39
- mediaClient,
40
- identifier,
41
- onError
42
- } = this.props;
43
- const {
44
- id,
45
- collectionName
46
- } = identifier;
47
- try {
48
- const fileSrc = await mediaClient.file.getFileBinaryURL(id, collectionName);
49
- this.setFileSrc(fileSrc);
50
- } catch (error) {
51
- if (onError && error instanceof Error) {
52
- onError(error);
53
- }
54
- }
55
- });
56
- _defineProperty(this, "unsubscribe", () => {
57
- if (this.subscription) {
58
- this.subscription.unsubscribe();
23
+ export const InlinePlayerBase = ({
24
+ identifier,
25
+ onError,
26
+ onClick,
27
+ dimensions = defaultImageCardDimensions,
28
+ originalDimensions,
29
+ selected,
30
+ testId,
31
+ forwardRef,
32
+ autoplay,
33
+ cardPreview,
34
+ onFullscreenChange,
35
+ videoControlsWrapperRef
36
+ }) => {
37
+ // === States ===
38
+ const [fileSrc, setFileSrc] = useState();
39
+ const [isUploading, setIsUploading] = useState();
40
+ const [progress, setProgress] = useState();
41
+
42
+ // === Refs and Local Variables ===
43
+ const divRef = useRef(null);
44
+ const onErrorRef = useRef(onError);
45
+ onErrorRef.current = onError;
46
+ const {
47
+ id,
48
+ collectionName,
49
+ occurrenceKey
50
+ } = identifier;
51
+ const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
52
+ const mediaClient = useMediaClient();
53
+ const {
54
+ fileState
55
+ } = useFileState(id, {
56
+ collectionName,
57
+ occurrenceKey
58
+ });
59
+ useEffect(() => {
60
+ const subscribeFileState = async fileState => {
61
+ if (fileState.status === 'uploading') {
62
+ setIsUploading(true);
63
+ setProgress(fileState.progress);
64
+ } else {
65
+ setIsUploading(false);
59
66
  }
60
- });
61
- _defineProperty(this, "revoke", () => {
62
- const {
63
- fileSrc
64
- } = this.state;
67
+
68
+ // We reuse the existing fileSrc to prevent re renders, therefore we only perform fileSrc updates when there isn't any
65
69
  if (fileSrc) {
66
- URL.revokeObjectURL(fileSrc);
67
- }
68
- });
69
- _defineProperty(this, "onDownloadClick", () => {
70
- const {
71
- mediaClient,
72
- identifier
73
- } = this.props;
74
- const {
75
- id,
76
- collectionName
77
- } = identifier;
78
- mediaClient.file.downloadBinary(id, undefined, collectionName);
79
- });
80
- _defineProperty(this, "onFirstPlay", () => {
81
- const {
82
- identifier
83
- } = this.props;
84
- globalMediaEventEmitter.emit('media-viewed', {
85
- fileId: identifier.id,
86
- viewingLevel: 'full'
87
- });
88
- });
89
- _defineProperty(this, "saveElementWidth", () => {
90
- const {
91
- dimensions
92
- } = this.props;
93
- if (!dimensions) {
94
70
  return;
95
71
  }
96
- const {
97
- width
98
- } = dimensions;
99
- if (width && isValidPercentageUnit(width) && !!this.divRef.current) {
100
- const elementWidth = getElementDimension(this.divRef.current, 'width');
101
- this.setState({
102
- elementWidth
103
- });
104
- }
105
- });
106
- }
107
- componentDidMount() {
108
- this.saveElementWidth();
109
- const {
110
- mediaClient,
111
- identifier
112
- } = this.props;
113
- const {
114
- id,
115
- collectionName
116
- } = identifier;
117
- this.revoke();
118
- this.unsubscribe();
119
- this.subscription = mediaClient.file.getFileState(id, {
120
- collectionName
121
- }).subscribe({
122
- next: async fileState => {
123
- if (fileState.status === 'uploading') {
124
- this.setState({
125
- isUploading: true,
126
- progress: fileState.progress
127
- });
128
- } else {
129
- this.setState({
130
- isUploading: false
131
- });
132
- }
72
+ if (fileState.status !== 'error' && fileState.preview) {
133
73
  const {
134
- fileSrc: existingFileSrc
135
- } = this.state;
136
- // we want to reuse the existing fileSrc to prevent re renders
137
- if (existingFileSrc) {
74
+ value
75
+ } = await fileState.preview;
76
+ if (value instanceof Blob && value.type.indexOf('video/') === 0) {
77
+ const newFileSrc = URL.createObjectURL(value);
78
+ setFileSrc(newFileSrc);
138
79
  return;
139
80
  }
140
- if (fileState.status !== 'error' && fileState.preview) {
141
- const {
142
- value
143
- } = await fileState.preview;
144
- if (value instanceof Blob && value.type.indexOf('video/') === 0) {
145
- const fileSrc = URL.createObjectURL(value);
146
- this.setFileSrc(fileSrc);
147
- return;
148
- }
149
- }
150
- if (fileState.status === 'processed' || fileState.status === 'processing') {
151
- const artifactName = getPreferredVideoArtifact(fileState);
152
- const {
153
- artifacts
154
- } = fileState;
155
- if (!artifactName || !artifacts) {
156
- this.setBinaryURL();
157
- return;
158
- }
81
+ }
82
+ if (fileState.status === 'processed' || fileState.status === 'processing') {
83
+ const artifactName = getPreferredVideoArtifact(fileState);
84
+ const {
85
+ artifacts
86
+ } = fileState;
87
+ if (!artifactName || !artifacts) {
88
+ // Tries to use the binary artifact to provide something to play while the video is still processing
159
89
  try {
160
- const fileSrc = await mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
161
- this.setFileSrc(fileSrc);
90
+ const newFileSrc = await mediaClient.file.getFileBinaryURL(id, collectionName);
91
+ setFileSrc(newFileSrc);
162
92
  } catch (error) {
163
- const {
164
- onError
165
- } = this.props;
166
- if (onError && error instanceof Error) {
167
- onError(error);
93
+ if (onErrorRef.current && error instanceof Error) {
94
+ onErrorRef.current(error);
168
95
  }
169
96
  }
97
+ return;
98
+ }
99
+ try {
100
+ const newFileSrc = await mediaClient.file.getArtifactURL(artifacts, artifactName, collectionName);
101
+ setFileSrc(newFileSrc);
102
+ } catch (error) {
103
+ if (onErrorRef.current && error instanceof Error) {
104
+ onErrorRef.current(error);
105
+ }
170
106
  }
171
107
  }
172
- });
173
- }
174
- componentWillUnmount() {
175
- this.unsubscribe();
176
- this.revoke();
177
- }
178
- get breakpoint() {
179
- const width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || defaultImageCardDimensions.width;
180
- return calcBreakpointSize(parseInt(`${width}`, 10));
181
- }
182
- render() {
183
- const {
184
- onClick,
185
- dimensions,
186
- originalDimensions,
187
- selected,
188
- testId,
189
- identifier,
190
- forwardRef,
191
- autoplay,
192
- cardPreview,
193
- onFullscreenChange,
194
- videoControlsWrapperRef
195
- } = this.props;
196
- const {
197
- fileSrc,
198
- isUploading,
199
- progress
200
- } = this.state;
201
- if (!fileSrc) {
202
- return /*#__PURE__*/React.createElement(CardLoading, {
203
- testId: testId,
204
- dimensions: dimensions
205
- });
108
+ };
109
+ if (fileState) {
110
+ subscribeFileState(fileState);
206
111
  }
207
- return /*#__PURE__*/React.createElement(InlinePlayerWrapper, {
208
- testId: testId || 'media-card-inline-player',
209
- selected: {
210
- selected
211
- },
212
- onClick: onClick,
213
- innerRef: forwardRef || undefined,
214
- dimensions: dimensions
215
- }, /*#__PURE__*/React.createElement(InactivityDetector, null, checkMouseMovement => /*#__PURE__*/React.createElement(CustomMediaPlayer, {
216
- type: "video",
217
- src: fileSrc,
218
- onFullscreenChange: onFullscreenChange,
219
- fileId: identifier.id,
220
- isAutoPlay: autoplay,
221
- isHDAvailable: false,
222
- onDownloadClick: this.onDownloadClick,
223
- onFirstPlay: this.onFirstPlay,
224
- lastWatchTimeConfig: {
225
- contentId: identifier.id
226
- },
227
- originalDimensions: originalDimensions,
228
- showControls: checkMouseMovement,
229
- poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI,
230
- videoControlsWrapperRef: videoControlsWrapperRef
231
- })), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
232
- progress: progress,
233
- breakpoint: this.breakpoint,
234
- positionBottom: true,
235
- showOnTop: true
236
- }) : null);
237
- }
238
- }
239
- _defineProperty(InlinePlayerBase, "defaultProps", {
240
- dimensions: defaultImageCardDimensions
241
- });
112
+ }, [fileState, collectionName, fileSrc, id, mediaClient]);
113
+ useEffect(() => {
114
+ return () => {
115
+ fileSrc && URL.revokeObjectURL(fileSrc);
116
+ };
117
+ }, [fileSrc]);
118
+
119
+ // === Render ===
120
+ return fileSrc ? /*#__PURE__*/React.createElement(InlinePlayerWrapper, {
121
+ testId: testId || 'media-card-inline-player',
122
+ selected: {
123
+ selected
124
+ },
125
+ onClick: onClick,
126
+ innerRef: forwardRef || undefined,
127
+ dimensions: dimensions
128
+ }, /*#__PURE__*/React.createElement(InactivityDetector, null, checkMouseMovement => /*#__PURE__*/React.createElement(CustomMediaPlayer, {
129
+ type: "video",
130
+ src: fileSrc,
131
+ onFullscreenChange: onFullscreenChange,
132
+ fileId: id,
133
+ isAutoPlay: autoplay,
134
+ isHDAvailable: false,
135
+ onDownloadClick: () => {
136
+ mediaClient.file.downloadBinary(id, undefined, collectionName);
137
+ },
138
+ onFirstPlay: () => {
139
+ globalMediaEventEmitter.emit('media-viewed', {
140
+ fileId: id,
141
+ viewingLevel: 'full'
142
+ });
143
+ },
144
+ lastWatchTimeConfig: {
145
+ contentId: id
146
+ },
147
+ originalDimensions: originalDimensions,
148
+ showControls: checkMouseMovement,
149
+ poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI,
150
+ videoControlsWrapperRef: videoControlsWrapperRef
151
+ })), isUploading && /*#__PURE__*/React.createElement(ProgressBar, {
152
+ progress: progress,
153
+ breakpoint: breakpoint,
154
+ positionBottom: true,
155
+ showOnTop: true
156
+ })) : /*#__PURE__*/React.createElement(CardLoading, {
157
+ testId: testId,
158
+ dimensions: dimensions
159
+ });
160
+ };
242
161
  const InlinePlayerForwardRef = /*#__PURE__*/React.forwardRef((props, ref) => {
243
162
  return /*#__PURE__*/React.createElement(InlinePlayerBase, _extends({}, props, {
244
163
  forwardRef: ref