@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
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.titleBlockCss = exports.
|
|
8
|
+
exports.titleBlockCss = exports.separatorCss = exports.getTransitionStyles = exports.flexibleUiOptions = exports.HoverCardContainer = exports.CARD_WIDTH_REM = exports.CARD_GAP_PX = void 0;
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ var _index = require("../../index");
|
|
|
15
15
|
|
|
16
16
|
var _constants = require("../../constants");
|
|
17
17
|
|
|
18
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4
|
|
18
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
19
19
|
|
|
20
20
|
var flexibleUiOptions = {
|
|
21
21
|
hideElevation: true,
|
|
@@ -33,23 +33,14 @@ exports.CARD_GAP_PX = CARD_GAP_PX;
|
|
|
33
33
|
var blockGap = '0.5rem';
|
|
34
34
|
var elementGap = '0.5rem';
|
|
35
35
|
var separatorCss = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n [data-separator] + [data-separator]:before {\n margin-right: ", ";\n }\n"])), elementGap);
|
|
36
|
+
exports.separatorCss = separatorCss;
|
|
36
37
|
var HoverCardContainer = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\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, _index.loadingPlaceholderClassName);
|
|
37
38
|
exports.HoverCardContainer = HoverCardContainer;
|
|
38
39
|
var titleBlockCss = (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\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);
|
|
39
40
|
exports.titleBlockCss = titleBlockCss;
|
|
40
|
-
var metadataBlockCss = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\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);
|
|
41
|
-
exports.metadataBlockCss = metadataBlockCss;
|
|
42
|
-
var footerBlockCss = (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n padding-top: 0.25rem;\n"])));
|
|
43
|
-
exports.footerBlockCss = footerBlockCss;
|
|
44
|
-
var loadingViewContainer = (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n"])));
|
|
45
|
-
exports.loadingViewContainer = loadingViewContainer;
|
|
46
|
-
var skeletonContainer = (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: column;\n gap: 0.625rem;\n align-items: center;\n"])));
|
|
47
|
-
exports.skeletonContainer = skeletonContainer;
|
|
48
|
-
var hiddenSnippetStyles = (0, _react.css)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n visibility: hidden;\n position: absolute;\n"])));
|
|
49
|
-
exports.hiddenSnippetStyles = hiddenSnippetStyles;
|
|
50
41
|
|
|
51
42
|
var getTransitionStyles = function getTransitionStyles(snippetHeight) {
|
|
52
|
-
return (0, _react.css)(
|
|
43
|
+
return (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n transition: height 300ms ease-in-out;\n height: ", "px;\n"])), snippetHeight);
|
|
53
44
|
};
|
|
54
45
|
|
|
55
46
|
exports.getTransitionStyles = getTransitionStyles;
|
|
@@ -45,6 +45,8 @@ var _IconAndTitleLayout = require("../IconAndTitleLayout");
|
|
|
45
45
|
|
|
46
46
|
var _styled = require("../styled");
|
|
47
47
|
|
|
48
|
+
var _HoverCard = require("../../HoverCard");
|
|
49
|
+
|
|
48
50
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
49
51
|
|
|
50
52
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -108,8 +110,11 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
|
|
|
108
110
|
onClick = _this$props2.onClick,
|
|
109
111
|
isSelected = _this$props2.isSelected,
|
|
110
112
|
_this$props2$testId = _this$props2.testId,
|
|
111
|
-
testId = _this$props2$testId === void 0 ? 'inline-card-unauthorized-view' : _this$props2$testId
|
|
112
|
-
|
|
113
|
+
testId = _this$props2$testId === void 0 ? 'inline-card-unauthorized-view' : _this$props2$testId,
|
|
114
|
+
_this$props2$showAuth = _this$props2.showAuthTooltip,
|
|
115
|
+
showAuthTooltip = _this$props2$showAuth === void 0 ? false : _this$props2$showAuth;
|
|
116
|
+
|
|
117
|
+
var inlineCardUnauthenticatedView = /*#__PURE__*/_react.default.createElement(_Frame.Frame, {
|
|
113
118
|
testId: testId,
|
|
114
119
|
link: url,
|
|
115
120
|
onClick: onClick,
|
|
@@ -119,6 +124,15 @@ var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
|
|
|
119
124
|
title: this.renderMessage(),
|
|
120
125
|
titleColor: (0, _tokens.token)('color.text.subtle', _colors.N500)
|
|
121
126
|
}));
|
|
127
|
+
|
|
128
|
+
if (showAuthTooltip) {
|
|
129
|
+
return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
|
|
130
|
+
url: url,
|
|
131
|
+
onAuthorize: this.props.onAuthorise
|
|
132
|
+
}, inlineCardUnauthenticatedView);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return inlineCardUnauthenticatedView;
|
|
122
136
|
}
|
|
123
137
|
}]);
|
|
124
138
|
return InlineCardUnauthorizedView;
|
|
@@ -75,7 +75,8 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
75
75
|
onError = _ref.onError,
|
|
76
76
|
testId = _ref.testId,
|
|
77
77
|
inlinePreloaderStyle = _ref.inlinePreloaderStyle,
|
|
78
|
-
showHoverPreview = _ref.showHoverPreview
|
|
78
|
+
showHoverPreview = _ref.showHoverPreview,
|
|
79
|
+
showAuthTooltip = _ref.showAuthTooltip;
|
|
79
80
|
var status = cardState.status,
|
|
80
81
|
details = cardState.details;
|
|
81
82
|
var cardDetails = details && details.data || (0, _jsonld.getEmptyJsonLd)();
|
|
@@ -127,7 +128,8 @@ var InlineCard = function InlineCard(_ref) {
|
|
|
127
128
|
isSelected: isSelected,
|
|
128
129
|
onClick: handleFrameClick,
|
|
129
130
|
onAuthorise: handleAuthorize,
|
|
130
|
-
testId: testIdWithStatus
|
|
131
|
+
testId: testIdWithStatus,
|
|
132
|
+
showAuthTooltip: showAuthTooltip
|
|
131
133
|
});
|
|
132
134
|
|
|
133
135
|
case 'forbidden':
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _reactIntlNext = require("react-intl-next");
|
|
15
|
+
|
|
16
|
+
var _messages = require("../../messages");
|
|
17
|
+
|
|
18
|
+
var _constants = require("../../constants");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This component is used in unauthorized views of a smart link.
|
|
22
|
+
* It represents the main text that provides a user with information on how to connect their account
|
|
23
|
+
*/
|
|
24
|
+
var UnauthorisedViewContent = function UnauthorisedViewContent(_ref) {
|
|
25
|
+
var providerName = _ref.providerName,
|
|
26
|
+
_ref$testId = _ref.testId,
|
|
27
|
+
testId = _ref$testId === void 0 ? 'unauthorised-view-content' : _ref$testId;
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.messages.connect_unauthorised_account_description, {
|
|
29
|
+
values: {
|
|
30
|
+
context: providerName
|
|
31
|
+
}
|
|
32
|
+
})), ' ', /*#__PURE__*/_react.default.createElement("a", {
|
|
33
|
+
href: _constants.CONTENT_URL_SECURITY_AND_PERMISSIONS,
|
|
34
|
+
target: "_blank",
|
|
35
|
+
"data-testid": "".concat(testId, "-learn-more")
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.learn_more_about_smart_links_security)));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var _default = UnauthorisedViewContent;
|
|
40
|
+
exports.default = _default;
|
package/dist/es2019/version.json
CHANGED
|
@@ -54,6 +54,8 @@ export function CardWithUrlContent({
|
|
|
54
54
|
showHoverPreview = Boolean(showHoverPreviewFlag);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
const showAuthTooltipValue = useFeatureFlag('showAuthTooltip');
|
|
58
|
+
const showAuthTooltip = !!showAuthTooltipValue && showAuthTooltipValue === 'experiment';
|
|
57
59
|
const enableFlexibleBlockCardFlag = Boolean(useFeatureFlag('enableFlexibleBlockCard')); // Setup UI handlers.
|
|
58
60
|
|
|
59
61
|
const handleClick = useCallback(event => {
|
|
@@ -163,7 +165,8 @@ export function CardWithUrlContent({
|
|
|
163
165
|
onError: onError,
|
|
164
166
|
testId: testId,
|
|
165
167
|
inlinePreloaderStyle: inlinePreloaderStyle,
|
|
166
|
-
showHoverPreview: showHoverPreview
|
|
168
|
+
showHoverPreview: showHoverPreview,
|
|
169
|
+
showAuthTooltip: showAuthTooltip
|
|
167
170
|
});
|
|
168
171
|
|
|
169
172
|
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 const EmbedCardUnauthorisedView = ({
|
|
11
8
|
link,
|
|
12
9
|
context,
|
|
@@ -43,13 +40,8 @@ export const EmbedCardUnauthorisedView = ({
|
|
|
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": `${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
|
};
|
|
@@ -15,7 +15,8 @@ export const HoverCardComponent = ({
|
|
|
15
15
|
children,
|
|
16
16
|
url,
|
|
17
17
|
analyticsHandler,
|
|
18
|
-
analytics
|
|
18
|
+
analytics,
|
|
19
|
+
onAuthorize
|
|
19
20
|
}) => {
|
|
20
21
|
const delay = 300;
|
|
21
22
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -124,7 +125,8 @@ export const HoverCardComponent = ({
|
|
|
124
125
|
onActionClick: onActionClick,
|
|
125
126
|
onResolve: update,
|
|
126
127
|
renderers: renderers,
|
|
127
|
-
url: url
|
|
128
|
+
url: url,
|
|
129
|
+
onAuthorize: onAuthorize
|
|
128
130
|
})),
|
|
129
131
|
trigger: triggerProps => jsx("span", {
|
|
130
132
|
ref: parentSpan
|
|
@@ -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 const getOpenAction = (url, analytics, onActionClick) => ({
|
|
17
14
|
name: ActionName.CustomAction,
|
|
18
15
|
icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
@@ -32,18 +29,6 @@ export const getOpenAction = (url, analytics, onActionClick) => ({
|
|
|
32
29
|
},
|
|
33
30
|
testId: 'hover-card-open-button'
|
|
34
31
|
});
|
|
35
|
-
export const toFooterActions = (cardActions, onActionClick) => cardActions.map(action => ({
|
|
36
|
-
content: action.text,
|
|
37
|
-
name: ActionName.CustomAction,
|
|
38
|
-
onClick: () => {
|
|
39
|
-
if (onActionClick) {
|
|
40
|
-
onActionClick(action.id);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return action.invoke();
|
|
44
|
-
},
|
|
45
|
-
testId: action.id
|
|
46
|
-
}));
|
|
47
32
|
|
|
48
33
|
const HoverCardContent = ({
|
|
49
34
|
id = '',
|
|
@@ -53,23 +38,11 @@ const HoverCardContent = ({
|
|
|
53
38
|
onActionClick,
|
|
54
39
|
onResolve,
|
|
55
40
|
renderers,
|
|
56
|
-
url
|
|
41
|
+
url,
|
|
42
|
+
onAuthorize
|
|
57
43
|
}) => {
|
|
58
44
|
var _cardState$details;
|
|
59
45
|
|
|
60
|
-
const showActionableElement = useFeatureFlag('enableActionableElement');
|
|
61
|
-
const actions = useSmartCardActions(id, url, analytics);
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
actions.loadMetadata();
|
|
64
|
-
}, [actions]);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
// Since hover preview only render on resolved status,
|
|
67
|
-
// there is no need to check for statuses.
|
|
68
|
-
analytics.ui.renderSuccessEvent({
|
|
69
|
-
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
70
|
-
status: cardState.status
|
|
71
|
-
});
|
|
72
|
-
}, [analytics.ui, cardState.status]);
|
|
73
46
|
const extensionKey = useMemo(() => getExtensionKey(cardState.details), [cardState.details]);
|
|
74
47
|
const onClick = useCallback(event => {
|
|
75
48
|
const isModifierKeyPressed = isSpecialEvent(event);
|
|
@@ -82,35 +55,12 @@ const HoverCardContent = ({
|
|
|
82
55
|
});
|
|
83
56
|
}, [cardState.status, analytics.ui, id]);
|
|
84
57
|
const titleActions = useMemo(() => [getOpenAction(url, analytics, onActionClick)], [url, analytics, onActionClick]);
|
|
85
|
-
const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick), [cardActions, onActionClick]);
|
|
86
58
|
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
59
|
+
const types = data ? extractType(data) : undefined;
|
|
87
60
|
const {
|
|
88
|
-
primary,
|
|
89
|
-
secondary,
|
|
90
61
|
subtitle
|
|
91
|
-
} =
|
|
92
|
-
const types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
93
|
-
|
|
94
|
-
const metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
95
|
-
const primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
96
|
-
return {
|
|
97
|
-
primary,
|
|
98
|
-
secondary: metadata.secondary,
|
|
99
|
-
subtitle: metadata.subtitle
|
|
100
|
-
};
|
|
101
|
-
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]);
|
|
62
|
+
} = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
102
63
|
const titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
|
|
103
|
-
const snippetHeight = React.useRef(0);
|
|
104
|
-
const snippetBlockRef = useRef(null);
|
|
105
|
-
const onSnippetRender = useCallback(() => {
|
|
106
|
-
var _snippetBlockRef$curr, _snippetBlockRef$curr2;
|
|
107
|
-
|
|
108
|
-
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;
|
|
109
|
-
}, []);
|
|
110
|
-
const body = SnippetOrPreview({
|
|
111
|
-
data: data,
|
|
112
|
-
snippetHeight: snippetHeight.current
|
|
113
|
-
});
|
|
114
64
|
const titleBlockProps = {
|
|
115
65
|
actions: titleActions,
|
|
116
66
|
maxLines: titleMaxLines,
|
|
@@ -134,25 +84,27 @@ const HoverCardContent = ({
|
|
|
134
84
|
flexibleCardProps: flexibleCardProps,
|
|
135
85
|
titleBlockProps: titleBlockProps
|
|
136
86
|
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (cardState.status === 'unauthorized') {
|
|
90
|
+
return /*#__PURE__*/React.createElement(HoverCardUnauthorisedView, {
|
|
91
|
+
flexibleCardProps: flexibleCardProps,
|
|
92
|
+
onAuthorize: onAuthorize
|
|
93
|
+
});
|
|
137
94
|
} // if metadataStatus is 'errored' simply render using data available (normal path)
|
|
138
95
|
|
|
139
96
|
|
|
140
|
-
return /*#__PURE__*/React.createElement(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}), /*#__PURE__*/React.createElement(FooterBlock, {
|
|
152
|
-
actions: footerActions,
|
|
153
|
-
size: SmartLinkSize.Large,
|
|
154
|
-
overrideCss: footerBlockCss
|
|
155
|
-
}));
|
|
97
|
+
return /*#__PURE__*/React.createElement(HoverCardResolvedView, {
|
|
98
|
+
id: id,
|
|
99
|
+
url: url,
|
|
100
|
+
extensionKey: extensionKey,
|
|
101
|
+
analytics: analytics,
|
|
102
|
+
cardActions: cardActions,
|
|
103
|
+
cardState: cardState,
|
|
104
|
+
flexibleCardProps: flexibleCardProps,
|
|
105
|
+
onActionClick: onActionClick,
|
|
106
|
+
titleBlockProps: titleBlockProps
|
|
107
|
+
});
|
|
156
108
|
};
|
|
157
109
|
|
|
158
110
|
export default HoverCardContent;
|
|
@@ -0,0 +1,96 @@
|
|
|
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 const toFooterActions = (cardActions, onActionClick) => cardActions.map(action => ({
|
|
13
|
+
content: action.text,
|
|
14
|
+
name: ActionName.CustomAction,
|
|
15
|
+
onClick: () => {
|
|
16
|
+
if (onActionClick) {
|
|
17
|
+
onActionClick(action.id);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return action.invoke();
|
|
21
|
+
},
|
|
22
|
+
testId: action.id
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
const HoverCardResolvedView = ({
|
|
26
|
+
flexibleCardProps,
|
|
27
|
+
titleBlockProps,
|
|
28
|
+
analytics,
|
|
29
|
+
id = '',
|
|
30
|
+
url,
|
|
31
|
+
cardState,
|
|
32
|
+
cardActions = [],
|
|
33
|
+
onActionClick,
|
|
34
|
+
extensionKey
|
|
35
|
+
}) => {
|
|
36
|
+
var _cardState$details;
|
|
37
|
+
|
|
38
|
+
const showActionableElement = useFeatureFlag('enableActionableElement');
|
|
39
|
+
const actions = useSmartCardActions(id, url, analytics);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
actions.loadMetadata();
|
|
42
|
+
}, [actions]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
// Since this hover view is only rendered on resolved status,
|
|
45
|
+
// there is no need to check for statuses.
|
|
46
|
+
analytics.ui.renderSuccessEvent({
|
|
47
|
+
display: SMART_CARD_ANALYTICS_DISPLAY,
|
|
48
|
+
status: cardState.status
|
|
49
|
+
});
|
|
50
|
+
}, [analytics.ui, cardState.status]);
|
|
51
|
+
const footerActions = useMemo(() => toFooterActions(cardActions, onActionClick), [cardActions, onActionClick]);
|
|
52
|
+
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
53
|
+
const {
|
|
54
|
+
primary,
|
|
55
|
+
secondary
|
|
56
|
+
} = useMemo(() => {
|
|
57
|
+
const types = data ? extractType(data) : undefined; //TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
58
|
+
|
|
59
|
+
const metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
|
|
60
|
+
const primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
|
|
61
|
+
return {
|
|
62
|
+
primary,
|
|
63
|
+
secondary: metadata.secondary,
|
|
64
|
+
subtitle: metadata.subtitle
|
|
65
|
+
};
|
|
66
|
+
}, [cardActions, data, extensionKey, onActionClick, showActionableElement]);
|
|
67
|
+
const snippetHeight = React.useRef(0);
|
|
68
|
+
const snippetBlockRef = useRef(null);
|
|
69
|
+
const onSnippetRender = useCallback(() => {
|
|
70
|
+
var _snippetBlockRef$curr, _snippetBlockRef$curr2;
|
|
71
|
+
|
|
72
|
+
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;
|
|
73
|
+
}, []);
|
|
74
|
+
const body = SnippetOrPreview({
|
|
75
|
+
data: data,
|
|
76
|
+
snippetHeight: snippetHeight.current
|
|
77
|
+
});
|
|
78
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, flexibleCardProps, /*#__PURE__*/React.createElement(TitleBlock, titleBlockProps), /*#__PURE__*/React.createElement(MetadataBlock, {
|
|
79
|
+
primary: primary,
|
|
80
|
+
secondary: secondary,
|
|
81
|
+
size: SmartLinkSize.Large,
|
|
82
|
+
overrideCss: metadataBlockCss,
|
|
83
|
+
maxLines: 1
|
|
84
|
+
}), body, /*#__PURE__*/React.createElement(SnippetBlock, {
|
|
85
|
+
testId: 'hidden-snippet',
|
|
86
|
+
onRender: onSnippetRender,
|
|
87
|
+
blockRef: snippetBlockRef,
|
|
88
|
+
overrideCss: hiddenSnippetStyles
|
|
89
|
+
}), /*#__PURE__*/React.createElement(FooterBlock, {
|
|
90
|
+
actions: footerActions,
|
|
91
|
+
size: SmartLinkSize.Large,
|
|
92
|
+
overrideCss: footerBlockCss
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default HoverCardResolvedView;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { separatorCss } from '../../../styled';
|
|
3
|
+
const elementGap = '0.5rem';
|
|
4
|
+
export const metadataBlockCss = css`
|
|
5
|
+
gap: 0px;
|
|
6
|
+
|
|
7
|
+
/* primary element group */
|
|
8
|
+
[data-smart-element-group]:nth-of-type(1) {
|
|
9
|
+
flex-grow: 7;
|
|
10
|
+
|
|
11
|
+
// a separator between text-based element
|
|
12
|
+
${separatorCss}
|
|
13
|
+
|
|
14
|
+
/* horizontal spacing between elements in group */
|
|
15
|
+
> span {
|
|
16
|
+
margin-right: ${elementGap};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/* secondary element group */
|
|
20
|
+
[data-smart-element-group]:nth-of-type(2) {
|
|
21
|
+
flex-grow: 3;
|
|
22
|
+
/* horizontal spacing between elements in group */
|
|
23
|
+
> span {
|
|
24
|
+
margin-left: ${elementGap};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
export const footerBlockCss = css`
|
|
29
|
+
padding-top: 0.25rem;
|
|
30
|
+
`;
|
|
31
|
+
export const hiddenSnippetStyles = css`
|
|
32
|
+
visibility: hidden;
|
|
33
|
+
position: absolute;
|
|
34
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/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
|
const HoverCardLoadingView = ({
|
|
10
11
|
flexibleCardProps,
|
|
@@ -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
|
+
const HoverCardUnauthorisedView = ({
|
|
15
|
+
flexibleCardProps,
|
|
16
|
+
testId = 'hover-card-unauthorised-view',
|
|
17
|
+
onAuthorize
|
|
18
|
+
}) => {
|
|
19
|
+
var _cardState$details, _extractProvider;
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
cardState
|
|
23
|
+
} = flexibleCardProps;
|
|
24
|
+
const data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
|
|
25
|
+
const providerName = (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text;
|
|
26
|
+
const actions = useMemo(() => onAuthorize ? [{
|
|
27
|
+
name: ActionName.CustomAction,
|
|
28
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_action, {
|
|
29
|
+
values: {
|
|
30
|
+
context: providerName
|
|
31
|
+
}
|
|
32
|
+
})),
|
|
33
|
+
onClick: onAuthorize
|
|
34
|
+
}] : [], [onAuthorize, providerName]);
|
|
35
|
+
return /*#__PURE__*/React.createElement(FlexibleCard, _extends({}, flexibleCardProps, {
|
|
36
|
+
testId: testId
|
|
37
|
+
}), /*#__PURE__*/React.createElement(CustomBlock, {
|
|
38
|
+
overrideCss: titleBlockStyles,
|
|
39
|
+
testId: `${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: `${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: `${testId}-button`
|
|
52
|
+
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
53
|
+
items: actions,
|
|
54
|
+
appearance: "primary"
|
|
55
|
+
})));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default HoverCardUnauthorisedView;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
const blockGap = '0.5rem';
|
|
3
|
+
const iconGap = '0.5rem';
|
|
4
|
+
const titleFontWeight = '500';
|
|
5
|
+
export const connectButtonStyles = css`
|
|
6
|
+
justify-content: flex-end;
|
|
7
|
+
margin-top: ${blockGap};
|
|
8
|
+
`;
|
|
9
|
+
export const titleBlockStyles = css`
|
|
10
|
+
gap: ${blockGap} ${iconGap};
|
|
11
|
+
a {
|
|
12
|
+
font-weight: ${titleFontWeight};
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
export const mainTextStyles = css`
|
|
16
|
+
margin-top: ${blockGap};
|
|
17
|
+
font-size: 0.75rem;
|
|
18
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|