@atlaskit/media-card 77.11.3 → 77.12.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.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/card/card.js +5 -5
- package/dist/cjs/card/cardView.js +6 -10
- package/dist/cjs/card/inlinePlayerWrapperStyles.js +1 -1
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/ui/styles.js +1 -12
- package/dist/cjs/card/ui/wrapper/imageContainer.js +52 -0
- package/dist/cjs/card/ui/wrapper/index.js +8 -1
- package/dist/cjs/card/ui/wrapper/styles.js +1 -1
- package/dist/cjs/card/v2/cardV2.js +1 -1
- package/dist/cjs/card/v2/cardViewV2.js +12 -17
- package/dist/cjs/card/v2/cardviews/cardViewWrapper.js +5 -9
- package/dist/cjs/card/v2/fileCard.js +66 -20
- package/dist/cjs/card/v2/svgView/helpers.js +16 -0
- package/dist/cjs/card/v2/svgView/index.js +12 -0
- package/dist/cjs/card/v2/svgView/svgView.js +134 -0
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/es2019/card/card.js +5 -5
- package/dist/es2019/card/cardView.js +8 -12
- package/dist/es2019/card/inlinePlayerWrapperStyles.js +12 -12
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/ui/styles.js +0 -11
- package/dist/es2019/card/ui/wrapper/imageContainer.js +44 -0
- package/dist/es2019/card/ui/wrapper/index.js +2 -1
- package/dist/es2019/card/ui/wrapper/styles.js +21 -21
- package/dist/es2019/card/v2/cardV2.js +1 -1
- package/dist/es2019/card/v2/cardViewV2.js +13 -18
- package/dist/es2019/card/v2/cardviews/cardViewWrapper.js +6 -10
- package/dist/es2019/card/v2/fileCard.js +51 -8
- package/dist/es2019/card/v2/svgView/helpers.js +12 -0
- package/dist/es2019/card/v2/svgView/index.js +1 -0
- package/dist/es2019/card/v2/svgView/svgView.js +113 -0
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/esm/card/card.js +5 -5
- package/dist/esm/card/cardView.js +8 -12
- package/dist/esm/card/inlinePlayerWrapperStyles.js +1 -1
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/ui/styles.js +0 -11
- package/dist/esm/card/ui/wrapper/imageContainer.js +45 -0
- package/dist/esm/card/ui/wrapper/index.js +2 -1
- package/dist/esm/card/ui/wrapper/styles.js +1 -1
- package/dist/esm/card/v2/cardV2.js +1 -1
- package/dist/esm/card/v2/cardViewV2.js +13 -18
- package/dist/esm/card/v2/cardviews/cardViewWrapper.js +6 -10
- package/dist/esm/card/v2/fileCard.js +66 -20
- package/dist/esm/card/v2/svgView/helpers.js +10 -0
- package/dist/esm/card/v2/svgView/index.js +1 -0
- package/dist/esm/card/v2/svgView/svgView.js +123 -0
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +11 -11
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/types/card/ui/iconWrapper/styles.d.ts +1 -1
- package/dist/types/card/ui/styles.d.ts +0 -1
- package/dist/types/card/ui/titleBox/styles.d.ts +1 -1
- package/dist/types/card/ui/wrapper/imageContainer.d.ts +15 -0
- package/dist/types/card/ui/wrapper/index.d.ts +1 -0
- package/dist/types/card/v2/svgView/helpers.d.ts +3 -0
- package/dist/types/card/v2/svgView/index.d.ts +1 -0
- package/dist/types/card/v2/svgView/svgView.d.ts +31 -0
- package/dist/types/utils/preventClickThrough.d.ts +1 -1
- package/dist/types/utils/viewportDetector.d.ts +1 -1
- package/dist/types-ts4.5/card/ui/iconWrapper/styles.d.ts +1 -1
- package/dist/types-ts4.5/card/ui/styles.d.ts +0 -1
- package/dist/types-ts4.5/card/ui/titleBox/styles.d.ts +1 -1
- package/dist/types-ts4.5/card/ui/wrapper/imageContainer.d.ts +15 -0
- package/dist/types-ts4.5/card/ui/wrapper/index.d.ts +1 -0
- package/dist/types-ts4.5/card/v2/svgView/helpers.d.ts +3 -0
- package/dist/types-ts4.5/card/v2/svgView/index.d.ts +1 -0
- package/dist/types-ts4.5/card/v2/svgView/svgView.d.ts +31 -0
- package/dist/types-ts4.5/utils/preventClickThrough.d.ts +1 -1
- package/dist/types-ts4.5/utils/viewportDetector.d.ts +1 -1
- package/example-helpers/DelayedRender.tsx +19 -19
- package/example-helpers/cardViewWrapper.tsx +18 -22
- package/example-helpers/cards.tsx +268 -331
- package/example-helpers/developmentUseMessage.tsx +8 -9
- package/example-helpers/index.tsx +100 -124
- package/example-helpers/selectableCard.tsx +32 -35
- package/example-helpers/ssrHelpers.tsx +19 -29
- package/example-helpers/styles.ts +73 -73
- package/example-helpers/svg-helpers/cardContainer.tsx +24 -0
- package/example-helpers/svg-helpers/controls.tsx +21 -0
- package/example-helpers/svg-helpers/delayApiResponses.ts +31 -0
- package/example-helpers/svg-helpers/dimensionPicker.tsx +116 -0
- package/example-helpers/svg-helpers/index.ts +7 -0
- package/example-helpers/svg-helpers/svgContainer.tsx +32 -0
- package/example-helpers/svg-helpers/toggle.tsx +42 -0
- package/example-helpers/svg-helpers/uploader.ts +44 -0
- package/package.json +13 -5
- package/report.api.md +227 -232
|
@@ -17,17 +17,17 @@ const ErrorBoundaryComponent = ({
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/* Note:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
- styling is borrowed from packages/media/media-ui/src/MediaInlineCard/Frame/styled.ts
|
|
21
|
+
- because we are not using styled components, we are not able to use themed(), here is the "themed" property of color and backgroundColor
|
|
22
|
+
color: `${themed({
|
|
23
|
+
light: token('color.text', N900),
|
|
24
|
+
dark: token('color.text', DN600),
|
|
25
|
+
})}`,
|
|
26
|
+
backgroundColor: `${themed({
|
|
27
|
+
light: token('color.background.neutral', N30A),
|
|
28
|
+
dark: token('color.background.neutral', DN80),
|
|
29
|
+
})}`,
|
|
30
|
+
*/
|
|
31
31
|
|
|
32
32
|
const style = {
|
|
33
33
|
lineHeight: '16px',
|
|
@@ -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.12.1";
|
|
8
8
|
let concurrentExperience;
|
|
9
9
|
const getExperience = id => {
|
|
10
10
|
if (!concurrentExperience) {
|
package/dist/esm/card/card.js
CHANGED
|
@@ -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.
|
|
44
|
+
var packageVersion = "77.12.1";
|
|
45
45
|
export var CardBase = /*#__PURE__*/function (_Component) {
|
|
46
46
|
_inherits(CardBase, _Component);
|
|
47
47
|
var _super = _createSuper(CardBase);
|
|
@@ -281,8 +281,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
/*
|
|
284
|
-
|
|
285
|
-
|
|
284
|
+
If the cardPreview failed and it comes from server (global scope / ssrData), it means that we have reused it in client and the error counts for both: server & client.
|
|
285
|
+
*/
|
|
286
286
|
|
|
287
287
|
if (isSSRDataPreview(cardPreview)) {
|
|
288
288
|
_this.ssrReliability.server = failedSSRObject;
|
|
@@ -330,8 +330,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
/*
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
If the image loads successfully and it comes from server (global scope / ssrData), it means that we have reused it in client and the success counts for both: server & client.
|
|
334
|
+
*/
|
|
335
335
|
|
|
336
336
|
if (isSSRDataPreview(cardPreview) && _this.ssrReliability.server.status === 'unknown') {
|
|
337
337
|
_this.ssrReliability.server = {
|
|
@@ -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 {
|
|
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(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
,
|
|
207
|
-
|
|
208
|
-
|
|
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;
|
|
@@ -17,6 +17,6 @@ export var inlinePlayerClassName = 'media-card-inline-player';
|
|
|
17
17
|
export var inlinePlayerWrapperStyles = function inlinePlayerWrapperStyles(_ref2) {
|
|
18
18
|
var dimensions = _ref2.dimensions,
|
|
19
19
|
selected = _ref2.selected;
|
|
20
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
20
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\twidth: ", ";\n\theight: ", ";\n\toverflow: hidden;\n\tborder-radius: ", "px;\n\tposition: relative;\n\tmax-width: 100%;\n\tmax-height: 100%;\n\n\t", "\n\n\tvideo {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t}\n"])), getDimensionsWithDefault(dimensions).width || '100%', getDimensionsWithDefault(dimensions).height || 'auto', borderRadius(), getSelectedBorderStyle(selected));
|
|
21
21
|
};
|
|
22
22
|
inlinePlayerWrapperStyles.displayName = 'InlinePlayerWrapper';
|
|
@@ -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.12.1";
|
|
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';
|
|
@@ -20,6 +20,6 @@ export var wrapperStyles = function wrapperStyles(_ref) {
|
|
|
20
20
|
isTickBoxSelectable = _ref.isTickBoxSelectable,
|
|
21
21
|
shouldDisplayTooltip = _ref.shouldDisplayTooltip,
|
|
22
22
|
mediaCardCursor = _ref.mediaCardCursor;
|
|
23
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
23
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t", "\n\tbox-sizing: border-box;\n\t* {\n\t\tbox-sizing: border-box;\n\t}\n\tposition: relative;\n\tfont-family: ", ";\n\t", "\n\t", "\n ", "\n ", "\n ", "\n ", ";\n\t", "\n\n\t/* We use classnames from here exceptionally to be able to handle styles when the Card is on hover */\n ", "\n ", "\n &:hover .", " {\n\t\t", "\n\t}\n\t&:hover .", ", &:focus-within .", " {\n\t\t", "\n\t}\n\n\t/* Tooltip does not support percentage dimensions. We enforce them here */\n\t", "\n\n\tbutton:focus + & {\n\t\toutline: solid 2px ", ";\n\t}\n"])), transition(), fontFamily(), getWrapperDimensions(dimensions, appearance), displayBackground && "background: ".concat("var(--ds-background-neutral, ".concat(N20, ")"), ";"), borderRadius, getCursorStyle(mediaCardCursor), getWrapperShadow(disableOverlay, selected), generateResponsiveStyles(breakpoint), hideNativeBrowserTextSelectionStyles, getClickablePlayButtonStyles(isPlayButtonClickable), getSelectableTickBoxStyles(isTickBoxSelectable), blanketClassName, fixedBlanketStyles, actionsBarClassName, actionsBarClassName, fixedActionBarStyles, shouldDisplayTooltip && "> div { width: 100%; height: 100%; }", "var(--ds-border-focused, ".concat(B100, ")"));
|
|
24
24
|
};
|
|
25
25
|
wrapperStyles.displayName = 'NewFileExperienceWrapper';
|
|
@@ -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.12.1";
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
|
@@ -5,9 +5,8 @@ var _excluded = ["cardPreview", "testId", "dimensions", "appearance", "metadata"
|
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import Tooltip from '@atlaskit/tooltip';
|
|
8
|
-
import { Wrapper } from '../../ui/wrapper';
|
|
8
|
+
import { ImageContainer, Wrapper } from '../../ui/wrapper';
|
|
9
9
|
import { attachDetailsToActions } from '../../actions';
|
|
10
|
-
import { cardImageContainerStyles } from '../../ui/styles';
|
|
11
10
|
import { TitleBox } from '../../ui/titleBox/titleBox';
|
|
12
11
|
import { TickBox } from '../../ui/tickBox/tickBox';
|
|
13
12
|
import { Blanket } from '../../ui/blanket/blanket';
|
|
@@ -54,14 +53,11 @@ export var CardViewWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
|
54
53
|
titleBoxIcon: titleBoxIcon,
|
|
55
54
|
titleBoxBgColor: titleBoxBgColor
|
|
56
55
|
});
|
|
57
|
-
var contents = jsx(React.Fragment, null, jsx(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
,
|
|
61
|
-
|
|
62
|
-
"data-testid": fileCardImageViewSelector,
|
|
63
|
-
"data-test-media-name": name,
|
|
64
|
-
"data-test-selected": selected ? true : undefined
|
|
56
|
+
var contents = jsx(React.Fragment, null, jsx(ImageContainer, _extends({
|
|
57
|
+
testId: fileCardImageViewSelector,
|
|
58
|
+
mediaName: name,
|
|
59
|
+
status: status,
|
|
60
|
+
selected: selected ? true : undefined
|
|
65
61
|
}, props), children, customBlanket ? customBlanket() : defaultBlanket, customTitleBox ? customTitleBox() : defaultTitleBox, !disableOverlay && !!selectable && jsx(TickBox, {
|
|
66
62
|
selected: selected
|
|
67
63
|
}), progressBar && progressBar()), !disableOverlay && actions && actions.length !== 0 && jsx(ActionsBar, {
|
|
@@ -31,6 +31,7 @@ import { useFilePreview } from '@atlaskit/media-file-preview';
|
|
|
31
31
|
import { performanceNow } from './performance';
|
|
32
32
|
import { useContext } from 'react';
|
|
33
33
|
import { DateOverrideContext } from '../../dateOverrideContext';
|
|
34
|
+
import { SvgView } from './svgView';
|
|
34
35
|
var LoadedCardView = getBooleanFF('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardViewV2;
|
|
35
36
|
export var FileCard = function FileCard(_ref) {
|
|
36
37
|
var _ref$appearance = _ref.appearance,
|
|
@@ -140,12 +141,16 @@ export var FileCard = function FileCard(_ref) {
|
|
|
140
141
|
setIsPlayingFile = _useState8[1];
|
|
141
142
|
var _useState9 = useState(false),
|
|
142
143
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
shouldRenderSVG = _useState10[0],
|
|
145
|
+
setShouldRenderSVG = _useState10[1];
|
|
145
146
|
var _useState11 = useState(false),
|
|
146
147
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
shouldAutoplay = _useState12[0],
|
|
149
|
+
setShouldAutoplay = _useState12[1];
|
|
150
|
+
var _useState13 = useState(false),
|
|
151
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
152
|
+
previewDidRender = _useState14[0],
|
|
153
|
+
setPreviewDidRender = _useState14[1];
|
|
149
154
|
var mediaBlobUrlAttrs = useMemo(function () {
|
|
150
155
|
var id = identifier.id,
|
|
151
156
|
collection = identifier.collectionName;
|
|
@@ -181,18 +186,18 @@ export var FileCard = function FileCard(_ref) {
|
|
|
181
186
|
onImageErrorBase = _useFilePreview.onImageError,
|
|
182
187
|
onImageLoadBase = _useFilePreview.onImageLoad,
|
|
183
188
|
getSsrScriptProps = _useFilePreview.getSsrScriptProps;
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
error =
|
|
187
|
-
setError =
|
|
189
|
+
var _useState15 = useState(),
|
|
190
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
191
|
+
error = _useState16[0],
|
|
192
|
+
setError = _useState16[1];
|
|
188
193
|
|
|
189
194
|
// CXP-2723 TODO: TEMPORARY VARIABLES
|
|
190
195
|
var finalError = error || (previewError && previewError.primaryReason !== 'failed-processing' ? previewError : undefined);
|
|
191
196
|
var finalStatus = finalError ? 'error' : status;
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
mediaViewerSelectedItem =
|
|
195
|
-
setMediaViewerSelectedItem =
|
|
197
|
+
var _useState17 = useState(null),
|
|
198
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
199
|
+
mediaViewerSelectedItem = _useState18[0],
|
|
200
|
+
setMediaViewerSelectedItem = _useState18[1];
|
|
196
201
|
var uploadProgressRef = useRef();
|
|
197
202
|
var metadata = useMemo(function () {
|
|
198
203
|
var getProcessingStatusFromFileState = function getProcessingStatusFromFileState(status) {
|
|
@@ -430,6 +435,23 @@ export var FileCard = function FileCard(_ref) {
|
|
|
430
435
|
}
|
|
431
436
|
}, [isCardVisible, disableOverlay, fileAttributes.fileMediatype, fileStateValue, identifier, isPlayingFile, finalStatus, useInlinePlayer]);
|
|
432
437
|
|
|
438
|
+
//----------------------------------------------------------------//
|
|
439
|
+
// Switch to SVG
|
|
440
|
+
//----------------------------------------------------------------//
|
|
441
|
+
|
|
442
|
+
useEffect(function () {
|
|
443
|
+
if (getBooleanFF('platform.media-card-svg-rendering_6tdbv') &&
|
|
444
|
+
/**
|
|
445
|
+
* We need to check that the card is visible before switching to SVG
|
|
446
|
+
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
447
|
+
* it is able to set isCardVisible to true.
|
|
448
|
+
*/
|
|
449
|
+
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay // SVG won't be supported when overlay is on
|
|
450
|
+
) {
|
|
451
|
+
setShouldRenderSVG(true);
|
|
452
|
+
}
|
|
453
|
+
}, [isCardVisible, disableOverlay, metadata]);
|
|
454
|
+
|
|
433
455
|
//----------------------------------------------------------------//
|
|
434
456
|
//----------------- fireScreenEvent ------------------------------//
|
|
435
457
|
//----------------------------------------------------------------//
|
|
@@ -497,6 +519,18 @@ export var FileCard = function FileCard(_ref) {
|
|
|
497
519
|
updateFileStateRef.current();
|
|
498
520
|
}, [fileState, preview, previewStatus, updateFileStateRef]);
|
|
499
521
|
|
|
522
|
+
//----------------------------------------------------------------//
|
|
523
|
+
// Shared Card View & SVG View resources
|
|
524
|
+
//----------------------------------------------------------------//
|
|
525
|
+
|
|
526
|
+
var mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, finalStatus === 'error' || finalStatus === 'failed-processing', !!preview, metadata.mediaType);
|
|
527
|
+
var onImageMouseEnter = function onImageMouseEnter(event) {
|
|
528
|
+
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter({
|
|
529
|
+
event: event,
|
|
530
|
+
mediaItemDetails: metadata
|
|
531
|
+
});
|
|
532
|
+
};
|
|
533
|
+
|
|
500
534
|
//----------------------------------------------------------------//
|
|
501
535
|
//---------------------- Render Card Function --------------------//
|
|
502
536
|
//----------------------------------------------------------------//
|
|
@@ -516,7 +550,6 @@ export var FileCard = function FileCard(_ref) {
|
|
|
516
550
|
var nativeLazyLoad = isLazyWithOverride && !isCardVisible && preview && isSSRPreview(preview);
|
|
517
551
|
// Force Media Image to always display img for SSR
|
|
518
552
|
var forceSyncDisplay = !!ssr;
|
|
519
|
-
var mediaCardCursor = getMediaCardCursor(!!useInlinePlayer, !!shouldOpenMediaViewer, finalStatus === 'error' || finalStatus === 'failed-processing', !!preview, metadata.mediaType);
|
|
520
553
|
var card = /*#__PURE__*/React.createElement(LoadedCardView, {
|
|
521
554
|
status: cardStatusOverride || finalStatus,
|
|
522
555
|
error: finalError,
|
|
@@ -532,12 +565,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
532
565
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
533
566
|
openMediaViewerButtonRef: mediaViewerButtonRef,
|
|
534
567
|
onClick: withCallbacks ? onCardViewClick : undefined,
|
|
535
|
-
onMouseEnter: withCallbacks ?
|
|
536
|
-
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter({
|
|
537
|
-
event: event,
|
|
538
|
-
mediaItemDetails: metadata
|
|
539
|
-
});
|
|
540
|
-
} : undefined,
|
|
568
|
+
onMouseEnter: withCallbacks ? onImageMouseEnter : undefined,
|
|
541
569
|
disableOverlay: disableOverlay,
|
|
542
570
|
progress: uploadProgressRef.current,
|
|
543
571
|
onDisplayImage: withCallbacks ? function () {
|
|
@@ -594,7 +622,25 @@ export var FileCard = function FileCard(_ref) {
|
|
|
594
622
|
testId: testId,
|
|
595
623
|
cardPreview: preview,
|
|
596
624
|
videoControlsWrapperRef: videoControlsWrapperRef
|
|
597
|
-
})) :
|
|
625
|
+
})) : shouldRenderSVG ? /*#__PURE__*/React.createElement(SvgView, {
|
|
626
|
+
testId: testId,
|
|
627
|
+
identifier: identifier,
|
|
628
|
+
status: finalStatus,
|
|
629
|
+
fileName: metadata.name,
|
|
630
|
+
cardPreview: preview,
|
|
631
|
+
alt: alt,
|
|
632
|
+
resizeMode: resizeMode,
|
|
633
|
+
dimensions: cardDimensions,
|
|
634
|
+
selected: selected,
|
|
635
|
+
onClick: onCardViewClick,
|
|
636
|
+
onMouseEnter: onImageMouseEnter,
|
|
637
|
+
progress: uploadProgressRef.current,
|
|
638
|
+
onImageError: onImageError,
|
|
639
|
+
onImageLoad: onImageLoad,
|
|
640
|
+
mediaCardCursor: mediaCardCursor,
|
|
641
|
+
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
642
|
+
openMediaViewerButtonRef: mediaViewerButtonRef
|
|
643
|
+
}) : renderCard(), mediaViewerSelectedItem ? /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
|
|
598
644
|
collectionName: collectionName,
|
|
599
645
|
items: mediaViewerItems || [],
|
|
600
646
|
mediaClientConfig: mediaClient.config,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var calculateSvgDimensions = function calculateSvgDimensions(img, resizeMode) {
|
|
2
|
+
var naturalWidth = img.naturalWidth,
|
|
3
|
+
naturalHeight = img.naturalHeight;
|
|
4
|
+
var isLadscape = naturalWidth / naturalHeight > 1;
|
|
5
|
+
return resizeMode === 'crop' ? isLadscape ? {
|
|
6
|
+
height: '100%'
|
|
7
|
+
} : {
|
|
8
|
+
width: '100%'
|
|
9
|
+
} : {};
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SvgView } from './svgView';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import React, { useState, 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 { ProgressBar } from '../../ui/progressBar/progressBar';
|
|
9
|
+
import { Blanket } from '../../ui/blanket/blanket';
|
|
10
|
+
import { Wrapper, ImageContainer } from '../../ui/wrapper';
|
|
11
|
+
import { fileCardImageViewSelector } from '../../classnames';
|
|
12
|
+
import { useBreakpoint } from '../../useBreakpoint';
|
|
13
|
+
import MediaSvg from '@atlaskit/media-svg';
|
|
14
|
+
import { calculateSvgDimensions } from './helpers';
|
|
15
|
+
import OpenMediaViewerButton from '../../ui/openMediaViewerButton/openMediaViewerButton';
|
|
16
|
+
export var convertResizeMode = function convertResizeMode(resizeMode) {
|
|
17
|
+
switch (resizeMode) {
|
|
18
|
+
case 'crop':
|
|
19
|
+
return 'cover';
|
|
20
|
+
case 'fit':
|
|
21
|
+
case 'full-fit':
|
|
22
|
+
return 'scale-down';
|
|
23
|
+
case 'stretchy-fit':
|
|
24
|
+
return 'contain';
|
|
25
|
+
default:
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export var SvgViewBase = function SvgViewBase(_ref) {
|
|
30
|
+
var identifier = _ref.identifier,
|
|
31
|
+
dimensions = _ref.dimensions,
|
|
32
|
+
onClick = _ref.onClick,
|
|
33
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
34
|
+
testId = _ref.testId,
|
|
35
|
+
status = _ref.status,
|
|
36
|
+
selected = _ref.selected,
|
|
37
|
+
fileName = _ref.fileName,
|
|
38
|
+
cardPreview = _ref.cardPreview,
|
|
39
|
+
mediaCardCursor = _ref.mediaCardCursor,
|
|
40
|
+
progress = _ref.progress,
|
|
41
|
+
alt = _ref.alt,
|
|
42
|
+
resizeMode = _ref.resizeMode,
|
|
43
|
+
shouldOpenMediaViewer = _ref.shouldOpenMediaViewer,
|
|
44
|
+
_ref$openMediaViewerB = _ref.openMediaViewerButtonRef,
|
|
45
|
+
openMediaViewerButtonRef = _ref$openMediaViewerB === void 0 ? null : _ref$openMediaViewerB;
|
|
46
|
+
var _useState = useState(false),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
didSvgRender = _useState2[0],
|
|
49
|
+
setDidSvgRender = _useState2[1];
|
|
50
|
+
var _useState3 = useState(false),
|
|
51
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
|
+
didPreviewRender = _useState4[0],
|
|
53
|
+
setDidPreviewRender = _useState4[1];
|
|
54
|
+
var _useState5 = useState(),
|
|
55
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
56
|
+
svgDimensions = _useState6[0],
|
|
57
|
+
setSvgDimensions = _useState6[1];
|
|
58
|
+
var divRef = useRef(null);
|
|
59
|
+
var breakpoint = useBreakpoint(dimensions === null || dimensions === void 0 ? void 0 : dimensions.width, divRef);
|
|
60
|
+
var onSvgLoad = function onSvgLoad(evt) {
|
|
61
|
+
setSvgDimensions(calculateSvgDimensions(evt.currentTarget, resizeMode));
|
|
62
|
+
setDidSvgRender(true);
|
|
63
|
+
};
|
|
64
|
+
var onPreviewLoad = function onPreviewLoad() {
|
|
65
|
+
setDidPreviewRender(true);
|
|
66
|
+
};
|
|
67
|
+
return jsx(React.Fragment, null, shouldOpenMediaViewer && jsx(OpenMediaViewerButton, {
|
|
68
|
+
fileName: fileName !== null && fileName !== void 0 ? fileName : '',
|
|
69
|
+
innerRef: openMediaViewerButtonRef,
|
|
70
|
+
onClick: onClick
|
|
71
|
+
}), jsx(Wrapper, {
|
|
72
|
+
testId: testId || 'media-card-svg-wrapper',
|
|
73
|
+
dimensions: dimensions,
|
|
74
|
+
onClick: onClick,
|
|
75
|
+
onMouseEnter: onMouseEnter,
|
|
76
|
+
innerRef: divRef,
|
|
77
|
+
mediaCardCursor: mediaCardCursor,
|
|
78
|
+
selected: !!selected,
|
|
79
|
+
breakpoint: breakpoint,
|
|
80
|
+
disableOverlay: true,
|
|
81
|
+
displayBackground: !didSvgRender && !didPreviewRender,
|
|
82
|
+
isTickBoxSelectable: false,
|
|
83
|
+
shouldDisplayTooltip: false,
|
|
84
|
+
isPlayButtonClickable: false
|
|
85
|
+
}, jsx(ImageContainer, {
|
|
86
|
+
centerElements: true,
|
|
87
|
+
testId: fileCardImageViewSelector,
|
|
88
|
+
mediaName: fileName,
|
|
89
|
+
status: status,
|
|
90
|
+
progress: progress,
|
|
91
|
+
selected: selected,
|
|
92
|
+
source: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source
|
|
93
|
+
}, jsx(MediaSvg, {
|
|
94
|
+
testId: "media-card-svg",
|
|
95
|
+
identifier: identifier,
|
|
96
|
+
dimensions: svgDimensions,
|
|
97
|
+
onLoad: onSvgLoad,
|
|
98
|
+
style: {
|
|
99
|
+
visibility: didSvgRender ? 'visible' : 'hidden',
|
|
100
|
+
objectFit: convertResizeMode(resizeMode)
|
|
101
|
+
}
|
|
102
|
+
}), !!cardPreview && !didSvgRender && jsx(ImageRenderer, {
|
|
103
|
+
cardPreview: cardPreview,
|
|
104
|
+
onImageLoad: onPreviewLoad,
|
|
105
|
+
mediaType: 'image',
|
|
106
|
+
alt: alt,
|
|
107
|
+
resizeMode: resizeMode
|
|
108
|
+
}), status === 'uploading' && jsx(Blanket, {
|
|
109
|
+
isFixed: true
|
|
110
|
+
}), status === 'uploading' && jsx(ProgressBar, {
|
|
111
|
+
progress: progress,
|
|
112
|
+
breakpoint: breakpoint,
|
|
113
|
+
positionBottom: true
|
|
114
|
+
}))));
|
|
115
|
+
};
|
|
116
|
+
export var SvgView = withAnalyticsEvents({
|
|
117
|
+
onClick: createAndFireMediaCardEvent({
|
|
118
|
+
eventType: 'ui',
|
|
119
|
+
action: 'clicked',
|
|
120
|
+
actionSubject: 'mediaCard',
|
|
121
|
+
attributes: {}
|
|
122
|
+
})
|
|
123
|
+
})(SvgViewBase);
|
|
@@ -103,7 +103,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
103
103
|
ErrorBoundary = _this$state.ErrorBoundary;
|
|
104
104
|
var analyticsContext = {
|
|
105
105
|
packageVersion: "@atlaskit/media-card",
|
|
106
|
-
packageName: "77.
|
|
106
|
+
packageName: "77.12.1",
|
|
107
107
|
componentName: 'mediaInlineCard',
|
|
108
108
|
component: 'mediaInlineCard'
|
|
109
109
|
};
|