@atlaskit/media-card 78.0.2 → 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 +8 -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 +1 -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 +1 -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 +1 -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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/media-card
|
|
2
2
|
|
|
3
|
+
## 78.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#116684](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116684)
|
|
8
|
+
[`72f1da4341a27`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/72f1da4341a27) -
|
|
9
|
+
Fixes sizing modes for SVG native rendering integration
|
|
10
|
+
|
|
3
11
|
## 78.0.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/cjs/card/card.js
CHANGED
|
@@ -16,7 +16,7 @@ var _externalImageCard = require("./externalImageCard");
|
|
|
16
16
|
var _fileCard = require("./fileCard");
|
|
17
17
|
var _excluded = ["identifier"];
|
|
18
18
|
var packageName = "@atlaskit/media-card";
|
|
19
|
-
var packageVersion = "78.0.
|
|
19
|
+
var packageVersion = "78.0.3";
|
|
20
20
|
var CardBase = exports.CardBase = function CardBase(_ref) {
|
|
21
21
|
var identifier = _ref.identifier,
|
|
22
22
|
otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
@@ -41,7 +41,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
41
41
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
42
42
|
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; }
|
|
43
43
|
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) { (0, _defineProperty2.default)(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; }
|
|
44
|
-
var LoadedCardView = (0, _platformFeatureFlags.
|
|
44
|
+
var LoadedCardView = (0, _platformFeatureFlags.fg)('platform.media-experience.card-views-refactor_b91lr') ? _cardviews.CardViews : _cardView.CardView;
|
|
45
45
|
var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
46
46
|
var _ref$appearance = _ref.appearance,
|
|
47
47
|
appearance = _ref$appearance === void 0 ? 'auto' : _ref$appearance,
|
|
@@ -327,7 +327,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
327
327
|
setShouldRenderSVG(false);
|
|
328
328
|
};
|
|
329
329
|
var onImageError = function onImageError(newCardPreview) {
|
|
330
|
-
if ((0, _platformFeatureFlags.
|
|
330
|
+
if (metadata.mimeType === 'image/svg+xml' && (0, _platformFeatureFlags.fg)('platform.media-card-svg-rendering_6tdbv')) {
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
333
|
onImageErrorBase(newCardPreview);
|
|
@@ -336,7 +336,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
336
336
|
setPreviewDidRender(true);
|
|
337
337
|
};
|
|
338
338
|
var onImageLoad = function onImageLoad(newCardPreview) {
|
|
339
|
-
if ((0, _platformFeatureFlags.
|
|
339
|
+
if (metadata.mimeType === 'image/svg+xml' && (0, _platformFeatureFlags.fg)('platform.media-card-svg-rendering_6tdbv')) {
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
342
|
onImageLoadBase(newCardPreview);
|
|
@@ -463,14 +463,15 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
463
463
|
//----------------------------------------------------------------//
|
|
464
464
|
|
|
465
465
|
(0, _react.useEffect)(function () {
|
|
466
|
-
if (
|
|
466
|
+
if (finalStatus !== 'error' &&
|
|
467
467
|
/**
|
|
468
468
|
* We need to check that the card is visible before switching to SVG
|
|
469
469
|
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
470
470
|
* it is able to set isCardVisible to true.
|
|
471
471
|
*/
|
|
472
|
-
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay
|
|
473
|
-
|
|
472
|
+
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay &&
|
|
473
|
+
// SVG won't be supported when overlay is on
|
|
474
|
+
(0, _platformFeatureFlags.fg)('platform.media-card-svg-rendering_6tdbv')) {
|
|
474
475
|
setShouldRenderSVG(true);
|
|
475
476
|
}
|
|
476
477
|
}, [isCardVisible, disableOverlay, metadata.mimeType, finalStatus]);
|
|
@@ -653,7 +654,7 @@ var FileCard = exports.FileCard = function FileCard(_ref) {
|
|
|
653
654
|
cardPreview: preview,
|
|
654
655
|
alt: alt,
|
|
655
656
|
resizeMode: resizeMode,
|
|
656
|
-
|
|
657
|
+
cardDimensions: cardDimensions,
|
|
657
658
|
selected: selected,
|
|
658
659
|
onClick: onCardViewClick,
|
|
659
660
|
onMouseEnter: onImageMouseEnter,
|
|
@@ -90,7 +90,7 @@ var WrappedMediaCardAnalyticsErrorBoundary = /*#__PURE__*/function (_React$Compo
|
|
|
90
90
|
}(_react.default.Component);
|
|
91
91
|
(0, _defineProperty2.default)(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
92
92
|
var packageName = "@atlaskit/media-card";
|
|
93
|
-
var packageVersion = "78.0.
|
|
93
|
+
var packageVersion = "78.0.3";
|
|
94
94
|
var MediaCardAnalyticsErrorBoundary = (0, _mediaCommon.withMediaAnalyticsContext)({
|
|
95
95
|
packageVersion: packageVersion,
|
|
96
96
|
packageName: packageName,
|
|
@@ -4,13 +4,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calculateSvgDimensions = void 0;
|
|
7
|
-
var calculateSvgDimensions = exports.calculateSvgDimensions = function calculateSvgDimensions(
|
|
8
|
-
var naturalWidth =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
var calculateSvgDimensions = exports.calculateSvgDimensions = function calculateSvgDimensions(imgElement, parentElement, resizeMode) {
|
|
8
|
+
var naturalWidth = imgElement.naturalWidth,
|
|
9
|
+
width = imgElement.width,
|
|
10
|
+
naturalHeight = imgElement.naturalHeight,
|
|
11
|
+
height = imgElement.height;
|
|
12
|
+
// Firefox & Safari can't always read the "natural" dimensions correctly.
|
|
13
|
+
// When these are undefined or zero, we replace them with the rendered values
|
|
14
|
+
var imgWidth = naturalWidth || width;
|
|
15
|
+
var imgHeight = naturalHeight || height;
|
|
16
|
+
var _parentElement$getBou = parentElement.getBoundingClientRect(),
|
|
17
|
+
parentWidth = _parentElement$getBou.width,
|
|
18
|
+
parentHeight = _parentElement$getBou.height;
|
|
19
|
+
if (resizeMode === 'fit' || resizeMode === 'full-fit') {
|
|
20
|
+
return {
|
|
21
|
+
maxWidth: "min(100%, ".concat(imgWidth, "px"),
|
|
22
|
+
maxHeight: "min(100%, ".concat(imgHeight, "px")
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var imgRatio = imgWidth / imgHeight;
|
|
26
|
+
var cardRatio = parentWidth / parentHeight;
|
|
27
|
+
var isImageLandscapier = imgRatio > cardRatio;
|
|
28
|
+
if (resizeMode === 'stretchy-fit') {
|
|
29
|
+
if (isImageLandscapier) {
|
|
30
|
+
return {
|
|
31
|
+
width: '100%',
|
|
32
|
+
maxHeight: '100%'
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
35
|
+
return {
|
|
36
|
+
height: '100%',
|
|
37
|
+
maxWidth: '100%'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (resizeMode === 'crop') {
|
|
42
|
+
if (isImageLandscapier) {
|
|
43
|
+
return {
|
|
44
|
+
height: imgHeight,
|
|
45
|
+
maxHeight: '100%'
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
return {
|
|
49
|
+
width: imgWidth,
|
|
50
|
+
maxWidth: '100%'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {};
|
|
16
55
|
};
|
|
@@ -5,7 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.SvgViewBase = exports.SvgView = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = require("@emotion/react");
|
|
11
12
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
@@ -24,25 +25,11 @@ var _errors = require("../../errors");
|
|
|
24
25
|
var _errors2 = require("./errors");
|
|
25
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
26
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
29
|
-
|
|
30
|
-
var convertResizeMode = exports.convertResizeMode = function convertResizeMode(resizeMode) {
|
|
31
|
-
switch (resizeMode) {
|
|
32
|
-
case 'crop':
|
|
33
|
-
return 'cover';
|
|
34
|
-
case 'fit':
|
|
35
|
-
case 'full-fit':
|
|
36
|
-
return 'scale-down';
|
|
37
|
-
case 'stretchy-fit':
|
|
38
|
-
return 'contain';
|
|
39
|
-
default:
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
28
|
+
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; }
|
|
29
|
+
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) { (0, _defineProperty2.default)(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; } /** @jsx jsx */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
43
30
|
var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
44
31
|
var identifier = _ref.identifier,
|
|
45
|
-
|
|
32
|
+
cardDimensions = _ref.cardDimensions,
|
|
46
33
|
onClick = _ref.onClick,
|
|
47
34
|
onMouseEnter = _ref.onMouseEnter,
|
|
48
35
|
testId = _ref.testId,
|
|
@@ -71,10 +58,17 @@ var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
|
71
58
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
72
59
|
svgDimensions = _useState6[0],
|
|
73
60
|
setSvgDimensions = _useState6[1];
|
|
74
|
-
var
|
|
75
|
-
var
|
|
61
|
+
var imgRef = (0, _react2.useRef)(null);
|
|
62
|
+
var wrapperRef = (0, _react2.useRef)(null);
|
|
63
|
+
var breakpoint = (0, _useBreakpoint.useBreakpoint)(cardDimensions.width, wrapperRef);
|
|
64
|
+
var calculateDimensions = (0, _react2.useCallback)(function (targetImgElem) {
|
|
65
|
+
if (!wrapperRef.current || !targetImgElem) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setSvgDimensions((0, _helpers.calculateSvgDimensions)(targetImgElem, wrapperRef.current, resizeMode));
|
|
69
|
+
}, [resizeMode]);
|
|
76
70
|
var onSvgLoad = function onSvgLoad(evt) {
|
|
77
|
-
|
|
71
|
+
calculateDimensions(evt.currentTarget);
|
|
78
72
|
setDidSvgRender(true);
|
|
79
73
|
onLoad();
|
|
80
74
|
};
|
|
@@ -85,16 +79,21 @@ var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
|
85
79
|
var onPreviewLoad = function onPreviewLoad() {
|
|
86
80
|
setDidPreviewRender(true);
|
|
87
81
|
};
|
|
82
|
+
(0, _react2.useEffect)(function () {
|
|
83
|
+
if (imgRef.current) {
|
|
84
|
+
calculateDimensions(imgRef.current);
|
|
85
|
+
}
|
|
86
|
+
}, [imgRef, calculateDimensions]);
|
|
88
87
|
return (0, _react.jsx)(_react2.default.Fragment, null, shouldOpenMediaViewer && (0, _react.jsx)(_openMediaViewerButton.default, {
|
|
89
88
|
fileName: fileName !== null && fileName !== void 0 ? fileName : '',
|
|
90
89
|
innerRef: openMediaViewerButtonRef,
|
|
91
90
|
onClick: onClick
|
|
92
91
|
}), (0, _react.jsx)(_wrapper.Wrapper, {
|
|
93
92
|
testId: testId || 'media-card-svg-wrapper',
|
|
94
|
-
dimensions:
|
|
93
|
+
dimensions: cardDimensions,
|
|
95
94
|
onClick: onClick,
|
|
96
95
|
onMouseEnter: onMouseEnter,
|
|
97
|
-
innerRef:
|
|
96
|
+
innerRef: wrapperRef,
|
|
98
97
|
mediaCardCursor: mediaCardCursor,
|
|
99
98
|
selected: !!selected,
|
|
100
99
|
breakpoint: breakpoint,
|
|
@@ -114,13 +113,12 @@ var SvgViewBase = exports.SvgViewBase = function SvgViewBase(_ref) {
|
|
|
114
113
|
}, (0, _react.jsx)(_mediaSvg.default, {
|
|
115
114
|
testId: "media-card-svg",
|
|
116
115
|
identifier: identifier,
|
|
117
|
-
dimensions: svgDimensions,
|
|
118
116
|
onLoad: onSvgLoad,
|
|
119
117
|
onError: onSvgError,
|
|
120
|
-
style: {
|
|
121
|
-
visibility: didSvgRender ? 'visible' : 'hidden'
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
style: _objectSpread({
|
|
119
|
+
visibility: didSvgRender ? 'visible' : 'hidden'
|
|
120
|
+
}, svgDimensions),
|
|
121
|
+
ref: imgRef
|
|
124
122
|
}), !!cardPreview && !didSvgRender && (0, _react.jsx)(_imageRenderer.ImageRenderer, {
|
|
125
123
|
cardPreview: cardPreview,
|
|
126
124
|
onImageLoad: onPreviewLoad,
|
|
@@ -11,7 +11,7 @@ var _styles = require("../../styles");
|
|
|
11
11
|
var _constants = require("@atlaskit/theme/constants");
|
|
12
12
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
13
|
|
|
14
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
14
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
15
15
|
var wrapperStyles = exports.wrapperStyles = (0, _react.css)({
|
|
16
16
|
boxSizing: 'border-box',
|
|
17
17
|
fontFamily: (0, _constants.fontFamily)(),
|
|
@@ -14,7 +14,7 @@ var discSize = 48;
|
|
|
14
14
|
var discSizeHover = 56;
|
|
15
15
|
var fixedPlayButtonStyles = exports.fixedPlayButtonStyles = "\n .".concat(bkgClassName, " {\n width: ").concat(discSizeHover, "px;\n height: ").concat(discSizeHover, "px;\n }\n");
|
|
16
16
|
|
|
17
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
18
18
|
var playButtonWrapperStyles = exports.playButtonWrapperStyles = (0, _react.css)({
|
|
19
19
|
position: 'absolute',
|
|
20
20
|
top: 0,
|
|
@@ -31,7 +31,7 @@ var playButtonWrapperStyles = exports.playButtonWrapperStyles = (0, _react.css)(
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
34
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
35
35
|
var backgroundStyles = exports.backgroundStyles = (0, _react.css)({
|
|
36
36
|
transitionProperty: 'width, height',
|
|
37
37
|
transitionDuration: '0.1s',
|
|
@@ -65,14 +65,14 @@ var titleBoxFooterStyles = exports.titleBoxFooterStyles = function titleBoxFoote
|
|
|
65
65
|
};
|
|
66
66
|
titleBoxFooterStyles.displayName = 'TitleBoxFooter';
|
|
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
|
var titleBoxIconStyles = exports.titleBoxIconStyles = (0, _react.css)({
|
|
70
70
|
position: 'absolute',
|
|
71
71
|
right: "var(--ds-space-050, 4px)",
|
|
72
72
|
bottom: '0px'
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles
|
|
75
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
76
76
|
var errorMessageWrapperStyles = exports.errorMessageWrapperStyles = (0, _react.css)({
|
|
77
77
|
display: 'flex',
|
|
78
78
|
alignItems: 'center',
|
|
@@ -119,7 +119,7 @@ var MediaInlineCardLoader = exports.default = /*#__PURE__*/function (_React$Pure
|
|
|
119
119
|
ErrorBoundary = _this$state.ErrorBoundary;
|
|
120
120
|
var analyticsContext = {
|
|
121
121
|
packageVersion: "@atlaskit/media-card",
|
|
122
|
-
packageName: "78.0.
|
|
122
|
+
packageName: "78.0.3",
|
|
123
123
|
componentName: 'mediaInlineCard',
|
|
124
124
|
component: 'mediaInlineCard'
|
|
125
125
|
};
|
|
@@ -7,7 +7,7 @@ exports.errorIconWrapperStyles = void 0;
|
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
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
|
var errorIconWrapperStyles = exports.errorIconWrapperStyles = (0, _react.css)({
|
|
12
12
|
display: 'flex',
|
|
13
13
|
color: "var(--ds-icon-warning, #ff991f)"
|
|
@@ -15,7 +15,7 @@ var _mediaClient = require("@atlaskit/media-client");
|
|
|
15
15
|
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; }
|
|
16
16
|
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) { (0, _defineProperty2.default)(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; }
|
|
17
17
|
var packageName = "@atlaskit/media-card";
|
|
18
|
-
var packageVersion = "78.0.
|
|
18
|
+
var packageVersion = "78.0.3";
|
|
19
19
|
var concurrentExperience;
|
|
20
20
|
var getExperience = function getExperience(id) {
|
|
21
21
|
if (!concurrentExperience) {
|
package/dist/es2019/card/card.js
CHANGED
|
@@ -7,7 +7,7 @@ import { IntlProvider, injectIntl } from 'react-intl-next';
|
|
|
7
7
|
import { ExternalImageCard } from './externalImageCard';
|
|
8
8
|
import { FileCard } from './fileCard';
|
|
9
9
|
const packageName = "@atlaskit/media-card";
|
|
10
|
-
const packageVersion = "78.0.
|
|
10
|
+
const packageVersion = "78.0.3";
|
|
11
11
|
export const CardBase = ({
|
|
12
12
|
identifier,
|
|
13
13
|
...otherProps
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
3
3
|
import { globalMediaEventEmitter, RECENTS_COLLECTION, imageResizeModeToFileImageMode, isProcessedFileState } from '@atlaskit/media-client';
|
|
4
4
|
import { MediaFileStateError, useFileState, useMediaClient } from '@atlaskit/media-client-react';
|
|
@@ -27,7 +27,7 @@ import { performanceNow } from './performance';
|
|
|
27
27
|
import { useContext } from 'react';
|
|
28
28
|
import { DateOverrideContext } from '../dateOverrideContext';
|
|
29
29
|
import { SvgView } from './svgView';
|
|
30
|
-
const LoadedCardView =
|
|
30
|
+
const LoadedCardView = fg('platform.media-experience.card-views-refactor_b91lr') ? CardViews : CardView;
|
|
31
31
|
export const FileCard = ({
|
|
32
32
|
appearance = 'auto',
|
|
33
33
|
resizeMode = 'crop',
|
|
@@ -277,7 +277,7 @@ export const FileCard = ({
|
|
|
277
277
|
setShouldRenderSVG(false);
|
|
278
278
|
};
|
|
279
279
|
const onImageError = newCardPreview => {
|
|
280
|
-
if (
|
|
280
|
+
if (metadata.mimeType === 'image/svg+xml' && fg('platform.media-card-svg-rendering_6tdbv')) {
|
|
281
281
|
return;
|
|
282
282
|
}
|
|
283
283
|
onImageErrorBase(newCardPreview);
|
|
@@ -286,7 +286,7 @@ export const FileCard = ({
|
|
|
286
286
|
setPreviewDidRender(true);
|
|
287
287
|
};
|
|
288
288
|
const onImageLoad = newCardPreview => {
|
|
289
|
-
if (
|
|
289
|
+
if (metadata.mimeType === 'image/svg+xml' && fg('platform.media-card-svg-rendering_6tdbv')) {
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
292
|
onImageLoadBase(newCardPreview);
|
|
@@ -414,14 +414,15 @@ export const FileCard = ({
|
|
|
414
414
|
//----------------------------------------------------------------//
|
|
415
415
|
|
|
416
416
|
useEffect(() => {
|
|
417
|
-
if (
|
|
417
|
+
if (finalStatus !== 'error' &&
|
|
418
418
|
/**
|
|
419
419
|
* We need to check that the card is visible before switching to SVG
|
|
420
420
|
* in order to avoid race conditions of the ViewportDector being unmounted before
|
|
421
421
|
* it is able to set isCardVisible to true.
|
|
422
422
|
*/
|
|
423
|
-
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay
|
|
424
|
-
|
|
423
|
+
isCardVisible && metadata.mimeType === 'image/svg+xml' && disableOverlay &&
|
|
424
|
+
// SVG won't be supported when overlay is on
|
|
425
|
+
fg('platform.media-card-svg-rendering_6tdbv')) {
|
|
425
426
|
setShouldRenderSVG(true);
|
|
426
427
|
}
|
|
427
428
|
}, [isCardVisible, disableOverlay, metadata.mimeType, finalStatus]);
|
|
@@ -604,7 +605,7 @@ export const FileCard = ({
|
|
|
604
605
|
cardPreview: preview,
|
|
605
606
|
alt: alt,
|
|
606
607
|
resizeMode: resizeMode,
|
|
607
|
-
|
|
608
|
+
cardDimensions: cardDimensions,
|
|
608
609
|
selected: selected,
|
|
609
610
|
onClick: onCardViewClick,
|
|
610
611
|
onMouseEnter: onImageMouseEnter,
|
|
@@ -66,7 +66,7 @@ class WrappedMediaCardAnalyticsErrorBoundary extends React.Component {
|
|
|
66
66
|
}
|
|
67
67
|
_defineProperty(WrappedMediaCardAnalyticsErrorBoundary, "displayName", 'MediaCardAnalyticsErrorBoundary');
|
|
68
68
|
const packageName = "@atlaskit/media-card";
|
|
69
|
-
const packageVersion = "78.0.
|
|
69
|
+
const packageVersion = "78.0.3";
|
|
70
70
|
const MediaCardAnalyticsErrorBoundary = withMediaAnalyticsContext({
|
|
71
71
|
packageVersion,
|
|
72
72
|
packageName,
|
|
@@ -1,12 +1,52 @@
|
|
|
1
|
-
export const calculateSvgDimensions = (
|
|
1
|
+
export const calculateSvgDimensions = (imgElement, parentElement, resizeMode) => {
|
|
2
2
|
const {
|
|
3
3
|
naturalWidth,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
width,
|
|
5
|
+
naturalHeight,
|
|
6
|
+
height
|
|
7
|
+
} = imgElement;
|
|
8
|
+
// Firefox & Safari can't always read the "natural" dimensions correctly.
|
|
9
|
+
// When these are undefined or zero, we replace them with the rendered values
|
|
10
|
+
const imgWidth = naturalWidth || width;
|
|
11
|
+
const imgHeight = naturalHeight || height;
|
|
12
|
+
const {
|
|
13
|
+
width: parentWidth,
|
|
14
|
+
height: parentHeight
|
|
15
|
+
} = parentElement.getBoundingClientRect();
|
|
16
|
+
if (resizeMode === 'fit' || resizeMode === 'full-fit') {
|
|
17
|
+
return {
|
|
18
|
+
maxWidth: `min(100%, ${imgWidth}px`,
|
|
19
|
+
maxHeight: `min(100%, ${imgHeight}px`
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const imgRatio = imgWidth / imgHeight;
|
|
23
|
+
const cardRatio = parentWidth / parentHeight;
|
|
24
|
+
const isImageLandscapier = imgRatio > cardRatio;
|
|
25
|
+
if (resizeMode === 'stretchy-fit') {
|
|
26
|
+
if (isImageLandscapier) {
|
|
27
|
+
return {
|
|
28
|
+
width: '100%',
|
|
29
|
+
maxHeight: '100%'
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
return {
|
|
33
|
+
height: '100%',
|
|
34
|
+
maxWidth: '100%'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (resizeMode === 'crop') {
|
|
39
|
+
if (isImageLandscapier) {
|
|
40
|
+
return {
|
|
41
|
+
height: imgHeight,
|
|
42
|
+
maxHeight: '100%'
|
|
43
|
+
};
|
|
44
|
+
} else {
|
|
45
|
+
return {
|
|
46
|
+
width: imgWidth,
|
|
47
|
+
maxWidth: '100%'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {};
|
|
12
52
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import React, { useState, useRef } from 'react';
|
|
4
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
5
5
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
6
|
import { createAndFireMediaCardEvent } from '../../utils/analytics';
|
|
7
7
|
import { ImageRenderer } from '../ui/imageRenderer/imageRenderer';
|
|
@@ -15,22 +15,9 @@ import { calculateSvgDimensions } from './helpers';
|
|
|
15
15
|
import OpenMediaViewerButton from '../ui/openMediaViewerButton/openMediaViewerButton';
|
|
16
16
|
import { MediaCardError } from '../../errors';
|
|
17
17
|
import { getErrorReason } from './errors';
|
|
18
|
-
export const convertResizeMode = resizeMode => {
|
|
19
|
-
switch (resizeMode) {
|
|
20
|
-
case 'crop':
|
|
21
|
-
return 'cover';
|
|
22
|
-
case 'fit':
|
|
23
|
-
case 'full-fit':
|
|
24
|
-
return 'scale-down';
|
|
25
|
-
case 'stretchy-fit':
|
|
26
|
-
return 'contain';
|
|
27
|
-
default:
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
18
|
export const SvgViewBase = ({
|
|
32
19
|
identifier,
|
|
33
|
-
|
|
20
|
+
cardDimensions,
|
|
34
21
|
onClick,
|
|
35
22
|
onMouseEnter,
|
|
36
23
|
testId,
|
|
@@ -50,10 +37,17 @@ export const SvgViewBase = ({
|
|
|
50
37
|
const [didSvgRender, setDidSvgRender] = useState(false);
|
|
51
38
|
const [didPreviewRender, setDidPreviewRender] = useState(false);
|
|
52
39
|
const [svgDimensions, setSvgDimensions] = useState();
|
|
53
|
-
const
|
|
54
|
-
const
|
|
40
|
+
const imgRef = useRef(null);
|
|
41
|
+
const wrapperRef = useRef(null);
|
|
42
|
+
const breakpoint = useBreakpoint(cardDimensions.width, wrapperRef);
|
|
43
|
+
const calculateDimensions = useCallback(targetImgElem => {
|
|
44
|
+
if (!wrapperRef.current || !targetImgElem) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setSvgDimensions(calculateSvgDimensions(targetImgElem, wrapperRef.current, resizeMode));
|
|
48
|
+
}, [resizeMode]);
|
|
55
49
|
const onSvgLoad = evt => {
|
|
56
|
-
|
|
50
|
+
calculateDimensions(evt.currentTarget);
|
|
57
51
|
setDidSvgRender(true);
|
|
58
52
|
onLoad();
|
|
59
53
|
};
|
|
@@ -64,16 +58,21 @@ export const SvgViewBase = ({
|
|
|
64
58
|
const onPreviewLoad = () => {
|
|
65
59
|
setDidPreviewRender(true);
|
|
66
60
|
};
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (imgRef.current) {
|
|
63
|
+
calculateDimensions(imgRef.current);
|
|
64
|
+
}
|
|
65
|
+
}, [imgRef, calculateDimensions]);
|
|
67
66
|
return jsx(React.Fragment, null, shouldOpenMediaViewer && jsx(OpenMediaViewerButton, {
|
|
68
67
|
fileName: fileName !== null && fileName !== void 0 ? fileName : '',
|
|
69
68
|
innerRef: openMediaViewerButtonRef,
|
|
70
69
|
onClick: onClick
|
|
71
70
|
}), jsx(Wrapper, {
|
|
72
71
|
testId: testId || 'media-card-svg-wrapper',
|
|
73
|
-
dimensions:
|
|
72
|
+
dimensions: cardDimensions,
|
|
74
73
|
onClick: onClick,
|
|
75
74
|
onMouseEnter: onMouseEnter,
|
|
76
|
-
innerRef:
|
|
75
|
+
innerRef: wrapperRef,
|
|
77
76
|
mediaCardCursor: mediaCardCursor,
|
|
78
77
|
selected: !!selected,
|
|
79
78
|
breakpoint: breakpoint,
|
|
@@ -93,13 +92,14 @@ export const SvgViewBase = ({
|
|
|
93
92
|
}, jsx(MediaSvg, {
|
|
94
93
|
testId: "media-card-svg",
|
|
95
94
|
identifier: identifier,
|
|
96
|
-
dimensions: svgDimensions,
|
|
97
95
|
onLoad: onSvgLoad,
|
|
98
96
|
onError: onSvgError,
|
|
99
97
|
style: {
|
|
100
98
|
visibility: didSvgRender ? 'visible' : 'hidden',
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
100
|
+
...svgDimensions
|
|
101
|
+
},
|
|
102
|
+
ref: imgRef
|
|
103
103
|
}), !!cardPreview && !didSvgRender && jsx(ImageRenderer, {
|
|
104
104
|
cardPreview: cardPreview,
|
|
105
105
|
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 const wrapperStyles = css({
|
|
10
10
|
boxSizing: 'border-box',
|
|
11
11
|
fontFamily: fontFamily(),
|
|
@@ -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)"
|