@atlaskit/media-card 78.0.1 → 78.0.3
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 +15 -0
- package/dist/cjs/card/card.js +1 -1
- package/dist/cjs/card/fileCard.js +8 -7
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/svgView/helpers.js +48 -9
- package/dist/cjs/card/svgView/svgView.js +26 -28
- package/dist/cjs/card/ui/actionsBar/cardActions/styles.js +1 -1
- package/dist/cjs/card/ui/playButton/styles.js +2 -2
- package/dist/cjs/card/ui/titleBox/styles.js +2 -2
- package/dist/cjs/inline/loader.js +1 -1
- package/dist/cjs/utils/lightCards/errorIcon/styles.js +1 -1
- package/dist/cjs/utils/ufoExperiences.js +24 -1
- package/dist/es2019/card/card.js +1 -1
- package/dist/es2019/card/fileCard.js +9 -8
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/svgView/helpers.js +49 -9
- package/dist/es2019/card/svgView/svgView.js +23 -23
- package/dist/es2019/card/ui/actionsBar/cardActions/styles.js +1 -1
- package/dist/es2019/card/ui/playButton/styles.js +2 -2
- package/dist/es2019/card/ui/titleBox/styles.js +2 -2
- package/dist/es2019/inline/loader.js +1 -1
- package/dist/es2019/utils/lightCards/errorIcon/styles.js +1 -1
- package/dist/es2019/utils/ufoExperiences.js +25 -1
- package/dist/esm/card/card.js +1 -1
- package/dist/esm/card/fileCard.js +9 -8
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/svgView/helpers.js +48 -9
- package/dist/esm/card/svgView/svgView.js +26 -25
- package/dist/esm/card/ui/actionsBar/cardActions/styles.js +1 -1
- package/dist/esm/card/ui/playButton/styles.js +2 -2
- package/dist/esm/card/ui/titleBox/styles.js +2 -2
- package/dist/esm/inline/loader.js +1 -1
- package/dist/esm/utils/lightCards/errorIcon/styles.js +1 -1
- package/dist/esm/utils/ufoExperiences.js +24 -1
- package/dist/types/card/svgView/helpers.d.ts +1 -2
- package/dist/types/card/svgView/svgView.d.ts +4 -5
- package/dist/types-ts4.5/card/svgView/helpers.d.ts +1 -2
- package/dist/types-ts4.5/card/svgView/svgView.d.ts +4 -5
- package/example-helpers/cardViewWrapper.tsx +2 -0
- package/example-helpers/styles.ts +16 -16
- package/example-helpers/svg-helpers/svgContainer.tsx +3 -3
- package/package.json +3 -2
|
@@ -12,7 +12,7 @@ export const fixedPlayButtonStyles = `
|
|
|
12
12
|
}
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
15
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
16
16
|
export const playButtonWrapperStyles = css({
|
|
17
17
|
position: 'absolute',
|
|
18
18
|
top: 0,
|
|
@@ -29,7 +29,7 @@ export const playButtonWrapperStyles = css({
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
32
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
33
33
|
export const backgroundStyles = css({
|
|
34
34
|
transitionProperty: 'width, height',
|
|
35
35
|
transitionDuration: '0.1s',
|
|
@@ -55,14 +55,14 @@ infoStyles,
|
|
|
55
55
|
hasIconOverlap && iconOverlapStyles);
|
|
56
56
|
titleBoxFooterStyles.displayName = 'TitleBoxFooter';
|
|
57
57
|
|
|
58
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
58
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
59
59
|
export const titleBoxIconStyles = css({
|
|
60
60
|
position: 'absolute',
|
|
61
61
|
right: "var(--ds-space-050, 4px)",
|
|
62
62
|
bottom: '0px'
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
65
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
66
66
|
export const errorMessageWrapperStyles = css({
|
|
67
67
|
display: 'flex',
|
|
68
68
|
alignItems: 'center',
|
|
@@ -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: "78.0.
|
|
40
|
+
packageName: "78.0.3",
|
|
41
41
|
componentName: 'mediaInlineCard',
|
|
42
42
|
component: 'mediaInlineCard'
|
|
43
43
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
5
5
|
export const errorIconWrapperStyles = css({
|
|
6
6
|
display: 'flex',
|
|
7
7
|
color: "var(--ds-icon-warning, #ff991f)"
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
2
2
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
3
|
+
import isValidId from 'uuid-validate';
|
|
3
4
|
import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
4
5
|
import { MediaCardError } from '../errors';
|
|
5
6
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
6
7
|
const packageName = "@atlaskit/media-card";
|
|
7
|
-
const packageVersion = "78.0.
|
|
8
|
+
const packageVersion = "78.0.3";
|
|
8
9
|
let concurrentExperience;
|
|
9
10
|
const getExperience = id => {
|
|
10
11
|
if (!concurrentExperience) {
|
|
@@ -23,6 +24,20 @@ const getExperience = id => {
|
|
|
23
24
|
export const startUfoExperience = id => {
|
|
24
25
|
getExperience(id).start();
|
|
25
26
|
};
|
|
27
|
+
const sanitiseFileAttributes = fileAttributes => {
|
|
28
|
+
/*
|
|
29
|
+
Allow external image mediaItemType as fileId
|
|
30
|
+
See ExternalImageIdentifier interface on platform/packages/media/media-client/src/identifier.ts
|
|
31
|
+
*/
|
|
32
|
+
let sanitisedFileId = 'INVALID_FILE_ID';
|
|
33
|
+
if (fileAttributes.fileId === 'external-image' || isValidId(fileAttributes.fileId)) {
|
|
34
|
+
sanitisedFileId = fileAttributes.fileId;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
...fileAttributes,
|
|
38
|
+
fileId: sanitisedFileId
|
|
39
|
+
};
|
|
40
|
+
};
|
|
26
41
|
export const completeUfoExperience = (id, status, fileAttributes, fileStateFlags, ssrReliability, error = new MediaCardError('missing-error-data')) => {
|
|
27
42
|
switch (status) {
|
|
28
43
|
case 'complete':
|
|
@@ -58,6 +73,9 @@ const getBasePayloadAttributes = () => ({
|
|
|
58
73
|
mediaRegion: getMediaRegion()
|
|
59
74
|
});
|
|
60
75
|
const succeedUfoExperience = (id, properties) => {
|
|
76
|
+
if (properties !== null && properties !== void 0 && properties.fileAttributes) {
|
|
77
|
+
properties.fileAttributes = sanitiseFileAttributes(properties.fileAttributes);
|
|
78
|
+
}
|
|
61
79
|
getExperience(id).success({
|
|
62
80
|
metadata: {
|
|
63
81
|
...properties,
|
|
@@ -66,6 +84,9 @@ const succeedUfoExperience = (id, properties) => {
|
|
|
66
84
|
});
|
|
67
85
|
};
|
|
68
86
|
const failUfoExperience = (id, properties) => {
|
|
87
|
+
if (properties !== null && properties !== void 0 && properties.fileAttributes) {
|
|
88
|
+
properties.fileAttributes = sanitiseFileAttributes(properties.fileAttributes);
|
|
89
|
+
}
|
|
69
90
|
getExperience(id).failure({
|
|
70
91
|
metadata: {
|
|
71
92
|
...properties,
|
|
@@ -75,6 +96,9 @@ const failUfoExperience = (id, properties) => {
|
|
|
75
96
|
};
|
|
76
97
|
export const abortUfoExperience = (id, properties) => {
|
|
77
98
|
// UFO won't abort if it's already in a final state (succeeded, failed, aborted, etc)
|
|
99
|
+
if (properties !== null && properties !== void 0 && properties.fileAttributes) {
|
|
100
|
+
properties.fileAttributes = sanitiseFileAttributes(properties.fileAttributes);
|
|
101
|
+
}
|
|
78
102
|
getExperience(id).abort({
|
|
79
103
|
metadata: {
|
|
80
104
|
...properties,
|
package/dist/esm/card/card.js
CHANGED
|
@@ -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 = "78.0.
|
|
12
|
+
var packageVersion = "78.0.3";
|
|
13
13
|
export var CardBase = function CardBase(_ref) {
|
|
14
14
|
var identifier = _ref.identifier,
|
|
15
15
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
import {
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
8
8
|
import { globalMediaEventEmitter, RECENTS_COLLECTION, imageResizeModeToFileImageMode, isProcessedFileState } from '@atlaskit/media-client';
|
|
9
9
|
import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
@@ -32,7 +32,7 @@ import { performanceNow } from './performance';
|
|
|
32
32
|
import { useContext } from 'react';
|
|
33
33
|
import { DateOverrideContext } from '../dateOverrideContext';
|
|
34
34
|
import { SvgView } from './svgView';
|
|
35
|
-
var LoadedCardView =
|
|
35
|
+
var LoadedCardView = fg('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardView;
|
|
36
36
|
export var FileCard = function FileCard(_ref) {
|
|
37
37
|
var _ref$appearance = _ref.appearance,
|
|
38
38
|
appearance = _ref$appearance === void 0 ? 'auto' : _ref$appearance,
|
|
@@ -318,7 +318,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
318
318
|
setShouldRenderSVG(false);
|
|
319
319
|
};
|
|
320
320
|
var onImageError = function onImageError(newCardPreview) {
|
|
321
|
-
if (
|
|
321
|
+
if (metadata.mimeType === 'image/svg+xml' && fg('platform.media-card-svg-rendering_6tdbv')) {
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
324
|
onImageErrorBase(newCardPreview);
|
|
@@ -327,7 +327,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
327
327
|
setPreviewDidRender(true);
|
|
328
328
|
};
|
|
329
329
|
var onImageLoad = function onImageLoad(newCardPreview) {
|
|
330
|
-
if (
|
|
330
|
+
if (metadata.mimeType === 'image/svg+xml' && fg('platform.media-card-svg-rendering_6tdbv')) {
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
onImageLoadBase(newCardPreview);
|
|
@@ -454,14 +454,15 @@ export var FileCard = function FileCard(_ref) {
|
|
|
454
454
|
//----------------------------------------------------------------//
|
|
455
455
|
|
|
456
456
|
useEffect(function () {
|
|
457
|
-
if (
|
|
457
|
+
if (finalStatus !== 'error' &&
|
|
458
458
|
/**
|
|
459
459
|
* We need to check that the card is visible before switching to SVG
|
|
460
460
|
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
461
461
|
* it is able to set isCardVisible to true.
|
|
462
462
|
*/
|
|
463
|
-
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay
|
|
464
|
-
|
|
463
|
+
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay &&
|
|
464
|
+
// SVG won't be supported when overlay is on
|
|
465
|
+
fg('platform.media-card-svg-rendering_6tdbv')) {
|
|
465
466
|
setShouldRenderSVG(true);
|
|
466
467
|
}
|
|
467
468
|
}, [isCardVisible, disableOverlay, metadata.mimeType, finalStatus]);
|
|
@@ -644,7 +645,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
644
645
|
cardPreview: preview,
|
|
645
646
|
alt: alt,
|
|
646
647
|
resizeMode: resizeMode,
|
|
647
|
-
|
|
648
|
+
cardDimensions: cardDimensions,
|
|
648
649
|
selected: selected,
|
|
649
650
|
onClick: onCardViewClick,
|
|
650
651
|
onMouseEnter: onImageMouseEnter,
|
|
@@ -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 = "78.0.
|
|
86
|
+
var packageVersion = "78.0.3";
|
|
87
87
|
var MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
88
88
|
packageVersion: packageVersion,
|
|
89
89
|
packageName: packageName,
|
|
@@ -1,10 +1,49 @@
|
|
|
1
|
-
export var calculateSvgDimensions = function calculateSvgDimensions(
|
|
2
|
-
var naturalWidth =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export var calculateSvgDimensions = function calculateSvgDimensions(imgElement, parentElement, resizeMode) {
|
|
2
|
+
var naturalWidth = imgElement.naturalWidth,
|
|
3
|
+
width = imgElement.width,
|
|
4
|
+
naturalHeight = imgElement.naturalHeight,
|
|
5
|
+
height = imgElement.height;
|
|
6
|
+
// Firefox & Safari can't always read the "natural" dimensions correctly.
|
|
7
|
+
// When these are undefined or zero, we replace them with the rendered values
|
|
8
|
+
var imgWidth = naturalWidth || width;
|
|
9
|
+
var imgHeight = naturalHeight || height;
|
|
10
|
+
var _parentElement$getBou = parentElement.getBoundingClientRect(),
|
|
11
|
+
parentWidth = _parentElement$getBou.width,
|
|
12
|
+
parentHeight = _parentElement$getBou.height;
|
|
13
|
+
if (resizeMode === 'fit' || resizeMode === 'full-fit') {
|
|
14
|
+
return {
|
|
15
|
+
maxWidth: "min(100%, ".concat(imgWidth, "px"),
|
|
16
|
+
maxHeight: "min(100%, ".concat(imgHeight, "px")
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
var imgRatio = imgWidth / imgHeight;
|
|
20
|
+
var cardRatio = parentWidth / parentHeight;
|
|
21
|
+
var isImageLandscapier = imgRatio > cardRatio;
|
|
22
|
+
if (resizeMode === 'stretchy-fit') {
|
|
23
|
+
if (isImageLandscapier) {
|
|
24
|
+
return {
|
|
25
|
+
width: '100%',
|
|
26
|
+
maxHeight: '100%'
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
return {
|
|
30
|
+
height: '100%',
|
|
31
|
+
maxWidth: '100%'
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (resizeMode === 'crop') {
|
|
36
|
+
if (isImageLandscapier) {
|
|
37
|
+
return {
|
|
38
|
+
height: imgHeight,
|
|
39
|
+
maxHeight: '100%'
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
return {
|
|
43
|
+
width: imgWidth,
|
|
44
|
+
maxWidth: '100%'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {};
|
|
10
49
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
5
|
/** @jsx jsx */
|
|
3
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
7
|
import { jsx } from '@emotion/react';
|
|
5
|
-
import React, { useState, useRef } from 'react';
|
|
8
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
6
9
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
7
10
|
import { createAndFireMediaCardEvent } from '../../utils/analytics';
|
|
8
11
|
import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
|
|
@@ -16,22 +19,9 @@ import { calculateSvgDimensions } from './helpers';
|
|
|
16
19
|
import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
|
|
17
20
|
import { MediaCardError } from '../../errors';
|
|
18
21
|
import { getErrorReason } from './errors';
|
|
19
|
-
export var convertResizeMode = function convertResizeMode(resizeMode) {
|
|
20
|
-
switch (resizeMode) {
|
|
21
|
-
case 'crop':
|
|
22
|
-
return 'cover';
|
|
23
|
-
case 'fit':
|
|
24
|
-
case 'full-fit':
|
|
25
|
-
return 'scale-down';
|
|
26
|
-
case 'stretchy-fit':
|
|
27
|
-
return 'contain';
|
|
28
|
-
default:
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
22
|
export var SvgViewBase = function SvgViewBase(_ref) {
|
|
33
23
|
var identifier = _ref.identifier,
|
|
34
|
-
|
|
24
|
+
cardDimensions = _ref.cardDimensions,
|
|
35
25
|
onClick = _ref.onClick,
|
|
36
26
|
onMouseEnter = _ref.onMouseEnter,
|
|
37
27
|
testId = _ref.testId,
|
|
@@ -60,10 +50,17 @@ export var SvgViewBase = function SvgViewBase(_ref) {
|
|
|
60
50
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
61
51
|
svgDimensions = _useState6[0],
|
|
62
52
|
setSvgDimensions = _useState6[1];
|
|
63
|
-
var
|
|
64
|
-
var
|
|
53
|
+
var imgRef = useRef(null);
|
|
54
|
+
var wrapperRef = useRef(null);
|
|
55
|
+
var breakpoint = useBreakpoint(cardDimensions.width, wrapperRef);
|
|
56
|
+
var calculateDimensions = useCallback(function (targetImgElem) {
|
|
57
|
+
if (!wrapperRef.current || !targetImgElem) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setSvgDimensions(calculateSvgDimensions(targetImgElem, wrapperRef.current, resizeMode));
|
|
61
|
+
}, [resizeMode]);
|
|
65
62
|
var onSvgLoad = function onSvgLoad(evt) {
|
|
66
|
-
|
|
63
|
+
calculateDimensions(evt.currentTarget);
|
|
67
64
|
setDidSvgRender(true);
|
|
68
65
|
onLoad();
|
|
69
66
|
};
|
|
@@ -74,16 +71,21 @@ export var SvgViewBase = function SvgViewBase(_ref) {
|
|
|
74
71
|
var onPreviewLoad = function onPreviewLoad() {
|
|
75
72
|
setDidPreviewRender(true);
|
|
76
73
|
};
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (imgRef.current) {
|
|
76
|
+
calculateDimensions(imgRef.current);
|
|
77
|
+
}
|
|
78
|
+
}, [imgRef, calculateDimensions]);
|
|
77
79
|
return jsx(React.Fragment, null, shouldOpenMediaViewer && jsx(OpenMediaViewerButton, {
|
|
78
80
|
fileName: fileName !== null && fileName !== void 0 ? fileName : '',
|
|
79
81
|
innerRef: openMediaViewerButtonRef,
|
|
80
82
|
onClick: onClick
|
|
81
83
|
}), jsx(Wrapper, {
|
|
82
84
|
testId: testId || 'media-card-svg-wrapper',
|
|
83
|
-
dimensions:
|
|
85
|
+
dimensions: cardDimensions,
|
|
84
86
|
onClick: onClick,
|
|
85
87
|
onMouseEnter: onMouseEnter,
|
|
86
|
-
innerRef:
|
|
88
|
+
innerRef: wrapperRef,
|
|
87
89
|
mediaCardCursor: mediaCardCursor,
|
|
88
90
|
selected: !!selected,
|
|
89
91
|
breakpoint: breakpoint,
|
|
@@ -103,13 +105,12 @@ export var SvgViewBase = function SvgViewBase(_ref) {
|
|
|
103
105
|
}, jsx(MediaSvg, {
|
|
104
106
|
testId: "media-card-svg",
|
|
105
107
|
identifier: identifier,
|
|
106
|
-
dimensions: svgDimensions,
|
|
107
108
|
onLoad: onSvgLoad,
|
|
108
109
|
onError: onSvgError,
|
|
109
|
-
style: {
|
|
110
|
-
visibility: didSvgRender ? 'visible' : 'hidden'
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
style: _objectSpread({
|
|
111
|
+
visibility: didSvgRender ? 'visible' : 'hidden'
|
|
112
|
+
}, svgDimensions),
|
|
113
|
+
ref: imgRef
|
|
113
114
|
}), !!cardPreview && !didSvgRender && jsx(ImageRenderer, {
|
|
114
115
|
cardPreview: cardPreview,
|
|
115
116
|
onImageLoad: onPreviewLoad,
|
|
@@ -5,7 +5,7 @@ import { borderRadius, size, center } from '@atlaskit/media-ui';
|
|
|
5
5
|
import { rgba } from '../../styles';
|
|
6
6
|
import { fontFamily } from '@atlaskit/theme/constants';
|
|
7
7
|
|
|
8
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
9
9
|
export var wrapperStyles = css({
|
|
10
10
|
boxSizing: 'border-box',
|
|
11
11
|
fontFamily: fontFamily(),
|
|
@@ -7,7 +7,7 @@ var discSize = 48;
|
|
|
7
7
|
var discSizeHover = 56;
|
|
8
8
|
export var fixedPlayButtonStyles = "\n .".concat(bkgClassName, " {\n width: ").concat(discSizeHover, "px;\n height: ").concat(discSizeHover, "px;\n }\n");
|
|
9
9
|
|
|
10
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
10
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
11
11
|
export var playButtonWrapperStyles = css({
|
|
12
12
|
position: 'absolute',
|
|
13
13
|
top: 0,
|
|
@@ -24,7 +24,7 @@ export var playButtonWrapperStyles = css({
|
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
27
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
28
28
|
export var backgroundStyles = css({
|
|
29
29
|
transitionProperty: 'width, height',
|
|
30
30
|
transitionDuration: '0.1s',
|
|
@@ -58,14 +58,14 @@ export var titleBoxFooterStyles = function titleBoxFooterStyles(_ref3) {
|
|
|
58
58
|
};
|
|
59
59
|
titleBoxFooterStyles.displayName = 'TitleBoxFooter';
|
|
60
60
|
|
|
61
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
61
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
62
62
|
export var titleBoxIconStyles = css({
|
|
63
63
|
position: 'absolute',
|
|
64
64
|
right: "var(--ds-space-050, 4px)",
|
|
65
65
|
bottom: '0px'
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
68
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
69
69
|
export var errorMessageWrapperStyles = css({
|
|
70
70
|
display: 'flex',
|
|
71
71
|
alignItems: 'center',
|
|
@@ -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: "78.0.
|
|
106
|
+
packageName: "78.0.3",
|
|
107
107
|
componentName: 'mediaInlineCard',
|
|
108
108
|
component: 'mediaInlineCard'
|
|
109
109
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
3
|
|
|
4
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
5
5
|
export var errorIconWrapperStyles = css({
|
|
6
6
|
display: 'flex',
|
|
7
7
|
color: "var(--ds-icon-warning, #ff991f)"
|
|
@@ -3,11 +3,12 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
5
5
|
import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
|
|
6
|
+
import isValidId from 'uuid-validate';
|
|
6
7
|
import { extractErrorInfo, getRenderErrorRequestMetadata } from './analytics';
|
|
7
8
|
import { MediaCardError } from '../errors';
|
|
8
9
|
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
9
10
|
var packageName = "@atlaskit/media-card";
|
|
10
|
-
var packageVersion = "78.0.
|
|
11
|
+
var packageVersion = "78.0.3";
|
|
11
12
|
var concurrentExperience;
|
|
12
13
|
var getExperience = function getExperience(id) {
|
|
13
14
|
if (!concurrentExperience) {
|
|
@@ -26,6 +27,19 @@ var getExperience = function getExperience(id) {
|
|
|
26
27
|
export var startUfoExperience = function startUfoExperience(id) {
|
|
27
28
|
getExperience(id).start();
|
|
28
29
|
};
|
|
30
|
+
var sanitiseFileAttributes = function sanitiseFileAttributes(fileAttributes) {
|
|
31
|
+
/*
|
|
32
|
+
Allow external image mediaItemType as fileId
|
|
33
|
+
See ExternalImageIdentifier interface on platform/packages/media/media-client/src/identifier.ts
|
|
34
|
+
*/
|
|
35
|
+
var sanitisedFileId = 'INVALID_FILE_ID';
|
|
36
|
+
if (fileAttributes.fileId === 'external-image' || isValidId(fileAttributes.fileId)) {
|
|
37
|
+
sanitisedFileId = fileAttributes.fileId;
|
|
38
|
+
}
|
|
39
|
+
return _objectSpread(_objectSpread({}, fileAttributes), {}, {
|
|
40
|
+
fileId: sanitisedFileId
|
|
41
|
+
});
|
|
42
|
+
};
|
|
29
43
|
export var completeUfoExperience = function completeUfoExperience(id, status, fileAttributes, fileStateFlags, ssrReliability) {
|
|
30
44
|
var error = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new MediaCardError('missing-error-data');
|
|
31
45
|
switch (status) {
|
|
@@ -64,17 +78,26 @@ var getBasePayloadAttributes = function getBasePayloadAttributes() {
|
|
|
64
78
|
};
|
|
65
79
|
};
|
|
66
80
|
var succeedUfoExperience = function succeedUfoExperience(id, properties) {
|
|
81
|
+
if (properties !== null && properties !== void 0 && properties.fileAttributes) {
|
|
82
|
+
properties.fileAttributes = sanitiseFileAttributes(properties.fileAttributes);
|
|
83
|
+
}
|
|
67
84
|
getExperience(id).success({
|
|
68
85
|
metadata: _objectSpread(_objectSpread({}, properties), getBasePayloadAttributes())
|
|
69
86
|
});
|
|
70
87
|
};
|
|
71
88
|
var failUfoExperience = function failUfoExperience(id, properties) {
|
|
89
|
+
if (properties !== null && properties !== void 0 && properties.fileAttributes) {
|
|
90
|
+
properties.fileAttributes = sanitiseFileAttributes(properties.fileAttributes);
|
|
91
|
+
}
|
|
72
92
|
getExperience(id).failure({
|
|
73
93
|
metadata: _objectSpread(_objectSpread({}, properties), getBasePayloadAttributes())
|
|
74
94
|
});
|
|
75
95
|
};
|
|
76
96
|
export var abortUfoExperience = function abortUfoExperience(id, properties) {
|
|
77
97
|
// UFO won't abort if it's already in a final state (succeeded, failed, aborted, etc)
|
|
98
|
+
if (properties !== null && properties !== void 0 && properties.fileAttributes) {
|
|
99
|
+
properties.fileAttributes = sanitiseFileAttributes(properties.fileAttributes);
|
|
100
|
+
}
|
|
78
101
|
getExperience(id).abort({
|
|
79
102
|
metadata: _objectSpread(_objectSpread({}, properties), getBasePayloadAttributes())
|
|
80
103
|
});
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { type ImageResizeMode } from '@atlaskit/media-client';
|
|
2
|
-
|
|
3
|
-
export declare const calculateSvgDimensions: (img: HTMLImageElement, resizeMode?: ImageResizeMode) => MediaSvgProps['dimensions'];
|
|
2
|
+
export declare const calculateSvgDimensions: (imgElement: HTMLImageElement, parentElement: HTMLElement, resizeMode: ImageResizeMode) => React.CSSProperties;
|
|
@@ -3,16 +3,15 @@ import { jsx } from '@emotion/react';
|
|
|
3
3
|
import React, { type MouseEvent } from 'react';
|
|
4
4
|
import { type FileIdentifier, type ImageResizeMode } from '@atlaskit/media-client';
|
|
5
5
|
import { type WithAnalyticsEventsProps, type UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
|
-
import { type
|
|
6
|
+
import { type CardDimensions, type CardStatus, type MediaCardCursor } from '../../types';
|
|
7
7
|
import { type MediaFilePreview } from '@atlaskit/media-file-preview';
|
|
8
8
|
import { MediaCardError } from '../../errors';
|
|
9
|
-
export declare const convertResizeMode: (resizeMode?: ImageResizeMode) => React.CSSProperties['objectFit'];
|
|
10
9
|
export type OnClickFn = (event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
|
|
11
10
|
export interface SvgViewBaseOwnProps {
|
|
12
11
|
readonly testId?: string;
|
|
13
12
|
identifier: FileIdentifier;
|
|
14
13
|
readonly status: CardStatus;
|
|
15
|
-
readonly
|
|
14
|
+
readonly cardDimensions: CardDimensions;
|
|
16
15
|
readonly onClick?: OnClickFn;
|
|
17
16
|
readonly onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
18
17
|
readonly selected?: boolean;
|
|
@@ -21,12 +20,12 @@ export interface SvgViewBaseOwnProps {
|
|
|
21
20
|
readonly mediaCardCursor?: MediaCardCursor;
|
|
22
21
|
readonly progress?: number;
|
|
23
22
|
readonly alt?: string;
|
|
24
|
-
readonly resizeMode
|
|
23
|
+
readonly resizeMode: ImageResizeMode;
|
|
25
24
|
readonly onLoad: () => void;
|
|
26
25
|
readonly onError: (error: MediaCardError) => void;
|
|
27
26
|
readonly shouldOpenMediaViewer?: boolean;
|
|
28
27
|
readonly openMediaViewerButtonRef?: React.Ref<HTMLButtonElement>;
|
|
29
28
|
}
|
|
30
29
|
export type SvgViewProps = SvgViewBaseOwnProps & WithAnalyticsEventsProps;
|
|
31
|
-
export declare const SvgViewBase: ({ identifier,
|
|
30
|
+
export declare const SvgViewBase: ({ identifier, cardDimensions, onClick, onMouseEnter, testId, status, selected, fileName, cardPreview, mediaCardCursor, progress, alt, resizeMode, shouldOpenMediaViewer, openMediaViewerButtonRef, onLoad, onError, }: SvgViewProps) => jsx.JSX.Element;
|
|
32
31
|
export declare const SvgView: React.ForwardRefExoticComponent<Omit<SvgViewBaseOwnProps & WithAnalyticsEventsProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { type ImageResizeMode } from '@atlaskit/media-client';
|
|
2
|
-
|
|
3
|
-
export declare const calculateSvgDimensions: (img: HTMLImageElement, resizeMode?: ImageResizeMode) => MediaSvgProps['dimensions'];
|
|
2
|
+
export declare const calculateSvgDimensions: (imgElement: HTMLImageElement, parentElement: HTMLElement, resizeMode: ImageResizeMode) => React.CSSProperties;
|
|
@@ -3,16 +3,15 @@ import { jsx } from '@emotion/react';
|
|
|
3
3
|
import React, { type MouseEvent } from 'react';
|
|
4
4
|
import { type FileIdentifier, type ImageResizeMode } from '@atlaskit/media-client';
|
|
5
5
|
import { type WithAnalyticsEventsProps, type UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
|
-
import { type
|
|
6
|
+
import { type CardDimensions, type CardStatus, type MediaCardCursor } from '../../types';
|
|
7
7
|
import { type MediaFilePreview } from '@atlaskit/media-file-preview';
|
|
8
8
|
import { MediaCardError } from '../../errors';
|
|
9
|
-
export declare const convertResizeMode: (resizeMode?: ImageResizeMode) => React.CSSProperties['objectFit'];
|
|
10
9
|
export type OnClickFn = (event: React.MouseEvent<HTMLDivElement | HTMLButtonElement>, analyticsEvent?: UIAnalyticsEvent) => void;
|
|
11
10
|
export interface SvgViewBaseOwnProps {
|
|
12
11
|
readonly testId?: string;
|
|
13
12
|
identifier: FileIdentifier;
|
|
14
13
|
readonly status: CardStatus;
|
|
15
|
-
readonly
|
|
14
|
+
readonly cardDimensions: CardDimensions;
|
|
16
15
|
readonly onClick?: OnClickFn;
|
|
17
16
|
readonly onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
18
17
|
readonly selected?: boolean;
|
|
@@ -21,12 +20,12 @@ export interface SvgViewBaseOwnProps {
|
|
|
21
20
|
readonly mediaCardCursor?: MediaCardCursor;
|
|
22
21
|
readonly progress?: number;
|
|
23
22
|
readonly alt?: string;
|
|
24
|
-
readonly resizeMode
|
|
23
|
+
readonly resizeMode: ImageResizeMode;
|
|
25
24
|
readonly onLoad: () => void;
|
|
26
25
|
readonly onError: (error: MediaCardError) => void;
|
|
27
26
|
readonly shouldOpenMediaViewer?: boolean;
|
|
28
27
|
readonly openMediaViewerButtonRef?: React.Ref<HTMLButtonElement>;
|
|
29
28
|
}
|
|
30
29
|
export type SvgViewProps = SvgViewBaseOwnProps & WithAnalyticsEventsProps;
|
|
31
|
-
export declare const SvgViewBase: ({ identifier,
|
|
30
|
+
export declare const SvgViewBase: ({ identifier, cardDimensions, onClick, onMouseEnter, testId, status, selected, fileName, cardPreview, mediaCardCursor, progress, alt, resizeMode, shouldOpenMediaViewer, openMediaViewerButtonRef, onLoad, onError, }: SvgViewProps) => jsx.JSX.Element;
|
|
32
31
|
export declare const SvgView: React.ForwardRefExoticComponent<Omit<SvgViewBaseOwnProps & WithAnalyticsEventsProps, keyof WithAnalyticsEventsProps> & React.RefAttributes<any>>;
|
|
@@ -35,8 +35,10 @@ const cardWrapperStyles = ({ small, displayInline }: CardViewWrapperProps) =>
|
|
|
35
35
|
|
|
36
36
|
export const CardViewWrapper = (props: CardViewWrapperProps) => {
|
|
37
37
|
if (props.small) {
|
|
38
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
38
39
|
return <Box xcss={[cardWrapperStyles(props), smallStyles]}>{props.children}</Box>;
|
|
39
40
|
} else {
|
|
41
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
40
42
|
return <Box xcss={[cardWrapperStyles(props), largeStyles]}>{props.children}</Box>;
|
|
41
43
|
}
|
|
42
44
|
};
|