@atlaskit/media-card 77.11.3 → 77.12.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 (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/cardView.js +6 -10
  4. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  5. package/dist/cjs/card/ui/styles.js +1 -12
  6. package/dist/cjs/card/ui/wrapper/imageContainer.js +52 -0
  7. package/dist/cjs/card/ui/wrapper/index.js +8 -1
  8. package/dist/cjs/card/v2/cardV2.js +1 -1
  9. package/dist/cjs/card/v2/cardViewV2.js +12 -17
  10. package/dist/cjs/card/v2/cardviews/cardViewWrapper.js +5 -9
  11. package/dist/cjs/card/v2/fileCard.js +66 -20
  12. package/dist/cjs/card/v2/svgView/helpers.js +16 -0
  13. package/dist/cjs/card/v2/svgView/index.js +12 -0
  14. package/dist/cjs/card/v2/svgView/svgView.js +134 -0
  15. package/dist/cjs/inline/loader.js +1 -1
  16. package/dist/cjs/utils/ufoExperiences.js +1 -1
  17. package/dist/es2019/card/card.js +1 -1
  18. package/dist/es2019/card/cardView.js +8 -12
  19. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  20. package/dist/es2019/card/ui/styles.js +0 -11
  21. package/dist/es2019/card/ui/wrapper/imageContainer.js +44 -0
  22. package/dist/es2019/card/ui/wrapper/index.js +2 -1
  23. package/dist/es2019/card/v2/cardV2.js +1 -1
  24. package/dist/es2019/card/v2/cardViewV2.js +13 -18
  25. package/dist/es2019/card/v2/cardviews/cardViewWrapper.js +6 -10
  26. package/dist/es2019/card/v2/fileCard.js +51 -8
  27. package/dist/es2019/card/v2/svgView/helpers.js +12 -0
  28. package/dist/es2019/card/v2/svgView/index.js +1 -0
  29. package/dist/es2019/card/v2/svgView/svgView.js +113 -0
  30. package/dist/es2019/inline/loader.js +1 -1
  31. package/dist/es2019/utils/ufoExperiences.js +1 -1
  32. package/dist/esm/card/card.js +1 -1
  33. package/dist/esm/card/cardView.js +8 -12
  34. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  35. package/dist/esm/card/ui/styles.js +0 -11
  36. package/dist/esm/card/ui/wrapper/imageContainer.js +45 -0
  37. package/dist/esm/card/ui/wrapper/index.js +2 -1
  38. package/dist/esm/card/v2/cardV2.js +1 -1
  39. package/dist/esm/card/v2/cardViewV2.js +13 -18
  40. package/dist/esm/card/v2/cardviews/cardViewWrapper.js +6 -10
  41. package/dist/esm/card/v2/fileCard.js +66 -20
  42. package/dist/esm/card/v2/svgView/helpers.js +10 -0
  43. package/dist/esm/card/v2/svgView/index.js +1 -0
  44. package/dist/esm/card/v2/svgView/svgView.js +123 -0
  45. package/dist/esm/inline/loader.js +1 -1
  46. package/dist/esm/utils/ufoExperiences.js +1 -1
  47. package/dist/types/card/ui/styles.d.ts +0 -1
  48. package/dist/types/card/ui/wrapper/imageContainer.d.ts +15 -0
  49. package/dist/types/card/ui/wrapper/index.d.ts +1 -0
  50. package/dist/types/card/v2/svgView/helpers.d.ts +3 -0
  51. package/dist/types/card/v2/svgView/index.d.ts +1 -0
  52. package/dist/types/card/v2/svgView/svgView.d.ts +31 -0
  53. package/dist/types-ts4.5/card/ui/styles.d.ts +0 -1
  54. package/dist/types-ts4.5/card/ui/wrapper/imageContainer.d.ts +15 -0
  55. package/dist/types-ts4.5/card/ui/wrapper/index.d.ts +1 -0
  56. package/dist/types-ts4.5/card/v2/svgView/helpers.d.ts +3 -0
  57. package/dist/types-ts4.5/card/v2/svgView/index.d.ts +1 -0
  58. package/dist/types-ts4.5/card/v2/svgView/svgView.d.ts +31 -0
  59. package/example-helpers/svg-helpers/cardContainer.tsx +30 -0
  60. package/example-helpers/svg-helpers/controls.tsx +21 -0
  61. package/example-helpers/svg-helpers/delayApiResponses.ts +31 -0
  62. package/example-helpers/svg-helpers/dimensionPicker.tsx +124 -0
  63. package/example-helpers/svg-helpers/index.ts +7 -0
  64. package/example-helpers/svg-helpers/svgContainer.tsx +32 -0
  65. package/example-helpers/svg-helpers/toggle.tsx +43 -0
  66. package/example-helpers/svg-helpers/uploader.ts +44 -0
  67. package/package.json +11 -3
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
66
66
  }
