@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.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/v2/cardV2.js +1 -1
- package/dist/cjs/card/v2/cardviews/cardViewWrapper.js +100 -0
- package/dist/cjs/card/v2/cardviews/errorCardView.js +87 -0
- package/dist/cjs/card/v2/cardviews/iconCardView.js +79 -0
- package/dist/cjs/card/v2/cardviews/imageCardView.js +89 -0
- package/dist/cjs/card/v2/cardviews/index.js +282 -0
- package/dist/cjs/card/v2/cardviews/loadingCardView.js +53 -0
- package/dist/cjs/card/v2/cardviews/processingCardView.js +65 -0
- package/dist/cjs/card/v2/cardviews/videoCardView.js +94 -0
- package/dist/cjs/card/v2/fileCard.js +4 -1
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/v2/cardV2.js +1 -1
- package/dist/es2019/card/v2/cardviews/cardViewWrapper.js +92 -0
- package/dist/es2019/card/v2/cardviews/errorCardView.js +82 -0
- package/dist/es2019/card/v2/cardviews/iconCardView.js +70 -0
- package/dist/es2019/card/v2/cardviews/imageCardView.js +75 -0
- package/dist/es2019/card/v2/cardviews/index.js +268 -0
- package/dist/es2019/card/v2/cardviews/loadingCardView.js +48 -0
- package/dist/es2019/card/v2/cardviews/processingCardView.js +60 -0
- package/dist/es2019/card/v2/cardviews/videoCardView.js +80 -0
- package/dist/es2019/card/v2/fileCard.js +4 -1
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/v2/cardV2.js +1 -1
- package/dist/esm/card/v2/cardviews/cardViewWrapper.js +93 -0
- package/dist/esm/card/v2/cardviews/errorCardView.js +79 -0
- package/dist/esm/card/v2/cardviews/iconCardView.js +71 -0
- package/dist/esm/card/v2/cardviews/imageCardView.js +81 -0
- package/dist/esm/card/v2/cardviews/index.js +271 -0
- package/dist/esm/card/v2/cardviews/loadingCardView.js +45 -0
- package/dist/esm/card/v2/cardviews/processingCardView.js +57 -0
- package/dist/esm/card/v2/cardviews/videoCardView.js +86 -0
- package/dist/esm/card/v2/fileCard.js +4 -1
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/ui/wrapper/types.d.ts +2 -2
- package/dist/types/card/v2/cardviews/cardViewWrapper.d.ts +38 -0
- package/dist/types/card/v2/cardviews/errorCardView.d.ts +11 -0
- package/dist/types/card/v2/cardviews/iconCardView.d.ts +12 -0
- package/dist/types/card/v2/cardviews/imageCardView.d.ts +21 -0
- package/dist/types/card/v2/cardviews/index.d.ts +45 -0
- package/dist/types/card/v2/cardviews/loadingCardView.d.ts +10 -0
- package/dist/types/card/v2/cardviews/processingCardView.d.ts +8 -0
- package/dist/types/card/v2/cardviews/videoCardView.d.ts +21 -0
- package/dist/types-ts4.5/card/ui/wrapper/types.d.ts +2 -2
- package/dist/types-ts4.5/card/v2/cardviews/cardViewWrapper.d.ts +38 -0
- package/dist/types-ts4.5/card/v2/cardviews/errorCardView.d.ts +11 -0
- package/dist/types-ts4.5/card/v2/cardviews/iconCardView.d.ts +12 -0
- package/dist/types-ts4.5/card/v2/cardviews/imageCardView.d.ts +21 -0
- package/dist/types-ts4.5/card/v2/cardviews/index.d.ts +45 -0
- package/dist/types-ts4.5/card/v2/cardviews/loadingCardView.d.ts +10 -0
- package/dist/types-ts4.5/card/v2/cardviews/processingCardView.d.ts +8 -0
- package/dist/types-ts4.5/card/v2/cardviews/videoCardView.d.ts +21 -0
- package/package.json +4 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
2
3
|
import { globalMediaEventEmitter, isImageRepresentationReady, RECENTS_COLLECTION } from '@atlaskit/media-client';
|
|
3
4
|
import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
@@ -20,8 +21,10 @@ import { getDefaultCardDimensions } from '../../utils/cardDimensions';
|
|
|
20
21
|
import { fireCommencedEvent, fireCopiedEvent, fireNonCriticalErrorEvent, fireOperationalEvent, fireScreenEvent } from '../cardAnalytics';
|
|
21
22
|
import { isSSRPreview } from '../getCardPreview';
|
|
22
23
|
import { CardViewV2 } from './cardViewV2';
|
|
24
|
+
import { CardViews } from './cardviews';
|
|
23
25
|
import { InlinePlayerLazyV2 } from './inlinePlayerLazyV2';
|
|
24
26
|
import { useFilePreview } from './useFilePreview';
|
|
27
|
+
const LoadedCardView = getBooleanFF('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardViewV2;
|
|
25
28
|
export const FileCard = ({
|
|
26
29
|
appearance = 'auto',
|
|
27
30
|
resizeMode = 'crop',
|
|
@@ -468,7 +471,7 @@ export const FileCard = ({
|
|
|
468
471
|
// Force Media Image to always display img for SSR
|
|
469
472
|
const forceSyncDisplay = !!ssr;
|
|
470
473
|
const mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, finalStatus === 'error' || finalStatus === 'failed-processing', !!cardPreview, metadata.mediaType);
|
|
471
|
-
const card = /*#__PURE__*/React.createElement(
|
|
474
|
+
const card = /*#__PURE__*/React.createElement(LoadedCardView, {
|
|
472
475
|
status: cardStatusOverride || finalStatus,
|
|
473
476
|
error: finalError,
|
|
474
477
|
mediaItemType: mediaItemType,
|
|
@@ -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.
|
|
40
|
+
packageName: "77.6.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.
|
|
7
|
+
const packageVersion = "77.6.0";
|
|
8
8
|
let concurrentExperience;
|
|
9
9
|
const getExperience = id => {
|
|
10
10
|
if (!concurrentExperience) {
|
package/dist/esm/card/card.js
CHANGED
|
@@ -40,7 +40,7 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
|
|
|
40
40
|
import { completeUfoExperience, startUfoExperience, abortUfoExperience } from '../utils/ufoExperiences';
|
|
41
41
|
import { generateUniqueId } from '../utils/generateUniqueId';
|
|
42
42
|
var packageName = "@atlaskit/media-card";
|
|
43
|
-
var packageVersion = "77.
|
|
43
|
+
var packageVersion = "77.6.0";
|
|
44
44
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
45
45
|
_inherits(CardBase, _Component);
|
|
46
46
|
var _super = _createSuper(CardBase);
|
|
@@ -83,7 +83,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
|
|
|
83
83
|
}(React.Component);
|
|
84
84
|
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
85
85
|
var packageName = "@atlaskit/media-card";
|
|
86
|
-
var packageVersion = "77.
|
|
86
|
+
var packageVersion = "77.6.0";
|
|
87
87
|
var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
88
88
|
packageVersion: packageVersion,
|
|
89
89
|
packageName: packageName,
|
|
@@ -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.
|
|
12
|
+
var packageVersion = "77.6.0";
|
|
13
13
|
export var CardV2Base = function CardV2Base(_ref) {
|
|
14
14
|
var identifier = _ref.identifier,
|
|
15
15
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["cardPreview", "testId", "dimensions", "appearance", "metadata", "selected", "selectable", "actions", "breakpoint", "disableOverlay", "titleBoxBgColor", "titleBoxIcon", "shouldHideTooltip", "children", "onClick", "onMouseEnter", "mediaCardCursor", "customBlanket", "customTitleBox", "progressBar"];
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
8
|
+
import { Wrapper } from '../../ui/wrapper';
|
|
9
|
+
import { attachDetailsToActions } from '../../actions';
|
|
10
|
+
import { cardImageContainerStyles } from '../../ui/styles';
|
|
11
|
+
import { TitleBox } from '../../ui/titleBox/titleBox';
|
|
12
|
+
import { TickBox } from '../../ui/tickBox/tickBox';
|
|
13
|
+
import { Blanket } from '../../ui/blanket/blanket';
|
|
14
|
+
import { ActionsBar } from '../../ui/actionsBar/actionsBar';
|
|
15
|
+
import { fileCardImageViewSelector } from '../../classnames';
|
|
16
|
+
export var CardViewWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
17
|
+
var cardPreview = _ref.cardPreview,
|
|
18
|
+
testId = _ref.testId,
|
|
19
|
+
dimensions = _ref.dimensions,
|
|
20
|
+
_ref$appearance = _ref.appearance,
|
|
21
|
+
appearance = _ref$appearance === void 0 ? 'auto' : _ref$appearance,
|
|
22
|
+
metadata = _ref.metadata,
|
|
23
|
+
selected = _ref.selected,
|
|
24
|
+
selectable = _ref.selectable,
|
|
25
|
+
actions = _ref.actions,
|
|
26
|
+
breakpoint = _ref.breakpoint,
|
|
27
|
+
disableOverlay = _ref.disableOverlay,
|
|
28
|
+
titleBoxBgColor = _ref.titleBoxBgColor,
|
|
29
|
+
titleBoxIcon = _ref.titleBoxIcon,
|
|
30
|
+
shouldHideTooltip = _ref.shouldHideTooltip,
|
|
31
|
+
children = _ref.children,
|
|
32
|
+
onClick = _ref.onClick,
|
|
33
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
34
|
+
mediaCardCursor = _ref.mediaCardCursor,
|
|
35
|
+
customBlanket = _ref.customBlanket,
|
|
36
|
+
customTitleBox = _ref.customTitleBox,
|
|
37
|
+
progressBar = _ref.progressBar,
|
|
38
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var _ref2 = metadata || {},
|
|
40
|
+
name = _ref2.name,
|
|
41
|
+
createdAt = _ref2.createdAt,
|
|
42
|
+
mediaType = _ref2.mediaType;
|
|
43
|
+
var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
|
|
44
|
+
var defaultBlanket = !disableOverlay && jsx(Blanket, null);
|
|
45
|
+
var defaultTitleBox = !disableOverlay && !!name && jsx(TitleBox, {
|
|
46
|
+
name: name,
|
|
47
|
+
createdAt: createdAt,
|
|
48
|
+
breakpoint: breakpoint,
|
|
49
|
+
titleBoxIcon: titleBoxIcon,
|
|
50
|
+
titleBoxBgColor: titleBoxBgColor
|
|
51
|
+
});
|
|
52
|
+
var content = jsx(React.Fragment, null, jsx("div", _extends({
|
|
53
|
+
css: cardImageContainerStyles,
|
|
54
|
+
className: fileCardImageViewSelector,
|
|
55
|
+
"data-testid": fileCardImageViewSelector,
|
|
56
|
+
"data-test-media-name": name,
|
|
57
|
+
"data-test-selected": selected ? true : undefined
|
|
58
|
+
}, props), children, customBlanket ? customBlanket() : defaultBlanket, customTitleBox ? customTitleBox() : defaultTitleBox, !disableOverlay && !!selectable && jsx(TickBox, {
|
|
59
|
+
selected: selected
|
|
60
|
+
}), progressBar && progressBar()), !disableOverlay && actions && actions.length !== 0 && jsx(ActionsBar, {
|
|
61
|
+
actions: actionsWithDetails
|
|
62
|
+
}));
|
|
63
|
+
var shouldRenderPlayButton = function shouldRenderPlayButton() {
|
|
64
|
+
if (mediaType !== 'video' || !cardPreview) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
69
|
+
var isPlayButtonClickable = shouldRenderPlayButton() && disableOverlay;
|
|
70
|
+
var isTickBoxSelectable = !disableOverlay && !!selectable && !selected;
|
|
71
|
+
var shouldDisplayTooltip = !disableOverlay && !shouldHideTooltip;
|
|
72
|
+
var shouldDisplayBackground = !cardPreview || !disableOverlay;
|
|
73
|
+
return jsx(Wrapper, {
|
|
74
|
+
testId: testId || 'media-card-view',
|
|
75
|
+
dimensions: dimensions,
|
|
76
|
+
appearance: appearance,
|
|
77
|
+
onClick: onClick,
|
|
78
|
+
onMouseEnter: onMouseEnter,
|
|
79
|
+
innerRef: ref,
|
|
80
|
+
breakpoint: breakpoint,
|
|
81
|
+
mediaCardCursor: mediaCardCursor,
|
|
82
|
+
disableOverlay: !!disableOverlay,
|
|
83
|
+
selected: !!selected,
|
|
84
|
+
displayBackground: shouldDisplayBackground,
|
|
85
|
+
isPlayButtonClickable: !!isPlayButtonClickable,
|
|
86
|
+
isTickBoxSelectable: isTickBoxSelectable,
|
|
87
|
+
shouldDisplayTooltip: shouldDisplayTooltip
|
|
88
|
+
}, shouldDisplayTooltip ? jsx(Tooltip, {
|
|
89
|
+
content: name,
|
|
90
|
+
position: "bottom",
|
|
91
|
+
tag: "div"
|
|
92
|
+
}, content) : content);
|
|
93
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
var IconMessage = function IconMessage(_ref) {
|
|
16
|
+
var error = _ref.error,
|
|
17
|
+
metadata = _ref.metadata;
|
|
18
|
+
var _ref2 = error || {},
|
|
19
|
+
secondaryError = _ref2.secondaryError;
|
|
20
|
+
if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
|
|
21
|
+
return jsx(PreviewCurrentlyUnavailable, null);
|
|
22
|
+
} else if (isUploadError(error)) {
|
|
23
|
+
return jsx(FailedToUpload, null);
|
|
24
|
+
} else if (!metadata) {
|
|
25
|
+
return jsx(FailedToLoad, null);
|
|
26
|
+
} else {
|
|
27
|
+
return jsx(PreviewUnavailable, null);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var ErrorCardViewBase = function ErrorCardViewBase(props) {
|
|
31
|
+
var error = props.error,
|
|
32
|
+
metadata = props.metadata,
|
|
33
|
+
dimensions = props.dimensions,
|
|
34
|
+
disableOverlay = props.disableOverlay;
|
|
35
|
+
var _ref3 = metadata || {},
|
|
36
|
+
name = _ref3.name,
|
|
37
|
+
mediaType = _ref3.mediaType,
|
|
38
|
+
mimeType = _ref3.mimeType;
|
|
39
|
+
var divRef = useRef(null);
|
|
40
|
+
var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
|
|
41
|
+
var customMessage = isUploadError(props.error) ? messages.failed_to_upload : undefined;
|
|
42
|
+
var renderFailedTitleBox = !disableOverlay && (!name || !!customMessage);
|
|
43
|
+
var renderTitleBox = !disableOverlay && !!name && !customMessage;
|
|
44
|
+
var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
|
|
45
|
+
return jsx(CardViewWrapper, _extends({}, props, {
|
|
46
|
+
metadata: metadata,
|
|
47
|
+
breakpoint: breakpoint,
|
|
48
|
+
"data-test-status": "error",
|
|
49
|
+
ref: divRef,
|
|
50
|
+
customTitleBox: renderFailedTitleBox ? function () {
|
|
51
|
+
return jsx(FailedTitleBox, {
|
|
52
|
+
breakpoint: breakpoint,
|
|
53
|
+
customMessage: customMessage
|
|
54
|
+
});
|
|
55
|
+
} : undefined
|
|
56
|
+
}), jsx(IconWrapper, {
|
|
57
|
+
breakpoint: breakpoint,
|
|
58
|
+
hasTitleBox: hasTitleBox
|
|
59
|
+
}, jsx(MimeTypeIcon, {
|
|
60
|
+
testId: "media-card-file-type-icon",
|
|
61
|
+
mediaType: mediaType,
|
|
62
|
+
mimeType: mimeType,
|
|
63
|
+
name: name
|
|
64
|
+
}), !renderFailedTitleBox && jsx(IconMessage, {
|
|
65
|
+
error: error,
|
|
66
|
+
metadata: metadata
|
|
67
|
+
})));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// TODO: check if analytics is correct
|
|
71
|
+
|
|
72
|
+
export var ErrorCardView = withAnalyticsEvents({
|
|
73
|
+
onClick: createAndFireMediaCardEvent({
|
|
74
|
+
eventType: 'ui',
|
|
75
|
+
action: 'clicked',
|
|
76
|
+
actionSubject: 'mediaCard',
|
|
77
|
+
attributes: {}
|
|
78
|
+
})
|
|
79
|
+
})(ErrorCardViewBase);
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
var IconCardViewBase = function IconCardViewBase(props) {
|
|
16
|
+
var dimensions = props.dimensions,
|
|
17
|
+
metadata = props.metadata,
|
|
18
|
+
disableOverlay = props.disableOverlay,
|
|
19
|
+
innerRef = props.innerRef,
|
|
20
|
+
progress = props.progress,
|
|
21
|
+
status = props.status;
|
|
22
|
+
var divRef = useRef(null);
|
|
23
|
+
var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
innerRef && !!divRef.current && innerRef(divRef.current);
|
|
26
|
+
}, [innerRef]);
|
|
27
|
+
var _ref = metadata || {},
|
|
28
|
+
name = _ref.name,
|
|
29
|
+
mediaType = _ref.mediaType,
|
|
30
|
+
mimeType = _ref.mimeType;
|
|
31
|
+
var hasTitleBox = !disableOverlay && !!name;
|
|
32
|
+
var isUploading = status === 'uploading';
|
|
33
|
+
return jsx(CardViewWrapper, _extends({}, props, {
|
|
34
|
+
metadata: metadata,
|
|
35
|
+
breakpoint: breakpoint,
|
|
36
|
+
"data-test-status": status,
|
|
37
|
+
"data-test-progress": progress,
|
|
38
|
+
ref: divRef,
|
|
39
|
+
customBlanket: function customBlanket() {
|
|
40
|
+
return jsx(Blanket, {
|
|
41
|
+
isFixed: isUploading
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
progressBar: isUploading ? function () {
|
|
45
|
+
return jsx(ProgressBar, {
|
|
46
|
+
progress: progress,
|
|
47
|
+
breakpoint: breakpoint,
|
|
48
|
+
positionBottom: !hasTitleBox
|
|
49
|
+
});
|
|
50
|
+
} : undefined
|
|
51
|
+
}), jsx(IconWrapper, {
|
|
52
|
+
breakpoint: breakpoint,
|
|
53
|
+
hasTitleBox: hasTitleBox
|
|
54
|
+
}, jsx(MimeTypeIcon, {
|
|
55
|
+
testId: "media-card-file-type-icon",
|
|
56
|
+
mediaType: mediaType,
|
|
57
|
+
mimeType: mimeType,
|
|
58
|
+
name: name
|
|
59
|
+
})));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// TODO: check if analytics is correct
|
|
63
|
+
|
|
64
|
+
export var IconCardView = withAnalyticsEvents({
|
|
65
|
+
onClick: createAndFireMediaCardEvent({
|
|
66
|
+
eventType: 'ui',
|
|
67
|
+
action: 'clicked',
|
|
68
|
+
actionSubject: 'mediaCard',
|
|
69
|
+
attributes: {}
|
|
70
|
+
})
|
|
71
|
+
})(IconCardViewBase);
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
var ImageCardViewBase = function ImageCardViewBase(props) {
|
|
13
|
+
var status = props.status,
|
|
14
|
+
dimensions = props.dimensions,
|
|
15
|
+
metadata = props.metadata,
|
|
16
|
+
disableOverlay = props.disableOverlay,
|
|
17
|
+
innerRef = props.innerRef,
|
|
18
|
+
progress = props.progress,
|
|
19
|
+
cardPreview = props.cardPreview,
|
|
20
|
+
alt = props.alt,
|
|
21
|
+
resizeMode = props.resizeMode,
|
|
22
|
+
onDisplayImage = props.onDisplayImage,
|
|
23
|
+
nativeLazyLoad = props.nativeLazyLoad,
|
|
24
|
+
forceSyncDisplay = props.forceSyncDisplay,
|
|
25
|
+
_onImageLoad = props.onImageLoad,
|
|
26
|
+
_onImageError = props.onImageError;
|
|
27
|
+
var divRef = useRef(null);
|
|
28
|
+
var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
innerRef && !!divRef.current && innerRef(divRef.current);
|
|
31
|
+
}, [innerRef]);
|
|
32
|
+
var _ref = metadata || {},
|
|
33
|
+
name = _ref.name,
|
|
34
|
+
_ref$mediaType = _ref.mediaType,
|
|
35
|
+
mediaType = _ref$mediaType === void 0 ? 'unknown' : _ref$mediaType;
|
|
36
|
+
var hasTitleBox = !disableOverlay && !!name;
|
|
37
|
+
var isUploading = status === 'uploading';
|
|
38
|
+
return jsx(CardViewWrapper, _extends({}, props, {
|
|
39
|
+
breakpoint: breakpoint,
|
|
40
|
+
"data-test-status": status,
|
|
41
|
+
"data-test-progress": progress,
|
|
42
|
+
ref: divRef,
|
|
43
|
+
customBlanket: function customBlanket() {
|
|
44
|
+
return jsx(Blanket, {
|
|
45
|
+
isFixed: isUploading
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
progressBar: isUploading ? function () {
|
|
49
|
+
return jsx(ProgressBar, {
|
|
50
|
+
progress: progress,
|
|
51
|
+
breakpoint: breakpoint,
|
|
52
|
+
positionBottom: !hasTitleBox
|
|
53
|
+
});
|
|
54
|
+
} : undefined
|
|
55
|
+
}), jsx(ImageRenderer, {
|
|
56
|
+
cardPreview: cardPreview,
|
|
57
|
+
mediaType: mediaType,
|
|
58
|
+
alt: alt,
|
|
59
|
+
resizeMode: resizeMode,
|
|
60
|
+
onDisplayImage: onDisplayImage,
|
|
61
|
+
onImageLoad: function onImageLoad() {
|
|
62
|
+
return _onImageLoad === null || _onImageLoad === void 0 ? void 0 : _onImageLoad(cardPreview);
|
|
63
|
+
},
|
|
64
|
+
onImageError: function onImageError() {
|
|
65
|
+
return _onImageError === null || _onImageError === void 0 ? void 0 : _onImageError(cardPreview);
|
|
66
|
+
},
|
|
67
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
68
|
+
forceSyncDisplay: forceSyncDisplay
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// TODO: check if analytics is correct
|
|
73
|
+
|
|
74
|
+
export var ImageCardView = withAnalyticsEvents({
|
|
75
|
+
onClick: createAndFireMediaCardEvent({
|
|
76
|
+
eventType: 'ui',
|
|
77
|
+
action: 'clicked',
|
|
78
|
+
actionSubject: 'mediaCard',
|
|
79
|
+
attributes: {}
|
|
80
|
+
})
|
|
81
|
+
})(ImageCardViewBase);
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
6
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
7
|
+
import { createAndFireMediaCardEvent } from '../../../utils/analytics';
|
|
8
|
+
import { useBreakpoint } from '../../useBreakpoint';
|
|
9
|
+
import { ProcessingCardView } from './processingCardView';
|
|
10
|
+
import { ErrorCardView } from './errorCardView';
|
|
11
|
+
import { VideoCardView } from './videoCardView';
|
|
12
|
+
import { ImageCardView } from './imageCardView';
|
|
13
|
+
import { IconCardView } from './iconCardView';
|
|
14
|
+
import { LoadingCardView } from './loadingCardView';
|
|
15
|
+
export var CardViewsBase = function CardViewsBase(_ref) {
|
|
16
|
+
var innerRef = _ref.innerRef,
|
|
17
|
+
onImageLoad = _ref.onImageLoad,
|
|
18
|
+
onImageError = _ref.onImageError,
|
|
19
|
+
dimensions = _ref.dimensions,
|
|
20
|
+
_ref$appearance = _ref.appearance,
|
|
21
|
+
appearance = _ref$appearance === void 0 ? 'auto' : _ref$appearance,
|
|
22
|
+
onClick = _ref.onClick,
|
|
23
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
24
|
+
testId = _ref.testId,
|
|
25
|
+
metadata = _ref.metadata,
|
|
26
|
+
status = _ref.status,
|
|
27
|
+
selected = _ref.selected,
|
|
28
|
+
selectable = _ref.selectable,
|
|
29
|
+
cardPreview = _ref.cardPreview,
|
|
30
|
+
mediaCardCursor = _ref.mediaCardCursor,
|
|
31
|
+
shouldHideTooltip = _ref.shouldHideTooltip,
|
|
32
|
+
progress = _ref.progress,
|
|
33
|
+
alt = _ref.alt,
|
|
34
|
+
resizeMode = _ref.resizeMode,
|
|
35
|
+
onDisplayImage = _ref.onDisplayImage,
|
|
36
|
+
nativeLazyLoad = _ref.nativeLazyLoad,
|
|
37
|
+
forceSyncDisplay = _ref.forceSyncDisplay,
|
|
38
|
+
actions = _ref.actions,
|
|
39
|
+
disableOverlay = _ref.disableOverlay,
|
|
40
|
+
titleBoxBgColor = _ref.titleBoxBgColor,
|
|
41
|
+
titleBoxIcon = _ref.titleBoxIcon,
|
|
42
|
+
error = _ref.error,
|
|
43
|
+
disableAnimation = _ref.disableAnimation;
|
|
44
|
+
var _useState = useState(false),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
didImageRender = _useState2[0],
|
|
47
|
+
setDidImageRender = _useState2[1];
|
|
48
|
+
var divRef = useRef(null);
|
|
49
|
+
var prevCardPreviewRef = useRef();
|
|
50
|
+
var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
innerRef && !!divRef.current && innerRef(divRef.current);
|
|
53
|
+
}, [innerRef]);
|
|
54
|
+
|
|
55
|
+
/* didImageRender movements */
|
|
56
|
+
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
// 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
|
|
59
|
+
if (prevCardPreviewRef.current && !cardPreview) {
|
|
60
|
+
setDidImageRender(false);
|
|
61
|
+
}
|
|
62
|
+
prevCardPreviewRef.current = cardPreview;
|
|
63
|
+
}, [cardPreview]);
|
|
64
|
+
var handleOnImageLoad = function handleOnImageLoad(prevCardPreview) {
|
|
65
|
+
if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setDidImageRender(true);
|
|
69
|
+
onImageLoad === null || onImageLoad === void 0 || onImageLoad(cardPreview);
|
|
70
|
+
};
|
|
71
|
+
var handleOnImageError = function handleOnImageError(prevCardPreview) {
|
|
72
|
+
if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setDidImageRender(false);
|
|
76
|
+
onImageError === null || onImageError === void 0 || onImageError(cardPreview);
|
|
77
|
+
};
|
|
78
|
+
var getRenderConfigByStatus = function getRenderConfigByStatus() {
|
|
79
|
+
var _ref2 = metadata || {},
|
|
80
|
+
mediaType = _ref2.mediaType;
|
|
81
|
+
|
|
82
|
+
// TODO: figure out if data-test-progress for all the card views
|
|
83
|
+
|
|
84
|
+
var baseProps = {
|
|
85
|
+
testId: testId,
|
|
86
|
+
dimensions: dimensions,
|
|
87
|
+
appearance: appearance,
|
|
88
|
+
metadata: metadata,
|
|
89
|
+
selected: selected,
|
|
90
|
+
selectable: selectable,
|
|
91
|
+
actions: actions,
|
|
92
|
+
breakpoint: breakpoint,
|
|
93
|
+
disableOverlay: disableOverlay,
|
|
94
|
+
titleBoxBgColor: titleBoxBgColor,
|
|
95
|
+
titleBoxIcon: titleBoxIcon,
|
|
96
|
+
shouldHideTooltip: shouldHideTooltip,
|
|
97
|
+
onClick: onClick,
|
|
98
|
+
onMouseEnter: onMouseEnter,
|
|
99
|
+
mediaCardCursor: mediaCardCursor,
|
|
100
|
+
innerRef: innerRef
|
|
101
|
+
};
|
|
102
|
+
switch (status) {
|
|
103
|
+
case 'uploading':
|
|
104
|
+
if (cardPreview) {
|
|
105
|
+
return jsx(React.Fragment, null, jsx("div", {
|
|
106
|
+
style: {
|
|
107
|
+
display: !didImageRender ? 'none' : 'inline'
|
|
108
|
+
}
|
|
109
|
+
}, mediaType === 'video' ? jsx(VideoCardView, _extends({}, baseProps, {
|
|
110
|
+
status: status,
|
|
111
|
+
cardPreview: cardPreview,
|
|
112
|
+
alt: alt,
|
|
113
|
+
resizeMode: resizeMode,
|
|
114
|
+
onDisplayImage: onDisplayImage,
|
|
115
|
+
onImageLoad: handleOnImageLoad,
|
|
116
|
+
onImageError: handleOnImageError,
|
|
117
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
118
|
+
forceSyncDisplay: forceSyncDisplay,
|
|
119
|
+
progress: progress
|
|
120
|
+
})) : jsx(ImageCardView, _extends({}, baseProps, {
|
|
121
|
+
status: status,
|
|
122
|
+
cardPreview: cardPreview,
|
|
123
|
+
alt: alt,
|
|
124
|
+
resizeMode: resizeMode,
|
|
125
|
+
onDisplayImage: onDisplayImage,
|
|
126
|
+
onImageLoad: handleOnImageLoad,
|
|
127
|
+
onImageError: handleOnImageError,
|
|
128
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
129
|
+
forceSyncDisplay: forceSyncDisplay,
|
|
130
|
+
progress: progress
|
|
131
|
+
}))), jsx("div", {
|
|
132
|
+
style: {
|
|
133
|
+
display: didImageRender ? 'none' : 'inline'
|
|
134
|
+
}
|
|
135
|
+
}, jsx(IconCardView, _extends({
|
|
136
|
+
status: status,
|
|
137
|
+
progress: progress
|
|
138
|
+
}, baseProps))));
|
|
139
|
+
} else {
|
|
140
|
+
return jsx(IconCardView, _extends({
|
|
141
|
+
status: status,
|
|
142
|
+
progress: progress
|
|
143
|
+
}, baseProps));
|
|
144
|
+
}
|
|
145
|
+
case 'processing':
|
|
146
|
+
if (cardPreview) {
|
|
147
|
+
return jsx(React.Fragment, null, jsx("div", {
|
|
148
|
+
style: {
|
|
149
|
+
display: !didImageRender ? 'none' : 'inline'
|
|
150
|
+
}
|
|
151
|
+
}, mediaType === 'video' ? jsx(VideoCardView, _extends({}, baseProps, {
|
|
152
|
+
status: status,
|
|
153
|
+
cardPreview: cardPreview,
|
|
154
|
+
alt: alt,
|
|
155
|
+
resizeMode: resizeMode,
|
|
156
|
+
onDisplayImage: onDisplayImage,
|
|
157
|
+
onImageLoad: handleOnImageLoad,
|
|
158
|
+
onImageError: handleOnImageError,
|
|
159
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
160
|
+
forceSyncDisplay: forceSyncDisplay,
|
|
161
|
+
progress: progress
|
|
162
|
+
})) : jsx(ImageCardView, _extends({}, baseProps, {
|
|
163
|
+
status: status,
|
|
164
|
+
cardPreview: cardPreview,
|
|
165
|
+
alt: alt,
|
|
166
|
+
resizeMode: resizeMode,
|
|
167
|
+
onDisplayImage: onDisplayImage,
|
|
168
|
+
onImageLoad: handleOnImageLoad,
|
|
169
|
+
onImageError: handleOnImageError,
|
|
170
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
171
|
+
forceSyncDisplay: forceSyncDisplay,
|
|
172
|
+
progress: progress
|
|
173
|
+
}))), jsx("div", {
|
|
174
|
+
style: {
|
|
175
|
+
display: didImageRender ? 'none' : 'inline'
|
|
176
|
+
}
|
|
177
|
+
}, jsx(ProcessingCardView, _extends({
|
|
178
|
+
disableAnimation: disableAnimation
|
|
179
|
+
}, baseProps))));
|
|
180
|
+
} else {
|
|
181
|
+
return jsx(ProcessingCardView, _extends({
|
|
182
|
+
disableAnimation: disableAnimation
|
|
183
|
+
}, baseProps));
|
|
184
|
+
}
|
|
185
|
+
case 'complete':
|
|
186
|
+
if (cardPreview) {
|
|
187
|
+
return jsx(React.Fragment, null, jsx("div", {
|
|
188
|
+
style: {
|
|
189
|
+
display: !didImageRender ? 'none' : 'inline'
|
|
190
|
+
}
|
|
191
|
+
}, mediaType === 'video' ? jsx(VideoCardView, _extends({}, baseProps, {
|
|
192
|
+
status: status,
|
|
193
|
+
cardPreview: cardPreview,
|
|
194
|
+
alt: alt,
|
|
195
|
+
resizeMode: resizeMode,
|
|
196
|
+
onDisplayImage: onDisplayImage,
|
|
197
|
+
onImageLoad: handleOnImageLoad,
|
|
198
|
+
onImageError: handleOnImageError,
|
|
199
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
200
|
+
forceSyncDisplay: forceSyncDisplay
|
|
201
|
+
})) : jsx(ImageCardView, _extends({}, baseProps, {
|
|
202
|
+
status: status,
|
|
203
|
+
cardPreview: cardPreview,
|
|
204
|
+
alt: alt,
|
|
205
|
+
resizeMode: resizeMode,
|
|
206
|
+
onDisplayImage: onDisplayImage,
|
|
207
|
+
onImageLoad: handleOnImageLoad,
|
|
208
|
+
onImageError: handleOnImageError,
|
|
209
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
210
|
+
forceSyncDisplay: forceSyncDisplay
|
|
211
|
+
}))), jsx("div", {
|
|
212
|
+
style: {
|
|
213
|
+
display: didImageRender ? 'none' : 'inline'
|
|
214
|
+
}
|
|
215
|
+
}, jsx(IconCardView, _extends({
|
|
216
|
+
status: status
|
|
217
|
+
}, baseProps))));
|
|
218
|
+
} else {
|
|
219
|
+
return jsx(IconCardView, _extends({
|
|
220
|
+
status: status
|
|
221
|
+
}, baseProps));
|
|
222
|
+
}
|
|
223
|
+
case 'error':
|
|
224
|
+
case 'failed-processing':
|
|
225
|
+
return jsx(ErrorCardView, _extends({
|
|
226
|
+
disableAnimation: disableAnimation,
|
|
227
|
+
error: error
|
|
228
|
+
}, baseProps));
|
|
229
|
+
case 'loading-preview':
|
|
230
|
+
case 'loading':
|
|
231
|
+
default:
|
|
232
|
+
if (cardPreview) {
|
|
233
|
+
return jsx(React.Fragment, null, jsx("div", {
|
|
234
|
+
style: {
|
|
235
|
+
display: !didImageRender ? 'none' : 'inline'
|
|
236
|
+
}
|
|
237
|
+
}, jsx(ImageCardView, _extends({}, baseProps, {
|
|
238
|
+
status: status,
|
|
239
|
+
cardPreview: cardPreview,
|
|
240
|
+
alt: alt,
|
|
241
|
+
resizeMode: resizeMode,
|
|
242
|
+
onDisplayImage: onDisplayImage,
|
|
243
|
+
onImageLoad: handleOnImageLoad,
|
|
244
|
+
onImageError: handleOnImageError,
|
|
245
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
246
|
+
forceSyncDisplay: forceSyncDisplay,
|
|
247
|
+
progress: progress
|
|
248
|
+
}))), jsx("div", {
|
|
249
|
+
style: {
|
|
250
|
+
display: didImageRender ? 'none' : 'inline'
|
|
251
|
+
}
|
|
252
|
+
}, jsx(LoadingCardView, _extends({}, baseProps, {
|
|
253
|
+
disableAnimation: disableAnimation
|
|
254
|
+
}))));
|
|
255
|
+
} else {
|
|
256
|
+
return jsx(LoadingCardView, _extends({}, baseProps, {
|
|
257
|
+
disableAnimation: disableAnimation
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return getRenderConfigByStatus();
|
|
263
|
+
};
|
|
264
|
+
export var CardViews = withAnalyticsEvents({
|
|
265
|
+
onClick: createAndFireMediaCardEvent({
|
|
266
|
+
eventType: 'ui',
|
|
267
|
+
action: 'clicked',
|
|
268
|
+
actionSubject: 'mediaCard',
|
|
269
|
+
attributes: {}
|
|
270
|
+
})
|
|
271
|
+
})(CardViewsBase);
|