@atlaskit/media-card 78.1.2 → 78.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 (60) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/card/card.js +1 -1
  3. package/dist/cjs/card/fileCard.js +1 -3
  4. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  5. package/dist/cjs/inline/loader.js +1 -1
  6. package/dist/cjs/utils/mediaPerformanceObserver/mediaPerformanceObserver.js +1 -1
  7. package/dist/cjs/utils/ufoExperiences.js +1 -1
  8. package/dist/es2019/card/card.js +1 -1
  9. package/dist/es2019/card/fileCard.js +1 -3
  10. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  11. package/dist/es2019/inline/loader.js +1 -1
  12. package/dist/es2019/utils/mediaPerformanceObserver/mediaPerformanceObserver.js +1 -1
  13. package/dist/es2019/utils/ufoExperiences.js +1 -1
  14. package/dist/esm/card/card.js +1 -1
  15. package/dist/esm/card/fileCard.js +1 -3
  16. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  17. package/dist/esm/inline/loader.js +1 -1
  18. package/dist/esm/utils/mediaPerformanceObserver/mediaPerformanceObserver.js +1 -1
  19. package/dist/esm/utils/ufoExperiences.js +1 -1
  20. package/package.json +12 -16
  21. package/dist/cjs/card/cardviews/cardViewWrapper.js +0 -112
  22. package/dist/cjs/card/cardviews/errorCardView.js +0 -91
  23. package/dist/cjs/card/cardviews/iconCardView.js +0 -83
  24. package/dist/cjs/card/cardviews/imageCardView.js +0 -93
  25. package/dist/cjs/card/cardviews/index.js +0 -292
  26. package/dist/cjs/card/cardviews/loadingCardView.js +0 -58
  27. package/dist/cjs/card/cardviews/processingCardView.js +0 -69
  28. package/dist/cjs/card/cardviews/videoCardView.js +0 -98
  29. package/dist/es2019/card/cardviews/cardViewWrapper.js +0 -103
  30. package/dist/es2019/card/cardviews/errorCardView.js +0 -86
  31. package/dist/es2019/card/cardviews/iconCardView.js +0 -74
  32. package/dist/es2019/card/cardviews/imageCardView.js +0 -79
  33. package/dist/es2019/card/cardviews/index.js +0 -278
  34. package/dist/es2019/card/cardviews/loadingCardView.js +0 -53
  35. package/dist/es2019/card/cardviews/processingCardView.js +0 -64
  36. package/dist/es2019/card/cardviews/videoCardView.js +0 -84
  37. package/dist/esm/card/cardviews/cardViewWrapper.js +0 -105
  38. package/dist/esm/card/cardviews/errorCardView.js +0 -83
  39. package/dist/esm/card/cardviews/iconCardView.js +0 -75
  40. package/dist/esm/card/cardviews/imageCardView.js +0 -85
  41. package/dist/esm/card/cardviews/index.js +0 -281
  42. package/dist/esm/card/cardviews/loadingCardView.js +0 -50
  43. package/dist/esm/card/cardviews/processingCardView.js +0 -61
  44. package/dist/esm/card/cardviews/videoCardView.js +0 -90
  45. package/dist/types/card/cardviews/cardViewWrapper.d.ts +0 -41
  46. package/dist/types/card/cardviews/errorCardView.d.ts +0 -15
  47. package/dist/types/card/cardviews/iconCardView.d.ts +0 -17
  48. package/dist/types/card/cardviews/imageCardView.d.ts +0 -34
  49. package/dist/types/card/cardviews/index.d.ts +0 -51
  50. package/dist/types/card/cardviews/loadingCardView.d.ts +0 -14
  51. package/dist/types/card/cardviews/processingCardView.d.ts +0 -11
  52. package/dist/types/card/cardviews/videoCardView.d.ts +0 -34
  53. package/dist/types-ts4.5/card/cardviews/cardViewWrapper.d.ts +0 -41
  54. package/dist/types-ts4.5/card/cardviews/errorCardView.d.ts +0 -15
  55. package/dist/types-ts4.5/card/cardviews/iconCardView.d.ts +0 -17
  56. package/dist/types-ts4.5/card/cardviews/imageCardView.d.ts +0 -34
  57. package/dist/types-ts4.5/card/cardviews/index.d.ts +0 -51
  58. package/dist/types-ts4.5/card/cardviews/loadingCardView.d.ts +0 -14
  59. package/dist/types-ts4.5/card/cardviews/processingCardView.d.ts +0 -11
  60. package/dist/types-ts4.5/card/cardviews/videoCardView.d.ts +0 -34
