@atlaskit/smart-card 21.2.0 → 22.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 +56 -0
- package/dist/cjs/extractors/block/index.js +6 -7
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +16 -19
- package/dist/cjs/state/actions/index.js +54 -10
- package/dist/cjs/state/analytics/types.js +5 -0
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +429 -109
- package/dist/cjs/state/hooks-external/useSmartLinkActions.js +5 -3
- package/dist/cjs/utils/analytics/analytics.js +241 -74
- package/dist/cjs/utils/analytics/index.js +32 -5
- package/dist/cjs/utils/mocks.js +28 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/actions/PreviewAction.js +2 -2
- package/dist/cjs/view/BlockCard/index.js +6 -5
- package/dist/cjs/view/CardWithUrl/component.js +27 -5
- package/dist/cjs/view/CardWithUrl/loader.js +6 -1
- package/dist/cjs/view/EmbedCard/index.js +3 -2
- package/dist/cjs/view/EmbedModal/components/analytics/index.js +100 -0
- package/dist/cjs/view/EmbedModal/components/analytics/types.js +5 -0
- package/dist/cjs/view/EmbedModal/components/size-experiment/index.js +5 -10
- package/dist/cjs/view/EmbedModal/index.js +54 -15
- package/dist/cjs/view/EmbedModal/types.js +9 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +17 -3
- package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +5 -2
- package/dist/cjs/view/FlexibleCard/components/common/image-icon/index.js +4 -2
- package/dist/cjs/view/FlexibleCard/components/common/loading-skeleton/index.js +1 -2
- package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +5 -2
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +11 -3
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +36 -8
- package/dist/cjs/view/HoverCard/components/SnippetOrPreview.js +74 -0
- package/dist/cjs/view/HoverCard/index.js +6 -1
- package/dist/cjs/view/HoverCard/styled.js +11 -3
- package/dist/cjs/view/common/Modal.js +29 -4
- package/dist/cjs/view/common/ModalHeader.js +3 -2
- package/dist/es2019/extractors/block/index.js +6 -7
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +16 -10
- package/dist/es2019/state/actions/index.js +54 -10
- package/dist/es2019/state/analytics/types.js +1 -0
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +424 -41
- package/dist/es2019/state/hooks-external/useSmartLinkActions.js +5 -3
- package/dist/es2019/utils/analytics/analytics.js +254 -79
- package/dist/es2019/utils/analytics/index.js +32 -4
- package/dist/es2019/utils/mocks.js +26 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/actions/PreviewAction.js +3 -3
- package/dist/es2019/view/BlockCard/index.js +5 -4
- package/dist/es2019/view/CardWithUrl/component.js +27 -5
- package/dist/es2019/view/CardWithUrl/loader.js +6 -1
- package/dist/es2019/view/EmbedCard/index.js +3 -2
- package/dist/es2019/view/EmbedModal/components/analytics/index.js +80 -0
- package/dist/es2019/view/EmbedModal/components/analytics/types.js +1 -0
- package/dist/es2019/view/EmbedModal/components/size-experiment/index.js +5 -9
- package/dist/es2019/view/EmbedModal/index.js +46 -13
- package/dist/es2019/view/EmbedModal/types.js +6 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +17 -7
- package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +4 -1
- package/dist/es2019/view/FlexibleCard/components/common/image-icon/index.js +4 -2
- package/dist/es2019/view/FlexibleCard/components/common/loading-skeleton/index.js +2 -3
- package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +5 -2
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +11 -3
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +36 -10
- package/dist/es2019/view/HoverCard/components/SnippetOrPreview.js +42 -0
- package/dist/es2019/view/HoverCard/index.js +6 -1
- package/dist/es2019/view/HoverCard/styled.js +8 -0
- package/dist/es2019/view/common/Modal.js +27 -6
- package/dist/es2019/view/common/ModalHeader.js +3 -2
- package/dist/esm/extractors/block/index.js +6 -7
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +17 -19
- package/dist/esm/state/actions/index.js +54 -10
- package/dist/esm/state/analytics/types.js +1 -0
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +428 -111
- package/dist/esm/state/hooks-external/useSmartLinkActions.js +5 -3
- package/dist/esm/utils/analytics/analytics.js +241 -74
- package/dist/esm/utils/analytics/index.js +31 -4
- package/dist/esm/utils/mocks.js +25 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/actions/PreviewAction.js +3 -3
- package/dist/esm/view/BlockCard/index.js +5 -4
- package/dist/esm/view/CardWithUrl/component.js +27 -5
- package/dist/esm/view/CardWithUrl/loader.js +6 -1
- package/dist/esm/view/EmbedCard/index.js +3 -2
- package/dist/esm/view/EmbedModal/components/analytics/index.js +82 -0
- package/dist/esm/view/EmbedModal/components/analytics/types.js +1 -0
- package/dist/esm/view/EmbedModal/components/size-experiment/index.js +5 -10
- package/dist/esm/view/EmbedModal/index.js +52 -15
- package/dist/esm/view/EmbedModal/types.js +6 -1
- package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +11 -3
- package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +5 -2
- package/dist/esm/view/FlexibleCard/components/common/image-icon/index.js +4 -2
- package/dist/esm/view/FlexibleCard/components/common/loading-skeleton/index.js +1 -2
- package/dist/esm/view/FlexibleCard/components/elements/media/index.js +5 -2
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +11 -3
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +36 -10
- package/dist/esm/view/HoverCard/components/SnippetOrPreview.js +53 -0
- package/dist/esm/view/HoverCard/index.js +6 -1
- package/dist/esm/view/HoverCard/styled.js +6 -2
- package/dist/esm/view/common/Modal.js +28 -6
- package/dist/esm/view/common/ModalHeader.js +3 -2
- package/dist/types/extractors/block/types.d.ts +4 -2
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +7 -5
- package/dist/types/state/analytics/types.d.ts +9 -0
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +41 -24
- package/dist/types/state/hooks/useSmartLink.d.ts +26 -18
- package/dist/types/state/hooks-external/useSmartLinkActions.d.ts +6 -2
- package/dist/types/utils/analytics/analytics.d.ts +19 -21
- package/dist/types/utils/analytics/index.d.ts +2 -2
- package/dist/types/utils/analytics/types.d.ts +91 -0
- package/dist/types/utils/mocks.d.ts +48 -0
- package/dist/types/utils/types.d.ts +3 -1
- package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +4 -0
- package/dist/types/view/BlockCard/index.d.ts +2 -2
- package/dist/types/view/BlockCard/types.d.ts +4 -4
- package/dist/types/view/Card/index.d.ts +1 -1
- package/dist/types/view/EmbedCard/types.d.ts +2 -2
- package/dist/types/view/EmbedModal/components/analytics/index.d.ts +5 -0
- package/dist/types/view/EmbedModal/components/analytics/types.d.ts +6 -0
- package/dist/types/view/EmbedModal/components/size-experiment/index.d.ts +4 -3
- package/dist/types/view/EmbedModal/index.d.ts +3 -1
- package/dist/types/view/EmbedModal/types.d.ts +14 -4
- package/dist/types/view/FlexibleCard/components/blocks/preview-block/types.d.ts +7 -1
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +15 -0
- package/dist/types/view/FlexibleCard/components/common/image-icon/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/elements/media/types.d.ts +5 -0
- package/dist/types/view/HoverCard/components/SnippetOrPreview.d.ts +4 -0
- package/dist/types/view/HoverCard/styled.d.ts +2 -0
- package/dist/types/view/HoverCard/types.d.ts +5 -0
- package/dist/types/view/common/Modal.d.ts +6 -8
- package/package.json +1 -1
- package/report.api.md +324 -108
|
@@ -5,7 +5,6 @@ import { extractBlockProps } from '../../extractors/block';
|
|
|
5
5
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
6
6
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
7
7
|
import { CardLinkView } from '../LinkView';
|
|
8
|
-
export { default as PreviewAction } from './actions/PreviewAction';
|
|
9
8
|
import { AuthorizeAction } from './actions/AuthorizeAction';
|
|
10
9
|
import { ForbiddenAction } from './actions/ForbiddenAction';
|
|
11
10
|
import { ResolvedView as BlockCardResolvedView } from './views/ResolvedView';
|
|
@@ -15,6 +14,7 @@ import { UnauthorizedView as BlockCardUnauthorisedView } from './views/Unauthori
|
|
|
15
14
|
import { ForbiddenView as BlockCardForbiddenView } from './views/ForbiddenView';
|
|
16
15
|
import { ErroredView as BlockCardErroredView } from './views/ErroredView';
|
|
17
16
|
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
17
|
+
export { default as PreviewAction } from './actions/PreviewAction';
|
|
18
18
|
export { ForbiddenAction, AuthorizeAction, BlockCardResolvedView, BlockCardResolvingView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardErroredView, BlockCardNotFoundView };
|
|
19
19
|
export var BlockCard = function BlockCard(_ref) {
|
|
20
20
|
var _details$meta, _forbiddenViewProps$c;
|
|
@@ -27,7 +27,6 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
27
27
|
handleAuthorize = _ref.handleAuthorize,
|
|
28
28
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
29
29
|
handleFrameClick = _ref.handleFrameClick,
|
|
30
|
-
handleAnalytics = _ref.handleAnalytics,
|
|
31
30
|
handleInvoke = _ref.handleInvoke,
|
|
32
31
|
renderers = _ref.renderers,
|
|
33
32
|
isSelected = _ref.isSelected,
|
|
@@ -35,7 +34,8 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
35
34
|
onError = _ref.onError,
|
|
36
35
|
testId = _ref.testId,
|
|
37
36
|
showActions = _ref.showActions,
|
|
38
|
-
platform = _ref.platform
|
|
37
|
+
platform = _ref.platform,
|
|
38
|
+
analytics = _ref.analytics;
|
|
39
39
|
// Actions do not have access to the react tree, so we need to obtain
|
|
40
40
|
// feature flags here where we still can access SmartLinkContext context
|
|
41
41
|
// and pass the flags down to the extractor. See PreviewAction.tsx for details.
|
|
@@ -46,8 +46,9 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
46
46
|
var data = details && details.data || getEmptyJsonLd();
|
|
47
47
|
var meta = details && details.meta;
|
|
48
48
|
var extractorOpts = {
|
|
49
|
+
analytics: analytics,
|
|
50
|
+
origin: 'smartLinkCard',
|
|
49
51
|
featureFlags: featureFlags,
|
|
50
|
-
handleAnalytics: handleAnalytics,
|
|
51
52
|
handleInvoke: handleInvoke,
|
|
52
53
|
extensionKey: getExtensionKey(details)
|
|
53
54
|
};
|
|
@@ -63,7 +63,16 @@ export function CardWithUrlContent(_ref) {
|
|
|
63
63
|
}, [state.details, url]);
|
|
64
64
|
var handleClickWrapper = useCallback(function (event) {
|
|
65
65
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
66
|
-
analytics.ui.cardClickedEvent(
|
|
66
|
+
analytics.ui.cardClickedEvent({
|
|
67
|
+
id: id,
|
|
68
|
+
display: isFlexibleUi ? 'flexible' : appearance,
|
|
69
|
+
status: state.status,
|
|
70
|
+
definitionId: definitionId,
|
|
71
|
+
extensionKey: extensionKey,
|
|
72
|
+
isModifierKeyPressed: isModifierKeyPressed,
|
|
73
|
+
destinationProduct: product,
|
|
74
|
+
destinationSubproduct: subproduct
|
|
75
|
+
});
|
|
67
76
|
|
|
68
77
|
if (onClick) {
|
|
69
78
|
onClick(event);
|
|
@@ -87,7 +96,14 @@ export function CardWithUrlContent(_ref) {
|
|
|
87
96
|
|
|
88
97
|
if (state.status !== 'pending') {
|
|
89
98
|
measure.create(id, state.status);
|
|
90
|
-
analytics.operational.instrument(
|
|
99
|
+
analytics.operational.instrument({
|
|
100
|
+
id: id,
|
|
101
|
+
status: state.status,
|
|
102
|
+
definitionId: definitionId,
|
|
103
|
+
extensionKey: extensionKey,
|
|
104
|
+
resourceType: resourceType,
|
|
105
|
+
error: state.error
|
|
106
|
+
});
|
|
91
107
|
}
|
|
92
108
|
}, [id, appearance, state.status, state.error, definitionId, extensionKey, resourceType, analytics.operational]); // NB: once the smart-card has rendered into an end state, we capture
|
|
93
109
|
// this as a successful render. These can be one of:
|
|
@@ -96,7 +112,13 @@ export function CardWithUrlContent(_ref) {
|
|
|
96
112
|
|
|
97
113
|
useEffect(function () {
|
|
98
114
|
if (isFinalState(state.status)) {
|
|
99
|
-
analytics.ui.renderSuccessEvent(
|
|
115
|
+
analytics.ui.renderSuccessEvent({
|
|
116
|
+
display: appearance,
|
|
117
|
+
status: state.status,
|
|
118
|
+
id: id,
|
|
119
|
+
definitionId: definitionId,
|
|
120
|
+
extensionKey: extensionKey
|
|
121
|
+
});
|
|
100
122
|
}
|
|
101
123
|
}, [appearance, state.status, url, definitionId, extensionKey, analytics.ui, id]);
|
|
102
124
|
|
|
@@ -160,7 +182,7 @@ export function CardWithUrlContent(_ref) {
|
|
|
160
182
|
handleErrorRetry: handleRetry,
|
|
161
183
|
handleInvoke: handleInvoke,
|
|
162
184
|
handleFrameClick: handleClickWrapper,
|
|
163
|
-
|
|
185
|
+
analytics: analytics,
|
|
164
186
|
isSelected: isSelected,
|
|
165
187
|
onResolve: onResolve,
|
|
166
188
|
onError: onError,
|
|
@@ -178,7 +200,7 @@ export function CardWithUrlContent(_ref) {
|
|
|
178
200
|
handleErrorRetry: handleRetry,
|
|
179
201
|
handleFrameClick: handleClickWrapper,
|
|
180
202
|
handleInvoke: handleInvoke,
|
|
181
|
-
|
|
203
|
+
analytics: analytics,
|
|
182
204
|
isSelected: isSelected,
|
|
183
205
|
isFrameVisible: isFrameVisible,
|
|
184
206
|
platform: platform,
|
|
@@ -72,7 +72,12 @@ export function CardWithURLRenderer(props) {
|
|
|
72
72
|
var errorInfo = {
|
|
73
73
|
componentStack: componentStack
|
|
74
74
|
};
|
|
75
|
-
analytics.ui.renderFailedEvent(
|
|
75
|
+
analytics.ui.renderFailedEvent({
|
|
76
|
+
display: appearance,
|
|
77
|
+
id: id,
|
|
78
|
+
error: error,
|
|
79
|
+
errorInfo: errorInfo
|
|
80
|
+
});
|
|
76
81
|
}
|
|
77
82
|
}, [analytics.ui, appearance, id]);
|
|
78
83
|
|
|
@@ -23,7 +23,7 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
23
23
|
handleAuthorize = _ref.handleAuthorize,
|
|
24
24
|
handleErrorRetry = _ref.handleErrorRetry,
|
|
25
25
|
handleFrameClick = _ref.handleFrameClick,
|
|
26
|
-
|
|
26
|
+
analytics = _ref.analytics,
|
|
27
27
|
handleInvoke = _ref.handleInvoke,
|
|
28
28
|
showActions = _ref.showActions,
|
|
29
29
|
isSelected = _ref.isSelected,
|
|
@@ -77,7 +77,8 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
var resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
80
|
-
|
|
80
|
+
analytics: analytics,
|
|
81
|
+
origin: 'smartLinkEmbed',
|
|
81
82
|
handleInvoke: handleInvoke,
|
|
82
83
|
extensionKey: getExtensionKey(details)
|
|
83
84
|
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { EmbedModalSize } from '../../types';
|
|
4
|
+
|
|
5
|
+
var getResizeFrom = function getResizeFrom(size) {
|
|
6
|
+
return size === EmbedModalSize.Small ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
var withAnalytics = function withAnalytics(Component) {
|
|
10
|
+
return function (props) {
|
|
11
|
+
var analytics = props.analytics,
|
|
12
|
+
onClose = props.onClose,
|
|
13
|
+
onOpen = props.onOpen,
|
|
14
|
+
onOpenFailed = props.onOpenFailed,
|
|
15
|
+
onResize = props.onResize,
|
|
16
|
+
origin = props.origin;
|
|
17
|
+
var handleOnOpen = useCallback(function (context) {
|
|
18
|
+
analytics.screen.modalViewedEvent({
|
|
19
|
+
name: 'embedPreviewModal',
|
|
20
|
+
attributes: {
|
|
21
|
+
origin: origin,
|
|
22
|
+
size: context.size
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
analytics.ui.renderSuccessEvent({
|
|
26
|
+
status: 'resolved',
|
|
27
|
+
display: 'preview'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (onOpen) {
|
|
31
|
+
onOpen(context);
|
|
32
|
+
}
|
|
33
|
+
}, [analytics.screen, analytics.ui, onOpen, origin]);
|
|
34
|
+
var handleOnOpenFailed = useCallback(function (error, errorInfo) {
|
|
35
|
+
analytics.ui.renderFailedEvent({
|
|
36
|
+
display: 'preview',
|
|
37
|
+
error: error,
|
|
38
|
+
errorInfo: errorInfo
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (onOpenFailed) {
|
|
42
|
+
onOpenFailed(error, errorInfo);
|
|
43
|
+
}
|
|
44
|
+
}, [analytics.ui, onOpenFailed]);
|
|
45
|
+
var handleOnClose = useCallback(function (context) {
|
|
46
|
+
analytics.ui.modalClosedEvent({
|
|
47
|
+
actionSubjectId: 'embedPreview',
|
|
48
|
+
attributes: {
|
|
49
|
+
origin: origin,
|
|
50
|
+
previewTime: context.duration,
|
|
51
|
+
size: context.size
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (onClose) {
|
|
56
|
+
onClose(context);
|
|
57
|
+
}
|
|
58
|
+
}, [analytics.ui, onClose, origin]);
|
|
59
|
+
var handleOnResize = useCallback(function (context) {
|
|
60
|
+
analytics.ui.buttonClickedEvent({
|
|
61
|
+
actionSubjectId: 'embedPreviewResize',
|
|
62
|
+
attributes: {
|
|
63
|
+
newSize: context.size,
|
|
64
|
+
origin: origin,
|
|
65
|
+
previousSize: getResizeFrom(context.size)
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (onResize) {
|
|
70
|
+
onResize(context);
|
|
71
|
+
}
|
|
72
|
+
}, [analytics.ui, onResize, origin]);
|
|
73
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
74
|
+
onClose: handleOnClose,
|
|
75
|
+
onOpen: handleOnOpen,
|
|
76
|
+
onOpenFailed: handleOnOpenFailed,
|
|
77
|
+
onResize: handleOnResize
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default withAnalytics;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Modal from '../../../common/Modal';
|
|
4
|
-
import {
|
|
4
|
+
import { EmbedModalSize } from '../../types';
|
|
5
5
|
|
|
6
6
|
var withSizeExperiment = function withSizeExperiment(Component) {
|
|
7
7
|
return function (props) {
|
|
8
8
|
var _props$featureFlags = props.featureFlags,
|
|
9
|
-
featureFlags = _props$featureFlags === void 0 ? {} : _props$featureFlags
|
|
10
|
-
|
|
11
|
-
closeLabel = _props$closeLabel === void 0 ? 'Close Preview' : _props$closeLabel;
|
|
12
|
-
var embedModalSize = featureFlags.embedModalSize; // Experiment
|
|
9
|
+
featureFlags = _props$featureFlags === void 0 ? {} : _props$featureFlags;
|
|
10
|
+
var size = featureFlags.embedModalSize; // Experiment
|
|
13
11
|
|
|
14
|
-
if (
|
|
15
|
-
var size = embedModalSize === 'large' ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
12
|
+
if (size === EmbedModalSize.Large || size === EmbedModalSize.Small) {
|
|
16
13
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
17
14
|
size: size
|
|
18
15
|
}));
|
|
19
16
|
} // Control
|
|
20
17
|
|
|
21
18
|
|
|
22
|
-
return /*#__PURE__*/React.createElement(Modal,
|
|
23
|
-
closeLabel: closeLabel
|
|
24
|
-
}));
|
|
19
|
+
return /*#__PURE__*/React.createElement(Modal, props);
|
|
25
20
|
};
|
|
26
21
|
};
|
|
27
22
|
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
3
3
|
import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
|
|
4
4
|
import LinkInfo from './components/link-info';
|
|
5
5
|
import { MAX_MODAL_SIZE, MIN_MODAL_SIZE } from './constants';
|
|
6
6
|
import EmbedContent from './components/embed-content';
|
|
7
|
+
import { EmbedModalSize } from './types';
|
|
7
8
|
import withErrorBoundary from './components/error-boundary';
|
|
8
9
|
import withSizeExperiment from './components/size-experiment';
|
|
10
|
+
import withAnalytics from './components/analytics';
|
|
11
|
+
|
|
12
|
+
var toSize = function toSize(width) {
|
|
13
|
+
return width === MAX_MODAL_SIZE ? EmbedModalSize.Large : EmbedModalSize.Small;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var toWidth = function toWidth(size) {
|
|
17
|
+
return size === EmbedModalSize.Large ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
18
|
+
};
|
|
9
19
|
|
|
10
20
|
var EmbedModal = function EmbedModal(_ref) {
|
|
11
21
|
var downloadUrl = _ref.download,
|
|
@@ -16,49 +26,76 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
16
26
|
onClose = _ref.onClose,
|
|
17
27
|
onDownloadActionClick = _ref.onDownloadActionClick,
|
|
18
28
|
onOpen = _ref.onOpen,
|
|
29
|
+
onResize = _ref.onResize,
|
|
19
30
|
onViewActionClick = _ref.onViewActionClick,
|
|
20
31
|
providerName = _ref.providerName,
|
|
21
32
|
showModal = _ref.showModal,
|
|
22
33
|
_ref$size = _ref.size,
|
|
23
|
-
|
|
34
|
+
size = _ref$size === void 0 ? EmbedModalSize.Small : _ref$size,
|
|
24
35
|
src = _ref.src,
|
|
25
36
|
_ref$testId = _ref.testId,
|
|
26
37
|
testId = _ref$testId === void 0 ? 'smart-embed-preview-modal' : _ref$testId,
|
|
27
38
|
title = _ref.title,
|
|
28
39
|
url = _ref.url;
|
|
40
|
+
var defaultWidth = toWidth(size);
|
|
29
41
|
|
|
30
42
|
var _useState = useState(showModal),
|
|
31
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
44
|
isOpen = _useState2[0],
|
|
33
45
|
setIsOpen = _useState2[1];
|
|
34
46
|
|
|
35
|
-
var _useState3 = useState(
|
|
47
|
+
var _useState3 = useState(defaultWidth),
|
|
36
48
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
37
|
-
|
|
38
|
-
|
|
49
|
+
width = _useState4[0],
|
|
50
|
+
setWidth = _useState4[1];
|
|
51
|
+
|
|
52
|
+
var openAt = useRef();
|
|
53
|
+
var handleOnOpenComplete = useCallback(function () {
|
|
54
|
+
openAt.current = Date.now();
|
|
39
55
|
|
|
56
|
+
if (onOpen) {
|
|
57
|
+
onOpen({
|
|
58
|
+
size: size
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [onOpen, size]);
|
|
40
62
|
var handleOnClose = useCallback(function () {
|
|
41
63
|
return setIsOpen(false);
|
|
42
64
|
}, []);
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
var handleOnCloseComplete = useCallback(function () {
|
|
66
|
+
if (onClose) {
|
|
67
|
+
var duration = openAt.current ? Date.now() - openAt.current : undefined;
|
|
68
|
+
onClose({
|
|
69
|
+
duration: duration,
|
|
70
|
+
size: toSize(width)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}, [onClose, width]);
|
|
74
|
+
var handleOnResizeClick = useCallback(function () {
|
|
75
|
+
var newWidth = width === MIN_MODAL_SIZE ? MAX_MODAL_SIZE : MIN_MODAL_SIZE;
|
|
76
|
+
setWidth(newWidth);
|
|
77
|
+
|
|
78
|
+
if (onResize) {
|
|
79
|
+
onResize({
|
|
80
|
+
size: toSize(newWidth)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, [onResize, width]);
|
|
47
84
|
return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
|
|
48
85
|
height: "100%",
|
|
49
86
|
onClose: handleOnClose,
|
|
50
|
-
onCloseComplete:
|
|
51
|
-
onOpenComplete:
|
|
87
|
+
onCloseComplete: handleOnCloseComplete,
|
|
88
|
+
onOpenComplete: handleOnOpenComplete,
|
|
52
89
|
testId: testId,
|
|
53
|
-
width:
|
|
90
|
+
width: width
|
|
54
91
|
}, /*#__PURE__*/React.createElement(LinkInfo, {
|
|
55
92
|
downloadUrl: downloadUrl,
|
|
56
93
|
icon: icon,
|
|
57
94
|
providerName: providerName,
|
|
58
95
|
onViewButtonClick: onViewActionClick,
|
|
59
96
|
onDownloadButtonClick: onDownloadActionClick,
|
|
60
|
-
onResizeButtonClick:
|
|
61
|
-
size:
|
|
97
|
+
onResizeButtonClick: handleOnResizeClick,
|
|
98
|
+
size: width,
|
|
62
99
|
title: title,
|
|
63
100
|
testId: testId,
|
|
64
101
|
url: url
|
|
@@ -70,4 +107,4 @@ var EmbedModal = function EmbedModal(_ref) {
|
|
|
70
107
|
}))));
|
|
71
108
|
};
|
|
72
109
|
|
|
73
|
-
export default withSizeExperiment(withErrorBoundary(EmbedModal));
|
|
110
|
+
export default withSizeExperiment(withAnalytics(withErrorBoundary(EmbedModal)));
|
|
@@ -3,7 +3,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
|
3
3
|
var _templateObject;
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
|
-
import React from 'react';
|
|
6
|
+
import React, { useEffect } from 'react';
|
|
7
7
|
import { css, jsx } from '@emotion/core';
|
|
8
8
|
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../../constants';
|
|
9
9
|
import { getBaseStyles, getGapSize, highlightRemoveStyles, renderChildren } from '../utils';
|
|
@@ -28,11 +28,19 @@ var Block = function Block(_ref) {
|
|
|
28
28
|
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
29
29
|
_ref$testId = _ref.testId,
|
|
30
30
|
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId,
|
|
31
|
-
overrideCss = _ref.overrideCss
|
|
31
|
+
overrideCss = _ref.overrideCss,
|
|
32
|
+
blockRef = _ref.blockRef,
|
|
33
|
+
onRender = _ref.onRender,
|
|
34
|
+
onTransitionEnd = _ref.onTransitionEnd;
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
onRender && onRender();
|
|
37
|
+
}, [onRender]);
|
|
32
38
|
return jsx("div", {
|
|
33
39
|
css: [getBlockStyles(direction, size), overrideCss],
|
|
34
40
|
"data-smart-block": true,
|
|
35
|
-
"data-testid": testId
|
|
41
|
+
"data-testid": testId,
|
|
42
|
+
onTransitionEnd: onTransitionEnd,
|
|
43
|
+
ref: blockRef
|
|
36
44
|
}, renderChildren(children, size));
|
|
37
45
|
};
|
|
38
46
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["status", "testId"];
|
|
3
|
+
var _excluded = ["status", "testId", "onError"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { SmartLinkStatus } from '../../../../../constants';
|
|
6
6
|
import Block from '../block';
|
|
@@ -17,6 +17,7 @@ var PreviewBlock = function PreviewBlock(_ref) {
|
|
|
17
17
|
status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
|
|
18
18
|
_ref$testId = _ref.testId,
|
|
19
19
|
testId = _ref$testId === void 0 ? 'smart-block-preview' : _ref$testId,
|
|
20
|
+
onError = _ref.onError,
|
|
20
21
|
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
21
22
|
|
|
22
23
|
if (status !== SmartLinkStatus.Resolved) {
|
|
@@ -25,7 +26,9 @@ var PreviewBlock = function PreviewBlock(_ref) {
|
|
|
25
26
|
|
|
26
27
|
return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
|
|
27
28
|
testId: "".concat(testId, "-resolved-view")
|
|
28
|
-
}), /*#__PURE__*/React.createElement(Preview,
|
|
29
|
+
}), /*#__PURE__*/React.createElement(Preview, {
|
|
30
|
+
onError: onError
|
|
31
|
+
}));
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
export default PreviewBlock;
|
|
@@ -7,7 +7,8 @@ import LoadingSkeleton from '../loading-skeleton';
|
|
|
7
7
|
var ImageIcon = function ImageIcon(_ref) {
|
|
8
8
|
var defaultIcon = _ref.defaultIcon,
|
|
9
9
|
testId = _ref.testId,
|
|
10
|
-
url = _ref.url
|
|
10
|
+
url = _ref.url,
|
|
11
|
+
onError = _ref.onError;
|
|
11
12
|
return jsx(ImageLoader, {
|
|
12
13
|
src: url,
|
|
13
14
|
loading: jsx(LoadingSkeleton, {
|
|
@@ -17,7 +18,8 @@ var ImageIcon = function ImageIcon(_ref) {
|
|
|
17
18
|
src: url,
|
|
18
19
|
"data-testid": "".concat(testId, "-image")
|
|
19
20
|
}),
|
|
20
|
-
errored: defaultIcon
|
|
21
|
+
errored: defaultIcon,
|
|
22
|
+
onError: onError
|
|
21
23
|
});
|
|
22
24
|
};
|
|
23
25
|
|
|
@@ -11,8 +11,7 @@ var LoadingSkeleton = function LoadingSkeleton(_ref) {
|
|
|
11
11
|
var testId = _ref.testId,
|
|
12
12
|
width = _ref.width,
|
|
13
13
|
height = _ref.height;
|
|
14
|
-
var
|
|
15
|
-
var animationNameStyles = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { background-position: -", " 0; }\n 100% { background-position: ", " 0; }\n "])), animationWidth, animationWidth);
|
|
14
|
+
var animationNameStyles = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { background-position: 50% 0; }\n 100% { background-position: -50% 0; }\n "])));
|
|
16
15
|
var styles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n width: ", "rem;\n height: ", "rem;\n border-radius: 2px;\n user-select: none;\n background: ", ";\n // TODO: https://product-fabric.atlassian.net/browse/DSP-4236\n background-image: linear-gradient(\n to right,\n ", " 0%,\n ", " 20%,\n ", " 40%,\n ", "100%\n );\n background-repeat: no-repeat;\n background-size: 280% 100%;\n display: inline-block;\n\n animation-duration: 1s;\n animation-fill-mode: forwards;\n animation-iteration-count: infinite;\n animation-name: ", ";\n animation-timing-function: linear;\n "])), width, height, token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton', '#edeef1'), token('color.skeleton.subtle', '#f6f7f8'), token('color.skeleton.subtle', '#f6f7f8'), animationNameStyles);
|
|
17
16
|
return jsx("span", {
|
|
18
17
|
css: styles,
|
|
@@ -31,7 +31,8 @@ var Media = function Media(_ref) {
|
|
|
31
31
|
_ref$testId = _ref.testId,
|
|
32
32
|
testId = _ref$testId === void 0 ? 'smart-element-media' : _ref$testId,
|
|
33
33
|
type = _ref.type,
|
|
34
|
-
url = _ref.url
|
|
34
|
+
url = _ref.url,
|
|
35
|
+
onError = _ref.onError;
|
|
35
36
|
|
|
36
37
|
if (!type || !url) {
|
|
37
38
|
return null;
|
|
@@ -44,7 +45,9 @@ var Media = function Media(_ref) {
|
|
|
44
45
|
"data-testid": testId
|
|
45
46
|
}, jsx(ImageIcon, {
|
|
46
47
|
testId: "".concat(testId, "-image"),
|
|
47
|
-
url: url
|
|
48
|
+
url: url,
|
|
49
|
+
onError: onError,
|
|
50
|
+
defaultIcon: null
|
|
48
51
|
}));
|
|
49
52
|
};
|
|
50
53
|
|
|
@@ -48,7 +48,11 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
48
48
|
//Check its previously open to avoid firing events when moving between the child and hover card components
|
|
49
49
|
if (isOpen === true && cardOpenTime.current) {
|
|
50
50
|
var hoverTime = Date.now() - cardOpenTime.current;
|
|
51
|
-
analytics.ui.hoverCardDismissedEvent(
|
|
51
|
+
analytics.ui.hoverCardDismissedEvent({
|
|
52
|
+
previewDisplay: 'card',
|
|
53
|
+
hoverTime: hoverTime,
|
|
54
|
+
previewInvokeMethod: 'mouse_hover'
|
|
55
|
+
});
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
setIsOpen(false);
|
|
@@ -73,7 +77,10 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
73
77
|
//Check if its previously closed to avoid firing events when moving between the child and hover card components
|
|
74
78
|
if (isOpen === false) {
|
|
75
79
|
cardOpenTime.current = Date.now();
|
|
76
|
-
analytics.ui.hoverCardViewedEvent(
|
|
80
|
+
analytics.ui.hoverCardViewedEvent({
|
|
81
|
+
previewDisplay: hoverDisplay,
|
|
82
|
+
previewInvokeMethod: invokeMethod
|
|
83
|
+
});
|
|
77
84
|
} //If these are undefined then popupOffset is undefined and we fallback to default bottom-start placement
|
|
78
85
|
|
|
79
86
|
|
|
@@ -91,7 +98,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
91
98
|
var linkActions = useSmartLinkActions({
|
|
92
99
|
url: url,
|
|
93
100
|
appearance: SMART_CARD_ANALYTICS_DISPLAY,
|
|
94
|
-
analyticsHandler: analyticsHandler
|
|
101
|
+
analyticsHandler: analyticsHandler,
|
|
102
|
+
origin: 'smartLinkPreviewHoverCard'
|
|
95
103
|
});
|
|
96
104
|
var onActionClick = useCallback(function (actionId) {
|
|
97
105
|
if (actionId === 'preview-content') {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
2
2
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
3
|
-
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { ActionName, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
5
|
-
import extractPreview from '../../../extractors/flexible/extract-preview';
|
|
6
5
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
7
6
|
import { useSmartCardActions } from '../../../state/actions';
|
|
8
7
|
import { getExtensionKey } from '../../../state/helpers';
|
|
9
8
|
import { isSpecialEvent } from '../../../utils';
|
|
10
9
|
import FlexibleCard from '../../FlexibleCard';
|
|
11
|
-
import { FooterBlock, MetadataBlock,
|
|
12
|
-
import { flexibleUiOptions, footerBlockCss, metadataBlockCss, titleBlockCss } from '../styled';
|
|
10
|
+
import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../FlexibleCard/components/blocks';
|
|
11
|
+
import { flexibleUiOptions, footerBlockCss, metadataBlockCss, titleBlockCss, hiddenSnippetStyles } from '../styled';
|
|
13
12
|
import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
14
13
|
import HoverCardLoadingView from './HoverCardLoadingView';
|
|
14
|
+
import SnippetOrPreview from './SnippetOrPreview';
|
|
15
15
|
export var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
|
|
16
16
|
return {
|
|
17
17
|
name: ActionName.CustomAction,
|
|
@@ -26,7 +26,9 @@ export var getOpenAction = function getOpenAction(url, analytics, onActionClick)
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
window.open(url, '_blank');
|
|
29
|
-
analytics.ui.hoverCardOpenLinkClickedEvent(
|
|
29
|
+
analytics.ui.hoverCardOpenLinkClickedEvent({
|
|
30
|
+
previewDisplay: 'card'
|
|
31
|
+
});
|
|
30
32
|
},
|
|
31
33
|
testId: 'hover-card-open-button'
|
|
32
34
|
};
|
|
@@ -68,15 +70,24 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
68
70
|
useEffect(function () {
|
|
69
71
|
// Since hover preview only render on resolved status,
|
|
70
72
|
// there is no need to check for statuses.
|
|
71
|
-
analytics.ui.renderSuccessEvent(
|
|
73
|
+
analytics.ui.renderSuccessEvent({
|
|
74
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
75
|
+
status: cardState.status
|
|
76
|
+
});
|
|
72
77
|
}, [analytics.ui, cardState.status]);
|
|
73
78
|
var extensionKey = useMemo(function () {
|
|
74
79
|
return getExtensionKey(cardState.details);
|
|
75
80
|
}, [cardState.details]);
|
|
76
81
|
var onClick = useCallback(function (event) {
|
|
77
82
|
var isModifierKeyPressed = isSpecialEvent(event);
|
|
78
|
-
analytics.ui.cardClickedEvent(
|
|
79
|
-
|
|
83
|
+
analytics.ui.cardClickedEvent({
|
|
84
|
+
id: id,
|
|
85
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
86
|
+
status: cardState.status,
|
|
87
|
+
isModifierKeyPressed: isModifierKeyPressed,
|
|
88
|
+
actionSubjectId: 'titleGoToLink'
|
|
89
|
+
});
|
|
90
|
+
}, [cardState.status, analytics.ui, id]);
|
|
80
91
|
var titleActions = useMemo(function () {
|
|
81
92
|
return [getOpenAction(url, analytics, onActionClick)];
|
|
82
93
|
}, [url, analytics, onActionClick]);
|
|
@@ -92,7 +103,17 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
92
103
|
subtitle = _extractMetadata.subtitle;
|
|
93
104
|
|
|
94
105
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
95
|
-
var
|
|
106
|
+
var snippetHeight = React.useRef(0);
|
|
107
|
+
var snippetBlockRef = useRef(null);
|
|
108
|
+
var onSnippetRender = useCallback(function () {
|
|
109
|
+
var _snippetBlockRef$curr, _snippetBlockRef$curr2;
|
|
110
|
+
|
|
111
|
+
snippetHeight.current = (_snippetBlockRef$curr = (_snippetBlockRef$curr2 = snippetBlockRef.current) === null || _snippetBlockRef$curr2 === void 0 ? void 0 : _snippetBlockRef$curr2.getBoundingClientRect().height) !== null && _snippetBlockRef$curr !== void 0 ? _snippetBlockRef$curr : 0;
|
|
112
|
+
}, []);
|
|
113
|
+
var body = SnippetOrPreview({
|
|
114
|
+
data: data,
|
|
115
|
+
snippetHeight: snippetHeight.current
|
|
116
|
+
});
|
|
96
117
|
var titleBlockProps = {
|
|
97
118
|
actions: titleActions,
|
|
98
119
|
maxLines: titleMaxLines,
|
|
@@ -125,7 +146,12 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
125
146
|
size: SmartLinkSize.Large,
|
|
126
147
|
overrideCss: metadataBlockCss,
|
|
127
148
|
maxLines: 1
|
|
128
|
-
}), body, /*#__PURE__*/React.createElement(
|
|
149
|
+
}), body, /*#__PURE__*/React.createElement(SnippetBlock, {
|
|
150
|
+
testId: 'hidden-snippet',
|
|
151
|
+
onRender: onSnippetRender,
|
|
152
|
+
blockRef: snippetBlockRef,
|
|
153
|
+
overrideCss: hiddenSnippetStyles
|
|
154
|
+
}), /*#__PURE__*/React.createElement(FooterBlock, {
|
|
129
155
|
actions: footerActions,
|
|
130
156
|
size: SmartLinkSize.Large,
|
|
131
157
|
overrideCss: footerBlockCss
|