@atlaskit/smart-card 23.5.2 → 23.6.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 +10 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +4 -1
- package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +5 -16
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +4 -2
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +30 -92
- package/dist/cjs/view/HoverCard/components/views/resolved/index.js +134 -0
- package/dist/cjs/view/HoverCard/components/views/resolved/styled.js +24 -0
- package/dist/cjs/view/HoverCard/components/views/resolved/types.js +5 -0
- package/dist/cjs/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js} +8 -6
- package/dist/cjs/view/HoverCard/components/views/resolving/styled.js +19 -0
- package/dist/cjs/view/HoverCard/components/views/resolving/types.js +5 -0
- package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +85 -0
- package/dist/cjs/view/HoverCard/components/views/unauthorised/styled.js +24 -0
- package/dist/cjs/view/HoverCard/components/views/unauthorised/types.js +5 -0
- package/dist/cjs/view/HoverCard/styled.js +4 -13
- package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +16 -2
- package/dist/cjs/view/InlineCard/index.js +4 -2
- package/dist/cjs/view/common/UnauthorisedViewContent.js +40 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +4 -1
- package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +5 -13
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +4 -2
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +28 -76
- package/dist/es2019/view/HoverCard/components/views/resolved/index.js +96 -0
- package/dist/es2019/view/HoverCard/components/views/resolved/styled.js +34 -0
- package/dist/es2019/view/HoverCard/components/views/resolved/types.js +1 -0
- package/dist/es2019/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js} +5 -4
- package/dist/es2019/view/HoverCard/components/views/resolving/styled.js +11 -0
- package/dist/es2019/view/HoverCard/components/views/resolving/types.js +1 -0
- package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +58 -0
- package/dist/es2019/view/HoverCard/components/views/unauthorised/styled.js +18 -0
- package/dist/es2019/view/HoverCard/components/views/unauthorised/types.js +1 -0
- package/dist/es2019/view/HoverCard/styled.js +1 -42
- package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +13 -2
- package/dist/es2019/view/InlineCard/index.js +4 -2
- package/dist/es2019/view/common/UnauthorisedViewContent.js +24 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +4 -1
- package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +5 -13
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +4 -2
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +29 -83
- package/dist/esm/view/HoverCard/components/views/resolved/index.js +104 -0
- package/dist/esm/view/HoverCard/components/views/resolved/styled.js +10 -0
- package/dist/esm/view/HoverCard/components/views/resolved/types.js +1 -0
- package/dist/esm/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js} +5 -4
- package/dist/esm/view/HoverCard/components/views/resolving/styled.js +7 -0
- package/dist/esm/view/HoverCard/components/views/resolving/types.js +1 -0
- package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +58 -0
- package/dist/esm/view/HoverCard/components/views/unauthorised/styled.js +11 -0
- package/dist/esm/view/HoverCard/components/views/unauthorised/types.js +1 -0
- package/dist/esm/view/HoverCard/styled.js +3 -8
- package/dist/esm/view/InlineCard/UnauthorisedView/index.js +14 -2
- package/dist/esm/view/InlineCard/index.js +4 -2
- package/dist/esm/view/common/UnauthorisedViewContent.js +26 -0
- package/dist/types/view/HoverCard/components/HoverCardContent.d.ts +0 -2
- package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +7 -0
- package/dist/types/view/HoverCard/components/views/resolved/styled.d.ts +3 -0
- package/dist/types/view/HoverCard/components/views/resolved/types.d.ts +13 -0
- package/dist/types/view/HoverCard/components/{HoverCardLoadingView.d.ts → views/resolving/index.d.ts} +1 -1
- package/dist/types/view/HoverCard/components/views/resolving/styled.d.ts +2 -0
- package/dist/types/view/HoverCard/components/views/resolving/types.d.ts +6 -0
- package/dist/types/view/HoverCard/components/views/unauthorised/index.d.ts +4 -0
- package/dist/types/view/HoverCard/components/views/unauthorised/styled.d.ts +3 -0
- package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +19 -0
- package/dist/types/view/HoverCard/index.d.ts +1 -1
- package/dist/types/view/HoverCard/styled.d.ts +1 -5
- package/dist/types/view/HoverCard/types.d.ts +3 -6
- package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +2 -0
- package/dist/types/view/InlineCard/types.d.ts +1 -0
- package/dist/types/view/common/UnauthorisedViewContent.d.ts +20 -0
- package/package.json +2 -2
|
@@ -13,7 +13,7 @@ export const CARD_WIDTH_REM = 24; // gap between mouse cursor and hover card
|
|
|
13
13
|
export const CARD_GAP_PX = 10;
|
|
14
14
|
const blockGap = '0.5rem';
|
|
15
15
|
const elementGap = '0.5rem';
|
|
16
|
-
const separatorCss = css`
|
|
16
|
+
export const separatorCss = css`
|
|
17
17
|
[data-separator] + [data-separator]:before {
|
|
18
18
|
margin-right: ${elementGap};
|
|
19
19
|
}
|
|
@@ -47,47 +47,6 @@ export const titleBlockCss = css`
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
`;
|
|
50
|
-
export const metadataBlockCss = css`
|
|
51
|
-
gap: 0px;
|
|
52
|
-
|
|
53
|
-
/* primary element group */
|
|
54
|
-
[data-smart-element-group]:nth-of-type(1) {
|
|
55
|
-
flex-grow: 7;
|
|
56
|
-
|
|
57
|
-
// a separator between text-based element
|
|
58
|
-
${separatorCss}
|
|
59
|
-
|
|
60
|
-
/* horizontal spacing between elements in group */
|
|
61
|
-
> span {
|
|
62
|
-
margin-right: ${elementGap};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/* secondary element group */
|
|
66
|
-
[data-smart-element-group]:nth-of-type(2) {
|
|
67
|
-
flex-grow: 3;
|
|
68
|
-
/* horizontal spacing between elements in group */
|
|
69
|
-
> span {
|
|
70
|
-
margin-left: ${elementGap};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
export const footerBlockCss = css`
|
|
75
|
-
padding-top: 0.25rem;
|
|
76
|
-
`;
|
|
77
|
-
export const loadingViewContainer = css`
|
|
78
|
-
display: flex;
|
|
79
|
-
flex-direction: column;
|
|
80
|
-
`;
|
|
81
|
-
export const skeletonContainer = css`
|
|
82
|
-
display: flex;
|
|
83
|
-
flex-direction: column;
|
|
84
|
-
gap: 0.625rem;
|
|
85
|
-
align-items: center;
|
|
86
|
-
`;
|
|
87
|
-
export const hiddenSnippetStyles = css`
|
|
88
|
-
visibility: hidden;
|
|
89
|
-
position: absolute;
|
|
90
|
-
`;
|
|
91
50
|
export const getTransitionStyles = snippetHeight => css`
|
|
92
51
|
transition: height 300ms ease-in-out;
|
|
93
52
|
height: ${snippetHeight}px;
|
|
@@ -11,6 +11,7 @@ import { Frame } from '../Frame';
|
|
|
11
11
|
import { AKIconWrapper } from '../Icon';
|
|
12
12
|
import { IconAndTitleLayout } from '../IconAndTitleLayout';
|
|
13
13
|
import { IconStyledButton, LinkAppearance } from '../styled';
|
|
14
|
+
import { HoverCard } from '../../HoverCard';
|
|
14
15
|
const FallbackUnauthorizedIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
|
|
15
16
|
label: "error",
|
|
16
17
|
size: "small",
|
|
@@ -56,9 +57,10 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
56
57
|
icon,
|
|
57
58
|
onClick,
|
|
58
59
|
isSelected,
|
|
59
|
-
testId = 'inline-card-unauthorized-view'
|
|
60
|
+
testId = 'inline-card-unauthorized-view',
|
|
61
|
+
showAuthTooltip = false
|
|
60
62
|
} = this.props;
|
|
61
|
-
|
|
63
|
+
const inlineCardUnauthenticatedView = /*#__PURE__*/React.createElement(Frame, {
|
|
62
64
|
testId: testId,
|
|
63
65
|
link: url,
|
|
64
66
|
onClick: onClick,
|
|
@@ -68,6 +70,15 @@ export class InlineCardUnauthorizedView extends React.Component {
|
|
|
68
70
|
title: this.renderMessage(),
|
|
69
71
|
titleColor: token('color.text.subtle', N500)
|
|
70
72
|
}));
|
|
73
|
+
|
|
74
|
+
if (showAuthTooltip) {
|
|
75
|
+
return /*#__PURE__*/React.createElement(HoverCard, {
|
|
76
|
+
url: url,
|
|
77
|
+
onAuthorize: this.props.onAuthorise
|
|
78
|
+
}, inlineCardUnauthenticatedView);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return inlineCardUnauthenticatedView;
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
}
|
|
@@ -23,7 +23,8 @@ export const InlineCard = ({
|
|
|
23
23
|
onError,
|
|
24
24
|
testId,
|
|
25
25
|
inlinePreloaderStyle,
|
|
26
|
-
showHoverPreview
|
|
26
|
+
showHoverPreview,
|
|
27
|
+
showAuthTooltip
|
|
27
28
|
}) => {
|
|
28
29
|
var _details$meta;
|
|
29
30
|
|
|
@@ -80,7 +81,8 @@ export const InlineCard = ({
|
|
|
80
81
|
isSelected: isSelected,
|
|
81
82
|
onClick: handleFrameClick,
|
|
82
83
|
onAuthorise: handleAuthorize,
|
|
83
|
-
testId: testIdWithStatus
|
|
84
|
+
testId: testIdWithStatus,
|
|
85
|
+
showAuthTooltip: showAuthTooltip
|
|
84
86
|
});
|
|
85
87
|
|
|
86
88
|
case 'forbidden':
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
4
|
+
import { messages } from '../../messages';
|
|
5
|
+
import { CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This component is used in unauthorized views of a smart link.
|
|
9
|
+
* It represents the main text that provides a user with information on how to connect their account
|
|
10
|
+
*/
|
|
11
|
+
const UnauthorisedViewContent = ({
|
|
12
|
+
providerName,
|
|
13
|
+
testId = 'unauthorised-view-content'
|
|
14
|
+
}) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_description, {
|
|
15
|
+
values: {
|
|
16
|
+
context: providerName
|
|
17
|
+
}
|
|
18
|
+
})), ' ', /*#__PURE__*/React.createElement("a", {
|
|
19
|
+
href: CONTENT_URL_SECURITY_AND_PERMISSIONS,
|
|
20
|
+
target: "_blank",
|
|
21
|
+
"data-testid": `${testId}-learn-more`
|
|
22
|
+
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.learn_more_about_smart_links_security)));
|
|
23
|
+
|
|
24
|
+
export default UnauthorisedViewContent;
|
package/dist/esm/version.json
CHANGED
|
@@ -56,6 +56,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
56
56
|
showHoverPreview = Boolean(showHoverPreviewFlag);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
var showAuthTooltipValue = useFeatureFlag('showAuthTooltip');
|
|
60
|
+
var showAuthTooltip = !!showAuthTooltipValue && showAuthTooltipValue === 'experiment';
|
|
59
61
|
var enableFlexibleBlockCardFlag = Boolean(useFeatureFlag('enableFlexibleBlockCard')); // Setup UI handlers.
|
|
60
62
|
|
|
61
63
|
var handleClick = useCallback(function (event) {
|
|
@@ -169,7 +171,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
169
171
|
onError: onError,
|
|
170
172
|
testId: testId,
|
|
171
173
|
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
172
|
-
showHoverPreview: showHoverPreview
|
|
174
|
+
showHoverPreview: showHoverPreview,
|
|
175
|
+
showAuthTooltip: showAuthTooltip
|
|
173
176
|
});
|
|
174
177
|
|
|
175
178
|
case 'block':
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { FormattedMessage } from 'react-intl-next';
|
|
4
2
|
import { EmbedCardUnresolvedView } from './UnresolvedView';
|
|
5
3
|
import { UnauthorisedImage } from '../constants';
|
|
6
4
|
import { ExpandedFrame } from '../components/ExpandedFrame';
|
|
7
5
|
import { ImageIcon } from '../components/ImageIcon';
|
|
8
|
-
import
|
|
9
|
-
import { CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../../constants';
|
|
6
|
+
import UnauthorisedViewContent from '../../common/UnauthorisedViewContent';
|
|
10
7
|
export var EmbedCardUnauthorisedView = function EmbedCardUnauthorisedView(_ref) {
|
|
11
8
|
var _context$image;
|
|
12
9
|
|
|
@@ -43,13 +40,8 @@ export var EmbedCardUnauthorisedView = function EmbedCardUnauthorisedView(_ref)
|
|
|
43
40
|
},
|
|
44
41
|
onClick: onAuthorise,
|
|
45
42
|
testId: testId
|
|
46
|
-
}, /*#__PURE__*/React.createElement(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})), ' ', /*#__PURE__*/React.createElement("a", {
|
|
51
|
-
href: CONTENT_URL_SECURITY_AND_PERMISSIONS,
|
|
52
|
-
target: "_blank",
|
|
53
|
-
"data-testid": "".concat(testId, "-learn-more")
|
|
54
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, messages.learn_more_about_smart_links_security))));
|
|
43
|
+
}, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
44
|
+
providerName: context === null || context === void 0 ? void 0 : context.text,
|
|
45
|
+
testId: testId
|
|
46
|
+
})));
|
|
55
47
|
};
|
|
@@ -16,7 +16,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
16
16
|
var children = _ref.children,
|
|
17
17
|
url = _ref.url,
|
|
18
18
|
analyticsHandler = _ref.analyticsHandler,
|
|
19
|
-
analytics = _ref.analytics
|
|
19
|
+
analytics = _ref.analytics,
|
|
20
|
+
onAuthorize = _ref.onAuthorize;
|
|
20
21
|
var delay = 300;
|
|
21
22
|
|
|
22
23
|
var _React$useState = React.useState(false),
|
|
@@ -133,7 +134,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
133
134
|
onActionClick: onActionClick,
|
|
134
135
|
onResolve: update,
|
|
135
136
|
renderers: renderers,
|
|
136
|
-
url: url
|
|
137
|
+
url: url,
|
|
138
|
+
onAuthorize: onAuthorize
|
|
137
139
|
}));
|
|
138
140
|
},
|
|
139
141
|
trigger: function trigger(triggerProps) {
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
2
1
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
3
2
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
4
|
-
import React, { useCallback,
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
4
|
import { ActionName, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
6
5
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
7
|
-
import { useSmartCardActions } from '../../../state/actions';
|
|
8
6
|
import { getExtensionKey } from '../../../state/helpers';
|
|
9
7
|
import { isSpecialEvent } from '../../../utils';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import SnippetOrPreview from './SnippetOrPreview';
|
|
8
|
+
import { flexibleUiOptions, titleBlockCss } from '../styled';
|
|
9
|
+
import { getSimulatedMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../utils';
|
|
10
|
+
import HoverCardLoadingView from './views/resolving';
|
|
11
|
+
import HoverCardUnauthorisedView from './views/unauthorised';
|
|
12
|
+
import HoverCardResolvedView from './views/resolved';
|
|
16
13
|
export var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
|
|
17
14
|
return {
|
|
18
15
|
name: ActionName.CustomAction,
|
|
@@ -34,22 +31,6 @@ export var getOpenAction = function getOpenAction(url, analytics, onActionClick)
|
|
|
34
31
|
testId: 'hover-card-open-button'
|
|
35
32
|
};
|
|
36
33
|
};
|
|
37
|
-
export var toFooterActions = function toFooterActions(cardActions, onActionClick) {
|
|
38
|
-
return cardActions.map(function (action) {
|
|
39
|
-
return {
|
|
40
|
-
content: action.text,
|
|
41
|
-
name: ActionName.CustomAction,
|
|
42
|
-
onClick: function onClick() {
|
|
43
|
-
if (onActionClick) {
|
|
44
|
-
onActionClick(action.id);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return action.invoke();
|
|
48
|
-
},
|
|
49
|
-
testId: action.id
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
34
|
|
|
54
35
|
var HoverCardContent = function HoverCardContent(_ref) {
|
|
55
36
|
var _cardState$details;
|
|
@@ -63,20 +44,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
63
44
|
onActionClick = _ref.onActionClick,
|
|
64
45
|
onResolve = _ref.onResolve,
|
|
65
46
|
renderers = _ref.renderers,
|
|
66
|
-
url = _ref.url
|
|
67
|
-
|
|
68
|
-
var actions = useSmartCardActions(id, url, analytics);
|
|
69
|
-
useEffect(function () {
|
|
70
|
-
actions.loadMetadata();
|
|
71
|
-
}, [actions]);
|
|
72
|
-
useEffect(function () {
|
|
73
|
-
// Since hover preview only render on resolved status,
|
|
74
|
-
// there is no need to check for statuses.
|
|
75
|
-
analytics.ui.renderSuccessEvent({
|
|
76
|
-
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
77
|
-
status: cardState.status
|
|
78
|
-
});
|
|
79
|
-
}, [analytics.ui, cardState.status]);
|
|
47
|
+
url = _ref.url,
|
|
48
|
+
onAuthorize = _ref.onAuthorize;
|
|
80
49
|
var extensionKey = useMemo(function () {
|
|
81
50
|
return getExtensionKey(cardState.details);
|
|
82
51
|
}, [cardState.details]);
|
|
@@ -93,38 +62,13 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
93
62
|
var titleActions = useMemo(function () {
|
|
94
63
|
return [getOpenAction(url, analytics, onActionClick)];
|
|
95
64
|
}, [url, analytics, onActionClick]);
|
|
96
|
-
var footerActions = useMemo(function () {
|
|
97
|
-
return toFooterActions(cardActions, onActionClick);
|
|
98
|
-
}, [cardActions, onActionClick]);
|
|
99
65
|
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
66
|
+
var types = data ? extractType(data) : undefined;
|
|
100
67
|
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
105
|
-
var primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
106
|
-
return {
|
|
107
|
-
primary: primary,
|
|
108
|
-
secondary: metadata.secondary,
|
|
109
|
-
subtitle: metadata.subtitle
|
|
110
|
-
};
|
|
111
|
-
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]),
|
|
112
|
-
primary = _useMemo.primary,
|
|
113
|
-
secondary = _useMemo.secondary,
|
|
114
|
-
subtitle = _useMemo.subtitle;
|
|
68
|
+
var _extractMetadata = extractMetadata(getSimulatedMetadata(extensionKey, types)),
|
|
69
|
+
subtitle = _extractMetadata.subtitle;
|
|
115
70
|
|
|
116
71
|
var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
117
|
-
var snippetHeight = React.useRef(0);
|
|
118
|
-
var snippetBlockRef = useRef(null);
|
|
119
|
-
var onSnippetRender = useCallback(function () {
|
|
120
|
-
var _snippetBlockRef$curr, _snippetBlockRef$curr2;
|
|
121
|
-
|
|
122
|
-
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;
|
|
123
|
-
}, []);
|
|
124
|
-
var body = SnippetOrPreview({
|
|
125
|
-
data: data,
|
|
126
|
-
snippetHeight: snippetHeight.current
|
|
127
|
-
});
|
|
128
72
|
var titleBlockProps = {
|
|
129
73
|
actions: titleActions,
|
|
130
74
|
maxLines: titleMaxLines,
|
|
@@ -148,25 +92,27 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
148
92
|
flexibleCardProps: flexibleCardProps,
|
|
149
93
|
titleBlockProps: titleBlockProps
|
|
150
94
|
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (cardState.status === 'unauthorized') {
|
|
98
|
+
return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
|
|
99
|
+
flexibleCardProps: flexibleCardProps,
|
|
100
|
+
onAuthorize: onAuthorize
|
|
101
|
+
});
|
|
151
102
|
} // if metadataStatus is 'errored' simply render using data available (normal path)
|
|
152
103
|
|
|
153
104
|
|
|
154
|
-
return /*#__PURE__*/React.createElement(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}), /*#__PURE__*/React.createElement(FooterBlock, {
|
|
166
|
-
actions: footerActions,
|
|
167
|
-
size: SmartLinkSize.Large,
|
|
168
|
-
overrideCss: footerBlockCss
|
|
169
|
-
}));
|
|
105
|
+
return /*#__PURE__*/React.createElement(HoverCardResolvedView, {
|
|
106
|
+
id: id,
|
|
107
|
+
url: url,
|
|
108
|
+
extensionKey: extensionKey,
|
|
109
|
+
analytics: analytics,
|
|
110
|
+
cardActions: cardActions,
|
|
111
|
+
cardState: cardState,
|
|
112
|
+
flexibleCardProps: flexibleCardProps,
|
|
113
|
+
onActionClick: onActionClick,
|
|
114
|
+
titleBlockProps: titleBlockProps
|
|
115
|
+
});
|
|
170
116
|
};
|
|
171
117
|
|
|
172
118
|
export default HoverCardContent;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
3
|
+
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
4
|
+
import { ActionName, SmartLinkSize } from '../../../../../constants';
|
|
5
|
+
import { FooterBlock, MetadataBlock, SnippetBlock, TitleBlock } from '../../../../FlexibleCard/components/blocks';
|
|
6
|
+
import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
|
|
7
|
+
import FlexibleCard from '../../../../FlexibleCard';
|
|
8
|
+
import { useSmartCardActions } from '../../../../../state/actions';
|
|
9
|
+
import { getSimulatedMetadata, toActionableMetadata, SMART_CARD_ANALYTICS_DISPLAY } from '../../../utils';
|
|
10
|
+
import SnippetOrPreview from '../../SnippetOrPreview';
|
|
11
|
+
import { extractMetadata } from '../../../../../extractors/hover/extractMetadata';
|
|
12
|
+
export var toFooterActions = function toFooterActions(cardActions, onActionClick) {
|
|
13
|
+
return cardActions.map(function (action) {
|
|
14
|
+
return {
|
|
15
|
+
content: action.text,
|
|
16
|
+
name: ActionName.CustomAction,
|
|
17
|
+
onClick: function onClick() {
|
|
18
|
+
if (onActionClick) {
|
|
19
|
+
onActionClick(action.id);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return action.invoke();
|
|
23
|
+
},
|
|
24
|
+
testId: action.id
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
|
|
30
|
+
var _cardState$details;
|
|
31
|
+
|
|
32
|
+
var flexibleCardProps = _ref.flexibleCardProps,
|
|
33
|
+
titleBlockProps = _ref.titleBlockProps,
|
|
34
|
+
analytics = _ref.analytics,
|
|
35
|
+
_ref$id = _ref.id,
|
|
36
|
+
id = _ref$id === void 0 ? '' : _ref$id,
|
|
37
|
+
url = _ref.url,
|
|
38
|
+
cardState = _ref.cardState,
|
|
39
|
+
_ref$cardActions = _ref.cardActions,
|
|
40
|
+
cardActions = _ref$cardActions === void 0 ? [] : _ref$cardActions,
|
|
41
|
+
onActionClick = _ref.onActionClick,
|
|
42
|
+
extensionKey = _ref.extensionKey;
|
|
43
|
+
var showActionableElement = useFeatureFlag('enableActionableElement');
|
|
44
|
+
var actions = useSmartCardActions(id, url, analytics);
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
actions.loadMetadata();
|
|
47
|
+
}, [actions]);
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
// Since this hover view is only rendered on resolved status,
|
|
50
|
+
// there is no need to check for statuses.
|
|
51
|
+
analytics.ui.renderSuccessEvent({
|
|
52
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
53
|
+
status: cardState.status
|
|
54
|
+
});
|
|
55
|
+
}, [analytics.ui, cardState.status]);
|
|
56
|
+
var footerActions = useMemo(function () {
|
|
57
|
+
return toFooterActions(cardActions, onActionClick);
|
|
58
|
+
}, [cardActions, onActionClick]);
|
|
59
|
+
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
60
|
+
|
|
61
|
+
var _useMemo = useMemo(function () {
|
|
62
|
+
var types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
63
|
+
|
|
64
|
+
var metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
65
|
+
var primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
66
|
+
return {
|
|
67
|
+
primary: primary,
|
|
68
|
+
secondary: metadata.secondary,
|
|
69
|
+
subtitle: metadata.subtitle
|
|
70
|
+
};
|
|
71
|
+
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]),
|
|
72
|
+
primary = _useMemo.primary,
|
|
73
|
+
secondary = _useMemo.secondary;
|
|
74
|
+
|
|
75
|
+
var snippetHeight = React.useRef(0);
|
|
76
|
+
var snippetBlockRef = useRef(null);
|
|
77
|
+
var onSnippetRender = useCallback(function () {
|
|
78
|
+
var _snippetBlockRef$curr, _snippetBlockRef$curr2;
|
|
79
|
+
|
|
80
|
+
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;
|
|
81
|
+
}, []);
|
|
82
|
+
var body = SnippetOrPreview({
|
|
83
|
+
data: data,
|
|
84
|
+
snippetHeight: snippetHeight.current
|
|
85
|
+
});
|
|
86
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, /*#__PURE__*/React.createElement(TitleBlock, titleBlockProps), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
87
|
+
primary: primary,
|
|
88
|
+
secondary: secondary,
|
|
89
|
+
size: SmartLinkSize.Large,
|
|
90
|
+
overrideCss: metadataBlockCss,
|
|
91
|
+
maxLines: 1
|
|
92
|
+
}), body, /*#__PURE__*/React.createElement(SnippetBlock, {
|
|
93
|
+
testId: 'hidden-snippet',
|
|
94
|
+
onRender: onSnippetRender,
|
|
95
|
+
blockRef: snippetBlockRef,
|
|
96
|
+
overrideCss: hiddenSnippetStyles
|
|
97
|
+
}), /*#__PURE__*/React.createElement(FooterBlock, {
|
|
98
|
+
actions: footerActions,
|
|
99
|
+
size: SmartLinkSize.Large,
|
|
100
|
+
overrideCss: footerBlockCss
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default HoverCardResolvedView;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
|
+
|
|
5
|
+
import { css } from '@emotion/react';
|
|
6
|
+
import { separatorCss } from '../../../styled';
|
|
7
|
+
var elementGap = '0.5rem';
|
|
8
|
+
export var metadataBlockCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n gap: 0px;\n\n /* primary element group */\n [data-smart-element-group]:nth-of-type(1) {\n flex-grow: 7;\n\n // a separator between text-based element\n ", "\n\n /* horizontal spacing between elements in group */\n > span {\n margin-right: ", ";\n }\n }\n /* secondary element group */\n [data-smart-element-group]:nth-of-type(2) {\n flex-grow: 3;\n /* horizontal spacing between elements in group */\n > span {\n margin-left: ", ";\n }\n }\n"])), separatorCss, elementGap, elementGap);
|
|
9
|
+
export var footerBlockCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: 0.25rem;\n"])));
|
|
10
|
+
export var hiddenSnippetStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n visibility: hidden;\n position: absolute;\n"])));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js}
RENAMED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import LoadingSkeleton from '
|
|
5
|
-
import FlexibleCard from '
|
|
6
|
-
import { TitleBlock } from '
|
|
7
|
-
import { CARD_WIDTH_REM
|
|
4
|
+
import LoadingSkeleton from '../../../../FlexibleCard/components/common/loading-skeleton';
|
|
5
|
+
import FlexibleCard from '../../../../FlexibleCard';
|
|
6
|
+
import { TitleBlock } from '../../../../FlexibleCard/components/blocks';
|
|
7
|
+
import { CARD_WIDTH_REM } from '../../../styled';
|
|
8
|
+
import { loadingViewContainer, skeletonContainer } from './styled';
|
|
8
9
|
|
|
9
10
|
var HoverCardLoadingView = function HoverCardLoadingView(_ref) {
|
|
10
11
|
var flexibleCardProps = _ref.flexibleCardProps,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2;
|
|
4
|
+
|
|
5
|
+
import { css } from '@emotion/react';
|
|
6
|
+
export var loadingViewContainer = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n"])));
|
|
7
|
+
export var skeletonContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 0.625rem;\n align-items: center;\n"])));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
4
|
+
import FlexibleCard from '../../../../FlexibleCard';
|
|
5
|
+
import { messages } from '../../../../../messages';
|
|
6
|
+
import { CustomBlock } from '../../../../FlexibleCard/components/blocks';
|
|
7
|
+
import { extractProvider } from '@atlaskit/linking-common/extractors';
|
|
8
|
+
import { connectButtonStyles, mainTextStyles, titleBlockStyles } from './styled';
|
|
9
|
+
import UnauthorisedViewContent from '../../../../common/UnauthorisedViewContent';
|
|
10
|
+
import ActionGroup from '../../../../FlexibleCard/components/blocks/action-group';
|
|
11
|
+
import { LinkIcon } from '../../../../FlexibleCard/components/elements';
|
|
12
|
+
import { ActionName } from '../../../../../constants';
|
|
13
|
+
|
|
14
|
+
var HoverCardUnauthorisedView = function HoverCardUnauthorisedView(_ref) {
|
|
15
|
+
var _cardState$details, _extractProvider;
|
|
16
|
+
|
|
17
|
+
var flexibleCardProps = _ref.flexibleCardProps,
|
|
18
|
+
_ref$testId = _ref.testId,
|
|
19
|
+
testId = _ref$testId === void 0 ? 'hover-card-unauthorised-view' : _ref$testId,
|
|
20
|
+
onAuthorize = _ref.onAuthorize;
|
|
21
|
+
var cardState = flexibleCardProps.cardState;
|
|
22
|
+
var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
23
|
+
var providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
|
|
24
|
+
var actions = useMemo(function () {
|
|
25
|
+
return onAuthorize ? [{
|
|
26
|
+
name: ActionName.CustomAction,
|
|
27
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_action, {
|
|
28
|
+
values: {
|
|
29
|
+
context: providerName
|
|
30
|
+
}
|
|
31
|
+
})),
|
|
32
|
+
onClick: onAuthorize
|
|
33
|
+
}] : [];
|
|
34
|
+
}, [onAuthorize, providerName]);
|
|
35
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, _extends({}, flexibleCardProps, {
|
|
36
|
+
testId: testId
|
|
37
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
38
|
+
overrideCss: titleBlockStyles,
|
|
39
|
+
testId: "".concat(testId, "-title")
|
|
40
|
+
}, /*#__PURE__*/React.createElement(LinkIcon, null), /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_link_account_card_name, {
|
|
41
|
+
values: {
|
|
42
|
+
context: providerName
|
|
43
|
+
}
|
|
44
|
+
}))), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
45
|
+
overrideCss: mainTextStyles,
|
|
46
|
+
testId: "".concat(testId, "-content")
|
|
47
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(UnauthorisedViewContent, {
|
|
48
|
+
providerName: providerName
|
|
49
|
+
}))), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
50
|
+
overrideCss: connectButtonStyles,
|
|
51
|
+
testId: "".concat(testId, "-button")
|
|
52
|
+
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
53
|
+
items: actions,
|
|
54
|
+
appearance: "primary"
|
|
55
|
+
})));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default HoverCardUnauthorisedView;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
|
+
|
|
5
|
+
import { css } from '@emotion/react';
|
|
6
|
+
var blockGap = '0.5rem';
|
|
7
|
+
var iconGap = '0.5rem';
|
|
8
|
+
var titleFontWeight = '500';
|
|
9
|
+
export var connectButtonStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n justify-content: flex-end;\n margin-top: ", ";\n"])), blockGap);
|
|
10
|
+
export var titleBlockStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n gap: ", " ", ";\n a {\n font-weight: ", ";\n }\n"])), blockGap, iconGap, titleFontWeight);
|
|
11
|
+
export var mainTextStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-top: ", ";\n font-size: 0.75rem;\n"])), blockGap);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
4
4
|
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
6
|
import { loadingPlaceholderClassName } from '../../index';
|
|
@@ -17,14 +17,9 @@ export var CARD_WIDTH_REM = 24; // gap between mouse cursor and hover card
|
|
|
17
17
|
export var CARD_GAP_PX = 10;
|
|
18
18
|
var blockGap = '0.5rem';
|
|
19
19
|
var elementGap = '0.5rem';
|
|
20
|
-
var separatorCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
|
|
20
|
+
export var separatorCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
|
|
21
21
|
export var HoverCardContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background: none;\n border-width: 0;\n box-sizing: border-box;\n width: ", "rem;\n padding: 1rem;\n\n .", " {\n display: none;\n }\n"])), CARD_WIDTH_REM, loadingPlaceholderClassName);
|
|
22
22
|
export var titleBlockCss = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n gap: ", ";\n\n ", "\n\n // title and subtitle element group\n [data-smart-element-group] {\n // gap between title and subtitle\n gap: 0.06rem;\n\n /* subtitle element group */\n > [data-smart-element-group] {\n > span {\n margin-right: ", ";\n }\n }\n }\n"])), blockGap, separatorCss, elementGap);
|
|
23
|
-
export var metadataBlockCss = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n gap: 0px;\n\n /* primary element group */\n [data-smart-element-group]:nth-of-type(1) {\n flex-grow: 7;\n\n // a separator between text-based element\n ", "\n\n /* horizontal spacing between elements in group */\n > span {\n margin-right: ", ";\n }\n }\n /* secondary element group */\n [data-smart-element-group]:nth-of-type(2) {\n flex-grow: 3;\n /* horizontal spacing between elements in group */\n > span {\n margin-left: ", ";\n }\n }\n"])), separatorCss, elementGap, elementGap);
|
|
24
|
-
export var footerBlockCss = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding-top: 0.25rem;\n"])));
|
|
25
|
-
export var loadingViewContainer = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n"])));
|
|
26
|
-
export var skeletonContainer = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 0.625rem;\n align-items: center;\n"])));
|
|
27
|
-
export var hiddenSnippetStyles = css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n visibility: hidden;\n position: absolute;\n"])));
|
|
28
23
|
export var getTransitionStyles = function getTransitionStyles(snippetHeight) {
|
|
29
|
-
return css(
|
|
24
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n transition: height 300ms ease-in-out;\n height: ", "px;\n"])), snippetHeight);
|
|
30
25
|
};
|