@@ -1,103 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { jsx } from '@emotion/react';
8
- import React from 'react';
9
- import Tooltip from '@atlaskit/tooltip';
10
- import { ImageContainer, Wrapper } from '../ui/wrapper';
11
- import { attachDetailsToActions } from '../actions';
12
- import { TitleBox } from '../ui/titleBox/titleBox';
13
- import { TickBox } from '../ui/tickBox/tickBox';
14
- import { Blanket } from '../ui/blanket/blanket';
15
- import { ActionsBar } from '../ui/actionsBar/actionsBar';
16
- import { fileCardImageViewSelector } from '../classnames';
17
- import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
18
- export const CardViewWrapper = /*#__PURE__*/React.forwardRef(({
19
- cardPreview,
20
- testId,
21
- dimensions,
22
- appearance = 'auto',
23
- metadata,
24
- selected,
25
- selectable,
26
- actions,
27
- breakpoint,
28
- disableOverlay,
29
- titleBoxBgColor,
30
- titleBoxIcon,
31
- shouldHideTooltip,
32
- children,
33
- onClick,
34
- onMouseEnter,
35
- mediaCardCursor,
36
- customBlanket,
37
- customTitleBox,
38
- progressBar,
39
- shouldOpenMediaViewer,
40
- openMediaViewerButtonRef = null,
41
- overriddenCreationDate,
42
- ...props
43
- }, ref) => {
44
- const {
45
- name,
46
- createdAt,
47
- mediaType
48
- } = metadata || {};
49
- const actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
50
- const defaultBlanket = !disableOverlay && jsx(Blanket, null);
51
- const defaultTitleBox = !disableOverlay && !!name && jsx(TitleBox, {
52
- name: name,
53
- createdAt: overriddenCreationDate !== null && overriddenCreationDate !== void 0 ? overriddenCreationDate : createdAt,
54
- breakpoint: breakpoint,
55
- titleBoxIcon: titleBoxIcon,
56
- titleBoxBgColor: titleBoxBgColor
57
- });
58
- const contents = jsx(React.Fragment, null, jsx(ImageContainer, _extends({
59
- testId: fileCardImageViewSelector,
60
- mediaName: name,
61
- status: status,
62
- selected: selected ? true : undefined
63
- }, props), children, customBlanket ? customBlanket() : defaultBlanket, customTitleBox ? customTitleBox() : defaultTitleBox, !disableOverlay && !!selectable && jsx(TickBox, {
64
- selected: selected
65
- }), progressBar && progressBar()), !disableOverlay && actions && actions.length !== 0 && jsx(ActionsBar, {
66
- filename: name,
67
- actions: actionsWithDetails
68
- }));
69
- const shouldRenderPlayButton = () => {
70
- if (mediaType !== 'video' || !cardPreview) {
71
- return false;
72
- }
73
- return true;
74
- };
75
- const isPlayButtonClickable = shouldRenderPlayButton() && disableOverlay;
76
- const isTickBoxSelectable = !disableOverlay && !!selectable && !selected;
77
- const shouldDisplayTooltip = !disableOverlay && !shouldHideTooltip;
78
- const shouldDisplayBackground = !cardPreview || !disableOverlay;
79
- return jsx(React.Fragment, null, shouldOpenMediaViewer && jsx(OpenMediaViewerButton, {
80
- fileName: name !== null && name !== void 0 ? name : '',
81
- innerRef: openMediaViewerButtonRef,
82
- onClick: onClick
83
- }), jsx(Wrapper, {
84
- testId: testId || 'media-card-view',
85
- dimensions: dimensions,
86
- appearance: appearance,
87
- onClick: onClick,
88
- onMouseEnter: onMouseEnter,
89
- innerRef: ref,
90
- breakpoint: breakpoint,
91
- mediaCardCursor: mediaCardCursor,
92
- disableOverlay: !!disableOverlay,
93
- selected: !!selected,
94
- displayBackground: shouldDisplayBackground,
95
- isPlayButtonClickable: !!isPlayButtonClickable,
96
- isTickBoxSelectable: isTickBoxSelectable,
97
- shouldDisplayTooltip: shouldDisplayTooltip
98
- }, shouldDisplayTooltip ? jsx(Tooltip, {
99
- content: name,
100
- position: "bottom",
101
- tag: "div"
102
- }, contents) : contents));
103
- });
@@ -1,86 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { jsx } from '@emotion/react';
8
- import { useRef } from 'react';
9
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
10
- import { createAndFireMediaCardEvent } from '../../utils/analytics';
11
- import { useBreakpoint } from '../useBreakpoint';
12
- import { CardViewWrapper } from './cardViewWrapper';
13
- import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
14
- import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
15
- import { FailedTitleBox } from '../ui/titleBox/failedTitleBox';
16
- import { PreviewUnavailable, FailedToUpload, PreviewCurrentlyUnavailable, FailedToLoad } from '../ui/iconMessage';
17
- import { isUploadError, isRateLimitedError, isPollingError } from '../../errors';
18
- import { messages } from '@atlaskit/media-ui';
19
- const IconMessage = ({
20
- error,
21
- metadata
22
- }) => {
23
- const {
24
- secondaryError
25
- } = error || {};
26
- if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
27
- return jsx(PreviewCurrentlyUnavailable, null);
28
- } else if (isUploadError(error)) {
29
- return jsx(FailedToUpload, null);
30
- } else if (!metadata) {
31
- return jsx(FailedToLoad, null);
32
- } else {
33
- return jsx(PreviewUnavailable, null);
34
- }
35
- };
36
- const ErrorCardViewBase = props => {
37
- const {
38
- error,
39
- metadata,
40
- dimensions,
41
- disableOverlay
42
- } = props;
43
- const {
44
- name,
45
- mediaType,
46
- mimeType
47
- } = metadata || {};
48
- const divRef = useRef(null);
49
- const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
50
- const customMessage = isUploadError(props.error) ? messages.failed_to_upload : undefined;
51
- const renderFailedTitleBox = !disableOverlay && (!name || !!customMessage);
52
- const renderTitleBox = !disableOverlay && !!name && !customMessage;
53
- const hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
54
- return jsx(CardViewWrapper, _extends({}, props, {
55
- metadata: metadata,
56
- breakpoint: breakpoint,
57
- "data-test-status": "error",
58
- ref: divRef,
59
- customTitleBox: renderFailedTitleBox ? () => jsx(FailedTitleBox, {
60
- breakpoint: breakpoint,
61
- customMessage: customMessage
62
- }) : undefined
63
- }), jsx(IconWrapper, {
64
- breakpoint: breakpoint,
65
- hasTitleBox: hasTitleBox
66
- }, jsx(MimeTypeIcon, {
67
- testId: "media-card-file-type-icon",
68
- mediaType: mediaType,
69
- mimeType: mimeType,
70
- name: name
71
- }), !renderFailedTitleBox && jsx(IconMessage, {
72
- error: error,
73
- metadata: metadata
74
- })));
75
- };
76
-
77
- // TODO: check if analytics is correct
78
-
79
- export const ErrorCardView = withAnalyticsEvents({
80
- onClick: createAndFireMediaCardEvent({
81
- eventType: 'ui',
82
- action: 'clicked',
83
- actionSubject: 'mediaCard',
84
- attributes: {}
85
- })
86
- })(ErrorCardViewBase);
@@ -1,74 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { jsx } from '@emotion/react';
8
- import { useEffect, useRef } from 'react';
9
- import { MimeTypeIcon } from '@atlaskit/media-ui/mime-type-icon';
10
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
11
- import { createAndFireMediaCardEvent } from '../../utils/analytics';
12
- import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
13
- import { useBreakpoint } from '../useBreakpoint';
14
- import { CardViewWrapper } from './cardViewWrapper';
15
- import { ProgressBar } from '../ui/progressBar/progressBar';
16
- import { Blanket } from '../ui/blanket/blanket';
17
- // NOTE: should we call this Icon or UploadingCardView since we now have ProgressBar?
18
-
19
- const IconCardViewBase = props => {
20
- const {
21
- dimensions,
22
- metadata,
23
- disableOverlay,
24
- innerRef,
25
- progress,
26
- status
27
- } = props;
28
- const divRef = useRef(null);
29
- const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
30
- useEffect(() => {
31
- innerRef && !!divRef.current && innerRef(divRef.current);
32
- }, [innerRef]);
33
- const {
34
- name,
35
- mediaType,
36
- mimeType
37
- } = metadata || {};
38
- const hasTitleBox = !disableOverlay && !!name;
39
- const isUploading = status === 'uploading';
40
- return jsx(CardViewWrapper, _extends({}, props, {
41
- metadata: metadata,
42
- breakpoint: breakpoint,
43
- "data-test-status": status,
44
- "data-test-progress": progress,
45
- ref: divRef,
46
- customBlanket: () => jsx(Blanket, {
47
- isFixed: isUploading
48
- }),
49
- progressBar: isUploading ? () => jsx(ProgressBar, {
50
- progress: progress,
51
- breakpoint: breakpoint,
52
- positionBottom: !hasTitleBox
53
- }) : undefined
54
- }), jsx(IconWrapper, {
55
- breakpoint: breakpoint,
56
- hasTitleBox: hasTitleBox
57
- }, jsx(MimeTypeIcon, {
58
- testId: "media-card-file-type-icon",
59
- mediaType: mediaType,
60
- mimeType: mimeType,
61
- name: name
62
- })));
63
- };
64
-
65
- // TODO: check if analytics is correct
66
-
67
- export const IconCardView = withAnalyticsEvents({
68
- onClick: createAndFireMediaCardEvent({
69
- eventType: 'ui',
70
- action: 'clicked',
71
- actionSubject: 'mediaCard',
72
- attributes: {}
73
- })
74
- })(IconCardViewBase);
@@ -1,79 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { jsx } from '@emotion/react';
8
- import { useEffect, useRef } from 'react';
9
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
10
- import { createAndFireMediaCardEvent } from '../../utils/analytics';
11
- import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
12
- import { useBreakpoint } from '../useBreakpoint';
13
- import { CardViewWrapper } from './cardViewWrapper';
14
- import { ProgressBar } from '../ui/progressBar/progressBar';
15
- import { Blanket } from '../ui/blanket/blanket';
16
- const ImageCardViewBase = props => {
17
- const {
18
- status,
19
- dimensions,
20
- metadata,
21
- disableOverlay,
22
- innerRef,
23
- progress,
24
- cardPreview,
25
- alt,
26
- resizeMode,
27
- onDisplayImage,
28
- nativeLazyLoad,
29
- forceSyncDisplay,
30
- onImageLoad,
31
- onImageError
32
- } = props;
33
- const divRef = useRef(null);
34
- const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
35
- useEffect(() => {
36
- innerRef && !!divRef.current && innerRef(divRef.current);
37
- }, [innerRef]);
38
- const {
39
- name,
40
- mediaType = 'unknown'
41
- } = metadata || {};
42
- const hasTitleBox = !disableOverlay && !!name;
43
- const isUploading = status === 'uploading';
44
- return jsx(CardViewWrapper, _extends({}, props, {
45
- breakpoint: breakpoint,
46
- "data-test-status": status,
47
- "data-test-progress": progress,
48
- ref: divRef,
49
- customBlanket: () => jsx(Blanket, {
50
- isFixed: isUploading
51
- }),
52
- progressBar: isUploading ? () => jsx(ProgressBar, {
53
- progress: progress,
54
- breakpoint: breakpoint,
55
- positionBottom: !hasTitleBox
56
- }) : undefined
57
- }), jsx(ImageRenderer, {
58
- cardPreview: cardPreview,
59
- mediaType: mediaType,
60
- alt: alt,
61
- resizeMode: resizeMode,
62
- onDisplayImage: onDisplayImage,
63
- onImageLoad: () => onImageLoad === null || onImageLoad === void 0 ? void 0 : onImageLoad(cardPreview),
64
- onImageError: () => onImageError === null || onImageError === void 0 ? void 0 : onImageError(cardPreview),
65
- nativeLazyLoad: nativeLazyLoad,
66
- forceSyncDisplay: forceSyncDisplay
67
- }));
68
- };
69
-
70
- // TODO: check if analytics is correct
71
-
72
- export const ImageCardView = withAnalyticsEvents({
73
- onClick: createAndFireMediaCardEvent({
74
- eventType: 'ui',
75
- action: 'clicked',
76
- actionSubject: 'mediaCard',
77
- attributes: {}
78
- })
79
- })(ImageCardViewBase);
@@ -1,278 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { jsx } from '@emotion/react';
8
- import React, { useEffect, useState, useRef } from 'react';
9
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
10
- import { createAndFireMediaCardEvent } from '../../utils/analytics';
11
- import { useBreakpoint } from '../useBreakpoint';
12
- import { ProcessingCardView } from './processingCardView';
13
- import { ErrorCardView } from './errorCardView';
14
- import { VideoCardView } from './videoCardView';
15
- import { ImageCardView } from './imageCardView';
16
- import { IconCardView } from './iconCardView';
17
- import { LoadingCardView } from './loadingCardView';
18
- export const CardViewsBase = ({
19
- innerRef,
20
- onImageLoad,
21
- onImageError,
22
- dimensions,
23
- appearance = 'auto',
24
- onClick,
25
- onMouseEnter,
26
- testId,
27
- metadata,
28
- status,
29
- selected,
30
- selectable,
31
- cardPreview,
32
- mediaCardCursor,
33
- shouldHideTooltip,
34
- progress,
35
- alt,
36
- resizeMode,
37
- onDisplayImage,
38
- nativeLazyLoad,
39
- forceSyncDisplay,
40
- actions,
41
- disableOverlay,
42
- titleBoxBgColor,
43
- titleBoxIcon,
44
- error,
45
- disableAnimation,
46
- shouldOpenMediaViewer,
47
- openMediaViewerButtonRef,
48
- overriddenCreationDate
49
- }) => {
50
- const [didImageRender, setDidImageRender] = useState(false);
51
- const divRef = useRef(null);
52
- const prevCardPreviewRef = useRef();
53
- const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
54
- useEffect(() => {
55
- innerRef && !!divRef.current && innerRef(divRef.current);
56
- }, [innerRef]);
57
-
58
- /* didImageRender movements */
59
-
60
- useEffect(() => {
61
- // We should only switch didImageRender to false when cardPreview goes undefined, not when it is changed. as this method could be triggered after onImageLoad callback, falling on a race condition
62
- if (prevCardPreviewRef.current && !cardPreview) {
63
- setDidImageRender(false);
64
- }
65
- prevCardPreviewRef.current = cardPreview;
66
- }, [cardPreview]);
67
- const handleOnImageLoad = prevCardPreview => {
68
- if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
69
- return;
70
- }
71
- setDidImageRender(true);
72
- onImageLoad === null || onImageLoad === void 0 ? void 0 : onImageLoad(cardPreview);
73
- };
74
- const handleOnImageError = prevCardPreview => {
75
- if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
76
- return;
77
- }
78
- setDidImageRender(false);
79
- onImageError === null || onImageError === void 0 ? void 0 : onImageError(cardPreview);
80
- };
81
- const getRenderConfigByStatus = () => {
82
- const {
83
- mediaType
84
- } = metadata || {};
85
-
86
- // TODO: figure out if data-test-progress for all the card views
87
-
88
- const baseProps = {
89
- testId,
90
- dimensions,
91
- appearance,
92
- metadata,
93
- selected,
94
- selectable,
95
- actions,
96
- breakpoint,
97
- disableOverlay,
98
- titleBoxBgColor,
99
- titleBoxIcon,
100
- shouldHideTooltip,
101
- onClick,
102
- onMouseEnter,
103
- mediaCardCursor,
104
- innerRef,
105
- shouldOpenMediaViewer,
106
- openMediaViewerButtonRef,
107
- overriddenCreationDate
108
- };
109
- switch (status) {
110
- case 'uploading':
111
- if (cardPreview) {
112
- return jsx(React.Fragment, null, jsx("div", {
113
- style: {
114
- display: !didImageRender ? 'none' : 'inline'
115
- }
116
- }, mediaType === 'video' ? jsx(VideoCardView, _extends({}, baseProps, {
117
- status: status,
118
- cardPreview: cardPreview,
119
- alt: alt,
120
- resizeMode: resizeMode,
121
- onDisplayImage: onDisplayImage,
122
- onImageLoad: handleOnImageLoad,
123
- onImageError: handleOnImageError,
124
- nativeLazyLoad: nativeLazyLoad,
125
- forceSyncDisplay: forceSyncDisplay,
126
- progress: progress
127
- })) : jsx(ImageCardView, _extends({}, baseProps, {
128
- status: status,
129
- cardPreview: cardPreview,
130
- alt: alt,
131
- resizeMode: resizeMode,
132
- onDisplayImage: onDisplayImage,
133
- onImageLoad: handleOnImageLoad,
134
- onImageError: handleOnImageError,
135
- nativeLazyLoad: nativeLazyLoad,
136
- forceSyncDisplay: forceSyncDisplay,
137
- progress: progress
138
- }))), jsx("div", {
139
- style: {
140
- display: didImageRender ? 'none' : 'inline'
141
- }
142
- }, jsx(IconCardView, _extends({
143
- status: status,
144
- progress: progress
145
- }, baseProps))));
146
- } else {
147
- return jsx(IconCardView, _extends({
148
- status: status,
149
- progress: progress
150
- }, baseProps));
151
- }
152
- case 'processing':
153
- if (cardPreview) {
154
- return jsx(React.Fragment, null, jsx("div", {
155
- style: {
156
- display: !didImageRender ? 'none' : 'inline'
157
- }
158
- }, mediaType === 'video' ? jsx(VideoCardView, _extends({}, baseProps, {
159
- status: status,
160
- cardPreview: cardPreview,
161
- alt: alt,
162
- resizeMode: resizeMode,
163
- onDisplayImage: onDisplayImage,
164
- onImageLoad: handleOnImageLoad,
165
- onImageError: handleOnImageError,
166
- nativeLazyLoad: nativeLazyLoad,
167
- forceSyncDisplay: forceSyncDisplay,
168
- progress: progress
169
- })) : jsx(ImageCardView, _extends({}, baseProps, {
170
- status: status,
171
- cardPreview: cardPreview,
172
- alt: alt,
173
- resizeMode: resizeMode,
174
- onDisplayImage: onDisplayImage,
175
- onImageLoad: handleOnImageLoad,
176
- onImageError: handleOnImageError,
177
- nativeLazyLoad: nativeLazyLoad,
178
- forceSyncDisplay: forceSyncDisplay,
179
- progress: progress
180
- }))), jsx("div", {
181
- style: {
182
- display: didImageRender ? 'none' : 'inline'
183
- }
184
- }, jsx(ProcessingCardView, _extends({
185
- disableAnimation: disableAnimation
186
- }, baseProps))));
187
- } else {
188
- return jsx(ProcessingCardView, _extends({
189
- disableAnimation: disableAnimation
190
- }, baseProps));
191
- }
192
- case 'complete':
193
- if (cardPreview) {
194
- return jsx(React.Fragment, null, jsx("div", {
195
- style: {
196
- display: !didImageRender ? 'none' : 'inline'
197
- }
198
- }, mediaType === 'video' ? jsx(VideoCardView, _extends({}, baseProps, {
199
- status: status,
200
- cardPreview: cardPreview,
201
- alt: alt,
202
- resizeMode: resizeMode,
203
- onDisplayImage: onDisplayImage,
204
- onImageLoad: handleOnImageLoad,
205
- onImageError: handleOnImageError,
206
- nativeLazyLoad: nativeLazyLoad,
207
- forceSyncDisplay: forceSyncDisplay
208
- })) : jsx(ImageCardView, _extends({}, baseProps, {
209
- status: status,
210
- cardPreview: cardPreview,
211
- alt: alt,
212
- resizeMode: resizeMode,
213
- onDisplayImage: onDisplayImage,
214
- onImageLoad: handleOnImageLoad,
215
- onImageError: handleOnImageError,
216
- nativeLazyLoad: nativeLazyLoad,
217
- forceSyncDisplay: forceSyncDisplay
218
- }))), jsx("div", {
219
- style: {
220
- display: didImageRender ? 'none' : 'inline'
221
- }
222
- }, jsx(IconCardView, _extends({
223
- status: status
224
- }, baseProps))));
225
- } else {
226
- return jsx(IconCardView, _extends({
227
- status: status
228
- }, baseProps));
229
- }
230
- case 'error':
231
- case 'failed-processing':
232
- return jsx(ErrorCardView, _extends({
233
- disableAnimation: disableAnimation,
234
- error: error
235
- }, baseProps));
236
- case 'loading-preview':
237
- case 'loading':
238
- default:
239
- if (cardPreview) {
240
- return jsx(React.Fragment, null, jsx("div", {
241
- style: {
242
- display: !didImageRender ? 'none' : 'inline'
243
- }
244
- }, jsx(ImageCardView, _extends({}, baseProps, {
245
- status: status,
246
- cardPreview: cardPreview,
247
- alt: alt,
248
- resizeMode: resizeMode,
249
- onDisplayImage: onDisplayImage,
250
- onImageLoad: handleOnImageLoad,
251
- onImageError: handleOnImageError,
252
- nativeLazyLoad: nativeLazyLoad,
253
- forceSyncDisplay: forceSyncDisplay,
254
- progress: progress
255
- }))), jsx("div", {
256
- style: {
257
- display: didImageRender ? 'none' : 'inline'
258
- }
259
- }, jsx(LoadingCardView, _extends({}, baseProps, {
260
- disableAnimation: disableAnimation
261
- }))));
262
- } else {
263
- return jsx(LoadingCardView, _extends({}, baseProps, {
264
- disableAnimation: disableAnimation
265
- }));
266
- }
267
- }
268
- };
269
- return getRenderConfigByStatus();
270
- };
271
- export const CardViews = withAnalyticsEvents({
272
- onClick: createAndFireMediaCardEvent({
273
- eventType: 'ui',
274
- action: 'clicked',
275
- actionSubject: 'mediaCard',
276
- attributes: {}
277
- })
278
- })(CardViewsBase);
@@ -1,53 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { jsx } from '@emotion/react';
8
- import { useEffect, useRef } from 'react';
9
- import SpinnerIcon from '@atlaskit/spinner';
10
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
11
- import { createAndFireMediaCardEvent } from '../../utils/analytics';
12
- import { IconWrapper } from '../ui/iconWrapper/iconWrapper';
13
- import { useBreakpoint } from '../useBreakpoint';
14
- import { CardViewWrapper } from './cardViewWrapper';
15
- const LoadingCardViewBase = props => {
16
- const {
17
- dimensions,
18
- metadata,
19
- disableOverlay,
20
- innerRef
21
- } = props;
22
- const divRef = useRef(null);
23
- const breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
24
- useEffect(() => {
25
- innerRef && !!divRef.current && innerRef(divRef.current);
26
- }, [innerRef]);
27
- const {
28
- name
29
- } = metadata || {};
30
- const hasTitleBox = !disableOverlay && !!name;
31
- return jsx(CardViewWrapper, _extends({}, props, {
32
- metadata: metadata,
33
- breakpoint: breakpoint,
34
- ref: divRef
35
- }), jsx(IconWrapper, {
36
- breakpoint: breakpoint,
37
- hasTitleBox: hasTitleBox
38
- }, jsx(SpinnerIcon, {
39
- testId: "media-card-loading",
40
- interactionName: "media-card-loading"
41
- })));
42
- };
43
-
44
- // TODO: check if analytics is correct
45
-
46
- export const LoadingCardView = withAnalyticsEvents({
47
- onClick: createAndFireMediaCardEvent({
48
- eventType: 'ui',
49
- action: 'clicked',
50
- actionSubject: 'mediaCard',
51
- attributes: {}
52
- })
53
- })(LoadingCardViewBase);