67
67
  _defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
68
68
  const packageName = "@atlaskit/media-card";
69
- const packageVersion = "77.11.3";
69
+ const packageVersion = "77.12.0";
70
70
  const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
71
71
  packageVersion,
72
72
  packageName,
@@ -1,5 +1,3 @@
1
- import { css } from '@emotion/react';
2
- import { borderRadius } from '@atlaskit/media-ui';
3
1
  import { N60A } from '@atlaskit/theme/colors';
4
2
  import { akEditorSelectedBoxShadow } from '@atlaskit/editor-shared-styles/consts';
5
3
  import { getCSSUnitValue } from '../../utils/getCSSUnitValue';
@@ -65,15 +63,6 @@ export const getSelectableTickBoxStyles = isTickBoxSelectable => {
65
63
  }
66
64
  `;
67
65
  };
68
- export const cardImageContainerStyles = css({
69
- display: 'flex',
70
- position: 'relative',
71
- maxWidth: '100%',
72
- width: '100%',
73
- height: '100%',
74
- maxHeight: '100%',
75
- overflow: 'hidden'
76
- }, borderRadius);
77
66
  const defaultTransitionDuration = '.3s';
78
67
  export const transition = (propertyName = 'all') => `
79
68
  transition: ${propertyName} ${defaultTransitionDuration};
@@ -0,0 +1,44 @@
1
+ /** @jsx jsx */
2
+ import { jsx, css } from '@emotion/react';
3
+ import { fileCardImageViewSelector } from '../../classnames';
4
+ const imageContainerStyles = css({
5
+ display: 'flex',
6
+ position: 'relative',
7
+ maxWidth: '100%',
8
+ width: '100%',
9
+ height: '100%',
10
+ maxHeight: '100%',
11
+ overflow: 'hidden',
12
+ borderRadius: "var(--ds-border-radius, 3px)"
13
+ });
14
+ const imageContainerCenterStyles = css({
15
+ flexDirection: 'column',
16
+ justifyContent: 'center',
17
+ alignItems: 'center'
18
+ });
19
+ export const ImageContainer = ({
20
+ children,
21
+ testId,
22
+ mediaName,
23
+ status,
24
+ progress,
25
+ selected,
26
+ source,
27
+ centerElements
28
+ }) => jsx("div", {
29
+ css: [imageContainerStyles, centerElements && imageContainerCenterStyles],
30
+ "data-testid": fileCardImageViewSelector
31
+ /**
32
+ * This wrapper MUST add the classname in order to allow the editor to prevent bubbling up the click event.
33
+ * See the method isInteractiveElement in source platform/packages/editor/renderer/src/ui/Renderer/click-to-edit.ts
34
+ * Also, many other consumer tests rely on this selector.
35
+ */
36
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
37
+ ,
38
+ className: fileCardImageViewSelector,
39
+ "data-test-media-name": mediaName,
40
+ "data-test-status": status,
41
+ "data-test-progress": progress,
42
+ "data-test-selected": selected,
43
+ "data-test-source": source
44
+ }, children);
@@ -1 +1,2 @@
1
- export { Wrapper } from './wrapper';
1
+ export { Wrapper } from './wrapper';
2
+ export { ImageContainer } from './imageContainer';
@@ -7,7 +7,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
7
7
  import { ExternalImageCard } from './externalImageCard';
8
8
  import { FileCard } from './fileCard';
9
9
  const packageName = "@atlaskit/media-card";
