@atlaskit/media-card 70.11.0 → 73.0.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 +104 -0
- package/dist/cjs/errors.js +78 -5
- package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
- package/dist/cjs/files/cardImageView/index.js +53 -104
- package/dist/cjs/files/cardImageView/styled.js +1 -1
- package/dist/cjs/files/index.js +0 -6
- package/dist/cjs/index.js +12 -6
- package/dist/cjs/root/card/cardAnalytics.js +11 -17
- package/dist/cjs/root/card/cardLoader.js +66 -124
- package/dist/cjs/root/card/cardState.js +50 -0
- package/dist/cjs/root/card/getCardPreview/cache.js +6 -1
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +53 -0
- package/dist/cjs/root/card/getCardPreview/helpers.js +14 -22
- package/dist/cjs/root/card/getCardPreview/index.js +176 -102
- package/dist/cjs/root/card/getCardStatus.js +7 -1
- package/dist/cjs/root/card/index.js +361 -281
- package/dist/cjs/root/cardView.js +109 -86
- package/dist/cjs/root/index.js +9 -1
- package/dist/cjs/root/inline/loader.js +22 -21
- package/dist/cjs/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +84 -26
- package/dist/cjs/root/inlinePlayer.js +4 -3
- 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 +11 -5
- package/dist/cjs/root/ui/iconMessage/index.js +16 -7
- package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +34 -124
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/cjs/root/ui/playButton/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +2 -2
- package/dist/cjs/root/ui/progressBar/styled.js +2 -4
- package/dist/cjs/root/ui/styled.js +80 -17
- package/dist/cjs/root/ui/tickBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +9 -3
- package/dist/cjs/root/ui/titleBox/styled.js +2 -4
- 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/utils/analytics.js +21 -43
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +16 -9
- 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 +1 -1
- package/dist/cjs/utils/getErrorMessage.js +2 -2
- package/dist/cjs/utils/index.js +46 -46
- package/dist/cjs/utils/lightCards/styled.js +1 -1
- package/dist/cjs/utils/metadata.js +11 -3
- package/dist/cjs/utils/objectURLCache.js +7 -1
- package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/cjs/utils/viewportDetector.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +42 -2
- package/dist/es2019/files/cardImageView/index.js +8 -61
- package/dist/es2019/files/index.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/root/card/cardAnalytics.js +7 -15
- package/dist/es2019/root/card/cardLoader.js +47 -53
- package/dist/es2019/root/card/cardState.js +26 -0
- package/dist/es2019/root/card/getCardPreview/cache.js +5 -0
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +38 -0
- package/dist/es2019/root/card/getCardPreview/helpers.js +2 -12
- package/dist/es2019/root/card/getCardPreview/index.js +112 -79
- package/dist/es2019/root/card/getCardStatus.js +1 -0
- package/dist/es2019/root/card/index.js +285 -190
- package/dist/es2019/root/cardView.js +93 -68
- package/dist/es2019/root/index.js +2 -1
- package/dist/es2019/root/inline/loader.js +16 -15
- package/dist/es2019/root/inline/mediaInlineCard.js +143 -0
- package/dist/es2019/root/inlinePlayer.js +3 -2
- package/dist/es2019/root/styled.js +2 -1
- package/dist/es2019/root/ui/common.js +7 -1
- package/dist/es2019/root/ui/iconMessage/index.js +8 -5
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +25 -88
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/es2019/root/ui/progressBar/progressBar.js +1 -1
- package/dist/es2019/root/ui/progressBar/styled.js +1 -2
- package/dist/es2019/root/ui/styled.js +64 -3
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +6 -3
- package/dist/es2019/root/ui/titleBox/styled.js +1 -2
- package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
- package/dist/es2019/utils/analytics.js +15 -34
- package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
- package/dist/es2019/utils/dimensionComparer.js +1 -1
- package/dist/es2019/utils/getErrorMessage.js +1 -1
- package/dist/es2019/utils/metadata.js +12 -4
- package/dist/es2019/utils/objectURLCache.js +5 -0
- package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +60 -1
- package/dist/esm/files/cardImageView/index.js +51 -102
- package/dist/esm/files/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/root/card/cardAnalytics.js +7 -16
- package/dist/esm/root/card/cardLoader.js +66 -126
- package/dist/esm/root/card/cardState.js +32 -0
- package/dist/esm/root/card/getCardPreview/cache.js +6 -0
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +38 -0
- package/dist/esm/root/card/getCardPreview/helpers.js +13 -21
- package/dist/esm/root/card/getCardPreview/index.js +142 -95
- package/dist/esm/root/card/getCardStatus.js +3 -0
- package/dist/esm/root/card/index.js +370 -284
- package/dist/esm/root/cardView.js +109 -84
- package/dist/esm/root/index.js +2 -1
- package/dist/esm/root/inline/loader.js +23 -22
- package/dist/esm/root/inline/mediaInlineCard.js +156 -0
- package/dist/esm/root/inlinePlayer.js +3 -2
- package/dist/esm/root/styled.js +3 -2
- package/dist/esm/root/ui/common.js +7 -1
- package/dist/esm/root/ui/iconMessage/index.js +10 -5
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +27 -118
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/esm/root/ui/progressBar/progressBar.js +1 -1
- package/dist/esm/root/ui/progressBar/styled.js +1 -2
- package/dist/esm/root/ui/styled.js +61 -13
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +7 -3
- package/dist/esm/root/ui/titleBox/styled.js +1 -2
- package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
- package/dist/esm/utils/analytics.js +16 -35
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +16 -9
- package/dist/esm/utils/dimensionComparer.js +1 -1
- package/dist/esm/utils/getErrorMessage.js +1 -1
- package/dist/esm/utils/metadata.js +12 -4
- package/dist/esm/utils/objectURLCache.js +6 -0
- package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +15 -1
- package/dist/types/files/cardImageView/index.d.ts +4 -13
- package/dist/types/files/cardImageView/styled.d.ts +1 -1
- package/dist/types/files/index.d.ts +1 -1
- package/dist/types/index.d.ts +7 -5
- package/dist/types/root/card/cardAnalytics.d.ts +2 -6
- package/dist/types/root/card/cardLoader.d.ts +5 -19
- package/dist/types/root/card/cardState.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/cache.d.ts +3 -1
- package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
- package/dist/types/root/card/getCardPreview/helpers.d.ts +3 -4
- package/dist/types/root/card/getCardPreview/index.d.ts +24 -14
- package/dist/types/root/card/getCardStatus.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +19 -18
- package/dist/types/root/cardView.d.ts +13 -8
- package/dist/types/root/index.d.ts +1 -0
- package/dist/types/root/inline/loader.d.ts +8 -8
- package/dist/types/root/inline/{inlineMediaCard.d.ts → mediaInlineCard.d.ts} +4 -6
- package/dist/types/root/inlinePlayer.d.ts +1 -1
- package/dist/types/root/styled.d.ts +1 -0
- package/dist/types/root/ui/common.d.ts +4 -1
- package/dist/types/root/ui/iconMessage/index.d.ts +4 -3
- package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -15
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
- package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
- package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
- package/dist/types/root/ui/progressBar/progressBar.d.ts +2 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +1 -1
- package/dist/types/root/ui/styled.d.ts +10 -3
- package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -1
- package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
- package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
- package/dist/types/styles/mixins.d.ts +1 -1
- package/dist/types/types.d.ts +7 -1
- package/dist/types/utils/analytics.d.ts +14 -15
- package/dist/types/utils/cardDimensions.d.ts +4 -4
- package/dist/types/utils/dimensionComparer.d.ts +1 -1
- package/dist/types/utils/getErrorMessage.d.ts +1 -0
- package/dist/types/utils/metadata.d.ts +2 -2
- package/dist/types/utils/objectURLCache.d.ts +2 -1
- package/example-helpers/developmentUseMessage.tsx +14 -0
- package/example-helpers/index.tsx +55 -4
- package/example-helpers/selectableCard.tsx +2 -1
- package/package.json +20 -16
- package/dist/cjs/root/card/cardSSRView.js +0 -99
- package/dist/cjs/root/card/getCardPreview/types.js +0 -5
- package/dist/cjs/root/ui/Breakpoint.js +0 -13
- package/dist/cjs/root/ui/styledSSR.js +0 -108
- package/dist/cjs/utils/fileAttributesContext.js +0 -40
- package/dist/es2019/root/card/cardSSRView.js +0 -79
- package/dist/es2019/root/card/getCardPreview/types.js +0 -1
- package/dist/es2019/root/inline/inlineMediaCard.js +0 -92
- package/dist/es2019/root/ui/Breakpoint.js +0 -6
- package/dist/es2019/root/ui/styledSSR.js +0 -93
- package/dist/es2019/utils/fileAttributesContext.js +0 -19
- package/dist/esm/root/card/cardSSRView.js +0 -78
- package/dist/esm/root/card/getCardPreview/types.js +0 -1
- package/dist/esm/root/inline/inlineMediaCard.js +0 -100
- package/dist/esm/root/ui/Breakpoint.js +0 -6
- package/dist/esm/root/ui/styledSSR.js +0 -76
- package/dist/esm/utils/fileAttributesContext.js +0 -18
- package/dist/types/root/card/cardSSRView.d.ts +0 -12
- package/dist/types/root/card/getCardPreview/types.d.ts +0 -5
- package/dist/types/root/ui/Breakpoint.d.ts +0 -4
- package/dist/types/root/ui/styledSSR.d.ts +0 -16
- package/dist/types/utils/fileAttributesContext.d.ts +0 -10
|
@@ -1,95 +1,32 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import
|
|
3
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
4
3
|
import { MediaImage } from '@atlaskit/media-ui';
|
|
5
|
-
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
|
-
import { fireMediaCardEvent, RenderEventAction, getRenderSucceededEventPayload, getRenderFailedFileUriPayload, getRenderFailedExternalUriPayload } from '../../../utils/analytics';
|
|
7
|
-
import { withFileAttributes } from '../../../utils/fileAttributesContext';
|
|
8
4
|
import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const durationSinceCommenced = timeElapsedTillCommenced && timeElapsedTillSucceeded - timeElapsedTillCommenced;
|
|
23
|
-
const performanceAttributes = {
|
|
24
|
-
overall: {
|
|
25
|
-
durationSincePageStart: timeElapsedTillSucceeded,
|
|
26
|
-
durationSinceCommenced
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
fireMediaCardEvent(getRenderSucceededEventPayload(fileAttributes, performanceAttributes), createAnalyticsEvent);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "onImageError", () => {
|
|
34
|
-
const {
|
|
35
|
-
onImageError,
|
|
36
|
-
fileAttributes
|
|
37
|
-
} = this.props;
|
|
38
|
-
onImageError && onImageError();
|
|
39
|
-
|
|
40
|
-
if (fileAttributes && this.shouldFireEvent(RenderEventAction.FAILED)) {
|
|
41
|
-
const {
|
|
42
|
-
createAnalyticsEvent,
|
|
43
|
-
mediaItemType,
|
|
44
|
-
timeElapsedTillCommenced
|
|
45
|
-
} = this.props;
|
|
46
|
-
const timeElapsedTillFailed = performance.now();
|
|
47
|
-
const durationSinceCommenced = timeElapsedTillCommenced && timeElapsedTillFailed - timeElapsedTillCommenced;
|
|
48
|
-
const performanceAttributes = {
|
|
49
|
-
overall: {
|
|
50
|
-
durationSincePageStart: timeElapsedTillFailed,
|
|
51
|
-
durationSinceCommenced
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
if (mediaItemType === 'file') {
|
|
56
|
-
fireMediaCardEvent(getRenderFailedFileUriPayload(fileAttributes, performanceAttributes), createAnalyticsEvent);
|
|
57
|
-
} else if (mediaItemType === 'external-image') {
|
|
58
|
-
fireMediaCardEvent(getRenderFailedExternalUriPayload(fileAttributes, performanceAttributes), createAnalyticsEvent);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
_defineProperty(this, "shouldFireEvent", action => !this.lastAnalyticsAction || this.lastAnalyticsAction !== action);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
componentDidMount() {
|
|
5
|
+
export const ImageRenderer = ({
|
|
6
|
+
dataURI,
|
|
7
|
+
previewOrientation,
|
|
8
|
+
alt,
|
|
9
|
+
resizeMode,
|
|
10
|
+
onImageLoad,
|
|
11
|
+
onImageError,
|
|
12
|
+
onDisplayImage,
|
|
13
|
+
mediaType,
|
|
14
|
+
nativeLazyLoad,
|
|
15
|
+
forceSyncDisplay
|
|
16
|
+
}) => {
|
|
17
|
+
useEffect(() => {
|
|
67
18
|
// TODO: trigger accordingly with the succeeded event. This could be a breaking change
|
|
68
|
-
const {
|
|
69
|
-
onDisplayImage,
|
|
70
|
-
mediaType
|
|
71
|
-
} = this.props;
|
|
72
|
-
|
|
73
19
|
if (mediaType === 'image' && onDisplayImage) {
|
|
74
20
|
onDisplayImage();
|
|
75
21
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
alt: alt,
|
|
88
|
-
previewOrientation: previewOrientation,
|
|
89
|
-
onImageLoad: this.onImageLoad,
|
|
90
|
-
onImageError: this.onImageError
|
|
91
|
-
}, resizeModeToMediaImageProps(resizeMode)));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
export const ImageRenderer = withAnalyticsEvents()(withFileAttributes(ImageRendererBase));
|
|
22
|
+
}, [mediaType, onDisplayImage]);
|
|
23
|
+
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
24
|
+
dataURI: dataURI,
|
|
25
|
+
alt: alt,
|
|
26
|
+
previewOrientation: previewOrientation,
|
|
27
|
+
onImageLoad: onImageLoad,
|
|
28
|
+
onImageError: onImageError,
|
|
29
|
+
loading: nativeLazyLoad ? 'lazy' : undefined,
|
|
30
|
+
forceSyncDisplay: forceSyncDisplay
|
|
31
|
+
}, resizeModeToMediaImageProps(resizeMode)));
|
|
32
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { errorIcon } from '@atlaskit/media-ui/errorIcon';
|
|
3
3
|
import { WarningIconWrapper, LoadingRateLimitedContainer, CouldntLoadWrapper, ErrorWrapper, LoadingRateLimitedTextWrapper } from './styled';
|
|
4
|
+
import { FormattedMessageWrapper } from '../../styled';
|
|
4
5
|
import { messages } from '@atlaskit/media-ui';
|
|
5
|
-
import { FormattedMessage } from 'react-intl';
|
|
6
|
-
import { Breakpoint } from '../
|
|
6
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
7
|
+
import { Breakpoint } from '../common';
|
|
7
8
|
export const LoadingRateLimited = ({
|
|
8
9
|
breakpoint = Breakpoint.SMALL,
|
|
9
10
|
positionBottom = true
|
|
@@ -11,5 +12,5 @@ export const LoadingRateLimited = ({
|
|
|
11
12
|
return /*#__PURE__*/React.createElement(LoadingRateLimitedContainer, null, /*#__PURE__*/React.createElement(WarningIconWrapper, null, errorIcon), /*#__PURE__*/React.createElement(LoadingRateLimitedTextWrapper, {
|
|
12
13
|
breakpoint: breakpoint,
|
|
13
14
|
positionBottom: positionBottom
|
|
14
|
-
}, /*#__PURE__*/React.createElement(CouldntLoadWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.couldnt_load_file)), /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.error_429))));
|
|
15
|
+
}, /*#__PURE__*/React.createElement(CouldntLoadWrapper, null, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.couldnt_load_file))), /*#__PURE__*/React.createElement(ErrorWrapper, null, /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages.error_429)))));
|
|
15
16
|
};
|
|
@@ -2,8 +2,7 @@ import styled from 'styled-components';
|
|
|
2
2
|
import { borderRadius } from '@atlaskit/media-ui';
|
|
3
3
|
import { rgba } from '../../../styles/mixins';
|
|
4
4
|
import { N0, N400 } from '@atlaskit/theme/colors';
|
|
5
|
-
import { getTitleBoxHeight, responsiveSettings } from '../common';
|
|
6
|
-
import { Breakpoint } from '../Breakpoint';
|
|
5
|
+
import { Breakpoint, getTitleBoxHeight, responsiveSettings } from '../common';
|
|
7
6
|
const height = 3;
|
|
8
7
|
const padding = 1;
|
|
9
8
|
const width = 95; // %
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { getCSSUnitValue } from '../../utils/getCSSUnitValue';
|
|
3
3
|
import { getDefaultCardDimensions } from '../../utils/cardDimensions';
|
|
4
|
+
import { fontFamily } from '@atlaskit/theme/constants';
|
|
5
|
+
import { borderRadius } from '@atlaskit/media-ui';
|
|
6
|
+
import { N20, N60A } from '@atlaskit/theme/colors';
|
|
7
|
+
import { akEditorSelectedBoxShadow } from '@atlaskit/editor-shared-styles/consts';
|
|
4
8
|
import { hideNativeBrowserTextSelectionStyles } from '@atlaskit/editor-shared-styles/selection';
|
|
9
|
+
import { transition } from '../../styles';
|
|
5
10
|
import { tickBoxClassName, tickboxFixedStyles } from './tickBox/styled';
|
|
11
|
+
import { fixedBlanketStyles, blanketClassName } from './blanket/styled';
|
|
6
12
|
import { fixedActionBarStyles, actionsBarClassName } from './actionsBar/styled';
|
|
7
13
|
import { fixedPlayButtonStyles, playButtonClassName } from './playButton/styled';
|
|
8
|
-
import {
|
|
14
|
+
import { Breakpoint, responsiveSettings } from './common';
|
|
15
|
+
const breakpointSizes = [[Breakpoint.SMALL, 599], [Breakpoint.LARGE, Infinity]];
|
|
16
|
+
export const calcBreakpointSize = (wrapperWidth = 0) => {
|
|
17
|
+
const [breakpoint] = breakpointSizes.find(([_breakpoint, limit]) => wrapperWidth <= limit) || [Breakpoint.SMALL];
|
|
18
|
+
return breakpoint;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const generateResponsiveStyles = (breakpoint = Breakpoint.SMALL) => {
|
|
22
|
+
const setting = responsiveSettings[breakpoint];
|
|
23
|
+
return `
|
|
24
|
+
font-size: ${setting.fontSize}px;
|
|
25
|
+
line-height: ${setting.lineHeight}px;
|
|
26
|
+
`;
|
|
27
|
+
};
|
|
9
28
|
|
|
10
29
|
const getWrapperDimensions = (dimensions, appearance) => {
|
|
11
30
|
const {
|
|
@@ -22,8 +41,19 @@ const getWrapperDimensions = (dimensions, appearance) => {
|
|
|
22
41
|
height: ${getCSSUnitValue(height || defaultHeight)};
|
|
23
42
|
max-height: 100%;
|
|
24
43
|
`;
|
|
44
|
+
}; // This is a trick to simulate the blue border without affecting the dimensions.
|
|
45
|
+
// CSS outline has no 'radius', therefore we can't achieve the same effect with it
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const getWrapperShadow = (disableOverlay, selected) => {
|
|
49
|
+
const withOverlayShadow = !disableOverlay ? `0 1px 1px ${N60A}, 0 0 1px 0 ${N60A}` : '';
|
|
50
|
+
const selectedShadow = selected ? akEditorSelectedBoxShadow : '';
|
|
51
|
+
const shadow = [selectedShadow, withOverlayShadow].filter(Boolean).join(', ');
|
|
52
|
+
return shadow ? `box-shadow: ${shadow};` : '';
|
|
25
53
|
};
|
|
26
54
|
|
|
55
|
+
const getCursorStyle = shouldUsePointerCursor => `cursor: ${shouldUsePointerCursor ? 'pointer' : 'default'};`;
|
|
56
|
+
|
|
27
57
|
const getClickablePlayButtonStyles = isPlayButtonClickable => {
|
|
28
58
|
if (!isPlayButtonClickable) {
|
|
29
59
|
return '';
|
|
@@ -48,19 +78,40 @@ const getSelectableTickBoxStyles = isTickBoxSelectable => {
|
|
|
48
78
|
`;
|
|
49
79
|
};
|
|
50
80
|
|
|
51
|
-
export const NewFileExperienceWrapper = styled
|
|
81
|
+
export const NewFileExperienceWrapper = styled.div`
|
|
52
82
|
${({
|
|
83
|
+
breakpoint,
|
|
53
84
|
dimensions,
|
|
54
85
|
appearance,
|
|
86
|
+
shouldUsePointerCursor,
|
|
87
|
+
disableOverlay,
|
|
88
|
+
displayBackground,
|
|
89
|
+
selected,
|
|
55
90
|
isPlayButtonClickable,
|
|
56
91
|
isTickBoxSelectable,
|
|
57
92
|
shouldDisplayTooltip
|
|
58
93
|
}) => `
|
|
94
|
+
${transition()}
|
|
95
|
+
box-sizing: border-box;
|
|
96
|
+
* {
|
|
97
|
+
box-sizing: border-box;
|
|
98
|
+
}
|
|
99
|
+
position: relative;
|
|
100
|
+
font-family: ${fontFamily()};
|
|
101
|
+
${getWrapperDimensions(dimensions, appearance)}
|
|
102
|
+
${displayBackground ? `background-color: ${N20};` : ''}
|
|
103
|
+
${borderRadius}
|
|
104
|
+
${getCursorStyle(shouldUsePointerCursor)}
|
|
105
|
+
${getWrapperShadow(disableOverlay, selected)}
|
|
106
|
+
${generateResponsiveStyles(breakpoint)}
|
|
59
107
|
${hideNativeBrowserTextSelectionStyles}
|
|
60
108
|
|
|
61
109
|
/* We use classnames from here exceptionally to be able to handle styles when the Card is on hover */
|
|
62
110
|
${getClickablePlayButtonStyles(isPlayButtonClickable)}
|
|
63
111
|
${getSelectableTickBoxStyles(isTickBoxSelectable)}
|
|
112
|
+
&:hover .${blanketClassName} {
|
|
113
|
+
${fixedBlanketStyles}
|
|
114
|
+
}
|
|
64
115
|
|
|
65
116
|
&:hover .${actionsBarClassName} {
|
|
66
117
|
${fixedActionBarStyles}
|
|
@@ -70,4 +121,14 @@ export const NewFileExperienceWrapper = styled(SSRFileExperienceWrapper)`
|
|
|
70
121
|
${shouldDisplayTooltip ? `> div { ${getWrapperDimensions(dimensions, appearance)} }` : ''}
|
|
71
122
|
`}
|
|
72
123
|
`;
|
|
73
|
-
NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
|
|
124
|
+
NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
|
|
125
|
+
export const CardImageContainer = styled.div`
|
|
126
|
+
display: flex;
|
|
127
|
+
position: relative;
|
|
128
|
+
max-width: 100%;
|
|
129
|
+
width: 100%;
|
|
130
|
+
height: 100%;
|
|
131
|
+
max-height: 100%;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
${borderRadius}
|
|
134
|
+
`;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TitleBoxWrapper, ErrorMessageWrapper } from './styled';
|
|
3
3
|
import EditorWarningIcon from '@atlaskit/icon/glyph/editor/warning';
|
|
4
|
+
import { messages } from '@atlaskit/media-ui';
|
|
4
5
|
import { R300 } from '@atlaskit/theme/colors';
|
|
5
|
-
import {
|
|
6
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
7
|
+
import { FormattedMessageWrapper } from '../../styled';
|
|
6
8
|
export const FailedTitleBox = ({
|
|
7
|
-
breakpoint
|
|
9
|
+
breakpoint,
|
|
10
|
+
customMessage = messages.failed_to_load
|
|
8
11
|
}) => {
|
|
9
12
|
return /*#__PURE__*/React.createElement(TitleBoxWrapper, {
|
|
10
13
|
breakpoint: breakpoint
|
|
@@ -12,5 +15,5 @@ export const FailedTitleBox = ({
|
|
|
12
15
|
label: 'Warning',
|
|
13
16
|
size: 'small',
|
|
14
17
|
primaryColor: R300
|
|
15
|
-
}),
|
|
18
|
+
}), /*#__PURE__*/React.createElement(FormattedMessageWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, customMessage))));
|
|
16
19
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import { responsiveSettings, getTitleBoxHeight } from '../common';
|
|
3
|
-
import { Breakpoint } from '../Breakpoint';
|
|
2
|
+
import { responsiveSettings, getTitleBoxHeight, Breakpoint } from '../common';
|
|
4
3
|
import { N0 } from '@atlaskit/theme/colors';
|
|
5
4
|
import { rgba } from '../../../styles/mixins';
|
|
6
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LockFilledIcon from '@atlaskit/icon/glyph/lock-filled';
|
|
3
|
-
import { injectIntl } from 'react-intl';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
4
|
import { TitleBoxWrapper, TitleBoxHeader, TitleBoxFooter, TitleBoxIcon } from './styled';
|
|
5
5
|
import { Truncate } from '@atlaskit/media-ui/truncateText';
|
|
6
6
|
import { formatDate } from '@atlaskit/media-ui/formatDate';
|
|
@@ -2,14 +2,6 @@ import { getMediaClientErrorReason, isRequestError } from '@atlaskit/media-clien
|
|
|
2
2
|
import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
|
|
3
3
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
4
4
|
import { isMediaCardError } from '../errors';
|
|
5
|
-
export let RenderEventAction;
|
|
6
|
-
|
|
7
|
-
(function (RenderEventAction) {
|
|
8
|
-
RenderEventAction["COMMENCED"] = "commenced";
|
|
9
|
-
RenderEventAction["SUCCEEDED"] = "succeeded";
|
|
10
|
-
RenderEventAction["FAILED"] = "failed";
|
|
11
|
-
})(RenderEventAction || (RenderEventAction = {}));
|
|
12
|
-
|
|
13
5
|
export const getFileAttributes = (metadata, fileStatus) => ({
|
|
14
6
|
fileMediatype: metadata.mediaType,
|
|
15
7
|
fileMimetype: metadata.mimeType,
|
|
@@ -17,10 +9,20 @@ export const getFileAttributes = (metadata, fileStatus) => ({
|
|
|
17
9
|
fileSize: metadata.size,
|
|
18
10
|
fileStatus
|
|
19
11
|
});
|
|
12
|
+
export const getRenderPreviewableCardPayload = fileAttributes => ({
|
|
13
|
+
eventType: 'screen',
|
|
14
|
+
action: 'viewed',
|
|
15
|
+
actionSubject: 'mediaCardRenderScreen',
|
|
16
|
+
name: 'mediaCardRenderScreen',
|
|
17
|
+
attributes: {
|
|
18
|
+
type: fileAttributes.fileMediatype,
|
|
19
|
+
fileAttributes
|
|
20
|
+
}
|
|
21
|
+
});
|
|
20
22
|
export const getRenderCommencedEventPayload = (fileAttributes, performanceAttributes) => {
|
|
21
23
|
return {
|
|
22
24
|
eventType: 'operational',
|
|
23
|
-
action:
|
|
25
|
+
action: 'commenced',
|
|
24
26
|
actionSubject: 'mediaCardRender',
|
|
25
27
|
attributes: {
|
|
26
28
|
fileAttributes,
|
|
@@ -30,7 +32,7 @@ export const getRenderCommencedEventPayload = (fileAttributes, performanceAttrib
|
|
|
30
32
|
};
|
|
31
33
|
export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes) => ({
|
|
32
34
|
eventType: 'operational',
|
|
33
|
-
action:
|
|
35
|
+
action: 'succeeded',
|
|
34
36
|
actionSubject: 'mediaCardRender',
|
|
35
37
|
attributes: {
|
|
36
38
|
fileAttributes,
|
|
@@ -38,30 +40,9 @@ export const getRenderSucceededEventPayload = (fileAttributes, performanceAttrib
|
|
|
38
40
|
status: 'success'
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
|
-
export const getFailedFileUriFailReason = fileStatus => {
|
|
42
|
-
if (!fileStatus) {
|
|
43
|
-
// This fail reason will come from a bug, most likely.
|
|
44
|
-
return `unknown-uri`;
|
|
45
|
-
} else if (fileStatus === 'uploading') {
|
|
46
|
-
return 'local-uri';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return 'remote-uri';
|
|
50
|
-
};
|
|
51
|
-
export const getRenderFailedFileUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
52
|
-
eventType: 'operational',
|
|
53
|
-
action: RenderEventAction.FAILED,
|
|
54
|
-
actionSubject: 'mediaCardRender',
|
|
55
|
-
attributes: {
|
|
56
|
-
fileAttributes,
|
|
57
|
-
performanceAttributes,
|
|
58
|
-
status: 'fail',
|
|
59
|
-
failReason: getFailedFileUriFailReason(fileAttributes.fileStatus)
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
43
|
export const getRenderFailedExternalUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
63
44
|
eventType: 'operational',
|
|
64
|
-
action:
|
|
45
|
+
action: 'failed',
|
|
65
46
|
actionSubject: 'mediaCardRender',
|
|
66
47
|
attributes: {
|
|
67
48
|
fileAttributes,
|
|
@@ -102,7 +83,7 @@ export const getRenderErrorRequestMetadata = error => {
|
|
|
102
83
|
};
|
|
103
84
|
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
|
|
104
85
|
eventType: 'operational',
|
|
105
|
-
action:
|
|
86
|
+
action: 'failed',
|
|
106
87
|
actionSubject: 'mediaCardRender',
|
|
107
88
|
attributes: {
|
|
108
89
|
fileAttributes,
|
|
@@ -116,7 +97,7 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
|
|
|
116
97
|
});
|
|
117
98
|
export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes) => ({
|
|
118
99
|
eventType: 'operational',
|
|
119
|
-
action:
|
|
100
|
+
action: 'failed',
|
|
120
101
|
actionSubject: 'mediaCardRender',
|
|
121
102
|
attributes: {
|
|
122
103
|
fileAttributes,
|
|
@@ -57,14 +57,18 @@ export class CardActionsDropdownMenu extends Component {
|
|
|
57
57
|
|
|
58
58
|
if (actions.length > 0) {
|
|
59
59
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
60
|
-
|
|
60
|
+
testId: "media-card-actions-menu",
|
|
61
61
|
onOpenChange: onOpenChange,
|
|
62
|
-
trigger:
|
|
62
|
+
trigger: ({
|
|
63
|
+
triggerRef,
|
|
64
|
+
...providedProps
|
|
65
|
+
}) => /*#__PURE__*/React.createElement(CardActionButtonWithAnalytics, _extends({
|
|
63
66
|
variant: triggerVariant,
|
|
64
67
|
style: {
|
|
65
68
|
color: triggerColor
|
|
66
|
-
}
|
|
67
|
-
|
|
69
|
+
},
|
|
70
|
+
ref: triggerRef
|
|
71
|
+
}, providedProps), /*#__PURE__*/React.createElement(MoreIcon, {
|
|
68
72
|
label: "more"
|
|
69
73
|
}))
|
|
70
74
|
}, /*#__PURE__*/React.createElement(DropdownItemGroup, null, actions.map(createDropdownItemWithAnalytics)));
|
|
@@ -20,7 +20,7 @@ export const canCompareDimension = (current, next) => {
|
|
|
20
20
|
return false;
|
|
21
21
|
};
|
|
22
22
|
export const isBigger = (current, next) => {
|
|
23
|
-
if (canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
23
|
+
if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|
|
24
24
|
const nextIsHigher = parseInt(`${current.width}`, 10) < parseInt(`${next.width}`, 10);
|
|
25
25
|
const nextIsWider = parseInt(`${current.height}`, 10) < parseInt(`${next.height}`, 10);
|
|
26
26
|
return nextIsHigher || nextIsWider;
|
|
@@ -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);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isErrorFileState } from '@atlaskit/media-client';
|
|
1
|
+
import { isErrorFileState, isFileIdentifier } from '@atlaskit/media-client';
|
|
2
2
|
|
|
3
3
|
const getProcessingStatusFromFileState = status => {
|
|
4
4
|
switch (status) {
|
|
@@ -13,7 +13,7 @@ const getProcessingStatusFromFileState = status => {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const getFileDetailsFromFileState = state => ({
|
|
17
17
|
id: state.id,
|
|
18
18
|
name: state.name,
|
|
19
19
|
size: state.size,
|
|
@@ -21,6 +21,14 @@ export const getFileDetails = state => !isErrorFileState(state) ? {
|
|
|
21
21
|
createdAt: state.createdAt,
|
|
22
22
|
mediaType: state.mediaType,
|
|
23
23
|
processingStatus: getProcessingStatusFromFileState(state.status)
|
|
24
|
-
}
|
|
25
|
-
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const getFileDetails = (identifier, fileState) => {
|
|
27
|
+
return isFileIdentifier(identifier) ? fileState && !isErrorFileState(fileState) ? getFileDetailsFromFileState(fileState) : {
|
|
28
|
+
id: identifier.id
|
|
29
|
+
} : {
|
|
30
|
+
id: identifier.mediaItemType,
|
|
31
|
+
name: identifier.name || identifier.dataURI,
|
|
32
|
+
mediaType: 'image'
|
|
33
|
+
};
|
|
26
34
|
};
|
|
@@ -42,5 +42,10 @@ export class ObjectURLCache {
|
|
|
42
42
|
this.cache.set(key, value);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
remove(key) {
|
|
46
|
+
const removed = this.cache.remove(key);
|
|
47
|
+
removed && URL.revokeObjectURL(removed.dataURI);
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
}
|
|
46
51
|
export const createObjectURLCache = () => new ObjectURLCache(PREVIEW_CACHE_LRU_SIZE);
|
|
@@ -5,7 +5,7 @@ export const shouldDisplayImageThumbnail = (cardStatus, mediaItemType, dataURI,
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
if (dataURI) {
|
|
8
|
-
return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete';
|
|
8
|
+
return mediaItemType === 'external-image' || mimeType && isMimeTypeSupportedByBrowser(mimeType) || cardStatus === 'complete' || cardStatus === 'loading-preview';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return false;
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/errors.js
CHANGED
|
@@ -70,6 +70,59 @@ export var RemotePreviewError = /*#__PURE__*/function (_MediaCardError2) {
|
|
|
70
70
|
|
|
71
71
|
return RemotePreviewError;
|
|
72
72
|
}(MediaCardError);
|
|
73
|
+
export var SsrPreviewError = /*#__PURE__*/function (_MediaCardError3) {
|
|
74
|
+
_inherits(SsrPreviewError, _MediaCardError3);
|
|
75
|
+
|
|
76
|
+
var _super4 = _createSuper(SsrPreviewError);
|
|
77
|
+
|
|
78
|
+
function SsrPreviewError(primaryReason, secondaryError) {
|
|
79
|
+
var _this4;
|
|
80
|
+
|
|
81
|
+
_classCallCheck(this, SsrPreviewError);
|
|
82
|
+
|
|
83
|
+
_this4 = _super4.call(this, primaryReason, secondaryError);
|
|
84
|
+
_this4.primaryReason = primaryReason;
|
|
85
|
+
_this4.secondaryError = secondaryError;
|
|
86
|
+
return _this4;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return SsrPreviewError;
|
|
90
|
+
}(MediaCardError);
|
|
91
|
+
export var getImageLoadPrimaryReason = function getImageLoadPrimaryReason(source) {
|
|
92
|
+
switch (source) {
|
|
93
|
+
case 'cache-remote':
|
|
94
|
+
return 'cache-remote-uri';
|
|
95
|
+
|
|
96
|
+
case 'cache-local':
|
|
97
|
+
return 'cache-local-uri';
|
|
98
|
+
|
|
99
|
+
case 'external':
|
|
100
|
+
return 'external-uri';
|
|
101
|
+
|
|
102
|
+
case 'local':
|
|
103
|
+
return 'local-uri';
|
|
104
|
+
|
|
105
|
+
case 'remote':
|
|
106
|
+
return 'remote-uri';
|
|
107
|
+
// This fail reason will come from a bug, most likely.
|
|
108
|
+
|
|
109
|
+
default:
|
|
110
|
+
return "unknown-uri";
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
export var ImageLoadError = /*#__PURE__*/function (_MediaCardError4) {
|
|
114
|
+
_inherits(ImageLoadError, _MediaCardError4);
|
|
115
|
+
|
|
116
|
+
var _super5 = _createSuper(ImageLoadError);
|
|
117
|
+
|
|
118
|
+
function ImageLoadError(source) {
|
|
119
|
+
_classCallCheck(this, ImageLoadError);
|
|
120
|
+
|
|
121
|
+
return _super5.call(this, getImageLoadPrimaryReason(source));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return ImageLoadError;
|
|
125
|
+
}(MediaCardError);
|
|
73
126
|
export function isMediaCardError(err) {
|
|
74
127
|
return err instanceof MediaCardError;
|
|
75
128
|
}
|
|
@@ -81,9 +134,15 @@ export var isRemotePreviewError = function isRemotePreviewError(err) {
|
|
|
81
134
|
};
|
|
82
135
|
export var isUnsupportedLocalPreviewError = function isUnsupportedLocalPreviewError(err) {
|
|
83
136
|
return isMediaCardError(err) && err.primaryReason === 'local-preview-unsupported';
|
|
84
|
-
};
|
|
137
|
+
};
|
|
138
|
+
export function isImageLoadError(err) {
|
|
139
|
+
return err instanceof ImageLoadError;
|
|
140
|
+
} // In a try/catch statement, the error caught is the type of any.
|
|
85
141
|
// We can use this helper to ensure that the error handled is the type of MediaCardError if unsure
|
|
86
142
|
|
|
87
143
|
export var ensureMediaCardError = function ensureMediaCardError(primaryReason, error) {
|
|
88
144
|
return isMediaCardError(error) ? error : new MediaCardError(primaryReason, error);
|
|
145
|
+
};
|
|
146
|
+
export var isUploadError = function isUploadError(error) {
|
|
147
|
+
return error && error.primaryReason === 'upload';
|
|
89
148
|
};
|