@atlaskit/media-card 71.0.0 → 73.1.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/actions.js +2 -2
- package/dist/cjs/errors.js +83 -8
- 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 +8 -8
- package/dist/cjs/root/card/cardAnalytics.js +4 -16
- 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 +10 -5
- 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 +177 -97
- package/dist/cjs/root/card/getCardStatus.js +7 -1
- package/dist/cjs/root/card/index.js +384 -285
- package/dist/cjs/root/cardView.js +113 -88
- package/dist/cjs/root/inline/loader.js +47 -15
- package/dist/cjs/root/inline/mediaInlineCard.js +33 -12
- package/dist/cjs/root/inlinePlayer.js +77 -24
- 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 +47 -123
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
- 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 +7 -4
- package/dist/cjs/root/ui/progressBar/styled.js +8 -9
- 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 +7 -44
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +18 -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 +49 -22
- 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/root/card/cardAnalytics.js +3 -14
- 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 -73
- package/dist/es2019/root/card/getCardStatus.js +1 -0
- package/dist/es2019/root/card/index.js +308 -190
- package/dist/es2019/root/cardView.js +97 -68
- package/dist/es2019/root/inline/loader.js +17 -5
- package/dist/es2019/root/inline/mediaInlineCard.js +32 -11
- package/dist/es2019/root/inlinePlayer.js +56 -4
- 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 +35 -88
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +5 -3
- package/dist/es2019/root/ui/progressBar/styled.js +7 -6
- package/dist/es2019/root/ui/styled.js +65 -4
- 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 +5 -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/utils/viewportDetector.js +48 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +64 -4
- package/dist/esm/files/cardImageView/index.js +51 -102
- package/dist/esm/files/index.js +1 -1
- package/dist/esm/root/card/cardAnalytics.js +3 -15
- 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 +9 -2
- 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 +144 -91
- package/dist/esm/root/card/getCardStatus.js +3 -0
- package/dist/esm/root/card/index.js +396 -288
- package/dist/esm/root/cardView.js +113 -86
- package/dist/esm/root/inline/loader.js +48 -15
- package/dist/esm/root/inline/mediaInlineCard.js +32 -11
- package/dist/esm/root/inlinePlayer.js +74 -23
- 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 +37 -116
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +6 -3
- package/dist/esm/root/ui/progressBar/styled.js +7 -7
- 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 +5 -36
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +17 -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/utils/viewportDetector.js +48 -21
- 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 -4
- package/dist/types/root/card/cardAnalytics.d.ts +1 -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 +20 -18
- package/dist/types/root/cardView.d.ts +13 -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 +8 -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 +14 -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 +4 -2
- package/dist/types/root/ui/progressBar/styled.d.ts +3 -2
- 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 +6 -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/dist/types/utils/viewportDetector.d.ts +13 -5
- package/example-helpers/developmentUseMessage.tsx +14 -0
- package/example-helpers/index.tsx +55 -4
- package/example-helpers/selectableCard.tsx +2 -1
- package/package.json +18 -16
- package/dist/cjs/root/card/cardSSRView.js +0 -112
- 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/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/root/card/cardSSRView.js +0 -92
- package/dist/es2019/root/card/getCardPreview/types.js +0 -1
- 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/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/root/card/cardSSRView.js +0 -91
- package/dist/esm/root/card/getCardPreview/types.js +0 -1
- 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/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/root/card/cardSSRView.d.ts +0 -13
- 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
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
|
@@ -1,95 +1,42 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
import styled from 'styled-components';
|
|
6
|
+
export const ImageRendererBase = ({
|
|
7
|
+
dataURI,
|
|
8
|
+
previewOrientation,
|
|
9
|
+
alt,
|
|
10
|
+
resizeMode,
|
|
11
|
+
onImageLoad,
|
|
12
|
+
onImageError,
|
|
13
|
+
onDisplayImage,
|
|
14
|
+
mediaType,
|
|
15
|
+
nativeLazyLoad,
|
|
16
|
+
forceSyncDisplay,
|
|
17
|
+
className = 'media-card-image-renderer'
|
|
18
|
+
}) => {
|
|
19
|
+
useEffect(() => {
|
|
67
20
|
// TODO: trigger accordingly with the succeeded event. This could be a breaking change
|
|
68
|
-
const {
|
|
69
|
-
onDisplayImage,
|
|
70
|
-
mediaType
|
|
71
|
-
} = this.props;
|
|
72
|
-
|
|
73
21
|
if (mediaType === 'image' && onDisplayImage) {
|
|
74
22
|
onDisplayImage();
|
|
75
23
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
export const ImageRenderer = withAnalyticsEvents()(withFileAttributes(ImageRendererBase));
|
|
24
|
+
}, [mediaType, onDisplayImage]);
|
|
25
|
+
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
26
|
+
className: className,
|
|
27
|
+
dataURI: dataURI,
|
|
28
|
+
alt: alt,
|
|
29
|
+
previewOrientation: previewOrientation,
|
|
30
|
+
onImageLoad: onImageLoad,
|
|
31
|
+
onImageError: onImageError,
|
|
32
|
+
loading: nativeLazyLoad ? 'lazy' : undefined,
|
|
33
|
+
forceSyncDisplay: forceSyncDisplay
|
|
34
|
+
}, resizeModeToMediaImageProps(resizeMode)));
|
|
35
|
+
};
|
|
36
|
+
export const ImageRenderer = styled(ImageRendererBase)`
|
|
37
|
+
${({
|
|
38
|
+
isImageVisible
|
|
39
|
+
}) => `
|
|
40
|
+
visibility: ${isImageVisible ? 'visible' : 'hidden'};
|
|
41
|
+
`}
|
|
42
|
+
`;
|
|
@@ -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
|
};
|
|
@@ -31,7 +31,7 @@ export const LoadingRateLimitedTextWrapper = styled.div`
|
|
|
31
31
|
display: block;
|
|
32
32
|
width:100%;
|
|
33
33
|
text-align:center;
|
|
34
|
-
${generateResponsiveStyles(breakpoint, positionBottom, 1)}
|
|
34
|
+
${generateResponsiveStyles(breakpoint, positionBottom, false, 1)}
|
|
35
35
|
`}
|
|
36
36
|
`;
|
|
37
37
|
LoadingRateLimitedTextWrapper.displayName = 'LoadingRateLimitedTextWrapper';
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyledBar } from './styled';
|
|
3
|
-
import { Breakpoint } from '../
|
|
3
|
+
import { Breakpoint } from '../common';
|
|
4
4
|
export const ProgressBar = ({
|
|
5
5
|
progress,
|
|
6
6
|
breakpoint = Breakpoint.SMALL,
|
|
7
|
-
positionBottom = false
|
|
7
|
+
positionBottom = false,
|
|
8
|
+
showOnTop = false
|
|
8
9
|
}) => {
|
|
9
10
|
const normalizedProgress = Math.min(1, Math.max(0, progress || 0)) * 100;
|
|
10
11
|
return /*#__PURE__*/React.createElement(StyledBar, {
|
|
11
12
|
progress: normalizedProgress,
|
|
12
13
|
breakpoint: breakpoint,
|
|
13
|
-
positionBottom: positionBottom
|
|
14
|
+
positionBottom: positionBottom,
|
|
15
|
+
showOnTop: showOnTop
|
|
14
16
|
});
|
|
15
17
|
};
|
|
@@ -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; // %
|
|
@@ -16,19 +15,20 @@ const smallSizeSettings = {
|
|
|
16
15
|
const largeSizeSettings = {
|
|
17
16
|
marginBottom: 12
|
|
18
17
|
};
|
|
19
|
-
export function generateResponsiveStyles(breakpoint, positionBottom, multiplier = 1) {
|
|
18
|
+
export function generateResponsiveStyles(breakpoint, positionBottom, showOnTop, multiplier = 1) {
|
|
20
19
|
const setting = breakpoint === Breakpoint.SMALL ? smallSizeSettings : largeSizeSettings;
|
|
21
20
|
const marginPositionBottom = responsiveSettings[breakpoint].titleBox.verticalPadding;
|
|
22
21
|
const marginBottom = setting.marginBottom * multiplier + (positionBottom ? marginPositionBottom : getTitleBoxHeight(breakpoint));
|
|
23
22
|
return `
|
|
24
|
-
bottom: ${marginBottom}px
|
|
23
|
+
${showOnTop ? 'top' : 'bottom'}: ${marginBottom}px
|
|
25
24
|
`;
|
|
26
25
|
}
|
|
27
26
|
export const StyledBar = styled.div`
|
|
28
27
|
${({
|
|
29
28
|
progress,
|
|
30
29
|
breakpoint,
|
|
31
|
-
positionBottom
|
|
30
|
+
positionBottom,
|
|
31
|
+
showOnTop
|
|
32
32
|
}) => `
|
|
33
33
|
${borderRadius}
|
|
34
34
|
overflow: hidden;
|
|
@@ -38,6 +38,7 @@ export const StyledBar = styled.div`
|
|
|
38
38
|
background-color: ${rgba(N0, 0.8)};
|
|
39
39
|
height: ${height + padding * 2}px;
|
|
40
40
|
padding: ${padding}px;
|
|
41
|
+
box-sizing: border-box;
|
|
41
42
|
|
|
42
43
|
::before {
|
|
43
44
|
content: '';
|
|
@@ -48,7 +49,7 @@ export const StyledBar = styled.div`
|
|
|
48
49
|
display: block;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
${generateResponsiveStyles(breakpoint, positionBottom)}
|
|
52
|
+
${generateResponsiveStyles(breakpoint, positionBottom, showOnTop)}
|
|
52
53
|
`}
|
|
53
54
|
`;
|
|
54
55
|
StyledBar.displayName = 'StyledProgressBar';
|
|
@@ -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,26 +78,57 @@ 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}
|
|
67
118
|
}
|
|
68
119
|
|
|
69
120
|
/* Tooltip does not support percentage dimensions. We enforce them here */
|
|
70
|
-
${shouldDisplayTooltip ? `> div {
|
|
121
|
+
${shouldDisplayTooltip ? `> div { width: 100%; height: 100% }` : ''}
|
|
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,
|
|
@@ -30,7 +22,7 @@ export const getRenderPreviewableCardPayload = fileAttributes => ({
|
|
|
30
22
|
export const getRenderCommencedEventPayload = (fileAttributes, performanceAttributes) => {
|
|
31
23
|
return {
|
|
32
24
|
eventType: 'operational',
|
|
33
|
-
action:
|
|
25
|
+
action: 'commenced',
|
|
34
26
|
actionSubject: 'mediaCardRender',
|
|
35
27
|
attributes: {
|
|
36
28
|
fileAttributes,
|
|
@@ -40,7 +32,7 @@ export const getRenderCommencedEventPayload = (fileAttributes, performanceAttrib
|
|
|
40
32
|
};
|
|
41
33
|
export const getRenderSucceededEventPayload = (fileAttributes, performanceAttributes) => ({
|
|
42
34
|
eventType: 'operational',
|
|
43
|
-
action:
|
|
35
|
+
action: 'succeeded',
|
|
44
36
|
actionSubject: 'mediaCardRender',
|
|
45
37
|
attributes: {
|
|
46
38
|
fileAttributes,
|
|
@@ -48,30 +40,9 @@ export const getRenderSucceededEventPayload = (fileAttributes, performanceAttrib
|
|
|
48
40
|
status: 'success'
|
|
49
41
|
}
|
|
50
42
|
});
|
|
51
|
-
export const getFailedFileUriFailReason = fileStatus => {
|
|
52
|
-
if (!fileStatus) {
|
|
53
|
-
// This fail reason will come from a bug, most likely.
|
|
54
|
-
return `unknown-uri`;
|
|
55
|
-
} else if (fileStatus === 'uploading') {
|
|
56
|
-
return 'local-uri';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return 'remote-uri';
|
|
60
|
-
};
|
|
61
|
-
export const getRenderFailedFileUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
62
|
-
eventType: 'operational',
|
|
63
|
-
action: RenderEventAction.FAILED,
|
|
64
|
-
actionSubject: 'mediaCardRender',
|
|
65
|
-
attributes: {
|
|
66
|
-
fileAttributes,
|
|
67
|
-
performanceAttributes,
|
|
68
|
-
status: 'fail',
|
|
69
|
-
failReason: getFailedFileUriFailReason(fileAttributes.fileStatus)
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
43
|
export const getRenderFailedExternalUriPayload = (fileAttributes, performanceAttributes) => ({
|
|
73
44
|
eventType: 'operational',
|
|
74
|
-
action:
|
|
45
|
+
action: 'failed',
|
|
75
46
|
actionSubject: 'mediaCardRender',
|
|
76
47
|
attributes: {
|
|
77
48
|
fileAttributes,
|
|
@@ -112,7 +83,7 @@ export const getRenderErrorRequestMetadata = error => {
|
|
|
112
83
|
};
|
|
113
84
|
export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes, error) => ({
|
|
114
85
|
eventType: 'operational',
|
|
115
|
-
action:
|
|
86
|
+
action: 'failed',
|
|
116
87
|
actionSubject: 'mediaCardRender',
|
|
117
88
|
attributes: {
|
|
118
89
|
fileAttributes,
|
|
@@ -126,7 +97,7 @@ export const getRenderErrorEventPayload = (fileAttributes, performanceAttributes
|
|
|
126
97
|
});
|
|
127
98
|
export const getRenderFailedFileStatusPayload = (fileAttributes, performanceAttributes) => ({
|
|
128
99
|
eventType: 'operational',
|
|
129
|
-
action:
|
|
100
|
+
action: 'failed',
|
|
130
101
|
actionSubject: 'mediaCardRender',
|
|
131
102
|
attributes: {
|
|
132
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;
|
|
@@ -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