10
- const packageVersion = "77.11.3";
10
+ const packageVersion = "77.12.0";
11
11
  export const CardV2Base = ({
12
12
  identifier,
13
13
  ...otherProps
@@ -8,7 +8,6 @@ import Tooltip from '@atlaskit/tooltip';
8
8
  import { messages } from '@atlaskit/media-ui';
9
9
  import { createAndFireMediaCardEvent } from '../../utils/analytics';
10
10
  import { attachDetailsToActions } from '../actions';
11
- import { cardImageContainerStyles } from '../ui/styles';
12
11
  import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
13
12
  import { TitleBox } from '../ui/titleBox/titleBox';
14
13
  import { FailedTitleBox } from '../ui/titleBox/failedTitleBox';
@@ -20,7 +19,7 @@ import { ActionsBar } from '../ui/actionsBar/actionsBar';
20
19
  import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
21
20
  import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from '../ui/iconMessage';
22
21
  import { isUploadError, isRateLimitedError, isPollingError } from '../../errors';
23
- import { Wrapper } from '../ui/wrapper';
22
+ import { Wrapper, ImageContainer } from '../ui/wrapper';
24
23
  import { fileCardImageViewSelector } from '../classnames';
25
24
  import { useBreakpoint } from '../useBreakpoint';
26
25
  import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
@@ -74,11 +73,11 @@ export const CardViewV2Base = ({
74
73
  return;
75
74
  }
76
75
  /*
77
- We render the icon & icon message always, even if there is cardPreview available.
78
- If the image fails to load/render, the icon will remain, i.e. the user won't see a change until the root card decides to chage status to error.
79
- If the image renders successfully, we switch this variable to hide the icon & icon message behind the thumbnail in case the image has transparency.
80
- It is less likely that root component replaces a suceeded cardPreview for a failed one than the opposite case. Therefore we prefer to hide the icon instead show when the image fails, for a smoother transition
81
- */
76
+ We render the icon & icon message always, even if there is cardPreview available.
77
+ If the image fails to load/render, the icon will remain, i.e. the user won't see a change until the root card decides to chage status to error.
78
+ If the image renders successfully, we switch this variable to hide the icon & icon message behind the thumbnail in case the image has transparency.
79
+ It is less likely that root component replaces a suceeded cardPreview for a failed one than the opposite case. Therefore we prefer to hide the icon instead show when the image fails, for a smoother transition
80
+ */
82
81
  setDidImageRender(true);
83
82
  onImageLoad === null || onImageLoad === void 0 ? void 0 : onImageLoad(cardPreview);
84
83
  };
@@ -205,17 +204,13 @@ export const CardViewV2Base = ({
205
204
  createdAt
206
205
  } = metadata || {};
207
206
  const actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
208
- const contents = jsx(React.Fragment, null, jsx("div", {
209
- css: cardImageContainerStyles
210
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
211
- ,
212
- className: fileCardImageViewSelector,
213
- "data-testid": fileCardImageViewSelector,
214
- "data-test-media-name": name,
215
- "data-test-status": status,
216
- "data-test-progress": progress,
217
- "data-test-selected": selected,
218
- "data-test-source": cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source
207
+ const contents = jsx(React.Fragment, null, jsx(ImageContainer, {
208
+ testId: fileCardImageViewSelector,
209
+ mediaName: name,
210
+ status: status,
211
+ progress: progress,
212
+ selected: selected,
213
+ source: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source
219
214
  }, renderTypeIcon && jsx(IconWrapper, {
220
215
  breakpoint: breakpoint,
221
216
  hasTitleBox: hasTitleBox
@@ -3,9 +3,8 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { jsx } from '@emotion/react';
4
4
  import React from 'react';
5
5
  import Tooltip from '@atlaskit/tooltip';
6
- import { Wrapper } from '../../ui/wrapper';
6
+ import { ImageContainer, Wrapper } from '../../ui/wrapper';
7
7
  import { attachDetailsToActions } from '../../actions';
8
- import { cardImageContainerStyles } from '../../ui/styles';
9
8
  import { TitleBox } from '../../ui/titleBox/titleBox';
10
9
  import { TickBox } from '../../ui/tickBox/tickBox';
11
10
  import { Blanket } from '../../ui/blanket/blanket';
@@ -52,14 +51,11 @@ export const CardViewWrapper = /*#__PURE__*/React.forwardRef(({
52
51
  titleBoxIcon: titleBoxIcon,
53
52
  titleBoxBgColor: titleBoxBgColor
54
53
  });
55
- const contents = jsx(React.Fragment, null, jsx("div", _extends({
56
- css: cardImageContainerStyles
57
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
58
- ,
59
- className: fileCardImageViewSelector,
60
- "data-testid": fileCardImageViewSelector,
61
- "data-test-media-name": name,
62
- "data-test-selected": selected ? true : undefined
54
+ const contents = jsx(React.Fragment, null, jsx(ImageContainer, _extends({
55
+ testId: fileCardImageViewSelector,
56
+ mediaName: name,
57
+ status: status,
58
+ selected: selected ? true : undefined
63
59
  }, props), children, customBlanket ? customBlanket() : defaultBlanket, customTitleBox ? customTitleBox() : defaultTitleBox, !disableOverlay && !!selectable && jsx(TickBox, {
64
60
  selected: selected
65
61
  }), progressBar && progressBar()), !disableOverlay && actions && actions.length !== 0 && jsx(ActionsBar, {
@@ -26,6 +26,7 @@ import { useFilePreview } from '@atlaskit/media-file-preview';
26
26
  import { performanceNow } from './performance';
27
27
  import { useContext } from 'react';
28
28
  import { DateOverrideContext } from '../../dateOverrideContext';
29
+ import { SvgView } from './svgView';
29
30
  const LoadedCardView = getBooleanFF('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardViewV2;
30
31
  export const FileCard = ({
31
32
  appearance = 'auto',
@@ -110,6 +111,7 @@ export const FileCard = ({
110
111
  }), []);
111
112
  const [status, setStatus] = useState('loading');
112
113
  const [isPlayingFile, setIsPlayingFile] = useState(false);
114
+ const [shouldRenderSVG, setShouldRenderSVG] = useState(false);
113
115
  const [shouldAutoplay, setShouldAutoplay] = useState(false);
114
116
  const [previewDidRender, setPreviewDidRender] = useState(false);
115
117
  const mediaBlobUrlAttrs = useMemo(() => {
@@ -393,6 +395,23 @@ export const FileCard = ({
393
395
  }
394
396
  }, [isCardVisible, disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isPlayingFile, finalStatus, useInlinePlayer]);
395
397
 
398
+ //----------------------------------------------------------------//
399
+ // Switch to SVG
400
+ //----------------------------------------------------------------//
401
+
402
+ useEffect(() => {
403
+ if (getBooleanFF('platform.media-svg-rendering') &&
404
+ /**
405
+ * We need to check that the card is visible before switching to SVG
406
+ * in order to avoid race conditions of the ViewportDector being unmounted before
407
+ * it is able to set isCardVisible to true.
408
+ */
409
+ isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay // SVG won't be supported when overlay is on
410
+ ) {
411
+ setShouldRenderSVG(true);
412
+ }
413
+ }, [isCardVisible, disableOverlay, metadata]);
414
+
396
415
  //----------------------------------------------------------------//
397
416
  //----------------- fireScreenEvent ------------------------------//
398
417
  //----------------------------------------------------------------//
@@ -460,6 +479,18 @@ export const FileCard = ({
460
479
  updateFileStateRef.current();
461
480
  }, [fileState, preview, previewStatus, updateFileStateRef]);
462
481
 
482
+ //----------------------------------------------------------------//
483
+ // Shared Card View & SVG View resources
484
+ //----------------------------------------------------------------//
485
+
486
+ const mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, finalStatus === 'error' || finalStatus === 'failed-processing', !!preview, metadata.mediaType);
487
+ const onImageMouseEnter = event => {
488
+ onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter({
489
+ event,
490
+ mediaItemDetails: metadata
491
+ });
492
+ };
493
+
463
494
  //----------------------------------------------------------------//
464
495
  //---------------------- Render Card Function --------------------//
465
496
  //----------------------------------------------------------------//
@@ -478,7 +509,6 @@ export const FileCard = ({
478
509
  const nativeLazyLoad = isLazyWithOverride && !isCardVisible && preview && isSSRPreview(preview);
479
510
  // Force Media Image to always display img for SSR
480
511
  const forceSyncDisplay = !!ssr;
481
- const mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, finalStatus === 'error' || finalStatus === 'failed-processing', !!preview, metadata.mediaType);
482
512
  const card = /*#__PURE__*/React.createElement(LoadedCardView, {
483
513
  status: cardStatusOverride || finalStatus,
484
514
  error: finalError,
@@ -494,12 +524,7 @@ export const FileCard = ({
494
524
  shouldOpenMediaViewer: shouldOpenMediaViewer,
495
525
  openMediaViewerButtonRef: mediaViewerButtonRef,
496
526
  onClick: withCallbacks ? onCardViewClick : undefined,
497
- onMouseEnter: withCallbacks ? event => {
498
- onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter({
499
- event,
500
- mediaItemDetails: metadata
501
- });
502
- } : undefined,
527
+ onMouseEnter: withCallbacks ? onImageMouseEnter : undefined,
503
528
  disableOverlay: disableOverlay,
504
529
  progress: uploadProgressRef.current,
505
530
  onDisplayImage: withCallbacks ? () => {
@@ -557,7 +582,25 @@ export const FileCard = ({
557
582
  testId: testId,
558
583
  cardPreview: preview,
559
584
  videoControlsWrapperRef: videoControlsWrapperRef
560
- })) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
585
+ })) : shouldRenderSVG ? /*#__PURE__*/React.createElement(SvgView, {
586
+ testId: testId,
587
+ identifier: identifier,
588
+ status: finalStatus,
589
+ fileName: metadata.name,
590
+ cardPreview: preview,
591
+ alt: alt,
592
+ resizeMode: resizeMode,
593
+ dimensions: cardDimensions,
594
+ selected: selected,
595
+ onClick: onCardViewClick,
596
+ onMouseEnter: onImageMouseEnter,
597
+ progress: uploadProgressRef.current,
598
+ onImageError: onImageError,
599
+ onImageLoad: onImageLoad,
600
+ mediaCardCursor: mediaCardCursor,
601
+ shouldOpenMediaViewer: shouldOpenMediaViewer,
602
+ openMediaViewerButtonRef: mediaViewerButtonRef
603
+ }) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
561
604
  collectionName: collectionName,
562
605
  items: mediaViewerItems || [],
563
606
  mediaClientConfig: mediaClient.config,
@@ -0,0 +1,12 @@
1
+ export const calculateSvgDimensions = (img, resizeMode) => {
2
+ const {
3
+ naturalWidth,
4
+ naturalHeight
5
+ } = img;
6
+ const isLadscape = naturalWidth / naturalHeight > 1;
7
+ return resizeMode === 'crop' ? isLadscape ? {
8
+ height: '100%'
9
+ } : {
10
+ width: '100%'
11
+ } : {};
12
+ };
@@ -0,0 +1 @@
1
+ export { SvgView } from './svgView';
@@ -0,0 +1,113 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import React, { useState, useRef } from 'react';
4
+ import { withAnalyticsEvents } from '@atlaskit/analytics-next';
5
+ import { createAndFireMediaCardEvent } from '../../../utils/analytics';
6
+ import { ImageRenderer } from '../../ui/imageRenderer/imageRenderer';
7
+ import { ProgressBar } from '../../ui/progressBar/progressBar';
8
+ import { Blanket } from '../../ui/blanket/blanket';
9
+ import { Wrapper, ImageContainer } from '../../ui/wrapper';
10
+ import { fileCardImageViewSelector } from '../../classnames';
11
+ import { useBreakpoint } from '../../useBreakpoint';
12
+ import MediaSvg from '@atlaskit/media-svg';
13
+ import { calculateSvgDimensions } from './helpers';
14
+ import OpenMediaViewerButton from '../../ui/openMediaViewerButton/openMediaViewerButton';
15
+ export const convertResizeMode = resizeMode => {
16
+ switch (resizeMode) {
17
+ case 'crop':
18
+ return 'cover';
19
+ case 'fit':
20
+ case 'full-fit':
21
+ return 'scale-down';
22
+ case 'stretchy-fit':
23
+ return 'contain';
24
+ default:
25
+ return;
26
+ }
27
+ };
28
+ export const SvgViewBase = ({
29
+ identifier,
30
+ dimensions,
31
+ onClick,
32
+ onMouseEnter,
33
+ testId,
34
+ status,
35
+ selected,
36
+ fileName,
37
+ cardPreview,
38
+ mediaCardCursor,
39
+ progress,
40
+ alt,
41
+ resizeMode,
42
+ shouldOpenMediaViewer,
43
+ openMediaViewerButtonRef = null
44
+ }) => {
45
+ const [didSvgRender, setDidSvgRender] = useState(false);
46
+ const [didPreviewRender, setDidPreviewRender] = useState(false);
47
+ const [svgDimensions, setSvgDimensions] = useState();
48
+ const divRef = useRef(null);
49
+ const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
50
+ const onSvgLoad = evt => {
51
+ setSvgDimensions(calculateSvgDimensions(evt.currentTarget, resizeMode));
52
+ setDidSvgRender(true);
53
+ };
54
+ const onPreviewLoad = () => {
55
+ setDidPreviewRender(true);
56
+ };
57
+ return jsx(React.Fragment, null, shouldOpenMediaViewer && jsx(OpenMediaViewerButton, {
58
+ fileName: fileName !== null && fileName !== void 0 ? fileName : '',
59
+ innerRef: openMediaViewerButtonRef,
60
+ onClick: onClick
61
+ }), jsx(Wrapper, {
62
+ testId: testId || 'media-card-svg-wrapper',
63
+ dimensions: dimensions,
64
+ onClick: onClick,
65
+ onMouseEnter: onMouseEnter,
66
+ innerRef: divRef,
67
+ mediaCardCursor: mediaCardCursor,
68
+ selected: !!selected,
69
+ breakpoint: breakpoint,
70
+ disableOverlay: true,
71
+ displayBackground: !didSvgRender && !didPreviewRender,
72
+ isTickBoxSelectable: false,
73
+ shouldDisplayTooltip: false,
74
+ isPlayButtonClickable: false
75
+ }, jsx(ImageContainer, {
76
+ centerElements: true,
77
+ testId: fileCardImageViewSelector,
78
+ mediaName: fileName,
79
+ status: status,
80
+ progress: progress,
81
+ selected: selected,
82
+ source: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source
83
+ }, jsx(MediaSvg, {
84
+ testId: "media-card-svg",
85
+ identifier: identifier,
86
+ dimensions: svgDimensions,
87
+ onLoad: onSvgLoad,
88
+ style: {
89
+ visibility: didSvgRender ? 'visible' : 'hidden',
90
+ objectFit: convertResizeMode(resizeMode)
91
+ }
92
+ }), !!cardPreview && !didSvgRender && jsx(ImageRenderer, {
93
+ cardPreview: cardPreview,
94
+ onImageLoad: onPreviewLoad,
95
+ mediaType: 'image',
96
+ alt: alt,
97
+ resizeMode: resizeMode
98
+ }), status === 'uploading' && jsx(Blanket, {
99
+ isFixed: true
100
+ }), status === 'uploading' && jsx(ProgressBar, {
101
+ progress: progress,
102
+ breakpoint: breakpoint,
103
+ positionBottom: true
104
+ }))));
105
+ };
106
+ export const SvgView = withAnalyticsEvents({
107
+ onClick: createAndFireMediaCardEvent({
108
+ eventType: 'ui',
109
+ action: 'clicked',
110
+ actionSubject: 'mediaCard',
111
+ attributes: {}
112
+ })
113
+ })(SvgViewBase);
@@ -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.11.3",
40
+ packageName: "77.12.0",
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.11.3";
7
+ const packageVersion = "77.12.0";
8
8
  let concurrentExperience;
9
9
  const getExperience = id => {
10
10
  if (!concurrentExperience) {
@@ -41,7 +41,7 @@ import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '.
41
41
  import { generateUniqueId } from '../utils/generateUniqueId';
42
42
  import { DateOverrideContext } from '../dateOverrideContext';
43
43
  var packageName = "@atlaskit/media-card";
44
- var packageVersion = "77.11.3";
44
+ var packageVersion = "77.12.0";
45
45
  export var CardBase = /*#__PURE__*/function (_Component) {
46
46
  _inherits(CardBase, _Component);
47
47
  var _super = _createSuper(CardBase);
@@ -22,7 +22,7 @@ import { isValidPercentageUnit } from '../utils/isValidPercentageUnit';
22
22
  import { getElementDimension } from '../utils/getElementDimension';
23
23
  import { createAndFireMediaCardEvent } from '../utils/analytics';
24
24
  import { attachDetailsToActions } from './actions';
25
- import { cardImageContainerStyles, calcBreakpointSize } from './ui/styles';
25
+ import { calcBreakpointSize } from './ui/styles';
26
26
  import { ImageRenderer } from './ui/imageRenderer/imageRenderer';
27
27
  import { TitleBox } from './ui/titleBox/titleBox';
28
28
  import { FailedTitleBox } from './ui/titleBox/failedTitleBox';
@@ -34,7 +34,7 @@ import { ActionsBar } from './ui/actionsBar/actionsBar';
34
34
  import { IconWrapper } from './ui/iconWrapper/iconWrapper';
35
35
  import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from './ui/iconMessage';
36
36
  import { isUploadError, isRateLimitedError, isPollingError } from '../errors';
37
- import { Wrapper } from './ui/wrapper';
37
+ import { ImageContainer, Wrapper } from './ui/wrapper';
38
38
  import { fileCardImageViewSelector } from './classnames';
39
39
  import OpenMediaViewerButton from './ui/openMediaViewerButton/openMediaViewerButton';
40
40
  /**
@@ -200,16 +200,12 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
200
200
  var _ref3 = metadata || {},
201
201
  name = _ref3.name;
202
202
  var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
203
- return jsx(React.Fragment, null, jsx("div", {
204
- css: cardImageContainerStyles
205
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
206
- ,
207
- className: fileCardImageViewSelector,
208
- "data-testid": fileCardImageViewSelector,
209
- "data-test-media-name": name,
210
- "data-test-status": status,
211
- "data-test-progress": progress,
212
- "data-test-selected": selected ? true : undefined
203
+ return jsx(React.Fragment, null, jsx(ImageContainer, {
204
+ testId: fileCardImageViewSelector,
205
+ mediaName: name,
206
+ status: status,
207
+ progress: progress,
208
+ selected: selected ? true : undefined
213
209
  }, renderTypeIcon && _this.renderMediaTypeIcon(hasTitleBox, iconMessage), renderSpinner && _this.renderSpinner(hasTitleBox), renderImageRenderer && _this.renderImageRenderer(), renderPlayButton && _this.renderPlayButton(hasTitleBox), renderBlanket && _this.renderBlanket(!!isFixedBlanket), renderTitleBox && _this.renderTitleBox(), renderFailedTitleBox && _this.renderFailedTitleBox(customTitleMessage), renderProgressBar && _this.renderProgressBar(!hasTitleBox), renderTickBox && _this.renderTickBox()), _this.renderActionsBar());
214
210
  });
215
211
  return _this;
@@ -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.11.3";
86
+ var packageVersion = "77.12.0";
87
87
  var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
88
88
  packageVersion: packageVersion,
89
89
  packageName: packageName,
@@ -1,6 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { css } from '@emotion/react';
3
- import { borderRadius } from '@atlaskit/media-ui';
4
2
  import { N60A } from '@atlaskit/theme/colors';
5
3
  import { akEditorSelectedBoxShadow } from '@atlaskit/editor-shared-styles/consts';
6
4
  import { getCSSUnitValue } from '../../utils/getCSSUnitValue';
@@ -59,15 +57,6 @@ export var getSelectableTickBoxStyles = function getSelectableTickBoxStyles(isTi
59
57
  }
60
58
  return "\n &:hover .".concat(tickBoxClassName, " {\n ").concat(tickboxFixedStyles, "\n }\n ");
61
59
  };
62
- export var cardImageContainerStyles = css({
63
- display: 'flex',
64
- position: 'relative',
65
- maxWidth: '100%',
66
- width: '100%',
67
- height: '100%',
68
- maxHeight: '100%',
69
- overflow: 'hidden'
70
- }, borderRadius);
71
60
  var defaultTransitionDuration = '.3s';
72
61
  export var transition = function transition() {
73
62
  var propertyName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all';
@@ -0,0 +1,45 @@
1
+ /** @jsx jsx */
2
+ import { jsx, css } from '@emotion/react';
3
+ import { fileCardImageViewSelector } from '../../classnames';
4
+ var imageContainerStyles = css({
5
+ display: 'flex',
6
+ position: 'relative',
7
+ maxWidth: '100%',
8
+ width: '100%',
9
+ height: '100%',
10
+ maxHeight: '100%',
11
+ overflow: 'hidden',
12
+ borderRadius: "var(--ds-border-radius, 3px)"
13
+ });
14
+ var imageContainerCenterStyles = css({
15
+ flexDirection: 'column',
16
+ justifyContent: 'center',
17
+ alignItems: 'center'
18
+ });
19
+ export var ImageContainer = function ImageContainer(_ref) {
20
+ var children = _ref.children,
21
+ testId = _ref.testId,
22
+ mediaName = _ref.mediaName,
23
+ status = _ref.status,
24
+ progress = _ref.progress,
25
+ selected = _ref.selected,
26
+ source = _ref.source,
27
+ centerElements = _ref.centerElements;
28
+ return jsx("div", {
29
+ css: [imageContainerStyles, centerElements && imageContainerCenterStyles],
30
+ "data-testid": fileCardImageViewSelector
31
+ /**
32
+ * This wrapper MUST add the classname in order to allow the editor to prevent bubbling up the click event.
33
+ * See the method isInteractiveElement in source platform/packages/editor/renderer/src/ui/Renderer/click-to-edit.ts
34
+ * Also, many other consumer tests rely on this selector.
35
+ */
36
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
37
+ ,
38
+ className: fileCardImageViewSelector,
39
+ "data-test-media-name": mediaName,
40
+ "data-test-status": status,
41
+ "data-test-progress": progress,
42
+ "data-test-selected": selected,
43
+ "data-test-source": source
44
+ }, children);
45
+ };
@@ -1 +1,2 @@
1
- export { Wrapper } from './wrapper';
1
+ export { Wrapper } from './wrapper';
2
+ export { ImageContainer } from './imageContainer';
@@ -9,7 +9,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
9
9
  import { ExternalImageCard } from './externalImageCard';
10
10
  import { FileCard } from './fileCard';
11
11
  var packageName = "@atlaskit/media-card";
12
- var packageVersion = "77.11.3";
12
+ var packageVersion = "77.12.0";
13
13
  export var CardV2Base = function CardV2Base(_ref) {
14
14
  var identifier = _ref.identifier,
15
15
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -12,7 +12,6 @@ import Tooltip from '@atlaskit/tooltip';
12
12
  import { messages } from '@atlaskit/media-ui';
13
13
  import { createAndFireMediaCardEvent } from '../../utils/analytics';
14
14
  import { attachDetailsToActions } from '../actions';
15
- import { cardImageContainerStyles } from '../ui/styles';
16
15
  import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
17
16
  import { TitleBox } from '../ui/titleBox/titleBox';
18
17
  import { FailedTitleBox } from '../ui/titleBox/failedTitleBox';
@@ -24,7 +23,7 @@ import { ActionsBar } from '../ui/actionsBar/actionsBar';
24
23
  import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
25
24
  import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from '../ui/iconMessage';
26
25
  import { isUploadError, isRateLimitedError, isPollingError } from '../../errors';
27
- import { Wrapper } from '../ui/wrapper';
26
+ import { Wrapper, ImageContainer } from '../ui/wrapper';
28
27
  import { fileCardImageViewSelector } from '../classnames';
29
28
  import { useBreakpoint } from '../useBreakpoint';
30
29
  import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
@@ -81,11 +80,11 @@ export var CardViewV2Base = function CardViewV2Base(_ref) {
81
80
  return;
82
81
  }
83
82
  /*
84
- We render the icon & icon message always, even if there is cardPreview available.
85
- If the image fails to load/render, the icon will remain, i.e. the user won't see a change until the root card decides to chage status to error.
86
- If the image renders successfully, we switch this variable to hide the icon & icon message behind the thumbnail in case the image has transparency.
87
- It is less likely that root component replaces a suceeded cardPreview for a failed one than the opposite case. Therefore we prefer to hide the icon instead show when the image fails, for a smoother transition
88
- */
83
+ We render the icon & icon message always, even if there is cardPreview available.
84
+ If the image fails to load/render, the icon will remain, i.e. the user won't see a change until the root card decides to chage status to error.
85
+ If the image renders successfully, we switch this variable to hide the icon & icon message behind the thumbnail in case the image has transparency.
86
+ It is less likely that root component replaces a suceeded cardPreview for a failed one than the opposite case. Therefore we prefer to hide the icon instead show when the image fails, for a smoother transition
87
+ */
89
88
  setDidImageRender(true);
90
89
  onImageLoad === null || onImageLoad === void 0 || onImageLoad(cardPreview);
91
90
  };
@@ -201,17 +200,13 @@ export var CardViewV2Base = function CardViewV2Base(_ref) {
201
200
  name = _ref5.name,
202
201
  createdAt = _ref5.createdAt;
203
202
  var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
204
- var contents = jsx(React.Fragment, null, jsx("div", {
205
- css: cardImageContainerStyles
206
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
207
- ,
208
- className: fileCardImageViewSelector,
209
- "data-testid": fileCardImageViewSelector,
210
- "data-test-media-name": name,
211
- "data-test-status": status,
212
- "data-test-progress": progress,
213
- "data-test-selected": selected,
214
- "data-test-source": cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source
203
+ var contents = jsx(React.Fragment, null, jsx(ImageContainer, {
204
+ testId: fileCardImageViewSelector,
205
+ mediaName: name,
206
+ status: status,
207
+ progress: progress,
208
+ selected: selected,
209
+ source: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source
215
210
  }, renderTypeIcon && jsx(IconWrapper, {
216
211
  breakpoint: breakpoint,
217
212
  hasTitleBox: hasTitleBox