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