@atlaskit/media-card 72.1.0 → 73.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/dist/cjs/actions.js +2 -2
- package/dist/cjs/errors.js +11 -7
- package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
- package/dist/cjs/files/cardImageView/index.js +52 -42
- package/dist/cjs/files/cardImageView/styled.js +1 -1
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/root/card/cardAnalytics.js +2 -2
- package/dist/cjs/root/card/cardState.js +2 -2
- package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
- package/dist/cjs/root/card/getCardPreview/index.js +18 -9
- package/dist/cjs/root/card/getCardStatus.js +1 -1
- package/dist/cjs/root/card/index.js +279 -159
- package/dist/cjs/root/cardView.js +130 -118
- package/dist/cjs/root/inline/loader.js +45 -14
- package/dist/cjs/root/inline/mediaInlineCard.js +24 -9
- package/dist/cjs/root/inlinePlayer.js +80 -25
- package/dist/cjs/root/styled.js +7 -3
- package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
- package/dist/cjs/root/ui/blanket/styled.js +1 -1
- package/dist/cjs/root/ui/common.js +1 -1
- package/dist/cjs/root/ui/iconMessage/index.js +5 -3
- package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +4 -2
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
- package/dist/cjs/root/ui/playButton/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +5 -2
- package/dist/cjs/root/ui/progressBar/styled.js +7 -6
- package/dist/cjs/root/ui/styled.js +6 -6
- package/dist/cjs/root/ui/tickBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
- package/dist/cjs/root/ui/titleBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
- package/dist/cjs/styles/index.js +25 -23
- package/dist/cjs/styles/mixins.js +1 -1
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/utils/analytics.js +24 -7
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +3 -1
- package/dist/cjs/utils/cardActions/index.js +10 -10
- package/dist/cjs/utils/cardActions/styled.js +1 -1
- package/dist/cjs/utils/cardDimensions.js +1 -1
- package/dist/cjs/utils/dimensionComparer.js +7 -13
- package/dist/cjs/utils/getErrorMessage.js +2 -2
- package/dist/cjs/utils/getMediaCardCursor.js +29 -0
- package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
- package/dist/cjs/utils/globalScope/globalScope.js +94 -0
- package/dist/cjs/utils/globalScope/index.js +39 -0
- package/dist/cjs/utils/globalScope/types.js +5 -0
- package/dist/cjs/utils/index.js +46 -46
- package/dist/cjs/utils/lightCards/styled.js +1 -1
- package/dist/cjs/utils/objectURLCache.js +1 -1
- package/dist/cjs/utils/printScript.js +44 -0
- package/dist/cjs/utils/viewportDetector.js +49 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/files/cardImageView/index.js +19 -5
- package/dist/es2019/root/card/cardAnalytics.js +1 -1
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/es2019/root/card/getCardPreview/index.js +1 -0
- package/dist/es2019/root/card/index.js +150 -49
- package/dist/es2019/root/cardView.js +40 -30
- package/dist/es2019/root/inline/loader.js +15 -4
- package/dist/es2019/root/inline/mediaInlineCard.js +23 -8
- package/dist/es2019/root/inlinePlayer.js +59 -5
- package/dist/es2019/root/styled.js +2 -1
- package/dist/es2019/root/ui/iconMessage/index.js +3 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +4 -2
- package/dist/es2019/root/ui/progressBar/styled.js +6 -4
- package/dist/es2019/root/ui/styled.js +5 -5
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
- package/dist/es2019/types.js +7 -1
- package/dist/es2019/utils/analytics.js +8 -3
- package/dist/es2019/utils/dimensionComparer.js +6 -13
- package/dist/es2019/utils/getErrorMessage.js +1 -1
- package/dist/es2019/utils/getMediaCardCursor.js +19 -0
- package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
- package/dist/es2019/utils/globalScope/globalScope.js +62 -0
- package/dist/es2019/utils/globalScope/index.js +2 -0
- package/dist/es2019/utils/globalScope/types.js +1 -0
- package/dist/es2019/utils/printScript.js +19 -0
- package/dist/es2019/utils/viewportDetector.js +48 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +6 -5
- package/dist/esm/files/cardImageView/index.js +53 -41
- package/dist/esm/root/card/cardAnalytics.js +1 -1
- package/dist/esm/root/card/cardState.js +2 -2
- package/dist/esm/root/card/getCardPreview/cache.js +3 -2
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/esm/root/card/getCardPreview/index.js +5 -2
- package/dist/esm/root/card/index.js +266 -145
- package/dist/esm/root/cardView.js +128 -117
- package/dist/esm/root/inline/loader.js +46 -14
- package/dist/esm/root/inline/mediaInlineCard.js +23 -8
- package/dist/esm/root/inlinePlayer.js +77 -24
- package/dist/esm/root/styled.js +3 -2
- package/dist/esm/root/ui/iconMessage/index.js +3 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +5 -2
- package/dist/esm/root/ui/progressBar/styled.js +6 -5
- package/dist/esm/root/ui/styled.js +5 -5
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
- package/dist/esm/types.js +7 -1
- package/dist/esm/utils/analytics.js +17 -6
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +2 -1
- package/dist/esm/utils/dimensionComparer.js +8 -13
- package/dist/esm/utils/getErrorMessage.js +1 -1
- package/dist/esm/utils/getMediaCardCursor.js +19 -0
- package/dist/esm/utils/globalScope/getSSRData.js +10 -0
- package/dist/esm/utils/globalScope/globalScope.js +69 -0
- package/dist/esm/utils/globalScope/index.js +2 -0
- package/dist/esm/utils/globalScope/types.js +1 -0
- package/dist/esm/utils/printScript.js +30 -0
- package/dist/esm/utils/viewportDetector.js +48 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/files/cardImageView/index.d.ts +6 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/root/card/cardLoader.d.ts +2 -2
- package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +10 -9
- package/dist/types/root/cardView.d.ts +10 -8
- package/dist/types/root/inline/loader.d.ts +2 -0
- package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
- package/dist/types/root/inlinePlayer.d.ts +10 -1
- package/dist/types/root/styled.d.ts +1 -0
- package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +4 -4
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -0
- package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
- package/dist/types/root/ui/progressBar/progressBar.d.ts +3 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +2 -1
- package/dist/types/root/ui/styled.d.ts +2 -1
- package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -2
- package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -9
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/analytics.d.ts +6 -0
- package/dist/types/utils/getErrorMessage.d.ts +1 -0
- package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
- package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
- package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
- package/dist/types/utils/globalScope/index.d.ts +4 -0
- package/dist/types/utils/globalScope/types.d.ts +8 -0
- package/dist/types/utils/printScript.d.ts +2 -0
- package/dist/types/utils/viewportDetector.d.ts +13 -5
- package/package.json +14 -16
- package/dist/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
package/dist/es2019/types.js
CHANGED
|
@@ -81,6 +81,13 @@ export const getRenderErrorRequestMetadata = error => {
|
|
|
81
81
|
return error.secondaryError.metadata;
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
+
export const extractErrorInfo = error => {
|
|
85
|
+
return {
|
|
86
|
+
failReason: getRenderErrorFailReason(error),
|
|
87
|
+
error: getRenderErrorErrorReason(error),
|
|
88
|
+
errorDetail: getRenderErrorErrorDetail(error)
|
|
89
|
+
};
|
|
90
|
+
};
|
|
84
91
|
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
|
|
85
92
|
eventType: 'operational',
|
|
86
93
|
action: 'failed',
|
|
@@ -89,9 +96,7 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
|
|
|
89
96
|
fileAttributes,
|
|
90
97
|
performanceAttributes,
|
|
91
98
|
status: 'fail',
|
|
92
|
-
|
|
93
|
-
error: getRenderErrorErrorReason(error),
|
|
94
|
-
errorDetail: getRenderErrorErrorDetail(error),
|
|
99
|
+
...extractErrorInfo(error),
|
|
95
100
|
request: getRenderErrorRequestMetadata(error)
|
|
96
101
|
}
|
|
97
102
|
});
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { isValidPercentageUnit } from './isValidPercentageUnit';
|
|
2
2
|
import { containsPixelUnit } from './containsPixelUnit';
|
|
3
|
+
|
|
4
|
+
const isPixelEquivalent = dimension => typeof dimension === 'number' || containsPixelUnit(`${dimension}`);
|
|
5
|
+
|
|
3
6
|
export const canCompareDimension = (current, next) => {
|
|
4
7
|
if (!current || !next) {
|
|
5
8
|
return false;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (containsPixelUnit(`${current}`) && containsPixelUnit(`${next}`)) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof current === 'number' && typeof next === 'number') {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return false;
|
|
11
|
+
const bothPixelEquivalent = isPixelEquivalent(current) && isPixelEquivalent(next);
|
|
12
|
+
const bothPercentage = isValidPercentageUnit(current) && isValidPercentageUnit(next);
|
|
13
|
+
return bothPixelEquivalent || bothPercentage;
|
|
21
14
|
};
|
|
22
15
|
export const isBigger = (current, next) => {
|
|
23
16
|
if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
2
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
3
3
|
import { messages } from '@atlaskit/media-ui';
|
|
4
4
|
export const getErrorMessage = status => status === 'error' && /*#__PURE__*/React.createElement(FormattedMessage, messages.failed_to_load);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MediaCardCursor } from '../types';
|
|
2
|
+
export const getMediaCardCursor = (useInlinePlayer, useMediaViewer, isErrorStatus, hasCardPreview, mediaType) => {
|
|
3
|
+
// If error status or no action is requested = NoAction
|
|
4
|
+
if (isErrorStatus || !useInlinePlayer && !useMediaViewer) {
|
|
5
|
+
return MediaCardCursor.NoAction;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!mediaType && (useInlinePlayer || useInlinePlayer && useMediaViewer)) {
|
|
9
|
+
return MediaCardCursor.NotReady;
|
|
10
|
+
} else if (mediaType === 'video' && hasCardPreview && useInlinePlayer) {
|
|
11
|
+
return MediaCardCursor.Action;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (useMediaViewer) {
|
|
15
|
+
return MediaCardCursor.Action;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return MediaCardCursor.NoAction;
|
|
19
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { printFunctionCall, printScript } from '../printScript';
|
|
3
|
+
// ----- WARNING -----
|
|
4
|
+
// This is a very sensitive fraction of code.
|
|
5
|
+
// Any changes to this file must be tested directly in product before merging.
|
|
6
|
+
// The scripts printed here might differ from what we observe in our internal tests
|
|
7
|
+
// due to minimification, for example.
|
|
8
|
+
export const GLOBAL_MEDIA_CARD_SSR = 'mediaCardSsr';
|
|
9
|
+
export const GLOBAL_MEDIA_NAMESPACE = '__MEDIA_INTERNAL';
|
|
10
|
+
export function getMediaGlobalScope(globalScope = window) {
|
|
11
|
+
// Must match GLOBAL_MEDIA_NAMESPACE. Can't reference the constant from here.
|
|
12
|
+
const namespace = '__MEDIA_INTERNAL';
|
|
13
|
+
|
|
14
|
+
if (!globalScope[namespace]) {
|
|
15
|
+
globalScope[namespace] = {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return globalScope[namespace];
|
|
19
|
+
}
|
|
20
|
+
export function getMediaCardSSR(globalScope = window) {
|
|
21
|
+
const globalMedia = getMediaGlobalScope(globalScope); // Must match GLOBAL_MEDIA_CARD_SSR. Can't reference the constant from here.
|
|
22
|
+
|
|
23
|
+
const key = 'mediaCardSsr';
|
|
24
|
+
|
|
25
|
+
if (!globalMedia[key]) {
|
|
26
|
+
globalMedia[key] = {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return globalMedia[key];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const dashed = param => param ? `-${param}` : '';
|
|
33
|
+
|
|
34
|
+
export const getKey = ({
|
|
35
|
+
id,
|
|
36
|
+
collectionName,
|
|
37
|
+
occurrenceKey
|
|
38
|
+
}) => `${id}${dashed(collectionName)}${dashed(occurrenceKey)}`;
|
|
39
|
+
export const storeDataURI = (key, dataURI, dimensions, error, globalScope = window) => {
|
|
40
|
+
const mediaCardSsr = getMediaCardSSR(globalScope);
|
|
41
|
+
mediaCardSsr[key] = {
|
|
42
|
+
dataURI,
|
|
43
|
+
dimensions,
|
|
44
|
+
error
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const generateScript = (identifier, dataURI, dimensions, error) => {
|
|
49
|
+
const functionCall = printFunctionCall(storeDataURI, getKey(identifier), dataURI, dimensions, error);
|
|
50
|
+
return printScript([getMediaCardSSR.toString(), getMediaGlobalScope.toString(), functionCall]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const StoreSSRDataScript = ({
|
|
54
|
+
dataURI,
|
|
55
|
+
identifier,
|
|
56
|
+
dimensions,
|
|
57
|
+
error
|
|
58
|
+
}) => /*#__PURE__*/React.createElement("script", {
|
|
59
|
+
dangerouslySetInnerHTML: {
|
|
60
|
+
__html: generateScript(identifier, dataURI, dimensions, error)
|
|
61
|
+
}
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const printParam = param => {
|
|
2
|
+
if (typeof param === 'string') {
|
|
3
|
+
return `'${param}'`;
|
|
4
|
+
} else if (typeof param === 'object') {
|
|
5
|
+
return JSON.stringify(param);
|
|
6
|
+
} else if (param === undefined) {
|
|
7
|
+
return 'undefined';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return param;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const printParams = args => args.map(arg => printParam(arg)).join(',');
|
|
14
|
+
|
|
15
|
+
export const printFunctionCall = (fn, ...args) => `(${fn.toString()})(${printParams(args)});`;
|
|
16
|
+
export const printScript = statements => `(function(){
|
|
17
|
+
${statements.join(';')}
|
|
18
|
+
})();
|
|
19
|
+
`;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
|
|
1
|
+
import React, { useEffect, forwardRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* As IntersectionObserver::rootMargin doesn't work within IFrames, we use an empty div + dynamic offsetTop to eagerly detect cards entering viewport.
|
|
4
|
+
* Using this approach, we can lazy load cards ABS_VIEWPORT_ANCHOR_OFFSET_TOP px before they enter viewport.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const ABS_VIEWPORT_ANCHOR_OFFSET_TOP = 900; //px
|
|
8
|
+
|
|
9
|
+
export const ViewportAnchor = /*#__PURE__*/forwardRef((props, ref) => {
|
|
10
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
ref: ref,
|
|
16
|
+
className: "media-card-viewport-anchor",
|
|
17
|
+
style: {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
top: `${props.offsetTop}px`
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
3
23
|
|
|
4
24
|
const createIntersectionObserverCallback = onVisible => (entries, observer) => {
|
|
5
25
|
for (let entry of entries) {
|
|
@@ -11,31 +31,41 @@ const createIntersectionObserverCallback = onVisible => (entries, observer) => {
|
|
|
11
31
|
}
|
|
12
32
|
};
|
|
13
33
|
|
|
14
|
-
const
|
|
34
|
+
const ViewportObserver = ({
|
|
15
35
|
onVisible,
|
|
36
|
+
cardEl,
|
|
16
37
|
children,
|
|
17
|
-
|
|
38
|
+
preAnchorRef,
|
|
39
|
+
postAnchorRef
|
|
18
40
|
}) => {
|
|
19
41
|
useEffect(() => {
|
|
20
42
|
// IntersectionObserver uses root and target elements to detect intersections, defaulting root to the viewport
|
|
21
43
|
const intersectionObserver = new IntersectionObserver(createIntersectionObserverCallback(onVisible));
|
|
22
|
-
|
|
44
|
+
(preAnchorRef === null || preAnchorRef === void 0 ? void 0 : preAnchorRef.current) && intersectionObserver.observe(preAnchorRef.current);
|
|
45
|
+
(postAnchorRef === null || postAnchorRef === void 0 ? void 0 : postAnchorRef.current) && intersectionObserver.observe(postAnchorRef.current);
|
|
46
|
+
cardEl && intersectionObserver.observe(cardEl);
|
|
23
47
|
return () => {
|
|
24
48
|
intersectionObserver.disconnect();
|
|
25
49
|
};
|
|
26
|
-
}, [
|
|
50
|
+
}, [cardEl, preAnchorRef, postAnchorRef, onVisible]);
|
|
27
51
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
28
52
|
};
|
|
29
53
|
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
export const ViewportDetector = ({
|
|
55
|
+
cardEl,
|
|
56
|
+
preAnchorRef,
|
|
57
|
+
postAnchorRef,
|
|
58
|
+
onVisible,
|
|
59
|
+
children
|
|
60
|
+
}) => {
|
|
61
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
62
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return /*#__PURE__*/React.createElement(ViewportObserver, {
|
|
66
|
+
cardEl: cardEl,
|
|
67
|
+
preAnchorRef: preAnchorRef,
|
|
68
|
+
postAnchorRef: postAnchorRef,
|
|
69
|
+
onVisible: onVisible
|
|
70
|
+
}, children);
|
|
71
|
+
};
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/actions.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
export function attachDetailsToActions(actions, details) {
|
|
8
8
|
return actions.map(function (action) {
|
package/dist/esm/errors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
@@ -32,7 +33,7 @@ export var MediaCardError = /*#__PURE__*/function (_Error) {
|
|
|
32
33
|
return _this;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
return MediaCardError;
|
|
36
|
+
return _createClass(MediaCardError);
|
|
36
37
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
37
38
|
export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
|
|
38
39
|
_inherits(LocalPreviewError, _MediaCardError);
|
|
@@ -50,7 +51,7 @@ export var LocalPreviewError = /*#__PURE__*/function (_MediaCardError) {
|
|
|
50
51
|
return _this2;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
return LocalPreviewError;
|
|
54
|
+
return _createClass(LocalPreviewError);
|
|
54
55
|
}(MediaCardError);
|
|
55
56
|
export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
|
|
56
57
|
_inherits(RemotePreviewError, _MediaCardError2);
|
|
@@ -68,7 +69,7 @@ export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
|
|
|
68
69
|
return _this3;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
return RemotePreviewError;
|
|
72
|
+
return _createClass(RemotePreviewError);
|
|
72
73
|
}(MediaCardError);
|
|
73
74
|
export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
|
|
74
75
|
_inherits(SsrPreviewError, _MediaCardError3);
|
|
@@ -86,7 +87,7 @@ export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
|
|
|
86
87
|
return _this4;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
return SsrPreviewError;
|
|
90
|
+
return _createClass(SsrPreviewError);
|
|
90
91
|
}(MediaCardError);
|
|
91
92
|
export var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
|
|
92
93
|
switch (source) {
|
|
@@ -121,7 +122,7 @@ export var ImageLoadError = /*#__PURE__*/function (_MediaCardError4) {
|
|
|
121
122
|
return _super5.call(this, getImageLoadPrimaryReason(source));
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
return ImageLoadError;
|
|
125
|
+
return _createClass(ImageLoadError);
|
|
125
126
|
}(MediaCardError);
|
|
126
127
|
export function isMediaCardError(err) {
|
|
127
128
|
return err instanceof MediaCardError;
|
|
@@ -156,18 +156,30 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
|
|
|
156
156
|
})));
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
159
|
+
_defineProperty(_assertThisInitialized(_this), "onImageLoad", function () {
|
|
160
160
|
var _this$props6 = _this.props,
|
|
161
|
-
status = _this$props6.status,
|
|
162
|
-
mediaItemType = _this$props6.mediaItemType,
|
|
163
|
-
dataURI = _this$props6.dataURI,
|
|
164
|
-
mediaType = _this$props6.mediaType,
|
|
165
|
-
mimeType = _this$props6.mimeType,
|
|
166
|
-
previewOrientation = _this$props6.previewOrientation,
|
|
167
|
-
onDisplayImage = _this$props6.onDisplayImage,
|
|
168
|
-
alt = _this$props6.alt,
|
|
169
161
|
onImageLoad = _this$props6.onImageLoad,
|
|
170
|
-
|
|
162
|
+
cardPreview = _this$props6.cardPreview;
|
|
163
|
+
onImageLoad && onImageLoad(cardPreview);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
_defineProperty(_assertThisInitialized(_this), "onImageError", function () {
|
|
167
|
+
var _this$props7 = _this.props,
|
|
168
|
+
onImageError = _this$props7.onImageError,
|
|
169
|
+
cardPreview = _this$props7.cardPreview;
|
|
170
|
+
onImageError && onImageError(cardPreview);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
_defineProperty(_assertThisInitialized(_this), "renderMediaImage", function () {
|
|
174
|
+
var _this$props8 = _this.props,
|
|
175
|
+
status = _this$props8.status,
|
|
176
|
+
mediaItemType = _this$props8.mediaItemType,
|
|
177
|
+
dataURI = _this$props8.dataURI,
|
|
178
|
+
mediaType = _this$props8.mediaType,
|
|
179
|
+
mimeType = _this$props8.mimeType,
|
|
180
|
+
previewOrientation = _this$props8.previewOrientation,
|
|
181
|
+
onDisplayImage = _this$props8.onDisplayImage,
|
|
182
|
+
alt = _this$props8.alt;
|
|
171
183
|
|
|
172
184
|
if (!shouldDisplayImageThumbnail(status, mediaItemType, dataURI, mediaType, mimeType)) {
|
|
173
185
|
return null;
|
|
@@ -184,17 +196,17 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
|
|
|
184
196
|
crop: _this.isCropped,
|
|
185
197
|
stretch: _this.isStretched,
|
|
186
198
|
previewOrientation: previewOrientation,
|
|
187
|
-
onImageLoad: onImageLoad,
|
|
188
|
-
onImageError: onImageError
|
|
199
|
+
onImageLoad: _this.onImageLoad,
|
|
200
|
+
onImageError: _this.onImageError
|
|
189
201
|
});
|
|
190
202
|
});
|
|
191
203
|
|
|
192
204
|
_defineProperty(_assertThisInitialized(_this), "renderProgressBar", function () {
|
|
193
|
-
var _this$
|
|
194
|
-
mediaName = _this$
|
|
195
|
-
progress = _this$
|
|
196
|
-
actions = _this$
|
|
197
|
-
status = _this$
|
|
205
|
+
var _this$props9 = _this.props,
|
|
206
|
+
mediaName = _this$props9.mediaName,
|
|
207
|
+
progress = _this$props9.progress,
|
|
208
|
+
actions = _this$props9.actions,
|
|
209
|
+
status = _this$props9.status;
|
|
198
210
|
|
|
199
211
|
if (status !== 'uploading') {
|
|
200
212
|
return null;
|
|
@@ -213,10 +225,10 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
|
|
|
213
225
|
});
|
|
214
226
|
|
|
215
227
|
_defineProperty(_assertThisInitialized(_this), "renderSuccessCardContents", function () {
|
|
216
|
-
var _this$
|
|
217
|
-
disableOverlay = _this$
|
|
218
|
-
selectable = _this$
|
|
219
|
-
status = _this$
|
|
228
|
+
var _this$props10 = _this.props,
|
|
229
|
+
disableOverlay = _this$props10.disableOverlay,
|
|
230
|
+
selectable = _this$props10.selectable,
|
|
231
|
+
status = _this$props10.status;
|
|
220
232
|
var overlay = null;
|
|
221
233
|
|
|
222
234
|
if (!disableOverlay) {
|
|
@@ -237,15 +249,15 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
|
|
|
237
249
|
});
|
|
238
250
|
|
|
239
251
|
_defineProperty(_assertThisInitialized(_this), "renderSuccessCardOverlay", function () {
|
|
240
|
-
var _this$
|
|
241
|
-
status = _this$
|
|
242
|
-
mediaName = _this$
|
|
243
|
-
mediaType = _this$
|
|
244
|
-
fileSize = _this$
|
|
245
|
-
dataURI = _this$
|
|
246
|
-
selectable = _this$
|
|
247
|
-
selected = _this$
|
|
248
|
-
actions = _this$
|
|
252
|
+
var _this$props11 = _this.props,
|
|
253
|
+
status = _this$props11.status,
|
|
254
|
+
mediaName = _this$props11.mediaName,
|
|
255
|
+
mediaType = _this$props11.mediaType,
|
|
256
|
+
fileSize = _this$props11.fileSize,
|
|
257
|
+
dataURI = _this$props11.dataURI,
|
|
258
|
+
selectable = _this$props11.selectable,
|
|
259
|
+
selected = _this$props11.selected,
|
|
260
|
+
actions = _this$props11.actions;
|
|
249
261
|
var isPersistent = mediaType === 'doc' || !dataURI;
|
|
250
262
|
return /*#__PURE__*/React.createElement(CardOverlay, {
|
|
251
263
|
cardStatus: status,
|
|
@@ -265,14 +277,14 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
|
|
|
265
277
|
_createClass(FileCardImageView, [{
|
|
266
278
|
key: "render",
|
|
267
279
|
value: function render() {
|
|
268
|
-
var _this$
|
|
269
|
-
disableOverlay = _this$
|
|
270
|
-
selectable = _this$
|
|
271
|
-
selected = _this$
|
|
272
|
-
mediaType = _this$
|
|
273
|
-
progress = _this$
|
|
274
|
-
status = _this$
|
|
275
|
-
mediaName = _this$
|
|
280
|
+
var _this$props12 = this.props,
|
|
281
|
+
disableOverlay = _this$props12.disableOverlay,
|
|
282
|
+
selectable = _this$props12.selectable,
|
|
283
|
+
selected = _this$props12.selected,
|
|
284
|
+
mediaType = _this$props12.mediaType,
|
|
285
|
+
progress = _this$props12.progress,
|
|
286
|
+
status = _this$props12.status,
|
|
287
|
+
mediaName = _this$props12.mediaName;
|
|
276
288
|
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
277
289
|
"data-testid": "media-file-card-view",
|
|
278
290
|
"data-test-media-name": mediaName,
|
|
@@ -289,9 +301,9 @@ export var FileCardImageView = /*#__PURE__*/function (_Component) {
|
|
|
289
301
|
}, {
|
|
290
302
|
key: "isFileCardImageReadyForDisplay",
|
|
291
303
|
get: function get() {
|
|
292
|
-
var _this$
|
|
293
|
-
dataURI = _this$
|
|
294
|
-
status = _this$
|
|
304
|
+
var _this$props13 = this.props,
|
|
305
|
+
dataURI = _this$props13.dataURI,
|
|
306
|
+
status = _this$props13.status;
|
|
295
307
|
return !!dataURI || !['loading', 'processing', 'loading-preview'].includes(status);
|
|
296
308
|
}
|
|
297
309
|
}, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fireMediaCardEvent, getRenderSucceededEventPayload, getRenderErrorEventPayload, getRenderFailedFileStatusPayload, getCopiedFilePayload, getRenderCommencedEventPayload, getRenderPreviewableCardPayload } from '../../utils/analytics';
|
|
2
|
-
export var relevantFeatureFlagNames = ['newCardExperience', 'captions'];
|
|
2
|
+
export var relevantFeatureFlagNames = ['newCardExperience', 'captions', 'timestampOnVideo'];
|
|
3
3
|
export var fireOperationalEvent = function fireOperationalEvent(createAnalyticsEvent, status, fileAttributes, performanceAttributes, error) {
|
|
4
4
|
var fireEvent = function fireEvent(payload) {
|
|
5
5
|
return fireMediaCardEvent(payload, createAnalyticsEvent);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { isErrorFileState } from '@atlaskit/media-client';
|
|
8
8
|
import { MediaCardError } from '../../errors';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
import { createObjectURLCache } from '../../../utils/objectURLCache';
|
|
@@ -6,7 +7,7 @@ import { createObjectURLCache } from '../../../utils/objectURLCache';
|
|
|
6
7
|
export var getCacheKey = function getCacheKey(id, dimensions) {
|
|
7
8
|
return [id, dimensions.height, dimensions.width].join('-');
|
|
8
9
|
};
|
|
9
|
-
export var CardPreviewCacheImpl = function CardPreviewCacheImpl(previewCache) {
|
|
10
|
+
export var CardPreviewCacheImpl = /*#__PURE__*/_createClass(function CardPreviewCacheImpl(previewCache) {
|
|
10
11
|
var _this = this;
|
|
11
12
|
|
|
12
13
|
_classCallCheck(this, CardPreviewCacheImpl);
|
|
@@ -29,5 +30,5 @@ export var CardPreviewCacheImpl = function CardPreviewCacheImpl(previewCache) {
|
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
this.previewCache = previewCache;
|
|
32
|
-
};
|
|
33
|
+
});
|
|
33
34
|
export default new CardPreviewCacheImpl(createObjectURLCache());
|
|
@@ -31,5 +31,8 @@ export var isPreviewableStatus = function isPreviewableStatus(cardStatus, _ref3)
|
|
|
31
31
|
var isPreviewable = _ref3.isPreviewable,
|
|
32
32
|
hasPreview = _ref3.hasPreview,
|
|
33
33
|
isSupportedByBrowser = _ref3.isSupportedByBrowser;
|
|
34
|
-
return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' ||
|
|
34
|
+
return hasPreview && isPreviewable && (cardStatus === 'complete' || cardStatus === 'loading-preview' || cardStatus === 'uploading' || // For Video, we can have local or remote preview while processing.
|
|
35
|
+
// Then, we only want to show the thumbnail if the file is supported by the browser,
|
|
36
|
+
// this way we prevent playing unsupported videos that are not procesed
|
|
37
|
+
cardStatus === 'processing' && isSupportedByBrowser);
|
|
35
38
|
};
|
|
@@ -2,9 +2,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
9
|
import { isPreviewableFileState, addFileAttrsToUrl } from '@atlaskit/media-client';
|
|
10
10
|
import { isMimeTypeSupportedByBrowser } from '@atlaskit/media-common';
|
|
@@ -208,6 +208,9 @@ export var isSSRClientPreview = function isSSRClientPreview(preview) {
|
|
|
208
208
|
var ssrClientSources = ['ssr-client', 'cache-ssr-client'];
|
|
209
209
|
return ssrClientSources.includes(preview.source);
|
|
210
210
|
};
|
|
211
|
+
export var isSSRDataPreview = function isSSRDataPreview(preview) {
|
|
212
|
+
return preview.source === 'ssr-data';
|
|
213
|
+
};
|
|
211
214
|
export var fetchAndCacheRemotePreview = /*#__PURE__*/function () {
|
|
212
215
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(mediaClient, id, dimensions, params, mediaBlobUrlAttrs) {
|
|
213
216
|
var remotePreview;
|